Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge remote-tracking branch 'origin/master' into capy/gbra93-a
garrytan5a08ef436056
diff --cc CHANGELOG.mdindex a40059429c,5db984b093..c59baf0799--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,19 -10,25 +10,38 @@@ credits are retained; no result has beeidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [Unreleased]++**Writes stop failing at the cumulative quota wall (#6696).** A brain running autopilot hit `queue_capacity` on every write once its receipt bytes reached the 1.5 GiB principal cap, because every receipt held a 16 KiB reservation it never gave back and nothing warned before the wall. Receipts are now charged for what they keep, the defaults cover a year at 5,000 writes a day, background work pauses before the wall so your own writes keep working, and doctor, notices and `/metrics` say how many days are left.++### Itemized changes++- **Receipt true-up**: an admission reserves its request body plus 12 KiB (at least 16 KiB), so a 100 KB page reserves its 100 KB; once the last effect settles, `trueUpRequests` gives back what the receipt does not keep (in its own transaction after every settle path: the effect runner, embedding settle, the `embed --stale` bulk settle, effect retry and restore). Receipts compacted earlier give their excess back in one bounded pass.+- **Defaults and forecast**: principal caps 2,000,000 request ids and 16 GiB receipt bytes (brain 8,000,000 and 64 GiB), from the growth model in `docs/guides/concurrent-writes.md#growth-model`. `persistence_capacity` forecasts days to exhaustion from the full 7-day aggregate on the principal index; warn at 80% or 30 days, fail at 95% or 7 days (`persistence.capacity.warn_days`, `fail_days`).+- **Clear refusals**: a cumulative cap refuses `write_quota_exhausted` (reason `lifetime_ids` or `terminal_bytes`) with the host's `gbrain config set` raise; `queue_capacity` is only the outstanding-request cap. Background producers pause at `persistence.capacity.background_pause_pct` (80) with `write_capacity_backpressure`.+- **Warnings**: `[gbrain notice write_capacity_low]` on write and sync receipts (hourly per scope, muteable), sync status and cycle output; `write_capacity_backpressure` notice when the pause starts; admin `/metrics` gauges `gbrain_write_capacity_{used,limit,days_to_exhaustion}` with a documented alert rule.+- **Sync**: a capacity preflight refuses `write_quota_insufficient` before the first admission; a later cap refusal ends the drain `resumable` / `capacity_paused`.+- **Compaction**: `gbrain repair receipt-compaction` (explicit-only, preview-bound) compacts on demand, floored at the configured retention unless `--force`; compaction skips open sync runs and the newest sync receipt per worktree; the consumer records each pass (`persistence.maintenance.last_compaction`); doctor adds `persistence_compaction` and `persistence_counter_drift`.+- **Known-failing writes**: maintenance refuses a page whose canonical file is gone before admission (`canonical_file_missing`) and holds back a write refused three times in a day (`persistence.maintenance.refusal_breaker_threshold`); doctor `maintenance_write_drift` lists them.+ ## [0.60.230.0] - 2026-10-14++ **The entity-card latency test no longer fails on a busy CI machine while the card itself is fast (test and CI only, no product change).** The test checks that a card's p99 stays under 100 ms. On Ubicloud it failed at 107-125 ms whenever other memory-heavy tests shared its VM, or the hypervisor took CPU time from the guest, while the same calls took 36-41 ms run alone. It now measures the call's own thread CPU time, runs alone on its VM and re-times a call that hypervisor steal crossed. The 100 ms budget and every assertion are unchanged, and a 90 ms slowdown injected into the reference read still fails it.++ ### Itemized changes++ - **CPU-time gate** (`test/entity-card-perf.slow.test.ts`): the p99 budget applies to the call's thread CPU time. PGLite runs every query in-process with no I/O, so that time is the card's latency on an idle machine, and it leaves out time spent waiting for a CPU. Wall-clock p99 is still logged, along with the five slowest samples (wall, thread CPU, heap change).+ - **Runs alone** (`scripts/run-slow-tests.sh`, `scripts/ci-ubicloud.ts`): `run-slow-tests.sh --dry-run-list-exclusive` lists latency contracts, and `ci:ubicloud` runs them as control items with nothing else on that VM, as GitHub CI's dedicated perf runner already does. A full GC before each measured loop keeps corpus-seeding garbage out of the window.+ - **Steal guard** (`test/helpers/hypervisor-steal.ts`): on guest kernels that bill steal to the running thread (Ubuntu 6.8 generic on GitHub and Ubicloud runners), the test reads the VM-wide steal counter around each call and times it again, at most 5 times, until steal did not move. Unit-tested with a stubbed `/proc/stat` (`test/hypervisor-steal.test.ts`).++ ## [0.60.229.0] - 2026-10-14++ **When a gbrain process that was running a group of writes is killed, its queued group members are now reclaimed with the rest of its claims, within about 5 s, instead of after their 30 s claim lease (#6650 follow-up).** On Linux, a consumer on the same machine already took back the claims of a write owner it could prove dead. But the members of a group the owner had claimed and not yet started carried no record of their owner, so they waited out their lease and held up the rest of the catch-up behind them. Now each member records its owner when it is claimed. Members that the owner had started, and any member with a recovery record or a publication in progress, are handled exactly as before. In the convergence harness (seed 6650, 50 ms latency) the worst stall after the round-1 serve kill went from 30 s to 21 s.++ ### Itemized changes++ - **Follower claims record their owner** (`src/core/persistence/journal.ts` `claimGroupFollowers`): a group follower's claim stamp holds its own token and the claiming process's identity (pid, nonce, pid namespace, boot id, start time), with no phase until its wave dispatches it. The dead-owner reclaim (`consumer.ts`) matches it by owner like any other claim. Because it has no `preparing` phase, the reclaim charges it no preparation attempt, as before.+ - **Readers of a follower stamp** (`claim-phase.ts` `claimStateOf`, `sync-drain.ts` `drainClaimOf`): a stamp with an owner and no phase reads as unrecorded for its phase and stall window, as an unstamped follower did, and now names its owner. Doctor ages it from when it was claimed, and `gbrain sources writer status` does not count its wait against the preparation budget it has not started.+ - **Owner probe** (`consumer-heartbeat.ts` `probeLiveFullConsumer`): the probe reads every live row of the host before it skips rows it can prove dead, so a live serve listed after eight dead rows is still found. Before, it read the first eight rows and could answer "no owner".## [0.60.228.0] - 2026-10-14diff --cc src/core/behavior-change-notice.tsindex 0f332d3eb2,f04360dc17..e5210b0c53--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@@ -563,11 -563,8 +563,13 @@@ export const BEHAVIOR_CHANGES: Readonly{ since: '0.60.223.0', text: 'On Linux, when the process holding write claims on this host is killed, another consumer on the same machine now reclaims those claims within about 5 s instead of waiting out their lease (up to `persistence.publication_ceiling_ms` plus about 65 s, so about 365 s by default). Only claims with no recovery record and no publication started are taken, the same guard an expired claim has. An owner that is alive, however slow, or on another host or container keeps its full lease.' },// GBRA-96 (default reranker). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.{ since: '0.60.228.0', text: 'The default search reranker is now Voyage `rerank-3-lite` instead of `rerank-2.5`, for brains that never set `search.reranker.model` (a brain that set one keeps it). In gbrain-evals #148 (v0.10.93) it cut rerank cost 60% at the same 50 candidates × 1,400 tokens, with retrieval quality within noise. To go back: `gbrain config set search.reranker.model voyage:rerank-2.5`.' },+ // #6650 follow-up (group follower stamps). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.+ { since: '0.60.229.0', text: 'On Linux, when a gbrain process holding a group of writes is killed, the group members it had claimed but not started are now reclaimed with its other claims within about 5 s, instead of after their 30 s claim lease. Members it had started, and any member with a recovery record or a publication in progress, are handled as before. A host with a dead owner row ahead of more than eight others now still finds the live `gbrain serve` to hand a sync to.' },+ // #6696 (GBRA-93 PR A, write-quota outage). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.- { since: '0.60.228.0', text: 'A write refused at a cumulative write cap (permanent request ids or receipt bytes) now fails with `write_quota_exhausted` instead of `queue_capacity`, with `reason` (`lifetime_ids` or `terminal_bytes`) and the brain host\'s reversible `gbrain config set` raise; `queue_capacity` now means only the outstanding-request cap, which frees as queued writes settle. Before the wall, background producers (maintenance, conversation facts, autopilot phases and catch-up syncs) pause at `persistence.capacity.background_pause_pct` (default 80) with `write_capacity_backpressure`, so your own writes keep the rest; the conversation-facts preflight reports a cumulative cap the same host-only way instead of as a wait.' },- { since: '0.60.228.0', text: 'Receipt bytes are now charged for what a receipt really keeps. An admission reserves its request body plus 12 KiB (still at least 16 KiB), so a 100 KB page write reserves about 110 KB instead of 16 KiB, and once its last effect settles the receipt gives back everything it does not keep (most small writes keep 3 to 6 KB). Receipts compacted before this release give their excess back in one bounded pass. Doctor adds `persistence_counter_drift` and `persistence_compaction` (warns when a resident consumer has not compacted in `persistence.maintenance.compaction_stale_hours`, default 24), and `gbrain repair receipt-compaction` (explicit-only, preview-bound) compacts receipts past the retention window on demand.' },- { since: '0.60.228.0', text: 'A managed sync now checks before its first write that its remaining files fit the write capacity left and refuses `write_quota_insufficient` with the config raise when they do not (nothing is admitted). A sync that passes the check and is then stopped by a cap another writer filled ends `resumable` with stop reason `capacity_paused`; the same command resumes it. Write and sync receipts carry `[gbrain notice write_capacity_low]` (at most once an hour per scope; mute with `gbrain notices mute write_capacity_low`) when a cap is at 80% or runs out within `persistence.capacity.warn_days`.' },- { since: '0.60.228.0', text: 'Maintenance no longer submits writes it knows will fail: a page whose canonical file is gone is refused before a request exists (`source_changed`, detail `canonical_file_missing`), and the same write refused three times in a day (`persistence.maintenance.refusal_breaker_threshold`; 0 turns it off) is held back until the page, the planner or the write changes. Doctor `maintenance_write_drift` lists what is held back and how to release it.' },++ { since: '0.60.230.0', text: 'A write refused at a cumulative write cap (permanent request ids or receipt bytes) now fails with `write_quota_exhausted` instead of `queue_capacity`, with `reason` (`lifetime_ids` or `terminal_bytes`) and the brain host\'s reversible `gbrain config set` raise; `queue_capacity` now means only the outstanding-request cap, which frees as queued writes settle. Before the wall, background producers (maintenance, conversation facts, autopilot phases and catch-up syncs) pause at `persistence.capacity.background_pause_pct` (default 80) with `write_capacity_backpressure`, so your own writes keep the rest; the conversation-facts preflight reports a cumulative cap the same host-only way instead of as a wait.' },++ { since: '0.60.230.0', text: 'Receipt bytes are now charged for what a receipt really keeps. An admission reserves its request body plus 12 KiB (still at least 16 KiB), so a 100 KB page write reserves about 110 KB instead of 16 KiB, and once its last effect settles the receipt gives back everything it does not keep (most small writes keep 3 to 6 KB). Receipts compacted before this release give their excess back in one bounded pass. Doctor adds `persistence_counter_drift` and `persistence_compaction` (warns when a resident consumer has not compacted in `persistence.maintenance.compaction_stale_hours`, default 24), and `gbrain repair receipt-compaction` (explicit-only, preview-bound) compacts receipts past the retention window on demand.' },++ { since: '0.60.230.0', text: 'A managed sync now checks before its first write that its remaining files fit the write capacity left and refuses `write_quota_insufficient` with the config raise when they do not (nothing is admitted). A sync that passes the check and is then stopped by a cap another writer filled ends `resumable` with stop reason `capacity_paused`; the same command resumes it. Write and sync receipts carry `[gbrain notice write_capacity_low]` (at most once an hour per scope; mute with `gbrain notices mute write_capacity_low`) when a cap is at 80% or runs out within `persistence.capacity.warn_days`.' },++ { since: '0.60.230.0', text: 'Maintenance no longer submits writes it knows will fail: a page whose canonical file is gone is refused before a request exists (`source_changed`, detail `canonical_file_missing`), and the same write refused three times in a day (`persistence.maintenance.refusal_breaker_threshold`; 0 turns it off) is held back until the page, the planner or the write changes. Doctor `maintenance_write_drift` lists what is held back and how to release it.' },];/** The newest disclosed change's release: the notice id moves only when a release adds rows. */