ADR-0004 — Runs: MCAP the record of truth; a SQLite index and prepared frames derived from it¶
Status: Accepted (2026-11-15, by the operator); in part superseded by RFC-0010 Date: 2026-11-15 Context documents: RFC-0009 §2 and §7, ADR-0001, ADR-0002
What RFC-0010 supersedes (2026-11-15). The run file is format 2 (ADR-0007): Foxglove JSON-schema messages for poses, transforms, the map and depth, one writer under a lock, flushed per tick, absolute time, compacted into zstd chunks at the end; format 1 is not read any more. The run is
robot/scene/run(ADR-0006). The index is no longer in the data folder and has no per-tick table: it is the service's own, read by the listing and by questions across runs (ADR-0009); "the ticks table answers the Moment" is withdrawn (the moment comes from the loaded run). "A killed run loses at most the record being written" became "at most the tick being written" (the writer flushes after each tick's records). "Prepared frames" were never built: the pages load windows from the API (ADR-0010, ADR-0011). The rest of this record (MCAP as the record of truth, an index derived from it) stands.
Context¶
The operator asked for storage that is friendly to time series. Runs are bounded bundles — poses, sensor frames, map snapshots, plans, decisions and events at 10–20 Hz for 1–15 minutes, a few MB compressed each — and the challenge course will make hundreds. Uses: the page loads a run and scrubs it; an agent asks for the state at t, events, and questions across runs ("which runs in this scene broke this invariant"); a navigator appends while it runs and may be killed; Rerun, Lichtblick and eval-harness should open runs; one format for every robot.
ADR-0002 already decided that MCAP is the record format and every robot writes it. The duck's
navigator does not: it writes JSON lines (ticks.jsonl). That is a gap against ADR-0002, not a new
choice. A comparison of MCAP, DuckDB over Parquet, Parquet/Arrow files, SQLite, time-series
databases and JSON lines was made on 2026-11-15 (versions checked on PyPI, npm and the projects'
pages that day).
Decision¶
- Each run is one MCAP file, the record of truth. One channel per kind of record (poses,
truth, sensor, world, plan, decisions, events). Foxglove's protobuf schemas where a standard
shape exists (pose in frame, transforms, grids), which Rerun decodes; JSON schemas for our own
kinds. A small chunk size, so a killed run loses seconds, not the run. The navigator writes it
natively (RFC-0008 step 1); until then an adapter converts
ticks.jsonl, never editing it. - Derived, rebuildable, deletable:
index.sqliteacross runs (Python's standard library): one row per run (scene, robot, verdict, numbers), events, invariant breaks — the agent's questions across runs are one SQL line;index.jsonfor the page is exported from it.- Prepared frames per run, next to its MCAP: what the page loads whole and scrubs in memory.
Both are rebuilt by
miniview indexandminiview prepare, with a staleness check.
As built (2026-11-15, with ADR-0005): the
frames are built in memory by the service from the MCAP and served by time window; there is no
frames.json or miniview prepare. The MCAP has one channel per record kind with JSON
messages only (no Foxglove protobuf schemas yet, so Foxglove and Lichtblick open the files but
have no ready panels for them, and Rerun does not decode them), and it is written without
chunks, so a reader can follow the file while it grows; a killed run loses at most the tick
being written (the writer flushes after each tick's records, ADR-0007). miniview import
converts ticks.jsonl.
3. Scenes are files of their own, referred to by name from each run's metadata.
4. Where: one lab data folder outside the code checkout, /work/robotics-lab/data/ (operator,
2026-11-15), for every robot and tool; not in git (runs grow to gigabytes). Later the logbook
(RFC-0007) copies it to the homelab for backup.
data/
scenes/<scene>/scene.json
runs/<robot>/<scene>/<run-id>/run.mcap the record (truth)
source/ the original log, copied by an import (ADR-0007)
(index.sqlite is the service's own, outside the data: MINIVIEW_INDEX, ADR-0009)
- The database is SQLite (the operator asked which): one file, in Python's standard library, no server.
- No time-series server. A run is a bounded, nested bundle, not a metrics stream; a service would break "files in, files out", and nothing downstream reads it.
Consequences¶
- Positive: keeps ADR-0002's decision and closes the duck's gap; append and crash safety are
native; Foxglove, Lichtblick and Rerun (via protobuf) open runs directly; no new Python dependency
(
mcapis already in both projects); the page needs no database in the browser. - Negative: two derived artifacts to keep fresh; a new question over raw records across runs means a re-scan (or adding DuckDB later as a reader of the derived exports).
- Neutral: the browser can read a growing MCAP directly later (
@mcap/browser) for a live view.
Alternatives considered¶
- MCAP only — one format, but every question across runs opens hundreds of files, and the page would decode and decompress the log on every scrub.
- DuckDB over Parquet as the core — the best ad-hoc analytics; but two new heavy dependencies, a second place for truth or a conversion step, no append for a live run, and nothing that Rerun or Lichtblick open. It can be added later as a reader.
- SQLite as the record — good queries and append; no viewer reads it, and nested records fit it poorly.
- A time-series database (TimescaleDB, QuestDB, InfluxDB) — a service for bounded bundles.
- JSON lines (today) — simple, but no schema, no index, largest, and against ADR-0002.