Coverage for src/governed_harness/configuration/agent_results.py: 96%

285 statements  

« prev     ^ index     » next       coverage.py v7.17.2, created at 2026-11-12 16:06 +0000

1"""Configuration of the agent-results settings (since 2.0, issues #37-#44 and #52). 

2 

3Every section and key here is optional. A key that is absent keeps the 1.0.0 behaviour and is 

4left out of the serialized configuration, so the configuration snapshot (and its digest) of a 

5project written before these settings existed does not change. ``harness init`` writes them. 

6""" 

7 

8from __future__ import annotations 

9 

10from typing import Any, Literal 

11 

12from pydantic import ( 

13 BaseModel, 

14 ConfigDict, 

15 Field, 

16 SerializerFunctionWrapHandler, 

17 field_validator, 

18 model_serializer, 

19 model_validator, 

20) 

21 

22from governed_harness.domain.enums import FindingSeverity 

23 

24 

25class _Section(BaseModel): 

26 """A section whose unset (``None``) keys are left out of the serialized configuration.""" 

27 

28 model_config = ConfigDict(extra="forbid", populate_by_name=True, frozen=True) 

29 

30 @model_serializer(mode="wrap") 

31 def _omit_unset(self, handler: SerializerFunctionWrapHandler) -> dict[str, Any]: 

32 data: dict[str, Any] = handler(self) 

33 for name, field in type(self).model_fields.items(): 

34 if getattr(self, name) is None: 

35 data.pop(name, None) 

36 data.pop(field.alias or name, None) 

37 return data 

38 

39 

40Policy = Literal["enforce", "warn", "off"] 

41CallKind = Literal["implement", "clarify", "review", "plan", "acceptance", "architecture", "locate"] 

42 

43 

44class AgentCallConfig(_Section): 

45 """Which provider, model and effort an agent call of one kind uses. 

46 

47 ``provider`` names an entry of ``agentProviders`` (default: the run's provider); 

48 ``model`` and ``effort`` are passed to the provider in the request (``routing``) and take 

49 precedence over ``agentRouting``.""" 

50 

51 provider: str | None = None 

52 model: str | None = None 

53 effort: str | None = None 

54 

55 

56# ----- INTENT (#37) ------------------------------------------------------------------------- 

57AmbiguityReview = Literal["agent", "off"] 

58 

59 

60def off_from_yaml(value: Any) -> Any: 

61 # YAML 1.1 (PyYAML) reads a bare ``off`` as false. 

62 return "off" if value is False else value 

63 

64 

65AmbiguityExhausted = Literal["assume", "block"] 

66AmbiguityDepth = Literal["fixed", "adaptive"] 

67DEFAULT_AMBIGUITY_ROUNDS = 3 

68"""Rounds of agent questions a person answers before the review is exhausted (#79).""" 

69DEFAULT_AMBIGUITY_QUESTIONS = 8 

70"""Agent questions asked at most in one round (#79).""" 

71 

72 

73class AmbiguityReviewConfig(_Section): 

74 """The converging agent review of a task in INTENT (#79), the object form of 

75 ``intake.ambiguityReview``. 

76 

77 The review receives the questions already asked and their answers, asks only for blocking 

78 ambiguity that the latest revision introduced or left open, never asks again a question 

79 already asked (same rule and normalised text) and asks at most ``maxQuestions`` per round. 

80 After ``maxRounds`` rounds answered by a person, the points the agent still raises are 

81 recorded as explicit assumptions and the run continues (``onExhausted: assume``), or they 

82 are asked again and INTENT stays blocked (``block``, the default). The bare value 

83 ``agent`` keeps the single-round review, which neither converges nor stops.""" 

84 

85 mode: AmbiguityReview = "agent" 

86 max_rounds: int | None = Field(default=None, alias="maxRounds", ge=1, le=20) 

87 max_questions: int | None = Field(default=None, alias="maxQuestions", ge=1, le=40) 

88 on_exhausted: AmbiguityExhausted | None = Field(default=None, alias="onExhausted") 

89 skip_settled: bool | None = Field(default=None, alias="skipSettled") 

