Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

chore(todos): file #6734's saved-fact threshold move and gated OR retry

garrytan330fe13bff40
diff --git a/TODOS.md b/TODOS.md
index c25115744b..aa4f4eba0d 100644
--- a/TODOS.md
+++ b/TODOS.md
@@ -9,6 +9,7 @@ Context: gbrain-evals `docs/plans/2026-10-15-lhf-wave-2/PLAN.md` ("NOT in scope"
- [ ] **P2 — Expansion model and rewrite count (old item 10).** **What:** Haiku 5.5 for query expansion needs one resolver shared by serving and `gbrain models`, an unchanged OCR fallback (the expansion model is also the OCR fallback) and unchanged init auto-pin rules. Expansion is off by default since item 0, so the saving is small. Goes with TODO-D (`TIER_DEFAULTS`, `synthesize`/`think` on Opus 4.7 at $0.094 per call, other utility-tier callers); #6335 stays open as TODO-D input. **Findings:** `eng-native.r1.md` F14, F15; `eng-outside.r1.md` F14; `ceo-outside.r1.md` F6, F7; `dx-outside.r1.md` F6. **Effort:** M. **Priority:** P2.
- [ ] **P2 — Post-fusion read fan-out, fusion prefetch and the CLI config snapshot (from item 5).** **What:** item 5 kept the MCP per-request config snapshot, one settings statement per search, concurrent response-meta reads and concurrent entity resolve. These three each need their own failure-semantics and staleness design: one `Promise.all` must not become one failure domain for post-fusion ranking, the fan-out needs a pool-2 check, and a CLI snapshot needs a staleness rule for long-running commands. **Findings:** `eng-native.r1.md` F8, F9; `eng-outside.r1.md` F3, F11. **Effort:** M. **Priority:** P2.
- [ ] **P2 — Off-reply `mcp_request_log` insert (dropped from item 5).** **What:** writing the request-log row after the reply takes its insert off every MCP call's reply path, but a bounded queue can drop rows, and an in-memory drop counter in `serve --http` is invisible to `gbrain doctor` (another process) and resets on restart, while the admin dashboard, per-client usage and `last_used_at` read the table. **Fix:** persist losses (a summary row or a counter row doctor reads), a config switch for blocking inserts when an operator needs complete audit rows, usage reports qualified over incomplete windows, and shutdown that awaits in-flight inserts; test forced backpressure, insert failure and restart from a fresh process. **Findings:** `dx-native-1`, `dx-native-2`, `eng-native-9`, `eng-outside-9`, `dx-outside-3`. **Effort:** M. **Priority:** P2.
+- [ ] **P3 — Saved-fact threshold move and the gated OR retry (not taken from #6734 by @troyhoffman-oss).** **What:** #6734 moved the saved-fact match threshold into SQL, which returns facts the old 200-row cap missed, and added a gated OR retry (55dc07cb) for strict keyword misses. Both change which results a search returns, so neither fits a parity-clean latency wave. **Fix:** take each with a retrieval-quality gate (saved-fact recall at the cap boundary; OR-retry precision on Cat 13 and Cat 40 development data) after the trigram index entry below is decided. **Source:** `audit/latency.md` (#6734 review), item 5 lane report. **Effort:** S-M each. **Priority:** P3.
- [ ] **P2 — Automatic expression-statistics recovery on Postgres (item 6's heavier fix).** **What:** item 6 analyzes after every index build and recovers an already-present expression index automatically on PGLite; on Postgres doctor `planner_stats_stale` names it and an operator runs `gbrain repair planner-stats --apply`, because autovacuum waits for 10% of a table to change. **Fix:** a bounded maintenance owner (for example `post-upgrade` or the resident `serve` running `repairPlannerTable` once for flagged tables), with retry after a failed first ANALYZE, restricted roles kept as unknown, and no statement added to any search. **Findings:** `eng-native-7`, `ceo-outside-4`, `dx-outside-4`, `eng-outside-6`. **Effort:** S. **Priority:** P2.
- [ ] **P2 — Paraphrased attendance questions (item 9, dropped by its preregistered gate).** **What:** the narrowed lexicon ("were present at", "was in the room for", "took part in", "participated in", "sat in on", the "participants" noun frame, with a funding-object guard) fired the development paraphrase split 150 of 150 on world-v1-attendees (0 before; recall@5 on 0.530 to 0.707) but the held-out set of 30 independently written questions fired 18 of 90 runs (20%; base 6 of 90) against the 80% floor: 6 of 30 held-out questions parse as attendance (base 2). The held-out author used frames such as "showed up", "made it to", "turned out for", roster and guest-list nouns. One competing-intent question (school attendance) already routes to attendance on master. "joined", "was at" and "went to" would route employment, education and location questions unless guarded by the anchor's type, and a resolver-only guard still changes keyword weights and title-mention ranking (`relational-plan.ts` `isRelationalQuery` feeds `hybrid/rank.ts` and `hybrid/request.ts`); a guard must follow schema-pack aliases of meeting types. **Gate:** a fresh held-out set (the 2026-10-15 one is spent), zero false routes on chosen relations and returned evidence. **Receipt:** gbrain-evals `docs/benchmarks/2026-10-16-lhf-wave-2-attendance-preregistration.md` and its result. **Findings:** `eng-outside-1`, `eng-native-13`, `ceo-native-11`, `ceo-outside.r1.md` F5. **Effort:** M. **Priority:** P2.
- [ ] **P3 — Saved-facts trigram index (item 2, dropped by its insert gate; from #6734 by @troyhoffman-oss).** **What:** a GIN trigram index on the saved-fact match expression serves master's unchanged statement after ANALYZE on both engines (p50 19.6 to 3.4 / 94 to 12 / 167 to 23 ms on PGLite at 10k/50k/100k facts; 32 to 4.9 / 87 to 12 / 83 to 21 ms on Postgres), but with `fastupdate=on` the pending list makes the planner pick a seq scan, `fastupdate=off` costs +27-40% insert p50 and -45% batch throughput, and a 256k-1MB pending list keeps p50/p95/p99 flat but costs -11-37% batch throughput and 15-30 ms flush spikes, so every configuration fails the +25% insert gate. A shelved patch (1MB pending list, own rebuild command, EXPLAIN test) is in the GBRA-107 thread. **Fix:** a cheaper write path (for example a separate narrow match table or an index on the fact text only) or a gate that weighs batch imports separately. **Effort:** M. **Priority:** P3.