Skip to content

refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates - #4774

Merged
thymikee merged 7 commits into
mainfrom
t3/q1q5-runner-error-table-reason-guards
Nov 20, 2026
Merged

thymikee merged 7 commits into
mainfrom
t3/q1q5-runner-error-table-reason-guards

Conversation

@thymikee

@thymikee thymikee commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Runner error codes were declared four times in packages/apple-runner/src/runner-contract.ts (parallel maps plus a hand-written union), and the Swift runner emitted many of them as loose string literals. That split silently: a constant no emitter used, or a literal no table knew, both passed CI.

One table, RUNNER_ERROR_CODES (29 rows), now owns the reason union, the code-constant types, and classification. In Swift every emitter routes through its RunnerWireErrorCode / RunnerPassThroughErrorCode constant. Classification output is unchanged, so there is no protocol bump. Scope: two doc gaps fixed in commands.md; the untyped-reason ratchet was split out to #4779 (merged).

Repo guards enforce the closure:

  • The TS table and the Swift enum match 1:1, and every declared Swift constant is emitted.
  • Every UPPER_SNAKE literal in production runner Swift is accounted for by value and file: a family code, a declared raw-value case, an NSLog/environment name, or a waived (file, literal) pair.
  • Every exported published-reason table is documented.

Validation

Tested head: de9abdd (base 115c83a).

  • Full iOS XCTest suite, run 44706252033 at 4fb6050: 741 tests, 0 failures. The commits since change two TS classifiers, one Swift comment, and the guard.
  • Local at de9abdd: repo-guards and apple-runner 1,137 tests pass; pnpm typecheck and lint pass.
  • CI owns the full gate for this head.
  • Risk: the pass-through list is the one judgement call. It holds codes no host path classifies, and the guard pins it so it cannot grow silently.

🤖 Generated with Claude Code

@thymikee

Copy link
Copy Markdown
Member Author

The runner error table in 2a71119 is a good direction, but the parity guard does not check what the runner actually emits, so the gate this PR describes does not hold yet. The PR also has merge conflicts with main. Nothing in CI has failed so far.

The guard in runner-error-code-parity.test.ts compares RUNNER_ERROR_CODES with the static let constants of Swift RunnerWireErrorCode. The runner does not emit through that enum: the 13 constants this PR adds are referenced nowhere. Emitters write raw literals, for example "INVALID_ARGS" and "RUNNER_BUSY" in RunnerTests+CommandDispatch.swift, and "ELEMENT_NOT_FOUND" and "ALERT_NOT_FOUND" in RunnerTests+CommandExecution.swift. The runner also emits 8 codes that neither side declares (TEXT_INPUT_NOT_FOCUSED, IOS_SNAPSHOT_PROJECTION_MISMATCH, TEXT_ENTRY_MISMATCH, four TEXT_INPUT_* codes, XCTEST_RECORDED_FAILURE). So a runner change that adds or renames a refusal code through ErrorPayload(code: "NEW") still passes the guard, and the TS side silently falls back to the unknown path. The rule should be: every code the runner can put on the wire is declared once in Swift, and that set equals the RUNNER_ERROR_CODES keys. Either route every emitter (ErrorPayload code: and the RunnerAppScreenCapture raw values) through RunnerWireErrorCode and make the guard reject UPPER_SNAKE code: literals in non-test runner Swift, or point the guard at the emitted literals and drop the unused constants. The 8 undeclared codes then need rows or an explicit pass-through declaration, or the title claim should be narrower.

