Repository navigation
fix(audit): fail audit --ci on a differing unrecorded native MCP entry - #4493
Merged
Daniel Meppiel (danielmeppiel) merged 5 commits intoNov 21, 2026
Merged
Daniel Meppiel (danielmeppiel) merged 5 commits into
Daniel Meppiel (danielmeppiel) merged 5 commits into
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]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…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]>
#4477) apm audit --ci now runs a native-mcp-ownership baseline check that uses the same ownership helper as install --frozen, so a user's MCP entry that differs from a declared server of the same name fails both. apm-spec-waiver: audit baseline check parity with install --frozen; no OpenAPM-observable requirement changes Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 19:44
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
MCP ownership checks can falsely reject excluded runtime entries and matching plugin-derived configs, and abort audits on unreadable or malformed Codex state.
3 open issues
What changed in this PR
This PR adds a native MCP ownership check to apm audit --ci to align its verdict with frozen install for conflicting user-owned entries, addressing #4477. It also includes the matching-entry handling from stacked PR #4470.
Changes:
- Add a baseline check that reports differing, unrecorded native MCP entries by server and target.
- Allow matching user-owned entries during frozen replay, including Codex entries disabled by the user.
- Extend lifecycle coverage, update check inventories, and document the behavior.
| File | Description |
|---|---|
tests/unit/policy/test_ci_checks.py |
Update the expected baseline-check count. |
tests/integration/test_required_lifecycle_state_machine.py |
Register the new audit rule. |
tests/integration/test_native_mcp_collision_lifecycle.py |
Cover matching entries, frozen replay, and audit conflicts. |
tests/integration/test_codex_native_plugin_lifecycle.py |
Distinguish native-cache and replay drift diagnostics. |
tests/fixtures/lifecycle_bug_ledger.json |
Record regression coverage for both fixes. |
src/apm_cli/policy/ci_checks.py |
Add and run the native MCP ownership check. |
src/apm_cli/install/service.py |
Accept matching unrecorded entries during frozen replay. |
src/apm_cli/install/mcp/ownership.py |
Add declaration matching and unrecorded-conflict detection. |
src/apm_cli/adapters/client/codex.py |
Ignore activation and normalize empty connection fields. |
packages/apm-guide/.apm/skills/apm-usage/governance.md |
Document the new baseline check. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Explain matching user-owned entries during install. |
docs/src/content/docs/reference/cli/install.md |
Clarify collision and frozen-replay behavior. |
docs/src/content/docs/reference/baseline-checks.md |
Describe the ownership check and remediation. |
CHANGELOG.md |
Add user-facing entries for both fixes. |
Review effort: Balanced
| state = compare_native_mcp_connection( | ||
| client, | ||
| name, | ||
| requested_info=MCPIntegrator._build_self_defined_info(dependency), |
Comment on lines
+134
to
+136
| except (TypeError, ValueError): | ||
| logger.debug("Could not compare %s MCP entry %s", runtime, name, exc_info=True) | ||
| return False |
Comment on lines
+187
to
+189
| for runtime in sorted(clients): | ||
| recorded = ownership.get(runtime, set()) | ||
| for name, stored in sorted((lockfile.mcp_configs or {}).items()): |
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…3 checks) #4065 pinned the exact ordered baseline; #4493 adds native-mcp-ownership after config-consistency. Interaction fix, no check dropped. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…migration #4493 (main-based) adds a free-text remedy to policy/ci_checks.py; the train's remediation-advice ratchet (#4090) counts it. Baselined (1 -> 2) so the gate-9 remedy migration renders it from core/remediation.py with the rest. Co-authored-by: Copilot App <[email protected]>
5 of 14 tasks
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-h-4477-audit-mcp-conflict
branch
November 21, 2026 05:24
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
apm audit --cinow runs anative-mcp-ownershipbaseline check. It fails when a runtime MCP config holds an entry, not recorded in the lockfile, that differs from a declared server with the same name. The check calls the same ownership helper asapm install --frozen(differing_unrecorded_native_mcp_entriesininstall/mcp/ownership.py), so both commands give the same verdict. An identical unowned entry still passes.Stacked on #4470 (head 719c757); the first commits in this diff belong to #4470.
Issue and approved scope
Issue: Fixes #4477
Human scope-approval comment: assigned in the 0.37 final release train by the maintainer-run PM.
Does this PR complete the issue, or what remains? Completes it.
Type of change
Testing
Evidence:
tests/integration/test_native_mcp_collision_lifecycle.py::test_user_disabled_matching_codex_connection_installs_and_replays_frozen: fails 2/2 without the src change (audit exits 0) and passes 2/2 with it. It asserts exit 1, the server and target are named, and the file bytes are unchanged.tests/unit/policy/test_ci_checks.py, MCP portable-approval lifecycle, transitive MCP audit e2e): 196 passed.test_ci_checkscount goes from 11 to 12, and_GLOBAL_AUDIT_RULESis updated.ruff checkandruff format --check(0.15.12) are clean on the changed files.Changelog
## [Unreleased]inCHANGELOG.md.Spec conformance (OpenAPM v0.1)