Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

Regenerate llms-full.txt and the memory-provider contract on the merged tree

garrytan025f43871ee2
diff --git a/docs/contracts/qm-memory-provider/v5.json b/docs/contracts/qm-memory-provider/v5.json
index 12264cfd0c..47bb2ebb52 100644
--- a/docs/contracts/qm-memory-provider/v5.json
+++ b/docs/contracts/qm-memory-provider/v5.json
@@ -982,7 +982,7 @@
},
"token_budget": {
"type": "number",
- "description": "Evidence token cap."
+ "description": "Evidence token cap. Without return_unit it caps the chunk payload; with search.query_budget_unit=auto it is the hard delivery cap (below 32 refused)."
},
"expand": {
"type": "boolean",
diff --git a/llms-full.txt b/llms-full.txt
index b67f0aed84..288a79b97b 100644
--- a/llms-full.txt
+++ b/llms-full.txt
@@ -5132,11 +5132,18 @@ tables) under that role's RLS. Every gbrain function that pins a search_path end
cannot hide it from a guard; before, any session, the owner included, could store purged
content that way. A write role with no policy on a ledger still reads it empty, so its
purged or withdrawn writes still go through: give a scoped write role a `SELECT` policy on
-the ledgers of the sources it writes (gbrain#7659 tracks the fix). Where the migrating role
-does not own a function, v277 names it on stderr and leaves it; `gbrain doctor`
-(`function_search_path`) prints the `ALTER FUNCTION` to run as its owner
-(`test/e2e/function-search-path-postgres.test.ts`).
-
+the ledgers of the sources it writes (gbrain#7659 tracks the fix). Each definition outside
+`src/core/schema-migrations/` pins `pg_catalog, public, pg_temp` itself (`bun run check:search-path`
+fails one that does not, or a pinned function missing from `PINNED_FUNCTION_NAMES`), so a schema
+replay keeps it; historical migration bodies still pin the old path, so every migration run ends by
+putting `pg_temp` back (`hardenFunctionSearchPaths` in `src/core/function-search-path.ts`), and the
+schema blob's generated hardening region must stay its last statement. Where the migrating role
+does not own a function, the run that applies migrations names it on stderr and leaves it;
+`gbrain doctor` (`function_search_path`) prints the schema-qualified `ALTER FUNCTION` to run as its
+owner, or `gbrain apply-migrations --yes` below v277 ([function search path](guides/troubleshooting.md#function-search-path);
+`test/e2e/function-search-path-postgres.test.ts`).
+
+<a id="writer-protocol-fences"></a>
**Writer-protocol fences.** The managed-writer guard, the persistence protocol floor, protocol
activation and the Git-canonical source counter also run as the writing role and read their state
under its RLS. Since migration v278 (#7636) they fail closed: a role that cannot see the
@@ -5149,8 +5156,9 @@ publication either one is stored on the receipt as `writer_coordinator_required`
#7777 for the protocol guards, #7780 for the state and remedy). A protocol guard's
refusal outside publication (write admission, protocol activation) reaches the command as that
database error, which gbrain's generic database output labels `permission_denied` with grant
-advice: the code at the start of the message names the refusal. On a managed brain the same refusal covers a hidden `git_canonical_brain` row or
-Git-canonical source row (for a writer without the git protocol) and a hidden page row behind a tag,
+advice: the code at the start of the message names the refusal. On a managed brain the same refusal covers, for a writer without the git protocol, a
+hidden `git_canonical_brain` row and, while the brain has any Git-canonical source, a hidden
+target or old source row whether or not that source is Git-canonical; and a hidden page row behind a tag,
timeline entry or take. Protocol activation (row-level security on `sources`, `persistence_requests`,
`persistence_effects`, `persistence_worktrees` or `persistence_source_bindings`) and a change to
which sources are Git-canonical (row-level security on `sources`) refuse any role it applies to,
@@ -9380,6 +9388,7 @@ Source: https://raw.githubusercontent.com/garrytan/gbrain/master/docs/guides/tro
| Writes fail with `connection_inherited_read_only` (SQLSTATE 25006) | [reset the pooler's server connections, stop session-level `SET`, check role defaults](write-refusals.md#connection_inherited_read_only) | brain host | none | `gbrain doctor --json` |
| [Doctor warns `persistence_session_timeouts` (`session_timeouts_not_applied`)](#session-timeouts-not-applied) | `ALTER ROLE <gbrain role> SET statement_timeout = '5min'` on the database, or accept it: preparation reads carry their own bound | brain host | none (a role default; `destructive` only in that it changes a server setting) | `gbrain doctor --only persistence_session_timeouts --json` |
| `gbrain init` or `gbrain upgrade` stops with `schema_lock_blocked` naming a pid (or, before #5227, sat in `wait_event_type=Lock` with no output) | let the named session finish, or with the user's agreement end it on the database host: `SELECT pg_terminate_backend(<pid>)`; then rerun the same command ([ENGINES.md](../ENGINES.md#schema-lock-blocked)) | brain host, after the user agrees | `destructive` when it ends another session | the rerun completes; `gbrain doctor --json` shows the schema at head |
+| Doctor `function_search_path` fails: a gbrain function's search_path does not end in `pg_temp` | follow the check's `fix`: below schema v277 it is `gbrain apply-migrations --yes`; past it, run the printed `ALTER FUNCTION` statements as the role that owns each function ([function search path](#function-search-path)) | agent below v277; brain host past it | none | `gbrain doctor --only function_search_path --json` |
| [`queue_capacity`, `persistence_capacity` or `persistence_request_growth`](#write-capacity) | run the printed `gbrain config set persistence.limits.<limit> <value>` | brain host | none | `gbrain doctor --only persistence_capacity,persistence_request_growth --json` |
| [`dream_paid_loop`, or dream keeps skipping one transcript](#dream-paid-loop) | fix the cause, then `gbrain dream reset-key --list` and `gbrain dream reset-key '<key>'` | agent, after the user agrees | `paid` (the key is retried) | `gbrain doctor --only dream_paid_loop --json` |
| [A page exists (`gbrain get <slug>` returns it) but search never finds text from it](memory-boundaries.md#large-pages) | `gbrain reindex --oversized --dry-run --json` lists pages stored before the upgrade with a size-based `embed_skip` marker (without `--dry-run` it keyword-indexes them, free); a page above an operator-lowered `content_sanity.bytes_block` keeps its marker until it is raised; a page the content-quality gate quarantined shows in `gbrain quarantine list` (`gbrain quarantine clear <slug>` re-checks it once the user agrees); a file over the 24 MiB page ceiling was never stored ([`file_too_large`](write-refusals.md#file_too_large)). Its chunks waiting for embedding approval (doctor `partial_embedding`) are a paid step: `gbrain embed --held --dry-run`, then `gbrain embed --held --source <id> --max-usd <N>` as printed | agent for the reindex; the user decides embedding spend, a `bytes_block` change and a quarantine clear | none for the reindex; `paid` for `gbrain embed` | `gbrain reindex --oversized --dry-run --json` lists nothing; `gbrain search "<phrase from deep in the page>"` returns the page |
@@ -10242,6 +10251,25 @@ from it are theirs to review before anything is removed.
Verify with `gbrain sources status <id> --json` and
`gbrain doctor --only default_source_local_path --json`.
+## Function search path
+
+<a id="function-search-path"></a>
+
+Every gbrain function that pins a `search_path` ends it with `pg_temp`, so a session's temporary table or view named
+like a purge or withdrawal ledger cannot hide that ledger from the guard that reads it (#7632). Migration v277 and the
+end of every migration run append it to each function the migrating role owns; doctor's `function_search_path` check
+names any function whose pinned path still lacks it.
+
+- **Below schema v277**, the check's fix is `gbrain apply-migrations --yes`, which runs v277. Check again afterwards:
+ what is left is owned by another role.
+- **A function another role owns** cannot be altered by the migrating role, so the migration leaves it and names it
+ on stderr during runs that apply migrations. Run the `ALTER FUNCTION public.<function>(<argument types>) SET
+ search_path = …, pg_temp;` statements the check prints (also in its `details.sql`) on the database host, connected
+ to this brain's database as the role that owns each function. `ALTER FUNCTION … SET` changes neither the owner nor
+ the body, so the next boot's `CREATE OR REPLACE` still succeeds.
+
+Verify with `gbrain doctor --only function_search_path --json`.
+
---
# Migrations