Skip to content

guardrails: remove maxChecks per-session call-count cap (security footgun) #168

Closed

Description

@JAORMX

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() returns ok=false once used >= max, guarded by a mutex.
  • internal/adapter/modelhook/modelhook.go:225 — on admit returning 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 explicit maxChecks wins; if the operator only set a model (default advisory rules) and didn't pin maxChecks, 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 the budget field on Runner (modelhook.go:124).
  • Remove the admit() gate and the budget-exhausted WARN branch in Runner.check (modelhook.go:225-233).
  • Remove Options.MaxChecks (modelhook.go:147), Config.GuardrailsMaxChecks, defaultGuardrailsMaxChecks (guardrails.go:163), the maxChecks YAML key parse in permconfig, 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,297 and 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 / maxContentBytes size 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions