|
|
|
@@ -67,8 +67,7 @@ func TestPublishFailsWhenPrerequisiteNotSucceeded(t *testing.T) {
|
|
|
|
func TestPublishUploadsRunFilesPublishedOutputsAndCurrentPointer(t *testing.T) {
|
|
|
|
func TestPublishUploadsRunFilesPublishedOutputsAndCurrentPointer(t *testing.T) {
|
|
|
|
env, m, runRoot := publishFixture(t)
|
|
|
|
env, m, runRoot := publishFixture(t)
|
|
|
|
fake := env.ObjectStore.(*storage.FakeBackend)
|
|
|
|
fake := env.ObjectStore.(*storage.FakeBackend)
|
|
|
|
lanePath := configurePublishExtractionFixture(t, env, m)
|
|
|
|
configurePublishExtractionFixture(t, env, m)
|
|
|
|
durableBundleRoot := filepath.Dir(filepath.Dir(lanePath))
|
|
|
|
|
|
|
|
runBundleRoot := filepath.Join(runRoot, "extract", "notarius-output", "notarius-run-1")
|
|
|
|
runBundleRoot := filepath.Join(runRoot, "extract", "notarius-output", "notarius-run-1")
|
|
|
|
for rel, contents := range map[string]string{
|
|
|
|
for rel, contents := range map[string]string{
|
|
|
|
"index.json": `{"lanes":[]}`,
|
|
|
|
"index.json": `{"lanes":[]}`,
|
|
|
|
@@ -96,11 +95,11 @@ func TestPublishUploadsRunFilesPublishedOutputsAndCurrentPointer(t *testing.T) {
|
|
|
|
sessionPrefix := m.S3SessionPrefix
|
|
|
|
sessionPrefix := m.S3SessionPrefix
|
|
|
|
wantRunUploads := []string{
|
|
|
|
wantRunUploads := []string{
|
|
|
|
"analyze/outputs/artifacts/session_recap.md",
|
|
|
|
"analyze/outputs/artifacts/session_recap.md",
|
|
|
|
"merge/config/seriatim.generated.yml",
|
|
|
|
"merge/logs/seriatim.generated.yml",
|
|
|
|
"prepare/inputs/session.yml",
|
|
|
|
"prepare/inputs/session.yml",
|
|
|
|
"prepare/outputs/audio/speaker.flac",
|
|
|
|
"prepare/outputs/audio/speaker.flac",
|
|
|
|
"logs/audita.stderr.log",
|
|
|
|
"polish/logs/audita.stderr.log",
|
|
|
|
"polish/reports/audita.report.json",
|
|
|
|
"polish/logs/report.json",
|
|
|
|
"transcribe/outputs/transcripts/raw/speaker.json",
|
|
|
|
"transcribe/outputs/transcripts/raw/speaker.json",
|
|
|
|
"trim/outputs/transcripts/final.trimmed.json",
|
|
|
|
"trim/outputs/transcripts/final.trimmed.json",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -116,12 +115,6 @@ func TestPublishUploadsRunFilesPublishedOutputsAndCurrentPointer(t *testing.T) {
|
|
|
|
t.Fatalf("run-local Notarius bundle member was uploaded at %q", key)
|
|
|
|
t.Fatalf("run-local Notarius bundle member was uploaded at %q", key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, upload := range fake.Uploads {
|
|
|
|
|
|
|
|
localPath := filepath.Clean(upload.LocalPath)
|
|
|
|
|
|
|
|
if localPath == durableBundleRoot || strings.HasPrefix(localPath, durableBundleRoot+string(filepath.Separator)) {
|
|
|
|
|
|
|
|
t.Fatalf("durable Notarius bundle member was implicitly uploaded from %q", upload.LocalPath)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trimmedKey := publishOutputRemoteKey(runPrefix, "transcripts/final.trimmed.json")
|
|
|
|
trimmedKey := publishOutputRemoteKey(runPrefix, "transcripts/final.trimmed.json")
|
|
|
|
recapKey := publishOutputRemoteKey(runPrefix, "artifacts/session_recap.md")
|
|
|
|
recapKey := publishOutputRemoteKey(runPrefix, "artifacts/session_recap.md")
|
|
|
|
@@ -195,9 +188,9 @@ func TestPublishUploadsPreviousCacheWhenPresent(t *testing.T) {
|
|
|
|
env.Config.Session.Campaign,
|
|
|
|
env.Config.Session.Campaign,
|
|
|
|
env.Config.Session.SessionID,
|
|
|
|
env.Config.Session.SessionID,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
writeStageTestFile(t, filepath.Join(sessionRoot, "previous", "manifest.json"), "{\"session_id\":\"2026-04-12\"}\n")
|
|
|
|
writeStageTestFile(t, filepath.Join(sessionRoot, "inputs", "previous", "manifest.json"), "{\"session_id\":\"2026-04-12\"}\n")
|
|
|
|
writeStageTestFile(t, filepath.Join(sessionRoot, "previous", "artifacts", "session_recap.md"), "# previous recap\n")
|
|
|
|
writeStageTestFile(t, filepath.Join(sessionRoot, "inputs", "previous", "artifacts", "session_recap.md"), "# previous recap\n")
|
|
|
|
writePublishPreviousManifest(t, filepath.Join(sessionRoot, "previous"), "2026-04-12", filepath.Join(sessionRoot, "previous", "artifacts", "session_recap.md"))
|
|
|
|
writePublishPreviousManifest(t, filepath.Join(sessionRoot, "inputs", "previous"), "2026-04-12", filepath.Join(sessionRoot, "inputs", "previous", "artifacts", "session_recap.md"))
|
|
|
|
|
|
|
|
|
|
|
|
result, err := publishStage{}.Run(context.Background(), env, m)
|
|
|
|
result, err := publishStage{}.Run(context.Background(), env, m)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
@@ -233,7 +226,7 @@ func TestPublishRejectsDeclaredLeafSymlinkBeforeUploading(t *testing.T) {
|
|
|
|
env, m, runRoot := publishFixture(t)
|
|
|
|
env, m, runRoot := publishFixture(t)
|
|
|
|
sentinel := filepath.Join(t.TempDir(), "outside.txt")
|
|
|
|
sentinel := filepath.Join(t.TempDir(), "outside.txt")
|
|
|
|
writeStageTestFile(t, sentinel, "outside secret\n")
|
|
|
|
writeStageTestFile(t, sentinel, "outside secret\n")
|
|
|
|
target := filepath.Join(runRoot, "logs", "audita.stderr.log")
|
|
|
|
target := filepath.Join(runRoot, "polish", "logs", "audita.stderr.log")
|
|
|
|
if err := os.Remove(target); err != nil {
|
|
|
|
if err := os.Remove(target); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -269,7 +262,7 @@ func TestPublishRejectsDeclaredSourceWithSymlinkedAncestor(t *testing.T) {
|
|
|
|
env, m, runRoot := publishFixture(t)
|
|
|
|
env, m, runRoot := publishFixture(t)
|
|
|
|
outside := t.TempDir()
|
|
|
|
outside := t.TempDir()
|
|
|
|
writeStageTestFile(t, filepath.Join(outside, "audita.stderr.log"), "outside secret\n")
|
|
|
|
writeStageTestFile(t, filepath.Join(outside, "audita.stderr.log"), "outside secret\n")
|
|
|
|
logsDir := filepath.Join(runRoot, "logs")
|
|
|
|
logsDir := filepath.Join(runRoot, "polish", "logs")
|
|
|
|
if err := os.Rename(logsDir, logsDir+"-original"); err != nil {
|
|
|
|
if err := os.Rename(logsDir, logsDir+"-original"); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -286,7 +279,7 @@ func TestPublishRejectsDeclaredSourceWithSymlinkedAncestor(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
|
|
func TestPublishRejectsDeclaredSourceReplacement(t *testing.T) {
|
|
|
|
func TestPublishRejectsDeclaredSourceReplacement(t *testing.T) {
|
|
|
|
_, m, runRoot := publishFixture(t)
|
|
|
|
_, m, runRoot := publishFixture(t)
|
|
|
|
target := filepath.Join(runRoot, "logs", "audita.stderr.log")
|
|
|
|
target := filepath.Join(runRoot, "polish", "logs", "audita.stderr.log")
|
|
|
|
checksum, err := artifacts.SHA256File(target)
|
|
|
|
checksum, err := artifacts.SHA256File(target)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
@@ -299,14 +292,14 @@ func TestPublishRejectsDeclaredSourceReplacement(t *testing.T) {
|
|
|
|
writeStageTestFile(t, target, "replacement\n")
|
|
|
|
writeStageTestFile(t, target, "replacement\n")
|
|
|
|
|
|
|
|
|
|
|
|
_, err = openPublishRunFiles(runRoot, files)
|
|
|
|
_, err = openPublishRunFiles(runRoot, files)
|
|
|
|
if err == nil || !strings.Contains(err.Error(), `source "logs/audita.stderr.log" does not match its declared checksum`) {
|
|
|
|
if err == nil || !strings.Contains(err.Error(), `source "polish/logs/audita.stderr.log" does not match its declared checksum`) {
|
|
|
|
t.Fatalf("openPublishRunFiles() error = %v, want replacement rejection", err)
|
|
|
|
t.Fatalf("openPublishRunFiles() error = %v, want replacement rejection", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func TestPublishRejectsDeclaredDirectoryBeforeUploading(t *testing.T) {
|
|
|
|
func TestPublishRejectsDeclaredDirectoryBeforeUploading(t *testing.T) {
|
|
|
|
env, m, runRoot := publishFixture(t)
|
|
|
|
env, m, runRoot := publishFixture(t)
|
|
|
|
target := filepath.Join(runRoot, "logs", "audita.stderr.log")
|
|
|
|
target := filepath.Join(runRoot, "polish", "logs", "audita.stderr.log")
|
|
|
|
if err := os.Remove(target); err != nil {
|
|
|
|
if err := os.Remove(target); err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -324,6 +317,11 @@ func TestPublishRejectsDeclaredDirectoryBeforeUploading(t *testing.T) {
|
|
|
|
func TestPublishDoesNotUploadUndeclaredRunFile(t *testing.T) {
|
|
|
|
func TestPublishDoesNotUploadUndeclaredRunFile(t *testing.T) {
|
|
|
|
env, m, runRoot := publishFixture(t)
|
|
|
|
env, m, runRoot := publishFixture(t)
|
|
|
|
writeStageTestFile(t, filepath.Join(runRoot, "unlisted.txt"), "outside of manifest\n")
|
|
|
|
writeStageTestFile(t, filepath.Join(runRoot, "unlisted.txt"), "outside of manifest\n")
|
|
|
|
|
|
|
|
writeStageTestFile(t, filepath.Join(runRoot, "polish", "debug", "capture.json"), "private audita capture\n")
|
|
|
|
|
|
|
|
writeStageTestFile(t, filepath.Join(runRoot, "extract", "debug", "capture.json"), "private notarius capture\n")
|
|
|
|
|
|
|
|
renderDebug := filepath.Join(runRoot, "analyze", "debug", "session_recap.render.json")
|
|
|
|
|
|
|
|
writeStageTestFile(t, renderDebug, `{"rendered":true}`)
|
|
|
|
|
|
|
|
m.Stages["analyze"].Logs = append(m.Stages["analyze"].Logs, renderDebug)
|
|
|
|
paths := artifacts.NewLocalStore(env.Config.Pipeline.Workspace.Root).SessionPathsFor(m.Campaign, m.SessionID)
|
|
|
|
paths := artifacts.NewLocalStore(env.Config.Pipeline.Workspace.Root).SessionPathsFor(m.Campaign, m.SessionID)
|
|
|
|
cacheFile := filepath.Join(artifacts.SessionNotariusReferenceCacheDir(paths), strings.Repeat("a", 64), "party.yml")
|
|
|
|
cacheFile := filepath.Join(artifacts.SessionNotariusReferenceCacheDir(paths), strings.Repeat("a", 64), "party.yml")
|
|
|
|
writeStageTestFile(t, cacheFile, "local Notarius reference cache\n")
|
|
|
|
writeStageTestFile(t, cacheFile, "local Notarius reference cache\n")
|
|
|
|
@@ -335,8 +333,11 @@ func TestPublishDoesNotUploadUndeclaredRunFile(t *testing.T) {
|
|
|
|
if _, exists := fake.Objects[m.S3RunPrefix+"unlisted.txt"]; exists {
|
|
|
|
if _, exists := fake.Objects[m.S3RunPrefix+"unlisted.txt"]; exists {
|
|
|
|
t.Fatal("undeclared run file was uploaded")
|
|
|
|
t.Fatal("undeclared run file was uploaded")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if _, exists := fake.Objects[m.S3RunPrefix+"analyze/debug/session_recap.render.json"]; !exists {
|
|
|
|
|
|
|
|
t.Fatal("declared render diagnostic was not uploaded")
|
|
|
|
|
|
|
|
}
|
|
|
|
for _, object := range fake.Objects {
|
|
|
|
for _, object := range fake.Objects {
|
|
|
|
if strings.Contains(string(object.Data), "outside of manifest") || strings.Contains(string(object.Data), "local Notarius reference cache") {
|
|
|
|
if strings.Contains(string(object.Data), "outside of manifest") || strings.Contains(string(object.Data), "local Notarius reference cache") || strings.Contains(string(object.Data), "private audita capture") || strings.Contains(string(object.Data), "private notarius capture") {
|
|
|
|
t.Fatalf("undeclared or cache bytes were uploaded in %q", object.Key)
|
|
|
|
t.Fatalf("undeclared or cache bytes were uploaded in %q", object.Key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -408,7 +409,7 @@ func TestPublishRejectsDeclaredPreviousSymlinkBeforeUploading(t *testing.T) {
|
|
|
|
env.Config.Session.Campaign,
|
|
|
|
env.Config.Session.Campaign,
|
|
|
|
env.Config.Session.SessionID,
|
|
|
|
env.Config.Session.SessionID,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
config.PathPreviousDirSegment,
|
|
|
|
config.PathInputsDirSegment, config.PathPreviousDirSegment,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
target := filepath.Join(previousDir, "artifacts", "session_recap.md")
|
|
|
|
target := filepath.Join(previousDir, "artifacts", "session_recap.md")
|
|
|
|
sentinel := filepath.Join(t.TempDir(), "outside.md")
|
|
|
|
sentinel := filepath.Join(t.TempDir(), "outside.md")
|
|
|
|
@@ -476,7 +477,6 @@ func TestPublishUploadsExplicitExtractionAndPreservesManifestMetadata(t *testing
|
|
|
|
t.Fatalf("Run() error = %v", err)
|
|
|
|
t.Fatalf("Run() error = %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fake := env.ObjectStore.(*storage.FakeBackend)
|
|
|
|
fake := env.ObjectStore.(*storage.FakeBackend)
|
|
|
|
durableBundleRoot := filepath.Dir(filepath.Dir(lanePath))
|
|
|
|
|
|
|
|
publishedKey := publishOutputRemoteKey(m.S3RunPrefix, "artifacts/encounters.json")
|
|
|
|
publishedKey := publishOutputRemoteKey(m.S3RunPrefix, "artifacts/encounters.json")
|
|
|
|
if got := string(fake.Objects[publishedKey].Data); got != `{"encounters":[]}` {
|
|
|
|
if got := string(fake.Objects[publishedKey].Data); got != `{"encounters":[]}` {
|
|
|
|
t.Fatalf("published extraction = %q", got)
|
|
|
|
t.Fatalf("published extraction = %q", got)
|
|
|
|
@@ -489,12 +489,6 @@ func TestPublishUploadsExplicitExtractionAndPreservesManifestMetadata(t *testing
|
|
|
|
t.Fatalf("Notarius bundle member was implicitly published at %q", key)
|
|
|
|
t.Fatalf("Notarius bundle member was implicitly published at %q", key)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, upload := range fake.Uploads {
|
|
|
|
|
|
|
|
localPath := filepath.Clean(upload.LocalPath)
|
|
|
|
|
|
|
|
if (localPath == durableBundleRoot || strings.HasPrefix(localPath, durableBundleRoot+string(filepath.Separator))) && localPath != filepath.Clean(lanePath) {
|
|
|
|
|
|
|
|
t.Fatalf("durable Notarius bundle member other than selected lane was uploaded from %q", upload.LocalPath)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if result.Metadata["published_files_uploaded"] != 1 {
|
|
|
|
if result.Metadata["published_files_uploaded"] != 1 {
|
|
|
|
t.Fatalf("published_files_uploaded = %#v, want 1", result.Metadata["published_files_uploaded"])
|
|
|
|
t.Fatalf("published_files_uploaded = %#v, want 1", result.Metadata["published_files_uploaded"])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -507,12 +501,11 @@ func TestPublishUploadsExplicitExtractionAndPreservesManifestMetadata(t *testing
|
|
|
|
t.Fatalf("unmarshal committed session manifest: %v", err)
|
|
|
|
t.Fatalf("unmarshal committed session manifest: %v", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
extractRecord := current.Stages["extract"]
|
|
|
|
extractRecord := current.Stages["extract"]
|
|
|
|
if extractRecord == nil || len(extractRecord.Outputs) != 2 {
|
|
|
|
if extractRecord == nil || len(extractRecord.Outputs) != 1 {
|
|
|
|
t.Fatalf("extract record = %#v", extractRecord)
|
|
|
|
t.Fatalf("extract record = %#v", extractRecord)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lane := extractRecord.Outputs[0]
|
|
|
|
lane := extractRecord.Outputs[0]
|
|
|
|
if lane.LocalPath != lanePath || lane.Contract == nil || lane.Contract.SchemaID != "encounters" ||
|
|
|
|
if lane.LocalPath != lanePath || lane.ExternalProvenance == nil || lane.ExternalProvenance.ArtifactID != "encounters" || lane.Size != int64(len(`{"encounters":[]}`)) {
|
|
|
|
lane.ExternalProvenance == nil || lane.ExternalProvenance.RunID != "notarius-run-1" {
|
|
|
|
|
|
|
|
t.Fatalf("serialized extraction metadata = %#v", lane)
|
|
|
|
t.Fatalf("serialized extraction metadata = %#v", lane)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1177,9 +1170,9 @@ func publishFixture(t *testing.T) (*Env, *manifest.Manifest, string) {
|
|
|
|
"transcribe/outputs/transcripts/raw/speaker.json": "{}\n",
|
|
|
|
"transcribe/outputs/transcripts/raw/speaker.json": "{}\n",
|
|
|
|
"trim/outputs/transcripts/final.trimmed.json": "{\"segments\":[]}\n",
|
|
|
|
"trim/outputs/transcripts/final.trimmed.json": "{\"segments\":[]}\n",
|
|
|
|
"analyze/outputs/artifacts/session_recap.md": "# recap\n",
|
|
|
|
"analyze/outputs/artifacts/session_recap.md": "# recap\n",
|
|
|
|
"polish/reports/audita.report.json": "{}\n",
|
|
|
|
"polish/logs/report.json": "{}\n",
|
|
|
|
"merge/config/seriatim.generated.yml": "key: value\n",
|
|
|
|
"merge/logs/seriatim.generated.yml": "key: value\n",
|
|
|
|
"logs/audita.stderr.log": "stderr\n",
|
|
|
|
"polish/logs/audita.stderr.log": "stderr\n",
|
|
|
|
} {
|
|
|
|
} {
|
|
|
|
writeStageTestFile(t, filepath.Join(runRoot, filepath.FromSlash(rel)), contents)
|
|
|
|
writeStageTestFile(t, filepath.Join(runRoot, filepath.FromSlash(rel)), contents)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1246,9 +1239,8 @@ func recordPublishRunDiagnostics(m *manifest.Manifest, runRoot string) {
|
|
|
|
m.Stages["transcribe"].Outputs = []manifest.ArtifactRecord{{LocalPath: filepath.Join(runRoot, "transcribe", "outputs", "transcripts", "raw", "speaker.json")}}
|
|
|
|
m.Stages["transcribe"].Outputs = []manifest.ArtifactRecord{{LocalPath: filepath.Join(runRoot, "transcribe", "outputs", "transcripts", "raw", "speaker.json")}}
|
|
|
|
m.Stages["trim"].Outputs = append(m.Stages["trim"].Outputs, manifest.ArtifactRecord{LocalPath: filepath.Join(runRoot, "trim", "outputs", "transcripts", "final.trimmed.json")})
|
|
|
|
m.Stages["trim"].Outputs = append(m.Stages["trim"].Outputs, manifest.ArtifactRecord{LocalPath: filepath.Join(runRoot, "trim", "outputs", "transcripts", "final.trimmed.json")})
|
|
|
|
m.Stages["analyze"].Outputs = append(m.Stages["analyze"].Outputs, manifest.ArtifactRecord{LocalPath: filepath.Join(runRoot, "analyze", "outputs", "artifacts", "session_recap.md")})
|
|
|
|
m.Stages["analyze"].Outputs = append(m.Stages["analyze"].Outputs, manifest.ArtifactRecord{LocalPath: filepath.Join(runRoot, "analyze", "outputs", "artifacts", "session_recap.md")})
|
|
|
|
m.Stages["polish"].Outputs = []manifest.ArtifactRecord{{LocalPath: filepath.Join(runRoot, "polish", "reports", "audita.report.json")}}
|
|
|
|
m.Stages["polish"].Logs = []string{filepath.Join(runRoot, "polish", "logs", "report.json"), filepath.Join(runRoot, "polish", "logs", "audita.stderr.log")}
|
|
|
|
m.Stages["polish"].Logs = []string{filepath.Join(runRoot, "logs", "audita.stderr.log")}
|
|
|
|
m.Stages["merge"].GeneratedConfigs = []string{filepath.Join(runRoot, "merge", "logs", "seriatim.generated.yml")}
|
|
|
|
m.Stages["merge"].GeneratedConfigs = []string{filepath.Join(runRoot, "merge", "config", "seriatim.generated.yml")}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func writePublishPreviousManifest(t *testing.T, previousDir, sessionID string, archivePaths ...string) {
|
|
|
|
func writePublishPreviousManifest(t *testing.T, previousDir, sessionID string, archivePaths ...string) {
|
|
|
|
@@ -1268,32 +1260,14 @@ func writePublishPreviousManifest(t *testing.T, previousDir, sessionID string, a
|
|
|
|
|
|
|
|
|
|
|
|
func configurePublishExtractionFixture(t *testing.T, env *Env, m *manifest.Manifest) string {
|
|
|
|
func configurePublishExtractionFixture(t *testing.T, env *Env, m *manifest.Manifest) string {
|
|
|
|
t.Helper()
|
|
|
|
t.Helper()
|
|
|
|
env.Config.Pipeline.Notarius = &config.NotariusConfig{
|
|
|
|
env.Config.Pipeline.Notarius = &config.NotariusConfig{Enabled: true, PipelineID: "campaign.extract", Outputs: map[string]config.NotariusOutputConfig{"encounters": {LaneID: "encounters"}}}
|
|
|
|
Enabled: true, PipelineID: "campaign.extract",
|
|
|
|
|
|
|
|
Outputs: map[string]config.NotariusOutputConfig{
|
|
|
|
|
|
|
|
"encounters": {
|
|
|
|
|
|
|
|
LaneID: "encounters", MediaType: "application/json", SchemaID: "encounters",
|
|
|
|
|
|
|
|
SchemaVersion: "1", ModuleKey: "encounters",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
paths := publishSessionPaths(env, m)
|
|
|
|
paths := publishSessionPaths(env, m)
|
|
|
|
producerRunID := "extract-run-1"
|
|
|
|
producerRunID := "extract-run-1"
|
|
|
|
bundleRoot := filepath.Join(paths.ArtifactsDir, "notarius", producerRunID)
|
|
|
|
lanePath := filepath.Join(paths.ArtifactsDir, "encounters.json")
|
|
|
|
lanePath := filepath.Join(bundleRoot, "lanes", "encounters.json")
|
|
|
|
content := `{"encounters":[]}`
|
|
|
|
indexPath := filepath.Join(bundleRoot, "index.json")
|
|
|
|
writeStageTestFile(t, lanePath, content)
|
|
|
|
writeStageTestFile(t, lanePath, `{"encounters":[]}`)
|
|
|
|
writeStageTestFile(t, filepath.Join(paths.Root, "runs", producerRunID, "extract", "notarius-output", "bundle", "manifest.json"), "private bundle")
|
|
|
|
writeStageTestFile(t, indexPath, `{"lanes":[]}`)
|
|
|
|
checksum, err := artifacts.SHA256File(lanePath)
|
|
|
|
writeStageTestFile(t, filepath.Join(bundleRoot, "manifest.json"), `{"run_id":"notarius-run-1"}`)
|
|
|
|
|
|
|
|
writeStageTestFile(t, filepath.Join(bundleRoot, "rejected.json"), `[]`)
|
|
|
|
|
|
|
|
writeStageTestFile(t, filepath.Join(bundleRoot, "warnings.json"), `[]`)
|
|
|
|
|
|
|
|
writeStageTestFile(t, filepath.Join(bundleRoot, "pipeline", "chunk-map.json"), `{"chunks":[]}`)
|
|
|
|
|
|
|
|
writeStageTestFile(t, filepath.Join(bundleRoot, "unknown", "notes.txt"), "internal bundle note\n")
|
|
|
|
|
|
|
|
laneChecksum, err := artifacts.SHA256File(lanePath)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
t.Fatal(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
indexChecksum, err := artifacts.SHA256File(indexPath)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -1303,20 +1277,8 @@ func configurePublishExtractionFixture(t *testing.T, env *Env, m *manifest.Manif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m.Stages["extract"] = &manifest.StageRecord{
|
|
|
|
m.Stages["extract"] = &manifest.StageRecord{
|
|
|
|
Name: "extract", Status: manifest.StatusSucceeded,
|
|
|
|
Name: "extract", Status: manifest.StatusSucceeded,
|
|
|
|
Metadata: map[string]any{
|
|
|
|
Metadata: map[string]any{"narratio_run_id": producerRunID, "completion": map[string]any{"pipeline": "campaign.extract"}, "direct_input": input.Metadata()},
|
|
|
|
"narratio_run_id": producerRunID, "bundle_root": bundleRoot,
|
|
|
|
Outputs: []manifest.ArtifactRecord{{Kind: "notarius_lane", SourceID: artifacts.ExtractionArtifactSourceID("encounters"), LocalPath: lanePath, ProducerRunID: producerRunID, Checksum: checksum, Size: int64(len(content)), ExternalProvenance: &artifactmodel.ExternalProvenance{System: "notarius", PipelineID: "campaign.extract", ArtifactID: "encounters"}}},
|
|
|
|
"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: producerRunID, 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: producerRunID, Checksum: indexChecksum},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lanePath
|
|
|
|
return lanePath
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|