Fix nested inheritance history and budget accounting

This commit is contained in:
2026-09-30 00:04:02 +00:00
parent b45f7a0410
commit 83c59ea7d3
5 changed files with 187 additions and 9 deletions

View File

@@ -3,8 +3,31 @@
Reviewed implementation commits `78d4b59` through `2ca1f80` against the
[feature roadmap](named-inheritance.md), [implementation plan](implementation.md),
and the user's agreed sibling lookup, enclosing-first expansion, presence, and
provenance decisions. Both findings below require remediation. No implementation
fixes are included in this review.
provenance decisions. Both findings below are now resolved. The original review
evidence is retained below; source line references identify the reviewed baseline.
## Resolution — 2026-09-30
- The destination walker now detaches each mapping/sequence container before
replacing its child pointers. Retained enclosing templates remain immutable;
untouched subtrees remain shared, with existing retained-history accounting.
Regressions check value introduction, inherited control arrival/consumption,
container explanations, a three-generation chain, and sequence-contained scopes.
The nested-history regression failed before the fix and passes afterward.
- Budget accounting now maintains one logical document total and updates it from
old/new scope counts. Each scope receives the budget remaining after other
branches are reserved. Early expansion checks and final node/depth validation
remain in place. Boundary tests include independent scopes inside sequences,
unchanged sibling data, and consumed null directives.
- The maintained `BenchmarkInheritanceIndependentScopes` covers 256, 512, and
1,024 independent scopes. Allocations measured approximately 8.95, 17.87, and
36.12 MB/op respectively: roughly proportional to scope count. This benchmark
has a larger per-scope payload than the original review probe, so absolute
values are not a before/after comparison. No timing threshold was introduced.
- Validation after the fixes: `./scripts/check.sh`, `go test -race ./...`,
the new independent-scope benchmark, and the existing expansion/inspected-load
benchmarks passed on Linux. Existing redaction, ownership, and history-budget
tests remain passing; no public contract or limit was changed.
## 1. Preserve immutable enclosing snapshots during nested resolution