Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs(#5888): capture dedup is exact-only; align wave notes and TODOS after reverting the 0.95 capture drop
garrytanb8dfa01d2eb6
diff --git a/TODOS.md b/TODOS.mdindex e9c14dc274..c4aed3904f 100644--- a/TODOS.md+++ b/TODOS.md@@ -29,7 +29,7 @@- [ ] **P3 — Measure the upgrade journey (Pass 8).****What:** the time from the end of `gbrain upgrade` to both new repairs previewed was estimated (target under 5 minutes), not measured. **Fix:** time it once on a seeded PGLite brain with `captured_facts_active` and `loop_facts_drift` present and record it in the upgrade guide. **Effort:** XS. **Priority:** P3.- [ ] **P2 — Corrections lost to the cosine 0.95 drop (V1).**- **What:** `remember` and `extract_facts` keep the unguarded same-entity cosine ≥ 0.95 drop. Measured with voyage-4, 4 of 20 correction pairs (negation, number or date) and 2 of 10 word-change corrections ("The offsite is in Lisbon" / "... Porto") score ≥ 0.95, so an explicit correction can be dropped as a duplicate. Capture lanes apply the `claimsDiverge` negation/number/date guard, which catches the 4 but not the 2 word-change pairs. **Fix:** apply `claimsDiverge` to the explicit lanes' drop and extend it (or raise the threshold) for single-word substitutions, with the V1 pairs in the wave notes as the test table. **Effort:** S. **Priority:** P2.+ **What:** `remember` and `extract_facts` keep the unguarded same-entity cosine ≥ 0.95 drop. Measured with voyage-4, 4 of 20 correction pairs (negation, number or date) and 2 of 10 word-change corrections ("The offsite is in Lisbon" / "... Porto") score ≥ 0.95, so an explicit correction can be dropped as a duplicate. Capture lanes never drop by cosine (shadow-count only), and the `claimsDiverge` negation/number/date guard catches the 4 but not the 2 word-change pairs, so a token guard alone is not enough to re-enable any cosine drop. **Fix:** make the explicit lanes' drop safe for single-word substitutions (or raise the threshold) before relying on it, and only then consider a measured capture threshold, with the V1 pairs in the wave notes as the test table. **Effort:** S. **Priority:** P2.- [ ] **P3 — JIT off for the remote title arm.****What:** on a 40k-page Postgres brain most of the remaining common-term title-arm latency is JIT compilation (for example 17 ms execution, 504 ms JIT): the visibility subplans push the cost estimate past `jit_above_cost`. **Fix:** `SET LOCAL jit = off` around the remote title statement, measured against the same benchmark before shipping. **Effort:** S. **Priority:** P3.- [ ] **P3 — Move `captured-facts` database-only expiry onto the loop-fact retirement mutation.**diff --git a/docs/fix-wave-notes/capy-gbra35w2-fix-wave.md b/docs/fix-wave-notes/capy-gbra35w2-fix-wave.mdindex 2e3b2c465e..4294338d27 100644--- a/docs/fix-wave-notes/capy-gbra35w2-fix-wave.md+++ b/docs/fix-wave-notes/capy-gbra35w2-fix-wave.md@@ -11,7 +11,7 @@ for this wave).### Memory-- **What the agent saves with `remember` is no longer stored a second time by automatic capture (#5888).** Automatic capture (the writeback hook, the compaction harvest and the corpus sweep) now skips a fact when an active fact in the same source has the same normalized text on the same entity (or on another entity the claim names), is visible where the new fact would be, and was written within 15 minutes of the turn or by capture in the same conversation. A reworded copy on the same entity is skipped at cosine 0.95 or higher only when the two claims do not differ in a negation, number or date, so a correction such as "is not moving" or a changed amount is kept. Facts between 0.92 and 0.95 are always kept and only counted. Hot memory and the `context_pack`/`delta` facts show one line per duplicate group. Each skip is logged on stderr and in the hook heartbeat, and `gbrain doctor` (`memory_writeback`) reports `cross_lane_duplicates_7d` and `near_duplicates_shadow_7d`. Explicit `remember` is never skipped, so use it for anything that must persist.+- **What the agent saves with `remember` is no longer stored a second time by automatic capture (#5888).** Automatic capture (the writeback hook, the compaction harvest and the corpus sweep) now skips a fact when an active fact in the same source has the same normalized text on the same entity (or on another entity the claim names), is visible where the new fact would be, and was written within 15 minutes of the turn or by capture in the same conversation. Reworded copies are never skipped by similarity, so a correction such as "is not moving", a changed amount or a changed place is always kept; capture only counts same-entity near duplicates (cosine 0.92 or higher) so a threshold can be measured first. Hot memory and the `context_pack`/`delta` facts show one line per duplicate group. Each skip is logged on stderr and in the hook heartbeat, and `gbrain doctor` (`memory_writeback`) reports `cross_lane_duplicates_7d` and `near_duplicates_shadow_7d`. Explicit `remember` is never skipped, so use it for anything that must persist.- **The maintenance sweep now reads whole session transcripts, not just their first 8,000 characters, and a resumed session no longer re-extracts the same head (#5887).** The sweep cuts each transcript into windows at turn boundaries, each carrying its `[user]` or `[assistant]` label, with pasted blocks removed first, and records progress in a `<file>.progress` sidecar so appends and compaction rewrites cost only their new turns. Cost: a long transcript costs one extraction call per window, so a typical 120 KB transcript is about 15 calls where it used to be one. Spend per sweep is capped at 8 windows per file and 32 windows across files (`GBRAIN_CORPUS_WINDOWS_PER_SWEEP` changes the 32); longer files finish over later sweeps. `gbrain sweep --once --json` reports `corpus_files[]` with `windows_done` and `windows_remaining`. Transcripts marked done before this release are not re-read; only turns added after the upgrade are extracted.- **New explicit repair: `gbrain repair captured-facts` expires facts captured before v0.60.30.0 from gbrain's own claude-cli sessions or from pasted text.** Doctor reports them as `captured_facts_active`, and the post-upgrade banner names the preview. Self-capture facts with evidence expire with `--apply --expect <hash>`; paste candidates (a word-overlap heuristic against the retained session corpus) expire only with `--include-ambiguous`. A claim that also has a legitimate active copy is kept. Facts are expired, never withdrawn, so `remember` can save the claim again.@@ -84,7 +84,7 @@ Ported code carries `Co-Authored-By` trailers: @javieraldape (#5897), @andreinea- #5888: a `remember` saved after automatic capture already stored the same claim leaves two active rows. Hot memory shows them once only when the text is identical, and search can return both.- #5888: the dedup check is a read outside the write transaction, so two capture writers racing on the same claim can both insert it.-- #5888: same-entity word-change corrections at cosine ≥ 0.95 are not caught by the capture guard (see the V1 measurement above).+- #5888: capture keeps same-entity rewordings (cosine dedup is shadow-only), so a reworded duplicate can still appear twice until a measured threshold ships. The V1 measurement shows why: single-word corrections ("Lisbon" → "Porto", "Vim" → "Emacs") embed at ≥ 0.95, which no token guard catches.- #5855: hosts on v0.60.31.0 or older run their own upgrade code, which has no floor check, so the next Bun floor raise must wait until this release is widely installed.- #5856: with an unpriced `extract_atoms` model the auto-drain's dollar limit is not enforced; only the attempt count bounds it.- `gbrain repair captured-facts` stays registered (no sunset), so hosts that skip versions can still run it.