Skip to content

fix(browser): compare concurrent scenario network events by their request step, not receipt order - #2637

Closed
jayhemnani9910 wants to merge 8 commits into
morluto:mainfrom
jayhemnani9910:fix/scenario-network-event-order
Closed

jayhemnani9910 wants to merge 8 commits into
morluto:mainfrom
jayhemnani9910:fix/scenario-network-event-order

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

Summary

Two capture-browser-scenario runs of the same static page, with capture.events: ["network"], compare as changed in compare-web-captures. The page is a local file with a stylesheet, four images and three parallel fetch() calls; nothing on it changes between runs:

compare-web-captures run1.json run2.json
overall_status: changed
  scenario_start: events changed
  settle:         events changed

Every pair I tried did this (16 of 16 on 6.4.0 and main), so a network-selected scenario comparison cannot report unchanged for an ordinary page.

No related issue; the fix is small and stays inside the existing comparison contract, so it comes straight as a PR.

Problem and expected behavior

eventsFor (src/domain/browserScenarioDiffEvidence.ts:97-117) returns a step's events in receipt order and keeps transaction_id / redirected_from_transaction_id. The built-in rules drop only sequence and step_index. Two things then differ between identical runs:

  1. Concurrent responses and request-finished events arrive in a different order each run, and request-N IDs follow request start order.
  2. A response that arrives just after a step ends is attributed to the next step, so the same transaction is split across steps differently each run (scenario_start vs settle above).

Expected: the same requests with the same outcomes compare unchanged; a different status, header set, body or URL still compares changed. The passive comparison already works this way (webCaptureDiff.ts compares requests as sorted digests per identity), and content events are already attributed to their source event's step.

Change and scope

  • Network events (request, response, request-failed, request-finished, request-unfinished, network-content) are grouped per transaction and attributed to the step that sent the request (receipt step when the request was not observed). Content follows the same rule.
  • Capture-local transaction IDs are dropped; a redirect keeps its predecessor's method and URL instead of its ID.
  • Each transaction's own fields (method, URL, status, header names, failure, captured headers and body, redirect source) are still compared exactly; only the order between transactions and the capture-local IDs are dropped. Transactions are compared as an unordered collection. The ordering runs after caller literal rules, through a new optional order argument to digestNormalizedScenarioValue, so rules still apply to every field.
  • Console, page errors, frames, workers, popups, WebSocket frames and downloads keep receipt order and receipt step.
  • The comparison limitation text and docs/browser-scenario-contract.md describe the new rule.

Not included: ordering for non-network events. Console output from concurrently loaded scripts can still reorder; that is page behavior, not capture noise.

Follow the contribution scope: not applicable, a fix within the existing comparison.

Contract and boundary impact

  • Semantic owner and earliest changed stage: browser scenario comparison, event projection (browserScenarioDiffEvidence.ts).

  • Contribution scope fit and linked maintainer decision: routine fix; no decision needed.

  • CLI and MCP/tool-catalog contract: same result schema; one limitation string reworded.

  • Provider, bridge, target-format, or platform compatibility: none.

  • Evidence, artifact, provenance, or reconstruction contract: event digests in scenario diffs change for network-selected captures; capture Evidence is unchanged.

  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable.

  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

  • Read existing files or captured data.

  • Launch or attach to a process.

  • Inject instrumentation or run scripts/code.

  • Change process memory, registers, files, or configuration.

  • Contact network services.

  • Recover protected code or work around protections.

  • Documentation or usability only; no target interaction.

  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: compares concurrent network transactions without receipt order, receipt step or capture-local IDs in src/domain/browserScenarioDiff.test.ts. Two transactions, the second redirected from the first, captured in opposite orders with the responses in different steps: unchanged. The same with the two statuses swapped: changed. It fails on main; reverting only the step attribution or only the redirect mapping also fails it.
  • Base reproduction or other evidence: executed on Linux x64, Chromium 153, local page above served on 127.0.0.1, scenario goto + wait_for_timeout 1500, network events only. Four captures, capture 1 compared with 2, 3, 4:
    6.4.0:         changed, changed, changed
    main 3ae826ce: changed, changed, changed
    this branch:   unchanged, unchanged, unchanged
    this branch, d2.json removed from the page: changed (scenario_start events)
    
    A second page whose server delays each script 0-200 ms at random also compares unchanged on this branch.
  • User-visible CLI/MCP output: the overall_status lines above.
  • Remaining proof gaps: MCP not exercised separately (same shared workflow).

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run --project domain src/domain/browserScenarioDiff.test.ts — 11 passed; the new case fails on 3ae826c without the change.
  • npm run check:fast — passed.
  • npx vitest run --project <name> for each project except acceptance, after npm run build:cached, rebased on main 3ae826c — 10045 passed, 64 failed, 86 skipped, against 10044 / 64 / 86 on untouched 3ae826c with an identical failure list (environment: firmware tests that need Binwalk 3.1.x, ASAR tests whose unpacked companion file is missing here, Ghidra provider tests). acceptance was not run (out of memory on this machine).

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Stored diffs keep their meaning; new comparisons of network-selected captures can now return unchanged where they returned changed.
  • Real Hopper/Ghidra, browser, or OS coverage: Linux x64 with Playwright Chromium 153.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: none; comparison of already-redacted capture data only.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Copilot AI balanced review requested due to automatic review settings October 13, 2026 06:21

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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 ✅ Completed 2026-10-13T19:00:11.168281Z a524b32 New commits
ℹ️ 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.

