Enforcement hooks: what apm can ship and portable alternatives #168

Closed
opened 2026-11-12 18:05:33 +00:00 by Claude · 1 comment
Owner

Part of #166

Question

Can the infra package enforce (not just instruct) the safety stance on the map — block kubectl apply/delete, helm upgrade, un-checked ansible-playbook, tofu apply, vault decryption and reads of vault password files unless a human has approved — and through what mechanism?

  • What hook primitives apm supports (format, events, how it deploys them — see how kyberforge ships its SessionStart hook, ADR-0019), and which targets (Claude Code, Copilot, Codex, Gemini, Cursor) actually receive and honour them.
  • Whether a pre-tool-use style hook can inspect command arguments and deny/ask, per target.
  • Portable alternatives where hooks don't reach: host permission settings, wrapper scripts on PATH, pre-commit/pre-push, kube RBAC / read-only kubeconfig for agents, separate credentials for apply.
  • Recommend a layered enforcement design with the gaps named per provider.
Part of #166 ## Question Can the infra package *enforce* (not just instruct) the safety stance on the map — block `kubectl apply/delete`, `helm upgrade`, un-checked `ansible-playbook`, `tofu apply`, vault decryption and reads of vault password files unless a human has approved — and through what mechanism? - What hook primitives apm supports (format, events, how it deploys them — see how `kyberforge` ships its `SessionStart` hook, ADR-0019), and **which targets** (Claude Code, Copilot, Codex, Gemini, Cursor) actually receive and honour them. - Whether a pre-tool-use style hook can inspect command arguments and deny/ask, per target. - Portable alternatives where hooks don't reach: host permission settings, wrapper scripts on PATH, pre-commit/pre-push, kube RBAC / read-only kubeconfig for agents, separate credentials for apply. - Recommend a layered enforcement design with the gaps named per provider.
Claude added this to the Map: Infra and agent-team packages milestone 2026-11-12 18:05:33 +00:00
Claude added the Wayfinder/Research label 2026-11-12 18:05:33 +00:00
Claude added a new dependency 2026-11-12 18:05:54 +00:00
Author
Owner

Resolution

Findings: docs/research/infra-packages/enforcement-hooks.md on research/enforcement-hooks (throwaway branch, never merged). Sources: apm 0.28.0 source and each provider's official docs (Context7 was unavailable).

  • Yes, apm can ship hooks: .apm/hooks/ deploys to Claude, Copilot, Codex, Gemini, Cursor (not OpenCode). Events are renamed per target; tool-name matchers are not translated; no permission/sandbox settings ship. Codex/Gemini only receive hooks if .codex//.gemini/ already exist; Cursor output unverified.
  • Deny works everywhere (pre-tool hook reads the command; exit 2 + stderr). Ask (human approval) only in Claude Code and Copilot CLI — Codex treats it as allow, Copilot cloud as deny, Gemini undocumented.
  • Hooks are a guardrail, not a boundary, per every provider's docs.

Recommended layering: skill instructions → one portable matcher-less guard hook (through apm's executable-trust gate) → documented host settings → credential boundary (read-only kubeconfig, apply creds the agent never holds, unreadable vault password, branch protection) → infra-repo pre-commit/CI. PATH wrappers rejected.

Surfaced conflict (vault password vs --check) carried to the Safety model ticket.

## Resolution Findings: [`docs/research/infra-packages/enforcement-hooks.md` on `research/enforcement-hooks`](https://git.rkdr.net/Defame1297/holocron/src/branch/research/enforcement-hooks/docs/research/infra-packages/enforcement-hooks.md) (throwaway branch, never merged). Sources: apm 0.28.0 source and each provider's official docs (Context7 was unavailable). - **Yes, apm can ship hooks**: `.apm/hooks/` deploys to Claude, Copilot, Codex, Gemini, Cursor (not OpenCode). Events are renamed per target; tool-name matchers are **not** translated; no permission/sandbox settings ship. Codex/Gemini only receive hooks if `.codex/`/`.gemini/` already exist; Cursor output unverified. - **Deny works everywhere** (pre-tool hook reads the command; exit 2 + stderr). **Ask (human approval) only in Claude Code and Copilot CLI** — Codex treats it as allow, Copilot cloud as deny, Gemini undocumented. - **Hooks are a guardrail, not a boundary**, per every provider's docs. **Recommended layering:** skill instructions → one portable matcher-less guard hook (through apm's executable-trust gate) → documented host settings → **credential boundary** (read-only kubeconfig, apply creds the agent never holds, unreadable vault password, branch protection) → infra-repo pre-commit/CI. PATH wrappers rejected. Surfaced conflict (vault password vs `--check`) carried to the Safety model ticket.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: Mortis/Holocron#168