* test: destroy 9 config-schema.cjs/core.cjs source-grep tests, add behavioral config-set tests (#2691, #2693)
Replace source-grep theater with config-set behavioral tests:
- execute-phase-wave: config-set workflow.use_worktrees replaces VALID_CONFIG_KEYS grep
- inline-plan-threshold: delete redundant source-grep (behavioral test at L36 already covered it)
- plan-bounce: config-set for plan_bounce / plan_bounce_script / plan_bounce_passes replaces 3 key-presence greps
- code-review: config-set for code_review / code_review_depth replaces 2 greps; removes CONFIG_PATH constant
- thinking-partner: config-set features.thinking_partner replaces two greps (config-schema.cjs AND core.cjs)
Behavioral tests survive refactors (no path constants, no file reads). The config-schema.cjs →
core.cjs migration commit 990c3e64 happened because these tests groped source paths.
Add allow-test-rule: source-text-is-the-product annotations to legitimate product-content tests:
autonomous-allowed-tools, agent-frontmatter, agent-skills-awareness, bug-2334, bug-2346,
execute-phase-wave (MD reads), plan-bounce (workflow reads). Annotations explain WHY text
inspection is the right level of testing for AI instruction files.
Closes #2691
Closes #2693
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test: address CodeRabbit findings on #2696
- agent-frontmatter.test.cjs: move allow-test-rule annotation from block comment
to standalone // line comment so rule scanners can detect it
- thinking-partner.test.cjs: strengthen config-set test with config-get read-back
assertion to verify the value was persisted, not just accepted (exit 0)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* test: tighten thinking_partner config assertion per CodeRabbit (#2696)
Replace config-get output substring check (includes('true') false-positive
risk) with a direct JSON read of .planning/config.json, asserting the
exact persisted value via strictEqual. This also validates the config file
was created, catching silent key-acceptance without persistence.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
112 lines
4.3 KiB
JavaScript
112 lines
4.3 KiB
JavaScript
/**
|
|
* Regression tests for bug #2346
|
|
*
|
|
* Multiple GSD agents (gsd-ui-checker, gsd-planner) entered unbounded Read
|
|
* loops — re-reading the same file hundreds of times in a single run. Root
|
|
* cause: no explicit no-re-read rule or tool-budget cap in the agent prompts.
|
|
* gsd-pattern-mapper was fixed in #2312; this covers the remaining agents.
|
|
*
|
|
* Fix: add <critical_rules> block to each affected agent with:
|
|
* 1. No-re-read constraint
|
|
* 2. Large-file strategy (Grep first, then targeted offset/limit Read)
|
|
* 3. Stop-on-sufficient-evidence rule (where applicable)
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const { test, describe } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const AGENTS_DIR = path.join(__dirname, '..', 'agents');
|
|
|
|
// allow-test-rule: source-text-is-the-product
|
|
// The <critical_rules> block in agent .md files IS the fix — it is the AI instruction that
|
|
// prevents unbounded Read loops. There is no behavioral equivalent without a live LLM run.
|
|
describe('bug #2346: agent read loop guards', () => {
|
|
|
|
describe('gsd-ui-checker', () => {
|
|
const agentPath = path.join(AGENTS_DIR, 'gsd-ui-checker.md');
|
|
let content;
|
|
|
|
test('agent file exists', () => {
|
|
assert.ok(fs.existsSync(agentPath), 'agents/gsd-ui-checker.md must exist');
|
|
content = fs.readFileSync(agentPath, 'utf-8');
|
|
});
|
|
|
|
test('has <critical_rules> block', () => {
|
|
content = content || fs.readFileSync(agentPath, 'utf-8');
|
|
assert.ok(
|
|
content.includes('<critical_rules>'),
|
|
'gsd-ui-checker.md must have a <critical_rules> block to prevent unbounded read loops (#2346)'
|
|
);
|
|
});
|
|
|
|
test('critical_rules contains no-re-read constraint', () => {
|
|
content = content || fs.readFileSync(agentPath, 'utf-8');
|
|
const rulesStart = content.indexOf('<critical_rules>');
|
|
const rulesEnd = content.indexOf('</critical_rules>', rulesStart);
|
|
assert.ok(rulesStart !== -1 && rulesEnd !== -1, '<critical_rules> block must be complete');
|
|
const rulesBlock = content.slice(rulesStart, rulesEnd);
|
|
assert.ok(
|
|
rulesBlock.includes('re-read') || rulesBlock.includes('re read'),
|
|
'critical_rules must include a no-re-read rule'
|
|
);
|
|
});
|
|
|
|
test('critical_rules appears before success_criteria', () => {
|
|
content = content || fs.readFileSync(agentPath, 'utf-8');
|
|
const rulesIdx = content.indexOf('<critical_rules>');
|
|
const successIdx = content.indexOf('<success_criteria>');
|
|
assert.ok(rulesIdx !== -1 && successIdx !== -1, 'both sections must exist');
|
|
assert.ok(
|
|
rulesIdx < successIdx,
|
|
'<critical_rules> must appear before <success_criteria>'
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('gsd-planner', () => {
|
|
const agentPath = path.join(AGENTS_DIR, 'gsd-planner.md');
|
|
let content;
|
|
|
|
test('agent file exists', () => {
|
|
assert.ok(fs.existsSync(agentPath), 'agents/gsd-planner.md must exist');
|
|
content = fs.readFileSync(agentPath, 'utf-8');
|
|
});
|
|
|
|
test('has <critical_rules> block', () => {
|
|
content = content || fs.readFileSync(agentPath, 'utf-8');
|
|
assert.ok(
|
|
content.includes('<critical_rules>'),
|
|
'gsd-planner.md must have a <critical_rules> block to prevent unbounded read loops (#2346)'
|
|
);
|
|
});
|
|
|
|
test('critical_rules contains no-re-read constraint', () => {
|
|
content = content || fs.readFileSync(agentPath, 'utf-8');
|
|
const rulesStart = content.indexOf('<critical_rules>');
|
|
const rulesEnd = content.indexOf('</critical_rules>', rulesStart);
|
|
assert.ok(rulesStart !== -1 && rulesEnd !== -1, '<critical_rules> block must be complete');
|
|
const rulesBlock = content.slice(rulesStart, rulesEnd);
|
|
assert.ok(
|
|
rulesBlock.includes('re-read') || rulesBlock.includes('re read'),
|
|
'critical_rules must include a no-re-read rule'
|
|
);
|
|
});
|
|
|
|
test('critical_rules appears before success_criteria', () => {
|
|
content = content || fs.readFileSync(agentPath, 'utf-8');
|
|
const rulesIdx = content.indexOf('<critical_rules>');
|
|
const successIdx = content.lastIndexOf('<success_criteria>');
|
|
assert.ok(rulesIdx !== -1 && successIdx !== -1, 'both sections must exist');
|
|
assert.ok(
|
|
rulesIdx < successIdx,
|
|
'<critical_rules> must appear before <success_criteria>'
|
|
);
|
|
});
|
|
});
|
|
|
|
});
|