Complete shared domain contract verification

This commit is contained in:
2026-11-29 18:28:59 +00:00
parent 9dc976afaf
commit 41a5c43561
33 changed files with 126 additions and 97 deletions

View File

@@ -37,7 +37,7 @@ func TestProductionSpellCatalogValidationCoordinatesCorrections(t *testing.T) {
wantRejected: true,
},
{
name: "overlay spell becomes valid after correction",
name: "shared glossary spell becomes valid after correction",
responses: []string{
productionSpellResponse("Unknown Spell"),
productionSpellResponse("Aegis of Emberfall"),
@@ -95,7 +95,7 @@ func TestProductionSpellCatalogValidationCoordinatesCorrections(t *testing.T) {
}
value := decodeAssembledOutput[dnd.SpellList](t, output.OutputFiles, "lanes/spells.json")
if len(value.SpellCasts) != 1 || value.SpellCasts[0].Spell != tt.wantSpell {
t.Fatalf("normalized spell list = %#v, want accepted overlay spell", value)
t.Fatalf("normalized spell list = %#v, want accepted shared glossary spell", value)
}
if len(output.Diagnostics.Groups) != 2 || output.Diagnostics.Groups[0].ReasonCode != tt.wantAdvisoryCode {
t.Fatalf("diagnostics = %#v, want terminal extract and normalize diagnostics", output.Diagnostics)

View File

@@ -23,12 +23,12 @@ func TestMaterializedSpellCatalogOrderingPreservesSemanticContents(t *testing.T)
t.Fatal(err)
}
resolved := effective.ResolvedPipeline
overlayPath := filepath.Join(t.TempDir(), "catalog.json")
sharedGlossaryPath := filepath.Join(t.TempDir(), "catalog.json")
for _, target := range []*pipeline.ResolvedReferenceTarget{&resolved.Steps[0].ArtifactLanes[0].ExtractReferences, &resolved.Steps[0].ArtifactLanes[0].NormalizeReferences} {
matched := false
for index := range target.Bindings {
if target.Bindings[index].SlotName == spellcatalog.SpellCatalogReferenceSlot {
target.Bindings[index].Source = overlayPath
target.Bindings[index].Source = sharedGlossaryPath
matched = true
}
}
@@ -38,7 +38,7 @@ func TestMaterializedSpellCatalogOrderingPreservesSemanticContents(t *testing.T)
}
materialize := func(contents string) pipeline.ResolvedPipeline {
t.Helper()
if err := os.WriteFile(overlayPath, []byte(contents), 0600); err != nil {
if err := os.WriteFile(sharedGlossaryPath, []byte(contents), 0600); err != nil {
t.Fatal(err)
}
value, _, err := pipeline.MaterializeReferences(resolved, catalog, pipeline.ReferenceMaterializationOptions{ConfigPath: configPath, WorkingDir: filepath.Dir(configPath)})
@@ -47,7 +47,7 @@ func TestMaterializedSpellCatalogOrderingPreservesSemanticContents(t *testing.T)
}
return value
}
first, second := materialize(reorderedOverlayA), materialize(reorderedOverlayB)
first, second := materialize(reorderedSharedGlossaryA), materialize(reorderedSharedGlossaryB)
laneA, laneB := first.Steps[0].ArtifactLanes[0], second.Steps[0].ArtifactLanes[0]
for _, pair := range [][2]pipeline.ResolvedReferenceTarget{
{laneA.ExtractReferences, laneB.ExtractReferences},
@@ -104,7 +104,7 @@ func TestConfiguredSpellCatalogBindingChangesResolvedPipelineIdentity(t *testing
}
}
func TestProductionOverlayRunAlignsGroundingAndValidation(t *testing.T) {
func TestProductionSharedGlossaryRunAlignsGroundingAndValidation(t *testing.T) {
outputRoot := filepath.Join(t.TempDir(), "output")
client := &productionFakeLLMClient{spellResponse: productionSpellResponse("Aegis of Emberfall")}
configPath := writeProductionContractConfig(t, productionSpellCatalogContractConfig(t)+productionProviderConfiguration)
@@ -130,7 +130,7 @@ func TestProductionOverlayRunAlignsGroundingAndValidation(t *testing.T) {
}
for _, fragment := range []string{`"canonical_name":"Aegis of Emberfall"`, `"aliases":["Emberfall Aegis"]`} {
if !strings.Contains(prompt.String(), fragment) {
t.Fatalf("catalog prompt omitted overlay recognition %q", fragment)
t.Fatalf("catalog prompt omitted shared glossary recognition %q", fragment)
}
}
artifact := readProductionJSON[dnd.SpellList](t, filepath.Join(report.OutputDirectory, "lanes", "spells.json"))
@@ -139,7 +139,7 @@ func TestProductionOverlayRunAlignsGroundingAndValidation(t *testing.T) {
}
}
const reorderedOverlayA = `{
const reorderedSharedGlossaryA = `{
"schema_version": "maximumdirect.glossary.v1",
"collections": {"spells": {"entries": [
{"id":"a","name":"Aegis of Emberfall","category":"spell","aliases":["Emberfall Aegis"]},
@@ -147,4 +147,4 @@ const reorderedOverlayA = `{
]}}
}`
const reorderedOverlayB = `{"collections":{"spells":{"entries":[{"aliases":["Cinder Shroud","Veil of Cinder"],"name":"Cinder Veil","id":"b","category":"spell"},{"aliases":["Emberfall Aegis"],"name":"Aegis of Emberfall","id":"a","category":"spell"}]}},"schema_version":"maximumdirect.glossary.v1"}`
const reorderedSharedGlossaryB = `{"collections":{"spells":{"entries":[{"aliases":["Cinder Shroud","Veil of Cinder"],"name":"Cinder Veil","id":"b","category":"spell"},{"aliases":["Emberfall Aegis"],"name":"Aegis of Emberfall","id":"a","category":"spell"}]}},"schema_version":"maximumdirect.glossary.v1"}`