[PR #7036] [MERGED] fix(evidence): preserve JSON ownership across metadata rebinding #7595

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

📋 Pull Request Information

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

Base: main ← Head: fix/managed-projection-sharing-20261024


📝 Commits (1)

  • c65d19d fix(evidence): preserve JSON ownership across metadata rebinding

📊 Changes

2 files changed (+68 additions, -10 deletions)

View changed files

📝 src/domain/evidence.test.ts (+51 -1)
📝 src/domain/evidence.ts (+17 -9)

📄 Description

Summary

Main CI fails its low-headroom managed Evidence test because adding caller-path metadata loses the shared JSON sealing proof. Error projection then clones the completed report precisely when memory admission has refused more work.

Change and scope

Seal rebound Evidence through the existing JSON owner as well as the Evidence owner. Borrow each already-sealed source member before sealing the small changed envelope, so large result/parameter/location trees are shared. Use that single path for both caller-input metadata and snapshot subject-path rebinding; remove their separate shallow-freeze registrations.

The fix belongs to the domain Evidence owner. CLI/MCP, snapshot identity, raw caller paths, complete retained Evidence and error schemas are unchanged. Ordinary repair within existing contribution scope; a maintainer capability decision is not applicable. No new target execution, mutation authority, provider, configuration, package or generated-metadata changes. Tests read authored fixtures, launch CLI processes and create/delete temporary bundles.

Evidence and validation

  • Main CI 40120484609, shard 8: managedBundleReadGuards.test.ts fails at the original strict reference assertion. Local latest-main base 3f168af2 reproduces 1 failed / 10 passed. The existing test and admission limit remain unchanged.

  • Two new domain regressions fail on the original implementation for both rebinding producers: projected partial Evidence must retain its reference, payload references and semantic identity. Both pass after the owner fix; generic JSON parsing also reuses the sealed result.

  • Four exact test files covering Evidence, error projection, immutable JSON and the unchanged low-headroom integration test: 129 tests passed.

  • Snapshot/bundle/ledger: 30 passed, including a graph with >125,000 dependents. Real compiled CLI managed bundle/paging and cancellation/finalization: 16 passed. MCP managed member/artifact summary handlers: 5 passed. In total 180 tests in 10 files passed in serial batches (153.17 s wall / 173.56 s family CPU / 2031.3 MiB maximum sampled family RSS), build excluded.

  • Runtime build passed. Linux local fixtures exercise the actual managed parser and compiled CLI plus MCP handlers, not a new real external-provider claim. The low-headroom failure is injected at the production admission boundary with a simulated provider.

  • Rebased onto latest main 31fc9762 (independent Go parsing changes); runtime compilation and npm run check passed on the updated base (41.38 s wall / 70.46 s CPU / 2367.2 MiB sampled family RSS). git diff --check passed.

Measured bounds

A bounded source-level microbenchmark creates sealed Evidence, alternates both public rebinding operations, projects six resource errors, and serializes/hashes every complete response. Three fresh processes per variant, two CPUs, Node 24.22.1, 768 MiB V8 heap. All equivalent response bytes and SHA-256 digests match before/after; no token reduction is claimed.

Rows Median whole-process wall / family CPU, before → after Maximum sampled family RSS, before → after
100,000 2.289 / 2.604 s → 1.190 / 1.399 s 331.8 → 240.8 MiB
1 0.507 / 0.668 s → 0.471 / 0.596 s 116.9 → 111.5 MiB

The six warm projection/serialization operations take a median 1296 → 206 ms on the large input; the table also includes fresh imports and input construction. OS caches were uncontrolled. This isolates envelope/projection costs, not complete provider analysis; agent tokens/catalog/transport costs were not measured. An initial benchmark fixture used an invalid architecture and was rejected before analysis; its failed attempt is retained outside the repository and excluded from measurements. RSS sums descendants approximately every 100 ms and may double-count shared pages or miss short-lived/reparented children. Local test/benchmark runs use a 3 GiB sampled stop; no host OOM occurred.

Published head c65d19d5 passed complete selected CI: 32,815 tests passed, zero failed, 234 skipped, all eight built shards and the final CI required gate passed. Greptile review completed successfully with no actionable inline findings. Codex's separate review still reports running at merge preparation; it is not counted as completed. The final diff and both producing boundaries were manually inspected by the agent, and the original low-headroom assertion is unchanged.

Post-merge main 03ed0c63 passed actual main CI: 32,835 passed, zero failed, 234 skipped, all eight built shards, Windows/native package/real verification lanes and the final gate passed.

Author readiness

Human owner: @gensokyo-dev

The owner explicitly delegated readiness declarations and agent-managed review. Inspection and execution were performed by Codex; no separate human inspection is claimed.

  • 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/7036 **Author:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@gensokyo-dev](https://github.com/gensokyo-dev) **Base:** `main` ← **Head:** `fix/managed-projection-sharing-20261024` --- ### 📝 Commits (1) - [`c65d19d`](https://github.com/morluto/rea/commit/c65d19d517cb493e87cd183cce4ef07142020f89) fix(evidence): preserve JSON ownership across metadata rebinding ### 📊 Changes **2 files changed** (+68 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/domain/evidence.test.ts` (+51 -1) 📝 `src/domain/evidence.ts` (+17 -9) </details> ### 📄 Description ## Summary Main CI fails its low-headroom managed Evidence test because adding caller-path metadata loses the shared JSON sealing proof. Error projection then clones the completed report precisely when memory admission has refused more work. ## Change and scope Seal rebound Evidence through the existing JSON owner as well as the Evidence owner. Borrow each already-sealed source member before sealing the small changed envelope, so large result/parameter/location trees are shared. Use that single path for both caller-input metadata and snapshot subject-path rebinding; remove their separate shallow-freeze registrations. The fix belongs to the domain Evidence owner. CLI/MCP, snapshot identity, raw caller paths, complete retained Evidence and error schemas are unchanged. Ordinary repair within existing contribution scope; a maintainer capability decision is not applicable. No new target execution, mutation authority, provider, configuration, package or generated-metadata changes. Tests read authored fixtures, launch CLI processes and create/delete temporary bundles. ## Evidence and validation - [Main CI 40120484609](https://github.com/morluto/rea/actions/runs/40120484609), shard 8: `managedBundleReadGuards.test.ts` fails at the original strict reference assertion. Local latest-main base `3f168af2` reproduces **1 failed / 10 passed**. The existing test and admission limit remain unchanged. - Two new domain regressions fail on the original implementation for both rebinding producers: projected partial Evidence must retain its reference, payload references and semantic identity. Both pass after the owner fix; generic JSON parsing also reuses the sealed result. - Four exact test files covering Evidence, error projection, immutable JSON and the unchanged low-headroom integration test: **129 tests passed**. - Snapshot/bundle/ledger: **30 passed**, including a graph with >125,000 dependents. Real compiled CLI managed bundle/paging and cancellation/finalization: **16 passed**. MCP managed member/artifact summary handlers: **5 passed**. In total **180 tests in 10 files passed** in serial batches (153.17 s wall / 173.56 s family CPU / 2031.3 MiB maximum sampled family RSS), build excluded. - Runtime build passed. Linux local fixtures exercise the actual managed parser and compiled CLI plus MCP handlers, not a new real external-provider claim. The low-headroom failure is injected at the production admission boundary with a simulated provider. - Rebased onto latest main `31fc9762` (independent Go parsing changes); runtime compilation and `npm run check` passed on the updated base (41.38 s wall / 70.46 s CPU / 2367.2 MiB sampled family RSS). `git diff --check` passed. ## Measured bounds A bounded source-level microbenchmark creates sealed Evidence, alternates both public rebinding operations, projects six resource errors, and serializes/hashes every complete response. Three fresh processes per variant, two CPUs, Node 24.22.1, 768 MiB V8 heap. All equivalent response bytes and SHA-256 digests match before/after; no token reduction is claimed. | Rows | Median whole-process wall / family CPU, before → after | Maximum sampled family RSS, before → after | | --- | --- | --- | | 100,000 | 2.289 / 2.604 s → 1.190 / 1.399 s | 331.8 → 240.8 MiB | | 1 | 0.507 / 0.668 s → 0.471 / 0.596 s | 116.9 → 111.5 MiB | The six warm projection/serialization operations take a median 1296 → 206 ms on the large input; the table also includes fresh imports and input construction. OS caches were uncontrolled. This isolates envelope/projection costs, not complete provider analysis; agent tokens/catalog/transport costs were not measured. An initial benchmark fixture used an invalid architecture and was rejected before analysis; its failed attempt is retained outside the repository and excluded from measurements. RSS sums descendants approximately every 100 ms and may double-count shared pages or miss short-lived/reparented children. Local test/benchmark runs use a 3 GiB sampled stop; no host OOM occurred. Published head `c65d19d5` passed [complete selected CI](https://github.com/morluto/rea/actions/runs/40122342563): **32,815 tests passed, zero failed, 234 skipped**, all eight built shards and the final `CI required` gate passed. Greptile review completed successfully with no actionable inline findings. Codex's separate review still reports running at merge preparation; it is not counted as completed. The final diff and both producing boundaries were manually inspected by the agent, and the original low-headroom assertion is unchanged. Post-merge main `03ed0c63` passed [actual main CI](https://github.com/morluto/rea/actions/runs/40124173090): **32,835 passed, zero failed, 234 skipped**, all eight built shards, Windows/native package/real verification lanes and the final gate passed. ## Author readiness Human owner: @gensokyo-dev The owner explicitly delegated readiness declarations and agent-managed review. Inspection and execution were performed by Codex; no separate human inspection is claimed. - [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-03 13:38:59 +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#7595
No description provided.