Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Merge origin/master (v0.60.231.0) into capy/list-write-conflicts-scope
garrytana8a16392e30e
diff --cc CHANGELOG.mdindex 2a1b86beab,6eb1308c66..8b8f7cd1c2--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -10,33 -10,21 +10,48 @@@ credits are retained; no result has beeidentifiers and attribution are available in the pre-removal Git revision`6040075c6cb95be5881cc2e1b76ef7d71f4e5d29` (retained on 2026-09-23).+## [0.60.232.0] - 2026-10-14++**MCP `list_write_conflicts` refuses a source outside the caller's grant and bounds its window to that source's own requests (#6643 follow-up).** A remote caller that named a source outside its grant used to get an empty report back. The response's `window` sequences were also brain-wide, so polling one granted source showed write activity in sources the caller cannot see. Both were found by GBRA-60's D5 agent smoke.++### Itemized changes++- **Out-of-grant `source_id`** (`src/core/ops/persistence.ts`): the op checks an explicit `source_id` with `resolveRequestedScope`, like the other source-scoped reads. A remote caller outside its grant gets `permission_denied`, whether or not the source exists.+- **Source-scoped window** (`src/core/persistence/drift-conflicts.ts`):+ - The window ends at the source's own newest request in its current incarnation, read through the `(source_incarnation, sequence)` index, and the scan reads only that incarnation.+ - A cursor naming a later sequence is clamped.+ - A source the caller may not read returns before anything is computed.+- **Tests:** `test/maintenance-file-drift-6643.test.ts` covers the refusal for a real and an unregistered source, a window that does not move when another source is written, and the clamped forged cursor. Each half fails on the previous code.++## [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.231.0] - 2026-10-14++ **Reading a large page no longer pulls the whole page into a response: `get_page` returns an outline and a window, and every remote window is cut from the privacy-sanitized view of the page (large pages Wave A, part 1).** Before, `get_page` of a 100 MB page built a 204 MB JSON-RPC frame. That is over the MCP SDK's 10 MiB stdio limit and far over the 25k tokens a harness accepts. Evidence delivery also read the whole body for every conversation hit: 2 s and +622 MB per hit at 100 MB. Now an MCP client that is not the thin client gets the full body up to the inline threshold, and above it an outline plus the first window with the exact call to read on. Windows, outlines and short leads all slice one projection with withdrawals applied, takes/facts fences stripped and credentials projected. A partial response never fills `compiled_truth`, `timeline` or `content`, so a read followed by a write cannot shrink a page by accident. Another guard backs this up: a remote `put_page` that would cut a large page to under half refuses unless `allow_shrink: true`. Pages up to today's ingest limits read as before through the local CLI and the thin client. The ceiling increase and searchability of large pages come in the next Wave A PR.++ ### Itemized changes++ - **Body modes** (`src/core/ops/get-page-body.ts`, `src/core/page-window/`): `get_page` takes `body: auto|full|none|outline|window` and the selectors `lines`, `bytes` (UTF-8, snapped to code-point and line starts), `around_chunk_id` and a revision-bound `cursor`. A stale cursor returns `revision_changed`, whose fix reads on from the same offset. The default window is 40,000 bytes, measured as the final encoded frame.+ - **Exact chunk spans** (migration v244, `src/core/chunkers/recursive.ts`): `content_chunks.projected_byte_start/end` record each chunk's position in projected UTF-8 coordinates at chunk time. A differential oracle test proves chunk text and indexes are byte-identical to the previous chunker over 160 seeded documents and 6 option sets.+ - **Paging** (`src/core/ops/chunks.ts`, `src/core/ops/admin.ts`, `src/core/ops/read-paging.ts`): `get_chunks` pages 50 rows at a time and returns `total_chunks`. `get_versions` returns the newest 20, metadata only, by default.+ - **fetch and evidence** (`src/core/ops/pages.ts`, `src/core/search/evidence-delivery.ts`): on pages over 256 KB, `fetch` returns the window around the searched chunk with a `next_id` continuation, and the evidence `page` unit becomes a window. Above 1 MiB, hits are placed by stored spans only.+ - **Egress backstop** (`src/core/egress-budget.ts`, `src/mcp/dispatch.ts`): a read result over `mcp.max_result_bytes_stdio` (4 MiB) or `_http` (1 MiB), measured on the final frame, returns `result_too_large` with a fix.+ - **Bounded leads** (`src/core/page-window/bounded-lead.ts`): search snippets, synopses, entity cards and think rows read a 64 KiB prefix through the withdrawal overlay instead of the whole body.+ - **Thin CLI and capability** (`src/cli/page-render.ts`): `gbrain get` pages the round-trip markdown to the end, verifies size and sha256, and never prints a partial body as whole. `get_brain_identity` advertises `large_pages_v1`.+ - **Docs**: new `docs/guides/windowed-reads.md`, plus error-registry entries for `page_too_large_for_inline`, `result_too_large`, `revision_changed` and `page_shrink_refused`.+## [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.