The ledger: SQLite, frozen envelope with hash chain, proofs and HLC, signed checkpoints, verify issue #3 closed: completed andymccall opened this · 1 comment
andymccall set labels feature ·
andymccall set milestone Sprint 1 ·
andymccall edited ·
andymccall referenced by change 36537112fcac on main ·
Done: the ledger in crates/spectra-core. Events are deterministic CBOR through oxy-core, hashed as BLAKE3("spectra1 event " || len || 0 || body) and chained by prev; the envelope with its hybrid logical clock is frozen (a test asserts the field set). The instance key signs a checkpoint every 256 events (exactly, even mid-batch), every ten minutes while writing, and on demand, through oxy-core's challenge signing with a spectra1 checkpoint prefix. spectra admin verify [--json] catches an edited row, an edit with its hash recomputed, a removed row, and a checkpoint signed by another key; admin check and rebuild hold projections to the ledger over 10,000 random events. Measured in release: 0.15 ms a single append (target 10 ms). Also: make check and the pipeline now test and lint Spectra's own packages only, as --workspace was running oxy-core's 379 tests.
andymccall closed ·
The core of Spectra: an append-only ledger in SQLite, tamper-evident the way Oxygen's history is, with everything else a projection of it (spec §9, §9.5).
spectra-core::store: opens<data>/spectra.db(WAL,synchronous=NORMAL, foreign keys), applies sqlx migrations, refuses a database from a newer version.seq, ULIDid,at_ms,hlc(a hybrid logical clock with the five-minute drift bound, oxygen spec §6.4),prev(the previous event's hash),hash(deterministic CBOR throughoxy-core, hashed asBLAKE3("spectra1 event " || len || 0 || body), oxygen spec §5.1 and §5.2) andauth(key, method, assurance, proof). Projections update in the same transaction; events are published on the bus after commit.ledger.checkpoint { seq, hash, hlc, count }signed by the instance identity every 256 events, every ten minutes while writing, and at shutdown.spectra admin verify: recomputes every hash andprev, verifies every proof against the identities and delegations in the ledger at that event'shlc, verifies every checkpoint; reports breaks, unproven events, since-revoked delegates; exit 1 on any.seq,id,at_ms,hlc,prev,hash,auth,kind,actor,session,project,subject,payload,trace) is frozen from this release. A test asserts the field set so it cannot drift, and a test edits a row in SQLite and showsverifycatching it.spectra admin rebuildandadmin check. A projection-equality harness (append a random mix, rebuild, compare every table) that every later scenario test uses.Depends on
oxy-core(pinned as a subrepo underdeps/, as oxygenhub pins its dependencies) for identities, signatures, encoding and hashing. Never reimplement those.Done when the harness passes over 10,000 random events, appending stays under 10 ms with fsync, and an edited row is caught. After issue #1.