architecture: select the canonical memory system of record (proposal: SQLite) #139

Closed
opened 2026-10-08 13:08:17 +02:00 by clawdie · 3 comments
Owner

Context

PR #136's verdict was "right shape around an unfilled center". store_memory.go
had to fall back to naive map writes (records[key] = rec) because the
canonical system of record is unselected across the architecture docs
(docs/wiki/shared-memory-architecture.md: "the canonical memory store has not
been chosen"
).

Without a storage backing, an in-memory map cannot provide:

  1. Transactional isolation and conflict logging.
  2. Database-level constraints for provenance and promotion gates.
  3. Durable timestamps for observation freshness and TTL eviction.

So any patch to issue #137's three priorities without selecting the store is
a temporary mock.

Proposal: SQLite (memory.db)

Candidate Fit
SQLite (memory.db) (recommended) Embedded, zero-daemon, pure-Go / CGO-optional, native on Debian 13 (debby) and FreeBSD 15 (valhala). Already proven in Colibri's store-schema.md for the coordination / task board. WAL mode, foreign keys, triggers.
PostgreSQL (system_brain) Heavyweight: external daemon, port listeners, credential management, FreeBSD jail socket forwarding. Conflicts with the lean ~3–5 MB footprint target.
Oxigraph as store Wrong abstraction: an RDF/SPARQL graph projection, not append-only provenance envelopes and conflict queues; no relational constraints.
Git / Markdown Too slow for runtime memory. Right for system_skills and reviewed docs, not high-frequency episodic recall.

How SQLite closes issue #137

  1. Blind overwrite → conflict records. canonical_records keyed
    (tenant_boundary, record_id); on key collision with a differing
    content_hash, an ON CONFLICT transaction inserts into
    conflict_records(conflict_id, existing_record_id, incoming_payload, detected_at, status='open') instead of mutating the existing row.
  2. Silent downgrade → promotion / authority gate. Enforce the authority
    hierarchy operator_authored > system_derived > agent_observed; reject
    down-tier replacement unless an explicit operator_approval token is
    supplied.
  3. Faked freshness → true observed_at + fail-closed staleness. Project
    observed_at; preflight discards records beyond the policy TTL
    (WHERE observed_at >= datetime('now','-30 seconds')) and moves the envelope
    to STALE_TELEMETRY.

Decision needed

Operator sign-off on SQLite as the canonical store, and confirmation of the
two-projection boundary (OpenViking + Oxigraph remain derived, rebuildable).

Acceptance

  • Canonical store selected and recorded in shared-memory-architecture.md
    ("What is and is not decided").
  • Schema drafted for canonical_records + conflict_records with authority
    constraints.
  • Issue #137's three priorities are backed by schema constraints, not only
    Go code.
  • Status / verification frontmatter reflects the new state.

Companion: #138 (retire the term).

## Context PR #136's verdict was "right shape around an unfilled center". `store_memory.go` had to fall back to naive map writes (`records[key] = rec`) because the canonical system of record is unselected across the architecture docs (`docs/wiki/shared-memory-architecture.md`: *"the canonical memory store has not been chosen"*). Without a storage backing, an in-memory map cannot provide: 1. Transactional isolation and conflict logging. 2. Database-level constraints for provenance and promotion gates. 3. Durable timestamps for observation freshness and TTL eviction. So any patch to issue #137's three priorities **without selecting the store** is a temporary mock. ## Proposal: SQLite (`memory.db`) | Candidate | Fit | | --- | --- | | **SQLite (`memory.db`)** *(recommended)* | Embedded, zero-daemon, pure-Go / CGO-optional, native on Debian 13 (debby) and FreeBSD 15 (valhala). Already proven in Colibri's `store-schema.md` for the coordination / task board. WAL mode, foreign keys, triggers. | | PostgreSQL (`system_brain`) | Heavyweight: external daemon, port listeners, credential management, FreeBSD jail socket forwarding. Conflicts with the lean ~3–5 MB footprint target. | | Oxigraph as store | Wrong abstraction: an RDF/SPARQL graph projection, not append-only provenance envelopes and conflict queues; no relational constraints. | | Git / Markdown | Too slow for runtime memory. Right for `system_skills` and reviewed docs, not high-frequency episodic recall. | ## How SQLite closes issue #137 1. **Blind overwrite → conflict records.** `canonical_records` keyed `(tenant_boundary, record_id)`; on key collision with a differing `content_hash`, an `ON CONFLICT` transaction inserts into `conflict_records(conflict_id, existing_record_id, incoming_payload, detected_at, status='open')` instead of mutating the existing row. 2. **Silent downgrade → promotion / authority gate.** Enforce the authority hierarchy `operator_authored > system_derived > agent_observed`; reject down-tier replacement unless an explicit `operator_approval` token is supplied. 3. **Faked freshness → true `observed_at` + fail-closed staleness.** Project `observed_at`; preflight discards records beyond the policy TTL (`WHERE observed_at >= datetime('now','-30 seconds')`) and moves the envelope to `STALE_TELEMETRY`. ## Decision needed Operator sign-off on **SQLite** as the canonical store, and confirmation of the **two-projection boundary** (OpenViking + Oxigraph remain derived, rebuildable). ## Acceptance - [ ] Canonical store selected and recorded in `shared-memory-architecture.md` ("What is and is not decided"). - [ ] Schema drafted for `canonical_records` + `conflict_records` with authority constraints. - [ ] Issue #137's three priorities are backed by schema constraints, not only Go code. - [ ] Status / verification frontmatter reflects the new state. --- **Companion:** #138 (retire the term).
Author
Owner

Docs update for this decision opened as PR #140: #140

Docs update for this decision opened as PR #140: https://code.clawdie.si/clawdie/colibri/pulls/140
Author
Owner

Status update (08.oct.2026) — recording/consistency work has landed; the decision itself is still open.

# Acceptance item State
1 Store selected and recorded in shared-memory-architecture.md ("What is and is not decided") Provisional ✅ / operator sign-off ❌ — recorded via #140; the contradicting store-schema.md line fixed in #141 (merged)
2 Schema drafted for canonical_records + conflict_records with authority constraints ❌ not started
3 #137's three priorities backed by schema constraints, not only Go ❌ not started — internal/memory/store_memory.go is still an in-memory map
4 Status/verification frontmatter reflects the new state ✅ mostly (2026-10-08)

Supporting evidence for SQLite (now in-repo, not aspirational): go.mod already requires modernc.org/sqlite v1.36.3, and internal/ledger/ledger.go documents it as pure-Go SQLite: no CGO, so FreeBSD links statically; the coordination store already runs WAL + foreign keys. Embedded / zero-daemon / pure-Go / native to Debian and FreeBSD is therefore already proven by the task-board store.

Remaining to close: operator sign-off on SQLite (item 1), then the schema draft that closes items 2 & 3 and unblocks #137 (the enforcement tracker).

Naming context, not a deliverable here: #142 rebases "split-brain" on the current decisions; it does not affect the store selection.

**Status update** (08.oct.2026) — recording/consistency work has landed; the decision itself is still open. | # | Acceptance item | State | | --- | --- | --- | | 1 | Store selected and recorded in `shared-memory-architecture.md` ("What is and is not decided") | **Provisional ✅ / operator sign-off ❌** — recorded via #140; the contradicting `store-schema.md` line fixed in #141 (merged) | | 2 | Schema drafted for `canonical_records` + `conflict_records` with authority constraints | ❌ not started | | 3 | #137's three priorities backed by schema constraints, not only Go | ❌ not started — `internal/memory/store_memory.go` is still an in-memory map | | 4 | Status/verification frontmatter reflects the new state | ✅ mostly (2026-10-08) | **Supporting evidence for SQLite** (now in-repo, not aspirational): `go.mod` already requires `modernc.org/sqlite v1.36.3`, and `internal/ledger/ledger.go` documents it as `pure-Go SQLite: no CGO, so FreeBSD links statically`; the coordination store already runs WAL + foreign keys. Embedded / zero-daemon / pure-Go / native to Debian and FreeBSD is therefore already proven by the task-board store. **Remaining to close:** operator sign-off on SQLite (item 1), then the schema draft that closes items 2 & 3 and unblocks #137 (the enforcement tracker). Naming context, not a deliverable here: #142 rebases "split-brain" on the current decisions; it does not affect the store selection.
Author
Owner

reference to PR #143 (signed off SQLite memory.db
canonical store + airgap mode with full Jev probe evidence)

reference to PR #143 (signed off SQLite memory.db canonical store + airgap mode with full Jev probe evidence)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
clawdie/colibri#139
No description provided.