Make production registration asset-free and verify direct deterministic execution

This commit is contained in:
2026-11-22 01:35:23 +00:00
parent 433ed420f8
commit b47208bd57
18 changed files with 231 additions and 250 deletions

View File

@@ -1,25 +1,11 @@
package register package assets_test
import ( import (
"context" "context"
"reflect"
"strings" "strings"
"testing" "testing"
"time"
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm" "go.maximumdirect.net/promptkit"
combatextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/combatturns"
enemyeventextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/enemyevents"
itemoccurrenceextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/itemoccurrences"
itemregistryextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/itemregistry"
locationoccurrenceextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/locationoccurrences"
locationextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/locationregistry"
occurrenceextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/npcoccurrences"
npcextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/npcregistry"
scenedescriptionextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/scenedescriptions"
spellextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/spells"
"gitea.maximumdirect.net/eric/notarius/internal/testsupport/promptkitfixture"
"gitea.maximumdirect.net/eric/promptkit"
) )
func TestExtractionPromptComposition(t *testing.T) { func TestExtractionPromptComposition(t *testing.T) {
@@ -34,11 +20,7 @@ func TestExtractionPromptComposition(t *testing.T) {
endpointOrderSentinel = "according to transcript order" endpointOrderSentinel = "according to transcript order"
combatPolicySentinel = "substantive active combat materially organizes the" combatPolicySentinel = "substantive active combat materially organizes the"
) )
registry := llm.NewAssetRegistry() _, engine := loadNativeAssets(t)
if err := registerPromptAssets(registry); err != nil {
t.Fatalf("registerPromptAssets() error = %v", err)
}
engine := newPromptCacheEngine(t, registry)
commonInputs := map[string]promptkit.ArtifactRef{ commonInputs := map[string]promptkit.ArtifactRef{
"transcript": promptkit.InlineWithURI("file:///session.json", `{"sentinel":"`+transcriptSentinel+`"}`), "transcript": promptkit.InlineWithURI("file:///session.json", `{"sentinel":"`+transcriptSentinel+`"}`),
"players": promptkit.Inline(playersSentinel), "players": promptkit.Inline(playersSentinel),
@@ -48,31 +30,28 @@ func TestExtractionPromptComposition(t *testing.T) {
cases := []struct { cases := []struct {
name string name string
promptID string promptID string
promptVersion string
inputs map[string]promptkit.ArtifactRef inputs map[string]promptkit.ArtifactRef
suffixGroups [][]string suffixGroups [][]string
middleSentinel string middleSentinel string
}{ }{
{name: "npcs", promptID: npcextract.PromptID, promptVersion: npcextract.SchemaVersion, inputs: commonInputs, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}}}, {name: "npcs", promptID: "notarius/dnd.npc_registry", inputs: commonInputs, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}}},
{name: "locations", promptID: locationextract.PromptID, promptVersion: locationextract.SchemaVersion, inputs: commonInputs, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}}}, {name: "locations", promptID: "notarius/dnd.location_registry", inputs: commonInputs, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}}},
{name: "item occurrences", promptID: itemoccurrenceextract.PromptID, promptVersion: itemoccurrenceextract.SchemaVersion, inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{ {name: "item occurrences", promptID: "notarius/dnd.item_occurrences", inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
"item_registry": promptkit.Inline(`{"items":[{"id":"item-registry-sentinel","name":"Torch"}]}`), "item_registry": promptkit.Inline(`{"items":[{"id":"item-registry-sentinel","name":"Torch"}]}`),
}), suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {"item-registry-sentinel"}}}, }), suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {"item-registry-sentinel"}}},
{name: "item registry", promptID: itemregistryextract.PromptID, promptVersion: itemregistryextract.SchemaVersion, inputs: commonInputs, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}}}, {name: "item registry", promptID: "notarius/dnd.item_registry", inputs: commonInputs, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}}},
{name: "scene descriptions", promptID: scenedescriptionextract.PromptID, promptVersion: scenedescriptionextract.SchemaVersion, inputs: commonInputs, middleSentinel: combatPolicySentinel}, {name: "scene descriptions", promptID: "notarius/dnd.scene_descriptions", inputs: commonInputs, middleSentinel: combatPolicySentinel},
{ {
name: "combat turns", name: "combat turns",
promptID: combatextract.PromptID, promptID: "notarius/dnd.combat_turns",
promptVersion: combatextract.SchemaVersion,
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{ inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
"npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`), "npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`),
}), }),
suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {npcSentinel}}, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {npcSentinel}},
}, },
{ {
name: "enemy events", name: "enemy events",
promptID: enemyeventextract.PromptID, promptID: "notarius/dnd.enemy_events",
promptVersion: enemyeventextract.SchemaVersion,
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{ inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
"npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`), "npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`),
"combat_turns": promptkit.Inline(`{"sentinel":"combat-turns-sentinel"}`), "combat_turns": promptkit.Inline(`{"sentinel":"combat-turns-sentinel"}`),
@@ -85,27 +64,24 @@ func TestExtractionPromptComposition(t *testing.T) {
}, },
}, },
{ {
name: "npc occurrences", name: "npc occurrences",
promptID: occurrenceextract.PromptID, promptID: "notarius/dnd.npc_occurrences",
promptVersion: occurrenceextract.SchemaVersion,
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{ inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
"npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`), "npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`),
}), }),
suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {npcSentinel}}, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {npcSentinel}},
}, },
{ {
name: "location occurrences", name: "location occurrences",
promptID: locationoccurrenceextract.PromptID, promptID: "notarius/dnd.location_occurrences",
promptVersion: locationoccurrenceextract.SchemaVersion,
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{ inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
"location_registry": promptkit.Inline(`{"sentinel":"location-registry-sentinel"}`), "location_registry": promptkit.Inline(`{"sentinel":"location-registry-sentinel"}`),
}), }),
suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {"location-registry-sentinel"}}, suffixGroups: [][]string{{evidenceSentinel, endpointOrderSentinel}, {"location-registry-sentinel"}},
}, },
{ {
name: "spells", name: "spells",
promptID: spellextract.PromptID, promptID: "notarius/dnd.spells",
promptVersion: spellextract.SchemaVersion,
inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{ inputs: withPromptInputs(commonInputs, map[string]promptkit.ArtifactRef{
"npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`), "npc_registry": promptkit.Inline(`{"sentinel":"` + npcSentinel + `"}`),
"spell_catalog": promptkit.Inline(`{"sentinel":"` + catalogSentinel + `"}`), "spell_catalog": promptkit.Inline(`{"sentinel":"` + catalogSentinel + `"}`),
@@ -114,18 +90,19 @@ func TestExtractionPromptComposition(t *testing.T) {
}, },
} }
var sharedPrefix []promptkit.RenderedMessage
for _, testCase := range cases { for _, testCase := range cases {
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
prepared, err := engine.Prepare(context.Background(), promptkit.RunRequest{ handle, err := engine.PrepareExecution(context.Background(), promptkit.RunRequest{
PromptID: testCase.promptID, PromptID: testCase.promptID,
PromptVersion: testCase.promptVersion, APIKey: "test-only",
ProfileID: "prompt-cache-test-profile", ProfileID: "notarius/dnd-extraction",
Inputs: testCase.inputs, Inputs: testCase.inputs,
}) })
if err != nil { if err != nil {
t.Fatalf("Prepare() error = %v", err) t.Fatalf("PrepareExecution() error = %v", err)
} }
defer handle.Discard()
prepared := handle.Details()
transcriptIndex := renderedInputMessageIndex(t, prepared.Messages, transcriptSentinel) transcriptIndex := renderedInputMessageIndex(t, prepared.Messages, transcriptSentinel)
referenceIndex := renderedInputMessageIndex(t, prepared.Messages, playersSentinel) referenceIndex := renderedInputMessageIndex(t, prepared.Messages, playersSentinel)
if referenceIndex >= transcriptIndex { if referenceIndex >= transcriptIndex {
@@ -133,15 +110,6 @@ func TestExtractionPromptComposition(t *testing.T) {
} }
assertEphemeralCache(t, prepared.Messages, referenceIndex) assertEphemeralCache(t, prepared.Messages, referenceIndex)
assertEphemeralCache(t, prepared.Messages, transcriptIndex) assertEphemeralCache(t, prepared.Messages, transcriptIndex)
prefix := prepared.Messages[:transcriptIndex+1]
if len(prepared.Messages) <= len(prefix) {
t.Fatalf("prepared prompt has %d messages, want lane-specific suffix after transcript", len(prepared.Messages))
}
if sharedPrefix == nil {
sharedPrefix = append([]promptkit.RenderedMessage(nil), prefix...)
} else if !reflect.DeepEqual(prefix, sharedPrefix) {
t.Fatalf("rendered prefix = %#v, want %#v", prefix, sharedPrefix)
}
previousIndex := transcriptIndex previousIndex := transcriptIndex
for _, group := range testCase.suffixGroups { for _, group := range testCase.suffixGroups {
groupIndex := -1 groupIndex := -1
@@ -173,13 +141,6 @@ func TestExtractionPromptComposition(t *testing.T) {
} }
} }
func newPromptCacheEngine(t *testing.T, registry *llm.AssetRegistry) *promptkit.Engine {
t.Helper()
return promptkitfixture.NewEngine(t, registry, promptkit.Config{Timeout: time.Second}, map[string]promptkit.ProfileConfig{
"prompt-cache-test-profile": promptkitfixture.Profile("http://127.0.0.1:1/v1", "prompt-cache-test-model"),
})
}
func withPromptInputs(inputs, extras map[string]promptkit.ArtifactRef) map[string]promptkit.ArtifactRef { func withPromptInputs(inputs, extras map[string]promptkit.ArtifactRef) map[string]promptkit.ArtifactRef {
merged := make(map[string]promptkit.ArtifactRef, len(inputs)+len(extras)) merged := make(map[string]promptkit.ArtifactRef, len(inputs)+len(extras))
for name, input := range inputs { for name, input := range inputs {

View File

@@ -1,4 +1,4 @@
package register package assets_test
import ( import (
"encoding/json" "encoding/json"
@@ -8,25 +8,18 @@ import (
"strings" "strings"
"testing" "testing"
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm" "gitea.maximumdirect.net/eric/notarius/assets"
) )
func TestRegisteredResponseSchemasRequireEveryObjectProperty(t *testing.T) { func TestModelResponseSchemasRequireEveryObjectProperty(t *testing.T) {
assets := llm.NewAssetRegistry() schemaFS := assets.FS()
if err := Register(completeRegistries(), assets); err != nil {
t.Fatal(err)
}
schemaFS, err := assets.SchemaFS()
if err != nil {
t.Fatal(err)
}
count := 0 count := 0
err = fs.WalkDir(schemaFS, ".", func(path string, entry fs.DirEntry, walkErr error) error { err := fs.WalkDir(schemaFS, ".", func(path string, entry fs.DirEntry, walkErr error) error {
if walkErr != nil { if walkErr != nil {
return walkErr return walkErr
} }
if entry.IsDir() || !strings.HasSuffix(path, ".json") { if entry.IsDir() || !strings.HasSuffix(path, "_llm.v1.json") {
return nil return nil
} }
content, err := fs.ReadFile(schemaFS, path) content, err := fs.ReadFile(schemaFS, path)
@@ -46,7 +39,7 @@ func TestRegisteredResponseSchemasRequireEveryObjectProperty(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
if count == 0 { if count == 0 {
t.Fatal("no registered response schemas found") t.Fatal("no model response schemas found")
} }
} }

View File

@@ -1086,6 +1086,26 @@ unusable final response, no prior-candidate recovery, and source identity.
## Stage 24: Finish Deterministic Stage Paths And Production Registration ## Stage 24: Finish Deterministic Stage Paths And Production Registration
**Status:** Complete. D&D, generic, and Seriatim family registration now accepts
only typed module registries; removed prompt/schema/fallback-profile registration
and adapted composition callers. Raw codecs, evidence projectors, all domain
validator defaults, and typed append/noop variants remain intact. Added native
embedded-resource dependency coverage for registered producers and validators.
Moved prompt-composition/schema-compatibility checks to the content package,
using real native preparation without private asset assembly or prefix snapshots.
Deterministic producers already run directly through the migrated runner; updated
the Seriatim typed fixtures to run without an engine and added direct merge-error
and noop-value/cancellation coverage. No synthetic requests or outer retries were
introduced; ordinary errors remain errors even in permissive mode.
All generic and Seriatim package tests, scene-normalizer tests, native asset tests,
focused typed pipeline tests, selected vet/race checks, and `git diff --check`
pass. The D&D registrar, six other deterministic normalizers, and full module
integration tests remain blocked at setup by shared legacy asset helpers importing
old ConfigKit's removed YAML `plugin/limit`; their results, including the new
registration dependency test, are not claimed passing. Scheduled legacy cleanup
and final assembled verification must execute them. Old CLI runtime asset/client
wiring remains assigned to its later migration stages.
**Goal:** all non-LLM work runs directly, and production registration is asset-free. **Goal:** all non-LLM work runs directly, and production registration is asset-free.
**Inspect/change:** generic unit chunker/append-order merger/noop normalizer, **Inspect/change:** generic unit chunker/append-order merger/noop normalizer,

View File

@@ -35,14 +35,14 @@ func newProductionComponents() (productionComponents, error) {
assets := llm.NewAssetRegistry() assets := llm.NewAssetRegistry()
registrars := []struct { registrars := []struct {
name string name string
register func(pipeline.Registries, *llm.AssetRegistry) error register func(pipeline.Registries) error
}{ }{
{name: "generic", register: genericregister.Register}, {name: "generic", register: genericregister.Register},
{name: "seriatim", register: seriatimregister.Register}, {name: "seriatim", register: seriatimregister.Register},
{name: "dnd", register: dndregister.Register}, {name: "dnd", register: dndregister.Register},
} }
for _, registrar := range registrars { for _, registrar := range registrars {
if err := registrar.register(registries, assets); err != nil { if err := registrar.register(registries); err != nil {
return productionComponents{}, fmt.Errorf("register %s module family: %w", registrar.name, err) return productionComponents{}, fmt.Errorf("register %s module family: %w", registrar.name, err)
} }
} }

View File

@@ -0,0 +1,81 @@
package register
import (
"context"
"testing"
"gitea.maximumdirect.net/eric/notarius/assets"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
"go.maximumdirect.net/configkit"
"go.maximumdirect.net/promptkit"
)
func TestRegisteredDependenciesUseNativeEmbeddedPrompts(t *testing.T) {
registries := completeRegistries()
if err := Register(registries); err != nil {
t.Fatal(err)
}
type document struct {
PromptKit promptkit.Settings `yaml:"promptkit"`
}
filesystem := configkit.NewFilesystem("Notarius assets", assets.FS())
definition := promptkit.Configure(configkit.Definition[document]{}, func(value *document) *promptkit.Settings { return &value.PromptKit })
result, err := configkit.LoadLayered(configkit.Input{Source: configkit.NoSource()}, configkit.LayeredOptions[document]{
Definition: definition,
Underlays: []configkit.Underlay{
promptkit.BundledOpenRouterUnderlay(),
{Inputs: []configkit.Input{{
Source: filesystem.File("notarius.yml"), Imports: true,
Filesystem: &configkit.FilesystemContext{FS: &filesystem, Root: "."},
}}},
},
})
if err != nil {
t.Fatal(err)
}
engine, err := promptkit.NewFromConfig(result, promptkit.RuntimeConfig{})
if err != nil {
t.Fatal(err)
}
checkPrompts := func(key string, class contracts.ExecutionClass, ids []string, expected int) {
t.Helper()
if class == contracts.ExecutionClassDeterministic {
expected = 0
}
if len(ids) != expected {
t.Fatalf("%s declares %v; want %d static prompt dependencies", key, ids, expected)
}
for _, id := range ids {
if _, err := engine.InspectPrompt(context.Background(), id); err != nil {
t.Fatalf("%s prompt %s: %v", key, id, err)
}
}
}
for _, key := range registries.Chunkers.RegisteredKeys() {
spec, ok := registries.Chunkers.Spec(key)
if !ok {
t.Fatalf("missing chunker spec %s", key)
}
checkPrompts(key, spec.ExecutionClass, spec.Prompts, 2)
}
for _, key := range registries.Extractors.RegisteredKeys() {
spec, ok := registries.Extractors.Spec(key)
if !ok {
t.Fatalf("missing extractor spec %s", key)
}
checkPrompts(key, spec.ExecutionClass, spec.Prompts, 2)
}
for _, key := range registries.Normalizers.RegisteredKeys() {
for _, kind := range registries.Normalizers.RegisteredArtifactKinds(key) {
spec, ok := registries.Normalizers.SpecForArtifact(key, kind)
if !ok {
t.Fatalf("missing normalizer spec %s/%s", key, kind)
}
checkPrompts(key, spec.ExecutionClass, spec.Prompts, 2)
}
}
for _, spec := range registries.Validators.RegisteredSpecs() {
checkPrompts(spec.Key, spec.ExecutionClass, spec.Prompts, 1)
}
}

View File

@@ -1,7 +1,6 @@
package register package register
import ( import (
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd" "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/chunk/scenes" "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/chunk/scenes"
@@ -35,7 +34,6 @@ import (
npcnormalize "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/normalize/npcregistry" npcnormalize "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/normalize/npcregistry"
scenedescriptionnormalize "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/normalize/scenedescriptions" scenedescriptionnormalize "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/normalize/scenedescriptions"
spellnormalize "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/normalize/spells" spellnormalize "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/normalize/spells"
combatsemantics "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/validate/scenedescriptions/combat_semantics"
"gitea.maximumdirect.net/eric/notarius/internal/modules/generic/merge/appendorder" "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/merge/appendorder"
"gitea.maximumdirect.net/eric/notarius/internal/modules/generic/normalize/noop" "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/normalize/noop"
) )
@@ -144,23 +142,3 @@ func registerModules(registries pipeline.Registries) error {
}}, }},
}) })
} }
func registerPromptAssets(assets *llm.AssetRegistry) error {
return runRegistrations([]registration{
{name: "scenes prompt assets", register: func() error { return scenes.RegisterPromptAssets(assets) }},
{name: "spells prompt assets", register: func() error { return spellextract.RegisterPromptAssets(assets) }},
{name: "npc registry prompt assets", register: func() error { return npcextract.RegisterPromptAssets(assets) }},
{name: "npc normalization prompt assets", register: func() error { return npcnormalize.RegisterPromptAssets(assets) }},
{name: "combat turns prompt assets", register: func() error { return combatextract.RegisterPromptAssets(assets) }},
{name: "enemy events prompt assets", register: func() error { return enemyeventextract.RegisterPromptAssets(assets) }},
{name: "item occurrences prompt assets", register: func() error { return itemoccurrenceextract.RegisterPromptAssets(assets) }},
{name: "item registry prompt assets", register: func() error { return itemregistryextract.RegisterPromptAssets(assets) }},
{name: "item registry normalization prompt assets", register: func() error { return itemregistrynormalize.RegisterPromptAssets(assets) }},
{name: "npc occurrences prompt assets", register: func() error { return occurrenceextract.RegisterPromptAssets(assets) }},
{name: "scene descriptions prompt assets", register: func() error { return scenedescriptionextract.RegisterPromptAssets(assets) }},
{name: "scene combat-semantics validator prompt assets", register: func() error { return combatsemantics.RegisterPromptAssets(assets) }},
{name: "location registry prompt assets", register: func() error { return locationextract.RegisterPromptAssets(assets) }},
{name: "location normalization prompt assets", register: func() error { return locationnormalize.RegisterPromptAssets(assets) }},
{name: "location occurrences prompt assets", register: func() error { return locationoccurrenceextract.RegisterPromptAssets(assets) }},
})
}

View File

@@ -1,17 +0,0 @@
package register
import (
"fmt"
"io/fs"
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
)
func registerFallbackProfiles(assets *llm.AssetRegistry) error {
profiles, err := fs.Sub(rootassets.FS(), "dnd/profiles")
if err != nil {
return fmt.Errorf("scope D&D fallback profiles: %w", err)
}
return assets.RegisterFallbackProfileFS(profiles, ".")
}

View File

@@ -4,7 +4,6 @@ package register
import ( import (
"fmt" "fmt"
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
) )
@@ -13,9 +12,9 @@ type registration struct {
register func() error register func() error
} }
// Register adds all production D&D modules, validators, policy, and assets. // Register adds all production D&D modules, validators, and policy.
func Register(registries pipeline.Registries, assets *llm.AssetRegistry) error { func Register(registries pipeline.Registries) error {
if err := validateRegistries(registries, assets); err != nil { if err := validateRegistries(registries); err != nil {
return err return err
} }
if err := registerModules(registries); err != nil { if err := registerModules(registries); err != nil {
@@ -27,12 +26,6 @@ func Register(registries pipeline.Registries, assets *llm.AssetRegistry) error {
if err := registerValidators(registries); err != nil { if err := registerValidators(registries); err != nil {
return err return err
} }
if err := registerPromptAssets(assets); err != nil {
return err
}
if err := registerFallbackProfiles(assets); err != nil {
return err
}
return registerDefaultChains(registries.ValidatorChains) return registerDefaultChains(registries.ValidatorChains)
} }
@@ -45,7 +38,7 @@ func runRegistrations(registrations []registration) error {
return nil return nil
} }
func validateRegistries(registries pipeline.Registries, assets *llm.AssetRegistry) error { func validateRegistries(registries pipeline.Registries) error {
switch { switch {
case registries.Chunkers == nil: case registries.Chunkers == nil:
return fmt.Errorf("dnd registrar: chunker registry must not be nil") return fmt.Errorf("dnd registrar: chunker registry must not be nil")
@@ -63,8 +56,6 @@ func validateRegistries(registries pipeline.Registries, assets *llm.AssetRegistr
return fmt.Errorf("dnd registrar: validator registry must not be nil") return fmt.Errorf("dnd registrar: validator registry must not be nil")
case registries.ValidatorChains == nil: case registries.ValidatorChains == nil:
return fmt.Errorf("dnd registrar: validator chain registry must not be nil") return fmt.Errorf("dnd registrar: validator chain registry must not be nil")
case assets == nil:
return fmt.Errorf("dnd registrar: asset registry must not be nil")
default: default:
return nil return nil
} }

View File

@@ -1,14 +1,12 @@
package register package register
import ( import (
"io/fs"
"reflect" "reflect"
"strings" "strings"
"testing" "testing"
"gitea.maximumdirect.net/eric/notarius/internal/core/source" "gitea.maximumdirect.net/eric/notarius/internal/core/source"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts" "gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd" "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
combatextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/combatturns" combatextract "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/extract/combatturns"
@@ -36,49 +34,9 @@ import (
func TestRegisterAddsDNDFamily(t *testing.T) { func TestRegisterAddsDNDFamily(t *testing.T) {
registries := completeRegistries() registries := completeRegistries()
assets := llm.NewAssetRegistry() if err := Register(registries); err != nil {
if err := Register(registries, assets); err != nil {
t.Fatalf("Register() error = %v, want nil", err) t.Fatalf("Register() error = %v, want nil", err)
} }
promptFS, err := assets.PromptFS()
if err != nil {
t.Fatalf("PromptFS() error = %v", err)
}
if _, err := fs.ReadFile(promptFS, "dnd.npc_registry.normalize/prompt.yaml"); err != nil {
t.Fatalf("normalization prompt asset = %v, want registered private prompt", err)
}
for _, name := range []string{
"dnd.scenes/prompt.yaml",
"dnd.spells/prompt.yaml",
"dnd.npc_registry/prompt.yaml",
"dnd.combat_turns/prompt.yaml",
"dnd.enemy_events/prompt.yaml",
"dnd.item_occurrences/prompt.yaml",
"dnd.item_registry/prompt.yaml",
"dnd.item_registry.normalize/prompt.yaml",
"dnd.npc_occurrences/prompt.yaml",
"dnd.scene_descriptions/prompt.yaml",
"dnd.scene_descriptions.validate_combat/prompt.yaml",
"dnd.npc_registry.normalize/prompt.yaml",
"dnd.location_registry/prompt.yaml",
"dnd.location_registry.normalize/prompt.yaml",
"dnd.location_occurrences/prompt.yaml",
} {
content, err := fs.ReadFile(promptFS, name)
if err != nil {
t.Fatalf("read prompt asset %q: %v", name, err)
}
if !strings.Contains(string(content), "default_profile: dnd-extraction") {
t.Fatalf("prompt asset %q does not select dnd-extraction", name)
}
}
fallbackFS, err := assets.FallbackProfileFS()
if err != nil {
t.Fatalf("FallbackProfileFS() error = %v", err)
}
if _, err := fs.ReadFile(fallbackFS, "dnd-extraction.yaml"); err != nil {
t.Fatalf("fallback profile asset = %v, want registered D&D profile", err)
}
assertContainsKeys(t, "chunkers", registries.Chunkers.RegisteredKeys(), []string{"dnd/scenes"}) assertContainsKeys(t, "chunkers", registries.Chunkers.RegisteredKeys(), []string{"dnd/scenes"})
assertContainsKeys(t, "extractors", registries.Extractors.RegisteredKeys(), []string{"dnd/spells", npcextract.Key, combatextract.Key, enemyeventextract.Key, itemoccurrenceextract.Key, itemregistryextract.Key, occurrenceextract.Key, scenedescriptionextract.Key, locationextract.Key, locationoccurrenceextract.Key}) assertContainsKeys(t, "extractors", registries.Extractors.RegisteredKeys(), []string{"dnd/spells", npcextract.Key, combatextract.Key, enemyeventextract.Key, itemoccurrenceextract.Key, itemregistryextract.Key, occurrenceextract.Key, scenedescriptionextract.Key, locationextract.Key, locationoccurrenceextract.Key})
assertContainsKeys(t, "normalizers", registries.Normalizers.RegisteredKeys(), []string{spellnormalize.Key, npcnormalize.Key, combatnormalize.Key, enemyeventnormalize.Key, itemoccurrencenormalize.Key, itemregistrynormalize.Key, occurrencenormalize.Key, scenedescriptionnormalize.Key, locationnormalize.Key, locationoccurrencenormalize.Key, pipeline.DefaultNormalizeModule}) assertContainsKeys(t, "normalizers", registries.Normalizers.RegisteredKeys(), []string{spellnormalize.Key, npcnormalize.Key, combatnormalize.Key, enemyeventnormalize.Key, itemoccurrencenormalize.Key, itemregistrynormalize.Key, occurrencenormalize.Key, scenedescriptionnormalize.Key, locationnormalize.Key, locationoccurrencenormalize.Key, pipeline.DefaultNormalizeModule})
@@ -767,25 +725,23 @@ func TestAppendListsPreserveNestedSourceReferencePresence(t *testing.T) {
func TestRegisterRejectsMissingDNDDependenciesBeforeMutation(t *testing.T) { func TestRegisterRejectsMissingDNDDependenciesBeforeMutation(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
remove func(*pipeline.Registries, **llm.AssetRegistry) remove func(*pipeline.Registries)
wantErr string wantErr string
}{ }{
{name: "chunkers", remove: func(r *pipeline.Registries, _ **llm.AssetRegistry) { r.Chunkers = nil }, wantErr: "chunker registry"}, {name: "chunkers", remove: func(r *pipeline.Registries) { r.Chunkers = nil }, wantErr: "chunker registry"},
{name: "artifact codecs", remove: func(r *pipeline.Registries, _ **llm.AssetRegistry) { r.ArtifactCodecs = nil }, wantErr: "artifact codec registry"}, {name: "artifact codecs", remove: func(r *pipeline.Registries) { r.ArtifactCodecs = nil }, wantErr: "artifact codec registry"},
{name: "artifact evidence", remove: func(r *pipeline.Registries, _ **llm.AssetRegistry) { r.ArtifactEvidence = nil }, wantErr: "artifact evidence registry"}, {name: "artifact evidence", remove: func(r *pipeline.Registries) { r.ArtifactEvidence = nil }, wantErr: "artifact evidence registry"},
{name: "extractors", remove: func(r *pipeline.Registries, _ **llm.AssetRegistry) { r.Extractors = nil }, wantErr: "extractor registry"}, {name: "extractors", remove: func(r *pipeline.Registries) { r.Extractors = nil }, wantErr: "extractor registry"},
{name: "mergers", remove: func(r *pipeline.Registries, _ **llm.AssetRegistry) { r.Mergers = nil }, wantErr: "merger registry"}, {name: "mergers", remove: func(r *pipeline.Registries) { r.Mergers = nil }, wantErr: "merger registry"},
{name: "normalizers", remove: func(r *pipeline.Registries, _ **llm.AssetRegistry) { r.Normalizers = nil }, wantErr: "normalizer registry"}, {name: "normalizers", remove: func(r *pipeline.Registries) { r.Normalizers = nil }, wantErr: "normalizer registry"},
{name: "validators", remove: func(r *pipeline.Registries, _ **llm.AssetRegistry) { r.Validators = nil }, wantErr: "validator registry"}, {name: "validators", remove: func(r *pipeline.Registries) { r.Validators = nil }, wantErr: "validator registry"},
{name: "validator chains", remove: func(r *pipeline.Registries, _ **llm.AssetRegistry) { r.ValidatorChains = nil }, wantErr: "validator chain registry"}, {name: "validator chains", remove: func(r *pipeline.Registries) { r.ValidatorChains = nil }, wantErr: "validator chain registry"},
{name: "assets", remove: func(_ *pipeline.Registries, assets **llm.AssetRegistry) { *assets = nil }, wantErr: "asset registry"},
} }
for _, test := range tests { for _, test := range tests {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registries := completeRegistries() registries := completeRegistries()
assets := llm.NewAssetRegistry() test.remove(&registries)
test.remove(&registries, &assets) err := Register(registries)
err := Register(registries, assets)
if err == nil || !strings.Contains(err.Error(), test.wantErr) { if err == nil || !strings.Contains(err.Error(), test.wantErr) {
t.Fatalf("Register() error = %v, want %q", err, test.wantErr) t.Fatalf("Register() error = %v, want %q", err, test.wantErr)
} }
@@ -798,11 +754,10 @@ func TestRegisterRejectsMissingDNDDependenciesBeforeMutation(t *testing.T) {
func TestRegisterReportsDuplicateDNDRegistration(t *testing.T) { func TestRegisterReportsDuplicateDNDRegistration(t *testing.T) {
registries := completeRegistries() registries := completeRegistries()
assets := llm.NewAssetRegistry() if err := Register(registries); err != nil {
if err := Register(registries, assets); err != nil {
t.Fatalf("first Register() error = %v, want nil", err) t.Fatalf("first Register() error = %v, want nil", err)
} }
err := Register(registries, assets) err := Register(registries)
if err == nil || !strings.Contains(err.Error(), "register dnd spells codec") || !strings.Contains(err.Error(), "already registered") { if err == nil || !strings.Contains(err.Error(), "register dnd spells codec") || !strings.Contains(err.Error(), "already registered") {
t.Fatalf("second Register() error = %v, want contextual duplicate error", err) t.Fatalf("second Register() error = %v, want contextual duplicate error", err)
} }

View File

@@ -2,6 +2,7 @@ package appendorder
import ( import (
"context" "context"
"errors"
"reflect" "reflect"
"testing" "testing"
@@ -23,3 +24,27 @@ func TestTypedMergerCombinesValuesInFrameworkOrder(t *testing.T) {
t.Fatalf("result=%#v err=%v", result, err) t.Fatalf("result=%#v err=%v", result, err)
} }
} }
func TestTypedMergerPropagatesApplicationErrorWithoutRetry(t *testing.T) {
failure := errors.New("cannot combine these values")
calls := 0
merger, err := NewTyped(func([]string) (string, error) {
calls++
return "", failure
})
if err != nil {
t.Fatal(err)
}
result, err := merger.Merge(context.Background(), contracts.TypedMergeRequest[string]{
Operation: contracts.ProducerOperation[string]{
Controls: contracts.ProducerControls{Mode: contracts.ModePermissive, MaxAdditionalTurns: 3},
Assess: func(context.Context, string) (contracts.CandidateAssessment, error) {
t.Fatal("merger invoked assessment instead of returning its operation error")
return contracts.CandidateAssessment{}, nil
},
},
})
if !errors.Is(err, failure) || calls != 1 || result.Outcome.Disposition != "" || result.Fallback != nil {
t.Fatalf("Merge() = %#v, %v; combine calls = %d", result, err, calls)
}
}

View File

@@ -0,0 +1,33 @@
package noop
import (
"context"
"errors"
"reflect"
"testing"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
)
func TestTypedNormalizerReturnsIncomingValueForRunnerAssessment(t *testing.T) {
value := []string{"second", "first", "first"}
request := contracts.TypedNormalizeRequest[[]string]{
MergeOutput: contracts.MergeArtifact[[]string]{Value: value},
Operation: contracts.ProducerOperation[[]string]{
Controls: contracts.ProducerControls{Mode: contracts.ModePermissive, MaxAdditionalTurns: 3},
Assess: func(context.Context, []string) (contracts.CandidateAssessment, error) {
t.Fatal("deterministic normalizer invoked the runner's assessor")
return contracts.CandidateAssessment{}, nil
},
},
}
result, err := NewTyped[[]string]().Normalize(context.Background(), request)
if err != nil || !reflect.DeepEqual(result.Value, value) || result.Outcome.Disposition != "" || result.Fallback != nil {
t.Fatalf("Normalize() = %#v, %v; want unchanged value for direct runner assessment", result, err)
}
ctx, cancel := context.WithCancel(context.Background())
cancel()
if _, err := NewTyped[[]string]().Normalize(ctx, request); !errors.Is(err, context.Canceled) {
t.Fatalf("Normalize() after cancellation = %v", err)
}
}

View File

@@ -4,9 +4,7 @@ package register
import ( import (
"fmt" "fmt"
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
"gitea.maximumdirect.net/eric/notarius/internal/framework/semanticreconcile"
"gitea.maximumdirect.net/eric/notarius/internal/modules/generic/chunk/units" "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/chunk/units"
jsonoutput "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/output/json" jsonoutput "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/output/json"
alwaysaccept "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/validate/always_accept" alwaysaccept "gitea.maximumdirect.net/eric/notarius/internal/modules/generic/validate/always_accept"
@@ -16,18 +14,14 @@ import (
) )
// Register adds all production domain-neutral modules and validators. // Register adds all production domain-neutral modules and validators.
func Register(registries pipeline.Registries, assets *llm.AssetRegistry) error { func Register(registries pipeline.Registries) error {
if err := validateRegistries(registries); err != nil { if err := validateRegistries(registries); err != nil {
return err return err
} }
if assets == nil {
return fmt.Errorf("generic registrar: asset registry must not be nil")
}
registrations := []struct { registrations := []struct {
name string name string
register func() error register func() error
}{ }{
{name: "semantic reconciliation assets", register: func() error { return semanticreconcile.RegisterAssets(assets) }},
{name: "generic chunker", register: func() error { return units.Register(registries.Chunkers) }}, {name: "generic chunker", register: func() error { return units.Register(registries.Chunkers) }},
{name: "always accept validator", register: func() error { return alwaysaccept.Register(registries.Validators) }}, {name: "always accept validator", register: func() error { return alwaysaccept.Register(registries.Validators) }},
{name: "always reject validator", register: func() error { return alwaysreject.Register(registries.Validators) }}, {name: "always reject validator", register: func() error { return alwaysreject.Register(registries.Validators) }},

View File

@@ -1,18 +1,15 @@
package register package register
import ( import (
"io/fs"
"strings" "strings"
"testing" "testing"
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
) )
func TestRegisterAddsGenericFamily(t *testing.T) { func TestRegisterAddsGenericFamily(t *testing.T) {
registries := completeRegistries() registries := completeRegistries()
assets := llm.NewAssetRegistry() if err := Register(registries); err != nil {
if err := Register(registries, assets); err != nil {
t.Fatalf("Register() error = %v, want nil", err) t.Fatalf("Register() error = %v, want nil", err)
} }
assertContainsKeys(t, "chunkers", registries.Chunkers.RegisteredKeys(), []string{"generic"}) assertContainsKeys(t, "chunkers", registries.Chunkers.RegisteredKeys(), []string{"generic"})
@@ -33,31 +30,6 @@ func TestRegisterAddsGenericFamily(t *testing.T) {
if output, err := registries.Outputs.Build("json"); err != nil || output.Key() != "json" { if output, err := registries.Outputs.Build("json"); err != nil || output.Key() != "json" {
t.Fatalf("build json output = %v, %v; want json implementation", output, err) t.Fatalf("build json output = %v, %v; want json implementation", output, err)
} }
promptAssets, err := assets.PromptFS()
if err != nil {
t.Fatal(err)
}
if _, err := fs.ReadFile(promptAssets, "generic.semantic_reconciliation/prompt.yaml"); err != nil {
t.Fatalf("registered semantic reconciliation prompt: %v", err)
}
schemaAssets, err := assets.SchemaFS()
if err != nil {
t.Fatal(err)
}
if _, err := fs.ReadFile(schemaAssets, "semantic_reconciliation_llm.v1.json"); err != nil {
t.Fatalf("registered semantic reconciliation schema: %v", err)
}
}
func TestRegisterRejectsNilAssetRegistryBeforeMutation(t *testing.T) {
registries := completeRegistries()
err := Register(registries, nil)
if err == nil || !strings.Contains(err.Error(), "asset registry must not be nil") {
t.Fatalf("Register() error = %v, want nil asset registry error", err)
}
if len(registries.Chunkers.RegisteredKeys()) != 0 {
t.Fatalf("chunker keys = %#v, want validation before mutation", registries.Chunkers.RegisteredKeys())
}
} }
func TestRegisterRejectsMissingGenericRegistriesBeforeMutation(t *testing.T) { func TestRegisterRejectsMissingGenericRegistriesBeforeMutation(t *testing.T) {
@@ -76,7 +48,7 @@ func TestRegisterRejectsMissingGenericRegistriesBeforeMutation(t *testing.T) {
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
registries := completeRegistries() registries := completeRegistries()
test.remove(&registries) test.remove(&registries)
err := Register(registries, llm.NewAssetRegistry()) err := Register(registries)
if err == nil || !strings.Contains(err.Error(), test.wantErr) { if err == nil || !strings.Contains(err.Error(), test.wantErr) {
t.Fatalf("Register() error = %v, want %q", err, test.wantErr) t.Fatalf("Register() error = %v, want %q", err, test.wantErr)
} }
@@ -89,12 +61,11 @@ func TestRegisterRejectsMissingGenericRegistriesBeforeMutation(t *testing.T) {
func TestRegisterReportsDuplicateGenericRegistration(t *testing.T) { func TestRegisterReportsDuplicateGenericRegistration(t *testing.T) {
registries := completeRegistries() registries := completeRegistries()
assets := llm.NewAssetRegistry() if err := Register(registries); err != nil {
if err := Register(registries, assets); err != nil {
t.Fatalf("first Register() error = %v, want nil", err) t.Fatalf("first Register() error = %v, want nil", err)
} }
err := Register(registries, assets) err := Register(registries)
if err == nil || !strings.Contains(err.Error(), "register semantic reconciliation assets") || !strings.Contains(err.Error(), "already registered") { if err == nil || !strings.Contains(err.Error(), "register generic chunker") || !strings.Contains(err.Error(), "already registered") {
t.Fatalf("second Register() error = %v, want contextual duplicate error", err) t.Fatalf("second Register() error = %v, want contextual duplicate error", err)
} }
} }

View File

@@ -10,7 +10,6 @@ import (
"gitea.maximumdirect.net/eric/notarius/internal/core/config" "gitea.maximumdirect.net/eric/notarius/internal/core/config"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts" "gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
"gitea.maximumdirect.net/eric/notarius/internal/framework/semanticreconcile" "gitea.maximumdirect.net/eric/notarius/internal/framework/semanticreconcile"
npccodec "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/codec/npcregistry" npccodec "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/codec/npcregistry"
@@ -305,16 +304,15 @@ func productionNPCRegistries(t *testing.T) pipeline.Registries {
ValidatorChains: pipeline.NewValidatorChainRegistry(), ValidatorChains: pipeline.NewValidatorChainRegistry(),
Outputs: pipeline.NewOutputEncoderRegistry(), Outputs: pipeline.NewOutputEncoderRegistry(),
} }
assets := llm.NewAssetRegistry()
for _, registration := range []struct { for _, registration := range []struct {
name string name string
fn func(pipeline.Registries, *llm.AssetRegistry) error fn func(pipeline.Registries) error
}{ }{
{name: "generic", fn: genericregister.Register}, {name: "generic", fn: genericregister.Register},
{name: "seriatim", fn: seriatimregister.Register}, {name: "seriatim", fn: seriatimregister.Register},
{name: "dnd", fn: dndregister.Register}, {name: "dnd", fn: dndregister.Register},
} { } {
if err := registration.fn(registries, assets); err != nil { if err := registration.fn(registries); err != nil {
t.Fatalf("register %s modules: %v", registration.name, err) t.Fatalf("register %s modules: %v", registration.name, err)
} }
} }

View File

@@ -110,7 +110,7 @@ type fakeExtractor struct{}
func (fakeExtractor) Key() string { return "fake/extract" } func (fakeExtractor) Key() string { return "fake/extract" }
func (fakeExtractor) ReferenceSlots() []contracts.ReferenceSlot { return nil } func (fakeExtractor) ReferenceSlots() []contracts.ReferenceSlot { return nil }
func (fakeExtractor) Extract(context.Context, contracts.TypedExtractionRequest) (contracts.TypedExtractionResult[seriatimArtifact], error) { func (fakeExtractor) Extract(context.Context, contracts.TypedExtractionRequest[seriatimArtifact]) (contracts.TypedExtractionResult[seriatimArtifact], error) {
return contracts.TypedExtractionResult[seriatimArtifact]{}, nil return contracts.TypedExtractionResult[seriatimArtifact]{}, nil
} }

View File

@@ -13,9 +13,9 @@ import (
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
) )
func runPreparedPipeline(t *testing.T, registries pipeline.Registries, resolved pipeline.ResolvedPipeline, llmClient contracts.StructuredLLMClient, input pipeline.RunInput) (pipeline.RunOutput, error) { func runPreparedPipeline(t *testing.T, registries pipeline.Registries, resolved pipeline.ResolvedPipeline, input pipeline.RunInput) (pipeline.RunOutput, error) {
t.Helper() t.Helper()
prepared, err := pipeline.Prepare(resolved, registries, pipeline.ModuleDependencies{LLM: llmClient}) prepared, err := pipeline.Prepare(resolved, registries, pipeline.ModuleDependencies{})
if err != nil { if err != nil {
return pipeline.RunOutput{}, err return pipeline.RunOutput{}, err
} }
@@ -36,7 +36,7 @@ func TestRunnerProcessesSeriatimInputWithFakeModules(t *testing.T) {
} }
extractor := &runnerSeriatimExtractor{} extractor := &runnerSeriatimExtractor{}
output, err := runPreparedPipeline(t, seriatimRunnerRegistries(t, extractor), resolved.ResolvedPipeline, nil, pipeline.RunInput{ output, err := runPreparedPipeline(t, seriatimRunnerRegistries(t, extractor), resolved.ResolvedPipeline, pipeline.RunInput{
RawInput: raw, RawInput: raw,
}) })
if err != nil { if err != nil {
@@ -90,7 +90,7 @@ func TestRunnerFailsOnInvalidSeriatimInput(t *testing.T) {
t.Fatalf("Resolve() error = %v, want nil", err) t.Fatalf("Resolve() error = %v, want nil", err)
} }
output, err := runPreparedPipeline(t, seriatimRunnerRegistries(t, &runnerSeriatimExtractor{}), resolved.ResolvedPipeline, nil, pipeline.RunInput{ output, err := runPreparedPipeline(t, seriatimRunnerRegistries(t, &runnerSeriatimExtractor{}), resolved.ResolvedPipeline, pipeline.RunInput{
RawInput: []byte(`{"metadata":{},"segments":[]}`), RawInput: []byte(`{"metadata":{},"segments":[]}`),
SourceID: "invalid-source", SourceID: "invalid-source",
}) })
@@ -195,7 +195,7 @@ func (e *runnerSeriatimExtractor) ReferenceSlots() []contracts.ReferenceSlot {
return nil return nil
} }
func (e *runnerSeriatimExtractor) Extract(ctx context.Context, req contracts.TypedExtractionRequest) (contracts.TypedExtractionResult[seriatimArtifact], error) { func (e *runnerSeriatimExtractor) Extract(ctx context.Context, req contracts.TypedExtractionRequest[seriatimArtifact]) (contracts.TypedExtractionResult[seriatimArtifact], error) {
e.calls++ e.calls++
if req.Source == nil { if req.Source == nil {
return contracts.TypedExtractionResult[seriatimArtifact]{}, fmt.Errorf("source must not be nil") return contracts.TypedExtractionResult[seriatimArtifact]{}, fmt.Errorf("source must not be nil")

View File

@@ -4,14 +4,12 @@ package register
import ( import (
"fmt" "fmt"
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline" "gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
"gitea.maximumdirect.net/eric/notarius/internal/modules/seriatim/input/transcript" "gitea.maximumdirect.net/eric/notarius/internal/modules/seriatim/input/transcript"
) )
// Register adds all production Seriatim modules. // Register adds all production Seriatim modules.
func Register(registries pipeline.Registries, assets *llm.AssetRegistry) error { func Register(registries pipeline.Registries) error {
_ = assets
if registries.Inputs == nil { if registries.Inputs == nil {
return fmt.Errorf("seriatim registrar: input registry must not be nil") return fmt.Errorf("seriatim registrar: input registry must not be nil")
} }

View File

@@ -9,7 +9,7 @@ import (
func TestRegisterAddsSeriatimFamily(t *testing.T) { func TestRegisterAddsSeriatimFamily(t *testing.T) {
registries := pipeline.Registries{Inputs: pipeline.NewInputAdapterRegistry()} registries := pipeline.Registries{Inputs: pipeline.NewInputAdapterRegistry()}
if err := Register(registries, nil); err != nil { if err := Register(registries); err != nil {
t.Fatalf("Register() error = %v, want nil", err) t.Fatalf("Register() error = %v, want nil", err)
} }
assertContainsKeys(t, "inputs", registries.Inputs.RegisteredKeys(), []string{"seriatim"}) assertContainsKeys(t, "inputs", registries.Inputs.RegisteredKeys(), []string{"seriatim"})
@@ -32,7 +32,7 @@ func assertContainsKeys(t *testing.T, name string, got, want []string) {
} }
func TestRegisterRejectsNilInputRegistry(t *testing.T) { func TestRegisterRejectsNilInputRegistry(t *testing.T) {
err := Register(pipeline.Registries{}, nil) err := Register(pipeline.Registries{})
if err == nil || !strings.Contains(err.Error(), "input registry must not be nil") { if err == nil || !strings.Contains(err.Error(), "input registry must not be nil") {
t.Fatalf("Register() error = %v, want nil input registry error", err) t.Fatalf("Register() error = %v, want nil input registry error", err)
} }
@@ -40,10 +40,10 @@ func TestRegisterRejectsNilInputRegistry(t *testing.T) {
func TestRegisterReportsDuplicateSeriatimRegistration(t *testing.T) { func TestRegisterReportsDuplicateSeriatimRegistration(t *testing.T) {
registries := pipeline.Registries{Inputs: pipeline.NewInputAdapterRegistry()} registries := pipeline.Registries{Inputs: pipeline.NewInputAdapterRegistry()}
if err := Register(registries, nil); err != nil { if err := Register(registries); err != nil {
t.Fatalf("first Register() error = %v, want nil", err) t.Fatalf("first Register() error = %v, want nil", err)
} }
err := Register(registries, nil) err := Register(registries)
if err == nil || !strings.Contains(err.Error(), "register transcript input") || !strings.Contains(err.Error(), "already registered") { if err == nil || !strings.Contains(err.Error(), "register transcript input") || !strings.Contains(err.Error(), "already registered") {
t.Fatalf("second Register() error = %v, want contextual duplicate error", err) t.Fatalf("second Register() error = %v, want contextual duplicate error", err)
} }