You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(install): write and verify git-path checkouts from the pack in process - #5366
On the git CLI path (GHE and every other non-github.com host; github.com installs already fetch in process, #5353), a cold install of a whole-repo dependency now writes the pinned worktree from the bare clone's pack in process, and verifies checkouts by reading objects from the pack, instead of spawning git checkout, git ls-tree and git cat-file --batch per package. Every byte is still hashed to its git object id, and any shape outside the plain case is left to git unchanged.
Two levers, one PR:
2a, pack-served verify (cache/checkout_verify.py, cache/pack_objects.py). verify_checkout reads commit, tree and blob objects from the repository's v2 pack indexes. The pack is a byte source, never a trust root: every object is re-hashed against the id asked for, exactly as the cat-file --batch reader does. If the pack cannot serve any object, the whole package is verified again through git cat-file --batch (all or nothing). The pack reader refuses, so git answers, on:
a .git file, grafts, nested alternates, http-alternates;
promisor packs or a promisor config, replace refs (dir or packed);
a multi-pack index, SHA-256, 64-bit offsets, an out-of-pack REF_DELTA, a delta chain deeper than 50;
any zlib, size-cap or parse error.
C, pack checkout (git_cache._create_checkout, pack_objects.materialize_tree). After clone --local --shared --no-checkout (kept, so .git is real), the pinned tree is written in process from the pack, followed by a v2 index with real lstat data and a detached HEAD at the pin. Only full checkouts are covered, never sparse or promisor ones. It engages only through perf(install): in-process pinned fetch engages on Windows #5351's inert-attributes gate (W4); a commit .gitattributes, a symlink (120000) or a gitlink (160000) is refused. The exec bit comes only from 100755. Files are written with O_EXCL|O_NOFOLLOW under a fresh 0700 staging root. On any refusal or failed write, only .git is left and today's git checkout runs.
APM_NO_INPROCESS_CHECKOUT / APM_NO_INPROCESS_VERIFY are kill switches on a default-on feature. Like APM_NO_INPROCESS_FETCH, they turn it off only for 1, true, yes or on.
Equivalence (why a shortcut is the same answer)
Verify (2a). Each object the pack returns is hashed with git_object_id and compared with the requested id before use. A pack that names the wrong bytes therefore fails exactly as a corrupt cat-file answer would; the cell swaps two index offsets and only the re-hash catches it. A miss is never treated as a verdict: it sends the whole package back to git.
Checkout (C). The tree walk re-hashes every object. The writer uses the same _safe_name and caps as the in-process fetch (perf(install): in-process pinned fetch #5330), and the index, HEAD and worktree are what git checkout produces. Every git reader of a landed checkout gives the same answer:
ls-files -s, status --porcelain, rev-parse HEAD, a detached HEAD, and diff, checked by the parity cell;
checkout_verify, checked by the 2a differential;
verify_checkout_sha (HEAD equals the pin);
the git_sparse link plan, which reads the detached HEAD tree;
ls-files --deleted, which only runs for promisor checkouts and so never meets C.
The remaining git -C readers in git_env act on downloader temp clones only (checked with grep).
Every git reader gives the same answer as on git checkout.
A planted link, a commit .gitattributes, a replace ref, a flipped pack byte, a swapped parent, or a parent swapped for a symlink each refuse and leave only .git.
tests/integration/test_pack_checkout_world.py:
A tree-10 install with the git path forced gives an identical lockfile, deployed bytes and receipts with the pack checkout and with APM_NO_INPROCESS_CHECKOUT=1; engaged 10/10.
A warm reinstall re-verifies through git readers.
Validation evidence:
Local runs through host_guard (before the host BURST stop): pytest tests/integration/test_pack_verify_cells.py -n 0 -> 12 passed. The negative controls were each run and each failed its cell. The C cells passed 44/45 together with test_inprocess_fetch; the replace-ref cell failed in its own setup under safe.bareRepository=explicit, which is fixed in 175e7b5. The local rerun was stopped by the host BURST, so CI on this PR is the evidence.
ruff check/format (ruff 0.15.12), the complexity ratchet, the architecture linter, the assertion-quality ratchet and the taxonomy gate: clean.
Performance at the head against merge-base 0a2460a (paired CPU including children, tree-50, 6 pairs; JH's non-github host harness):
GHE / git-path installs: Windows cold t50 0.845 anon (30.5 -> 25.7 s) and 0.848 auth (29.1 -> 24.6 s). Spawns 369 -> 171 and 365 -> 167; requests identical, 0 errors [45491748318].
One fragment per section, changelog.d/<pr>.<section>.md, holding
one line: user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes only under upgrade notes; no Highlights; no
new lines under ## [Unreleased]. See changelog.d/README.md and .github/instructions/changelog.instructions.md.
…ck in process, all-or-nothing per package) + lever C (pinned worktree from the bare's pack after clone --no-checkout; one-shot verify via the B1 manifest)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…es read like APM_NO_INPROCESS_FETCH
The pack-served verify gives git's verdict on clean, tampered, planted,
deleted and exec-bit shapes with no cat-file spawn; a loose object or a
replace ref sends the whole package to git; every flipped pack byte gives
git's verdict or a refusal; an index that names the wrong bytes is refused
only by the re-hash (negative control). APM_NO_INPROCESS_VERIFY/CHECKOUT
turn the feature off only for 1, true, yes or on. pack_objects.py joins the
checkout-commit-verification owner. Refs #4939
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…cell names its bare by --git-dir
safe.bareRepository=explicit refuses bare discovery, so the cell failed in its
own setup on such hosts before reaching product code.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical gaps in checkout-attribute checks, blob memory limits, index writes, and pack-header validation can produce incorrect or unusable checkouts or exhaust the install process.
This PR advances #4939’s install-performance work by reading Git pack objects in process, reducing subprocess overhead for checkout verification and full-repository checkouts on the Git CLI path.
Changes:
Adds pack-backed object reads and worktree materialization with object-ID verification, Git fallback, and opt-out switches.
Integrates the fast paths into checkout creation and verification.
Adds parity, corruption, fallback, and cold/warm install coverage.
File
Description
tests/integration/test_pack_verify_cells.py
Compares pack-backed verification with Git across clean and altered checkouts.
tests/integration/test_pack_checkout_world.py
Checks install parity and warm reuse in an offline environment.
tests/integration/test_pack_checkout_cells.py
Tests Git-reader parity and checkout refusal cases.
src/apm_cli/cache/pack_objects.py
Implements pack reading, worktree writing, and index creation.
src/apm_cli/cache/git_cache.py
Attempts in-process materialization before Git checkout.
src/apm_cli/cache/checkout_verify.py
Adds pack-backed verification with whole-package Git fallback.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical issues remain: blob materialization lacks an aggregate memory limit, attributes checks use the wrong environment, and short index writes can leave corrupt checkouts registered as verified.
…the tree; switches honor the command env
The attributes/config gate (a git config spawn) now runs after the in-process
tree walk and still before the first write, so a pack-shape refusal costs no
spawn. APM_NO_INPROCESS_CHECKOUT/VERIFY are read from the command's git env as
well as the process env, like APM_NO_INPROCESS_FETCH. The Windows-world
reference arm turns off both in-process paths so it stays pure git.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The fast path checks the wrong checkout environment and lacks an aggregate inflation budget, risking incorrect file contents and installer memory exhaustion; unchecked short writes can also leave a truncated index registered as verified.
The comprehension calls read once per file before deduplicating by object ID. Repeated files therefore cause the same blob to be inflated and re-hashed repeatedly; top-level reads are not cached by PackObjects. For example, 10,000 paths sharing a 1 MiB blob process roughly 10 GiB just to populate a dictionary holding 1 MiB. Deduplicate the IDs before reading them.
Please mark this parity cell windows_compat. The PR-time Windows gate selects integration tests exclusively with that marker (.github/workflows/ci.yml:151-167), so it currently omits the assertions that Git accepts the hand-written index and reports a clean status. The marked install-world tests compare deployed bytes but do not check index/status parity. This specific cell needs to run on Windows as well as Linux.
R1: one inflate budget covers the whole materialize_tree call (every blob is
held until written), not a fresh cap per read.
R2: the gate checks the attributes git's own checkout would read, through
_require_inert_checkout_attributes(env) (the checkout env, the #5351 fold-2
class).
R3: a C8 seal before the index: the staged tree must hold exactly the made
directories (same dev and inode) and written files, with no link; otherwise
it is discarded and git checks out.
N1: grafts are refused at $GIT_DIR/info/grafts as well.
Cells: a half-tree budget refuses, the isolated-config XDG eol=crlf refuses,
and a parent swapped mid-write leaves only .git. Refs #4939
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unchecked partial index writes and insufficient pack-header validation can allow checkouts to be reported as successful even though Git cannot read them.
The pack reader opens only what git opens (at least 32 bytes, PACK, version 2
or 3), and the byte-flip cell now covers the version bytes. The index write
loops until every byte is written and fails on no progress, so a short write
discards and falls back to git. Shared blobs are read once, so the whole-tree
inflate budget counts what is held. The changelog line names only the spawns
avoided.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human security assessment is needed because filesystem races and unsafe symlink or hardlink handling can cause checkout writes to create or overwrite files outside staging.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved critical issues allow writes outside staging through swapped parent-directory symlinks and accept packs with count or hash mismatches that Git rejects.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Unresolved defects allow symlink races to write outside staging, accept pack/index count mismatches rejected by Git, and miss conditional attributes that alter checkout bytes.
…hored writes, includeIf, atomic HEAD
- A pack is served only when its object count and trailing checksum match
its index, as git requires; the byte-flip cell covers bytes 4-11 and the
trailer.
- On POSIX every directory and file is created through a directory fd this
call opened no-follow, so a parent swapped for a link is never followed out
of the stage (Windows keeps path writes plus the C8 seal); the swap cell
asserts the link's outside target stays empty.
- When the effective config holds a conditional include, the attributes git's
checkout reads are re-read from the stage itself; free otherwise.
- HEAD is replaced atomically, so a failed write leaves the clone's HEAD valid.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because a parent-directory swap can redirect Windows writes outside staging, causing changes that subsequent checkout rejection and cleanup cannot undo.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The pack reader can accept malformed indexes and normalize alternate paths in ways that leave checkouts unreadable by Git, while unbounded index reads can exhaust the main process’s memory.
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
full-integrationRun the full integration suite (ci-integration.yml) on this PR before merge
2 participants
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.
Description
On the git CLI path (GHE and every other non-github.com host; github.com installs already fetch in process, #5353), a cold install of a whole-repo dependency now writes the pinned worktree from the bare clone's pack in process, and verifies checkouts by reading objects from the pack, instead of spawning
git checkout,git ls-treeandgit cat-file --batchper package. Every byte is still hashed to its git object id, and any shape outside the plain case is left to git unchanged.Two levers, one PR:
cache/checkout_verify.py,cache/pack_objects.py).verify_checkoutreads commit, tree and blob objects from the repository's v2 pack indexes. The pack is a byte source, never a trust root: every object is re-hashed against the id asked for, exactly as thecat-file --batchreader does. If the pack cannot serve any object, the whole package is verified again throughgit cat-file --batch(all or nothing). The pack reader refuses, so git answers, on:.gitfile, grafts, nested alternates, http-alternates;git_cache._create_checkout,pack_objects.materialize_tree). Afterclone --local --shared --no-checkout(kept, so.gitis real), the pinned tree is written in process from the pack, followed by a v2 index with real lstat data and a detached HEAD at the pin. Only full checkouts are covered, never sparse or promisor ones. It engages only through perf(install): in-process pinned fetch engages on Windows #5351's inert-attributes gate (W4); a commit.gitattributes, a symlink (120000) or a gitlink (160000) is refused. The exec bit comes only from 100755. Files are written with O_EXCL|O_NOFOLLOW under a fresh 0700 staging root. On any refusal or failed write, only.gitis left and today'sgit checkoutruns.APM_NO_INPROCESS_CHECKOUT/APM_NO_INPROCESS_VERIFYare kill switches on a default-on feature. LikeAPM_NO_INPROCESS_FETCH, they turn it off only for1,true,yesoron.Equivalence (why a shortcut is the same answer)
Verify (2a). Each object the pack returns is hashed with
git_object_idand compared with the requested id before use. A pack that names the wrong bytes therefore fails exactly as a corruptcat-fileanswer would; the cell swaps two index offsets and only the re-hash catches it. A miss is never treated as a verdict: it sends the whole package back to git.Checkout (C). The tree walk re-hashes every object. The writer uses the same
_safe_nameand caps as the in-process fetch (perf(install): in-process pinned fetch #5330), and the index, HEAD and worktree are whatgit checkoutproduces. Every git reader of a landed checkout gives the same answer:ls-files -s,status --porcelain,rev-parse HEAD, a detached HEAD, anddiff, checked by the parity cell;checkout_verify, checked by the 2a differential;verify_checkout_sha(HEAD equals the pin);git_sparselink plan, which reads the detached HEAD tree;ls-files --deleted, which only runs for promisor checkouts and so never meets C.The remaining
git -Creaders ingit_envact on downloader temp clones only (checked with grep).Issue and approved scope
Issue: Refs #4939
Human scope-approval comment: the #4939 install-performance scope (2x install), lever 2a+C accepted by the PERF VP for v0.39.0.
Does this PR complete the issue, or what remains? No. This is one slice of #4939; other levers remain.
Type of change
Testing
Cells:
tests/integration/test_pack_verify_cells.py(2a):cat-filespawns.tests/integration/test_pack_checkout_cells.py(C):git checkout..gitattributes, a replace ref, a flipped pack byte, a swapped parent, or a parent swapped for a symlink each refuse and leave only.git.tests/integration/test_pack_checkout_world.py:APM_NO_INPROCESS_CHECKOUT=1; engaged 10/10.Validation evidence:
pytest tests/integration/test_pack_verify_cells.py -n 0-> 12 passed. The negative controls were each run and each failed its cell. The C cells passed 44/45 together with test_inprocess_fetch; the replace-ref cell failed in its own setup undersafe.bareRepository=explicit, which is fixed in 175e7b5. The local rerun was stopped by the host BURST, so CI on this PR is the evidence.Performance at the head against merge-base 0a2460a (paired CPU including children, tree-50, 6 pairs; JH's non-github host harness):
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)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.