Knotrel Docs

ADR 0016: authority, snapshots and restore

Status: Accepted on 2026-11-29 (knotrel/knotrel#224). Scope decisions Q3 and Q5 approved by the maintainer on 2026-11-29. Issues: #154 (contracts), #157 (snapshots).

Related: ADR 0012 (source-managed mode), ADR 0015 (runtime and registry).

Context

Knotrel stores nothing on disk. A restarted source-managed graph is rebuilt by a full import from the authoritative source, which can take long on large graphs. Snapshots can shorten that recovery, but a local copy can also claim more than it knows: it may be older than the source, from another source epoch, or corrupt. Durable acknowledgment of direct writes needs a log and is planned separately (#158, v1.4.0).

Decision

  1. Each graph has three properties fixed at creation: authority (direct, external, later knotrel), persistence (none, snapshot, later wal) and residency (resident, later bounded). Unsupported combinations are rejected with an explicit error, never mapped to the nearest valid one. Mode changes in place are not supported in v1.3.0: an operator creates a new graph and loads it.
  2. Q3: in v1.3.0 snapshots are allowed only with external authority. Valid combinations: direct/none (today’s standalone mode), external/none (today’s source-managed mode) and external/snapshot. direct/snapshot is rejected.
  3. A snapshot is an engine-neutral logical image of one graph at one coherent point: every node with its flags, every canonical edge with its flags, configuration, generation and revision, and the source identity, epoch and applied position. It never contains engine internals and can be restored on any supported engine. It lives in a new synchronous crate, knotrel-storage, behind a store interface with a local-filesystem implementation; publication is atomic and keeps the last valid snapshot.
  4. What a restore guarantees: the graph equals the graph that existed at the snapshot’s recorded source position, or the restore fails visibly (corrupt, unsupported or incompatible snapshot) and the graph falls back to the normal rebuild. It does not guarantee that the graph matches the source now.
  5. A restored graph is never ready by itself. It starts a new generation in the catching-up state and exposes its source position. The feeder resumes after that position and declares a barrier (the ADR 0012 path to ready), or detects a gap, an epoch change or expired history and performs a full replace import. Without a valid snapshot the graph starts uninitialized, as today.
  6. Q5: snapshots are opt-in and on demand. The default graph enables them with a snapshot directory setting (configuration, planned); without it, persistence stays none. Periodic scheduling may come later.

Alternatives considered

Consequences