Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

large pages switch-on: turn pages.segmented_storage on by default

garrytan098220ab00aa
diff --git a/docs/ENGINES.md b/docs/ENGINES.md
index 6ba6b863c7..c6b8bd6721 100644
--- a/docs/ENGINES.md
+++ b/docs/ENGINES.md
@@ -425,7 +425,7 @@ and the fix is the read-only `gbrain migrate --to postgres --plan --json`.
| Cost | Free | Supabase Pro ($25/mo) |
| Concurrency | Single process | Connection pooling |
| Backups | Manual (file copy) | Managed by Supabase |
-| Largest page | 24 MiB; 128 MiB stored in segments with `pages.segmented_storage on` (`pages.max_bytes`) | 24 MiB; 256 MiB stored in segments with `pages.segmented_storage on` (`pages.max_bytes`) |
+| Largest page | 128 MiB, stored in segments (`pages.max_bytes`) | 256 MiB, stored in segments (`pages.max_bytes`) |
**The belief ledger lives only in the database.** `belief_events` and its side tables record what the brain had recorded, and when (`gbrain beliefs status`). Markdown carries only current state, so a rebuild from Markdown, `gbrain reinit-pglite` or a dropped database starts an empty history; back up the database itself. After restoring a Postgres (or PGLite) backup, replay the purges made after the backup was taken: until then content purged later is readable again, and `gbrain doctor --only belief_ledger_coverage` reports a restore whose purge replay was partial, unavailable or unverified. Graduation copies the ledger verbatim (equal event keys and digests); the legacy copier refuses a brain that has one.
diff --git a/docs/architecture/key-files/core-services-2-continued.md b/docs/architecture/key-files/core-services-2-continued.md
index cdd4ac3d51..f731d51c90 100644
--- a/docs/architecture/key-files/core-services-2-continued.md
+++ b/docs/architecture/key-files/core-services-2-continued.md
@@ -22,7 +22,7 @@ The page-state concurrency foundation under `src/core/page-state/` and the share
- `src/core/progressive-batch/` — shared ramp-up + cost-cap + verification primitive (trial 10 → ramp 100 → ramp 500 → full, with verification at each stage), with verifier+policy injection (callers describe HOW TO MEASURE SUCCESS, not WHEN TO WAIT FOR CTRL-C). Modules: `types.ts` (Stage, StageVerdict, AbortReason, discriminated `Verifier` union `OutputCountVerifier | IdempotentMutationVerifier | NoopVerifier`, Policy, StageReport), `orchestrator.ts` (`runProgressiveBatch(items, verifier, policy, runner)` — reads `getCurrentBudgetTracker()` ahead of `Policy.maxCostUsd` fail-closed; null both ways triggers `abort_cost_cap reason='no_budget_safety_net'`), `audit.ts` (ISO-week JSONL at `~/.gbrain/audit/progressive-batch-YYYY-Www.jsonl` via the shared `audit-writer` primitive), `stage-report.ts` (ASCII formatter for the default `Policy.onStageReport`). Env knobs: `GBRAIN_PROGRESSIVE_BATCH_DISABLED=1`, `GBRAIN_PROGRESSIVE_BATCH_AUTO=1` (skip Ctrl-C grace), `GBRAIN_PROGRESSIVE_BATCH_STAGES=10,100,500`. Sites that "jump straight to full" stay that way by default; ramp is opt-in per-site via `Policy.interactiveAbortMs > 0`. Pinned by `test/progressive-batch/orchestrator.test.ts` (35 cases, every verdict path).
- `src/core/page-body/page-shape.ts` — Wave B PR 1 (spec 1.5): segmented page bodies are unreachable as strings. `guardSegmentedBody` (called by `rowToPage` for a row with `body_storage = 'segmented'`, so by every snapshot and `getPage` read) replaces `compiled_truth` / `timeline` with enumerable getters and setters that throw `page_body_segmented`, so property reads, spread, `JSON.stringify`, `structuredClone` and assignment all fail loud instead of seeing an empty body. `isSegmentedPage`, `assertInlineBody(page, site)` (explicit refusal where a writer would otherwise act before a getter fires, e.g. SQL-only writers; every `page_body_segmented` refusal's fix reads the page with `get_page body: 'auto'`), `pageBodyBytes(page)` (`body_bytes` for segmented pages), `pageBodySegmentedError` and `pageBodyOverCeilingError` (the refusal of a fence or timeline write through the put path on a page over 24 MiB; `wholeBodySnapshot` in `persistence/segmented-apply.ts` reads a page within it back as strings and refuses above it: semantic timeline writes, `takes-prepare.ts`, `facts-prepare.ts`, `reconcile-state.ts`, `gbrain core`). Tag writes on a segmented page never read the body: `prepareSegmentedTagMutation` (`persistence/page-prepare.ts`) flips them in metadata over the live manifest (`test/large-pages/segmented-semantic-writes.test.ts`). `bodyUnread(page)` says a segmented page's body was not read back as strings (over the single-string ceiling, see `materializedPage`); such a body was written by the streamed import, which holds fenced files, so `fenceBody(page)` reads it as empty for the fence merges and `withoutBody(page)` copies the page's other fields for a render whose body comes from the incoming write (a shrunk file rewrites such a page: `test/large-pages/segmented-shrink-below-ceiling.test.ts`). `Page` stays one shape (`body_storage?`, `body_bytes?`); the static half is `scripts/check-page-body-readers.ts` with `scripts/page-body-readers-baseline.tsv` (docs/TESTING.md#page-body-readers). Pinned by `test/large-pages/segmented-body-unreachable.test.ts`.
-- `src/core/page-body/limits.ts` — Wave B size classes, ceilings, retention numbers and config keys in one place. `readPageBodyPolicy` is the single question every write asks: `segmented` is the effective `pages.segmented_storage` (unset means `SEGMENTED_STORAGE_DEFAULT`, `off` in this release; `off` or an unrecognized value is off; held off while `segmentedWriterBlockers` finds a recent writer that blocks, and an unreadable gate counts as blocked), `maxBytes` the engine ceiling (256 MiB Postgres, 128 MiB PGLite, lowered by `pages.max_bytes`) while on and `PAGE_MAX_BYTES` while off. Config is read per call; only the writer gate is cached (`SEGMENTED_WRITER_GATE_TTL_MS`, `_resetSegmentedWriterGateForTests`). `chooseBodyStorage` applies the 1 MiB / 512 KiB hysteresis. The writer gate (`segmentedGateWriters` in `persistence/writer-versions.ts`) reads seven days of admitted requests in any state, committed publications, `ingest_log` rows and, on Postgres, `persistence_consumers` heartbeats; a row blocks when its version is below `SEGMENTED_WRITER_FLOOR` or unparsable, or when it lacks the segment-reader mark (migration v254: `admitter_segment_reader`, `consumer_segment_reader`, `persistence_consumers.segment_reader`, `ingest_log.writer_segment_reader`), because releases 0.60.252.0-0.60.262.0 have no segment readers and a version string cannot tell them apart. Not seen: an older binary's unmanaged single-page write, a run that dies before it logs, and read-only or export use. `pageRecoveryBytes` is the default `persistence.limits.worktree_recovery_bytes` (read by `persistence/limits.ts` `readJournalLimits` in its one config statement): twice the body the configured switch admits (`segmentedMaxBytes`, or `PAGE_MAX_BYTES` while off) plus `RECOVERY_FILE_HEADROOM_BYTES` per copy, never below 256 MiB, because a restore reserves its file twice; it ignores the writer gate so a page admitted while the switch was effective stays restorable. Tests: `test/large-pages/segmented-switch.test.ts`, `test/large-pages/recovery-budget-default.test.ts`.
+- `src/core/page-body/limits.ts` — Wave B size classes, ceilings, retention numbers and config keys in one place. `readPageBodyPolicy` is the single question every write asks: `segmented` is the effective `pages.segmented_storage` (unset means `SEGMENTED_STORAGE_DEFAULT`, `on`; `off` or an unrecognized value is off; held off while `segmentedWriterBlockers` finds a recent writer that blocks, and an unreadable gate counts as blocked), `maxBytes` the engine ceiling (256 MiB Postgres, 128 MiB PGLite, lowered by `pages.max_bytes`) while on and `PAGE_MAX_BYTES` while off. Config is read per call; only the writer gate is cached (`SEGMENTED_WRITER_GATE_TTL_MS`, `_resetSegmentedWriterGateForTests`). `chooseBodyStorage` applies the 1 MiB / 512 KiB hysteresis. The writer gate (`segmentedGateWriters` in `persistence/writer-versions.ts`) reads seven days of admitted requests in any state, committed publications, `ingest_log` rows and, on Postgres, `persistence_consumers` heartbeats; a row blocks when its version is below `SEGMENTED_WRITER_FLOOR` or unparsable, or when it lacks the segment-reader mark (migration v254: `admitter_segment_reader`, `consumer_segment_reader`, `persistence_consumers.segment_reader`, `ingest_log.writer_segment_reader`), because releases 0.60.252.0-0.60.262.0 have no segment readers and a version string cannot tell them apart. Not seen: an older binary's unmanaged single-page write, a run that dies before it logs, and read-only or export use. `pageRecoveryBytes` is the default `persistence.limits.worktree_recovery_bytes` (read by `persistence/limits.ts` `readJournalLimits` in its one config statement): twice the body the configured switch admits (`segmentedMaxBytes`, or `PAGE_MAX_BYTES` while off) plus `RECOVERY_FILE_HEADROOM_BYTES` per copy, never below 256 MiB, because a restore reserves its file twice; it ignores the writer gate so a page admitted while the switch was effective stays restorable. Tests: `test/large-pages/segmented-switch.test.ts`, `test/large-pages/recovery-budget-default.test.ts`.
- `src/core/page-body/read-range.ts` + `segment-projection.ts` + `segment-ledger.ts` — Wave B PR 2 (spec 7.1, 7.3): the segment reader. `openSegmentedBody` reads a page's live manifest rows and its withdrawal ledger (`readBodyLedger`); `readBodyRange(engine, { pageId, space, start, end, audience, region?, body? })` streams pieces one segment text at a time, never the whole body. Remote reads and every projected-space read serve the read projection: `projectSegment` projects whole segments from their stored protected regions (takes, truncated tail and markers out, keys as the projection token, facts regions rendered world-only and credential-projected), after the withdrawal overlay (`overlaySegmentText`; a fence split by a forced cut is omitted for reads and refuses a trusted read) and the fence overlay (held and purged rows out, rows below the page tier in the low-tier block after the truth). A transform or stale metadata recomputes the regions from the segment's entry state; with none usable the read refuses `page_projection_stale`, never raw text. Trusted stored-space reads give the overlaid stored stream. `projectedLayout` (cached on the handle), `projectedUnits` (rows and fixed text in projected order, for `page-window/segmented.ts`), `projectedTotals`, `projectedLineStart` and `projectedOutline` (outline from stored metadata, no segment text) locate projected bytes; the concatenation equals `projectPageText` of the joined body byte for byte except where a facts fence is longer than a segment (shows less). The chunker (`segment-chunks.ts`) chunks the same projection, so sealed segmented pages carry `MARKDOWN_CHUNKER_VERSION`; `sealSegmentedPage` indexes the overlaid, sanitized timeline lead. Pinned by `test/large-pages/projection-parity.test.ts`, `remote-window-privacy.test.ts` and `sealed-segmented-search.test.ts` (fixture `test/helpers/segmented-privacy-fixture.ts`).
- `src/core/page-body/segment-rewrite.ts` — fence rewrites of a segmented body without holding it as one string (forget strikes, purge drops). Only stored `facts`/`takes` protected regions are decoded and passed, in body order with their region, to a `FenceTransform` (a region crossing forced cuts is joined with its neighbours, refused above `PAGE_MAX_BYTES`). `rewriteLiveSegmentedFences` re-stages the live body through `prepareSegmentedBody` from the segment stream with the changed units replaced and flips it in the caller's transaction (trust tier and soft delete kept; null when nothing changed); `rewriteSegmentedGeneration` rebuilds one retained generation under its own number and updates its versions' hash and size; `rewrittenContentHash` streams the hash of a rewritten generation; `segmentedBodyContains` searches a body segment by segment with the previous segment's tail carried over. Tests: `test/large-pages/purge-segments.test.ts`, `forget-scope.test.ts`, `page-purge-segments.test.ts`.
- `src/core/page-body/segment-blocks.ts` + `segment-links.ts` + `segment-takes.ts` — Wave B PR 2 (spec 8, full-pass mode): the derived passes over a segmented body, O(page) work and O(segment) memory, not yet incremental. `bodyBlocks(engine, page, { regions?, separator?, want? })` yields the trusted, withdrawal-overlaid joined body one block at a time (a segment, or a run joined across forced cuts, refused above `BLOCK_MAX_BYTES` with `page_body_segmented`; `want` skips a run unread), so each block starts where the parsers start fresh; `truthLead` reads a bounded lead; `readGarbageCollector` forces a collection every 4 MiB read; `detachedValue` copies a result kept past its block so it pins no segment text; `segmentedPassWork` counts the passes' work for the linearity test. `extractSegmentedPageLinks` runs `extractBodyLinks` over each block in a window (`bodyWindows`: the whole blocks before it, 4096 chars after, the headings still open), with the role phrases a first pass found (`segmentedRoleText`), and merges candidates in `extractPageLinks` order, plus the temporal inputs (`TemporalBody`). `parseTakesFenceBlocks` gives `parseTakesFence` of the joined body. Consumers: link preparation and the links effect, stale-links maintenance, source reconciliation, the sweep, `extract links|timeline|takes --source db`, `extract --stale` (the stale list includes segmented pages since PR 2 fix lane J1; test `test/large-pages/segmented-extraction-stale.test.ts`), the mention pass (`pageMentions`), the canonical prior view (`segmentedPriorView`), `segmentedTimelineText`, the chronicle judge and the facts planner (`planSegmentedExtraction`). Tests: `test/large-pages/segmented-derived-parity.test.ts`, `segmented-derived-passes.test.ts`, `segmented-derived-linear.test.ts`, `segmented-derived-memory.slow.test.ts`, `segmented-derived-work.test.ts`. `segment-lines.ts` serves the line-local maintenance scans: `bodyLines` yields the joined text's complete lines a block at a time (a line cut by a block boundary is carried, counted in `segmentedPassWork.carry`), consumed by `gbrain integrity` and `reconcile-links`; `segmentedRegionContains` searches one region for literal markers across block boundaries (repair `connector-fences`). Test: `test/large-pages/segmented-maintenance-commands.test.ts`.
diff --git a/docs/guides/memory-boundaries.md b/docs/guides/memory-boundaries.md
index 820232667e..1237cdd620 100644
--- a/docs/guides/memory-boundaries.md
+++ b/docs/guides/memory-boundaries.md
@@ -140,8 +140,7 @@ receipt: the write is refused as `request_too_large`.
### Segmented page storage
A page over 1 MiB is stored as segments of about 256 KiB instead of one text
-column when `pages.segmented_storage` is on (off by default in this release;
-`gbrain config set pages.segmented_storage on` turns it on). Reading a window, an
+column (`pages.segmented_storage`, on by default). Reading a window, an
outline or a chunk's context costs the size of the window, not the page, and
a rewrite re-indexes only the segments that changed. Pages at or under 1 MiB
are stored exactly as before; a segmented page goes back to one column when a
@@ -154,14 +153,14 @@ files that is only the file at its own place in the checkout, which gbrain
never rewrites; a database-only source takes it by `gbrain import`.
The switch stays off while an older gbrain writes to the same brain: a
-writer older than the release that added this check, or one that stamps no
+writer older than the release that turned it on, or one that stamps no
version, that admitted or published a managed write in the last 7 days keeps
new pages inline, even when the setting is `on`. `gbrain doctor` check
`segmented_storage` shows the configured and effective value and names each
blocking host by UUID. Run `gbrain upgrade` there; the hold clears 7 days
after that writer's last write. An older binary that writes without managed
persistence (a classic brain shared by several hosts) is not detected, so
-upgrade every host before turning the switch on.
+upgrade every host before writing pages over 1 MiB.
<a id="segmented-searchable"></a>
**When a segmented write is searchable.** The receipt of a write that stores a
@@ -210,8 +209,8 @@ frontmatter re-import of a page stored in segments works the same way up to
24 MiB; over it the file is listed `needs_review` with `page_body_segmented`
and nothing is written.
-While the switch is off (unset in this release, set to `off`, or held by an
-older writer), new pages are stored inline up to 24 MiB as before.
+While the switch is off (`gbrain config set pages.segmented_storage off`, or
+held by an older writer), new pages are stored inline up to 24 MiB as before.
Pages already stored in segments stay readable and exportable; a write that
would leave one over 24 MiB is refused until the switch is on again.
diff --git a/docs/guides/windowed-reads.md b/docs/guides/windowed-reads.md
index eeba78bd98..30f60e8521 100644
--- a/docs/guides/windowed-reads.md
+++ b/docs/guides/windowed-reads.md
@@ -118,7 +118,7 @@ refusal instead of a partial page: upgrade it (`gbrain upgrade`).
## page_body_segmented
The page's body is stored in segments (a page over 1 MiB written while
-`pages.segmented_storage` is on; see
+`pages.segmented_storage` is on, the default; see
[segmented page storage](memory-boundaries.md#segmented-page-storage)), and the command or tool that hit it reads or
writes the whole body as one string. It stopped before reading or changing
anything, so the page is intact, and retrying refuses the same way. Read the
diff --git a/llms-full.txt b/llms-full.txt
index a1ba0f4bdc..5731f5baeb 100644
--- a/llms-full.txt
+++ b/llms-full.txt
@@ -5710,7 +5710,7 @@ and the fix is the read-only `gbrain migrate --to postgres --plan --json`.
| Cost | Free | Supabase Pro ($25/mo) |
| Concurrency | Single process | Connection pooling |
| Backups | Manual (file copy) | Managed by Supabase |
-| Largest page | 24 MiB; 128 MiB stored in segments with `pages.segmented_storage on` (`pages.max_bytes`) | 24 MiB; 256 MiB stored in segments with `pages.segmented_storage on` (`pages.max_bytes`) |
+| Largest page | 128 MiB, stored in segments (`pages.max_bytes`) | 256 MiB, stored in segments (`pages.max_bytes`) |
**The belief ledger lives only in the database.** `belief_events` and its side tables record what the brain had recorded, and when (`gbrain beliefs status`). Markdown carries only current state, so a rebuild from Markdown, `gbrain reinit-pglite` or a dropped database starts an empty history; back up the database itself. After restoring a Postgres (or PGLite) backup, replay the purges made after the backup was taken: until then content purged later is readable again, and `gbrain doctor --only belief_ledger_coverage` reports a restore whose purge replay was partial, unavailable or unverified. Graduation copies the ledger verbatim (equal event keys and digests); the legacy copier refuses a brain that has one.
diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.ts
index 43632f4b29..0bb678b227 100644
--- a/src/core/behavior-change-notice.ts
+++ b/src/core/behavior-change-notice.ts
@@ -882,6 +882,8 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }
{ since: '0.60.287.0', text: 'A batch of page purges no longer reads the whole write journal once per page: the first queued purge of a source sweeps once for its own claims and those of the purges queued behind it, and each of those scans only the journal rows added since. Purge receipts\' `journal_sweep` gains `batch` (how many purges that sweep covered) and `watermark` (the sequence a purge started past; null when it swept from the start). A purge whose claims changed since the batch sweep sweeps on its own as before.' },
{ since: '0.60.287.0', text: 'The managed purge (autopilot purge phase, the purge job and `gbrain pages purge-deleted`) submits only while the writer has outstanding-request room (a background run stops at `persistence.capacity.background_pause_pct` of the cap). The rest is reported as `write_capacity_deferred` and counted in `capacity_deferred` (cycle: `purged_pages_capacity_deferred`, phase status warn) and is submitted by the next run, where it used to fail each page with `queue_capacity` (`managed_purge_failed`) and count each failure toward parking it.' },
{ since: '0.60.288.0', text: 'On a managed brain `gbrain sync --dry-run --json` adds a `convergence` object: a read-only shadow of the level-triggered sync (#6712 PR 4a) that classifies every path of the source the way the coming pass will (matched, import, held, drift and the other classes, each tagged with who acts: none, owner or repair), with predicted file_drift decisions after a read-only screen, `legacy_unverified` counts, deletes with the mass-delete valve verdict and up to 20 sample paths per class. `--redact-paths` turns the sample paths into sha256 prefixes and drops slugs, so the counts can be shared. `gbrain sync status --detail --json` adds the same object (`convergence`, `dry_run: true`) and `convergence_read`; a plain `sync status` skips that heavy read. Nothing is written or admitted, existing keys keep their meaning, and sync behaves exactly as before.' },
+ // Large pages switch-on flip (Wave B PR 2 follow-up). `since` is stamped with SEGMENTED_WRITER_FLOOR at the merge slot.
+ { since: 'TBD', text: 'Pages over 1 MiB are now stored in segments: `pages.segmented_storage` is on by default. Reading a window, outline or chunk context of a large page costs the size of the window, not the page, and a rewrite re-indexes only the segments that changed. A page can be up to 256 MiB on Postgres and 128 MiB on PGLite (`pages.max_bytes` lowers it). `put_page`, `put_pages` and `capture` content and `gbrain put` stdin stay limited to 24 MiB per call, so a larger page comes in by `gbrain import` or `gbrain sync` of its file: on a source backed by files only from the file\'s own place in the checkout, which is never rewritten; a database-only source takes it by import. Pages at or under 1 MiB are stored exactly as before. `gbrain config set pages.segmented_storage off` stores new pages inline up to 24 MiB again; pages already stored in segments stay readable. The writer hold now counts any gbrain older than this release, v0.60.290.0 included (its withdrawal mirror leaves a large page\'s file unchanged and its search build can overlap another\'s): while one wrote in the last 7 days, new pages stay inline and doctor `segmented_storage` names the host to upgrade.' },
];
/** The newest disclosed change's release: the notice id moves only when a release adds rows. */
diff --git a/src/core/page-body/limits.ts b/src/core/page-body/limits.ts
index aaed16868d..1a2ee474b1 100644
--- a/src/core/page-body/limits.ts
+++ b/src/core/page-body/limits.ts
@@ -121,7 +121,7 @@ function positiveInt(raw: string | null, fallback: number): number {
}
/** The effective `pages.segmented_storage` when it is not configured. */
-export const SEGMENTED_STORAGE_DEFAULT: 'on' | 'off' = 'off';
+export const SEGMENTED_STORAGE_DEFAULT: 'on' | 'off' = 'on';
/** The configured `pages.segmented_storage`: unset means SEGMENTED_STORAGE_DEFAULT; an unrecognized value counts as `off`. */
export function parseSegmentedStorage(raw: string | null): 'on' | 'off' | 'unset' | 'invalid' {
diff --git a/src/core/persistence/writer-versions.ts b/src/core/persistence/writer-versions.ts
index c3a55e2752..dfeed02dee 100644
--- a/src/core/persistence/writer-versions.ts
+++ b/src/core/persistence/writer-versions.ts
@@ -10,9 +10,10 @@ export const UNSTAMPED_WRITER = 'unstamped (binary older than this release)';
* Writers older than this do not understand segmented page bodies (Wave B): a pre-Wave-B binary reads a segmented
* page's NULL body columns, and the release that added segmented storage behind the switch purges, forgets and exports
* without its segment texts. A recent one keeps `pages.segmented_storage` effectively off (`page-body/limits.ts`).
- * A placeholder equal to the branch's VERSION until the merge-slot stamp, which sets it to the release that turns the
- * switch on (the `since` of its BEHAVIOR_CHANGES row, pinned by test/large-pages/segmented-switch.test.ts). That
- * release must be above v0.60.252.0, the release that added segmented storage with the switch off. A version alone
+ * v0.60.290.0 shipped segment readers with the switch off, but its withdrawal mirror skips segmented pages and its
+ * projection builder renews a claim it may have lost, so the floor is the release that turns the switch on: a
+ * placeholder equal to the branch's VERSION until the merge-slot stamp sets it and the `since` of the switch-on
+ * BEHAVIOR_CHANGES row to the same release (pinned by test/large-pages/segmented-switch.test.ts). A version alone
* cannot tell a build with segment readers from a release of the same version without them (every release from
* v0.60.252.0 until the stamp has none), so the gate also requires the segment-reader mark (migration v254) on
* every write it sees: an unmarked writer blocks whatever its version, the floor included (`segmentedGateWriters`).
diff --git a/test/fixtures/goldens/doctor/content-pglite-human.json b/test/fixtures/goldens/doctor/content-pglite-human.json
index 5aad04bf3d..09b2c137ef 100644
--- a/test/fixtures/goldens/doctor/content-pglite-human.json
+++ b/test/fixtures/goldens/doctor/content-pglite-human.json
@@ -113,7 +113,7 @@
" [OK] coordination_lock_location: Every checkout's recorded coordination lock agrees with GBRAIN_COORDINATION_HOME, or the variable does not apply.",
" [OK] unbound_source: No page was written database-only to an unbound source.",
" [OK] writer_version: Every writer that admitted or published a request in the last 7 days is v0.60.5.0 or newer.",
- " [INFO] segmented_storage: Segmented page storage is off by default in this release (pages.segmented_storage unset): pages over 1 MiB are stored inline up to 24 MiB; pages already stored in segments stay readable.",
+ " [OK] segmented_storage: Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",
" [OK] self_capture: No session corpus is configured; nothing to classify.",
" [OK] vector_plan: Skipped: PGLite runs vector search in-process; the plan check applies to Postgres brains.",
" [OK] keyword_plan: Skipped: PGLite runs keyword search with no statement timeout; the canary applies to Postgres brains.",
diff --git a/test/fixtures/goldens/doctor/content-pglite-json.json b/test/fixtures/goldens/doctor/content-pglite-json.json
index 65a2ef6573..72276882a7 100644
--- a/test/fixtures/goldens/doctor/content-pglite-json.json
+++ b/test/fixtures/goldens/doctor/content-pglite-json.json
@@ -1527,46 +1527,15 @@
"blockers": [],
"configured": "unset",
"docs": "docs/guides/memory-boundaries.md#segmented-page-storage",
- "effective": "off",
+ "effective": "on",
"floor": "<segmented-writer-floor>",
- "max_bytes": 25165824,
+ "max_bytes": 134217728,
"truncated": false,
"window_days": 7
},
"elapsed_ms": "<volatile>",
- "fix": {
- "actor": "user",
- "argv": [
- "gbrain",
- "config",
- "set",
- "pages.segmented_storage",
- "on",
- "--brain",
- "host"
- ],
- "command": "gbrain config set pages.segmented_storage on --brain host",
- "consent": [],
- "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/memory-boundaries.md#segmented-page-storage",
- "next": "tell_user_to_run",
- "requires_exclusive": false,
- "verify": {
- "argv": [
- "gbrain",
- "doctor",
- "--only",
- "segmented_storage",
- "--json",
- "--brain",
- "host"
- ]
- },
- "why": "Turns segmented storage on: pages over 1 MiB are stored in segments, up to the engine ceiling."
- },
- "message": "Segmented page storage is off by default in this release (pages.segmented_storage unset): pages over 1 MiB are stored inline up to 24 MiB; pages already stored in segments stay readable.",
+ "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",
"name": "segmented_storage",
- "readiness_state": "disabled_by_choice",
- "severity": "info",
"status": "ok"
},
{
diff --git a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
index 62f50062d5..fee0d0e8d8 100644
--- a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
+++ b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
@@ -1695,46 +1695,15 @@
"blockers": [],
"configured": "unset",
"docs": "docs/guides/memory-boundaries.md#segmented-page-storage",
- "effective": "off",
+ "effective": "on",
"floor": "<segmented-writer-floor>",
- "max_bytes": 25165824,
+ "max_bytes": 134217728,
"truncated": false,
"window_days": 7
},
"elapsed_ms": "<volatile>",
- "fix": {
- "actor": "user",
- "argv": [
- "gbrain",
- "config",
- "set",
- "pages.segmented_storage",
- "on",
- "--brain",
- "host"
- ],
- "command": "gbrain config set pages.segmented_storage on --brain host",
- "consent": [],
- "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/memory-boundaries.md#segmented-page-storage",
- "next": "tell_user_to_run",
- "requires_exclusive": false,
- "verify": {
- "argv": [
- "gbrain",
- "doctor",
- "--only",
- "segmented_storage",
- "--json",
- "--brain",
- "host"
- ]
- },
- "why": "Turns segmented storage on: pages over 1 MiB are stored in segments, up to the engine ceiling."
- },
- "message": "Segmented page storage is off by default in this release (pages.segmented_storage unset): pages over 1 MiB are stored inline up to 24 MiB; pages already stored in segments stay readable.",
+ "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",
"name": "segmented_storage",
- "readiness_state": "disabled_by_choice",
- "severity": "info",
"status": "ok"
},
{
@@ -5966,46 +5935,15 @@
"blockers": [],
"configured": "unset",
"docs": "docs/guides/memory-boundaries.md#segmented-page-storage",
- "effective": "off",
+ "effective": "on",
"floor": "<segmented-writer-floor>",
- "max_bytes": 25165824,
+ "max_bytes": 134217728,
"truncated": false,
"window_days": 7
},
"elapsed_ms": "<volatile>",
- "fix": {
- "actor": "user",
- "argv": [
- "gbrain",
- "config",
- "set",
- "pages.segmented_storage",
- "on",
- "--brain",
- "host"
- ],
- "command": "gbrain config set pages.segmented_storage on --brain host",
- "consent": [],
- "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/memory-boundaries.md#segmented-page-storage",
- "next": "tell_user_to_run",
- "requires_exclusive": false,
- "verify": {
- "argv": [
- "gbrain",
- "doctor",
- "--only",
- "segmented_storage",
- "--json",
- "--brain",
- "host"
- ]
- },
- "why": "Turns segmented storage on: pages over 1 MiB are stored in segments, up to the engine ceiling."
- },
- "message": "Segmented page storage is off by default in this release (pages.segmented_storage unset): pages over 1 MiB are stored inline up to 24 MiB; pages already stored in segments stay readable.",
+ "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",
"name": "segmented_storage",
- "readiness_state": "disabled_by_choice",
- "severity": "info",
"status": "ok"
},
{
diff --git a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
index cd3abfe4f9..3602d725a0 100644
--- a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
+++ b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
@@ -1687,46 +1687,15 @@
"blockers": [],
"configured": "unset",
"docs": "docs/guides/memory-boundaries.md#segmented-page-storage",
- "effective": "off",
+ "effective": "on",
"floor": "<segmented-writer-floor>",
- "max_bytes": 25165824,
+ "max_bytes": 268435456,
"truncated": false,
"window_days": 7
},
"elapsed_ms": "<volatile>",
- "fix": {
- "actor": "user",
- "argv": [
- "gbrain",
- "config",
- "set",
- "pages.segmented_storage",
- "on",
- "--brain",
- "host"
- ],
- "command": "gbrain config set pages.segmented_storage on --brain host",
- "consent": [],
- "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/memory-boundaries.md#segmented-page-storage",
- "next": "tell_user_to_run",
- "requires_exclusive": false,
- "verify": {
- "argv": [
- "gbrain",
- "doctor",
- "--only",
- "segmented_storage",
- "--json",
- "--brain",
- "host"
- ]
- },
- "why": "Turns segmented storage on: pages over 1 MiB are stored in segments, up to the engine ceiling."
- },
- "message": "Segmented page storage is off by default in this release (pages.segmented_storage unset): pages over 1 MiB are stored inline up to 24 MiB; pages already stored in segments stay readable.",
+ "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 268435456 bytes on this Postgres brain.",
"name": "segmented_storage",
- "readiness_state": "disabled_by_choice",
- "severity": "info",
"status": "ok"
},
{
@@ -5959,46 +5928,15 @@
"blockers": [],
"configured": "unset",
"docs": "docs/guides/memory-boundaries.md#segmented-page-storage",
- "effective": "off",
+ "effective": "on",
"floor": "<segmented-writer-floor>",
- "max_bytes": 25165824,
+ "max_bytes": 268435456,
"truncated": false,
"window_days": 7
},
"elapsed_ms": "<volatile>",
- "fix": {
- "actor": "user",
- "argv": [
- "gbrain",
- "config",
- "set",
- "pages.segmented_storage",
- "on",
- "--brain",
- "host"
- ],
- "command": "gbrain config set pages.segmented_storage on --brain host",
- "consent": [],
- "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/memory-boundaries.md#segmented-page-storage",
- "next": "tell_user_to_run",
- "requires_exclusive": false,
- "verify": {
- "argv": [
- "gbrain",
- "doctor",
- "--only",
- "segmented_storage",
- "--json",
- "--brain",
- "host"
- ]
- },
- "why": "Turns segmented storage on: pages over 1 MiB are stored in segments, up to the engine ceiling."
- },
- "message": "Segmented page storage is off by default in this release (pages.segmented_storage unset): pages over 1 MiB are stored inline up to 24 MiB; pages already stored in segments stay readable.",
+ "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 268435456 bytes on this Postgres brain.",
"name": "segmented_storage",
- "readiness_state": "disabled_by_choice",
- "severity": "info",
"status": "ok"
},
{
diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.json
index 2674b689cf..3a8efd1480 100644
--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json
+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json
@@ -1415,46 +1415,15 @@
"blockers": [],
"configured": "unset",
"docs": "docs/guides/memory-boundaries.md#segmented-page-storage",
- "effective": "off",
+ "effective": "on",
"floor": "<segmented-writer-floor>",
- "max_bytes": 25165824,
+ "max_bytes": 134217728,
"truncated": false,
"window_days": 7
},
"elapsed_ms": "<volatile>",
- "fix": {
- "actor": "user",
- "argv": [
- "gbrain",
- "config",
- "set",
- "pages.segmented_storage",
- "on",
- "--brain",
- "host"
- ],
- "command": "gbrain config set pages.segmented_storage on --brain host",
- "consent": [],
- "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/memory-boundaries.md#segmented-page-storage",
- "next": "tell_user_to_run",
- "requires_exclusive": false,
- "verify": {
- "argv": [
- "gbrain",
- "doctor",
- "--only",
- "segmented_storage",
- "--json",
- "--brain",
- "host"
- ]
- },
- "why": "Turns segmented storage on: pages over 1 MiB are stored in segments, up to the engine ceiling."
- },
- "message": "Segmented page storage is off by default in this release (pages.segmented_storage unset): pages over 1 MiB are stored inline up to 24 MiB; pages already stored in segments stay readable.",
+ "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",
"name": "segmented_storage",
- "readiness_state": "disabled_by_choice",
- "severity": "info",
"status": "ok"
},
{
diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.json
index 4d6465da83..01a6baed56 100644
--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json
+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json
@@ -1471,46 +1471,15 @@
"blockers": [],
"configured": "unset",
"docs": "docs/guides/memory-boundaries.md#segmented-page-storage",
- "effective": "off",
+ "effective": "on",
"floor": "<segmented-writer-floor>",
- "max_bytes": 25165824,
+ "max_bytes": 134217728,
"truncated": false,
"window_days": 7
},
"elapsed_ms": "<volatile>",
- "fix": {
- "actor": "user",
- "argv": [
- "gbrain",
- "config",
- "set",
- "pages.segmented_storage",
- "on",
- "--brain",
- "host"
- ],
- "command": "gbrain config set pages.segmented_storage on --brain host",
- "consent": [],
- "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/memory-boundaries.md#segmented-page-storage",
- "next": "tell_user_to_run",
- "requires_exclusive": false,
- "verify": {
- "argv": [
- "gbrain",
- "doctor",
- "--only",
- "segmented_storage",
- "--json",
- "--brain",
- "host"
- ]
- },
- "why": "Turns segmented storage on: pages over 1 MiB are stored in segments, up to the engine ceiling."
- },
- "message": "Segmented page storage is off by default in this release (pages.segmented_storage unset): pages over 1 MiB are stored inline up to 24 MiB; pages already stored in segments stay readable.",
+ "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",
"name": "segmented_storage",
- "readiness_state": "disabled_by_choice",
- "severity": "info",
"status": "ok"
},
{
diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.json
index ffe932b93d..7251beb553 100644
--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json
+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json
@@ -1463,46 +1463,15 @@
"blockers": [],
"configured": "unset",
"docs": "docs/guides/memory-boundaries.md#segmented-page-storage",
- "effective": "off",
+ "effective": "on",
"floor": "<segmented-writer-floor>",
- "max_bytes": 25165824,
+ "max_bytes": 268435456,
"truncated": false,
"window_days": 7
},
"elapsed_ms": "<volatile>",
- "fix": {
- "actor": "user",
- "argv": [
- "gbrain",
- "config",
- "set",
- "pages.segmented_storage",
- "on",
- "--brain",
- "host"
- ],
- "command": "gbrain config set pages.segmented_storage on --brain host",
- "consent": [],
- "docs": "https://github.com/garrytan/gbrain/blob/master/docs/guides/memory-boundaries.md#segmented-page-storage",
- "next": "tell_user_to_run",
- "requires_exclusive": false,
- "verify": {
- "argv": [
- "gbrain",
- "doctor",
- "--only",
- "segmented_storage",
- "--json",
- "--brain",
- "host"
- ]
- },
- "why": "Turns segmented storage on: pages over 1 MiB are stored in segments, up to the engine ceiling."
- },
- "message": "Segmented page storage is off by default in this release (pages.segmented_storage unset): pages over 1 MiB are stored inline up to 24 MiB; pages already stored in segments stay readable.",
+ "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 268435456 bytes on this Postgres brain.",
"name": "segmented_storage",
- "readiness_state": "disabled_by_choice",
- "severity": "info",
"status": "ok"
},
{
diff --git a/test/large-pages/segmented-switch.test.ts b/test/large-pages/segmented-switch.test.ts
index b777982ee4..5a5913a03a 100644
--- a/test/large-pages/segmented-switch.test.ts
+++ b/test/large-pages/segmented-switch.test.ts
@@ -2,8 +2,8 @@
* Wave B PR 2 switch-on (spec 1.1 activation gate, 13 PR 2): `pages.segmented_storage` follows
* SEGMENTED_STORAGE_DEFAULT when unset and is gated by the writer versions recorded on committed persistence requests.
*
- * 1. Protects: with no configuration a page over 1 MiB is stored inline under the 24 MiB limit while the default is
- * off, and doctor offers the switch; a writer older than SEGMENTED_WRITER_FLOOR (or unstamped) seen in the last seven days keeps writes
+ * 1. Protects: with no configuration a page over 1 MiB is stored segmented and `pages.max_bytes` is the engine
+ * ceiling; a writer older than SEGMENTED_WRITER_FLOOR (or unstamped) seen in the last seven days keeps writes
* inline, even with an explicit `on`, and doctor `segmented_storage` names it with an upgrade fix; once that
* observation is gone the next write promotes; an explicit `off` keeps pages inline and reports it as a choice;
* (a stored segmented page over 32 MiB exporting while the switch is off is in segmented-real-size.slow.test.ts). Every write the gate sees must carry the
@@ -11,7 +11,7 @@
* run (ingest_log), its resident heartbeat and its uncommitted requests all block; this build's do not. An
* unreadable gate blocks, an unparsable stamp blocks, the 7-day window ends between day 6 and day 8, and the gate is
* read once per TTL (work counter) while doctor reads through.
- * 2. Fails when: the default turns on before the release flips it, the gate ignores old or unstamped writers, an explicit `on` overrides the
+ * 2. Fails when: the default stays off, the gate ignores old or unstamped writers, an explicit `on` overrides the
* gate, a cleared gate keeps writes inline, export sizes stored segmented pages by the write limit, a writer without
* the mark passes on its version, a write path of this build stops marking, or the gate's error, window, parse or
* cache handling changes.
@@ -43,8 +43,8 @@ async function storage(engine: BrainEngine, slug: string): Promise<string | unde
return (await engine.executeRaw<{ body_storage: string }>('SELECT body_storage FROM pages WHERE slug=$1', [slug]))[0]?.body_storage;
}
-test('SEGMENTED_WRITER_FLOOR is the release of the writer-gate BEHAVIOR_CHANGES row once stamped, and never above this build', () => {
- const row = BEHAVIOR_CHANGES.find(c => typeof c.text === 'string' && c.text.startsWith('Segmented page storage stays off while an older gbrain'));
+test('SEGMENTED_WRITER_FLOOR is the release of the switch-on BEHAVIOR_CHANGES row once stamped, and never above this build', () => {
+ const row = BEHAVIOR_CHANGES.find(c => typeof c.text === 'string' && c.text.startsWith('Pages over 1 MiB are now stored in segments'));
expect(row).toBeDefined();
if (row!.since !== 'TBD') expect(row!.since).toBe(SEGMENTED_WRITER_FLOOR);
expect(compareWriterVersions(SEGMENTED_WRITER_FLOOR, VERSION)).toBeLessThanOrEqual(0);
@@ -69,15 +69,12 @@ for (const kind of testBackends()) {
});
const inHome = <T>(fn: () => Promise<T>) => withEnv({ GBRAIN_HOME: home, DATABASE_URL: undefined, GBRAIN_DATABASE_URL: undefined }, fn);
- test('default off: unset keeps a page over 1 MiB inline under the 24 MiB limit, and doctor offers the switch', async () => {
+ test('default on: a page over 1 MiB is stored segmented and pages.max_bytes is the engine ceiling', async () => {
expect(await engine.getConfig('pages.segmented_storage')).toBeNull();
- expect(await readPageBodyPolicy(engine)).toMatchObject({ segmented: false, maxBytes: PAGE_MAX_BYTES });
- expect((await importFromContent(engine, 'notes/default-off', content, { noEmbed: true })).status).toBe('imported');
- expect(await storage(engine, 'notes/default-off')).toBe('inline');
- expect(await segmentedStorageCheck(engine)).toMatchObject({ status: 'ok', severity: 'info', readiness_state: 'disabled_by_choice',
- details: { configured: 'unset', effective: 'off', blockers: [] }, fix: { argv: ['gbrain', 'config', 'set', 'pages.segmented_storage', 'on'] } });
- await engine.setConfig('pages.segmented_storage', 'on');
expect(await readPageBodyPolicy(engine)).toMatchObject({ segmented: true, maxBytes: segmentedPageCeiling(engine.kind) });
+ expect((await importFromContent(engine, 'notes/default-on', content, { noEmbed: true })).status).toBe('imported');
+ expect(await storage(engine, 'notes/default-on')).toBe('segmented');
+ expect(await segmentedStorageCheck(engine)).toMatchObject({ status: 'ok', details: { configured: 'unset', effective: 'on', blockers: [] } });
}, 120_000);
test('a recent writer below the floor keeps writes inline, even with an explicit on; once it is gone the next write promotes', async () => inHome(async () => {