Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge remote-tracking branch 'origin/master' into capy/cat40-hard-fix

garrytan9de4ce89504b
diff --cc CHANGELOG.md
index 789f04d981,fd3988158e..5b7d26b3a5
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -10,72 -10,25 +10,91 @@@ credits are retained; no result has bee
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
+## [Unreleased: Cat 40 Hard fix wave, version stamped at merge] - 2026-10-07
+
+**gbrain now knows every name an account goes by, tells your agent how many records match, and says why a write or a rerank failed.**
+
+On a company brain, most records never repeat a customer's full name. They use a nickname, a code or a name filed on a different page. Before this release an agent asked gbrain for the customer's card, saw the name and the code, and believed it had every alias, so it missed the records filed under the nickname. Now the card shows every other name the customer's pages declare, with the line that declares it; search also searches those names on its own; and every search says how many pages match its keywords, with a way to list them all. Saved memories fail less, and when one fails the answer says why. The Cat 40 Hard confirmation run has not happened yet; its numbers lead the version stamped at merge.
+
+### What changes for your agent
+
+| Where | What changed |
+|---|---|
+| `entity` card | New `identity_siblings` (pages about the same subject under another title prefix, each with its own aliases, never merged), `identity_excerpt` (verbatim lines that may carry another name, with the page they came from), `aka_sources` and `alias_guidance` (what `aka` covers, which names to search). `aka` is unchanged. |
+| Alias learning | Prose cues ("also known as", "goes by", "formerly", "doing business as", a quoted name after "calls it"), alias label lines and table rows ("Internal nickname: Copper Fox"), labels later in a line ("Account: Widget Co. Nickname used by the team: Copper Fox.") and multi-word names. A name two sibling pages share now links mentions to both instead of neither. |
+| Saved facts | A fact saved by an account's name links to the account even when its sheet and CRM record share the name; the card's `recent_facts` and `recall {entity}` show facts saved under either page or the bare name, and a search naming the entity lists its newest saved facts first, then facts of an entity they point to. |
+| `search` / `query` | When a query names an entity, gbrain also searches up to 4 of its other names (keyword-only, rows carry `matched_alias`). Every search adds one line: the rows are a ranked top-K, and `keyword_total` pages match the keywords (up to "10000+"). |
+| `search` `match: "keyword"` | On an entity's name or alias it lists pages using any of its names in one walk. Otherwise lists every keyword match, page by page, with `total`, `truncated` and a ready-to-send `next`. Remote agents can use it. A per-call `mode` is refused with a fix naming `match: "keyword"`; an offset over 10,000 is refused. |
+| Search rows | `effective_date_source` survives lean rows, and one line says whether each date is a document, event or fallback date (never a contract's effective date). Pages gbrain generated (`dream_generated`, `extract_receipt`) carry `provenance: "generated"` and rank below a primary record about the same entity. |
+| `remember` and write tools | Any `request_id` of 1 to 128 printable characters is accepted (echoed as `client_request_id`; `request_id` stays a UUID). Re-saving a claim that was forgotten is refused straight away with `fact_withdrawn` and the write that works (`entity` plus `replaces`), instead of being accepted and failing later. Re-saving a claim with its entity links the copy saved without one (`status: superseded`, `superseded_fact_id`, also on batch receipts) instead of keeping a duplicate. Failed receipts and `get_write_request` name the cause. |
+| `forget` | Forgetting a fact saved without an entity is refused with `claim_linked` while the same claim is active on entity-linked facts, naming them. It used to withdraw those facts as well, and a withdrawn claim cannot be saved again. Forget the linked facts first to withdraw the claim everywhere. |
+| Degraded reranking | The `degraded_recall` notice and `_meta.retrieval.rerank_degraded` carry the reason (`timeout`, `budget`, `rate_limited`, `unreachable`, `auth`, `provider_error`), the fallback and the session's count, with a fix per reason. |
+
+Example card fields for an account whose CRM record and account sheet share a subject:
+
+```json
+{
+ "aka": ["wgco", "widget co"],
+ "aka_sources": [{ "origin": "declared", "slug": "crm/widget-co" }, { "origin": "subject", "slug": "crm/widget-co" }],
+ "identity_siblings": { "capped": false, "pages": [{ "slug": "accounts/widget-co", "title": "Account sheet: Widget Co", "type": "account", "aka": ["Copper Fox", "Widget Co"] }] },
+ "identity_excerpt": [{ "slug": "accounts/widget-co", "line": "Internal nickname: Copper Fox" }]
+}
+```
+
+### How to use it
+
+```bash
+gbrain extract --stale --catch-up # re-derive aliases and rescan mentions once (autopilot does this too)
+gbrain extract mentions --explain crm/widget-co # every name a page derives, rejected candidates, the sibling decision
+gbrain config set mentions.alias_deny "Copper Fox" # drop a derived name (or frontmatter alias_deny: on one page)
+gbrain config set search.alias_fanout_max 0 # turn the alias fan-out off
+```
+
+**Say to your agent:** *"Find every record about the Acme account, under any name it goes by."*
+
+### Things to watch
+
+- **One-time rescan.** The alias and mention extractor versions moved (`MENTION_EXTRACTOR_VERSION` 4, `ALIAS_DERIVATION_VERSION` 3), so every brain re-derives aliases and rescans mentions once on its next `gbrain extract --stale`; cards show `coverage: pending` until it finishes, even on a brain where no page changed.
+- **Migration v223** adds `persistence_requests.client_request_id` (nullable).
+- **Search output grew** by one count line and one date line per call; the starter tool list stays within its 25,000-character budget.
+- **Settings:** `mentions.multiword_aliases`, `mentions.sibling_merge`, frontmatter `identity: separate`, `search.demote_generated` (all on by default) are the off switches.
+- **Latency.** Alias fan-out measured 16 ms p50 on a 3,100-page PGLite brain. The keyword count runs beside the search with a 2-second deadline; a late count says "unavailable", never zero. Per-cell latency on the benchmark was harness scheduling (slot queue and restore), not gbrain; the slowest gbrain searches were email-typed filters on the real corpus, filed for profiling.
+- **Not in this release:** owner-based names ("Dana's freight account"), recall that follows "A now uses B's code" chains, and the other items filed in TODOS.
+
+### Itemized changes
+
+- Alias grammar (`src/core/mentions/aliases.ts`, spec `docs/designs/ALIAS_CONVENTIONS.md`): `declarationsIn` with prose cues, label lines, table rows and quoted defined terms; up to 4-token captures with possessive, common-word and relational-noun guards; `mentions.alias_deny`, frontmatter `alias_deny`, `mentions.multiword_aliases`.
+- Identity siblings (`src/core/mentions/siblings.ts`): one rule for the card, the fan-out and the gazetteer; `buildGazetteer` keeps a name claimed by a sibling group and `findMentionedEntities` links every sibling; `identity_siblings_capped` notice.
+- Entity card identity fields (`src/core/verbs/entity-card-identity.ts`), excerpt cut from `sanitizeRemoteBody`.
+- Alias fan-out (`src/core/search/alias-fanout.ts`): `resolveQueryEntity`, alias-required keyword queries via `SearchOpts.rankQuery` on both engines, `fanout` meta, `alias_fanout` notice; search and query emit `mention_index` when the resolved entity's source is still being indexed.
+- Version-aware mention coverage without a migration (`src/core/mentions/coverage.ts`, `pass.ts`): pending counts version-behind pages, the policy fingerprint covers the new settings, post-upgrade names the sweep.
+- Keyword counts and paging (`src/core/search/keyword-paging.ts`, `keyword-statement.ts`, `src/core/engine-sql/keyword-pages.ts`): `countKeywordPages`, `searchKeywordPages`, keyset `next`, `keyword_count_unavailable` stage; errors `search_mode_local_only`, `search_cursor_requires_keyword`, `search_offset_over_cap`.
+- Date labels (`src/core/search/date-labels.ts`) and lean rows keep `effective_date_source`, `matched_alias`, `provenance`, `evidence_omitted`.
+- Generated-page demotion (`src/core/search/provenance-demotion.ts`) in the identity-boost stage; corrections exempt.
+- Write ids (`src/core/persistence/preconditions.ts` `parseWriteRequestId`, UUIDv5 under a fixed namespace); `client_request_id` stored and echoed; `remember(items)` children still derive from the root string.
+- `remember` refuses a withdrawn claim before admission (`fact_withdrawn`); `replaces` accepts a target with no entity; failed receipts name their code.
+- Rerank failure reasons (`src/core/ai/gateway.ts`, `src/core/search/rerank.ts`, `src/core/interop-notices.ts`): a rerank timeout is reported as `timeout` (it was filed as a network failure); `reranker_health` names `provider_base_urls.<provider>` after repeated `unreachable` failures.
+- `docs/what-schemas-unlock.md` is linked, not inlined, in `llms-full.txt`.
+
+ ## [0.60.122.0] - 2026-10-09
+
+ **An eval-only evidence brief for the LongMemEval harness: a cheap model's claims, each with a verbatim quote, a pointer and a date, checked against the sessions before a reader sees them.**
+
+ Wave 1 of the 10x memory advantage plan asked whether a short, model-written brief can stand in for the five whole conversations gbrain hands a reader (about 14,000 tokens a question). `src/eval/longmemeval/evidence-brief.ts` is the builder the gbrain-evals pilot used. It makes no model call and changes no product default; nothing outside the eval harness imports it.
+
+ - **Grounded claims.** Every claim's quote is located in its session with the dream-cycle verifier (`groundSource`, `groundQuote`, `unsupportedNumericClaims`) and carries a pointer (session id, UTF-16 span, SHA-256 of the span and of the body) plus the session's date. Claims whose quote is not found, that cross or misattribute a speaker turn, that state a number the session does not, or that sit in instruction-like context are dropped and counted.
+ - **Provenance, not truth.** A paraphrase whose negation disagrees with its quote is withheld (the reader sees the quote), a later correction the brief did not cite is appended verbatim, and a count is never presented as complete. Unit fixtures cover an omitted correction, a reversed negation, a wrong attribution, a literally quoted malicious instruction, a false "complete" claim and an injection that tries to add a claim.
+ - **Scope wording.** An empty brief says "No supporting evidence was returned from the searched scope" and lists the sessions searched; it never says something is not in the brain. Claims render inside the reader's sanitized `<chat_session>` framing within a token budget, and the brief falls back to the full text when the builder's output cannot be parsed or most claims fail grounding.
+
+ ### Measured
+
+ The gbrain-evals pilot (garrytan/gbrain-evals#107, 100 LongMemEval-S development questions) found the Haiku-built 2,000-token brief kept Sonnet 5.5 at 92 of 100 against 93 for whole sessions, at $0.0079 against $0.0473 a question, with a p95 of 8.6 s against 2.5 s. A cheap model reading the whole sessions directly matched the brief at lower cost and latency, so the plan's preregistered off-ramp fired and the brief stays eval-only.
+
+ ### For contributors
+
+ - `test/e2e/client-grants.test.ts` reads `whoami`'s result block instead of joining the notice blocks prefixed to it. A brain whose sources row predates the fresh-brain grace gets the one-time `behavior_changes` disclosure on a client's first admitted call, which broke the JSON the D4 tests parsed whenever the shared CI database was old enough (forced probe: backdating `sources.created_at` by two hours fails both tests before the fix and passes after).
+ - `scripts/check-orphan-modules.mjs` permits the new eval-only module as test-only.
+
## [0.60.121.0] - 2026-10-09
**A managed catch-up on a live checkout finishes unattended: a page that moves under the run is held, a dropped database connection is retried, a relaunch resumes the frozen manifest, and `gbrain sync status` / `gbrain sync unblock` let an operator agent run the recovery loop without a human.**