Repository navigation
fix(uninstall): report a safety rejection after consent as a failure (#4815) - #4844
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the fix preventing prior consent from masking cleanup safety rejections during uninstall.
No open issues 🎉
What changed in this PR
This PR fixes #4815 in the --trust-lockfile uninstall flow introduced by #4650. A cleanup safety rejection now remains a failure even if preflight consent previously kept the file, preventing a successful exit and loss of lockfile ownership.
Changes:
- Record current safety-rejection reasons and propagate them through cleanup outcomes.
- Make uninstall retain ownership and report rejected paths without applying the consent exemption.
- Add regression coverage for a parent-symlink swap, a bug-ledger entry, and a changelog fragment.
| File | Description |
|---|---|
tests/unit/integration/test_cleanup_helper.py |
Tests that safety rejection overrides earlier consent-based retention. |
tests/integration/test_uninstall_consent_safety_rejection.py |
Checks uninstall failure, preserved ownership, and unchanged file contents after a symlink swap. |
tests/fixtures/lifecycle_bug_ledger/bugs/4815.json |
Records the bug and its regression tests. |
src/apm_cli/integration/cleanup.py |
Records rejection reasons and includes rejected paths in failure outcomes. |
src/apm_cli/install/selected_cleanup.py |
Carries rejection reasons into selected-cleanup outcomes. |
src/apm_cli/commands/uninstall/cli.py |
Prevents consent from hiding rejections and reports their reasons. |
changelog.d/4844.fixed.md |
Documents the corrected uninstall behavior. |
Review effort: Balanced
489d5dc to
4bdacfb
Compare
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
apm-spec-waiver: bug fix inside the existing #4295 consent contract; a safety rejection is reported as a failure, no new normative behaviour Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Safety-sensitive deletion outcomes depend on stacked PR #4650, and CI has not covered the final main-based merge state, so a maintainer should confirm race regressions and cleanup validation after retargeting.
No open issues 🎉
Review effort: Balanced
4bdacfb to
e6d0413
Compare
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
apm-spec-waiver: bug fix inside the existing #4295 consent contract; a safety rejection is reported as a failure, no new normative behaviour 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]>
There was a problem hiding this comment.
🟡 Changes recommended
A remaining cleanup issue causes uninstall with --trust-lockfile to reject a safely replaced final symlink instead of preserving it under consent, and a directory-member replacement regression test is needed.
1 open issue
Review effort: Balanced
e6d0413 to
0421533
Compare
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
apm-spec-waiver: bug fix inside the existing #4295 consent contract; a safety rejection is reported as a failure, no new normative behaviour 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]>
There was a problem hiding this comment.
🟡 Changes recommended
A critical symlink-safety gap in cleanup can misclassify an unsafe path as consent retention, allowing selected uninstall to release ownership and exit successfully without revalidating the full ancestor chain.
1 open issue
1 resolved since last review
Review effort: Balanced
…asIndex.aliases (#4815) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…pt under consent (#4815) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…ent (#4815) A member whose ancestors are safe but which became a symbolic link after the scan is consent retention, not a safety rejection. Symlinked ancestors stay rejections. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…report one deletion (#4815) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
#4815) A user-scope lock listing one file both as an absolute path and root-relative now reports one deletion after a single unlink. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…jection (#4815) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…cal path gate (#4815) A skill member that became a final link is consent retention only when validate_deploy_path with allow_final_symlink passes from the deploy root to its parent; a symlinked ancestor above the skill directory stays a rejection. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…oot (#4815) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…te before unlinking (#4815) The pre-unlink recheck stopped at the skill directory, so a proven member under a skills root swapped for a link after the scan could be unlinked outside the deploy root. Every member now also passes validate_deploy_path from the deploy root immediately before its unlink. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…re one file (#4815) Co-authored-by: Copilot App <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…owork root (#4815) Under an external Cowork root, cowork:// claims naming one file in another case now share hashes and owners through SpellingAliasIndex.aliases, so a conflicting hash under another spelling blocks --trust-lockfile consent. Co-authored-by: Copilot App <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]>
5c181b8 to
fe5fc82
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The Cowork path validator ignores allow_final_symlink, incorrectly failing trusted-lockfile cleanup when a proven skill member is replaced by an external symlink despite safe ancestors, and needs a fix with regression coverage.
1 open issue
Review effort: Balanced
…4815) The quality ratchet (AQ003) needs each component test to observe a user-visible outcome: a consent verdict never deletes the file, every kept skill member keeps the user's bytes, and a refused Cowork claim keeps its file. Co-authored-by: Copilot App <[email protected]> Co-authored-by: copilot-swe-agent[bot] <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because a critical symlink race can allow cleanup to delete files outside the deployment root after an earlier safety check has passed.
No open issues 🎉
1 resolved since last review
Review effort: Balanced


Description
During
apm uninstall --trust-lockfile, a file the preflight kept under consent could have its parent swapped for a symlink before cleanup. Cleanup's path-safety gate then refused it intoskipped_unmanaged, and the historical consent-kept filter hid that refusal: hook sync reported no failure, and selected cleanup incommands/uninstall/cli.pyreleased the file's ownership and finished with exit 0.Fix (owner:
integration/cleanup.py):CleanupResult.rejectedmaps each path a safety gate refused in this cleanup to its reason (traversal, prefix, path safety check, directory entry, replaced since checked). Still also listed inskipped_unmanaged.consent_outcomealways reports rejected paths as failures and unsafe paths, whatever consent kept earlier.SelectedCleanupOutcome.observercarriesrejected_paths;_abort_if_retained_target_cleanup_pathsnever waives a failed or rejected path (nor the directories holding it), and names the reason in the error list.Only current evidence-based retention stays exempt; consent semantics are unchanged.
Added scope (from #4815's follow-up comments, folded from closed #4828 and the #4650 review):
consent_kept_linkjudges the current file kind, whatever the earlier verdict.validate_deploy_path(allow_final_symlink=True)is retention, not a safety rejection. Symlinked ancestors are still rejected.--trust-lockfilethe kept-members warning names every file (the five-name cap stays without the flag).test_consent_reads_case_variant_spellings_as_one_filemoved intotests/unit/integration/test_cleanup_spelling_windows_compat.py(windows_compat, Windows lane), keeping its req-lk-024 link.test_consent_keeps_a_member_replaced_by_a_link_after_the_scan._consentedis keyed byself._key(claim)(root-relative), so a user-scope lock listing one file both absolute and relative reports one deletion. Red-first:test_consent_reports_one_deletion_for_absolute_and_relative_spellings(before: two entries).validate_deploy_path(..., allow_final_symlink=True)from the deploy root. The strict pre-unlink recheck now also runs the canonical gate, so a proven member reached through a skills root swapped for a link after the scan is never unlinked outside the root. Red-first:test_consent_rejects_a_member_link_under_a_symlinked_skills_rootandtest_consent_never_unlinks_a_member_moved_under_a_symlinked_skills_root(before: the outside file was deleted).cowork://spellings under an external Cowork root (APM_COPILOT_COWORK_SKILLS_DIRoutside the deploy root) are pooled throughSpellingAliasIndex.aliasesagainst the resolved Cowork root, so a conflicting hash under another spelling blocks consent. Red-first:test_consent_reads_case_variant_cowork_spellings_as_one_file(a hard link stands in for a case-insensitive filesystem; before the fix, consent was granted).install-deployment-cleanup-spelling-aliases:DeploymentEvidence._equivalent_keysmust callSpellingAliasIndex.aliases, andcleanup.pymay not callsamefile/normcase/casefold/physical_alias/stored_spelling. It has a mutation case and an entry in the runner's rule-id list.Ported red-first cells (
tests/spec_conformance/test_deletion_evidence_reqs.py), run on the earlier #4844 head (commit acaea08) before the fix:test_consent_keeps_a_file_replaced_by_a_link_after_preflight: FAILED,path.is_symlink()False (the link was unlinked)test_consent_names_every_kept_member_of_a_skill_directory: FAILED, "(and 2 more)"test_selected_cleanup_keeps_an_unchanged_consent_kept_link_without_failing: FAILED, the link was reported inrejected_pathstest_consent_reports_a_safety_rejection_after_preflight_as_a_failureandtest_selected_cleanup_never_releases_a_path_a_safety_gate_rejected: already green on fix(uninstall): report a safety rejection after consent as a failure (#4815) #4844, because its first fix covers them. They are ported as spec-level req-lk-024 cells.Stacked on #4650 (base
danielmeppiel-4295-uninstall-consent, rebased onto 9e63ec1): the consent code only exists there. Will retarget tomainonce #4650 lands.Issue and approved scope
Issue: Fixes #4815
Human scope-approval comment: #4815 (apm-scope:v1 comment by Daniel Meppiel (@danielmeppiel))
Completes the approved scope. The other two deferred findings in the second issue comment (final-symlink kind recheck at cleanup.py ~431, kept-files warning cap) are out of the approved scope and not touched.
Type of change
Testing
Regression cell (swaps the kept file's parent for a symlink between preflight and cleanup). It is an in-process component test, like
test_uninstall_hook_cleanup_failure.py, because the race must be injected between preflight and cleanup, which a subprocess binary cannot expose.Validation evidence (local; this PR targets a non-main base, so PR CI does not run until it is retargeted):
uv run --extra dev pytest -n 4 tests/unit/integration/test_cleanup_helper.py tests/integration/test_uninstall_consent_safety_rejection.py tests/integration/test_uninstall_hook_cleanup_failure.py tests/unit/test_deployment_materialization_receipts.py tests/spec_conformance/test_deletion_evidence_reqs.py tests/unit/install/test_target_contraction_logging.pyuv run --extra dev pytest -n 8 tests/unit tests/spec_conformance -k "uninstall or cleanup or hook or consent or selected"tests/unit/install/test_unix_install_ownership.py, which also fails on the unmodified base in this sandbox (install-script environment)uv run --extra dev pytest -n 8 tests/qualityruff check/ruff format --check(src, tests, architecture linter)bash scripts/lint-auth-signals.shscripts/check_complexity_ratchet.py --base-ref origin/danielmeppiel-4295-uninstall-consentpython -m tests.quality.taxonomy --changedtests/spec_conformance/mode_b_detector.shpython -m tests.spec_conformance.gen_statementpytest tests/integration/test_architecture_owner_rule_mutations.py -k spelling-aliases+scripts/lint_architecture_boundaries.py --root .pytest -n 8 tests/unit/integration tests/spec_conformance+ neighbourstest_mode_b_detector,test_resolution_reqs), unrelatedscripts/check_obligation_status_ratchet.pyChangelog
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)
CONFORMANCE.{md,json}regenerated