[PR #5182] [MERGED] feat(environment): build environments from browser scenario captures #6806

Closed
opened 2026-11-01 21:43:10 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5182
Author: @earakely-scale
Created: 10/19/2026
Status: ✅ Merged
Merged: 10/19/2026
Merged by: @gensokyo-dev

Base: main ← Head: feat/environment-scenario-capture


📝 Commits (10+)

  • 46dd8f0 feat(mcp): serve the MCP server over streamable HTTP
  • b0ec63c fix(mcp): harden the streamable HTTP listener's session replacement and shutdown
  • 9ed8f06 fix(mcp): compare the media type proper and bind before creating the server
  • b76f354 fix(mcp): classify loopback from the bound address and keep startup failures out of onerror
  • fb22df3 fix(mcp): match Accept ranges exactly and keep a session whose shutdown failed
  • 54a7475 refactor(mcp): release the listener through one helper
  • 1741882 fix(mcp): fire the shutdown hook once, stop awaiting the probe's tee and keep every Set-Cookie
  • 354b4d8 fix(mcp): latch startup signals so the HTTP entry never ends without cleanup
  • 136d073 fix(mcp): keep a startup signal's exit status through the entry's normal return
  • a23f5f1 fix(mcp): close the connection after a reply sent before the body was read

📊 Changes

24 files changed (+1443 additions, -77 deletions)

View changed files

📝 docs/agent-environments.md (+86 -0)
📝 docs/mcp-contracts.md (+1 -1)
➕ docs/specs/agent-environments/scenario-capture/plan.md (+20 -0)
➕ docs/specs/agent-environments/scenario-capture/spec.md (+62 -0)
➕ docs/specs/agent-environments/scenario-capture/tasks.md (+10 -0)
➕ docs/specs/agent-environments/scenario-capture/verification.md (+144 -0)
📝 docs/web-network-captures.md (+11 -1)
📝 scripts/ci/scopes.mjs (+1 -1)
📝 src/application/environment/environmentBundle.ts (+2 -2)
📝 src/application/environment/environmentExport.test.ts (+7 -2)
➕ src/application/environment/environmentScenario.test.ts (+129 -0)
📝 src/application/environment/environmentSource.test.ts (+1 -1)
📝 src/application/environment/environmentSource.ts (+76 -48)
📝 src/cli/environmentCommands.ts (+1 -1)
📝 src/contracts/analysisViewToolContracts.ts (+1 -1)
📝 src/domain/analysisView/WebNetworkProjectionAccumulator.ts (+10 -4)
📝 src/domain/analysisView/analysisView.ts (+7 -2)
📝 src/domain/analysisView/analysisViewDataAdmission.ts (+7 -3)
📝 src/domain/analysisView/environmentManifestView.ts (+44 -8)
➕ src/domain/analysisView/scenarioCaptureRecords.test.ts (+189 -0)

...and 4 more files

📄 Description

Change

environment-manifest, environment-serve and environment-export accept capture_browser_scenario Evidence alongside HAR Evidence. A browser session captured directly by REA becomes a replay environment through the existing commands. Transactions keep request-order ordinals and source pointers; redacted URLs and ambiguous links remain unrepresented. Refs #4933.

This original PR includes main after #4955/#4975/#4999 and the author’s subsequent redaction/body-budget corrections. Followups reserve copied/transformed text before validation or decoding, omit request text from replay projection, preserve exact response bytes and cleanup ownership, normalize portable Windows test inventories, select dependent CI lanes, and count body coverage over represented requests. Marker-bearing bodies replay their redacted bytes; bodies emptied by redaction remain unavailable. No new action/tool/dependency. Default MCP remains stdio; environment HTTP is explicit.

Validation

Final head cbd45eb72, Linux x64, Node 24.18.0 / npm 11.16.0:

  • Full typecheck/build/lint/format/docs/knip/catalog gate: 11 tasks passed; canonical product-catalog checks: 10 passed. Broader CLI/MCP/domain regression on d2416ca54: 657 tests/47 files; author/redaction/coverage changes then passed 145 related source tests and 5 final coverage cases. Scope and earlier run details are in docs/specs/agent-environments/scenario-capture/verification.md.
  • Original/fixed retained-parent counterexample, controlled 128 KiB budget: original admitted and decoded once; fixed returned resource_constraint before decoding. No OOM induced; the existing 96 MiB projection budget remains.
  • Actual Chrome 156.0.8078.4: interactive page capture (10 transactions/50 events/2 tools) and three live GitHub API responses (3 transactions/15 events/3 tools), without HAR, with zero dropped events. POST replay plus every public response replayed twice through the official HTTP SDK, matching body/status/Evidence/provenance. Declared secrets/transport credentials were removed; ordinary selected values remained. Both listeners and owned browser profiles were cleaned. Final complete task: 24.867 s / 19.021 s CPU / 1394.27 MiB family RSS.
  • The same actual captures produced identical manifests through CLI and default stdio MCP with HTTP variables present: 3.666 s / 3.570 s CPU / 478.99 MiB.
  • Scenario bundle: byte-exact capture/manifest and checkout package exported; generated Dockerfile built unchanged. Fresh non-root container replayed all three real responses twice, preserving provenance and discovery/card parity; package tarball removed and owned container cleaned: 41.597 s / 7.795 s CPU / 423.29 MiB.
  • Real pinned framework: observed agent-env 0.9.1334, ran that actual scenario bundle, passed its three-tool smoke task, tore down the sandbox, and reported no new containers or supervised descendants: 131.648 s / 80.938 s CPU / 375.98 MiB. Framework infrastructure/base-image layers were prepared.

Heavy tasks run serially on one CPU/worker; standalone Docker build/runtime limits are 4/2 GiB. Final static gate: 321.822 s / 308.573 s CPU / 4529.34 MiB family RSS. RSS sums sampled descendants and may double-count shared pages; Docker daemon/container CPU and peaks and agent tokens are unmeasured. Matched source projection samples preserve the result digest and do not establish a general speed/memory improvement.

Scope: historical response replay without application-state reconstruction. The checkout package was tested; the published package, Windows/macOS execution and the author’s five-application/model runs are not claimed as this followup’s verification. Initial probe/setup failures and missing-body observations are explicitly recorded in the verification document. Original initial readiness is preserved below.

Author readiness

Human owner: @earakely-scale

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

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.

🤖 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/5182 **Author:** [@earakely-scale](https://github.com/earakely-scale) **Created:** 10/19/2026 **Status:** ✅ Merged **Merged:** 10/19/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `feat/environment-scenario-capture` --- ### 📝 Commits (10+) - [`46dd8f0`](https://github.com/morluto/rea/commit/46dd8f0e2b5ff74e09821e09e51bc6fd47f3bc1a) feat(mcp): serve the MCP server over streamable HTTP - [`b0ec63c`](https://github.com/morluto/rea/commit/b0ec63cc0399ad9ca7bd00a65cb1c2d753cfd47b) fix(mcp): harden the streamable HTTP listener's session replacement and shutdown - [`9ed8f06`](https://github.com/morluto/rea/commit/9ed8f06f75ea772dfd81d552142b059852e530c3) fix(mcp): compare the media type proper and bind before creating the server - [`b76f354`](https://github.com/morluto/rea/commit/b76f354d76384abe56b079b0b37e1367d1908efd) fix(mcp): classify loopback from the bound address and keep startup failures out of onerror - [`fb22df3`](https://github.com/morluto/rea/commit/fb22df370b5146b3798b6f83e64317e2785ecfcb) fix(mcp): match Accept ranges exactly and keep a session whose shutdown failed - [`54a7475`](https://github.com/morluto/rea/commit/54a747560207c06196a1ba4eb8b8ca062f15ddc5) refactor(mcp): release the listener through one helper - [`1741882`](https://github.com/morluto/rea/commit/174188279b6ce482354966ed542436514d3d4624) fix(mcp): fire the shutdown hook once, stop awaiting the probe's tee and keep every Set-Cookie - [`354b4d8`](https://github.com/morluto/rea/commit/354b4d8c0867f3d0eadaae2b0dfe42cea810287e) fix(mcp): latch startup signals so the HTTP entry never ends without cleanup - [`136d073`](https://github.com/morluto/rea/commit/136d073fa019fb8a1c5ef95ff70ecaf6d34676c4) fix(mcp): keep a startup signal's exit status through the entry's normal return - [`a23f5f1`](https://github.com/morluto/rea/commit/a23f5f13524b5403794f3599e26f93cc18398820) fix(mcp): close the connection after a reply sent before the body was read ### 📊 Changes **24 files changed** (+1443 additions, -77 deletions) <details> <summary>View changed files</summary> 📝 `docs/agent-environments.md` (+86 -0) 📝 `docs/mcp-contracts.md` (+1 -1) ➕ `docs/specs/agent-environments/scenario-capture/plan.md` (+20 -0) ➕ `docs/specs/agent-environments/scenario-capture/spec.md` (+62 -0) ➕ `docs/specs/agent-environments/scenario-capture/tasks.md` (+10 -0) ➕ `docs/specs/agent-environments/scenario-capture/verification.md` (+144 -0) 📝 `docs/web-network-captures.md` (+11 -1) 📝 `scripts/ci/scopes.mjs` (+1 -1) 📝 `src/application/environment/environmentBundle.ts` (+2 -2) 📝 `src/application/environment/environmentExport.test.ts` (+7 -2) ➕ `src/application/environment/environmentScenario.test.ts` (+129 -0) 📝 `src/application/environment/environmentSource.test.ts` (+1 -1) 📝 `src/application/environment/environmentSource.ts` (+76 -48) 📝 `src/cli/environmentCommands.ts` (+1 -1) 📝 `src/contracts/analysisViewToolContracts.ts` (+1 -1) 📝 `src/domain/analysisView/WebNetworkProjectionAccumulator.ts` (+10 -4) 📝 `src/domain/analysisView/analysisView.ts` (+7 -2) 📝 `src/domain/analysisView/analysisViewDataAdmission.ts` (+7 -3) 📝 `src/domain/analysisView/environmentManifestView.ts` (+44 -8) ➕ `src/domain/analysisView/scenarioCaptureRecords.test.ts` (+189 -0) _...and 4 more files_ </details> ### 📄 Description ## Change `environment-manifest`, `environment-serve` and `environment-export` accept `capture_browser_scenario` Evidence alongside HAR Evidence. A browser session captured directly by REA becomes a replay environment through the existing commands. Transactions keep request-order ordinals and source pointers; redacted URLs and ambiguous links remain unrepresented. Refs #4933. This original PR includes main after #4955/#4975/#4999 and the author’s subsequent redaction/body-budget corrections. Followups reserve copied/transformed text before validation or decoding, omit request text from replay projection, preserve exact response bytes and cleanup ownership, normalize portable Windows test inventories, select dependent CI lanes, and count body coverage over represented requests. Marker-bearing bodies replay their redacted bytes; bodies emptied by redaction remain unavailable. No new action/tool/dependency. **Default MCP remains stdio; environment HTTP is explicit.** ## Validation Final head `cbd45eb72`, Linux x64, Node 24.18.0 / npm 11.16.0: - Full typecheck/build/lint/format/docs/knip/catalog gate: **11 tasks passed**; canonical product-catalog checks: **10 passed**. Broader CLI/MCP/domain regression on d2416ca54: **657 tests/47 files**; author/redaction/coverage changes then passed **145 related source tests** and **5 final coverage cases**. Scope and earlier run details are in `docs/specs/agent-environments/scenario-capture/verification.md`. - Original/fixed retained-parent counterexample, controlled 128 KiB budget: original admitted and decoded once; fixed returned `resource_constraint` before decoding. No OOM induced; the existing 96 MiB projection budget remains. - **Actual Chrome 156.0.8078.4:** interactive page capture (10 transactions/50 events/2 tools) and three live GitHub API responses (3 transactions/15 events/3 tools), without HAR, with zero dropped events. POST replay plus every public response replayed twice through the official HTTP SDK, matching body/status/Evidence/provenance. Declared secrets/transport credentials were removed; ordinary selected values remained. Both listeners and owned browser profiles were cleaned. Final complete task: **24.867 s / 19.021 s CPU / 1394.27 MiB** family RSS. - The same actual captures produced identical manifests through CLI and **default stdio MCP with HTTP variables present**: **3.666 s / 3.570 s CPU / 478.99 MiB**. - **Scenario bundle:** byte-exact capture/manifest and checkout package exported; generated Dockerfile built unchanged. Fresh non-root container replayed all three real responses twice, preserving provenance and discovery/card parity; package tarball removed and owned container cleaned: **41.597 s / 7.795 s CPU / 423.29 MiB**. - **Real pinned framework:** observed `agent-env 0.9.1334`, ran that actual scenario bundle, passed its three-tool smoke task, tore down the sandbox, and reported no new containers or supervised descendants: **131.648 s / 80.938 s CPU / 375.98 MiB**. Framework infrastructure/base-image layers were prepared. Heavy tasks run serially on one CPU/worker; standalone Docker build/runtime limits are 4/2 GiB. Final static gate: **321.822 s / 308.573 s CPU / 4529.34 MiB** family RSS. RSS sums sampled descendants and may double-count shared pages; Docker daemon/container CPU and peaks and agent tokens are unmeasured. Matched source projection samples preserve the result digest and do not establish a general speed/memory improvement. Scope: historical response replay without application-state reconstruction. The checkout package was tested; the published package, Windows/macOS execution and the author’s five-application/model runs are not claimed as this followup’s verification. Initial probe/setup failures and missing-body observations are explicitly recorded in the verification document. Original initial readiness is preserved below. ## Author readiness Human owner: @earakely-scale - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## 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, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. 🤖 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-11-01 21:43: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#6806
No description provided.