Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

docs(pages): large-pages guide, per-entry-point limits and no-split remediation text

garrytan44dcdf35a9f0
diff --git a/docs/architecture/key-files/files-and-sync-1.md b/docs/architecture/key-files/files-and-sync-1.md
index 62fbc36298..4cb57f548d 100644
--- a/docs/architecture/key-files/files-and-sync-1.md
+++ b/docs/architecture/key-files/files-and-sync-1.md
@@ -27,7 +27,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL
- `src/core/import-checkpoint.ts` — `loadCheckpoint(path, currentDir)`, `saveCheckpoint(path, cp)`, `resumeFilter(allFiles, dir, completed)`, `clearCheckpoint(path)`, `resolveImportTargetDir(dir)`, and the `ImportCheckpoint` type. Payload: `{schema_version: 1, owner: 'gbrain', kind: 'import', dir, completedPaths, timestamp}`; `dir` is the absolute realpath of the import target, never the caller's CWD. Paths record successful/unchanged progress, not content identity; ordinary `runImport` revalidates all current files via `importFile`'s existing content-hash comparison rather than using `resumeFilter`. Company-brain ingestion uses separate protected database checkpoints for an immutable approved manifest. The exported pure filter returns a path array and skips completed paths for company-brain manifest resume; by itself it is not proof that mutable file content is unchanged. `loadCheckpoint` returns `null` for missing/malformed payloads, target mismatch, invalid path/timestamp fields, or incompatible producer metadata; absent producer fields in legacy path-set checkpoints remain accepted. Old positional checkpoints log a stderr diagnostic before discard. `saveCheckpoint` sorts paths and atomically writes via `.tmp` + `rename()`; save/clear failures are non-fatal and silent. The caller supplies the checkpoint path via `gbrainPath()`, preserving `GBRAIN_HOME` isolation. Pinned by `test/import-checkpoint.test.ts`, `test/import-resume.test.ts`, and `test/import-json-stdout.test.ts`.
-- `src/core/import-screen.ts` — `screenImportContent`: the one content screen (published exemption, size, frontmatter hold, slug conflict, Tier 1: a fixable fence is admitted normalized, a residual refuses typed (`coordinated`) or warns (`lenient`); optional sanity reject) shared by `importFromContent`, managed import and managed sync publication. `contentRefusalError` keeps each site's wire `error`; `isContentRefusal(code, message)` matches new codes and exact pre-upgrade strings, never capacity or transient refusals; `contentRefusalFromReceipt` restores code, reason, key and line on receipt replies. Tests: `test/import-screen.test.ts`, `test/sync-frontmatter-recovery.test.ts`, `test/put-page-recoverable-frontmatter.test.ts`. #6259 marker strip: [quarantine cluster](quarantine.md).
+- `src/core/import-screen.ts` — `screenImportContent`: the one content screen (published exemption, size, frontmatter hold, slug conflict, Tier 1: a fixable fence is admitted normalized, a residual refuses typed (`coordinated`) or warns (`lenient`); optional sanity reject) shared by `importFromContent`, managed import and managed sync publication. `contentRefusalError` keeps each site's wire `error`; `isContentRefusal(code, message)` matches new codes and exact pre-upgrade strings, never capacity or transient refusals; `contentRefusalFromReceipt` restores code, reason, key and line on receipt replies. `PAGE_OVER_LIMIT_SUGGESTION` is the one next step of a page write over the page limit (put_page receipts and `page-prepare.ts`): it names the limit and says only content over it becomes several pages. Tests: `test/import-screen.test.ts`, `test/sync-frontmatter-recovery.test.ts`, `test/put-page-recoverable-frontmatter.test.ts`. #6259 marker strip: [quarantine cluster](quarantine.md).
- `src/core/import-file.ts` — importFromFile + importFromContent (chunk + embed + tags). Every markdown import resolves and stamps `contextual_retrieval_mode` and `corpus_generation` with the canonical write, `--no-embed` included (#5621), so later embed passes reproduce the page's wrapping; a failed source-policy read fails the import unless the row or table is missing (`SourceRowNotFoundError`, `isUndefinedTableError`). Unchanged markdown or code content whose page is below the safe-chunk fence is re-sealed projection-only (direct imports install it; coordinated `prepare` imports stay no-ops and queue a `safe_chunk_reseal` projection job), with no page write or admission. Freshly embedded chunks carry `embedding_input_hash` for the tier they were built under. The `beforeCommit` hook runs inside the guarded canonical transaction so a rejected file write rolls back its projections; optional legacy source-path repair uses a savepoint. Deferred importer embedding callbacks capture the committed text projection and indexing context, then install with an UPDATE-only revision/chunk/hash check. Tests: `test/import-publication-guards.test.ts`. Coordinated `prepare` imports resolve and atomically stamp the page/source/global contextual wrapping mode even with `noEmbed:true`; the durable outbox later embeds that revision. The existing paid-synopsis title fallback and mount trust gate remain in force, while embedding signatures only certify completed vectors. `test/persistence-contextual-embedding.test.ts` covers both engines, policy precedence, deferred provider execution, and a competing title replacement. `importFromContent` and `importCodeFile` stamp `pages.embedding_signature` via `setPageEmbeddingSignature(slug, {sourceId, signature: currentEmbeddingSignature()})` when the import actually embedded (not `--no-embed`) so a model/dims swap is detectable as stale; `importCodeFile` only stamps when every chunk was freshly embedded this call (`needsEmbedIndexes.length === chunks.length`), mixed reuse-by-hash pages stay unstamped (`reindex --code --force` / `embed --stale` handle those). `importFromContent` reconciles tags by provenance (`tags.tag_source`, migration v175): frontmatter tags go through `addTag(..., { tagSource: 'frontmatter' })`, and a row still marked 'frontmatter' whose tag left the frontmatter is deleted in the import transaction. Every other `addTag` stamps 'added' (add_tag, enrichment, the code importer) and is never import-deleted, so `gbrain reindex --markdown` keeps enrichment tags; legacy NULL rows are adopted only while the frontmatter still lists them; prepared (managed) imports keep add-only tags, matching the union their canonical file renders. Pinned by `test/reindex-preserve-tags.test.ts`, `test/import-frontmatter-tag-removal.test.ts` + `test/import-file.test.ts`. identity decisions live in `src/core/import-identity.ts` (`decideImportIdentity`, `collidingSlugOwner`; pure reads, the importer applies them). The dedup pre-check calls `engine.findDuplicatePage?.(sourceId, {hash, frontmatterId, excludeSlug})` (optional `?` so test doubles compile; the caller's own slug never matches, and a `frontmatter.id` match ranks ahead of a bare hash match). Posture: MOVE when the `frontmatter.id` matches and the other page's OWN origin proves it moved (#5675): that origin is the `file://` path `importFromFile` records in `pages.source_uri` (never replacing non-file provenance), else the source's configured root (`local_path`, or the default source's legacy `sync.repo_path`). An origin that still exists moves only when it is this very file under another relative path (overlapping roots converge); a gone origin needs this file under that same root, and differing content also needs the same file name or title, so a missing path under another root, or a new note reusing a deleted note's template id, never renames a live page. `updateSlug` carries the row (page id, links, facts incl. `entity_slug`/`source_markdown_slug`, `page_aliases`, timeline, plus a rename alias) and the new content imports onto it, so a full sync's delete-reconcile has nothing live to remove; SKIP only when the id AND the content (`content_hash`, or title and body for a row written outside the importer) both match while the recorded file still exists (overlapping ingest roots); IMPORT with a warning when the id matches but content differs (templates, copy-paste; an edit is never frozen by the other page); WARN-ALWAYS on a bare content_hash collision; FAIL CLOSED on lookup error; bypass via `--force-rechunk`. Content-only callers (`put_page`, transcripts) never move a page. Soft-deleted pages excluded at the engine layer so tombstones don't block legitimate re-imports under new slugs. Slug collisions: when another live file (`existing.source_path`, realpath-distinct) already owns the slug, the incoming file is skipped with `skip_reason: 'slug_collision'` and a stderr warning, unless the incoming file is named exactly `<slug>.md` (the file the link extractor reads for that slug), so two spellings never overwrite each other. An embedding failure never blocks the text write: chunks commit with NULL vectors, no embedding signature is stamped, the result carries `embedding_deferred: true`, and the stale sweep embeds them later (a code file whose embed failed is not stamped either). An inline markdown re-import embeds only chunks whose embedding input changed: `planEmbeddingReuse` (keyed on chunk source + exact text) reuses a stored vector when the old index is sealed (`requireSafeChunks`), the page's `embedding_signature`, contextual mode, `corpus_generation` and (under the title wrapper) sanitized title are unchanged, and neither the old nor the new body holds protected fences; `--force-rechunk` and post-commit-embedding imports reuse nothing (`test/import-markdown-embedding-reuse.test.ts`); identical rows stay put (`import-chunk-reuse.ts`). Offset-less frontmatter datetimes are read in the brain's `brain.timezone` (IANA, validated by `gbrain config set`; unset or invalid = UTC; the YAML parser tags naive timestamps with `NAIVE_DATETIME` so the wall-clock reading survives), while date-only values stay UTC calendar dates (`test/effective-date-brain-timezone.test.ts`). `effective_date` for an undated page falls back to `fallbackCreatedAt` (stored fallback date, else the earliest of the file's birth/modification time and — when `sync.git_first_commit_dates` is on — its git first-commit date via `fileTimes`, else now; `src/core/git-first-commit.ts` maps paths in one `git log --diff-filter=A` pass per `runImport`, skipping shallow clones; `test/effective-date-git-first-commit.test.ts`), never the latest write. Pinned by `test/import-dedup-frontmatter-id.test.ts`, `test/import-identity-move.test.ts`, `test/import-slug-collision.test.ts`, `test/import-embed-outage.test.ts` and `test/effective-date-calendar.test.ts`. `importFromContent` is the narrow waist every ingest path passes through (`gbrain import`, `gbrain sync`, `put_page` MCP, `/ingest` webhook). It runs a three-tier content-quality disposition via `assessContentSanity` from `src/core/content-sanity.ts` BEFORE chunking: (1) high-confidence junk (built-in Cloudflare/CAPTCHA interstitial patterns + operator literals) → QUARANTINE (stamps the `quarantine` frontmatter marker, writes ZERO chunks, hides the page from search) OR REJECT (throw → sync-failure) when `content_sanity.junk_disposition` is `reject`; (2) fuzzy markup-heavy (prose-vs-markup ratio above `content_sanity.max_markup_ratio`, warn-tier byte window, code pages exempt) → `content_flag:markup_heavy` marker (page stays fully searchable, marker rides search results + get_page to warn the agent); (3) oversize → `embed_skip` soft-block via `buildEmbedSkipMarker()` PLUS a `content_flag:oversized` marker, AND deletes any pre-existing chunks in the same transaction so search can't surface stale chunks. Gate-owned markers (`quarantine`, `content_flag`) are STRIPPED from untrusted (remote MCP, `ctx.remote !== false`) frontmatter so a write-scoped client can't hide pages or forge the warning channel; markers are excluded from `content_hash` so a flagged page doesn't re-embed every sync, but an `embed_skip` transition (present vs absent) defeats both unchanged fast paths so a threshold change rebuilds or removes chunks without `--force`. A trusted import whose content the gate no longer blocks drops an incoming `embed_skip` (and a `content_flag`) whose reason is `oversized`; other skip reasons, quarantined pages and the sanity bypass keep them. `gbrain import` honors `errors > 0` for non-zero exit. `classifyErrorCode` in `src/core/sync.ts` recognizes the `PAGE_JUNK_PATTERN` code so sync-failures.jsonl grouping bins these. `extractEntityRefs` (canonical; matches both `[Name](../people/slug)` markdown links and Obsidian `[[people/slug|Name]]` wikilinks), `extractPageLinks`, `inferLinkType` heuristics (attended/works_at/invested_in/founded/advises/source/mentions), `parseTimelineEntries`, `isAutoLinkEnabled` config helper. Link candidates match any dir-shaped path (existence-checked at persist). Used by extract.ts, operations.ts auto-link post-hook, and backlinks.ts. Pinned by `test/import-file-content-sanity.test.ts`. `importImageFile` records `source_path` on every image page and skips an unchanged image only when its index is complete for the run: a visual vector when embedding is on, and OCR (`ocr_status: 'done'` in frontmatter, or legacy stored OCR text) when OCR is enabled, so an image first imported under `--no-embed` or an OCR skip is rebuilt on its next import (`test/import-image-retry.test.ts`). `importCodeFile` writes `source_path: relativePath` on every code page (the same repo-relative path markdown imports record) so the full-sync reconcile — which only considers `source_path IS NOT NULL` rows — can retire a deleted code file's page; `putPage` COALESCEs the column, so rows imported before this keep NULL until the file changes, `sync --force`, or `gbrain reindex-code --force`. A frontmatter `slug:` that would become the page identity and ends in `.md`/`.mdx` is held as `frontmatter_slug_conflict` unless that exact (source_id, slug) page is live (`persistence/suffixed-slug.ts`).
diff --git a/docs/guides/error-codes.md b/docs/guides/error-codes.md
index 5c145491d9..478a16e256 100644
--- a/docs/guides/error-codes.md
+++ b/docs/guides/error-codes.md
@@ -1113,7 +1113,9 @@ More: [docs/guides/repair.md#file-removed-during-scan](../../docs/guides/repair.
| Meaning | Why | Next step | Who acts · consent | Verify | Exit | Retryable |
|---|---|---|---|---|---|---|
-| The file is over the import size limit (5 MB for Markdown and code, 10 MiB for any sync read), so it was not imported. | Size limits bound parsing, chunking and embedding cost. The same bytes refuse on every retry. | Split the file into smaller files, or leave it out of the source (sync.exclude), then sync or import again. | agent | `repeat the read that failed` | 1 | no |
+| The file is over the page size limit (24 MiB for a Markdown page, 5 MB for a code file), so it was not imported. | Every page under the limit is stored, chunked and searchable whatever its size; the limit bounds what one page may hold in this release. The same bytes refuse on every retry. A smaller page refused by an MCP or HTTP transport is a different refusal. | Leave the file out of the source (sync.exclude), or, if it must be in the brain, split it into files under the limit; then sync or import again. Never split a page under the limit. | agent | `repeat the read that failed` | 1 | no |
+
+More: [docs/guides/write-refusals.md#file_too_large](../../docs/guides/write-refusals.md#file_too_large)
### fix_not_writable
diff --git a/docs/guides/memory-boundaries.md b/docs/guides/memory-boundaries.md
index 58e4e29d92..8d57a7e72d 100644
--- a/docs/guides/memory-boundaries.md
+++ b/docs/guides/memory-boundaries.md
@@ -37,7 +37,8 @@ owner runs a [purge](#purge) on the brain host. See [ambient writeback](ambient-
Saving text or a fact never waits on a generative model: a write is
acknowledged and keyword-queryable without one. Embeddings are the configured
feature (`remember` embeds before saving to detect near-duplicates; pages embed
-just after the save). With default settings each saved page of an
+just after the save, and a page over 1 MiB embeds later through the stale
+sweep: see [large pages](#large-pages)). With default settings each saved page of an
extraction-eligible type (note, meeting, email and similar) also gets one facts
extraction call after it is saved; it runs as a queued job, is attributed to the
write that caused it, and stops with `gbrain config set facts.extraction_enabled
@@ -71,6 +72,109 @@ returns the rendered bullet, and editing or deleting that bullet in the page's
Timeline section through `edit_page` (with `expected_revision`) refreshes or
removes its row, because the page is the system of record for timeline rows.
+<a id="large-pages"></a>
+## Large pages
+
+**Say to your agent:** *"Import this long conversation export as one page and
+make it searchable. Tell me what embedding it will cost before you spend
+anything."* The agent imports the file on the brain host with
+`gbrain import <file>`, checks that keyword search finds it, and asks before
+running `gbrain embed`.
+
+**Say to your agent:** *"I upgraded gbrain. Which of my big pages couldn't be
+found before, and what would it cost to embed them now?"* The agent runs
+`gbrain reindex --oversized --dry-run --json` and `gbrain doctor --json`, then
+asks before `gbrain embed --held --max-usd <N>`.
+
+A page stays one page whatever its size: one slug, one title, one set of
+links. Size no longer decides whether search can find it. Every Markdown page
+up to 24 MiB (25,165,824 bytes) is stored, chunked and keyword-indexed when it
+is written, on every engine. Don't split a page by hand to make it searchable.
+
+| Page body | Keyword search | Meaning (vector) search |
+| --- | --- | --- |
+| Up to 1 MiB | right after the write | right after the write |
+| Over 1 MiB, up to 24 MiB (a *large* page) | right after the write | after the write commits, when the stale sweep embeds it (`gbrain embed --stale`, sync's embed pass, autopilot) |
+| Over 24 MiB | refused with [`file_too_large`](write-refusals.md#file_too_large); nothing is stored | — |
+
+Code files keep a lower limit; see [limits per entry point](#large-page-limits).
+
+A large page commits without vectors, so a big write never waits on the
+embedding provider. It also differs from a small page in three ways. Its
+chunks use the free title context tier, never a per-chunk model synopsis.
+Before it is embedded, the junk check samples its head, middle and tail
+instead of reading the whole body. And gbrain keeps a bounded number of
+version snapshots of it, so a page appended to every day doesn't store its
+whole body again in history on every write.
+
+An operator who set a lower `content_sanity.bytes_block` (the
+`GBRAIN_PAGE_BLOCK_BYTES` env var, the config file, or the database config)
+keeps the old behavior above that value: such a page is stored with an
+`embed_skip` marker and no chunks, so search doesn't find it. The default is
+the 24 MiB ceiling, so nothing is skipped for size unless someone lowered it.
+
+<a id="large-page-limits"></a>
+### Limits per entry point
+
+The page ceiling applies everywhere, but some transports carry less. When one
+of them refuses a page under 24 MiB, send the page by file instead: nothing is
+wrong with the page.
+
+| Entry point | Limit | What to do above it today |
+| --- | --- | --- |
+| Markdown import and sync (`gbrain import`, `gbrain sync`, the managed sync blob read) | 24 MiB | — |
+| CLI stdin (`gbrain put`, `gbrain capture --stdin`) | 24 MiB (was 5 MB) | — |
+| MCP stdio (local agents) | the MCP SDK reads at most 10 MiB per JSON-RPC message, and the page travels JSON-escaped | write the file into the brain repository and run `gbrain sync`, or run `gbrain import <file>` or `gbrain put <slug> < file` on the brain host |
+| MCP over HTTP (`gbrain serve --http`) | 4 MiB request body (the MCP SDK default) | the same: sync or the CLI on the brain host (chunked uploads arrive in a later release) |
+| Legacy HTTP transport | 1 MiB (`GBRAIN_HTTP_MAX_BODY_BYTES`) | the same |
+| `put_pages` batch | 8 MiB per batch | send large pages one per `put_page`, or by file |
+| Persistence journal | 64 MiB of outstanding JSON-escaped write intent per principal (was 32 MiB), 256 MiB per brain | nothing: a second large write waits for the first |
+| Local persistence socket (IPC) | 32 MiB per frame, JSON-escaped | nothing for ordinary text; only a pathological page (mostly quotes or backslashes) reaches it below the ceiling |
+| Pre-push secret scan | 25 MiB per file; gbrain never writes a canonical file over it | — |
+| GitHub | warns at 50 MB, rejects at 100 MB | — |
+| Export | aborts on a page over 32 MiB, which the 24 MiB ceiling makes unreachable | — |
+| Company-brain inspection | 5 MB per file | unchanged |
+| Transcript ingest input (Claude Code `.jsonl`) | 10 MiB by default, 50 MiB hard cap | unchanged |
+| Code files | 5 MB | unchanged |
+
+**Reading a large page.** Large reads come back in windows, not as one
+response, because agent transports and harness result caps can't carry tens of
+megabytes. The [`get_page` reference](../mcp/TOOL_REFERENCE.md#get_page)
+describes how to read the next window.
+
+**Cost.** Chunking and keyword indexing run locally and cost nothing.
+Embedding a large page costs about $0.15 per 10 MB at the default embedding
+model, so a page at the 24 MiB ceiling costs about $0.40. Each page has a paid
+spend cap, `embed.max_usd_per_page` (default $2), covering its embedding,
+per-chunk contextual synopsis and conversation facts. When several caps apply,
+the lowest wins: the per-page cap, the run's consent cap (`--max-usd`),
+`embed.backfill_max_usd` and `embed.backfill_max_usd_per_source_24h`. A page
+over its cap is still keyword-searchable, and its newest chunks are embedded
+first, up to the cap. Doctor's `partial_embedding` check names each such page
+with the exact fix, `gbrain embed --slugs <slug> --max-usd <N>`; raising a cap
+is the user's call.
+
+<a id="large-pages-upgrade"></a>
+**After upgrading.** Older releases stored a page over 500 KB with an
+`embed_skip` marker (reason `oversized`) and no chunks. `gbrain upgrade` and
+`gbrain apply-migrations --yes` re-chunk and keyword-index those pages
+themselves, on the CPU, on keyless brains too. The backfill is idempotent and
+resumes where it stopped. It removes only gate-written markers whose reason is
+`oversized`, and the matching `content_flag: oversized`; a page above the
+operator's effective `bytes_block` keeps both. The backfill never embeds:
+backfilled pages are held for consent. The post-upgrade notice and doctor show
+how many pages are held and what embedding them would cost.
+
+```bash
+gbrain reindex --oversized --dry-run --json # preview the backfill: free, no provider calls
+gbrain reindex --oversized --source <id> # run it now for one source
+gbrain embed --held --max-usd 2 # embed every held page, capped at $2 (paid)
+gbrain embed --slugs <slug> --max-usd 1 # embed one page, capped at $1 (paid)
+gbrain search "<a phrase from deep in the page>" # keyword search finds it before any embedding
+gbrain doctor --only partial_embedding --json # pages embedded only up to their cap
+gbrain config set embed.max_usd_per_page 5 # raise the per-page cap (ask the user first)
+```
+
## Where text goes
Local storage does not mean every enabled feature runs locally. Keyless keyword
diff --git a/docs/guides/remote-mcp.md b/docs/guides/remote-mcp.md
index 326f78e6b2..dcca4b7071 100644
--- a/docs/guides/remote-mcp.md
+++ b/docs/guides/remote-mcp.md
@@ -414,9 +414,13 @@ put_pages with one request_id per batch and wait_ms 25000."*
`gbrain config set mcp.remote_auto_links false`.
- **Embedding** runs after the commit. New text is searchable by keyword
immediately and by meaning once its embedding effect finishes.
-- **Request size.** `gbrain serve --http` reads the whole request; the
- simpler HTTP transport caps a request at `GBRAIN_HTTP_MAX_BODY_BYTES`
- (1 MiB by default) and its 413 reply tells the agent to split the batch.
+- **Request size.** HTTP carries less than the 24 MiB page ceiling:
+ `gbrain serve --http` reads at most 4 MiB per request (the MCP SDK
+ default), and the simpler HTTP transport caps a request at
+ `GBRAIN_HTTP_MAX_BODY_BYTES`. A batch goes in smaller `put_pages` calls; a
+ page over the transport limit goes by file on the brain host (sync,
+ `gbrain import` or `gbrain put`), never split by hand. Every limit is in
+ [limits per entry point](memory-boundaries.md#large-page-limits).
## PGLite brains
diff --git a/docs/guides/repair.md b/docs/guides/repair.md
index 57f0741277..f6ee921312 100644
--- a/docs/guides/repair.md
+++ b/docs/guides/repair.md
@@ -1294,7 +1294,7 @@ Each file gets one minimal line change in one class:
| --- | --- | --- |
| `safe` | Quote a value exactly as gbrain already reads it, strip NUL bytes, swap the outer quotes of a nested quoted value. Every parsed value stays the same. | Included. |
| `interpretive` | Fold unquoted continuation lines into the value above, keep the later of a duplicated key, quote an unclosed `[`/`{` or a `#`-leading title, insert a missing closing `---`, remove a `slug:` line that names another page, re-import a page from its file, re-bind a held rename to the old page's current revision. | Only with `--include-ambiguous`. |
-| `needs_review` | No rule fixes it (mis-indented YAML, a protected key such as `visibility`, an import that would keep page data the file does not carry, a file over 5 MB). | Never written. The preview names the exact manual fix. |
+| `needs_review` | No rule fixes it (mis-indented YAML, a protected key such as `visibility`, an import that would keep page data the file does not carry, a file over the [page size limit](memory-boundaries.md#large-page-limits)). | Never written. The preview names the exact manual fix. |
Two passes: when interpretive candidates exist, the safe preview's
`next_actions` carry both the safe apply and the `--include-ambiguous` preview.
diff --git a/docs/guides/troubleshooting.md b/docs/guides/troubleshooting.md
index 1316fa02f0..1124213abb 100644
--- a/docs/guides/troubleshooting.md
+++ b/docs/guides/troubleshooting.md
@@ -54,6 +54,7 @@
| `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 |
| [`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) | find the cause: `gbrain reindex --oversized --dry-run --json` lists pages stored before the upgrade with a size-based `embed_skip` marker (run it without `--dry-run` to keyword-index them, free); a page above an operator-lowered `content_sanity.bytes_block` keeps its marker until the operator raises or unsets it; a page the content-quality gate quarantined as junk shows in `gbrain quarantine list`, and `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)). Embedding the re-indexed pages is a separate paid step: `gbrain embed --held --max-usd <N>` | agent for the reindex; the user decides embedding spend, a `bytes_block` change and a quarantine clear | none for the reindex (CPU only); `paid` for `gbrain embed` | `gbrain reindex --oversized --dry-run --json` lists nothing; `gbrain doctor --json`; `gbrain search "<phrase from deep in the page>"` returns the page |
| [Search answers look keyword-only on a large Postgres brain](#hybrid-search-returns-only-keyword-hits) | read doctor's `vector_plan`; run the index command it prints | brain host | none | `gbrain doctor --only vector_plan --json` |
| [Broad keyword queries take about 8 s and come back vector-only (`keyword_arm_failed`) on a large Postgres brain](#keyword-search-times-out-on-a-large-postgres-brain) | read doctor's `keyword_plan`; narrow with `--source-id`, or raise `search.keyword_statement_timeout_ms` on the brain host and restart the serving process | brain host | none | `gbrain doctor --only keyword_plan --json` |
| A second `gbrain serve` cannot open the brain | the readiness `harness_wiring` fix: every session shares one `gbrain serve --http` | user | `persistent_install`, `credentials` | `gbrain doctor --only harness_wiring --json` |
diff --git a/docs/guides/write-refusals.md b/docs/guides/write-refusals.md
index b92e854ea5..599d086039 100644
--- a/docs/guides/write-refusals.md
+++ b/docs/guides/write-refusals.md
@@ -112,7 +112,7 @@ a receipt can report has a row here.
| `not_found` | `not_found` | The request, source or object named by the call does not exist. | Check the id; `gbrain sources list` lists sources. |
| `page_not_found` | `page_not_found` | The target page does not exist in that source, or disappeared during the write. | Check the slug and `--source`, then retry. |
| `write_claim_lost` | `write_claim_lost` | Another execution took over this request while it ran; that execution owns the outcome. | Poll `gbrain write-request <id>`; do not resubmit under a new ID. |
-| `request_too_large` | `request_too_large` | The request is larger than the configured request or recovery capacity. | Split the write, or raise the limit the message names on the brain host. |
+| `request_too_large` | `request_too_large` | The request is larger than the configured request or recovery capacity. | The message names the limit. Send a `put_pages` batch as smaller batches, or raise that limit on the brain host. A page under the 24 MiB page limit is never split: a transport that cannot carry it is bypassed by writing the file into the source and running `gbrain sync`, or by `gbrain import <file>` on the brain host ([limits per entry point](memory-boundaries.md#large-page-limits)). |
| `response_too_large` | `response_too_large` | The persistence response exceeded the local transport limit. The write may still have committed. | Poll `gbrain write-request <id>` before retrying. |
| `writer_registration_required` | `writer_registration_required` | The source needs an active canonical owner before this operation, for example activation. | Claim the source on its owner host (`gbrain sources writer status <source>` names the next step). |
| `writer_identity_invalid` | `writer_identity_invalid` | This host's local writer identity file is unreadable or has an unknown format. | Run `gbrain doctor` on the host; it names the identity file to repair. |
@@ -164,7 +164,7 @@ with each file and fix the ones that need no guessing."*
| <a id="invalid_frontmatter-ambiguous_identity_key"></a>`invalid_frontmatter` (`ambiguous_identity_key`) | `slug`, `type`, `id` or `source_id` appears twice, or its line was swallowed into another value, so gbrain cannot tell which page the file is. | Edit the file by hand: keep exactly one line for the key. The user decides which value is right. |
| <a id="invalid_frontmatter-ambiguous_protected_key"></a>`invalid_frontmatter` (`ambiguous_protected_key`) | A key that decides access or provenance (`visibility`, `derived_from`, …) is malformed, duplicated, swallowed into another value, rewritten by quoting, or inside an unclosed fence. gbrain never reads such a key as a broader value. | Edit the file by hand: write the key on one line with one quoted value. Ask the user which visibility is intended; never guess it. |
| <a id="frontmatter_slug_conflict"></a>`frontmatter_slug_conflict` | The file's frontmatter `slug:` names a different page than its path does (earlier releases reported this as `invalid_params`). The path decides the slug. The hold has three outcomes once the content-repair lane's `slug-conflicts` kind runs it (the maintenance run's `content_repair` phase, `gbrain sync unblock --apply`, or `gbrain repair content --source <source>`): **removed** (the named slug resolves to no page and names no other file, or to a page of a different type sharing no title token: the stray `slug:` line is removed, the file imported and committed, the hold cleared, with a receipt; a model under the `fences.repair` caps makes the same call when the two pages are not obviously different), **merge recommended** ([`merge_recommended`](#merge_recommended): the two files describe the same thing; gbrain recommends the merge and names the canonical page but never merges pages by itself), or **undecided** ([`content_repair_needs_human`](#content_repair_needs_human)). Until that kind ships, the lane leaves the hold to the frontmatter repair preview below. | Nothing to run when the lane removes the line: the hold clears on the sync it prints. For a recommendation or an undecided hold, `gbrain sync status --source <source> --json` carries the paragraph (`human_reason`): merge the unique sections into the canonical page by hand or decide which page keeps the slug, delete or edit the file, commit, then `gbrain sync --source <source> --no-pull`. By hand at any time: remove the `slug:` line or make it match the path, or move the file to the path its slug names (`gbrain repair frontmatter --source <source> --include-ambiguous` proposes removing the line, for approval). |
-| <a id="file_too_large"></a>`file_too_large` | Over the import size limit (5 MB for Markdown and code, 10 MiB for any sync read). The limit is fixed. | Split the file into smaller files and commit, or leave it out of the source: read `gbrain config get sync.exclude`, then `gbrain config set sync.exclude '<current list>,<path>'`. The next `gbrain sync --source <source> --no-pull` clears the hold. |
+| <a id="file_too_large"></a>`file_too_large` | Over the page size limit: 24 MiB for a Markdown page, 5 MB for a code file ([limits per entry point](memory-boundaries.md#large-page-limits)). Every page under the limit is stored, chunked and searchable whatever its size, so this hold only fires above it, and the same bytes are held on every retry. A smaller page refused by an MCP or HTTP transport limit is a different refusal: send it by file. | Leave the file out of the source: read `gbrain config get sync.exclude`, then `gbrain config set sync.exclude '<current list>,<path>'`; or, if it must be in the brain, split it into files under the limit and commit. The next `gbrain sync --source <source> --no-pull` clears the hold. |
| <a id="managed_image_sync_unsupported"></a>`managed_image_sync_unsupported` | Managed sync imports image files only while multimodal embedding is on (`GBRAIN_EMBEDDING_MULTIMODAL=true`): the image page, its OCR text and its image vector are built by the coordinated image importer at preparation, and `source_path` is recorded. While multimodal embedding is off, each image import is held with this code instead of refusing the whole sync (#5493); deleting or renaming an image still reconciles its page. These holds count as missing coverage (the image is not searchable) but never escalate, because they are not a content fault. | Nothing is broken. To import the images, set `GBRAIN_EMBEDDING_MULTIMODAL=true` on the owner and run `gbrain sync --source <source> --no-pull`: the next discovery re-screens every image hold and imports the files (#6529). To stop holding them instead, leave them out of the source (`gbrain config get sync.exclude`, then `gbrain config set sync.exclude '<current list>,**/*.png'`); that clears the holds on the next sync. A held image is also re-screened when it changes and on `gbrain sources retry-held <source>`. |
| <a id="content_rejected"></a>`content_rejected` | The content-sanity gate matched junk and the operator set `content_sanity.junk_disposition` to `reject`, so the file is never imported and always visible. | Remove the matched junk from the file, or ask the user whether `junk_disposition` should go back to `quarantine`; that setting is the user's decision. |
| <a id="purged_content"></a>`purged_content` | The file (or written content) has the content hash of a page the owner purged with `gbrain delete <slug> --purge`, under any slug, or carries a purged claim the database refuses. Purge leaves a text-free tombstone so a stale file, re-sync or revert cannot bring the content back. | Delete or edit the file and commit; an edited file imports normally. Only if the purge was a mistake, the owner lists tombstones with `gbrain pages purges list` and clears one with `gbrain pages unpurge <slug>` on the brain host. See [expire versus purge](memory-boundaries.md#purge). |
diff --git a/llms-full.txt b/llms-full.txt
index 76e8e927c0..14728888b2 100644
--- a/llms-full.txt
+++ b/llms-full.txt
@@ -427,9 +427,13 @@ put_pages with one request_id per batch and wait_ms 25000."*
`gbrain config set mcp.remote_auto_links false`.
- **Embedding** runs after the commit. New text is searchable by keyword
immediately and by meaning once its embedding effect finishes.
-- **Request size.** `gbrain serve --http` reads the whole request; the
- simpler HTTP transport caps a request at `GBRAIN_HTTP_MAX_BODY_BYTES`
- (1 MiB by default) and its 413 reply tells the agent to split the batch.
+- **Request size.** HTTP carries less than the 24 MiB page ceiling:
+ `gbrain serve --http` reads at most 4 MiB per request (the MCP SDK
+ default), and the simpler HTTP transport caps a request at
+ `GBRAIN_HTTP_MAX_BODY_BYTES`. A batch goes in smaller `put_pages` calls; a
+ page over the transport limit goes by file on the brain host (sync,
+ `gbrain import` or `gbrain put`), never split by hand. Every limit is in
+ [limits per entry point](memory-boundaries.md#large-page-limits).
## PGLite brains
@@ -10213,6 +10217,7 @@ Source: https://raw.githubusercontent.com/garrytan/gbrain/master/docs/guides/tro
| `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 |
| [`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) | find the cause: `gbrain reindex --oversized --dry-run --json` lists pages stored before the upgrade with a size-based `embed_skip` marker (run it without `--dry-run` to keyword-index them, free); a page above an operator-lowered `content_sanity.bytes_block` keeps its marker until the operator raises or unsets it; a page the content-quality gate quarantined as junk shows in `gbrain quarantine list`, and `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)). Embedding the re-indexed pages is a separate paid step: `gbrain embed --held --max-usd <N>` | agent for the reindex; the user decides embedding spend, a `bytes_block` change and a quarantine clear | none for the reindex (CPU only); `paid` for `gbrain embed` | `gbrain reindex --oversized --dry-run --json` lists nothing; `gbrain doctor --json`; `gbrain search "<phrase from deep in the page>"` returns the page |
| [Search answers look keyword-only on a large Postgres brain](#hybrid-search-returns-only-keyword-hits) | read doctor's `vector_plan`; run the index command it prints | brain host | none | `gbrain doctor --only vector_plan --json` |
| [Broad keyword queries take about 8 s and come back vector-only (`keyword_arm_failed`) on a large Postgres brain](#keyword-search-times-out-on-a-large-postgres-brain) | read doctor's `keyword_plan`; narrow with `--source-id`, or raise `search.keyword_statement_timeout_ms` on the brain host and restart the serving process | brain host | none | `gbrain doctor --only keyword_plan --json` |
| A second `gbrain serve` cannot open the brain | the readiness `harness_wiring` fix: every session shares one `gbrain serve --http` | user | `persistent_install`, `credentials` | `gbrain doctor --only harness_wiring --json` |
diff --git a/plugin-variants/gbrain-daily/skills/conversation-archive/SKILL.md b/plugin-variants/gbrain-daily/skills/conversation-archive/SKILL.md
index 89e46e59ea..5476186628 100644
--- a/plugin-variants/gbrain-daily/skills/conversation-archive/SKILL.md
+++ b/plugin-variants/gbrain-daily/skills/conversation-archive/SKILL.md
@@ -113,6 +113,14 @@ One page per conversation. Date-prefixed slugs make origin tracing sortable
and feed the recency ranking; the frontmatter `date:` drives the page's
`effective_date` (used by `--since`/`--until` filters).
+**Don't split a conversation for size.** One page per conversation is fine up
+to the 24 MiB page ceiling: it is chunked and keyword-searchable at any size
+under it, and a page over 1 MiB embeds after the write. Don't write `-p2`,
+`-p3` part pages to get under a size limit. Only a conversation over 24 MiB
+needs more than one page. If an MCP transport refuses a large page, import the
+file on the brain host instead (Step 4). Limits and costs:
+`docs/guides/memory-boundaries.md#large-pages`.
+
**Slug collisions are real — disambiguate deterministically.** Untitled threads
share a title ("New chat"), and several conversations can land on the same day,
so `YYYY-MM-DD-new-chat` collides across threads. `put_page` has no
diff --git a/plugin/skills/conversation-archive/SKILL.md b/plugin/skills/conversation-archive/SKILL.md
index 89e46e59ea..5476186628 100644
--- a/plugin/skills/conversation-archive/SKILL.md
+++ b/plugin/skills/conversation-archive/SKILL.md
@@ -113,6 +113,14 @@ One page per conversation. Date-prefixed slugs make origin tracing sortable
and feed the recency ranking; the frontmatter `date:` drives the page's
`effective_date` (used by `--since`/`--until` filters).
+**Don't split a conversation for size.** One page per conversation is fine up
+to the 24 MiB page ceiling: it is chunked and keyword-searchable at any size
+under it, and a page over 1 MiB embeds after the write. Don't write `-p2`,
+`-p3` part pages to get under a size limit. Only a conversation over 24 MiB
+needs more than one page. If an MCP transport refuses a large page, import the
+file on the brain host instead (Step 4). Limits and costs:
+`docs/guides/memory-boundaries.md#large-pages`.
+
**Slug collisions are real — disambiguate deterministically.** Untitled threads
share a title ("New chat"), and several conversations can land on the same day,
so `YYYY-MM-DD-new-chat` collides across threads. `put_page` has no
diff --git a/plugin/skills/frontmatter-guard/SKILL.md b/plugin/skills/frontmatter-guard/SKILL.md
index 68d5e52b48..34220e5317 100644
--- a/plugin/skills/frontmatter-guard/SKILL.md
+++ b/plugin/skills/frontmatter-guard/SKILL.md
@@ -71,7 +71,7 @@ Each hold record carries `code`, `reason`, `key`, `line`, `message` (location on
| `invalid_frontmatter` / `needs_interpretation` | Preview with `--include-ambiguous`, show the user each per-file diff, apply only what they approve. |
| `invalid_frontmatter` / `ambiguous_identity_key` or `ambiguous_protected_key` | Never guess. Show the user the line; they decide the one value (`visibility` decides who can read the page). |
| `frontmatter_slug_conflict` | Remove the `slug:` line or move the file; the repair proposes removing it under `--include-ambiguous`. |
-| `file_too_large` | Split the file or add it to `sync.exclude`; the limit is fixed. |
+| `file_too_large` | The file is over the fixed page limit (24 MiB for Markdown, 5 MB for code); every page under it is searchable, so never split one that fits. Ask the user to add it to `sync.exclude`, or to split it into files under the limit. A smaller page an MCP transport refused goes by file instead (`docs/guides/memory-boundaries.md#large-page-limits`). |
| `content_rejected` | The user chose `content_sanity.junk_disposition=reject`; ask before changing it. |
The fix flow (walkthrough with real output: `docs/guides/repair.md#held-files`):
diff --git a/skills/conversation-archive/SKILL.md b/skills/conversation-archive/SKILL.md
index 50741f5d63..1456df6404 100644
--- a/skills/conversation-archive/SKILL.md
+++ b/skills/conversation-archive/SKILL.md
@@ -112,6 +112,14 @@ One page per conversation. Date-prefixed slugs make origin tracing sortable
and feed the recency ranking; the frontmatter `date:` drives the page's
`effective_date` (used by `--since`/`--until` filters).
+**Don't split a conversation for size.** One page per conversation is fine up
+to the 24 MiB page ceiling: it is chunked and keyword-searchable at any size
+under it, and a page over 1 MiB embeds after the write. Don't write `-p2`,
+`-p3` part pages to get under a size limit. Only a conversation over 24 MiB
+needs more than one page. If an MCP transport refuses a large page, import the
+file on the brain host instead (Step 4). Limits and costs:
+`docs/guides/memory-boundaries.md#large-pages`.
+
**Slug collisions are real — disambiguate deterministically.** Untitled threads
share a title ("New chat"), and several conversations can land on the same day,
so `YYYY-MM-DD-new-chat` collides across threads. `put_page` has no
diff --git a/skills/frontmatter-guard/SKILL.md b/skills/frontmatter-guard/SKILL.md
index f5277c35d8..829ab2262a 100644
--- a/skills/frontmatter-guard/SKILL.md
+++ b/skills/frontmatter-guard/SKILL.md
@@ -70,7 +70,7 @@ Each hold record carries `code`, `reason`, `key`, `line`, `message` (location on
| `invalid_frontmatter` / `needs_interpretation` | Preview with `--include-ambiguous`, show the user each per-file diff, apply only what they approve. |
| `invalid_frontmatter` / `ambiguous_identity_key` or `ambiguous_protected_key` | Never guess. Show the user the line; they decide the one value (`visibility` decides who can read the page). |
| `frontmatter_slug_conflict` | Remove the `slug:` line or move the file; the repair proposes removing it under `--include-ambiguous`. |
-| `file_too_large` | Split the file or add it to `sync.exclude`; the limit is fixed. |
+| `file_too_large` | The file is over the fixed page limit (24 MiB for Markdown, 5 MB for code); every page under it is searchable, so never split one that fits. Ask the user to add it to `sync.exclude`, or to split it into files under the limit. A smaller page an MCP transport refused goes by file instead (`docs/guides/memory-boundaries.md#large-page-limits`). |
| `content_rejected` | The user chose `content_sanity.junk_disposition=reject`; ask before changing it. |
The fix flow (walkthrough with real output: `docs/guides/repair.md#held-files`):
diff --git a/skills/skills.lock.json b/skills/skills.lock.json
index 5844e7ec64..bf4ce37584 100644
--- a/skills/skills.lock.json
+++ b/skills/skills.lock.json
@@ -62,7 +62,7 @@
"conventions/subagent-routing.md": "8b8830b815a9a8581a12b489f966c0b0a39eb9b5f66e905a691a03653eef348d",
"conventions/test-before-bulk.md": "6b2c52cda9e2cd5f04c15152b3d92aeb7187ab193a15082be0f8a3991a6a5725",
"conventions/untrusted-content.md": "259384d490892cd0e1e8e054decf752d7354f516c83aee57b332c1a96aac6a6e",
- "conversation-archive/SKILL.md": "a59d3dc7076871b8605b5be0cd48fb0b7ae5c0d97bc65447233d2addc2680ac4",
+ "conversation-archive/SKILL.md": "ebea1a74ef2a5557666b0fdab39720d5699eb4309acd5cd31b37182279d48fb4",
"conversation-archive/routing-eval.jsonl": "ae087a84b1fd5b108b7cdab8d035a09b3ccecd8aad53ba5f71e463059108cfca",
"correction-pipeline/SKILL.md": "c19869aa60ac00e15fc97ca016dd84dd63338fdf3d7b39990b33900eb7dcc703",
"correction-pipeline/routing-eval.jsonl": "7f8d96606a8d7bed3d79fdcee6904764c8abb9fa0b506adb414b5c4805b69d0b",
@@ -83,7 +83,7 @@
"enrich/SKILL.md": "cbe6068373f4cd5006a6171a1795c3e619cfc82009ec4b3d86174b8ee2bcee2e",
"fact-check/SKILL.md": "49f0d356eee44541eddbc9cd501dc36707d417d84ca10446c0d315321f259674",
"fact-check/routing-eval.jsonl": "7519c6eada244813264b0df34ed67613e2d4404cfdf3cb209051b461749f5662",
- "frontmatter-guard/SKILL.md": "1ade7903bba96faab03acc21db0ea15507256ed3bf81153e60526ff63aa26665",
+ "frontmatter-guard/SKILL.md": "5d8dd7aac288063b10b586879d33cbc5ff7794f7841deac9c5bab25f7b4a10ce",
"frontmatter-guard/routing-eval.jsonl": "243c28b04b557bac5360318c0f47bb6f1dd56d2f720aad3763b93fc0b2ea081e",
"functional-area-resolver/SKILL.md": "fe6e35fbb34dffec7af9ce4a6cc9c0b0eaa8345f97f33262a2abe0983431b421",
"functional-area-resolver/routing-eval.jsonl": "f80674d915acdfe229046737a5b171da834be15ac6524b5a3fd18048e9b37028",
diff --git a/src/core/error-registry.ts b/src/core/error-registry.ts
index 68ecadaa30..1b9d2949e8 100644
--- a/src/core/error-registry.ts
+++ b/src/core/error-registry.ts
@@ -197,7 +197,7 @@ export const CODES = {
fetch_failed: { class: 'retryable', summary: "Fetching the upstream failed." },
fix_not_writable: { class: 'host_only', summary: "A gbrain lint fix was not applied because the file refused the write (EACCES, EPERM or EROFS); the file was left unchanged.", why: "Lint repairs files in place, and this file's permissions or a read-only mount stopped the write; lint reports it and continues with the remaining files.", docs: 'docs/guides/repair.md#fix-not-writable', suggestion: "Make the file writable by the user running gbrain, or pass its directory or file name to gbrain lint --exclude, then lint again." },
file_removed_during_scan: { class: 'retryable', summary: "A file lint listed was removed before lint read it, so it was not linted.", why: "Another process deleted or renamed the file during the run; lint reports it and continues with the remaining files.", docs: 'docs/guides/repair.md#file-removed-during-scan', suggestion: "Re-run gbrain lint on the same target; it lints the files present now." },
- file_too_large: { class: 'caller', summary: "The file is over the import size limit (5 MB for Markdown and code, 10 MiB for any sync read), so it was not imported.", why: "Size limits bound parsing, chunking and embedding cost. The same bytes refuse on every retry.", suggestion: 'Split the file into smaller files, or leave it out of the source (sync.exclude), then sync or import again.' },
+ file_too_large: { class: 'caller', summary: "The file is over the page size limit (24 MiB for a Markdown page, 5 MB for a code file), so it was not imported.", why: "Every page under the limit is stored, chunked and searchable whatever its size; the limit bounds what one page may hold in this release. The same bytes refuse on every retry. A smaller page refused by an MCP or HTTP transport is a different refusal.", docs: 'docs/guides/write-refusals.md#file_too_large', suggestion: 'Leave the file out of the source (sync.exclude), or, if it must be in the brain, split it into files under the limit; then sync or import again. Never split a page under the limit.' },
follow_approval_required: { class: 'caller', summary: "Following a brain's shared skills needs the user's explicit follow approval.", docs: 'docs/guides/shared-brain-skills.md#approve-publication-following-and-editing-separately' },
forget_requires_owner: { class: 'consent', exit: 3, actor: 'user', summary: "A remote caller asked to forget a fact more trusted than its own writes, so nothing was forgotten and the owner was asked instead.", why: "Lower-trust writers cannot overwrite, supersede or forget what the owner confirmed or curated (#5575 guarded supersession). The request became a trust proposal the owner can accept on the brain host; forget's frozen expired meaning is unchanged because nothing expired.", docs: 'docs/guides/error-codes.md#forget_requires_owner', suggestion: 'Do not retry. Tell the user the fact needs their decision and give them the command in fix (gbrain trust confirm <proposal_ref> on the brain host).' },
frontmatter_slug_conflict: { class: 'caller', summary: "The file's frontmatter `slug:` names a different page than its path does.", why: "The path decides a file's page; a conflicting declared slug would overwrite or fork another page, so the file is refused until one of them changes.", suggestion: 'Remove the `slug:` line or make it match the path, then commit and sync again.' },
diff --git a/src/core/import-screen.ts b/src/core/import-screen.ts
index e14be2e2f6..36b18414a8 100644
--- a/src/core/import-screen.ts
+++ b/src/core/import-screen.ts
@@ -234,7 +234,7 @@ export async function settleContentDisposition(engine: BrainEngine, parsed: Pars
disposition: 'warn',
});
process.stderr.write(
- `[gbrain] content-sanity warn: ${slug} (${sanityResult.bytes} bytes) — exceeds warn threshold, consider splitting\n`,
+ `[gbrain] content-sanity warn: ${slug} (${sanityResult.bytes} bytes) — exceeds warn threshold; stored and searchable, no action needed\n`,
);
}
const gate = ctx.writeGate ? await applyTrustAllowRules(engine, assessPageForGate(parsed, ctx.writeGate, sanityCfg.writeGate ?? DEFAULT_WRITE_GATE_CONFIG),
@@ -428,6 +428,9 @@ export function screenImportContent(input: ImportScreenInput): ImportScreenResul
return { status: 'importable', parsed, ...(fences ? { fences } : {}) };
}
+/** The next step of a page write over the page limit; a page under it never needs splitting. */
+export const PAGE_OVER_LIMIT_SUGGESTION = `The content is over the ${MAX_FILE_SIZE}-byte page limit, so it refuses on every retry. Every page under the limit is stored and searchable; only content over it must become several pages, each submitted with its own request_id.`;
+
/**
* The typed refusal a publication path throws. `legacy_error` keeps the wire
* `error` the site always returned, so stored receipts keep matching
@@ -471,7 +474,7 @@ export function contentRefusalFromReceipt(code: string | null | undefined, messa
: typed === 'content_rejected' ? 'The content-sanity gate rejects this content under the operator\'s junk_disposition=reject setting. Remove the matched junk, then submit with a new request_id.'
: typed === 'purged_content' ? 'This content was purged by the owner and stays out of the brain. Do not resubmit it; write new content, or ask the user to clear the tombstone on the brain host (gbrain pages unpurge).'
: typed === 'write_gate_rejected' ? 'The write gate refuses this external instruction-like content under the operator\'s write_gate.external_mode=reject setting, so it refuses on every retry. Tell the user; changing that setting is their decision.'
- : 'The content is over the import size limit. Split it into smaller pages, then submit each with its own request_id.';
+ : PAGE_OVER_LIMIT_SUGGESTION;
return { code: typed, ...(reason ? { reason } : {}), ...(key ? { key } : {}), ...(line !== undefined ? { line } : {}), suggestion };
}
diff --git a/src/core/interaction.ts b/src/core/interaction.ts
index 02ea35aea9..73c8f10fe7 100644
--- a/src/core/interaction.ts
+++ b/src/core/interaction.ts
@@ -203,7 +203,7 @@ function firstByteDeadlineMs(explicit: number | undefined): number {
}
const tooLarge = (maxBytes: number, bytes: number): StdinRead =>
- ({ kind: 'error', error: new Error(`stdin exceeds ${maxBytes} bytes; split the input into smaller pieces`), bytes });
+ ({ kind: 'error', error: new Error(`stdin exceeds ${maxBytes} bytes, the most this command reads from stdin; nothing was read`), bytes });
/**
* fd 0 as a regular file or a non-TTY character device (`< file`, `< /dev/null`)
diff --git a/src/core/markdown.ts b/src/core/markdown.ts
index da15cd3617..17827e12aa 100644
--- a/src/core/markdown.ts
+++ b/src/core/markdown.ts
@@ -477,7 +477,7 @@ export interface ContentHold {
export function contentSizeHold(byteLength: number, maxBytes: number, codeFile = false): ContentHold | null {
if (byteLength <= maxBytes) return null;
return { code: 'file_too_large', message: codeFile ? `Code file too large (${byteLength} bytes)`
- : `Content too large (${byteLength} bytes, max ${maxBytes}). Split the content into smaller files or remove large embedded assets.` };
+ : `Content too large (${byteLength} bytes, max ${maxBytes}). Every page under that limit is stored and searchable; leave this file out of the source, or split it into files under the limit.` };
}
const HOLD_GUIDANCE: Record<InvalidFrontmatterReason, string> = {
diff --git a/src/core/persistence/import-prepare.ts b/src/core/persistence/import-prepare.ts
index 0efb1d98e1..e2995b6b54 100644
--- a/src/core/persistence/import-prepare.ts
+++ b/src/core/persistence/import-prepare.ts
@@ -53,7 +53,7 @@ export function readImportBytes(path: string): Buffer {
}
const maxBytes = isImageFilePath(path) ? MAX_IMAGE_BYTES : MAX_FILE_SIZE;
if (lstatSync(path).size > maxBytes) throw opError('invalid_params', `File too large (max ${maxBytes} bytes).`,
- `${basename(path)} is over the ${maxBytes}-byte import limit and was not imported. Split it into smaller files or leave it out of the import.`);
+ `${basename(path)} is over the ${maxBytes}-byte import limit and was not imported. Files under the limit import normally; leave this one out of the import, or split it into files under the limit.`);
return readFileSync(path);
}
@@ -63,7 +63,7 @@ function managedImportRefusal(refusal: ContentRefusal, sourcePath: string): Oper
? `Edit ${fenceWhere(refusal.fence)} in ${sourcePath} as the message says (the rest of the page is fine), then import it again.`
: refusal.code === 'frontmatter_slug_conflict'
? `In ${sourcePath}, remove the frontmatter slug or set it to the path-derived slug (the path decides the slug), or move the file to the path that matches its slug, then import again.`
- : refusal.code === 'file_too_large' ? `${sourcePath} is over the import size limit and was not imported. Split it into smaller files or leave it out of the import.`
+ : refusal.code === 'file_too_large' ? `${sourcePath} is over the size limit the message names and was not imported. Every page under the limit imports and is searchable; leave this file out of the import, or split it into files under the limit.`
: refusal.code === 'content_rejected' ? `Remove the matched junk from ${sourcePath}, then import it again.`
: refusal.code === 'write_gate_rejected' ? `The write gate refuses ${sourcePath} (external instruction-like content under write_gate.external_mode=reject); tell the user, the decision is theirs.`
: `Fix line ${refusal.line ?? '?'} of ${sourcePath}${refusal.key ? ` (key "${refusal.key}")` : ''}: one line per key with its whole value quoted. Run gbrain frontmatter validate on the file to see every problem, then import it again.`;
diff --git a/src/core/persistence/page-prepare.ts b/src/core/persistence/page-prepare.ts
index 7b0a07762d..15e8ab80a5 100644
--- a/src/core/persistence/page-prepare.ts
+++ b/src/core/persistence/page-prepare.ts
@@ -17,7 +17,7 @@ import { isOpPageSlug } from '../ops/context.ts';
import { shellQuote, type Action } from '../agent-output.ts';
import type { RegistryCode } from '../error-registry.ts';
import { pageIdentityError } from './page-identity.ts';
-import { contentRefusalError } from '../import-screen.ts';
+import { contentRefusalError, PAGE_OVER_LIMIT_SUGGESTION } from '../import-screen.ts';
import { ContentSanityBlockError } from '../content-sanity.ts';
import { assertPageRevision, type PageSnapshot } from '../page-state/types.ts';
import { gitHoldFix, readGitHold } from './sync-holds.ts';
@@ -526,7 +526,7 @@ export async function preparePageMutation(unbounded: BrainEngine, row: WriteRequ
// A remote caller's refusal names the line, never a key: keys can be private, and the receipt keeps the message.
const refusal = result.refusal && row.authority.remote && result.refusal.code === 'invalid_frontmatter'
? { ...result.refusal, key: undefined, message: frontmatterHoldMessageWithoutKeys(result.refusal.message) } : result.refusal;
- if (refusal?.code === 'file_too_large') throw contentRefusalError(refusal, 'Split the content into smaller pages, then submit each with its own request_id.', { legacy_error: 'request_too_large' });
+ if (refusal?.code === 'file_too_large') throw contentRefusalError(refusal, PAGE_OVER_LIMIT_SUGGESTION, { legacy_error: 'request_too_large' });
if (refusal?.code === 'invalid_fence') throw contentRefusalError(refusal, `Page ${row.slug} was not written. Fix ${fenceWhere(refusal.fence)} as the message says (fence_issues lists every row and column; use the allowed values), `
+ 'or write facts with remember and takes with takes_add instead of a hand-built table, then submit the corrected content with a new request_id.', { legacy_error: 'invalid_params' });
if (refusal) throw contentRefusalError(refusal, `Correct ${refusal.line !== undefined ? `frontmatter line ${refusal.line}${refusal.key ? ` (key "${refusal.key}")` : ''}` : 'the frontmatter'}: one line per key with its whole value quoted, then submit the corrected content with a new request_id.`,
diff --git a/src/core/persistence/sync-fault-class.ts b/src/core/persistence/sync-fault-class.ts
index b632d79583..1fe274e3db 100644
--- a/src/core/persistence/sync-fault-class.ts
+++ b/src/core/persistence/sync-fault-class.ts
@@ -54,7 +54,7 @@ export const SYNC_FAULT_TABLE: ReadonlyArray<SyncFaultRule> = [
{ code: 'invalid_frontmatter', class: 'page', safe_actions: ['repair'], needs_human: false, escalate: 'the repair preview needs an interpretation (--include-ambiguous)', human_reason: 'Approve the proposed frontmatter fix or edit the file.' },
{ code: 'frontmatter_slug_conflict', class: 'page', safe_actions: ['repair'], needs_human: false, escalate: 'the repair preview needs an interpretation', human_reason: 'Decide which page keeps the slug.' },
{ code: 'rename_held', class: 'page', safe_actions: ['repair'], needs_human: false, escalate: 'the repair preview needs an interpretation', human_reason: 'Approve re-binding the rename to the current page.' },
- { code: 'file_too_large', class: 'page', safe_actions: ['none'], needs_human: true, escalate: 'always', human_reason: 'Split the file or exclude it with sync.exclude.' },
+ { code: 'file_too_large', class: 'page', safe_actions: ['none'], needs_human: true, escalate: 'always', human_reason: 'The file is over the page size limit; exclude it with sync.exclude, or split it into files under the limit.' },
{ code: 'content_rejected', class: 'page', safe_actions: ['none'], needs_human: true, escalate: 'always', human_reason: 'The content-sanity gate rejected the file; remove the junk or change junk_disposition.' },
{ code: 'parser_regression', class: 'page', safe_actions: ['upgrade'], needs_human: true, escalate: 'always: a gbrain bug', human_reason: 'Report the file and gbrain version, then upgrade or pin the last good release.' },
{ code: 'managed_image_sync_unsupported', class: 'page', safe_actions: ['none'], needs_human: false, escalate: 'never: images stay held while multimodal embedding is off', human_reason: 'Leave images held, exclude them with sync.exclude, or set GBRAIN_EMBEDDING_MULTIMODAL=true so the next sync imports them.' },
diff --git a/src/core/persistence/sync-holds.ts b/src/core/persistence/sync-holds.ts
index 93c6a9e54e..2f4ddaf0ae 100644
--- a/src/core/persistence/sync-holds.ts
+++ b/src/core/persistence/sync-holds.ts
@@ -517,7 +517,7 @@ export function gitHoldFix(record: Pick<GitHoldRecord, 'source_id' | 'path' | 'c
}
case 'file_too_large':
return { argv: ['gbrain', 'config', 'get', 'sync.exclude'], consent: [], actor: 'agent', requires_exclusive: false,
- why: `The size limit is fixed. Split ${record.path} into smaller files and commit, or leave it out of the source: read the current sync.exclude list, then run gbrain config set sync.exclude '<current list>,${record.path}'. The next gbrain sync --source ${source} --no-pull clears the hold.`,
+ why: `${record.path} is over the page size limit. The size limit is fixed, and every page under it syncs and is searchable. Leave the file out of the source: read the current sync.exclude list, then run gbrain config set sync.exclude '<current list>,${record.path}'; or, if it must be in the brain, split it into files under the limit and commit. The next gbrain sync --source ${source} --no-pull clears the hold.`,
verify: { argv: ['gbrain', 'sources', 'status', source, '--json'] } };
case 'purged_content':
return { argv: ['gbrain', 'pages', 'purges', 'list', '--source', source], consent: [], actor: 'user', requires_exclusive: false,
diff --git a/src/core/persistence/sync-prepare.ts b/src/core/persistence/sync-prepare.ts
index 38dba7b70b..4205dea3ef 100644
--- a/src/core/persistence/sync-prepare.ts
+++ b/src/core/persistence/sync-prepare.ts
@@ -218,7 +218,7 @@ function syncContentRefusal(refusal: ContentRefusal, row: WriteRequest, p: SyncI
const where = refusal.line !== undefined ? `line ${refusal.line}${refusal.key ? ` (key "${refusal.key}")` : ''} of ${p.sourcePath}` : p.sourcePath;
const cause = refusal.code === 'invalid_fence' ? `Edit ${fenceWhere(refusal.fence)} in ${p.sourcePath} as the message says and commit the change${p.companyApproval ? ' to the repository (a company-brain source never rewrites repository files and never holds a file)' : ''}.`
: refusal.code === 'frontmatter_slug_conflict' ? 'Correct the frontmatter `slug:` in the file and commit the change.'
- : refusal.code === 'file_too_large' ? `${p.sourcePath} is over the import size limit; split it into smaller files or add it to sync.exclude, then commit.`
+ : refusal.code === 'file_too_large' ? `${p.sourcePath} is over the page size limit; add it to sync.exclude, or split it into files under the limit and commit.`
: refusal.code === 'content_rejected' ? `The content-sanity gate rejects ${p.sourcePath} under junk_disposition=reject; remove the matched junk and commit.`
: refusal.code === 'purged_content' ? `${p.sourcePath} still carries purged content; delete or edit the file and commit, or the owner clears the tombstone with gbrain pages unpurge.`
: refusal.code === 'write_gate_rejected' ? `The write gate refuses ${p.sourcePath}: external instruction-like content under write_gate.external_mode=reject. Tell the user; changing that setting or the file is their decision.`
diff --git a/src/core/persistence/sync-screen.ts b/src/core/persistence/sync-screen.ts
index 0961b17cbd..a5baed76dc 100644
--- a/src/core/persistence/sync-screen.ts
+++ b/src/core/persistence/sync-screen.ts
@@ -177,7 +177,7 @@ export function managedImageHold(entry: Pick<SyncEntry, 'path' | 'sourcePath' |
/** #5988: the hold of a file over the sync read bound, whose content is never read (#6529: shared with the image freeze). */
export function oversizeHold(entry: Pick<SyncEntry, 'path' | 'sourcePath' | 'working' | 'renameFrom' | 'renameHeld'>, slug: string, pageId: number | null, size: number | null, blob: TreeBlob | null | undefined): HeldEntry {
return heldEntry(entry, slug, pageId, { code: 'file_too_large',
- message: `File too large (${size ?? 'over 10485760'} bytes; the sync read bound is ${SYNC_READ_BOUND} bytes). Split the content into smaller files or leave it out of the source.` }, null, blob);
+ message: `File too large (${size ?? `over ${SYNC_READ_BOUND}`} bytes; the sync read bound is ${SYNC_READ_BOUND} bytes). Leave it out of the source, or split it into files under the bound.` }, null, blob);
}
const purgeTombstonesByRun = new WeakMap<SyncScreenRun, Promise<Map<string, string>>>();
diff --git a/src/core/persistence/verb-errors.ts b/src/core/persistence/verb-errors.ts
index b3a52b813c..4a59b857d0 100644
--- a/src/core/persistence/verb-errors.ts
+++ b/src/core/persistence/verb-errors.ts
@@ -29,7 +29,7 @@ export function heldFileDiagnostic(message: string | null | undefined, sourceId
// #6188 (D6): a fence hold routes to the fence repair, never to frontmatter repair.
const repair = held[1] === 'invalid_fence'
? `the maintenance run repairs most fence holds by itself; to repair it now, preview with gbrain repair fences --source ${sourceId} (read-only: it names the planned repair or the exact edit) and run the apply command it prints`
- : `frontmatter holds: preview the fix with gbrain repair frontmatter --source ${sourceId} and apply it; file_too_large: split the file`;
+ : `frontmatter holds: preview the fix with gbrain repair frontmatter --source ${sourceId} and apply it; file_too_large: the file is over the page size limit, so exclude it with sync.exclude or split it into files under the limit`;
return { reason: held[2] === 'and differs from the page' ? 'file_database_drift' : 'canonical_path_occupied', message: message!,
suggestion: `Sync holds this page's file because gbrain cannot import it; gbrain sources status ${sourceId} names the file${held[1] === 'invalid_fence' ? ', fence and reason' : ', line and key'}. `
+ 'The page keeps its last good revision and refuses put_page until the file is repaired, so retrying this write refuses the same way. '
diff --git a/src/core/repair/frontmatter.ts b/src/core/repair/frontmatter.ts
index f33c71b83f..7c8e891a4a 100644
--- a/src/core/repair/frontmatter.ts
+++ b/src/core/repair/frontmatter.ts
@@ -173,7 +173,7 @@ function resolution(hold: Pick<ContentRefusal, 'code' | 'reason' | 'key' | 'line
// #6188: frontmatter repair never rewrites a fence; the fence repair does.
case 'invalid_fence': return `${path}: ${fenceWhere(hold.fence)} is malformed (${hold.fence?.reason ?? hold.reason ?? 'invalid_fence'}), and frontmatter repair does not change fences. `
+ `Preview its repair with gbrain repair fences --source ${sourceId} --only ${path} (read-only; it names the exact edit when gbrain will not repair it).`;
- case 'file_too_large': return `Split ${path} into files under ${MAX_FILE_SIZE} bytes and commit, or leave it out of the source with sync.exclude.`;
+ case 'file_too_large': return `${path} is over the ${MAX_FILE_SIZE}-byte page limit, which no repair changes; every page under it imports and is searchable. Leave it out of the source with sync.exclude, or split it into files under the limit and commit.`;
case 'frontmatter_slug_conflict': return `Remove the slug: line of ${path} (the path decides the slug), or move the file to the path its slug names.`;
case 'content_rejected': return `Remove the junk the content-sanity gate matched in ${path}, or ask the user whether junk_disposition should stay reject.`;
case 'purged_content': return `${path} carries purged page content; delete or edit it and commit, or the owner clears the tombstone with gbrain pages unpurge.`;
diff --git a/src/mcp/http-transport.ts b/src/mcp/http-transport.ts
index 0057903ad0..2b5c616588 100644
--- a/src/mcp/http-transport.ts
+++ b/src/mcp/http-transport.ts
@@ -59,9 +59,9 @@ export { parseLegacyTokenScope } from '../core/legacy-token-scope.ts';
const DEFAULT_BODY_CAP = 1024 * 1024; // 1 MiB
-/** #6007: what an agent does after a 413: nothing was processed, so split the request. */
+/** #6007: what an agent does after a 413: nothing was processed; a batch goes smaller, a big page goes by file. */
function oversizeSuggestion(bodyCap: number): string {
- return `Nothing was processed. Send smaller requests: split put_pages into calls under ${bodyCap} bytes each (a new request_id per call). The host operator sets this limit with GBRAIN_HTTP_MAX_BODY_BYTES.`;
+ return `Nothing was processed: this transport reads at most ${bodyCap} bytes per request (GBRAIN_HTTP_MAX_BODY_BYTES on the brain host). Send put_pages as smaller batches, a new request_id per call. Do not split a page: one page over this limit goes by file instead, so ask the user to write it into the brain repository and run gbrain sync, or to run gbrain import <file> or gbrain put <slug> < file on the brain host.`;
}
function hashToken(token: string): string {
diff --git a/test/http-transport.test.ts b/test/http-transport.test.ts
index cda1f07136..45962dfcc8 100644
--- a/test/http-transport.test.ts
+++ b/test/http-transport.test.ts
@@ -577,6 +577,10 @@ describe('http-transport: body cap', () => {
body: big,
});
expect(r.status).toBe(413);
+ const body = await r.json() as { error: string; suggestion: string };
+ expect(body.error).toBe('payload_too_large');
+ expect(body.suggestion).toBe('Nothing was processed: this transport reads at most 100 bytes per request (GBRAIN_HTTP_MAX_BODY_BYTES on the brain host). Send put_pages as smaller batches, a new request_id per call. '
+ + 'Do not split a page: one page over this limit goes by file instead, so ask the user to write it into the brain repository and run gbrain sync, or to run gbrain import <file> or gbrain put <slug> < file on the brain host.');
} finally { srv.stop(); }
});
diff --git a/test/import-screen.test.ts b/test/import-screen.test.ts
index 8734bff7b3..5856dc5ca4 100644
--- a/test/import-screen.test.ts
+++ b/test/import-screen.test.ts
@@ -14,7 +14,7 @@ import { tmpdir } from 'node:os';
import { join } from 'node:path';
import type { BrainEngine } from '../src/core/engine.ts';
import { importFromContent, MAX_FILE_SIZE } from '../src/core/import-file.ts';
-import { isContentRefusal, screenImportContent, type ImportSanityConfig } from '../src/core/import-screen.ts';
+import { contentRefusalFromReceipt, isContentRefusal, screenImportContent, type ImportSanityConfig } from '../src/core/import-screen.ts';
import { managedImportContent, readImportBytes } from '../src/core/persistence/import-prepare.ts';
import { readSyncFile } from '../src/core/persistence/sync-discovery.ts';
import { frontmatterSlugConflictMessage } from '../src/core/persistence/verb-errors.ts';
@@ -110,6 +110,15 @@ describe('the screen and every publication path agree', () => {
const big = screenImportContent({ content: 'x', byteLength: MAX_FILE_SIZE + 1, path: 'src/a.ts' });
expect(big).toMatchObject({ status: 'refused', refusal: { code: 'file_too_large', message: `Code file too large (${MAX_FILE_SIZE + 1} bytes)` } });
});
+
+ // Large pages (A9): the refusal an agent reads must name the limit and say a page under it needs no splitting.
+ test('a Markdown page over the limit names the limit, and its next step splits only content over it', () => {
+ const big = screenImportContent({ content: doc('title: a'), byteLength: MAX_FILE_SIZE + 1, path: 'notes/page.md' });
+ expect(big).toMatchObject({ status: 'refused', refusal: { code: 'file_too_large',
+ message: `Content too large (${MAX_FILE_SIZE + 1} bytes, max ${MAX_FILE_SIZE}). Every page under that limit is stored and searchable; leave this file out of the source, or split it into files under the limit.` } });
+ expect(contentRefusalFromReceipt('file_too_large', `Content too large (${MAX_FILE_SIZE + 1} bytes, max ${MAX_FILE_SIZE}).`)).toEqual({ code: 'file_too_large',
+ suggestion: `The content is over the ${MAX_FILE_SIZE}-byte page limit, so it refuses on every retry. Every page under the limit is stored and searchable; only content over it must become several pages, each submitted with its own request_id.` });
+ });
});
describe('isContentRefusal', () => {