Files
get-shit-done/tests/bug-2421-planner-grep-gate-hygiene.test.cjs
Tom Boucher dfa1ecce99 fix(#2418,#2399,#2419,#2421): four workflow and installer bug fixes (#2462)
- #2418: convertClaudeToAntigravityContent now replaces bare ~/.claude and
  $HOME/.claude (no trailing slash) for both global and local installs,
  eliminating the "unreplaced .claude path reference" warnings in
  gsd-debugger.md and update.md during Antigravity installs.

- #2399: plan-phase workflow gains step 13c that commits PLAN.md files
  and STATE.md via gsd-sdk query commit when commit_docs is true.
  Previously commit_docs:true was read but never acted on in plan-phase.

- #2419: new-project.md and new-milestone.md now parse agents_installed
  and missing_agents from the init JSON and warn users clearly when GSD
  agents are not installed, rather than silently failing with "agent type
  not found" when trying to spawn gsd-project-researcher subagents.

- #2421: gsd-planner.md gains a "Grep gate hygiene" rule immediately after
  the Nyquist Rule explaining the self-invalidating grep gate anti-pattern
  and providing comment-stripping alternatives (grep -v, ast-grep).

Tests: 4 new test files (30 tests) all passing.

Closes #2418
Closes #2399
Closes #2419
Closes #2421

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-20 10:09:33 -04:00

70 lines
2.9 KiB
JavaScript

/**
* Bug #2421: gsd-planner emits grep-count acceptance gates that count comment text
*
* The planner must instruct agents to use comment-aware grep patterns in
* <automated> verify blocks. Without this, descriptive comments in file
* headers count against the gate and force authors to reword them — the
* "self-invalidating grep gate" anti-pattern.
*/
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const PLANNER_PATH = path.join(__dirname, '..', 'agents', 'gsd-planner.md');
describe('gsd-planner grep gate hygiene (#2421)', () => {
test('gsd-planner.md exists in agents source dir', () => {
assert.ok(fs.existsSync(PLANNER_PATH), 'agents/gsd-planner.md must exist');
});
test('gsd-planner.md contains Grep gate hygiene rule', () => {
const content = fs.readFileSync(PLANNER_PATH, 'utf-8');
assert.ok(
content.includes('Grep gate hygiene') || content.includes('grep gate hygiene'),
'gsd-planner.md must contain a "Grep gate hygiene" rule to prevent self-invalidating grep gates'
);
});
test('gsd-planner.md explains self-invalidating grep gate anti-pattern', () => {
const content = fs.readFileSync(PLANNER_PATH, 'utf-8');
assert.ok(
content.includes('self-invalidating'),
'gsd-planner.md must describe the "self-invalidating" grep gate anti-pattern'
);
});
test('gsd-planner.md provides comment-stripping grep example', () => {
const content = fs.readFileSync(PLANNER_PATH, 'utf-8');
// Must show a pattern that excludes comment lines (grep -v or grep -vE)
assert.ok(
content.includes('grep -v') || content.includes('grep -vE') || content.includes('-v '),
'gsd-planner.md must provide a comment-stripping grep example (grep -v or grep -vE)'
);
});
test('gsd-planner.md warns against bare zero-count grep gates on whole files', () => {
const content = fs.readFileSync(PLANNER_PATH, 'utf-8');
assert.ok(
content.includes('== 0') || content.includes('zero-count') || content.includes('zero count'),
'gsd-planner.md must warn against bare zero-count grep gates without comment exclusion'
);
});
test('gsd-planner.md grep gate hygiene rule appears after Nyquist Rule', () => {
const content = fs.readFileSync(PLANNER_PATH, 'utf-8');
const nyquistIdx = content.indexOf('Nyquist Rule');
const grepGateIdx = content.indexOf('grep gate hygiene') !== -1
? content.indexOf('grep gate hygiene')
: content.indexOf('Grep gate hygiene');
assert.ok(nyquistIdx !== -1, 'Nyquist Rule must be present in gsd-planner.md');
assert.ok(grepGateIdx !== -1, 'Grep gate hygiene must be present in gsd-planner.md');
assert.ok(
grepGateIdx > nyquistIdx,
`Grep gate hygiene rule (at ${grepGateIdx}) must appear after Nyquist Rule (at ${nyquistIdx})`
);
});
});