Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
revert: keep tokenmax as the chat-key recommendation (GBRA-81 item 1 flip not shipped)
garrytana5044b1d0802
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7350dd6647..636f81224c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,7 +15,6 @@ identifiers and attribution are available in the pre-removal Git revision### Itemized changes- **`query` expands only when the search mode says so (GBRA-81 item 1b).** The `query` operation used to send `expand: true` on every call, so every mode, `balanced` included, made one expansion LLM call before retrieval. It now leaves `expand` unset unless the caller passes it, so the resolved mode decides: on in `tokenmax`, off in `balanced` and `conservative`. `expand: true` (CLI `--expand`) forces it and `expand: false` (`--no-expand`) skips it; `gbrain config set search.expansion true` restores it by default for a brain, and a `search.expansion` value set earlier, which `query` ignored, now takes effect. The expander stays wired whenever expansion can resolve on, so `tokenmax` still expands. CRAG's caller-expanded check reads `expansion_applied`; eval capture records the raw `expand` param (null when unset) and `gbrain eval replay` maps null to the mode default. The tool description, the concept-search hint, `gbrain search modes`, `search tune`, top-level help, the picker copy and the docs say the same, and a guard test rejects "in every mode" / "always expands" phrasing in `src/` and `docs/`. `test/search/operation-expansion-contract.serial.test.ts` is rewritten to pin the new contract.-- **`gbrain init` recommends `balanced` (GBRA-81 item 1).** The picker recommends `balanced` for brains with a chat key, Opus-class models included. Measured evidence: on LongMemEval-S (direct harness, top 5) `balanced` found every gold session for 451 of 470 questions and `tokenmax` for 442. New `balanced` installs do not run the paid nightly conversation-parser probe, which `tokenmax` turns on; that coupling is kept. Existing brains keep their mode; a brain on picker-chosen `tokenmax` gets one owner-only `search_mode_coaching` notice (CLI and stdio MCP, never HTTP, once per brain, muteable) naming what switching changes, with `gbrain config set search.mode balanced` as an ask-first fix.- **`gbrain init` reads keys the way the gateway does.** Provider keys are read through `mergedProviderEnv`, so a key saved in `~/.gbrain/config.json` counts, and a brain with a ready reranker but no chat key gets `balanced` instead of `conservative` (the reranker branch uses `rerankerReadiness`, not a key name); `conservative` stays for a Haiku subagent or when neither a chat key nor a ready reranker exists.- **`gbrain init --search-mode <mode>` and `search.mode_source`.** An agent that knows the operator's choice records it at install time: no recommendation, no first-run `search_mode` ask, `search.mode_source: operator`. On a brain with a different mode it refuses unless `--force`. Picker choices record `auto`; `gbrain config set search.mode` records `operator`.- **One source for the mode advice.** `src/core/search/mode-advice.ts` holds the recommendation, its reasons and evidence, the `[AGENT]` and upgrade banners, init's first-run decision text and the cost matrix, now priced for Haiku 5.5, Sonnet 5.5 and Opus 5.5 from `src/core/model-pricing.ts` (about a 200x corner-to-corner spread). `INSTALL_FOR_AGENTS.md` Step 3.5 carries the generated matrix, kept in sync by a test. Switching modes no longer promises a cache refill while semantic result caching is off.diff --git a/INSTALL_FOR_AGENTS.md b/INSTALL_FOR_AGENTS.mdindex ca23d3ec37..0456b89124 100644--- a/INSTALL_FOR_AGENTS.md+++ b/INSTALL_FOR_AGENTS.md@@ -228,9 +228,9 @@ loop; full reference in `docs/ENGINES.md` ("Engine detection and access repair")## Step 3.5: Confirm search mode with the user (DO NOT SKIP)This is the `search_mode` decision from the first-run bundle.-`gbrain init` auto-applied a default search mode: `balanced`, unless your-subagent tier is Haiku-class or there is neither a chat key (Anthropic, OpenAI-or Google) nor a ready reranker, in which case `conservative`. The init output+`gbrain init` auto-applied a default search mode: `tokenmax` with a chat key+(Anthropic, OpenAI or Google), `balanced` with a ready reranker but no chat key,+and `conservative` when your subagent tier is Haiku-class or neither exists. The init outputincluded the cost matrix below preceded by `[AGENT]` markers. You must NOTsilently accept the default. Stop and ask the operator.@@ -266,12 +266,10 @@ Estimated downstream input cost of the retrieved payload @ 10K queries/mo:> 1) conservative — tight 4K budget, 10 chunks max, no reranker.> Best for Haiku subagents, cost-sensitive setups, high-volume loops.>-> 2) balanced (recommended default) — 12K budget, 25 chunks, reranked.-> On LongMemEval-S it found every gold session for 451 of 470 questions,-> against 442 for tokenmax.+> 2) balanced — 12K budget, 25 chunks, reranked.>-> 3) tokenmax — no budget, 50 chunks, reranked, `gbrain query` expands by-> default. The widest retrieval, for low-volume high-stakes work.+> 3) tokenmax (recommended with a chat key) — no budget, 50 chunks, reranked,+> `gbrain query` expands by default. The widest retrieval.>> Expansion follows the mode for `gbrain query` only: on in `tokenmax`, off in> `balanced` and `conservative`; `--expand` (`expand: true` over MCP) forces itdiff --git a/docs/architecture/key-files/commands-4-continued.md b/docs/architecture/key-files/commands-4-continued.mdindex 7500226a01..41544b7a93 100644--- a/docs/architecture/key-files/commands-4-continued.md+++ b/docs/architecture/key-files/commands-4-continued.md@@ -27,7 +27,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `src/commands/reindex-search-vector.ts` — `gbrain reindex-search-vector [--dry-run] [--yes] [--json]`. Escape hatch for changing `GBRAIN_FTS_LANGUAGE` after the `configurable_fts_language` migration has run (the migration shows applied and is skipped): recreates `update_page_search_vector` + `update_chunk_search_vector` with the configured language through `pageSearchVectorTriggerFnSql`/`chunkSearchVectorTriggerFnSql` (`fts-language.ts`; they KEEP the `SET search_path = pg_catalog, public` hardening, which CREATE OR REPLACE resets) — then backfills `pages` and `content_chunks` through `src/core/search-vector-backfill.ts` in id-keyset batches of `BACKFILL_BATCH_SIZE` (5000). Pages: an UPDATE-to-self of `id` reads each batch (`RETURNING id, timeline, knowledge_revision`; row locks only for that statement), the timeline is sanitized with `sanitizeRemoteBody` as the seal does, and one `UPDATE … FROM unnest(…)` writes `search_vector` through `pageSearchVectorSql` (the seal's own expression), guarded by the revision read, so a page edited in between is skipped (its seal reindexes it) and private, withdrawn, takes or malformed fence text never enters the vector. Chunks: direct vector recompute via `UPDATE … WHERE id IN (SELECT … LIMIT n) RETURNING id`. It then replaces `idx_facts_fts` (v237) under the language through `ensureFactsFtsIndex` (`src/core/facts/fts-index.ts`): the new index is built beside the old one (CONCURRENTLY on Postgres) and renamed into place, so writes never wait and search keeps an index (no row rewrite). Both stream phases `reindex_search_vector.pages`/`.chunks` through the shared progress reporter (stderr). Consent gate (agent operator wave C2): `requireConsent` (effect `destructive`, not plan-bound: derived index, the undo is a re-run under the previous language) — `--yes` or a TTY prompt; `--json` never implies it, and a refusal changes nothing, returns `status: 'confirmation_required'` and exits 3 with the consent payload. Interrupted-run safety: stamps `fts.reindex_in_progress` (= target language, key exported as `FTS_REINDEX_MARKER_KEY` from `fts-language.ts`) in the config table BEFORE the autocommitted DDL and clears it only after both backfills return; each batch persists its keyset cursor under `backfill.fts_pages.last_id` / `backfill.fts_content_chunks.last_id` (the `checkpointKey` convention from `backfill-base.ts`), so a re-run with the same language resumes from the checkpoint and a different language resets it. Deliberately not one `engine.transaction()` (whole-run row locks on Postgres, zero banked progress on a hang). Idempotent. Pinned by `test/reindex-search-vector.serial.test.ts` and `test/reindex-search-vector-pages.serial.test.ts`.-- `src/commands/init-mode-picker.ts` — install-time mode recommendation and mandatory operator choice. `recommendModeFor` recommends `balanced`, `conservative` only for a Haiku subagent or when there is neither a chat key nor a ready reranker; `resolveModePickerInputs` reads keys through `mergedProviderEnv` (so `~/.gbrain/config.json` keys count) and the reranker through `rerankerReadiness`. `gbrain init --search-mode <mode>` (`searchModeChoiceFromArgs`) records the operator's choice, suppresses the first-run `search_mode` ask and refuses on a brain with another mode unless `--force`; picker choices record `search.mode_source: auto`, explicit ones `operator`. Reasons, the `[AGENT]` banner and the cost matrix come from `src/core/search/mode-advice.ts`. Pinned by `test/init-mode-picker.test.ts`.+- `src/commands/init-mode-picker.ts` — install-time mode recommendation and mandatory operator choice. `recommendModeFor` recommends `tokenmax` with a chat key, `balanced` with a ready reranker and no chat key, and `conservative` for a Haiku subagent or when neither exists; `resolveModePickerInputs` reads keys through `mergedProviderEnv` (so `~/.gbrain/config.json` keys count) and the reranker through `rerankerReadiness`. `gbrain init --search-mode <mode>` (`searchModeChoiceFromArgs`) records the operator's choice, suppresses the first-run `search_mode` ask and refuses on a brain with another mode unless `--force`; picker choices record `search.mode_source: auto`, explicit ones `operator`. Reasons, the `[AGENT]` banner and the cost matrix come from `src/core/search/mode-advice.ts`. Pinned by `test/init-mode-picker.test.ts`.- `src/core/embedding-migration-cli.ts` — pure, positive migration control contract, shared by the pre-engine CLI boundary and the command parser (re-exported by `commands/migrate-embeddings.ts`). Validates original argv as well as command arguments, so consumed global timeout/progress flags cannot evade validation. Unknown controls, unsupported equals forms, duplicate flags, missing values, invalid numeric ranges and unknown pace modes refuse rather than falling back, truncating, clamping or widening work. Only implemented globals are accepted; no new fact-only or deadline behavior. The flag-registry generator includes this peeled surface; the registry's embed/import unions do not define migration legality.- `test/migrate-embeddings-recovery-cli.serial.test.ts` — real migration CLI subprocesses over isolated synthetic PGLite brains. Pins recovery envelopes and private-safe help/stderr, then exercises unsupported scope/work flags, consumed timeout, malformed numeric controls, supported pacing/globals/status/help, zero dispatch and unchanged DB/config snapshots on both routes. Direct parser cases use the same adversarial matrix. Help directs deferred work back through the migration with the existing total authorization, never standalone/background embedding. The static `EMBEDDING_MIGRATION_RECOVERY` is shared with the local-only admin operation; its unchanged discriminators and restrictions remain covered by `test/migrate-embeddings-op-contract.serial.test.ts`. Archived pending projections still block destructive transitions; no silent restore or source exclusion is introduced.diff --git a/docs/architecture/key-files/core-search-1.md b/docs/architecture/key-files/core-search-1.mdindex 2a6f11bd1a..ea548d2052 100644--- a/docs/architecture/key-files/core-search-1.md+++ b/docs/architecture/key-files/core-search-1.md@@ -60,8 +60,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `src/core/search/metadata-boost-gate.ts` — the ONE parse + decision contract for `search.metadata_boost_gate` (`always` | `lexical`; every bundle is `lexical`, `DEFAULT_METADATA_BOOST_GATE` stays `always` so a knobs literal without the field keeps its pre-wave hash identity). `lexicalArmsVoted` answers "did a strict keyword, title-phrase or relational row fuse?" from the composed fusion lists (relaxed OR-fallback rows do not count — they are already demoted); `decideMetadataBoosts({gate, lexicalVoted})` returns `{gate, lexical_voted, boosts_applied, reason: 'gate_always'|'lexical_voted'|'vector_only_voter'|'image_modality'}`. Image-modality queries are exempt from the gate: `hybridSearch` never runs the keyword / title arms for an image query and excludes the relational arm, so their lexical arms never vote by construction and `lexical` would silently disable the boosts for the whole modality — the caller passes `modality` (from `effectiveModality`) and an image decision applies the boosts as before (reason `image_modality`). Under `lexical`, `hybridSearch` passes `skipMetadataBoosts` into `runPostFusionStages` so the backlink, salience, recency (+chronicle), graph-signal and alias-resolved boosts are skipped when the vector arm was the only voter; supersede downrank, exact-match boost, title-phrase boost, compiled-truth boost, cosine re-score, dedup, reranker and autocut are untouched either way. Receipt (Cat 13 conceptual recall, sibling repo): the E1 localization showed hub pages carrying 1.03–1.12x backlink / graph-adjacency / recency boosts over gold concept pages that carried none whenever both lexical arms were empty; the pre-registered E3 held-out arm moved gbrain from 53.0 to 57.8 nDCG@5 (rule ≥ 57.0) with NamedThingBench, BrainBench, the retrieval canary and the LongMemEval dev slice byte-identical, so the gate flipped to `lexical` in all three bundles. The decision is surfaced as `HybridSearchMeta.metadata_boost_gate` (`--explain`); knobs-hash part `mbg=`; override chain per-call `metadataBoostGate` → config → bundle (`normalizeMetadataBoostGate` is the shared parser, garbage falls through). Pinned by `test/search/metadata-boost-gate.test.ts` (pure contract, hash participation, resolution chain) and `test/search/metadata-boost-gate-hybrid.test.ts` (hermetic PGLite hub-vs-gold corpus: `always` reproduces the hub-first regression, the default yields gold-first, config and per-call planes, unparseable falls through).- `src/core/search/mode.ts` — Named search-mode bundles and retained semantic-cache key machinery; persisted result reuse remains disabled. `MODE_BUNDLES` (conservative/balanced/tokenmax) and the resolution chain (per-call `SearchOpts` → per-key `search.*` config → bundle → balanced fallback) resolve every search knob; `knobsHash` folds registered search knobs into the `query_cache` key, and `KNOBS_HASH_VERSION` (exported from this file — the single source of truth for the current cache-key version) is bumped whenever a new knob shapes results so stale cache rows become unreachable. `graph_signals: boolean` knob in `ModeBundle` (defaults: `conservative=false`, `balanced=true`, `tokenmax=true`). `KNOBS_HASH_VERSION` appends a `gs=` parts entry per the cache-key contamination convention so a graph-on cache write can't be served to a graph-off lookup. `SearchKeyOverrides` + `SearchPerCallOpts` + `loadOverridesFromConfig` + `SEARCH_MODE_CONFIG_KEYS` + `resolveSearchMode` + `attributeKnob` all carry the field. Opt-out: `gbrain config set search.graph_signals false`. `query_cache` rows written under an older hash version hash differently — natural row segregation, cleared within `cache.ttl_seconds` (3600s default). `title_boost: number | undefined` knob in `ModeBundle` (default `1.25` for all three modes; multiplier for the post-fusion title-phrase boost). Override chain: per-call `SearchOpts` → `search.title_boost` config (clamped `[1.0, 5.0]`) → bundle. `KNOBS_HASH_VERSION` appends a `tib=` parts entry so a title-boost-on cache write can't be served to a title-boost-off lookup. `SEARCH_MODE_CONFIG_KEYS` gains `search.title_boost`. Cross-modal knobs in `ModeBundle`: `cross_modal_both_text_weight`/`cross_modal_both_image_weight` (weighted RRF for 'both' modality, defaults 0.6/0.4), `image_query_text_refinement_weight`/`image_query_image_refinement_weight` (hybrid intersect for `searchByImage` query refinement, defaults 0.4/0.6), `unified_multimodal` + `unified_multimodal_only` (unified-column routing flags), `cross_modal_llm_intent` (opt-in LLM escalation). `KNOB_CONFIG_KEY` (a `Record<keyof ModeBundle, string>`, so every knob names the `search.*` key `loadOverridesFromConfig` reads it from) is the single knob→key map: `SEARCH_MODE_CONFIG_KEYS` derives from it, `attributeKnob` prints it as the override `source_detail`, and `KNOWN_CONFIG_KEYS` in `config.ts` hand-mirrors it (config.ts stays import-light; `test/config-search-registry.test.ts` pins the two equal), and the modality knobs participate in `knobsHash` so a cached text-mode result can't be served to an image-mode caller. Retrieval-quality knobs `autocut_min_top` (default 0.35 in all three bundles; config `search.autocut_min_top`; folds into `knobsHash` as an `acm=` part) and `evidence_cosine_floor` (default 0.8 in all three bundles; config `search.evidence_cosine_floor`; labels evidence — result-set-shape-neutral, so not hashed) ride the same bundle → config → per-call chain. `keywordOrFallback: boolean` knob in `ModeBundle` (default true in all three bundles; config `search.keywordOrFallback`): the keyword arm's AND→OR zero-recall retry — corpora the FTS config can't stem (CJK/agglutinative text under `'english'`) can turn it off because the OR retry has no IDF demotion and its common-token hits read as noise in the RRF blend; folds into `knobsHash` as a `kof=` part. `KnobsHashContext` additionally carries the EFFECTIVE per-call salience/recency boost modes (`sal=`/`rec=` — explicit `SearchOpts` ?? the classifier's auto-suggestion, resolved by the same chain bare `hybridSearch` uses) and the per-engine `search.intent_patterns` config fingerprint (`ipat=`, from `query-intent.ts`'s `intentPatternFingerprint`; threaded through ctx, never read process-globally, so a multi-engine process can't key one brain's rows under another brain's patterns) — a reordered or reclassified write can never serve a differently-configured lookup. Cache HITS slice the stored page to the same resolved result count as misses (per-call `limit` → the mode's `searchLimit`) in `hybridSearchCached`, so a mode's result-count knob holds on both paths; nonzero offsets (positive OR negative) skip the cache entirely. `expansion_variant_budget: number | null` knob in `ModeBundle` (`null` in all three bundles; config `search.expansion_variant_budget` accepts `legacy`/`null` or a number in (0, 4] through the ONE range contract `normalizeExpansionVariantBudget` in `fusion-lists.ts` — out-of-range falls through to the bundle; per-call `HybridSearchOpts.expansionVariantBudget`, normalized by the same function in both the inner search and the cache resolver): the total RRF weight the NON-EMPTY expansion variant/clause lists share at fusion (`weight_i = b / n_voting_arms`; the original list always keeps weight 1), `null` = legacy weight 1 on every list (byte-identical fusion), a no-op when `expansion` is off. It folds into `knobsHash` as the last, append-only `evb=` part (`legacy` or the budget to 3 decimals) — `KNOBS_HASH_VERSION` is 29 with that part in — so a budget-weighted write can never serve a legacy lookup. `KNOB_NULL_LABELS` + `formatKnobValue` in `modes-report.ts` render its legitimate null as `legacy (null)` in `gbrain search modes` (plain `(undefined)` stays reserved for genuinely unset knobs). `relational_rerank_pin: number` knob in `ModeBundle` (3 in all three bundles — a no-op under `conservative`, which has no reranker; config `search.relational_rerank_pin` accepts `off`/`0` or an integer in [0, 10] through the ONE range contract `normalizeRelationalRerankPin` in `relational-rerank-pin.ts`, out-of-range falls through to the bundle; per-call `SearchOpts.relationalRerankPin`, normalized by the same function in both the inner search and the cache resolver): how many relational-arm rows `pinRelationalRows` re-pins above the reranked text rows after `applyReranker`. It folds into `knobsHash` as the append-only `rrp=` part, riding `KNOBS_HASH_VERSION` 29 together with `evb=` (one bump per wave — both parts landed before v29 shipped; a partial-knobs literal without the field hashes as the bundle default), so a pin-3 write can never serve a pin-0 lookup. Pinned by `test/search-mode.test.ts` (bundle snapshots + hash pins), `test/search/knobs-hash-reranker.test.ts` (the version comment chain), `test/config-adaptive-return-keys.test.ts`, `test/search/modes-report-coverage.test.ts`.-- `src/core/search/mode-advice.ts` — the one source of the search-mode recommendation (`RECOMMENDED_SEARCH_MODE`, `MODE_REASONS`, the measured `BALANCED_EVIDENCE`) and the copy that states it: the downstream-input cost matrix priced from `model-pricing.ts` (`costMatrixLines`, `costMatrixSentence` for init's first-run decision), the picker's `[AGENT]` banner, the post-upgrade banner and `QUERY_EXPANSION_LINE`; `search.mode_source` (`auto` | `operator`). `INSTALL_FOR_AGENTS.md` Step 3.5 carries the matrix verbatim (pinned by `test/init-mode-picker.test.ts`).-- `src/core/search/mode-coaching.ts` — the owner-only `search_mode_coaching` notice for a brain on picker-chosen `tokenmax` (no `search.mode_source: operator`): once per brain across the CLI (stderr, `cli/main.ts`) and the stdio MCP pipe (`mcp/dispatch.ts`), never HTTP, through `claimBrainNoticeMarker` beside the behavior-change markers; muteable; its fix is `gbrain config set search.mode balanced` as an `ask_user`. Pinned by `test/search-mode-coaching.serial.test.ts`.+- `src/core/search/mode-advice.ts` — the one source of the search-mode recommendation (`RECOMMENDED_SEARCH_MODE`, `MODE_REASONS`) and the copy that states it: the downstream-input cost matrix priced from `model-pricing.ts` (`costMatrixLines`, `costMatrixSentence` for init's first-run decision), the picker's `[AGENT]` banner, the post-upgrade banner and `QUERY_EXPANSION_LINE`; `search.mode_source` (`auto` | `operator`). `INSTALL_FOR_AGENTS.md` Step 3.5 carries the matrix verbatim (pinned by `test/init-mode-picker.test.ts`).- `src/core/search/modes-report.ts` — `buildModesReport(engine)` → `SearchModesReport` (`schema_version: 2`), the read-only dashboard behind `gbrain search modes` and the `search_modes` MCP op: `active_mode` + validity, the per-knob `resolved` attribution (`attributeKnob` over `KNOB_DESCRIPTIONS`, including the five `reranker_*` knobs), the three frozen `bundles`, `config_keys`, and `reranker_readiness` — `{model, enabled, ready, required_key, key_present, self_hosted, fix}` from `rerankerReadinessForEngine` + `describeRerankerFix` (a thrown readiness check still yields a `ready: false` verdict whose `fix` says to run `gbrain doctor`; the block never vanishes silently). `redactReadinessForRemote(report)` is what the `search_modes` op returns when `ctx.remote !== false`: `required_key`, `key_present` and `fix` are dropped and `self_hosted` is forced false — which env vars exist on the host is fingerprinting data and the fix names them; `ready` stays because it is observable anyway (reranked results carry `rerank_score`). `src/commands/search.ts:formatModesText` renders the runtime `Reranker:` line (`off (resolved) — …` / `<model> (enabled) — <KEY> present` / `<model> (enabled but NOT running) — <fix>`) and a per-bundle `reranker=… topNIn=… autocut=…` line. Pinned by `test/modes-report-reranker.test.ts`. The CLI dashboard leads with command-specific expansion: `query` follows the mode's expansion default (on in `tokenmax`) unless the call passes `expand`, while `search` is off. It discloses provider prerequisites/text flow and distinguishes retained bundle configuration from effective command behavior.diff --git a/docs/guides/search-modes.md b/docs/guides/search-modes.mdindex 1d17dc1115..4cc558a3f7 100644--- a/docs/guides/search-modes.md+++ b/docs/guides/search-modes.md@@ -236,17 +236,13 @@ for the question but, by default, never below three results and never an exact mNone of them changes a mode bundle. See [System One](system-one.md).The mode picker runs inside `gbrain init`. Non-TTY and `--json` initialization-tentatively applies its recommendation, `balanced`, with two exceptions:-`conservative` for a Haiku subagent, or when there is neither a chat key-(Anthropic, OpenAI or Google) nor a ready reranker. A ready reranker without a-chat key still gets `balanced`, since nothing in `balanced` needs a chat-model. Keys count whether they are exported or saved in-`~/.gbrain/config.json`. The evidence: on LongMemEval-S (direct harness, top-5), `balanced` found every gold session for 451 of 470 questions and-`tokenmax` for 442 (gbrain-evals, 2026-10-04; that `tokenmax` run also-expanded queries). Existing valid selections are preserved, and the picker-asks agents to confirm the choice with their operator before continuing a real-setup.+tentatively applies its recommendation: `tokenmax` with a chat key (Anthropic,+OpenAI or Google), `balanced` with a ready reranker but no chat key (nothing in+`balanced` needs a chat model), and `conservative` for a Haiku subagent or when+neither exists. Keys count whether they are exported or saved in+`~/.gbrain/config.json`. Existing valid selections are preserved, and the+picker asks agents to confirm the choice with their operator before+continuing a real setup.An agent that already knows the operator's choice records it at install timewith `gbrain init --search-mode <conservative|balanced|tokenmax>`: no@@ -255,19 +251,6 @@ recommendation, no first-run `search_mode` question, and the brain recordsset search.mode` records `operator`). On a brain that already has a differentmode, `--search-mode` refuses unless you also pass `--force`.-Brains that run `tokenmax` because the picker chose it (no-`search.mode_source: operator`) get one `search_mode_coaching` notice, once-per brain and only on the owner's local channels (CLI and the stdio MCP pipe,-never HTTP). It names what switching to `balanced` changes: `query` returns 25-rows instead of 50 under a 12,000-token budget, the rerank pool is 25 instead-of 50, `query` stops expanding by default, new chunks are embedded with title-context instead of per-chunk synopses (existing vectors keep serving until-replaced), and the paid nightly conversation-parser probe stops (it runs in-`tokenmax` or when `autopilot.conversation_parser_probe.enabled` is true). Its-fix is `gbrain config set search.mode balanced`, run only after the user-agrees; nothing changes on its own. Mute it with `gbrain notices mute-search_mode_coaching`.-## Query instruction prefixInstruction-style embedding models (Qwen3-Embedding, e5, BGE v1.5, nomic-embed, EmbeddingGemma)diff --git a/llms-full.txt b/llms-full.txtindex 7cb73e5ac3..c203c320df 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -2730,9 +2730,9 @@ loop; full reference in `docs/ENGINES.md` ("Engine detection and access repair")## Step 3.5: Confirm search mode with the user (DO NOT SKIP)This is the `search_mode` decision from the first-run bundle.-`gbrain init` auto-applied a default search mode: `balanced`, unless your-subagent tier is Haiku-class or there is neither a chat key (Anthropic, OpenAI-or Google) nor a ready reranker, in which case `conservative`. The init output+`gbrain init` auto-applied a default search mode: `tokenmax` with a chat key+(Anthropic, OpenAI or Google), `balanced` with a ready reranker but no chat key,+and `conservative` when your subagent tier is Haiku-class or neither exists. The init outputincluded the cost matrix below preceded by `[AGENT]` markers. You must NOTsilently accept the default. Stop and ask the operator.@@ -2768,12 +2768,10 @@ Estimated downstream input cost of the retrieved payload @ 10K queries/mo:> 1) conservative — tight 4K budget, 10 chunks max, no reranker.> Best for Haiku subagents, cost-sensitive setups, high-volume loops.>-> 2) balanced (recommended default) — 12K budget, 25 chunks, reranked.-> On LongMemEval-S it found every gold session for 451 of 470 questions,-> against 442 for tokenmax.+> 2) balanced — 12K budget, 25 chunks, reranked.>-> 3) tokenmax — no budget, 50 chunks, reranked, `gbrain query` expands by-> default. The widest retrieval, for low-volume high-stakes work.+> 3) tokenmax (recommended with a chat key) — no budget, 50 chunks, reranked,+> `gbrain query` expands by default. The widest retrieval.>> Expansion follows the mode for `gbrain query` only: on in `tokenmax`, off in> `balanced` and `conservative`; `--expand` (`expand: true` over MCP) forces itdiff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsvindex 336325e446..6e0c7a34e2 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/main.ts 3010 ratchet moved from src/cli.ts at 3214 (cold start: src/cli.ts is now the 66-line entry with the --version/help fast path; the top-level help text moved to cli/top-help.ts and the exit seam became runCli/exitOnFatalCliError); +2 #6340: the sync status / sync unblock preflight skip (logic in commands/sync/operator.ts); +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); +2 retrieval feedback: answer id line on stderr and additive answer_id on --json search/query rows (logic in feedback/record.ts); +1 feedback help line and its D3 table-dispatch entry (logic in commands/feedback.ts); 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 line; +3 engine graduation (GBRA-50 G2a): connect-path graduation check on every engine (logic in persistence/graduation-custody.ts assertGraduationConnectAllowed); P3 x engine graduation composition: both deltas re-summed at the merge; 1 Foundations 2 Lane F: sources refresh pre-connect delegation to a resident PGLite owner (logic in commands/sources-refresh-delegate.ts); +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); +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 line; +3 engine graduation (GBRA-50 G2a): connect-path graduation check on every engine (logic in persistence/graduation-custody.ts assertGraduationConnectAllowed); P3 x foundations-2 composition: deltas re-summed at the merge; 1 Foundations 2 Lane F: sources refresh pre-connect delegation to a resident PGLite owner (logic in commands/sources-refresh-delegate.ts); +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); +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 line; +3 engine graduation (GBRA-50 G2a): connect-path graduation check on every engine (logic in persistence/graduation-custody.ts assertGraduationConnectAllowed); GBRA-49: edge-proposals answers --help without a brain (SELF_HELP_WITHOUT_ENGINE row); P3 x P1 (v0.60.57.0) composition: deltas re-summed at the merge; 1 Foundations 2 Lane F: sources refresh pre-connect delegation to a resident PGLite owner (logic in commands/sources-refresh-delegate.ts); +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); +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 line; +3 engine graduation (GBRA-50 G2a): connect-path graduation check on every engine (logic in persistence/graduation-custody.ts assertGraduationConnectAllowed); GBRA-49: edge-proposals answers --help without a brain (SELF_HELP_WITHOUT_ENGINE row); -25 agent-operator follow-up Item 3: the host connect moved to core/engine-connect.ts (throw-only connectEngineForServe, wrapped by connectEngine; the graduation connect gate moved with it); 1 Foundations 2 Lane F: sources refresh pre-connect delegation to a resident PGLite owner (logic in commands/sources-refresh-delegate.ts); +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); +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 line; +3 engine graduation (GBRA-50 G2a): connect-path graduation check on every engine (logic in persistence/graduation-custody.ts assertGraduationConnectAllowed); GBRA-49: edge-proposals answers --help without a brain (SELF_HELP_WITHOUT_ENGINE row); -25 agent-operator follow-up Item 3: the host connect moved to core/engine-connect.ts (throw-only connectEngineForServe, wrapped by connectEngine; the graduation connect gate moved with it); +2 entity recall: the human `gbrain entity` card prints referenced_by groups and a non-complete mention coverage; cat40 entity wave merge with v0.60.61.0 (3179 measured); +3 #4772 (W14 PR3): get_health text output says the entity ratios are n/a because the schema pack did not load (entity_types_status); +1 C4: gbrain questions CLI-only dispatch row (its help line is in cli/top-help.ts); +3 GBRA-81 item 1: the once-per-brain search-mode coaching notice on the CLI channel (logic in core/search/mode-coaching.ts)+src/cli/main.ts 3007 ratchet moved from src/cli.ts at 3214 (cold start: src/cli.ts is now the 66-line entry with the --version/help fast path; the top-level help text moved to cli/top-help.ts and the exit seam became runCli/exitOnFatalCliError); +2 #6340: the sync status / sync unblock preflight skip (logic in commands/sync/operator.ts); +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); +2 retrieval feedback: answer id line on stderr and additive answer_id on --json search/query rows (logic in feedback/record.ts); +1 feedback help line and its D3 table-dispatch entry (logic in commands/feedback.ts); 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 line; +3 engine graduation (GBRA-50 G2a): connect-path graduation check on every engine (logic in persistence/graduation-custody.ts assertGraduationConnectAllowed); P3 x engine graduation composition: both deltas re-summed at the merge; 1 Foundations 2 Lane F: sources refresh pre-connect delegation to a resident PGLite owner (logic in commands/sources-refresh-delegate.ts); +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); +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 line; +3 engine graduation (GBRA-50 G2a): connect-path graduation check on every engine (logic in persistence/graduation-custody.ts assertGraduationConnectAllowed); P3 x foundations-2 composition: deltas re-summed at the merge; 1 Foundations 2 Lane F: sources refresh pre-connect delegation to a resident PGLite owner (logic in commands/sources-refresh-delegate.ts); +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); +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 line; +3 engine graduation (GBRA-50 G2a): connect-path graduation check on every engine (logic in persistence/graduation-custody.ts assertGraduationConnectAllowed); GBRA-49: edge-proposals answers --help without a brain (SELF_HELP_WITHOUT_ENGINE row); P3 x P1 (v0.60.57.0) composition: deltas re-summed at the merge; 1 Foundations 2 Lane F: sources refresh pre-connect delegation to a resident PGLite owner (logic in commands/sources-refresh-delegate.ts); +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); +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 line; +3 engine graduation (GBRA-50 G2a): connect-path graduation check on every engine (logic in persistence/graduation-custody.ts assertGraduationConnectAllowed); GBRA-49: edge-proposals answers --help without a brain (SELF_HELP_WITHOUT_ENGINE row); -25 agent-operator follow-up Item 3: the host connect moved to core/engine-connect.ts (throw-only connectEngineForServe, wrapped by connectEngine; the graduation connect gate moved with it); 1 Foundations 2 Lane F: sources refresh pre-connect delegation to a resident PGLite owner (logic in commands/sources-refresh-delegate.ts); +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); +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 line; +3 engine graduation (GBRA-50 G2a): connect-path graduation check on every engine (logic in persistence/graduation-custody.ts assertGraduationConnectAllowed); GBRA-49: edge-proposals answers --help without a brain (SELF_HELP_WITHOUT_ENGINE row); -25 agent-operator follow-up Item 3: the host connect moved to core/engine-connect.ts (throw-only connectEngineForServe, wrapped by connectEngine; the graduation connect gate moved with it); +2 entity recall: the human `gbrain entity` card prints referenced_by groups and a non-complete mention coverage; cat40 entity wave merge with v0.60.61.0 (3179 measured); +3 #4772 (W14 PR3): get_health text output says the entity ratios are n/a because the schema pack did not load (entity_types_status); +1 C4: gbrain questions CLI-only dispatch row (its help line is in cli/top-help.ts)src/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 2236 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); +8 green-master lane A: chunkless install re-reads through retryProjectionConflict instead of recording an unavailable page (retry lives in core/page-state/projections.ts, failure line in core/agent-output.ts); +8 fix wave 13 P1.18: runEmbed consent parameter, cost-cap stop wiring and result fields, --slugs parsing to the next flag (cap, verdict and resume logic live in core/embed-cost-cap.ts)diff --git a/scripts/serial-files.tsv b/scripts/serial-files.tsvindex 655f5e9a87..db9e2787c7 100644--- a/scripts/serial-files.tsv+++ b/scripts/serial-files.tsv@@ -396,6 +396,5 @@ test/divergence-safe-pull-5429.serial.test.ts R1 R1: mutates process.env (GBRAINtest/embed-stale-progress-5968.serial.test.ts R1 R1: mutates process.env (GBRAIN_MAX_CHUNK_TOKENS)test/eval-longmemeval-via-operation.serial.test.ts global-state global-state: configureGateway changes the process-wide AI gateway; process-wide test seams __setEmbedTransportForTests, __setGenerateObjectTransportForTests, __setRerankTransportForTests; process.chdir to prove the summary names gbrain's own treetest/init-search-mode.serial.test.ts global-state global-state: spawns real gbrain init/config CLI children against PGLite datastores in temp homes (180 s budget each)-test/search-mode-coaching.serial.test.ts global-state global-state: scoped env overrides through withEnv; resets the process notice ledger and behavior-notice state; R3: constructs PGLiteEngine outside beforeAll; spawns the real CLItest/search/mode-receipt.serial.test.ts global-state global-state: configureGateway changes the process-wide AI gateway; process-wide test seams __setEmbedTransportForTests, __setRerankTransportForTests, __setChatTransportForTests, __setGenerateTextTransportForTests, __setGenerateObjectTransportForTests; R3: constructs PGLiteEngine outside beforeAlltest/search/query-expand-capture-replay.serial.test.ts global-state global-state: spyOn replaces the hybridSearch module export process-widediff --git a/src/cli/main.ts b/src/cli/main.tsindex d7dd997702..2becf9453b 100755--- a/src/cli/main.ts+++ b/src/cli/main.ts@@ -2909,16 +2909,13 @@ async function completeEngineStartup(engine: BrainEngine): Promise<void> {// Non-fatal. Pre-v39 brains may not have a usable config table yet.}- // The one-time behavior-change disclosure and the once-per-brain search-mode- // coaching notice on the CLI channel (stderr). `serve` delivers them per MCP- // channel; `doctor` reads the disclosure without marking it shown.+ // The one-time behavior-change disclosure on the CLI channel (stderr). `serve`+ // delivers it per MCP channel; `doctor` reads it without marking it shown.if (dispatchedCommand !== 'serve' && dispatchedCommand !== 'doctor') {try {const { takeLocalBehaviorNotice } = await import('../core/behavior-change-notice.ts');const notice = await takeLocalBehaviorNotice(engine, 'cli', { cfg: MERGED_CONFIG_BY_ENGINE.get(engine) ?? config });if (notice) writeCliNotice(notice);- const coaching = await (await import('../core/search/mode-coaching.ts')).takeSearchModeCoachingNotice(engine, { cfg: MERGED_CONFIG_BY_ENGINE.get(engine) ?? config });- if (coaching) writeCliNotice(coaching);} catch { /* a disclosure never breaks a command */ }}}diff --git a/src/commands/init-mode-picker.ts b/src/commands/init-mode-picker.tsindex 5c0d0619aa..6f21f0c0a8 100644--- a/src/commands/init-mode-picker.ts+++ b/src/commands/init-mode-picker.ts@@ -69,7 +69,7 @@ export interface ModePickerInputs {* - Haiku subagent → conservative (a small-context model).* - No chat key and no ready reranker → conservative.* - A ready reranker without a chat key → balanced.- * - Opus, or anything else → balanced (RECOMMENDED_SEARCH_MODE).+ * - Opus, or anything else → tokenmax (RECOMMENDED_SEARCH_MODE).*/export function recommendModeFor(inputs: ModePickerInputs): { mode: SearchMode; reason: string } {if (/haiku/i.test(inputs.subagentModel ?? '')) return { mode: 'conservative', reason: MODE_REASONS.haiku };@@ -137,7 +137,7 @@ retrieval or downstream generation.high-volume search loops, MCP servers w/ many users.2) balanced 12K-token cap, 25 results by default, reranked.- The recommended default for most brains.+ Best for: mixed workloads, a reranker without a chat key.3) tokenmax no token cap, 50 results by default, reranked,query expansion on by default.diff --git a/src/core/behavior-change-notice.ts b/src/core/behavior-change-notice.tsindex 12f63f8a03..3b5869f935 100644--- a/src/core/behavior-change-notice.ts+++ b/src/core/behavior-change-notice.ts@@ -475,7 +475,6 @@ export const BEHAVIOR_CHANGES: ReadonlyArray<{ since: string; text: ChangeText }{ since: '0.60.182.0', text: 'On a multimodal install, plain `gbrain embed --stale` now runs the image sweep (`--images`) before its text pass and reports it as `images` in `--json`; `gbrain embed --stale --images` works on managed brains, finds an image page with no recorded `source_path` by its slug, and exits non-zero naming the path it tried when no candidate has a file (it used to exit 0); the folded sweep only reports fileless pages. Doctor gains `image_embedding_coverage`.' },// Low-hanging-fruit wave lane A (GBRA-81 items 1 and 1b). `since` is provisional (this branch's VERSION, 0.60.184.0); the integrator restamps it to the release at the merge slot.{ since: '0.60.184.0', text: '`query` now expands only when the search mode says so: on in `tokenmax`, off in `balanced` (the default) and `conservative`, so `query` on a `balanced` brain no longer makes an expansion LLM call before retrieval. `expand: true` (CLI `--expand`) expands one call in any mode, and `gbrain config set search.expansion true` restores expansion by default for the brain; `expand: false` (`--no-expand`) still skips it. A `search.expansion` value set earlier, which `query` used to ignore, now takes effect on `query`; `gbrain search modes` shows it. `search` never expands, as before. CRAG escalation now reads whether the first pass actually expanded (`expansion_applied`), and eval capture records the `expand` the caller sent (null when unset) so `gbrain eval replay` replays the mode default.' },- { since: '0.60.184.0', text: '`gbrain init` now recommends `balanced` instead of `tokenmax` for brains with a chat key, Opus-class models included (on LongMemEval-S, direct harness, top 5, `balanced` found every gold session for 451 of 470 questions and `tokenmax` for 442). New `balanced` installs do not run the paid nightly conversation-parser probe, which `tokenmax` turns on (`gbrain config set autopilot.conversation_parser_probe.enabled true` runs it in any mode). Existing brains keep their mode; one that runs `tokenmax` because init chose it gets one `search_mode_coaching` notice on the CLI or stdio MCP (never HTTP) naming what switching changes, and nothing changes unless the user agrees.' },{ since: '0.60.184.0', text: '`gbrain init --search-mode <conservative|balanced|tokenmax>` records the operator\'s choice: no recommendation, no first-run `search_mode` question, and `search.mode_source: operator` (picker choices record `auto`, and `gbrain config set search.mode` records `operator`). On a brain that already has a different mode it refuses unless `--force`. Init now recommends `balanced` instead of `conservative` when a reranker is ready but no chat key exists, and provider keys saved in `~/.gbrain/config.json` count toward the recommendation. The install matrix now prices Haiku 5.5, Sonnet 5.5 and Opus 5.5 from gbrain\'s pricing table (about a 200x corner-to-corner spread), and switching modes no longer promises a cache refill while semantic result caching is off.' },// Low-hanging fruit wave lane B (GBRA-81, items 2 and 3). `since` is a placeholder equal to the branch's VERSION until the merge-slot stamp.{ since: '0.60.184.0', text: 'Lean `search` and `query` rows (remote callers) now carry `id`, the `fetch` key, only when the connection can call `fetch` at that moment: a `full` surface, a stdio session `request_tools` widened, or an HTTP client whose surface and scopes include it. On `starter` and `verbs` connections, `fetch` was never callable, so the row\'s `slug` and `source_id` identify the page; `fields: "full"` returns every field, `id` included, and the `mcp.result_rows: full` host setting does so for every remote caller. Lean-row `score` now prints 4 significant digits. The local CLI and gbrain\'s thin client keep full rows, unchanged. `fetch` called without an id now says to re-run `search` once `fetch` is callable, or to pass the row\'s slug.' },@@ -579,22 +578,6 @@ function claimMarker(brainKey: string, channel: 'cli' | 'stdio'): 'claimed' | 's}}-/**- * A one-time notice per brain (every local channel together), under the same- * directory as the behavior-change markers: created exclusively, so- * concurrent processes deliver it once. `unwritable` still delivers.- */-export function claimBrainNoticeMarker(code: string, brainKey: string): 'claimed' | 'shown' | 'unwritable' {- const path = join(noticeDir(), `${safe(code)}.${brainKey}.shown`);- try {- mkdirSync(dirname(path), { recursive: true });- writeFileSync(path, `${new Date().toISOString()}\n`, { mode: 0o600, flag: 'wx' });- return 'claimed';- } catch (e) {- return (e as NodeJS.ErrnoException)?.code === 'EEXIST' ? 'shown' : 'unwritable';- }-}-/** The newest notice release this brain × channel was shown (any build's marker), `0` when none. */function localShownThrough(brainKey: string, channel: 'cli' | 'stdio'): string {const suffix = markerSuffix(brainKey, channel);diff --git a/src/core/error-registry.ts b/src/core/error-registry.tsindex cf6e279bf4..1d1834c163 100644--- a/src/core/error-registry.ts+++ b/src/core/error-registry.ts@@ -522,7 +522,6 @@ export const NOTICE_CODES = {local_transcripts: { kind: 'info', summary: 'The brain host keeps recent session transcripts that page reads never return and this connection cannot read; the fix is the CLI read (`gbrain transcripts recent --json`).' },synthesis_keyless: { kind: 'info', summary: 'think returned gathered evidence without synthesis because no chat-model key is configured (by design on a keyless brain).' },think_not_saved: { kind: 'info', summary: 'think save/take persist only for the local CLI, so this answer was not saved.' },- search_mode_coaching: { kind: 'coaching', summary: 'This brain runs search.mode tokenmax because gbrain init chose it automatically, and gbrain now recommends balanced; owner-only (CLI and stdio, never HTTP), once per brain. The fix switches modes after the user agrees; nothing changes on its own.' },onboard_opportunities: { kind: 'coaching', summary: 'Onboarding checks found work that would improve this brain (gbrain onboard --check lists it).' },onboard_stale_chunks: { kind: 'coaching', summary: 'This search could not match chunks that have no embedding; the remedy is an embedding backfill (paid, ask first).' },onboard_link_coverage: { kind: 'coaching', summary: 'Few people/company pages have incoming links, so backlinks and graph answers are thin; the remedy is link extraction.' },diff --git a/src/core/search/mode-advice.ts b/src/core/search/mode-advice.tsindex 7f0c6ca6d5..076efa71d1 100644--- a/src/core/search/mode-advice.ts+++ b/src/core/search/mode-advice.ts@@ -19,8 +19,8 @@ import type { SearchMode } from './mode.ts';export const SEARCH_MODE_SOURCE_KEY = 'search.mode_source';export type SearchModeSource = 'auto' | 'operator';-/** The mode gbrain recommends when nothing argues for another. */-export const RECOMMENDED_SEARCH_MODE: SearchMode = 'balanced';+/** The mode gbrain recommends for a brain with a chat key when nothing argues for another. */+export const RECOMMENDED_SEARCH_MODE: SearchMode = 'tokenmax';const MODES: readonly SearchMode[] = ['conservative', 'balanced', 'tokenmax'];@@ -89,18 +89,13 @@ export const QUERY_EXPANSION_LINE ='--expand forces it and --no-expand skips it. `gbrain search` never expands. An expansion is one call to the ' +'configured chat model, a separate provider charge; keyless brains never expand.';-/** The measured evidence behind the recommendation, as measured. */-export const BALANCED_EVIDENCE =- 'On LongMemEval-S (direct harness, top 5), balanced found every gold session for 451 of 470 questions and ' +- 'tokenmax for 442 (gbrain-evals, 2026-10-04; that tokenmax run also expanded queries).';-/** The picker's reason for each recommendation branch. */export const MODE_REASONS = {haiku: 'Haiku subagent tier detected — conservative keeps the payload at 4K tokens for a small-context model.',noKeys: 'No chat key (Anthropic/OpenAI/Google) and no ready reranker — conservative keeps a tight 4K budget; balanced\'s reranker could not run.',rerankOnly: 'A reranker is ready but there is no chat key — balanced reranks with it; nothing in balanced needs a chat model.',- opus: `Opus-class model detected — balanced is still the recommendation: ${BALANCED_EVIDENCE}`,- default: `Recommended default. ${BALANCED_EVIDENCE} tokenmax doubles the payload; pick it when the operator wants the widest retrieval.`,+ opus: 'Opus-class model detected — quality ceiling worth the token cost.',+ default: 'A chat key is configured — tokenmax gives the widest retrieval; pick conservative or balanced if cost-sensitive.',} as const;/** The non-TTY banner the picker prints after applying `applied`: an agent block asking the operator, then the matrix. */@@ -139,7 +134,7 @@ export function upgradeBannerLines(): string[] {'',...agentBlock({ask: 'Which search mode should this brain use: conservative, balanced or tokenmax?',- why: `Relay this matrix to your operator and ask which mode they want. Recommended: ${RECOMMENDED_SEARCH_MODE}. ${BALANCED_EVIDENCE}`,+ why: `Relay this matrix to your operator and ask which mode they want. Recommended for a brain with a chat key: ${RECOMMENDED_SEARCH_MODE}.`,next: 'ask_user: run `gbrain config set search.mode <mode>` after they decide.',verify: 'gbrain search modes',}).trimEnd().split('\n'),diff --git a/src/core/search/mode-coaching.ts b/src/core/search/mode-coaching.tsdeleted file mode 100644index 342faba3a2..0000000000--- a/src/core/search/mode-coaching.ts+++ /dev/null@@ -1,75 +0,0 @@-/**- * One owner-only coaching notice for brains running `tokenmax` because the- * install picker chose it (no `search.mode_source: operator`): gbrain now- * recommends `balanced`. Delivered once per brain on the local channels (CLI- * stderr and the stdio MCP pipe), through a per-brain marker file next to the- * behavior-change markers; never on HTTP. It changes nothing and costs- * nothing: the fix is the switch, asked of the user first. Muteable like any- * coaching notice (`gbrain notices mute search_mode_coaching`).- */-import type { Notice } from '../agent-output.ts';-import type { GBrainConfig } from '../config.ts';-import type { BrainEngine } from '../engine.ts';-import { behaviorBrainKey, claimBrainNoticeMarker, currentBrainId } from '../behavior-change-notice.ts';-import { mutedNoticeCodes } from '../notice-ledger.ts';-import { SEARCH_MODE_KEY } from './mode.ts';-import { BALANCED_EVIDENCE, SEARCH_MODE_SOURCE_KEY } from './mode-advice.ts';--export const SEARCH_MODE_COACHING_CODE = 'search_mode_coaching';--export function searchModeCoachingNotice(): Notice {- return {- code: SEARCH_MODE_COACHING_CODE,- kind: 'coaching',- why: 'This brain runs search.mode tokenmax, which gbrain init chose automatically; gbrain now recommends balanced. ' +- `${BALANCED_EVIDENCE} Switching to balanced changes: \`query\` returns 25 rows instead of 50, under a 12,000-token budget; ` +- 'the rerank pool is 25 instead of 50; `query` stops expanding by default (`expand: true` still does); new chunks are embedded ' +- 'with title context instead of per-chunk synopses (existing vectors keep serving until they are replaced); and the paid nightly ' +- 'conversation-parser probe stops (it runs in tokenmax, or when autopilot.conversation_parser_probe.enabled is true). ' +- 'Nothing changes unless the user agrees, and switching costs nothing.',- fix: {- ask_user: true,- argv: ['gbrain', 'config', 'set', 'search.mode', 'balanced'],- consent: [],- actor: 'agent',- requires_exclusive: false,- why: 'Switches this brain to the recommended search mode.',- user_message: 'gbrain recommends switching this brain\'s search mode from tokenmax (chosen automatically at install) to balanced: ' +- 'about half the retrieved text per query, and it scored higher in gbrain\'s retrieval benchmark. Switch to balanced?',- verify: { argv: ['gbrain', 'search', 'modes', '--json'] },- docs: 'docs/guides/search-modes.md',- },- };-}--/** Brains already looked at in this process: one look per process. */-const looked = new Set<string>();--/** Test seam: forget this process's looks. */-export function __resetSearchModeCoachingForTests(): void {- looked.clear();-}--/**- * The notice when this brain runs picker-chosen tokenmax and has not been- * shown it on any local channel, else null. `principal` names the mute list- * to honor (`stdio` for the MCP pipe; the owner's global list always- * applies). Claims the per-brain marker only when it returns the notice.- * Never throws.- */-export async function takeSearchModeCoachingNotice(- engine: BrainEngine,- opts: { cfg: GBrainConfig | null; brainKey?: string; principal?: string },-): Promise<Notice | null> {- try {- const brainKey = opts.brainKey ?? behaviorBrainKey(opts.cfg, await currentBrainId());- if (looked.has(brainKey)) return null;- looked.add(brainKey);- const [mode, source] = await Promise.all([engine.getConfig(SEARCH_MODE_KEY), engine.getConfig(SEARCH_MODE_SOURCE_KEY)]);- if (mode !== 'tokenmax' || source === 'operator') return null;- if (mutedNoticeCodes(opts.principal).has(SEARCH_MODE_COACHING_CODE)) return null;- return claimBrainNoticeMarker(SEARCH_MODE_COACHING_CODE, brainKey) === 'shown' ? null : searchModeCoachingNotice();- } catch {- return null;- }-}diff --git a/src/mcp/dispatch.ts b/src/mcp/dispatch.tsindex 9c0e4403bb..7fed99b8cd 100644--- a/src/mcp/dispatch.ts+++ b/src/mcp/dispatch.ts@@ -25,7 +25,6 @@ import { localTranscriptsNotice, recallInteropNotices, wantsTranscriptHint } froimport { hiddenToolHint } from './hidden-tool-hint.ts';import { takePostUpgradeMcpNotice } from '../core/post-upgrade-notice.ts';import { takeHttpBehaviorNotice, takeLocalBehaviorNotice } from '../core/behavior-change-notice.ts';-import { takeSearchModeCoachingNotice } from '../core/search/mode-coaching.ts';import { takeChatFallbackHopNotices } from '../core/ai/fallback-hop-queue.ts';import { mcpOnboardingNotices } from '../core/onboard/mcp-onboarding.ts';import { takeFactsDrainNotice } from '../core/facts/drain.ts';@@ -1002,8 +1001,6 @@ export async function dispatchToolCall(if (opts.transport === 'stdio' && opts.remote !== false) notices.push(...await mcpOnboardingNotices({ engine, op: name, result, meta: responseMeta, config: ctx.config, render: dispatchRenderContext(opts) }));if (opts.transport === 'stdio' && opts.remote !== false) { const drain = takeFactsDrainNotice(); if (drain) notices.push(drain); } // Lane D facts drainnotices.push(...await sessionSafetyNotices(engine, opts, ctx.config));- // Owner-only (stdio, never HTTP), once per brain; first in line so the session's coaching budget admits it.- if (opts.transport === 'stdio' && opts.remote !== false) { const coaching = await takeSearchModeCoachingNotice(engine, { cfg: ctx.config ?? null, principal: 'stdio' }); if (coaching) notices.unshift(coaching); }const out: ToolResult = toolResultWithNotices(result, admitNotices(notices, opts), dispatchRenderContext(opts));if (evidenceBlocks.length > 0) out.content.splice(1, 0, ...evidenceBlocks.map(text => ({ type: 'text' as const, text })));if (opts.transport === 'stdio') {diff --git a/test/config-search-registry.test.ts b/test/config-search-registry.test.tsindex 26d54a52f8..bd6d7ff4df 100644--- a/test/config-search-registry.test.ts+++ b/test/config-search-registry.test.ts@@ -19,7 +19,7 @@ import { REMOTE_PRIVATE_PAGES_KEY } from '../src/core/search/private-visibility.const DIRECTLY_READ_SINGLETONS = [SEARCH_MODE_KEY,'search.mode_upgrade_notice_shown', // commands/upgrade.ts- 'search.mode_source', // search/mode-coaching.ts (who chose search.mode)+ 'search.mode_source', // init --search-mode / config set search.mode (who chose search.mode)'search.image_query.max_bytes', // ops/image.ts'search.image_query.daily_budget_usd_per_client', // ops/image.ts'search.image_query.remote_max_bytes', // ops/image.tsdiff --git a/test/init-mode-picker.test.ts b/test/init-mode-picker.test.tsindex 01fa4c0f93..0a4b5176e7 100644--- a/test/init-mode-picker.test.ts+++ b/test/init-mode-picker.test.ts@@ -83,7 +83,7 @@ describe('recommendModeFor: every input combination', () => {const expected = (model: string, chat: boolean, rerank: boolean): string => {if (model === 'Haiku') return 'conservative';if (!chat && !rerank) return 'conservative';- return 'balanced';+ return chat ? 'tokenmax' : 'balanced';};for (const m of models) {for (const chat of [true, false]) {@@ -107,20 +107,13 @@ describe('recommendModeFor: every input combination', () => {});test('unknown key state is not "no keys": empty inputs get the default', () => {- expect(recommendModeFor({}).mode).toBe('balanced');+ expect(recommendModeFor({}).mode).toBe('tokenmax');});test('a Haiku subagent wins over an Opus default model', () => {const r = recommendModeFor({ defaultModel: 'anthropic:claude-opus-5-5', subagentModel: 'anthropic:claude-haiku-5-5', hasChatKey: true, hasRerankKey: true });expect(r.mode).toBe('conservative');});-- test('the Opus and default reasons quote the benchmark as measured', () => {- for (const reason of [MODE_REASONS.opus, MODE_REASONS.default]) {- expect(reason).toContain('451 of 470');- expect(reason).toContain('442');- }- });});describe('resolveModePickerInputs: keys through mergedProviderEnv and reranker readiness', () => {@@ -156,7 +149,7 @@ describe('resolveModePickerInputs: keys through mergedProviderEnv and reranker rconst inputs = await resolveModePickerInputs(engine);expect(inputs.hasChatKey).toBe(true);expect(inputs.hasRerankKey).toBe(false);- expect(recommendModeFor(inputs)).toEqual({ mode: 'balanced', reason: MODE_REASONS.default });+ expect(recommendModeFor(inputs)).toEqual({ mode: 'tokenmax', reason: MODE_REASONS.default });});});@@ -244,14 +237,14 @@ describe('parseModeInput', () => {});describe('runModePicker: non-TTY and --json', () => {- test('non-TTY applies balanced for a keyed brain, records auto, prints the [AGENT] banner', async () => {+ test('non-TTY applies tokenmax for a keyed brain, records auto, prints the [AGENT] banner', async () => {await inHome({ ANTHROPIC_API_KEY: 'sk-ant-test-stub' }, async () => {let decision: { mode: string; reason: string } | undefined;const out = (await captureLog(() => runModePicker(engine, { onDecision: d => { decision = d; } }))).join('\n');- expect(await engine.getConfig('search.mode')).toBe('balanced');+ expect(await engine.getConfig('search.mode')).toBe('tokenmax');expect(await engine.getConfig('search.mode_source')).toBe('auto');- expect(decision).toEqual({ mode: 'balanced', reason: MODE_REASONS.default });- expect(out).toContain('[gbrain] search mode tentatively set to: balanced');+ expect(decision).toEqual({ mode: 'tokenmax', reason: MODE_REASONS.default });+ expect(out).toContain('[gbrain] search mode tentatively set to: tokenmax');expect(out.toLowerCase()).toContain('show this matrix');expect(out).toContain('INSTALL_FOR_AGENTS.md');expect(out).toContain('gbrain init --search-mode <mode>');@@ -290,8 +283,9 @@ describe('runModePicker: non-TTY and --json', () => {test('--force re-runs the recommendation over an existing mode', async () => {await engine.setConfig('search.mode', 'tokenmax');await inHome({ ANTHROPIC_API_KEY: 'sk-ant-test-stub' }, async () => {+ await engine.setConfig('search.mode', 'conservative');await captureLog(() => runModePicker(engine, { force: true }));- expect(await engine.getConfig('search.mode')).toBe('balanced');+ expect(await engine.getConfig('search.mode')).toBe('tokenmax');expect(await engine.getConfig('search.mode_source')).toBe('auto');});});@@ -353,8 +347,7 @@ describe('upgrade banner', () => {test('states the default a mode-less brain runs and the recommendation from the shared source', () => {const text = upgradeBannerLines().join('\n');expect(text).toContain('runs balanced');- expect(text).toContain('Recommended: balanced');- expect(text).toContain('451 of 470');+ expect(text).toContain('Recommended for a brain with a chat key: tokenmax');expect(text).not.toMatch(/expand=true|preserves current retrieval shape|v0\.31/);});});diff --git a/test/search-mode-coaching.serial.test.ts b/test/search-mode-coaching.serial.test.tsdeleted file mode 100644index b17798bd25..0000000000--- a/test/search-mode-coaching.serial.test.ts+++ /dev/null@@ -1,178 +0,0 @@-/**- * The owner-only search-mode coaching notice: a brain running `tokenmax`- * because the install picker chose it (no `search.mode_source: operator`)- * sees one `search_mode_coaching` notice per brain, on the CLI or the stdio- * MCP pipe, whichever comes first, and never over HTTP. A fresh brain, an- * operator's tokenmax, any other mode and a muted code see nothing.- *- * Serial: the CLI case spawns the real binary against a PGLite brain in a- * temp home.- */-import { afterAll, beforeAll, beforeEach, describe, expect, test } from 'bun:test';-import { mkdtempSync } from 'node:fs';-import { tmpdir } from 'node:os';-import { join } from 'node:path';-import { PGLiteEngine } from '../src/core/pglite-engine.ts';-import type { GBrainConfig } from '../src/core/config.ts';-import { dispatchToolCall } from '../src/mcp/dispatch.ts';-import { NoticeLedger, __resetProcessNoticeLedgerForTests, setNoticeMuted } from '../src/core/notice-ledger.ts';-import { __resetBehaviorNoticeForTests } from '../src/core/behavior-change-notice.ts';-import { _resetDbPlaneMergeMemoForTests } from '../src/core/config-db-merge.ts';-import {- SEARCH_MODE_COACHING_CODE,- __resetSearchModeCoachingForTests,- takeSearchModeCoachingNotice,-} from '../src/core/search/mode-coaching.ts';-import { withEnv } from './helpers/with-env.ts';-import { runCli } from './helpers/cli-spawn.ts';--const PREFIX = `[gbrain notice ${SEARCH_MODE_COACHING_CODE} kind=coaching]`;-const QUIET = { GBRAIN_NO_ONBOARD_NUDGE: '1', GBRAIN_CHAT_FALLBACK_CHAIN: undefined };-let seq = 0;-const config = (): GBrainConfig => ({ engine: 'pglite', database_path: join(tmpdir(), `coaching-brain-${process.pid}-${++seq}`) } as GBrainConfig);-const freshHome = () => mkdtempSync(join(tmpdir(), 'gbrain-coaching-home-'));--function coachingBlocks(res: { content: Array<{ text: string }> }): string[] {- return res.content.map(c => c.text).filter(t => t.startsWith(PREFIX));-}--let engine: PGLiteEngine;--beforeAll(async () => {- engine = new PGLiteEngine();- await engine.connect({});- await engine.initSchema();-}, 120_000);--afterAll(async () => { await engine.disconnect(); });--beforeEach(async () => {- __resetSearchModeCoachingForTests();- __resetBehaviorNoticeForTests();- __resetProcessNoticeLedgerForTests();- _resetDbPlaneMergeMemoForTests();- await engine.executeRaw(`DELETE FROM config WHERE key IN ('search.mode', 'search.mode_source')`);-});--async function pickerTokenmax(): Promise<void> {- await engine.setConfig('search.mode', 'tokenmax');-}--const stdio = (cfg: GBrainConfig) => ({ remote: true, transport: 'stdio' as const, sourceId: 'default', config: cfg });--describe('search_mode_coaching', () => {- test('stdio: an upgraded brain on picker-chosen tokenmax sees it once, with the switch as an ask_user fix', async () => {- await pickerTokenmax();- await withEnv({ GBRAIN_HOME: freshHome(), ...QUIET }, async () => {- const cfg = config();- const first = await dispatchToolCall(engine as never, 'list_pages', {}, stdio(cfg));- const blocks = coachingBlocks(first);- expect(blocks).toHaveLength(1);- expect(blocks[0]).toContain('gbrain config set search.mode balanced');- expect(blocks[0]).toContain('next: ask_user');- expect(blocks[0]).toContain('451 of 470');- expect(blocks[0]).toContain('nightly');- expect(coachingBlocks(await dispatchToolCall(engine as never, 'list_pages', {}, stdio(cfg)))).toHaveLength(0);-- // A new process (looks reset) on the same brain: the per-brain marker holds.- __resetSearchModeCoachingForTests();- __resetProcessNoticeLedgerForTests();- expect(coachingBlocks(await dispatchToolCall(engine as never, 'list_pages', {}, stdio(cfg)))).toHaveLength(0);- // The CLI channel shares the marker: shown on stdio means shown.- __resetSearchModeCoachingForTests();- expect(await takeSearchModeCoachingNotice(engine, { cfg })).toBeNull();- });- }, 60_000);-- test('CLI then stdio: once per brain across channels; another brain gets its own', async () => {- await pickerTokenmax();- await withEnv({ GBRAIN_HOME: freshHome(), ...QUIET }, async () => {- const cfg = config();- const notice = await takeSearchModeCoachingNotice(engine, { cfg });- expect(notice?.code).toBe(SEARCH_MODE_COACHING_CODE);- expect(notice?.kind).toBe('coaching');- expect(notice?.fix).toMatchObject({ ask_user: true, argv: ['gbrain', 'config', 'set', 'search.mode', 'balanced'], verify: { argv: ['gbrain', 'search', 'modes', '--json'] } });- __resetSearchModeCoachingForTests();- expect(coachingBlocks(await dispatchToolCall(engine as never, 'list_pages', {}, stdio(cfg)))).toHaveLength(0);-- __resetSearchModeCoachingForTests();- expect(await takeSearchModeCoachingNotice(engine, { cfg: config() })).not.toBeNull();- });- }, 60_000);-- test('HTTP never shows it, and does not use up the owner\'s one showing', async () => {- await pickerTokenmax();- await withEnv({ GBRAIN_HOME: freshHome(), ...QUIET }, async () => {- const cfg = config();- const ledger = new NoticeLedger();- const http = { remote: true, transport: 'http' as const, sourceId: 'default', config: cfg, noticeLedger: ledger,- auth: { token: 't', clientId: 'http-a', clientName: 'http-a', scopes: ['read'], expiresAt: Date.now() / 1000 + 3600 } as never };- expect(coachingBlocks(await dispatchToolCall(engine as never, 'list_pages', {}, http))).toHaveLength(0);- expect(coachingBlocks(await dispatchToolCall(engine as never, 'list_pages', {}, http))).toHaveLength(0);- expect(coachingBlocks(await dispatchToolCall(engine as never, 'list_pages', {}, stdio(cfg)))).toHaveLength(1);- });- }, 60_000);-- test('nothing for an operator\'s tokenmax, for balanced, conservative, or a fresh brain with no mode', async () => {- await withEnv({ GBRAIN_HOME: freshHome(), ...QUIET }, async () => {- const cases: Array<[string | null, string | null]> = [['tokenmax', 'operator'], ['balanced', 'auto'], ['balanced', null], ['conservative', 'auto'], [null, null]];- for (const [mode, source] of cases) {- await engine.executeRaw(`DELETE FROM config WHERE key IN ('search.mode', 'search.mode_source')`);- if (mode) await engine.setConfig('search.mode', mode);- if (source) await engine.setConfig('search.mode_source', source);- __resetSearchModeCoachingForTests();- expect(await takeSearchModeCoachingNotice(engine, { cfg: config() })).toBeNull();- }- });- }, 60_000);-- test('a picker tokenmax recorded as auto still gets it', async () => {- await pickerTokenmax();- await engine.setConfig('search.mode_source', 'auto');- await withEnv({ GBRAIN_HOME: freshHome(), ...QUIET }, async () => {- expect(await takeSearchModeCoachingNotice(engine, { cfg: config() })).not.toBeNull();- });- });-- test('muted by the owner (gbrain notices mute) or on the stdio pipe (mute_notice), it stays silent and unclaimed', async () => {- await pickerTokenmax();- await withEnv({ GBRAIN_HOME: freshHome(), ...QUIET }, async () => {- const cfg = config();- setNoticeMuted(SEARCH_MODE_COACHING_CODE, true);- expect(await takeSearchModeCoachingNotice(engine, { cfg })).toBeNull();- setNoticeMuted(SEARCH_MODE_COACHING_CODE, false);- setNoticeMuted(SEARCH_MODE_COACHING_CODE, true, 'stdio');- __resetSearchModeCoachingForTests();- expect(coachingBlocks(await dispatchToolCall(engine as never, 'list_pages', {}, stdio(cfg)))).toHaveLength(0);- setNoticeMuted(SEARCH_MODE_COACHING_CODE, false, 'stdio');- __resetSearchModeCoachingForTests();- expect(await takeSearchModeCoachingNotice(engine, { cfg })).not.toBeNull();- });- }, 60_000);-- test('the real CLI prints it once on stderr for a picker-tokenmax brain, and `config set search.mode` records operator', async () => {- const home = freshHome();- const env = { ...QUIET, ANTHROPIC_API_KEY: undefined, OPENAI_API_KEY: undefined, VOYAGE_API_KEY: undefined, GEMINI_API_KEY: undefined, GOOGLE_GENERATIVE_AI_API_KEY: undefined };- const init = await runCli(['init', '--pglite', '--no-embedding', '--json'], { home, env, timeoutMs: 180_000 });- expect(init.exitCode).toBe(0);- // Simulate a brain the old picker put on tokenmax (no mode_source).- const brain = new PGLiteEngine();- await brain.connect({ engine: 'pglite', database_path: join(home, '.gbrain', 'brain.pglite') });- try {- await brain.setConfig('search.mode', 'tokenmax');- await brain.unsetConfig('search.mode_source');- } finally { await brain.disconnect(); }-- const first = await runCli(['config', 'get', 'search.mode'], { home, env });- expect(first.exitCode).toBe(0);- expect(first.stderr).toContain(`[${SEARCH_MODE_COACHING_CODE}]`);- expect(first.stderr).toContain('next: ask_user: gbrain config set search.mode balanced');- const second = await runCli(['config', 'get', 'search.mode'], { home, env });- expect(second.stderr).not.toContain(SEARCH_MODE_COACHING_CODE);-- const set = await runCli(['config', 'set', 'search.mode', 'balanced'], { home, env });- expect(set.exitCode).toBe(0);- const source = await runCli(['config', 'get', 'search.mode_source'], { home, env });- expect(source.stdout.trim()).toBe('operator');- }, 300_000);-});