Reconcile reuse and inspection with native extraction
This commit is contained in:
@@ -28,10 +28,12 @@ scriptorium:
|
||||
enabled: false
|
||||
for_each: party.characters
|
||||
prompt_id: dnd.character_meta
|
||||
output_path_pattern: artifacts/characters/{character_id}/meta.md
|
||||
output_path_pattern: artifacts/{character_id}-meta.md
|
||||
`)
|
||||
campaign := write("campaign.yml", `campaign_id: campaign
|
||||
inputs: {speakers_file: speakers.yml, autocorrect_file: autocorrect.yml, glossary_file: glossary.yml, party_file: party.yml}
|
||||
campaign := write("campaign.yml", `schema_version: maximumdirect.rpg.campaign.v1
|
||||
id: campaign
|
||||
references: {party: party.yml}
|
||||
narratio: {inputs: {speakers_file: speakers.yml, glossary_file: glossary.yml}}
|
||||
`)
|
||||
session := write("session.yml", `session_id: session
|
||||
campaign: campaign
|
||||
|
||||
@@ -181,7 +181,10 @@ func TestExecuteStagesBoundedCompositionUsesOnlySelectedCollaborators(t *testing
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
if test.configure != nil {
|
||||
var injected *stage.Env
|
||||
if test.stageName == "extract" {
|
||||
cfg, injected, _ = extractionLifecycleFixture(t, true)
|
||||
} else if test.configure != nil {
|
||||
test.configure(cfg)
|
||||
}
|
||||
plan := mustBoundedPlan(t, test.stageName, test.stageName)
|
||||
@@ -192,7 +195,7 @@ func TestExecuteStagesBoundedCompositionUsesOnlySelectedCollaborators(t *testing
|
||||
|
||||
var captured *stage.Env
|
||||
plan.stages = []stage.Stage{collaboratorProbeStage{name: test.stageName, captured: &captured}}
|
||||
_, err := executePlan(context.Background(), cfg, plan, RunOptions{})
|
||||
_, err := executePlan(context.Background(), cfg, plan, RunOptions{Env: injected})
|
||||
if err != nil {
|
||||
t.Fatalf("executeStages() error = %v", err)
|
||||
}
|
||||
|
||||
@@ -38,21 +38,21 @@ scriptorium:
|
||||
enabled: false
|
||||
for_each: party.characters
|
||||
prompt_id: meta
|
||||
output_path_pattern: artifacts/{character_id}/meta.md
|
||||
output_path_pattern: artifacts/{character_id}-meta.md
|
||||
inputs:
|
||||
players: {source: narratio.input.players, required: true}
|
||||
character_note:
|
||||
enabled: false
|
||||
for_each: party.characters
|
||||
prompt_id: note
|
||||
output_path_pattern: artifacts/{character_id}/note.md
|
||||
output_path_pattern: artifacts/{character_id}-note.md
|
||||
inputs:
|
||||
meta: {source: narratio.member_artifact.character_meta, required: true}
|
||||
member_vars:
|
||||
character_name: character.name
|
||||
`)
|
||||
campaignPath := filepath.Join(dir, "campaign.yml")
|
||||
mustWriteTestFile(t, campaignPath, "campaign_id: campaign\ninputs: {speakers_file: speakers.yml, autocorrect_file: autocorrect.yml, glossary_file: glossary.yml, party_file: default-party.yml}\n")
|
||||
mustWriteTestFile(t, campaignPath, "schema_version: maximumdirect.rpg.campaign.v1\nid: campaign\nreferences: {party: default-party.yml}\nnarratio: {inputs: {speakers_file: speakers.yml, glossary_file: glossary.yml}}\n")
|
||||
partyPath := filepath.Join(dir, "selected-party.yml")
|
||||
mustWriteTestFile(t, partyPath, "schema_version: maximumdirect.rpg.party.v1\ncharacters:\n ivy:\n player: {name: Selected Player}\n character: {name: Ivy, classes: [{name: ranger}]}\n")
|
||||
sessionPath := filepath.Join(dir, "session.yml")
|
||||
|
||||
@@ -149,7 +149,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(pipelinePath, []byte(pipelineYAML), 0o644); err != nil {
|
||||
@@ -212,7 +211,7 @@ inputs:
|
||||
}
|
||||
foundReference := false
|
||||
if err := filepath.WalkDir(workRoot, func(path string, entry os.DirEntry, walkErr error) error {
|
||||
if walkErr != nil || entry.IsDir() {
|
||||
if walkErr != nil || entry.IsDir() || entry.Type()&os.ModeSymlink != 0 {
|
||||
return walkErr
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
@@ -259,7 +258,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(pipelinePath, []byte(pipelineYAML), 0o644); err != nil {
|
||||
@@ -348,16 +346,18 @@ func TestExecuteCampaignIDSelectsRegistryCampaign(t *testing.T) {
|
||||
pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, workspaceRoot)
|
||||
campaignRoot := filepath.Dir(filepath.Dir(campaignPath))
|
||||
otherDir := filepath.Join(campaignRoot, "icewind")
|
||||
mustWriteTestFile(t, filepath.Join(otherDir, "campaign.yml"), `campaign_id: icewind
|
||||
inputs:
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
party_file: ./party.yml
|
||||
mustWriteTestFile(t, filepath.Join(otherDir, "campaign.yml"), `schema_version: maximumdirect.rpg.campaign.v1
|
||||
id: icewind
|
||||
references:
|
||||
party: ./party.yml
|
||||
narratio:
|
||||
inputs:
|
||||
speakers_file: ./speakers.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`)
|
||||
mustWriteTestFile(t, filepath.Join(otherDir, "speakers.yml"), "match:\n - speaker: Alice\n match: [\"alice\"]\n")
|
||||
mustWriteTestFile(t, filepath.Join(otherDir, "autocorrect.yml"), "[]\n")
|
||||
mustWriteTestFile(t, filepath.Join(otherDir, "glossary.yml"), "[]\n")
|
||||
mustWriteTestFile(t, filepath.Join(otherDir, "glossary.yml"), "schema_version: maximumdirect.glossary.v1\ncollections: {}\n")
|
||||
mustWriteTestFile(t, filepath.Join(otherDir, "players.yml"), "[]\n")
|
||||
mustWriteTestFile(t, filepath.Join(otherDir, "party.yml"), "schema_version: maximumdirect.rpg.party.v1\ncharacters:\n arannis:\n player: {name: Eric}\n character:\n name: Arannis\n classes: [{name: wizard}]\n")
|
||||
|
||||
@@ -470,7 +470,7 @@ narratio:
|
||||
|
||||
mustWriteTestFile(t, filepath.Join(campaignDir, "speakers.yml"), "match:\n - speaker: Alice\n match: [\"alice\"]\n")
|
||||
mustWriteTestFile(t, filepath.Join(campaignDir, "autocorrect.yml"), "[]\n")
|
||||
mustWriteTestFile(t, filepath.Join(campaignDir, "glossary.yml"), "campaign: {entries: []}\n")
|
||||
mustWriteTestFile(t, filepath.Join(campaignDir, "glossary.yml"), "schema_version: maximumdirect.glossary.v1\ncollections:\n campaign: {entries: []}\n")
|
||||
mustWriteTestFile(t, filepath.Join(campaignDir, "party.yml"), "schema_version: maximumdirect.rpg.party.v1\ncharacters:\n arannis:\n player: {name: Eric}\n character:\n name: Arannis\n classes: [{name: wizard}]\n")
|
||||
mustWriteTestFile(t, filepath.Join(dir, "audio", "alice.flac"), "audio-bytes")
|
||||
|
||||
|
||||
@@ -60,62 +60,34 @@ func (s assertExtractionSourcesStage) Run(_ context.Context, env *stage.Env, m *
|
||||
return &stage.StageResult{}, nil
|
||||
}
|
||||
|
||||
func (r *materializingNotariusRunner) Run(_ context.Context, req notarius.RunRequest) (notarius.RunResult, error) {
|
||||
func (r *materializingNotariusRunner) Preflight(ctx context.Context, req notarius.ReadinessRequest) (notarius.ReadinessResult, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return notarius.ReadinessResult{}, err
|
||||
}
|
||||
return notarius.ReadinessResult{Pipeline: req.PipelineID, Lanes: append([]string(nil), req.RequiredLanes...), InspectionComplete: true, AssessmentComplete: true, Ready: true, InputPath: req.InputPath, InputDescription: req.InputDescription}, nil
|
||||
}
|
||||
|
||||
func (r *materializingNotariusRunner) Run(ctx context.Context, req notarius.RunRequest) (notarius.RunResult, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return notarius.RunResult{}, err
|
||||
}
|
||||
r.requests = append(r.requests, req)
|
||||
if r.failuresRemaining > 0 {
|
||||
r.failuresRemaining--
|
||||
return notarius.RunResult{}, errors.New("notarius execution failed")
|
||||
}
|
||||
externalRunID := fmt.Sprintf("notarius-run-%d", len(r.requests))
|
||||
bundle := filepath.Join(req.OutputRoot, externalRunID)
|
||||
lanesDir := filepath.Join(bundle, "lanes")
|
||||
if err := os.MkdirAll(lanesDir, 0o755); err != nil {
|
||||
bundle := filepath.Join(req.OutputRoot, fmt.Sprintf("notarius-run-%d", len(r.requests)))
|
||||
lanes := filepath.Join(bundle, "lanes")
|
||||
if err := os.MkdirAll(lanes, 0755); err != nil {
|
||||
return notarius.RunResult{}, err
|
||||
}
|
||||
for path, content := range map[string]string{
|
||||
filepath.Join(bundle, "index.json"): `{"manifest_file":"manifest.json"}`,
|
||||
filepath.Join(bundle, "manifest.json"): `{}`,
|
||||
filepath.Join(bundle, "rejected.json"): `{"rejected":[]}`,
|
||||
filepath.Join(bundle, "warnings.json"): `{"schema_version":"notarius.warnings.v2","group_count":0,"occurrence_count":0,"groups":[]}`,
|
||||
filepath.Join(bundle, "diagnostics.json"): `{"schema_version":"notarius.diagnostics.v1","group_count":0,"occurrence_count":0,"truncated":false,"unrepresented_occurrence_count":0,"groups":[]}`,
|
||||
} {
|
||||
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
|
||||
for _, output := range r.cfg.Outputs {
|
||||
filename := output.LaneID + ".json"
|
||||
if err := os.WriteFile(filepath.Join(lanes, filename), []byte(`{"records":[]}`), 0644); err != nil {
|
||||
return notarius.RunResult{}, err
|
||||
}
|
||||
}
|
||||
keys := make([]string, 0, len(r.cfg.Outputs))
|
||||
for key := range r.cfg.Outputs {
|
||||
keys = append(keys, key)
|
||||
}
|
||||
sort.Strings(keys)
|
||||
lanes := make([]notarius.LaneDescriptor, 0, len(keys))
|
||||
for _, key := range keys {
|
||||
output := r.cfg.Outputs[key]
|
||||
filename := key + ".json"
|
||||
path := filepath.Join(lanesDir, filename)
|
||||
if err := os.WriteFile(path, []byte(`{"records":[]}`), 0o644); err != nil {
|
||||
return notarius.RunResult{}, err
|
||||
}
|
||||
lanes = append(lanes, notarius.LaneDescriptor{
|
||||
LaneID: output.LaneID, File: filepath.ToSlash(filepath.Join("lanes", filename)), Path: path,
|
||||
MediaType: output.MediaType, SchemaID: output.SchemaID,
|
||||
SchemaVersion: output.SchemaVersion, ModuleKey: output.ModuleKey,
|
||||
})
|
||||
}
|
||||
return notarius.RunResult{
|
||||
Receipt: notarius.Receipt{
|
||||
SchemaVersion: notarius.ReceiptSchemaVersion, RunID: externalRunID,
|
||||
PipelineID: req.PipelineID, OutputDirectory: bundle, IndexFile: "index.json",
|
||||
NormalizedOutputCount: len(lanes), ValidationStatus: "approved",
|
||||
},
|
||||
BundleRoot: bundle,
|
||||
Index: notarius.Index{
|
||||
Path: filepath.Join(bundle, "index.json"), RejectedPath: filepath.Join(bundle, "rejected.json"),
|
||||
WarningsPath: filepath.Join(bundle, "warnings.json"),
|
||||
DiagnosticsPath: filepath.Join(bundle, "diagnostics.json"),
|
||||
Lanes: lanes,
|
||||
},
|
||||
}, nil
|
||||
return notarius.RunResult{BundleRoot: bundle, Report: notarius.CompletionReport{Pipeline: req.PipelineID, ArtifactCount: len(r.cfg.Outputs), OutputDirectory: bundle}}, nil
|
||||
}
|
||||
|
||||
func TestExtractLifecycleDisabledThenEnabled(t *testing.T) {
|
||||
@@ -145,7 +117,7 @@ func TestExtractLifecycleDisabledThenEnabled(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
if loaded.Stages["extract"] == nil || loaded.Stages["extract"].Status != manifest.StatusSucceeded || len(loaded.Stages["extract"].Outputs) != 2 {
|
||||
if loaded.Stages["extract"] == nil || loaded.Stages["extract"].Status != manifest.StatusSucceeded || len(loaded.Stages["extract"].Outputs) != 1 {
|
||||
t.Fatalf("extract record = %#v, want succeeded manifest-ready outputs", loaded.Stages["extract"])
|
||||
}
|
||||
}
|
||||
@@ -170,10 +142,10 @@ func TestExtractLifecyclePrepareBindsVerifiedReferenceSnapshots(t *testing.T) {
|
||||
sourceID string
|
||||
filename string
|
||||
}{
|
||||
{selector: "glossary", sourceID: artifactpolicy.SourceInputGlossaryCampaign, filename: "campaign.yml"},
|
||||
{selector: "glossary", sourceID: artifactpolicy.SourceInputGlossaryCombined, filename: "combined.yml"},
|
||||
{selector: "party", sourceID: artifactpolicy.SourceInputParty, filename: "party.yml"},
|
||||
{selector: "players", sourceID: artifactpolicy.SourceInputPlayers, filename: "players.yml"},
|
||||
{selector: "spells", sourceID: artifactpolicy.SourceInputSpellCatalog, filename: "spell_catalog.json"},
|
||||
{selector: "spells", sourceID: artifactpolicy.SourceInputGlossaryCombined, filename: "combined.yml"},
|
||||
}
|
||||
request := runner.requests[0]
|
||||
if len(request.References) != len(want) {
|
||||
@@ -354,8 +326,8 @@ func TestExtractLifecycleEmptyReferencesPreserveAllDndExtractionSources(t *testi
|
||||
t.Fatalf("summary=%#v requests=%#v analyze=%d", summary, runner.requests, analyzeRuns)
|
||||
}
|
||||
loaded := loadLifecycleManifest(t, cfg)
|
||||
if got := len(loaded.Stages["extract"].Outputs); got != len(keys)+1 {
|
||||
t.Fatalf("extract outputs = %d, want %d lanes plus index", got, len(keys))
|
||||
if got := len(loaded.Stages["extract"].Outputs); got != len(keys) {
|
||||
t.Fatalf("extract outputs = %d, want %d lanes", got, len(keys))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,7 +448,7 @@ characters:
|
||||
t.Fatalf("changed party retained derived players snapshot path %q", thirdPaths["players"])
|
||||
}
|
||||
for selector, firstPath := range firstPaths {
|
||||
if selector != "party" && selector != "players" && thirdPaths[selector] != firstPath {
|
||||
if selector != "party" && selector != "players" && selector != "glossary" && selector != "spells" && thirdPaths[selector] != firstPath {
|
||||
t.Fatalf("unchanged %s snapshot path = %q, want %q", selector, thirdPaths[selector], firstPath)
|
||||
}
|
||||
if _, err := os.Stat(firstPath); err != nil {
|
||||
@@ -496,8 +468,8 @@ func TestExtractLifecycleCacheControlsAndSnapshotLossDoNotInvalidateCompleteResu
|
||||
if err := os.RemoveAll(cacheRoot); err != nil {
|
||||
t.Fatalf("RemoveAll(snapshot cache) error = %v", err)
|
||||
}
|
||||
cfg.Pipeline.Notarius.Resume = true
|
||||
cfg.Pipeline.Notarius.ChunkCache = "bypass"
|
||||
cache := "bypass"
|
||||
cfg.Pipeline.Notarius.Cache = &cache
|
||||
extractPlan, _ := BuildSingleStagePlan("extract")
|
||||
summary, err := executeStages(context.Background(), cfg, extractPlan, RunOptions{Env: env})
|
||||
if err != nil {
|
||||
@@ -537,14 +509,14 @@ func TestAnalyzeOnlyLifecyclePreservesExtractionWithoutInvokingNotarius(t *testi
|
||||
|
||||
func TestForcedArtifactRegenerationUsesOrdinaryExtractAndAnalyzePath(t *testing.T) {
|
||||
cfg, env, runner := extractionLifecycleFixture(t, true)
|
||||
cfg.Pipeline.Notarius.Resume = true
|
||||
cfg.Pipeline.Notarius.ChunkCache = "bypass"
|
||||
cache := "bypass"
|
||||
cfg.Pipeline.Notarius.Cache = &cache
|
||||
analyzeRuns := 0
|
||||
plan := extractionLifecyclePlan(t, &analyzeRuns)
|
||||
if _, err := executeStages(context.Background(), cfg, plan, RunOptions{Env: env, Force: true, SelectedArtifacts: []string{"session_recap"}}); err != nil {
|
||||
t.Fatalf("forced artifact regeneration error = %v", err)
|
||||
}
|
||||
if len(runner.requests) != 1 || runner.requests[0].Resume || runner.requests[0].ChunkCache != "refresh" || analyzeRuns != 1 {
|
||||
if len(runner.requests) != 1 || runner.requests[0].Cache == nil || *runner.requests[0].Cache != "refresh" || analyzeRuns != 1 {
|
||||
t.Fatalf("forced path request=%#v analyze=%d", runner.requests, analyzeRuns)
|
||||
}
|
||||
}
|
||||
@@ -821,10 +793,6 @@ func TestExtractLifecycleRealConfigOverlaysSelectNotariusExplicitly(t *testing.T
|
||||
outputs:
|
||||
npc_registry:
|
||||
lane_id: npc-registry
|
||||
media_type: application/json
|
||||
schema_id: notarius.dnd.npc_registry
|
||||
schema_version: v1
|
||||
module_key: dnd/npc-registry
|
||||
`)
|
||||
closeErr := pipelineFile.Close()
|
||||
if writeErr != nil || closeErr != nil {
|
||||
@@ -941,7 +909,7 @@ func TestExtractLifecycleResumesAndRerunsObsoleteResults(t *testing.T) {
|
||||
}{
|
||||
{name: "configuration changed", mutate: func(_ *testing.T, cfg *config.Config, _ *manifest.Manifest) {
|
||||
output := cfg.Pipeline.Notarius.Outputs["npc_registry"]
|
||||
output.SchemaVersion = "v2"
|
||||
output.Filename = "changed.json"
|
||||
cfg.Pipeline.Notarius.Outputs["npc_registry"] = output
|
||||
}},
|
||||
{name: "payload missing", mutate: func(t *testing.T, _ *config.Config, m *manifest.Manifest) {
|
||||
@@ -955,7 +923,7 @@ func TestExtractLifecycleResumesAndRerunsObsoleteResults(t *testing.T) {
|
||||
}
|
||||
}},
|
||||
{name: "record incompatible", mutate: func(_ *testing.T, _ *config.Config, m *manifest.Manifest) {
|
||||
m.Stages["extract"].Outputs[0].Contract.SchemaID = "incompatible"
|
||||
m.Stages["extract"].Outputs[0].ExternalProvenance.ArtifactID = "incompatible"
|
||||
}},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
@@ -1007,7 +975,7 @@ func TestExtractLifecycleUnsafeResumeErrorPreservesSuccess(t *testing.T) {
|
||||
"analyze": persisted.Stages["analyze"],
|
||||
})
|
||||
|
||||
if _, err := executeStages(context.Background(), cfg, plan, RunOptions{Env: env}); err == nil || !strings.Contains(err.Error(), "unsafe") {
|
||||
if _, err := executeStages(context.Background(), cfg, plan, RunOptions{Env: env}); err == nil || !strings.Contains(err.Error(), "canonical destination") {
|
||||
t.Fatalf("executeStages() error = %v, want unsafe resume failure", err)
|
||||
}
|
||||
afterManifest, err := store.Load(context.Background(), first.ManifestPath)
|
||||
@@ -1083,25 +1051,13 @@ func (lifecycleTrimEvidenceStage) Run(_ context.Context, env *stage.Env, m *mani
|
||||
func configureLifecycleReferences(t *testing.T, cfg *config.Config) map[string]string {
|
||||
t.Helper()
|
||||
cfg.Pipeline.Notarius.References = map[string]string{
|
||||
"party": artifactpolicy.SourceInputParty,
|
||||
"players": artifactpolicy.SourceInputPlayers,
|
||||
"glossary": artifactpolicy.SourceInputGlossaryCampaign,
|
||||
"spells": artifactpolicy.SourceInputSpellCatalog,
|
||||
"party": artifactpolicy.SourceInputParty, "players": artifactpolicy.SourceInputPlayers,
|
||||
"glossary": artifactpolicy.SourceInputGlossaryCombined, "spells": artifactpolicy.SourceInputGlossaryCombined,
|
||||
}
|
||||
spellPath := filepath.Join(filepath.Dir(cfg.CampaignPath), "spells.json")
|
||||
if err := os.WriteFile(spellPath, []byte(`{"spells":[]}`+"\n"), 0o644); err != nil {
|
||||
t.Fatalf("WriteFile(spell catalog) error = %v", err)
|
||||
}
|
||||
cfg.StableInputs.SpellCatalogFile = config.ResolvedInputFile{
|
||||
Path: "./spells.json", ConfigPath: cfg.CampaignPath, Source: "campaign_config",
|
||||
}
|
||||
cfg.Session.Inputs.SpellCatalogFile = "./spells.json"
|
||||
|
||||
return map[string]string{
|
||||
artifactpolicy.SourceInputParty: filepath.Join(filepath.Dir(cfg.CampaignPath), "party.yml"),
|
||||
artifactpolicy.SourceInputPlayers: filepath.Join(filepath.Dir(cfg.CampaignPath), "players.yml"),
|
||||
artifactpolicy.SourceInputGlossaryCampaign: filepath.Join(filepath.Dir(cfg.CampaignPath), "glossary.yml"),
|
||||
artifactpolicy.SourceInputSpellCatalog: spellPath,
|
||||
artifactpolicy.SourceInputGlossaryCombined: filepath.Join(filepath.Dir(cfg.CampaignPath), "glossary.yml"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1129,16 +1085,16 @@ func lifecycleReferencePaths(request notarius.RunRequest) map[string]string {
|
||||
|
||||
func lifecycleDndOutputs() map[string]config.NotariusOutputConfig {
|
||||
return map[string]config.NotariusOutputConfig{
|
||||
"item_registry": {LaneID: "item-registry", MediaType: "application/json", SchemaID: "notarius.dnd.item_registry", SchemaVersion: "v1", ModuleKey: "dnd/item-registry"},
|
||||
"npc_registry": {LaneID: "npc-registry", MediaType: "application/json", SchemaID: "notarius.dnd.npc_registry", SchemaVersion: "v1", ModuleKey: "dnd/npc-registry"},
|
||||
"location_registry": {LaneID: "location-registry", MediaType: "application/json", SchemaID: "notarius.dnd.location_registry", SchemaVersion: "v1", ModuleKey: "dnd/location-registry"},
|
||||
"scene_descriptions": {LaneID: "scene-descriptions", MediaType: "application/json", SchemaID: "notarius.dnd.scene_descriptions", SchemaVersion: "v1", ModuleKey: "dnd/scene-descriptions"},
|
||||
"item_occurrences": {LaneID: "item-occurrences", MediaType: "application/json", SchemaID: "notarius.dnd.item_occurrences", SchemaVersion: "v1", ModuleKey: "dnd/item-occurrences"},
|
||||
"spells": {LaneID: "spells", MediaType: "application/json", SchemaID: "notarius.dnd.spells", SchemaVersion: "v1", ModuleKey: "dnd/spells"},
|
||||
"combat_turns": {LaneID: "combat-turns", MediaType: "application/json", SchemaID: "notarius.dnd.combat_turns", SchemaVersion: "v1", ModuleKey: "dnd/combat-turns"},
|
||||
"npc_occurrences": {LaneID: "npc-occurrences", MediaType: "application/json", SchemaID: "notarius.dnd.npc_occurrences", SchemaVersion: "v1", ModuleKey: "dnd/npc-occurrences"},
|
||||
"location_occurrences": {LaneID: "location-occurrences", MediaType: "application/json", SchemaID: "notarius.dnd.location_occurrences", SchemaVersion: "v1", ModuleKey: "dnd/location-occurrences"},
|
||||
"enemy_events": {LaneID: "enemy-events", MediaType: "application/json", SchemaID: "notarius.dnd.enemy_events", SchemaVersion: "v1", ModuleKey: "dnd/enemy-events"},
|
||||
"item_registry": {LaneID: "item-registry"},
|
||||
"npc_registry": {LaneID: "npc-registry"},
|
||||
"location_registry": {LaneID: "location-registry"},
|
||||
"scene_descriptions": {LaneID: "scene-descriptions"},
|
||||
"item_occurrences": {LaneID: "item-occurrences"},
|
||||
"spells": {LaneID: "spells"},
|
||||
"combat_turns": {LaneID: "combat-turns"},
|
||||
"npc_occurrences": {LaneID: "npc-occurrences"},
|
||||
"location_occurrences": {LaneID: "location-occurrences"},
|
||||
"enemy_events": {LaneID: "enemy-events"},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1163,8 +1119,7 @@ func extractionLifecycleFixture(t *testing.T, enabled bool) (*config.Config, *st
|
||||
Timeout: "45m", WorkingDirectory: workingDirectory,
|
||||
Outputs: map[string]config.NotariusOutputConfig{
|
||||
"npc_registry": {
|
||||
LaneID: "npc-registry", MediaType: "application/json", SchemaID: "notarius.dnd.npc_registry",
|
||||
SchemaVersion: "v1", ModuleKey: "dnd/npc-registry",
|
||||
LaneID: "npc-registry",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestPreparedGlossaryAliasPresence(t *testing.T) {
|
||||
pipeline, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
||||
entry := "{id: watch, name: Watch, category: person" + aliases + "}"
|
||||
if mode == "file" {
|
||||
mustWriteTestFile(t, filepath.Join(filepath.Dir(campaign), "glossary.yml"), "campaign: {entries: ["+entry+"]}\n")
|
||||
mustWriteTestFile(t, filepath.Join(filepath.Dir(campaign), "glossary.yml"), "schema_version: maximumdirect.glossary.v1\ncollections:\n campaign: {entries: ["+entry+"]}\n")
|
||||
} else {
|
||||
mustWriteTestFile(t, session, "session_id: 2026-05-03\ninputs:\n audio_dir: ./audio\n glossary_file: null\n glossary: {entries: ["+entry+"]}\n")
|
||||
}
|
||||
@@ -43,13 +43,15 @@ func TestPreparedGlossaryAliasPresence(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var doc map[string]struct {
|
||||
Entries []map[string]any `yaml:"entries"`
|
||||
var doc struct {
|
||||
Collections map[string]struct {
|
||||
Entries []map[string]any `yaml:"entries"`
|
||||
} `yaml:"collections"`
|
||||
}
|
||||
if err := yaml.Unmarshal(data, &doc); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
entries := doc["campaign"].Entries
|
||||
entries := doc.Collections["campaign"].Entries
|
||||
if len(entries) != 1 {
|
||||
t.Fatalf("entries: %s", data)
|
||||
}
|
||||
@@ -90,11 +92,11 @@ func TestSelectedCatalogSourcesBeforePreparation(t *testing.T) {
|
||||
}
|
||||
mustWriteTestFile(t, pipeline, string(body)+fmt.Sprintf("reference_catalog:\n %s:\n broken: %s\n", group.name, tc.value))
|
||||
if tc.selected {
|
||||
body, err = os.ReadFile(campaign)
|
||||
body, err = os.ReadFile(session)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mustWriteTestFile(t, campaign, string(body)+fmt.Sprintf(" %s: broken\n", group.selector))
|
||||
mustWriteTestFile(t, session, string(body)+fmt.Sprintf(" %s: broken\n", group.selector))
|
||||
}
|
||||
cfg, err := config.LoadWithSessionOptions(pipeline, campaign, session, config.SessionLoadOptions{})
|
||||
if tc.invalid {
|
||||
|
||||
@@ -109,18 +109,20 @@ func TestExecuteSessionInitExplicitConfigWinsOverDefaults(t *testing.T) {
|
||||
|
||||
explicitDir := t.TempDir()
|
||||
explicitCampaign := filepath.Join(explicitDir, "campaign.yml")
|
||||
if err := os.WriteFile(explicitCampaign, []byte(`campaign_id: explicit-campaign
|
||||
inputs:
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
party_file: ./party.yml
|
||||
if err := os.WriteFile(explicitCampaign, []byte(`schema_version: maximumdirect.rpg.campaign.v1
|
||||
id: explicit-campaign
|
||||
references:
|
||||
party: ./party.yml
|
||||
narratio:
|
||||
inputs:
|
||||
speakers_file: ./speakers.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`), 0o644); err != nil {
|
||||
t.Fatalf("write explicit campaign: %v", err)
|
||||
}
|
||||
mustWriteTestFile(t, filepath.Join(explicitDir, "speakers.yml"), "match:\n - speaker: Alice\n match: [\"alice\"]\n")
|
||||
mustWriteTestFile(t, filepath.Join(explicitDir, "autocorrect.yml"), "[]\n")
|
||||
mustWriteTestFile(t, filepath.Join(explicitDir, "glossary.yml"), "[]\n")
|
||||
mustWriteTestFile(t, filepath.Join(explicitDir, "glossary.yml"), "schema_version: maximumdirect.glossary.v1\ncollections: {}\n")
|
||||
mustWriteTestFile(t, filepath.Join(explicitDir, "players.yml"), "[]\n")
|
||||
mustWriteTestFile(t, filepath.Join(explicitDir, "party.yml"), "schema_version: maximumdirect.rpg.party.v1\ncharacters:\n arannis:\n player: {name: Eric}\n character:\n name: Arannis\n classes: [{name: wizard}]\n")
|
||||
|
||||
@@ -468,63 +470,6 @@ inputs:
|
||||
}
|
||||
}
|
||||
|
||||
func TestOperatorCommandsReportConfiguredSpellCatalog(t *testing.T) {
|
||||
workspaceRoot := t.TempDir()
|
||||
pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, workspaceRoot)
|
||||
campaignBytes, err := os.ReadFile(campaignPath)
|
||||
if err != nil {
|
||||
t.Fatalf("read campaign: %v", err)
|
||||
}
|
||||
campaignYAML := strings.Replace(string(campaignBytes), " party_file: ./party.yml\n", " party_file: ./party.yml\n spell_catalog_file: ./spells.json\n", 1)
|
||||
if err := os.WriteFile(campaignPath, []byte(campaignYAML), 0o644); err != nil {
|
||||
t.Fatalf("write campaign: %v", err)
|
||||
}
|
||||
spellPath := filepath.Join(filepath.Dir(campaignPath), "spells.json")
|
||||
mustWriteTestFile(t, spellPath, "{\"spells\":[]}\n")
|
||||
seedValidationPrepared(t, loadConfigForSemanticEvidence(t, pipelinePath, campaignPath, sessionPath))
|
||||
|
||||
fake := &storage.FakeBackend{}
|
||||
var storeInitCalls int
|
||||
deps := fakeCommandDependencies(fake, &storeInitCalls)
|
||||
commonArgs := []string{
|
||||
"2026-05-03",
|
||||
"--config", pipelinePath,
|
||||
"--campaign-file", campaignPath, "--session-file", sessionPath,
|
||||
}
|
||||
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
validateArgs := append([]string{"session", "validate"}, commonArgs...)
|
||||
if code := executeWithDependencies(validateArgs, &stdout, &stderr, deps, executePlan); code != 0 {
|
||||
t.Fatalf("validate exit code = %d, want 0; stdout=%q stderr=%q", code, stdout.String(), stderr.String())
|
||||
}
|
||||
if !findingMatches(decodeNativeReport[sessionValidationReport](t, stdout.Bytes()).Findings, "OK", "inputs", spellPath) {
|
||||
t.Fatalf("validate stdout = %q, want spell catalog finding", stdout.String())
|
||||
}
|
||||
|
||||
stdout.Reset()
|
||||
stderr.Reset()
|
||||
statusArgs := append([]string{"session", "status"}, commonArgs...)
|
||||
if code := executeWithDependencies(statusArgs, &stdout, &stderr, deps, executePlan); code != 0 {
|
||||
t.Fatalf("status exit code = %d, want 0; stdout=%q stderr=%q", code, stdout.String(), stderr.String())
|
||||
}
|
||||
if !findingMatches(decodeNativeReport[sessionStateReport](t, stdout.Bytes()).Findings, "INFO", "inputs", spellPath) {
|
||||
t.Fatalf("status stdout = %q, want spell catalog inventory", stdout.String())
|
||||
}
|
||||
|
||||
if err := os.Remove(spellPath); err != nil {
|
||||
t.Fatalf("remove spell catalog: %v", err)
|
||||
}
|
||||
stdout.Reset()
|
||||
stderr.Reset()
|
||||
if code := executeWithDependencies(validateArgs, &stdout, &stderr, deps, executePlan); code == 0 {
|
||||
t.Fatalf("validate missing spell catalog exit code = 0; stdout=%q", stdout.String())
|
||||
}
|
||||
if !findingMatches(decodeNativeReport[sessionValidationReport](t, stdout.Bytes()).Findings, "ERROR", "inputs", "spell_catalog") {
|
||||
t.Fatalf("validate stdout = %q, want missing spell catalog finding", stdout.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestExecuteLocksAddListAndRemoveUseIndependentObjects(t *testing.T) {
|
||||
workspaceRoot := t.TempDir()
|
||||
pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, workspaceRoot)
|
||||
@@ -1273,10 +1218,6 @@ func addExtractionOutputToPipeline(t *testing.T, pipelinePath string) {
|
||||
outputs:
|
||||
encounters:
|
||||
lane_id: encounters
|
||||
media_type: application/json
|
||||
schema_id: encounters
|
||||
schema_version: "1"
|
||||
module_key: encounters
|
||||
`)...)
|
||||
if err := os.WriteFile(pipelinePath, data, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -1289,21 +1230,14 @@ func addExtractionOutputToPipeline(t *testing.T, pipelinePath string) {
|
||||
func writeOperatorExtractionManifest(t *testing.T, workspaceRoot string) string {
|
||||
t.Helper()
|
||||
paths := artifacts.NewLocalStore(workspaceRoot).SessionPathsFor("sample-campaign", "2026-05-03")
|
||||
bundleRoot := filepath.Join(paths.ArtifactsDir, "notarius", "extract-run-1")
|
||||
lanePath := filepath.Join(bundleRoot, "lanes", "encounters.json")
|
||||
indexPath := filepath.Join(bundleRoot, "index.json")
|
||||
lanePath := filepath.Join(paths.ArtifactsDir, "encounters.json")
|
||||
trimmedPath := filepath.Join(paths.Root, filepath.FromSlash(artifacts.TranscriptPathFinalTrimmed))
|
||||
mustWriteTestFile(t, lanePath, `{"secret":"DO_NOT_PRINT"}`)
|
||||
mustWriteTestFile(t, indexPath, `{"lanes":[]}`)
|
||||
mustWriteTestFile(t, trimmedPath, `{"segments":[]}`)
|
||||
laneChecksum, err := artifacts.SHA256File(lanePath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
indexChecksum, err := artifacts.SHA256File(indexPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := manifest.New("2026-05-03", time.Now().UTC())
|
||||
m.Campaign = "sample-campaign"
|
||||
trimmedChecksum, err := artifacts.SHA256File(trimmedPath)
|
||||
@@ -1322,20 +1256,8 @@ func writeOperatorExtractionManifest(t *testing.T, workspaceRoot string) string
|
||||
}
|
||||
m.Stages["extract"] = &manifest.StageRecord{
|
||||
Name: "extract", Status: manifest.StatusSucceeded,
|
||||
Metadata: map[string]any{
|
||||
"narratio_run_id": "extract-run-1", "bundle_root": bundleRoot,
|
||||
"receipt": map[string]any{"run_id": "notarius-run-1", "pipeline_id": "campaign.extract"},
|
||||
"direct_input": input.Metadata(),
|
||||
},
|
||||
Outputs: []manifest.ArtifactRecord{
|
||||
{
|
||||
Kind: "notarius_lane", SourceID: artifacts.ExtractionArtifactSourceID("encounters"), LocalPath: lanePath,
|
||||
ProducerRunID: "extract-run-1", Checksum: laneChecksum,
|
||||
Contract: &artifactmodel.ContractMetadata{MediaType: "application/json", SchemaID: "encounters", SchemaVersion: "1", ModuleKey: "encounters"},
|
||||
ExternalProvenance: &artifactmodel.ExternalProvenance{System: "notarius", RunID: "notarius-run-1", PipelineID: "campaign.extract", ArtifactID: "encounters"},
|
||||
},
|
||||
{Kind: "notarius_index", LocalPath: indexPath, ProducerRunID: "extract-run-1", Checksum: indexChecksum},
|
||||
},
|
||||
Metadata: map[string]any{"narratio_run_id": "extract-run-1", "completion": map[string]any{"pipeline": "campaign.extract"}, "direct_input": input.Metadata()},
|
||||
Outputs: []manifest.ArtifactRecord{{Kind: "notarius_lane", SourceID: artifacts.ExtractionArtifactSourceID("encounters"), LocalPath: lanePath, ProducerRunID: "extract-run-1", Checksum: laneChecksum, Size: int64(len(`{"secret":"DO_NOT_PRINT"}`)), ExternalProvenance: &artifactmodel.ExternalProvenance{System: "notarius", PipelineID: "campaign.extract", ArtifactID: "encounters"}}},
|
||||
}
|
||||
if err := (&manifest.LocalStore{}).Save(context.Background(), paths.ManifestPath, m); err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func TestInspectStableInputsRejectsSpellCatalogFIFO(t *testing.T) {
|
||||
func TestInspectStableInputsRejectsSpeakersFIFO(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
sourcePath := filepath.Join(root, "spells.fifo")
|
||||
if err := unix.Mkfifo(sourcePath, 0o644); err != nil {
|
||||
@@ -19,16 +19,16 @@ func TestInspectStableInputsRejectsSpellCatalogFIFO(t *testing.T) {
|
||||
}
|
||||
|
||||
cfg := &config.Config{StableInputs: config.ResolvedStableInputs{
|
||||
SpellCatalogFile: config.ResolvedInputFile{Path: sourcePath, ConfigPath: filepath.Join(root, "campaign.yml")},
|
||||
SpeakersFile: config.ResolvedInputFile{Path: sourcePath, ConfigPath: filepath.Join(root, "campaign.yml")},
|
||||
}}
|
||||
for _, check := range inspectStableInputs(cfg) {
|
||||
if check.Name != "spell_catalog" {
|
||||
if check.Name != "speakers" {
|
||||
continue
|
||||
}
|
||||
if check.Err == nil || !strings.Contains(check.Err.Error(), "not a regular file") {
|
||||
t.Fatalf("spell catalog check = %#v, want regular-file rejection", check)
|
||||
t.Fatalf("speakers check = %#v, want regular-file rejection", check)
|
||||
}
|
||||
return
|
||||
}
|
||||
t.Fatal("spell catalog inspection result was not reported")
|
||||
t.Fatal("speakers inspection result was not reported")
|
||||
}
|
||||
|
||||
@@ -170,7 +170,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(pipelinePath, []byte(pipelineYAML), 0o644); err != nil {
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
pipelinePath, campaignPath, sessionPath := writeValidConfigFiles(t, t.TempDir())
|
||||
mustWriteTestFile(t, filepath.Join(filepath.Dir(campaignPath), "glossary.yml"), "campaign: {entries: [{id: watch, name: Watch, category: organization}]}\n")
|
||||
mustWriteTestFile(t, filepath.Join(filepath.Dir(campaignPath), "glossary.yml"), "schema_version: maximumdirect.glossary.v1\ncollections:\n campaign: {entries: [{id: watch, name: Watch, category: organization}]}\n")
|
||||
fragment := filepath.Join(filepath.Dir(sessionPath), "fragment.yml")
|
||||
mustWriteTestFile(t, sessionPath, "config:\n imports:\n - path: fragment.yml\nsession_id: 2026-05-03\n")
|
||||
mustWriteTestFile(t, fragment, "title: Published title\ninputs: {audio_dir: audio}\n")
|
||||
@@ -117,7 +117,7 @@ func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
||||
}
|
||||
prefix := artifacts.S3SessionPrefix("dnd", m.Campaign, m.SessionID)
|
||||
key := artifacts.S3RunRelativeDestinationKey(artifacts.S3RunPrefix(prefix, m.RunID), "prepare/inputs/session.yml")
|
||||
if got := string(fake.Objects[key].Data); !strings.Contains(got, "Published title") || strings.Contains(got, "imports:") || strings.Contains(got, "speakers_file:") {
|
||||
if got := string(fake.Objects[key].Data); !strings.Contains(got, "Published title") || strings.Contains(got, "imports:") {
|
||||
t.Fatalf("published session = %q", got)
|
||||
}
|
||||
for _, name := range []string{"campaign.yml", "party.yml", "glossaries/party.yml", "glossaries/campaign.yml", "glossaries/setting.yml", "glossaries/spells.yml"} {
|
||||
@@ -137,8 +137,8 @@ func TestPreparedSessionPublishAndRemoteLoad(t *testing.T) {
|
||||
if received.Session.Title != "Published title" || received.SessionSource.S3Key != key {
|
||||
t.Fatalf("remote session = %#v, source=%#v", received.Session, received.SessionSource)
|
||||
}
|
||||
if got := received.StableInputs.SpeakersFile; got.Source != "campaign_config" || got.Path != filepath.Join(filepath.Dir(campaignPath), "speakers.yml") {
|
||||
t.Fatalf("receiving campaign speakers = %#v", got)
|
||||
if got := received.StableInputs.SpeakersFile; got.Source != "session_config" || got.Path != filepath.Join(filepath.Dir(campaignPath), "speakers.yml") {
|
||||
t.Fatalf("receiving session speakers = %#v", got)
|
||||
}
|
||||
current, err := discoverRemoteCurrentState(ctx, received, fake)
|
||||
if err != nil {
|
||||
|
||||
@@ -73,10 +73,6 @@ notarius:
|
||||
outputs:
|
||||
npc_registry:
|
||||
lane_id: npc-registry
|
||||
media_type: application/json
|
||||
schema_id: notarius.dnd.npc_registry
|
||||
schema_version: v1
|
||||
module_key: dnd/npc-registry
|
||||
notification:
|
||||
mode: noop
|
||||
`)
|
||||
@@ -85,7 +81,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`)
|
||||
|
||||
@@ -154,7 +149,7 @@ inputs:
|
||||
}
|
||||
assertNoProviderValues(t, stdout.Bytes(), stderr.Bytes())
|
||||
if err := filepath.WalkDir(workRoot, func(path string, entry os.DirEntry, walkErr error) error {
|
||||
if walkErr != nil || entry.IsDir() {
|
||||
if walkErr != nil || entry.IsDir() || entry.Type()&os.ModeSymlink != 0 {
|
||||
return walkErr
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
@@ -233,6 +228,14 @@ func TestProviderCredentialProcessFixture(t *testing.T) {
|
||||
_, _ = os.Stderr.WriteString(sharedProviderKey + "\n")
|
||||
os.Exit(0)
|
||||
}
|
||||
if args[0] == "pipeline" {
|
||||
_, _ = os.Stdout.WriteString(`{"pipeline":"dnd-session","input":{"module":"synthetic","execution_class":"deterministic"},"chunk":{"module":"synthetic","execution_class":"deterministic"},"output":{"module":"synthetic","execution_class":"deterministic"},"steps":[{"id":"step","lanes":[{"id":"npc-registry","artifact_kind":"synthetic","extract":{"module":"synthetic","execution_class":"deterministic"},"merge":{"module":"synthetic","execution_class":"deterministic"},"normalize":{"module":"synthetic","execution_class":"deterministic"}}]}]}`)
|
||||
os.Exit(0)
|
||||
}
|
||||
if args[0] == "preflight" && appSeriatimFlagValue(args, "--input-file") != "" {
|
||||
_, _ = os.Stdout.WriteString(`{"pipeline":"dnd-session","ready":true,"checks":[]}`)
|
||||
os.Exit(0)
|
||||
}
|
||||
switch args[0] {
|
||||
case "process", "preflight":
|
||||
if os.Getenv(auditaOnlyName) != auditaOnlyKey {
|
||||
@@ -271,18 +274,11 @@ func TestProviderCredentialProcessFixture(t *testing.T) {
|
||||
if err := os.MkdirAll(filepath.Join(bundle, "lanes"), 0o755); err != nil {
|
||||
os.Exit(2)
|
||||
}
|
||||
for name, value := range map[string]string{
|
||||
"manifest.json": "{}", "rejected.json": `{"rejected":[]}`,
|
||||
"warnings.json": `{"schema_version":"notarius.warnings.v2","group_count":0,"occurrence_count":0,"groups":[]}`,
|
||||
"diagnostics.json": `{"schema_version":"notarius.diagnostics.v1","group_count":0,"occurrence_count":0,"truncated":false,"unrepresented_occurrence_count":0,"groups":[]}`,
|
||||
"lanes/npc.json": `{"records":[]}`,
|
||||
"index.json": `{"manifest_file":"manifest.json","output_files":[{"lane_id":"npc-registry","file":"lanes/npc.json","media_type":"application/json","module_key":"dnd/npc-registry","schema_id":"notarius.dnd.npc_registry","schema_version":"v1"}],"rejected_file":"rejected.json","warnings_file":"warnings.json","diagnostics_file":"diagnostics.json"}`,
|
||||
} {
|
||||
if err := os.WriteFile(filepath.Join(bundle, filepath.FromSlash(name)), []byte(value), 0o644); err != nil {
|
||||
os.Exit(2)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(bundle, "lanes", "npc-registry.json"), []byte(`{"records":[]}`), 0o644); err != nil {
|
||||
os.Exit(2)
|
||||
}
|
||||
_, _ = os.Stdout.WriteString(fmt.Sprintf(`{"schema_version":"notarius.run-result.v2","run_id":"fixture-run","pipeline_id":"dnd-session","output_directory":%q,"index_file":"index.json","normalized_output_count":1,"rejected_output_count":0,"warning_group_count":0,"warning_occurrence_count":0,"diagnostic_group_count":0,"diagnostic_occurrence_count":0,"diagnostics_truncated":false,"validation_status":"approved"}`, bundle))
|
||||
_, _ = fmt.Fprintf(os.Stdout, `{"pipeline":"dnd-session","artifact_count":1,"output_directory":%q}`, bundle)
|
||||
|
||||
default:
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
@@ -442,6 +442,8 @@ func seedRestoreObject(store *storage.FakeBackend, key string, data []byte) {
|
||||
source := artifacts.ConfiguredArtifactSourceID("test")
|
||||
if destination == artifacts.S3RunSessionManifestKey(sessionPrefix, pointer.RunID) {
|
||||
typeID, source = artifacts.RemoteArtifactTypeSessionManifest, "session.manifest"
|
||||
} else if strings.HasSuffix(destination, "/published/transcripts/final.trimmed.json") {
|
||||
source = artifacts.ArtifactTranscriptFinalTrimmed
|
||||
} else if relative := strings.TrimPrefix(destination, runPrefix); strings.HasPrefix(relative, "artifacts/") || strings.HasPrefix(relative, "published/artifacts/") {
|
||||
name := strings.TrimPrefix(relative, "published/")
|
||||
name = strings.TrimSuffix(strings.TrimPrefix(name, "artifacts/"), filepath.Ext(name))
|
||||
|
||||
@@ -3,9 +3,9 @@ package app
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -24,7 +24,7 @@ func TestRestoreThenForcedAnalyzeUsesRestoredDurableState(t *testing.T) {
|
||||
cfg, sessionPrefix, manifestKey, runIDKey := seedRestoreCommittedState(t, fake, pipelinePath, campaignPath, sessionPath)
|
||||
seedRestoreObject(fake, runIDKey, []byte("20260519T010203Z-a1b2c3d4\n"))
|
||||
seedRestoreObject(fake, manifestKey, restoreWorkflowManifestJSON(t, cfg.Session.SessionID, cfg.Session.Campaign))
|
||||
seedRestoreObject(fake, sessionPrefix+"transcripts/full.json", []byte(`{"segments":[1,2,3]}`+"\n"))
|
||||
seedRestoreObject(fake, sessionPrefix+"transcripts/final.trimmed.json", []byte(`{"segments":[]}`+"\n"))
|
||||
seedRestoreObject(fake, sessionPrefix+"artifacts/session_recap.md", []byte("# restored recap\n"))
|
||||
|
||||
executeRestore := restoreCommandExecutor(fake)
|
||||
@@ -56,7 +56,7 @@ func TestRestoreThenForcedAnalyzeUsesRestoredDurableState(t *testing.T) {
|
||||
}
|
||||
|
||||
sessionRoot := artifacts.SessionWorkDirForCampaign(workspaceRoot, cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
mustReadEquals(t, filepath.Join(sessionRoot, "transcripts", "full.json"), `{"segments":[1,2,3]}`+"\n")
|
||||
mustReadEquals(t, filepath.Join(sessionRoot, "transcripts", "final.trimmed.json"), `{"segments":[]}`+"\n")
|
||||
mustReadEquals(t, filepath.Join(sessionRoot, "artifacts", "session_recap.md"), "# restored recap\n")
|
||||
|
||||
manifestStore := &manifest.LocalStore{}
|
||||
@@ -188,18 +188,19 @@ previous_session_id: 2026-04-26
|
||||
t.Fatalf("load restored manifest: %v", err)
|
||||
}
|
||||
setCurrentBuiltInEvidence(t, localManifest, "trim", artifacts.TranscriptOutputKindFinalTrimmed, artifacts.ArtifactTranscriptFinalTrimmed, filepath.Join(sessionRoot, "transcripts", "final.trimmed.json"))
|
||||
setCurrentPreviousArtifactInput(t, localManifest, filepath.Join(sessionRoot, "previous", "artifacts", "session_recap.md"))
|
||||
setCurrentPreviousArtifactInput(t, localManifest, filepath.Join(sessionRoot, "inputs", "previous", "artifacts", "session_recap.md"))
|
||||
if err := (&manifest.LocalStore{}).Save(context.Background(), filepath.Join(sessionRoot, "manifest.json"), localManifest); err != nil {
|
||||
t.Fatalf("save manifest evidence: %v", err)
|
||||
}
|
||||
previousManifestBytes, err := os.ReadFile(filepath.Join(sessionRoot, "previous", "manifest.json"))
|
||||
previousManifestBytes, err := os.ReadFile(filepath.Join(sessionRoot, "inputs", "previous", "manifest.json"))
|
||||
if err != nil {
|
||||
t.Fatalf("read restored previous manifest: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(previousManifestBytes), `"session_id": "2026-04-26"`) {
|
||||
var previousManifest manifest.Manifest
|
||||
if json.Unmarshal(previousManifestBytes, &previousManifest) != nil || previousManifest.SessionID != "2026-04-26" {
|
||||
t.Fatalf("restored previous manifest = %q, want previous session id", string(previousManifestBytes))
|
||||
}
|
||||
mustReadEquals(t, filepath.Join(sessionRoot, "previous", "artifacts", "session_recap.md"), "# previous recap\n")
|
||||
mustReadEquals(t, filepath.Join(sessionRoot, "inputs", "previous", "artifacts", "session_recap.md"), "# previous recap\n")
|
||||
|
||||
scriptoriumFake := &scriptorium.FakeRunner{}
|
||||
objectStoreConstructed := false
|
||||
@@ -245,7 +246,7 @@ previous_session_id: 2026-04-26
|
||||
if got := req.InputPaths["transcript"]; got != filepath.Join(sessionRoot, "transcripts", "final.trimmed.json") {
|
||||
t.Fatalf("transcript input = %q, want trimmed transcript path", got)
|
||||
}
|
||||
if got := req.InputPaths["previous_recap"]; got != filepath.Join(sessionRoot, "previous", "artifacts", "session_recap.md") {
|
||||
if got := req.InputPaths["previous_recap"]; got != filepath.Join(sessionRoot, "inputs", "previous", "artifacts", "session_recap.md") {
|
||||
t.Fatalf("previous_recap input = %q, want restored previous cache path", got)
|
||||
}
|
||||
}
|
||||
@@ -261,6 +262,10 @@ func restoreWorkflowManifestJSON(t *testing.T, sessionID, campaign string) []byt
|
||||
for i, stageName := range stages {
|
||||
m.MarkStageSucceeded(stageName, now.Add(time.Duration(i+1)*time.Minute), nil)
|
||||
}
|
||||
transcript := filepath.Join(t.TempDir(), "final.trimmed.json")
|
||||
mustWriteTestFile(t, transcript, `{"segments":[]}`+"\n")
|
||||
setCurrentBuiltInEvidence(t, m, "trim", artifacts.TranscriptOutputKindFinalTrimmed, artifacts.ArtifactTranscriptFinalTrimmed, transcript)
|
||||
m.Stages["trim"].Outputs[0].LocalPath = "transcripts/final.trimmed.json"
|
||||
setAppAnalyzeEvidence(m, "session_recap", "artifacts/session_recap.md", []byte("# restored recap\n"))
|
||||
path := filepath.Join(t.TempDir(), "manifest.json")
|
||||
if err := store.Save(context.Background(), path, m); err != nil {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/artifacts"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/manifest"
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/stage"
|
||||
@@ -136,7 +137,11 @@ func TestPlannedStageModelMatchesStageExecution(t *testing.T) {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
at := time.Date(2026, time.May, 3, 12, 0, 0, 0, time.UTC)
|
||||
cfg := testConfig(t)
|
||||
workDir := filepath.Join(t.TempDir(), "run")
|
||||
paths, err := artifacts.NewLocalStore(cfg.Pipeline.Workspace.Root).EnsureLayoutFor(cfg.Session.Campaign, cfg.Session.SessionID)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
workDir := filepath.Join(paths.RunsDir, "20260503T120000Z-a1b2c3d4")
|
||||
cfg.Pipeline.Notarius = &config.NotariusConfig{Enabled: test.result == nil || test.result.Disposition != stage.StageDispositionSkipped}
|
||||
planned := manifest.New("2026-05-03", at)
|
||||
executed := manifest.New("2026-05-03", at)
|
||||
@@ -164,6 +169,7 @@ func TestPlannedStageModelMatchesStageExecution(t *testing.T) {
|
||||
cfg: cfg,
|
||||
opts: RunOptions{Force: test.force},
|
||||
identity: invocationIdentity{RunID: "20260503T120000Z-a1b2c3d4", LocalWorkDir: workDir},
|
||||
paths: paths,
|
||||
env: &stage.Env{Config: cfg},
|
||||
manifestStore: &manifest.LocalStore{},
|
||||
manifestPath: filepath.Join(t.TempDir(), "manifest.json"),
|
||||
|
||||
@@ -301,16 +301,15 @@ func TestExecuteStagesBindsResolvedConfigToEnvironment(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestExecuteStagesComposesNotariusOnlyForEnabledExtraction(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
cfg.Pipeline.Notarius = &config.NotariusConfig{Enabled: true}
|
||||
cfg, env, _ := extractionLifecycleFixture(t, true)
|
||||
captured := false
|
||||
|
||||
_, err := executeStages(context.Background(), cfg, []stage.Stage{captureNotariusStage{captured: &captured}}, RunOptions{})
|
||||
_, err := executeStages(context.Background(), cfg, []stage.Stage{captureNotariusStage{captured: &captured}}, RunOptions{Env: env})
|
||||
if err != nil {
|
||||
t.Fatalf("executeStages() error = %v", err)
|
||||
}
|
||||
if !captured {
|
||||
t.Fatal("extract stage did not receive the default Notarius runner")
|
||||
t.Fatal("extract stage did not receive the Notarius runner")
|
||||
}
|
||||
|
||||
if needsNotariusForRun(cfg, []stage.Stage{countingStage{name: "analyze", runs: new(int)}}) {
|
||||
@@ -1424,7 +1423,7 @@ func testConfig(t *testing.T) *config.Config {
|
||||
mustWriteFile(t, sessionPath, "session_id: 2026-05-03\ncampaign: sample-campaign\ninputs:\n audio_dir: ./audio\n")
|
||||
mustWriteFile(t, filepath.Join(cfgDir, "speakers.yml"), "alice: alice.flac\n")
|
||||
mustWriteFile(t, filepath.Join(cfgDir, "autocorrect.yml"), "[]\n")
|
||||
mustWriteFile(t, filepath.Join(cfgDir, "glossary.yml"), "campaign: {entries: []}\n")
|
||||
mustWriteFile(t, filepath.Join(cfgDir, "glossary.yml"), "schema_version: maximumdirect.glossary.v1\ncollections:\n campaign: {entries: []}\n")
|
||||
mustWriteFile(t, filepath.Join(cfgDir, "party.yml"), "schema_version: maximumdirect.rpg.party.v1\ncharacters:\n arannis:\n player: {name: Eric}\n character:\n name: Arannis\n classes: [{name: wizard}]\n")
|
||||
mustWriteFile(t, filepath.Join(cfgDir, "audio", "alice.flac"), "audio")
|
||||
partyDocument, err := config.ParseParty([]byte("schema_version: maximumdirect.rpg.party.v1\ncharacters:\n arannis:\n player: {name: Eric}\n character:\n name: Arannis\n classes: [{name: wizard}]\n"))
|
||||
@@ -1452,11 +1451,6 @@ func testConfig(t *testing.T) *config.Config {
|
||||
ConfigPath: campaignPath,
|
||||
Source: "campaign_config",
|
||||
},
|
||||
AutocorrectFile: config.ResolvedInputFile{
|
||||
Path: "./autocorrect.yml",
|
||||
ConfigPath: campaignPath,
|
||||
Source: "campaign_config",
|
||||
},
|
||||
GlossaryFile: config.ResolvedInputFile{
|
||||
Path: "./glossary.yml",
|
||||
ConfigPath: campaignPath,
|
||||
@@ -1472,10 +1466,9 @@ func testConfig(t *testing.T) *config.Config {
|
||||
SessionID: "2026-05-03",
|
||||
Campaign: "sample-campaign",
|
||||
Inputs: config.SessionInputsConfig{
|
||||
AudioDir: "./audio",
|
||||
SpeakersFile: "./speakers.yml",
|
||||
AutocorrectFile: "./autocorrect.yml",
|
||||
GlossaryFile: new(filepath.Join(cfgDir, "glossary.yml")),
|
||||
AudioDir: "./audio",
|
||||
SpeakersFile: "./speakers.yml",
|
||||
GlossaryFile: new(filepath.Join(cfgDir, "glossary.yml")),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1493,19 +1486,19 @@ whisperx:
|
||||
notification:
|
||||
mode: noop
|
||||
`
|
||||
campaignYAML := `campaign_id: sample-campaign
|
||||
inputs:
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
party_file: ./party.yml
|
||||
campaignYAML := `schema_version: maximumdirect.rpg.campaign.v1
|
||||
id: sample-campaign
|
||||
references: {party: ./party.yml}
|
||||
narratio:
|
||||
inputs:
|
||||
speakers_file: ./speakers.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
sessionYAML := `session_id: 2026-05-03
|
||||
campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
mustWriteFile(t, pipelinePath, pipelineYAML)
|
||||
|
||||
@@ -498,9 +498,16 @@ func TestOldPolishSemanticEvidenceIsReconsideredOnlyWhenSelected(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeliverySemanticChangesInvalidateOnlyTheirFixedDependents(t *testing.T) {
|
||||
t.Run("extract contract", func(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
t.Run("extract pipeline", func(t *testing.T) {
|
||||
cfg, env, runner := extractionLifecycleFixture(t, true)
|
||||
original := cfg.Pipeline.Notarius
|
||||
configureDeliverySemanticConfig(cfg)
|
||||
cfg.Pipeline.Notarius.Binary = original.Binary
|
||||
cfg.Pipeline.Notarius.ConfigPath = original.ConfigPath
|
||||
cfg.Pipeline.Notarius.WorkingDirectory = original.WorkingDirectory
|
||||
cfg.Pipeline.Notarius.Timeout = original.Timeout
|
||||
cfg.Pipeline.Notarius.References = nil
|
||||
runner.cfg = cfg.Pipeline.Notarius
|
||||
provider := canonicalSemanticProvider(t, "extract")
|
||||
seed := manifest.New(cfg.Session.SessionID, time.Now().UTC())
|
||||
for _, name := range []string{"render", "extract", "analyze", "publish", "notify"} {
|
||||
@@ -518,7 +525,7 @@ func TestDeliverySemanticChangesInvalidateOnlyTheirFixedDependents(t *testing.T)
|
||||
cfg.Pipeline.Notarius.PipelineID = "session-v2"
|
||||
runs := 0
|
||||
selected := semanticContractRunStub{name: "extract", provider: provider, runs: &runs}
|
||||
if _, err := executeStages(context.Background(), cfg, []stage.Stage{selected}, RunOptions{}); err != nil {
|
||||
if _, err := executeStages(context.Background(), cfg, []stage.Stage{selected}, RunOptions{Env: env}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
loaded, err := store.Load(context.Background(), manifestPathFor(cfg))
|
||||
@@ -594,7 +601,7 @@ func configureDeliverySemanticConfig(cfg *config.Config) {
|
||||
Enabled: true, PipelineID: "session",
|
||||
References: map[string]string{"party": "narratio.input.party"},
|
||||
Outputs: map[string]config.NotariusOutputConfig{
|
||||
"encounters": {LaneID: "encounters", MediaType: "application/json", SchemaID: "encounters", SchemaVersion: "1"},
|
||||
"encounters": {LaneID: "encounters"},
|
||||
},
|
||||
}
|
||||
cfg.Pipeline.Publish = &config.PublishConfig{
|
||||
|
||||
@@ -20,7 +20,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(sessionPath, []byte(sessionTemplate), 0o644); err != nil {
|
||||
@@ -72,7 +71,6 @@ campaign: sample-campaign
|
||||
inputs:
|
||||
audio_dir: ./audio
|
||||
speakers_file: ./speakers.yml
|
||||
autocorrect_file: ./autocorrect.yml
|
||||
glossary_file: ./glossary.yml
|
||||
`
|
||||
if err := os.WriteFile(sessionPath, []byte(sessionYAML), 0o644); err != nil {
|
||||
|
||||
@@ -94,8 +94,8 @@ func TestNativeProgressTracksDownloadsConcurrentSpeakersAndReuse(t *testing.T) {
|
||||
t.Fatalf("unexpected repeated work=%v", got)
|
||||
}
|
||||
_, diagnostic = executeProgressCommand(t, app, append([]string{"run", "2026-05-03", "--stage", "prepare", "--force"}, common...))
|
||||
if strings.Count(diagnostic, "reusing cached audio") != 4 || strings.Contains(diagnostic, "downloading audio") || len(store.Downloads) != 4 {
|
||||
t.Fatalf("cache reuse claimed new downloads: %s", diagnostic)
|
||||
if strings.Count(diagnostic, "reusing prepared audio") != 4 || strings.Contains(diagnostic, "downloading audio") || len(store.Downloads) != 4 {
|
||||
t.Fatalf("prepared audio reuse claimed new downloads: %s", diagnostic)
|
||||
}
|
||||
store.SeedObject(storage.FakeObject{Key: prefix + "audio/a.flac", Data: []byte("replacement-audio"), ETag: "new-generation"})
|
||||
cause := errors.New("audio download failed")
|
||||
|
||||
Reference in New Issue
Block a user