Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge remote-tracking branch 'origin/master' into capy/gbra145-stale-signature-batching

garrytan925a119ce3ab
diff --cc CHANGELOG.md
index c5b1efb15e,7f0c4c5617..e412354810
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -10,33 -10,25 +10,52 @@@ credits are retained; no result has bee
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
- ## [0.60.338.0] - 2026-10-21
++## [0.60.339.0] - 2026-10-21
+
+**A model or dimension swap now finishes re-embedding on a large brain, and one overlong fact no longer stops the fact backfill.** After a swap, `gbrain embed --stale`, the background backfill and `gbrain migrate embeddings` mark every chunk from the old model for re-embedding. That marking was one statement over the whole brain, so on a large brain the statement timeout cancelled it, nothing was marked, and the next run hit the same timeout. Separately, before probing the embedder, every embed run counted drifted chunks with two full joins over every chunk. On a large drifted brain those counts timed out too, and the timeout was read as "no drift", so the swap was silently skipped.
+
+### What changed
+
+| Situation | Before | Now |
+|---|---|---|
+| Marking old-model chunks after a model or width swap | one statement over every chunk; cancelled by the statement timeout on a large brain | one pair of statements per 1,000 pages, all committed together |
+| The drift check before the embedder probe | two `count(*)` joins over every chunk on every run; a timeout read as "no drift" | one page-first `EXISTS`; a healthy brain answers it without reading chunks |
+| The "probe failed, skipping invalidation" warning | named a chunk count | no count, since nothing is counted before the probe |
+| A fact longer than the embedding input limit during `gbrain embed --facts` | the whole batch failed with "A fact exceeds the embedding input limit; no batch was sent", and every later run stopped at the same fact | that fact is skipped, never truncated, and reported (`refused_oversized` with its id, doctor `fact_take_vectors`, `gbrain embed --held`); every other fact embeds |
+
+### What to watch for after you upgrade
+
+- Nothing runs on upgrade. The next `gbrain embed --stale` or `gbrain migrate embeddings` after a swap marks the old vectors and re-embeds them as before.
+- A skipped fact stays stale with its text unchanged. Shorten or split it in its page's `## Facts` fence, or withdraw it with `gbrain forget <fact-id>`; the next `gbrain embed --facts` embeds it once it fits. Until then `gbrain migrate embeddings` counts it as remaining.
+
+### Itemized changes
+
+- `invalidateStaleSignatureEmbeddingsGuarded` runs in page-id windows (`SIGNATURE_INVALIDATION_PAGE_BATCH`, 1000) inside one transaction.
+- New `hasSignatureDrift` replaces the drift pre-counts in `gbrain embed` and the embed backfill, and gates the NULL-signature (left-behind) warning's counts.
+
+- `gbrain embed --facts` skips facts over the input limit (`readOversizedStaleFacts`) and reports `refused_oversized`, `refused_samples` and `refused_fix`; doctor `fact_take_vectors` adds `facts.oversized`, and `gbrain embed --held` lists them with `oversized_facts`.
+
+Follow-up to #7117 (#7148). Oversized facts reported by @dyana1lyons-ai (#7211).
+
+ ## [0.60.338.0] - 2026-10-21
+
+ **Keyword search on a large Postgres brain no longer stalls on a common word, and agent guidance now says to search gbrain first.** At 300k pages, a keyword query whose words matched hundreds of thousands of chunks ranked every one of them and often hit the 8 s keyword statement timeout, so the keyword arm returned nothing. Ranking is now bounded, the OR retry matches only the words that fit, and the candidate pool keeps one chunk per page. On a 305k-page bench behind a transaction-mode pooler, warm search p95 fell from 8.4 s to 2.4 s, warm query from 8.6 s to 1.2 s and warm recall from 8.4 s to 1.0 s. Retrieval quality on the agent-retrieval shapes and the 70-question ranking-shapes set is unchanged.
+
+ ### What changed
+
+ | Situation | Before | Now |
+ |---|---|---|
+ | A keyword search whose words match more than 50,000 chunks (Postgres) | ts_rank ran over every match and often timed out | the first 50,000 matches that pass the filters are ranked, and the response is stamped `keyword_candidates_incomplete` |
+ | The keyword arm's any-word retry after an all-words miss | an OR over common words matched up to 850k chunks | matches only the words that planner statistics say fit under a 20k-chunk cap, and still ranks with the full OR query |
+ | A page with hundreds of matching chunks | it could fill the keyword candidate pool | the pool keeps one chunk per page (Postgres and PGLite) |
+ | The title arm's any-word retry for local callers | matched page text | matches titles only, as remote callers already did, and drops repeated words (#7135) |
+ | An agent deciding where to look | guidance didn't say | brain-first, query, brain-ops, RESOLVER and the AGENTS/INSTALL templates say to search gbrain first, then read the page, with copyable examples |
+
+ ### For contributors
+
+ - `scripts/bench/retrieval-scale/` builds a synthetic large brain and times cold and warm search, query, get and recall behind PgBouncer and toxiproxy.
+ - `test/e2e/retrieval-round-trip-budget.test.ts` pins the cold CLI round trips: search 65, get 19, recall 38.
+
## [0.60.337.0] - 2026-10-21
**Agents can ask gbrain what happened to a file instead of copying its path rules, and `gbrain sync status` no longer contradicts itself.** A landing check that rebuilt gbrain's path-to-slug rules in its own code reported pages as synced but unsearchable for days when nothing was wrong. `gbrain sources resolve-path` gives gbrain's own answer for each path, and sync status and doctor now flag the pages that really are committed but not yet searchable.
diff --cc src/core/behavior-change-notice.ts
index d176d33b0a,cda8c94855..562850369e
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@@ -1049,10 -1049,10 +1049,14 @@@ export const BEHAVIOR_CHANGES: Readonly
{ since: '0.60.337.0', id: 'sync_status_coherent_7189', text: '`gbrain sync status --json` no longer contradicts itself while a source falls behind (#7189). `freshness` adds `behind` (commits on the checkout HEAD after the last synced commit, and the oldest one\'s age), because its latency samples date only commits that already synced. The `notifier` block adds `drain_holder`: with no notifier running, the process holding the source\'s drain lease is named and no fix is offered while it makes progress, instead of "No resident … watches this source". A `last_error` the source\'s sync has committed a page past now carries `superseded: { at }` and no longer sets `needs_human`, `state` or `next`. New `needs_human_from` says whether `needs_human` comes from a hold or the last error. In `gbrain sources resolve-path`, a large page whose embedding budget is held or capped reads `pending_embedding` with `embedding_hold`, never `keyword_only`, which means `embed_skip`.' },
// GBRA-150 (nested typed metafiles become pages): Garry, "take all recommendations" (2026-10-20), answering the proposal to import typed non-root index.md/README.md. `since` is stamped at the merge slot.
{ since: '0.60.337.0', text: 'Sync now imports a folder-scaffolding file below a source\'s root (`index.md`, `README.md`, `log.md`, `schema.md` or `RESOLVER.md`) as a page when its frontmatter has `type:` or `title:`, for example `projects/acme-example/index.md`. A bare one at any depth and every one at the source root stay skipped. The first sync after the upgrade imports the existing typed files once and deletes or rewrites nothing else; deleting such a file later soft-deletes its page. `gbrain config set sync.metafile_pages off` restores the old skip. Default change approved by Garry, "take all recommendations", 2026-10-20.' },
+ // GBRA-156 retrieval wave.
+ { since: '0.60.338.0', text: 'On Postgres, a keyword search whose words match more than 50,000 chunks now ranks the first 50,000 matches that pass its filters instead of all of them, so a common-word query on a large brain returns ranked rows in about a second instead of running into the keyword statement timeout and returning none; hybrid search reports `keyword_candidates_incomplete` when the bound applies. Its any-word retry (after an all-words match finds nothing) now matches only the words the planner statistics say fit about 20,000 chunks, still ranking with every word, and also reports `keyword_candidates_incomplete` when it drops a word.' },
+ { since: '0.60.338.0', text: 'The keyword arm keeps one chunk per page in its candidate pool (Postgres and PGLite), so a page with hundreds of matching chunks no longer pushes every other matching page out of the results.' },
+ { since: '0.60.338.0', text: 'The title arm\'s any-word retry (after an all-words title match finds nothing) now matches page titles only, as remote callers already did, and drops repeated words (#7135): a date in a question no longer pulls every dated timeline into ranking, which cut a 3-5 s title arm to well under a second on a large brain. A local all-words title match is unchanged.' },
+ // #7148 (GBRA-145, #7117 follow-up). `since` is restamped at the merge slot.
+ { since: 'TBD', text: 'After a model or dimension swap, `gbrain embed --stale`, the embed backfill and `gbrain migrate embeddings` now mark old-model chunks for re-embedding in windows of 1,000 pages (all committed together) instead of one statement over the whole brain, which a large brain cancelled at the statement timeout on every run. The drift check before the embedder probe is one page-first lookup instead of two counts over every chunk, so a count that timed out can no longer skip the swap silently; the "embedder probe failed" warning no longer names a chunk count.' },
+ // #7211 (GBRA-145). `since` is restamped at the merge slot.
+ { since: 'TBD', text: '`gbrain embed --facts` no longer fails a whole batch, and every later run, on one fact longer than the embedding input limit: that fact is skipped (never truncated), keeps its text and stays stale, and the result reports it (`refused_oversized`, `refused_samples` with fact ids, `refused_fix`) without counting it in `remaining` or against `--max-facts`. Doctor `fact_take_vectors` adds `facts.oversized`, and `gbrain embed --held` lists them. Shorten or split the fact, or withdraw it with `gbrain forget <fact-id>`, and the next run embeds it once it fits.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */