Repository navigation
fix: keep Codex MCP identity outside native settings - #3157
sama Pyb (Pybsama) wants to merge 17 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The changelog entry does not use the required pull-request-number suffix.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Removes unsupported Codex MCP id settings while preserving registry identity and ownership-safe migration.
Changes:
- Stores registry IDs in escaped TOML comments.
- Migrates only APM-owned legacy entries.
- Adds lifecycle coverage and consumer guidance.
| File | Description |
|---|---|
src/apm_cli/adapters/client/codex.py |
Implements comment metadata and migration. |
src/apm_cli/core/conflict_detector.py |
Reads Codex registry metadata. |
src/apm_cli/install/mcp/ownership.py |
Preserves conservative legacy adoption. |
src/apm_cli/integration/mcp_integrator_install.py |
Runs owned-entry migration. |
src/apm_cli/registry/operations.py |
Detects installed Codex UUIDs. |
tests/unit/test_codex_mcp_native_schema.py |
Covers schema and migration behavior. |
tests/unit/test_codex_adapter_phase3.py |
Updates native-setting expectations. |
tests/unit/test_codex_adapter_compatibility.py |
Updates compatibility expectations. |
tests/integration/test_codex_mcp_schema_lifecycle.py |
Tests CLI regeneration and convergence. |
docs/src/content/docs/consumer/install-mcp-servers.md |
Documents metadata and migration limits. |
CHANGELOG.md |
Records the fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a # Conflicts: # src/apm_cli/install/mcp/ownership.py
APM Review Panel:
|
| Workflow | Result |
|---|---|
| CI | success |
| CodeQL | success |
| Docs | success |
| Merge admission check | success |
| NOTICE Drift | success |
| Spec conformance | success |
Uploaded CodeQL analyses 1966054287 (Python) and 1966050912 (Actions) have zero results and match observed synthetic merge 6bb96c10, whose parents are bd672981 and 07a3e307.
Current compatibility and admission
A separate strict merge preview against newer main 6333b56a succeeds; all 14 incoming-only paths preserve main's exact blobs. This preview is not a claim that the functional suite or CI tested that newer main. GitHub reports MERGEABLE. The live account has admin=false, maintain=false, push=true; platform admission remains the parent's independent responsibility. No permission workaround or empty push was attempted.
Convergence
Counters retained: 3 outer iterations, 2 Copilot rounds, 1 CI-recovery iteration. No additional broad panel or review request.
Retained narrow panel findings
Test-coverage-expert: no findings. The test-only recovery strengthens native-ID assertions and adds four genuine frozen conformance cases without weakening safeguards. The CEO retained ship_now; the preceding seven-specialist clean delta remains the broad-review provenance.
Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.
Fold the panel migration-feedback, documentation, changelog and decoder follow-ups for microsoft#3157 within the approved microsoft#3087 scope. Lifecycle assertions distinguish repair from fresh/no-op installs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Keep main runtime-header regression coverage while asserting the native-schema repair in microsoft#3157; the old pop(id) assumed the unsupported field was still emitted. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Retain candidate config mappings so the existing OpenCode enabled-intent guard remains recognizable while the Codex UUID exclusion applies only to Codex. No ownership policy or other-target behavior changes. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
…tions Exercise req-lk-006 through real project/user CLI installs before Codex legacy repair. Preserve UUID lookup assertions and exact lifecycle output without unsupported native IDs. No conformance waiver or normative requirement change. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Resolve the real changelog conflict by retaining both native Codex repair and SSH marketplace entries. Preserve all current-main code, conformance, documentation and dependency changes; no Codex behavior changed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Carry the approved local target provenance, sibling-claim and conservative historical preservation changes into the Codex candidate before final combined-tree validation. Keep both changelog entries unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a

Description
APM writes an
idsetting into Codex MCP server entries, but Codex's native schema rejects that field. Stop emitting it for stdio and HTTP servers, and retain registry UUID matching in an escaped TOML comment. Conflict detection and installed-server lookup read that metadata, including legacy IDs, without treating it as proof of ownership.On MCP regeneration, remove legacy IDs only from entries recorded as APM-owned. Preserve the existing narrow adoption rule for legacy self-defined entries that exactly match the saved baseline; a nonempty UUID disqualifies that adoption. Unrelated user entries and settings stay outside migration. Inline MCP containers being written and owned inline entries being repaired may expand into regular tables, retaining their values and comments. Reparse the serialized TOML before atomically writing it. The consumer documentation explains regeneration and ownership limits.
Issue and approved scope
Fixes #3087.
Human scope approval: #3087 (comment)
This completes the bounded Codex adapter repair. It adds no shared MCP schema, target, credential model, or trust policy.
Type of change
Testing
Regression tests cover both transports, save/reparse UUID alias matching, owned migration, unowned and edited-entry preservation, and legacy baseline adoption. Hermetic project- and user-scope CLI tests verify regeneration and convergence.
Generated stdio and HTTP configurations were validated against the official Codex schema and the installed Codex CLI
0.159.0-alpha.12.1in strict mode. MCP entries were disabled during initialization, so no MCP server was launched. This validates that client version, not all Codex releases.Final focused adapter/conflict/ownership/integrator/lifecycle suite: 569 passed. The schema/ownership/lifecycle subset also passes with the declared minimum
tomlkit==0.13.0: 74 passed.Eight final runtime fixtures pass official-schema validation and strict Codex initialization with exit code 0 and empty stderr: two fresh transport configurations in an empty inline MCP container, plus legacy stdio/HTTP entries in standard, out-of-order, inline-child, nested-inline-parent, dotted-container, and dotted-root layouts. Regression tests also cover deleting a legacy ID at the beginning, middle, or end of an inline table.
Full-source Ruff lint/format and pylint duplication checks, architecture/auth boundaries, YAML I/O/file-length/portable-path guards, and assertion/duplicate-test quality checks pass. The full functional suite, Windows runtime, and other Codex versions were not tested locally.
Spec conformance (OpenAPM v0.1)
No normative requirement changes. This repairs output for an existing client adapter while preserving APM's ownership and conflict safeguards; it introduces no new manifest, lockfile, or native configuration setting.