Complete safety and transfer remediation verification
This commit is contained in:
@@ -26,10 +26,11 @@ func TestAnalyzeAbsolutePathSharesPortableIdentity(t *testing.T) {
|
||||
if got := m.Stages["analyze"].AnalyzeArtifacts["session_recap"].Output.LocalPath; got != "artifacts/session_recap.md" {
|
||||
t.Fatalf("checkpoint is not portable: %q", got)
|
||||
}
|
||||
catalog, err := buildPublishRuntimeArtifactCatalog(paths, m, env.Config.ConcreteArtifacts(), nil)
|
||||
catalog, err := newPublishArtifactCatalog(env.Config.ConcreteArtifacts(), nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
hydratePublishArtifactCatalog(catalog, paths, m, env.Config.ConcreteArtifacts(), nil, nil)
|
||||
source := artifacts.ConfiguredArtifactSourceID("session_recap")
|
||||
resolved, err := artifacts.ResolveSessionArtifactWithCatalog(paths, m, source, catalog)
|
||||
if err != nil || resolved.Path != item.OutputPath {
|
||||
|
||||
@@ -408,16 +408,6 @@ func (s *preparePreviousCaptureStore) Read(ctx context.Context, key string) (sto
|
||||
return s.delegate.Read(ctx, key)
|
||||
}
|
||||
|
||||
func (s *preparePreviousCaptureStore) Download(ctx context.Context, key, localPath string) error {
|
||||
s.accessKeys = append(s.accessKeys, key)
|
||||
return s.delegate.Download(ctx, key, localPath)
|
||||
}
|
||||
|
||||
func (s *preparePreviousCaptureStore) DownloadTo(ctx context.Context, key string, destination io.Writer) error {
|
||||
s.accessKeys = append(s.accessKeys, key)
|
||||
return storage.DownloadTo(ctx, s.delegate, key, destination)
|
||||
}
|
||||
|
||||
func (s *preparePreviousCaptureStore) Upload(ctx context.Context, localPath, key string, opts storage.UploadOptions) (storage.ObjectInfo, error) {
|
||||
return s.delegate.Upload(ctx, localPath, key, opts)
|
||||
}
|
||||
|
||||
@@ -407,7 +407,7 @@ func TestPrepareStageS3AudioFailures(t *testing.T) {
|
||||
name: "download error",
|
||||
setup: func(_ *Env, _ *manifest.Manifest, fake *storage.FakeBackend) {
|
||||
fake.SeedObject(storage.FakeObject{Key: "dnd/campaigns/forsaken/sessions/2026-05-03/audio/alice.flac", Data: []byte("alice")})
|
||||
fake.DownloadErr = os.ErrPermission
|
||||
fake.ReadErr = os.ErrPermission
|
||||
},
|
||||
wantError: "download s3 audio object",
|
||||
},
|
||||
|
||||
@@ -112,12 +112,7 @@ func (publishStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*S
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("publish: collect previous files: %w", err)
|
||||
}
|
||||
runtimeCatalog, err := buildPublishRuntimeArtifactCatalog(
|
||||
sessionPaths,
|
||||
m,
|
||||
env.Config.ConcreteArtifacts(),
|
||||
env.Config.Pipeline.Notarius,
|
||||
)
|
||||
runtimeCatalog, err := newPublishArtifactCatalog(env.Config.ConcreteArtifacts(), env.Config.Pipeline.Notarius)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("publish: build runtime artifact catalog: %w", err)
|
||||
}
|
||||
@@ -133,6 +128,7 @@ func (publishStage) Run(ctx context.Context, env *Env, m *manifest.Manifest) (*S
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("publish: read publish output locks: %w", err)
|
||||
}
|
||||
hydratePublishArtifactCatalog(runtimeCatalog, sessionPaths, m, env.Config.ConcreteArtifacts(), env.Config.Pipeline.Notarius, initialLocks)
|
||||
var priorCommit *artifacts.RemoteCommitManifest
|
||||
if publishRulesNeedPriorCommit(publishRules, initialLocks) {
|
||||
priorCommit, err = loadPriorPublishCommit(ctx, env.ObjectStore, sessionPrefix, m.Campaign, m.SessionID)
|
||||
|
||||
@@ -172,12 +172,7 @@ func extractionOutputSetFromCatalog(catalog *artifacts.ArtifactCatalog) map[stri
|
||||
return out
|
||||
}
|
||||
|
||||
func buildPublishRuntimeArtifactCatalog(
|
||||
paths artifacts.SessionPaths,
|
||||
m *manifest.Manifest,
|
||||
definitions map[string]config.ScriptoriumArtifactConfig,
|
||||
notariusCfg *config.NotariusConfig,
|
||||
) (*artifacts.ArtifactCatalog, error) {
|
||||
func newPublishArtifactCatalog(definitions map[string]config.ScriptoriumArtifactConfig, notariusCfg *config.NotariusConfig) (*artifacts.ArtifactCatalog, error) {
|
||||
extractionDefinitions := artifacts.ExtractionDefinitionsFromConfig(notariusCfg)
|
||||
configured := artifacts.ConfiguredArtifactDefinitions(definitions)
|
||||
effective, err := artifacts.ResolveEffectiveArtifactSet(configured, nil)
|
||||
@@ -188,11 +183,34 @@ func buildPublishRuntimeArtifactCatalog(
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return catalog, nil
|
||||
}
|
||||
|
||||
func hydratePublishArtifactCatalog(catalog *artifacts.ArtifactCatalog, paths artifacts.SessionPaths, m *manifest.Manifest, definitions map[string]config.ScriptoriumArtifactConfig, notariusCfg *config.NotariusConfig, locks []artifacts.RemoteLock) {
|
||||
excluded := make(map[string]bool, len(locks))
|
||||
for _, lock := range locks {
|
||||
excluded[lock.Source] = true
|
||||
}
|
||||
configured := artifacts.ConfiguredArtifactDefinitions(definitions)
|
||||
for key := range configured {
|
||||
if excluded[artifacts.ConfiguredArtifactSourceID(key)] {
|
||||
delete(configured, key)
|
||||
}
|
||||
}
|
||||
if notariusCfg != nil && notariusCfg.Enabled {
|
||||
catalog.HydrateExtractionArtifacts(paths, m, extractionDefinitions)
|
||||
extraction := artifacts.ExtractionDefinitionsFromConfig(notariusCfg)
|
||||
allExcluded := len(extraction) > 0
|
||||
for key := range extraction {
|
||||
if !excluded[artifacts.ExtractionArtifactSourceID(key)] {
|
||||
allExcluded = false
|
||||
break
|
||||
}
|
||||
}
|
||||
if !allExcluded {
|
||||
catalog.HydrateExtractionArtifactsExcept(paths, m, extraction, excluded)
|
||||
}
|
||||
}
|
||||
catalog.HydrateAnalyzeArtifacts(paths, m, configured)
|
||||
return catalog, nil
|
||||
}
|
||||
|
||||
func publishOutputRemoteKey(runPrefix, destination string) string {
|
||||
|
||||
Reference in New Issue
Block a user