Skip to content

chore(gates): ratchet untyped reason literals per file (R89) - #4779

Merged
thymikee merged 1 commit into
mainfrom
t3/ratchet-untyped-reason-literals
Nov 20, 2026
Merged

thymikee merged 1 commit into
mainfrom
t3/ratchet-untyped-reason-literals

Conversation

@thymikee

@thymikee thymikee commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

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 in test/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 reason property inside the arguments of new AppError(...) or a file-visible alias/subclass of it, or the super(...) call inside such a subclass's own body (where SnapshotSourceError and NativeBuildError stamp request_canceled). A reason: 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, so reason: 'old' becoming reason: 'brand_new' in place fails even at equal count.

One resolver answers what a reason expression 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-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, which the docs guards in test/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_CODES in #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 (internal reason: properties excluded; subclass constructions and their super() stamps included; the review's android-system-dialog.ts example not counted at head), hoisting does not launder (plain, export, and as const markers all count), cast-at-call-site counts, conditional/logical branches count, quoted keys count via propertyName(), aliased AppError imports and aliased extends resolve to a fixed point, nested cause: { 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 --check and oxlint -c oxlint.config.ts scripts/layering/ clean.
  • No device lanes: no device-facing change.

@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 0 B
Package (unpacked) 6.43 MB 6.43 MB 0 B
Package (download) 1.95 MB 1.95 MB +9 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 72.7 ms 47.5 ms -25.2 ms
CLI --help 165.3 ms 101.0 ms -64.2 ms

@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: 4 new findings on 07f07b5. The verdict and the full list are in the summary comment.

Comment thread scripts/layering/check.ts Resolved
@apex-sentinel-staging

This comment has been minimized.

@thymikee

Copy link
Copy Markdown
Member Author

@apex-sentinel-staging review

@thymikee

Copy link
Copy Markdown
Member Author

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 reason: '<literal>' property in a function body, whatever its type. Many are already typed by a union return type and never reach error.details.reason, for example packages/daemon/src/execution/android-system-dialog.ts:109 (checked against the union at :28). By grep, main has about 86 such sites in about 49 files. A new branch that returns an existing union member would fail R89 and get the guidance to publish it from the owning typed table. That guidance is wrong for a typed internal value. The rule should count only reasons published on the wire, meaning the reason property of the details argument of an AppError construction, with the constructor set taken from the kernel AppError owner.

The header, the violation message and the PR body define "declared" as an as const satisfies table. The code at :96 accepts any module-scope initializer. Hoisting const R = { reason: 'brand_new' } and passing R to AppError zeroes the count, while the value stays untyped and undocumented. The rule should require as const or satisfies on the spine before it marks a site declared.

The check at :50 compares per-file counts only. In one file, reason: 'old' can become reason: 'brand_new' and still pass. Template-literal values, reason: CONST and shorthand { reason } are never counted. Comparing the per-file set of values against the merge-base would make any new value fail.

Not blocking, and you can take or leave these: the key test at :103 accepts only Identifier keys, so { 'reason': 'x' } is missed, and propertyName() in layering-ast.ts:26 already handles both; DECLARATION_SPINE (:67) has no CallExpression, so a module-scope Object.freeze table would count as untyped, though none exists on main today; and the baseline is keyed by file path (:48), so a pure rename or split of a file with counted sites fails R89 until the baseline is reset. Narrowing to AppError details would make the last two rare or moot.

