feat(#443): unified cross-provider effort controls + fast-mode-aware routing (#463)

* test(#443): RED unified effort + fast_mode + resolve-execution

All 68 tests failing as expected — no implementation yet.
Covers: effort cascade (tier defaults, overrides, invalid fallthrough),
fast_mode cascade (boolean-only, tier defaults), resolveEffortForTier
escalation, renderEffortForRuntime clamping, resolve-execution CLI,
config schema new keys, QA hostile-input matrix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(#443): unified cross-provider effort + fast_mode knobs and resolve-execution query

Adds config-driven effort control (universal ladder: minimal<low<medium<high<xhigh<max)
and fast_mode propagation knobs, with per-runtime rendering that clamps the unique
tail values (max=Anthropic-only clamps to xhigh on Codex; minimal=Codex-only clamps
to low on Claude).

Key changes:
- config-schema.manifest.json: add effort.default, fast_mode.enabled as validKeys;
  add 4 dynamicKeyPatterns for effort.routing_tier_defaults, effort.agent_overrides,
  fast_mode.routing_tier_defaults, fast_mode.agent_overrides; fix stale _comment
- config-defaults.manifest.json: add effort and fast_mode blocks with tier defaults
- model-catalog.cjs: add EFFORT_RENDERING map, renderEffortForRuntime(), RUNTIMES_WITH_FAST_MODE
- model-profiles.cjs: re-export new catalog exports
- core.cjs: add resolveEffortInternal, resolveFastModeInternal, resolveEffortForTier,
  VALID_EFFORTS, EFFORT_SET, nextEffort; pass effort/fast_mode through loadConfig
- commands.cjs: replace reasoning_effort in cmdResolveModel with unified effort;
  add cmdResolveExecution (superset command with effort_rendered, effort_param,
  effort_propagation, fast_mode, fast_mode_supported)
- gsd-tools.cjs: add resolve-execution case with --effort/--fast-mode/--attempt flags
- tests/feat-443: 69 tests covering cascade, rendering, escalation, CLI, schema, QA matrix
- tests/commands.test.cjs: convert 3 reasoning_effort assertions to unified effort
- docs/CONFIGURATION.md: document effort + fast_mode + resolve-execution sections
- settings-advanced.md: list new effort/fast_mode keys in confirmation table

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(#443): remove dead catalog effort lane; unify codex effort through renderEffortForRuntime

- Remove resolveReasoningEffortInternal (catalog-driven effort function) from
  core.cjs and its export; remove from commands.cjs destructure import
- Convert tests/issue-2517-runtime-aware-profiles.test.cjs: all 11 effort
  assertions now use resolveEffortInternal + renderEffortForRuntime; Claude
  effort is first-class (output_config.effort); unknown runtimes assert param===null
- Convert tests/feat-3023-model-phase-types.test.cjs: replace the entire
  resolveReasoningEffortInternal describe with unified effort assertions;
  effort derives from AGENT_DEFAULT_TIERS routing tier, not phase-type tier

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs(#443): ADR for unified cross-provider effort + fast-mode routing

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* test(#443): architecture-level QA invariants + test-strategy doc

Add 48-test integration suite (feat-443-effort-fast-mode.integration.test.cjs)
covering 8 architectural invariants: cross-provider validity (never emit a value
the real API would 400 on), param/channel contract stability, resolve-execution
JSON contract (all 8 keys + correct types), totality across the full 33-agent
registry, fast-mode honesty (claude always fast_mode_supported=false), precedence
first-valid-wins matrix for both effort and fast_mode cascades, dynamic-routing
composition (effort escalation independent of model tier), and config-set round-trip
for all new effort/* and fast_mode/* key namespaces. Append test-strategy section
with invariant rationale and E2E gap documentation to docs/TESTING-SUITES.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* test(#443): add failing install-wiring tests for effort per-runtime injection (RED)

TDD RED: 10 failing tests covering:
- Claude .md gets effort: injected per tier (planner=xhigh, mapper=low, executor=high)
- Gemini .md does NOT get effort: (already passing — Gemini-safe)
- Codex .toml gets model_reasoning_effort via unified resolver
- Config-driven: effort.agent_overrides drives both Claude .md and Codex .toml
- Source purity: agents/*.md have no effort: key (already passing)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(#443): wire effort per-runtime at install (Claude .md frontmatter + Codex .toml unified)

- Import AGENT_DEFAULT_TIERS and renderEffortForRuntime from model-catalog.cjs
- Add readGsdEffectiveEffortConfig(targetDir): reads merged effort config from
  .planning/config.json (per-project wins) + ~/.gsd/defaults.json (global fallback),
  same probe pattern as readGsdRuntimeProfileResolver
- Add resolveInstallTimeEffort(effortCfg, agentName): pure function matching
  resolveEffortInternal() precedence (agent_overrides > routing_tier_defaults > default > 'high')
  without loadConfig side-effects (no sub-repo detection, no migration writes)
- Claude agent copy loop: inject `effort: <value>` into frontmatter ONLY for
  runtime === 'claude'; all other .md runtimes (Gemini, Qwen, Hermes, etc.) stay
  effort-free (Gemini-safe source contract preserved in agents/*.md)
- generateCodexAgentToml: add effortCfg param; emit model_reasoning_effort from
  unified resolver (replaces old catalog entry.reasoning_effort); Codex clamps
  max → xhigh via renderEffortForRuntime('codex', ...)
- installCodexConfig: pass readGsdEffectiveEffortConfig(targetDir) to
  generateCodexAgentToml so per-project config wins for Codex .toml too
- Update failing tests to GREEN: 12/12 pass; all 17 install tests pass;
  2847/2848 unit tests pass (1 pre-existing failure: policy-shell-pinning)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor(#443): source install effort defaults from manifest (kill drift) + guard test

Replace hardcoded _GSD_EFFORT_MANIFEST_TIER_DEFAULTS and the 'high' fallback in
resolveInstallTimeEffort with values read from config-defaults.manifest.json at
module init, using the same __dirname-relative path install.js already uses for
all shared manifests. Add feat-443-effort-defaults-drift.test.cjs to assert
equality between install.js's runtime constants and the manifest on every CI run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(#443): reconcile Codex TOML tests with unified effort design

The #443 unified effort resolver makes generateCodexAgentToml always emit
model_reasoning_effort (driven by resolveInstallTimeEffort, not model_profile_overrides).
The test 'generated TOML omits reasoning_effort when runtime has none' had an
obsolete premise — model_profile_overrides.reasoning_effort:'' no longer suppresses
unified effort. Convert it to assert the new invariant: Codex TOML always carries a
valid model_reasoning_effort from the agent's routing tier (xhigh for gsd-planner,
a heavy-tier agent), while model_profile_overrides model override is still respected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(#443): make install.js effort resolution lazy (no load-time side effects breaking launcher-parity)

Replace module-load-time IIFE + hard throw (config-defaults.manifest.json read)
and top-level require of model-catalog.cjs with a lazy _getGsdEffortCatalog()
getter that initialises on first call from resolveInstallTimeEffort /
generateCodexAgentToml / Claude .md effort injection.  Requiring install.js in
unrelated test contexts (e.g. runtime-launcher-parity) no longer triggers
manifest IO or throws, eliminating the load-time side effect that changed
subprocess exit codes / stderr on the bench.

Drift-guard exports (_GSD_EFFORT_MANIFEST_TIER_DEFAULTS / _GSD_EFFORT_MANIFEST_DEFAULT)
preserved as lazy getter properties on module.exports so feat-443-effort-defaults-drift
still validates them without forcing eager load.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(#443): isolate install-wiring test HOME to stop \$HOME/.claude pollution breaking launcher-parity

runGlobalInstall() now redirects HOME to a per-call isolated tmpdir in addition
to the existing runtime-specific env-var redirects (CLAUDE_CONFIG_DIR,
GEMINI_CONFIG_DIR, CODEX_HOME). This ensures install.js code that uses
os.homedir() directly — including the ~/.cache/gsd update-check deletion,
~/.gsd/defaults.json reads, and any HOME-relative npm subprocess writes —
never touches the real \$HOME during the test.

Without the HOME isolation the install test (which is new to this branch and
is now picked up by Docker's raw \`tests/*.test.cjs\` glob) could write or
delete files under the real \$HOME, causing runtime-launcher-parity test (D)
to fail: (D) asserts a loud non-zero exit when \$RUNTIME_DIR/gsd-tools.cjs is
absent and gsd-tools is not on PATH, but the launcher's \$HOME/.claude fallback
arm succeeds if \$HOME/.claude/get-shit-done/bin/gsd-tools.cjs exists.

Also sets GSD_SKIP_STALE_SDK_CHECK=1 to suppress the \`npm ls -g\` subprocess
that the global installer spawns — irrelevant to effort-wiring assertions,
slow, and potentially writes to ~/.npm cache.

All 12 feat-443 install-wiring assertions preserved. Drift-guard 5/5. Unit
suite 2848/2850 (pre-existing policy-shell-pinning.test.cjs failure on next).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore(#443): add changeset fragment for effort + fast-mode routing

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix(#443): set GSD_TEST_MODE before requiring install.js in drift-guard test to prevent HOME leak

Without GSD_TEST_MODE=1, require('bin/install.js') runs the module's main
install block (guarded by !GSD_TEST_MODE), performing a real global Claude
install into $HOME/.claude/. On CI ubuntu where node is on standard PATH,
the launcher's $HOME/.claude fallback arm then finds gsd-tools.cjs, causing
runtime-launcher-parity test (D) to exit zero when it must exit non-zero.

Root cause: feat-443-effort-defaults-drift.test.cjs (unit suite) runs
alphabetically before runtime-launcher-parity.test.cjs in the same node
--test invocation. Each runs in a separate worker process but shares the
same HOME. The drift test's install leaks gsd-tools.cjs into that HOME,
then the launcher test's bash subprocess finds it via the $HOME/.claude arm.

Fix: add process.env.GSD_TEST_MODE = '1' at the top of the drift-guard
test, before the require(installPath) call. This matches the pattern used
by feat-443-effort-fast-mode.test.cjs and feat-443-effort-install-wiring
.install.test.cjs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(#443): deterministic resolve-execution arg parsing + validate install-time effort (Codex adversarial findings)

Finding 1: resolve-execution --effort low gsd-planner misrouted 'low' as the agent.
Replace find(non-dash) with a proper flag-consuming loop that collects a single
positional; validate missing/extra positionals and malformed --attempt values.

Finding 2: resolveInstallTimeEffort returned unvalidated effort strings (e.g. "ultra")
verbatim. Each precedence layer now checks GSD_EFFORT_SET (imported once from
core.cjs) before accepting a value, mirroring resolveEffortInternal exactly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(#443): newline-agnostic effort frontmatter injection (Windows CRLF) + CRLF-safe assertions

Extracts injectEffortFrontmatter(content, effortValue) pure helper that detects
EOL (LF vs CRLF) from the opening '---' line and inserts 'effort: <value>'
before the closing '---' delimiter using the same EOL as the surrounding
frontmatter. Regex now uses /^---\r?\n([\s\S]*?)^---\r?$/m instead of the
LF-only /^(---\n[\s\S]*?)(---)(\n|$)/ that silently skipped CRLF files on
Windows (git core.autocrlf=true checkout).

Also adds 7 unit tests covering LF, CRLF, idempotency, no-frontmatter, and
complex frontmatter cases. Exports injectEffortFrontmatter from module.exports.

Fixes 6 CI failures in tests/feat-443-effort-install-wiring.install.test.cjs
on windows-latest runners (lines 138, 145, 152, 261, 345, 356).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: CI Rebase Check <ci@gsd-redux>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-05-29 10:32:58 -04:00
committed by GitHub
parent 199251c0f6
commit 5ca646f015
20 changed files with 3354 additions and 211 deletions

View File

@@ -1135,7 +1135,10 @@ describe('resolve-model command', () => {
assert.ok(output.model, 'should resolve a model');
});
test('includes reasoning_effort when selected runtime supports it', () => {
// #443: resolve-model now emits unified `effort` instead of `reasoning_effort`.
// reasoning_effort was flavor-text (resolved but consumed by nobody); effort is
// the wired, config-driven universal effort string for all runtimes.
test('emits unified effort (not reasoning_effort) when runtime supports tiered effort', () => {
fs.writeFileSync(path.join(tmpDir, '.planning', 'config.json'), JSON.stringify({
model_profile: 'balanced',
runtime: 'codex',
@@ -1147,10 +1150,14 @@ describe('resolve-model command', () => {
const output = JSON.parse(result.output);
assert.strictEqual(output.model, 'gpt-5.4');
assert.strictEqual(output.profile, 'balanced');
assert.strictEqual(output.reasoning_effort, 'xhigh');
// #443: effort is now the unified field (xhigh for gsd-planner heavy tier default)
assert.strictEqual(output.effort, 'xhigh');
// reasoning_effort must be absent — replaced by unified effort
assert.ok(!Object.prototype.hasOwnProperty.call(output, 'reasoning_effort'),
'reasoning_effort must not appear in resolve-model output (replaced by effort)');
});
test('does not include reasoning_effort for unsupported runtime overrides', () => {
test('does not include reasoning_effort for unsupported runtime overrides (effort present instead)', () => {
fs.writeFileSync(path.join(tmpDir, '.planning', 'config.json'), JSON.stringify({
model_profile: 'balanced',
runtime: 'opencode',
@@ -1167,10 +1174,13 @@ describe('resolve-model command', () => {
const output = JSON.parse(result.output);
assert.strictEqual(output.model, 'openrouter/openai/gpt-5.5');
assert.strictEqual(output.profile, 'balanced');
assert.ok(!Object.prototype.hasOwnProperty.call(output, 'reasoning_effort'));
// #443: effort always present; reasoning_effort never present
assert.ok(Object.prototype.hasOwnProperty.call(output, 'effort'), 'effort must be present');
assert.ok(!Object.prototype.hasOwnProperty.call(output, 'reasoning_effort'),
'reasoning_effort must not appear (replaced by unified effort)');
});
test('does not include reasoning_effort for per-agent model_overrides', () => {
test('does not include reasoning_effort for per-agent model_overrides (effort present instead)', () => {
fs.writeFileSync(path.join(tmpDir, '.planning', 'config.json'), JSON.stringify({
model_profile: 'balanced',
runtime: 'codex',
@@ -1183,7 +1193,10 @@ describe('resolve-model command', () => {
const output = JSON.parse(result.output);
assert.strictEqual(output.model, 'gpt-5.5');
assert.strictEqual(output.profile, 'balanced');
assert.ok(!Object.prototype.hasOwnProperty.call(output, 'reasoning_effort'));
// #443: effort always present; reasoning_effort never present
assert.ok(Object.prototype.hasOwnProperty.call(output, 'effort'), 'effort must be present');
assert.ok(!Object.prototype.hasOwnProperty.call(output, 'reasoning_effort'),
'reasoning_effort must not appear (replaced by unified effort)');
});
test('fails when no agent-type provided', () => {

View File

@@ -253,129 +253,100 @@ describe('#3023 resolver: models.<phase_type> overrides profile-based tier', ()
});
});
// ─── #3030 CR Major outside-diff: reasoning_effort honors phase-type ───────
// ─── #443 Unified effort: resolveEffortInternal + renderEffortForRuntime ────
const { resolveReasoningEffortInternal } = require('../get-shit-done/bin/lib/core.cjs');
const { resolveEffortInternal } = require('../get-shit-done/bin/lib/core.cjs');
const { renderEffortForRuntime } = require('../get-shit-done/bin/lib/model-catalog.cjs');
describe('#3023 + #3030 CR: resolveReasoningEffortInternal honors phase-type tier (Codex)', () => {
describe('#3023 + #443: unified effort resolver (resolveEffortInternal) for Codex', () => {
let projectDir;
beforeEach(() => { projectDir = makeTmp('effort'); });
afterEach(() => { rmr(projectDir); });
test('exported from core.cjs', () => {
assert.equal(typeof resolveReasoningEffortInternal, 'function');
test('resolveEffortInternal exported from core.cjs', () => {
assert.equal(typeof resolveEffortInternal, 'function');
});
test('phase-type override flips both model AND reasoning_effort to the same tier (Codex)', () => {
// The CR Major bug: previously the model was resolved from the
// phase-type tier (opus → gpt-5.4) but reasoning_effort still came
// from the profile-derived sonnet tier (medium) — leading to a
// mismatched (model, effort) pair on Codex spawn.
test('effort derives from AGENT_DEFAULT_TIERS (routing), not phase-type; gsd-executor is standard → high', () => {
// Under unification, effort is config-driven via routing_tier_defaults.
// gsd-executor has routing tier 'standard' → default effort 'high', regardless
// of models.execution phase-type or model_profile setting.
writeConfig(projectDir, {
runtime: 'codex',
model_profile: 'balanced',
models: { execution: 'opus' },
});
// gsd-executor's profile tier under balanced is sonnet, so without
// the phase-type lookup mirror, model would resolve to opus (xhigh)
// but effort to medium. Both must derive from the same tier source.
const effort = resolveReasoningEffortInternal(projectDir, 'gsd-executor');
// The exact effort value depends on the runtime tier map's opus row;
// the test guards the relationship: it must NOT be the sonnet/medium
// value when the phase-type forced opus.
const sonnetEffort = (() => {
// Read the sonnet effort by setting a config that uses the sonnet tier
// and reading what comes back, so the assertion is semantic (effort
// matches phase-type tier) rather than a hard-coded string.
const sonnetDir = makeTmp('effort-sonnet');
try {
writeConfig(sonnetDir, {
runtime: 'codex', model_profile: 'balanced',
});
return resolveReasoningEffortInternal(sonnetDir, 'gsd-executor');
} finally {
rmr(sonnetDir);
}
})();
const opusEffort = (() => {
const opusDir = makeTmp('effort-opus');
try {
writeConfig(opusDir, {
runtime: 'codex', model_profile: 'quality', // quality → executor=opus
});
return resolveReasoningEffortInternal(opusDir, 'gsd-executor');
} finally {
rmr(opusDir);
}
})();
// The phase-type override (models.execution=opus) must produce the
// SAME effort as a profile-only opus config.
assert.equal(effort, opusEffort,
`phase-type override must match opus-tier effort, got ${effort}, expected ${opusEffort}`);
// And it must NOT match sonnet effort (proving the override fired).
if (opusEffort !== null && sonnetEffort !== null && opusEffort !== sonnetEffort) {
assert.notEqual(effort, sonnetEffort,
`phase-type override should not silently use sonnet effort: ${effort}`);
}
const eff = resolveEffortInternal(projectDir, 'gsd-executor');
// standard tier → 'high' (not 'xhigh' from opus, not 'medium' from old catalog)
assert.equal(eff, 'high');
const rendered = renderEffortForRuntime('codex', eff);
assert.equal(rendered.param, 'model_reasoning_effort');
assert.equal(rendered.value, 'high');
});
test('inherit phase-type tier returns null effort (no runtime entry maps to inherit)', () => {
test('effort resolves universally even when models.execution=inherit', () => {
// Under unification, models.execution='inherit' does not affect effort resolution.
// Effort always resolves from routing_tier_defaults: gsd-executor (standard) → 'high'.
writeConfig(projectDir, {
runtime: 'codex',
model_profile: 'balanced',
models: { execution: 'inherit' },
});
// 'inherit' has no runtime-tier entry, so the resolver returns null.
const effort = resolveReasoningEffortInternal(projectDir, 'gsd-executor');
assert.equal(effort, null);
const eff = resolveEffortInternal(projectDir, 'gsd-executor');
assert.equal(eff, 'high');
const rendered = renderEffortForRuntime('codex', eff);
assert.equal(rendered.param, 'model_reasoning_effort');
assert.equal(rendered.value, 'high');
});
test('per-agent override still bypasses phase-type for reasoning_effort', () => {
test('per-agent model_overrides does not affect effort (effort is routing-tier-based)', () => {
// Under unification, effort does not check model_overrides.
// gsd-executor (standard tier) → 'high' regardless.
writeConfig(projectDir, {
runtime: 'codex',
model_profile: 'balanced',
models: { execution: 'opus' },
model_overrides: { 'gsd-executor': 'openai/gpt-5' },
});
// model_overrides[agent] short-circuits resolveReasoningEffortInternal
// (the user supplied a fully-qualified ID; effort must be set per-agent).
assert.equal(resolveReasoningEffortInternal(projectDir, 'gsd-executor'), null);
const eff = resolveEffortInternal(projectDir, 'gsd-executor');
assert.equal(eff, 'high');
const rendered = renderEffortForRuntime('codex', eff);
assert.equal(rendered.param, 'model_reasoning_effort');
assert.equal(rendered.value, 'high');
});
test('claude runtime ignores models.* for reasoning_effort (returns null)', () => {
test('Claude runtime: effort is first-class (emits output_config.effort, not null)', () => {
// Under unification, Claude effort is first-class via output_config.effort.
// No `runtime` set → defaults to claude (no runtime key → undefined runtime).
writeConfig(projectDir, {
// No `runtime` set → defaults to claude, which has no reasoning_effort.
model_profile: 'balanced',
models: { execution: 'opus' },
});
assert.equal(resolveReasoningEffortInternal(projectDir, 'gsd-executor'), null);
const eff = resolveEffortInternal(projectDir, 'gsd-executor');
// effort resolves universally; claude render gives output_config.effort
const rendered = renderEffortForRuntime(undefined, eff);
// undefined runtime yields param=null (no runtime key set)
assert.equal(rendered.param, null);
// But if explicitly set to 'claude':
const renderedClaude = renderEffortForRuntime('claude', eff);
assert.equal(renderedClaude.param, 'output_config.effort');
assert.equal(renderedClaude.value, 'high');
});
test('phase-type override wins over profile=inherit for effort (CR Major #3030)', () => {
// Pre-fix bug: profile=inherit short-circuited to null even when
// models.execution=opus would have supplied a valid tier.
test('profile=inherit does not affect effort; effort resolves from routing tier', () => {
// Under unification, effort is completely independent of model_profile.
// gsd-executor (standard routing tier) → 'high' even with model_profile='inherit'.
writeConfig(projectDir, {
runtime: 'codex',
model_profile: 'inherit',
models: { execution: 'opus' },
});
// Compute the expected effort by reading what gsd-executor would
// get under a profile-only opus config — the phase-type override
// must produce the SAME result.
const expected = (() => {
const dir = makeTmp('effort-opus2');
try {
writeConfig(dir, { runtime: 'codex', model_profile: 'quality' });
return resolveReasoningEffortInternal(dir, 'gsd-executor');
} finally {
rmr(dir);
}
})();
const actual = resolveReasoningEffortInternal(projectDir, 'gsd-executor');
assert.equal(actual, expected,
`phase-type override over profile=inherit must produce the opus-tier effort; got ${actual}, expected ${expected}`);
assert.notEqual(actual, null,
'phase-type opus must NOT return null effort just because profile=inherit');
const eff = resolveEffortInternal(projectDir, 'gsd-executor');
assert.equal(eff, 'high',
'profile=inherit must not affect effort; standard routing tier → high');
const rendered = renderEffortForRuntime('codex', eff);
assert.equal(rendered.param, 'model_reasoning_effort');
assert.equal(rendered.value, 'high');
});
});

View File

@@ -0,0 +1,83 @@
'use strict';
/**
* feat-443-effort-defaults-drift.test.cjs
*
* Drift-guard: asserts that install.js's resolved baseline effort defaults
* equal config-defaults.manifest.json's effort block. Any future divergence
* (someone edits the manifest without updating install.js or vice-versa) fails
* CI immediately rather than silently injecting stale effort values.
*
* Real assertions on runtime values — no source-grep.
*/
// MUST be set before require('bin/install.js') so the main install block
// (guarded by !GSD_TEST_MODE) does not execute and perform a real global
// install into $HOME/.claude/ — which would leak gsd-tools.cjs into the
// ambient HOME and break runtime-launcher-parity test (D) in the same
// node --test run (all unit tests share the same HOME on CI).
process.env.GSD_TEST_MODE = '1';
const assert = require('assert');
const path = require('path');
const { test } = require('node:test');
// Load the manifest directly (JSON, not a .cjs source file — allowed by lint rule)
const manifestPath = path.join(
__dirname,
'..',
'get-shit-done',
'bin',
'shared',
'config-defaults.manifest.json'
);
const manifest = require(manifestPath);
// Load install.js exported values (executes the module, not text inspection)
const installPath = path.join(__dirname, '..', 'bin', 'install.js');
const {
_GSD_EFFORT_MANIFEST_TIER_DEFAULTS,
_GSD_EFFORT_MANIFEST_DEFAULT,
} = require(installPath);
test('install.js _GSD_EFFORT_MANIFEST_TIER_DEFAULTS.light matches manifest effort.routing_tier_defaults.light', () => {
assert.strictEqual(
_GSD_EFFORT_MANIFEST_TIER_DEFAULTS.light,
manifest.effort.routing_tier_defaults.light,
`install.js tier default for "light" (${_GSD_EFFORT_MANIFEST_TIER_DEFAULTS.light}) differs from manifest (${manifest.effort.routing_tier_defaults.light})`
);
});
test('install.js _GSD_EFFORT_MANIFEST_TIER_DEFAULTS.standard matches manifest effort.routing_tier_defaults.standard', () => {
assert.strictEqual(
_GSD_EFFORT_MANIFEST_TIER_DEFAULTS.standard,
manifest.effort.routing_tier_defaults.standard,
`install.js tier default for "standard" (${_GSD_EFFORT_MANIFEST_TIER_DEFAULTS.standard}) differs from manifest (${manifest.effort.routing_tier_defaults.standard})`
);
});
test('install.js _GSD_EFFORT_MANIFEST_TIER_DEFAULTS.heavy matches manifest effort.routing_tier_defaults.heavy', () => {
assert.strictEqual(
_GSD_EFFORT_MANIFEST_TIER_DEFAULTS.heavy,
manifest.effort.routing_tier_defaults.heavy,
`install.js tier default for "heavy" (${_GSD_EFFORT_MANIFEST_TIER_DEFAULTS.heavy}) differs from manifest (${manifest.effort.routing_tier_defaults.heavy})`
);
});
test('install.js _GSD_EFFORT_MANIFEST_DEFAULT matches manifest effort.default', () => {
assert.strictEqual(
_GSD_EFFORT_MANIFEST_DEFAULT,
manifest.effort.default,
`install.js effort default (${_GSD_EFFORT_MANIFEST_DEFAULT}) differs from manifest (${manifest.effort.default})`
);
});
test('install.js tier-defaults object has exactly the same keys as manifest effort.routing_tier_defaults', () => {
const installKeys = Object.keys(_GSD_EFFORT_MANIFEST_TIER_DEFAULTS).sort();
const manifestKeys = Object.keys(manifest.effort.routing_tier_defaults).sort();
assert.deepStrictEqual(
installKeys,
manifestKeys,
`Key mismatch — install.js: [${installKeys.join(', ')}], manifest: [${manifestKeys.join(', ')}]`
);
});

View File

@@ -0,0 +1,718 @@
'use strict';
/**
* Architecture-level QA for issue #443 — unified effort + fast_mode engine.
*
* Integration suite (*.integration.test.cjs): cross-module flows that exercise
* real CLI invocations via runGsdTools, the full 33-agent registry, and the
* config round-trip through config-set -> resolve-execution.
*
* INVARIANTS tested here (each is also documented in docs/TESTING-SUITES.md):
*
* (a) CROSS-PROVIDER VALIDITY — renderEffortForRuntime never emits a value
* that the real provider API would 400 on. Ground-truth provider enums are
* defined as local constants (not sourced from the implementation).
*
* (b) PARAM/CHANNEL CONTRACT — each runtime exposes a stable parameter name
* and propagation channel.
*
* (c) RESOLVE-EXECUTION JSON CONTRACT — the CLI command emits a stable JSON
* shape with all required keys and correct types.
*
* (d) TOTALITY across the real 33-agent registry — every agent produces a
* valid effort value; none returns undefined/null.
*
* (e) FAST-MODE HONESTY INVARIANT — claude runtime always reports
* fast_mode_supported=false (emitting fast_mode frontmatter is a silent
* no-op for Claude Code subagents).
*
* (f) PRECEDENCE MATRIX — first-valid-wins for both effort and fast_mode
* cascades, including invalid values correctly falling through.
*
* (g) DYNAMIC-ROUTING COMPOSITION — resolveEffortForTier escalates
* independently of model tier logic; clamps at 'max'; respects
* max_escalations; disabled when escalate_on_failure=false.
*
* (h) CONFIG-TOOLING ROUND-TRIP — config-set accepts all new effort/fast_mode
* key paths (schema validation passes); values survive round-trip through
* resolve-execution.
*/
process.env.GSD_TEST_MODE = '1';
const { describe, test, before, after, beforeEach, afterEach } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { createTempProject, cleanup, runGsdTools } = require('./helpers.cjs');
const {
resolveEffortInternal,
resolveFastModeInternal,
resolveEffortForTier,
VALID_EFFORTS,
} = require('../get-shit-done/bin/lib/core.cjs');
const {
renderEffortForRuntime,
RUNTIMES_WITH_FAST_MODE,
catalog,
} = require('../get-shit-done/bin/lib/model-catalog.cjs');
// ─────────────────────────────────────────────────────────────────────────────
// Ground-truth provider enums (defined HERE, not sourced from the implementation).
// These are the exact values the real APIs accept — using a value outside these
// sets would result in a 400 response from the provider.
//
// Sources:
// Anthropic: output_config.effort — https://docs.anthropic.com (Claude API)
// OpenAI: model_reasoning_effort — https://platform.openai.com/docs (Codex)
// ─────────────────────────────────────────────────────────────────────────────
const PROVIDER_EFFORT_ENUMS = {
claude: new Set(['low', 'medium', 'high', 'xhigh', 'max']),
codex: new Set(['minimal', 'low', 'medium', 'high', 'xhigh']),
};
// Helper: write config.json into a temp project
function writeConfig(dir, config) {
const planningDir = path.join(dir, '.planning');
fs.mkdirSync(planningDir, { recursive: true });
fs.writeFileSync(path.join(planningDir, 'config.json'), JSON.stringify(config, null, 2));
}
// ─── (a) CROSS-PROVIDER VALIDITY INVARIANT ───────────────────────────────────
describe('#443 integration (a): cross-provider validity invariant', () => {
// For every universal effort × every provider runtime, the rendered value
// must be a member of that provider's real API enum.
test('all VALID_EFFORTS render within provider enums for claude and codex', () => {
for (const universalEffort of VALID_EFFORTS) {
for (const [runtime, providerEnum] of Object.entries(PROVIDER_EFFORT_ENUMS)) {
const rendered = renderEffortForRuntime(runtime, universalEffort);
assert.ok(
providerEnum.has(rendered.value),
`render('${runtime}', '${universalEffort}').value = '${rendered.value}' is NOT in the ` +
`${runtime} provider enum ${[...providerEnum].join('|')} — real API would 400`
);
}
}
});
// Documented clamps must hold exactly
test("render('codex','max').value === 'xhigh' (max is Anthropic-only)", () => {
assert.strictEqual(renderEffortForRuntime('codex', 'max').value, 'xhigh');
});
test("render('claude','minimal').value === 'low' (minimal is Codex-only)", () => {
assert.strictEqual(renderEffortForRuntime('claude', 'minimal').value, 'low');
});
// Common levels must pass through unchanged on BOTH providers
test('common levels (low/medium/high/xhigh) pass through unchanged on claude', () => {
for (const level of ['low', 'medium', 'high', 'xhigh']) {
assert.strictEqual(
renderEffortForRuntime('claude', level).value,
level,
`claude: level '${level}' should pass through unchanged`
);
}
});
test('common levels (low/medium/high/xhigh) pass through unchanged on codex', () => {
for (const level of ['low', 'medium', 'high', 'xhigh']) {
assert.strictEqual(
renderEffortForRuntime('codex', level).value,
level,
`codex: level '${level}' should pass through unchanged`
);
}
});
});
// ─── (b) PARAM/CHANNEL CONTRACT ──────────────────────────────────────────────
describe('#443 integration (b): param/channel contract', () => {
test("claude: param is always 'output_config.effort'", () => {
for (const effort of VALID_EFFORTS) {
const r = renderEffortForRuntime('claude', effort);
assert.strictEqual(r.param, 'output_config.effort',
`claude param must be 'output_config.effort' for effort '${effort}'`);
}
});
test("codex: param is always 'model_reasoning_effort'", () => {
for (const effort of VALID_EFFORTS) {
const r = renderEffortForRuntime('codex', effort);
assert.strictEqual(r.param, 'model_reasoning_effort',
`codex param must be 'model_reasoning_effort' for effort '${effort}'`);
}
});
test('claude channel is stable: frontmatter', () => {
for (const effort of VALID_EFFORTS) {
assert.strictEqual(renderEffortForRuntime('claude', effort).channel, 'frontmatter');
}
});
test('codex channel is stable: api', () => {
for (const effort of VALID_EFFORTS) {
assert.strictEqual(renderEffortForRuntime('codex', effort).channel, 'api');
}
});
test("unknown runtimes (gemini, qwen, 'mystery'): param===null, value passes through", () => {
for (const runtime of ['gemini', 'qwen', 'mystery']) {
for (const effort of VALID_EFFORTS) {
const r = renderEffortForRuntime(runtime, effort);
assert.strictEqual(r.param, null, `${runtime}: param must be null`);
assert.strictEqual(r.channel, null, `${runtime}: channel must be null`);
assert.strictEqual(r.value, effort, `${runtime}: value must pass through unchanged`);
}
}
});
});
// ─── (c) RESOLVE-EXECUTION JSON CONTRACT ─────────────────────────────────────
describe('#443 integration (c): resolve-execution JSON contract', () => {
let tmpDir;
beforeEach(() => { tmpDir = createTempProject(); });
afterEach(() => { cleanup(tmpDir); });
function assertFullContract(output, label) {
assert.ok(typeof output.model === 'string' && output.model.length > 0,
`${label}: model must be a non-empty string`);
assert.ok(typeof output.profile === 'string' && output.profile.length > 0,
`${label}: profile must be a non-empty string`);
assert.ok(VALID_EFFORTS.includes(output.effort),
`${label}: effort '${output.effort}' must be a member of VALID_EFFORTS`);
assert.ok(typeof output.effort_rendered === 'string' && output.effort_rendered.length > 0,
`${label}: effort_rendered must be a non-empty string`);
assert.ok(output.effort_param === null || typeof output.effort_param === 'string',
`${label}: effort_param must be string or null`);
assert.ok(output.effort_propagation === null || typeof output.effort_propagation === 'string',
`${label}: effort_propagation must be string or null`);
assert.ok(typeof output.fast_mode === 'boolean',
`${label}: fast_mode must be a boolean`);
assert.ok(typeof output.fast_mode_supported === 'boolean',
`${label}: fast_mode_supported must be a boolean`);
}
test('gsd-planner (default claude runtime): full contract + known-agent shape', () => {
const result = runGsdTools(['resolve-execution', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assertFullContract(output, 'gsd-planner/claude');
assert.strictEqual(output.effort_param, 'output_config.effort');
assert.strictEqual(output.effort_propagation, 'frontmatter');
assert.strictEqual(output.fast_mode_supported, false);
// known agent must NOT have unknown_agent:true
assert.ok(!output.unknown_agent, 'known agent must not have unknown_agent:true');
});
test('codex runtime: full contract + effort_param=model_reasoning_effort', () => {
writeConfig(tmpDir, { runtime: 'codex' });
const result = runGsdTools(['resolve-execution', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assertFullContract(output, 'gsd-planner/codex');
assert.strictEqual(output.effort_param, 'model_reasoning_effort');
assert.strictEqual(output.fast_mode_supported, false);
});
test('gemini runtime: full contract + effort_param===null (no effort wire)', () => {
writeConfig(tmpDir, { runtime: 'gemini' });
const result = runGsdTools(['resolve-execution', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assertFullContract(output, 'gsd-planner/gemini');
assert.strictEqual(output.effort_param, null);
assert.strictEqual(output.effort_propagation, null);
assert.strictEqual(output.fast_mode_supported, false);
});
test('unknown agent: full contract + unknown_agent===true', () => {
const result = runGsdTools(['resolve-execution', 'unknown-agent-xyz'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assertFullContract(output, 'unknown-agent-xyz');
assert.strictEqual(output.unknown_agent, true, 'unknown agent must have unknown_agent:true');
});
});
// ─── (d) TOTALITY across the real 33-agent registry ──────────────────────────
describe('#443 integration (d): totality across real registry', () => {
let tmpDir;
before(() => { tmpDir = createTempProject(); });
after(() => { cleanup(tmpDir); });
const registeredAgents = Object.keys(catalog.agents);
// Confirm we're covering the full registry — snapshot the count so a
// catalog shrink is caught by this assertion.
test(`registry has at least 33 agents (currently ${registeredAgents.length})`, () => {
assert.ok(registeredAgents.length >= 33,
`Expected at least 33 agents in registry, got ${registeredAgents.length}`);
});
test(`all ${registeredAgents.length} agents: resolveEffortInternal returns a VALID_EFFORTS member`, () => {
const effortSet = new Set(VALID_EFFORTS);
const bad = [];
for (const agent of registeredAgents) {
const effort = resolveEffortInternal(tmpDir, agent);
if (effort === undefined || effort === null || !effortSet.has(effort)) {
bad.push(`${agent}: got ${JSON.stringify(effort)}`);
}
}
assert.strictEqual(bad.length, 0,
`Agents with invalid effort:\n${bad.join('\n')}`);
});
test(`all ${registeredAgents.length} agents: resolveFastModeInternal returns strict boolean`, () => {
const bad = [];
for (const agent of registeredAgents) {
const fm = resolveFastModeInternal(tmpDir, agent);
if (typeof fm !== 'boolean') {
bad.push(`${agent}: got ${JSON.stringify(fm)} (${typeof fm})`);
}
}
assert.strictEqual(bad.length, 0,
`Agents with non-boolean fast_mode:\n${bad.join('\n')}`);
});
test(`all ${registeredAgents.length} agents: renderEffortForRuntime('claude', effort) stays in claude enum`, () => {
const claudeEnum = PROVIDER_EFFORT_ENUMS.claude;
const bad = [];
for (const agent of registeredAgents) {
const effort = resolveEffortInternal(tmpDir, agent);
const rendered = renderEffortForRuntime('claude', effort);
if (!claudeEnum.has(rendered.value)) {
bad.push(`${agent}: effort=${effort} rendered=${rendered.value} not in claude enum`);
}
}
assert.strictEqual(bad.length, 0,
`Agents producing invalid claude effort:\n${bad.join('\n')}`);
});
});
// ─── (e) FAST-MODE HONESTY INVARIANT ─────────────────────────────────────────
describe('#443 integration (e): fast-mode honesty invariant', () => {
let tmpDir;
beforeEach(() => { tmpDir = createTempProject(); });
afterEach(() => { cleanup(tmpDir); });
// Sample of agents across all tiers to prove the invariant is not agent-specific
const testAgents = ['gsd-planner', 'gsd-executor', 'gsd-codebase-mapper', 'gsd-verifier'];
test('claude runtime: fast_mode_supported is ALWAYS false regardless of fast_mode config', () => {
const configs = [
{},
{ fast_mode: { enabled: true } },
{ fast_mode: { routing_tier_defaults: { heavy: true } } },
{ fast_mode: { agent_overrides: { 'gsd-planner': true } } },
];
for (const config of configs) {
writeConfig(tmpDir, config);
for (const agent of testAgents) {
const result = runGsdTools(['resolve-execution', agent], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed for ${agent}: ${result.error}`);
const output = JSON.parse(result.output);
assert.strictEqual(output.fast_mode_supported, false,
`claude/${agent}: fast_mode_supported must be false (Claude has no per-subagent fast-mode mechanism); config=${JSON.stringify(config)}`);
}
}
});
test("RUNTIMES_WITH_FAST_MODE.has('api') === true (api is the only fast-mode capable runtime)", () => {
assert.ok(RUNTIMES_WITH_FAST_MODE.has('api'),
"RUNTIMES_WITH_FAST_MODE must include 'api' — this is the only runtime with per-call fast_mode support");
});
test("RUNTIMES_WITH_FAST_MODE.has('claude') === false (claude fast-mode is session-level only)", () => {
assert.ok(!RUNTIMES_WITH_FAST_MODE.has('claude'),
"RUNTIMES_WITH_FAST_MODE must NOT include 'claude' — emitting fast_mode frontmatter on a Claude subagent is a silent no-op");
});
test("RUNTIMES_WITH_FAST_MODE.has('codex') === false", () => {
assert.ok(!RUNTIMES_WITH_FAST_MODE.has('codex'),
"codex does not support per-call fast_mode");
});
test("RUNTIMES_WITH_FAST_MODE.has('gemini') === false", () => {
assert.ok(!RUNTIMES_WITH_FAST_MODE.has('gemini'),
"gemini does not support per-call fast_mode");
});
});
// ─── (f) PRECEDENCE MATRIX ───────────────────────────────────────────────────
describe('#443 integration (f): precedence matrix (property/table-driven)', () => {
let tmpDir;
beforeEach(() => { tmpDir = createTempProject(); });
afterEach(() => { cleanup(tmpDir); });
// Effort: first-valid-wins from highest precedence to lowest
// 1. opts.override (invocation)
// 2. effort.agent_overrides.<agent>
// 3. effort.routing_tier_defaults.<tier>
// 4. effort.default
// 5. manifest tier default
// 6. hardcoded 'high'
const effortPrecedenceTable = [
{
label: 'layer 1 (invocation override) beats all',
config: {
effort: {
agent_overrides: { 'gsd-planner': 'low' },
routing_tier_defaults: { heavy: 'medium' },
default: 'xhigh',
},
},
opts: { override: 'minimal' },
expected: 'minimal',
},
{
label: 'layer 2 (agent_override) beats tier default and default',
config: {
effort: {
agent_overrides: { 'gsd-planner': 'low' },
routing_tier_defaults: { heavy: 'medium' },
default: 'xhigh',
},
},
opts: {},
expected: 'low',
},
{
label: 'layer 3 (routing_tier_defaults) beats effort.default',
config: {
effort: {
routing_tier_defaults: { heavy: 'medium' },
default: 'xhigh',
},
},
opts: {},
expected: 'medium',
},
{
label: 'layer 4 (effort.default) when no tier default set',
config: {
effort: { default: 'low' },
},
opts: {},
expected: 'low',
},
{
label: 'invalid layer 1 (turbo) falls through to layer 2 (agent_override)',
config: {
effort: { agent_overrides: { 'gsd-planner': 'medium' } },
},
opts: { override: 'turbo' },
expected: 'medium',
},
{
label: 'invalid layer 2 (agent_override=123 numeric) falls through to tier default',
config: {
effort: {
agent_overrides: { 'gsd-planner': 123 },
routing_tier_defaults: { heavy: 'high' },
},
},
opts: {},
expected: 'high',
},
{
label: 'invalid tier default (turbo) falls through to effort.default',
config: {
effort: {
routing_tier_defaults: { heavy: 'turbo' },
default: 'low',
},
},
opts: {},
expected: 'low',
},
];
for (const row of effortPrecedenceTable) {
test(`effort precedence: ${row.label}`, () => {
writeConfig(tmpDir, row.config);
const result = resolveEffortInternal(tmpDir, 'gsd-planner', row.opts);
assert.strictEqual(result, row.expected,
`Expected '${row.expected}', got '${result}' — config: ${JSON.stringify(row.config)}`);
});
}
// fast_mode precedence:
// 1. opts.override (strict boolean only)
// 2. fast_mode.agent_overrides.<agent> (strict boolean only)
// 3. fast_mode.routing_tier_defaults.<tier> (strict boolean only)
// 4. fast_mode.enabled (strict boolean only)
// 5. false
const fastModePrecedenceTable = [
{
label: 'layer 1 (opts.override=false) beats enabled=true',
config: { fast_mode: { enabled: true } },
opts: { override: false },
expected: false,
},
{
label: 'layer 2 (agent_override=true) beats tier default',
config: {
fast_mode: {
agent_overrides: { 'gsd-planner': true },
routing_tier_defaults: { heavy: false },
enabled: false,
},
},
opts: {},
expected: true,
},
{
label: 'layer 3 (tier default=true) beats enabled=false',
config: {
fast_mode: {
routing_tier_defaults: { heavy: true },
enabled: false,
},
},
opts: {},
expected: true,
},
{
label: 'layer 4 (enabled=true) when no tier/agent overrides',
config: { fast_mode: { enabled: true } },
opts: {},
expected: true,
},
{
label: 'layer 5 (default false) when all absent',
config: {},
opts: {},
expected: false,
},
{
label: 'string "true" in opts.override is NOT accepted (falls through)',
config: { fast_mode: { enabled: true } },
// override must be strict boolean; string falls through to next layer
opts: { override: 'true' },
// 'true' as string is not boolean -> falls through to tier default
// gsd-planner is heavy; no tier default set; falls to enabled=true
expected: true,
},
{
label: 'string "true" in agent_overrides is NOT accepted',
config: {
fast_mode: {
agent_overrides: { 'gsd-planner': 'true' },
enabled: false,
},
},
opts: {},
// string 'true' is not boolean -> fall through to tier default -> enabled=false -> false
expected: false,
},
];
for (const row of fastModePrecedenceTable) {
test(`fast_mode precedence: ${row.label}`, () => {
writeConfig(tmpDir, row.config);
const result = resolveFastModeInternal(tmpDir, 'gsd-planner', row.opts);
assert.strictEqual(result, row.expected,
`Expected ${row.expected}, got ${result} — config: ${JSON.stringify(row.config)}`);
});
}
});
// ─── (g) DYNAMIC-ROUTING COMPOSITION ─────────────────────────────────────────
describe('#443 integration (g): dynamic-routing composition', () => {
let tmpDir;
beforeEach(() => { tmpDir = createTempProject(); });
afterEach(() => { cleanup(tmpDir); });
const dynamicRoutingBase = {
dynamic_routing: {
enabled: true,
tier_models: { light: 'haiku', standard: 'sonnet', heavy: 'opus' },
escalate_on_failure: true,
max_escalations: 4,
},
effort: { routing_tier_defaults: { light: 'low' } },
};
test('resolveEffortForTier escalates independently of model resolution', () => {
writeConfig(tmpDir, dynamicRoutingBase);
const effort0 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 0);
const effort1 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 1);
const effort2 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 2);
assert.strictEqual(effort0, 'low');
assert.strictEqual(effort1, 'medium');
assert.strictEqual(effort2, 'high');
// Verify the effort ladder steps up correctly without asserting model value
// (model timing is a separate concern from effort escalation)
assert.notStrictEqual(effort0, effort1, 'effort should escalate at attempt 1');
assert.notStrictEqual(effort1, effort2, 'effort should escalate at attempt 2');
});
test('escalate_on_failure=false: attempt is ignored for effort', () => {
writeConfig(tmpDir, {
...dynamicRoutingBase,
dynamic_routing: {
...dynamicRoutingBase.dynamic_routing,
escalate_on_failure: false,
},
});
const e0 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 0);
const e1 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 1);
const e3 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 3);
assert.strictEqual(e0, e1, 'effort must not escalate when escalate_on_failure=false');
assert.strictEqual(e0, e3, 'effort must not escalate when escalate_on_failure=false');
});
test('escalation clamps at "max" regardless of attempt number', () => {
writeConfig(tmpDir, {
dynamic_routing: {
enabled: true,
tier_models: { light: 'haiku', standard: 'sonnet', heavy: 'opus' },
escalate_on_failure: true,
max_escalations: 99,
},
effort: { default: 'max' },
});
// Any large attempt number — result must never exceed 'max'
const r = resolveEffortForTier(tmpDir, 'gsd-planner', 50);
assert.strictEqual(r, 'max', `Effort must clamp at 'max', got '${r}'`);
const EFFORT_LADDER = VALID_EFFORTS;
const maxIdx = EFFORT_LADDER.indexOf('max');
const rIdx = EFFORT_LADDER.indexOf(r);
assert.ok(rIdx <= maxIdx, 'Effort must not exceed the max position in the ladder');
});
test('respects max_escalations cap: attempt beyond cap gives same as cap', () => {
writeConfig(tmpDir, {
dynamic_routing: {
enabled: true,
tier_models: { light: 'haiku', standard: 'sonnet', heavy: 'opus' },
escalate_on_failure: true,
max_escalations: 1,
},
effort: { routing_tier_defaults: { light: 'low' } },
});
const atCap = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 1); // 1 escalation
const beyond = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 5); // capped at 1
assert.strictEqual(atCap, beyond,
'Effort beyond max_escalations must be same as at cap');
assert.strictEqual(atCap, 'medium', 'low + 1 escalation = medium');
});
test('dynamic_routing disabled: resolveEffortForTier ignores attempt', () => {
writeConfig(tmpDir, {
effort: { routing_tier_defaults: { light: 'low' } },
});
const e0 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 0);
const e5 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 5);
assert.strictEqual(e0, e5, 'Effort must not change when dynamic_routing is disabled');
assert.strictEqual(e0, 'low');
});
});
// ─── (h) CONFIG-TOOLING ROUND-TRIP ───────────────────────────────────────────
describe('#443 integration (h): config-tooling round-trip', () => {
let tmpDir;
beforeEach(() => { tmpDir = createTempProject(); });
afterEach(() => { cleanup(tmpDir); });
test('config-set effort.default then resolve-execution reflects new value', () => {
const setResult = runGsdTools(['config-set', 'effort.default', 'low'], tmpDir, { HOME: tmpDir });
assert.ok(setResult.success, `config-set effort.default failed: ${setResult.error}`);
const execResult = runGsdTools(['resolve-execution', 'unknown-agent-xyz'], tmpDir, { HOME: tmpDir });
assert.ok(execResult.success, `resolve-execution failed: ${execResult.error}`);
const output = JSON.parse(execResult.output);
// unknown agent falls through to effort.default
assert.strictEqual(output.effort, 'low',
`Expected effort='low' after config-set, got '${output.effort}'`);
});
test('config-set effort.routing_tier_defaults.heavy then resolve-execution uses it', () => {
const setResult = runGsdTools(
['config-set', 'effort.routing_tier_defaults.heavy', 'medium'],
tmpDir, { HOME: tmpDir }
);
assert.ok(setResult.success, `config-set failed: ${setResult.error}`);
const execResult = runGsdTools(['resolve-execution', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(execResult.success, `resolve-execution failed: ${execResult.error}`);
const output = JSON.parse(execResult.output);
// gsd-planner is heavy; tier default now overridden to medium
assert.strictEqual(output.effort, 'medium',
`Expected effort='medium' after routing_tier_defaults override, got '${output.effort}'`);
});
test('config-set effort.agent_overrides.<agent> wins over tier default', () => {
// Set tier default first, then per-agent override
runGsdTools(['config-set', 'effort.routing_tier_defaults.heavy', 'medium'], tmpDir, { HOME: tmpDir });
const setResult = runGsdTools(
['config-set', 'effort.agent_overrides.gsd-planner', 'xhigh'],
tmpDir, { HOME: tmpDir }
);
assert.ok(setResult.success, `config-set agent_overrides failed: ${setResult.error}`);
const execResult = runGsdTools(['resolve-execution', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(execResult.success, `resolve-execution failed: ${execResult.error}`);
const output = JSON.parse(execResult.output);
assert.strictEqual(output.effort, 'xhigh',
`Expected agent_overrides to win (xhigh), got '${output.effort}'`);
});
test('config-set fast_mode.enabled true then resolve-execution reflects fast_mode=true', () => {
const setResult = runGsdTools(['config-set', 'fast_mode.enabled', 'true'], tmpDir, { HOME: tmpDir });
assert.ok(setResult.success, `config-set fast_mode.enabled failed: ${setResult.error}`);
const execResult = runGsdTools(['resolve-execution', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(execResult.success, `resolve-execution failed: ${execResult.error}`);
const output = JSON.parse(execResult.output);
assert.strictEqual(output.fast_mode, true,
`Expected fast_mode=true after config-set, got ${output.fast_mode}`);
// fast_mode_supported stays false (claude runtime)
assert.strictEqual(output.fast_mode_supported, false);
});
test('config-set fast_mode.agent_overrides.<agent> true reflects in output', () => {
const setResult = runGsdTools(
['config-set', 'fast_mode.agent_overrides.gsd-codebase-mapper', 'true'],
tmpDir, { HOME: tmpDir }
);
assert.ok(setResult.success, `config-set failed: ${setResult.error}`);
const execResult = runGsdTools(['resolve-execution', 'gsd-codebase-mapper'], tmpDir, { HOME: tmpDir });
assert.ok(execResult.success, `resolve-execution failed: ${execResult.error}`);
const output = JSON.parse(execResult.output);
assert.strictEqual(output.fast_mode, true,
`Expected fast_mode=true for agent-specific override`);
});
// Prove the config-set commands accept all the new key namespaces (schema validation)
test('config-set accepts all effort/* and fast_mode/* key namespaces without error', () => {
const keysToTest = [
['effort.default', 'high'],
['effort.routing_tier_defaults.light', 'low'],
['effort.routing_tier_defaults.standard', 'medium'],
['effort.routing_tier_defaults.heavy', 'xhigh'],
['effort.agent_overrides.gsd-executor', 'high'],
['fast_mode.enabled', 'false'],
['fast_mode.routing_tier_defaults.light', 'false'],
['fast_mode.routing_tier_defaults.standard', 'false'],
['fast_mode.routing_tier_defaults.heavy', 'false'],
['fast_mode.agent_overrides.gsd-verifier', 'false'],
];
for (const [key, val] of keysToTest) {
const r = runGsdTools(['config-set', key, val], tmpDir, { HOME: tmpDir });
assert.ok(r.success, `config-set '${key}' '${val}' should succeed, got: ${r.error}`);
}
});
});

View File

@@ -0,0 +1,862 @@
'use strict';
/**
* Feature test for issue #443 — unified cross-provider effort + fast_mode knobs.
*
* Adds config-driven effort (universal ladder: minimal<low<medium<high<xhigh<max)
* and fast_mode knobs. Per-runtime rendering clamps the unique tails:
* - Anthropic/Claude: supports {low,medium,high,xhigh,max}, param=output_config.effort
* - Codex: supports {minimal,low,medium,high,xhigh}, param=model_reasoning_effort
*
* Also adds resolve-execution query which is the superset command including
* effort rendering and fast_mode propagation metadata.
*/
process.env.GSD_TEST_MODE = '1';
const { describe, test, beforeEach, afterEach } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { createTempProject, createTempDir, cleanup, runGsdTools } = require('./helpers.cjs');
const {
resolveEffortInternal,
resolveFastModeInternal,
resolveEffortForTier,
} = require('../get-shit-done/bin/lib/core.cjs');
const {
renderEffortForRuntime,
RUNTIMES_WITH_FAST_MODE,
} = require('../get-shit-done/bin/lib/model-catalog.cjs');
const {
injectEffortFrontmatter,
} = require('../bin/install.js');
function writeConfig(dir, config) {
const planningDir = path.join(dir, '.planning');
fs.mkdirSync(planningDir, { recursive: true });
fs.writeFileSync(path.join(planningDir, 'config.json'), JSON.stringify(config, null, 2));
}
// ─── Effort cascade ───────────────────────────────────────────────────────────
describe('#443 effort cascade', () => {
let tmpDir;
beforeEach(() => { tmpDir = createTempProject(); });
afterEach(() => { cleanup(tmpDir); });
test('no config -> gsd-planner (heavy) defaults to "xhigh" via tier default', () => {
// gsd-planner is heavy tier; manifest default for heavy is xhigh
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'xhigh');
});
test('routing_tier_defaults: light (gsd-codebase-mapper) -> "low"', () => {
// gsd-codebase-mapper routingTier=light, default for light is "low"
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-codebase-mapper'), 'low');
});
test('routing_tier_defaults: standard (gsd-executor) -> "high"', () => {
// gsd-executor routingTier=standard, default for standard is "high"
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-executor'), 'high');
});
test('routing_tier_defaults: heavy (gsd-planner) -> "xhigh"', () => {
// gsd-planner routingTier=heavy, default for heavy is "xhigh"
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'xhigh');
});
test('effort.routing_tier_defaults override beats tier default', () => {
writeConfig(tmpDir, {
effort: { routing_tier_defaults: { heavy: 'medium' } },
});
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'medium');
});
test('effort.agent_overrides beats routing_tier_defaults', () => {
writeConfig(tmpDir, {
effort: {
routing_tier_defaults: { heavy: 'medium' },
agent_overrides: { 'gsd-planner': 'low' },
},
});
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'low');
});
test('opts.override beats agent_overrides', () => {
writeConfig(tmpDir, {
effort: { agent_overrides: { 'gsd-planner': 'low' } },
});
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner', { override: 'minimal' }), 'minimal');
});
test('invalid override falls through to agent_overrides', () => {
writeConfig(tmpDir, {
effort: { agent_overrides: { 'gsd-planner': 'low' } },
});
// 'turbo' is not a valid effort — should fall through to agent_overrides
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner', { override: 'turbo' }), 'low');
});
test('invalid agent_overrides value falls through to routing_tier_defaults', () => {
writeConfig(tmpDir, {
effort: {
agent_overrides: { 'gsd-planner': 123 },
routing_tier_defaults: { heavy: 'medium' },
},
});
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'medium');
});
test('invalid routing_tier_defaults value falls through to effort.default', () => {
writeConfig(tmpDir, {
effort: {
routing_tier_defaults: { heavy: 'turbo' },
default: 'low',
},
});
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'low');
});
test('invalid effort.default falls through to hardcoded "high" (no routing_tier_defaults set)', () => {
writeConfig(tmpDir, {
effort: { default: 'turbo' },
});
// effortCfg set but no routing_tier_defaults; turbo is invalid; fallback = hardcoded 'high'
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'high');
});
test('unknown agent -> uses effort.default', () => {
writeConfig(tmpDir, {
effort: { default: 'medium' },
});
// unknown-agent has no routingTier, so step 3 skipped
assert.strictEqual(resolveEffortInternal(tmpDir, 'unknown-agent-xyz'), 'medium');
});
test('effort.default numeric value (123) ignored, hardcoded "high" fallback', () => {
writeConfig(tmpDir, {
effort: { default: 123 },
});
// effortCfg set, no routing_tier_defaults -> no tier default; numeric ignored -> 'high'
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'high');
});
test('effort block missing entirely -> uses tier default', () => {
// No effort key in config at all
writeConfig(tmpDir, { model_profile: 'balanced' });
// heavy agent: tier default xhigh
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'xhigh');
});
test('effort block is non-object (string) -> effortCfg=null -> uses manifest tier default xhigh', () => {
writeConfig(tmpDir, { effort: 'bad' });
// Non-object effort => effortCfg=null; gsd-planner heavy tier manifest default = xhigh
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'xhigh');
});
test('effort.routing_tier_defaults empty object -> effort.default', () => {
writeConfig(tmpDir, {
effort: { routing_tier_defaults: {}, default: 'low' },
});
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'low');
});
});
// ─── Fast mode cascade ────────────────────────────────────────────────────────
describe('#443 fast_mode cascade', () => {
let tmpDir;
beforeEach(() => { tmpDir = createTempProject(); });
afterEach(() => { cleanup(tmpDir); });
test('no config -> defaults to false', () => {
assert.strictEqual(resolveFastModeInternal(tmpDir, 'gsd-planner'), false);
});
test('fast_mode.enabled=true -> true when no tier/agent overrides', () => {
writeConfig(tmpDir, { fast_mode: { enabled: true } });
// heavy agent: tier default is false, but enabled=true is layer 4
// tier default for heavy is false (below enabled), so gets enabled=true
// Wait — the cascade is: 1.override 2.agent_overrides 3.tier_defaults 4.enabled 5.false
// For gsd-planner (heavy), tier default is false — falls through to enabled=true
assert.strictEqual(resolveFastModeInternal(tmpDir, 'gsd-planner'), true);
});
test('fast_mode.routing_tier_defaults.light=true -> light agent gets true', () => {
writeConfig(tmpDir, {
fast_mode: { routing_tier_defaults: { light: true } },
});
assert.strictEqual(resolveFastModeInternal(tmpDir, 'gsd-codebase-mapper'), true);
});
test('fast_mode.routing_tier_defaults.heavy=false -> heavy agent stays false', () => {
writeConfig(tmpDir, {
fast_mode: { enabled: true, routing_tier_defaults: { heavy: false } },
});
assert.strictEqual(resolveFastModeInternal(tmpDir, 'gsd-planner'), false);
});
test('fast_mode.agent_overrides beats routing_tier_defaults', () => {
writeConfig(tmpDir, {
fast_mode: {
routing_tier_defaults: { light: false },
agent_overrides: { 'gsd-codebase-mapper': true },
},
});
assert.strictEqual(resolveFastModeInternal(tmpDir, 'gsd-codebase-mapper'), true);
});
test('opts.override beats agent_overrides', () => {
writeConfig(tmpDir, {
fast_mode: { agent_overrides: { 'gsd-planner': true } },
});
assert.strictEqual(resolveFastModeInternal(tmpDir, 'gsd-planner', { override: false }), false);
});
test('string "true" NOT accepted as fast_mode override', () => {
writeConfig(tmpDir, {
fast_mode: { agent_overrides: { 'gsd-planner': 'true' } },
});
// string "true" is not boolean -> fall through to tier default or enabled
const result = resolveFastModeInternal(tmpDir, 'gsd-planner');
assert.strictEqual(typeof result, 'boolean');
});
test('string "true" in opts.override NOT accepted', () => {
// opts.override must be strict boolean — string falls through
const result = resolveFastModeInternal(tmpDir, 'gsd-planner', { override: 'true' });
assert.strictEqual(result, false);
});
test('fast_mode block missing entirely -> defaults to false', () => {
writeConfig(tmpDir, { model_profile: 'balanced' });
assert.strictEqual(resolveFastModeInternal(tmpDir, 'gsd-planner'), false);
});
test('fast_mode.enabled="yes" (non-boolean) ignored -> false', () => {
writeConfig(tmpDir, { fast_mode: { enabled: 'yes' } });
assert.strictEqual(resolveFastModeInternal(tmpDir, 'gsd-planner'), false);
});
test('unknown agent fast_mode -> uses enabled flag', () => {
writeConfig(tmpDir, { fast_mode: { enabled: true } });
assert.strictEqual(resolveFastModeInternal(tmpDir, 'unknown-agent-xyz'), true);
});
});
// ─── Effort escalation (resolveEffortForTier) ─────────────────────────────────
describe('#443 resolveEffortForTier escalation', () => {
let tmpDir;
beforeEach(() => { tmpDir = createTempProject(); });
afterEach(() => { cleanup(tmpDir); });
test('dynamic_routing disabled -> attempt ignored, returns base effort', () => {
// gsd-planner heavy -> xhigh baseline
const base = resolveEffortForTier(tmpDir, 'gsd-planner', 0);
const attempt1 = resolveEffortForTier(tmpDir, 'gsd-planner', 1);
assert.strictEqual(base, 'xhigh');
assert.strictEqual(attempt1, 'xhigh'); // no dynamic_routing -> attempt ignored
});
test('dynamic_routing enabled, escalate_on_failure=false -> attempt ignored', () => {
writeConfig(tmpDir, {
dynamic_routing: {
enabled: true,
tier_models: { light: 'haiku', standard: 'sonnet', heavy: 'opus' },
escalate_on_failure: false,
max_escalations: 2,
},
});
const base = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 0);
const attempt1 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 1);
assert.strictEqual(base, attempt1);
});
test('dynamic_routing enabled, attempt=1 -> one step up from base', () => {
writeConfig(tmpDir, {
dynamic_routing: {
enabled: true,
tier_models: { light: 'haiku', standard: 'sonnet', heavy: 'opus' },
escalate_on_failure: true,
max_escalations: 2,
},
effort: { routing_tier_defaults: { light: 'low' } },
});
// gsd-codebase-mapper: light -> effort 'low'; attempt=1 -> 'medium'
assert.strictEqual(resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 0), 'low');
assert.strictEqual(resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 1), 'medium');
});
test('escalation clamps at "max"', () => {
writeConfig(tmpDir, {
dynamic_routing: {
enabled: true,
tier_models: { light: 'haiku', standard: 'sonnet', heavy: 'opus' },
escalate_on_failure: true,
max_escalations: 99,
},
effort: { default: 'xhigh' },
});
// xhigh -> max -> max (clamp)
const result = resolveEffortForTier(tmpDir, 'gsd-planner', 99);
assert.strictEqual(result, 'max');
});
test('respects max_escalations cap', () => {
writeConfig(tmpDir, {
dynamic_routing: {
enabled: true,
tier_models: { light: 'haiku', standard: 'sonnet', heavy: 'opus' },
escalate_on_failure: true,
max_escalations: 1,
},
effort: { routing_tier_defaults: { light: 'low' } },
});
// light: low -> attempt=1 -> medium (but max=1 so can only escalate once)
const at1 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 1);
const at2 = resolveEffortForTier(tmpDir, 'gsd-codebase-mapper', 2);
// at2 is capped at 1 escalation, same as at1
assert.strictEqual(at1, at2);
assert.strictEqual(at1, 'medium');
});
});
// ─── Rendering / clamping ──────────────────────────────────────────────────────
describe('#443 renderEffortForRuntime', () => {
test('codex: "max" clamps to "xhigh"', () => {
const r = renderEffortForRuntime('codex', 'max');
assert.strictEqual(r.value, 'xhigh');
assert.strictEqual(r.param, 'model_reasoning_effort');
});
test('codex: common levels passthrough', () => {
assert.strictEqual(renderEffortForRuntime('codex', 'low').value, 'low');
assert.strictEqual(renderEffortForRuntime('codex', 'medium').value, 'medium');
assert.strictEqual(renderEffortForRuntime('codex', 'high').value, 'high');
assert.strictEqual(renderEffortForRuntime('codex', 'xhigh').value, 'xhigh');
});
test('codex: "minimal" passthrough', () => {
assert.strictEqual(renderEffortForRuntime('codex', 'minimal').value, 'minimal');
});
test('claude: "minimal" clamps to "low"', () => {
const r = renderEffortForRuntime('claude', 'minimal');
assert.strictEqual(r.value, 'low');
assert.strictEqual(r.param, 'output_config.effort');
});
test('claude: "max" passthrough (Anthropic-only)', () => {
const r = renderEffortForRuntime('claude', 'max');
assert.strictEqual(r.value, 'max');
assert.strictEqual(r.param, 'output_config.effort');
});
test('claude: common levels passthrough', () => {
assert.strictEqual(renderEffortForRuntime('claude', 'low').value, 'low');
assert.strictEqual(renderEffortForRuntime('claude', 'medium').value, 'medium');
assert.strictEqual(renderEffortForRuntime('claude', 'high').value, 'high');
assert.strictEqual(renderEffortForRuntime('claude', 'xhigh').value, 'xhigh');
});
test('unknown runtime: param is null, value passthrough', () => {
const r = renderEffortForRuntime('unknown-runtime', 'high');
assert.strictEqual(r.param, null);
assert.strictEqual(r.value, 'high');
});
test('RUNTIMES_WITH_FAST_MODE does NOT include "claude"', () => {
// Claude Code has no per-subagent fast-mode mechanism — session-level only
assert.ok(!RUNTIMES_WITH_FAST_MODE.has('claude'),
'claude must NOT be in RUNTIMES_WITH_FAST_MODE — emitting fast_mode frontmatter is a silent no-op');
});
});
// ─── resolve-execution end-to-end ─────────────────────────────────────────────
describe('#443 resolve-execution CLI command', () => {
let tmpDir;
beforeEach(() => {
tmpDir = createTempProject();
// HOME isolation to prevent ~/.gsd/defaults.json bleed
process.env._GSD_TEST_HOME_OVERRIDE = tmpDir;
});
afterEach(() => {
cleanup(tmpDir);
delete process.env._GSD_TEST_HOME_OVERRIDE;
});
test('default (claude) runtime -> effort present, effort_param=output_config.effort, fast_mode_supported=false', () => {
const result = runGsdTools(['resolve-execution', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assert.ok(output.effort, 'should have effort field');
assert.strictEqual(output.effort_param, 'output_config.effort');
assert.strictEqual(output.fast_mode_supported, false);
assert.ok('fast_mode' in output, 'should have fast_mode field');
assert.ok('model' in output, 'should have model field');
assert.ok('profile' in output, 'should have profile field');
});
test('codex runtime -> effort_param=model_reasoning_effort, max clamps to xhigh, fast_mode_supported=false', () => {
writeConfig(tmpDir, {
runtime: 'codex',
effort: { default: 'max' },
});
const result = runGsdTools(['resolve-execution', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assert.strictEqual(output.effort_param, 'model_reasoning_effort');
assert.strictEqual(output.effort_rendered, 'xhigh');
// fast_mode_supported: codex does not support fast mode via subagent
assert.strictEqual(output.fast_mode_supported, false);
});
test('--effort flag overrides config effort', () => {
const result = runGsdTools(
['resolve-execution', 'gsd-planner', '--effort', 'low'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assert.strictEqual(output.effort, 'low');
});
test('--fast-mode flag honored', () => {
const result = runGsdTools(
['resolve-execution', 'gsd-planner', '--fast-mode', 'true'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assert.strictEqual(output.fast_mode, true);
});
test('--attempt flag triggers escalation', () => {
writeConfig(tmpDir, {
dynamic_routing: {
enabled: true,
tier_models: { light: 'haiku', standard: 'sonnet', heavy: 'opus' },
escalate_on_failure: true,
max_escalations: 2,
},
effort: { routing_tier_defaults: { light: 'low' } },
});
const result0 = runGsdTools(
['resolve-execution', 'gsd-codebase-mapper', '--attempt', '0'],
tmpDir,
{ HOME: tmpDir }
);
const result1 = runGsdTools(
['resolve-execution', 'gsd-codebase-mapper', '--attempt', '1'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(result0.success && result1.success);
const out0 = JSON.parse(result0.output);
const out1 = JSON.parse(result1.output);
assert.strictEqual(out0.effort, 'low');
assert.strictEqual(out1.effort, 'medium');
});
test('--raw prints effort string', () => {
const result = runGsdTools(
['resolve-execution', 'gsd-planner', '--raw'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(result.success, `Command failed: ${result.error}`);
// Raw output should be the effort string
const VALID_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
assert.ok(VALID_EFFORTS.includes(result.output.trim()),
`Expected effort string, got: ${result.output}`);
});
test('fails when no agent-type provided', () => {
const result = runGsdTools(['resolve-execution'], tmpDir, { HOME: tmpDir });
assert.ok(!result.success, 'should fail without agent-type');
assert.ok(result.error.includes('agent-type required'), `error: ${result.error}`);
});
test('unknown agent -> unknown_agent=true still emits effort', () => {
const result = runGsdTools(['resolve-execution', 'unknown-agent-xyz'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assert.strictEqual(output.unknown_agent, true);
assert.ok(output.effort, 'should have effort even for unknown agent');
});
test('emits effort_propagation (channel) field', () => {
const result = runGsdTools(['resolve-execution', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assert.ok('effort_propagation' in output, 'should have effort_propagation field');
});
});
// ─── resolve-model now emits effort (replaces reasoning_effort) ───────────────
describe('#443 resolve-model emits effort (unified)', () => {
let tmpDir;
beforeEach(() => { tmpDir = createTempProject(); });
afterEach(() => { cleanup(tmpDir); });
test('resolve-model on claude runtime emits effort (not null)', () => {
const result = runGsdTools(['resolve-model', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
// effort must be present and valid
const VALID_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
assert.ok(VALID_EFFORTS.includes(output.effort),
`Expected valid effort, got: ${output.effort}`);
// reasoning_effort must NOT be present (removed)
assert.ok(!Object.prototype.hasOwnProperty.call(output, 'reasoning_effort'),
'resolve-model must not emit reasoning_effort (replaced by effort)');
});
test('resolve-model on codex runtime emits unified effort (not reasoning_effort)', () => {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'config.json'),
JSON.stringify({ runtime: 'codex', model_profile: 'balanced' })
);
const result = runGsdTools(['resolve-model', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
const VALID_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
assert.ok(VALID_EFFORTS.includes(output.effort),
`Expected valid effort, got: ${output.effort}`);
assert.ok(!Object.prototype.hasOwnProperty.call(output, 'reasoning_effort'),
'resolve-model must not emit reasoning_effort');
});
});
// ─── QA Matrix — hostile/malformed configs ───────────────────────────────────
describe('#443 QA matrix — malformed effort/fast_mode configs', () => {
let tmpDir;
beforeEach(() => { tmpDir = createTempProject(); });
afterEach(() => { cleanup(tmpDir); });
test('effort.default=123 (numeric) -> gracefully falls through', () => {
writeConfig(tmpDir, { effort: { default: 123 } });
// gsd-planner is heavy, tier default xhigh is used instead
const result = resolveEffortInternal(tmpDir, 'gsd-planner');
assert.ok(typeof result === 'string');
const VALID_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
assert.ok(VALID_EFFORTS.includes(result));
});
test('fast_mode.enabled="yes" (string) -> ignored, returns false', () => {
writeConfig(tmpDir, { fast_mode: { enabled: 'yes' } });
assert.strictEqual(resolveFastModeInternal(tmpDir, 'gsd-planner'), false);
});
test('effort:{} empty block -> uses tier default or hardcoded high', () => {
writeConfig(tmpDir, { effort: {} });
const result = resolveEffortInternal(tmpDir, 'gsd-planner');
const VALID_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
assert.ok(VALID_EFFORTS.includes(result));
});
test('fast_mode:{} empty block -> false', () => {
writeConfig(tmpDir, { fast_mode: {} });
assert.strictEqual(resolveFastModeInternal(tmpDir, 'gsd-planner'), false);
});
test('effort config is completely absent -> still resolves valid effort', () => {
writeConfig(tmpDir, { model_profile: 'quality' });
const result = resolveEffortInternal(tmpDir, 'gsd-planner');
const VALID_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
assert.ok(VALID_EFFORTS.includes(result));
});
test('effort.routing_tier_defaults has boolean value -> falls through', () => {
writeConfig(tmpDir, {
effort: {
routing_tier_defaults: { heavy: true },
default: 'medium',
},
});
// boolean true is not a valid effort -> falls through to default 'medium'
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'medium');
});
test('effort.agent_overrides is non-object -> falls through gracefully', () => {
writeConfig(tmpDir, {
effort: {
agent_overrides: 'not-an-object',
default: 'low',
},
});
// non-object agent_overrides -> skip step 2, use tier default (heavy=xhigh)
// actually heavy tier default kicks in first if no routing_tier_defaults
const result = resolveEffortInternal(tmpDir, 'gsd-planner');
const VALID_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
assert.ok(VALID_EFFORTS.includes(result));
});
test('config.json has unknown agent with effort.default set -> uses effort.default', () => {
writeConfig(tmpDir, { effort: { default: 'minimal' } });
assert.strictEqual(resolveEffortInternal(tmpDir, 'completely-unknown-agent-98765'), 'minimal');
});
test('resolve-execution with malformed config does not crash', () => {
writeConfig(tmpDir, {
effort: { default: null, routing_tier_defaults: null },
fast_mode: { enabled: null, agent_overrides: null },
});
const result = runGsdTools(['resolve-execution', 'gsd-planner'], tmpDir, { HOME: tmpDir });
assert.ok(result.success, `Should not crash with null config values: ${result.error}`);
});
});
// ─── Config schema: new keys are valid ───────────────────────────────────────
describe('#443 config schema: new effort/fast_mode keys valid', () => {
const { isValidConfigKey } = require('../get-shit-done/bin/lib/config-schema.cjs');
test('effort.default is a valid config key', () => {
assert.ok(isValidConfigKey('effort.default'), 'effort.default must be valid');
});
test('fast_mode.enabled is a valid config key', () => {
assert.ok(isValidConfigKey('fast_mode.enabled'), 'fast_mode.enabled must be valid');
});
test('effort.routing_tier_defaults.light is valid (dynamic pattern)', () => {
assert.ok(isValidConfigKey('effort.routing_tier_defaults.light'));
});
test('effort.routing_tier_defaults.standard is valid', () => {
assert.ok(isValidConfigKey('effort.routing_tier_defaults.standard'));
});
test('effort.routing_tier_defaults.heavy is valid', () => {
assert.ok(isValidConfigKey('effort.routing_tier_defaults.heavy'));
});
test('effort.agent_overrides.<agent-id> is valid (dynamic pattern)', () => {
assert.ok(isValidConfigKey('effort.agent_overrides.gsd-planner'));
assert.ok(isValidConfigKey('effort.agent_overrides.my-custom-agent'));
});
test('fast_mode.routing_tier_defaults.light is valid', () => {
assert.ok(isValidConfigKey('fast_mode.routing_tier_defaults.light'));
});
test('fast_mode.agent_overrides.<agent-id> is valid', () => {
assert.ok(isValidConfigKey('fast_mode.agent_overrides.gsd-planner'));
});
test('effort.routing_tier_defaults.invalid-tier is NOT valid', () => {
assert.ok(!isValidConfigKey('effort.routing_tier_defaults.super'));
});
});
// ─── resolve-execution arg parsing matrix (Codex adversarial finding #1) ──────
//
// These tests FAIL before the fix: flags-first ordering misroutes the agent.
describe('#443 resolve-execution: deterministic arg parsing (flags-first ordering)', () => {
let tmpDir;
beforeEach(() => {
tmpDir = createTempProject();
process.env._GSD_TEST_HOME_OVERRIDE = tmpDir;
});
afterEach(() => {
cleanup(tmpDir);
delete process.env._GSD_TEST_HOME_OVERRIDE;
});
test('flags-first: --effort low gsd-planner resolves gsd-planner (NOT "low" as agent)', () => {
// BUG: before fix, agentTypeArg = 'low' (first non-dash token) -> unknown_agent:true
const result = runGsdTools(
['resolve-execution', '--effort', 'low', 'gsd-planner'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assert.ok(!output.unknown_agent, `agent must be resolved (not unknown_agent), got: ${JSON.stringify(output)}`);
assert.strictEqual(output.effort, 'low', `effort should be low, got: ${output.effort}`);
});
test('flags-first: --attempt 1 gsd-codebase-mapper resolves gsd-codebase-mapper (NOT "1" as agent)', () => {
// BUG: before fix, agentTypeArg = '1' -> unknown_agent:true
const result = runGsdTools(
['resolve-execution', '--attempt', '1', 'gsd-codebase-mapper'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(result.success, `Command failed: ${result.error}`);
const output = JSON.parse(result.output);
assert.ok(!output.unknown_agent, `gsd-codebase-mapper must be resolved, got: ${JSON.stringify(output)}`);
});
test('agent-first parity: gsd-planner --effort low produces same effort as flags-first', () => {
const flagsFirst = runGsdTools(
['resolve-execution', '--effort', 'low', 'gsd-planner'],
tmpDir,
{ HOME: tmpDir }
);
const agentFirst = runGsdTools(
['resolve-execution', 'gsd-planner', '--effort', 'low'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(flagsFirst.success && agentFirst.success,
`Both orderings must succeed. flags-first err: ${flagsFirst.error} agent-first err: ${agentFirst.error}`);
const outFF = JSON.parse(flagsFirst.output);
const outAF = JSON.parse(agentFirst.output);
assert.strictEqual(outFF.effort, outAF.effort, 'effort must be identical for both orderings');
assert.strictEqual(outFF.model, outAF.model, 'model must be identical for both orderings');
});
test('error: missing agent (--effort low with no positional) -> non-zero exit, no stack trace', () => {
const result = runGsdTools(
['resolve-execution', '--effort', 'low'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(!result.success, 'must exit non-zero when agent is missing');
assert.ok(!result.error.includes('at '), `error must not contain stack trace, got: ${result.error}`);
assert.ok(result.error.length > 0, 'must emit an error message');
});
test('error: two positional agents -> non-zero exit', () => {
const result = runGsdTools(
['resolve-execution', 'gsd-planner', 'gsd-executor'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(!result.success, 'must exit non-zero when two agents are given');
});
test('error: --attempt notanumber -> non-zero exit, clear error', () => {
const result = runGsdTools(
['resolve-execution', '--attempt', 'notanumber', 'gsd-planner'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(!result.success, 'must exit non-zero for non-integer --attempt');
assert.ok(result.error.length > 0, 'must emit an error message');
});
test('error: trailing --effort (no value) -> non-zero exit', () => {
const result = runGsdTools(
['resolve-execution', 'gsd-planner', '--effort'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(!result.success, 'must exit non-zero for trailing --effort with no value');
assert.ok(result.error.length > 0, 'must emit an error message');
});
test('unknown agent positional -> unknown_agent:true (preserved behavior)', () => {
const result = runGsdTools(
['resolve-execution', 'totally-not-an-agent'],
tmpDir,
{ HOME: tmpDir }
);
assert.ok(result.success, `Should succeed (unknown agent is valid input): ${result.error}`);
const output = JSON.parse(result.output);
assert.strictEqual(output.unknown_agent, true, 'unknown agent must emit unknown_agent:true');
});
});
// ─── injectEffortFrontmatter: newline-agnostic injection (#443 Windows fix) ──
describe('#443 injectEffortFrontmatter: newline-agnostic YAML frontmatter injection', () => {
// LF source (macOS / Linux git checkout) — baseline
test('LF frontmatter: injects effort: before closing ---', () => {
const content = '---\nname: gsd-planner\ndescription: Creates plans\ncolor: blue\n---\nBody here\n';
const result = injectEffortFrontmatter(content, 'xhigh');
assert.notStrictEqual(result, content, 'content should be modified');
assert.match(result, /^effort:\s*xhigh$/m, 'effort: xhigh must be present');
assert.ok(result.includes('\neffort: xhigh\n---\n'), 'effort: must appear before closing --- with LF');
// Closing --- must still be present and intact
assert.ok(result.includes('\n---\n'), 'closing --- must remain with LF');
});
// CRLF source (Windows git checkout with core.autocrlf=true) — the actual bug
test('CRLF frontmatter: injects effort: with CRLF preserved (Windows fix)', () => {
const content = '---\r\nname: gsd-planner\r\ndescription: Creates plans\r\ncolor: blue\r\n---\r\nBody here\r\n';
const result = injectEffortFrontmatter(content, 'xhigh');
assert.notStrictEqual(result, content, 'content should be modified (CRLF source was silently skipped before fix)');
// effort: line must use CRLF, not LF (EOL consistency)
assert.ok(result.includes('effort: xhigh\r\n'), 'effort: line must use CRLF to match surrounding frontmatter');
// Closing --- must use CRLF and remain intact
assert.ok(result.includes('\r\neffort: xhigh\r\n---\r\n'), 'effort: must appear before closing ---\\r\\n with CRLF');
// The effort value must be readable via multiline regex (as the install-wiring assertions do)
assert.match(result, /^effort:\s*xhigh$/m, '/^effort:\\s*xhigh$/m must match in CRLF output');
});
// Idempotency: don't double-insert if effort: already exists
test('idempotent: does NOT insert a second effort: line when already present (LF)', () => {
const content = '---\nname: gsd-planner\neffort: high\n---\nBody\n';
const result = injectEffortFrontmatter(content, 'xhigh');
assert.strictEqual(result, content, 'content must be unchanged when effort: already present');
// Confirm no duplicate
const matches = [...result.matchAll(/^effort:/mg)];
assert.strictEqual(matches.length, 1, 'exactly one effort: key must exist');
});
test('idempotent: does NOT insert a second effort: line when already present (CRLF)', () => {
const content = '---\r\nname: gsd-planner\r\neffort: high\r\n---\r\nBody\r\n';
const result = injectEffortFrontmatter(content, 'xhigh');
assert.strictEqual(result, content, 'content must be unchanged when effort: already present (CRLF)');
});
// No frontmatter — leave unchanged
test('no YAML frontmatter: returns content unchanged', () => {
const content = 'Just a body\nNo frontmatter here\n';
const result = injectEffortFrontmatter(content, 'xhigh');
assert.strictEqual(result, content, 'content without frontmatter must be returned unchanged');
});
// Complex frontmatter with comment lines and color: key (mirrors real agent .md files)
test('complex LF frontmatter (# comment + color:) still injects effort: before ---', () => {
const content = [
'---',
'name: gsd-executor',
'# hooks: see .claude/settings.json',
'description: Executes tasks',
'color: green',
'---',
'Body content here',
'',
].join('\n');
const result = injectEffortFrontmatter(content, 'high');
assert.match(result, /^effort:\s*high$/m, 'effort: high must be present');
assert.ok(result.includes('\neffort: high\n---\n'), 'effort: must appear immediately before closing ---');
// Other frontmatter fields must be untouched
assert.ok(result.includes('color: green'), 'color: must be preserved');
assert.ok(result.includes('# hooks:'), '# comment must be preserved');
});
test('complex CRLF frontmatter (# comment + color:) still injects effort: with CRLF before ---', () => {
const lines = [
'---',
'name: gsd-executor',
'# hooks: see .claude/settings.json',
'description: Executes tasks',
'color: green',
'---',
'Body content here',
'',
];
const content = lines.join('\r\n');
const result = injectEffortFrontmatter(content, 'high');
assert.ok(result.includes('effort: high\r\n'), 'effort: must use CRLF in CRLF file');
assert.ok(result.includes('\r\neffort: high\r\n---\r\n'), 'effort: must appear before closing ---\\r\\n');
assert.ok(result.includes('color: green\r\n'), 'color: must be preserved with CRLF');
});
});

View File

@@ -0,0 +1,408 @@
// allow-test-rule: integration-test-input
// Exercises install() + generateCodexAgentToml() as a black-box by inspecting
// produced output files in temp dirs. Source agent .md files are inputs whose
// installed transformation is asserted — not inspected for string presence.
/**
* #443 — Effort per-runtime wiring at install time.
*
* Verifies:
* 1. Claude global install injects `effort:` into agent .md frontmatter.
* 2. Gemini global install does NOT inject `effort:` (Gemini-safe .md).
* 3. Codex global install emits `model_reasoning_effort` in .toml via the
* unified resolver (not the old catalog-static path).
* 4. Config-driven proof: effort.agent_overrides wins over tier defaults
* for both Claude .md and Codex .toml.
* 5. Source agents/gsd-planner.md has NO effort: key (injection is
* install-only, source stays Gemini-safe).
*/
'use strict';
process.env.GSD_TEST_MODE = '1';
const { describe, test, beforeEach, afterEach } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const os = require('node:os');
const { install } = require('../bin/install.js');
const REPO_ROOT = path.resolve(__dirname, '..');
const SOURCE_AGENTS_DIR = path.join(REPO_ROOT, 'agents');
// ─── helpers ─────────────────────────────────────────────────────────────────
function makeTmpDir(prefix) {
return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
}
function readFrontmatter(mdPath) {
const content = fs.readFileSync(mdPath, 'utf8');
if (!content.startsWith('---')) return '';
const end = content.indexOf('---', 3);
if (end === -1) return '';
return content.substring(3, end);
}
/**
* Run a global install for the given runtime, redirecting its home dir to
* tmpHome. Returns the tmpHome for inspection.
*
* Env-var redirection:
* claude → CLAUDE_CONFIG_DIR
* gemini → GEMINI_CONFIG_DIR
* codex → CODEX_HOME
*
* HOME is also redirected to an isolated temp dir for the duration of the
* install call. This prevents any install.js code that uses os.homedir()
* directly (e.g. ~/.cache/gsd update-check deletion, ~/.gsd/defaults.json
* reads, stale-SDK npm subprocess writes to ~/.npm) from touching the real
* HOME and polluting the test environment for other concurrently-running
* test files (e.g. runtime-launcher-parity test (D) checks that
* $HOME/.claude/get-shit-done/bin/gsd-tools.cjs is absent).
*
* GSD_SKIP_STALE_SDK_CHECK=1 is set to suppress the `npm ls -g` subprocess
* that the installer spawns for global installs — that subprocess is slow,
* writes to ~/.npm cache, and is irrelevant to effort-wiring assertions.
*
* The working directory is set to REPO_ROOT so install() can find the source
* agents/. For config-driven tests, place tmpHome inside the project dir
* so that readGsdEffectiveEffortConfig(targetDir) can walk up from tmpHome
* and find .planning/config.json.
*/
function runGlobalInstall(runtime, tmpHome) {
const envVarMap = {
claude: 'CLAUDE_CONFIG_DIR',
gemini: 'GEMINI_CONFIG_DIR',
codex: 'CODEX_HOME',
};
const envVar = envVarMap[runtime];
if (!envVar) throw new Error(`Unsupported runtime in test: ${runtime}`);
// Isolate HOME to a fresh temp dir so install.js code that calls
// os.homedir() (cache deletion, defaults.json reads, npm subprocess)
// never touches the real $HOME/.claude / $HOME/.cache / $HOME/.gsd.
const isolatedHome = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-443-home-'));
const prev = process.env[envVar];
const prevCwd = process.cwd();
const prevHome = process.env.HOME;
const prevSkipStale = process.env.GSD_SKIP_STALE_SDK_CHECK;
process.env[envVar] = tmpHome;
process.env.HOME = isolatedHome;
process.env.GSD_SKIP_STALE_SDK_CHECK = '1';
process.chdir(REPO_ROOT);
try {
install(true, runtime);
} finally {
process.chdir(prevCwd);
if (prev === undefined) delete process.env[envVar];
else process.env[envVar] = prev;
if (prevHome === undefined) delete process.env.HOME;
else process.env.HOME = prevHome;
if (prevSkipStale === undefined) delete process.env.GSD_SKIP_STALE_SDK_CHECK;
else process.env.GSD_SKIP_STALE_SDK_CHECK = prevSkipStale;
// Clean up the isolated HOME dir
try { fs.rmSync(isolatedHome, { recursive: true, force: true }); } catch (_) { /* best-effort */ }
}
return tmpHome;
}
// ─── Tier default expectations ────────────────────────────────────────────────
// light → low, standard → high, heavy → xhigh (catalog defaults)
// gsd-planner: heavy → xhigh
// gsd-codebase-mapper: light → low
// gsd-executor: standard → high
// ─── describe 1: Claude install injects effort: ───────────────────────────────
describe('#443 Claude install: effort: injected into frontmatter', () => {
let tmpDir;
let claudeHome;
beforeEach(() => {
tmpDir = makeTmpDir('gsd-443-claude-');
claudeHome = path.join(tmpDir, 'claude-home');
fs.mkdirSync(claudeHome, { recursive: true });
});
afterEach(() => {
fs.rmSync(tmpDir, { recursive: true, force: true });
});
test('gsd-planner.md contains effort: xhigh (heavy tier default)', () => {
runGlobalInstall('claude', claudeHome);
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-planner.md'));
assert.match(fm, /^effort:\s*xhigh$/m,
`gsd-planner frontmatter should have effort: xhigh\nActual:\n${fm}`);
});
test('gsd-codebase-mapper.md contains effort: low (light tier default)', () => {
runGlobalInstall('claude', claudeHome);
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-codebase-mapper.md'));
assert.match(fm, /^effort:\s*low$/m,
`gsd-codebase-mapper frontmatter should have effort: low\nActual:\n${fm}`);
});
test('gsd-executor.md contains effort: high (standard tier default)', () => {
runGlobalInstall('claude', claudeHome);
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-executor.md'));
assert.match(fm, /^effort:\s*high$/m,
`gsd-executor frontmatter should have effort: high\nActual:\n${fm}`);
});
});
// ─── describe 2: Gemini install does NOT inject effort: ──────────────────────
describe('#443 Gemini install: effort: absent (Gemini-safe)', () => {
let tmpDir;
let geminiHome;
beforeEach(() => {
tmpDir = makeTmpDir('gsd-443-gemini-');
geminiHome = path.join(tmpDir, 'gemini-home');
fs.mkdirSync(geminiHome, { recursive: true });
});
afterEach(() => {
fs.rmSync(tmpDir, { recursive: true, force: true });
});
test('gsd-planner.md does NOT contain effort: (Gemini install)', () => {
runGlobalInstall('gemini', geminiHome);
const fm = readFrontmatter(path.join(geminiHome, 'agents', 'gsd-planner.md'));
assert.doesNotMatch(fm, /^effort:/m,
`gsd-planner (Gemini) frontmatter must NOT have effort:\nActual:\n${fm}`);
});
test('gsd-executor.md does NOT contain effort: (Gemini install)', () => {
runGlobalInstall('gemini', geminiHome);
const fm = readFrontmatter(path.join(geminiHome, 'agents', 'gsd-executor.md'));
assert.doesNotMatch(fm, /^effort:/m,
`gsd-executor (Gemini) frontmatter must NOT have effort:\nActual:\n${fm}`);
});
});
// ─── describe 3: Codex install emits model_reasoning_effort in .toml ─────────
describe('#443 Codex install: model_reasoning_effort in .toml (unified resolver)', () => {
let tmpDir;
let codexHome;
beforeEach(() => {
tmpDir = makeTmpDir('gsd-443-codex-');
codexHome = path.join(tmpDir, 'codex-home');
fs.mkdirSync(codexHome, { recursive: true });
});
afterEach(() => {
fs.rmSync(tmpDir, { recursive: true, force: true });
});
test('gsd-planner.toml contains model_reasoning_effort = "xhigh" (heavy tier)', () => {
runGlobalInstall('codex', codexHome);
const tomlContent = fs.readFileSync(
path.join(codexHome, 'agents', 'gsd-planner.toml'), 'utf8'
);
assert.match(tomlContent, /^model_reasoning_effort\s*=\s*"xhigh"$/m,
`gsd-planner.toml should have model_reasoning_effort = "xhigh"\nActual:\n${tomlContent.slice(0, 500)}`);
});
});
// ─── describe 4: Config-driven proof ─────────────────────────────────────────
//
// The runtime home dir must be INSIDE (or a sibling of) the project root so
// that readGsdEffectiveEffortConfig(targetDir) can walk up from the runtime
// home and find .planning/config.json. We put .claude/ and .codex/ as siblings
// of .planning/ inside the project dir — this is the natural local-install shape.
describe('#443 Config-driven: effort.agent_overrides drives install-time effort', () => {
let tmpDir;
let claudeHome;
let codexHome;
beforeEach(() => {
// Layout: tmpDir/project/ <-- project root (cwd for install)
// .planning/config.json
// .claude/ <-- claudeHome (CLAUDE_CONFIG_DIR)
// .codex/ <-- codexHome (CODEX_HOME)
tmpDir = makeTmpDir('gsd-443-cfg-');
const projectDir = path.join(tmpDir, 'project');
claudeHome = path.join(projectDir, '.claude');
codexHome = path.join(projectDir, '.codex');
fs.mkdirSync(claudeHome, { recursive: true });
fs.mkdirSync(codexHome, { recursive: true });
fs.mkdirSync(path.join(projectDir, '.planning'), { recursive: true });
// Write a project config with effort.agent_overrides overriding gsd-planner to 'low'
const config = {
effort: {
agent_overrides: {
'gsd-planner': 'low',
},
},
};
fs.writeFileSync(
path.join(projectDir, '.planning', 'config.json'),
JSON.stringify(config, null, 2)
);
});
afterEach(() => {
fs.rmSync(tmpDir, { recursive: true, force: true });
});
test('Claude .md gets effort: low when agent_overrides.gsd-planner=low', () => {
// projectDir is the cwd for install — chdir handled inside runGlobalInstall.
// claudeHome is inside projectDir, so walking up from claudeHome finds .planning/config.json.
runGlobalInstall('claude', claudeHome);
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-planner.md'));
assert.match(fm, /^effort:\s*low$/m,
`gsd-planner should have effort: low from config override\nActual:\n${fm}`);
});
test('Codex .toml gets model_reasoning_effort = "low" when agent_overrides.gsd-planner=low', () => {
runGlobalInstall('codex', codexHome);
const tomlContent = fs.readFileSync(
path.join(codexHome, 'agents', 'gsd-planner.toml'), 'utf8'
);
assert.match(tomlContent, /^model_reasoning_effort\s*=\s*"low"$/m,
`gsd-planner.toml should have model_reasoning_effort = "low" from config override\nActual:\n${tomlContent.slice(0, 500)}`);
});
test('Codex .toml clamps effort max → xhigh when agent_overrides.gsd-planner=max', () => {
const projectDir = path.dirname(codexHome);
// Overwrite config with max override
const config = {
effort: {
agent_overrides: {
'gsd-planner': 'max',
},
},
};
fs.writeFileSync(
path.join(projectDir, '.planning', 'config.json'),
JSON.stringify(config, null, 2)
);
runGlobalInstall('codex', codexHome);
const tomlContent = fs.readFileSync(
path.join(codexHome, 'agents', 'gsd-planner.toml'), 'utf8'
);
// Codex does not support 'max' → clamped to 'xhigh'
assert.match(tomlContent, /^model_reasoning_effort\s*=\s*"xhigh"$/m,
`gsd-planner.toml should clamp max → xhigh for Codex\nActual:\n${tomlContent.slice(0, 500)}`);
assert.doesNotMatch(tomlContent, /model_reasoning_effort\s*=\s*"max"/,
'Codex .toml must never contain model_reasoning_effort = "max"');
});
});
// ─── describe 5b: Invalid effort tokens fall through (Codex adversarial finding #2) ─
//
// These tests FAIL before the fix: resolveInstallTimeEffort returns the raw
// invalid string without validating it against VALID_EFFORTS.
describe('#443 resolveInstallTimeEffort: invalid tokens fall through to valid effort', () => {
let tmpDir;
let claudeHome;
let codexHome;
beforeEach(() => {
// Layout: tmpDir/project/ <-- project root
// .planning/config.json
// .claude/ <-- claudeHome
// .codex/ <-- codexHome
tmpDir = makeTmpDir('gsd-443-invalid-effort-');
const projectDir = path.join(tmpDir, 'project');
claudeHome = path.join(projectDir, '.claude');
codexHome = path.join(projectDir, '.codex');
fs.mkdirSync(claudeHome, { recursive: true });
fs.mkdirSync(codexHome, { recursive: true });
fs.mkdirSync(path.join(projectDir, '.planning'), { recursive: true });
});
afterEach(() => {
fs.rmSync(tmpDir, { recursive: true, force: true });
});
function writeProjectConfig(config) {
const projectDir = path.dirname(claudeHome);
fs.writeFileSync(
path.join(projectDir, '.planning', 'config.json'),
JSON.stringify(config, null, 2)
);
}
const VALID_EFFORTS = ['minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
test('effort.default="ultra" (invalid) -> Claude .md effort: is a VALID value (falls through to high)', () => {
// BUG before fix: resolveInstallTimeEffort returns "ultra" verbatim
writeProjectConfig({ effort: { default: 'ultra' } });
runGlobalInstall('claude', claudeHome);
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-planner.md'));
const match = fm.match(/^effort:\s*(\S+)$/m);
assert.ok(match, `effort: must be present in frontmatter\nActual:\n${fm}`);
assert.ok(VALID_EFFORTS.includes(match[1]),
`effort: must be a VALID effort string, got: "${match[1]}"\nActual frontmatter:\n${fm}`);
});
test('effort.agent_overrides.gsd-planner="bogus" (invalid) with valid default -> falls through to valid default', () => {
// BUG before fix: "bogus" is returned and written verbatim
writeProjectConfig({
effort: {
agent_overrides: { 'gsd-planner': 'bogus' },
default: 'medium',
},
});
runGlobalInstall('claude', claudeHome);
const fm = readFrontmatter(path.join(claudeHome, 'agents', 'gsd-planner.md'));
const match = fm.match(/^effort:\s*(\S+)$/m);
assert.ok(match, `effort: must be present in frontmatter\nActual:\n${fm}`);
assert.ok(VALID_EFFORTS.includes(match[1]),
`effort: must be a VALID effort string, got: "${match[1]}"\nActual frontmatter:\n${fm}`);
// Falls through invalid "bogus" -> valid tier default or "medium" default
// "medium" is valid, so it should appear (or tier default if medium is invalid, but medium is valid)
});
test('effort.default="ultra" (invalid) -> Codex .toml model_reasoning_effort is VALID', () => {
// BUG before fix: "ultra" written into .toml verbatim
writeProjectConfig({ effort: { default: 'ultra' } });
runGlobalInstall('codex', codexHome);
const tomlContent = fs.readFileSync(
path.join(codexHome, 'agents', 'gsd-planner.toml'), 'utf8'
);
const match = tomlContent.match(/^model_reasoning_effort\s*=\s*"([^"]+)"/m);
assert.ok(match, `model_reasoning_effort must be present in .toml\nActual:\n${tomlContent.slice(0, 500)}`);
assert.ok(VALID_EFFORTS.includes(match[1]),
`model_reasoning_effort must be VALID, got: "${match[1]}"\nActual:\n${tomlContent.slice(0, 500)}`);
});
});
// ─── describe 5: Source stays clean ──────────────────────────────────────────
describe('#443 Source purity: agents/gsd-planner.md has no effort: key', () => {
test('source agents/gsd-planner.md frontmatter does not contain effort:', () => {
const fm = readFrontmatter(path.join(SOURCE_AGENTS_DIR, 'gsd-planner.md'));
assert.doesNotMatch(fm, /^effort:/m,
`Source agents/gsd-planner.md must NOT contain effort: (injection is install-only)`);
});
test('source agents/gsd-executor.md frontmatter does not contain effort:', () => {
const fm = readFrontmatter(path.join(SOURCE_AGENTS_DIR, 'gsd-executor.md'));
assert.doesNotMatch(fm, /^effort:/m,
`Source agents/gsd-executor.md must NOT contain effort: (injection is install-only)`);
});
test('source agents/gsd-codebase-mapper.md frontmatter does not contain effort:', () => {
const fm = readFrontmatter(path.join(SOURCE_AGENTS_DIR, 'gsd-codebase-mapper.md'));
assert.doesNotMatch(fm, /^effort:/m,
`Source agents/gsd-codebase-mapper.md must NOT contain effort: (injection is install-only)`);
});
});

View File

@@ -34,12 +34,13 @@ const { createTempProject, cleanup } = require('./helpers.cjs');
const {
resolveModelInternal,
resolveReasoningEffortInternal,
resolveEffortInternal,
resolveTierEntry,
RUNTIME_PROFILE_MAP,
KNOWN_RUNTIMES,
_resetRuntimeWarningCacheForTests,
} = require('../get-shit-done/bin/lib/core.cjs');
const { renderEffortForRuntime } = require('../get-shit-done/bin/lib/model-catalog.cjs');
const { isValidConfigKey } = require('../get-shit-done/bin/lib/config-schema.cjs');
function writeConfig(tmpDir, obj) {
@@ -98,9 +99,12 @@ describe('issue #2517: backwards compat — no runtime key set', () => {
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), '');
});
test('reasoning_effort returns null when runtime absent', () => {
test('effort resolves universally but render param is null when runtime absent', () => {
writeConfig(tmpDir, { model_profile: 'balanced' });
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), null);
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
// Effort always resolves (universal); rendering without a runtime yields no wire param.
const rendered = renderEffortForRuntime(undefined, eff);
assert.strictEqual(rendered.param, null);
});
test('adaptive profile still works without runtime (#1713/#1806)', () => {
@@ -144,9 +148,14 @@ describe('issue #2517: runtime "claude" is a no-op for resolution (finding #4)',
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'claude-opus-4-7');
});
test('reasoning_effort is null on Claude (never leaks)', () => {
test('effort is first-class on Claude (emits output_config.effort)', () => {
writeConfig(tmpDir, { runtime: 'claude', model_profile: 'quality' });
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), null);
// Under unification, Claude effort is first-class — rendered via output_config.effort.
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
const rendered = renderEffortForRuntime('claude', eff);
assert.strictEqual(rendered.param, 'output_config.effort');
// gsd-planner is heavy tier → default effort 'xhigh'
assert.strictEqual(rendered.value, 'xhigh');
});
});
@@ -156,23 +165,35 @@ describe('issue #2517: runtime "codex" — Codex tier resolution', () => {
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('opus tier -> gpt-5.4 with reasoning_effort xhigh', () => {
test('opus tier -> gpt-5.4 model; heavy-tier agent -> xhigh effort on codex', () => {
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'quality' });
// gsd-planner quality -> opus -> gpt-5.4
// gsd-planner quality -> opus -> gpt-5.4 (model unchanged)
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gpt-5.4');
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), 'xhigh');
// gsd-planner is heavy routing tier → effort 'xhigh' → rendered model_reasoning_effort
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
const rendered = renderEffortForRuntime('codex', eff);
assert.strictEqual(rendered.param, 'model_reasoning_effort');
assert.strictEqual(rendered.value, 'xhigh');
});
test('sonnet tier -> gpt-5.3-codex with reasoning_effort medium', () => {
test('sonnet tier -> gpt-5.3-codex model; heavy-tier agent -> xhigh effort on codex', () => {
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'balanced' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-roadmapper'), 'gpt-5.3-codex');
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-roadmapper'), 'medium');
// gsd-roadmapper is heavy routing tier → effort 'xhigh' (not catalog medium)
const eff = resolveEffortInternal(tmpDir, 'gsd-roadmapper');
const rendered = renderEffortForRuntime('codex', eff);
assert.strictEqual(rendered.param, 'model_reasoning_effort');
assert.strictEqual(rendered.value, 'xhigh');
});
test('haiku tier -> gpt-5.4-mini with reasoning_effort medium', () => {
test('haiku tier -> gpt-5.4-mini model; light-tier agent -> low effort on codex', () => {
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'budget' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'gpt-5.4-mini');
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-codebase-mapper'), 'medium');
// gsd-codebase-mapper is light routing tier → effort 'low' (not catalog medium)
const eff = resolveEffortInternal(tmpDir, 'gsd-codebase-mapper');
const rendered = renderEffortForRuntime('codex', eff);
assert.strictEqual(rendered.param, 'model_reasoning_effort');
assert.strictEqual(rendered.value, 'low');
});
test('adaptive profile resolves on Codex (no #1713/#1806 regression)', () => {
@@ -183,11 +204,15 @@ describe('issue #2517: runtime "codex" — Codex tier resolution', () => {
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'gpt-5.4-mini');
});
test('inherit profile still returns "inherit" on Codex', () => {
test('inherit profile still returns "inherit" on Codex; effort still resolves universally', () => {
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'inherit' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'inherit');
// No reasoning_effort when inherit
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), null);
// Unified effort is config-driven (routing_tier_defaults), independent of model_profile.
// gsd-planner (heavy tier) → 'xhigh'; rendered to codex param.
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
const rendered = renderEffortForRuntime('codex', eff);
assert.strictEqual(rendered.param, 'model_reasoning_effort');
assert.strictEqual(rendered.value, 'xhigh');
});
test('runtime:"codex" beats resolve_model_ids:"omit" (explicit non-Claude opt-in wins)', () => {
@@ -261,33 +286,39 @@ describe('issue #2517: field-merge of overrides with built-in defaults (finding
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('string-shorthand override keeps reasoning_effort from built-in (CONFIGURATION.md example)', () => {
// `{ codex: { opus: "gpt-5-pro" } }` is the documented shorthand. Pre-fix,
// it silently dropped reasoning_effort. Post-fix, the model is overridden
// and reasoning_effort comes from the built-in entry.
test('string-shorthand override: model is overridden; unified effort derives from routing tier', () => {
// `{ codex: { opus: "gpt-5-pro" } }` is the documented shorthand.
// Model is overridden to gpt-5-pro; effort now derives from the universal
// config-driven path (gsd-planner heavy tier → 'xhigh'), not from the catalog.
writeConfig(tmpDir, {
runtime: 'codex',
model_profile: 'quality',
model_profile_overrides: { codex: { opus: 'gpt-5-pro' } },
});
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gpt-5-pro');
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), 'xhigh');
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
const rendered = renderEffortForRuntime('codex', eff);
assert.strictEqual(rendered.param, 'model_reasoning_effort');
assert.strictEqual(rendered.value, 'xhigh');
});
test('partial-object override (no model) keeps model from built-in', () => {
// `{ codex: { opus: { reasoning_effort: "low" } } }` previously dropped
// the model entirely (returned undefined and fell through). Post-fix, the
// built-in `gpt-5.4` model is preserved and `low` reasoning_effort wins.
test('partial-object override (no model) keeps model from built-in; unified effort from routing tier', () => {
// `{ codex: { opus: { reasoning_effort: "low" } } }` preserves the built-in model.
// Under unification, the catalog reasoning_effort field is not read for effort resolution;
// effort comes from routing_tier_defaults (gsd-planner heavy → 'xhigh').
writeConfig(tmpDir, {
runtime: 'codex',
model_profile: 'quality',
model_profile_overrides: { codex: { opus: { reasoning_effort: 'low' } } },
});
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gpt-5.4');
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), 'low');
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
const rendered = renderEffortForRuntime('codex', eff);
assert.strictEqual(rendered.param, 'model_reasoning_effort');
assert.strictEqual(rendered.value, 'xhigh');
});
test('full-object override replaces both fields', () => {
test('full-object override: model replaced; unified effort from routing tier (not catalog field)', () => {
writeConfig(tmpDir, {
runtime: 'codex',
model_profile: 'quality',
@@ -296,7 +327,11 @@ describe('issue #2517: field-merge of overrides with built-in defaults (finding
},
});
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'custom-model');
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), 'minimal');
// Effort comes from routing_tier_defaults, not the catalog 'minimal' field.
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
const rendered = renderEffortForRuntime('codex', eff);
assert.strictEqual(rendered.param, 'model_reasoning_effort');
assert.strictEqual(rendered.value, 'xhigh');
});
test('resolveTierEntry helper: shorthand merge', () => {
@@ -328,15 +363,15 @@ describe('issue #2517: field-merge of overrides with built-in defaults (finding
});
});
// ─── reasoning_effort allowlist (review finding #3) ─────────────────────────
describe('issue #2517: reasoning_effort allowlist gates regardless of overrides (finding #3)', () => {
// ─── Unknown runtime render safety (finding #3 spirit) ──────────────────────
describe('issue #2517: unknown runtime render param is null (effort does not leak to install path)', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('unknown runtime with overrides supplying reasoning_effort yields null effort', () => {
// Pre-fix: `if (!overrides) return null` left a hole — overrides for an
// unknown runtime made effort propagate, defeating the typo guard.
test('unknown runtime: model resolves via override; render param is null (no wire param leaked)', () => {
// Under unification, effort always resolves (universal), but renderEffortForRuntime
// returns param=null for unknown runtimes — no effort leaks to the install path.
writeConfig(tmpDir, {
runtime: 'mystery',
model_profile: 'quality',
@@ -346,17 +381,21 @@ describe('issue #2517: reasoning_effort allowlist gates regardless of overrides
});
// Model still resolves (overrides are honored).
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'mystery-opus');
// …but reasoning_effort does NOT propagate to a runtime not in the allowlist.
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), null);
// Effort resolves universally but the unknown runtime has no wire param.
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
const rendered = renderEffortForRuntime('mystery', eff);
assert.strictEqual(rendered.param, null);
});
test('typo runtime "codx" with overrides yields null effort (no leak into install path)', () => {
test('typo runtime "codx": render param is null (no leak into install path)', () => {
writeConfig(tmpDir, {
runtime: 'codx',
model_profile: 'quality',
model_profile_overrides: { codx: { opus: { model: 'gpt-5.4', reasoning_effort: 'xhigh' } } },
});
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), null);
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
const rendered = renderEffortForRuntime('codx', eff);
assert.strictEqual(rendered.param, null);
});
});
@@ -541,10 +580,13 @@ describe('issue #2517: install end-to-end — per-project config reaches Codex T
assert.match(toml, /^model_reasoning_effort = "xhigh"$/m);
});
test('generated TOML omits reasoning_effort when runtime has none', () => {
// For a known runtime with model but no reasoning_effort, only model is emitted.
// Use the user-override path to simulate this with codex (no built-in returns
// model alone, so fabricate via override of an unknown-runtime entry).
test('generated TOML always includes model_reasoning_effort even when model_profile_overrides sets reasoning_effort to empty (#443 unified)', () => {
// Under the unified effort design (#443), model_reasoning_effort in the Codex TOML
// is driven by the unified effort resolver (resolveInstallTimeEffort / effortCfg),
// NOT by model_profile_overrides.reasoning_effort. Setting reasoning_effort: '' in
// model_profile_overrides does NOT suppress the unified effort — the TOML always
// carries a valid model_reasoning_effort drawn from the agent's routing tier.
// gsd-planner is a heavy-tier agent → unified default resolves to "xhigh".
writeConfig(tmpDir, {
runtime: 'codex',
model_profile: 'quality',
@@ -557,8 +599,12 @@ describe('issue #2517: install end-to-end — per-project config reaches Codex T
null,
resolver
);
// Model override (from model_profile_overrides) is still respected.
assert.match(toml, /^model = "custom"$/m);
assert.doesNotMatch(toml, /model_reasoning_effort/);
// Unified effort always fires — model_reasoning_effort is present and valid.
assert.match(toml, /^model_reasoning_effort = "(minimal|low|medium|high|xhigh)"$/m);
// gsd-planner is heavy-tier, so with no effortCfg the manifest tier default applies → xhigh.
assert.match(toml, /^model_reasoning_effort = "xhigh"$/m);
});
test('resolver returns null with no global, no per-project config', () => {
@@ -612,9 +658,10 @@ describe('issue #2612: runtime "gemini" — Gemini tier resolution', () => {
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'gemini-2.5-flash-lite');
});
test('reasoning_effort is null for gemini (no reasoning_effort in spec)', () => {
test('gemini: effort resolves universally but render param is null (no wire param)', () => {
writeConfig(tmpDir, { runtime: 'gemini', model_profile: 'quality' });
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), null);
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
assert.strictEqual(renderEffortForRuntime('gemini', eff).param, null);
});
});
@@ -639,9 +686,10 @@ describe('issue #2612: runtime "qwen" — Qwen tier resolution', () => {
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'qwen3-coder-next');
});
test('reasoning_effort is null for qwen (no reasoning_effort in spec)', () => {
test('qwen: effort resolves universally but render param is null (no wire param)', () => {
writeConfig(tmpDir, { runtime: 'qwen', model_profile: 'quality' });
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), null);
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
assert.strictEqual(renderEffortForRuntime('qwen', eff).param, null);
});
});
@@ -666,9 +714,10 @@ describe('issue #2612: runtime "opencode" — OpenCode tier resolution', () => {
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'anthropic/claude-haiku-4-5');
});
test('reasoning_effort is null for opencode (no reasoning_effort in spec)', () => {
test('opencode: effort resolves universally but render param is null (no wire param)', () => {
writeConfig(tmpDir, { runtime: 'opencode', model_profile: 'quality' });
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), null);
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
assert.strictEqual(renderEffortForRuntime('opencode', eff).param, null);
});
});
@@ -693,9 +742,10 @@ describe('issue #2612: runtime "copilot" — Copilot tier resolution', () => {
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'claude-haiku-4-5');
});
test('reasoning_effort is null for copilot (no reasoning_effort in spec)', () => {
test('copilot: effort resolves universally but render param is null (no wire param)', () => {
writeConfig(tmpDir, { runtime: 'copilot', model_profile: 'quality' });
assert.strictEqual(resolveReasoningEffortInternal(tmpDir, 'gsd-planner'), null);
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
assert.strictEqual(renderEffortForRuntime('copilot', eff).param, null);
});
});