Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(facts): page purge skips extraction outcome markers; guards exempt them (#7778)

garrytane6fd47839478
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 76800a8a01..47a7742257 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,23 @@ credits are retained; no result has been reassigned to another provider. Origina
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
+## [Unreleased]
+
+**A page purge no longer stops conversation-fact extraction from ever finishing (#7778).**
+
+Each conversation page records its extraction outcome as a bookkeeping row with the same text on every page (`EXTRACTION_COMPLETE`, or `EXTRACTION_NOT_APPLICABLE`) and no entity. A page purge tombstoned every fact row of the page, that row included, so the tombstone had subject `*` and matched the outcome row of every other page in the source. Since #7438 the extractor leaves out a row that matches a tombstone, so no page could record its outcome: every run re-extracted and re-paid for the same pages, and doctor's backlog never reached zero.
+
+### What changed
+
+| Situation | Before | Now |
+|---|---|---|
+| A page purge of a conversation page | tombstoned the outcome marker with subject `*` | tombstones the page's claims only; the marker is also left out of the purge's journal and segment sweeps |
+| A brain that already holds such a tombstone | every page stayed unfinished; each run paid again | the next run records each page's outcome and later runs skip them, with no manual step; the tombstone row stays |
+| An extracted user claim that matches a tombstone (#7438) | left out | still left out, even when its text is `EXTRACTION_COMPLETE` |
+| `gbrain forget <id>` or `forget <id> --purge` naming an outcome row | withdrew or purged the marker for the whole source | not found, nothing changes |
+
+Migration v279 replaces the facts insert guard's function so its purge refusal skips a row whose source is a conversation-facts audit source and whose text is exactly one of the two markers. Any other row under those sources is still refused. It changes no trigger, privilege or row.
+
## [0.60.474.0] - 2026-10-27
**A database role that can't read the writer state is now refused instead of let through.**
diff --git a/docs/guides/troubleshooting.md b/docs/guides/troubleshooting.md
index 37aac2e35a..52f93f67c1 100644
--- a/docs/guides/troubleshooting.md
+++ b/docs/guides/troubleshooting.md
@@ -19,6 +19,7 @@
| Doctor `sync_freshness` says a source has "no successful sync recorded" or "first sync running" | follow the check's `fix`: `first sync running` (code `sync_first_run_in_progress`, warn) means wait; `no successful sync recorded` (code `sync_no_successful_sync`, fail) names the last attempt and its `reason`: wait for a queued job, inspect holds (`gbrain sync status --source <id> --json`), or retry (`gbrain sync --source <id>`) ([details](#sync-freshness-no-successful-sync)) | agent | none | `gbrain doctor --only sync_freshness --json` |
| Recall returns conversation facts like "Date said …", "Attendees said …" or "Summary said …" | `gbrain repair conversation-labels` previews them ([conversation labels](repair.md#conversation-labels)); apply the printed command with `--yes` | agent, after the user agrees | `destructive` | `gbrain doctor --only conversation_label_facts --json` is ok |
| Conversation facts are dated 1970-01-01 | same preview: `gbrain repair conversation-labels` (an undated page's pre-fix facts carry a `segment 1970-01-01` context); add a `date:` to the page frontmatter before re-extracting it | agent, after the user agrees | `destructive` | `gbrain doctor --only conversation_label_facts --json` is ok |
+| After a page purge, `extract-conversation-facts` logs `left out 1 extracted fact(s) that match a purge tombstone (#7438)` for every page, the same pages are extracted (and paid for) on every run, and doctor's conversation-facts backlog never reaches zero | upgrade (#7778): a page purge on an older release tombstoned the shared `EXTRACTION_COMPLETE` outcome marker with subject `*`, which kept every page from recording its outcome. The next run records each page's outcome; no manual step is needed and the tombstone row stays in `fact_purges` (it no longer matches the marker) | agent | none | a second `gbrain extract-conversation-facts --dry-run` lists none of the pages the first run completed |
| `remember` or `put_page` refused `source_changed` "The canonical file contains an uncoordinated local edit" on many pages nobody edited, or doctor `lost_caller_writes` warns | upgrade to v0.60.157.0 or later (a database-only v0.13.1 `validate: false` stamp was read as a file edit, #6429); then `gbrain repair failed-writes --source <id>` previews the refused writes and prints the apply command ([failed writes](repair.md#failed-writes)) | agent; the apply after the user agrees | none to preview | `gbrain doctor --only lost_caller_writes --json` is ok |
| A write (`add_timeline_entry`, `put_page`, `remember`, any `mutating` tool) refused `invalid_params` "unknown parameter … write operations always reject unknown parameters; nothing was written" | the call named a parameter the tool does not declare (for example `content` instead of `detail`); the `suggestion` names the submitted key and the declared one; resend with the declared name. Reads keep the `mcp.strict_params` warn grace period | agent | none | the resent call returns no `invalid_params` and no `unknown_param` warning |
| `gbrain config set chat_model` (or `expansion_model`) printed `[config] WARN: … outranks it, so the model in use does not change`, or its `--json` says `effective: false` | the value is stored in the database, but `shadowed_by` names what wins at runtime (never its value): a `models.*` key (`gbrain config unset <that key>`, after asking: it may select other models too), an environment variable (`GBRAIN_MODEL`, `GBRAIN_CHAT_MODEL`, `GBRAIN_EXPANSION_MODEL`: the user removes it from their shell profile or service environment), or the `config.json` pin (`gbrain config unset chat_model --file` removes only the pin) | agent for the config changes, after the user agrees; user for an environment variable | none | `gbrain config get chat_model` reports `source: db plane`, and a repeat `config set … --json` says `effective: true` |
diff --git a/src/core/facts/audit-sources.ts b/src/core/facts/audit-sources.ts
index 196591f4c1..c35937ecb4 100644
--- a/src/core/facts/audit-sources.ts
+++ b/src/core/facts/audit-sources.ts
@@ -44,6 +44,27 @@ export const AUDIT_ROW_SOURCES = [
LEGACY_TERMINAL_AUDIT_SOURCE,
] as const;
+/** The fixed claim text of each outcome row (`terminalAuditFact`, `nonExtractableAuditFact`). */
+export const OUTCOME_MARKER_FACTS = ['EXTRACTION_COMPLETE', 'EXTRACTION_NOT_APPLICABLE'] as const;
+
+/**
+ * #7778: true for an extraction outcome row, the bookkeeping marker every
+ * conversation page carries with the same text. It is not a user claim, so no
+ * purge tombstone applies to it and no purge or forget writes one: a
+ * subject-'*' tombstone on its fingerprint would keep every page of the
+ * source from ever completing. Both the source and the exact marker text must
+ * match, so a user claim keeps every purge guarantee whatever its source.
+ */
+export function isOutcomeMarker(row: { source?: string | null; fact: string }): boolean {
+ return (AUDIT_ROW_SOURCES as readonly string[]).includes(row.source ?? '') && (OUTCOME_MARKER_FACTS as readonly string[]).includes(row.fact);
+}
+
+/** SQL twin of `isOutcomeMarker` over a facts row alias (constants only, no parameters). */
+export function outcomeMarkerSql(alias: string): string {
+ const list = (values: readonly string[]) => values.map(v => `'${v}'`).join(',');
+ return `(${alias}.source IN (${list(AUDIT_ROW_SOURCES)}) AND ${alias}.fact IN (${list(OUTCOME_MARKER_FACTS)}))`;
+}
+
/**
* Decision 8 (wave 9 follow-ups): the conversation parser + extractor
* semantic version. Bump it when a parser or extractor change alters what an
diff --git a/src/core/facts/conversation-publication.ts b/src/core/facts/conversation-publication.ts
index 9602ecbda0..039c6ce523 100644
--- a/src/core/facts/conversation-publication.ts
+++ b/src/core/facts/conversation-publication.ts
@@ -74,7 +74,7 @@ import { maintenanceCallerPreflight, maintenancePreflight, submitDatabaseMainten
import { loadConfig } from '../config.ts';
import { waitForWrite } from '../persistence/service.ts';
import { catalogueError } from '../error-catalogue.ts';
-import { AUDIT_ROW_SOURCES, CONVERSATION_EXTRACTOR_VERSION, NON_EXTRACTABLE_AUDIT_SOURCE, TERMINAL_AUDIT_SOURCE, stampExtractorVersion } from './audit-sources.ts';
+import { AUDIT_ROW_SOURCES, CONVERSATION_EXTRACTOR_VERSION, NON_EXTRACTABLE_AUDIT_SOURCE, outcomeMarkerSql, TERMINAL_AUDIT_SOURCE, stampExtractorVersion } from './audit-sources.ts';
import { ALLOWED_TYPES, pageTypesForAllowed, type AllowedType } from './conversation-types.ts';
import { withWriteTrust } from '../persistence/context.ts';
import { conversationDerivation } from '../persistence/derived-facts.ts';
@@ -560,14 +560,15 @@ export async function replaceConversationFacts(tx: BrainEngine, sourceId: string
* Inserts `rows` numbered above every fact row of the page; a lost insert throws, rolling the publication back.
* #7438: a row whose claim matches a purge tombstone (under the entity it carries after relink inheritance) is left
* out and its index returned in `purged`; the facts insert guard would otherwise refuse the whole statement.
+ * #7778: never the page outcome row, which no tombstone applies to (the guard exempts it too).
*/
async function insertConversationFacts(tx: BrainEngine, sourceId: string, slug: string, rows: UnnumberedFact[]): Promise<{ inserted: number; ids: number[]; purged: Set<number> }> {
if (!rows.length) return { inserted: 0, ids: [], purged: new Set() };
rows = await inheritRelinkedEntities(tx, sourceId, slug, rows);
- const matches = await tx.executeRaw<{ ord: number | string }>(`SELECT n.ord FROM unnest($2::text[], $3::text[], $4::text[]) WITH ORDINALITY AS n(fact, visibility, subject, ord)
- WHERE EXISTS (SELECT 1 FROM fact_purges p WHERE p.source_id=$1 AND p.visibility=n.visibility AND p.subject IN ('*', n.subject)
+ const matches = await tx.executeRaw<{ ord: number | string }>(`SELECT n.ord FROM unnest($2::text[], $3::text[], $4::text[], $5::text[]) WITH ORDINALITY AS n(fact, visibility, subject, source, ord)
+ WHERE NOT ${outcomeMarkerSql('n')} AND EXISTS (SELECT 1 FROM fact_purges p WHERE p.source_id=$1 AND p.visibility=n.visibility AND p.subject IN ('*', n.subject)
AND p.fact_hash=gbrain_fact_fingerprint(n.fact))`,
- [sourceId, rows.map(row => ensureWellFormed(row.fact)), rows.map(row => row.visibility ?? 'private'), rows.map(row => row.entity_slug ? ensureWellFormed(row.entity_slug) : null)]);
+ [sourceId, rows.map(row => ensureWellFormed(row.fact)), rows.map(row => row.visibility ?? 'private'), rows.map(row => row.entity_slug ? ensureWellFormed(row.entity_slug) : null), rows.map(row => row.source ?? null)]);
const purged = new Set(matches.map(match => Number(match.ord) - 1));
rows = rows.filter((_, i) => !purged.has(i));
if (!rows.length) return { inserted: 0, ids: [], purged };
diff --git a/src/core/facts/insert-guard-schema.ts b/src/core/facts/insert-guard-schema.ts
index 123f4c44bc..ee555fcf3b 100644
--- a/src/core/facts/insert-guard-schema.ts
+++ b/src/core/facts/insert-guard-schema.ts
@@ -40,13 +40,19 @@
* not saved either). Installed by migration v264.
*/
import { FACT_WITHDRAWAL_STAMP_SETTING } from '../persistence/attribution-schema.ts';
+import { outcomeMarkerSql } from './audit-sources.ts';
export const FACT_INSERT_GUARD_TRIGGER = 'facts_guard_inserted';
/** Transaction-local; 'on' defers the withdrawal stamp of the following inserts to facts_guard_inserted. */
export const FACT_WITHDRAWAL_STAMP_DEFERRED_SETTING = 'gbrain.fact_withdrawal_stamp_deferred';
export const FACT_INSERT_GUARD_FUNCTION = 'gbrain_guard_inserted_facts';
-export const FACT_INSERT_GUARD_SQL = `
+/**
+ * The guard function alone (#7778 re-creates it without touching the triggers). The purge refusal skips an extraction
+ * outcome row (facts/audit-sources.ts `isOutcomeMarker`): that bookkeeping marker is not a claim, and a subject-'*'
+ * tombstone on its fingerprint, which a page purge wrote before #7778, kept every page of the source from completing.
+ */
+export const FACT_INSERT_GUARD_FUNCTION_SQL = `
CREATE OR REPLACE FUNCTION gbrain_guard_inserted_facts() RETURNS trigger
LANGUAGE plpgsql SET search_path = pg_catalog, public AS $fn$
DECLARE purged TEXT; stamp_setting TEXT;
@@ -55,7 +61,7 @@ CREATE OR REPLACE FUNCTION gbrain_guard_inserted_facts() RETURNS trigger
IF EXISTS (SELECT 1 FROM fact_purges p WHERE p.source_id IN (SELECT i.source_id FROM inserted_facts i)) THEN
WITH n AS MATERIALIZED (
SELECT row_number() OVER () AS ord, i.source_id, i.visibility, i.entity_slug, gbrain_fact_fingerprint(i.fact) AS fact_hash
- FROM inserted_facts i)
+ FROM inserted_facts i WHERE NOT ${outcomeMarkerSql('i')})
SELECT n.fact_hash INTO purged FROM n
WHERE EXISTS (SELECT 1 FROM fact_purges p WHERE p.source_id = n.source_id AND p.visibility = n.visibility
AND p.subject IN ('*', n.entity_slug) AND p.fact_hash = n.fact_hash)
@@ -85,6 +91,9 @@ CREATE OR REPLACE FUNCTION gbrain_guard_inserted_facts() RETURNS trigger
RETURN NULL;
END
$fn$;
+`;
+
+export const FACT_INSERT_GUARD_SQL = `${FACT_INSERT_GUARD_FUNCTION_SQL}
DROP TRIGGER IF EXISTS facts_guard_inserted ON facts;
CREATE TRIGGER facts_guard_inserted AFTER INSERT ON facts REFERENCING NEW TABLE AS inserted_facts
FOR EACH STATEMENT EXECUTE FUNCTION gbrain_guard_inserted_facts();
diff --git a/src/core/facts/purge.ts b/src/core/facts/purge.ts
index 4c38668279..a6601475ec 100644
--- a/src/core/facts/purge.ts
+++ b/src/core/facts/purge.ts
@@ -38,6 +38,7 @@ import { assertPersistenceAccepting } from '../persistence/service.ts';
import { declareDurablePersistence } from '../persistence/protocol.ts';
import { parseWriteRequestId } from '../persistence/preconditions.ts';
import { withCoordinatedWrite } from '../persistence/context.ts';
+import { outcomeMarkerSql } from './audit-sources.ts';
import { requestAttribution } from '../persistence/attribution.ts';
import { isTerminal, principalKey, type WriteRequest } from '../persistence/model.ts';
import { retryWriteAdmission } from '../persistence/admission-retry.ts';
@@ -102,7 +103,7 @@ function notFound(rawId: string): OperationError {
async function loadTarget(engine: BrainEngine, id: number, sourceId: string): Promise<PurgeTarget | null> {
const [row] = await engine.executeRaw<PurgeTarget>(`SELECT id,source_id,visibility,fact,entity_slug,source_markdown_slug,
gbrain_fact_fingerprint(fact) AS fact_hash,embedding::text AS embedding,embedding_model
- FROM facts WHERE id=$1 AND source_id=$2`, [id, sourceId]);
+ FROM facts WHERE id=$1 AND source_id=$2 AND NOT ${outcomeMarkerSql('facts')}`, [id, sourceId]);
return row ? { ...row, id: Number(row.id) } : null;
}
diff --git a/src/core/facts/withdrawal.ts b/src/core/facts/withdrawal.ts
index 075e8378fc..933e13b44f 100644
--- a/src/core/facts/withdrawal.ts
+++ b/src/core/facts/withdrawal.ts
@@ -6,6 +6,7 @@ import { withdrawnFact, withdrawalFenceBlocks } from './withdrawal-overlay.ts';
import { ambiguousFenceClaims, discoverWithdrawalTargets, withdrawalDiscoveryFailure } from './withdrawal-discovery.ts';
import { dropPurgedFenceRows } from './purge-overlay.ts';
import { privateProvenanceFilterFragment } from '../search/private-visibility.ts';
+import { outcomeMarkerSql } from './audit-sources.ts';
import { coverageActive, noteBelief, readLedgerSource, withBeliefBatch } from '../belief/ledger.ts';
import { createPageVersion } from '../page-state/versions.ts';
import { validateSlug } from '../utils.ts';
@@ -59,7 +60,7 @@ export async function recordFactWithdrawal(
await tx.executeRaw('SELECT id FROM sources WHERE id=$1 FOR UPDATE', [sourceId]);
const visible = await tx.executeRaw<{ visibility: 'private' | 'world'; fact: string; fact_hash: string; subject: string }>(
`SELECT visibility,fact,gbrain_fact_fingerprint(fact) AS fact_hash,COALESCE(entity_slug,'*') AS subject FROM facts WHERE id=$1 AND source_id=$2
- AND ($3::boolean=false OR visibility='world')${opts.excludePrivate ? ` AND ${privateProvenanceFilterFragment('facts')}` : ''}`, [id, sourceId, worldOnly]);
+ AND NOT ${outcomeMarkerSql('facts')} AND ($3::boolean=false OR visibility='world')${opts.excludePrivate ? ` AND ${privateProvenanceFilterFragment('facts')}` : ''}`, [id, sourceId, worldOnly]);
if (!visible.length) return { withdrawn: false, pages: [] };
const { visibility, fact, fact_hash, subject } = visible[0];
// Discovery is keyed on the claim and its subject: a subject-scoped
diff --git a/src/core/persistence/page-purge.ts b/src/core/persistence/page-purge.ts
index 7e46f8cd24..b1cef5e6f4 100644
--- a/src/core/persistence/page-purge.ts
+++ b/src/core/persistence/page-purge.ts
@@ -47,6 +47,7 @@ import { clearRebuildableCache } from './rebuildable-cache.ts';
import { carryingNeedles, findRequestsForSlugs, JOURNAL_SWEEP_MATCH_CAP, recheckRequestsCarrying, redactRequestIntents, sweepRequestsCarrying, sweepRequestsForGroups,
type JournalSweep } from './intent-redaction.ts';
import { dropPurgedFenceRows } from '../facts/purge-overlay.ts';
+import { isOutcomeMarker, outcomeMarkerSql } from '../facts/audit-sources.ts';
import { derivedRowsFrom, hideDerivedRows } from '../facts/derivation-inputs.ts';
import { contentHash } from '../utils.ts';
import { isSegmentedPage } from '../page-body/page-shape.ts';
@@ -81,15 +82,15 @@ const purgeReceipts = new Map<string, { receipt: Record<string, unknown>; purge:
/** The page's claims (facts filed on it, its takes) that the journal sweep searches for, bounded, trimmed, deduplicated. */
async function readPurgeClaims(engine: Pick<BrainEngine, 'executeRaw'>, sourceId: string, slug: string, pageId: number) {
- const factRows = await engine.executeRaw<{ id: number; fact: string }>('SELECT id,fact FROM facts WHERE source_id=$1 AND source_markdown_slug=$2 ORDER BY id LIMIT 1000', [sourceId, slug]);
+ const factRows = await engine.executeRaw<{ id: number; fact: string; source: string | null }>('SELECT id,fact,source FROM facts WHERE source_id=$1 AND source_markdown_slug=$2 ORDER BY id LIMIT 1000', [sourceId, slug]);
const takeRows = await engine.executeRaw<{ id: number; claim: string }>('SELECT id,claim FROM takes WHERE page_id=$1 ORDER BY id LIMIT 1000', [pageId]);
- const needles = [...new Set([...factRows.map(f => f.fact), ...takeRows.map(t => t.claim)].map(t => t.trim()).filter(t => t.length >= 8))].slice(0, 32);
+ const needles = [...new Set([...factRows.filter(f => !isOutcomeMarker(f)).map(f => f.fact), ...takeRows.map(t => t.claim)].map(t => t.trim()).filter(t => t.length >= 8))].slice(0, 32);
return { factRows, takeRows, needles };
}
/** Every claim of the page (its facts, withdrawn ones included, and its takes), trimmed and deduplicated, unbounded: the segment-text sweep's needles. */
async function readSegmentClaims(engine: Pick<BrainEngine, 'executeRaw'>, sourceId: string, slug: string, pageId: number): Promise<string[]> {
- const rows = await engine.executeRaw<{ c: string }>('SELECT fact AS c FROM facts WHERE source_id=$1 AND source_markdown_slug=$2 UNION SELECT claim FROM takes WHERE page_id=$3',
+ const rows = await engine.executeRaw<{ c: string }>(`SELECT fact AS c FROM facts WHERE source_id=$1 AND source_markdown_slug=$2 AND NOT ${outcomeMarkerSql('facts')} UNION SELECT claim FROM takes WHERE page_id=$3`,
[sourceId, slug, pageId]);
return [...new Set(rows.map(r => r.c.trim()).filter(t => t.length >= 8))];
}
@@ -232,7 +233,7 @@ async function tombstonePage(tx: BrainEngine, sourceId: string, slug: string, pa
const page = snapshot.page;
await tx.executeRaw(`INSERT INTO fact_purges(source_id,visibility,subject,fact_hash,request_id,actor,reason)
SELECT DISTINCT source_id,visibility,COALESCE(entity_slug,'*'),gbrain_fact_fingerprint(fact),$3::uuid,$4,'page purge'
- FROM facts WHERE source_id=$1 AND source_markdown_slug=$2 ON CONFLICT DO NOTHING`, [sourceId, slug, requestId, actor]);
+ FROM facts WHERE source_id=$1 AND source_markdown_slug=$2 AND NOT ${outcomeMarkerSql('facts')} ON CONFLICT DO NOTHING`, [sourceId, slug, requestId, actor]);
await tx.executeRaw(`INSERT INTO take_purges(source_id,subject,claim_hash,request_id)
SELECT DISTINCT $1,$2,gbrain_fact_fingerprint(claim),$4::uuid FROM takes WHERE page_id=$3 ON CONFLICT DO NOTHING`, [sourceId, slug, pageId, requestId]);
// Tombstone the content hash of the page and of every retained version, each as an import of that body would
@@ -278,7 +279,7 @@ export async function purgePageInTransaction(tx: BrainEngine, row: WriteRequest,
const lifetimes = ledgerPresent ? await pageLifetimesOf(tx, sourceId, slug, page.id) : [];
const inventory = ledgerPresent ? await lookup('ledger_redaction', () => pagePurgeClaims(tx, { sourceId, slug, pageId: page.id, lifetimes })) : { claims: [], fps: [] };
const mirrorFacts = retention ? [] : await tx.executeRaw<{ fact_hash: string; visibility: string; subject: string }>(`SELECT DISTINCT gbrain_fact_fingerprint(fact) AS fact_hash,
- visibility, COALESCE(entity_slug,'*') AS subject FROM facts WHERE source_id=$1 AND source_markdown_slug=$2`, [sourceId, slug]);
+ visibility, COALESCE(entity_slug,'*') AS subject FROM facts WHERE source_id=$1 AND source_markdown_slug=$2 AND NOT ${outcomeMarkerSql('facts')}`, [sourceId, slug]);
const mirrorTakes = retention ? [] : (await tx.executeRaw<{ claim_hash: string }>('SELECT DISTINCT gbrain_fact_fingerprint(claim) AS claim_hash FROM takes WHERE page_id=$1', [page.id])).map(t => t.claim_hash);
const hashes = new Set<string>();
if (!retention) await tombstonePage(tx, sourceId, slug, page.id, snapshot, row.id, actor, { hash: storedHash, generation: Number(stored?.body_generation) }, hashes);
diff --git a/src/core/schema-migrations/latest.generated.ts b/src/core/schema-migrations/latest.generated.ts
index 37227d57d5..e4bd78fa4b 100644
--- a/src/core/schema-migrations/latest.generated.ts
+++ b/src/core/schema-migrations/latest.generated.ts
@@ -4,4 +4,4 @@
// The highest schema migration version (migrate.ts LATEST_VERSION), importable without
// loading the migrations themselves.
-export const LATEST_SCHEMA_VERSION = 278;
+export const LATEST_SCHEMA_VERSION = 279;
diff --git a/src/core/schema-migrations/registry.generated.ts b/src/core/schema-migrations/registry.generated.ts
index ee27aee507..c002645061 100644
--- a/src/core/schema-migrations/registry.generated.ts
+++ b/src/core/schema-migrations/registry.generated.ts
@@ -279,6 +279,7 @@ import { v275 } from './v275-rls-backfill-unguarded-tables.ts';
import { v276 } from './v276-persistence-foreground-committed-index.ts';
import { v277 } from './v277-function-search-path-pg-temp.ts';
import { v278 } from './v278-writer-fence-fail-closed.ts';
+import { v279 } from './v279-outcome-markers-skip-purge-guard.ts';
// Array order is historical (see HISTORICAL_ARRAY_ORDER in the generator); the
// runner sorts by version before applying.
@@ -556,4 +557,5 @@ export const MIGRATIONS: Migration[] = [
v276,
v277,
v278,
+ v279,
];
diff --git a/src/core/schema-migrations/v279-outcome-markers-skip-purge-guard.ts b/src/core/schema-migrations/v279-outcome-markers-skip-purge-guard.ts
new file mode 100644
index 0000000000..15ee6ce601
--- /dev/null
+++ b/src/core/schema-migrations/v279-outcome-markers-skip-purge-guard.ts
@@ -0,0 +1,22 @@
+import type { Migration } from './types.ts';
+import { FACT_INSERT_GUARD_FUNCTION_SQL } from '../facts/insert-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.
+//
+// #7778: the facts insert guard's purge refusal no longer applies to an
+// extraction outcome row (source one of the conversation-facts audit sources
+// and text EXTRACTION_COMPLETE or EXTRACTION_NOT_APPLICABLE). A page purge
+// tombstoned that shared marker with subject '*', after which no page of the
+// source could record its outcome, so every run re-extracted and re-paid for
+// the same pages. Brains holding such a tombstone converge on their next run:
+// the tombstone row stays (it is history and the restore mirror replays it),
+// it just no longer matches a marker. Replaces only the function: its trigger
+// already calls it, and re-creating the trigger would take an ACCESS EXCLUSIVE
+// lock on facts. No row is read or written.
+export const v279: Migration = {
+ version: 279,
+ name: 'outcome_markers_skip_purge_guard',
+ idempotent: true,
+ sql: FACT_INSERT_GUARD_FUNCTION_SQL,
+};
diff --git a/test/conversation-facts-outcome-marker-purge-7778.test.ts b/test/conversation-facts-outcome-marker-purge-7778.test.ts
new file mode 100644
index 0000000000..6388e11d99
--- /dev/null
+++ b/test/conversation-facts-outcome-marker-purge-7778.test.ts
@@ -0,0 +1,184 @@
+/**
+ * #7778: a page purge tombstoned every fact row of the page, the extraction
+ * outcome row included. That row's text (EXTRACTION_COMPLETE) is the same on
+ * every conversation page and it has no entity, so the tombstone had subject
+ * '*'. Since #7438 the conversation lane leaves out any row matching a
+ * tombstone, so afterwards no page of the source could record its outcome:
+ * each run re-extracted (and re-paid for) the same pages and the backlog never
+ * reached zero. Now the page purge writes no tombstone for an outcome row, and
+ * neither the #7438 skip nor the facts insert guard applies to one, so a brain
+ * already holding such a tombstone converges on its next run.
+ */
+import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
+import { randomUUID } from 'node:crypto';
+import { PGLiteEngine } from '../src/core/pglite-engine.ts';
+import type { BrainEngine } from '../src/core/engine.ts';
+import type { ExtractedFact } from '../src/core/facts/extract.ts';
+import { runExtractConversationFactsCore } from '../src/commands/extract-conversation-facts.ts';
+import { persistencePostgresTemplate } from './helpers/persistence-postgres.ts';
+import { requirePostgresTestDatabase, testBackends } from './helpers/test-backends.ts';
+import { resetPgliteState } from './helpers/reset-pglite.ts';
+import { dispatchToolCall } from '../src/mcp/dispatch.ts';
+import { configureGateway, resetGateway, __setEmbedTransportForTests } from '../src/core/ai/gateway.ts';
+import { LEGACY_EMBEDDING_CONFIG } from './helpers/legacy-embedding-config.ts';
+import { disposePersistenceConsumer } from '../src/core/persistence/service.ts';
+import { submitPageMutation } from '../src/core/persistence/page-mutations.ts';
+import { managedBrain } from './helpers/managed-brain.ts';
+import { TERMINAL_AUDIT_SOURCE } from '../src/core/facts/audit-sources.ts';
+
+let engine: BrainEngine;
+
+const KEPT = 'Owner Example sends the quarterly plan on Thursday';
+const PURGED = 'Alice Example reviews plans on Mondays';
+const transcript = (title: string) => [
+ '---', `title: ${title}`, 'type: meeting', 'date: 2026-09-28', '---',
+ '**Alice Example:** Can you send me the quarterly plan before the review?',
+ '**Owner Example:** Yes, I will send it on Thursday with the finance appendix.',
+ '**Alice Example:** Good. I review plans on Mondays, so that works.',
+ '**Owner Example:** I will flag any launch date changes in the summary.', '',
+].join('\n');
+
+async function call(name: string, params: Record<string, unknown>) {
+ const res = await dispatchToolCall(engine, name, params, { remote: false });
+ return JSON.parse(res.content[0]!.text!) as Record<string, any>;
+}
+
+const fact = (text: string): ExtractedFact => ({ fact: text, kind: 'fact', confidence: 0.9, entity_slug: null, source: 'test', notability: 'high' } as ExtractedFact);
+
+/** One run; `calls` counts provider calls (the extractor and the embedding transport). */
+async function extract(slugs: string[] | undefined, facts: string[], calls: { n: number }) {
+ await disposePersistenceConsumer(engine);
+ return runExtractConversationFactsCore(engine, { sourceId: 'default', ...(slugs ? { slugs } : {}), sleepMs: 0, overrideDisabled: true, workers: 1,
+ extractor: async () => { calls.n++; return facts.map(fact); } });
+}
+
+async function tombstone(text: string, subject = '*') {
+ const [{ visibility }] = await engine.executeRaw<{ visibility: string }>(
+ `SELECT COALESCE((SELECT value FROM config WHERE key='facts.default_visibility'), 'private') AS visibility`);
+ await engine.executeRaw(`INSERT INTO fact_purges(source_id, visibility, subject, fact_hash) VALUES ('default', $1, $2, gbrain_fact_fingerprint($3))`,
+ [visibility, subject, text]);
+}
+
+async function completed(slugs: string[]) {
+ return (await engine.executeRaw<{ slug: string }>(`SELECT DISTINCT source_markdown_slug AS slug FROM facts
+ WHERE source_id='default' AND source=$1 AND expired_at IS NULL AND source_markdown_slug = ANY($2::text[]) ORDER BY 1`, [TERMINAL_AUDIT_SOURCE, slugs])).map(r => r.slug);
+}
+
+async function markerTombstones() {
+ const [row] = await engine.executeRaw<{ n: number | string }>(`SELECT count(*)::int AS n FROM fact_purges
+ WHERE source_id='default' AND fact_hash IN (gbrain_fact_fingerprint('EXTRACTION_COMPLETE'), gbrain_fact_fingerprint('EXTRACTION_NOT_APPLICABLE'))`);
+ return Number(row?.n ?? 0);
+}
+
+/** Seeds the pre-#7778 wildcard marker tombstone, then runs twice: the first run completes both pages, the second makes no provider call. */
+async function convergesDespiteMarkerTombstone(put: (slug: string, title: string) => Promise<void>) {
+ const slugs = ['meetings/run-1', 'meetings/run-2'];
+ for (const [i, slug] of slugs.entries()) await put(slug, `Run ${i + 1}`);
+ await tombstone('EXTRACTION_COMPLETE');
+ const first = { n: 0 };
+ const run1 = await extract(slugs, [KEPT], first);
+ expect(run1.pages_failed).toBe(0);
+ expect(run1.facts_skipped_purged ?? 0).toBe(0);
+ expect(run1.pages_processed).toBe(2);
+ expect(first.n).toBeGreaterThan(0);
+ expect(await completed(slugs)).toEqual(slugs);
+ const second = { n: 0 };
+ const run2 = await extract(undefined, [KEPT], second);
+ expect(run2.pages_processed).toBe(0);
+ expect(run2.pages_failed).toBe(0);
+ expect(second.n).toBe(0);
+ expect(await markerTombstones()).toBe(1);
+}
+
+for (const backend of testBackends()) {
+ describe(backend, () => {
+ let pglite: PGLiteEngine | undefined;
+ let template: Awaited<ReturnType<typeof persistencePostgresTemplate>> | undefined;
+ let close: (() => Promise<void>) | undefined;
+ let embedCalls = 0;
+ beforeAll(async () => {
+ if (backend === 'postgres') template = await persistencePostgresTemplate(requirePostgresTestDatabase());
+ else { pglite = new PGLiteEngine(); await pglite.connect({}); await pglite.initSchema(); }
+ }, 120_000);
+ afterAll(async () => { resetGateway(); __setEmbedTransportForTests(null); await template?.dispose(); await pglite?.disconnect(); });
+ beforeEach(async () => {
+ if (pglite) { engine = pglite; await disposePersistenceConsumer(engine); await resetPgliteState(pglite); }
+ else { const c = await template!.clone(); engine = c.engine; close = c.close; }
+ configureGateway({ ...LEGACY_EMBEDDING_CONFIG, env: {} });
+ embedCalls = 0;
+ __setEmbedTransportForTests(async () => { embedCalls++; throw new Error('no provider call is expected'); });
+ }, 60_000);
+ afterEach(async () => {
+ expect(embedCalls).toBe(0);
+ if (close) { await disposePersistenceConsumer(engine); await close(); close = undefined; }
+ });
+
+ test('repo-less brain: a wildcard EXTRACTION_COMPLETE tombstone no longer keeps pages from completing', async () => {
+ await convergesDespiteMarkerTombstone(async (slug, title) => { await call('put_page', { slug, content: transcript(title) }); });
+ });
+
+ test('managed brain: the batch publishes each outcome row despite the tombstone', async () => {
+ await managedBrain(async (brain) => {
+ const outer = engine;
+ engine = brain.engine;
+ try {
+ await convergesDespiteMarkerTombstone(async (slug, content) => {
+ await submitPageMutation(brain.ctx, { operation: 'put_page', params: { slug, request_id: randomUUID(), content: transcript(content) } });
+ });
+ } finally {
+ await disposePersistenceConsumer(brain.engine);
+ engine = outer;
+ }
+ }, { databaseUrl: backend === 'postgres' ? requirePostgresTestDatabase() : undefined });
+ }, 120_000);
+
+ test('a page purge tombstones the page\'s claims but not its outcome row; other pages still complete', async () => {
+ await call('put_page', { slug: 'meetings/purged', content: transcript('Purged') });
+ await extract(['meetings/purged'], [PURGED], { n: 0 });
+ expect(await completed(['meetings/purged'])).toEqual(['meetings/purged']);
+ const snapshot = await engine.readPageSnapshot('meetings/purged', { sourceId: 'default', includeDeleted: true });
+ const purge = await call('delete_page', { slug: 'meetings/purged', purge: true, request_id: randomUUID(), expected_revision: snapshot!.revision });
+ expect(purge.status).toBe('purged');
+ const [claim] = await engine.executeRaw<{ n: number | string }>(`SELECT count(*)::int AS n FROM fact_purges WHERE source_id='default' AND fact_hash=gbrain_fact_fingerprint($1)`, [PURGED]);
+ expect(Number(claim?.n)).toBe(1);
+ expect(await markerTombstones()).toBe(0);
+ await call('put_page', { slug: 'meetings/next', content: transcript('Next') });
+ const run1 = await extract(['meetings/next'], [KEPT, PURGED], { n: 0 });
+ expect(run1.facts_skipped_purged).toBe(1);
+ expect(await completed(['meetings/next'])).toEqual(['meetings/next']);
+ const second = { n: 0 };
+ expect((await extract(undefined, [KEPT], second)).pages_processed).toBe(0);
+ expect(second.n).toBe(0);
+ });
+
+ test('a user claim with the marker text keeps the #7438 skip; forget and purge leave outcome rows alone', async () => {
+ await tombstone('EXTRACTION_COMPLETE');
+ await call('put_page', { slug: 'meetings/run-1', content: transcript('Run 1') });
+ const run = await extract(['meetings/run-1'], [KEPT, 'EXTRACTION_COMPLETE'], { n: 0 });
+ expect(run.facts_skipped_purged).toBe(1);
+ expect(run.facts_inserted).toBe(1);
+ const [marker] = await engine.executeRaw<{ id: number | string }>(`SELECT id FROM facts WHERE source_id='default' AND source=$1 AND expired_at IS NULL`, [TERMINAL_AUDIT_SOURCE]);
+ expect(marker).toBeDefined();
+ const forgot = await call('forget_fact', { id: Number(marker!.id), request_id: randomUUID() });
+ expect(forgot.withdrawn ?? false).toBe(false);
+ const purged = await dispatchToolCall(engine, 'purge_fact', { id: Number(marker!.id), dry_run: true }, { remote: false });
+ expect(purged.isError).toBe(true);
+ expect(purged.content[0]!.text).toContain('fact_not_found');
+ const [withdrawals] = await engine.executeRaw<{ n: number | string }>(`SELECT count(*)::int AS n FROM fact_withdrawals WHERE source_id='default'`);
+ expect(Number(withdrawals?.n)).toBe(0);
+ expect(await completed(['meetings/run-1'])).toEqual(['meetings/run-1']);
+ });
+
+ test('the facts insert guard exempts only the exact outcome row: another claim under the audit source is still refused', async () => {
+ await call('put_page', { slug: 'meetings/run-1', content: transcript('Run 1') });
+ await extract(['meetings/run-1'], [KEPT], { n: 0 });
+ await tombstone(PURGED);
+ await tombstone('EXTRACTION_COMPLETE');
+ const insert = (text: string) => engine.executeRaw(`INSERT INTO facts(source_id, source_markdown_slug, row_num, fact, kind, visibility, source, confidence, notability)
+ SELECT source_id, source_markdown_slug, 1000 + row_num, $1, kind, visibility, source, confidence, notability FROM facts
+ WHERE source_id='default' AND source=$2 AND expired_at IS NULL LIMIT 1`, [text, TERMINAL_AUDIT_SOURCE]);
+ await expect(insert(PURGED)).rejects.toThrow(/purged_content/);
+ await insert('EXTRACTION_COMPLETE');
+ });
+ });
+}
diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-default.json b/test/fixtures/goldens/catalog/pglite-engine-init-default.json
index cce10da76a..cd1677c556 100644
--- a/test/fixtures/goldens/catalog/pglite-engine-init-default.json
+++ b/test/fixtures/goldens/catalog/pglite-engine-init-default.json
@@ -552,7 +552,7 @@
"gbrain_fts_input(t text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[search_path=pg_catalog, pg_temp] body_sha256=c73d0dbc333c6dccc9714a6b8d1b7785f48170556b9024002ddca1c80b25d87d",
"gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803",
"gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=aa01528006dd7029eac6808e0233991524c9de9dc14aaf41f44160d67a747042",
- "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=b794bdc82a9818e1b53738ee7476788cfc05929dd7fcde8b3d07d9a3e221fe59",
+ "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=027c16bf0f61101510f54966dfa7d3c5f90112cef52a51861adc36103a0bc02b",
"gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=66b6cd26959d68687e6bec2314d10594bd2e20c5013638cad41c2d872a999eda",
"gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=962d9fc19fc77ad54fe532d5003e28cbc428d17522612067975b7703d1fcb0c0",
"gbrain_guard_skill_publication()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=e854c0d058e75a65c3a90127c5c417380975100e83fc34288f6085e786df10a9",
diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json
index c9e850e28b..088ea0dc9c 100644
--- a/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json
+++ b/test/fixtures/goldens/catalog/pglite-engine-init-fts-portuguese.json
@@ -552,7 +552,7 @@
"gbrain_fts_input(t text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[search_path=pg_catalog, pg_temp] body_sha256=c73d0dbc333c6dccc9714a6b8d1b7785f48170556b9024002ddca1c80b25d87d",
"gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803",
"gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=aa01528006dd7029eac6808e0233991524c9de9dc14aaf41f44160d67a747042",
- "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=b794bdc82a9818e1b53738ee7476788cfc05929dd7fcde8b3d07d9a3e221fe59",
+ "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=027c16bf0f61101510f54966dfa7d3c5f90112cef52a51861adc36103a0bc02b",
"gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=66b6cd26959d68687e6bec2314d10594bd2e20c5013638cad41c2d872a999eda",
"gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=962d9fc19fc77ad54fe532d5003e28cbc428d17522612067975b7703d1fcb0c0",
"gbrain_guard_skill_publication()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=e854c0d058e75a65c3a90127c5c417380975100e83fc34288f6085e786df10a9",
diff --git a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json
index b18a529863..bde5cf78c4 100644
--- a/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json
+++ b/test/fixtures/goldens/catalog/pglite-engine-init-high-dims.json
@@ -552,7 +552,7 @@
"gbrain_fts_input(t text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[search_path=pg_catalog, pg_temp] body_sha256=c73d0dbc333c6dccc9714a6b8d1b7785f48170556b9024002ddca1c80b25d87d",
"gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803",
"gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=aa01528006dd7029eac6808e0233991524c9de9dc14aaf41f44160d67a747042",
- "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=b794bdc82a9818e1b53738ee7476788cfc05929dd7fcde8b3d07d9a3e221fe59",
+ "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=027c16bf0f61101510f54966dfa7d3c5f90112cef52a51861adc36103a0bc02b",
"gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=66b6cd26959d68687e6bec2314d10594bd2e20c5013638cad41c2d872a999eda",
"gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=962d9fc19fc77ad54fe532d5003e28cbc428d17522612067975b7703d1fcb0c0",
"gbrain_guard_skill_publication()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=e854c0d058e75a65c3a90127c5c417380975100e83fc34288f6085e786df10a9",
diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-default.json b/test/fixtures/goldens/catalog/postgres-engine-init-default.json
index 679f506729..70e15a7051 100644
--- a/test/fixtures/goldens/catalog/postgres-engine-init-default.json
+++ b/test/fixtures/goldens/catalog/postgres-engine-init-default.json
@@ -555,7 +555,7 @@
"gbrain_fts_input(t text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[search_path=pg_catalog, pg_temp] body_sha256=c73d0dbc333c6dccc9714a6b8d1b7785f48170556b9024002ddca1c80b25d87d",
"gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803",
"gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=aa01528006dd7029eac6808e0233991524c9de9dc14aaf41f44160d67a747042",
- "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=b794bdc82a9818e1b53738ee7476788cfc05929dd7fcde8b3d07d9a3e221fe59",
+ "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=027c16bf0f61101510f54966dfa7d3c5f90112cef52a51861adc36103a0bc02b",
"gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=66b6cd26959d68687e6bec2314d10594bd2e20c5013638cad41c2d872a999eda",
"gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=962d9fc19fc77ad54fe532d5003e28cbc428d17522612067975b7703d1fcb0c0",
"gbrain_guard_skill_publication()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=e854c0d058e75a65c3a90127c5c417380975100e83fc34288f6085e786df10a9",
diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json b/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json
index 76f858197d..e886b06e30 100644
--- a/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json
+++ b/test/fixtures/goldens/catalog/postgres-engine-init-fts-portuguese.json
@@ -555,7 +555,7 @@
"gbrain_fts_input(t text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[search_path=pg_catalog, pg_temp] body_sha256=c73d0dbc333c6dccc9714a6b8d1b7785f48170556b9024002ddca1c80b25d87d",
"gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803",
"gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=aa01528006dd7029eac6808e0233991524c9de9dc14aaf41f44160d67a747042",
- "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=b794bdc82a9818e1b53738ee7476788cfc05929dd7fcde8b3d07d9a3e221fe59",
+ "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=027c16bf0f61101510f54966dfa7d3c5f90112cef52a51861adc36103a0bc02b",
"gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=66b6cd26959d68687e6bec2314d10594bd2e20c5013638cad41c2d872a999eda",
"gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=962d9fc19fc77ad54fe532d5003e28cbc428d17522612067975b7703d1fcb0c0",
"gbrain_guard_skill_publication()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=e854c0d058e75a65c3a90127c5c417380975100e83fc34288f6085e786df10a9",
diff --git a/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json b/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json
index e55c2dc01b..f2024ae829 100644
--- a/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json
+++ b/test/fixtures/goldens/catalog/postgres-engine-init-high-dims.json
@@ -555,7 +555,7 @@
"gbrain_fts_input(t text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[search_path=pg_catalog, pg_temp] body_sha256=c73d0dbc333c6dccc9714a6b8d1b7785f48170556b9024002ddca1c80b25d87d",
"gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803",
"gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=aa01528006dd7029eac6808e0233991524c9de9dc14aaf41f44160d67a747042",
- "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=b794bdc82a9818e1b53738ee7476788cfc05929dd7fcde8b3d07d9a3e221fe59",
+ "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=027c16bf0f61101510f54966dfa7d3c5f90112cef52a51861adc36103a0bc02b",
"gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=66b6cd26959d68687e6bec2314d10594bd2e20c5013638cad41c2d872a999eda",
"gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=962d9fc19fc77ad54fe532d5003e28cbc428d17522612067975b7703d1fcb0c0",
"gbrain_guard_skill_publication()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=e854c0d058e75a65c3a90127c5c417380975100e83fc34288f6085e786df10a9",
diff --git a/test/fixtures/goldens/migrations/records.json b/test/fixtures/goldens/migrations/records.json
index 32a61f5aac..3c79e8ccb0 100644
--- a/test/fixtures/goldens/migrations/records.json
+++ b/test/fixtures/goldens/migrations/records.json
@@ -1,6 +1,6 @@
{
"golden": {
- "count": 273,
+ "count": 274,
"gaps": [
17,
18,
@@ -92,7 +92,7 @@
"verifyProjectionStatistics": "0d231b04ecfbc5a4109d6fca9567bf4e8c9e9db6c3fbbb35212e026579ed6f67",
"withSchemaLockTimeout": "95605bd3004955e11e936c7a4aa6889319b401098abf9db18ef3e48da2c3fc59"
},
- "latest": 278,
+ "latest": 279,
"records": [
{
"handler": {
@@ -4214,8 +4214,8 @@
"idempotent": true,
"name": "set_based_fact_insert_guards",
"sql": {
- "length": 8343,
- "sha256": "d01ea4d8a212485932351ad8473d54ef7d0b65f4d5b59b1ba34e4b63bf20b4bb"
+ "length": 8575,
+ "sha256": "7a76b08224ef82c7034f93c983b82effc7e5bb54a4b734182541967bb478caec"
},
"sqlFor": "absent",
"transaction": "absent",
@@ -4518,6 +4518,19 @@
"transaction": "absent",
"verify": "absent",
"version": 278
+ },
+ {
+ "handler": "absent",
+ "idempotent": true,
+ "name": "outcome_markers_skip_purge_guard",
+ "sql": {
+ "length": 2560,
+ "sha256": "95449fe0798457014873642724ad5da8fc97db0bb9cbb94d3b8c22c01b303a3b"
+ },
+ "sqlFor": "absent",
+ "transaction": "absent",
+ "verify": "absent",
+ "version": 279
}
],
"versions": [
@@ -4793,7 +4806,8 @@
275,
276,
277,
- 278
+ 278,
+ 279
]
},
"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.json
index 870fde3de5..aedf71f495 100644
--- a/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
+++ b/test/fixtures/goldens/pglite-upgrade-replay/catalog-after-boot.json
@@ -552,7 +552,7 @@
"gbrain_fts_input(t text)": "RETURNS text kind=f lang=sql volatility=i secdef=false config=[search_path=pg_catalog, pg_temp] body_sha256=c73d0dbc333c6dccc9714a6b8d1b7785f48170556b9024002ddca1c80b25d87d",
"gbrain_graduation_fence()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=cd4642fe8deee2a3c14ef41f53862f0a449b2d8a10e47177bd4f5d2e05ce8803",
"gbrain_guard_effect_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=aa01528006dd7029eac6808e0233991524c9de9dc14aaf41f44160d67a747042",
- "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=b794bdc82a9818e1b53738ee7476788cfc05929dd7fcde8b3d07d9a3e221fe59",
+ "gbrain_guard_inserted_facts()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=027c16bf0f61101510f54966dfa7d3c5f90112cef52a51861adc36103a0bc02b",
"gbrain_guard_protocol_activation()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=66b6cd26959d68687e6bec2314d10594bd2e20c5013638cad41c2d872a999eda",
"gbrain_guard_request_protocol()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=962d9fc19fc77ad54fe532d5003e28cbc428d17522612067975b7703d1fcb0c0",
"gbrain_guard_skill_publication()": "RETURNS trigger kind=f lang=plpgsql volatility=v secdef=false config=[search_path=pg_catalog, public, pg_temp] body_sha256=e854c0d058e75a65c3a90127c5c417380975100e83fc34288f6085e786df10a9",
diff --git a/test/postgres-unit-arms.txt b/test/postgres-unit-arms.txt
index 0ba0d1862a..1a1fadaa21 100644
--- a/test/postgres-unit-arms.txt
+++ b/test/postgres-unit-arms.txt
@@ -44,6 +44,7 @@ test/company-brain-policy.test.ts
test/company-brain-runtime.test.ts
test/consolidate-fenced-close-reimport.test.ts
test/consolidate-same-instant-6023.test.ts
+test/conversation-facts-outcome-marker-purge-7778.test.ts
test/conversation-facts-oversized-sidecar.test.ts
test/conversation-facts-purged-claim-7438.test.ts
test/cycle/synthesize-concepts-merge.test.ts