Preserve validation decisions across failed batches
This commit is contained in:
@@ -13,20 +13,22 @@ import (
|
||||
ck "gitea.maximumdirect.net/eric/ConfigKit"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/core/config"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/llm"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/outcomes"
|
||||
"gitea.maximumdirect.net/eric/audita/internal/framework/proposals"
|
||||
)
|
||||
|
||||
func TestValidationRepairAndRuntimeFailuresThroughDomainBoundary(t *testing.T) {
|
||||
valid := `{"validations":[{"correction_index":0,"approved":true,"confidence":0.9,"reason":"ok"}]}`
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
responses []string
|
||||
wantCalls int
|
||||
wantApproved, wantWarning, wantRuntime bool
|
||||
name string
|
||||
responses []string
|
||||
wantCalls int
|
||||
wantApproved bool
|
||||
wantFailure outcomes.ReasonCode
|
||||
}{
|
||||
{"repair reaches decisions", []string{`{"wrong":true}`, valid}, 2, true, false, false},
|
||||
{"exhausted repair rejects batch", []string{`{"wrong":true}`, `{"wrong":true}`}, 2, false, true, false},
|
||||
{"malformed envelope propagates", []string{"MALFORMED_ENVELOPE"}, 1, false, false, true},
|
||||
{"repair reaches decisions", []string{`{"wrong":true}`, valid}, 2, true, ""},
|
||||
{"exhausted repair rejects batch", []string{`{"wrong":true}`, `{"wrong":true}`}, 2, false, outcomes.ReasonInvalidOutputExhausted},
|
||||
{"malformed envelope excludes batch", []string{"MALFORMED_ENVELOPE"}, 1, false, outcomes.ReasonProviderResponseInvalid},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
calls := 0
|
||||
@@ -79,16 +81,10 @@ func TestValidationRepairAndRuntimeFailuresThroughDomainBoundary(t *testing.T) {
|
||||
if calls != tc.wantCalls {
|
||||
t.Fatalf("calls=%d, want %d", calls, tc.wantCalls)
|
||||
}
|
||||
if tc.wantRuntime {
|
||||
if err == nil || len(result.Warnings) != 0 {
|
||||
t.Fatalf("runtime failure downgraded: %+v, %v", result, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(result.Decisions) != 1 || result.Decisions[0].Approved != tc.wantApproved || (len(result.Warnings) > 0) != tc.wantWarning {
|
||||
if len(result.Decisions) != 1 || result.Decisions[0].Approved != tc.wantApproved || len(result.Operations) != 1 || result.Operations[0].FailureReason != tc.wantFailure {
|
||||
t.Fatalf("domain result: %+v", result)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user