Repository navigation
fix(cache): stop a replay from acting on the twin of a control that is gone - #2093
Conversation
…s gone A step recorded on one of two same-named controls replayed onto the other when its own control was gone: by place when the twins had no test id, and by role and name once the recorded test id was gone. Relocation now accepts a lone match only on a tier where the recording saw no twin, the recorder notes twins beside a test id (twinsWithoutTestId), and replay marks the refusal (twinLeft) so point and screen-scroll fallbacks and the extra look apply only where main's behavior was safe. A count taken on a look an earlier action of the step ran from is marked and replays as on main. Fixes ENG-1404, ENG-1405. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🟢 e2e web: 95 passedAll 95 tests in 43 files
Tested by e2e 0.24.0 · 58.8s · web · run artifacts |
🟢 e2e web agent: 34 passed36 agent steps · 26 replayed from cache · 25 model calls · 129.3k tokens (93% cached) · $0.0058 All 34 tests in 5 files
Tested by e2e 0.24.0 · 1m 40s · web · run artifacts |
🟢 e2e android agent: 20 passed24 agent steps · 15 replayed from cache · 50 model calls · 377.6k tokens (83% cached) · $0.0248 All 20 tests in 1 file
Tested by e2e 0.24.0 · 6m 3s · android-emulator · run artifacts |
🟢 e2e android: 61 passed, 1 skippedAll 62 tests in 7 files
Tested by e2e 0.24.0 · 9m 10s · android-emulator · run artifacts |
🟢 e2e ios: 60 passed, 1 skippedAll 61 tests in 7 files
Tested by e2e 0.24.0 · 6m 59s · ios-simulator · run artifacts |
🟢 e2e ios agent: 1 flaky, 20 passed, 1 skipped25 agent steps · 11 replayed from cache · 80 model calls · 847.3k tokens (82% cached) · $0.0586
|
| Test | Agent | Time | |
|---|---|---|---|
| tests-agent/scenarios.e2e.ts · 1 flaky, 20 passed, 1 skipped | 25 steps · 80 calls | 9m 45s | |
| 🟢 | act completes Login Form | 1 step · 11 calls | 1m 30s |
| 🟢 | act completes Infinite Scroll List | 1 step | 36.9s |
| 🟢 | act completes Modal Flow | 1 step | 9.8s |
| 🟢 | act completes Bottom Tabs | 1 step | 7.4s |
| 🟢 | act completes Text Input Variations | 1 step | 12.7s |
| 🟢 | act completes Broken Accessibility | 2 steps · 5 calls | 20.7s |
| 🟢 | act completes Vision Only | 2 steps · 6 calls | 24.1s |
| act completes Gestures (2 failed attempts first) | 1 step · 12 calls | 46.3s | |
| 🟢 | act completes Async States | 1 step · 8 calls | 23.3s |
| 🟢 | act completes Debounced Search | 1 step · 1 call | 28.3s |
| 🟢 | act completes Flattened Registration Form | 2 steps · 1 call | 24.8s |
| 🟢 | act completes Flattened Login | 2 steps · 20 calls | 1m 43s |
| 🟢 | act completes Sticky Chrome Target | 1 step | 13.3s |
| 🟢 | act completes WebView Accessibility | 1 step | 12.2s |
| 🟢 | act completes Permission Prompt | 1 step | 11.7s |
| 🟢 | act completes Photo Picker | 1 step · 2 calls | 27.1s |
| 🟢 | act completes Product Catalog | 1 step | 10.0s |
| 🟢 | act completes Error Recovery | 1 step | 10.4s |
| 🟢 | act completes Choice Controls | 1 step · 5 calls | 33.0s |
| 🟢 | act completes Stripe PaymentSheet | 1 step · 9 calls | 29.7s |
| 🟢 | act completes Apple Pay | 1 step | 10.8s |
| ⏭️ | act completes Apple Pay Billing Address (skipped: the CI simulator's Apple Pay sheet skips the billing-address step, so the scenario cannot be completed there) |
Tested by e2e 0.24.0 · 11m 32s · ios-simulator · run artifacts
Review fixes for the twin-gone replay change: - Look again on a refused twin only when the recorded test id named the control alone; a test id shared with a twin hands off at once instead of waiting and picking by order. - Keep the refusal for the rest of that relocation, so a look-alike that renders later is not settled by the recorded point or by scrolling the screen. - Find a nameless control that shares a test id when the one left shows the recorded text, as main does. - Bring action-dispatcher.ts back under 1,000 lines; name e2e in the changeset; note the 15-second wait in the docs; cover strict mode, the second run's exit code, and a fresh look between two presses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rries no count mark The twin fixture page takes `?done=1` for a lone "Done" button. One step presses "Set up" and then "Done" from a single look; "Done" has no count, so its recorded target must carry no `countedOnEarlierLook`. Without this test, marking every placement taken from an earlier look survived. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A drag end recorded by its own test id stopped looking for that id as soon as a second look-alike rendered beside the one refused, since relocatePair judged each look on its own. It now keeps the refusal per end, as relocate does for one target. The changeset names drags and says scrollUntil is not covered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A nameless control known by its text and no test id: two "Preview" buttons counted on the strict tier took the one left, since the text exception meant for a shared test id applied without one. - A drag whose source was still loading returned before judging the destination, so a later look picked the destination by order. Both ends are now judged on every look. - A press right after scrolling to text on an engine without scrollTo was marked as counted on an earlier look, though the scroll read its last page after its last swipe; the stop now applies to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
michal-e2e
left a comment
There was a problem hiding this comment.
Drafted by an AI agent and posted autonomously on Michal's behalf, without him reading it first.
I checked point-drag and node-drag replay at cfc8b0392 with scripted screen observations.
- Point-drag replay can send a stale coordinate. When replay waited for one endpoint's test ID to return, the other endpoint moved on the next screen. Replay sent the old coordinate and reported success. I reproduced this while waiting for either endpoint. Resolve the endpoints together on each screen observation and dispatch the drag once both coordinates are valid on that screen. Point-drag replay
- A node drag can lose its twin-refusal reason. When replay refused a same-named twin and later saw neither endpoint, it stopped without dragging and reported
target-not-found. Preservetarget-ambiguouswhile the refused endpoint is unresolved. If its original test ID returns, report the other endpoint as missing. Node-drag relocation
The local fixes passed the targeted replay and relocation tests, plus the core type check. GitHub still shows the reviewed commit.
kdy1
left a comment
There was a problem hiding this comment.
Note
This text was drafted with AI and posted after human approval.
- Harnesses: T3 Code, Claude Code (coordinator and Claude reviewers), Codex (GPT reviewers)
- AI agents: Claude Opus 5.5 (claude-opus-5-5), coordinator and reviewer, Claude Sonnet 5.5 (claude-sonnet-5-5), reviewer, GPT-6.2 Astra (gpt-6.2-astra), reviewer, GPT-6.2 Sol (gpt-6.2-sol), reviewer
Verdict: Approve with changes
This review approves the pull request with changes. Fix the P2 items before merge. The P3 items are optional and do not block the merge.
This PR stops a cache replay from acting on a same-named twin when the recorded control is gone. We ran the motivating case on the base (b6e65ae37) and on the head (cfc8b0392). Two "Set up" buttons, the recorded one removed: on the base, the --strict-cache replay taps the survivor and the test passes (exit 0). On the head, the replay stops with REPLAY_STALE and taps nothing (exit 2). This is true with and without test ids. The new relocation rules in relocateDescriptor and the read and write of the two new descriptor flags look consistent. We found one regression in drag relocation and one behavior change on a progressive render; both are listed below. We also found a pre-existing point-drag defect that this change can now trigger in a new way, and three small defects. The relocate and trace unit tests and trace-cache-twin-gone pass on the head (447 tests in 18 files).
Reviewed commit: cfc8b039202e33c959bd64251bb316e172c89ff7
- P2 (fix before merge): 3 (3 inline)
- P3 (non-blocking): 3 (3 inline)
Review fixes from kdy1 on #2093: - One of two recorded twins left now waits for the count, as two of three already did, and acts on the recorded place once it is back; it hands off after the 15 second wait. A twin that renders ahead of the recorded control takes its place, the same price the 2-of-3 wait already paid. - A drag judges its source first again, as on main, so a destination that is ambiguous for one look no longer ends the wait for a source still loading. - A drag stops with target-ambiguous while an end refused as a twin is still missing, and with target-not-found once that end is back. - A bare-point drag places both ends from the same look, so a box that moved while the other end loaded is read where it is now. - The cache guide and changeset say when a count is waited for, and that a same-look action recorded before this change hands off once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es no page On an engine without scrollTo, a scrollUntil whose text was already in view returned with screens 0 and no new look, yet cleared actedFrom, so the next action from that same look recorded its count without countedOnEarlierLook. The mark now clears only after a real page read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…inc#2229) - github, integrations/index, and the ci/ pages: github-actions, gitlab, vercel-previews, eas-workflows, bitrise, codemagic, norrix - catch up English changes the pt pages were missing: authentication (e2e-inc#2131), mobile (e2e-inc#1903, e2e-inc#2192), ci (e2e-inc#2137), web (e2e-inc#2147), cache (e2e-inc#2093), models (e2e-inc#2146) - ci: "step" for a CI step, as on the new pages - README: glossary rows for the CI terms
Text conflicts: the replay cache sections of docs/cache.mdx and both copies of the skill's running.md, which main shortened, now keep main's wording and say what this branch changed (one YAML and lock per test). The trace page options in report/traces.ts keep main's publishedResultsRoot beside this branch's recording file. Semantic conflicts, so the merged tree builds and passes: - #2093 added twinsWithoutTestId and countedOnEarlierLook to a target. The YAML now writes and reads both; without them readsBack failed and a test whose recording marked a twin was never written. - trace-cache-twin-gone.test.ts awaits readEntries, which reads through the file store here. - #2265's step-cache test spies on FileCacheStore.list, since keyHashes is gone; rekeyed.ts keeps #2265's reset of a failed listing only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What and why
self-finalized, and the test passed. It happened two ways:position {index: 0, of: 2}, but relocation accepted any lone match on a named tier, whatever count was recorded.docs/cache.mdxalready promisedtarget-ambiguouswhen the count changes.packages/core/src/cache/relocate.ts,relocateDescriptor) now accepts a lone match only on a tier where the recording saw no twin:relocate-minted-test-id).twinsWithoutTestId). A target with no test id gets no such exception: its count already compares text, so two "Preview" buttons that lose one stop.twinsWithoutTestId: true, when a test-id target's role and name also matched other controls in its container (hasTwinsWithoutTestId, called fromplacementOf). A lone match on the semantic tier then stops. An exact test id match ignores the field.packages/core/src/agent/replay.ts):twinLefton thetarget-ambiguousresult.placeWithindoes not settle the lone candidate by the recorded point, and ascrollon a list that filled the screen does not fall back to scrolling the screen. Every other ambiguity keeps main's fallbacks.retryablelooks again on that mark, as it already did for two of three: the recorded test id may come back, or the count catch up on a form that renders in steps, and then the control in the recorded place is used. After about 15 seconds it hands off. A count that catches up picks by order, so a twin that renders ahead of the recorded control takes its place, the same price the two-of-three wait pays on main.relocateEnds), for node drags and bare-point drags alike, so a box that moves while the other end loads is read where it is now. It judges the source first, as main did, so a destination that is ambiguous for one look does not end the wait for a source still loading. Each end keeps its refusal, and the drag stops withtarget-ambiguouswhile a refused end is missing, ortarget-not-foundonce it is back and the other end is not.countedOnEarlierLook: true(placementOfinpackages/core/src/agent/action-dispatcher.ts); ascrollUntilthat found its text without paging takes no look and leaves the mark as it was. An executor may act twice from one look, and the first action may remove or add a twin, so replay does not apply the new stop to that count: such an action replays as on main. No extra look is taken, so what the executor's later actions address is unchanged. Node actions, point actions and drag destinations all record their place throughplacementOf. The pagescrollUntilreads after its last swipe, on an engine withoutscrollTo, counts as a fresh look, so a press right after it keeps the stop.flowchart LR A[recorded target] --> B{tier that matched} B -- "named, no count recorded" --> N{matches now} N -- one --> F[act] N -- several --> G[target-ambiguous: hand off at once, as on main] B -- "strict, count recorded on it (no test id, or a shared one)" --> C{matches now} C -- same count --> P[act on the recorded place] C -- "another count above one" --> L[look again, then hand off, as on main] C -- one left --> D["target-ambiguous, twinLeft: look again for the count, then hand off or REPLAY_STALE; no point or screen-scroll fallback"] B -- "semantic, twinsWithoutTestId" --> E{matches now} E -- one --> D2["target-ambiguous, twinLeft: look again for the test id, then hand off"] E -- "several, count recorded on a shared test id" --> P E -- several --> G B -- "unnamed or generated test id, by place" --> H[as on main] B -- "count marked countedOnEarlierLook" --> HREPLAY_POLICY_VERSIONbump. What changes for recordings already on disk:twinsWithoutTestId, so it replays as before, the ENG-1405 bug included, until the step is recorded again. A replay that passes is never re-recorded, so such an entry keeps the old behavior until it misses for another reason.--strict-cacheit fails withREPLAY_STALEuntil re-recorded.--strict-cachewith committed recordings it fails withREPLAY_STALEuntil someone re-records it. The runner cannot tell that case from the wrong-twin case.Issue
ENG-1404, ENG-1405 (Linear)
Verified
Ran it locally: yes
A throwaway project on the built CLI: a fake engine (
defineEngine) with two "Set up" buttons that lead to the same screen, and a scripted executor that taps the first one (no model). The first run records; the second run removes the first button. The same two cases run through the web engine intests/integration/trace-cache-twin-gone.test.ts(pnpm --filter e2e exec vitest run tests/integration/trace-cache-twin-gone.test.ts), which fails on main (self-finalized) and passes here.b6e65ae37)cfc8b0392){"role":"button","name":"Set up","position":{"index":0,"of":2}}self-finalized, test passedmissed,target-ambiguous, nothing tapped, handed to the executor{"role":"button","name":"Set up","testId":"setup-primary"}(plustwinsWithoutTestId: trueon this branch)self-finalized, test passedmissed,target-ambiguous, nothing tapped, handed to the executor--strict-cacheon the replayREPLAY_STALE, nothing tapped34 added tests: 22 fail on main and pass here; 12 pass on both on purpose, as guards for what must not change (an exact test id still on screen, a changed test id with no twin as in fix(cache): replay steps on nodes known only by a generated test id #1208, a text that tells two shared-test-id controls apart, a control recorded alone, an unnamed control in a named group that lost a twin, two twins of a flagged target handing off at once, a recorded point inside an unnamed control whose one look-alike is left, a full-screen list joined by a smaller namesake, a count marked
countedOnEarlierLookreplaying as main both with one match left and with the recorded count, a count taken on a fresh look between two presses, and a lone control acted on from an earlier look recorded with no count mark). Hand mutants of the changed relocation, recording, reading, dispatch and replay lines are each caught by an assertion: 28 on8902df508(this head without the empty-look rule inrelocate), and 8 onda12d2e2b's replay lines, one of them dropping the refusal when a look shows no match.4 more tests on
cfc8b0392, each failing onda12d2e2band passing here: two "Preview" buttons with no name or test id that lose one (relocate-position); a drag end that keeps its refusal when a second look-alike renders (trace-replay); a drag whose destination is refused while its source is still loading (trace-replay); and a press right afterscrollUntilon an engine withoutscrollTo, recorded with nocountedOnEarlierLook(trace-cache-twin-gone).Review fixes on
2443bd8c3(kdy1's six threads): 6 new or rewritten tests intrace-replay.test.tsfail oncfc8b0392'sreplay.tsand pass here (one of two twins waits for the count, for each index and for a shared test id; it hands off after the wait and picks by order when a twin renders ahead; a drag waits for its source while the destination is ambiguous for one look; a drag keepstarget-ambiguousfor a refused end and reportstarget-not-foundonce it is back, at either end; a bare-point drag places both ends on one look when either end waits and the other moves). One new test intrace-cache-twin-gone(a press, ascrollUntilthat takes no page, a press, all from one look, recordscountedOnEarlierLook) fails without theaction-dispatcher.tschange.pnpm checkpasses;pnpm --filter e2e run test:unit4380 passed, 2 skipped; the relocate, trace and twin-gone files 177 passed.More cases, in
tests/unit/trace-replay.test.tsandtests/unit/relocate-twins-without-test-id.test.ts:b6e65ae37)cfc8b0392)target-ambiguous, nothing tappedtarget-ambiguous, nothing scrolledtarget-ambiguous, nothing scrolledIn rows 2 to 4 the recorded control is on neither screen, so completing means acting on a twin. In row 1 main acts on the one button it sees, which here is the recorded one; this branch waits for the count and taps the button in the recorded place.
trace-cache-twin-gonealso runs the replay under--strict-cache(REPLAY_STALE, nothing pressed, no executor call) and checks the second run's exit code.On
cfc8b0392:pnpm checkpasses;pnpm --filter e2e run test:unit4377 passed, 2 skipped; the relocate, trace and agent unit and integration files (40) 663 passed. Onda12d2e2b:pnpm --filter @e2e-dev/testbed test600 passed, 1 skipped. Onb948c3c8f(this head without the empty-look rule and its tests):pnpm testpasses except one@e2e-dev/desktoptest (surface.test.ts, "quits the process carrying the launch token of a launch the app list never showed"), which fails the same way on mainb6e65ae37on this machine;pnpm test:web-benchmark95 passed; the web benchmark's agent suite with--strict-cacheand no model key: 26 passed, 0REPLAY_STALE, and the same 8 steps that need a model fail on main too.Merged with fix(cache): replay a control that leads its row in that row, not by its place #2053's head (
1b3d16189), before this change's last fixes: two conflicts, both resolved by keeping both sides. InreadDescriptorthe two new field blocks sit side by side. InplacementOfthis change's placement follows fix(cache): replay a control that leads its row in that row, not by its place #2053's early return for a control that leads its row, andhasTwinsWithoutTestIdpassesfalsefor fix(cache): replay a control that leads its row in that row, not by its place #2053's newleadsargument. On that merge, the sixrelocate-*unit files,trace-replay,trace-recorder,trace-cache-twin-gone,trace-cache-replayandtrace-cache-minted-test-id: 159 of 159 pass.Not run: the agentic suites with a model key (the mobile ones run in CI only) and a recording made by a real model.
For maintainers
countedOnEarlierLookand replays as on main, the wrong-twin case included. The built-in loop and the ACP and MCP tools look after every action and the decision executor every turn, so this mostly reaches custom executors that batch.scrollUntilrecords no place for its list, so neither a position nor the new field reaches it, and its viewport fallback stays as on main.e92a62efcwithda12d2e2b:trace-cache-twin-gonereads entries with the synchronousreadEntrieshelper, which feat(cache)!: keep one reviewable YAML file of replay recordings per test #2092 makes async, so the e2e package typecheck fails.awaitadded, typecheck passes and two of its four tests fail on an assertion:recording-file.tswrites a target'sDESCRIPTOR_FIELDS,statesandpositiononly (renderTarget), its reader refuses any other key (TARGET_KEYS), and its store writes a test's file only when it reads back the same (readsBackinstore.ts). A step that recordstwinsWithoutTestIdorcountedOnEarlierLooktherefore leaves the test's whole file unwritten, and the next--strict-cacherun finds no recording for that step and calls the executor, as for a step never recorded.trueand adding both toTARGET_KEYS(two lines;readTraceEntryalready validates them) makes the file pass, 3 runs of 3, and the sixrelocate-*unit files,trace-recorder,trace-replay,trace-store,trace-cache-replayandtrace-cache-minted-test-idpass (213 tests).twinsWithoutTestId, so a target recorded by a unique test id keeps main's behavior until re-recorded, as for entries already on disk above.readDescriptorandplacementOf). Whichever lands second must counttwinsWithoutTestIdin the row scope it records: passfalseforleadson the plain path, and compute the flag inside fix(cache): replay a control that leads its row in that row, not by its place #2053's early return for a control that leads its row too, with that row key andleads: true. Without the second part, a row-leading control that shares a test id and a row label with a twin can still be taken after it is removed.🤖 Generated with Claude Code