Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(trust): tier vocabulary, trust_tier schema and stamping trigger (#5575 lane F)
garrytan4ed27a2ef2b6
diff --git a/src/commands/doctor/checks/managed-guard.ts b/src/commands/doctor/checks/managed-guard.tsindex 4e3576abb4..816213cffc 100644--- a/src/commands/doctor/checks/managed-guard.ts+++ b/src/commands/doctor/checks/managed-guard.ts@@ -16,21 +16,21 @@ export const GUARDED_TABLE_COLUMNS: Readonly<Record<string, readonly string[]>>'generation', 'id', 'import_filename', 'ingested_at', 'ingested_via', 'knowledge_revision', 'last_retrieved_at', 'links_attendance_blocked_at','links_attendance_blocked_revision', 'links_extracted_at', 'page_kind', 'revision_principal_id', 'revision_principal_kind', 'revision_write_request_id','salience_touched_at', 'search_vector', 'slug', 'source_id', 'source_kind', 'source_path', 'source_uri', 'text_projection_revision', 'timeline',- 'title', 'type', 'updated_at'],+ 'title', 'trust_tier', 'type', 'updated_at', 'write_origin'],tags: ['id', 'page_id', 'tag', 'tag_source'],slug_aliases: ['alias_slug', 'canonical_slug', 'created_at', 'id', 'notes', 'source_id'],page_aliases: ['alias_norm', 'alias_text', 'case_sensitive', 'created_at', 'id', 'origin', 'slug', 'source_id'],facts: ['attributed_to', 'claim_metric', 'claim_period', 'claim_unit', 'claim_value', 'confidence', 'consolidated_at', 'consolidated_into', 'context', 'created_at','dim_status', 'dimension', 'embedded_at', 'embedded_text_hash', 'embedding', 'embedding_model', 'entity_slug', 'event_type', 'expired_at', 'fact','id', 'kind', 'last_write_principal_id', 'last_write_principal_kind', 'last_write_request_id', 'last_written_at', 'notability', 'row_num', 'source',- 'source_id', 'source_markdown_slug', 'source_session', 'superseded_by', 'valid_from', 'valid_until', 'value', 'value_hash', 'visibility',- 'write_principal_id', 'write_principal_kind', 'write_request_id'],+ 'source_id', 'source_markdown_slug', 'source_session', 'superseded_by', 'trust_tier', 'valid_from', 'valid_until', 'value', 'value_hash', 'visibility',+ 'write_origin', 'write_principal_id', 'write_principal_kind', 'write_request_id'],takes: ['active', 'claim', 'created_at', 'embedded_at', 'embedded_text_hash', 'embedding', 'embedding_model', 'holder', 'id', 'kind','last_write_principal_id', 'last_write_principal_kind', 'last_write_request_id', 'last_written_at', 'page_id', 'resolved_at', 'resolved_by','resolved_outcome', 'resolved_quality', 'resolved_source', 'resolved_unit', 'resolved_value', 'row_num', 'since_date', 'source', 'superseded_by',- 'until_date', 'updated_at', 'weight', 'write_principal_id', 'write_principal_kind', 'write_request_id'],+ 'trust_tier', 'until_date', 'updated_at', 'weight', 'write_origin', 'write_principal_id', 'write_principal_kind', 'write_request_id'],timeline_entries: ['created_at', 'date', 'detail', 'event_page_id', 'id', 'last_write_principal_id', 'last_write_principal_kind', 'last_write_request_id',- 'last_written_at', 'page_id', 'source', 'summary', 'write_principal_id', 'write_principal_kind', 'write_request_id'],+ 'last_written_at', 'page_id', 'source', 'summary', 'trust_tier', 'write_origin', 'write_principal_id', 'write_principal_kind', 'write_request_id'],sources: ['archive_expires_at', 'archived', 'archived_at', 'chunker_version', 'config', 'contextual_retrieval_mode', 'created_at', 'id', 'incarnation','last_commit', 'last_sync_at', 'local_path', 'name', 'newest_content_at', 'trust_frontmatter_overrides', 'upstream_behind', 'upstream_checked_at','upstream_commit'],diff --git a/src/core/persistence/attribution-schema.ts b/src/core/persistence/attribution-schema.tsindex 9b9e7617e9..3b8b4aee97 100644--- a/src/core/persistence/attribution-schema.ts+++ b/src/core/persistence/attribution-schema.ts@@ -20,6 +20,7 @@* guard); the classification test in test/write-attribution.test.ts fails* until it is.*/+import { TRUST_ROW_COLUMNS } from '../trust/schema.ts';/** created_by and last_mutated_by on facts, takes and timeline_entries. */export const ROW_ATTRIBUTION_COLUMNS = [@@ -46,11 +47,16 @@ export const WRITE_ATTRIBUTION_CONTENT_COLUMNS: Record<AttributedTable, readonly'resolved_by', 'created_at', 'resolved_quality'],timeline_entries: ['id', 'page_id', 'date', 'source', 'summary', 'detail', 'event_page_id', 'created_at'],};-/** Physical projections (embeddings and their identity): changing them leaves attribution untouched. */+/**+ * Columns whose change leaves attribution untouched: physical projections+ * (embeddings and their identity) and the trust tier and its origin record,+ * which trust/schema.ts stamps and guards (a confirmation or backfill is not a+ * content rewrite, so it does not move last_write_*).+ */export const WRITE_ATTRIBUTION_PROJECTION_COLUMNS: Record<AttributedTable, readonly string[]> = {- facts: ['embedding', 'embedded_at', 'embedding_model', 'embedded_text_hash'],- takes: ['embedding', 'embedded_at', 'updated_at', 'embedding_model', 'embedded_text_hash'],- timeline_entries: [],+ facts: ['embedding', 'embedded_at', 'embedding_model', 'embedded_text_hash', ...TRUST_ROW_COLUMNS],+ takes: ['embedding', 'embedded_at', 'updated_at', 'embedding_model', 'embedded_text_hash', ...TRUST_ROW_COLUMNS],+ timeline_entries: [...TRUST_ROW_COLUMNS],};const ATTRIBUTED_TABLES = Object.keys(WRITE_ATTRIBUTION_CONTENT_COLUMNS) as AttributedTable[];diff --git a/src/core/persistence/attribution.ts b/src/core/persistence/attribution.tsindex 6b3ca90362..7f8e9091b9 100644--- a/src/core/persistence/attribution.ts+++ b/src/core/persistence/attribution.ts@@ -2,13 +2,19 @@ import { currentVerifiedLocalWriter, existingLocalHostId, readLocalWriter } fromimport type { Principal, SqlEngine, WriteRequest } from './model.ts';import type { BrainEngine } from '../engine.ts';import { withWriteAttribution } from './context.ts';+import type { WriteTrust } from '../trust/tier.ts';/*** The actor the database stamps on rows written inside withCoordinatedWrite* or withWriteAttribution. `requestId` is persistence_requests.id (globally* unique), or null for a maintenance write with no journal request.*/-export interface WriteAttribution { requestId: string | null; principal: Principal; }+export interface WriteAttribution {+ requestId: string | null;+ principal: Principal;+ /** The tier and origin of the rows written (trust/tier.ts). Undeclared: rows are stamped `unknown` unless an enclosing scope declared one. */+ trust?: WriteTrust;+}export { withWriteAttribution };@@ -55,7 +61,7 @@ const installationRegistration = new WeakMap<SqlEngine, Promise<string>>();* stale-atom retirement) whose rows carry the maintenance principal. A managed* brain's guard still refuses these writes: this sets no coordinator capability.*/-export async function maintenanceTransaction<T>(engine: BrainEngine, fn: (tx: BrainEngine) => Promise<T>): Promise<T> {+export async function maintenanceTransaction<T>(engine: BrainEngine, fn: (tx: BrainEngine) => Promise<T>, trust?: WriteTrust): Promise<T> {const attribution = await maintenanceAttribution(engine);- return engine.transaction(tx => withWriteAttribution(tx, attribution, () => fn(tx)));+ return engine.transaction(tx => withWriteAttribution(tx, trust ? { ...attribution, trust } : attribution, () => fn(tx)));}diff --git a/src/core/persistence/context.ts b/src/core/persistence/context.tsindex 0fabd1a996..843ed73fa6 100644--- a/src/core/persistence/context.ts+++ b/src/core/persistence/context.ts@@ -2,10 +2,15 @@ import { AsyncLocalStorage } from 'node:async_hooks';import type { BrainEngine } from '../engine.ts';import { opError, OperationError } from '../ops/contract.ts';import type { WriteAttribution } from './attribution.ts';+import { isTrustTier, nestWriteTrust, trustRankSql, type TrustTier, type WriteTrust } from '../trust/tier.ts';interface PublicationContext { brainId: string; sourceIds: ReadonlySet<string>; active: boolean; }const publication = new AsyncLocalStorage<PublicationContext>();const ATTRIBUTION_SETTINGS = ['gbrain.write_request', 'gbrain.write_principal_kind', 'gbrain.write_principal_id'] as const;+/** The writer's trust declaration (trust/schema.ts reads them in the tier trigger). */+const TRUST_SETTINGS = ['gbrain.write_trust_tier', 'gbrain.write_origin'] as const;+const TRUST_PROMOTION_SETTING = 'gbrain.write_trust_promotion';+const TRUST_BACKFILL_SETTING = 'gbrain.write_trust_backfill';/*** Sets transaction-local settings around `fn` in one round trip each way. An@@ -32,6 +37,15 @@ function applySettings(engine: Pick<BrainEngine, 'executeRaw'>, names: readonly/** A nested scope keeps the outer actor: a request publication that calls a derived writer stays attributed to the request. */const attributionValues = (outer: string[], attribution: WriteAttribution) => outer[1]? outer : [attribution.requestId ?? '', attribution.principal.kind, attribution.principal.id];+/** The enclosing trust declaration read back from its two settings; null when none is set. */+function storedWriteTrust(tier: string, origin: string): WriteTrust | null {+ if (!isTrustTier(tier)) return null;+ try { return { tier, origin: origin ? JSON.parse(origin) as WriteTrust['origin'] : null }; } catch { return { tier, origin: null }; }+}+const trustValues = (trust: WriteTrust | null): string[] => trust ? [trust.tier, trust.origin ? JSON.stringify(trust.origin) : ''] : ['', ''];+/** Unlike the actor, a nested trust declaration combines as min(outer, inner): a nested derived write can lower, never raise. */+const nestedTrustValues = (outer: string[], trust: WriteTrust | undefined) =>+ trust ? trustValues(nestWriteTrust(storedWriteTrust(outer[0] ?? '', outer[1] ?? ''), trust)) : outer;/*** Only the coordinator and guarded projection workers establish this execution@@ -41,15 +55,20 @@ const attributionValues = (outer: string[], attribution: WriteAttribution) => ouexport async function withCoordinatedWrite<T>(engine: BrainEngine, sourceIds: string[], fn: () => Promise<T>, attribution: WriteAttribution): Promise<T> {// #6007: the persistence identity, the enclosing settings and the new settings in one round trip;// nothing is set when the identity row is missing. The OFFSET 0 subquery reads the enclosing values first.- const names = ['gbrain.write_sources', ...ATTRIBUTION_SETTINGS];+ // A declared trust tier nests as min(outer, inner) (ranks compared in SQL); an undeclared one leaves the enclosing settings.+ const names = ['gbrain.write_sources', ...ATTRIBUTION_SETTINGS, ...TRUST_SETTINGS];+ const [tier, origin] = trustValues(attribution.trust ?? null);const [brain] = await engine.executeRaw<Record<string, string | null>>(`SELECT b.brain_id,prev.*,CASE WHEN b.brain_id IS NOT NULL THEN concat(set_config('gbrain.write_sources',$1,true),set_config('gbrain.write_request',CASE WHEN prev.s2<>'' THEN prev.s1 ELSE $2 END,true),set_config('gbrain.write_principal_kind',CASE WHEN prev.s2<>'' THEN prev.s2 ELSE $3 END,true),- set_config('gbrain.write_principal_id',CASE WHEN prev.s2<>'' THEN prev.s3 ELSE $4 END,true)) END AS applied+ set_config('gbrain.write_principal_id',CASE WHEN prev.s2<>'' THEN prev.s3 ELSE $4 END,true),+ CASE WHEN $5::text<>'' THEN concat(+ set_config('gbrain.write_trust_tier',CASE WHEN ${trustRankSql('prev.s4')}>0 AND ${trustRankSql('prev.s4')}<${trustRankSql('$5::text')} THEN prev.s4 ELSE $5::text END,true),+ set_config('gbrain.write_origin',CASE WHEN $6::text<>'' THEN $6::text ELSE prev.s5 END,true)) END) END AS appliedFROM (SELECT ${names.map((name, index) => `COALESCE(current_setting('${name}',true),'') AS s${index}`).join(',')} OFFSET 0) prevLEFT JOIN persistence_brain b ON b.singleton=1`,- [JSON.stringify(sourceIds), attribution.requestId ?? '', attribution.principal.kind, attribution.principal.id]);+ [JSON.stringify(sourceIds), attribution.requestId ?? '', attribution.principal.kind, attribution.principal.id, tier, origin]);if (!brain?.brain_id) {throw opError('writer_not_initialized', 'Persistence identity is missing.','This brain has no persistence identity row, so coordinated writes cannot run and nothing was written. List the pending migrations that create it and ask the user to approve applying them.',@@ -75,12 +94,41 @@ export async function withCoordinatedWrite<T>(engine: BrainEngine, sourceIds: st* enclosing coordinated write restores the outer values when it ends.*/export async function setMemberAttribution(engine: Pick<BrainEngine, 'executeRaw'>, attribution: WriteAttribution): Promise<void> {- await engine.executeRaw(`SELECT ${ATTRIBUTION_SETTINGS.map((name, index) => `set_config('${name}',$${index + 1},true)`).join(',')}`,- [attribution.requestId ?? '', attribution.principal.kind, attribution.principal.id]);+ // The member's trust declaration replaces the previous member's (an undeclared member resets to none: `unknown`).+ await engine.executeRaw(`SELECT ${[...ATTRIBUTION_SETTINGS, ...TRUST_SETTINGS].map((name, index) => `set_config('${name}',$${index + 1},true)`).join(',')}`,+ [attribution.requestId ?? '', attribution.principal.kind, attribution.principal.id, ...trustValues(attribution.trust ?? null)]);}/** Attribution without coordinator capability, for unmanaged legacy transactions. */export function withWriteAttribution<T>(engine: Pick<BrainEngine, 'executeRaw'>, attribution: WriteAttribution, fn: () => Promise<T>): Promise<T> {- return withTransactionSettings(engine, ATTRIBUTION_SETTINGS, outer => attributionValues(outer, attribution), fn);+ return withTransactionSettings(engine, [...ATTRIBUTION_SETTINGS, ...TRUST_SETTINGS],+ outer => [...attributionValues(outer.slice(0, 3), attribution), ...nestedTrustValues(outer.slice(3), attribution.trust)], fn);+}+/**+ * Declares the tier and origin of the rows written inside `fn`, within an+ * enclosing transaction (a coordinated write, an attributed maintenance+ * transaction, or a plain one). Nested declarations combine as min(outer,+ * inner). Compute the declaration once with trust/tier.ts `effectiveWriteTrust`.+ */+export function withWriteTrust<T>(engine: Pick<BrainEngine, 'executeRaw'>, trust: WriteTrust, fn: () => Promise<T>): Promise<T> {+ return withTransactionSettings(engine, TRUST_SETTINGS, outer => nestedTrustValues(outer, trust), fn);+}+/** The trust declaration in force on this transaction, or null (rows would be stamped `unknown`). */+export async function currentWriteTrust(engine: Pick<BrainEngine, 'executeRaw'>): Promise<WriteTrust | null> {+ const [row] = await engine.executeRaw<{ tier: string | null; origin: string | null }>(+ `SELECT current_setting('gbrain.write_trust_tier',true) AS tier, current_setting('gbrain.write_origin',true) AS origin`);+ return storedWriteTrust(row?.tier ?? '', row?.origin ?? '');+}+/**+ * The owner-confirmation capability (CEO-9): inside `fn`, an UPDATE may raise+ * a row's trust_tier up to `ceiling`. Callers establish the confirmation first+ * (trust/confirm.ts); the trigger is a backstop against bugs, not a boundary.+ */+export function withTrustPromotion<T>(engine: Pick<BrainEngine, 'executeRaw'>, ceiling: TrustTier, fn: () => Promise<T>): Promise<T> {+ return withTransactionSettings(engine, [TRUST_PROMOTION_SETTING], () => [ceiling], fn);+}+/** CEO-10: the deterministic backfill may move rows from `unknown` to any tier below user_confirmed. */+export function withTrustBackfill<T>(engine: Pick<BrainEngine, 'executeRaw'>, fn: () => Promise<T>): Promise<T> {+ return withTransactionSettings(engine, [TRUST_BACKFILL_SETTING], () => ['on'], fn);}export async function assertCoordinatedWrite(engine: Pick<BrainEngine, 'executeRaw'>, sourceId: string): Promise<void> {const [brain] = await engine.executeRaw<{ brain_id: string; enabled: boolean }>('SELECT brain_id,enabled FROM persistence_brain WHERE singleton=1');diff --git a/src/core/persistence/writer-guard-schema.ts b/src/core/persistence/writer-guard-schema.tsindex a08d4376c8..756208dd9a 100644--- a/src/core/persistence/writer-guard-schema.ts+++ b/src/core/persistence/writer-guard-schema.ts@@ -17,7 +17,9 @@ BEGINIF TG_TABLE_NAME='pages' AND TG_OP='UPDATE' THENIF (NEW.source_id,NEW.slug,NEW.type,NEW.page_kind,NEW.title,NEW.compiled_truth,NEW.timeline,NEW.frontmatter,NEW.deleted_at,NEW.knowledge_revision)IS NOT DISTINCT FROM- (OLD.source_id,OLD.slug,OLD.type,OLD.page_kind,OLD.title,OLD.compiled_truth,OLD.timeline,OLD.frontmatter,OLD.deleted_at,OLD.knowledge_revision) THEN RETURN NEW; END IF;+ (OLD.source_id,OLD.slug,OLD.type,OLD.page_kind,OLD.title,OLD.compiled_truth,OLD.timeline,OLD.frontmatter,OLD.deleted_at,OLD.knowledge_revision)+ -- The trust tier is guarded content (trust/schema.ts); read by key so brains before the column keep working.+ AND row_data->'trust_tier' IS NOT DISTINCT FROM old_data->'trust_tier' THEN RETURN NEW; END IF;ELSIF TG_TABLE_NAME='sources' THENIF TG_OP='UPDATE' AND (NEW.id,NEW.incarnation,NEW.local_path,NEW.archived)IS NOT DISTINCT FROM (OLD.id,OLD.incarnation,OLD.local_path,OLD.archived) THEN@@ -38,10 +40,11 @@ BEGINEND IF;IF TG_OP='DELETE' THEN RETURN OLD; ELSE RETURN NEW; END IF;ELSIF TG_TABLE_NAME IN ('facts','takes') AND TG_OP='UPDATE' THEN- row_data := row_data - ARRAY['embedding_model','embedded_text_hash'] - ${ROW_ATTRIBUTION_KEYS};- old_data := old_data - ARRAY['embedding_model','embedded_text_hash'] - ${ROW_ATTRIBUTION_KEYS};- -- Embedding completion, retrieval telemetry and write attribution- -- (attribution-schema.ts; a journal backfill fills it) are physical projections.+ row_data := row_data - ARRAY['embedding_model','embedded_text_hash','write_origin'] - ${ROW_ATTRIBUTION_KEYS};+ old_data := old_data - ARRAY['embedding_model','embedded_text_hash','write_origin'] - ${ROW_ATTRIBUTION_KEYS};+ -- Embedding completion, retrieval telemetry, write attribution+ -- (attribution-schema.ts; a journal backfill fills it) and the write origin+ -- record are physical projections. The trust tier is not: it stays guarded.IF (row_data - ARRAY['embedding','embedded_at','last_retrieved_at','retrieval_count','updated_at'])= (old_data - ARRAY['embedding','embedded_at','last_retrieved_at','retrieval_count','updated_at']) THEN RETURN NEW; END IF;END IF;diff --git a/src/core/pglite-schema.generated.ts b/src/core/pglite-schema.generated.tsindex d2c8054a97..d730222f1f 100644--- a/src/core/pglite-schema.generated.ts+++ b/src/core/pglite-schema.generated.ts@@ -1331,7 +1331,9 @@ BEGINIF TG_TABLE_NAME='pages' AND TG_OP='UPDATE' THENIF (NEW.source_id,NEW.slug,NEW.type,NEW.page_kind,NEW.title,NEW.compiled_truth,NEW.timeline,NEW.frontmatter,NEW.deleted_at,NEW.knowledge_revision)IS NOT DISTINCT FROM- (OLD.source_id,OLD.slug,OLD.type,OLD.page_kind,OLD.title,OLD.compiled_truth,OLD.timeline,OLD.frontmatter,OLD.deleted_at,OLD.knowledge_revision) THEN RETURN NEW; END IF;+ (OLD.source_id,OLD.slug,OLD.type,OLD.page_kind,OLD.title,OLD.compiled_truth,OLD.timeline,OLD.frontmatter,OLD.deleted_at,OLD.knowledge_revision)+ -- The trust tier is guarded content (trust/schema.ts); read by key so brains before the column keep working.+ AND row_data->'trust_tier' IS NOT DISTINCT FROM old_data->'trust_tier' THEN RETURN NEW; END IF;ELSIF TG_TABLE_NAME='sources' THENIF TG_OP='UPDATE' AND (NEW.id,NEW.incarnation,NEW.local_path,NEW.archived)IS NOT DISTINCT FROM (OLD.id,OLD.incarnation,OLD.local_path,OLD.archived) THEN@@ -1352,10 +1354,11 @@ BEGINEND IF;IF TG_OP='DELETE' THEN RETURN OLD; ELSE RETURN NEW; END IF;ELSIF TG_TABLE_NAME IN ('facts','takes') AND TG_OP='UPDATE' THEN- row_data := row_data - ARRAY['embedding_model','embedded_text_hash'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];- old_data := old_data - ARRAY['embedding_model','embedded_text_hash'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];- -- Embedding completion, retrieval telemetry and write attribution- -- (attribution-schema.ts; a journal backfill fills it) are physical projections.+ row_data := row_data - ARRAY['embedding_model','embedded_text_hash','write_origin'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];+ old_data := old_data - ARRAY['embedding_model','embedded_text_hash','write_origin'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];+ -- Embedding completion, retrieval telemetry, write attribution+ -- (attribution-schema.ts; a journal backfill fills it) and the write origin+ -- record are physical projections. The trust tier is not: it stays guarded.IF (row_data - ARRAY['embedding','embedded_at','last_retrieved_at','retrieval_count','updated_at'])= (old_data - ARRAY['embedding','embedded_at','last_retrieved_at','retrieval_count','updated_at']) THEN RETURN NEW; END IF;END IF;diff --git a/src/core/schema-embedded.generated.ts b/src/core/schema-embedded.generated.tsindex 4566433c96..ccbf627ecf 100644--- a/src/core/schema-embedded.generated.ts+++ b/src/core/schema-embedded.generated.ts@@ -2053,7 +2053,9 @@ BEGINIF TG_TABLE_NAME='pages' AND TG_OP='UPDATE' THENIF (NEW.source_id,NEW.slug,NEW.type,NEW.page_kind,NEW.title,NEW.compiled_truth,NEW.timeline,NEW.frontmatter,NEW.deleted_at,NEW.knowledge_revision)IS NOT DISTINCT FROM- (OLD.source_id,OLD.slug,OLD.type,OLD.page_kind,OLD.title,OLD.compiled_truth,OLD.timeline,OLD.frontmatter,OLD.deleted_at,OLD.knowledge_revision) THEN RETURN NEW; END IF;+ (OLD.source_id,OLD.slug,OLD.type,OLD.page_kind,OLD.title,OLD.compiled_truth,OLD.timeline,OLD.frontmatter,OLD.deleted_at,OLD.knowledge_revision)+ -- The trust tier is guarded content (trust/schema.ts); read by key so brains before the column keep working.+ AND row_data->'trust_tier' IS NOT DISTINCT FROM old_data->'trust_tier' THEN RETURN NEW; END IF;ELSIF TG_TABLE_NAME='sources' THENIF TG_OP='UPDATE' AND (NEW.id,NEW.incarnation,NEW.local_path,NEW.archived)IS NOT DISTINCT FROM (OLD.id,OLD.incarnation,OLD.local_path,OLD.archived) THEN@@ -2074,10 +2076,11 @@ BEGINEND IF;IF TG_OP='DELETE' THEN RETURN OLD; ELSE RETURN NEW; END IF;ELSIF TG_TABLE_NAME IN ('facts','takes') AND TG_OP='UPDATE' THEN- row_data := row_data - ARRAY['embedding_model','embedded_text_hash'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];- old_data := old_data - ARRAY['embedding_model','embedded_text_hash'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];- -- Embedding completion, retrieval telemetry and write attribution- -- (attribution-schema.ts; a journal backfill fills it) are physical projections.+ row_data := row_data - ARRAY['embedding_model','embedded_text_hash','write_origin'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];+ old_data := old_data - ARRAY['embedding_model','embedded_text_hash','write_origin'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];+ -- Embedding completion, retrieval telemetry, write attribution+ -- (attribution-schema.ts; a journal backfill fills it) and the write origin+ -- record are physical projections. The trust tier is not: it stays guarded.IF (row_data - ARRAY['embedding','embedded_at','last_retrieved_at','retrieval_count','updated_at'])= (old_data - ARRAY['embedding','embedded_at','last_retrieved_at','retrieval_count','updated_at']) THEN RETURN NEW; END IF;END IF;diff --git a/src/core/schema-migrations/registry.generated.ts b/src/core/schema-migrations/registry.generated.tsindex 54cf78e271..7a16127fd1 100644--- a/src/core/schema-migrations/registry.generated.ts+++ b/src/core/schema-migrations/registry.generated.ts@@ -220,6 +220,7 @@ import { v216 } from './v216-chronicle-campaign-stamps.ts';import { v217 } from './v217-persistence-request-claim-phase.ts';import { v218 } from './v218-purge-legacy-worktree-manifest-files.ts';import { v219 } from './v219-pages-reconcile-name-indexes.ts';+import { v230 } from './v230-trust-tiers.ts';// Array order is historical (see HISTORICAL_ARRAY_ORDER in the generator); the// runner sorts by version before applying.@@ -438,4 +439,5 @@ export const MIGRATIONS: Migration[] = [v217,v218,v219,+ v230,];diff --git a/src/core/schema-migrations/v230-trust-tiers.ts b/src/core/schema-migrations/v230-trust-tiers.tsnew file mode 100644index 0000000000..057a219b15--- /dev/null+++ b/src/core/schema-migrations/v230-trust-tiers.ts@@ -0,0 +1,26 @@+import type { Migration } from './types.ts';+import { TRUST_SCHEMA_SQL } from '../trust/schema.ts';+import { MANAGED_WRITER_GUARD_FUNCTION_SQL } from '../persistence/writer-guard-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.+//+// Memory trust tiers (#5575): `trust_tier` (NOT NULL DEFAULT 'unknown', a+// constant default, so the ADD is metadata-only on Postgres 11+ and PGLite;+// the CHECK is added NOT VALID and validated in a separate statement) and+// `write_origin` on facts, takes, timeline_entries and pages; the+// page_versions snapshot; the nullable per-token `min_trust` read floor on+// oauth_clients and access_tokens; the trust_proposals decision record; and+// the BEFORE ROW trigger that stamps and guards the tier (trust/schema.ts).+// Every existing row reads `unknown` until `gbrain trust backfill` classifies+// it. content_chunks gets no column: chunk tier is its page's at read time.+// The managed-writer guard function is re-created (no table lock) so a page+// tier change is guarded content like the page body. No schema.sql mirror:+// like write attribution, these columns exist only through migrations.+export const v230: Migration = {+ version: 230,+ name: 'trust_tiers',+ idempotent: true,+ sql: `${TRUST_SCHEMA_SQL}+${MANAGED_WRITER_GUARD_FUNCTION_SQL}`,+};diff --git a/src/core/trust/schema.ts b/src/core/trust/schema.tsnew file mode 100644index 0000000000..144a209331--- /dev/null+++ b/src/core/trust/schema.ts@@ -0,0 +1,220 @@+/**+ * Memory trust tiers (#5575) in the database: the `trust_tier` and+ * `write_origin` columns, the BEFORE ROW trigger that stamps and guards them,+ * the page_versions snapshot, the per-token `min_trust` read floor and the+ * `trust_proposals` decision record. One canonical copy used by the trust+ * tiers schema migration. Like the attribution DDL it is not in the schema+ * blob: a fresh install replays every migration.+ *+ * The writer's tier reaches the trigger through transaction-local settings+ * that the attribution seam sets (persistence/context.ts):+ * gbrain.write_trust_tier the effective tier (trust/tier.ts computes it once)+ * gbrain.write_origin its origin record, JSON text+ * gbrain.write_trust_promotion a tier ceiling for an explicit raise (owner confirmation, CEO-9)+ * gbrain.write_trust_backfill 'on' for the deterministic backfill (CEO-10)+ *+ * Trigger semantics (CEO-12, CEO-16, CEO-10, ENG-13):+ * - INSERT: the row gets the writer's tier, or `unknown` without one; a+ * supplied value is honored only under the backfill setting (never above+ * operator_curated without promotion).+ * - UPDATE that changes a TRUST_CONTENT_COLUMNS column: an owner-tier writer+ * (operator_curated or higher) restamps the row to its tier; any lower+ * writer (or none, read as `unknown`) sets min(prior tier, writer tier).+ * - UPDATE that changes no content column keeps the stored tier.+ * - An UPDATE that sets a higher tier is honored under a covering promotion+ * ceiling, or under the backfill setting from `unknown` to anything below+ * user_confirmed. Inside a writer scope it is otherwise clamped back; with+ * no writer scope it raises `trust_raise_refused`. Lowering is always allowed.+ * - A writer tier above operator_curated needs a covering promotion ceiling.+ *+ * `gbrain.write_trust_promotion` protects against bugs, not against a process+ * holding a raw database connection, which can set any setting.+ */+import { HASH_EPHEMERAL_FRONTMATTER_KEYS } from '../utils.ts';+import { OWNER_TIER_FLOOR, TRUST_TIERS, trustRankSql } from './tier.ts';++export type TrustTable = 'facts' | 'takes' | 'timeline_entries' | 'pages';+export const TRUST_TABLES: readonly TrustTable[] = ['facts', 'takes', 'timeline_entries', 'pages'];++/**+ * Frontmatter keys whose change is not a content change for the tier rule:+ * the hash-ephemeral keys (timestamps and gate-owned markers re-derived on+ * every import) and the stored quarantine override. The lower-only+ * `trust_tier` marker is content on purpose: deleting it by hand is the+ * owner act that lets the next owner sync restamp the page (CEO-21).+ */+export const TRUST_EPHEMERAL_FRONTMATTER_KEYS: readonly string[] = [...HASH_EPHEMERAL_FRONTMATTER_KEYS, 'quarantine_override'];++/**+ * ENG-2: the columns whose change is a content rewrite. Lifecycle and+ * placement columns (expiry, supersession, consolidation, row numbers,+ * visibility, notability, confidence, active, resolution, weight, source)+ * keep the stored tier. Pages use the pages_knowledge_revision tuple+ * (page-state/schema.ts) with the ephemeral frontmatter keys removed.+ * Pinned by test/trust-tier-schema.test.ts.+ */+export const TRUST_CONTENT_COLUMNS: Readonly<Record<TrustTable, readonly string[]>> = {+ facts: ['fact', 'entity_slug', 'kind', 'claim_metric', 'claim_value', 'claim_unit', 'claim_period', 'value', 'event_type', 'dimension', 'context'],+ takes: ['claim', 'kind', 'holder'],+ timeline_entries: ['summary', 'detail', 'date'],+ pages: ['source_id', 'slug', 'type', 'page_kind', 'title', 'compiled_truth', 'timeline', 'frontmatter', 'deleted_at'],+};++/** Columns the migration adds to every trust table (and to page_versions, nullable there). */+export const TRUST_ROW_COLUMNS = ['trust_tier', 'write_origin'] as const;++export const TRUST_TIER_TRIGGER = 'trust_tier_stamp';+export const TRUST_VERSION_TRIGGER = 'page_versions_trust_snapshot';+/** Triggers that must fire before the tier trigger on the same row (PostgreSQL fires same-timing triggers by name). */+export const TRUST_TIER_TRIGGER_PREDECESSORS: Readonly<Record<TrustTable, readonly string[]>> = {+ facts: ['facts_preserve_withdrawal', 'gbrain_write_attribution', 'managed_writer_guard'],+ takes: ['gbrain_write_attribution', 'managed_writer_guard'],+ timeline_entries: ['gbrain_write_attribution', 'managed_writer_guard'],+ pages: ['managed_writer_guard', 'pages_knowledge_revision', 'pages_revision_attribution', 'trg_pages_search_vector'],+};++const tierList = TRUST_TIERS.map(tier => `'${tier}'`).join(',');+const rank = trustRankSql;+const lowerOf = (a: string, b: string) => `(CASE WHEN ${rank(a)} <= ${rank(b)} THEN ${a} ELSE ${b} END)`;+const contentExpr = (row: 'NEW' | 'OLD', table: TrustTable) => TRUST_CONTENT_COLUMNS[table]+ .map(column => table === 'pages' && column === 'frontmatter'+ ? `(${row}.frontmatter - ARRAY[${TRUST_EPHEMERAL_FRONTMATTER_KEYS.map(key => `'${key}'`).join(',')}]::text[])`+ : `${row}.${column}`)+ .join(', ');+const contentChanged = (table: TrustTable) => `(${contentExpr('NEW', table)}) IS DISTINCT FROM (${contentExpr('OLD', table)})`;+const refuse = (message: string, detail: string) => `RAISE EXCEPTION USING ERRCODE='P0001', MESSAGE='trust_raise_refused: ${message}',+ TABLE=TG_TABLE_NAME, SCHEMA=TG_TABLE_SCHEMA, CONSTRAINT='trust_tier_guard', DETAIL=${detail}`;+const SETTINGS = `+ writer := NULLIF(current_setting('gbrain.write_trust_tier', true), '');+ origin_text := NULLIF(current_setting('gbrain.write_origin', true), '');+ promo := NULLIF(current_setting('gbrain.write_trust_promotion', true), '');+ backfill := COALESCE(current_setting('gbrain.write_trust_backfill', true), '') = 'on';+ IF ${rank('writer')} = 0 AND writer IS NOT NULL OR ${rank('promo')} = 0 AND promo IS NOT NULL THEN+ RAISE EXCEPTION USING ERRCODE='22023', MESSAGE='gbrain trust setting names no tier', CONSTRAINT='trust_tier_guard';+ END IF;`;++const STAMP_TIER_FUNCTION = `CREATE OR REPLACE FUNCTION gbrain_stamp_trust_tier() RETURNS trigger LANGUAGE plpgsql SET search_path = pg_catalog, public AS $fn$+DECLARE writer text; origin_text text; promo text; backfill boolean; changed boolean; effective text;+BEGIN${SETTINGS}+ IF ${rank('writer')} > ${rank(`'${OWNER_TIER_FLOOR}'`)} AND (promo IS NULL OR ${rank('writer')} > ${rank('promo')}) THEN+ ${refuse('a write declared a tier above operator_curated without owner confirmation', `jsonb_build_object('op',TG_OP,'writer',writer)::text`)};+ END IF;+ IF TG_OP = 'INSERT' THEN+ IF backfill THEN+ IF ${rank('NEW.trust_tier')} > ${rank(`'${OWNER_TIER_FLOOR}'`)} AND (promo IS NULL OR ${rank('NEW.trust_tier')} > ${rank('promo')}) THEN+ ${refuse('a copied row named a tier above operator_curated without owner confirmation', `jsonb_build_object('op',TG_OP,'to',NEW.trust_tier)::text`)};+ END IF;+ RETURN NEW;+ END IF;+ NEW.trust_tier := COALESCE(writer, 'unknown');+ NEW.write_origin := origin_text::jsonb;+ RETURN NEW;+ END IF;+ IF ${rank('NEW.trust_tier')} > ${rank('OLD.trust_tier')} THEN+ IF promo IS NOT NULL AND ${rank('NEW.trust_tier')} <= ${rank('promo')} THEN+ RETURN NEW;+ ELSIF backfill AND OLD.trust_tier = 'unknown' AND NEW.trust_tier <> 'user_confirmed' THEN+ RETURN NEW;+ ELSIF writer IS NULL THEN+ ${refuse('raising a tier needs owner confirmation', `jsonb_build_object('op',TG_OP,'from',OLD.trust_tier,'to',NEW.trust_tier,'backfill',backfill)::text`)};+ END IF;+ NEW.trust_tier := OLD.trust_tier;+ END IF;+ ${TRUST_TABLES.map((table, index) => `${index === 0 ? 'IF' : 'ELSIF'} TG_TABLE_NAME = '${table}' THEN+ changed := ${contentChanged(table)};`).join('\n ')}+ ELSE+ RAISE EXCEPTION 'gbrain_stamp_trust_tier is not classified for table %', TG_TABLE_NAME;+ END IF;+ IF changed THEN+ effective := COALESCE(writer, 'unknown');+ IF ${rank('effective')} < ${rank(`'${OWNER_TIER_FLOOR}'`)} THEN effective := ${lowerOf('OLD.trust_tier', 'effective')}; END IF;+ IF ${rank('NEW.trust_tier')} < ${rank('OLD.trust_tier')} THEN effective := ${lowerOf('NEW.trust_tier', 'effective')}; END IF;+ NEW.trust_tier := effective;+ IF NEW.write_origin IS NOT DISTINCT FROM OLD.write_origin THEN NEW.write_origin := origin_text::jsonb; END IF;+ END IF;+ RETURN NEW;+END $fn$`;++/**+ * A version row snapshots the page before the archiving write changes it, in+ * the same transaction, so the page row still carries the snapshotted tier+ * (ENG-10). A supplied value is honored only under the backfill setting.+ */+const SNAPSHOT_VERSION_FUNCTION = `CREATE OR REPLACE FUNCTION gbrain_snapshot_version_trust() RETURNS trigger LANGUAGE plpgsql SET search_path = pg_catalog, public AS $fn$+BEGIN+ IF COALESCE(current_setting('gbrain.write_trust_backfill', true), '') = 'on' AND NEW.trust_tier IS NOT NULL THEN RETURN NEW; END IF;+ SELECT p.trust_tier, p.write_origin INTO NEW.trust_tier, NEW.write_origin FROM pages p WHERE p.id = NEW.page_id;+ RETURN NEW;+END $fn$`;++/** NOT VALID first (no scan under the ADD), then a separate validation pass. */+const checkConstraint = (table: string, name: string, predicate: string) => [+ `DO $do$ BEGIN+ IF NOT EXISTS (SELECT 1 FROM pg_constraint WHERE conname = '${name}' AND conrelid = '${table}'::regclass) THEN+ ALTER TABLE ${table} ADD CONSTRAINT ${name} CHECK (${predicate}) NOT VALID;+ END IF;+ END $do$`,+ `ALTER TABLE ${table} VALIDATE CONSTRAINT ${name}`,+];++export const TRUST_PROPOSAL_ACTIONS = ['supersede_fact', 'supersede_take', 'forget', 'lower_page', 'confirm'] as const;+export const TRUST_PROPOSAL_STATUSES = ['pending', 'accepted', 'rejected', 'undone', 'superseded'] as const;+const list = (values: readonly string[]) => values.map(value => `'${value}'`).join(',');+const TRUST_TABLE_LIST = list(TRUST_TABLES);++/**+ * ENG-4: one typed trust-decision record. Handlers (lane L1) reuse the+ * decide_proposals coordinator primitives; CLI refs are `tp<id>`. `target`+ * is the row the decision changes; `related` is the row that caused it (the+ * contested lower-tier fact of a guarded supersession, the agent version of a+ * lowered page). before_state/after_state hold tiers, ids and revisions, the+ * exact state the accept path re-checks under lock.+ */+const TRUST_PROPOSALS_DDL = `CREATE TABLE IF NOT EXISTS trust_proposals (+ id BIGSERIAL PRIMARY KEY,+ action TEXT NOT NULL CHECK (action IN (${list(TRUST_PROPOSAL_ACTIONS)})),+ source_id TEXT NOT NULL REFERENCES sources(id) ON DELETE CASCADE,+ target_table TEXT NOT NULL CHECK (target_table IN (${TRUST_TABLE_LIST})),+ target_id BIGINT NOT NULL,+ related_table TEXT CHECK (related_table IN (${TRUST_TABLE_LIST})),+ related_id BIGINT,+ before_state JSONB NOT NULL DEFAULT '{}'::jsonb,+ after_state JSONB NOT NULL DEFAULT '{}'::jsonb,+ proposer TEXT NOT NULL,+ proposer_principal_kind TEXT,+ proposer_principal_id TEXT,+ write_request_id UUID,+ status TEXT NOT NULL DEFAULT 'pending' CHECK (status IN (${list(TRUST_PROPOSAL_STATUSES)})),+ decided_at TIMESTAMPTZ,+ decided_principal_kind TEXT,+ decided_principal_id TEXT,+ created_at TIMESTAMPTZ NOT NULL DEFAULT now(),+ updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),+ CHECK ((related_table IS NULL) = (related_id IS NULL))+)`;++export const TRUST_SCHEMA_STATEMENTS = [+ ...TRUST_TABLES.map(table => `ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS trust_tier TEXT NOT NULL DEFAULT 'unknown', ADD COLUMN IF NOT EXISTS write_origin JSONB`),+ ...TRUST_TABLES.flatMap(table => checkConstraint(table, `${table}_trust_tier_check`, `trust_tier IN (${tierList})`)),+ `ALTER TABLE page_versions ADD COLUMN IF NOT EXISTS trust_tier TEXT, ADD COLUMN IF NOT EXISTS write_origin JSONB`,+ ...checkConstraint('page_versions', 'page_versions_trust_tier_check', `trust_tier IS NULL OR trust_tier IN (${tierList})`),+ ...['oauth_clients', 'access_tokens'].flatMap(table => [+ `ALTER TABLE ${table} ADD COLUMN IF NOT EXISTS min_trust TEXT`,+ ...checkConstraint(table, `${table}_min_trust_check`, `min_trust IS NULL OR min_trust IN (${tierList})`),+ ]),+ TRUST_PROPOSALS_DDL,+ `CREATE INDEX IF NOT EXISTS trust_proposals_pending_idx ON trust_proposals (source_id, created_at) WHERE status = 'pending'`,+ `CREATE INDEX IF NOT EXISTS trust_proposals_target_idx ON trust_proposals (target_table, target_id)`,+ `CREATE UNIQUE INDEX IF NOT EXISTS trust_proposals_pending_unique ON trust_proposals+ (action, target_table, target_id, COALESCE(related_table, ''), COALESCE(related_id, 0)) WHERE status = 'pending'`,+ STAMP_TIER_FUNCTION,+ SNAPSHOT_VERSION_FUNCTION,+ ...TRUST_TABLES.flatMap(table => [+ `DROP TRIGGER IF EXISTS ${TRUST_TIER_TRIGGER} ON ${table}`,+ `CREATE TRIGGER ${TRUST_TIER_TRIGGER} BEFORE INSERT OR UPDATE ON ${table} FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()`,+ ]),+ `DROP TRIGGER IF EXISTS ${TRUST_VERSION_TRIGGER} ON page_versions`,+ `CREATE TRIGGER ${TRUST_VERSION_TRIGGER} BEFORE INSERT ON page_versions FOR EACH ROW EXECUTE FUNCTION gbrain_snapshot_version_trust()`,+] as const;++export const TRUST_SCHEMA_SQL = `${TRUST_SCHEMA_STATEMENTS.join(';\n')};\n`;diff --git a/src/core/trust/tier.ts b/src/core/trust/tier.tsnew file mode 100644index 0000000000..07100de70b--- /dev/null+++ b/src/core/trust/tier.ts@@ -0,0 +1,174 @@+/**+ * Memory trust tiers (#5575): how much a stored fact, take, page or timeline+ * entry deserves to influence an agent. One vocabulary, one order and one set+ * of user-facing labels for every writer, reader, gate and doctor check.+ *+ * Order (highest first, also the filter order of `min_trust`):+ * user_confirmed > operator_curated > tool_observed > agent_written > unknown > external_untrusted.+ * `unknown` marks rows written before tiers existed (or by a writer that has+ * not declared its channel yet); it is never treated as confirmed.+ *+ * The effective tier of a write is computed once, here (`effectiveWriteTrust`),+ * by the writer or coordinator scope; it reaches the database through the+ * transaction-local `gbrain.write_trust_tier` / `gbrain.write_origin` settings+ * (persistence/context.ts) and the BEFORE ROW trigger (trust/schema.ts) only+ * clamps it. The same value is what the write gate receives.+ */+import { opError } from '../ops/contract.ts';++export const TRUST_TIERS = [+ 'user_confirmed', 'operator_curated', 'tool_observed', 'agent_written', 'unknown', 'external_untrusted',+] as const;+export type TrustTier = typeof TRUST_TIERS[number];++/** Larger is more trusted. Shared with the trigger SQL (trust/schema.ts) through `trustRankSql`. */+export const TRUST_TIER_RANK: Readonly<Record<TrustTier, number>> = Object.freeze({+ user_confirmed: 6, operator_curated: 5, tool_observed: 4, agent_written: 3, unknown: 2, external_untrusted: 1,+});++/** The fixed user-facing labels (DX-8). Enum names appear only in JSON. */+export const TRUST_TIER_LABELS: Readonly<Record<TrustTier, string>> = Object.freeze({+ user_confirmed: 'confirmed by you',+ operator_curated: 'your notes',+ tool_observed: 'tool data',+ agent_written: 'written by an agent',+ unknown: 'unverified origin',+ external_untrusted: 'external, untrusted',+});++/** Writers at or above this tier restamp a row on a content rewrite (CEO-12); lower writers can only lower it. */+export const OWNER_TIER_FLOOR: TrustTier = 'operator_curated';++export function isTrustTier(value: unknown): value is TrustTier {+ return typeof value === 'string' && Object.hasOwn(TRUST_TIER_RANK, value);+}++/** A tier named by a caller (CLI flag, op param, config value); anything else is `invalid_params` listing the accepted values. */+export function parseTrustTier(value: unknown, param = 'tier'): TrustTier {+ if (isTrustTier(value)) return value;+ throw opError('invalid_params', `${param} must be one of ${TRUST_TIERS.join(', ')}; got ${JSON.stringify(value)}.`,+ `Pass one of: ${TRUST_TIERS.join(', ')}.`);+}++/** Positive when `a` is more trusted than `b`, negative when less, 0 when equal. */+export function compareTrust(a: TrustTier, b: TrustTier): number {+ return TRUST_TIER_RANK[a] - TRUST_TIER_RANK[b];+}++/** The least trusted of the given tiers (taint, nesting, lowering). At least one tier is required. */+export function minTrust(first: TrustTier, ...rest: TrustTier[]): TrustTier {+ return rest.reduce((low, tier) => (TRUST_TIER_RANK[tier] < TRUST_TIER_RANK[low] ? tier : low), first);+}++/** The most trusted of the given tiers (the stricter of two read floors). */+export function maxTrust(first: TrustTier, ...rest: TrustTier[]): TrustTier {+ return rest.reduce((high, tier) => (TRUST_TIER_RANK[tier] > TRUST_TIER_RANK[high] ? tier : high), first);+}++/** CEO-13: `min_trust=floor` admits rows at or above the floor. */+export function admitsTrust(rowTier: TrustTier, floor: TrustTier): boolean {+ return TRUST_TIER_RANK[rowTier] >= TRUST_TIER_RANK[floor];+}++/** Every tier a `min_trust=floor` read admits, highest first (for SQL `= ANY($n)` filters). */+export function tiersAtOrAbove(floor: TrustTier): TrustTier[] {+ return TRUST_TIERS.filter(tier => admitsTrust(tier, floor));+}++export function trustLabel(tier: TrustTier): string {+ return TRUST_TIER_LABELS[tier];+}++/** A stored tier read back from the database; NULL (a legacy page_versions row) and unrecognized values read as `unknown`. */+export function storedTrustTier(value: unknown): TrustTier {+ return isTrustTier(value) ? value : 'unknown';+}++/** SQL expression mapping a tier-valued expression to its rank (unrecognized and NULL -> 0). */+export function trustRankSql(expr: string): string {+ return `(CASE ${expr} ${TRUST_TIERS.map(tier => `WHEN '${tier}' THEN ${TRUST_TIER_RANK[tier]}`).join(' ')} ELSE 0 END)`;+}++/** SQL expression mapping a rank expression back to its tier name. */+export function trustTierFromRankSql(expr: string): string {+ return `(CASE ${expr} ${TRUST_TIERS.map(tier => `WHEN ${TRUST_TIER_RANK[tier]} THEN '${tier}'`).join(' ')} ELSE 'unknown' END)`;+}++// ---------------------------------------------------------------------------+// Agent-declared content origin (DX-8, CEO-26)+// ---------------------------------------------------------------------------++export const CONTENT_ORIGINS = ['user_said', 'tool_output', 'inferred'] as const;+export type ContentOrigin = typeof CONTENT_ORIGINS[number];++/** `tool_output` lowers a write to external_untrusted; `user_said` never confers owner authority. */+export function contentOriginTier(value: unknown): TrustTier {+ if (value === 'tool_output') return 'external_untrusted';+ if (value === 'user_said' || value === 'inferred') return 'agent_written';+ throw opError('invalid_params', `content_origin must be one of ${CONTENT_ORIGINS.join(', ')}; got ${JSON.stringify(value)}.`,+ `Pass content_origin as one of: ${CONTENT_ORIGINS.join(', ')} (tool_output for text that came from a web page, email, file or other tool).`);+}++// ---------------------------------------------------------------------------+// The effective tier of one write (ENG-18), and its origin record (CEO-1)+// ---------------------------------------------------------------------------++export type TaintTable = 'facts' | 'takes' | 'pages' | 'timeline_entries';+export interface TaintInput { table: TaintTable; id: number | string; tier: TrustTier }++/** At most this many taint inputs are kept in `write_origin` (the 32 least trusted); complete edges live elsewhere (ENG-7). */+export const TAINT_INPUT_SAMPLE_LIMIT = 32;++/** Stored in `write_origin` (jsonb). `channel` names the write path, e.g. `mcp:put_page`, `sync`, `connector:google`. */+export interface WriteOrigin {+ channel: string;+ connector?: string;+ source_uri?: string;+ request_id?: string;+ taint_inputs?: TaintInput[];+ taint_inputs_truncated?: true;+ taint_input_count?: number;+}++/** What a writer declares to the attribution seam: the tier its rows get and why. */+export interface WriteTrust { tier: TrustTier; origin: WriteOrigin | null }++export interface WriteTrustInput {+ /** The tier the write channel earns (A3), e.g. agent_written for a remote MCP write. */+ channel: TrustTier;+ /** Lowering signals: content_origin, frontmatter markers, source trust settings. They can only lower. */+ lowerTo?: readonly TrustTier[];+ /** A model or rule derived this content from other rows: tier = min(inputs, agent_written) (A3, ENG-3). */+ derived?: boolean;+ /** Every input placed in the derivation's context (ENG-3). */+ inputs?: readonly TaintInput[];+ origin: Omit<WriteOrigin, 'taint_inputs' | 'taint_inputs_truncated' | 'taint_input_count'>;+}++/**+ * Computes the tier once. A derived write is capped at agent_written and at+ * the least trusted input; lowering signals apply last. The origin keeps a+ * bounded display sample of the inputs (least trusted first).+ */+export function effectiveWriteTrust(input: WriteTrustInput): WriteTrust {+ const inputs = input.inputs ?? [];+ const caps: TrustTier[] = [...(input.lowerTo ?? []), ...inputs.map(i => i.tier)];+ if (input.derived) caps.push('agent_written');+ const tier = minTrust(input.channel, ...caps);+ const origin: WriteOrigin = { ...input.origin };+ if (inputs.length) {+ const sample = [...inputs].sort((a, b) => compareTrust(a.tier, b.tier)).slice(0, TAINT_INPUT_SAMPLE_LIMIT);+ origin.taint_inputs = sample;+ if (inputs.length > TAINT_INPUT_SAMPLE_LIMIT) {+ origin.taint_inputs_truncated = true;+ origin.taint_input_count = inputs.length;+ }+ }+ return { tier, origin };+}++/** Combines a nested declaration with the enclosing one: a nested write can lower the tier, never raise it. */+export function nestWriteTrust(outer: WriteTrust | null, inner: WriteTrust): WriteTrust {+ if (!outer) return inner;+ return { tier: minTrust(outer.tier, inner.tier), origin: inner.origin ?? outer.origin };+}diff --git a/src/schema.sql b/src/schema.sqlindex aebd2e4791..f0adc265f7 100644--- a/src/schema.sql+++ b/src/schema.sql@@ -2049,7 +2049,9 @@ BEGINIF TG_TABLE_NAME='pages' AND TG_OP='UPDATE' THENIF (NEW.source_id,NEW.slug,NEW.type,NEW.page_kind,NEW.title,NEW.compiled_truth,NEW.timeline,NEW.frontmatter,NEW.deleted_at,NEW.knowledge_revision)IS NOT DISTINCT FROM- (OLD.source_id,OLD.slug,OLD.type,OLD.page_kind,OLD.title,OLD.compiled_truth,OLD.timeline,OLD.frontmatter,OLD.deleted_at,OLD.knowledge_revision) THEN RETURN NEW; END IF;+ (OLD.source_id,OLD.slug,OLD.type,OLD.page_kind,OLD.title,OLD.compiled_truth,OLD.timeline,OLD.frontmatter,OLD.deleted_at,OLD.knowledge_revision)+ -- The trust tier is guarded content (trust/schema.ts); read by key so brains before the column keep working.+ AND row_data->'trust_tier' IS NOT DISTINCT FROM old_data->'trust_tier' THEN RETURN NEW; END IF;ELSIF TG_TABLE_NAME='sources' THENIF TG_OP='UPDATE' AND (NEW.id,NEW.incarnation,NEW.local_path,NEW.archived)IS NOT DISTINCT FROM (OLD.id,OLD.incarnation,OLD.local_path,OLD.archived) THEN@@ -2070,10 +2072,11 @@ BEGINEND IF;IF TG_OP='DELETE' THEN RETURN OLD; ELSE RETURN NEW; END IF;ELSIF TG_TABLE_NAME IN ('facts','takes') AND TG_OP='UPDATE' THEN- row_data := row_data - ARRAY['embedding_model','embedded_text_hash'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];- old_data := old_data - ARRAY['embedding_model','embedded_text_hash'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];- -- Embedding completion, retrieval telemetry and write attribution- -- (attribution-schema.ts; a journal backfill fills it) are physical projections.+ row_data := row_data - ARRAY['embedding_model','embedded_text_hash','write_origin'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];+ old_data := old_data - ARRAY['embedding_model','embedded_text_hash','write_origin'] - ARRAY['write_request_id','write_principal_kind','write_principal_id','last_write_request_id','last_write_principal_kind','last_write_principal_id','last_written_at'];+ -- Embedding completion, retrieval telemetry, write attribution+ -- (attribution-schema.ts; a journal backfill fills it) and the write origin+ -- record are physical projections. The trust tier is not: it stays guarded.IF (row_data - ARRAY['embedding','embedded_at','last_retrieved_at','retrieval_count','updated_at'])= (old_data - ARRAY['embedding','embedded_at','last_retrieved_at','retrieval_count','updated_at']) THEN RETURN NEW; END IF;END IF;diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-default.json b/test/fixtures/goldens/catalog/pglite-engine-init-default.jsonindex ea9e4cf815..6623f76703 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-default.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-default.json@@ -1,6 +1,7 @@{"golden": {"constraints": {+ "access_tokens.access_tokens_min_trust_check": "c CHECK (((min_trust IS NULL) OR (min_trust = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","access_tokens.access_tokens_pkey": "p PRIMARY KEY (id)","access_tokens.access_tokens_source_grant_check": "c CHECK ((source_grant = ANY (ARRAY['default'::text, 'scalar'::text, 'federated'::text, 'none'::text])))","access_tokens.access_tokens_token_hash_key": "u UNIQUE (token_hash)",@@ -81,6 +82,7 @@"facts.facts_pkey": "p PRIMARY KEY (id)","facts.facts_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","facts.facts_superseded_by_fkey": "f FOREIGN KEY (superseded_by) REFERENCES facts(id) ON DELETE SET NULL",+ "facts.facts_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","facts.facts_visibility_check": "c CHECK ((visibility = ANY (ARRAY['private'::text, 'world'::text])))","files.files_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE SET NULL","files.files_pkey": "p PRIMARY KEY (id)",@@ -164,6 +166,7 @@"minion_self_fix_log.minion_self_fix_log_parent_id_fkey": "f FOREIGN KEY (parent_id) REFERENCES minion_jobs(id) ON DELETE SET NULL","minion_self_fix_log.minion_self_fix_log_pkey": "p PRIMARY KEY (id)","oauth_clients.oauth_clients_complete_agent_grant": "c CHECK (((NOT (COALESCE(scope, ''::text) ~ '(^|[[:space:]])agent([[:space:]]|$)'::text)) OR ((COALESCE(cardinality(bound_tools), 0) > 0) AND (source_id IS NOT NULL) AND (bound_source_id IS NOT NULL) AND (bound_source_id = source_id) AND COALESCE((source_id = ANY (federated_read)), false) AND (((delegated_namespace = 'job'::text) AND (delegated_slug_prefixes IS NULL)) OR ((delegated_namespace = 'prefixes'::text) AND (COALESCE(cardinality(delegated_slug_prefixes), 0) > 0))) AND (bound_max_concurrent > 0))))",+ "oauth_clients.oauth_clients_min_trust_check": "c CHECK (((min_trust IS NULL) OR (min_trust = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","oauth_clients.oauth_clients_pkey": "p PRIMARY KEY (client_id)","oauth_clients.oauth_clients_source_grant_check": "c CHECK ((source_grant = 'none'::text))","oauth_clients.oauth_clients_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE RESTRICT",@@ -198,12 +201,14 @@"page_projection_jobs.page_projection_jobs_source_incarnation_fkey": "f FOREIGN KEY (source_incarnation) REFERENCES sources(incarnation) ON DELETE CASCADE","page_versions.page_versions_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE","page_versions.page_versions_pkey": "p PRIMARY KEY (id)",+ "page_versions.page_versions_trust_tier_check": "c CHECK (((trust_tier IS NULL) OR (trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","page_write_guards.page_write_guards_pkey": "p PRIMARY KEY (source_incarnation, slug)","page_write_guards.page_write_guards_source_incarnation_fkey": "f FOREIGN KEY (source_incarnation) REFERENCES sources(incarnation) ON DELETE CASCADE","pages.pages_page_kind_check": "c CHECK ((page_kind = ANY (ARRAY['markdown'::text, 'code'::text, 'image'::text])))","pages.pages_pkey": "p PRIMARY KEY (id)","pages.pages_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","pages.pages_source_slug_key": "u UNIQUE (source_id, slug)",+ "pages.pages_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","persistence_brain.persistence_brain_pkey": "p PRIMARY KEY (singleton)","persistence_brain.persistence_brain_singleton_check": "c CHECK ((singleton = 1))","persistence_brain.persistence_brain_writer_protocol_floor_check": "c CHECK ((writer_protocol_floor = ANY (ARRAY[1, 2])))",@@ -349,6 +354,7 @@"takes.takes_pkey": "p PRIMARY KEY (id)","takes.takes_resolution_consistency": "c CHECK ((((resolved_quality IS NULL) AND (resolved_outcome IS NULL)) OR ((resolved_quality = 'correct'::text) AND (resolved_outcome = true)) OR ((resolved_quality = 'incorrect'::text) AND (resolved_outcome = false)) OR ((resolved_quality = 'partial'::text) AND (resolved_outcome IS NULL)) OR ((resolved_quality = 'unresolvable'::text) AND (resolved_outcome IS NULL))))","takes.takes_resolved_quality_values": "c CHECK (((resolved_quality IS NULL) OR (resolved_quality = ANY (ARRAY['correct'::text, 'incorrect'::text, 'partial'::text, 'unresolvable'::text]))))",+ "takes.takes_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","takes.takes_weight_check": "c CHECK (((weight >= (0)::double precision) AND (weight <= (1)::double precision)))","think_ab_results.think_ab_results_pkey": "p PRIMARY KEY (id)","think_ab_results.think_ab_results_preferred_check": "c CHECK ((preferred = ANY (ARRAY['baseline'::text, 'with_calibration'::text, 'neither'::text, 'tie'::text])))",@@ -356,6 +362,14 @@"timeline_entries.timeline_entries_event_page_id_fkey": "f FOREIGN KEY (event_page_id) REFERENCES pages(id) ON DELETE CASCADE","timeline_entries.timeline_entries_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE","timeline_entries.timeline_entries_pkey": "p PRIMARY KEY (id)",+ "timeline_entries.timeline_entries_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))",+ "trust_proposals.trust_proposals_action_check": "c CHECK ((action = ANY (ARRAY['supersede_fact'::text, 'supersede_take'::text, 'forget'::text, 'lower_page'::text, 'confirm'::text])))",+ "trust_proposals.trust_proposals_check": "c CHECK (((related_table IS NULL) = (related_id IS NULL)))",+ "trust_proposals.trust_proposals_pkey": "p PRIMARY KEY (id)",+ "trust_proposals.trust_proposals_related_table_check": "c CHECK ((related_table = ANY (ARRAY['facts'::text, 'takes'::text, 'timeline_entries'::text, 'pages'::text])))",+ "trust_proposals.trust_proposals_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE",+ "trust_proposals.trust_proposals_status_check": "c CHECK ((status = ANY (ARRAY['pending'::text, 'accepted'::text, 'rejected'::text, 'undone'::text, 'superseded'::text])))",+ "trust_proposals.trust_proposals_target_table_check": "c CHECK ((target_table = ANY (ARRAY['facts'::text, 'takes'::text, 'timeline_entries'::text, 'pages'::text])))","wanted_links.wanted_links_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE","wanted_links.wanted_links_pkey": "p PRIMARY KEY (id)","wanted_links.wanted_links_producer_check": "c CHECK ((producer = ANY (ARRAY['body'::text, 'frontmatter'::text])))",@@ -387,9 +401,11 @@"gbrain_lease_shared_skill_delivery()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=5e493c1ac8dce8cb025a736629e563437c4b214744137c302c532c20bf7e7acf","gbrain_preserve_fact_withdrawal()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9beb118551a08451a228146373f50f2aa2ce0cfe89937e937d361b33224aa0aa","gbrain_queue_page_projection()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=6c544b9c129b6a17dcabeb5ee8d44a2b0e0af9d02ca3fe47c7d7f22ec313042c",- "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9dc91548479da39c77e3015481b89901ef13fb02ce496597606fbac592c05201",+ "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d444fd431abe188062c7266caa9ab41327336c916805d7dd02a362affe2f26a7","gbrain_require_persistence_protocol(required integer)": "RETURNS void kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=af07b7fac60dec0a4fe568217931ac449d32f73b3a53a047b3b02a5f59cb5058",+ "gbrain_snapshot_version_trust()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=7452350236ed4c68a6cd1f4d78a1381a4ef44cc70e8a032141f01bba4a704702","gbrain_stamp_revision_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d446ed1145d8bb9c93cb0ca4aa076a5dc7a5fe07b3e79518adaf1b17b0a51216",+ "gbrain_stamp_trust_tier()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=c3dbe0330bcdd42294891167e4d9cbec0902e8304ce26e934f0b124bd451bb94","gbrain_stamp_version_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=1b28a0e5769198d86490dc20b2aee80b7e6595670428a63ac9c6825cd2a35b10","gbrain_stamp_write_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=50e9b0e5bf37eeae6555dd16c8104cb0807be6c05a79e0c82237d45162c21dc2","update_chunk_search_vector()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e12c37d5489202aaf708560db42e6c0c7c8886d198d412e1c5d915c3ae782559",@@ -759,6 +775,9 @@"timeline_entries": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "trust_proposals": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"wanted_links": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"]@@ -1130,6 +1149,10 @@"think_ab_results_pkey": "CREATE UNIQUE INDEX think_ab_results_pkey ON public.think_ab_results USING btree (id)","think_ab_results_recent_idx": "CREATE INDEX think_ab_results_recent_idx ON public.think_ab_results USING btree (source_id, ran_at DESC)","timeline_entries_pkey": "CREATE UNIQUE INDEX timeline_entries_pkey ON public.timeline_entries USING btree (id)",+ "trust_proposals_pending_idx": "CREATE INDEX trust_proposals_pending_idx ON public.trust_proposals USING btree (source_id, created_at) WHERE (status = 'pending'::text)",+ "trust_proposals_pending_unique": "CREATE UNIQUE INDEX trust_proposals_pending_unique ON public.trust_proposals USING btree (action, target_table, target_id, COALESCE(related_table, ''::text), COALESCE(related_id, (0)::bigint)) WHERE (status = 'pending'::text)",+ "trust_proposals_pkey": "CREATE UNIQUE INDEX trust_proposals_pkey ON public.trust_proposals USING btree (id)",+ "trust_proposals_target_idx": "CREATE INDEX trust_proposals_target_idx ON public.trust_proposals USING btree (target_table, target_id)","uniq_minion_attachments_job_filename": "CREATE UNIQUE INDEX uniq_minion_attachments_job_filename ON public.minion_attachments USING btree (job_id, filename)","uniq_minion_jobs_idempotency": "CREATE UNIQUE INDEX uniq_minion_jobs_idempotency ON public.minion_jobs USING btree (idempotency_key) WHERE (idempotency_key IS NOT NULL)","uniq_subagent_messages_idx": "CREATE UNIQUE INDEX uniq_subagent_messages_idx ON public.subagent_messages USING btree (job_id, message_idx)",@@ -1195,6 +1218,7 @@"takes_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=takes.id","think_ab_results_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=think_ab_results.id","timeline_entries_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=timeline_entries.id",+ "trust_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=trust_proposals.id","wanted_links_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=wanted_links.id"},"tables": {@@ -1213,7 +1237,8 @@"11 federated_read ARRAY/_text NULL","12 allowed_operations ARRAY/_text NULL","13 takes_holders ARRAY/_text NULL",- "14 grant_revision integer/int4 NOT NULL DEFAULT 0"+ "14 grant_revision integer/int4 NOT NULL DEFAULT 0",+ "15 min_trust text/text NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -1844,7 +1869,9 @@"38 last_write_principal_kind text/text NULL","39 last_write_principal_id text/text NULL","40 last_written_at timestamp with time zone/timestamptz NULL",- "41 attributed_to text/text NULL"+ "41 attributed_to text/text NULL",+ "42 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "43 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -2219,7 +2246,8 @@"27 grant_repair_reasons ARRAY/_text NOT NULL DEFAULT '{}'::text[]","28 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()","29 source_grant text/text NULL",- "30 takes_holders ARRAY/_text NULL"+ "30 takes_holders ARRAY/_text NULL",+ "31 min_trust text/text NULL"],"flags": "relkind=r rls=true force_rls=false"},@@ -2381,7 +2409,9 @@"15 write_principal_id text/text NULL","16 archived_write_request_id uuid/uuid NULL","17 archived_principal_kind text/text NULL",- "18 archived_principal_id text/text NULL"+ "18 archived_principal_id text/text NULL",+ "19 trust_tier text/text NULL",+ "20 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -2433,7 +2463,9 @@"37 links_attendance_blocked_at timestamp with time zone/timestamptz NULL","38 revision_write_request_id uuid/uuid NULL","39 revision_principal_kind text/text NULL",- "40 revision_principal_id text/text NULL"+ "40 revision_principal_id text/text NULL",+ "41 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "42 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -3130,7 +3162,9 @@"29 last_write_request_id uuid/uuid NULL","30 last_write_principal_kind text/text NULL","31 last_write_principal_id text/text NULL",- "32 last_written_at timestamp with time zone/timestamptz NULL"+ "32 last_written_at timestamp with time zone/timestamptz NULL",+ "33 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "34 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -3165,7 +3199,33 @@"12 last_write_request_id uuid/uuid NULL","13 last_write_principal_kind text/text NULL","14 last_write_principal_id text/text NULL",- "15 last_written_at timestamp with time zone/timestamptz NULL"+ "15 last_written_at timestamp with time zone/timestamptz NULL",+ "16 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "17 write_origin jsonb/jsonb NULL"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },+ "trust_proposals": {+ "columns": [+ "1 id bigint/int8 NOT NULL DEFAULT nextval('trust_proposals_id_seq'::regclass)",+ "2 action text/text NOT NULL",+ "3 source_id text/text NOT NULL",+ "4 target_table text/text NOT NULL",+ "5 target_id bigint/int8 NOT NULL",+ "6 related_table text/text NULL",+ "7 related_id bigint/int8 NULL",+ "8 before_state jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "9 after_state jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "10 proposer text/text NOT NULL",+ "11 proposer_principal_kind text/text NULL",+ "12 proposer_principal_id text/text NULL",+ "13 write_request_id uuid/uuid NULL",+ "14 status text/text NOT NULL DEFAULT 'pending'::text",+ "15 decided_at timestamp with time zone/timestamptz NULL",+ "16 decided_principal_kind text/text NULL",+ "17 decided_principal_id text/text NULL",+ "18 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "19 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"],"flags": "relkind=r rls=false force_rls=false"},@@ -3197,11 +3257,13 @@"facts.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.facts REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","facts.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.facts REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","facts.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.facts REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "facts.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.facts FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","links.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.links REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","links.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.links REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","links.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.links REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","minion_jobs.minion_queue_protocol": "CREATE TRIGGER minion_queue_protocol BEFORE INSERT OR UPDATE ON public.minion_jobs FOR EACH ROW EXECUTE FUNCTION enforce_minion_queue_protocol()","page_aliases.managed_writer_guard": "CREATE TRIGGER managed_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.page_aliases FOR EACH ROW EXECUTE FUNCTION gbrain_require_managed_writer()",+ "page_versions.page_versions_trust_snapshot": "CREATE TRIGGER page_versions_trust_snapshot BEFORE INSERT ON public.page_versions FOR EACH ROW EXECUTE FUNCTION gbrain_snapshot_version_trust()","page_versions.page_versions_write_attribution": "CREATE TRIGGER page_versions_write_attribution BEFORE INSERT ON public.page_versions FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_version_attribution()","pages.bump_page_generation_clock_trg": "CREATE TRIGGER bump_page_generation_clock_trg AFTER INSERT OR DELETE OR UPDATE ON public.pages FOR EACH STATEMENT EXECUTE FUNCTION bump_page_generation_clock_fn()","pages.bump_page_generation_trg": "CREATE TRIGGER bump_page_generation_trg BEFORE INSERT OR UPDATE ON public.pages FOR EACH ROW EXECUTE FUNCTION bump_page_generation_fn()",@@ -3214,6 +3276,7 @@"pages.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.pages REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","pages.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.pages REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","pages.trg_pages_search_vector": "CREATE TRIGGER trg_pages_search_vector BEFORE INSERT OR UPDATE OF title, timeline ON public.pages FOR EACH ROW EXECUTE FUNCTION update_page_search_vector()",+ "pages.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.pages FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","persistence_brain.gbrain_protocol_activation": "CREATE TRIGGER gbrain_protocol_activation BEFORE UPDATE ON public.persistence_brain FOR EACH ROW EXECUTE FUNCTION gbrain_guard_protocol_activation()","persistence_effects.gbrain_effect_protocol": "CREATE TRIGGER gbrain_effect_protocol BEFORE INSERT OR DELETE OR UPDATE ON public.persistence_effects FOR EACH ROW EXECUTE FUNCTION gbrain_guard_effect_protocol()","persistence_requests.gbrain_request_protocol": "CREATE TRIGGER gbrain_request_protocol BEFORE INSERT OR DELETE OR UPDATE ON public.persistence_requests FOR EACH ROW EXECUTE FUNCTION gbrain_guard_request_protocol()",@@ -3230,11 +3293,13 @@"takes.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.takes REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","takes.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.takes REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","takes.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.takes REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "takes.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.takes FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","timeline_entries.gbrain_write_attribution": "CREATE TRIGGER gbrain_write_attribution BEFORE INSERT OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_write_attribution()","timeline_entries.managed_writer_guard": "CREATE TRIGGER managed_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_require_managed_writer()","timeline_entries.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.timeline_entries REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","timeline_entries.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",- "timeline_entries.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()"+ "timeline_entries.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "timeline_entries.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()"},"viewColumns": {"page_links": [diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.jsonindex a69c264dff..15dd8cb247 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json@@ -1,6 +1,7 @@{"golden": {"constraints": {+ "access_tokens.access_tokens_min_trust_check": "c CHECK (((min_trust IS NULL) OR (min_trust = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","access_tokens.access_tokens_pkey": "p PRIMARY KEY (id)","access_tokens.access_tokens_source_grant_check": "c CHECK ((source_grant = ANY (ARRAY['default'::text, 'scalar'::text, 'federated'::text, 'none'::text])))","access_tokens.access_tokens_token_hash_key": "u UNIQUE (token_hash)",@@ -81,6 +82,7 @@"facts.facts_pkey": "p PRIMARY KEY (id)","facts.facts_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","facts.facts_superseded_by_fkey": "f FOREIGN KEY (superseded_by) REFERENCES facts(id) ON DELETE SET NULL",+ "facts.facts_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","facts.facts_visibility_check": "c CHECK ((visibility = ANY (ARRAY['private'::text, 'world'::text])))","files.files_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE SET NULL","files.files_pkey": "p PRIMARY KEY (id)",@@ -164,6 +166,7 @@"minion_self_fix_log.minion_self_fix_log_parent_id_fkey": "f FOREIGN KEY (parent_id) REFERENCES minion_jobs(id) ON DELETE SET NULL","minion_self_fix_log.minion_self_fix_log_pkey": "p PRIMARY KEY (id)","oauth_clients.oauth_clients_complete_agent_grant": "c CHECK (((NOT (COALESCE(scope, ''::text) ~ '(^|[[:space:]])agent([[:space:]]|$)'::text)) OR ((COALESCE(cardinality(bound_tools), 0) > 0) AND (source_id IS NOT NULL) AND (bound_source_id IS NOT NULL) AND (bound_source_id = source_id) AND COALESCE((source_id = ANY (federated_read)), false) AND (((delegated_namespace = 'job'::text) AND (delegated_slug_prefixes IS NULL)) OR ((delegated_namespace = 'prefixes'::text) AND (COALESCE(cardinality(delegated_slug_prefixes), 0) > 0))) AND (bound_max_concurrent > 0))))",+ "oauth_clients.oauth_clients_min_trust_check": "c CHECK (((min_trust IS NULL) OR (min_trust = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","oauth_clients.oauth_clients_pkey": "p PRIMARY KEY (client_id)","oauth_clients.oauth_clients_source_grant_check": "c CHECK ((source_grant = 'none'::text))","oauth_clients.oauth_clients_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE RESTRICT",@@ -198,12 +201,14 @@"page_projection_jobs.page_projection_jobs_source_incarnation_fkey": "f FOREIGN KEY (source_incarnation) REFERENCES sources(incarnation) ON DELETE CASCADE","page_versions.page_versions_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE","page_versions.page_versions_pkey": "p PRIMARY KEY (id)",+ "page_versions.page_versions_trust_tier_check": "c CHECK (((trust_tier IS NULL) OR (trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","page_write_guards.page_write_guards_pkey": "p PRIMARY KEY (source_incarnation, slug)","page_write_guards.page_write_guards_source_incarnation_fkey": "f FOREIGN KEY (source_incarnation) REFERENCES sources(incarnation) ON DELETE CASCADE","pages.pages_page_kind_check": "c CHECK ((page_kind = ANY (ARRAY['markdown'::text, 'code'::text, 'image'::text])))","pages.pages_pkey": "p PRIMARY KEY (id)","pages.pages_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","pages.pages_source_slug_key": "u UNIQUE (source_id, slug)",+ "pages.pages_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","persistence_brain.persistence_brain_pkey": "p PRIMARY KEY (singleton)","persistence_brain.persistence_brain_singleton_check": "c CHECK ((singleton = 1))","persistence_brain.persistence_brain_writer_protocol_floor_check": "c CHECK ((writer_protocol_floor = ANY (ARRAY[1, 2])))",@@ -349,6 +354,7 @@"takes.takes_pkey": "p PRIMARY KEY (id)","takes.takes_resolution_consistency": "c CHECK ((((resolved_quality IS NULL) AND (resolved_outcome IS NULL)) OR ((resolved_quality = 'correct'::text) AND (resolved_outcome = true)) OR ((resolved_quality = 'incorrect'::text) AND (resolved_outcome = false)) OR ((resolved_quality = 'partial'::text) AND (resolved_outcome IS NULL)) OR ((resolved_quality = 'unresolvable'::text) AND (resolved_outcome IS NULL))))","takes.takes_resolved_quality_values": "c CHECK (((resolved_quality IS NULL) OR (resolved_quality = ANY (ARRAY['correct'::text, 'incorrect'::text, 'partial'::text, 'unresolvable'::text]))))",+ "takes.takes_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","takes.takes_weight_check": "c CHECK (((weight >= (0)::double precision) AND (weight <= (1)::double precision)))","think_ab_results.think_ab_results_pkey": "p PRIMARY KEY (id)","think_ab_results.think_ab_results_preferred_check": "c CHECK ((preferred = ANY (ARRAY['baseline'::text, 'with_calibration'::text, 'neither'::text, 'tie'::text])))",@@ -356,6 +362,14 @@"timeline_entries.timeline_entries_event_page_id_fkey": "f FOREIGN KEY (event_page_id) REFERENCES pages(id) ON DELETE CASCADE","timeline_entries.timeline_entries_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE","timeline_entries.timeline_entries_pkey": "p PRIMARY KEY (id)",+ "timeline_entries.timeline_entries_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))",+ "trust_proposals.trust_proposals_action_check": "c CHECK ((action = ANY (ARRAY['supersede_fact'::text, 'supersede_take'::text, 'forget'::text, 'lower_page'::text, 'confirm'::text])))",+ "trust_proposals.trust_proposals_check": "c CHECK (((related_table IS NULL) = (related_id IS NULL)))",+ "trust_proposals.trust_proposals_pkey": "p PRIMARY KEY (id)",+ "trust_proposals.trust_proposals_related_table_check": "c CHECK ((related_table = ANY (ARRAY['facts'::text, 'takes'::text, 'timeline_entries'::text, 'pages'::text])))",+ "trust_proposals.trust_proposals_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE",+ "trust_proposals.trust_proposals_status_check": "c CHECK ((status = ANY (ARRAY['pending'::text, 'accepted'::text, 'rejected'::text, 'undone'::text, 'superseded'::text])))",+ "trust_proposals.trust_proposals_target_table_check": "c CHECK ((target_table = ANY (ARRAY['facts'::text, 'takes'::text, 'timeline_entries'::text, 'pages'::text])))","wanted_links.wanted_links_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE","wanted_links.wanted_links_pkey": "p PRIMARY KEY (id)","wanted_links.wanted_links_producer_check": "c CHECK ((producer = ANY (ARRAY['body'::text, 'frontmatter'::text])))",@@ -387,9 +401,11 @@"gbrain_lease_shared_skill_delivery()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=5e493c1ac8dce8cb025a736629e563437c4b214744137c302c532c20bf7e7acf","gbrain_preserve_fact_withdrawal()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9beb118551a08451a228146373f50f2aa2ce0cfe89937e937d361b33224aa0aa","gbrain_queue_page_projection()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=6c544b9c129b6a17dcabeb5ee8d44a2b0e0af9d02ca3fe47c7d7f22ec313042c",- "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9dc91548479da39c77e3015481b89901ef13fb02ce496597606fbac592c05201",+ "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d444fd431abe188062c7266caa9ab41327336c916805d7dd02a362affe2f26a7","gbrain_require_persistence_protocol(required integer)": "RETURNS void kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=af07b7fac60dec0a4fe568217931ac449d32f73b3a53a047b3b02a5f59cb5058",+ "gbrain_snapshot_version_trust()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=7452350236ed4c68a6cd1f4d78a1381a4ef44cc70e8a032141f01bba4a704702","gbrain_stamp_revision_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d446ed1145d8bb9c93cb0ca4aa076a5dc7a5fe07b3e79518adaf1b17b0a51216",+ "gbrain_stamp_trust_tier()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=c3dbe0330bcdd42294891167e4d9cbec0902e8304ce26e934f0b124bd451bb94","gbrain_stamp_version_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=1b28a0e5769198d86490dc20b2aee80b7e6595670428a63ac9c6825cd2a35b10","gbrain_stamp_write_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=50e9b0e5bf37eeae6555dd16c8104cb0807be6c05a79e0c82237d45162c21dc2","update_chunk_search_vector()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e099e8a1d30bd74b7632b6055d3edffe753c00c00183e3bdac34d28d23347555",@@ -759,6 +775,9 @@"timeline_entries": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "trust_proposals": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"wanted_links": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"]@@ -1130,6 +1149,10 @@"think_ab_results_pkey": "CREATE UNIQUE INDEX think_ab_results_pkey ON public.think_ab_results USING btree (id)","think_ab_results_recent_idx": "CREATE INDEX think_ab_results_recent_idx ON public.think_ab_results USING btree (source_id, ran_at DESC)","timeline_entries_pkey": "CREATE UNIQUE INDEX timeline_entries_pkey ON public.timeline_entries USING btree (id)",+ "trust_proposals_pending_idx": "CREATE INDEX trust_proposals_pending_idx ON public.trust_proposals USING btree (source_id, created_at) WHERE (status = 'pending'::text)",+ "trust_proposals_pending_unique": "CREATE UNIQUE INDEX trust_proposals_pending_unique ON public.trust_proposals USING btree (action, target_table, target_id, COALESCE(related_table, ''::text), COALESCE(related_id, (0)::bigint)) WHERE (status = 'pending'::text)",+ "trust_proposals_pkey": "CREATE UNIQUE INDEX trust_proposals_pkey ON public.trust_proposals USING btree (id)",+ "trust_proposals_target_idx": "CREATE INDEX trust_proposals_target_idx ON public.trust_proposals USING btree (target_table, target_id)","uniq_minion_attachments_job_filename": "CREATE UNIQUE INDEX uniq_minion_attachments_job_filename ON public.minion_attachments USING btree (job_id, filename)","uniq_minion_jobs_idempotency": "CREATE UNIQUE INDEX uniq_minion_jobs_idempotency ON public.minion_jobs USING btree (idempotency_key) WHERE (idempotency_key IS NOT NULL)","uniq_subagent_messages_idx": "CREATE UNIQUE INDEX uniq_subagent_messages_idx ON public.subagent_messages USING btree (job_id, message_idx)",@@ -1195,6 +1218,7 @@"takes_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=takes.id","think_ab_results_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=think_ab_results.id","timeline_entries_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=timeline_entries.id",+ "trust_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=trust_proposals.id","wanted_links_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=wanted_links.id"},"tables": {@@ -1213,7 +1237,8 @@"11 federated_read ARRAY/_text NULL","12 allowed_operations ARRAY/_text NULL","13 takes_holders ARRAY/_text NULL",- "14 grant_revision integer/int4 NOT NULL DEFAULT 0"+ "14 grant_revision integer/int4 NOT NULL DEFAULT 0",+ "15 min_trust text/text NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -1844,7 +1869,9 @@"38 last_write_principal_kind text/text NULL","39 last_write_principal_id text/text NULL","40 last_written_at timestamp with time zone/timestamptz NULL",- "41 attributed_to text/text NULL"+ "41 attributed_to text/text NULL",+ "42 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "43 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -2219,7 +2246,8 @@"27 grant_repair_reasons ARRAY/_text NOT NULL DEFAULT '{}'::text[]","28 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()","29 source_grant text/text NULL",- "30 takes_holders ARRAY/_text NULL"+ "30 takes_holders ARRAY/_text NULL",+ "31 min_trust text/text NULL"],"flags": "relkind=r rls=true force_rls=false"},@@ -2381,7 +2409,9 @@"15 write_principal_id text/text NULL","16 archived_write_request_id uuid/uuid NULL","17 archived_principal_kind text/text NULL",- "18 archived_principal_id text/text NULL"+ "18 archived_principal_id text/text NULL",+ "19 trust_tier text/text NULL",+ "20 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -2433,7 +2463,9 @@"37 links_attendance_blocked_at timestamp with time zone/timestamptz NULL","38 revision_write_request_id uuid/uuid NULL","39 revision_principal_kind text/text NULL",- "40 revision_principal_id text/text NULL"+ "40 revision_principal_id text/text NULL",+ "41 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "42 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -3130,7 +3162,9 @@"29 last_write_request_id uuid/uuid NULL","30 last_write_principal_kind text/text NULL","31 last_write_principal_id text/text NULL",- "32 last_written_at timestamp with time zone/timestamptz NULL"+ "32 last_written_at timestamp with time zone/timestamptz NULL",+ "33 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "34 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -3165,7 +3199,33 @@"12 last_write_request_id uuid/uuid NULL","13 last_write_principal_kind text/text NULL","14 last_write_principal_id text/text NULL",- "15 last_written_at timestamp with time zone/timestamptz NULL"+ "15 last_written_at timestamp with time zone/timestamptz NULL",+ "16 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "17 write_origin jsonb/jsonb NULL"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },+ "trust_proposals": {+ "columns": [+ "1 id bigint/int8 NOT NULL DEFAULT nextval('trust_proposals_id_seq'::regclass)",+ "2 action text/text NOT NULL",+ "3 source_id text/text NOT NULL",+ "4 target_table text/text NOT NULL",+ "5 target_id bigint/int8 NOT NULL",+ "6 related_table text/text NULL",+ "7 related_id bigint/int8 NULL",+ "8 before_state jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "9 after_state jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "10 proposer text/text NOT NULL",+ "11 proposer_principal_kind text/text NULL",+ "12 proposer_principal_id text/text NULL",+ "13 write_request_id uuid/uuid NULL",+ "14 status text/text NOT NULL DEFAULT 'pending'::text",+ "15 decided_at timestamp with time zone/timestamptz NULL",+ "16 decided_principal_kind text/text NULL",+ "17 decided_principal_id text/text NULL",+ "18 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "19 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"],"flags": "relkind=r rls=false force_rls=false"},@@ -3197,11 +3257,13 @@"facts.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.facts REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","facts.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.facts REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","facts.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.facts REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "facts.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.facts FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","links.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.links REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","links.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.links REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","links.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.links REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","minion_jobs.minion_queue_protocol": "CREATE TRIGGER minion_queue_protocol BEFORE INSERT OR UPDATE ON public.minion_jobs FOR EACH ROW EXECUTE FUNCTION enforce_minion_queue_protocol()","page_aliases.managed_writer_guard": "CREATE TRIGGER managed_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.page_aliases FOR EACH ROW EXECUTE FUNCTION gbrain_require_managed_writer()",+ "page_versions.page_versions_trust_snapshot": "CREATE TRIGGER page_versions_trust_snapshot BEFORE INSERT ON public.page_versions FOR EACH ROW EXECUTE FUNCTION gbrain_snapshot_version_trust()","page_versions.page_versions_write_attribution": "CREATE TRIGGER page_versions_write_attribution BEFORE INSERT ON public.page_versions FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_version_attribution()","pages.bump_page_generation_clock_trg": "CREATE TRIGGER bump_page_generation_clock_trg AFTER INSERT OR DELETE OR UPDATE ON public.pages FOR EACH STATEMENT EXECUTE FUNCTION bump_page_generation_clock_fn()","pages.bump_page_generation_trg": "CREATE TRIGGER bump_page_generation_trg BEFORE INSERT OR UPDATE ON public.pages FOR EACH ROW EXECUTE FUNCTION bump_page_generation_fn()",@@ -3214,6 +3276,7 @@"pages.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.pages REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","pages.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.pages REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","pages.trg_pages_search_vector": "CREATE TRIGGER trg_pages_search_vector BEFORE INSERT OR UPDATE OF title, timeline ON public.pages FOR EACH ROW EXECUTE FUNCTION update_page_search_vector()",+ "pages.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.pages FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","persistence_brain.gbrain_protocol_activation": "CREATE TRIGGER gbrain_protocol_activation BEFORE UPDATE ON public.persistence_brain FOR EACH ROW EXECUTE FUNCTION gbrain_guard_protocol_activation()","persistence_effects.gbrain_effect_protocol": "CREATE TRIGGER gbrain_effect_protocol BEFORE INSERT OR DELETE OR UPDATE ON public.persistence_effects FOR EACH ROW EXECUTE FUNCTION gbrain_guard_effect_protocol()","persistence_requests.gbrain_request_protocol": "CREATE TRIGGER gbrain_request_protocol BEFORE INSERT OR DELETE OR UPDATE ON public.persistence_requests FOR EACH ROW EXECUTE FUNCTION gbrain_guard_request_protocol()",@@ -3230,11 +3293,13 @@"takes.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.takes REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","takes.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.takes REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","takes.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.takes REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "takes.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.takes FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","timeline_entries.gbrain_write_attribution": "CREATE TRIGGER gbrain_write_attribution BEFORE INSERT OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_write_attribution()","timeline_entries.managed_writer_guard": "CREATE TRIGGER managed_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_require_managed_writer()","timeline_entries.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.timeline_entries REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","timeline_entries.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",- "timeline_entries.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()"+ "timeline_entries.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "timeline_entries.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()"},"viewColumns": {"page_links": [diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.jsonindex a2c8c94fb9..7942a74b07 100644--- a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json+++ b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json@@ -1,6 +1,7 @@{"golden": {"constraints": {+ "access_tokens.access_tokens_min_trust_check": "c CHECK (((min_trust IS NULL) OR (min_trust = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","access_tokens.access_tokens_pkey": "p PRIMARY KEY (id)","access_tokens.access_tokens_source_grant_check": "c CHECK ((source_grant = ANY (ARRAY['default'::text, 'scalar'::text, 'federated'::text, 'none'::text])))","access_tokens.access_tokens_token_hash_key": "u UNIQUE (token_hash)",@@ -81,6 +82,7 @@"facts.facts_pkey": "p PRIMARY KEY (id)","facts.facts_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","facts.facts_superseded_by_fkey": "f FOREIGN KEY (superseded_by) REFERENCES facts(id) ON DELETE SET NULL",+ "facts.facts_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","facts.facts_visibility_check": "c CHECK ((visibility = ANY (ARRAY['private'::text, 'world'::text])))","files.files_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE SET NULL","files.files_pkey": "p PRIMARY KEY (id)",@@ -164,6 +166,7 @@"minion_self_fix_log.minion_self_fix_log_parent_id_fkey": "f FOREIGN KEY (parent_id) REFERENCES minion_jobs(id) ON DELETE SET NULL","minion_self_fix_log.minion_self_fix_log_pkey": "p PRIMARY KEY (id)","oauth_clients.oauth_clients_complete_agent_grant": "c CHECK (((NOT (COALESCE(scope, ''::text) ~ '(^|[[:space:]])agent([[:space:]]|$)'::text)) OR ((COALESCE(cardinality(bound_tools), 0) > 0) AND (source_id IS NOT NULL) AND (bound_source_id IS NOT NULL) AND (bound_source_id = source_id) AND COALESCE((source_id = ANY (federated_read)), false) AND (((delegated_namespace = 'job'::text) AND (delegated_slug_prefixes IS NULL)) OR ((delegated_namespace = 'prefixes'::text) AND (COALESCE(cardinality(delegated_slug_prefixes), 0) > 0))) AND (bound_max_concurrent > 0))))",+ "oauth_clients.oauth_clients_min_trust_check": "c CHECK (((min_trust IS NULL) OR (min_trust = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","oauth_clients.oauth_clients_pkey": "p PRIMARY KEY (client_id)","oauth_clients.oauth_clients_source_grant_check": "c CHECK ((source_grant = 'none'::text))","oauth_clients.oauth_clients_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE RESTRICT",@@ -198,12 +201,14 @@"page_projection_jobs.page_projection_jobs_source_incarnation_fkey": "f FOREIGN KEY (source_incarnation) REFERENCES sources(incarnation) ON DELETE CASCADE","page_versions.page_versions_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE","page_versions.page_versions_pkey": "p PRIMARY KEY (id)",+ "page_versions.page_versions_trust_tier_check": "c CHECK (((trust_tier IS NULL) OR (trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","page_write_guards.page_write_guards_pkey": "p PRIMARY KEY (source_incarnation, slug)","page_write_guards.page_write_guards_source_incarnation_fkey": "f FOREIGN KEY (source_incarnation) REFERENCES sources(incarnation) ON DELETE CASCADE","pages.pages_page_kind_check": "c CHECK ((page_kind = ANY (ARRAY['markdown'::text, 'code'::text, 'image'::text])))","pages.pages_pkey": "p PRIMARY KEY (id)","pages.pages_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","pages.pages_source_slug_key": "u UNIQUE (source_id, slug)",+ "pages.pages_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","persistence_brain.persistence_brain_pkey": "p PRIMARY KEY (singleton)","persistence_brain.persistence_brain_singleton_check": "c CHECK ((singleton = 1))","persistence_brain.persistence_brain_writer_protocol_floor_check": "c CHECK ((writer_protocol_floor = ANY (ARRAY[1, 2])))",@@ -349,6 +354,7 @@"takes.takes_pkey": "p PRIMARY KEY (id)","takes.takes_resolution_consistency": "c CHECK ((((resolved_quality IS NULL) AND (resolved_outcome IS NULL)) OR ((resolved_quality = 'correct'::text) AND (resolved_outcome = true)) OR ((resolved_quality = 'incorrect'::text) AND (resolved_outcome = false)) OR ((resolved_quality = 'partial'::text) AND (resolved_outcome IS NULL)) OR ((resolved_quality = 'unresolvable'::text) AND (resolved_outcome IS NULL))))","takes.takes_resolved_quality_values": "c CHECK (((resolved_quality IS NULL) OR (resolved_quality = ANY (ARRAY['correct'::text, 'incorrect'::text, 'partial'::text, 'unresolvable'::text]))))",+ "takes.takes_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","takes.takes_weight_check": "c CHECK (((weight >= (0)::double precision) AND (weight <= (1)::double precision)))","think_ab_results.think_ab_results_pkey": "p PRIMARY KEY (id)","think_ab_results.think_ab_results_preferred_check": "c CHECK ((preferred = ANY (ARRAY['baseline'::text, 'with_calibration'::text, 'neither'::text, 'tie'::text])))",@@ -356,6 +362,14 @@"timeline_entries.timeline_entries_event_page_id_fkey": "f FOREIGN KEY (event_page_id) REFERENCES pages(id) ON DELETE CASCADE","timeline_entries.timeline_entries_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE","timeline_entries.timeline_entries_pkey": "p PRIMARY KEY (id)",+ "timeline_entries.timeline_entries_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))",+ "trust_proposals.trust_proposals_action_check": "c CHECK ((action = ANY (ARRAY['supersede_fact'::text, 'supersede_take'::text, 'forget'::text, 'lower_page'::text, 'confirm'::text])))",+ "trust_proposals.trust_proposals_check": "c CHECK (((related_table IS NULL) = (related_id IS NULL)))",+ "trust_proposals.trust_proposals_pkey": "p PRIMARY KEY (id)",+ "trust_proposals.trust_proposals_related_table_check": "c CHECK ((related_table = ANY (ARRAY['facts'::text, 'takes'::text, 'timeline_entries'::text, 'pages'::text])))",+ "trust_proposals.trust_proposals_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE",+ "trust_proposals.trust_proposals_status_check": "c CHECK ((status = ANY (ARRAY['pending'::text, 'accepted'::text, 'rejected'::text, 'undone'::text, 'superseded'::text])))",+ "trust_proposals.trust_proposals_target_table_check": "c CHECK ((target_table = ANY (ARRAY['facts'::text, 'takes'::text, 'timeline_entries'::text, 'pages'::text])))","wanted_links.wanted_links_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE","wanted_links.wanted_links_pkey": "p PRIMARY KEY (id)","wanted_links.wanted_links_producer_check": "c CHECK ((producer = ANY (ARRAY['body'::text, 'frontmatter'::text])))",@@ -387,9 +401,11 @@"gbrain_lease_shared_skill_delivery()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=5e493c1ac8dce8cb025a736629e563437c4b214744137c302c532c20bf7e7acf","gbrain_preserve_fact_withdrawal()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9beb118551a08451a228146373f50f2aa2ce0cfe89937e937d361b33224aa0aa","gbrain_queue_page_projection()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=6c544b9c129b6a17dcabeb5ee8d44a2b0e0af9d02ca3fe47c7d7f22ec313042c",- "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9dc91548479da39c77e3015481b89901ef13fb02ce496597606fbac592c05201",+ "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d444fd431abe188062c7266caa9ab41327336c916805d7dd02a362affe2f26a7","gbrain_require_persistence_protocol(required integer)": "RETURNS void kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=af07b7fac60dec0a4fe568217931ac449d32f73b3a53a047b3b02a5f59cb5058",+ "gbrain_snapshot_version_trust()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=7452350236ed4c68a6cd1f4d78a1381a4ef44cc70e8a032141f01bba4a704702","gbrain_stamp_revision_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d446ed1145d8bb9c93cb0ca4aa076a5dc7a5fe07b3e79518adaf1b17b0a51216",+ "gbrain_stamp_trust_tier()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=c3dbe0330bcdd42294891167e4d9cbec0902e8304ce26e934f0b124bd451bb94","gbrain_stamp_version_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=1b28a0e5769198d86490dc20b2aee80b7e6595670428a63ac9c6825cd2a35b10","gbrain_stamp_write_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=50e9b0e5bf37eeae6555dd16c8104cb0807be6c05a79e0c82237d45162c21dc2","update_chunk_search_vector()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e12c37d5489202aaf708560db42e6c0c7c8886d198d412e1c5d915c3ae782559",@@ -759,6 +775,9 @@"timeline_entries": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "trust_proposals": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"wanted_links": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"]@@ -1126,6 +1145,10 @@"think_ab_results_pkey": "CREATE UNIQUE INDEX think_ab_results_pkey ON public.think_ab_results USING btree (id)","think_ab_results_recent_idx": "CREATE INDEX think_ab_results_recent_idx ON public.think_ab_results USING btree (source_id, ran_at DESC)","timeline_entries_pkey": "CREATE UNIQUE INDEX timeline_entries_pkey ON public.timeline_entries USING btree (id)",+ "trust_proposals_pending_idx": "CREATE INDEX trust_proposals_pending_idx ON public.trust_proposals USING btree (source_id, created_at) WHERE (status = 'pending'::text)",+ "trust_proposals_pending_unique": "CREATE UNIQUE INDEX trust_proposals_pending_unique ON public.trust_proposals USING btree (action, target_table, target_id, COALESCE(related_table, ''::text), COALESCE(related_id, (0)::bigint)) WHERE (status = 'pending'::text)",+ "trust_proposals_pkey": "CREATE UNIQUE INDEX trust_proposals_pkey ON public.trust_proposals USING btree (id)",+ "trust_proposals_target_idx": "CREATE INDEX trust_proposals_target_idx ON public.trust_proposals USING btree (target_table, target_id)","uniq_minion_attachments_job_filename": "CREATE UNIQUE INDEX uniq_minion_attachments_job_filename ON public.minion_attachments USING btree (job_id, filename)","uniq_minion_jobs_idempotency": "CREATE UNIQUE INDEX uniq_minion_jobs_idempotency ON public.minion_jobs USING btree (idempotency_key) WHERE (idempotency_key IS NOT NULL)","uniq_subagent_messages_idx": "CREATE UNIQUE INDEX uniq_subagent_messages_idx ON public.subagent_messages USING btree (job_id, message_idx)",@@ -1191,6 +1214,7 @@"takes_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=takes.id","think_ab_results_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=think_ab_results.id","timeline_entries_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=timeline_entries.id",+ "trust_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=trust_proposals.id","wanted_links_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=wanted_links.id"},"tables": {@@ -1209,7 +1233,8 @@"11 federated_read ARRAY/_text NULL","12 allowed_operations ARRAY/_text NULL","13 takes_holders ARRAY/_text NULL",- "14 grant_revision integer/int4 NOT NULL DEFAULT 0"+ "14 grant_revision integer/int4 NOT NULL DEFAULT 0",+ "15 min_trust text/text NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -1840,7 +1865,9 @@"38 last_write_principal_kind text/text NULL","39 last_write_principal_id text/text NULL","40 last_written_at timestamp with time zone/timestamptz NULL",- "41 attributed_to text/text NULL"+ "41 attributed_to text/text NULL",+ "42 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "43 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -2215,7 +2242,8 @@"27 grant_repair_reasons ARRAY/_text NOT NULL DEFAULT '{}'::text[]","28 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()","29 source_grant text/text NULL",- "30 takes_holders ARRAY/_text NULL"+ "30 takes_holders ARRAY/_text NULL",+ "31 min_trust text/text NULL"],"flags": "relkind=r rls=true force_rls=false"},@@ -2377,7 +2405,9 @@"15 write_principal_id text/text NULL","16 archived_write_request_id uuid/uuid NULL","17 archived_principal_kind text/text NULL",- "18 archived_principal_id text/text NULL"+ "18 archived_principal_id text/text NULL",+ "19 trust_tier text/text NULL",+ "20 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -2429,7 +2459,9 @@"37 links_attendance_blocked_at timestamp with time zone/timestamptz NULL","38 revision_write_request_id uuid/uuid NULL","39 revision_principal_kind text/text NULL",- "40 revision_principal_id text/text NULL"+ "40 revision_principal_id text/text NULL",+ "41 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "42 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -3126,7 +3158,9 @@"30 last_write_request_id uuid/uuid NULL","31 last_write_principal_kind text/text NULL","32 last_write_principal_id text/text NULL",- "33 last_written_at timestamp with time zone/timestamptz NULL"+ "33 last_written_at timestamp with time zone/timestamptz NULL",+ "34 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "35 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -3161,7 +3195,33 @@"12 last_write_request_id uuid/uuid NULL","13 last_write_principal_kind text/text NULL","14 last_write_principal_id text/text NULL",- "15 last_written_at timestamp with time zone/timestamptz NULL"+ "15 last_written_at timestamp with time zone/timestamptz NULL",+ "16 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "17 write_origin jsonb/jsonb NULL"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },+ "trust_proposals": {+ "columns": [+ "1 id bigint/int8 NOT NULL DEFAULT nextval('trust_proposals_id_seq'::regclass)",+ "2 action text/text NOT NULL",+ "3 source_id text/text NOT NULL",+ "4 target_table text/text NOT NULL",+ "5 target_id bigint/int8 NOT NULL",+ "6 related_table text/text NULL",+ "7 related_id bigint/int8 NULL",+ "8 before_state jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "9 after_state jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "10 proposer text/text NOT NULL",+ "11 proposer_principal_kind text/text NULL",+ "12 proposer_principal_id text/text NULL",+ "13 write_request_id uuid/uuid NULL",+ "14 status text/text NOT NULL DEFAULT 'pending'::text",+ "15 decided_at timestamp with time zone/timestamptz NULL",+ "16 decided_principal_kind text/text NULL",+ "17 decided_principal_id text/text NULL",+ "18 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "19 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"],"flags": "relkind=r rls=false force_rls=false"},@@ -3193,11 +3253,13 @@"facts.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.facts REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","facts.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.facts REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","facts.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.facts REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "facts.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.facts FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","links.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.links REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","links.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.links REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","links.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.links REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","minion_jobs.minion_queue_protocol": "CREATE TRIGGER minion_queue_protocol BEFORE INSERT OR UPDATE ON public.minion_jobs FOR EACH ROW EXECUTE FUNCTION enforce_minion_queue_protocol()","page_aliases.managed_writer_guard": "CREATE TRIGGER managed_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.page_aliases FOR EACH ROW EXECUTE FUNCTION gbrain_require_managed_writer()",+ "page_versions.page_versions_trust_snapshot": "CREATE TRIGGER page_versions_trust_snapshot BEFORE INSERT ON public.page_versions FOR EACH ROW EXECUTE FUNCTION gbrain_snapshot_version_trust()","page_versions.page_versions_write_attribution": "CREATE TRIGGER page_versions_write_attribution BEFORE INSERT ON public.page_versions FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_version_attribution()","pages.bump_page_generation_clock_trg": "CREATE TRIGGER bump_page_generation_clock_trg AFTER INSERT OR DELETE OR UPDATE ON public.pages FOR EACH STATEMENT EXECUTE FUNCTION bump_page_generation_clock_fn()","pages.bump_page_generation_trg": "CREATE TRIGGER bump_page_generation_trg BEFORE INSERT OR UPDATE ON public.pages FOR EACH ROW EXECUTE FUNCTION bump_page_generation_fn()",@@ -3210,6 +3272,7 @@"pages.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.pages REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","pages.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.pages REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","pages.trg_pages_search_vector": "CREATE TRIGGER trg_pages_search_vector BEFORE INSERT OR UPDATE OF title, timeline ON public.pages FOR EACH ROW EXECUTE FUNCTION update_page_search_vector()",+ "pages.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.pages FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","persistence_brain.gbrain_protocol_activation": "CREATE TRIGGER gbrain_protocol_activation BEFORE UPDATE ON public.persistence_brain FOR EACH ROW EXECUTE FUNCTION gbrain_guard_protocol_activation()","persistence_effects.gbrain_effect_protocol": "CREATE TRIGGER gbrain_effect_protocol BEFORE INSERT OR DELETE OR UPDATE ON public.persistence_effects FOR EACH ROW EXECUTE FUNCTION gbrain_guard_effect_protocol()","persistence_requests.gbrain_request_protocol": "CREATE TRIGGER gbrain_request_protocol BEFORE INSERT OR DELETE OR UPDATE ON public.persistence_requests FOR EACH ROW EXECUTE FUNCTION gbrain_guard_request_protocol()",@@ -3226,11 +3289,13 @@"takes.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.takes REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","takes.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.takes REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","takes.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.takes REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "takes.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.takes FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","timeline_entries.gbrain_write_attribution": "CREATE TRIGGER gbrain_write_attribution BEFORE INSERT OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_write_attribution()","timeline_entries.managed_writer_guard": "CREATE TRIGGER managed_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_require_managed_writer()","timeline_entries.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.timeline_entries REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","timeline_entries.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",- "timeline_entries.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()"+ "timeline_entries.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "timeline_entries.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()"},"viewColumns": {"page_links": [diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-default.json b/test/fixtures/goldens/catalog/pglite-schema-blob-default.jsonindex fa606b9089..2eb08b97e2 100644--- a/test/fixtures/goldens/catalog/pglite-schema-blob-default.json+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-default.json@@ -297,7 +297,7 @@"gbrain_guard_skill_publication()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e854c0d058e75a65c3a90127c5c417380975100e83fc34288f6085e786df10a9","gbrain_lease_shared_skill_delivery()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=5e493c1ac8dce8cb025a736629e563437c4b214744137c302c532c20bf7e7acf","gbrain_queue_page_projection()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=6c544b9c129b6a17dcabeb5ee8d44a2b0e0af9d02ca3fe47c7d7f22ec313042c",- "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9dc91548479da39c77e3015481b89901ef13fb02ce496597606fbac592c05201",+ "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d444fd431abe188062c7266caa9ab41327336c916805d7dd02a362affe2f26a7","gbrain_require_persistence_protocol(required integer)": "RETURNS void kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=af07b7fac60dec0a4fe568217931ac449d32f73b3a53a047b3b02a5f59cb5058","update_page_search_vector()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=8e2e253471f22c3e70b2fa2e67ba9162ee3d2c764d175cb5b674db2b907d1e9d"},diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.jsonindex 6704135f17..7199ebaefe 100644--- a/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-fts-portuguese.json@@ -297,7 +297,7 @@"gbrain_guard_skill_publication()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e854c0d058e75a65c3a90127c5c417380975100e83fc34288f6085e786df10a9","gbrain_lease_shared_skill_delivery()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=5e493c1ac8dce8cb025a736629e563437c4b214744137c302c532c20bf7e7acf","gbrain_queue_page_projection()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=6c544b9c129b6a17dcabeb5ee8d44a2b0e0af9d02ca3fe47c7d7f22ec313042c",- "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9dc91548479da39c77e3015481b89901ef13fb02ce496597606fbac592c05201",+ "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d444fd431abe188062c7266caa9ab41327336c916805d7dd02a362affe2f26a7","gbrain_require_persistence_protocol(required integer)": "RETURNS void kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=af07b7fac60dec0a4fe568217931ac449d32f73b3a53a047b3b02a5f59cb5058","update_page_search_vector()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=3d98cc6ce4387bd742c1588ddc2133d036c7c5c8c64f7d33d1909c9ae44e73a6"},diff --git a/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json b/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.jsonindex c0c3934a06..cff3e33488 100644--- a/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json+++ b/test/fixtures/goldens/catalog/pglite-schema-blob-high-dims.json@@ -297,7 +297,7 @@"gbrain_guard_skill_publication()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e854c0d058e75a65c3a90127c5c417380975100e83fc34288f6085e786df10a9","gbrain_lease_shared_skill_delivery()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=5e493c1ac8dce8cb025a736629e563437c4b214744137c302c532c20bf7e7acf","gbrain_queue_page_projection()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=6c544b9c129b6a17dcabeb5ee8d44a2b0e0af9d02ca3fe47c7d7f22ec313042c",- "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9dc91548479da39c77e3015481b89901ef13fb02ce496597606fbac592c05201",+ "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d444fd431abe188062c7266caa9ab41327336c916805d7dd02a362affe2f26a7","gbrain_require_persistence_protocol(required integer)": "RETURNS void kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=af07b7fac60dec0a4fe568217931ac449d32f73b3a53a047b3b02a5f59cb5058","update_page_search_vector()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=8e2e253471f22c3e70b2fa2e67ba9162ee3d2c764d175cb5b674db2b907d1e9d"},diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.jsonindex 3d3d2867e2..3fcab3bc31 100644--- a/test/fixtures/goldens/migrations/records.json+++ b/test/fixtures/goldens/migrations/records.json@@ -1,11 +1,21 @@{"golden": {- "count": 214,+ "count": 215,"gaps": [17,18,19,- 100+ 100,+ 220,+ 221,+ 222,+ 223,+ 224,+ 225,+ 226,+ 227,+ 228,+ 229],"helpers": {"ALIAS_TABLES": "cddd37c636af42d862c08ca7754a57dfe9d12576b769fa8f74a5f02c803f67a0",@@ -36,7 +46,7 @@"sqlQueryForEngine": "71fb1ccec1b22cdc1662876dbd8c17ed81e9ab83485c6965cdf5caa4fc4a4ab5","verifyProjectionStatistics": "59d9ccfea1c53384d8607874a51209a9c2dfd51b2b85a2cb6269fa4120faf1f3"},- "latest": 219,+ "latest": 230,"records": [{"handler": {@@ -2230,8 +2240,8 @@"idempotent": true,"name": "durable_concurrent_persistence","sql": {- "length": 10185,- "sha256": "5c29e2ba0eed52dbab814e8bb2e99eda48c9ccd26f4d97f2274adc5c1712a8b7"+ "length": 10481,+ "sha256": "b8b1d396e74ec20db357eec5d2937d28d22530f3b47ad261e1ae1681b81a7d1e"},"sqlFor": "absent","transaction": "absent",@@ -2295,8 +2305,8 @@"idempotent": true,"name": "managed_alias_and_source_checkpoint_guards","sql": {- "length": 5336,- "sha256": "0791cfc72706a9fad3c32e54842d1aa1238a57172425e552134517421223c675"+ "length": 5632,+ "sha256": "7cdd67f6734a0f3963b243420d4c0097700d756339e86b36dd8a19a39a20b0b2"},"sqlFor": "absent","transaction": "absent",@@ -2454,8 +2464,8 @@"idempotent": true,"name": "fact_embedding_identity","sql": {- "length": 5481,- "sha256": "a9418ca9a8c10990b77eddc16e2e38eee1ba77d53e802936247c94eccadacff7"+ "length": 5777,+ "sha256": "9b2ba4919832da41e48e8688bb31c24ea2d27197b9143cde1077b7701621ea40"},"sqlFor": "absent","transaction": "absent",@@ -2853,8 +2863,8 @@"idempotent": true,"name": "take_embedding_identity","sql": {- "length": 5481,- "sha256": "98409b6776bdc98d65db3bff2afce7adb9ecb34bab5ddf8bd364e528ee4f4eea"+ "length": 5777,+ "sha256": "f859485119a29379245109e95303a7de53584c023633f38d0287804138b00282"},"sqlFor": "absent","transaction": "absent",@@ -2866,8 +2876,8 @@"idempotent": true,"name": "f1_write_attribution","sql": {- "length": 14327,- "sha256": "b33d4cab4dd9f1bed8e7847e800b632c7c6b1ac800c19ddf12d176f83b8b0cd0"+ "length": 14623,+ "sha256": "ad09591c350cddb3d863c3d36c8b6784b41dafc526cf9eb3023504eec7f8e1c6"},"sqlFor": "absent","transaction": "absent",@@ -2924,8 +2934,8 @@"idempotent": true,"name": "managed_guard_null_source_fallback","sql": {- "length": 4838,- "sha256": "d42aecea4f34cc10bdc8201268a284c353d71e389d423c4891a4953a26eaf3c0"+ "length": 5134,+ "sha256": "6d014f2104fe4f938d470329a75320f13a1a0153f21076f315ba6c85e6f84d04"},"sqlFor": "absent","transaction": "absent",@@ -2937,8 +2947,8 @@"idempotent": true,"name": "publication_failure_detail","sql": {- "length": 4929,- "sha256": "7eed76362cdf4a94019b53229c4fa56c88be9aea371db497d6614ea5eba3cd7a"+ "length": 5225,+ "sha256": "8e6bd0354bd0334b1dd3fb443c1a92d3e1397ffbf3162c4eea6dbd03fbf12da3"},"sqlFor": "absent","transaction": "absent",@@ -3254,6 +3264,19 @@"transaction": false,"verify": "absent","version": 219+ },+ {+ "handler": "absent",+ "idempotent": true,+ "name": "trust_tiers",+ "sql": {+ "length": 20422,+ "sha256": "b3e7750c08d970c587250a270434dc4e2ac54e3568240b58b9ecc2c4d0168cd9"+ },+ "sqlFor": "absent",+ "transaction": "absent",+ "verify": "absent",+ "version": 230}],"versions": [@@ -3470,7 +3493,8 @@216,217,218,- 219+ 219,+ 230]},"normalizer": "migrations-record-v1"diff --git a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.jsonindex dbdc20143b..7859c4a7e7 100644--- a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json+++ b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json@@ -1,6 +1,7 @@{"golden": {"constraints": {+ "access_tokens.access_tokens_min_trust_check": "c CHECK (((min_trust IS NULL) OR (min_trust = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","access_tokens.access_tokens_pkey": "p PRIMARY KEY (id)","access_tokens.access_tokens_source_grant_check": "c CHECK ((source_grant = ANY (ARRAY['default'::text, 'scalar'::text, 'federated'::text, 'none'::text])))","access_tokens.access_tokens_token_hash_key": "u UNIQUE (token_hash)",@@ -81,6 +82,7 @@"facts.facts_pkey": "p PRIMARY KEY (id)","facts.facts_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","facts.facts_superseded_by_fkey": "f FOREIGN KEY (superseded_by) REFERENCES facts(id) ON DELETE SET NULL",+ "facts.facts_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","facts.facts_visibility_check": "c CHECK ((visibility = ANY (ARRAY['private'::text, 'world'::text])))","files.files_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE SET NULL","files.files_pkey": "p PRIMARY KEY (id)",@@ -164,6 +166,7 @@"minion_self_fix_log.minion_self_fix_log_parent_id_fkey": "f FOREIGN KEY (parent_id) REFERENCES minion_jobs(id) ON DELETE SET NULL","minion_self_fix_log.minion_self_fix_log_pkey": "p PRIMARY KEY (id)","oauth_clients.oauth_clients_complete_agent_grant": "c CHECK (((NOT (COALESCE(scope, ''::text) ~ '(^|[[:space:]])agent([[:space:]]|$)'::text)) OR ((COALESCE(cardinality(bound_tools), 0) > 0) AND (source_id IS NOT NULL) AND (bound_source_id IS NOT NULL) AND (bound_source_id = source_id) AND COALESCE((source_id = ANY (federated_read)), false) AND (((delegated_namespace = 'job'::text) AND (delegated_slug_prefixes IS NULL)) OR ((delegated_namespace = 'prefixes'::text) AND (COALESCE(cardinality(delegated_slug_prefixes), 0) > 0))) AND (bound_max_concurrent > 0))))",+ "oauth_clients.oauth_clients_min_trust_check": "c CHECK (((min_trust IS NULL) OR (min_trust = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","oauth_clients.oauth_clients_pkey": "p PRIMARY KEY (client_id)","oauth_clients.oauth_clients_source_grant_check": "c CHECK ((source_grant = 'none'::text))","oauth_clients.oauth_clients_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE RESTRICT",@@ -198,12 +201,14 @@"page_projection_jobs.page_projection_jobs_source_incarnation_fkey": "f FOREIGN KEY (source_incarnation) REFERENCES sources(incarnation) ON DELETE CASCADE","page_versions.page_versions_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE","page_versions.page_versions_pkey": "p PRIMARY KEY (id)",+ "page_versions.page_versions_trust_tier_check": "c CHECK (((trust_tier IS NULL) OR (trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text]))))","page_write_guards.page_write_guards_pkey": "p PRIMARY KEY (source_incarnation, slug)","page_write_guards.page_write_guards_source_incarnation_fkey": "f FOREIGN KEY (source_incarnation) REFERENCES sources(incarnation) ON DELETE CASCADE","pages.pages_page_kind_check": "c CHECK ((page_kind = ANY (ARRAY['markdown'::text, 'code'::text, 'image'::text])))","pages.pages_pkey": "p PRIMARY KEY (id)","pages.pages_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE","pages.pages_source_slug_key": "u UNIQUE (source_id, slug)",+ "pages.pages_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","persistence_brain.persistence_brain_pkey": "p PRIMARY KEY (singleton)","persistence_brain.persistence_brain_singleton_check": "c CHECK ((singleton = 1))","persistence_brain.persistence_brain_writer_protocol_floor_check": "c CHECK ((writer_protocol_floor = ANY (ARRAY[1, 2])))",@@ -349,6 +354,7 @@"takes.takes_pkey": "p PRIMARY KEY (id)","takes.takes_resolution_consistency": "c CHECK ((((resolved_quality IS NULL) AND (resolved_outcome IS NULL)) OR ((resolved_quality = 'correct'::text) AND (resolved_outcome = true)) OR ((resolved_quality = 'incorrect'::text) AND (resolved_outcome = false)) OR ((resolved_quality = 'partial'::text) AND (resolved_outcome IS NULL)) OR ((resolved_quality = 'unresolvable'::text) AND (resolved_outcome IS NULL))))","takes.takes_resolved_quality_values": "c CHECK (((resolved_quality IS NULL) OR (resolved_quality = ANY (ARRAY['correct'::text, 'incorrect'::text, 'partial'::text, 'unresolvable'::text]))))",+ "takes.takes_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))","takes.takes_weight_check": "c CHECK (((weight >= (0)::double precision) AND (weight <= (1)::double precision)))","think_ab_results.think_ab_results_pkey": "p PRIMARY KEY (id)","think_ab_results.think_ab_results_preferred_check": "c CHECK ((preferred = ANY (ARRAY['baseline'::text, 'with_calibration'::text, 'neither'::text, 'tie'::text])))",@@ -356,6 +362,14 @@"timeline_entries.timeline_entries_event_page_id_fkey": "f FOREIGN KEY (event_page_id) REFERENCES pages(id) ON DELETE CASCADE","timeline_entries.timeline_entries_page_id_fkey": "f FOREIGN KEY (page_id) REFERENCES pages(id) ON DELETE CASCADE","timeline_entries.timeline_entries_pkey": "p PRIMARY KEY (id)",+ "timeline_entries.timeline_entries_trust_tier_check": "c CHECK ((trust_tier = ANY (ARRAY['user_confirmed'::text, 'operator_curated'::text, 'tool_observed'::text, 'agent_written'::text, 'unknown'::text, 'external_untrusted'::text])))",+ "trust_proposals.trust_proposals_action_check": "c CHECK ((action = ANY (ARRAY['supersede_fact'::text, 'supersede_take'::text, 'forget'::text, 'lower_page'::text, 'confirm'::text])))",+ "trust_proposals.trust_proposals_check": "c CHECK (((related_table IS NULL) = (related_id IS NULL)))",+ "trust_proposals.trust_proposals_pkey": "p PRIMARY KEY (id)",+ "trust_proposals.trust_proposals_related_table_check": "c CHECK ((related_table = ANY (ARRAY['facts'::text, 'takes'::text, 'timeline_entries'::text, 'pages'::text])))",+ "trust_proposals.trust_proposals_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE",+ "trust_proposals.trust_proposals_status_check": "c CHECK ((status = ANY (ARRAY['pending'::text, 'accepted'::text, 'rejected'::text, 'undone'::text, 'superseded'::text])))",+ "trust_proposals.trust_proposals_target_table_check": "c CHECK ((target_table = ANY (ARRAY['facts'::text, 'takes'::text, 'timeline_entries'::text, 'pages'::text])))","wanted_links.wanted_links_origin_page_id_fkey": "f FOREIGN KEY (origin_page_id) REFERENCES pages(id) ON DELETE CASCADE","wanted_links.wanted_links_pkey": "p PRIMARY KEY (id)","wanted_links.wanted_links_producer_check": "c CHECK ((producer = ANY (ARRAY['body'::text, 'frontmatter'::text])))",@@ -387,9 +401,11 @@"gbrain_lease_shared_skill_delivery()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=5e493c1ac8dce8cb025a736629e563437c4b214744137c302c532c20bf7e7acf","gbrain_preserve_fact_withdrawal()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9beb118551a08451a228146373f50f2aa2ce0cfe89937e937d361b33224aa0aa","gbrain_queue_page_projection()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=6c544b9c129b6a17dcabeb5ee8d44a2b0e0af9d02ca3fe47c7d7f22ec313042c",- "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=9dc91548479da39c77e3015481b89901ef13fb02ce496597606fbac592c05201",+ "gbrain_require_managed_writer()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d444fd431abe188062c7266caa9ab41327336c916805d7dd02a362affe2f26a7","gbrain_require_persistence_protocol(required integer)": "RETURNS void kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=af07b7fac60dec0a4fe568217931ac449d32f73b3a53a047b3b02a5f59cb5058",+ "gbrain_snapshot_version_trust()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=7452350236ed4c68a6cd1f4d78a1381a4ef44cc70e8a032141f01bba4a704702","gbrain_stamp_revision_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=d446ed1145d8bb9c93cb0ca4aa076a5dc7a5fe07b3e79518adaf1b17b0a51216",+ "gbrain_stamp_trust_tier()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=c3dbe0330bcdd42294891167e4d9cbec0902e8304ce26e934f0b124bd451bb94","gbrain_stamp_version_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=1b28a0e5769198d86490dc20b2aee80b7e6595670428a63ac9c6825cd2a35b10","gbrain_stamp_write_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=50e9b0e5bf37eeae6555dd16c8104cb0807be6c05a79e0c82237d45162c21dc2","update_chunk_search_vector()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=e12c37d5489202aaf708560db42e6c0c7c8886d198d412e1c5d915c3ae782559",@@ -759,6 +775,9 @@"timeline_entries": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"],+ "trust_proposals": [+ "<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"+ ],"wanted_links": ["<current_role> -> <current_role> WITH GRANT OPTION: DELETE,INSERT,REFERENCES,SELECT,TRIGGER,TRUNCATE,UPDATE"]@@ -1130,6 +1149,10 @@"think_ab_results_pkey": "CREATE UNIQUE INDEX think_ab_results_pkey ON public.think_ab_results USING btree (id)","think_ab_results_recent_idx": "CREATE INDEX think_ab_results_recent_idx ON public.think_ab_results USING btree (source_id, ran_at DESC)","timeline_entries_pkey": "CREATE UNIQUE INDEX timeline_entries_pkey ON public.timeline_entries USING btree (id)",+ "trust_proposals_pending_idx": "CREATE INDEX trust_proposals_pending_idx ON public.trust_proposals USING btree (source_id, created_at) WHERE (status = 'pending'::text)",+ "trust_proposals_pending_unique": "CREATE UNIQUE INDEX trust_proposals_pending_unique ON public.trust_proposals USING btree (action, target_table, target_id, COALESCE(related_table, ''::text), COALESCE(related_id, (0)::bigint)) WHERE (status = 'pending'::text)",+ "trust_proposals_pkey": "CREATE UNIQUE INDEX trust_proposals_pkey ON public.trust_proposals USING btree (id)",+ "trust_proposals_target_idx": "CREATE INDEX trust_proposals_target_idx ON public.trust_proposals USING btree (target_table, target_id)","uniq_minion_attachments_job_filename": "CREATE UNIQUE INDEX uniq_minion_attachments_job_filename ON public.minion_attachments USING btree (job_id, filename)","uniq_minion_jobs_idempotency": "CREATE UNIQUE INDEX uniq_minion_jobs_idempotency ON public.minion_jobs USING btree (idempotency_key) WHERE (idempotency_key IS NOT NULL)","uniq_subagent_messages_idx": "CREATE UNIQUE INDEX uniq_subagent_messages_idx ON public.subagent_messages USING btree (job_id, message_idx)",@@ -1195,6 +1218,7 @@"takes_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=takes.id","think_ab_results_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=think_ab_results.id","timeline_entries_id_seq": "integer start=1 min=1 max=2147483647 increment=1 cycle=false cache=1 owned_by=timeline_entries.id",+ "trust_proposals_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=trust_proposals.id","wanted_links_id_seq": "bigint start=1 min=1 max=9223372036854775807 increment=1 cycle=false cache=1 owned_by=wanted_links.id"},"tables": {@@ -1213,7 +1237,8 @@"11 federated_read ARRAY/_text NULL","12 allowed_operations ARRAY/_text NULL","13 takes_holders ARRAY/_text NULL",- "14 grant_revision integer/int4 NOT NULL DEFAULT 0"+ "14 grant_revision integer/int4 NOT NULL DEFAULT 0",+ "15 min_trust text/text NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -1844,7 +1869,9 @@"38 last_write_principal_kind text/text NULL","39 last_write_principal_id text/text NULL","40 last_written_at timestamp with time zone/timestamptz NULL",- "41 attributed_to text/text NULL"+ "41 attributed_to text/text NULL",+ "42 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "43 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -2219,7 +2246,8 @@"27 grant_repair_reasons ARRAY/_text NOT NULL DEFAULT '{}'::text[]","28 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()","29 source_grant text/text NULL",- "30 takes_holders ARRAY/_text NULL"+ "30 takes_holders ARRAY/_text NULL",+ "31 min_trust text/text NULL"],"flags": "relkind=r rls=true force_rls=false"},@@ -2381,7 +2409,9 @@"15 write_principal_id text/text NULL","16 archived_write_request_id uuid/uuid NULL","17 archived_principal_kind text/text NULL",- "18 archived_principal_id text/text NULL"+ "18 archived_principal_id text/text NULL",+ "19 trust_tier text/text NULL",+ "20 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -2433,7 +2463,9 @@"37 links_attendance_blocked_at timestamp with time zone/timestamptz NULL","38 revision_write_request_id uuid/uuid NULL","39 revision_principal_kind text/text NULL",- "40 revision_principal_id text/text NULL"+ "40 revision_principal_id text/text NULL",+ "41 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "42 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -3130,7 +3162,9 @@"29 last_write_request_id uuid/uuid NULL","30 last_write_principal_kind text/text NULL","31 last_write_principal_id text/text NULL",- "32 last_written_at timestamp with time zone/timestamptz NULL"+ "32 last_written_at timestamp with time zone/timestamptz NULL",+ "33 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "34 write_origin jsonb/jsonb NULL"],"flags": "relkind=r rls=false force_rls=false"},@@ -3165,7 +3199,33 @@"12 last_write_request_id uuid/uuid NULL","13 last_write_principal_kind text/text NULL","14 last_write_principal_id text/text NULL",- "15 last_written_at timestamp with time zone/timestamptz NULL"+ "15 last_written_at timestamp with time zone/timestamptz NULL",+ "16 trust_tier text/text NOT NULL DEFAULT 'unknown'::text",+ "17 write_origin jsonb/jsonb NULL"+ ],+ "flags": "relkind=r rls=false force_rls=false"+ },+ "trust_proposals": {+ "columns": [+ "1 id bigint/int8 NOT NULL DEFAULT nextval('trust_proposals_id_seq'::regclass)",+ "2 action text/text NOT NULL",+ "3 source_id text/text NOT NULL",+ "4 target_table text/text NOT NULL",+ "5 target_id bigint/int8 NOT NULL",+ "6 related_table text/text NULL",+ "7 related_id bigint/int8 NULL",+ "8 before_state jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "9 after_state jsonb/jsonb NOT NULL DEFAULT '{}'::jsonb",+ "10 proposer text/text NOT NULL",+ "11 proposer_principal_kind text/text NULL",+ "12 proposer_principal_id text/text NULL",+ "13 write_request_id uuid/uuid NULL",+ "14 status text/text NOT NULL DEFAULT 'pending'::text",+ "15 decided_at timestamp with time zone/timestamptz NULL",+ "16 decided_principal_kind text/text NULL",+ "17 decided_principal_id text/text NULL",+ "18 created_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()",+ "19 updated_at timestamp with time zone/timestamptz NOT NULL DEFAULT now()"],"flags": "relkind=r rls=false force_rls=false"},@@ -3197,11 +3257,13 @@"facts.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.facts REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","facts.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.facts REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","facts.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.facts REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "facts.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.facts FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","links.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.links REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","links.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.links REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","links.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.links REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","minion_jobs.minion_queue_protocol": "CREATE TRIGGER minion_queue_protocol BEFORE INSERT OR UPDATE ON public.minion_jobs FOR EACH ROW EXECUTE FUNCTION enforce_minion_queue_protocol()","page_aliases.managed_writer_guard": "CREATE TRIGGER managed_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.page_aliases FOR EACH ROW EXECUTE FUNCTION gbrain_require_managed_writer()",+ "page_versions.page_versions_trust_snapshot": "CREATE TRIGGER page_versions_trust_snapshot BEFORE INSERT ON public.page_versions FOR EACH ROW EXECUTE FUNCTION gbrain_snapshot_version_trust()","page_versions.page_versions_write_attribution": "CREATE TRIGGER page_versions_write_attribution BEFORE INSERT ON public.page_versions FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_version_attribution()","pages.bump_page_generation_clock_trg": "CREATE TRIGGER bump_page_generation_clock_trg AFTER INSERT OR DELETE OR UPDATE ON public.pages FOR EACH STATEMENT EXECUTE FUNCTION bump_page_generation_clock_fn()","pages.bump_page_generation_trg": "CREATE TRIGGER bump_page_generation_trg BEFORE INSERT OR UPDATE ON public.pages FOR EACH ROW EXECUTE FUNCTION bump_page_generation_fn()",@@ -3214,6 +3276,7 @@"pages.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.pages REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","pages.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.pages REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","pages.trg_pages_search_vector": "CREATE TRIGGER trg_pages_search_vector BEFORE INSERT OR UPDATE OF title, timeline ON public.pages FOR EACH ROW EXECUTE FUNCTION update_page_search_vector()",+ "pages.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.pages FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","persistence_brain.gbrain_protocol_activation": "CREATE TRIGGER gbrain_protocol_activation BEFORE UPDATE ON public.persistence_brain FOR EACH ROW EXECUTE FUNCTION gbrain_guard_protocol_activation()","persistence_effects.gbrain_effect_protocol": "CREATE TRIGGER gbrain_effect_protocol BEFORE INSERT OR DELETE OR UPDATE ON public.persistence_effects FOR EACH ROW EXECUTE FUNCTION gbrain_guard_effect_protocol()","persistence_requests.gbrain_request_protocol": "CREATE TRIGGER gbrain_request_protocol BEFORE INSERT OR DELETE OR UPDATE ON public.persistence_requests FOR EACH ROW EXECUTE FUNCTION gbrain_guard_request_protocol()",@@ -3230,11 +3293,13 @@"takes.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.takes REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","takes.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.takes REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","takes.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.takes REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "takes.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.takes FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()","timeline_entries.gbrain_write_attribution": "CREATE TRIGGER gbrain_write_attribution BEFORE INSERT OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_write_attribution()","timeline_entries.managed_writer_guard": "CREATE TRIGGER managed_writer_guard BEFORE INSERT OR DELETE OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_require_managed_writer()","timeline_entries.planner_stats_del": "CREATE TRIGGER planner_stats_del AFTER DELETE ON public.timeline_entries REFERENCING OLD TABLE AS old_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()","timeline_entries.planner_stats_ins": "CREATE TRIGGER planner_stats_ins AFTER INSERT ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",- "timeline_entries.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()"+ "timeline_entries.planner_stats_upd": "CREATE TRIGGER planner_stats_upd AFTER UPDATE ON public.timeline_entries REFERENCING NEW TABLE AS new_rows FOR EACH STATEMENT EXECUTE FUNCTION gbrain_count_modifications()",+ "timeline_entries.trust_tier_stamp": "CREATE TRIGGER trust_tier_stamp BEFORE INSERT OR UPDATE ON public.timeline_entries FOR EACH ROW EXECUTE FUNCTION gbrain_stamp_trust_tier()"},"viewColumns": {"page_links": [