90 """Since 2.0.1: the review is not called again for a new revision of the task when the 

91 previous round of this run left no agent question, or once the ``unresolvable-ambiguity`` 

92 stop condition was recorded; the run goes straight to ``onExhausted``. Absent: the review 

93 runs for every revision, as in 2.0.0.""" 

94 depth: AmbiguityDepth | None = None 

95 """Since 2.0.1: ``adaptive`` scales the rounds and the questions per round with how little 

96 the task says and asks the fundamental topics first (users, what they do, main flows, 

97 platform, data, business rules, edge cases, acceptance criteria, first version), see 

98 :mod:`governed_harness.intake.depth`. Absent or ``fixed``: ``maxRounds`` and 

99 ``maxQuestions`` as written and no topic questions, as in 2.0.0.""" 

100 

101 @field_validator("mode", mode="before") 

102 @classmethod 

103 def _bare_off(cls, value: Any) -> Any: 

104 return off_from_yaml(value) 

105 

106 @property 

107 def enabled(self) -> bool: 

108 return self.mode == "agent" 

109 

110 @property 

111 def rounds(self) -> int: 

112 return self.max_rounds or DEFAULT_AMBIGUITY_ROUNDS 

113 

114 @property 

115 def questions(self) -> int: 

116 return self.max_questions or DEFAULT_AMBIGUITY_QUESTIONS 

117 

118 @property 

119 def exhausted(self) -> AmbiguityExhausted: 

120 return self.on_exhausted or "block" 

121 

122 @property 

123 def skips_settled(self) -> bool: 

124 return self.skip_settled is True 

125 

126 @property 

127 def adaptive(self) -> bool: 

128 return self.depth == "adaptive" 

129 

130 

131# ----- read-only calls (#80) ---------------------------------------------------------------- 

132ContractRetryMode = Literal["once", "off"] 

133 

134 

135class ContractRetryConfig(_Section): 

136 """A read-only call (clarify, plan, acceptance, locate, architecture, review) whose answer 

137 breaks its contract (no valid JSON, no ``result`` object, a ``result`` its phase rejects 

138 or, since #92, a call that changed the workspace) is sent once more before the phase 

139 blocks (``mode: once``), to 

140 ``fallbackProvider`` when it names an entry of ``agentProviders``, else to the same 

141 provider. Both attempts are recorded. Absent: the first broken answer blocks, as before.""" 

142 

143 mode: ContractRetryMode = "once" 

144 fallback_provider: str | None = Field(default=None, alias="fallbackProvider", min_length=1) 

145 

146 @field_validator("mode", mode="before") 

147 @classmethod 

148 def _bare_off(cls, value: Any) -> Any: 

149 return off_from_yaml(value) 

150 

151 @property 

152 def enabled(self) -> bool: 

153 return self.mode == "once" 

154 

155 

156# ----- VERIFICATION (#40, #52) -------------------------------------------------------------- 

157class ForbiddenImport(_Section): 

158 """Modules under ``source`` must not import modules under ``target`` (dotted prefixes).""" 

159 

160 source: str = Field(alias="from", min_length=1) 

161 target: str = Field(alias="to", min_length=1) 

162 

163 

164class ArchitectureConfig(_Section): 

165 """Engineering limits checked on the Python files of the ChangeSet (#40).""" 

166 

167 max_module_lines: int | None = Field(default=None, alias="maxModuleLines", ge=1) 

168 max_function_lines: int | None = Field(default=None, alias="maxFunctionLines", ge=1) 

169 max_complexity: int | None = Field(default=None, alias="maxComplexity", ge=1) 

170 forbidden_imports: tuple[ForbiddenImport, ...] | None = Field( 

171 default=None, alias="forbiddenImports" 

172 ) 

173 severity: FindingSeverity | None = None 

174 

175 

176class TestQualityConfig(_Section): 

177 """Test-quality checks on the ChangeSet (#52): assertion-free tests, coverage of changed 

178 lines, declared interface methods without tests and a second, reordered test run.""" 

179 

180 __test__ = False # not a pytest test class 

181 

182 assertions: bool | None = None 

183 diff_coverage: float | None = Field(default=None, alias="diffCoverage", ge=0, le=100) 

184 interface_tests: bool | None = Field(default=None, alias="interfaceTests") 

