Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Merge origin/master (9254987b5, v0.60.195.0) into capy/mpw2-w3-rerank-gate

garrytan14f2cc285aa0
diff --cc CHANGELOG.md
index 637658d415,b28593a159..8cf8dfdbc3
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -10,17 -10,21 +10,32 @@@ 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] - memory proof wave 2 W3 + W5, confidence-gated reranking and the page-unit ranking cut (#6445)
+
+**A page-unit call with its own budget now gets whole pages that fill that budget instead of many partial ones, and search can grade its candidates before the cross-encoder to report how often the reranker was paying for an answer retrieval already found. The page cut is on by default (`gbrain config set search.page_rank_cut off` restores the old path); the grade is off by default and never changes results.**
+
+### Itemized changes
+
+- `search.reranker.gate` (off by default) grades search candidates before the cross-encoder. `shadow` records how often the reranker was paying for an answer retrieval already found, in the response's `rerank_gate` metadata, on `--explain` and in a new `rerank_gate` section of `gbrain search stats`, and leaves results unchanged. A grade is strong when the top result is a vector match with cosine at least `search.evidence_cosine_floor` and `search.reranker.gate_min_gap` ahead of every other page. There is no skip mode: on the dev sets no question reached the 0.8 floor with voyage-4 embeddings, and the reranker changed about half the delivered tokens, so skipping it is not shipped. The cache key now includes the gate keys and `search.evidence_cosine_floor`.
+- `search.page_rank_cut` (default `whole_pages`) lets a `return_unit: "page"` call's own budget decide how many pages delivery gets. Before, ranking cut hits by chunk tokens to the mode's `search.tokenBudget` whatever the caller asked for: under tokenmax delivery was handed far more pages than fit and returned them as slivers, and under a mode cut small pages under-filled the budget. Now `search`, `query` and `recall` lift the mode cut, and delivery keeps ranked pages while their whole delivered size fits `search.page_rank_cut_factor` (default 1.5) × the budget, reporting `delivery.page_rank_cut`. Calls without a budget and other units are unchanged. On 72 BEAM conversations it was non-inferior to the cut off: −0.25 points, lower bound −1.00 against a −3 margin, with delivered context at budget. Those conversations are regression evidence, not a held-out test, and the 1.5 factor was picked under a rule amended after the dev results ([gbrain-evals #126 results](https://github.com/garrytan/gbrain-evals/blob/8b764e3e/docs/benchmarks/2026-10-13-memory-proof-wave-2-results.md)).
+- `recall` with `return_unit` and `budget_tokens` fills its budget. Delivery used to be sized to the whole budget, and the facts-first packer then dropped whole delivered blocks. It also re-costed those blocks with a chars/4 estimate while delivery had counted cl100k tokens, so even a call with no facts came back about 7% short. Delivery now gets what the facts leave (except under `query_first`), and delivered blocks cost what delivery counted.
+- The brain-ops and query skills and the ambient-recall guide now tell agents to pass the user's question as `recall`'s `question` for question-shaped lookups, so facts come back ranked by relevance (`facts_order: "relevance"`) instead of newest first, and to say so when `facts_degraded` reports keyword-only ranking. The `question` parameter's own description is unchanged.
+
+ ## [0.60.195.0] - 2026-10-13
+
+ **CI and the release build move to Bun 1.4.3, which carries the fix for the spawnSync hang that poisoned whole test shards (#6586).** On Bun 1.4.0 to 1.4.2, a garbage-collection finalizer that runs while `Bun.spawnSync` waits can leave the runtime's private spawnSync loop miscounted for the rest of the process (oven-sh/bun#34069). After that, a synchronous child spawn may never notice its child exit. A spawn with a timeout comes back `ETIMEDOUT` even though the child finished, and one without a timeout spins until the test deadline kills it. Run 38335527492 hit this twice: `test (2)` hung in `test/managed-sync-pinned-reads.test.ts` and was cancelled, while the identical code on the identical file order passed on master and on #6576. Bun 1.4.3 (released 2026-10-10) contains upstream commit 13a98b0. `compare/bun-v1.4.3...13a98b0` reports `behind`, which means the release already has the commit. The supported install floor stays at Bun 1.4.0.
+
+ Three gaps the hang exposed are fixed too, plus one Bun 1.4.3 change in `fetch` error wording that made a thin client's unreachable remote host read as a database error. A managed sync no longer mistakes a timed-out `git` child for a lost database connection. CI names the signature as soon as it appears instead of only when the test process exits. And the pinned-reads test no longer keeps running behind the next test after it times out.
+
+ ### Itemized changes
+
+ - **Bun 1.4.3 everywhere CI pins one version:** every `bun-version:` in `.github/workflows/`, the `['1.4.0', '1.4.3']` floor-plus-primary matrices (the 1.4.0 cells stay, since 1.4.0 is the supported floor), `docker-compose.ci.yml` (`bun run ci:local`), `scripts/ubicloud/setup-ci-vm.sh` and `scripts/ci-ubicloud.ts` (`bun run ci:ubicloud`), `tests/docker/`, and `scripts/setup-in-agent.sh`'s runtime pin for new in-agent installs (repairs keep the version their receipt records). `test/scripts/ci-pr-scope.test.ts` still requires every single-version pin to equal the primary. The release compiler (`release.yml`) now builds the published binaries on 1.4.3, so a compiled `gbrain` no longer carries the defect.
+ - **`isConnectionDrop` (`src/core/persistence/sync-drain.ts`):** a child-process error is no longer a dropped database connection. That covers Node's `syscall: 'spawnSync git'` and any message of the form `spawn(Sync) <cmd> E…`. Before, the drain's git reads coming back `spawnSync git ETIMEDOUT` printed "database connection dropped", reconnected the database, and counted a strike toward `connection_lost`, which pointed the operator at the wrong component. Now the error takes the drain's ordinary transient retry, with no reconnect and no connection line. The test throws a real `spawnSync` timeout and a synthetic `spawnSync git ETIMEDOUT` through `runDrain`. It fails on the old code, where the first is classified as a drop.
+ - **`scripts/capture-test-log.ts`:** two live notes, each printed once to stderr and appended to the job's step summary as soon as its evidence arrives. The first, `bun_spawnsync_poisoned?`, fires on the first `spawnSync <cmd> ETIMEDOUT` line and names its file. The second is the existing `bun_spawnsync_poisoned` verdict, the moment it holds. Before, the classifier ran only when the test process exited, so the cancelled #6578 job never named the signature. The tests replay that job's log shape and check a still-running capture's summary. Both fail on the old script.
+ - **`test/managed-sync-pinned-reads.test.ts`:** `afterEach` aborts the running arm's sync (`performSync` now gets the arm's signal), waits up to 20 s for the arm to unwind so its PATH override is gone, and prints the arm's Git calls: how long each took and which never finished. Each counter wraps the Git and PATH the file loaded with, never another arm's shim. Before, a timed-out test left PATH on its counting `git` shim. It also kept spawning Git behind the next test and threw `ENOENT` into the temp home that `afterAll` had already removed. The shim now records a start and end line per call (`calls()` counts are unchanged). Forced probe: with the test deadline cut to 4 s and a `git` that sleeps 200 ms, a trailing test that checks PATH and the arm's Git log fails on the old file and passes on the new one.
+ - **A thin client's refused remote MCP host no longer reads as a database error on Bun 1.4.3 (`src/cli/cli-error.ts`).** Bun 1.4.3's `fetch` reports a refused connection as `ECONNREFUSED: Unable to connect…` with code `ECONNREFUSED`, where 1.4.2 said `Unable to connect…` with code `ConnectionRefused`. The fatal CLI seam ran every error through the database access classifier first. So on 1.4.3, a thin client whose remote host was down printed `GBRAIN_DB_ACCESS conn_refused` and "switch to the transaction pooler … Run: gbrain db-repair" instead of `Error [unavailable] … Fix: gbrain remote doctor`. The first full gate on 1.4.3 caught it in `test/cli-thin-client-refusal-matrix.test.ts`. A `RemoteMcpError` now skips the database classifier, and a refused Postgres connection still gets the marker and the db-repair line. `test/cli-fatal-remote-mcp-6586.test.ts` fails on the old seam on any Bun. The thin-client goldens (`test/fixtures/goldens/cli/thin-client-{cases,routing}.json`) take 1.4.3's `ECONNREFUSED: ` message prefix, and no other line changes. This affects anyone already running gbrain from source on Bun 1.4.3, not only CI.
+ - `TODOS.md`: the P2 "Bump Bun when a release carries 13a98b0" item is done. `docs/TESTING.md`, `docs/RELEASING.md`, `docs/guides/authorization-upgrade.md` and `native/locks/README.md` name 1.4.3 as the CI and build runtime.
+
## [0.60.194.0] - 2026-10-13
**A Postgres read that follows a failed statement on the same pooled connection now gets back only its own rows.** A statement that streamed rows and then failed (a runtime error after its first rows, or a cancel or timeout while it was still producing them) left its row count behind in the driver. The next statement on that connection then returned its rows after that many empty slots. So `persistence_brain`'s one-row read came back as two rows, and a managed connector sync refused with `storage_error` ("requires exactly one known boolean persistence state") before its sweep started. Before the strict readers, the same read came back as `enabled = false` and the run took the unmanaged path (#6482). A cancel at consumer stop is enough to leave the count behind.
diff --cc src/core/behavior-change-notice.ts
index ba79270973,67e517d102..3cb8e61f26
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@@ -520,11 -520,6 +520,11 @@@ export const BEHAVIOR_CHANGES: Readonly
{ since: '0.60.190.0', text: 'Pools count reconnects of connections retired after an incident (stuck, desynced, or closed under running statements): `recovered` and `recovery_failed` in `/health?deep=1` and `getPoolDiagnostics()`, and a failed reconnect logs `pg_connection_recovery_failed`. `gbrain serve` writes its stuck, desync and recovery events to the pool-recovery audit, so `gbrain doctor --only pool_reap_health` now fails on a recovery failure and warns on a stuck or desynced connection in the last hour.' },
// #6554 (GBRA-60 D8). `since` is provisional (current VERSION); the integrator restamps it at the merge slot.
{ since: '0.60.191.0', text: '`gbrain bootstrap harness` now wires the Codex SessionEnd transcript-capture hook (its `hooks.json` group and `config.toml` trust entry) only when capture is on: turning capture off with its no-capture flag skips it, and registrar mode (a non-loopback `--url`) skips it like every other hook, because the hook talks to the local brain rather than the registered remote serve. The consent block names the hook when it is wired. A hook an earlier run installed stays until `gbrain bootstrap harness --remove`. New: `gbrain setup codex` wires Codex MCP and read-context hooks with hash-owned entries.' },
+ // W3 confidence-gated reranking (memory proof wave 2). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.
- { since: '0.60.194.0', text: '`gbrain search stats --json` and the `search_stats` tool now always include a `rerank_gate` section, all zeros until you set `search.reranker.gate` to `shadow`; search results and ranking are unchanged. The search cache key now includes `search.evidence_cosine_floor` and the new gate keys (the result cache stays disabled).' },
- { since: '0.60.194.0', text: '`recall` with `budget_tokens` and a `return_unit` now fills its budget: saved facts are packed first and the delivered evidence gets the budget they leave, so the same parameters return more evidence (up to about 16% more on long conversations). Before, delivered blocks were dropped after the facts and re-counted with a rougher estimate. `budget_policy: "query_first"` is unchanged.' },
++ { since: '0.60.195.0', text: '`gbrain search stats --json` and the `search_stats` tool now always include a `rerank_gate` section, all zeros until you set `search.reranker.gate` to `shadow`; search results and ranking are unchanged. The search cache key now includes `search.evidence_cosine_floor` and the new gate keys (the result cache stays disabled).' },
++ { since: '0.60.195.0', text: '`recall` with `budget_tokens` and a `return_unit` now fills its budget: saved facts are packed first and the delivered evidence gets the budget they leave, so the same parameters return more evidence (up to about 16% more on long conversations). Before, delivered blocks were dropped after the facts and re-counted with a rougher estimate. `budget_policy: "query_first"` is unchanged.' },
+ // W5 adaptive page-unit cut, default on after memory proof wave 2 (gbrain-evals #126). `since` is the VERSION placeholder.
- { since: '0.60.194.0', text: 'A `return_unit: "page"` call that passes its own budget (`token_budget` on `search` and `query`, `budget_tokens` on `recall`) now stops adding pages once their whole delivered pages fill 1.5 times that budget (`search.page_rank_cut: whole_pages`, `search.page_rank_cut_factor: 1.5`), and the search mode\'s chunk-token cut no longer limits it: you get fewer pages, more of them whole, filling the budget, instead of many partial ones. On 72 BEAM conversations (regression evidence, not held-out) accuracy moved -0.25 points against the cut off (lower bound -1.00, non-inferior at the -3 margin) with delivered context at budget. The response reports it as `delivery.page_rank_cut`. `gbrain config set search.page_rank_cut off` restores the old behavior.' },
++ { since: '0.60.195.0', text: 'A `return_unit: "page"` call that passes its own budget (`token_budget` on `search` and `query`, `budget_tokens` on `recall`) now stops adding pages once their whole delivered pages fill 1.5 times that budget (`search.page_rank_cut: whole_pages`, `search.page_rank_cut_factor: 1.5`), and the search mode\'s chunk-token cut no longer limits it: you get fewer pages, more of them whole, filling the budget, instead of many partial ones. On 72 BEAM conversations (regression evidence, not held-out) accuracy moved -0.25 points against the cut off (lower bound -1.00, non-inferior at the -3 margin) with delivered context at budget. The response reports it as `delivery.page_rank_cut`. `gbrain config set search.page_rank_cut off` restores the old behavior.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */