Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

docs: tighten the inherited read-only entries to fit the llms-full budget

garrytand4ed7c17ce0a
diff --git a/docs/guides/troubleshooting.md b/docs/guides/troubleshooting.md
index d533464ee7..b50073acec 100644
--- a/docs/guides/troubleshooting.md
+++ b/docs/guides/troubleshooting.md
@@ -159,7 +159,7 @@ Turning the `preparation_deadlines` switch off (`gbrain config set persistence.p
<a id="session-timeouts-not-applied"></a>**Doctor warns `persistence_session_timeouts` with `session_timeouts_not_applied`?** gbrain sets `statement_timeout` (`GBRAIN_STATEMENT_TIMEOUT`, default 5min) and `idle_in_transaction_session_timeout` as connection startup parameters, and a transaction-mode pooler (PgBouncer with `ignore_startup_parameters`, Supavisor) drops them: `SHOW statement_timeout` through the configured URL reads `0`, so a statement outside a transaction has no server-side bound and a relation lock held in another session (a migration's `ALTER TABLE pages` queued behind a long transaction, for example) holds it for as long as the lock lasts. Managed write *preparation* reads are not affected since v0.60.108: they run under a transaction-local `statement_timeout` of the write's remaining preparation budget, so a lock-blocked read ends at the budget and the member is released `preparation_deadline` with no statement left on the server (#6278). For every other autocommit statement, set the default on the role instead of the connection: `ALTER ROLE <gbrain role> SET statement_timeout = '5min'` (read-only to check: `gbrain doctor --only persistence_session_timeouts --json`). Setting `GBRAIN_STATEMENT_TIMEOUT` has no effect through such a pooler.
-<a id="inherited-read-only-connections"></a>**Writes fail with `connection_inherited_read_only` (SQLSTATE 25006, `cannot execute INSERT in a read-only transaction` or `... SELECT FOR SHARE ...`)?** The server connection defaults to read-only transactions. On a transaction-mode pooler (PgBouncer `pool_mode = transaction`, Supavisor) the usual cause is another client that ran a session-level `SET default_transaction_read_only = on`: the pooler shares server connections, so that setting stays on the connection and later clients inherit it until the connection closes. A role or database default (`ALTER ROLE ... SET default_transaction_read_only = on`) or a read-only server (a hot standby) has the same effect. gbrain opens its own transactions `BEGIN READ WRITE` and runs an autocommit statement the server refused this way once more inside one, so an inherited session default no longer stops its writes; the code remains for a read-only server and for any write path outside those seams. On the database or pooler host: reset the pooler's server connections (PgBouncer `RECONNECT <db>` on the admin console, or `server_reset_query = DISCARD ALL` with `server_reset_query_always = 1` so no session state survives a transaction), find the client that issues session-level `SET` through the pooler, and check the role and database defaults (`SELECT setrole::regrole, setdatabase, setconfig FROM pg_db_role_setting`). Run read-only audits as `BEGIN READ ONLY; ...; COMMIT;` or under a read-only role, never as a session-level `SET` through a transaction pooler.
+<a id="inherited-read-only-connections"></a>**Writes fail with `connection_inherited_read_only` (SQLSTATE 25006, `cannot execute INSERT in a read-only transaction`)?** The server connection defaults to read-only transactions: usually another client's session-level `SET default_transaction_read_only = on` left on a connection a transaction-mode pooler (PgBouncer `pool_mode = transaction`, Supavisor) shares, otherwise a role or database default or a read-only server such as a hot standby. gbrain opens its transactions `BEGIN READ WRITE` and retries a refused autocommit statement inside one, so the code means a read-only server or a write path outside those seams. On the database or pooler host: reset the pooler's server connections (PgBouncer `RECONNECT <db>`, or `server_reset_query = DISCARD ALL` with `server_reset_query_always = 1`), stop the client that issues session-level `SET` through the pooler (read-only audits belong in `BEGIN READ ONLY; ...; COMMIT;`), and check `pg_db_role_setting` for role and database defaults.
<a id="managed-sync-blocked"></a>**A managed sync run is blocked (doctor `managed_sync_blocked`, a freshness `sync` job ended `dead`, or get_brain_health reports `sync_blocked`)?** The source's unfinished run stopped on a page request that did not commit and recorded the stop, so it resumes nothing by itself while the other sources keep syncing (#6858: one source stopped for 21 hours while every freshness job reported `completed`). Such a job now ends `dead`: its error names the stop and the run's `next` command, and `gbrain jobs get <id> --json` carries `outcome`, `drain` and `next` in its progress. Doctor warns as soon as a run is blocked and fails once it has been blocked for more than an hour; get_brain_health turns to `attention` past the same hour, with a count band and no source names. A sync pass that stopped before it finished (in discovery, path `<discovery>`, or on one file) counts as blocked too, until a later sync of the source succeeds. Run `gbrain sync status --source <id> --json` (read-only): it names the page, its fault class and its exit. Clear the cause it names and run the step it prints; the next freshness job resumes the run once the cause is gone. A page publication that `gbrain repair stuck-recovery --keep disk` abandoned is not a blocker: the next plain sync retries that page after the rest of its run, imports it when the kept file is committed, and holds it `worktree_dirty` otherwise.
diff --git a/docs/guides/write-refusals.md b/docs/guides/write-refusals.md
index 8994fcbf1e..d0d00303e0 100644
--- a/docs/guides/write-refusals.md
+++ b/docs/guides/write-refusals.md
@@ -108,7 +108,7 @@ of making a duplicate.
| <a id="path_not_utf8"></a>`path_not_utf8` (sync hold) | `path_not_utf8` | A managed sync held one committed file because its name is not valid UTF-8 (a Latin-1 name from an older system, an archive or a network share). Git hands the name back with U+FFFD for the bytes that are not UTF-8, and no Git read or file matches that decoded name, so nothing is imported from it. Until GBRA-133 the managed sync either stopped at that file on every run or skipped it with no hold; now only the file waits and the hold names it. With `sync.holds=fail` the run stops with `path_not_utf8` instead of holding. | Rename the file to a UTF-8 name (`git -c core.quotePath=true ls-files` shows its exact bytes; `convmv -f latin1 -t utf8` converts a Latin-1 name), commit, then `gbrain sync --source <source> --no-pull`. The rename clears the hold. |
| <a id="write_interrupted"></a>`write_interrupted` | `write_interrupted` | A transient interruption kept ending this managed write: the database ended its own statements (SQLSTATE `57014`, a statement timeout or cancel) at preparation or inside its publication transaction, or its publication ran past `persistence.publication_ceiling_ms` and its grace and the owner cancelled it. Each interruption throws the preparation away, but it is load or latency, not the write's content, so it has its own budget: the request is claimed again after a backoff (1 s, 2 s, 4 s, 8 s, then 15 s, scheduled on the request as `next_attempt_at`; no claim, root lock or connection is held while it waits, and `gbrain sources writer status` names the waiting head `transient_backoff`) up to `persistence.max_transient_retries` times (default 5, 0 to 20), and the next interruption finishes it `failed` instead of preparing it again without limit. Interruptions never spend `persistence.max_preparation_attempts`, which preparations cut off at their deadline keep ([`preparation_stalled`](#preparation_stalled)). Nothing was published: a worktree-backed write's canonical file is restored before the failure is recorded. Contention with other transactions (`55P03` lock timeout, `40001` serialization failure, `40P01` deadlock) is released as `database_contention` uncounted, and a dropped connection or a database that is restarting or out of connections is never counted. The receipt's message and owner-only `error_detail` name the interruptions (`attempts`), the retry limit (`limit`, `limit_key`), the `cause` (`statement_cancel` or `publication_ceiling`) and the SQLSTATE (`sqlstate`, public). A managed sync member is held like [`preparation_stalled`](#write_interrupted-hold): the run moves past it and the rest of the source lands, `gbrain sync status` lists the hold (class `page`, safe action `retry`, [runbook row](sync-unblock-runbook.md)), and `gbrain sources retry-held` re-admits it. A group's shared read the database cancels is charged once, to the first member that settles with it, never to every member; and the charge commits with the claim's release, so a crash between them never counts it twice. With `persistence.preparation_deadlines` off nothing is counted and no backoff applies. | Run `gbrain sources writer status --source <source> --json` (read-only: the owner, its pool, what its writes wait on), then submit the write again with a new `request_id` once the database is less loaded; for a held sync file, run `gbrain sources retry-held <source>` and the same sync with its options. A `publication_ceiling` cause on a page that legitimately takes longer to publish is the user's call: ask before raising `persistence.publication_ceiling_ms` (or the database `statement_timeout` for a `statement_cancel`). If the same write ends this way again, report its request id with `gbrain doctor --json`. Do not raise `persistence.max_transient_retries` to get past it. |
| <a id="write_outcome_unknown"></a>`write_outcome_unknown` | `write_outcome_unknown` | The database session dropped while the write was being admitted (a pooler reap, a failover, `pg_terminate_backend`), and it kept dropping through the re-reads, so whether the write was accepted is unknown (#6355). A single drop never reaches you: the admission attempt is re-run after 100, 300 and 900 ms, and every attempt begins by reading the retained `request_id`, so a re-run replays an admitted row instead of admitting again. Before this code existed the raw socket error (`write CONNECTION_CLOSED …`, `57P01`) reached the caller while the write went on to commit, and a receipt oracle took it for a refusal. | Read the request first: `gbrain write-request -- <request_id>` or `get_write_request { request_id }` (the error's `fix` names it). A committed or pending row means the write was accepted: replay the same `request_id` to wait for it. No row means it was not: submit it again with the same `request_id`. Never resubmit under a new `request_id` without that read. |
-| <a id="connection_inherited_read_only"></a>`connection_inherited_read_only` | `connection_inherited_read_only` | The database refused the write as read-only (SQLSTATE `25006`): the server connection defaults to read-only transactions, from a session-level `SET default_transaction_read_only = on` another client left on a connection a transaction-mode pooler shares, a role or database default, or a read-only server such as a hot standby. Nothing was written. gbrain opens its transactions `BEGIN READ WRITE` and runs a refused autocommit statement once more inside one, so this code means the refusal outlasted that: a read-only server, or a write path outside those seams. A managed sync stops the run with it (systemic, needs the database operator). | Ask the database operator: reset the pooler's server connections (PgBouncer `RECONNECT`, or `server_reset_query = DISCARD ALL` with `server_reset_query_always = 1`), find the client that issues session-level `SET` through the pooler, and check `ALTER ROLE` / `ALTER DATABASE ... SET default_transaction_read_only`; then submit the write again. [Troubleshooting](troubleshooting.md#inherited-read-only-connections). |
+| <a id="connection_inherited_read_only"></a>`connection_inherited_read_only` | `connection_inherited_read_only` | The database refused the write as read-only (SQLSTATE `25006`): the server connection defaults to read-only transactions (a session-level `SET` another client left on a pooled connection, a role or database default, or a read-only server). Nothing was written. gbrain opens its transactions `BEGIN READ WRITE` and retries a refused autocommit statement inside one, so this means a read-only server or a write path outside those seams. A managed sync stops the run with it (systemic). | Ask the database operator to reset the pooler's server connections, stop the client issuing session-level `SET` through the pooler and check `ALTER ROLE` / `ALTER DATABASE` defaults; then submit the write again. [Troubleshooting](troubleshooting.md#inherited-read-only-connections). |
| <a id="page_body_segmented"></a>`page_body_segmented` | `page_body_segmented` (a memory verb: `invalid_params` with `write_error: page_body_segmented`) | The target page stores its body in segments (a page over 1 MiB written while `pages.segmented_storage` was on), and this write needs the whole body as one string: `remember` against an entity page over 24 MiB (named, or inferred from the fact), and the other whole-body writers listed under [page_body_segmented](windowed-reads.md#page_body_segmented). It refused before changing anything and is not retryable. | For `remember`, save the claim without an entity (`infer_entity: false`); remembering it with `entity` once that page accepts fact rows replaces that copy. Otherwise edit the page's file and sync it, or read it with `get_page` `body: "auto"`. |
| <a id="fence_unrenderable"></a>`fence_unrenderable` | `fence_unrenderable` | A legacy fact row (an active `facts` row with no fence row number) was not adopted into its page's `## Facts` fence because the fence codec reads the rendered row back as something other than the stored fact: a whitespace-only claim comes back empty, `~~x~~` comes back struck, a literal `<br>` comes back as a line break, or another column changes. Surrounding whitespace and CRLF line endings are the one accepted difference: such a row is adopted and `facts.fact` takes the fence's text. A second legacy row whose normalized claim, source and visibility the page already carries is left too (`duplicate_claim`; a private and a world row with one text are two facts and both adopt). The cycle and the v0.32.2 migration print `FACTS_FENCE_FAILED: <slug> (fence_unrenderable: N row(s), <class>)`; doctor `fence_integrity` lists the pages, fact ids and reason classes under `unrenderable_legacy_facts` (never the claim text). The same code refuses a planned adoption whose rendered fence does not read back as its facts; that is a gbrain planning defect, not caller input. The planner runs the publisher's own read-back check on the whole rendered fence first, so such a page is reported as unadoptable (class `whole_fence`) instead of being submitted. A managed adoption refused in the last day is not resubmitted: the cycle reports it as class `prior_refusal` with the refused request id (`gbrain write-request -- <id>` reads it), and a direct `submitFactFenceAdoption` call refuses with `The same fact-fence adoption was already refused.`. It is retried a day after the refusal, or at once by a build whose adoption planner revision changed. Unadopted rows hold only their own page: the phantom-redirect pass skips a phantom that owns one and redirects the others. Before v0.60.218.0 the planner could reuse a leftover fence row (one with no database owner) whose visibility differed from the legacy fact's. On a managed brain the publisher refused that page here every cycle, so no private fact was published as world. An unmanaged brain had no such check: it fenced the fact into the leftover row, and the same cycle's reconcile copied that row's visibility into the fact, so a private fact could become world. The current planner never reuses a leftover row for a fact with a different visibility unless the fact is private, and re-renders a reused row from the fact. To count what an older build left in the writer table, run the read-only `scripts/diagnose/fence-adoption-census.sql` on the brain host against the brain's Postgres database (its header shows the `psql` command). | Nothing to fix in the page: the rows stay active and searchable, nothing is lost, and their pages skip destructive fact reconciliation until the rows are adopted. Report the pages and reason classes with the gbrain version. Never `forget_fact` a row to clear the count. |
| <a id="reconcile-private-facts"></a>reconcile private facts | `permission_denied` | `gbrain sources reconcile --apply` (and its preview) found a `## Facts` row that would edit, renumber or change the visibility of a stored private fact, copy a stored private claim into a row under another visibility, or copy a stored private row's context (24 characters or longer) verbatim into a world row. A row is identified by its row number and claim, so a world row that only shares a private row's claim is not a private row and publishes. The refusal names the row number, never its text. It guards against verbatim copies only; reworded text is not detected, so it is not a confidentiality proof. Sources are not compared, because rows share provenance such as "Slack import". Nothing was written. | Read the stored page with the printed `gbrain get --source <id> -- <slug>`, keep the named row as stored in the file (or remove the copied text), then run a fresh `gbrain sources reconcile <id> <slug> --preview` and apply it. Change private facts with `remember` and `forget`. |
diff --git a/llms-full.txt b/llms-full.txt
index 4fe10d600a..8a9c49477d 100644
--- a/llms-full.txt
+++ b/llms-full.txt
@@ -10644,7 +10644,7 @@ Turning the `preparation_deadlines` switch off (`gbrain config set persistence.p
<a id="session-timeouts-not-applied"></a>**Doctor warns `persistence_session_timeouts` with `session_timeouts_not_applied`?** gbrain sets `statement_timeout` (`GBRAIN_STATEMENT_TIMEOUT`, default 5min) and `idle_in_transaction_session_timeout` as connection startup parameters, and a transaction-mode pooler (PgBouncer with `ignore_startup_parameters`, Supavisor) drops them: `SHOW statement_timeout` through the configured URL reads `0`, so a statement outside a transaction has no server-side bound and a relation lock held in another session (a migration's `ALTER TABLE pages` queued behind a long transaction, for example) holds it for as long as the lock lasts. Managed write *preparation* reads are not affected since v0.60.108: they run under a transaction-local `statement_timeout` of the write's remaining preparation budget, so a lock-blocked read ends at the budget and the member is released `preparation_deadline` with no statement left on the server (#6278). For every other autocommit statement, set the default on the role instead of the connection: `ALTER ROLE <gbrain role> SET statement_timeout = '5min'` (read-only to check: `gbrain doctor --only persistence_session_timeouts --json`). Setting `GBRAIN_STATEMENT_TIMEOUT` has no effect through such a pooler.
-<a id="inherited-read-only-connections"></a>**Writes fail with `connection_inherited_read_only` (SQLSTATE 25006, `cannot execute INSERT in a read-only transaction` or `... SELECT FOR SHARE ...`)?** The server connection defaults to read-only transactions. On a transaction-mode pooler (PgBouncer `pool_mode = transaction`, Supavisor) the usual cause is another client that ran a session-level `SET default_transaction_read_only = on`: the pooler shares server connections, so that setting stays on the connection and later clients inherit it until the connection closes. A role or database default (`ALTER ROLE ... SET default_transaction_read_only = on`) or a read-only server (a hot standby) has the same effect. gbrain opens its own transactions `BEGIN READ WRITE` and runs an autocommit statement the server refused this way once more inside one, so an inherited session default no longer stops its writes; the code remains for a read-only server and for any write path outside those seams. On the database or pooler host: reset the pooler's server connections (PgBouncer `RECONNECT <db>` on the admin console, or `server_reset_query = DISCARD ALL` with `server_reset_query_always = 1` so no session state survives a transaction), find the client that issues session-level `SET` through the pooler, and check the role and database defaults (`SELECT setrole::regrole, setdatabase, setconfig FROM pg_db_role_setting`). Run read-only audits as `BEGIN READ ONLY; ...; COMMIT;` or under a read-only role, never as a session-level `SET` through a transaction pooler.
+<a id="inherited-read-only-connections"></a>**Writes fail with `connection_inherited_read_only` (SQLSTATE 25006, `cannot execute INSERT in a read-only transaction`)?** The server connection defaults to read-only transactions: usually another client's session-level `SET default_transaction_read_only = on` left on a connection a transaction-mode pooler (PgBouncer `pool_mode = transaction`, Supavisor) shares, otherwise a role or database default or a read-only server such as a hot standby. gbrain opens its transactions `BEGIN READ WRITE` and retries a refused autocommit statement inside one, so the code means a read-only server or a write path outside those seams. On the database or pooler host: reset the pooler's server connections (PgBouncer `RECONNECT <db>`, or `server_reset_query = DISCARD ALL` with `server_reset_query_always = 1`), stop the client that issues session-level `SET` through the pooler (read-only audits belong in `BEGIN READ ONLY; ...; COMMIT;`), and check `pg_db_role_setting` for role and database defaults.
<a id="managed-sync-blocked"></a>**A managed sync run is blocked (doctor `managed_sync_blocked`, a freshness `sync` job ended `dead`, or get_brain_health reports `sync_blocked`)?** The source's unfinished run stopped on a page request that did not commit and recorded the stop, so it resumes nothing by itself while the other sources keep syncing (#6858: one source stopped for 21 hours while every freshness job reported `completed`). Such a job now ends `dead`: its error names the stop and the run's `next` command, and `gbrain jobs get <id> --json` carries `outcome`, `drain` and `next` in its progress. Doctor warns as soon as a run is blocked and fails once it has been blocked for more than an hour; get_brain_health turns to `attention` past the same hour, with a count band and no source names. A sync pass that stopped before it finished (in discovery, path `<discovery>`, or on one file) counts as blocked too, until a later sync of the source succeeds. Run `gbrain sync status --source <id> --json` (read-only): it names the page, its fault class and its exit. Clear the cause it names and run the step it prints; the next freshness job resumes the run once the cause is gone. A page publication that `gbrain repair stuck-recovery --keep disk` abandoned is not a blocker: the next plain sync retries that page after the rest of its run, imports it when the kept file is committed, and holds it `worktree_dirty` otherwise.