Route producer diagnostics to run directories
This commit is contained in:
@@ -603,6 +603,13 @@ directory-write failure. Check that a reused invocation creates no empty run.
|
||||
|
||||
## Stage 16 — Route all producer diagnostics and remaining flat products
|
||||
|
||||
**Complete.** Commit: `Route producer diagnostics to run directories`.
|
||||
Verification: focused artifact and producer-stage tests passed, including multiple
|
||||
render invocations and debug-independent fingerprints; `go test ./... -run '^$'`
|
||||
passed with Go 1.27.4. Broader publication tests still include old previous-cache
|
||||
and extraction fixtures, to be reconciled in the publication, restore, and test
|
||||
cutover stages.
|
||||
|
||||
**Read:** roadmap workspace and diagnostics sections; focused merge, normalize,
|
||||
trim, render, and analyze internals. Entry points: `run_local.go`, those stages,
|
||||
Seriatim/Scriptorium adapters, and render-debug helpers.
|
||||
|
||||
@@ -94,8 +94,6 @@ func (s *LocalStore) ensureLayout(paths SessionPaths) (SessionPaths, error) {
|
||||
paths.TranscriptsDir,
|
||||
paths.TranscriptsRawDir,
|
||||
paths.ArtifactsDir,
|
||||
paths.ReportsDir,
|
||||
paths.ConfigDir,
|
||||
paths.LogsDir,
|
||||
paths.RunsDir,
|
||||
paths.PreviousDir,
|
||||
|
||||
@@ -24,8 +24,6 @@ func TestEnsureLayoutCreatesExpectedDirectories(t *testing.T) {
|
||||
checkDirExists(t, paths.TranscriptsDir)
|
||||
checkDirExists(t, paths.TranscriptsRawDir)
|
||||
checkDirExists(t, paths.ArtifactsDir)
|
||||
checkDirExists(t, paths.ReportsDir)
|
||||
checkDirExists(t, paths.ConfigDir)
|
||||
checkDirExists(t, paths.LogsDir)
|
||||
checkDirExists(t, paths.RunsDir)
|
||||
checkDirExists(t, paths.PreviousDir)
|
||||
|
||||
@@ -133,14 +133,14 @@ func SessionRunExtractDirForCampaign(rootDir, campaign, sessionID, runID string)
|
||||
return SessionRunStageDirForCampaign(rootDir, campaign, sessionID, runID, "extract")
|
||||
}
|
||||
|
||||
// SessionRunNotariusReceiptPathForCampaign returns the invocation-local receipt path.
|
||||
// SessionRunNotariusReceiptPathForCampaign returns the invocation's captured completion report.
|
||||
func SessionRunNotariusReceiptPathForCampaign(rootDir, campaign, sessionID, runID string) string {
|
||||
return filepath.Join(SessionRunExtractDirForCampaign(rootDir, campaign, sessionID, runID), "notarius.receipt.json")
|
||||
return filepath.Join(SessionRunExtractDirForCampaign(rootDir, campaign, sessionID, runID), "logs", "notarius.report.json")
|
||||
}
|
||||
|
||||
// SessionRunNotariusLogPathForCampaign returns the invocation-local stderr log path.
|
||||
func SessionRunNotariusLogPathForCampaign(rootDir, campaign, sessionID, runID string) string {
|
||||
return filepath.Join(SessionRunExtractDirForCampaign(rootDir, campaign, sessionID, runID), "notarius.stderr.log")
|
||||
return filepath.Join(SessionRunExtractDirForCampaign(rootDir, campaign, sessionID, runID), "logs", "notarius.stderr.log")
|
||||
}
|
||||
|
||||
// SessionRunNotariusOutputRootForCampaign returns the invocation-local Notarius output root.
|
||||
|
||||
@@ -82,8 +82,8 @@ func TestSessionNotariusPathsForCampaign(t *testing.T) {
|
||||
want string
|
||||
}{
|
||||
{name: "extract directory", got: SessionRunExtractDirForCampaign(root, campaign, sessionID, runID), want: extractDir},
|
||||
{name: "receipt", got: SessionRunNotariusReceiptPathForCampaign(root, campaign, sessionID, runID), want: filepath.Join(extractDir, "notarius.receipt.json")},
|
||||
{name: "stderr", got: SessionRunNotariusLogPathForCampaign(root, campaign, sessionID, runID), want: filepath.Join(extractDir, "notarius.stderr.log")},
|
||||
{name: "report", got: SessionRunNotariusReceiptPathForCampaign(root, campaign, sessionID, runID), want: filepath.Join(extractDir, "logs", "notarius.report.json")},
|
||||
{name: "stderr", got: SessionRunNotariusLogPathForCampaign(root, campaign, sessionID, runID), want: filepath.Join(extractDir, "logs", "notarius.stderr.log")},
|
||||
{name: "output root", got: SessionRunNotariusOutputRootForCampaign(root, campaign, sessionID, runID), want: filepath.Join(extractDir, "notarius-output")},
|
||||
{name: "durable bundle", got: SessionNotariusBundleDirForCampaign(root, campaign, sessionID, runID), want: filepath.Join(root, "work", campaign, sessionID, "artifacts", "notarius", runID)},
|
||||
}
|
||||
|
||||
@@ -116,18 +116,11 @@ func prepareAnalyzeArtifact(
|
||||
return nil, fmt.Errorf("analyze: resolve run-local output path for artifact %q: %w", artifactName, err)
|
||||
}
|
||||
|
||||
stderrLogPath := filepath.Join(paths.LogsDir, "scriptorium."+artifactName+".stderr.log")
|
||||
generatedConfigPath := filepath.Join(paths.ConfigDir, "scriptorium."+artifactName+".generated.yml")
|
||||
renderOutputPath := filepath.Join(paths.ArtifactsDir, artifactName+".render.json")
|
||||
renderStderrPath := filepath.Join(paths.LogsDir, "scriptorium."+artifactName+".render.stderr.log")
|
||||
renderConfigPath := filepath.Join(paths.ConfigDir, "scriptorium."+artifactName+".render.generated.yml")
|
||||
if runLayout.Enabled {
|
||||
stderrLogPath = filepath.Join(runLayout.LogsDir, "scriptorium."+artifactName+".stderr.log")
|
||||
generatedConfigPath = filepath.Join(runLayout.ConfigDir, "scriptorium."+artifactName+".generated.yml")
|
||||
renderOutputPath = filepath.Join(runLayout.ReportsDir, artifactName+".render.json")
|
||||
renderStderrPath = filepath.Join(runLayout.LogsDir, "scriptorium."+artifactName+".render.stderr.log")
|
||||
renderConfigPath = filepath.Join(runLayout.ConfigDir, "scriptorium."+artifactName+".render.generated.yml")
|
||||
}
|
||||
stderrLogPath := filepath.Join(runLayout.LogsDir, "scriptorium."+artifactName+".stderr.log")
|
||||
generatedConfigPath := filepath.Join(runLayout.LogsDir, "scriptorium."+artifactName+".generated.yml")
|
||||
renderOutputPath := filepath.Join(runLayout.DebugDir, artifactName+".render.json")
|
||||
renderStderrPath := filepath.Join(runLayout.LogsDir, "scriptorium."+artifactName+".render.stderr.log")
|
||||
renderConfigPath := filepath.Join(runLayout.LogsDir, "scriptorium."+artifactName+".render.generated.yml")
|
||||
|
||||
timeout := requestContext.Timeout
|
||||
renderEnabled := resolveRenderDebugEnabled(env.Config.Pipeline.Scriptorium.RenderDebug, artifactCfg.RenderDebug)
|
||||
@@ -212,7 +205,7 @@ func invokeAnalyzeRender(
|
||||
return fmt.Errorf("analyze: render diagnostics %q invalid json: %w", outputPath, err)
|
||||
}
|
||||
|
||||
prepared.logs = append(prepared.logs, prepared.renderStderrPath)
|
||||
prepared.logs = append(prepared.logs, prepared.renderStderrPath, outputPath)
|
||||
prepared.generatedConfigs = append(prepared.generatedConfigs, prepared.renderConfigPath)
|
||||
prepared.metadata["render_output_path"] = outputPath
|
||||
prepared.metadata["render_stderr_log_path"] = prepared.renderStderrPath
|
||||
|
||||
@@ -56,12 +56,11 @@ type analyzeFingerprintPayload struct {
|
||||
}
|
||||
|
||||
type analyzeFingerprintArtifact struct {
|
||||
Key string `json:"key"`
|
||||
PromptID string `json:"prompt_id"`
|
||||
ProfileID string `json:"profile_id"`
|
||||
EffectiveRenderDebug bool `json:"effective_render_debug"`
|
||||
OutputIdentity string `json:"output_identity"`
|
||||
Dependencies []string `json:"dependencies"`
|
||||
Key string `json:"key"`
|
||||
PromptID string `json:"prompt_id"`
|
||||
ProfileID string `json:"profile_id"`
|
||||
OutputIdentity string `json:"output_identity"`
|
||||
Dependencies []string `json:"dependencies"`
|
||||
}
|
||||
|
||||
type analyzeFingerprintInput struct {
|
||||
@@ -165,8 +164,7 @@ func computeAnalyzeArtifactFingerprint(
|
||||
Version: manifest.AnalyzeFingerprintContractVersion,
|
||||
Artifact: analyzeFingerprintArtifact{
|
||||
Key: key, PromptID: artifactCfg.PromptID, ProfileID: artifactCfg.ProfileID,
|
||||
EffectiveRenderDebug: resolveRenderDebugEnabled(scriptoriumCfg.RenderDebug, artifactCfg.RenderDebug),
|
||||
OutputIdentity: outputIdentity, Dependencies: dependencies,
|
||||
OutputIdentity: outputIdentity, Dependencies: dependencies,
|
||||
},
|
||||
Inputs: canonicalAnalyzeFingerprintInputs(inputs.Ordered),
|
||||
DependencyOutputs: canonicalAnalyzeFingerprintDependencies(dependencyOutputs),
|
||||
|
||||
@@ -21,7 +21,6 @@ func TestAnalyzeFingerprintCanonicalPayloadSensitivity(t *testing.T) {
|
||||
{name: "artifact key", mutate: func(p *analyzeFingerprintPayload) { p.Artifact.Key = "other" }},
|
||||
{name: "prompt", mutate: func(p *analyzeFingerprintPayload) { p.Artifact.PromptID = "prompt.changed" }},
|
||||
{name: "profile", mutate: func(p *analyzeFingerprintPayload) { p.Artifact.ProfileID = "profile.changed" }},
|
||||
{name: "render debug", mutate: func(p *analyzeFingerprintPayload) { p.Artifact.EffectiveRenderDebug = !p.Artifact.EffectiveRenderDebug }},
|
||||
{name: "output identity", mutate: func(p *analyzeFingerprintPayload) { p.Artifact.OutputIdentity = "artifacts/changed.md" }},
|
||||
{name: "dependency keys", mutate: func(p *analyzeFingerprintPayload) { p.Artifact.Dependencies[0] = "other" }},
|
||||
{name: "input name", mutate: func(p *analyzeFingerprintPayload) { p.Inputs[0].Name = "other" }},
|
||||
@@ -105,7 +104,6 @@ func TestComputeAnalyzeFingerprintsTracksEffectiveConfiguration(t *testing.T) {
|
||||
}{
|
||||
{name: "prompt", options: fingerprintFixtureOptions{producerRunID: "run-a", dependencyBody: "notes\n", promptID: "prompt.changed"}},
|
||||
{name: "profile", options: fingerprintFixtureOptions{producerRunID: "run-a", dependencyBody: "notes\n", profileID: "profile.changed"}},
|
||||
{name: "render debug", options: fingerprintFixtureOptions{producerRunID: "run-a", dependencyBody: "notes\n", renderDebug: true}},
|
||||
{name: "output", options: fingerprintFixtureOptions{producerRunID: "run-a", dependencyBody: "notes\n", outputPath: "artifacts/changed.md"}},
|
||||
{name: "effective variable", options: fingerprintFixtureOptions{producerRunID: "run-a", dependencyBody: "notes\n", label: "changed"}},
|
||||
{name: "dependency bytes", options: fingerprintFixtureOptions{producerRunID: "run-a", dependencyBody: "other\n"}},
|
||||
@@ -120,6 +118,16 @@ func TestComputeAnalyzeFingerprintsTracksEffectiveConfiguration(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAnalyzeFingerprintIgnoresRenderDebugSelection(t *testing.T) {
|
||||
base := fingerprintFixtureOptions{producerRunID: "run-a", dependencyBody: "notes\n"}
|
||||
before := computeFingerprintFixture(t, base)
|
||||
base.renderDebug = true
|
||||
after := computeFingerprintFixture(t, base)
|
||||
if before != after {
|
||||
t.Fatal("render-debug selection changed product identity")
|
||||
}
|
||||
}
|
||||
|
||||
func TestComputeAnalyzeFingerprintsOrdersDependenciesAndRejectsInvalidGraphs(t *testing.T) {
|
||||
env, m, _ := setupAnalyzeEnv(t)
|
||||
writeAnalyzeFile(t, filepath.Join(sessionPathsForEnv(env, m.SessionID).TranscriptsDir, "final.trimmed.json"), `{"segments":[]}`)
|
||||
@@ -169,8 +177,8 @@ func analyzeFingerprintPayloadFixture() analyzeFingerprintPayload {
|
||||
Version: manifest.AnalyzeFingerprintContractVersion,
|
||||
Artifact: analyzeFingerprintArtifact{
|
||||
Key: "session_recap", PromptID: "dnd.session_recap", ProfileID: "local",
|
||||
EffectiveRenderDebug: true, OutputIdentity: "artifacts/session_recap.md",
|
||||
Dependencies: []string{"source_notes"},
|
||||
OutputIdentity: "artifacts/session_recap.md",
|
||||
Dependencies: []string{"source_notes"},
|
||||
},
|
||||
Inputs: []analyzeFingerprintInput{{
|
||||
Name: "encounters", SourceID: "narratio.extraction.encounters", Required: true, Present: true,
|
||||
|
||||
@@ -52,9 +52,6 @@ func TestResolveAnalyzeInputIdentitiesSupportsEverySourceKind(t *testing.T) {
|
||||
return configureAnalyzeExtractionFixture(t, env, m)["encounters"]
|
||||
},
|
||||
wantOutputKind: "notarius_lane",
|
||||
wantContract: &artifactmodel.ContractMetadata{
|
||||
MediaType: "application/json", SchemaID: "encounters", SchemaVersion: "1", ModuleKey: "encounters",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "previous", sourceID: "narratio.previous_session.artifact.session_recap",
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -55,7 +56,7 @@ func TestAnalyzeGeneratesSessionRecapFromTrimmedTranscript(t *testing.T) {
|
||||
if req.StderrLogPath != filepath.Join(runRoot, "logs", "scriptorium.session_recap.stderr.log") {
|
||||
t.Fatalf("stderr log path = %q", req.StderrLogPath)
|
||||
}
|
||||
if req.GeneratedConfigPath != filepath.Join(runRoot, "config", "scriptorium.session_recap.generated.yml") {
|
||||
if req.GeneratedConfigPath != filepath.Join(runRoot, "logs", "scriptorium.session_recap.generated.yml") {
|
||||
t.Fatalf("generated config path = %q", req.GeneratedConfigPath)
|
||||
}
|
||||
if req.Timeout != 2*time.Minute {
|
||||
@@ -189,11 +190,11 @@ func TestAnalyzeRenderOutputPathIsRecorded(t *testing.T) {
|
||||
runRoot := artifacts.SessionRunStageDirForCampaign(
|
||||
env.Config.Pipeline.Workspace.Root, m.Campaign, m.SessionID, m.RunID, "analyze",
|
||||
)
|
||||
if result.Metadata["render_output_path"] != filepath.Join(runRoot, "reports", "session_recap.render.json") {
|
||||
if result.Metadata["render_output_path"] != filepath.Join(runRoot, "debug", "session_recap.render.json") {
|
||||
t.Fatalf("render_output_path = %#v, want session_recap.render.json path", result.Metadata["render_output_path"])
|
||||
}
|
||||
if len(result.Logs) != 2 || result.Logs[0] != fake.RenderRequests[0].StderrLogPath || result.Logs[1] != fake.RunRequests[0].StderrLogPath {
|
||||
t.Fatalf("logs = %#v, want render and run stderr logs", result.Logs)
|
||||
if len(result.Logs) != 3 || !slices.Contains(result.Logs, fake.RenderRequests[0].StderrLogPath) || !slices.Contains(result.Logs, fake.RenderRequests[0].OutputPath) || !slices.Contains(result.Logs, fake.RunRequests[0].StderrLogPath) {
|
||||
t.Fatalf("logs = %#v, want render evidence and stderr logs", result.Logs)
|
||||
}
|
||||
if len(result.GeneratedConfigs) != 2 {
|
||||
t.Fatalf("generated configs = %#v, want render+run generated configs", result.GeneratedConfigs)
|
||||
@@ -584,6 +585,7 @@ func TestAnalyzeMetadataIncludesGeneratedAndReusedArtifacts(t *testing.T) {
|
||||
|
||||
func TestAnalyzeRunsMultipleIndependentArtifactsInDeterministicOrder(t *testing.T) {
|
||||
env, m, fake := setupAnalyzeEnv(t)
|
||||
env.Config.Pipeline.Scriptorium.RenderDebug = true
|
||||
paths := sessionPathsForEnv(env, m.SessionID)
|
||||
writeAnalyzeFile(t, filepath.Join(paths.TranscriptsDir, "final.trimmed.json"), `{"segments":[]}`)
|
||||
|
||||
@@ -613,6 +615,16 @@ func TestAnalyzeRunsMultipleIndependentArtifactsInDeterministicOrder(t *testing.
|
||||
if fake.RunRequests[1].PromptID != "dnd.session_recap" {
|
||||
t.Fatalf("second prompt id = %q, want dnd.session_recap", fake.RunRequests[1].PromptID)
|
||||
}
|
||||
if len(fake.RenderRequests) != 2 {
|
||||
t.Fatalf("render requests = %d, want 2", len(fake.RenderRequests))
|
||||
}
|
||||
runRoot := artifacts.SessionRunStageDirForCampaign(env.Config.Pipeline.Workspace.Root, m.Campaign, m.SessionID, m.RunID, "analyze")
|
||||
for i, name := range []string{"player_handout", "session_recap"} {
|
||||
want := filepath.Join(runRoot, "debug", name+".render.json")
|
||||
if fake.RenderRequests[i].OutputPath != want || !slices.Contains(result.Logs, want) || !slices.Contains(m.Stages["analyze"].AnalyzeArtifacts[name].Logs, want) {
|
||||
t.Fatalf("render output for %s is not recorded at %s", name, want)
|
||||
}
|
||||
}
|
||||
|
||||
selected, ok := result.Metadata["selected_artifacts"].([]string)
|
||||
if !ok {
|
||||
@@ -1624,8 +1636,8 @@ func configureAnalyzeExtraction(t *testing.T, env *Env) {
|
||||
env.Config.Pipeline.Notarius = &config.NotariusConfig{
|
||||
Enabled: true, PipelineID: "campaign.extract",
|
||||
Outputs: map[string]config.NotariusOutputConfig{
|
||||
"characters": {LaneID: "characters", MediaType: "application/json", SchemaID: "characters", SchemaVersion: "1"},
|
||||
"encounters": {LaneID: "encounters", MediaType: "application/json", SchemaID: "encounters", SchemaVersion: "1", ModuleKey: "encounters"},
|
||||
"characters": {LaneID: "characters"},
|
||||
"encounters": {LaneID: "encounters"},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1635,7 +1647,6 @@ func configureAnalyzeExtractionFixture(t *testing.T, env *Env, m *manifest.Manif
|
||||
configureAnalyzeExtraction(t, env)
|
||||
paths := sessionPathsForEnv(env, m.SessionID)
|
||||
producerRunID := "extract-run-1"
|
||||
bundleRoot := filepath.Join(paths.ArtifactsDir, "notarius", producerRunID)
|
||||
keys := make([]string, 0, len(env.Config.Pipeline.Notarius.Outputs))
|
||||
for key := range env.Config.Pipeline.Notarius.Outputs {
|
||||
keys = append(keys, key)
|
||||
@@ -1643,10 +1654,10 @@ func configureAnalyzeExtractionFixture(t *testing.T, env *Env, m *manifest.Manif
|
||||
sort.Strings(keys)
|
||||
|
||||
outputPaths := make(map[string]string, len(keys))
|
||||
outputs := make([]manifest.ArtifactRecord, 0, len(keys)+1)
|
||||
outputs := make([]manifest.ArtifactRecord, 0, len(keys))
|
||||
for _, key := range keys {
|
||||
definition := env.Config.Pipeline.Notarius.Outputs[key]
|
||||
outputPath := filepath.Join(bundleRoot, "lanes", key+".json")
|
||||
outputPath := filepath.Join(paths.ArtifactsDir, key+".json")
|
||||
writeAnalyzeFile(t, outputPath, `{"items":[]}`)
|
||||
checksum, err := artifacts.SHA256File(outputPath)
|
||||
if err != nil {
|
||||
@@ -1655,35 +1666,22 @@ func configureAnalyzeExtractionFixture(t *testing.T, env *Env, m *manifest.Manif
|
||||
outputPaths[key] = outputPath
|
||||
outputs = append(outputs, manifest.ArtifactRecord{
|
||||
Kind: "notarius_lane", SourceID: artifacts.ExtractionArtifactSourceID(key), LocalPath: outputPath,
|
||||
ProducerRunID: producerRunID, Checksum: checksum,
|
||||
Contract: &artifactmodel.ContractMetadata{
|
||||
MediaType: definition.MediaType, SchemaID: definition.SchemaID,
|
||||
SchemaVersion: definition.SchemaVersion, ModuleKey: definition.ModuleKey,
|
||||
},
|
||||
ProducerRunID: producerRunID, Checksum: checksum, Size: int64(len(`{"items":[]}`)),
|
||||
ExternalProvenance: &artifactmodel.ExternalProvenance{
|
||||
System: "notarius", RunID: "notarius-run-1", PipelineID: "campaign.extract", ArtifactID: definition.LaneID,
|
||||
System: "notarius", PipelineID: "campaign.extract", ArtifactID: definition.LaneID,
|
||||
},
|
||||
})
|
||||
}
|
||||
indexPath := filepath.Join(bundleRoot, "index.json")
|
||||
writeAnalyzeFile(t, indexPath, `{"lanes":[]}`)
|
||||
indexChecksum, err := artifacts.SHA256File(indexPath)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
input, err := artifacts.ResolveExtractionInputIdentity(paths, m)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
outputs = append(outputs, manifest.ArtifactRecord{
|
||||
Kind: "notarius_index", LocalPath: indexPath, ProducerRunID: producerRunID, Checksum: indexChecksum,
|
||||
})
|
||||
m.Stages["extract"] = &manifest.StageRecord{
|
||||
Name: "extract", Status: manifest.StatusSucceeded, Outputs: outputs,
|
||||
Metadata: map[string]any{
|
||||
"narratio_run_id": producerRunID, "bundle_root": bundleRoot,
|
||||
"receipt": map[string]any{"run_id": "notarius-run-1", "pipeline_id": "campaign.extract"},
|
||||
"direct_input": input.Metadata(),
|
||||
"narratio_run_id": producerRunID,
|
||||
"completion": map[string]any{"pipeline": "campaign.extract"},
|
||||
"direct_input": input.Metadata(),
|
||||
},
|
||||
}
|
||||
return outputPaths
|
||||
|
||||
@@ -77,24 +77,12 @@ func (mergeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Sta
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("merge: resolve run-local merged transcript path: %w", err)
|
||||
}
|
||||
canonicalReportPath := filepath.Join(paths.ArtifactsDir, "seriatim.report.json")
|
||||
reportPath := canonicalReportPath
|
||||
if runLayout.Enabled {
|
||||
reportPath, err = runLocalPathForCanonical(runLayout, paths, canonicalReportPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("merge: resolve run-local report path: %w", err)
|
||||
}
|
||||
}
|
||||
stdoutPath := filepath.Join(paths.LogsDir, "seriatim.stdout.log")
|
||||
stderrPath := filepath.Join(paths.LogsDir, "seriatim.stderr.log")
|
||||
genCfgPath := filepath.Join(paths.ConfigDir, "seriatim.generated.yml")
|
||||
if runLayout.Enabled {
|
||||
stdoutPath = filepath.Join(runLayout.LogsDir, "seriatim.stdout.log")
|
||||
stderrPath = filepath.Join(runLayout.LogsDir, "seriatim.stderr.log")
|
||||
genCfgPath = filepath.Join(runLayout.ConfigDir, "seriatim.generated.yml")
|
||||
}
|
||||
reportPath := filepath.Join(runLayout.LogsDir, "seriatim.report.json")
|
||||
stdoutPath := filepath.Join(runLayout.LogsDir, "seriatim.stdout.log")
|
||||
stderrPath := filepath.Join(runLayout.LogsDir, "seriatim.stderr.log")
|
||||
genCfgPath := filepath.Join(runLayout.LogsDir, "seriatim.generated.yml")
|
||||
|
||||
normalizedInputs, normalizeLogs, normalizeConfigs, normalizeMeta, err := normalizeMergeInputs(ctx, env, inputs, paths, runLayout)
|
||||
normalizedInputs, normalizeLogs, normalizeConfigs, normalizeMeta, err := normalizeMergeInputs(ctx, env, inputs, runLayout)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -146,26 +134,11 @@ func (mergeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Sta
|
||||
return nil, fmt.Errorf("merge: materialize canonical base transcript: %w", err)
|
||||
}
|
||||
outputs := []artifacts.Ref{materializedMerged}
|
||||
if reportEnabled {
|
||||
materializedReport, err := materializeRunLocalOutput(env.ArtifactStore, finalReportPath, canonicalReportPath, artifacts.Ref{
|
||||
Kind: "seriatim_report",
|
||||
Category: "artifacts",
|
||||
SessionID: sessionID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("merge: materialize canonical report: %w", err)
|
||||
}
|
||||
outputs = append(outputs, materializedReport)
|
||||
}
|
||||
|
||||
coalesceGap := any(nil)
|
||||
if env.Config.Pipeline.Seriatim.CoalesceGap != nil {
|
||||
coalesceGap = *env.Config.Pipeline.Seriatim.CoalesceGap
|
||||
}
|
||||
reportCanonicalPath := ""
|
||||
if reportEnabled {
|
||||
reportCanonicalPath = canonicalReportPath
|
||||
}
|
||||
|
||||
meta := map[string]any{
|
||||
"stage": "merge",
|
||||
@@ -180,7 +153,7 @@ func (mergeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Sta
|
||||
"run_output_path": finalMergedPath,
|
||||
"output_path": canonicalMergedPath,
|
||||
"run_report_path": finalReportPath,
|
||||
"report_path": reportCanonicalPath,
|
||||
"report_path": finalReportPath,
|
||||
"timeout": env.Config.Pipeline.Seriatim.Timeout,
|
||||
"binary": env.Config.Pipeline.Seriatim.Binary,
|
||||
"adapter_duration_ms": res.Duration.Milliseconds(),
|
||||
@@ -198,9 +171,13 @@ func (mergeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Sta
|
||||
meta["adapter_metadata"] = res.Metadata
|
||||
}
|
||||
|
||||
logs := append(normalizeLogs, stdoutPath, stderrPath)
|
||||
if reportEnabled {
|
||||
logs = append(logs, finalReportPath)
|
||||
}
|
||||
return &StageResult{
|
||||
Outputs: outputs,
|
||||
Logs: append(normalizeLogs, stdoutPath, stderrPath),
|
||||
Logs: logs,
|
||||
GeneratedConfigs: append(normalizeConfigs, genCfgPath),
|
||||
Metadata: meta,
|
||||
}, nil
|
||||
@@ -224,17 +201,13 @@ func normalizeMergeInputs(
|
||||
ctx context.Context,
|
||||
env *Env,
|
||||
rawInputs []string,
|
||||
paths artifacts.SessionPaths,
|
||||
runLayout runStageLayout,
|
||||
) ([]string, []string, []string, []normalizeMergeInputMeta, error) {
|
||||
normalizedInputs := make([]string, 0, len(rawInputs))
|
||||
logs := make([]string, 0, len(rawInputs)*2)
|
||||
configs := make([]string, 0, len(rawInputs))
|
||||
meta := make([]normalizeMergeInputMeta, 0, len(rawInputs))
|
||||
normalizedDir := filepath.Join(paths.TranscriptsRawDir, "normalized")
|
||||
if runLayout.Enabled {
|
||||
normalizedDir = filepath.Join(runLayout.ScratchDir, "normalized")
|
||||
}
|
||||
normalizedDir := filepath.Join(runLayout.ScratchDir, "normalized")
|
||||
if err := fileops.EnsureWorkspaceDirectory(normalizedDir); err != nil {
|
||||
return nil, nil, nil, nil, fmt.Errorf("merge: ensure normalized transcripts directory %q: %w", normalizedDir, err)
|
||||
}
|
||||
@@ -251,14 +224,9 @@ func normalizeMergeInputs(
|
||||
for _, input := range rawInputs {
|
||||
base := strings.TrimSuffix(filepath.Base(input), filepath.Ext(input))
|
||||
outPath := filepath.Join(normalizedDir, base+".normalized.json")
|
||||
stdoutPath := filepath.Join(paths.LogsDir, "seriatim.normalize."+base+".stdout.log")
|
||||
stderrPath := filepath.Join(paths.LogsDir, "seriatim.normalize."+base+".stderr.log")
|
||||
cfgPath := filepath.Join(paths.ConfigDir, "seriatim.normalize."+base+".generated.yml")
|
||||
if runLayout.Enabled {
|
||||
stdoutPath = filepath.Join(runLayout.LogsDir, "seriatim.normalize."+base+".stdout.log")
|
||||
stderrPath = filepath.Join(runLayout.LogsDir, "seriatim.normalize."+base+".stderr.log")
|
||||
cfgPath = filepath.Join(runLayout.ConfigDir, "seriatim.normalize."+base+".generated.yml")
|
||||
}
|
||||
stdoutPath := filepath.Join(runLayout.LogsDir, "seriatim.normalize."+base+".stdout.log")
|
||||
stderrPath := filepath.Join(runLayout.LogsDir, "seriatim.normalize."+base+".stderr.log")
|
||||
cfgPath := filepath.Join(runLayout.LogsDir, "seriatim.normalize."+base+".generated.yml")
|
||||
|
||||
req := seriatim.NormalizeRequest{
|
||||
Binary: env.Config.Pipeline.Seriatim.Binary,
|
||||
|
||||
@@ -79,22 +79,19 @@ func TestMergeStageMergesRawTranscriptsAndRecordsMetadata(t *testing.T) {
|
||||
t.Fatalf("normalize request inputs = %#v", fake.NormalizeRequests)
|
||||
}
|
||||
for _, mergeIn := range req.InputTranscriptPaths {
|
||||
if !strings.Contains(mergeIn, filepath.Join("transcripts", "raw", "normalized")) {
|
||||
if !strings.Contains(mergeIn, filepath.Join("scratch", "normalized")) {
|
||||
t.Fatalf("merge input path = %q, want normalized input path", mergeIn)
|
||||
}
|
||||
}
|
||||
|
||||
if len(result.Outputs) != 2 {
|
||||
t.Fatalf("outputs len = %d, want 2", len(result.Outputs))
|
||||
if len(result.Outputs) != 1 {
|
||||
t.Fatalf("outputs len = %d, want transcript only", len(result.Outputs))
|
||||
}
|
||||
if result.Outputs[0].Kind != "transcript_base" {
|
||||
t.Fatalf("output[0] kind = %q, want transcript_base", result.Outputs[0].Kind)
|
||||
}
|
||||
if result.Outputs[1].Kind != "seriatim_report" {
|
||||
t.Fatalf("output[1] kind = %q, want seriatim_report", result.Outputs[1].Kind)
|
||||
}
|
||||
if len(result.Logs) != 6 {
|
||||
t.Fatalf("logs = %#v, want 6 paths (4 normalize + 2 merge)", result.Logs)
|
||||
if len(result.Logs) != 7 || !strings.HasSuffix(result.Logs[6], "seriatim.report.json") {
|
||||
t.Fatalf("logs = %#v, want streams and report", result.Logs)
|
||||
}
|
||||
if len(result.GeneratedConfigs) != 3 {
|
||||
t.Fatalf("generated configs = %#v, want 3 paths (2 normalize + 1 merge)", result.GeneratedConfigs)
|
||||
@@ -282,8 +279,8 @@ func TestMergeStageResolvesWorkspaceQualifiedManifestOutputsWithoutDuplication(t
|
||||
if len(got) != 1 {
|
||||
t.Fatalf("input transcript paths = %#v, want len 1", got)
|
||||
}
|
||||
if !strings.Contains(got[0], filepath.Join("transcripts", "raw", "normalized")) {
|
||||
t.Fatalf("resolved transcript path = %q, want normalized path under transcripts/raw/normalized", got[0])
|
||||
if !strings.Contains(got[0], filepath.Join("scratch", "normalized")) {
|
||||
t.Fatalf("resolved transcript path = %q, want normalized staging path", got[0])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -296,7 +293,7 @@ func TestMergeStageCreatesNormalizedRawDirectoryBeforeNormalize(t *testing.T) {
|
||||
writeFile(t, filepath.Join(paths.InputsDir, "speakers.yml"), "match: []\n")
|
||||
writeFile(t, filepath.Join(paths.InputsDir, "autocorrect.yml"), "rules: []\n")
|
||||
|
||||
normalizedDir := filepath.Join(paths.TranscriptsRawDir, "normalized")
|
||||
normalizedDir := filepath.Join(paths.Root, "scratch", "merge", "scratch", "normalized")
|
||||
if err := os.RemoveAll(normalizedDir); err != nil {
|
||||
t.Fatalf("remove normalized dir: %v", err)
|
||||
}
|
||||
@@ -413,8 +410,8 @@ func TestMergeStageResolvesSessionRelativeManifestOutputs(t *testing.T) {
|
||||
if len(got) != 1 {
|
||||
t.Fatalf("input transcript paths = %#v, want len 1", got)
|
||||
}
|
||||
if !strings.Contains(got[0], filepath.Join("transcripts", "raw", "normalized")) {
|
||||
t.Fatalf("resolved transcript path = %q, want normalized path under transcripts/raw/normalized", got[0])
|
||||
if !strings.Contains(got[0], filepath.Join("scratch", "normalized")) {
|
||||
t.Fatalf("resolved transcript path = %q, want normalized staging path", got[0])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,24 +68,12 @@ func (normalizeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (
|
||||
}
|
||||
reportEnabled := normalizeCfg.Report != nil && *normalizeCfg.Report
|
||||
reportPath := ""
|
||||
canonicalReportPath := filepath.Join(paths.ArtifactsDir, "seriatim.normalize.report.json")
|
||||
if reportEnabled {
|
||||
reportPath = canonicalReportPath
|
||||
if runLayout.Enabled {
|
||||
reportPath, err = runLocalPathForCanonical(runLayout, paths, canonicalReportPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("normalize: resolve run-local report path: %w", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
stdoutPath := filepath.Join(paths.LogsDir, "seriatim.normalize.stdout.log")
|
||||
stderrPath := filepath.Join(paths.LogsDir, "seriatim.normalize.stderr.log")
|
||||
generatedConfigPath := filepath.Join(paths.ConfigDir, "seriatim.normalize.generated.yml")
|
||||
if runLayout.Enabled {
|
||||
stdoutPath = filepath.Join(runLayout.LogsDir, "seriatim.normalize.stdout.log")
|
||||
stderrPath = filepath.Join(runLayout.LogsDir, "seriatim.normalize.stderr.log")
|
||||
generatedConfigPath = filepath.Join(runLayout.ConfigDir, "seriatim.normalize.generated.yml")
|
||||
reportPath = filepath.Join(runLayout.LogsDir, "seriatim.normalize.report.json")
|
||||
}
|
||||
stdoutPath := filepath.Join(runLayout.LogsDir, "seriatim.normalize.stdout.log")
|
||||
stderrPath := filepath.Join(runLayout.LogsDir, "seriatim.normalize.stderr.log")
|
||||
generatedConfigPath := filepath.Join(runLayout.LogsDir, "seriatim.normalize.generated.yml")
|
||||
timeout, err := resolveSeriatimStageTimeout(env.Config.Pipeline.Seriatim.Timeout)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("normalize: resolve seriatim timeout: %w", err)
|
||||
@@ -135,21 +123,6 @@ func (normalizeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (
|
||||
return nil, fmt.Errorf("normalize: materialize canonical final transcript: %w", err)
|
||||
}
|
||||
outputs := []artifacts.Ref{materializedNormalized}
|
||||
if reportEnabled {
|
||||
materializedReport, err := materializeRunLocalOutput(env.ArtifactStore, finalReportPath, canonicalReportPath, artifacts.Ref{
|
||||
Kind: "seriatim_normalize_report",
|
||||
Category: "artifacts",
|
||||
SessionID: sessionID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("normalize: materialize canonical report: %w", err)
|
||||
}
|
||||
outputs = append(outputs, materializedReport)
|
||||
}
|
||||
reportCanonicalPath := ""
|
||||
if reportEnabled {
|
||||
reportCanonicalPath = canonicalReportPath
|
||||
}
|
||||
|
||||
meta := map[string]any{
|
||||
"stage": "normalize",
|
||||
@@ -161,7 +134,7 @@ func (normalizeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (
|
||||
"output_schema": normalizeCfg.OutputSchema,
|
||||
"report_enabled": reportEnabled,
|
||||
"run_report_path": finalReportPath,
|
||||
"report_path": reportCanonicalPath,
|
||||
"report_path": finalReportPath,
|
||||
"timeout": env.Config.Pipeline.Seriatim.Timeout,
|
||||
"binary": env.Config.Pipeline.Seriatim.Binary,
|
||||
"stdout_log_path": stdoutPath,
|
||||
@@ -181,9 +154,13 @@ func (normalizeStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (
|
||||
meta["adapter_metadata"] = res.Metadata
|
||||
}
|
||||
|
||||
logs := []string{stdoutPath, stderrPath}
|
||||
if reportEnabled {
|
||||
logs = append(logs, finalReportPath)
|
||||
}
|
||||
return &StageResult{
|
||||
Outputs: outputs,
|
||||
Logs: []string{stdoutPath, stderrPath},
|
||||
Logs: logs,
|
||||
GeneratedConfigs: []string{generatedConfigPath},
|
||||
Metadata: meta,
|
||||
}, nil
|
||||
|
||||
@@ -146,15 +146,12 @@ func TestNormalizeStageRecordsReportLogAndGeneratedConfigRefs(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("normalize.Run() error = %v", err)
|
||||
}
|
||||
if len(result.Outputs) < 2 {
|
||||
t.Fatalf("outputs = %#v, want transcript_final + report", result.Outputs)
|
||||
}
|
||||
if result.Outputs[1].Kind != "seriatim_normalize_report" {
|
||||
t.Fatalf("outputs[1].kind = %q, want seriatim_normalize_report", result.Outputs[1].Kind)
|
||||
if len(result.Outputs) != 1 || result.Outputs[0].Kind != "transcript_final" {
|
||||
t.Fatalf("outputs = %#v, want transcript only", result.Outputs)
|
||||
}
|
||||
logs := strings.Join(result.Logs, "\n")
|
||||
if !strings.Contains(logs, "seriatim.normalize.stdout.log") || !strings.Contains(logs, "seriatim.normalize.stderr.log") {
|
||||
t.Fatalf("logs = %#v, want normalize stdout/stderr", result.Logs)
|
||||
if !strings.Contains(logs, "seriatim.normalize.stdout.log") || !strings.Contains(logs, "seriatim.normalize.stderr.log") || !strings.Contains(logs, "seriatim.normalize.report.json") {
|
||||
t.Fatalf("logs = %#v, want normalize streams and report", result.Logs)
|
||||
}
|
||||
if len(result.GeneratedConfigs) != 1 || !strings.Contains(result.GeneratedConfigs[0], "seriatim.normalize.generated.yml") {
|
||||
t.Fatalf("generated configs = %#v, want seriatim.normalize.generated.yml", result.GeneratedConfigs)
|
||||
|
||||
@@ -66,12 +66,8 @@ func (polishStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*St
|
||||
if !runLayout.Enabled {
|
||||
processedPath = filepath.Join(paths.Root, "scratch", "polish", "polished.json")
|
||||
}
|
||||
logs := paths.LogsDir
|
||||
debug := filepath.Join(paths.Root, "debug", "polish")
|
||||
if runLayout.Enabled {
|
||||
logs = runLayout.LogsDir
|
||||
debug = filepath.Join(runLayout.Root, "debug")
|
||||
}
|
||||
logs := runLayout.LogsDir
|
||||
debug := runLayout.DebugDir
|
||||
req, evidence, err := BuildPolishRequest(paths, m, mergedPath, processedPath, logs, debug)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("polish: %w", err)
|
||||
|
||||
@@ -106,20 +106,12 @@ func (renderStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*St
|
||||
return nil, fmt.Errorf("render: resolve run-local final trimmed markdown output path: %w", err)
|
||||
}
|
||||
|
||||
finalStdoutLogPath := filepath.Join(paths.LogsDir, "seriatim.render.final.stdout.log")
|
||||
finalStderrLogPath := filepath.Join(paths.LogsDir, "seriatim.render.final.stderr.log")
|
||||
finalGeneratedConfigPath := filepath.Join(paths.ConfigDir, "seriatim.render.final.generated.yml")
|
||||
finalTrimmedStdoutLogPath := filepath.Join(paths.LogsDir, "seriatim.render.final_trimmed.stdout.log")
|
||||
finalTrimmedStderrLogPath := filepath.Join(paths.LogsDir, "seriatim.render.final_trimmed.stderr.log")
|
||||
finalTrimmedGeneratedConfigPath := filepath.Join(paths.ConfigDir, "seriatim.render.final_trimmed.generated.yml")
|
||||
if runLayout.Enabled {
|
||||
finalStdoutLogPath = filepath.Join(runLayout.LogsDir, "seriatim.render.final.stdout.log")
|
||||
finalStderrLogPath = filepath.Join(runLayout.LogsDir, "seriatim.render.final.stderr.log")
|
||||
finalGeneratedConfigPath = filepath.Join(runLayout.ConfigDir, "seriatim.render.final.generated.yml")
|
||||
finalTrimmedStdoutLogPath = filepath.Join(runLayout.LogsDir, "seriatim.render.final_trimmed.stdout.log")
|
||||
finalTrimmedStderrLogPath = filepath.Join(runLayout.LogsDir, "seriatim.render.final_trimmed.stderr.log")
|
||||
finalTrimmedGeneratedConfigPath = filepath.Join(runLayout.ConfigDir, "seriatim.render.final_trimmed.generated.yml")
|
||||
}
|
||||
finalStdoutLogPath := filepath.Join(runLayout.LogsDir, "seriatim.render.final.stdout.log")
|
||||
finalStderrLogPath := filepath.Join(runLayout.LogsDir, "seriatim.render.final.stderr.log")
|
||||
finalGeneratedConfigPath := filepath.Join(runLayout.LogsDir, "seriatim.render.final.generated.yml")
|
||||
finalTrimmedStdoutLogPath := filepath.Join(runLayout.LogsDir, "seriatim.render.final_trimmed.stdout.log")
|
||||
finalTrimmedStderrLogPath := filepath.Join(runLayout.LogsDir, "seriatim.render.final_trimmed.stderr.log")
|
||||
finalTrimmedGeneratedConfigPath := filepath.Join(runLayout.LogsDir, "seriatim.render.final_trimmed.generated.yml")
|
||||
|
||||
timeout, err := resolveSeriatimStageTimeout(env.Config.Pipeline.Seriatim.Timeout)
|
||||
if err != nil {
|
||||
|
||||
@@ -17,8 +17,7 @@ type runStageLayout struct {
|
||||
Root string
|
||||
OutputsDir string
|
||||
LogsDir string
|
||||
ReportsDir string
|
||||
ConfigDir string
|
||||
DebugDir string
|
||||
ScratchDir string
|
||||
}
|
||||
|
||||
@@ -48,40 +47,31 @@ func resolveRunStageLayout(
|
||||
campaign = strings.TrimSpace(m.Campaign)
|
||||
}
|
||||
|
||||
// Compatibility fallback for direct stage tests and older call paths
|
||||
// that execute a stage without a run id.
|
||||
if runID == "" || campaign == "" {
|
||||
return runStageLayout{}, nil
|
||||
enabled := runID != "" && campaign != ""
|
||||
root := filepath.Join(sessionPaths.Root, "scratch", stageName)
|
||||
if enabled {
|
||||
if err := artifacts.ValidateSessionIdentity(campaign, sessionID); err != nil {
|
||||
return runStageLayout{}, err
|
||||
}
|
||||
if err := artifacts.ValidateRunIdentity(runID); err != nil {
|
||||
return runStageLayout{}, err
|
||||
}
|
||||
root = artifacts.SessionRunStageDirForCampaign(env.Config.Pipeline.Workspace.Root, campaign, sessionID, runID, stageName)
|
||||
}
|
||||
if err := artifacts.ValidateSessionIdentity(campaign, sessionID); err != nil {
|
||||
return runStageLayout{}, err
|
||||
}
|
||||
if err := artifacts.ValidateRunIdentity(runID); err != nil {
|
||||
return runStageLayout{}, err
|
||||
}
|
||||
|
||||
root := artifacts.SessionRunStageDirForCampaign(
|
||||
env.Config.Pipeline.Workspace.Root,
|
||||
campaign,
|
||||
sessionID,
|
||||
runID,
|
||||
stageName,
|
||||
)
|
||||
logs := filepath.Join(root, "logs")
|
||||
layout := runStageLayout{
|
||||
Enabled: true,
|
||||
Enabled: enabled,
|
||||
Root: root,
|
||||
OutputsDir: filepath.Join(root, "outputs"),
|
||||
LogsDir: filepath.Join(root, "logs"),
|
||||
ReportsDir: filepath.Join(root, "reports"),
|
||||
ConfigDir: filepath.Join(root, "config"),
|
||||
LogsDir: logs,
|
||||
DebugDir: filepath.Join(root, "debug"),
|
||||
ScratchDir: filepath.Join(root, "scratch"),
|
||||
}
|
||||
for _, dir := range []string{
|
||||
layout.Root,
|
||||
layout.OutputsDir,
|
||||
layout.LogsDir,
|
||||
layout.ReportsDir,
|
||||
layout.ConfigDir,
|
||||
layout.DebugDir,
|
||||
layout.ScratchDir,
|
||||
} {
|
||||
if err := fileops.EnsureWorkspaceDirectory(dir); err != nil {
|
||||
|
||||
@@ -122,12 +122,8 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("trim: resolve run-local bounds output path: %w", err)
|
||||
}
|
||||
boundsStderrLogPath := filepath.Join(paths.LogsDir, "scriptorium.bounds.stderr.log")
|
||||
boundsGeneratedConfigPath := filepath.Join(paths.ConfigDir, "scriptorium.bounds.generated.yml")
|
||||
if runLayout.Enabled {
|
||||
boundsStderrLogPath = filepath.Join(runLayout.LogsDir, "scriptorium.bounds.stderr.log")
|
||||
boundsGeneratedConfigPath = filepath.Join(runLayout.ConfigDir, "scriptorium.bounds.generated.yml")
|
||||
}
|
||||
boundsStderrLogPath := filepath.Join(runLayout.LogsDir, "scriptorium.bounds.stderr.log")
|
||||
boundsGeneratedConfigPath := filepath.Join(runLayout.LogsDir, "scriptorium.bounds.generated.yml")
|
||||
requestContext, err := TrimScriptoriumContext(env.Config, sessionID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("trim: resolve bounds request: %w", err)
|
||||
@@ -150,20 +146,13 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
|
||||
|
||||
renderOutputPath := ""
|
||||
if boundsCfg.RenderDebug {
|
||||
canonicalRenderOutputPath, err := resolveScriptoriumOutputPath(paths, boundsCfg.RenderOutputPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("trim: resolve bounds render output path: %w", err)
|
||||
}
|
||||
renderOutputPath, err = runLocalPathForCanonical(runLayout, paths, canonicalRenderOutputPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("trim: resolve run-local bounds render output path: %w", err)
|
||||
}
|
||||
renderStderrLogPath := filepath.Join(paths.LogsDir, "scriptorium.bounds.render.stderr.log")
|
||||
renderGeneratedConfigPath := filepath.Join(paths.ConfigDir, "scriptorium.bounds.render.generated.yml")
|
||||
if runLayout.Enabled {
|
||||
renderStderrLogPath = filepath.Join(runLayout.LogsDir, "scriptorium.bounds.render.stderr.log")
|
||||
renderGeneratedConfigPath = filepath.Join(runLayout.ConfigDir, "scriptorium.bounds.render.generated.yml")
|
||||
filename := filepath.Base(strings.TrimSpace(boundsCfg.RenderOutputPath))
|
||||
if filename == "." || filename == ".." || strings.ContainsAny(filename, `/\\`) {
|
||||
return nil, fmt.Errorf("trim: bounds render output must name a file")
|
||||
}
|
||||
renderOutputPath = filepath.Join(runLayout.DebugDir, filename)
|
||||
renderStderrLogPath := filepath.Join(runLayout.LogsDir, "scriptorium.bounds.render.stderr.log")
|
||||
renderGeneratedConfigPath := filepath.Join(runLayout.LogsDir, "scriptorium.bounds.render.generated.yml")
|
||||
|
||||
renderReq := scriptorium.RenderArtifactRequest{
|
||||
Binary: requestContext.Binary,
|
||||
@@ -196,7 +185,7 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
|
||||
return nil, fmt.Errorf("trim: bounds render diagnostics %q invalid json: %w", finalRenderOutputPath, err)
|
||||
}
|
||||
|
||||
logPaths = append(logPaths, renderStderrLogPath)
|
||||
logPaths = append(logPaths, renderStderrLogPath, finalRenderOutputPath)
|
||||
generatedConfigs = append(generatedConfigs, renderGeneratedConfigPath)
|
||||
metadata["bounds_render_output_path"] = finalRenderOutputPath
|
||||
metadata["bounds_render_stderr_log_path"] = renderStderrLogPath
|
||||
@@ -294,14 +283,9 @@ func (trimStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*Stag
|
||||
return nil, fmt.Errorf("trim: copy normalized transcript to trimmed output: %w", err)
|
||||
}
|
||||
} else {
|
||||
trimStdoutLogPath := filepath.Join(paths.LogsDir, "seriatim.trim.stdout.log")
|
||||
trimStderrLogPath := filepath.Join(paths.LogsDir, "seriatim.trim.stderr.log")
|
||||
trimGeneratedConfigPath := filepath.Join(paths.ConfigDir, "seriatim.trim.generated.yml")
|
||||
if runLayout.Enabled {
|
||||
trimStdoutLogPath = filepath.Join(runLayout.LogsDir, "seriatim.trim.stdout.log")
|
||||
trimStderrLogPath = filepath.Join(runLayout.LogsDir, "seriatim.trim.stderr.log")
|
||||
trimGeneratedConfigPath = filepath.Join(runLayout.ConfigDir, "seriatim.trim.generated.yml")
|
||||
}
|
||||
trimStdoutLogPath := filepath.Join(runLayout.LogsDir, "seriatim.trim.stdout.log")
|
||||
trimStderrLogPath := filepath.Join(runLayout.LogsDir, "seriatim.trim.stderr.log")
|
||||
trimGeneratedConfigPath := filepath.Join(runLayout.LogsDir, "seriatim.trim.generated.yml")
|
||||
trimTimeout, err := resolveSeriatimStageTimeout(env.Config.Pipeline.Seriatim.Timeout)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("trim: resolve seriatim timeout: %w", err)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -118,6 +119,8 @@ func TestTrimStageRecordsLogAndGeneratedConfigRefs(t *testing.T) {
|
||||
|
||||
func TestTrimStageRenderDebugDiagnosticsAreNotStageOutputs(t *testing.T) {
|
||||
env, m, scr, _ := setupTrimEnv(t)
|
||||
env.Config.Session.Campaign = "sample-campaign"
|
||||
m.Campaign, m.RunID = "sample-campaign", "run-debug"
|
||||
env.Config.Pipeline.Scriptorium.Credentials = []configkit.Secret{configkit.SecretEnv("TRIM_PROVIDER_KEY")}
|
||||
paths := sessionPathsForEnv(env, m.SessionID)
|
||||
writeFile(t, filepath.Join(paths.TranscriptsDir, "final.json"), `{"segments":[{"id":1},{"id":2}]}`)
|
||||
@@ -151,8 +154,17 @@ func TestTrimStageRenderDebugDiagnosticsAreNotStageOutputs(t *testing.T) {
|
||||
t.Fatalf("render diagnostics should not be stage outputs: %#v", result.Outputs)
|
||||
}
|
||||
}
|
||||
if result.Metadata["bounds_render_output_path"] == nil {
|
||||
t.Fatalf("bounds_render_output_path metadata missing: %#v", result.Metadata)
|
||||
wantDebug := filepath.Join(paths.RunsDir, m.RunID, "trim", "debug", "session_bounds.render.json")
|
||||
if result.Metadata["bounds_render_output_path"] != wantDebug || scr.RenderRequests[0].OutputPath != wantDebug {
|
||||
t.Fatalf("bounds render diagnostics = %#v, request = %#v", result.Metadata, scr.RenderRequests[0])
|
||||
}
|
||||
if !slices.Contains(result.Logs, wantDebug) {
|
||||
t.Fatalf("render debug is not declared for publication: %#v", result.Logs)
|
||||
}
|
||||
for _, path := range result.GeneratedConfigs {
|
||||
if filepath.Dir(path) != filepath.Join(paths.RunsDir, m.RunID, "trim", "logs") {
|
||||
t.Fatalf("invocation description is outside logs: %q", path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user