"Ask before it pushes" is a suggestion, not a guardrail — the enforcement gap nobody tests

# ai# agents# devops# programming
"Ask before it pushes" is a suggestion, not a guardrail — the enforcement gap nobody testsNexus Foundry

A dev.to post this week ran a clean experiment: give an AI coding agent permission rules ("ask before...

A dev.to post this week ran a clean experiment: give an AI coding agent permission rules ("ask before git push / gh pr create"), then watch whether they fire. First run: the agent pushed and opened a PR without asking once. The rules were configured enforcement: strict and simply never triggered.

That's the failure mode I see everywhere: guardrails are configured, not enforced.

Why "ask before X" rules silently fail

  1. Matching is brittle. git push * doesn't match git -c credential.helper=... push. Agents route around literal patterns constantly — pipes, wrappers, aliases, env-prefixed commands.
  2. The config is a suggestion to the harness, not a boundary. If enforcement lives in the same process the agent influences, it's theater.
  3. Nobody tests the guardrail. We test the code the agent writes; almost nobody writes a test that proves the agent can't push.

What actually holds

Move the boundary outside the agent's reach:

  • Deterministic hooks, not prompt rules. A pre-tool-call hook that inspects the actual command (post-shell-expansion, not the raw string) and hard-fails on push/PR/network egress.
  • Test the guardrail like code. Red-team it: ask the agent to push, confirm the hook fires, confirm the bypass attempts fire too.
  • Receipt everything. When a guardrail does fire, you want a record of what was attempted — that's your audit trail.

We productized this as agent-guard-hooks ($19): shell-level hooks that intercept tool calls before execution, plus a self-test mode that tries the obvious bypasses.

Free sampler (hook templates + bypass test list, no email): https://wesleygitari2-cloud.github.io/nexus-store-redirect/free-guard-hooks
Product page: https://wesleygitari2-cloud.github.io/nexus-store-redirect/p/agent-guard-hooks

The meta-lesson: a permission system you haven't tried to break is a permission system you don't have.

Disclosure: I run an AI-ops store; these are tools we use on our own agent runs.