The baseline fails closed with two judges, and a judge not answering is a notification
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
07af03aa93
commit
c553f2041a
11 files changed
+67
-22
No files matched your search
@@ -160,6 +160,14 @@ func newServerCmd() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
rt.SetNotifier(notifier)
|
||||
if gate != nil && notifier != nil {
|
||||
gate.SetJudgeAlarm(func(model string, err error) {
|
||||
notifier.Notify(notify.JudgeUnavailable, model,
|
||||
fmt.Sprintf("the guardrails judge %s gives no verdict (%v): policies with fail: closed "+
|
||||
"refuse what it should read, fail: open serve it unjudged", model, err),
|
||||
map[string]any{"model": model, "error": err.Error()})
|
||||
})
|
||||
}
|
||||
if notifier != nil {
|
||||
log.Info("notifications on", "webhooks", len(cfg.Notify.Webhooks))
|
||||
}
|
||||
|
||||
@@ -285,9 +285,10 @@ func guardSection(judge bool) string {
|
||||
`
|
||||
if judge {
|
||||
j = ` # A judge model reads what patterns cannot: violence, weapons, abuse,
|
||||
# self-harm. It runs on a CPU, about half a second for a short text;
|
||||
# an answer is read every 600 characters as it streams. Slower than
|
||||
# latency_budget, the request is served and recorded as flagged.
|
||||
# self-harm. Two replicas run on CPUs with AVX2, about half a second
|
||||
# for a short text; an answer is read every 600 characters as it
|
||||
# streams. With fail: closed, a request the judge cannot read within
|
||||
# latency_budget is refused (503); open serves it, flagged, unjudged.
|
||||
# Defamation (S5), specialized advice (S6), intellectual property (S8)
|
||||
# and elections (S13) are left out: they refuse too much ordinary work.
|
||||
judge:
|
||||
@@ -305,7 +306,7 @@ guard:
|
||||
default: [baseline]
|
||||
policies:
|
||||
baseline:
|
||||
fail: open
|
||||
fail: closed
|
||||
input:
|
||||
pii: {secret: block, card: redact}
|
||||
injection: flag
|
||||
|
||||
@@ -458,7 +458,9 @@ func guardModel(source string) catalog.Model {
|
||||
Source: source,
|
||||
Role: catalog.RoleGuard,
|
||||
Guard: &catalog.GuardModel{Format: "llamaguard3", Categories: llamaGuard3Categories},
|
||||
Scaling: catalog.Scaling{Min: 1, Max: 1},
|
||||
// Two: every judged request waits on it, and with fail: closed a
|
||||
// judge that is not there refuses everything.
|
||||
Scaling: catalog.Scaling{Min: 2, Max: 2},
|
||||
Profiles: []catalog.Profile{{
|
||||
Name: "cpu", Engine: "llamacpp", Priority: 100, MinMemoryGB: 2,
|
||||
Args: []string{"--ctx-size", "8192"},
|
||||
|
||||
@@ -144,6 +144,9 @@ func TestTheInstalledConfigurationIsHardenedAndLoads(t *testing.T) {
|
||||
t.Errorf("judge=%v: guard.default %v", judge, cfg.Guard.Default)
|
||||
}
|
||||
p := cfg.Guard.Policies["baseline"]
|
||||
if p.Fail != "closed" {
|
||||
t.Errorf("judge=%v: the baseline fails %q", judge, p.Fail)
|
||||
}
|
||||
if (p.Judge != nil) != judge {
|
||||
t.Errorf("judge=%v: the policy's judge is %+v", judge, p.Judge)
|
||||
}
|
||||
@@ -164,7 +167,7 @@ func TestTheGuardModelIsAValidJudge(t *testing.T) {
|
||||
t.Fatalf("not a valid catalog entry: %v", err)
|
||||
}
|
||||
got, _ := c.Resolve(guardModelName)
|
||||
if !got.IsGuard() || got.Guard.Format != "llamaguard3" || len(got.Guard.Categories) != 13 {
|
||||
if !got.IsGuard() || got.Guard.Format != "llamaguard3" || len(got.Guard.Categories) != 13 || got.Scaling.Min != 2 {
|
||||
t.Errorf("%+v", got)
|
||||
}
|
||||
for _, p := range got.Profiles {
|
||||
|
||||
Reference in new issue
Block a user