* enhance(#4273): add phase.tdd-applicable single-owner predicate One query verb computes TDD-applicability for a plan (CLI flag, plan type: tdd frontmatter, a task's tdd="true" attribute, or the workflow.tdd_mode config default), mirroring phase.mvp-mode's precedence-cascade shape. Foundation for epic #4272 Phase 2, which wires both dispatch backends to consume it instead of restating the predicate independently. Also fixes workflow.tdd_mode, workflow.research, and workflow.nyquist_validation, which never reached cmdInitExecutePhase/cmdInitPlanPhase/cmdInitDebug/cmdInitNewMilestone because loadConfig() never populates config.workflow — a dead accessor found while wiring this verb's own config read, fixed inline per the no-defer rule rather than left alongside it. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * docs(#4273): document phase.tdd-applicable's FEATURES.md entry Add a docs/features/ fragment for the new phase.tdd-applicable query verb and regenerate docs/FEATURES.md. docs/COMMANDS.md is left untouched: it documents /gsd-* slash commands only, and the sibling verb phase.tdd-applicable mirrors (phase.mvp-mode) has no formal CLI reference entry anywhere in docs/ either -- only inline prose mentions in docs/reference/workflow-fragments.md -- so there is no COMMANDS.md precedent to extend. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(#4273): use PHASE_NOT_FOUND reason code, remove try/finally from tests Two orthogonal code reviews flagged a mistyped error reason and a CONTRIBUTING.md-banned try/finally pattern in the phase.tdd-applicable change; both are corrected here. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(#4273): stop whitelisting capability-owned config keys centrally workflow.tdd_mode, workflow.research, and workflow.nyquist_validation are each already owned by their own first-party capability's federated config schema (the tdd/research/nyquist capabilities declare them under their own capability.json `config`), resolved via isCapabilityConfigKey. Adding them to gsd-core/bin/shared/config-schema.manifest.json's central validKeys, as the prior commit in this branch did (mirroring workflow.mvp_mode, which genuinely is central-only), declares the same key in two places at once. That collision breaks capability-loader.cts's loadRegistry composition: gsd-test caught this as 84-85 unrelated failures across capability-cli/capability-command-dispatch/capability-lifecycle test files, every one showing "unknown capability: <id>" for a freshly-installed third-party capability that should have resolved fine. Verified directly (not asserted): reverting only this file, keeping the config-loader.cts tdd_mode/research/nyquist_validation flattening and the init.cts call-site fixes from the prior commit, and re-running the exact capability install + capability set repro from tests/capability-cli.test.cjs's "issue-2322" test locally reproduces the failure with the whitelist entries present and clears it without them. loadConfig() still surfaces all three flattened values correctly with no central whitelist entry (confirmed directly against the compiled module) — the whitelist additions were never required for the #4273 fix to work; they were an incorrect over-application of the mvp_mode precedent to keys that aren't central. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(#4273): use getNested for tdd_mode (no legacy top-level fallback), allowlist new test file Both fixes address defects found by a gsd-test bench run: tdd_mode routed through get() invented an undocumented top-level alias that silently outranked the canonical workflow.tdd_mode key, and the new phase-tdd-applicable test file was missing from the file-count allowlist. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * chore(#4273): backfill changeset PR number Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: sim <sim@local> Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4612,6 +4612,117 @@ describe('init section manifest', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('init tdd_mode: workflow.tdd_mode config flows through loadConfig (#4273 defect fix)', () => {
|
||||
// Regression test for a pre-existing defect fixed alongside #4273's
|
||||
// `phase.tdd-applicable` work: `loadConfig()` (src/config-loader.cts)
|
||||
// had no flattened `tdd_mode` field, so every `(config.workflow ?? {})`
|
||||
// call site in this file always read `{}` — `workflow.tdd_mode` set in
|
||||
// `.planning/config.json` silently never reached `cmdInitExecutePhase`,
|
||||
// `cmdInitPlanPhase`, or `cmdInitDebug`'s `tdd_mode` output field, despite
|
||||
// `workflow.tdd_mode` being a documented config contract
|
||||
// (gsd-core/references/tdd.md). `loadConfig()` now flattens
|
||||
// `workflow.tdd_mode` onto `config.tdd_mode` — mirroring the existing
|
||||
// `workflow.mvp_mode` -> `config.mvp_mode` pattern — and all three call
|
||||
// sites read `config.tdd_mode` directly instead of the dead `wf['tdd_mode']`
|
||||
// lookup. Before the fix, every assertion below would have failed
|
||||
// (`body.tdd_mode` would read `false` regardless of the config value).
|
||||
function writeWorkflowConfig(dir, workflowConfig) {
|
||||
fs.writeFileSync(path.join(dir, '.planning', 'config.json'), JSON.stringify({ workflow: workflowConfig }));
|
||||
}
|
||||
|
||||
test('executePhaseTddModeReflectsWorkflowConfig', (t) => {
|
||||
const dir = seedSinglePhaseProject(t, 'gsd-tdd-exec-');
|
||||
writeWorkflowConfig(dir, { tdd_mode: true });
|
||||
const body = parseOkJson(runExecutePhase(['1'], dir), 'tdd-exec');
|
||||
assert.equal(body.tdd_mode, true, 'workflow.tdd_mode: true must flow through to the tdd_mode output field');
|
||||
});
|
||||
|
||||
test('executePhaseTddModeFalseWhenConfigAbsent', (t) => {
|
||||
const dir = seedSinglePhaseProject(t, 'gsd-tdd-exec-absent-');
|
||||
const body = parseOkJson(runExecutePhase(['1'], dir), 'tdd-exec-absent');
|
||||
assert.equal(body.tdd_mode, false);
|
||||
});
|
||||
|
||||
test('planPhaseTddModeReflectsWorkflowConfig', (t) => {
|
||||
const dir = seedSinglePhaseProject(t, 'gsd-tdd-plan-');
|
||||
writeWorkflowConfig(dir, { tdd_mode: true });
|
||||
const body = parseOkJson(runSectionManifestCli(['init.plan-phase', '1'], dir), 'tdd-plan');
|
||||
assert.equal(body.tdd_mode, true, 'workflow.tdd_mode: true must flow through to the tdd_mode output field');
|
||||
});
|
||||
|
||||
test('planPhaseTddModeFalseWhenConfigAbsent', (t) => {
|
||||
const dir = seedSinglePhaseProject(t, 'gsd-tdd-plan-absent-');
|
||||
const body = parseOkJson(runSectionManifestCli(['init.plan-phase', '1'], dir), 'tdd-plan-absent');
|
||||
assert.equal(body.tdd_mode, false);
|
||||
});
|
||||
|
||||
test('debugTddModeReflectsWorkflowConfig', (t) => {
|
||||
const dir = seedSinglePhaseProject(t, 'gsd-tdd-debug-');
|
||||
writeWorkflowConfig(dir, { tdd_mode: true });
|
||||
const body = parseOkJson(runSectionManifestCli(['init.debug'], dir), 'tdd-debug');
|
||||
assert.equal(body.tdd_mode, true, 'workflow.tdd_mode: true must flow through to the tdd_mode output field');
|
||||
});
|
||||
|
||||
test('debugTddModeFalseWhenConfigFalse', (t) => {
|
||||
const dir = seedSinglePhaseProject(t, 'gsd-tdd-debug-false-');
|
||||
writeWorkflowConfig(dir, { tdd_mode: false });
|
||||
const body = parseOkJson(runSectionManifestCli(['init.debug'], dir), 'tdd-debug-false');
|
||||
assert.equal(body.tdd_mode, false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('init research_enabled/nyquist_validation_enabled: workflow.research + workflow.nyquist_validation config flow through loadConfig (#4273 defect fix)', () => {
|
||||
// Regression test for the same dead-accessor class as the tdd_mode block
|
||||
// above, found while fixing it: `cmdInitNewMilestone`'s `research_enabled`
|
||||
// and `cmdInitPlanPhase`'s `research_enabled` / `nyquist_validation_enabled`
|
||||
// all read through `(config.workflow ?? {})` (`wf`), which `loadConfig()`
|
||||
// never populates — so all three fields were ALWAYS `undefined`,
|
||||
// regardless of `.planning/config.json`. `loadConfig()` already flattens
|
||||
// `workflow.research` -> `config.research` and `workflow.nyquist_validation`
|
||||
// -> `config.nyquist_validation` (both default `true` when unset — see
|
||||
// gsd-core/bin/shared/config-defaults.manifest.json); these call sites now
|
||||
// read the flattened fields directly instead of the dead `wf[...]` lookup.
|
||||
// Before the fix, every assertion below would have failed (`undefined`
|
||||
// regardless of config, dropped entirely from the JSON output).
|
||||
function writeWorkflowConfig(dir, workflowConfig) {
|
||||
fs.writeFileSync(path.join(dir, '.planning', 'config.json'), JSON.stringify({ workflow: workflowConfig }));
|
||||
}
|
||||
|
||||
test('newMilestoneResearchEnabledDefaultsTrue', (t) => {
|
||||
const dir = fs.realpathSync(createFixture());
|
||||
t.after(() => cleanup(dir));
|
||||
const result = runGsdTools('init new-milestone', dir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const body = JSON.parse(result.output);
|
||||
assert.strictEqual(body.research_enabled, true, 'workflow.research defaults to true and must flow through to research_enabled');
|
||||
});
|
||||
|
||||
test('newMilestoneResearchEnabledReflectsWorkflowConfigFalse', (t) => {
|
||||
const dir = fs.realpathSync(createFixture());
|
||||
t.after(() => cleanup(dir));
|
||||
writeWorkflowConfig(dir, { research: false });
|
||||
const result = runGsdTools('init new-milestone', dir);
|
||||
assert.ok(result.success, `Command failed: ${result.error}`);
|
||||
const body = JSON.parse(result.output);
|
||||
assert.strictEqual(body.research_enabled, false, 'workflow.research: false must flow through to research_enabled');
|
||||
});
|
||||
|
||||
test('planPhaseResearchAndNyquistEnabledReflectWorkflowConfig', (t) => {
|
||||
const dir = seedSinglePhaseProject(t, 'gsd-research-plan-');
|
||||
writeWorkflowConfig(dir, { research: false, nyquist_validation: false });
|
||||
const body = parseOkJson(runSectionManifestCli(['init.plan-phase', '1'], dir), 'research-plan');
|
||||
assert.strictEqual(body.research_enabled, false, 'workflow.research: false must flow through to research_enabled');
|
||||
assert.strictEqual(body.nyquist_validation_enabled, false, 'workflow.nyquist_validation: false must flow through to nyquist_validation_enabled');
|
||||
});
|
||||
|
||||
test('planPhaseResearchAndNyquistEnabledDefaultTrueWhenConfigAbsent', (t) => {
|
||||
const dir = seedSinglePhaseProject(t, 'gsd-research-plan-absent-');
|
||||
const body = parseOkJson(runSectionManifestCli(['init.plan-phase', '1'], dir), 'research-plan-absent');
|
||||
assert.strictEqual(body.research_enabled, true);
|
||||
assert.strictEqual(body.nyquist_validation_enabled, true);
|
||||
});
|
||||
});
|
||||
|
||||
// ── Row 62: stub <execution_context> @-refs still resolve (ADR-0002) ────
|
||||
|
||||
describe('commands/gsd/execute-phase.md: <execution_context> @-refs resolve (#2932 row 62)', () => {
|
||||
|
||||
Reference in New Issue
Block a user