Repository navigation
[0.38] fix(uninstall): check shrinking survivor selections in the evidence preflight (#4313) - #4588
Closed
Daniel Meppiel (danielmeppiel) wants to merge 3 commits into
Closed
Daniel Meppiel (danielmeppiel) wants to merge 3 commits into
Daniel Meppiel (danielmeppiel) wants to merge 3 commits into
Conversation
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-fuzzy-fishstick
branch
2 times, most recently
from
November 21, 2026 11:14
c87fd47 to
2d9d6ed
Compare
Closed
9 of 14 tasks
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-fuzzy-fishstick
branch
from
November 21, 2026 11:49
2d9d6ed to
8d091fc
Compare
Daniel Meppiel (danielmeppiel)
marked this pull request as ready for review
November 21, 2026 12:03
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 21, 2026 12:03
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Uninstall preflight can miss edited retired files and allow state changes before detecting them, while mishandling shared ownership can also incorrectly block removal.
3 open issues
What changed in this PR
Extends uninstall’s deployment-evidence preflight to files retired when a surviving shared bundle’s selection shrinks, addressing #4313 before manifest, lockfile, or package changes begin.
Changes:
- Shares a read-only survivor-selection projection between preflight and shrink application.
- Adds retired deployment paths to evidence preparation and refusal checks.
- Adds project- and user-scope regression coverage, updates documentation, and registers the new module with its architecture owner.
| File | Description |
|---|---|
tests/unit/test_uninstall_engine_helpers.py |
Tests retired paths for skill and target selection changes. |
tests/lifecycle/generator/rules.py |
Updates uninstall CLI evidence line references. |
tests/integration/test_skill_selection_merge_lifecycle.py |
Tests early refusal and unchanged files in 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 shared, read-only selection projection. |
src/apm_cli/commands/uninstall/cli.py |
Includes shrinking selections in the evidence preflight. |
docs/src/content/docs/reference/cli/uninstall.md |
Documents refusal for files retired by shrinking selections. |
CHANGELOG.md |
Records the user-visible uninstall fix. |
.apm/architecture/owners/install-deployment.json |
Registers the new module under the selection-merge owner. |
Review effort: Balanced
Comment on lines
+58
to
+74
| skills = skill_subset_filter_tokens(selection.skill_subset) | ||
| for value in { | ||
| record.locator.value.rstrip("/") for record in records if key in record.owners | ||
| }: | ||
| skill_dir = _enclosing_skill_dir(value) | ||
| targets = set(targets_at[value]) | ||
| if skill_dir is not None: | ||
| targets |= sharers.get(skill_dir.rpartition("/")[0], set()) | ||
| if ( | ||
| selection.target_subset is not None | ||
| and not any(selection.selects_target(target) for target in targets) | ||
| ) or ( | ||
| skills is not None | ||
| and skill_dir is not None | ||
| and skill_dir.rpartition("/")[2] not in skills | ||
| ): | ||
| retired.add(value) |
| and skill_dir.rpartition("/")[2] not in skills | ||
| ): | ||
| retired.add(value) | ||
| return retired |
Comment on lines
+607
to
+608
| retired = BaseIntegrator.normalize_managed_files(shrink_retired_paths(lockfile, shrunk)) | ||
| candidates |= (retired or builtins.set()) - others - builtins.set(other_hashes) |
7 of 14 tasks
…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]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…tires (#4313) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-fuzzy-fishstick
branch
from
November 21, 2026 12:32
8d091fc to
a6fe996
Compare
Merged
6 of 14 tasks
Collaborator
Author
|
Superseded by #4620 (same change rebased on main, authorship kept via trailers; this branch's owning session is unreachable). |
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 21, 2026
…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]>
Merged
3 of 10 tasks
Mohammed Alkindi (MohammedAlkindi)
pushed a commit
to MohammedAlkindi/apm
that referenced
this pull request
Nov 21, 2026
…reflight (microsoft#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: microsoft#4588 Co-authored-by: Copilot App <[email protected]>
Mohammed Alkindi (MohammedAlkindi)
pushed a commit
to MohammedAlkindi/apm
that referenced
this pull request
Nov 21, 2026
…#4313) Co-authored-by: copilot-swe-agent[bot] <[email protected]> Supersedes: microsoft#4588 Co-authored-by: Copilot App <[email protected]>
Mohammed Alkindi (MohammedAlkindi)
pushed a commit
to MohammedAlkindi/apm
that referenced
this pull request
Nov 21, 2026
…tires (microsoft#4313) Co-authored-by: copilot-swe-agent[bot] <[email protected]> Supersedes: microsoft#4588 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
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
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