Repository navigation
fix(git): pin core.symlinks=true so package hashes match across platforms - #3545
Merged
Daniel Meppiel (danielmeppiel) merged 10 commits intoNov 12, 2026
Merged
Conversation
…orms APM hides user and system Git config from dependency children. Git for Windows then records core.symlinks=false and writes each in-repo link as a text file holding its target path, so the package content_hash differs from the POSIX hash of the same commit and `apm install --frozen` fails with a lockfile generated on Linux or macOS. - git_env owns the pin (git_symlink_pin_args and the network config materializer) and the GitSymlinkCapabilityError diagnostic. - Clone, cached checkout, shared-bare checkout and the uncached fallback all carry core.symlinks=true; cached shards record the pin and older shards are rematerialized on hit. - A host that cannot create symlinks fails before hashing with an error naming the package and the Windows Developer Mode requirement; cache and transport fallbacks no longer retry it. - The native Windows standard-user gate now proves the diagnostic instead of the previous link-text fallback. Fixes #3457 Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 10, 2026 20:48
Co-authored-by: Copilot App <[email protected]>
apm-spec-waiver: remote package content_hash is reserved for OpenAPM v0.2; this fixes platform materialization only Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Uncached installs can fail on unrelated default-branch symlinks or retry downloads after capability failures, while an incorrect cleanup path and platform-dependent fixtures undermine regression tests.
5 open issues
Stop sparse-checkout retries after a symlink capability failure · New Skip checkout during clone to avoid unrelated symlink failures · New Check for incomplete checkouts under the correct cache directory · New Write fixture contents with platform-independent line endings · New Use the canonical symlink pin for cache persistence · New
What changed in this PR
This PR addresses #3457 by forcing real symlinks in dependency Git checkouts, preventing link-text files from producing different package hashes across platforms. It deliberately replaces the earlier fallback behavior with an actionable error when the host cannot create symlinks.
Changes:
- Centralizes the symlink pin and capability diagnostic, applying them across clone and checkout paths.
- Rematerializes older cache entries and propagates capability failures.
- Updates regression tests, Windows acceptance checks, architecture guards, and documentation.
| File | Description |
|---|---|
| tests/unit/test_windows_native_symlink_probe.py | Updates diagnostic case and mutation expectations. |
| tests/unit/install/test_symlink_capability_install.py | Tests install failure before hashing or lockfile creation. |
| tests/unit/deps/test_github_downloader_symlink_capability.py | Tests capability-error propagation and retry suppression. |
| tests/unit/deps/test_github_downloader_phase3.py | Updates checkout expectations with package labels. |
| tests/unit/deps/test_github_downloader_error_handling.py | Updates checkout expectations with package labels. |
| tests/unit/cache/test_proxy_compat.py | Adds the symlink pin to cache fixtures. |
| tests/unit/cache/test_git_symlink_precedence.py | Removes obsolete precedence tests. |
| tests/unit/cache/test_git_symlink_pin.py | Tests the canonical pin and error classification. |
| tests/unit/cache/test_git_symlink_config.py | Replaces precedence checks with pin and hash regressions. |
| tests/unit/cache/test_git_cache.py | Updates cache fixtures with both materialization pins. |
| tests/unit/cache/test_git_cache_symlinks.py | Adds cache, rematerialization, and shared-bare regressions. |
| tests/unit/cache/test_git_cache_recency.py | Updates the cache fixture for pin validation. |
| tests/unit/cache/test_git_cache_hardening.py | Updates the cache fixture for pin validation. |
| tests/test_github_downloader.py | Verifies the package label passed to checkout. |
| tests/integration/test_windows_native_symlink.py | Requires a capability diagnostic instead of link-text fallback. |
| tests/integration/test_git_cache_hermetic.py | Updates cache fixtures and subprocess counts. |
| src/apm_cli/utils/git_env.py | Owns the symlink pin and capability diagnostic. |
| src/apm_cli/deps/github_downloader.py | Propagates capability errors and passes package labels. |
| src/apm_cli/deps/bare_cache.py | Pins shared-bare checkouts and classifies failures. |
| src/apm_cli/cache/git_cache.py | Pins materialization and rebuilds older checkout shards. |
| scripts/windows_native_symlink_probe_entry.py | Updates native diagnostic and mutation checks. |
| scripts/architecture_linter/checks/transport_auth_platform.py | Adds pin ownership and consumer guards. |
| packages/apm-guide/.apm/skills/apm-usage/dependencies.md | Documents symlink requirements for agent guidance. |
| docs/src/content/docs/contributing/integration-testing.md | Updates the native Windows acceptance contract. |
| docs/src/content/docs/consumer/install-packages.md | Documents capability errors and cache migration. |
| CHANGELOG.md | Records the portability fix and changed fallback behavior. |
| .apm/architecture/owners/transport-auth-platform.json | Registers ownership of the dependency symlink pin. |
Review effort: Balanced
Native Windows git checkout prints 'unable to create symlink' but exits 0 without symlink privilege (observed in the Windows Native Symlink Acceptance job). Classify completed checkout output too, and make the shared test fixture write LF bytes on Windows. apm-spec-waiver: remote package content_hash is reserved for OpenAPM v0.2; this fixes platform materialization only Co-authored-by: Copilot App <[email protected]>
- Expose git_symlink_pin_entry() from git_env; the cache marker, the config materializer and the -c args all derive from it, and the architecture guard forbids quoted core.symlinks literals elsewhere. - Classify sparse-checkout results before the exit-code check and let the capability error escape, so no re-clone follows a known failure. - Commit-pinned clones skip the default-branch checkout, so an unrelated link at HEAD cannot fail a package that has none. - Fix the cache test's checkout root so stage cleanup is really asserted. apm-spec-waiver: remote package content_hash is reserved for OpenAPM v0.2; this fixes platform materialization only Co-authored-by: Copilot App <[email protected]>
Commit-pinned downloads keep cloning with a checkout (the native download-denied recovery probe depends on that sequence) and only retry with --no-checkout when the default-branch clone hits the symlink capability error, so a link at HEAD cannot fail a commit without links. apm-spec-waiver: remote package content_hash is reserved for OpenAPM v0.2; this fixes platform materialization only Co-authored-by: Copilot App <[email protected]>
Resolve git_env.py conflict: keep both the core.symlinks pin helpers (this PR) and git_autocrlf_pin_args (#3409); checkout_git_worktree now applies both pins and keeps symlink-capability classification. Co-authored-by: Copilot App <[email protected]>
Keep the PR changelog bullet under [Unreleased] after the 0.35.1 release cut. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-issue-3457-delivery
branch
November 12, 2026 09:17
This was referenced Nov 12, 2026
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 12, 2026
…3603) * fix(git): materialize package links from Git objects on every host Dependency checkouts now pin core.symlinks=false, so Git writes each in-repo link as link text and never needs OS symlink capability. One owner, utils/git_sparse.materialize_tracked_symlinks, resolves every tracked mode-120000 entry in the package scope against the checked-out commit's tree (POSIX component-wise resolution, containment, 40-hop and directory-cycle bounds) and writes the target's checkout bytes and executable bit, or expands a directory link. The result is the tree a POSIX checkout yields when its links are followed, so content_hash is identical on Linux, macOS and Windows without Developer Mode, and --frozen replays a lockfile from any platform. Escaping, broken and cyclic links are rejected before hashing. Shared cache shards materialize leniently and the package consumer validates strictly; shards without the new apm.linkMaterialization marker heal on hit. Out-of-cone targets resolve from objects, so sparse cones no longer widen (#2707). The now-unreachable symlink capability diagnostic from #3545 is removed. Fixes #3457 apm-spec-waiver: Git checkout link handling is not an OpenAPM statement; materialized links reach req-sc-015 as regular, scanned files. Co-authored-by: Copilot App <[email protected]> * docs(changelog): reference #3603 for the link materialization entry Co-authored-by: Copilot App <[email protected]> * test(links): root the install lifecycle under a short temp dir for Windows MAX_PATH Co-authored-by: Copilot App <[email protected]> * fix(links): bound expansion, reject host-unsafe entries, cover path: fetches Review follow-ups on the Git-object link owner: - a shared 100000-entry budget rejects acyclic fan-out before it grows exponentially; - expanded source and destination entry names must be plain portable paths (no "..", backslash, colon or NUL), so a POSIX-authored "..\\..\\x" cannot escape the checkout on Windows; - a component after a file, including "", "." and "..", is ENOTDIR; - link blobs load on demand, and out-of-tree reads take attributes from the commit (--attr-source=HEAD, Git 2.40+, with fallback); - the path: sparse file transport resolves a tracked link through the owner instead of returning its link text. Co-authored-by: Copilot App <[email protected]> * test(gitlab): allow the local ls-tree link lookup in the sparse transport contract Co-authored-by: Copilot App <[email protected]> * test(links): make the unsafe-name and transport link tests portable to Windows Co-authored-by: Copilot App <[email protected]> * test(links): feed mktree bytes so Windows does not append CR to entry names Co-authored-by: Copilot App <[email protected]> * test(links): cover monorepo subdirectory installs and the full-clone fallback Panel follow-ups (test-coverage-expert): - the real-binary lifecycle now runs for a whole-repo and a subdirectory package whose links leave the package path; both pin a golden content_hash, replay with --frozen from a cold cache and reject escaping, broken and cyclic links before any lock is written; - a real-Git test drives download_subdirectory_package through the full-clone fallback and asserts the installed tree is link content. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>
7 of 17 tasks
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 12, 2026
Name what users observe (an error naming the Git command and offending byte), cover apm update and other Git-running commands, and keep the entry next to, not between, the related #3545 symlink entries. Addresses panel follow-ups from doc-writer (FU-2, FU-3). Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 12, 2026
…#3626) * fix(install): decode Git output as UTF-8 regardless of Windows locale On hosts whose locale codec is not UTF-8 (cp936/GBK on Simplified Chinese Windows), subprocess text mode decoded Git output with the locale codec and crashed `apm install` inside the Windows reader thread (#3056). Add run_git_text() to the Git child-process owner (utils/git_env.py): it decodes UTF-8 with surrogateescape so decoding never fails mid-stream, then raises GitOutputDecodeError if a successful command's stdout is not valid UTF-8, and renders stderr / failed-command output with visible backslash escapes so existing failure handling is unchanged. Route the install-path Git text-mode calls through it, decode the progress clone stream as UTF-8, and add the transport-platform-git-output-decoding architecture guard. Fixes #3056 Co-authored-by: Copilot App <[email protected]> * docs(changelog): reference #3626 for the Git output decoding fix Co-authored-by: Copilot App <[email protected]> * fix(cache): remove staged trees when Git output decoding fails GitOutputDecodeError subclasses subprocess.SubprocessError, not CalledProcessError or TimeoutExpired, so a rejected checkout or bare clone output escaped _create_checkout() and _ensure_bare_repo() (and its partial-clone fallback) without removing the .inc.* staging tree. Catch SubprocessError in those three handlers so the stage is removed and the failure is still raised as the existing RuntimeError, chained to the named decode error. Regression tests prove no stage or shard remains; each handler was mutation-broken to confirm its test fails without it. Addresses Copilot inline on src/apm_cli/cache/git_cache.py:834. Co-authored-by: Copilot App <[email protected]> * test(git): guard URL-free decode diagnostics; tighten helper types Add a parametrized regression proving GitOutputDecodeError names only 'git <subcommand>' and never echoes URLs, tokens, paths or option values; mutation-broken by dropping the option-value skip (5 of 6 cases fail). Treat --config-env as a value-taking global option, which Git accepts in the separated form. Type _escaped_git_text and _strict_git_text with overloads so CompletedProcess[str] assignments stay typed, and skip the codec round-trip for empty output. Addresses panel follow-ups from test-coverage-expert (FU-1), python-architect (FU-4) and performance-expert (FU-5). Co-authored-by: Copilot App <[email protected]> * docs(changelog): describe the Git decode error users actually see Name what users observe (an error naming the Git command and offending byte), cover apm update and other Git-running commands, and keep the entry next to, not between, the related #3545 symlink entries. Addresses panel follow-ups from doc-writer (FU-2, FU-3). Co-authored-by: Copilot App <[email protected]> * fix(cache): count a sparse probe decode error as incomplete The #3071 sparse completeness probe documents that probe failures count as incomplete so the shard is rebuilt, but it caught only CalledProcessError and TimeoutExpired, so a GitOutputDecodeError from non-UTF-8 ls-files output escaped the cache-hit path. Catch SubprocessError there and in the best-effort pin write, matching the other cache handlers in this PR. Regression test mutation-broken. Co-authored-by: Copilot App <[email protected]> * test(git): ignore shard lock files in the checkout cleanup regression On Linux the shard lock leaves a <variant>.lock file next to the checkout; assert that no stage or published shard remains, as the bare clone regression already does. Fixes the Build & Test Shard 2 failure. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
fix(git): pin
core.symlinks=trueso package hashes match across platformsTL;DR
APM hides user and system Git config from dependency children, so Git for Windows records
core.symlinks=falseand writes every in-repo link as a small text file. The packagecontent_hashthen differs from the Linux/macOS hash for the same commit andapm install --frozenfails on Windows with a lockfile generated elsewhere. This PR pinscore.symlinks=trueon every APM clone and checkout and, when the host cannot create symlinks, fails before hashing with a diagnostic that names the package and the Windows requirement.Important
This deliberately replaces the link-text fallback that #3145 (#3137) preserved for non-admin Windows accounts. Under the approved #3457 scope, a package with in-repo links on a host without symlink capability now fails with a clear diagnostic instead of installing link text with a non-portable hash. Packages without links are unaffected. The native Windows Native Symlink Acceptance job is re-pointed to prove the new contract.
Problem (WHY)
_materialize_git_config_snapshotfroze whatevercore.symlinksit saw, including thefalsethatgit initwrites on Windows when global config is hidden, so APM clones wrote link text (reporter:microsoft/[email protected], 74 mode-120000 entries,sha256:5ef3cc66…vs Linuxsha256:9328e637…).GitCache, shared-bare consumers,checkout_git_worktree) ran under the auth env with no symlink setting at all, so they inherited the samefalse.Content hash mismatch, which does not tell the user what to fix.Why these matter: the lockfile contract requires that the same pinned commit produces the same
content_hashon every platform (issue #3457 "Expected behavior"); the approved scope is the apm-scope:v1 record.Approach (WHAT)
utils/git_env.py:git_symlink_pin_args()(-c core.symlinks=true) for local commands, and the network config materializer always emitscore.symlinks=true(dropping inherited, capability and caller values).GitSymlinkCapabilityError+raise_for_symlink_capability()classify Git'sunable to create symlinkfailure (through wrapped causes) into one named diagnostic.clone_git_worktree), cached checkout (GitCachevia_safe_git_args), shared-bare checkout (materialize_from_bare) and the uncached fallback (checkout_git_worktree, sparse fetch) through the pin and the diagnostic.core.symlinks = true; shards without it are rematerialized on hit, mirroring the existingcore.autocrlfheal.git checkoutprintsunable to create symlinkyet exits 0 (observed in the native job). If a commit-pinned clone fails on a link at the default-branch HEAD, it retries with--no-checkoutand materializes only the pinned commit.Implementation (HOW)
src/apm_cli/utils/git_env.py—git_symlink_pin_entry(single source of the key/value),git_symlink_pin_args,GitSymlinkCapabilityError,raise_for_symlink_capability; materializer pins instead of retaining (removes_symlink_entry_wins);clone_git_worktreeandcheckout_git_worktreeclassify failures (checkout_git_worktreegainspackage=).src/apm_cli/cache/git_cache.py—_safe_git_argsadds the pin; staged shards record both pins;_checkout_has_materialization_pinsgates cache hits and write-dedup; checkout failures raise the diagnostic after cleaning the stage.src/apm_cli/deps/bare_cache.py—materialize_from_barepins clone/sparse/checkout/repair and acceptspackage=for the diagnostic.src/apm_cli/deps/github_downloader.py— passes the package label and re-raisesGitSymlinkCapabilityErrorfrom cache, shared-bare, clone and checkout paths.scripts/architecture_linter/checks/transport_auth_platform.py,.apm/architecture/owners/transport-auth-platform.json— extend the existingtransport-platform-git-child-environmentguard: required owner symbols ingit_env.py, required pin/diagnostic use ingit_cache.py/bare_cache.py, and a ban on literalcore.symlinks=outsidegit_env.py.tests/integration/test_windows_native_symlink.py,scripts/windows_native_symlink_probe_entry.py, probe unit test) — the standard-user case now requires the diagnostic; the negative control inverts the pin (drop-symlink-pin) and must fail.consumer/install-packages.md,contributing/integration-testing.md,apm-guidedependencies.mddescribe the new requirement; CHANGELOGFixedentry.Diagrams
Legend: where the pin and the diagnostic apply on the install path; boxed nodes are new behavior.
flowchart LR DL[github_downloader.download_package] --> GC[GitCache.get_checkout] DL --> CL[clone_git_worktree] DL --> CO[checkout_git_worktree] DL --> MB[materialize_from_bare] GC -->|_safe_git_args| PIN["-c core.symlinks=true"] CO --> PIN MB --> PIN CL -->|git_network_env materializer| PIN PIN --> GIT{git checkout} GIT -->|real symlinks| HASH[copy + compute_package_hash = POSIX hash] GIT -->|unable to create symlink| ERR["GitSymlinkCapabilityError: names package + Developer Mode"] ERR --> EXIT[apm install exits nonzero, no lockfile]Trade-offs
-cargv for local commands plus the materializer for network envs.-coutranksGIT_CONFIG_KEY_nand every file scope (same reason as the existingcore.autocrlfpin); both read one constant ingit_env.py.content_hashdiffers on Windows when the dependency repository setstext=autoin.gitattributes#3270, [BUG] Uncached fallback install of a locked commit fails on Windows with "Your local changes ... would be overwritten by checkout" when the system gitconfig setscore.autocrlf=true#3368).apm cache clean.Benefits
Content hash mismatch.core.symlinks=literal fails the architecture lint.Validation
Lint mirror (merged with origin/main 59549ac)
File-length:
github_downloader.py2050 lines (< 2100). No newrelative_tooryaml.dumppatterns.Tests
Red on main: 17 of 22 real-Git cases in
tests/unit/cache/test_git_symlink_config.pyfail on59549aca5.Mutation-break: setting
_SYMLINK_PIN_VALUE = "false"fails 27 of 29 real-Git cache/clone cases; removing the downloader re-raise fails 2 of 3 downloader cases.Scenario Evidence
core.symlinks=truetests/unit/cache/test_git_symlink_config.py::test_network_env_pins_symlinks_true,::test_checkout_pins_symlinks_over_isolated_caller_env,tests/unit/cache/test_git_cache_symlinks.py::test_safe_git_args_pin_real_symlinks,::test_bare_materialization_pins_symlinks_over_caller_envcontent_hash(runs natively on the Windowswindows_compatlane)test_git_symlink_config.py::test_clone_records_the_posix_content_hash,test_git_cache_symlinks.py::test_cached_checkout_materializes_links_with_posix_hashtests/unit/install/test_symlink_capability_install.py,tests/unit/cache/test_git_symlink_pin.py,tests/integration/test_windows_native_symlink.py(native standard user)test_git_cache_symlinks.py::test_cache_hit_rematerializes_shard_missing_symlink_pintest_git_cache_autocrlf.py,test_git_cache_hermetic.py, downloader suitesHow to test
uv run --extra dev pytest tests/unit/cache/test_git_symlink_config.py tests/unit/cache/test_git_cache_symlinks.py tests/unit/cache/test_git_symlink_pin.py tests/unit/deps/test_github_downloader_symlink_capability.py tests/unit/install/test_symlink_capability_install.pyapm installa project depending onmicrosoft/aspire-skills#v0.0.4with an emptyAPM_CACHE_DIR; the lockfile recordssha256:9328e637….drop-symlink-pinmutation fails, restored passes.Issue and approved scope
Issue: Fixes #3457
Human scope-approval comment: #3457 (comment) (Review contact: Daniel Meppiel (@danielmeppiel))
This PR completes the posted Scope and Done when. Out of scope items are untouched.
Type of change
Testing
Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regeneratedapm-spec-waiver: remote package content_hash is reserved for OpenAPM v0.2; this fixes platform materialization only