[PR #3140] [CLOSED] fix(browser): explain service-worker policy rejections #5637

Closed
opened 2026-10-31 01:08:10 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/3140
Author: @pollychen-lab
Created: 10/14/2026
Status: ❌ Closed

Base: main ← Head: agent/browser-service-worker-remediation


📝 Commits (3)

  • 3f9e5b1 fix(browser): explain service-worker policy rejections
  • b0ab3c5 fix(browser): distinguish service-worker guard failures
  • d9f262a fix(browser): keep service-worker guard check first

📊 Changes

9 files changed (+134 additions, -20 deletions)

View changed files

📝 docs/browser-scenario-contract.md (+4 -0)
📝 scripts/lib/browser-scenario-service-workers-e2e.mjs (+2 -2)
📝 src/browser/PlaywrightScenarioServiceWorkers.ts (+31 -11)
📝 src/browser/PlaywrightScenarioSession.test.ts (+32 -7)
📝 src/domain/analysisErrorPresentation.ts (+12 -0)
📝 src/domain/analysisErrorProjection.test.ts (+45 -0)
📝 src/domain/analysisErrorProjection.ts (+2 -0)
📝 src/domain/browserObservationError.ts (+4 -0)
📝 src/domain/browserObservationErrors.ts (+2 -0)

📄 Description

Summary

Fixes #3126. When the existing browser-scenario policy blocks an attached page because of a service worker, the error now names that cause and explains how the caller can permit it.

Problem and expected behavior

Previously the policy returned the generic target_not_allowed reason, which projected to a generic target_unavailable message recommending rea doctor. Callers could not tell that environment.service_workers: "allow" was the relevant option. The policy continues to refuse capture by default; its error now identifies the service-worker condition and points to the caller-controlled remedy.

Change and scope

Added the service_worker_blocked browser-observation reason and use it when the scenario policy finds a controlling or registered service worker. The shared error projection preserves the existing top-level target_unavailable code/category, while emitting the specific reason, message, and remediation. No capture policy or target behavior changes. This is an isolated fix within the existing capability; maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: PlaywrightScenarioServiceWorkers.assertBlocked, the policy boundary that detects the condition.
  • Contribution scope fit and linked maintainer decision: routine correction to existing behavior; not applicable.
  • CLI and MCP/tool-catalog contract: for this policy rejection, details.reason changes from target_not_allowed to service_worker_blocked; the top-level code remains target_unavailable.
  • Provider, bridge, target-format, or platform compatibility: browser scenario capture only; other target_not_allowed cases are unchanged.
  • Evidence, artifact, provenance, or reconstruction contract: no change; blocked capture still returns no scenario observation.
  • Target selection, authority, upstream behavior, and cleanup details: the caller-selected target and policy are unchanged; REA does not remove registrations.
  • Generated metadata, package, or installation impact: none.

Expected effects: read existing files and captured data only. No process launch, attachment, instrumentation, mutation, network access, or target execution was added by this change.

Evidence and regression coverage

  • Tests added or updated: session policy tests assert the new reason for detected service-worker violations; error projection test checks the public code, category, details, message, and remediation.
  • Base reproduction: existing scenario tests returned target_not_allowed; they now verify the more specific reason while preserving the block.
  • Representative projected response: code: "target_unavailable", details.reason: "service_worker_blocked", a message naming the service worker, and remediation to set environment.service_workers to allow or remove the registration using caller-owned browser controls.
  • Remaining proof gaps: The full real-browser verifier was attempted but could not discover Snap Chromium's DevToolsActivePort file and timed out after 60 seconds, although Chromium logged a DevTools WebSocket endpoint; session and error-projection boundaries passed.

Validation performed

  • npm run test:focused -- src/domain/analysisErrorProjection.test.ts src/browser/PlaywrightScenarioSession.test.ts — 68 tests passed.
  • npm run check:fast — typecheck and lint passed.
  • npx oxfmt --check ... on the changed files — passed.
  • git diff --check — passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: top-level error code/category remain unchanged; consumers matching the specific details.reason should accept the new service_worker_blocked value.
  • Real Hopper/Ghidra, browser, or OS coverage: mocked browser-session boundary tests passed; real Chromium/CDP coverage remains unverified.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the default block remains enforced, and the remediation does not ask REA to remove or modify registrations.

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.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed; no docs or generated files needed changes.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 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/3140 **Author:** [@pollychen-lab](https://github.com/pollychen-lab) **Created:** 10/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `agent/browser-service-worker-remediation` --- ### 📝 Commits (3) - [`3f9e5b1`](https://github.com/morluto/rea/commit/3f9e5b1ca501fe0232b7e262d62339f0a24bae2b) fix(browser): explain service-worker policy rejections - [`b0ab3c5`](https://github.com/morluto/rea/commit/b0ab3c5f550bf499f8d5f8aaba0f975cda3f7b24) fix(browser): distinguish service-worker guard failures - [`d9f262a`](https://github.com/morluto/rea/commit/d9f262a0772f015526638f3a1e49147b7ea93d4a) fix(browser): keep service-worker guard check first ### 📊 Changes **9 files changed** (+134 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `docs/browser-scenario-contract.md` (+4 -0) 📝 `scripts/lib/browser-scenario-service-workers-e2e.mjs` (+2 -2) 📝 `src/browser/PlaywrightScenarioServiceWorkers.ts` (+31 -11) 📝 `src/browser/PlaywrightScenarioSession.test.ts` (+32 -7) 📝 `src/domain/analysisErrorPresentation.ts` (+12 -0) 📝 `src/domain/analysisErrorProjection.test.ts` (+45 -0) 📝 `src/domain/analysisErrorProjection.ts` (+2 -0) 📝 `src/domain/browserObservationError.ts` (+4 -0) 📝 `src/domain/browserObservationErrors.ts` (+2 -0) </details> ### 📄 Description ## Summary Fixes #3126. When the existing browser-scenario policy blocks an attached page because of a service worker, the error now names that cause and explains how the caller can permit it. ## Problem and expected behavior Previously the policy returned the generic `target_not_allowed` reason, which projected to a generic `target_unavailable` message recommending `rea doctor`. Callers could not tell that `environment.service_workers: "allow"` was the relevant option. The policy continues to refuse capture by default; its error now identifies the service-worker condition and points to the caller-controlled remedy. ## Change and scope Added the `service_worker_blocked` browser-observation reason and use it when the scenario policy finds a controlling or registered service worker. The shared error projection preserves the existing top-level `target_unavailable` code/category, while emitting the specific reason, message, and remediation. No capture policy or target behavior changes. This is an isolated fix within the existing capability; maintainer scope decision is not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: `PlaywrightScenarioServiceWorkers.assertBlocked`, the policy boundary that detects the condition. - Contribution scope fit and linked maintainer decision: routine correction to existing behavior; not applicable. - CLI and MCP/tool-catalog contract: for this policy rejection, `details.reason` changes from `target_not_allowed` to `service_worker_blocked`; the top-level code remains `target_unavailable`. - Provider, bridge, target-format, or platform compatibility: browser scenario capture only; other `target_not_allowed` cases are unchanged. - Evidence, artifact, provenance, or reconstruction contract: no change; blocked capture still returns no scenario observation. - Target selection, authority, upstream behavior, and cleanup details: the caller-selected target and policy are unchanged; REA does not remove registrations. - Generated metadata, package, or installation impact: none. Expected effects: read existing files and captured data only. No process launch, attachment, instrumentation, mutation, network access, or target execution was added by this change. ## Evidence and regression coverage - Tests added or updated: session policy tests assert the new reason for detected service-worker violations; error projection test checks the public code, category, details, message, and remediation. - Base reproduction: existing scenario tests returned `target_not_allowed`; they now verify the more specific reason while preserving the block. - Representative projected response: `code: "target_unavailable"`, `details.reason: "service_worker_blocked"`, a message naming the service worker, and remediation to set `environment.service_workers` to `allow` or remove the registration using caller-owned browser controls. - Remaining proof gaps: The full real-browser verifier was attempted but could not discover Snap Chromium's DevToolsActivePort file and timed out after 60 seconds, although Chromium logged a DevTools WebSocket endpoint; session and error-projection boundaries passed. ## Validation performed - `npm run test:focused -- src/domain/analysisErrorProjection.test.ts src/browser/PlaywrightScenarioSession.test.ts` — 68 tests passed. - `npm run check:fast` — typecheck and lint passed. - `npx oxfmt --check ...` on the changed files — passed. - `git diff --check` — passed. ## Compatibility, safety, and release - Breaking changes or migration steps: top-level error code/category remain unchanged; consumers matching the specific `details.reason` should accept the new `service_worker_blocked` value. - Real Hopper/Ghidra, browser, or OS coverage: mocked browser-session boundary tests passed; real Chromium/CDP coverage remains unverified. - Package or release metadata impact: none. - Security, privacy, process, or containment review: the default block remains enforced, and the remediation does not ask REA to remove or modify registrations. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed; no docs or generated files needed changes. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:08:10 +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#5637
No description provided.