Index previous publication selections and missing inputs
This commit is contained in:
@@ -594,7 +594,7 @@ Validation: `go test ./internal/app ./internal/preflight ./internal/stage`.
|
||||
|
||||
## Stage 22: Index Previous Publication Selection And Optional Absence
|
||||
|
||||
CAT IDs: CAT-27, remote/reporting parts. Status: Pending.
|
||||
CAT IDs: CAT-27, remote/reporting parts. Status: Complete.
|
||||
|
||||
Read [EF-03](audit/02-efficiency.md#ef-03--p3-previous-session-metadata-is-repeatedly-searched-as-a-list).
|
||||
|
||||
|
||||
@@ -197,12 +197,3 @@ func requireInspectionFile(path, label string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func previousRequirementSkipped(values []string, name string) bool {
|
||||
for _, value := range values {
|
||||
if value == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -202,9 +202,14 @@ func inspectSessionState(ctx context.Context, cfg *config.Config, status, remote
|
||||
fail("artifacts", inputs.requirementsErr)
|
||||
if inputs.effectiveErr == nil && inputs.requirementsErr == nil {
|
||||
fail("previous", inputs.previous.Err)
|
||||
skipped := make(map[string]struct{}, len(inputs.previous.SkippedMissing))
|
||||
for _, name := range inputs.previous.SkippedMissing {
|
||||
skipped[name] = struct{}{}
|
||||
}
|
||||
for _, requirement := range inputs.previous.Requirements {
|
||||
state := "ready"
|
||||
if inputs.previous.Err != nil || previousRequirementSkipped(inputs.previous.SkippedMissing, requirement.Name) {
|
||||
_, missing := skipped[requirement.Name]
|
||||
if inputs.previous.Err != nil || missing {
|
||||
state = "unavailable"
|
||||
}
|
||||
report.Previous = append(report.Previous, sessionPreviousState{Name: requirement.Name, Required: requirement.Required, State: state})
|
||||
|
||||
@@ -116,10 +116,16 @@ func Resolve(
|
||||
return nil, fmt.Errorf("previous-session current state does not include a committed remote declaration")
|
||||
}
|
||||
|
||||
publishedBySource := make(map[string][]artifacts.RemoteArtifact)
|
||||
for _, artifact := range current.Commit.Artifacts {
|
||||
if artifact.Type == artifacts.RemoteArtifactTypePublishedOutput {
|
||||
publishedBySource[artifact.Source] = append(publishedBySource[artifact.Source], artifact)
|
||||
}
|
||||
}
|
||||
for _, requirement := range orderedRequirements {
|
||||
sourceID := previousArtifactSourceID(requirement.Name)
|
||||
selectedArtifact, ok := committedPublishedArtifactBySource(current.Commit, sourceID)
|
||||
if !ok {
|
||||
candidates := publishedBySource[strings.TrimSpace(sourceID)]
|
||||
if len(candidates) == 0 {
|
||||
if requirement.Required {
|
||||
return nil, fmt.Errorf(
|
||||
"required previous-session artifact %q is not declared by the selected remote commit",
|
||||
@@ -129,6 +135,7 @@ func Resolve(
|
||||
result.SkippedMissing = append(result.SkippedMissing, requirement.Name)
|
||||
continue
|
||||
}
|
||||
selectedArtifact := candidates[0]
|
||||
selectedRel, err := publishedOutputRelativePath(previousSessionPrefix, selectedArtifact.DestinationKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resolve declared previous-session artifact %q: %w", requirement.Name, err)
|
||||
@@ -167,22 +174,6 @@ func Resolve(
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func committedPublishedArtifactBySource(commit *artifacts.RemoteCommitManifest, source string) (artifacts.RemoteArtifact, bool) {
|
||||
if commit == nil {
|
||||
return artifacts.RemoteArtifact{}, false
|
||||
}
|
||||
want := strings.TrimSpace(source)
|
||||
if want == "" {
|
||||
return artifacts.RemoteArtifact{}, false
|
||||
}
|
||||
for _, artifact := range commit.Artifacts {
|
||||
if artifact.Type == artifacts.RemoteArtifactTypePublishedOutput && artifact.Source == want {
|
||||
return artifact, true
|
||||
}
|
||||
}
|
||||
return artifacts.RemoteArtifact{}, false
|
||||
}
|
||||
|
||||
func publishedOutputRelativePath(sessionPrefix, destinationKey string) (string, error) {
|
||||
identity, err := artifacts.ParsePublishedOutputObjectKey(sessionPrefix, destinationKey)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user