Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs(w9f): fold the lane notes into docs/fix-wave-notes/capy-wave-9-followups.md and its judge probe record
garrytan4d8bd38db903
diff --git a/docs/architecture/key-files/core-ai.md b/docs/architecture/key-files/core-ai.mdindex c96535e6cc..f883d84d33 100644--- a/docs/architecture/key-files/core-ai.md+++ b/docs/architecture/key-files/core-ai.md@@ -24,7 +24,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `src/core/ai/fallback-hop-queue.ts`: the process-level queue for the first hop's `chat_fallback_hop` notice (at most one per process; type-only imports so every drain site loads it cheaply). Drained by stdio MCP dispatch, the CLI op notice channel (`src/cli/op-notices.ts`) and `finishCliTeardown`; never by HTTP, because the notice names models.- `src/core/ai/chat-fallback-planes.ts`: where the effective `chat_fallback_chain` comes from, read without network, subprocess or inference. `readChatFallbackPlanes(db)` reads env `GBRAIN_CHAT_FALLBACK_CHAIN` > the config.json key > the DB row (`parseDbChatFallbackChain` in `config-db-merge.ts`) with the loader's rule that the first plane that speaks wins even when its value yields no chain, and returns the winner, shadowed values, unreadable planes and the `chat_fallback_on_refusal` value with its plane. `diagnoseChatFallbackEntry` checks one entry by presence: `provider:model` parse, known provider with chat, the provider's own credential (recipe env keys or `authPresent`; for `claude-cli` the binary on PATH or `GBRAIN_CLAUDE_CLI_BIN`), and a price when a key in `USER_CHAT_CAP_KEYS` sets a user cap. `chatFallbackRemovalFix` is the per-plane removal guidance (DB `gbrain config unset chat_fallback_chain` with `destructive` consent → `ask_user`; env/file are the user's, with the restart note). Consumers: the `chat_fallback_chain` doctor check and the `behavior_changes` notice.- `src/core/ai/sdk-warnings.ts` — AI SDK provider warnings to stderr (#5892). The gateway calls `installAiSdkWarningWriter()` when it loads, which sets `globalThis.AI_SDK_LOG_WARNINGS` to a writer with the `ai` logger signature (`{ warnings, provider, model }`) that prints each warning in the SDK's own wording to stderr and never the SDK's `console.info` banner, which landed on stdout and broke `--json` output (the claude-cli model's v2-compat notice fires on every process's first call). A user-set value (`false` or a function) is kept. Tests: `ai-sdk-warnings.test.ts`, `json-stdout-ai-warnings.test.ts`.-- `src/core/ai/thinking-off.ts`: the per-route mapping behind `ChatOpts.thinking: 'off'` (#5331). `thinkingOffControl(modelStr)` is the per-model capability table: the provider-options namespace and keys to set, and whether they turn reasoning off (`disables`) or only set its floor. Full off: native `anthropic`, `deepseek`, `openrouter` with a `deepseek/` model (`thinking: { type: 'disabled' }`), Gemini 2.5 Flash/Flash-Lite (`thinkingConfig.thinkingBudget: 0`), OpenAI gpt-5.1/5.2/5.4/5.5/5.6 (`reasoningEffort: 'none'`). Floor: Gemini 2.5 Pro (`thinkingBudget: 128`), Gemini 3.x (`thinkingLevel` `minimal`, or `low` on 3.7/3.8 Flash and 3.x Pro, where `minimal` is a 400), gpt-5/-mini/-nano (`minimal`), o-series (`low`). Other Gemini 3+ and OpenAI reasoning ids, gpt-6 included (the pinned @ai-sdk/openai drops its effort), get no option. Only native recipes get an option; the two Google fields are never sent together. `applyThinkingOff` sets the keys, replacing a configured value under the same key while siblings such as `cacheControl` or `promptCacheKey` survive; `chat()` applies it after the call-scoped `providerOptions` merge, on the resolved recipe. `thinkingOffMaxOutputTokens` keeps the requested cap where reasoning turns off and raises a route that keeps reasoning (a floor row, or no row and `isThinkingModel`) to the thinking headroom. gateway.ts `thinkingOffOutputCap(model, requested)` wraps it for `chat()` and for the takes-quality and cross-modal preflight estimates, so they price the cap the call sends. Callers: those two judges and the synthesize triage judge. Rows were checked live on 2026-10-07 (`docs/w9f/lane-j.md`). Pinned by `test/ai/chat-thinking-off.test.ts` (request bodies per route against a local stub, estimate parity per default panel model) and `test/ai/gateway-chat.test.ts`.+- `src/core/ai/thinking-off.ts`: the per-route mapping behind `ChatOpts.thinking: 'off'` (#5331). `thinkingOffControl(modelStr)` is the per-model capability table: the provider-options namespace and keys to set, and whether they turn reasoning off (`disables`) or only set its floor. Full off: native `anthropic`, `deepseek`, `openrouter` with a `deepseek/` model (`thinking: { type: 'disabled' }`), Gemini 2.5 Flash/Flash-Lite (`thinkingConfig.thinkingBudget: 0`), OpenAI gpt-5.1/5.2/5.4/5.5/5.6 (`reasoningEffort: 'none'`). Floor: Gemini 2.5 Pro (`thinkingBudget: 128`), Gemini 3.x (`thinkingLevel` `minimal`, or `low` on 3.7/3.8 Flash and 3.x Pro, where `minimal` is a 400), gpt-5/-mini/-nano (`minimal`), o-series (`low`). Other Gemini 3+ and OpenAI reasoning ids, gpt-6 included (the pinned @ai-sdk/openai drops its effort), get no option. Only native recipes get an option; the two Google fields are never sent together. `applyThinkingOff` sets the keys, replacing a configured value under the same key while siblings such as `cacheControl` or `promptCacheKey` survive; `chat()` applies it after the call-scoped `providerOptions` merge, on the resolved recipe. `thinkingOffMaxOutputTokens` keeps the requested cap where reasoning turns off and raises a route that keeps reasoning (a floor row, or no row and `isThinkingModel`) to the thinking headroom. gateway.ts `thinkingOffOutputCap(model, requested)` wraps it for `chat()` and for the takes-quality and cross-modal preflight estimates, so they price the cap the call sends. Callers: those two judges and the synthesize triage judge. Rows were checked live on 2026-10-07 (`docs/fix-wave-notes/capy-wave-9-followups.md`). Pinned by `test/ai/chat-thinking-off.test.ts` (request bodies per route against a local stub, estimate parity per default panel model) and `test/ai/gateway-chat.test.ts`.- `src/core/ai/model-resolver.ts` — Recipe-touchpoint validator. `assertTouchpoint(recipe, touchpoint, modelId)` checks the PROVIDER's capability only (anthropic has no embedding touchpoint; voyage/ollama have no chat) and never gates on the model id. Recipe `models:` arrays are informational — default-model selection (`models[0]` for `--model <provider>` shorthand and env-ready pickers), guard-test fixtures for the repo's own hardcoded defaults, and `gbrain providers list` display — NOT a runtime allowlist, so frontier models newer than a recipe work without a recipe PR. A nonexistent id surfaces as the provider's own `model_not_found` at call time; `gbrain models doctor` live-probes the configured models for a pre-flight check. Exception: `gateway.rerank()` keeps its own model-list check because each listed reranker id maps to a known request/response wire shape. `embeddingDimsForModel` matches recipe `model_dims` keys exactly first, then case-insensitively with BOTH sides folded (configured ids arrive cased, and user-editable recipe tables can carry cased keys; without the fold a cased id would fall through to `default_dims` and `gbrain init` would build a wrong-width column), before falling back to `default_dims`.diff --git a/docs/w9f/lane-j.md b/docs/fix-wave-notes/capy-wave-9-followups-judge-probe.mdsimilarity index 59%rename from docs/w9f/lane-j.mdrename to docs/fix-wave-notes/capy-wave-9-followups-judge-probe.mdindex c8ba966e75..dfe2503621 100644--- a/docs/w9f/lane-j.md+++ b/docs/fix-wave-notes/capy-wave-9-followups-judge-probe.md@@ -1,105 +1,14 @@-# Wave 9 follow-ups, lane J: judge thinking caps (item 5)+# Wave 9 follow-ups: judge thinking probe record-Branch `capy/w9f-lane-j`, based on origin/master 9cc7c4677 (v0.60.99.0). No version bump, no CHANGELOG header; the release lines below are for the integrator.+The exact requests and responses of the capped live probe behind the thinking capability table in `src/core/ai/thinking-off.ts` ([wave notes](capy-wave-9-followups.md#judge-thinking-caps-lane-j)).-## Verdict--Item 5 is confirmed on current master and fixed on this branch. Re-verification on 9cc7c4677:--- `chat()` raised a `thinking: 'off'` call's cap to 32,000 only for a thinking-by-default route without a switch (`gateway.ts:3461` on master), but the takes-quality projection priced `estimateCost(m, 5000, 2000)` (`takes-quality-eval/runner.ts:223`, `:259`) and the cross-modal preflight priced `maxTokens` (`cross-modal-eval/runner.ts:410`).-- `thinking-off.ts` had no Google or OpenAI row and `recipes/google.ts` declares no `thinking_by_default`, so `google:gemini-2.5-flash` on the default takes-quality panel ran with dynamic thinking inside the 2,000-token cap.-- The live probe below settles the open question: Gemini thoughts are billed inside `maxOutputTokens`. At a 128-token cap with no thinking config, gemini-2.5-flash spent 120 tokens thinking and returned `{"score": ` with `finishReason: length` (case G1b); gemini-3.8-flash did the same (G4b).--## The capability table (`src/core/ai/thinking-off.ts`)--`thinkingOffControl(modelStr)` returns the provider-options namespace and keys to set and whether they turn reasoning off (`disables`). `applyThinkingOff` and `thinkingOffMaxOutputTokens` (runtime, inside `chat()`) and gateway.ts `thinkingOffOutputCap` (the takes-quality and cross-modal estimates) all read it, so an estimate prices the cap the call sends.--| Route | Option sent under `thinking: 'off'` | Reasoning off? | Cap sent |-|---|---|---|---|-| `anthropic:*`, `deepseek:*`, `openrouter:deepseek/*` | `thinking: {type:'disabled'}` (unchanged) | yes | requested |-| `google:gemini-2.5-flash*`, `-2.5-flash-lite*` | `thinkingConfig: {thinkingBudget: 0}` | yes (probe G2: 0 reasoning tokens) | requested |-| `google:gemini-2.5-pro*` | `thinkingConfig: {thinkingBudget: 128}` (never `thinkingLevel`; probe G3: a 400 on 2.5) | no (128 is the documented minimum) | 32,000 |-| `google:gemini-3.7-flash`, `-3.8-flash`, `-3-pro*`, `-3.1-pro*` | `thinkingConfig: {thinkingLevel: 'low'}` | no (probe G5: 90 reasoning tokens) | 32,000 |-| `google:gemini-3-flash*`, `-3.5-flash`, `-3.6-flash`, `-3.1-flash-lite*`, `-3.5-flash-lite*` | `thinkingConfig: {thinkingLevel: 'minimal'}` | no (`minimal` does not guarantee off) | 32,000 |-| other `google:gemini-3+`, `gemini-*-latest` aliases | none (an unsupported level is a 400; probe G6) | no | 32,000 |-| `google:` image, TTS, audio, live, transcribe, computer-use ids; Gemini < 2.5 | none, no row | n/a | requested (or `isThinkingModel`) |-| `openai:gpt-5.1`, `-5.2`, `-5.4`(`-mini`/`-nano`), `-5.5`, `-5.6-{luna,sol,terra}` | `reasoningEffort: 'none'` | yes (probe O2) | requested |-| `openai:gpt-5`, `-5-mini`, `-5-nano` | `reasoningEffort: 'minimal'` | no | 32,000 |-| `openai:o1`, `o3`, `o3-mini`, `o4-mini` | `reasoningEffort: 'low'` | no | 32,000 |-| other OpenAI reasoning ids (`-pro`, `-codex`, gpt-6 family, unknown gpt-5+/o-series) | none | no | 32,000 |-| `openai:*-chat*`, `gpt-4o*` | none, no row | n/a | requested |-| every other route | none, no row | when `isThinkingModel` (claude-cli Claude 5, GLM, local reasoning) | 32,000 if thinking, else requested |--Rules the table enforces:--- Never both Google fields: the Google option replaces any configured `thinkingConfig` wholesale (probe G7: both fields together are a 400 on 3.8 Flash).-- A namespace alone is not an off switch: only the native `google` and `openai` recipes get these rows. `openrouter:openai/gpt-5.2`, `openrouter:google/...` and `litellm:` routes get nothing.-- gpt-6 has no option because the pinned `@ai-sdk/openai` 3.0.58 lists only `o1`/`o3`/`o4-mini`/`gpt-5*` as reasoning models (`getOpenAILanguageModelCapabilities`) and drops `reasoningEffort` for gpt-6 with a warning. The unit test caught this; a TODO covers it.-- Sources: Google's generateContent thinking guide (levels per model, budget ranges), OpenAI's reasoning guide (supported efforts per model), and the probe.--Out of scope on purpose: the Google and OpenAI recipes still declare no `thinking_by_default`, so calls without `thinking: 'off'` keep today's default caps. Flipping them would raise default caps (and budget reservations) for every Gemini and gpt-5.5+ caller, which is a wider change than item 5.--## Files and functions touched--- `src/core/ai/thinking-off.ts`: new `ThinkingOffControl`, `thinkingOffControl` (the table: `googleControl`, `openaiControl`); `applyThinkingOff` reads it; `thinkingOffMaxOutputTokens` now takes `thinkingByDefault` and raises the cap when a row keeps reasoning. Removed `thinkingOffNamespace` (no callers outside the module).-- `src/core/ai/gateway.ts`: new export `thinkingOffOutputCap(modelStr, requested)` after `defaultMaxOutputTokens`, and `chat()` uses it (net +2 lines; `scripts/module-size-limits.tsv` ceiling 4425 → 4427 with a note). No change to `instantiateChat`/`instantiateEmbedding`/`instantiateExpansion` (GBRA-52's area).-- `src/core/takes-quality-eval/runner.ts`: `JUDGE_MAX_TOKENS`, `judgeCallCostUsd`; `callOneModel` sends `JUDGE_MAX_TOKENS`; `runEval` projection and correction pricing use `judgeCallCostUsd` and announce a raised cap on stderr.-- `src/core/cross-modal-eval/runner.ts`: `estimateCost` prices each slot at `thinkingOffOutputCap(slot.model, maxTokens)`, notes a raised cap, and `perCallTokens` uses the largest cap.-- `src/commands/eval-cross-modal.ts`: the batch preflight (`--max-usd`) prints the estimate notes, as the single run already did.-- `docs/architecture/key-files/core-ai.md`, `docs/architecture/key-files/evaluation.md`: entries updated.-- `TODOS.md`: one edit. It removes the two wave 9 lines this wave resolves or replaces (item 5 judge estimates; item 9 stall detection) and adds the section "Fix wave 9 follow-ups, round 2" at the top: item 9 (both transports), receipts for the pages/timeline/alias writers, the production fail-closed receipt guard, repair owner delegation, typed `ShutdownInterruptedError`, the judge-panel refresh, and the gpt-6 SDK gap from this lane. The integrator may want to fold other lanes' removals from the wave 9 section into the same hunk.--## Tests--Fail on master source (src stashed, branch tests kept), pass on the branch:--- `test/ai/chat-thinking-off.test.ts` (real gateway against a local stub; the Google request is caught at `fetch`): 27 of 36 fail on master. These are the Google and OpenAI request-body rows (option and cap per model id), configured-value replacement (never both Google fields; OpenAI effort replaced, `prompt_cache_key` kept), the provider-options snapshot per model id, and estimate parity for every default takes-quality panel model and cross-modal slot plus a route that keeps reasoning (`openai:gpt-5`: sent cap = estimated cap = 32,000). The 9 that pass on master are the #5331 rows and three unchanged-behaviour guards (`gpt-4o-mini`, `gpt-5.2-chat-latest`, Google without thinking off). Branch: 36 pass.-- `test/eval-takes-quality-runner.serial.test.ts`: new case "a model that cannot turn thinking off is projected at the output cap its call sends". It fails on master (cycle runs under a $0.30 cap priced at 2,000 tokens) and passes on the branch (aborts before the call, priced at 32,000). Branch: 16 pass.-- Related suites, all green on the branch: `test/ai/` (910 pass), `cross-modal-default-slots`, `cross-modal-eval-prompt`, `default-model-panels`, `eval-cross-modal-batch`, `eval-takes-quality-boundaries`, `eval-takes-quality-pricing`, `nightly-quality-probe`, `cycle/synthesize-gateway-adapter`, `e2e/cross-modal-eval`.--## Release notes for the integrator--CHANGELOG lines (user voice):--- Eval judges on Google and OpenAI now really turn thinking off where the model allows it. `gemini-2.5-flash` on the default takes-quality panel used to think inside its 2,000-token reply budget and could return a cut-off verdict; it now sends `thinkingBudget: 0`. `gpt-5.2` judges now send `reasoning.effort: none` explicitly.-- Models that can't turn thinking off (Gemini 2.5 Pro and 3.x, gpt-5/-mini/-nano, o-series, gpt-6) now run judges at their lowest supported thinking setting with room to finish, and `eval takes-quality --budget-usd` and `eval cross-modal --max-usd` price that larger reply cap and say so, instead of under-estimating it 8-16x.--`BEHAVIOR_CHANGES` candidates (`src/core/behavior-change-notice.ts`):--- `thinking: 'off'` callers (takes-quality and cross-modal judges, the synthesize triage judge) on native Google and OpenAI routes now send a thinking option (table above) and, where reasoning cannot be turned off, a 32,000-token cap. Budget reservations for those calls grow accordingly.-- Judge cost preflights for those routes rise to the 32,000-token cap. A `--budget-usd`/`--max-usd` that passed before can now refuse or abort earlier.--Upgrade notes: none (no migration, no config).--## Live compatibility probe (Decision 6)--One run of `~/.capy/work/w9f-lane-j/probe.ts` (scratch, not committed), with the real AI SDK (`ai` 6.0.174, `@ai-sdk/google` 3.0.67, `@ai-sdk/openai` 3.0.58) and the provider options produced by the branch's `applyThinkingOff`. Caps were reduced from the judge's 2,000 so that the worst case stayed under the $0.02 bound. A plumbing dry run with invalid keys came first; it cost nothing (every call returned 400/401). Prices for the bound: gemini-2.5-flash $0.30/$2.50, gemini-3.8-flash $0.825/$4.125 (the non-global intro rate, an upper bound), gpt-5.2 $1.75/$14 (list price, above the repo's canonical $1.25/$10). gemini-3.8-flash is the newest Gemini 3.x Flash in `models.list` on 2026-10-07.--Summary:--| Case | Model | Options | Cap | Result | Reasoning / text tokens |-|---|---|---|---|---|---|-| G1 | gemini-2.5-flash | none (master) | 600 | stop | 193 / 21 |-| G1b | gemini-2.5-flash | none (master) | 128 | **length**, text `{"score": ` | 120 / 3 |-| G2 | gemini-2.5-flash | `thinkingBudget: 0` (branch) | 600 | stop | 0 / 30 |-| G3 | gemini-2.5-flash | `thinkingLevel: 'low'` | 64 | 400 "Thinking level is not supported for this model." | n/a |-| G4 | gemini-3.8-flash | none | 600 | stop | 130 / 20 |-| G4b | gemini-3.8-flash | none | 128 | **length**, text `{"score": 1` | 119 / 5 |-| G5 | gemini-3.8-flash | `thinkingLevel: 'low'` (branch) | 600 | stop | 90 / 20 |-| G6 | gemini-3.8-flash | `thinkingLevel: 'minimal'` | 64 | 400 "Thinking level MINIMAL is not supported for this model. Please retry with other thinking level." | n/a |-| G7 | gemini-3.8-flash | `thinkingLevel: 'low'` + `thinkingBudget: 0` | 64 | 400 "You can only set only one of thinking budget and thinking level." | n/a |-| O1 | gpt-5.2 | none (master) | 200 | stop; server echoes `reasoning.effort: "none"` | 0 / 31 |-| O2 | gpt-5.2 | `reasoningEffort: 'none'` (branch) | 200 | stop | 0 / 30 |--What it changed in the table: nothing had to move. It confirmed that `thinkingLevel` must never reach 2.5, that `minimal` is a 400 on 3.8 Flash, that both fields together are a 400, and that 3.8 Flash at `low` still reasons (so it gets headroom). It also showed gpt-5.2 already defaults to effort `none`, so the branch's explicit `none` changes no gpt-5.2 output; it pins the behaviour against a configured effort.--### Exact requests and responses+## Exact requests and responsesBodies are the JSON the SDK sent and received, pretty-printed. Headers were not logged; the logger refused any URL carrying a key, and the Google key travelled in the `x-goog-api-key` header. The opaque `thoughtSignature` blobs are elided by length.Run at 2026-10-07T00:50:09.448Z. Worst-case bound (every call hitting its cap at the upper-bound prices): $0.0162. Actual spend from reported usage: $0.00397.-#### G1: `google:gemini-2.5-flash`, maxOutputTokens 600 (master behaviour: no thinkingConfig)+### G1: `google:gemini-2.5-flash`, maxOutputTokens 600 (master behaviour: no thinkingConfig)Request (`POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent`; headers, including the API key header, not recorded):@@ -164,7 +73,7 @@ Response (HTTP 200):}```-#### G1b: `google:gemini-2.5-flash`, maxOutputTokens 128 (master behaviour, small cap: do thoughts consume maxOutputTokens?)+### G1b: `google:gemini-2.5-flash`, maxOutputTokens 128 (master behaviour, small cap: do thoughts consume maxOutputTokens?)Request (`POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent`; headers, including the API key header, not recorded):@@ -229,7 +138,7 @@ Response (HTTP 200):}```-#### G2: `google:gemini-2.5-flash`, maxOutputTokens 600 (branch thinking:'off' mapping)+### G2: `google:gemini-2.5-flash`, maxOutputTokens 600 (branch thinking:'off' mapping)Request (`POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent`; headers, including the API key header, not recorded):@@ -296,7 +205,7 @@ Response (HTTP 200):}```-#### G3: `google:gemini-2.5-flash`, maxOutputTokens 64 (negative: thinkingLevel on 2.5 (table never sends it))+### G3: `google:gemini-2.5-flash`, maxOutputTokens 64 (negative: thinkingLevel on 2.5 (table never sends it))Request (`POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent`; headers, including the API key header, not recorded):@@ -340,7 +249,7 @@ Response (HTTP 400):}```-#### G4: `google:gemini-3.8-flash`, maxOutputTokens 600 (no thinkingConfig (default medium))+### G4: `google:gemini-3.8-flash`, maxOutputTokens 600 (no thinkingConfig (default medium))Request (`POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent`; headers, including the API key header, not recorded):@@ -406,7 +315,7 @@ Response (HTTP 200):}```-#### G4b: `google:gemini-3.8-flash`, maxOutputTokens 128 (no thinkingConfig, small cap)+### G4b: `google:gemini-3.8-flash`, maxOutputTokens 128 (no thinkingConfig, small cap)Request (`POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent`; headers, including the API key header, not recorded):@@ -472,7 +381,7 @@ Response (HTTP 200):}```-#### G5: `google:gemini-3.8-flash`, maxOutputTokens 600 (branch thinking:'off' mapping (floor))+### G5: `google:gemini-3.8-flash`, maxOutputTokens 600 (branch thinking:'off' mapping (floor))Request (`POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent`; headers, including the API key header, not recorded):@@ -541,7 +450,7 @@ Response (HTTP 200):}```-#### G6: `google:gemini-3.8-flash`, maxOutputTokens 64 (negative: thinkingLevel minimal on 3.8 Flash)+### G6: `google:gemini-3.8-flash`, maxOutputTokens 64 (negative: thinkingLevel minimal on 3.8 Flash)Request (`POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent`; headers, including the API key header, not recorded):@@ -585,7 +494,7 @@ Response (HTTP 400):}```-#### G7: `google:gemini-3.8-flash`, maxOutputTokens 64 (negative: both Google fields)+### G7: `google:gemini-3.8-flash`, maxOutputTokens 64 (negative: both Google fields)Request (`POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3.8-flash:generateContent`; headers, including the API key header, not recorded):@@ -630,7 +539,7 @@ Response (HTTP 400):}```-#### O1: `openai:gpt-5.2`, maxOutputTokens 200 (master behaviour: no reasoningEffort)+### O1: `openai:gpt-5.2`, maxOutputTokens 200 (master behaviour: no reasoningEffort)Request (`POST https://api.openai.com/v1/responses`; headers, including the API key header, not recorded):@@ -755,7 +664,7 @@ Response (HTTP 200):}```-#### O2: `openai:gpt-5.2`, maxOutputTokens 200 (branch thinking:'off' mapping)+### O2: `openai:gpt-5.2`, maxOutputTokens 200 (branch thinking:'off' mapping)Request (`POST https://api.openai.com/v1/responses`; headers, including the API key header, not recorded):diff --git a/docs/fix-wave-notes/capy-wave-9-followups.md b/docs/fix-wave-notes/capy-wave-9-followups.mdnew file mode 100644index 0000000000..393a9cbdc1--- /dev/null+++ b/docs/fix-wave-notes/capy-wave-9-followups.md@@ -0,0 +1,203 @@+# Wave 9 follow-ups notes (`capy/wave-9-followups`, v0.60.107.0)++One integrated PR for the nine follow-ups fix wave 9 (v0.60.74.0) filed in+TODOS. Three lanes were built in parallel on master v0.60.99.0 and merged here+onto master v0.60.106.0 (after fix waves 10, 11 and 12 and the four #6188+fence PRs):++- **Lane R+F:** receipted managed writes for conversation facts (batched),+ fence facts, deleted-page expiry, takes reextract and take reprojection, the+ receipt coverage table, the 80% admission stop, and+ `gbrain repair conversation-labels` (items 1 and 2).+- **Lane T:** concept file recheck, take row reservation, shutdown errors,+ supervisor stop, `takes rebuild` under serve (items 3, 4, 6, 7, 8).+- **Lane J:** the judge thinking capability table and judge cost preflights+ (item 5). Item 9 (stall detection) is deferred to TODOS.++Decisions as approved: 1A defer stall detection, 2A one PR, 3A visible+reservation row, 4A expire (not delete), 5A 1970-01-01 facts by default,+6A one capped live probe, 7A only `UnrecoverableError` burns an attempt during+shutdown, 8A stamp the extractor version and count stale outcomes in doctor,+9 batched receipts (about 25 pages or 8 MiB per request, fact pages in smaller+batches, no migration, plus an 80% stop), 10A enforce receipts in tests and+the coverage table only.++## Integration with master++- `fence-repair/llm.ts` (#6188 PR4) used `thinkingOffNamespace`, which lane J+ replaced with the capability table: its Tier 3 ceiling now reserves room to+ reason only where the route's thinking-off option does not turn reasoning+ fully off (gpt-6 gets the 32,000-token cap the gateway sends; Gemini 2.5+ Flash, which now sends `thinkingBudget: 0`, gets the table's size).+- `repair conversation-labels` replays a still-pending batch with the CLI write+ wait, as #6185 made `repair extractor-facts` do.+- Wave 12's `repair timeline-comments` row cleanup is listed in the receipt+ coverage table with its TODO.+- Managed conversation outcome rows stay private under+ `facts.default_visibility=world` (the wave 10 #5120 contract), the managed+ publisher preflights at its first page with work, and+ `conversation_facts_backfill` reports a managed source another host owns as+ skipped (`sources_skipped_not_owner`), as `fence_repair` does.+- On a managed brain `takes rebuild` of a page whose takes are already in sync+ admits nothing and reports `takesUpserted: 0`.++## Receipts (lane R)++### Upgrade notes++- Managed conversation-fact extraction, fence reconcile, takes reextract and+ take-supersession reprojection now preflight like every other managed+ maintenance writer (`maintenancePreflight`): a source with a canonical+ checkout needs its active owner on this host before any model work. The+ cycle and takes paths preflight lazily, on the first page that needs a+ write, so a run with nothing to change never needs it.+- A request still pending after the job's wait is reported (`pages_pending`)+ and replayed on the next run with no model call.++### Decision 9: measured request volume++Run: 200 managed conversation pages on PGLite, three facts per segment with+1536-dimension vectors, injected extractor (no model calls), default caps+(25 pages, 10 fact pages, 8 MiB per request), receipts then force-compacted.+The measurement script was scratch (not committed). The 50k column scales the+200-page run linearly.++| 50k pages | Before batching (one request per page) | Batched, 25% outcome-only | Batched, 75% outcome-only |+|---|---|---|---|+| Requests (permanent request ids) | 50,000 (20% of `principalLifetimeIds`) | 3,750 (1.5%) | 2,000 (0.8%) |+| Reserved receipt bytes, 30-day window | 781 MiB (51% of `principalTerminalBytes`) | 61 MB (3.8%) | 33 MB (2.0%) |+| Retained receipt bytes after compaction | 87 MB (5.5%) | 17 MB (1.1%) | 14 MB (0.9%) |+| Intent per request | 128 KB fact page, 1.5 KB outcome-only | avg 1.6 MB, max 1.6 MB | avg 1.2 MB, max 1.4 MB |++The fact-page cap (10 per request) sets the request count: 150 fact pages+made 15 requests in the 25% run, 50 fact pages and 150 outcome-only pages+made 8 in the 75% run. A batch receipt keeps one result per member+(about 150 bytes each), so a compacted batch receipt keeps about 4.6 KB.+Both mixes are now well under Decision 9's 10% switch threshold. The+`maintenance_backpressure` stop at 80% of reserved receipt bytes and request+ids stays, and the up-front check counts the run's planned batches (pages+over 10).++Before batching, for the record: request ids and reserved receipt bytes were+charged per request (16,384 B flat), so each request type's share of the 20%+and 51% equalled its share of pages; a compacted per-page receipt kept about+1.75 KB.++### Functions touched in `src/commands/extract-conversation-facts.ts`++`ExtractConversationFactsResult` (two optional counters), `ExtractCoreState`+(`managed` is now the publisher or null), `processPage` (three managed call+sites; a managed page is enqueued and counted when its batch publishes),+`runExtractConversationFactsCore` (preflight line, run-stop errors in the two+page loops, the final batch flush before the checkpoint and on the error+path), `runExtractConversationFacts` (aggregate and print the+two counters), `terminalAuditFact`/`nonExtractableAuditFact` (version+stamp); new `currentConversationVersionToken`; removed `replacePageFacts`.+The managed logic lives in `src/core/facts/conversation-publication.ts`.++## Label repair (lane F)++### Decisions applied++- Decision 4 (A): apply expires an approved id set (captured-facts pattern);+ nothing is hard-deleted.+- Decision 5 (A): default set = rows whose context carries+ `segment 1970-01-01`; everything else on a label page is ambiguous, behind+ `--include-ambiguous` with its own hash. Confirmed no post-fix path writes+ that context: the fixed parser records an epoch-dated parse as not+ extractable (`conversationSkip`), so it never reaches segment extraction.++### Notes++- Approved pages apply in batches of up to 25 (one request and one receipt+ per batch on a managed brain, one transaction per batch otherwise), each+ page rechecked on its own under its lock; the apply reports one `retired`+ outcome per batch with per-page outcomes in its detail.++- Under a live `gbrain serve` on PGLite the lock refusal is already immediate+ (`acquireLock` throws `LiveServeLockError` without waiting), and the fatal+ CLI seam's fix is the stop → rerun → restart plan; the test pins it for this+ command. Owner delegation for repair kinds stays a TODO.++## Takes, concepts and jobs (lane T)++### Upgrade notes++- Supervisors started before the upgrade write `worker_exited` rows without a `pid`. `supervisor stop` pairs them with spawns by order and warns. After a restart on the new version, the rows carry the pid and the process start time.++### Integration points and follow-ups++- **Lane R (item 8).** `takes_rebuild` calls `extractTakes({ source: 'db', rebuild: true })`, which on a managed brain publishes through `reextractCoordinated` (`src/core/cycle/extract-takes.ts`). When Lane R moves `reextractCoordinated` onto its receipted takes intent, `takes rebuild` (local and delegated) is receipted with no further change. The op already takes `request_id` (`WRITE_REQUEST_PARAM`), and the CLI sends a fresh UUID. If the intent returns a `write_request` receipt, `runTakesRebuild` renders it as part of the JSON result; pending handling like `runTakesMutation` would be a small addition there.+- **Item 6 follow-up.** In-process, the watchdog aborts the per-job signal, so a cooperative job interrupted by the watchdog burns an attempt (`aborted: watchdog`). Isolated mode treats the watchdog as a shutdown. This was already the case and Decision 7 leaves it alone. `test/worker-shutdown-error-matrix.test.ts` pins the current behavior so any change is deliberate. The strict `ShutdownInterruptedError` stays a TODO.+- **Item 4.** No reader displays `promoted_row_num` today, so the "resolve to removed" reader in the plan has no consumer. The pointer is never cleared and never re-targeted. No doctor check flags a hand-deleted reservation, because #6221 owns fence_integrity.+- **Item 3.** `composeConceptRepublication` and `preserveCanonicalFences` (GBRA-55 #6161) are untouched. The recheck lives in `publishClassicConcept`, `conceptFile` and the new `fileHoldsPage`, plus `writePageThrough({ expectedFileBytes })`.++## Judge thinking caps (lane J)++Item 5 is confirmed on current master and fixed on this branch. Re-verification on 9cc7c4677:++- `chat()` raised a `thinking: 'off'` call's cap to 32,000 only for a thinking-by-default route without a switch (`gateway.ts:3461` on master), but the takes-quality projection priced `estimateCost(m, 5000, 2000)` (`takes-quality-eval/runner.ts:223`, `:259`) and the cross-modal preflight priced `maxTokens` (`cross-modal-eval/runner.ts:410`).+- `thinking-off.ts` had no Google or OpenAI row and `recipes/google.ts` declares no `thinking_by_default`, so `google:gemini-2.5-flash` on the default takes-quality panel ran with dynamic thinking inside the 2,000-token cap.+- The live probe below settles the open question: Gemini thoughts are billed inside `maxOutputTokens`. At a 128-token cap with no thinking config, gemini-2.5-flash spent 120 tokens thinking and returned `{"score": ` with `finishReason: length` (case G1b); gemini-3.8-flash did the same (G4b).++### The capability table (`src/core/ai/thinking-off.ts`)++`thinkingOffControl(modelStr)` returns the provider-options namespace and keys to set and whether they turn reasoning off (`disables`). `applyThinkingOff` and `thinkingOffMaxOutputTokens` (runtime, inside `chat()`) and gateway.ts `thinkingOffOutputCap` (the takes-quality and cross-modal estimates) all read it, so an estimate prices the cap the call sends.++| Route | Option sent under `thinking: 'off'` | Reasoning off? | Cap sent |+|---|---|---|---|+| `anthropic:*`, `deepseek:*`, `openrouter:deepseek/*` | `thinking: {type:'disabled'}` (unchanged) | yes | requested |+| `google:gemini-2.5-flash*`, `-2.5-flash-lite*` | `thinkingConfig: {thinkingBudget: 0}` | yes (probe G2: 0 reasoning tokens) | requested |+| `google:gemini-2.5-pro*` | `thinkingConfig: {thinkingBudget: 128}` (never `thinkingLevel`; probe G3: a 400 on 2.5) | no (128 is the documented minimum) | 32,000 |+| `google:gemini-3.7-flash`, `-3.8-flash`, `-3-pro*`, `-3.1-pro*` | `thinkingConfig: {thinkingLevel: 'low'}` | no (probe G5: 90 reasoning tokens) | 32,000 |+| `google:gemini-3-flash*`, `-3.5-flash`, `-3.6-flash`, `-3.1-flash-lite*`, `-3.5-flash-lite*` | `thinkingConfig: {thinkingLevel: 'minimal'}` | no (`minimal` does not guarantee off) | 32,000 |+| other `google:gemini-3+`, `gemini-*-latest` aliases | none (an unsupported level is a 400; probe G6) | no | 32,000 |+| `google:` image, TTS, audio, live, transcribe, computer-use ids; Gemini < 2.5 | none, no row | n/a | requested (or `isThinkingModel`) |+| `openai:gpt-5.1`, `-5.2`, `-5.4`(`-mini`/`-nano`), `-5.5`, `-5.6-{luna,sol,terra}` | `reasoningEffort: 'none'` | yes (probe O2) | requested |+| `openai:gpt-5`, `-5-mini`, `-5-nano` | `reasoningEffort: 'minimal'` | no | 32,000 |+| `openai:o1`, `o3`, `o3-mini`, `o4-mini` | `reasoningEffort: 'low'` | no | 32,000 |+| other OpenAI reasoning ids (`-pro`, `-codex`, gpt-6 family, unknown gpt-5+/o-series) | none | no | 32,000 |+| `openai:*-chat*`, `gpt-4o*` | none, no row | n/a | requested |+| every other route | none, no row | when `isThinkingModel` (claude-cli Claude 5, GLM, local reasoning) | 32,000 if thinking, else requested |++Rules the table enforces:++- Never both Google fields: the Google option replaces any configured `thinkingConfig` wholesale (probe G7: both fields together are a 400 on 3.8 Flash).+- A namespace alone is not an off switch: only the native `google` and `openai` recipes get these rows. `openrouter:openai/gpt-5.2`, `openrouter:google/...` and `litellm:` routes get nothing.+- gpt-6 has no option because the pinned `@ai-sdk/openai` 3.0.58 lists only `o1`/`o3`/`o4-mini`/`gpt-5*` as reasoning models (`getOpenAILanguageModelCapabilities`) and drops `reasoningEffort` for gpt-6 with a warning. The unit test caught this; a TODO covers it.+- Sources: Google's generateContent thinking guide (levels per model, budget ranges), OpenAI's reasoning guide (supported efforts per model), and the probe.++Out of scope on purpose: the Google and OpenAI recipes still declare no `thinking_by_default`, so calls without `thinking: 'off'` keep today's default caps. Flipping them would raise default caps (and budget reservations) for every Gemini and gpt-5.5+ caller, which is a wider change than item 5.++### Tests++Fail on master source (src stashed, branch tests kept), pass on the branch:++- `test/ai/chat-thinking-off.test.ts` (real gateway against a local stub; the Google request is caught at `fetch`): 27 of 36 fail on master. These are the Google and OpenAI request-body rows (option and cap per model id), configured-value replacement (never both Google fields; OpenAI effort replaced, `prompt_cache_key` kept), the provider-options snapshot per model id, and estimate parity for every default takes-quality panel model and cross-modal slot plus a route that keeps reasoning (`openai:gpt-5`: sent cap = estimated cap = 32,000). The 9 that pass on master are the #5331 rows and three unchanged-behaviour guards (`gpt-4o-mini`, `gpt-5.2-chat-latest`, Google without thinking off). Branch: 36 pass.+- `test/eval-takes-quality-runner.serial.test.ts`: new case "a model that cannot turn thinking off is projected at the output cap its call sends". It fails on master (cycle runs under a $0.30 cap priced at 2,000 tokens) and passes on the branch (aborts before the call, priced at 32,000). Branch: 16 pass.+- Related suites, all green on the branch: `test/ai/` (910 pass), `cross-modal-default-slots`, `cross-modal-eval-prompt`, `default-model-panels`, `eval-cross-modal-batch`, `eval-takes-quality-boundaries`, `eval-takes-quality-pricing`, `nightly-quality-probe`, `cycle/synthesize-gateway-adapter`, `e2e/cross-modal-eval`.++### Live compatibility probe (Decision 6)++One run of `a scratch probe script (not committed), with the real AI SDK (`ai` 6.0.174, `@ai-sdk/google` 3.0.67, `@ai-sdk/openai` 3.0.58) and the provider options produced by the branch's `applyThinkingOff`. Caps were reduced from the judge's 2,000 so that the worst case stayed under the $0.02 bound. A plumbing dry run with invalid keys came first; it cost nothing (every call returned 400/401). Prices for the bound: gemini-2.5-flash $0.30/$2.50, gemini-3.8-flash $0.825/$4.125 (the non-global intro rate, an upper bound), gpt-5.2 $1.75/$14 (list price, above the repo's canonical $1.25/$10). gemini-3.8-flash is the newest Gemini 3.x Flash in `models.list` on 2026-10-07.++Summary:++| Case | Model | Options | Cap | Result | Reasoning / text tokens |+|---|---|---|---|---|---|+| G1 | gemini-2.5-flash | none (master) | 600 | stop | 193 / 21 |+| G1b | gemini-2.5-flash | none (master) | 128 | **length**, text `{"score": ` | 120 / 3 |+| G2 | gemini-2.5-flash | `thinkingBudget: 0` (branch) | 600 | stop | 0 / 30 |+| G3 | gemini-2.5-flash | `thinkingLevel: 'low'` | 64 | 400 "Thinking level is not supported for this model." | n/a |+| G4 | gemini-3.8-flash | none | 600 | stop | 130 / 20 |+| G4b | gemini-3.8-flash | none | 128 | **length**, text `{"score": 1` | 119 / 5 |+| G5 | gemini-3.8-flash | `thinkingLevel: 'low'` (branch) | 600 | stop | 90 / 20 |+| G6 | gemini-3.8-flash | `thinkingLevel: 'minimal'` | 64 | 400 "Thinking level MINIMAL is not supported for this model. Please retry with other thinking level." | n/a |+| G7 | gemini-3.8-flash | `thinkingLevel: 'low'` + `thinkingBudget: 0` | 64 | 400 "You can only set only one of thinking budget and thinking level." | n/a |+| O1 | gpt-5.2 | none (master) | 200 | stop; server echoes `reasoning.effort: "none"` | 0 / 31 |+| O2 | gpt-5.2 | `reasoningEffort: 'none'` (branch) | 200 | stop | 0 / 30 |++What it changed in the table: nothing had to move. It confirmed that `thinkingLevel` must never reach 2.5, that `minimal` is a 400 on 3.8 Flash, that both fields together are a 400, and that 3.8 Flash at `low` still reasons (so it gets headroom). It also showed gpt-5.2 already defaults to effort `none`, so the branch's explicit `none` changes no gpt-5.2 output; it pins the behaviour against a configured effort.++The exact requests and responses are in+[the probe record](capy-wave-9-followups-judge-probe.md).diff --git a/docs/w9f/F.md b/docs/w9f/F.mddeleted file mode 100644index dde44f6c2c..0000000000--- a/docs/w9f/F.md+++ /dev/null@@ -1,53 +0,0 @@-# Wave 9 follow-ups, lane F: repair old label facts--Integrator notes for the release PR (no version stamped).--## CHANGELOG lines--- New `gbrain repair conversation-labels` retires conversation facts that the- parser before v0.60.69 extracted from meeting-note labels (`**Date:**`,- `**Attendees:**`, …) read as speakers, often dated 1970-01-01. It previews- every candidate with its class and a hash, makes no model calls, and needs- the user's consent to apply (`--apply --expect <hash> --yes`). Retired facts- are expired, not deleted. Prose and undated pages are recorded as not- extractable at no cost; other pages re-enter the extraction backlog and the- preview prints the capped re-extract commands- (`gbrain extract-conversation-facts --slugs … --dry-run`).-- Doctor `conversation_label_facts` counts the facts the repair would retire- by default and points at its preview.-- `gbrain extract-conversation-facts --slugs <a,b,…>` processes exactly the- named pages.-- A conversation page whose completion marker was expired is extracted again,- and re-extraction no longer deletes facts an open loop or another fact's- `superseded_by` still references (they are expired instead) or facts the- label repair retired.--## BEHAVIOR_CHANGES candidates--> `gbrain repair conversation-labels` (new, explicit-only) retires conversation facts misattributed to meeting-note labels; it never runs from `gbrain repair --all`, doctor remediation or the upgrade, and it makes no model calls.--> Re-extracting a conversation page now keeps facts an open loop or a superseding fact references, as expired history, instead of deleting them.--## Decisions applied--- Decision 4 (A): apply expires an approved id set (captured-facts pattern);- nothing is hard-deleted.-- Decision 5 (A): default set = rows whose context carries- `segment 1970-01-01`; everything else on a label page is ambiguous, behind- `--include-ambiguous` with its own hash. Confirmed no post-fix path writes- that context: the fixed parser records an epoch-dated parse as not- extractable (`conversationSkip`), so it never reaches segment extraction.--## Notes--- Approved pages apply in batches of up to 25 (one request and one receipt- per batch on a managed brain, one transaction per batch otherwise), each- page rechecked on its own under its lock; the apply reports one `retired`- outcome per batch with per-page outcomes in its detail.--- Under a live `gbrain serve` on PGLite the lock refusal is already immediate- (`acquireLock` throws `LiveServeLockError` without waiting), and the fatal- CLI seam's fix is the stop → rerun → restart plan; the test pins it for this- command. Owner delegation for repair kinds stays a TODO.-- Upstream master moved to v0.60.100.0 while this lane ran; the branch is- based on 9cc7c467 (v0.60.99.0) and does not merge it (integrator's call).diff --git a/docs/w9f/R.md b/docs/w9f/R.mddeleted file mode 100644index 9c2cea8a52..0000000000--- a/docs/w9f/R.md+++ /dev/null@@ -1,111 +0,0 @@-# Wave 9 follow-ups, lane R: receipts on managed brains--Integrator notes for the release PR. Nothing here is stamped: no VERSION, no-CHANGELOG header, no BEHAVIOR_CHANGES row was written to source. Copy the-lines below when the PR is next to merge.--## CHANGELOG lines--- Managed brains now publish conversation facts through receipted maintenance- requests (`managed_maintenance_conversation_facts`), batched across pages:- one request carries up to 25 pages (at most 10 with extracted facts, at- most 8 MiB), and every page's facts and outcome row commit in the same- transaction as that receipt. A page that changed while the batch was being- built is skipped and reported inside the batch; the rest publish. A crash- after the request was accepted replays the stored batch on the next run- without calling the model again; a failed batch is resubmitted from its- stored pages; a page whose rows can never publish, or that sat in three- failed batches, is blocked until it changes.-- Managed brains now extract facts from email threads, and record single- emails, prose meeting notes and undated pages as "not extractable" for good- instead of rescanning them every run.-- `gbrain extract-conversation-facts` on a managed brain stops admitting once- the writer's outstanding requests, reserved receipt bytes or permanent- request ids would pass 80% of their limit (`maintenance_backpressure`,- exit 12; the message names the resource and a `--limit` that fits), checked- up front for the whole planned run and again before each page, and skips a- page whose largest batch cannot fit one request before any model call.-- The cycle `extract_facts` fence reconcile, its deleted-page fact expiry,- `gbrain extract takes --source db` / `gbrain takes rebuild` / the v0.28.0- takes backfill, and `gbrain repair take-supersession`'s database branch now- publish receipted maintenance requests on managed brains. A page that is- already in sync admits nothing.-- Conversation extraction outcomes record the parser/extractor version- (`extractor_version=<n>` in the outcome row context). Doctor- `conversation_outcomes_stale` counts outcomes from an older version; they- are never reopened automatically.--## BEHAVIOR_CHANGES candidate (one row, `since:` = this release)--> Managed brains now extract facts from email threads and record single emails, prose meeting notes and undated pages as not extractable for good. Preview what a run would extract and its segment count with `gbrain extract-conversation-facts --source-id <id> --dry-run`; a two-message thread is one segment, about $0.006 on Haiku 4.5 or $0.017 on Sonnet 4.6. Spend stays under the existing caps (`--max-cost-usd`, default $5; the opt-in `cycle.conversation_facts_backfill` at $1 per run and $5 total); nothing submits extraction automatically. There is no separate opt-out for email threads: leave the backfill off, or narrow `cycle.conversation_facts_backfill.types`.--The per-thread estimate is the plan's per-segment figure (about 3k input and-0.5k output tokens per segment, priced from `model-pricing.ts`), not a-measurement.--## Upgrade notes--- Managed conversation-fact extraction, fence reconcile, takes reextract and- take-supersession reprojection now preflight like every other managed- maintenance writer (`maintenancePreflight`): a source with a canonical- checkout needs its active owner on this host before any model work. The- cycle and takes paths preflight lazily, on the first page that needs a- write, so a run with nothing to change never needs it.-- A request still pending after the job's wait is reported (`pages_pending`)- and replayed on the next run with no model call.--## Decision 9: measured request volume (batched; Garry chose batching, no migration)--Run: 200 managed conversation pages on PGLite, three facts per segment with-1536-dimension vectors, injected extractor (no model calls), default caps-(25 pages, 10 fact pages, 8 MiB per request), receipts then force-compacted.-Script: `~/.capy/work/w9f-r/scratch/measure-d9c.test.ts` (not committed);-outputs `~/.capy/work/w9f-r/out/d9-batched-1.json` (25% outcome-only) and-`d9-batched-3.json` (75% outcome-only). The 50k column scales the 200-page-run linearly.--| 50k pages | Before batching (one request per page) | Batched, 25% outcome-only | Batched, 75% outcome-only |-|---|---|---|---|-| Requests (permanent request ids) | 50,000 (20% of `principalLifetimeIds`) | 3,750 (1.5%) | 2,000 (0.8%) |-| Reserved receipt bytes, 30-day window | 781 MiB (51% of `principalTerminalBytes`) | 61 MB (3.8%) | 33 MB (2.0%) |-| Retained receipt bytes after compaction | 87 MB (5.5%) | 17 MB (1.1%) | 14 MB (0.9%) |-| Intent per request | 128 KB fact page, 1.5 KB outcome-only | avg 1.6 MB, max 1.6 MB | avg 1.2 MB, max 1.4 MB |--The fact-page cap (10 per request) sets the request count: 150 fact pages-made 15 requests in the 25% run, 50 fact pages and 150 outcome-only pages-made 8 in the 75% run. A batch receipt keeps one result per member-(about 150 bytes each), so a compacted batch receipt keeps about 4.6 KB.-Both mixes are now well under Decision 9's 10% switch threshold. The-`maintenance_backpressure` stop at 80% of reserved receipt bytes and request-ids stays, and the up-front check counts the run's planned batches (pages-over 10).--Before batching, for the record: request ids and reserved receipt bytes were-charged per request (16,384 B flat), so each request type's share of the 20%-and 51% equalled its share of pages; a compacted per-page receipt kept about-1.75 KB.--## Functions touched in GBRA-52's file (`src/commands/extract-conversation-facts.ts`)--`ExtractConversationFactsResult` (two optional counters), `ExtractCoreState`-(`managed` is now the publisher or null), `processPage` (three managed call-sites; a managed page is enqueued and counted when its batch publishes),-`runExtractConversationFactsCore` (preflight line, run-stop errors in the two-page loops, the final batch flush before the checkpoint and on the error-path), `runExtractConversationFacts` (aggregate and print the-two counters), `terminalAuditFact`/`nonExtractableAuditFact` (version-stamp); new `currentConversationVersionToken`; removed `replacePageFacts`.-The managed logic lives in `src/core/facts/conversation-publication.ts`.--## TODOs (not written to TODOS.md)--- Receipts for the pages, timeline and alias derived writers- (`page-state/materialize.ts`, `timeline-extract.ts`, `reindex-aliases.ts`,- `mentions/pass.ts`) and for bootstrap verify's probe-fact cleanup- (`bootstrap/verify.ts`), each listed in `test/receipt-coverage.test.ts`.-- Production fail-closed receipt guard (Decision 10 B): the contract harness- enforces it today.-- Decision 9 follow-up above.-- A parser-version change is part of the generation identity but has no- runtime test (the version is a constant); the stamp and doctor count are- tested.diff --git a/docs/w9f/T.md b/docs/w9f/T.mddeleted file mode 100644index c4b741d897..0000000000--- a/docs/w9f/T.md+++ /dev/null@@ -1,30 +0,0 @@-# W9F lane T: takes, concepts, jobs--Branch `capy/w9f-lane-t` from origin/master 9cc7c467 (v0.60.99.0). No migration, no version bump.-The integrator folds these lines into the wave's CHANGELOG entry and `BEHAVIOR_CHANGES`.--## CHANGELOG lines--- Unmanaged brains: dream-cycle concept publication no longer overwrites a concept's markdown file when the file holds an edit the database has not imported (narrative, frontmatter, tags, type or title), or an edit made while the import ran. The concept is deferred (`revision_conflict`) and publishes after sync imports the edit. A failed file write now holds the concept (`concept_write_through_failed`) instead of reporting success. (item 3)-- `gbrain takes remove` leaves a reservation row (`| N | ~~(removed)~~ | take | world | 0.0 | | removed |`) in the takes fence, so a removed take's number is never handed out again and `slug#N` citations and `take_proposals.promoted_row_num` never start pointing at an unrelated take. Every new take row number now comes from the shared `nextFreeRowNum` allocator. (item 4)-- Worker shutdown: an `UnrecoverableError` thrown while the worker shuts down now dead-letters on its first attempt with its own error text, instead of being re-queued as `worker_shutdown` for a second (possibly paid) run. Other errors during shutdown are still handed back with no attempt burned, and the hand-back now keeps the handler's text (`error_text = 'worker_shutdown: <handler error>'`). (item 6)-- `gbrain jobs supervisor stop`: a recycled worker pid no longer reads as `worker_still_running`; a supervisor started before the ISO-week boundary no longer reports a false `drained`; a run whose `started` audit row is missing or pruned reports `unverified`; and a stale PID file whose pid now belongs to another process is never signaled (`stale_pid_file`). (item 7)-- `gbrain takes rebuild <slug>` works while `gbrain serve` owns a PGLite brain (it used to hang on the owner's lock until killed). It is now the local-only `takes_rebuild` operation, delegated to the resident owner, with the same JSON, warnings and exit codes as a local rebuild. (item 8)--## BEHAVIOR_CHANGES candidates--1. **Take numbering on pages with a facts fence (item 4).** `nextFreeRowNum` is page-wide by GBRA-54's agreed contract: one more than every fence row number on the page, facts and takes, live, struck and reserved, plus stored facts/takes rows. The first take added to a page whose facts fence holds rows 1-5 is now #6, not #1. Existing rows are never renumbered. No opt-out.-2. **Visible reservation rows (item 4, Decision 3A).** `takes remove` now leaves a struck `(removed)` row in the user's markdown instead of deleting the line. The claim, holder and other cells are reset, so no removed text stays. The promise holds only while the row exists; deleting it by hand frees the number again.-3. **Shutdown error text (item 6).** `minion_jobs.error_text` for a shutdown hand-back is `worker_shutdown: <handler error>`, not bare `worker_shutdown`. Anything matching the exact string should match the prefix. The drain-expiry hand-back (no handler error) stays bare `worker_shutdown`.-4. **Supervisor stop reasons and PID file (item 7).** New stop outcomes: `unverified` (exit 1) and `stale_pid_file` (exit 0, `stopped: false`), plus `warnings: ['legacy_exit_pairing']` on audit rows written before this release. The PID file now holds a second line with the kernel start time on Linux; every gbrain reader takes the first line. External tools that parse the whole file as one integer need to read the first line.--## Upgrade notes--- Supervisors started before the upgrade write `worker_exited` rows without a `pid`. `supervisor stop` pairs them with spawns by order and warns. After a restart on the new version, the rows carry the pid and the process start time.--## Integration points and follow-ups--- **Lane R (item 8).** `takes_rebuild` calls `extractTakes({ source: 'db', rebuild: true })`, which on a managed brain publishes through `reextractCoordinated` (`src/core/cycle/extract-takes.ts`). When Lane R moves `reextractCoordinated` onto its receipted takes intent, `takes rebuild` (local and delegated) is receipted with no further change. The op already takes `request_id` (`WRITE_REQUEST_PARAM`), and the CLI sends a fresh UUID. If the intent returns a `write_request` receipt, `runTakesRebuild` renders it as part of the JSON result; pending handling like `runTakesMutation` would be a small addition there.-- **Item 6 follow-up.** In-process, the watchdog aborts the per-job signal, so a cooperative job interrupted by the watchdog burns an attempt (`aborted: watchdog`). Isolated mode treats the watchdog as a shutdown. This was already the case and Decision 7 leaves it alone. `test/worker-shutdown-error-matrix.test.ts` pins the current behavior so any change is deliberate. The strict `ShutdownInterruptedError` stays a TODO.-- **Item 4.** No reader displays `promoted_row_num` today, so the "resolve to removed" reader in the plan has no consumer. The pointer is never cleared and never re-targeted. No doctor check flags a hand-deleted reservation, because #6221 owns fence_integrity.-- **Item 3.** `composeConceptRepublication` and `preserveCanonicalFences` (GBRA-55 #6161) are untouched. The recheck lives in `publishClassicConcept`, `conceptFile` and the new `fileHoldsPage`, plus `writePageThrough({ expectedFileBytes })`.diff --git a/src/core/ai/thinking-off.ts b/src/core/ai/thinking-off.tsindex 0ee1784ebe..05494b7132 100644--- a/src/core/ai/thinking-off.ts+++ b/src/core/ai/thinking-off.ts@@ -42,7 +42,7 @@** Gemini rows follow Google's generateContent thinking docs; OpenAI rows* follow the reasoning guide. Both were checked live on 2026-10-07- * (docs/w9f/lane-j.md).+ * (docs/fix-wave-notes/capy-wave-9-followups.md).*/import { splitProviderModelId } from '../model-id.ts';