Repository navigation
Route skill retrieval by pure KNN instead of hybrid BM25 tiering - #2549
Conversation
#2265) find_skills used the hybrid BM25+KNN semantic_search_nodes, whose result order is a hard tier partition (BM25∩KNN, then KNN-only, then BM25-only) rather than a blended score. A skill whose guidance markdown happened to share a keyword with the query could rank ahead of a much stronger semantic match purely from tier membership — this is what made Schema Creation retrieval intermittent rather than an embedding near-tie as originally hypothesized. find_skills now calls semantic_search_nodes_of_type (pure KNN over skill-typed roots), a pre-existing primitive built for exactly this small-corpus classification shape, with no BM25 involvement. Also fixes an unrelated 2-day-old regression in the eval harness's scripts/aichat.ts: it read node.properties["ai-chat"], but node get --json's output was flattened by a recent commit, so the turn-completion poll loop could never observe it and every eval turn silently burned its full timeout. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Code Review SummaryClean, well-scoped fix. Requirements Check (issue #2265 acceptance criteria)
FindingsCritical IssuesNone. Suggested Improvements
Nitpicks
Verification Performed
RecommendationAPPROVE. The core fix is correct, minimal, and directly traceable to the issue's root-cause finding; it removes rather than layers on complexity (deletes the now-unneeded pre-inflation logic and an unused import). Test coverage is real and meaningfully asserts the fix (not tautological — it reproduces the documented intermittent-failure rate and shows a fix). The bundled |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Pragmatic Code Review — PR #2549 (closes #2265)Verdict: APPROVE Summary of what changed
Verification performed
FindingsNone blocking. This is a well-scoped, well-verified fix:
Minor, non-blocking observations (not requesting changes):
No correctness, security, or architectural concerns. Recommend merge. |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Summary
find_skillscalled the hybrid BM25+KNNsemantic_search_nodes, whose result order is a hard tier partition (BM25∩KNN, then KNN-only, then BM25-only) rather than a blended score — so a skill whose guidance markdown happened to share a keyword with the query could rank ahead of a much stronger semantic match purely from tier membership. Verified directly this is what made Schema Creation retrieval intermittent (not an embedding near-tie, as originally hypothesized).find_skillsnow callssemantic_search_nodes_of_type(pure KNN overskill-typed roots) — a pre-existing primitive built for exactly this small closed-corpus classification shape, with no BM25 involvement at all.packages/agent/tests/live_skill_retrieval_stability.rs) closing a real test-coverage gap: every prior skill-routing test either mocked retrieval out entirely or drove the full Stage-1 LLM, so nothing exercised live Stage-2 retrieval against the real seeded registry.scripts/aichat.ts: it readnode.properties["ai-chat"], butnode get --json's output was flattened by a recent commit (Emit flat node properties from the CLI (closes #2381) #2423), so the turn-completion poll loop could never observe it and every eval turn silently burned its full timeout before detecting completion.Verification
live_skill_retrieval_stability.rs, run explicitly against the realnomic-embed-text-v1.5model): scenario 8a now routes Schema Creation 1st (previously 3rd), 5/5 reps, with a clear score margin over the runner-up. A BM25-collision regression test confirms two unrelated skills still keyword-match viabm25_search_rootsbut no longer affectfind_skills's output.bun run eval:agentmatrix (gemma-4-e4b-q4km,--runs 3, fresh isolated DB):create_schemawas offered and called in every rep for every Schema-Creation-relevant scenario; the daemon log'sall_scoresdiagnostic confirms Schema Creation won retrieval by a clear margin on every turn. Filed Relationship Management never routes for natural 'point at'/'link'/'connect' phrasing #2548 for an unrelated, pre-existing routing gap in Relationship Management found along the way.cargo test -p nodespace-core -p nodespace-agent --lib: 1286 + 627 passed, no regressions.bun run quality:fix: clean (ESLint, TypeScript, svelte-check, clippy).bun run test:all: clean, no new failures vs. baseline (4909 frontend tests).test:all+cargo build --bin nodespaced+test:e2e): passed.Test plan
packages/agent/tests/live_skill_retrieval_stability.rs, run with--ignored)quality:fixandtest:allcleanCloses #2265
🤖 Generated with Claude Code