interplane.Get Omega
Read in your language

spark-rsi-mv

Native Rust recursive self-improvement engine with paired bootstrap evaluation and cryptographic ledger

Brought by drakestapleton

[MOVEMENT] Bound per-cycle checkpoint work without reloading all historical receipt payloads

Open · #71 · open 2026-10-24 17:49 UTC

Imported from GitHub aien-dev/spark-rsi-mv#71, by drakestapleton

drakestapleton wrote on 2026-10-24 17:49 UTC

Evidence:

  • all_blocks selects and materializes every full payload and parses each blob list.
  • checkpoint needs only block hashes/count/last sequence, clones the hashes and rebuilds the whole Merkle tree.
  • compute_merkle_root repeatedly clones/allocates hex String levels; odd nodes duplicate the right child and hashes consume ASCII hex, not raw digest bytes.
  • soak checkpoints each cycle and again at completion.

For initial b0 blocks and constant k new blocks per completed cycle, c cycles visit sum_i(b0+ki) = cb0 + kc(c+1)/2 historical rows, plus final checkpoint. With constant average serialized payload size S, unnecessary payload materialization scales as S times that sum. This is a source-level cost model, not measured disk traffic (SQLite/page cache matter).

Stage 1: query only required sequence/hash columns in a consistent snapshot, preserve checkpoint semantics. Stage 2 only after measured need: append-maintained Merkle frontier or cached internal nodes, transactionally bound to exact ledger prefix; reconstruct/verify on restart, fail closed on cache/head mismatch. Preserve root bytes, duplicate-last behavior and hash encoding at every prefix. A faster new Merkle format requires explicit versioning, never silent conversion.

Tests:

  • Prefix-by-prefix root/signature parity against current function for 0/1/2/3 and sizes around powers of two, variable batches, restart and concurrent append.
  • Corrupted payload/hash/link/blob/checkpoint, wrong key, stale frontier, crash between append/cache/checkpoint, and non-tip checkpoint all retain refusal/coverage semantics.
  • Record rows materialized, payload bytes decoded, allocations, peak RSS, hash calls, DB page reads separately, and median/p95 checkpoint/soak wall time for growing histories.
  • Independent full-chain/blob audit remains authoritative and still revalidates evidence; optimizing checkpoint construction is not permission to skip verification.
  • Existing #50/PR #51 fix non-tip checkpoint correctness and disclosure, already present at audited pin. Do not reopen that bug. Current open PR #69 is evaluation fixtures, no conflict seen.

No measured speedup, implementation or deployment claimed. Follow existing ledger/signing authority and Omega migration decisions.

drakestapleton wrote on 2026-11-06 20:44 UTC

Stage 1 only (narrow checkpoint query). Stage 2 (Merkle frontier or cache) is not started.

Branch fix/issue-71-checkpoint-hash-query, head a708ac977ea014558c1c536ef7b0a44507663f6c (base main 7e8bf7da). A draft PR has been requested through the PR desk.

Change: checkpoint now reads SELECT sequence, block_hash FROM blocks ORDER BY sequence ASC (one statement, one read snapshot) and holds the connection lock across that read and the checkpoint insert, instead of calling all_blocks(). Merkle format, root bytes, duplicate-last behavior, hash encoding, signature and the empty-ledger refusal are unchanged. verify_chain_integrity keeps all_blocks (the audit needs every payload) and still refuses a corrupted payload.

Spark host evidence (taskset -c 6 nice -n 10 bwrap ... cargo test --locked --test test_cryptographic_improvement_ledger checkpoint_):

  • before (main db.rs + new tests): rc 101, test result: FAILED. 3 passed; 1 failed — test_checkpoint_does_not_materialize_payloads: checkpoint must not read payloads: "Invalid column type Blob at index: 4, name: payload_json"
  • after (branch): rc 0, test result: ok. 4 passed; 0 failed
  • negative control (branch with checkpoint pointed back at all_blocks(), uncommitted): rc 101, same failure
  • parity: root, count, sequence and p256 signature identical to the all_blocks path at prefix sizes 0,1,2,3,4,5,7,8,9,16,17 (size 0: same refusal): PASS
  • full suite: 339 passed, 3 failed; the 3 failures fail identically with main's db.rs on the same host (pre-existing). fmt, crumb-verify (CI pin 12ad0141) and zero-disk-secrets: rc 0.

Labels: IMPLEMENTED, EXERCISED (host). GitHub CI on the head: NOT_RUN (PR desk gate). No speedup measured or claimed; host results are not hardware evidence.

Sign in to comment