Guiding Principles & Invariants
Gonzalo's design philosophy is otherwise recoverable only by reading the full ADR log and the founding design spec. This page synthesizes that philosophy into one place: the guiding principles that shape the system and the inviolable invariants it must never break. It complements — it does not replace — the ADRs; each item cites the ADR(s) it derives from, and should be kept in sync when those are superseded.
Guiding principles
- One uniform
Record, one genericStore("Approach A"). Every domain type is a serde view overRecord { key, kind, revision, parent, body, meta, links }; versioning, concurrency, conflict, and sync are written once in the core (ADR 0002). - Substrate pluggability — the backend is configuration, not API.
fs/git/S3/daemon-client each implement only
Store; moving from local to git/S3/daemon is a config change, not a code change; fs is the zero-dependency default (ADR 0004, 0009). - Optimistic concurrency with explicit, typed conflict surfacing.
put(record, expected_parent_rev); a stale parent yieldsPutResult::Conflict(recoverable, not an error); merge is keyed byRecordKind, andSyncreuses the exact same machinery (ADR 0005). - Layering discipline — capabilities compose over a storage-only core.
Vector, graph, tickets, and knowledge are added as layers, each keyed by
RecordKey; substrates never know about vectors or graphs (ADR 0008, 0010, 0011, 0012). - Minimal-core-touch for new capabilities. A new layer may register a
RecordKindat most — no new core traits or types enter (ADR 0010, 0011). This aligns with the rule of three for promoting anything into the core. - Provider-agnostic boundaries via traits. Embedding goes through
Embedder, tickets throughTicketSource; provider divergence is handled bycapabilities()negotiation, neverif provider == …branches (ADR 0008, 0010). - The conformance suite is the executable contract. One shared conformance
suite that every
Storeimplementation must pass (ADR 0006). - A single canonical schema behind dual transports. gRPC (tonic) and
HTTP/JSON (axum) sit over one service layer;
gonzalo-protois the single schema, so the transports cannot drift (ADR 0007). - Single-facade public surface + workspace discipline. Caliban depends on
one crate — the
gonzalofacade; substrates and layers are toggled by Cargo feature (ADR 0009). - Normalize on the shared spine, preserve the raw losslessly. Tickets
normalize to
State { category, resolution, raw_name, raw_id }plus a boundedfieldsmap; the status signal is configured per connection, not hard-coded per provider (ADR 0010). - Separate storage identity from query identity. The code graph keys slices by content + grammar hash (which dedups) and resolves them through a per-worktree manifest — git's blob/tree split (ADR 0012).
- Retrieval returns first-class records, never bare ids. Vector, graph,
knowledge, and ticket queries resolve back through the
Storeto whole records (ADR 0008, 0011).
Inviolable invariants
- Concurrent edits are never silently lost — the core invariant. A
stale-parent write MUST return
Conflict, never overwrite; ambiguous merges MUST surface (ADR 0005). - Conflict is a typed, recoverable result —
PutResult::Conflict, never collapsed intoGonzaloError(ADR 0005). - All persistence funnels through the one
Record/Store— no parallel typed store re-implements versioning (ADR 0002). - Substrates implement only the generic
Storeand stay type-blind — no substrate-specific escape hatches (ADR 0004, 0008). - Every
Storeimplementation must pass the shared conformance suite (ADR 0006). - Capability layers never bypass or mutate the core — a layer may register
a
RecordKind+ merge class at most (ADR 0008, 0010, 0011). Syncreuses the exact local-write conflict/merge machinery — anyStorecan be a sync peer (ADR 0005).- The daemon's two transports derive from one canonical schema + one service
layer (
gonzalo-proto) (ADR 0007). - The code graph is NEVER keyed by
(repo, path)— two-level keying; slices are content-addressed, path-agnostic, and stored raw, and resolution tolerates missing targets (ADR 0012). - No query engine ever sits under the
Storesubstrate — engines back only regenerable index layers, never the durable source of truth (ADR 0012). unsafe_codeis forbidden workspace-wide (ADR 0009).- License is AGPL-3.0-only (ADR 0003).
- The core does no I/O —
gonzalo-coreis pure logic; all I/O lives in substrates (design spec §3). - Every write carries provenance identity — an
Identity;Metarecordsauthorandorigin_system(design spec §4, §9). - ADRs are an append-only log — superseded, never deleted (ADR 0001).