test(#4520): migrate generators/doc-gates/attribution batch to named timeout constants

Batch 9 of 17 in the ad hoc timeout literal migration (epic #4445).
Replaces every bare numeric timeout/timeoutMs object-literal property in
14 files with a named constant, per eslint-rules/no-adhoc-timeout-literal.cjs.
Removes the 14 files from the rule's allowlist.

The issue's own guess ("all run a scripts/*.cjs generator or lint script
once, BUILD_TIMEOUT_MS class") needed two corrections found by reading
every site directly. First, BUILD_TIMEOUT_MS's own doc comment scopes it
specifically to scripts/build-hooks.js, which none of this batch's
generator/lint-script sites run — a new shared constant,
GENERATOR_SCRIPT_TIMEOUT_MS, covers the class instead. Second,
no-pending-3212-markers.test.cjs's single site spawns `git ls-files`
directly, not a scripts/*.cjs script at all — routed to a second new
shared constant, REAL_REPO_GIT_TIMEOUT_MS, promoted once
emitted-attribution.test.cjs's own git-plumbing sites were found sharing
the same class and value.

Isolated Standards-axis review caught a further misclassification: one
of REAL_REPO_GIT_TIMEOUT_MS's three emitted-attribution.test.cjs sites
actually builds a fresh throwaway temp repo (createTempDir + git init),
contradicting that constant's own real-repo-tree-only scope. Fixed with
a new file-local FRESH_FIXTURE_GIT_TIMEOUT_MS holding the exact
pre-existing value under an honest name, rather than reusing the shared
GIT_FIXTURE_TIMEOUT_MS (which would have doubled the bound).

emitted-attribution.test.cjs also gets two more file-local constants:
HEAVY_REAL_TREE_TEST_TIMEOUT_MS (node:test's own per-test timeout
option, not a spawn bound) and BUILD_HOOKS_UNDER_LOAD_TIMEOUT_MS (the
same build-hooks.js script as the shared norm, at 4x its bound inside
the suite's heaviest test). emitted-ack-trailer.test.cjs gets
IMPOSSIBLY_SHORT_GIT_TIMEOUT_MS — the one value in this migration that
is deliberately tiny (20ms), used to force a timeout in a negative test,
not generous headroom.

No src/bin file touched, no numeric value changed anywhere.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
sim
2026-09-10 19:22:04 -04:00
parent a1a4182bda
commit 2eef8ada4f
16 changed files with 138 additions and 35 deletions

View File

@@ -224,6 +224,47 @@ const SCAN_USAGE_ERROR_TIMEOUT_MS = 5000;
*/
const MALFORMED_INPUT_HOOK_TIMEOUT_MS = 5000;
/**
* A single `scripts/*.cjs` generator or lint script (gen-adr-index.cjs,
* check-glossary-refs.cjs, gen-context-index.cjs, and siblings), spawned
* directly and once against a small temp fixture repo -- no fan-out.
*
* Deliberately NOT `BUILD_TIMEOUT_MS`, despite the coincidentally-matching
* value: that constant's own doc comment scopes it specifically to
* `scripts/build-hooks.js` ("not a full project build"), and none of this
* norm's sites run that script. Reusing a constant for its number while
* ignoring what its comment actually describes is exactly the trap this
* migration exists to avoid -- see `SEAM_DEFAULT_TIMEOUT_MS` and
* `SCAN_USAGE_ERROR_TIMEOUT_MS` for the same reasoning applied elsewhere in
* this file.
*
* Shared across 7 files in batch #4520 of the ad hoc timeout literal
* migration, epic #4445 -- every site independently arrived at this exact
* value -- that is why it lives here rather than as a file-local constant.
*/
const GENERATOR_SCRIPT_TIMEOUT_MS = 30000;
/**
* A git plumbing command (or a short scratch-index sequence of them) run
* against the REAL, current repo tree -- never a throwaway mkdtemp fixture.
* Distinct from `GIT_TIMEOUT_MS` (15000ms, plumbing reads against a small
* fixture repo) and `GIT_FIXTURE_TIMEOUT_MS` (60000ms, the shared helper's
* own multi-spawn fixture-CONSTRUCTION sequence) -- this norm's sites
* either read the real object database directly (`git ls-files`) or build a
* synthetic commit on a scratch index against it, which is heavier than a
* tiny-fixture read but not the shared helper's own six-spawn construction
* class. Explicitly NOT for fixture-repo CONSTRUCTION (init/config/add/commit
* against a throwaway mkdtemp repo) -- tests/emitted-attribution.test.cjs's
* own file-local `FRESH_FIXTURE_GIT_TIMEOUT_MS` covers that shape instead,
* after an earlier pass conflated the two and a Standards-axis review caught
* it.
*
* Shared across 2 files in batch #4520 of the ad hoc timeout literal
* migration, epic #4445 -- every site independently arrived at this exact
* value -- that is why it lives here rather than as a file-local constant.
*/
const REAL_REPO_GIT_TIMEOUT_MS = 30000;
module.exports = {
PROBE_TIMEOUT_MS,
HOOK_FANOUT_TIMEOUT_MS,
@@ -238,4 +279,6 @@ module.exports = {
LOOP_HOOK_POINT_CLI_TIMEOUT_MS,
SCAN_USAGE_ERROR_TIMEOUT_MS,
MALFORMED_INPUT_HOOK_TIMEOUT_MS,
GENERATOR_SCRIPT_TIMEOUT_MS,
REAL_REPO_GIT_TIMEOUT_MS,
};