Separate example contracts and relax run ID format test

This commit is contained in:
2026-11-26 03:07:43 +00:00
parent fef0530533
commit fed376351f
4 changed files with 57 additions and 29 deletions

View File

@@ -26,9 +26,7 @@ import (
"go.maximumdirect.net/promptkit"
)
func TestMaintainedExamplesLoadResolveAndList(t *testing.T) {
components := productionTestComponents(t)
completePipelines := make(map[string]pipeline.ResolvedPipeline)
func TestMaintainedExamplesLoadAndParse(t *testing.T) {
for _, example := range maintainedExampleFiles(t) {
t.Run(example.name, func(t *testing.T) {
cfg := loadMaintainedExample(t, example.path)
@@ -39,16 +37,22 @@ func TestMaintainedExamplesLoadResolveAndList(t *testing.T) {
if err != nil {
t.Fatalf("read maintained transcript %q: %v", example.transcriptPath, err)
}
document, err := transcript.New().Parse(context.Background(), contracts.ParseRequest{
Path: example.transcriptPath,
Raw: raw,
})
if err != nil {
document, err := transcript.New().Parse(context.Background(), contracts.ParseRequest{Path: example.transcriptPath, Raw: raw})
if err != nil || document == nil {
t.Fatalf("parse maintained transcript %q: %v", example.transcriptPath, err)
}
if len(document.Units) == 0 {
t.Fatalf("maintained transcript %q has no parsed units", example.transcriptPath)
}
})
}
}
func TestMaintainedExamplesResolveComposition(t *testing.T) {
components := productionTestComponents(t)
for _, example := range maintainedExampleFiles(t) {
t.Run(example.name, func(t *testing.T) {
cfg := loadMaintainedExample(t, example.path)
for _, pipelineID := range example.pipelineIDs {
effective, err := cfg.Resolve(resolveInputForMaintainedExample(components, pipelineID))
if err != nil {
@@ -62,25 +66,9 @@ func TestMaintainedExamplesLoadResolveAndList(t *testing.T) {
t.Fatalf("materialize maintained example references for %q: %v", pipelineID, err)
}
if example.name == "complete" {
if pipelineID == "dnd-session-development" {
if materialized.ChunkControls.MaxAdditionalTurns != 0 || materialized.Chunk.LLMProfile != "notarius/dnd-extraction-development" {
t.Fatalf("development native controls=%#v profile=%q", materialized.ChunkControls, materialized.Chunk.LLMProfile)
}
parent, found := completePipelines["dnd-session"]
if !found {
t.Fatal("complete parent pipeline was not resolved before its development variant")
}
if strings.Join(exampleStepLaneIDs(materialized), "|") != strings.Join(exampleStepLaneIDs(parent), "|") {
t.Fatalf("development variant steps and lanes = %v, want parent composition %v", exampleStepLaneIDs(materialized), exampleStepLaneIDs(parent))
}
if got, want := strings.Join(generatedReferenceBindingDescriptions(materialized), "|"), strings.Join(generatedReferenceBindingDescriptions(parent), "|"); got != want {
t.Fatalf("development generated reference bindings = %q, want parent bindings %q", got, want)
}
}
if got := exampleStepLaneIDs(materialized); strings.Join(got, "|") != "describe-session:item-registry,location-registry,npc-registry,scene-descriptions|extract-events:combat-turns,item-occurrences,location-occurrences,npc-occurrences,spells|track-enemies:enemy-events" {
t.Fatalf("complete example steps and lanes = %v, want the documented D&D extractor composition", got)
}
completePipelines[pipelineID] = materialized
locationLane := referenceContractLane(t, materialized, "location-registry")
if locationLane.ArtifactKind != dnd.LocationRegistryKind || locationLane.Extract.Module != locationextract.Key || locationLane.Merge.Module != pipeline.DefaultMergeModule || locationLane.Normalize.Module != locationnormalize.Key {
t.Fatalf("location lane = %#v, want typed registry composition", locationLane)
@@ -131,6 +119,43 @@ func TestMaintainedExamplesLoadResolveAndList(t *testing.T) {
}
}
}
})
}
}
func TestMaintainedExampleDevelopmentInheritsComposition(t *testing.T) {
path := repositoryPath("examples", "dnd-complete", "config.yml")
cfg := loadMaintainedExample(t, path)
components := productionTestComponents(t)
resolve := func(id string) pipeline.ResolvedPipeline {
t.Helper()
effective, err := cfg.Resolve(resolveInputForMaintainedExample(components, id))
if err != nil {
t.Fatalf("resolve %q: %v", id, err)
}
result, _, err := pipeline.MaterializeReferences(effective.ResolvedPipeline, catalogFromRegistries(components.registries), pipeline.ReferenceMaterializationOptions{ConfigPath: path, WorkingDir: filepath.Dir(path)})
if err != nil {
t.Fatalf("materialize %q: %v", id, err)
}
return result
}
development := resolve("dnd-session-development")
parent := resolve("dnd-session")
if development.ChunkControls.MaxAdditionalTurns != 0 || development.Chunk.LLMProfile != "notarius/dnd-extraction-development" {
t.Fatalf("development native controls=%#v profile=%q", development.ChunkControls, development.Chunk.LLMProfile)
}
if got, want := exampleStepLaneIDs(development), exampleStepLaneIDs(parent); !reflect.DeepEqual(got, want) {
t.Fatalf("development variant steps and lanes = %v, want %v", got, want)
}
if got, want := generatedReferenceBindingDescriptions(development), generatedReferenceBindingDescriptions(parent); !reflect.DeepEqual(got, want) {
t.Fatalf("development generated reference bindings = %v, want %v", got, want)
}
}
func TestMaintainedExamplesList(t *testing.T) {
components := productionTestComponents(t)
for _, example := range maintainedExampleFiles(t) {
t.Run(example.name, func(t *testing.T) {
var stdout, stderr strings.Builder
code := RunWithOptions([]string{"pipeline", "list", "--config", example.path, "--format", "json"}, &stdout, &stderr, productionOptionsFromComponents(components))
var ids []string