Skip to content

fix(trust): native plugin mcp.json executables owned by trust.py; approve sees them (#4042) - #4058

Merged
Daniel Meppiel (danielmeppiel) merged 12 commits into
mainfrom
danielmeppiel-4042-native-trust
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 12 commits into
mainfrom
danielmeppiel-4042-native-trust

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

TL;DR — apm approve could not see a native Agent Plugin whose only executable is its root mcp.json. Install parked the plugin, but apm approve <path> said "not found", --pending said everything was approved, and {mcp: true} still parked it because of a hidden bin type. security/trust.py is now the single source of a native plugin's executable types, and install, approve, --pending/--list, policy explain and the pin summary all read that one set. Fail-closed behaviour is unchanged.

Important

Rebase after #4025 (P5a). #4025 rewrites the same admit_native_plugin(...) calls in install/exec_gate.py (closed_exec_map(...)). This PR's exec_gate hunk only drops the extra_types= lines, removes native_declared_types, and wraps the blocked declaration, so the conflict is a two-line rebase. #4044 (stacked on #4025) touches exec_gate ~108-121, which this PR does not.

Warning

Pre-merge: after #4040 lands, remove the strict xfail for gate cell b (#4042) in #4040's tests/integration/test_generated_lifecycle_state_machine.py as part of the rebase onto main (this fix makes that cell XPASS).

Problem (WHY)

On main 67936cd, with the installed CLI:

Command Result
apm install ./pkgs/np parked (gated_pending_approval)
apm approve ./pkgs/np not found in installed packages, exit 0
apm approve --pending All packages with executables are approved.
apm approve --list / apm policy explain nothing / not found
executables.allow: {./pkgs/np: {mcp: true}} still parked, with no reason given
  • security/executables.py scan_package_executables counts MCP only from apm.yml, so approve.py dropped the plugin at its has_executables filter.
  • trust.native_plugin_exec_types looked for .mcp.json, not the Agent Plugins mcp.json.
  • Install added the IR's mcp/bin from outside the owner (exec_gate.native_declared_types → extra_types=), so install and approve saw different sets.

Approach (WHAT)

Owner Change
security/trust.py (executable-item-admission) agent_plugin_exec_types(root) derives mcp, plus bin for a command server, from the Agent Plugins loader IR (a root mcp.json the loader cannot read still counts as mcp). native_plugin_exec_types(root) includes it; the extra / extra_types parameters are gone. native_declaration(decl, root) puts that set on an ExecutableDeclaration. A partial grant parks with detail naming the missing types.
security/executables.py ExecutableDeclaration.native_exec_types feeds has_executables, exec_types and summary_line.
install/exec_gate.py native_declared_types and extra_types= removed; the blocked declaration carries the native set.
install/native_plugin_admission.py Registration gates on trust.native_plugin_exec_types; its local IR-type helper moved to trust.
install/deployment_plan.py An incomplete grant is named: Parked native plugin <pkg>: not approved (missing grant: bin).
commands/approve.py Both scan paths apply native_declaration to native plugins before the has_executables filter.
scripts/architecture_linter/checks/install_portable_trust.py The item-admission guard rejects extra_types=, native_declared_types( and def agent_plugin_exec_types( outside trust.py, and requires the new routes.

Trade-offs

  • The loader IR, not a second parser. bin comes from the loader's executable classification (what install already used), so it is not re-derived and the bin policy is unchanged (out of scope per the record).
  • Codex manifest types. has_mcp/has_hooks were dropped from exec_gate because trust's manifest scan already reads .codex-plugin/plugin.json mcpServers/hooks and the hooks/ dir. The Codex lifecycle suites stay green.
  • Missing-grant wording only for partial grants. A plugin with no grant keeps the registrar's single refusal line, so there are no duplicate warnings.
  • Out of scope, noted: apm_owned_reference does not scan the root mcp.json for .apm/ references (pre-existing; separate issue if wanted).

Issue and approved scope

Issue: Fixes #4042

Human scope-approval comment: #4042 (comment) (eligibility.cjs: record-present, contact_confirmation_needed: false)

Completes the issue: every Done-when item is covered below.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Scenario evidence

Promise Test Principle
A root-mcp.json plugin is parked, listed by --pending/--list/policy explain, approved by a whole-plugin pin, registered, parked again when mcp.json changes, and re-approved tests/integration/test_mcp_portable_approval_lifecycle.py::test_native_plugin_with_only_a_root_mcp_json_is_approvable Secure by default
{mcp: true} alone parks and names bin; {mcp, bin} admits ...::test_native_plugin_mcp_grant_alone_parks_and_names_the_missing_bin Secure by default
A URL-only server never acquires bin ...::test_native_plugin_url_mcp_server_needs_no_bin_grant Least privilege
No native type derivation outside trust.py 3 new MutationCases (install-deployment-executable-item-admission) in tests/integration/test_architecture_owner_rule_mutations.py Single owner

Fails on main (installed CLI, APM_BINARY_PATH=.venv/bin/apm, run before the fix):

FAILED ...::test_native_plugin_with_only_a_root_mcp_json_is_approvable - AssertionError: All packages with executables are approved.
FAILED ...::test_native_plugin_mcp_grant_alone_parks_and_names_the_missing_bin - 'Parked native plugin ./pkgs/np: not approved (missing grant: bin)' not in output
FAILED ...::test_native_plugin_url_mcp_server_needs_no_bin_grant - AssertionError: No installed packages declare executable primitives.
3 failed
After the fix
$ APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest tests/integration/test_mcp_portable_approval_lifecycle.py -q
22 passed in 56.41s

# native / approval / codex / gate lifecycle suites (18 files)
$ APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest tests/integration/{test_agent_plugin_spec_contract,test_codex_native_plugin_lifecycle,test_copilot_native_plugin_binary_lifecycle,test_executables_*,test_native_plugin_*,test_plugin_bin_trust_posture,...}.py -n 4 -q
201 passed, 12 skipped

$ uv run --extra dev pytest tests/integration/test_architecture_owner_rule_mutations.py -q -k "item_admission or 4042 or matrix or native"
100 passed

$ uv run --extra dev pytest tests/unit/copilot_plugins/test_pr2705_folds.py -q
22 passed

tests/unit/copilot_plugins/test_pr2705_folds.py: the native fixture was a SimpleNamespace IR with no plugin root. It is now a real Agent Plugin written by the existing write_agent_plugin builder, because types come from disk via trust.py.

Full tests/unit locally: the remaining failures are environment-only in this sandbox (commit signing, Unix install ownership, network guard). I re-ran each non-obvious one on main, and they fail identically there. CI is the authority.

Lint contract (.apm/instructions/linting.instructions.md, HEAD up to date with main): ruff check, ruff format --check, pylint R0801 10.00/10, lint-auth-signals.sh clean, lint_architecture_boundaries.py --root . exit 0.

How to test

  • APM_BINARY_PATH=$PWD/.venv/bin/apm uv run --extra dev pytest tests/integration/test_mcp_portable_approval_lifecycle.py -q -k "root_mcp_json or missing_bin or url_mcp" → 3 passed (3 failed on main).
  • uv run --extra dev pytest tests/integration/test_architecture_owner_rule_mutations.py -q -k 4042 → the 3 guard mutations are caught.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md: user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes only under upgrade notes; no Highlights; see .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Docs are in ONE isolated last commit (reference/cli/approve.md, consumer/copilot-agent-plugins.md, apm-usage commands.md). Docs re-home after #3996:

Page here After #3996
reference/cli/approve.md reference/cli/approve.md (same path)
consumer/copilot-agent-plugins.md consumer/install-plugins.md

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour. Native plugin admission semantics (whole-root pin, req-na-005) are unchanged; APM now reports the types it already gated on.

Co-authored-by: Copilot [email protected]

…rove sees them (#4042)

security/trust.py is now the single source of a native plugin's
executable types. native_plugin_exec_types derives an Agent Plugin's
root mcp.json types from the loader IR itself (mcp, plus bin for a
server that runs a command), so install/exec_gate.py no longer passes
caller-supplied extra_types and native_declared_types is gone.

apm approve, approve --pending/--list and apm policy explain read the
same set through native_declaration, so a plugin whose only executable
is its root mcp.json is listed, approvable and pinned instead of 'not
found'. A partial type-level grant names the missing grant when it
parks the plugin. Fail-closed is unchanged.

The install-deployment-executable-item-admission guard rejects native
type derivation outside trust.py, with mutation cases.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…t message (#4042)

Docs re-home after #3996:

| Page here | After #3996 |
| --- | --- |
| reference/cli/approve.md | reference/cli/approve.md (unchanged path) |
| consumer/copilot-agent-plugins.md | consumer/install-plugins.md |

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Resolutions: admit_native_plugin keeps main's one_off and transitive
gate-off path and drops extra_types (trust.py owns native types);
approve.py keeps main's user_scope in _is_native_plugin; the #4042
mutation fragment now anchors on main's one_off line;
copilot-agent-plugins.md was deleted by #3996 (re-homed next commit).

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…4042)

consumer/copilot-agent-plugins.md was folded into consumer/install-plugins.md
by #3996; the Agent Plugin row now carries the note.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title [0.38] fix(trust): native plugin mcp.json executables owned by trust.py; approve sees them (#4042) fix(trust): native plugin mcp.json executables owned by trust.py; approve sees them (#4042) Nov 20, 2026
#4058 fixes #4042, so #4040's strict known failure for gate cell b
would XPASS; remove it.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
install_portable_trust.py: keep #4025's inventory-wide guard; approve.py
routes keep the native_declaration calls (#4042), and native plugin type
derivation outside trust.py stays rejected.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…orks (#4042)

#4040's spine reached update and deny with the plugin still pending
because approve never took effect for a root-mcp.json Agent Plugin.
With #4042 fixed the plugin is approved there, so the required
update|plugin|pending and deny|plugin|pending cells went unvisited.
Revoke and reinstall the plugin before update to keep them covered.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
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

Without a lockfile, approve --pending and --list still omit Agent Plugins whose only executable is root mcp.json, requiring canonical plugin detection and a no-lockfile regression test.

1 open issue
What changed in this PR

This PR addresses #4042 by centralizing native plugin executable detection in security/trust.py, so install and approval views use the same types for Agent Plugins with a root mcp.json.

Changes:

  • Routes native plugin admission, approval listings, and summaries through the shared trust owner.
  • Reports missing executable grants and documents whole-plugin approval.
  • Adds lifecycle and architecture regression coverage, replacing the resolved expected failure.
File Description
tests/​unit/​copilot_plugins/​test_pr2705_folds.py Uses on-disk Agent Plugin fixtures for native admission tests.
tests/​integration/​test_mcp_portable_approval_lifecycle.py Covers MCP-only approval, changed content, partial grants, and URL-only servers.
tests/​integration/​test_generated_gate_state_machine.py Adjusts the sequence after plugin approval starts working.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds mutations checking native type ownership and approval routing.
tests/​integration/​_gate_machine_kit.py Removes the expected failure for #4042.
src/​apm_cli/​security/​trust.py Owns native executable types and missing-grant details.
src/​apm_cli/​security/​executables.py Includes native types in executable detection and summaries.
src/​apm_cli/​install/​native_plugin_admission.py Uses trust-owned types to gate registration.
src/​apm_cli/​install/​exec_gate.py Removes caller-derived types and enriches blocked declarations.
src/​apm_cli/​install/​deployment_plan.py Displays incomplete-grant parking reasons.
src/​apm_cli/​commands/​approve.py Adds native types before filtering installed packages.
scripts/​architecture_linter/​checks/​install_portable_trust.py Guards centralized native type derivation.
packages/​apm-guide/​.apm/​skills/​apm-usage/​commands.md Updates approval guidance for root MCP definitions.
docs/​src/​content/​docs/​reference/​cli/​approve.md Explains native MCP and binary grant requirements.
docs/​src/​content/​docs/​consumer/​install-plugins.md Documents Agent Plugin executables and approval.
CHANGELOG.md Records the user-visible approval fix.

Review effort: Balanced

Comment thread src/apm_cli/commands/approve.py Resolved
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
With no apm.lock.yaml, approve's fallback scan has no recorded
package_type, so a root-mcp.json-only Agent Plugin was not marked native
and dropped from --pending/--list. Ask the canonical loader
(detect_agent_plugin) instead. Adds a no-lockfile lifecycle case.

Addresses review thread on approve.py:1085.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 643523b into main Nov 20, 2026
42 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-4042-native-trust branch November 20, 2026 12:32
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.

A local-path native Agent Plugin cannot be approved through apm approve

2 participants