perf(control-plane): streamed integrity snapshots, planner snapshot chain, package-repository memo (#227 E1#1/#4) - #249
Merged
Merged
Conversation
…ge repository The CP-PROVIDER-INTEGRITY guard captures a whole-repository snapshot before and after every provider invocation. Both captures read each declared target in full, retained every byte, and hashed each one twice; on this repository that is 201 captures over 65 declared paths per `reconcile --check`, including a 10 MB frozen provider binary. Captures now stream: the precondition hash is seeded with the pre-read mode and fed chunk by chunk, `retain_content=False` drops the bytes a comparison never reads, and the content digest is computed only when it is promised. `reconcile --check` falls from 17.5 s to 13.7 s (median of three) and peak RSS from 185 MB to 117 MB. `provider_snapshot_chain()` additionally lets one planning pass hand the AFTER snapshot of one provider to the next provider declaring the identical target set — 201 captures to 102, 12.5 s to 10.4 s in-process. It is opt-in because the window carries an obligation the guard cannot check: that nothing but the providers themselves touches a declared path between two invocations. Wiring it into the planner is left to a change that owns that file. `build_package_repository` serves a repeated build of an unchanged tree from an in-process memo keyed on the size and mtime of every file under `standards/` and `catalogs/`: a second build costs 0.05 s instead of 2.75 s. The stat-keyed content cache proposed for the snapshot guard is not added — that surface reads and hashes bytes on purpose. Refs #227
`plan_reconciliation` now wraps its provider invocations in `provider_snapshot_chain()`, so the AFTER snapshot the CP-PROVIDER-INTEGRITY guard takes for one provider becomes the BEFORE snapshot of the next provider declaring the identical target set: 201 captures per `reconcile --check` fall to 102, and the command falls from 13.7 s to 9.5 s (median of three; 17.5 s before this leg's streaming change). Planning is the only pass that enters the window, and it satisfies the window's obligation by construction: it invokes every render, validate and transform provider and writes nothing itself. Publication, the executor's post-publication verification providers, and the MCP and migration call sites stay outside it, because a window spanning a control-plane write would report the control plane's own bytes as the next provider's violation. Leaving any window now drops the slot rather than restoring the outer pass's older reading, so no chained snapshot can outlive the pass that vouched for it. Refs #227
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Control-plane efficiency (#227 E1 items 1 and 4): integrity snapshots stream their hash and no longer retain file bytes; the planning pass enters an opt-in
provider_snapshot_chain()window so consecutive providers share one snapshot (N+1 captures instead of 2N) while the executor's post-publication verification, migrations, and MCP call sites stay outside it;build_package_repositoryis memoized per process on a content fingerprint. Measured on the real tree:reconcile --checkmedian 17.50 s → 9.52 s, peak RSS 185 MB → 117 MB, captures 201 → 102. The stat-keyed content cache was declined (it would weaken the CP-PROVIDER-INTEGRITY guard).Governing work
Supporting: #227
Acceptance coverage
Verification
Remote
tests/control_plane+tests/package_contract/test_repository.py→ 1095 passed; five validators, ruff, basedpyright, markdownlint — exit 0.