Skip to content
Cisco AI Defense logo
CiscoAI Security

Judge vs regex — DefenseClaw

Overview

GuardrailInspector.Inspect chooses one of three strategy functions based on guardrail.detection_strategy and the flat per-direction overrides. The default global strategy is regex_judge, completion defaults to regex_only, and judge_sweep defaults to true.

Mode matrix

ModeLatencyCost per callFalse-positive rateBlocks mid-streamDeterministicBest for
regex_onlyLocal regex/rule path$0 LLM spendHigher on ambiguous patternsYes, through InspectMidStreamYesKnown-bad strings, secrets, sensitive paths, dangerous commands
regex_judgeLocal regex first; judge only for review signals or no-signal sweep when enabledJudge spend only when adjudication or sweep runsLower when judge is availableMid-stream still regex-onlySemi-deterministicBalanced default for prompt and tool-call traffic
judge_firstLLM judge path plus regex safety netJudge spend on every eligible inspectionLowest semantic miss rate, provider-dependentMid-stream still regex-onlyNoSemantic intent detection and high-risk deployments

Decision path

Rendering diagram…

Strategy details

regex_only

inspectRegexOnly runs scanLocalPatterns, which includes built-in triage patterns and the full rule engine. If scanner_mode is remote or both and Cisco AI Defense is configured, the remote scanner can be merged too. High or critical local findings produce action=block; lower findings alert.

regex_judge

inspectRegexJudge separates triage signals into high-confidence and needs-review groups.

CaseBehavior
High-signal triageBuilds an immediate local-triage verdict.
High or critical rule-engine findingBlocks immediately after optional Cisco merge.
Needs-review signalsCalls LLMJudge.AdjudicateFindings; judge failure falls back to a medium alert.
No signals and judge_sweep=trueCalls LLMJudge.RunJudges for full classification.

judge_first

inspectJudgeFirst runs the judge and triage concurrently. If the judge fails or returns an error verdict, the inspector falls back to regex_only. If the judge succeeds, high-signal regex and high or critical rule-engine findings are still merged into the judge verdict.

Streaming semantics

InspectMidStream is fixed to inspectRegexOnly. Streaming output can therefore be blocked in action mode by deterministic patterns, but the LLM judge is reserved for pre-call and final post-call content.

Cache keying

The LLM judge cache is process-local. internal/guardrail/verdict_cache.go builds keys from kind, model, direction, and content. A generation counter is stored with each entry and incremented by Invalidate, so entries produced before a rule-pack or policy reload become misses without needing an O(n) clear.

Tuning knobs

KnobSourceUse
guardrail.detection_strategyGuardrailConfigGlobal fallback strategy.
guardrail.detection_strategy_promptGuardrailConfigPrompt override.
guardrail.detection_strategy_completionGuardrailConfigCompletion override; default regex_only.
guardrail.detection_strategy_tool_callGuardrailConfigTool-call override.
guardrail.judge_sweepGuardrailConfigWhether regex_judge judges no-signal content.
data.guardrail.block_thresholdpolicies/rego/data.jsonRego threshold for final block decisions.
data.guardrail.alert_thresholdpolicies/rego/data.jsonRego threshold for final alert decisions.

Related