From 8d0486c03c45413218843d00b2ca48fa8c9183b9 Mon Sep 17 00:00:00 2001 From: Juan Barbat Date: Thu, 12 Nov 2026 17:15:41 -0300 Subject: [PATCH] fix(cli): document --backend in qa setup usage and docs Fixes #336 --- docs/operating.md | 17 ++++++++++++++--- internal/cli/doctor.go | 2 +- internal/cli/qa_test.go | 18 ++++++++++++++++++ internal/cli/qasetup.go | 6 +++++- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/docs/operating.md b/docs/operating.md index 9b2a668..8e5a8db 100644 --- a/docs/operating.md +++ b/docs/operating.md @@ -187,6 +187,11 @@ user-owned profile file in the catalog root: {"schemaVersion":1,"defaultProfile":"my-route","profiles":{"my-route":{"routes":{"evidence-auditor":{"pi":{"provider":"nan","model":"glm5.3","effort":"high"}}}}}} ``` +Routes are keyed by role and then by backend token (`pi`, `claude`, `opencode`); a +`qa run --backend ` reads only the `` entry, and a role without one is refused +as `route_incomplete` with a `route_missing_backend=` line and a `qa setup ... --backend ` remedy. `qa setup` +writes these entries for you. + Location: `/cortex/qa-profiles.json` (mode 0600, regular file). The `defaultProfile` applies to every `qa run` without a `--profile` flag; pass `--profile ` to select another profile for one run. The three optional flags @@ -289,14 +294,20 @@ run looks like, and where it currently stops: when the probe's verdict carried one, and is not a per-run profile check. 2. **Configure the route.** The fleet ships no models, so pick a provider/model pair from the runtime's extension-free surface and run - `cortex qa setup --catalog --provider

--model `. Relative and + `cortex qa setup --catalog --provider

--model [--backend pi|claude|opencode] [--effort ]`. + On a machine whose pi backend is unavailable, pass `--backend claude` or + `--backend opencode`; without `--backend` the route is written for `pi`. Relative and absolute roots are both accepted: the command resolves the path before it writes, so `qa setup --catalog catalog` and `qa run --catalog catalog` from the same directory address the same file (#324). The root must already exist and contain `catalog.json`; `qa setup` validates it before probing models and refuses to create the tree, so a typo fails instead of writing a profile no run reads. `qa setup` - writes `/cortex/qa-profiles.json` with one route per fleet role, - pi-backend scoped (#328). + writes `/cortex/qa-profiles.json` with one route per fleet role for the + selected backend and preserves routes already configured for other backends, so + running it once per backend routes the whole fleet on each (#328). Only the `pi` + pair is checked against the runtime's model table at setup; a `claude` or + `opencode` pair is written as given and an unavailable model is refused at the + run's `model_probe` preflight. `--effort` defaults to `high`. 3. **Run one role with evidence.** Write a short bounded `request.txt`, then: ```sh diff --git a/internal/cli/doctor.go b/internal/cli/doctor.go index 5296ddc..9ff73d6 100644 --- a/internal/cli/doctor.go +++ b/internal/cli/doctor.go @@ -240,7 +240,7 @@ func doctorPriorStateBlocker(resolveRoots func() ([]skillroot.UninstallRoot, err const ( qaUsage = "usage: cortex qa run --role --request --catalog

[--backend pi|claude|opencode] [--evidence ] [--profile ]\n" + - "usage: cortex qa setup --catalog --provider

--model [--effort ]\n" + qaSetupUsageLine qaHelp = qaUsage + "\nQA evaluates evidence and does not run tests.\n" + "Write a short, bounded plain-text request (request.txt):\n" + "printf 'R1: Responses must finish within 100 ms.\\nR2: Responses must wait at least 500 ms.\\nIdentify the contradiction; do not edit files.\\n' > request.txt\n" + diff --git a/internal/cli/qa_test.go b/internal/cli/qa_test.go index 5feee75..ff3d74f 100644 --- a/internal/cli/qa_test.go +++ b/internal/cli/qa_test.go @@ -342,6 +342,24 @@ func TestQAHelpDocumentsEvidenceSidecarSchema(t *testing.T) { } } +func TestQAHelpDocumentsSetupBackendLikeSetupUsage(t *testing.T) { + const setupLine = "usage: cortex qa setup --catalog

--provider

--model [--backend pi|claude|opencode] [--effort ]\n" + help, helpErr := &bytes.Buffer{}, &bytes.Buffer{} + if code := Run(context.Background(), []string{"qa", "--help"}, help, helpErr, nil); code != exitOK || helpErr.Len() != 0 { + t.Fatalf("qa --help exit=%d stderr=%q", code, helpErr) + } + if !strings.Contains(help.String(), setupLine) { + t.Fatalf("qa --help = %q, want setup usage %q", help, setupLine) + } + setupOut, setupErr := &bytes.Buffer{}, &bytes.Buffer{} + if code := Run(context.Background(), []string{"qa", "setup"}, setupOut, setupErr, nil); code != exitUsage || setupOut.Len() != 0 { + t.Fatalf("qa setup exit=%d stdout=%q", code, setupOut) + } + if !strings.HasSuffix(setupErr.String(), setupLine) { + t.Fatalf("qa setup stderr = %q, want setup usage %q", setupErr, setupLine) + } +} + func TestQARunHonorsRouteProfileFromCatalog(t *testing.T) { args := roleReportFixture(t, "requirements-analyst") var catalogRoot string diff --git a/internal/cli/qasetup.go b/internal/cli/qasetup.go index 6ead625..49f9810 100644 --- a/internal/cli/qasetup.go +++ b/internal/cli/qasetup.go @@ -100,9 +100,13 @@ func runQASetup(ctx context.Context, args []string, stdout, stderr io.Writer) in return exitOK } +// qaSetupUsageLine is the single setup usage line shared by the setup refusal +// and qa --help, so both surfaces name --backend identically (#336). +const qaSetupUsageLine = "usage: cortex qa setup --catalog

--provider

--model [--backend pi|claude|opencode] [--effort ]\n" + func qaSetupUsage(stderr io.Writer) int { writeError(stderr, "invalid_arguments") - _, _ = io.WriteString(stderr, "usage: cortex qa setup --catalog

--provider

--model [--backend pi|claude|opencode] [--effort ]\n") + _, _ = io.WriteString(stderr, qaSetupUsageLine) return exitUsage }