Repository navigation
fix(mcp): a user's Codex entry equal to the declaration is no conflict on install or --frozen - #4470
Merged
Merged
Conversation
…t on install or --frozen (#4449) The Codex adapter compares connection identity: the user's enabled switch and empty args or env are not part of it. The --frozen services gate needs no recorded ownership for a self-defined server whose native entry already equals the declaration, since nothing is written and the entry stays the user's. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 18:43
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Managed rewrites can silently re-enable disabled servers, frozen replay can write without an ownership receipt, and existing collision tests contradict the new behavior.
7 open issues
Managed rewrites can silently re-enable disabled Codex servers · New Update frozen expectations for identical collision cases · New Frozen replay can write a replacement after preflight · New Normalize only correctly typed empty Codex fields · New Frozen precheck loses the dependency’s bound plugin root · New Frozen precheck resolves secret placeholders twice · New Self-defined entry exemption bypasses the approved plugin-owner scope · New
What changed in this PR
This PR addresses the Codex restore conflict reported in #4449 by allowing matching user-authored MCP entries to remain untouched and unowned during install and frozen replay.
Changes:
- Compares Codex connections without treating the user's activation switch or valid empty arguments and environment as differences.
- Adds a frozen-replay exception for matching, unowned self-defined MCP entries.
- Adds lifecycle coverage, broadens accepted cache-drift diagnostics, and records the fix.
| File | Description |
|---|---|
tests/integration/test_native_mcp_collision_lifecycle.py |
Adds matching-disabled-entry replay and genuine-conflict checks. |
tests/integration/test_codex_native_plugin_lifecycle.py |
Accepts either supported cache-drift diagnostic. |
tests/fixtures/lifecycle_bug_ledger.json |
Links #4449 to regression coverage. |
src/apm_cli/install/service.py |
Allows matching unowned entries through frozen preflight. |
src/apm_cli/install/mcp/ownership.py |
Adds self-defined native-entry matching. |
src/apm_cli/adapters/client/codex.py |
Normalizes connection identity for comparisons. |
CHANGELOG.md |
Documents the install and frozen-replay behavior change. |
Review effort: Balanced
Comment on lines
+247
to
+248
| if isinstance(comparable.get("enabled"), bool): | ||
| comparable.pop("enabled") |
| ): | ||
| deferred.add((name, target)) | ||
| continue | ||
| if service == "MCP" and native_mcp_entry_matches_declaration( |
| project_root=project_root, | ||
| user_scope=user_scope, | ||
| ): | ||
| continue |
| return { | ||
| key: value | ||
| for key, value in config.items() | ||
| if not (key in _EMPTY_AS_ABSENT and value in ([], {})) |
| if not isinstance(stored_config, dict) or stored_config.get("registry") is not False: | ||
| return False | ||
| try: | ||
| dependency = MCPDependency.from_dict(stored_config) |
Comment on lines
+127
to
+130
| state = compare_native_mcp_connection( | ||
| client, | ||
| name, | ||
| requested_info=MCPIntegrator._build_self_defined_info(dependency), |
| ): | ||
| deferred.add((name, target)) | ||
| continue | ||
| if service == "MCP" and native_mcp_entry_matches_declaration( |
…te-stable across install, --frozen and audit (#4449) An identical foreign self-defined entry needs no write, so install and --frozen both pass without claiming it; a differing entry is refused by both. Docs and the apm-usage guide state the same rule. Co-authored-by: copilot-swe-agent[bot] <[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
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
A user's own Codex MCP entry that equals a self-defined declaration is not a conflict.
enabledswitch is an activation choice, not part of the connection, and an emptyargsorenvequals an absent one. Any other difference still fails closed.apm install --frozenneeds no recorded ownership for a self-defined server whose native entry already equals the declaration. Nothing is written, and the entry stays the user's (install/service.py, vianative_mcp_entry_matches_declarationininstall/mcp/ownership.py).tests/integration/test_codex_native_plugin_lifecycle.pynames audit cache drift through either fail-closed diagnosis: the Codex native owner ("cache differs") or the integrity replay ("do not match apm.lock.yaml").Issue and approved scope
Issue: Fixes #4449
Human scope-approval comment: scope record on #4449 (last comment).
Does this PR complete the issue, or what remains? It completes it: the git-pinned install, cache removal and
--frozenrestore pass with a real Codex CLI. Genuine conflicts with user-authored entries still fail closed.Type of change
Testing
tests/integration/test_native_mcp_collision_lifecycle.py::test_user_disabled_matching_codex_connection_installs_and_replays_frozen[project]tests/integration/test_native_mcp_collision_lifecycle.py::test_user_disabled_matching_codex_connection_installs_and_replays_frozen[user]tests/integration/test_codex_native_plugin_lifecycle.py(6 tests, real codex-cli 0.163.0 and 0.170.0)Commands run locally:
APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest tests/integration/test_native_mcp_collision_lifecycle.py -k user_disabled-> 2 passedAPM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest tests/integration/test_codex_native_plugin_lifecycle.pywith codex-cli 0.163.0 and 0.170.0 on PATH -> 6 passed eachuv run --extra dev pytest tests/quality/test_lifecycle_bug_ledger.py-> 2 passedscripts/lint-auth-signals.sh,scripts/check_complexity_ratchet.py --base-ref origin/main,scripts/lint_architecture_boundaries.py --root .-> cleanChangelog
## [Unreleased]inCHANGELOG.md.Spec conformance (OpenAPM v0.1)