An SQL database for Go that stores everything in S3. Written by agents, trusted with simulation testing.
s4ql is an embedded database engine in the spirit of SQLite. Your Go application talks to the bucket directly, and there is no server to run. Every line of it is written by AI agents, and no human reviews the code. Trust has to come from verification.
- Experiment
- Storage built
- First SQL built
- Not ready for use
Why it exists
Two experiments in one repository. One is a database that needs nothing but object storage. The other is whether software that nobody reads can still be trusted.
- Nothing to operate
- Your Go application talks to S3 directly through the module. There is no server, no cluster, and no replica to look after. The bucket is the only infrastructure and the source of truth.
- A database per user
- Each database is a key prefix, so one bucket holds as many databases as you like. One database per user costs nothing extra, and write-heavy work spreads across them.
- SQLite's SQL, strictly
- s4ql speaks a strict subset of SQLite's SQL. Whatever it accepts behaves exactly as in SQLite. Everything else is rejected, never reinterpreted.
- Trust without reading
- AI agents write and own the code. Markus sets the goals and takes part in design and architecture; he does not review code. The bet is that a database can earn trust when its correctness is checked, not read.
What it does
A database in S3 is a log. Each commit is an immutable object named by the SHA-256 of its content and linked to its parent, as in git. One small file, manifest.json, points at the newest commit. Swapping that pointer is the commit.
manifest.json
{
"version": 0,
"branches": {
"main": {
"head": "d39febcf6aba…"
}
},
"lease": {
"holder": "5b0e3a4f9c1d77c3",
"duration": "30s",
"renewed": "2026-11-12T12:00:30.123Z",
"salt": "c41d07a9e2b35f68"
}
}
A compare-and-swap replaces this file. The transaction is committed when the swap succeeds, and not before.
Illustration. Each bar code is the 256 bits of a real SHA-256, taken over sample content. A real commit object records the rows it changed, with the SQL kept beside them as a note.
- Transactions
- ACID within one database. No transaction spans databases.
- Writes
- One write transaction at a time per database. A second writer waits until the first has committed or rolled back.
- Reads
- In parallel, from a local SQLite cache, without contacting S3. Each read sees one consistent state, even while a write is in progress.
- Cache
- Holds the same tables and rows as the database, is never ahead of S3, and can be rebuilt from the log at any time.
- Lease
- One instance at a time holds the database's lease, recorded in the manifest. It lasts 30 seconds and is renewed every 20. A spare instance waits and takes over when the lease times out.
- Unknown outcome
- If the swap ends without an answer, the instance asks S3 until it knows. The transaction is committed if and only if its commit object is in the log.
- S3 must offer
- Strong consistency, compare-and-swap, and create-if-absent.
- Interface
- Go's
database/sql.
How it is built
Agents write the code and nobody reviews it, so the tests have to show that it works. The production code runs unchanged inside a simulation where S3, time, and randomness are driven by one seed. The same seed always replays the same run, failures included.
- Deterministic simulation
- S3, clocks, and randomness are reached only through interfaces. One seed controls a whole run, so any failure the simulation finds can be replayed exactly.
- Buggify
- Marked points in the production code do something legal but unusual in simulation: return an error, add a delay, take a rare branch. Each run switches on a different subset.
- SQLite is the oracle
- s4ql writes its own parser and engine, and checks them against SQLite. Results and errors are compared with SQLite's, and the parser is run on SQLite's own test statements.
- Real S3
- A conformance suite and integration tests run against a real S3-compatible bucket on Tigris, to check that the simulated store behaves like the real one.
- Tests that test the tests
- Property-based tests, fuzzing, and mutation testing. Bugs are planted on purpose to count how many seeds the simulation needs to find each one.
- Everything written down
- The spec, the research, the builders' diaries, and the conversations behind each decision are in the repository.
Status
As of 23 November 2026. s4ql is an experiment. It is not ready for use, and anything in it may change.
| Works now |
Through
|
|---|---|
| Checked | Against SQLite with generated statements, in the engine and through |
| Not built |
|
| Next | The rest of the SQL that glue needs, agreed one slice at a time (the roadmap's milestones). The slices, and how each is checked, are in the roadmap. |
Roadmap
SQL grows in small slices. Nothing is supported until it is listed, all the way down to select 1, and each slice goes through every layer and is checked against SQLite before the next one starts.
- Built
- Agreed, not built
- Open
-
Built
Storage core
The log of commit objects, the manifest swap, the lease, crash recovery, and the local cache.
-
Built
S3 client
Uploads are signed with the commit object's SHA-256, so the store refuses content that does not match it.
-
Built
Tokenizer
The first piece of the SQL front end.
-
Built
Parser
s4ql's own parser for all of SQLite's grammar. It agrees with SQLite on which statements parse, on the message of each syntax error, and on the shape of the syntax tree.
-
Built
The pass after the parser
It rejects whatever the roadmap does not list, and it raises the errors that SQLite's grammar actions raise while they parse.
-
Built
Slice 1: one integer column
create table,insert,select *, anddrop tableon a strict table with oneint primary key. The answers must survive a restart with an empty cache. -
Built
The driver
A
database/sqldriver as the main interface. -
Built
Slice 2: parameters
A plain
?in the place of the integer literal of aninsert, with a Go integer as the argument, directly and through a prepared statement. The number of arguments must equal the number of?. -
Built
Slice 3: transactions
db.BeginTxbegins a write transaction, which holds the place of the single writer until it commits or rolls back, or a read-only one withsql.TxOptions{ReadOnly: true}, which reads the state of its beginning and holds up no one. A transaction writes one commit object. -
Built
Slice 4: the other types
The column types
int,integer,real,text, andblob, with their literals and Go arguments. A value must have the exact type of its column. -
Built
Slice 5: several columns
A table with several columns: one primary key, and the others
not null. Aninsertgives the columns in the table's order or names them in any order, and aselectnames the columns it returns. -
Built
Slice 6:
nullColumns that take null: the literal
null, a nil argument, and a column left out of aninsert. A null comes back as nil. -
Built
Slice 7:
whereonselectA column compared with a literal or a
?,is null, andis not null, joined withand. -
Built
Slice 8:
updateanddeleteupdate ... setwith literals,null, and?, anddelete from, each with or without thewhereof slice 7.RowsAffectedgives the rows that SQLite reports as changed. -
Built
Slice 9: indexes
create indexon one or more columns, eachascordesc, anddrop index. The log holds only the definition, and the cache holds a real SQLite index. s4ql picks the index by fixed rules, so the choice is the same on every instance, and rows withoutorder bycome in an order that varies from query to query. The statements run, and generated queries run through every path that can serve them. -
Built
Slice 10:
if not existsandif existscreate table if not existsdoes nothing when the table exists, anddrop table if existsdoes nothing when it does not, and the same for indexes. A statement that does nothing writes nothing to the log. The statements run, and generated sequences check them against SQLite. -
Built
Slice 11:
defaultwith a literalA column may carry
defaultwith a literal ornull, and aninsertthat leaves the column out stores it. The commit format changes: a column carries its default. The statements run, and generated sequences check them against SQLite. -
Built
Slice 12: a value on the left of a comparison
In a
where, a comparison may have a literal or?on the left and the column on the right, such as? >= timeout. The primary key and the indexes are used as for the other order, and the commit format stays as it is. The statements run, and generated sequences check them against SQLite. -
Built
Slice 13:
order byandlimitselecttakesorder bywith one or more columns, eachascordesc, andlimitwith a number or?. Where the engine sorts, rows that tie come in an order that varies from query to query. The commit format stays as it is. The statements run, and generated ordered and limited queries are compared with SQLite up to ties, the engine's choice is compared with a model of the rules, and a check shows that the order SQLite leaves unspecified varies. -
Built
Slice 14:
returningoninsert,update, anddeleteAn
insert, anupdate, or adeletemay end withreturningand a list of columns or*. It gives one row for each row that it changes. Outside a transaction, the statement commits before it gives its first row. The commit format stays as it is. The statements run, and table tests compare them with SQLite, and through the driver with mattn/go-sqlite3, with goqite's send and its receive by id among them. Generated sequences withreturningrun in the engine's differential tests and in the driver's against mattn/go-sqlite3, and the simulation checks that the rows a caller read belong to a committed change and finds the planted bugs. Mutation testing of the new code left no mutant unexplained. -
Open
More SQL, slice by slice
Each slice is agreed before it is built. Every table is strict and without rowid, foreign keys are always enforced, and a name is never empty.
-
Open
Storage format version 1
The formats are drafts until then. From version 1 on, every version of s4ql reads what any older version wrote.
Inspired by
s4ql builds on ideas from other databases and storage engines. How each idea works in its own project is written up in docs/inspiration.md.
- SQLite
- The embedded database s4ql is modelled on. s4ql speaks a subset of its SQL, checks its own answers against it, and uses it for the local cache.
- FoundationDB
- A distributed, transactional key-value store, tested in deterministic simulation. s4ql's simulation and its buggify points follow its example, and so does the rule that an application checks its own data after an unknown commit outcome.
- Graft
- A storage engine in Rust that replicates SQLite pages to object storage as an append-only log of commits, with no server in between.
- SlateDB
- An embedded key-value store in Rust that keeps all its files in object storage, with a manifest that lists the current state of the database.
- Turbopuffer
- A search service where object storage is the only source of truth and each namespace is a prefix in the bucket, with caches in memory and on disk in front of it.
- Litestream
- A tool in Go that replicates a SQLite database to object storage from its write-ahead log, and a SQLite plugin that queries the copy in object storage directly.
Follow along
The code, the spec, the open questions, and every conversation behind the decisions are public. Watch the repository to see whether a database written by agents can earn trust.
maragudk/s4ql on GitHub