test(#4521): migrate capability subsystem batch to named timeout constants (#4627)

Batch 10 of the ad hoc timeout literal migration (epic #4445). Replaces
every bare numeric timeout/timeoutMs object-literal property in
tests/adr857-core-without-capabilities.test.cjs, tests/capability-cli.test.cjs,
tests/capability-probe-fallback.test.cjs, tests/capability-state.test.cjs,
tests/capability-trust.test.cjs,
tests/capability-validator-task-content-resolver.test.cjs, and
tests/capability-writer.test.cjs with a named constant, per
eslint-rules/no-adhoc-timeout-literal.cjs. Removes these 7 files from the
rule's allowlist.

Reuses the existing PROBE_TIMEOUT_MS constant at 8 sites across 3 files.
Adds 7 new file-local constants (no promotion to the shared helper needed
this batch -- every new class is confined to exactly one file, below the
two-file promotion bar): GSD_TOOLS_CLI_TIMEOUT_MS,
FRAGMENT_PROBE_SNIPPET_TIMEOUT_MS, INSTALLED_RUNTIME_CLI_TIMEOUT_MS,
FIXTURE_MCP_SERVER_TIMEOUT_VALUE, TASK_RESOLVER_FIXTURE_TIMEOUT_MS,
TASK_RESOLVER_TIMEOUT_CEILING_MS, and TASK_RESOLVER_TIMEOUT_CEILING_PLUS_ONE_MS
(the last two forming a boundary-coverage limit/limit+1 pair). 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-11 09:55:55 -04:00
committed by GitHub
parent 7249bdddac
commit aad96e0b5f
8 changed files with 97 additions and 25 deletions

View File

@@ -16,6 +16,7 @@ const os = require('node:os');
const path = require('node:path');
const { cleanup, runGsdTools } = require('./helpers.cjs');
const { PROBE_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
const {
resolveCapabilityState,
@@ -786,7 +787,7 @@ function runCapabilityState(cwd, configDir) {
const result = spawnSync(
process.execPath,
[gsdToolsPath, 'capability', 'state', '--config-dir', configDir, '--raw', '--cwd', cwd],
{ encoding: 'utf8', timeout: 15000 },
{ encoding: 'utf8', timeout: PROBE_TIMEOUT_MS },
);
return result;
}
@@ -1324,7 +1325,7 @@ describe('regressions: installed-runtime capability surface (#1160)', () => {
'--config-dir', tmpInstalledConfigDir,
'--cwd', tmpInstalledProjectDir,
],
{ encoding: 'utf8', timeout: 15000 },
{ encoding: 'utf8', timeout: PROBE_TIMEOUT_MS },
);
assert.strictEqual(result.status, 0, `gsd-tools exited ${result.status}:\nstdout: ${result.stdout}\nstderr: ${result.stderr}`);
const envelope = JSON.parse(result.stdout.trim());
@@ -1353,7 +1354,7 @@ describe('regressions: installed-runtime capability surface (#1160)', () => {
'--config-dir', tmpInstalledConfigDir,
'--cwd', tmpInstalledProjectDir,
],
{ encoding: 'utf8', timeout: 15000 },
{ encoding: 'utf8', timeout: PROBE_TIMEOUT_MS },
);
assert.strictEqual(result.status, 0, `gsd-tools exited ${result.status}:\nstdout: ${result.stdout}\nstderr: ${result.stderr}`);
const envelope = JSON.parse(result.stdout.trim());
@@ -1381,6 +1382,19 @@ describe('regressions: installed-runtime capability surface (#1160)', () => {
// is genuinely empty, so pre-fix the '*' profile materialized to an empty
// surfaced set → enabled=false → verify:post activeHooks: []. This test FAILS
// before the fix and PASSES after.
/**
* gsd-tools.cjs spawned against a COPIED install-root tree (fs.cpSync of the
* executable runtime into a temp dir simulating a global skills-runtime
* install with no commands/ sibling) rather than the bare source checkout.
* Same CLI-query shape as PROBE_TIMEOUT_MS (15000ms) elsewhere in this file,
* but a genuinely heavier pre-existing bound -- not equalized without bench
* data. Coincides numerically with tests/helpers/timeouts.cjs's
* STAGED_HOOK_SCRIPT_TIMEOUT_MS but describes a different operation (a
* gsd-tools.cjs CLI subcommand, not a staged hook script) -- kept local.
*/
const INSTALLED_RUNTIME_CLI_TIMEOUT_MS = 20000;
describe('true installed layout (commands/gsd unreachable)', () => {
let installRoot;
let installedConfigDir;
@@ -1449,7 +1463,7 @@ describe('regressions: installed-runtime capability surface (#1160)', () => {
'--cwd', installedProjectDir,
'--raw',
],
{ encoding: 'utf8', timeout: 20000 },
{ encoding: 'utf8', timeout: INSTALLED_RUNTIME_CLI_TIMEOUT_MS },
);
assert.strictEqual(result.status, 0, `gsd-tools exited ${result.status}:\nstdout: ${result.stdout}\nstderr: ${result.stderr}`);
const envelope = JSON.parse(result.stdout);
@@ -1471,7 +1485,7 @@ describe('regressions: installed-runtime capability surface (#1160)', () => {
'--config-dir', installedConfigDir,
'--cwd', installedProjectDir,
],
{ encoding: 'utf8', timeout: 20000 },
{ encoding: 'utf8', timeout: INSTALLED_RUNTIME_CLI_TIMEOUT_MS },
);
assert.strictEqual(result.status, 0, `gsd-tools exited ${result.status}:\nstdout: ${result.stdout}\nstderr: ${result.stderr}`);
const envelope = JSON.parse(result.stdout.trim());
@@ -1506,7 +1520,7 @@ describe('regressions: installed-runtime capability surface (#1160)', () => {
'--config-dir', installedConfigDir,
'--cwd', disabledProj,
],
{ encoding: 'utf8', timeout: 20000 },
{ encoding: 'utf8', timeout: INSTALLED_RUNTIME_CLI_TIMEOUT_MS },
);
assert.strictEqual(result.status, 0, `gsd-tools exited ${result.status}:\nstderr: ${result.stderr}`);
const envelope = JSON.parse(result.stdout.trim());