Folds 15 tests/fix-*.test.cjs regression files (191 test() blocks) into their module's main suite, per the wave decomposition of #3315 (H3 of epic #3053). 187 blocks land in 8 existing suites (4 exact-duplicate cases dropped, documented inline); 4 blocks move via git mv into 2 new suite files with no prior coverage to merge into. Zero production behavior change. Also tightens two H1 (#3313) ratchets that the fold's own file-count reduction moved past their grace window, per the ratchets' documented dual failure mode (a stale/too-loose baseline fails exactly like a novel violation): - lint-test-file-count.allowlist.json: removes the stale "audit" entry (folding fix-2766 into tests/uat.test.cjs drops that module back to its 2-file cap). - lint-allow-test-rule-refs.ceiling.json: lowers maxFiles 314 -> 309, the real post-fold high-water mark (gsd-test's own repo-baseline test caught this — CI, not a human, found it). Two orthogonal review passes (Standards+Spec code-review, isolated security-review) found and this commit fixes two issues before push: a genuinely-distinct #2287 test case (file-absent vs. file-present- resolved) that a prior fold pass had wrongly dropped as a duplicate — restored verbatim into tests/uat.test.cjs; and a missing same-line allow-test-rule citation on the #2196 block in tests/debug-session-management.test.cjs, added for consistency with its sibling #2257 block. lint-removed-but-needed also caught two stale doc references to the now-folded-away fix-2285-claude-orchestration-wiring.test.cjs filename (docs/adr/1143-claude-orchestration-capability.md, gsd-core/references/execute-phase-response-language.md) — updated both to point at tests/claude-orchestration.test.cjs, its new home. Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -15,6 +15,11 @@
|
||||
const { describe, test } = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fc = require('fast-check');
|
||||
const fs = require('node:fs');
|
||||
const os = require('node:os');
|
||||
const path = require('node:path');
|
||||
|
||||
const { cleanup } = require('./helpers.cjs');
|
||||
|
||||
const {
|
||||
REVIEWER_LANES,
|
||||
@@ -29,6 +34,7 @@ const {
|
||||
|
||||
const RUN = '/run';
|
||||
const ROOT = '/repo';
|
||||
const REVIEW_MD = path.join(__dirname, '..', 'gsd-core', 'workflows', 'review.md');
|
||||
|
||||
/** Deterministic property runs — pinned seed, bounded, replay printed on failure. */
|
||||
const FC = { seed: 42, numRuns: 200 };
|
||||
@@ -450,3 +456,119 @@ describe('reviewer lane invocation — properties', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// Folded in from tests/fix-2358-review-temp-path-scoping.test.cjs (#3334 H3 test-hygiene fold-in).
|
||||
//
|
||||
// #2358 — review.md (and ship.md's external peer-review step) wrote every temp file to a
|
||||
// hardcoded, phase-number-only path under /tmp, which two GSD projects sharing a phase number
|
||||
// could collide on. The fix threads a single run-scoped `mktemp -d` directory through every
|
||||
// review.md temp path.
|
||||
describe('#2358 review.md temp paths are run-scoped, not phase-only', () => {
|
||||
const reviewMdContent = fs.readFileSync(REVIEW_MD, 'utf-8');
|
||||
|
||||
test('no bare, unscoped /tmp/gsd-review-* path remains', () => {
|
||||
assert.ok(
|
||||
!reviewMdContent.includes('/tmp/gsd-review'),
|
||||
'review.md must not contain any hardcoded /tmp/gsd-review* literal — ' +
|
||||
'every review temp path must be rooted under the run-scoped mktemp directory'
|
||||
);
|
||||
});
|
||||
|
||||
test('creates exactly one run-scoped directory via the portable ${TMPDIR:-/tmp} seam', () => {
|
||||
const mktempAssignments = reviewMdContent.match(/RUN_DIR=\$\(mktemp -d "\$\{TMPDIR:-\/tmp\}\/gsd-review-XXXXXX"\)/g) || [];
|
||||
assert.equal(
|
||||
mktempAssignments.length, 1,
|
||||
'review.md must create the run directory with exactly one `mktemp -d "${TMPDIR:-/tmp}/gsd-review-XXXXXX"` — ' +
|
||||
'a hardcoded /tmp (no ${TMPDIR:-/tmp} seam) breaks on Windows, and re-mktemp-ing per block would break the ' +
|
||||
'write/read pairing between build_prompt and the local-reviewer budget-trimming reads'
|
||||
);
|
||||
});
|
||||
|
||||
test('every downstream temp path is threaded through {run_dir} / $RUN_DIR, not re-derived from {phase}', () => {
|
||||
assert.ok(
|
||||
/\{run_dir\}\/gsd-review-/.test(reviewMdContent),
|
||||
'reviewer blocks must reference {run_dir}/gsd-review-... (the run-scoped placeholder)'
|
||||
);
|
||||
assert.ok(
|
||||
/\$\{RUN_DIR\}\/gsd-review-/.test(reviewMdContent),
|
||||
'the build_prompt section-file writes must reference ${RUN_DIR}/gsd-review-... (the run-scoped shell var)'
|
||||
);
|
||||
// The old isolation key must be gone entirely from path construction.
|
||||
assert.ok(
|
||||
!/\/tmp\/gsd-review[^\r\n]*\{phase\}/.test(reviewMdContent),
|
||||
'no temp path may still be keyed on a bare {phase} placeholder'
|
||||
);
|
||||
assert.ok(
|
||||
!/\$\{PHASE\}-(?:instructions|roadmap|plan|project|context|research|requirements)\.md/.test(reviewMdContent),
|
||||
'no temp path may still be keyed on the ${PHASE} shell var'
|
||||
);
|
||||
});
|
||||
|
||||
// Phase 5b (#2799) moved these strings out of review.md's bash and into the resolver and the
|
||||
// antigravity handler, so the assertions follow them. The invariant is unchanged and is what
|
||||
// #2358 was about: every reviewer artifact must live under the run-scoped mktemp directory, never
|
||||
// a bare `{phase}`-keyed /tmp path that a concurrent review could collide with.
|
||||
test('every lane anchors its prompt and artifacts under the run dir', () => {
|
||||
const RUN_2358 = '/run-scoped';
|
||||
for (const lane of REVIEWER_LANES) {
|
||||
const r = resolveLanePlan({
|
||||
lane, configGet: () => undefined, runDir: RUN_2358, repoRoot: '/repo',
|
||||
});
|
||||
assert.equal(r.ok, true, `${lane.slug} failed to resolve`);
|
||||
const p = r.plan;
|
||||
assert.ok(p.reviewPath.startsWith(`${RUN_2358}/`), `${lane.slug} review path escapes the run dir`);
|
||||
assert.ok(p.errPath.startsWith(`${RUN_2358}/`), `${lane.slug} err path escapes the run dir`);
|
||||
assert.ok(p.promptPath.startsWith(`${RUN_2358}/`), `${lane.slug} prompt path escapes the run dir`);
|
||||
}
|
||||
});
|
||||
|
||||
test('the argv-borne prompt instruction references the run-scoped path', () => {
|
||||
const RUN_2358 = '/run-scoped';
|
||||
const fileRefLanes = REVIEWER_LANES.filter(
|
||||
(l) => l.transport === 'spawn' && l.invoke.promptChannel === 'argv-file-ref',
|
||||
);
|
||||
assert.ok(fileRefLanes.length > 0, 'expected at least one argv-file-ref lane');
|
||||
for (const lane of fileRefLanes) {
|
||||
const r = resolveLanePlan({ lane, configGet: () => undefined, runDir: RUN_2358, repoRoot: '/repo' });
|
||||
const arg = r.plan.argv[r.plan.argv.length - 1];
|
||||
assert.ok(arg.includes(`${RUN_2358}/gsd-review-prompt.md`), `${lane.slug} prompt not run-scoped`);
|
||||
}
|
||||
});
|
||||
|
||||
test('an instance writes under the run dir, keyed by its own identity', () => {
|
||||
// Two instances of one adapter must not overwrite each other, and neither may escape the run
|
||||
// dir — the identity is sanitized to a flat filename.
|
||||
const lane = REVIEWER_LANES.find((l) => l.slug === 'opencode');
|
||||
const r = resolveLanePlan({ lane, configGet: () => undefined, runDir: '/run-scoped', repoRoot: '/repo' });
|
||||
assert.ok(r.plan.reviewPath.startsWith('/run-scoped/'));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#2358 design principle: run-scoped temp dirs never collide across projects/phases', () => {
|
||||
// review.md and ship.md are markdown instructions an AI agent executes, not
|
||||
// node-executable code, so this does not shell out to the literal snippet —
|
||||
// it validates the underlying guarantee the fix relies on (mktemp-style
|
||||
// randomized-suffix isolation) using Node's built-in equivalent, which is
|
||||
// cross-platform (Windows included) unlike shelling out to `mktemp`/bash.
|
||||
test('two runs — even for the same phase number, same or different project — get distinct run dirs', (t) => {
|
||||
const prefix = path.join(os.tmpdir(), 'gsd-review-');
|
||||
const runDirA = fs.mkdtempSync(prefix);
|
||||
const runDirB = fs.mkdtempSync(prefix);
|
||||
// helpers.cleanup (not raw fs.rmSync) carries the Windows-EBUSY retry budget.
|
||||
t.after(() => {
|
||||
cleanup(runDirA);
|
||||
cleanup(runDirB);
|
||||
});
|
||||
assert.notEqual(
|
||||
runDirA, runDirB,
|
||||
'two review runs sharing the same phase number must never resolve to the same run-scoped directory'
|
||||
);
|
||||
const phase = '10'; // same phase number in both "projects" — the historical collision case
|
||||
const staleProjectAPath = path.join(runDirA, `gsd-review-prompt.md`);
|
||||
const laterProjectBPath = path.join(runDirB, `gsd-review-prompt.md`);
|
||||
assert.notEqual(
|
||||
staleProjectAPath, laterProjectBPath,
|
||||
`phase ${phase} in two different runs must not resolve to the same prompt path`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user