You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[0.38] fix(install): refuse registry and recorded MCP collisions before any write (#4741) - #4763
#4268 (#4745) made apm install refuse a colliding self-defined MCP server
the lockfile never recorded before writing anything. Two cases still reached
the MCP write path, where the collision stopped the install after earlier
files were already written:
registry-backed servers;
servers the lockfile already records.
The install preflight (install/mcp/collision_preflight.py, called from check_before_deploy and, for service-only installs, from run_mcp_integration) now projects both cases through the same comparator, compare_native_mcp_connection, and reports a conflict with the same _report_native_conflict diagnostic before any write.
Registry servers. The server info is looked up the way the install
looks it up: the registry snapshot that org policy judged comes first, then
a fetch, with the declaration overlaid on top. A server whose render needs
values the MCP stage may prompt for (package environment variables,
runtime or package argument variables, docker ${...} args) is not
projected. Neither is one whose lookup fails. Both stay on the write path.
No prompt is ever shown in preflight.
Recorded servers. These are compared as managed, against the stored
declaration and every native hash the lockfile records for the name, on
any runtime. A pair counts as a conflict only when every baseline
conflicts. A conflict against a managed baseline implies a conflict as
unmanaged, so the MCP stage's comparison conflicts too, whatever ownership
it settles on (inherited shared-destination claims, migrations). This
avoids false refusals.
Not projected (left to the write-path backstop, which keeps the
writes that reached other targets): a --frozen replay of recorded claims
(adoptable root entries settle only in the MCP stage), and a lockfile from
APM 0.36 or earlier that records Copilot or VS Code claims (translated by split_mcp_claims in the MCP stage).
Three safeguards prevent false refusals:
check_before_deploy prepares the projected MCP set with the packages the
write plan routes to Claude natively (PackageDeploymentPlan.claude_native).
A now-native plugin's loose entry is therefore retired by the MCP stage, as
before, rather than refused. Claude routing is only queued during
integration, after this gate. The policy check's own inputs are unchanged.
A native config the comparator cannot read (for example an invalid server
map) is left to the MCP stage's own error.
A declaration with an invalid env map is not projected.
The write path keeps the same comparison as its backstop. No second collision
rule is added. The preflight reads the --frozen disposition through InstallService.frozen_disposition (it passes replay_claims), as the
frozen-flag reader guard requires.
Does this PR complete the issue, or what remains? It completes the issue.
These pairs cannot be projected without prompting, or settle only in the
MCP stage, so they stay on the write-path backstop:
a registry server whose render needs prompted environment or runtime
values;
a registry lookup that fails;
a --frozen replay of recorded claims;
a pre-0.37 lockfile with Copilot or VS Code claims.
Recorded-claim post-registration cell (P2 lead ruling; rationale): since #4594, MCP and LSP reconciliation runs before native registration. With this
PR, a colliding recorded claim is refused in preflight before any write,
including native registration.
The state "the lock claims commit-point-srv while ~/.claude.json holds
the user's entry" is created by the user's edit after a clean install. A
refused install must not write, so it cannot make the lock equal to disk. The
cell therefore asserts four things: the refusal, unchanged apm.lock.yaml
and ~/.claude.json bytes, an unchanged home tree, and that clearing the
entry converges with lock == disk.
The ruled "apm audit --ci reports the drift" assertion was dropped.
Verification showed that audit passes for a user-edited recorded native MCP
entry. That pre-existing gap is #4757.
Cells rewritten to the refusal contract, because they pinned a partial
write for a recorded or registry collision that is now refused before any
write:
test_partial_install_retains_deferred_names_in_active_target. The refusal
keeps the edited claim, so retiring the undeclared server then preserves the
user's entry and exits 1 until the user removes it. After that, the install
converges.
The write-path partial branch stays covered by the req-lk-006 spec cell test_partial_mcp_conflict_persistence_respects_lock_write_suppression, which
simulates an unprojectable pair.
Done-when mapping (all fail before this PR on the #4745 base and pass after):
test_a_colliding_registry_server_is_refused_before_any_write[project|user x claude|codex]:
a registry server colliding with a user entry exits 1 with the conflict
diagnostic;
the user config bytes are unchanged, and the other runtime is not
written;
no claim is recorded.
Control: after the user removes the entry, the install succeeds, and a
repeat install of the now-recorded registry server succeeds (no false
refusal).
a recorded self-defined server whose entry the user edited refuses
before any write;
the primitive change is not deployed;
.mcp.json and lockfile bytes are unchanged.
test_a_recorded_mcp_server_collision_is_refused_before_any_write[declaration]
(control): a changed declaration of the recorded server installs and
updates APM's entry.
test_a_recorded_mcp_server_collision_is_refused_before_any_write[user-edit]
and test_a_recorded_native_plugin_mcp_collision_is_refused_and_converges:
failed.
Spec Mode B: apm-spec-waiver trailer. This is local install ordering; no
manifest, lockfile or resolver contract changes.
Changelog
One fragment per section, changelog.d/<pr>.<section>.md, holding
one line: user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes only under upgrade notes; no Highlights; no
new lines under ## [Unreleased]. See changelog.d/README.md and .github/instructions/changelog.instructions.md.
…ite (#4741)
The install preflight now also projects registry servers whose render
needs no prompted value (looked up as their install looks them up) and
servers the lockfile records, compared as managed against every recorded
baseline and refused only when each one conflicts. A --frozen replay and
pre-0.37 Copilot/VS Code claims still settle in the MCP stage.
apm-spec-waiver: install-time MCP collision ordering is local client behaviour; no manifest, lockfile or resolver contract changes
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Collision preflight can reject matching foreign entries because it omits group-level environment overrides and can unexpectedly prompt for unresolved header values, violating its prompt-free contract.
Extends the existing MCP collision preflight to cover registry-backed and already-recorded servers, addressing #4741. Predictable conflicts are checked before deployment, while cases requiring prompts or later ownership resolution remain on the write-path backstop.
Changes:
Projects eligible registry configurations and recorded baselines through the existing collision comparator.
Wires the expanded preflight into package and service-only installs.
Adds refusal and convergence coverage, updates architecture guards, and documents deferred cases.
…le pair (#4741)
The install preflight now refuses the recorded collision this req-lk-006
cell used; the write-path branch stays reachable for pairs the preflight
declines (a registry render needing prompted values), simulated here.
Co-authored-by: Copilot App <[email protected]>
…eadable configs (#4741)
check_before_deploy prepares the projected MCP set with the write plan's
natively routed packages, so a now-native plugin's loose entry is retired
rather than refused; a config the comparator cannot read is left to the MCP
stage's own report; an invalid env map is not projected. Cells that pinned a
partial write for a recorded or registry collision assert the refusal.
apm-spec-waiver: install-time MCP collision ordering is local client behaviour; no manifest, lockfile or resolver contract changes
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The collision preflight can prompt for unresolved header variables and falsely reject valid installs because its environment inputs differ from the grouped write path.
Using only this dependency's environment overrides can falsely refuse a valid install: _install_registry_group pools collected values and overrides across the registry/runtime group (mcp_integrator_install.py:362-372). On Gemini, if A's header references ${VALUE} and a later server B overrides A's supplied VALUE, an existing foreign A entry matching the pooled value conflicts with this per-dependency render, even without prompting. Reuse the write path's effective grouped inputs, or defer groups whose inputs cannot be determined without prompting, and add a two-server matching-entry control.
…v registry render to the install (#4741)
A remote header, URL or docker placeholder may make an adapter prompt, and
declared env feeds the install's group-wide overrides, so neither is
projected. The deferred-names cell no longer asserts ownership of an entry
the preserved retirement wrote unrecorded.
apm-spec-waiver: install-time MCP collision ordering is local client behaviour; no manifest, lockfile or resolver contract changes
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Active preflight defects reject valid installs with mixed claims or shared registry inputs and allow legacy header placeholders to trigger interactive prompts, violating the prompt-free contract.
No open issues 🎉
3 previously missed issues
In code that hasn't changed since last review
Detect legacy placeholders to keep preflight prompt-free
Legacy <VAR> header placeholders still bypass this check. A Gemini registry remote with X-Custom: <MISSING_VALUE> can therefore call Prompt.ask during preflight when the variable is unset and the terminal is interactive, violating the prompt-free contract. Use the adapter's placeholder detector alongside the existing ${ check, and add an interactive prompt-trap regression test.
Defer preflight for arguments using group-level inputs
_needs_input accepts an argument such as {"type": "named", "name": "--org", "value": "{org}"} when that server has no variables declaration. If another server in the registry group supplies org, installation renders the shared value while preflight renders literal {org}, falsely rejecting a matching foreign connection. Defer argument templates that consume group-level inputs, and add a matching-foreign control with two registry servers.
Preserve hashless claims when fingerprinted claims coexist
A recorded, hashless Codex claim loses its None baseline when another runtime has a fingerprint for the same server. Codex accepts legacy env: {TOKEN: "${TOKEN}"} entries without a receipt, but an unrelated fingerprint makes them conflict, so preflight rejects an otherwise valid install. Preserve None for recorded claims lacking fingerprints and add a mixed hashless/fingerprinted-claim regression control.
… the --mcp preflight (#4759)
#4763 renamed refuse_unrecorded_mcp_collisions; the direct --mcp preflight,
its architecture guard edge and mutation case now use the new owner name.
Co-authored-by: Copilot App <[email protected]>
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
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
#4268 (#4745) made
apm installrefuse a colliding self-defined MCP serverthe lockfile never recorded before writing anything. Two cases still reached
the MCP write path, where the collision stopped the install after earlier
files were already written:
The install preflight (
install/mcp/collision_preflight.py, called fromcheck_before_deployand, for service-only installs, fromrun_mcp_integration) now projects both cases through the same comparator,compare_native_mcp_connection, and reports a conflict with the same_report_native_conflictdiagnostic before any write.looks it up: the registry snapshot that org policy judged comes first, then
a fetch, with the declaration overlaid on top. A server whose render needs
values the MCP stage may prompt for (package environment variables,
runtime or package argument variables, docker
${...}args) is notprojected. Neither is one whose lookup fails. Both stay on the write path.
No prompt is ever shown in preflight.
declaration and every native hash the lockfile records for the name, on
any runtime. A pair counts as a conflict only when every baseline
conflicts. A conflict against a managed baseline implies a conflict as
unmanaged, so the MCP stage's comparison conflicts too, whatever ownership
it settles on (inherited shared-destination claims, migrations). This
avoids false refusals.
writes that reached other targets): a
--frozenreplay of recorded claims(adoptable root entries settle only in the MCP stage), and a lockfile from
APM 0.36 or earlier that records Copilot or VS Code claims (translated by
split_mcp_claimsin the MCP stage).Three safeguards prevent false refusals:
check_before_deployprepares the projected MCP set with the packages thewrite plan routes to Claude natively (
PackageDeploymentPlan.claude_native).A now-native plugin's loose entry is therefore retired by the MCP stage, as
before, rather than refused. Claude routing is only queued during
integration, after this gate. The policy check's own inputs are unchanged.
map) is left to the MCP stage's own error.
The write path keeps the same comparison as its backstop. No second collision
rule is added. The preflight reads the
--frozendisposition throughInstallService.frozen_disposition(it passesreplay_claims), as thefrozen-flag reader guard requires.
Issue and approved scope
Issue: Fixes #4741
Human scope-approval comment: #4741 (comment) (amended apm-scope:v1 record; earlier amendment #4741 (comment))
Does this PR complete the issue, or what remains? It completes the issue.
These pairs cannot be projected without prompting, or settle only in the
MCP stage, so they stay on the write-path backstop:
values;
--frozenreplay of recorded claims;Recorded-claim post-registration cell (P2 lead ruling; rationale): since
#4594, MCP and LSP reconciliation runs before native registration. With this
PR, a colliding recorded claim is refused in preflight before any write,
including native registration.
The state "the lock claims
commit-point-srvwhile~/.claude.jsonholdsthe user's entry" is created by the user's edit after a clean install. A
refused install must not write, so it cannot make the lock equal to disk. The
cell therefore asserts four things: the refusal, unchanged
apm.lock.yamland
~/.claude.jsonbytes, an unchanged home tree, and that clearing theentry converges with lock == disk.
The ruled "
apm audit --cireports the drift" assertion was dropped.Verification showed that audit passes for a user-edited recorded native MCP
entry. That pre-existing gap is #4757.
Cells rewritten to the refusal contract, because they pinned a partial
write for a recorded or registry collision that is now refused before any
write:
test_partial_install_retains_deferred_names_in_active_target. The refusalkeeps the edited claim, so retiring the undeclared server then preserves the
user's entry and exits 1 until the user removes it. After that, the install
converges.
test_registry_partial_conflict_does_not_skip_managed_self_defined_update.test_installed_global_prune_intersects_each_targets_ownership.The write-path partial branch stays covered by the req-lk-006 spec cell
test_partial_mcp_conflict_persistence_respects_lock_write_suppression, whichsimulates an unprojectable pair.
Done-when mapping (all fail before this PR on the #4745 base and pass after):
test_a_colliding_registry_server_is_refused_before_any_write[project|user x claude|codex]:diagnostic;
written;
repeat install of the now-recorded registry server succeeds (no false
refusal).
test_a_recorded_mcp_server_collision_is_refused_before_any_write[user-edit]:before any write;
.mcp.jsonand lockfile bytes are unchanged.test_a_recorded_mcp_server_collision_is_refused_before_any_write[declaration](control): a changed declaration of the recorded server installs and
updates APM's entry.
test_a_recorded_native_plugin_mcp_collision_is_refused_and_converges:the recorded-claim fixture moved from Detect MCP server config collisions during install preflight #4268, as described above.
Type of change
Testing
Validation evidence (host under a test cap: targeted files only, heavy suites on CI):
test_a_colliding_registry_server_is_refused_before_any_write: 4 failed.test_a_recorded_mcp_server_collision_is_refused_before_any_write[user-edit]and
test_a_recorded_native_plugin_mcp_collision_is_refused_and_converges:failed.
test_a_colliding_registry_server_is_refused_before_any_write: 4 passed.tests/integration/test_lockfile_commit_point_lifecycle.py: see the CIintegration run.
ruff check/ruff format --check(0.15.12, CI paths): clean.scripts/lint_architecture_boundaries.py --root .: exit 0 (frozen-flagreader guard satisfied).
pylint R0801: 10.00/10.lint-auth-signals.sh: clean.check_complexity_ratchet.py --base-ref main: clean.check_test_assertions.py: ratchet clean.tests.quality.taxonomy --changed: clean.apm-spec-waivertrailer. This is local install ordering; nomanifest, lockfile or resolver contract changes.
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