Repository navigation
fix(browser): start coverage at domain enablement - #6276
sachinkr7368 wants to merge 1 commit into
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. |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
[Medium impact] The PR appears safe to merge; the previous test gap is fixed and no new blocking issue was found. SummaryThe PR reports network and console coverage from domain-enable dispatch rather than capture entry.
Reviews (2) · Last reviewed commit: "fix(browser): start coverage at domain e..." · Reviewed by Greptile |
inspect_web_page reported network and console coverage as starting at capture entry, before Page.enable completed and before Runtime.enable or Network.enable was dispatched. Record the dispatch time of each observation domain so events delivered while a domain is being enabled remain inside the reported section boundary. Fixes morluto#6232
450e6c4 to
5abcff3
Compare
|
Addressed the Greptile finding in 5abcff3: the regression now holds the |
baron
left a comment
There was a problem hiding this comment.
AI-assisted review traced capture entry, authorized-frame reset, separate Runtime/Network dispatch boundaries, pre-reply event ingestion and final normalization. The changed producer owns explicit start facts; consumers no longer guess from capture-entry time. Cancellation, target identity and cleanup remain on existing paths.
The MCP regression uses the production CDP provider and clock barriers for both enable calls, addressing the earlier after-reply mutation gap. This is stronger than asserting nonempty events, but fake-browser tests are not real-browser verification.
I authorized the waiting exact-head CI/title runs (CI 39740635792). Authorization is not a successful result; approval is withheld pending completed required checks and inspection of applicable coverage. No local full focused-suite or real-browser pass is claimed by this review.
CassieFox23
left a comment
There was a problem hiding this comment.
TL;DR: Main still reports both coverage start times as the capture start (issue #6232). This PR moves them to just before the Runtime.enable and Network.enable commands, and the test fails if a stamp is taken after a reply. The code reads right. CI is red on one process test this PR does not touch, and the body drops two template parts.
Findings
Should fix
- CI failed on this head:
CI required,Portable testsandTest shard (4/8). Each shows the same single test,rejects a reparented alternate launcher without signaling itintests/process-global/cleanLinuxHopperRuntime.test.ts(errorCommand failed: ps -p 17653 -o ppid=,pgid=). This PR does not touch that file. The run is attempt 2 of run 39740635792. It tested a merge of this head into main c9b4cae (#6260, 22 Oct). Since then #6570 (cc8835c, merged 23 Oct) changed that test file and its boundary twin. In the two failed main push runs among the latest 20 (39975172638 and 39972636909), that file passes. I did not confirm that #6570 fixes this exact failure. Please update the branch and rerun. The other seven shards were cancelled in this run, so it does not show whether they pass. - The body does not keep the repo template as written. Please restore:
- The "Follow the contribution scope" paragraph is gone. It sits between "Change and scope" and "Contract and boundary impact" in the template. The "Contribution scope fit" line below it is filled in.
- The "Generated metadata" label lost its note in parentheses. The template says that CI generates the catalogs and
skills/. It says to edit authored instructions in.agents/skills/reverse-engineer-anything/. It also says to never commit build outputs. - The label "Base reproduction or other evidence" is now just "Base reproduction".
- Every other heading, label and checkbox is there. The added "AI-assisted" line under "Author readiness" is fine by me.
Worth a look
- The stamp is taken before the command is sent, not after the reply (lines 399 to 403). That is the point of the fix: an event delivered before the reply stays inside the window. It also means a section can claim coverage a few milliseconds before the domain is on. The new doc sentence says "begins enabling", so it matches. In issue #6232, the ask was for the time "when observation becomes available". That is a little different. I think dispatch time is a fair choice. A maintainer may want it said in the body.
- Nothing in
srcreadscoverage_started_atexcept the producer and the schema (grep at the head sha), so no consumer sees a changed value. CdpPageCapture.tsline 88 still says "Observation starts when REA attaches". It is true for the capture as a whole. With this change the two sections start later than that. Not new, but the limitation text and the section stamps now say different things.- The test blocks the whole process for 25 ms three times with
Atomics.wait(line 28). The fake'scommandResulthook is synchronous (fakeCdpBrowser.ts line 231), so a timer would not work there. No other test on main usesAtomics.wait(grep oftestsandsrc). It reads as deliberate and I did not run it.
Looks good
- Main (ecd997e) still has the bug:
startedAtat line 98 is reused for network and console coverage. - Small and focused: 3 files, 115 changed lines (compare API). It changes one producer, and the docs line that describes it.
- The test gives each of the three enable calls its own 25 ms barrier. That answers the Greptile thread. The thread is about late timestamps passing. The head test waits 25 ms in the fake for
Page.enable,Runtime.enableandNetwork.enablealike. The body also shows a mutation that stamps after the reply and fails the test. - The test sends
Network.enableevents before its reply and checks the request is kept. That is the exact case in the issue. - The body is open about the gap: no real browser, only the loopback fake.
- baron already reviewed this head as a comment and held approval until CI finishes. I have not repeated that.
- No other open PR targets #6232 (search on the number found only this one), so there is no overlap to compare.
Not run
- No checkout, no build, no tests, no formatter.
- I did not run the test or the mutation in the body, and did not start a browser.
Thanks, sachinkr7368, for the fix, the three-barrier test, and the plain "no real browser" note. Thanks, coygeek, for the clear report in #6232.
Test setup
🤖 Written with Claude Code (Sonnet 5.5, verified by Opus 5.5), posted with my OK 🦊
|
Closing this as already fixed upstream. Issue #6232 was closed on 2026-10-24, and |
Summary
inspect_web_pagenow reportsnetwork.coverage_started_atandconsole.coverage_started_atfrom the moment REA dispatches the corresponding CDP domain-enable command, instead of reusingcapture_window.started_atfrom before attach and setup. Events delivered while a domain is being enabled therefore remain inside that section's reported coverage boundary. Fixes #6232.Problem and expected behavior
On the base revision,
normalizedInspectionset both section timestamps tostate.startedAt, which is captured beforePage.enable, the authorized-main-frame check andenableObservationDomains. A successful MCP request against the repository's loopback CDP fake therefore returned:network.coverage_started_at === capture_window.started_at, andconsole.coverage_started_at === capture_window.started_at,even though
Runtime.enableandNetwork.enablehad not been dispatched yet. CDP can deliver events after a command is dispatched but before its reply, and the capture already ingests those events; reporting a start later than their delivery would place retained events outside their own coverage window.Expected: each section's coverage start reflects when observation of that domain becomes available, and an event delivered while a domain is being enabled remains represented within the boundary.
capture_window.started_atandprior_activity_available: falseare unchanged.Change and scope
src/browser/CdpPageCapture.ts: addnetworkCoverageStartedAt/consoleCoverageStartedAttoCaptureState; record each immediately before dispatchingNetwork.enable/Runtime.enable; report them in the two section objects.tests/boundary/mcp/coverageStart.test.ts: MCP regression with deterministic 25 ms reply barriers forPage.enable,Runtime.enableandNetwork.enable, aNetwork.enableevent delivered before its reply, and assertions that both starts are later than capture entry, at/after thePage.enablereply, at/before their enable command reaches the fake, and that the pre-reply request remains present. The per-command barriers make a timestamp recorded after an enable reply fail the test.docs/browser-observation.md: clarify that coverage starts when REA begins enabling the domains and includes events delivered during enablement.Not included: no change to event filtering or retention,
capture_window,prior_activity_available, the scripts/workers/storage sections, or CDP command order. This is an ordinary fix inside the existinginspect_web_pageboundary; no new capability or maintainer scope decision is required.Contract and boundary impact
src/browser/CdpPageCapture.ts; no new capture stage.inspect_web_pagebehavior; not applicable (no new capability).inspect_web_pageoutput schema is unchanged; the two timestamps now reflect domain enablement. CLI projection carries the same corrected timestamps.docs/public/product-catalog.json), package, or installation impact: none.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
tests/boundary/mcp/coverageStart.test.tsexercises the registered MCP tool and production CDP provider against the loopback fake, with a 25 msPage.enablereply barrier and aNetwork.enableevent sent before its reply.npm run test:boundary -- tests/boundary/mcp/coverageStart.test.tsfailed atexpect(networkStart).toBeGreaterThan(captureStart)withexpected 1792652942473 to be greater than 1792652942473; the same test passes with the fix. This shows coverage previously started at capture entry rather than at domain enablement.expected 1792654033686 to be less than or equal to 1792654033654, confirming the barriers distinguish dispatch from reply. The mutation was reverted.inspect_web_pagenow returnsnetwork.coverage_started_atandconsole.coverage_started_ataftercapture_window.started_at, at or before the correspondingNetwork.enable/Runtime.enabledispatch. All other output is unchanged.For evidence-bearing changes:
Validation performed
networkStart === captureStart).networkStartexceeded theNetwork.enablereceipt time).npm run test:boundary -- tests/boundary/mcp/coverageStart.test.ts— 1 file, 1 test passed with the fix.npm run test:boundary -- tests/boundary/mcp/browserMcp.test.ts tests/boundary/browser/— 60 passed | 1 skipped (61 files), 792 passed | 6 skipped (798 tests).npm run test:local -- <all 56 src/browser/**/*.test.ts files>— 56 files, 744 tests passed.npm run typecheck— exit 0.npm run check— pass (Turbo tasks and architecture guards across 1,785 source files).npm run docs:check— 9 tests passed.npx oxfmt --check src/browser/CdpPageCapture.ts tests/boundary/mcp/coverageStart.test.ts docs/browser-observation.md— pass.git diff --check— clean.Compatibility, safety, and release
Author readiness
Human owner: @sachinkr7368
AI-assisted: the diff and evidence were prepared by an AI coding agent. The human owner directed that this PR be marked ready for initial review and dictated the readiness declarations above.
Before merge
type(scope): outcome.