Verify Notarius cache lifecycle boundaries

This commit is contained in:
2026-09-16 17:59:52 +00:00
parent e13d87a077
commit 1b480d4ed5
5 changed files with 161 additions and 4 deletions

View File

@@ -58,9 +58,12 @@ func TestCleanupStageRemovesOnlySelectedPublishedRunTargets(t *testing.T) {
otherSpool := filepath.Join(env.Config.Pipeline.Spool.Root, m.Campaign, m.SessionID, "other-run", "audio")
otherWorkspace := filepath.Join(env.Config.Pipeline.Workspace.Root, "work", m.Campaign, m.SessionID, "runs", "other-run")
cacheFile := filepath.Join(env.Config.Pipeline.Cache.Root, "s3", "audio.cache")
sessionPaths := artifacts.NewLocalStore(env.Config.Pipeline.Workspace.Root).SessionPathsFor(m.Campaign, m.SessionID)
referenceCacheFile := filepath.Join(artifacts.SessionNotariusReferenceCacheDir(sessionPaths), strings.Repeat("a", 64), "party.yml")
writeStageTestFile(t, filepath.Join(otherSpool, "audio.wav"), "other spool")
writeStageTestFile(t, filepath.Join(otherWorkspace, "result.txt"), "other workspace")
writeStageTestFile(t, cacheFile, "cache")
writeStageTestFile(t, referenceCacheFile, "reference cache")
result, err := (cleanupStage{}).Run(context.Background(), env, m)
if err != nil {
@@ -81,7 +84,7 @@ func TestCleanupStageRemovesOnlySelectedPublishedRunTargets(t *testing.T) {
t.Fatalf("unselected workspace target changed: %v", err)
}
}
for _, preserved := range []string{otherSpool, otherWorkspace, cacheFile} {
for _, preserved := range []string{otherSpool, otherWorkspace, cacheFile, referenceCacheFile} {
if _, err := os.Stat(preserved); err != nil {
t.Fatalf("preserved path %q: %v", preserved, err)
}

View File

@@ -324,6 +324,9 @@ func TestPublishRejectsDeclaredDirectoryBeforeUploading(t *testing.T) {
func TestPublishDoesNotUploadUndeclaredRunFile(t *testing.T) {
env, m, runRoot := publishFixture(t)
writeStageTestFile(t, filepath.Join(runRoot, "unlisted.txt"), "outside of manifest\n")
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")
writeStageTestFile(t, cacheFile, "local Notarius reference cache\n")
if _, err := (publishStage{}).Run(context.Background(), env, m); err != nil {
t.Fatalf("Run() error = %v", err)
@@ -333,8 +336,8 @@ func TestPublishDoesNotUploadUndeclaredRunFile(t *testing.T) {
t.Fatal("undeclared run file was uploaded")
}
for _, object := range fake.Objects {
if strings.Contains(string(object.Data), "outside of manifest") {
t.Fatalf("undeclared bytes were uploaded in %q", object.Key)
if strings.Contains(string(object.Data), "outside of manifest") || strings.Contains(string(object.Data), "local Notarius reference cache") {
t.Fatalf("undeclared or cache bytes were uploaded in %q", object.Key)
}
}
}