You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(uninstall): never remove a skill-directory member a surviving dependency still deploys - #4752
Bug: when apm uninstall removed a package whose lockfile entry claims a whole skill directory, cleanup removed the entire tree with rmtree once every remaining member looked APM-owned. That tree could include a member another, surviving dependency still deploys (src/apm_cli/integration/cleanup.py, _safe_remove_skill_directory), and that member was lost.
Fix, in the cleanup owner:
reconcile_target_deployed_files passes the surviving dependencies' deployed paths into the cleanup pass as live paths. remove_stale_deployed_files already treats live paths as "still deployed after this run".
_safe_remove_skill_directory never removes a member in that live set. When one is present, the directory stays, and the departing package's other proven members are removed one by one through _remove_proven_members.
_remove_proven_members runs each member's deletion gates again immediately before its unlink. A file changed after the directory check is kept and named, never removed.
Consent and approval rules are unchanged, and uninstall never removes more than before. A directory with no surviving members takes the same path as before.
Does this PR complete the issue, or what remains? It completes it. #4650 (--trust-lockfile) will rebase onto this owner fix for its per-member consent path, and carries no second copy.
Type of change
Bug fix
New feature
Documentation
Maintenance / refactor
Testing
Tested locally
All existing tests pass: CI pending.
Added tests for new functionality (if applicable)
Failing-before cells at the uninstall owner, reconcile_target_deployed_files with selected-owner removal (the path apm uninstall takes), driven through the real cleanup.py code:
test_selected_removal_keeps_a_skill_member_a_surviving_dependency_deploys: two packages share a skill-directory member. Uninstalling one keeps the shared member byte-identical, removes the departing package's own member, and leaves the survivor's lockfile row equal to disk.
Before the fix: FileNotFoundError ... .agents/skills/alpha/shared.md (the member was removed).
test_selected_removal_keeps_a_member_edited_between_check_and_unlink: a member edited after its check is kept.
Before the fix: FileNotFoundError ... .agents/skills/alpha/notes.md.
Both pass after the fix. Local results, run through the host guard:
pytest -n 2 over target contraction, cleanup skill dirs, cleanup helper, skill cleanup containment, deletion-evidence spec, lifecycle bug ledger, the uninstall engine and shared-ownership units, and the manifest reconcile units: 139 passed.
The lint contract is clean: ruff 0.15.12 check and format, the complexity ratchet, the architecture linter, auth signals, the assertion and taxonomy ratchets. No source file exceeds 2100 lines.
One fragment per section, changelog.d/<pr>.<section>.md, holding
one line: user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes only under upgrade notes; no Highlights; no
new lines under ## [Unreleased]. See changelog.d/README.md and .github/instructions/changelog.instructions.md.
N/A -- this PR does not change OpenAPM-observable behaviour. It enforces the existing req-lk-024 deletion-evidence rule more strictly; no spec text changes.
…endency still deploys
Fixes#4750. When a departing package's skill directory held a member a
surviving dependency still deploys, cleanup removed the whole tree once
every member looked APM-owned. Survivors' paths now reach the directory
pass as live paths: those members are never removed, the departing
package's other proven members are removed one by one, and each member's
deletion gates run again immediately before its unlink, so a file
changed after the check is kept and named.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical cleanup flaws can delete surviving shared files or files outside the deployment root, and installed-CLI lifecycle coverage is missing for disk and persisted-lockfile consistency.
This PR addresses #4750 by updating the shared cleanup owner to preserve skill-directory files still deployed by surviving dependencies during apm uninstall.
Changes:
Passes surviving dependencies’ deployed paths into cleanup as protected live paths.
Uses per-member deletion when a directory contains shared files, rechecking deployment evidence before each unlink.
Adds two reconciliation regressions, a bug-ledger entry, and a changelog fragment.
…p call
The spelling-alias owner check pinned live_paths=files; the call now
passes survivors' paths too (#4750), still through SpellingAliasIndex.
apm-spec-waiver: enforces the existing req-lk-024 deletion-evidence rule more strictly; no new normative behaviour or spec text
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Critical cleanup flaws can delete surviving owners’ files through missed case or Unicode aliases and delete redirected files outside the deployment root because path and symlink safety checks are not repeated before removal.
…safety before each unlink
Addresses review on #4752 (Fixes#4750):
- a surviving claim spelled differently on a case-insensitive
filesystem (Shared.md vs shared.md) is matched through
SpellingAliasIndex physical identity, so it is never removed
- immediately before each per-member unlink, the member must still be a
regular file, reached through no symlinked directory and contained in
the skill directory, and its evidence must still authorize its bytes
- an installed-CLI lifecycle cell runs apm uninstall and asserts the
survivor's bytes and the persisted apm.lock.yaml (red on main)
apm-spec-waiver: enforces the existing req-lk-024 deletion-evidence rule more strictly; no new normative behaviour or spec text
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Cleanup can delete files outside the validated deployment scope after an ancestor symlink swap and fail to protect surviving URI-claimed files on case-insensitive filesystems.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Revalidate ancestor symlinks before authorizing deletion
src/apm_cli/integration/cleanup.py:802
If .agents or .agents/skills becomes a symlink after the scan, this recheck misses it: the ancestor walk stops at skill_dir, and containment resolves both paths into the outside tree. Matching locked-render bytes can then authorize deletion of an outside file. Pass the original validated deployment scope into the recheck, rerun its canonical ancestor and containment gates, and add a regression that swaps an ancestor above the skill directory.
Resolve URI claims when protecting surviving files
src/apm_cli/integration/cleanup.py:977
SpellingAliasIndex excludes candidates containing :// (utils/paths.py:94-96), so on a case-insensitive filesystem a survivor claiming cowork://skills/alpha/Shared.md does not protect the scanned cowork://skills/alpha/shared.md. With matching deployment evidence, cleanup can still delete that surviving member. Resolve URI claims through the canonical target resolver before checking spelling and physical identity under the external root, and cover this case in a regression.
Merges main (with #4752, which owns the per-member skill-directory fix)
and folds the #4650 and #4725 review threads:
- a receipt store no installation marker binds counts as unreadable
- consented deletions are reported once, before any early exit
- the consent exemption follows actual deletion verdicts; a path
cleanup failed on (I/O) is never waived; ancestor lookup is O(1)
- under consent a standalone tracked file replaced by a link is kept
and named by the evidence owner, so uninstall finishes
- the --trust-lockfile remedy names the packages; the lifecycle test
runs the printed command
Spec stays 0.1.76; CONFORMANCE regenerated.
Co-authored-by: Copilot App <[email protected]>
Merges main (with #4752, which owns the per-member skill-directory fix)
and folds the #4650 and #4725 review threads:
- a receipt store no installation marker binds counts as unreadable
- consented deletions are reported once, before any early exit
- the consent exemption follows actual deletion verdicts; a path
cleanup failed on (I/O) is never waived; ancestor lookup is O(1)
- under consent a standalone tracked file replaced by a link is kept
and named by the evidence owner, so uninstall finishes
- the --trust-lockfile remedy names the packages; the lifecycle test
runs the printed command
Spec stays 0.1.76; CONFORMANCE regenerated.
Co-authored-by: Copilot App <[email protected]>
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
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
Fixes #4750. Record: #4750 (comment)
Bug: when
apm uninstallremoved a package whose lockfile entry claims a whole skill directory, cleanup removed the entire tree withrmtreeonce every remaining member looked APM-owned. That tree could include a member another, surviving dependency still deploys (src/apm_cli/integration/cleanup.py,_safe_remove_skill_directory), and that member was lost.Fix, in the cleanup owner:
reconcile_target_deployed_filespasses the surviving dependencies' deployed paths into the cleanup pass as live paths.remove_stale_deployed_filesalready treats live paths as "still deployed after this run"._safe_remove_skill_directorynever removes a member in that live set. When one is present, the directory stays, and the departing package's other proven members are removed one by one through_remove_proven_members._remove_proven_membersruns each member's deletion gates again immediately before its unlink. A file changed after the directory check is kept and named, never removed.Issue and approved scope
Issue: Fixes #4750
Human scope-approval comment: #4750 (comment)
Does this PR complete the issue, or what remains? It completes it. #4650 (
--trust-lockfile) will rebase onto this owner fix for its per-member consent path, and carries no second copy.Type of change
Testing
Failing-before cells at the uninstall owner,
reconcile_target_deployed_fileswith selected-owner removal (the pathapm uninstalltakes), driven through the realcleanup.pycode:test_selected_removal_keeps_a_skill_member_a_surviving_dependency_deploys: two packages share a skill-directory member. Uninstalling one keeps the shared member byte-identical, removes the departing package's own member, and leaves the survivor's lockfile row equal to disk.FileNotFoundError ... .agents/skills/alpha/shared.md(the member was removed).test_selected_removal_keeps_a_member_edited_between_check_and_unlink: a member edited after its check is kept.FileNotFoundError ... .agents/skills/alpha/notes.md.Both pass after the fix. Local results, run through the host guard:
pytest -n 2over target contraction, cleanup skill dirs, cleanup helper, skill cleanup containment, deletion-evidence spec, lifecycle bug ledger, the uninstall engine and shared-ownership units, and the manifest reconcile units: 139 passed.Bug-ledger row:
tests/fixtures/lifecycle_bug_ledger/bugs/4750.json(ownership.preserve_unowned).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)