Repository navigation
refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates - #4774
Conversation
|
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 Not blocking, and fine to take or leave: R87 is already taken on main by 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 |
This comment has been minimized.
This comment has been minimized.
2a71119 to
c396dd9
Compare
|
Fixed on The guard now reads what the runner emits (runner-error-code-parity.test.ts), scanning the production UITests files ( 13 dead constants are now load-bearing. Every raw literal routes through its constant: The undeclared codes get an explicit pass-through declaration, and they are 15, not 8. Your four Not blocking, taken: rebased on main with the One consequence of deriving instead of hand-listing: deleting New head: c396dd9. |
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
c396dd9 to
fba58d6
Compare
|
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: |
This comment has been minimized.
This comment has been minimized.
fba58d6 to
e678e6b
Compare
|
All three optional items taken, at Widened literal scan. The scan now classifies every code-position literal by kind ( Framing exemption narrowed from per-file to per-(file, code): only Bridge comment reworded. It claimed the parity guard keeps the library's literal and the runner constant equal — it doesn't: the bridge drops Validation at this head: repo-guards 155 pass, tsc clean, oxfmt/oxlint clean, |
e678e6b to
500d0b5
Compare
|
Still ready at 500d0b5. The change since fba58d6 applies the optional items: the parity guard now also catches UPPER_SNAKE codes in |
This comment has been minimized.
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.
500d0b5 to
684ea23
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
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.
684ea23 to
42abfea
Compare
This comment has been minimized.
This comment has been minimized.
|
Thanks for the update. At 42abfea the table and the Swift swaps still look right, and multi-line positions are now scanned: 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 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 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 Before merge, please attach the XCTest lane result at 42abfea. The notes above are worth folding in while you are there. |
… 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>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 4fb6050. The verdict and the full list are in the summary comment.
|
New head 1. Evidence. 84 XCTest cases assert on
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 One deviation: literals starting with 3. Also.
Local: repo-guards + apple-runner 1,137 tests pass, typecheck passes. Guard files are net −29 lines. |
|
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 Not blocking, and fine to take or leave: the 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 Nothing blocks merge. |
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>
|
Applied the optional notes at
The full XCTest run was at |
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 · ✅ Approve · review of
|
| 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.
|
Still ready at de9abdd. The change applies the optional notes: an |
* 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) ...
* 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)
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 itsRunnerWireErrorCode/RunnerPassThroughErrorCodeconstant. 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:
NSLog/environment name, or a waived (file, literal) pair.Validation
Tested head: de9abdd (base 115c83a).
pnpm typecheckand lint pass.🤖 Generated with Claude Code