Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat(graph): temporal edge schema, relationship state and liveness predicate (GBRA-49 P1)

garrytancd6c6f7718d6
diff --git a/scripts/build-schema.ts b/scripts/build-schema.ts
index c5011158c1..d691873941 100644
--- a/scripts/build-schema.ts
+++ b/scripts/build-schema.ts
@@ -31,6 +31,7 @@ import { SOURCE_INGESTION_RECEIPTS_SCHEMA_SQL } from '../src/core/company-brain/
import { FACT_WITHDRAWAL_SCHEMA_STATEMENTS } from '../src/core/facts/withdrawal-schema.ts';
import { GRANT_AUDIT_SCHEMA_SQL } from '../src/core/grants/schema.ts';
import { LEASE_TOKEN_SCHEMA_SQL } from '../src/core/lease-schema.ts';
+import { LINK_TEMPORAL_SCHEMA_SQL } from '../src/core/link-temporal-schema.ts';
import { PAGE_PROJECTION_SCHEMA_SQL } from '../src/core/page-state/projection-schema.ts';
import { PAGE_STATE_SCHEMA_SQL } from '../src/core/page-state/schema.ts';
import { POSTGRES_CONCURRENT_PERSISTENCE_INDEXES, PERSISTENCE_SCHEMA_STATEMENTS } from '../src/core/persistence/schema.ts';
@@ -95,6 +96,7 @@ export const FRAGMENTS: readonly Fragment[] = [
{ source: 'src/core/shared-skills/schema-all.ts', expr: 'SHARED_SKILLS_SCHEMA_SQL', postgres: SHARED_SKILLS_SCHEMA_SQL, pglite: SHARED_SKILLS_SCHEMA_SQL },
{ source: 'src/core/ai/decide/schema.ts', expr: 'DECIDE_SCHEMA_SQL', postgres: DECIDE_SCHEMA_SQL, pglite: DECIDE_SCHEMA_SQL },
{ source: 'src/core/facts/relink-schema.ts', expr: 'FACT_RELINK_SCHEMA_SQL', postgres: FACT_RELINK_SCHEMA_SQL, pglite: FACT_RELINK_SCHEMA_SQL },
+ { source: 'src/core/link-temporal-schema.ts', expr: 'LINK_TEMPORAL_SCHEMA_SQL', postgres: LINK_TEMPORAL_SCHEMA_SQL, pglite: LINK_TEMPORAL_SCHEMA_SQL },
];
const fragmentLabel = (f: Fragment) => `${f.source} (${f.expr})`;
diff --git a/scripts/engine-sql-baseline.tsv b/scripts/engine-sql-baseline.tsv
index c38676eb32..9d35c2f5ab 100644
--- a/scripts/engine-sql-baseline.tsv
+++ b/scripts/engine-sql-baseline.tsv
@@ -14,6 +14,7 @@ migrated code-edges
migrated facts
migrated files
migrated health
+migrated link-relationships
migrated links
migrated pages
migrated salience
diff --git a/src/core/engine-sql/link-relationships.ts b/src/core/engine-sql/link-relationships.ts
new file mode 100644
index 0000000000..9fb73cdfea
--- /dev/null
+++ b/src/core/engine-sql/link-relationships.ts
@@ -0,0 +1,214 @@
+/**
+ * Relationship state refresh (temporal typed edges): one SQL implementation
+ * for both engines. Reads every piece of evidence for the given relationships
+ * (`links` assertions + `link_transitions`), runs the pure
+ * `buildRelationshipState`, and upserts one `link_relationships` row per read
+ * scope:
+ *
+ * all evidence from every live origin page in the relationship's source
+ * world the same minus evidence from private origins, so private notes
+ * never change what a remote caller sees
+ *
+ * Callers run this inside the transaction that changed the evidence (link
+ * writes, derived-link replacement, transition replacement), so state and
+ * evidence commit together. Evidence from soft-deleted origins, from origins in
+ * another source, or attached to a soft-deleted endpoint does not count.
+ * Relationships with no remaining evidence lose their state row (and then read
+ * as live, the same as an unrefreshed relationship).
+ */
+import { createHash } from 'node:crypto';
+import { executeRawJsonb } from '../sql-query.ts';
+import { privatePagesFilterFragment } from '../search/private-visibility.ts';
+import {
+ buildRelationshipState, relationSemantics, statusAt, stintsToMultirange, dateKey, TEMPORAL_LINK_TYPES,
+ type AssertionEvidence, type TransitionEvidence, type RelationshipScope, type TransitionProducer,
+} from '../link-validity.ts';
+
+export interface RelationshipKey { from_page_id: number; to_page_id: number; link_type: string }
+
+type RawExec = { executeRaw<R = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<R[]> };
+
+const keyOf = (k: RelationshipKey) => `${k.from_page_id}\0${k.to_page_id}\0${k.link_type}`;
+
+/** Dedupe keys and keep only temporal (state/event) relation types. */
+export function temporalKeys(keys: Iterable<RelationshipKey>): RelationshipKey[] {
+ const out = new Map<string, RelationshipKey>();
+ for (const k of keys) {
+ if (!k || relationSemantics(k.link_type) === 'reference') continue;
+ const from = Number(k.from_page_id), to = Number(k.to_page_id);
+ if (!Number.isSafeInteger(from) || !Number.isSafeInteger(to)) continue;
+ out.set(keyOf(k), { from_page_id: from, to_page_id: to, link_type: k.link_type });
+ }
+ return [...out.values()];
+}
+
+interface AssertionRow { from_page_id: number; to_page_id: number; link_type: string; origin_id: number; tense: string; created_at: unknown; source_id: string; origin_public: boolean }
+interface TransitionRow { from_page_id: number; to_page_id: number; link_type: string; origin_id: number | null; kind: string; occurred_on: unknown; producer: string; created_at: unknown; source_id: string; origin_public: boolean }
+interface ExistingRow { from_page_id: number; to_page_id: number; link_type: string; scope: RelationshipScope; recorded_at: unknown; retired_at: unknown; evidence_hash: string }
+
+/** Refresh the state of `keys`. Returns the number of state rows written or removed. */
+export async function refreshRelationships(exec: RawExec, keys: Iterable<RelationshipKey>): Promise<number> {
+ const rows = temporalKeys(keys);
+ if (rows.length === 0) return 0;
+ const payload = { rows };
+ const assertions = await executeRawJsonb<AssertionRow>(exec,
+ `SELECT v.from_page_id, v.to_page_id, v.link_type,
+ COALESCE(l.origin_page_id, l.from_page_id) AS origin_id,
+ COALESCE(l.assertion_tense, 'present') AS tense, l.created_at, f.source_id,
+ (${privatePagesFilterFragment('o')}) AS origin_public
+ FROM jsonb_to_recordset(($1::jsonb)->'rows') AS v(from_page_id int, to_page_id int, link_type text)
+ JOIN links l ON l.from_page_id = v.from_page_id AND l.to_page_id = v.to_page_id AND l.link_type = v.link_type
+ JOIN pages f ON f.id = l.from_page_id AND f.deleted_at IS NULL
+ JOIN pages t ON t.id = l.to_page_id AND t.deleted_at IS NULL
+ JOIN pages o ON o.id = COALESCE(l.origin_page_id, l.from_page_id) AND o.deleted_at IS NULL AND o.source_id = f.source_id`,
+ [], [payload]);
+ const transitions = await executeRawJsonb<TransitionRow>(exec,
+ `SELECT v.from_page_id, v.to_page_id, v.link_type, lt.origin_page_id AS origin_id, lt.kind,
+ lt.occurred_on::text AS occurred_on, lt.producer, lt.created_at, f.source_id,
+ (o.id IS NULL OR ${privatePagesFilterFragment('o')}) AS origin_public
+ FROM jsonb_to_recordset(($1::jsonb)->'rows') AS v(from_page_id int, to_page_id int, link_type text)
+ JOIN link_transitions lt ON lt.from_page_id = v.from_page_id AND lt.to_page_id = v.to_page_id AND lt.link_type = v.link_type
+ JOIN pages f ON f.id = lt.from_page_id AND f.deleted_at IS NULL
+ JOIN pages t ON t.id = lt.to_page_id AND t.deleted_at IS NULL
+ LEFT JOIN pages o ON o.id = lt.origin_page_id
+ WHERE lt.origin_page_id IS NULL OR (o.deleted_at IS NULL AND o.source_id = f.source_id)`,
+ [], [payload]);
+ const existing = await executeRawJsonb<ExistingRow>(exec,
+ `SELECT lr.from_page_id, lr.to_page_id, lr.link_type, lr.scope, lr.recorded_at, lr.retired_at, lr.evidence_hash
+ FROM jsonb_to_recordset(($1::jsonb)->'rows') AS v(from_page_id int, to_page_id int, link_type text)
+ JOIN link_relationships lr ON lr.from_page_id = v.from_page_id AND lr.to_page_id = v.to_page_id AND lr.link_type = v.link_type`,
+ [], [payload]);
+
+ const byKey = new Map<string, { a: AssertionRow[]; t: TransitionRow[] }>();
+ const bucket = (k: RelationshipKey) => {
+ const id = keyOf(k);
+ let b = byKey.get(id);
+ if (!b) { b = { a: [], t: [] }; byKey.set(id, b); }
+ return b;
+ };
+ for (const a of assertions) bucket(a).a.push(a);
+ for (const t of transitions) bucket(t).t.push(t);
+ const prior = new Map(existing.map(e => [`${keyOf(e)}\0${e.scope}`, e]));
+
+ let changed = 0;
+ const upserts: Array<Record<string, unknown>> = [];
+ const removals: Array<{ from_page_id: number; to_page_id: number; link_type: string; scope: RelationshipScope }> = [];
+ const now = new Date();
+ for (const key of rows) {
+ const evidence = byKey.get(keyOf(key));
+ const semantics = relationSemantics(key.link_type) as 'state' | 'event';
+ for (const scope of ['all', 'world'] as const) {
+ const a = (evidence?.a ?? []).filter(r => scope === 'all' || r.origin_public);
+ const t = (evidence?.t ?? []).filter(r => scope === 'all' || r.origin_public);
+ const before = prior.get(`${keyOf(key)}\0${scope}`);
+ if (a.length === 0 && t.length === 0) {
+ if (before) removals.push({ ...key, scope });
+ continue;
+ }
+ const state = buildRelationshipState(semantics,
+ a.map((r): AssertionEvidence => ({ tense: r.tense === 'past' ? 'past' : 'present', originPageId: Number(r.origin_id) })),
+ t.map((r): TransitionEvidence => ({ kind: r.kind === 'end' ? 'end' : 'start', occurredOn: String(dateKey(r.occurred_on)), producer: r.producer as TransitionProducer, originPageId: r.origin_id == null ? null : Number(r.origin_id) })));
+ const status = statusAt(state);
+ const hash = evidenceHash(a, t);
+ const earliest = [...a.map(r => r.created_at), ...t.map(r => r.created_at), before?.recorded_at]
+ .map(v => (v instanceof Date ? v : v == null ? null : new Date(String(v))))
+ .filter((d): d is Date => !!d && Number.isFinite(d.getTime()))
+ .sort((x, y) => x.getTime() - y.getTime())[0] ?? now;
+ const ended = status === 'ended' || status === 'ended_unknown_date';
+ const priorRetired = before?.retired_at == null ? null : before.retired_at instanceof Date ? before.retired_at : new Date(String(before.retired_at));
+ const retiredAt = ended ? (priorRetired ?? now) : null;
+ upserts.push({
+ ...key, scope, source_id: (a[0] ?? t[0]).source_id, semantics,
+ valid_ranges: stintsToMultirange(state.stints), status_now: status,
+ first_start: state.firstStart, last_start: state.lastStart, last_end: state.lastEnd,
+ undated_present: state.undatedPresent, undated_past: state.undatedPast, disputed: state.disputed,
+ recorded_at: earliest.toISOString(), retired_at: retiredAt ? retiredAt.toISOString() : null,
+ evidence_hash: hash,
+ });
+ if (!before || before.evidence_hash !== hash || (before.retired_at == null) !== (retiredAt == null)) changed++;
+ }
+ }
+
+ if (upserts.length) {
+ const written = await executeRawJsonb(exec,
+ `INSERT INTO link_relationships (from_page_id, to_page_id, link_type, scope, source_id, semantics, valid_ranges,
+ status_now, first_start, last_start, last_end, undated_present, undated_past, disputed, recorded_at, retired_at,
+ evidence_hash, refreshed_at)
+ SELECT v.from_page_id, v.to_page_id, v.link_type, v.scope, v.source_id, v.semantics, v.valid_ranges::datemultirange,
+ v.status_now, v.first_start, v.last_start, v.last_end, v.undated_present, v.undated_past, v.disputed,
+ v.recorded_at, v.retired_at, v.evidence_hash, now()
+ FROM jsonb_to_recordset(($1::jsonb)->'rows') AS v(from_page_id int, to_page_id int, link_type text, scope text,
+ source_id text, semantics text, valid_ranges text, status_now text, first_start date, last_start date,
+ last_end date, undated_present int, undated_past int, disputed boolean, recorded_at timestamptz,
+ retired_at timestamptz, evidence_hash text)
+ ON CONFLICT (from_page_id, to_page_id, link_type, scope) DO UPDATE SET
+ source_id = EXCLUDED.source_id, semantics = EXCLUDED.semantics, valid_ranges = EXCLUDED.valid_ranges,
+ status_now = EXCLUDED.status_now, first_start = EXCLUDED.first_start, last_start = EXCLUDED.last_start,
+ last_end = EXCLUDED.last_end, undated_present = EXCLUDED.undated_present, undated_past = EXCLUDED.undated_past,
+ disputed = EXCLUDED.disputed, recorded_at = LEAST(link_relationships.recorded_at, EXCLUDED.recorded_at),
+ retired_at = EXCLUDED.retired_at, evidence_hash = EXCLUDED.evidence_hash, refreshed_at = now()
+ RETURNING 1`,
+ [], [{ rows: upserts }]);
+ if (written.length !== upserts.length) throw new Error('link_relationships refresh did not persist every state row');
+ }
+ if (removals.length) {
+ const removed = await executeRawJsonb(exec,
+ `DELETE FROM link_relationships lr
+ USING jsonb_to_recordset(($1::jsonb)->'rows') AS v(from_page_id int, to_page_id int, link_type text, scope text)
+ WHERE lr.from_page_id = v.from_page_id AND lr.to_page_id = v.to_page_id AND lr.link_type = v.link_type AND lr.scope = v.scope
+ RETURNING 1`,
+ [], [{ rows: removals }]);
+ changed += removed.length;
+ }
+ if (changed) await exec.executeRaw(`SELECT nextval('graph_generation_seq')`);
+ return changed;
+}
+
+function evidenceHash(a: readonly AssertionRow[], t: readonly TransitionRow[]): string {
+ const parts = [
+ ...a.map(r => `a:${r.origin_id}:${r.tense}`),
+ ...t.map(r => `t:${r.origin_id ?? 'manual'}:${r.kind}:${dateKey(r.occurred_on)}:${r.producer}`),
+ ].sort();
+ return createHash('sha256').update(parts.join('\n')).digest('hex').slice(0, 32);
+}
+
+/** Relationship keys with any evidence touching these pages (as endpoint or origin). */
+export async function relationshipKeysForPages(exec: RawExec, pageIds: readonly number[]): Promise<RelationshipKey[]> {
+ const ids = [...new Set(pageIds.map(Number).filter(Number.isSafeInteger))];
+ if (!ids.length) return [];
+ const rows = await exec.executeRaw<RelationshipKey>(
+ `SELECT DISTINCT from_page_id, to_page_id, link_type FROM links
+ WHERE (from_page_id = ANY($1::int[]) OR to_page_id = ANY($1::int[]) OR origin_page_id = ANY($1::int[]))
+ AND link_type = ANY($2::text[])
+ UNION
+ SELECT DISTINCT from_page_id, to_page_id, link_type FROM link_transitions
+ WHERE from_page_id = ANY($1::int[]) OR to_page_id = ANY($1::int[]) OR origin_page_id = ANY($1::int[])
+ UNION
+ SELECT from_page_id, to_page_id, link_type FROM link_relationships
+ WHERE from_page_id = ANY($1::int[]) OR to_page_id = ANY($1::int[])`,
+ [ids, [...TEMPORAL_LINK_TYPES]]);
+ return rows.map(r => ({ from_page_id: Number(r.from_page_id), to_page_id: Number(r.to_page_id), link_type: r.link_type }));
+}
+
+/**
+ * Relationships whose state is missing or older than their newest evidence,
+ * oldest first. The extract cycle phase refreshes these so writers that bypass
+ * the engine (or ran before an upgrade) converge.
+ */
+export async function staleRelationshipKeys(exec: RawExec, limit = 500): Promise<RelationshipKey[]> {
+ const rows = await exec.executeRaw<RelationshipKey>(
+ `SELECT from_page_id, to_page_id, link_type FROM (
+ SELECT l.from_page_id, l.to_page_id, l.link_type, max(l.created_at) AS newest
+ FROM links l WHERE l.link_type = ANY($1::text[]) GROUP BY 1, 2, 3
+ UNION ALL
+ SELECT lt.from_page_id, lt.to_page_id, lt.link_type, max(lt.created_at)
+ FROM link_transitions lt GROUP BY 1, 2, 3
+ ) e
+ WHERE NOT EXISTS (SELECT 1 FROM link_relationships lr WHERE lr.from_page_id = e.from_page_id
+ AND lr.to_page_id = e.to_page_id AND lr.link_type = e.link_type AND lr.scope = 'all' AND lr.refreshed_at >= e.newest)
+ GROUP BY from_page_id, to_page_id, link_type
+ ORDER BY min(newest) LIMIT $2`,
+ [[...TEMPORAL_LINK_TYPES], limit]);
+ return rows.map(r => ({ from_page_id: Number(r.from_page_id), to_page_id: Number(r.to_page_id), link_type: r.link_type }));
+}
+
diff --git a/src/core/link-temporal-schema.ts b/src/core/link-temporal-schema.ts
new file mode 100644
index 0000000000..320172d6d1
--- /dev/null
+++ b/src/core/link-temporal-schema.ts
@@ -0,0 +1,104 @@
+/**
+ * Temporal typed-edge storage DDL: one canonical copy used by the schema
+ * migration and, through scripts/build-schema.ts FRAGMENTS, by fresh-install
+ * DDL. Contract: docs/guides/temporal-edges.md and src/core/link-validity.ts.
+ *
+ * - link_transitions: dated start/end evidence for a relationship
+ * (from_page_id, to_page_id, link_type). Owned by the page that states it
+ * (origin_page_id; NULL for manual edges) and replaced with that page's
+ * derived links.
+ * - link_relationships: the derived temporal state of each relationship, one
+ * row per read scope ('all' = every live origin, 'world' = evidence from
+ * private origins excluded). valid_ranges holds the stints; readers probe it
+ * by primary key. A relationship with no row reads as live.
+ * - link_edge_proposals: contradiction proposals from the edge_contradictions
+ * dream phase, with their apply/undo state.
+ * - graph_generation_seq: bumped whenever relationship state changes, so query
+ * caches can invalidate graph-dependent results.
+ */
+
+const rls = (table: string) => `DO $rls$ BEGIN
+ IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ ALTER TABLE ${table} ENABLE ROW LEVEL SECURITY;
+ END IF;
+END $rls$;`;
+
+export const LINK_TEMPORAL_SCHEMA_SQL = `
+CREATE TABLE IF NOT EXISTS link_transitions (
+ id BIGSERIAL PRIMARY KEY,
+ source_id TEXT NOT NULL,
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ kind TEXT NOT NULL CHECK (kind IN ('start','end')),
+ occurred_on DATE NOT NULL,
+ date_precision TEXT NOT NULL DEFAULT 'day' CHECK (date_precision IN ('day','month','year')),
+ producer TEXT NOT NULL CHECK (producer IN ('timeline','explicit','frontmatter','manual','inline','dream')),
+ origin_page_id INTEGER REFERENCES pages(id) ON DELETE CASCADE,
+ line_hash TEXT NOT NULL DEFAULT '',
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
+);
+CREATE UNIQUE INDEX IF NOT EXISTS link_transitions_identity_idx
+ ON link_transitions (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT;
+CREATE INDEX IF NOT EXISTS link_transitions_relationship_idx ON link_transitions (from_page_id, to_page_id, link_type);
+CREATE INDEX IF NOT EXISTS link_transitions_origin_idx ON link_transitions (origin_page_id);
+${rls('link_transitions')}
+CREATE TABLE IF NOT EXISTS link_relationships (
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ scope TEXT NOT NULL CHECK (scope IN ('all','world')),
+ source_id TEXT NOT NULL,
+ semantics TEXT NOT NULL CHECK (semantics IN ('state','event')),
+ valid_ranges DATEMULTIRANGE NOT NULL,
+ status_now TEXT NOT NULL CHECK (status_now IN ('live','ended','ended_unknown_date','not_started','disputed','event')),
+ first_start DATE,
+ last_start DATE,
+ last_end DATE,
+ undated_present INTEGER NOT NULL DEFAULT 0,
+ undated_past INTEGER NOT NULL DEFAULT 0,
+ disputed BOOLEAN NOT NULL DEFAULT false,
+ recorded_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ retired_at TIMESTAMPTZ,
+ evidence_hash TEXT NOT NULL,
+ refreshed_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ PRIMARY KEY (from_page_id, to_page_id, link_type, scope)
+);
+CREATE INDEX IF NOT EXISTS link_relationships_to_idx ON link_relationships (to_page_id, link_type, scope);
+CREATE INDEX IF NOT EXISTS link_relationships_source_idx ON link_relationships (source_id, status_now);
+${rls('link_relationships')}
+CREATE TABLE IF NOT EXISTS link_edge_proposals (
+ id BIGSERIAL PRIMARY KEY,
+ source_id TEXT NOT NULL,
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ a_to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ b_to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ evidence_hash TEXT NOT NULL,
+ status TEXT NOT NULL CHECK (status IN ('proposed','applied','rejected','undone','stale','reverted_by_user','undated_unresolved','ambiguous_same_date','compatible','error')),
+ ending_to_page_id INTEGER REFERENCES pages(id) ON DELETE SET NULL,
+ close_date DATE,
+ born_closed BOOLEAN NOT NULL DEFAULT false,
+ model TEXT,
+ confidence REAL,
+ cost_usd REAL,
+ generated_line TEXT,
+ detail TEXT,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)
+);
+CREATE INDEX IF NOT EXISTS link_edge_proposals_status_idx ON link_edge_proposals (source_id, status, created_at);
+${rls('link_edge_proposals')}
+CREATE SEQUENCE IF NOT EXISTS graph_generation_seq;
+`;
+
+/** Assertion tense on links rows; applied by the migration and mirrored in schema.sql. */
+export const LINK_ASSERTION_TENSE_SQL = `
+ALTER TABLE links ADD COLUMN IF NOT EXISTS assertion_tense TEXT;
+DO $tense$ BEGIN
+ IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = 'links_assertion_tense_check' AND conrelid = 'links'::regclass) THEN
+ ALTER TABLE links ADD CONSTRAINT links_assertion_tense_check CHECK (assertion_tense IS NULL OR assertion_tense IN ('present','past'));
+ END IF;
+END $tense$;
+`;
diff --git a/src/core/link-validity.ts b/src/core/link-validity.ts
new file mode 100644
index 0000000000..a2141fea10
--- /dev/null
+++ b/src/core/link-validity.ts
@@ -0,0 +1,414 @@
+/**
+ * Temporal typed edges: relation semantics, relationship state and the one
+ * liveness predicate every semantic graph reader uses.
+ *
+ * Model (docs/guides/temporal-edges.md):
+ * - A relationship is (from_page_id, to_page_id, link_type). Its evidence is
+ * every `links` row for it (assertions, each with a tense) plus every
+ * `link_transitions` row (dated start/end statements).
+ * - `buildRelationshipState` turns that evidence into stints. It reads only the
+ * evidence, never arrival order, so any ingestion order yields the same state.
+ * - `link_relationships` stores the state per read scope; readers filter with
+ * `relationshipFilterSql`, a primary-key probe. A relationship with no state
+ * row reads as live, so a lagging projection never hides an edge.
+ * - `closeContradiction` is the date arithmetic applied after something (an LLM
+ * verdict, a declared single-value relation) says two relationships cannot
+ * both hold. It never invents dates.
+ *
+ * Pure module except the SQL fragment builders; no engine imports.
+ */
+
+export type RelationSemantics = 'state' | 'event' | 'reference';
+export type TransitionKind = 'start' | 'end';
+export type TransitionProducer = 'timeline' | 'explicit' | 'frontmatter' | 'manual' | 'inline' | 'dream';
+export type DatePrecision = 'day' | 'month' | 'year';
+export type AssertionTense = 'present' | 'past';
+export type RelationshipStatus = 'live' | 'ended' | 'ended_unknown_date' | 'not_started' | 'disputed' | 'event';
+export type EdgeStatusFilter = 'live' | 'ended' | 'all';
+export type RelationshipScope = 'all' | 'world';
+
+/**
+ * State relations can end; event relations happened on a date and stay true
+ * afterwards; everything else is a plain reference with no temporal state.
+ * Open-loop edges (owes_to, awaiting_reply_from) keep their own lifecycle in
+ * open_loops, so they are references here.
+ */
+export const RELATION_SEMANTICS: Readonly<Record<string, RelationSemantics>> = {
+ works_at: 'state',
+ advises: 'state',
+ yc_partner: 'state',
+ founded: 'event',
+ invested_in: 'event',
+ led_round: 'event',
+ attended: 'event',
+ discussed_in: 'event',
+ cited: 'event',
+};
+
+export function relationSemantics(linkType: string | null | undefined): RelationSemantics {
+ return (linkType && RELATION_SEMANTICS[linkType]) || 'reference';
+}
+
+export function isTemporalLinkType(linkType: string | null | undefined): boolean {
+ return relationSemantics(linkType) !== 'reference';
+}
+
+export const TEMPORAL_LINK_TYPES: readonly string[] = Object.keys(RELATION_SEMANTICS);
+
+// ─── Dates ───────────────────────────────────────────────────────────────
+
+const DATE_RE = /^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?$/;
+
+/**
+ * Normalize a full or partial calendar date. `2021` → 2021-01-01 (year),
+ * `2021-04` → 2021-04-01 (month), `2021-04-09` → itself (day). Rejects
+ * impossible dates (2021-02-30) and anything else.
+ */
+export function normalizePartialDate(raw: string | null | undefined): { date: string; precision: DatePrecision } | null {
+ if (typeof raw !== 'string') return null;
+ const m = DATE_RE.exec(raw.trim());
+ if (!m) return null;
+ const year = Number(m[1]);
+ const month = m[2] === undefined ? 1 : Number(m[2]);
+ const day = m[3] === undefined ? 1 : Number(m[3]);
+ if (year < 1000 || month < 1 || month > 12 || day < 1) return null;
+ const d = new Date(Date.UTC(year, month - 1, day));
+ if (d.getUTCFullYear() !== year || d.getUTCMonth() !== month - 1 || d.getUTCDate() !== day) return null;
+ const date = `${m[1]}-${String(month).padStart(2, '0')}-${String(day).padStart(2, '0')}`;
+ return { date, precision: m[3] !== undefined ? 'day' : m[2] !== undefined ? 'month' : 'year' };
+}
+
+/** Strict YYYY-MM-DD (op params). */
+export function isCalendarDate(raw: unknown): raw is string {
+ return typeof raw === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(raw) && normalizePartialDate(raw)?.date === raw;
+}
+
+/** Today's date in UTC, the reference "now" for liveness. */
+export function utcToday(now: Date = new Date()): string {
+ return now.toISOString().slice(0, 10);
+}
+
+/** Date column values arrive as Date (PGLite) or string (postgres.js); normalize to YYYY-MM-DD. */
+export function dateKey(value: unknown): string | null {
+ if (value == null) return null;
+ if (value instanceof Date) return value.toISOString().slice(0, 10);
+ const s = String(value);
+ return /^\d{4}-\d{2}-\d{2}/.test(s) ? s.slice(0, 10) : null;
+}
+
+// ─── Relationship state ──────────────────────────────────────────────────
+
+/** A half-open stint [from, until). NULL bound = unbounded. */
+export interface Stint { from: string | null; until: string | null }
+
+export interface AssertionEvidence {
+ tense: AssertionTense;
+ /** Page that asserts it (origin_page_id, else from_page_id). */
+ originPageId: number | null;
+}
+
+export interface TransitionEvidence {
+ kind: TransitionKind;
+ occurredOn: string;
+ producer: TransitionProducer;
+ originPageId: number | null;
+}
+
+export interface RelationshipState {
+ semantics: Exclude<RelationSemantics, 'reference'>;
+ stints: Stint[];
+ firstStart: string | null;
+ lastStart: string | null;
+ lastEnd: string | null;
+ undatedPresent: number;
+ undatedPast: number;
+ disputed: boolean;
+ /** Present-tense assertions that a later dated end overrides. */
+ staleAssertions: number;
+}
+
+/**
+ * Turn a relationship's evidence into stints.
+ *
+ * State relations:
+ * 1. Dated transitions collapse to one event per (kind, date), sorted by date
+ * with an end before a start on the same day.
+ * 2. A start opens a stint when none is open (a second start, e.g. a promotion,
+ * is absorbed). An end closes the open stint; an end with no open stint
+ * closes an implicit stint (-inf, end) only when no stint exists yet, so
+ * repeated unmatched ends collapse to the first.
+ * 3. Undated present assertions: with no dated events they form (-inf, inf);
+ * if the last event is a start its stint stays open; if the last event is an
+ * end they do not reopen it (dated evidence beats undated) and count as
+ * stale assertions.
+ * 4. Undated past assertions with no dated events: no undated present →
+ * ended at an unknown date (no stints); undated present from another origin
+ * → disputed (kept live, flagged).
+ * Event relations: [earliest dated occurrence, inf), or (-inf, inf) undated.
+ */
+export function buildRelationshipState(
+ semantics: Exclude<RelationSemantics, 'reference'>,
+ assertions: readonly AssertionEvidence[],
+ transitions: readonly TransitionEvidence[],
+): RelationshipState {
+ const undatedPresent = assertions.filter(a => a.tense === 'present').length;
+ const undatedPast = assertions.filter(a => a.tense === 'past').length;
+ const events = dedupeEvents(transitions);
+ const starts = events.filter(e => e.kind === 'start').map(e => e.date);
+ const ends = events.filter(e => e.kind === 'end').map(e => e.date);
+ const base = {
+ semantics,
+ firstStart: starts[0] ?? null,
+ lastStart: starts.length ? starts[starts.length - 1] : null,
+ lastEnd: ends.length ? ends[ends.length - 1] : null,
+ undatedPresent,
+ undatedPast,
+ };
+
+ if (semantics === 'event') {
+ const first = events.length ? events[0].date : null;
+ return { ...base, stints: [{ from: first, until: null }], disputed: false, staleAssertions: 0 };
+ }
+
+ if (events.length === 0) {
+ if (undatedPresent > 0) {
+ return { ...base, stints: [{ from: null, until: null }], disputed: pastFromOtherOrigin(assertions), staleAssertions: 0 };
+ }
+ // Only past-tense assertions (or no evidence at all): ended, date unknown.
+ return { ...base, stints: [], disputed: false, staleAssertions: 0 };
+ }
+
+ const stints: Stint[] = [];
+ let open: Stint | null = null;
+ for (const e of events) {
+ if (e.kind === 'start') {
+ if (!open) { open = { from: e.date, until: null }; stints.push(open); }
+ } else if (open) {
+ open.until = e.date;
+ open = null;
+ } else if (stints.length === 0) {
+ stints.push({ from: null, until: e.date });
+ }
+ }
+ const lastEvent = events[events.length - 1];
+ const staleAssertions = lastEvent.kind === 'end' ? undatedPresent : 0;
+ let disputed = false;
+ if (open && undatedPast > 0) {
+ if (undatedPresent === 0) {
+ // Dated start, no dated end, and every assertion says it is over: the
+ // stint ended at an unknown date, so it is neither live now nor at any
+ // later as-of date. Earlier closed stints keep their history.
+ stints.pop();
+ } else {
+ disputed = pastFromOtherOrigin(assertions);
+ }
+ }
+ return { ...base, stints: mergeStints(stints), disputed, staleAssertions };
+}
+
+function pastFromOtherOrigin(assertions: readonly AssertionEvidence[]): boolean {
+ const presentOrigins = new Set(assertions.filter(a => a.tense === 'present').map(a => a.originPageId));
+ return assertions.some(a => a.tense === 'past' && !presentOrigins.has(a.originPageId));
+}
+
+function dedupeEvents(transitions: readonly TransitionEvidence[]): Array<{ kind: TransitionKind; date: string }> {
+ const seen = new Set<string>();
+ const out: Array<{ kind: TransitionKind; date: string }> = [];
+ for (const t of transitions) {
+ const date = dateKey(t.occurredOn);
+ if (!date) continue;
+ const key = `${t.kind}:${date}`;
+ if (seen.has(key)) continue;
+ seen.add(key);
+ out.push({ kind: t.kind, date });
+ }
+ return out.sort((a, b) => a.date < b.date ? -1 : a.date > b.date ? 1 : a.kind === b.kind ? 0 : a.kind === 'end' ? -1 : 1);
+}
+
+/** Merge touching/overlapping stints and drop empty ones (until <= from). */
+function mergeStints(stints: Stint[]): Stint[] {
+ const valid = stints.filter(s => !(s.from && s.until && s.until <= s.from));
+ const sorted = [...valid].sort((a, b) => (a.from ?? '') < (b.from ?? '') ? -1 : (a.from ?? '') > (b.from ?? '') ? 1 : 0);
+ const out: Stint[] = [];
+ for (const s of sorted) {
+ const prev = out[out.length - 1];
+ if (prev && (prev.until === null || (s.from !== null && prev.until >= s.from))) {
+ if (prev.until !== null && (s.until === null || s.until > prev.until)) prev.until = s.until;
+ continue;
+ }
+ out.push({ ...s });
+ }
+ return out;
+}
+
+export function stintCovers(s: Stint, date: string): boolean {
+ return (s.from === null || s.from <= date) && (s.until === null || date < s.until);
+}
+
+/** Status of a relationship at `date` (default today, UTC). */
+export function statusAt(state: Pick<RelationshipState, 'semantics' | 'stints' | 'disputed' | 'undatedPast'>, date: string = utcToday()): RelationshipStatus {
+ if (state.stints.some(s => stintCovers(s, date))) {
+ if (state.semantics === 'event') return 'event';
+ return state.disputed ? 'disputed' : 'live';
+ }
+ if (state.stints.length === 0) return state.semantics === 'event' ? 'not_started' : 'ended_unknown_date';
+ if (state.stints.every(s => s.from !== null && s.from > date)) return 'not_started';
+ return 'ended';
+}
+
+// ─── Multirange text form ────────────────────────────────────────────────
+
+/** Postgres datemultirange literal: '{[2021-04-01,2025-03-01),[2026-01-01,)}', '{}' when empty. */
+export function stintsToMultirange(stints: readonly Stint[]): string {
+ return `{${stints.map(s => `${s.from === null ? '(' : '['}${s.from ?? ''},${s.until ?? ''})`).join(',')}}`;
+}
+
+/** Parse a datemultirange text value back into stints (both engines return the canonical text form). */
+export function parseMultirange(text: unknown): Stint[] {
+ if (typeof text !== 'string') return [];
+ const out: Stint[] = [];
+ for (const m of text.matchAll(/([[(])([^,\])]*),([^,\])]*)([\])])/g)) {
+ let from: string | null = m[2] ? m[2].replace(/"/g, '') : null;
+ let until: string | null = m[3] ? m[3].replace(/"/g, '') : null;
+ if (from === '-infinity') from = null;
+ if (until === 'infinity') until = null;
+ out.push({ from, until });
+ }
+ return out;
+}
+
+// ─── Contradiction closing (pure date arithmetic) ────────────────────────
+
+export interface ContradictionSide {
+ /** Relationship-specific dated start (latest), or null when unknown. */
+ lastStart: string | null;
+ stints: readonly Stint[];
+ /** When the brain first recorded this relationship. */
+ recordedAt: string | Date | null;
+}
+
+export type ContradictionOutcome =
+ | { action: 'close'; side: 'a' | 'b'; closeDate: string; bornClosed: boolean }
+ | { action: 'none'; reason: 'undated_unresolved' | 'ambiguous_same_date' | 'already_disjoint' };
+
+/**
+ * Given two state relationships that cannot both hold, end the one that
+ * started earlier at the date the other started. Dates come only from each
+ * relationship's own dated start; page dates and ingestion time never count.
+ * The arithmetic is symmetric in valid time, so arrival order cannot change
+ * the result; `bornClosed` labels the case where the relationship being ended
+ * is the one recorded later (out-of-order arrival).
+ */
+export function closeContradiction(a: ContradictionSide, b: ContradictionSide): ContradictionOutcome {
+ const da = dateKey(a.lastStart);
+ const db = dateKey(b.lastStart);
+ if (!da || !db) return { action: 'none', reason: 'undated_unresolved' };
+ if (da === db) return { action: 'none', reason: 'ambiguous_same_date' };
+ const [older, newer, olderSide] = da < db ? [a, db, 'a' as const] : [b, da, 'b' as const];
+ const olderCurrent = older.stints[older.stints.length - 1];
+ if (!olderCurrent || (olderCurrent.until !== null && olderCurrent.until <= newer)) {
+ return { action: 'none', reason: 'already_disjoint' };
+ }
+ const recordedOlder = recordedMs(older.recordedAt);
+ const recordedNewer = recordedMs((olderSide === 'a' ? b : a).recordedAt);
+ return { action: 'close', side: olderSide, closeDate: newer, bornClosed: recordedOlder > recordedNewer };
+}
+
+function recordedMs(v: string | Date | null): number {
+ if (v == null) return 0;
+ const t = v instanceof Date ? v.getTime() : Date.parse(String(v));
+ return Number.isFinite(t) ? t : 0;
+}
+
+// ─── SQL ─────────────────────────────────────────────────────────────────
+
+export interface EdgeTemporalOpts {
+ /** live (default), ended, or all. */
+ status?: EdgeStatusFilter;
+ /** Valid-time reference day, YYYY-MM-DD; default today (UTC). */
+ asOf?: string;
+ /** Overlap window [from, until) — "during 2022" is ['2022-01-01','2023-01-01']. */
+ during?: { from: string; until: string };
+ /** Exclude evidence from private origins (remote callers). */
+ excludePrivate?: boolean;
+ /** Read policy off (graph.edge_validity=off): no filtering. */
+ disabled?: boolean;
+}
+
+/** SQL literal for a validated YYYY-MM-DD date (never user free text). */
+function dateLiteral(date: string): string {
+ if (!isCalendarDate(date)) throw new TypeError(`temporal edge filter: invalid date ${JSON.stringify(date)}`);
+ return `DATE '${date}'`;
+}
+
+/**
+ * WHERE-clause fragment for a `links` row alias. Returns `TRUE` when no
+ * filtering applies. Dates are validated and inlined as literals so the
+ * fragment composes into statements with any parameter numbering.
+ *
+ * A row passes when its relationship has no state row (reference type, or not
+ * yet refreshed) or its state row matches the requested status.
+ */
+export function relationshipFilterSql(linkAlias: string, opts: EdgeTemporalOpts = {}): string {
+ const status = opts.status ?? 'live';
+ if (opts.disabled || (status === 'all' && !opts.during)) return 'TRUE';
+ const scope = opts.excludePrivate ? 'world' : 'all';
+ const day = opts.asOf ? dateLiteral(opts.asOf) : `(now() AT TIME ZONE 'UTC')::date`;
+ const probe = `lr.from_page_id = ${linkAlias}.from_page_id AND lr.to_page_id = ${linkAlias}.to_page_id
+ AND lr.link_type = ${linkAlias}.link_type AND lr.scope = '${scope}'`;
+ if (opts.during) {
+ const range = `daterange(${dateLiteral(opts.during.from)}, ${dateLiteral(opts.during.until)})`;
+ return `NOT EXISTS (SELECT 1 FROM link_relationships lr WHERE ${probe} AND NOT (lr.valid_ranges && ${range}))`;
+ }
+ if (status === 'ended') {
+ return `EXISTS (SELECT 1 FROM link_relationships lr WHERE ${probe} AND lr.semantics = 'state'
+ AND NOT (lr.valid_ranges @> ${day}) AND (lr.first_start IS NULL OR lr.first_start <= ${day}))`;
+ }
+ const disputedClause = opts.asOf ? ' OR lr.disputed' : '';
+ return `NOT EXISTS (SELECT 1 FROM link_relationships lr WHERE ${probe} AND (NOT (lr.valid_ranges @> ${day})${disputedClause}))`;
+}
+
+/** Validate op-level temporal params; returns normalized opts or an error message. */
+export function parseTemporalParams(p: { status?: unknown; as_of?: unknown; during?: unknown }):
+ { ok: true; opts: EdgeTemporalOpts } | { ok: false; param: string; message: string } {
+ const opts: EdgeTemporalOpts = {};
+ if (p.status !== undefined) {
+ if (p.status !== 'live' && p.status !== 'ended' && p.status !== 'all') {
+ return { ok: false, param: 'status', message: `status must be one of live, ended, all (got ${JSON.stringify(p.status)})` };
+ }
+ opts.status = p.status;
+ }
+ if (p.as_of !== undefined) {
+ if (!isCalendarDate(p.as_of)) return { ok: false, param: 'as_of', message: `as_of must be a calendar date YYYY-MM-DD (got ${JSON.stringify(p.as_of)})` };
+ opts.asOf = p.as_of;
+ }
+ if (p.during !== undefined) {
+ const during = parseDuring(p.during);
+ if (!during) return { ok: false, param: 'during', message: `during must be YYYY, YYYY-MM, YYYY-MM-DD or FROM..UNTIL of those (got ${JSON.stringify(p.during)})` };
+ opts.during = during;
+ }
+ return { ok: true, opts };
+}
+
+/**
+ * "2022" → [2022-01-01, 2023-01-01); "2022-03" → that month; "2022-03-04" →
+ * that day; "2021..2023-06" → [2021-01-01, 2023-07-01) (the end is inclusive
+ * of its own period).
+ */
+export function parseDuring(raw: unknown): { from: string; until: string } | null {
+ if (typeof raw !== 'string') return null;
+ const [a, b] = raw.split('..');
+ const start = normalizePartialDate(a);
+ const endBase = normalizePartialDate(b ?? a);
+ if (!start || !endBase) return null;
+ const until = periodEnd(endBase.date, endBase.precision);
+ return until > start.date ? { from: start.date, until } : null;
+}
+
+function periodEnd(date: string, precision: DatePrecision): string {
+ const [y, m, d] = date.split('-').map(Number);
+ const next = precision === 'year' ? new Date(Date.UTC(y + 1, 0, 1))
+ : precision === 'month' ? new Date(Date.UTC(y, m, 1))
+ : new Date(Date.UTC(y, m - 1, d + 1));
+ return next.toISOString().slice(0, 10);
+}
diff --git a/src/core/pglite-schema.generated.ts b/src/core/pglite-schema.generated.ts
index f9af4910a2..b256c24e3a 100644
--- a/src/core/pglite-schema.generated.ts
+++ b/src/core/pglite-schema.generated.ts
@@ -185,6 +185,7 @@ CREATE TABLE IF NOT EXISTS links (
origin_field TEXT,
resolution_type TEXT CHECK (resolution_type IS NULL OR resolution_type IN ('qualified', 'unqualified')),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ assertion_tense TEXT CONSTRAINT links_assertion_tense_check CHECK (assertion_tense IS NULL OR assertion_tense IN ('present', 'past')),
CONSTRAINT links_from_to_type_source_origin_unique
UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)
);
@@ -1826,6 +1827,87 @@ DO \$rls\$ BEGIN
END IF;
END \$rls\$;
+-- Temporal typed edges: dated evidence, derived relationship state, proposals.
+CREATE TABLE IF NOT EXISTS link_transitions (
+ id BIGSERIAL PRIMARY KEY,
+ source_id TEXT NOT NULL,
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ kind TEXT NOT NULL CHECK (kind IN ('start','end')),
+ occurred_on DATE NOT NULL,
+ date_precision TEXT NOT NULL DEFAULT 'day' CHECK (date_precision IN ('day','month','year')),
+ producer TEXT NOT NULL CHECK (producer IN ('timeline','explicit','frontmatter','manual','inline','dream')),
+ origin_page_id INTEGER REFERENCES pages(id) ON DELETE CASCADE,
+ line_hash TEXT NOT NULL DEFAULT '',
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
+);
+CREATE UNIQUE INDEX IF NOT EXISTS link_transitions_identity_idx
+ ON link_transitions (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT;
+CREATE INDEX IF NOT EXISTS link_transitions_relationship_idx ON link_transitions (from_page_id, to_page_id, link_type);
+CREATE INDEX IF NOT EXISTS link_transitions_origin_idx ON link_transitions (origin_page_id);
+DO \$rls\$ BEGIN
+ IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ ALTER TABLE link_transitions ENABLE ROW LEVEL SECURITY;
+ END IF;
+END \$rls\$;
+CREATE TABLE IF NOT EXISTS link_relationships (
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ scope TEXT NOT NULL CHECK (scope IN ('all','world')),
+ source_id TEXT NOT NULL,
+ semantics TEXT NOT NULL CHECK (semantics IN ('state','event')),
+ valid_ranges DATEMULTIRANGE NOT NULL,
+ status_now TEXT NOT NULL CHECK (status_now IN ('live','ended','ended_unknown_date','not_started','disputed','event')),
+ first_start DATE,
+ last_start DATE,
+ last_end DATE,
+ undated_present INTEGER NOT NULL DEFAULT 0,
+ undated_past INTEGER NOT NULL DEFAULT 0,
+ disputed BOOLEAN NOT NULL DEFAULT false,
+ recorded_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ retired_at TIMESTAMPTZ,
+ evidence_hash TEXT NOT NULL,
+ refreshed_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ PRIMARY KEY (from_page_id, to_page_id, link_type, scope)
+);
+CREATE INDEX IF NOT EXISTS link_relationships_to_idx ON link_relationships (to_page_id, link_type, scope);
+CREATE INDEX IF NOT EXISTS link_relationships_source_idx ON link_relationships (source_id, status_now);
+DO \$rls\$ BEGIN
+ IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ ALTER TABLE link_relationships ENABLE ROW LEVEL SECURITY;
+ END IF;
+END \$rls\$;
+CREATE TABLE IF NOT EXISTS link_edge_proposals (
+ id BIGSERIAL PRIMARY KEY,
+ source_id TEXT NOT NULL,
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ a_to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ b_to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ evidence_hash TEXT NOT NULL,
+ status TEXT NOT NULL CHECK (status IN ('proposed','applied','rejected','undone','stale','reverted_by_user','undated_unresolved','ambiguous_same_date','compatible','error')),
+ ending_to_page_id INTEGER REFERENCES pages(id) ON DELETE SET NULL,
+ close_date DATE,
+ born_closed BOOLEAN NOT NULL DEFAULT false,
+ model TEXT,
+ confidence REAL,
+ cost_usd REAL,
+ generated_line TEXT,
+ detail TEXT,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)
+);
+CREATE INDEX IF NOT EXISTS link_edge_proposals_status_idx ON link_edge_proposals (source_id, status, created_at);
+DO \$rls\$ BEGIN
+ IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ ALTER TABLE link_edge_proposals ENABLE ROW LEVEL SECURITY;
+ END IF;
+END \$rls\$;
+CREATE SEQUENCE IF NOT EXISTS graph_generation_seq;
+
`;
diff --git a/src/core/schema-embedded.generated.ts b/src/core/schema-embedded.generated.ts
index 01044b0e99..50d6715af3 100644
--- a/src/core/schema-embedded.generated.ts
+++ b/src/core/schema-embedded.generated.ts
@@ -505,6 +505,10 @@ CREATE TABLE IF NOT EXISTS links (
-- extraction time. NULL for legacy/manual/frontmatter edges.
resolution_type TEXT CHECK (resolution_type IS NULL OR resolution_type IN ('qualified', 'unqualified')),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ -- Temporal typed edges: tense of the assertion on its origin page ('past' for
+ -- "previously at", "former CTO of"); NULL = present. Temporal state lives in
+ -- link_transitions / link_relationships (src/core/link-temporal-schema.ts).
+ assertion_tense TEXT CONSTRAINT links_assertion_tense_check CHECK (assertion_tense IS NULL OR assertion_tense IN ('present', 'past')),
-- NULLS NOT DISTINCT (PG15+) so two rows with link_source IS NULL or
-- origin_page_id IS NULL collide as expected. Without this, every row with
-- NULL origin_page_id (markdown/manual edges) would be treated as unique.
@@ -2547,6 +2551,89 @@ DO \$rls\$ BEGIN
END \$rls\$;
-- END GENERATED from src/core/facts/relink-schema.ts (FACT_RELINK_SCHEMA_SQL)
+-- Temporal typed edges: dated evidence, derived relationship state, proposals.
+-- BEGIN GENERATED from src/core/link-temporal-schema.ts (LINK_TEMPORAL_SCHEMA_SQL). Edit that file, then run: bun run build:schema
+CREATE TABLE IF NOT EXISTS link_transitions (
+ id BIGSERIAL PRIMARY KEY,
+ source_id TEXT NOT NULL,
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ kind TEXT NOT NULL CHECK (kind IN ('start','end')),
+ occurred_on DATE NOT NULL,
+ date_precision TEXT NOT NULL DEFAULT 'day' CHECK (date_precision IN ('day','month','year')),
+ producer TEXT NOT NULL CHECK (producer IN ('timeline','explicit','frontmatter','manual','inline','dream')),
+ origin_page_id INTEGER REFERENCES pages(id) ON DELETE CASCADE,
+ line_hash TEXT NOT NULL DEFAULT '',
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
+);
+CREATE UNIQUE INDEX IF NOT EXISTS link_transitions_identity_idx
+ ON link_transitions (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT;
+CREATE INDEX IF NOT EXISTS link_transitions_relationship_idx ON link_transitions (from_page_id, to_page_id, link_type);
+CREATE INDEX IF NOT EXISTS link_transitions_origin_idx ON link_transitions (origin_page_id);
+DO \$rls\$ BEGIN
+ IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ ALTER TABLE link_transitions ENABLE ROW LEVEL SECURITY;
+ END IF;
+END \$rls\$;
+CREATE TABLE IF NOT EXISTS link_relationships (
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ scope TEXT NOT NULL CHECK (scope IN ('all','world')),
+ source_id TEXT NOT NULL,
+ semantics TEXT NOT NULL CHECK (semantics IN ('state','event')),
+ valid_ranges DATEMULTIRANGE NOT NULL,
+ status_now TEXT NOT NULL CHECK (status_now IN ('live','ended','ended_unknown_date','not_started','disputed','event')),
+ first_start DATE,
+ last_start DATE,
+ last_end DATE,
+ undated_present INTEGER NOT NULL DEFAULT 0,
+ undated_past INTEGER NOT NULL DEFAULT 0,
+ disputed BOOLEAN NOT NULL DEFAULT false,
+ recorded_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ retired_at TIMESTAMPTZ,
+ evidence_hash TEXT NOT NULL,
+ refreshed_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ PRIMARY KEY (from_page_id, to_page_id, link_type, scope)
+);
+CREATE INDEX IF NOT EXISTS link_relationships_to_idx ON link_relationships (to_page_id, link_type, scope);
+CREATE INDEX IF NOT EXISTS link_relationships_source_idx ON link_relationships (source_id, status_now);
+DO \$rls\$ BEGIN
+ IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ ALTER TABLE link_relationships ENABLE ROW LEVEL SECURITY;
+ END IF;
+END \$rls\$;
+CREATE TABLE IF NOT EXISTS link_edge_proposals (
+ id BIGSERIAL PRIMARY KEY,
+ source_id TEXT NOT NULL,
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ a_to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ b_to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ evidence_hash TEXT NOT NULL,
+ status TEXT NOT NULL CHECK (status IN ('proposed','applied','rejected','undone','stale','reverted_by_user','undated_unresolved','ambiguous_same_date','compatible','error')),
+ ending_to_page_id INTEGER REFERENCES pages(id) ON DELETE SET NULL,
+ close_date DATE,
+ born_closed BOOLEAN NOT NULL DEFAULT false,
+ model TEXT,
+ confidence REAL,
+ cost_usd REAL,
+ generated_line TEXT,
+ detail TEXT,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)
+);
+CREATE INDEX IF NOT EXISTS link_edge_proposals_status_idx ON link_edge_proposals (source_id, status, created_at);
+DO \$rls\$ BEGIN
+ IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ ALTER TABLE link_edge_proposals ENABLE ROW LEVEL SECURITY;
+ END IF;
+END \$rls\$;
+CREATE SEQUENCE IF NOT EXISTS graph_generation_seq;
+-- END GENERATED from src/core/link-temporal-schema.ts (LINK_TEMPORAL_SCHEMA_SQL)
+
-- #5255/#5176 (O-DX-8): last upstream observation per source, recorded by sync
-- from the checkout's Git state (upstream ref, its last fetch/push time, commits
-- the synced commit lacks); doctor sync_freshness reads it with no subprocess.
diff --git a/src/core/schema-migrations/registry.generated.ts b/src/core/schema-migrations/registry.generated.ts
index 16ef4d9ecc..0022578960 100644
--- a/src/core/schema-migrations/registry.generated.ts
+++ b/src/core/schema-migrations/registry.generated.ts
@@ -201,6 +201,7 @@ import { v197 } from './v197-managed-guard-null-source-fallback.ts';
import { v198 } from './v198-publication-failure-detail.ts';
import { v199 } from './v199-chronicle-page-state.ts';
import { v200 } from './v200-sync-hold-page-index.ts';
+import { v201 } from './v201-links-temporal-state.ts';
// Array order is historical (see HISTORICAL_ARRAY_ORDER in the generator); the
// runner sorts by version before applying.
@@ -400,4 +401,5 @@ export const MIGRATIONS: Migration[] = [
v198,
v199,
v200,
+ v201,
];
diff --git a/src/core/schema-migrations/v201-links-temporal-state.ts b/src/core/schema-migrations/v201-links-temporal-state.ts
new file mode 100644
index 0000000000..646f058a3f
--- /dev/null
+++ b/src/core/schema-migrations/v201-links-temporal-state.ts
@@ -0,0 +1,19 @@
+import type { Migration } from './types.ts';
+import { LINK_ASSERTION_TENSE_SQL, LINK_TEMPORAL_SCHEMA_SQL } from '../link-temporal-schema.ts';
+
+// Applied by src/core/migrate.ts on the next initSchema(); see docs/ENGINES.md
+// ("Canonical schema sources") for when schema.sql or a TS fragment also changes.
+//
+// Temporal typed edges: links.assertion_tense, link_transitions (dated
+// evidence), link_relationships (derived state per relationship and scope),
+// link_edge_proposals and graph_generation_seq. DDL in
+// src/core/link-temporal-schema.ts. Additive only: the links identity and its
+// ON CONFLICT targets are unchanged, so writers from the previous release keep
+// working; relationships without a state row read as live.
+export const v201: Migration = {
+ version: 201,
+ name: 'links_temporal_state',
+ idempotent: true,
+ sql: `${LINK_ASSERTION_TENSE_SQL}
+${LINK_TEMPORAL_SCHEMA_SQL}`,
+};
diff --git a/src/schema.sql b/src/schema.sql
index 43fed65c5e..e0fe962c13 100644
--- a/src/schema.sql
+++ b/src/schema.sql
@@ -501,6 +501,10 @@ CREATE TABLE IF NOT EXISTS links (
-- extraction time. NULL for legacy/manual/frontmatter edges.
resolution_type TEXT CHECK (resolution_type IS NULL OR resolution_type IN ('qualified', 'unqualified')),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ -- Temporal typed edges: tense of the assertion on its origin page ('past' for
+ -- "previously at", "former CTO of"); NULL = present. Temporal state lives in
+ -- link_transitions / link_relationships (src/core/link-temporal-schema.ts).
+ assertion_tense TEXT CONSTRAINT links_assertion_tense_check CHECK (assertion_tense IS NULL OR assertion_tense IN ('present', 'past')),
-- NULLS NOT DISTINCT (PG15+) so two rows with link_source IS NULL or
-- origin_page_id IS NULL collide as expected. Without this, every row with
-- NULL origin_page_id (markdown/manual edges) would be treated as unique.
@@ -2543,6 +2547,89 @@ DO $rls$ BEGIN
END $rls$;
-- END GENERATED from src/core/facts/relink-schema.ts (FACT_RELINK_SCHEMA_SQL)
+-- Temporal typed edges: dated evidence, derived relationship state, proposals.
+-- BEGIN GENERATED from src/core/link-temporal-schema.ts (LINK_TEMPORAL_SCHEMA_SQL). Edit that file, then run: bun run build:schema
+CREATE TABLE IF NOT EXISTS link_transitions (
+ id BIGSERIAL PRIMARY KEY,
+ source_id TEXT NOT NULL,
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ kind TEXT NOT NULL CHECK (kind IN ('start','end')),
+ occurred_on DATE NOT NULL,
+ date_precision TEXT NOT NULL DEFAULT 'day' CHECK (date_precision IN ('day','month','year')),
+ producer TEXT NOT NULL CHECK (producer IN ('timeline','explicit','frontmatter','manual','inline','dream')),
+ origin_page_id INTEGER REFERENCES pages(id) ON DELETE CASCADE,
+ line_hash TEXT NOT NULL DEFAULT '',
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
+);
+CREATE UNIQUE INDEX IF NOT EXISTS link_transitions_identity_idx
+ ON link_transitions (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT;
+CREATE INDEX IF NOT EXISTS link_transitions_relationship_idx ON link_transitions (from_page_id, to_page_id, link_type);
+CREATE INDEX IF NOT EXISTS link_transitions_origin_idx ON link_transitions (origin_page_id);
+DO $rls$ BEGIN
+ IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ ALTER TABLE link_transitions ENABLE ROW LEVEL SECURITY;
+ END IF;
+END $rls$;
+CREATE TABLE IF NOT EXISTS link_relationships (
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ scope TEXT NOT NULL CHECK (scope IN ('all','world')),
+ source_id TEXT NOT NULL,
+ semantics TEXT NOT NULL CHECK (semantics IN ('state','event')),
+ valid_ranges DATEMULTIRANGE NOT NULL,
+ status_now TEXT NOT NULL CHECK (status_now IN ('live','ended','ended_unknown_date','not_started','disputed','event')),
+ first_start DATE,
+ last_start DATE,
+ last_end DATE,
+ undated_present INTEGER NOT NULL DEFAULT 0,
+ undated_past INTEGER NOT NULL DEFAULT 0,
+ disputed BOOLEAN NOT NULL DEFAULT false,
+ recorded_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ retired_at TIMESTAMPTZ,
+ evidence_hash TEXT NOT NULL,
+ refreshed_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ PRIMARY KEY (from_page_id, to_page_id, link_type, scope)
+);
+CREATE INDEX IF NOT EXISTS link_relationships_to_idx ON link_relationships (to_page_id, link_type, scope);
+CREATE INDEX IF NOT EXISTS link_relationships_source_idx ON link_relationships (source_id, status_now);
+DO $rls$ BEGIN
+ IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ ALTER TABLE link_relationships ENABLE ROW LEVEL SECURITY;
+ END IF;
+END $rls$;
+CREATE TABLE IF NOT EXISTS link_edge_proposals (
+ id BIGSERIAL PRIMARY KEY,
+ source_id TEXT NOT NULL,
+ from_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ a_to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ b_to_page_id INTEGER NOT NULL REFERENCES pages(id) ON DELETE CASCADE,
+ link_type TEXT NOT NULL,
+ evidence_hash TEXT NOT NULL,
+ status TEXT NOT NULL CHECK (status IN ('proposed','applied','rejected','undone','stale','reverted_by_user','undated_unresolved','ambiguous_same_date','compatible','error')),
+ ending_to_page_id INTEGER REFERENCES pages(id) ON DELETE SET NULL,
+ close_date DATE,
+ born_closed BOOLEAN NOT NULL DEFAULT false,
+ model TEXT,
+ confidence REAL,
+ cost_usd REAL,
+ generated_line TEXT,
+ detail TEXT,
+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
+ UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)
+);
+CREATE INDEX IF NOT EXISTS link_edge_proposals_status_idx ON link_edge_proposals (source_id, status, created_at);
+DO $rls$ BEGIN
+ IF EXISTS (SELECT 1 FROM pg_roles r WHERE pg_has_role(current_user, r.oid, 'USAGE') AND (r.rolbypassrls OR r.rolsuper)) THEN
+ ALTER TABLE link_edge_proposals ENABLE ROW LEVEL SECURITY;
+ END IF;
+END $rls$;
+CREATE SEQUENCE IF NOT EXISTS graph_generation_seq;
+-- END GENERATED from src/core/link-temporal-schema.ts (LINK_TEMPORAL_SCHEMA_SQL)
+
-- #5255/#5176 (O-DX-8): last upstream observation per source, recorded by sync
-- from the checkout's Git state (upstream ref, its last fetch/push time, commits
-- the synced commit lacks); doctor sync_freshness reads it with no subprocess.
diff --git a/test/e2e/link-relationships-postgres.test.ts b/test/e2e/link-relationships-postgres.test.ts
new file mode 100644
index 0000000000..f5bbcba889
--- /dev/null
+++ b/test/e2e/link-relationships-postgres.test.ts
@@ -0,0 +1,23 @@
+/**
+ * Temporal typed edges on Postgres: the shared relationship-state scenario
+ * (test/helpers/link-temporal-scenario.ts) against a real database, covering
+ * datemultirange text, JSONB recordset binding and the graph generation
+ * sequence through postgres.js.
+ */
+import { test } from 'bun:test';
+import { PostgresEngine } from '../../src/core/postgres-engine.ts';
+import { assertSafeE2eDatabaseUrl } from '../helpers/db-guard.ts';
+import { defineLinkRelationshipTests } from '../helpers/link-temporal-scenario.ts';
+
+const databaseUrl = process.env.DATABASE_URL;
+if (!databaseUrl) {
+ test.skip('link relationships Postgres scenario skipped (DATABASE_URL unset)', () => {});
+} else {
+ defineLinkRelationshipTests('postgres', async () => {
+ const eng = new PostgresEngine();
+ assertSafeE2eDatabaseUrl(databaseUrl);
+ await eng.connect({ database_url: databaseUrl });
+ await eng.initSchema();
+ return eng;
+ }, eng => eng.disconnect(), 'lrtpg');
+}
diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-default.json b/test/fixtures/goldens/catalog/pglite-engine-init-default.json
index 99a6d7000e..9e5a4f45df 100644
--- a/test/fixtures/goldens/catalog/pglite-engine-init-default.json
+++ b/test/fixtures/goldens/catalog/pglite-engine-init-default.json
@@ -82,6 +82,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -441,6 +462,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -827,6 +857,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -999,7 +1039,10 @@
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"facts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=facts.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1666,6 +1709,69 @@
],
"flags": "relkind=r rls=false force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1678,7 +1784,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json
index db8a7c1b35..b7c11a2ba4 100644
--- a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json
+++ b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json
@@ -82,6 +82,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -441,6 +462,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -827,6 +857,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -999,7 +1039,10 @@
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"facts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=facts.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1666,6 +1709,69 @@
],
"flags": "relkind=r rls=false force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1678,7 +1784,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json
index 796685335b..2ce1a60992 100644
--- a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json
+++ b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json
@@ -82,6 +82,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -441,6 +462,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -823,6 +853,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -995,7 +1035,10 @@
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"facts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=facts.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1662,6 +1705,69 @@
],
"flags": "relkind=r rls=false force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1674,7 +1780,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-default.json b/test/fixtures/goldens/catalog/pglite-schema-blob-default.json
index 3a33f51e94..c7d0a9f6ba 100644
--- a/test/fixtures/goldens/catalog/pglite-schema-blob-default.json
+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-default.json
@@ -52,6 +52,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -335,6 +356,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -614,6 +644,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -749,7 +789,10 @@
"eval_capture_failures_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=eval_capture_failures.id",
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1215,6 +1258,69 @@
],
"flags": "relkind=r rls=false force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1227,7 +1333,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json
index 358ba68154..0079a3a447 100644
--- a/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json
+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json
@@ -52,6 +52,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -335,6 +356,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -614,6 +644,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -749,7 +789,10 @@
"eval_capture_failures_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=eval_capture_failures.id",
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1215,6 +1258,69 @@
],
"flags": "relkind=r rls=false force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1227,7 +1333,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json b/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json
index c53886296f..78ba69b500 100644
--- a/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json
+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json
@@ -52,6 +52,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -335,6 +356,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -613,6 +643,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -748,7 +788,10 @@
"eval_capture_failures_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=eval_capture_failures.id",
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1214,6 +1257,69 @@
],
"flags": "relkind=r rls=false force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1226,7 +1332,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/postgres-db-initschema.json b/test/fixtures/goldens/catalog/postgres-db-initschema.json
index 49158bae10..60879b1603 100644
--- a/test/fixtures/goldens/catalog/postgres-db-initschema.json
+++ b/test/fixtures/goldens/catalog/postgres-db-initschema.json
@@ -65,6 +65,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -358,6 +379,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -646,6 +676,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -774,7 +814,10 @@
"eval_capture_failures_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=eval_capture_failures.id",
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1297,6 +1340,69 @@
],
"flags": "relkind=r rls=true force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1309,7 +1415,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=true force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-default.json b/test/fixtures/goldens/catalog/postgres-engine-init-default.json
index 65013754c1..0af80af589 100644
--- a/test/fixtures/goldens/catalog/postgres-engine-init-default.json
+++ b/test/fixtures/goldens/catalog/postgres-engine-init-default.json
@@ -85,6 +85,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -448,6 +469,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -830,6 +860,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -1001,7 +1041,10 @@
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"facts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=facts.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1678,6 +1721,69 @@
],
"flags": "relkind=r rls=true force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1690,7 +1796,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=true force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json
index ecdff86800..4d830cd093 100644
--- a/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json
+++ b/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json
@@ -85,6 +85,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -448,6 +469,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -830,6 +860,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -1001,7 +1041,10 @@
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"facts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=facts.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1678,6 +1721,69 @@
],
"flags": "relkind=r rls=true force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1690,7 +1796,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=true force_rls=false"
},
diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json b/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json
index a815cd1c99..cdce7bb690 100644
--- a/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json
+++ b/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json
@@ -85,6 +85,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -448,6 +469,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -826,6 +856,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -997,7 +1037,10 @@
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"facts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=facts.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1674,6 +1717,69 @@
],
"flags": "relkind=r rls=true force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1686,7 +1792,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=true force_rls=false"
},
diff --git a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
index 40df5ecbfd..1dc2627107 100644
--- a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
+++ b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
@@ -82,6 +82,27 @@
"files.files_storage_path_key": "u UNIQUE (storage_path)",
"gbrain_cycle_locks.gbrain_cycle_locks_pkey": "p PRIMARY KEY (id)",
"ingest_log.ingest_log_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_a_to_page_id_fkey": "f FOREIGN KEY (a_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_b_to_page_id_fkey": "f FOREIGN KEY (b_to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_ending_to_page_id_fkey": "f FOREIGN KEY (ending_to_page_id) REFERENCES pages(id) ON DELETE SET NULL",
+ "link_edge_proposals.link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "u UNIQUE (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals.link_edge_proposals_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_edge_proposals.link_edge_proposals_pkey": "p PRIMARY KEY (id)",
+ "link_edge_proposals.link_edge_proposals_status_check": "c CHECK ((status = ANY (ARRAY['proposed'::text, 'applied'::text, 'rejected'::text, 'undone'::text, 'stale'::text, 'reverted_by_user'::text, 'undated_unresolved'::text, 'ambiguous_same_date'::text, 'compatible'::text, 'error'::text])))",
+ "link_relationships.link_relationships_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_relationships.link_relationships_pkey": "p PRIMARY KEY (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships.link_relationships_scope_check": "c CHECK ((scope = ANY (ARRAY['all'::text, 'world'::text])))",
+ "link_relationships.link_relationships_semantics_check": "c CHECK ((semantics = ANY (ARRAY['state'::text, 'event'::text])))",
+ "link_relationships.link_relationships_status_now_check": "c CHECK ((status_now = ANY (ARRAY['live'::text, 'ended'::text, 'ended_unknown_date'::text, 'not_started'::text, 'disputed'::text, 'event'::text])))",
+ "link_relationships.link_relationships_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_date_precision_check": "c CHECK ((date_precision = ANY (ARRAY['day'::text, 'month'::text, 'year'::text])))",
+ "link_transitions.link_transitions_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_kind_check": "c CHECK ((kind = ANY (ARRAY['start'::text, 'end'::text])))",
+ "link_transitions.link_transitions_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "link_transitions.link_transitions_pkey": "p PRIMARY KEY (id)",
+ "link_transitions.link_transitions_producer_check": "c CHECK ((producer = ANY (ARRAY['timeline'::text, 'explicit'::text, 'frontmatter'::text, 'manual'::text, 'inline'::text, 'dream'::text])))",
+ "link_transitions.link_transitions_to_page_id_fkey": "f FOREIGN KEY (to_page_id) REFERENCES pages(id) ON DELETE CASCADE",
+ "links.links_assertion_tense_check": "c CHECK (((assertion_tense IS NULL) OR (assertion_tense = ANY (ARRAY['present'::text, 'past'::text]))))",
"links.links_from_page_id_fkey": "f FOREIGN KEY (from_page_id) REFERENCES pages(id) ON DELETE CASCADE",
"links.links_from_to_type_source_origin_unique": "u UNIQUE NULLS NOT DISTINCT (from_page_id, to_page_id, link_type, link_source, origin_page_id)",
"links.links_link_kind_check": "c CHECK (((link_kind IS NULL) OR (link_kind = ANY (ARRAY['plain'::text, 'typed_ner'::text]))))",
@@ -441,6 +462,15 @@
"ingest_log": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
+ "link_edge_proposals": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_relationships": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
+ "link_transitions": [
+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
+ ],
"links": [
"<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"
],
@@ -827,6 +857,16 @@
"idx_timeline_page": "CREATE INDEX idx_timeline_page ON public.timeline_entries USING btree (page_id)",
"idx_versions_page": "CREATE INDEX idx_versions_page ON public.page_versions USING btree (page_id)",
"ingest_log_pkey": "CREATE UNIQUE INDEX ingest_log_pkey ON public.ingest_log USING btree (id)",
+ "link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key": "CREATE UNIQUE INDEX link_edge_proposals_from_page_id_a_to_page_id_b_to_page_id__key ON public.link_edge_proposals USING btree (from_page_id, a_to_page_id, b_to_page_id, link_type, evidence_hash)",
+ "link_edge_proposals_pkey": "CREATE UNIQUE INDEX link_edge_proposals_pkey ON public.link_edge_proposals USING btree (id)",
+ "link_edge_proposals_status_idx": "CREATE INDEX link_edge_proposals_status_idx ON public.link_edge_proposals USING btree (source_id, status, created_at)",
+ "link_relationships_pkey": "CREATE UNIQUE INDEX link_relationships_pkey ON public.link_relationships USING btree (from_page_id, to_page_id, link_type, scope)",
+ "link_relationships_source_idx": "CREATE INDEX link_relationships_source_idx ON public.link_relationships USING btree (source_id, status_now)",
+ "link_relationships_to_idx": "CREATE INDEX link_relationships_to_idx ON public.link_relationships USING btree (to_page_id, link_type, scope)",
+ "link_transitions_identity_idx": "CREATE UNIQUE INDEX link_transitions_identity_idx ON public.link_transitions USING btree (origin_page_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer) NULLS NOT DISTINCT",
+ "link_transitions_origin_idx": "CREATE INDEX link_transitions_origin_idx ON public.link_transitions USING btree (origin_page_id)",
+ "link_transitions_pkey": "CREATE UNIQUE INDEX link_transitions_pkey ON public.link_transitions USING btree (id)",
+ "link_transitions_relationship_idx": "CREATE INDEX link_transitions_relationship_idx ON public.link_transitions USING btree (from_page_id, to_page_id, link_type)",
"links_from_to_type_source_origin_unique": "CREATE UNIQUE INDEX links_from_to_type_source_origin_unique ON public.links USING btree (from_page_id, to_page_id, link_type, link_source, origin_page_id) NULLS NOT DISTINCT",
"links_pkey": "CREATE UNIQUE INDEX links_pkey ON public.links USING btree (id)",
"loop_suppressions_pkey": "CREATE UNIQUE INDEX loop_suppressions_pkey ON public.loop_suppressions USING btree (id)",
@@ -999,7 +1039,10 @@
"eval_takes_quality_runs_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=eval_takes_quality_runs.id",
"facts_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=facts.id",
"files_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=files.id",
+ "graph_generation_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=-",
"ingest_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=ingest_log.id",
+ "link_edge_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_edge_proposals.id",
+ "link_transitions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=link_transitions.id",
"links_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=links.id",
"loop_suppressions_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=loop_suppressions.id",
"mcp_request_log_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=mcp_request_log.id",
@@ -1666,6 +1709,69 @@
],
"flags": "relkind=r rls=false force_rls=false"
},
+ "link_edge_proposals": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_edge_proposals_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 a_to_page_id integer/int4 NOT NULL",
+ "5 b_to_page_id integer/int4 NOT NULL",
+ "6 link_type text/text NOT NULL",
+ "7 evidence_hash text/text NOT NULL",
+ "8 status text/text NOT NULL",
+ "9 ending_to_page_id integer/int4 NULL",
+ "10 close_date date/date NULL",
+ "11 born_closed boolean/bool NOT NULL DEFAULT false",
+ "12 model text/text NULL",
+ "13 confidence real/float4 NULL",
+ "14 cost_usd real/float4 NULL",
+ "15 generated_line text/text NULL",
+ "16 detail text/text NULL",
+ "17 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "18 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_relationships": {
+ "columns": [
+ "1 from_page_id integer/int4 NOT NULL",
+ "2 to_page_id integer/int4 NOT NULL",
+ "3 link_type text/text NOT NULL",
+ "4 scope text/text NOT NULL",
+ "5 source_id text/text NOT NULL",
+ "6 semantics text/text NOT NULL",
+ "7 valid_ranges datemultirange/datemultirange NOT NULL",
+ "8 status_now text/text NOT NULL",
+ "9 first_start date/date NULL",
+ "10 last_start date/date NULL",
+ "11 last_end date/date NULL",
+ "12 undated_present integer/int4 NOT NULL DEFAULT 0",
+ "13 undated_past integer/int4 NOT NULL DEFAULT 0",
+ "14 disputed boolean/bool NOT NULL DEFAULT false",
+ "15 recorded_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "16 retired_at timestamp with time zone/timestamptz NULL",
+ "17 evidence_hash text/text NOT NULL",
+ "18 refreshed_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
+ "link_transitions": {
+ "columns": [
+ "1 id bigint/int8 NOT NULL DEFAULT nextval('link_transitions_id_seq'::regclass)",
+ "2 source_id text/text NOT NULL",
+ "3 from_page_id integer/int4 NOT NULL",
+ "4 to_page_id integer/int4 NOT NULL",
+ "5 link_type text/text NOT NULL",
+ "6 kind text/text NOT NULL",
+ "7 occurred_on date/date NOT NULL",
+ "8 date_precision text/text NOT NULL DEFAULT 'day'::text",
+ "9 producer text/text NOT NULL",
+ "10 origin_page_id integer/int4 NULL",
+ "11 line_hash text/text NOT NULL DEFAULT ''::text",
+ "12 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ ],
+ "flags": "relkind=r rls=true force_rls=false"
+ },
"links": {
"columns": [
"1 id integer/int4 NOT NULL DEFAULT nextval('links_id_seq'::regclass)",
@@ -1678,7 +1784,8 @@
"8 origin_page_id integer/int4 NULL",
"9 origin_field text/text NULL",
"10 resolution_type text/text NULL",
- "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"
+ "11 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",
+ "12 assertion_tense text/text NULL"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/helpers/link-temporal-scenario.ts b/test/helpers/link-temporal-scenario.ts
new file mode 100644
index 0000000000..3e156c9478
--- /dev/null
+++ b/test/helpers/link-temporal-scenario.ts
@@ -0,0 +1,124 @@
+/**
+ * Shared temporal-edge scenario: relationship state refresh and the liveness
+ * filter, run against PGLite (test/link-relationships.test.ts) and Postgres
+ * (test/e2e/link-relationships-postgres.test.ts).
+ */
+import { describe, test, expect, beforeAll, afterAll } from 'bun:test';
+import type { BrainEngine } from '../../src/core/engine.ts';
+import { refreshRelationships, relationshipKeysForPages, staleRelationshipKeys } from '../../src/core/engine-sql/link-relationships.ts';
+import { relationshipFilterSql, parseMultirange } from '../../src/core/link-validity.ts';
+
+export function defineLinkRelationshipTests(label: string, open: () => Promise<BrainEngine>, close: (e: BrainEngine) => Promise<void>, tag = 'lrt') {
+ let eng: BrainEngine;
+ const ids: Record<string, number> = {};
+ const alice = `people/${tag}-alice-example`;
+ const notes = `people/${tag}-private-notes`;
+ const acme = `companies/${tag}-acme-example`;
+ const widget = `companies/${tag}-widget-co`;
+ const fund = `companies/${tag}-fund-a`;
+ const newco = `companies/${tag}-new-co`;
+ const short = (slug: string) => slug.replace(`${tag}-`, '');
+
+ async function page(slug: string, type: string, frontmatter: Record<string, unknown> = {}) {
+ await eng.putPage(slug, { type: type as never, title: slug, compiled_truth: `${slug} page.`, timeline: '', frontmatter });
+ const [row] = await eng.executeRaw<{ id: number }>(`SELECT id FROM pages WHERE slug = $1 AND source_id = 'default'`, [slug]);
+ ids[slug] = Number(row.id);
+ }
+ async function transition(from: string, to: string, type: string, kind: 'start' | 'end', on: string, origin: string | null) {
+ await eng.executeRaw(
+ `INSERT INTO link_transitions (source_id, from_page_id, to_page_id, link_type, kind, occurred_on, producer, origin_page_id)
+ VALUES ('default', $1, $2, $3, $4, $5::date, 'timeline', $6)`,
+ [ids[from], ids[to], type, kind, on, origin ? ids[origin] : null]);
+ }
+ async function liveTargets(from: string, opts: Parameters<typeof relationshipFilterSql>[1] = {}) {
+ const rows = await eng.executeRaw<{ slug: string; link_type: string }>(
+ `SELECT t.slug, l.link_type FROM links l JOIN pages t ON t.id = l.to_page_id
+ WHERE l.from_page_id = $1 AND ${relationshipFilterSql('l', opts)} ORDER BY t.slug, l.link_type`, [ids[from]]);
+ return [...new Set(rows.map(r => `${short(r.slug)}:${r.link_type}`))];
+ }
+ const key = (to: string, link_type: string) => ({ from_page_id: ids[alice], to_page_id: ids[to], link_type });
+
+ describe(`link_relationships refresh (${label})`, () => {
+ beforeAll(async () => {
+ eng = await open();
+ await page(alice, 'person');
+ await page(notes, 'note', { visibility: 'private' });
+ for (const c of [acme, widget, fund]) await page(c, 'company');
+ });
+ afterAll(async () => {
+ await eng.executeRaw(`DELETE FROM pages WHERE slug LIKE $1`, [`%/${tag}-%`]);
+ await close(eng);
+ });
+
+ test('schema objects exist after initSchema', async () => {
+ const rows = await eng.executeRaw<{ t: string }>(
+ `SELECT table_name AS t FROM information_schema.tables WHERE table_name IN ('link_transitions','link_relationships','link_edge_proposals') ORDER BY 1`);
+ expect(rows.map(r => r.t)).toEqual(['link_edge_proposals', 'link_relationships', 'link_transitions']);
+ const col = await eng.executeRaw(`SELECT 1 FROM information_schema.columns WHERE table_name = 'links' AND column_name = 'assertion_tense'`);
+ expect(col.length).toBe(1);
+ });
+
+ test('a dated end on the person page closes an undated assertion from the company page', async () => {
+ await eng.addLink(alice, acme, 'CTO of Acme', 'works_at', 'frontmatter', acme, 'key_people');
+ await eng.addLink(alice, widget, 'joined Widget', 'works_at', 'markdown');
+ await eng.addLink(alice, fund, 'invested in Fund A', 'invested_in', 'markdown');
+ await transition(alice, acme, 'works_at', 'start', '2019-02-01', alice);
+ await transition(alice, acme, 'works_at', 'end', '2025-03-01', alice);
+ await transition(alice, widget, 'works_at', 'start', '2025-03-01', alice);
+ const keys = await relationshipKeysForPages(eng, [ids[alice]]);
+ expect(keys.length).toBe(3);
+ expect(await refreshRelationships(eng, keys)).toBeGreaterThan(0);
+
+ const [row] = await eng.executeRaw<{ valid_ranges: string; status_now: string; retired_at: unknown }>(
+ `SELECT valid_ranges::text AS valid_ranges, status_now, retired_at FROM link_relationships
+ WHERE from_page_id = $1 AND to_page_id = $2 AND scope = 'all'`, [ids[alice], ids[acme]]);
+ expect(parseMultirange(row.valid_ranges)).toEqual([{ from: '2019-02-01', until: '2025-03-01' }]);
+ expect(row.status_now).toBe('ended');
+ expect(row.retired_at).not.toBeNull();
+
+ expect(await liveTargets(alice)).toEqual(['companies/fund-a:invested_in', 'companies/widget-co:works_at']);
+ expect(await liveTargets(alice, { asOf: '2022-06-01' })).toEqual(['companies/acme-example:works_at', 'companies/fund-a:invested_in']);
+ expect(await liveTargets(alice, { status: 'ended' })).toEqual(['companies/acme-example:works_at']);
+ expect(await liveTargets(alice, { during: { from: '2025-01-01', until: '2026-01-01' } }))
+ .toEqual(['companies/acme-example:works_at', 'companies/fund-a:invested_in', 'companies/widget-co:works_at']);
+ expect(await liveTargets(alice, { status: 'all' })).toHaveLength(3);
+ });
+
+ test('events are invisible before their dated occurrence', async () => {
+ await transition(alice, fund, 'invested_in', 'start', '2023-01-01', alice);
+ await refreshRelationships(eng, [key(fund, 'invested_in')]);
+ expect(await liveTargets(alice, { asOf: '2022-06-01' })).toEqual(['companies/acme-example:works_at']);
+ });
+
+ test('private-origin evidence does not change the world-scope state', async () => {
+ await eng.addLink(alice, widget, 'left Widget', 'works_at', 'manual-test', notes);
+ await transition(alice, widget, 'works_at', 'end', '2026-01-15', notes);
+ await refreshRelationships(eng, [key(widget, 'works_at')]);
+ expect(await liveTargets(alice, { asOf: '2026-06-01' })).not.toContain('companies/widget-co:works_at');
+ expect(await liveTargets(alice, { asOf: '2026-06-01', excludePrivate: true })).toContain('companies/widget-co:works_at');
+ });
+
+ test('a relationship without a state row reads as live; the stale sweep finds it', async () => {
+ await page(newco, 'company');
+ await eng.addLink(alice, newco, 'advisor to New Co', 'advises', 'markdown');
+ expect(await liveTargets(alice)).toContain('companies/new-co:advises');
+ const stale = await staleRelationshipKeys(eng, 5000);
+ expect(stale.some(k => k.to_page_id === ids[newco])).toBe(true);
+ });
+
+ test('removing all evidence removes the state row', async () => {
+ await refreshRelationships(eng, [key(newco, 'advises')]);
+ await eng.removeLink(alice, newco, 'advises');
+ await refreshRelationships(eng, [key(newco, 'advises')]);
+ const rows = await eng.executeRaw('SELECT 1 FROM link_relationships WHERE to_page_id = $1', [ids[newco]]);
+ expect(rows.length).toBe(0);
+ });
+
+ test('graph generation advances only on change', async () => {
+ const before = await eng.executeRaw<{ v: string }>('SELECT last_value::text AS v FROM graph_generation_seq');
+ expect(await refreshRelationships(eng, [key(acme, 'works_at')])).toBe(0);
+ const after = await eng.executeRaw<{ v: string }>('SELECT last_value::text AS v FROM graph_generation_seq');
+ expect(after[0].v).toBe(before[0].v);
+ });
+ });
+}
diff --git a/test/link-relationships.test.ts b/test/link-relationships.test.ts
new file mode 100644
index 0000000000..d6d2b037e9
--- /dev/null
+++ b/test/link-relationships.test.ts
@@ -0,0 +1,14 @@
+/**
+ * Temporal typed edges — relationship state refresh and the liveness filter on
+ * a real PGLite brain (schema + migration + engine-sql domain). The Postgres
+ * twin is test/e2e/link-relationships-postgres.test.ts.
+ */
+import { PGLiteEngine } from '../src/core/pglite-engine.ts';
+import { defineLinkRelationshipTests } from './helpers/link-temporal-scenario.ts';
+
+defineLinkRelationshipTests('pglite', async () => {
+ const eng = new PGLiteEngine();
+ await eng.connect({});
+ await eng.initSchema();
+ return eng;
+}, eng => eng.disconnect());
diff --git a/test/link-validity.test.ts b/test/link-validity.test.ts
new file mode 100644
index 0000000000..e196c57a63
--- /dev/null
+++ b/test/link-validity.test.ts
@@ -0,0 +1,190 @@
+/**
+ * Temporal typed edges — pure relationship-state rules (src/core/link-validity.ts).
+ * Pins stint construction, order invariance, statuses, the multirange text
+ * form, contradiction date arithmetic and op-param parsing.
+ */
+import { describe, test, expect } from 'bun:test';
+import {
+ buildRelationshipState, statusAt, stintsToMultirange, parseMultirange, closeContradiction,
+ normalizePartialDate, isCalendarDate, parseDuring, parseTemporalParams, relationSemantics,
+ relationshipFilterSql, type AssertionEvidence, type TransitionEvidence,
+} from '../src/core/link-validity.ts';
+
+const start = (d: string, origin: number | null = 1): TransitionEvidence => ({ kind: 'start', occurredOn: d, producer: 'timeline', originPageId: origin });
+const end = (d: string, origin: number | null = 1): TransitionEvidence => ({ kind: 'end', occurredOn: d, producer: 'timeline', originPageId: origin });
+const present = (origin = 1): AssertionEvidence => ({ tense: 'present', originPageId: origin });
+const past = (origin = 1): AssertionEvidence => ({ tense: 'past', originPageId: origin });
+
+describe('relation semantics', () => {
+ test('state, event and reference types', () => {
+ expect(relationSemantics('works_at')).toBe('state');
+ expect(relationSemantics('advises')).toBe('state');
+ expect(relationSemantics('invested_in')).toBe('event');
+ expect(relationSemantics('founded')).toBe('event');
+ expect(relationSemantics('mentions')).toBe('reference');
+ expect(relationSemantics('owes_to')).toBe('reference');
+ expect(relationSemantics('')).toBe('reference');
+ expect(relationSemantics(undefined)).toBe('reference');
+ });
+});
+
+describe('buildRelationshipState — state relations', () => {
+ test('undated present assertion is live forever', () => {
+ const s = buildRelationshipState('state', [present()], []);
+ expect(s.stints).toEqual([{ from: null, until: null }]);
+ expect(statusAt(s, '2026-01-01')).toBe('live');
+ });
+
+ test('only past-tense assertions: ended at an unknown date', () => {
+ const s = buildRelationshipState('state', [past()], []);
+ expect(s.stints).toEqual([]);
+ expect(statusAt(s, '2026-01-01')).toBe('ended_unknown_date');
+ });
+
+ test('same page present beats past (one assertion row carries present)', () => {
+ const s = buildRelationshipState('state', [present(1)], []);
+ expect(statusAt(s)).toBe('live');
+ });
+
+ test('present and past from different origins with no dates: live but disputed', () => {
+ const s = buildRelationshipState('state', [present(1), past(2)], []);
+ expect(s.disputed).toBe(true);
+ expect(statusAt(s, '2026-01-01')).toBe('disputed');
+ });
+
+ test('dated start and end make one closed stint; undated present does not reopen it', () => {
+ const s = buildRelationshipState('state', [present()], [start('2021-04-01'), end('2025-03-01')]);
+ expect(s.stints).toEqual([{ from: '2021-04-01', until: '2025-03-01' }]);
+ expect(s.staleAssertions).toBe(1);
+ expect(statusAt(s, '2024-01-01')).toBe('live');
+ expect(statusAt(s, '2025-03-01')).toBe('ended');
+ expect(statusAt(s, '2020-01-01')).toBe('not_started');
+ });
+
+ test('rejoin (A→B→A) keeps two stints', () => {
+ const s = buildRelationshipState('state', [present()], [start('2015-01-01'), end('2018-06-01'), start('2021-02-01')]);
+ expect(s.stints).toEqual([{ from: '2015-01-01', until: '2018-06-01' }, { from: '2021-02-01', until: null }]);
+ expect(statusAt(s, '2019-01-01')).toBe('ended');
+ expect(statusAt(s, '2026-01-01')).toBe('live');
+ });
+
+ test('a second start while open (promotion) is absorbed', () => {
+ const s = buildRelationshipState('state', [], [start('2020-01-01'), start('2022-01-01'), end('2024-01-01')]);
+ expect(s.stints).toEqual([{ from: '2020-01-01', until: '2024-01-01' }]);
+ });
+
+ test('an end with no start closes an implicit stint; repeated unmatched ends collapse', () => {
+ const s = buildRelationshipState('state', [present()], [end('2019-05-01'), end('2020-01-01')]);
+ expect(s.stints).toEqual([{ from: null, until: '2019-05-01' }]);
+ expect(statusAt(s, '2026-01-01')).toBe('ended');
+ });
+
+ test('same-day end then start continues as a new stint (merged when touching)', () => {
+ const s = buildRelationshipState('state', [], [start('2020-01-01'), end('2022-01-01'), start('2022-01-01')]);
+ expect(s.stints).toEqual([{ from: '2020-01-01', until: null }]);
+ });
+
+ test('dated start with only past-tense assertions: ended at an unknown date after the start', () => {
+ const s = buildRelationshipState('state', [past()], [start('2021-01-01')]);
+ expect(s.stints).toEqual([]);
+ expect(s.firstStart).toBe('2021-01-01');
+ expect(statusAt(s, '2026-01-01')).toBe('ended_unknown_date');
+ });
+
+ test('future end stays live until then', () => {
+ const s = buildRelationshipState('state', [present()], [end('2099-01-01')]);
+ expect(statusAt(s, '2026-01-01')).toBe('live');
+ });
+
+ test('duplicate evidence across producers and origins collapses to one event per (kind, date)', () => {
+ const a = buildRelationshipState('state', [], [start('2020-01-01', 1), start('2020-01-01', 2), end('2021-01-01', null)]);
+ expect(a.stints).toEqual([{ from: '2020-01-01', until: '2021-01-01' }]);
+ });
+
+ test('order invariance: every permutation of the same evidence gives the same state', () => {
+ const ev = [start('2015-01-01'), end('2018-06-01', 2), start('2021-02-01', null), end('2018-06-01', 3), start('2015-01-01', 4)];
+ const asserts = [present(1), past(2)];
+ const baseline = JSON.stringify(buildRelationshipState('state', asserts, ev));
+ const perms = (xs: TransitionEvidence[]): TransitionEvidence[][] => xs.length <= 1 ? [xs]
+ : xs.flatMap((x, i) => perms([...xs.slice(0, i), ...xs.slice(i + 1)]).map(p => [x, ...p]));
+ for (const p of perms(ev)) {
+ expect(JSON.stringify(buildRelationshipState('state', [...asserts].reverse(), p))).toBe(baseline);
+ }
+ });
+});
+
+describe('buildRelationshipState — event relations', () => {
+ test('events never end and are invisible before their date', () => {
+ const s = buildRelationshipState('event', [present()], [start('2019-03-01'), end('2024-01-01')]);
+ expect(s.stints).toEqual([{ from: '2019-03-01', until: null }]);
+ expect(statusAt(s, '2018-01-01')).toBe('not_started');
+ expect(statusAt(s, '2030-01-01')).toBe('event');
+ });
+ test('undated events are always visible', () => {
+ const s = buildRelationshipState('event', [past()], []);
+ expect(statusAt(s, '1990-01-01')).toBe('event');
+ });
+});
+
+describe('multirange text form', () => {
+ test('round trip', () => {
+ const stints = [{ from: null, until: '2018-06-01' }, { from: '2021-02-01', until: null }];
+ const text = stintsToMultirange(stints);
+ expect(text).toBe('{(,2018-06-01),[2021-02-01,)}');
+ expect(parseMultirange(text)).toEqual(stints);
+ expect(stintsToMultirange([])).toBe('{}');
+ expect(parseMultirange('{}')).toEqual([]);
+ expect(parseMultirange('{[2021-02-01,2022-01-01)}')).toEqual([{ from: '2021-02-01', until: '2022-01-01' }]);
+ });
+});
+
+describe('closeContradiction', () => {
+ const side = (lastStart: string | null, recordedAt = '2026-01-01T00:00:00Z', until: string | null = null) =>
+ ({ lastStart, recordedAt, stints: [{ from: lastStart, until }] });
+ test('the relationship that started earlier ends when the other started', () => {
+ expect(closeContradiction(side('2020-01-01'), side('2023-05-01'))).toEqual({ action: 'close', side: 'a', closeDate: '2023-05-01', bornClosed: false });
+ expect(closeContradiction(side('2023-05-01'), side('2020-01-01'))).toEqual({ action: 'close', side: 'b', closeDate: '2023-05-01', bornClosed: false });
+ });
+ test('out-of-order arrival: the older one recorded later is born closed', () => {
+ const r = closeContradiction(side('2020-01-01', '2026-02-01T00:00:00Z'), side('2023-05-01', '2026-01-01T00:00:00Z'));
+ expect(r).toEqual({ action: 'close', side: 'a', closeDate: '2023-05-01', bornClosed: true });
+ });
+ test('undated side never closes (no page or ingestion dates)', () => {
+ expect(closeContradiction(side(null), side('2023-05-01'))).toEqual({ action: 'none', reason: 'undated_unresolved' });
+ });
+ test('same date is ambiguous; already disjoint is a no-op', () => {
+ expect(closeContradiction(side('2023-05-01'), side('2023-05-01'))).toEqual({ action: 'none', reason: 'ambiguous_same_date' });
+ expect(closeContradiction(side('2020-01-01', undefined, '2022-01-01'), side('2023-05-01'))).toEqual({ action: 'none', reason: 'already_disjoint' });
+ });
+});
+
+describe('dates and params', () => {
+ test('partial dates normalize; impossible dates are rejected', () => {
+ expect(normalizePartialDate('2021')).toEqual({ date: '2021-01-01', precision: 'year' });
+ expect(normalizePartialDate('2021-04')).toEqual({ date: '2021-04-01', precision: 'month' });
+ expect(normalizePartialDate('2021-04-09')).toEqual({ date: '2021-04-09', precision: 'day' });
+ expect(normalizePartialDate('2021-02-30')).toBeNull();
+ expect(normalizePartialDate('April 2021')).toBeNull();
+ expect(isCalendarDate('2024-02-29')).toBe(true);
+ expect(isCalendarDate('2023-02-29')).toBe(false);
+ });
+ test('during ranges', () => {
+ expect(parseDuring('2022')).toEqual({ from: '2022-01-01', until: '2023-01-01' });
+ expect(parseDuring('2022-03')).toEqual({ from: '2022-03-01', until: '2022-04-01' });
+ expect(parseDuring('2021..2023-06')).toEqual({ from: '2021-01-01', until: '2023-07-01' });
+ expect(parseDuring('2023..2021')).toBeNull();
+ });
+ test('op params validate', () => {
+ expect(parseTemporalParams({ status: 'all', as_of: '2022-01-01' })).toEqual({ ok: true, opts: { status: 'all', asOf: '2022-01-01' } });
+ expect(parseTemporalParams({ status: 'former' }).ok).toBe(false);
+ expect(parseTemporalParams({ as_of: '2022-13-01' }).ok).toBe(false);
+ expect(parseTemporalParams({ during: 'last year' }).ok).toBe(false);
+ });
+ test('filter SQL inlines only validated dates and is TRUE when off', () => {
+ expect(relationshipFilterSql('l', { status: 'all' })).toBe('TRUE');
+ expect(relationshipFilterSql('l', { disabled: true })).toBe('TRUE');
+ expect(relationshipFilterSql('l', { asOf: '2022-01-01' })).toContain("DATE '2022-01-01'");
+ expect(relationshipFilterSql('l', { excludePrivate: true })).toContain("lr.scope = 'world'");
+ expect(() => relationshipFilterSql('l', { asOf: "2022-01-01'; DROP TABLE links; --" })).toThrow();
+ });
+});