Skip to content

fix(cache): replay a control that leads its row in that row, not by its place - #2053

Closed
JaynouOliver wants to merge 6 commits into
e2e-inc:mainfrom
JaynouOliver:fix/replay-leading-control-row
Closed

JaynouOliver wants to merge 6 commits into
e2e-inc:mainfrom
JaynouOliver:fix/replay-leading-control-row

Conversation

@JaynouOliver

@JaynouOliver JaynouOliver commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

What and why

  • A control that shares its name with other rows' controls and is the first text in its row (an Archive button in a table's first column) was recorded as tap button "Archive" (2 of 5). The row's first text was the button's own name, so containerKey keyed nothing, and a replay on a list of the same length in another order pressed another row's button. A glyph button (<button aria-label="Archive">×</button>) did the same with in "×" (2 of 5).
  • containerKey takes pastOwn and then reads the row's first text outside the control. The recorder uses that key only when the control has twins and the text tells it from all of them. Relocation accepts either key.
  • No REPLAY_POLICY_VERSION bump, as in fix(cache): a row of a windowed list is not keyed by its list's first rendered row; mobile benchmark re-recorded, Android strict #998: entries recorded on main match the same nodes as before. The cost is that an entry already recorded by place replays by place until the step is recorded again. I can bump it if you would rather cold-start.
  • The row's next text can be data (Archive | $500 | Acme). The key is then $500, and a changed price hands off where main replayed by place. I did not skip volatile text, since containerKey matches no patterns today.
  • Still by place, as on main: rows whose next text is the same in every row ([Archive] [Edit] Acme, a status column).

Issue

Fixes #2052

Verified

Ran it locally: yes

Real CLI and Chromium, the repro from the issue (sh run.sh, a scripted executor, no model): five rows a page, one new record on top before the second run.

second run main (0.24.0 and 0.25.0-nightly-20261121030204) this branch
recorded tap button "Suspend" (2 of 5) tap button "Suspend" in "Acme Corp"
cache 1 replayed · 1 handed off 2 replayed
invoices archived Globex, then Acme Corp Acme Corp
account suspended Globex, and the test passes Acme Corp
  • --strict-cache: main fails the archive test with REPLAY_STALE after archiving Globex and still passes the suspend test on Globex. The branch replays both on Acme Corp.
  • The new tests: 5 failed | 27 passed on main's sources, 32 passed here.
  • main against this branch over 20,000 generated lists, recorded and then replayed after a reorder, a new row, a removed row, or changed data: 2,858 wrong-row replays become right, 1,050 become hand-offs, and no hand-off becomes a wrong row. 175 right replays become hand-offs and 2 land on a wrong row, all keyed by row data that changed. Entries recorded on main relocate to the same node in all 296,229 cases.
  • Web benchmark recordings, CI=1, test:agent --strict-cache, no model key: 26 replayed · 3 handed off · 6 missed on main and here, every step the same. The 8 tests that call the model fail on both.
  • Not run: the mobile benchmark recordings (no emulator), bench:ab and a recording made by a real model (no key). A target that is itself a row or group, as many mobile targets are, takes the old path.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

View guided diff

…ts place

A same-named control that is the first text in its row was recorded by its place among its twins, because the row's first text was its own name. A replay on a list of the same length in another order then acted on another row. Key such a control by the row's first text outside it, when that text tells it from its twins.
@github-actions github-actions Bot added the size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile label Nov 22, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 8 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/core/src/cache/relocate.ts">

<violation number="1" location="packages/core/src/cache/relocate.ts:274">
P2: This fallback changes matching for legacy `within` entries too: a candidate whose ordinary key differs can now match through `pastOwn`, so an old trace may replay where it previously handed off. Gate the fallback on an explicit new key mode, or otherwise version the matching behavior to preserve the stated compatibility.</violation>
</file>

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

View guided diff | Re-trigger cubic

Comment thread packages/core/src/cache/relocate.ts Resolved
… recorded that way

Relocation accepted either key for every entry, so an entry recorded
before this change could match a control that leads its row and replay
where it used to hand off.

A leading control's entry now carries `leads`, and only such an entry
reads a candidate's key past the candidate. Entries without it match as
on main.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 9 files (changes from recent commits).

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

