Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
eval cross-modal: resolve judge slots from models.eval.cross_modal.slot_* before the defaults (#6486)
garrytand32211ace118
diff --git a/docs/architecture/key-files/core-cycle.md b/docs/architecture/key-files/core-cycle.mdindex 8a720210a3..aa56ccd95b 100644--- a/docs/architecture/key-files/core-cycle.md+++ b/docs/architecture/key-files/core-cycle.md@@ -36,7 +36,7 @@ Current behavior and load-bearing invariants; history belongs in Git and CHANGEL- `src/core/cycle/nightly-probe-fixtures.ts` — `NIGHTLY_PROBE_FIXTURES`: the LongMemEval nightly fixture and the conversation-parser probe's two fixture files, embedded with `import ... with { type: 'file' }` (types in `src/types/jsonl-assets.d.ts`). A source checkout resolves them to `test/fixtures/...`, a compiled binary to a `/$bunfs/` path `readFileSync` reads, so both installs run the probes (#5187, C-N6). Pinned by `test/nightly-probe-compiled-binary.serial.test.ts` (a `bun build --compile` harness copied to an empty dir runs both autopilot probe steps on a hermetic provider, plus a source-mode run).-- `src/core/cycle/nightly-probe-routes.ts` — the nightly probe's model routes, resolved against the live brain by the caller that holds the engine (the search-config-snapshot shape). `resolveNightlyProbeModelRoutes(engine)`: reader through `NIGHTLY_PROBE_READER_ROUTE` (`models.eval.longmemeval` → `models.tier.reasoning` → `models.default` → `GBRAIN_MODEL` → key-aware default, the chain `gbrain models` reports for that key), extractor through `NIGHTLY_PROBE_EXTRACTOR_ROUTE` (utility tier), and the optional `models.eval.cross_modal.slot_{a,b,c}` keys (`NIGHTLY_PROBE_SLOT_KEYS`; alias-expanded, blank = unset). Any read failure rethrows as `NightlyProbeModelRoutesError`, whose message names the routes. Consumed by `autopilot-probes.ts` (after a gateway refresh) and `gbrain models`. Pinned by `test/cycle/nightly-probe-routes.test.ts`.+- `src/core/cycle/nightly-probe-routes.ts` — the nightly probe's model routes, resolved against the live brain by the caller that holds the engine (the search-config-snapshot shape). `resolveNightlyProbeModelRoutes(engine)`: reader through `NIGHTLY_PROBE_READER_ROUTE` (`models.eval.longmemeval` → `models.tier.reasoning` → `models.default` → `GBRAIN_MODEL` → key-aware default, the chain `gbrain models` reports for that key), extractor through `NIGHTLY_PROBE_EXTRACTOR_ROUTE` (utility tier), and the optional `models.eval.cross_modal.slot_{a,b,c}` keys (`NIGHTLY_PROBE_SLOT_KEYS`; alias-expanded, blank = unset). Any read failure rethrows as `NightlyProbeModelRoutesError`, whose message names the routes. Consumed by `autopilot-probes.ts` (after a gateway refresh) and `gbrain models`. Pinned by `test/cycle/nightly-probe-routes.test.ts`. `readCrossModalSlotConfig(reader)` is the one slot-pin reader (#6486), shared with `gbrain eval cross-modal`: the CLI resolves each judge slot as `--slot-<x>-model` flag → `models.eval.cross_modal.slot_<x>` → `DEFAULT_SLOTS` (`resolveSlotModels` in `src/commands/eval-cross-modal.ts`; a config pin counts as explicit for the #4636 substitution), reading the pins through `readCrossModalSlotConfigFrom(connect)` only when some slot has no flag; `src/cli/main.ts` passes a probe-only connect (no migrations, closed after the read) and a reader that throws (no brain, brain busy) leaves the defaults, so the command stays usable before `gbrain init`. Pinned by `test/cross-modal-slot-config-6486.test.ts`.- `src/core/cycle/nightly-quality-probe.ts` + `src/core/audit-quality-probe.ts` + `test/fixtures/longmemeval-nightly.jsonl` + `test/nightly-quality-probe.test.ts` — opt-in nightly cross-modal quality probe. The phase runs `gbrain eval longmemeval --by-type` against the committed 10-question placeholder fixture, pipes output through `gbrain eval cross-modal --batch --max-usd 5 --yes`, and writes one event per run to `~/.gbrain/audit/quality-probe-YYYY-Www.jsonl` (ISO-week-rotated, mirrors `audit-slug-fallback.ts`; honors `GBRAIN_AUDIT_DIR`). Default DISABLED — opt-in via `gbrain config set autopilot.nightly_quality_probe.enabled true` (prevents surprise API spend). 24h rate limit (pure `shouldRunNightly(now, recentEvents, windowMs?)`) skips without an audit row. An unreadable fixture writes `outcome: skipped` with `reason: fixture_unavailable` (exit 0, no model call; the row also holds the 24h gate). Embedding-key short-circuit: longmemeval needs `gateway.embedQuery()`, so the phase exits early with `outcome: no_embedding_key` + stderr warn when no provider configured. Full DI surface via `NightlyProbeDeps` (`isEnabled`, `hasEmbeddingProvider`, `resolveMaxUsd`, optional `resolveBudgetPolicy`, `resolveFixturePath` (wins) / `resolveRepoRoot`, `resolveSearchConfigSnapshot` and `resolveModelRoutes`, `runLongMemEval`, `runCrossModalBatch`, `now`) so the unit test stubs every external effect. `resolveModelRoutes` runs inside the run's `try` before LongMemEval and its routes reach both adapters; a rejection becomes an `error` audit row naming the model routes and LongMemEval never starts. Rows also carry the evidence behind the verdict (#5506), every field optional so older rows read unchanged (`logQualityProbeEvent` copies them from one explicit list): `reader_model` / `extractor_model` once the routes resolved; `judge_models` in slot order, `judge_scored_questions` per slot, and `distinct_judge_models` / `distinct_judge_providers` over the slots that scored, from a completed batch; on a non-pass row, up to 10 `failures` (failing dimensions with mean, slot-indexed scores and fail reason, or redacted error text) and a one-line digest `detail` counting every question that did not pass, malformed rows included, and naming a slot that scored none. One pricing `withChatCallMeter` meter wraps LongMemEval and the batch, so every row of a run that reached its model calls, a part-way failure included, records `chat_calls`, `chat_cost_usd` (reader, extractor and judges) and `unpriced_chat_calls`; `est_cost_usd` stays the batch's pre-flight estimate for its judge calls only, 0 without a summary. Run-level budget (CEO B4): one `BudgetTracker` (`withBudgetTracker`) wraps both stages with `max_usd` as the cap (`resolveProbeCap`: a configured value is a `user` cap, else the $5 `default`; `pricing.overrides` from the brain), so every gateway chat/embed call of LongMemEval and the judges reserves first. A refusal is kept by the `ProbeBudgetTracker` subclass even when LongMemEval records it as a per-question error: exhausted after LongMemEval → `budget_exceeded`, no judge call; exhausted while judging → `budget_exceeded` whatever the batch said; a user cap refuses an unpriced model with the shared no_pricing text (`reason: no_pricing`), a default cap warns and runs it. Rows carry `cap_usd` / `cap_source`. A pass or fail from a collapsed panel (one model holding two judged slots, or fewer than two models judged) becomes `inconclusive` with `reason: panel_collapsed`, the batch verdict and the slot-key remedy in `detail` (D12). A non-pass run copies `summary.json` / `lme-output.jsonl` to `<audit dir>/nightly-probe/<ts>/` (newest 7) and names it in `receipt_dir`. The `nightly_quality_probe_health` doctor check (`computeNightlyQualityProbeHealthCheck` in `src/commands/doctor/checks/search-eval.ts`, registered right after `slug_fallback_audit` by `src/commands/doctor/checks/local-audits.ts`) reads last 7 days: SKIPPED when flag off (with enable command); OK when enabled + all PASS; WARN on any non-PASS outcome with per-outcome counts (`skipped=N` appended when a run skipped), so a skipped run is never OK. OK and WARN append the latest row's judge panel and name a slot that scored no question; among the slots that scored, a model holding two or more gets the remedy (three different models in `models.eval.cross_modal.slot_a` / `slot_b` / `slot_c`), fewer than three providers get the not-cross-modal information; a row without valid panel fields keeps the plain message. Pinned by `test/nightly-quality-probe.test.ts`.diff --git a/skills/skillify/SKILL.md b/skills/skillify/SKILL.mdindex 1196760ac1..abb36997b1 100644--- a/skills/skillify/SKILL.md+++ b/skills/skillify/SKILL.md@@ -287,21 +287,29 @@ gbrain eval cross-modal \--output skills/<slug>/SKILL.md```-The command runs 3 frontier models from 3 different providers in parallel,+The command runs 3 judge models (frontier models from 3 different providers) in parallel,scores the OUTPUT against the TASK on the given dimensions (default: 5standard dimensions when `--dimensions` is omitted), and writes a receiptunder `~/.gbrain/.gbrain/eval-receipts/<slug>-<sha8>.json` (the sha-8 bindsthe receipt to the current SKILL.md content — re-running after edits writes anew receipt, so every iteration leaves its own baseline).-**Default models** (override per slot via `--slot-a-model`, `--slot-b-model`,-`--slot-c-model`):+**Judge models** resolve per slot, in this order:-| Slot | Default | Provider |-|------|---------|----------|-| A | `openai:gpt-5.2` | OpenAI |-| B | `anthropic:claude-opus-4-7` | Anthropic |-| C | `deepseek:deepseek-v4-pro` | DeepSeek |+| Slot | 1. flag | 2. brain config key | 3. fallback |+|------|---------|---------------------|-------------|+| A | `--slot-a-model <provider:model>` | `models.eval.cross_modal.slot_a` | gbrain's shipped default for slot A |+| B | `--slot-b-model <provider:model>` | `models.eval.cross_modal.slot_b` | gbrain's shipped default for slot B |+| C | `--slot-c-model <provider:model>` | `models.eval.cross_modal.slot_c` | gbrain's shipped default for slot C |++The brain config keys are the same ones the nightly quality probe reads, so+pin them once (`gbrain config set models.eval.cross_modal.slot_a+<provider:model>`) and every run — CLI or probe — judges with the same+panel. `gbrain models` shows the panel the probe resolves. The shipped+defaults are three current frontier models from three providers; they move+with gbrain releases, so do not copy literal ids into a skill — a slot whose+default provider has no key here is substituted with the configured chat+model (#4636) and the receipt records the model that actually judged.**These MUST be frontier models from DIFFERENT providers.** Using a singleprovider's family or budget models defeats the purpose — different families@@ -361,9 +369,11 @@ gbrain providers test # see what's configuredgbrain config # set keys```-Or set env vars: `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`,-`GOOGLE_GENERATIVE_AI_API_KEY`, `TOGETHER_API_KEY`, etc. The gateway reads-from `~/.gbrain/config.json` plus `process.env`.+Each slot needs a key for its provider: `gbrain providers test --model+<provider:model>` says whether a slot's model is reachable, and `gbrain+providers env <provider>` names the env var or `<vendor>_api_key` config key+that recipe reads (`~/.gbrain/config.json` plus `process.env`). Pin the slots+to providers you have keys for instead of acquiring keys for the defaults.### Cost expectations@@ -526,10 +536,11 @@ Phase 2: Write SKILL.md + extract script to scripts/summarize-pr.tsPhase 2.5: Declare eval_contract — goal: reviewer-ready PR summary;dimensions: file_coverage, test_plan, specificity;hard-fail: any fabricated claim about the diff-Phase 3: Cross-modal eval cycle 1 (dimensions from the contract) →- gpt-5.2: file_coverage=6, test_plan=4, specificity=5 → "misses file-level diffs"- claude-opus-4-7: file_coverage=7, test_plan=5, specificity=5 → "no test plan in summary"- deepseek-v4-pro: file_coverage=6, test_plan=5, specificity=5 → "template feels generic"+Phase 3: Cross-modal eval cycle 1 (dimensions from the contract; slots from+ models.eval.cross_modal.slot_*) →+ slot A (<provider-1 model>): file_coverage=6, test_plan=4, specificity=5 → "misses file-level diffs"+ slot B (<provider-2 model>): file_coverage=7, test_plan=5, specificity=5 → "no test plan in summary"+ slot C (<provider-3 model>): file_coverage=6, test_plan=5, specificity=5 → "template feels generic"Aggregate: file_coverage=6.3 FAIL, test_plan=4.7 FAILTop improvements: add file-level changes, include test plan, use PR context→ Apply fixes → Cycle 2: file_coverage=8, test_plan=7.5, specificity=7 → PASSdiff --git a/skills/skills.lock.json b/skills/skills.lock.jsonindex 69794209ef..0d239b26a7 100644--- a/skills/skills.lock.json+++ b/skills/skills.lock.json@@ -214,7 +214,7 @@"skill-optimizer/SKILL.md": "1dea9a5257a60fb29a4c7701c92bce428025fb2321e950533f1367edfca1b8b0","skill-optimizer/routing-eval.jsonl": "48f7fc04414b194ee8674577c3e58e03ebd7f74d836766bd16cb5abfd4effb76","skill-optimizer/skillopt-benchmark.jsonl": "5552457d6eaa32486b79796d12fcbe2c078b0c53d7fbdaf582f0fd1a17e9a381",- "skillify/SKILL.md": "d7cf802c7291642dacf922f3557f7e4c258f471c6dcf8feea1460710539ea263",+ "skillify/SKILL.md": "6fa84bd744b1082d6550def977b49ecaac7ada0abf1a04180a8e3b0d432fb20e","skillify/routing-eval.jsonl": "c0a55ee371bb7a797c76d58cf211407a667930673e34e945e09047470cdfd2f4","skillpack-check/SKILL.md": "bcb96d0d231827c9fcd47865f63aaef70c9b9f7a7402464594f24f5fe1eeff8c","skillpack-harvest/SKILL.md": "0f86314b58d25b5511809f567c04aedc3fba6fe35ed642ac52d8216ae365b6eb",diff --git a/src/cli/main.ts b/src/cli/main.tsindex 191ee0a248..2becf9453b 100755--- a/src/cli/main.ts+++ b/src/cli/main.ts@@ -2131,8 +2131,8 @@ async function routeEngineFreeSubcommands(command: string, args: string[]): Prom// doesn't even attempt the connect (T3=A in plans/radiant-napping-lerdorf.md).// The handler self-configures the AI gateway from loadConfig() + process.env.if (command === 'eval' && args[0] === 'cross-modal') {- const { runEvalCrossModal } = await import('../commands/eval-cross-modal.ts');- setCliExitVerdict(await runEvalCrossModal(args.slice(1)));+ const [{ runEvalCrossModal }, { readCrossModalSlotConfigFrom }] = await Promise.all([import('../commands/eval-cross-modal.ts'), import('../core/cycle/nightly-probe-routes.ts')]);+ setCliExitVerdict(await runEvalCrossModal(args.slice(1), { slotConfig: () => readCrossModalSlotConfigFrom(() => connectEngineForServe(ENGINE_CONNECT_HOOKS, { probeOnly: true })) }));return true;}diff --git a/src/commands/eval-cross-modal.ts b/src/commands/eval-cross-modal.tsindex f9ae31e9e4..fa3c7d51a4 100644--- a/src/commands/eval-cross-modal.ts+++ b/src/commands/eval-cross-modal.ts@@ -344,6 +344,37 @@ export interface RunCrossModalOpts {* substitution still run, in batch mode even with an injected `runEval`.*/useConfiguredGateway?: boolean;+ /**+ * #6486: the brain's `models.eval.cross_modal.slot_{a,b,c}` pins, read+ * only when some slot has no `--slot-*-model` flag. `src/cli/main.ts`+ * passes a fail-open probe-only read of the configured brain; a reader+ * that throws (no brain, brain busy) leaves the defaults in place.+ */+ slotConfig?: () => Promise<Partial<Record<'A' | 'B' | 'C', string>>>;+}++type SlotFlags = Pick<ParsedArgs, 'slotAModel' | 'slotBModel' | 'slotCModel'>;+type SlotPins = Partial<Record<'A' | 'B' | 'C', string>>;++/** Per slot: `--slot-<x>-model` flag → brain pin → DEFAULT_SLOTS (#6486). */+export function resolveSlotModels(flags: SlotFlags, pins: SlotPins): SlotConfig[] {+ const pin = (id: 'A' | 'B' | 'C') => pins[id]?.trim() || undefined;+ return [+ { id: 'A', model: flags.slotAModel ?? pin('A') ?? DEFAULT_SLOTS[0]!.model },+ { id: 'B', model: flags.slotBModel ?? pin('B') ?? DEFAULT_SLOTS[1]!.model },+ { id: 'C', model: flags.slotCModel ?? pin('C') ?? DEFAULT_SLOTS[2]!.model },+ ];+}++/** The pins to consult: none when every slot is flagged, and a throwing reader counts as no pins. */+async function readSlotPins(flags: SlotFlags, read: RunCrossModalOpts['slotConfig']): Promise<SlotPins> {+ if (!read || (flags.slotAModel && flags.slotBModel && flags.slotCModel)) return {};+ try {+ return await read();+ } catch (err) {+ process.stderr.write(`[eval cross-modal] could not read models.eval.cross_modal.slot_* from the brain (${err instanceof Error ? err.message : String(err)}); using the default slots.\n`);+ return {};+ }}export async function runEvalCrossModal(args: string[], opts: RunCrossModalOpts = {}): Promise<number> {@@ -396,11 +427,8 @@ export async function runEvalCrossModal(args: string[], opts: RunCrossModalOptsconst receiptDir = parsed.receiptDir ?? gbrainPath('eval-receipts');const maxTokens = parsed.maxTokens ?? 4000;- let slots: SlotConfig[] = [- { id: 'A', model: parsed.slotAModel ?? DEFAULT_SLOTS[0]!.model },- { id: 'B', model: parsed.slotBModel ?? DEFAULT_SLOTS[1]!.model },- { id: 'C', model: parsed.slotCModel ?? DEFAULT_SLOTS[2]!.model },- ];+ const pins = await readSlotPins(parsed, opts.slotConfig);+ let slots: SlotConfig[] = resolveSlotModels(parsed, pins);// Configure the AI gateway. Without this, every chat() call throws// "AI gateway is not configured" because the cli.ts no-DB branch skips@@ -419,7 +447,7 @@ export async function runEvalCrossModal(args: string[], opts: RunCrossModalOpts// #4636: swap unusable frontier defaults for the configured chat model// (before the cost estimate so the banner prices what actually runs).slots = substituteUnavailableDefaultSlots(slots, {- A: parsed.slotAModel, B: parsed.slotBModel, C: parsed.slotCModel,+ A: parsed.slotAModel ?? pins.A, B: parsed.slotBModel ?? pins.B, C: parsed.slotCModel ?? pins.C,});// Cost estimate (T11=B).@@ -738,11 +766,8 @@ async function runBatchMode(parsed: ParsedArgs, opts: RunCrossModalOpts): Promisconst maxTokens = parsed.maxTokens ?? 4000;const maxUsd = parsed.maxUsd ?? 5.0;- let slots: SlotConfig[] = [- { id: 'A', model: parsed.slotAModel ?? DEFAULT_SLOTS[0]!.model },- { id: 'B', model: parsed.slotBModel ?? DEFAULT_SLOTS[1]!.model },- { id: 'C', model: parsed.slotCModel ?? DEFAULT_SLOTS[2]!.model },- ];+ const pins = await readSlotPins(parsed, opts.slotConfig);+ let slots: SlotConfig[] = resolveSlotModels(parsed, pins);// v0.40.1.0 Track D (codex CDX-2): --limit must be >= 1. Passing// --limit 0 would let an empty result fall through to PASS with@@ -795,7 +820,7 @@ async function runBatchMode(parsed: ParsedArgs, opts: RunCrossModalOpts): Promis}// #4636: swap unusable frontier defaults for the configured chat model.slots = substituteUnavailableDefaultSlots(slots, {- A: parsed.slotAModel, B: parsed.slotBModel, C: parsed.slotCModel,+ A: parsed.slotAModel ?? pins.A, B: parsed.slotBModel ?? pins.B, C: parsed.slotCModel ?? pins.C,});}diff --git a/src/core/cli-flag-registry.generated.ts b/src/core/cli-flag-registry.generated.tsindex c29736007e..a3df7369ce 100644--- a/src/core/cli-flag-registry.generated.ts+++ b/src/core/cli-flag-registry.generated.ts@@ -46,7 +46,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'core': ['--apply', '--brain', '--fail-fast', '--help', '--include-core', '--json', '--priority', '--revision', '--slug', '--source', '--tools-json'],'creds': ['--allow-create-db', '--allow-docker', '--brain', '--chat-model', '--content-root', '--db-only', '--embedding-dimensions', '--embedding-model', '--expansion-model', '--force', '--git', '--grant-types', '--help', '--http', '--ids', '--issuer-url', '--json', '--key', '--local-postgres', '--mcp-only', '--mcp-url', '--migrate-only', '--model', '--no-embedding', '--no-git', '--non-interactive', '--oauth-client-id', '--oauth-client-secret', '--out', '--passphrase-env', '--path', '--pglite', '--plan', '--prefer-postgres', '--provenance', '--provider', '--query', '--schema-pack', '--scopes', '--skip-embed-check', '--source', '--status', '--supabase', '--surface', '--to', '--url', '--version'],'db-repair': ['--accept-pending', '--apply', '--apply-rewrites', '--background', '--brain', '--break-lock', '--db-url', '--dry-run', '--explain', '--filter', '--follow', '--force', '--force-retry', '--format', '--help', '--http', '--json', '--locks', '--name', '--no-accept-pending', '--path', '--prefer-postgres', '--probe', '--progress-interval', '--progress-json', '--quiet', '--remediate', '--restart', '--skip-verify', '--source', '--supabase', '--timeout', '--undo-last-rewrite', '--url', '--version', '--wait', '--yes'],- 'decide': ['--accept-all', '--all', '--all-from', '--apply', '--brain', '--call-site', '--dataset', '--dry-run', '--egress', '--embedding-dimensions', '--embedding-model', '--expect', '--from', '--help', '--include-withdrawals', '--input', '--json', '--kind', '--limit', '--max-cost', '--max-usd', '--min', '--non-interactive', '--out', '--provenance', '--provider', '--query', '--reason', '--reason-family', '--recommended', '--remove', '--shadow', '--since', '--slot', '--source', '--status', '--suite', '--target', '--threshold', '--trust', '--undo', '--uri-prefix', '--version', '--what-if-threshold', '--yes'],+ 'decide': ['--accept-all', '--all', '--all-from', '--apply', '--brain', '--call-site', '--dataset', '--dry-run', '--egress', '--embedding-dimensions', '--embedding-model', '--expect', '--from', '--help', '--include-withdrawals', '--input', '--json', '--kind', '--limit', '--max-cost', '--max-usd', '--min', '--non-interactive', '--out', '--provenance', '--provider', '--query', '--rate', '--reason', '--reason-family', '--recommended', '--remove', '--shadow', '--since', '--slot', '--source', '--status', '--suite', '--target', '--threshold', '--trust', '--undo', '--uri-prefix', '--version', '--what-if-threshold', '--yes'],'doctor': ['--abandon', '--abbrev-ref', '--abort', '--accept-pending', '--access', '--add', '--admin-intent', '--adopt', '--adopt-columns', '--adopt-permissions', '--all', '--all-from', '--allow-old-serve', '--allow-shell-jobs', '--allow-unverified-remote', '--allowed-operations', '--apply', '--apply-rewrites', '--assign-corpus', '--audit', '--auto', '--auto-fix', '--background', '--bound-brain', '--bound-max-concurrent', '--bound-source', '--bound-tools', '--brain', '--branch', '--break-lock', '--budget-ms', '--budget-usd', '--by-mention', '--cached', '--call-site', '--catch-up', '--check', '--client', '--concurrency', '--confidence', '--confirm', '--confirm-quiesced', '--confirm-relocated-root', '--contacts-dir', '--content-audit', '--content-root', '--count', '--dataset', '--db-url', '--delegated-namespace', '--delegated-slug-prefixes', '--delete-brain', '--dest', '--detach', '--diff-filter', '--dim', '--dir', '--disable', '--drain', '--drain-timeout', '--dry-run', '--egress', '--embedding-dimensions', '--embedding-model', '--enable', '--end-of-options', '--env', '--error-unmatch', '--exclude', '--exclude-standard', '--exit-code', '--expect', '--expected-epoch', '--expected-revision', '--expected-state', '--explain', '--facts', '--fast', '--federated-read', '--fetch-timeout-ms', '--ff-only', '--file', '--fix', '--follow', '--force', '--force-rechunk', '--force-retry', '--force-schema', '--format', '--fresh', '--from', '--from-meetings', '--from-pages', '--full', '--get', '--get-url', '--git-common-dir', '--git-dir', '--git-path', '--group', '--hard', '--hard-deadline', '--harness', '--help', '--home', '--http', '--id', '--if-version', '--ignore-env-override', '--images', '--include-ambiguous', '--include-flagged', '--include-gitignored', '--include-hidden', '--include-pseudo', '--include-repairs', '--include-withdrawals', '--index-audit', '--init', '--input', '--install', '--is-ancestor', '--is-inside-work-tree', '--job-isolation', '--jq', '--json', '--lanes', '--lang', '--left-right', '--limit', '--link-source', '--link-type', '--local', '--locks', '--log-noop', '--manifest', '--markdown', '--max-cost', '--max-cost-usd', '--max-jobs', '--max-rss', '--max-runtime', '--max-usd', '--max-waiting', '--mcp-only', '--migrate-legacy', '--migrate-only', '--min', '--mode', '--multimodal', '--name-only', '--nice', '--no-accept-pending', '--no-autopilot-install', '--no-capture', '--no-confirm', '--no-cron', '--no-delegate', '--no-edit', '--no-embed', '--no-embedding', '--no-extract', '--no-hooks', '--no-lanes', '--no-llm', '--no-migrate', '--no-pull', '--no-renames', '--no-repair', '--no-schema-pack', '--no-seat', '--no-tags', '--no-verify', '--no-write-fetch-head', '--non-interactive', '--once', '--only', '--operations', '--others', '--out', '--output', '--overwrite', '--page', '--parallel', '--params', '--pat-file', '--path', '--path-format', '--pglite', '--phase', '--pid-file', '--plan', '--porcelain', '--port', '--prefer-postgres', '--preset', '--preview', '--probe', '--probe-pglite', '--profile', '--progress-interval', '--progress-json', '--project', '--provider', '--prune-orphans', '--pure', '--push', '--push-only', '--query', '--question', '--queue', '--quiet', '--rate', '--reauth', '--rebase', '--recommended', '--reference-date', '--refresh', '--refresh-operations', '--refresh-skills', '--regenerate', '--reissue', '--relative', '--remediate', '--remediation-plan', '--remove', '--remove-core', '--repair', '--replace', '--repo', '--request-id', '--reranker', '--reset', '--reset-checkpoint', '--reset-default', '--restore-only', '--resume', '--retry-failed', '--reverse', '--review-lower', '--revision', '--rollback-to-source', '--scope', '--scopes', '--seat', '--section', '--select', '--self-transfer', '--session', '--set', '--set-upstream-to', '--shadow', '--short', '--show-current', '--show-prefix', '--show-token', '--show-toplevel', '--since', '--skills-dir', '--skip', '--skip-bare-tweet', '--skip-failed', '--skip-urls', '--skip-verify', '--slot', '--slug', '--slugs', '--source', '--source-id', '--sources', '--src-subpath', '--staged', '--stale', '--status', '--stdin', '--strategy', '--strict', '--suite', '--supabase', '--surface', '--symbol-kind', '--symbolic-full-name', '--takes-holders', '--target', '--target-score', '--threshold', '--timeout', '--to', '--token', '--token-ttl', '--top-k', '--trust', '--type', '--uninstall', '--unsafe-bypass-dream-guard', '--unset-all', '--untracked-files', '--url', '--url-env', '--user', '--vectors', '--verbose', '--verify', '--version', '--wait', '--wait-drain', '--warn-only', '--what-if-threshold', '--window', '--workers', '--working-tree', '--workspace', '--yes'],'dream': ['--audit-rejects', '--brain', '--cancel-unmatched', '--date', '--dir', '--drain', '--dry-run', '--eval-run', '--force', '--from', '--help', '--input', '--install', '--json', '--limit', '--list', '--max-usd', '--once', '--path', '--phase', '--pull', '--reconcile-queue', '--since', '--source', '--source-id', '--threshold', '--to', '--unsafe-bypass-dream-guard', '--window', '--yes'],'edge-proposals': ['--access', '--add', '--all-applied', '--all-held', '--allowed-operations', '--asof', '--bound-slug-prefixes', '--brain', '--client', '--date', '--dated-since', '--days', '--entities', '--federated-read', '--full', '--fuzzy', '--help', '--http', '--id', '--include-deleted', '--json', '--kind', '--limit', '--max-usd', '--model', '--multimodal', '--no-autopilot-install', '--page', '--params', '--path', '--phase', '--purge', '--recent', '--refresh-operations', '--row', '--scopes', '--session', '--since', '--slugs', '--source', '--sources', '--stale', '--status', '--surface', '--to', '--updated-after', '--url', '--yes'],diff --git a/src/core/cycle/nightly-probe-routes.ts b/src/core/cycle/nightly-probe-routes.tsindex 8aa3a1ac80..cb161e1a20 100644--- a/src/core/cycle/nightly-probe-routes.ts+++ b/src/core/cycle/nightly-probe-routes.ts@@ -72,18 +72,46 @@ export class NightlyProbeModelRoutesError extends Error {}}+/**+ * The judge-slot pins `models.eval.cross_modal.slot_{a,b,c}`, alias-expanded;+ * unset and blank keys are absent. The one reader for the nightly probe and+ * `gbrain eval cross-modal` (#6486), so the two cannot resolve a pin+ * differently.+ */+export async function readCrossModalSlotConfig(engine: ConfigReader): Promise<Partial<Record<NightlyProbeSlotId, string>>> {+ const slots: Partial<Record<NightlyProbeSlotId, string>> = {};+ for (const [id, key] of Object.entries(NIGHTLY_PROBE_SLOT_KEYS) as Array<[NightlyProbeSlotId, string]>) {+ const value = (await engine.getConfig(key))?.trim();+ if (value) slots[id] = await resolveAlias(engine, value);+ }+ return slots;+}++/**+ * `gbrain eval cross-modal`'s slot reader (#6486): opens the brain through+ * `connect` (the CLI passes a probe-only connect, which starts no migration),+ * reads the pins and closes it. Called only when a slot has no flag; the+ * caller treats a throw (no brain, brain busy) as "no pins", so the command+ * stays usable before `gbrain init`.+ */+export async function readCrossModalSlotConfigFrom(+ connect: () => Promise<ConfigReader & { disconnect(): Promise<void> }>,+): Promise<Partial<Record<NightlyProbeSlotId, string>>> {+ const engine = await connect();+ try {+ return await readCrossModalSlotConfig(engine);+ } finally {+ await engine.disconnect().catch(() => {});+ }+}+export async function resolveNightlyProbeModelRoutes(engine: ConfigReader,): Promise<NightlyProbeModelRoutes> {try {const reader = await resolveModelDetailed(engine, NIGHTLY_PROBE_READER_ROUTE);const extractor = await resolveModelDetailed(engine, NIGHTLY_PROBE_EXTRACTOR_ROUTE);- const slots: NightlyProbeModelRoutes['slots'] = {};- for (const [id, key] of Object.entries(NIGHTLY_PROBE_SLOT_KEYS) as Array<[NightlyProbeSlotId, string]>) {- const value = (await engine.getConfig(key))?.trim();- if (value) slots[id] = await resolveAlias(engine, value);- }- return { reader, extractor, slots };+ return { reader, extractor, slots: await readCrossModalSlotConfig(engine) };} catch (err) {throw new NightlyProbeModelRoutesError(err);}diff --git a/test/cross-modal-slot-config-6486.test.ts b/test/cross-modal-slot-config-6486.test.tsnew file mode 100644index 0000000000..3ff5c88797--- /dev/null+++ b/test/cross-modal-slot-config-6486.test.ts@@ -0,0 +1,153 @@+/**+ * #6486 — `gbrain eval cross-modal` resolves each judge slot as+ * `--slot-<x>-model` flag → brain config `models.eval.cross_modal.slot_<x>`+ * → `DEFAULT_SLOTS`. The config keys already existed for the nightly probe+ * (`nightly-probe-routes.ts`) but the CLI read only the flags, so an+ * operator who pinned the slots for the probe still got the literal frontier+ * defaults from the CLI and the skill text.+ *+ * The CLI stays brain-free: the slot pins arrive through an injected reader+ * (`opts.slotConfig`) that `src/cli/main.ts` builds from a fail-open+ * probe-only connect; without a brain or when every flag is given, nothing+ * is read.+ */+import { afterEach, beforeEach, describe, expect, test } from 'bun:test';+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';++import { DEFAULT_SLOTS, type RunEvalResult, type SlotConfig } from '../src/core/cross-modal-eval/runner.ts';+import { runEvalCrossModal, resolveSlotModels } from '../src/commands/eval-cross-modal.ts';+import { readCrossModalSlotConfig, readCrossModalSlotConfigFrom, NIGHTLY_PROBE_SLOT_KEYS } from '../src/core/cycle/nightly-probe-routes.ts';+import { __setChatTransportForTests, configureGateway, resetGateway } from '../src/core/ai/gateway.ts';++const ALL_KEYED = { ANTHROPIC_API_KEY: 'sk-ant-fake', OPENAI_API_KEY: 'sk-fake', DEEPSEEK_API_KEY: 'sk-ds-fake', GOOGLE_GENERATIVE_AI_API_KEY: 'g-fake' };++describe('resolveSlotModels precedence', () => {+ test('flag beats config beats default, per slot', () => {+ const slots = resolveSlotModels(+ { slotAModel: 'openai:gpt-5.5', slotBModel: undefined, slotCModel: undefined },+ { B: 'anthropic:claude-sonnet-5-5' },+ );+ expect(slots).toEqual([+ { id: 'A', model: 'openai:gpt-5.5' },+ { id: 'B', model: 'anthropic:claude-sonnet-5-5' },+ { id: 'C', model: DEFAULT_SLOTS[2]!.model },+ ]);+ });++ test('a flag wins over a config pin for the same slot; blank config values are ignored', () => {+ const slots = resolveSlotModels(+ { slotAModel: 'openai:gpt-5.5', slotBModel: undefined, slotCModel: undefined },+ { A: 'anthropic:claude-sonnet-5-5', B: ' ' },+ );+ expect(slots.map(s => s.model)).toEqual(['openai:gpt-5.5', DEFAULT_SLOTS[1]!.model, DEFAULT_SLOTS[2]!.model]);+ });+});++describe('readCrossModalSlotConfig (shared with the nightly probe)', () => {+ test('reads the three keys, trims, resolves aliases, and leaves unset keys absent', async () => {+ const values: Record<string, string | null> = {+ [NIGHTLY_PROBE_SLOT_KEYS.A]: ' anthropic:claude-sonnet-5-5 ',+ [NIGHTLY_PROBE_SLOT_KEYS.B]: '',+ };+ const reader = { getConfig: async (key: string) => values[key] ?? null };+ expect(await readCrossModalSlotConfig(reader)).toEqual({ A: 'anthropic:claude-sonnet-5-5' });+ });++ test('readCrossModalSlotConfigFrom opens, reads and always closes the brain; a connect failure propagates to the caller', async () => {+ let closed = 0;+ const pins = await readCrossModalSlotConfigFrom(async () => ({+ getConfig: async (key: string) => (key === NIGHTLY_PROBE_SLOT_KEYS.C ? 'deepseek:deepseek-v4-pro' : null),+ disconnect: async () => { closed++; },+ }));+ expect(pins).toEqual({ C: 'deepseek:deepseek-v4-pro' });+ expect(closed).toBe(1);+ await expect(readCrossModalSlotConfigFrom(async () => { throw new Error('No database URL'); })).rejects.toThrow('No database URL');+ const failing = await readCrossModalSlotConfigFrom(async () => ({+ getConfig: async () => { throw new Error('config table missing'); },+ disconnect: async () => { closed++; },+ })).catch((e: Error) => e.message);+ expect(failing).toBe('config table missing');+ expect(closed).toBe(2);+ });+});++describe('gbrain eval cross-modal --batch honours the brain slot pins (#6486)', () => {+ let dir: string;+ let batchPath: string;+ let summaryPath: string;++ beforeEach(() => {+ dir = mkdtempSync(join(tmpdir(), 'cm-slot-config-'));+ batchPath = join(dir, 'batch.jsonl');+ summaryPath = join(dir, 'summary.json');+ writeFileSync(batchPath, JSON.stringify({ question_id: 'q1', question: 'Where?', hypothesis: 'widget-co', answer: 'widget-co' }) + '\n');+ configureGateway({ chat_model: 'anthropic:claude-sonnet-5-5', env: ALL_KEYED });+ });++ afterEach(() => {+ __setChatTransportForTests(null);+ resetGateway();+ rmSync(dir, { recursive: true, force: true });+ });++ const stubRunEval = (judged: SlotConfig[][]) => async (opts: { slots?: SlotConfig[] }): Promise<RunEvalResult> => {+ judged.push(opts.slots ?? []);+ return {+ finalAggregate: { verdict: 'pass', verdictMessage: 'stub: pass' } as RunEvalResult['finalAggregate'],+ cycles: [],+ finalReceiptPath: join(dir, 'receipt.json'),+ };+ };++ test('slot_a pinned in config and no flag: the panel runs the pinned model in slot A, defaults elsewhere', async () => {+ const judged: SlotConfig[][] = [];+ let reads = 0;+ const exit = await runEvalCrossModal(['--batch', batchPath, '--output', summaryPath, '--yes'], {+ useConfiguredGateway: true,+ slotConfig: async () => { reads++; return { A: 'anthropic:claude-sonnet-5-5' }; },+ runEval: stubRunEval(judged),+ });+ expect(exit).toBe(0);+ expect(reads).toBe(1);+ const panel = ['anthropic:claude-sonnet-5-5', DEFAULT_SLOTS[1]!.model, DEFAULT_SLOTS[2]!.model];+ expect(judged.map(slots => slots.map(s => s.model))).toEqual([panel]);+ const summary = JSON.parse(readFileSync(summaryPath, 'utf8'));+ expect(summary.slots.map((s: SlotConfig) => s.model)).toEqual(panel);+ });++ test('an explicit --slot-a-model flag wins over the config pin', async () => {+ const judged: SlotConfig[][] = [];+ await runEvalCrossModal(['--batch', batchPath, '--output', summaryPath, '--yes', '--slot-a-model', 'openai:gpt-5.5'], {+ useConfiguredGateway: true,+ slotConfig: async () => ({ A: 'anthropic:claude-sonnet-5-5' }),+ runEval: stubRunEval(judged),+ });+ expect(judged[0]![0]!.model).toBe('openai:gpt-5.5');+ });++ test('all three flags given: the brain is never read', async () => {+ const judged: SlotConfig[][] = [];+ let reads = 0;+ await runEvalCrossModal(['--batch', batchPath, '--output', summaryPath, '--yes',+ '--slot-a-model', 'openai:gpt-5.5', '--slot-b-model', 'anthropic:claude-sonnet-5-5', '--slot-c-model', 'deepseek:deepseek-v4-pro'], {+ useConfiguredGateway: true,+ slotConfig: async () => { reads++; return {}; },+ runEval: stubRunEval(judged),+ });+ expect(reads).toBe(0);+ expect(judged[0]!.map(s => s.model)).toEqual(['openai:gpt-5.5', 'anthropic:claude-sonnet-5-5', 'deepseek:deepseek-v4-pro']);+ });++ test('a reader that throws (brain busy, no brain) falls back to the defaults and the run still completes', async () => {+ const judged: SlotConfig[][] = [];+ const exit = await runEvalCrossModal(['--batch', batchPath, '--output', summaryPath, '--yes'], {+ useConfiguredGateway: true,+ slotConfig: async () => { throw new Error('PGLite is locked by another process'); },+ runEval: stubRunEval(judged),+ });+ expect(exit).toBe(0);+ expect(judged[0]!.map(s => s.model)).toEqual(DEFAULT_SLOTS.map(s => s.model));+ });+});