Remove legacy configuration machinery
This commit is contained in:
43
internal/modules/integration/config_test.go
Normal file
43
internal/modules/integration/config_test.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package integration_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/config"
|
||||
)
|
||||
|
||||
func loadIntegrationConfig(t *testing.T, path string) config.Config {
|
||||
t.Helper()
|
||||
loaded, err := config.Load(path, config.LoadOptions{})
|
||||
if err != nil {
|
||||
t.Fatalf("load configuration %q: %v", path, err)
|
||||
}
|
||||
return loaded.RuntimeConfig()
|
||||
}
|
||||
|
||||
func loadIntegrationConfigText(t *testing.T, content string) config.Config {
|
||||
t.Helper()
|
||||
path := filepath.Join(t.TempDir(), "config.yml")
|
||||
if err := os.WriteFile(path, []byte(content), 0o600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return loadIntegrationConfig(t, path)
|
||||
}
|
||||
|
||||
func configFromYAML(content string) (config.Config, error) {
|
||||
directory, err := os.MkdirTemp("", "notarius-integration-config-")
|
||||
if err != nil {
|
||||
return config.Config{}, err
|
||||
}
|
||||
path := filepath.Join(directory, "config.yml")
|
||||
if err := os.WriteFile(path, []byte(content), 0o600); err != nil {
|
||||
return config.Config{}, err
|
||||
}
|
||||
loaded, err := config.Load(path, config.LoadOptions{})
|
||||
if err != nil {
|
||||
return config.Config{}, err
|
||||
}
|
||||
return loaded.RuntimeConfig(), nil
|
||||
}
|
||||
@@ -10,18 +10,18 @@ import (
|
||||
func TestItemOccurrenceConfigurationRequiresEarlierItemRegistry(t *testing.T) {
|
||||
registries := productionNPCRegistries(t)
|
||||
cfg, err := configFromYAML(`
|
||||
version: 4
|
||||
version: 5
|
||||
pipelines:
|
||||
items:
|
||||
input: seriatim
|
||||
chunk: generic
|
||||
input: {module: seriatim}
|
||||
chunk: {module: generic}
|
||||
steps:
|
||||
- id: identify-items
|
||||
artifacts:
|
||||
registry:
|
||||
extract: dnd/item-registry
|
||||
merge: appendorder
|
||||
normalize: dnd/item-registry
|
||||
extract: {module: dnd/item-registry}
|
||||
merge: {module: appendorder}
|
||||
normalize: {module: dnd/item-registry}
|
||||
- id: record-occurrences
|
||||
references:
|
||||
item_registry:
|
||||
@@ -30,9 +30,9 @@ pipelines:
|
||||
lane: registry
|
||||
artifacts:
|
||||
occurrences:
|
||||
extract: dnd/item-occurrences
|
||||
merge: appendorder
|
||||
normalize: dnd/item-occurrences
|
||||
extract: {module: dnd/item-occurrences}
|
||||
merge: {module: appendorder}
|
||||
normalize: {module: dnd/item-occurrences}
|
||||
`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -42,16 +42,16 @@ pipelines:
|
||||
}
|
||||
|
||||
broken, err := configFromYAML(strings.Replace(`
|
||||
version: 4
|
||||
version: 5
|
||||
pipelines:
|
||||
items:
|
||||
input: seriatim
|
||||
chunk: generic
|
||||
input: {module: seriatim}
|
||||
chunk: {module: generic}
|
||||
steps:
|
||||
- id: record-occurrences
|
||||
artifacts:
|
||||
occurrences:
|
||||
extract: dnd/item-occurrences
|
||||
extract: {module: dnd/item-occurrences}
|
||||
`, "record-occurrences", "record-occurrences", 1))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -99,11 +99,8 @@ func TestLocationOccurrenceConsumerDoesNotRunAfterRejectedRegistry(t *testing.T)
|
||||
|
||||
func TestLocationOccurrenceConfigurationRequiresEarlierRegistry(t *testing.T) {
|
||||
registries := productionNPCRegistries(t)
|
||||
cfg, err := configFromYAML(strings.Replace(locationPipelineConfig, "step: identify-locations", "step: track-location-occurrences", 1))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err = cfg.Resolve(config.ResolveInput{PipelineID: "dnd-locations-fixture", Catalog: moduleCatalog(registries)})
|
||||
cfg := loadIntegrationConfigText(t, strings.Replace(locationPipelineConfig, "step: identify-locations", "step: track-location-occurrences", 1))
|
||||
_, err := cfg.Resolve(config.ResolveInput{PipelineID: "dnd-locations-fixture", Catalog: moduleCatalog(registries)})
|
||||
if err == nil || !strings.Contains(err.Error(), "earlier step") {
|
||||
t.Fatalf("Resolve() error = %v, want an earlier generated registry requirement", err)
|
||||
}
|
||||
@@ -129,10 +126,7 @@ func TestLocationOccurrenceCheckpointTracksGeneratedRegistry(t *testing.T) {
|
||||
|
||||
func resolveLocationPipeline(t *testing.T, registries pipeline.Registries) pipeline.ResolvedPipeline {
|
||||
t.Helper()
|
||||
cfg, err := configFromYAML(locationPipelineConfig)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg := loadIntegrationConfigText(t, locationPipelineConfig)
|
||||
effective, err := cfg.Resolve(config.ResolveInput{PipelineID: "dnd-locations-fixture", Catalog: moduleCatalog(registries)})
|
||||
if err != nil {
|
||||
t.Fatalf("Resolve() error = %v", err)
|
||||
@@ -144,26 +138,15 @@ func resolveLocationPipeline(t *testing.T, registries pipeline.Registries) pipel
|
||||
return resolved
|
||||
}
|
||||
|
||||
func configFromYAML(content string) (config.Config, error) {
|
||||
fileConfig, err := config.ParseFileConfigYAML([]byte(content))
|
||||
if err != nil {
|
||||
return config.Config{}, err
|
||||
}
|
||||
cfg := config.Default()
|
||||
if err := cfg.ApplyFileConfig(fileConfig); err != nil {
|
||||
return config.Config{}, err
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
|
||||
const locationPipelineConfig = `version: 4
|
||||
const locationPipelineConfig = `version: 5
|
||||
cache:
|
||||
chunk_plans:
|
||||
mode: bypass
|
||||
checkpoints: {}
|
||||
pipelines:
|
||||
dnd-locations-fixture:
|
||||
input: seriatim
|
||||
input:
|
||||
module: seriatim
|
||||
output:
|
||||
module: json
|
||||
options:
|
||||
@@ -174,9 +157,9 @@ pipelines:
|
||||
- id: identify-locations
|
||||
artifacts:
|
||||
locations:
|
||||
extract: dnd/location-registry
|
||||
merge: appendorder
|
||||
normalize: dnd/location-registry
|
||||
extract: {module: dnd/location-registry}
|
||||
merge: {module: appendorder}
|
||||
normalize: {module: dnd/location-registry}
|
||||
- id: track-location-occurrences
|
||||
references:
|
||||
location_registry:
|
||||
@@ -185,9 +168,9 @@ pipelines:
|
||||
lane: locations
|
||||
artifacts:
|
||||
occurrences:
|
||||
extract: dnd/location-occurrences
|
||||
merge: appendorder
|
||||
normalize: dnd/location-occurrences
|
||||
extract: {module: dnd/location-occurrences}
|
||||
merge: {module: appendorder}
|
||||
normalize: {module: dnd/location-occurrences}
|
||||
`
|
||||
|
||||
type locationHandoffLLMClient struct {
|
||||
|
||||
@@ -429,15 +429,7 @@ func assertCurrentEvidence(t *testing.T, references []source.SourceRef) {
|
||||
|
||||
func loadGroundedPipelineConfig(t *testing.T) config.Config {
|
||||
t.Helper()
|
||||
fileConfig, err := config.LoadFileConfig(repositoryPathForIntegration("internal", "modules", "integration", "testdata", "dnd_npc_grounded_pipeline.yml"))
|
||||
if err != nil {
|
||||
t.Fatalf("LoadFileConfig() error = %v", err)
|
||||
}
|
||||
cfg := config.Default()
|
||||
if err := cfg.ApplyFileConfig(fileConfig); err != nil {
|
||||
t.Fatalf("ApplyFileConfig() error = %v", err)
|
||||
}
|
||||
return cfg
|
||||
return loadIntegrationConfig(t, repositoryPathForIntegration("internal", "modules", "integration", "testdata", "dnd_npc_grounded_pipeline.yml"))
|
||||
}
|
||||
|
||||
func configureGroundedCampaignReferences(t *testing.T, cfg *config.Config) map[string]string {
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -168,19 +167,7 @@ func resolveNPCOccurrencePipeline(t *testing.T, registries pipeline.Registries)
|
||||
|
||||
func loadNPCOccurrencePipelineConfig(t *testing.T) config.Config {
|
||||
t.Helper()
|
||||
data, err := os.ReadFile("testdata/dnd_npc_occurrences_pipeline.yml")
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFile(dnd_npc_occurrences_pipeline.yml) error = %v", err)
|
||||
}
|
||||
fileConfig, err := config.ParseFileConfigYAML(data)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseFileConfigYAML() error = %v", err)
|
||||
}
|
||||
result := config.Default()
|
||||
if err := result.ApplyFileConfig(fileConfig); err != nil {
|
||||
t.Fatalf("ApplyFileConfig() error = %v", err)
|
||||
}
|
||||
return result
|
||||
return loadIntegrationConfig(t, "testdata/dnd_npc_occurrences_pipeline.yml")
|
||||
}
|
||||
|
||||
func normalizedLane(t *testing.T, output pipeline.RunOutput, laneID string) contracts.SerializedOutput {
|
||||
|
||||
@@ -331,19 +331,7 @@ func moduleCatalog(registries pipeline.Registries) pipeline.ModuleCatalog {
|
||||
|
||||
func loadNPCPipelineConfig(t *testing.T) config.Config {
|
||||
t.Helper()
|
||||
data, err := os.ReadFile("testdata/dnd_npc_registry_pipeline.yml")
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFile(dnd_npc_registry_pipeline.yml) error = %v", err)
|
||||
}
|
||||
fileConfig, err := config.ParseFileConfigYAML(data)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseFileConfigYAML() error = %v", err)
|
||||
}
|
||||
cfg := config.Default()
|
||||
if err := cfg.ApplyFileConfig(fileConfig); err != nil {
|
||||
t.Fatalf("ApplyFileConfig() error = %v", err)
|
||||
}
|
||||
return cfg
|
||||
return loadIntegrationConfig(t, "testdata/dnd_npc_registry_pipeline.yml")
|
||||
}
|
||||
|
||||
func readNPCFixture(t *testing.T) []byte {
|
||||
|
||||
@@ -2,7 +2,6 @@ package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -121,19 +120,7 @@ func dndCapabilityCatalog(t *testing.T, inputSpec, extractorSpec pipeline.Module
|
||||
func loadDNDSpellsPipelineConfig(t *testing.T) config.Config {
|
||||
t.Helper()
|
||||
|
||||
data, err := os.ReadFile("testdata/pipeline.yml")
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFile(pipeline.yml) error = %v, want nil", err)
|
||||
}
|
||||
fileCfg, err := config.ParseFileConfigYAML(data)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseFileConfigYAML() error = %v, want nil", err)
|
||||
}
|
||||
cfg := config.Default()
|
||||
if err := cfg.ApplyFileConfig(fileCfg); err != nil {
|
||||
t.Fatalf("ApplyFileConfig() error = %v, want nil", err)
|
||||
}
|
||||
return cfg
|
||||
return loadIntegrationConfig(t, "testdata/pipeline.yml")
|
||||
}
|
||||
|
||||
type dndSpellsCatalogSpecs struct {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version: 4
|
||||
version: 5
|
||||
output:
|
||||
directory: ./notarius-output
|
||||
cache:
|
||||
@@ -9,16 +9,16 @@ debug:
|
||||
directory: ./notarius-debug
|
||||
pipelines:
|
||||
dnd-npc-grounded:
|
||||
input: seriatim
|
||||
input: {module: seriatim}
|
||||
steps:
|
||||
- id: identify-npcs
|
||||
artifacts:
|
||||
npc_registry:
|
||||
extract: dnd/npc-registry
|
||||
normalize: dnd/npc-registry
|
||||
extract: {module: dnd/npc-registry}
|
||||
normalize: {module: dnd/npc-registry}
|
||||
scene-descriptions:
|
||||
extract: dnd/scene-descriptions
|
||||
normalize: dnd/scene-descriptions
|
||||
extract: {module: dnd/scene-descriptions}
|
||||
normalize: {module: dnd/scene-descriptions}
|
||||
- id: grounded-events
|
||||
references:
|
||||
npc_registry:
|
||||
@@ -31,8 +31,8 @@ pipelines:
|
||||
lane: scene-descriptions
|
||||
artifacts:
|
||||
spells:
|
||||
extract: dnd/spells
|
||||
normalize: dnd/spells
|
||||
extract: {module: dnd/spells}
|
||||
normalize: {module: dnd/spells}
|
||||
combat:
|
||||
extract: dnd/combat-turns
|
||||
normalize: dnd/combat-turns
|
||||
extract: {module: dnd/combat-turns}
|
||||
normalize: {module: dnd/combat-turns}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version: 4
|
||||
version: 5
|
||||
output:
|
||||
directory: ./notarius-output
|
||||
cache:
|
||||
@@ -9,13 +9,13 @@ debug:
|
||||
directory: ./notarius-debug
|
||||
pipelines:
|
||||
dnd-npc-occurrences-fixture:
|
||||
input: seriatim
|
||||
input: {module: seriatim}
|
||||
steps:
|
||||
- id: identify-npcs
|
||||
artifacts:
|
||||
npc_registry:
|
||||
extract: dnd/npc-registry
|
||||
normalize: dnd/npc-registry
|
||||
extract: {module: dnd/npc-registry}
|
||||
normalize: {module: dnd/npc-registry}
|
||||
- id: extract-occurrences
|
||||
references:
|
||||
npc_registry:
|
||||
@@ -24,5 +24,5 @@ pipelines:
|
||||
lane: npc_registry
|
||||
artifacts:
|
||||
occurrences:
|
||||
extract: dnd/npc-occurrences
|
||||
normalize: dnd/npc-occurrences
|
||||
extract: {module: dnd/npc-occurrences}
|
||||
normalize: {module: dnd/npc-occurrences}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version: 4
|
||||
version: 5
|
||||
output:
|
||||
directory: ./notarius-output
|
||||
cache:
|
||||
@@ -9,12 +9,12 @@ debug:
|
||||
directory: ./notarius-debug
|
||||
pipelines:
|
||||
dnd-npc-registry-fixture:
|
||||
input: seriatim
|
||||
chunk: generic
|
||||
input: {module: seriatim}
|
||||
chunk: {module: generic}
|
||||
artifacts:
|
||||
npc_registry:
|
||||
extract:
|
||||
module: dnd/npc-registry
|
||||
retries: 2
|
||||
normalize: dnd/npc-registry
|
||||
output: json
|
||||
normalize: {module: dnd/npc-registry}
|
||||
output: {module: json}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
version: 4
|
||||
version: 5
|
||||
output:
|
||||
directory: ./notarius-output
|
||||
cache:
|
||||
@@ -9,11 +9,11 @@ debug:
|
||||
directory: ./notarius-debug
|
||||
pipelines:
|
||||
dnd-spells-fixture:
|
||||
input: seriatim
|
||||
chunk: fake/chunk
|
||||
input: {module: seriatim}
|
||||
chunk: {module: fake/chunk}
|
||||
artifacts:
|
||||
spells:
|
||||
extract: dnd/spells
|
||||
merge: appendorder
|
||||
normalize: noop
|
||||
output: json
|
||||
extract: {module: dnd/spells}
|
||||
merge: {module: appendorder}
|
||||
normalize: {module: noop}
|
||||
output: {module: json}
|
||||
|
||||
Reference in New Issue
Block a user