Skip to content

guardrails: document the per-rule prompt override field (+ update docs for #168-#172) #173

Description

@JAORMX

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:

  • permconfig YAML parse (schema.go:258: Prompt string yaml:"prompt", strict-parse registered at schema.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's prompt if set, else falls back to defaultPrePrompt/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 (defaultPrePrompt for outbound/pre, defaultPostPrompt for inbound/post). When a rule covers both phases (the default), one prompt replaces both rubrics — to use different prompts for pre vs post on the same tool matcher, author two rules with mutually exclusive phases. An empty/omitted prompt keeps 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):

These are dependent on their respective issues landing; the prompt documentation is independent and can land immediately.

Scope

Ref: #168, #169, #170, #171, #172.

Activity

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