fix(libsy): validate classifier scores, fix packaging and strict rustdoc#104
fix(libsy): validate classifier scores, fix packaging and strict rustdoc#104elyasmnvidian wants to merge 2 commits into
Conversation
WalkthroughChangesLLM classifier routing
Estimated code review effort: 3 (Moderate) | ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/libsy/src/algorithms/llm_class.rs`:
- Around line 417-419: Remove the tracker reference “NvBug 6485976” from the NaN
fail-open comment at crates/libsy/src/algorithms/llm_class.rs lines 417-419
while preserving its rationale; likewise remove “NvBug 6485975” from the
streamed-score rationale at lines 439-441 without changing the surrounding
behavior or explanation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 81f87868-d92e-4236-97ce-2e768d7abaac
📒 Files selected for processing (4)
crates/libsy/Cargo.tomlcrates/libsy/src/algorithms/llm_class.rscrates/libsy/src/core/algorithm.rscrates/libsy/src/lib.rs
2e417fe to
3d3b31c
Compare
Before/after — this fix is library-mode, so the proof is the classifier's own tests
I ran the branch's With With the fix ( Command: Audit follow-up applied in this push: added |
Three fixes to the libsy LLM-classifier router (
crates/libsy/src/algorithms/llm_class.rs), plus a packaging and a rustdoc fix.Streaming classifier verdicts were ignored. The router read the score with
as_agg(), which returnsNonefor a streaming response, so a classifier target that streamed its score always fell open to the strong model no matter what it returned. It now drains the stream withinto_agg()and routes on the real score. A genuine stream error still propagates instead of being swallowed.Invalid scores were trusted as verdicts. A classifier reply that parsed as a float but was not a probability —
NaN,±inf, or anything outside[0, 1]— was compared against the threshold directly.NaNand negative values compared below the threshold and were routed to the weak model. The router now keeps only scores in[0.0, 1.0]; everything else fails open to the strong model, same as an unparseable reply.Packaging:
cargo package -p switchyard-libsynow succeeds. Theswitchyard-protocolpath dependency carriesversion = "0.1.0", which cargo requires before it will package a crate that has a path dependency.Docs:
RUSTDOCFLAGS="-D warnings" cargo docis clean again. Fixed two intra-doc links that pointed at private items (DriverRequest,Driver::stream) and dropped redundant explicit link targets inlib.rs.New regression tests cover the streaming drain and the invalid-score fail-open.
Note for reviewers:
LlmClassifieris a Rust library type. The Python bindings (crates/switchyard-py/src/libsy_bindings.rs) expose onlynoopandrandom, so this router is not reachable throughswitchyard serveyet — the tests are the proof of behavior.How to try it:
cargo test -p switchyard-libsyruns the new tests.