Skip to content

plan/apply P5a: ExecDecision, one executable trust owner (#4018) - #4025

Merged
Daniel Meppiel (danielmeppiel) merged 17 commits into
mainfrom
danielmeppiel-legendary-chainsaw
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 17 commits into
mainfrom
danielmeppiel-legendary-chainsaw

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

TL;DR — Executable trust now has one owner with no fail-open defaults. security/executables.py gains an explicit blanket authorization (authorized_exec_map) for the two cases that legitimately approve everything (gate disabled, audit replay of already-authorized rows); a None or omitted approvals map now approves nothing. check_executable_approval, the local-bundle helpers and resolve_bin_skip become adapters over that owner, and the portable-trust guard moves from caller lists to inventory-wide enforcement. Installed-CLI outcomes are unchanged.

Problem (WHY)

  • allow_executables is None meant "approve every executable" in check_executable_approval, plugin_admission, hook_file_admission, the services canvas gate, the local-bundle hooks/canvas/MCP/LSP filters and the declared-service filter. Any caller that forgot to pass a map silently got full trust.
  • bundle_deploy_relative_path / bundle_deploy_skip_warning defaulted hooks_approved=True, canvas_approved=True; resolve_bin_skip defaulted non_interactive=False (trusting bin/ on an omitted input).
  • Adapters did their own is_package_approved lookups (services canvas, local-bundle hooks/canvas/MCP/LSP), beside the owner.
  • The portable-trust guard asserted that named consumer files contained named tokens. A new consumer outside that list was never checked: closed-world guards hold, caller-list guards leak.

Approach (WHAT)

Before After
None map ⇒ all approved None ⇒ nothing approved; authorized_exec_map(AUTHORIZED_GATE_DISABLED | AUTHORIZED_REPLAY) ⇒ all approved
materialize_exec_map returns None when the gate is off returns an explicit gate-disabled EffectiveExecMap (still empty, still trust_context=None)
_local trusted via the None-or-name shortcut FIRST_PARTY_PACKAGE checked explicitly
Adapters call is_package_approved Adapters call package_type_approved(s); native and pinned-hook item admission unchanged
--trust-bin composition in exec_gate.py compose_trust_bin in the owner; non_interactive required
Bundle hooks_approved / canvas_approved default True required keyword-only
Guard: consumer-presence tokens Guard: inventory-wide prohibitions (below)

Implementation (HOW)

File Change
security/executables.py EffectiveExecMap.authorized_by; authorized_exec_map, exec_map_authorizes_all, package_type_approved(s), compose_trust_bin, closed_exec_map, declared_project_exec_map; materialize_exec_map returns the explicit gate-disabled map.
install/exec_gate.py check_executable_approval, plugin_admission, hook_file_admission route through the owner; a missing map reaches native admission as an empty gate-on map (fails closed). ReplayExecAllowMap.for_dependency returns AUTHORIZED_REPLAY instead of None. resolve_bin_skip delegates; non_interactive required.
install/services.py, install/local_bundle_handler.py, install/local_bundle_paths.py, install/dry_run_plan.py Owner calls replace local lookups and is None branches; bundle approval inputs are required keyword-only.
scripts/architecture_linter/checks/install_portable_trust.py Consumer-presence routes removed. Inventory-wide over src/apm_cli/: no approval lookups or approvals-map is None tests outside security/; every def taking hooks_approved / canvas_approved (or non_interactive with trust_bin) declares them required keyword-only and every call passes them (hook_file_admitted too when hooks may be approved); any function calling package_type_approvals also calls native_install and hooks_package_admissible; package_exec_status always gets native=; grants are written only by apm approve and the install prompt. Existing owner-boundary prohibitions kept.
scripts/architecture_linter/checks/install_lsp_plugin.py, .apm/architecture/owners/install-deployment.json Trust-context guard and registry name the new owner functions; bundle tokens follow the refactor.

Legend: who may authorize every executable, and how each adapter reaches a verdict.

flowchart LR
    M["materialize_exec_map"] -->|"gate off"| A["authorized_exec_map: gate-disabled"]
    R["ReplayExecAllowMap"] -->|"already authorized"| B["authorized_exec_map: replay"]
    M -->|"gate on"| G["EffectiveExecMap grants"]
    N["None / omitted"] --> C["closed: nothing approved"]
    A --> X["exec_gate adapters"]
    B --> X
    G --> X
    C --> X
    X --> P["package_type_approved(s)"]
    X --> I["trust.py item admission: pins, native plugins"]
Loading

Trade-offs

  • None now fails closed instead of raising. Every production producer passes an explicit map, and the guard forbids is None tests on approvals maps outside security/; raising would have added churn to the 90+ internal integrate_package_primitives test calls for no outcome difference.
  • The gate-disabled map keeps trust_context=None, so McpAdmission still resolves its own context exactly as before (no change to policy_unavailable reporting).
  • allow_executables on integrate_package_primitives / prepare_package_deployment keeps its None default (now meaning "nothing approved") rather than becoming required; the scope names only the bundle and trust-bin inputs as required.
  • apm approve keeps one presence token (record_pins) as the registered grant writer; there is no inventory-wide shape for "pins what it approves".

Validation

  • Equivalence: tests/unit/install/test_exec_decision_equivalence.py (12 cases: no policy signals, org deny, user deny, pinned hooks, native plugin, bin with/without --trust-bin, audit replay) uses only APIs present on main and passes unchanged on both main and this branch.
  • uv run --extra dev pytest tests/unit -n 8: 312 failed / 28204 passed on this branch vs 313 failed on main in the same sandbox; zero failures not present on main (the shared failures are sandbox git-signing / network / locale tests).
  • tests/acceptance tests/red_team tests/spec_conformance tests/mutation tests/scripts tests/quality tests/test_*.py: identical pass/fail sets on branch and main.
  • bash scripts/lint-architecture-boundaries.sh: exit 0. New mutation-break cases (test_executable_approval_cannot_leave_the_trust_owners, 7 cases) all rejected by install-deployment-executable-item-admission.
  • ruff check / format, pylint R0801 (10.00/10), auth-signal lint, file length: clean.
  • PR CI on 0bf3951: all 30 checks pass (Lint, Build & Test shards, Windows Compatibility Gate, Spec conformance gate, Architecture Ratchets, Lifecycle Smoke, Binary Smoke). A local tests/integration run did not finish in the sandbox (stopped after 45 min); CI's Build & Test shards cover it.
Scenario evidence
Scenario Test
No policy signals deploy everything test_no_policy_signals_deploy_every_executable
Org / user deny withhold test_org_deny_withholds_every_executable, test_user_deny_beats_a_project_grant
Pinned hooks admit per file, park on change test_pinned_hooks_admit_per_file
Native plugin admitted as one pinned unit test_native_plugin_is_admitted_as_one_pinned_unit
bin with / without --trust-bin test_bin_composes_approval_with_trust_bin
Audit replay keeps already-authorized rows test_audit_replay_keeps_already_authorized_rows
Missing / omitted inputs never authorize test_missing_or_omitted_inputs_never_authorize, tests/spec_conformance/test_exec_decision_reqs.py (req-sc-009, req-sc-014)
Guard rejects out-of-owner lookup and omitted hooks_approved tests/integration/test_architecture_owner_rule_mutations.py::test_executable_approval_cannot_leave_the_trust_owners

Rebased on 0.37 main

Merged main (0.37 stack) in one merge commit; conflicts in exec_gate.py, local_bundle_handler.py, CHANGELOG and two tests. Semantic folds:

  • native_plugin_verdict keeps 0.37's gate-off rule (a transitive plugin with MCP servers still needs trust): the explicit gate-disabled map maps to ctx.exec_trust_ctx, replay to no context, a missing map fails closed.
  • 0.37's local_bundle_hook_trust.py ("None = gate off") routes through the owner (exec_map_authorizes_all, package_type_approved); its trust-integrity guard token and mutation case follow.
  • The native-status guard also covers package_exec_decision.
  • Internal-API tests that omitted the map now pass an explicit gate-disabled map (incl. 0.37's Claude native-route tests).

Allow-map provenance (closed world)

  • install/dry_run_plan.py reads the executable-trust-context owner (offline, policy-free, no migration or warnings) instead of the manifest's declared grants; registered as a trust-owner caller.
  • First-party content gets an explicit AUTHORIZED_FIRST_PARTY map (template.py, services.integrate_local_content); lazily resolved maps start from closed_exec_map(None), never None (lsp/integration.py, hook_integrator.py, uninstall/engine.py).
  • New check scripts/architecture_linter/checks/install_exec_provenance.py under install-deployment-executable-trust-context: every inventory function with an allow_executables / effective_allow_execs parameter is a consumer, discovered not listed; every call outside security/ must pass an owner-produced map (producer call, pass-through parameter, local name or provider bound only to producers). Mutation cases: manifest grants in dry-run, omitted first-party map, literal None, None placeholder.

Issue and approved scope

Issue: Fixes #4018

Human scope-approval comment: #4018 (comment)

Completes the issue: owner extension, adapters, removed fail-open defaults, inventory-wide guard, equivalence and mutation tests, one CHANGELOG line. Out of scope (untouched): default-allow changes, new policy fields, pin semantics, lifecycle script gating.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass (no failures beyond those on main in the same sandbox)
  • Added tests for new functionality (if applicable)

How to test

  • uv run --extra dev pytest tests/unit/install/test_exec_decision_equivalence.py tests/spec_conformance/test_exec_decision_reqs.py -q
  • Copy test_exec_decision_equivalence.py minus its last test onto main and run it: same results.
  • uv run --extra dev pytest "tests/integration/test_architecture_owner_rule_mutations.py::test_executable_approval_cannot_leave_the_trust_owners" -q
  • bash scripts/lint-architecture-boundaries.sh exits 0.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md (internal line under Changed, as the scope requires).
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit: tests/spec_conformance/test_exec_decision_reqs.py cites req-sc-009 and req-sc-014 (no normative change).
  • CONFORMANCE.{md,json} regenerated and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Co-authored-by: Copilot [email protected]

…efaults (#4018)

Extend the executable-trust-context owner with an explicit blanket
authorization (gate disabled, audit replay already-authorized), package
type approvals and --trust-bin composition. check_executable_approval,
the bundle helpers and resolve_bin_skip become adapters; a missing or
omitted map no longer authorizes anything.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Resolve exec_gate.py (native_plugin_verdict keeps its gate-off transitive
MCP check through the explicit gate-disabled map), local_bundle_handler.py
(scope-manifest bundle trust from #3989), and route the new
local_bundle_hook_trust.py adapter through the trust owner.

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] plan/apply P5a: ExecDecision, one executable trust owner (#4018) plan/apply P5a: ExecDecision, one executable trust owner (#4018) Nov 20, 2026
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…4018)

The dry-run LSP preview reads the executable-trust-context owner (offline,
policy-free) instead of the manifest's declared grants. First-party content
gets an explicit AUTHORIZED_FIRST_PARTY map. Lazily resolved maps start from
closed_exec_map(None), never None. The executable-trust-context guard gains a
closed-world provenance check: every inventory function that takes an
allow-map is a consumer, and every call to it outside security/ must pass an
owner-produced map; mutation cases pin it.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) marked this pull request as ready for review November 20, 2026 10:04
Copilot AI balanced review requested due to automatic review settings November 20, 2026 10:04
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit ff65dfb into main Nov 20, 2026
38 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-legendary-chainsaw branch November 20, 2026 10:11
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
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

Critical provenance and trust-check bypasses allow raw executable grants to override owner deny rules and fail-open approval defaults to evade detection.

6 open issues
What changed in this PR

This PR advances #4018 by centralizing executable trust decisions in APM's security owner. Missing approval maps now deny executable deployment, while gate-disabled, replay, and first-party authorization become explicit.

Changes:

  • Routes install, bundle, replay, and reintegration trust checks through shared owner APIs.
  • Adds inventory-wide guards for approval inputs and allow-map provenance.
  • Updates existing tests, adds equivalence and conformance coverage, and refreshes ownership records.
File Description
tests/​unit/​test_surviving_deps_reintegration.py Supplies explicit authorization for reintegration testing.
tests/​unit/​security/​test_resolve_exec_decision.py Verifies explicit gate-disabled map materialization.
tests/​unit/​integration/​test_hook_target_selection.py Makes hook-test authorization explicit.
tests/​unit/​integration/​test_hook_configured_routing.py Updates routing fixtures for explicit authorization.
tests/​unit/​integration/​test_dep_target_intersection.py Preserves target-selection tests under the new contract.
tests/​unit/​integration/​test_data_driven_dispatch.py Authorizes dispatch fixtures explicitly.
tests/​unit/​integration/​test_cursor_hook_native_contract.py Updates hook-contract tests with authorization maps.
tests/​unit/​integration/​test_command_integrator.py Supplies authorization to command-dispatch tests.
tests/​unit/​integration/​test_canvas_integrator.py Supplies explicit authorization for canvas deployment.
tests/​unit/​install/​test_skill_completion_receipt.py Updates receipt tests for explicit authorization.
tests/​unit/​install/​test_services.py Updates service-test authorization inputs.
tests/​unit/​install/​test_services_rendering.py Preserves rendering tests with explicit maps.
tests/​unit/​install/​test_services_phase3.py Updates service-phase fixtures.
tests/​unit/​install/​test_services_hook_scope.py Authorizes hook-scope fixtures explicitly.
tests/​unit/​install/​test_services_branches.py Updates service-branch fixtures.
tests/​unit/​install/​test_replay_exec_allow_map.py Checks explicit replay authorization.
tests/​unit/​install/​test_lsp_integration.py Returns explicit gate-disabled maps from mocks.
tests/​unit/​install/​test_local_bundle_hook_trust.py Distinguishes gate-off authorization from missing maps.
tests/​unit/​install/​test_install_local_bundle.py Passes required bundle approval arguments.
tests/​unit/​install/​test_exec_decision_equivalence.py Adds trust-outcome equivalence and omission tests.
tests/​unit/​install/​test_claude_native_hooks.py Updates native-hook fixtures with explicit authorization.
tests/​unit/​install/​test_claude_native_admission.py Preserves gate-off transitive-MCP refusal coverage.
tests/​unit/​install/​test_agent_symlink_diagnostics.py Authorizes the diagnostic test fixture explicitly.
tests/​unit/​install/​test_agent_plugin_deployment_boundary.py Updates deployment-boundary test inputs.
tests/​spec_conformance/​test_exec_decision_reqs.py Covers fail-closed approval and bin consent requirements.
tests/​integration/​test_plugin_bin_trust_posture.py Makes authorization and interaction posture explicit.
tests/​integration/​test_install_services_phase3w5.py Updates service integration fixtures.
tests/​integration/​test_install_services_orchestration.py Updates orchestration fixtures.
tests/​integration/​test_hook_integrator_copilot_casing_e2e.py Supplies explicit authorization for casing tests.
tests/​integration/​test_hook_configured_routing_e2e.py Supplies explicit authorization for routing tests.
tests/​integration/​test_executables_gate_integration.py Separates missing-map denial from gate-disabled approval.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds provenance and approval-boundary mutations.
tests/​integration/​test_architecture_lsp_plugin.py Updates the bundle-identity bypass mutation.
src/​apm_cli/​security/​executables.py Owns explicit authorization, approval lookup, and bin consent.
src/​apm_cli/​integration/​hook_integrator.py Initializes unresolved reintegration trust closed.
src/​apm_cli/​install/​template.py Explicitly authorizes first-party deployment planning.
src/​apm_cli/​install/​services.py Routes canvas and bundle approvals through the owner.
src/​apm_cli/​install/​lsp/​integration.py Starts lazy LSP trust resolution with a closed map.
src/​apm_cli/​install/​local_bundle_paths.py Requires explicit hook and canvas approval inputs.
src/​apm_cli/​install/​local_bundle_hook_trust.py Uses owner APIs for deployed bundle-hook admission.
src/​apm_cli/​install/​local_bundle_handler.py Uses owner APIs for bundle executable filtering.
src/​apm_cli/​install/​exec_gate.py Adapts approval, native admission, replay, and bin checks.
src/​apm_cli/​install/​dry_run_plan.py Resolves preview LSP trust through the context owner.
src/​apm_cli/​install/​context.py Clarifies unresolved-map semantics in comments.
src/​apm_cli/​commands/​uninstall/​engine.py Initializes survivor reintegration trust closed.
scripts/​architecture_linter/​checks/​install_trust_integrity.py Updates the bundle-hook owner token.
scripts/​architecture_linter/​checks/​install_portable_trust.py Adds inventory-wide approval and admission checks.
scripts/​architecture_linter/​checks/​install_lsp_plugin.py Registers owner APIs and provenance enforcement.
scripts/​architecture_linter/​checks/​install_exec_provenance.py Adds allow-map consumer and provenance analysis.
scripts/​architecture_linter/​checks/​install_dry_run_plan.py Updates the dry-run call-shape guard.
CONFORMANCE.md Updates executable-trust requirement test counts.
CONFORMANCE.json Records new executable-trust conformance cases.
CHANGELOG.md Records the internal trust-owner refactor.
.apm/​architecture/​owners/​install-deployment.json Expands the executable-trust ownership contract.

Review effort: Balanced

Comment on lines +95 to +97
def _is_producer(value: ast.AST | None) -> bool:
if isinstance(value, ast.Call):
return _callee(value) in _PRODUCERS
Comment on lines +95 to +97
def _is_producer(value: ast.AST | None) -> bool:
if isinstance(value, ast.Call):
return _callee(value) in _PRODUCERS
Comment on lines +143 to +144
if enclosing is not None and value.id in _params(enclosing):
return True
Comment on lines +188 to +193
names = tuple(consumers)
for path in _python_paths(provider, _SRC):
if path in trees or path.startswith(_SECURITY):
continue
facts, failures = _facts_for(provider, path, rule_id)
if not failures and any(name + "(" in line for line in _lines(facts) for name in names):
found = [token for token in _BOOL_LOOKUPS if _present(facts, token)]
if found:
def _code_lines(facts: object) -> list[str]:
return [line for line in _lines(facts) if not line.lstrip().startswith(("#", "def "))]
allow_map = materialize_exec_map(
exec_trust_context_for_project(
project_manifest_path(
manifest_root(ctx.project_root, user_scope=is_user_scope(ctx.scope))
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
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]>
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.

plan/apply P5a: ExecDecision, one executable trust owner without fail-open defaults

2 participants