Declare producer correction capability
This commit is contained in:
@@ -32,14 +32,70 @@ func TestValidateModuleSpecRequiresSupportedExecutionClass(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCloneModuleSpecPreservesExecutionClass(t *testing.T) {
|
||||
spec := normalizeModuleSpec(ModuleSpec{Key: " module ", Stage: StageChunk, ExecutionClass: contracts.ExecutionClassLLMBacked})
|
||||
func TestCloneModuleSpecPreservesCorrectionProtocol(t *testing.T) {
|
||||
spec := normalizeModuleSpec(ModuleSpec{
|
||||
Key: " module ",
|
||||
Stage: StageChunk,
|
||||
ExecutionClass: contracts.ExecutionClassLLMBacked,
|
||||
CorrectionProtocol: " single_response_v1 ",
|
||||
})
|
||||
if spec.CorrectionProtocol != contracts.CorrectionProtocolSingleResponseV1 {
|
||||
t.Fatalf("normalized CorrectionProtocol = %q, want %q", spec.CorrectionProtocol, contracts.CorrectionProtocolSingleResponseV1)
|
||||
}
|
||||
cloned := cloneModuleSpec(spec)
|
||||
if !reflect.DeepEqual(cloned, spec) {
|
||||
t.Fatalf("cloneModuleSpec() = %#v, want %#v", cloned, spec)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateModuleSpecCorrectionProtocolEligibility(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
stage ModuleStage
|
||||
class contracts.ExecutionClass
|
||||
protocol contracts.CorrectionProtocol
|
||||
want string
|
||||
}{
|
||||
{name: "LLM chunk", stage: StageChunk, class: contracts.ExecutionClassLLMBacked, protocol: contracts.CorrectionProtocolSingleResponseV1},
|
||||
{name: "LLM extract", stage: StageExtract, class: contracts.ExecutionClassLLMBacked, protocol: contracts.CorrectionProtocolSingleResponseV1},
|
||||
{name: "LLM merge", stage: StageMerge, class: contracts.ExecutionClassLLMBacked, protocol: contracts.CorrectionProtocolSingleResponseV1},
|
||||
{name: "LLM normalize", stage: StageNormalize, class: contracts.ExecutionClassLLMBacked, protocol: contracts.CorrectionProtocolSingleResponseV1},
|
||||
{name: "deterministic chunk", stage: StageChunk, class: contracts.ExecutionClassDeterministic, protocol: contracts.CorrectionProtocolSingleResponseV1, want: "LLM-backed"},
|
||||
{name: "input", stage: StageInput, class: contracts.ExecutionClassLLMBacked, protocol: contracts.CorrectionProtocolSingleResponseV1, want: "not supported"},
|
||||
{name: "output", stage: StageOutput, class: contracts.ExecutionClassLLMBacked, protocol: contracts.CorrectionProtocolSingleResponseV1, want: "not supported"},
|
||||
{name: "unknown protocol", stage: StageChunk, class: contracts.ExecutionClassLLMBacked, protocol: "unsupported", want: "unsupported correction protocol"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
spec := normalizeModuleSpec(ModuleSpec{
|
||||
Key: "module",
|
||||
Stage: test.stage,
|
||||
ExecutionClass: test.class,
|
||||
CorrectionProtocol: test.protocol,
|
||||
})
|
||||
err := validateModuleSpec("module", test.stage, spec)
|
||||
if test.want == "" && err != nil {
|
||||
t.Fatalf("validateModuleSpec() error = %v, want nil", err)
|
||||
}
|
||||
if test.want != "" && (err == nil || !strings.Contains(err.Error(), test.want)) {
|
||||
t.Fatalf("validateModuleSpec() error = %v, want %q", err, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeValidatorSpecRejectsCorrectionProtocol(t *testing.T) {
|
||||
_, err := normalizeValidatorSpec(ValidatorSpec{
|
||||
Key: "validator",
|
||||
ExecutionClass: contracts.ExecutionClassLLMBacked,
|
||||
CorrectionProtocol: contracts.CorrectionProtocolSingleResponseV1,
|
||||
})
|
||||
if err == nil || !strings.Contains(err.Error(), "correction protocol") {
|
||||
t.Fatalf("normalizeValidatorSpec() error = %v, want correction protocol error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateModuleSpecAllowsReferenceSlotsForEligibleStages(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
|
||||
Reference in New Issue
Block a user