Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/spark-rsi-mv/blob/main/src/ledger/schema.rs # spark-rsi-mv Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `spark-rsi-mv / src / ledger / schema.rs` 47 lines ยท 1465 bytes Raw Blame History 1 use rusqlite::{Connection, Result}; 2 3 pub fn init_schema(conn: &Connection) -> Result<()> { 4 // 1. Enable WAL mode and synchronous NORMAL for high concurrency durability 5 conn.pragma_update(None, "journal_mode", "WAL")?; 6 conn.pragma_update(None, "synchronous", "NORMAL")?; 7 conn.pragma_update(None, "foreign_keys", "ON")?; 8 9 // 2. Blocks table: append-only sequential ledger 10 conn.execute( 11 "CREATE TABLE IF NOT EXISTS blocks ( 12 sequence INTEGER PRIMARY KEY, 13 block_type TEXT NOT NULL, 14 timestamp_utc TEXT NOT NULL, 15 prev_block_hash TEXT NOT NULL, 16 payload_json TEXT NOT NULL, 17 payload_digest TEXT NOT NULL, 18 blob_hashes_json TEXT NOT NULL, 19 block_hash TEXT NOT NULL UNIQUE 20 );", 21 [], 22 )?; 23 24 // 3. Checkpoints table: signed Merkle tree roots 25 conn.execute( 26 "CREATE TABLE IF NOT EXISTS checkpoints ( 27 up_to_sequence INTEGER PRIMARY KEY, 28 merkle_root TEXT NOT NULL, 29 block_count INTEGER NOT NULL, 30 timestamp_utc TEXT NOT NULL, 31 signature TEXT 32 );", 33 [], 34 )?; 35 36 // 4. Blobs index table: content-addressed blob metadata 37 conn.execute( 38 "CREATE TABLE IF NOT EXISTS blobs_index ( 39 digest TEXT PRIMARY KEY, 40 size_bytes INTEGER NOT NULL, 41 created_at TEXT NOT NULL 42 );", 43 [], 44 )?; 45 46 Ok(()) 47 }