Skip to content

fix(mcp): a user's Codex entry equal to the declaration is no conflict on install or --frozen - #4470

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
godspeed-4449
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
godspeed-4449

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

A user's own Codex MCP entry that equals a self-defined declaration is not a conflict.

  • The Codex adapter compares connection identity: the command Codex runs and what it passes. The user's enabled switch is an activation choice, not part of the connection, and an empty args or env equals an absent one. Any other difference still fails closed.
  • apm install --frozen needs 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, via native_mcp_entry_matches_declaration in install/mcp/ownership.py).
  • The real-Codex module tests/integration/test_codex_native_plugin_lifecycle.py names 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 --frozen restore pass with a real Codex CLI. Genuine conflicts with user-authored entries still fail closed.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
Node id Result
tests/integration/test_native_mcp_collision_lifecycle.py::test_user_disabled_matching_codex_connection_installs_and_replays_frozen[project] green on branch
tests/integration/test_native_mcp_collision_lifecycle.py::test_user_disabled_matching_codex_connection_installs_and_replays_frozen[user] green on branch
tests/integration/test_codex_native_plugin_lifecycle.py (6 tests, real codex-cli 0.163.0 and 0.170.0) green on branch

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 passed
  • APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest tests/integration/test_codex_native_plugin_lifecycle.py with codex-cli 0.163.0 and 0.170.0 on PATH -> 6 passed each
  • uv run --extra dev pytest tests/quality/test_lifecycle_bug_ledger.py -> 2 passed
  • ruff check / ruff format --check, pylint R0801, scripts/lint-auth-signals.sh, scripts/check_complexity_ratchet.py --base-ref origin/main, scripts/lint_architecture_boundaries.py --root . -> clean

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

…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]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 18:43
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Codex native plugin restore after a missing cache reports an MCP server conflict

2 participants