ISSUE DESCRIPTION [BUG] apm install fail second time with Content hash mismatch Describe…
- User
ISSUE DESCRIPTION
[BUG] apm install fail second time with Content hash mismatch Describe the bug I can install my repo (see apm.yml further down) via
apm install <org>/<repo>/package/<project>just fine (kinda, see the logs, it looks wonky but maybe it's just a new feature) but the second time I runapm installit will fail consistently withContent hash mismatch.To Reproduce Steps to reproduce the behavior:
- apm install <repo>
- apm install
Expected behavior A clear and concise description of what you expected to happen.
Environment (please complete the following information):
- OS: Windows
- APM Version: 0.16.0
Logs
> apm install --update --force [>] Installing dependencies from apm.yml... [>] Resolving github-copilot-agent-skills-testing... [i] Targets: copilot (source: apm.yml) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/<project> #default @d479f42e |-- (files unchanged) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/myorg #default @d479f42e |-- (files unchanged) [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/instructions/testing.instructions.md #main |-- 1 instruction(s) integrated -> .github/instructions/ Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/run-coverage #default @d479f42e |-- (files unchanged) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/update-from-template #default @d479f42e |-- (files unchanged) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/csharp #default @d479f42e |-- (files unchanged) [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/instructions/code-style.instructions.md #main |-- 1 instruction(s) integrated -> .github/instructions/ [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/instructions/protect-prefixed-agent-files.instructions.md #main |-- 1 instruction(s) integrated -> .github/instructions/ Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/git-conventions #default @d479f42e |-- (files unchanged) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/update-nuget-packages #default @d479f42e |-- (files unchanged) Partial clone (--filter=blob:none) failed for https://dev.azure.com/<org>/tools; retrying with full bare clone. Server may not support filter v2. [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/write-tests #default @d479f42e |-- (files unchanged) cache-pin: remote dep '<org>/tools/github-copilot-agent-skills' has no resolved_commit; drift cannot verify its cache freshness. Re-run 'apm install' with a pinned ref (commit, tag, or specific branch HEAD). cache-pin: remote dep '<org>/tools/github-copilot-agent-skills' has no resolved_commit; drift cannot verify its cache freshness. Re-run 'apm install' with a pinned ref (commit, tag, or specific branch HEAD). cache-pin: remote dep '<org>/tools/github-copilot-agent-skills' has no resolved_commit; drift cannot verify its cache freshness. Re-run 'apm install' with a pinned ref (commit, tag, or specific branch HEAD). [i] Trusting direct dependency MCP 'MyOrg.CLI' from '<project>-skills' [i] Trusting direct dependency MCP 'NuGet' from '<project>-skills' [i] Trusting direct dependency MCP 'Github' from '<project>-skills' [i] Trusting direct dependency MCP 'MyOrg.CLI' from 'skills' [i] Trusting direct dependency MCP 'NuGet' from 'skills' +- MCP Servers (3) | [+] MyOrg.CLI (already configured) | [+] NuGet (already configured) | [+] Github (already configured) [*] All servers up to date [!] 11 dependencies unpinned: <org>/tools/github-copilot-agent-skills -- add #tag or #sha to prevent drift [!] Transitive package 'csharp-skills' declares self-defined MCP server 'NuGet' (registry: false). Re-declare it in your apm.yml or use --trust-transitive-mcp. [!] Transitive package 'csharp-skills' declares self-defined MCP server 'Github' (registry: false). Re-declare it in your apm.yml or use --trust-transitive-mcp. [*] Installed 11 APM dependencies in 87.9s. > apm install [>] Installing dependencies from apm.yml... [i] Targets: copilot (source: apm.yml) [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/<project> @d479f42e (cached) |-- (files unchanged) [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/myorg @d479f42e (cached) |-- (files unchanged) [+] dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/instructions/testing.instructions.md #main Content hash mismatch for <org>/tools/github-copilot-agent-skills/.apm/instructions/testing.instructions.md: expected sha256:2227579674ab30b5b59f703ac152fa74ac2912d724d04aeffbf3914cac2e6b88, got sha256:b82d09e4e7879eeb0e90cc7dfeebdac45de6ebdbcdda7824b40438196692f8f8. The downloaded content differs from the lockfile record. This may indicate a supply-chain attack. Use 'apm install --update' to accept new content and update the lockfile. [!] Install interrupted after 7.7s.Additional context apm.yml
name: <project>-skills version: 1.0.0 description: '<Project> skills and agent for GitHub Copilot.' author: Oskar Klintrot target: vscode dependencies: apm: - dev.azure.com/<org>/tools/github-copilot-agent-skills/packages/csharp - dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/skills/run-coverage - dev.azure.com/<org>/tools/github-copilot-agent-skills/.apm/instructions/testing.instructions.md mcp: - name: NuGet registry: false transport: stdio command: dnx args: - NuGet.Mcp.Server - --source - https://api.nuget.org/v3/index.json - --yesADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /apm, current file: none) bash-$
- Assistant
I’ll first map the repository and locate the install, lockfile hash, and remote-file download paths. Then I’ll reproduce the mismatch with the smallest relevant existing test or a temporary local fixture before changing code.
- Assistant
The mismatch is enforced in the integration phase, while the report specifically involves a Git-hosted single-file dependency and an unpinned
#mainlock entry. I’ll inspect that phase, the hashing implementation, lockfile update logic, and tests around single-file dependencies to determine whether first and second installs hash different representations (for example, raw bytes versus an installed tree). - Assistant
Hash generation consistently calls
compute_package_hash(install_path), so the key question is whatinstall_pathcontains after acquisition. I’ll compare cached versus fresh source strategies and inspect ADO virtual-file extraction tests and downloader code, especially path naming and metadata files that may exist only after a full clone. - Assistant
Virtual files are materialized as directories, so package-tree hashing should work if materialization is stable. I’ll now inspect the exact virtual-file implementation and the fresh source’s pre/post-download hash timing. The reported hashes can also be decoded by recreating candidate trees to identify whether
apm.ymlor another generated file is the difference. - Assistant
The prior combined output interleaved large sections, so I’ll isolate the two functions with line numbers. I also need to determine how branch/default refs are handled: the log shows the file as
#mainbut no resolved commit, which likely forces a redownload on every run and exposes any nondeterminism in generated virtual-package metadata. - Assistant
The virtual downloader itself is deterministic apart from platform newline translation, which remains stable between runs. A more likely cause is that integration mutates the cached source package after its hash is captured: fresh acquisition records
package_hashesbeforerun_integration_templateintegrates primitives, while lockfile writing happens later. I’ll trace integrators for source-file mutation (especially link resolution/frontmatter normalization) and compare hash capture timing across the template. - Assistant
Integration only writes destination files, not the package cache, and
.apm-pinis explicitly excluded, so post-hash mutation is not the culprit. The report’s first install used--update --force, and its second run necessarily redownloads the ADO virtual file because ADO SHA resolution returnsNone. I’ll inspect raw-file transport and reference replay: if the first run downloadsmainbut lockfile replay passes a synthetic value such as"locked"or"cached"as the ref, ADO can return different content while still succeeding. - Assistant
Reference replay is correct: with no SHA it reuses the manifest’s implicit
main. The symptom closely resembles an excluded-metadata regression, so I’ll inspect recent history/blame for content hashing and cache-pin writes, plus all files created insideapm_modulesafter hash capture. This should reveal another volatile root file not currently excluded. - Assistant
The unresolved-commit condition is central: the installer explicitly says it cannot verify cache freshness, then redownloads the moving branch, but still treats any byte change as a supply-chain attack. Before deciding to relax that check, I’ll inspect ADO’s API parameters and the branch-heal logic to see whether ADO refs are resolved incorrectly or whether unresolved refs are already intended to be treated as mutable.
- Assistant
A concrete root cause is now visible: single-file dependencies only use GitHub’s commits API for SHA resolution; ADO is deliberately left with
resolved_commit=None. Every reinstall therefore fetches a mutable branch instead of the exact bytes represented by the lockfile, and the generic hash guard can reject that unavoidable drift. The correct fix is not to weaken integrity checking, but to resolve non-GitHub virtual-file refs through the existing Git backend (ls-remote) and download the file at that SHA. I’ll verify resolver behavior/auth support and then implement the fallback narrowly for virtual files. - Assistant
The generic
resolve()fallback would clone the repository, which fixes correctness but defeats single-file downloads. I’ll use the resolver’s existing remote-ref enumeration if it includes branch names and symbolic HEAD; this should resolve ADO via authenticatedgit ls-remotewithout downloading blobs. For implicit defaults, I’ll confirm whethermainis represented directly. - Assistant
list_remote_refsreturns named branches/tags and already supports ADO PAT/bearer fallback. I’ll implement a best-effort ADO fallback that resolves the requested ref (andmasterwhen an implicitmainis absent), then fetch raw content by the resolved SHA to avoid a ref-moving race. Failures will preserve the current non-fatal behavior. I’ll also use an already-resolved GitHub SHA for the raw fetch, improving the same integrity invariant there. - Assistant
The edit passes the repository’s Ruff executable. The test invocation used the system Python, which does not have the project installed; I’ll rerun with the repository virtual environment. I’ll also create a temporary focused reproduction (outside
tests/) that mocks ADO refs and raw content, installs the virtual package twice, and verifies both downloads use the same immutable SHA and produce identical hashes. - Assistant
The focused reproduction now confirms the previously unresolved ADO virtual dependency records a SHA, downloads by that SHA on both acquisitions, and yields an identical package hash; all 195 relevant existing tests pass. I’ll review the diff and run the broader downloader, install-source, drift, and lockfile test groups to catch interactions with branch updates and lockfile replay.
- Assistant
The broader command did not run because one listed test path does not exist; this is a test-selection error, not a code failure. The diff is clean, but I’ll improve readability of the nested generator, then rerun using only existing paths and include the install integration tests that cover hash mismatch/self-healing.
- Assistant
The broad affected suite passes: 2,678 tests with 11 expected skips, plus Ruff and whitespace checks. I’ll do one final source review for ADO URL semantics (ensuring a 40-character SHA is accepted as a commit rather than interpreted as a branch), run static type/format checks if configured, and inspect repository status before submission.
- Assistant
A test altered the repository’s tracked
apm.lock.yaml; that is unrelated generated state and must not be submitted, so I’ll restore it. I also requested the wrong line range for the ADO URL helper, so I’ll inspect the actual function before finalizing. - Assistant
The ADO URL currently omits
versionDescriptor.versionType; Azure defaults that descriptor to a branch, so simply passing a SHA may be interpreted as a branch name. I need to make SHA pinning effective by settingversionType=commitfor 40-character hashes (and leave existing branch/tag URLs unchanged). I’ll inspect URL-builder tests, make this narrow change, and rerun them along with the virtual-file tests. - Assistant
Existing tests assert only the branch parameter and will remain compatible. I’ll append the commit descriptor only for full SHA refs, update the helper’s documentation, then verify URL output and rerun affected suites.
- Assistant
The URL behavior check passed. One legacy downloader test fails because it patches the old
Repo.clone_fromimplementation while current production code delegates cloning throughCloneEngine; this failure is unrelated to the changed paths and is already structurally stale. Ruff requested formatting for the URL helper, so I’ll apply the formatter, rerun the directly affected tests (including ADO strategy tests), and run my focused two-install reproduction once more against the final code. - Assistant
Final targeted verification passes (356 tests), and the two-install ADO reproduction remains stable with commit-typed API URLs. I’ll now inspect the complete diff/status to ensure only the intended source changes remain, then submit with the requested checklist assessment.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →