Separate example contracts and relax run ID format test
This commit is contained in:
@@ -630,6 +630,9 @@ for a general deadline framework.
|
|||||||
|
|
||||||
**Assessment:** Test readability/refactoring opportunity; original low.
|
**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).
|
**Source:** [CPLX-008](03-complexity.md#cplx-008--maintained-example-testing-combines-several-independent-concerns).
|
||||||
|
|
||||||
One nested test combines loading, transcript handling, composition, generated
|
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.
|
**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).
|
**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,
|
Remove the exact timestamp/hex-width run-ID regex while retaining uniqueness,
|
||||||
|
|||||||
@@ -885,6 +885,8 @@ prefix-length/live-quality gates, or production prompt rewrite.
|
|||||||
|
|
||||||
## Stage 33 — Separate Example Tests And Unfreeze Run-ID Format
|
## Stage 33 — Separate Example Tests And Unfreeze Run-ID Format
|
||||||
|
|
||||||
|
**Completed.**
|
||||||
|
|
||||||
**Coverage:** CAT-028/CAT-029. **Prerequisites:** Stages 20, 25–26.
|
**Coverage:** CAT-028/CAT-029. **Prerequisites:** Stages 20, 25–26.
|
||||||
|
|
||||||
Refactor cli/example_contract_test.go into independent resolved fixtures and focused
|
Refactor cli/example_contract_test.go into independent resolved fixtures and focused
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ import (
|
|||||||
"go.maximumdirect.net/promptkit"
|
"go.maximumdirect.net/promptkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMaintainedExamplesLoadResolveAndList(t *testing.T) {
|
func TestMaintainedExamplesLoadAndParse(t *testing.T) {
|
||||||
components := productionTestComponents(t)
|
|
||||||
completePipelines := make(map[string]pipeline.ResolvedPipeline)
|
|
||||||
for _, example := range maintainedExampleFiles(t) {
|
for _, example := range maintainedExampleFiles(t) {
|
||||||
t.Run(example.name, func(t *testing.T) {
|
t.Run(example.name, func(t *testing.T) {
|
||||||
cfg := loadMaintainedExample(t, example.path)
|
cfg := loadMaintainedExample(t, example.path)
|
||||||
@@ -39,16 +37,22 @@ func TestMaintainedExamplesLoadResolveAndList(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("read maintained transcript %q: %v", example.transcriptPath, err)
|
t.Fatalf("read maintained transcript %q: %v", example.transcriptPath, err)
|
||||||
}
|
}
|
||||||
document, err := transcript.New().Parse(context.Background(), contracts.ParseRequest{
|
document, err := transcript.New().Parse(context.Background(), contracts.ParseRequest{Path: example.transcriptPath, Raw: raw})
|
||||||
Path: example.transcriptPath,
|
if err != nil || document == nil {
|
||||||
Raw: raw,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("parse maintained transcript %q: %v", example.transcriptPath, err)
|
t.Fatalf("parse maintained transcript %q: %v", example.transcriptPath, err)
|
||||||
}
|
}
|
||||||
if len(document.Units) == 0 {
|
if len(document.Units) == 0 {
|
||||||
t.Fatalf("maintained transcript %q has no parsed units", example.transcriptPath)
|
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 {
|
for _, pipelineID := range example.pipelineIDs {
|
||||||
effective, err := cfg.Resolve(resolveInputForMaintainedExample(components, pipelineID))
|
effective, err := cfg.Resolve(resolveInputForMaintainedExample(components, pipelineID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -62,25 +66,9 @@ func TestMaintainedExamplesLoadResolveAndList(t *testing.T) {
|
|||||||
t.Fatalf("materialize maintained example references for %q: %v", pipelineID, err)
|
t.Fatalf("materialize maintained example references for %q: %v", pipelineID, err)
|
||||||
}
|
}
|
||||||
if example.name == "complete" {
|
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" {
|
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)
|
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")
|
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 {
|
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)
|
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
|
var stdout, stderr strings.Builder
|
||||||
code := RunWithOptions([]string{"pipeline", "list", "--config", example.path, "--format", "json"}, &stdout, &stderr, productionOptionsFromComponents(components))
|
code := RunWithOptions([]string{"pipeline", "list", "--config", example.path, "--format", "json"}, &stdout, &stderr, productionOptionsFromComponents(components))
|
||||||
var ids []string
|
var ids []string
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package cli
|
|||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
@@ -13,16 +12,12 @@ import (
|
|||||||
|
|
||||||
func TestDefaultRunIDGeneratorProducesUniqueSafeIDs(t *testing.T) {
|
func TestDefaultRunIDGeneratorProducesUniqueSafeIDs(t *testing.T) {
|
||||||
startedAt := time.Unix(0, 123456789).UTC()
|
startedAt := time.Unix(0, 123456789).UTC()
|
||||||
pattern := regexp.MustCompile(`^run-123456789-[0-9a-f]{32}$`)
|
|
||||||
seen := make(map[string]struct{}, 256)
|
seen := make(map[string]struct{}, 256)
|
||||||
for i := 0; i < 256; i++ {
|
for i := 0; i < 256; i++ {
|
||||||
runID, err := defaultRunIDGenerator(startedAt)
|
runID, err := defaultRunIDGenerator(startedAt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !pattern.MatchString(runID) {
|
|
||||||
t.Fatalf("run ID %q does not match production format", runID)
|
|
||||||
}
|
|
||||||
if err := validateRunID(runID); err != nil {
|
if err := validateRunID(runID); err != nil {
|
||||||
t.Fatalf("run ID %q is not path-safe: %v", runID, err)
|
t.Fatalf("run ID %q is not path-safe: %v", runID, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user