Permit safe cross-run output declarations

This commit is contained in:
2026-09-05 12:37:58 +00:00
parent be59bff690
commit 145baac393
16 changed files with 363 additions and 81 deletions

View File

@@ -155,7 +155,7 @@ func Resolve(
result.SkippedMissing = append(result.SkippedMissing, requirement.Name)
continue
}
selectedRel, err := publishedOutputRelativePath(previousSessionPrefix, current.RunID, selectedArtifact.DestinationKey)
selectedRel, err := publishedOutputRelativePath(previousSessionPrefix, selectedArtifact.DestinationKey)
if err != nil {
return nil, fmt.Errorf("resolve declared previous-session artifact %q: %w", requirement.Name, err)
}
@@ -209,11 +209,14 @@ func committedPublishedArtifactBySource(commit *artifacts.RemoteCommitManifest,
return artifacts.RemoteArtifact{}, false
}
func publishedOutputRelativePath(sessionPrefix, runID, destinationKey string) (string, error) {
prefix := artifacts.S3RunRelativeDestinationKey(artifacts.S3RunPrefix(sessionPrefix, runID), "published") + "/"
rel, ok := strings.CutPrefix(strings.TrimSpace(destinationKey), prefix)
func publishedOutputRelativePath(sessionPrefix, destinationKey string) (string, error) {
identity, err := artifacts.ParseImmutableRunObjectKey(sessionPrefix, destinationKey)
if err != nil {
return "", err
}
rel, ok := strings.CutPrefix(identity.RelativePath, "published/")
if !ok || strings.TrimSpace(rel) == "" {
return "", fmt.Errorf("destination %q is outside selected run published-output prefix %q", destinationKey, prefix)
return "", fmt.Errorf("destination %q is outside its immutable run published-output prefix", destinationKey)
}
normalized, err := pathsafe.NormalizeRelativeDestination(rel)
if err != nil {