Skip to content

guardrails: flip default mode from advisory to block (advisory becomes opt-in) #171

Description

@JAORMX

The problem

The default guardrail rule set (internal/app/guardrails.go:173, defaultGuardrailSpecs) ships every rule in advisory mode:

var defaultGuardrailSpecs = []modelhook.RuleSpec{
	{Match: "WebSearch", Phases: []string{"pre", "post"}, Mode: string(modelhook.ModeAdvisory)},
	{Match: "WebFetch", Phases: []string{"post"}, Mode: string(modelhook.ModeAdvisory)},
	{Match: "mcp__*", Phases: []string{"pre", "post"}, Mode: string(modelhook.ModeAdvisory)},
}

The ADR 0021 rationale was "the operator measures the false-positive rate before promoting a rule to block/sanitize." But combined with #170 (advisory findings are invisible to the TUI), advisory mode was a black hole: findings fired, vanished into the operator log, and never got promoted because the signal never surfaced in the operator's primary interface. An operator who enables a security control expects enforcement, not an invisible observe-only mode that requires log-grepping to discover it's working.

Proposed change

Flip the default rule set to block; make advisory an opt-in.

When a guardrail model is configured but the operator authors no explicit rules: list, the built-in default rules ship in block mode:

Tool matcher Phases Mode (new default)
WebSearch pre + post block
WebFetch post block
mcp__* pre + post block

Advisory becomes something the operator explicitly opts into — either per-rule (mode: advisory in an explicit rules: list) or via a global default-mode toggle (see below).

Global default-mode toggle

Add an operator-tier config key that sets the mode the built-in default rules ship in, so the operator can choose the posture without authoring a full rule list:

guardrails:
  model: deepseek/deepseek-v4-flash
  defaultMode: block   # default; "advisory" opts into observe-only; "sanitize" for rewrite

Resolution:

  • defaultMode sets the Mode field on every entry in defaultGuardrailSpecs at compile time.
  • An explicit rules: list still replaces the defaults entirely (unchanged behaviour — effectiveGuardrailSpecs, guardrails.go:189).
  • Per-rule mode in an explicit list overrides the global defaultMode (the per-rule value wins; defaultMode only fills in for the built-in defaults).

What changes in code

  • defaultGuardrailSpecs entries change from ModeAdvisory to ModeBlock (the literal default).
  • foldOperatorGuardrails (guardrails.go:21) reads the new defaultMode YAML key onto Config.
  • effectiveGuardrailSpecs (guardrails.go:189) applies defaultMode to the built-in specs when no explicit rules are configured (the usedDefaults path).
  • permconfig parses defaultMode (strict, operator-tier-only — same discipline as the rest of guardrails:).
  • ADR 0021 (Default rule set section), docs/architecture.md, docs/usage.md updated.
  • Tests: default rules compile to block; defaultMode: advisory downgrades; explicit rules: ignores defaultMode; the e2e guardrails test (e2e/guardrails_test.go) updated for the new default.

Rationale

Out of scope

Ref: #168, #169, #170.

Activity

  1. JAORMX commented on Jun 24, 2026

    @JAORMX
    ContributorAuthor

    Dependency note: this issue depends on #170 (advisory findings surface to the TUI) for advisory mode to be a useful opt-in. If #170 hasn't landed, an operator who sets defaultMode: advisory gets the same invisible-findings black hole this issue's rationale argues against.

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