fix(cache): record a vanished node only when no end node matches its anchor

Merged
OK
2mo ago
+120-5

The web benchmark agent test control inventory > check picks a radio the pick replaces with its summary (added in #788) could never replay its pick Express delivery step.

  • Root cause: describeDelta decided which nodes vanished by exact descriptor key, while deltaHolds checks a gone anchor by matching only the fields it recorded (fieldsEqual). The radio label { text: "Express" } was recorded as gone, the status Delivery state reading Express matched it on replay, and the entry failed its own end check every run (end-mismatch, REPLAY_STALE under --strict-cache).
  • Fix (packages/e2e/src/cache/anchors.ts): a start node counts as gone only when no end node matches its anchor the way deltaHolds checks one (anchorIn). The appeared side is unchanged: an appeared anchor always matches the end screen it came from, and dropping one that also matches the start screen would remove a real presence check.
  • The recorded delta now always holds on the screen it was recorded on. The radio { role: "radio", name: "Express" } and the Standard label stay gone anchors, so a pick that leaves the picker on screen still fails.
  • Commits the one new entry for that step. No other entry changed.
before: goneAnchors [... {"role":"radio","name":"Express"}, {"role":"group","name":"Delivery"}, {"text":"Standard"}, {"text":"Express"}]
after:  goneAnchors [... {"role":"radio","name":"Express"}, {"role":"group","name":"Delivery"}, {"text":"Standard"}]

No REPLAY_POLICY_VERSION bump

  • Matching and the replay check are unchanged; only which gone anchors get recorded changes.
  • The only anchors the fix drops are ones that match the recording's own end screen, so every entry carrying one fails every faithful replay already. An entry that replays today has none, and re-recording it gives the same content.
  • A bump would re-key every committed entry (what broke the benchmark after #732) to fix entries that are already broken. Read-write runs heal those on their own (the end-mismatch hands off and the step records again). Under --strict-cache they need one re-record, which the changeset says.

Verified

Ran it locally: yes

  • Unit: new a radio the pick replaces with its summary cases in packages/e2e/tests/unit/trace-anchors.test.ts build the exact before/after screens. On the base build 2 of them fail (recorded delta fails its own check, { text: "Express" } recorded as gone); here all pass. A replay whose radios stayed on screen still fails the check, before and after.
  • Web benchmark, base build (#796 head): recorded the step without CI=1, then replayed it read-only with --strict-cache:
× control inventory > check picks a radio the pick replaces with its summary > agent.act "pick Express delivery" 14.33s failed
REPLAY_STALE: the recording of this step no longer replays (end-mismatch), and cache.strict hands no step to the agent
  • Same on this branch: recorded once (2 model calls), then CI=1 ... --strict-cache replays it in 155 ms with no model call.
  • Whole tests-agent/ suite, CI=1 e2e run --config e2e.agent.config.ts --strict-cache, read-only:
main (#796)this branch
pick Express deliverymissed, 2 model callsreplayed, 0 model calls
tests33 passed33 passed
cache25 replayed, 2 handed off, 5 missed26 replayed, 2 handed off, 4 missed
model calls2120

The other 2 handed off and 4 missed are the same steps on both builds: steps the agent ends with a gap, which never record, and the cart and wishlist steps whose planted bugs fail them.

Follow-up, not in this PR

The appeared side has a related older gap in deltaEvidenced: a step whose only effect is a text-only node also matching something already on screen (a chip Express beside a status reading Express) records a delta that holds but is never evidenced, so it never self-finalizes. Fixing it means deciding what to record when no anchor can be evidence, so it is left out here.