Add versioned script library, reconcile permit refusals and compact helper captures

This commit is contained in:
2026-11-17 15:45:56 +01:00
parent a576c10e8a
commit 8e2fef7007
29 changed files with 1225 additions and 50 deletions
+14
View File
@@ -1038,6 +1038,20 @@ fn initialize(db: &Connection, binding: &Binding) -> Result<()> {
CREATE TABLE IF NOT EXISTS helper_sync_rows(grant_id TEXT PRIMARY KEY,revision INTEGER NOT NULL,fingerprint TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS helper_sync_captures(checkpoint INTEGER PRIMARY KEY,snapshot BLOB NOT NULL,fingerprint TEXT NOT NULL,captured_at TEXT NOT NULL);
CREATE TABLE IF NOT EXISTS helper_sync_decisions(decision_id TEXT PRIMARY KEY,checkpoint INTEGER NOT NULL,response BLOB NOT NULL,request BLOB NOT NULL,fingerprint TEXT NOT NULL);")?;
let legacy_captures: bool = db.query_row(
"SELECT EXISTS(SELECT 1 FROM sqlite_schema WHERE type='table' AND name='helper_sync_captures')",
[], |row| row.get(0),
)?;
if legacy_captures {
// initialize runs under the snapshot transaction; savepoint also makes
// the schema change atomic for callers that initialize independently.
db.execute_batch("SAVEPOINT helper_capture_schema")?;
if let Err(error) = db.execute_batch(include_str!("helper_capture_storage.sql")) {
db.execute_batch("ROLLBACK TO helper_capture_schema; RELEASE helper_capture_schema")?;
return Err(error.into());
}
db.execute_batch("RELEASE helper_capture_schema")?;
}
let binding_hash = hash(&serde_json::to_vec(binding)?);
db.execute(
"INSERT OR IGNORE INTO helper_sync_meta(id,journal_id,binding_sha256) VALUES(1,?1,?2)",