test(#1977): consolidate 22 misc + repo-invariant regression tests
Final epic-#1969 batch. Fold 22 issue-named files: the 4 genuine repo-wide invariant scans (551-eslint-bin-lib-coverage, bug-3054 stale /gsd-next, bug-3810 no-gsd-sdk-runtime-refs, feat-3593 cli-negative-universal) into a NEW shared repo-invariants.test.cjs; the other 18 as singletons into their nearest module suite (model-resolver, codex-config, runtime-converters, security, state-transition, worktree-safety, roadmap-parser, etc.). Verbatim block-scoped describe wrappers; 334 subtests conserved 1:1. Host-env pre-check (B2+B6): the 6 CLI folds into GSD_TEST_MODE-setting hosts (model-resolver/ codex-config/runtime-converters) are benign — each origin independently sets GSD_TEST_MODE=1 itself (idempotent), unlike the B6 real-install case. Regenerates regression-name allowlist (222->213), ratchets file-count allowlist (state 17->16), makes 7 relocated allow-test-rule exemptions issue-ref-compliant (ADR-456; prunes stale ids). Repoints 2 tests/ refs in docs/TESTING-SUITES.md. lint:ci green. Part of epic #1969. Closes #1977. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -432,3 +432,90 @@ describe('gsd-project-researcher agent registration (#2419)', () => {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
// Folded from tests/bug-2559-stale-search-year.test.cjs — consolidation epic #1969 (B8 #1977)
|
||||
// ────────────────────────────────────────────────────────────────────────
|
||||
{
|
||||
const { describe: __foldDescribe } = require('node:test');
|
||||
__foldDescribe("folded:bug-2559-stale-search-year (consolidation epic #1969 B8 #1977)", () => {
|
||||
// allow-test-rule: source-text-is-the-product (see #2559)
|
||||
// Workflow .md / agent .md / command .md / reference .md files — their text
|
||||
// IS what the runtime loads. Testing text content tests the deployed contract.
|
||||
// Per CONTRIBUTING.md exception matrix.
|
||||
|
||||
/**
|
||||
* Bug #2559: Stale document references in Research phase
|
||||
*
|
||||
* The gsd-phase-researcher and gsd-project-researcher agents instruct
|
||||
* WebSearch queries to always include "current year" (or a hardcoded
|
||||
* year). This biases results toward stale dated content as time passes
|
||||
* (e.g., a 2024 query run in 2026 returns stale results).
|
||||
*
|
||||
* Fix: Remove year-injection instructions from research agent
|
||||
* WebSearch guidance so searches return current results.
|
||||
*/
|
||||
|
||||
const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const PHASE_RESEARCHER = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'agents',
|
||||
'gsd-phase-researcher.md'
|
||||
);
|
||||
const PROJECT_RESEARCHER = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'agents',
|
||||
'gsd-project-researcher.md'
|
||||
);
|
||||
|
||||
const FILES = [
|
||||
{ label: 'gsd-phase-researcher.md', path: PHASE_RESEARCHER },
|
||||
{ label: 'gsd-project-researcher.md', path: PROJECT_RESEARCHER },
|
||||
];
|
||||
|
||||
describe('research agents do not inject year into web searches (#2559)', () => {
|
||||
for (const { label, path: filePath } of FILES) {
|
||||
test(`${label} contains no CURRENT_YEAR placeholder`, () => {
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
assert.ok(
|
||||
!/CURRENT_YEAR/.test(content),
|
||||
`${label} must not contain CURRENT_YEAR placeholder (causes stale-year injection)`
|
||||
);
|
||||
});
|
||||
|
||||
test(`${label} contains no hardcoded year in web search instructions`, () => {
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
const match = content.match(/\b20(2[3-9]|[3-9]\d)\b/);
|
||||
assert.ok(
|
||||
!match,
|
||||
`${label} must not contain hardcoded year (found "${match && match[0]}") — biases searches toward stale content`
|
||||
);
|
||||
});
|
||||
|
||||
test(`${label} does not instruct searches to include year or current year`, () => {
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
// Match phrases like "include current year", "year in searches",
|
||||
// "[current year]", "with year", etc.
|
||||
const patterns = [
|
||||
/include\s+(?:the\s+)?current\s+year/i,
|
||||
/current\s+year/i,
|
||||
/year\s+in\s+(?:searches|queries)/i,
|
||||
/\[current year\]/i,
|
||||
];
|
||||
for (const pat of patterns) {
|
||||
assert.ok(
|
||||
!pat.test(content),
|
||||
`${label} must not instruct year injection (matched /${pat.source}/)`
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user