Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test: goldens for facts.attributed_to (SQL text, export surface, upgrade-replay catalog)

garrytan3d36e31a9ad0
diff --git a/test/fixtures/goldens/exports/types.json b/test/fixtures/goldens/exports/types.json
index 3da2b2da88..c9d65705ec 100644
--- a/test/fixtures/goldens/exports/types.json
+++ b/test/fixtures/goldens/exports/types.json
@@ -82,7 +82,7 @@
"expireFact: (id: number, opts?: { supersededBy?: number; at?: Date; }) => Promise<boolean>",
"findAnomalies: (opts: AnomaliesOpts) => Promise<AnomalyResult[]>",
"findByTitleFuzzy: (name: string, dirPrefix?: string, minSimilarity?: number, sourceId?: string) => Promise<{ slug: string; similarity: number; } | null>",
- "findCandidateDuplicates: (source_id: string, entitySlug: string, factText: string, opts?: { k?: number; embedding?: Float32Array; embeddingModel?: string | null; }) => Promise<FactRow[]>",
+ "findCandidateDuplicates: (source_id: string, entitySlug: string, factText: string, opts?: { k?: number; embedding?: Float32Array; embeddingModel?: string | null; attributedTo?: FactAttribution | null; }) => Promise<FactRow[]>",
"findDuplicatePage?: ((sourceId: string, opts: { hash: string; frontmatterId?: string | null; excludeSlug?: string; }) => Promise<{ slug: string; id: number; } | null>) | undefined",
"findOntologyConflicts: (opts?: PageReadScope & { minConfidence?: number; visibility?: OntologyReadOpts[\"visibility\"]; }) => Promise<OntologyConflict[]>",
"findOrphanPages: (opts?: PageReadScope & { sourceId?: string; sourceIds?: string[]; mode?: \"inbound\" | \"islanded\"; }) => Promise<Array<{ slug: string; title: string; domain: string | null; type?: string | null; quarantined?: boolean; source_id?: string; }>>",
@@ -639,7 +639,7 @@
"kind": "type",
"name": "EvalCaptureFailureReason",
"signature": [
- "\"db_down\" | \"rls_reject\" | \"check_violation\" | \"scrubber_exception\" | \"other\""
+ "\"other\" | \"db_down\" | \"rls_reject\" | \"check_violation\" | \"scrubber_exception\""
]
},
{
@@ -1030,7 +1030,7 @@
"explainVectorSearch: (embedding: Float32Array, opts?: SearchOpts) => Promise<Record<string, unknown>>",
"findAnomalies: (opts: AnomaliesOpts) => Promise<AnomalyResult[]>",
"findByTitleFuzzy: (name: string, dirPrefix?: string, minSimilarity?: number, sourceId?: string) => Promise<{ slug: string; similarity: number; } | null>",
- "findCandidateDuplicates: (source_id: string, entitySlug: string, factText: string, opts?: { k?: number; embedding?: Float32Array; embeddingModel?: string | null; }) => Promise<FactRow[]>",
+ "findCandidateDuplicates: (source_id: string, entitySlug: string, factText: string, opts?: { k?: number; embedding?: Float32Array; embeddingModel?: string | null; attributedTo?: FactAttribution | null; }) => Promise<FactRow[]>",
"findDuplicatePage: (sourceId: string, opts: { hash: string; frontmatterId?: string | null; excludeSlug?: string; }) => Promise<{ slug: string; id: number; } | null>",
"findOntologyConflicts: (opts?: PageReadScope & { minConfidence?: number; visibility?: OntologyReadOpts[\"visibility\"]; }) => Promise<OntologyConflict[]>",
"findOrphanPages: (opts?: { sourceId?: string; sourceIds?: string[]; excludePrivate?: boolean; mode?: \"inbound\" | \"islanded\"; }) => Promise<Array<{ slug: string; title: string; domain: string | null; type?: string | null; quarantined?: boolean; source_id?: string; }>>",
@@ -1639,7 +1639,7 @@
"kind": "type",
"name": "ChatRole",
"signature": [
- "\"user\" | \"tool\" | \"system\" | \"assistant\""
+ "\"user\" | \"assistant\" | \"tool\" | \"system\""
]
},
{
@@ -3154,7 +3154,7 @@
"expireFact: (id: number, opts?: { supersededBy?: number; at?: Date; }) => Promise<boolean>",
"findAnomalies: (opts: AnomaliesOpts) => Promise<AnomalyResult[]>",
"findByTitleFuzzy: (name: string, dirPrefix?: string, minSimilarity?: number, sourceId?: string) => Promise<{ slug: string; similarity: number; } | null>",
- "findCandidateDuplicates: (source_id: string, entitySlug: string, factText: string, opts?: { k?: number; embedding?: Float32Array; embeddingModel?: string | null; }) => Promise<FactRow[]>",
+ "findCandidateDuplicates: (source_id: string, entitySlug: string, factText: string, opts?: { k?: number; embedding?: Float32Array; embeddingModel?: string | null; attributedTo?: FactAttribution | null; }) => Promise<FactRow[]>",
"findDuplicatePage?: ((sourceId: string, opts: { hash: string; frontmatterId?: string | null; excludeSlug?: string; }) => Promise<{ slug: string; id: number; } | null>) | undefined",
"findOntologyConflicts: (opts?: PageReadScope & { minConfidence?: number; visibility?: OntologyReadOpts[\"visibility\"]; }) => Promise<OntologyConflict[]>",
"findOrphanPages: (opts?: PageReadScope & { sourceId?: string; sourceIds?: string[]; mode?: \"inbound\" | \"islanded\"; }) => Promise<Array<{ slug: string; title: string; domain: string | null; type?: string | null; quarantined?: boolean; source_id?: string; }>>",
@@ -3355,6 +3355,13 @@
],
"name": "DreamVerdictInput"
},
+ {
+ "kind": "type",
+ "name": "FactAttribution",
+ "signature": [
+ "\"user\" | \"assistant\" | \"other\""
+ ]
+ },
{
"kind": "type",
"name": "FactInsertStatus",
@@ -3388,6 +3395,7 @@
{
"kind": "interface",
"members": [
+ "attributed_to?: FactAttribution | null | undefined",
"confidence: number",
"consolidated_at: Date | null",
"consolidated_into: number | null",
@@ -3498,6 +3506,7 @@
{
"kind": "interface",
"members": [
+ "attributed_to?: FactAttribution | null | undefined",
"claim_metric?: string | null | undefined",
"claim_period?: string | null | undefined",
"claim_unit?: string | null | undefined",
@@ -5962,7 +5971,7 @@
"expireFact: (id: number, opts?: { supersededBy?: number; at?: Date; }) => Promise<boolean>",
"findAnomalies: (opts: AnomaliesOpts) => Promise<AnomalyResult[]>",
"findByTitleFuzzy: (name: string, dirPrefix?: string, minSimilarity?: number, sourceId?: string) => Promise<{ slug: string; similarity: number; } | null>",
- "findCandidateDuplicates: (source_id: string, entitySlug: string, factText: string, opts?: { k?: number; embedding?: Float32Array; embeddingModel?: string | null; }) => Promise<FactRow[]>",
+ "findCandidateDuplicates: (source_id: string, entitySlug: string, factText: string, opts?: { k?: number; embedding?: Float32Array; embeddingModel?: string | null; attributedTo?: FactAttribution | null; }) => Promise<FactRow[]>",
"findDuplicatePage: (sourceId: string, opts: { hash: string; frontmatterId?: string | null; excludeSlug?: string; }) => Promise<{ slug: string; id: number; } | null>",
"findOntologyConflicts: (opts?: PageReadScope & { minConfidence?: number; visibility?: OntologyReadOpts[\"visibility\"]; }) => Promise<OntologyConflict[]>",
"findOrphanPages: (opts?: { sourceId?: string; sourceIds?: string[]; excludePrivate?: boolean; mode?: \"inbound\" | \"islanded\"; }) => Promise<Array<{ slug: string; title: string; domain: string | null; type?: string | null; quarantined?: boolean; source_id?: string; }>>",
@@ -7869,7 +7878,7 @@
"kind": "type",
"name": "EvalCaptureFailureReason",
"signature": [
- "\"db_down\" | \"rls_reject\" | \"check_violation\" | \"scrubber_exception\" | \"other\""
+ "\"other\" | \"db_down\" | \"rls_reject\" | \"check_violation\" | \"scrubber_exception\""
]
},
{
diff --git a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
index 8b03ba0f94..ddd5696639 100644
--- a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
+++ b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
@@ -69,6 +69,7 @@
"fact_withdrawals.fact_withdrawals_pkey": "p PRIMARY KEY (source_id, visibility, subject, fact_hash)",
"fact_withdrawals.fact_withdrawals_source_id_fkey": "f FOREIGN KEY (source_id) REFERENCES sources(id) ON DELETE CASCADE",
"fact_withdrawals.fact_withdrawals_visibility_check": "c CHECK ((visibility = ANY (ARRAY['private'::text, 'world'::text])))",
+ "facts.facts_attributed_to_check": "c CHECK ((attributed_to = ANY (ARRAY['user'::text, 'assistant'::text, 'other'::text])))",
"facts.facts_confidence_check": "c CHECK (((confidence >= (0)::double precision) AND (confidence <= (1)::double precision)))",
"facts.facts_kind_check": "c CHECK ((kind = ANY (ARRAY['event'::text, 'preference'::text, 'commitment'::text, 'belief'::text, 'fact'::text, 'idea'::text])))",
"facts.facts_notability_check": "c CHECK ((notability = ANY (ARRAY['high'::text, 'medium'::text, 'low'::text])))",
@@ -376,7 +377,7 @@
"gbrain_require_persistence_protocol(required integer)": "RETURNS void kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=af07b7fac60dec0a4fe568217931ac449d32f73b3a53a047b3b02a5f59cb5058",
"gbrain_stamp_revision_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=d446ed1145d8bb9c93cb0ca4aa076a5dc7a5fe07b3e79518adaf1b17b0a51216",
"gbrain_stamp_version_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=1b28a0e5769198d86490dc20b2aee80b7e6595670428a63ac9c6825cd2a35b10",
- "gbrain_stamp_write_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] body_sha256=022ddf5754968b6a6647f32a0c42db94b7aa4e680e739b79c1ec8931d06cfb92",
+ "gbrain_stamp_write_attribution()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[] 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",
"update_page_search_vector()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public] body_sha256=8e2e253471f22c3e70b2fa2e67ba9162ee3d2c764d175cb5b674db2b907d1e9d"
},
@@ -1740,7 +1741,8 @@
"37 last_write_request_id uuid/uuid NULL",
"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"
+ "40 last_written_at timestamp with time zone/timestamptz NULL",
+ "41 attributed_to text/text NULL"
],
"flags": "relkind=r rls=false force_rls=false"
},
diff --git a/test/fixtures/goldens/sql-text/_driver.json b/test/fixtures/goldens/sql-text/_driver.json
index 2a412ae254..826775fb9f 100644
--- a/test/fixtures/goldens/sql-text/_driver.json
+++ b/test/fixtures/goldens/sql-text/_driver.json
@@ -1439,7 +1439,7 @@
"via": "unsafe"
},
{
- "paramCount": 20,
+ "paramCount": 21,
"unsafeOptions": {
"cancelFence": false,
"prepare": true,
@@ -1454,7 +1454,7 @@
"via": "tagged"
},
{
- "paramCount": 20,
+ "paramCount": 21,
"unsafeOptions": {
"cancelFence": false,
"prepare": true,
@@ -1478,7 +1478,7 @@
"via": "unsafe"
},
{
- "paramCount": 19,
+ "paramCount": 20,
"unsafeOptions": {
"cancelFence": false,
"prepare": true,
@@ -1504,7 +1504,7 @@
"via": "tagged"
},
{
- "paramCount": 24,
+ "paramCount": 25,
"unsafeOptions": {
"cancelFence": false,
"prepare": true,
@@ -1528,7 +1528,7 @@
"via": "unsafe"
},
{
- "paramCount": 24,
+ "paramCount": 25,
"unsafeOptions": {
"cancelFence": false,
"prepare": true,
@@ -1537,7 +1537,7 @@
"via": "unsafe"
},
{
- "paramCount": 23,
+ "paramCount": 24,
"unsafeOptions": {
"cancelFence": false,
"prepare": true,
diff --git a/test/fixtures/goldens/sql-text/facts.json b/test/fixtures/goldens/sql-text/facts.json
index 5d6d975dec..9d6e2e3f06 100644
--- a/test/fixtures/goldens/sql-text/facts.json
+++ b/test/fixtures/goldens/sql-text/facts.json
@@ -112,7 +112,7 @@
"number"
],
"sql": "SELECT * FROM facts WHERE source_id = $1 AND entity_slug = $2 AND expired_at IS NULL AND (valid_until IS NULL OR valid_until > now()) ORDER BY created_at DESC, id DESC LIMIT $3",
- "textSha256": "c3a62723b69cce67dbb0f1b609b2271aa19c562f49faa95c0373565a92ccd0f1"
+ "textSha256": "bf05f65b608a16ecfa26d78c4d8c902b7658703c5512ae76de966698ba77cb10"
}
],
"embedding": [
@@ -127,7 +127,7 @@
"number"
],
"sql": "SELECT * FROM facts WHERE source_id = $1 AND entity_slug = $2 AND expired_at IS NULL AND (valid_until IS NULL OR valid_until > now()) AND embedding IS NOT NULL AND embedding_model=$3 AND embedded_text_hash=md5(fact) AND vector_dims(embedding)=$4 AND source != ALL($5::text[]) ORDER BY embedding <=> '[0.10000000149011612,0.20000000298023224,0.30000001192092896]'::vector LIMIT $6",
- "textSha256": "a5243e480ca8e1db3524e9ba1e5d2075425dd5e2b4de15b33d3a78cf138a0e8c"
+ "textSha256": "71fc68c3afb198e4398f9b82ed2fef9ae7aec1d80e22224ff71df9962731ceda"
}
]
},
@@ -293,10 +293,11 @@
"null",
"null",
"null",
+ "null",
"null"
],
- "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, claim_metric, claim_value, claim_unit, claim_period ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20 ) RETURNING id",
- "textSha256": "bcbde84a7eaf1c6e0fa25e98b604e7613b8ac6b048ac4aabe6d072848bed7f45"
+ "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, claim_metric, claim_value, claim_unit, claim_period, attributed_to ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21 ) RETURNING id",
+ "textSha256": "91218ff972ed492fd6737c096f073813440e9949611dbcf53cd40fdb940b8357"
},
{
"event": "commit",
@@ -336,10 +337,11 @@
"null",
"null",
"null",
+ "null",
"null"
],
- "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, claim_metric, claim_value, claim_unit, claim_period ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20 ) RETURNING id",
- "textSha256": "bcbde84a7eaf1c6e0fa25e98b604e7613b8ac6b048ac4aabe6d072848bed7f45"
+ "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, claim_metric, claim_value, claim_unit, claim_period, attributed_to ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21 ) RETURNING id",
+ "textSha256": "91218ff972ed492fd6737c096f073813440e9949611dbcf53cd40fdb940b8357"
},
{
"event": "commit",
@@ -387,10 +389,11 @@
"null",
"null",
"null",
+ "null",
"null"
],
- "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, claim_metric, claim_value, claim_unit, claim_period ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, '[0.10000000149011612,0.20000000298023224,0.30000001192092896]'::vector, $13, $14, md5($15), $16, $17, $18, $19 ) RETURNING id",
- "textSha256": "65e8d0aeab906bbcadd438a0bae75656a00a218f91873436d8e7b81f659ffe88"
+ "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, claim_metric, claim_value, claim_unit, claim_period, attributed_to ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, '[0.10000000149011612,0.20000000298023224,0.30000001192092896]'::vector, $13, $14, md5($15), $16, $17, $18, $19, $20 ) RETURNING id",
+ "textSha256": "1b09a8a0dce210b383e1f70b05fd9fa6c69c828f8a79cc208da5898616011662"
},
{
"lane": "tx",
@@ -445,10 +448,11 @@
"null",
"null",
"null",
+ "null",
"null"
],
- "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, expired_at, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, row_num, source_markdown_slug, claim_metric, claim_value, claim_unit, claim_period, event_type ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24 ) ON CONFLICT (source_id, source_markdown_slug, row_num) WHERE row_num IS NOT NULL DO NOTHING RETURNING id",
- "textSha256": "60a6c39082f072b78eceacaae96c2912c91e24c8c68f379547a6612166f86a3d"
+ "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, expired_at, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, row_num, source_markdown_slug, claim_metric, claim_value, claim_unit, claim_period, event_type, attributed_to ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25 ) ON CONFLICT (source_id, source_markdown_slug, row_num) WHERE row_num IS NOT NULL DO NOTHING RETURNING id",
+ "textSha256": "ea2d66315f5edb9eaa1132fc036a326e5ba4973f89d477ff29c53dd22a980690"
},
{
"event": "commit",
@@ -502,10 +506,11 @@
"null",
"null",
"null",
+ "null",
"null"
],
- "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, expired_at, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, row_num, source_markdown_slug, claim_metric, claim_value, claim_unit, claim_period, event_type ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24 ) ON CONFLICT (source_id, source_markdown_slug, row_num) WHERE row_num IS NOT NULL DO NOTHING RETURNING id",
- "textSha256": "60a6c39082f072b78eceacaae96c2912c91e24c8c68f379547a6612166f86a3d"
+ "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, expired_at, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, row_num, source_markdown_slug, claim_metric, claim_value, claim_unit, claim_period, event_type, attributed_to ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25 ) ON CONFLICT (source_id, source_markdown_slug, row_num) WHERE row_num IS NOT NULL DO NOTHING RETURNING id",
+ "textSha256": "ea2d66315f5edb9eaa1132fc036a326e5ba4973f89d477ff29c53dd22a980690"
},
{
"lane": "tx",
@@ -532,10 +537,11 @@
"null",
"null",
"null",
+ "null",
"null"
],
- "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, expired_at, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, row_num, source_markdown_slug, claim_metric, claim_value, claim_unit, claim_period, event_type ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, '[0.10000000149011612,0.20000000298023224,0.30000001192092896]'::vector, $14, $15, md5($16), $17, $18, $19, $20, $21, $22, $23 ) ON CONFLICT (source_id, source_markdown_slug, row_num) WHERE row_num IS NOT NULL DO NOTHING RETURNING id",
- "textSha256": "c1dad491e606a42126c8a20c14f2e90d7fba86f90aff23b5b82a4885361d03d9"
+ "sql": "INSERT INTO facts ( source_id, entity_slug, fact, kind, visibility, notability, context, valid_from, valid_until, expired_at, source, source_session, confidence, embedding, embedded_at, embedding_model, embedded_text_hash, row_num, source_markdown_slug, claim_metric, claim_value, claim_unit, claim_period, event_type, attributed_to ) VALUES ( $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, '[0.10000000149011612,0.20000000298023224,0.30000001192092896]'::vector, $14, $15, md5($16), $17, $18, $19, $20, $21, $22, $23, $24 ) ON CONFLICT (source_id, source_markdown_slug, row_num) WHERE row_num IS NOT NULL DO NOTHING RETURNING id",
+ "textSha256": "55ec99676fc259d94b5e8723d9629d422832e92b2ef019444e55a2de7989556d"
},
{
"lane": "tx",