test(#1972): consolidate 94 command/module regression tests into subject suites

Fold 94 issue-named command/module regression files into the canonical test file
that owns each subject-under-test, across 52 existing suites (state, config, frontmatter,
roadmap-parser, capability-registry, shell-command-projection-dispatch, plan-phase-drift-guard,
health-validation, runtime-converters, commands, etc.). Verbatim block-scoped describe
wrappers; 881 subtests conserved 1:1. No new test files.

Host-env pre-check (per B2): the only GSD_WORKSTREAM/GSD_PROJECT-touching destinations
(intel, planning-workspace) clear those vars hermetically, so folded CLI tests are safe.

Regenerates regression-name allowlist (222->162), ratchets file-count allowlist across
8 buckets (validate entry removed after dropping <=2), makes 34 relocated allow-test-rule
exemptions issue-ref-compliant (ADR-456; prunes 34 stale ids). Repoints CONTEXT.md +
ADR-0002/443/1235/3524 test-file references. lint:ci green.

Part of epic #1969. Closes #1972.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-07-03 01:54:30 -04:00
parent f9987600f2
commit 85ed50cc4f
154 changed files with 21333 additions and 20523 deletions

View File

@@ -625,3 +625,358 @@ describe('ADVERSARIAL: edge cases', () => {
assert.strictEqual(at0, at1);
});
});
// ────────────────────────────────────────────────────────────────────────
// Folded from tests/bug-1829-inherit-model-profile.test.cjs — consolidation epic #1969 (B3 #1972)
// ────────────────────────────────────────────────────────────────────────
{
const { describe: __foldDescribe } = require('node:test');
__foldDescribe("folded:bug-1829-inherit-model-profile (consolidation epic #1969 B3 #1972)", () => {
/**
* Regression tests for bug #1829
*
* model_profile: "inherit" in .planning/config.json was not recognised as a
* valid profile. resolveModelInternal() silently fell back to "balanced",
* causing all agents to use "sonnet" instead of inheriting the parent model.
*
* Root cause in core.cjs:
* const profile = config.model_profile || 'balanced';
* const agentModels = MODEL_PROFILES[agentType];
* if (!agentModels) return 'sonnet';
* const resolved = agentModels[profile] || agentModels['balanced'] || 'sonnet';
* // agentModels['inherit'] is undefined → falls through to agentModels['balanced']
*
* Fix 1 (core.cjs): add early return — if (profile === 'inherit') return 'inherit';
* Fix 2 (verify.cjs): add 'inherit' to validProfiles so it doesn't trigger W004.
*/
'use strict';
const { describe, test, beforeEach, afterEach } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const { runGsdTools, createTempProject, cleanup } = require('./helpers.cjs');
const { resolveModelInternal } = require('../gsd-core/bin/lib/model-resolver.cjs');
// ─── Helpers ──────────────────────────────────────────────────────────────────
function writeConfig(tmpDir, obj) {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'config.json'),
JSON.stringify(obj, null, 2)
);
}
function writeMinimalProjectMd(tmpDir) {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'PROJECT.md'),
'# Project\n\n## What This Is\n\nContent.\n\n## Core Value\n\nContent.\n\n## Requirements\n\nContent.\n'
);
}
function writeMinimalRoadmap(tmpDir) {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'ROADMAP.md'),
'# Roadmap\n\n### Phase 1: First Phase\n'
);
}
function writeMinimalStateMd(tmpDir) {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'STATE.md'),
'# Session State\n\n## Current Position\n\nPhase: 1\n'
);
}
// ─── resolveModelInternal — inherit profile ───────────────────────────────────
describe('bug #1829: model_profile "inherit" — resolveModelInternal', () => {
let tmpDir;
beforeEach(() => {
tmpDir = createTempProject();
});
afterEach(() => {
cleanup(tmpDir);
});
test('returns "inherit" for gsd-planner when model_profile is "inherit"', () => {
writeConfig(tmpDir, { model_profile: 'inherit' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'inherit');
});
test('returns "inherit" for gsd-executor when model_profile is "inherit"', () => {
writeConfig(tmpDir, { model_profile: 'inherit' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-executor'), 'inherit');
});
test('returns "inherit" for gsd-phase-researcher when model_profile is "inherit"', () => {
writeConfig(tmpDir, { model_profile: 'inherit' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-phase-researcher'), 'inherit');
});
test('returns "inherit" for gsd-codebase-mapper when model_profile is "inherit"', () => {
writeConfig(tmpDir, { model_profile: 'inherit' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-codebase-mapper'), 'inherit');
});
test('returns "inherit" for gsd-verifier when model_profile is "inherit"', () => {
writeConfig(tmpDir, { model_profile: 'inherit' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-verifier'), 'inherit');
});
test('returns "inherit" for unknown agent with inherit profile', () => {
writeConfig(tmpDir, { model_profile: 'inherit' });
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-nonexistent'), 'inherit');
});
test('per-agent override takes precedence over inherit profile', () => {
writeConfig(tmpDir, {
model_profile: 'inherit',
model_overrides: { 'gsd-executor': 'haiku' },
});
// Override wins even when profile is inherit
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-executor'), 'haiku');
// Other agents without override still inherit
assert.strictEqual(resolveModelInternal(tmpDir, 'gsd-planner'), 'inherit');
});
test('does not silently fall back to "sonnet" (the original bug)', () => {
writeConfig(tmpDir, { model_profile: 'inherit' });
// Before the fix, this returned 'sonnet' (via balanced fallback)
const model = resolveModelInternal(tmpDir, 'gsd-planner');
assert.notStrictEqual(model, 'sonnet', 'inherit profile must not silently fall back to sonnet');
});
});
// ─── resolve-model CLI — inherit profile ──────────────────────────────────────
describe('bug #1829: model_profile "inherit" — resolve-model CLI', () => {
let tmpDir;
beforeEach(() => {
tmpDir = createTempProject();
});
afterEach(() => {
cleanup(tmpDir);
});
test('CLI resolve-model returns "inherit" for gsd-executor with inherit profile', () => {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'config.json'),
JSON.stringify({ model_profile: 'inherit' }, null, 2)
);
const result = runGsdTools('resolve-model gsd-executor', tmpDir);
assert.ok(result.success, `resolve-model failed: ${result.error}`);
const parsed = JSON.parse(result.output);
assert.strictEqual(parsed.model, 'inherit');
assert.strictEqual(parsed.profile, 'inherit');
});
test('CLI resolve-model returns "inherit" for gsd-planner with inherit profile', () => {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'config.json'),
JSON.stringify({ model_profile: 'inherit' }, null, 2)
);
const result = runGsdTools('resolve-model gsd-planner', tmpDir);
assert.ok(result.success, `resolve-model failed: ${result.error}`);
const parsed = JSON.parse(result.output);
assert.strictEqual(parsed.model, 'inherit');
});
});
// ─── verify health — inherit profile is not a validation error ────────────────
describe('bug #1829: model_profile "inherit" — validate health does not warn W004', () => {
let tmpDir;
beforeEach(() => {
tmpDir = createTempProject();
writeMinimalProjectMd(tmpDir);
writeMinimalRoadmap(tmpDir);
writeMinimalStateMd(tmpDir);
fs.mkdirSync(path.join(tmpDir, '.planning', 'phases', '01-first-phase'), { recursive: true });
});
afterEach(() => {
cleanup(tmpDir);
});
test('does not emit W004 for model_profile "inherit"', () => {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'config.json'),
JSON.stringify({
model_profile: 'inherit',
workflow: {
research: true,
plan_check: true,
verifier: true,
nyquist_validation: true,
},
}, null, 2)
);
const result = runGsdTools('validate health', tmpDir);
assert.ok(result.success, `validate health failed: ${result.error}`);
const output = JSON.parse(result.output);
assert.ok(
!output.warnings.some(w => w.code === 'W004'),
`inherit profile must not trigger W004: ${JSON.stringify(output.warnings)}`
);
});
test('still emits W004 for genuinely invalid model_profile values', () => {
fs.writeFileSync(
path.join(tmpDir, '.planning', 'config.json'),
JSON.stringify({ model_profile: 'invalid-profile' }, null, 2)
);
const result = runGsdTools('validate health', tmpDir);
assert.ok(result.success, `validate health failed: ${result.error}`);
const output = JSON.parse(result.output);
assert.ok(
output.warnings.some(w => w.code === 'W004'),
`Invalid profile should trigger W004: ${JSON.stringify(output.warnings)}`
);
});
});
});
}
// ────────────────────────────────────────────────────────────────────────
// Folded from tests/bug-492-effort-manifest-fallback.test.cjs — consolidation epic #1969 (B3 #1972)
// ────────────────────────────────────────────────────────────────────────
{
const { describe: __foldDescribe } = require('node:test');
__foldDescribe("folded:bug-492-effort-manifest-fallback (consolidation epic #1969 B3 #1972)", () => {
'use strict';
/**
* bug-492-effort-manifest-fallback.test.cjs
*
* Verifies resolveEffortInternal's fallback chain when no project config.json
* is present.
*
* Isolation strategy: every test that injects custom effort values writes
* them to a per-test ~/.gsd/defaults.json rooted under a tmpHome, pointed at
* via GSD_HOME. This avoids mutating the module-level CANONICAL_CONFIG_DEFAULTS
* singleton (which caused independence violations under parallel runs).
*
* Test 1 (pure manifest fallback): tmpDir WITH .planning/ but no config.json.
* GSD_HOME points to a bare tmpHome (no defaults.json). loadConfig sees
* .planning/ → returns effort:null → model-resolver reads CANONICAL_CONFIG_DEFAULTS
* directly for routing_tier_defaults.
*
* Tests 2-4 (global-defaults path): bare tmpDir (no .planning/) so loadConfig
* hits the ~/.gsd/defaults.json branch. A test-scoped defaults.json injects
* the desired effort sub-object; model-resolver then takes the effortCfg
* (non-null) branch — no singleton touched.
*/
process.env.GSD_TEST_MODE = '1';
const { describe, test } = 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 { cleanup } = require('./helpers.cjs');
const { resolveEffortInternal } = require('../gsd-core/bin/lib/model-resolver.cjs');
/** Create a bare temp directory with no .planning/ structure */
function createBareTmpDir(prefix = 'gsd-test-') {
return fs.mkdtempSync(path.join(os.tmpdir(), prefix));
}
/** Create a temp home dir and write effort config into .gsd/defaults.json */
function createTmpHomeWithEffort(effortConfig) {
const tmpHome = createBareTmpDir('gsd-home-');
const gsdDir = path.join(tmpHome, '.gsd');
fs.mkdirSync(gsdDir, { recursive: true });
fs.writeFileSync(
path.join(gsdDir, 'defaults.json'),
JSON.stringify({ effort: effortConfig })
);
return tmpHome;
}
describe('#492 manifest effort fallback', () => {
// These tests manage GSD_HOME per-test, so no shared beforeEach/afterEach.
test('routing_tier_defaults manifest fallback still works when no config and no defaults.json', (t) => {
// .planning/ exists → loadConfig returns effort:null → model-resolver reads
// CANONICAL_CONFIG_DEFAULTS['effort']['routing_tier_defaults']['heavy'] = "xhigh".
const tmpDir = createBareTmpDir();
fs.mkdirSync(path.join(tmpDir, '.planning'), { recursive: true });
const tmpHome = createBareTmpDir('gsd-home-');
process.env.GSD_HOME = tmpHome;
t.after(() => {
delete process.env.GSD_HOME;
cleanup(tmpDir);
cleanup(tmpHome);
});
// gsd-planner's default tier is "heavy"; manifest routing_tier_defaults.heavy = "xhigh"
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'xhigh');
});
test('global-defaults effort.agent_overrides wins over routing_tier_defaults when no project config', (t) => {
// bare tmpDir (no .planning/) → loadConfig reads ~/.gsd/defaults.json
// which supplies effort.agent_overrides → resolveEffortInternal returns that value.
const tmpDir = createBareTmpDir();
const tmpHome = createTmpHomeWithEffort({ agent_overrides: { 'gsd-planner': 'max' } });
process.env.GSD_HOME = tmpHome;
t.after(() => {
delete process.env.GSD_HOME;
cleanup(tmpDir);
cleanup(tmpHome);
});
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'max');
});
test('global-defaults effort.default consulted for unknown agent with no project config', (t) => {
// effort.default in defaults.json wins for an agent with no tier mapping.
const tmpDir = createBareTmpDir();
const tmpHome = createTmpHomeWithEffort({ default: 'max' });
process.env.GSD_HOME = tmpHome;
t.after(() => {
delete process.env.GSD_HOME;
cleanup(tmpDir);
cleanup(tmpHome);
});
assert.strictEqual(resolveEffortInternal(tmpDir, 'fictional-agent-xyz-492'), 'max');
});
test('global-defaults agent_overrides takes precedence over routing_tier_defaults', (t) => {
// agent_overrides is checked first (step 2), so "minimal" wins over
// routing_tier_defaults.heavy = "xhigh" (step 3).
const tmpDir = createBareTmpDir();
const tmpHome = createTmpHomeWithEffort({
agent_overrides: { 'gsd-planner': 'minimal' },
routing_tier_defaults: { heavy: 'xhigh' },
});
process.env.GSD_HOME = tmpHome;
t.after(() => {
delete process.env.GSD_HOME;
cleanup(tmpDir);
cleanup(tmpHome);
});
assert.strictEqual(resolveEffortInternal(tmpDir, 'gsd-planner'), 'minimal');
});
});
});
}