Repository navigation
chore(gates): ratchet untyped reason literals per file (R89) - #4779
Conversation
Size Report
Startup median (7 runs, lower is better):
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 4 new findings on 07f07b5. The verdict and the full list are in the summary comment.
07f07b5 to
1bf8b65
Compare
This comment has been minimized.
This comment has been minimized.
|
@apex-sentinel-staging review |
|
This is not ready to merge yet. At 1bf8b65 the rule counts too much (typed internal outcomes) and checks too little (values inside one file). The gate was not run at head, so there is no measured baseline yet. R89 counts every The header, the violation message and the PR body define "declared" as an The check at :50 compares per-file counts only. In one file, Not blocking, and you can take or leave these: the key test at :103 accepts only Identifier keys, so Could R89 count only The open inline threads on the Identifier key (r4634524330), the missing CallExpression in the spine (r4634524347) and typed union outcomes counting (r4634524359) still stand. The thread on check.ts (r4634524291) no longer applies, because check.ts:479-481 now passes The smoke jobs were still running, and none had failed. The diff touches only scripts/layering, so it does not overlap the route those jobs exercise. No conflicts. Before merge, please settle the R89 scope question (wire reasons only, or fold into the docs guard), then fix the declared-table mismatch and the key check, and let CI finish green. |
This comment has been minimized.
This comment has been minimized.
1bf8b65 to
24d5129
Compare
|
Scope settled toward your option (b), implemented at What "published reason" now means (the definition you asked to fix first): the Why not (a) now: measured on main, the literal The three findings, each closed in code:
Also taken from the not-blocking list: the quoted-key miss now goes through Gate evidence at |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Apex Sentinel: 1 new finding on 24d5129. The verdict and the full list are in the summary comment.
24d5129 to
a29572f
Compare
|
Both Sentinel findings on |
|
At a29572f, the The resolver in untyped-reason-ratchet.ts:203 still misses four forms. First, There are now two hand-rolled expression walkers: Not blocking: these can be taken or left. The constructor set is matched by the local callee name, so Of the open inline threads, the one on laundering (discussion) still applies, tracked by the finding above. The other five do not apply, so please resolve them. The The diff touches only |
This comment has been minimized.
This comment has been minimized.
a29572f to
b764cb2
Compare
|
Option (1) taken, pushed: The four escapes, dispositioned exactly per your rule ("defers only when it reads a declared table through a member expression, and every other expression counts each string literal it can evaluate to"):
The cycle you called out — a new syntactic form per round — was the two hand-rolled walkers each owning half a marker list. They are now one Optional item taken: Evidence at |
|
This PR is ready at b764cb2, and the changes since the earlier review (#4779 (comment)) fix what it raised. Hoisted and exported literal constants now resolve, so they no longer hide untyped reasons from the count. Nothing in the code needs to change before merge. Not blocking: the const resolver in scripts/layering/untyped-reason-ratchet.ts:14 reads only module-scope constants, so a function-local const or a parameter defers, and one that shadows a module constant resolves to that constant's literal. Please consider adding "a function-scoped binding (local const or parameter)" to the header's list of known escapes; scope-aware lookup is not needed. You can take or leave this. The review threads that the latest changes fix or that need no change are: #4779 (comment) (fixed), #4779 (comment) (fixed), #4779 (comment) (fixed), #4779 (comment) (check.ts is untouched, so the totals are unaffected), #4779 (comment) (only construction and super() arguments are scanned), and #4779 (comment) (only the details object's own reason counts, and a test pins it). Please resolve these. The 18 finished checks pass, including the ones that run the layering rule tests. |
R89 measures only reasons PUBLISHED ON THE WIRE: the `reason` property
written inside the arguments of `new AppError(...)` (or a file-visible
alias/subclass of it), or the `super(...)` call inside a subclass's own
body — where SnapshotSourceError and NativeBuildError stamp their reason.
A `reason:` property anywhere else (a typed internal union outcome, a
queue record) is not wire vocabulary and is not measured.
Comparison is the per-file VALUE SET against the merge-base: a site that
changes 'old' to 'brand_new' in place fails, and moving a site between
files cannot hide growth. One resolver answers what an expression can
publish: a literal or substitution-free template resolves to itself; a
cast resolves through its operand; conditional and logical branches each
contribute; an identifier resolves through a same-file module-scope const
(local or exported, ANY marker — `as const` scalars included) to its
initializer. Deferral is exactly two things: a MemberExpression (a read
from a declared table — the docs guards keep those documented) and an
expression that cannot resolve to a literal at all.
R89 is a ratchet, not a proof. The header lists the known escapes a
syntactic scan deliberately does not chase: cross-file imported
identifiers, a details object hoisted to a module-scope const, and
dynamic expressions; a test pins each boundary so the promise cannot
widen silently. File-visible aliased imports and aliased `extends` are
resolved to a fixed point, so `import { AppError as KernelAppError }`
cannot launder a construction.
b764cb2 to
eda59ab
Compare
|
Both notes taken. The six threads are resolved. Header escape (4) added at |
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.
R89 (callstack#4779) requires a wire-published error reason to come from a declared table. The two shake reasons now live in SHAKE_FAILURES, and commands.md documents both. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* 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) ...
R89 (callstack#4779) requires a wire-published error reason to come from a declared table. The two shake reasons now live in SHAKE_FAILURES, and commands.md documents both. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…tors (#4741) * feat(ios): shake an iOS simulator Add `agent-device shake` and `client.command.shake()`. On an iPhone or iPad simulator the Apple owner posts the notification that the Simulator app's Device > Shake menu posts (`simctl spawn <udid> notifyutil -p com.apple.UIKit.SimulatorShake`), which UIKit delivers to the app as a motion-shake event. It injects no accelerometer data. `shake` joins the system-button family as one more argumentless cell that returns nothing, so it adds a row to the family table instead of a module, a dispatcher arm and a conformance entry. It is served by host simctl and never waits for the XCTest runner. The result reports that the shake was sent; what the app did with it is not observed. Physical iPhones and iPads refuse with `unsupported-device-kind`, the other Apple leaves with `unsupported-platform-leaf`, and a provider-owned simulator with `unsupported-provider-mode`, because the shake is posted by simctl on the daemon host. Android and WebDriver state their own refusals. Every other owner takes its family denial. The session journal's fixed summaries for the argumentless system commands move to one table, which keeps `buildStructuredActionSummary` under the complexity threshold. The perf suite does not time `shake`, because the fixture handles none. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * feat(android): shake an Android emulator `agent-device shake` now also works on an Android emulator. The Android owner overrides the accelerometer through the emulator console (`adb emu sensor set acceleration`): ten swings of about 2 g in alternating directions along the screen's X axis, 80 ms apart, then the reading it found. A detector that counts direction changes above a force threshold, as React Native's dev-menu detector does, sees one shake. The rest reading is restored even when the swings are cancelled or the console refuses one. A console refusal fails with `COMMAND_FAILED`, `reason: shake-console-refused`; an unreadable rest reading fails before any swing with `reason: shake-rest-acceleration-unreadable`. Physical Android devices refuse with `unsupported-device-kind`. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * fix(android): refuse shake on Android TV and keep the first shake failure A TV emulator was admitted by kind alone; it now refuses like the other handheld-only cells. A console that refuses the rest reading reports dispatched: no, and a restore that fails after a refused or cancelled swing no longer replaces that error. Help and docs state the measured duration and name the provider devices that refuse. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * refactor(android): publish shake failure reasons from a typed table R89 (#4779) requires a wire-published error reason to come from a declared table. The two shake reasons now live in SHAKE_FAILURES, and commands.md documents both. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> * docs(shake): say what shake-console-refused leaves behind A refused swing is followed by an attempted, unconfirmed restore; a refusal on the initial read dispatched nothing. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
…reason table R89 (upstream callstack#4779) ratchets wire-published reason literals by value per file against the merge-base. The verify-unsupported-on-ref-plan refusal typed its reason at the call site; move it into the shared INTERACTION_ERROR_REASONS table and read it through the member expression, and compress the screenshotDiff.changedFromBefore schema text to hold the always-loaded byte budget that the longer text broke on CI.
Summary
Split out of #4774 at review, per the CoS comment: the ratchet is unrelated to the runner error table, so it lands on its own.
A reason published on the wire (
error.details.reason) is vocabulary a client branches on; the docs guards intest/repo-guards/tie each declared reason to the user docs. A literal written at a construction site belongs to no table, so nothing derives a union from it and nothing documents it. R89 (scripts/layering/untyped-reason-ratchet.ts) holds, per file, the set of values published as literals against the merge-base: a new value fails, an existing one banks with no edit, no name list.Scope (from review, option b): only reasons PUBLISHED ON THE WIRE count — the
reasonproperty inside the arguments ofnew AppError(...)or a file-visible alias/subclass of it, or thesuper(...)call inside such a subclass's own body (whereSnapshotSourceErrorandNativeBuildErrorstamprequest_canceled). Areason:property anywhere else — the ~86 typed internal union outcomes main already has, queue records — is not wire vocabulary and is not measured. Comparison is by VALUE SET, soreason: 'old'becomingreason: 'brand_new'in place fails even at equal count.One resolver answers what a
reasonexpression can publish: a literal and a substitution-free template resolve to themselves, a cast resolves through its operand, the branches of a conditional or logical expression each contribute, and an identifier resolves through a same-file module-scopeconst(local or exported, any marker —as constscalars included) to its initializer. Deferral is exactly two things: aMemberExpression— a read from a declared table, which the docs guards intest/repo-guards/keep documented — and an expression that cannot resolve to a literal at all.R89 is a ratchet, not a proof. The rule header lists the known escapes a syntactic scan deliberately does not chase: imported identifiers (cross-file flow), a details object hoisted to a module-scope const, and dynamic expressions. A test pins each boundary so the promise cannot widen silently; the docs guards are the other half — every value a table declares stays documented.
Option (a) — drop the ratchet and extend the docs guard to every AppError details.reason literal — measured first and deferred: of the 252 distinct literal reason values main publishes inside construction arguments, only 33 appear in commands.md and 4 sit in a typed spine, so that guard fails on ~214 values on day one. R89 stops the set growing while tables (
RUNNER_ERROR_CODESin #4774 first) absorb it; at zero, (a) subsumes R89.Numbering: R89, not the R87 the parent branch used (taken on main by
unique-exported-type-names, #4757) and not R88 (taken in code by the open race ratchet, #4766).Validation
Tested head: b764cb2 (base 0b91864).
node --test scripts/layering/untyped-reason-ratchet.test.ts: 12 pass — scope (internalreason:properties excluded; subclass constructions and their super() stamps included; the review'sandroid-system-dialog.tsexample not counted at head), hoisting does not launder (plain,export, andas constmarkers all count), cast-at-call-site counts, conditional/logical branches count, quoted keys count viapropertyName(), aliasedAppErrorimports and aliasedextendsresolve to a fixed point, nestedcause: { reason }does not count, the documented escapes stay escapes (pinned), value-set replace-in-place fails, moved value fails, quiet at baseline, shrink banks.node --test scripts/layering/*.test.ts: 505 pass.node scripts/layering/check.ts: OK, R89 active; head and merge-base measure identically (383 sites in 193 files both sides — the old rule measured 723 in 287; the difference is the internal outcomes and test declarations the scope excludes).pnpm typecheck(tsc -b tsconfig.typecheck.json examples/sdk/tsconfig.json) clean on the scripts program;oxfmt --checkandoxlint -c oxlint.config.ts scripts/layering/clean.