[PR #7120] [MERGED] feat(browser): add retained scenario summaries and paged views #7654

Closed
opened 2026-11-03 13:39:25 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/7120
Author: @gensokyo-dev
Created: 10/25/2026
Status: ✅ Merged
Merged: 10/25/2026
Merged by: @gensokyo-dev

Base: main ← Head: feat/6167-browser-scenario-summary


📝 Commits (2)

  • 247897c feat(browser): retain compact scenario summaries and selected views
  • 4238265 fix(browser): preserve cleanup diagnostics and summary caveats

📊 Changes

19 files changed (+2297 additions, -90 deletions)

View changed files

📝 .agents/skills/reverse-engineer-anything/references/runtime-observation.md (+2 -0)
📝 docs/browser-scenario-contract.md (+55 -0)
➕ experiments/analysis-efficiency/browser-scenario-summary.md (+63 -0)
➕ experiments/analysis-efficiency/browser-scenario-summary.mjs (+412 -0)
➕ src/application/analysisView/BrowserScenarioViews.test.ts (+521 -0)
📝 src/application/environment/environmentScenario.test.ts (+5 -5)
📝 src/cli/finishAnalysisCommand.ts (+8 -0)
📝 src/cliBrowserScenarioCommands.ts (+36 -27)
📝 src/contracts/analysisViewToolContracts.ts (+1 -1)
📝 src/contracts/browserScenarioToolContracts.ts (+13 -4)
📝 src/domain/analysisView/analysisView.ts (+28 -3)
➕ src/domain/analysisView/browserScenarioNetworkView.ts (+193 -0)
➕ src/domain/analysisView/browserScenarioView.ts (+388 -0)
➕ src/domain/analysisView/browserScenarioViewSchemas.ts (+250 -0)
📝 src/server/createServer.ts (+1 -0)
📝 src/server/registerBrowserScenarioTool.ts (+35 -50)
➕ tests/boundary/cli/browserScenarioSummaryCli.test.ts (+146 -0)
📝 tests/boundary/cli/scenarioCliInputDiagnostics.test.ts (+32 -0)
📝 tests/boundary/mcp/browserScenarioMcp.test.ts (+108 -0)

📄 Description

Summary

Fixes #6167. A ten-action TodoMVC capture returned about 628 KB / 395k estimated tokens even when the analyst needed only the final screen and selected records. capture_browser_scenario now accepts detail: "summary", retains the complete parent Evidence, and returns step outcomes, the focus accessibility tree and retained event/network counts. Complete delivery remains the default.

CLI uses --detail summary --evidence_output FILE. inspect_analysis_view adds browser-scenario steps, events, transactions and UTF-16 text pages. Filters and artifact/content selection preserve original record identities and source omissions; exhausting a page never upgrades capture completeness.

Change and scope

  • Domain projection owns the summary and selections. CLI/MCP reuse existing Evidence delivery and publication. Delivery detail never enters scenario parameters or its digest.
  • Immutable parent validation and a metadata-only transaction index are reused for the retained parent's lifetime. Pages materialize only selected rows. Unrequested/legacy-unknown network observation remains distinct from an observed empty result, and transactions without retained requests remain visible.
  • CLI finalization reuses the shared owner, retaining completed Evidence during late cancellation and typed cleanup failure. Its explicit initial-failure projection preserves browser CLI diagnostics across cleanup retries.
  • Existing capture authority and producer behavior are preserved. This adds historical projection and caller-selected Evidence publication; a separate new-provider/runtime scope decision is not applicable. Follow the contribution scope.
  • Reuses Kaoru0822's ab3893d48 prototype with attribution retained. #4163 overlaps record views and proposes broader producer/state contracts; this PR uses current producers.

Contract and boundary impact

The named CLI/MCP contracts share canonical scenario semantics and projections. The SDK's structural admission stays separate from canonical semantic diagnostics so full/compact clients retain precise field paths. Browser views explicitly have no file artifact (artifact: null). Transaction identity is parent Evidence + transaction ID; text pages retain the complete artifact digest. Authored guidance/docs are updated; generated catalogs and packaged skills remain build outputs.

Validation performed

  • npm run check — passed, including typecheck, lint, format, Knip, architecture/module boundaries and typed lint of 5,402 files. An earlier run hit the 8 GiB family-RSS guard; returning to the checker's existing 1 GiB Go soft target completed the full check without changing its configuration or coverage.
  • npm run docs:check — passed, including nine README consistency tests.
  • Focused source/CLI/MCP route checks — 44 passed; final schema/projection/CLI lifecycle checks — 30 passed, including every canonical SDK-converted schema, opt-in content, orphan transactions, unknown selection, Unicode/text truncation, late-cleanup cancellation and typed cleanup failure.
  • Review fixes: inherited limitations count has a failing-original/passing-fixed regression; 27 projection/finalizer/CLI/provider-cleanup tests passed, including the four cleanup regressions caught by CI. Relative paths failed with the original verifier and passed after resolving at entry. An empty transaction-page control falsely passed the original verifier and is rejected by the corrected exact-ID oracle. npm run check:fast passed after these changes.
  • Real Chromium 156.0.8078.47 / TodoMVC JavaScript ES5 pinned at ff43b02e59dfa604386bb382034b2cd07c2bcd8a: two alternating sessions per revision, each with cold/warm captures, all checked 11 completed steps, 36 events, 12 transactions and the final five todo labels. Separate real-browser checks passed failed-step focus, CLI summary/bundle publication and MCP evidence-file text readback, including a fresh post-review run with the stronger limitation/transaction checks. Reproducer: experiments/analysis-efficiency/browser-scenario-summary.mjs and its adjacent guide.

Baseline 160d821ac; performance feature 247897c72 (before the small review/cleanup fixes), based on bc143125e. Linux x64, Node 24.22.1/npm 11.16.0, two CPUs. Each session includes discovery, two captures, complete-parent export and verification; summary sessions additionally perform five retained queries per capture.

Measured cost Complete baseline Summary + selected reads
Capture reply, cl100k_base estimate ~395,270 tokens 2,800–2,834 tokens
Cold task including raw discovery/arguments/replies ~1,295,042 tokens ~920,306 tokens
Whole-session elapsed, median 8.92 s 13.34 s
Whole-family CPU, median 8.95 s 14.38 s
Sampled family RSS peak, median 1.61 GiB 1.87 GiB

These are serialization estimates, not actual model usage; protocol framing, prompts and client rendering are unmeasured. RSS sums the process family every 100 ms, may count shared pages more than once and can miss short peaks. The first generic-view call also pays ~3.4 s of client schema compilation; three warmed step reads totalled 27–44 ms. No latency or memory improvement is claimed. OS file caches were not cold. Windows/macOS and other browsers were not verified.

Author readiness

Human owner: @gensokyo-dev

  • 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.

🔄 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/7120 **Author:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Created:** 10/25/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `feat/6167-browser-scenario-summary` --- ### 📝 Commits (2) - [`247897c`](https://github.com/morluto/rea/commit/247897c72322cf414ba4f5dec7aed194e27a04ad) feat(browser): retain compact scenario summaries and selected views - [`4238265`](https://github.com/morluto/rea/commit/42382651b59229eb400f07b012eb437ced7d5fb6) fix(browser): preserve cleanup diagnostics and summary caveats ### 📊 Changes **19 files changed** (+2297 additions, -90 deletions) <details> <summary>View changed files</summary> 📝 `.agents/skills/reverse-engineer-anything/references/runtime-observation.md` (+2 -0) 📝 `docs/browser-scenario-contract.md` (+55 -0) ➕ `experiments/analysis-efficiency/browser-scenario-summary.md` (+63 -0) ➕ `experiments/analysis-efficiency/browser-scenario-summary.mjs` (+412 -0) ➕ `src/application/analysisView/BrowserScenarioViews.test.ts` (+521 -0) 📝 `src/application/environment/environmentScenario.test.ts` (+5 -5) 📝 `src/cli/finishAnalysisCommand.ts` (+8 -0) 📝 `src/cliBrowserScenarioCommands.ts` (+36 -27) 📝 `src/contracts/analysisViewToolContracts.ts` (+1 -1) 📝 `src/contracts/browserScenarioToolContracts.ts` (+13 -4) 📝 `src/domain/analysisView/analysisView.ts` (+28 -3) ➕ `src/domain/analysisView/browserScenarioNetworkView.ts` (+193 -0) ➕ `src/domain/analysisView/browserScenarioView.ts` (+388 -0) ➕ `src/domain/analysisView/browserScenarioViewSchemas.ts` (+250 -0) 📝 `src/server/createServer.ts` (+1 -0) 📝 `src/server/registerBrowserScenarioTool.ts` (+35 -50) ➕ `tests/boundary/cli/browserScenarioSummaryCli.test.ts` (+146 -0) 📝 `tests/boundary/cli/scenarioCliInputDiagnostics.test.ts` (+32 -0) 📝 `tests/boundary/mcp/browserScenarioMcp.test.ts` (+108 -0) </details> ### 📄 Description ## Summary Fixes #6167. A ten-action TodoMVC capture returned about 628 KB / 395k estimated tokens even when the analyst needed only the final screen and selected records. `capture_browser_scenario` now accepts `detail: "summary"`, retains the complete parent Evidence, and returns step outcomes, the focus accessibility tree and retained event/network counts. Complete delivery remains the default. CLI uses `--detail summary --evidence_output FILE`. `inspect_analysis_view` adds browser-scenario steps, events, transactions and UTF-16 text pages. Filters and artifact/content selection preserve original record identities and source omissions; exhausting a page never upgrades capture completeness. ## Change and scope - Domain projection owns the summary and selections. CLI/MCP reuse existing Evidence delivery and publication. Delivery detail never enters scenario parameters or its digest. - Immutable parent validation and a metadata-only transaction index are reused for the retained parent's lifetime. Pages materialize only selected rows. Unrequested/legacy-unknown network observation remains distinct from an observed empty result, and transactions without retained requests remain visible. - CLI finalization reuses the shared owner, retaining completed Evidence during late cancellation and typed cleanup failure. Its explicit initial-failure projection preserves browser CLI diagnostics across cleanup retries. - Existing capture authority and producer behavior are preserved. This adds historical projection and caller-selected Evidence publication; a separate new-provider/runtime scope decision is not applicable. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). - Reuses Kaoru0822's `ab3893d48` prototype with attribution retained. #4163 overlaps record views and proposes broader producer/state contracts; this PR uses current producers. ## Contract and boundary impact The named CLI/MCP contracts share canonical scenario semantics and projections. The SDK's structural admission stays separate from canonical semantic diagnostics so full/compact clients retain precise field paths. Browser views explicitly have no file artifact (`artifact: null`). Transaction identity is parent Evidence + transaction ID; text pages retain the complete artifact digest. Authored guidance/docs are updated; generated catalogs and packaged skills remain build outputs. ## Validation performed - `npm run check` — passed, including typecheck, lint, format, Knip, architecture/module boundaries and typed lint of 5,402 files. An earlier run hit the 8 GiB family-RSS guard; returning to the checker's existing 1 GiB Go soft target completed the full check without changing its configuration or coverage. - `npm run docs:check` — passed, including nine README consistency tests. - Focused source/CLI/MCP route checks — 44 passed; final schema/projection/CLI lifecycle checks — 30 passed, including every canonical SDK-converted schema, opt-in content, orphan transactions, unknown selection, Unicode/text truncation, late-cleanup cancellation and typed cleanup failure. - Review fixes: inherited limitations count has a failing-original/passing-fixed regression; 27 projection/finalizer/CLI/provider-cleanup tests passed, including the four cleanup regressions caught by CI. Relative paths failed with the original verifier and passed after resolving at entry. An empty transaction-page control falsely passed the original verifier and is rejected by the corrected exact-ID oracle. `npm run check:fast` passed after these changes. - Real Chromium 156.0.8078.47 / TodoMVC JavaScript ES5 pinned at `ff43b02e59dfa604386bb382034b2cd07c2bcd8a`: two alternating sessions per revision, each with cold/warm captures, all checked 11 completed steps, 36 events, 12 transactions and the final five todo labels. Separate real-browser checks passed failed-step focus, CLI summary/bundle publication and MCP evidence-file text readback, including a fresh post-review run with the stronger limitation/transaction checks. Reproducer: `experiments/analysis-efficiency/browser-scenario-summary.mjs` and its adjacent guide. Baseline `160d821ac`; performance feature `247897c72` (before the small review/cleanup fixes), based on `bc143125e`. Linux x64, Node 24.22.1/npm 11.16.0, two CPUs. Each session includes discovery, two captures, complete-parent export and verification; summary sessions additionally perform five retained queries per capture. | Measured cost | Complete baseline | Summary + selected reads | | --- | ---: | ---: | | Capture reply, cl100k_base estimate | ~395,270 tokens | 2,800–2,834 tokens | | Cold task including raw discovery/arguments/replies | ~1,295,042 tokens | ~920,306 tokens | | Whole-session elapsed, median | 8.92 s | 13.34 s | | Whole-family CPU, median | 8.95 s | 14.38 s | | Sampled family RSS peak, median | 1.61 GiB | 1.87 GiB | These are serialization estimates, not actual model usage; protocol framing, prompts and client rendering are unmeasured. RSS sums the process family every 100 ms, may count shared pages more than once and can miss short peaks. The first generic-view call also pays ~3.4 s of client schema compilation; three warmed step reads totalled 27–44 ms. No latency or memory improvement is claimed. OS file caches were not cold. Windows/macOS and other browsers were not verified. ## Author readiness Human owner: @gensokyo-dev - [ ] 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 13:39:25 +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#7654
No description provided.