Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
graduation(G3): serve hand-off via lifecycle shutdown hook (exit 75), cli.ts/config.ts compression + ceilings, windows legacy test, docs fixes
garrytancf7c484c078f
diff --git a/docs/ENGINES.md b/docs/ENGINES.mdindex bc21992653..255f8f48f7 100644--- a/docs/ENGINES.md+++ b/docs/ENGINES.md@@ -303,7 +303,7 @@ The legacy copier handles every other direction: `gbrain migrate --to pglite`, P| Refusing side | `fix.next` | Next step ||---|---|---|-| A PGLite brain with history moving to Postgres with graduation turned off | `ask_user` | Relay `user_message`: graduation moves this brain (`gbrain config set migrate.graduation true`, then the [two-command flow](guides/move-to-postgres.md#move-the-brain)), or keep it on PGLite and share it through `gbrain mcp expose`. |+| A PGLite brain with history moving to Postgres with graduation turned off | `ask_user` | Relay `user_message`: graduation moves this brain (`gbrain config unset migrate.graduation`, then the [two-command flow](guides/move-to-postgres.md#move-the-brain)), or keep it on PGLite and share it through `gbrain mcp expose`. || A Postgres brain moving to PGLite | `report` | The brain stays on Postgres; moving down would drop its history. || A target that already holds persistence history | `tell_user_to_run` | Rerun with an empty database the user provides (`--path` for a PGLite target). |diff --git a/llms-full.txt b/llms-full.txtindex 04cc88e1f1..131e220e0e 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -5153,7 +5153,7 @@ The legacy copier handles every other direction: `gbrain migrate --to pglite`, P| Refusing side | `fix.next` | Next step ||---|---|---|-| A PGLite brain with history moving to Postgres with graduation turned off | `ask_user` | Relay `user_message`: graduation moves this brain (`gbrain config set migrate.graduation true`, then the [two-command flow](guides/move-to-postgres.md#move-the-brain)), or keep it on PGLite and share it through `gbrain mcp expose`. |+| A PGLite brain with history moving to Postgres with graduation turned off | `ask_user` | Relay `user_message`: graduation moves this brain (`gbrain config unset migrate.graduation`, then the [two-command flow](guides/move-to-postgres.md#move-the-brain)), or keep it on PGLite and share it through `gbrain mcp expose`. || A Postgres brain moving to PGLite | `report` | The brain stays on Postgres; moving down would drop its history. || A target that already holds persistence history | `tell_user_to_run` | Rerun with an empty database the user provides (`--path` for a PGLite target). |diff --git a/plugin-variants/gbrain-coding/skills/postgres-adopt/SKILL.md b/plugin-variants/gbrain-coding/skills/postgres-adopt/SKILL.mdindex 781d858655..c1e9e63cd6 100644--- a/plugin-variants/gbrain-coding/skills/postgres-adopt/SKILL.md+++ b/plugin-variants/gbrain-coding/skills/postgres-adopt/SKILL.md@@ -64,7 +64,7 @@ Branch on the output:belong to that host. Stop.- `effective_engine: null` (no brain) → Step 2.- `effective_engine: "pglite"` with data → Step 3.-- The output reports a graduation state other than `none` (in progress,+- The output has a `graduation` block whose `state` is not `none` (in progress,interrupted, graduated or split) → Step 4.## Step 2 — Fresh install, Postgres-firstdiff --git a/plugin-variants/gbrain-daily/skills/postgres-adopt/SKILL.md b/plugin-variants/gbrain-daily/skills/postgres-adopt/SKILL.mdindex 781d858655..c1e9e63cd6 100644--- a/plugin-variants/gbrain-daily/skills/postgres-adopt/SKILL.md+++ b/plugin-variants/gbrain-daily/skills/postgres-adopt/SKILL.md@@ -64,7 +64,7 @@ Branch on the output:belong to that host. Stop.- `effective_engine: null` (no brain) → Step 2.- `effective_engine: "pglite"` with data → Step 3.-- The output reports a graduation state other than `none` (in progress,+- The output has a `graduation` block whose `state` is not `none` (in progress,interrupted, graduated or split) → Step 4.## Step 2 — Fresh install, Postgres-firstdiff --git a/plugin/skills/postgres-adopt/SKILL.md b/plugin/skills/postgres-adopt/SKILL.mdindex 781d858655..c1e9e63cd6 100644--- a/plugin/skills/postgres-adopt/SKILL.md+++ b/plugin/skills/postgres-adopt/SKILL.md@@ -64,7 +64,7 @@ Branch on the output:belong to that host. Stop.- `effective_engine: null` (no brain) → Step 2.- `effective_engine: "pglite"` with data → Step 3.-- The output reports a graduation state other than `none` (in progress,+- The output has a `graduation` block whose `state` is not `none` (in progress,interrupted, graduated or split) → Step 4.## Step 2 — Fresh install, Postgres-firstdiff --git a/scripts/function-size-baseline.tsv b/scripts/function-size-baseline.tsvindex e1d00035bd..e534d2f562 100644--- a/scripts/function-size-baseline.tsv+++ b/scripts/function-size-baseline.tsv@@ -22,7 +22,7 @@ src/commands/extract.ts runExtract 398 seed: W5 baseline, refactor wave 1 (decomsrc/commands/import.ts runImport 972 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +4 GBRA-40 F4b: planner-stats refresh every import.analyze_every_pages files (logic in planner-stats.ts); +6 #5988: onFileResult hook so full sync holds content refusals (logic in commands/sync/holds.ts); +3 #5988: heldPaths skip so a full sync never imports a rename destination it held this run (logic in commands/sync/holds.ts)src/commands/mcp-expose.ts runPublish 443 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)src/commands/migrate-engine.ts runMigrateEngine 405 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)-src/commands/serve.ts installStdioLifecycle 315 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)+src/commands/serve.ts installStdioLifecycle 316 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +1 engine graduation (GBRA-50 G3): onShutdownReady hook for the graduation hand-off (logic in installGraduationHandoff)src/commands/sources.ts runAdd 365 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1); +3 fix wave 4 #5673: connector sources print that autopilot keeps them synced after the first syncsrc/core/ai/gateway.ts chat 311 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)src/core/bootstrap/harness.ts applyHarness 1167 seed: W5 baseline, refactor wave 1 (decomposition deferred to wave 2, plan D1)diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex c8d143f471..9380097824 100644--- a/scripts/module-size-limits.tsv+++ b/scripts/module-size-limits.tsv@@ -3,7 +3,7 @@# Raising a ceiling is a conscious, reviewer-visible act. Lower ceilings in# the same commit as any peel (the guard fails on >50 lines of stale slack).# Columns: path max_lines policy note-src/cli.ts 3199 ratchet +3 agent operator gate fixes: repair-failed connect wrapper (logic in cli/cli-error.ts exitOnRepairFailed), transcripts recent through a live serve (logic in commands/transcripts.ts), pre-connect status reason (logic in commands/serve-status.ts); +23 merged from the collector (Lanes B/E/F: thin-client token reason, status-only serve hand-off, jobs/sync readiness wiring); +9 agent operator wave D3/D4: curated --help short-circuit (renderer in cli/help/render.ts), curated flag-value validation call (cli/help/validate.ts), table-dispatched SELF_HELP_WITHOUT_ENGINE entries for the selfHelp flips; +5 agent operator wave C10 (merged from the collector): serve --fail-fast in the connect-failure path; +31 #5950 (D6): connectEngine thin-client backstop, engine-free MCP-twin dispatch, recall/advisor/export refusal hints, refusal fix subcommand (lowered to 3131 by D1's renderCliError seam first); +2 agent operator wave A4: observational startup (probe-only connect for startup:observational commands; completeEngineStartup split out of connectEngine, exposed as ctx.completeStartup); +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5232: write-wait import, reporter-owned verdict in the op catch, thin-client writeWaitMs, ctx.writeWaitMs (logic in persistence/write-wait.ts); +1 #4768: serve --access help line; +4 #5433: list_pages TSV cell escaping in formatResult; +2 #lane-h pricing: help line + thin-client refusal hint for `gbrain pricing`; +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5433: list_pages TSV cell escaping in formatResult; +1 #5984: a strict run deadline when no progress window is set; v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (3199 measured)+src/cli.ts 3205 ratchet +3 agent operator gate fixes: repair-failed connect wrapper (logic in cli/cli-error.ts exitOnRepairFailed), transcripts recent through a live serve (logic in commands/transcripts.ts), pre-connect status reason (logic in commands/serve-status.ts); +23 merged from the collector (Lanes B/E/F: thin-client token reason, status-only serve hand-off, jobs/sync readiness wiring); +9 agent operator wave D3/D4: curated --help short-circuit (renderer in cli/help/render.ts), curated flag-value validation call (cli/help/validate.ts), table-dispatched SELF_HELP_WITHOUT_ENGINE entries for the selfHelp flips; +5 agent operator wave C10 (merged from the collector): serve --fail-fast in the connect-failure path; +31 #5950 (D6): connectEngine thin-client backstop, engine-free MCP-twin dispatch, recall/advisor/export refusal hints, refusal fix subcommand (lowered to 3131 by D1's renderCliError seam first); +2 agent operator wave A4: observational startup (probe-only connect for startup:observational commands; completeEngineStartup split out of connectEngine, exposed as ctx.completeStartup); +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5232: write-wait import, reporter-owned verdict in the op catch, thin-client writeWaitMs, ctx.writeWaitMs (logic in persistence/write-wait.ts); +1 #4768: serve --access help line; +4 #5433: list_pages TSV cell escaping in formatResult; +2 #lane-h pricing: help line + thin-client refusal hint for `gbrain pricing`; +2 fix wave 5 (#5401): projections drain help line and thin-client hint; +2 (#5137) key-shadow warning seam, logic in ai/key-warnings.ts; +2 System One v1: decide help line + thin-client refusal hint; refactor wave 1 split target (W4 cli); ceiling rationale: docs/architecture/key-files/entrypoints-and-docs.md entry for src/cli.ts; evidence delivery: thin-client return_unit version-skew warning (+3; logic in search/evidence-delivery.ts); put stdin recovery (#5700): stdin hint in the --content requires-a-value error and stdin usage/required text in printOpHelp (+7); logic in persistence/deactivation.ts); +36 #5827: link-command help examples, local --source vs --source-id/--all-sources conflict check, ambient-binding return from applyThinClientSourceScope (logic in cli/source-scope.ts); +4 #5433: list_pages TSV cell escaping in formatResult; +1 #5984: a strict run deadline when no progress window is set; v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (3199 measured); +6 engine graduation (GBRA-50 G3): migrate pre-connect route (logic in commands/migrate-graduation.ts), serve start refusal and degraded-reconnect identity gate (logic in persistence/graduation-serve-guard.ts), usage linesrc/commands/autopilot.ts 1642 ratchet refactor wave 1 split target (W4 autopilot, cut line); ceiling rationale: docs/architecture/key-files/commands-1.md entry for src/commands/autopilot.ts; +2 fix wave 5: nosemgrep justifications on the per-brain job launchctl/systemctl calls (#5195); +2 #5813: boot reconcile names attempted and running versions in log + audit; +2 #5855: Bun floor gate before the swap and the swap-refusal hold (logic in core/bun-floor.ts); +3 agent operator wave E9: --dry-run and the persistent_install consent gate before anything is written (logic in autopilot/install-consent.ts)src/commands/doctor.ts 667 ratchet +1 agent operator gate fixes: --probe consent gate (logic in doctor/probe-consent.ts); refactor wave 1 split target (W4 doctor); ceiling rationale: docs/architecture/key-files/commands-2.md entry for src/commands/doctor.tssrc/commands/embed.ts 2219 ratchet +2 agent operator wave D2: --json failure envelope via writeCliError; lowered v0.46.26.0: embedBatchWithBackoff + retry cluster peeled to core/embed-retry.ts (core/commands layering fix); grown wave-g (#4530): per-model input-limit wiring; wave-k #3622 reimpl: --stale zero-progress failure quarantine; +29 #4668 (#4530): oversize-heal call sites in both --stale drains — kept low by peeling the healed-row remap to core/embed-oversize-heal.ts (shared with embed-stale.ts); +35 #4647 (refs #4599): per-tick timeout+abort on the single-flight lock heartbeat refresh (interval deliberately NOT unref'd); +122 refs #4599: stall-watchdog race around the drain + shared idempotent flushAndRelease + CLI stall exit mapping (watchdog machinery itself lives in core/embed-stall.ts); +12: adversarial-review hardening (healed_splits progress key + heal-tick comment); #5105: guarded derived projection preparation and read seals; #5105: conditional embedding installer wiring; archived eligibility: active-only dispatch with honest stranded-work reporting; explicit archived admission: live-source snapshots and honest refused-installation failures; +2 fw3: embed --stale --images dispatch (sweep lives in core/embed-stale-images.ts); +5 #5289: dry run reports restamp-only chunks apart from chunks to embed (count lives in core/embedding-invalidation.ts); +6 #4616: keep a partially refused batch in embedPageTexts and name the recovery command in failure samples (guard lives in core/ai/embedding-guard.ts); +5 #5226: embed summary counts distinct pages; +3 #5804: null projection snapshot counted as a failure with one batch summary in embed --stale; +18 wave 8 lane D1: #5527 mixed-space warning subtracts current-model chunks (+4), #5885 takes option/result fields and the stale-drain takes call (pass lives in core/embed-takes.ts); +9 Foundations 1 F4d: time-budget stop result fields, stdout verdict and stop recording in embed --stale (logic in core/embed-budget-stop.ts)@@ -36,7 +36,7 @@ src/core/embedding-migration.ts 1569 ratchet new row: crossed 1500 in v0.46.25.0src/core/github-source.ts 1530 ratchet new row: crossed the 1500 unlisted cap in v0.46.23.0 review fix wave (scope-state gating, client hardening, symlink containment); merged reliability/shared-skills source integration; managed sweep lease wrapper; fix wave 3 lane A: config parser peeled to github-source-config.ts (-47), +account pin wiring and pinned-installation refreshsrc/commands/hook.ts 1903 ratchet cathedral-5 heartbeat extraction offsets part of the BrainBench-seam growth; grown v0.46.26.0 megawave hooks-ipc (#4245); +108 monthly backup check: banner + gated session-start note + detached spawn (backup/status-file readers); +28 ship-review egress hardening: per-harness capture dispatch (capture-spec), memorable gate + receipt + relay block, fail-closed unscanned/newest-guess skips; +79 ambient-writeback WP4: hookStop bank step (gate -> bankWritebackTurn -> IPC flush; gate/bank logic live in core/facts + corpus-segments); +41 adversarial fix wave: wide-tail retry when the 128KB window misses the user turn, by-design heartbeat outcome classes, source-in-name banking; +11 #5413 session-end skips claude-cli self-transcripts; +11 #5701: hook lanes pass allowOversize so a long session reaches the bounded tail readsrc/core/chunkers/code.ts 1588 ratchet new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (decorated-python defs #3821, version-gate + timeout chunker fixes); grown wave-g (#4511): named defs never folded into merged chunks; grown #4669: skip WASM parse for languages without TOP_LEVEL_TYPES; +6 N13-1: CodeChunkMetadata.definesFunction field + merge-guard stamp (predicate lives in def-types.ts)-src/core/config.ts 1838 ratchet +8 #5988: sync.holds/hold_cap/hold_escalate_count/hold_escalate_pct/parser_regression key registration (read by persistence/sync-holds.ts); +3 agent operator wave A4: GBrainConfig.consent file-plane slot + 2 consent.preapprove.* key rows (logic in core/consent.ts); +1 System One v1: decide.* key prefix (validated by ai/decide/config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (spend-controls hint #3703, config-set validation); +3 wave G #3974: sync.include_working_tree key; grown wave-g (#4540 #4494 #4415): extractor caps + intent-pattern config keys; +1 chat-connectors: connectors. config prefix; wave-k: config-table snapshot serving the DB-plane reads (#3980 + #2119 merge); +8: loadConfig hook for ~/.gbrain/.env, loader lives in gbrain-env-file.ts (#3893); +17: litellm/together key-fold slots (#3904 reimpl: two GBrainConfig fields + KNOWN_CONFIG_KEYS rows); +1: link_resolution.cross_source key (#3908); +4 v0.47 gmail-loops: loops.extraction_enabled key; +1: pricing.overrides key (#4633 adoption); +7 #4667 adoption: sync.exclude key registration; +4: eval fix wave keys (quote_verify + 3 rescue knobs); +memorable file-plane key registration (integrations.memorable.enabled + consent-event doc); +33 ambient-writeback: memory.* + brain.audience key registration + GBrainConfig.memory mirror slot (resolvers live in facts/writeback-config.ts); +38 2026-08 wave: retrieval_reflex_volunteer key + env mapping (volunteer-arm kill switch) + E5a registration of the 10 adaptive_return*/autocut*/crag_* search (incl. adversarial batch isEnvDisabled dedup); ambient-writeback (master merge): facts/writeback-config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave; prior growth: sync/intent/chat-connectors/litellm/pricing/loops key folds; +34: #4702 content_sanity.disabled_patterns (type + DB-plane parse/merge + key registration); composition true-up (fix-wave multi-train) | merged v0.48.1.0: master #4788 writeback keys + wave #4702/#4748 keys; master: | merged v0.48.1.0 true-up; ranker wave v0.48.4.0: +4 KNOWN_CONFIG_KEYS rows (+8); +5 #4895: CWD_DOTENV_FILES gains the per-NODE_ENV .local variants Bun auto-loads; +2 #5003: sync.include_hidden key registration; +57 #4605: search.* registry reconciled to the keys mode.ts reads (+20 knob rows, +4 direct-read singletons) + GBrainConfig.search slot + adaptive_return* DB-plane merge; +2 pre-landing review: fts.reindex_in_progress key registration (#4795 marker escape hatch); +4 #4987: auto_timeline key registration (the documented off switch was rejected as unknown); lowered to 1793: GHSA wave v0.50.5.0 moved CWD_DOTENV_FILES + dotenvValuesForKey into core/env-trust.ts (-49, re-exported); re-summed to the merged line count after merging master v0.50.2.0 (#5122) with the v0.50.5.0 security wave; fix wave 3 x fix wave 2 (v0.60.5.0) composition: +1 at the merge; evidence delivery: 5 registered config keys + comment (+7); +2 #5691: embedding_query_prefix key registration; evidence delivery auto v2: search.return_budget_conversation key row (+1); +1 #5836: facts.entity_inference key row; +6 #5824: search.vector_legacy_guard key row + GBrainConfig.search slot + DB-plane merge; +3 wave 8 lane D1 #5885: takes.auto_embed key row; +3 #5232: GBrainConfig.persistence.write_wait_ms file-plane slot + key row (resolver in persistence/write-wait.ts); +2 F4b: planner.* and import.analyze_every_pages keys; +3 cat40 cost wave C1 (garrytan/gbrain-evals#57 follow-ups): mcp.result_rows GBrainConfig slot + key row (resolver in mcp/result-rows.ts); v0.60.46.0 merge: both waves' +3 compose (1824 + 3 = 1827 measured); +4 #5984: sync.bulk, sync.bulk_size, sync.bulk_max_txn_ms known keys; v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (1838 measured)+src/core/config.ts 1840 ratchet +8 #5988: sync.holds/hold_cap/hold_escalate_count/hold_escalate_pct/parser_regression key registration (read by persistence/sync-holds.ts); +3 agent operator wave A4: GBrainConfig.consent file-plane slot + 2 consent.preapprove.* key rows (logic in core/consent.ts); +1 System One v1: decide.* key prefix (validated by ai/decide/config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave (spend-controls hint #3703, config-set validation); +3 wave G #3974: sync.include_working_tree key; grown wave-g (#4540 #4494 #4415): extractor caps + intent-pattern config keys; +1 chat-connectors: connectors. config prefix; wave-k: config-table snapshot serving the DB-plane reads (#3980 + #2119 merge); +8: loadConfig hook for ~/.gbrain/.env, loader lives in gbrain-env-file.ts (#3893); +17: litellm/together key-fold slots (#3904 reimpl: two GBrainConfig fields + KNOWN_CONFIG_KEYS rows); +1: link_resolution.cross_source key (#3908); +4 v0.47 gmail-loops: loops.extraction_enabled key; +1: pricing.overrides key (#4633 adoption); +7 #4667 adoption: sync.exclude key registration; +4: eval fix wave keys (quote_verify + 3 rescue knobs); +memorable file-plane key registration (integrations.memorable.enabled + consent-event doc); +33 ambient-writeback: memory.* + brain.audience key registration + GBrainConfig.memory mirror slot (resolvers live in facts/writeback-config.ts); +38 2026-08 wave: retrieval_reflex_volunteer key + env mapping (volunteer-arm kill switch) + E5a registration of the 10 adaptive_return*/autocut*/crag_* search (incl. adversarial batch isEnvDisabled dedup); ambient-writeback (master merge): facts/writeback-config.ts); new row: crossed the 1500 unlisted cap in v0.46.26.0 megawave; prior growth: sync/intent/chat-connectors/litellm/pricing/loops key folds; +34: #4702 content_sanity.disabled_patterns (type + DB-plane parse/merge + key registration); composition true-up (fix-wave multi-train) | merged v0.48.1.0: master #4788 writeback keys + wave #4702/#4748 keys; master: | merged v0.48.1.0 true-up; ranker wave v0.48.4.0: +4 KNOWN_CONFIG_KEYS rows (+8); +5 #4895: CWD_DOTENV_FILES gains the per-NODE_ENV .local variants Bun auto-loads; +2 #5003: sync.include_hidden key registration; +57 #4605: search.* registry reconciled to the keys mode.ts reads (+20 knob rows, +4 direct-read singletons) + GBrainConfig.search slot + adaptive_return* DB-plane merge; +2 pre-landing review: fts.reindex_in_progress key registration (#4795 marker escape hatch); +4 #4987: auto_timeline key registration (the documented off switch was rejected as unknown); lowered to 1793: GHSA wave v0.50.5.0 moved CWD_DOTENV_FILES + dotenvValuesForKey into core/env-trust.ts (-49, re-exported); re-summed to the merged line count after merging master v0.50.2.0 (#5122) with the v0.50.5.0 security wave; fix wave 3 x fix wave 2 (v0.60.5.0) composition: +1 at the merge; evidence delivery: 5 registered config keys + comment (+7); +2 #5691: embedding_query_prefix key registration; evidence delivery auto v2: search.return_budget_conversation key row (+1); +1 #5836: facts.entity_inference key row; +6 #5824: search.vector_legacy_guard key row + GBrainConfig.search slot + DB-plane merge; +3 wave 8 lane D1 #5885: takes.auto_embed key row; +3 #5232: GBrainConfig.persistence.write_wait_ms file-plane slot + key row (resolver in persistence/write-wait.ts); +2 F4b: planner.* and import.analyze_every_pages keys; +3 cat40 cost wave C1 (garrytan/gbrain-evals#57 follow-ups): mcp.result_rows GBrainConfig slot + key row (resolver in mcp/result-rows.ts); v0.60.46.0 merge: both waves' +3 compose (1824 + 3 = 1827 measured); +4 #5984: sync.bulk, sync.bulk_size, sync.bulk_max_txn_ms known keys; v0.60.48.0 merge: #5984 growth re-summed over v0.60.47.0 (1838 measured); +2 engine graduation (GBRA-50 G3): GBrainConfig.migrate.graduation file-plane opt-out slot + key row (read by commands/migrate-graduation.ts)src/core/bootstrap/harness.ts 2711 ratchet +29 live-PGLite-serve lane: LIVE_SERVE refusal ahead of source resolution + unpinned --token hooks (CI e2e fix); +46 wave review: resolveHookSource dep (serve-parity resolver + federated grant), --source shape validation, loud SOURCE_UNRESOLVED instead of a silent 'default'; +10: #4574 parseCodexBlockBearer http_headers shape + legacy bearer_token fallback; +4 at megawave/wave-k merge; +codex hooks lane: step-7 codex hooks.json + config.toml trust pair, removeHarness arm; +234 ambient-writeback WP3: kind:'instructions' targets (plan/apply/converge-off/remove/status probes, OV-A4 override pre-check) — splice/render mechanics live in instructions-block.ts; +59 adversarial fix wave: registrar-mode block suppression, converge-failure receipt tracking, MCP-confirmed guard before block install; +26 round-3 fixes: codex-lane MCP-confirmed guard + smoke-rollback block strip; master: | merged v0.48.1.0 true-up; +41 #4897 resolveImplicitSource dep + defaultResolveImplicitSource: hooks/token/receipt bind to the serve's implicit default source when --source is omitted; +23 #4586 statusHarness live claude-code mcp verdict (URL mismatch or same-scope non-HTTP registration reads failed, receipt untouched); shared-skills integration on company-ingestion base; +18 #5671: logAmbientPostureNotes helper (registrar note moved out of applyHarness + pre-consent warning when an explicit private facts default meets the HTTP harness; text shared with doctor in facts/writeback-config.ts); +24 #5893: rotation grant carry wiring and its rotationCarry/withheldOperationsNote helpers (carry rules live in token-mint.ts carryLegacyGrant); +6 #5878: --refresh-skills flag and status epoch line (refresh logic lives in harness-skills.ts); +7 #4618 seat: HarnessFlags.seat field, --seat/--no-seat parse via hooks.ts parseSeatFlags, GBRAIN_SEAT in the hook envsrc/core/oauth-provider.ts 1236 ratchet new row: crossed the 1500 unlisted cap absorbing #3819 (DCR 400 invalid_client_metadata + scope filtering + custom-scheme redirect_uris + pseudo-scheme guard); merged v0.49: transactional grant enforcement shared with hosted grant policies; +1 #5222 resourceUrl optionsrc/core/ops/pages.ts 663 ratchet crossed the unlisted 1500 cap in the fix wave: pack-vocabulary enforcement on capture (#4721) + get_page alias follow (#4275) landed together; next growth should peel a pages-ops submodule; +3: alias hop reads the canonical in the owning source (ship-review); +5: explicit source_id liveness check in get_page/list_pages (#4620); +3: #4857 total-order slug sort + list_pages source_id parse; +5: #4620 explicit removed-source id fails loudly; master integration: +4: authenticated delegated private-write boundary and auto-link suppression; #5105: canonical page mutations peeled into persistence modules; +2 v0.50.5.0 purge parameter and shared preflight call; preparation composes through the persistence modules; +7: source-qualified deep-research fetch authorization and ambiguity refusal (codec lives in deep-research-id.ts); +1 #5567: remote get_page keeps materialized markers; +1 #5622: trusted local capture file parameter; +5 #5709: get_page include_timeline_entries (rows via get_timeline's read policy); +8 GBRA-36 security wave: required outputRedaction policy on each pages op; +1 #5154: list_pages passes listColumnsOnly; +17 #5641: list_pages exposes the updated_after_slug keyset cursor and updated_at_iso; +8 agent operator wave A2: every op declares mutating + idempotent (tags only); +7 F3b (#5954): list_pages pagination meta + listing_truncated notice for MCP callers (logic in ops/list-pages-pagination.ts); +4 #5988: get_page file_held (one indexed hold lookup; logic in persistence/held-reads.ts)diff --git a/skills/postgres-adopt/SKILL.md b/skills/postgres-adopt/SKILL.mdindex 781d858655..c1e9e63cd6 100644--- a/skills/postgres-adopt/SKILL.md+++ b/skills/postgres-adopt/SKILL.md@@ -64,7 +64,7 @@ Branch on the output:belong to that host. Stop.- `effective_engine: null` (no brain) → Step 2.- `effective_engine: "pglite"` with data → Step 3.-- The output reports a graduation state other than `none` (in progress,+- The output has a `graduation` block whose `state` is not `none` (in progress,interrupted, graduated or split) → Step 4.## Step 2 — Fresh install, Postgres-firstdiff --git a/skills/skills.lock.json b/skills/skills.lock.jsonindex 4a7d954dee..5c728e7189 100644--- a/skills/skills.lock.json+++ b/skills/skills.lock.json@@ -177,7 +177,7 @@"perplexity-research/routing-eval.jsonl": "f1a40d87e710d5d2acd602a372d83f46c95da022b6e635228fffeaacb3bb2b27","plugin-exclusions.json": "797782fd0647e06763febcbe6b8cb6715c717504628af84185cc345804087d35","plugin-lanes.json": "ec7fc44821c6a9b40c582db9b39026c84677d3fdd94657d983b7c5ea6216124e",- "postgres-adopt/SKILL.md": "b5df8bf7da596bc0b927ca6352f859c205cbd45577874d1228644c64066b094c",+ "postgres-adopt/SKILL.md": "44b7d29a135c23184794c82a2330a230fd45ae593d1cd519a75c90de8ad0e2b0","postgres-adopt/routing-eval.jsonl": "db91c1fae408a45082979c402c11eff413277ace6cf746297cc86009dcaefe06","publish/SKILL.md": "df87df3ab6c0e799f5dc88edaec7f6b4049c49bbee5525874fe24f1765c3028c","query/SKILL.md": "8905796d90cae85873cbb9fa6aacba47e51bb0f6037edb72d733981c47f83d3b",diff --git a/src/cli.ts b/src/cli.tsindex 56e047d5f4..ae1b38fbf4 100755--- a/src/cli.ts+++ b/src/cli.ts@@ -2062,14 +2062,8 @@ async function routeEngineFreeSubcommands(command: string, args: string[]): Promconst { tryRunConfigEngineFree } = await import('./commands/config.ts');if (await tryRunConfigEngineFree(args)) return true;}- // Engine graduation (PGLite -> Postgres) owns its connections: --plan and- // --status migrate neither schema, and the run holds the source's kernel- // lock itself. Everything else (`migrate embeddings`, `--to pglite`, the- // migrate.graduation=false opt-out) falls through to the post-connect record.- if (command === 'migrate') {- const { tryRunMigrateGraduation } = await import('./commands/migrate-graduation.ts');- if (await tryRunMigrateGraduation(args)) return true;- }+ // Engine graduation owns its connections (routing rules: commands/migrate-graduation.ts routesToGraduation).+ if (command === 'migrate' && await (await import('./commands/migrate-graduation.ts')).tryRunMigrateGraduation(args)) return true;if (command === 'mcp') {const { runMcp, mcpNeedsEngine } = await import('./commands/mcp.ts');if (!mcpNeedsEngine(args)) { await runMcp(args); return true; }@@ -2579,11 +2573,7 @@ async function connectCliOnlyEngine(command: string, args: string[]): Promise<Br// F4: a stdio serve with no brain / a missing or repair-failed brain / unreadable config// completes the MCP handshake in status-only mode instead of exiting (connectEngine exits).// Engine graduation (§6.4): a serve (re)launched while a run owns the host brain exits 75 with graduation_in_progress.- if (command === 'serve' && (dbMarkerBrainId() ?? 'host') === 'host') {- const guard = await import('./core/persistence/graduation-serve-guard.ts');- const running = guard.serveGraduationStartRefusal();- if (running) process.exit(guard.writeServeGraduationEnvelope(running));- }+ if (command === 'serve' && (dbMarkerBrainId() ?? 'host') === 'host') (await import('./core/persistence/graduation-serve-guard.ts')).exitIfGraduationRunning();const serveStatus = command === 'serve' ? await import('./commands/serve-status.ts') : null;const serveStatusEligible = !!serveStatus?.statusModeEligible(args, (dbMarkerBrainId() ?? 'host') === 'host');const preConnectReason = serveStatusEligible ? serveStatus!.preConnectStatusReason() : null;@@ -2643,8 +2633,7 @@ async function connectCliOnlyEngine(command: string, args: string[]): Promise<Brconsole.error(`${formatDbMarker(d)}\n${d.message}\n${d.remediation} Run: gbrain db-repair`);} catch { /* marker is best-effort; degraded serve still starts */ }const { createDegradedEngine } = await import('./core/degraded-engine.ts');- const { engineIdentity, exitOnEngineIdentityChange } = await import('./core/persistence/graduation-serve-guard.ts');- const startIdentity = engineIdentity();+ const graduationGate = (await import('./core/persistence/graduation-serve-guard.ts')).engineIdentityGate();const degraded = createDegradedEngine({initialError: serveConnectError,// Guarded reconnect: connectEngine's no-config path calls@@ -2654,7 +2643,7 @@ async function connectCliOnlyEngine(command: string, args: string[]): Promise<Br// through connectMountEngine before loadConfig() and needs no host// config, so the guard must not brick a mount serve's recovery.reconnect: async () => {- if ((dbMarkerBrainId() ?? 'host') === 'host') exitOnEngineIdentityChange(startIdentity);+ if ((dbMarkerBrainId() ?? 'host') === 'host') graduationGate();if ((dbMarkerBrainId() ?? 'host') === 'host' && !loadConfig()) {throw new Error('No brain configured (config.json missing or unreadable). Run: gbrain init');}diff --git a/src/commands/migrate-engine.ts b/src/commands/migrate-engine.tsindex b723a7cf50..83692bc235 100644--- a/src/commands/migrate-engine.ts+++ b/src/commands/migrate-engine.ts@@ -832,7 +832,7 @@ export async function quiesceAutopilot(engine?: BrainEngine): Promise<(() => voi* with migrate.graduation=false, or Windows. On Windows a brain with write* history gets graduation's platform refusal; a history-free brain copies here.*/-async function assertWindowsGraduationPlatform(sourceEngine: BrainEngine, opts: MigrateOpts, platform: NodeJS.Platform = process.platform): Promise<void> {+export async function assertWindowsGraduationPlatform(sourceEngine: BrainEngine, opts: Pick<MigrateOpts, 'targetEngine'>, platform: NodeJS.Platform = process.platform): Promise<void> {if (platform !== 'win32' || sourceEngine.kind !== 'pglite' || opts.targetEngine !== 'postgres') return;const { graduationOptedOut } = await import('./migrate-graduation.ts');if (graduationOptedOut(loadConfig())) return;diff --git a/src/commands/serve.ts b/src/commands/serve.tsindex 74028cf8dc..388a46fa53 100644--- a/src/commands/serve.ts+++ b/src/commands/serve.ts@@ -81,6 +81,8 @@ export interface ServeOptions {signals?: Pick<NodeJS.Process, 'on'>;exit?: (code?: number) => void;log?: (msg: string) => void;+ /** Receives the stdio lifecycle's drain-then-shutdown (the graduation hand-off uses it). */+ onShutdownReady?: (shutdown: (reason: string) => void) => void;// Test seam: replace startMcpServer to avoid booting the real MCP SDK// (which unconditionally attaches a 'data' listener to real// process.stdin and would pollute the test runner's stdin handle).@@ -349,7 +351,7 @@ export async function runServe(// the MCP client log "Failed to parse JSONRPC message" for every line.redirectStdoutLoggingToStderr();- const activateStdioIdleActivityTracking = installStdioLifecycle(engine, args, opts);+ const activateStdioIdleActivityTracking = installStdioLifecycle(engine, args, installGraduationHandoff(engine, opts));const start = opts.startMcpServer ?? startMcpServer;@@ -472,6 +474,37 @@ function resolveBootTimeoutMs(): number {return n * 1000;}+/**+ * Engine graduation hand-off (§13): a PGLite stdio serve polls (a stat every+ * 2 s) for another live run's intent marker. On one it writes the+ * graduation_in_progress envelope and takes the lifecycle's drain-then-shutdown+ * (in-flight requests finish, bounded; the engine closes and releases the+ * brain); the process exits 75 so a supervisor relaunch (which exits the same+ * way while the marker stands) is distinguishable from a clean stop.+ */+function installGraduationHandoff(engine: BrainEngine, opts: ServeOptions): ServeOptions {+ if (engine.kind !== 'pglite') return opts;+ const exit = opts.exit ?? ((code?: number) => { process.exit(code); });+ const log = opts.log ?? ((msg: string) => console.error(msg));+ let handoffExit: number | null = null;+ let shutdown: ((reason: string) => void) | null = null;+ const timer = setInterval(() => {+ if (handoffExit !== null || !shutdown || isEngineDegradedForServe(engine)) return;+ const request = graduationHandoffRequested();+ if (!request) return;+ clearInterval(timer);+ log('GBrain MCP server: an engine graduation run asked for this brain; handing it over.');+ handoffExit = writeServeGraduationEnvelope(request, (s) => log(s.trimEnd()));+ shutdown('graduation-handoff');+ }, GRADUATION_HANDOFF_POLL_MS);+ timer.unref?.();+ return {+ ...opts,+ exit: (code?: number) => exit(handoffExit ?? code),+ onShutdownReady: (fn) => { shutdown = fn; opts.onShutdownReady?.(fn); },+ };+}+interface StdioLifecycleDeps {stdin: NodeJS.ReadableStream & { isTTY?: boolean };signals: Pick<NodeJS.Process, 'on'>;@@ -502,8 +535,6 @@ function installStdioLifecycle(let shuttingDown = false;let parentWatchdog: unknown = null;let idleSweepTimer: unknown = null;- let graduationHandoffTimer: ReturnType<typeof setInterval> | null = null;- let shutdownExitCode = 0;let activateIdleActivityTracking = (): void => {};const beginShutdown = (reason: string): void => {if (shuttingDown) return;@@ -523,10 +554,6 @@ function installStdioLifecycle(deps.clearInterval(idleSweepTimer);idleSweepTimer = null;}- if (graduationHandoffTimer !== null) {- clearInterval(graduationHandoffTimer);- graduationHandoffTimer = null;- }deps.log(`GBrain MCP server: graceful exit (${reason})`);@@ -576,26 +603,10 @@ function installStdioLifecycle(}).finally(() => {if (deadline) clearTimeout(deadline);- deps.exit(shutdownExitCode);+ deps.exit(0);});};- // Engine graduation hand-off (§13): a live run's intent marker asks the PGLite- // serve that holds the brain to finish, release the lock and exit 75 so the- // run can take the brain; a relaunched serve then exits the same way. A real- // unref'd timer (a stat per tick), separate from the injectable lifecycle timers.- if (engine.kind === 'pglite') {- graduationHandoffTimer = setInterval(() => {- if (shuttingDown || isEngineDegradedForServe(engine)) return;- const request = graduationHandoffRequested();- if (!request) return;- deps.log(`GBrain MCP server: an engine graduation run asked for this brain; handing it over.`);- shutdownExitCode = writeServeGraduationEnvelope(request, (s) => deps.log(s.trimEnd()));- drainThenShutdown('graduation-handoff');- }, GRADUATION_HANDOFF_POLL_MS);- graduationHandoffTimer.unref?.();- }-// Signal-based termination. SIGTERM: daemon ask. SIGINT: user Ctrl-C.// SIGHUP: terminal disconnect / daemon-style "reload" channels — Aragorn// observed real-world hosts (Claude Desktop on macOS, hermes-agent@@ -660,6 +671,7 @@ function installStdioLifecycle(beginShutdown(reason);})();};+ opts.onShutdownReady?.(drainThenShutdown);if (!deps.stdin.isTTY && !mcpStdioMode) {deps.stdin.once('end', () => drainThenShutdown('stdin-end'));deps.stdin.once('close', () => drainThenShutdown('stdin-close'));diff --git a/src/core/config.ts b/src/core/config.tsindex 7ec614e81a..f80673b1cb 100644--- a/src/core/config.ts+++ b/src/core/config.ts@@ -71,8 +71,7 @@ export interface GBrainConfig {backup?: { check_enabled?: boolean | string; check_interval_days?: number | string };/** #5232: CLI write wait in ms (file plane; persistence/write-wait.ts). */persistence?: { write_wait_ms?: number | string };- /** Engine graduation opt-out (`migrate.graduation false` uses the legacy copier); file plane, read pre-connect. */- migrate?: { graduation?: boolean };+ migrate?: { graduation?: boolean }; // `migrate.graduation false`: legacy copier instead of graduation (file plane, read pre-connect)/** A4 user preapprovals (file plane only; set by the trusted local CLI; read by core/consent.ts). */consent?: { preapprove?: { paid?: { max_usd_per_run?: number }; persistent_install?: boolean } };database_url?: string;diff --git a/src/core/persistence/graduation-serve-guard.ts b/src/core/persistence/graduation-serve-guard.tsindex 02c124eb10..bed2ed5598 100644--- a/src/core/persistence/graduation-serve-guard.ts+++ b/src/core/persistence/graduation-serve-guard.ts@@ -96,6 +96,18 @@ export function exitOnEngineIdentityChange(startIdentity: string | null, opts: {}}+/** `gbrain serve` startup: exit 75 with the envelope on stderr when another live run owns the host brain. */+export function exitIfGraduationRunning(exit: (code: number) => void = (code) => { process.exit(code); }): void {+ const running = serveGraduationStartRefusal();+ if (running) exit(writeServeGraduationEnvelope(running));+}++/** The degraded serve's reconnect gate: captures the identity now, checks it on each call. */+export function engineIdentityGate(): () => void {+ const start = engineIdentity();+ return () => exitOnEngineIdentityChange(start);+}+/** A resident PGLite serve should hand the brain over: a live graduation run (not this process) wrote its marker. */export function graduationHandoffRequested(cfg: GBrainConfig | null = loadConfig()): OperationError | null {return serveGraduationStartRefusal(cfg);diff --git a/test/fixtures/goldens/cli/dispatch-phase.json b/test/fixtures/goldens/cli/dispatch-phase.jsonindex e69877c3c1..3a74a53066 100644--- a/test/fixtures/goldens/cli/dispatch-phase.json+++ b/test/fixtures/goldens/cli/dispatch-phase.json@@ -1102,15 +1102,13 @@"phase": "post-connect","preConnectRules": [{- "condition": "command === 'migrate'",+ "condition": "command === 'migrate' && await (await import('./commands/migrate-graduation.ts')).tryRunMigrateGraduation(args)","connectsEngine": false,"refusesThinClient": false,"routesThinClient": false,- "terminates": false,+ "terminates": true,"thinClientCheck": false,- "unconditionalFor": [- "migrate"- ]+ "unconditionalFor": []}],"thinClient": "refuse",diff --git a/test/migrate-graduation-windows.test.ts b/test/migrate-graduation-windows.test.tsnew file mode 100644index 0000000000..98d000dc70--- /dev/null+++ b/test/migrate-graduation-windows.test.ts@@ -0,0 +1,40 @@+/**+ * On Windows, PGLite -> Postgres keeps the legacy copier for history-free+ * brains and refuses brains with write history with+ * graduation_unsupported_platform, before the legacy copier's own refusals.+ * Other platforms and other directions are untouched.+ */+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';+import { PGLiteEngine } from '../src/core/pglite-engine.ts';+import type { BrainEngine } from '../src/core/engine.ts';+import { assertWindowsGraduationPlatform } from '../src/commands/migrate-engine.ts';++let engine: PGLiteEngine;++beforeAll(async () => {+ engine = new PGLiteEngine();+ await engine.connect({ engine: 'pglite' });+ await engine.initSchema();+});++afterAll(async () => {+ await engine.disconnect();+});++describe('Windows engine migration routing', () => {+ test('a history-free PGLite brain passes on win32 (legacy copier proceeds)', async () => {+ await assertWindowsGraduationPlatform(engine as unknown as BrainEngine, { targetEngine: 'postgres' }, 'win32');+ });++ test('a brain with write history is refused with graduation_unsupported_platform on win32 only', async () => {+ const withHistory = {+ kind: 'pglite',+ executeRaw: async (sql: string) => (sql.includes('information_schema') ? [{ name: 'persistence_requests' }] : [{ present: true }]),+ } as unknown as BrainEngine;+ let code: string | undefined;+ try { await assertWindowsGraduationPlatform(withHistory, { targetEngine: 'postgres' }, 'win32'); } catch (e) { code = (e as { code?: string }).code; }+ expect(code).toBe('graduation_unsupported_platform');+ await assertWindowsGraduationPlatform(withHistory, { targetEngine: 'postgres' }, 'linux');+ await assertWindowsGraduationPlatform(withHistory, { targetEngine: 'pglite' }, 'win32');+ });+});