[PR #5319] [MERGED] feat(environment): extract the initial state a capture's reads observed #6877

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

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5319
Author: @earakely-scale
Created: 10/20/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @kaoru0822-kitauji

Base: main ← Head: feat/environment-state-view


📝 Commits (10+)

  • ad439bd feat(environment): extract the initial state a capture's reads observed
  • 7a668b7 Merge main into feat/environment-state-view
  • f2c9a2e fix(environment): bound state at redacted writes; infer identity only from items
  • 2999128 fix(environment): keep first sightings, one list pointer and linear field unions
  • a5c7b92 fix(environment): keep post-write values and partial lists out of the initial state
  • 4e93547 docs(environment): scope item-shaped and deleted written paths out of documents
  • aba9cb1 fix(environment): count writes in flight when a value changes between reads
  • 856c8c0 Merge main into feat/environment-state-view
  • 55480bd chore: merge main (5fa4defc) into environment state view
  • 9fee36d fix(environment): catch cross-tool changes across writes; read only item totals

📊 Changes

39 files changed (+3555 additions, -220 deletions)

View changed files

📝 .agents/skills/reverse-engineer-anything/references/evidence-workflows.md (+6 -0)
📝 docs/agent-environments.md (+12 -0)
📝 docs/mcp-contracts.md (+7 -0)
➕ docs/specs/agent-environments/state-view/plan.md (+28 -0)
➕ docs/specs/agent-environments/state-view/spec.md (+74 -0)
➕ docs/specs/agent-environments/state-view/tasks.md (+12 -0)
➕ docs/specs/agent-environments/state-view/verification.md (+118 -0)
📝 docs/web-network-captures.md (+97 -0)
📝 scripts/ci/scopes.mjs (+1 -1)
📝 src/application/analysisView/AnalysisViewService.test.ts (+102 -55)
📝 src/application/analysisView/AnalysisViewService.ts (+17 -6)
📝 src/application/environment/environmentReplay.ts (+4 -19)
📝 src/application/environment/environmentScenario.test.ts (+2 -2)
📝 src/application/environment/environmentSource.ts (+7 -58)
📝 src/contracts/analysisDetail.test.ts (+2 -0)
📝 src/contracts/analysisViewToolContracts.ts (+1 -1)
📝 src/domain/analysisView/EnvironmentManifestAccumulator.ts (+9 -2)
➕ src/domain/analysisView/EnvironmentStateAccumulator.ts (+283 -0)
➕ src/domain/analysisView/EnvironmentStateExtraction.ts (+587 -0)
📝 src/domain/analysisView/WebNetworkProjectionAccumulator.ts (+4 -4)

...and 19 more files

📄 Description

Summary

Add the read-only environment-state analysis view for HAR and browser-scenario Evidence. It reports observed initial entities, documents and checked read plans, using the same grouping and template rules as the environment manifest. It does not serve tools from state or implement write effects / the AgentEnv data plane.

Refs #4933. Scope is local inspection of already-captured Evidence: no new provider, target execution, injection, network access or mutation.

Changes

  • Bound initial reads by recorded writes and preserve identity, artifact provenance, record ordinals, redaction markers and explicit recorded-view fallback reasons. File, inline and retained sources share the application workflow.
  • Reject state-backed plans when membership changes across a recorded write, including empty lists, or entity fields are added/removed. Keep each field's last observation across sparse projections so omitted fields cannot hide a write effect. Query strings remain distinct.
  • Recognize compact totalcount/itemcount envelope totals while excluding page counts and account IDs.
  • Remove repeated growing-array copies in API-base grouping and quadratic identity-key intersections. Keep byte admission and bounded membership sets at the owning boundary.
  • Preserve main's authenticated Evidence-file input and file-relative errors. Preserve the author's concurrent main merge and integrate current main. Documents remain limited to non-parameterized non-entity paths written by POST/PUT/PATCH; item-shaped and delete-only paths stay recorded. Public tool text and regression coverage state this limit.

Validation

  • 39 relevant source files: 493 tests passed, 3 existing skips. Eight cases reproduced before their fixes.
  • Broader CLI/MCP/environment/schema/qlog boundaries: 65 passed, 1 existing skip; both final state CLI/MCP cases rerun successfully. Default/compact schemas validate within the provider input budget.
  • Final serial static/build/artifact gate: 11 tasks passed. Final docs/catalog/format checks: 9 tasks passed; architecture guards and 5 README consistency tests passed.
  • Real Gitea 28.2.0: the same 3-exchange capture produces one erroneous post-create entity before the fix and none afterward; an 11-exchange CRUD capture preserves two initial issues and one document, with 6 exact HTTP replays. Fresh actual Chromium capture produces one entity and list/item plans. File CLI/default stdio MCP agree for both parent kinds.
  • Measured grouping and 15,001-field item projection improved with equal output digests; the 2,000-collection whole projection had overlapping warm timings. Peak memory did not decrease in the benchmark. One CPU/worker; maximum static/build process-family RSS about 4.6 GiB; no workspace OOM. Model token usage unmeasured.

Detailed results and scope: verification.md. The author's earlier 44-capture experiments are historical evidence, not rerun claims. No new macOS/Windows, model-task scoring, state serving or AgentEnv data-plane verification is claimed. A type first read only after a write under another root can still lack the earlier observation needed to detect the write's effect.

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/5319 **Author:** [@earakely-scale](https://github.com/earakely-scale) **Created:** 10/20/2026 **Status:** ✅ Merged **Merged:** 10/20/2026 **Merged by:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Base:** `main` ← **Head:** `feat/environment-state-view` --- ### 📝 Commits (10+) - [`ad439bd`](https://github.com/morluto/rea/commit/ad439bd2f26c61b442dcf758c2bb149e49657929) feat(environment): extract the initial state a capture's reads observed - [`7a668b7`](https://github.com/morluto/rea/commit/7a668b73f4783b42eb0e8ce1eeff079f86d53e22) Merge main into feat/environment-state-view - [`f2c9a2e`](https://github.com/morluto/rea/commit/f2c9a2e4462a7162224bec209f21dfa2622abe39) fix(environment): bound state at redacted writes; infer identity only from items - [`2999128`](https://github.com/morluto/rea/commit/2999128baedceabc738e9a5aa69bfcfec39a55f1) fix(environment): keep first sightings, one list pointer and linear field unions - [`a5c7b92`](https://github.com/morluto/rea/commit/a5c7b9236c48094bc4af24ae055e8d67e3968477) fix(environment): keep post-write values and partial lists out of the initial state - [`4e93547`](https://github.com/morluto/rea/commit/4e93547c846444e891e2a2267425c316e6ee5218) docs(environment): scope item-shaped and deleted written paths out of documents - [`aba9cb1`](https://github.com/morluto/rea/commit/aba9cb15c8836b7592a51743d79bceab4dfd99af) fix(environment): count writes in flight when a value changes between reads - [`856c8c0`](https://github.com/morluto/rea/commit/856c8c0b50ec11e4ba96cb6172b7cfe01ef6829f) Merge main into feat/environment-state-view - [`55480bd`](https://github.com/morluto/rea/commit/55480bdf7e3275e3be8903e53baabe28be81a9a9) chore: merge main (5fa4defc) into environment state view - [`9fee36d`](https://github.com/morluto/rea/commit/9fee36d3155145fa8e568b34713e0e68c7675216) fix(environment): catch cross-tool changes across writes; read only item totals ### 📊 Changes **39 files changed** (+3555 additions, -220 deletions) <details> <summary>View changed files</summary> 📝 `.agents/skills/reverse-engineer-anything/references/evidence-workflows.md` (+6 -0) 📝 `docs/agent-environments.md` (+12 -0) 📝 `docs/mcp-contracts.md` (+7 -0) ➕ `docs/specs/agent-environments/state-view/plan.md` (+28 -0) ➕ `docs/specs/agent-environments/state-view/spec.md` (+74 -0) ➕ `docs/specs/agent-environments/state-view/tasks.md` (+12 -0) ➕ `docs/specs/agent-environments/state-view/verification.md` (+118 -0) 📝 `docs/web-network-captures.md` (+97 -0) 📝 `scripts/ci/scopes.mjs` (+1 -1) 📝 `src/application/analysisView/AnalysisViewService.test.ts` (+102 -55) 📝 `src/application/analysisView/AnalysisViewService.ts` (+17 -6) 📝 `src/application/environment/environmentReplay.ts` (+4 -19) 📝 `src/application/environment/environmentScenario.test.ts` (+2 -2) 📝 `src/application/environment/environmentSource.ts` (+7 -58) 📝 `src/contracts/analysisDetail.test.ts` (+2 -0) 📝 `src/contracts/analysisViewToolContracts.ts` (+1 -1) 📝 `src/domain/analysisView/EnvironmentManifestAccumulator.ts` (+9 -2) ➕ `src/domain/analysisView/EnvironmentStateAccumulator.ts` (+283 -0) ➕ `src/domain/analysisView/EnvironmentStateExtraction.ts` (+587 -0) 📝 `src/domain/analysisView/WebNetworkProjectionAccumulator.ts` (+4 -4) _...and 19 more files_ </details> ### 📄 Description ## Summary Add the read-only `environment-state` analysis view for HAR and browser-scenario Evidence. It reports observed initial entities, documents and checked read plans, using the same grouping and template rules as the environment manifest. It does not serve tools from state or implement write effects / the AgentEnv data plane. Refs #4933. Scope is local inspection of already-captured Evidence: no new provider, target execution, injection, network access or mutation. ## Changes - Bound initial reads by recorded writes and preserve identity, artifact provenance, record ordinals, redaction markers and explicit recorded-view fallback reasons. File, inline and retained sources share the application workflow. - Reject state-backed plans when membership changes across a recorded write, including empty lists, or entity fields are added/removed. Keep each field's last observation across sparse projections so omitted fields cannot hide a write effect. Query strings remain distinct. - Recognize compact `totalcount`/`itemcount` envelope totals while excluding page counts and account IDs. - Remove repeated growing-array copies in API-base grouping and quadratic identity-key intersections. Keep byte admission and bounded membership sets at the owning boundary. - Preserve main's authenticated Evidence-file input and file-relative errors. Preserve the author's concurrent main merge and integrate current main. Documents remain limited to non-parameterized non-entity paths written by POST/PUT/PATCH; item-shaped and delete-only paths stay recorded. Public tool text and regression coverage state this limit. ## Validation - 39 relevant source files: 493 tests passed, 3 existing skips. Eight cases reproduced before their fixes. - Broader CLI/MCP/environment/schema/qlog boundaries: 65 passed, 1 existing skip; both final state CLI/MCP cases rerun successfully. Default/compact schemas validate within the provider input budget. - Final serial static/build/artifact gate: 11 tasks passed. Final docs/catalog/format checks: 9 tasks passed; architecture guards and 5 README consistency tests passed. - Real Gitea 28.2.0: the same 3-exchange capture produces one erroneous post-create entity before the fix and none afterward; an 11-exchange CRUD capture preserves two initial issues and one document, with 6 exact HTTP replays. Fresh actual Chromium capture produces one entity and list/item plans. File CLI/default stdio MCP agree for both parent kinds. - Measured grouping and 15,001-field item projection improved with equal output digests; the 2,000-collection whole projection had overlapping warm timings. Peak memory did not decrease in the benchmark. One CPU/worker; maximum static/build process-family RSS about 4.6 GiB; no workspace OOM. Model token usage unmeasured. Detailed results and scope: [verification.md](docs/specs/agent-environments/state-view/verification.md). The author's earlier 44-capture experiments are historical evidence, not rerun claims. No new macOS/Windows, model-task scoring, state serving or AgentEnv data-plane verification is claimed. A type first read only after a write under another root can still lack the earlier observation needed to detect the write's effect. ## 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:45 +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#6877
No description provided.