fix(interaction): a ref the stored tree lacks refuses with a typed reason
Summary
A stale or unknown @ref failed as COMMAND_FAILED with Ref @e12 not found or has no bounds and the stale-ref hint, on every route: press, click, fill, longpress, hover, get, wait, and snapshot --scope. A consumer that re-observes on a stale ref had to match the message. docs/agents/pull-requests.md says message matching must not replace a lost reason code, and the sibling producers already carry typed reasons (offscreen_ref, covered_by_interactive_descendants, selector_not_found).
Every ref miss now carries details.reason and details.ref (the bare ref body, as offscreen_ref does) beside the hint: a ref the stored tree does not list is ref_not_found (Ref @e9 not found); a listed ref whose node has no usable centre, or a selector target without one, is target_bounds_invalid (Ref @e1 has no usable bounds); a listed ref with no label to wait on or scope by is ref_unlabeled. The reasons live in INTERACTION_ERROR_REASONS beside the existing ones; ADR 0011's fixture list names them.
agent-device press @e999 --json
# {"ok":false,"error":{"code":"COMMAND_FAILED","message":"Ref @e999 not found or has no bounds",
# "hint":"Snapshot refs expire when the UI changes. ...","details":{"reason":"ref_not_found","ref":"e999"}}}
11 files: 5 producers, 5 tests, the ADR. The wire shape is additive.
Validation
Tested at 275851f803 (third commit: tryResolveRefNode returns a discriminated outcome, resolved, unusable, or missing, and the refusal maps it with one lookup; get carries the stale-ref hint; pnpm check:affected --run --base c31cc49f6 passed on it):
pnpm check:affected --run --base c31cc49f6: all runnable checks passed.- Regression rows:
resolution.test.ts,interaction-touch-runtime.test.ts,interaction-touch-fill.test.ts, and theruntime-refcontract test assert the reason and ref;selector-read.test.tsgains thegetandwaitmisses (ref_not_foundfor a missing node,ref_unlabeledfor one without text), andresolution.test.tspins the three outcomes oftryResolveRefNode, the trailing-label recovery of an unusable node included;snapshot-scope-ref.test.tscovers--scope. - Live, dev daemon,
dev.e2e.benchmarkopen with a storedsnapshot -i: on an Android emulator (API 36.1, helper 0.21.14) and an iPhone 17 Pro Max simulator (iOS 26.5),press @e999,get text @e999,wait @e999 300,snapshot -s @e999, andfill @e999 helloeach answeredCOMMAND_FAILEDwithdetails.reason: ref_not_found,details.ref: e999, the mutation, wait, and scope paths with the stale-ref hint. - Risk: consumers that deep-equal the error
detailsof a ref miss now see two more keys, and the two messages that sharednot found or has no boundsnow say which it was.