Documentation
¶
Overview ¶
Package guardrails implements request-content guardrails (G5): regex-PII detection (email/phone/card/API keys) and conservative prompt-injection heuristics. Three enforcement modes driven by config.Guardrails.Mode:
- "log" — findings are reported to telemetry, the request passes through;
- "redact" — matched PII in user/system messages is masked with [REDACTED] before forwarding;
- "block" — any finding rejects the request with 403 guardrail_blocked.
Heuristics are deliberately phrase-level (not word-level) so ordinary developer chat ("ignore the noise in this dataset", "show me the system prompt of your friend") does not false-positive; the eval suite in guardrails_test.go pins that contract.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KindString ¶
KindString joins detected kinds into a stable audit label.
Types ¶
type Config ¶
type Config struct {
Mode string `json:"mode,omitempty"`
PII PIIConfig `json:"pii,omitempty"`
// Injection enables the prompt-injection heuristics. When zero-valued we
// inherit from the mode (see Effective).
Injection bool `json:"injection,omitempty"`
}
Config mirrors the yaml `guardrails:` block. Mode off/empty disables.