Skip to content

fix(exec): pinned hooks denied by policy report the deny, not apm approve (#4044) - #4055

Merged
Daniel Meppiel (danielmeppiel) merged 7 commits into
mainfrom
danielmeppiel-exec-pinned-deny-4044
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 7 commits into
mainfrom
danielmeppiel-exec-pinned-deny-4044

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

TL;DR — When hooks pinned with apm approve are later denied by org policy or by apm deny --user, apm install now prints the existing denied line (hooks skipped (denied). Run 'apm policy explain <pkg>' …) instead of not approved … Run 'apm approve <pkg>'. Approving cannot lift a deny, so the old hint sent users in a loop. Only the diagnostic changes: admission, deployment, lockfile exec_status and the approval prompt are untouched.

Important

Stacked on #4025 (base danielmeppiel-legendary-chainsaw). CI does not run on a non-main base, so the evidence below is the local CI mirror.

Problem (WHY)

  • check_executable_approval (install/exec_gate.py) drops every pinned type from unapproved before denied_exec_types runs, so a pinned hook that the item-admission owner (pinned_exec_status) resolves to TRUST_DENIED never reaches ctx.package_denied_exec_types.
  • log_hooks_skip reads only that set, so it falls back to the "not approved / apm approve" message even though the hooks are hard-denied.
  • The same path hits a pinned package denied in the user store (apm deny --user): the issue record lists it as a control, but it fails on the base too, so this PR fixes it as well.

Approach (WHAT)

Seed the per-package denied set with the pinned TRUST_DENIED verdicts from pinned_exec_status, then union the type-level denies as before. ctx.package_denied_exec_types is read only by log_hooks_skip; the blocked-for-prompt decision still uses unapproved (pinned types excluded) and the pinned TRUST_GATED check, so it is unchanged.

Implementation (HOW)

File Change
src/apm_cli/install/exec_gate.py denied starts from pinned TRUST_DENIED types; denied_exec_types results are unioned in; the set is stored whenever non-empty.
tests/integration/test_pinned_hook_policy_deny_lifecycle.py New installed-CLI lifecycle test (org policy served via the loopback GitHub fixture), marked lifecycle_smoke (5 cases, ~11 s with -n 4).
scripts/architecture_linter/checks/install_lsp_plugin.py, tests/integration/test_architecture_owner_rule_mutations.py Trust-context guard requires the pinned-deny propagation; new mutation case removing it is rejected.
CHANGELOG.md One Fixed line.

Trade-offs

  • MCP pinned denies are also recorded in the set (the scope says "a pinned TRUST_DENIED verdict"); nothing reads MCP from it today, so MCP diagnostics are unchanged (out of scope).
  • No docs change: no page quotes the hooks-skip diagnostic.

Validation

Installed-CLI lifecycle test (APM_BINARY_PATH=.venv/bin/apm), before and after the fix:

Case Before fix After fix
pinned via apm approve, then org deny_all → denied / apm policy explain, no approve hint, exec_status: denied, hooks removed fails passes
pinned, then apm deny --user fails passes
control: unpinned hooks: true, then org deny_all passes passes
control: pinned, then apm deny (project) passes passes
control: pinned, script changed, no deny → still apm approve ../hooky, not denied, exec_status: gated_pending_approval passes passes
  • Same selection with and without the fix (tests/integration/test_pinned_hook_policy_deny_lifecycle.py, test_executables_deny_retires_hooks_lifecycle.py, test_executables_gate_integration.py, tests/unit/install, tests/unit/security, tests/unit/commands/test_approve_deny.py): the only difference is the pinned-org-deny case going from fail to pass; no new failures (the remaining sandbox failures — git signing, installer ownership — are identical both ways).
  • ruff check / ruff format --check (src, tests, architecture linter): clean. pylint R0801: 10.00/10. scripts/lint-auth-signals.sh: clean. scripts/lint-architecture-boundaries.sh: exit 0. Affected mutation tests: 22 passed.

How to test

  • APM_BINARY_PATH=.venv/bin/apm uv run --extra dev pytest tests/integration/test_pinned_hook_policy_deny_lifecycle.py -q
  • Revert src/apm_cli/install/exec_gate.py and rerun: only [pinned-org-deny] and [pinned-user-deny] fail.

Issue and approved scope

Issue: Fixes #4044

Human scope-approval comment: #4044 (comment)

Completes the issue. Out of scope (untouched): bin/ and canvas skip diagnostics (#4052), allow/deny decisions, pin format, apm policy explain output, native-plugin and MCP diagnostics, the approval prompt.

Pre-merge

Type of change

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

Testing

  • Tested locally
  • All existing tests pass (no change in the targeted selection besides the fixed case)
  • Added tests for new functionality (if applicable)

Changelog

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

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour (diagnostic text only).

Co-authored-by: Copilot [email protected]

@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-exec-pinned-deny-4044 branch from a98080f to ca17ec7 Compare November 20, 2026 03:03
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the danielmeppiel-exec-pinned-deny-4044 branch from ca17ec7 to f4024c8 Compare November 20, 2026 03:03
@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(exec): pinned hooks denied by policy report the deny, not apm approve (#4044) fix(exec): pinned hooks denied by policy report the deny, not apm approve (#4044) Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
#3290 moved the canvas skip warning to install/target_warnings.py; the
deny-aware wording moves with 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]>
Base automatically changed from danielmeppiel-legendary-chainsaw to main November 20, 2026 10:11
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:21
Copilot AI balanced review requested due to automatic review settings November 20, 2026 10:21
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 0a9fc2e into main Nov 20, 2026
41 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-exec-pinned-deny-4044 branch November 20, 2026 10:23

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.

🟢 Approval recommended

No active review issues were identified for the change correcting policy-denied pinned-hook diagnostics.

No open issues 🎉

What changed in this PR

Fixes #4044 by making apm install report pinned hooks blocked by organization policy or a user-level deny as denied, directing users to apm policy explain rather than an ineffective approval command. The change reuses existing trust verdicts without changing admission, deployment, lockfile status, or approval prompts.

Changes:

  • Propagates pinned deny verdicts into the hook diagnostic state.
  • Adds five lifecycle cases covering denies and changed-pin behavior.
  • Strengthens the architecture guard, removes the resolved expected failure, and documents the fix.
File Description
tests/​integration/​test_pinned_hook_policy_deny_lifecycle.py Adds lifecycle checks for diagnostics, deployed hooks, and lockfile status.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds mutation coverage for pinned-deny propagation.
tests/​integration/​_gate_machine_kit.py Removes the expected failure tracked by #4044.
src/​apm_cli/​install/​exec_gate.py Includes pinned deny verdicts in per-package diagnostic state.
scripts/​architecture_linter/​checks/​install_lsp_plugin.py Requires pinned-deny propagation in the trust-context guard.
CHANGELOG.md Records the corrected hook-denial diagnostic.

Review effort: Balanced

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
… tracking #4270 (#4094)

Main's #4055 merge stopped deploying the whole plugin (and its bin/)
after approve + --trust-bin, silently; the docs still promise it.

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.

Org-denied hooks report the wrong reason and remediation

2 participants