Skip to main content

Module mode

Module mode 

Source
Expand description

Harness mode selection: daily-driver (default, token-efficiency consumption point) vs parity (full-schema benchmark mode) — #2059, vision spec §5.9.

Why: reconciles the parity spec’s byte-identical-schema requirement with the production harness’s future token-efficiency work by making the choice an explicit, resolvable, queryable mode rather than picking one behaviour permanently. What: HarnessMode, resolve_mode (the three-tier precedence: env var > task.run param > .claude/settings.json > default). Test: mode::tests::*. Harness mode selection: daily-driver (token-efficient, default) vs parity (full-schema benchmark mode) — #2059, vision spec §5.9 (“Reconciliation with Parity-Spec Decision D2”).

Why: the parity spec (D2) mandates byte-identical, full tool schemas across every model for benchmark fairness; the production harness wants deferred schemas / compaction / per-model optimisation for real coding work. §5.9’s resolved decision is two modes selected by a three-tier precedence, rather than picking one behaviour permanently. This module is ONLY the selection mechanism — resolving which mode applies to a given run and making that resolution queryable. It deliberately does NOT implement any token-efficiency behaviour (deferred schemas, compaction, repo-map): that is P1B’s job, hooking into the branch points this module’s callers expose (prompt::assemble_system_prompt_for_mode, agent_loop::AgentLoop’s mode-aware tool_definitions). In M1 both modes are functionally identical.

Precedence note: §5.9 states the three-tier hierarchy, highest to lowest, as: (1) TRUSTY_CODE_MODE env var (“escape hatch… overrides all”), (2) task.run’s mode param (“overrides setting”), (3) .claude/settings.json’s code_harness.mode (the configured default). [resolve_mode] implements EXACTLY this order. (A paraphrase of this ticket’s delegation put the env var last instead of first; §5.9’s own table and the raw issue #2059 text both independently state env-var- highest, so this module follows the spec verbatim — flagged explicitly for the reader rather than silently reconciled.)

What: [HarnessMode] (DailyDriver | Parity, Default = DailyDriver), [HarnessMode::parse_lenient] (case/separator-tolerant string parsing), and [resolve_mode] (the three-tier precedence chain, reading the env var and .claude/settings.json directly — no injected clock/env abstraction, matching this crate’s existing task::mock_llm::build_llm_client precedent for a small, direct std::env/std::fs read in production code). Test: mode::tests::* (precedence order, lenient parsing, unknown-value degrade-to-next-tier, settings.json presence/absence/malformed-JSON).

Enums§

HarnessMode
The two harness modes §5.9 resolves between.

Constants§

MODE_ENV_VAR
Escape-hatch environment variable (§5.9): TRUSTY_CODE_MODE=parity or daily-driver. Highest precedence — overrides everything else.

Functions§

resolve_mode
Resolve the effective HarnessMode for one task.run call, per §5.9’s three-tier precedence (highest to lowest): MODE_ENV_VAR > task_param (the task.run request’s own mode field) > .claude/settings.json’s code_harness.mode > HarnessMode::default.