Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
feat(search): query facts arm on by default (gate 1b: forget-then-remember 92% -> 100% correct, 8% -> 0% stale at both checkpoints; revised gate 2: 0 recall@10 losses in all five sets); search.query_facts_arm=false turns it off
garrytan5f4156a2e7f0
diff --git a/docs/architecture/RETRIEVAL.md b/docs/architecture/RETRIEVAL.mdindex c26c1d49b6..ea8b18b8f2 100644--- a/docs/architecture/RETRIEVAL.md+++ b/docs/architecture/RETRIEVAL.md@@ -298,16 +298,15 @@ Two cross-cutting seams sit around the pipeline rather than inside it:token budget stay what the caller asked for, and anchored rows take at mosthalf the rows. It is skipped with `offset`, type, date, language or symbolfilters. Verdict and gates: `docs/eval/decisions/entity-anchoring-query/`.-- **Facts arm in `query` (default off).** With `search.query_facts_arm=true`,- `query` adds up to three active saved facts that match the question (by the- query embedding it already computed, by shared terms or by a named entity)- as fact rows in spare capacity only (free slots under the caller's row- count, and what the page rows leave of the token budget; a page row is- never displaced), and marks a- page row `superseded_claim` when a newer fact covers its typed claim- (`src/core/search/facts-arm.ts`). No model call. It stays off: in the B2- corrections suite the facts surfaced but the reader kept the old value,- because a remembered fact is dated when it was saved. Verdict and gates:+- **Facts arm in `query` (default on).** `query` adds up to three active+ saved facts that match the question (by the query embedding it already+ computed, by shared terms or by a named entity) as fact rows in spare+ capacity only: free slots under the caller's row count, and what the page+ rows leave of the token budget. A page row is never displaced. It also marks+ a page row `superseded_claim` when a newer fact covers its typed claim+ (`src/core/search/facts-arm.ts`). No model call. In the B2 corrections suite+ with correction-dated writes it lifted forget-then-remember from 92% to 100%+ correct. `search.query_facts_arm=false` turns it off. Verdict and gates:`docs/eval/decisions/query-facts-arm/`.### Use-attributed feedbackdiff --git a/docs/architecture/key-files/core-search-2.md b/docs/architecture/key-files/core-search-2.mdindex 47d7802a9c..4187a3867a 100644--- a/docs/architecture/key-files/core-search-2.md+++ b/docs/architecture/key-files/core-search-2.md@@ -7,8 +7,8 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `src/core/search/evidence-date.ts` — C1 dated evidence blocks: the fixed header grammar (`[observed YYYY-MM-DD|unknown]` for page blocks; `[observed unknown; valid FROM to UNTIL]` for `recall` facts), `pageObservationDate` (effective-date precedence with `event_date` removed and no row-timestamp fallback; mirrors #6020's `resolveObservationDate`, the seam to swap once it lands), `formatBrainDay` (midnight UTC renders as written, other instants in `brain.timezone`; the rule think's page dates use), `loadPageDateHeaders` (one `pages` read per delivery; only the derived day leaves it) and `evidenceDateHeaderEnabled` (`search.evidence_date_header`, default off). Tests: `test/evidence-date-header.test.ts`.- `src/core/search/entity-anchor.ts` — entity-anchored retrieval: `entityAnchoredPages` (the entity page plus up to 10 pages that link to it or name it as a word, newest by `COALESCE(effective_date, updated_at)`; question/synthesis/pinned-question pages excluded) and `prefixAnchoredPages`, shared by pinned-question refresh (`questions/refresh.ts` `anchoredSlugs`) and the `query`/`search` ops; `asksForCurrentState` (deterministic cue regex), `namedEntity` (exactly one `isFactEntityPage` page whose title `isTitleMentionedInQuery` matches, read-policy filtered; a title inside a longer matched title is the same mention); `applyEntityAnchoring` (anchored rows first, at most half the row count, organic rows of the same page moved up, missing pages read through `getChunkWindows` under the caller's scope, rows stamped `entity_anchored`, token budget re-applied, fail-open); `entityAnchoringEnabled` (`search.entity_anchoring`, default off). Tests: `test/search-entity-anchor.test.ts`. Gates: `docs/eval/decisions/entity-anchoring-query/`.-- `src/core/search/facts-arm.ts` — the `query` facts arm behind `search.query_facts_arm` (default off; see its decision record). `matchQueryFacts` reads active facts only (not expired, not superseded, `valid_until` not passed, audit rows excluded) under recall's read policy (source scope; remote callers get world facts with private provenance filtered) and matches them by query-embedding cosine (`FACT_COSINE_MIN` 0.6, the embedding `hybridSearch` already computed, via `HybridSearchOpts.onQueryEmbedding`) or by query-term share (half the terms) or a named entity, newest `valid_from` first, at most `MAX_FACT_ROWS` (3). `applyFactsArm` adds them as `fact_row` rows in spare capacity only: free slots under the caller's row count, and whole rows that fit in what the page rows leave of the token budget; a page row is never displaced and stamps `superseded_claim` on page rows whose typed `claim_metric` (plus `claim_period` when both carry it) a newer active fact covers. No model call. Tests: `test/search-facts-arm.test.ts`. Gates and verdict: `docs/eval/decisions/query-facts-arm/`.-- `src/core/search/query-arms.ts` — `applyQueryArms`: the `query` op's post-retrieval arms in order (entity anchoring, then the facts arm), each behind its own default-off key; with both keys off it returns the rows untouched.+- `src/core/search/facts-arm.ts` — the `query` facts arm behind `search.query_facts_arm` (default on since gates 1b and 2 passed; `false` turns it off). `matchQueryFacts` reads active facts only (not expired, not superseded, `valid_until` not passed, audit rows excluded) under recall's read policy (source scope; remote callers get world facts with private provenance filtered) and matches them by query-embedding cosine (`FACT_COSINE_MIN` 0.6, the embedding `hybridSearch` already computed, via `HybridSearchOpts.onQueryEmbedding`) or by query-term share (half the terms) or a named entity, newest `valid_from` first, at most `MAX_FACT_ROWS` (3). `applyFactsArm` adds them as `fact_row` rows in spare capacity only: free slots under the caller's row count, and whole rows that fit in what the page rows leave of the token budget; a page row is never displaced and stamps `superseded_claim` on page rows whose typed `claim_metric` (plus `claim_period` when both carry it) a newer active fact covers. No model call. Tests: `test/search-facts-arm.test.ts`. Gates and verdict: `docs/eval/decisions/query-facts-arm/`.+- `src/core/search/query-arms.ts` — `applyQueryArms`: the `query` op's post-retrieval arms in order (entity anchoring, then the facts arm), each behind its own key (entity anchoring default off, the facts arm default on); with both off it returns the rows untouched.- `src/core/search/image-vector-presence.ts` — `brainHasImageVectors` (one `EXISTS embedding_image IS NOT NULL` probe per engine, cached 60 s, fail-open to true). `hybrid/arms.ts` uses it so an inferred image/both modality on a brain with no image embeddings stays text: no multimodal embed, keyword arm kept, no `vector_arm_failed`; the opt-in LLM modality tie-break still runs, and an image or both answer is demoted to text. An explicit `crossModal` is honored. Tests: `test/search-image-arm-text-only.test.ts`, `test/cross-modal-hybrid-integration.serial.test.ts`.- `src/core/search/chunk-windows.ts` — request/response shapes and the row mapper for `BrainEngine.getChunkWindows`. The SQL lives once in `src/core/engine-sql/chunks.ts` (`getChunkWindows`): page rows (authorization + seal + max chunk index + raw body columns) and chunk rows (inside the requested chunk_index ranges, text modality, requested chunk sources, row cap) come back in one UNION so the row cap never hides a page's authorization; the predicate is the search legs' (source scope, deleted, current text projection, archived source, quarantine, private pages, safe chunks). Postgres runs it inside the scoped read transaction.diff --git a/docs/eval/decisions/query-facts-arm/README.md b/docs/eval/decisions/query-facts-arm/README.mdindex 0b279a5e3e..9f02f62b1c 100644--- a/docs/eval/decisions/query-facts-arm/README.md+++ b/docs/eval/decisions/query-facts-arm/README.md@@ -1,10 +1,48 @@# Facts arm in query: gates and verdict-The facts arm is built and stays off. It sits behind `search.query_facts_arm` (default off), measured at-garrytan/gbrain@16288b95c. Gate 1 failed as preregistered and gate 2 passed. With the key off, `query` returns-exactly what it returned before the arm existed.+The facts arm is on by default. It sits behind `search.query_facts_arm`, and `false` turns it off. Gate 1b and+the revised gate 2 passed at garrytan/gbrain@947536f4c, the build where fact rows take only spare capacity. Gate+1 failed at 16288b95c, and that failure is recorded below. With the key set to `false`, `query` returns exactly+what it returned before the arm existed.-## Result+## Result: gate 1b and revised gate 2++**Gate 1b passed.** In the B2 corrections suite each correction was dated when it was made. Forget-then-remember+went from 92% correct and 8% stale with the key off to 100% correct and 0% stale with it on, after 1 write and+after 5. The fact row was in the reader's context for all 200 answers after the correction.++Corrected-value accuracy and stale-answer rate per 100 items, reader `claude-sonnet-5-5`, build 947536f4c:++| Arm | Key | Before correction | After 1 write | After 5 writes |+|---|---|---|---|---|+| forget-then-remember | off | 100% / 0% | 92% / 8% | 92% / 8% |+| forget-then-remember | on | 100% / 0% | 100% / 0% | 100% / 0% |+| edit-sync | off and on | 100% / 0% | 100% / 0% | 100% / 0% |+| append | off and on | 100% / 0% | 100% / 0% | 100% / 0% |++Edit-sync and append lose nothing, but the check can't show more than that. Those arms save no facts, so the arm+never added a row there (0 of 600 answers each), and both sit at 100%.++**Revised gate 2 passed.** Fact rows now take only spare capacity, so they never push out a page. No question's+recall@10 is lower with the key on, in any of the five sets:++| Set | Questions | Arm added a row | Recall@10 lower |+|---|---|---|---|+| NamedThingBench | 12 | 0 | 0 |+| Relational retrieval-quality | 38 | 0 | 0 |+| LongMemEval nightly | 10 | 0 | 0 |+| NamedThingBench + one saved fact per question | 12 | 11 | 0 |+| Relational + one saved fact per question | 38 | 38 | 0 (was 2 at 16288b95c) |++The runs are hermetic and keyword-only. The harness reports this rule as `pass_with_facts_diagnostics`.++Spend was $18.05 against a $30 cap. A first attempt that ran out of disk is not in that total. Its records were+lost, but it ran for about two minutes, which by the observed rate cost under $0.50.++**Decision.** `search.query_facts_arm` is on by default. Each `query` now runs up to three extra lookups+on the facts table: terms, embedding and named entity. It makes no model call.++## Result: gate 1 (16288b95c)**Gate 1 failed.** In the B2 corrections suite's forget-then-remember arm, the key moved the stale-answer ratefrom 92% to 4-6%. Corrected-value accuracy went from 0% to 1% after one unrelated write and stayed at 0% after@@ -56,7 +94,7 @@ Records are in `decision.json` (what was tested and how) and `verdict.json` (whamirror carries the two bench flags the gate-1 runs used (`--gbrain-search-config`, `--remember-valid-from`) as apatch.-**Decision.** `search.query_facts_arm` stays off by default.+**Decision at gate 1.** `search.query_facts_arm` stayed off by default.## Gate 1b and revised gate 2: preregistered@@ -164,3 +202,4 @@ stays off. The spend cap is set before the gate 1 run.- 2026-10-05: gates preregistered before any code or gated run.- 2026-10-06: built at 16288b95c and gated. Gate 1 failed, gate 2 passed, and the key stays off.- 2026-10-06: gate 1b (correction-dated writes) and revised gate 2 (fact rows take spare capacity only) preregistered before any of their runs.+- 2026-10-06: gate 1b and revised gate 2 passed at 947536f4c; the key is on by default.diff --git a/docs/eval/decisions/query-facts-arm/decision.json b/docs/eval/decisions/query-facts-arm/decision.jsonindex 85fe663651..83225a5fbf 100644--- a/docs/eval/decisions/query-facts-arm/decision.json+++ b/docs/eval/decisions/query-facts-arm/decision.json@@ -30,7 +30,9 @@"gates": {"1": "B2 corrections (gbrain-evals eval/workload-suites, corrections-v1, seed 20261006, 100 items), forget-then-remember arm key on vs off; pass if key-on corrected-value accuracy is higher at after_1_write and after_5_writes and its stale-answer rate is not higher at either; edit-sync and append lose no more than 2 points with the key on","2": "NamedThingBench, relational retrieval-quality, LongMemEval nightly through the query op key on vs off; recall@10 over page rows; pass if no question's recall@10 is lower with the key on",- "3": "harness lane: LongMemEval knowledge-update and PersonaMem dev slices (optional; not run)"+ "3": "harness lane: LongMemEval knowledge-update and PersonaMem dev slices (optional; not run)",+ "1b": "B2 corrections with --remember-valid-from (remember gets each item's correction_timestamp as valid_from), same suite, seed, items, reader, judge and budget as gate 1; forget-then-remember key on vs off; pass if key-on corrected accuracy is higher at after_1_write and after_5_writes and stale not higher; edit-sync and append lose no more than 2 points with the key on",+ "2_revised": "gate 2's three corpora plus the two one-saved-fact-per-question diagnostic copies; pass if no question's recall@10 is lower with the key on in any of the five"},"decision_rule": "default-on only if gates 1 and 2 pass (and gate 3 if it runs); off until then","budget": {@@ -39,6 +41,30 @@},"reproduce": {"gate_1": "cd gbrain-evals && bun eval/workload-suites/bench.ts corrections --phase answer --arms gbrain-forget-remember --budget-usd 6 --out <dir> --gbrain <gbrain>@16288b95c [--gbrain-search-config search.query_facts_arm=true] [--remember-valid-from]; then the same command with --phase score. The two bracketed flags come from bench-flags.patch in the gbrain-evals mirror of this record, applied to gbrain-evals 00baf2b.",- "gate_2": "bun evals/entity-anchoring/regression.ts --json --key search.query_facts_arm"+ "gate_2": "bun evals/entity-anchoring/regression.ts --json --key search.query_facts_arm",+ "gate_1b": "cd gbrain-evals (d01d3bc or later) && bun eval/workload-suites/bench.ts corrections --phase answer --arms <gbrain-forget-remember | gbrain-edit-sync,gbrain-append> --remember-valid-from [--gbrain-search-config search.query_facts_arm=true] --budget-usd <cap> --out <dir> --gbrain <gbrain>@947536f4c; then --phase score",+ "gate_2_revised": "bun evals/entity-anchoring/regression.ts --json --key search.query_facts_arm (field pass_with_facts_diagnostics)"+ },+ "candidate_gate_1b": {+ "gbrain": "garrytan/gbrain@947536f4c",+ "config": {+ "search.query_facts_arm": "true"+ },+ "change": "fact rows take spare capacity only (free slots under the row count, whole rows into the budget the pages leave)"+ },+ "baselines_gate_1b": [+ {+ "gbrain": "garrytan/gbrain@947536f4c",+ "config": {+ "search.query_facts_arm": "false"+ },+ "note": "same build, same correction-dated writes, key off"+ }+ ],+ "preregistration_gate_1b": "README.md section 'Gate 1b and revised gate 2: preregistered' in garrytan/gbrain@c672352d4 (also gbrain-evals capy/mpw-gbrain-verdicts 0b2a6ae), before any gate 1b or revised gate 2 run",+ "decision_rule_gate_1b": "default-on only if gate 1b and revised gate 2 both pass",+ "budget_gate_1b": {+ "max_usd": 30,+ "metered_spend_usd": 18.05}}diff --git a/docs/eval/decisions/query-facts-arm/verdict.json b/docs/eval/decisions/query-facts-arm/verdict.jsonindex 796e3b6986..8db8886467 100644--- a/docs/eval/decisions/query-facts-arm/verdict.json+++ b/docs/eval/decisions/query-facts-arm/verdict.json@@ -1,9 +1,9 @@{"decision_id": "query-facts-arm","stage": "dev",- "decided_at": "2026-10-06T00:30:00Z",+ "decided_at": "2026-10-06T02:10:00Z","measured_build": "garrytan/gbrain@16288b95c",- "overall": "off_gate_1_failed",+ "overall": "on_gates_1b_and_2_passed","gate_1": {"status": "fail","rule_result": {@@ -233,7 +233,173 @@"gate_3": {"status": "not_run"},- "decision": "search.query_facts_arm stays off by default",+ "decision": "search.query_facts_arm is on by default (gate 1 failed at 16288b95c; gates 1b and revised 2 passed at 947536f4c)","metered_spend_usd": 26.05,- "spend_note": "gate 1 runs 25.56, two 6-probe smokes 0.14, and 0.35 for a duplicate run stopped after 30 probes and not used"+ "spend_note": "gate 1 runs 25.56, two 6-probe smokes 0.14, and 0.35 for a duplicate run stopped after 30 probes and not used",+ "gate_1b": {+ "status": "pass",+ "measured_build": "garrytan/gbrain@947536f4c",+ "rule_result": {+ "after_1_write": {+ "on_correct": 100,+ "off_correct": 92,+ "higher": true,+ "on_stale": 0,+ "off_stale": 8,+ "stale_not_higher": true+ },+ "after_5_writes": {+ "on_correct": 100,+ "off_correct": 92,+ "higher": true,+ "on_stale": 0,+ "off_stale": 8,+ "stale_not_higher": true+ }+ },+ "forget_remember": {+ "off": {+ "checkpoints": {+ "0": {+ "correct": 100,+ "stale": 0,+ "n": 100+ },+ "1": {+ "correct": 92,+ "stale": 8,+ "n": 100+ },+ "5": {+ "correct": 92,+ "stale": 8,+ "n": 100+ }+ },+ "metered_spend_usd": 3.4989+ },+ "on": {+ "checkpoints": {+ "0": {+ "correct": 100,+ "stale": 0,+ "n": 100+ },+ "1": {+ "correct": 100,+ "stale": 0,+ "n": 100+ },+ "5": {+ "correct": 100,+ "stale": 0,+ "n": 100+ }+ },+ "fact_row_in_context": "200 of 200 post-correction answers",+ "metered_spend_usd": 3.3858+ }+ },+ "no_loss_checks": {+ "status": "pass",+ "edit_sync": {+ "off": {+ "1": {+ "correct": 100,+ "stale": 0,+ "n": 100+ },+ "5": {+ "correct": 100,+ "stale": 0,+ "n": 100+ }+ },+ "on": {+ "1": {+ "correct": 100,+ "stale": 0,+ "n": 100+ },+ "5": {+ "correct": 100,+ "stale": 0,+ "n": 100+ }+ }+ },+ "append": {+ "off": {+ "1": {+ "correct": 100,+ "stale": 0,+ "n": 100+ },+ "5": {+ "correct": 100,+ "stale": 0,+ "n": 100+ }+ },+ "on": {+ "1": {+ "correct": 100,+ "stale": 0,+ "n": 100+ },+ "5": {+ "correct": 100,+ "stale": 0,+ "n": 100+ }+ }+ },+ "arm_fired": "0 of 600 answers in each arm: they save no facts",+ "ceiling": "both arms are at 100% with the key off and on, so these checks rule out a loss and cannot show a gain",+ "metered_spend_usd": {+ "off": 5.5835,+ "on": 5.585+ }+ },+ "context_tokens_mean": {+ "forget_remember_off": 3127,+ "forget_remember_on": 3139+ },+ "metered_spend_usd": 18.0532,+ "unmetered_note": "a first attempt that ran out of disk is not in the total; its records were lost; about two minutes of one run, under $0.50 by the observed rate"+ },+ "gate_2_revised": {+ "status": "pass",+ "measured_build": "garrytan/gbrain@947536f4c",+ "mode": "hermetic, keyword-only",+ "sets": {+ "namedthing": {+ "questions": 12,+ "fired": 0,+ "recall10_lower": 0+ },+ "relational": {+ "questions": 38,+ "fired": 0,+ "recall10_lower": 0+ },+ "longmemeval-nightly": {+ "questions": 10,+ "fired": 0,+ "recall10_lower": 0+ },+ "namedthing+facts": {+ "questions": 12,+ "fired": 11,+ "recall10_lower": 0+ },+ "relational+facts": {+ "questions": 38,+ "fired": 38,+ "recall10_lower": 0,+ "recall10_lower_at_16288b95c": 2+ }+ }+ },+ "metered_spend_usd_total": 44.1}diff --git a/src/core/config.ts b/src/core/config.tsindex 4165f7c0e9..08f5841b07 100644--- a/src/core/config.ts+++ b/src/core/config.ts@@ -1383,7 +1383,7 @@ export const KNOWN_CONFIG_KEYS: readonly string[] = ['search.return_budget_max_remote','search.evidence_date_header', // C1: one-line date header per delivered block (default off; search/evidence-date.ts)'search.entity_anchoring', // entity-anchored retrieval for entity-scoped current-state query/search (default off; search/entity-anchor.ts)- 'search.query_facts_arm', // query adds matching active facts as rows (default off; search/facts-arm.ts)+ 'search.query_facts_arm', // query adds matching active facts as rows in spare capacity (default on; search/facts-arm.ts)'think.return_unit',// Models tier system (v0.31.12)'models.default',diff --git a/src/core/search/facts-arm.ts b/src/core/search/facts-arm.tsindex c92f5e95a6..5fbb945982 100644--- a/src/core/search/facts-arm.ts+++ b/src/core/search/facts-arm.ts@@ -161,11 +161,15 @@ export async function applyFactsArm(engine: BrainEngine, query: string, results:}}-/** `search.query_facts_arm` is on ('true' | 'on' | '1' | 'yes'); off by default and on any read error. */+/**+ * `search.query_facts_arm`: on by default (gates 1b and 2 passed,+ * docs/eval/decisions/query-facts-arm/); 'false' | 'off' | '0' | 'no' turns it+ * off. A config read error leaves it off.+ */export async function queryFactsArmEnabled(engine: { getConfig(key: string): Promise<string | null> }): Promise<boolean> {try {const raw = (await engine.getConfig(QUERY_FACTS_ARM_KEY))?.trim().toLowerCase();- return raw === 'true' || raw === 'on' || raw === '1' || raw === 'yes';+ return !(raw === 'false' || raw === 'off' || raw === '0' || raw === 'no');} catch {return false;}diff --git a/src/core/search/query-arms.ts b/src/core/search/query-arms.tsindex 86c12b5ed4..c17ba7a692 100644--- a/src/core/search/query-arms.ts+++ b/src/core/search/query-arms.ts@@ -1,9 +1,9 @@/**- * The `query` op's opt-in arms, applied after hybrid search and the+ * The `query` op's post-retrieval arms, applied after hybrid search and the* declared-name fan-out, before the CRAG grade: entity anchoring- * (`search.entity_anchoring`, search/entity-anchor.ts) and then the facts arm- * (`search.query_facts_arm`, search/facts-arm.ts). Both default off; with- * both off the rows pass through unchanged.+ * (`search.entity_anchoring`, default off, search/entity-anchor.ts) and then+ * the facts arm (`search.query_facts_arm`, default on, search/facts-arm.ts).+ * With both off the rows pass through unchanged.*/import type { BrainEngine } from '../engine.ts';import type { PageReadScope, SearchResult } from '../types.ts';diff --git a/test/search-c5-identical.test.ts b/test/search-c5-identical.test.tsindex 903ef7a275..878f50fcdd 100644--- a/test/search-c5-identical.test.ts+++ b/test/search-c5-identical.test.ts@@ -7,7 +7,9 @@* and queries on a brain with active saved facts and declared other names,* including one that fans out to the other name, plus the same searches on a* brain with neither. Regenerate only on a build whose search output is meant- * to change, and say why in the commit.+ * to change, and say why in the commit. The query facts arm+ * (`search.query_facts_arm`, default on) changes query output on purpose, so+ * these brains pin it off; test/search-facts-arm.test.ts covers it.** Also: a fact saved with `remember` is found by the next search in the same* process, and by a search after another process saved it (no per-process@@ -58,6 +60,7 @@ async function brain(withFactsAndNames: boolean): Promise<PGLiteEngine> {await importFromContent(engine, slug, serializeMarkdown({}, text, '', { type: 'note', title, tags: [] }), { noEmbed: true, forceRechunk: true });}if (withFactsAndNames) await engine.executeRaw(FACTS);+ await engine.setConfig('search.query_facts_arm', 'false');return engine;}diff --git a/test/search-facts-arm.test.ts b/test/search-facts-arm.test.tsindex fc68367bf3..f74fbe33da 100644--- a/test/search-facts-arm.test.ts+++ b/test/search-facts-arm.test.ts@@ -5,7 +5,7 @@* pages leave of the token budget), never displacing a page; a remote caller never sees a* private fact; page-unit delivery passes the fact row through as written;* a page whose typed claim a newer fact covers is stamped superseded_claim;- * with the key off the rows are unchanged. PGLite, keyword-only, no network.+ * the key is on when unset, and with it off the rows are unchanged. PGLite, keyword-only, no network.*/import { afterAll, beforeAll, describe, expect, test } from 'bun:test';import { PGLiteEngine } from '../src/core/pglite-engine.ts';@@ -44,12 +44,14 @@ describe('facts arm', () => {expect(queryTerms(Q)).toEqual(['forge', 'offsite', 'booked']);});- test('off (unset or false): no fact rows, rows unchanged', async () => {- const unset = await query();+ test('unset is on; false turns it off and leaves the page rows unchanged', async () => {+ await engine.executeRaw(`DELETE FROM config WHERE key = $1`, [QUERY_FACTS_ARM_KEY]);+ const unset = await query({ limit: 10 });await engine.setConfig(QUERY_FACTS_ARM_KEY, 'false');- const off = await query();- expect(JSON.stringify(off.map(r => [r.slug, r.chunk_text]))).toBe(JSON.stringify(unset.map(r => [r.slug, r.chunk_text])));- expect(unset.some(r => r.fact_row)).toBe(false);+ const off = await query({ limit: 10 });+ expect(unset.some(r => r.fact_row)).toBe(true);+ expect(off.some(r => r.fact_row)).toBe(false);+ expect(JSON.stringify(unset.filter(r => !r.fact_row).map(r => [r.slug, r.chunk_text]))).toBe(JSON.stringify(off.map(r => [r.slug, r.chunk_text])));});test('on: the matching fact is a row of its own, newest first, in free slots after every page row', async () => {