@coderabbitai

coderabbitai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0b5e14d7-e216-466e-9d75-c27e07d50b26
📥 Commits

Reviewing files that changed from the base of the PR and between 18d56f5 and f1b7ac6.

📒 Files selected for processing (5)
  • docs/browser-scenario-contract.md
  • src/domain/browserScenarioDiff.test.ts
  • src/domain/browserScenarioDiff.ts
  • src/domain/browserScenarioDiffEvidence.ts
  • src/domain/browserScenarioNormalization.ts
 ________________________________________________________________________________________________________________________
< Don't assume it - prove it. Prove your assumptions in the actual environment - with real data and boundary conditions. >
 ------------------------------------------------------------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f1b7ac6675

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

@greptileai review

@greptile-apps

greptile-apps Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 2/5 Tier: plus

[Medium impact] Refactors how network events are grouped and compared in browser scenarios.

The PR needs fixes before merging because swapped redirect outcomes can compare as unchanged and both numbered findings remain outstanding.

Findings

  1. P1 Swapped redirect results appear unchanged ▶
  2. P1 New test rejects its fixture ▶
  3. P1 Combined coverage reason is lost ▶
Fix with agent prompt
### Issue 1
src/domain/browserScenarioNetworkComparison.ts:203-210
With header values off, identical requests started in different steps get the same ancestor hash. If both redirect during a later step, swapping their final URLs or statuses leaves the earlier steps and the sorted later collection identical. The comparison reports `unchanged` even though each starting step now gets a different result.

Include the ancestor’s stable `step_id` in its identity, rather than its capture-local `step_index`. Add a test with identical roots from different steps and swapped redirect results.

### Issue 2
src/domain/browserScenarioDiff.test.ts:undefined-399
The response inherits `redirected_from_transaction_state: "root"` from `concurrentCapture`. This change adds a non-null `redirected_from_transaction_id` without removing that state. `browserScenarioEventSchema` rejects the combination, so `browserScenarioCaptureSchema.parse` throws before the comparison runs and fails the domain suite.

Remove the state field from the linked response so the test reaches the intended check.

### Issue 3
src/domain/browserScenarioDiff.ts:447-448
When event families and content selections both differ, prioritizing `familyIncomparableReason` drops the content-selection explanation from the combined `incomparableReason`. Users are told about only one setting they need to match, and the existing test requiring both explanations fails.

Keep the family check before the changed shortcut, but return the combined `incomparableReason` when available.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR compares network events by request step and removes noise from concurrent receipt order.

  • Network comparisons ignore arrival order but keep each redirect chain.

Review was source-only; no tests were run. Supersession could not be verified because GitHub access was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Captured events] --> B[Ordered non-network events by step]
  A --> C[Group network transactions]
  C --> D[Apply caller rules to retained fields]
  D --> E[Hash each transaction with its ancestor hash]
  E --> F[Sort hashes by requesting step]
  B --> G[Compare aligned steps]
  F --> G
  H[Coverage and selection checks] --> G
  G --> I[Changed, unchanged, or unknown]
Loading

Reviews (10) · Last reviewed commit: "fix(browser): reject root ancestry contr..." · Reviewed by Greptile

