Two more diagnostic passes (clusters J: residuals in already-touched files,
K: 12 untouched files) plus a production-code path fix and a new
ratchet-style lint guard.
## Test-only fixes (14 files)
bug-1736, bug-2248, bug-2698 — replace inline 1s-budget rmSync with the
shared cleanup() helper (5s budget, 20×250ms retries). The earlier
inline maxRetries:10 / retryDelay:100 wasn't enough to absorb Windows
Defender's deferred-scan handle hold on cold runners.
bug-2256, skill-manifest — also override USERPROFILE alongside HOME in
beforeEach/runGsdTools calls. os.homedir() reads USERPROFILE on win32,
so HOME-only stubs leak the runner's real home into the SUT.
bug-2784, bug-3608, enh-2500, enh-2790, few-shot-calibration,
gsd-settings-advanced — CRLF tolerance: literal \n in regexes against
file content (frontmatter anchors, bash-fence regex, multi-line
numbered-list captures, awk-block extractors) becomes \r?\n; split('\n')
becomes split(/\r?\n/). Windows checkout with autocrlf=true puts \r
before every \n; .+ doesn't match \r in JS regex by default.
bug-2966 — three-part fix to extractStepRun (CRLF split), awk regex
(\r?\n), and conflict-marker parser (rawLine + \r$ strip).
bug-2969, config — normalize separators on test assertions where the
SUT correctly emits \ on win32 but the test compares against /.
prompt-injection-scan — normalize relPath via replace(/\\/g, '/') before
ALLOWLIST.has() lookup. ALLOWLIST keys are POSIX; path.relative returns
backslashes on win32 → falsely scans allowlisted security module → trips
the boundary-tag detector on its own legitimate detection code.
prune-orphaned-worktrees — use the existing canonicalPath +
listedWorktreePaths(repoDir).has(...) helpers instead of substring
matching the raw path. git stores long-form canonical paths
(runneradmin), but mkdtempSync returns 8.3 short-form (RUNNER~1) on
Windows runners; plain string compare misses every entry.
## Production-code fix (1 file)
get-shit-done/bin/lib/init.cjs — bug-3491 in_nested_subdir computation
canonicalizes both worktreeRoot and cwd via fs.realpathSync.native +
path.relative before declaring "nested." Windows runner cwd (8.3 short
name) vs git's --show-toplevel (long form, forward slashes) made the
raw string compare always say true even at the worktree root, breaking
the "init new-project at worktree root" subtest.
## New ratchet lint guard
tests/windows-test-parity-guard.test.cjs — scans tests/ for 7
anti-patterns that drove the Windows failure clusters. Each rule has a
baseline count snapshot from this PR; the test fails when a new
occurrence appears (count grows above baseline), ratcheting down as
existing offenders are fixed. Patterns covered:
G1 split('\n') after readFileSync (use /\r?\n/)
G2 ```bash\n fence regex (use ```bash\r?\n)
G3 ^---\n frontmatter anchor (use ^---\r?\n)
G4 hardcoded "/tmp/..." literal passed to fs.* (use os.tmpdir())
G5 bare 'npm' to execFileSync without {shell:true} on win32
G6 process.env.HOME stub with no USERPROFILE
G7 fs.rmSync({recursive,force}) without maxRetries
Future Windows-parity regressions get caught at PR time rather than
five iterations into a CI loop.
Validated: holodeck (ubuntu docker) 11232/0 pass (count +8 = the 7
new ratchet tests + parent describe).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
135 lines
5.8 KiB
JavaScript
135 lines
5.8 KiB
JavaScript
/**
|
|
* Enhancement #2500: gsd-codebase-mapper (arch focus) rich architecture output
|
|
*
|
|
* The codebase/ARCHITECTURE.md produced by gsd-codebase-mapper was a sparse
|
|
* structural inventory — file listings and module relationships. After a major
|
|
* refactor, research/ARCHITECTURE.md (created at /gsd-new-project) goes stale
|
|
* with no refresh command. This enhancement enriches the codebase mapper's
|
|
* arch-focus template to match the richness of the research version:
|
|
* - ASCII system overview diagram
|
|
* - Data flow traces with numbered steps and code references
|
|
* - Component responsibility table (component → responsibility → file)
|
|
* - Critical architectural constraints
|
|
* - Anti-patterns specific to the codebase
|
|
* - <!-- refreshed: {date} --> marker at top (maintainer request)
|
|
*
|
|
* The agent's template text IS what the runtime executes, so testing
|
|
* the template content directly tests the deployed contract.
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
// allow-test-rule: source-text-is-the-product
|
|
// The gsd-codebase-mapper ARCHITECTURE.md template is the instruction set
|
|
// executed by the LLM at runtime. Testing its text content tests whether the
|
|
// deployed agent will produce rich architecture docs as required by #2500.
|
|
|
|
const { describe, test, before } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const AGENT_PATH = path.join(__dirname, '..', 'agents', 'gsd-codebase-mapper.md');
|
|
|
|
describe('enh-2500: gsd-codebase-mapper arch focus — rich architecture output', () => {
|
|
let agentContent;
|
|
let archTemplate;
|
|
|
|
before(() => {
|
|
assert.ok(fs.existsSync(AGENT_PATH), 'agents/gsd-codebase-mapper.md must exist');
|
|
agentContent = fs.readFileSync(AGENT_PATH, 'utf-8');
|
|
|
|
// Isolate the ARCHITECTURE.md template section from the agent file.
|
|
// End boundary is the STRUCTURE.md Template heading that immediately follows it.
|
|
const archStart = agentContent.indexOf('## ARCHITECTURE.md Template (arch focus)');
|
|
assert.ok(archStart !== -1, 'agent must contain an ARCHITECTURE.md Template (arch focus) section');
|
|
|
|
const archEnd = agentContent.indexOf('## STRUCTURE.md Template (arch focus)', archStart + 1);
|
|
archTemplate = archEnd !== -1
|
|
? agentContent.slice(archStart, archEnd)
|
|
: agentContent.slice(archStart);
|
|
});
|
|
|
|
test('template includes a refreshed date marker', () => {
|
|
assert.ok(
|
|
archTemplate.includes('<!-- refreshed:') || archTemplate.includes('refreshed:'),
|
|
'ARCHITECTURE.md template must include a <!-- refreshed: {date} --> marker so users can see when the doc was last generated (#2500 maintainer requirement)'
|
|
);
|
|
});
|
|
|
|
test('template includes an ASCII system overview diagram', () => {
|
|
// ASCII diagrams use box-drawing characters or at minimum ┌/└/│/─ or +/|/-
|
|
const hasAsciiDiagram =
|
|
archTemplate.includes('┌') ||
|
|
archTemplate.includes('└') ||
|
|
archTemplate.includes('│') ||
|
|
archTemplate.includes('+--') ||
|
|
archTemplate.includes('+-') ||
|
|
archTemplate.includes('→') ||
|
|
archTemplate.includes('↓') ||
|
|
archTemplate.includes('↑');
|
|
|
|
assert.ok(
|
|
hasAsciiDiagram,
|
|
'ARCHITECTURE.md template must include an ASCII system overview diagram (box-drawing characters or flow arrows) as required by #2500'
|
|
);
|
|
});
|
|
|
|
test('template includes System Overview section header', () => {
|
|
assert.ok(
|
|
archTemplate.includes('System Overview') || archTemplate.includes('system overview'),
|
|
'ARCHITECTURE.md template must include a "System Overview" section for the ASCII diagram (#2500)'
|
|
);
|
|
});
|
|
|
|
test('template includes a component responsibility table with required columns', () => {
|
|
// Must have a markdown table with component, responsibility, and file columns
|
|
const hasComponentCol =
|
|
archTemplate.includes('Component') || archTemplate.includes('component');
|
|
const hasResponsibilityCol =
|
|
archTemplate.includes('Responsibility') || archTemplate.includes('responsibility');
|
|
const hasFileCol =
|
|
archTemplate.includes('File') || archTemplate.includes('file');
|
|
|
|
assert.ok(
|
|
hasComponentCol && hasResponsibilityCol && hasFileCol,
|
|
'ARCHITECTURE.md template must include a component responsibility table with Component, Responsibility, and File columns (#2500)'
|
|
);
|
|
});
|
|
|
|
test('template includes data flow traces with numbered steps', () => {
|
|
const hasPrimaryRequestPath = /###\s+Primary Request Path/i.test(archTemplate);
|
|
// [^\n]+ + \r?\n is CRLF-tolerant: .+ doesn't match \r in JS regex by
|
|
// default, so \r before the literal \n in CRLF content kills the match.
|
|
const hasThreeNumberedSteps = /^\s*1\.[^\n]+\r?\n\s*2\.[^\n]+\r?\n\s*3\./m.test(archTemplate);
|
|
const hasFileLineRefs = /\(`\[.*:(?:line|\d+)\]`\)/.test(archTemplate);
|
|
|
|
assert.ok(
|
|
hasPrimaryRequestPath && hasThreeNumberedSteps && hasFileLineRefs,
|
|
'ARCHITECTURE.md template must include a "Primary Request Path" section with numbered steps and file:line references (#2500)'
|
|
);
|
|
});
|
|
|
|
test('template includes architectural constraints section', () => {
|
|
const hasConstraints =
|
|
/##\s+Architectural Constraints/i.test(archTemplate) &&
|
|
/\bThreading\b/.test(archTemplate) &&
|
|
/\bGlobal state\b/i.test(archTemplate) &&
|
|
/\bCircular imports\b/i.test(archTemplate);
|
|
|
|
assert.ok(
|
|
hasConstraints,
|
|
'ARCHITECTURE.md template must include an "Architectural Constraints" section with Threading, Global state, and Circular imports categories (#2500)'
|
|
);
|
|
});
|
|
|
|
test('template includes anti-patterns section', () => {
|
|
assert.ok(
|
|
archTemplate.includes('Anti-pattern') ||
|
|
archTemplate.includes('Anti-Pattern') ||
|
|
archTemplate.includes('anti-pattern'),
|
|
'ARCHITECTURE.md template must include an anti-patterns section specific to the codebase (#2500)'
|
|
);
|
|
});
|
|
});
|