Skip to content

fix(browser): ignore scenario storage enumeration order - #5035

Merged
morluto merged 3 commits into
morluto:mainfrom
Vaishnavi220506:fix/scenario-storage-order
Oct 22, 2026
Merged

morluto merged 3 commits into
morluto:mainfrom
Vaishnavi220506:fix/scenario-storage-order

Conversation

@Vaishnavi220506

@Vaishnavi220506 Vaishnavi220506 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Browser scenario comparison treated storage enumeration order as a change. The same cookies and storage records could therefore produce changed when 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.

  • The domain regression passes for cookies, local storage, and session storage, including duplicates and changed attributes (21 tests).
  • On Node 24.18.0/npm 11.16.0, this pass executed npm run test:local -- src/domain/browserScenarioDiff.test.ts (21 passed), typecheck, lint and cached npm run check:fast on the semantic fix. The final commit changes formatting only; its formatting check and check:fast passed.
  • Exact-head hosted Source tests, Static checks and Docs Generation passed at the latest query. Earlier body claims about a 12-case CLI comparison, compilation and local docs checks were not independently repeated or pinned to this head, so they are not used as current validation evidence.

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

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

@Vaishnavi220506
Vaishnavi220506 marked this pull request as ready for review October 18, 2026 14:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-18T14:31:30.650099Z e0d993e Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@greptile-apps

greptile-apps Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no new blocking findings.

Summary

Storage comparisons ignore entry order while preserving duplicates, values, and cookie attributes.

  • Browser comparisons ignore storage order but still notice changed entries.

Reviews (3) · Last reviewed commit: "style(browser): format storage normaliza..." · Reviewed by Greptile

@rahul05ranjan rahul05ranjan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@x1mm4nu3l

Copy link
Copy Markdown

Replayed e0d993ea92 on main c374c2fe7, Linux/Node 24.18.0. Reordering identical cookies/local/session-storage inventories fails three domain cases and the saved-capture CLI comparison on main. With the patch, all 33 tests pass: order-only changes compare unchanged, while value edits, deletions, duplicate entries and cookie scope/flag changes remain changed. The regression also checks that capture arrays are not mutated and that the new rule is included in the normalization commitment. No real-browser capture was used.

@morluto
morluto merged commit 809f3b7 into morluto:main Oct 22, 2026
42 checks passed
@morluto morluto added the bug Something isn't working label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants