Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
7.8 kB · 212 lines
SQL
at dev
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213-- Ideonomics AppView schema.-- Governing principle (docs/03): repos hold what the user *said*; these tables-- hold what the system *concluded* — plus mirrors of the said, keyed by AT-URI.
-- ============ auth ============
-- jacquard ClientAuthStore backing: active OAuth sessions, keyed (did, session_id).CREATE TABLE oauth_sessions ( did TEXT NOT NULL, session_id TEXT NOT NULL, data TEXT NOT NULL, -- ClientSessionData as JSON updated_at INTEGER NOT NULL, PRIMARY KEY (did, session_id));
-- In-flight authorization requests, keyed by OAuth `state`.CREATE TABLE oauth_requests ( state TEXT PRIMARY KEY, data TEXT NOT NULL, -- AuthRequestData as JSON created_at INTEGER NOT NULL);
-- Opaque cookie -> jacquard OAuth session mapping (docs/07), plus per-session chain state.CREATE TABLE web_sessions ( cookie TEXT PRIMARY KEY, did TEXT NOT NULL, oauth_session_id TEXT NOT NULL, handle TEXT, chain_parent_uri TEXT, -- last completion in this session's chain chain_parent_cid TEXT, chain_depth INTEGER NOT NULL DEFAULT 0, last_term TEXT, -- user's last completion text, for chaining created_at INTEGER NOT NULL);
-- ============ record mirrors (hydrated by Jetstream + write-path read-after-write) ============
CREATE TABLE squares ( uri TEXT PRIMARY KEY, -- AT-URI cid TEXT, a TEXT, b TEXT, c TEXT, d TEXT, -- one NULL: the open slot open_slot TEXT NOT NULL CHECK (open_slot IN ('a','b','c','d')), provenance TEXT NOT NULL CHECK (provenance IN ('bank','chained')), chained_from TEXT, -- completion AT-URI when provenance='chained' bank_id INTEGER, -- bank row when provenance='bank' created_at TEXT);
CREATE TABLE completions ( uri TEXT PRIMARY KEY, cid TEXT, did TEXT NOT NULL, square_uri TEXT NOT NULL, slot TEXT NOT NULL, text TEXT, -- NULL for non-completions mode TEXT NOT NULL CHECK (mode IN ('completed','refused','noparse','joke')), chain_parent TEXT, chain_depth INTEGER, latency_bucket TEXT, created_at TEXT, indexed_at INTEGER NOT NULL);CREATE INDEX completions_did ON completions (did, indexed_at);CREATE INDEX completions_square ON completions (square_uri);
CREATE TABLE resonances ( uri TEXT PRIMARY KEY, cid TEXT, did TEXT NOT NULL, completion_uri TEXT, -- NULL when reacting to generated archetype text square_uri TEXT, archetype_text TEXT, reaction TEXT NOT NULL CHECK (reaction IN ('lands','funny','irritates','flat')), created_at TEXT);CREATE INDEX resonances_did ON resonances (did);
CREATE TABLE glosses ( uri TEXT PRIMARY KEY, -- AT-URI (app repo) or local: URI in local mode completion_uri TEXT NOT NULL, did TEXT NOT NULL, -- subject user (denormalized from completion) readings TEXT NOT NULL, -- JSON: [{relation, canonicalRelation, weight, valence}] interpreter TEXT NOT NULL, -- model id prompt_version TEXT NOT NULL, ensemble_member TEXT NOT NULL, orphaned INTEGER NOT NULL DEFAULT 0, -- source completion deleted; keep only for aggregates created_at TEXT);CREATE INDEX glosses_completion ON glosses (completion_uri);CREATE INDEX glosses_did ON glosses (did);
CREATE TABLE snapshots ( uri TEXT PRIMARY KEY, did TEXT NOT NULL, layout_version TEXT NOT NULL, input_hash TEXT NOT NULL, created_at TEXT);
-- ============ canonical relation space (docs/04: discovered, never fixed) ============
CREATE TABLE relations ( id INTEGER PRIMARY KEY AUTOINCREMENT, label TEXT NOT NULL, -- medoid gloss text, human-readable centroid BLOB NOT NULL, -- f32 LE embedding centroid count INTEGER NOT NULL DEFAULT 1);
-- ============ per-user term graph (docs/05: the primary object) ============
CREATE TABLE terms ( did TEXT NOT NULL, term TEXT NOT NULL, centrality REAL NOT NULL DEFAULT 0, degree INTEGER NOT NULL DEFAULT 0, community INTEGER NOT NULL DEFAULT 0, entropy REAL NOT NULL DEFAULT 0, -- completion-distribution entropy at this term gloss_variance REAL NOT NULL DEFAULT 0, -- interpreter-ensemble disagreement, term-local is_master INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (did, term));
CREATE TABLE edges ( did TEXT NOT NULL, src TEXT NOT NULL, dst TEXT NOT NULL, relation INTEGER NOT NULL, -- relations.id weight REAL NOT NULL, sign REAL NOT NULL DEFAULT 0, -- gloss valence in [-1, 1] variance REAL NOT NULL DEFAULT 0, -- gloss-ensemble disagreement completion_uri TEXT NOT NULL, PRIMARY KEY (did, src, dst, relation, completion_uri));CREATE INDEX edges_did ON edges (did);
-- ============ inference state ============
CREATE TABLE posteriors ( did TEXT PRIMARY KEY, weights TEXT NOT NULL, -- JSON: {quilt_id: weight} entropy REAL NOT NULL, -- contested-quilting measure updated_at INTEGER NOT NULL);
CREATE TABLE quilts ( id INTEGER PRIMARY KEY AUTOINCREMENT, label TEXT NOT NULL, -- most central term of the component, as a name profile TEXT NOT NULL, -- JSON sparse vector over (term, relation) features size REAL NOT NULL, refit_at INTEGER NOT NULL);
CREATE TABLE discrimination ( square_uri TEXT NOT NULL, -- bank:<id> for unreified bank items quilt_a INTEGER NOT NULL, quilt_b INTEGER NOT NULL, score REAL NOT NULL, PRIMARY KEY (square_uri, quilt_a, quilt_b));
-- ============ derived caches ============
CREATE TABLE layouts ( did TEXT NOT NULL, layout_version TEXT NOT NULL, input_hash TEXT NOT NULL, layout TEXT NOT NULL, -- JSON: nodes with polar coords, edges, verdict, fit metrics computed_at INTEGER NOT NULL, PRIMARY KEY (did, layout_version, input_hash));
CREATE TABLE pairings ( did_a TEXT NOT NULL, did_b TEXT NOT NULL, status TEXT NOT NULL CHECK (status IN ('requested','accepted')), requested_by TEXT NOT NULL, created_at INTEGER NOT NULL, PRIMARY KEY (did_a, did_b));
CREATE TABLE cursor ( id INTEGER PRIMARY KEY CHECK (id = 1), time_us INTEGER NOT NULL);
-- Falsifiability metrics (docs/05), one row per (refit, metric, scope).CREATE TABLE metrics ( id INTEGER PRIMARY KEY AUTOINCREMENT, refit_at INTEGER NOT NULL, name TEXT NOT NULL, scope TEXT NOT NULL, -- 'population' or a DID value REAL NOT NULL);
-- Durable medium-loop queue (mpsc alone loses work on restart).CREATE TABLE gloss_queue ( id INTEGER PRIMARY KEY AUTOINCREMENT, completion_uri TEXT NOT NULL UNIQUE, enqueued_at INTEGER NOT NULL, attempts INTEGER NOT NULL DEFAULT 0);
-- ============ square bank (offline-generated items; docs/02) ============
CREATE TABLE bank ( id INTEGER PRIMARY KEY AUTOINCREMENT, a TEXT, b TEXT, c TEXT, d TEXT, open_slot TEXT NOT NULL CHECK (open_slot IN ('a','b','c','d')), targets TEXT, -- JSON: quilt archetypes this item was designed to separate square_uri TEXT, -- set once reified as a record on first serve generator TEXT NOT NULL DEFAULT 'seed-v1');