feat(delivery): add the guard hook (ADR-0032 layer 2)

Ship one pre-tool-use hook in the delivery package. It denies the Never
tier on every runtime and asks before Odd jobs on Claude Code and Copilot
CLI (denying them on Codex and unknown runtimes):

- guard.py: stdlib-only Python; tokenises the shell line, unwraps
  bash -c / env / sudo / eval / xargs / find -exec / rtk / uv run and
  friends, checks file-tool paths for secret material, and uses read-verb
  allowlists for kubectl, helm, flux and tofu
- hooks.json: no matcher, onFailure: block, 10s timeout
- tests/test-delivery-guard-hook.sh: 281 cases incl. bypass attempts and
  per-runtime output shape
- root apm.yml: executables.allow delivery#0.1.0
- check-executables-allow-sync now covers every plugin shipping hooks/bin
- ADR-0032 amended: Copilot ask kept as an accepted risk, file tools and
  allowlists recorded

Refs #190

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012CqgnwEGtmfsjcoG9QwByN
This commit is contained in:
Defame1297andClaude Opus 5.5 committed 2026-11-23 08:15:14 +00:00
1 parent 6edd66432c
commit a6ff1c14d4
11 files changed
+2244 -110

No files matched your search

@@ -92,6 +92,16 @@ running it in CI on a bot PR hands the bot those credentials. Decided in
user) pushes same-repo branches; Gitea runs a `pull_request` workflow from the PR branch's own copy
and gives same-repo PRs the repo secrets, so a bot branch can read them. Protected file patterns
block the merge, not the run.
- **Accepted risk:** Copilot CLI's TUI auto-approves a hook `ask` (github/copilot-cli#3590, open
since v1.0.53), so on Copilot an odd-job ask may run without a human answer. The owner kept ask
on Copilot rather than deny; Copilot is untested in v1 and the credential boundary still holds.
- The guard hook (`plugins/delivery/.apm/hooks/guard.py`) also checks file-tool paths (Read, Grep,
Edit, Copilot's `view`, Codex's `apply_patch`) against the secret-path globs, not only shell
commands. `kubectl`, `helm`, `flux` and `tofu` are allowlists of read verbs: anything not on
the list is denied, so an unlisted mutating verb fails safe. Codex cannot ask, so odd jobs are
denied there; an unrecognised runtime is treated the same way.
- *Amended 2026-11-23 ([delivery guard hook](https://git.rkdr.net/Mortis/Holocron/issues/190)): Copilot ask kept
as an accepted risk; the guard covers file tools and uses read-verb allowlists.*
- *Amended 2026-11-22 ([Credential boundary setup in ansible-homelab-mono](https://git.rkdr.net/Mortis/Holocron/issues/184)): test paths left
the protected file patterns for the test-path check; the Flux dry run became an offline render,
and live `kubectl diff` left the Read tier;