Repository navigation
feat(search): rerank symbol and document search with Jev - #60
Conversation
Mở rộng rerank Jev (TypeSafe SystemOne) từ `codegraph_context` sang
`codegraph_search_symbol` và 3 tool document search
(`graphdoc_search`, `graphdoc_search_value`, `graphdoc_search_struct`).
- `codegraph_search_symbol`: arg `rerank = "jev"`, pool = `limit × 4`
(cap `[jev] max_candidates`), gắn `match_score.probability`, trả
`no_match`/`rerank`. Chỉ trang đầu — `offset > 0` hoặc `resume` bị từ
chối vì rerank phá tính ổn định phân trang.
- Doc search: cùng arg `rerank`; response đổi thành object
`{results, no_match, rerank}` khi bật (mặc định vẫn là array).
Candidate = `kind \`key\` in \`doc\`` + value tuỳ chọn.
- Config `[jev] doc_include_values` (default false) và `doc_value_chars`
(default 120): value giúp phân biệt node trùng key ở nhiều file nhưng
tốn token nên là opt-in.
- Fail-open toàn bộ: Jev lỗi/tắt/timeout → giữ thứ tự cũ + `rerank.used=false`.
- Gộp phần chọn candidate + fail-open vào `codegraph_context::rank()`
dùng chung cho cả 3 nguồn.
Test: unit cho candidate/apply outcome (MCP), `search_symbol_reranked`
với judge giả (API), live test `#[ignore]` thêm case doc-node-nhờ-value
(đã chạy thật: chọn đúng id 2, p=0.81).
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
* feat(context): rerank candidates with Jev (TypeSafe SystemOne)
`codegraph_context` chỉ biết `Contains` trên tên symbol, nên query tự nhiên
("where do we validate config.toml") trả rỗng hoặc trả symbol không liên quan.
Thêm `rerank = "jev"` (MCP arg + GraphQL field, mặc định off):
- Pool: query gốc + từng token (camelCase/snake_case, bỏ stopword) qua
`Contains`, lọc kind code và loại test/bench, cap `max_candidates`.
- Một request Jev: Choice (mỗi candidate một option + `none_of_the_above`)
cộng Noul để chẩn đoán. Trả `probabilities` → xếp hạng, `no_match` khi
`none` thắng xác suất hạng 1 hoặc hạng 1 dưới `min_probability`.
- Pool < 3 candidate → `no_match` luôn, không gọi API.
- Fail-open: thiếu token, timeout, 4xx, JSON lỗi → giữ thứ tự pool cũ kèm
`rerank.used = false` + `reason`; không bao giờ làm hỏng context.
- Response: `ContextHit.match_score { probability, confidence }`,
`ContextResponse.no_match`/`rerank`, markdown in thêm `(p=0.62)`.
- Config `[jev]` opt-in (dữ liệu rời máy): endpoint/model/api_key_env/
timeout_ms/max_candidates/min_probability/repo. Token chỉ đọc từ env.
Đo với jev-1.13-free: 4 candidate → 1.0s, ~530 input token, cost 0; chọn
đúng `parse_config` (p=0.62, none 0.38). Choice một mình luôn `confidence`
cao kể cả với pool rác (đo được 1.0 với 8 candidate sai), nên `none` +
`min_probability` mới là tín hiệu "không khớp" — không dùng Noul làm cổng
vì Jev trả noul thấp (0.33) ngay cả khi đã chọn đúng.
Test: 18 unit test (pool/tokenize/ngưỡng/fail-open/markdown) + 1 live
`#[ignore]` gọi API thật.
* feat(search): rerank symbol and document search with Jev (#60)
* feat(search): rerank symbol and document search with Jev
Mở rộng rerank Jev (TypeSafe SystemOne) từ `codegraph_context` sang
`codegraph_search_symbol` và 3 tool document search
(`graphdoc_search`, `graphdoc_search_value`, `graphdoc_search_struct`).
- `codegraph_search_symbol`: arg `rerank = "jev"`, pool = `limit × 4`
(cap `[jev] max_candidates`), gắn `match_score.probability`, trả
`no_match`/`rerank`. Chỉ trang đầu — `offset > 0` hoặc `resume` bị từ
chối vì rerank phá tính ổn định phân trang.
- Doc search: cùng arg `rerank`; response đổi thành object
`{results, no_match, rerank}` khi bật (mặc định vẫn là array).
Candidate = `kind \`key\` in \`doc\`` + value tuỳ chọn.
- Config `[jev] doc_include_values` (default false) và `doc_value_chars`
(default 120): value giúp phân biệt node trùng key ở nhiều file nhưng
tốn token nên là opt-in.
- Fail-open toàn bộ: Jev lỗi/tắt/timeout → giữ thứ tự cũ + `rerank.used=false`.
- Gộp phần chọn candidate + fail-open vào `codegraph_context::rank()`
dùng chung cho cả 3 nguồn.
Test: unit cho candidate/apply outcome (MCP), `search_symbol_reranked`
với judge giả (API), live test `#[ignore]` thêm case doc-node-nhờ-value
(đã chạy thật: chọn đúng id 2, p=0.81).
* Bump version to v2.2.13
* Potential fix for pull request finding 'CodeQL / Cleartext logging of sensitive information'
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
* docs(config): thêm block [jev] vào config.toml mặc định
Theo quy ước: thêm config key phải cập nhật DEFAULT_CONFIG_TOML để
sinh file mẫu có đủ key (kèm ghi chú opt-in + token chỉ
đọc từ env).
---------
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Codecov Report❌ Patch coverage is ❌ Your patch status has failed because the patch coverage (90.37%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## feat/jev-context-rerank #60 +/- ##
===========================================================
+ Coverage 80.77% 81.28% +0.51%
===========================================================
Files 105 105
Lines 30205 30561 +356
===========================================================
+ Hits 24398 24843 +445
+ Misses 5807 5718 -89 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will not alter performance1 warning
Comparing |
Tóm tắt
Mở rộng rerank Jev (TypeSafe SystemOne) từ
codegraph_contextsang symbol search và 3 tool document search. Stacked trên #59.Thay đổi
codegraph_search_symbolrerank = "none" | "jev"(defaultnone).limit × 4, cap[jev] max_candidates(40) → model có lựa chọn rồi cắt vềlimit.match_score.probability; response cóno_match+rerank { used, reason }.offset > 0hoặc córesume→ lỗi rõ ràng (rerank phá tính ổn định phân trang). Binary rows giữ nguyên thứ tự.Document search (
graphdoc_search,graphdoc_search_value,graphdoc_search_struct)rerank. Khi bật, response thành{ results, no_match, rerank }; khi tắt vẫn là array như cũ (không breaking).kind `key_path` in `doc_path`.limit(search_value lấy thêmlimit × 4; struct search rerank trên rows đã sort IDF).Config
[jev]doc_include_valuesfalsespec.replicasở nhiều file); value giúp Jev chọn đúng nhưng tốn token theo số candidatedoc_value_chars120Kiến trúc
codegraph_context::rank()+RankOutcomedùng chung cho context / symbol / doc → không lặp logic fail-open.codegraph-api::search_symbol_reranked()giữ phần lọc binary/timing ở tầng API.Fail-open
Jev tắt, thiếu token, timeout, 4xx, JSON lạ → giữ thứ tự cũ,
rerank.used = false+reason. Không tool nào hỏng vì Jev.Test
rerank_tests.rs— candidate doc (doc_include_valueson/off, cắt value),apply_doc_outcome(fail-open / no_match / sort +match_score), dispatch thật qua doc graph (array vs object), guardoffset/resumecho symbol search.search_symbol_rerankedvới judge giả (đổi thứ tự, cắt theo limit,totalgốc), no_match, fail-open khi jev tắt.#[ignore]: thêm case doc-node — chạy thật, Jev chọn đúng node nhờ value (id 2, p=0.81, none=0.05).Verify
cargo fmt --all -- --check✅cargo clippy --workspace --all-targets -- -D warnings✅cargo clippy -p codegraph-graph --features postgres,mysql,redis --tests -- -D warnings✅cargo test --workspace✅ (4 teststorage::redisfailConnection refused— pre-existing, không có redis-server)cargo test -p codegraph-context --test jev_live -- --ignored✅ (2/2 pass, gọi API thật)