Preserve smoke observer failures independently of readiness

This commit is contained in:
2026-11-28 16:10:49 +00:00
parent 33e8309322
commit f4951b9bde
5 changed files with 60 additions and 6 deletions

View File

@@ -62,7 +62,6 @@ func executePreflight(invocation commandkit.Invocation, input pipelineRunInput,
report.Checks = append(report.Checks, preflightCheck{ID: id, Scope: scope, Result: result, Message: message})
}
finish := func(outcome commandkit.Outcome) commandkit.Outcome {
report.Ready = outcome.Status == 0
report.DebugDirectory = capture.Path()
if err := capture.Finalize(report, outcome.Cause); err != nil {
if outcome.Status == 0 {
@@ -200,8 +199,10 @@ func executePreflight(invocation commandkit.Invocation, input pipelineRunInput,
add(string(observation.Kind), scope, "passed", fmt.Sprintf("%s check passed for profile %q.", observation.Kind, observation.ProfileID))
}
}
// Recording failure is independent of a completed diagnostic assessment.
report.Ready = !failedCheck && len(observations) == 2*len(targets.Access)+len(targets.Profiles) && ctx.Err() == nil
if err != nil {
if !failedCheck {
if !failedCheck && !report.Ready {
if capture.Err() != nil {
add("debug", preflightScope{Path: capture.Path()}, "failed", err.Error())
} else {

View File

@@ -122,3 +122,29 @@ func TestPreflightDebugAllocationFailureAndDisable(t *testing.T) {
}
}
}
func TestPreflightCaptureFailureBeforeLastProfileIsNotReady(t *testing.T) {
probe := &runProbe{}
_, config, input, _ := runFixture(t, probe, func(configuration string) string {
return strings.Replace(configuration, "id: inspect-validator\n default_profile: partial", "id: inspect-validator\n default_profile: chosen", 1)
})
root := t.TempDir()
calls := 0
client := captureClient(func(context.Context, promptkit.GenerateRequest) (*promptkit.GenerateResponse, error) {
calls++
if err := os.Mkdir(filepath.Join(root, "inspection", "smoke", "004.json"), 0o700); err != nil {
t.Fatal(err)
}
return &promptkit.GenerateResponse{Content: `{"status":"ok"}`}, nil
})
app, err := NewApplication("test", Options{Registries: runRegistries(t, probe), LLMClient: client, RunIDGenerator: func(time.Time) (string, error) { return "inspection", nil }})
if err != nil {
t.Fatal(err)
}
var out, stderr bytes.Buffer
outcome := app.Execute(context.Background(), []string{"preflight", "demo", "--config", config, "--input-file", input, "--cache", "bypass", "--debug", "--debug-dir", root, "--format", "json"}, commandkit.Streams{Out: &out, Err: &stderr})
var report preflightReport
if err := json.Unmarshal(out.Bytes(), &report); err != nil || report.Ready || outcome.Status == 0 || calls != 1 {
t.Fatalf("outcome=%+v report=%+v error=%v calls=%d", outcome, report, err, calls)
}
}