Skip to content

fix(git): pin core.eol=lf so text=auto package hashes match across platforms - #3599

Merged
Daniel Meppiel (danielmeppiel) merged 25 commits into
mainfrom
danielmeppiel-fix-3270-windows-text-auto-hash
Nov 12, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 25 commits into
mainfrom
danielmeppiel-fix-3270-windows-text-auto-hash

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

TL;DR

A dependency whose .gitattributes uses text / text=auto was checked out with CRLF on Windows (Git's core.eol defaults to native) and LF elsewhere, so content_hash differed and apm install --frozen failed across platforms. APM now pins core.eol=lf next to the existing core.autocrlf=false pin on every dependency materialization path, persists it in cache shards, and rematerializes older shards. Explicit eol= attributes, binary files, and committed CRLF blobs keep their repository-defined bytes.

Fixes #3270

Note

Builds on #3409 (autocrlf on the uncached fallback) and #3545 (core.symlinks pin), both merged. It follows the same owner pattern as #3545: utils/git_env owns the pin, and cache shards record it. Coordination note for Sheila Shahpari (@sheilagithub), who offered this follow-up on #2971: #3270 (comment)

Problem (WHY)

  • With * text=auto, Git writes LF-committed text using the line ending core.eol selects. core.eol defaults to native, which is CRLF on Windows. APM hides user and system config from some dependency children, so Windows gets CRLF even when the user never set anything.
  • The [BUG] Git-subpath dependency content_hash records CRLF bytes on Windows when the system gitconfig sets core.autocrlf=true; lockfile is not portable to Linux #2971 pin (-c core.autocrlf=false) does not override core.eol. _safe_git_args documented this gap: "This pin does not override core.eol or .gitattributes eol=crlf / text=auto requests."
  • Reproduced on main at cbd9f2b11: GitCache.get_checkout under host core.eol=crlf wrote CRLF SKILL.md for both full and sparse checkouts, and compute_package_hash diverged from the committed bytes.
  • Pre-fix CLI evidence: the new lifecycle test fails with the reported Content hash mismatch for apm-fixture-org/eol-skills/pkg ... re-downloading / Install failed.
  • [!] Cache shards written before this fix may already hold CRLF bytes and would be reused.

Why these matter: compute_package_hash hashes raw bytes and its docstring relies on "identical bytes at a pinned commit on every OS" (src/apm_cli/utils/content_hash.py). The accepted scope puts the repair in Git materialization, not in hashing (scope record).

Approach (WHAT)

# Fix
1 utils/git_env gains git_line_ending_pin_entries() / git_line_ending_pin_args() (core.autocrlf=false, core.eol=lf), replacing git_autocrlf_pin_args().
2 Every dependency checkout path carries the -c pins: GitCache clone, checkout and sparse operations (_safe_git_args), shared-bare materialize_from_bare, and the uncached fallback clone_git_worktree / checkout_git_worktree.
3 The network config snapshot (_materialize_git_config_snapshot) replaces host core.autocrlf / core.eol entries with the pins, the same way #3545 handles core.symlinks. This covers the snapshot-only children: the downloader's sparse fallback and git_file_transport.
4 Cache shards persist every pin. On a cache hit, _checkout_has_materialization_pins rejects shards without eol = lf and rematerializes them in place under the existing shard lock.
5 Architecture guard: git_cache.py / bare_cache.py must route through the line-ending owner, and core.eol literals are forbidden outside git_env.py.

Implementation (HOW)

  • src/apm_cli/utils/git_env.py -- new line-ending pin owner; snapshot materializer drops host core.symlinks / core.autocrlf / core.eol and appends the canonical pins; clone and checkout helpers use the combined pin args.
  • src/apm_cli/cache/git_cache.py -- _safe_git_args uses the owner; _checkout_materialization_pins() is the single list both persisted into shards and required on cache hits. The old autocrlf-only marker is folded into _checkout_has_materialization_pins.
  • src/apm_cli/deps/bare_cache.py -- checkout and sparse operations carry the line-ending pins as well as the symlink pin; the consumer config persists both entries.
  • scripts/architecture_linter/checks/transport_auth_platform.py, .apm/architecture/owners/transport-auth-platform.json -- required-substring needles plus a core.eol forbid scan under the existing transport-platform-git-child-environment guard (no new guard ID).
  • Docs -- consumer/install-packages.md, troubleshooting/common-errors.md, reference/lockfile-spec.md, packaged apm-usage/dependencies.md: line-ending guarantee, and recovery of a lock that recorded a pre-fix CRLF hash.

Diagrams

Legend: every dependency Git child gets the same line-ending decision from git_env, either as -c arguments or through the env snapshot. Boxed nodes are new in this PR.

flowchart LR
    owner["git_env.git_line_ending_pin_entries<br/>core.autocrlf=false + core.eol=lf"]:::new
    owner --> args["git_line_ending_pin_args (-c)"]:::new
    owner --> snap["_materialize_git_config_snapshot<br/>replaces host autocrlf/eol"]:::new
    args --> gc["GitCache clone / checkout / sparse<br/>(_safe_git_args)"]
    args --> bare["bare_cache.materialize_from_bare"]
    args --> fb["clone_git_worktree / checkout_git_worktree<br/>(uncached fallback)"]
    snap --> sp["downloader sparse fallback<br/>git_file_transport"]
    gc --> shard["shard .git/config records pins"]:::new
    shard -->|"hit without eol = lf"| remat["evict + rematerialize"]:::new
    classDef new stroke-width:3px
Loading

Trade-offs

  • Pin in materialization, not hashing. Normalizing in compute_package_hash would mask real CRLF content changes. The record excludes whole-tree hash normalization.
  • core.eol=lf rather than text=false/-text. core.eol changes only the line ending Git itself selects. Explicit eol=crlf, binary paths, and CRLF blobs in the index keep their bytes (covered by controls).
  • No automatic acceptance of old CRLF hashes. A lock written by pre-fix Windows APM still fails --frozen and its bytes are preserved. Recovery is a reviewed apm install --update, which the lifecycle test exercises (same resolved_commit, corrected hash).
  • Snapshot pin applies to all dependency network children. All snapshot consumers are dependency Git operations; user Git config files are never modified.
  • _checkout_pins_autocrlf_false removed. Its lenient boolean parsing (0 / no / off) was unnecessary, because APM itself always writes false.

Benefits

  1. A text=auto package locked on Windows replays --frozen on Linux/macOS and vice versa (4 lifecycle permutations).
  2. Same raw content_hash under system, global, GIT_CONFIG_COUNT, and GIT_CONFIG_PARAMETERS host core.eol=crlf, and under the Windows native default.
  3. Existing Windows caches heal on the next install without apm cache clean.
  4. The CRLF fixture repository's explicit eol=crlf, binary, and committed-CRLF files arrive byte-identical on every host.

Validation

Pre-fix (fix reverted in src/, tests kept)
tests/unit/cache/test_git_text_eol_pin.py: 17 failed, 5 passed
  (5 passing = host-default LF controls on macOS; on Windows they are the native-CRLF cases)
tests/integration/test_git_text_eol_lifecycle.py: 4 failed
  E  assert 'sha256:e31ee...3f32ac28211af' == 'sha256:02e7a...1e86d869cad61'
  E  [i] Content hash mismatch for apm-fixture-org/eol-skills/pkg -- re-downloading
  E  [x] Failed to install APM dependencies: Content hash mismatch for
With fix
Commit 34065c139 (rebased on origin/main 2ffc07c23):
uv run --extra dev pytest tests/unit/cache/test_git_text_eol_pin.py          -> 22 passed (2 load-timeouts re-run green)
APM_E2E_TESTS=1 pytest tests/integration/test_git_text_eol_lifecycle.py   -> 4 passed in 213.32s
pytest tests/unit/cache tests/integration/test_git_cache_hermetic.py tests/unit/deps/test_shared_clone_cache.py \
       tests/unit/deps/test_github_downloader_symlink_capability.py tests/test_github_downloader.py \
       tests/integration/test_architecture_owner_rule_mutations.py      -> 1113 passed, 2 skipped, 5 failed
   3 = git subprocess timeouts under host load 190+ (pass on re-run); 2 = mocked subprocess call
   count 4 -> 5 for the new core.eol config write (updated; test_git_cache_hermetic.py 58 passed)
bash scripts/lint-architecture-boundaries.sh                                -> rc=0
preflight T0 lint lane on the same commit: ruff, ruff-format, yaml-io, file-length, relpath,
   pylint R0801, lint-auth-signals, arch-boundaries, spec.mode-b, ascii guard -> all [+]
preflight T1 arch.contracts -> 188 passed; apm.self-check, apm.lock-snapshots, spec.orphans -> [+]

Scenario evidence

# Scenario (user promise) Principle(s) Test(s) proving it Type
1 A lock written on one host (host-default / crlf-env) installs --frozen on a fresh consumer with the opposite core.eol, cold and warm, for subdirectory and whole-repo packages Portability by manifest; Governed by policy tests/integration/test_git_text_eol_lifecycle.py::test_locked_text_auto_package_replays_across_host_eol e2e
2 A lock holding a pre-fix CRLF hash fails --frozen honestly, leaves manifest and lock bytes untouched, and a reviewed install --update re-records the intended hash at the same commit Secure by default; Governed by policy same test (frozen-stale-hash, reviewed-refresh steps) e2e
3 Older cache shards without the eol pin are rematerialized, not trusted Secure by default; DevX same test (frozen-legacy-shard)
tests/unit/cache/test_git_text_eol_pin.py::test_legacy_shard_without_eol_pin_is_rematerialized
e2e / integration
4 Cached full/sparse, shared-bare, and uncached fallback checkouts write the repository-defined bytes under system/global/env core.eol=crlf; explicit eol=crlf/eol=lf, binary, and committed-CRLF controls are preserved Portability by manifest tests/unit/cache/test_git_text_eol_pin.py (cached, bare, fallback, network-env tests) integration (real git)
5 Native Windows: no host config, core.eol=native Portability by manifest both modules are marked windows_compat, so they run in the PR Windows Compatibility Gate e2e on windows-latest

Note

Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate. The full preflight run was stopped during phase A (T0 lint and T1 contracts above were green); the full unit suite and lifecycle shards run in CI.

How to test

  • uv run --extra dev pytest tests/unit/cache/test_git_text_eol_pin.py -q
  • APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest tests/integration/test_git_text_eol_lifecycle.py -q
  • Revert src/ only and re-run both: the cross-host cases fail with Content hash mismatch.
  • Check the Windows Compatibility Gate job log for both modules passing on windows-latest.

Issue and approved scope

Issue: Fixes #3270

Human scope-approval comment: #3270 (comment) (apm-scope:v1, review contact Daniel Meppiel (@danielmeppiel))

Completes the issue. Native Windows evidence comes from the windows_compat lane on this PR.

Type of change

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

Testing

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

Spec conformance (OpenAPM v0.1)

Co-authored-by: Copilot [email protected]

…atforms

Under .gitattributes text / text=auto, Git writes the line ending that
core.eol selects. Its default (native) is CRLF on Windows, and the
#2971 core.autocrlf=false pin does not override it, so a package
committed with LF was materialized with CRLF on Windows, recorded a
different content_hash and failed `apm install --frozen` across
platforms.

- utils/git_env owns the line-ending pins (core.autocrlf=false and
  core.eol=lf) as -c args and in the network config snapshot, which
  replaces host autocrlf/eol entries like the core.symlinks pin.
- GitCache, shared-bare materialization and the uncached fallback
  clone/checkout carry the pins; cache shards record them and older
  shards without core.eol are rematerialized on hit.
- Explicit eol=lf/eol=crlf attributes, binary paths and committed CRLF
  blobs keep their repository-defined bytes.
- Real-git component tests and installed-CLI lifecycle tests run in the
  windows_compat lane; docs describe the guarantee and the reviewed
  `apm install --update` recovery for locks with pre-fix CRLF hashes.

Fixes #3270

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]>
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]>

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 documentation promises a same-pin hash refresh from apm install --update, but the command can reuse the old installation or re-resolve mutable refs, so it should instead reference the recovery steps.

