Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Revert the default flip ahead of merging the integration branch (re-applied as the final commit)
garrytan765da9c4829e
diff --git a/docs/ENGINES.md b/docs/ENGINES.mdindex 344a3ba9ea..d8c9b7ff78 100644--- a/docs/ENGINES.md+++ b/docs/ENGINES.md@@ -343,7 +343,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 | 128 MiB, stored in segments (`pages.max_bytes`) | 256 MiB, stored in segments (`pages.max_bytes`) |+| 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`) |**Migration:** on a PGLite brain, `gbrain migrate --to postgres` (alias `--to supabase`) graduates the brain to Postgres. Without `--yes` it prints the plan and exits 3; `--yes --expect <plan_hash>` runs it. Graduation drains pending writes, copies every table verbatim with its primary keys (pages, facts, takes, versions, links, timeline, embeddings, transcripts and paid caches, request history and withdrawals, token and OAuth rows) into a fenced target, verifies row counts and digests, runs `gbrain doctor` on the target, and only then flips routing. It works for brains with write history and for managed brains. The PGLite data dir is retained as `<path>.graduated-<run_id>` and a tombstone file takes its place. Walkthrough, recovery by error code, rollback and what stays on this computer: [Move a PGLite brain to Postgres](guides/move-to-postgres.md).diff --git a/docs/architecture/key-files/core-services-2-continued.md b/docs/architecture/key-files/core-services-2-continued.mdindex 26a5dac123..04581c0150 100644--- a/docs/architecture/key-files/core-services-2-continued.md+++ b/docs/architecture/key-files/core-services-2-continued.md@@ -17,7 +17,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), `pageBodyBytes(page)` (`body_bytes` for segmented pages) and `pageBodySegmentedError`. `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`, `on`; `off` or an unrecognized value is off; held off while `segmentedWriterBlockers` finds a recent writer below `SEGMENTED_WRITER_FLOOR`, 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. Tests: `test/large-pages/segmented-switch.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 below `SEGMENTED_WRITER_FLOOR`, 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. Tests: `test/large-pages/segmented-switch.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), `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? })` 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`), 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`, 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`.diff --git a/docs/guides/memory-boundaries.md b/docs/guides/memory-boundaries.mdindex 55d2b09f52..4e2a34b56f 100644--- a/docs/guides/memory-boundaries.md+++ b/docs/guides/memory-boundaries.md@@ -140,7 +140,8 @@ receipt: the write is refused as `request_too_large`.### Segmented page storageA page over 1 MiB is stored as segments of about 256 KiB instead of one text-column (`pages.segmented_storage`, on by default). Reading a window, an+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, anoutline or a chunk's context costs the size of the window, not the page, anda rewrite re-indexes only the segments that changed. Pages at or under 1 MiBare stored exactly as before; a segmented page goes back to one column when a@@ -153,17 +154,17 @@ files that is only the file at its own place in the checkout, which gbrainnever 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 turned it on, or one that stamps no+writer older than the release that added this check, or one that stamps noversion, that admitted or published a managed write in the last 7 days keepsnew pages inline, even when the setting is `on`. `gbrain doctor` check`segmented_storage` shows the configured and effective value and names eachblocking host by UUID. Run `gbrain upgrade` there; the hold clears 7 daysafter that writer's last write. An older binary that writes without managedpersistence (a classic brain shared by several hosts) is not detected, so-upgrade every host before writing pages over 1 MiB.+upgrade every host before turning the switch on.-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.+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.Pages already stored in segments stay readable and exportable; a write thatwould 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.mdindex 251a6f71a8..6359d5fba4 100644--- a/docs/guides/windowed-reads.md+++ b/docs/guides/windowed-reads.md@@ -101,7 +101,7 @@ refusal instead of a partial page: upgrade it (`gbrain upgrade`).## page_body_segmentedThe page's body is stored in segments (a page over 1 MiB written while-`pages.segmented_storage` is on, the default; see+`pages.segmented_storage` is on; see[segmented page storage](memory-boundaries.md#segmented-page-storage)), and the command or tool that hit it reads orwrites the whole body as one string. It stopped before reading or changinganything, so the page is intact. Read the page's revision and stored size withdiff --git a/llms-full.txt b/llms-full.txtindex ab5cce79d9..fda85578b5 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -5582,7 +5582,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 | 128 MiB, stored in segments (`pages.max_bytes`) | 256 MiB, stored in segments (`pages.max_bytes`) |+| 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`) |**Migration:** on a PGLite brain, `gbrain migrate --to postgres` (alias `--to supabase`) graduates the brain to Postgres. Without `--yes` it prints the plan and exits 3; `--yes --expect <plan_hash>` runs it. Graduation drains pending writes, copies every table verbatim with its primary keys (pages, facts, takes, versions, links, timeline, embeddings, transcripts and paid caches, request history and withdrawals, token and OAuth rows) into a fenced target, verifies row counts and digests, runs `gbrain doctor` on the target, and only then flips routing. It works for brains with write history and for managed brains. The PGLite data dir is retained as `<path>.graduated-<run_id>` and a tombstone file takes its place. Walkthrough, recovery by error code, rollback and what stays on this computer: [Move a PGLite brain to Postgres](guides/move-to-postgres.md).diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex ff52de7ba1..422cacfe43 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -647,7 +647,7 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }{ since: '0.60.251.0', text: 'After `purge_fact` or a page purge, no read returns the purged text from what the purge hid: a page a purge hid for re-derivation now reads as missing in `get_page` and `fetch` (even with `include_deleted`) and returns no `get_versions` history, and a page purge now hides rows derived from the page and its facts, as `purge_fact` already did. `purge_fact` now redacts every retained version of a page (it stopped after 5,000), and its receipt\'s `pages` and `page_versions` stores also report a page or version that still states the claim in its title or frontmatter, alongside prose (`out_of_scope: source_prose`).' },// Wave B PR 2 (segmented page storage, switch on). `since` is 'TBD' until the merge-slot stamp, which also stamps// SEGMENTED_WRITER_FLOOR (persistence/writer-versions.ts) with the same release.- { 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.' },+ { since: 'TBD', text: '`gbrain config set pages.segmented_storage on` stores pages over 1 MiB in segments; it is off by default in this release. 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. Turning it off again stores new pages inline up to 24 MiB; pages already stored in segments stay readable.' },{ since: 'TBD', text: 'Segmented page storage stays off while an older gbrain writes to the same brain: a writer older than this release, or one that stamps no version, that admitted or published a managed write in the last 7 days keeps new pages over 1 MiB inline up to 24 MiB, even with `pages.segmented_storage` set to `on`. New doctor check `segmented_storage` shows the configured and effective value and names each blocking host; run `gbrain upgrade` there, and the hold clears 7 days after its last write. An older binary that writes without managed persistence is not detected.' },{ since: 'TBD', text: 'Pages stored in segments keep at most `versions.segmented_max_per_page` (default 50) version snapshots, and fewer when the old text they pin exceeds `versions.segmented_max_pinned_bytes` (default 64 MiB, never below the page size). A snapshot of such a page records its segment generation instead of copying the body. History of every other page is unchanged.' },{ since: 'TBD', text: 'A page over 24 MiB imported or synced from its file is no longer stamped `embed_skip` and `content_flag: oversized` for its size: while `content_sanity.bytes_block` is unset, a segmented page is judged against its page ceiling, and the markup check samples its head, middle and tail as it does for any large page. A `content_sanity.bytes_block` set above 24 MiB no longer holds such a file; one set below the page still stops its embedding.' },diff --git a/src/core/page-body/limits.ts b/src/core/page-body/limits.tsindex 7b828960d6..ffb7c00485 100644--- a/src/core/page-body/limits.ts+++ b/src/core/page-body/limits.ts@@ -110,7 +110,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' = 'on';+export const SEGMENTED_STORAGE_DEFAULT: 'on' | 'off' = 'off';/** 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/test/fixtures/goldens/doctor/content-pglite-human.json b/test/fixtures/goldens/doctor/content-pglite-human.jsonindex bdd08ae9b4..c6a74e5bd4 100644--- a/test/fixtures/goldens/doctor/content-pglite-human.json+++ b/test/fixtures/goldens/doctor/content-pglite-human.json@@ -107,7 +107,7 @@" [OK] foreign_ownership_marker: Every ownership marker beside a source checkout belongs to this brain."," [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.",- " [OK] segmented_storage: Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",+ " [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] 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.jsonindex 929520a93a..bb4e1552d3 100644--- a/test/fixtures/goldens/doctor/content-pglite-json.json+++ b/test/fixtures/goldens/doctor/content-pglite-json.json@@ -1444,15 +1444,46 @@"blockers": [],"configured": "unset","docs": "docs/guides/memory-boundaries.md#segmented-page-storage",- "effective": "on",+ "effective": "off","floor": "<version>",- "max_bytes": 134217728,+ "max_bytes": 25165824,"truncated": false,"window_days": 7},"elapsed_ms": "<volatile>",- "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",+ "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.","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.jsonindex 6fd21b42d8..552032bb99 100644--- a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json+++ b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json@@ -1569,15 +1569,46 @@"blockers": [],"configured": "unset","docs": "docs/guides/memory-boundaries.md#segmented-page-storage",- "effective": "on",+ "effective": "off","floor": "<version>",- "max_bytes": 134217728,+ "max_bytes": 25165824,"truncated": false,"window_days": 7},"elapsed_ms": "<volatile>",- "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",+ "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.","name": "segmented_storage",+ "readiness_state": "disabled_by_choice",+ "severity": "info","status": "ok"},{@@ -5293,15 +5324,46 @@"blockers": [],"configured": "unset","docs": "docs/guides/memory-boundaries.md#segmented-page-storage",- "effective": "on",+ "effective": "off","floor": "<version>",- "max_bytes": 134217728,+ "max_bytes": 25165824,"truncated": false,"window_days": 7},"elapsed_ms": "<volatile>",- "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",+ "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.","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.jsonindex 22580668ac..2d4b53b77a 100644--- a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json+++ b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json@@ -1561,15 +1561,46 @@"blockers": [],"configured": "unset","docs": "docs/guides/memory-boundaries.md#segmented-page-storage",- "effective": "on",+ "effective": "off","floor": "<version>",- "max_bytes": 268435456,+ "max_bytes": 25165824,"truncated": false,"window_days": 7},"elapsed_ms": "<volatile>",- "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 268435456 bytes on this Postgres brain.",+ "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.","name": "segmented_storage",+ "readiness_state": "disabled_by_choice",+ "severity": "info","status": "ok"},{@@ -5280,15 +5311,46 @@"blockers": [],"configured": "unset","docs": "docs/guides/memory-boundaries.md#segmented-page-storage",- "effective": "on",+ "effective": "off","floor": "<version>",- "max_bytes": 268435456,+ "max_bytes": 25165824,"truncated": false,"window_days": 7},"elapsed_ms": "<volatile>",- "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 268435456 bytes on this Postgres brain.",+ "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.","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.jsonindex a7c4d30862..9c3556914c 100644--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json@@ -1332,15 +1332,46 @@"blockers": [],"configured": "unset","docs": "docs/guides/memory-boundaries.md#segmented-page-storage",- "effective": "on",+ "effective": "off","floor": "<version>",- "max_bytes": 134217728,+ "max_bytes": 25165824,"truncated": false,"window_days": 7},"elapsed_ms": "<volatile>",- "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",+ "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.","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.jsonindex 8dbaecc23e..df726f714e 100644--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json@@ -1388,15 +1388,46 @@"blockers": [],"configured": "unset","docs": "docs/guides/memory-boundaries.md#segmented-page-storage",- "effective": "on",+ "effective": "off","floor": "<version>",- "max_bytes": 134217728,+ "max_bytes": 25165824,"truncated": false,"window_days": 7},"elapsed_ms": "<volatile>",- "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 134217728 bytes on this PGLite brain.",+ "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.","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.jsonindex 0c20b9f045..8f380564db 100644--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json@@ -1380,15 +1380,46 @@"blockers": [],"configured": "unset","docs": "docs/guides/memory-boundaries.md#segmented-page-storage",- "effective": "on",+ "effective": "off","floor": "<version>",- "max_bytes": 268435456,+ "max_bytes": 25165824,"truncated": false,"window_days": 7},"elapsed_ms": "<volatile>",- "message": "Segmented page storage is on: pages over 1 MiB are stored in segments, up to 268435456 bytes on this Postgres brain.",+ "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.","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.tsindex 7e6bdab3d0..a0c2a09e27 100644--- a/test/large-pages/segmented-switch.test.ts+++ b/test/large-pages/segmented-switch.test.ts@@ -2,12 +2,12 @@* 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 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+ * 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* 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 still exports while the switch is off.- * 2. Fails when: the default stays off, the gate ignores old or unstamped writers, an explicit `on` overrides the+ * 2. Fails when: the default turns on before the release flips it, the gate ignores old or unstamped writers, an explicit `on` overrides the* gate, a cleared gate keeps writes inline, or export sizes stored segmented pages by the write limit.*/import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';@@ -71,12 +71,15 @@ 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 on: a page over 1 MiB is stored segmented and pages.max_bytes is the engine ceiling', async () => {+ test('default off: unset keeps a page over 1 MiB inline under the 24 MiB limit, and doctor offers the switch', 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 () => {