Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

docs(eval): query facts arm verdict: gate 1 fails as preregistered (stale 92% -> 4-6%, accuracy 0% -> 1%/0%: remembered facts are dated at write time), gate 2 passes; search.query_facts_arm stays off

garrytan7dc11c6e1744
diff --git a/docs/architecture/RETRIEVAL.md b/docs/architecture/RETRIEVAL.md
index 5cfcb6647b..509fd7ae0d 100644
--- a/docs/architecture/RETRIEVAL.md
+++ b/docs/architecture/RETRIEVAL.md
@@ -298,6 +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 most
half the rows. It is skipped with `offset`, type, date, language or symbol
filters. 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 inside the caller's row count and token budget, 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:
+ `docs/eval/decisions/query-facts-arm/`.
### Use-attributed feedback
diff --git a/docs/architecture/key-files/core-search-2.md b/docs/architecture/key-files/core-search-2.md
index 922c06d5b6..843c1ce540 100644
--- a/docs/architecture/key-files/core-search-2.md
+++ b/docs/architecture/key-files/core-search-2.md
@@ -7,6 +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; gate 1 failed as preregistered). `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 inside the caller's row count and token budget (free slots first; the lowest page rows give way only when the count is full) 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/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.md
index 9991861669..3ffdcb0003 100644
--- a/docs/eval/decisions/query-facts-arm/README.md
+++ b/docs/eval/decisions/query-facts-arm/README.md
@@ -1,8 +1,67 @@
-# Facts arm in query: preregistered gates
+# Facts arm in query: gates and verdict
-Not built and not measured. The gates below were written and pushed before any code or gated run. The arm will
-sit behind `search.query_facts_arm`, which is off by default. With the key off, `query` returns what it returns
-today.
+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.
+
+## Result
+
+**Gate 1 failed.** In the B2 corrections suite's forget-then-remember arm, the key moved the stale-answer rate
+from 92% to 4-6%. Corrected-value accuracy went from 0% to 1% after one unrelated write and stayed at 0% after
+five. The rule needed it higher at both checkpoints.
+
+The reader named the correction in 158 of the 200 answers after it (0 of 200 with the key off), and still kept the old value. A
+remembered fact is dated when it is saved. In this suite that date is the day of the run, after every
+question's simulated date. So the reader judged the correction not yet in effect and answered with the old
+value. The fixed judge scored those answers wrong rather than stale. A typical answer was "Saltgrass Tacos. The
+correction to The Green Fork is only valid from 2026-10-05, which is after the 2025-05-11 question date."
+
+Corrected-value accuracy and stale-answer rate per 100 items, reader `claude-sonnet-5-5`:
+
+| Arm | Key | Before correction | After 1 write | After 5 writes |
+|---|---|---|---|---|
+| forget-then-remember | off | 100% / 0% | 0% / 92% | 0% / 92% |
+| forget-then-remember | on | 100% / 0% | 1% / 4% | 0% / 6% |
+| 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 with the key on. Both are at 100% with the key off too, so these checks
+can only rule out a loss; they cannot show a gain.
+
+**A diagnostic, not a gate.** It was chosen after gate 1's cells ran, so it cannot change the decision. In
+these runs `remember` received the correction's own timestamp as `valid_from`, which `remember` accepts on
+this branch. That changes the written fact, not the query path. With the fact dated when it took effect, the
+key-off arm already answered 92% correctly (8% stale), and the key-on arm answered 100% correctly (0% stale)
+at both checkpoints. A future preregistered gate on correction-dated writes would test this directly.
+
+**Gate 2 passed, though the formal gate is close to vacuous.** On NamedThingBench (12 questions), the
+relational fixture (38) and the LongMemEval nightly fixture (10), no question's recall@10 is lower with the key
+on. These corpora hold no saved facts, so the arm never fired. The runs are hermetic and keyword-only, so the arm
+matched by terms and named entity, not by embedding. Two diagnostic copies seed one saved fact per question:
+
+- NamedThingBench: fired 11 of 12 times and lost nothing (recall@10 0.917 both ways).
+- Relational: fired 38 of 38 times and lost recall@10 on 2 questions (mean 1.000 off, 0.974 on). Fact rows
+ take a page slot when the row count is already full.
+
+With the key off, gate-2 output matches garrytan/gbrain@a87c3e2af exactly, apart from wall-clock recency scores
+and random revision ids.
+
+Metered spend was $26.05 against a $40 cap:
+
+- Gate 1 runs: $25.56.
+- Two 6-probe smokes: $0.14.
+- A duplicate run stopped after 30 probes and not used: $0.35.
+
+Records are in `decision.json` (what was tested and how) and `verdict.json` (what happened). The gbrain-evals
+mirror carries the two bench flags the gate-1 runs used (`--gbrain-search-config`, `--remember-valid-from`) as a
+patch.
+
+**Decision.** `search.query_facts_arm` stays off by default.
+
+## Preregistration
+
+The sections below were written and pushed in garrytan/gbrain@a87c3e2af, before any code or gated run, and are
+unchanged.
## Why
@@ -60,3 +119,4 @@ stays off. The spend cap is set before the gate 1 run.
## Changelog
- 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.
diff --git a/docs/eval/decisions/query-facts-arm/decision.json b/docs/eval/decisions/query-facts-arm/decision.json
new file mode 100644
index 0000000000..85fe663651
--- /dev/null
+++ b/docs/eval/decisions/query-facts-arm/decision.json
@@ -0,0 +1,44 @@
+{
+ "schema_version": 1,
+ "decision_id": "query-facts-arm",
+ "plan": "MEMORY_PROOF_WAVE fix lane (proposal 4)",
+ "title": "Facts arm in query: matching active saved facts as rows inside the caller's row count and budget",
+ "verdict_type": "quality",
+ "stage": "dev",
+ "candidate": {
+ "gbrain": "garrytan/gbrain@16288b95c",
+ "config": {
+ "search.query_facts_arm": "true"
+ }
+ },
+ "baselines": [
+ {
+ "gbrain": "garrytan/gbrain@16288b95c",
+ "config": {
+ "search.query_facts_arm": "false"
+ },
+ "note": "same build, same brain writes, same query op call, key off"
+ }
+ ],
+ "preregistration": "README.md in this directory, pushed in garrytan/gbrain@a87c3e2af before any code or gated run",
+ "models": {
+ "reader": "anthropic:claude-sonnet-5-5",
+ "judge": "anthropic:claude-sonnet-5-5 (B2 fixed judge for ambiguous answers)",
+ "embedding": "voyage:voyage-4 (1024d)",
+ "selection": "B-suite fixed reader and judge; gbrain default embedding"
+ },
+ "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)"
+ },
+ "decision_rule": "default-on only if gates 1 and 2 pass (and gate 3 if it runs); off until then",
+ "budget": {
+ "max_usd": 40,
+ "metered_spend_usd": 26.05
+ },
+ "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"
+ }
+}
diff --git a/docs/eval/decisions/query-facts-arm/verdict.json b/docs/eval/decisions/query-facts-arm/verdict.json
new file mode 100644
index 0000000000..796e3b6986
--- /dev/null
+++ b/docs/eval/decisions/query-facts-arm/verdict.json
@@ -0,0 +1,239 @@
+{
+ "decision_id": "query-facts-arm",
+ "stage": "dev",
+ "decided_at": "2026-10-06T00:30:00Z",
+ "measured_build": "garrytan/gbrain@16288b95c",
+ "overall": "off_gate_1_failed",
+ "gate_1": {
+ "status": "fail",
+ "rule_result": {
+ "after_1_write": {
+ "on_correct": 1,
+ "off_correct": 0,
+ "higher": true,
+ "on_stale": 4,
+ "off_stale": 92,
+ "stale_not_higher": true
+ },
+ "after_5_writes": {
+ "on_correct": 0,
+ "off_correct": 0,
+ "higher": false,
+ "on_stale": 6,
+ "off_stale": 92,
+ "stale_not_higher": true
+ }
+ },
+ "why": "With the key on the reader named the remembered correction in 158 of 200 post-correction answers (0 of 200 with the key off), but the fact is dated when it was saved (the run date), after each question's simulated date; the reader treated it as not yet in effect and kept the old value. The judge scored those answers wrong rather than stale, so stale fell from 92 to 4-6 while accuracy stayed at 0-1.",
+ "forget_remember": {
+ "off": {
+ "checkpoints": {
+ "0": {
+ "correct": 100,
+ "stale": 0,
+ "n": 100
+ },
+ "1": {
+ "correct": 0,
+ "stale": 92,
+ "n": 100
+ },
+ "5": {
+ "correct": 0,
+ "stale": 92,
+ "n": 100
+ }
+ },
+ "outcomes": {
+ "correct": 100,
+ "stale": 184,
+ "wrong": 12,
+ "abstain": 4
+ },
+ "metered_spend_usd": 3.586
+ },
+ "on": {
+ "checkpoints": {
+ "0": {
+ "correct": 100,
+ "stale": 0,
+ "n": 100
+ },
+ "1": {
+ "correct": 1,
+ "stale": 4,
+ "n": 100
+ },
+ "5": {
+ "correct": 0,
+ "stale": 6,
+ "n": 100
+ }
+ },
+ "outcomes": {
+ "correct": 101,
+ "stale": 10,
+ "wrong": 181,
+ "abstain": 8
+ },
+ "metered_spend_usd": 3.9239
+ }
+ },
+ "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
+ }
+ }
+ },
+ "ceiling": "both arms are at 100% with the key off and on, so these checks cannot show a gain, only rule out a loss",
+ "metered_spend_usd": {
+ "off": 5.5857,
+ "on": 5.5821
+ }
+ },
+ "context_tokens_mean": {
+ "forget_remember_off": 3127,
+ "forget_remember_on": 3139
+ }
+ },
+ "diagnostic_correction_dated": {
+ "preregistered": false,
+ "note": "Not a gate. Same runs, except remember receives the correction's own timestamp as valid_from (bench --remember-valid-from; gbrain's remember has accepted valid_from since this branch). Decided after gate 1's cells ran, so it cannot change the decision; it shows what the arm does once a fact carries the date it took effect.",
+ "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.4966
+ },
+ "on": {
+ "checkpoints": {
+ "0": {
+ "correct": 100,
+ "stale": 0,
+ "n": 100
+ },
+ "1": {
+ "correct": 100,
+ "stale": 0,
+ "n": 100
+ },
+ "5": {
+ "correct": 100,
+ "stale": 0,
+ "n": 100
+ }
+ },
+ "metered_spend_usd": 3.3887
+ }
+ }
+ },
+ "gate_2": {
+ "status": "pass",
+ "mode": "hermetic, keyword-only (no embedding provider), so the arm matched by terms and named entity only",
+ "corpora": {
+ "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
+ }
+ },
+ "vacuous": "the arm never fired on the corpora as written, which hold no saved facts",
+ "diagnostics_with_saved_facts": {
+ "namedthing+facts": {
+ "questions": 12,
+ "fired": 11,
+ "recall10_lower": 0,
+ "recall10_mean_on": 0.917,
+ "recall10_mean_off": 0.917
+ },
+ "relational+facts": {
+ "questions": 38,
+ "fired": 38,
+ "recall10_lower": 2,
+ "recall10_mean_on": 0.974,
+ "recall10_mean_off": 1.0,
+ "why_lower": "fact rows take a page slot when the row count is already full"
+ }
+ },
+ "key_off_identity": "query output with the key off is identical to garrytan/gbrain@a87c3e2af on all gate-2 corpora apart from wall-clock recency scores and random revision ids"
+ },
+ "gate_3": {
+ "status": "not_run"
+ },
+ "decision": "search.query_facts_arm stays off by default",
+ "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"
+}