Repository navigation
[0.38] fix(install): a failed MCP or LSP write restores the deploys and the lockfile (#4594) - #4681
Merged
Daniel Meppiel (danielmeppiel) merged 9 commits intoNov 22, 2026
Conversation
…lockfile (#4594) The install transaction still holds its deploy journal while service integrations run inside the lockfile writer scope; a failure there now rolls back before the scope commits. MCP collisions keep the writes that reached disk (#4268). Co-authored-by: Copilot App <[email protected]>
#4594) Keeps _install_apm_packages within the complexity limit; the commit-order guard now requires the restoring call, with a mutation cell; bug-ledger row and docs. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…-p2-4594-mcp-write-restore
Co-authored-by: Copilot App <[email protected]>
Main now reconciles MCP and LSP inside the pipeline while the lockfile is still staged (#4329), so the deploy journal is still live there: a failed reconciliation rolls the install transaction back, except an MCP collision, and native registration then registers nothing. The earlier hold of the journal past the lockfile commit is no longer needed. apm-spec-waiver: restores pre-command bytes under the existing req-pl-002 failing-check contract; no new OpenAPM-observable surface. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
marked this pull request as ready for review
November 21, 2026 22:28
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 21, 2026 22:28
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Service-failure rollback leaves successful MCP writes and native plugin registrations outside the transaction, risking unowned server entries and registrations inconsistent with restored packages and lockfiles.
4 open issues
What changed in this PR
This PR extends the install deploy journal from #4612 to roll back failed MCP/LSP reconciliation before the staged lockfile commits, addressing #4594.
Changes:
- Rolls back the install transaction on service failures while preserving MCP collision behavior.
- Adds rollback coverage and removes the MCP-write scenario’s known-failure allowance.
- Updates the ownership record, bug ledger, CLI documentation, and changelog.
| File | Description |
|---|---|
tests/unit/install/test_services_before_native_registration.py |
Tests rollback and native-registration suppression; uses the typed MCP collision. |
tests/lifecycle/scenarios/test_failure_phase.py |
Requires MCP-write failures to preserve pre-command state. |
tests/fixtures/lifecycle_bug_ledger/bugs/4594.json |
Records the fix and linked lifecycle regression. |
src/apm_cli/install/phases/services.py |
Adds transaction rollback and narrows native-registration eligibility. |
docs/src/content/docs/reference/cli/install.md |
Documents service-write rollback and the MCP collision exception. |
CHANGELOG.md |
Announces the install rollback behavior. |
.apm/architecture/owners/install-deployment.json |
Records service-failure rollback under the install transaction owner. |
Review effort: Balanced
…stration (#4594) - MCP adapter config writes (base, Claude, Codex, Hermes, IntelliJ) are journaled at the deploy write seam, so a later service failure restores them too. - MCP/LSP reconciliation runs before Copilot, Codex and Claude native registration, and a rolled-back reconciliation registers none of them. - An LSP user-entry collision keeps its writes like an MCP collision. - Unit cells assert the durable lockfile state and the restored MCP config. - The changelog line moves to changelog.d/4681.fixed.md. apm-spec-waiver: restores pre-command bytes under the existing req-pl-002 failing-check contract; no new OpenAPM-observable surface. Co-authored-by: Copilot App <[email protected]>
…lockfile (#4594) The #4086 single-write cell pinned the old record-what-reached-disk contract for this failure; it now asserts the restored state and zero lockfile writes. apm-spec-waiver: restores pre-command bytes under the existing req-pl-002 failing-check contract; no new OpenAPM-observable surface. Co-authored-by: Copilot App <[email protected]>
…-write-restore # Conflicts: # .apm/architecture/owners/install-deployment.json # docs/src/content/docs/reference/cli/install.md
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-p2-4594-mcp-write-restore
branch
November 22, 2026 09:21
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 22, 2026
…; main flipped its cell) Co-authored-by: Copilot App <[email protected]>
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
Builds on #4612 (#4282, merged): its deploy journal.
apm installwrites MCP and LSP configuration after the pipeline stagesapm.lock.yaml. When that write failed (for example.mcp.jsonis a directory), install exited 1 but kept the failed attempt's hooks and lockfile on disk. That is themcp-config-writerow oftests/lifecycle/scenarios/test_failure_phase.py.install/phases/services.pynow rolls the install transaction back when reconciliation fails: deployed files,apm.lock.yamlandapm.ymlkeep their pre-command bytes, and native Claude registration then registers nothing.MCPNativeConflictError) keeps the writes that reached disk and still registers, as documented (Detect MCP server config collisions during install preflight #4268).tests/unit/install/test_services_before_native_registration.pycovers the collision (now with the realMCPNativeConflictError) and the new rollback.The
lockfile-writerow of the same scenario is flipped by #4612.Issue and approved scope
Issue: Fixes #4594
Human scope-approval comment: #4594 (comment)
Does this PR complete the issue, or what remains? It completes the approved scope.
Type of change
Testing
Done when: the strict known cell
_LOCK_CHANGED(rowmcp-config-write) is removed and the row passes on the real binary; it still exits 1 with "MCP configuration failed for selected runtime(s): p-exec-mcp". The other rows of the scenario stay green.pytest "tests/lifecycle/scenarios/test_failure_phase.py::test_failed_install_preserves_state_and_recovers[mcp-config-write]"withsrc/from #4612.github/hooks/changed): red beforepytest tests/lifecycle/scenarios/test_failure_phase.py tests/integration/test_lockfile_commit_point_lifecycle.py tests/integration/test_intellij_mcp_config_lifecycle.py tests/integration/test_mcp_integrator_characterisation.py(installed CLI)pytest tests/integration/test_architecture_owner_rule_mutations.py tests/unit/installplus MCP integration files (after merging main)test_unix_install_ownership.py, unrelatedpytest tests/unit/install/test_services_before_native_registration.pypython scripts/lint_architecture_boundaries.py --root ., ruff 0.15.12 check/format, pylint R0801,lint-auth-signals.sh, complexity ratchet, taxonomyChangelog
## [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)
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.