1 open issue
What changed in this PR

This PR addresses #3270 by extending APM's Git checkout policy with core.eol=lf, preventing host-selected line endings from changing dependency hashes across platforms without altering raw-byte hashing.

Changes:

  • Centralizes line-ending pins and applies them to cached, shared-bare, fallback, and snapshot-based Git operations.
  • Records the pins in cache checkouts and rematerializes older entries that lack them.
  • Adds cross-platform regression coverage, architecture checks, and recovery documentation.
File Description
tests/​unit/​cache/​test_proxy_compat.py Updates cache-hit fixtures with the EOL pin.
tests/​unit/​cache/​test_git_text_eol_pin.py Tests checkout bytes, host overrides, and legacy-cache repair.
tests/​unit/​cache/​test_git_env.py Verifies both line-ending pins precede clone and checkout.
tests/​unit/​cache/​test_git_cache.py Updates valid-cache fixtures for the new pin requirement.
tests/​unit/​cache/​test_git_cache_symlinks.py Checks that cache entries require all materialization pins.
tests/​unit/​cache/​test_git_cache_recency.py Updates the sparse-validation cache fixture.
tests/​unit/​cache/​test_git_cache_hardening.py Updates the logging test's cache fixture.
tests/​unit/​cache/​test_git_cache_autocrlf.py Uses the consolidated materialization-pin validator.
tests/​integration/​test_git_text_eol_lifecycle.py Adds CLI coverage for cross-host replay, cache repair, and recovery.
tests/​integration/​test_git_cache_hermetic.py Updates cache fixtures and expected config-write counts.
src/​apm_cli/​utils/​git_env.py Owns canonical line-ending pins and applies them to Git environments.
src/​apm_cli/​deps/​bare_cache.py Applies and persists line-ending pins for shared-bare checkouts.
src/​apm_cli/​cache/​git_cache.py Applies pins and requires them when reusing cache entries.
scripts/​architecture_linter/​checks/​transport_auth_platform.py Guards centralized ownership of line-ending configuration.
packages/​apm-guide/​.apm/​skills/​apm-usage/​dependencies.md Documents checkout line endings and legacy-hash recovery.
docs/​src/​content/​docs/​troubleshooting/​common-errors.md Explains EOL-related hash mismatches and cache repair.
docs/​src/​content/​docs/​reference/​lockfile-spec.md Updates the materialized-byte contract for content_hash.
docs/​src/​content/​docs/​consumer/​install-packages.md Describes cross-platform behavior and links recovery guidance.
CHANGELOG.md Records the portability fix and recovery caveat.
.apm/​architecture/​owners/​transport-auth-platform.json Registers line-ending pins under the existing Git environment owner.

