Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
v0.60.51.0: CHANGELOG, eval results for the round-trip diet and admit-ahead (#5984)
garrytan91a2ca756d38
diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.jsonindex bae12eb663..45fd7e7300 100644--- a/.claude-plugin/plugin.json+++ b/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain",- "version": "0.60.48.0",+ "version": "0.60.51.0","description": "Personal knowledge brain for your coding agent — hybrid search, synthesis, graph traversal, and durable cross-session memory over Postgres/PGLite with pgvector, plus a curated brain-first skill set.","author": {"name": "Garry Tan",diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.jsonindex 126a098877..69ff7ce5f0 100644--- a/.codex-plugin/plugin.json+++ b/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain",- "version": "0.60.48.0",+ "version": "0.60.51.0","description": "Personal knowledge brain for your coding agent — hybrid search, synthesis, graph traversal, and durable cross-session memory over Postgres/PGLite with pgvector, plus a curated brain-first skill set.","author": {"name": "Garry Tan",diff --git a/BOOTSTRAP_FOR_AGENTS.md b/BOOTSTRAP_FOR_AGENTS.mdindex deb02fd956..637e0568f9 100644--- a/BOOTSTRAP_FOR_AGENTS.md+++ b/BOOTSTRAP_FOR_AGENTS.md@@ -1,4 +1,4 @@-<!-- gbrain-runbook-stamp: 0.60.48.0 -->+<!-- gbrain-runbook-stamp: 0.60.51.0 --><!-- This stamp must equal the VERSION file at every release; CI enforces it(scripts/check-bootstrap-tag.sh). `gbrain bootstrap status` compares it tothe installed binary and warns on skew. -->diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 32213b24fd..784607ec12 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -10,6 +10,65 @@ credits are retained; no result has been reassigned to another provider. Originaidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [0.60.51.0] - 2026-10-04++**A managed Postgres brain far from its database catches up a sync backlog about 2.7 times faster again, and every write to it costs fewer round trips (#5984).**++On a brain with managed writes and a database across the internet, `gbrain sync` drains a backlog in one run, but each page still took about 48 network round trips to save, and the next batch of pages waited until the previous one had committed. Each page now costs about 17 round trips, and the next batch is prepared and queued while the current one is still being saved. On a test rig with 57 ms to the database, a 10,000-file backlog now takes about 5.4 hours instead of about 11. Every page still gets its own write receipt, pages still land in file order, and a failed page still stops the run before anything after it is published.++### The numbers that matter++| 57 ms to the database | Before | Now |+| --- | --- | --- |+| 500-file backlog, pages per minute | 10.6 | 28.8 |+| 10,000-file backlog (300-word pages) | about 10.7 h | about 5.4 h |+| Round trips to save one page in a bulk group | 48 | 17 |+| Time the brain-wide write counter stays locked per batch | 0.72 s | 0.12 s |+| A foreground write while catching up (p95) | 18.2 s (15.5 s idle) | 15.1 s (14.9 s idle), no failures |+| Same backlog next to the database | 527 pages/min | 545 pages/min |++### Things to watch++- Finish a running catch-up before downgrading gbrain. An older version refuses a batch this version queued ahead, and its sync stops with a conflict instead of saving a page twice.+- Nothing is queued ahead while foreground writes are recent (one in the last minute), so a busy agent session slows a catch-up but its own writes stay fast.+- 150 pages/min at 57 ms is still not reached. It needs several batches saved at once, which is a separate change.++## To take advantage of v0.60.51.0++`gbrain upgrade` should do this automatically. If it didn't, or if `gbrain doctor` warns about a partial migration:++1. **Run the orchestrator manually:**+ ```bash+ gbrain apply-migrations --yes+ ```+2. **Nothing else to migrate.** There is no schema change; the next `gbrain sync` uses the new path.+3. **Verify the outcome:**+ ```bash+ gbrain sync --source <id> --no-pull --json+ ```+ `drain.bulk.admitted_ahead` counts the batches queued while the previous one was saving.+4. **If any step fails or the numbers look wrong,** please file an issue:+ https://github.com/garrytan/gbrain/issues with:+ - output of `gbrain doctor`+ - contents of `~/.gbrain/upgrade-errors.jsonl` if it exists+ - which step broke++ This feedback loop is how the gbrain maintainers find fragile upgrade paths. Thank you.++### Itemized changes++- **Admit-ahead** (`src/core/persistence/sync-window.ts`, `admitAhead` in `sync-run.ts`): while a bulk group publishes, the drain freezes and admits the next group into the cursor's `window`. Window members name the previous group's last request (`intent.after`); the consumer cancels a window group whose predecessor did not commit, publication re-checks it once per transaction, and the drain cancels the window's queued members after a failed page (reason: "An earlier page of the same sync did not commit"). The publication fence reads the cursor `FOR KEY SHARE` and accepts window members, so cursor saves no longer wait for the publishing group. `drain.bulk.admitted_ahead` reports the count.+- **One preimage and one postimage per page**: publishers pass their in-transaction page read to `apply(tx, preimage)` and the version row; managed-sync imports run coordinated (no re-read, one read after the last write feeds the read-back check, projections, a single text seal, provenance, receipt and effects).+- **Per-transaction memos** (`transactionMemo`, `src/core/page-state/transactions.ts`) for the local writer row, source membership, embedding config and the hold summary.+- **Chunks**: the chunk insert binds its rows as one JSON document (stable, prepared text); a complete replacement seals `chunker_version` in the statement that locks the page row.+- **Set-based group completion** (`completeGroup`, `group-publish.ts`): effect bytes are read before the counter lock; the counter lock and one `UPDATE ... FROM unnest(...) RETURNING` that checks every member's claim and terminal reservation are pipelined; a short `RETURNING` rolls the group back to the single path, where each member gets its own error code.+- **Pipelining** (`pipelined`): independent statements inside one page's chain share a round trip on direct Postgres; PGLite and transaction-mode PgBouncer run them one by one.++### For contributors++- The bench reports a per-phase critical path, group publication and counter-hold breakdowns, effects per group and foreground round trips (`--analyze <trace.jsonl>` for a kept trace); `scripts/bench/managed-sync-pipeline-spike.ts` records what postgres.js pipelines. Results are in `docs/eval/managed-sync-catchup.md` ("Round-trip diet 2" and "Admit-ahead").+- Goldens regenerated for the prepared chunk insert (`sql-text/chunks.json`, `_driver.json`) and the export surface (`verifyPageReadable`; optional `preimage` on `createVersion`, `sealChunkerVersion` on `upsertChunks`).+## [0.60.48.0] - 2026-10-04**A managed Postgres brain now catches up a big sync backlog in one `gbrain sync` run, about 4.6 times faster, and the run tells your agent exactly what happened and what to do next (#5984).**diff --git a/VERSION b/VERSIONindex 34d19106af..028d240923 100644--- a/VERSION+++ b/VERSION@@ -1 +1 @@-0.60.48.0+0.60.51.0diff --git a/docs/eval/managed-sync-catchup.md b/docs/eval/managed-sync-catchup.mdindex d42741886e..05783bfc21 100644--- a/docs/eval/managed-sync-catchup.md+++ b/docs/eval/managed-sync-catchup.md@@ -633,3 +633,57 @@ admission and 1.4 claim waves. Between two group commits about 7 s isfreeze, admission, cursor saves, claim and prepare, all strictly afterthe previous commit; that is the gap Phase 1.5 (the cursor window)targets.++## Admit-ahead (150 pages/min plan, Phase 1.5)++While a bulk group publishes, the drain freezes and admits the next group+and records it in the cursor's `window` (`src/core/persistence/sync-window.ts`).+The per-worktree FIFO claim is unchanged: the window group waits queued+behind the publishing group, and the consumer claims it as soon as that+group commits. Window members name the previous group's last request+(`intent.after`); the consumer cancels a window group whose predecessor+did not commit, publication re-checks the predecessor, and the drain+cancels the window after a failed page, so no page publishes after an+earlier page of the same sync failed. Publication reads the cursor+`FOR KEY SHARE` and accepts `pending`, `group` and `window` members, so+the drain's cursor saves no longer wait for the publishing group (the+`FOR SHARE` read they used to wait on would have serialized admit-ahead+behind publication). Nothing is admitted ahead while foreground writes+are recent (one was queued on the worktree in the last minute).++Same host and bench as the diet table above, 57 ms rows time-boxed at+10 min (the 10k row at 15 min):++| Measure | Master `6622a119` | Admit-ahead only | Diet only | Diet + admit-ahead |+|---|---|---|---|---|+| `cli` pages/min, 57 ms | 10.6 | 13.4 | 24.5 | **28.8** |+| Gap between group publications, 57 ms (p50) | about 5.6 s | 2.2 s | about 7 s | 3.7 s (claim + prepare of an 8 to 9 page group) |+| Pages per group (steady state) | 3 to 4 | 4 | 7 to 9 | 8 to 9 |+| `cli` 10k files, 300-word pages, 300 receipts, 57 ms | 3.4 pages/min on v0.60.39 (about 49 h); 15.7 on v0.60.48 (about 10.7 h) | | | **30.9 pages/min, about 5.4 h** |+| `cli` pages/min, ~0 ms | 527 | 514 | 504 (3-run median) | 545 |+| Foreground `put_page` p95 at 57 ms, idle / during catch-up | 15.5 s / 18.2 s, 0 failures | 15.3 s / 17.7 s, 0 failures | 15.0 s / 14.7 s, 0 failures | **14.9 s / 15.1 s, 0 failures, 0 lock timeouts** |+| Catch-up while a `put_page` arrives every second, 57 ms | 3.9 pages/min | 3.8 | | 4.4 |++The foreground idle figure comes from 5 writes per run, so single-run p95+values carry about ±1 s of noise; master on this host shows the same+during-catch-up excess as admit-ahead alone.++Per-phase critical path with both changes (57 ms `cli` row, p50 per+occurrence): publication 10.9 s (180 waves, 21.8 per page), prepare 2.5 s+(144 waves, 17.7 per page), freeze 1.2 s, admission 1.1 s, claim 0.36 s,+cursor save 0.37 s. Freeze and admission of the next group now overlap the+publishing group; claim and prepare still run strictly between two group+commits (15.0 s from commit to commit, p50).++### Against the 150 pages/min target++With both changes one sync catches up at about 29 to 31 pages/min at 57 ms+(about 2.7 times master, about 5.4 h for the 10k backlog). The plan's+forecast for these phases was 36 to 40; the difference is prepare, which+grew with group size (17.7 waves per page) and still sits between commits.+Reaching 150 needs parallel publication (Phase 2, lanes), which waits for+the owner's decision. A cheaper step that stays single-lane is to prepare+the window group's members while the current group publishes (prepare is+read-only and its results are re-validated in the publication+transaction); at the measured costs that would remove about 2.5 s of the+15 s cycle, for roughly 33 to 35 pages/min.diff --git a/llms-full.txt b/llms-full.txtindex 57bab91e74..c0c8c5cca2 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -6009,11 +6009,18 @@ transaction, and the writer publishes the group in one transaction. Everypage still gets its own write request, receipt, attribution and failurereport; if one page fails, the pages before it commit, that page is reported,and the pages after it are cancelled and re-frozen once it is fixed. Group size-adapts so a group takes about `sync.bulk_max_txn_ms` (default 15 s); a-foreground write waits behind at most one group. Turn bulk off with+adapts so a group takes about `sync.bulk_max_txn_ms` (default 15 s). While a+group publishes, the drain freezes and admits the next one, so the writer+starts it as soon as the current group commits. Nothing is admitted ahead+while foreground writes are recent (one was queued in the last minute), so a+foreground write waits behind at most the group that is publishing. If a page fails, the group admitted ahead of it is+cancelled with the reason "An earlier page of the same sync did not commit"+and re-frozen once the failure is fixed. Turn bulk off with`--no-bulk`, `GBRAIN_SYNC_BULK=0` or `gbrain config set sync.bulk false`. Thefinal JSON reports `drain.bulk` (`enabled`, `reason` when off, `groups`,-`largest_group`). PGLite publishes without network round trips and does not+`largest_group`, `admitted_ahead`). Finish a drain before downgrading gbrain:+an older version refuses a group this version admitted ahead, and the sync+stops there instead of publishing a page twice. PGLite publishes without network round trips and does notuse bulk groups.*Written* pages published a change. *Waived* entries needed no write (andiff --git a/openclaw.plugin.json b/openclaw.plugin.jsonindex 3cf3086649..d3c41807ff 100644--- a/openclaw.plugin.json+++ b/openclaw.plugin.json@@ -1,7 +1,7 @@{"id": "gbrain-context-engine","name": "gbrain",- "version": "0.60.48.0",+ "version": "0.60.51.0","description": "Personal knowledge brain with Postgres + pgvector hybrid search","family": "bundle-plugin","kind": "context-engine",diff --git a/package.json b/package.jsonindex a91018fb95..9443b10473 100644--- a/package.json+++ b/package.json@@ -212,7 +212,7 @@"bun": ">=1.4.0"},"license": "MIT",- "version": "0.60.48.0",+ "version": "0.60.51.0","overrides": {"@ai-sdk/provider-utils": "4.0.56","@hono/node-server": "^2.0.5",diff --git a/plugin-variants/gbrain-coding/.claude-plugin/plugin.json b/plugin-variants/gbrain-coding/.claude-plugin/plugin.jsonindex 533aa47a53..9d21ad0e9d 100644--- a/plugin-variants/gbrain-coding/.claude-plugin/plugin.json+++ b/plugin-variants/gbrain-coding/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-coding",- "version": "0.60.48.0",+ "version": "0.60.51.0","description": "Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant. (persona variant of the gbrain plugin — 21 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-coding/.codex-plugin/plugin.json b/plugin-variants/gbrain-coding/.codex-plugin/plugin.jsonindex 43c1351a75..215a61a8a7 100644--- a/plugin-variants/gbrain-coding/.codex-plugin/plugin.json+++ b/plugin-variants/gbrain-coding/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-coding",- "version": "0.60.48.0",+ "version": "0.60.51.0","description": "Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant. (persona variant of the gbrain plugin — 21 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-coding/README.md b/plugin-variants/gbrain-coding/README.mdindex f42eb7b0bf..a74a7b1b58 100644--- a/plugin-variants/gbrain-coding/README.md+++ b/plugin-variants/gbrain-coding/README.md@@ -1,4 +1,4 @@-<!-- gbrain-plugin-tree-stamp: 0.60.48.0 -->+<!-- gbrain-plugin-tree-stamp: 0.60.51.0 --># gbrain-coding (generated persona variant — do not hand-edit)Brain-first coding agent working inside a repo: retrieval, routing, ingest discipline, correction hygiene. Default persona for the claude-code harness bridge; also published as the gbrain-coding marketplace variant.diff --git a/plugin-variants/gbrain-daily/.claude-plugin/plugin.json b/plugin-variants/gbrain-daily/.claude-plugin/plugin.jsonindex 45cc87ad3a..2f152f620e 100644--- a/plugin-variants/gbrain-daily/.claude-plugin/plugin.json+++ b/plugin-variants/gbrain-daily/.claude-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-daily",- "version": "0.60.48.0",+ "version": "0.60.51.0","description": "Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant. (persona variant of the gbrain plugin — 20 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-daily/.codex-plugin/plugin.json b/plugin-variants/gbrain-daily/.codex-plugin/plugin.jsonindex 042a7ecce9..49f2ae4b6b 100644--- a/plugin-variants/gbrain-daily/.codex-plugin/plugin.json+++ b/plugin-variants/gbrain-daily/.codex-plugin/plugin.json@@ -1,6 +1,6 @@{"name": "gbrain-daily",- "version": "0.60.48.0",+ "version": "0.60.51.0","description": "Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant. (persona variant of the gbrain plugin — 20 skills)","author": {"name": "Garry Tan",diff --git a/plugin-variants/gbrain-daily/README.md b/plugin-variants/gbrain-daily/README.mdindex 0fcb73a8ce..bc0925f82d 100644--- a/plugin-variants/gbrain-daily/README.md+++ b/plugin-variants/gbrain-daily/README.md@@ -1,4 +1,4 @@-<!-- gbrain-plugin-tree-stamp: 0.60.48.0 -->+<!-- gbrain-plugin-tree-stamp: 0.60.51.0 --># gbrain-daily (generated persona variant — do not hand-edit)Personal knowledge-brain daily use: meetings, tasks, briefings, reading, research. Published as the gbrain-daily marketplace variant.diff --git a/plugin/README.md b/plugin/README.mdindex c7ea253562..477db09c37 100644--- a/plugin/README.md+++ b/plugin/README.md@@ -1,4 +1,4 @@-<!-- gbrain-plugin-tree-stamp: 0.60.48.0 -->+<!-- gbrain-plugin-tree-stamp: 0.60.51.0 --># gbrain plugin skill tree (generated — do not hand-edit)This tree is the curated skill set for the gbrain Codex and Claude Codediff --git a/templates/bootstrap/template-repo/README.md b/templates/bootstrap/template-repo/README.mdindex 4321c345a8..7af2592a2c 100644--- a/templates/bootstrap/template-repo/README.md+++ b/templates/bootstrap/template-repo/README.md@@ -1,6 +1,6 @@# gbrain agent workspace — template-<!-- gbrain-template-stamp: 0.60.48.0 -->+<!-- gbrain-template-stamp: 0.60.51.0 -->This repository is the **"Use this template"** distribution artifact for a[gbrain](https://github.com/garrytan/gbrain) personal-agent workspace — the same