Skip to content

perf(control-plane): streamed integrity snapshots, planner snapshot chain, package-repository memo (#227 E1#1/#4) - #249

Merged
chrisdpurcell merged 2 commits into
testingfrom
cp-perf
Sep 1, 2026
Merged

chrisdpurcell merged 2 commits into
testingfrom
cp-perf

Conversation

@chrisdpurcell

Copy link
Copy Markdown
Collaborator

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_repository is memoized per process on a content fingerprint. Measured on the real tree: reconcile --check median 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

  • Chaining still detects an undeclared write; a write between windows is never attributed to the next provider; a changed manifest invalidates the memo; the chain is proven live in the planner (capture counts 4 vs 5 with the window disabled).

Verification

Remote tests/control_plane + tests/package_contract/test_repository.py → 1095 passed; five validators, ruff, basedpyright, markdownlint — exit 0.

…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
@chrisdpurcell
chrisdpurcell marked this pull request as ready for review September 1, 2026 21:05
@chrisdpurcell
chrisdpurcell merged commit 0153054 into testing Sep 1, 2026
3 of 4 checks passed
@chrisdpurcell
chrisdpurcell deleted the cp-perf branch September 1, 2026 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant