[PR #6897] [MERGED] feat(environment): serve writes by what their recordings show #7431

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

📋 Pull Request Information

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

Base: main ← Head: feat/environment-write-rules


📝 Commits (10+)

  • b49177e fix(environment): keep read-only POSTs out of the write list
  • d5a1fa9 fix(environment): take an entity an unplanned write made when a read first shows it
  • 004b064 fix(environment): plan a create into the type its returned id is read under
  • d8f9c05 fix(environment): end a type's initial reads at the write its reads disagree across
  • 64e472a fix(environment): replay request lines that show entities in another form
  • 28c3ae9 docs(environment): specify and record the state-target changes
  • 48d7fae fix(environment): keep a read-only POST a write when its evidence is incomplete
  • 5d48df7 fix(environment): answer a field selection only when the state shows it exactly
  • ce2301d fix(environment): hold adopted entities and linked creates to what the recording shows
  • 48106e1 Merge remote-tracking branch 'origin/main' into feat/environment-state-targets

📊 Changes

91 files changed (+9988 additions, -750 deletions)

View changed files

📝 docs/agent-environments.md (+53 -10)
📝 docs/specs/agent-environments/list-queries/spec.md (+9 -5)
📝 docs/specs/agent-environments/state-coverage/spec.md (+4 -2)
📝 docs/specs/agent-environments/state-view/spec.md (+32 -2)
📝 docs/specs/agent-environments/state-writes/spec.md (+187 -18)
➕ docs/specs/agent-environments/write-rules/plan.md (+14 -0)
➕ docs/specs/agent-environments/write-rules/spec.md (+83 -0)
➕ docs/specs/agent-environments/write-rules/tasks.md (+14 -0)
➕ docs/specs/agent-environments/write-rules/verification.md (+169 -0)
📝 docs/web-network-captures.md (+46 -29)
📝 scripts/lib/owned-verifier-terminal.mjs (+4 -5)
📝 scripts/lib/verifier-file-snapshots.mjs (+4 -5)
➕ scripts/lib/verifier-source-loader.mjs (+17 -0)
📝 scripts/lib/verify-package-commands.mjs (+4 -5)
📝 scripts/lib/windows-owned-command.mjs (+5 -2)
📝 src/application/environment/environmentCompare.ts (+19 -16)
➕ src/application/environment/environmentCompareBulk.test.ts (+84 -0)
📝 src/application/environment/environmentCompareIds.ts (+61 -10)
📝 src/application/environment/environmentCompareMatch.ts (+64 -4)
📝 src/application/environment/environmentState.ts (+15 -2)

...and 71 more files

📄 Description

Summary

Environment writes were refused for common generated values, bulk targets and view ordering, while other writes could be confirmed without checking their own fields. This change derives those effects from retained capture Evidence and withholds unsupported or contradictory effects. Part of #4933; #6385 is merged.

  • Preserve field-level attribution and compact equality facts for earlier structured values.
  • Share atomic bulk writes, item actions, clocks/tokens, enveloped bodies and recorded-query enforcement through the existing application layer.
  • Classify complete multi-row responses and verify every recorded call using the serving renderer. Keep literal JSON IDs and nested parsed-body memory ownership intact.
  • Preserve initial/learned ordering and counter formats. Mask envelope members only with independent repeat evidence on every concrete path.
  • Advertise fixed values and optional recorded-query defaults in compatible schemas, with shared runtime enforcement.

Verifier source imports also release their transformer service; the Windows graph loads only when needed so copied Linux supervisors remain independent.

This reads retained captures and mutates only the served local environment state. Existing states remain readable; optional metadata and derived Evidence identities can change. The original author's subsequent bulk tests and measurements are retained.

Verification

Qualified at 7360127f2: 1,284 source tests in 52 files, serial typecheck/lint/module boundaries/format/knip/metadata, architecture/docs/build, and four compiled real HTTP MCP write cases passed. Eight process/cold-loader cases passed at 7f01865c2 (five platform skips); unchanged schema/process boundaries passed 22 cases at 034eed476. Authenticated regressions failed at their pinned pre-fix revisions, including two newly reproduced single/bulk precision regressions at 7f01865c2. Live Gemini execution was not performed.

Latest review fixes preserve confirmed body absence separately from unretained/malformed bodies; use observed entity fields to distinguish arrays from envelopes; reject unmodelled nested token links; and recognize string-valued bulk counts. One shared generated-value owner now checks complete nested-clock objects for creates and single/bulk updates, including constants, omissions, equal clock members and formats. Obsolete request/envelope interpretations and the partial nested-clock validator were removed.

At 7360127f2, four immutable public application recordings were rebuilt and served through real CLI listeners and the MCP SDK (412 calls). Initial reads match 109/114, session reads 302/358, preserving every previous result record by record. Sessions apply six NocoDB mutations, one Ghost deletion and one Metabase update. Write-response proof now precedes stored-read restamping, preserving Metabase's millisecond response/microsecond read semantics. Bulk rendering consumes validated response fields directly, with separately budgeted storage facts; unequal response clocks remain refused even when the later read normalizes them. Mailpit's unparsed text/plain acknowledgement is withheld as body-unusable; its previous session already refused the missing target, so no applied mutation was lost. Read mismatches and unserved creates remain coverage gaps. Original apps and the historical 50-capture census were not re-recorded/requalified by this follow-up.

A separate SQLite-backed HTTP application was recorded by actual Chromium (11 API exchanges), inspected/projected by public CLI commands, then reset and compared against the real HTTP MCP SDK. Seven successful JSON responses matched the native app and one missing-target request was refused atomically by both, including subset/full updates, atomic refusal and ordered deletion. This controlled fixture does not establish live third-party multi-row behavior. At the current head its complete fresh-process run took 12.619 s wall / 11.600 s CPU / 555.8 MiB peak, with verified payload cleanup; artifacts and source hashes were retained locally.

Final CI passed 17,919 source tests (13 skips), static/docs/build, agentenv, three native package baselines and shard 8. Its only test failures are three WASM prefix assertions and ten Windows typed-error assertions independently reproduced on main be2811e414; six portable shards were canceled by fail-fast. Baseline comparison and authorized bypass. Greptile reviewed 91 files with no new findings; all threads are resolved.

Cost and limits

Measurements at 352c0278d, versus main 3ce311757: three alternating fresh four-capture sweeps had median wall/CPU/peak 5.360 s / 4.263 s / 327.3 MiB → 4.960 s / 4.357 s / 323.1 MiB; ranges overlap. Complete SDK replay (403 → 413 calls), one observation per revision, took 20.905 s / 19.039 s / 508.7 MiB → 23.426 s / 19.396 s / 462.8 MiB. Different coverage and sampling prevent a general performance-improvement claim.

The current head separately qualified at 4.861 s / 4.601 s / 326.7 MiB for extraction and 19.984 s / 19.593 s / 514.1 MiB for 412 SDK calls. These observations are not pooled with the earlier cohort. Current catalog estimates (cl100k_base) are NocoDB 9,408, Ghost 11,355, Metabase 12,648 and Mailpit 2,955 tokens. Instructions, named arguments and text replies were also counted; the historical counting method was independently matched. Actual model usage, prompts and client/protocol rendering were not measured. No token saving is claimed.

Tasks used one CPU, 3 GiB early-stop / 4 GiB hard memory limits and zero swap. Recorded-data tasks verified payload cleanup with no observed OOM/limit events. Final whole-scope counters were unavailable. Builds, downloads and identity preparation are excluded from measurements. Detailed evidence and historical author measurements.

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.

🔄 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/6897 **Author:** [@earakely-scale](https://github.com/earakely-scale) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `feat/environment-write-rules` --- ### 📝 Commits (10+) - [`b49177e`](https://github.com/morluto/rea/commit/b49177e425f102570572a70f98880112c07c8c1a) fix(environment): keep read-only POSTs out of the write list - [`d5a1fa9`](https://github.com/morluto/rea/commit/d5a1fa98e5b8a7e49ab419d56bbdc82487772073) fix(environment): take an entity an unplanned write made when a read first shows it - [`004b064`](https://github.com/morluto/rea/commit/004b064b85465e40944df7ac0cf65a07f44dc6d1) fix(environment): plan a create into the type its returned id is read under - [`d8f9c05`](https://github.com/morluto/rea/commit/d8f9c05264dd8267d12a4462e3b632ed89fef5d2) fix(environment): end a type's initial reads at the write its reads disagree across - [`64e472a`](https://github.com/morluto/rea/commit/64e472a769b974501bbb8db19183d1ac6fc6978a) fix(environment): replay request lines that show entities in another form - [`28c3ae9`](https://github.com/morluto/rea/commit/28c3ae97a9c8b8a45771cc396d2d3516b26c1518) docs(environment): specify and record the state-target changes - [`48d7fae`](https://github.com/morluto/rea/commit/48d7faee9015b5985d0e0cd75fb952f6d7a3af05) fix(environment): keep a read-only POST a write when its evidence is incomplete - [`5d48df7`](https://github.com/morluto/rea/commit/5d48df7bfc2f7a69fdd843ffa333b25233b39e27) fix(environment): answer a field selection only when the state shows it exactly - [`ce2301d`](https://github.com/morluto/rea/commit/ce2301d263138de9871faed04b3ed174a3db5c19) fix(environment): hold adopted entities and linked creates to what the recording shows - [`48106e1`](https://github.com/morluto/rea/commit/48106e103effaa04525edea73af6583d388c4448) Merge remote-tracking branch 'origin/main' into feat/environment-state-targets ### 📊 Changes **91 files changed** (+9988 additions, -750 deletions) <details> <summary>View changed files</summary> 📝 `docs/agent-environments.md` (+53 -10) 📝 `docs/specs/agent-environments/list-queries/spec.md` (+9 -5) 📝 `docs/specs/agent-environments/state-coverage/spec.md` (+4 -2) 📝 `docs/specs/agent-environments/state-view/spec.md` (+32 -2) 📝 `docs/specs/agent-environments/state-writes/spec.md` (+187 -18) ➕ `docs/specs/agent-environments/write-rules/plan.md` (+14 -0) ➕ `docs/specs/agent-environments/write-rules/spec.md` (+83 -0) ➕ `docs/specs/agent-environments/write-rules/tasks.md` (+14 -0) ➕ `docs/specs/agent-environments/write-rules/verification.md` (+169 -0) 📝 `docs/web-network-captures.md` (+46 -29) 📝 `scripts/lib/owned-verifier-terminal.mjs` (+4 -5) 📝 `scripts/lib/verifier-file-snapshots.mjs` (+4 -5) ➕ `scripts/lib/verifier-source-loader.mjs` (+17 -0) 📝 `scripts/lib/verify-package-commands.mjs` (+4 -5) 📝 `scripts/lib/windows-owned-command.mjs` (+5 -2) 📝 `src/application/environment/environmentCompare.ts` (+19 -16) ➕ `src/application/environment/environmentCompareBulk.test.ts` (+84 -0) 📝 `src/application/environment/environmentCompareIds.ts` (+61 -10) 📝 `src/application/environment/environmentCompareMatch.ts` (+64 -4) 📝 `src/application/environment/environmentState.ts` (+15 -2) _...and 71 more files_ </details> ### 📄 Description ## Summary Environment writes were refused for common generated values, bulk targets and view ordering, while other writes could be confirmed without checking their own fields. This change derives those effects from retained capture Evidence and withholds unsupported or contradictory effects. Part of #4933; #6385 is merged. - Preserve field-level attribution and compact equality facts for earlier structured values. - Share atomic bulk writes, item actions, clocks/tokens, enveloped bodies and recorded-query enforcement through the existing application layer. - Classify complete multi-row responses and verify every recorded call using the serving renderer. Keep literal JSON IDs and nested parsed-body memory ownership intact. - Preserve initial/learned ordering and counter formats. Mask envelope members only with independent repeat evidence on every concrete path. - Advertise fixed values and optional recorded-query defaults in compatible schemas, with shared runtime enforcement. Verifier source imports also release their transformer service; the Windows graph loads only when needed so copied Linux supervisors remain independent. This reads retained captures and mutates only the served local environment state. Existing states remain readable; optional metadata and derived Evidence identities can change. The original author's subsequent bulk tests and measurements are retained. ## Verification Qualified at `7360127f2`: **1,284 source tests in 52 files**, serial typecheck/lint/module boundaries/format/knip/metadata, architecture/docs/build, and four compiled real HTTP MCP write cases passed. Eight process/cold-loader cases passed at `7f01865c2` (five platform skips); unchanged schema/process boundaries passed 22 cases at `034eed476`. Authenticated regressions failed at their pinned pre-fix revisions, including two newly reproduced single/bulk precision regressions at `7f01865c2`. Live Gemini execution was not performed. Latest review fixes preserve confirmed body absence separately from unretained/malformed bodies; use observed entity fields to distinguish arrays from envelopes; reject unmodelled nested token links; and recognize string-valued bulk counts. One shared generated-value owner now checks complete nested-clock objects for creates and single/bulk updates, including constants, omissions, equal clock members and formats. Obsolete request/envelope interpretations and the partial nested-clock validator were removed. At `7360127f2`, four immutable public application recordings were rebuilt and served through real CLI listeners and the MCP SDK (412 calls). Initial reads match **109/114**, session reads **302/358**, preserving every previous result record by record. Sessions apply six NocoDB mutations, one Ghost deletion and one Metabase update. Write-response proof now precedes stored-read restamping, preserving Metabase's millisecond response/microsecond read semantics. Bulk rendering consumes validated response fields directly, with separately budgeted storage facts; unequal response clocks remain refused even when the later read normalizes them. Mailpit's unparsed text/plain acknowledgement is withheld as `body-unusable`; its previous session already refused the missing target, so no applied mutation was lost. Read mismatches and unserved creates remain coverage gaps. Original apps and the historical 50-capture census were not re-recorded/requalified by this follow-up. A separate SQLite-backed HTTP application was recorded by actual Chromium (11 API exchanges), inspected/projected by public CLI commands, then reset and compared against the real HTTP MCP SDK. Seven successful JSON responses matched the native app and one missing-target request was refused atomically by both, including subset/full updates, atomic refusal and ordered deletion. This controlled fixture does not establish live third-party multi-row behavior. At the current head its complete fresh-process run took 12.619 s wall / 11.600 s CPU / 555.8 MiB peak, with verified payload cleanup; artifacts and source hashes were retained locally. Final CI passed 17,919 source tests (13 skips), static/docs/build, agentenv, three native package baselines and shard 8. Its only test failures are three WASM prefix assertions and ten Windows typed-error assertions independently reproduced on main `be2811e414`; six portable shards were canceled by fail-fast. [Baseline comparison and authorized bypass](https://github.com/morluto/rea/pull/6897#issuecomment-6384016687). Greptile reviewed 91 files with no new findings; all threads are resolved. ## Cost and limits Measurements at `352c0278d`, versus main `3ce311757`: three alternating fresh four-capture sweeps had median wall/CPU/peak **5.360 s / 4.263 s / 327.3 MiB → 4.960 s / 4.357 s / 323.1 MiB**; ranges overlap. Complete SDK replay (403 → 413 calls), one observation per revision, took **20.905 s / 19.039 s / 508.7 MiB → 23.426 s / 19.396 s / 462.8 MiB**. Different coverage and sampling prevent a general performance-improvement claim. The current head separately qualified at **4.861 s / 4.601 s / 326.7 MiB** for extraction and **19.984 s / 19.593 s / 514.1 MiB** for 412 SDK calls. These observations are not pooled with the earlier cohort. Current catalog estimates (`cl100k_base`) are NocoDB 9,408, Ghost 11,355, Metabase 12,648 and Mailpit 2,955 tokens. Instructions, named arguments and text replies were also counted; the historical counting method was independently matched. Actual model usage, prompts and client/protocol rendering were not measured. No token saving is claimed. Tasks used one CPU, 3 GiB early-stop / 4 GiB hard memory limits and zero swap. Recorded-data tasks verified payload cleanup with no observed OOM/limit events. Final whole-scope counters were unavailable. Builds, downloads and identity preparation are excluded from measurements. [Detailed evidence and historical author measurements](https://github.com/earakely-scale/rea/blob/130121f74282700b1e236685808d23b26efccab6/docs/specs/agent-environments/write-rules/verification.md). ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:47:49 +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#7431
No description provided.