Require explicit module execution classes
This commit is contained in:
@@ -8,15 +8,35 @@ import (
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
)
|
||||
|
||||
func TestNormalizeModuleSpecDefaultsExecutionClass(t *testing.T) {
|
||||
normalized := normalizeModuleSpec(ModuleSpec{Key: " module ", Stage: StageChunk})
|
||||
if normalized.ExecutionClass != contracts.ExecutionClassDeterministic {
|
||||
t.Fatalf("ExecutionClass = %q, want deterministic compatibility default", normalized.ExecutionClass)
|
||||
func TestValidateModuleSpecRequiresSupportedExecutionClass(t *testing.T) {
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
class contracts.ExecutionClass
|
||||
want string
|
||||
}{
|
||||
{name: "missing", want: "execution class"},
|
||||
{name: "unsupported", class: "remote", want: "unsupported"},
|
||||
{name: "deterministic", class: contracts.ExecutionClassDeterministic},
|
||||
{name: "llm backed", class: contracts.ExecutionClassLLMBacked},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
spec := normalizeModuleSpec(ModuleSpec{Key: "module", Stage: StageChunk, ExecutionClass: test.class})
|
||||
err := validateModuleSpec("chunker", StageChunk, 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
cloned := cloneModuleSpec(normalized)
|
||||
if !reflect.DeepEqual(cloned, normalized) {
|
||||
t.Fatalf("cloneModuleSpec() = %#v, want %#v", cloned, normalized)
|
||||
func TestCloneModuleSpecPreservesExecutionClass(t *testing.T) {
|
||||
spec := normalizeModuleSpec(ModuleSpec{Key: " module ", Stage: StageChunk, ExecutionClass: contracts.ExecutionClassLLMBacked})
|
||||
cloned := cloneModuleSpec(spec)
|
||||
if !reflect.DeepEqual(cloned, spec) {
|
||||
t.Fatalf("cloneModuleSpec() = %#v, want %#v", cloned, spec)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +55,9 @@ func TestValidateModuleSpecAllowsReferenceSlotsForEligibleStages(t *testing.T) {
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
spec := normalizeModuleSpec(ModuleSpec{
|
||||
Key: "module",
|
||||
Stage: test.stage,
|
||||
Key: "module",
|
||||
Stage: test.stage,
|
||||
ExecutionClass: contracts.ExecutionClassDeterministic,
|
||||
ReferenceSlots: []contracts.ReferenceSlot{
|
||||
{Name: "roster", Description: "Character roster", MaxBytes: 1024},
|
||||
},
|
||||
@@ -63,8 +84,9 @@ func TestValidateModuleSpecRejectsReferenceSlotsForIneligibleStages(t *testing.T
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
spec := normalizeModuleSpec(ModuleSpec{
|
||||
Key: "module",
|
||||
Stage: test.stage,
|
||||
Key: "module",
|
||||
Stage: test.stage,
|
||||
ExecutionClass: contracts.ExecutionClassDeterministic,
|
||||
ReferenceSlots: []contracts.ReferenceSlot{
|
||||
{Name: "roster"},
|
||||
},
|
||||
@@ -122,6 +144,7 @@ func TestValidateModuleSpecRejectsInvalidReferenceSlotsForEligibleStages(t *test
|
||||
spec := normalizeModuleSpec(ModuleSpec{
|
||||
Key: "module",
|
||||
Stage: stage.stage,
|
||||
ExecutionClass: contracts.ExecutionClassDeterministic,
|
||||
ReferenceSlots: invalid.slots,
|
||||
})
|
||||
err := validateModuleSpec(stage.kind, stage.stage, spec)
|
||||
|
||||
Reference in New Issue
Block a user