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

@@ -114,7 +114,23 @@ func (m RemoteCommitManifest) ValidateForSessionPrefix(sessionPrefix string) err
if runPrefix == "" {
return fmt.Errorf("remote commit run prefix is required")
}
publishedDestinations := make(map[string]struct{})
for _, artifact := range m.Artifacts {
if artifact.Type == RemoteArtifactTypePublishedOutput {
identity, err := ParseImmutableRunObjectKey(sessionPrefix, artifact.DestinationKey)
if err != nil {
return fmt.Errorf("remote commit published output destination %q: %w", artifact.DestinationKey, err)
}
effectiveDestination := strings.TrimPrefix(identity.RelativePath, "published/")
if effectiveDestination == "" {
return fmt.Errorf("remote commit published output destination %q is empty", artifact.DestinationKey)
}
if _, duplicate := publishedDestinations[effectiveDestination]; duplicate {
return fmt.Errorf("remote commit declares duplicate published output destination %q", effectiveDestination)
}
publishedDestinations[effectiveDestination] = struct{}{}
continue
}
if !strings.HasPrefix(artifact.DestinationKey, runPrefix) {
return fmt.Errorf("remote commit artifact destination %q is outside immutable run prefix %q", artifact.DestinationKey, runPrefix)
}