Repository navigation
fix: address Cora review critical issues (7 items) - #264
Conversation
FTS5 (from PR #261): - Fix BM25 score conversion: rank is negative unbounded, clamping to 0..1 produced 0.0 for all results. Now uses rank-based scoring (placeholder 1.0) since actual ranking is done by RRF in hybrid. - Fix RRF normalization: denominator calculation was correct but .min(1.0) was misleading. Replaced with explicit .clamp(0.0, 1.0). - Replace memories.remove().unwrap() with expect() for clearer panic msg. Metadata (from PR #262): - Replace as_object_mut().unwrap() with if-let pattern to prevent panic. - Server-mode remember now includes entity/category/meta in request body instead of silently ignoring them.
📝 WalkthroughWalkthroughThe PR updates the remember command pipeline to enrich recall results with user-provided metadata while improving the safety and scoring of search responses. CLI arguments are captured and transmitted via HTTP; response formatting is hardened to safely insert metadata; and search scoring paths refine their normalization logic. ChangesMetadata enrichment and search scoring
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Suggested labels
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Cora AI Code Review❌ Blocked — critical issues found. 🔴 Error (1)
Review powered by cora-cli · BYOK · MIT |
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/uteke-cli/src/commands/server.rs`:
- Around line 64-82: The server-mode metadata builder in server.rs (the meta_map
construction and assignment to body["metadata"]) currently only accepts
"key:value" pairs and stores everything as strings, which diverges from local
parsing in remember.rs::parse_meta_pairs and can drop bare flags; update the
server-side parsing to reuse the same parsing logic/semantics as
remember.rs::parse_meta_pairs (or call that helper) so bare flags become boolean
true, numeric/boolean strings are typed appropriately, and key-only entries are
preserved, then assign the resulting serde_json::Value/Object to
body["metadata"] instead of the current string-only map.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1926a735-770a-4e1f-ae8b-e66d30e7c76d
📒 Files selected for processing (3)
crates/uteke-cli/src/commands/remember.rscrates/uteke-cli/src/commands/server.rscrates/uteke-core/src/operations.rs
| // Build metadata from entity/category/meta flags | ||
| let mut meta_map = serde_json::Map::new(); | ||
| if let Some(e) = entity { | ||
| meta_map.insert("entity".to_string(), serde_json::Value::String(e.clone())); | ||
| } | ||
| if let Some(c) = category { | ||
| meta_map.insert("category".to_string(), serde_json::Value::String(c.clone())); | ||
| } | ||
| for pair in meta { | ||
| if let Some((key, value)) = pair.split_once(':') { | ||
| meta_map.insert( | ||
| key.to_string(), | ||
| serde_json::Value::String(value.to_string()), | ||
| ); | ||
| } | ||
| } | ||
| if !meta_map.is_empty() { | ||
| body["metadata"] = serde_json::Value::Object(meta_map); | ||
| } |
There was a problem hiding this comment.
Metadata parsing in server mode diverges from local mode and can silently lose/reshape user metadata.
At Line 72–79, server-mode parsing only accepts key:value and stores all values as strings. This drops bare flags (--meta foo) and changes typed values (true, 42) compared to local mode behavior in remember.rs::parse_meta_pairs, creating inconsistent persisted metadata across execution paths.
Suggested fix
- for pair in meta {
- if let Some((key, value)) = pair.split_once(':') {
- meta_map.insert(
- key.to_string(),
- serde_json::Value::String(value.to_string()),
- );
- }
- }
+ for pair in meta {
+ if let Some((key, value)) = pair.split_once(':') {
+ let val = if let Ok(n) = value.parse::<f64>() {
+ serde_json::Value::from(n)
+ } else if value == "true" {
+ serde_json::Value::Bool(true)
+ } else if value == "false" {
+ serde_json::Value::Bool(false)
+ } else {
+ serde_json::Value::String(value.to_string())
+ };
+ meta_map.insert(key.to_string(), val);
+ } else {
+ meta_map.insert(pair.to_string(), serde_json::Value::Bool(true));
+ }
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Build metadata from entity/category/meta flags | |
| let mut meta_map = serde_json::Map::new(); | |
| if let Some(e) = entity { | |
| meta_map.insert("entity".to_string(), serde_json::Value::String(e.clone())); | |
| } | |
| if let Some(c) = category { | |
| meta_map.insert("category".to_string(), serde_json::Value::String(c.clone())); | |
| } | |
| for pair in meta { | |
| if let Some((key, value)) = pair.split_once(':') { | |
| meta_map.insert( | |
| key.to_string(), | |
| serde_json::Value::String(value.to_string()), | |
| ); | |
| } | |
| } | |
| if !meta_map.is_empty() { | |
| body["metadata"] = serde_json::Value::Object(meta_map); | |
| } | |
| // Build metadata from entity/category/meta flags | |
| let mut meta_map = serde_json::Map::new(); | |
| if let Some(e) = entity { | |
| meta_map.insert("entity".to_string(), serde_json::Value::String(e.clone())); | |
| } | |
| if let Some(c) = category { | |
| meta_map.insert("category".to_string(), serde_json::Value::String(c.clone())); | |
| } | |
| for pair in meta { | |
| if let Some((key, value)) = pair.split_once(':') { | |
| let val = if let Ok(n) = value.parse::<f64>() { | |
| serde_json::Value::from(n) | |
| } else if value == "true" { | |
| serde_json::Value::Bool(true) | |
| } else if value == "false" { | |
| serde_json::Value::Bool(false) | |
| } else { | |
| serde_json::Value::String(value.to_string()) | |
| }; | |
| meta_map.insert(key.to_string(), val); | |
| } else { | |
| meta_map.insert(pair.to_string(), serde_json::Value::Bool(true)); | |
| } | |
| } | |
| if !meta_map.is_empty() { | |
| body["metadata"] = serde_json::Value::Object(meta_map); | |
| } |
🤖 Prompt for 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.
In `@crates/uteke-cli/src/commands/server.rs` around lines 64 - 82, The
server-mode metadata builder in server.rs (the meta_map construction and
assignment to body["metadata"]) currently only accepts "key:value" pairs and
stores everything as strings, which diverges from local parsing in
remember.rs::parse_meta_pairs and can drop bare flags; update the server-side
parsing to reuse the same parsing logic/semantics as
remember.rs::parse_meta_pairs (or call that helper) so bare flags become boolean
true, numeric/boolean strings are typed appropriately, and key-only entries are
preserved, then assign the resulting serde_json::Value/Object to
body["metadata"] instead of the current string-only map.
* fix: address Cora review critical issues (7 items) FTS5 (from PR #261): - Fix BM25 score conversion: rank is negative unbounded, clamping to 0..1 produced 0.0 for all results. Now uses rank-based scoring (placeholder 1.0) since actual ranking is done by RRF in hybrid. - Fix RRF normalization: denominator calculation was correct but .min(1.0) was misleading. Replaced with explicit .clamp(0.0, 1.0). - Replace memories.remove().unwrap() with expect() for clearer panic msg. Metadata (from PR #262): - Replace as_object_mut().unwrap() with if-let pattern to prevent panic. - Server-mode remember now includes entity/category/meta in request body instead of silently ignoring them. * style: cargo fmt
Cora Review Findings Fixed
FTS5 Issues (from PR #261 Cora review)
BM25 score conversion broken —
rankfrom FTS5 BM25 is negative unbounded (-15.3, -0.5, etc).(1.0 + rank).clamp(0.0, 1.0)produced 0.0 for almost all results. Fixed: FTS5-only path now uses placeholder score (actual ranking done by RRF in hybrid).RRF normalization misleading —
.min(1.0)clamp masked potential overflow. Replaced with explicit.clamp(0.0, 1.0)and clearer comment about theoretical max.unwrap() panic risk —
memories.remove(&id).unwrap()replaced with.expect()for clearer panic message if invariant violated.Metadata Issues (from PR #262 Cora review)
4-5.
as_object_mut().unwrap()panics — Two instances inremember.rsreplaced withif let Some(map) = obj.as_object_mut()pattern.--entity,--category,--metawere destructured with_and silently dropped in server mode. Now properly included in the request body.Verification
cargo clippy --all-targets -- -D warnings— cleancargo test— 107/107 passSummary by CodeRabbit
New Features
Bug Fixes