diff --git a/docs/roadmap/remediation.md b/docs/roadmap/remediation.md index eb6305b..4ec3304 100644 --- a/docs/roadmap/remediation.md +++ b/docs/roadmap/remediation.md @@ -57,7 +57,12 @@ complete upstream error wording. ## R2 — Identify the profile while its smoke check is running -**Priority:** P3. **Stage:** 7. **Status:** Open. +**Priority:** P3. **Stage:** 7. **Status:** Complete. + +**Completion:** A small adapter callback identifies each profile before dispatch +through CommandKit progress. Adapter ordering and CLI visibility regressions +cover progress, disabled progress, debug, and quiet modes. Focused CLI and LLM +tests pass with Go 1.27.4. **Locations:** `internal/cli/preflight.go:36`; `internal/framework/llm/smoke.go:64`. diff --git a/internal/cli/preflight.go b/internal/cli/preflight.go index c9156a8..828aef3 100644 --- a/internal/cli/preflight.go +++ b/internal/cli/preflight.go @@ -34,7 +34,9 @@ func runPreflight(inv commandkit.Invocation, input processInput) commandkit.Outc return commandkit.Success() } _ = reporter.Progress("Checking structured output for selected profiles.") - results, err := llm.VerifyStructuredOutput(inv.Context, loaded.Runtime.Engine, prepared.Plan.Profiles) + results, err := llm.VerifyStructuredOutput(inv.Context, loaded.Runtime.Engine, prepared.Plan.Profiles, func(id string) { + _ = reporter.Progress(fmt.Sprintf("Checking structured output for profile %q.", id)) + }) if err != nil { details := make([]commandkit.Detail, 0, len(results)) for _, result := range results { diff --git a/internal/cli/preflight_test.go b/internal/cli/preflight_test.go index 63925af..7d7f9ad 100644 --- a/internal/cli/preflight_test.go +++ b/internal/cli/preflight_test.go @@ -213,11 +213,16 @@ func TestPreflightExplainsNativePreparationError(t *testing.T) { if err != nil { t.Fatal(err) } - for _, flags := range [][]string{nil, {"--quiet"}, {"--debug"}} { + for _, flags := range [][]string{nil, {"--quiet"}, {"--debug"}, {"--progress"}, {"--progress=false"}, {"--quiet", "--progress"}} { var out, diagnostic bytes.Buffer args := append([]string{"preflight"}, flags...) args = append(args, "--config", filepath.Join(dir, "config.yml"), "--output", filepath.Join(dir, "out.json"), filepath.Join(dir, "transcript.json")) result := app.Execute(context.Background(), args, commandkit.Streams{Out: &out, Err: &diagnostic}) + wantProgress := slices.Contains(flags, "--debug") || (slices.Contains(flags, "--progress") && !slices.Contains(flags, "--quiet")) + if strings.Contains(diagnostic.String(), `Checking structured output for profile "selected"`) != wantProgress { + t.Fatalf("flags=%v diagnostic=%s", flags, diagnostic.String()) + } + if result.Status != 1 || result.Cause == nil || !strings.Contains(diagnostic.String(), `Profile "selected"`) || !strings.Contains(diagnostic.String(), "model is required") { t.Fatalf("status=%d cause=%v diagnostic=%s", result.Status, result.Cause, diagnostic.String()) } diff --git a/internal/framework/llm/smoke.go b/internal/framework/llm/smoke.go index 3a7bcdb..1d1a886 100644 --- a/internal/framework/llm/smoke.go +++ b/internal/framework/llm/smoke.go @@ -61,7 +61,7 @@ func classifyStructuredOutput(report *pk.SmokeTestReport, err error) Verificatio } // VerifyStructuredOutput checks selected profiles sequentially and retains native evidence. -func VerifyStructuredOutput(ctx context.Context, engine smokeTester, profiles []string) ([]ProfileVerification, error) { +func VerifyStructuredOutput(ctx context.Context, engine smokeTester, profiles []string, progress func(string)) ([]ProfileVerification, error) { var results []ProfileVerification var failures []error for _, id := range profiles { @@ -69,6 +69,9 @@ func VerifyStructuredOutput(ctx context.Context, engine smokeTester, profiles [] failures = append(failures, err) break } + if progress != nil { + progress(id) + } report, err := engine.SmokeTest(ctx, pk.SmokeTestRequest{Kind: pk.SmokeTestStructuredOutput, ProfileID: id}) status := classifyStructuredOutput(report, err) results = append(results, ProfileVerification{ProfileID: id, Status: status, Report: report, Err: err}) diff --git a/internal/framework/llm/smoke_test.go b/internal/framework/llm/smoke_test.go index fec684b..c72f095 100644 --- a/internal/framework/llm/smoke_test.go +++ b/internal/framework/llm/smoke_test.go @@ -79,7 +79,7 @@ func TestVerifyStructuredOutputContinuesAndStopsOnCancellation(t *testing.T) { return positiveSmokeReport(), nil } }) - results, err := VerifyStructuredOutput(ctx, engine, []string{"first", "second", "third"}) + results, err := VerifyStructuredOutput(ctx, engine, []string{"first", "second", "third"}, nil) if !slices.Equal(calls, []string{"first", "second"}) || len(results) != 2 || results[1].Report == nil || !errors.Is(err, failure) || !errors.Is(err, context.Canceled) { t.Fatalf("calls=%v results=%+v error=%v", calls, results, err) } @@ -111,8 +111,22 @@ func TestVerifyStructuredOutputUsesNativeEngine(t *testing.T) { if err != nil { t.Fatal(err) } - results, err := VerifyStructuredOutput(context.Background(), runtime.Engine, []string{"fixture"}) + results, err := VerifyStructuredOutput(context.Background(), runtime.Engine, []string{"fixture"}, nil) if err != nil || calls != 1 || len(results) != 1 || results[0].Status != VerificationSuccess { t.Fatalf("calls=%d results=%+v err=%v", calls, results, err) } } + +func TestVerificationIdentifiesProfileBeforeDispatch(t *testing.T) { + var current string + engine := smokeFunc(func(_ context.Context, req pk.SmokeTestRequest) (*pk.SmokeTestReport, error) { + if current != req.ProfileID { + t.Fatalf("progress %q before dispatch %q", current, req.ProfileID) + } + return positiveSmokeReport(), nil + }) + _, err := VerifyStructuredOutput(context.Background(), engine, []string{"one", "two"}, func(id string) { current = id }) + if err != nil { + t.Fatal(err) + } +}