Cleanup and complete the pipeline refactor
This commit is contained in:
@@ -124,15 +124,6 @@ func TestRunRejectsInvalidSetup(t *testing.T) {
|
||||
},
|
||||
error: "normalizer registry",
|
||||
},
|
||||
{
|
||||
name: "missing validator registry only when configured validators are used",
|
||||
run: func() (RunOutput, error) {
|
||||
registries := newRunnerRegistries(t, nil)
|
||||
registries.Validators = nil
|
||||
return New(registries).Run(context.Background(), RunInput{Pipeline: resolvedPipelineWithValidators("configured")})
|
||||
},
|
||||
error: "validator registry",
|
||||
},
|
||||
{
|
||||
name: "missing output registry",
|
||||
run: func() (RunOutput, error) {
|
||||
@@ -529,18 +520,16 @@ func TestRunPassesSourceInputAndSessionIDToPromptCapableStages(t *testing.T) {
|
||||
t.Fatalf("manifest metadata = %#v, want session_id", output.Manifest.Metadata)
|
||||
}
|
||||
|
||||
requests := []struct {
|
||||
sourceRequests := []struct {
|
||||
name string
|
||||
material contracts.LLMInputMaterial
|
||||
sessionID string
|
||||
}{
|
||||
{name: "chunk", material: modules.chunker.requests[0].SourceInput, sessionID: modules.chunker.requests[0].SessionID},
|
||||
{name: "extract first", material: modules.extractors["extract-alpha"].requests[0].SourceInput, sessionID: modules.extractors["extract-alpha"].requests[0].SessionID},
|
||||
{name: "extract second", material: modules.extractors["extract-alpha"].requests[1].SourceInput, sessionID: modules.extractors["extract-alpha"].requests[1].SessionID},
|
||||
{name: "merge", material: modules.mergers["merge"].requests[0].SourceInput, sessionID: modules.mergers["merge"].requests[0].SessionID},
|
||||
{name: "normalize", material: modules.normalizers["normalize"].requests[0].SourceInput, sessionID: modules.normalizers["normalize"].requests[0].SessionID},
|
||||
}
|
||||
for _, req := range requests {
|
||||
for _, req := range sourceRequests {
|
||||
if req.sessionID != "explicit-session" {
|
||||
t.Fatalf("%s session ID = %q, want explicit-session", req.name, req.sessionID)
|
||||
}
|
||||
@@ -557,9 +546,29 @@ func TestRunPassesSourceInputAndSessionIDToPromptCapableStages(t *testing.T) {
|
||||
t.Fatalf("%s origin URI = %q, want file URI ending in session.json", req.name, req.material.OriginURI)
|
||||
}
|
||||
}
|
||||
for i, req := range modules.extractors["extract-alpha"].requests {
|
||||
if req.SessionID != "explicit-session" {
|
||||
t.Fatalf("extract %d session ID = %q, want explicit-session", i, req.SessionID)
|
||||
}
|
||||
if req.Chunk == nil {
|
||||
t.Fatalf("extract %d chunk = nil, want chunk", i)
|
||||
}
|
||||
if got := string(req.SourceInput.Content); got != string(req.Chunk.Content) {
|
||||
t.Fatalf("extract %d source input content = %q, want chunk content %q", i, got, req.Chunk.Content)
|
||||
}
|
||||
if req.SourceInput.Name != "source" || req.SourceInput.MediaType != req.Chunk.MediaType || req.SourceInput.SizeBytes != int64(len(req.Chunk.Content)) {
|
||||
t.Fatalf("extract %d source input = %#v, want chunk metadata", i, req.SourceInput)
|
||||
}
|
||||
if req.SourceInput.Digest != sourceInputDigest(req.Chunk.Content) {
|
||||
t.Fatalf("extract %d digest = %q, want %q", i, req.SourceInput.Digest, sourceInputDigest(req.Chunk.Content))
|
||||
}
|
||||
if !strings.HasPrefix(req.SourceInput.OriginURI, "file://") || !strings.HasSuffix(req.SourceInput.OriginURI, "/session.json") {
|
||||
t.Fatalf("extract %d origin URI = %q, want file URI ending in session.json", i, req.SourceInput.OriginURI)
|
||||
}
|
||||
}
|
||||
|
||||
modules.chunker.requests[0].SourceInput.Content[0] = 'X'
|
||||
if got := string(modules.extractors["extract-alpha"].requests[0].SourceInput.Content); got != string(rawInput) {
|
||||
if got := string(modules.extractors["extract-alpha"].requests[0].SourceInput.Content); got != string(modules.extractors["extract-alpha"].requests[0].Chunk.Content) {
|
||||
t.Fatalf("source input content aliased across requests: %q", got)
|
||||
}
|
||||
if got := string(rawInput); got != "{\"source\":\"exact bytes\"}" {
|
||||
@@ -619,14 +628,13 @@ func TestRunPassesInputRequestFields(t *testing.T) {
|
||||
|
||||
func TestRunPassesModuleBindingConfigToStageRequests(t *testing.T) {
|
||||
modules := defaultRunnerModules()
|
||||
pipeline := resolvedPipelineWithValidators("configured")
|
||||
pipeline := resolvedPipeline()
|
||||
pipeline.Input = ModuleBinding{Module: "input", LLMProfile: "input-profile", Options: map[string]any{"input_option": "input-value"}}
|
||||
pipeline.Chunk = ModuleBinding{Module: "chunk", LLMProfile: "chunk-profile", Options: map[string]any{"chunk_option": "chunk-value"}}
|
||||
pipeline.Output = ModuleBinding{Module: "output", LLMProfile: "output-profile", Options: map[string]any{"output_option": "output-value"}}
|
||||
pipeline.ArtifactLanes[0].Extract = ModuleBinding{Module: "extract-alpha", LLMProfile: "extract-profile", Options: map[string]any{"extract_option": "extract-value"}}
|
||||
pipeline.ArtifactLanes[0].Merge = ModuleBinding{Module: "merge", LLMProfile: "merge-profile", Options: map[string]any{"merge_option": "merge-value"}}
|
||||
pipeline.ArtifactLanes[0].Normalize = ModuleBinding{Module: "normalize", LLMProfile: "normalize-profile", Options: map[string]any{"normalize_option": "normalize-value"}}
|
||||
pipeline.ArtifactLanes[0].Validators[0] = ModuleBinding{Module: "configured", LLMProfile: "validator-profile", Options: map[string]any{"validator_option": "validator-value"}}
|
||||
|
||||
_, err := New(newRunnerRegistries(t, modules)).Run(context.Background(), RunInput{Pipeline: pipeline})
|
||||
if err != nil {
|
||||
@@ -1063,19 +1071,11 @@ func TestRunContextCancellationStopsRetries(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunRecordsConfiguredValidatorsInManifest(t *testing.T) {
|
||||
modules := defaultRunnerModules()
|
||||
|
||||
output, err := New(newRunnerRegistries(t, modules)).Run(context.Background(), RunInput{
|
||||
func TestRunRejectsConfiguredValidators(t *testing.T) {
|
||||
_, err := New(newRunnerRegistries(t, defaultRunnerModules())).Run(context.Background(), RunInput{
|
||||
Pipeline: resolvedPipelineWithValidators("configured", "second-validator"),
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Run() error = %v, want nil", err)
|
||||
}
|
||||
|
||||
if got := output.Manifest.ArtifactLanes[0].Validators; !reflect.DeepEqual(got, []string{"configured", "second-validator"}) {
|
||||
t.Fatalf("manifest validators = %#v, want configured validators", got)
|
||||
}
|
||||
assertRunError(t, err, "configured validators")
|
||||
}
|
||||
|
||||
func TestRunCollectsStageWarnings(t *testing.T) {
|
||||
@@ -1181,7 +1181,7 @@ func TestRunReturnsFailedManifestWhenOutputEncoderFails(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRunManifestIncludesPipelineAndLaneDetails(t *testing.T) {
|
||||
resolved := resolvedPipelineWithValidators("configured")
|
||||
resolved := resolvedPipeline()
|
||||
resolved.ChunkReferences.ReferenceSet = contracts.ReferenceSet{
|
||||
Slots: map[string]contracts.ResolvedReferenceSlot{
|
||||
"scene_guide": {
|
||||
@@ -1312,8 +1312,8 @@ func TestRunManifestIncludesPipelineAndLaneDetails(t *testing.T) {
|
||||
if lane.ID != "alpha" || lane.Extractor != "extract-alpha" || lane.Merger != "merge" || lane.Normalizer != "normalize" {
|
||||
t.Fatalf("ArtifactLanes[0] = %#v, want lane details", lane)
|
||||
}
|
||||
if !reflect.DeepEqual(lane.Validators, []string{"configured"}) {
|
||||
t.Fatalf("lane validators = %#v, want configured validator", lane.Validators)
|
||||
if len(lane.Validators) != 0 {
|
||||
t.Fatalf("lane validators = %#v, want none", lane.Validators)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user