Could R89 count only reason inside the details argument of new AppError(code, message, details), and compare the per-file values against the merge-base instead of counts? That targets the real wire route, leaves typed internal outcomes alone, and lets you delete the module-scope spine walker. Could it be smaller still: extend the existing published-reason docs guard (#4774) so any AppError details.reason literal in source must appear in a typed table or in commands.md, which drops the ratchet entirely? What would have to change first is agreement that "published reason" means AppError details.reason, and which constructors that includes.

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 .untypedReasonLiterals; please resolve it.

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.

@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the t3/ratchet-untyped-reason-literals branch from 1bf8b65 to 24d5129 Compare November 19, 2026 21:03
@thymikee

Copy link
Copy Markdown
Member Author

Scope settled toward your option (b), implemented at 24d5129. Option (a) measured first, and it is not implementable today:

What "published reason" now means (the definition you asked to fix first): the reason property written inside the arguments of a construction of a class that publishes details — AppError, or a class extending it (resolved transitively across files, because a subclass is constructed in files that never see its declaration), including the super(...) call inside that subclass's own body, which is where SnapshotSourceError and NativeBuildError stamp their request_canceled. Constructors counted: exactly new <Those>(...) with an Identifier callee and the subclass's own super(...). A reason: property anywhere else — the ~86 typed internal union outcomes, queue records — is not wire vocabulary and is not measured.

Why not (a) now: measured on main, the literal reason: values inside AppError-style construction arguments are 252 distinct; only 33 appear in commands.md and 4 sit in an as const/satisfies spine. A guard requiring "in a typed table or in commands.md" fails on ~214 values on day one — a backlog bigger than this PR, and merging it first would red-flag every CI run until someone docs-mined six packages. The ratchet instead stops the set growing while the tables (starting with RUNNER_ERROR_CODES in #4774) absorb the values file by file; when the count reaches zero, (a) subsumes it and R89 deletes.

The three findings, each closed in code:

  • Counts too much: narrowed to the definition above. Your android-system-dialog.ts:109 example is not counted at head; the two subclass files count exactly their super() stamp. 366 sites in 189 files measured identically on head and merge-base (vs the old rule's 723 in 287 — the ~357 dropped sites are the internal outcomes and test-only declarations you named).
  • Declared accepts any module-scope initializer: the spine walker is deleted. "Declared" is now structural: a call site that names vocabulary (member expression, spread, substitution template, identifier bound to an as const/satisfies declaration) is skipped; a bare const X = 'lit' hoist still counts through the identifier, so hoisting no longer zeroes anything.
  • Counts only: per-file value sets vs the merge-base. 'old'→'brand_new' in place fails at equal count; a moved value fails because the target file never published it. Template literals count (substitution-free ones), reason: CONST counts through the untyped-hoist rule, shorthand { reason } cannot yield a literal and is left to the table owners' docs guards.

Also taken from the not-blocking list: the quoted-key miss now goes through propertyName() (pinned by a test); the file-path-rename concern is real but rarer under the value-set rule (a renamed file fails as "never published it" — same behavior as every other ratchet here, which resets at the merge-base, so a rename PR carries its baseline by rebasing). Object.freeze at module scope is now simply "names vocabulary" — the spine no longer exists to misclassify it.

Gate evidence at 24d5129: 8/8 rule unit tests (rewritten for the new semantics: subclass/super scoping, hoist-doesn't-launder, cast-at-callsite counts, quoted key, value-set replace-in-place, moved value), 501/501 layering tests, node scripts/layering/check.ts OK with the new summary line, real tsc -b clean on the scripts program, oxfmt/oxlint clean. No label added per the triage rule.

@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 24d5129. The verdict and the full list are in the summary comment.

@thymikee
thymikee force-pushed the t3/ratchet-untyped-reason-literals branch from 24d5129 to a29572f Compare November 19, 2026 21:19
@thymikee

Copy link
Copy Markdown
Member Author

Both Sentinel findings on 24d5129 fixed at a29572f: the export const hoist escape (Major) now counts — the export wrapper is unwrapped before the const map is built; and the nested-property over-count (Minor) is gone — only the details object's own reason counts, reached through the spread/conditional wrappers the real idiom uses, so cause: { reason: 'internal_detail' } no longer trips the rule. 10/10 rule tests (two pinned fixtures), 503/501 layering tests, check.ts green (374 sites in 191 files both sides — up from 366/189 because the export-unwrap and own-property walk each measure more honestly), tsc/oxfmt/oxlint clean.

@thymikee

Copy link
Copy Markdown
Member Author

At a29572f, the export const laundering form from the earlier review is fixed, and the quoted-key and nested cause cases are covered by tests. One gap remains: string literals that reach error.details.reason can still escape the count, so a new undocumented wire reason can ship with R89 reporting zero.

The resolver in untyped-reason-ratchet.ts:203 still misses four forms. First, const R = 'brand_new' as const is marked typed and deferred at :293-295 and :205, and tests at test.ts:79/84 and :122/124 pin that deferral. Second, an identifier imported from another file has no binding in the per-file map; main already does this in platform-android/src/text-input.ts:8. Third, a conditional or logical value such as reason: timedOut ? 'brand_new' : 'old' returns undefined at :207, although the same file walks Conditional/Logical at :246-257; main has this at provider-webdriver/src/webdriver-utils.ts:140, inside new AppError. Fourth, a hoisted module-scope object passed or spread as details (const D = { reason: 'brand_new' }; new AppError('X','m', D) or { ...D }) reaches publishedReasonProperties as an Identifier and yields no reasons. The rule to enforce: a reason value defers only when it is a member read from a declared table, and every other expression counts each string literal it can evaluate to. That covers literals, no-substitution templates, casts, conditional and logical branches, and identifiers bound to a module-scope const with any marker (local, exported, or followed through a named import using the cross-file pass that already builds appErrorConstructors). It also covers an identifier bound to a module-scope object literal when it is passed or spread as details. Please flip the as const assertions at test.ts:84 and :124, and add tests for the import, conditional and object-hoist forms.

There are now two hand-rolled expression walkers: reasonLiteralValue resolves a value, and publishedReasonProperties resolves details objects. Each review round has added one more syntactic form to one of them. This is the fourth round in which a new syntactic form escapes, which suggests the gate is trying to prove something a syntactic scan cannot fully prove. Two ways to stop the cycle, in order of preference: (1) treat R89 as a ratchet, not a proof — count literals, no-substitution templates, casts, conditional/logical branches and same-file consts, document in the rule header that imported and hoisted-object forms are known escapes, and stop there; or (2) if it must be airtight, could one resolver replace both, returning every string literal an expression can evaluate to and every reason property an object expression can contribute? It would follow identifiers through one cross-file module-scope binding map built in the same pass as appErrorConstructors, and it would defer only MemberExpression reads. Then one place answers what an expression can publish, and the deferral rule is one node type instead of a list of markers.

Not blocking: these can be taken or left. The constructor set is matched by the local callee name, so import { AppError as KernelAppError } (main: packages/daemon/src/execution/interaction/internal/interaction-runtime.ts:5) leaves new KernelAppError('X','m', { reason: 'brand_new' }) unmeasured. No reason literal sits behind that alias today. Adding the local names of matching ImportSpecifiers to the set per file, or resolving the callee through the import map in the cross-file pass, would close it.

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 NaN thread: report() sums sites through untypedReasonSiteCount (thread). The quoted key goes through propertyName at :264 and test.ts:107-115 covers it (thread). The declaration-spine walker is deleted, and a frozen-table read defers as a member expression at :207 (thread). Only construction arguments are scanned (:142-168), and test.ts:23 shows a typed union outcome is not counted (thread). Only the details object's own reason counts (:239-265), and test.ts:134-151 pins nested cause and array cases as not counted (thread).

The diff touches only scripts/layering, and there are no conflicts. Before merge, every expression that can evaluate to a string literal needs to count, with deferral only for member reads from declared tables, and each form needs a flipped or new test.

@apex-sentinel-staging

This comment has been minimized.

@thymikee
thymikee force-pushed the t3/ratchet-untyped-reason-literals branch from a29572f to b764cb2 Compare November 19, 2026 21:43
@thymikee

Copy link
Copy Markdown
Member Author

Option (1) taken, pushed: b764cb2e52. All six threads resolved.

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"):

  • as const scalars — now count. The HoistedLiteral { value, typed } marker is deleted; moduleScopeConstInits maps name → initializer, whatever the marker, and one resolver walks the initializer. Both pinned tests flipped ('from_typed_const' as const satisfies string and export const TYPED = 'typed_export' as const now measure).
  • Conditional/logical values — count: reason: timedOut ? 'brand_new' : CONST yields both branches' values through the same resolver.
  • reason: CONST where the const is module-scope — counts with any marker, local or exported.
  • Imported identifiers and hoisted details objects — documented known escapes, in the rule header and pinned by a test that asserts they are NOT measured (with a counted control site beside them), so the boundary cannot silently widen in either direction. Header also names dynamic expressions as the third escape. The reasoning is written down: chasing cross-file value flow turns the ratchet into a type checker; the docs guards are the other half — every value a table DECLARES stays documented, so the escape paths lead either to a documented table or to review.

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 resolveReasonValues (literal / template / cast / conditional / logical / same-file identifier, cycle-guarded), and the deferral rule is one node type: MemberExpression, plus expressions that cannot resolve at all. typedLiteral and the typed/untyped spine distinction are gone.

Optional item taken: fileConstructorNames resolves per-file ImportSpecifiers AND file-local extends of a resolved name to a fixed point, so import { AppError as KernelAppError } and class LocalError extends KernelAppError both land in the constructor set — tested.

Evidence at b764cb2e52: 12/12 rule tests, 505/505 layering tests, check.ts OK (383 sites in 193 files head == merge-base; the jump from 374/191 is the newly-resolved forms measured on main's code, e.g. webdriver-utils.ts:140 and the as const scalars), tsc clean, oxfmt/oxlint clean.

@thymikee

Copy link
Copy Markdown
Member Author

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.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 19, 2026
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.
@thymikee
thymikee force-pushed the t3/ratchet-untyped-reason-literals branch from b764cb2 to eda59ab Compare November 19, 2026 21:58
@thymikee

Copy link
Copy Markdown
Member Author

Both notes taken. The six threads are resolved.

Header escape (4) added at eda59ab: the const lookup reads only the module-scope map, so a function-local const or a parameter defers, and a local shadowing a module constant resolves to the module constant's literal. That is now in the KNOWN ESCAPES list in the rule header, with scope-aware lookup deliberately left unbuilt, as you said. Comment-only change; 12/12 rule tests still pass.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of eda59ab

Since the review of a29572f: 0 new · 0 still open · 0 no longer raised

No open findings.

2 findings below minor hidden (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (0b9186494f80).

💬 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 eda59ab. The only change since b764cb2 is the header comment in scripts/layering/untyped-reason-ratchet.ts, which now lists function-scoped bindings as a known escape. The label stays.

@thymikee
thymikee merged commit 115c83a into main Nov 20, 2026
19 checks passed
@thymikee
thymikee deleted the t3/ratchet-untyped-reason-literals branch November 20, 2026 06:42
thymikee added a commit that referenced this pull request Nov 20, 2026
* origin/main:
  chore(gates): ratchet wire-published reason literals by value (R89) (#4779)
  feat(audit): evaluate role-less clickable views on Android (#4780)
  fix(mutation): keep umask-setting tests out of Stryker's thread pool (#4785)
forever8896 added a commit to forever8896/agent-device that referenced this pull request Nov 20, 2026
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>
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)
  ...
forever8896 added a commit to forever8896/agent-device that referenced this pull request Nov 20, 2026
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>
thymikee pushed a commit that referenced this pull request Nov 20, 2026
…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>
strzhao added a commit to strzhao/agent-device-upstream that referenced this pull request Nov 20, 2026
…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.
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