185 flaky_reruns: int | None = Field(default=None, alias="flakyReruns", ge=0, le=5) 

186 severity: FindingSeverity | None = None 

187 

188 

189class SarifInput(_Section): 

190 """A SARIF file an external scanner writes into the workspace (path relative to it).""" 

191 

192 path: str = Field(min_length=1) 

193 tool: str | None = None 

194 required: bool | None = None 

195 

196 @field_validator("path") 

197 @classmethod 

198 def _relative(cls, value: str) -> str: 

199 if value.startswith("/") or ".." in value.replace("\\", "/").split("/"): 199 ↛ 200line 199 didn't jump to line 200 because the condition on line 199 was never true

200 raise ValueError(f"a SARIF path must be relative to the workspace: {value!r}") 

201 return value 

202 

203 

204class InvariantCheck(_Section): 

205 """A command that must pass on every VERIFICATION, including each sub-task's.""" 

206 

207 invariant_id: str = Field(alias="id", min_length=1) 

208 command: tuple[str, ...] 

209 

210 @field_validator("command") 

211 @classmethod 

212 def _not_empty(cls, value: tuple[str, ...]) -> tuple[str, ...]: 

213 if not value: 213 ↛ 214line 213 didn't jump to line 214 because the condition on line 213 was never true

214 raise ValueError("an invariant needs a command") 

215 return value 

216 

217 

218AcceptanceMode = Literal["agent", "off"] 

219AcceptanceDisputes = Literal["person", "off"] 

220DEFAULT_ACCEPTANCE_DIRECTORY = "tests/acceptance" 

221 

222 

223class AcceptanceTestsConfig(_Section): 

224 """Independent, frozen acceptance tests (#52, N4): written from the criteria by a separate 

225 call (``author``), approved by a person, checked to fail before the change and to pass, 

226 unchanged, after it. 

227 

228 Since 2.0 (#94): 

229 

230 * ``protect: true`` keeps the frozen files from the implementing agent: the agent sandbox 

231 denies writes to them (as to ``.git`` and ``.harness``), and a frozen file that an agent 

232 invocation changed or deleted anyway is put back as approved, with a finding; 

233 * ``disputes: person`` lets the agent dispute a frozen test instead of failing against it: 

234 a VERIFICATION that fails only on the frozen acceptance tests, after an implementation 

235 whose self-report lists ``disputedAcceptanceTests``, waits for a person who upholds the 

236 tests (the run goes on as before) or sends the run back to SPECIFICATION for new ones.""" 

237 

238 mode: AcceptanceMode | None = None 

239 author: AgentCallConfig | None = None 

240 directory: str | None = None 

241 protect: bool | None = None 

242 disputes: AcceptanceDisputes | None = None 

243 

244 @field_validator("mode", "disputes", mode="before") 

245 @classmethod 

246 def _bare_off(cls, value: Any) -> Any: 

247 return off_from_yaml(value) 

248 

249 @field_validator("directory") 

250 @classmethod 

251 def _relative(cls, value: str | None) -> str | None: 

252 if value is not None and ( 

253 value.startswith("/") or ".." in value.replace("\\", "/").split("/") 

254 ): 

255 raise ValueError(f"the acceptance directory must be relative: {value!r}") 

256 return value 

257 

258 @property 

259 def enabled(self) -> bool: 

260 return self.mode == "agent" 

261 

262 @property 

263 def path(self) -> str: 

264 return (self.directory or DEFAULT_ACCEPTANCE_DIRECTORY).rstrip("/") 

265 

266 @property 

267 def disputes_enabled(self) -> bool: 

268 return self.disputes == "person" 

269 

270 

271RiskAction = Literal["block", "acknowledge", "inform", "off"] 

272 

273RISK_FACTORS: tuple[str, ...] = ( 

274 "newDependency", 

275 "authentication", 

276 "destructiveMigration", 

277 "publicContract", 

278 "network", 

279 "floatMoney", 

280 "sensitiveLogging", 

281 "deletedWithoutTests", 

282) 

283"""Risk factors of a sensitive change (#52), in the order they are reported.""" 

284 

