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
fix: fetch every named dependency ref by the commit it was admitted at - #5195
A dependency given as a branch or tag name was admitted at the commit its ref resolved to, but some download paths then fetched it by name (git clone --branch). If the ref moved in between, the fetched commit and the lockfile could differ from the admitted one.
Every declared ref other than a full commit is now fetched by its admitted commit, never by name:
The subdirectory path fetches the admitted commit through the existing by-commit paths.
The regular path without the persistent cache fetches it shallowly: git init, git fetch --depth=1 --no-tags <url> <commit>, then a detached checkout, using the same validated environment a clone gets (so remote-activated config such as a mirror rewrite applies) and an untranslated git locale. Only when the server refuses a want for an unadvertised commit does it fall back to a full clone and a checkout of the commit, logged at verbose; a commit the server no longer has, or an auth failure, fails at depth-1 cost. When a host answers "not our ref" for a commit, the ref is listed: if it still names the admitted commit, that ref is fetched at depth 1 and the admitted commit is checked out and verified; otherwise the install fails as below.
The persistent-cache paths already fetched by commit and are unchanged.
When the admitted commit is no longer on the origin (for example the branch was force-pushed), the install fails closed and the message names both commits and the remedy, for example: 'main' was admitted at commit <a>, which can no longer be fetched from the origin ('main' now points to <b>). Run the install again to admit its current commit, or 'apm update' when the lockfile pins it. A failure that never reached a reachability verdict, or one that is not a git fetch, clone or checkout failure, keeps its original error. Admission and reachability rules are unchanged.
Human scope-approval comment: the apm-scope approval on #5138.
This PR completes the issue.
Type of change
Bug fix
New feature
Documentation
Maintenance / refactor
Testing
Tested locally
All existing tests pass
Added tests for new functionality (if applicable)
Red-first CLI cells in tests/integration/test_install_pinned_commit_reachability.py (real origin; repo or subdirectory, with or without the persistent cache):
test_a_branch_that_moves_after_admission_installs_the_admitted_commit: the lockfile records the admitted commit and the deployed content matches it. Failed on main for both no-cache paths.
test_an_admitted_commit_force_pushed_away_fails_closed: exit 1 with the named message, nothing installed, no lockfile. Failed on main on all four paths.
test_a_named_ref_is_checked_out_at_its_commit_even_when_a_want_by_commit_is_refused: the shallow fetch by commit, and the full-clone fallback when the server refuses the want.
Fixture and expectation changes (classified with QL before editing, assertions unchanged where marked):
Cells that asserted clone --branch/depth=1 for a named ref now assert the fetch by commit, or run on the default-branch path they were exercising.
Cells whose downloaders had no resolver now use the default-branch path; their assertions are unchanged.
Cost: unchanged with the persistent cache (default). Without it, the regular path stays depth 1, now by commit.
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.
A branch or tag can move between admission and fetch. Every declared ref
other than a full commit is now fetched by its admitted commit, never by
name: the subdirectory path fetches the commit through the existing
by-commit paths, and the regular path without the persistent cache
fetches it shallowly (init, fetch --depth=1 of the commit, detached
checkout), falling back to a full clone and a checkout of the commit when
the server refuses a want by commit. The lockfile and the deployed
content are always the admitted commit. When the admitted commit is no
longer on the origin, the install fails with a message that names both
commits and the remedy.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
apm-spec-waiver: fetch mechanics only; which commit a ref admits and resolves to is unchanged.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
With tiered resolution disabled, persistent-cache downloads can use a newer commit instead of the admitted SHA, while failure handling can misclassify validation or filesystem errors and suppress lost-commit diagnostics.
This PR addresses #5138 by fetching named dependencies at their admitted commit, aiming to keep installed content and lockfile records consistent when a branch or tag moves during installation.
Changes:
Fetches named refs by commit, with a shallow-fetch path and full-clone fallback.
Adds diagnostics for admitted commits that can no longer be fetched.
Adds moving-ref regression coverage and adjusts existing download fixtures.
File
Description
tests/unit/deps/test_github_downloader.py
Updates named-ref expectations and default-branch fixtures.
- Fetch by admitted commit falls back to a full clone only when the
server refuses a want-by-commit; a commit the server no longer has
fails without cloning the history.
- The lost-admitted-commit message renders the ref as printable ASCII.
- Only git and clone failures are renamed; validation errors pass through.
- The persistent subdir path and the error check use the admitted commit
captured at admission instead of resolving the ref again; string refs
are parsed before the check.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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 issues can bypass configured mirrors and misreport transport failures as lost commits, while direct subdirectory downloads lack admission diagnostics and error tests no longer reliably exercise the intended failure paths.
Open admission context for direct subdirectory downloads
src/apm_cli/deps/github_downloader.py:1804
The admission context is opened only for download_package, but ScriptRunner._auto_install_virtual_package calls download_subdirectory_package directly (core/script_runner.py:919). On that path, _note_admitted discards the admitted ref/commit, so a ref force-pushed away still produces a generic Git failure instead of the named diagnostic. Establish the context at the subdirectory entry point too, preserving its keyword-call interface, and cover the direct-call path.
Update tests to mock the named-ref fetch route
src/apm_cli/deps/github_downloader.py:1994
TestGitHubPackageDownloader.test_download_package_git_failure and TestDownloadPackage.test_git_command_error_auth_failure_raises_runtime still stub only the old clone route, which this named-ref branch bypasses. They can reach the real fetch transport and satisfy their broad Failed to clone assertions on an unrelated failure without exercising the scripted Git/authentication error. Update both fixtures to mock the new fetch route (or use an undeclared ref if they specifically test cloning), and assert that the failure mock was called.
- The fetch by commit runs untranslated (LC_ALL=C, LANGUAGE=C), so a
server's refusal is recognized in any locale.
- A host that answers "not our ref" gets the named ref fetched shallowly
by name, only while it still points at the admitted commit, and the
checkout is verified against that commit; otherwise the install fails
naming the lost commit. No full clone either way.
- The fetch by commit uses the validated clone environment, so config a
clone activates by its remote URL (a mirror rewrite) applies.
- A transport failure before any reachability verdict keeps its original
error instead of being reported as a lost commit.
- Mkdtemp permission cells use the default branch: a named ref is now
resolved to its commit before any temp directory exists.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A named ref, resolved to its commit through a stubbed resolver, reaches
the same temp-directory error handling as the default branch.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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
Active findings identify a prohibited mutable-ref fallback, a false lost-commit diagnosis for reachable commits, and verification failures for packages with valid internal symlinks.
The fetch by name for a host that will not serve a commit by its id
checked the checkout before tracked links were materialized, so a
package with a link failed. The caller already verifies every fetch by
commit against its commit after materializing links.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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 mirror routing and auto-install diagnostics have unresolved edge cases, while an authentication test may pass on an unrelated network failure.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The fallback lookup uses the original transport environment instead of the validated mirror configuration, risking contact with the wrong server and incorrect reports that an available commit is missing.
The by-name fallback listed the ref with the transport environment, so a
mirror activated by the remote URL was skipped and the listing went to
the origin. Listing and fetch now both use the validated clone env.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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 to evaluate a critical risk of reusing mirror-derived reachability verdicts at the origin and a dumb-HTTP regression affecting fully qualified refs.
The probe memo was process-global and held its entries for the process
lifetime. It now lives on the install attempt's verdict stage, keyed by
a digest of the URL and environment, and is dropped when the attempt
commits or is discarded. Without an open stage every listing probes.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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 conditional mirror rewrites can permit reuse of reachability verdicts without upstream checks and mask lost-commit diagnostics, while dumb-HTTP no-cache installs can regress.
A ref listing that a remote-activated mirror served recorded its tip
under the transport environment, i.e. as the origin's verdict; once the
rewrite was removed, the origin trusted that marker without a check. The
listing environment is now probed once and used both to list and to
record, so the verdict names the mirror.
The loopback HTTPS cell server wraps its socket with stdlib ssl, as the
repository's HTTPS fixtures do, so an injected truststore cannot break it.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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 to evaluate mirror-transport inconsistencies and dumb-HTTP fallback regressions that can suppress lost-commit diagnostics or reject available commits.
A tip the resolver read from the origin (a commits API answer or its
legacy clone) was recorded under the transport environment. A clone that
a remote-activated mirror served was then keyed as the origin's verdict.
The tip is now keyed under the same probed listing environment as a
listed tip, and nothing is recorded when that probe cannot run.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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
A critical cache issue can record the origin’s reachability verdict for an unchecked mirror, allowing later SHA admission to skip required verification.
The reachability check listed and keyed its verdict under the transport
environment, but its persisted repository has an origin remote, so a
remote-activated mirror rewrite could serve its fetch. A commit only the
mirror held was then recorded as the origin's verdict. The check now
probes the clone environment once and uses it for the verdict key, the
listing and the fetch, so each names the server that answered.
The locked-replay cell matches git subcommands by argument, not by
substring of a path.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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 unpublished critical findings identify stale-cache commit admission without origin verification and dumb-HTTP compatibility regressions.
- Only an includeIf section can make git config depend on the remote. An
install attempt checks once whether any config scope has one; without
one, the transport environment already is the clone environment and
nothing is probed. When that cannot be told, it probes.
- A tip the resolver read is recorded only when the probed and transport
environments name the same server: the resolver may have listed the
origin plainly or cloned it through a remote-activated mirror, so under
such a rewrite the tip is verified at the destination when next admitted.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Recording a resolved tip probes which server a clone of its contact
reaches. That probe ran under the downloader's environment, so its local
git calls (which name the contact URL) could carry platform tokens and a
translated locale. It only needs the URL git contacts, so it now runs
without credentials and untranslated.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
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 unpublished findings identify Git object-format mismatches and missing commit-pinned fallback support for whole-repository dependencies on dumb-HTTPS hosts.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to evaluate unpublished findings concerning version-range fallback failures and no-cache download regressions on dumb HTTPS origins.
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
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
A dependency given as a branch or tag name was admitted at the commit its ref resolved to, but some download paths then fetched it by name (
git clone --branch). If the ref moved in between, the fetched commit and the lockfile could differ from the admitted one.Every declared ref other than a full commit is now fetched by its admitted commit, never by name:
git init,git fetch --depth=1 --no-tags <url> <commit>, then a detached checkout, using the same validated environment a clone gets (so remote-activated config such as a mirror rewrite applies) and an untranslated git locale. Only when the server refuses a want for an unadvertised commit does it fall back to a full clone and a checkout of the commit, logged at verbose; a commit the server no longer has, or an auth failure, fails at depth-1 cost. When a host answers "not our ref" for a commit, the ref is listed: if it still names the admitted commit, that ref is fetched at depth 1 and the admitted commit is checked out and verified; otherwise the install fails as below.When the admitted commit is no longer on the origin (for example the branch was force-pushed), the install fails closed and the message names both commits and the remedy, for example:
'main' was admitted at commit <a>, which can no longer be fetched from the origin ('main' now points to <b>). Run the install again to admit its current commit, or 'apm update' when the lockfile pins it.A failure that never reached a reachability verdict, or one that is not a git fetch, clone or checkout failure, keeps its original error. Admission and reachability rules are unchanged.Issue and approved scope
Issue: Fixes #5138
Human scope-approval comment: the apm-scope approval on #5138.
This PR completes the issue.
Type of change
Testing
Red-first CLI cells in
tests/integration/test_install_pinned_commit_reachability.py(real origin; repo or subdirectory, with or without the persistent cache):test_a_branch_that_moves_after_admission_installs_the_admitted_commit: the lockfile records the admitted commit and the deployed content matches it. Failed on main for both no-cache paths.test_an_admitted_commit_force_pushed_away_fails_closed: exit 1 with the named message, nothing installed, no lockfile. Failed on main on all four paths.test_a_named_ref_is_checked_out_at_its_commit_even_when_a_want_by_commit_is_refused: the shallow fetch by commit, and the full-clone fallback when the server refuses the want.Fixture and expectation changes (classified with QL before editing, assertions unchanged where marked):
clone --branch/depth=1 for a named ref now assert the fetch by commit, or run on the default-branch path they were exercising.Validation (serial, targeted): tests/unit/deps plus shared_clone_cache, validation_flow, deps_resolver, deps_models, install_pinned and git_cache_sha_reachability: 2624+ passed. Lint mirror (ruff check/format, pylint R0801, lint-auth-signals.sh, complexity ratchet, taxonomy --changed, architecture boundaries) and quality baselines: clean.
Cost: unchanged with the persistent cache (default). Without it, the regular path stays depth 1, now by commit.
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}regenerated