View guided diff | Re-trigger cubic

Comment thread packages/core/src/cache/trace.ts Resolved

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[claude-opus-5-5] automated review on behalf of @okwasniewski

Reviewed at 078eb7a (main 7e32054, mergeable_state clean, CI green). Read #2052 and the gist flow.

The fix is in the right place. containerKey already keys a repeated control by its row's first text. A control that leads its row made that key its own name (or glyph), so nothing was keyed and the replay went by order. Reading past the control fixes the key inside the existing model. It is not a new rung or a text heuristic, and descriptorTiers is untouched. The leads mark keeps the new reading away from entries recorded on main:

  • unmarked entries go through candidatesWithin(..., false), the same filter as main, so cached keys do not change and nothing cold-starts
  • for a non-leading control pastOwn returns the same key, so recordings of every other control are byte-identical
  • the uniqueness check (describePosition(node, outside, nodes, true) === undefined) keeps twins with the same next text (Hold | One day) on the old by-place path

Must fix

  • none

Should fix

  • packages/core/src/cache/trace.ts:140 (cubic P3, real): the leads doc says it is set whenever the target is its container's first text. The recorder sets it only when the control has twins and the outside text tells it from all of them. Take cubic's suggested wording.

Nits

  • Positional booleans at the call sites (containerKey(id, nodes, parents, true), describePosition(node, outside, nodes, true)) do not say what true means. A named const or an options object would.
  • The changeset is long and describes internals ("carries a mark"). Something like this is enough: "A repeated control that is the first text in its row (an Archive button in a table's first column) is now recorded with its row instead of its place among its twins, so a reordered list no longer replays it on another row. Entries already recorded by place keep replaying by place until the step is recorded again."

cubic's P2 on 4e1fd9a (the either-key fallback could match legacy entries by the new key) was real, and 078eb7a fixes it by gating on leads.

Verified

  • tests/unit/relocate-within.test.ts 11/11 and tests/integration/trace-cache-replay.test.ts 22/22 (real Chromium; the replay renders the offers reversed). oxlint is clean on the touched dirs, and tsc --noEmit passes for core and e2e.
  • Mutants, each caught:
    • dispatcher leads branch disabled: 3 integration tests fail
    • relocation ignores leads: 2 unit + 2 integration fail
    • pastOwn skip removed: 2 unit fail
    • container-role guard on the skip removed: 1 unit fails ("row that is itself the target")
    • uniqueness check removed: 2 integration fail
    • trace-read drops leads: 2 integration fail
  • One mutant survived: leads ignored in describePosition's by-place branch. It is equivalent, since anonymous controls always get a position on that branch and never reach the leads path.
  • Checked that leads survives the trace text mapping and redaction (spread), sameTarget, and readDescriptor (rejected without within). An older runner reading a marked entry drops leads, finds no key match and hands off, so it never acts on the wrong row.

…is set

Review follow-up: containerKey and describePosition take named options
instead of a bare true, the leads doc states the recorder's condition,
and the changeset covers only what a user sees.
@github-actions github-actions Bot removed the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 22, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 6 files (changes from recent commits).

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

View guided diff | Re-trigger cubic

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[claude-opus-5-5] automated review on behalf of @okwasniewski

Re-checked at b9521ee (main 6fdb1c2, mergeable_state clean, CI green). The new commit only does what the last review asked: no behavior change, every earlier ask is done.

  • trace.ts:140: the leads doc now says it is set only for a leading control with same-named twins when the row's outside text tells it from all of them. That matches the recorder in action-dispatcher.ts:905-909 and closes cubic's P3.
  • The positional booleans are now named options (containerKey(..., { pastOwn }), describePosition(..., { leads })). Every call site in core and the tests was updated, and the defaults are unchanged, so callers that pass nothing behave as before.
  • The changeset is now the short, user-facing version.

Must fix

  • none

Should fix

  • none

cubic: no open findings. Both earlier threads (P2 relocate.ts fallback, P3 trace.ts doc) are fixed and resolved, and cubic reports 0 issues on b9521ee.

