graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
feat(fleet): effort pins, closed local evolution loop, bench-prior worker routing (#292 follow-up)
justrach03454ce42fe5
diff --git a/README.md b/README.mdindex d50243e3..b7d5a098 100644--- a/README.md+++ b/README.md@@ -907,18 +907,24 @@ name: implementertier: mid # a rung of the current provider's ladder — preferred,# it stays correct when the root model changes# model: gpt-5.6-terra # …or pin an exact name instead+effort: max # reasoning depth for this worker (low|medium|high|xhigh|max);+ # unpinned workers run at mediumisolation: worktree---``````jsonc// one subagent call, overriding everything above for that child only-{"description": "extract imports", "prompt": "…", "agent": "implementer", "tier": "small"}+{"description": "extract imports", "prompt": "…", "agent": "implementer", "tier": "small", "effort": "low"}```Precedence, highest first: **`model`/`tier` on the spawn → the persona's`model:`/`tier:` frontmatter → `--subagent-model` → the default tier ladder →-the root model.** Within one level an exact `model` beats a `tier`. Pins are+the root model.** Within one level an exact `model` beats a `tier`. Reasoning+**effort** follows the same spawn → persona → default chain (default: medium)+but is an independent axis — an effort-only override keeps the persona's model+pin, so `effort: max` on a `model: gpt-5.6-luna` persona is exactly a "Luna+Max" worker. Pins areprovider-local — they pick a different model on the child's *current* providerand never move work across a provider boundary, which stays with`--subagent-provider` + `--allow-cross-provider-subagents`. A pin that cannotdiff --git a/sdk/py/harness_sdk.py b/sdk/py/harness_sdk.pyindex 47d09715..ce8ef27c 100644--- a/sdk/py/harness_sdk.py+++ b/sdk/py/harness_sdk.py@@ -13,7 +13,7 @@ import urllib.errorimport urllib.requestfrom typing import Iterator, Optional-MODELS = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "grok-4.3", "grok-build", "k3", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mlx-community/Qwen3.6-27B-OptiQ-4bit"]+MODELS = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "grok-4.3", "grok-build", "k3", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k2.7-code-highspeed", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mlx-community/Qwen3.6-27B-OptiQ-4bit"]TOOLS = ["bash", "bash_output", "bash_kill", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "todo_write", "todo_read", "eval", "ask_user", "attempt_completion", "clock_sleep", "subagent", "workflow", "agent_output", "learn_candidate", "imagegen"]PROVIDERS = ["anthropic", "codegraff", "deepseek", "openai", "minimax", "xiaomi", "kimi", "moonshot", "xai", "zai", "fugu", "fireworks", "mlx", "lmstudio", "codex"]diff --git a/sdk/ts/harness.ts b/sdk/ts/harness.tsindex 23d327ec..7ea7e4ed 100644--- a/sdk/ts/harness.ts+++ b/sdk/ts/harness.ts@@ -10,7 +10,7 @@ import { createInterface } from "node:readline";export const HARNESS_VERSION = "0.10";-export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5.2" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "grok-4.3" | "grok-build" | "k3" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | (string & {});+export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5.2" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "grok-4.3" | "grok-build" | "k3" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-k2.7-code" | "kimi-k2.7-code-highspeed" | "kimi-k3" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | (string & {});export type ToolName = "bash" | "bash_output" | "bash_kill" | "read_file" | "edit_file" | "write_file" | "webfetch" | "skill" | "codedb" | "todo_write" | "todo_read" | "eval" | "ask_user" | "attempt_completion" | "clock_sleep" | "subagent" | "workflow" | "agent_output" | "learn_candidate" | "imagegen";export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "minimax" | "xiaomi" | "kimi" | "moonshot" | "xai" | "zai" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";@@ -431,5 +431,5 @@ export async function* runAgent(opts: RunAgentOptions): AsyncGenerator<Event> {}}-export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "grok-4.3", "grok-build", "k3", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mlx-community/Qwen3.6-27B-OptiQ-4bit"];+export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "grok-4.3", "grok-build", "k3", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k2.7-code-highspeed", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mlx-community/Qwen3.6-27B-OptiQ-4bit"];export const TOOLS: ToolName[] = ["bash", "bash_output", "bash_kill", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "todo_write", "todo_read", "eval", "ask_user", "attempt_completion", "clock_sleep", "subagent", "workflow", "agent_output", "learn_candidate", "imagegen"];diff --git a/sdk/ts/remote.ts b/sdk/ts/remote.tsindex 030fa2ef..099ad121 100644--- a/sdk/ts/remote.ts+++ b/sdk/ts/remote.ts@@ -9,7 +9,7 @@export const HARNESS_VERSION = "0.10";-export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-4.8" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-4.6" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5.2" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "grok-4.3" | "grok-build" | "k3" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | (string & {});+export type ModelName = "MiniMax-M2.5" | "MiniMax-M2.7" | "MiniMax-M3" | "accounts/fireworks/models/deepseek-v4-flash" | "accounts/fireworks/models/deepseek-v4-pro" | "accounts/fireworks/models/glm-5p2" | "accounts/fireworks/models/gpt-oss-120b" | "accounts/fireworks/models/kimi-k2p6" | "accounts/fireworks/models/kimi-k2p7-code" | "accounts/fireworks/models/minimax-m3" | "accounts/fireworks/models/qwen3p7-plus" | "claude-fable-5" | "claude-haiku-4-5" | "claude-opus-4-5" | "claude-opus-4-6" | "claude-opus-4-7" | "claude-opus-4-8" | "claude-opus-5" | "claude-sonnet-4-5" | "claude-sonnet-4-6" | "claude-sonnet-5" | "deepseek-chat" | "deepseek-reasoner" | "deepseek-v4-flash" | "deepseek-v4-pro" | "fugu" | "fugu-ultra" | "fugu-ultra-20260615" | "glm-4.5" | "glm-4.7" | "glm-5" | "glm-5.2" | "gpt-5-codex" | "gpt-5.2" | "gpt-5.3-codex-spark" | "gpt-5.4" | "gpt-5.4-mini" | "gpt-5.4-pro" | "gpt-5.5" | "gpt-5.6" | "gpt-5.6-luna" | "gpt-5.6-sol" | "gpt-5.6-terra" | "grok-4.3" | "grok-build" | "k3" | "kimi-for-coding" | "kimi-for-coding-highspeed" | "kimi-k2.6" | "kimi-k2.7-code" | "kimi-k2.7-code-highspeed" | "kimi-k3" | "kimi-latest" | "lmstudio" | "mimo-v2-flash" | "mimo-v2.5" | "mimo-v2.5-pro" | "mimo-v2.5-pro-ultraspeed" | "minimax-m3" | "mlx-community/Qwen3.6-27B-OptiQ-4bit" | (string & {});export type ToolName = "bash" | "bash_output" | "bash_kill" | "read_file" | "edit_file" | "write_file" | "webfetch" | "skill" | "codedb" | "todo_write" | "todo_read" | "eval" | "ask_user" | "attempt_completion" | "clock_sleep" | "subagent" | "workflow" | "agent_output" | "learn_candidate" | "imagegen";export type ProviderId = "anthropic" | "codegraff" | "deepseek" | "openai" | "minimax" | "xiaomi" | "kimi" | "moonshot" | "xai" | "zai" | "fugu" | "fireworks" | "mlx" | "lmstudio" | "codex";@@ -322,5 +322,5 @@ export async function* runAgentRemote(opts: RunAgentRemoteOptions): AsyncGenerat}}-export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-4.8", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-4.6", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "grok-4.3", "grok-build", "k3", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mlx-community/Qwen3.6-27B-OptiQ-4bit"];+export const MODELS: ModelName[] = ["MiniMax-M2.5", "MiniMax-M2.7", "MiniMax-M3", "accounts/fireworks/models/deepseek-v4-flash", "accounts/fireworks/models/deepseek-v4-pro", "accounts/fireworks/models/glm-5p2", "accounts/fireworks/models/gpt-oss-120b", "accounts/fireworks/models/kimi-k2p6", "accounts/fireworks/models/kimi-k2p7-code", "accounts/fireworks/models/minimax-m3", "accounts/fireworks/models/qwen3p7-plus", "claude-fable-5", "claude-haiku-4-5", "claude-opus-4-5", "claude-opus-4-6", "claude-opus-4-7", "claude-opus-4-8", "claude-opus-5", "claude-sonnet-4-5", "claude-sonnet-4-6", "claude-sonnet-5", "deepseek-chat", "deepseek-reasoner", "deepseek-v4-flash", "deepseek-v4-pro", "fugu", "fugu-ultra", "fugu-ultra-20260615", "glm-4.5", "glm-4.7", "glm-5", "glm-5.2", "gpt-5-codex", "gpt-5.2", "gpt-5.3-codex-spark", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-pro", "gpt-5.5", "gpt-5.6", "gpt-5.6-luna", "gpt-5.6-sol", "gpt-5.6-terra", "grok-4.3", "grok-build", "k3", "kimi-for-coding", "kimi-for-coding-highspeed", "kimi-k2.6", "kimi-k2.7-code", "kimi-k2.7-code-highspeed", "kimi-k3", "kimi-latest", "lmstudio", "mimo-v2-flash", "mimo-v2.5", "mimo-v2.5-pro", "mimo-v2.5-pro-ultraspeed", "minimax-m3", "mlx-community/Qwen3.6-27B-OptiQ-4bit"];export const TOOLS: ToolName[] = ["bash", "bash_output", "bash_kill", "read_file", "edit_file", "write_file", "webfetch", "skill", "codedb", "todo_write", "todo_read", "eval", "ask_user", "attempt_completion", "clock_sleep", "subagent", "workflow", "agent_output", "learn_candidate", "imagegen"];diff --git a/src/agent.zig b/src/agent.zigindex eb556f29..80c4aeea 100644--- a/src/agent.zig+++ b/src/agent.zig@@ -151,6 +151,7 @@ pub const Agent = struct {eval_best: f64 = -1, // best score seen this session (-1 = none yet)eval_verified: bool = false, // latest workspace state has a target-meeting verifier resulteval_repair_pending: bool = false, // a contradiction blocks completion until a fresh green eval+ eval_repair_grants: u8 = 0, // RED continuations consumed (agent_steps.grantRepairTurn); reset by any green eval, capped by eval_control.max_repair_grantsstrict: bool = false,completed: ?[]const u8 = null,last_context_tokens: u64 = 0,diff --git a/src/agent_eval.zig b/src/agent_eval.zigindex 2ee940e7..ae1868af 100644--- a/src/agent_eval.zig+++ b/src/agent_eval.zig@@ -20,6 +20,9 @@ const telemetry = @import("telemetry.zig");const runCapped = @import("jobs.zig").runCapped;const judgeTask = @import("subagent.zig").judgeTask;const eval_memory = @import("eval_memory.zig");+const trace = @import("trace.zig");+const fleet = @import("fleet.zig");+const main_mod = @import("main.zig");test {_ = @import("agent_eval_tests.zig");@@ -89,6 +92,10 @@ pub fn runEval(self: *Agent, note: []const u8) !ExecResult {const met = if (combined) |s| s >= target_f else false;self.eval_repair_pending = exit_code != 0 or !met;self.eval_verified = !self.eval_repair_pending;+ // A green eval refunds the RED-continuation budget (see grantRepairTurn):+ // red→repair→green→red progress cycles keep running; only sustained+ // failure exhausts it.+ if (self.eval_verified) self.eval_repair_grants = 0;// Resolve the commitment made above: a nonzero exit or an unmet/unparsed// target contradicts "this command will meet the target", so it is a// misprediction. Meeting the target leaves the commitment unresolved by@@ -114,13 +121,14 @@ pub fn runEval(self: *Agent, note: []const u8) !ExecResult {// rejection, so the submit counter stays in sync with stored// scores. The local eval verdict below still shows the number.if (self.tracer) |tr| tr.note("fleet", "score skipped: eval score outside [0,100]");- } else if (telemetry.g_telem) |t| {+ } else if (trace.g_traj != null or telemetry.g_telem != null) {+ // Skipped entirely when neither sink exists (also keeps stub+ // agents in tests from touching provider/systemPrompt).const sys = self.systemPrompt();const genome_fp = promptFingerprint(sys);const esh_fp = promptFingerprint(cmd);const genome: []const u8 = &genome_fp;const esh: []const u8 = &esh_fp;- const run_id: []const u8 = &scoring.g_run_id;const pclass = providerClass(self.provider.model);// --niche tags this score's cell. Without it the score lands in the// anonymous "" niche, which pullElites can never match to a builtin —@@ -130,32 +138,65 @@ pub fn runEval(self: *Agent, note: []const u8) !ExecResult {// /score) so signed bytes equal ingested bytes.var niche_buf: [64]u8 = undefined;const niche = scoring.sanitizeMetaField(&niche_buf, utf8Prefix(self.eval_niche, 64));- // Genome-send (graff-dgm.md §B): the eval genome is this agent's own- // persona, never spawned via runSub, so its prompt_text never reached- // the worker. A cell only promotes when harness_scores joins to a- // harness_genomes row, so ride the genome text over on a `propose`- // (deduped by prompt_sha) before the score — else a winning eval cell- // has nothing to serve. Gated on a niche: a "" cell is unpromotable.- // Oversized genomes skip the propose (review F6): the server verifies- // the fingerprint over the carried text, so a truncated genome would- // be dropped there anyway.- if (niche.len > 0) {- if (sys.len <= telemetry.Telemetry.max_propose_text)- t.fleetEvent("propose", niche, genome, "", pclass, "", 0, sys)- else if (self.tracer) |tr| tr.note("fleet", "propose skipped: genome > 64KB");- }- // SCORE SCALE CONTRACT (issue #168 Gap 4): local UX stays- // 0-100 (the /100 verdicts below, eval_best, eval_target),- // but every score that leaves the client is [0,1] — divide at- // the emission boundary; s01 is what gets signed (v2: niche +- // provider_class in the envelope) and sent.+ // SCORE SCALE CONTRACT (issue #168 Gap 4): local UX stays 0-100+ // (the /100 verdicts below, eval_best, eval_target), but every+ // score that leaves this function — the local archive row and+ // the signed envelope alike — is [0,1].const s01 = s / 100.0;- const sig = signScore(genome, "", s01, run_id, "", "", esh, niche, pclass);- const sig_s: []const u8 = if (scoring.g_score_key != null) &sig else "";- var provbuf: [512]u8 = undefined;- const prov = std.fmt.bufPrint(&provbuf, "{s}\t{s}\t{s}\t{s}\t{s}", .{ "", "", esh, pclass, niche }) catch "";- t.scoreEvent(genome, "", s01, run_id, sig_s, prov);- t.fleetEvent("submit", niche, genome, "", pclass, esh, 0, "");+ // Local DGM capture, deliberately OUTSIDE the telemetry gate:+ // the same genome + score the fleet events carry also lands in+ // .graff/trajectories, so `/agents promote` can grow a champion+ // from eval-driven runs with zero egress. Until this block the+ // eval loop fed only the backend — a default-local-privacy+ // session scored work the local promote could never see. The+ // kind:"eval" row carries the niche tag: promoteAgents reads+ // niche off non-prompt/non-score records only. Same niche gate+ // as the backend path — a "" cell is unpromotable either way.+ if (niche.len > 0) if (trace.g_traj) |traj| {+ traj.capturePrompt(genome_fp, sys);+ traj.node(.{ .kind = "eval", .prompt_sha = genome, .niche = niche, .eval_set_hash = esh, .provider_class = pclass, .t = traj.elapsedMs() });+ traj.node(.{ .kind = "score", .prompt_sha = genome, .score = s01, .niche = niche, .eval_set_hash = esh, .provider_class = pclass, .t = traj.elapsedMs() });+ };+ // Auto-learn: evolution is a default part of the harness, not+ // a command. A target-met NEW BEST is the learning moment —+ // the work just verified green — so recompute this project's+ // champions from the archive right now and hot-reload them,+ // making the very next spawn run the evolved genome with no+ // restart and no /agents promote. Auto mode never overwrites+ // a hand-written persona (fleet.promoteAgents); the manual+ // command remains for --personal tiers and forced overwrites.+ if (met and niche.len > 0 and main_mod.g_fleet and !self.sub) {+ var pout: Io.Writer.Allocating = .init(self.arena);+ const n = fleet.promoteAgents(self.io, self.gpa, &pout.writer, fleet.g_home, false, true);+ if (n > 0) {+ fleet.g_agent_types = fleet.loadAgentTypes(self.io, self.arena, fleet.g_home);+ self.say(" auto-promoted {d} champion persona(s) → {s} (live now)\n", .{ n, fleet.agents_dir }) catch {};+ if (self.tracer) |tr| tr.note("fleet", "auto-promoted champions after green eval");+ }+ }+ if (telemetry.g_telem) |t| {+ const run_id: []const u8 = &scoring.g_run_id;+ // Genome-send (graff-dgm.md §B): the eval genome is this agent's own+ // persona, never spawned via runSub, so its prompt_text never reached+ // the worker. A cell only promotes when harness_scores joins to a+ // harness_genomes row, so ride the genome text over on a `propose`+ // (deduped by prompt_sha) before the score — else a winning eval cell+ // has nothing to serve. Gated on a niche: a "" cell is unpromotable.+ // Oversized genomes skip the propose (review F6): the server verifies+ // the fingerprint over the carried text, so a truncated genome would+ // be dropped there anyway.+ if (niche.len > 0) {+ if (sys.len <= telemetry.Telemetry.max_propose_text)+ t.fleetEvent("propose", niche, genome, "", pclass, "", 0, sys)+ else if (self.tracer) |tr| tr.note("fleet", "propose skipped: genome > 64KB");+ }+ const sig = signScore(genome, "", s01, run_id, "", "", esh, niche, pclass);+ const sig_s: []const u8 = if (scoring.g_score_key != null) &sig else "";+ var provbuf: [512]u8 = undefined;+ const prov = std.fmt.bufPrint(&provbuf, "{s}\t{s}\t{s}\t{s}\t{s}", .{ "", "", esh, pclass, niche }) catch "";+ t.scoreEvent(genome, "", s01, run_id, sig_s, prov);+ t.fleetEvent("submit", niche, genome, "", pclass, esh, 0, "");+ }}}}diff --git a/src/agent_eval_control.zig b/src/agent_eval_control.zigindex 740cc716..b3048bec 100644--- a/src/agent_eval_control.zig+++ b/src/agent_eval_control.zig@@ -10,6 +10,13 @@ pub const verifier_boundary =pub const verifier_hard_stop ="VERIFIER RED: the committed plan was dropped. Start a repair turn, make one focused repair, then rerun eval before completion.";+/// How many RED continuations one session may consume before the turn gives+/// up and surfaces verifier_hard_stop as its final text. Each grant is one+/// repair attempt plus its eval rerun; any green eval resets the budget+/// (runEval), so progress loops stay alive while a permanently-red eval+/// still terminates.+pub const max_repair_grants: u8 = 5;+pub fn evalCallIndex(calls: []const ToolCall) ?usize {for (calls, 0..) |call, index| {if (std.mem.eql(u8, call.name, "eval")) return index;diff --git a/src/agent_steps.zig b/src/agent_steps.zigindex c6310982..1e7c2156 100644--- a/src/agent_steps.zig+++ b/src/agent_steps.zig@@ -35,6 +35,22 @@ fn surfaceUnstreamedText(self: *Agent, text: []const u8) !void {const ssePayload = Agent.ssePayload;const sseIndex = Agent.sseIndex;+/// A RED eval used to END the turn with verifier_hard_stop as its final+/// text — right as a batch boundary, wrong as a turn outcome: the message+/// orders the MODEL to "start a repair turn", but a -p one-shot has no next+/// turn, so the run died at score 0 with the artifact never written (and in+/// the REPL the user had to re-prompt by hand). Grant the repair turn+/// in-loop instead: append the hard-stop as a user steering message and+/// keep stepping. Bounded by max_repair_grants — reset on any green eval in+/// runEval — so a permanently-red eval still terminates; when the budget is+/// spent the caller falls back to the old end-the-turn behavior.+fn grantRepairTurn(self: *Agent) !bool {+ if (self.eval_repair_grants >= eval_control.max_repair_grants) return false;+ self.eval_repair_grants += 1;+ try self.messages.append(try messages_mod.textMessage(self.arena, "user", eval_control.verifier_hard_stop));+ return true;+}+/// Consume a Codex `response` object: append its output items to history/// (verbatim — they're valid Responses input items), surface text, and/// collect any function calls. Returns final text when no tools were@@ -119,7 +135,10 @@ pub fn stepResponses(self: *Agent, response: std.json.ObjectMap) !?[]const u8 {const fco = try toolResultMessage(self.arena, .responses, call.id, r.text, r.is_error);try self.messages.append(fco);}- if (eval_control.shouldStopAfterBatch(calls.items, self.eval_repair_pending)) return eval_control.verifier_hard_stop;+ if (eval_control.shouldStopAfterBatch(calls.items, self.eval_repair_pending)) {+ if (try grantRepairTurn(self)) return null;+ return eval_control.verifier_hard_stop;+ }if (self.completed) |result| return result;return null;}@@ -177,7 +196,10 @@ pub fn stepAnthropic(self: *Agent, root: std.json.ObjectMap) !?[]const u8 {try user_msg.put(self.arena, "content", .{ .array = blocks });try self.messages.append(.{ .object = user_msg });- if (eval_control.shouldStopAfterBatch(calls.items, self.eval_repair_pending)) return eval_control.verifier_hard_stop;+ if (eval_control.shouldStopAfterBatch(calls.items, self.eval_repair_pending)) {+ if (try grantRepairTurn(self)) return null;+ return eval_control.verifier_hard_stop;+ }if (self.completed) |result| return result;return null; // loop again}@@ -238,7 +260,10 @@ pub fn stepOpenAI(self: *Agent, root: std.json.ObjectMap) !?[]const u8 {const tool_msg = try toolResultMessage(self.arena, .openai, call.id, r.text, r.is_error);try self.messages.append(tool_msg);}- if (eval_control.shouldStopAfterBatch(calls.items, self.eval_repair_pending)) return eval_control.verifier_hard_stop;+ if (eval_control.shouldStopAfterBatch(calls.items, self.eval_repair_pending)) {+ if (try grantRepairTurn(self)) return null;+ return eval_control.verifier_hard_stop;+ }if (self.completed) |result| return result;return null;}diff --git a/src/bench_priors.zig b/src/bench_priors.zignew file mode 100644index 00000000..b4dade22--- /dev/null+++ b/src/bench_priors.zig@@ -0,0 +1,295 @@+//! Bench-derived worker priors: `.harness/bench.json` (project, else+//! personal ~/.harness/bench.json) is a benchmark score/cost sheet — one+//! entry per (model, effort) config, e.g. a DeepSWE leaderboard export — and+//! this module turns it into per-provider tier ladders so worker assignment+//! starts from measured capability and cost instead of the compiled-in hand+//! table in subagent_tier_ladder.zig (which stays as the fallback for+//! providers the sheet cannot cover).+//!+//! Derivation, per provider, over the sheet models that RESOLVE on that+//! provider's live catalog (subagent_selection.modelForProvider — so one+//! sheet feeds every provider serving any of its models, and an unknown or+//! renamed model is skipped, never a load failure):+//!+//! frontier = best score (capability ceiling)+//! small = best score-per-dollar among the other models (the efficiency+//! knee the sheet's power-law tail points at)+//! mid = best score among the rest (nullable)+//!+//! A provider needs at least two resolved models to earn a derived ladder.+//! Scores accept [0,1] or percent (0,100]; a non-positive cost contributes+//! capability but no efficiency. Loaded by fleet.loadAgentTypes, so the+//! session registry and auto-promote's hot-reload refresh it together.+//!+//! PRECEDENCE: project ./.harness/bench.json > personal ~/.harness/bench.json+//! > the BUILTIN sheet below — a shipped community leaderboard snapshot, so+//! every install starts with a measured cost/capability power law rather+//! than a blank. The intended refresher for the builtin is aggregated fleet+//! telemetry (users who opt into data sharing already submit signed+//! niche-tagged scores); serving that aggregate back is backend work — the+//! seam here is just "a sheet from anywhere, highest tier wins".++const std = @import("std");+const Io = std.Io;+const Allocator = std.mem.Allocator;++const tier_ladder = @import("subagent_tier_ladder.zig");+const selection = @import("subagent_selection.zig");+const provider_mod = @import("provider.zig");++pub const bench_path = ".harness/bench.json";++/// Bench-derived ladders, consulted by tier_ladder.forProvider ahead of the+/// compiled table. Session-arena strings; empty when no sheet is present.+pub var g_ladders: []const tier_ladder.TierLadder = &.{};++/// Which providers the user is actually logged into / keyed for, snapshotted+/// when startup resolves credentials (noteAvailability, spec-table order).+/// Derivation skips the rest: priors describe YOUR available fleet, not the+/// whole catalog. null (tests, pre-startup) = no opinion, derive everything.+/// A mid-session /login is picked up on next start, like persona files —+/// until then the compiled ladder covers the newly added provider.+pub var g_available: ?[provider_mod.provider_specs.len]bool = null;++/// By VALUE in, by value out — written to ride resolveKeys' return statement+/// (a pointer into its stack Keys would dangle) without costing the capped+/// file a line.+pub fn noteAvailability(keys: provider_mod.Keys) provider_mod.Keys {+ var av: [provider_mod.provider_specs.len]bool = undefined;+ for (keys.values, 0..) |v, i| av[i] = v != null;+ g_available = av;+ return keys;+}++pub const Entry = struct {+ model: []const u8,+ effort: ?[]const u8 = null, // recorded for provenance; ladders name models+ score: f64,+ cost: f64 = 0, // avg $ per task; <= 0 = unknown (no efficiency signal)+};++pub const Sheet = struct {+ suite: []const u8 = "",+ updated: []const u8 = "",+ entries: []Entry = &.{},+};++/// The shipped default sheet: DeepSWE v1.1 (113 tasks, updated 2026-07-25),+/// avg $ per task. Chart-read values (±~2% score, ±~$0.5 cost) — plenty for+/// rung ORDERING, which is all derivation consumes. Models no provider+/// serves (gemini, muse-spark) still belong here: they resolve nowhere today+/// but start working the day a catalog serves them.+pub const builtin_entries = [_]Entry{+ .{ .model = "claude-opus-5", .effort = "max", .score = 74, .cost = 12.0 },+ .{ .model = "claude-fable-5", .effort = "high", .score = 70, .cost = 9.0 },+ .{ .model = "claude-sonnet-5", .effort = "high", .score = 49, .cost = 10.5 },+ .{ .model = "claude-opus-4-8", .effort = "high", .score = 41, .cost = 2.9 },+ .{ .model = "claude-sonnet-4-6", .effort = "high", .score = 31, .cost = 6.5 },+ .{ .model = "k3", .effort = "max", .score = 68, .cost = 4.6 },+ .{ .model = "kimi-k2.7-code", .score = 30, .cost = 2.6 },+ .{ .model = "gpt-5.6-sol", .effort = "max", .score = 73, .cost = 5.5 },+ .{ .model = "gpt-5.6-sol", .effort = "medium", .score = 61, .cost = 1.86 },+ .{ .model = "gpt-5.6-terra", .effort = "medium", .score = 35, .cost = 0.9 },+ .{ .model = "gpt-5.6-luna", .effort = "max", .score = 67, .cost = 0.61 },+ .{ .model = "gpt-5.6-luna", .effort = "medium", .score = 11, .cost = 0.15 },+ .{ .model = "gpt-5.5", .effort = "medium", .score = 54, .cost = 3.2 },+ .{ .model = "gpt-5.4", .effort = "xhigh", .score = 53, .cost = 5.2 },+ .{ .model = "grok-4.5", .effort = "high", .score = 53, .cost = 3.0 },+ .{ .model = "glm-5.2", .effort = "max", .score = 44, .cost = 3.9 },+ .{ .model = "muse-spark-1.1", .effort = "xhigh", .score = 50, .cost = 3.0 },+ .{ .model = "gemini-3.6-flash", .effort = "high", .score = 54, .cost = 3.5 },+ .{ .model = "gemini-3.5-flash", .effort = "medium", .score = 38, .cost = 7.0 },+ .{ .model = "gemini-3.1-pro", .effort = "high", .score = 12, .cost = 9.5 },+};++pub fn loadInto(io: Io, arena: Allocator, home: ?[]const u8) void {+ var sheet = readSheet(io, arena, bench_path);+ if (sheet == null) if (home) |h| {+ const p = std.fmt.allocPrint(arena, "{s}/{s}", .{ h, bench_path }) catch return;+ sheet = readSheet(io, arena, p);+ };+ g_entries = if (sheet) |s| s.entries else &builtin_entries;+ g_ladders = derive(arena, g_entries);+}++fn readSheet(io: Io, arena: Allocator, path: []const u8) ?Sheet {+ const data = Io.Dir.cwd().readFileAlloc(io, path, arena, .limited(1 << 20)) catch return null;+ return std.json.parseFromSliceLeaky(Sheet, arena, data, .{ .ignore_unknown_fields = true, .allocate = .alloc_always }) catch null;+}++/// [0,1] passes; (1,100] reads as percent; anything else is not a score.+fn normalScore(s: f64) ?f64 {+ if (!(s >= 0)) return null;+ if (s <= 1) return s;+ if (s <= 100) return s / 100.0;+ return null;+}++/// The current sheet's entries (file else builtin) — the score authority+/// subscription-rung ranking consults (subagent_pin.subscriptionRung).+pub var g_entries: []const Entry = &builtin_entries;++/// The session Keys, captured where main() builds its loop context (the+/// pointer targets main's stack frame, alive for the whole loop). Lets the+/// spawn path build a Provider for a logged-in subscription — null in tests+/// and before startup, which reads as "no subscriptions reachable".+pub var g_keys: ?*const provider_mod.Keys = null;++pub fn noteKeys(keys: *provider_mod.Keys) *provider_mod.Keys {+ g_keys = keys;+ return keys;+}++/// Best sheet score for `model` as served by `provider_id`; null when the+/// sheet has no opinion.+pub fn scoreFor(provider_id: []const u8, model: []const u8) ?f64 {+ var best: ?f64 = null;+ for (g_entries) |e| {+ const s = normalScore(e.score) orelse continue;+ const r = selection.modelForProvider(provider_id, e.model) orelse continue;+ if (!std.mem.eql(u8, r, model)) continue;+ if (best == null or s > best.?) best = s;+ }+ return best;+}++const Best = struct { name: []const u8, score: f64 = -1, spd: f64 = -1 };++/// One provider's per-model bests: the max score over that model's configs+/// and the max score-per-dollar, folded across every sheet entry that+/// resolves to it (several efforts of one model collapse into one candidate).+fn foldProvider(arena: Allocator, provider_id: []const u8, entries: []const Entry) []Best {+ var models: std.ArrayList(Best) = .empty;+ for (entries) |e| {+ const score = normalScore(e.score) orelse continue;+ const resolved = selection.modelForProvider(provider_id, e.model) orelse continue;+ const slot = blk: {+ for (models.items) |*m| if (std.mem.eql(u8, m.name, resolved)) break :blk m;+ models.append(arena, .{ .name = resolved }) catch return models.items;+ break :blk &models.items[models.items.len - 1];+ };+ if (score > slot.score) slot.score = score;+ if (e.cost > 0 and score / e.cost > slot.spd) slot.spd = score / e.cost;+ }+ return models.items;+}++fn derive(arena: Allocator, entries: []const Entry) []const tier_ladder.TierLadder {+ var out: std.ArrayList(tier_ladder.TierLadder) = .empty;+ for (provider_mod.provider_specs, 0..) |spec, i| {+ if (g_available) |av| if (!av[i]) continue;+ const models = foldProvider(arena, spec.id, entries);+ if (models.len < 2) continue;+ var frontier: *const Best = &models[0];+ for (models) |*m| if (m.score > frontier.score) {+ frontier = m;+ };+ var small: ?*const Best = null;+ for (models) |*m| {+ if (m == frontier or m.spd < 0) continue;+ if (small == null or m.spd > small.?.spd) small = m;+ }+ const sm = small orelse continue; // capability alone cannot rank efficiency+ var mid: ?*const Best = null;+ for (models) |*m| {+ if (m == frontier or m == sm) continue;+ if (mid == null or m.score > mid.?.score) mid = m;+ }+ out.append(arena, .{+ .provider = spec.id,+ .frontier = frontier.name,+ .mid = if (mid) |m| m.name else null,+ .small = sm.name,+ }) catch return out.items;+ }+ return out.items;+}++test "bench sheet: score normalization accepts unit and percent, rejects junk" {+ try std.testing.expectEqual(@as(f64, 0.67), normalScore(0.67).?);+ try std.testing.expectEqual(@as(f64, 0.67), normalScore(67).?);+ try std.testing.expect(normalScore(-1) == null);+ try std.testing.expect(normalScore(101) == null);+}++test "derive: frontier by score, small by score-per-dollar, mid from the rest" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();+ // Another test (or startup_tests' resolveKeys) may have snapshotted THIS+ // process's credentials; pin "no opinion" so derivation sees all specs.+ const saved = g_available;+ defer g_available = saved;+ g_available = null;+ // openai serves gpt-5.6 / gpt-5.6-terra / gpt-5.6-luna in the shipped+ // table, so this exercises real catalog resolution — including two+ // configs of one model collapsing into one candidate.+ const entries = [_]Entry{+ .{ .model = "gpt-5.6", .effort = "max", .score = 73, .cost = 5.5 },+ .{ .model = "gpt-5.6", .effort = "medium", .score = 61, .cost = 1.86 },+ .{ .model = "gpt-5.6-terra", .effort = "medium", .score = 35, .cost = 0.9 },+ .{ .model = "gpt-5.6-luna", .effort = "max", .score = 0.67, .cost = 0.61 },+ .{ .model = "not-a-model-anywhere", .score = 99, .cost = 0.01 }, // skipped, never a failure+ };+ const ladders = derive(a, &entries);+ var openai: ?tier_ladder.TierLadder = null;+ for (ladders) |l| if (std.mem.eql(u8, l.provider, "openai")) {+ openai = l;+ };+ try std.testing.expectEqualStrings("gpt-5.6", openai.?.frontier);+ try std.testing.expectEqualStrings("gpt-5.6-luna", openai.?.small.?); // 0.67/0.61 ≈ 1.10 beats terra's 0.39+ try std.testing.expectEqualStrings("gpt-5.6-terra", openai.?.mid.?);+}++test "builtin sheet: every install derives a codex ladder from the shipped leaderboard" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();+ const saved = g_available;+ defer g_available = saved;+ g_available = null;+ const ladders = derive(a, &builtin_entries);+ var codex: ?tier_ladder.TierLadder = null;+ for (ladders) |l| if (std.mem.eql(u8, l.provider, "codex")) {+ codex = l;+ };+ // sol tops capability; luna-max tops score-per-dollar (the leaderboard's+ // "most efficient" config); the data promotes gpt-5.5 over the hand+ // table's terra for the mid rung (54% vs 35%).+ try std.testing.expectEqualStrings("gpt-5.6-sol", codex.?.frontier);+ try std.testing.expectEqualStrings("gpt-5.6-luna", codex.?.small.?);+ try std.testing.expectEqualStrings("gpt-5.5", codex.?.mid.?);+}++test "derive: fewer than two resolved models yields no ladder for a provider" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();+ const saved = g_available;+ defer g_available = saved;+ g_available = null;+ const entries = [_]Entry{.{ .model = "grok-4.3", .score = 0.5, .cost = 3.0 }};+ for (derive(a, &entries)) |l| try std.testing.expect(!std.mem.eql(u8, l.provider, "xai"));+}++test "scoreFor: the sheet ranks a provider's models for subscription routing" {+ // Luna's best config (max, 67%) outranks terra's (medium, 35%) on codex.+ try std.testing.expect(scoreFor("codex", "gpt-5.6-luna").? > scoreFor("codex", "gpt-5.6-terra").?);+ try std.testing.expect(scoreFor("codex", "model-nobody-benched") == null);+}++test "derive: availability gate — priors describe only logged-in services" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();+ const saved = g_available;+ defer g_available = saved;+ var av: [provider_mod.provider_specs.len]bool = @splat(false);+ for (provider_mod.provider_specs, 0..) |spec, i| av[i] = std.mem.eql(u8, spec.id, "openai");+ g_available = av;+ // The full builtin sheet, but only one service logged in → exactly one+ // ladder: the sheet never speaks for a provider the user cannot reach.+ const ladders = derive(a, &builtin_entries);+ try std.testing.expectEqual(@as(usize, 1), ladders.len);+ try std.testing.expectEqualStrings("openai", ladders[0].provider);+}diff --git a/src/commands_session.zig b/src/commands_session.zigindex a4ce7d23..92c7cdfd 100644--- a/src/commands_session.zig+++ b/src/commands_session.zig@@ -277,7 +277,7 @@ pub fn tryHandle(root: *Agent, keys: *Keys, arena: Allocator, line: []const u8,if (std.mem.startsWith(u8, line, "/agents promote")) {const personal = std.mem.indexOf(u8, line, "--personal") != null or std.mem.indexOf(u8, line, "--global") != null;try out.print("{s}promoting local champions{s} → {s} tier (from {s})\n", .{ style.bold, style.reset, if (personal) "personal ~/.harness/agents" else "private ./.harness/agents", trace.trajectories_dir });- const n = promoteAgents(root.io, root.gpa, out, fleet.g_home, personal);+ const n = promoteAgents(root.io, root.gpa, out, fleet.g_home, personal, false);if (n > 0) try out.print("{s}✓ promoted {d} niche(s) — they load on next start{s}\n", .{ style.green, n, style.reset });try out.flush();return true;@@ -296,6 +296,11 @@ pub fn tryHandle(root: *Agent, keys: *Keys, arena: Allocator, line: []const u8,style.reset,});if (t.score) |sc| try out.print(" {s}score {d:.2}{s}", .{ style.green, sc, style.reset });+ // #292: surface a persona's operational pins (else only the .md shows them).+ if (t.model) |m| try out.print(" {s}model={s}{s}", .{ style.dim, m, style.reset });+ if (t.tier) |x| try out.print(" {s}tier={s}{s}", .{ style.dim, x.label(), style.reset });+ if (t.effort) |e| try out.print(" {s}effort={s}{s}", .{ style.dim, @tagName(e), style.reset });+ if (t.isolation) |i| try out.print(" {s}isolation={s}{s}", .{ style.dim, @tagName(i), style.reset });try out.print(" {s}\n", .{t.desc});}try out.flush();diff --git a/src/fleet.zig b/src/fleet.zigindex a73b1434..8ccca9fd 100644--- a/src/fleet.zig+++ b/src/fleet.zig@@ -29,7 +29,7 @@ const http = @import("http.zig");/// A named, reusable subagent persona: the unit the MAP-Elites archive is/// organized around (docs/hyperagents.md §MAP-Elites). Each niche keeps one/// elite prompt; builtins ship compiled in, and `.harness/agents/<name>.md`-/// files (frontmatter: name/description/score/isolation/model/tier, body: the system prompt)+/// files (frontmatter: name/description/score/isolation/model/tier/effort, body: the system prompt)/// override or extend them — that's where an evolution driver promotes/// archive winners. Spawn one with subagent/workflow `agent: "<name>"`./// #276 P0-1: per-agent git-worktree isolation. `.shared_cwd` (default) is@@ -70,6 +70,7 @@ pub const AgentType = struct {// default instead of failing a persona load or a spawn mid-fleet.model: ?[]const u8 = null, // frontmatter `model: gpt-5.6-terra`tier: ?Tier = null, // frontmatter `tier: mid`+ effort: ?root.ReasoningEffort = null, // frontmatter `effort: max` — reasoning depth, an axis independent of model/tier (vocabulary: subagent_pin.parseEffort)};/// Preloaded niches: deliberately orthogonal *behavioral* dimensions (what@@ -118,6 +119,7 @@ pub const agents_dir = ".harness/agents";/// previous by niche name, so a project persona beats a personal one beats a/// builtin.pub fn loadAgentTypes(io: Io, arena: Allocator, home: ?[]const u8) []const AgentType {+ @import("bench_priors.zig").loadInto(io, arena, home); // bench score/cost priors ride the same registry load (startup + auto-promote hot-reload)var list: std.ArrayList(AgentType) = .empty;list.appendSlice(arena, &builtin_agent_types) catch return &builtin_agent_types;if (home) |h| {@@ -149,7 +151,7 @@ pub fn loadAgentTypes(io: Io, arena: Allocator, home: ?[]const u8) []const Agent}/// Merge `<dir>/*.md` personas into `list`: YAML-ish frontmatter-/// (name/description/score/isolation/model/tier) + body as the prompt. A+/// (name/description/score/isolation/model/tier/effort) + body as the prompt. A/// file shadows any existing/// type (builtin or earlier tier) of the same name — the elite for a niche is/// whatever the highest tier last promoted.@@ -184,6 +186,7 @@ fn loadAgentDir(io: Io, arena: Allocator, list: *std.ArrayList(AgentType), dir_p// load, and an unknown model name is caught per spawn.if (std.mem.eql(u8, key, "model")) at.model = if (val.len > 0) val else null;if (std.mem.eql(u8, key, "tier")) at.tier = Tier.parse(val);+ if (std.mem.eql(u8, key, "effort")) at.effort = @import("subagent_pin.zig").parseEffort(val); // #292 follow-up: persona effort pin; off-vocabulary (incl. ultra) is "no opinion"}const body_start = fm_end + "\n---".len;at.prompt = std.mem.trim(u8, data[@min(body_start + 1, data.len)..], " \t\r\n");@@ -210,7 +213,7 @@ fn loadAgentDir(io: Io, arena: Allocator, list: *std.ArrayList(AgentType), dir_p/// (personal ~/.harness/agents or private ./.harness/agents) as <niche>.md. No/// backend: your own scored runs become your built-in personas. Returns the/// number of niches promoted.-pub fn promoteAgents(io: Io, gpa: Allocator, out: *Io.Writer, home: ?[]const u8, personal: bool) usize {+pub fn promoteAgents(io: Io, gpa: Allocator, out: *Io.Writer, home: ?[]const u8, personal: bool, auto: bool) usize {var arena_state = std.heap.ArenaAllocator.init(gpa);defer arena_state.deinit();const arena = arena_state.allocator();@@ -295,6 +298,12 @@ pub fn promoteAgents(io: Io, gpa: Allocator, out: *Io.Writer, home: ?[]const u8,}}const path = std.fmt.allocPrint(arena, "{s}/{s}.md", .{ dir, champ.niche }) catch continue;+ // Auto (green-eval) promotion never clobbers a hand-written persona:+ // only a file promotion itself wrote is fair game. Manual /agents+ // promote keeps today's overwrite semantics — the user asked for it.+ if (auto) if (Io.Dir.cwd().readFileAlloc(io, path, arena, .limited(64 * 1024)) catch null) |old| {+ if (std.mem.indexOf(u8, old, "description: promoted local champion") == null) continue;+ };// Promotion ranks GENOMES; the persona's operational frontmatter// (isolation, #292's model/tier) is policy, not something the judge// scored, so carry it across the rewrite instead of dropping it.diff --git a/src/main.zig b/src/main.zigindex b5d5540b..74bd37bc 100644--- a/src/main.zig+++ b/src/main.zig@@ -280,7 +280,7 @@ pub fn main(init: std.process.Init) !void {if (try startup.runSubcommand(io, gpa, arena, init, flags)) return;// Credential/model resolution (env vars → on-disk logins → `harness key set` store, env always wins; then --model or the last-saved model) lives// in startup.zig as resolveKeys() — pure over env/disk/arena, safe to call outside main()'s own stack frame.- const resolved_keys = try startup.resolveKeys(io, gpa, arena, init.environ_map, flags.model_flag);+ const resolved_keys = try startup.resolveKeys(io, gpa, arena, init.environ_map, flags.model_flag, flags.subagent_provider_flag orelse init.environ_map.get("GRAFF_SUBAGENT_PROVIDER"));boot.mark(io, "credentials/model");var keys = resolved_keys.keys;const default_provider = resolved_keys.default_provider;@@ -485,10 +485,10 @@ pub fn main(init: std.process.Init) !void {// `graff repl`: interactive chat REPL on the zigzag TUI, backed by the REAL agent loop — each prompt runs a full root turn (tools + MCP) via// replTurnCb, reusing the root agent's tool set + registry + system prompt. Self-contained — exits after.- if (try session_run.runReplCommand(gpa, io, init.environ_map, &root, &keys, &client, in, out, arena, flags)) return;+ if (try session_run.runReplCommand(gpa, io, init.environ_map, &root, @import("bench_priors.zig").noteKeys(&keys), &client, in, out, arena, flags)) return;// One-shot print mode: run the single prompt to completion, print the final text to stdout, exit.if (flags.oneshot_prompt) |prompt_text| {- try session_run.runOneshotPrompt(gpa, io, arena, &root, &keys, &tracer, out, prompt_text);+ try session_run.runOneshotPrompt(gpa, io, arena, &root, @import("bench_priors.zig").noteKeys(&keys), &tracer, out, prompt_text); // one-shot exits before loop_ctx below — capture keys for sub-first routing here tooreturn;}@@ -517,7 +517,7 @@ pub fn main(init: std.process.Init) !void {.io = io,.arena = arena,.root = &root,- .keys = &keys,+ .keys = @import("bench_priors.zig").noteKeys(&keys), // also captured for sub-first worker routing (subagent_pin.subscriptionRung).out = out,.in = in,.history = &history,diff --git a/src/prompts.zig b/src/prompts.zigindex 2a8293e6..2d451859 100644--- a/src/prompts.zig+++ b/src/prompts.zig@@ -81,6 +81,28 @@ pub const main_system_prompt =\\explicitly asks. Their existing commits and any -w worktree\\auto-checkpoints are the user's safety net; do not blow them away.\\+ \\Assume the user wants the work done, not described. Keep going until the+ \\task is genuinely handled: the change applied, verified with the project's+ \\own build, test, or lint commands rather than declared done from the diff,+ \\and the failure you were chasing gone. Never stop at a plan, a half-applied+ \\edit, or an untested guess, and never leave the last step for the user. If+ \\a real ambiguity blocks you, ask; otherwise decide and go.+ \\+ \\Before a large chunk of work, give a one- or two-sentence heads-up on what+ \\you are about to do; on long tasks, drop a brief note as each phase lands.+ \\With todo_write, mark an item in_progress when you start it and completed+ \\as it lands, not in a batch at the end.+ \\+ \\Fix root causes, not symptoms — a patch that only hides a failure is not a+ \\fix. Match the surrounding file's style and keep diffs minimal: no drive-by+ \\refactors, renames, or reformatting the task did not require.+ \\+ \\Write the final message as an update to a teammate who has not seen your+ \\screen. Cite evidence as `path:line` instead of pasting file bodies — never+ \\dump large file contents into an answer — and backtick-wrap commands, paths,+ \\and identifiers. Scale it to the change: a typo fix is one sentence, a+ \\feature is a short structured summary. Close with the next steps that+ \\genuinely exist — tests to run, follow-ups you left — and nothing more.\\Be direct and concise.++ parallel_tools_note;diff --git a/src/schema.zig b/src/schema.zigindex 8eb423a1..b9e0716f 100644--- a/src/schema.zig+++ b/src/schema.zig@@ -115,7 +115,7 @@ const base_specs = [_]ToolSpec{const meta_specs = [_]ToolSpec{.{.name = "todo_write",- .desc = "Replace the task list for the current standing goal (items from a replaced, cleared or completed goal are parked - kept in the session, but not part of this list and not replaced by this call). An item you already marked completed is kept as history when you leave it out; list it again (with any status) to change or remove it that way. Omitted pending/in_progress items are dropped. Every call needs at least one item: a call with none leaves the list untouched. Use to plan and track multi-step work. Each item has content and status (pending|in_progress|completed).",+ .desc = "Replace the task list for the current standing goal (items from a replaced, cleared or completed goal are parked - kept in the session, but not part of this list and not replaced by this call). An item you already marked completed is kept as history when you leave it out; list it again (with any status) to change or remove it that way. Omitted pending/in_progress items are dropped. Every call needs at least one item: a call with none leaves the list untouched. Use to plan and track multi-step work; skip it for trivial single-step tasks. Each item has content and status (pending|in_progress|completed). Write steps small enough to verify individually; keep exactly ONE item in_progress at a time — mark it in_progress when you start and completed as it lands, never a batch flipped at the end.",.schema =\\{"type": "object", "properties": {"todos": {"type": "array", "items": {"type": "object", "properties": {"content": {"type": "string"}, "status": {"type": "string", "enum": ["pending", "in_progress", "completed"]}}, "required": ["content", "status"]}}}, "required": ["todos"]},@@ -127,7 +127,7 @@ const meta_specs = [_]ToolSpec{},.{.name = "eval",- .desc = "Run the configured scoring command (graff --eval) alone and record the result. The HARNESS runs it and logs the score to .graff/eval-log.tsv - do not run it via bash. Returns score, best, target, and gate state. Red drops the current plan and ends the turn; repair next turn and re-evaluate. In `note`, describe the focused change and label new CONFIRMED/GUESS/HYPOTHESIS/FACT beliefs.",+ .desc = "Run the configured scoring command (graff --eval) alone and record the result. The HARNESS runs it and logs the score to .graff/eval-log.tsv - do not run it via bash. Returns score, best, target, and gate state. Red drops the current plan and grants a repair turn: make ONE focused repair, then re-evaluate before completion (a repeatedly-red eval eventually surfaces the hard stop). In `note`, describe the focused change and label new CONFIRMED/GUESS/HYPOTHESIS/FACT beliefs.",.schema =\\{"type": "object", "properties": {"note": {"type": "string", "description": "What you changed since the last eval"}}},@@ -157,9 +157,9 @@ const meta_specs = [_]ToolSpec{const subagent_spec = ToolSpec{.name = "subagent",- .desc = "Delegate a self-contained task to a subagent. It has bash, read_file, edit_file, write_file, codedb (code search), and skill (load an installed playbook); it cannot spawn further subagents and does NOT share your context — the prompt must be self-contained. Returns the subagent final report. Call several times in one response to run tasks in parallel. Pick a persona with agent (builtins: reviewer, researcher, implementer, skeptic — plus any in .harness/agents/), or give the child a custom system_prompt; the trajectory log records the lineage either way. Set run_in_background true to launch it asynchronously instead: you get the agent id back immediately and keep working, then fetch the result with agent_output. Which model this child runs on is decided in this order: model/tier given on THIS call > the chosen persona's own model:/tier: frontmatter > the session default (--subagent-model, else the default tier ladder) > the root model; within one level an exact model wins over tier. Pins are provider-local — they choose a different model on the child's current provider and never move work to another provider — and a pin that cannot be honored is ignored (the spawn still runs on the session default) rather than failing.",+ .desc = "Delegate a self-contained task to a subagent. It has bash, read_file, edit_file, write_file, codedb (code search), and skill (load an installed playbook); it cannot spawn further subagents and does NOT share your context — the prompt must be self-contained. Returns the subagent final report. Call several times in one response to run tasks in parallel. Pick a persona with agent (builtins: reviewer, researcher, implementer, skeptic — plus any in .harness/agents/), or give the child a custom system_prompt; the trajectory log records the lineage either way. Set run_in_background true to launch it asynchronously instead: you get the agent id back immediately and keep working, then fetch the result with agent_output. Which model this child runs on is decided in this order: model/tier given on THIS call > the chosen persona's own model:/tier: frontmatter > the session default (--subagent-model, else the default tier ladder) > the root model; within one level an exact model wins over tier. The child's reasoning effort is pinned the same way: effort on THIS call > the persona's effort: frontmatter > the worker default (medium) — an independent axis, so an effort-only override keeps the persona's model pin. Pins are provider-local — they choose a different model on the child's current provider and never move work to another provider — and a pin that cannot be honored is ignored (the spawn still runs on the session default) rather than failing.",.schema =- \\{"type": "object", "properties": {"description": {"type": "string", "description": "Short label for logs, 3-5 words"}, "prompt": {"type": "string", "description": "Complete, self-contained task description"}, "agent": {"type": "string", "description": "Optional: a named agent type (reviewer, researcher, implementer, skeptic, or a .harness/agents/ name) whose persona the child runs with"}, "system_prompt": {"type": "string", "description": "Optional: replace the child's system prompt with a custom one (overrides agent)"}, "model": {"type": "string", "description": "Optional: run THIS child on an exact model name available on the current provider (e.g. \"gpt-5.6-luna\"). Highest precedence — beats the persona's own pin and the session default. Ignored (spawn still runs on the session default, with a trace note) if the name is unknown, ambiguous, or not served by this provider. Never crosses providers."}, "tier": {"type": "string", "enum": ["frontier", "mid", "small"], "description": "Optional: run THIS child on a rung of the current provider's model ladder instead of an exact name — frontier (planner/judge class), mid (reviewers, implementers, researchers), small (mechanical transform/extract/label). Prefer this over model: it stays correct when the root model changes. Ignored if the provider has no ladder or no model at that rung; model wins if both are given."}, "isolation": {"type": "string", "enum": ["shared_cwd", "worktree"], "description": "Optional: \"worktree\" gives this child its own scratch git worktree (auto-removed if it finishes with no changes, kept + reported if it has any) instead of the shared working tree — use for parallel agents that edit files. Default shared_cwd (today's behavior), unless the chosen agent persona sets its own default."}, "isolation_fallback": {"type": "boolean", "description": "Optional: if isolation:\"worktree\" fails to set up (not a git repo, git error), run in the shared working tree instead of failing the spawn. Default false (fails the spawn on setup failure)."}, "run_in_background": {"type": "boolean", "description": "Optional: start this subagent asynchronously and return its agent id immediately instead of waiting for it to finish (default false). Poll status/result with agent_output (id, optional wait_ms). A spawn beyond the concurrency cap is queued, never failed."}}, "required": ["description", "prompt"]}+ \\{"type": "object", "properties": {"description": {"type": "string", "description": "Short label for logs, 3-5 words"}, "prompt": {"type": "string", "description": "Complete, self-contained task description"}, "agent": {"type": "string", "description": "Optional: a named agent type (reviewer, researcher, implementer, skeptic, or a .harness/agents/ name) whose persona the child runs with"}, "system_prompt": {"type": "string", "description": "Optional: replace the child's system prompt with a custom one (overrides agent)"}, "model": {"type": "string", "description": "Optional: run THIS child on an exact model name available on the current provider (e.g. \"gpt-5.6-luna\"). Highest precedence — beats the persona's own pin and the session default. Ignored (spawn still runs on the session default, with a trace note) if the name is unknown, ambiguous, or not served by this provider. Never crosses providers."}, "tier": {"type": "string", "enum": ["frontier", "mid", "small"], "description": "Optional: run THIS child on a rung of the current provider's model ladder instead of an exact name — frontier (planner/judge class), mid (reviewers, implementers, researchers), small (mechanical transform/extract/label). Prefer this over model: it stays correct when the root model changes. Ignored if the provider has no ladder or no model at that rung; model wins if both are given."}, "effort": {"type": "string", "enum": ["low", "medium", "high", "xhigh", "max"], "description": "Optional: reasoning effort for THIS child — beats the persona's effort: frontmatter; unpinned children run at medium. An axis independent of model/tier: an effort-only override keeps the persona's model pin. An off-vocabulary value is ignored with a trace note."}, "isolation": {"type": "string", "enum": ["shared_cwd", "worktree"], "description": "Optional: \"worktree\" gives this child its own scratch git worktree (auto-removed if it finishes with no changes, kept + reported if it has any) instead of the shared working tree — use for parallel agents that edit files. Default shared_cwd (today's behavior), unless the chosen agent persona sets its own default."}, "isolation_fallback": {"type": "boolean", "description": "Optional: if isolation:\"worktree\" fails to set up (not a git repo, git error), run in the shared working tree instead of failing the spawn. Default false (fails the spawn on setup failure)."}, "run_in_background": {"type": "boolean", "description": "Optional: start this subagent asynchronously and return its agent id immediately instead of waiting for it to finish (default false). Poll status/result with agent_output (id, optional wait_ms). A spawn beyond the concurrency cap is queued, never failed."}}, "required": ["description", "prompt"]},};diff --git a/src/startup.zig b/src/startup.zigindex 701bf00b..ad2bf950 100644--- a/src/startup.zig+++ b/src/startup.zig@@ -62,28 +62,28 @@ fn explicitProvider(model_flag: ?[]const u8) ?[]const u8 {return catalog_selection.explicitProvider(model_flag orelse return null);}-/// Whether one stored credential can affect an explicit startup selection.-/// Provider ids need one key; exact catalog model names need only providers-/// that serve that model. Aliases/fuzzy queries retain the full scan because-/// key availability participates in their tie-break.-fn storedKeyMayAffectSelection(provider_id: []const u8, model_flag: ?[]const u8) bool {+/// Whether one stored credential can affect an explicit startup selection:+/// provider ids need one key; exact catalog models need only providers that+/// serve them (aliases/fuzzy retain the full scan); --subagent-provider (worker_hint) is+/// equally explicit — that provider WILL be used. pub only for startup_tests.zig (at cap).+pub fn storedKeyMayAffectSelection(provider_id: []const u8, model_flag: ?[]const u8, worker_hint: ?[]const u8) bool {const query = model_flag orelse return true;+ if (worker_hint) |h| if (std.mem.eql(u8, provider_id, h)) return true;if (explicitProvider(query)) |id| return std.mem.eql(u8, provider_id, id);if (pricing.modelInTable(query)) return pricing.providerModelInTable(provider_id, query);return true;}fn hasSelectiveStoredKeyScope(model_flag: ?[]const u8) bool {- const query = model_flag orelse return false;- return explicitProvider(query) != null or pricing.modelInTable(query);+ return if (model_flag) |query| explicitProvider(query) != null or pricing.modelInTable(query) else false;}-fn startupStoredKeyScope(model_flag: ?[]const u8, selective: bool) keys_cli.StoredKeyScope {+pub fn startupStoredKeyScope(model_flag: ?[]const u8, selective: bool, worker_hint: ?[]const u8) keys_cli.StoredKeyScope {if (!selective) return .all;- if (explicitProvider(model_flag)) |id| return .{ .provider = id };+ if (worker_hint == null) if (explicitProvider(model_flag)) |id| return .{ .provider = id };var mask: [provider_mod.provider_specs.len]bool = @splat(false);for (provider_mod.provider_specs, 0..) |spec, i|- mask[i] = storedKeyMayAffectSelection(spec.id, model_flag);+ mask[i] = storedKeyMayAffectSelection(spec.id, model_flag, worker_hint);return .{ .mask = mask };}@@ -94,12 +94,12 @@ test "Codex catalog loads at startup only when selection can observe it" {try std.testing.expect(explicitProvider("deepseek-v4-pro") == null);try std.testing.expect(explicitProvider(null) == null);try std.testing.expect(hasSelectiveStoredKeyScope("deepseek-v4-pro"));- try std.testing.expect(storedKeyMayAffectSelection("codegraff", "deepseek-v4-pro"));- try std.testing.expect(storedKeyMayAffectSelection("deepseek", "deepseek-v4-pro"));- try std.testing.expect(!storedKeyMayAffectSelection("anthropic", "deepseek-v4-pro"));- try std.testing.expect(storedKeyMayAffectSelection("anthropic", "opus"));- try std.testing.expect(storedKeyMayAffectSelection("openai", null));- const exact_scope = startupStoredKeyScope("deepseek-v4-pro", true);+ try std.testing.expect(storedKeyMayAffectSelection("codegraff", "deepseek-v4-pro", null));+ try std.testing.expect(storedKeyMayAffectSelection("deepseek", "deepseek-v4-pro", null));+ try std.testing.expect(!storedKeyMayAffectSelection("anthropic", "deepseek-v4-pro", null));+ try std.testing.expect(storedKeyMayAffectSelection("anthropic", "opus", null));+ try std.testing.expect(storedKeyMayAffectSelection("openai", null, null));+ const exact_scope = startupStoredKeyScope("deepseek-v4-pro", true, null);try std.testing.expect(exact_scope.includes(1, "codegraff"));try std.testing.expect(exact_scope.includes(2, "deepseek"));try std.testing.expect(!exact_scope.includes(0, "anthropic"));@@ -148,7 +148,7 @@ test "Kimi catalog loads at startup only when selection can observe it" {/// former inline credential-loading block verbatim; fatals via/// std.process.fatal exactly as that block did (no key found, or a bad/// --model value).-pub fn resolveKeys(io: Io, gpa: Allocator, arena: Allocator, environ_map: anytype, model_flag: ?[]const u8) !ResolvedKeys {+pub fn resolveKeys(io: Io, gpa: Allocator, arena: Allocator, environ_map: anytype, model_flag: ?[]const u8, worker_provider_hint: ?[]const u8) !ResolvedKeys {var keys: provider_mod.Keys = .{ .values = undefined };for (provider_mod.provider_specs, &keys.values, &keys.sources) |spec, *value, *source| {value.* = environ_map.get(spec.env_key);@@ -198,13 +198,13 @@ pub fn resolveKeys(io: Io, gpa: Allocator, arena: Allocator, environ_map: anytyp// scope discipline as the stored-key load a few lines below.if (keys_cli.homeEnv(environ_map)) |home| {for (provider_mod.provider_specs, &keys.values, &keys.sources) |spec, *value, *source| {- if (std.mem.eql(u8, spec.id, "kimi") and value.* == null and storedKeyMayAffectSelection(spec.id, model_flag)) {+ if (std.mem.eql(u8, spec.id, "kimi") and value.* == null and storedKeyMayAffectSelection(spec.id, model_flag, worker_provider_hint)) {if (oauth.loadKimiOAuth(io, gpa, arena, home, false, null)) |key| {value.* = key;source.* = .login;}}- if (std.mem.eql(u8, spec.id, "xai") and value.* == null and storedKeyMayAffectSelection(spec.id, model_flag)) {+ if (std.mem.eql(u8, spec.id, "xai") and value.* == null and storedKeyMayAffectSelection(spec.id, model_flag, worker_provider_hint)) {if (oauth.loadXaiOAuth(io, gpa, arena, home, false, null)) |key| {value.* = key;source.* = .login;@@ -220,7 +220,7 @@ pub fn resolveKeys(io: Io, gpa: Allocator, arena: Allocator, environ_map: anytypvar stored_keys_loaded = !selective_stored_keys;if (keys_cli.homeEnv(environ_map)) |home| {if (selective_stored_keys) {- keys_cli.loadMissingStoredKeys(io, gpa, arena, home, &keys, startupStoredKeyScope(model_flag, true));+ keys_cli.loadMissingStoredKeys(io, gpa, arena, home, &keys, startupStoredKeyScope(model_flag, true, worker_provider_hint));// Preserve the old diagnostics/fallback behavior when none of the// selective candidates has any credential: only failed launches// pay for the exhaustive scan.@@ -306,7 +306,7 @@ pub fn resolveKeys(io: Io, gpa: Allocator, arena: Allocator, environ_map: anytyp}}}- return .{ .keys = keys, .default_provider = default_provider, .stale_saved_model = stale_saved_model, .preferred_provider = preferred_provider, .codex_account = codex_account, .model_catalog = model_catalog, .stored_keys_loaded = stored_keys_loaded };+ return .{ .keys = @import("bench_priors.zig").noteAvailability(keys), .default_provider = default_provider, .stale_saved_model = stale_saved_model, .preferred_provider = preferred_provider, .codex_account = codex_account, .model_catalog = model_catalog, .stored_keys_loaded = stored_keys_loaded };}/// Root system-prompt layering, frozen at startup so it staysdiff --git a/src/startup_tests.zig b/src/startup_tests.zigindex 451229d1..f537df35 100644--- a/src/startup_tests.zig+++ b/src/startup_tests.zig@@ -50,7 +50,23 @@ test "resolveKeys does not load Kimi/xAI OAuth credentials for an explicit unrel};const env: TestEnv = .{ .home = home };- const resolved = try resolveKeys(io, gpa, arena, env, "codegraff");+ const resolved = try resolveKeys(io, gpa, arena, env, "codegraff", null);try std.testing.expect(resolved.keys.get("kimi") == null);try std.testing.expectEqualStrings("codegraff", resolved.default_provider.id);++ // …and the mirror: an explicit --subagent-provider kimi is exactly as+ // explicit as --model, so the SAME launch shape (unrelated root provider)+ // must now load the kimi login — root sol + kimi workers used to fatal+ // "no key/login for subagent model 'k3' via 'kimi'" despite a valid+ // on-disk kimi credential, because the selective scope read only the+ // root model flag.+ const hinted = try resolveKeys(io, gpa, arena, env, "codegraff", "kimi");+ try std.testing.expectEqualStrings("kimi-test-token", hinted.keys.get("kimi").?);+ try std.testing.expectEqualStrings("codegraff", hinted.default_provider.id);++ // Scope units for the same rule (pub-flipped in startup.zig for this).+ const startup = @import("startup.zig");+ try std.testing.expect(startup.storedKeyMayAffectSelection("kimi", "gpt-5.6-sol", "kimi"));+ try std.testing.expect(!startup.storedKeyMayAffectSelection("kimi", "gpt-5.6-sol", null));+ try std.testing.expect(startup.startupStoredKeyScope("deepseek", true, "kimi").includes(6, "kimi"));}diff --git a/src/subagent.zig b/src/subagent.zigindex d0e14e4e..1f768284 100644--- a/src/subagent.zig+++ b/src/subagent.zig@@ -64,10 +64,13 @@ pub fn execSubagent(ctx: ToolCtx, input: Value) !ToolOutput {// the session default (--subagent-model / the #291 ladder). Resolved// provider-locally here so an unavailable pin degrades to the session// default with a trace note instead of failing the spawn.- const pinned = subagent_pin.forSpawn(childProvider(ctx.provider, ctx.subagent_provider, ctx.subagent_cross_provider), obj);- if (ctx.tracer) |tr| if (pinned.outcome != .none) tr.note("subagent", pinned.outcome.describe());- if (tools.json_args.flag(input, "run_in_background")) return spawnSubBackground(ctx, label, prompt, sys_override, niche, isolation, isolation_fallback, pinned.provider);- const run = try runSub(ctx, "subagent", label, prompt, sys_override, niche, isolation, isolation_fallback, pinned.provider);+ const pinned = subagent_pin.forSpawn(childProvider(ctx.provider, ctx.subagent_provider, ctx.subagent_cross_provider), obj, ctx.subagent_provider == null);+ if (ctx.tracer) |tr| {+ if (pinned.outcome != .none) tr.note("subagent", pinned.outcome.describe());+ if (pinned.effort_outcome != .none) tr.note("subagent", pinned.effort_outcome.describe());+ }+ if (tools.json_args.flag(input, "run_in_background")) return spawnSubBackground(ctx, label, prompt, sys_override, niche, isolation, isolation_fallback, pinned.provider, pinned.effort);+ const run = try runSub(ctx, "subagent", label, prompt, sys_override, niche, isolation, isolation_fallback, pinned.provider, pinned.effort);return run.output;}@@ -127,6 +130,9 @@ const AgentJob = struct {/// model catalog and the credential store, none of which are the tool/// call's arena — so unlike label/prompt it needs no gpa copy.pin: ?Provider = null,+ /// #292 follow-up: resolved per-spawn/per-persona effort pin — an enum by+ /// value, no lifetime to manage.+ effort: ?main_mod.ReasoningEffort = null,ctx: ToolCtx,admitted: bool = false,done: bool = false,@@ -197,7 +203,7 @@ fn admitNext(gpa: Allocator, io: Io) void {/// shape in jobs.zig.fn agentJobPump(job: *AgentJob, gpa: Allocator, io: Io) void {const t0: Io.Timestamp = .now(io, .awake);- const run = runSub(job.ctx, "subagent", job.label, job.prompt, job.sys_override, job.niche, job.isolation, job.isolation_fallback, job.pin) catch |err| SubRun{+ const run = runSub(job.ctx, "subagent", job.label, job.prompt, job.sys_override, job.niche, job.isolation, job.isolation_fallback, job.pin, job.effort) catch |err| SubRun{.output = failure(gpa, err),.usage = .{ .duration_ms = @intCast(@max(0, t0.untilNow(io, .awake).toMilliseconds())) },};@@ -215,7 +221,7 @@ fn agentJobPump(job: *AgentJob, gpa: Allocator, io: Io) void {/// job and return immediately with its id; the child runs on the pool./// Never blocks on a free concurrency slot — a spawn beyond the cap is/// queued, not failed; admitNext drains it once room frees up.-fn spawnSubBackground(ctx: ToolCtx, label: []const u8, prompt: []const u8, sys_override: ?[]const u8, niche: []const u8, isolation: Isolation, isolation_fallback: bool, pin: ?Provider) !ToolOutput {+fn spawnSubBackground(ctx: ToolCtx, label: []const u8, prompt: []const u8, sys_override: ?[]const u8, niche: []const u8, isolation: Isolation, isolation_fallback: bool, pin: ?Provider, effort: ?main_mod.ReasoningEffort) !ToolOutput {const gpa = ctx.gpa;const label_c = try gpa.dupe(u8, label);errdefer gpa.free(label_c);@@ -236,6 +242,7 @@ fn spawnSubBackground(ctx: ToolCtx, label: []const u8, prompt: []const u8, sys_o.isolation = isolation,.isolation_fallback = isolation_fallback,.pin = pin,+ .effort = effort,.ctx = ctx,};@@ -412,16 +419,17 @@ test "agentStatusText: composes with isolation:\"worktree\" — a kept-worktree/// `niche` is the task's MAP-Elites cell, threaded through so runSub's/// fleet:propose — and scoreVariants' submit — tag the variant's genome.pub fn workflowTask(ctx: ToolCtx, label: []const u8, prompt: []const u8, sys_override: ?[]const u8, niche: []const u8, isolation: Isolation, isolation_fallback: bool) ToolOutput {- // No #292 pin: a phase's variants must share a model or scoreVariants- // would file model effects under the prompt genome (#290).- const run = runSub(ctx, "workflow_task", label, prompt, sys_override, niche, isolation, isolation_fallback, null) catch |err| return failure(ctx.gpa, err);+ // No #292 pin (model or effort): a phase's variants must share one+ // configuration or scoreVariants would file model effects under the+ // prompt genome (#290).+ const run = runSub(ctx, "workflow_task", label, prompt, sys_override, niche, isolation, isolation_fallback, null, null) catch |err| return failure(ctx.gpa, err);return run.output;}/// A second workflow attempt has its own explicit budget kind. It still shares/// the same invocation-wide atomic ceiling and concurrency limiter.pub fn workflowRetryTask(ctx: ToolCtx, label: []const u8, prompt: []const u8, sys_override: ?[]const u8, niche: []const u8, isolation: Isolation, isolation_fallback: bool) ToolOutput {- const run = runSub(ctx, "workflow_retry", label, prompt, sys_override, niche, isolation, isolation_fallback, null) catch |err| return failure(ctx.gpa, err);+ const run = runSub(ctx, "workflow_retry", label, prompt, sys_override, niche, isolation, isolation_fallback, null, null) catch |err| return failure(ctx.gpa, err);return run.output;}@@ -431,7 +439,7 @@ pub fn workflowRetryTask(ctx: ToolCtx, label: []const u8, prompt: []const u8, sy/// on a pool thread. Never worktree-isolated: a judge only reads/reasons over/// text handed to it, never the filesystem, so there's nothing to isolate.pub fn judgeTask(ctx: ToolCtx, prompt: []const u8) ToolOutput {- const run = runSub(ctx, "judge_task", "judge", prompt, null, "", .shared_cwd, false, null) catch |err| return failure(ctx.gpa, err);+ const run = runSub(ctx, "judge_task", "judge", prompt, null, "", .shared_cwd, false, null, null) catch |err| return failure(ctx.gpa, err);return run.output;}diff --git a/src/subagent_pin.zig b/src/subagent_pin.zigindex a6c2d149..6e18562b 100644--- a/src/subagent_pin.zig+++ b/src/subagent_pin.zig@@ -11,6 +11,17 @@//! into AgentType.model/.tier; resolved here.//! 2. One `subagent` call may pin `model` / `tier` for that spawn only.//!+//! The same two grains can pin reasoning EFFORT — frontmatter `effort: max`+//! or an `effort` param on the call (low|medium|high|xhigh|max — the /effort+//! vocabulary minus `ultra`, which is the ultracode prompt switch, not a+//! depth a worker should inherit). Effort is an INDEPENDENT AXIS from+//! model/tier: each falls through spawn → persona → session default on its+//! own, so an effort-only override keeps the persona's model pin (and vice+//! versa). Unlike a model pin it needs no catalog resolution — a model that+//! rejects reasoning_effort already degrades per request (effort_rejected in+//! agent_request.zig) — so an effort pin is either applied as stated or+//! reported off-vocabulary, never provider-dependent.+//!//! PRECEDENCE (what the tool schema advertises, implemented by `requested`//! and `resolve` below)://!@@ -48,12 +59,18 @@ const std = @import("std");const provider_mod = @import("provider.zig");const Provider = provider_mod.Provider;+const pricing = @import("pricing.zig");+const bench_priors = @import("bench_priors.zig");const fleet = @import("fleet.zig");const selection = @import("subagent_selection.zig");const tier_ladder = @import("subagent_tier_ladder.zig");pub const Tier = tier_ladder.Tier;+/// Worker reasoning depth (main.zig's ReasoningEffort) — pinnable per persona+/// or per spawn since the #292 follow-up; parsed by `parseEffort` below.+pub const Effort = @import("main.zig").ReasoningEffort;+/// A requested pin, before it has been checked against any catalog. All/// fields at their defaults means "no opinion" — keep the session default.pub const Pin = struct {@@ -64,9 +81,13 @@ pub const Pin = struct {/// distinct from "no tier" so a typo is reported rather than silently/// falling through to a persona pin the caller was trying to override.bad_tier: bool = false,+ /// Reasoning-effort pin — an axis of its own (see module doc), with the+ /// same typo discipline as `bad_tier`.+ effort: ?Effort = null,+ bad_effort: bool = false,pub fn isNone(self: Pin) bool {- return self.model == null and self.tier == null and !self.bad_tier;+ return self.model == null and self.tier == null and !self.bad_tier and self.effort == null and !self.bad_effort;}};@@ -81,6 +102,8 @@ pub const Outcome = enum {unknown_tier, // `tier` was not one of frontier/mid/smallno_ladder, // this provider has no tier ladderno_rung, // the ladder has no model at that rung+ rung_pricier, // the rung would cost more than the child's current model+ sub_routed, // the rung went to a logged-in flat-rate subscription insteadpub fn describe(self: Outcome) []const u8 {return switch (self) {@@ -91,12 +114,31 @@ pub const Outcome = enum {.unknown_tier => "tier pin ignored: expected frontier, mid or small — kept the session default",.no_ladder => "tier pin ignored: this provider has no tier ladder — kept the session default",.no_rung => "tier pin ignored: this provider's ladder has no model at that rung — kept the session default",+ .rung_pricier => "tier pin ignored: that rung is pricier than this agent's model — cost never escalates implicitly; pin the model by name to escalate",+ .sub_routed => "tier routed to a logged-in flat-rate subscription — marginal cost zero outranks metered spend; the login is the user's standing consent for that vendor",};}};-/// `provider == null` means the spawn keeps whatever it already had.-pub const Resolved = struct { provider: ?Provider = null, outcome: Outcome = .none };+/// The effort half of Outcome — its own enum because the axes resolve+/// independently and one spawn may need a note about each.+pub const EffortOutcome = enum {+ none,+ pinned,+ unknown_effort,++ pub fn describe(self: EffortOutcome) []const u8 {+ return switch (self) {+ .none => "",+ .pinned => "effort pin applied",+ .unknown_effort => "effort pin ignored: expected low, medium, high, xhigh or max — kept the session default",+ };+ }+};++/// `provider == null` means the spawn keeps whatever it already had; `effort+/// == null` likewise (the worker default, not the root's /effort).+pub const Resolved = struct { provider: ?Provider = null, outcome: Outcome = .none, effort: ?Effort = null, effort_outcome: EffortOutcome = .none };fn trimmed(v: std.json.Value) ?[]const u8 {if (v != .string) return null;@@ -104,21 +146,35 @@ fn trimmed(v: std.json.Value) ?[]const u8 {return if (s.len == 0) null else s;}+/// The `effort` pin vocabulary: /effort's levels minus `ultra`, which is the+/// ultracode prompt switch rather than a reasoning depth a delegated worker+/// should inherit. Off-vocabulary parses to null — the caller decides whether+/// that is "no opinion" (a frontmatter load) or a reportable typo (a spawn's+/// stated override).+pub fn parseEffort(s: []const u8) ?Effort {+ const e = std.meta.stringToEnum(Effort, s) orelse return null;+ return if (e == .ultra) null else e;+}+/// The persona's own pin, if `name` matches a loaded agent type. An unknown/// name is "no opinion", matching resolveOverride/resolveIsolation's/// never-fail-a-spawn-on-a-typo contract.pub fn personaPin(name: []const u8) Pin {if (name.len == 0) return .{};for (fleet.g_agent_types) |t| {- if (std.mem.eql(u8, t.name, name)) return .{ .model = t.model, .tier = t.tier };+ if (std.mem.eql(u8, t.name, name)) return .{ .model = t.model, .tier = t.tier, .effort = t.effort };}return .{};}/// The pin for one spawn, applying the cross-level half of the precedence-/// rule: an explicit `model`/`tier` on the call replaces the persona's pin-/// wholesale (it does not merge with it), and only a call that states neither-/// falls through to the persona.+/// rule PER AXIS: an explicit `model`/`tier` on the call replaces the+/// persona's model pin wholesale (it does not merge with it), an explicit+/// `effort` replaces the persona's effort, and each axis the call leaves+/// unstated falls through to the persona on its own — so an effort-only+/// override keeps the persona's model pin, and vice versa. A stated typo+/// (`bad_tier`/`bad_effort`) blocks that axis's fallthrough: the caller was+/// trying to override, and a silent substitution would hide it.pub fn requested(obj: std.json.ObjectMap) Pin {var call: Pin = .{};if (obj.get("model")) |v| call.model = trimmed(v);@@ -126,9 +182,20 @@ pub fn requested(obj: std.json.ObjectMap) Pin {call.tier = Tier.parse(raw);call.bad_tier = call.tier == null;};- if (!call.isNone()) return call;- if (obj.get("agent")) |v| if (v == .string) return personaPin(v.string);- return .{};+ if (obj.get("effort")) |v| if (trimmed(v)) |raw| {+ call.effort = parseEffort(raw);+ call.bad_effort = call.effort == null;+ };+ const persona: Pin = blk: {+ const v = obj.get("agent") orelse break :blk .{};+ break :blk if (v == .string) personaPin(v.string) else .{};+ };+ if (call.model == null and call.tier == null and !call.bad_tier) {+ call.model = persona.model;+ call.tier = persona.tier;+ }+ if (call.effort == null and !call.bad_effort) call.effort = persona.effort;+ return call;}/// Resolve `pin` against `base` — the provider the child would otherwise use.@@ -143,12 +210,62 @@ pub fn resolve(base: Provider, pin: Pin) Resolved {// models refresh` can drop a model the compiled ladder names, and a// pin resolving to a model the provider no longer serves must fall// back rather than send a request that 404s mid-fleet.- return finish(base, selection.modelForProvider(base.id, rung));+ const resolved = selection.modelForProvider(base.id, rung) orelse return .{ .outcome = .unknown_model };+ // COST CEILING: a tier rung may DESCEND price, never raise it — on a+ // multi-vendor catalog (the codegraff gateway serves everything up to+ // opus-class) an automatic rung must not spend more than the model+ // the user chose. Escalation stays possible, but only by naming the+ // model in the call — visible, never implicit.+ if (!rungAffordable(base.model, resolved)) return .{ .outcome = .rung_pricier };+ return finish(base, resolved);}if (pin.bad_tier) return .{ .outcome = .unknown_tier };return .{};}+/// Flat-rate, device-login subscription providers, in fallback preference+/// order (bench scores rank them when several are logged in). codegraff's+/// license is deliberately absent: it fronts the metered multi-vendor+/// gateway this policy protects the user's wallet FROM.+const subscription_providers = [_][]const u8{ "codex", "kimi" };++/// SUB-FIRST TIER ROUTING (explicit `tier` asks only — the silent no-tier+/// default still inherits the user's chosen family): a logged-in flat-rate+/// subscription is marginal-cost-zero, so its rung outranks ANY metered+/// model — a deepseek session's tier:"small" goes to luna on the codex sub,+/// not to a metered gateway row — and the login itself is the user's+/// standing consent for that vendor. Metered cross-provider routing keeps+/// the explicit --subagent-provider + --allow-cross-provider-subagents bar.+/// When several subs serve the rung, the bench sheet's score picks.+fn subscriptionRung(tier: Tier, base: Provider) ?Resolved {+ const keys = bench_priors.g_keys orelse return null;+ var best: ?Resolved = null;+ var best_score: f64 = -1;+ for (subscription_providers) |sid| {+ if (std.mem.eql(u8, sid, base.id)) continue; // the base's own ladder handles it provider-locally+ const ladder = tier_ladder.forProvider(sid) orelse continue;+ const rung = ladder.modelFor(tier) orelse continue;+ const resolved = selection.modelForProvider(sid, rung) orelse continue;+ const prov = keys.providerById(sid, resolved) catch continue; // not logged in → not a candidate+ const s = bench_priors.scoreFor(sid, resolved) orelse 0;+ if (best == null or s > best_score) {+ best = .{ .provider = prov, .outcome = .sub_routed };+ best_score = s;+ }+ }+ return best;+}++/// Summed in+out $/1M. An unpriced BASE has no ceiling to enforce (whole+/// subscription families like codex carry no per-token price — blocking+/// there would kill every intra-family rung); a priced base with an unpriced+/// rung cannot prove the rung is not an escalation, so it blocks.+pub fn rungAffordable(base_model: []const u8, rung_model: []const u8) bool {+ const bp = pricing.priceFor(base_model) orelse return true;+ const rp = pricing.priceFor(rung_model) orelse return false;+ return rp.in + rp.out <= bp.in + bp.out;+}+fn finish(base: Provider, name: ?[]const u8) Resolved {const resolved = name orelse return .{ .outcome = .unknown_model };if (std.mem.eql(u8, resolved, base.model)) return .{ .outcome = .same };@@ -156,16 +273,28 @@ fn finish(base: Provider, name: ?[]const u8) Resolved {}/// The whole chain for one spawn: read the pin off the call (or its persona),-/// then resolve it provider-locally against `base`.-pub fn forSpawn(base: Provider, obj: std.json.ObjectMap) Resolved {+/// route an explicit tier to a logged-in subscription when one serves it+/// better (subscriptionRung; `sub_ok` false = the session pinned workers+/// with --subagent-provider, an explicit human choice no auto-route may+/// override), else resolve the model axis provider-locally against `base`;+/// the effort axis rides through verbatim (it needs no catalog).+pub fn forSpawn(base: Provider, obj: std.json.ObjectMap, sub_ok: bool) Resolved {const pin = requested(obj);if (pin.isNone()) return .{};- return resolve(base, pin);+ var out: Resolved = blk: {+ if (sub_ok and pin.model == null) if (pin.tier) |t| if (subscriptionRung(t, base)) |r| break :blk r;+ break :blk resolve(base, pin);+ };+ if (pin.effort) |e| {+ out.effort = e;+ out.effort_outcome = .pinned;+ } else if (pin.bad_effort) out.effort_outcome = .unknown_effort;+ return out;}/// The live persona's OPERATIONAL frontmatter lines — isolation plus #292's-/// model/tier — arena-allocated and newline-terminated, or "" when it has-/// none.+/// model/tier/effort — arena-allocated and newline-terminated, or "" when it+/// has none.////// Promotion (fleet.promoteAgents) replaces a niche's genome with a better/// scoring one, and rewrites `<niche>.md` from scratch to do it. Without this@@ -180,7 +309,8 @@ pub fn personaPolicyFrontmatter(arena: std.mem.Allocator, name: []const u8) []coconst iso = if (t.isolation) |i| std.fmt.allocPrint(arena, "isolation: {s}\n", .{@tagName(i)}) catch "" else "";const mdl = if (t.model) |m| std.fmt.allocPrint(arena, "model: {s}\n", .{m}) catch "" else "";const rung = if (t.tier) |x| std.fmt.allocPrint(arena, "tier: {s}\n", .{x.label()}) catch "" else "";- return std.fmt.allocPrint(arena, "{s}{s}{s}", .{ iso, mdl, rung }) catch "";+ const eff = if (t.effort) |e| std.fmt.allocPrint(arena, "effort: {s}\n", .{@tagName(e)}) catch "" else "";+ return std.fmt.allocPrint(arena, "{s}{s}{s}{s}", .{ iso, mdl, rung, eff }) catch "";}return "";}diff --git a/src/subagent_pin_tests.zig b/src/subagent_pin_tests.zigindex bf2d3e8d..539c63d6 100644--- a/src/subagent_pin_tests.zig+++ b/src/subagent_pin_tests.zig@@ -54,10 +54,10 @@ test "persona frontmatter parse: model/tier land on AgentType, a bad tier is drotry std.testing.expect(pin_mod.personaPin("").isNone());// …and the pin reaches a spawn that only names the persona.- try std.testing.expectEqualStrings("gpt-5.6-terra", pin_mod.forSpawn(codexBase(), obj(a, "{\"agent\":\"implementer\"}")).provider.?.model);- try std.testing.expectEqualStrings("gpt-5.6-terra", pin_mod.forSpawn(codexBase(), obj(a, "{\"agent\":\"reviewer\"}")).provider.?.model);- try std.testing.expect(pin_mod.forSpawn(codexBase(), obj(a, "{\"agent\":\"typo\"}")).provider == null);- try std.testing.expect(pin_mod.forSpawn(codexBase(), obj(a, "{\"agent\":\"plain\"}")).provider == null);+ try std.testing.expectEqualStrings("gpt-5.6-terra", pin_mod.forSpawn(codexBase(), obj(a, "{\"agent\":\"implementer\"}"), true).provider.?.model);+ try std.testing.expectEqualStrings("gpt-5.6-terra", pin_mod.forSpawn(codexBase(), obj(a, "{\"agent\":\"reviewer\"}"), true).provider.?.model);+ try std.testing.expect(pin_mod.forSpawn(codexBase(), obj(a, "{\"agent\":\"typo\"}"), true).provider == null);+ try std.testing.expect(pin_mod.forSpawn(codexBase(), obj(a, "{\"agent\":\"plain\"}"), true).provider == null);}test "spawn override resolution: exact name, alias, ladder rung, and no-op" {@@ -67,7 +67,7 @@ test "spawn override resolution: exact name, alias, ladder rung, and no-op" {const base = codexBase();// Exact catalog name.- const exact = pin_mod.forSpawn(base, obj(a, "{\"model\":\"gpt-5.6-luna\"}"));+ const exact = pin_mod.forSpawn(base, obj(a, "{\"model\":\"gpt-5.6-luna\"}"), true);try std.testing.expectEqual(pin_mod.Outcome.pinned, exact.outcome);try std.testing.expectEqualStrings("gpt-5.6-luna", exact.provider.?.model);try std.testing.expectEqualStrings("codex", exact.provider.?.id); // provider-local, always@@ -76,22 +76,22 @@ test "spawn override resolution: exact name, alias, ladder rung, and no-op" {try std.testing.expect(exact.provider.?.context != 0);// Abbreviation: the same resolver --subagent-model uses (unique substring).- const alias = pin_mod.forSpawn(base, obj(a, "{\"model\":\" 5.6-terra \"}")); // whitespace trimmed+ const alias = pin_mod.forSpawn(base, obj(a, "{\"model\":\" 5.6-terra \"}"), true); // whitespace trimmedtry std.testing.expectEqualStrings("gpt-5.6-terra", alias.provider.?.model);// Ladder rung instead of a name.- const rung = pin_mod.forSpawn(base, obj(a, "{\"tier\":\"small\"}"));+ const rung = pin_mod.forSpawn(base, obj(a, "{\"tier\":\"small\"}"), true);try std.testing.expectEqual(pin_mod.Outcome.pinned, rung.outcome);try std.testing.expectEqualStrings("gpt-5.6-luna", rung.provider.?.model);- try std.testing.expectEqualStrings("gpt-5.6-terra", pin_mod.forSpawn(base, obj(a, "{\"tier\":\"mid\"}")).provider.?.model);+ try std.testing.expectEqualStrings("gpt-5.6-terra", pin_mod.forSpawn(base, obj(a, "{\"tier\":\"mid\"}"), true).provider.?.model);// A pin naming the model the child already has changes nothing, and says so.- const same = pin_mod.forSpawn(base, obj(a, "{\"tier\":\"frontier\"}"));+ const same = pin_mod.forSpawn(base, obj(a, "{\"tier\":\"frontier\"}"), true);try std.testing.expectEqual(pin_mod.Outcome.same, same.outcome);try std.testing.expect(same.provider == null);// No pin at all: untouched, and cheap — nothing is resolved.- const none = pin_mod.forSpawn(base, obj(a, "{\"description\":\"x\",\"prompt\":\"y\"}"));+ const none = pin_mod.forSpawn(base, obj(a, "{\"description\":\"x\",\"prompt\":\"y\"}"), true);try std.testing.expectEqual(pin_mod.Outcome.none, none.outcome);try std.testing.expect(none.provider == null);}@@ -117,26 +117,26 @@ test "precedence: spawn param > persona pin > session default" {// which is the case a merge-instead-of-replace rule would break.try std.testing.expectEqualStrings("gpt-5.6-luna",- pin_mod.forSpawn(session_default, obj(a, "{\"agent\":\"pinned-frontier\",\"tier\":\"small\"}")).provider.?.model,+ pin_mod.forSpawn(session_default, obj(a, "{\"agent\":\"pinned-frontier\",\"tier\":\"small\"}"), true).provider.?.model,);try std.testing.expectEqualStrings("gpt-5.6-sol",- pin_mod.forSpawn(session_default, obj(a, "{\"agent\":\"pinned-mid\",\"model\":\"gpt-5.6-sol\"}")).provider.?.model,+ pin_mod.forSpawn(session_default, obj(a, "{\"agent\":\"pinned-mid\",\"model\":\"gpt-5.6-sol\"}"), true).provider.?.model,);// 2. No spawn param → the persona's pin applies over the session default.try std.testing.expectEqualStrings("gpt-5.6-sol",- pin_mod.forSpawn(session_default, obj(a, "{\"agent\":\"pinned-frontier\"}")).provider.?.model,+ pin_mod.forSpawn(session_default, obj(a, "{\"agent\":\"pinned-frontier\"}"), true).provider.?.model,);// 3. Neither → the session default is kept untouched.- try std.testing.expect(pin_mod.forSpawn(session_default, obj(a, "{\"prompt\":\"y\"}")).provider == null);+ try std.testing.expect(pin_mod.forSpawn(session_default, obj(a, "{\"prompt\":\"y\"}"), true).provider == null);// Within one level, an exact model beats a tier (both on the call…try std.testing.expectEqualStrings("gpt-5.6-sol",- pin_mod.forSpawn(session_default, obj(a, "{\"model\":\"gpt-5.6-sol\",\"tier\":\"small\"}")).provider.?.model,+ pin_mod.forSpawn(session_default, obj(a, "{\"model\":\"gpt-5.6-sol\",\"tier\":\"small\"}"), true).provider.?.model,);// …and both on the persona).- try std.testing.expectEqual(pin_mod.Outcome.same, pin_mod.forSpawn(session_default, obj(a, "{\"agent\":\"both\"}")).outcome);+ try std.testing.expectEqual(pin_mod.Outcome.same, pin_mod.forSpawn(session_default, obj(a, "{\"agent\":\"both\"}"), true).outcome);}test "graceful fallback: every unhonorable pin keeps the session default, never fails" {@@ -161,7 +161,7 @@ test "graceful fallback: every unhonorable pin keeps the session default, never.{ .args = "{\"model\":42}", .want = .none },.{ .args = "{\"model\":\" \"}", .want = .none },}) |case| {- const got = pin_mod.forSpawn(base, obj(a, case.args));+ const got = pin_mod.forSpawn(base, obj(a, case.args), true);try std.testing.expectEqual(case.want, got.outcome);try std.testing.expect(got.provider == null); // the spawn still runs// Every non-honored outcome carries a reason for the trace.@@ -170,12 +170,67 @@ test "graceful fallback: every unhonorable pin keeps the session default, never// A provider with no ladder at all: a tier pin is a no-op, not a crash.const xai: Provider = .{ .id = "xai", .kind = .openai, .auth = .bearer, .url = "", .api_key = "k", .model = "grok-4.3", .context = 256_000 };- try std.testing.expectEqual(pin_mod.Outcome.no_ladder, pin_mod.forSpawn(xai, obj(a, "{\"tier\":\"small\"}")).outcome);+ try std.testing.expectEqual(pin_mod.Outcome.no_ladder, pin_mod.forSpawn(xai, obj(a, "{\"tier\":\"small\"}"), true).outcome);// A ladder without that rung (deepseek has no `small`) — never rounds to// the nearest rung.const deepseek: Provider = .{ .id = "deepseek", .kind = .openai, .auth = .bearer, .url = "", .api_key = "k", .model = "deepseek-v4-pro", .context = 128_000 };- try std.testing.expectEqual(pin_mod.Outcome.no_rung, pin_mod.forSpawn(deepseek, obj(a, "{\"tier\":\"small\"}")).outcome);- try std.testing.expectEqualStrings("deepseek-v4-flash", pin_mod.forSpawn(deepseek, obj(a, "{\"tier\":\"mid\"}")).provider.?.model);+ try std.testing.expectEqual(pin_mod.Outcome.no_rung, pin_mod.forSpawn(deepseek, obj(a, "{\"tier\":\"small\"}"), true).outcome);+ try std.testing.expectEqualStrings("deepseek-v4-flash", pin_mod.forSpawn(deepseek, obj(a, "{\"tier\":\"mid\"}"), true).provider.?.model);+}++test "cost ceiling: a tier rung may descend price but never raise it" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();+ // deepseek's compiled ladder: frontier deepseek-v4-pro ($0.435/0.87),+ // mid deepseek-v4-flash ($0.14/0.28). Descending is fine…+ const pro: Provider = .{ .id = "deepseek", .kind = .openai, .auth = .bearer, .url = "", .api_key = "k", .model = "deepseek-v4-pro", .context = 128_000 };+ try std.testing.expectEqualStrings("deepseek-v4-flash", pin_mod.forSpawn(pro, obj(a, "{\"tier\":\"mid\"}"), true).provider.?.model);+ // …but a flash root asking for the frontier rung would RAISE cost —+ // blocked with a reason, spawn keeps the session default. Naming the+ // model explicitly still escalates: that is the visible, consented path.+ const flash: Provider = .{ .id = "deepseek", .kind = .openai, .auth = .bearer, .url = "", .api_key = "k", .model = "deepseek-v4-flash", .context = 128_000 };+ const blocked = pin_mod.forSpawn(flash, obj(a, "{\"tier\":\"frontier\"}"), true);+ try std.testing.expectEqual(pin_mod.Outcome.rung_pricier, blocked.outcome);+ try std.testing.expect(blocked.provider == null);+ try std.testing.expect(blocked.outcome.describe().len > 0);+ try std.testing.expectEqualStrings("deepseek-v4-pro", pin_mod.forSpawn(flash, obj(a, "{\"model\":\"deepseek-v4-pro\"}"), true).provider.?.model);+ // The affordability rule itself: unpriced base has no ceiling; a priced+ // base blocks an unpriced rung (it cannot prove it is not an escalation).+ try std.testing.expect(pin_mod.rungAffordable("model-with-no-price-anywhere", "deepseek-v4-pro"));+ try std.testing.expect(!pin_mod.rungAffordable("deepseek-v4-flash", "model-with-no-price-anywhere"));+}++test "sub-first routing: a logged-in flat-rate sub outranks metered for explicit tier asks" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();+ const bench = @import("bench_priors.zig");+ const saved = bench.g_keys;+ defer bench.g_keys = saved;+ var keys: provider_mod.Keys = .{ .values = @splat(null) };+ for (provider_mod.provider_specs, 0..) |spec, i| {+ if (std.mem.eql(u8, spec.id, "codex")) keys.values[i] = "tok";+ }+ bench.g_keys = &keys;+ // A deepseek session asking tier:"small": the codex sub is logged in and+ // luna is the better pick — of course it goes to luna, on the sub.+ const dsv: Provider = .{ .id = "deepseek", .kind = .openai, .auth = .bearer, .url = "", .api_key = "k", .model = "deepseek-v4-pro", .context = 128_000 };+ const routed = pin_mod.forSpawn(dsv, obj(a, "{\"tier\":\"small\"}"), true);+ try std.testing.expectEqual(pin_mod.Outcome.sub_routed, routed.outcome);+ try std.testing.expectEqualStrings("codex", routed.provider.?.id);+ try std.testing.expectEqualStrings("gpt-5.6-luna", routed.provider.?.model);+ try std.testing.expect(routed.outcome.describe().len > 0);+ // An explicit --subagent-provider (sub_ok=false) is a human choice no+ // auto-route may override: back to the provider-local path (deepseek has+ // no small rung → no_rung, session default kept).+ try std.testing.expectEqual(pin_mod.Outcome.no_rung, pin_mod.forSpawn(dsv, obj(a, "{\"tier\":\"small\"}"), false).outcome);+ // Explicit model pins stay provider-local — naming a model is a statement+ // about THIS provider, never a silent hop.+ try std.testing.expectEqual(pin_mod.Outcome.unknown_model, pin_mod.forSpawn(dsv, obj(a, "{\"model\":\"gpt-5.6-luna\"}"), true).outcome);+ // No login (g_keys null) → no candidates → the metered ceiling rules.+ bench.g_keys = null;+ try std.testing.expectEqual(pin_mod.Outcome.no_rung, pin_mod.forSpawn(dsv, obj(a, "{\"tier\":\"small\"}"), true).outcome);}test "a pin never crosses a provider boundary" {@@ -193,7 +248,7 @@ test "a pin never crosses a provider boundary" {};for (bases) |base| {for ([_][]const u8{ "{\"tier\":\"mid\"}", "{\"tier\":\"small\"}", "{\"model\":\"gpt-5.6-luna\"}", "{\"model\":\"claude-haiku-4-5\"}" }) |args| {- const got = pin_mod.forSpawn(base, obj(a, args));+ const got = pin_mod.forSpawn(base, obj(a, args), true);const p = got.provider orelse continue;try std.testing.expectEqualStrings(base.id, p.id);try std.testing.expectEqualStrings(base.api_key, p.api_key);@@ -211,6 +266,7 @@ test "promotion carries a persona's model/tier policy, and it round-trips" {fleet.g_agent_types = &.{.{ .name = "worker", .desc = "", .prompt = "old genome", .isolation = .worktree, .tier = .mid },.{ .name = "exact", .desc = "", .prompt = "old genome", .model = "gpt-5.6-luna" },+ .{ .name = "luna-max", .desc = "", .prompt = "old genome", .model = "gpt-5.6-luna", .effort = .max },.{ .name = "bare", .desc = "", .prompt = "old genome" },};@@ -222,6 +278,16 @@ test "promotion carries a persona's model/tier policy, and it round-trips" {const policy = pin_mod.personaPolicyFrontmatter(a, "worker");try std.testing.expectEqualStrings("isolation: worktree\ntier: mid\n", policy);try std.testing.expectEqualStrings("model: gpt-5.6-luna\n", pin_mod.personaPolicyFrontmatter(a, "exact"));+ // #292 follow-up: the effort pin is policy too — promote must not un-pin+ // it, and the emitted line round-trips through the loader's parse.+ try std.testing.expectEqualStrings("model: gpt-5.6-luna\neffort: max\n", pin_mod.personaPolicyFrontmatter(a, "luna-max"));+ var round_eff: ?pin_mod.Effort = null;+ var eff_lines = std.mem.tokenizeScalar(u8, pin_mod.personaPolicyFrontmatter(a, "luna-max"), '\n');+ while (eff_lines.next()) |ln| {+ const sep = std.mem.indexOfScalar(u8, ln, ':') orelse continue;+ if (std.mem.eql(u8, std.mem.trim(u8, ln[0..sep], " \t"), "effort")) round_eff = pin_mod.parseEffort(std.mem.trim(u8, ln[sep + 1 ..], " \t\""));+ }+ try std.testing.expectEqual(pin_mod.Effort.max, round_eff.?);// The emitted lines are exactly what the loader parses back — spliced// into a promoted file, `tier: mid` must survive as Tier.mid, so a@@ -264,3 +330,79 @@ test "withModel: rebuilds the model-derived fields, keeps the credential (#292)"try std.testing.expectEqualStrings("m2", alien.withModel("m2").model);try std.testing.expectEqualStrings("u", alien.withModel("m2").url);}++test "effort pin: spawn param, persona frontmatter, and axis independence (#292 follow-up)" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();+ const base = codexBase();++ const saved = fleet.g_agent_types;+ defer fleet.g_agent_types = saved;+ fleet.g_agent_types = &.{+ // The tweet-shaped persona: an exact model AND a depth — "Luna Max".+ .{ .name = "luna-worker", .desc = "", .prompt = "x", .model = "gpt-5.6-luna", .effort = .max },+ .{ .name = "thinker", .desc = "", .prompt = "x", .effort = .xhigh },+ };++ // Persona effort reaches a spawn that only names the persona, riding+ // alongside the persona's model pin.+ const luna = pin_mod.forSpawn(base, obj(a, "{\"agent\":\"luna-worker\"}"), true);+ try std.testing.expectEqualStrings("gpt-5.6-luna", luna.provider.?.model);+ try std.testing.expectEqual(pin_mod.Effort.max, luna.effort.?);+ try std.testing.expectEqual(pin_mod.EffortOutcome.pinned, luna.effort_outcome);++ // A spawn's effort beats the persona's, in BOTH directions.+ try std.testing.expectEqual(pin_mod.Effort.low, pin_mod.forSpawn(base, obj(a, "{\"agent\":\"thinker\",\"effort\":\"low\"}"), true).effort.?);+ try std.testing.expectEqual(pin_mod.Effort.max, pin_mod.forSpawn(base, obj(a, "{\"agent\":\"thinker\",\"effort\":\"max\"}"), true).effort.?);++ // AXIS INDEPENDENCE — an effort-only call keeps the persona's model pin…+ const eff_only = pin_mod.forSpawn(base, obj(a, "{\"agent\":\"luna-worker\",\"effort\":\"high\"}"), true);+ try std.testing.expectEqualStrings("gpt-5.6-luna", eff_only.provider.?.model);+ try std.testing.expectEqual(pin_mod.Effort.high, eff_only.effort.?);+ // …and a model-only call keeps the persona's effort.+ const mdl_only = pin_mod.forSpawn(base, obj(a, "{\"agent\":\"luna-worker\",\"model\":\"gpt-5.6-terra\"}"), true);+ try std.testing.expectEqualStrings("gpt-5.6-terra", mdl_only.provider.?.model);+ try std.testing.expectEqual(pin_mod.Effort.max, mdl_only.effort.?);++ // An effort pin alone never touches the model: provider stays null.+ const bare = pin_mod.forSpawn(base, obj(a, "{\"effort\":\"xhigh\"}"), true);+ try std.testing.expect(bare.provider == null);+ try std.testing.expectEqual(pin_mod.Outcome.none, bare.outcome);+ try std.testing.expectEqual(pin_mod.Effort.xhigh, bare.effort.?);+}++test "effort pin: off-vocabulary (incl. ultra) is reported and never guessed" {+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();+ const base = codexBase();++ // `ultra` is /effort's ultracode prompt switch, not a worker depth — a+ // persona/spawn cannot pin it; the vocabulary is case-exact like tier's.+ for ([_][]const u8{ "{\"effort\":\"ultra\"}", "{\"effort\":\"Max\"}", "{\"effort\":\"extreme\"}" }) |args| {+ const got = pin_mod.forSpawn(base, obj(a, args), true);+ try std.testing.expectEqual(pin_mod.EffortOutcome.unknown_effort, got.effort_outcome);+ try std.testing.expect(got.effort == null); // the spawn still runs, at the default+ try std.testing.expect(got.effort_outcome.describe().len > 0);+ }++ // A stated typo does NOT fall through to the persona's effort — the+ // caller was overriding, and a silent substitution would hide the typo.+ const saved = fleet.g_agent_types;+ defer fleet.g_agent_types = saved;+ fleet.g_agent_types = &.{.{ .name = "thinker", .desc = "", .prompt = "x", .effort = .xhigh }};+ const typo = pin_mod.forSpawn(base, obj(a, "{\"agent\":\"thinker\",\"effort\":\"woops\"}"), true);+ try std.testing.expect(typo.effort == null);+ try std.testing.expectEqual(pin_mod.EffortOutcome.unknown_effort, typo.effort_outcome);++ // Non-string / blank values are simply not a pin.+ try std.testing.expectEqual(pin_mod.EffortOutcome.none, pin_mod.forSpawn(base, obj(a, "{\"effort\":42}"), true).effort_outcome);+ try std.testing.expectEqual(pin_mod.EffortOutcome.none, pin_mod.forSpawn(base, obj(a, "{\"effort\":\" \"}"), true).effort_outcome);++ // The parse contract loadAgentDir relies on.+ try std.testing.expectEqual(pin_mod.Effort.max, pin_mod.parseEffort("max").?);+ try std.testing.expectEqual(pin_mod.Effort.xhigh, pin_mod.parseEffort("xhigh").?);+ try std.testing.expect(pin_mod.parseEffort("ultra") == null);+ try std.testing.expect(pin_mod.parseEffort("") == null);+}diff --git a/src/subagent_run.zig b/src/subagent_run.zigindex e7de5d1b..3dbd3138 100644--- a/src/subagent_run.zig+++ b/src/subagent_run.zig@@ -192,7 +192,11 @@ pub const SubRun = struct { output: ToolOutput, usage: AgentUsage };/// deliberately a resolved Provider rather than a name: resolution (catalog/// lookup, graceful fallback, provider locality) happens once at the call/// site, so nothing here can fail a spawn on an unavailable pin.-pub fn runSub(ctx: ToolCtx, kind: []const u8, label: []const u8, prompt: []const u8, sys_override: ?[]const u8, niche: []const u8, isolation: Isolation, isolation_fallback: bool, pin: ?Provider) !SubRun {+///+/// `effort` is the same story on the reasoning axis (#292 follow-up):+/// forSpawn's resolved per-spawn/per-persona depth; null keeps the worker+/// default (medium — a child never inherits the root's /effort implicitly).+pub fn runSub(ctx: ToolCtx, kind: []const u8, label: []const u8, prompt: []const u8, sys_override: ?[]const u8, niche: []const u8, isolation: Isolation, isolation_fallback: bool, pin: ?Provider, effort: ?main_mod.ReasoningEffort) !SubRun {const gpa = ctx.gpa;if (ctx.run_budget) |budget| if (ctx.depth >= budget.max_depth) return .{.output = .{@@ -232,6 +236,7 @@ pub fn runSub(ctx: ToolCtx, kind: []const u8, label: []const u8, prompt: []constelse.child,.sys_override = sys_override,+ .reasoning = effort orelse .medium, // #292 follow-up: effort pin; unpinned workers keep the default depth, not the root's /effort};const sub_start = Io.Timestamp.now(ctx.io, .awake);if (sys_override) |so| if (telemetry.g_telem) |t| {diff --git a/src/subagent_tier_ladder.zig b/src/subagent_tier_ladder.zigindex c9d2d170..2b7ad1ac 100644--- a/src/subagent_tier_ladder.zig+++ b/src/subagent_tier_ladder.zig@@ -68,9 +68,12 @@ pub const ladders = [_]TierLadder{.{ .provider = "deepseek", .frontier = "deepseek-v4-pro", .mid = "deepseek-v4-flash" },};-/// The ladder row for a provider, if any. A provider absent from `ladders`-/// has no default tiering — every root on it always inherits.+/// The ladder row for a provider, if any. A bench-derived ladder (a+/// .harness/bench.json score/cost sheet — see bench_priors.zig) outranks the+/// compiled table: measured capability+cost beats a hand-picked default. A+/// provider absent from both has no default tiering — roots on it inherit.pub fn forProvider(provider_id: []const u8) ?TierLadder {+ for (@import("bench_priors.zig").g_ladders) |l| if (std.mem.eql(u8, l.provider, provider_id)) return l;for (ladders) |l| if (std.mem.eql(u8, l.provider, provider_id)) return l;return null;}diff --git a/src/test_hooks.zig b/src/test_hooks.zigindex 1eb0fd40..59490c75 100644--- a/src/test_hooks.zig+++ b/src/test_hooks.zig@@ -43,6 +43,8 @@ const subagent_selection = @import("subagent_selection.zig");const subagent_pin_tests = @import("subagent_pin_tests.zig");// Moved off subagent.zig, which is at the 600-line cap.const subagent_tests = @import("subagent_tests.zig");+// Bench score/cost priors → derived tier ladders (.harness/bench.json).+const bench_priors = @import("bench_priors.zig");// `graff serve` resumability (#330): serve.zig imports these, but nothing in// the production graph references their decls, so Zig never analyses them.@@ -75,6 +77,7 @@ test {_ = subagent_selection;_ = subagent_pin_tests;_ = subagent_tests;+ _ = bench_priors;_ = serve_events;_ = serve_create;_ = scoring_slot_test;diff --git a/src/workflow.zig b/src/workflow.zigindex 00b1a2ad..f66d635a 100644--- a/src/workflow.zig+++ b/src/workflow.zig@@ -196,7 +196,7 @@ fn pipelineChain(ctx: ToolCtx, item: []const u8, stages: []const StageSpec) Toolfor (stages, 1..) |st, stage_no| {const prompt = pipelinePrompt(arena, st.prompt, item, prev, stage_no) catch |e| return failure(gpa, e);// null pin: #292 model pins deliberately do not reach pipeline stages (see subagent_run.variantProviderClass).- var out = if (runSub(ctx, "workflow_task", st.label, prompt, st.override, st.niche, st.isolation, st.isolation_fallback, null)) |r| r.output else |e| failure(gpa, e);+ var out = if (runSub(ctx, "workflow_task", st.label, prompt, st.override, st.niche, st.isolation, st.isolation_fallback, null, null)) |r| r.output else |e| failure(gpa, e);if (out.is_error) {// Only spend the one retry (#2) when the harness's own// classification hasn't already ruled it out (auth, invalid@@ -204,7 +204,7 @@ fn pipelineChain(ctx: ToolCtx, item: []const u8, stages: []const StageSpec) Tool// wasting a second attempt.if (failureAllowsRetry(out.text)) {gpa.free(out.text);- out = if (runSub(ctx, "workflow_retry", st.label, prompt, st.override, st.niche, st.isolation, st.isolation_fallback, null)) |r| r.output else |e| failure(gpa, e);+ out = if (runSub(ctx, "workflow_retry", st.label, prompt, st.override, st.niche, st.isolation, st.isolation_fallback, null, null)) |r| r.output else |e| failure(gpa, e);}if (out.is_error) {// #248 — excerpt the stage's own error BEFORE freeing it, so