Review effort: Balanced

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Pins core.eol=lf through a canonical owner so text=auto packages hash identically on every platform, closing the last cross-OS determinism gap in APM's integrity model.

panel-mode=full; personas=python-architect,test-coverage-expert,performance-expert,supply-chain-security-expert,doc-writer,auth-expert(adhoc: network snapshot shares auth fences and #2999 TLS config),apm-ceo

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

The panel converged cleanly: six personas, zero blocking-severity findings, no dissent on the core fix. The integrity model is sound: frozen locks fail closed on stale hashes, rematerialization is shard-locked, and user Git config is never touched. The strongest signal is a three-source convergence (Copilot inline, supply-chain-security, doc-writer) on misleading --update recovery guidance in dependencies.md and the CHANGELOG: install/phases/integrate.py skips re-download when the installed copy's HEAD already matches the locked SHA, so a plain --update does not by itself re-record a stale CRLF hash. The architecture discipline is well applied: git_line_ending_pin_entries is the single owner for every pin injection point, and the linter forbids core.eol literals outside it. Those new linter checks still need mutation-test teeth.

The core.autocrlf forbid scan plus rerouting codex_plugins/snapshot.py is correctly kept out of this PR: that path builds a local Codex native transport repo from already-admitted bytes with hash-object --no-filters, which is not upstream dependency materialization and is outside the #3270 scope. The performance findings (extra git config spawns per bare consumer, one-time rematerialization of every pre-existing shard on upgrade) are real but bounded, with proportionate in-PR fixes.

Dissent. None of substance. Architect and supply-chain both note the missing core.autocrlf forbid scan, at recommended/nit, and accept it as separate scope.

Aligned with: Portable by manifest -- the same manifest and lock now produce identical package bytes on Windows, Linux and macOS regardless of host Git config; Secure by default -- frozen fails closed on stale hashes and legacy shards rematerialize under the shard lock; Governed by policy -- linter needles and a core.eol forbid scan enforce the owner; Pragmatic as npm -- legacy cached shards heal on first touch without a manual cache clear.

Panel summary

Persona B R N Takeaway
Python Architect 0 1 1 Canonical single-owner discipline is well applied; one forbid-scan gap for core.autocrlf leaves the guardrail incomplete.
Test Coverage Expert 0 1 0 Determinism fix is exhaustively regression-trapped; the new core.eol forbid scan and pin needles have no mutation-test teeth.
Performance Expert 0 2 1 Correctness sound; one extra git-config spawn per bare consumer and a one-time full-shard rematerialization on upgrade.
Supply Chain Security Expert 0 1 1 Integrity model sound; recovery wording could lead users to advance mutable refs without review.
Doc Writer 0 1 1 Two pages overclaim what apm install --update fixes; the pin mechanism is restated in three places.
Auth Expert 0 0 0 Auth-neutral: pinned_keys filters only core.* keys; auth fence, helper suppression and #2999 TLS entries unchanged.

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

Top 5 follow-ups

  1. [Doc Writer + Supply Chain Security Expert] Fix --update recovery wording in dependencies.md and the CHANGELOG to point at the common-errors.md recovery steps instead of implying a plain --update re-records the hash at the same pin. -- Three-source convergence; integrate.py skips re-download when the installed HEAD matches the locked SHA.
  2. [Test Coverage Expert] Add architecture-rule mutation tests proving the core.eol forbid scan and the git_cache / bare_cache line-ending needles fire. -- Without them a refactor could silently drop the guardrail.
  3. [Performance Expert] Persist pins in materialize_from_bare via git clone --config instead of extra git config spawns; add elapsed-ms to the rematerialize log and note the first post-upgrade cost in docs. -- Non-amortized per-consumer path; one-time migration cost deserves visibility.
  4. [Python Architect] Add a one-line comment in bare_cache.py explaining why only some pins are persisted there. -- Prevents a future contributor from "fixing" an intentional asymmetry.
  5. [Python Architect + Supply Chain Security Expert] Post-merge: track a core.autocrlf forbid scan and codex_plugins/snapshot.py owner rerouting under Codex native transport scope. -- Completes the guardrail but changes Codex transport semantics, outside [BUG] Package content_hash differs on Windows when the dependency repository sets text=auto in .gitattributes #3270.

Architecture

classDiagram
    direction LR
    class git_env {
        <<CanonicalOwner>>
        +git_line_ending_pin_entries() tuple
        +git_line_ending_pin_args() tuple
        +git_symlink_pin_entry() tuple
        +git_symlink_pin_args() tuple
        +_materialize_git_config_snapshot()
        +clone_git_worktree()
        +checkout_git_worktree()
    }
    class git_cache_module {
        <<Module>>
        +_safe_git_args() list
        +_checkout_materialization_pins() tuple
        +_checkout_has_materialization_pins() bool
    }
    class bare_cache_module {
        <<Module>>
        +materialize_from_bare()
    }
    class transport_auth_platform {
        <<StaticGuard>>
        +_check_git_child_environment()
    }
    git_cache_module ..> git_env : delegates pins
    bare_cache_module ..> git_env : delegates pins
    transport_auth_platform ..> git_env : forbid scan exempt
    transport_auth_platform ..> git_cache_module : needle check
    transport_auth_platform ..> bare_cache_module : needle check
    class git_env:::touched
    class git_cache_module:::touched
    class bare_cache_module:::touched
    class transport_auth_platform:::touched
    classDef touched fill:#fff3b0,stroke:#d47600
Loading
flowchart TD
    A["apm install / apm lock"] --> B{"Materialization path"}
    B -->|cached| C["GitCache.get_checkout"]
    B -->|bare| D["materialize_from_bare"]
    B -->|uncached fallback| E["clone_git_worktree"]
    C --> F{"shard records all pins?"}
    F -->|yes| G["reuse shard"]
    F -->|"no: missing eol=lf or symlinks"| H["rematerialize under shard lock"]
    H --> I["clone + checkout with -c pins"]
    D --> L["clone --no-checkout, persist pins, checkout with -c pins"]
    E --> O["clone + checkout with -c pins"]
    C -->|snapshot children| Q["_materialize_git_config_snapshot drops host autocrlf/eol/symlinks, appends pins"]
Loading

Recommendation

The core determinism fix is sound and the panel is unanimous. The merge worker's fold plan covers every in-scope finding; verify the dependencies.md / CHANGELOG --update wording fix (highest signal) and the architecture mutation tests land before shipping. The deferred core.autocrlf forbid scan plus Codex snapshot rerouting should be tracked in a follow-up issue and does not need to hold this PR.


Full per-persona findings

Python Architect

  • [recommended] Missing core.autocrlf forbid scan leaves the line-ending dual guardrail incomplete at scripts/architecture_linter/checks/transport_auth_platform.py
    A literal core.autocrlf=false exists at codex_plugins/snapshot.py:62, outside the canonical owner. Merge worker: deferred (Codex native transport, outside [BUG] Package content_hash differs on Windows when the dependency repository sets text=auto in .gitattributes #3270 scope).
  • [nit] bare_cache.py persists only the line-ending pins; add a one-line comment for the intentional asymmetry at src/apm_cli/deps/bare_cache.py:678

Test Coverage Expert

  • [recommended] New core.eol forbid scan and git_line_ending_pin_* needle checks have no mutation case proving they fire at tests/integration/test_architecture_owner_rule_mutations.py
    Proof (missing): tests/integration/test_architecture_owner_rule_mutations.py -- proves: a future PR cannot bypass or regress the core.eol=lf pin without a test failing.

Performance Expert

  • [recommended] materialize_from_bare spawns two git config subprocesses per consumer instead of one, on a non-amortized path at src/apm_cli/deps/bare_cache.py:679
  • [recommended] The stricter pin check rematerializes every pre-existing GitCache shard on first touch after upgrade; the cost is unobservable at src/apm_cli/cache/git_cache.py:136
  • [nit] No spawn-count assertion for the config phase of materialize_from_bare

Supply Chain Security Expert

  • [recommended] dependencies.md recovery guidance ("re-records the hash at the same pin") can mislead users into silently advancing mutable refs at packages/apm-guide/.apm/skills/apm-usage/dependencies.md:97
  • [nit] No core.autocrlf forbid scan (same as architect)

Doc Writer

  • [recommended] dependencies.md and CHANGELOG claim apm install --update re-records the hash at the same pin; the code only does that when the installed copy is gone at packages/apm-guide/.apm/skills/apm-usage/dependencies.md:96
  • [nit] The pin mechanism is restated near-verbatim in install-packages.md, lockfile-spec.md and dependencies.md at docs/src/content/docs/consumer/install-packages.md:250

Auth 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.

A plain `apm install --update` does not re-record a stale CRLF hash when
the installed copy still matches the locked SHA (install/phases/integrate.py
skips the re-download), and it re-resolves mutable refs. The packaged usage
guide and the CHANGELOG promised a same-pin in-place refresh; both now point
at the `Content hash mismatch` recovery steps, which require a fresh
consumer or removal of the installed copy and review of the SHA and hash
diff. install-packages.md links the lockfile content_hash definition
instead of restating it, and notes that older cached checkouts are
re-created on their next use.

Addresses Copilot inline on packages/apm-guide/.apm/skills/apm-usage/
dependencies.md:97 and panel follow-ups (doc-writer, supply-chain,
performance).

Co-authored-by: Copilot App <[email protected]>
materialize_from_bare runs once per consumer and is not amortized across
installs. Writing the two line-ending pins with one `git config` spawn
each added a process per dependency on every install (Windows pays the
most per spawn). `git clone --config` records the same values in the new
repository's config with no extra process; the checkout still carries
the `-c` pins that outrank env snapshots. A comment notes why the symlink
pin travels only as `-c` there. The rematerialization of a cache shard
that lacks the pins now logs its elapsed time, so the one-time cost after
upgrading is observable.

The bare regression test asserts the consumer config records both pins;
mutation-break: dropping the `--config` args fails it.

Addresses panel follow-ups (performance-expert, python-architect).

Co-authored-by: Copilot App <[email protected]>
The PR extends transport-platform-git-child-environment with needles for
git_line_ending_pin_* in git_env.py, git_cache.py and bare_cache.py and a
forbid scan for core.eol literals outside git_env.py, but no test proved
those checks fire. Three source-override mutations now do: a core.eol
literal in bare_cache.py, git_cache.py bypassing git_line_ending_pin_args,
and the config snapshot no longer appending the line-ending pins. Each must
report a violation with the matching message.

Mutation-break: restoring the pre-PR linter check makes all three fail.

Addresses panel follow-up (test-coverage-expert).

Co-authored-by: Copilot App <[email protected]>
A mocked materialize_from_bare must carry the line-ending pins as clone
--config arguments and spawn no separate `git config core.*` process, so
a later change that reintroduces per-key spawns on this non-amortized
path is a reviewed decision. Mutation-break: the previous per-key loop
fails it.

Addresses panel follow-up (performance-expert nit).

Co-authored-by: Copilot App <[email protected]>
Resolves conflicts with #3603 (links materialized from Git objects) by
keeping both intents: core.symlinks=false plus the
apm.linkMaterialization marker from #3603, and the core.autocrlf=false +
core.eol=lf line-ending pins from #3270. Cache shards now require all
four entries; the snapshot materializer replaces host symlink and
line-ending entries; the git-child-environment needles cover both the
link materializer and the line-ending owner.

Co-authored-by: Copilot App <[email protected]>
#3603 resolves a tracked link whose target a sparse cone left out with
`git cat-file --filters`, which applies checkout conversion. Callers such
as the downloader's sparse fallback and git_file_transport pass no `-c`
pins, so under a host `core.eol=crlf` (or the Windows native default) a
link to a `text=auto` file was written with CRLF and its content_hash
diverged across platforms, the #3270 failure on a new materialization
path. The resolver now appends git_line_ending_pin_args to its own Git
calls, so every caller gets the committed LF bytes.

Regression: test_link_target_outside_sparse_cone_ignores_host_eol (global
and env-count host core.eol=crlf; host-default control). Mutation-break:
without the pin both crlf cases fail.

Co-authored-by: Copilot App <[email protected]>
After #3603 the shard checkout runs materialize_tracked_symlinks, which
parses bytes; TestCreateCheckout's text-mode subprocess mocks fed it str
and three cases failed on main as well, alongside a stale config-call
count. The class fixture now stubs the resolver (covered by real-git
tests) and the counts derive from _checkout_materialization_pins, so
the line-ending and link pins are both accounted for. The bare spawn
test returns bytes when the caller did not ask for text.

Co-authored-by: Copilot App <[email protected]>
#3603's sparse-symlink rule required _LINK_MATERIALIZATION_PIN three
times in git_cache.py (definition, persisted pins, cache-hit check).
With the #3270 line-ending pins both the persisted list and the cache-hit
check route through the single _checkout_materialization_pins(), so the
marker now appears in its definition and that list, and the rule also
requires the helper at its definition, persistence and validation sites.
Dropping the marker from the list still reports a violation.

Co-authored-by: Copilot App <[email protected]>
GitCache wrote each materialization pin with its own `git config` spawn
after cloning a shard; with the line-ending and link pins that became
four extra processes per new or rematerialized shard. The pins now ride
on the existing clone as `-c key=value`, which git clone records in the
new repository, as bare_cache already does. The checkout keeps the
`-c` pins from _safe_git_args. Hermetic call counts drop to clone plus
checkout.

Mutation-break: dropping the pins from the clone fails
test_cached_checkout_ignores_host_eol (shard no longer recognized).

Addresses delta-panel follow-up (performance-expert).

Co-authored-by: Copilot App <[email protected]>
The sparse-symlink rule now requires git_cache.py to route persisted and
required pins through _checkout_materialization_pins(). A fourth
source-override case inlines the pin tuple at the persistence site and
expects the rule to report it. Mutation-break: main's count-only rule
misses it.

Addresses delta-panel follow-up (test-coverage-expert).

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

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Pins core.eol=lf across every Git materialization path so text=auto packages hash identically on Windows, Linux and macOS, and closes a live #3603 link-resolver variant of the same bug class.

panel-mode=delta; personas=python-architect,test-coverage-expert,supply-chain-security-expert,performance-expert,doc-writer,auth-expert,apm-ceo (two delta rounds)

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

All six panelists converged across two delta rounds with no remaining in-scope findings. Every follow-up from the first advisory was folded into this PR. The material delta since then comes from the merge with #3603 (links materialized from Git objects). First, #3603 resolves out-of-cone link targets with git cat-file --filters, which applies checkout line-ending conversion. Callers such as the downloader's sparse fallback and git_file_transport pass no -c pins, so a host core.eol=crlf leaked CRLF into those link targets: the #3270 failure on a new path. _CheckoutBytes now appends git_line_ending_pin_args, with a regression test that fails without it. Second, the merge resolution keeps both intents. Shards persist and require one list, _checkout_materialization_pins() (core.autocrlf=false, core.eol=lf, core.symlinks=false, apm.linkMaterialization=git-objects), and the linter needles cover both owners.

The round-1 performance finding (four post-clone git config spawns per shard) and the test-coverage finding (the adjusted sparse-symlink rule count had no mutation test) were folded. Shard pins now ride on the clone as -c key=value, and a fourth architecture mutation case covers the bypass. Round 2 confirmed that clone -c persists the pins after init probes, that cache-hit validation is sound, that shard trust is unchanged, and that a real-git test plus the architecture case cover the surface.

Aligned with: Portable by manifest -- host core.eol/core.autocrlf no longer change materialized bytes for the same pinned commit; Secure by default -- pins apply through the canonical owner without touching user Git config, and frozen locks still fail closed on stale hashes; Governed by policy -- forbid scans and needles enforce pin ownership, with four mutation-break tests proving they have teeth; Multi harness multi host -- real-git and installed-CLI lifecycle tests run on the windows_compat lane.

Panel summary

Persona B R N Takeaway
Python Architect 0 0 0 Delta strengthens the canonical owner; clone -c persists pins after init probes; cache-hit validation sound.
Test Coverage Expert 0 0 0 Shard-pin persistence covered by a real-git test; the new architecture case closes the sparse-rule gap (round-1 item folded).
Supply Chain Security Expert 0 0 0 Delta closes a real integrity gap (host core.eol leak on out-of-cone link targets); pin persistence on clone is trust-equivalent.
Performance Expert 0 0 0 Prior findings resolved: pins ride on the single clone for both bare consumers and cache shards.
Doc Writer 0 0 0 Recovery wording, merged symlink and line-ending bullets, and the CHANGELOG entry are accurate and consistent.
Auth Expert 0 0 0 Merged git_env.py and the git_sparse pin are auth-neutral; no credential, header or TLS change.

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

Top 1 follow-ups

  1. [Python Architect] Add a core.autocrlf forbid scan parallel to the core.eol scan and route codex_plugins/snapshot.py through the canonical line-ending owner. -- Completes the guardrail; kept out of this PR because the Codex snapshot is Codex native transport (hash-object --no-filters), outside [BUG] Package content_hash differs on Windows when the dependency repository sets text=auto in .gitattributes #3270 scope.

Recommendation

Every in-scope finding from the original and delta panels has been folded and verified by the returning panelists. The cross-PR link-resolver fix closes an integrity gap that would otherwise have shipped with #3603. Track the core.autocrlf forbid scan plus Codex snapshot rerouting as a separate issue.

Folded in this run

  • (copilot) dependencies.md promised a same-pin in-place --update refresh -- resolved in 0b1a634.
  • (panel) CHANGELOG and docs recovery wording, first post-upgrade rematerialization note -- resolved in 0b1a634.
  • (panel) Bare consumer pins via clone --config, symlink-pin comment, rematerialization elapsed-ms log -- resolved in a62d5d7.
  • (panel) Architecture tests proving the line-ending needles and core.eol forbid scan fire -- resolved in b89e649.
  • (panel) Spawn trap for the bare consumer path -- resolved in a97326f.
  • (panel) Link resolver applies the line-ending pins to cat-file --filters (cross-PR with fix(git): materialize package links from Git objects on every host #3603) -- resolved in a92f0ca.
  • (panel) Hermetic checkout mocks kept off the link resolver (also failing on main) -- resolved in 589bb90.
  • (panel) Sparse-symlink rule counts the marker through the shared pin list -- resolved in ed3747c.
  • (panel) Shard pins ride on the clone instead of config spawns -- resolved in 9c997dd.
  • (panel) Architecture case for the shard pin-list count guard -- resolved in 80183ed.

Copilot signals reviewed

  • packages/apm-guide/.apm/skills/apm-usage/dependencies.md:97 -- LEGIT: --update can reuse a matching installed copy and re-resolve mutable refs, so the same-pin promise was inaccurate (resolved in 0b1a634).

Deferred (out-of-scope follow-ups)

Regression-trap evidence (mutation-break gate)

  • test_bare_materialization_ignores_host_eol -- deleted the --config pins from the bare clone; test FAILED as expected; guard restored.
  • test_bare_materialization_pins_line_endings_without_extra_spawns -- restored the per-key git config loop; test FAILED as expected; guard restored.
  • test_line_ending_pin_guard_rejects_owner_bypass -- restored the pre-PR linter check / main's sparse rule; cases FAILED as expected; guard restored.
  • test_link_target_outside_sparse_cone_ignores_host_eol -- removed the resolver's line-ending pin; crlf cases FAILED as expected; guard restored.
  • test_cached_checkout_ignores_host_eol -- removed the pins from the shard clone; test FAILED as expected; guard restored.
  • test_bare_materialization_ignores_host_eol[full-system] -- removed core.eol=lf from the owner; test FAILED as expected; guard restored.

Lint contract

The full CI lint mirror (ruff check, ruff format --check, YAML I/O, file length, relpath, pylint R0801, lint-auth-signals, lint-architecture-boundaries) exits 0 on the merged head.


Full per-persona findings

Python Architect

No findings.

Test Coverage Expert

No findings (round 1 item on the sparse-rule count mutation test folded in 80183ed).

Supply Chain Security Expert

No findings.

Performance Expert

No findings (round 1 item on shard config spawns folded in 9c997dd).

Doc Writer

No findings.

Auth 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.

Avoids landing-order conflicts with other queued PRs.

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

Copy link
Copy Markdown
Collaborator Author

Lane L: main merged for landing

  • Pre-merge head: a8356122b1aab450f6fc425ed38fb5ff84047279
  • Merged origin/main c2c2e0d72c8e8c88f143099c73f40720b6529a4e (clean merge; GitHub reported DIRTY only on CHANGELOG.md, which this repo merges with merge=union).
  • New head: 9f3a21c6e95ad7b168f479bd10fd098841079fd8
  • CHANGELOG: moved 1 bullet(s) in '### Fixed' after entry Add support for GitHub EU #6 of 18, so queued PRs no longer collide at the section head while landing serially.
  • Lint: ruff check + ruff format --check silent at the new head; CI green at the new head.
  • Owner-touch report regenerated at the new head; every recorded functional test was re-run at that exact head and passed (one process at a time, no xdist).
  • Push: git push https://github.com/microsoft/apm.git HEAD:refs/heads/danielmeppiel-fix-3270-windows-text-auto-hash (plain push, no force).

This comment was generated by an AI agent (Lane L landing desk) on behalf of Daniel Meppiel (@danielmeppiel).

Resolve tests/integration/test_architecture_owner_rule_mutations.py by
keeping main's orphan-selection mutation tests (#2926) and this PR's
line-ending pin guard test (#3270).

Co-authored-by: Copilot App <[email protected]>
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]>
Resolve docs/src/content/docs/reference/lockfile-spec.md content_hash row:
keep this PR's core.autocrlf/core.eol pin wording (#3270) and main's
carried_licenses exclusion (#3646).

Co-authored-by: Copilot App <[email protected]>
Avoids landing-order conflicts with other queued PRs.

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

Copy link
Copy Markdown
Collaborator Author

Lane L: main merged for landing

  • Pre-merge head: 4c194e876ff210c9be6f854ecb30452fbabeb9f3
  • Merged origin/main d4aa58883e190613fd9cf255d3afe0d04d29bc90 (clean merge; GitHub reported DIRTY only on CHANGELOG.md, which this repo merges with merge=union).
  • New head: ca4e6f99ad22750509fb08550a4b9765e91163be
  • CHANGELOG: moved 1 bullet(s) in '### Fixed' after entry Add support for GitHub EU #6 of 26, so queued PRs no longer collide at the section head while landing serially.
  • Lint: ruff check + ruff format --check silent at the new head; CI green at the new head.
  • Owner-touch report regenerated at the new head; every recorded functional test was re-run at that exact head and passed (one process at a time, no xdist).
  • Push: git push https://github.com/microsoft/apm.git HEAD:refs/heads/danielmeppiel-fix-3270-windows-text-auto-hash (plain push, no force).

This comment was generated by an AI agent (Lane L landing desk) on behalf of Daniel Meppiel (@danielmeppiel).

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit edcf568 into main Nov 12, 2026
26 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-3270-windows-text-auto-hash branch November 12, 2026 20:34
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
Clean merge of #3599, #3647, #3650, #2933; no lockfile or autopilot
package conflicts.

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 git_cache.py, bare_cache.py and git_sparse.py by taking main's
line-ending pin rewrite (#3599) and re-applying this PR's mechanical
text=True -> run_git_text rewrite plus the SubprocessError cleanup and
probe handlers, so GitOutputDecodeError still removes staged trees and
counts as an incomplete sparse probe.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
…3673)

* fix(git): check out out-of-cone link targets with Git's own checkout

A link whose target a sparse checkout left out was read with
`git --attr-source=HEAD cat-file --filters`, falling back to plain
`cat-file --filters` when that call failed. cat-file reads no index, so
in a sparse checkout the fallback silently skipped the target's
.gitattributes and wrote e.g. an eol=crlf file with LF. That is the
post-merge red on macOS x86_64 since 90e76bf: the path: transport link
to shared/notes.crlf returned LF while the checked-out target was CRLF.

Out-of-worktree targets are now written by `checkout-index` into a
throwaway work tree from a throwaway full index (`read-tree HEAD`), in
one batch per materialization. Attributes come from that index exactly
as `git checkout` reads them, on every Git version, with no
version-gated option and no silent fallback. In-worktree targets still
read the bytes Git already wrote. The line-ending pins (#3599) still
apply; the content_hash domain is unchanged.

Regression: test_out_of_sparse_eol_target_keeps_checkout_bytes_without_attr_source
emulates a Git that rejects --attr-source; it fails on main with the CI
assertion and passes here. Also re-points two #3603 downloader tests at
the persistent-checkout seam that #3640 changed underneath them.

Refs #3457

apm-spec-waiver: Git checkout byte fidelity for link targets; no OpenAPM statement or hash-domain change.

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

* docs(changelog): reference #3673 on the link materialization entry

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

* fix(links): report an unwritten out-of-cone target with the diagnostic

A target that checkout-index leaves unwritten raised a bare
FileNotFoundError; it now raises the 'did not check out ... as a regular
file' diagnostic before any link is written. Panel follow-up
(test-coverage-expert).

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

* fix(links): rebuild shards from the cat-file materializer; honor APM_TEMP_DIR

Review follow-ups (Copilot):
- The shard marker is versioned to apm.linkMaterialization=git-objects-checkout.
  A sparse shard pinned by the first Git-object materializer could hold
  an out-of-cone eol=crlf target with LF and would otherwise be served
  as is; it is now rematerialized on its next cache hit. Regression:
  test_cache_hit_rematerializes_shard_without_link_materialization[pre-checkout-marker]
  (fails if the marker value is reverted).
- The throwaway checkout scratch directory uses get_apm_temp_dir(), like
  the downloader's own scratch space, so APM_TEMP_DIR / temp_dir keep
  working on hosts with a restricted system temp directory.

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

* chore: restore uv.lock swept in by a local uv rewrite

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

---------

Co-authored-by: danielmeppiel <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Andy (AndyElessar) added a commit to AndyElessar/SourceGen that referenced this pull request Nov 17, 2026
apm 0.36.0 checks packages out with LF (microsoft/apm#3599), so the
TUnit skill's content hash, recorded by apm 0.35.1 over a CRLF checkout
on Windows, no longer matched and apm install failed. Upstream is
unchanged (v1.85.0 at 399f07cf, same SKILL.md blob).

apm install --update records the LF hash and now also deploys the
skill's upstream MIT LICENSE. apm writes the skill with LF, so the
.gitattributes exceptions that kept its copies at the platform's line
endings are removed.

Co-Authored-By: Claude Opus 5.5 <[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] Package content_hash differs on Windows when the dependency repository sets text=auto in .gitattributes

2 participants