Repository navigation
In review
In review
Copy link
Labels
Description
Source PR: #407
Branch: fix/qa-refusal-profile
Head reviewed: 569ea98
Push the fixes to the branch above; do not open a new pull request. Comment on the PR and on this issue when done.
Blocking findings
- Pre-launch refusals that return before the stage block still print no stage (
internal/cli/doctor.go:387):qaRefusalStageis only consulted in the block that runs afterqapi.RunLocalReportOnreturns (doctor.go:386-389). Every earlier pre-launch refusal returns throughqaFailurebefore reaching it: the--evidenceread failure at doctor.go:352-363 (which printsevidence_field=/evidence_reason=and no stage) and the install-root failure at doctor.go:373 (error=actor_unavailable, reachable becauseqaInstallRootfails whenos.UserHomeDirfails, e.g. HOME unset). The new docs/operating.md:219 says "Aqa runrefusal names the preflight question that refused it (qa run refusals do not identify the failing stage and the route note misreports the resolved route #374)", and docs/operating.md:232 says an evidence refusal printsstage=evidence_admissionwithevidence_field/evidence_reason— the word order describes exactly the branch that prints the two fields without the stage. This is the ambiguity qa run refusals do not identify the failing stage and the route note misreports the resolved route #374 was filed for, still present in the two paths the doc promises to cover.- Failure scenario:
cortex qa run --role requirements-analyst --request requirements.txt --catalog /abs/catalog --evidence missing.jsonprintserror=invalid_request, thenote=prerequisitesline, thenevidence_field=path evidence_reason=file_not_found, and exits failure with nostage=line, so the operator cannot tell this from any other pre-launch refusal;env -u HOME cortex qa run --role requirements-analyst --request requirements.txt --catalog /abs/cataloglikewise printserror=actor_unavailablewith nostage=actor_admission.
- Failure scenario:
- route_provider/route_model are written raw while the new doc claims they are escaped (
internal/cli/doctor.go:408):fmt.Fprintf(stderr, "route_provider=%s route_model=%s\n", unavailable.Provider, unavailable.Model)writes the routed pair verbatim. That pair is the profile's own text: qaroute.routeText accepts any JSON string of up to 128 bytes with no charset restriction, resolve.go copies it into ResolvedRoute.Provider/Model, and qapi carries it into BackendUnavailableError (backend.go:70-83, report.go:172). The section this PR adds says the pair is "escaped for the terminal" (docs/operating.md:230), and the same PR sanitizes the caller-supplied--profileid throughsanitizeProfileToken, so the escaping contract exists in the new surface but is not applied to the values the profile file controls. The model-probe test only feeds a benign pair (openai-codex/gpt-5.6-terra), so nothing catches it.- Failure scenario: A catalog whose
cortex/qa-profiles.jsonroutes the role to{"provider":"\u001b]52;c;SGVsbG8=\u0007","model":"m","effort":"low"}and a run whose availability probe answersmodel_unavailablewrites the raw OSC 52 sequence into stderr on theroute_provider=line (clipboard write / title rewrite in the operator's terminal), contradicting the documented escaping.
- Failure scenario: A catalog whose
Acceptance criteria
- Fixed: Pre-launch refusals that return before the stage block still print no stage (internal/cli/doctor.go:387). The scenario below no longer reproduces:
cortex qa run --role requirements-analyst --request requirements.txt --catalog /abs/catalog --evidence missing.jsonprintserror=invalid_request, thenote=prerequisitesline, thenevidence_field=path evidence_reason=file_not_found, and exits failure with nostage=line, so the operator cannot tell this from any other pre-launch refusal;env -u HOME cortex qa run --role requirements-analyst --request requirements.txt --catalog /abs/cataloglikewise printserror=actor_unavailablewith nostage=actor_admission. - Fixed: route_provider/route_model are written raw while the new doc claims they are escaped (internal/cli/doctor.go:408). The scenario below no longer reproduces: A catalog whose
cortex/qa-profiles.jsonroutes the role to{"provider":"\u001b]52;c;SGVsbG8=\u0007","model":"m","effort":"low"}and a run whose availability probe answersmodel_unavailablewrites the raw OSC 52 sequence into stderr on theroute_provider=line (clipboard write / title rewrite in the operator's terminal), contradicting the documented escaping.
Activity
barbatdev commentedon Nov 24, 2026
Implemented in #446 at d9d6743. Early evidence-file refusals emit stage=evidence_admission; unset-HOME install-root refusal emits stage=actor_admission. Existing terminal-safe provider/model rendering is covered with hostile profile regressions. Current main reports missing evidence as file_unavailable (the bounded reader drops the underlying stat error); that existing reason remains unchanged. Focused tests, full Go suite, vet, all 16 local Python policy tests and independent review passed. Exact-head GitHub CI also passed the full race suite and all policy checks: https://github.com/refactor-ia/cortex/actions/runs/45307126360. Ready for review; not merged.