Repository navigation
fix(install): retire a native Claude plugin when apm.yml drops claude (#4744) - #4751
Daniel Meppiel (danielmeppiel) merged 10 commits into
Conversation
…#4744) Co-authored-by: Copilot App <[email protected]>
apm-spec-waiver: bug fix that retires a native Claude plugin when apm.yml drops claude, matching existing target contraction (#4517); no new normative surface. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Two critical findings show that removing the Claude target can leave its plugin registration untracked or enabled across lockfile-only and partial installs, while updated target records prevent later installs from detecting the contraction.
2 open issues
What changed in this PR
This PR addresses #4744 by retiring user-scope native Claude plugins when apm.yml drops claude, while preserving them for one-shot target overrides.
Changes:
- Centralizes detection of dropped manifest targets.
- Uses that detection to stop carrying forward native Claude plugin ownership.
- Adds a lifecycle regression test, bug-ledger entry, and changelog fragment.
| File | Description |
|---|---|
tests/lifecycle/scenarios/test_ownership_siblings.py |
Tests plugin retirement after narrowing user-scope targets. |
tests/fixtures/lifecycle_bug_ledger/bugs/4744.json |
Records the bug and its regression test. |
src/apm_cli/install/phases/lockfile.py |
Suppresses native plugin carry-forward when Claude is dropped. |
src/apm_cli/install/manifest_reconcile.py |
Shares prior-declaration logic for target contraction. |
changelog.d/4751.fixed.md |
Documents the user-visible cleanup fix. |
Review effort: Balanced
…aude is undeclared (#4744) Review fold: apply the target-contraction rule (claude neither declared in apm.yml nor active) to the final merged lock, so a partial install retires untouched plugins; apm lock keeps the records since it never touches deployed state. Reverts the manifest_targets-based rule: a refreshed declaration must not hide the drop. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Frozen installs can miss native-only target mismatches and retain stale state, while retirement lacks regression coverage for preserving user-edited plugin files.
3 open issues
2 resolved since last review
Review effort: Balanced
…aude plugins (#4744) Review fold for #4751: - target_governance.target_retired is the single dropped-target predicate; manifest_reconcile._dropped_target_of and the native plugin retirement in phases/lockfile.py both use it. - dropped_target_files includes native Claude plugin roots, so install --frozen refuses and audit --ci reports a dropped claude (as for files, #4517). - Scenario: an edited plugin bin/ is kept and reported while ownership and the Claude registration retire (scope control); frozen refusal changes nothing. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
A critical lockfile reconciliation issue can hide pending native-plugin retirement from frozen preflight and audit checks, and the documented retention rule is outdated.
2 open issues
3 resolved since last review
Review effort: Balanced
…gin (#4744) Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because shared lockfile objects can lose native-plugin ownership during dependency rescue, leaving plugin roots and settings behind after their lockfile records are removed.
No open issues 🎉
2 resolved since last review
Review effort: Balanced
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]> # Conflicts: # docs/src/content/docs/consumer/install-plugins.md
…lared (#4744) Review fold: attribution prefers a harness the lock's manifest_targets recorded, so the #4517 precedence filter in dropped_target_files keeps a project plugin root whose only recorded harness was copilot. Co-authored-by: Copilot App <[email protected]>
… regenerate Keeps #4843's native observation (a root half plus the enabledPlugins declaration half, native_gaps). Builds _surface_hits on train 5's entry-aware surfaces (JsonEntry, MergedHooks) and _observable. projected_cells keeps #4843's native projection plus the shared-root loose skill (#4559). #4751 fixed #4744, so the user-scope bin target-change cell drops its strict known and is required (known 9 -> 8, L15). Co-authored-by: Copilot App <[email protected]>



Description
At user scope, a Claude plugin that ships
bin/is activated natively: APM deploys the plugin root to~/.agents/plugins/<pkg>/, registers it in~/.claude/settings.json, and records anative_pluginrow in the lockfile. When the user narrowedtargets:from[copilot, claude]to[copilot], the nextapm install -g --trust-binreported "No changes" and kept the plugin root (includingbin/), its Claude registration and its lock record.Cause:
_attach_native_plugins(install/phases/lockfile.py) carries the priornative_pluginrecord forward whenever this run's targets exclude claude. That carry-forward is correct for a one-shotinstall -g --target codex, whereapm.ymlstill declares claude and the plugin must survive. It was wrong whenapm.ymlitself dropped claude.Fix, in the lockfile phase, using target contraction's rule (
manifest_reconcile._dropped_target_of: a target that is neither declared inapm.ymlnor active this run is dropped):_retire_undeclared_native_pluginsruns on the final merged lock, after_maybe_merge_partial. Whenapm.ymldeclares targets without claude and claude is not active, it clears everynative_pluginrecord, so a partial install also retires untouched plugins. The existing registrar (reconcile_claude_plugins) then retires the plugin root, catalog entry and Claude settings declaration.claude_plugins/registrar.pyandnative_plugins/are not changed, so this composes with feat(native): project-scope native plugins for Claude and Copilot (#3921, #3896) #4559.apm lock(lockfile-only) skips it: it never touches deployed state, so the records stay and the roots remain owned until the next install.manifest_targets, so a lock write that refreshed the declaration cannot hide the drop. This came from review.Unchanged: one-shot
--targetruns (test_claude_native_hook_lifecycle.pykeeps asserting the plugin survivesinstall -g --target codex), auto-detect manifests (no declaration means nothing is dropped), widening, and the U-BIN pin (plugin_bin_deployableand thebin/writer are untouched).Issue and approved scope
Issue: Fixes #4744
Human scope-approval comment: none posted yet when this PR opened; the change follows the issue's Expected behavior exactly. The review contact is the Regent-assigned lead.
Does this PR complete the issue, or what remains? Completes the behavior. The issue names a strict known cell
tests/lifecycle/scenarios/test_user_scope.py::test_a_target_change_keeps_a_plugin_bin_only_while_claude_is_declared[multi-narrowed]. That module is not onmain(it lives in the unmerged QL corpus train 5), so this PR adds its own failing-before cell onmain:test_ownership_siblings.py::test_target_narrow_retires_a_user_scope_plugin_bin. Once this lands, the train-5 strict cell XPASSes and must be flipped to required when that train rebases; the QL lead has been notified.Type of change
Testing
pytest tests/lifecycle/scenarios/test_ownership_siblings.py::test_target_narrow_retires_a_user_scope_plugin_bin(real binary)pytest -n 2on the 69 unit, integration and lifecycle modules touchingdropped_target_files,manifest_targets,native_pluginor Claude native activationpytest tests/quality/test_lifecycle_bug_ledger.pyuvx [email protected] check/format --check(CI paths)scripts/lint-auth-signals.sh,scripts/lint-architecture-boundaries.shscripts/check_complexity_ratchet.py --base-ref <main>python -m tests.quality.taxonomy --changedsrcfile)hook_integrator.py, untouched)tests/spec_conformance/mode_b_detector.shBug-ledger row:
tests/fixtures/lifecycle_bug_ledger/bugs/4744.json.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.
apm-spec-waiver: bug fix that retires a native Claude plugin when apm.yml drops claude, matching existing target contraction (#4517); no new normative surface.