Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix: saved-facts corrections stay with their own entity
garrytane9f1288a609f
diff --git a/docs/architecture/RETRIEVAL.md b/docs/architecture/RETRIEVAL.mdindex 5777264e3c..52c360073e 100644--- a/docs/architecture/RETRIEVAL.md+++ b/docs/architecture/RETRIEVAL.md@@ -360,9 +360,14 @@ Two cross-cutting seams sit around the pipeline rather than inside it:acknowledgement saved after a correction does not crowd it out. Anacknowledgement corrects nothing: a cue fact that adds no figure (a numberother than a date such as "14 Oct" or a time) to the older fact, when it restates one of its- figures or the older fact is itself a correction. The cue is a fixed word list, so- an unmarked correction is not caught and a marked unrelated post can relabel- a fact; nothing stored changes.+ figures or the older fact is itself a correction, or when it states no figure+ and withdraws nothing ("thanks for the correction"). A cue fact corrects+ nothing saved under another entity, nothing of higher trust, and nothing whose+ matched names (the first word of a capitalized name, "Orbix" in "Orbix Home+ Goods") it shares none of. Corrections rank newest first under the five-fact+ cap, and a corrected fact whose correction does not fit is left out. The cue+ is a fixed word list, so an unmarked correction is not caught; nothing stored+ changes.- **Temporal fact reserve (default off).** With `search.temporal_fact_reserve=true`,a `query` with a deterministic temporal cue (when, before, after, how long,since, until, ordinal-time words, ISO dates, month names) and a token budgetdiff --git a/docs/architecture/key-files/entity-recall.md b/docs/architecture/key-files/entity-recall.mdindex db5f7eb28b..64efcf6f6d 100644--- a/docs/architecture/key-files/entity-recall.md+++ b/docs/architecture/key-files/entity-recall.md@@ -24,7 +24,7 @@ card and `get_backlinks`. Guide: [entity recall](../../guides/entity-recall.md).- `src/core/verbs/entity-card-identity.ts` — the `entity` card's `aka_sources`, `identity_siblings`, `identity_excerpt` (verbatim lines of the page and its siblings from `sanitizeRemoteBody`, tiered: declarations, label lines with a name-like value, other label lines, lines with another capitalized run or code; 600 characters per page, 1,200 per card, `identity_excerpt_omitted`), `alias_guidance` (surface-aware) and the `identity_siblings_capped` notice. A segmented page is excerpted from its trusted, withdrawal-overlaid lead (`truthLead`, `EXCERPT_LEAD_BYTES` = 64 KiB, cut back to a whole line), never its body getters; the card equals the inline page's when the qualifying lines sit in that lead (`test/large-pages/segmented-read-refusals.test.ts`). `readSiblingIdentity` is its siblings-and-aliases half (one alias read for the page and its siblings; optional preloaded mention policy and pack), used alone by `entity names[]`. Tests: `test/mentions-identity-siblings.test.ts`.- `src/core/search/alias-fanout.ts` — search and query's alias fan-out: `resolveQueryEntity` (query n-grams up to 4 tokens through `resolveAliases` and linkable exact titles, longest first, capitalized or code-shaped unless a multi-word n-gram resolves to one page, case-sensitive aliases as written, a tie only when the pages are identity siblings), the names of the entity and its siblings by origin then length, at most `search.alias_fanout_max` (4) keyword queries of 5 rows (`searchAliasRequired`: the name as a required websearch phrase, ranked by the query's other terms through `SearchOpts.rankQuery` on both engines), at most 8 spliced rows with `matched_alias`, and the `fanout` meta (`alias_fanout` notice when capped). Offset 0 only. `resolving` takes the handler's `resolveQueryEntity` started before the search, so its reads overlap it. Tests: `test/search-alias-fanout.test.ts`, `test/search-other-names.test.ts`, `test/e2e/mentions-parity.test.ts`. `wholeQueryEntityNames`: when the whole query is one entity's name or alias, `match: "keyword"` lists pages matching any of its names (one websearch OR of phrases; `match_names` in the meta and the count line; rows found by another name carry `matched_alias`). `resolveQueryEntities` returns every entity a text names; its alias, linkable-title and case-sensitive alias reads run concurrently (`test/search-entity-resolve-concurrency.test.ts`).- `src/core/search/entity-facts.ts` — `entitySavedFacts`: when a search names an entity, its newest active saved facts (`factEntitySlugs`, 5) lead the model-visible saved-facts block, then up to 3 facts each of up to 2 entities those facts name (`linked_from`), before the word-overlap matches. Same active, audit-row and visibility rules as recall. Tests: `test/memory-sibling-facts.test.ts`.-- `src/core/search/saved-facts-match.ts` — `matchingSavedFacts`, the word-matched saved facts `search` and `query` report in `retrieval.saved_facts` after the named entity's facts (`ops/search.ts` `buildRetrievalResponseMeta`). Words match whole after stemming with the facts keyword index's expression (`factsFtsDocument`), CJK words as substrings; a fact needs three quarters of the query's words, at most four, question-framing words (`QUESTION_FRAME_WORDS`: count, number, total, amount) not counted; most matched words first, then newest (time, then id), at most five after the #7043 collapse. One statement behind the facts-only EXISTS probe (`test/search/saved-facts-probe.test.ts`). `search.saved_facts_supersede` (default on; `false` turns it off): a newer fact with a correction cue that shares two matched words with a returned fact is returned too, even below the threshold, and the facts it corrects move last with `corrected_by` (the newest correction); every correction of a returned fact comes back; a cue fact that adds no figure to the older fact (`figures`: numbers, with ISO and day-month dates and times left out; `CORRECTION_CUE` leaves out "corrected"/"correcting", which report a correction) corrects nothing when it restates one of its figures or the older fact is itself a correction. Also owns `FACT_MATCH_STOPWORDS`. Tests: `test/search-saved-facts-match.test.ts`, `test/search-saved-facts.test.ts`.+- `src/core/search/saved-facts-match.ts` — `matchingSavedFacts`, the word-matched saved facts `search` and `query` report in `retrieval.saved_facts` after the named entity's facts (`ops/search.ts` `buildRetrievalResponseMeta`). Words match whole after stemming with the facts keyword index's expression (`factsFtsDocument`), CJK words as substrings; a fact needs three quarters of the query's words, at most four, question-framing words (`QUESTION_FRAME_WORDS`: count, number, total, amount) not counted; most matched words first, then newest (time, then id), at most five after the #7043 collapse. One statement behind the facts-only EXISTS probe (`test/search/saved-facts-probe.test.ts`). `search.saved_facts_supersede` (default on; `false` turns it off): a newer fact with a correction cue that shares two matched words with a returned fact is returned too, even below the threshold, and the facts it corrects move last with `corrected_by` (the newest correction); every correction of a returned fact comes back; a cue fact that adds no figure to the older fact (`figures`: numbers, with ISO and day-month dates and times left out; `CORRECTION_CUE` leaves out "corrected"/"correcting", which report a correction) corrects nothing when it restates one of its figures or the older fact is itself a correction, nor when it states no figure and withdraws nothing (`RETRACTION`); nor does one saved under another entity, of lower trust, or sharing none of the older fact's matched names (`namedWords`). Correctors rank newest first under the cap and a corrected fact whose corrector is cut is dropped; `buildRetrievalResponseMeta` carries `corrected_by` onto the entity copy. Also owns `FACT_MATCH_STOPWORDS`. Tests: `test/search-saved-facts-match.test.ts`, `test/search-saved-facts.test.ts`.- `src/core/schema-migrations/v206-entity-mention-index.ts` — additive: `page_aliases.origin` (`frontmatter` default, `declared`, `subject`), `case_sensitive`, `alias_text`, unique key `(source_id, alias_norm, slug, origin)`; tables `page_mention_state`, `mention_gazetteer_entries`, `mention_index_status` (RLS on when the role bypasses RLS). `GUARDED_TABLE_COLUMNS` lists the new `page_aliases` columns.Alias readers apply precedence frontmatter > declared > subject per source, and a derived alias never answers for another live page's exact title that the caller can read (the title competitor gets the caller's `pageReadFilter`, so a private title a private-excluding caller can't see never hides a readable alias) (`readAliases` in `src/core/search/read-enrichment.ts`, shared by both engines' `resolveAliases`), so `resolveEntitySlug`, the retrieval reflex, the alias hop, intent weights and `search-diagnose` rank an exact title first. `buildGazetteer` (`src/core/by-mention.ts`) applies the same precedence, drops an alias claimed by two pages at its best origin (unless the claimants are identity siblings, which all keep it), yields to a same-source title, drops a single-word alias equal to the first word of another multi-word entity name, applies the generic-word list to every single-word name, and carries `caseTokens` for case-sensitive entries; `opts.dropped` records every dropped name with its reason.diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex c93db1c761..2a4c18cc3a 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -1344,7 +1344,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText;// GBRA-205: Garry approved the default ("Yes", 2026-10-26), on the sealed held-out result (gbrain-evals docs/benchmarks/2026-10-26-gbrain-8k-conversion.md).{ since: '0.60.491.0', text: '`query` with a token budget now puts question-ranked dated saved facts ahead of the pages (the facts block): up to 22% of the budget and 40 rows, oldest first, each with its date header, in place of the facts arm (and of the temporal fact reserve when it is on). On a sealed held-out set of 200 questions it answered 183 against 151 without it. It adds about 70 tokens to a median budgeted result (p95 about 700) and no model call. Queries without a budget, `search` and `think` are unchanged; remote callers see only facts whose source pages they could read. `gbrain config set search.query_facts_block false` restores the previous results.' },// GBRA-205 saved-facts wave (harness case cr-05). `since` is stamped at the merge slot.- { since: 'TBD', id: 'saved_facts_stems', text: 'Search `saved_facts` matches a saved fact\'s words the way the facts keyword index does: whole words after stemming with the brain\'s full-text language, so a query for "seats renewal" finds a fact that says "renews at 52 seats", and "count" no longer matches inside "countersigned". A fact still needs three quarters of the query\'s words, and never more than four, so a question asked in full finds the short fact that answers it, not counting words that frame a question about a figure (count, number, total, amount); words of a CJK script still match as substrings. Among facts matching as many words, the newest comes first, and at most five facts ride a reply. On by default (`gbrain config set search.saved_facts_supersede false` turns it off): search also returns a newer fact with a correction cue that shares two matched words with a returned fact, ahead of the fact it corrects, which is labelled `corrected_by`; every such correction comes back, not only the newest, and an acknowledgement that adds no figure (dates left out) corrects nothing, and a reply that only reports a correction ("corrected", "correcting") makes none.' },+ { since: 'TBD', id: 'saved_facts_stems', text: 'Search `saved_facts` matches a saved fact\'s words the way the facts keyword index does: whole words after stemming with the brain\'s full-text language, so a query for "seats renewal" finds a fact that says "renews at 52 seats", and "count" no longer matches inside "countersigned". A fact still needs three quarters of the query\'s words, and never more than four, so a question asked in full finds the short fact that answers it, not counting words that frame a question about a figure (count, number, total, amount); words of a CJK script still match as substrings. Among facts matching as many words, the newest comes first, and at most five facts ride a reply. On by default (`gbrain config set search.saved_facts_supersede false` turns it off): search also returns a newer fact with a correction cue that shares two matched words with a returned fact, ahead of the fact it corrects, which is labelled `corrected_by`; every such correction comes back, not only the newest, and an acknowledgement that adds no figure (dates left out) corrects nothing, and a reply that only reports a correction ("corrected", "correcting") makes none; nor does a cue fact saved under another entity, of lower trust, or sharing none of the names the older fact matched.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */diff --git a/src/core/ops/search.ts b/src/core/ops/search.tsindex 3b01af77d2..55cc5c2c12 100644--- a/src/core/ops/search.ts+++ b/src/core/ops/search.ts@@ -432,8 +432,16 @@ async function buildRetrievalResponseMeta(// A fact the facts arm already returned as a row is not repeated beside the blocks.const factRowIds = new Set((results as SearchResult[]).flatMap(r => r.fact_row ? [r.fact_row.id] : []));// #7043: a matched fact may copy an entity fact; the merged list collapses again before the response.- const savedFacts = (await collapseFactReads(ctx.engine, [...entityFacts, ...matchedFacts.filter(m => !entityFacts.some(e => e.id === m.id))]- .filter(f => !factRowIds.has(f.id)))).map(stripCollapseColumns);+ // An entity fact keeps the corrected_by its matched copy carries, and a label follows its corrector into the collapse.+ const correctedBy = new Map(matchedFacts.flatMap(m => m.corrected_by ? [[m.id, m.corrected_by] as const] : []));+ const merged = await collapseFactReads(ctx.engine, [...entityFacts.map(e => ({ ...e, corrected_by: correctedBy.get(e.id) })),+ ...matchedFacts.filter(m => !entityFacts.some(e => e.id === m.id))].filter(f => !factRowIds.has(f.id)));+ const shownAs = new Map([...factRowIds].map(id => [id, id]));+ for (const f of merged) for (const id of f.collapsed_ids ?? [f.id]) shownAs.set(id, f.id);+ const savedFacts = merged.map(({ corrected_by, ...f }) => {+ const by = corrected_by === undefined ? undefined : shownAs.get(corrected_by);+ return stripCollapseColumns(by === undefined || by === f.id ? f : { ...f, corrected_by: by });+ });const heldTotal = [...heldBySource.values()].reduce((sum, n) => sum + n, 0);const embedding = embeddingHeld?.total ? embeddingHeld : null;const coverage: RetrievalCoverage | undefined = pending || heldTotal || embedding ? {diff --git a/src/core/search/saved-facts-match.ts b/src/core/search/saved-facts-match.tsindex 8b8c81182b..dcf218184e 100644--- a/src/core/search/saved-facts-match.ts+++ b/src/core/search/saved-facts-match.ts@@ -7,7 +7,7 @@* test/search/saved-facts-probe.test.ts.*/import type { OperationContext } from '../ops/contract.ts';-import { TRUST_TIER_RANK, trustRankSql, type TrustTier } from '../trust/tier.ts';+import { trustRankSql, type TrustTier } from '../trust/tier.ts';import { AUDIT_ROW_SOURCES } from '../facts/audit-sources.ts';import { collapseFactReads } from '../facts/capture-dedup.ts';import { projectionEligibleSql } from '../eligibility/sql.ts';@@ -30,12 +30,21 @@ export interface SavedFactMatch { id: number; fact: string; entity_slug: string/** Default on (set false to turn off): a newer saved fact carrying a correction cue is returned ahead of the older fact it corrects, which is labelled `corrected_by`. */export const SAVED_FACTS_SUPERSEDE_KEY = 'search.saved_facts_supersede';+/** Cues that withdraw what was said, so they correct without stating a new figure. */+const RETRACTION = String.raw`retract(s|ed|ing|ion)?|disregard|scratch that|i misspoke|i was wrong|not what (i|we) (posted|said|wrote)|ignore (the|my|that|what)`;+const RETRACTION_CUE = new RegExp(String.raw`\b(${RETRACTION})\b`, 'i');/** What marks a saved fact as making a correction (Postgres ARE, matched case-insensitively); "corrected" and "correcting" report one made elsewhere. */-const CORRECTION_CUE = String.raw`\m(correction|retract(s|ed|ing|ion)?|disregard|scratch that|i misspoke|i was wrong|not what (i|we) (posted|said|wrote)|ignore (the|my|that|what))\M`;+const CORRECTION_CUE = String.raw`\m(correction|${RETRACTION})\M`;const MONTH = String.raw`(?:jan(?:uary)?|feb(?:ruary)?|mar(?:ch)?|apr(?:il)?|may|june?|july?|aug(?:ust)?|sep(?:t(?:ember)?)?|oct(?:ober)?|nov(?:ember)?|dec(?:ember)?)\b\.?`;const DATES = new RegExp(String.raw`\b\d{4}-\d{2}-\d{2}(?:[ T]\d{2}:\d{2}(?::\d{2})?)?|\b\d{1,2}:\d{2}\b|\b\d{1,2}(?:st|nd|rd|th)? ${MONTH}|\b${MONTH} \d{1,2}(?:st|nd|rd|th)?\b`, 'gi');+/** The query words a fact writes as the first word of a name ("Orbix" in "Orbix Home Goods", not "Example" in "Alice Example"); term indexes are 1-based. */+function namedWords(text: string, terms: string[], words: Set<number>): Set<number> {+ return new Set([...words].filter(i => [...text.matchAll(new RegExp(String.raw`(?<![\p{L}\p{N}])${terms[i - 1]}`, 'giu'))]+ .some(m => m[0][0] !== m[0][0]!.toLowerCase() && !/\p{Lu}[\p{L}\p{N}'-]*\s+$/u.test(text.slice(0, m.index)))));+}+/** The figures a fact states: its numbers, with dates ("2026-10-14", "14 Oct", "July 1") and clock times left out. */function figures(text: string): Set<string> {return new Set(text.replace(DATES, ' ').match(/\d+(?:[.,]\d+)*/g) ?? []);@@ -69,9 +78,10 @@ async function savedFactsSupersedeEnabled(engine: { getConfig(key: string): Prom* corrects, labelled `corrected_by`. An acknowledgement corrects nothing: a cue* fact that adds no figure (a number other than a date or time) to the older* fact, when it restates one of its figures or the older fact is itself a- * correction. Nor does a cue fact about another entity, or one below- * agent_written trust correcting a fact of higher trust. A corrected fact whose- * corrector the five-fact cap leaves out is dropped.+ * correction. Nor does a cue fact about another entity, one missing every+ * name the older fact starts with a matched word, one of lower trust, or one+ * stating no figure that withdraws nothing. A corrected fact whose corrector+ * the five-fact cap leaves out is dropped.*/export async function matchingSavedFacts(ctx: OperationContext, scope: { sourceId?: string; sourceIds?: string[]; minTrust?: TrustTier }, queryText: string, otherNames: string[] = []): Promise<Array<SavedFactMatch & CollapseColumns>> {// A query naming one of two declared names also matches facts saved under the other.@@ -129,7 +139,8 @@ export async function matchingSavedFacts(ctx: OperationContext, scope: { sourceI[sources, [...AUDIT_ROW_SOURCES], terms, terms.map(t => hasCJK(t) ? `%${t.replace(/[\\%_]/g, m => `\\${m}`)}%` : null), CORRECTION_CUE, supersede],);const found = rows.map(({ at, matched, need, cue, trust_rank, pool_rank: _p, ...fact }) => ({ fact: { ...fact, id: Number(fact.id) } as SavedFactMatch & CollapseColumns,- at: new Date(at as string).getTime(), words: new Set(matched.map(Number)), need: Number(need), cue, trust: Number(trust_rank), figures: figures(fact.fact) }));+ at: new Date(at as string).getTime(), words: new Set(matched.map(Number)), need: Number(need), cue, trust: Number(trust_rank), figures: figures(fact.fact) }))+ .map(r => ({ ...r, names: namedWords(r.fact.fact, terms, r.words) }));const admitted = found.filter(r => r.words.size >= r.need);const correcting = new Set<number>();if (supersede) {@@ -138,11 +149,13 @@ export async function matchingSavedFacts(ctx: OperationContext, scope: { sourceI// Posts saved in one flush share a time; the later id is the later post.// An acknowledgement is not a correction: a cue fact that adds no figure to the older fact// corrects it only when it restates no figure and the older fact is not a correction itself.- // A cue fact about another entity corrects nothing, and one below agent_written corrects only facts at or below its tier.+ // A cue fact corrects nothing about another entity, nor a fact whose matched names it shares none of, nor one of+ // higher trust; one stating no figure corrects only by withdrawing ("disregard"), never by a bare "correction".const corrections = cues.filter(n => (n.at > older.at || (n.at === older.at && n.fact.id > older.fact.id))&& (!n.fact.entity_slug || !older.fact.entity_slug || n.fact.entity_slug === older.fact.entity_slug)- && (n.trust >= TRUST_TIER_RANK.agent_written || n.trust >= older.trust)+ && (older.names.size === 0 || [...older.names].some(w => n.words.has(w))) && n.trust >= older.trust&& [...n.words].filter(w => older.words.has(w)).length >= Math.min(2, n.need)+ && (n.figures.size > 0 || RETRACTION_CUE.test(n.fact.fact))&& !([...n.figures].every(x => older.figures.has(x)) && (n.figures.size > 0 || older.cue))).sort((a, b) => b.at - a.at || b.fact.id - a.fact.id);if (corrections.length) older.fact.corrected_by = corrections[0].fact.id;for (const c of corrections) correcting.add(c.fact.id);diff --git a/test/search-saved-facts-match.test.ts b/test/search-saved-facts-match.test.tsindex d7d0a7ff4f..ee13c95b02 100644--- a/test/search-saved-facts-match.test.ts+++ b/test/search-saved-facts-match.test.ts@@ -274,7 +274,7 @@ describe('search.saved_facts_supersede: the five-fact cap', () => {});});// Value: protects=a corrector outside the top 200 candidates still corrects; fails_when=200 full matches push a two-word cue row past the cut; why_new=no fixture had more than a handful of matching facts; seam=none; no_claim=query cost on a large facts table-// Value: protects=a fact naming another entity, or written below agent_written, never demotes a better fact; fails_when=a cue fact with shared words and a new figure demotes any older fact; why_new=every earlier corrector shared the corrected fact's entity and tier; seam=none; no_claim=two writers at one tier disagreeing+// Value: protects=a fact naming another entity, or of lower trust, never demotes the fact it names; fails_when=a cue fact with shared words and a new figure demotes any older fact; why_new=every earlier corrector shared the corrected fact's entity and tier; seam=none; no_claim=two writers at one tier disagreeingdescribe('search.saved_facts_supersede: which cue facts can correct', () => {test('a cue fact past the first 200 full matches still comes back as the correction', async () => {await engine.setConfig(SAVED_FACTS_SUPERSEDE_KEY, 'true');@@ -289,7 +289,7 @@ describe('search.saved_facts_supersede: which cue facts can correct', () => {}}, 120_000);- test('a cue fact about another entity, or below agent_written and the fact it names, does not correct', async () => {+ test('a cue fact about another entity, or of lower trust than the fact it names, does not correct', async () => {await engine.setConfig(SAVED_FACTS_SUPERSEDE_KEY, 'true');try {const base = await remember('Torvane Logistics renews at 40 seats.', '2026-02-01T09:00:00Z');@@ -330,3 +330,44 @@ describe('search.saved_facts_supersede: a chain of corrections under the cap', (}});});+// Value: protects=a correction of one entity's figure never labels another entity's fact, a bare "correction" acknowledgement corrects nothing, and an entity-resolved search keeps the label; fails_when=two shared generic words let a correction cross entities, a figure-free thank-you demotes the figure, or the entity copy replaces the labelled copy; why_new=every earlier fixture named one entity per query and no entity page; seam=none; no_claim=names written in lower case+describe('search.saved_facts_supersede: what a correction must share', () => {+ test('a correction naming another entity does not label a fact on the same two words', async () => {+ await engine.setConfig(SAVED_FACTS_SUPERSEDE_KEY, 'true');+ try {+ const zeta = await remember('Zentic renews at 52 seats.', '2025-10-30T09:00:00Z');+ await remember('Ostrel renews at 52 seats.', '2025-11-01T09:00:00Z');+ await remember('Correction: Ostrel renews at 46 seats, ignore the 52.', '2025-11-02T09:00:00Z');+ const { facts } = await search('Zentic renewal seats');+ expect(facts.map(f => f.id)).toContain(zeta);+ expect(facts.find(f => f.id === zeta)?.corrected_by).toBeUndefined();+ } finally {+ await engine.setConfig(SAVED_FACTS_SUPERSEDE_KEY, 'false');+ }+ });++ test('an acknowledgement with no figure does not correct the fact that states one', async () => {+ await engine.setConfig(SAVED_FACTS_SUPERSEDE_KEY, 'true');+ try {+ const yonder = await remember('Yondrel renews at 52 seats.', '2025-10-01T09:00:00Z');+ await remember('Thanks for the correction on the Yondrel renewal seats, noted.', '2025-10-02T09:00:00Z');+ expect((await search('Yondrel renewal seats')).facts.find(f => f.id === yonder)?.corrected_by).toBeUndefined();+ } finally {+ await engine.setConfig(SAVED_FACTS_SUPERSEDE_KEY, 'false');+ }+ });++ test('a search that resolves the entity keeps the label on the entity copy', async () => {+ await engine.setConfig(SAVED_FACTS_SUPERSEDE_KEY, 'true');+ try {+ await importFromContent(engine, 'companies/halvard-example', serializeMarkdown({}, 'Halvard Example is a customer account.', '', { type: 'company', title: 'Halvard Example', tags: [] }), { noEmbed: true, forceRechunk: true });+ const old = await remember('Halvard Example renews at 40 seats.', '2025-09-01T09:00:00Z');+ const fix = await remember('Correction: Halvard Example is at 35 seats, ignore the 40.', '2025-09-02T09:00:00Z');+ const { facts } = await search('Halvard Example seats');+ expect(facts.map(f => f.id)).toEqual(expect.arrayContaining([old, fix]));+ expect(facts.find(f => f.id === old)?.corrected_by).toBe(fix);+ } finally {+ await engine.setConfig(SAVED_FACTS_SUPERSEDE_KEY, 'false');+ }+ });+});