Repository navigation
[0.38] fix(uninstall): rebuild survivors only into lock-recorded targets after a target change (#4636) - #4663
Merged
Daniel Meppiel (danielmeppiel) merged 3 commits intoNov 21, 2026
Conversation
) After apm.yml switched or added a target, uninstall re-integrated the remaining packages into the new target without recording the files in apm.lock.yaml (I1), and printed a skip hint for the root it had just created. Uninstall now reconciles only the targets the lock records (manifest_targets, else targets owning a recorded file) and says once that apm install deploys and records the new target. Unchanged targets behave as before. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
marked this pull request as ready for review
November 21, 2026 18:19
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 21, 2026 18:19
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Uninstall can mistake updated manifest targets or shared skill paths for deployment evidence, causing surviving packages to be rebuilt into unrecorded target-specific paths.
2 open issues
What changed in this PR
This PR addresses #4636 by filtering uninstall survivor rebuilds through lock-recorded targets, intended to prevent deployments to newly selected targets without matching lockfile records.
Changes:
- Adds a target filter using recorded declarations or deployed paths.
- Adds one-time guidance to run
apm installfor newly selected targets. - Adds unit coverage, bug tracking, documentation, and architecture registration.
| File | Description |
|---|---|
tests/unit/test_uninstall_engine_validation_logic.py |
Tests target filtering, fallback behavior, and remediation text. |
tests/unit/core/test_remediation_commands_catalog.py |
Records coverage context for the new remediation entry. |
tests/fixtures/lifecycle_bug_ledger/bugs/4636.json |
Tracks the bug and regression tests. |
src/apm_cli/core/remediation.py |
Adds install guidance for undeployed targets. |
src/apm_cli/commands/uninstall/recorded_targets.py |
Implements lock-based filtering and user guidance. |
src/apm_cli/commands/uninstall/engine.py |
Applies filtering before survivor reintegration. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Updates the uninstall usage reference. |
docs/src/content/docs/reference/cli/uninstall.md |
Documents behavior after target changes. |
changelog.d/4663.fixed.md |
Adds the user-facing fix note. |
.apm/architecture/owners/install-deployment.json |
Registers the new module under the existing owner. |
Review effort: Balanced
…st_targets (#4636) Review follow-ups: - manifest_targets is refreshed from apm.yml on every changed lock write, so a second uninstall after a target switch would have rebuilt into the new target. The evidence is now the target each recorded deployment row names. - A legacy row on a root several targets share (.agents/) counts only for the one candidate target that governs it. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-4636-uninstall-new-target
branch
November 21, 2026 20:46
This was referenced Nov 21, 2026
Merged
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
After
apm.ymlswitches or adds a target ([copilot]->[claude]or[copilot]->[copilot, claude]),apm uninstall <pkg>rebuilt the remaining packages into the new target. It did not record those files inapm.lock.yaml, which breaks lifecycle invariant I1. It also printedSkipped .claude/commands/ -- create a .claude/ directory, a hint about a root the same command had just created.Uninstall now rebuilds survivors only into the targets the lock records:
deployments[].target, or the legacy prefix attribution for older locks).manifest_targets, which every changed lock write refreshes fromapm.yml..agents/) counts only for the one candidate target that governs it.Not deployed to claude: this project was not installed for it yet. Run 'apm install' to deploy the remaining packages to claude and record them in apm.lock.yaml.The decision lives in one place,
src/apm_cli/commands/uninstall/recorded_targets.py. The new module is registered under theskills-root-derivationowner alongsideengine.py._sync_integrations_after_uninstallcalls it once, afterresolve_reintegration_targets. No second target resolver is added. Cleanup of the removed packages' own files is unchanged.Issue and approved scope
Issue: Fixes #4636
Human scope-approval comment: #4636 (comment)
Does this PR complete the issue, or what remains? It completes the fix. The done-when cells (
test_command_after_a_target_change[uninstall-*]intests/lifecycle/scenarios/test_history_upgrade.py) live on the Q&L corpus train 3 branchdanielmeppiel-w3-t6a-historyand are not on main yet. I ran them locally against this branch with their #4636 strict known-cell markers removed:deployed file is not in the lock: .claude/skills/p-skill/SKILL.md.Q&L retires the #4636 known cells: the I1 rows and the
uninstall-new-target-skipped-hint-repeatsoutput cell. This is coordinated through the Q&L inbox, so the cells are not duplicated here.Type of change
Testing
Local results, run through the host guard:
tests/unit/test_uninstall_engine_validation_logic.py: 28 passed. They cover:manifest_targetsthat is not evidence;[copilot], thentargets: [claude], then two consecutive uninstalls. Both print the advice, and no.claude/exists after either.APM_E2E_TESTS=1: 4 passed.pytest -n 2across 8 uninstall integration and lifecycle modules (engine coverage, multi, survivor output, skill selection, summary, global exact removal, LSP recorded targets, wave6): 79 passed, 2 skipped.pytest -n 2 tests/integration/test_architecture_owner_rule_mutations.py tests/unit/scripts/test_architecture_runner.py tests/quality/test_quality_baselines.py: 1334 passed.tests.quality.taxonomy --changed, andlint_architecture_boundaries.py --root ..engine.pystays at 2087 lines, under the 2100 guardrail.tests/fixtures/lifecycle_bug_ledger/bugs/4636.json, andtests/quality/test_lifecycle_bug_ledger.pypasses.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)