test(3072): parse bash blocks for findings probe guard checks

This commit is contained in:
Tom Boucher
2026-05-04 23:28:52 -04:00
parent 50f714cdd5
commit b331c48261
2 changed files with 40 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
type: Fixed
pr: 3119
---
**Optional findings probe guard checks now use structured parsing** — regression tests now parse fenced bash blocks and validate sketch/spike findings probes as structured command records, ensuring non-fatal `|| true` guards are enforced without raw source grep assertions.

View File

@@ -11,6 +11,37 @@ function read(rel) {
return fs.readFileSync(path.join(ROOT, rel), 'utf8');
}
function extractFindingsProbesFromBashBlocks(markdown) {
const probes = [];
const fenceRe = /```bash\n([\s\S]*?)```/g;
let fenceMatch;
while ((fenceMatch = fenceRe.exec(markdown)) !== null) {
const block = fenceMatch[1];
const baseLine = markdown.slice(0, fenceMatch.index).split('\n').length;
const lines = block.split('\n');
lines.forEach((line, idx) => {
if (!line.includes('.claude/skills/')) return;
const kind = line.includes('sketch-findings-*/SKILL.md')
? 'sketch'
: line.includes('spike-findings-*/SKILL.md')
? 'spike'
: null;
if (!kind) return;
probes.push({
lineNumber: baseLine + idx,
commandText: line.trim(),
kind,
hasNonFatalGuard: /\|\|\s*true/.test(line),
});
});
}
return probes;
}
describe('bug #3072: optional sketch/spike findings probes are non-fatal', () => {
test('all sketch/spike findings SKILL.md ls probes include || true', () => {
const files = ['ui-phase.md', 'plan-phase.md', 'discuss-phase.md', 'new-project.md'];
@@ -18,10 +49,10 @@ describe('bug #3072: optional sketch/spike findings probes are non-fatal', () =>
for (const file of files) {
const content = read(file);
const lines = content.split('\n');
for (const line of lines) {
if (/\.claude\/skills\/(?:sketch|spike)-findings-\*\/SKILL\.md/.test(line) && !/\|\|\s*true/.test(line)) {
offenders.push(`${file}: ${line.trim()}`);
const probes = extractFindingsProbesFromBashBlocks(content);
for (const probe of probes) {
if (!probe.hasNonFatalGuard) {
offenders.push(`${file}:${probe.lineNumber} ${probe.commandText}`);
}
}
}