Repository navigation
fix(audit): replay the project's own content the way install deploys it - #3209
Open
Aditya Nikam (adityaanikam) wants to merge 1 commit into
Open
Aditya Nikam (adityaanikam) wants to merge 1 commit into
Aditya Nikam (adityaanikam) wants to merge 1 commit into
Conversation
apm install integrates the project's own content through a synthetic _local package that is always an APM_PACKAGE, so a sibling skills/<name>/SKILL.md next to .apm/ is never deployed. Audit replay rebuilt the package for the project's own lock entry and detected its type from the project root, which is SKILL_BUNDLE for that layout. The replay promoted skills/<name>, so apm audit --ci failed a clean install with an unintegrated drift finding. Build the synthetic package in one place, build_project_local_package_info, and use it for both install and the project's own entry in the replay. The install-deployment-audit-replay guard now requires both call sites. Add a lifecycle test that installs, audits, reinstalls and audits again for explicit and automatic includes with one and two targets, and checks that a missing or changed managed file still fails the audit.
Aditya Nikam (adityaanikam)
requested review from
Daniel Meppiel (danielmeppiel) and
Sergio Sisternes (sergio-sisternes-epam)
as code owners
October 11, 2026 10:53
This branch has not been deployed
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
apm auditreported a rootskills/folder asunintegrateddrift after a cleanapm install, although install never deploys it.Install integrates the project's own content through a synthetic
_localpackage that is always anAPM_PACKAGE, so only.apm/content is deployed. The audit replay built the package for the project's own lock entry fromapm.ymland detected its type from the project root. For a project with.apm/content and a siblingskills/<name>/SKILL.mdthat detection givesSKILL_BUNDLE, so the replay promotedskills/<name>and the diff showed it as missing.Both paths now build that package in one place,
build_project_local_package_infoin the newinstall/project_package.py.integrate_local_content(install) and the project's own entry inrun_replay(audit) call it. Dependencies in the replay still use_build_package_infoas before, so their behavior does not change.Issue and approved scope
Issue: #3151
Human scope-approval comment: #3151 (comment) (acceptance clarification: #3151 (comment))
Does this PR complete the issue, or what remains? Fixes #3151.
How it follows the acceptance clarification:
install-deployment-audit-replayrule now fails if either one stops usingbuild_project_local_package_info.tests/integration/test_project_self_audit_lifecycle.pyruns install, audit, reinstall and audit for explicit andautoincludes, each with one target and with two targets. It asserts the deployed bytes, that nothing is deployed for the siblingskills/hello, thatlocal_deployed_fileslists only the instruction paths, and that the audit leaves the project state unchanged. It then deletes a managed file and, after a reinstall, edits it: the audit fails withdeployed-files-presentfor the deletion and withcontent-integrityanddriftfor the edit, and a reinstall repairs both.tests/fixtures/lifecycle_bug_ledger.jsonrow for [BUG] apm audit reports a root skills/ folder as unintegrated drift, although install never deploys it #3151, a CHANGELOG entry, and a short paragraph indrift-and-secure-by-default.md.drift.pyis now 1025 lines, so I raised its entry inKNOWN_LARGE_MODULESfrom 1020 to 1025.services.pygot smaller.Type of change
Testing
On Windows with Python 3.12, using
uv run, withAPM_E2E_TESTS=1andAPM_BINARY_PATHpointing at theapm.exeof the checkout:test_project_self_audit_lifecycle.py: 4 passed. With thedrift.pychange reverted, all 4 fail at the first audit after a clean install (exit 1).tests/unitselected with-k "drift or replay or audit or local_content or project_package": 903 passed, 9 skipped.tests/quality: 64 passed.tests/unit/install,scripts,integration,commands,coreanddeps: 8926 passed, 91 failed, 4 errors. The same 91 failures and 4 errors occur onmainon my machine (the ones I looked at create symlinks and fail withWinError 1314, no symlink privilege), and the sets of failing tests are identical with and without this change.test_architecture_owner_rule_mutations.py,test_deps_models_validation.py,test_drift_detection.py,test_services.pyandtest_architecture_invariants.pypass, apart from the symlink test intest_services.pythat fails the same way onmain.scripts/lint_architecture_boundaries.pyandruff check/ruff format --checkon the changed files are clean.I did not run the whole test suite, so that box is unchecked.
Spec conformance (OpenAPM v0.1)