Skip to content

perf(install): authenticated in-process fetch and ref listing for github.com - #5353

Merged
Daniel Meppiel (danielmeppiel) merged 26 commits into
mainfrom
danielmeppiel-inprocess-fetch-auth
Nov 24, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 26 commits into
mainfrom
danielmeppiel-inprocess-fetch-auth

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Stacked on #5351. Authenticated installs from github.com get the in-process speed-up too: the pinned fetch (A') and the ref listing (lever 1) carry APM's own github-basic credential, per request, exactly where today's git path would send it.

Who gets it. Authenticated github.com installs (public and private): GITHUB_APM_PAT/GITHUB_TOKEN with APM_GITHUB_AUTH_FIRST, and the token retry after an anonymous failure. GHE, Azure DevOps, GitLab and Artifactory hosts, sparse checkouts and any user-configured http.extraHeader/helper still use git. No user changes rate-limit bucket: the same credential goes to the same origin as git would send it, with fewer requests.

Mechanism (W3d row w3d:ruling:b1-authenticated, A1-A10; listing LA1-LA5).

  • _split_managed_auth consumes exactly one http.extraheader entry: the Authorization: Basic b64(x-access-token:<token>) that utils/git_env writes under APM_GIT_MANAGED_AUTH_INTENT=1. It returns the env without it. Bearer, foreign or malformed values, or two managed entries, refuse. The gate, memos and logs only ever see the token-free env; any other extraHeader stays and sends the fetch to git.
  • _post(..., authorization): the header goes on the request only (never session.headers), via origin_bounded_request with the exact origin, max_hops=0 and ambient_credentials=False. del authorization follows the post.
  • A 403/throttle trips the breaker. WWW-Authenticate or any non-200 refuses, so git runs in the SAME try_with_fallback attempt with the same env.
  • Lever 1 (anonymous_ref_listing.list_refs_authenticated): the same managed-auth seam for git ls-remote. It runs perf(outdated): list public github.com refs in process for the anonymous attempt #4960's own _list_refs gates on the token-free env (same charset, size/time caps and output filter).
