Confine publish archive reads

This commit is contained in:
2026-08-10 19:16:18 +00:00
parent 60cebf0e4b
commit 9900211fa4
18 changed files with 655 additions and 152 deletions

View File

@@ -33,6 +33,7 @@ type ArtifactRecord struct {
Kind string `json:"kind"`
SourceID string `json:"source_id,omitempty"`
LocalPath string `json:"local_path"`
ArchivePath string `json:"archive_path,omitempty"`
Contract *artifactmodel.ContractMetadata `json:"contract,omitempty"`
ExternalProvenance *artifactmodel.ExternalProvenance `json:"external_provenance,omitempty"`
// ProducerRunID identifies the run that produced this durable artifact.

View File

@@ -149,18 +149,35 @@ func (s *LocalStore) LoadRun(ctx context.Context, path string) (*RunManifest, er
return nil, fmt.Errorf("load run manifest: path is required")
}
data, err := os.ReadFile(path)
file, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("load run manifest %q: %w", path, err)
}
defer file.Close()
return s.LoadRunReader(ctx, file)
}
// LoadRunReader reads and validates a run manifest from a caller-owned reader.
func (s *LocalStore) LoadRunReader(ctx context.Context, source io.Reader) (*RunManifest, error) {
if err := checkContext(ctx); err != nil {
return nil, err
}
if source == nil {
return nil, fmt.Errorf("load run manifest: source is required")
}
data, err := io.ReadAll(source)
if err != nil {
return nil, fmt.Errorf("read run manifest: %w", err)
}
var m RunManifest
if err := json.Unmarshal(data, &m); err != nil {
return nil, fmt.Errorf("decode run manifest %q: %w", path, err)
return nil, fmt.Errorf("decode run manifest: %w", err)
}
if err := validateLoadedRunManifest(&m); err != nil {
return nil, fmt.Errorf("run manifest %q invalid: %w", path, err)
return nil, fmt.Errorf("run manifest invalid: %w", err)
}
normalizeRunManifest(&m)