285DEFAULT_RISK_ACTIONS: dict[str, RiskAction] = { 

286 "newDependency": "acknowledge", 

287 "authentication": "acknowledge", 

288 "destructiveMigration": "block", 

289 "publicContract": "acknowledge", 

290 "network": "acknowledge", 

291 "floatMoney": "block", 

292 "sensitiveLogging": "block", 

293 "deletedWithoutTests": "inform", 

294} 

295"""What ``harness init`` writes for ``verification.riskFactors``.""" 

296 

297 

298# ----- PLANNING (#39) ------------------------------------------------------------------------ 

299Decomposition = Literal["agent", "off"] 

300Granularity = Literal["fixed", "adaptive"] 

301 

302_GPT_SOL = "gpt-6.1-sol" 

303 

304DEFAULT_DECOMPOSITION_THRESHOLD = 12 

305DEFAULT_COARSE_MODELS: tuple[str, ...] = ( 

306 "claude-sonnet-5-5", 

307 "claude-opus-5-5", 

308 _GPT_SOL, 

309) 

310"""Models ``harness init`` lets start with a coarse (undecomposed) task under 

311``planning.granularity: adaptive``; a starting point from the evaluation, not a statement about 

312which models an account can use.""" 

313 

314 

315class PlanningConfig(_Section): 

316 """Decomposition of large tasks into governed sub-tasks (#39).""" 

317 

318 decomposition: Decomposition | None = None 

319 threshold: int | None = Field(default=None, ge=1, le=1000) 

320 planner: AgentCallConfig | None = None 

321 granularity: Granularity | None = None 

322 coarse_models: tuple[str, ...] | None = Field(default=None, alias="coarseModels") 

323 max_subtasks: int | None = Field(default=None, alias="maxSubtasks", ge=2, le=100) 

324 

325 @field_validator("decomposition", mode="before") 

326 @classmethod 

327 def _bare_off(cls, value: Any) -> Any: 

328 return off_from_yaml(value) 

329 

330 @property 

331 def enabled(self) -> bool: 

332 return self.decomposition == "agent" 

333 

334 @property 

335 def requirement_threshold(self) -> int: 

336 return self.threshold or DEFAULT_DECOMPOSITION_THRESHOLD 

337 

338 

339# ----- IMPLEMENTATION context (#41) ---------------------------------------------------------- 

340ContextManifestMode = Literal["auto", "off"] 

341DEFAULT_CONTEXT_MAX_FILES = 40 

342DEFAULT_CONTEXT_MAX_BYTES = 400_000 

343 

344 

345LocateMode = Literal["agent", "off"] 

346LocateReuse = Literal["revision", "scope"] 

347DEFAULT_LOCATE_MAX = 20 

348 

349 

350class LocateConfig(_Section): 

351 """Localisation with evidence (#55, item 11): a read-only ``locate`` call that returns 

352 where to intervene (``path:line`` with evidence) before IMPLEMENTATION. It runs only for 

353 tasks the router classifies M or L, once per task revision (cached by its digest), on the 

354 cheapest rung of the router; its answer feeds the context manifest.""" 

355 

356 mode: LocateMode | None = None 

357 agent: AgentCallConfig | None = None 

358 max_locations: int | None = Field(default=None, alias="maxLocations", ge=1, le=200) 

359 reuse: LocateReuse | None = None 

360 """Since 2.0.1: ``scope`` reuses the last locate result of the task while its scope (owned 

361 paths, contract scope, size class and limit) is unchanged, so a clarified revision does 

362 not call again; ``revision`` (the default) calls once per task revision, as in 2.0.0.""" 

363 

364 @field_validator("mode", mode="before") 

365 @classmethod 

366 def _bare_off(cls, value: Any) -> Any: 

367 return off_from_yaml(value) 

368 

369 @property 

370 def enabled(self) -> bool: 

371 return self.mode == "agent" 

372 

373 @property 

374 def limit(self) -> int: 

375 return self.max_locations or DEFAULT_LOCATE_MAX 

376 

377 @property 

378 def reuses_scope(self) -> bool: 

379 return self.reuse == "scope" 

380 

381 

382class ContextConfig(_Section): 

383 """The bounded context manifest sent to the agent (#41) and, since #55, the localisation 

384 call that feeds it (``locate``).""" 

385 

386 manifest: ContextManifestMode | None = None 