Verified

  • relocate-within, relocate-position, relocate-anonymous and relocate-minted-test-id unit tests pass (35/35). tests/integration/trace-cache-replay.test.ts passes 22/22 on real Chromium. tsc --noEmit passes for core and e2e, and oxlint is clean on the touched dirs.
  • Mutant: containerKey ignores the pastOwn option, and 2 unit tests fail. Mutant: describePosition ignores leads, and it survives. That one is equivalent, same as noted last round.

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 22, 2026

@michal-e2e michal-e2e left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drafted by an AI agent and posted autonomously on Michal's behalf, without him reading it first.

Reviewed at b9521eeef (merge base c30354ff8, main).

The fix is in the right place and works for the issue's case. One changeset sentence promises more than the code gives. Two calls about existing recordings are the maintainer's.

Must fix

  • Your changeset says "A repeated control that is the first thing in its row, list item, or card ... is now recorded by its row, so a replay on a reordered list no longer acts on another row." That holds only when the text after the control tells the row apart. Your own new flow records the second Hold by place (position: { index: 1, of: 2 }), and [Archive] [Edit] Acme rows stay by place too, so a reorder can still hit another row there. A user reading the release note would stop guarding against it. Please narrow it, for example: "A repeated control that is the first thing in its row (an Archive button in a table's first column) is now recorded by the row's next text when that text tells the rows apart, so a reordered list no longer replays it on another row. Rows the next text does not tell apart are still replayed by place, and entries already recorded by place keep replaying by place until the step is recorded again." .changeset/replay-leading-control-row.md:5

Optional

  • Can we add the issue's glyph button (<button aria-label="Reserve now">×</button>) to the ?lead=1 rows and assert its recorded target? The recorder replaces a defined within ("×") with the outside key, and no test reaches that through the recorder. I changed the condition to within === undefined, so a glyph keeps in "×" (n of m), and the packages/e2e unit suite and trace-cache-replay.test.ts still passed. action-dispatcher.ts:907
  • Can we add a reader test for a malformed leads? Accepting leads without within, or leads: false, also passed the same tests. A case in the trace-read tests with { leads: true } and no within, and one with leads: 1, should both read as an invalid entry. trace-read.ts:385
  • Your PR description says "Relocation accepts either key." That was true before 078eb7a. Now relocation reads one key per entry: past the control when the entry has leads, the row's first text otherwise, which your test "matches an entry recorded without the mark by the row's first text only, as before" pins. Please update the sentence, since the description is what we read later to learn why the code is this way.

Nit

  • The doc block that describes renderRepeats (including the new ?lead=1 paragraph) now sits on const LEAD_ROWS. forms.ts:56

Verified

  • The issue's case is fixed. On a clean merge-base build (c30354ff8) your new tests fail where they should: the leading-row recording (expected [ …(3) ] to deeply equal [ …(3) ]), the name key (expected undefined to be 'Acme') and the glyph key (expected '×' to be 'Acme'). The other three new tests pass on the merge base by design, since they guard behavior you kept. At b9521eeef, tests/unit/relocate-* and tests/integration/trace-cache-replay.test.ts pass, 60 of 60, on real Chromium.

  • Older entries: a descriptor without leads relocates the same on the merge base and this head, and a by-place glyph entry (in "×" (2 of 3)) still finds the same button.

  • Suites at b9521eeef, run here: pnpm check, the testbed and the web benchmark passed. pnpm test passed except one desktop test, "quits the process carrying the launch token of a launch the app list never showed", which failed the same way on a rerun at this head and on the merge base, with this machine under heavy load from other runs. It is not this PR's, and the load may explain it. The web agent suite from its committed recordings with --strict-cache and no model key gave 26 passed, 8 failed and 26 replayed · 3 handed off · 4 missed on both the merge base and this head, with the same outcome per test and step. The 8 failures are steps with no recording that call the model (Unauthenticated request to AI Gateway). None failed with REPLAY_STALE.

  • New tests: 6 added, 6 fail under at least one mutant. "replays an entry recorded by the glyph and a place as it did before" needed a targeted one (relocation always reading past the control).

  • Mutation testing: 18 places this PR adds or changes a branch, 19 mutants, 13 killed by a failing assertion, run with each mutant applied to b9521eeef. Survivors, each also run against the whole packages/e2e unit suite:

    • the glyph path and the reader checks above;
    • sameTarget ignoring leads (it only decides whether two recorded scrolls merge);
    • dropping outside !== within, and describePosition ignoring leads on its by-place branch, which I could not reach with any input and read as equivalent.

    One mutant did not compile as written and was rewritten.

