Repository navigation
fix(install): record a local bundle's MCP server only where the install claims it - #4657
Merged
Daniel Meppiel (danielmeppiel) merged 6 commits intoNov 22, 2026
Merged
Conversation
…ll claims it Reinstalling a local bundle after apm.lock.yaml was lost recorded its MCP server with bundle provenance although the identical .mcp.json entry was not APM's (equality never establishes ownership), so audit --ci and install --frozen rejected the lock. The bundle install now records only the servers it claims on a runtime and names the unmanaged entry to remove. Fixes #4634 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 17:48
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The warning incorrectly treats an unsupported-transport skip as an unmanaged entry, prompting users to remove a nonexistent entry and reinstall without resolving the issue.
1 open issue
What changed in this PR
Fixes local-bundle reinstalls after a lost lockfile by recording MCP servers only when the install claims ownership on at least one runtime. This preserves unmanaged entries while avoiding lock state rejected by audit and frozen install.
Changes:
- Filters bundle MCP lock records by runtime ownership and adds a remediation warning.
- Adds unit and real-CLI regression coverage, including recovery after removing an unmanaged entry.
- Records the regression in the bug ledger and changelog.
| File | Description |
|---|---|
tests/unit/install/test_owned_mcp_integration.py |
Verifies only claimed servers are recorded while unrelated records remain. |
tests/lifecycle/test_local_bundle_lost_lock_mcp.py |
Covers lost-lock reinstall, gate acceptance, entry preservation, and recovery. |
tests/fixtures/lifecycle_bug_ledger/bugs/4634.json |
Links the ownership and outcome regression to its tests. |
src/apm_cli/install/mcp/integration.py |
Filters bundle lock records and reports unrecorded selected servers. |
changelog.d/4657.fixed.md |
Documents the user-visible reinstall fix. |
Review effort: Balanced
Co-authored-by: Copilot App <[email protected]>
apm-spec-waiver: bug fix in bundle MCP lock recording; no OpenAPM-observable behaviour changes (#4634) Co-authored-by: Copilot App <[email protected]>
A server can stay unclaimed because a runtime skipped it (for example an unsupported transport); the remediation is printed only when a selected runtime's config holds an entry under that name. apm-spec-waiver: bug fix in bundle MCP lock recording; no OpenAPM-observable behaviour changes (#4634) Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
w2-fix-4634-bundle-lost-lock-mcp
branch
November 22, 2026 09:19
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 22, 2026
The local-bundle hook row at present-provenance-unknown credits its pair and asserts the converged pair state; the obligation is required. Co-authored-by: Copilot App <[email protected]>
This was referenced Nov 22, 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
Reinstalling a local plugin bundle after
apm.lock.yamlwas lost (apm install ./bundle.zip) exited 0. The lock it left was rejected by both gates.apm audit --cifailedconfig-consistencywithp-exec-mcp: in lockfile but not in manifest (declared by bundle:p-exec), andapm install --frozenexited 1 withMCP server 'p-exec-mcp' is no longer declared in apm.yml.Cause. With no lock, the bundle's server already sits in
.mcp.jsonas an identical entry that APM has no record of writing. The MCP integrator therefore treats it asMATCHING_FOREIGN: equality alone never establishes ownership (install/mcp/ownership.py). It claims no runtime and records no native-entry receipt for it.run_owned_mcp_integrationstill wrote the server intomcp_servers,mcp_configsandmcp_config_provenance(bundle:p-exec). The MCP view reads abundle:provenance back only as a deployment, meaning a claim with its receipt (mcp_config_view._bundle_owned_baseline). So the server became lock-only and both gates rejected it.Fix (owner:
install/mcp/integration.pyrun_owned_mcp_integration). A bundle install now records a server only when it claims it on at least one runtime. For a selected server left to an unmanaged entry, the install names the entry and the remedy, the same way the hook beside it is skipped in that step:Running that hint makes APM own the server again: the next reinstall records it with
bundle:p-execprovenance and both gates pass. A first bundle install and a reinstall with the lock in place record the same rows as before.Scope note: the approved scope says the reinstall "records the bundle's MCP servers exactly as a first bundle install does". A first install's record includes the native-entry receipt, which would require adopting an identical entry APM did not write. That conflicts with the ownership rule and with this issue's out-of-scope line (re-adopting what has unknown provenance, #4626). This PR leaves the entry with the user and keeps both gates green. If adoption is wanted instead, it is a change to
run_owned_mcp_integrationonly.Issue and approved scope
Issue: Fixes #4634
Human scope-approval comment: #4634 (comment) (the deviation noted above keeps the scope's out-of-scope line and the ownership rule)
Does this PR complete the issue, or what remains? It completes the fix. The T-6b lifecycle scenario named in "Done when" (
test_ownership_siblings.py::test_a_local_bundle_never_replaces_the_users_hook[present-provenance-unknown]) is not on main yet. Its strict known cells for #4634 are dropped when that corpus branch rebases onto this fix. This PR carries its own real-CLI regression test for the same flow.Type of change
Testing
Commands run locally (all passed):
pytest tests/lifecycle/test_local_bundle_lost_lock_mcp.py tests/integration/test_local_bundle_mcp_lifecycle.py tests/integration/test_local_bundle_mcp_retire_lifecycle.py(APM_E2E_TESTS=1): 9 passedpytest tests/unit/install/test_owned_mcp_integration.py tests/unit/install/test_copilot_project_mcp_destination.py tests/integration/test_architecture_lockfile_write_authority.py tests/quality/test_lifecycle_bug_ledger.py: 45 passedruff check/ruff format --check(0.15.12), pylint R0801,scripts/lint-auth-signals.sh,scripts/check_complexity_ratchet.py --base-ref origin/main,python -m tests.quality.taxonomy --changed,python -m tests.lifecycle.generator --check: cleanChangelog
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.