Repository navigation
perf(install): locked install engine -- no-op and locked apply skip the pipeline (2-3x) - #4893
Conversation
A plain 'apm install' (or --frozen) on an unchanged project now decides 'No changes' from state alone: the lockfile written by this APM version, every locked package copy proving its locked content, the apm audit --ci baseline owner passing (manifest/lock identity, ledger owners, deployed files present and hashed, MCP config consistency, hook approval pins, the executables gate against the live policy) and, when a policy is in force, its dependency checks. Org policy is discovered and routed live on every run. Anything else, or any doubt, runs the full pipeline. No memo, no recorder. APM_INSTALL_FAST_PATH=0 turns it off. apm-spec-waiver: prototype for the lane C no-op bench; output is the no-op summary Co-authored-by: Copilot App <[email protected]>
…, WIP) Co-authored-by: Copilot App <[email protected]>
…file hash Every full install now records each deployed file's exact bytes in <cache>/deploy_v1/<hex[:2]>/<hex>, keyed by the canonical sha256 the lockfile records as its deployed_file_hashes value. This is the lane C deploy-store unit (S1): later commands can rebuild a deployed file from the lockfile hash alone. - Keys are exactly 64 lowercase hex characters (fullmatch), so no path. - Every read re-hashes the entry; a mismatch is evicted and returned as a miss. Linked buckets and entries are never followed; only regular files. - Writes go to an owner-only exclusive temp file, then os.replace; a warm install costs one lstat per file (same-size entries are left alone). - The lockfile phase reads each deployed file once to hash and store it. - Owner record deploy-store + guard transport-platform-deploy-store-verified-reads (frozen inventory + mutation case). apm-spec-waiver: machine-cache side store only; lockfile, deployed files and every OpenAPM-observable output are unchanged Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…-cache parsing W3b hardening at 42d3658: Windows junctions/reparse points are refused like symlinks; get(raw_sha256=...) lets a byte-exact restorer reject the other line-ending image sharing a normalized key; APM_NO_CACHE parses like get_cache_root. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…entity, no-delete apply (S2 car 1) Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…ordered plan to the renderer (S2) Co-authored-by: Copilot App <[email protected]>
…e's owners install/fast_output.render prints the header, target provenance, one cached header plus '(files unchanged)' (or the engine's per-package body) per locked package in install order, runs the pre-deploy merged MCP policy check and the MCP/LSP service reconciliation itself, then the post-install summary. The engine's empty diff now prints exactly the full no-op's output (validated on tree-10 and the lifecycle differential cells on danielmeppiel-perf-noop-diff @973dca8a). Co-authored-by: Copilot App <[email protected]>
…announcement The install's own policy gate announces the org policy outcome with the same logger (and records the banner, so the executables trust reader does not repeat it neutrally), then runs the dependency policy checks on the locked set; its fetch feeds the trust map, so discovery runs once. Co-authored-by: Copilot App <[email protected]>
… bound; cache clean QL red at c29777a: a refused `install --frozen` stored the changed local snapshot's bytes, because hashing wrote the store. Hashing now only stages {path: digest} per command run; InstallService.run commits the staged files after the install committed (and discards them before the pipeline), each re-read and re-verified, so a refused or failed install stores nothing. #4854 conditions: entries above 4 MiB are never stored; a command that added entries evicts least recently used ones above 256 MiB down to 80% (a verified read refreshes recency); `apm cache clean` empties the store through the canonical cleanup owner (cleanup guard consumer); DeployStore takes the cache root. Cells: size bound, entry bound, clean, staging contract, bytes changed after hashing, and an e2e that an empty or deleted store changes nothing. The frozen-local lifecycle oracle after the SUCCESSFUL accepted install now allows only self-verifying deploy-store entries holding the accepted deployment; every refused row is unchanged. Refs #4854 Co-authored-by: Copilot App <[email protected]>
… ruling) Co-authored-by: Copilot App <[email protected]>
…g declines - The engine's own policy/audit verification runs under fast_output.quiet(): its trust readers would report a policy miss neutrally before the header; render's policy gate announces it in the full run's place and wording. - noop_diff.sources_scan_clean: any pre-deploy scan finding in a package copy declines to the full pipeline, which prints those warnings. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…r 2)
QL's S2 binding rule, owned in the deploy store: the lockfile authorizes
nothing by itself. After an install commits, each dependency whose content
hash was verified this run, and whose every recorded file the integrators
produced or claimed and this run hashed, gets one render record keyed by
sha256(version, repo_url, resolved_commit, content_hash, sorted targets,
scope): {rel: [canonical digest, raw sha256 of the exact bytes]}, ascii_only
and the package's output body (fresh deploys only). A record is written only
when every blob it names is stored.
- DeployStore.package_record(...) validates the shape and refuses linked,
non-regular, oversized or malformed records (None = full run).
- record_matches(record, lock_hashes): exact equality with the lock's
deployed_file_hashes, so a hand-edited row pointing a path at another
cached blob is refused.
- get(digest, raw_sha256=...) refuses the other line-ending image.
Red-first rows: lock edit to another cached blob refused; CRLF image refused
by the recorded raw digest; another setup never reads the record; malformed
and linked records read as None; no record when a blob is not stored; e2e:
every installed package gets a record binding its lockfile hashes.
Co-authored-by: Copilot App <[email protected]>
A no-op install asks for the org policy several times (preflight, gate, exec trust, MCP); each ran discovery again, re-reading the git remote and re-fetching. discover_policy_with_chain is now memoized per command run (core/invocation_memo, keyed on every argument), reusing each answer except outcomes a retry in the same command may change (cached_stale, cache_miss_fetch_fail, incomplete_chain). Lifecycle scripts still drop the memo; a new command run discovers again. No .git/config parsing. Red-first: one command run discovers a found chain once and reads the git remote once (both fail without the memo); a transient failure is retried in the same run; the next run discovers again. apm-spec-waiver: policy discovery call count only; the resolved policy and every outcome are unchanged Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…le) (S2) Co-authored-by: Copilot App <[email protected]>
- render(frozen=True) runs the services phase with the frozen disposition and prints frozen_verified_line (the same owner as commands/install.py) after the summary. - The engine's empty diff traces 'no-op (desired state already deployed)', the S3 contract line. Co-authored-by: Copilot App <[email protected]>
…ng; harvest-only decorator (S2) Co-authored-by: Copilot App <[email protected]>
Apply output renders through the full run's owners with per-package bodies; frozen is a FrozenDisposition end to end. Co-authored-by: Copilot App <[email protected]>
…e; cache info Copilot threads on 9283d91: - Reads open with O_NONBLOCK (a FIFO is a miss, not a hang), reject oversized descriptors and read at most the bound + 1 (an entry grown out of band is a miss and is evicted). - put() verifies the incoming digest first; a same-size existing entry is kept only if it still hashes to its key, otherwise it is atomically replaced (so the next full install heals same-length damage). - Eviction scans only key-named entries in their own real shard (Windows junctions and linked shards refused; .tmp-*.part and strays untouched); the same scan feeds `apm cache info` (deployed entries and size). - The empty-store e2e ignores .apm-local/installation (a per-run id), and an e2e covers install -> cache info -> cache clean --force. Co-authored-by: Copilot App <[email protected]>
Cold: a refused install leaves deploy_v1 empty. Warm: after a successful install, a refused install leaves the whole cache byte-identical. Co-authored-by: Copilot App <[email protected]>
…e-resolved live (S4') Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…night) The fresh-install memo needs live re-derivation of every trust field and git-object verification; it moves to a dated follow-up, not this train. Co-authored-by: Copilot App <[email protected]>
…ecide skips the update notice The engine's present-copy check uses cache_pin.marker_is_current, the cache-pin owner's own predicate, instead of probing the marker itself (copy validity stays with drift.locked_copy_proof). APM_INSTALL_FAST_PATH=decide skips the update notice, which may create its cache or fetch. The one umask read that must swap uses the most private temporary mask, and a guard keeps every other module off os.umask. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because fast installs can bypass carried-licence validation and publish altered executable permissions despite package-content hash checks.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
… observes a real write's mode Co-authored-by: Copilot App <[email protected]>
CI durations: main's file plus the train's parity-kit entries. Co-authored-by: Copilot App <[email protected]>
|
Merge-only update: main 9959a49 merged into the train (head 5767591). The train's src patch is unchanged across the merge: the md5 of the filtered +/- lines of |
There was a problem hiding this comment.
🟡 Changes recommended
A critical race can cause rollback to delete another writer’s files because the destination’s identity is captured after publication rather than from the staged directory before the atomic rename.
1 open issue
Review effort: Balanced
… before the rename The rename keeps the directory's identity, so taking it from the staged copy means a destination substituted between the rename and the record is never taken for this install's output; rollback leaves it in place and reports it. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
With APM_NO_CACHE=1, the temporary-cache path still creates and chmods a directory during read-only scopes, violating the no-write contract for decision-only runs.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
Rebased onto main after #4893 (squashed). LockFile.write records the document it dumped as the parse of the text it wrote, so later reads in the same command skip the YAML parse; top_level_scalar_values memoizes its pure scan. QL rebase conditions: - The seed goes through lockfile_container.parse_key(text), the machine loader's key, so a read uses exactly the parse a fresh read would. - One admission gate, yaml_io.machine_yaml_admits, is shared by load_machine_yaml_str and the seed: an over-budget text is never seeded and a read refuses it exactly like a fresh read (cell). - A dumped document loads back exactly equal, in key order, through the machine loader for adversarial scalars (cell). Refs #4939 apm-spec-waiver: in-process parse reuse of APM-written lockfile text; no spec surface changes Co-authored-by: Copilot App <[email protected]>


Description
Lane C install engine train: a bare
apm installorapm install --frozenon a locked project skips the install pipeline when the verified lockfile, caches and live policy prove the full run would produce the same state.apm_modulesmissing, e.g. CI or a fresh clone with a committed lock): copies package copies from the read-only git cache (verified and scanned in a private temp copy, then published insideapm_modulesby one rename each), writes deployed bytes from the deploy store (perf(cache): store every deployed file's bytes by lockfile hash (deploy store) #4846) bound to package-bound render records and re-hashed against the committed lockfile (each file appears whole by a link and never replaces one; paths only under the active targets' deploy roots), records receipts, then prints the full run's output..apm/, a found org policy issue, and any non-bare argv all run the full pipeline. The writes, receipts and rendered output share one journal: any failure restores the pre-run tree, drops the held output and runs the full pipeline once; a restore that cannot put every path back stops with exit 1 and names the paths, and never falls back.APM_INSTALL_FAST_PATH=decidedecides with every cache read-only.APM_INSTALL_FAST_PATH=0disables it;traceprints one decision line;decidestops after a decline (parity cells).Cars in this train: S0 no-op (L5), S1 deploy store sync with #4846 (F&C), package-bound records (F&C), APPLY engine + early CLI entry (IFP), fast_output renderer + update_notice import trim (L5), policy-chain memo (F&C).
Fresh installs (no lockfile) are NOT in this train: the resolution-memo design was blocked by W3b/QL (C1-C9) and reverted; it is tracked as research.
Issue and approved scope
Issue: Refs #4897 (locked apply), Refs #4770 (no-op fast path) and Refs #4854 (deploy store, S1).
Human scope-approval comment: #4897 (comment) (locked apply), #4770 (comment) (no-op) and #4854 (comment) (deploy store).
Does this PR complete the issue, or what remains? It delivers the #4770 no-op target by a different mechanism (stateless proof instead of replay) plus locked apply. Fresh-install speedups remain (S4'').
Type of change
Testing
Evidence:
-n 2.tests/unit/install/test_diff_apply.py(15, incl. a static no-delete guard),tests/unit/cache/test_deploy_store.py,tests/integration/test_deploy_store_lifecycle.py,tests/integration/test_policy_absent_memo.py: pass.CI perf bench at head a8e519d (code-identical to the final head) (CPU user+sys incl. children, paired new/base vs 8710b95, rtt 30 ms, 3 runners x 3 interleaved pairs; wall not used):
Spawns 29 -> 3 on frozen, 0 network requests, 0 errors in every cell.
Changelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regeneratedapm-spec-waiverin the merge commit).