Skip to content

mcp: one header shape for registry servers; --frozen skips servers install refused - #5814

Open
Daniel Meppiel (danielmeppiel) wants to merge 6 commits into
mainfrom
mcp-exec-refusal-headers
Open

Daniel Meppiel (danielmeppiel) wants to merge 6 commits into
mainfrom
mcp-exec-refusal-headers

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Hardens the MCP env-reference owner introduced for #5773.

  • Header shape. A registry server's remote headers are stored as {name, value} entries at the overlay step (MCPIntegrator._canonicalize_remote_headers), so every writer and the owner read one shape. A payload that sends a mapping now renders on Codex, Gemini and Antigravity, which only read the list form.
  • Owner reads both forms. _declared_values in mcp_env_reference walks list-form and mapping-form headers.
  • --frozen matches install. refused_pairs also covers registry servers. The dependency overlay goes through the same _apply_overlay, without the payload, and a server refused on every target is not reported as a missing lockfile claim. The every-target check is one helper, _dependency_exec_refusal, shared with _exec_refusal.

Authored (root apm.yml) values are unchanged.

Note

Under --frozen, an unrecorded registry server whose header overlay is confirmed against the fetched payload now reports "unrecorded" even if a matching native entry exists (stricter than before).

Issue and approved scope

Issue: Refs #5773

Human scope-approval comment: the #5773 apm-scope record v3 (comment 7349125162) covers the dependency-value refusal in the shared owner.

Does this PR complete the issue, or what remains? #5773 was completed by #5777; this PR completes the owner's coverage of header shapes and the --frozen view.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
Cell Before (main) After
tests/unit/test_mcp_env_reference_headers.py: the dependency refusal in both header forms, one [!] line, and nothing rendered [mapping] failed pass
same module: an authored header is written verbatim in both forms pass pass
same module: a registry mapping header renders on codex, gemini and antigravity AttributeError pass
same module: refused_pairs covers registry dependency overlays and leaves plain or root values alone frozenset() pass
tests/integration/test_mcp_dependency_overlay_refusal_lifecycle.py (real binary, local registry): mapping-form headers, install, then --frozen install rc 1 pass
same module: env overlay, install, then --frozen --frozen rc 1, "ownership is not recorded" pass
  • Mutation M2 (QL): with the _canonicalize_remote_headers(info) call in _overlaid_server_infos removed, test_a_plain_registry_reference_is_judged_in_one_header_shape fails (assert {'X-Base': 'b', 'X-Key': '!registry'} == [{'name': ...}]; 1 failed, 12 passed). With the call restored, 13 passed. A registry reference with no dependency overlay has no dep_map entry, so _apply_overlay never sees it; this call is its only canonicalization.
  • Emit-site mutation: suppressing the refuses_render warning fails both refusal rows.
  • Oracle updates: three existing tests pinned the old in-place mapping merge (test_mcp_integrator_overlay.py, test_mcp_integrator_install_flow.py, test_github_mcp_auth_policy_logic.py), plus a type check in test_github_mcp_auth_policy.py. Each keeps its promise (the overlay is merged, the existing header is kept, and the authored value and type are retained) and now reads the canonical list form.
  • Neighbours: the MCP unit and integration modules that touch the overlay or the owner pass (516 + 366), as do test_mcp_env_reference_lifecycle.py, the goldens, test_mcp_remote_transport_harness_lifecycle.py and the bug ledger.
  • CI-mirror lint: ruff 0.15.12, R0801, auth signals, complexity ratchet, tm006 and architecture boundaries all pass.

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.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Agent assessment

  • Change confidence: high. The change is at a single owner, with red-first unit and real-binary cells for each part and an emit-site mutation.
  • Diagnosis confidence: high. Both behaviours reproduce on main with the packaged binary.
  • Evidence fit: strong. Each cell fails on main for the stated reason and passes after the change.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Copilot AI balanced review requested due to automatic review settings December 2, 2026 23:21
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Dec 2, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title mcp: apply the exec-prefix refusal to mapping-form headers mcp: one header shape for registry servers; --frozen skips servers install refused Dec 2, 2026

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

Active issues allow frozen mode to write an unclaimed server through false refusal exemptions and cause header overrides to retain stale values or incorrectly skip servers.

2 open issues
What changed in this PR

Extends #5773’s MCP dependency-value safeguards to mapping-form headers and registry overlays during frozen installs.

Changes:

  • Normalizes remote headers and checks both supported shapes for refused values.
  • Extends frozen-install refusal handling to registry dependency overlays.
  • Adds regression coverage and updates existing header assertions.
File Description
tests/​unit/​test_mcp_integrator_overlay.py Updates canonical header expectations.
tests/​unit/​test_mcp_env_reference_headers.py Covers header shapes, rendering, and refusals.
tests/​unit/​test_github_mcp_auth_policy.py Adapts value-type checks to normalized headers.
tests/​unit/​test_github_mcp_auth_policy_logic.py Checks normalized overlay values and provenance.
tests/​integration/​test_mcp_integrator_install_flow.py Updates merged-header expectations.
tests/​integration/​test_mcp_dependency_overlay_refusal_lifecycle.py Adds install and frozen-replay regression cases.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​5773.json Links the new regression cases.
src/​apm_cli/​mcp_env_reference.py Handles mapping headers and registry-overlay refusals.
src/​apm_cli/​integration/​mcp_integrator.py Normalizes headers before overlay merging.
src/​apm_cli/​integration/​mcp_integrator_install.py Normalizes fetched header snapshots.
changelog.d/​5814.fixed.md Documents header and frozen-install changes.

Review effort: Balanced

Comment thread src/apm_cli/mcp_env_reference.py Resolved
Registry remote headers are stored in the list form at the overlay step,
so every writer and the env-reference owner read one shape; the owner
also reads both forms directly. --frozen now counts a registry server
whose dependency overlay the install refused, matching the install.

apm-spec-waiver: MCP owner hardening covered by the #5773 scope record; no OpenAPM requirement changes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…of the same name

An overlay header now replaces a registry header with the same name
(case-insensitive) instead of sitting beside it, so the refusal owner and
every writer see the overriding value. An empty override keeps the
published header, as before.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A registry dependency's header overlay applies only to a remote, so its
refusal is excused from --frozen claims when the declared transport is
remote, never for stdio, and is deferred to the payload check when no
transport is declared. An env overlay still decides alone.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The overlay pairs that need the fetched payload are excused from the claim
filter and the unclaimed ones seed the existing --frozen deferral; the owner
applies each server's targets selection and native runtimes, as the claim
filter does.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A registry server without a dependency overlay reaches the writers only
through _overlaid_server_infos; this pins that its mapping-form headers
are stored as list entries and render and judge like the list form.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Dec 3, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Dec 3, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Dec 3, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

No deployments
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.

2 participants