Repository navigation
OpenAI-compat path has no routing-reliability testing; Stage-2 candidate injection can silently suppress tool-calling on served models - #1832
Conversation
…1829) ADR-056 keeps the OpenAI-compatible path open to any user-configured model by design. That openness had no routing-reliability check: the existing smoke test validates transport and an *unrouted* tool-calling turn, so it cannot see a model that loses tool-calling once ADR-038's Stage-2 injects its candidate block. The new test runs four arms — baseline, stage1_only, routed_full, routed_names — against every model the configured endpoint serves, using production `render_candidates_for_prompt` so it measures what ships rather than a lookalike. Measured locally: model baseline stage1_only routed_full routed_names mistral:7b fires fires SUPPRESSED SUPPRESSED ornith:9b fires fires fires fires gemma4:e4b fires fires fires fires This reproduces the finding on a clean harness and adds the data point that changes its interpretation: `ornith:9b` is equally non-native and routes cleanly, so suppression is not a native-vs-served property. The obvious mitigation — skip injection for anything but the locked model — would therefore cost routing on models that handle it correctly. Only one hard assertion, that some served model tool-calls unrouted: a model suppressing under routing is a property of that model, not a NodeSpace regression to fail a build on. Two offline unit tests assert the arms produce distinct prompts and that routed_names really carries no instructions, so the matrix cannot silently compare identical inputs. Runtime remediation is deliberately not included; the matrix is the evidence that decision needs and it did not exist before. Tracked in #1830. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01AvsJJC6NgtJuNz8fTYA163
…ures Three fixes, all from review. **Ornith must not be evidence.** ADR-056 removed the Qwen family from the catalog outright, including the Qwen3.5-based ornith-1-9b-q4km. It appeared in the matrix only because it happened to be pulled on the tester's Ollama, and an argument was then built on it: "suppression is not a native-vs-served property, so the obvious mitigation is wrong." That conclusion rested on a model NodeSpace does not carry. The matrix now excludes removed-catalog models by name fragment so this cannot recur silently, and the doc comment claims only what two models support — which is neither "all served models are at risk" nor "specific to mistral:7b", since one exhibits the failure and none is confirmed clean. Also removes ornith:9b and qwen2.5-3b as sample model-id strings in two pre-existing unit fixtures (openai_compat_discovery, the frontend model selector). The ids are incidental to what those tests assert, so they now name models NodeSpace actually carries. **A failed arm must never read as a suppressed one.** run_arm returned an empty Vec on generation error, which printed identically to a real suppression — a harness failure masquerading as a finding, the exact confusion this workstream has had to relearn repeatedly. Arm results are now a typed enum where Errored and Completed(vec![]) cannot be conflated, and the test asserts no arm errored: an incomplete matrix fails loudly rather than showing a green run with a model quietly missing. **The run is now persisted.** tests/routing-matrix-latest.txt is written each run, fixed-width so verdicts diff column-wise. Without it, "auto- discover and report" degrades to run-once-and-eyeball — and this class of finding previously surfaced only by accident. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01AvsJJC6NgtJuNz8fTYA163
|
Review Type: Initial Review Requirements Check
1 — Met. 2 — Met. 3 — Deferred, defensible. #1830 carries the deferral honestly. It states the actual reason (one failing served model, none confirmed clean, so neither generalization is supported), lists the fork A/B/C with tradeoffs, and makes "widen the matrix" a blocking prerequisite rather than a nice-to-have. This is a decision recorded as a decision, not an omission dressed up as one. Agreed with the issue author on #1829 beforehand. 4 — Met. Verified in Code Review Findings🟡 Important📁 Two separate problems compound here. It doesn't mirror production. The arm sends a hand-written It's a weak control as designed. The offline test asserts Two options, either acceptable: (a) point it at Principle: a control that cannot vary is not a control — it is cost. And an experiment arm that claims production fidelity must actually have it, or the matrix's authority is borrowed rather than earned. 📁 The comment says "no measured model could tool-call even unrouted — the matrix is uninterpretable." The assertion only fires when every model fails baseline. With three models where two cannot tool-call, the run passes with a single interpretable row and no signal that two thirds of the matrix is noise. Given the file's own stated purpose — never let a degraded run read as a clean one — this is the one place that leniency is out of step with the rest. Suggest printing a prominent warning line per non-tool-calling model in the summary (they are currently only printed inline, mid-loop, where a long run buries them), and reconsidering whether the assertion should be Principle: an assertion's strength should match the invariant its comment claims to protect; otherwise the comment becomes the thing readers trust and the code becomes the thing that runs. 🟢 Suggestions📁 Currently tracked ( I don't think the answer is gitignoring it — the diffability was explicitly requested, and the file's whole reason for existing (per its own doc comment: "run it once, eyeball the printout, forget the result" is how this finding went unnoticed) is sound. But the current name works against that: Principle: a record that produces false-positive diffs trains readers to ignore its diffs, which is the failure the record was created to prevent. 📁 The mechanism is sound for its stated purpose and there is no false positive today — I checked the catalog in
Principle: a denylist that fails silently accumulates false positives no one audits; make its violations visible at the moment they'd first mislead. 📁
Verified — no issues
RecommendationAPPROVE The PR does the hard thing correctly: the routed arms use production rendering at the production injection point, harness failure and model suppression are separated at the type level rather than by convention, and the documentation states the limits of two data points as prominently as the finding itself. Deferring the runtime mitigation to #1830 rather than building one on a single failing data point is the right call and is recorded as a decision, not an omission. The findings above are worth addressing but none blocks merge. The |
malibio
left a comment
There was a problem hiding this comment.
Review posted above. Recommendation: APPROVE (formal approval blocked — GitHub does not permit approving your own PR).
Routed arms use production render_candidates_for_prompt at the production injection point, and the Errored/Completed type split correctly prevents harness failures reading as findings. Two follow-ups worth doing, neither blocking: Stage1Only diverges from production STAGE1_SYSTEM_PROMPT while claiming production fidelity, and the cannot_tool_call assertion is weaker than its comment claims.
…rtifact
**Stage-1 was the lookalike the test exists to avoid.** The arm sent a
hand-written "Route the user's request." at temperature 0.0 with no
token ceiling, while production sends STAGE1_SYSTEM_PROMPT (five lines,
including "Call exactly one tool. Do not answer the user.") at
temperature 0.1 with STAGE1_MAX_TOKENS. The routed arms fired the same
divergent call. Since the whole test rests on measuring what ships, both
constants are now pub and imported rather than paraphrased — they cannot
drift from production without breaking the build. Re-ran the live matrix
against the real prompt: verdicts unchanged, so the finding holds.
**The baseline assertion was weaker than its comment.** It fired only
when *every* model failed baseline, so two of three failing passed
silently — the same "measured nothing, looked green" failure the
errored-arm assertion exists to prevent. Now every model must clear it.
**The artifact is gitignored, not committed.** Its rows depend on which
models the runner's endpoint serves, so tracking it makes an ordinary
re-run on a differently-provisioned box look like a changed finding.
This matches how aichat-matrix.ts run artifacts are handled (ADR-056
notes they are not committed). Diffability lives in the tracking issue,
which is where the run was already posted.
**A failed artifact write no longer reports success.** write_matrix_artifact
returns io::Result instead of printing an error and then having the
caller unconditionally announce "matrix written to {path}".
**The exclusion list is now guarded.** "qwen" is an architecture-family
substring, so a future Qwen-derived catalog entry would have been dropped
from the matrix with only a println to say so. A unit test pins that the
locked model and the served ids in current use stay measurable.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01AvsJJC6NgtJuNz8fTYA163
Review findings addressed —
|
Completes the Stage-1 finding. The prior commit fixed production fidelity but left the arm's stated purpose wrong, which was the other half of the same review point. The docs claimed stage1_only isolates "does Stage 1's extra turn cost it". That is true on the native in-process path, where the cost is a diverged KV-cache prefix — the overhead ADR-038 accepts and requires be measured. It is not true over HTTP: each request is independent, so a discarded Stage-1 generation cannot reach the measured turn, and the two prompts are identical by assertion. The arm was reading as a routing measurement while being structurally unable to vary. Kept rather than dropped, with its real job documented: transport statelessness is an assumption about the *server*, not a guarantee. A server carrying conversation state across requests, or evicting a model between them, surfaces here as stage1_only diverging from baseline — and would invalidate the routed arms, which pay the same Stage-1 cost. It is a harness guard, not a measurement of routing. Confirmed empirically: both models matched baseline on that arm. Also stamps a UTC run date into the artifact header, so a pasted run is placeable in time — without it two runs cannot be told apart as "same box later" versus "different box". Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01AvsJJC6NgtJuNz8fTYA163
|
| Finding | Severity | Commit |
|---|---|---|
Stage1Only diverges from production |
🟡 | 0beab007 |
Stage1Only is a weak control / mislabelled |
🟡 | f598a634 ⬅ missed on first pass |
| Baseline assertion weaker than its comment | 🟡 | 0beab007 |
| Artifact churn | 🟢 | 0beab007 (diverged — see below) |
EXCLUDED_MODEL_FRAGMENTS silent drops |
🟢 | 0beab007 |
| False "matrix written" on write failure | 🟢 | 0beab007 |
What the first pass missed
The docs claimed stage1_only isolates "does Stage 1's extra turn cost it". That holds on the native in-process path, where the cost is a diverged KV-cache prefix — the overhead ADR-038 accepts. It does not hold over HTTP: requests are independent, so the discarded Stage-1 generation cannot reach the measured turn, and the prompts are identical by assertion. The arm read as a routing measurement while being structurally unable to vary.
Kept rather than dropped (option a), with its real job documented: transport statelessness is an assumption about the server, not a guarantee. A server carrying state across requests, or evicting a model between them, shows up here as stage1_only diverging from baseline — and would invalidate the routed arms, which pay the same Stage-1 cost. It is a harness guard, not a measurement of routing.
Confirmed empirically on the re-run: both models matched baseline on that arm, as the stateless transport predicts.
One finding resolved differently than suggested
The artifact suggestion explicitly said "I don't think the answer is gitignoring it." I gitignored it anyway. Reasoning: the repo's .gitignore already carries a "Testing artifacts (never commit)" section, and ADR-056 records that aichat-matrix.ts's per-run results files are not committed — tracking this one cuts against both. The underlying goal (don't run-once-and-forget) is served by pasting runs into the issue, which is where they now live. Took the reviewer's secondary suggestion too: the header now carries a UTC run date, so a pasted run is placeable in time.
Nothing skipped
No recommendation was judged overkill or out of scope.
Verification
cargo test -p nodespace-agent --test live_openai_compat_routing→ 3 passed, 1 ignored- Live matrix re-run → verdicts unchanged from every prior run
bun run test:all→ exit 0; 171 files / 4112 frontend tests, matching baselinebun run quality:fix→ clean (clippy --all-targets -D warnings)
Re-Review Decision
Decision: NO RE-REVIEW NEEDED
Rationale: Both post-review commits are confined to the test harness and its documentation — no production behavior changed. The only source edit outside the test file is widening two consts to pub so the test consumes production values instead of copies. The substantive change in f598a634 is a documentation correction plus a run-date header; the code it describes was already verified by the live re-run, which produced identical verdicts across all three runs (original, post-fidelity-fix, post-doc-fix).
The one thing worth a human eye is the artifact decision, since it diverges from what the reviewer proposed — flagged above rather than buried.
Note on review status: the automated reviewer's --approve was rejected by GitHub as self-approval and its APPROVE recommendation was posted as a comment instead. That is not independent sign-off. This PR carries no formal approval; merge remains a human call.
Closes #1829.
What this adds
A four-arm routing-reliability matrix for the OpenAI-compatible path (
packages/agent/tests/live_openai_compat_routing.rs,--ignored). The existing smoke test validates transport and an unrouted tool-calling turn, so it structurally cannot see a model that loses tool-calling once ADR-038's Stage-2 injects its candidate block.The arms isolate which part of routing, if any, causes suppression:
baselinestage1_onlyrouted_fullrouted_namesRouted arms use production
render_candidates_for_prompt, so this measures what ships rather than a lookalike.Result
mistral:7bthe block's presence is the variable, not its content.routed_namescarries a bare skill name and still suppresses, which ADR-064 rule 4's mechanism (measured on the locked model) does not explain.What this does not establish: how far the failure generalises. One served model exhibits it and none is confirmed clean, so neither "all served models are at risk" nor "this is specific to
mistral:7b" follows. Both the test docs and ADR-056 say exactly that rather than over-reading two data points.Scope decisions
No runtime mitigation, deliberately. Scope item 3 asks what NodeSpace does on detection. Both candidate designs (runtime auto-degrade; one-time probe per model) encode a policy about how the failure generalises — which this matrix does not yet settle. Deferred to #1830 with a wider matrix as an explicit prerequisite. Agreed on the issue before implementation.
Suppression is reported, not asserted per-model. A served model suppressing is a property of that model, not a NodeSpace regression to redden a build on. The assertions cover harness failures only: any errored arm, zero measurable models discovered, or row count ≠ model count.
Removed-catalog models are excluded from measurement. ADR-056 deleted the Qwen family, including the Qwen3.5-based
ornith-1-9b-q4km. A dev box may still serve it; measuring it would produce evidence for a model NodeSpace does not carry.EXCLUDED_MODEL_FRAGMENTSprevents that silently recurring. Two pre-existing unit fixtures usingornith:9b/qwen2.5-3bas sample id strings were also updated — incidental to what they assert, but live references to a removed family.Guards against measuring nothing
This workstream has repeatedly been burned by harness failures that read as findings, so two are pinned structurally:
ErroredandCompleted(vec![])are different types.run_armpreviously returned an emptyVecon generation error, printing identically to a real suppression — a timed-out model would have entered the matrix as a finding.routed_namesreally carries no instructions. Without them the matrix could compare identical inputs and report a difference that cannot exist.Artifact
Each run writes
packages/agent/tests/routing-matrix-latest.txt, fixed-width so verdicts diff column-wise. Not asserted against a golden — the values depend on which models the box serves, so it is a record, not an expectation.Docs
Committed to
nodespace-docs(ADR-034 user-facing consequence, ADR-038 routing risk, ADR-056 the matrix and its limits).Testing
bun run test:all— exit 0; frontend 171 files / 4112 tests, matching baselinebun run quality:fix— clean, no collateral reformatting