Repository navigation
[0.38] fix(uninstall): check shrinking survivor selections in the evidence preflight (#4313) - #4620
Merged
Daniel Meppiel (danielmeppiel) merged 5 commits intoNov 21, 2026
Conversation
…reflight (#4313) Files a shrinking shared survivor selection retires now join the uninstall deployment-evidence preflight, so an edited file refuses before any change instead of being kept after apm.yml and apm_modules were already rewritten. The projection reuses declared_node_selections through project_shrunk_selections (one shrink computation, shared with the apply step) and reads retired paths from the deployment ledger; DeploymentEvidence keeps the verdict. Co-authored-by: copilot-swe-agent[bot] <[email protected]> Supersedes: #4588 Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Supersedes: #4588 Co-authored-by: Copilot App <[email protected]>
…tires (#4313) Co-authored-by: copilot-swe-agent[bot] <[email protected]> Supersedes: #4588 Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 21, 2026 12:50
Closed
6 of 14 tasks
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical shrink-preflight gaps let edited retired files bypass refusal or be detected only after package-state changes, alongside false refusals and failures caused by unrelated target resolution.
4 open issues
What changed in this PR
This PR addresses #4313 by extending uninstall’s deployment-evidence preflight to files retired when a surviving shared bundle’s selection shrinks. It aims to refuse edited or unproven files before changing manifests, lockfiles, or deployed state.
Changes:
- Shares a read-only survivor-selection projection between preflight and shrink application.
- Adds retired paths to evidence preparation and refusal checks.
- Adds project- and user-scope regression tests, documentation, and ownership metadata.
| File | Description |
|---|---|
tests/unit/test_uninstall_engine_helpers.py |
Tests retired-path detection and unrestricted selections. |
tests/lifecycle/generator/rules.py |
Updates uninstall source-evidence line references. |
tests/integration/test_skill_selection_merge_lifecycle.py |
Tests refusal without state changes at project and user scopes. |
src/apm_cli/commands/uninstall/selection_shrink.py |
Identifies retired paths and applies survivor-selection changes. |
src/apm_cli/commands/uninstall/engine.py |
Extracts the read-only selection projection. |
src/apm_cli/commands/uninstall/cli.py |
Includes shrink retirements in evidence preflight. |
docs/src/content/docs/reference/cli/uninstall.md |
Documents evidence checks for shrinking shared selections. |
CHANGELOG.md |
Records the intended early-refusal behavior. |
.apm/architecture/owners/install-deployment.json |
Registers the shrink module under the selection owner. |
Review effort: Balanced
…ed retained paths (#4313) Review of #4620: - Skip dynamic-root targets when mapping shared skills roots, so an unrelated Cowork resolution cannot fail a project uninstall. - Decide retirement per target through the exact pairings: a skill selected only for another target retires from this root. - A retired skill directory also retires members older lockfiles record only in deployed_file_hashes. - A path another shrinking survivor keeps deploying is not a deletion candidate. Supersedes: #4588 Co-authored-by: Copilot App <[email protected]>
…gets owner (#4313) Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-4313-shrink-preflight
branch
November 21, 2026 15:25
Merged
3 of 10 tasks
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.


Supersedes #4588 (its owning session became unreachable while still force-pushing the branch). Same change, rebased on current main; authorship kept through commit trailers.
Description
When you uninstall one parent of a diamond, the surviving shared bundle's skill selection shrinks. The skills only that parent selected are then retired. Today those files skip the deployment-evidence preflight. If you edited one, uninstall still rewrites apm.yml and apm_modules, then keeps the file with a warning and exits 0.
With this change, the files a shrinking survivor selection retires join
_refuse_uninstall_without_evidence's candidate set. An edited (or unproven) retired file now refuses withUninstall refusedbefore any change.engine.project_shrunk_selectionsis the read-only projection of the survivor selections. It uses the existing selection ownerdeclared_node_selections(dependency-selection-merge). The preflight and the shrink apply step (_shrink_surviving_selections) both use it, so there is no second shrink computation.selection_shrink.shrink_retired_pathsreads the survivor's recorded paths from the deployment ledger (DeploymentLedgerCodec.from_lockfile). It returns two kinds of path. First, a skill directory and its members when no surviving declaration selects that skill. Second, a path when none of its targets is still selected. A skills root shared by several targets counts every target that deploys there, so a shared root is never over-retired.DeploymentEvidencekeeps the verdict. The retired paths are also passed toevidence.prepare, so the locked render materializes while sources exist. Paths still owned by another survivor are excluded._abort_if_retained_target_cleanup_pathsis unchanged and stays as the backstop.commands/uninstall/selection_shrink.pykeepsengine.pyunder the 2100-line guardrail. It is registered under thedependency-selection-mergeowner selectors.Issue and approved scope
Issue: Fixes #4313
Human scope-approval comment: #4313 (comment) (governance eligibility:
record-present,contact_confirmation_needed: false)Does this PR complete the issue? Yes. Out of scope and untouched: the consent path for missing evidence (#4295, stacked on this PR), how survivor selections merge or shrink, install-time selection, and
apm prune.Decisions (taken as recommended defaults, per rule S15):
KNOWN_TARGETSprofile sharing that skills root) is still selected.Landing order
Type of change
Testing
Red on main (
origin/mainf8c31a5, same uninstall code as d365b87 for this path). Both new cells fail:rc=0, and the output only warnsSkipped removing .agents/skills/alpha/SKILL.md: file has been edited....tests/integration/test_skill_selection_merge_lifecycle.py::test_uninstall_refuses_before_any_change_when_a_shrink_would_remove_an_edited_skilltests/integration/test_skill_selection_merge_lifecycle.py::test_user_scope_uninstall_refuses_before_any_change_when_a_shrink_would_remove_an_editGreen on head. Each cell asserts exit 1,
Uninstall refusednamingskills/alpha/SKILL.md, and noUninstall could not remove tracked target filesline. It also asserts that apm.yml, apm.lock.yaml, apm_modules and every deployed skill are byte-unchanged, at project scope and at user scope.Local evidence:
APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm uv run --frozen --extra dev pytest -n 8 tests/integration/test_skill_selection_merge_lifecycle.py tests/integration/test_uninstall_skill_selection_lifecycle.py: 35 passed. This includes the unchanged controlstest_uninstalling_one_diamond_parent_shrinks_to_the_survivor_selection_then_cleansandtest_user_scope_diamond_merges_then_shrinks_on_uninstall.uv run --frozen --extra dev pytest -n 8 tests/unit -k "uninstall or shrink or selection or cleanup or evidence or reachab": 1521 passed. Under host load, 6 failures appeared; all pass when rerun alone or are environment-only (git commitsigning intest_check_complexity_ratchet).tests/unit/test_uninstall_engine_helpers.py::TestShrinkRetiredPaths(a dropped skill and a dropped target both retire with their members; an unrestricted survivor retires nothing).lint_architecture_boundaries.py --root .(exit 0), complexity ratchet vs origin/main, check_test_assertions,tests.quality.taxonomy --changed, check_taxonomy_allowances, and the Mode B detector (no critical-path diff). Runninggen_statementleaves CONFORMANCE unchanged.Changelog
## [Unreleased]inCHANGELOG.md:user-visible effect first, 25 words or fewer, ending with
(#PR);breaking changes only under upgrade notes; no Highlights; see
.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regenerated