W3d condition where / cell
A1 token only inside the try_with_fallback attempt, AuthResolver's github-basic bytes _split_managed_auth; unit only_apms_github_basic_header_is_taken
A2 per request, exact origin, max_hops=0 _post; listing cell a_redirect_falls_back_and_never_carries_the_header_away
A3 never on session.headers unit header_is_sent_per_request_and_never_on_the_session
A4 HTTPS CONNECT proxies only proxy from anonymous_ref_listing._proxy in _gate (https:// proxy or userinfo -> git)
A5 never logged / in exceptions / memos / receipts split before _gate; _redact; cells token_never_reaches_debug_output, the_token_never_reaches_debug_logs
A6 non-200/challenge -> git, same attempt _admit; cells revoked_token_fails_exactly_like_git_and_never_leaks, a_revoked_token_falls_back_to_git_which_fails_as_today
A7 breaker applies _admitted_post + _rate_limited (unchanged)
A8 only APM's header consumed; user extraHeader -> git unit a_bearer_or_foreign_header_is_not_consumed; cells user_extra_header_sends_the_authenticated_fetch_to_git, a_user_extra_header_sends_the_listing_to_git
A9 token only in the call frame local authorization, del after the post
A10 / F12 same write/verify path; differential (private, auth-first, revoked) cells authenticated_attempt_fetches_in_process_with_only_apms_header (lockfile + tree == APM_NO_INPROCESS_FETCH=1), private_repository_installs_in_process_like_git, retry_env_fetches_in_process_and_an_anonymous_env_too
LA1 same credential as git, per request a_private_listing_in_process_equals_git_with_the_same_header, an_env_without_apms_header_never_lists_in_process
LA2 #4960 E1-E4 unchanged shared _list_refs gates on the token-free env
LA3 one origin; fallback in the same attempt redirect and revoked-token listing cells
LA4 never logged the_token_never_reaches_debug_logs
LA5 private listing == git byte for byte first listing cell asserts equality with git ls-remote --tags --heads

This replaces #5330's cell "an authenticated attempt never uses the in-process fetch": the authenticated attempt now engages by design.

Windows scope. Windows numbers apply to Windows with the OpenSSL TLS backend. Default Git for Windows uses schannel, which falls back to git until #5376 lands.

Evidence. Population: authenticated token-first, github.com (incl. private repos), for both A' and lever 1. Headline = the authenticated harness; the anonymous runs are no-regression checks only.

  • A' cold t50: Linux 14.82 -> 10.31 s (0.708), spawns 816 -> 166 [45375435538]; Windows 50.74 -> 25.66 s (0.504, about 2x) [45378994721].
  • Lever 1 warm t50: Linux 11.88 -> 10.00 s (0.842) [45378975894]; Windows 20.73 -> 17.19 s (0.827) [45383549748]; git ls-remote 50 -> 0.
  • Cells on hosted runners x3: Windows 66 passed [45378907506], Linux 65 passed + 1 skip [45378948943].

Issue and approved scope

Issue: Refs #4939

Human scope-approval comment: none yet for this item. Ordered by the PERF lead chain under #4939; W3d ruled A1-A10 and LA1-LA5 OK with conditions; QL granted the combined-PR timing override.

This does not complete #4939.

Type of change

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

Testing

  • Tested locally (not run locally: a host load order is in force; all evidence is from CI)
  • All existing tests pass (PR CI)
  • Added tests for new functionality (if applicable)

Fast check (declared before dispatch): base = #5351 head, new = this head, authenticated harness (GITHUB_APM_PAT + APM_GITHUB_AUTH_FIRST=1) and the anonymous harness. install-cold + install-warm, tree-50, rtt 30, 6 pairs, Linux + Windows. Bar: an authenticated cold win, at most 1.010 elsewhere, 0 errors. Runs at 679208c: headline, authenticated harness, Linux 45387819588 and Windows 45387843433; no-regression only, anonymous harness, Linux 45387735840 and Windows 45387762251 (pending).

Final read at 20bd3e7 vs main d62aebe (PERF VP). Authenticated harness: Windows cold t50 40.23 -> 20.43 s (0.503), warm 0.886; Linux cold 11.84 -> 7.00 s (0.578), warm 0.817; requests 251 -> 101, spawns 365 -> 19 [45424300764 / 45424160141]. Anonymous harness: cold Linux 0.998, Windows 0.989. Disclosure: anonymous warm +1.6% CPU on both OSes (Linux 1.016, Windows 1.017 [45424456133 / 45424540252]) with identical requests; no named function at profile resolution; accepted against the ~2x authenticated win. Later heads (3002278, e0ba7e9) are test-only.

Changelog

  • 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.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

apm-spec-waiver: transport change below the lockfile; no OpenAPM requirement covers how a pinned commit is fetched or refs are listed

…ged github-basic header only)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…d token differential, user extraHeader -> git, no token in output)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…' env places it

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…on A''s managed-auth seam (no PR)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A private repository's listing in process equals git ls-remote byte for
byte and carries only git's own extraheader. A redirect, a revoked token,
a user extraHeader or an env without APM's managed header falls back to
git, and neither a hit nor a fallback logs the token.

apm-spec-waiver: test-only cells for the authenticated in-process listing

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel Daniel Meppiel (danielmeppiel) added the full-integration Run the full integration suite (ci-integration.yml) on this PR before merge label Nov 24, 2026

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.

🟡 Changes recommended

The new test module lacks a required behavioral marker and will fail the taxonomy gate, while private-repository token retries bypass the advertised in-process ref listing.

2 open issues
What changed in this PR

Extends APM's in-process Git transport to authenticated github.com requests, building on earlier anonymous and Windows support to reduce install overhead.

Changes:

  • Sends APM-managed credentials per request for pinned fetches and ref listings, preserving transport gates and git fallback.
  • Adds authenticated ref listing to the resolver's auth-first path.
  • Adds credential-isolation, fallback, and git-parity tests, plus a performance changelog entry.
