Skip to content

Commit d843a5f

Browse files
committed
feat: update specs
1 parent bc02fce commit d843a5f

6 files changed

Lines changed: 48 additions & 12 deletions

File tree

.kiro/specs/ci-multi-platform/spec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"phase": "implementation",
66
"language": "ru",
77
"created": "2026-07-14",
8-
"updated": "2026-07-14"
9-
}
8+
"updated": "2026-07-15"
9+
}

.kiro/specs/code-anchors-cross-repo/spec.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
"language": "ru",
77
"priority": "P0",
88
"effort": "XL",
9-
"depends_on": ["trace-graph-db"],
9+
"depends_on": [
10+
"trace-graph-db"
11+
],
1012
"wave": 2,
1113
"created": "2026-07-11",
12-
"updated": "2026-07-14"
13-
}
14+
"updated": "2026-07-15"
15+
}

.kiro/specs/kq-dual-mode/spec.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@
55
"phase": "implementation",
66
"language": "ru",
77
"approvals": {
8-
"requirements": { "generated": true, "approved": true },
9-
"design": { "generated": true, "approved": true }
8+
"requirements": {
9+
"generated": true,
10+
"approved": true
11+
},
12+
"design": {
13+
"generated": true,
14+
"approved": true
15+
}
1016
},
1117
"created": "2026-07-14",
1218
"updated": "2026-07-15"
13-
}
19+
}

.kiro/specs/trace-graph-db/spec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"depends_on": [],
1010
"wave": 1,
1111
"created": "2026-07-11",
12-
"updated": "2026-07-11"
13-
}
12+
"updated": "2026-07-15"
13+
}

kq-core/src/vector.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ use std::collections::HashMap;
22
use std::sync::Once;
33

44
use anyhow::{Context, Result};
5-
use rusqlite::Connection;
65
use sqlite_vec::sqlite3_vec_init;
6+
use rusqlite::Connection;
7+
use rusqlite::ffi as sqlite_ffi;
78

89
const EMBEDDING_DIM: usize = 384;
910
static REGISTER_VEC_GLOBAL: Once = Once::new();
1011

1112
/// Register vec0 globally (for future connections) and directly on this connection.
1213
pub fn register_vec_on_connection(db: &Connection) -> Result<()> {
1314
REGISTER_VEC_GLOBAL.call_once(|| unsafe {
14-
rusqlite::ffi::sqlite3_auto_extension(Some(std::mem::transmute::<*const (), _>(
15+
sqlite_ffi::sqlite3_auto_extension(Some(std::mem::transmute::<*const (), _>(
1516
sqlite3_vec_init as *const (),
1617
)));
1718
});
@@ -105,6 +106,7 @@ pub fn reindex_embeddings(conn: &Connection) -> Result<usize> {
105106
Ok(changed.len())
106107
}
107108

109+
108110
#[cfg(test)]
109111
mod tests {
110112
use super::*;

kq-core/src/vector_add.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
pub fn register_vec_on_connection(db: &Connection) -> Result<()> {
2+
REGISTER_VEC.call_once(|| unsafe {
3+
rusqlite::ffi::sqlite3_auto_extension(Some(std::mem::transmute::<*const (), _>(
4+
sqlite3_vec_init as *const (),
5+
)));
6+
});
7+
unsafe {
8+
type F = unsafe extern "C" fn(*mut rusqlite::ffi::sqlite3, *mut *mut std::os::raw::c_char, *const std::ffi::c_void) -> i32;
9+
let ptr: *const () = sqlite3_vec_init as *const ();
10+
let f: F = std::mem::transmute(ptr);
11+
let rc = f(db.handle(), std::ptr::null_mut(), std::ptr::null());
12+
if rc != 0 { anyhow::bail!("vec0 init failed: {}", rc); }
13+
}
14+
Ok(())
15+
}
16+
17+
pub fn reindex_embeddings(conn: &Connection) -> Result<usize> {
18+
let changed: Vec<(i64, String, String)> = conn.prepare(
19+
"SELECT f.id, f.path, f.content_hash FROM files f
20+
LEFT JOIN vec_chunks vc ON vc.file_id = f.id AND vc.content_hash = f.content_hash
21+
WHERE vc.rowid IS NULL"
22+
)?.query_map([], |row| Ok((row.get(0)?, row.get(1)?, row.get(2)?)))?.filter_map(|r| r.ok()).collect();
23+
if changed.is_empty() { return Ok(0); }
24+
for (fid, _, _) in &changed { conn.execute("DELETE FROM vec_chunks WHERE file_id = ?1", rusqlite::params![fid])?; }
25+
Ok(changed.len())
26+
}

0 commit comments

Comments
 (0)