Comment thread src/domain/browserScenarioDiff.test.ts Resolved
@greptile-apps

greptile-apps Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eab6784a1f

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba3d7ca5e2

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/browser-scenario-contract.md Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

The redirect projection reduced predecessor identity to method and URL, discarding the response outcome and selected content that distinguish same-URL transactions. Commit ba3d7ca projects the predecessor's retained request/response/content evidence once at the owning boundary, removes capture-local IDs/sequence metadata, preserves missing lookup as explicit unknown, and canonicalizes this evidence after normalizing values. Swapping children between 301/302 predecessors now changes their projected evidence. Source inspection and git diff --check completed; touched files were formatted. Tests, builds, lint, checks, CI reruns, and performance measurements were not run at the explicit user request. Added CPU/memory costs are unmeasured under this instruction.

  1. thread 1

Addressed in eab6784. The result contract now owns one built-in normalization-rule list, reused by commitment hashing and the advertised schema. It includes capture-local network ID removal, request-step attribution, and unordered transaction comparison. The schema length follows that owned list, so the policy change produces a different commitment instead of reusing the old digest. No related cleanup remains.

Validation: source inspection, touched-file formatting, and git diff --check. Tests, builds, lint, and CI reruns were not run at the explicit user request.

  1. thread 1

Addressed in eab6784. Network projection and ordering now have explicit built-in rule identities in the normalization commitment and result schema. Both consume the same canonical list, removing the duplicate five-rule representation that allowed behavior and saved policy identity to drift. No related cleanup remains.

Validation: source inspection, touched-file formatting, and git diff --check. Tests, builds, lint, and CI reruns were not run at the explicit user request.

  1. thread 1

Addressed in eab6784. The concurrency fixture now uses independent requests with null redirect predecessors and separate request/response orders. Additional cases distinguish response-only reordering and status swaps. Redirect coverage is separate and emits the parent request/response before the child request, matching the producer ordering constraint. No related cleanup remains.

Validation: source inspection, touched-file formatting, and git diff --check. Tests, builds, lint, and CI reruns were not run at the explicit user request.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

The one-hop projection removed the intermediate transaction's parent before reusing its evidence. Commit c218331 replaces that representation with one indexed transaction graph and memoized fingerprints of each normalized transaction plus its complete predecessor fingerprint. Temporary indices and capture-local IDs never enter the final digest. Missing/cyclic predecessors prevent unchanged claims. The previous nested predecessor map and its second interpretation are removed; source regressions cover swapped grandchildren, renamed IDs/reordered receipts, and incomplete/cyclic ancestry. Source inspection and targeted formatting completed; git diff --check passed. Authored regression cases were not run. No tests, builds, lint, typechecks, provider workloads, or CI reruns were executed, at the explicit user request. CPU and process-family memory costs are unmeasured under that instruction.

  1. thread 1

The contract retained the obsolete method/URL-only description. Commit c218331 documents full request/outcome/selected-content ancestry, removal of local sequence/ID fields, normalization before fingerprinting, the exact events/redirected_from fingerprint structure, unordered selected fingerprints, and unknown comparability for missing/cyclic ancestry. The canonical built-in rule owner now commits preserve_redirect_transaction_ancestry, and its existing schema/commitment consumers share that owner. Source inspection and targeted formatting completed; git diff --check passed. Authored regression cases were not run. No tests, builds, lint, typechecks, provider workloads, or CI reruns were executed, at the explicit user request. No related contract cleanup remains identified.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c21833108b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@morluto morluto added bug Something isn't working area: runtime Process capture and runtime observation area: domain Domain logic, errors, and pure functions P2: medium Medium priority issue labels Oct 13, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 983fb857e7

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/domain/browserScenarioDiff.ts Resolved
Comment thread src/domain/browserScenarioDiff.ts Resolved
@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

Root cause: Playwright emitted null for both an observed redirect root and a predecessor outside the capture, and the comparison treated both as roots. The producer now adds redirected_from_transaction_state=root or unknown when the ID is null; linked IDs remain explicit, and legacy nulls remain unknown. The graph comparison preserves unknown ancestry and reports the evidence as incomparable. Regression coverage and the contract documentation were added; source inspection, pinned formatting, and git diff --check completed. No tests or provider runs were executed.

review thread

