mirror of
https://github.com/instructkr/claw-code.git
synced 2026-11-21 00:00:00 +08:00
fix(clippy): resolve new lint violations in trident, compact, and claw-rag-service
- runtime/trident.rs: derive Default, fix for_kv_map, if_same_then_else, extend_with_drain, unnecessary_cast, needless_borrows - runtime/compact.rs: fix useless_borrows_in_formatting - claw-rag-service/ingest.rs: remove unnecessary into_iter() - claw-rag-service/db.rs: use as_chunks instead of chunks_exact, remove unused import All tests pass (1014 Rust + 47 Python tests verified).
This commit is contained in:
1 parent
5433dac4a2
commit
8938f53790
11 files changed
+32
-30
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
{"schema_version":1,"session_id":"24aa7e35-e6af-4d2d-ab41-a38b9115a031","state":"running","ready_for_input":false,"updated_at":"2026-10-12T22:10:00.508Z","current_turn_id":null,"last_turn_id":null,"live":true,"reason":null,"source":"agent_session_event","event":"turn_start","cwd":"/home/bellman/Data/Workspace/gc-task-cc-pr-3250-lane","workdir":"/home/bellman/Data/Workspace/gc-task-cc-pr-3250-lane","branch":null,"session_file":"/home/bellman/.gajaeway/broker/agent/sessions/v2-famocqbiduwkxmc2g2nvg6jfq2ay6qtc5aihbhbdoqopsmduj4sa/2026-10-12T22-02-16-124Z_24aa7e35-e6af-4d2d-ab41-a38b9115a031.jsonl","activity":{"seq":149,"last_activity_at":"2026-10-12T22:10:01.196Z","tool":"bash","phase":"started","outcome":null,"elapsed_ms":null,"active_tool_count":1,"active_tools":[{"tool":"bash","started_at":"2026-10-12T22:10:01.196Z"}],"in_flight":[{"digest":"fa5f186357264e6b1be2a7a4a7162d0fff04f721630413a25d05b40bcd933836","tool":"bash","started_at":"2026-10-12T22:10:01.196Z"}]}}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"pid":1,"start_time":"unknown","token":"8389ee99-c41c-47dd-9615-e76a5268967c","owner_host_id":"7af2fb0e8e37bd543e3d0bda6f205b56f30077b5a9b77e83208e94ae441315ac","released":true}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"pid":1,"start_time":"unknown","token":"6e35ded8-fda1-421e-a727-42906ef57646","owner_host_id":"7af2fb0e8e37bd543e3d0bda6f205b56f30077b5a9b77e83208e94ae441315ac","released":true}
|
||||||
Whitespace-only changes.
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"sessionId": "24aa7e35-e6af-4d2d-ab41-a38b9115a031",
|
||||||
|
"pid": 177576,
|
||||||
|
"host": "127.0.0.1",
|
||||||
|
"port": 34539,
|
||||||
|
"url": "ws://127.0.0.1:34539",
|
||||||
|
"token": "8FBuSDC3564yKKk5Fpgl6TEknzktQX8W",
|
||||||
|
"startedAt": 1791842537691,
|
||||||
|
"updatedAt": 1791842537691,
|
||||||
|
"stale": false
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"effectMarker":"7b92c148-d616-4eb5-95e8-4e95084bebe9","incarnation":"linux:159085489","pid":177576}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"effectMarker":"7b92c148-d616-4eb5-95e8-4e95084bebe9","incarnation":"linux:159085489","pid":177576}
|
||||||
@@ -166,8 +166,8 @@ pub fn blob_to_f32_vec(blob: &[u8], dim: usize) -> Option<Vec<f32>> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let mut v = Vec::with_capacity(dim);
|
let mut v = Vec::with_capacity(dim);
|
||||||
for chunk in blob.chunks_exact(4) {
|
for chunk in blob.as_chunks::<4>().0 {
|
||||||
v.push(f32::from_le_bytes([chunk[0], chunk[1], chunk[2], chunk[3]]));
|
v.push(f32::from_le_bytes(*chunk));
|
||||||
}
|
}
|
||||||
Some(v)
|
Some(v)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ async fn flush_path_batch(
|
|||||||
#[cfg(feature = "qdrant-index")]
|
#[cfg(feature = "qdrant-index")]
|
||||||
let mut qdrant_points: Vec<ChunkPoint> = Vec::with_capacity(batch.len());
|
let mut qdrant_points: Vec<ChunkPoint> = Vec::with_capacity(batch.len());
|
||||||
|
|
||||||
for ((ord, t), vec) in batch.drain(..).zip(vecs.into_iter()) {
|
for ((ord, t), vec) in batch.drain(..).zip(vecs) {
|
||||||
let dim = vec.len();
|
let dim = vec.len();
|
||||||
let cid = insert_chunk(conn, path, ord, &t)?;
|
let cid = insert_chunk(conn, path, ord, &t)?;
|
||||||
insert_embedding(conn, cid, dim, &vec)?;
|
insert_embedding(conn, cid, dim, &vec)?;
|
||||||
|
|||||||
@@ -826,7 +826,7 @@ mod tests {
|
|||||||
"message[{}] is a ToolResult but message[{}] has no ToolUse: {:?}",
|
"message[{}] is a ToolResult but message[{}] has no ToolUse: {:?}",
|
||||||
i,
|
i,
|
||||||
i - 1,
|
i - 1,
|
||||||
&messages[i - 1].blocks
|
messages[i - 1].blocks
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ impl Default for TridentConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Statistics from a Trident compaction run.
|
/// Statistics from a Trident compaction run.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||||
pub struct TridentStats {
|
pub struct TridentStats {
|
||||||
pub superseded_count: usize,
|
pub superseded_count: usize,
|
||||||
pub collapsed_chains: usize,
|
pub collapsed_chains: usize,
|
||||||
@@ -41,21 +41,6 @@ pub struct TridentStats {
|
|||||||
pub final_message_count: usize,
|
pub final_message_count: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for TridentStats {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
superseded_count: 0,
|
|
||||||
collapsed_chains: 0,
|
|
||||||
messages_collapsed: 0,
|
|
||||||
clusters_found: 0,
|
|
||||||
messages_clustered: 0,
|
|
||||||
tokens_saved_estimate: 0,
|
|
||||||
original_message_count: 0,
|
|
||||||
final_message_count: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl TridentStats {
|
impl TridentStats {
|
||||||
pub fn format_report(&self) -> String {
|
pub fn format_report(&self) -> String {
|
||||||
let compression = if self.final_message_count > 0 {
|
let compression = if self.final_message_count > 0 {
|
||||||
@@ -192,7 +177,7 @@ fn stage1_supersede(messages: &[ConversationMessage]) -> (Vec<ConversationMessag
|
|||||||
|
|
||||||
let mut obsolete_indices: BTreeSet<usize> = BTreeSet::new();
|
let mut obsolete_indices: BTreeSet<usize> = BTreeSet::new();
|
||||||
|
|
||||||
for (_path, ops) in &file_ops {
|
for ops in file_ops.values() {
|
||||||
if ops.len() < 2 {
|
if ops.len() < 2 {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -205,9 +190,9 @@ fn stage1_supersede(messages: &[ConversationMessage]) -> (Vec<ConversationMessag
|
|||||||
|
|
||||||
if let Some(last_write) = last_write_idx {
|
if let Some(last_write) = last_write_idx {
|
||||||
for op in ops {
|
for op in ops {
|
||||||
if op.op_type == FileOp::Read && op.index < last_write {
|
if (op.op_type == FileOp::Read
|
||||||
obsolete_indices.insert(op.index);
|
|| op.op_type == FileOp::Write
|
||||||
} else if (op.op_type == FileOp::Write || op.op_type == FileOp::Edit)
|
|| op.op_type == FileOp::Edit)
|
||||||
&& op.index < last_write
|
&& op.index < last_write
|
||||||
{
|
{
|
||||||
obsolete_indices.insert(op.index);
|
obsolete_indices.insert(op.index);
|
||||||
@@ -325,7 +310,7 @@ fn stage2_collapse(
|
|||||||
usage: None,
|
usage: None,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
result.extend(buffer.drain(..));
|
result.append(&mut buffer);
|
||||||
}
|
}
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
result.push(msg.clone());
|
result.push(msg.clone());
|
||||||
@@ -476,7 +461,7 @@ fn stage3_cluster(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let total_clustered: usize = cluster_assignments.len();
|
let total_clustered: usize = cluster_assignments.len();
|
||||||
let clusters_found = cluster_id as usize;
|
let clusters_found = cluster_id;
|
||||||
|
|
||||||
let mut result: Vec<ConversationMessage> = Vec::new();
|
let mut result: Vec<ConversationMessage> = Vec::new();
|
||||||
let mut cluster_buffers: BTreeMap<usize, Vec<usize>> = BTreeMap::new();
|
let mut cluster_buffers: BTreeMap<usize, Vec<usize>> = BTreeMap::new();
|
||||||
@@ -677,7 +662,7 @@ fn truncate_text(text: &str, max_chars: usize) -> String {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::compact::CompactionConfig;
|
use crate::compact::CompactionConfig;
|
||||||
use crate::session::{ContentBlock, ConversationMessage, MessageRole, Session};
|
use crate::session::{ContentBlock, ConversationMessage, Session};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn stage1_removes_obsolete_file_reads() {
|
fn stage1_removes_obsolete_file_reads() {
|
||||||
@@ -736,7 +721,7 @@ mod tests {
|
|||||||
fn stage2_collapses_chatty_messages() {
|
fn stage2_collapses_chatty_messages() {
|
||||||
let mut messages = vec![];
|
let mut messages = vec![];
|
||||||
for i in 0..6 {
|
for i in 0..6 {
|
||||||
messages.push(ConversationMessage::user_text(&format!("ok {i}")));
|
messages.push(ConversationMessage::user_text(format!("ok {i}")));
|
||||||
messages.push(ConversationMessage::assistant(vec![ContentBlock::Text {
|
messages.push(ConversationMessage::assistant(vec![ContentBlock::Text {
|
||||||
text: format!("got {i}"),
|
text: format!("got {i}"),
|
||||||
}]));
|
}]));
|
||||||
@@ -767,9 +752,9 @@ mod tests {
|
|||||||
},
|
},
|
||||||
]));
|
]));
|
||||||
messages.push(ConversationMessage::tool_result(
|
messages.push(ConversationMessage::tool_result(
|
||||||
&format!("read_{i}"),
|
format!("read_{i}"),
|
||||||
"read_file",
|
"read_file",
|
||||||
&format!(r#"{{"path":"src/{i}.rs","content":"data {i}"}}"#),
|
format!(r#"{{"path":"src/{i}.rs","content":"data {i}"}}"#),
|
||||||
false,
|
false,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user