Repository navigation
Description
The problem
The per-rule prompt override field — which lets an operator replace the built-in checker rubric for a matched rule — is fully implemented end-to-end but completely undocumented in the operator-facing docs. An operator would only discover it by reading Go struct comments in internal/adapter/permconfig/schema.go:257 or internal/app/build.go:787.
The field exists at every layer:
permconfigYAML parse (schema.go:258:Prompt string yaml:"prompt", strict-parse registered atschema.go:285)- composition
GuardrailRule.Prompt(internal/app/build.go:787) modelhook.RuleSpec.Prompt/CompiledRule.prompt(matcher.go:46,131)- runtime resolution in
rubric()(modelhook.go:441): returns the rule'spromptif set, else falls back todefaultPrePrompt/defaultPostPrompt.
What's missing
docs/usage.md (the operator guide)
The guardrails section (lines 1030-1123) and its example YAML block (lines 1080-1104) show match / phases / mode / failClosed but never mention prompt. The field-by-field bullets (lines 1106-1123) cover matcher/block/sanitize/advisory/fail-closed — no prompt bullet.
The example YAML should add a rule using prompt:, e.g.:
guardrails:
model: deepseek/deepseek-v4-flash
rules:
- match: "mcp__*"
mode: block
prompt: >
You are a strict exfiltration guardrail for MCP tool calls.
Check for any credential, secret, or PII being sent to an
external service. Reject anything that looks like a token,
key, or password being transmitted. If uncertain, judge unsafe.And a field bullet:
prompt(optional, per-rule) overrides the built-in inspection rubric (defaultPrePromptfor outbound/pre,defaultPostPromptfor inbound/post). When a rule covers both phases (the default), onepromptreplaces both rubrics — to use different prompts for pre vs post on the same tool matcher, author two rules with mutually exclusivephases. An empty/omittedpromptkeeps the built-in defaults.
docs/adr/0021-guardrails.md
The example config (lines 247-277) should include a prompt: field on at least one rule, and the "Where it lives" / matcher-precedence section should note the per-rule prompt override path (rubric() in modelhook.go).
docs/usage.md startup posture line
The guardrails: ON|OFF … posture line (lines 1073-1078) currently names the resolved model + provenance + rule mode + rule count + maxChecks. It does not mention whether any rule carries a custom prompt — minor, but an operator auditing posture at startup can't tell if a rule overrides the built-in rubric. Consider noting "N custom prompt(s)" in the posture line when any rule sets prompt.
Also: documentation needs updating for #168/#169/#170/#171/#172
While the guardrails docs are being touched, they should be updated to reflect the issues filed in this session (cross-reference, don't pre-implement):
- guardrails: remove maxChecks per-session call-count cap (security footgun) #168 (remove maxChecks): the
maxChecksdocumentation (usage.md lines 1088-1091, ADR 0021 cost-model section) and the startup posture line'smaxChecksmention need removing/adjusting once guardrails: remove maxChecks per-session call-count cap (security footgun) #168 lands. - guardrails: add global checker-down posture toggle (warn default / fail opt-in) #169 (checker-down posture toggle): new
onCheckerDownkey needs documenting once added. - guardrails: surface advisory findings to the TUI (client-visible, model-invisible) #170 (advisory TUI visibility): the "client/model see nothing" language (usage.md line 1054-1057, 1116; ADR 0021) needs amending — advisory findings will surface to the TUI.
- guardrails: flip default mode from advisory to block (advisory becomes opt-in) #171 (default mode → block): the default rule set table (usage.md lines 1048-1052) and the "default advisory" language throughout need updating once the default flips to block.
- guardrails: oversized content is skipped from inspection (maxContentBytes) — should compact-and-check or check in full #172 (oversized content inspection): the
maxContentBytes/ fail-open-on-oversized language (usage.md line 1117-1118, ADR 0021 cost-model) needs updating once the skip-inspection behavior changes.
These are dependent on their respective issues landing; the prompt documentation is independent and can land immediately.
Scope
- Document the
prompt:field indocs/usage.md(example YAML + field bullet + the both-phases caveat). - Document the
prompt:field indocs/adr/0021-guardrails.md(example config + rubric note). - (Optional) Add custom-prompt count to the startup posture line.
- Cross-reference guardrails: remove maxChecks per-session call-count cap (security footgun) #168/guardrails: add global checker-down posture toggle (warn default / fail opt-in) #169/guardrails: surface advisory findings to the TUI (client-visible, model-invisible) #170/guardrails: flip default mode from advisory to block (advisory becomes opt-in) #171/guardrails: oversized content is skipped from inspection (maxContentBytes) — should compact-and-check or check in full #172 as documentation TODOs that should be done in the same docs touch when those issues land.
Activity