Root cause: graph projection and fingerprinting were inside per-step event comparison, causing repeated O(S·E) work. The source fix is public at 983fb85: each capture is projected, normalized, and fingerprinted once, then indexed by initiating request step. Source inspection, pinned formatting, and git diff --check completed; regression tests were authored but not executed. Representative task measurements were not run: elapsed time, CPU time, peak process-family memory, and before/after task token usage remain unmeasured, with no quantitative performance claim.

Comment thread src/domain/browserScenarioDiff.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d40ea204b4

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/domain/browserScenarioDiff.ts Outdated
Comment on lines +411 to +413
const changedOrdinaryEvents =
isCaptured && ordinaryBeforeDigest !== ordinaryAfterDigest;
if (changedOrdinaryEvents)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep mismatched event-family captures unknown

When both event ledgers are captured but their event_families differ (for example, the before capture selects console while the after capture also selects page-errors and consequently contains a page error), changedOrdinaryEvents is true and this early return runs before the eventFamilyCoverageReason in input.incomparableReason. The comparator therefore reports changed for a difference caused solely by selection, despite the contract treating such captures as incomparable; gate this return on known, matching event-family selections while still allowing ordinary-event differences to dominate redirect-only uncertainty.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

Comment on lines +403 to +406
const beforeSha256 =
isCaptured && beforeValue !== undefined
? digestScenarioEvents(beforeValue, ordinaryBeforeDigest)
: null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the digest from the captured side

When one side's event ledger is captured and the other is missing or truncated, isCaptured is false because it requires both sides, so this condition also emits null for the complete side's SHA-256. The resulting unknown diagnostic drops available digest provenance that the generic artifact comparator previously retained; compute each side's digest from its own evidence state and reserve the joint condition for deciding comparison status.

AGENTS.md reference: AGENTS.md:L13-L13

Useful? React with 👍 / 👎.

Comment on lines +68 to +69
predecessor =
request === undefined ? parent : request.redirected_from_transaction_id;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject cross-event ancestry contradictions

Even with the new per-event refinement, a capture can contain request and response events with the same transaction_id but different non-null predecessor IDs, because each event is independently schema-valid. This branch then replaces the response's retained predecessor with the request's predecessor before hashing, so that malformed capture can compare unchanged to a coherent one; validate transaction-wide ancestry agreement at the capture boundary or keep the ancestry unknown instead of discarding one phase's evidence.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

The digest layer normalized the aggregate after network transactions had already become SHA-256 fingerprints, so caller literals could rewrite those generated identities. Comparison now normalizes ordinary event evidence once and preserves the generated network fingerprint strings as opaque values. Regression coverage removes every hexadecimal character while changing a numeric response status and confirms the event result remains changed. Published in d40ea20 (src/domain/browserScenarioDiff.ts and src/domain/browserScenarioDiff.test.ts); pinned formatting and diff-check only. Tests were not run; no remaining cleanup identified.

review thread

The capture schema permitted mutually exclusive predecessor facts: a non-null redirected_from_transaction_id alongside root or unknown state. A schema refinement now allows root/unknown only when the predecessor ID is null, while continuing to accept legacy null links without a state. Added a malformed-pair regression in src/domain/browserScenarioCapture.test.ts. Published in d40ea20; pinned formatting and diff-check only; tests were not run.

review thread

A network ancestry gap previously marked the whole per-step events artifact unknown before considering captured console/page events, hiding observed changes unrelated to the gap. The owner now retains a known changed result when normalized ordinary event evidence differs, while keeping unchanged claims unknown until network coverage is complete. Added a console-change-with-orphan-request regression in src/domain/browserScenarioDiff.test.ts. Published in d40ea20; pinned formatting and diff-check only; tests were not run.

