Skip to content

mcp: judge registry overlays against each target's row - #5821

Open
Daniel Meppiel (danielmeppiel) wants to merge 9 commits into
mainfrom
mcp-overlay-row-refusal
Open

Daniel Meppiel (danielmeppiel) wants to merge 9 commits into
mainfrom
mcp-overlay-row-refusal

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Follow-up to #5814, in the same owner (apm_cli.mcp_env_reference). It builds on #5814 and lands after it; until #5814 merges, this diff also shows #5814's commits (its own change is the last commit).

refused_pairs and overlay_refusal_pairs_to_confirm judged a registry server's overlay only by the dependency rule. Install, meanwhile, judges it against each target's env-reference row (_exec_refusal). For a row with an exec_prefix, --frozen could therefore report a missing claim for a server the install skipped. Now:

  • _overlay_refusals builds the overlay stubs once per server (through _apply_overlay, with no payload) and judges each installed target with _exec_refusal(env_reference(target, user_scope), stub). That covers both the dependency rule and the target row.
  • An env overlay decides on its own. A header overlay decides on its own only for a declared remote transport; it is never excused for stdio, and with no declared transport it is deferred to the existing payload confirmation.
  • Targets follow the server's targets: selection minus native runtimes, for both functions.
  • overlay_refusal_pairs_to_confirm gains user_scope; the one call site in install/service.py stays on one line (the file stays at 1000 lines).

No row on main sets exec_prefix, so behaviour on existing targets is unchanged.

Issue and approved scope

Issue: Refs #5773

Human scope-approval comment: the #5773 apm-scope record v3 (comment 7349125162).

Does this PR complete the issue, or what remains? #5773 was completed by #5777; this refines the shared owner.

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 (tests/unit/test_mcp_env_reference_headers.py) At #5814 head 3008dc3 After
test_a_target_row_exec_prefix_judges_a_root_registry_overlay[env-value] (refused) failed pass
...[remote-header] (refused) failed pass
...[undeclared-header] (deferred to confirm) failed pass
...[stdio-header] (not excused) failed (new user_scope argument) pass
test_a_target_without_an_exec_prefix_leaves_a_root_overlay_alone[*] — pass
  • Mutation M2 (QL): dropping the native_runtimes exclusion in _overlay_refusals makes test_a_native_runtime_target_yields_no_overlay_pair fail (Extra items in the left set: ('env', 'cursor')). With the exclusion restored, 22 passed.
  • The synthetic row is injected as data (monkeypatch.setitem(ENV_REFERENCES, ...)); no owner function is patched.
  • Neighbours: 279 passed, covering the overlay and env-reference lifecycles, the frozen native service lifecycle, install services, the auth-policy and overlay tests, and the LOC invariants.
  • Composed with feat(pi): MCP servers for the pi target, on the shared env reference owner #5785 (36ca4b6): clean merge. On that tree, the real pi row gives remote header refused, undeclared deferred, env refused, stdio not excused, with cursor unaffected; 31 owner cells pass.
  • 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).

There is no user-visible change on released targets: no shipped row sets exec_prefix, and #5814's Fixed line already covers --frozen.

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

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

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>
A registry server's overlay is now checked against each installed target's
env-reference row, not only the dependency rule, so --frozen excuses or
defers the same pairs the install skips. Targets follow the server's
targets selection minus native runtimes.

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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@danielmeppiel
Daniel Meppiel (danielmeppiel) changed the base branch from mcp-exec-refusal-headers to main December 3, 2026 02:16
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 03:21

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

Header-only refusal logic mishandles HTTP and stdio payload fallbacks, allowing installs to bypass frozen ownership checks or fail frozen replay.

1 open issue
What changed in this PR

Builds on #5814 to align registry-overlay refusal checks with each target’s environment-reference rules and frozen-install ownership checks.

Changes:

  • Evaluates overlays per target and scope, respecting target selection and native runtimes.
  • Normalizes registry headers and adds deferred payload confirmation.
  • Adds regression coverage and updates header-shape assertions.
File Description
tests/​unit/​test_mcp_integrator_overlay.py Expects normalized header entries.
tests/​unit/​test_mcp_env_reference_headers.py Covers header forms, target rows, and refusal classification.
tests/​unit/​test_github_mcp_auth_policy.py Checks value types in normalized headers.
tests/​unit/​test_github_mcp_auth_policy_logic.py Updates overlay provenance assertions.
tests/​integration/​test_mcp_integrator_install_flow.py Updates merged-header expectations.
tests/​integration/​test_mcp_dependency_overlay_refusal_lifecycle.py Exercises refusal and frozen replay through the CLI.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​5773.json Registers new lifecycle regressions.
src/​apm_cli/​mcp_env_reference.py Adds per-target overlay refusal classification.
src/​apm_cli/​integration/​mcp_integrator.py Normalizes headers and merges case-insensitive overrides.
src/​apm_cli/​integration/​mcp_integrator_install.py Normalizes fetched registry headers before use.
src/​apm_cli/​install/​service.py Connects deferred overlay checks to frozen ownership enforcement.
changelog.d/​5814.fixed.md Documents header normalization and frozen-install behavior.

Review effort: Balanced

Comment thread src/apm_cli/mcp_env_reference.py Resolved
A declared transport does not show whether the fetched payload keeps a
remote, so a header-sourced overlay refusal is always deferred to the
existing payload confirmation under --frozen; an env overlay still
decides alone.

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