Repository navigation
Releases: theoriclabs/LeanDB
Release list
LeanDB 0.5.1
- Schemas of more than fifteen entities (#139).
schema%, and
native_schema%through it, generatedIsSchema.packas amatchon
Finliterals, which Lean's match compiler rejected with "Missing
cases" from about the sixteenth entity on.packnow indexes an array
of the packed entities, so a schema of any size elaborates. The model
suite declares a twenty-entity schema and writes and reads its first and
last tables on SQLite.
Lean 4.33.0, leansqlite, and leanontology are unchanged.
Validation: ./scripts/release_check.sh passed, including the engine, DDD and model suites, precompiled consumers, examples, dashboard, scaffolding/import, and HTTP/MCP/host checks; the DDD negative fixtures were rejected as expected. Linux and macOS CI passed.
LeanDB 0.5.0
Portable domain models, typed read and transaction programs, and the
LDB-12 through LDB-24 engine improvements. Lean remains at 4.33.0;
leansqlite is unchanged and leanontology is pinned to
322a4c12631dd8ece6ae9841a5e6b630d08d1e3b.
-
Portable model.
LeanDb.Modeldescribes entities, checked value
types, unique and cascade constraints, links,Changes, andDB/
Queryprograms without importing SQLite. The same programs run in
memory and on SQLite throughLeanDb.Native,native_schema%, and
derive_requirements. Structured and represented values can occupy
one column. The domain bridge also checks native storage evidence and
typed migration requirements. -
Typed API. The typed layer provides schema-indexed queries, validated
reads, typed write errors, and transaction programs with a pure meaning.
Differential tests compare that meaning with SQLite execution; the
preservation laws and their remaining gaps are documented in
the typed interface guide. -
Reliability. HTTP dispatch and host handshakes are bounded; hosted
child processes are cleaned up on failure. Restore respects writer
locks, migration errors restore connection settings, custom migration
steps cannot escape the engine transaction, and backup names avoid
collisions. MCP validates arguments and does not reply to notifications.
Seeding refuses a non-empty catalog unless forced; scaffolding and
import generation validate and escape names and preserve existing files. -
Packaging. Example and benchmark lockfiles include the pinned
leanontologydependency. The engine, portable model, and SQLite model
interpreter have separate Lake libraries, so precompiled client adapters
can load the engine without undeclared model dependencies. Shared-library
names match Lean module initializers so native model consumers also load
their dependencies in the correct order. -
M15b3.
Txn.update_wf,Txn.set_wf,Txn.append_wf: on aWF
state,update,setandappendyield aWFstate whether they
succeed or fail (HasPack,LawfulEntity). Unique keys compare with
Unique.keyClash a b := a == b || b == a, symmetric by construction:
Float.beqisextern, soArray Colequality is not provably
commutative. It agrees with IEEE and SQLite (-0.0 = 0.0; SQLite has
no NaN).patchanddeletehave no WF lemma yet; the remainder is
indocs/typed-interface.md. -
M15b2.
Table.nextOk(1 ≤ next ≤ natSqlMax + 1) is inTable.check.
assigndoes not wrapInt64.ofNat.DbState.empty_wf.
Txn.insert_wf: on aWFstate,insertyields aWFstate
whether it succeeds or fails (HasPack,LawfulEntity). Part 1's
Txn.denote_wfis renameddenote_wf_of_unchanged; the name
denote_wfis reserved for the whole-program law (remainder). -
M15b. Laws LeanAPI theorems need, in
LeanDb/Typed/Laws.lean.
Exact plans are denotational (approx.denote = pred.denotewhen there
is no opaque leaf). Aggregates arecount = size ∘ rows,
exists = !isEmpty ∘ rows,first = head? ∘ rows. Codecs carry
LawfulColCodec.roundTripandLawfulSqlOrd.order_toCol;Natis
bounded tonatSqlMax. Reads do not write (Txn.ReadOnly). Failure
exactness isiffagainstfirstDuplicate/firstMissingRefin
declaration order. Table frames (get_set_otherlifted to each write)
and query frames (denote_eq_of_admitted, including joins). Remainder
is listed indocs/typed-interface.md. -
M15a. Meaning agrees with SQLite on the M14 review findings D1–D10.
Child lists are inDbState.snapshot; two-level cascade already
agreed (deleteAt);Option (Ref)is a typed FK and child-list
Refs are refused atschema%;appendCAS compares list contents
and checks parent unique/FK;orderBypushes SQL only forSqlOrd
(closed enums sort in Lean);Currenthas a private constructor;
NataboveInt64.maxis notChecked;firstafterlimit := 0
isnoneand huge windows apply in Lean; a join keeps a left-side
quantifier; mixed-invariantpatchisSetError.invalid;
UpdateError.staleBEqcompares payloads; issued ids are positive
(Id.toNat,Table.refsOk).LeanDb.ExecutesAsMeaning sis the
named hypothesis for LeanAPI (not an axiom). Harness: 572 fixed-seed
cases. Docs:docs/typed-interface.md. -
M15-pre.
DbStateis a lawful(t : Fin nTables) → Table (pack t).ty
with nounsafe/implemented_byinLeanDb/Typed.get/set/
loadare the executed definitions;get_set_same,get_set_other,
empty_rows, andinsert_team_on_emptyare proved.Read.get/
lookupreturnValid α(invariant proof; coerces toStored);
Txn.update/appendtake that proof plusCheckedso callers need
not re-check.deleteAtis fueled byrowCount(nopartial).
exact_planis kernel-reducible (decide, notnative_decide).
scripts/CheckAxioms.leanallowlistspropext/Classical.choice/
Quot.sound. Harness compares productionloadtodenotethrough
lawfulget. -
M15-pre (part 2).
Table.rows : List (Valid α)so read evidence
is by construction (Has.entity_eq/Table.cast).Read.first/
all/pageanswerValid α(joinsValid α × Valid β);
Query.fromstaysStored. Decode-time invariant failure is
DbFault.corruption.deleteAterases before walking (fuel =
rowCountsuffices on a finite cascade graph). LeanAPIwriteStep's
invariantifcan be deleted:Read.firston a filtered query
already returnsValid.TestsM14c.leanrandom harness: 100 cases
covering field-subsetpatch, cascade delete, and exact joins. -
M14c. Close remaining QUERIES.md §3 / §5 gaps:
patchwrites only
the named fields (meaning merge and SQLUPDATE);SetErrorlists
only constraints over written fields (Unique.Touching/
ForeignKey.Withinreduce toEmpty); window/first/count/exists
refuse a non-exact plan at elaboration; FKjoinis a SQLJOIN;
decidableDbState.checkWF(harness after every successful write);
Runtime.Service.runReadon a reader snapshot andrunTxnon the
writer; per-FKON DELETERESTRICT or CASCADE (cascade%), mirrored
in SQLite, meaning, andDeleteError.Restricting. Tests in
TestsM14c.lean. Remaining deviations are listed in
docs/typed-interface.md. -
M14b. Typed writes and transaction programs: schema-derived
InsertError/UpdateError/SetError/AppendError/
DeleteError,Txn σ s ε αwith ST-styleCurrent σ α,Txn.denote
andTxn.run(BEGIN IMMEDIATE, SAVEPOINT per write, constraints
checked in declaration order), and an execution-equals-meaning harness
(LeanDb/Typed/Harness.lean,TestsM14b.lean). -
LDB-24.
readSnapshotis public: a deferredBEGIN DEFERRED
snapshot for multi-statement reads, so adapters need not rebuild one. -
LDB-23.
Pred.Snapshot.rowsfails on an undecodable row instead of
dropping it (which madeforallvacuously true over corrupt data). -
LDB-22.
count/exists?apply the lambda, not only the plan, so
a residual (or a hand-written.ttplan) cannot overcount.countP/
existsPstill pushCOUNT(*)/EXISTSfor exact plans. -
LDB-21.
patchrefuses a guard that contains an opaque leaf.
Opaque used to render as true, so a residual false guard still wrote. -
LDB-20. Multi-statement verbs that join an outer transaction run
under a SAVEPOINT, so catching their error and committing cannot keep
partial effects. -
LDB-19.
Runtime.Service.withReaderlocks each pooled connection
and never hands out the writer.readers := 0still opens one
dedicated read-only slot, so a reader cannot write and two callbacks
cannot share one SQLite handle. -
LDB-18.
Natcolumns are bounded to0 … Int64.maxValue. Writes
of a largerNatare.decode; a comparison bound outside that range
renders as a tautology or contradiction instead of wrapping, so
select (·.n < 2^64)agrees with its meaning.SqlOrd Natstays. -
LDB-17.
selectP/existsPapplyLIMIT/OFFSETafter the
residual Lean filter unless the plan is exact (and not a join). A
pushed window on theapproxsuperset can no longer hide a later
matching row (existsPfalse negatives, short pages). -
LDB-15 (#129).
append old new: grow an entity's child lists against
the value that was read. Only the added child rows are written, at the
positions after the stored ones; the parent's columns are written under
update's compare-and-swap. A list that moved on since the read, or a
parent that did, is.stale, in one connection or across processes
(BEGIN IMMEDIATE, backed by the(parent, position)UNIQUE index). A
list that does not continue the stored one is.notAppend.update's
docstring now says plainly that its CAS does not see child lists. -
LDB-16 (#130). Entity invariants.
@[leandb_invariant] def T.invariant : T → Bool, declared beforederiving instance LeanDb.Entity for T, is
checked on every read (after the child lists are attached) and before
every write (insert,insertMany,update,patch,append). A row
that fails is.invariant table name: never returned, never stored. The
attribute refuses a check declared afterEntity Texists. The name is
part of the schema:TableSpec.invariant,schema_json, the fingerprint
(table:invariant=<name>; unchanged for a table without one), and a
journaledrestampInvariantmigration step. -
Freeze (#131). Frozen snapshots are written with named fields and
includeindexesandinvariant. Since 0.4.0 they were written as
⟨name, #[…]⟩, which does not compile against a three-field
TableSpec. The legacy example's snapshots are updated. -
Breaking.
TableSpechas a four...
LeanDB 0.4.0
LeanDB 0.4.0 lands the LeanGD engine surface (LDB-01 … LDB-11). Defaults stay byte-identical to 0.3.x (synchronous=FULL, 5s busy timeout, audit log .all).
- LDB-01.
transaction/withTransaction/untrackedSqliteandLeanDb.Runtime.Service:BEGIN IMMEDIATEat depth 0, savepoints when nested, typed.abort, poisoned connections after a failedROLLBACK, serializedwithConnection,drain/resume/snapshot/restore/close. - LDB-02.
OpenConfig(synchronous,cache_size,mmap_size,wal_autocheckpoint, allowlistedextraPragmas) plusLEANDB_*environment overrides. - LDB-03.
Indexes αdeclares indexes and composite UNIQUE constraints; they appear in DDL,schemaJSON, the fingerprint, andmigrateadd/drop plans. Child tables get(parent, position) UNIQUE. - LDB-04.
selectPtakes a pushedOrderandWindow(LIMIT/OFFSET); a Lean-side sort plus a limit is refused. Tie-break is, id ASC. - LDB-05.
LogConfig.verbs(all/failuresAndPlans/failuresOnly/none) andsampleEvery; CLI default remains.all. - LDB-06.
count/countP/exists?/existsPpushCOUNT(*)/EXISTSwhen the predicate has no residual. - LDB-07. Typed
patchwith aPredguard;PatchResultis.updated/.notFound/.guardFailed. - LDB-08.
insertManyand keysetscan. - LDB-09.
Runtime.Config.readersandService.withReader; write verbs on a read-only connection returnDbError.readOnly. - LDB-10.
deriving instance LeanDb.ClosedEnum/DbJson/Inlineworks post-hoc on LeanDB-free domain types. - LDB-11. Extra tables in a fingerprinted instance are tolerated;
Base.auxiliarydeclares FTS5 objects;searchPbindsMATCH.
Also in this release: JSON true/false only on Bool columns; colliding table names are refused; --db is taken only before the verb; WAL + deferred snapshots; HTTP Host/Origin pin and JSON Content-Type requirement; restore-safety path shared with the runtime.
Lean 4.33.0 and the pinned SQLite dependency are unchanged.
Validation: lake build LeanDb, lake build leandb, and .lake/build/bin/leandb_tests (all engine tests passed).
LeanDB 0.3.1
LeanDB 0.3.1 adds a practical documentation set and cleans up the examples.
- Read the core concepts guide, glossary, and roadmap.
- The README is shorter and includes the architecture diagram. Example READMEs replace the old CLI transcripts.
- The old proposal directory and the Gpus, Kernels, and Pricewatch examples have been removed. Release checks now cover the remaining packages.
- This release also includes the typed HTTP client integration and pinned dashboard dependency added after the 0.3.0 tag. HTTP clients use the separate
leandb-httpadapter.
Lean 4.33.0 and the pinned SQLite dependency are unchanged.
Validation: the full release check passed, the guide's Lean examples compile, and all 48 local documentation links resolve.