Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

docs: wave 7 CHANGELOG, behavior notice and key-files entries

time-attack235272dba702
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dd30ad65a5..2e784480f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,35 @@ credits are retained; no result has been reassigned to another provider. Origina
identifiers and attribution are available in the pre-removal Git revision
`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).
+## [0.60.141.0] - 2026-10-10
+
+**Re-importing and syncing unchanged files is 2.4x faster, `gbrain extract` finishes on a 50,000-page PGLite brain (114 s instead of hanging), a PGLite `serve` with a git backlog answers its first tool call in 0.6 s instead of 4.3 s, and a Postgres brain that lost its planner statistics gets them back instead of taking a minute per search.**
+
+Efficiency wave 7. Every number below is interleaved base vs this branch on the same 4-vCPU AMD EPYC / 16 GiB machine, Bun 1.4.2, synthetic brains (5k = 5,001 pages / 25,331 chunks, 50k = 50,010 / 248,802), cold processes, p50 / p95.
+
+| Path | Engine, brain | Before | After | N |
+|---|---|---|---|---|
+| unchanged re-import, 3,700 files | Postgres 5k | 35,310 / 36,281 ms | 14,268 / 15,552 ms | 3 |
+| unchanged re-import, 3,700 files | PGLite 5k | 19,278 / 20,138 ms | 8,111 / 8,254 ms | 3 |
+| first sync of an already-imported 3,700-file source | Postgres 5k | 119,230 / 137,457 ms | 87,227 / 88,866 ms | 2 |
+| first sync of an already-imported 3,700-file source | PGLite 5k | 84,242 / 91,485 ms | 63,996 / 65,691 ms | 2 |
+| `extract links --source db` from empty links | PGLite 50k | 1,485 s (3.5 → 59.9 ms/page) | 103 s in `extract all` (1.2-1.8 ms/page, flat) | 1 |
+| `extract all` watermark stamp | PGLite 50k | wedges at ~528 MB WAL | completes | 1 |
+| `serve` first tool call after a 50k import (29.8k queued git effects) | PGLite 50k | 4,340 / 4,596 ms | 630 / 726 ms | 10 |
+| git effects drained in 60 s of `serve` | PGLite 50k | 12.7k-14.0k | 20.0k-21.8k | 2 |
+| warm search with planner statistics deleted | Postgres 5k | 55,975 / 61,535 ms | 582 / 1,768 ms (564 after the first call) | 6 / 21 |
+
+### Itemized changes
+
+- **Skipped files cost less** (`persistence/import-mutations.ts`, `import-prepare.ts`, `noop-kernel.ts`, `sync-run.ts`, `sync-waivers.ts`, new `screening-paths.ts`, `shared-skills/knowledge-guard.ts`, `page-state/snapshot.ts`, `persistence/identity.ts`). A file the hash screen proves unchanged takes one page-snapshot read and no admission: the screen hands its snapshot to the preparer, which drops the duplicate path check and re-read, and the no-op kernel reports `revision_moved` when the page moved since. Other sources' realpath roots, the skillpack roots and the source Git scope are resolved once per screening batch (never across batches, never a thrown result), cutting openat/access/readlink syscalls 1.58M → 466k per re-import. `readPageSnapshot` computes its withdrawal fingerprints only when the page has withdrawals or `*` purges. `localHostId()` caches the validated `host.json` keyed by path, dev, inode, mtime, ctime and size (a file modified in the last 2 s is read, not cached), so a replaced or edited identity and a changed home still read fresh.
+- **PGLite extract at scale** (`pglite-engine.ts`, `pglite-engine/checkpoint-guard.ts`, `commands/extract.ts`). Autocommit writes through the engine's SQL helpers (`markPagesExtractedBatch` and the rest of `engineSql`) pass the same WAL checkpoint guard as `executeRaw`; before, the stamp loop reached PGLite's automatic checkpoint inside a write and spun forever. The `extract --source db` links walk refreshes planner statistics through `plannerStatsForLinkDrain` at each snapshot batch, so `links` is analyzed while it grows instead of planning every page against zero rows. The same 147,969 links come out (identical md5 of the ordered link set); Postgres is unchanged within noise (91.6 vs 92.8 s).
+- **Git effect claims** (`persistence/effect-journal.ts`, `worktree-refresh-schema.ts`). `claimCoalescedGitEffects` checks the worktree-wide conditions (owner, refresh fence, effect and request recovery blocks) once as an InitPlan and walks `persistence_effects_pending` in order to its limit: 351 → 25 ms per claim with 22k ready effects. PGLite runs each claim synchronously on the main thread, so the old claim also starved the serve boot behind it.
+- **Missing planner statistics on Postgres** (`search/projection-statistics.ts`, `postgres-engine.ts`, doctor `planner_stats_stale`, repair `planner-stats`). `missingSearchStatistics` is the one test for absent search statistics (the six `pages` and three `content_chunks` columns plus the projection statistics); the wave-6 write-pass skip, a once-per-process background guard on the first search outside a transaction (never awaited by the search), doctor and repair all use it. The flip comes from the `pages` statistics: without them the adjacency count runs pages × pages.
+- The write gate no longer flags an assistant's ordinary replies in saved chat transcripts ("As an AI language model, I don't…, but I can…") as instructions to an agent; planted instructions are still caught. (GBRA-58)
+- Importing or saving a page no longer slows down on a brain with many purged facts; gbrain looks up only the purges that match the page's own fact rows (12k tombstones: PGLite import 159 → 57 ms, Postgres 161 → 50 ms). Migration v231 adds two `fact_purges` indexes. (GBRA-58)
+- `test/e2e/persistence-idle-pool.test.ts` awaits the drain, dumps `pg_stat_activity` on failure and holds past one probe cycle. (GBRA-64)
+- Tests: `persistence-skip-cost.test.ts`, `persistence-host-identity-cache.serial.test.ts`, `pglite-checkpoint-guard.test.ts` (with a WAL worker fixture), `extract-links-db-planner-stats.test.ts`, `search-statistics-guard.test.ts` + its Postgres e2e, `purge-global-marker.test.ts`, and a reference-predicate equivalence case in `persistence-git-coalescing-5530.slow.test.ts` (every fence, recovery, mirror, owner and readiness state claims exactly the old predicate's rows, both engines).
+
## [0.60.140.0] - 2026-10-10
**CI only: unit shard 7 no longer loses its tail to a Bun runtime defect, and a red shard that does names the defect instead of blaming the tests. Nothing in gbrain itself changes.**
diff --git a/docs/architecture/key-files/core-persistence.md b/docs/architecture/key-files/core-persistence.md
index 381d08b024..358cc13ec0 100644
--- a/docs/architecture/key-files/core-persistence.md
+++ b/docs/architecture/key-files/core-persistence.md
@@ -45,7 +45,7 @@ Connector ingestion, item holds, checkpoint validation and the single-write fast
- `src/core/persistence/page-edit.ts` — `edit_page` (#5616): splits the canonical serialization into editable text and protected takes/facts segments whose remote view matches get_page's sanitized `content` byte for byte; `applyPageEdits` applies ordered exact-once replacements inside editable text only (typed `edit_no_match`/`edit_ambiguous_match`/`edit_protected_span`/`edit_invalid`), so canonical fences never move; `editDiff` caps the caller-view diff at 8 KB. Called at submission (`page-mutations.ts`, before admission) and again on the locked snapshot in `page-prepare.ts`, which gives edit_page put_page's revision-bound `editing` timeline semantics. Pinned by `test/edit-page.test.ts`.
- `src/core/persistence/suffixed-slug.ts` — `.md`/`.mdx`-suffixed slugs (#4807). `preparePageAdmission` refuses a new put_page/put_pages slug ending in `.md`/`.mdx` before any journal row (`invalid_params`, why, suggestion naming the bare slug, read-only `get_page` fix and verify); a live page with that exact (source_id, slug) still updates and the put_page response carries `slug_advisory` (put under the bare slug, then delete_page). `suffixedSlugDryRun` serves put_page dry runs; `suffixedFrontmatterSlugHold` holds a file import whose frontmatter `slug:` identity ends in `.md` as `frontmatter_slug_conflict`. `validateSlug` and path-derived import slugs are unchanged. Test: `test/ingestion/put-page-write-through.test.ts`.
-- `src/core/persistence/{effect-schema,effect-model,effect-journal,effect-recovery,effect-git,effects}.ts` — bounded postcommit outbox (migration 155). Canonical publication atomically queues Git and embedding work; withdrawals queue three versioned, bounded exact-page manifests with durable slug cursors. `effect-targets.ts` converts legacy source scans with complete bounded discovery keyed on the request's own forgotten fact (falling back to the whole source ledger only when that fact row is gone) while retaining each cursor; ambiguous or over-capacity legacy intent stays pending. Older workers must be quiesced before rollout. Independent mirror recovery reserves capacity before file effects, finishes forward without changing revision or receipt, and blocks only its worktree until reconciled. Git holds the native root lock, disables hooks, uses literal pathspecs and target-only commits, and pushes without pull/rebase. A claimed single-file Git effect brings up to 99 more ready single-file Git effects of its worktree (`claimCoalescedGitEffects`, same readiness, recovery and withdrawal-mirror ordering predicates, `SKIP LOCKED`); the runner validates each path under the worktree lock, makes one `commit --only` per group (`commitGitTargets`: one `ls-files`, `status`, `add` and `diff` for the group; untracked absent or ignored targets take the per-target refusal path) and pushes each root once at the end of the pass (`pushGitRoot`). A page file target's optional `commit` note (`GitCommitNote`, set only by trusted local preparers: a fence repair's `fenceRepairCommit`) is queued as `commit_subject`/`commit_line` in the Git effect's data and passed by the runner to `commitGitTargets`/`publishGitEffect`: a noted path committing alone takes its subject; a group keeps `gbrain: persist N canonical memory updates` and lists the noted paths' lines in the body, in path order; control characters are stripped, and targets without a note commit exactly as before (`test/fence-repair-receipts.test.ts`). A group shorter than 100 yields to publications still queued or running for its worktree (`retryEffect` with `publication_pending`, 250 ms apart) for at most 20 claims, so a serial producer publishes ahead and its Git work lands as one group; the v0.13.1 grandfather step admits a 50-page window (`admitCanonicalGrandfather`) before waiting for it. A path failure fails only its effect; a push failure leaves the group queued with `git_push_unavailable`, and the next pass finds nothing to commit and pushes once (#5530; tests: `persistence-git-coalescing-5530.slow.test.ts` + Postgres wrapper). A Git effect for a declared db_only page completes as skipped (`reason: db_only`), keeping its gitignored cache file out of Git. A Git or withdrawal target parks after five consecutive execution failures (`data.target_failures` for `data.failing_target`, reset when the target advances or a different target fails; shutdown cancellation, contention, dependency waits (including recovery-capacity waits) and transient database failures do not count): a scan records it in `data.parked` and moves on, a single-target effect or a failure outside any target parks the whole effect, and an effect with parked targets finishes as `failed`/`targets_parked`, never committed. A mirror or Git scan never parks on a sync-skip metafile page (`RESOLVER.md` carries the managed durability block by design) or on a file whose bytes hold an uncoordinated local edit (`file_database_drift`): the mirror materializes the withdrawal in the database without touching the file, both scans record the page in `data.skipped` (at most 100) and advance, so the request's Git and embedding effects are no longer gated behind a parked mirror (#5396). Migration 170 indexes parked effects for the `parked_effects` doctor check. `retryParkedEffects` (the `retry-effects` admin path) previews parked targets or authorizes one more attempt per target (`data.retry_slugs`, visited before the cursor); tests: `persistence-effect-parking.test.ts`. Old targets resolve under the same hash/confinement checks without changing frozen data; ambiguous absent spellings refuse after scoped staged/unstaged deletion checks. Embedding runs outside transactions/OS locks and installs with projection CAS. Receipt helpers return only public effect state/reason/push. Consumer shutdown aborts providers and awaits workers; receipt compaction is bounded. Tests: `persistence-effects.test.ts`, `persistence-git-publication.test.ts`, `persistence-publication-native.serial.test.ts`. Embedding completion checks active column/vector, embedded stamp, text hash, model and page signature; partial work sends only stale chunks and preserves valid siblings. A partial synopsis rebuild completes before title demotion. Provider timeouts use the gateway budget, five durable page claims/backoff, execution-token CAS after provider work and atomic vector/stamp/effect completion. Keyless work skips cleanly. `retry-effects` is an explicit one-shot failed-effect allowance; current vectors reconcile provider-free without changing canonical receipts. A git refusal on an index lock (git's own message names the lock, so linked worktrees resolve) is `git_index_locked` contention (retried, not counted toward parking) while the lock is younger than 10 minutes, and `git_index_stale` (counted, naming the lock) when older or future-dated; the lock is never removed, because no timestamp proves its holder is gone.
+- `src/core/persistence/{effect-schema,effect-model,effect-journal,effect-recovery,effect-git,effects}.ts` — bounded postcommit outbox (migration 155). Canonical publication atomically queues Git and embedding work; withdrawals queue three versioned, bounded exact-page manifests with durable slug cursors. `effect-targets.ts` converts legacy source scans with complete bounded discovery keyed on the request's own forgotten fact (falling back to the whole source ledger only when that fact row is gone) while retaining each cursor; ambiguous or over-capacity legacy intent stays pending. Older workers must be quiesced before rollout. Independent mirror recovery reserves capacity before file effects, finishes forward without changing revision or receipt, and blocks only its worktree until reconciled. Git holds the native root lock, disables hooks, uses literal pathspecs and target-only commits, and pushes without pull/rebase. A claimed single-file Git effect brings up to 99 more ready single-file Git effects of its worktree (`claimCoalescedGitEffects`, same readiness, recovery and withdrawal-mirror ordering predicates, `SKIP LOCKED`); the runner validates each path under the worktree lock, makes one `commit --only` per group (`commitGitTargets`: one `ls-files`, `status`, `add` and `diff` for the group; untracked absent or ignored targets take the per-target refusal path) and pushes each root once at the end of the pass (`pushGitRoot`). A page file target's optional `commit` note (`GitCommitNote`, set only by trusted local preparers: a fence repair's `fenceRepairCommit`) is queued as `commit_subject`/`commit_line` in the Git effect's data and passed by the runner to `commitGitTargets`/`publishGitEffect`: a noted path committing alone takes its subject; a group keeps `gbrain: persist N canonical memory updates` and lists the noted paths' lines in the body, in path order; control characters are stripped, and targets without a note commit exactly as before (`test/fence-repair-receipts.test.ts`). A group shorter than 100 yields to publications still queued or running for its worktree (`retryEffect` with `publication_pending`, 250 ms apart) for at most 20 claims, so a serial producer publishes ahead and its Git work lands as one group; the v0.13.1 grandfather step admits a 50-page window (`admitCanonicalGrandfather`) before waiting for it. `claimCoalescedGitEffects` checks the worktree-wide conditions (owner, refresh fence, recovery blocks) once as an InitPlan, so the claim walks `persistence_effects_pending` in order and stops at its limit (351 → 25 ms per claim with 22k ready effects). A path failure fails only its effect; a push failure leaves the group queued with `git_push_unavailable`, and the next pass finds nothing to commit and pushes once (#5530; tests: `persistence-git-coalescing-5530.slow.test.ts` + Postgres wrapper). A Git effect for a declared db_only page completes as skipped (`reason: db_only`), keeping its gitignored cache file out of Git. A Git or withdrawal target parks after five consecutive execution failures (`data.target_failures` for `data.failing_target`, reset when the target advances or a different target fails; shutdown cancellation, contention, dependency waits (including recovery-capacity waits) and transient database failures do not count): a scan records it in `data.parked` and moves on, a single-target effect or a failure outside any target parks the whole effect, and an effect with parked targets finishes as `failed`/`targets_parked`, never committed. A mirror or Git scan never parks on a sync-skip metafile page (`RESOLVER.md` carries the managed durability block by design) or on a file whose bytes hold an uncoordinated local edit (`file_database_drift`): the mirror materializes the withdrawal in the database without touching the file, both scans record the page in `data.skipped` (at most 100) and advance, so the request's Git and embedding effects are no longer gated behind a parked mirror (#5396). Migration 170 indexes parked effects for the `parked_effects` doctor check. `retryParkedEffects` (the `retry-effects` admin path) previews parked targets or authorizes one more attempt per target (`data.retry_slugs`, visited before the cursor); tests: `persistence-effect-parking.test.ts`. Old targets resolve under the same hash/confinement checks without changing frozen data; ambiguous absent spellings refuse after scoped staged/unstaged deletion checks. Embedding runs outside transactions/OS locks and installs with projection CAS. Receipt helpers return only public effect state/reason/push. Consumer shutdown aborts providers and awaits workers; receipt compaction is bounded. Tests: `persistence-effects.test.ts`, `persistence-git-publication.test.ts`, `persistence-publication-native.serial.test.ts`. Embedding completion checks active column/vector, embedded stamp, text hash, model and page signature; partial work sends only stale chunks and preserves valid siblings. A partial synopsis rebuild completes before title demotion. Provider timeouts use the gateway budget, five durable page claims/backoff, execution-token CAS after provider work and atomic vector/stamp/effect completion. Keyless work skips cleanly. `retry-effects` is an explicit one-shot failed-effect allowance; current vectors reconcile provider-free without changing canonical receipts. A git refusal on an index lock (git's own message names the lock, so linked worktrees resolve) is `git_index_locked` contention (retried, not counted toward parking) while the lock is younger than 10 minutes, and `git_index_stale` (counted, naming the lock) when older or future-dated; the lock is never removed, because no timestamp proves its holder is gone.
- `src/core/persistence/native-file-target.ts` — shared preparation/Git execution spelling resolution. Native directory-entry inode/device identity proves aliases; no global case folding or separator rewrite. Missing suffixes retain exact spelling, descendant symlinks and ambiguous aliases refuse, and physical root identity is rechecked. Exact POSIX case-distinct names and literal backslashes remain distinct. #5032: `isWindowsColonTarget(rel)` and `colonSlugWindowsRefusal(slug, sourceId)` name the one Windows-only refusal (`colon_slug_windows_write_through`: `:` names an NTFS alternate data stream); `submitPageMutation` raises it before admission when this host publishes the file, `prepareFileTarget` at publication, and managed (`fileRefusals`) and unmanaged (`failedFiles`) sync skip each such path by name (`test/colon-slug-windows-5032.test.ts`).
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index d35783a09d..a0f30dea3d 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -365,6 +365,8 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }
{ since: '0.60.138.0', text: 'On a brain without a multimodal embedding model (the default voyage-4 install), a query that reads like an image request ("a photo of ...", "show me photos") now runs as a text query, keyword arm and expansion included, instead of falling back after a failed image embed; `cross_modal: image` still routes to image search when asked.' },
{ since: '0.60.138.0', text: 'A search query holding a markdown rule of 32 or more dashes no longer fails the keyword and title arms (`tsquery stack too small`); the run collapses to its parity, and `query` results now report `retrieval.crag.top_rerank_score` whenever the reranker ran.' },
{ since: '0.60.139.0', text: 'Memory trust: everything an agent reads back from memory now carries a trust label ("your notes", "written by an agent", "external, untrusted" and the rest), and a write that reads like instructions to an agent is flagged. By default a flagged item is still saved, searchable and used in proactive context, shown with its flag; `gbrain trust review` lists flagged items. The stricter protections are opt-in: `gbrain config set write_gate.external_mode quarantine` holds instruction-like external content until you release it, and `gbrain config set trust.agent_activation suppress` keeps flagged agent-written items out of proactive context until you confirm them. Content saved before this release is flagged only after you claim your own sources (`gbrain trust claim-sources`, in a terminal) and run `gbrain trust scan` yourself; no agent starts either.' },
+ // Wave 7 perf (GBRA-75).
+ { since: '0.60.141.0', text: 'On Postgres, the first search of a process whose planner statistics on `pages` or `content_chunks` are absent (after pg_upgrade or a deleted pg_statistic, which autovacuum does not restore) now collects them in the background with the bounded refresh import already runs; without them a search on 5,000 pages took 50 to 60 s. Doctor `planner_stats_stale` names the absent columns and `gbrain repair planner-stats --apply` collects them. On PGLite, writes through the engine\'s SQL helpers now pass the same WAL checkpoint guard as other writes, so `gbrain extract` no longer wedges at 50,000 pages.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */