Repository navigation
Description
Research. Where chant keeps records over time, and what could replace the chant/lifecycle orphan branch and the git-ref index store, judged by what a graph reader needs from history.
Related: #4519 (the index store), INTENTIUS/behold#1025 (the index), INTENTIUS/behold#1027 (the graph pane), INTENTIUS/behold#1028 (index diff).
Why now
behold's graph pane loads each index scope's latest version into LadybugDB and nothing older (latestVersions in behold's src/graph-db/sources.ts). Resource keys are <scopeKey>/<id> with no version, so two versions of one scope would collide. chant's history template says so in its note: "Snapshot history (chant#4519's store) is not loaded into the session yet." History today is a diff of two JSON documents (index diff), not something Cypher can ask.
Loading every version (to a cap) into the session would let a person ask "what was true at T" and "when did this edge appear" in Cypher. Before behold builds that, the question is whether the stores underneath it are the right shape for history reads, or whether a different store would make the projection simpler or unnecessary.
What exists, checked at chant 799f239
There are two kinds of record, and they need different things.
Indexes and snapshots are derived, stamped and never load-bearing (#4519; index-store-load-bearing.test.ts). They sit behind SnapshotStore (lifecycle/snapshot-store.ts), with git-ref (refs/chant/snapshots, indexes under _index/), local, s3, none, and read-only orphan-branch. Each version is a file named <UTC stamp>-<digest12>.json under its scope path. History on git-ref is the ref's commits and the version files; on local it is the latest file only; on s3 it is the bucket's object versions.
Op records are not derivable, and some decide what an Op may do next. They stay on the chant/lifecycle orphan branch: gate ledgers (_gates/<op>.jsonl), checkpoints, applied lines, deploy outcomes (<env>/outcomes.jsonl), converge and release ledgers, stored change sets and build manifests (_builds/). Writes go through writeBlobToPath (lifecycle/git.ts): hash-object, mktree, commit-tree and update-ref, with a compare-and-swap retry, and a --force-with-lease push (pushLifecycle). #4519 left open whether these leave the branch, and named refs/chant/ledger as one answer.
Questions
- What history questions do readers ask? Measure rather than guess: behold's pane and
historytemplate, index diff,chant search --at,lifecycle diff --live(declared, then, now), gate audit,operator status,components status. - What are the sizes on real estates: versions per scope per month, bytes per version, records per ledger file, write rate under converge? The three-cloud demo and the fan-out demo are two candidates.
- What does each record kind need from its store: compare-and-swap, append-only, review in a pull request, offline reads, read without write credentials (behold reads with none), retention and erasure of a masked value that should not have been kept?
- Can a reader enumerate versions cheaply, and read one version without reading the rest?
- Is the graph a projection of the store, or could it be the store for either kind of record?
Alternatives to compare
For Op records:
- The orphan branch as it is.
- The same layout under
refs/chant/ledger(or a ref per stream, such asrefs/chant/gates/<op>), which keeps the mechanics, drops the branch-list and protection objections, and narrows compare-and-swap contention to one stream. - git notes on the source commit, for records keyed by commit (the plan a gate approved). Weak for records not keyed by a commit.
- An object store with conditional writes (S3
If-None-MatchandIf-Match, GCS generation preconditions): one object per record, append by unique key, compare-and-swap on a head pointer. Needs credentials to read, which the git-native stores do not. - A hosted store with conditional writes (DynamoDB, Postgres). Strongest concurrency, and a service to run.
- A versioned or bitemporal store such as OxiliteDB's
loglevel (SQLite, Turso, D1) or Tiramemsu (append-only SQLite, transaction and valid time). History becomes a query. Both are months old and single-maintainer, and both are RDF-shaped with Cypher translated on top. - choudoufu's record store as the model (
pkg/staterecord):Get,PutIfAbsent,PutIfVersion,Delete,List, with compare-and-swap per key on each backend. One key per event means writers never conflict and history comes from the key names. Costs the git-native story and needs credentials to read. (comment)
For indexes:
- The git-ref store as it is, with behold loading every version to a cap and adding version to the key.
- A columnar copy per version (Parquet) that LadybugDB or DuckDB imports in bulk. behold now inserts one row per prepared statement; a bulk load would also shorten the session build.
- A persistent graph file in behold's per-user data directory, loaded incrementally by version name and still safe to delete. This trades the per-session rebuild for a file that must survive LadybugDB upgrades.
- A bitemporal store as above, where behold's
observedAtis valid time andreadAtis transaction time. - The index as an event log: one file per changed resource, created only if absent, with a checkpoint every N versions. History costs about the size of the changes; reading the latest version becomes a fold. (comment)
- Dolt as an opt-in store, run through the
doltCLI with a git remote (refs/dolt/data). History and diff are SQL queries (AS OF,dolt_diff). DoltLite is the in-process option for Node, but has no git remote. (alternative, research)
For each: what a reader gains, what is lost (reviewability, portability, offline, the git-native story, the credential boundary), migration from what exists (old snapshots and ledgers must stay readable), and who owns it (chant's store, or a projection behold keeps).
Findings so far
Dolt, measured on synthetic data with a local git remote (results):
- It works for indexes. History survives a fresh clone past the git history cap.
AS OFand diff answer in under a second. A second writer fails at once with a clean error and leaves nothing half-written. - It costs a
doltbinary and at least 2.5 s per push. The git remote also adds a visible branch,__dolt_remote_info__. - It saves no storage. Over 40 versions, today's git layout took 292 KB, Dolt's row tables 584 KB, and Dolt with one JSON cell per version 1.2 MB. The case for Dolt is history as a query.
Not yet done: question 2 on a real estate, and the comparison table.
Done when
- A comment here measures question 2 on at least one estate and answers questions 1, 3 and 4 per record kind.
- A comparison table scores the alternatives against question 3's needs, with a recommendation for indexes and one for Op records, which may differ.
- Follow-up issues are filed for what is chosen, including the behold side (loading versions into the session).
- No production code merges under this issue.
Activity
lex00 commentedon Nov 20, 2026
Two more alternatives, both keeping records as files.
The index as an event log, the shape the Op records already have
Today an index version is a whole document,
<scope>/<stamp>-<digest12>.json, so a history read loads many near-identical copies. The alternative writes one line or file per changed resource (added, removed, changed, withobservedAt) and a full checkpoint every N versions.How it is written matters. On the git-ref store an "append" is not one:
writeLedgerFiles(lifecycle/git.ts) reads the file, writes a new blob holding every line, rebuilds the trees, and moves the ref with a compare-and-swap. Packs keep the disk cost small, but every write is a read-modify-write of the whole file under one ref, and a file many writers append to is a hot spot. S3 has no append at all. So the shape that works on every store is one file per change, created only if absent, never a file that grows.choudoufu's record store as the model
choudoufu's live backend already keeps its records this way (
pkg/staterecord, choudoufu f8e250dce6). The estate's truth is the markers on the resources and live reads. Each managed instance has one small record holding only what a read leaves out, and the state file a run writes is a cache that may be thrown away.The store is five calls:
Get,PutIfAbsent,PutIfVersion,DeleteandList. Keys and payloads are opaque, and a version is opaque except that""means no record. Each backend gives a real compare-and-swap per key with its own primitive:.tofu-recordsIf-None-Match: *,If-Matchlive-historylists them without payloadsifGenerationMatchtofu-records-<estate>resourceVersionWhat chant would take from it:
writeLedgerFilesmakes the wholechant/lifecycleref the unit a writer races on, and detects conflicts per path on top. With one key per event (_gates/<op>/<stamp>-<digest>) written withPutIfAbsent, two writers never conflict and no append re-reads anything.What it costs:
git fetchto copy history to another clone, no offline read of a remote store.refs/chant/snapshotswith git alone.For the graph, both alternatives keep records as the storage and the graph as a projection, which is also how choudoufu treats its own state file.
lex00 commentedon Nov 21, 2026
Another alternative: a versioned database kept in files, Dolt or DoltLite. Checked 2026-11-20 against DoltHub's docs, blog and the npm registry; the points not yet checked are marked.
Dolt
A SQL database (MySQL wire protocol, Apache-2.0, v2.7.5 released 2026-11-18) with commit, branch, merge, diff, clone, push and pull.
dolt_history_<table>anddolt_diff_<table>(system tables).AS OFreads are documented elsewhere and not yet checked here.file://,s3://(conditional writes, no DynamoDB),aws://(S3 plus DynamoDB),gs://,oci://, ssh, http, and since v1.81.10 a git remote (remotes, git remotes). The git remote keeps the data underrefs/dolt/data(changeable with--ref), needs agitbinary and an existing repository, and a plaingit clonedoes not fetch it, the same asrefs/chant/snapshots. v1.81.10 failed when git asked for credentials on stdin (dolt remote operations with git remotes fail when credentials require inline password. dolthub/dolt#10486); whether that is fixed is not checked.doltCLI (dolt sqlworks against a directory with no server), ordolt sql-serverwith a MySQL client. DoltHub listsmysqlandmariadbfor Node;mysql2is not listed and not checked. The in-process engine (dolthub/driver) is Go only, so choudoufu could embed it and chant could not.dolt sqlper command is not documented.The graph pane's four tables (
Resource,CloudId,KNOWN_AS,REF) would be Dolt tables as they are, with a commit per index version. Index diff becomesdolt_diff_*, and behold loads any version into LadybugDB. Content-addressed storage with structural sharing would make a whole snapshot per version cost about what it changed, which removes the need for the event-log shape above. That is Dolt's design, but this comment has no cited page for it yet.DoltLite
A SQLite fork with Dolt-style versioned storage, a separate engine from Dolt (repo, why).
@dolthub/doltlite, a native Node addon with anode:sqlite-style API, and@dolthub/doltlite-wasmfor the browser, both 0.51.14 and Apache-2.0. Beta since about 2026-08-31, with a storage format it calls stable.SQLITE_BUSY.AS OFanddolt_history_*is not checked.It is the only route with an in-process engine for TypeScript, and the only one that runs in an exported bundle beside LadybugDB's WebAssembly build.
Gained and lost
refs/chant/snapshotsdoes now.doltbinary on every machine and runner), or a beta engine for DoltLite; Dolt and DoltLite cannot share one history, so chant (Node) and choudoufu (Go) would have to pick one engine or keep separate histories; and Op records' compare-and-swap rule becomes transactions on one writer per branch, where choudoufu's store gives it per key.Fit: indexes, where queryable history is the need. Op records are better served by a record per key with a conditional write (above).
Also worth a line:
lex00 commentedon Nov 21, 2026
More on Dolt, as an opt-in store spawned through the
doltCLI with a git remote. Checked 2026-11-20 from DoltHub's docs, blog, releases and issues. Nothing was run.The git remote
refs/dolt/datapoints at a git commit whose tree holds Dolt's table files and manifest as blobs, split into parts past 50 MB (how it works, blobstore: add chunked-object mode to GitBlobstore dolthub/dolt#10424, v1.81.8).git-remote.max-history-commits(default 64) the next write starts a commit with no parent, so git can collect old objects (remotes). The git commits are transport. Dolt's own history is in the table files, so I expect it to survive this, but nothing I read says so outright. That needs a check.publishafter every snapshot would be slow; it fits a store that publishes once per run.git. Since v1.82.1 it turns git's prompts off and fails fast, and v1.86.4 keeps a user'sGIT_SSH_COMMAND. dolt remote operations with git remotes fail when credentials require inline password. dolthub/dolt#10486 (passphrases on stdin) is still open, so CI needs a token in the URL or a credential helper. Bitbucket is not supported.History as a query
AS OFtakes a commit hash, a branch,HEAD^2, orTIMESTAMP('...')(querying history). Tags are not mentioned.dolt_log,dolt_history_<table>,dolt_diff_<table>,dolt_blame_<table>, branches, merge and tags, and reads a past revision withdolt_at_<table>('<rev>')rather thanAS OF(README). Its remotes arefile://, its own HTTP server and DoltHub; no git remote, and no plan for one that I found.What storage costs, and what that means for a schema
Dolt keeps tables in prolly trees of content-addressed chunks of about 4 KB. One changed value costs about 4 KB times the tree depth; appends are cheap; edits scattered across a table can touch almost every chunk; adding a column rewrites the table (structural sharing). There are no published numbers for many near-identical snapshots. Garbage collection has run automatically since 1.75, but history that is still reachable is never collected; squashing it is
dolt rebaseplusdolt gc --full(disk space).That decides the schema:
Medium) shares almost nothing between versions, because every read changes values throughout the document. At minimumobservedAtchanges on every node. It would pass the conformance suite and gain little.observedAtand the read stamp go in a table per version, and a resource row changes only when the resource did. Then a commit costs about what changed, anddolt_diff_*answers what changed.Driving it from chant
dolt sql -q ... -r jsonexists. The JSON shape is not documented beside it;dolt table exportwrites{rows: [...]}. Needs a check.doltprocesses on one directory: nothing documents whether the second waits or fails, and one third-party report describes a stale lock file after quick successive commands. chant should run onedoltat a time per store until this is measured. Workspace members written in parallel are the case to test.dolt table importreadsjsonandjsonl(with--schema). No size limit for a JSON cell is documented.Still to measure, before building
max-history-commitsstill answersAS OFafter a fresh clone.lex00 commentedon Nov 21, 2026
The five Dolt measurements from the previous comment, run 2026-11-21 with Dolt 2.7.6 on macOS arm64.
Limits. No checkout here has a real index store, so the data is synthetic. It is shaped like
graph-schema/fixtures/index.json, with 400 resources and about 600 edges, and one document is 416 KB. Each version movesobservedAton every node, changes an attribute on 2% of resources, and adds and removes one resource. The git remote is a bare repository on local disk, so the times have no network in them.1. CLI start and a one-row commit
dolt version, first run / afterdolt sql -q "select 1", small dbcall dolt_commit(...)in onedolt sqldolt_diff('HEAD~20','HEAD','resources')resourcesviaAS OF, as JSON-r jsonprints{"rows":[...]}once per statement, one line each, and JSON columns come back as objects. Each call costs a process start of roughly 150-300 ms, so a store should batch a version's writes into onedolt sqlcall.2. Push and fetch over a git remote
git fetchofrefs/dolt/dataA push costs about 2.5 s with no network, before any data moves, and the history cap's reset adds more. That confirms the earlier advice: publish once per run, not once per snapshot.
The git remote writes three refs:
refs/dolt/data, the existingrefs/heads/mainleft as it was, and a branch,refs/heads/__dolt_remote_info__, holding aDOLT_REMOTE.md. That branch shows in the branch list and on the forge, which is the objection that moved chant's indexes offchant/snapshots. Not checked: whether the--refoption also moves the info branch.3. Storage growth over 40 versions
Medium)dolt gcresources,edges,cloud_ids,observations)dolt gcgit gc --aggressiveThis corrects the previous comment. A JSON cell does share storage between versions: Dolt chunks JSON values, so a document whose
observedAtchanges on every node still costs about 30 KB a version after gc, not a full copy. The row schema is half the size, and git's delta compression is half again. Storage alone is no argument for Dolt over the current layout. What Dolt adds is history as a query (AS OF,dolt_diff), which the git layout leaves to reading and comparing whole documents.Writing a version took about 0.8 s for the JSON cell and 1.2 s for the row tables, using one
dolt table importper table and so a process each. Doing it in onedolt sqlcall should cut most of that; not measured.On the remote, each push added about 70 KB to the bare repository until
git gc(1.9 MB after 20 pushes, 764 KB after gc). The cap exists so a forge can collect those objects; with cap 0 they stay.4. Concurrent writers on one directory
Three loops, each running 30 single-row insert-and-commit calls against one directory:
cannot update manifest: database is read only. The second process opens the database read-only and fails at once rather than waiting.LOCKfile stays, empty, and the next write succeeds.dolt sql-serverholds the directory,dolt sqlfrom another process sends its writes through the server, and they land.So chant either retries on that error, holds one writer per store per run, or starts a
sql-serverfor a run that writes in parallel (workspace members) and sends every write through it.5. History past the cap after a fresh clone
With
DOLT_GIT_REMOTE_MAX_HISTORY_COMMITS=4, 20 pushes reset the git chain repeatedly (2 to 4 commits onrefs/dolt/data). A fresh clone then had all 62 Dolt commits.AS OFthe oldest data commit returned version 0, anddolt_difffrom it answered. The cap prunes git's copy of old table files, not Dolt's history.Where this leaves the opt-in store
doltbinary, about 2.5 s or more per push, a visible__dolt_remote_info__branch, and per-process start costs that make the write path one batched call per version.AS OFand diff as queries. Not on storage grounds.The scripts that produced this are a generator and two shell scripts, available on request. They use no chant code.