From fed376351f8923bd40b04e0d9c7675d559f6a810 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Thu, 26 Nov 2026 03:07:43 +0000 Subject: [PATCH] Separate example contracts and relax run ID format test --- docs/roadmap/audit/catalog.md | 6 +++ docs/roadmap/implementation.md | 2 + internal/cli/example_contract_test.go | 73 ++++++++++++++++++--------- internal/cli/run_id_test.go | 5 -- 4 files changed, 57 insertions(+), 29 deletions(-) diff --git a/docs/roadmap/audit/catalog.md b/docs/roadmap/audit/catalog.md index 4116bdcf..4a80b533 100644 --- a/docs/roadmap/audit/catalog.md +++ b/docs/roadmap/audit/catalog.md @@ -630,6 +630,9 @@ for a general deadline framework. **Assessment:** Test readability/refactoring opportunity; original low. +**Status:** Resolved. Loading, composition, inheritance, and listing have focused +checks; the parent is resolved independently. Repeated focused and CLI tests pass. + **Source:** [CPLX-008](03-complexity.md#cplx-008--maintained-example-testing-combines-several-independent-concerns). One nested test combines loading, transcript handling, composition, generated @@ -642,6 +645,9 @@ and local expectations; do not replace it with an assertion DSL or new snapshots **Assessment:** Incidental test restriction; original P3, small cleanup. +**Status:** Resolved. Uniqueness and safety remain covered without a private +format regex; allocation, partial-write, and versioned session checks are retained. + **Source:** [TEST-006](08-testing.md#test-006--run-id-test-freezes-an-incidental-private-format). Remove the exact timestamp/hex-width run-ID regex while retaining uniqueness, diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 52099ab9..7f40dcdd 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -885,6 +885,8 @@ prefix-length/live-quality gates, or production prompt rewrite. ## Stage 33 — Separate Example Tests And Unfreeze Run-ID Format +**Completed.** + **Coverage:** CAT-028/CAT-029. **Prerequisites:** Stages 20, 25–26. Refactor cli/example_contract_test.go into independent resolved fixtures and focused diff --git a/internal/cli/example_contract_test.go b/internal/cli/example_contract_test.go index 35e26586..92634d81 100644 --- a/internal/cli/example_contract_test.go +++ b/internal/cli/example_contract_test.go @@ -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 diff --git a/internal/cli/run_id_test.go b/internal/cli/run_id_test.go index d7829cfe..15b8d79a 100644 --- a/internal/cli/run_id_test.go +++ b/internal/cli/run_id_test.go @@ -3,7 +3,6 @@ package cli import ( "os" "path/filepath" - "regexp" "strings" "testing" "time" @@ -13,16 +12,12 @@ import ( func TestDefaultRunIDGeneratorProducesUniqueSafeIDs(t *testing.T) { startedAt := time.Unix(0, 123456789).UTC() - pattern := regexp.MustCompile(`^run-123456789-[0-9a-f]{32}$`) seen := make(map[string]struct{}, 256) for i := 0; i < 256; i++ { runID, err := defaultRunIDGenerator(startedAt) if err != nil { t.Fatal(err) } - if !pattern.MatchString(runID) { - t.Fatalf("run ID %q does not match production format", runID) - } if err := validateRunID(runID); err != nil { t.Fatalf("run ID %q is not path-safe: %v", runID, err) }