387 max_files: int | None = Field(default=None, alias="maxFiles", ge=1, le=1000) 

388 max_bytes: int | None = Field(default=None, alias="maxBytes", ge=1024) 

389 locate: LocateConfig | None = None 

390 

391 @field_validator("manifest", mode="before") 

392 @classmethod 

393 def _bare_off(cls, value: Any) -> Any: 

394 return off_from_yaml(value) 

395 

396 @property 

397 def enabled(self) -> bool: 

398 return self.manifest == "auto" 

399 

400 

401# ----- Budget (#42) -------------------------------------------------------------------------- 

402class BudgetLimits(_Section): 

403 cost_usd: float | None = Field(default=None, alias="costUsd", gt=0) 

404 tokens: int | None = Field(default=None, ge=1) 

405 wall_seconds: int | None = Field(default=None, alias="wallSeconds", ge=1) 

406 

407 

408class BudgetConfig(_Section): 

409 """Limits per agent call, per task (all its runs) and per run (#42).""" 

410 

411 per_call: BudgetLimits | None = Field(default=None, alias="perCall") 

412 per_task: BudgetLimits | None = Field(default=None, alias="perTask") 

413 per_run: BudgetLimits | None = Field(default=None, alias="perRun") 

414 warn_at: float | None = Field(default=None, alias="warnAt", gt=0, lt=1) 

415 

416 @property 

417 def warning_ratio(self) -> float: 

418 return self.warn_at or 0.8 

419 

420 

421# ----- Memory (#43) -------------------------------------------------------------------------- 

422LearnMode = Literal["auto", "off"] 

423 

424 

425class MemoryConfig(_Section): 

426 """Lessons from findings that caused a correction (#43).""" 

427 

428 learn_from_findings: LearnMode | None = Field(default=None, alias="learnFromFindings") 

429 auto_approve_recurring: bool | None = Field(default=None, alias="autoApproveRecurring") 

430 recurrence_runs: int | None = Field(default=None, alias="recurrenceRuns", ge=2, le=100) 

431 max_lessons: int | None = Field(default=None, alias="maxLessons", ge=1, le=100) 

432 

433 @field_validator("learn_from_findings", mode="before") 

434 @classmethod 

435 def _bare_off(cls, value: Any) -> Any: 

436 return off_from_yaml(value) 

437 

438 @property 

439 def enabled(self) -> bool: 

440 return self.learn_from_findings == "auto" 

441 

442 

443# ----- Routing (#44) ------------------------------------------------------------------------- 

444RoutingMode = Literal["fixed", "tiered", "anchored"] 

445SizeClass = Literal["S", "M", "L"] 

446ImplementSize = Literal["trivial", "S", "M", "L"] 

447"""Since #197: the keys of a family's ``implement`` rungs, ``trivial`` below ``S``.""" 

448ProviderFamily = Literal["claude-code", "codex", "generic"] 

449 

450 

451class Rung(_Section): 

452 model: str = Field(min_length=1) 

453 effort: str | None = None 

454 

455 

456class TrivialThresholds(_Section): 

457 """Since #197: the upper bounds under which an ``S`` task is ``trivial`` for the 

458 ``implement`` call. A trivial task also has at least one requirement and one owned file, 

459 no risk flag and no decomposition; ``requirements: 0`` turns the tier off.""" 

460 

461 requirements: int | None = Field(default=None, ge=0) 

462 files: int | None = Field(default=None, ge=0) 

463 loc: int | None = Field(default=None, ge=0) 

464 

465 

466class SizeThresholds(_Section): 

467 """Upper bounds of ``S`` and ``M`` for each signal; above the ``M`` bound a task is ``L``.""" 

468 

469 requirements: tuple[int, int] | None = None 

470 files: tuple[int, int] | None = None 

471 loc: tuple[int, int] | None = None 

472 trivial: TrivialThresholds | None = None 

473 """Since #197: the bounds of the ``trivial`` implement tier; without it 

474 ``DEFAULT_TRIVIAL_THRESHOLDS``.""" 

475 

476 @model_validator(mode="after") 

477 def _ordered(self) -> SizeThresholds: 

478 for name in ("requirements", "files", "loc"): 

479 pair = getattr(self, name) 