Not blocking, and fine to take or leave: R87 is already taken on main by unique-exported-type-names (#4757), so untyped-reason-ratchet.ts should become R88, and the scripts/layering/check.ts conflict is two rule ids appended at the same place, so keep both. RunnerErrorCodeConstant is a hand-kept union of 9 constants that omits COMMAND_ALREADY_FINISHED_RUNNER_CODE, RUNNER_WEDGED_RUNNER_CODE and three internal ones, and RUNNER_SCREEN_CAPTURE_REFUSAL_RUNNER_CODES still repeats the four APP_SCREEN_* rows, so both could be derived from the table keys. hasRunnerBusyCode and isRunnerMainThreadTimeoutError in runner-error-classification.ts now index the table through a cast and skip the Object.hasOwn guard in runnerErrorCodeRow(), which they could call instead. dispatched: 'yes' is allowed by the types and mapped to unknown, but no row uses it, and RunnerErrorCodeRow and RunnerReportedErrorReason are newly exported without importers. The R87 ratchet is unrelated to the runner table, it counts per package so removing one site and adding another passes, and it treats declarations inside function bodies as declared vocabulary, so it fits better in its own PR.

Could the PR keep the table and the derived reason union, derive the remaining per-code constants and the capture-refusal set from the table keys, and replace the enum-vs-table test with one that reads the codes the runner actually emits? That would also let the 13 unused Swift constants go unless emitters use them. Before merge, please rebase on main to clear the conflict and the R87 clash, decide whether the 8 emitted pass-through codes get rows or a pass-through declaration, and fix the guard.

The old maps match the new table row by row. Whether the 8 undeclared codes are kernel codes that toAppErrorCode passes through was not checked; their classification is unchanged by this PR either way.

@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Fixed on 9ede2c643c + 503b8fe373 (rebased, ratchet split out). Chose your first option — route every emitter through the enums and have the guard reject raw literals — because the guard is worth more as a closure over what the runner emits than as a check that two declaration lists agree.

The guard now reads what the runner emits (runner-error-code-parity.test.ts), scanning the production UITests files (UnitTests/ excluded) and checking four things: table keys ≡ RunnerWireErrorCode 1:1; the pass-through list ≡ RunnerPassThroughErrorCode 1:1; every declared Swift constant is referenced outside its enum — the dead-constant half is what made the old gate rubber-stamp, so a constant added back without an emitter fails; and no production file writes an UPPER_SNAKE code literal on a wire-code line, which is the ErrorPayload(code: "NEW") hole. Negative tests cover a deleted Swift constant and an invented emit-site literal.

13 dead constants are now load-bearing. Every raw literal routes through its constant: INVALID_ARGS (14 sites), RUNNER_BUSY, RUNNER_WEDGED, OBSERVATION_UNAVAILABLE, ELEMENT_NOT_FOUND, ELEMENT_OFFSCREEN, AMBIGUOUS_MATCH, ALERT_NOT_FOUND, SCROLL_KEYBOARD_OCCLUDES_SURFACE (ScrollViewportPolicy.occlusionRunnerCode now names the constant), and the four APP_SCREEN_* + five TEXT_INPUT_* codes, which keep their String rawValue for the UnitTests/ assertions but emit through a wireCode property. 35 replacements + 8 rawValue→wireCode; a constant-resolving diff check proves every wire string is byte-identical, and xcodebuild build-for-testing succeeds.

The undeclared codes get an explicit pass-through declaration, and they are 15, not 8. Your four TEXT_INPUT_* plus a fifth (TEXT_INPUT_SYNTHESIS_BUDGET_EXCEEDED), TEXT_ENTRY_MISMATCH, XCTEST_RECORDED_FAILURE, the two alert codes, and the five-code IOS_SNAPSHOT_*/IOS_TREE_CAPTURE_TIMEOUT family (which reaches the wire from RunnerTests+Snapshot*.swift and the snapshot-presentation library). The answer to your closing question: they are not kernel codes — none is in KNOWN_APP_ERROR_CODES, and toAppErrorCode passes a runner code through verbatim as the command's AppError.code, so they travel as unclassified top-level codes today; the pass-through list states that instead of leaving it implicit. Classification is unchanged for all of them. The declaration lives in the guard (nothing on the host branches on these, so a production table would be vocabulary no production code reads — check:production-exports would rightly flag it), with the Swift enum as the half the emitters use and the guard test tying them 1:1.

Not blocking, taken: rebased on main with the check.ts conflict resolved by keeping both rule ids; RunnerErrorCodeConstant and the capture-refusal set are derived from the table keys (RunnerTableErrorCode, and the set is typed ReadonlySet<RunnerTableErrorCode> after the table); hasRunnerBusyCode and isRunnerMainThreadTimeoutError both call runnerErrorCodeRow() now; dispatched is 'no' | 'unknown' (the dead 'yes' and its mapping are gone); the ratchet is #4779, numbered R89 (R87 is on main, R88 is #4766's race ratchet).

One consequence of deriving instead of hand-listing: deleting RunnerErrorCodeConstant removed the only non-test consumer of eight exported code constants, so they became dead production exports (check:production-exports went red). They are deleted, with their doc prose moved onto the table rows that own the codes — which also puts the facts next to the classification they describe. RunnerErrorCodeRowView and RunnerReportedErrorReason stay exported; they have in-file consumers (ignoreExportsUsedInFile covers them). RUNNER_SCREEN_CAPTURE_REFUSAL_RUNNER_CODES was already test-only on main, and ALERT_BUTTON_NOT_FOUND_RUNNER_CODE lost its last consumer when the union went away; both go.

New head: c396dd9.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.43 MB 6.43 MB +4.3 kB
Package (unpacked) 6.43 MB 6.43 MB +4.3 kB
Package (download) 1.95 MB 1.95 MB +533 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 19.2 ms 22.4 ms +3.3 ms
CLI --help 42.4 ms 48.1 ms +5.7 ms

@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the t3/q1q5-runner-error-table-reason-guards branch from c396dd9 to fba58d6 Compare November 19, 2026 20:56
@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at fba58d6 (reviewed at c396dd9; the only tree change since is a test constant moved inside its test), and the findings from the earlier review (#4774 (comment)) are fixed. CI was green on c396dd9 with 20 checks, and the Swift runner build lanes cover the constant swaps. There are no conflicts. Your guard run and the runner build cover the constant swaps.

Not blocking, and you can take or leave these: swiftEmittedCodeLiterals in runner-source-assertions.ts only matches lowercase code-style assignments, so static let fooErrorCode = "NEW", return "NEW" in a computed wireCode, and a new raw-value case in RunnerAppScreenCaptureFailure or TextEntryFailure all pass the guard and reach the host as an unclassified code. The rule to enforce is that no UPPER_SNAKE code string appears in production runner Swift outside the two enum bodies, except the family codes. Matching [cC]ode\b\s*[:=] and return "UPPER_SNAKE" lines would cover it, as would dropping the : String raw values from those two failure enums and asserting wireCode in the unit tests. The RunnerHttpRequestFraming.swift exemption could also shrink to its two framing codes. Separately, the comment in RunnerTests+SnapshotPresentationInvariant.swift says a library-side change to SnapshotPresentationFailure.code shows up in the parity guard, but the guard only reads the UITests directory. Rewording it to say the bridge ignores failure.code and emits the runner constant would fix that.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 19, 2026
@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the t3/q1q5-runner-error-table-reason-guards branch from fba58d6 to e678e6b Compare November 19, 2026 21:09
@thymikee

Copy link
Copy Markdown
Member Author

All three optional items taken, at e678e6b284.

Widened literal scan. The scan now classifies every code-position literal by kind (swiftCodeLiteralSites in runner-source-assertions.ts): emit (a code:/errorCode:/wireCode:/lifecycleErrorCode: argument), binding (let/var — including static let — or return whose value is the literal), and rawValue (case x = "CODE"). Emit and binding positions take only the three family codes: a static let hoisted = "NEW" or return "SNEAKED" fails the guard the same way code: "NEW" does — the fixture test pins both. Raw-value cases are the exception Swift forces (a raw value must be a literal), so their rule is closure instead: case clearNotObserved = "TEXT_INPUT_CLEAR_NOT_OBSERVED" passes because the code is declared vocabulary; case x = "RAW_REFUSAL" fails. That covers the two refusal enums' literal rawValues — which stay, because UnitTests/ asserts on them and init(rawValue:) decoding needs the String — while wireCode remains the only route to the wire. Comment text is stripped before matching (NSLog marks like AGENT_DEVICE_RUNNER_LISTENER_READY are logs, not codes). RunnerTests.swift's declaration-enum bodies are blanked before its scan: those static let lines ARE the vocabulary. Head measures zero offenders.

Framing exemption narrowed from per-file to per-(file, code): only UNAUTHORIZED and INVALID_ARGS are waived in RunnerHttpRequestFraming.swift; a third code there now fails.

Bridge comment reworded. It claimed the parity guard keeps the library's literal and the runner constant equal — it doesn't: the bridge drops failure.code and emits the constant, so the library string never reaches the guard. The comment now says what holds: the library owns WHEN the refusal happens, the parity guard owns the code the caller sees.

Validation at this head: repo-guards 155 pass, tsc clean, oxfmt/oxlint clean, check:packaged-runner-swift ok (71 files parse).

@thymikee
thymikee force-pushed the t3/q1q5-runner-error-table-reason-guards branch from e678e6b to 500d0b5 Compare November 19, 2026 21:17
@thymikee

Copy link
Copy Markdown
Member Author

Still ready at 500d0b5. The change since fba58d6 applies the optional items: the parity guard now also catches UPPER_SNAKE codes in static let, return "..." and raw-value enum cases, the framing exemption is narrowed to its two codes, and the SnapshotPresentationInvariant comment now says the bridge drops the library literal. Production code is unchanged apart from that comment, and the label stays.

@apex-sentinel-staging

This comment has been minimized.

Replace the four parallel structures in runner-contract.ts (diagnostic-only
set, wire-code overrides, published reasons, dispatch disclosure) plus the
hand-written RunnerReportedErrorReason union with a single
RUNNER_ERROR_CODES table: one 'as const satisfies' row per runner error code,
holding dispatched, an optional reason and an optional diagnosticOnly
(retriable / wireCode). The reason union is derived from the table, and
classifyRunnerReportedError plus runner-error-classification.ts read the one
row through runnerErrorCodeRow(), so classification output is byte-identical
(no wire impact: no protocol bump, no ledger change). The remaining code
constants are typed RunnerTableErrorCode = keyof typeof RUNNER_ERROR_CODES, so
a constant naming no row fails to compile, and dispatched holds only the two
verdicts the wire publishes.

The constants and sets that existed only to name a code for the deleted union
go with it: eight code constants, the capture-refusal set, and
ALERT_BUTTON_NOT_FOUND_RUNNER_CODE were exported with no production reader.
Their docs move onto the table rows that own the codes, beside the
classification each one describes.

On the Swift side the runner's wire vocabulary becomes closed: 29 table codes
as RunnerWireErrorCode constants that the emitters now actually use (raw
"INVALID_ARGS" / "RUNNER_BUSY" / "ELEMENT_NOT_FOUND" literals and the parallel
rawValue enums route through them), plus RunnerPassThroughErrorCode for the
15 codes the host does not classify (TEXT_INPUT_*, IOS_SNAPSHOT_*, the alert
pair, TEXT_ENTRY_MISMATCH, XCTEST_RECORDED_FAILURE). Every code on the wire
comes from one of those two enums or a top-level COMMAND_FAILED /
UNSUPPORTED_OPERATION / UNAUTHORIZED literal. No string value changes.
@thymikee
thymikee force-pushed the t3/q1q5-runner-error-table-reason-guards branch from 500d0b5 to 684ea23 Compare November 20, 2026 07:04
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 684ea23. The verdict and the full list are in the summary comment.

…yped reason literals

- test/repo-guards/runner-error-code-parity.test.ts: exact 1:1 key parity
  between RUNNER_ERROR_CODES and the Swift RunnerWireErrorCode enum (oxc for
  the table, regex for the Swift constants), with a negative test proving
  that deleting a Swift constant fails the guard.
- test/repo-guards/runner-refusal-reason-docs.test.ts: generalize the docs
  guard to every exported typed published-reason table (RUNNER_ERROR_CODES,
  PRE_DISPATCH_REFUSAL_REASONS, WAIT_REASONS, DeviceClaimConflictReason); each
  reason must be documented in commands.md (and cli-help where required).
  commands.md gains the missing entries (wait_runner_restart_exhausted,
  DEVICE_CLAIM_* conflict reasons).
- scripts/layering rule R87 (untyped-reason-literals): count-only ratchet on
  untyped reason: '<literal>' occurrences per package against the merge-base
  with origin/main; holds no name list — typed means inside a declaration's
  initializer spine. Registered in LAYERING_RULES and measured via
  ratchet-reference.ts, with a unit test.
@thymikee
thymikee force-pushed the t3/q1q5-runner-error-table-reason-guards branch from 684ea23 to 42abfea Compare November 20, 2026 07:26
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks for the update. At 42abfea the table and the Swift swaps still look right, and multi-line positions are now scanned: var code: String { "NEW_REFUSAL" } is measured as an emit site, and that the per-(file, code) waiver in RunnerHttpRequestFraming.swift is really per code. All 20 checks pass, and this delta only touches the parity guard and its test, so no job's production route is exercised by it.

What is still missing is live evidence. The PR's counts (repo-guards 155, parity guard 7/7, apple-runner 982, TEST BUILD SUCCEEDED) are author-reported. No lane that runs the runner's XCTest assertions on response.error?.code is reported at head, and that is the check that each constant is wired to the right emitter. Please attach a run of that lane at 42abfea, or point to the job that covers it.

The open thread about multi-line emit positions (#4774 (comment)) is fixed at 42abfea and can be resolved. No other review threads are open.

Not blocking, and you can take or leave these: the openness rule at runner-source-assertions.ts:134 still drops a code value that is wrapped after ??, +, a nested call like lookup(, or an array literal (ErrorPayload(code: resolve( then "NEW_CODE") ships an unclassified code); the close rule at :135 leaves a window open after a bare return, so a new NSLog("AGENT_DEVICE_RUNNER_NEW_DIAGNOSTIC_MARK") at RunnerTests+TextEntry.swift:735 is reported as an offender; the code-label list is spelled twice, at :113 and :133, so a new label would be classified by one regex and not the other; RUNNER_PROTOCOL.md:375 still names the deleted DIAGNOSTIC_ONLY_RUNNER_ERROR_CODES and RUNNER_REPORTED_ERROR_REASONS tables (it should point at RUNNER_ERROR_CODES and runnerErrorCodeRow), and the comment at RunnerHttpRequestFraming.swift:29-31 says the parity guard skips that file when it now scans it under a waiver; and runnerErrorCodeRow(details.runnerErrorCode as string | undefined) at runner-error-classification.ts:81 and the same cast at :717 could go away with one lookup that takes AppErrorDetails.

Could the guard get smaller instead? Keep the single table and the value-identical Swift swaps. Then measure every UPPER_SNAKE literal in production runner Swift and pass it only if it sits in an enumerated exempt location: the declaration enum bodies, the raw-value enum bodies, or a WAIVED_LITERALS (file, code) pair. The scanner already collects every literal, so this is one membership test and the openness state machine and position kinds are not needed. No wrap style could then hide a literal, and no sibling statement after a return would be scanned by mistake. It needs nothing new first, because the emitters already route through constants.

Before merge, please attach the XCTest lane result at 42abfea. The notes above are worth folding in while you are there.

@thymikee thymikee removed the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
thymikee and others added 2 commits November 20, 2026 09:54
… stale references

runnerErrorCodeRow takes the details value as it arrives, so its two
callers drop their casts. RUNNER_PROTOCOL.md and the HTTP framing comment
named tables and a guard skip that no longer exist.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The closed-vocabulary guard tracked which syntactic position a literal sat
in, across lines. A code wrapped after ??, +, a nested call or an array
escaped it, and a window left open after a bare return flagged unrelated
log marks. It now measures every UPPER_SNAKE literal and passes one only
as a family code, a declared raw-value case, the log/env namespace, or a
waived (file, literal) pair.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 4fb6050. The verdict and the full list are in the summary comment.

@thymikee

Copy link
Copy Markdown
Member Author

New head 4fb605037a (two commits on top of 42abfea).

1. Evidence. 84 XCTest cases assert on response.error?.code. PR lanes run only part of them, so I dispatched the full suite on this head:

  • XCTest Nightly, run 44706252033 at 4fb605037a: iPhone full suite executed 741 tests, 2 skipped, 0 failures; iPad sole-screen leg passed. 83 of the 84 code-asserting tests passed there.
  • The remaining one, testPasteboardWriteIsUnsupportedWithoutAUIKitPasteboard, is macOS-only and passed in the Smoke Tests (macos) host lane (434 tests, 0 failures at 42abfea; the lane is green again at this head).

2. Smaller guard: done. The openness state machine and position kinds are deleted. The guard measures every UPPER_SNAKE literal in production runner Swift (comments removed with the repo's lexical strip-swift-comments) and passes one only as a family code, a raw-value case that spells declared vocabulary, or a WAIVED_LITERALS (file, literal) pair. The declaration enum bodies are blanked first. A fixture pins both holes: a code wrapped after ?? inside lookup([...]) is caught, and nothing is scanned by position after a bare return. A waived pair that no source spells any more also fails.

One deviation: literals starting with AGENT_DEVICE_ (NSLog marks, environment names) pass by prefix, and the guard asserts no declared code uses that prefix. Without it the list is about 40 pairs instead of 24 and every new log mark needs a guard edit. Say if you prefer pairs.

3. Also.

  • Code-label list: both regexes are gone, so nothing is spelled twice.
  • RUNNER_PROTOCOL.md now points at RUNNER_ERROR_CODES rows and runnerErrorCodeRow.
  • The RunnerHttpRequestFraming.swift comment says the file is scanned under a waiver.
  • runnerErrorCodeRow takes the details value as it arrives; both casts are removed.
  • The multi-line thread was already resolved.

Local: repo-guards + apple-runner 1,137 tests pass, typecheck passes. Guard files are net −29 lines.

@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 4fb6050. The code looks correct, and the earlier review's open point is now fixed: the guard measures each literal by value and file, so a code wrapped after ??, inside a nested call or in an array literal now fails, and a third code in RunnerHttpRequestFraming.swift still fails. The guard was probed against the 71 Swift files at this head; the test counts in the PR body are author-reported. All 19 checks at this exact commit are green, including Repo Guards & Compatibility, both Smoke Test lanes and the two XCTest jobs, and there are no conflicts.

Not blocking, and fine to take or leave: the AGENT_DEVICE_ pass in runner-error-code-parity.test.ts lets ErrorPayload(code: "AGENT_DEVICE_NEW_REFUSAL") through with no row, so the guard should accept that prefix only in the files that own marks and env names, or the header at :25-27 should state the exception; the comment at RunnerHttpRequestFraming.swift:31 says the guard waives "exactly these literals" but it also waives "POST" in that file; the row read at runner-contract.ts:459 takes unknown and casts inside, so a typo'd details key compiles and reads as no row, which a typed runnerErrorCode field on the error details would avoid; and one assert that no two RUNNER_ERROR_CODES rows share a reason would pin the reason-keyed lookup.

Of the other open threads, the one on the guard's literal position classifier is fixed at this head and can be resolved. The one on reason-based predicates does not apply, because both predicates read details.runnerErrorCode and each reason comes from a single row, so it can be resolved too. No other threads remain open.

Nothing blocks merge.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
thymikee and others added 2 commits November 20, 2026 11:14
The busy and main-thread-timeout classifiers looked the code up in the
table and compared its reason. They compare the code directly again,
checked against the table's keys at compile time, so no reason a host path
publishes can stand in for it and the row lookup keeps its string input.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…call sites

An AGENT_DEVICE_ literal passed anywhere, so a code spelled in that
namespace could ship without a row. It now passes only as a direct NSLog
argument or an environment key.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Applied the optional notes at c2990d5eb2 (two commits on 4fb6050).

  • AGENT_DEVICE_ pass. Restricted by call site, not by file list: the prefix passes only as the direct argument of NSLog( or the key of an environment[ read. ErrorPayload(code: "AGENT_DEVICE_NEW_REFUSAL") now fails, and the fixture pins it. All 16 existing sites match.
  • Framing comment. Now says the guard waives the file's two code literals.
  • Cast and shared reasons. Both go away with one change, which also answers the open Sentinel thread: the busy and main-thread-timeout classifiers compare details.runnerErrorCode to the code again ('RUNNER_BUSY' satisfies RunnerTableErrorCode), as on main, where they went code → row → reason. runnerErrorCodeRow takes string | undefined again. Nothing branches on a row's reason any more, so I did not add a unique-reason assertion; say if you want it anyway.
  • PR body. Counts refreshed and brought under 250 words.
  • Threads. The Sentinel occupancy thread is resolved with the change above; I found no other open thread.

The full XCTest run was at 4fb6050; the commits since touch two TS classifiers, one Swift comment and the guard. Local: 1,137 repo-guard and apple-runner tests, typecheck and lint pass.

Its last outside caller went away when the occupancy classifiers returned
to comparing the runner code.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of de9abdd

Since the review of 4fb6050: 0 new · 0 still open · 1 no longer raised

No open findings.

Reviewed with this repository's own Sentinel configuration (5b906b7d40f1).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee

Copy link
Copy Markdown
Member Author

Still ready at de9abdd. The change applies the optional notes: an AGENT_DEVICE_ literal now passes only as a direct NSLog( argument or environment[ key, and a new test case pins that ErrorPayload(code: "AGENT_DEVICE_NEW_REFUSAL") fails. The two predicates compare the runner code itself through satisfies RunnerTableErrorCode, so the cast and the exported row lookup are gone, and the RunnerHttpRequestFraming comment now matches what the guard waives. All checks pass, and the label stays.

@thymikee
thymikee merged commit 0b6f305 into main Nov 20, 2026
19 of 20 checks passed
@thymikee
thymikee deleted the t3/q1q5-runner-error-table-reason-guards branch November 20, 2026 11:45
thymikee added a commit to pcbeingused333/agent-device that referenced this pull request Nov 20, 2026
* origin/main: (70 commits)
  refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (callstack#4774)
  fix(android): require acknowledgements for test IME typing (callstack#4722)
  feat(scroll): add scroll refresh for pull-to-refresh (callstack#4770)
  refactor(host-kit): add request Scope and use it for the wait capture deadline (callstack#4794)
  fix(android): let permission all change nothing on an app that declares no permissions (callstack#4796)
  fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (callstack#4797)
  fix(host-kit): accept a group-writable script directory the user owns (callstack#4799)
  fix(cli): escape control characters at the CLI's stdout and stderr writes (callstack#4778)
  fix(audit): do not report rows under a persistent bar that scrolling reveals (callstack#4775)
  fix(daemon): refuse an unsafe state directory before first use (callstack#4783)
  refactor: settle remaining single-deadline races through settleWithin (callstack#4788)
  refactor(host-kit): settle deadline races via settleWithin with R87 race ratchet (callstack#4766)
  fix(android): authenticate and bound persistent snapshot helper sessions (callstack#4729)
  fix(daemon): bound upload ingress and finalization (callstack#4721)
  chore(gates): ratchet wire-published reason literals by value (R89) (callstack#4779)
  feat(audit): evaluate role-less clickable views on Android (callstack#4780)
  fix(mutation): keep umask-setting tests out of Stryker's thread pool (callstack#4785)
  feat(audit): report controls that share one accessible name (callstack#4771)
  fix(contracts): pair open runtime hints with their apply operation (callstack#4754)
  refactor(daemon): report startup progress over the launch channel instead of marker files (callstack#4777)
  ...
thymikee added a commit that referenced this pull request Nov 20, 2026
* origin/main:
  feat(gesture): hold before the move with gesture pan --hold-ms (#4767)
  docs: clarify device verification and security proposals (#4805)
  fix(daemon-client): say that a hung daemon is stopped before ensureDaemon starts a new one (#4803)
  test: remove five timing races from CI (#4800)
  refactor(remote): save a remote script from memory with the local publisher (#4802)
  refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (#4774)
  fix(android): require acknowledgements for test IME typing (#4722)
  feat(scroll): add scroll refresh for pull-to-refresh (#4770)
  refactor(host-kit): add request Scope and use it for the wait capture deadline (#4794)
  fix(android): let permission all change nothing on an app that declares no permissions (#4796)
  fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (#4797)
  fix(host-kit): accept a group-writable script directory the user owns (#4799)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant