The windows-test-parity ratchet greps test source for fs.rmSync-without-
maxRetries (and six other Windows-portability anti-patterns), failing when an
integer offender COUNT exceeds a frozen baseline (rmSync: 95). A count ratchet
is a Goodhart metric: fixing one offender and adding another keeps the count
constant, so a new defect slips through green. Replace it — and every other
count ratchet in the repo — with a layered, masking-proof design.
Behavioral seam test
- tests/helpers-cleanup.test.cjs proves helpers.cleanup() carries the Windows
EBUSY retry budget. cleanup() delegates retries to Node's fs.rmSync via
maxRetries (it owns no loop), so the test asserts the option contract
(recursive/force/maxRetries>0/retryDelay>0) + real-FS removal + the cwd-guard,
rather than a loop that does not exist. The EBUSY risk is now tested ONCE at
the helper, not approximated textually at every call site.
Write-time ESLint rule (AST-accurate, replaces the grep)
- eslint-rules/no-raw-rmsync-in-tests.cjs (error in tests/**/*.test.cjs) bans
raw fs.rmSync, steering to cleanup(). Catches member, computed (fs['rmSync']),
destructured and aliased forms; escape hatch is inline
`// eslint-disable-next-line local/no-raw-rmsync-in-tests -- <reason>` only.
- Migrated 336 raw fs.rmSync teardown calls across ~116 test files to cleanup().
~18 genuinely load-bearing sites (mid-test SUT/fault-injection removals,
error-swallowing or name-colliding local teardown helpers) keep the raw call
with an inline eslint-disable + reason.
Shared anti-ratchet primitive
- scripts/lib/allowlist-ratchet.cjs:
- assertWithinAllowlist: fails on NOVEL ids (new offender introduced) AND on
STALE ids (a known offender was fixed but not pruned) — identity, not count,
and a ratchet DOWN toward zero.
- assertTightCeiling: a size/length budget whose ceiling must stay within a
grace band of the high-water mark, so budgets may only tighten, never creep.
Ratchets converted onto the primitive
- windows-test-parity-guard.test.cjs: rmSync rule deleted (now ESLint-enforced);
the remaining six patterns moved from integer baselines to named-set
allowlists with ratchet-down.
- scripts/lint-test-file-count.{cjs,allowlist.json}: per-module integer counts →
named filename sets (closes the swap-a-file-keep-the-count blind spot); a
module dropping under cap now FAILS to force pruning its allowlist entry.
- enh-2790 skill-count `<= 63` → named skill allowlist (ratchets toward ~58).
Size budgets hardened (tighten-only)
- agent-size / workflow-size / feat-3039 help-tiered: ceilings lowered to the
current high-water mark and an assertTightCeiling anti-creep check added per
tier. Fixed external-contract limits (description ≤100 chars, agent ≤100 KB)
are intentionally left as-is — they are not grandfathered creeping budgets.
No user-facing behavior change (tests + tooling only); no USER_FACING_PREFIXES
touched, so no changeset fragment is required.
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
182 lines
6.3 KiB
JavaScript
182 lines
6.3 KiB
JavaScript
/**
|
|
* Regression tests for bug #2836
|
|
*
|
|
* audit-open had two convention drifts vs the documented workflows:
|
|
* 1. quick-task scanner looked for bare `SUMMARY.md`, but workflows/quick.md
|
|
* mandates `${quick_id}-SUMMARY.md`. Result: every documented quick task
|
|
* reported as `status: missing`.
|
|
* 2. UAT terminal-status enum only accepted `complete`, but
|
|
* workflows/execute-phase.md uses `resolved` post-gap-closure.
|
|
* Result: gap-closed UATs reported as open.
|
|
*
|
|
* Tests structurally invoke auditOpenArtifacts() against real fixtures on disk
|
|
* and assert the returned items array — never regex on raw file content.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const { describe, test, before, after } = 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 auditModule = require('../get-shit-done/bin/lib/audit.cjs');
|
|
const { auditOpenArtifacts } = auditModule;
|
|
const { cleanup } = require('./helpers.cjs');
|
|
|
|
function mkTmp() {
|
|
return fs.mkdtempSync(path.join(os.tmpdir(), 'bug-2836-'));
|
|
}
|
|
|
|
describe('bug #2836: audit-open quick-task summary filename + UAT terminal status', () => {
|
|
// Ensure GSD env vars do not redirect planningDir() away from our fixture.
|
|
let prevProject, prevWorkstream;
|
|
before(() => {
|
|
prevProject = process.env.GSD_PROJECT;
|
|
prevWorkstream = process.env.GSD_WORKSTREAM;
|
|
delete process.env.GSD_PROJECT;
|
|
delete process.env.GSD_WORKSTREAM;
|
|
});
|
|
after(() => {
|
|
if (prevProject !== undefined) process.env.GSD_PROJECT = prevProject;
|
|
if (prevWorkstream !== undefined) process.env.GSD_WORKSTREAM = prevWorkstream;
|
|
});
|
|
|
|
test('quick task with ${quick_id}-SUMMARY.md is recognized as complete (not missing)', () => {
|
|
const cwd = mkTmp();
|
|
try {
|
|
const quickId = '260429-test-foo';
|
|
const taskDir = path.join(cwd, '.planning', 'quick', quickId);
|
|
fs.mkdirSync(taskDir, { recursive: true });
|
|
fs.writeFileSync(
|
|
path.join(taskDir, `${quickId}-SUMMARY.md`),
|
|
'---\nstatus: complete\n---\ntest summary\n',
|
|
'utf-8'
|
|
);
|
|
|
|
const result = auditOpenArtifacts(cwd);
|
|
const realQuickTasks = result.items.quick_tasks.filter(
|
|
i => !i.scan_error && !i._remainder_count
|
|
);
|
|
|
|
assert.equal(
|
|
realQuickTasks.length, 0,
|
|
`quick task with ${quickId}-SUMMARY.md (status: complete) must not appear ` +
|
|
`as an open item; got: ${JSON.stringify(realQuickTasks)}`
|
|
);
|
|
assert.equal(result.counts.quick_tasks, 0);
|
|
} finally {
|
|
cleanup(cwd);
|
|
}
|
|
});
|
|
|
|
test('UAT with status: resolved is treated as terminal (not an open gap)', () => {
|
|
const cwd = mkTmp();
|
|
try {
|
|
const phaseDir = path.join(cwd, '.planning', 'phases', '01-test');
|
|
fs.mkdirSync(phaseDir, { recursive: true });
|
|
fs.writeFileSync(
|
|
path.join(phaseDir, '01-UAT.md'),
|
|
'---\nstatus: resolved\n---\nUAT body — gap closed via execute-phase flow.\n',
|
|
'utf-8'
|
|
);
|
|
|
|
const result = auditOpenArtifacts(cwd);
|
|
const realUatGaps = result.items.uat_gaps.filter(i => !i.scan_error);
|
|
|
|
assert.equal(
|
|
realUatGaps.length, 0,
|
|
`UAT with status: resolved must not appear as an open gap; ` +
|
|
`got: ${JSON.stringify(realUatGaps)}`
|
|
);
|
|
assert.equal(result.counts.uat_gaps, 0);
|
|
} finally {
|
|
cleanup(cwd);
|
|
}
|
|
});
|
|
|
|
test('UAT with status: complete remains terminal (no regression)', () => {
|
|
const cwd = mkTmp();
|
|
try {
|
|
const phaseDir = path.join(cwd, '.planning', 'phases', '02-test');
|
|
fs.mkdirSync(phaseDir, { recursive: true });
|
|
fs.writeFileSync(
|
|
path.join(phaseDir, '02-UAT.md'),
|
|
'---\nstatus: complete\n---\nUAT body.\n',
|
|
'utf-8'
|
|
);
|
|
|
|
const result = auditOpenArtifacts(cwd);
|
|
const realUatGaps = result.items.uat_gaps.filter(i => !i.scan_error);
|
|
assert.equal(realUatGaps.length, 0);
|
|
} finally {
|
|
cleanup(cwd);
|
|
}
|
|
});
|
|
|
|
test('UAT with status: pending is still flagged as an open gap', () => {
|
|
const cwd = mkTmp();
|
|
try {
|
|
const phaseDir = path.join(cwd, '.planning', 'phases', '03-test');
|
|
fs.mkdirSync(phaseDir, { recursive: true });
|
|
fs.writeFileSync(
|
|
path.join(phaseDir, '03-UAT.md'),
|
|
'---\nstatus: pending\n---\nresult: pending\n',
|
|
'utf-8'
|
|
);
|
|
|
|
const result = auditOpenArtifacts(cwd);
|
|
const realUatGaps = result.items.uat_gaps.filter(i => !i.scan_error);
|
|
assert.equal(realUatGaps.length, 1, 'pending UAT must still be flagged');
|
|
assert.equal(realUatGaps[0].status, 'pending');
|
|
} finally {
|
|
cleanup(cwd);
|
|
}
|
|
});
|
|
|
|
test('quick task without any SUMMARY file is still flagged as missing', () => {
|
|
const cwd = mkTmp();
|
|
try {
|
|
const quickId = '260429-test-bar';
|
|
const taskDir = path.join(cwd, '.planning', 'quick', quickId);
|
|
fs.mkdirSync(taskDir, { recursive: true });
|
|
// No SUMMARY file at all.
|
|
|
|
const result = auditOpenArtifacts(cwd);
|
|
const realQuickTasks = result.items.quick_tasks.filter(
|
|
i => !i.scan_error && !i._remainder_count
|
|
);
|
|
assert.equal(realQuickTasks.length, 1);
|
|
assert.equal(realQuickTasks[0].status, 'missing');
|
|
} finally {
|
|
cleanup(cwd);
|
|
}
|
|
});
|
|
});
|
|
|
|
describe('bug #2836: workflows/help.md one-liner reconciliation', () => {
|
|
test('help.md quick-task one-liner uses ${quick_id}-SUMMARY.md pattern', () => {
|
|
// After #3039, help content moved into help/modes/full.md.
|
|
const helpPath = path.resolve(
|
|
__dirname, '..', 'get-shit-done', 'workflows', 'help', 'modes', 'full.md'
|
|
);
|
|
const content = fs.readFileSync(helpPath, 'utf-8');
|
|
|
|
// Locate the documented "Result: Creates ..." quick-task one-liner and
|
|
// assert it references the per-task SUMMARY filename pattern, not bare
|
|
// SUMMARY.md. We parse by line to avoid false positives elsewhere.
|
|
const resultLines = content.split('\n').filter(l =>
|
|
l.includes('Result: Creates') && l.includes('.planning/quick/')
|
|
);
|
|
assert.ok(resultLines.length > 0, 'expected a quick-task Result line in help.md');
|
|
for (const line of resultLines) {
|
|
assert.ok(
|
|
/\$\{quick_id\}-SUMMARY\.md|NNN-slug-SUMMARY\.md/.test(line),
|
|
`help.md quick-task Result line must reference per-task SUMMARY filename ` +
|
|
`(e.g. \${quick_id}-SUMMARY.md); got: ${line}`
|
|
);
|
|
}
|
|
});
|
|
});
|