Not run

  • The mobile benchmark: no simulator or emulator here. pnpm test:mobile-benchmark.
  • The issue's gist on the real CLI: I did not run it. The integration flow covers the same shape on real Chromium.
  • An older runner replaying a newer entry through the CLI: checked only through the exported relocation functions on both commits' source.

For the maintainer

  • Whether to bump REPLAY_POLICY_VERSION. Without a bump, two things follow, both checked on the merge base and this head source:
    • A by-place entry recorded before this change keeps replaying by place, and a replay that passes never records the step again. So a project that already holds the issue's Suspend recording keeps pressing the wrong row after it upgrades. npx e2e cache clear is the way out today.
    • An older runner that reads an entry this head wrote drops leads and matches within the old way. With buttons named View route that show the departure city, and the arrival city after them (Albany -> Boston, Albany -> Denver, Boston -> Chicago), the head records the first button as { within: "Boston", leads: true }. The merge base relocates { within: "Boston" } to the Boston -> Chicago button, on an unchanged screen. It needs a button whose shown text differs from its name and matches another row's key, plus recordings shared across runner versions. A bump fixes both, but it re-keys every entry and means recording both benchmarks again in this PR, which a fork has no model key for.
  • Keying by row data. When the row's next text is data, the key moves with it. With [Archive] $500 Acme above [Archive] $700 Globex and the prices swapped, rows in place, the merge base replays by place on Acme and this head replays in "$500" on Globex. The description discloses this. By my reading of containerKey, main already keys a label-first row by its first text the same way ($500 Acme [Archive] keys in "$500"), so I read it as a design limit rather than a defect of this PR.

The findings are mine; the approval is @okwasniewski's.

@michal-e2e michal-e2e removed the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 22, 2026
…changeset

Review follow-up: the release note promised row keying everywhere, but
rows the next text does not tell apart still replay by place. A glyph
button now leads two fixture rows and its recorded target is asserted,
and the reader is tested to take leads only as true beside a within.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files (changes from recent commits).

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

View guided diff | Re-trigger cubic

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

View guided diff | Re-trigger cubic

@okwasniewski okwasniewski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[claude-opus-5-5] automated review on behalf of @okwasniewski

Re-checked at 1b3d161 (main c330373, mergeable_state clean, merges into main without conflict, CI green). The two new commits (e1528ab, 1b3d161) only touch the changeset and tests, with no source change since b9521ee.

@michal-e2e's review of b9521ee:

  • Must fix, changeset promises too much: done. It now says the row key applies "when that text tells the rows apart" and holds "while that text stays the same", and that rows the next text does not tell apart still replay by place. That also closes cubic's P2 on the changeset.
  • Glyph button through the recorder: done. ?lead=1 has two Dismiss (×) rows, and the flow asserts { name: 'Dismiss', text: '×', within: 'Note two', leads: true }.
  • Reader test for a malformed leads: done (reads \leads` only as true beside a `within`: no within, plus 1, false, 'true', null`).
  • The doc block on LEAD_ROWS: done, the const now sits above the renderRepeats doc.
  • PR description "Relocation accepts either key": not done, see below.

Must fix

  • none

Should fix

  • PR description: "Relocation accepts either key" is still there. Since 078eb7a relocation reads one key per entry: past the control for an entry with leads, the row's first text otherwise. Please update the sentence as Michal asked.

Nits

  • trace-recorder.test.ts:417: the new reader test sits in describe('TraceRecorder: bare-point drags'). It belongs in its own describe or next to the other reader tests.

Overlap with #2093 (twin control gone): both PRs edit placementOf and readDescriptor. #2093's description records the merge: keep both sides, and whichever PR lands second must also compute twinsWithoutTestId inside this PR's early return for a leading control. Nothing for this PR to change.

cubic: no open findings. All three threads are fixed (P2 relocate fallback, P3 leads doc, P2 changeset).

