Repository navigation
fix(install): a refused native registration restores the previous lockfile byte for byte - #4689
Merged
Daniel Meppiel (danielmeppiel) merged 5 commits intoNov 22, 2026
Conversation
…kfile byte for byte When native plugin declaration fails (for example a user's own file at a Claude plugin bin path), claude_plugins.run rolls apm.lock.yaml back to the previous lock carrying the MCP/LSP records reconciliation wrote. The rollback always re-recorded the MCP target servers, so an unchanged lock gained an empty mcp_target_servers field and the refused install changed the lockfile. The rollback now returns the previous lock untouched when no MCP/LSP record changed. Fixes #4685 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 21, 2026 20:41
Refs #4685 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Rollback logic conflates type-distinct MCP values and fails to restore the original lockfile bytes, risking stale baselines and altered timestamps or lost comments.
2 open issues
What changed in this PR
This PR addresses #4685 in APM's native Claude plugin rollback path, avoiding an added empty mcp_target_servers field when registration fails and service records are unchanged.
Changes:
- Return the previous lock unchanged when MCP/LSP records compare equal.
- Add regression coverage and a lifecycle bug-ledger entry.
- Document the user-visible fix in a changelog fragment.
| File | Description |
|---|---|
tests/unit/install/test_services_before_native_registration.py |
Adds unchanged-service rollback regression coverage. |
tests/fixtures/lifecycle_bug_ledger/bugs/4685.json |
Records the bug and links its regression test. |
src/apm_cli/install/phases/claude_plugins.py |
Adds service-record comparison and an unchanged-record fast path. |
changelog.d/4689.fixed.md |
Describes the refused-registration lockfile fix. |
Review effort: Balanced
…istration Review: returning the previous LockFile still reserialized it, refreshing a legacy generated_at and dropping comments. The phase now captures the on-disk lock before its commit and restores those bytes through restore_lockfile_bytes when no MCP/LSP record changed; service records compare type-sensitively (_json_identity), so 1 and true differ. Refs #4685 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Refs #4685 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The change restores the previous lockfile bytes when native plugin declaration fails; it adds no OpenAPM-observable behaviour. apm-spec-waiver: rollback restores pre-install lockfile bytes; no OpenAPM-observable behaviour change Refs #4685 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-fix-refused-native-rollback-lock
branch
November 22, 2026 08:25
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 22, 2026
… are fixed #4689 fixed #4685 and b0d62e2 fixed #4697 on main, so both pair cells (bin and lsp, DEPLOYED=unowned) are required: drop the strict known expectations, the scenario's known map entries, and the known-failing status in lifecycle_obligations.json. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

Description
When native plugin declaration fails (for example,
apm install -g --trust-binrefuses because a user's own file sits at a Claude plugin'sbin/path),claude_plugins.runrollsapm.lock.yamlback to the previous lock. The rollback also carries the MCP/LSP records that reconciliation wrote (#4329). It always re-recorded the MCP target servers, which marks the field present, so an unchanged lock gainedmcp_target_servers: {}. The refused install therefore changed the lockfile (I7: a failed command preserves state).The fix is in
_with_reconciled_services(install/phases/claude_plugins.py). When the committed MCP/LSP records equal the previous lock's, the previous lock is returned untouched, so the rollback restores it byte for byte. When reconciliation did change records, they are still carried as before.Issue and approved scope
Issue: Fixes #4685
Human scope-approval comment: #4685 was filed and routed by the Q&L lead as the regression owner's fix (a regression from #4579 / #4329). Its scope is the rollback owner only.
Does this PR complete the issue, or what remains? It completes it. The lifecycle scenario cell that found it (
test_ownership_siblings.py::test_a_users_file_at_the_plugin_bin_path_refuses_the_plugin, strict known cell#4685) is on the corpus train branch, not on main. That train retires the known cell once this lands. I checked locally that the cell passes with this fix applied.Type of change
Testing
Commands run (local, through the host guard):
pytest tests/unit/install/test_services_before_native_registration.py: 7 passed. With the source change reverted, the new case fails.pytest tests/lifecycle/scenarios/test_ownership_siblings.py -k plugin_bin: 3 passed.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)
CONFORMANCE.{md,json}regenerated