Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

docs: fact-check fixes (commit grouping, receipts, incomplete conversion, host-repo preview, source_ids scope, segmented edit and upload routing)

garrytan562fb567755b
diff --git a/docs/architecture/brains-and-sources.md b/docs/architecture/brains-and-sources.md
index a1a771753e..9f3384bd47 100644
--- a/docs/architecture/brains-and-sources.md
+++ b/docs/architecture/brains-and-sources.md
@@ -58,7 +58,7 @@ database follows Git depends on the source:
| Source | Where the record is | How the database follows |
|---|---|---|
-| Checkout, mixed (the default) | The files in Git | Sync imports what is committed. A write publishes the file and its database row together (managed) or the row first (classic), and the Git commit follows later (a background Git effect once Git durability is on). When the two disagree, sync holds the page for review. |
+| Checkout, mixed (the default) | The files in Git | Sync imports what is committed (or the working tree when asked). A write publishes the file and its database row together (managed) or the row first (classic), and the Git commit follows later (a background Git effect once Git durability is on). When the two disagree, sync keeps the database version or holds the page for review. |
| Checkout, strict (`canonical: git`, opt-in per source) | Git commits | Every write is committed to Git before its row. Sync indexes committed blobs only, and Git wins. Private pages, `storage.db_only` directories and ignored paths are declared database-only. |
| Read-only mirror (`gbrain sources mirror-readonly`) | The upstream repository | Sync imports; gbrain never writes into the checkout. |
| No checkout (connector sources, database-only sources) | The database | Nothing to derive from; back up the database. |
diff --git a/docs/guides/git-canonical.md b/docs/guides/git-canonical.md
index 0b7dcae2c5..27dc6db166 100644
--- a/docs/guides/git-canonical.md
+++ b/docs/guides/git-canonical.md
@@ -25,9 +25,10 @@ operator's view.
Writes to a strict source pay for a local commit. The door commits with Git
plumbing and updates the index only for the paths it wrote, so on a
-150,000-file checkout it adds about 230 ms per write (p50). A `put_pages` batch,
-a maintenance run (dream patterns, one `extract_entities` call, one atom
-generation) and other grouped writes share one commit.
+150,000-file checkout it adds about 230 ms per write (p50). Writes published
+as one group share a commit (a `put_pages` batch publishes up to 8 pages per
+group, and maintenance writers group their pages per run), so a large batch
+makes several commits. Independent writes each make their own.
## When to turn it on
@@ -86,16 +87,17 @@ gbrain sources canonical <source-id> --to git --apply --expect <hash> [--no-embe
A plan that changed since the preview refuses with `preview_changed`; preview
again. The apply adopts group by group (a crash leaves the source mixed, and the
next preview lists only what is left), runs a full strict pass, sets
-`canonical: git`, then runs one more strict pass. Writes that land during the
-conversion can leave work behind; the command then reports
-`git_conversion_incomplete` and the source stays strict. Wait until
+`canonical: git`, then runs one more strict pass. A pass that stops early, or
+writes that land during the conversion, end it with
+`git_conversion_incomplete`: the source stays mixed if the first pass stopped
+before the flag was set, and strict (Git wins) if it stopped after. Wait until
`gbrain sync status --source <id> --json` shows it idle, preview again and apply
the new hash.
**A new, empty source** can start strict instead:
-`gbrain sources host-repo <id> --dir <path> [--push-remote <url>]` creates a bare
-repository people clone, with a worktree gbrain owns, and makes the source
-strict. See [hosted repositories](multi-source-brains.md#hosted-repositories).
+`gbrain sources host-repo <id> --dir <path> [--push-remote <url>]` previews a bare
+repository people clone, with a worktree gbrain owns; running the printed
+command with `--expect <plan_hash>` creates them and makes the source strict. See [hosted repositories](multi-source-brains.md#hosted-repositories).
## How writes reach a strict source
@@ -133,13 +135,16 @@ file is refused with [`git_home_required`](write-refusals.md#git_home_required).
| Derive-phase pages that never had a file | Kept database-only. |
| Paths the checkout's Git ignores | Never committed and never given a Git effect. |
| Detached pages and origin twins | Kept database-only. |
-| Derived data: chunks, embeddings, links and rows parsed from pages, receipts | Rebuilt from Git, never content of record. |
+| Derived data: chunks, embeddings, links and rows parsed from pages | Rebuilt from Git, never content of record. |
+| Write receipts and other operational records | Kept in the database as metadata; Git commits don't carry them. |
A file under a Git LFS rule is refused with `git_lfs_not_enabled` unless
`storage.git_lfs` is on and the checkout configures the LFS filter; the door
then commits the LFS pointer.
-Back up the database for the declared classes: Git holds everything else.
+Git holds every page outside these classes, so a strict source's index can be
+rebuilt from it. Back up the database too: it holds the declared classes,
+receipts and other operational records.
## Turning it off
diff --git a/docs/guides/memory-boundaries.md b/docs/guides/memory-boundaries.md
index 274c5f2abf..2a558f52ba 100644
--- a/docs/guides/memory-boundaries.md
+++ b/docs/guides/memory-boundaries.md
@@ -144,16 +144,17 @@ Don't send a growing page back whole to add a line. `append_page` (CLI
page in time proportional to the text. It takes a `request_id`, so a retry
never appends twice, and `expected_tail_sha256` refuses `tail_changed` when
another writer appended first. `edit_page` on a page stored in segments
-rewrites only the segments its match touches; `within` restricts the match to
-a range a window read returned.
+rewrites only the segments a body-text match touches (an edit that reaches the
+header or the timeline marker prepares the whole body instead); `within`
+restricts the match to a range a window read returned.
A page bigger than one request (see the limits below) goes in an upload
session: `begin_page_upload`, then `upload_page_part` from part 0, then
`commit_page_upload`, which returns `put_page`'s receipt. `get_page_upload`
resumes after a lost reply and `abort_page_upload` discards the session.
-`gbrain put --file` and `gbrain capture --file` use a session on a remote
-brain, and `gbrain append` switches to one when the text is over the
-connection's request limit. A session belongs to the connection, source and
+On a remote brain, `gbrain put --file`, `gbrain capture --file` and
+`gbrain append` switch to a session when the request is over the connection's
+limit. A session belongs to the connection, source and
page that began it, its staged bytes count against the `persistence.limits`
upload quotas, and an idle session expires.
diff --git a/docs/mcp/TOOL_REFERENCE.md b/docs/mcp/TOOL_REFERENCE.md
index 3a329efd7f..4add0273bd 100644
--- a/docs/mcp/TOOL_REFERENCE.md
+++ b/docs/mcp/TOOL_REFERENCE.md
@@ -339,7 +339,7 @@ Hybrid search with vector + keyword, plus multi-query expansion when the search
| `since` | string | Filter to pages whose effective_date is >= this. ISO-8601 (YYYY-MM-DD or full timestamp) OR relative ('7d', '2w', '1y'). |
| `until` | string | Filter to effective_date <= this. Same format as `since`. YYYY-MM-DD lands at end-of-day. |
| `source_id` | string | Scope search to a single source. Defaults to OperationContext.sourceId (set from CLI --source / GBRAIN_SOURCE / .gbrain-source dotfile). Pass '__all__' to span every source for trusted local callers. For remote callers, '__all__' uses the same scope as omission: an OAuth grant when present, otherwise the transport-computed federated sources for grantless local stdio. |
-| `source_ids` | array | Narrow the request to these sources (CLI: `--source-ids source-a,source-b`). Each id is authorized like an explicit `source_id`, so the list can narrow a request but never widen it: a source outside a remote caller's grant refuses the whole request with `permission_denied`, and a removed or archived one with `unknown_source`. Omitted, `[]` or a blank string reads every source you can read; `__all__` is refused. With `source_id` too, the request reads their intersection, and an empty intersection returns no rows with an `empty_retrieval` notice. See [narrowing one request](../guides/multi-source-brains.md#narrow-one-request-with-source_ids). |
+| `source_ids` | array | Narrow the request to these sources (CLI: `--source-ids source-a,source-b`). Each id is authorized like an explicit `source_id`, so the list can narrow a request but never widen it: a source outside a remote caller's grant refuses the whole request with `permission_denied`, and a removed or archived one with `unknown_source`. Omitted, `[]` or a blank string leaves the request's normal scope (`source_id`, or your default scope) unchanged; `__all__` is refused. With `source_id` too, the request reads their intersection, and an empty intersection returns no rows with an `empty_retrieval` notice. See [narrowing one request](../guides/multi-source-brains.md#narrow-one-request-with-source_ids). |
| `cross_modal` | string (`text`, `image`, `both`, `auto`) | Cross-modal search routing.<br> 'text' (default for non-image-intent queries) — text-only path.<br> 'image' — route the query through Voyage multimodal-3 + the embedding_image column. Best for 'show me photos of...' phrasings.<br> 'both' — run text AND image searches in parallel; merge via weighted RRF.<br> 'auto' — same effect as omitting the field; intent classifier decides based on query phrasing. |
| `embedding_column` | string | Route vector search through a non-default embedding column. Defaults to 'embedding' (the brain's primary column) unless `search_embedding_column` config sets a different default. Per-call override for A/B benchmarking across providers (e.g. 'embedding_voyage', 'embedding_openai'). Column MUST be declared in the `embedding_columns` config registry — unknown names throw with a paste-ready hint listing valid columns. |
| `adaptive_return` | boolean | Return a TIGHT, intent-sized result set instead of the full top-K. YOU (the agent) set this per query to serve the user well:<br> TRUE when the user's question has a small, specific answer — a lookup ('what is X', 'who is Y', 'what's my <thing>', 'what did Z decide'), a single-fact recall, or when you'll route the result into a precise downstream step (a classifier, a decision, an exact citation). The user gets the answer, not a wall of loosely-related pages, and you spend fewer tokens reading noise.<br> Omit / FALSE for breadth — 'everything about X', 'list all', 'what do I know about Y', exploration, brainstorming, or any time you'd rather see more candidates and judge for yourself. Recall matters more there, so take the full top-K.<br>Safe by construction: it NEVER returns empty when there are matches (you always get at least the top hit), and it only applies to the first page (omit when paginating). Caps come from config (search.adaptive_return_entity_max / _other_max; default 2 / 6) — pass `limit` 1 alongside this for a hard single-answer cap. |
@@ -407,7 +407,7 @@ Fuzzy-resolve a partial slug to matching page slugs
## `search`
-Cheap hybrid search (vector + keyword + RRF) with no LLM expansion. Best for exact known tokens, names, and structured-field lookups. A populated result set is NOT proof of coverage — for concept / synonym / landscape questions use `query` (it can add multi-query expansion with `expand: true`); for exhaustive enumeration use list_pages pagination. Pass `return_unit` ('window' / 'section' / 'page') for whole evidence instead of chunks; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For personal/emotional questions, prefer get_recent_salience or find_anomalies — they surface activity bursts without needing a search term. To find every page that contains a literal phrase or identifier, where you would otherwise grep, use `search_exact` (CLI `gbrain search --exact "<phrase>"`): it is unranked and exhaustive and says whether it read the whole scope ([exact search](../guides/exact-search.md)). For code-symbol questions (callers, callees, definitions, blast radius), use code_callers / code_callees / code_def / code_refs instead — those return structural graph data, not text chunks. For agent memory reads (saved facts + budget-packed retrieval), prefer the `recall` verb.
+Cheap hybrid search (vector + keyword + RRF) with no LLM expansion. Best for exact known tokens, names, and structured-field lookups. A populated result set is NOT proof of coverage — for concept / synonym / landscape questions use `query` (it can add multi-query expansion with `expand: true`); for exhaustive enumeration use list_pages pagination. Pass `return_unit` ('window' / 'section' / 'page') for whole evidence instead of chunks; conversation pages already come back whole by default (return_unit 'auto'; 'chunk' opts out). For personal/emotional questions, prefer get_recent_salience or find_anomalies — they surface activity bursts without needing a search term. To find every page that contains a literal phrase or identifier, where you would otherwise grep, use `search_exact` on the full surface (CLI `gbrain search --exact "<phrase>"`): it is unranked and exhaustive and says whether it read the whole scope ([exact search](../guides/exact-search.md)). For code-symbol questions (callers, callees, definitions, blast radius), use code_callers / code_callees / code_def / code_refs instead — those return structural graph data, not text chunks. For agent memory reads (saved facts + budget-packed retrieval), prefer the `recall` verb.
Every call also reports how many pages match the query's keywords (`keyword_total`, `keyword_truncated`; "10000+" past 10,000) in one line after the rows. That count covers keyword (full-text) matches only, not the ranked rows. To list every one of those pages, pass `match: "keyword"`: rows come one per page in keyword-score order with `total`, `truncated` and `next`, a ready-to-send argument object; keep calling with `next` until it is absent. A page whose text did not fit `token_budget` still gets a row, with `evidence_omitted: true`. If the count times out, the line says it is unavailable (degraded stage `keyword_count_unavailable`), never zero.
@@ -422,7 +422,7 @@ On a large Postgres brain a broad keyword statement can hit the keyword time lim
| `cursor` | string | The keyset cursor inside a `match: "keyword"` response's `next`. Send `next` unchanged; a cursor without `match: "keyword"` is refused (`search_cursor_requires_keyword`). |
| `mode` | string | Search mode (conservative\|balanced\|tokenmax). Local callers only: an agent-facing caller that sets it is refused (`search_mode_local_only`) with a fix naming `match: "keyword"`. |
| `source_id` | string | Scope search to a single source. Defaults to OperationContext.sourceId (set from CLI --source / GBRAIN_SOURCE / .gbrain-source dotfile); when unset, an unqualified read spans every federated source. Pass '__all__' to span every source for trusted local callers; for remote callers '__all__' spans only your granted sources. |
-| `source_ids` | array | Narrow the request to these sources (CLI: `--source-ids source-a,source-b`). Each id is authorized like an explicit `source_id`, so the list can narrow a request but never widen it: a source outside a remote caller's grant refuses the whole request with `permission_denied`, and a removed or archived one with `unknown_source`. Omitted, `[]` or a blank string reads every source you can read; `__all__` is refused. With `source_id` too, the request reads their intersection, and an empty intersection returns no rows with an `empty_retrieval` notice. See [narrowing one request](../guides/multi-source-brains.md#narrow-one-request-with-source_ids). |
+| `source_ids` | array | Narrow the request to these sources (CLI: `--source-ids source-a,source-b`). Each id is authorized like an explicit `source_id`, so the list can narrow a request but never widen it: a source outside a remote caller's grant refuses the whole request with `permission_denied`, and a removed or archived one with `unknown_source`. Omitted, `[]` or a blank string leaves the request's normal scope (`source_id`, or your default scope) unchanged; `__all__` is refused. With `source_id` too, the request reads their intersection, and an empty intersection returns no rows with an `empty_retrieval` notice. See [narrowing one request](../guides/multi-source-brains.md#narrow-one-request-with-source_ids). |
| `types` | array | Filter results to pages whose `type` is in this list (e.g. ['person','company']). CLI: --types person,company. Applied at SQL level on every retrieval leg — the same filter `whoknows` uses. Stacks with all other filters. |
| `snippet_chars` | number | Cap each result's chunk_text at N characters (a "… [truncated]" marker names the get_page recovery move). 0 forces full text. Unset: subagent tool loops default to the agent.search_snippet_chars config (300; 0=full); every other caller gets full text. A row widened by `search.long_page_unit` (`delivered: {unit, reason: "long_page"}`) is exempt and comes back whole; every other row is still cut. |
| `return_unit` | string (`chunk`, `window`, `section`, `page`, `auto`) | Evidence unit returned in each result's chunk_text (default: config search.return_unit, which defaults to 'auto').<br> 'chunk' — the ranked chunk only (~300-450 tokens per result).<br> 'window' — the hit chunk plus return_window neighbor chunks each side (local context, ~3x chunk).<br> 'section' — the enclosing markdown section, or the conversation rounds around the hit.<br> 'page' — the whole page/session, capped. Use for multi-session or temporal questions where the answer needs the whole conversation.<br> 'auto' — the whole page for conversation pages (conversation/transcript/chat/meeting/slack/imessage types, chat/ or conversations/ slugs), the ranked chunk unchanged for everything else. When no hit is a conversation the response is exactly the chunk response.<br>Non-chunk units return one result per page, packed into token_budget (default 6000, auto 24000; remote max 32000), with a `delivered` object (unit, chunk_ids, match_spans, tokens, truncated; reason under auto) per result and `delivery` in the response meta. |