Repository navigation
Description
The problem
The maxChecks per-session cap on guardrail checker calls is a security footgun. Guardrails are a security control — enabling them is an explicit opt-in that already signals awareness of the extra LLM-call cost. A per-session call-count budget that, once exhausted, silently fails open (the checker is skipped for the rest of the session, content goes uninspected) gives a false sense of security: the operator enabled protection and got less protection exactly when the session is busy (an MCP-heavy run racks up mcp__* checks fast). No other security tool I'm aware of silently degrades protection on a volume trigger.
What it is today
internal/adapter/modelhook/breaker.go(checkBudget) — the per-session struct:admit()returnsok=falseonceused >= max, guarded by a mutex.internal/adapter/modelhook/modelhook.go:225— onadmitreturning false, the runner fails open: logs a one-time WARN ("per-session checker budget exhausted; further tool content is NOT inspected this session") and skips the check for the rest of the session.internal/app/guardrails.go:139— resolution: an explicitmaxCheckswins; if the operator only set a model (default advisory rules) and didn't pinmaxChecks, an auto-default of 200 (defaultGuardrailsMaxChecks) is applied.
The cap is distinct from the checker-error fail-open path (onCheckerError, modelhook.go:285) — that one fires on a checker model error/timeout and has its own per-rule failClosed escape + the 3-strike "checker DOWN" escalation. This issue targets only the call-count cap, not the checker-error degrade path (that one is tracked separately in #NNN — add a global checker-down posture toggle).
Proposed change
Remove maxChecks / checkBudget entirely:
- Delete
checkBudget(internal/adapter/modelhook/breaker.go) and thebudgetfield onRunner(modelhook.go:124). - Remove the
admit()gate and the budget-exhausted WARN branch inRunner.check(modelhook.go:225-233). - Remove
Options.MaxChecks(modelhook.go:147),Config.GuardrailsMaxChecks,defaultGuardrailsMaxChecks(guardrails.go:163), themaxChecksYAML key parse inpermconfig, and the auto-200 default-application logic (guardrails.go:139-148). - Update
docs/adr/0021-guardrails.md(Cost model section),docs/architecture.md, and any tests that assert the cap (internal/adapter/modelhook/modelhook_test.go:283,297and any composition/budget tests).
Rationale
- Enabling guardrails is already the opt-in to spend. Operators who enable a security control expect it to run.
- Silent fail-open on a volume trigger is the worst-of-both-worlds: the operator pays the complexity of configuring guardrails and still runs unguarded once busy.
- Cost concerns belong in the operator's provider/billing layer, not as a silent protection-removal gate inside the harness.
- The checker-error degrade path stays (tracked in the companion issue), so an actual checker outage is still handled gracefully.
Out of scope
- The checker-error/timeout fail-open path (
onCheckerError) — that's the companion issue. - The
minContentBytes/maxContentBytessize gates — those are content-shape guards, not a call-count budget, and serve a different purpose (skip trivially-short inbound results / bound oversized content). Keep them.
Activity
fix(lint): add return after t.Fatal to satisfy staticcheck SA5011 (#185)