480 if pair is not None and not 0 <= pair[0] <= pair[1]: 480 ↛ 481line 480 didn't jump to line 481 because the condition on line 480 was never true

481 raise ValueError(f"{name} thresholds must be ascending non-negative numbers") 

482 return self 

483 

484 

485class FamilyTable(_Section): 

486 """The rung of each call kind and size for one provider family, and its escalation 

487 ladder (effort before model).""" 

488 

489 implement: dict[ImplementSize, Rung] | None = None 

490 """The rung of each task size; since #197 ``trivial`` (without it the ``S`` rung).""" 

491 clarify: Rung | None = None 

492 plan: Rung | None = None 

493 review: Rung | None = None 

494 locate: Rung | None = None 

495 """Since #55: the rung of the read-only ``locate`` call; without it the cheapest rung of 

496 the ladder (its first entry) is used.""" 

497 acceptance: Rung | None = None 

498 """Since #59: the rung of the ``acceptance`` call; without it the implement rung of the 

499 task's size is used, with a warning.""" 

500 architecture: Rung | None = None 

501 """Since #59: the rung of the ``architecture`` call; without it the ``plan`` rung.""" 

502 reviewers: dict[str, Rung] | None = None 

503 """Since #57: the rung of each reviewer of the review panel by id; without one the 

504 ``review`` rung.""" 

505 ladder: tuple[Rung, ...] | None = None 

506 

507 

508ReadOnlyKind = Literal["clarify", "locate", "architecture", "review", "plan", "acceptance"] 

509ReadOnlyEffort = Literal["low", "medium", "high"] 

510 

511DEFAULT_READ_ONLY_EFFORT: dict[str, str] = { 

512 "clarify": "low", 

513 "locate": "low", 

514 "architecture": "medium", 

515 "review": "medium", 

516} 

517"""Since 2.0.1: the read-only effort ``harness init`` writes (``agentRouting.readOnlyEffort``); 

518starting values, not a measured optimum.""" 

519 

520 

521class AgentRoutingConfig(_Section): 

522 """Model and effort of each agent call (#44): ``fixed`` keeps the provider's own model, 

523 ``tiered`` chooses from the tables by call kind and task size and escalates on quality 

524 failures. 

525 

526 Since #85 ``anchored`` uses the same tables with the invoking model as the ceiling: a rung 

527 of a cheaper model is kept, a rung of the invoking model's tier uses the invoking model 

528 with the rung's effort, a rung above it becomes the top rung allowed, and escalation climbs 

529 only up to that model. The invoking model is ``anchorModel`` when set, else the ``model`` 

530 of the provider that answers the call (for the ``session`` provider, ``agentProvider``), 

531 else the ``--model``/``-m`` value of its command or ``args``; when none is known every call 

532 keeps the provider's own model.""" 

533 

534 mode: RoutingMode | None = None 

535 anchor_model: str | None = Field(default=None, alias="anchorModel", min_length=1) 

536 """Since #85: the invoking model of ``mode: anchored`` when the provider does not say it 

537 (for example the model of an embedded agent session).""" 

538 thresholds: SizeThresholds | None = None 

539 families: dict[str, ProviderFamily] | None = None 

540 tables: dict[ProviderFamily, FamilyTable] | None = None 

541 max_escalations: int | None = Field(default=None, alias="maxEscalations", ge=0, le=10) 

542 risk_paths: tuple[str, ...] | None = Field(default=None, alias="riskPaths") 

543 read_only_effort: dict[ReadOnlyKind, ReadOnlyEffort] | None = Field( 

544 default=None, alias="readOnlyEffort" 

545 ) 

546 """Since 2.0.1: the effort of the first attempt of a routed read-only call by kind (and of 

547 the reviewers of the panel under ``review``), in place of the table's; escalations climb the 

548 ladder as before, ``implement`` never changes and a model that takes no effort (Claude 3, 

549 Haiku 4.x, Sonnet and Opus 4.0-4.5) keeps none. Absent: the table's effort, as in 2.0.0.""" 

550 

551 

552DEFAULT_SIZE_THRESHOLDS: dict[str, tuple[int, int]] = { 

553 "requirements": (5, 15), 

554 "files": (5, 20), 

555 "loc": (2000, 10000), 

556} 

