* 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>
161 lines
6.5 KiB
JavaScript
161 lines
6.5 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* Unit tests for `gsd-tools phase tdd-applicable` (#4273, Phase 1 of epic #4272).
|
|
*
|
|
* Matrix rows referenced below are from
|
|
* .gsd/phase/feat-4273-tdd-applicable-query-verb/50-test-matrix.md
|
|
*/
|
|
|
|
const path = require('node:path');
|
|
const fs = require('node:fs');
|
|
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const { createTempProject, cleanup, runGsdTools } = require('./helpers.cjs');
|
|
|
|
function writePlan(dir, relPath, content) {
|
|
const full = path.join(dir, relPath);
|
|
fs.mkdirSync(path.dirname(full), { recursive: true });
|
|
fs.writeFileSync(full, content, 'utf8');
|
|
return full;
|
|
}
|
|
|
|
describe('phase.tdd-applicable', () => {
|
|
test('row 9 — --cli-flag wins regardless of plan content', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const planPath = writePlan(tmpDir, '.planning/phases/01-x/01-PLAN.md', `---
|
|
type: standard
|
|
---
|
|
<task type="auto"><name>a</name></task>
|
|
`);
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable', planPath, '--cli-flag'], tmpDir);
|
|
assert.equal(result.success, true, result.error);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.equal(parsed.applicable, true);
|
|
assert.equal(parsed.source, 'cli_flag');
|
|
});
|
|
|
|
test('row 10 — plan frontmatter type: tdd, no flag', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const planPath = writePlan(tmpDir, '.planning/phases/01-x/01-PLAN.md', `---
|
|
type: tdd
|
|
---
|
|
<task type="auto"><name>a</name></task>
|
|
`);
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable', planPath], tmpDir);
|
|
assert.equal(result.success, true, result.error);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.equal(parsed.applicable, true);
|
|
assert.equal(parsed.source, 'plan_frontmatter');
|
|
});
|
|
|
|
test('row 11 — mixed-mode plan: standard plan, one tdd="true" task (the #4265 shape)', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const planPath = writePlan(tmpDir, '.planning/phases/01-x/01-PLAN.md', `---
|
|
type: standard
|
|
---
|
|
<task type="auto"><name>a</name></task>
|
|
<task type="auto" tdd="true"><name>b</name></task>
|
|
`);
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable', planPath], tmpDir);
|
|
assert.equal(result.success, true, result.error);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.equal(parsed.applicable, true);
|
|
assert.equal(parsed.source, 'task_attribute');
|
|
});
|
|
|
|
test('row 12 — config.workflow.tdd_mode true, nothing else set', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const planPath = writePlan(tmpDir, '.planning/phases/01-x/01-PLAN.md', `<task type="auto"><name>a</name></task>\n`);
|
|
const configPath = path.join(tmpDir, '.planning', 'config.json');
|
|
fs.writeFileSync(configPath, JSON.stringify({ workflow: { tdd_mode: true } }), 'utf8');
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable', planPath], tmpDir);
|
|
assert.equal(result.success, true, result.error);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.equal(parsed.applicable, true);
|
|
assert.equal(parsed.source, 'config');
|
|
});
|
|
|
|
test('row 13 — nothing set: applicable false, source none', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const planPath = writePlan(tmpDir, '.planning/phases/01-x/01-PLAN.md', `<task type="auto"><name>a</name></task>\n`);
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable', planPath], tmpDir);
|
|
assert.equal(result.success, true, result.error);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.equal(parsed.applicable, false);
|
|
assert.equal(parsed.source, 'none');
|
|
});
|
|
|
|
test('row 14 — missing plan file: non-zero exit, no silent false', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const missingPath = path.join(tmpDir, '.planning', 'phases', '01-x', 'does-not-exist-PLAN.md');
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable', missingPath], tmpDir);
|
|
assert.equal(result.success, false);
|
|
});
|
|
|
|
test('row 15 — missing plan-id argument: USAGE error, non-zero exit', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable'], tmpDir);
|
|
assert.equal(result.success, false);
|
|
});
|
|
|
|
test('row 16 — independence: --cli-flag wins over type: standard', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const planPath = writePlan(tmpDir, '.planning/phases/01-x/01-PLAN.md', `---
|
|
type: standard
|
|
---
|
|
<task type="auto"><name>a</name></task>
|
|
`);
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable', planPath, '--cli-flag'], tmpDir);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.equal(parsed.source, 'cli_flag');
|
|
});
|
|
|
|
test('row 17 — independence: type: tdd wins over a task with no tdd attribute (task tier never consulted)', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const planPath = writePlan(tmpDir, '.planning/phases/01-x/01-PLAN.md', `---
|
|
type: tdd
|
|
---
|
|
<task type="auto"><name>a</name></task>
|
|
`);
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable', planPath], tmpDir);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.equal(parsed.source, 'plan_frontmatter');
|
|
});
|
|
|
|
test('row 18 — JSON output shape names every source field', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const planPath = writePlan(tmpDir, '.planning/phases/01-x/01-PLAN.md', `<task type="auto"><name>a</name></task>\n`);
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable', planPath], tmpDir);
|
|
assert.equal(result.success, true, result.error);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.ok('applicable' in parsed);
|
|
assert.ok('source' in parsed);
|
|
assert.ok('plan_type' in parsed);
|
|
assert.ok('config_tdd_mode' in parsed);
|
|
assert.ok('cli_flag_present' in parsed);
|
|
});
|
|
|
|
test('row 19 — empty plan file (no frontmatter, no tasks) falls through, not an error', (t) => {
|
|
const tmpDir = createTempProject();
|
|
t.after(() => cleanup(tmpDir));
|
|
const planPath = writePlan(tmpDir, '.planning/phases/01-x/01-PLAN.md', '');
|
|
const result = runGsdTools(['query', 'phase.tdd-applicable', planPath], tmpDir);
|
|
assert.equal(result.success, true, result.error);
|
|
const parsed = JSON.parse(result.output);
|
|
assert.equal(parsed.applicable, false);
|
|
assert.equal(parsed.source, 'none');
|
|
});
|
|
});
|