Repository navigation
fix(cli): escape routed pair diagnostics - #408
Conversation
Fleet review (glm)Lens: requirements + adversarial. Slice 7/8 of #401 adds sanitizeRouteIdentity and applies it to the single routed-pair render site (internal/cli/doctor.go:408), with table-driven unit tests plus an end-to-end refusal test staging a hostile model token in a disposable catalog copy. The escaping itself is correct: printable ASCII (minus backslash) passes through, backslash is escaped first so escape forging is impossible, DEL and all non-ASCII bytes become \xNN, and values over the 128-byte bound are withheld. I verified BackendUnavailableError.Error() is a constant string, so the preceding raw err.Error() line cannot leak the pair, and no other render site of unavailable.Provider/Model exists at this head. The stage-classification and note lines required by #374 already landed in earlier slices of the chain, so this slice neither contradicts nor duplicates them. Three non-blocking observations: the equally caller-owned --catalog path is still rendered raw in the same refusal output; an empty route identity renders as , conflating a common misconfiguration with a withheld over-long value; and the body's claimed source commit is not resolvable in this repository, so its identical-tree claim is unverifiable from the repo alone. Suggestion (1)
Question (2)
Verdict: ready to merge |
Fleet review (qwen38)Lens: evidence. Slice 7/8 for #374: the routed provider/model pair from BackendUnavailableError now passes through sanitizeRouteIdentity before reaching the operator terminal (doctor.go:408), which escapes every byte outside printable ASCII (including backslash, so a literal \xNN cannot be forged) and withholds empty or >128-byte values. The escape property is backed by real, PR-contained evidence: the unit test pins ESC, newline, backslash-forgery, UTF-8, empty and over-long cases, and the CLI-level test stages a hostile profile in a disposable catalog copy, asserts no raw 0x1b byte appears in stderr and asserts the escaped form route_model=evil\x1b[2Jmodel. Both tests are reproducible from the diff alone, not just asserted in the body. The sanitizer logic itself has no blocking defect found. Open evidence items: the only production call site patched is the runQA stderr path, and the PR shows no scan proving no other path prints caller-owned provider/model identities; the delivery-head source-equivalence claim is an assertion with no reproducible check; and the comment's claim that the 128-byte bound matches qaroute is not evidenced in the diff. Suggestion (1)
Question (2)
Verdict: ready to merge |
Post-merge QA (glm)Slice 7/8: sanitizeRouteIdentity bounds (128 chars) and escapes caller-owned provider/model tokens, including backslash so an escape cannot be forged, and the runQA routed-pair diagnostic now goes through it. The test table covers plain ids, ESC sequences, newlines, backslash forging, non-ASCII, empty and over-long values, and the CLI-level test pins a hostile routed model never reaching the terminal raw. The escaping choice (escape rather than flatten) is right for values operators must compare against the runtime's model table. Nothing found that breaks what landed. No findings. Verdict: clean |
Post-merge QA (deepseek)Lens: evidence + test design. The escaping is the right shape: printable ASCII passes through, every other byte becomes a bounded hex escape, backslash is escaped so a caller-owned profile cannot forge an escape sequence, and empty or over-long values are withheld. The unit table covers the dangerous classes (ESC, newline, backslash, non-ASCII, empty, 129 bytes). Two evidence gaps: the end-to-end refusal test exercises only the model field, and the "same bound qaroute applies" claim lives in a comment with nothing in the diff tying the two bounds together. Suggestion (1)
Question (1)
Verdict: clean |
Linked Issue
Refs #374
Umbrella: #401
PR Type
type:featureFeaturetype:bugBug fixtype:docsDocumentationtype:refactorRefactoringtype:choreMaintenancetype:breaking-changeBreaking changeSummary
Bound and escape caller-owned provider/model identities before rendering the model-probe diagnostic, including backslash to prevent escape forging.
Changes
This is slice 7/8, 70 authored changed lines. Code, focused tests and applicable operating documentation stay together. Exact reviewed source commit:
0fa63eed9b26e67358ff64c0927d4d19f9ed2537. Delivery head520e70abe46da9b776316e088355b901eb776adehas the identical complete source tree.Focused Tests
Each cumulative prepared slice passed
go test ./internal/cli ./internal/qapi ./internal/qaroute ./internal/installobserve -count=1,go vet ./...and whitespace checks. Final candidate additionally passedgo test ./... -count=1,go vet ./...,go test -race ./...and all 15 repository Python policy tests on a byte-verified canonical clean snapshot. Independent source-agreement, typed-admission and final security verification passed with no severe blockers; final verification observed 19 named tests plus four package suites/vet.Native assessment of this exact slice: medium native tier, reviewDue=false (under_budget); no new native review started. Security-affecting slices retained explicit high-risk escalation and independent verification rather than treating assessment as proof. Parser's separately requested native review completed approved and acknowledged.
Runtime Harness
Disposable public CLI fixtures, no real provider calls. Rejections pin no launch/write effects, route identity and safe profile tokens. macOS /tmp is a symlink and intentionally refused: canonical snapshot cwd passed unchanged guards. No credentials changed.
Rollback
Revert this slice. Revert any dependent later slice first; no stored-data migration.
Chain Dependencies / Out of Scope
Sequential verified-main strategy: merged #407 -> [current slice 7/8] -> remaining slices. This PR targets main only after its predecessor lands, so its diff contains only this work unit. Do not close the umbrella from this intermediate slice.
Known acceptance limit: #329's literal transient/persistent causal distinction is NOT established by stage reporting and remains open. Defensive untyped branches, a currently unreachable non_nan_route mapping and a brittle wording assertion were disclosed as nonblocking verifier advisories, not silently fixed. Provider transport #345 and lifecycle #373 are out of scope.
Checklist
status:approved.type:*label is applied.