[PR #2048] [CLOSED] feat(browser): include page workers in session HAR #4988

Closed
opened 2026-10-31 00:57:43 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2048
Author: @Hyped01
Created: 10/12/2026
Status: ❌ Closed

Base: main ← Head: feat/session-har-4-workers


📝 Commits (5)

  • 6b912ce fix(browser): admit browser-serialized HAR request URLs
  • fba05f5 feat(browser): record observe_web_session traffic as HAR
  • 43a0e2b feat(browser): redact declared values in session HAR
  • 254e150 feat(browser): retain selected bodies and payloads in session HAR
  • f23dfac feat(browser): include page workers in session HAR

📊 Changes

35 files changed (+7445 additions, -81 deletions)

View changed files

📝 docs/browser-observation.md (+225 -3)
📝 docs/web-network-captures.md (+6 -0)
📝 src/application/BrowserEvidence.ts (+46 -7)
📝 src/browser/CdpCaptureEventBodyShapes.ts (+2 -1)
📝 src/browser/CdpCaptureEventHandlers.ts (+1 -1)
📝 src/browser/CdpCaptureEventHelpers.ts (+0 -7)
📝 src/browser/CdpCaptureStorageFingerprints.ts (+4 -14)
📝 src/browser/CdpObservationSession.ts (+106 -21)
➕ src/browser/CdpSessionHar.ts (+478 -0)
➕ src/browser/CdpSessionNetwork.ts (+798 -0)
➕ src/browser/CdpSessionResult.ts (+123 -0)
➕ src/browser/CdpSessionWorkers.ts (+399 -0)
➕ src/browser/SessionRedactor.test.ts (+321 -0)
➕ src/browser/SessionRedactor.ts (+464 -0)
📝 src/browser/history/CaptureRedaction.ts (+2 -7)
📝 src/browser/history/HarCapture.test.ts (+37 -0)
📝 src/browser/history/HarCapture.ts (+3 -7)
📝 src/browser/history/HarSchema.ts (+28 -1)
➕ src/browser/network/Base64.ts (+16 -0)
📝 src/browser/network/PlaywrightNetworkContent.ts (+2 -8)

...and 15 more files

📄 Description

Stacked on #2047 (and #2046, #2045). Only the top commit, f23dfac53, is new here.

Summary

Refs #774. The session HAR from #2045 now also covers the selected page's workers: dedicated workers, including workers started by workers, and in-scope shared and service workers.

Problem and expected behavior

Pages move network traffic into workers; realtime feeds, for example, often run in a SharedWorker. A page-only recorder misses that traffic and does not say so. Worker traffic should be recorded with its target and attribution, or reported as not observed.

Change and scope

  • Dedicated workers of the page, and of observed workers, are auto-attached and held at startup. The hold lasts only until REA enables their Network domain and worker auto-attach, each step bounded by 5 s; then the worker is resumed. REA never evaluates worker code. Out-of-scope workers, workers attached after recording stopped, and malformed attach payloads are released without observation.

  • Shared and service workers in scope, in the page's browser context, are discovered and attached while running. Their traffic has origin attribution, because they can also serve other documents of that origin.

  • Commands. Every worker command has a 5-second deadline. It ends early when the worker detaches or is destroyed, or when the observed target ends or disconnects. A worker that ends also ends its pending body reads.

  • Failures. Only these leave a worker unobserved instead of failing the observation:

    • a missing Target.* command (-32601);
    • a session that no longer exists (-32001);
    • Target.attachToTarget on a target that no longer exists (-32602);
    • the deadline;
    • the end of the worker or of the target.

    Any other rejection fails the observation.

  • Limitations. Per-worker limitations name the worker and quote the browser's reason, through the declared-value redactor from #2046.

  • HAR fields. Each HAR entry names its target through _rea_target_id, and network.targets gains worker types and an attribution field.

  • Service-worker pass-through bodies. For a service worker's fetch that the worker passes to the page (respondWith(fetch(request))), Chrome reads back an empty body even though encoded bytes arrived. That entry states the omission instead of claiming an empty body.

  • Cross-site iframes. The page's auto-attach filter also includes iframes, so Chrome announces only the selected page's own out-of-process iframes. REA never observes them and always resumes a held one. Each is named in a limitation, and network_requests and websocket_connections record an out_of_target_scope exclusion of unknown count. Iframes of other tabs are not reported.

  • Page-scoped transport. A page-scoped CDP transport cannot attach shared or service workers, so workers is then reported attach-limited.

Contract and boundary impact

  • Semantic owner and earliest changed stage: src/browser/CdpSessionWorkers.ts.
  • CLI and MCP/tool-catalog contract: an additive workers completeness section, plus target types and attribution in network.targets.
  • Provider, bridge, target-format, or platform compatibility: CDP only. Chromium does not let shared workers start dedicated workers.
  • Evidence, artifact, provenance, or reconstruction contract: none beyond the new fields.
  • Process execution, authorization, cleanup, or containment impact: workers are held only for the bounded setup steps above, then always resumed unless they ended or the caller cancelled. Worker sessions are released when REA closes its WebSocket.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated:
    • hold, enable, auto-attach and resume ordering;
    • a worker detach that does not end the page;
    • shared-worker and service-worker discovery;
    • unavailable setup commands, and other rejections retained;
    • per-worker failures with the browser's message;
    • workers attached after the timeline ended;
    • command deadlines;
    • a worker destroyed while attaching;
    • a page crash during a held worker's resume;
    • a browser-level page detach;
    • nested dedicated workers;
    • -32601/-32602 classification in both directions;
    • declared values in worker limitations;
    • malformed attach payloads;
    • a missing browser context;
    • the page-scoped transport;
    • service-worker pass-through bodies;
    • non-worker targets announced by auto-attach, which are only resumed;
    • a discovered iframe target.
  • Mutation checks: each of these fails a test.
    • The targetDestroyed end signal.
    • The terminated-target abort.
    • The page-session guard.
    • The resume classification.
    • The -32601-only-on-Target.* rule.
  • Live Chrome: tested with an isolated headless profile and a local fixture containing a navigation, a dedicated worker, a nested worker, a shared worker, a WebSocket and a POST carrying a planted value.
    • The run recorded 11 HAR entries, attributed to the page, the shared worker and both workers.
    • The planted value, the declared query value and the Set-Cookie value appear nowhere, whether raw, percent-encoded or base64.
    • inspect-web-network-capture decodes all 11 records.
  • Remaining proof gaps:
    • Chrome reports a worker's own script request on the page target and its response on the worker target, so that entry has no response. This is documented.
    • A held iframe that ends while being resumed is reported with the worker wording ("the worker ended").
    • A malformed iframe announcement is counted under workers.

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

  • Per-commit gate: pass.
  • npx vitest run on 12 browser, CLI, MCP and redactor test files: 147 passed, 2 skipped.
  • exposes CLI-equivalent Evidence results and session tools, an existing MCP test, times out only under heavy machine load. It fails the same way on unmodified main.
  • The live Chrome run above, on this commit.
  • Cold review with adversarial verification: the final round reported no findings.

Compatibility, safety, and release

  • Breaking changes or migration steps: none; worker coverage applies only when network is selected.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: REA never evaluates worker code, every hold is bounded, and declared values are redacted in worker limitations.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2048 **Author:** [@Hyped01](https://github.com/Hyped01) **Created:** 10/12/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/session-har-4-workers` --- ### 📝 Commits (5) - [`6b912ce`](https://github.com/morluto/rea/commit/6b912ce5b90e9b4a395570af0060c5efee9ab44a) fix(browser): admit browser-serialized HAR request URLs - [`fba05f5`](https://github.com/morluto/rea/commit/fba05f5e123ee1d1893689e2d6b265ea618459ac) feat(browser): record observe_web_session traffic as HAR - [`43a0e2b`](https://github.com/morluto/rea/commit/43a0e2ba067fdd4c811e4a561dc2a09a4ee1da16) feat(browser): redact declared values in session HAR - [`254e150`](https://github.com/morluto/rea/commit/254e150a232a77af16d88e367ee6ac9be9e01ace) feat(browser): retain selected bodies and payloads in session HAR - [`f23dfac`](https://github.com/morluto/rea/commit/f23dfac532a631de6238e51ea19d4ba5bbf0be34) feat(browser): include page workers in session HAR ### 📊 Changes **35 files changed** (+7445 additions, -81 deletions) <details> <summary>View changed files</summary> 📝 `docs/browser-observation.md` (+225 -3) 📝 `docs/web-network-captures.md` (+6 -0) 📝 `src/application/BrowserEvidence.ts` (+46 -7) 📝 `src/browser/CdpCaptureEventBodyShapes.ts` (+2 -1) 📝 `src/browser/CdpCaptureEventHandlers.ts` (+1 -1) 📝 `src/browser/CdpCaptureEventHelpers.ts` (+0 -7) 📝 `src/browser/CdpCaptureStorageFingerprints.ts` (+4 -14) 📝 `src/browser/CdpObservationSession.ts` (+106 -21) ➕ `src/browser/CdpSessionHar.ts` (+478 -0) ➕ `src/browser/CdpSessionNetwork.ts` (+798 -0) ➕ `src/browser/CdpSessionResult.ts` (+123 -0) ➕ `src/browser/CdpSessionWorkers.ts` (+399 -0) ➕ `src/browser/SessionRedactor.test.ts` (+321 -0) ➕ `src/browser/SessionRedactor.ts` (+464 -0) 📝 `src/browser/history/CaptureRedaction.ts` (+2 -7) 📝 `src/browser/history/HarCapture.test.ts` (+37 -0) 📝 `src/browser/history/HarCapture.ts` (+3 -7) 📝 `src/browser/history/HarSchema.ts` (+28 -1) ➕ `src/browser/network/Base64.ts` (+16 -0) 📝 `src/browser/network/PlaywrightNetworkContent.ts` (+2 -8) _...and 15 more files_ </details> ### 📄 Description > Stacked on #2047 (and #2046, #2045). Only the top commit, `f23dfac53`, is new here. ## Summary Refs #774. The session HAR from #2045 now also covers the selected page's workers: dedicated workers, including workers started by workers, and in-scope shared and service workers. ## Problem and expected behavior Pages move network traffic into workers; realtime feeds, for example, often run in a SharedWorker. A page-only recorder misses that traffic and does not say so. Worker traffic should be recorded with its target and attribution, or reported as not observed. ## Change and scope - **Dedicated workers** of the page, and of observed workers, are auto-attached and held at startup. The hold lasts only until REA enables their Network domain and worker auto-attach, each step bounded by 5 s; then the worker is resumed. REA never evaluates worker code. Out-of-scope workers, workers attached after recording stopped, and malformed attach payloads are released without observation. - **Shared and service workers** in scope, in the page's browser context, are discovered and attached while running. Their traffic has `origin` attribution, because they can also serve other documents of that origin. - **Commands.** Every worker command has a 5-second deadline. It ends early when the worker detaches or is destroyed, or when the observed target ends or disconnects. A worker that ends also ends its pending body reads. - **Failures.** Only these leave a worker unobserved instead of failing the observation: - a missing `Target.*` command (`-32601`); - a session that no longer exists (`-32001`); - `Target.attachToTarget` on a target that no longer exists (`-32602`); - the deadline; - the end of the worker or of the target. Any other rejection fails the observation. - **Limitations.** Per-worker limitations name the worker and quote the browser's reason, through the declared-value redactor from #2046. - **HAR fields.** Each HAR entry names its target through `_rea_target_id`, and `network.targets` gains worker types and an attribution field. - **Service-worker pass-through bodies.** For a service worker's fetch that the worker passes to the page (`respondWith(fetch(request))`), Chrome reads back an empty body even though encoded bytes arrived. That entry states the omission instead of claiming an empty body. - **Cross-site iframes.** The page's auto-attach filter also includes iframes, so Chrome announces only the selected page's own out-of-process iframes. REA never observes them and always resumes a held one. Each is named in a limitation, and `network_requests` and `websocket_connections` record an `out_of_target_scope` exclusion of unknown count. Iframes of other tabs are not reported. - **Page-scoped transport.** A page-scoped CDP transport cannot attach shared or service workers, so `workers` is then reported attach-limited. ## Contract and boundary impact - Semantic owner and earliest changed stage: `src/browser/CdpSessionWorkers.ts`. - CLI and MCP/tool-catalog contract: an additive `workers` completeness section, plus target types and `attribution` in `network.targets`. - Provider, bridge, target-format, or platform compatibility: CDP only. Chromium does not let shared workers start dedicated workers. - Evidence, artifact, provenance, or reconstruction contract: none beyond the new fields. - Process execution, authorization, cleanup, or containment impact: workers are held only for the bounded setup steps above, then always resumed unless they ended or the caller cancelled. Worker sessions are released when REA closes its WebSocket. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none. ## Evidence and regression coverage - Tests added or updated: - hold, enable, auto-attach and resume ordering; - a worker detach that does not end the page; - shared-worker and service-worker discovery; - unavailable setup commands, and other rejections retained; - per-worker failures with the browser's message; - workers attached after the timeline ended; - command deadlines; - a worker destroyed while attaching; - a page crash during a held worker's resume; - a browser-level page detach; - nested dedicated workers; - `-32601`/`-32602` classification in both directions; - declared values in worker limitations; - malformed attach payloads; - a missing browser context; - the page-scoped transport; - service-worker pass-through bodies; - non-worker targets announced by auto-attach, which are only resumed; - a discovered iframe target. - Mutation checks: each of these fails a test. - The `targetDestroyed` end signal. - The terminated-target abort. - The page-session guard. - The resume classification. - The `-32601`-only-on-`Target.*` rule. - Live Chrome: tested with an isolated headless profile and a local fixture containing a navigation, a dedicated worker, a nested worker, a shared worker, a WebSocket and a POST carrying a planted value. - The run recorded 11 HAR entries, attributed to the page, the shared worker and both workers. - The planted value, the declared query value and the `Set-Cookie` value appear nowhere, whether raw, percent-encoded or base64. - `inspect-web-network-capture` decodes all 11 records. - Remaining proof gaps: - Chrome reports a worker's own script request on the page target and its response on the worker target, so that entry has no response. This is documented. - A held iframe that ends while being resumed is reported with the worker wording ("the worker ended"). - A malformed iframe announcement is counted under `workers`. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - Per-commit gate: pass. - `npx vitest run` on 12 browser, CLI, MCP and redactor test files: 147 passed, 2 skipped. - `exposes CLI-equivalent Evidence results and session tools`, an existing MCP test, times out only under heavy machine load. It fails the same way on unmodified `main`. - The live Chrome run above, on this commit. - Cold review with adversarial verification: the final round reported no findings. ## Compatibility, safety, and release - Breaking changes or migration steps: none; worker coverage applies only when `network` is selected. - Package or release metadata impact: none. - Security, privacy, process, or containment review: REA never evaluates worker code, every hold is bounded, and declared values are redacted in worker limitations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 00:57:43 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#4988
No description provided.