feat(store-sqlite): add truncate_embedding_records helper
Wipes every row from embedding_records and returns the deleted row count. Used by the upcoming `kebab reset --vector-only` to keep SQLite consistent after the on-disk Lance store is removed. Plan deviation from the original spec (task 1): - Original test plan opened SqliteStore with a raw path; the actual signature is `SqliteStore::open(&Config)`, so the integration test builds a Config with `storage.data_dir` pointed at a tempdir. - Original return type was Result<()>; bumped to Result<u64> so the caller (kebab-app::reset) can surface the truncated count in the reset_report.v1 wire payload without a separate COUNT query. p9-fb-06 task 1. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -107,6 +107,22 @@ impl SqliteStore {
|
||||
/// WHERE embedding_id IN (?, ?, …)`) inside one transaction —
|
||||
/// avoids the per-row `execute()` round-trip the previous
|
||||
/// implementation paid.
|
||||
/// Wipe every row from `embedding_records`, returning the count of
|
||||
/// rows that were removed. Called by `kebab reset --vector-only` so
|
||||
/// SQLite cannot point at a Lance row that the reset just removed
|
||||
/// off-disk.
|
||||
///
|
||||
/// The function does NOT cascade to `chunks` or `documents` — those
|
||||
/// are kept so the next `kebab ingest` re-embeds the existing chunk
|
||||
/// set without re-parsing.
|
||||
pub fn truncate_embedding_records(&self) -> Result<u64> {
|
||||
let conn = self.lock_conn();
|
||||
let n = conn
|
||||
.execute("DELETE FROM embedding_records", [])
|
||||
.context("DELETE FROM embedding_records")?;
|
||||
Ok(n as u64)
|
||||
}
|
||||
|
||||
pub fn mark_embedding_records_committed(
|
||||
&self,
|
||||
embedding_ids: &[String],
|
||||
|
||||
Reference in New Issue
Block a user