M3: Network and environment (Route, HAR, Emulate, Clear Site Data, console) #6

Merged
akib merged 2 commits from akib/m3-network into main 2026-11-10 08:33:20 +00:00 AGit
Owner

M3: Network and environment (Chromium via CDP)

Completes M3.1–M3.5 on top of the run-scoped CDP sessions (M3.0). Version stays 0.4.0; 0.5.0 ships with M4.

New

  • Route (route): fulfill / abort / continue / modify / redirect through CDP Fetch; abort/redirect through declarativeNetRequest session rules (also Firefox, no debugging bar). Newest matching rule wins; rules are removed at run end; stale rules cleared at worker start.
  • HAR Record (har-record): HAR 1.2 metadata (≤ 500 entries), no bodies/cookies/auth headers, sensitive query values redacted; output, dataset or download.
  • Emulate (emulate): device presets, viewport, scale, UA, locale, timezone, geolocation, color scheme, reduced motion, offline. Only what the run changed is reset, also after failure.
  • Clear Site Data (clear-site-data): exact origins via browsingData (Chromium only; Firefox refuses and no longer requests the permission).
  • Console capture: per-step console messages and exceptions in the run record, Reports, HTML and JSON; Assert subject console-errors.
  • m3Host.ts: one feature set per run, tab claims (one run owns a tab's overrides), every cleanup runs before the debugger is released.

Verification

  • npm run check: 771 unit/DOM tests, guide/learning/wiki checks
  • npm run e2e: 234 checks in 22 specs (Chromium 156)
  • npm run e2e:firefox: 34 checks (Firefox 159): DNR routing works, Chromium-only blocks fail with permission.missing
  • npm run build, npm run build:firefox

Notes for review

  • Route delayMs (≤ 30 s) uses setTimeout in src/browser/routes.ts; CLAUDE.md reserves timers for hybridScheduler.ts. Keep as a documented exception or lower the cap?
  • Console capture starts when a run first attaches the debugger to a tab (messages since run start are replayed).
  • The mock-api-mobile guide example and the wiki recipe pass import checks but were not run in a browser.

Docs: lesson 07 + glossary, usage guide section + example, 13 wiki pages, M3 status in IMPLEMENTATION/PLAN/README/Roadmap.

🤖 Generated with Claude Code

## M3: Network and environment (Chromium via CDP) Completes M3.1–M3.5 on top of the run-scoped CDP sessions (M3.0). Version stays 0.4.0; 0.5.0 ships with M4. ### New - **Route** (`route`): fulfill / abort / continue / modify / redirect through CDP `Fetch`; abort/redirect through `declarativeNetRequest` session rules (also Firefox, no debugging bar). Newest matching rule wins; rules are removed at run end; stale rules cleared at worker start. - **HAR Record** (`har-record`): HAR 1.2 metadata (≤ 500 entries), no bodies/cookies/auth headers, sensitive query values redacted; output, dataset or download. - **Emulate** (`emulate`): device presets, viewport, scale, UA, locale, timezone, geolocation, color scheme, reduced motion, offline. Only what the run changed is reset, also after failure. - **Clear Site Data** (`clear-site-data`): exact origins via `browsingData` (Chromium only; Firefox refuses and no longer requests the permission). - **Console capture**: per-step console messages and exceptions in the run record, Reports, HTML and JSON; Assert subject `console-errors`. - `m3Host.ts`: one feature set per run, tab claims (one run owns a tab's overrides), every cleanup runs before the debugger is released. ### Verification - `npm run check`: 771 unit/DOM tests, guide/learning/wiki checks - `npm run e2e`: 234 checks in 22 specs (Chromium 156) - `npm run e2e:firefox`: 34 checks (Firefox 159): DNR routing works, Chromium-only blocks fail with `permission.missing` - `npm run build`, `npm run build:firefox` ### Notes for review - Route `delayMs` (≤ 30 s) uses `setTimeout` in `src/browser/routes.ts`; CLAUDE.md reserves timers for `hybridScheduler.ts`. Keep as a documented exception or lower the cap? - Console capture starts when a run first attaches the debugger to a tab (messages since run start are replayed). - The `mock-api-mobile` guide example and the wiki recipe pass import checks but were not run in a browser. Docs: lesson 07 + glossary, usage guide section + example, 13 wiki pages, M3 status in IMPLEMENTATION/PLAN/README/Roadmap. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Builds on the run-scoped CDP sessions (605203e). m3Host gives each run one feature set
(routes, environment, telemetry) on the run's debugger lease; finishRun runs every feature
cleanup, then releases the debugger, on success, failure and Stop. Route and emulation
overrides claim the tab so concurrent runs cannot fight over it.

- Route: fulfill/abort/continue/modify/redirect via CDP Fetch; abort/redirect via
  declarativeNetRequest session rules (also Firefox, no debugging bar). Newest match wins;
  reserved rule ids, stale rules removed at worker start.
- HAR Record: metadata-only HAR 1.2 (<= 500 entries), no bodies/cookies/auth headers,
  sensitive query values redacted, to output, dataset or download.
- Emulate: device presets, viewport, scale, UA, locale, timezone, geolocation, color scheme,
  reduced motion, offline; resets only what the run changed.
- Clear Site Data: exact origins only via browsingData (Chromium); Firefox refuses and its
  manifest no longer requests browsingData.
- Console: per-step console messages and exceptions on StepRecord.console (bounded, masked),
  in Reports/HTML/JSON; Assert subject console-errors.
- e2e: m3-route, m3-environment, m3-telemetry; Firefox checks DNR routing and clear
  permission.missing failures. m3-environment reloads before comparing (Playwright's own
  emulation is cleared by our reset until reload) and scopes its offline waits.
- Docs: lesson 07 section + glossary, guide section + mock-api-mobile example, 13 wiki
  pages, M3 marked done in IMPLEMENTATION/PLAN/README/Roadmap (version stays 0.4.0 until M4).

Verified: npm run check (771 tests), npm run e2e (234 checks, 22 specs, Chromium 156),
npm run e2e:firefox (34 checks, Firefox 159), build and build:firefox.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
akib merged commit eb5ae4fdb4 into main 2026-11-10 08:33:20 +00:00
Sign in to join this conversation.
No reviewers
No labels
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
akib/blockflow!6
No description provided.