Preserve runtime log evidence verbatim

This commit is contained in:
npc0-hue
2026-09-03 12:40:17 +08:00
parent 8ac45cf999
commit 48dd540253
3 changed files with 16 additions and 22 deletions
+13 -5
View File
@@ -264,7 +264,7 @@ func (executor LifecycleExecutor) runDependencyProbe(ctx context.Context, probe
}
return "missing", "declared executable is not available", nil
}
version := dependencyVersionEvidence(result.Stdout + "\n" + result.Stderr)
version := dependencyVersionEvidence(processOutputEvidence(result.Stdout, result.Stderr))
if probe.MinimumVersion != "" && !dependencyVersionAtLeast(version, probe.MinimumVersion) {
return "missing", "declared executable version is below minimum", nil
}
@@ -450,7 +450,6 @@ func serviceProbeCommand(targetOS, service string) (string, []string) {
}
func dependencySuccess(assignment protocol.RunJobAssignment, input protocol.DependencyExecutionInputResponse, state, evidence string, completed int) LifecycleExecutionResult {
evidence = RedactText(strings.TrimSpace(evidence))
payload, _ := json.Marshal(protocol.DependencyExecutionEvidence{ProbeKey: input.Probe.Key, PlanKey: input.Plan.Key, PlanDigest: input.PlanDigest, State: state, Evidence: evidence, CompletedSteps: completed})
kind := "dependency.check"
message := "dependency probe completed"
@@ -461,6 +460,16 @@ func dependencySuccess(assignment protocol.RunJobAssignment, input protocol.Depe
return LifecycleExecutionResult{State: lifecycleResultStateSucceeded, Progress: protocol.RunJobProgressReport{Percent: 100, Message: message}, ResultRef: fmt.Sprintf("artifact://jobs/%s/dependencies-result", url.PathEscape(assignment.JobID)), Message: message, ExecutionResult: protocol.RunJobExecutionResult{Kind: kind, Checksum: input.PlanDigest, Summary: message, Content: string(payload)}}
}
func processOutputEvidence(stdout string, stderr string) string {
if stdout == "" {
return stderr
}
if stderr == "" {
return stdout
}
return stdout + "\n" + stderr
}
func loadDependencyJournal(path string, assignment protocol.RunJobAssignment, digest string) (dependencyJournal, error) {
journal := dependencyJournal{Version: 1, JobID: assignment.JobID, Attempt: assignment.Attempt, PlanDigest: digest, State: "pending", UpdatedAt: time.Now().UTC()}
body, err := os.ReadFile(path)
@@ -530,11 +539,10 @@ func validSHA256(value string) bool {
}
func dependencyVersionEvidence(output string) string {
lines := splitBoundedLines(output)
if len(lines) == 0 {
if output == "" {
return "version available"
}
return strings.TrimSpace(lines[0])
return output
}
func dependencyVersionAtLeast(actual, minimum string) bool {