feat(workflow): add opt-in TDD pipeline mode (#2119)
* feat(workflow): add opt-in TDD pipeline mode (workflow.tdd_mode) Add workflow.tdd_mode config key (default: false) that enables red-green-refactor as a first-class phase execution mode. When enabled, the planner aggressively applies type: tdd to eligible tasks and the executor enforces RED/GREEN/REFACTOR gate sequence with fail-fast on unexpected GREEN before RED. An end-of-phase collaborative review checkpoint verifies gate compliance. Closes #1871 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(test): allowlist plan-phase.md in prompt injection scan plan-phase.md exceeds 50K chars after TDD mode integration. This is legitimate orchestration complexity, not prompt stuffing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci: trigger CI run * ci: trigger CI run --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -53,7 +53,7 @@ const ALLOWLIST = new Set([
|
||||
'get-shit-done/bin/lib/security.cjs', // The security module itself
|
||||
'get-shit-done/workflows/discuss-phase.md', // Large workflow (~50K) with power mode + i18n
|
||||
'get-shit-done/workflows/execute-phase.md', // Large orchestration workflow (~51K) with wave execution + code-review gate
|
||||
'get-shit-done/workflows/plan-phase.md', // Large orchestration workflow (~52K) with pattern mapper + TDD mode
|
||||
'get-shit-done/workflows/plan-phase.md', // Large orchestration workflow (~51K) with TDD mode integration
|
||||
'hooks/gsd-prompt-guard.js', // The prompt guard hook
|
||||
'tests/security.test.cjs', // Security tests
|
||||
'tests/prompt-injection-scan.test.cjs', // This file
|
||||
|
||||
105
tests/tdd-mode.test.cjs
Normal file
105
tests/tdd-mode.test.cjs
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* GSD Tools Tests — workflow.tdd_mode config key
|
||||
*
|
||||
* Validates that the tdd_mode workflow toggle is a first-class config key
|
||||
* with correct default, round-trip behavior, and presence in VALID_CONFIG_KEYS.
|
||||
*
|
||||
* Requirements: #1871
|
||||
*/
|
||||
|
||||
const { test, describe, 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');
|
||||
|
||||
// ─── helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
function readConfig(tmpDir) {
|
||||
const configPath = path.join(tmpDir, '.planning', 'config.json');
|
||||
return JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
||||
}
|
||||
|
||||
// ─── VALID_CONFIG_KEYS ──────────────────────────────────────────────────────
|
||||
|
||||
describe('workflow.tdd_mode in VALID_CONFIG_KEYS', () => {
|
||||
test('workflow.tdd_mode is a recognized config key', () => {
|
||||
const { VALID_CONFIG_KEYS } = require('../get-shit-done/bin/lib/config.cjs');
|
||||
assert.ok(
|
||||
VALID_CONFIG_KEYS.has('workflow.tdd_mode'),
|
||||
'workflow.tdd_mode should be in VALID_CONFIG_KEYS'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── config default value ───────────────────────────────────────────────────
|
||||
|
||||
describe('workflow.tdd_mode default value', () => {
|
||||
let tmpDir;
|
||||
|
||||
beforeEach(() => {
|
||||
tmpDir = createTempProject();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup(tmpDir);
|
||||
});
|
||||
|
||||
test('defaults to false in new project config', () => {
|
||||
// Ensure config is created with defaults
|
||||
const result = runGsdTools('config-ensure-section', tmpDir, { HOME: tmpDir });
|
||||
assert.ok(result.success, `config-ensure-section failed: ${result.error}`);
|
||||
|
||||
const config = readConfig(tmpDir);
|
||||
assert.strictEqual(
|
||||
config.workflow.tdd_mode,
|
||||
false,
|
||||
'workflow.tdd_mode should default to false'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── config round-trip (set / get) ─────────────────────────────────────────
|
||||
|
||||
describe('workflow.tdd_mode config round-trip', () => {
|
||||
let tmpDir;
|
||||
|
||||
beforeEach(() => {
|
||||
tmpDir = createTempProject();
|
||||
// Create a config file first
|
||||
runGsdTools('config-ensure-section', tmpDir, { HOME: tmpDir });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cleanup(tmpDir);
|
||||
});
|
||||
|
||||
test('config-set workflow.tdd_mode true round-trips via config-get', () => {
|
||||
const setResult = runGsdTools('config-set workflow.tdd_mode true', tmpDir);
|
||||
assert.ok(setResult.success, `config-set failed: ${setResult.error}`);
|
||||
|
||||
const getResult = runGsdTools('config-get workflow.tdd_mode', tmpDir);
|
||||
assert.ok(getResult.success, `config-get failed: ${getResult.error}`);
|
||||
assert.strictEqual(getResult.output, 'true');
|
||||
});
|
||||
|
||||
test('config-set workflow.tdd_mode false round-trips via config-get', () => {
|
||||
// First set to true, then back to false
|
||||
runGsdTools('config-set workflow.tdd_mode true', tmpDir);
|
||||
|
||||
const setResult = runGsdTools('config-set workflow.tdd_mode false', tmpDir);
|
||||
assert.ok(setResult.success, `config-set failed: ${setResult.error}`);
|
||||
|
||||
const getResult = runGsdTools('config-get workflow.tdd_mode', tmpDir);
|
||||
assert.ok(getResult.success, `config-get failed: ${getResult.error}`);
|
||||
assert.strictEqual(getResult.output, 'false');
|
||||
});
|
||||
|
||||
test('persists in config.json as boolean', () => {
|
||||
runGsdTools('config-set workflow.tdd_mode true', tmpDir);
|
||||
|
||||
const config = readConfig(tmpDir);
|
||||
assert.strictEqual(config.workflow.tdd_mode, true);
|
||||
assert.strictEqual(typeof config.workflow.tdd_mode, 'boolean');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user