Files
msd-core/tests/issue-2517-runtime-aware-profiles.test.cjs
Tom Boucher 463cffd894 chore(#604): rename get-shit-done/ runtime directory to gsd-core/ (#615)
* chore(#604): rename get-shit-done/ runtime directory to gsd-core/

Renames the installed runtime directory `get-shit-done/` to `gsd-core/` so the
on-disk name matches the package (`@opengsd/gsd-core`), repo, and binary
(`gsd-tools`). The npm package name and binary are unchanged; npx/npm consumers
are unaffected.

Mechanical (bulk, ~90% of the diff):
- `git mv get-shit-done gsd-core`
- Swept path/identifier references across the repo via
  `perl -pe 's/get-shit-done(?!-\w)/gsd-core/g'`. The negative lookahead
  preserves the five legitimate slug variants that are NOT the directory:
  get-shit-done-{OLD,cc,classic,cli,redux} (old package/repo names).
- Build/manifest wiring: package.json (bin, files, coverage globs),
  tsconfig.build.json (outDir), ~86 .gitignore build-output entries,
  stryker.config.mjs, scan-ignore files, install.js path strings.
- Frozen (not rewritten): CHANGELOG.md history; translated docs
  (README.<locale>.md and docs/{ja-JP,ko-KR,pt-BR,zh-CN}/).

New logic (review here):
- src/installer-migrations/003-rename-get-shit-done-to-gsd-core.cts: a proper
  ADR-0008 installer migration. On upgrade it walks the legacy
  `~/.claude/get-shit-done/` tree, classifies each file via the prior install
  manifest, and emits remove-managed / backup-and-remove for managed files
  while PRESERVING unknown user-added files. Symlink-safe (skips a symlinked
  root and symlinked entries; bounds-checks every path under configDir). The
  framework rolls back on install failure. Emptied dirs may remain (framework
  has no recursive dir-removal primitive) — documented.
- scripts/lint-legacy-dir-name.cjs: CI regression guard forbidding the bare
  `get-shit-done` directory token (split token to avoid self-match; case-
  insensitive; `(?!-\w)` lookahead allows the slug variants; allowlists
  CHANGELOG, translated docs, and `gsd-allow-legacy-name` marker lines).
  Wired into the lint-tests CI job.
- Restored scripts/lint-package-identity-drift.cjs detection regexes (the
  mechanical sweep had wrongly rewritten the old-name patterns it exists to
  detect) and marked them as intentional legacy references.
- TDD tests for the migration and the guard; do.md slash-command guard regex
  tightened so a `/gsd-core/bin` path segment is not mistaken for a command;
  changeset + docs/installer-migrations.md row added.

Breaking: the installed runtime path moves `~/.claude/get-shit-done/` ->
`~/.claude/gsd-core/`. Migration 003 removes the stale legacy dir's managed
files (preserving user files) on upgrade. Users with custom hooks/configs
hardcoding the old path must update them.

Closes #604

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

* fix(#604): unsweep pending changesets + allowlist injection-example docs

CI fixes for the rename PR:
- Do not sweep pending .changeset/*.md (ephemeral release-note fragments,
  like CHANGELOG); reverted those body edits so 5 pre-existing malformed
  fragments (missing type/pr) no longer enter the PR diff and trip docs-lint.
  Allowlisted .changeset/ in the legacy-name guard accordingly.
- Allowlisted TEST-EXAMPLES.md and docs/explanation/security-model.md in
  prompt-injection-scan.sh: they contain intentional injection examples /
  security-model prose; the path-reference rewrites are kept.

CodeQL alerts on this PR are pre-existing (alert lines unchanged by this PR;
none in the new migration/guard) and are out of scope for the rename.

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

* fix(#604): resolve CodeQL alerts surfaced on this PR

The rename diff touched files carrying pre-existing CodeQL findings; per the
no-pre-existing-dismissal rule, fixing every surfaced alert rather than waving
them off. All behavior-preserving:

- scripts/ci-test-scope.cjs: build the config-path match from string
  .includes() instead of a RegExp over an arg-derived value (js/regex-injection).
- src/profile-output.cts: escape backslashes before pipe-escaping desc/safeName
  so the table-cell escape is complete (js/incomplete-sanitization).
- tests/{bug-2643,bug-2808,docs-parity-live-registry}: two-pass HTML-comment
  strip so a bare/unclosed `<!--` cannot survive (js/incomplete-multi-character-sanitization).
- tests/inline-plan-threshold: drop the no-op `\s`->`\s` identity replace,
  keep the meaningful POSIX-class conversion (js/identity-replacement).

Verified: build:lib green; the touched test files + ci-test-scope + profile-output
suites pass; lint:legacy-name clean.

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

* fix(#604): correctly resolve remaining CodeQL alerts (regex-injection + sanitization)

The prior commit's fixes for two alerts were ineffective:
- ci-test-scope.cjs js/regex-injection: the alert is the CLI-arg-derived `file`
  reaching static regex `.test(file)` calls (not the config rule). Removed ALL
  regex over file/t — startsWith/includes/=== string checks + an isWindowsHint
  helper — so there is no regex sink for the tainted value.
- js/incomplete-multi-character-sanitization (3 test files): a single
  `.replace(/<!--...-->/g,'')` can let `<!--` re-form. Replaced with a fixpoint
  loop (replace until stable) plus a final bare-opener strip.

Verified: no regex over file/t remains; ci-test-scope + the 3 test suites pass;
lint:legacy-name clean.

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

* fix(#604): make ci-test-scope + comment-strippers regex-free to clear CodeQL

CodeQL flags the regex PATTERNS syntactically (regex-injection on the
--files arg split; incomplete-multi-character-sanitization on the <!--...-->
replace), so loop fixes do not satisfy it. Made these paths regex-free:
- ci-test-scope.cjs splitFiles: char-by-char separator tokenizer (no /[,\\s]+/).
- 3 test files: indexOf/slice HTML-comment stripper (no .replace(/<!--/)).
Behavior preserved; ci-test-scope + the 3 suites pass; guard clean.

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

* fix(#604): unblock security base64 scan on the large rename diff

The security job hit its 10m timeout: base64-scan.sh choked on the binary
test fixture tests/feat-3594-parser-property-style.test.cjs (embedded NUL/
non-UTF8 bytes -> thousands of bogus blobs + "ignored null byte" warnings),
and the ~800-file rename diff is slow to scan regardless.

- scripts/base64-scan.sh: skip binary-by-content files (grep -Iq .) — they
  can't carry base64-obfuscated *text* and feeding NUL bytes through the
  per-line scanner is pathologically slow. collect_files already filtered
  binary *extensions*; this catches binary *content* in text extensions.
- .github/workflows/security-scan.yml: raise the security job timeout 10m->30m
  to accommodate very large diffs (the scan itself is unchanged).

Verified locally: scan skips the fixture, 0 "ignored null byte" warnings,
0 findings, exit 0.

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

* fix(#604): sweep get-shit-done refs introduced by merging next

The branch was updated with next (#614/#384/#618 etc.), which reference the
get-shit-done/ dir (still named that on next). Swept the stale references in
the merged files to gsd-core so the rename stays consistent and lint:legacy-name
passes:
- commands/gsd/discuss-phase.md (runtime-launcher shim paths)
- src/core.cts (getAgentsDir layout comments)
- tests/bug-384-agents-runtime-aware.test.cjs (require path to runtime lib)

Verified: guard 0 violations; build green.

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

* fix(#604): exclude gsd-core/ path segments from bug-3683 command cross-ref invariant

The #614 runtime-launcher shim added to discuss-phase.md references
`${_GSD_RUNTIME_ROOT}/gsd-core/bin/...`. bug-3683's REF_PATTERN excluded path-y
refs only via lookbehind, but `}` precedes `/gsd-core/` in the shim, so it
mis-read the directory path as a dangling `/gsd-core` command ref (same class as
the #604 bug-2954 fix). Added a trailing `(?![\w-]*\/)` so `/gsd-<x>/...` path
segments are not treated as slash-command references.

Verified locally on BOTH platforms before pushing:
- mac (node 26) full suite: 0 failures
- gsd-test-runner (linux, node22 image) full suite: 0 failures
- bug-3683 + bug-2954 pass.

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

* fix(#604): lazily resolve findProjectRoot in gsd-tools (harden flaky CI)

CI intermittently failed state.test's gsd-tools subprocess with
"findProjectRoot is not a function" (flip-flopping across legs; not reproducible
on mac full suite, gsd-test linux full suite, test:unit, or state.test x8).
findProjectRoot is a re-export from core.cjs (sourced from project-root.cjs);
binding it via destructure at module-load can be undefined under a load-ordering
edge. Resolve it lazily at call time via a small wrapper so the lookup happens
after core.cjs is fully initialized.

Verified green on BOTH platforms before pushing:
- mac (node 26) full suite: 0 failures
- gsd-test-runner (linux, node22) full suite: 0 failures
- state.test.cjs: 106/106; gsd-tools loads cleanly.

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

* fix(#604): allowlist verification-patterns.md placeholder examples in secret scan

The rename git-mv'd references/verification-patterns.md into gsd-core/, pulling
it into the secret-scan diff. It documents stub/placeholder RED-FLAG env-var
examples (illustrative Stripe test-key / database-URL / API-key placeholders) —
not real credentials. Added it to .secretscanignore with the strict annotation,
mirroring the existing gsd-core/workflows/plan-phase.md exception.

Verified locally: secret-scan-lint --strict OK; secret-scan --diff origin/next
exits 0 with 0 findings.

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

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 18:35:29 -04:00

867 lines
39 KiB
JavaScript

/**
* Issue #2517 — runtime-aware model profile resolution.
*
* Today, profile tiers (opus/sonnet/haiku) only resolve to Claude IDs. On Codex /
* other runtimes, users must use `inherit` or write large `model_overrides` blocks.
*
* This adds a `runtime` config key + `model_profile_overrides[runtime][tier]` map.
* When `runtime` is set to a non-Claude value, profile tiers resolve to runtime-
* native model IDs.
*
* Codex: opus -> gpt-5.4 (xhigh), sonnet -> gpt-5.3-codex (medium), haiku -> gpt-5.4-mini (medium)
*
* `runtime: "claude"` is the implicit default and is treated as a no-op for
* resolution — it does not override `resolve_model_ids: "omit"` or any other
* Claude-native semantics (review finding #4).
*
* `inherit` keeps current behavior. Unknown runtimes fall back safely (do NOT emit
* provider-specific IDs the runtime can't accept) and trigger a one-shot stderr
* warning so typos like `runtime: "codx"` surface immediately (review finding #13).
*
* HOME isolation: every test sets `process.env.HOME` to a per-suite tmpdir so the
* developer's real `~/.gsd/defaults.json` cannot bleed into assertions
* (review finding #8 / pattern from CodeRabbit on PRs #2603, #2604).
*/
'use strict';
const { describe, test, beforeEach, afterEach } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const os = require('os');
const path = require('path');
const { createTempProject, cleanup } = require('./helpers.cjs');
const {
resolveModelInternal,
resolveEffortInternal,
resolveTierEntry,
RUNTIME_PROFILE_MAP,
KNOWN_RUNTIMES,
_resetRuntimeWarningCacheForTests,
} = require('../gsd-core/bin/lib/core.cjs');
const { renderEffortForRuntime } = require('../gsd-core/bin/lib/model-catalog.cjs');
const { isValidConfigKey } = require('../gsd-core/bin/lib/config-schema.cjs');
function writeConfig(tmpDir, obj) {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'config.json'),
JSON.stringify(obj, null, 2)
);
}
// ─── Shared HOME isolation (#2517 review finding #8) ────────────────────────
// Without this, a developer's real `~/.gsd/defaults.json` (e.g. one with
// `runtime: codex` set) silently overrides test assertions about back-compat
// behavior. Capture HOME, point it at an isolated tmpdir for the duration of
// each test, restore on teardown.
let _origHome;
let _origGsdHome;
let _isolatedHome;
function isolateHome() {
_origHome = process.env.HOME;
_origGsdHome = process.env.GSD_HOME;
_isolatedHome = fs.mkdtempSync(path.join(os.tmpdir(), 'gsd-home-iso-'));
process.env.HOME = _isolatedHome;
process.env.GSD_HOME = _isolatedHome;
}
function restoreHome() {
if (_origHome === undefined) delete process.env.HOME; else process.env.HOME = _origHome;
if (_origGsdHome === undefined) delete process.env.GSD_HOME; else process.env.GSD_HOME = _origGsdHome;
cleanup(_isolatedHome);
_isolatedHome = null;
}
// ─── Backwards compatibility — no `runtime` set ─────────────────────────────
describe('issue #2517: backwards compat — no runtime key set', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('balanced profile returns Claude alias when runtime absent', () => {
writeConfig(tmpDir, { model_profile: 'balanced' });
// gsd-planner balanced -> opus
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'opus');
});
test('inherit profile still returns "inherit" with no runtime', () => {
writeConfig(tmpDir, { model_profile: 'inherit' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'inherit');
});
test('resolve_model_ids:true still maps alias -> full Claude ID with no runtime', () => {
writeConfig(tmpDir, { model_profile: 'balanced', resolve_model_ids: true });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'claude-opus-4-8');
});
test('resolve_model_ids:"omit" still returns "" with no runtime', () => {
writeConfig(tmpDir, { model_profile: 'balanced', resolve_model_ids: 'omit' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), '');
});
test('effort resolves universally but render param is null when runtime absent', () => {
writeConfig(tmpDir, { model_profile: 'balanced' });
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)', () => {
writeConfig(tmpDir, { model_profile: 'adaptive' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'opus');
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'haiku');
});
});
// ─── runtime: "claude" — no-op (preserves Claude-native semantics) ──────────
describe('issue #2517: runtime "claude" is a no-op for resolution (finding #4)', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('runtime:"claude" + balanced returns the alias, not the resolved Claude ID', () => {
// `runtime: "claude"` is the implicit default — it must not silently flip
// resolve_model_ids on. The alias passes through identically to the unset case.
writeConfig(tmpDir, { runtime: 'claude', model_profile: 'balanced' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'opus');
});
test('runtime:"claude" + resolve_model_ids:"omit" returns "" (finding #4 regression)', () => {
// The pre-fix bug: runtime:"claude" hijacked the resolution chain and
// returned the resolved Claude ID even when the user explicitly asked for the
// omit semantics.
writeConfig(tmpDir, {
runtime: 'claude',
model_profile: 'quality',
resolve_model_ids: 'omit',
});
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), '');
});
test('runtime:"claude" + resolve_model_ids:true maps alias -> full Claude ID', () => {
writeConfig(tmpDir, {
runtime: 'claude',
model_profile: 'quality',
resolve_model_ids: true,
});
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'claude-opus-4-8');
});
test('effort is first-class on Claude (emits output_config.effort)', () => {
writeConfig(tmpDir, { runtime: 'claude', model_profile: 'quality' });
// 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');
});
});
// ─── runtime: "codex" — resolves tiers to Codex IDs + reasoning_effort ──────
describe('issue #2517: runtime "codex" — Codex tier resolution', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('opus tier -> gpt-5.5 model; heavy-tier agent -> xhigh effort on codex', () => {
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'quality' });
// gsd-planner quality -> opus -> gpt-5.5 (model unchanged)
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gpt-5.5');
// 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 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');
// 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 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');
// 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)', () => {
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'adaptive' });
// gsd-planner adaptive -> opus -> gpt-5.5
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gpt-5.5');
// gsd-codebase-mapper adaptive -> haiku -> gpt-5.4-mini
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'gpt-5.4-mini');
});
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');
// 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)', () => {
writeConfig(tmpDir, {
runtime: 'codex',
model_profile: 'quality',
resolve_model_ids: 'omit',
});
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gpt-5.5');
});
});
// ─── Precedence chain ───────────────────────────────────────────────────────
describe('issue #2517: precedence chain', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('per-agent model_overrides wins over runtime tier resolution', () => {
writeConfig(tmpDir, {
runtime: 'codex',
model_profile: 'quality',
model_overrides: { 'gsd-planner': 'gpt-5.4-mini' },
});
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gpt-5.4-mini');
});
test('model_profile_overrides[runtime][tier] beats built-in defaults', () => {
writeConfig(tmpDir, {
runtime: 'codex',
model_profile: 'quality',
model_profile_overrides: {
codex: { opus: 'gpt-5-pro' },
},
});
// gsd-planner quality -> opus -> overridden to gpt-5-pro
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gpt-5-pro');
// haiku not overridden — fall back to spec defaults
// gsd-codebase-mapper quality -> sonnet -> gpt-5.3-codex
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'gpt-5.3-codex');
});
test('partial profile_overrides — only opus overridden, sonnet uses default', () => {
writeConfig(tmpDir, {
runtime: 'codex',
model_profile: 'balanced',
model_profile_overrides: {
codex: { opus: 'gpt-5-pro' }, // only opus overridden
},
});
// gsd-planner balanced -> opus -> overridden to gpt-5-pro
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gpt-5-pro');
// gsd-roadmapper balanced -> sonnet -> spec default
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-roadmapper'), 'gpt-5.3-codex');
});
test('per-agent override beats profile override beats default', () => {
writeConfig(tmpDir, {
runtime: 'codex',
model_profile: 'quality',
model_profile_overrides: { codex: { opus: 'gpt-5-pro' } },
model_overrides: { 'gsd-planner': 'custom-model' },
});
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'custom-model');
});
});
// ─── Field-merge semantics — review findings #2 ─────────────────────────────
describe('issue #2517: field-merge of overrides with built-in defaults (finding #2)', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
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');
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; 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.5');
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: model replaced; unified effort from routing tier (not catalog field)', () => {
writeConfig(tmpDir, {
runtime: 'codex',
model_profile: 'quality',
model_profile_overrides: {
codex: { opus: { model: 'custom-model', reasoning_effort: 'minimal' } },
},
});
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'custom-model');
// 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', () => {
// Direct unit-test of the shared helper used by core + install.js.
const entry = resolveTierEntry({
runtime: 'codex',
tier: 'opus',
overrides: { codex: { opus: 'gpt-5-pro' } },
});
assert.deepStrictEqual(entry, { model: 'gpt-5-pro', reasoning_effort: 'xhigh' });
});
test('resolveTierEntry helper: partial-object merge keeps built-in model', () => {
const entry = resolveTierEntry({
runtime: 'codex',
tier: 'opus',
overrides: { codex: { opus: { reasoning_effort: 'low' } } },
});
assert.deepStrictEqual(entry, { model: 'gpt-5.5', reasoning_effort: 'low' });
});
test('resolveTierEntry helper: unknown runtime + no overrides -> null', () => {
const entry = resolveTierEntry({
runtime: 'mystery',
tier: 'opus',
overrides: null,
});
assert.strictEqual(entry, null);
});
});
// ─── 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: 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',
model_profile_overrides: {
mystery: { opus: { model: 'mystery-opus', reasoning_effort: 'xhigh' } },
},
});
// Model still resolves (overrides are honored).
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'mystery-opus');
// 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": 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' } } },
});
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
const rendered = renderEffortForRuntime('codx', eff);
assert.strictEqual(rendered.param, null);
});
});
// ─── Unknown runtime / unknown tier ─────────────────────────────────────────
describe('issue #2517: unknown runtime + safe fallback', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('unknown runtime falls back to Claude-alias safe default (no Codex IDs leaked)', () => {
writeConfig(tmpDir, { runtime: 'mystery-runtime', model_profile: 'quality' });
// Should NOT emit gpt-5.4 — should fall back to Claude alias
const resolved = resolveModelInternal(tmpDir, 'gsd-planner');
assert.notStrictEqual(resolved, 'gpt-5.4');
assert.strictEqual(resolved, 'opus');
});
test('unknown runtime + user-provided overrides for that runtime — uses overrides', () => {
writeConfig(tmpDir, {
runtime: 'mystery-runtime',
model_profile: 'quality',
model_profile_overrides: {
'mystery-runtime': { opus: 'mystery-opus' },
},
});
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'mystery-opus');
});
test('runtime:"codex" but missing model_profile_overrides[codex] uses spec defaults', () => {
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'quality' });
// No model_profile_overrides at all — built-in Codex defaults take over
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gpt-5.5');
});
});
// ─── Schema validation (config-set time + load time) ────────────────────────
describe('issue #2517: VALID_CONFIG_KEYS schema', () => {
test('"runtime" is a valid config key', () => {
assert.strictEqual(isValidConfigKey('runtime'), true);
});
test('model_profile_overrides.codex.opus is valid', () => {
assert.strictEqual(isValidConfigKey('model_profile_overrides.codex.opus'), true);
});
test('model_profile_overrides.codex.sonnet is valid', () => {
assert.strictEqual(isValidConfigKey('model_profile_overrides.codex.sonnet'), true);
});
test('model_profile_overrides.codex.haiku is valid', () => {
assert.strictEqual(isValidConfigKey('model_profile_overrides.codex.haiku'), true);
});
test('model_profile_overrides.claude.opus is valid', () => {
assert.strictEqual(isValidConfigKey('model_profile_overrides.claude.opus'), true);
});
test('model_profile_overrides with unknown runtime is valid (free-string runtime)', () => {
assert.strictEqual(isValidConfigKey('model_profile_overrides.acme.opus'), true);
});
test('model_profile_overrides with bogus tier is rejected', () => {
assert.strictEqual(isValidConfigKey('model_profile_overrides.codex.banana'), false);
});
test('model_profile_overrides without tier is rejected', () => {
assert.strictEqual(isValidConfigKey('model_profile_overrides.codex'), false);
});
test('model_profile_overrides root key alone is rejected (must include runtime+tier)', () => {
assert.strictEqual(isValidConfigKey('model_profile_overrides'), false);
});
});
// ─── loadConfig validation warnings (review findings #10, #13) ──────────────
describe('issue #2517: loadConfig warns on unknown runtime/tier (findings #10, #13)', () => {
const { loadConfig } = require('../gsd-core/bin/lib/core.cjs');
let tmpDir;
let origWrite;
let captured;
beforeEach(() => {
isolateHome();
tmpDir = createTempProject();
_resetRuntimeWarningCacheForTests();
captured = [];
origWrite = process.stderr.write.bind(process.stderr);
process.stderr.write = (chunk) => { captured.push(String(chunk)); return true; };
});
afterEach(() => { process.stderr.write = origWrite; cleanup(tmpDir); restoreHome(); });
test('unknown runtime triggers a stderr warning', () => {
writeConfig(tmpDir, { runtime: 'codx', model_profile: 'quality' });
loadConfig(tmpDir);
const joined = captured.join('');
assert.match(joined, /unknown value "codx"/);
});
test('known runtime does NOT trigger a runtime warning', () => {
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'quality' });
loadConfig(tmpDir);
const joined = captured.join('');
assert.doesNotMatch(joined, /unknown value/);
});
test('unknown tier in overrides triggers a stderr warning', () => {
writeConfig(tmpDir, {
runtime: 'codex',
model_profile_overrides: { codex: { banana: 'whatever' } },
});
loadConfig(tmpDir);
const joined = captured.join('');
assert.match(joined, /unknown tier "banana"/);
});
test('unknown runtime in overrides triggers a stderr warning', () => {
writeConfig(tmpDir, {
runtime: 'codex',
model_profile_overrides: { mystery: { opus: 'whatever' } },
});
loadConfig(tmpDir);
const joined = captured.join('');
assert.match(joined, /model_profile_overrides\.mystery\.\* uses unknown runtime/);
});
test('every name in KNOWN_RUNTIMES survives the warning gate', () => {
// Smoke check: `KNOWN_RUNTIMES` must list every runtime `bin/install.js`
// emits for, otherwise legitimate users get spammed at every loadConfig.
for (const r of KNOWN_RUNTIMES) {
assert.ok(typeof r === 'string' && r.length > 0);
}
});
});
// ─── End-to-end: per-project config -> Codex TOML emit (finding #1) ─────────
describe('issue #2517: install end-to-end — per-project config reaches Codex TOML (finding #1)', () => {
// Load install.js in test-mode so its module exports are populated.
const prevTestMode = process.env.GSD_TEST_MODE;
process.env.GSD_TEST_MODE = '1';
const installMod = require('../bin/install.js');
if (prevTestMode === undefined) delete process.env.GSD_TEST_MODE;
else process.env.GSD_TEST_MODE = prevTestMode;
const { readGsdRuntimeProfileResolver, generateCodexAgentToml } = installMod;
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('readGsdRuntimeProfileResolver picks up runtime from .planning/config.json', () => {
// No ~/.gsd/defaults.json (HOME is isolated tmpdir). Per-project config alone
// must drive the resolver — pre-fix, it returned null.
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'quality' });
const resolver = readGsdRuntimeProfileResolver(tmpDir);
assert.ok(resolver, 'expected a resolver from per-project config');
assert.strictEqual(resolver.runtime, 'codex');
const entry = resolver.resolve('gsd-planner');
assert.deepStrictEqual(entry, { model: 'gpt-5.5', reasoning_effort: 'xhigh' });
});
test('per-project config wins over global ~/.gsd/defaults.json', () => {
fs.mkdirSync(path.join(_isolatedHome, '.gsd'), { recursive: true });
fs.writeFileSync(
path.join(_isolatedHome, '.gsd', 'defaults.json'),
JSON.stringify({ runtime: 'claude', model_profile: 'budget' })
);
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'quality' });
const resolver = readGsdRuntimeProfileResolver(tmpDir);
assert.strictEqual(resolver.runtime, 'codex');
const entry = resolver.resolve('gsd-planner');
assert.strictEqual(entry.model, 'gpt-5.5');
});
test('generated Codex TOML embeds model = and model_reasoning_effort = lines', () => {
writeConfig(tmpDir, { runtime: 'codex', model_profile: 'quality' });
const resolver = readGsdRuntimeProfileResolver(tmpDir);
const toml = generateCodexAgentToml(
'gsd-planner',
'---\nname: gsd-planner\ndescription: Planner agent\n---\nBody.\n',
null,
resolver
);
assert.match(toml, /^model = "gpt-5\.5"$/m);
assert.match(toml, /^model_reasoning_effort = "xhigh"$/m);
});
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',
model_profile_overrides: { codex: { opus: { model: 'custom', reasoning_effort: '' } } },
});
const resolver = readGsdRuntimeProfileResolver(tmpDir);
const toml = generateCodexAgentToml(
'gsd-planner',
'---\nname: gsd-planner\n---\nBody.\n',
null,
resolver
);
// Model override (from model_profile_overrides) is still respected.
assert.match(toml, /^model = "custom"$/m);
// 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', () => {
// Sanity: nothing configured -> nothing emitted. Pre-existing back-compat.
const resolver = readGsdRuntimeProfileResolver(tmpDir);
assert.strictEqual(resolver, null);
});
test('inline require paths resolve relative to install.js __dirname (finding #6)', () => {
// Defensive: assert the lib files install.js requires actually exist at
// resolver-construction time. Catches accidental relative-path drift in CI.
const installDir = path.dirname(require.resolve('../bin/install.js'));
const libDir = path.join(installDir, '..', 'gsd-core', 'bin', 'lib');
assert.ok(fs.existsSync(path.join(libDir, 'core.cjs')));
assert.ok(fs.existsSync(path.join(libDir, 'model-profiles.cjs')));
});
});
// ─── RUNTIME_PROFILE_MAP single source of truth (finding #16) ───────────────
describe('issue #2517: RUNTIME_PROFILE_MAP single source of truth (finding #16)', () => {
test('install.js consumes the same map as core.cjs', () => {
// `bin/install.js` must NOT carry its own duplicate copy of the map.
// The shared resolver imported in install.js exposes `runtime` and the
// entries through `resolveTierEntry`, so any future drift between the two
// files would surface as a test failure here rather than a silent bug.
const codexOpus = RUNTIME_PROFILE_MAP.codex?.opus;
assert.deepStrictEqual(codexOpus, { model: 'gpt-5.5', reasoning_effort: 'xhigh' });
const claudeOpus = RUNTIME_PROFILE_MAP.claude?.opus;
assert.deepStrictEqual(claudeOpus, { model: 'claude-opus-4-8' });
});
});
// ─── Issue #2612: gemini runtime tier resolution ─────────────────────────────
describe('issue #2612: runtime "gemini" — Gemini tier resolution', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('opus tier -> gemini-3-pro', () => {
writeConfig(tmpDir, { runtime: 'gemini', model_profile: 'quality' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gemini-3-pro');
});
test('sonnet tier -> gemini-3-flash', () => {
writeConfig(tmpDir, { runtime: 'gemini', model_profile: 'balanced' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-roadmapper'), 'gemini-3-flash');
});
test('haiku tier -> gemini-2.5-flash-lite', () => {
writeConfig(tmpDir, { runtime: 'gemini', model_profile: 'budget' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'gemini-2.5-flash-lite');
});
test('gemini: effort resolves universally but render param is null (no wire param)', () => {
writeConfig(tmpDir, { runtime: 'gemini', model_profile: 'quality' });
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
assert.strictEqual(renderEffortForRuntime('gemini', eff).param, null);
});
});
// ─── Issue #2612: qwen runtime tier resolution ───────────────────────────────
describe('issue #2612: runtime "qwen" — Qwen tier resolution', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('opus tier -> qwen3-max-2026-01-23', () => {
writeConfig(tmpDir, { runtime: 'qwen', model_profile: 'quality' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'qwen3-max-2026-01-23');
});
test('sonnet tier -> qwen3-coder-plus', () => {
writeConfig(tmpDir, { runtime: 'qwen', model_profile: 'balanced' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-roadmapper'), 'qwen3-coder-plus');
});
test('haiku tier -> qwen3-coder-next', () => {
writeConfig(tmpDir, { runtime: 'qwen', model_profile: 'budget' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'qwen3-coder-next');
});
test('qwen: effort resolves universally but render param is null (no wire param)', () => {
writeConfig(tmpDir, { runtime: 'qwen', model_profile: 'quality' });
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
assert.strictEqual(renderEffortForRuntime('qwen', eff).param, null);
});
});
// ─── Issue #2612: opencode runtime tier resolution ───────────────────────────
describe('issue #2612: runtime "opencode" — OpenCode tier resolution', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('opus tier -> anthropic/claude-opus-4-8', () => {
writeConfig(tmpDir, { runtime: 'opencode', model_profile: 'quality' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'anthropic/claude-opus-4-8');
});
test('sonnet tier -> anthropic/claude-sonnet-4-6', () => {
writeConfig(tmpDir, { runtime: 'opencode', model_profile: 'balanced' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-roadmapper'), 'anthropic/claude-sonnet-4-6');
});
test('haiku tier -> anthropic/claude-haiku-4-5', () => {
writeConfig(tmpDir, { runtime: 'opencode', model_profile: 'budget' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'anthropic/claude-haiku-4-5');
});
test('opencode: effort resolves universally but render param is null (no wire param)', () => {
writeConfig(tmpDir, { runtime: 'opencode', model_profile: 'quality' });
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
assert.strictEqual(renderEffortForRuntime('opencode', eff).param, null);
});
});
// ─── Issue #2612: copilot runtime tier resolution ────────────────────────────
describe('issue #2612: runtime "copilot" — Copilot tier resolution', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('opus tier -> claude-opus-4-8', () => {
writeConfig(tmpDir, { runtime: 'copilot', model_profile: 'quality' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'claude-opus-4-8');
});
test('sonnet tier -> claude-sonnet-4-6', () => {
writeConfig(tmpDir, { runtime: 'copilot', model_profile: 'balanced' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-roadmapper'), 'claude-sonnet-4-6');
});
test('haiku tier -> claude-haiku-4-5', () => {
writeConfig(tmpDir, { runtime: 'copilot', model_profile: 'budget' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'claude-haiku-4-5');
});
test('copilot: effort resolves universally but render param is null (no wire param)', () => {
writeConfig(tmpDir, { runtime: 'copilot', model_profile: 'quality' });
const eff = resolveEffortInternal(tmpDir, 'gsd-planner');
assert.strictEqual(renderEffortForRuntime('copilot', eff).param, null);
});
});
// ─── Issue #2612: Group B runtimes fall through (no built-in map) ────────────
describe('issue #2612: Group B runtimes — no built-in map, use unknown-runtime fallback', () => {
test('cursor is not in RUNTIME_PROFILE_MAP (uses unknown-runtime fallback)', () => {
assert.strictEqual(RUNTIME_PROFILE_MAP.cursor, undefined);
});
test('kilo is not in RUNTIME_PROFILE_MAP', () => {
assert.strictEqual(RUNTIME_PROFILE_MAP.kilo, undefined);
});
test('windsurf is not in RUNTIME_PROFILE_MAP', () => {
assert.strictEqual(RUNTIME_PROFILE_MAP.windsurf, undefined);
});
test('cline is not in RUNTIME_PROFILE_MAP', () => {
assert.strictEqual(RUNTIME_PROFILE_MAP.cline, undefined);
});
test('augment is not in RUNTIME_PROFILE_MAP', () => {
assert.strictEqual(RUNTIME_PROFILE_MAP.augment, undefined);
});
test('trae is not in RUNTIME_PROFILE_MAP', () => {
assert.strictEqual(RUNTIME_PROFILE_MAP.trae, undefined);
});
test('codebuddy is not in RUNTIME_PROFILE_MAP', () => {
assert.strictEqual(RUNTIME_PROFILE_MAP.codebuddy, undefined);
});
test('antigravity is not in RUNTIME_PROFILE_MAP', () => {
assert.strictEqual(RUNTIME_PROFILE_MAP.antigravity, undefined);
});
test('cursor runtime falls back to Claude alias (not a Gemini/Qwen/etc ID)', () => {
const { createTempProject, cleanup } = require('./helpers.cjs');
isolateHome();
const tmpDir = createTempProject();
_resetRuntimeWarningCacheForTests();
try {
writeConfig(tmpDir, { runtime: 'cursor', model_profile: 'quality' });
// Should fall back to Claude alias, not emit a provider-specific ID
const resolved = resolveModelInternal(tmpDir, 'gsd-planner');
assert.strictEqual(resolved, 'opus');
} finally {
cleanup(tmpDir);
restoreHome();
}
});
});
// ─── Issue #2612: Partial override merge for new runtimes ────────────────────
describe('issue #2612: partial override merge for new Group A runtimes', () => {
let tmpDir;
beforeEach(() => { isolateHome(); tmpDir = createTempProject(); _resetRuntimeWarningCacheForTests(); });
afterEach(() => { cleanup(tmpDir); restoreHome(); });
test('gemini.opus override wins; sonnet and haiku use built-in defaults', () => {
writeConfig(tmpDir, {
runtime: 'gemini',
model_profile: 'quality',
model_profile_overrides: {
gemini: { opus: 'gemini-3-ultra' },
},
});
// opus is overridden
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'gemini-3-ultra');
// sonnet not overridden — built-in default (quality -> sonnet for gsd-codebase-mapper)
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'gemini-3-flash');
});
test('qwen.opus override wins; sonnet and haiku use built-in defaults', () => {
writeConfig(tmpDir, {
runtime: 'qwen',
model_profile: 'quality',
model_profile_overrides: {
qwen: { opus: 'qwen3-max-custom' },
},
});
// opus is overridden
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'qwen3-max-custom');
// sonnet not overridden — quality -> sonnet for gsd-codebase-mapper
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'qwen3-coder-plus');
});
test('opencode.sonnet override wins; opus and haiku still use built-in defaults', () => {
writeConfig(tmpDir, {
runtime: 'opencode',
model_profile: 'balanced',
model_profile_overrides: {
opencode: { sonnet: 'anthropic/claude-sonnet-4-7' },
},
});
// gsd-planner balanced -> opus -> built-in default
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'anthropic/claude-opus-4-8');
// gsd-roadmapper balanced -> sonnet -> overridden
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-roadmapper'), 'anthropic/claude-sonnet-4-7');
// gsd-codebase-mapper balanced -> haiku -> built-in default (haiku not overridden)
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'anthropic/claude-haiku-4-5');
});
test('copilot.haiku override wins; opus and sonnet still use built-in defaults', () => {
writeConfig(tmpDir, {
runtime: 'copilot',
model_profile: 'budget',
model_profile_overrides: {
copilot: { haiku: 'claude-haiku-4-6' },
},
});
// gsd-codebase-mapper budget -> haiku -> overridden
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'claude-haiku-4-6');
// gsd-planner budget -> sonnet -> built-in default
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'claude-sonnet-4-6');
});
});