Verified

  • trace-recorder, relocate-within, relocate-position, relocate-anonymous, relocate-minted-test-id and tests/integration/trace-cache-replay.test.ts (real Chromium) pass, 86/86. tsc --noEmit passes for packages/e2e, and oxlint is clean on the touched dirs.
  • Mutants on the new tests, each caught:
    • Michal's glyph mutant (within === undefined in place of outside !== within in placementOf): the lead-row recording test fails with within: "×"
    • reader accepts leads without within: the reader test fails
    • reader accepts any leads value: the reader test fails

@okwasniewski okwasniewski added the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 23, 2026
@github-actions github-actions Bot removed the Ready for Human Review Green, conflict-free, every thread handled. Waiting on a maintainer. label Nov 23, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.

View guided diff | Re-trigger cubic

@michal-e2e michal-e2e left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drafted by an AI agent and posted autonomously on Michal's behalf, without him reading it first.

Reviewed 840d373db against c30354ff8. The original reorder works. Replay clicks the wrong record in three other cases.

Must fix

  • Keep a sibling button from becoming the target's row key. I recorded Alpha in a group of buttons that all have the accessible name Open and show Alpha, Bravo, and Charlie. The new recorder skips Alpha and uses Bravo as the key. After reversing the buttons, replay clicked Charlie. The base handed off without a click. Please require the key to identify the row that owns the control, and hand off when that identity cannot be established. actions.ts:142
  • Keep a changing cell value from transferring a recorded click to another customer. I recorded Archive on Acme in a table with columns Archive | Price | Customer. I swapped the prices of Acme and Globex and left the rows in place. The base clicked Acme. The new replay followed the recorded price and clicked Globex. Please use a key that survives changes to the row's data, or hand off before clicking when the recorded row cannot be established. action-dispatcher.ts:907
  • Make earlier runners miss recordings that require the new key semantics. With routes Albany to Boston, Albany to Denver, and Boston to Chicago, I wrote a trace for the first route to a shared cache. The new runner clicked the intended route. The base read the same file as a hit, dropped leads, and completed replay after clicking Boston to Chicago on the unchanged page. The revisions generated identical cache keys. Please make earlier runners reject or miss these entries before dispatch and cover that with a shared-cache regression test. trace-read.ts:384 · Cache sharing

Please assert the full click log in these regressions. The end-state check runs after dispatch, so it cannot undo a click on the wrong record. Replay end-state check

Verified

  • The focused Chromium probe used the web engine's semantic reader, the pinned recorder and replay code, and the app's click log. It reproduced all three cases above. For the original leading-control reorder, the base clicked Albany to Denver and the head clicked Albany to Boston. The head also replayed the older recording on the unchanged page.
  • The head rejected the malformed leads values and the missing within case. The revised changeset says the recorded text must distinguish the rows and remain stable.
  • GitHub's deterministic web, iOS and Android jobs passed. The spec gate failed after its Node test jobs were cancelled, and the replay-only web agent job was skipped. GitHub checks

Verification gaps

Another review held the local execution lock. The full check, test, testbed, web benchmark, strict-cache web agent, mobile benchmark, and mutation runs are unverified locally at this head. The focused probe exercised actual clicks in Chromium through the replay engine.

@JaynouOliver

JaynouOliver commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@okwasniewski I tried a rework and hit the same failure with a status or badge in place of the price, so I don't think a text key is safe here without a design change. e2e-inc/e2e#2052 still reproduces on main. Happy to close this and leave the fix to the cache rewrite

@kdy1

kdy1 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Note

This text was drafted with AI and posted after human approval.

  • Harness: T3 Code
  • AI agent: Claude Sonnet 5.5 (claude-sonnet-5-5)

Thanks for the fix and for trying the rework, @JaynouOliver. You wrote that a text key is not safe here without a design change and that you are happy to close this and leave the fix to the cache rewrite. This PR also has conflicts with main, so I am closing it.

The bug itself is still open and stays tracked in #2052.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M Up to 99 changed lines, not counting tests, fixtures, translated docs, or the lockfile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cache: a replay presses the same-named button in the wrong row when the button is the first thing in its row

4 participants