Centralize validator classification and malformed output handling
This commit is contained in:
@@ -16,6 +16,16 @@ func (u unclassifiedValidator) Validate(_ context.Context, _ contracts.Validatio
|
||||
return frameworkvalidators.Result{ValidatorName: u.Name(), Decisions: nil}, nil
|
||||
}
|
||||
|
||||
type namedUnclassifiedValidator struct {
|
||||
name string
|
||||
}
|
||||
|
||||
func (n namedUnclassifiedValidator) Name() string { return n.name }
|
||||
|
||||
func (n namedUnclassifiedValidator) Validate(_ context.Context, _ contracts.ValidationRequest) (frameworkvalidators.Result, error) {
|
||||
return frameworkvalidators.Result{ValidatorName: n.Name(), Decisions: nil}, nil
|
||||
}
|
||||
|
||||
func TestClassOfDefaultsToDeterministic(t *testing.T) {
|
||||
if got := ClassOf(unclassifiedValidator{}); got != ExecutionClassDeterministic {
|
||||
t.Fatalf("expected deterministic default class, got %q", got)
|
||||
@@ -28,3 +38,22 @@ func TestWrapExposesExecutionClass(t *testing.T) {
|
||||
t.Fatalf("expected llm_backed class, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClassForKey(t *testing.T) {
|
||||
if got := ClassForKey(KeyProposalShape); got != ExecutionClassDeterministic {
|
||||
t.Fatalf("expected deterministic class for %q, got %q", KeyProposalShape, got)
|
||||
}
|
||||
if got := ClassForKey(KeySpokenFormPlausibility); got != ExecutionClassLLMBacked {
|
||||
t.Fatalf("expected llm_backed class for %q, got %q", KeySpokenFormPlausibility, got)
|
||||
}
|
||||
if got := ClassForKey("unknown"); got != ExecutionClassDeterministic {
|
||||
t.Fatalf("expected deterministic fallback for unknown key, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClassOfFallsBackToStableValidatorKey(t *testing.T) {
|
||||
v := namedUnclassifiedValidator{name: KeyEditorialReview}
|
||||
if got := ClassOf(v); got != ExecutionClassLLMBacked {
|
||||
t.Fatalf("expected llm_backed fallback by key, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user