[BUG] audit drift replay disagrees with install link rewriting for marketplace skill bundles
Describe the bug
apm audit --ci cache replay reports deployed skill files as modified immediately after a successful install of a marketplace skill bundle. The real installed files match their lockfile hashes and content-integrity passes; the false drift is isolated to replay output for files whose Markdown links are rewritten during deployment.
To reproduce
APM 0.25.0:
tmpdir="$(mktemp -d)"
cd "$tmpdir"
apm init -y --target codex drift-audit
cd drift-audit
apm install 'microsoft/skills-for-fabric#c8bd4eae16d0ab27e4828cba305ba82163ec9f45'
apm audit --ci --no-fail-fast
Actual behavior
Install exits 0. The immediately following audit exits 1:
[+] Replayed 1 package(s)
[>] Diffing scratch vs working tree...
[!] Drift detected: 58 file(s)
config-consistency: MCP configs match lockfile baseline
content-integrity: No critical hidden Unicode or hash drift detected
drift: drift detected: 58 file(s)
Every finding in the minimal reproduction is reported as modified and owned by microsoft/skills-for-fabric.
One representative file is .agents/skills/activator-authoring-cli/SKILL.md. Its installed hash exactly matches deployed_file_hashes in the lockfile. The source bundle contains links such as:
../../common/COMMON-CLI.md
The real install correctly rewrites those links for the deployed location:
../../../apm_modules/microsoft/skills-for-fabric/common/COMMON-CLI.md
Audit nevertheless reports the file as modified during scratch replay.
Expected behavior
An install followed immediately by apm audit --ci should report no drift. Cache replay must use the same link-resolution inputs and output bytes as the real install path.
Why this appears to be replay-only
deployed-files-presentpasses.content-integritypasses and the installed SHA-256 equals the lockfile hash.- A second real install leaves the deployed skill bytes unchanged.
- The failures cluster on bundle files containing cross-package relative links rewritten toward
apm_modules. - The same package reproduces 58 findings in a fresh one-dependency project, so this is not caused by local edits or multi-package collisions.
The likely boundary is install/drift.py::run_replay: scratch replay writes to a temporary deployment root, while link resolution needs the original project/deployment-root context to produce the same project-relative apm_modules links. This is an inference from the byte pattern; the scratch directory is removed at process exit, so the CLI output does not currently expose the replay-side bytes for direct comparison.
Real-project impact
The same defect contributes most of 148 drift findings in a 36-dependency project. Because apm audit --ci gates on replay drift, users cannot reach a green audit after a clean install and may stop trusting real drift findings.
Environment
- OS: macOS 27.0
- APM: Homebrew v0.25.0 (
d73e6ac) - Target: Codex
Related
- #2059 / #2114 fixed inactive-target ghost entries. The merged fix explicitly called this cache-replay byte mismatch a separate concern and did not address it.
Fixed at HEAD.
Empirical verification on commit 5b20a65f219a1b68212c44cc872f72c2163e5764:
- The reported regression exists on v0.25.0 (
d73e6ac). - Fix #2179 (
20903c35ad,fix(audit): preserve dependency link paths during replay) is an ancestor of HEAD and is not in v0.25.0. - A local skill with a cross-package Markdown link was installed; deployment rewrote the link to the expected
apm_modulespath. - A subsequent
apm audit --cicompleted with exit 0 and reported no drift.
The replay now preserves the deployment link frame, so the false-positive drift report does not reproduce. Closing as fixed.
I am seeing a related install/replay disagreement with APM 0.33.0 (18c4c43) on Linux, using a global agent-skills installation. This may be a regression or a different case from the marketplace example originally reported here; I have not established that the root cause is identical.
Observed workflow:
apm install --global --target agent-skills --only apm --update
cd ~/.apm
apm audit --ci --no-fail-fast --verbose --format json --output /path/to/audit.json
The audit reports 28 modified files belonging to one dependency, while deployed-files-present and content-integrity pass. Repeating the real install does not change the installed bytes or clear the replay findings.
I captured one replayed Markdown file before APM removed its temporary scratch directory. The concrete difference is a sibling-skill link rewritten only by replay. With private owner/package identifiers replaced by placeholders:
# Installed file, matching the package source:
-[S00](../core-architecture/references/design-baseline.md)
# Scratch replay:
+[S00](../../../apm_modules/<owner>/<package>/.apm/skills/core-architecture/references/design-baseline.md)
The installed sibling target exists under ~/.agents/skills/. Multiple cross-skill links in the captured file show the same transformation.
Independent checks:
- Before the update/reinstall, all 95 existing files from the affected dependency matched Git blob IDs fetched from GitHub at the revision recorded in the lockfile.
- After regeneration and reinstall, all 260 recorded file hashes across the global installation match the installed bytes, with no missing recorded files.
- The sample installed Markdown remains identical to the dependency source. The observed difference is in replay output, not an unverified assumption inferred from the drift list.
The dependency uses a .apm/skills/ source layout and cross-skill relative Markdown links. Its repository is private, so I cannot provide a public package URL. I have not yet reproduced this in a standalone public fixture.
Could this global/sibling-skill case be checked against the earlier replay-frame fix? A useful regression test would install two sibling skills from a .apm/skills/ package, retain a link between their deployed copies, and verify that immediate audit replay produces the same bytes.