Repository navigation
RFC: deterministic pre-execution guardrails for terminal commands (Grimdall hook) #3329
grimdalltech
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
Propose an opt-in hook that wraps CodeCompanion's command-execution / tool-approval flow to add deterministic, below-the-model guardrails: block destructive commands, deny reads of secret files, and enforce an egress allowlist. Shadow-mode (log-only) by default — zero behavior change unless enabled.
Motivation
CodeCompanion runs commands and reads/writes files directly in the user's environment with the user's credentials. Today the safety boundary is the user approving each action in the Neovim UI. That boundary disappears in agent mode and non-interactive automation, where there's no deterministic check between the model's output and the shell — the classic "confused deputy" problem.
Proposed integration (corrected)
The seam is the command-execution / tool-approval flow, not the adapter layer. A single Lua module wraps that path so that, before a command runs, it:
rm -rf,DROP TABLE,chmod -R 000, fork bombs, etc.).~/.ssh,~/.aws,.env,*.pem.Default is shadow mode: log what it would block, enforce only when enabled.
Rough Lua sketch
grimdall.check()shells out to grimdall-os (MIT, <2ms) and returns a structured allow/deny with a reason. The plugin stays opt-in and shadow-mode by default.Non-goals
Happy to open a PR with the module + tests once the exact command-execution seam is confirmed.
All reactions