Skip to content

fix(cache): retry incomplete promisor checkouts with credentials (#3071) - #3602

Merged
Daniel Meppiel (danielmeppiel) merged 9 commits into
mainfrom
danielmeppiel-fix-3071-transitive-git-path-monorepo-de
Nov 12, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 9 commits into
mainfrom
danielmeppiel-fix-3071-transitive-git-path-monorepo-de

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

TL;DR

Since 0.29.1, apm install of a transitive git: + path: dependency from a private GitHub monorepo can cache an empty sparse checkout, which then fails Not a valid APM package. On Git older than 2.36, git checkout exits 0 even when the anonymous blob fetch is rejected. GitCache now detects tracked files missing after a promisor checkout and raises an auth-classifiable error, so the existing anonymous-first fallback retries with credentials. It also rebuilds incomplete shards left in the cache by earlier versions.

Note

Root-cause analysis and the git ls-files --deleted idea come from jiteshjadav-rogers's investigation on the issue. This PR reproduces that analysis with a real Git 2.33 binary, bisects it to #2722, and adds regression tests plus a self-healing cache-hit path. Thanks also to danielle060821 for the earlier reproduction attempts that narrowed the shape.

Problem (WHY)

  • Version regression (bisected). fix: authenticate private subdirectory cache (closes #2714) #2722 (first released in v0.29.1) routed subdirectory cache checkouts through AuthResolver.try_with_fallback(unauth_first=True) for github.com-class hosts. It only retries with a token when the anonymous attempt raises (core/auth.py unauth-first branch).
  • Silent success on old Git. Once the parent install has cached the <shard>__p partial bare, a transitive sparse checkout needs no network until git checkout lazily fetches blobs. On Git < 2.36, a rejected promisor fetch during a non-forced checkout still exits 0. The result is that HEAD and the index move but the worktree stays empty.
  • Poisoned cache. _create_checkout only checked the exit code and HEAD, so the empty shard was landed as valid. Every later run, including the credentialed retry, then got a cache hit on it. Validation reported the bare repo_url, which hid the real cause.
  • [!] Git ≥ 2.36 dies on the failed prefetch (exit 128), so the fallback already works there. That is why public and modern-Git reproductions passed.

Approach (WHAT)

# Fix
1 After a promisor (sparse) checkout, run git ls-files --deleted -z. Any missing tracked file raises IncompleteCheckoutError, the staged directory is removed, and nothing lands.
2 The error carries Git's checkout stderr, so AuthResolver.is_public_github_auth_failure sees the anonymous rejection and retries with the resolved token.
3 Sparse cache hits and write-dedup hits with missing tracked files are rebuilt under the shard lock, the same way unpinned shards already heal. Users do not need apm cache clean.
4 Full checkouts are not probed: their non-partial bare already holds every blob.

Implementation (HOW)

  • src/apm_cli/cache/git_cache.py: adds IncompleteCheckoutError(RuntimeError) with a stderr attribute and the _unmaterialized_paths / _sparse_checkout_is_complete helpers (L167-L203). get_checkout runs the probe before trusting a sparse hit (L330). _create_checkout runs it in write-dedup and after a fresh promisor checkout (L931). The resolver, AuthResolver, the auth classifier, and containment checks are untouched.
  • tests/unit/cache/test_git_cache_materialization.py (new): a diamond monorepo fixture (pkg-a -> pkg-b -> pkg-shared, plus pkg-a -> pkg-shared) declared through real git: + path: manifests. Old-Git behavior is emulated by turning the SHA checkout into read-tree + update-ref with exit 0 and the anonymous-fetch stderr.
  • tests/unit/cache/test_git_cache_recency.py: no longer changed. fix(git): materialize package links from Git objects on every host #3603 removed _finalize_sparse_checkout and the recency test that targeted it, so the merge with main drops the stub.
  • Panel folds (merge-worker): probe-verified sparse shards now carry a local apm.sparseMaterialization=complete pin, so warm cache hits skip the ls-files spawn. Shards from 0.29.1+ lack the pin, so they are probed once and then healed or pinned. The probe under the shard lock uses a 10s timeout. A failed pin write is logged and ignored. On a fresh checkout, the probe runs before fix(git): materialize package links from Git objects on every host #3603's materialize_tracked_symlinks.
  • docs/src/content/docs/reference/cli/cache.md: one paragraph on how sparse variants fetch on demand and are discarded or rebuilt when incomplete.

Diagrams

Legend: a transitive sparse checkout before and after this PR. The boxed steps are new. Read the alt branch first.

sequenceDiagram
    participant DL as GitHubPackageDownloader
    participant AR as AuthResolver
    participant GC as GitCache
    participant G as git (< 2.36)
    DL->>AR: try_with_fallback(unauth_first)
    AR->>GC: get_checkout(env without token)
    GC->>G: clone --local from cached __p bare
    GC->>G: checkout SHA (lazy blob fetch rejected)
    G-->>GC: exit 0, worktree empty
    rect rgb(230, 245, 255)
    GC->>G: ls-files --deleted -z
    G-->>GC: packages/pkg-shared/apm.yml ...
    GC-->>AR: raise IncompleteCheckoutError (stderr kept)
    end
    alt before this PR
        GC-->>DL: empty shard landed and cached
        Note over DL: validate fails - Not a valid APM package
    else after this PR
        AR->>AR: is_public_github_auth_failure -> true
        AR->>GC: get_checkout(env with token)
        GC-->>DL: complete shard, package validates
    end
Loading

Trade-offs

  • Probe only promisor checkouts. I chose to probe only promisor checkouts and rejected probing every checkout. Full checkouts cannot lose blobs, and probing them would add a spawn to every cold full install.
  • One git ls-files spawn per unverified sparse shard. Shards are probed once and then pinned, so caches poisoned by 0.29.1-0.35.x heal without apm cache clean, and warm hits on verified shards spawn nothing. This follows the existing pin-rematerialization precedent.
  • Raise and let AuthResolver decide; no checkout-time credential logic. The retry policy stays in its single owner (try_with_fallback). The cache only reports the incomplete state with Git's own diagnostics. A non-auth failure surfaces as an error instead of a silently empty package.
  • Test emulates old Git rather than requiring Git 2.33 in CI. CI runners ship modern Git, where the failure is loud. A real Git 2.33 run was done locally (see Validation) to confirm the emulation matches.
  • git: parent sentinel behavior is out of scope per the approved record. It shares this cache path, so it should benefit, but no sentinel code was changed.

Benefits

  1. Transitive git: + path: dependencies from private monorepos install on Git < 2.36 without the APM_NO_CACHE=1 workaround.
  2. An incomplete sparse checkout never lands in checkouts_v1/, which removes a persistent cache-poisoning vector.
  3. Existing poisoned shards heal on the next install (no apm cache clean).
  4. A genuine non-auth fetch failure fails loudly with the shard named, instead of failing later with a misleading Not a valid APM package against the bare repo URL.

Issue and approved scope

Issue: Fixes #3071

Human scope-approval comment: #3071 (comment). This is the canonical apm-scope:v1 record; trusted-copy eligibility.cjs reports record-present. The approval was reconfirmed for this delivery by Daniel Meppiel (@danielmeppiel), the review contact, on 2026-11-12.

Does this PR complete the issue, or what remains? It completes the approved scope: it restores declared-subdirectory resolution and validation for nested and transitive Git+path monorepo dependencies. The regression was reproduced before coding (Git 2.33, see Validation), and a consumer/parent/child (diamond) fixture proves the declared subdirectory resolves and validates. Unrelated resolution and containment behavior are unchanged. Separate git: parent sentinel defects, if any remain, are out of scope per the record.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Reproduction before coding (real Git 2.33.0 built from source, HEAD without the fix)

Fixture: the parent sparse install seeds the __p partial bare, then the remote rejects blob fetches.

== HEAD (no fix), git 2.33
git: git version 2.33.0
child landed; valid: False errors: ['Not a valid APM package: no apm.yml, SKILL.md, hooks, or plugin structure found in pkg-shared. ...']
ls-files --deleted: ['packages/pkg-shared/.apm/instructions/s.instructions.md', 'packages/pkg-shared/apm.yml']
== HEAD (no fix), git 2.56
child raised: RuntimeError Failed to create checkout for file:///.../remote.git @ e1fcfb5139fc: Command '[... checkout ...]' returned non-zero exit status 128
== FIX, git 2.33
child raised: IncompleteCheckoutError Incomplete checkout for file:///.../remote.git @ 74818dadd763: 2 tracked file(s) not materialized (first: packages/pkg-shared/.apm/instructions/...

Bisect: git log v0.29.0..v0.29.1 -- src/apm_cli/deps/github_downloader.py → 74f05e4c0 fix: authenticate private subdirectory cache (closes #2714) (#2722) introduced _persistent_cache_checkout with unauth_first=True.

Validation

Note

Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate.

Tests, mutation break, and CI-mirror lint (rebased onto origin/main 1009d4b)
$ pytest tests/unit/cache/test_git_cache_materialization.py tests/unit/cache/test_git_cache.py \
    tests/unit/cache/test_git_cache_sparse.py tests/integration/test_git_cache_hermetic.py -n 4
109 passed in 144.47s

$ pytest tests/unit/cache tests/unit/test_git_cache_phase3w4.py tests/unit/test_git_cache_branch_coverage.py \
    tests/unit/deps/test_github_downloader_phase3.py tests/unit/deps/test_bare_cache_sparse.py \
    tests/integration/test_git_cache_hermetic.py tests/integration/test_cache_coverage.py -n 4
4 failed, 618 passed   # the 4 = test_git_cache_recency fake-shard cases, fixed in this PR:
$ pytest tests/unit/cache/test_git_cache_recency.py
21 passed

# After rebase onto 1009d4bf67:
$ pytest tests/unit/cache/test_git_cache_materialization.py tests/unit/cache/test_git_cache_recency.py \
    tests/unit/cache/test_git_cache_sparse.py
47 passed

# Mutation break: _unmaterialized_paths() forced to return []
$ pytest tests/unit/cache/test_git_cache_materialization.py
FAILED ...::test_silent_promisor_checkout_raises_auth_signal_and_lands_nothing
FAILED ...::test_cached_incomplete_sparse_shard_is_rematerialized
FAILED ...::test_transitive_monorepo_subdirectory_retries_with_credentials
3 failed   # fix restored -> 3 passed

$ ruff check src/ tests/ scripts/...            -> All checks passed!
$ ruff format --check src/ tests/ scripts/...   -> 2138 files already formatted
$ pylint --enable=R0801 --min-similarity-lines=10 src/apm_cli/ scripts/...  -> rated 10.00/10
$ bash scripts/lint-auth-signals.sh             -> [+] auth-signal lint clean
$ python scripts/lint_architecture_boundaries.py --root .  -> exit 0

Scenario Evidence

# Scenario (user promise) Principle(s) Test(s) proving it Type
1 Installing pkg-a from a private monorepo resolves its transitive git: + path: deps (pkg-b, then pkg-shared, plus the diamond edge) from the declared subdirectory, retrying with my token when anonymous blob fetches are rejected Vendor-neutral, DevX tests/unit/cache/test_git_cache_materialization.py::test_transitive_monorepo_subdirectory_retries_with_credentials (regression-trap for #3071) integration
2 A checkout that Git reports as successful but left files missing is never cached, and the failure is classified as an auth signal Governed by policy, Secure by default tests/unit/cache/test_git_cache_materialization.py::test_silent_promisor_checkout_raises_auth_signal_and_lands_nothing (regression-trap for #3071) integration
3 After upgrading, a cache poisoned by 0.29.1+ heals on the next install without apm cache clean DevX tests/unit/cache/test_git_cache_materialization.py::test_cached_incomplete_sparse_shard_is_rematerialized integration
4 A healed sparse shard is not re-probed on every warm install DevX tests/unit/cache/test_git_cache_materialization.py::test_verified_sparse_shard_skips_probe_on_hit integration
5 A crashing completeness probe rebuilds the shard instead of trusting it or failing the install Secure by default tests/unit/cache/test_git_cache_materialization.py::test_probe_failure_treats_shard_as_incomplete unit
6 A failed write of the completeness pin never discards a verified checkout DevX tests/unit/cache/test_git_cache_materialization.py::test_pin_write_failure_keeps_verified_checkout integration

How to test

  • uv run --extra dev pytest tests/unit/cache/test_git_cache_materialization.py -q → 3 passed.
  • Mutation: make _unmaterialized_paths return [] → all 3 fail; revert.
  • Optional, with Git < 2.36 on PATH: run a private-monorepo diamond install (from the issue) after apm cache clean → installs without APM_NO_CACHE=1.

Spec conformance (OpenAPM v0.1)

If this PR changes behaviour that an OpenAPM v0.1 req-XXX covers,
confirm the three-step ritual in the
development guide:

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Co-authored-by: Copilot [email protected]

Git before 2.36 ignores a failed promisor blob fetch during a non-forced
checkout and exits 0 with an empty worktree. Since #2722 (0.29.1), sparse
subdirectory installs from public-GitHub hosts try anonymous access first;
for a private monorepo the cached partial bare let the anonymous attempt
pass the network step, so transitive git+path dependencies landed as
empty shards and failed "Not a valid APM package" with no credentialed
retry.

GitCache now probes promisor checkouts with `git ls-files --deleted`
after checkout and raises IncompleteCheckoutError (carrying Git stderr so
AuthResolver classifies the anonymous rejection and retries with a
token). Sparse cache hits and write-dedup hits with missing tracked
files are rebuilt, healing shards poisoned by earlier versions.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 12, 2026 12:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the sparse-checkout recovery and credential-fallback changes.

No open issues 🎉

What changed in this PR

Fixes the private-monorepo regression from #3071 by detecting incomplete sparse Git checkouts and allowing the existing credential fallback to retry, including on Git older than 2.36.

Changes:

  • Detects missing tracked files before caching a sparse checkout, preserving Git diagnostics for authentication failure classification.
  • Rebuilds incomplete cached sparse checkouts automatically.
  • Adds regression coverage for credential retries, transitive monorepo dependencies, and cache repair, with supporting documentation.
File Description
tests/​unit/​cache/​test_git_cache_recency.py Adjusts the fake shard fixture to preserve recency-validation coverage.
tests/​unit/​cache/​test_git_cache_materialization.py Adds regression tests for incomplete checkouts, cache repair, and transitive credential retries.
src/​apm_cli/​cache/​git_cache.py Detects incomplete sparse checkouts and rebuilds affected cached shards.
docs/​src/​content/​docs/​reference/​cli/​cache.md Documents sparse checkout recovery behavior.
CHANGELOG.md Records the private-monorepo installation fix and automatic cache repair.

Review effort: Balanced

…orepo-de

Resolve git_cache.py against #3603: main replaced the sparse-widen
finalizer with materialize_tracked_symlinks. Keep the #3071 completeness
probe on cache hits and write-dedup, and run the post-checkout
unmaterialized-path probe before link materialization so an empty
promisor tree still raises the auth-classifiable IncompleteCheckoutError.
Drop the recency test for the removed finalizer, as main did.

Co-authored-by: Copilot App <[email protected]>
CI shard 1 (Linux) failed because filelock leaves sibling .lock files
next to variant directories; the assertion now counts only variant
directories, matching how git_cache prune skips .lock entries.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Fixes silent cache poisoning on old Git by probing promisor checkouts for missing blobs and retrying with credentials; panel converged, three in-scope folds queued.

panel-mode=lean; personas=auth-expert,test-coverage-expert,performance-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

All three panelists converged without conflict. The auth-expert confirms the new IncompleteCheckoutError.stderr attribute carries genuine Git auth diagnostics into is_public_github_auth_failure without leaking tokens or false-positiving on connectivity noise -- the integration is clean and the single-owner retry policy in AuthResolver is preserved. The performance-expert accepts the one-extra-git ls-files spawn per warm sparse cache hit as a sound ship trade-off for self-healing caches poisoned across 0.29.1-0.35.x, while correctly flagging that the cost becomes pure overhead once all shards are healed. The test-coverage-expert validates the three new fixture tests as a strong mutation-killed regression trap for #3071 but surfaces one defense-in-depth gap: the except (CalledProcessError, TimeoutExpired, OSError) branch in _sparse_checkout_is_complete has no automated guardrail -- if a refactor narrows that clause, a probe crash propagates from the cache-hit path instead of triggering a graceful rebuild.

Strategically this is a high-signal reliability fix: it closes a cache-poisoning window that affected every user on Git < 2.36 since v0.29.1, and it self-heals already-poisoned caches without requiring apm cache clean. That is the kind of silent-correctness story that builds trust with enterprise adopters who cannot control their Git version fleet. The merge-worker reports all three panel findings are in-scope and queued for fold into this PR, which is the right call -- they all touch code this PR introduces.

Aligned with: secure by default: Incomplete promisor checkouts are now detected and never landed in the cache; the retry path preserves the anonymous-first policy while ensuring credentialed fallback fires on silent auth rejections. pragmatic as npm: Self-healing existing poisoned shards on cache hit means users on affected versions recover without manual intervention or knowing the root cause. multi harness multi host: Fix targets the Git < 2.36 behavioral divergence specifically; modern Git users pay only the ls-files probe cost on sparse deps, which the config-pin follow-up will amortize.

Panel summary

Persona B R N Takeaway
Auth Expert 0 0 0 Auth integration is sound: IncompleteCheckoutError.stderr carries genuine Git auth diagnostics for the classifier; the human-readable phrase does not false-positive; probe env is local-only; no token leakage.
Test Coverage Expert 0 1 0 Three integration-with-fixtures tests form a strong regression trap for #3071 (mutation-killed); probe-failure defense-in-depth branch in _sparse_checkout_is_complete lacks a test.
Performance Expert 0 2 0 Probe is O(total_index_entries) per sparse cache hit on the warm-install hot path; trade-off is sound for shipping; amortize via config pin as follow-up.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 3 follow-ups

  1. [Test Coverage Expert] Add parametrized unit test for _sparse_checkout_is_complete probe-failure branch (CalledProcessError / TimeoutExpired / OSError -> returns False) -- Missing regression trap on a secure-by-default surface: if the except clause narrows, a subprocess crash propagates from the cache-hit hot path instead of triggering a graceful rebuild. Evidence outcome: missing; the assertion is straightforward and the merge-worker has queued the fold.
  2. [Performance Expert] Amortize the sparse-shard completeness probe via a local config pin so healed shards skip subsequent ls-files spawns -- Per-hit O(index) probe is correct for shipping but becomes pure overhead once a shard is healed; config pin eliminates the fork+exec on every warm install for large monorepos (10-30ms at 100K files). Merge-worker has queued the fold.
  3. [Performance Expert] Tighten the ls-files probe timeout from 60s to ~10s on the cache-hit and write-dedup paths (inside shard_lock) -- A healthy ls-files completes far under 1s; 60s under shard_lock serializes every concurrent consumer of that shard on a pathological hang. TimeoutExpired is already caught as incomplete, so the shorter bound is safe. Merge-worker has queued the fold.

Recommendation

Ship once the three queued folds land (probe-failure unit test, config-pin amortization, tighter probe timeout under shard_lock) and CI greens on the new head. All findings touch code this PR introduces and are confirmed in-scope by the merge-worker. Highest-signal item is the probe-failure regression trap -- it guards a secure-by-default surface with a one-test fix.


Full per-persona findings

Auth Expert

No findings.

Test Coverage Expert

  • [recommended] _sparse_checkout_is_complete probe-failure branch (CalledProcessError/TimeoutExpired/OSError -> False) has no regression trap at tests/unit/cache/test_git_cache_materialization.py
    No test exercises the except branch; grep of tests/ found no references to _sparse_checkout_is_complete or _unmaterialized_paths. If a refactor narrowed the except clause, a probe crash would propagate from the cache-hit/write-dedup path instead of rebuilding.
    Suggested: Add a parametrized unit test monkeypatching _unmaterialized_paths to raise CalledProcessError/TimeoutExpired/OSError and asserting _sparse_checkout_is_complete returns False.
    Proof (missing at): tests/unit/cache/test_git_cache_materialization.py::test_probe_failure_treats_shard_as_incomplete -- proves: A git ls-files --deleted crash on a cached sparse shard triggers a graceful rebuild instead of propagating the subprocess error

Performance Expert

  • [recommended] Per-dependency git ls-files spawn on every warm sparse cache hit is permanent overhead for a transient problem; amortize via config pin. at src/apm_cli/cache/git_cache.py:338
    _sparse_checkout_is_complete spawns 'git ls-files --deleted -z' on every warm cache hit for sparse deps (get_checkout, inside shard_lock). Git parses the full index (O(total tracked files), not O(cone)); ~2-5ms for 10K files, ~10-30ms for 100K-file monorepos, plus fork/exec. Once healed, every subsequent warm hit pays the same cost for no benefit. Write-dedup and fresh-checkout probes are cold paths and negligible.
    Suggested: After the probe passes, persist a local config pin in the shard's .git/config and skip the probe on later hits; unpinned (legacy, possibly poisoned) shards still get probed.
  • [recommended] 60s timeout on the ls-files probe inside shard_lock is disproportionate; tighten to ~10s to bound lock hold on failure. at src/apm_cli/cache/git_cache.py:181
    A healthy ls-files completes far under 1s even on huge monorepos. On the cache-hit and write-dedup paths the probe runs inside shard_lock, so a pathological 60s hang serializes every concurrent consumer of that shard. TimeoutExpired is already caught and treated as incomplete, so a shorter bound is safe.
    Suggested: Add a timeout parameter; pass ~10s from cache-hit/write-dedup; keep 60s for the fresh-checkout probe.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

Addresses the PR #3602 panel follow-ups (performance-expert x2,
test-coverage-expert). The #3071 ls-files completeness probe ran on every
warm sparse cache hit; verified shards now carry a local
apm.sparseMaterialization=complete pin and skip the spawn. Shards from
0.29.1+ lack the pin, so they are still probed once and healed or pinned.
The cache-hit and write-dedup probe runs inside the shard lock, so it now
uses a 10s timeout instead of 60s. New tests trap the pin skip and the
probe-failure branch (CalledProcessError, TimeoutExpired, OSError ->
rebuild); each was mutation-checked.

Co-authored-by: Copilot App <[email protected]>
Addresses the PR #3602 delta-panel follow-ups (performance-expert,
test-coverage-expert). The fresh-checkout pin write ran inside the
create try block, so a git config failure removed a checkout already
verified complete. The pin only lets later hits skip the probe, so the
helper now logs and ignores write failures on both call sites. A new
test fails pin writes and asserts the checkout lands, stays valid, and
is probed again on the next hit; it was mutation-checked.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_now

Self-heals cache poisoning from incomplete promisor checkouts on Git < 2.36; panel converged to zero findings across three iterations -- all folds mutation-checked.

panel-mode=delta; personas=auth-expert,test-coverage-expert,performance-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

Three-iteration convergence, zero remaining findings. Iteration 1 raised three in-scope items (probe-failure regression trap, config-pin amortization for healed shards, tighter probe timeout under shard_lock); iteration 2 raised one more (pin-write failure on fresh checkout discarding a verified checkout). All four have been folded, independently mutation-checked, and confirmed resolved by the terminal delta panelists. The performance-expert validates that the completeness pin eliminates the per-hit ls-files overhead on healed shards while the 10s timeout under shard_lock caps the serialization window to a sane bound. The test-coverage-expert confirms test_pin_write_failure_keeps_verified_checkout regression-traps both call sites (fresh checkout and unpinned cache hit) with mutation kill evidence. The auth-expert confirms the pin-write swallowing path cannot suppress or interfere with the IncompleteCheckoutError credential-retry flow through AuthResolver.

Strategically this is the kind of change that compounds trust with enterprise adopters: it closes a silent cache-poisoning window that affected every user on Git < 2.36 since v0.29.1, self-heals already-poisoned shards without manual intervention, and amortizes the probe cost so healed installations pay no ongoing overhead. The defense-in-depth layering -- detect via ls-files probe, heal via credential retry, amortize via config pin, degrade gracefully on pin-write failure -- is exactly the reliability posture APM needs to credibly serve teams that cannot control their Git version fleet.

Aligned with: secure by default: Incomplete promisor checkouts are now detected before landing in the cache; the retry path preserves anonymous-first policy while ensuring credentialed fallback fires on silent auth rejections. Pin-write failures degrade to re-probe, never to accepting an unverified checkout. pragmatic as npm: Self-healing on cache hit means users on affected Git versions recover without running apm cache clean, knowing the root cause, or upgrading Git. multi harness multi host: Fix targets the Git < 2.36 promisor behavioral divergence specifically; modern Git users pay only the one-time config-pin write, then zero ongoing probe cost per shard.

Material delta since the last advisory (d37325e): every iteration-1 follow-up and both iteration-2 follow-ups are folded. main was merged twice (latest c2c2e0d).

Folded in this run

  • (ci) The new [BUG] Transitive git+path monorepo dependency fails "not a valid APM package" on 0.29.1+ (regression from 0.29.0) #3071 test asserted the shard listing including filelock .lock files (Linux CI red). It now counts variant directories only. Resolved in d37325e.
  • (merge) Resolved the git_cache.py conflict with fix(git): materialize package links from Git objects on every host #3603: the completeness probe runs right after git checkout <sha> and before materialize_tracked_symlinks, so an empty promisor tree still raises the auth-classifiable IncompleteCheckoutError. Resolved in 2880a4f.
  • (panel) Probe-verified sparse shards carry apm.sparseMaterialization=complete, so warm hits skip the ls-files spawn. Legacy 0.29.1+ shards are probed once, then healed or pinned. Resolved in 4e81f07.
  • (panel) The completeness probe under shard_lock uses a 10s timeout (was 60s). Resolved in 4e81f07.
  • (panel) Regression trap for the probe-failure branch (CalledProcessError / TimeoutExpired / OSError -> rebuild). Resolved in 4e81f07.
  • (panel) A failed pin write no longer discards a verified checkout; the helper logs and ignores it. Resolved in 1340965.
  • (panel) Regression trap test_pin_write_failure_keeps_verified_checkout. Resolved in 1340965.

Copilot signals reviewed

  • Overview review 5874188928 (no inline comments) -- NOT-LEGIT: approval-recommended summary, nothing actionable. Round 2 found no new comments, so Copilot is drained.

Deferred (out-of-scope follow-ups)

Regression-trap evidence (mutation-break gate)

  • test_silent_promisor_checkout_raises_auth_signal_and_lands_nothing, test_cached_incomplete_sparse_shard_is_rematerialized, test_transitive_monorepo_subdirectory_retries_with_credentials: deleted _unmaterialized_paths detection (forced []). All 3 tests FAILED as expected; guard restored.
  • test_verified_sparse_shard_skips_probe_on_hit: deleted the pin short-circuit. The test FAILED as expected; guard restored.
  • test_probe_failure_treats_shard_as_incomplete (3 params): deleted the probe except. All 3 cases FAILED as expected; guard restored.
  • test_pin_write_failure_keeps_verified_checkout: re-raised pin-write errors. The test FAILED as expected; guard restored.

Lint contract

The canonical ruff pair (ruff 0.15.12, uv.lock pin) is silent over src/ tests/ plus the architecture-linter scripts. pylint R0801 rated 10.00/10, lint-auth-signals.sh is clean, and lint-architecture-boundaries.sh exits 0.

CI

gh pr checks 3602 at 2a2013f: 23 pass, 3 skipping (CodeQL, deploy, advisory eligibility), 0 failing. license/cla passed. This took 1 CI fix iteration.

Mergeability status

PR head SHA CEO stance iters folds defers Copilot rounds CI mergeable mergeStateStatus notes
#3602 2a2013f ship_now 3 7 1 2 green MERGEABLE BLOCKED pending required review; trial merge with open #3599 is clean

Convergence

3 outer iterations and 2 Copilot rounds. Final panel stance: ship_now. Ready for maintainer review.

Panel summary

Persona B R N Takeaway
Auth Expert 0 0 0 Pin-write swallowing cannot affect the IncompleteCheckoutError credential-retry path; no auth concerns in this delta.
Test Coverage Expert 0 0 0 Prior delta finding resolved: test_pin_write_failure_keeps_verified_checkout regression-traps both call sites; no new coverage gaps in this delta.
Performance Expert 0 0 0 Prior cold-path pin-write finding resolved; guard centralized in _pin_sparse_completeness helper. No new perf concerns in this delta.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 1 follow-ups

  1. [Test Coverage Expert] Pre-existing: 3 tests in tests/integration/test_git_cache_hermetic.py::TestCreateCheckout fail on plain main (mocked subprocess.run str stdout vs fix(git): materialize package links from Git objects on every host #3603 materialize_tracked_symlinks bytes expectation) -- Out of scope for this PR -- failures reproduce on main without this branch. Noted for backlog visibility; file against fix(git): materialize package links from Git objects on every host #3603 or a follow-up.

Recommendation

All four panel findings across three iterations have been folded and mutation-checked; zero in-scope items remain, and CI is green at the exact head. The one listed follow-up is a pre-existing test breakage on main from #3603, not introduced by this PR.


Full per-persona findings

Auth Expert

No findings.

Test Coverage Expert

No findings.

Performance Expert

No findings.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit ed2c920 into main Nov 12, 2026
26 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-3071-transitive-git-path-monorepo-de branch November 12, 2026 18:48
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
Resolve conflicts with the link-text checkout rewrite (#3599/#3602)
in git_cache.py, bare_cache.py, git_env.py and git_sparse.py by taking
main's version and re-applying this PR's mechanical text=True ->
run_git_text rewrite to the remaining Git text-mode calls. main's new
bytes-mode ls-tree/cat-file path in git_sparse stays as is. The sparse
regression test now drives main's public apply_sparse_cone,
sparse_checkout_active and materialize_tracked_symlinks instead of the
removed _tracked_symlinks helper.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
Clean merge of eight main commits (#3408, #2231, #2602, #3640, #3611,
#3645, #3602, #3646); no lockfile or autopilot package conflicts and
apm audit --ci passes with no drift.

Co-authored-by: sergio-sisternes-epam <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
Resolve the git_cache.py conflict with #3602 (incomplete promisor
checkout retry): keep main's `checkout =` result binding and route it
through run_git_text, and route main's new ls-files probe and sparse
completeness pin through run_git_text as well.

Co-authored-by: Copilot App <[email protected]>
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.

[BUG] Transitive git+path monorepo dependency fails "not a valid APM package" on 0.29.1+ (regression from 0.29.0)

2 participants