feat(guard): a model judge's answer, basis and eval standing are recorded in every verdict, clean answers included (audit requirement)

This commit is contained in:
sam committed 2026-11-16 11:12:15 +11:00
1 parent 4657ff2646
commit 4cdb5996c5
7 files changed
+306 -24

No files matched your search

+189 -24
View File
@@ -814,7 +814,11 @@ type JudgeResponse struct {
Ceiling Ceiling `protobuf:"varint,1,opt,name=ceiling,proto3,enum=guard.v1.Ceiling" json:"ceiling,omitempty"`
Findings []*Finding `protobuf:"bytes,2,rep,name=findings,proto3" json:"findings,omitempty"`
// blind_spots are what the guard could not see.
BlindSpots []string `protobuf:"bytes,3,rep,name=blind_spots,json=blindSpots,proto3" json:"blind_spots,omitempty"`
BlindSpots []string `protobuf:"bytes,3,rep,name=blind_spots,json=blindSpots,proto3" json:"blind_spots,omitempty"`
// judges is every model judgement the verdict rests on, clean answers
// included. A guard that asked a model records the answer here, so the
// verdict can be audited without asking the model again.
Judges []*JudgeRecord `protobuf:"bytes,4,rep,name=judges,proto3" json:"judges,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
@@ -870,6 +874,149 @@ func (x *JudgeResponse) GetBlindSpots() []string {
return nil
}
func (x *JudgeResponse) GetJudges() []*JudgeRecord {
if x != nil {
return x.Judges
}
return nil
}
// JudgeRecord is what one model judge answered and what it was judged on.
type JudgeRecord struct {
state protoimpl.MessageState `protogen:"open.v1"`
// model is the model that judged.
Model string `protobuf:"bytes,1,opt,name=model,proto3" json:"model,omitempty"`
// result_id identifies the judge's result with the service that ran it.
ResultId string `protobuf:"bytes,2,opt,name=result_id,json=resultId,proto3" json:"result_id,omitempty"`
// answer is the choice the judge settled on, such as "complies".
Answer string `protobuf:"bytes,3,opt,name=answer,proto3" json:"answer,omitempty"`
Confidence float64 `protobuf:"fixed64,4,opt,name=confidence,proto3" json:"confidence,omitempty"`
// reason is the judge's own reasoning, or why the call failed.
Reason string `protobuf:"bytes,5,opt,name=reason,proto3" json:"reason,omitempty"`
// basis is the text the judge was given beyond the action itself, such as
// the policy rules. basis_digest is its SHA-256 in hex.
Basis string `protobuf:"bytes,6,opt,name=basis,proto3" json:"basis,omitempty"`
BasisDigest string `protobuf:"bytes,7,opt,name=basis_digest,json=basisDigest,proto3" json:"basis_digest,omitempty"`
// answers is every question's answer as JSON: choice, probabilities and
// confidence.
Answers []byte `protobuf:"bytes,8,opt,name=answers,proto3" json:"answers,omitempty"`
// trusted says the judge has passed its recorded eval, so its verdict sets
// a ceiling. When false, advisory_reason says why.
Trusted bool `protobuf:"varint,9,opt,name=trusted,proto3" json:"trusted,omitempty"`
AdvisoryReason string `protobuf:"bytes,10,opt,name=advisory_reason,json=advisoryReason,proto3" json:"advisory_reason,omitempty"`
// eval_date is the date of the eval the judge's standing comes from.
EvalDate string `protobuf:"bytes,11,opt,name=eval_date,json=evalDate,proto3" json:"eval_date,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *JudgeRecord) Reset() {
*x = JudgeRecord{}
mi := &file_guard_v1_guard_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *JudgeRecord) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*JudgeRecord) ProtoMessage() {}
func (x *JudgeRecord) ProtoReflect() protoreflect.Message {
mi := &file_guard_v1_guard_proto_msgTypes[11]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use JudgeRecord.ProtoReflect.Descriptor instead.
func (*JudgeRecord) Descriptor() ([]byte, []int) {
return file_guard_v1_guard_proto_rawDescGZIP(), []int{11}
}
func (x *JudgeRecord) GetModel() string {
if x != nil {
return x.Model
}
return ""
}
func (x *JudgeRecord) GetResultId() string {
if x != nil {
return x.ResultId
}
return ""
}
func (x *JudgeRecord) GetAnswer() string {
if x != nil {
return x.Answer
}
return ""
}
func (x *JudgeRecord) GetConfidence() float64 {
if x != nil {
return x.Confidence
}
return 0
}
func (x *JudgeRecord) GetReason() string {
if x != nil {
return x.Reason
}
return ""
}
func (x *JudgeRecord) GetBasis() string {
if x != nil {
return x.Basis
}
return ""
}
func (x *JudgeRecord) GetBasisDigest() string {
if x != nil {
return x.BasisDigest
}
return ""
}
func (x *JudgeRecord) GetAnswers() []byte {
if x != nil {
return x.Answers
}
return nil
}
func (x *JudgeRecord) GetTrusted() bool {
if x != nil {
return x.Trusted
}
return false
}
func (x *JudgeRecord) GetAdvisoryReason() string {
if x != nil {
return x.AdvisoryReason
}
return ""
}
func (x *JudgeRecord) GetEvalDate() string {
if x != nil {
return x.EvalDate
}
return ""
}
var File_guard_v1_guard_proto protoreflect.FileDescriptor
const file_guard_v1_guard_proto_rawDesc = "" +
@@ -925,12 +1072,28 @@ const file_guard_v1_guard_proto_rawDesc = "" +
"\aFinding\x12\x12\n" +
"\x04text\x18\x01 \x01(\tR\x04text\x12\x1a\n" +
"\bevidence\x18\x02 \x01(\tR\bevidence\x12.\n" +
"\bstrength\x18\x03 \x01(\x0e2\x12.guard.v1.StrengthR\bstrength\"\x8c\x01\n" +
"\bstrength\x18\x03 \x01(\x0e2\x12.guard.v1.StrengthR\bstrength\"\xbb\x01\n" +
"\rJudgeResponse\x12+\n" +
"\aceiling\x18\x01 \x01(\x0e2\x11.guard.v1.CeilingR\aceiling\x12-\n" +
"\bfindings\x18\x02 \x03(\v2\x11.guard.v1.FindingR\bfindings\x12\x1f\n" +
"\vblind_spots\x18\x03 \x03(\tR\n" +
"blindSpots*\x95\x01\n" +
"blindSpots\x12-\n" +
"\x06judges\x18\x04 \x03(\v2\x15.guard.v1.JudgeRecordR\x06judges\"\xc3\x02\n" +
"\vJudgeRecord\x12\x14\n" +
"\x05model\x18\x01 \x01(\tR\x05model\x12\x1b\n" +
"\tresult_id\x18\x02 \x01(\tR\bresultId\x12\x16\n" +
"\x06answer\x18\x03 \x01(\tR\x06answer\x12\x1e\n" +
"\n" +
"confidence\x18\x04 \x01(\x01R\n" +
"confidence\x12\x16\n" +
"\x06reason\x18\x05 \x01(\tR\x06reason\x12\x14\n" +
"\x05basis\x18\x06 \x01(\tR\x05basis\x12!\n" +
"\fbasis_digest\x18\a \x01(\tR\vbasisDigest\x12\x18\n" +
"\aanswers\x18\b \x01(\fR\aanswers\x12\x18\n" +
"\atrusted\x18\t \x01(\bR\atrusted\x12'\n" +
"\x0fadvisory_reason\x18\n" +
" \x01(\tR\x0eadvisoryReason\x12\x1b\n" +
"\teval_date\x18\v \x01(\tR\bevalDate*\x95\x01\n" +
"\rReversibility\x12\x1d\n" +
"\x19REVERSIBILITY_UNSPECIFIED\x10\x00\x12&\n" +
"\"REVERSIBILITY_UNDONE_AUTOMATICALLY\x10\x01\x12\x1d\n" +
@@ -968,7 +1131,7 @@ func file_guard_v1_guard_proto_rawDescGZIP() []byte {
}
var file_guard_v1_guard_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
var file_guard_v1_guard_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_guard_v1_guard_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
var file_guard_v1_guard_proto_goTypes = []any{
(Reversibility)(0), // 0: guard.v1.Reversibility
(Ceiling)(0), // 1: guard.v1.Ceiling
@@ -984,35 +1147,37 @@ var file_guard_v1_guard_proto_goTypes = []any{
(*Evidence)(nil), // 11: guard.v1.Evidence
(*Finding)(nil), // 12: guard.v1.Finding
(*JudgeResponse)(nil), // 13: guard.v1.JudgeResponse
nil, // 14: guard.v1.ConfigureRequest.SettingsEntry
nil, // 15: guard.v1.ConfigureRequest.SecretsEntry
(*durationpb.Duration)(nil), // 16: google.protobuf.Duration
(*timestamppb.Timestamp)(nil), // 17: google.protobuf.Timestamp
(*JudgeRecord)(nil), // 14: guard.v1.JudgeRecord
nil, // 15: guard.v1.ConfigureRequest.SettingsEntry
nil, // 16: guard.v1.ConfigureRequest.SecretsEntry
(*durationpb.Duration)(nil), // 17: google.protobuf.Duration
(*timestamppb.Timestamp)(nil), // 18: google.protobuf.Timestamp
}
var file_guard_v1_guard_proto_depIdxs = []int32{
14, // 0: guard.v1.ConfigureRequest.settings:type_name -> guard.v1.ConfigureRequest.SettingsEntry
15, // 1: guard.v1.ConfigureRequest.secrets:type_name -> guard.v1.ConfigureRequest.SecretsEntry
15, // 0: guard.v1.ConfigureRequest.settings:type_name -> guard.v1.ConfigureRequest.SettingsEntry
16, // 1: guard.v1.ConfigureRequest.secrets:type_name -> guard.v1.ConfigureRequest.SecretsEntry
0, // 2: guard.v1.Effect.reversibility:type_name -> guard.v1.Reversibility
8, // 3: guard.v1.JudgeRequest.target:type_name -> guard.v1.Target
7, // 4: guard.v1.JudgeRequest.effect:type_name -> guard.v1.Effect
9, // 5: guard.v1.JudgeRequest.run:type_name -> guard.v1.RunContext
16, // 6: guard.v1.JudgeRequest.deadline:type_name -> google.protobuf.Duration
17, // 7: guard.v1.JudgeRequest.at:type_name -> google.protobuf.Timestamp
17, // 6: guard.v1.JudgeRequest.deadline:type_name -> google.protobuf.Duration
18, // 7: guard.v1.JudgeRequest.at:type_name -> google.protobuf.Timestamp
11, // 8: guard.v1.JudgeRequest.evidence:type_name -> guard.v1.Evidence
2, // 9: guard.v1.Finding.strength:type_name -> guard.v1.Strength
1, // 10: guard.v1.JudgeResponse.ceiling:type_name -> guard.v1.Ceiling
12, // 11: guard.v1.JudgeResponse.findings:type_name -> guard.v1.Finding
3, // 12: guard.v1.GuardService.Configure:input_type -> guard.v1.ConfigureRequest
5, // 13: guard.v1.GuardService.Describe:input_type -> guard.v1.DescribeRequest
10, // 14: guard.v1.GuardService.Judge:input_type -> guard.v1.JudgeRequest
4, // 15: guard.v1.GuardService.Configure:output_type -> guard.v1.ConfigureResponse
6, // 16: guard.v1.GuardService.Describe:output_type -> guard.v1.DescribeResponse
13, // 17: guard.v1.GuardService.Judge:output_type -> guard.v1.JudgeResponse
15, // [15:18] is the sub-list for method output_type
12, // [12:15] is the sub-list for method input_type
12, // [12:12] is the sub-list for extension type_name
12, // [12:12] is the sub-list for extension extendee
0, // [0:12] is the sub-list for field type_name
14, // 12: guard.v1.JudgeResponse.judges:type_name -> guard.v1.JudgeRecord
3, // 13: guard.v1.GuardService.Configure:input_type -> guard.v1.ConfigureRequest
5, // 14: guard.v1.GuardService.Describe:input_type -> guard.v1.DescribeRequest
10, // 15: guard.v1.GuardService.Judge:input_type -> guard.v1.JudgeRequest
4, // 16: guard.v1.GuardService.Configure:output_type -> guard.v1.ConfigureResponse
6, // 17: guard.v1.GuardService.Describe:output_type -> guard.v1.DescribeResponse
13, // 18: guard.v1.GuardService.Judge:output_type -> guard.v1.JudgeResponse
16, // [16:19] is the sub-list for method output_type
13, // [13:16] is the sub-list for method input_type
13, // [13:13] is the sub-list for extension type_name
13, // [13:13] is the sub-list for extension extendee
0, // [0:13] is the sub-list for field type_name
}
func init() { file_guard_v1_guard_proto_init() }
@@ -1026,7 +1191,7 @@ func file_guard_v1_guard_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_guard_v1_guard_proto_rawDesc), len(file_guard_v1_guard_proto_rawDesc)),
NumEnums: 3,
NumMessages: 13,
NumMessages: 14,
NumExtensions: 0,
NumServices: 1,
},
+24
View File
@@ -56,6 +56,23 @@ type GuardAnswer struct {
Ceiling int
Findings []GuardFinding
BlindSpots []string
Judges []GuardJudge
}
// GuardJudge is what one model judge answered and what it was judged on.
// Answers is the judge service's answers as JSON.
type GuardJudge struct {
Model string
ResultID string
Answer string
Confidence float64
Reason string
Basis string
BasisDigest string
Answers []byte
Trusted bool
AdvisoryReason string
EvalDate string
}
// Guard is a running guard extension.
@@ -107,6 +124,13 @@ func (g *Guard) Judge(ctx context.Context, r GuardRequest) (GuardAnswer, error)
for _, f := range resp.GetFindings() {
a.Findings = append(a.Findings, GuardFinding{Text: f.GetText(), Evidence: f.GetEvidence(), Strength: strengthName(f.GetStrength())})
}
for _, j := range resp.GetJudges() {
a.Judges = append(a.Judges, GuardJudge{
Model: j.GetModel(), ResultID: j.GetResultId(), Answer: j.GetAnswer(), Confidence: j.GetConfidence(),
Reason: j.GetReason(), Basis: j.GetBasis(), BasisDigest: j.GetBasisDigest(), Answers: j.GetAnswers(),
Trusted: j.GetTrusted(), AdvisoryReason: j.GetAdvisoryReason(), EvalDate: j.GetEvalDate(),
})
}
return a, nil
}
+7
View File
@@ -86,5 +86,12 @@ func (e extensionGuard) Judge(ctx context.Context, a Action) (Verdict, error) {
for _, f := range ans.Findings {
v.Findings = append(v.Findings, Finding{Text: f.Text, Evidence: f.Evidence, Strength: f.Strength})
}
for _, j := range ans.Judges {
v.Judges = append(v.Judges, JudgeRecord{
Model: j.Model, ResultID: j.ResultID, Answer: j.Answer, Confidence: j.Confidence, Reason: j.Reason,
Basis: j.Basis, BasisDigest: j.BasisDigest, Answers: j.Answers,
Trusted: j.Trusted, AdvisoryReason: j.AdvisoryReason, EvalDate: j.EvalDate,
})
}
return v, nil
}
+23
View File
@@ -72,6 +72,27 @@ type Finding struct {
Strength string `json:"strength,omitzero"`
}
// JudgeRecord is what one model judge answered and what it was judged on,
// kept whole so the verdict can be audited without asking the model again.
type JudgeRecord struct {
Model string `json:"model,omitzero"`
ResultID string `json:"result_id,omitzero"`
Answer string `json:"answer,omitzero"`
Confidence float64 `json:"confidence,omitzero"`
Reason string `json:"reason,omitzero"`
// Basis is the text the judge was given beyond the action, and
// BasisDigest its SHA-256.
Basis string `json:"basis,omitzero"`
BasisDigest string `json:"basis_digest,omitzero"`
// Answers is the judge service's answers as it returned them.
Answers jsontext.Value `json:"answers,omitzero"`
// Trusted says the judge has passed its eval; AdvisoryReason says why
// not when it hasn't.
Trusted bool `json:"trusted,omitzero"`
AdvisoryReason string `json:"advisory_reason,omitzero"`
EvalDate string `json:"eval_date,omitzero"`
}
// Verdict is one guard's judgement of one action.
type Verdict struct {
Guard string `json:"guard"`
@@ -82,6 +103,8 @@ type Verdict struct {
Ceiling Level `json:"ceiling"`
Findings []Finding `json:"findings,omitzero"`
BlindSpots []string `json:"blind_spots,omitzero"`
// Judges is every model judgement the verdict rests on.
Judges []JudgeRecord `json:"judges,omitzero"`
// Advisory verdicts are recorded and set no ceiling.
Advisory bool `json:"advisory,omitzero"`
// Failed says why the guard couldn't answer; its ceiling is then
+30
View File
@@ -122,4 +122,34 @@ message JudgeResponse {
repeated Finding findings = 2;
// blind_spots are what the guard could not see.
repeated string blind_spots = 3;
// judges is every model judgement the verdict rests on, clean answers
// included. A guard that asked a model records the answer here, so the
// verdict can be audited without asking the model again.
repeated JudgeRecord judges = 4;
}
// JudgeRecord is what one model judge answered and what it was judged on.
message JudgeRecord {
// model is the model that judged.
string model = 1;
// result_id identifies the judge's result with the service that ran it.
string result_id = 2;
// answer is the choice the judge settled on, such as "complies".
string answer = 3;
double confidence = 4;
// reason is the judge's own reasoning, or why the call failed.
string reason = 5;
// basis is the text the judge was given beyond the action itself, such as
// the policy rules. basis_digest is its SHA-256 in hex.
string basis = 6;
string basis_digest = 7;
// answers is every question's answer as JSON: choice, probabilities and
// confidence.
bytes answers = 8;
// trusted says the judge has passed its recorded eval, so its verdict sets
// a ceiling. When false, advisory_reason says why.
bool trusted = 9;
string advisory_reason = 10;
// eval_date is the date of the eval the judge's standing comes from.
string eval_date = 11;
}
+18
View File
@@ -64,6 +64,24 @@ const ceilingTone = (v: Verdict): Tone => (v.failed ? "warn" : "secondary");
{{ f.text }}<template v-if="f.evidence">: {{ f.evidence }}</template>
</span>
<span v-for="b in v.blind_spots" :key="b" class="text-caption text-muted-foreground">Blind spot: {{ b }}</span>
<div v-for="(j, i) in v.judges" :key="i" class="flex flex-col gap-0.5 border-l pl-2">
<span class="flex flex-wrap items-center gap-2 text-caption">
<span class="font-medium">{{ j.model || 'Judge' }}</span>
<Badge v-if="j.answer" variant="secondary">{{ j.answer }}</Badge>
<span v-if="j.confidence" class="text-muted-foreground">Confidence {{ j.confidence.toFixed(2) }}</span>
<Badge :variant="j.trusted ? 'secondary' : 'outline'">{{ j.trusted ? 'trusted' : 'advisory' }}</Badge>
</span>
<span v-if="j.reason" class="text-caption text-muted-foreground">{{ j.reason }}</span>
<span v-if="!j.trusted && j.advisory_reason" class="text-caption text-muted-foreground">{{ j.advisory_reason }}</span>
<span v-if="j.eval_date" class="text-caption text-muted-foreground">Eval {{ j.eval_date }}</span>
<span v-if="j.basis_digest" class="text-caption text-muted-foreground">Basis {{ j.basis_digest.slice(0, 12) }}</span>
<span v-if="j.result_id" class="text-caption text-muted-foreground">Result {{ j.result_id }}</span>
<details v-if="j.basis || j.answers" class="text-caption text-muted-foreground">
<summary>Judge record</summary>
<pre v-if="j.basis" class="whitespace-pre-wrap">{{ j.basis }}</pre>
<pre v-if="j.answers" class="whitespace-pre-wrap">{{ json(j.answers) }}</pre>
</details>
</div>
</li>
</ul>
<p v-if="decision.reason" class="text-destructive">{{ decision.reason }}</p>
+15
View File
@@ -79,11 +79,26 @@ export interface TrailEntry {
unknown?: boolean;
}
export interface JudgeRecord {
model?: string;
result_id?: string;
answer?: string;
confidence?: number;
reason?: string;
basis?: string;
basis_digest?: string;
answers?: unknown;
trusted?: boolean;
advisory_reason?: string;
eval_date?: string;
}
export interface Verdict {
guard: string;
ceiling: string;
findings?: { text: string; evidence?: string }[];
blind_spots?: string[];
judges?: JudgeRecord[];
advisory?: boolean;
failed?: string;
}