D47c — A changeset is written out as a bundle, and a graph is rebuilt from bundles¶
- Status: Accepted — implements D47 (part 2); scopes and the sweep log travel from slice 24 (D47l, D47m)
- Date: 2026-09-23
- Origin: slice 22 build
- Area: foundations
Decision¶
- A dataset is a directory holding three things:
dataset.yaml, which pins the packs and holds the computed settings (D47e);bundles/YYYY/MM/<date>-<bundle id>/;captures/<sha>.txt.gz, the shared page texts, stored by hash and written once however many bundles cite them.- A bundle is a folder with two files:
rows.jsonl: every column of every row, verbatim. The changeset comes first, then the sources its events cite, their capture rows, the staged rows, and the reviews about them so far.manifest.json: whose it is (owner, agent, mode, intent, scope), the exporting instance and person, the packs, counts, each capture with whether its text travelled, and the sha256 of the rows.
Its id is bd_ plus a hash of the rows and the capture list, so the same
content always has the same id.
- Two kinds of bundle.
- A changeset bundle carries one changeset.
- A decisions bundle carries merges and rejections made after the rows they
decide were exported, together with those changesets' current state.
- kg bundle export is stateless. It reads the dataset to learn which
changesets and reviews it already holds, and writes only the difference.
Exporting twice writes nothing.
- Exporting ends a changeset's life as a place to write. An exported
changeset with work still staged is sealed: it takes no more writes, and
its staged rows still await decisions. An exported changeset with nothing
staged is closed. Either way the writer's next change opens a new changeset. A
changeset nothing was ever written to is dropped, not kept as an empty record.
- kg rebuild <dataset> --into <file> builds a new graph:
1. It never writes over an existing file; --force moves that file to .bak
first.
2. It checks every bundle's rows against its manifest.
3. It restores the tables in dependency order, each in (created_at, id)
order. Sources are matched on their normalised URL, and ids minted by
another database are remapped.
4. It replays the reviews in order. A row's status is its last decision's
action, and its merged_at is that decision's time, exactly as set_status
wrote it.
5. It refuses if any row refers to one no bundle carries: foreign keys, entity
references inside claim values, and a derived claim's inputs.
6. It records which bundles it read in a bundles table.
- The proof: every golden session, on both packs, is replayed, exported,
rebuilt, and must render identically:
- on every entity: get, brief --full and trace;
- the review, and each changeset's diff;
- the audit and the changeset list.
Why¶
D47 makes the dataset a log and the database an index. This is the first half of that: writing the log and reading it back.
- Export is stateless because the dataset, not a table of local bookkeeping, is what other people will review. One source of truth for "what has been shared" cannot drift from a local note of it.
- Export seals because a bundle is what gets reviewed (slice 23). Rows added to a changeset after its bundle was written would never be seen.
- Rows travel verbatim, not as operations to replay, because reads depend on
ids, timestamps and insertion order (claim grouping, which name wins, the
latest changeset's diff). Status travels as reviews because
set_statusstamps the row and its review with the same instant, so replaying them reproduces status to the microsecond.
Alternatives¶
- Replaying operations. Rejected in D47. It re-runs the resolver and the policy on the receiving side, which gives different ids and times and refuses entities that already exist.
- Tracking exports locally. Rejected: that bookkeeping drifts, as described under Why.
- Letting an exported changeset keep taking writes and re-exporting a new version. Rejected: a bundle's id is its content, so a changeset would have several bundles with no rule for which is current.
- Rebuilding into
graph.db. Rejected for now. A graph can hold staged work that was never exported, and rebuilding in place would drop it silently. Slice 23'skg pullis where local work and the shared log are reconciled.
Open questions¶
- Exporting one changeset alone can leave a dangling reference, when its claims
cite an event staged in a changeset not yet exported. Rebuild refuses such a
dataset and says what is missing, so
--allis the normal way to export. Slice 23 decides whether a contribution must carry the events it cites. - Scopes, channels, sweeps and candidates do not travel yet (slice 24). So a
rebuilt graph has no scopes, and
kg sweep plancannot be compared across a round trip.