test(#4522): migrate core CLI/domain state batch to named timeout constants (#4662)

Batch 11 of the ad hoc timeout literal migration (epic #4445). Replaces
every bare numeric timeout/timeoutMs object-literal property in
tests/state-document.test.cjs, tests/phase.test.cjs, tests/commands.test.cjs,
tests/pattern.test.cjs, tests/adr-612-bracket-coherence.test.cjs,
tests/adr-612-bracket-read-tolerance.test.cjs, tests/milestone-lock.test.cjs,
tests/init.test.cjs, tests/state-todos-render.test.cjs,
tests/quick-batch.test.cjs, tests/graphify.test.cjs, and
tests/effort-surface-axis.test.cjs with a named constant, per
eslint-rules/no-adhoc-timeout-literal.cjs. Removes these 12 files from the
rule's allowlist.

Ground truth via eslint found 25 sites, not the issue's stated 24 (phase.test.cjs
has 5, not 4) -- disclosed in the PR body.

Reuses PROBE_TIMEOUT_MS, GIT_TIMEOUT_MS, and LOOP_HOOK_POINT_CLI_TIMEOUT_MS
across 8 files. Adds two new shared constants to tests/helpers/timeouts.cjs
(each independently arrived at by 2 files in this batch, crossing the
promotion bar): PATHOLOGICAL_INPUT_TEST_TIMEOUT_MS (node:test's own per-test
timeout option, not a subprocess bound) and GSD_TOOLS_CLI_MODERATE_TIMEOUT_MS
(a single gsd-tools.cjs CLI subcommand spawn, distinct tier from
PROBE_TIMEOUT_MS/LOOP_HOOK_POINT_CLI_TIMEOUT_MS). Adds 3 file-local constants
for values used by only 1 file in this batch. No src/bin file touched, no
numeric value changed anywhere.

Co-authored-by: sim <sim@local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-09-12 09:12:31 -04:00
committed by GitHub
parent 241646a43a
commit c99d7bb2be
14 changed files with 103 additions and 38 deletions

View File

@@ -15,6 +15,7 @@
const { describe, test } = require('node:test');
const assert = require('node:assert/strict');
const fc = require('fast-check');
const { LOOP_HOOK_POINT_CLI_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
const {
stateReplaceField,
@@ -1100,7 +1101,7 @@ describe('#3204 buildStateFrontmatter total_phases — negative space / boundari
const { TOOLS_PATH, TEST_ENV_BASE } = require('./helpers.cjs');
const rec = runNode(
[TOOLS_PATH, 'state', 'json', '--raw'],
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: 60000 },
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: LOOP_HOOK_POINT_CLI_TIMEOUT_MS },
);
assert.ok(rec.exitCode === 0, `state json --raw failed: ${rec.stderr}`);
assert.ok(
@@ -1658,7 +1659,7 @@ describe('#3355 phase-dir dedup — collision tie-break must not consult mtime',
// (runGsdTools discards stderr on success, so drive the seam directly).
const rec = runNode(
[TOOLS_PATH, 'state', 'json', '--raw'],
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: 60000 },
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: LOOP_HOOK_POINT_CLI_TIMEOUT_MS },
);
assert.ok(rec.exitCode === 0, `state json --raw failed: ${rec.stderr}`);
assert.ok(
@@ -1726,7 +1727,7 @@ describe('#3354 buildStateFrontmatter total_phases — milestoned-but-unbounded
// stderr on success). The warning is asserted on THIS invocation.
const rec = runNode(
[TOOLS_PATH, 'state', 'record-session', '--stopped-at', 'Phase 1, Plan 1', '--resume-file', 'none'],
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: 60000 },
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: LOOP_HOOK_POINT_CLI_TIMEOUT_MS },
);
assert.ok(rec.exitCode === 0, `state record-session failed: ${rec.stderr}`);
@@ -1823,7 +1824,7 @@ describe('#3573 total_phases — roadmap absent with an asserted milestone', ()
function recordSession(dir, stoppedAt = 'Phase 1, Plan 1') {
return runNode(
[TOOLS_PATH, 'state', 'record-session', '--stopped-at', stoppedAt, '--resume-file', 'none'],
{ cwd: dir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: 60000 },
{ cwd: dir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: LOOP_HOOK_POINT_CLI_TIMEOUT_MS },
);
}
@@ -1867,7 +1868,7 @@ describe('#3573 total_phases — roadmap absent with an asserted milestone', ()
// about total_phases surviving the resync.
const rec = runNode(
[TOOLS_PATH, 'state', 'begin-phase', '--phase', '2'],
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: 60000 },
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: LOOP_HOOK_POINT_CLI_TIMEOUT_MS },
);
assert.ok(rec.exitCode === 0, `state begin-phase failed: ${rec.stderr}`);
assert.strictEqual(
@@ -1935,7 +1936,7 @@ describe('#3573 total_phases — roadmap absent with an asserted milestone', ()
// about total_phases surviving the resync.
const rec = runNode(
[TOOLS_PATH, 'state', 'planned-phase', '--phase', '2', '--name', 'Core'],
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: 60000 },
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: LOOP_HOOK_POINT_CLI_TIMEOUT_MS },
);
assert.ok(rec.exitCode === 0, `state planned-phase failed: ${rec.stderr}`);
assert.strictEqual(
@@ -2072,7 +2073,7 @@ describe('#4094 milestone-unbounded withhold — all four progress counters', ()
function recordSession(dir, stoppedAt = 'Phase 1, Plan 1') {
return runNode(
[TOOLS_PATH, 'state', 'record-session', '--stopped-at', stoppedAt, '--resume-file', 'none'],
{ cwd: dir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: 60000 },
{ cwd: dir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: LOOP_HOOK_POINT_CLI_TIMEOUT_MS },
);
}
@@ -2288,7 +2289,7 @@ describe('#4094 milestone-unbounded withhold — all four progress counters', ()
const rec = runNode(
[TOOLS_PATH, 'state', 'sync'],
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: 60000 },
{ cwd: tmpDir, env: { ...process.env, ...TEST_ENV_BASE }, timeoutMs: LOOP_HOOK_POINT_CLI_TIMEOUT_MS },
);
assert.ok(rec.exitCode === 0, `state sync failed: ${rec.stderr}`);