Repository navigation
fix(uninstall): never hide a post-preflight safety rejection under --trust-lockfile - #4828
Daniel Meppiel (danielmeppiel) wants to merge 2 commits into
Conversation
Cleanup now records path-safety rejections of the current pass in CleanupResult.unsafe. Hook sync and selected cleanup treat them as failures that --trust-lockfile consent never waives, so a parent swapped for a symlink after preflight fails the uninstall instead of releasing ownership. Refs #4815 Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Late symlink rejections can still discard consent-kept hooks’ ownership claims during final reconciliation, and current regression tests do not verify that those claims remain persisted.
3 open issues
What changed in this PR
This PR follows #4650 by distinguishing current cleanup safety rejections from files intentionally kept under --trust-lockfile. It addresses #4815 by making those rejections visible as failures that consent cannot waive.
Changes:
- Records path-safety rejections separately in
CleanupResult.unsafe. - Propagates those rejections through hook-sync and selected-cleanup outcomes.
- Adds regressions for a parent replaced by a symlink after preflight.
| File | Description |
|---|---|
tests/spec_conformance/test_deletion_evidence_reqs.py |
Adds post-preflight symlink-race checks for both cleanup outcomes. |
src/apm_cli/integration/cleanup.py |
Tracks current safety rejections and excludes them from consent waivers. |
src/apm_cli/install/selected_cleanup.py |
Includes safety rejections in selected cleanup’s failed paths. |
Review effort: Balanced
…eep consent-kept outside links - under --trust-lockfile, cleanup judges the current file kind: a file replaced by a symbolic link after preflight is kept, never unlinked - a consent-kept final link whose parent passes path validation is retention, not a safety failure, in selected cleanup - under consent the kept-members warning names every file (no 5-name cap) - command-level cell: a post-preflight safety rejection exits 1 and the lock keeps claiming the file - bug-ledger row 4815, changelog fragment, CONFORMANCE regenerated Fixes #4815 Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
A skill member replaced by a final symlink after scanning causes uninstall to fail even with --trust-lockfile instead of receiving consent-kept retention when its ancestors are safe.
1 open issue
3 resolved since last review
Review effort: Balanced
| for member_rel, member in proven: | ||
| if not _member_still_safe(skill_dir, member): | ||
| result.skipped_unmanaged.append(member_rel) | ||
| result.unsafe.append(member_rel) |
|
Closing in favour of #4844, which covers #4815 (PGM decision). This branch keeps red-first cells for the scope extension that #4844 does not have (see |
Red on #4844: a file replaced by a link after preflight is unlinked, the kept-members warning caps at five names under consent, and a consent-kept final link is reported as a safety rejection. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Red on #4844: a file replaced by a link after preflight is unlinked, the kept-members warning caps at five names under consent, and a consent-kept final link is reported as a safety rejection. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Red on #4844: a file replaced by a link after preflight is unlinked, the kept-members warning caps at five names under consent, and a consent-kept final link is reported as a safety rejection. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Red on #4844: a file replaced by a link after preflight is unlinked, the kept-members warning caps at five names under consent, and a consent-kept final link is reported as a safety rejection. Co-authored-by: copilot-swe-agent[bot] <[email protected]>


Description
Closes the post-preflight race class from the #4650 review, in which a change on disk between
apm uninstallpreflight and cleanup was hidden by the consent-kept filter:CleanupResult.unsafe.consent_outcome(hook sync) andSelectedCleanupOutcome.observer(selected cleanup) report them as failures that consent never waives, so uninstall fails and keeps the lock tracking the file instead of releasing ownership.--trust-lockfile, cleanup checks the current file kind and keeps any symbolic link, whatever the earlier verdict.validate_deploy_path(allow_final_symlink=True). Symlinked ancestors are still rejected.Deferred: a hook-sync failure after Step 9 drops the removed row (predates #4815, applies to any late sync failure) is tracked in #4851.
Stacked on #4650 (base
danielmeppiel-4295-uninstall-consent). Merge order: lands after #4650, then retarget tomain.Issue and approved scope
Issue: Fixes #4815
Human scope-approval comment: #4815 (apm-scope:v1 record in the issue comments, plus the scope extension with 3 more items)
Does this PR complete the issue, or what remains? It completes it. The related late hook-sync claim gap is #4851.
Type of change
Testing
Red-first cells in
tests/spec_conformance/test_deletion_evidence_reqs.py(each fails on the base, passes here):test_consent_reports_a_safety_rejection_after_preflight_as_a_failure(before:assert 0 >= 1, the error hidden)test_selected_cleanup_never_releases_a_path_a_safety_gate_rejected(before:failed_paths == set())test_uninstall_fails_and_keeps_tracking_a_path_a_safety_gate_rejected(before:DID NOT RAISE SystemExit): exit 1, outside content unchanged, the claim still inapm.lock.yamltest_consent_keeps_a_file_replaced_by_a_link_after_preflight(before: the link was unlinked)test_consent_names_every_kept_member_of_a_skill_directory(before: "(and 2 more)")test_selected_cleanup_keeps_an_unchanged_consent_kept_link_without_failing(red at 0db9c25: the link was infailed_paths)Bug-ledger row:
tests/fixtures/lifecycle_bug_ledger/bugs/4815.json(tests/quality/test_lifecycle_bug_ledger.py: 2 passed).Targeted run at the final head:
pytest tests/spec_conformance/test_deletion_evidence_reqs.py tests/unit/install/test_target_contraction_logging.py tests/unit/core/test_remediation_block_proofs.py tests/unit/install/test_architecture_invariants.py tests/unit/integration/test_hook_integrator.py tests/unit/integration/test_cleanup*.py tests/unit/test_uninstall*.py: 1272 passed. The lint mirror (ruff 0.15.12, R0801, architecture boundaries, auth signals, complexity ratchet, assertion ratchet, taxonomy, changelog fragments) is clean.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)
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.