Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/master' into community/w-s1-search-takes
garrytana2f129a89875
diff --cc CHANGELOG.mdindex 7a3558c834,4279bd2458..81008ae44f--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,47 -10,20 +10,61 @@@ credits are retained; no result has beeidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [Unreleased]++**Eight search, recall, takes, trajectory and open-loop answers that were quietly wrong or quietly costly now behave.** A keyword listing no longer drops its total just because the rows took a moment to load. Searching for a page by its handle finds that page even when the search also tries the entity's other names. Link and graph results stop hiding a page name that merely looks like an API key. A take that was true only for a stretch of time reaches `gbrain think` with its dates. A monthly revenue figure is no longer reported as a crash because it came after an annual one. And when the brain cannot read its list of sources, the `open_loops` answer says it does not know instead of calling your inbox clean. A process holding several embedded brains no longer throws out every brain's in-flight query embeddings when one engine closes, so the next identical query is not paid for again. And a Postgres role that can read `pages` but does not own it stops warning about planner statistics on every import.++### What you'd see++| You ask for | Before | Now |+|---|---|---|+| `search` with `match: "keyword"` on a slow brain | "Keyword match count unavailable" | the total |+| keyword search for `acme-example`, a company with an alias | the alias matches, not the company page | both, counted |+| `get_links` to `districts/pa-<long name>` | `districts/<REDACTED:voyage>` | the slug |+| `think` over a take held Sep to Jan | a claim with no dates | `since=… until=… source=…` |+| `gbrain eval trajectory` with an annual then a monthly MRR | a 92% "regression" | nothing flagged |+| repeating a query in brain B after brain A closed mid-embed | a second paid embedding call | the cached vector |+| `gbrain import` as a non-owner role after the owner ran `ANALYZE` | "Projection planner statistics were not refreshed" every time | quiet; a large pass still warns once |+| `open_loops` when the sources table cannot be read | "no google source", coverage complete | `no_google_sources: null`, coverage partial, a notice to retry |++### Things to watch++- `takes_search` rows now carry `since_date`, `until_date` and `source`, the same fields `takes_list` already returns for the same takes.+- A trajectory regression now needs two observations with the same unit and period at different dates. When two different values are reported for one date, that date is skipped and the dates on either side are compared. An observation with no unit or period only compares with others that also lack it.++### Query embeddings and planner statistics++A process that holds several embedded brains (an MCP host, an app that opens one engine per user) used to discard every query embedding still in flight anywhere in the process whenever any one engine closed, so the next identical query in a surviving brain went back to the provider and was paid for again. Each embed in flight now belongs to its own engine: closing one engine only stops that engine's embeds from being cached.++On Postgres, when gbrain connects as a role that can read `pages` but does not own it (an app role next to an owner that runs maintenance), every `gbrain import`, sync and reindex printed `Projection planner statistics were not refreshed: database-owner maintenance is required`, even right after the owner ran `ANALYZE`, and `gbrain doctor` reported the projection statistic as absent. Postgres shows expression statistics only to the table owner, so gbrain read "hidden" as "missing". It now reads them as not inspectable: a small write pass stays quiet, and a pass large enough that the owner should analyze (50 + 10% of pages) still warns once.++### Itemized changes++- `src/core/search/keyword-paging.ts`: `readKeywordPage` passes its row read to `countKeywordMatches`, so the count waits for the rows plus the grace, as on the hybrid path. Reported and first fixed by @akinduroifedayo in #8500.+- `src/core/search/keyword-handles.ts`: `slugHandles` judges each alternative of a bare `OR` on its own; a negation or a non-handle phrase only stops its own alternative's handles, and quote marks split words and an empty phrase is ignored, as in `websearch_to_tsquery`. Reported and first fixed by @javieraldape in #8633.+- `src/core/search/output-redaction.ts`: `from_slug`, `to_slug`, `origin_slug` and their `*_source_id` are identity fields; link context is still scanned. Reported and first fixed by @calebhicks in #8545.+- `src/core/engine-sql/takes.ts`, `src/core/engine.ts` (`TakeHit`), `src/core/utils.ts`, `src/core/think/gather.ts`, `src/core/think/sanitize.ts`: both take searches select `since_date`, `until_date` and `source`; think renders `until=`, and all three attribute values, plus any holder outside the holder grammar, are neutralized and escaped like the claim. Takes SQL-text and export-surface goldens regenerated. Reported and first fixed by @calebhicks in #8546.+- `src/core/trajectory.ts` (`comparablePairs`), `src/core/trajectory-format.ts`: regressions and the `(superseded prior)` annotation pair only same-metric, same-unit, same-period observations at a strictly later date, and a point with no finite date is left out instead of dropping the entity's whole trajectory block. Reported and first fixed by @calebhicks in #8547 and #8541.+- `src/core/ops/loops.ts`, `src/core/error-registry.ts`, `src/core/notice-ledger.ts`: a failed sources read answers `no_google_sources: null`, `completeness: "partial"` and a `loops_source_read_failed` notice with no database error text; the digest says so. `skills/google-loops/SKILL.md` names the case. Reported and first fixed by @javieraldape in #8718.+- `src/core/ai/query-embed-cache.ts`, `src/core/ai/gateway.ts`, `src/core/ai/engine-gateway.ts`: an engine's close (`dropQueryEmbeddingsTagged`) no longer bumps the process-wide generation. It marks that engine's gateway state `released`, and `embedQuery` skips the store when the state it started under was released, so only the closed engine's in-flight embeds are dropped. A `cache_namespace` engine keeps its in-flight embed for the reopened brain, and a full `clearQueryEmbedCache` still drops every one. Reported and first fixed by @javieraldape in #8639.+- `src/core/search/projection-statistics.ts`: `can_inspect` applies `pg_stats_ext_exprs`'s own rule (`pg_has_role(relowner, 'USAGE')` outside row security), so a SELECT-only role reads the projection statistic as `uninspectable` instead of `uncollected`; `missingSearchStatistics` and doctor `planner_stats_stale` stop listing it as absent (doctor says the role cannot inspect it and adds `projection_statistics: "uninspectable"` to its details, instead of calling it fresh), and `statisticsStillCurrent` lets a pass below the threshold skip the refresh when the statistic is collected or not inspectable. Reported and first fixed by @Masashi-Ono0611 in #8630.+- Tests: `test/search-keyword-paging.test.ts`, `test/search/keyword-handles.test.ts`, `test/search/keyword-handles-or-alternatives-8618.test.ts`, `test/search/output-redaction-link-slugs-8545.test.ts`, `test/takes-search-validity-8546.test.ts`, `test/trajectory.test.ts`, `test/trajectory-format.test.ts`, `test/loops-source-read-failure-8452.test.ts`.+- Tests (query embeddings and planner statistics): `test/engine-gateway-state.test.ts` (closing engine A while engine B's query embed is in flight leaves B's vector cached, so repeating the query makes no provider call; an engine's own in-flight embed is still not cached after it closes); `test/engine-cache-namespace.test.ts` (a namespaced engine's in-flight embed is still there for the reopened brain); `test/projection-statistics.test.ts` (a SELECT-only role over owner-analyzed statistics: nothing missing, `cannot be inspected`, two small passes refresh nothing and print nothing, a large pass warns once); `test/e2e/planner-stats-postgres.test.ts` (doctor run as a SELECT-only role reports the projection statistic as uninspectable).++ ## [0.60.621.0] - 2026-11-09++ **A page a member-bound credential creates in the `default` source is now readable only by that member.** A token bound with `gbrain auth rescope --member <id>` and no `--sources` writes to `default`, the source every credential without a source grant reads, and so does a token granted `--sources default` and an OAuth client left at its registration default. Its `put_page` (and every page write through the same path) used to create an ordinary page there, which another member and an unbound token read through `get_page`, `search`, `query`, `recall` and `list_pages`; its `remember` facts were already kept on the member's own page. A page such a credential creates is now written with `readable_by: [member:<id>]`, in the database row on a repo-less brain and in the file on a repo brain; rewriting it without `readable_by` keeps the stored readers, and the member widens it by naming readers. An edit to an existing page that names no readers leaves it shared, and `POST /ingest`, which cannot keep a page to a member, refuses such a credential with `permission_denied`. Member-bound credentials whose write source is another source (the documented `--sources private-<member>,default` shape) and unbound credentials write exactly as before, apart from slugs a member now creates. Pages derived from such a page (extracted atoms, chronicle events, `derived_from` pages, and a synthesized concept that uses it) follow the rule for pages with readers and are readable by no remote caller, the writer included. A page that teammates should read, such as a shared `people/` or `companies/` entity page or a page in a folder a rule already scopes to a group, names its readers when it is created; otherwise the first member to create a slug keeps it, and every other remote credential writing that slug (another member, an unbound token, a shared agent) gets `page_not_found`. The operator widens such a page from the brain host by adding `readable_by` to it (the local CLI is not member-scoped). A member-bound `put_page` over a page deleted within the last 72 hours is a create, so it is kept to the member too. Pages written before this release keep whatever readers they have: `gbrain access who-can-read <slug>` shows who reads one.++ ### Itemized changes++ - `src/core/persistence/page-visibility.ts`: `defaultSourceMemberWriter` reads, live from the stored principal, whether a remote write to `default` comes from a token or OAuth client bound to an enabled member (never for a local, unbound, attested or audience write); `defaultSourceWriterReaders` gives a page such a writer sends without `readable_by` the stored page's readers, or the writer alone when the write creates the page.+ - `src/core/persistence/page-prepare.ts`: page preparation applies it to the frontmatter before the content hash, the rendered file and the stored row are made (restores and reverts excluded).+ - `src/core/persistence/upload-streamed.ts`: a page uploaded over the single-string ceiling gets the same readers.+ - The binding is read straight from the token or client row, so a lookup that fails refuses the write instead of publishing the page shared, and a write bound to a disabled member is refused (`readable_by_invalid`).+ - `src/commands/serve-http-webhooks.ts`: `POST /ingest` refuses a member-bound credential whose write source is `default` before anything is queued.+ - Docs: `docs/guides/multi-source-brains.md`, `docs/tutorials/company-brain.md` (Model C), `docs/mcp/ADMIN.md`.+ - Tests: `test/access-ungranted-member-writes.test.ts` (repo-less PGLite and Postgres, plus a repo brain: tokens with no grant and with `--sources default` and an OAuth client at its registration default; another member and an unbound token read nothing of a new page over `get_page`, `search`, `query`, `recall` and `list_pages`; the writer reads, rewrites and widens it; a shared page stays shared; `remember` unchanged; the documented shape unchanged and unstamped; `POST /ingest` refused with nothing queued).+## [0.60.620.0] - 2026-11-09**A diverged managed checkout now publishes its local commits on refresh by default when Git durability is on, after a secret scan of those commits.** Commits a script made with plain `git commit` in a managed checkout used to strand there whenever the remote moved: every `gbrain sources refresh` refused `refresh_diverged` and asked the user, unless `sources.refresh_publish_diverged` was set to `true`. With the setting unset, a worktree whose Git durability is on (`gbrain sources writer git-durability <source> --enable`, or the legacy hook) now publishes them itself: the local commits merged with the upstream in memory, never a rebase or force-push, then the fast-forward. The publish child scans, under its publish lock and for the exact commits it pushes, what they add: commit messages, added lines (including a value a later commit removed) and merge-commit conflict resolutions. A value that looks like a secret, added text too large to scan, or a commit that changes `.gbrain-scan-allow` or a `.gitattributes` refuses the new `publish_secret_found` naming the file, line, rule and commit, never the value, with nothing pushed; commits the scan cannot read in full refuse `publish_scan_unreadable` instead. The rewritten-upstream refusal and the `--expect-remote` bound are unchanged. `false` turns it off; `true` still publishes with durability off.