Repository navigation
fix(cache): tell long-id steps apart under --strict-cache with an identity digest - #1810
Conversation
There was a problem hiding this comment.
2 issues found across 5 files
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
View guided diff | Re-trigger cubic
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="docs/cache.mdx">
<violation number="1" location="docs/cache.mdx:396">
P3: The new row says these long-ID steps run live under `--strict-cache`, but `docs/reference/errors.mdx` (the `REPLAY_STALE` row) still lists `no-entry` under another key as a failure with no exception. Update that row to exclude steps over the 300-character limit, matching this table.</violation>
</file>
<file name=".changeset/strict-cache-long-test-id.md">
<violation number="1" location=".changeset/strict-cache-long-test-id.md:5">
P3: This changeset only mentions the test id, but the fix also covers long target names and agent names (see the "Still runs live" row in docs/cache.mdx). Name all three so users with long target or agent names know the fix applies to them.</violation>
</file>
There was a problem hiding this comment.
0 issues found across 2 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
|
Note 🤖 Claude Opus 5.5 responding on behalf of Samanyu Das Ready for human review. All 27 checks pass on 54b1ee3, both cubic findings are fixed and resolved, and the branch is up to date with |
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Reviewed at 54b1ee388. The diagnosis and the repro are right, and CI is green. The fix works around the collision instead of removing it, though. The reason given for skipping a digest (that it changes the entry format) does not hold:
readTraceEntry/readProvenance(packages/e2e/src/cache/trace-read.ts:77-79,:410-439) drop unknown fields and rebuild the object, so an optional field inrecordedForworks in both directions with noTRACE_SCHEMA_VERSIONbump.paramsDigest,callIndexandagentwere all added to provenance this way.stepKey(packages/e2e/src/cache/rekeyed.ts:89-93) already returnsundefinedwhen a field is missing, andcompleteProvenance(packages/e2e/src/cache/context.ts:148-152) backfills old entries.
Must-fix
- Store a digest instead of skipping the check.
- In
recordedProvenance(packages/e2e/src/cache/recorder.ts:344), write an optional digest of the full redacted identity when any oftestId/targetId/agentis cut. Usesha256Hexfrompackages/e2e/src/internal/ids.ts:60, e.g. overJSON.stringify([testId, targetId, agent]). - Validate it in
readProvenancelikeparamsDigest, and include it instepKey. - An old entry with a cut id and no digest can't identify its step, so
stepKeyreturnsundefinedfor it. That is the only place "runs live" should remain. - Let
completeProvenancebackfill the digest too. - Then
provenanceIdentifiesStepand the extra branch infailIfRekeyed(packages/e2e/src/agent/step-cache.ts:300) go away. A long-id step whose key really changed still fails strict instead of quietly running live.
- In
- Tests (
packages/e2e/tests/unit/step-cache.test.ts:1398). Changing<=to<at the boundary keeps all 66 tests green, and so does checkingtestIdonly. Add:- a 300-character id with a rekeyed recording (still
REPLAY_STALE) - long
targetIdandagentcases - for the digest: a long id with a rekeyed digest-carrying entry fails strict, and an old entry without a digest runs live
- a 300-character id with a rekeyed recording (still
- Docs and changeset.
- The
docs/cache.mdx:396row shrinks to "entries recorded before this version" or goes away. - Drop the sentence added to the
REPLAY_STALEcell indocs/reference/errors.mdx:122. That cell is already overloaded, and this is cache detail. - Changeset suggestion: "
--strict-cacheno longer fails withREPLAY_STALEa never-recorded step whose test id, target, or agent name is over 300 characters and starts like a recorded one."
- The
Checked and fine: the guard measures the same redacted string that gets stored, and MAX_TRACE_DESCRIPTOR_CHARS is reused rather than duplicated.
What I ran:
step-cache.test.ts: 66/66 pass.- Mutations: with the guard disabled, the new test fails with the issue's error. With
<=changed to<, or withtestIdchecked alone, everything still passes. oxlint: clean.
54b1ee3 to
af90c98
Compare
|
Note 🤖 Claude Opus 5.5 responding on behalf of Samanyu Das Done in af90c98. The skip is gone, and entries now store a digest.
|
…rict-cache An entry keeps the test id, target id, and agent name cut to 300 characters. Two steps whose names agree in their first 299 characters stored the same provenance, so the strict rekey check took a step that was never recorded for one whose key changed and failed it with REPLAY_STALE. When a name is longer than an entry keeps, the entry now also stores identityDigest, the SHA-256 of the whole redacted names, and stepKey compares it. A confirmed replay writes the digest into a kept entry that predates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bound() cuts a name to 299 characters and an ellipsis (298 after a surrogate pair). A whole target or agent name of that shape stored no digest, so it matched an entry recorded before the digest for another step whose name was cut, and strict failed it with REPLAY_STALE. boundIsAmbiguous() names both cases, and recordedProvenance writes the digest for either. Also pins that the digest is taken over the redacted names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…name ends in an ellipsis The test id percent-encodes the titles, so the limit is reached well before 300 characters of title text. The row names the test id again. The digest JSDoc names the createAgent cache key as the source of a name that ends like a cut, and the provenance tests leave the settlement block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
af90c98 to
d6bb251
Compare
|
Note 🤖 Claude Opus 5.5 responding on behalf of Samanyu Das Rebased onto main at
I reran the repro on the built CLI. On main the strict run gives 1 failed and 1 passed, with |
|
Note 🤖 Claude Opus 5.5 responding on behalf of Samanyu Das The red
This account can't rerun jobs. Could a maintainer rerun the failed job? Every other check on this head is green or still running. |
|
[claude-opus-5-5] automated review on behalf of @okwasniewski Re-checked d6bb251. All three asks are done, so I dismissed the change request.
Optional:
The red |
RegExp#test stringifies its argument, so ['<64 hex>'] passes the hex pattern; the typeof check is what refuses it, and now a test pins it. Also rewords the stepKey JSDoc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Heads up: you’ve reached your flex budget. Increase your flex budget or wait for usage to reset.
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
View guided diff | Re-trigger cubic
|
Note 🤖 Claude Opus 5.5 responding on behalf of Samanyu Das Ready for human review at
This account can't add the |
|
[claude-opus-5-5] automated review on behalf of @okwasniewski Re-checked aca807e. Test-only delta on top of d6bb251 (plus a JSDoc wording change in |
kdy1
left a comment
There was a problem hiding this comment.
Note
This text was drafted with AI and posted after human approval.
- Harness: T3 Code
- AI agents: Claude Opus 5.5 (claude-opus-5-5) as the main agent and a review subagent, Claude Sonnet 5.5 (claude-sonnet-5-5) as a review subagent
The fix works. I ran the same --strict-cache case on 25bde7a7 and aca807ee with the web engine and a scripted executor:
- A never-recorded test under a 350-character
describetitle fails withREPLAY_STALEon main. On this branch it runs live. - A long-id step whose agent
contextchanged fails withREPLAY_STALEon both. This branch still catches a real rekey.
Please fix three small items before merge. Two are inline comments. The third is outside the diff:
packages/core/src/cache/context.ts:40-41: theStagedTraceJSDoc still says that a confirmed kept entry is rewritten only when "its provenance predates the step's occurrence fields".completeProvenancenow also rewrites the entry when the storedidentityDigestis different from the step's. You updated the JSDoc at line 144, but not this one. Suggested text: "unless its provenance predates the step's occurrence fields or identity digest (recordedFor, as stored), which the replay proved and are then written in."
| | `invalid-entry`, `wrong-context`, `target-not-found`, `target-ambiguous`, `viewport-changed`, `action-failed`, `action-uncertain`, `end-mismatch`: the app or the entry changed | A step never recorded (a new or edited instruction or params) | | ||
| | `no-entry`, when the cache directory holds a recording of the same step under another key | A `gap` or a `truncated` recording | | ||
| | | A step whose store read fails | | ||
| | | A step whose test id, target name, or agent name is over 300 characters, when its recording under another key was made by an earlier `e2e` version | |
There was a problem hiding this comment.
Two problems in this row:
- On this page, "test id" means the app's element test id (lines 162, 206, and 217). Here it means the identity of the test, so readers can confuse the two.
- The row says "over 300 characters". But
boundIsAmbiguousalso gives a digest to a whole name of 299 or 300 characters that ends in…. An entry that an earlier version recorded for such a step also runs live.
Suggested text:
| | | A step whose test id, target name, or agent name is over 300 characters, when its recording under another key was made by an earlier `e2e` version | | |
| | | A step in a test with a very long title, or with a target or agent name over 300 characters (or of 299 or 300 characters ending in `…`), when its recording under another key was made by an earlier `e2e` version | |
There was a problem hiding this comment.
Note
🤖 Claude Opus 5.5 responding on behalf of Samanyu Das
Took your "a test with a very long title" wording in 0f8c4599, and left out the … parenthetical. On this page no input can reach that case:
- Target and agent names must match
TARGET_NAME_PATTERN(packages/core/src/config/targets.ts:40, reused for agents atconfig/resolve.ts:902), which is ASCII only. A target named'a'.repeat(298) + '…'fails withINVALID_CONFIG. - A runner test id ends in a title that
encodeTitlepercent-encodes, so…is stored as%E2%80%A6.
Only a createAgent cacheKey (core:${cacheKey}) can end like a cut. The identityDigest JSDoc says so, and this page does not cover createAgent.
The row now also ends with "and no read-write run has replayed it since". A confirmed read-write replay writes the digest into the older entry, and after that strict fails it on a rekey like any other entry. The ja and zh tables get the same row (6d373413).
There was a problem hiding this comment.
Note
🤖 Claude Opus 5.5 responding on behalf of Samanyu Das
I changed the row again in 275d93aa, after a second check showed that "a very long title" undersells the case. Titles are percent-encoded into the id, and each Japanese character becomes 9 characters. A 39-character Japanese title in tests/cart.e2e.ts gives a 370-character id, so two such tests that differ only at the end hit the same collision.
The row now names the field a user can look up, which also avoids the element test id clash:
A step whose test's
testIdinreport.json, target name, or agent name is over 300 characters, when an earliere2eversion recorded it under another key and noread-writerun of this version has replayed it since
"Of this version" is there because a read-write replay by an older runner writes no digest. The ja and zh rows say the same.
- Add a settleStagedTraces test: a confirmed kept entry that already keeps the step's identity digest gets no store write. - The StagedTrace JSDoc names the identity digest beside the occurrence fields. - The docs row no longer says "test id", which this page uses for the app's element test ids, and names the 299 or 300 characters ending in an ellipsis case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Test that a name a secret makes longer than an entry keeps gets an identity digest. - The docs row drops the ellipsis case: target and agent names are ASCII only, and runner test ids are percent-encoded, so neither can end in one. It says the test's file path and percent-encoded titles, and that a confirmed read-write replay ends the exception. - The identityDigest JSDoc names the secret-value case. - One isOptionalDigest check serves paramsDigest and identityDigest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… digest - A confirmed kept entry whose names redact differently now gets the step's new digest, and one whose names no longer need a digest drops it. - Shorten the docs row to the maintainer's wording. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…slate the row - The StagedTrace, completeProvenance, and settleStagedTraces JSDoc say an entry is rewritten when its stored provenance differs from the step's, which now includes replacing or dropping a digest. - Test that an invalid paramsDigest is refused too, in a describe for reading entries. - Add the long-name row to the ja and zh cache tables. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…redacted - Test both fields with a registered secret: the stored name holds no secret value, and the digest is the same for two values. - The StagedTrace and settleStagedTraces JSDoc point at completeProvenance instead of restating when it rewrites an entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note 🤖 Claude Opus 5.5 responding on behalf of Samanyu Das All three are addressed at
My own pre-review found these too:
On |
There was a problem hiding this comment.
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.
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
View guided diff | Re-trigger cubic
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A title is percent-encoded into the test id, so a 34-character Japanese title already passes 300 characters. Name the `testId` field users can see instead of "a very long title". - Only a read-write run of this version writes the digest in, so say so. - Drop a test assertion on a constant, and a stray blank line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
0 issues found 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.
Requires human review: Auto-approval skipped because cubic reviewed only this push, not the earlier force-push. Comment @cubic review to review the whole pull request.
View guided diff | Re-trigger cubic
okwasniewski
left a comment
There was a problem hiding this comment.
[claude-opus-5-5] automated review on behalf of @okwasniewski
Re-checked e6a69cf (delta since aca807e: kdy1's three asks, three extra tests, main merge, ja/zh rows).
kdy1's asks are done:
StagedTraceJSDoc (context.ts:37-41) now defers tocompleteProvenance, so one comment owns the rewrite rule.- No-rewrite test exists and counts store writes. kdy1's mutant (
recordedFor.identityDigest === undefined) now fails 2 tests. The replace/drop tests from0f8c4599also kill "never replace a stored digest". - Docs row uses "a test with a very long title". Leaving out the
…parenthetical is fine: target and agent names must matchTARGET_NAME_PATTERN(ASCII only), andencodeTitlepercent-encodes…in test ids, so only acreateAgentcache key can reach that case, and this page does not covercreateAgent.
Must fix
- None.
Should fix
- None.
Nits
- cubic on
context.ts:143is right, but it's only wording. "holds another identity digest" does not cover an entry that hascallIndexand no digest, which is the backfill this PR relies on (it also skips the drop case). Suggest: "whose stored provenance lacks the occurrence fields or whose identity digest differs from the step's (missing, stale, or no longer derived)".
Verified:
step-cache,trace-cache-config,textunit suites: 136/136 pass after building@e2e-dev/core. oxlint is clean, coretscis clean, and check-docs-translations passes (162 pages).- Mutants, each killed: always rewrite when the step has a digest (2 fail), never replace a stored digest (2), ambiguity measured on unredacted names (2), target name not redacted (1), agent name not redacted (1), main's
completeProvenancecondition (3). - CI at e6a69cf: all checks green.
|
Note 🤖 Claude Opus 5.5 responding on behalf of Samanyu Das Two commits landed after
Neither commit changes source code outside comments. |
|
Approval note: This is a bugfix |
--strict-cache, a step whose key misses is checked for a recording of the same step under another key (packages/core/src/cache/rekeyed.ts).recordedProvenancecutstestId,targetId, andagentto 300 characters (packages/core/src/cache/recorder.ts).REPLAY_STALE.recordedProvenancealso writes an optionalidentityDigest(SHA-256 of the whole redacted test id, target id, and agent name) whenboundwould make one of them ambiguous. That is when it cuts the name, or when the whole name already ends like a cut (…at 299 or 300 characters, which acreateAgentcache key can). Short-id entries are unchanged and keep the same cache key.readProvenancevalidates the digest likeparamsDigest, andstepKeykeys by it. A long-id step whose key really changed still fails withREPLAY_STALE.completeProvenancewrites the digest into such an entry once a confirmed replay proves which step it belongs to.readTraceEntrydrops unknown fields, so older runners ignore the new one. There is noTRACE_SCHEMA_VERSIONbump, the same as whenparamsDigest,callIndex, andagentwere added.@e2e-dev/core, so the changeset names bothe2eand@e2e-dev/core. Main is merged in at66d07ca4, and thejaandzhcache tables get the new row.completeProvenancerewrites a kept entry only when its stored provenance lacks the occurrence fields or holds another identity digest, so a confirmed long-name entry that already has the step's digest keeps its bytes.Issue
Fixes #1809
Verified
Ran it locally: yes
Built CLI at
e6a69cfaagainst a scratch web project (later commits change only comments, docs, and tests): two tests under a 342-character describe title, each runningagent.act('increment the counter')with a scripted model. Run 1 records the first test only (e2e run --grep 'first variant'). Run 2 isCI=1 e2e run --strict-cacheon both.Tests 1 failed | 1 passed (2)Cache 1 replayed · 1 missedREPLAY_STALE: the recording of this step no longer replays: the store holds it under another cache key (…json), exit 2Tests 2 passed (2)Cache 1 replayed · 1 missedsecond test ran live (2 model calls), exit 0
testIdplusidentityDigest. Main and this branch write the same key file in the same project (3b488c9e….json).context,--strict-cacheon the first test fails withREPLAY_STALE ... since the agent's context (its context, or the test's agentContext) changed after it was recorded. A long-id step whose key really changed is still caught.identityDigest.checkout flowpasses 2 of 2 on main, so the id length is the trigger.stepKey,>changed to>=, onlytestIdchecked, the…case dropped,>= maxChars - 1changed to>= maxCharstypeofcheck on a read digest dropped, theparamsDigestcheck droppedrecordedFor.identityDigest === undefined, which kdy1 tried), a backfill that never replaces or drops a stored digestpnpm checkpasses.e2eunit tests: 3974 passed, 2 skipped, on the branch with main merged in.🤖 Generated with Claude Code