Repository navigation
Description
Proposals are welcome before implementation. For substantive changes, wait
for a responsible human maintainer to approve the scope and identify a review
contact. An automated recommendation, label alone, or silence is not approval.
See Contributing.
Is your feature request related to a problem? Please describe.
A warm apm install (machine cache populated; fresh project or apm_modules deleted) still pays per dependency for materialization out of the persistent git cache (checkouts_v1/<shard>/<sha>/full): one git ls-tree -r HEAD subprocess (the tracked-symlink check, github_downloader.py WS3 hit path) and a per-file clonefile + copystat copy into apm_modules. On the tree-10 perf fixture (tests/fixtures/perf, offline mirror, 30 ms RTT) at main c969aba, warm spawns 12 git processes (2 version + 10 ls-tree); cProfile attributes 5.5% of warm wall to the copy and 4.2% to the ls-tree scans. The cache entry is also never re-verified against its content before it is copied: verify_checkout_sha checks HEAD only.
Describe the solution you'd like
Bounded scope:
- A seal per full checkout (
.git/apm-seal.json): SHA-256, size and exec bit of every file, every directory, and the tracked-symlink verdict for the whole tree. - Verify-before-reuse: every read re-hashes the entry against its seal. A mismatch, a malformed seal, or a seal naming a path outside the entry evicts the entry; nothing reaches
apm_modulesfrom it. - The tracked-symlink check runs once per entry; a passing verdict is recorded and later hits skip the
ls-tree. An unknown or failing verdict runs the existing strict check unchanged. - Materialization: copy-on-write clone by default where available (macOS dir-level
clonefile(2)through the existingutils/reflink.pybinding), copy elsewhere (FICLONE where supported). Hard links are opt-in only (APM_MATERIALIZE=link), protected by verify-before-reuse and documented. Cache file modes are untouched. - Read-only readers (
apm audit --cireplay) never write a seal or a lock. - Path security on every seal path and every materialized destination.
Done when:
- Red-first cells pass: editing a materialized file does not change the cache (clone, copy); an edited hard-linked entry is detected and never reused; a tampered entry is evicted before any byte is materialized; a seal path escaping the entry is rejected;
os.linkfailure falls back to copy (Windows/EXDEV); uninstall and prune never remove content another tree uses; an unknown or failing link verdict still raises the strict diagnostic; read-only readers write nothing. - GAINS evidence in the PR: ABAB at exact SHAs, warm and fresh, tree-10 and tree-50 at rtt 30, with CPU incl. children, wall, load, git subprocesses, copies/clones/links, % of the journey removed and the gap to 1 s.
Out of scope: reusing the seal hashes for the lockfile content_hash (follow-up), cold transport (#4776), subdirectory (virtual) package materialization, policy-discovery and credential traffic on warm installs.
Describe alternatives you've considered
- Hard links by default (pnpm/uv style): an in-place edit in
apm_modulesmutates the shared inode, and a read-only cache leaks mode 0444 into deployed files throughatomic_copy(metadata=True). Kept opt-in. - Trusting HEAD only: does not detect content edits.
Additional context
Implementation: #4779 (draft). Part of the PERF workstream toward 1 s warm installs on tree-10.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
danielmeppiel commentedon Nov 22, 2026
Decision: approve
Area: project
Scope: Performance and cache integrity. Each full checkout in the persistent git cache carries a seal (.git/apm-seal.json) with the SHA-256, size and exec bit of every file, every directory, and the tracked-symlink verdict for the tree. Every read re-hashes the entry against its seal before reuse; a mismatch, a malformed seal, or a seal naming a path outside the entry evicts the entry and nothing reaches apm_modules from it. A passing tracked-symlink verdict is recorded so later hits skip ls-tree; an unknown or failing verdict runs the existing strict check unchanged. Materialization uses copy-on-write clone where available (through src/apm_cli/utils/reflink.py) and copy elsewhere; hard links are opt-in only via APM_MATERIALIZE=link, documented in the environment-variable reference and protected by verify-before-reuse. Cache file modes are untouched, read-only readers (apm audit --ci replay) never write a seal or a lock, and path security applies to every seal path and every materialized destination.
Done when: Red-first cells pass: editing a materialized file does not change the cache (clone and copy); an edited hard-linked entry is detected and never reused; a tampered entry is evicted before any byte is materialized; a seal path escaping the entry is rejected; os.link failure falls back to copy (Windows, EXDEV); uninstall and prune never remove content another tree uses; an unknown or failing link verdict still raises the strict diagnostic; read-only readers write nothing; on Windows, when clone or hard link is unavailable, materialization falls back to copy, proven in the Windows lane; materialization never follows a symlink out of the cache entry or the deploy root, with path_security validation on every materialized path, proven red-first. The PR carries ABAB GAINS evidence at exact SHAs, warm and fresh, tree-10 and tree-50 at 30 ms RTT. QL's security lane reviews at head as part of H8, CI is green, and a CHANGELOG line is added.
Out of scope: Reusing seal hashes for the lockfile content_hash; cold transport (#4776); subdirectory (virtual) package materialization; hard links by default; policy-discovery and credential traffic on warm installs.
Review contact: Daniel Meppiel (@danielmeppiel)
perf(cache): own tree_store, refuse cache symlinks and escaping desti…
danielmeppiel commentedon Nov 23, 2026
Measured below the performance bar. Cached-checkout verification continues in #4891.