Repository navigation
fix(audit): audit --ci accepts a clean install -g of a user-root agent with a context link (#4832) - #4880
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
A critical link-resolution issue leaves scratch-materialized dependency sources pointing into scratch rather than their installed location, requiring corrected source mapping and a clean install/audit regression test.
1 open issue
What changed in this PR
This PR addresses #4832: false drift reported by apm audit --ci after a clean global install of a user-root agent with a context link. It aligns replay link rendering with live deployment paths while keeping writes in scratch.
Changes:
- Shares deployment-target mapping across context, memory, and asset links.
- Passes deployment coordinates to all replayed packages, including user-root self-entries.
- Adds regression coverage, an edited-agent drift control, and release documentation.
| File | Description |
|---|---|
tests/unit/compilation/test_link_resolver.py |
Tests matching context-link rendering during install and replay. |
tests/integration/test_user_root_primitives_lockfile_lifecycle.py |
Tests clean global-install audits and detection of deployed-agent edits. |
tests/fixtures/lifecycle_bug_ledger/bugs/4832.json |
Records the regression and its coverage. |
src/apm_cli/integration/base_integrator.py |
Sets the deployment frame for every package. |
src/apm_cli/install/drift.py |
Supplies live source and deployment coordinates for self-entry replay. |
src/apm_cli/compilation/link_resolver.py |
Reuses live-target mapping for context, memory, and asset links. |
changelog.d/4880.fixed.md |
Documents the user-visible audit fix. |
Review effort: Balanced
…yment frame (#4832) UnifiedLinkResolver._resolve_context_link computed context and memory links from the replay's scratch target directory, so after a clean apm install -g a user-root agent linking ../context/notes.context.md drifted under audit --ci. Context links now map the target through the deployment frame, as asset links already did; init_link_resolver sets the frame for every package (the $HOME user root included), and a lock self-entry (claimed root files) replays with the frame and its live source root. No self-entry is synthesized. Writes stay in scratch. Stacked on #4684 (a668d29). apm-spec-waiver: audit replay link text only; no manifest, lockfile or resolver contract changes Co-authored-by: Copilot App <[email protected]>
…control (#4832) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…ckage (#4832) Copilot review: a dependency replayed from scratch kept its context link source in scratch while the target mapped live. Context sources now project through deployment_package_root like asset links; scratch paths outside the package map through the frame; live and external sources are unchanged. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
174f745 to
ebd102e
Compare
There was a problem hiding this comment.
🟡 Changes recommended
A symlinked APM root still produces false dependency drift because replay paths differ from installation paths, requiring root resolution and a regression test.
1 open issue
1 resolved since last review
Review effort: Balanced
…ical paths (#4832) Copilot review: a symlinked APM_HOME or ~/.apm made the projection emit the symlink spelling while install linked from the physical path discovery registered. Projected package and frame roots now resolve; asset-link handling is unchanged. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
The folded fix changes shared project replay and self-entry framing beyond the linked human approval’s scope, requiring maintainer confirmation of expanded authorization.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
Keeps the AQ003 assertion-quality ceiling for test_link_resolver.py. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
The PR changes project self-entry framing and project-scope dependencies beyond the linked human scope approval, requiring maintainer confirmation that the broader replay scope is authorized.
No open issues 🎉
Review effort: Balanced


Description
After a clean
apm install -g,apm audit --cireported drift for a user-root agent (~/.apm/agents) that links to a context file. Audit replay computed context and memory links from its scratch target directory, while install computed them from the live~/.copilot/agents, so the link text differed.UnifiedLinkResolvernow maps the target through the deployment frame for context and memory links too (_live_target_location), as asset links already did. The frame only shapes link text; replay writes stay in scratch.deployment_package_root(as asset links do); other scratch paths map through the frame; live and external sources are unchanged.init_link_resolversets the frame for every package, including the$HOMEuser root.run_replay, a lock self-entry (claimed root files) replays with the frame and its live source root. No self-entry is synthesized.Issue and approved scope
Issue: Fixes #4832
Human scope-approval comment: #4832 (comment)
Does this PR complete the issue, or what remains? Completes it: the install -g -> audit --ci regression passes, and the edited-agent control still reports drift.
Type of change
Testing
New tests:
tests/integration/test_user_root_primitives_lockfile_lifecycle.py::test_install_g_then_audit_accepts_a_user_root_context_link(clean audit passes; edited deployed agent still drifts with exit 1) andtests/unit/compilation/test_link_resolver.py::TestReplayFrameTranslation::test_replay_renders_context_links_in_live_deployment_frame.test_install_g_then_audit_accepts_a_dependency_context_link(user scope) andtests/integration/test_local_link_audit_replay_lifecycle.py::test_local_dependency_context_link_audits_clean_and_tracks_edits(project scope) plustest_replay_projects_a_scratch_dependency_context_link_to_its_live_packagecover a scratch-materialized dependency. Bug ledger row:tests/fixtures/lifecycle_bug_ledger/bugs/4832.json.Validation evidence:
src/changes reverted toorigin/main, the user-root and user-scope dependency integration tests and the unit tests fail; without the dependency projection, the project-scope dependency test fails too. All pass with the fix. Earlier: both original tests fail (audit exit 1,1 of 15 check(s) failed; unit link text mismatch); restored, both pass.pytest -n auto tests/unit/{compilation,install,integration,policy} tests/unit/test_audit_ci_command.py+ 16 audit/link/drift integration modules: 9247 passed; 246 env-only failures (test_unix_install_ownership.py, same on main).uv run --extra dev pytest -q -n auto tests/unit tests/integration/test_global_update_audit_materialization_lifecycle.py tests/integration/test_user_root_primitives_lockfile_lifecycle.py tests/integration/*drift* tests/integration/*audit* tests/integration/*replay*: 29858 passed. 260 failures are local-environment-only (root user ownership, IPv6 guard, git env); the identical set fails onorigin/mainin the same container.test_global_update_then_audit_passes_for_released_user_lockfiles[v0.35.1|v0.36.0]: passed.tests/quality/test_lifecycle_bug_ledger.py tests/quality/test_test_taxonomy.py: 38 passed.Changelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
If this PR changes behaviour that an OpenAPM v0.1
req-XXXcovers,confirm the three-step ritual in the
development guide:
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.