File Description
src/​apm_cli/​cache/​inprocess_fetch.py Extracts managed authentication and passes it to pinned-fetch requests.
src/​apm_cli/​deps/​anonymous_ref_listing.py Adds authenticated listings using existing validation and transport gates.
src/​apm_cli/​deps/​git_reference_resolver.py Attempts authenticated in-process listing before git in the primary path.
tests/​unit/​cache/​test_inprocess_fetch_gate.py Checks managed-header extraction and request-only credentials.
tests/​integration/​test_inprocess_fetch_world.py Covers authenticated fetch parity, private repositories, and credential handling.
tests/​integration/​test_anonymous_ref_listing_auth_world.py Covers authenticated listing parity, redirects, fallback, and log privacy.
changelog.d/​5353.changed.md Records the authenticated-install performance improvement.

Review effort: Balanced

…ndows' into danielmeppiel-inprocess-fetch-auth
…W3d R1, LA3)

A throttle or any 403 on an in-process listing trips the command's breaker,
and a tripped breaker sends every later listing and fetch straight to git.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

The new test module lacks a required behavioral marker and fails the taxonomy gate, while default anonymous-first token retries still bypass the authenticated ref-listing fast path.

2 open issues

Review effort: Balanced

…ndows' into danielmeppiel-inprocess-fetch-auth
…ndows' into danielmeppiel-inprocess-fetch-auth
… patch collaborators

The authenticated fetch and listing build their per-request credential header
with http_credentials (owner rule transport-platform-authenticated-egress);
the A' gate cells no longer import the git_env owner they patch.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Base automatically changed from danielmeppiel-inprocess-fetch-windows to main November 24, 2026 15:13
…ndows' into danielmeppiel-inprocess-fetch-auth

# Conflicts:
#	tests/unit/cache/test_inprocess_fetch_gate.py

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.

🔵 Needs a closer look

The new test module lacks a required behavioral marker and fails the taxonomy gate, while the default token-retry path bypasses authenticated ref listing.

2 open issues

Review effort: Balanced

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.

🔵 Needs a closer look

The new test module fails the taxonomy gate because it lacks a behavioral marker, and the default token-retry path bypasses authenticated in-process ref listing.

2 open issues

Review effort: Balanced

…reads the world's ambient TLS config

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

Human assessment is needed because a concurrency finding omitted from the published review may allow additional requests after the shared throttling breaker has tripped.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The cells script git ls-remote, but branch_and_tag_refs first asks the
in-process anonymous listing, which reached the real github.com/owner/repo
on Windows runners and answered its real refs (main red at 3fb82ec).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…scripted listing

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ot a patch (AQ004)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…sting

install-cold-auth: 0 clones, 20 requests, +343 files written (pack objects
written by the in-process fetch, as on the anonymous path), git.config +1
(the checkout-attributes probe). install-warm-auth: the ref probe is 10
requests, not 10 ls-remote spawns.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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.

🟡 Changes recommended

A concurrency gap lets an in-process request proceed after another call trips the 403/429 circuit breaker, continuing traffic instead of falling back to git.

1 open issue

Review effort: Balanced

Another listing or fetch can trip the command's breaker while this one is in
its config, proxy and TLS checks; the request now stays unsent.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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 were identified for the authenticated in-process Git transport changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 12369e2 into main Nov 24, 2026
66 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-inprocess-fetch-auth branch November 24, 2026 19:43
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 24, 2026
… A' cell

SC6: an authenticated listing and fetch over the Windows-store session to an
untrusted peer (reached through a CONNECT tunnel) send no application byte,
so never the Authorization header.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 24, 2026
…th pack POSTs

The managed github-basic header is split from the env before the gate,
exactly as fetch_worktree does, and sent per request (exact origin, no
redirect hop, never on the session) on the capability GET and the trees
and blobs POSTs. Without managed auth nothing changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 24, 2026
…5364, #5353)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants