audit: canonical dump as committed truth; db demoted to gitignored cache; restore

This commit is contained in:
2026-11-11 17:58:39 +00:00
parent e0b384f858
commit 1dcdc917d2
6 changed files with 115 additions and 11 deletions
+29
View File
@@ -0,0 +1,29 @@
-- canonical dump of db/memory.db — GENERATED by tool/memory.mjs; do not edit.
-- one row per line; entries and events ordered by id; restore with: restore
PRAGMA foreign_keys = ON;
CREATE TABLE IF NOT EXISTS entries (
id INTEGER PRIMARY KEY,
ring TEXT NOT NULL CHECK (ring IN ('a', 'b', 'cold')),
type TEXT NOT NULL CHECK (type IN ('place', 'person', 'fact', 'thread')),
label TEXT NOT NULL,
detail TEXT NOT NULL DEFAULT '',
created TEXT NOT NULL,
last_touched TEXT NOT NULL
);
CREATE INDEX IF NOT EXISTS entries_ring_touch
ON entries (ring, last_touched DESC, id DESC);
-- append-only audit journal; nothing here is ever updated or deleted
CREATE TABLE IF NOT EXISTS events (
id INTEGER PRIMARY KEY,
window TEXT NOT NULL,
op TEXT NOT NULL CHECK (op IN ('insert', 'touch', 'promote', 'demote', 'reword', 'delete', 'evict', 'revive')),
entry_id INTEGER NOT NULL REFERENCES entries (id),
reason TEXT NOT NULL DEFAULT ''
);
CREATE INDEX IF NOT EXISTS events_window ON events (window);
BEGIN TRANSACTION;
COMMIT;