Preserve smoke observer failures independently of readiness
This commit is contained in:
@@ -29,6 +29,11 @@ guarantees was found. Keep the accepted scope unchanged while remediating.
|
|||||||
|
|
||||||
## Finding 1: Preserve Smoke Observer Errors Independently Of Readiness
|
## Finding 1: Preserve Smoke Observer Errors Independently Of Readiness
|
||||||
|
|
||||||
|
**Status: Complete.** Observer and diagnostic errors are joined consistently;
|
||||||
|
readiness now follows completed native checks independently of recording failure.
|
||||||
|
Focused smoke/preflight tests pass, including final/combined failures and stopping
|
||||||
|
before an unchecked profile.
|
||||||
|
|
||||||
**Priority:** P2 — error handling and separation of responsibilities.
|
**Priority:** P2 — error handling and separation of responsibilities.
|
||||||
|
|
||||||
**Affected owners:**
|
**Affected owners:**
|
||||||
|
|||||||
@@ -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})
|
report.Checks = append(report.Checks, preflightCheck{ID: id, Scope: scope, Result: result, Message: message})
|
||||||
}
|
}
|
||||||
finish := func(outcome commandkit.Outcome) commandkit.Outcome {
|
finish := func(outcome commandkit.Outcome) commandkit.Outcome {
|
||||||
report.Ready = outcome.Status == 0
|
|
||||||
report.DebugDirectory = capture.Path()
|
report.DebugDirectory = capture.Path()
|
||||||
if err := capture.Finalize(report, outcome.Cause); err != nil {
|
if err := capture.Finalize(report, outcome.Cause); err != nil {
|
||||||
if outcome.Status == 0 {
|
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))
|
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 err != nil {
|
||||||
if !failedCheck {
|
if !failedCheck && !report.Ready {
|
||||||
if capture.Err() != nil {
|
if capture.Err() != nil {
|
||||||
add("debug", preflightScope{Path: capture.Path()}, "failed", err.Error())
|
add("debug", preflightScope{Path: capture.Path()}, "failed", err.Error())
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -34,16 +34,13 @@ func RunSmokeChecksObserved(ctx context.Context, engine *promptkit.Engine, targe
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var observations []SmokeObservation
|
var observations []SmokeObservation
|
||||||
total := 2*len(targets.Access) + len(targets.Profiles)
|
|
||||||
run := func(kind promptkit.SmokeTestKind, profile, backend string, bindings []BindingScope) error {
|
run := func(kind promptkit.SmokeTestKind, profile, backend string, bindings []BindingScope) error {
|
||||||
report, err := engine.SmokeTest(ctx, promptkit.SmokeTestRequest{Kind: kind, ProfileID: profile, Execution: execution, TransientRetries: retries})
|
report, err := engine.SmokeTest(ctx, promptkit.SmokeTestRequest{Kind: kind, ProfileID: profile, Execution: execution, TransientRetries: retries})
|
||||||
observation := SmokeObservation{Kind: kind, ProfileID: profile, BackendID: backend, Bindings: bindings, Report: report}
|
observation := SmokeObservation{Kind: kind, ProfileID: profile, BackendID: backend, Bindings: bindings, Report: report}
|
||||||
observation.Applicable, observation.Err = evaluateSmoke(kind, report, err)
|
observation.Applicable, observation.Err = evaluateSmoke(kind, report, err)
|
||||||
observations = append(observations, observation)
|
observations = append(observations, observation)
|
||||||
if observe != nil {
|
if observe != nil {
|
||||||
if observeErr := observe(observation); observeErr != nil && observation.Err == nil && len(observations) < total {
|
return errors.Join(observation.Err, observe(observation))
|
||||||
return observeErr
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return observation.Err
|
return observation.Err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,3 +111,28 @@ func TestSmokeCaptureFailureStopsBeforeFurtherChecks(t *testing.T) {
|
|||||||
t.Fatalf("observations=%+v err=%v", observations, err)
|
t.Fatalf("observations=%+v err=%v", observations, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type smokeResultClient struct{ err error }
|
||||||
|
|
||||||
|
func (client smokeResultClient) Generate(context.Context, promptkit.GenerateRequest) (*promptkit.GenerateResponse, error) {
|
||||||
|
return &promptkit.GenerateResponse{Content: `{"status":"ok"}`}, client.err
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSmokeRetainsTerminalObserverAndDiagnosticErrors(t *testing.T) {
|
||||||
|
providerErr := errors.New("provider failed")
|
||||||
|
observerErr := errors.New("observer failed")
|
||||||
|
for _, cause := range []error{nil, providerErr} {
|
||||||
|
input := configkit.Input{Destination: configkit.Keys("promptkit"), Source: configkit.Mapping("smoke", map[string]any{"profiles": []any{map[string]any{"id": "profile", "endpoint": "http://example.invalid/v1", "model": "fixture"}}})}
|
||||||
|
engine, err := promptkit.NewEngine(promptkit.Config{Sources: promptkit.ConfigurationSources{Main: &input}}, promptkit.WithBundledOpenRouter(false), promptkit.WithLLMClient(smokeResultClient{cause}))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
observations, err := RunSmokeChecksObserved(context.Background(), engine, Targets{Profiles: []ProfileTarget{{ID: "profile"}}}, nil, nil, func(SmokeObservation) error { return observerErr })
|
||||||
|
if len(observations) != 1 || !errors.Is(err, observerErr) || cause != nil && !errors.Is(err, observations[0].Err) {
|
||||||
|
t.Fatalf("observations=%+v error=%v", observations, err)
|
||||||
|
}
|
||||||
|
if (observations[0].Err != nil) != (cause != nil) {
|
||||||
|
t.Fatalf("recording failure changed native verdict: %+v", observations[0])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user