fix(is): report ambiguous selector matches as ambiguity, not absence (#2870)
Summary
Closes #2870. Two coupled fixes for is on a selector that matches more than one node.
-
Ambiguity is no longer reported as absence. The strict reads (
ispredicates other thanexists/absent, andget attrs— bothreadUniquerows) turned a multi-node match intoCOMMAND_FAILED/selector_not_foundwith an empty candidate list — which to an agent reads as "the element does not exist" on a screen where it is plainly on display. A new shared door keys on the pipeline outcome kind, never message text:nonestaysselector_not_found;ambiguousnow answers with the existingAMBIGUOUS_MATCHcode plusmatchesand up to fiveformatSnapshotLinecandidates — ADR 0011's bounded-disclosure shape and the acting path's exact shape (selector-action-resolution.ts), so no new machine vocabulary is introduced and CLI/MCP/replay render candidates through the one existing reader.screenshot --crop-onalready had its own typed refusal (CROP_TARGET_AMBIGUOUS) and keeps it. Out of scope by declared policy:get text,is exists,wait. -
RN text reads as one node. React Native reports one authored
<Text>twice on a regular capture (paragraph view + accessibility-element mirror; measured live viasnapshot --raw: identical label, byte-identical rects, bothhittable: true).resolveElementReportedTwiceextends the read door's EXISTING structural collapse rule (#2498 wrapper control: one ancestor-descendant chain) with a text-echo branch keyed on label identity + wrapper-slack rects + no semantic touch target, keeping the outer reporter — the node whose testID the app authored and the rowsnapshot -ipublishes. Nothing in snapshot presentation changed: the client-serialization dedup invariant stays untouched, refs andfind list/snapshot --jsoncounts are unchanged; only fail-closed rows collapse. The replay gate consumes the same function, so live and replay resolve identically.
Validation
pnpm check:affected --run(one run per pushed head, recorded in comments): all checks pass at headc6acd1e5e(1,441 unit files, layering, eager-closure ratchet, fallow, wire-compat, command-docs).- Live on iPhone Duo / iOS 27.1 at head
e04e85be2:is visible|text 'label="Catalog scroll: top"'pass;is visible 'role=text'→AMBIGUOUS_MATCH matches=22+ 5 candidates ++17 more, no reason field; a true miss →selector_not_foundwith nomatches/candidates. Not re-run at the issuance heads — the daemon test below is the verification for those; a live Catalog re-run at this head is left to a human. - Reviewer-pinned sequence as a daemon test (
selector-runtime-ambiguity-issuance.test.ts):snapshot -iframe → ambiguousis→press <printed candidate ref>acts on the listed node's point, not the earlier tree's positional twin; the unpinned body is refused, never retargeted; the sparse-capture twin prints no candidates and issues nothing. Unit door pins stored / retired-ref / sessionless / no-generation / unstored-capture branches separately. - Tests pair each positive with its closest negative: collapse vs. distinct subtrees vs. offset rect (>1 pt stays ambiguous, at both pipeline and command surface); ambiguity carries
matches: 2; zero matches carries no count and no candidates.
Known risk
test/integration/android-emulator-e2e/live-assertions.ts accepts only selector_not_found/predicate_failed details reasons, so an ambiguous Android selector now fails loudly instead of scrolling. Lane unrun here.