557"""Starting thresholds ``harness init`` writes (S up to the first value, M up to the second); 

558to be calibrated with ``harness routing calibrate``, not a measured optimum.""" 

559 

560DEFAULT_TRIVIAL_THRESHOLDS: dict[str, int] = {"requirements": 1, "files": 1, "loc": 150} 

561"""Since #197: starting upper bounds of the ``trivial`` implement tier (one requirement, one 

562owned file of at most 150 lines), deliberately conservative and to be calibrated, not a 

563measured optimum.""" 

564 

565DEFAULT_ROUTING_TABLES: dict[str, dict[str, Any]] = { 

566 "claude-code": { 

567 "implement": { 

568 "trivial": {"model": "claude-haiku-5-5", "effort": "medium"}, 

569 "S": {"model": "claude-sonnet-5-5", "effort": "medium"}, 

570 "M": {"model": "claude-sonnet-5-5", "effort": "high"}, 

571 "L": {"model": "claude-opus-5-5", "effort": "high"}, 

572 }, 

573 "clarify": {"model": "claude-sonnet-5-5", "effort": "medium"}, 

574 "plan": {"model": "claude-opus-5-5", "effort": "high"}, 

575 "review": {"model": "claude-opus-5-5", "effort": "high"}, 

576 "acceptance": {"model": "claude-sonnet-5-5", "effort": "high"}, 

577 "architecture": {"model": "claude-opus-5-5", "effort": "high"}, 

578 "reviewers": { 

579 "quality": {"model": "claude-sonnet-5-5", "effort": "high"}, 

580 "architecture": {"model": "claude-opus-5-5", "effort": "high"}, 

581 "resilience": {"model": "claude-sonnet-5-5", "effort": "high"}, 

582 "tests": {"model": "claude-sonnet-5-5", "effort": "medium"}, 

583 "concurrency": {"model": "claude-opus-5-5", "effort": "high"}, 

584 "pipeline-security": {"model": "claude-sonnet-5-5", "effort": "high"}, 

585 }, 

586 "ladder": [ 

587 {"model": "claude-sonnet-5-5", "effort": "medium"}, 

588 {"model": "claude-sonnet-5-5", "effort": "high"}, 

589 {"model": "claude-opus-5-5", "effort": "high"}, 

590 {"model": "claude-opus-5-5", "effort": "xhigh"}, 

591 ], 

592 }, 

593 "codex": { 

594 "implement": { 

595 "trivial": {"model": "gpt-6-luna", "effort": "high"}, 

596 "S": {"model": "gpt-6-luna", "effort": "high"}, 

597 "M": {"model": _GPT_SOL, "effort": "medium"}, 

598 "L": {"model": _GPT_SOL, "effort": "high"}, 

599 }, 

600 "clarify": {"model": _GPT_SOL, "effort": "medium"}, 

601 "plan": {"model": _GPT_SOL, "effort": "high"}, 

602 "review": {"model": _GPT_SOL, "effort": "high"}, 

603 "acceptance": {"model": _GPT_SOL, "effort": "medium"}, 

604 "architecture": {"model": _GPT_SOL, "effort": "high"}, 

605 "reviewers": { 

606 "quality": {"model": _GPT_SOL, "effort": "medium"}, 

607 "architecture": {"model": _GPT_SOL, "effort": "high"}, 

608 "resilience": {"model": _GPT_SOL, "effort": "medium"}, 

609 "tests": {"model": "gpt-6-luna", "effort": "high"}, 

610 "concurrency": {"model": _GPT_SOL, "effort": "high"}, 

611 "pipeline-security": {"model": _GPT_SOL, "effort": "medium"}, 

612 }, 

613 "ladder": [ 

614 {"model": "gpt-6-luna", "effort": "high"}, 

615 {"model": _GPT_SOL, "effort": "medium"}, 

616 {"model": _GPT_SOL, "effort": "high"}, 

617 {"model": _GPT_SOL, "effort": "xhigh"}, 

618 ], 

619 }, 

620} 

621"""Starting tables (``.local`` research of 2026-10-04, summarised in docs): full model ids, effort 

622raised before the model, ``max``/``ultra`` left out. Availability for an account is not checked."""