const capture = concurrentCapture(["a", "b"], { a: 200, b: 404 });
const events = capture.events.items.map((event) =>
event.kind === "response" && event.transaction_id === "request-2"
? { ...event, redirected_from_transaction_id: "request-1" }

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.

P1 New test rejects its fixture

The response inherits redirected_from_transaction_state: "root" from concurrentCapture. This change adds a non-null redirected_from_transaction_id without removing that state. browserScenarioEventSchema rejects the combination, so browserScenarioCaptureSchema.parse throws before the comparison runs and fails the domain suite.

Remove the state field from the linked response so the test reaches the intended check.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/browserScenarioDiff.test.ts
Line: 399

Comment:
**New test rejects its fixture**

The response inherits `redirected_from_transaction_state: "root"` from `concurrentCapture`. This change adds a non-null `redirected_from_transaction_id` without removing that state. `browserScenarioEventSchema` rejects the combination, so `browserScenarioCaptureSchema.parse` throws before the comparison runs and fails the domain suite.

Remove the state field from the linked response so the test reaches the intended check.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +447 to +448
input.familyIncomparableReason ??
input.incomparableReason ??

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.

P1 Combined coverage reason is lost

When event families and content selections both differ, prioritizing familyIncomparableReason drops the content-selection explanation from the combined incomparableReason. Users are told about only one setting they need to match, and the existing test requiring both explanations fails.

Keep the family check before the changed shortcut, but return the combined incomparableReason when available.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/browserScenarioDiff.ts
Line: 447-448

Comment:
**Combined coverage reason is lost**

When event families and content selections both differ, prioritizing `familyIncomparableReason` drops the content-selection explanation from the combined `incomparableReason`. Users are told about only one setting they need to match, and the existing test requiring both explanations fails.

Keep the family check before the changed shortcut, but return the combined `incomparableReason` when available.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 514f5a186b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

const capture = concurrentCapture(["a", "b"], { a: 200, b: 404 });
const events = capture.events.items.map((event) =>
event.kind === "response" && event.transaction_id === "request-2"
? { ...event, redirected_from_transaction_id: "request-1" }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove the root state from the conflict fixture

The default concurrentCapture(..., redirect = false) adds redirected_from_transaction_state: "root" to every phase, so this spread retains "root" while adding a non-null predecessor. browserScenarioEventSchema explicitly rejects that combination, causing the parse below to throw and the domain test suite to fail before this regression test reaches comparison; explicitly remove the state in this mutation.

Useful? React with 👍 / 👎.

Comment on lines +100 to +102
else if (parent !== null && knownParent === null) {
previous.predecessor = parent;
previous.predecessorState = state;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep a later parent from overwriting an observed root

The final normal-order merge is fresh evidence beyond the earlier cross-event thread: when a schema-valid request phase records a null/root predecessor and a later response phase for the same transaction supplies a non-null predecessor with no state, this branch replaces the observed root instead of setting predecessorConflict. Because both ancestry fields are stripped before hashing, that contradictory capture can compare unchanged to a coherent linked capture; reject the contradiction at the capture boundary or keep its ancestry unknown.

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

for (const fingerprintsForStep of networkByStep.values())
fingerprintsForStep.sort();
return {
coverageReason: scenarioNetworkCoverageReason(capture, nodes),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope redirect coverage failures to affected steps

When any transaction in a capture has missing or cyclic ancestry, this single capture-wide reason is reused for every aligned step. Thus, in a two-step capture where a complete rooted transaction changes status in step 0 and an unrelated redirect is unresolved in step 1, compareScenarioEvents forces step 0 to unknown too and the overall result can remain unknown instead of reporting the observed network change; track coverage per selected transaction and its ancestry rather than globally.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@morluto
morluto force-pushed the fix/scenario-network-event-order branch from 0f8b4ad to aa18cbb Compare October 13, 2026 18:33

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa18cbba6b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +108 to +109
} else if (parent === null && state === "root" && knownParent !== null)
previous.predecessorConflict = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Treat explicit unknown ancestry as a conflict

When a request phase links a transaction to a known predecessor but a later phase for the same transaction records schema-valid null/"unknown" ancestry, this root-only branch is fresh evidence beyond the earlier non-null/root cases: it ignores the explicit unknown, retains the linked parent, and the projection strips both phase ancestry fields. Comparing that capture with a coherent capture whose phases both use the link can therefore return unchanged, even though docs/browser-scenario-contract.md:252-256 defines unknown as an unobserved predecessor; mark known-vs-explicit-unknown ancestry incomparable (or reject it at the capture boundary).

AGENTS.md reference: AGENTS.md:L21-L21

Useful? React with 👍 / 👎.

Comment on lines +24 to +27
const requests = new Map(
capture.events.items.flatMap((event) =>
event.kind === "request" ? [[event.transaction_id, event]] : [],
),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep reused transaction IDs incomparable

When a schema-valid capture reuses one transaction_id for two request records, this map silently keeps the last request and the later grouping folds both records into one transaction; ScenarioScriptCapture.ts:60-61 already treats this exact condition as ambiguous. A self-comparison (or two captures that redistribute bodies/outcomes between those records) consequently gets complete root coverage and can return unchanged even though transaction identity is unresolved, so detect reused request IDs and keep network comparison unknown rather than hashing the merge.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@morluto
morluto force-pushed the fix/scenario-network-event-order branch from aa18cbb to a524b32 Compare October 13, 2026 18:51
Comment on lines +203 to +210
const parent =
predecessor === -1
? null
: (fingerprints.get(predecessor) ?? { state: "missing" });
fingerprints.set(
member,
digestCanonicalValue(
{ events: own[member], redirected_from: parent },

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.

P1 Swapped redirect results appear unchanged

With header values off, identical requests started in different steps get the same ancestor hash. If both redirect during a later step, swapping their final URLs or statuses leaves the earlier steps and the sorted later collection identical. The comparison reports unchanged even though each starting step now gets a different result.

Include the ancestor’s stable step_id in its identity, rather than its capture-local step_index. Add a test with identical roots from different steps and swapped redirect results.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/domain/browserScenarioNetworkComparison.ts
Line: 203-210

Comment:
**Swapped redirect results appear unchanged**

With header values off, identical requests started in different steps get the same ancestor hash. If both redirect during a later step, swapping their final URLs or statuses leaves the earlier steps and the sorted later collection identical. The comparison reports `unchanged` even though each starting step now gets a different result.

Include the ancestor’s stable `step_id` in its identity, rather than its capture-local `step_index`. Add a test with identical roots from different steps and swapped redirect results.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a524b32aed

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

before_sha256: beforeSha256,
after_sha256: afterSha256,
reason:
input.familyIncomparableReason ??

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Retain all event incomparability reasons

When both the event-family selection and network-content selection differ (as in browserScenarioDiff.test.ts:229-235), incomparableReason already contains both diagnostics, but this earlier coalesce chooses the family-only string and discards the content-selection mismatch. The returned unknown Evidence therefore omits a known limitation and the existing domain assertion for both reasons fails; use the combined reason here while keeping the separate family value only for the changed-status gate.

AGENTS.md reference: AGENTS.md:L29-L29

Useful? React with 👍 / 👎.

morluto added a commit that referenced this pull request Oct 14, 2026
Own service-worker CDP registrations and retry failed teardown. Admit redaction and network metadata against remaining capture capacity, retain explicit omission reasons, and preserve source URL, redirect ancestry, caller-selected content, and historical capture values. Forward CLI cancellation through provider cleanup.

Reviewed fixes: #2263, #2637, #2767, #2845, #2859, #2863, #2872, #2874, #2876, #2879, #2955, #2957, #2961, #3033.

Validation: 25 current event/network source tests passed; earlier focused browser lanes passed 201 source tests and 176 boundary tests with two skips, plus 35 Python tests. Real browser/Windows lanes were not rerun. Playwright allocation before admission remains unbounded by these retention limits.
@jayhemnani9910

Copy link
Copy Markdown
Contributor Author

@morluto main has moved and this branch now conflicts. Should I rebase it onto main and run the full test suite on the result, or are you still pushing to it? I'll leave the branch alone until you say.

@CassieFox23

Copy link
Copy Markdown
Contributor

Heads up: main already has this change in f690571. The code is in src/domain/browserScenarioNetworkComparison.ts, and compares concurrent network transactions without receipt order, receipt step or capture-local IDs covers it. It is listed on tracker #3582. If this PR still adds something main doesn't have, please say so here and I'll take it off the list. Thanks for the fix!

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@jayhemnani9910

Copy link
Copy Markdown
Contributor Author

Thanks @CassieFox23, confirmed: f690571 on main carries this fix and the receipt-order test covers it, so this PR adds nothing beyond main. Closing.

@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks @jayhemnani9910 for tracking scenario network transactions to the step that sent each request, so callback receipt order does not make identical runs look changed. Main’s network comparison and regression coverage are in f6905719c (main).

@jayhemnani9910
jayhemnani9910 deleted the fix/scenario-network-event-order branch October 15, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions area: runtime Process capture and runtime observation bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants