Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(autopilot): nightly quality probe tells the truth: run budget, collapsed panel, receipts, embedded fixtures (#5506, #5187, C-N5, C-N6, D12)

time-attack24c1cd8c16fb
diff --git a/scripts/check-pglite-embedded.sh b/scripts/check-pglite-embedded.sh
index cff5ee9f4c..6923cb447f 100755
--- a/scripts/check-pglite-embedded.sh
+++ b/scripts/check-pglite-embedded.sh
@@ -42,6 +42,10 @@ cp -R "$REPO_ROOT/native" "$BUILD_DIR/native"
# from an engine-only import. Keep the compiled graph's file imports available.
cp -R "$REPO_ROOT/templates" "$BUILD_DIR/templates"
cp -R "$REPO_ROOT/skills" "$BUILD_DIR/skills"
+# The nightly probes embed their fixtures (src/core/cycle/nightly-probe-fixtures.ts).
+mkdir -p "$BUILD_DIR/test/fixtures/conversation-formats"
+cp "$REPO_ROOT/test/fixtures/longmemeval-nightly.jsonl" "$BUILD_DIR/test/fixtures/"
+cp "$REPO_ROOT/test/fixtures/conversation-formats/all.jsonl" "$REPO_ROOT/test/fixtures/conversation-formats/adversarial.jsonl" "$BUILD_DIR/test/fixtures/conversation-formats/"
cp "$REPO_ROOT/package.json" "$BUILD_DIR/package.json"
cp "$REPO_ROOT/LICENSE" "$BUILD_DIR/LICENSE"
cp "$REPO_ROOT/scripts/pglite-embedded-smoketest.ts" "$BUILD_DIR/scripts/pglite-embedded-smoketest.ts"
diff --git a/scripts/serial-files.tsv b/scripts/serial-files.tsv
index cfd295a129..bd144373c2 100644
--- a/scripts/serial-files.tsv
+++ b/scripts/serial-files.tsv
@@ -241,6 +241,7 @@ test/models-nightly-probe-routes.serial.test.ts global-state global-state: patch
test/models-per-task-extract-atoms.serial.test.ts global-state global-state: patches process stdout/stderr/console
test/models-probe-max-output-tokens.serial.test.ts global-state global-state: binds local servers/ports
test/native-base-url-fold.serial.test.ts R1 R1: mutates process.env (GBRAIN_HOME, OPENAI_BASE_URL)
+test/nightly-probe-compiled-binary.serial.test.ts global-state global-state: compiles a probe harness with bun build --compile and runs it plus a source-mode copy as subprocesses
test/oauth-client-setup.serial.test.ts global-state global-state: R3: constructs PGLiteEngine outside beforeAll; R4: PGLiteEngine without an afterAll disconnect
test/observational-startup.serial.test.ts R2 R2: mock.module(../src/cli/commands/repair.ts) replaces modules for every file in the process
test/openai-latest.serial.test.ts R1 R1: mutates process.env (GBRAIN_HOME, GBRAIN_MODEL_DISCOVERY)
diff --git a/src/commands/autopilot-daemon.ts b/src/commands/autopilot-daemon.ts
index 762f6344b3..96fa57595e 100644
--- a/src/commands/autopilot-daemon.ts
+++ b/src/commands/autopilot-daemon.ts
@@ -39,11 +39,6 @@ export interface AutopilotDaemonState {
/** #1872: the in-flight inline runCycle, drained by closeEngine on shutdown. */
inflightInlineCycle: Promise<unknown> | null;
consecutiveErrors: number;
- /**
- * Parser-probe fixture warning is once-per-process, not once-per-cycle
- * (compiled-binary installs have no source tree; don't spam the log).
- */
- parserProbeFixtureWarned: boolean;
/**
* #2608: once-per-process no-chat-provider warning. A keyless daemon used
* to run every cycle "green" while all LLM phases silently no-op'd
@@ -141,7 +136,6 @@ export async function runAutopilotDaemon(engine: BrainEngine, args: string[]): P
stopping: false,
inflightInlineCycle: null,
consecutiveErrors: 0,
- parserProbeFixtureWarned: false,
noChatProviderWarned: false,
autopilotReconnectFails: 0,
noWorkerConsecutiveIdle: 0,
@@ -341,8 +335,8 @@ export async function runAutopilotDaemon(engine: BrainEngine, args: string[]): P
}
}
- await runNightlyQualityProbeStep(engine, cfg, repoPath);
- await runParserProbeStep(engine, cfg, state);
+ await runNightlyQualityProbeStep(engine, cfg);
+ await runParserProbeStep(engine, cfg);
// Wait for next cycle
await new Promise(r => setTimeout(r, interval * 1000));
diff --git a/src/commands/autopilot-probes.ts b/src/commands/autopilot-probes.ts
index 41285f153b..0cbf61ff6d 100644
--- a/src/commands/autopilot-probes.ts
+++ b/src/commands/autopilot-probes.ts
@@ -5,8 +5,6 @@
*/
import type { BrainEngine } from '../core/engine.ts';
import type { GBrainConfig } from '../core/config.ts';
-import { gbrainPath as gbrainHomePath } from '../core/config.ts';
-import type { AutopilotDaemonState } from './autopilot-daemon.ts';
import type { NightlyProbeModelRoutes } from '../core/cycle/nightly-probe-routes.ts';
import { logError } from './autopilot.ts';
@@ -25,7 +23,7 @@ export async function resolveNightlyProbeModelRoutesForDaemon(engine: BrainEngin
return resolveNightlyProbeModelRoutes(engine);
}
-export async function runNightlyQualityProbeStep(engine: BrainEngine, cfg: GBrainConfig | null, repoPath: string): Promise<void> {
+export async function runNightlyQualityProbeStep(engine: BrainEngine, cfg: GBrainConfig | null): Promise<void> {
// 4.5 — Nightly quality probe (v0.41).
// Per D10: trust the phase's internal 24h rate-limit (via shouldRunNightly
// reading the audit JSONL). No scheduler-side precheck — one source of
@@ -34,7 +32,7 @@ export async function runNightlyQualityProbeStep(engine: BrainEngine, cfg: GBrai
// loop. Probe runs even when cycleOk=false (probe may surface signal
// explaining why the cycle is failing).
try {
- const { resolveProbeEnabled, resolveProbeMaxUsd, runNightlyQualityProbe } =
+ const { resolveProbeEnabled, resolveProbeCap, runNightlyQualityProbe } =
await import('../core/cycle/nightly-quality-probe.ts');
const { resolveNightlyProbeSearchConfigSnapshot } =
await import('../core/cycle/nightly-probe-search-config.ts');
@@ -49,19 +47,17 @@ export async function runNightlyQualityProbeStep(engine: BrainEngine, cfg: GBrai
const probeEnabled = resolveProbeEnabled(dbEnabled, cfg?.autopilot?.nightly_quality_probe?.enabled);
if (probeEnabled) {
const { runLongMemEvalForProbe, runCrossModalBatchForProbe } = await import('../core/cycle/nightly-probe-adapters.ts');
+ const { NIGHTLY_PROBE_FIXTURES } = await import('../core/cycle/nightly-probe-fixtures.ts');
+ const { loadPricingOverrides } = await import('../core/budget/budget-tracker.ts');
const { isAvailable } = await import('../core/ai/gateway.ts');
- const { existsSync } = await import('node:fs');
- const { fileURLToPath } = await import('node:url');
- const { join } = await import('node:path');
- const maxUsd = resolveProbeMaxUsd(dbMaxUsd, cfg?.autopilot?.nightly_quality_probe?.max_usd);
- // The fixture lives in the package, not usually in the user's brain repo.
- const pkgRoot = fileURLToPath(new URL('../..', import.meta.url));
- const fixtureAtPkgRoot = existsSync(join(pkgRoot, 'test', 'fixtures', 'longmemeval-nightly.jsonl'));
+ const cap = resolveProbeCap(dbMaxUsd, cfg?.autopilot?.nightly_quality_probe?.max_usd);
await runNightlyQualityProbe({
isEnabled: () => true, // already gated above; phase re-checks for defense-in-depth
hasEmbeddingProvider: () => isAvailable('embedding'),
- resolveMaxUsd: () => maxUsd,
- resolveRepoRoot: () => (fixtureAtPkgRoot ? pkgRoot : repoPath ?? gbrainHomePath('.')),
+ resolveMaxUsd: () => cap.maxUsd,
+ resolveBudgetPolicy: async () => ({ capSource: cap.capSource, pricingOverrides: await loadPricingOverrides(engine) }),
+ // Embedded with the package (#5187): a compiled binary reads it from the bundle, not the brain repo.
+ resolveFixturePath: () => NIGHTLY_PROBE_FIXTURES.longMemEval,
resolveSearchConfigSnapshot: () => resolveNightlyProbeSearchConfigSnapshot(engine),
resolveModelRoutes: () => resolveNightlyProbeModelRoutesForDaemon(engine),
runLongMemEval: runLongMemEvalForProbe,
@@ -76,7 +72,7 @@ export async function runNightlyQualityProbeStep(engine: BrainEngine, cfg: GBrai
}
}
-export async function runParserProbeStep(engine: BrainEngine, cfg: GBrainConfig | null, state: AutopilotDaemonState): Promise<void> {
+export async function runParserProbeStep(engine: BrainEngine, cfg: GBrainConfig | null): Promise<void> {
// 4.6 — Nightly conversation-parser probe (v0.41.16.0 phase module;
// the scheduler wire-up was deferred at ship and is added here). Same
// posture as 4.5: the phase owns its gates (enabled/mode-gate, LLM
@@ -87,9 +83,7 @@ export async function runParserProbeStep(engine: BrainEngine, cfg: GBrainConfig
const { runConversationParserNightlyProbe } = await import('../core/conversation-parser/nightly-probe.ts');
const { logParserProbeEvent, parserProbeRanWithin } = await import('../core/audit-parser-probe.ts');
const { isAvailable } = await import('../core/ai/gateway.ts');
- const { existsSync } = await import('node:fs');
- const { fileURLToPath } = await import('node:url');
- const { join } = await import('node:path');
+ const { NIGHTLY_PROBE_FIXTURES } = await import('../core/cycle/nightly-probe-fixtures.ts');
// Flag reads dual-plane: the DB row (`gbrain config set …`) wins,
// ~/.gbrain/config.json is the fallback. search.mode lives on the
// DB plane only (mode.ts owns it).
@@ -103,30 +97,22 @@ export async function runParserProbeStep(engine: BrainEngine, cfg: GBrainConfig
? parserDbEnabled === 'true'
: cfg?.autopilot?.conversation_parser_probe?.enabled === true;
const searchMode = dbSearchMode ?? '';
- // Fixtures are committed in the gbrain package (test/fixtures/…),
- // NOT the brain repo — resolve from the module location. Compiled
- // binaries carry no source tree: skip quietly instead of writing
- // failure rows that would flip doctor to WARN on every binary install.
- const pkgRoot = fileURLToPath(new URL('../..', import.meta.url));
- const fixturePath = join(pkgRoot, 'test', 'fixtures', 'conversation-formats', 'all.jsonl');
- const adversarialPath = join(pkgRoot, 'test', 'fixtures', 'conversation-formats', 'adversarial.jsonl');
- const shouldInvoke = parserEnabled || searchMode === 'tokenmax';
- if (shouldInvoke && existsSync(fixturePath) && existsSync(adversarialPath)) {
+ // Fixtures are embedded with the package (C-N6), so a compiled binary
+ // reads them from its bundle; the phase writes a `skipped` row if they
+ // are ever unreadable, and that row also holds the 24h rate limit.
+ if (parserEnabled || searchMode === 'tokenmax') {
const result = await runConversationParserNightlyProbe({
isEnabled: () => parserEnabled,
searchMode: () => searchMode,
hasLlmKey: () => isAvailable('chat'),
- resolveFixturePath: () => fixturePath,
- resolveAdversarialPath: () => adversarialPath,
+ resolveFixturePath: () => NIGHTLY_PROBE_FIXTURES.parserFormats,
+ resolveAdversarialPath: () => NIGHTLY_PROBE_FIXTURES.parserAdversarial,
now: () => new Date(),
shouldSkipForRateLimit: () => parserProbeRanWithin(24 * 60 * 60 * 1000),
});
// rate_limited is a non-run: the loop ticks every few minutes, so
// logging every skip would flood the audit file with no-signal rows.
if (result.outcome !== 'rate_limited') logParserProbeEvent(result);
- } else if (shouldInvoke && !state.parserProbeFixtureWarned) {
- state.parserProbeFixtureWarned = true;
- console.error(`[parser-probe] fixtures not found under ${pkgRoot}; skipping (probe needs a source-checkout install)`);
}
} catch (e) {
logError('autopilot.parser_probe', e);
diff --git a/src/commands/doctor/checks/search-eval.ts b/src/commands/doctor/checks/search-eval.ts
index 8da13e0d33..6303c12c10 100644
--- a/src/commands/doctor/checks/search-eval.ts
+++ b/src/commands/doctor/checks/search-eval.ts
@@ -395,7 +395,7 @@ export function computeConversationParserProbeHealthCheck(
return {
name,
status: 'ok',
- message: 'enabled but no probe events in the last 7 days (next run by autopilot; fixtures require a source-checkout install).',
+ message: 'enabled but no probe events in the last 7 days (next run by autopilot).',
};
}
const bad = events.filter(e => e.outcome !== 'pass');
@@ -502,6 +502,7 @@ export function computeNightlyQualityProbeHealthCheck(
const bad = events.filter(e => e.outcome !== 'pass');
const latest = events[events.length - 1]!;
if (bad.length > 0) {
+ const skipped = events.filter(e => e.outcome === 'skipped').length;
const counts =
`pass=${events.filter(e => e.outcome === 'pass').length} ` +
`fail=${events.filter(e => e.outcome === 'fail').length} ` +
@@ -509,7 +510,8 @@ export function computeNightlyQualityProbeHealthCheck(
`inconclusive=${events.filter(e => e.outcome === 'inconclusive').length} ` +
`budget=${events.filter(e => e.outcome === 'budget_exceeded').length} ` +
`no_embed_key=${events.filter(e => e.outcome === 'no_embedding_key').length} ` +
- `rate_limited=${events.filter(e => e.outcome === 'rate_limited').length}`;
+ `rate_limited=${events.filter(e => e.outcome === 'rate_limited').length}` +
+ (skipped > 0 ? ` skipped=${skipped}` : '');
return {
name,
status: 'warn',
diff --git a/src/core/audit-quality-probe.ts b/src/core/audit-quality-probe.ts
index 3685535ea0..6cb8a3db1b 100644
--- a/src/core/audit-quality-probe.ts
+++ b/src/core/audit-quality-probe.ts
@@ -21,7 +21,8 @@ export type QualityProbeOutcome =
| 'error'
| 'budget_exceeded'
| 'rate_limited'
- | 'no_embedding_key';
+ | 'no_embedding_key'
+ | 'skipped';
/**
* One non-passing question of a completed batch: its failing dimensions
@@ -93,6 +94,18 @@ export interface QualityProbeAuditEvent {
chat_calls?: number;
chat_cost_usd?: number;
unpriced_chat_calls?: number;
+ /**
+ * Machine reason behind a non-verdict outcome: `fixture_unavailable`
+ * (skipped), `panel_collapsed` (inconclusive: one model held two judge
+ * slots, or fewer than two models judged), or the run budget's
+ * `cost` / `runtime` / `no_pricing` (budget_exceeded).
+ */
+ reason?: string;
+ /** The run-level USD cap over every paid call of the run, and where it came from (`user` or `default`). */
+ cap_usd?: number;
+ cap_source?: string;
+ /** Directory holding the run's batch summary and LongMemEval output, kept for non-pass rows. */
+ receipt_dir?: string;
}
/** Fields copied onto the row only when the caller set them (rows written before #5506 lack them). */
@@ -109,6 +122,10 @@ const OPTIONAL_EVENT_FIELDS = [
'chat_calls',
'chat_cost_usd',
'unpriced_chat_calls',
+ 'reason',
+ 'cap_usd',
+ 'cap_source',
+ 'receipt_dir',
] as const satisfies ReadonlyArray<keyof QualityProbeAuditEvent>;
/** ISO-week-rotated filename: `quality-probe-YYYY-Www.jsonl`. Mirrors audit-slug-fallback. */
diff --git a/src/core/cli-flag-registry.generated.ts b/src/core/cli-flag-registry.generated.ts
index 9e2516f8cf..79c38149f2 100644
--- a/src/core/cli-flag-registry.generated.ts
+++ b/src/core/cli-flag-registry.generated.ts
@@ -19,7 +19,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {
'anomalies': ['--brain', '--help', '--json', '--lookback-days', '--mcp-only', '--sigma', '--since', '--source'],
'apply-migrations': ['--acknowledge-no-backup', '--apply', '--backup-confirmed', '--brain', '--break-lock', '--confirm-quiesced', '--content-root', '--dry-run', '--export-db-only', '--export-source', '--force', '--force-all', '--force-orchestrator', '--force-retry', '--force-schema', '--help', '--host-dir', '--http', '--json', '--list', '--locks', '--migrate-only', '--migration', '--mode', '--no-autopilot-install', '--non-interactive', '--probe', '--require-db', '--skip-verify', '--source', '--uninstall', '--yes'],
'auth': ['--add', '--admin-intent', '--adopt-columns', '--adopt-permissions', '--all-new', '--allowed-operations', '--before', '--bound-brain', '--bound-max-concurrent', '--bound-slug-prefixes', '--bound-source', '--bound-tools', '--brain', '--budget-usd-per-day', '--cleanup-dead-local-locks', '--client', '--confirm-quiesced', '--days', '--delegated-namespace', '--delegated-slug-prefixes', '--dry-run', '--enable-dcr-insecure', '--expected-epoch', '--expected-state', '--federated-read', '--fix', '--force', '--grant-types', '--help', '--id', '--if-version', '--json', '--limit', '--manifest', '--max-concurrent', '--migrate-legacy', '--no-pull', '--operations', '--path', '--probe', '--profile', '--read-sources', '--redirect-uri', '--refresh-operations', '--repair', '--replace', '--request-id', '--reset-default', '--retry-failed', '--scopes', '--self-transfer', '--shared-skills', '--slug-prefixes', '--source', '--source-ids', '--sources', '--surface', '--takes-holders', '--token', '--token-endpoint-auth-method', '--token-ttl', '--usage', '--yes'],
- 'autopilot': ['--apply', '--batch', '--brain', '--check', '--dimensions', '--dir', '--drain', '--dry-run', '--embedding-dimensions', '--embedding-model', '--expect', '--explain', '--ff-only', '--force', '--force-retry', '--from-pages', '--help', '--inject-bootstrap', '--inline', '--install', '--interval', '--json', '--markdown', '--max-cost', '--max-rss', '--max-usd', '--migrate-only', '--model', '--no-autopilot-install', '--no-bun-floor-check', '--no-inject', '--no-worker', '--non-interactive', '--now', '--once', '--only', '--output', '--params', '--path', '--pause', '--phase', '--reason', '--refresh-cache', '--remediation-plan', '--repo', '--resume', '--slot-a-model', '--slot-b-model', '--slot-c-model', '--source', '--stale', '--status', '--swap-only', '--target', '--trust', '--uninstall', '--user', '--verify', '--version', '--yes'],
+ 'autopilot': ['--apply', '--batch', '--brain', '--check', '--dimensions', '--dir', '--drain', '--dry-run', '--embedding-dimensions', '--embedding-model', '--expect', '--explain', '--ff-only', '--force', '--force-retry', '--from-pages', '--help', '--inject-bootstrap', '--inline', '--install', '--interval', '--json', '--markdown', '--max-cost', '--max-rss', '--max-runtime', '--max-usd', '--migrate-only', '--model', '--no-autopilot-install', '--no-bun-floor-check', '--no-embed-cache', '--no-inject', '--no-worker', '--non-interactive', '--now', '--once', '--only', '--output', '--params', '--path', '--pause', '--phase', '--reason', '--refresh-cache', '--remediation-plan', '--repo', '--resume', '--slot-a-model', '--slot-b-model', '--slot-c-model', '--source', '--stale', '--status', '--swap-only', '--target', '--trust', '--uninstall', '--user', '--verify', '--version', '--yes'],
'backfill': ['--batch-size', '--brain', '--concurrency', '--dry-run', '--fresh', '--help', '--json', '--keep-index', '--list', '--max-errors', '--max-rows', '--resume', '--source'],
'backup': ['--accept-pending', '--background', '--brain', '--confirm-authority-reviewed', '--confirm-backup-compatible', '--confirm-quiesced', '--dir', '--explain', '--follow', '--full', '--help', '--into', '--json', '--mode', '--no-accept-pending', '--output', '--path', '--progress-interval', '--progress-json', '--quiet', '--restore-only', '--source', '--timeout', '--wait'],
'bench': ['--baseline', '--brain', '--force', '--from', '--help', '--json', '--label', '--limit', '--source', '--threshold-jaccard', '--threshold-latency-multiplier', '--threshold-top1', '--to', '--tool'],
diff --git a/src/core/config.ts b/src/core/config.ts
index 7d60740556..62c3046570 100644
--- a/src/core/config.ts
+++ b/src/core/config.ts
@@ -201,9 +201,8 @@ export interface GBrainConfig {
/** Enable the nightly probe in the autopilot loop. Defaults to false. */
enabled?: boolean;
/**
- * Value (USD) the probe passes as the cross-modal batch's --max-usd.
- * Defaults to 5. Not a spend cap: the probe also passes --yes, which
- * skips that refusal; audit rows record the metered chat_cost_usd.
+ * Run-level cap (USD) over every paid call of one probe run (LongMemEval
+ * and judges). Default 5; a set value is a user cap (unpriced → no_pricing).
*/
max_usd?: number;
};
@@ -1412,7 +1411,7 @@ export const KNOWN_CONFIG_KEYS: readonly string[] = [
'models.contextual_synopsis',
'models.chat',
'models.brainstorm.judge',
- 'models.eval.longmemeval',
+ 'models.eval.longmemeval', 'models.eval.cross_modal.slot_a', 'models.eval.cross_modal.slot_b', 'models.eval.cross_modal.slot_c', // #5872 D12 probe judge slots
'facts.extraction_model',
// Brain-wide kill switch for fact extraction, read by
// src/core/facts/extract.ts:isFactsExtractionEnabled and honored by
diff --git a/src/core/conversation-parser/nightly-probe.ts b/src/core/conversation-parser/nightly-probe.ts
index fcc7c2ebf4..2c00db2a41 100644
--- a/src/core/conversation-parser/nightly-probe.ts
+++ b/src/core/conversation-parser/nightly-probe.ts
@@ -43,7 +43,8 @@ export type ProbeOutcome =
| 'rate_limited'
| 'budget_exceeded'
| 'adversarial_false_positive'
- | 'no_embedding_key';
+ | 'no_embedding_key'
+ | 'skipped';
export interface NightlyProbeResult {
outcome: ProbeOutcome;
@@ -145,8 +146,10 @@ export async function runConversationParserNightlyProbe(
if (!existsSync(fixturePath) || !existsSync(adversarialPath)) {
return {
...baseResult,
- outcome: 'fail',
- reason: `fixture path missing: ${!existsSync(fixturePath) ? fixturePath : adversarialPath}`,
+ outcome: 'skipped',
+ reason:
+ `fixture_unavailable: ${!existsSync(fixturePath) ? fixturePath : adversarialPath} is not readable, ` +
+ 'so the probe gave no parser signal. Reinstall gbrain (bun install -g github:garrytan/gbrain) and run gbrain doctor.',
};
}
diff --git a/src/core/cycle/nightly-probe-adapters.ts b/src/core/cycle/nightly-probe-adapters.ts
index 369e371f1f..5c72f3933e 100644
--- a/src/core/cycle/nightly-probe-adapters.ts
+++ b/src/core/cycle/nightly-probe-adapters.ts
@@ -92,11 +92,12 @@ export async function runLongMemEvalForProbe(args: LongMemEvalProbeArgs): Promis
/**
* argv + RunOpts for the LongMemEval call. The brain-resolved reader rides
- * `--model` and the extractor `RunOpts.extractorModel`; with no routes the
- * call is the pre-#5872 one.
+ * `--model` and the extractor `RunOpts.extractorModel`. `--no-embed-cache`
+ * (C-N5): the cache swaps the gateway's process-global embed transport for
+ * the run, which inside the daemon would also catch every other embed call.
*/
export function buildLongMemEvalProbeCall(args: LongMemEvalProbeArgs): { argv: string[]; runOpts: RunOpts } {
- const argv = [args.fixturePath, '--output', args.outputPath];
+ const argv = [args.fixturePath, '--output', args.outputPath, '--no-embed-cache'];
const runOpts: RunOpts = { searchConfigSnapshot: args.searchConfigSnapshot, exitOnError: false };
if (args.modelRoutes) {
argv.push('--model', args.modelRoutes.reader.model);
diff --git a/src/core/cycle/nightly-probe-fixtures.ts b/src/core/cycle/nightly-probe-fixtures.ts
new file mode 100644
index 0000000000..0109d5f6c0
--- /dev/null
+++ b/src/core/cycle/nightly-probe-fixtures.ts
@@ -0,0 +1,18 @@
+/**
+ * The nightly probes' committed fixtures, embedded with Bun's
+ * `import ... with { type: 'file' }` (#5187, C-N6) — the mechanism
+ * bootstrap/assets.ts uses. In a source checkout each import resolves to the
+ * file under test/fixtures; in a `bun build --compile` binary it resolves to a
+ * bundler path that `readFileSync` reads, so a binary install runs the probes
+ * instead of looking for the fixtures in the user's brain repo.
+ */
+
+import longMemEvalNightly from '../../../test/fixtures/longmemeval-nightly.jsonl' with { type: 'file' };
+import parserFormats from '../../../test/fixtures/conversation-formats/all.jsonl' with { type: 'file' };
+import parserAdversarial from '../../../test/fixtures/conversation-formats/adversarial.jsonl' with { type: 'file' };
+
+export const NIGHTLY_PROBE_FIXTURES = Object.freeze({
+ longMemEval: longMemEvalNightly,
+ parserFormats,
+ parserAdversarial,
+});
diff --git a/src/core/cycle/nightly-quality-probe.ts b/src/core/cycle/nightly-quality-probe.ts
index 93652c179a..16dcc3319a 100644
--- a/src/core/cycle/nightly-quality-probe.ts
+++ b/src/core/cycle/nightly-quality-probe.ts
@@ -10,6 +10,10 @@
* judge panel, the non-passing questions with per-judge scores and
* the run's metered chat spend (#5506).
*
+ * Both stages run under one BudgetTracker capped at `max_usd` (CEO B4).
+ * A collapsed judge panel is inconclusive, and a non-pass run keeps its
+ * receipts under the audit dir (#5506, D12).
+ *
* Default: DISABLED. Opt-in via `gbrain config set
* autopilot.nightly_quality_probe.enabled true`. Doctor surfaces a
* paste-ready enable hint when disabled.
@@ -32,6 +36,15 @@ import {
type QualityProbeFailure,
} from '../audit-quality-probe.ts';
import { withChatCallMeter, type ChatCallMeter } from '../ai/chat-usage.ts';
+import { withBudgetTracker } from '../ai/gateway.ts';
+import {
+ BudgetExhausted,
+ BudgetTracker,
+ type BudgetActualUsage,
+ type BudgetEstimate,
+ type PricingOverrides,
+} from '../budget/budget-tracker.ts';
+import { resolveAuditDir } from '../minions/handlers/shell-audit.ts';
import type { CrossModalBatchSummary } from './nightly-probe-adapters.ts';
import { NightlyProbeModelRoutesError, type NightlyProbeModelRoutes } from './nightly-probe-routes.ts';
@@ -39,12 +52,19 @@ import { NightlyProbeModelRoutesError, type NightlyProbeModelRoutes } from './ni
const NIGHTLY_WINDOW_MS = 24 * 60 * 60 * 1000;
/**
- * Default value passed as the batch's --max-usd (matches the eval-cross-modal
- * default). The probe also passes --yes, which skips that refusal, so this
- * value does not bound the probe's spend.
+ * Default run-level USD cap over every paid call of a probe run (LongMemEval
+ * reader, extractor and query embeddings, then the judges). A default cap:
+ * an unpriced model warns and runs; a configured `max_usd` is a user cap and
+ * refuses an unpriced model with the shared no_pricing guidance.
*/
const DEFAULT_MAX_USD = 5.0;
+/** Receipt directories (batch summary + LongMemEval output of a non-pass run) kept under the audit dir. */
+const RECEIPTS_KEPT = 7;
+
+/** Where a non-pass run's receipts go, under the audit dir (honors GBRAIN_AUDIT_DIR). */
+const RECEIPTS_DIR = 'nightly-probe';
+
/** Committed fixture used as the probe's input dataset. */
const NIGHTLY_FIXTURE_REL_PATH = 'test/fixtures/longmemeval-nightly.jsonl';
@@ -59,7 +79,7 @@ export const NIGHTLY_PROBE_SEARCH_CONFIG_KEYS: ReadonlyArray<string> = Object.fr
/** Result reported back to the cycle dispatcher / Minion handler. */
export interface NightlyProbeResult {
- outcome: 'pass' | 'fail' | 'inconclusive' | 'error' | 'budget_exceeded' | 'rate_limited' | 'no_embedding_key' | 'disabled';
+ outcome: 'pass' | 'fail' | 'inconclusive' | 'error' | 'budget_exceeded' | 'rate_limited' | 'no_embedding_key' | 'skipped' | 'disabled';
exit_code: number;
detail?: string;
}
@@ -69,10 +89,18 @@ export interface NightlyProbeDeps {
isEnabled: () => boolean | Promise<boolean>;
/** Returns true when an embedding provider is configured + reachable. */
hasEmbeddingProvider: () => boolean | Promise<boolean>;
- /** Resolves the batch's --max-usd value (config override OR DEFAULT_MAX_USD); --yes makes it no cap. */
+ /** Resolves the run-level USD cap (config override OR DEFAULT_MAX_USD). */
resolveMaxUsd: () => number | Promise<number>;
- /** Resolves the repo root so we can find the committed fixture. */
- resolveRepoRoot: () => string | Promise<string>;
+ /**
+ * Where the cap came from and the brain's `pricing.overrides`: a `user` cap
+ * (a configured max_usd) refuses an unpriced model, a `default` cap warns
+ * and runs it. Absent: a default cap with no overrides.
+ */
+ resolveBudgetPolicy?: () => Promise<{ capSource: 'user' | 'default'; pricingOverrides?: PricingOverrides }>;
+ /** Path of the LongMemEval fixture (the embedded asset, #5187); wins over resolveRepoRoot. */
+ resolveFixturePath?: () => string | Promise<string>;
+ /** Resolves a root holding test/fixtures/longmemeval-nightly.jsonl (used when resolveFixturePath is absent). */
+ resolveRepoRoot?: () => string | Promise<string>;
/** Resolves live search-mode/reranker overrides copied into the isolated benchmark brain. */
resolveSearchConfigSnapshot?: () => Record<string, string> | Promise<Record<string, string>>;
/**
@@ -116,8 +144,7 @@ export function resolveProbeEnabled(
}
/**
- * Same dual-plane rule for the batch's --max-usd value (not a spend cap:
- * the probe passes --yes). Malformed or negative
+ * Same dual-plane rule for the run-level USD cap. Malformed or negative
* values on either plane fall through to the next plane / the default.
*/
export function resolveProbeMaxUsd(
@@ -125,15 +152,49 @@ export function resolveProbeMaxUsd(
fileVal: unknown,
fallback: number = DEFAULT_MAX_USD,
): number {
- if (dbVal != null) {
- const n = Number(dbVal);
- if (Number.isFinite(n) && n >= 0) return n;
+ return resolveProbeCap(dbVal, fileVal, fallback).maxUsd;
+}
+
+/** The run-level cap and its source: a valid value on either plane is a `user` cap, else the `default`. */
+export function resolveProbeCap(
+ dbVal: string | null | undefined,
+ fileVal: unknown,
+ fallback: number = DEFAULT_MAX_USD,
+): { maxUsd: number; capSource: 'user' | 'default' } {
+ for (const raw of [dbVal, fileVal]) {
+ if (raw == null) continue;
+ const n = Number(raw);
+ if (Number.isFinite(n) && n >= 0) return { maxUsd: n, capSource: 'user' };
}
- if (fileVal != null) {
- const n = Number(fileVal);
- if (Number.isFinite(n) && n >= 0) return n;
+ return { maxUsd: fallback, capSource: 'default' };
+}
+
+/**
+ * The run's one BudgetTracker (CEO B4): every gateway chat and embed call of
+ * both stages reserves against it, so the LongMemEval stage is capped too.
+ * Keeps the first refusal so the phase can tell a budget stop from a crash
+ * even when LongMemEval records the refusal as a per-question error.
+ */
+class ProbeBudgetTracker extends BudgetTracker {
+ exhausted: BudgetExhausted | null = null;
+
+ override reserve(estimate: BudgetEstimate): void {
+ try {
+ super.reserve(estimate);
+ } catch (err) {
+ if (err instanceof BudgetExhausted) this.exhausted ??= err;
+ throw err;
+ }
+ }
+
+ override record(actual: BudgetActualUsage & { kind?: BudgetEstimate['kind'] }): void {
+ try {
+ super.record(actual);
+ } catch (err) {
+ if (err instanceof BudgetExhausted) this.exhausted ??= err;
+ throw err;
+ }
}
- return fallback;
}
/**
@@ -277,22 +338,28 @@ export async function runNightlyQualityProbe(deps: NightlyProbeDeps): Promise<Ni
return { outcome: 'no_embedding_key', exit_code: 0, detail: 'no embedding provider' };
}
- const repoRoot = await deps.resolveRepoRoot();
- const fixturePath = path.join(repoRoot, NIGHTLY_FIXTURE_REL_PATH);
+ const fixturePath = deps.resolveFixturePath
+ ? await deps.resolveFixturePath()
+ : path.join(deps.resolveRepoRoot ? await deps.resolveRepoRoot() : process.cwd(), NIGHTLY_FIXTURE_REL_PATH);
if (!fs.existsSync(fixturePath)) {
- const detail = `nightly fixture not found at ${fixturePath}`;
+ // A skip, not a runtime error (#5187): the probe could not run, so the
+ // row says why instead of blaming a file in the user's brain repo.
+ const detail =
+ `the nightly fixture is not readable at ${fixturePath}, so the probe gave no quality signal. ` +
+ `Reinstall gbrain (bun install -g github:garrytan/gbrain) and run gbrain doctor. See docs/eval-bench.md#nightly-cross-modal-quality-probe-opt-in-autopilot`;
process.stderr.write(`[nightly-quality-probe] ${detail}\n`);
logQualityProbeEvent({
- outcome: 'error',
- exit_code: 1,
+ outcome: 'skipped',
+ exit_code: 0,
pass_count: 0,
fail_count: 0,
inconclusive_count: 0,
error_count: 0,
est_cost_usd: 0,
+ reason: 'fixture_unavailable',
detail,
});
- return { outcome: 'error', exit_code: 1, detail };
+ return { outcome: 'skipped', exit_code: 0, detail };
}
const fixtureSha8 = sha8File(fixturePath);
@@ -304,10 +371,22 @@ export async function runNightlyQualityProbe(deps: NightlyProbeDeps): Promise<Ni
const summaryPath = path.join(workDir, 'summary.json');
// Set once a stage that makes model calls starts: the routes the run
- // uses (#5872) and the meter pricing its chat calls (#5506), so a row
- // written after a part-way failure still carries both.
+ // uses (#5872), the meter pricing its chat calls (#5506) and the run
+ // budget, so a row written after a part-way failure still carries them.
let modelRoutes: NightlyProbeModelRoutes | undefined;
let meter: ChatCallMeter | undefined;
+ let tracker: ProbeBudgetTracker | undefined;
+ let capFields: Partial<QualityProbeAuditEvent> = {};
+ const stopped = (): Partial<QualityProbeAuditEvent> => {
+ if (!tracker?.exhausted) return {};
+ const reason = tracker.exhausted.reason;
+ return {
+ reason,
+ detail:
+ `stopped by the run budget before a verdict (${reason}): ${tracker.exhausted.message} ` +
+ `No further paid call was made. Raise the cap with: gbrain config set autopilot.nightly_quality_probe.max_usd <usd>`,
+ };
+ };
try {
const searchConfigSnapshot = deps.resolveSearchConfigSnapshot
? await deps.resolveSearchConfigSnapshot()
@@ -319,17 +398,49 @@ export async function runNightlyQualityProbe(deps: NightlyProbeDeps): Promise<Ni
throw err instanceof NightlyProbeModelRoutesError ? err : new NightlyProbeModelRoutesError(err);
}
}
+ const policy = deps.resolveBudgetPolicy ? await deps.resolveBudgetPolicy() : { capSource: 'default' as const };
+ tracker = new ProbeBudgetTracker({
+ label: 'nightly_quality_probe',
+ maxCostUsd: maxUsd,
+ capSource: policy.capSource,
+ ...(policy.pricingOverrides ? { pricingOverrides: policy.pricingOverrides } : {}),
+ });
+ capFields = { cap_usd: maxUsd, cap_source: policy.capSource };
+ const runTracker = tracker;
meter = { calls: 0, cost_usd: 0, unpriced_calls: 0 };
- await withChatCallMeter(meter, () =>
- deps.runLongMemEval({ fixturePath, outputPath: lmeOutPath, searchConfigSnapshot, modelRoutes }));
- const { exitCode, summary } = await withChatCallMeter(meter, () => deps.runCrossModalBatch({
- batchPath: lmeOutPath,
- summaryPath,
- maxUsd,
- modelRoutes,
- }));
-
- const outcome: NightlyProbeResult['outcome'] = (() => {
+ const runMeter = meter;
+ await withBudgetTracker(runTracker, () => withChatCallMeter(runMeter, () =>
+ deps.runLongMemEval({ fixturePath, outputPath: lmeOutPath, searchConfigSnapshot, modelRoutes })));
+ if (runTracker.exhausted) {
+ const fields = stopped();
+ process.stderr.write(`[nightly-quality-probe] ${fields.detail}\n`);
+ logQualityProbeEvent({
+ outcome: 'budget_exceeded',
+ exit_code: 1,
+ pass_count: 0,
+ fail_count: 0,
+ inconclusive_count: 0,
+ error_count: 0,
+ est_cost_usd: 0,
+ fixture_sha8: fixtureSha8,
+ ...fields,
+ ...routeFields(modelRoutes),
+ ...spendFields(runMeter),
+ ...capFields,
+ ...keepReceipts(workDir, deps.now()),
+ });
+ return { outcome: 'budget_exceeded', exit_code: 1, detail: fields.detail };
+ }
+ const { exitCode, summary } = await withBudgetTracker(runTracker, () => withChatCallMeter(runMeter, () =>
+ deps.runCrossModalBatch({
+ batchPath: lmeOutPath,
+ summaryPath,
+ maxUsd,
+ modelRoutes,
+ })));
+
+ const verdict: NightlyProbeResult['outcome'] = (() => {
+ if (runTracker.exhausted) return 'budget_exceeded';
if (summary) {
if (summary.verdict === 'pass') return 'pass';
if (summary.verdict === 'fail') return 'fail';
@@ -340,9 +451,14 @@ export async function runNightlyQualityProbe(deps: NightlyProbeDeps): Promise<Ni
if (exitCode === 1) return 'budget_exceeded';
return 'error';
})();
+ const collapse = (verdict === 'pass' || verdict === 'fail') && summary ? collapsedPanel(summary) : undefined;
+ const outcome: NightlyProbeResult['outcome'] = collapse ? 'inconclusive' : verdict;
const failures = outcome !== 'pass' ? summary?.failures : undefined;
- const detail = summary && outcome !== 'pass' ? failureDigest(summary, failures ?? []) : undefined;
+ const digest = summary && outcome !== 'pass' ? failureDigest(summary, failures ?? []) : undefined;
+ const detail = collapse
+ ? `${collapse} (batch verdict: ${verdict})${digest ? `; ${digest}` : ''}`
+ : digest;
logQualityProbeEvent({
outcome,
exit_code: exitCode,
@@ -353,18 +469,24 @@ export async function runNightlyQualityProbe(deps: NightlyProbeDeps): Promise<Ni
est_cost_usd: summary?.est_cost_usd ?? 0,
fixture_sha8: fixtureSha8,
...(detail ? { detail } : {}),
+ ...(collapse ? { reason: 'panel_collapsed' } : {}),
+ ...stopped(),
...routeFields(modelRoutes),
...(summary ? panelFields(summary) : {}),
...(failures?.length ? { failures: failures.slice(0, AUDIT_MAX_FAILURES) } : {}),
- ...spendFields(meter),
+ ...spendFields(runMeter),
+ ...capFields,
+ ...(outcome !== 'pass' ? keepReceipts(workDir, deps.now()) : {}),
});
- return { outcome, exit_code: exitCode };
+ return { outcome, exit_code: exitCode, ...(detail ? { detail } : {}) };
} catch (err) {
- const detail = err instanceof Error ? err.message : String(err);
- process.stderr.write(`[nightly-quality-probe] runtime error: ${detail}\n`);
+ const budget = stopped();
+ const outcome = budget.reason ? 'budget_exceeded' : 'error';
+ const detail = budget.detail ?? (err instanceof Error ? err.message : String(err));
+ process.stderr.write(`[nightly-quality-probe] ${outcome === 'error' ? 'runtime error: ' : ''}${detail}\n`);
logQualityProbeEvent({
- outcome: 'error',
+ outcome,
exit_code: 1,
pass_count: 0,
fail_count: 0,
@@ -373,13 +495,69 @@ export async function runNightlyQualityProbe(deps: NightlyProbeDeps): Promise<Ni
est_cost_usd: 0,
fixture_sha8: fixtureSha8,
detail,
+ ...(budget.reason ? { reason: budget.reason } : {}),
...routeFields(modelRoutes),
...(meter ? spendFields(meter) : {}),
+ ...capFields,
+ ...keepReceipts(workDir, deps.now()),
});
- return { outcome: 'error', exit_code: 1, detail };
+ return { outcome, exit_code: 1, detail };
} finally {
try {
fs.rmSync(workDir, { recursive: true, force: true });
} catch { /* best-effort */ }
}
}
+
+/**
+ * A panel that is not three independent judges (#5506, D12): among the
+ * slots that scored, one model holding two or more slots (its votes count
+ * more than once), or fewer than two distinct models. Returns the detail's
+ * problem + next step, or undefined for a sound panel or a summary without
+ * panel fields (older batches keep their verdict).
+ */
+function collapsedPanel(summary: CrossModalBatchSummary): string | undefined {
+ const models = summary.judge_models;
+ const panel = summary.panel;
+ if (!models || !panel) return undefined;
+ const scored = panel.slot_scored_questions;
+ const judged = models.flatMap((model, i) =>
+ scored && !((scored[i] ?? 0) > 0) ? [] : [{ model, id: String.fromCharCode(65 + i) }]);
+ const remedy =
+ 'Set three different judge models: gbrain config set models.eval.cross_modal.slot_a <model> ' +
+ '(and slot_b, slot_c; one provider is enough). See docs/eval-bench.md#nightly-cross-modal-quality-probe-opt-in-autopilot';
+ if (panel.distinct_models < 2) {
+ return `judge panel collapsed: ${plural(panel.distinct_models, 'distinct model')} judged, so there is no cross-check. ${remedy}`;
+ }
+ const slotsByModel = new Map<string, string[]>();
+ for (const { model, id } of judged) slotsByModel.set(model, [...(slotsByModel.get(model) ?? []), id]);
+ const shared = [...slotsByModel].filter(([, ids]) => ids.length > 1);
+ if (shared.length === 0) return undefined;
+ const holders = shared.map(([model, ids]) => `${model} holds slots ${ids.join(', ')}`).join('; ');
+ return `judge panel collapsed: ${holders}, so its votes count more than once. ${remedy}`;
+}
+
+/**
+ * Keep a non-pass run's batch summary and LongMemEval output (#5506) under
+ * `<audit dir>/nightly-probe/<ts>/`, pruning to the newest RECEIPTS_KEPT.
+ * The fixture is synthetic, so receipts hold no user data. Best-effort:
+ * returns `receipt_dir` only when at least one file was kept.
+ */
+function keepReceipts(workDir: string, now: Date): Partial<QualityProbeAuditEvent> {
+ try {
+ const files = ['summary.json', 'lme-output.jsonl'].filter(f => fs.existsSync(path.join(workDir, f)));
+ if (files.length === 0) return {};
+ const root = path.join(resolveAuditDir(), RECEIPTS_DIR);
+ const dir = path.join(root, now.toISOString().replace(/[:.]/g, '-'));
+ fs.mkdirSync(dir, { recursive: true });
+ for (const f of files) fs.copyFileSync(path.join(workDir, f), path.join(dir, f));
+ const kept = fs.readdirSync(root).sort();
+ for (const old of kept.slice(0, Math.max(0, kept.length - RECEIPTS_KEPT))) {
+ fs.rmSync(path.join(root, old), { recursive: true, force: true });
+ }
+ return { receipt_dir: dir };
+ } catch (err) {
+ process.stderr.write(`[nightly-quality-probe] could not keep the run's receipts: ${err instanceof Error ? err.message : String(err)}\n`);
+ return {};
+ }
+}
diff --git a/src/types/jsonl-assets.d.ts b/src/types/jsonl-assets.d.ts
new file mode 100644
index 0000000000..d6854baa68
--- /dev/null
+++ b/src/types/jsonl-assets.d.ts
@@ -0,0 +1,5 @@
+/** `import p from './x.jsonl' with { type: 'file' }`: the asset's path (source tree in dev, bundler path in a compiled binary). */
+declare module '*.jsonl' {
+ const path: string;
+ export default path;
+}
diff --git a/test/autopilot-nightly-probe-wiring.test.ts b/test/autopilot-nightly-probe-wiring.test.ts
index 1f5a03d061..e975d7a1fa 100644
--- a/test/autopilot-nightly-probe-wiring.test.ts
+++ b/test/autopilot-nightly-probe-wiring.test.ts
@@ -63,25 +63,23 @@ describe('autopilot wiring: nightly quality probe', () => {
);
});
- test('DI shape: isEnabled / hasEmbeddingProvider / resolveMaxUsd / resolveRepoRoot / runLongMemEval / runCrossModalBatch / now', () => {
- // The exact 7 fields of NightlyProbeDeps.
+ test('DI shape: isEnabled / hasEmbeddingProvider / resolveMaxUsd / resolveBudgetPolicy / resolveFixturePath / runLongMemEval / runCrossModalBatch / now', () => {
expect(SOURCE).toContain(`isEnabled:`);
expect(SOURCE).toContain(`hasEmbeddingProvider:`);
expect(SOURCE).toContain(`resolveMaxUsd:`);
- expect(SOURCE).toContain(`resolveRepoRoot:`);
+ expect(SOURCE).toContain(`resolveBudgetPolicy:`);
+ expect(SOURCE).toContain(`resolveFixturePath:`);
expect(SOURCE).toContain(`runLongMemEval:`);
expect(SOURCE).toContain(`runCrossModalBatch:`);
expect(SOURCE).toContain(`now:`);
});
- test('resolveRepoRoot prefers the gbrain package root (committed fixture home), not the brain repoPath', () => {
- // The DI harness in nightly-quality-probe.test.ts passes process.cwd()
- // (= the gbrain repo in CI), which papered over the wiring passing
- // repoPath (= sync.repo_path, the user's BRAIN repo, where the fixture
- // never exists). Pin the package-root resolution + existence check.
- expect(SOURCE).toMatch(/fileURLToPath\(new URL\('\.\.\/\.\.', import\.meta\.url\)\)/);
- expect(SOURCE).toContain(`'longmemeval-nightly.jsonl'`);
- expect(SOURCE).toMatch(/fixtureAtPkgRoot \? pkgRoot : repoPath/);
+ test('the fixture is the embedded package asset, never the brain repoPath (#5187)', () => {
+ // Before #5187 the wiring resolved the fixture from the package root on
+ // disk, which a compiled binary does not have, and fell back to the
+ // user's brain repo. The embedded asset is readable in both installs.
+ expect(SOURCE).toContain(`resolveFixturePath: () => NIGHTLY_PROBE_FIXTURES.longMemEval`);
+ expect(SOURCE).not.toMatch(/fixtureAtPkgRoot \? pkgRoot : repoPath/);
});
test('hasEmbeddingProvider reads from gateway.isAvailable("embedding") (codex round-2 #12 — in-process, not subprocess)', () => {
@@ -89,8 +87,8 @@ describe('autopilot wiring: nightly quality probe', () => {
expect(SOURCE).toContain(`gateway`);
});
- test('max_usd resolves dual-plane (default = 5 pinned by resolveProbeMaxUsd unit tests)', () => {
+ test('max_usd resolves dual-plane with its cap source (default = 5 pinned by resolveProbeCap unit tests)', () => {
expect(SOURCE).toContain(`getConfig('autopilot.nightly_quality_probe.max_usd')`);
- expect(SOURCE).toMatch(/resolveProbeMaxUsd\(dbMaxUsd,\s*cfg\?\.autopilot\?\.nightly_quality_probe\?\.max_usd\)/);
+ expect(SOURCE).toMatch(/resolveProbeCap\(dbMaxUsd,\s*cfg\?\.autopilot\?\.nightly_quality_probe\?\.max_usd\)/);
});
});
diff --git a/test/autopilot-parser-probe-wiring.test.ts b/test/autopilot-parser-probe-wiring.test.ts
index de5ec1a5bc..a54952bba5 100644
--- a/test/autopilot-parser-probe-wiring.test.ts
+++ b/test/autopilot-parser-probe-wiring.test.ts
@@ -35,18 +35,17 @@ describe('autopilot wiring: conversation-parser probe', () => {
expect(SOURCE).toMatch(/parserEnabled \|\| searchMode === 'tokenmax'/);
});
- test('fixtures resolve from the gbrain package root, NOT the brain repoPath', () => {
- // The committed fixtures live in the gbrain source tree; resolving
- // them against sync.repo_path would point into the user's brain repo.
- expect(SOURCE).toMatch(/fileURLToPath\(new URL\('\.\.\/\.\.', import\.meta\.url\)\)/);
- expect(SOURCE).toContain(`'conversation-formats', 'all.jsonl'`);
- expect(SOURCE).toContain(`'conversation-formats', 'adversarial.jsonl'`);
+ test('fixtures are the embedded package assets, NOT the brain repoPath (C-N6)', () => {
+ // A compiled binary carries no source tree; the embedded assets are
+ // readable there and in a source checkout alike.
+ expect(SOURCE).toContain(`resolveFixturePath: () => NIGHTLY_PROBE_FIXTURES.parserFormats`);
+ expect(SOURCE).toContain(`resolveAdversarialPath: () => NIGHTLY_PROBE_FIXTURES.parserAdversarial`);
});
- test('missing fixtures skip quietly (no audit row, once-per-process stderr note)', () => {
- // Compiled-binary installs carry no source tree; writing failure rows
- // would flip doctor to WARN on every binary install.
- expect(SOURCE).toContain(`parserProbeFixtureWarned`);
+ test('no quiet skip: an unreadable fixture becomes an audited skipped row (C-N6)', () => {
+ // The once-per-process stderr note left doctor reporting ok on binary
+ // installs; the phase now returns `skipped`, which the wiring logs.
+ expect(SOURCE).not.toContain(`parserProbeFixtureWarned`);
});
test('rate_limited outcomes are NOT audit-logged (flood guard)', () => {
diff --git a/test/conversation-parser/nightly-probe.test.ts b/test/conversation-parser/nightly-probe.test.ts
index b470d8eb48..33eed2bccc 100644
--- a/test/conversation-parser/nightly-probe.test.ts
+++ b/test/conversation-parser/nightly-probe.test.ts
@@ -99,11 +99,22 @@ describe('runConversationParserNightlyProbe', () => {
expect(r.adversarial_false_positives).toBe(1);
});
- test('fixture path missing → fail', async () => {
+ test('fixture path missing → skipped with fixture_unavailable, not a parser failure (C-N6)', async () => {
const r = await runConversationParserNightlyProbe(
baseDeps({ resolveFixturePath: () => '/nonexistent/path.jsonl' }),
);
- expect(r.outcome).toBe('fail');
- expect(r.reason).toContain('missing');
+ expect(r.outcome).toBe('skipped');
+ expect(r.reason).toStartWith('fixture_unavailable: /nonexistent/path.jsonl is not readable');
+ expect(r.fixtures_total).toBe(0);
+ });
+
+ test('the embedded fixtures score as the committed corpus (C-N6)', async () => {
+ const { NIGHTLY_PROBE_FIXTURES } = await import('../../src/core/cycle/nightly-probe-fixtures.ts');
+ const r = await runConversationParserNightlyProbe(baseDeps({
+ resolveFixturePath: () => NIGHTLY_PROBE_FIXTURES.parserFormats,
+ resolveAdversarialPath: () => NIGHTLY_PROBE_FIXTURES.parserAdversarial,
+ }));
+ expect(r.outcome).not.toBe('skipped');
+ expect(r.fixtures_total).toBeGreaterThan(0);
});
});
diff --git a/test/cycle/nightly-probe-adapters.test.ts b/test/cycle/nightly-probe-adapters.test.ts
index bde8d2c19a..081506b75c 100644
--- a/test/cycle/nightly-probe-adapters.test.ts
+++ b/test/cycle/nightly-probe-adapters.test.ts
@@ -127,7 +127,7 @@ describe('nightly-probe-adapters: argv shape regression (codex round-2 #1)', ()
const fs = require('node:fs');
const source = fs.readFileSync(path, 'utf-8');
// longmemeval adapter: first positional arg is fixturePath, then --output outputPath.
- expect(source).toContain("[args.fixturePath, '--output', args.outputPath]");
+ expect(source).toContain("[args.fixturePath, '--output', args.outputPath, '--no-embed-cache']");
});
test('runLongMemEvalForProbe passes the live search config snapshot via RunOpts', () => {
@@ -161,12 +161,12 @@ describe('nightly-probe-adapters: model routes reach the eval commands', () => {
{
name: 'with routes: --model carries the reader, RunOpts.extractorModel the extractor',
modelRoutes: ROUTES,
- argv: ['/f.jsonl', '--output', '/w/lme.jsonl', '--model', 'claude-cli:claude-opus-5-5'],
+ argv: ['/f.jsonl', '--output', '/w/lme.jsonl', '--no-embed-cache', '--model', 'claude-cli:claude-opus-5-5'],
runOpts: { searchConfigSnapshot: SNAPSHOT, exitOnError: false, extractorModel: 'claude-cli:claude-sonnet-5' },
},
{
- name: 'no routes: the pre-#5872 call',
- argv: ['/f.jsonl', '--output', '/w/lme.jsonl'],
+ name: 'no routes: the pre-#5872 call (embed cache off, C-N5)',
+ argv: ['/f.jsonl', '--output', '/w/lme.jsonl', '--no-embed-cache'],
runOpts: { searchConfigSnapshot: SNAPSHOT, exitOnError: false },
},
];
diff --git a/test/doctor-parser-probe-check.test.ts b/test/doctor-parser-probe-check.test.ts
index c35bf6945d..a990112d7e 100644
--- a/test/doctor-parser-probe-check.test.ts
+++ b/test/doctor-parser-probe-check.test.ts
@@ -33,6 +33,18 @@ describe('computeConversationParserProbeHealthCheck', () => {
expect(check.message).toContain('all pass');
});
+ test('a skipped run (fixtures unreadable) → warn naming the skip and its reason, not ok (C-N6)', () => {
+ const check = computeConversationParserProbeHealthCheck(true, [
+ ev('skipped', 'fixture_unavailable: /$bunfs/root/all.jsonl is not readable'),
+ ]);
+ expect(check.status).toBe('warn');
+ expect(check.message).toContain('latest: skipped (fixture_unavailable: /$bunfs/root/all.jsonl is not readable)');
+ });
+
+ test('enabled with no events no longer blames a source-checkout install (C-N6)', () => {
+ expect(computeConversationParserProbeHealthCheck(true, []).message).not.toContain('source-checkout');
+ });
+
test('any non-pass outcome in the window → warn, latest surfaced with reason', () => {
const check = computeConversationParserProbeHealthCheck(true, [
ev('pass'),
diff --git a/test/helpers/nightly-probe-compiled-harness.ts b/test/helpers/nightly-probe-compiled-harness.ts
new file mode 100644
index 0000000000..cbe3360ecf
--- /dev/null
+++ b/test/helpers/nightly-probe-compiled-harness.ts
@@ -0,0 +1,67 @@
+/**
+ * Entry for test/nightly-probe-compiled-binary.serial.test.ts: runs both
+ * autopilot probe steps (the daemon's real wiring) against a config-only
+ * fake brain, with the gateway's chat and embed test transports as the
+ * hermetic provider. Compiled with `bun build --compile` and run from a
+ * directory with no gbrain checkout, it proves the embedded fixtures (#5187,
+ * C-N6) reach the probes. Prints `PROBE_RESULT <json>` with the audit rows.
+ */
+import {
+ __setChatTransportForTests,
+ __setEmbedTransportForTests,
+ configureGateway,
+ type ChatResult,
+} from '../../src/core/ai/gateway.ts';
+import { runNightlyQualityProbeStep, runParserProbeStep } from '../../src/commands/autopilot-probes.ts';
+import { readRecentQualityProbeEvents } from '../../src/core/audit-quality-probe.ts';
+import { readRecentParserProbeEvents } from '../../src/core/audit-parser-probe.ts';
+
+const DIMS = 1536;
+const JUDGE_REPLY = JSON.stringify({
+ scores: { CORRECTNESS: { score: 9, feedback: 'ok' }, DIRECTNESS: { score: 9, feedback: 'ok' } },
+ overall: 9,
+ improvements: Array.from({ length: 10 }, (_, i) => `${i + 1}. none`),
+});
+
+function reply(model: string, text: string): ChatResult {
+ return {
+ text,
+ blocks: [{ type: 'text', text }],
+ stopReason: 'end',
+ usage: { input_tokens: 50, output_tokens: 20, cache_read_tokens: 0, cache_creation_tokens: 0 },
+ model,
+ providerId: model.split(':')[0]!,
+ };
+}
+
+configureGateway({
+ chat_model: 'anthropic:claude-sonnet-4-6',
+ embedding_model: 'openai:text-embedding-3-small',
+ embedding_dimensions: DIMS,
+ env: { ...process.env } as Record<string, string>,
+});
+__setChatTransportForTests(async (opts) => {
+ const prompt = JSON.stringify(opts.messages);
+ return reply(opts.model ?? 'anthropic:claude-sonnet-4-6', prompt.includes('EVALUATION INPUT') ? JUDGE_REPLY : 'widget-co');
+});
+__setEmbedTransportForTests((async (params: { values: string[] }) => ({
+ embeddings: params.values.map((v, i) => Array.from({ length: DIMS }, (_, j) => ((v.length + i + j) % 11) / 11)),
+ values: params.values,
+ warnings: [],
+ usage: { tokens: params.values.length },
+})) as unknown as Parameters<typeof __setEmbedTransportForTests>[0]);
+
+const rows: Record<string, string> = {
+ 'autopilot.nightly_quality_probe.enabled': 'true',
+ 'autopilot.conversation_parser_probe.enabled': 'true',
+ 'search.reranker.enabled': 'false',
+ 'models.eval.cross_modal.slot_a': 'anthropic:claude-opus-4-7',
+ 'models.eval.cross_modal.slot_b': 'anthropic:claude-sonnet-4-6',
+ 'models.eval.cross_modal.slot_c': 'anthropic:claude-haiku-4-5-20251001',
+};
+const engine = { getConfig: async (key: string) => rows[key] ?? null } as unknown as Parameters<typeof runNightlyQualityProbeStep>[0];
+
+await runNightlyQualityProbeStep(engine, null);
+await runParserProbeStep(engine, null);
+console.log(`PROBE_RESULT ${JSON.stringify({ quality: readRecentQualityProbeEvents(1), parser: readRecentParserProbeEvents(1) })}`);
+process.exit(0);
diff --git a/test/nightly-probe-compiled-binary.serial.test.ts b/test/nightly-probe-compiled-binary.serial.test.ts
new file mode 100644
index 0000000000..d71de8d694
--- /dev/null
+++ b/test/nightly-probe-compiled-binary.serial.test.ts
@@ -0,0 +1,99 @@
+/**
+ * #5187 / C-N6: the nightly probes run on a compiled binary install.
+ *
+ * Builds test/helpers/nightly-probe-compiled-harness.ts with
+ * `bun build --compile`, copies the binary into an empty directory (no gbrain
+ * checkout), and runs both autopilot probe steps with an isolated
+ * GBRAIN_HOME and audit dir and the gateway's test transports as a hermetic
+ * provider (fake keys, no network). The same harness also runs from source
+ * with its cwd outside the repo.
+ *
+ * Protects: the quality probe reads its embedded LongMemEval fixture and
+ * reaches a verdict (master wrote `error: nightly fixture not found at
+ * <brain repo>/test/fixtures/...`); the parser probe reads its embedded
+ * fixtures and writes a row (master skipped quietly with no row, so doctor
+ * said ok).
+ * Fails when: a fixture is resolved from the package directory on disk
+ * again, or `bun build --compile` stops embedding a `type: 'file'` import.
+ * Serial: one compile plus two subprocess probe runs.
+ */
+import { afterAll, describe, expect, test } from 'bun:test';
+import { spawnSync } from 'node:child_process';
+import { copyFileSync, existsSync, mkdirSync, mkdtempSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+
+const REPO_ROOT = resolve(import.meta.dir, '..');
+const HARNESS = join(REPO_ROOT, 'test', 'helpers', 'nightly-probe-compiled-harness.ts');
+const root = mkdtempSync(join(tmpdir(), 'gb-probe-bin-'));
+
+afterAll(() => {
+ rmSync(root, { recursive: true, force: true });
+});
+
+interface ProbeRows {
+ quality: Array<{ outcome: string; fixture_sha8?: string; distinct_judge_models?: number; detail?: string }>;
+ parser: Array<{ outcome: string; fixtures_total: number; reason?: string }>;
+}
+
+function runHarness(label: string, argv: string[]): { rows: ProbeRows | null; output: string } {
+ const dir = join(root, label);
+ const cwd = join(dir, 'cwd');
+ mkdirSync(cwd, { recursive: true });
+ const res = spawnSync(argv[0]!, argv.slice(1), {
+ cwd,
+ encoding: 'utf8',
+ timeout: 120_000,
+ maxBuffer: 64 * 1024 * 1024,
+ env: {
+ PATH: process.env.PATH ?? '/usr/bin:/bin',
+ HOME: join(dir, 'home'),
+ GBRAIN_HOME: join(dir, 'home'),
+ GBRAIN_AUDIT_DIR: join(dir, 'audit'),
+ GBRAIN_MODEL_DISCOVERY: 'off',
+ GBRAIN_SKIP_STARTUP_HOOKS: '1',
+ OPENAI_API_KEY: 'sk-fake-hermetic',
+ ANTHROPIC_API_KEY: 'sk-ant-fake-hermetic',
+ },
+ });
+ const output = `${res.stdout ?? ''}\n${res.stderr ?? ''}`;
+ const line = (res.stdout ?? '').split('\n').find(l => l.startsWith('PROBE_RESULT '));
+ return { rows: line ? JSON.parse(line.slice('PROBE_RESULT '.length)) as ProbeRows : null, output: output.slice(-4000) };
+}
+
+function expectBothProbesRan(rows: ProbeRows | null, output: string): void {
+ expect(rows, output).not.toBeNull();
+ expect(rows!.quality, output).toHaveLength(1);
+ expect(rows!.quality[0]!.outcome, output).toBe('pass');
+ expect(rows!.quality[0]!.fixture_sha8).toMatch(/^[0-9a-f]{8}$/);
+ expect(rows!.quality[0]!.distinct_judge_models).toBe(3);
+ expect(rows!.parser, output).toHaveLength(1);
+ expect(rows!.parser[0]!.outcome, output).toBe('pass');
+ expect(rows!.parser[0]!.fixtures_total).toBeGreaterThan(0);
+}
+
+describe('nightly probes on a compiled binary (#5187, C-N6)', () => {
+ test('a compiled binary in an empty directory runs both probes on their embedded fixtures', () => {
+ const buildOut = join(root, 'build', 'nightly-probe-harness');
+ const build = spawnSync('bun', ['build', '--compile', '--outfile', buildOut, HARNESS], {
+ cwd: REPO_ROOT,
+ encoding: 'utf8',
+ timeout: 240_000,
+ maxBuffer: 64 * 1024 * 1024,
+ });
+ expect(build.status, `${build.stdout}\n${build.stderr}`).toBe(0);
+ expect(existsSync(buildOut)).toBe(true);
+ const isolated = join(root, 'isolated-bin');
+ mkdirSync(isolated, { recursive: true });
+ const bin = join(isolated, 'nightly-probe-harness');
+ copyFileSync(buildOut, bin);
+ rmSync(join(root, 'build'), { recursive: true, force: true });
+ const { rows, output } = runHarness('compiled', [bin]);
+ expectBothProbesRan(rows, output);
+ }, 300_000);
+
+ test('source mode with a cwd outside the checkout runs both probes too', () => {
+ const { rows, output } = runHarness('source', [process.execPath, HARNESS]);
+ expectBothProbesRan(rows, output);
+ }, 180_000);
+});
diff --git a/test/nightly-probe-gateway-isolation.test.ts b/test/nightly-probe-gateway-isolation.test.ts
new file mode 100644
index 0000000000..a144f0b025
--- /dev/null
+++ b/test/nightly-probe-gateway-isolation.test.ts
@@ -0,0 +1,118 @@
+/**
+ * C-N5: the nightly probe runs inside the autopilot daemon, so its two eval
+ * commands must leave the daemon's process-global gateway as they found it.
+ *
+ * Protects: after the real LongMemEval adapter runs, an embed call still
+ * goes through the transport the daemon had (the eval embed cache used to
+ * swap the transport for the run and restore the SDK default afterwards);
+ * after the real cross-modal adapter runs, the chat model, provider chat
+ * options and provider env the daemon configured are unchanged (the batch
+ * used to rebuild the gateway from the file plane).
+ * Fails when: the probe's LongMemEval call installs the embed cache, or the
+ * cross-modal call reconfigures the gateway.
+ * Seams: gateway test transports for chat and embed, an empty GBRAIN_HOME,
+ * the committed 5-question mini fixture; no network.
+ */
+
+import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+
+import {
+ __setChatTransportForTests,
+ __setEmbedTransportForTests,
+ configureGateway,
+ embed,
+ getChatModel,
+ requireConfig,
+ resetGateway,
+ type ChatResult,
+} from '../src/core/ai/gateway.ts';
+import { runCrossModalBatchForProbe, runLongMemEvalForProbe } from '../src/core/cycle/nightly-probe-adapters.ts';
+import { withEnv } from './helpers/with-env.ts';
+
+const DIMS = 1536;
+const DAEMON_CHAT_MODEL = 'anthropic:claude-sonnet-4-6';
+const DAEMON_CHAT_OPTIONS = { anthropic: { temperature: 0.1 } };
+
+let dir: string;
+let embedCalls: string[][];
+
+function reply(model: string): ChatResult {
+ return {
+ text: 'widget-co',
+ blocks: [{ type: 'text', text: 'widget-co' }],
+ stopReason: 'end',
+ usage: { input_tokens: 10, output_tokens: 5, cache_read_tokens: 0, cache_creation_tokens: 0 },
+ model,
+ providerId: model.split(':')[0]!,
+ };
+}
+
+beforeEach(() => {
+ dir = mkdtempSync(join(tmpdir(), 'probe-gateway-'));
+ embedCalls = [];
+ configureGateway({
+ chat_model: DAEMON_CHAT_MODEL,
+ embedding_model: 'openai:text-embedding-3-small',
+ embedding_dimensions: DIMS,
+ provider_chat_options: DAEMON_CHAT_OPTIONS,
+ env: { OPENAI_API_KEY: 'sk-fake', ANTHROPIC_API_KEY: 'sk-ant-fake' },
+ } as Parameters<typeof configureGateway>[0]);
+ __setEmbedTransportForTests((async (params: { values: string[] }) => {
+ embedCalls.push([...params.values]);
+ return {
+ embeddings: params.values.map((_, i) => Array.from({ length: DIMS }, (__, j) => ((i + j) % 7) / 7)),
+ values: params.values,
+ warnings: [],
+ usage: { tokens: params.values.length },
+ };
+ }) as unknown as Parameters<typeof __setEmbedTransportForTests>[0]);
+ __setChatTransportForTests(async (opts) => reply(opts.model ?? DAEMON_CHAT_MODEL));
+});
+
+afterEach(() => {
+ __setChatTransportForTests(null);
+ __setEmbedTransportForTests(null);
+ resetGateway();
+ rmSync(dir, { recursive: true, force: true });
+});
+
+describe('the probe leaves the daemon gateway as it found it (C-N5)', () => {
+ test('LongMemEval stage: embeds use the daemon transport during and after the run', async () => {
+ await withEnv({ GBRAIN_HOME: join(dir, 'home'), GBRAIN_MODEL: undefined }, async () => {
+ await runLongMemEvalForProbe({
+ fixturePath: join(import.meta.dir, 'fixtures', 'longmemeval-mini.jsonl'),
+ outputPath: join(dir, 'lme.jsonl'),
+ searchConfigSnapshot: { 'search.reranker.enabled': 'false' },
+ });
+ });
+ expect(embedCalls.length).toBeGreaterThan(0);
+ const during = embedCalls.length;
+ await embed(['after the probe']);
+ expect(embedCalls.length).toBe(during + 1);
+ expect(embedCalls.at(-1)).toEqual(['after the probe']);
+ }, 120_000);
+
+ test('cross-modal stage: chat model, provider chat options and provider env are unchanged', async () => {
+ const before = requireConfig();
+ const batchPath = join(dir, 'lme.jsonl');
+ writeFileSync(batchPath, JSON.stringify({ question_id: 'q1', question: 'Where?', hypothesis: 'widget-co', answer: 'widget-co' }) + '\n');
+ await withEnv({ GBRAIN_HOME: join(dir, 'home') }, () => runCrossModalBatchForProbe({
+ batchPath,
+ summaryPath: join(dir, 'summary.json'),
+ maxUsd: 1,
+ modelRoutes: {
+ reader: { model: DAEMON_CHAT_MODEL, source: 'tier_config' },
+ extractor: { model: 'anthropic:claude-haiku-4-5', source: 'tier_config' },
+ slots: {},
+ },
+ }));
+ const after = requireConfig();
+ expect(getChatModel()).toBe(DAEMON_CHAT_MODEL);
+ expect(after.provider_chat_options).toEqual(DAEMON_CHAT_OPTIONS);
+ expect(after.env).toEqual(before.env);
+ expect(after.embedding_model).toBe(before.embedding_model);
+ }, 120_000);
+});
diff --git a/test/nightly-probe-run-budget.test.ts b/test/nightly-probe-run-budget.test.ts
new file mode 100644
index 0000000000..2c77a82f66
--- /dev/null
+++ b/test/nightly-probe-run-budget.test.ts
@@ -0,0 +1,263 @@
+/**
+ * Nightly quality probe: one run-level budget over both stages (CEO B4),
+ * the pricing policy for that cap, and the receipts a non-pass run keeps
+ * (#5506).
+ *
+ * Protects: the LongMemEval stage spends against the same cap as the
+ * judges; a budget stop before judging makes no judge call; a budget stop
+ * is `budget_exceeded`, never `fail`; a default cap runs an unpriced model
+ * with a warning, a configured (user) cap refuses it with the shared
+ * no_pricing guidance unless `pricing.overrides` prices it; a non-pass run
+ * keeps its summary and LongMemEval output under the audit dir, newest 7.
+ * Fails when: the LongMemEval stage runs outside the tracker (master ran it
+ * uncapped), a budget stop reads as fail, or receipts are deleted.
+ * Seams: the gateway's test chat transport (reserve/record run for real),
+ * GBRAIN_AUDIT_DIR per test, DI stubs for the two stages.
+ */
+
+import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
+import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+
+import {
+ resolveProbeCap,
+ runNightlyQualityProbe,
+ type NightlyProbeDeps,
+} from '../src/core/cycle/nightly-quality-probe.ts';
+import { readRecentQualityProbeEvents } from '../src/core/audit-quality-probe.ts';
+import {
+ __setChatTransportForTests,
+ chat,
+ configureGateway,
+ resetGateway,
+ type ChatResult,
+} from '../src/core/ai/gateway.ts';
+import { _resetBudgetTrackerWarningsForTest } from '../src/core/budget/budget-tracker.ts';
+import { withEnv } from './helpers/with-env.ts';
+
+const PRICED = 'anthropic:claude-haiku-4-5';
+const UNPRICED = 'acme-local:unpriced-1';
+const PASS_SUMMARY = { pass_count: 10, fail_count: 0, inconclusive_count: 0, error_count: 0, est_cost_usd: 0.1, verdict: 'pass' };
+
+let auditTmp: string;
+let providerCalls: string[];
+
+function reply(model: string): ChatResult {
+ return {
+ text: 'widget-co',
+ blocks: [{ type: 'text', text: 'widget-co' }],
+ stopReason: 'end',
+ usage: { input_tokens: 1000, output_tokens: 200, cache_read_tokens: 0, cache_creation_tokens: 0 },
+ model,
+ providerId: model.split(':')[0]!,
+ };
+}
+
+/** `n` gateway chat calls on `model`, each failure swallowed the way LongMemEval records a per-question error. */
+async function chatCalls(model: string, n: number): Promise<number> {
+ let refused = 0;
+ for (let i = 0; i < n; i++) {
+ try {
+ await chat({ model, messages: [{ role: 'user', content: `question ${i}` }], maxTokens: 1000 });
+ } catch {
+ refused++;
+ }
+ }
+ return refused;
+}
+
+function deps(overrides: Partial<NightlyProbeDeps> = {}): NightlyProbeDeps {
+ return {
+ isEnabled: () => true,
+ hasEmbeddingProvider: () => true,
+ resolveMaxUsd: () => 5,
+ resolveRepoRoot: () => process.cwd(),
+ runLongMemEval: async () => { await chatCalls(PRICED, 1); },
+ runCrossModalBatch: async () => ({ exitCode: 0, summary: PASS_SUMMARY }),
+ now: () => new Date(),
+ ...overrides,
+ };
+}
+
+beforeEach(() => {
+ auditTmp = mkdtempSync(join(tmpdir(), 'probe-budget-'));
+ providerCalls = [];
+ configureGateway({ env: {} });
+ __setChatTransportForTests(async (opts) => {
+ providerCalls.push(opts.model!);
+ return reply(opts.model!);
+ });
+ _resetBudgetTrackerWarningsForTest();
+});
+
+afterEach(() => {
+ __setChatTransportForTests(null);
+ resetGateway();
+ rmSync(auditTmp, { recursive: true, force: true });
+});
+
+describe('resolveProbeCap', () => {
+ test('a valid value on either plane is a user cap; none is the $5 default cap', () => {
+ expect(resolveProbeCap('2.5', 10)).toEqual({ maxUsd: 2.5, capSource: 'user' });
+ expect(resolveProbeCap(null, '4')).toEqual({ maxUsd: 4, capSource: 'user' });
+ expect(resolveProbeCap('banana', 3)).toEqual({ maxUsd: 3, capSource: 'user' });
+ expect(resolveProbeCap(null, undefined)).toEqual({ maxUsd: 5, capSource: 'default' });
+ expect(resolveProbeCap('-1', 'x')).toEqual({ maxUsd: 5, capSource: 'default' });
+ });
+});
+
+describe('one budget across LongMemEval and the judges (CEO B4)', () => {
+ test('LongMemEval spend exhausts the cap → budget_exceeded, LongMemEval stops paying, no judge call', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ let judgeCalls = 0;
+ let refused = 0;
+ const r = await runNightlyQualityProbe(deps({
+ resolveMaxUsd: () => 0.02,
+ runLongMemEval: async () => { refused = await chatCalls(PRICED, 10); },
+ runCrossModalBatch: async () => { judgeCalls++; return { exitCode: 0, summary: PASS_SUMMARY }; },
+ }));
+ expect(r.outcome).toBe('budget_exceeded');
+ expect(judgeCalls).toBe(0);
+ expect(providerCalls.length).toBeLessThan(10);
+ expect(refused).toBe(10 - providerCalls.length);
+ const [event] = readRecentQualityProbeEvents(1);
+ expect(event!.outcome).toBe('budget_exceeded');
+ expect(event!.reason).toBe('cost');
+ expect(event!.cap_usd).toBe(0.02);
+ expect(event!.cap_source).toBe('default');
+ expect(event!.chat_calls).toBe(providerCalls.length);
+ expect(event!.detail).toContain('No further paid call was made.');
+ expect(event!.detail).toContain('gbrain config set autopilot.nightly_quality_probe.max_usd <usd>');
+ });
+ });
+
+ test('judge spend exhausts the cap → budget_exceeded even when the batch says fail', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ const r = await runNightlyQualityProbe(deps({
+ resolveMaxUsd: () => 0.02,
+ runCrossModalBatch: async () => {
+ await chatCalls(PRICED, 10);
+ return { exitCode: 1, summary: { ...PASS_SUMMARY, pass_count: 2, fail_count: 8, verdict: 'fail' } };
+ },
+ }));
+ expect(r.outcome).toBe('budget_exceeded');
+ expect(providerCalls.length).toBeLessThan(11);
+ const [event] = readRecentQualityProbeEvents(1);
+ expect(event!.outcome).toBe('budget_exceeded');
+ expect(event!.reason).toBe('cost');
+ });
+ });
+
+ test('a run under the cap reaches its verdict with every call metered', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ const r = await runNightlyQualityProbe(deps({
+ runCrossModalBatch: async () => { await chatCalls(PRICED, 3); return { exitCode: 0, summary: PASS_SUMMARY }; },
+ }));
+ expect(r.outcome).toBe('pass');
+ expect(providerCalls).toHaveLength(4);
+ const [event] = readRecentQualityProbeEvents(1);
+ expect(event!.chat_calls).toBe(4);
+ expect(event!.cap_usd).toBe(5);
+ });
+ });
+});
+
+describe('pricing policy for the run cap', () => {
+ test('default cap: an unpriced model warns and runs', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ const r = await runNightlyQualityProbe(deps({
+ runLongMemEval: async () => { await chatCalls(UNPRICED, 2); },
+ }));
+ expect(r.outcome).toBe('pass');
+ expect(providerCalls).toEqual([UNPRICED, UNPRICED]);
+ const [event] = readRecentQualityProbeEvents(1);
+ expect(event!.unpriced_chat_calls).toBe(2);
+ expect(event!.cap_source).toBe('default');
+ });
+ });
+
+ test('user cap: an unpriced model is refused with the no_pricing guidance and never reaches the provider', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ let judgeCalls = 0;
+ const r = await runNightlyQualityProbe(deps({
+ resolveMaxUsd: () => 3,
+ resolveBudgetPolicy: async () => ({ capSource: 'user' }),
+ runLongMemEval: async () => { await chatCalls(UNPRICED, 2); },
+ runCrossModalBatch: async () => { judgeCalls++; return { exitCode: 0, summary: PASS_SUMMARY }; },
+ }));
+ expect(r.outcome).toBe('budget_exceeded');
+ expect(providerCalls).toEqual([]);
+ expect(judgeCalls).toBe(0);
+ const [event] = readRecentQualityProbeEvents(1);
+ expect(event!.reason).toBe('no_pricing');
+ expect(event!.cap_source).toBe('user');
+ expect(event!.detail).toContain(`gbrain pricing set ${UNPRICED} --input <usd-per-1M-input-tokens>`);
+ expect(event!.detail).toContain('$3.00 cost cap');
+ });
+ });
+
+ test('user cap: pricing.overrides prices the model, so it runs under the cap', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ const r = await runNightlyQualityProbe(deps({
+ resolveMaxUsd: () => 3,
+ resolveBudgetPolicy: async () => ({ capSource: 'user', pricingOverrides: { [UNPRICED]: { input: 1, output: 2 } } }),
+ runLongMemEval: async () => { await chatCalls(UNPRICED, 2); },
+ }));
+ expect(r.outcome).toBe('pass');
+ expect(providerCalls).toEqual([UNPRICED, UNPRICED]);
+ });
+ });
+});
+
+describe('receipts of a non-pass run (#5506)', () => {
+ const failSummary = { ...PASS_SUMMARY, pass_count: 6, fail_count: 4, verdict: 'fail' };
+
+ function writingStages(): Pick<NightlyProbeDeps, 'runLongMemEval' | 'runCrossModalBatch'> {
+ return {
+ runLongMemEval: async ({ outputPath }) => { writeFileSync(outputPath, '{"question_id":"q1"}\n'); },
+ runCrossModalBatch: async ({ summaryPath }) => {
+ writeFileSync(summaryPath, JSON.stringify(failSummary));
+ return { exitCode: 1, summary: failSummary };
+ },
+ };
+ }
+
+ test('a FAIL keeps summary.json and lme-output.jsonl under the audit dir and names it on the row', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ const r = await runNightlyQualityProbe(deps(writingStages()));
+ expect(r.outcome).toBe('fail');
+ const [event] = readRecentQualityProbeEvents(1);
+ expect(event!.receipt_dir).toStartWith(join(auditTmp, 'nightly-probe'));
+ expect(JSON.parse(readFileSync(join(event!.receipt_dir!, 'summary.json'), 'utf8')).verdict).toBe('fail');
+ expect(readFileSync(join(event!.receipt_dir!, 'lme-output.jsonl'), 'utf8')).toContain('q1');
+ });
+ });
+
+ test('a runtime error after LongMemEval keeps its output too', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ const r = await runNightlyQualityProbe(deps({
+ runLongMemEval: writingStages().runLongMemEval,
+ runCrossModalBatch: async () => { throw new Error('summary missing'); },
+ }));
+ expect(r.outcome).toBe('error');
+ const [event] = readRecentQualityProbeEvents(1);
+ expect(existsSync(join(event!.receipt_dir!, 'lme-output.jsonl'))).toBe(true);
+ });
+ });
+
+ test('only the newest 7 receipt directories are kept', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ // Rows carry the wall-clock ts, so each night's now() lies past the 24h gate of every earlier row.
+ const start = Date.now() + 25 * 3600_000;
+ for (let night = 0; night < 9; night++) {
+ const now = new Date(start + night * 25 * 3600_000);
+ const r = await runNightlyQualityProbe(deps({ ...writingStages(), now: () => now }));
+ expect(r.outcome).toBe('fail');
+ }
+ const kept = readdirSync(join(auditTmp, 'nightly-probe')).sort();
+ expect(kept).toHaveLength(7);
+ expect(kept[0]).toStartWith(new Date(start + 2 * 25 * 3600_000).toISOString().slice(0, 13));
+ });
+ });
+});
diff --git a/test/nightly-probe-slot-config.test.ts b/test/nightly-probe-slot-config.test.ts
new file mode 100644
index 0000000000..7563ec91bd
--- /dev/null
+++ b/test/nightly-probe-slot-config.test.ts
@@ -0,0 +1,69 @@
+/**
+ * #5872 / D12: the nightly probe's judge-slot keys
+ * `models.eval.cross_modal.slot_{a,b,c}` are registered config keys whose
+ * value is the slot's effective route.
+ *
+ * Protects: `gbrain config set` accepts each key without --force (no
+ * unknown-key refusal), `config get` reads it back, the probe's route
+ * resolver returns the set value (alias-expanded) as that slot's model, and
+ * `config unset` returns the slot to the panel default.
+ * Fails when: a key drops out of KNOWN_CONFIG_KEYS or the resolver stops
+ * reading it.
+ * Seams: none; in-memory PGLite, console/process.exit spies around runConfig.
+ */
+
+import { afterAll, beforeAll, describe, expect, spyOn, test } from 'bun:test';
+
+import { PGLiteEngine } from '../src/core/pglite-engine.ts';
+import { runConfig } from '../src/commands/config.ts';
+import { KNOWN_CONFIG_KEYS } from '../src/core/config.ts';
+import { NIGHTLY_PROBE_SLOT_KEYS, resolveNightlyProbeModelRoutes } from '../src/core/cycle/nightly-probe-routes.ts';
+import { withEnv } from './helpers/with-env.ts';
+
+let engine: PGLiteEngine;
+
+beforeAll(async () => { engine = new PGLiteEngine(); await engine.connect({}); await engine.initSchema(); }, 120_000);
+afterAll(async () => { await engine.disconnect(); });
+
+async function runConfigCapture(args: string[]) {
+ const logs: string[] = [];
+ const errs: string[] = [];
+ let exit: number | null = null;
+ const logSpy = spyOn(console, 'log').mockImplementation((...a: unknown[]) => { logs.push(a.join(' ')); });
+ const errSpy = spyOn(console, 'error').mockImplementation((...a: unknown[]) => { errs.push(a.join(' ')); });
+ const exitSpy = spyOn(process, 'exit').mockImplementation(((code?: number) => { exit = code ?? 0; throw new Error(`EXIT:${code}`); }) as never);
+ try { await runConfig(engine, args); }
+ catch (e) { if (!(e as Error).message.startsWith('EXIT:')) throw e; }
+ finally { logSpy.mockRestore(); errSpy.mockRestore(); exitSpy.mockRestore(); }
+ return { out: logs.join('\n'), err: errs.join('\n'), exit: exit as number | null };
+}
+
+describe('models.eval.cross_modal.slot_{a,b,c} (D12)', () => {
+ test('the three keys are registered', () => {
+ expect(Object.values(NIGHTLY_PROBE_SLOT_KEYS)).toEqual([
+ 'models.eval.cross_modal.slot_a', 'models.eval.cross_modal.slot_b', 'models.eval.cross_modal.slot_c',
+ ]);
+ for (const key of Object.values(NIGHTLY_PROBE_SLOT_KEYS)) expect(KNOWN_CONFIG_KEYS).toContain(key);
+ });
+
+ test('set → get → effective route → unset → panel default', async () => {
+ await withEnv({ GBRAIN_HOME: '/nonexistent-gbrain-home-d12', GBRAIN_MODEL: undefined }, async () => {
+ const set = await runConfigCapture(['set', 'models.eval.cross_modal.slot_a', 'claude-cli:claude-opus-5-5']);
+ expect(set.exit).toBeNull();
+ expect(set.err).not.toContain('Unknown config key');
+ await runConfigCapture(['set', 'models.eval.cross_modal.slot_c', 'haiku']);
+
+ const get = await runConfigCapture(['get', 'models.eval.cross_modal.slot_a']);
+ expect(get.out.trim()).toBe('claude-cli:claude-opus-5-5');
+
+ const routes = await resolveNightlyProbeModelRoutes(engine);
+ expect(routes.slots.A).toBe('claude-cli:claude-opus-5-5');
+ expect(routes.slots.B).toBeUndefined();
+ expect(routes.slots.C).toBe('anthropic:claude-haiku-4-5-20251001');
+
+ await runConfigCapture(['unset', 'models.eval.cross_modal.slot_a']);
+ await runConfigCapture(['unset', 'models.eval.cross_modal.slot_c']);
+ expect((await resolveNightlyProbeModelRoutes(engine)).slots).toEqual({});
+ });
+ });
+});
diff --git a/test/nightly-quality-probe.test.ts b/test/nightly-quality-probe.test.ts
index 4ac0ff2e81..c0d6cebc93 100644
--- a/test/nightly-quality-probe.test.ts
+++ b/test/nightly-quality-probe.test.ts
@@ -270,15 +270,36 @@ describe('runNightlyQualityProbe (DI stub harness)', () => {
});
});
- test('missing fixture → outcome: error', async () => {
+ test('missing fixture → outcome: skipped with reason fixture_unavailable, no model call (#5187)', async () => {
await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ let longMemEvalCalls = 0;
const r = await runNightlyQualityProbe(makeDeps({
resolveRepoRoot: async () => '/this/repo/root/does/not/exist',
+ runLongMemEval: async () => { longMemEvalCalls++; },
}));
- expect(r.outcome).toBe('error');
+ expect(r.outcome).toBe('skipped');
+ expect(r.exit_code).toBe(0);
+ expect(longMemEvalCalls).toBe(0);
const events = await readEvents();
- expect(events[0].outcome).toBe('error');
- expect(events[0].detail).toContain('not found');
+ expect(events[0].outcome).toBe('skipped');
+ expect(events[0].reason).toBe('fixture_unavailable');
+ expect(events[0].detail).toContain('the nightly fixture is not readable at /this/repo/root/does/not/exist/test/fixtures/longmemeval-nightly.jsonl');
+ expect(events[0].detail).toContain('gbrain doctor');
+ });
+ });
+
+ test('resolveFixturePath wins over resolveRepoRoot (the embedded fixture, #5187)', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ const { NIGHTLY_PROBE_FIXTURES } = await import('../src/core/cycle/nightly-probe-fixtures.ts');
+ let seen = '';
+ const r = await runNightlyQualityProbe(makeDeps({
+ resolveRepoRoot: async () => '/this/repo/root/does/not/exist',
+ resolveFixturePath: () => NIGHTLY_PROBE_FIXTURES.longMemEval,
+ runLongMemEval: async (args) => { seen = args.fixturePath; },
+ }));
+ expect(r.outcome).toBe('pass');
+ expect(seen).toBe(NIGHTLY_PROBE_FIXTURES.longMemEval);
+ expect(readFileSync(seen, 'utf8').trim().split('\n')).toHaveLength(10);
});
});
@@ -316,6 +337,16 @@ describe('computeNightlyQualityProbeHealthCheck — pure doctor branch coverage'
expect(check.message).toMatch(/gbrain config set autopilot\.nightly_quality_probe\.enabled true/);
});
+ test('latest run skipped (fixture unavailable) → warn with skipped count and reason, never ok (#5187)', async () => {
+ const { computeNightlyQualityProbeHealthCheck } = await import('../src/commands/doctor.ts');
+ const check = computeNightlyQualityProbeHealthCheck(true, [
+ { outcome: 'skipped', ts: '2026-10-02T03:00:00Z', detail: 'the nightly fixture is not readable at /x.jsonl' },
+ ]);
+ expect(check.status).toBe('warn');
+ expect(check.message).toContain('skipped=1');
+ expect(check.message).toContain('Latest: skipped at 2026-10-02T03:00:00Z (the nightly fixture is not readable at /x.jsonl)');
+ });
+
test('enabled + no events → ok pending', async () => {
const { computeNightlyQualityProbeHealthCheck } = await import('../src/commands/doctor.ts');
const check = computeNightlyQualityProbeHealthCheck(true, []);
@@ -477,6 +508,10 @@ describe('codex CDX-5 — doctor health: every non-PASS outcome surfaces', () =>
const SONNET = 'anthropic:claude-sonnet-4-6';
const OPUS = 'anthropic:claude-opus-4-7';
const COLLAPSED_PANEL = { judge_models: [SONNET, OPUS, SONNET], panel: { distinct_models: 2, distinct_providers: 1 } };
+const CLI_PANEL = {
+ judge_models: ['claude-cli:claude-opus-5-5', 'claude-cli:claude-sonnet-5', 'claude-cli:claude-haiku-4-5-20251001'],
+ panel: { distinct_models: 3, distinct_providers: 1 },
+};
const ROUTES = {
reader: { model: 'claude-cli:claude-opus-5-5', source: 'tier_config' as const },
extractor: { model: 'claude-cli:claude-sonnet-5', source: 'tier_config' as const },
@@ -497,42 +532,103 @@ function batchStub(summary: CrossModalBatchSummary, exitCode = 1): NightlyProbeD
}
describe('runNightlyQualityProbe: panel, failures and digest on the audit row (#5506)', () => {
- test('a FAIL summary writes the judge panel, each failing question and a digest detail', async () => {
+ test('a FAIL summary on a sound panel writes the judge panel, each failing question and a digest detail', async () => {
const failures = [[6, 7, 6], [5, 8, 6], [5, 8, 5], [6, 7, 5], [6, 8, 6], [5, 7, 6]]
.map((scores, i) => directnessFailure(`q${i + 1}`, scores));
await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
const r = await runNightlyQualityProbe(makeDeps({
runCrossModalBatch: batchStub({
pass_count: 4, fail_count: 6, inconclusive_count: 0, error_count: 0, est_cost_usd: 2.8,
- verdict: 'fail', total: 10, failures, ...COLLAPSED_PANEL,
+ verdict: 'fail', total: 10, failures, ...CLI_PANEL,
}),
}));
expect(r.outcome).toBe('fail');
const [event] = await readEvents();
- expect(event.judge_models).toEqual([SONNET, OPUS, SONNET]);
- expect(event.distinct_judge_models).toBe(2);
+ expect(event.judge_models).toEqual(CLI_PANEL.judge_models);
+ expect(event.distinct_judge_models).toBe(3);
expect(event.distinct_judge_providers).toBe(1);
expect(event.failures).toEqual(failures);
+ expect(event.reason).toBeUndefined();
expect(event.detail).toBe(
- '6/10 questions did not pass (directness mean_below_7 x6); judges: 2 distinct models from 1 provider',
+ '6/10 questions did not pass (directness mean_below_7 x6); judges: 3 distinct models from 1 provider',
);
expect(event.est_cost_usd).toBe(2.8);
});
});
- test('a PASS summary records the panel and no failure list or digest', async () => {
+ test('a sonnet/opus/sonnet panel turns a FAIL into inconclusive with the remedy (#5506, D12)', async () => {
+ const failures = [[6, 7, 6], [5, 8, 6]].map((scores, i) => directnessFailure(`q${i + 1}`, scores));
await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
- await runNightlyQualityProbe(makeDeps({
+ const r = await runNightlyQualityProbe(makeDeps({
+ runCrossModalBatch: batchStub({
+ pass_count: 8, fail_count: 2, inconclusive_count: 0, error_count: 0, est_cost_usd: 2.8,
+ verdict: 'fail', total: 10, failures, ...COLLAPSED_PANEL,
+ }),
+ }));
+ expect(r.outcome).toBe('inconclusive');
+ const [event] = await readEvents();
+ expect(event.outcome).toBe('inconclusive');
+ expect(event.reason).toBe('panel_collapsed');
+ expect(event.judge_models).toEqual([SONNET, OPUS, SONNET]);
+ expect(event.failures).toEqual(failures);
+ expect(event.detail).toBe(
+ `judge panel collapsed: ${SONNET} holds slots A, C, so its votes count more than once. ` +
+ 'Set three different judge models: gbrain config set models.eval.cross_modal.slot_a <model> ' +
+ '(and slot_b, slot_c; one provider is enough). ' +
+ 'See docs/eval-bench.md#nightly-cross-modal-quality-probe-opt-in-autopilot (batch verdict: fail); ' +
+ '2/10 questions did not pass (directness mean_below_7 x2); judges: 2 distinct models from 1 provider',
+ );
+ });
+ });
+
+ test('a PASS from a collapsed panel is inconclusive, never a pass', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ const r = await runNightlyQualityProbe(makeDeps({
runCrossModalBatch: batchStub({
pass_count: 10, fail_count: 0, inconclusive_count: 0, error_count: 0, est_cost_usd: 1.8,
verdict: 'pass', total: 10, ...COLLAPSED_PANEL,
}, 0),
}));
+ expect(r.outcome).toBe('inconclusive');
const [event] = await readEvents();
- expect(event.outcome).toBe('pass');
+ expect(event.outcome).toBe('inconclusive');
+ expect(event.reason).toBe('panel_collapsed');
expect(event.judge_models).toEqual([SONNET, OPUS, SONNET]);
expect(event.failures).toBeUndefined();
+ expect(event.detail).toStartWith(`judge panel collapsed: ${SONNET} holds slots A, C`);
+ });
+ });
+
+ test('only one model judged (two slots silent) is inconclusive', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ const r = await runNightlyQualityProbe(makeDeps({
+ runCrossModalBatch: batchStub({
+ pass_count: 10, fail_count: 0, inconclusive_count: 0, error_count: 0, est_cost_usd: 1.8,
+ verdict: 'pass', total: 10, judge_models: CLI_PANEL.judge_models,
+ panel: { distinct_models: 1, distinct_providers: 1, slot_scored_questions: [10, 0, 0] },
+ }, 0),
+ }));
+ expect(r.outcome).toBe('inconclusive');
+ const [event] = await readEvents();
+ expect(event.reason).toBe('panel_collapsed');
+ expect(event.detail).toStartWith('judge panel collapsed: 1 distinct model judged, so there is no cross-check.');
+ });
+ });
+
+ test('a PASS summary on a sound panel records the panel and no failure list or digest', async () => {
+ await withEnv({ GBRAIN_AUDIT_DIR: auditTmp }, async () => {
+ await runNightlyQualityProbe(makeDeps({
+ runCrossModalBatch: batchStub({
+ pass_count: 10, fail_count: 0, inconclusive_count: 0, error_count: 0, est_cost_usd: 1.8,
+ verdict: 'pass', total: 10, ...CLI_PANEL,
+ }, 0),
+ }));
+ const [event] = await readEvents();
+ expect(event.outcome).toBe('pass');
+ expect(event.judge_models).toEqual(CLI_PANEL.judge_models);
+ expect(event.failures).toBeUndefined();
expect(event.detail).toBeUndefined();
+ expect(event.receipt_dir).toBeUndefined();
});
});