fix(skills): close RL rerank warmup TOCTOU and add test coverage#5850
Merged
Conversation
RoutingHead::rerank() now returns a RerankOutcome capturing blended and update_count under the same lock acquisition used to rank candidates, so the assembly.rs call site no longer needs a second, independently-locked update_count() call that could race with a concurrent background rl_head.update(). Also adds the RL-rerank branch's first automated test coverage: match_and_rank_skills' success path plus all three skip/error paths via a new with_rl_head()-wired Agent test harness, and an rl_head.rs case where cosine order and RL-blended order disagree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RoutingHead::rerank()(crates/zeph-skills/src/rl_head.rs) now returns aRerankOutcome { ranked, blended, update_count }capturingblended/update_countunder the same lock acquisition used to rank candidates, closing a narrow TOCTOU where theassembly.rspositive-confirmation log (added in RL rerank scoring has no positive-confirmation log, blocking live cross-backend parity verification #5834) computed those values via a second, independently-lockedupdate_count()call that could race with a concurrent backgroundrl_head.update().Agent::with_rl_head()(previously zero callers anywhere) is now exercised via a newzeph-coretest harness coveringmatch_and_rank_skills' success path and all three skip/error paths, plus anrl_head.rstest constructing a case where cosine order and RL-blended order disagree.Closes #5845, closes #5846.
Test plan
cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins(12372 passed)RUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links" cargo doc --no-deps --workspace --features "desktop,ide,server,chat,pdf,scheduler"cargo test --doc --workspace --features "desktop,ide,server,chat,pdf,scheduler"