Repository navigation
fix(browser): ignore scenario storage enumeration order - #5035
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The PR appears safe to merge, with no new blocking findings. SummaryStorage comparisons ignore entry order while preserving duplicates, values, and cookie attributes.
Reviews (3) · Last reviewed commit: "style(browser): format storage normaliza..." · Reviewed by Greptile |
rahul05ranjan
left a comment
There was a problem hiding this comment.
Traced the normalization path to check the artifact === "storage" filter can't sort anything it shouldn't: digestNormalizedScenarioValue is called per artifact kind, so the only arrays that reach the storage branch are cookies/local_storage/session_storage — the steps array and network transactions are digested under their own artifact kinds and can't be affected. Worth noting because a per-artifact label is easy to get wrong at the recursion entry points.
Two properties I confirmed from the key construction rather than the tests: sorting by canonicalJson(item) means equal keys are identical entries, so Array.prototype.sort stability never matters; and since the key covers every field, two entries with colliding names (the redaction/literal-rule case, e.g. your theme→locale rule making both locale) stay distinct and get a deterministic relative order on both sides — which is exactly why unchanged still holds there. Multiplicity survives because both duplicates are retained and sort adjacently; the count then differs across sides, matching the changed expectation for [...entries, entries[0]].
The docs' compatibility note is the honest part done right — moving the rule into the committed built-in list changes the normalization commitment sha256, and the doc says so instead of calling the digests stable.
The captured-arrays-not-mutated claim also checks out structurally: the sort operates on a mapped copy, and the test's after/retained equality pins it.
|
Replayed |
Summary
Browser scenario comparison treated storage enumeration order as a change. The same cookies and storage records could therefore produce
changedwhen returned in a different order. Storage inventories now compare deterministically while retaining meaningful record differences.Change and evidence
Normalization sorts parsed storage fields directly instead of retaining a full canonical JSON string for every record. It preserves duplicate entries, normalized values, cookie attributes, and permutation-invariant order; the normalization commitment records this behavior. No arbitrary cardinality cap was added because the contract has no existing bound and a new cap would make evidence incomplete.
npm run test:local -- src/domain/browserScenarioDiff.test.ts(21 passed), typecheck, lint and cachednpm run check:faston the semantic fix. The final commit changes formatting only; its formatting check andcheck:fastpassed.A representative completed domain comparison used 20,000 local-storage records on each side, mirrored across two scenario steps, and ran three comparisons per process. All results were
unchanged. Baseline: 706 ms elapsed, 690 ms CPU, 300,960 KB peak RSS (one run). Direct-field sort: 194–648 ms elapsed, 233–382 ms CPU, 183,552–198,896 KB peak RSS (four runs). The sample is small and wall time varies; it suggests lower CPU and peak RSS but does not establish a precise speedup. Whole CLI/MCP/provider latency and model or agent token cost were not measured; fixture construction and validation were outside the timed interval.Scope and limitations
This changes only normalization immediately before browser scenario comparison. Capture, Evidence provenance, schemas, providers, and target behavior are unchanged. No provider or CLI process was executed for the cost comparison. Hosted checks still pending at the recorded query are not treated as passed.
Author readiness
Human owner: @Vaishnavi220506