Repository navigation
fix(install): reconcile MCP/LSP before native Claude registration commits the lockfile (#4329) - #4579
Merged
Daniel Meppiel (danielmeppiel) merged 15 commits intoNov 21, 2026
Conversation
…mits the lockfile (#4329) MCP and LSP reconciliation now runs inside the install pipeline as a services phase ahead of claude_plugins, so native registration's lockfile flush is the install's single commit and the lock matches disk there. A reconcile failure the lockfile authority still commits registers native plugins first; a refusal registers nothing. Co-authored-by: Copilot App <[email protected]>
…l-fix-4329-single-lock-write
…4329) Route the call-time service options through the install command so the target-selection and frozen guards keep their seams; own the services phase under the lockfile write authority; extend the install commit-order guard (services before claude_plugins) with a mutation case. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 21, 2026 09:41
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical rollback gap leaves reconciled MCP/LSP service configurations on disk without matching ownership records when native Claude registration fails.
1 open issue
What changed in this PR
This PR addresses #4329 by moving MCP/LSP reconciliation into the install pipeline before native Claude registration, so its lockfile commit includes service ownership records.
Changes:
- Adds a services phase with deferred failure handling and command-level fallback.
- Reuses the lockfile authority’s failure decision to control native registration.
- Strengthens ordering guards and regression coverage for single-write installs.
| File | Description |
|---|---|
tests/unit/install/test_services_before_native_registration.py |
Tests ordering, commit counts, and failure handling. |
tests/integration/test_claude_native_hook_lifecycle.py |
Requires the single-write regression and adds LSP assertions. |
tests/integration/test_architecture_owner_rule_mutations.py |
Adds a services-ordering mutation case. |
tests/fixtures/lifecycle_bug_ledger.json |
Records #4329 and its regression coverage. |
src/apm_cli/install/service.py |
Passes reconciliation into the pipeline. |
src/apm_cli/install/service_integration.py |
Wraps reconciliation results and deferred failures. |
src/apm_cli/install/request.py |
Adds the reconciliation callback option. |
src/apm_cli/install/pipeline.py |
Runs services before Claude registration. |
src/apm_cli/install/phases/services.py |
Implements reconciliation and registration eligibility. |
src/apm_cli/install/phases/finalize.py |
Exposes the kept-overwrite failure check. |
src/apm_cli/install/context.py |
Holds the callback and deferred service failure. |
src/apm_cli/deps/lockfile_write_authority.py |
Exposes the existing commit-on-failure decision. |
src/apm_cli/commands/install.py |
Supplies service options and settles reconciliation. |
scripts/architecture_linter/checks/install_entry_and_commit.py |
Enforces service ordering before registration and scripts. |
CHANGELOG.md |
Documents the single-write fix. |
.apm/architecture/owners/contracts-tooling.json |
Registers the services phase under lockfile authority. |
Review effort: Balanced
…4329) The phase tests now read the lockfile on disk when native registration declares and at the end, instead of patching the atomic writer. apm-spec-waiver: internal phase ordering; lock content and OpenAPM-observable behaviour unchanged, only the write count drops to one Co-authored-by: Copilot App <[email protected]>
…l-fix-4329-single-lock-write
…l-fix-4329-single-lock-write
… rolls back (#4329) Services now reconcile before native Claude registration, so a failed declaration that restores the previous lock (req-na-004) keeps the MCP and LSP records for what reconciliation already wrote, on a first install and over an existing lock. apm-spec-waiver: req-na-004 rollback unit unchanged; only the service records that reached disk are kept Co-authored-by: Copilot App <[email protected]>
…l-fix-4329-single-lock-write
…l-fix-4329-single-lock-write
…le owner (main red) #4037 added deps/lockfile_lookup.py to the read-only-lockfile-path owner; the pack lockfile read test still pinned one selector, so Integration Tests failed on main and on every PR merge group. Co-authored-by: Copilot App <[email protected]>
…l-fix-4329-single-lock-write # Conflicts: # tests/integration/test_architecture_pack_lockfile_read.py
…iel-fix-4329-single-lock-write
…sed-wip # Conflicts: # tests/fixtures/lifecycle_bug_ledger.json
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-fix-4329-single-lock-write
branch
November 21, 2026 18:32
This was referenced Nov 21, 2026
Merged
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
apm installwith a native Claude plugin and MCP or LSP servers wroteapm.lock.yamltwice: native registration flushed the staged lockfile (claude_pluginsphase), then MCP/LSP reconciliation ran after the pipeline and the INSTALL writer scope committed a second time at exit.MCP/LSP reconciliation now runs inside the install pipeline as a
servicesphase, after the deploy gates andcopilot_plugins/codex_plugins, and beforeclaude_plugins. Claude's lockfile flush is then the install's single commit, and the lock equals disk at that commit.install/phases/services.py(new, owned bylockfile-write-authority): calls the caller's reconciliation hook with the pre-commitInstallResult. An install that finalize will fail reconciles nothing, as before. A reconcile failure is kept on the context: native registration still runs when the lockfile authority commits on that failure (an MCP collision after other servers were written), so the committed native records are on disk. A refusal (org policy) registers nothing and the staged lock is discarded. The caller then raises the original error, at the point where it was raised before.deps/lockfile_write_authority.py:commits_on_failure(error)exposes the owner's existing_commitsdecision. There is no second authority, and no new commit or flush site (contracts-tooling-lockfile-write-authorityis unchanged and green).install/service_integration.py:ServiceReconciliationwrapsrun_service_integrationsand the PolicyBlock/RequiredIntegration rendering the command did before. The command reads call-time options from the pipeline result. If no pipeline ran the hook (--only mcp, no APM deps, no-work installs), the command runs it afterwards, as before.--frozenpasses no hook (it writes no lockfile), so its service order is unchanged.apm updateandapm lockpass no hook and are unchanged.install-deployment-install-commit-ordernow also requires_run_phase("services")before_run_phase("claude_plugins"), plus a mutation case (commit-order-native-commit-before-services).commands/install.py: 2082 -> 2081 lines.pipeline.pystays within its LOC budget. The complexity ratchet is clean and the baseline did not grow.Issue and approved scope
Issue: Fixes #4329. Refs #4565 (epic).
Human scope-approval comment: #4329 (comment)
Completes the issue. Out of scope and unchanged: what MCP/LSP records in the lock. Sequencing note: #4559 rewrites the same native registration path. This PR rebases onto it once it lands.
Type of change
Testing
Evidence (lifecycle-tests skill):
Commands run locally (macOS):
pytest tests/unit/install/test_services_before_native_registration.py-> 4 passedpytest tests/unit/install tests/unit/commands tests/unit/test_install_*-> 4479 passed (installer-script shell tests deselected: they time out on this shared host and do not touch this change)pytest tests/integration/test_claude_native_hook_lifecycle.py test_lockfile_commit_point_lifecycle.py test_lockfile_write_authority_lifecycle.py test_opencode_lsp_lifecycle.py test_policy_announced_once_lifecycle.py test_gitlab_subgroup_policy_lifecycle.py(real binary) -> 37 passed, 22 skipped (inotify/platform), 3 xfailed (other issues)pytest tests/integration/test_architecture_owner_rule_mutations.py tests/integration/test_architecture_lockfile_write_authority.py tests/unit/scripts/test_architecture_runner.py-> passedpytest tests/quality/test_lifecycle_bug_ledger.py-> 2 passedChangelog
## [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