@holmes-lab/holmes-kit 0.30.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CHANGELOG.md +494 -0
  2. package/README.md +10 -1
  3. package/bin/holmes-hook-antigravity.js +4 -0
  4. package/bin/holmes-kit.js +4 -0
  5. package/bin/holmes-pre-push.js +3 -0
  6. package/bin/holmes-stop-antigravity.js +4 -0
  7. package/dist/.build-id +1 -1
  8. package/dist/holmes/cli/agents.d.ts +41 -0
  9. package/dist/holmes/cli/agents.js +382 -2
  10. package/dist/holmes/cli/attest.d.ts +2 -0
  11. package/dist/holmes/cli/attest.js +66 -15
  12. package/dist/holmes/cli/ci-gate.js +16 -1
  13. package/dist/holmes/cli/claude-switches.d.ts +95 -0
  14. package/dist/holmes/cli/claude-switches.js +967 -0
  15. package/dist/holmes/cli/codex-hooks.d.ts +77 -0
  16. package/dist/holmes/cli/codex-hooks.js +802 -0
  17. package/dist/holmes/cli/codex-oracle.d.ts +194 -0
  18. package/dist/holmes/cli/codex-oracle.js +1245 -0
  19. package/dist/holmes/cli/codex-toml.d.ts +35 -0
  20. package/dist/holmes/cli/codex-toml.js +321 -52
  21. package/dist/holmes/cli/doctor.d.ts +98 -8
  22. package/dist/holmes/cli/doctor.js +1328 -94
  23. package/dist/holmes/cli/index.js +23 -11
  24. package/dist/holmes/cli/init.d.ts +11 -0
  25. package/dist/holmes/cli/init.js +736 -44
  26. package/dist/holmes/cli/mcp-launcher.d.ts +64 -6
  27. package/dist/holmes/cli/mcp-launcher.js +189 -6
  28. package/dist/holmes/cli/mcp-version.js +13 -2
  29. package/dist/holmes/cli/settings-merge.js +8 -2
  30. package/dist/holmes/cli/upgrade.d.ts +13 -0
  31. package/dist/holmes/cli/upgrade.js +116 -23
  32. package/dist/holmes/cli/workspace-scope.d.ts +22 -0
  33. package/dist/holmes/cli/workspace-scope.js +375 -0
  34. package/dist/holmes/cpg/cpg-scanner.d.ts +29 -0
  35. package/dist/holmes/cpg/cpg-scanner.js +403 -3
  36. package/dist/holmes/cpg/cycle-detect.js +2 -1
  37. package/dist/holmes/cpg/forbidden-edges.js +9 -2
  38. package/dist/holmes/cpg/required-calls.js +8 -1
  39. package/dist/holmes/governance/constitution-debt.js +3 -2
  40. package/dist/holmes/governance/constitution.js +15 -3
  41. package/dist/holmes/governance/provenance-chain.js +3 -2
  42. package/dist/holmes/governance/push-gate-runner.js +4 -3
  43. package/dist/holmes/guardrail/dependency-delta.js +4 -3
  44. package/dist/holmes/guardrail/linear-match.d.ts +57 -0
  45. package/dist/holmes/guardrail/linear-match.js +256 -0
  46. package/dist/holmes/guardrail/risk-classifier.d.ts +6 -7
  47. package/dist/holmes/guardrail/risk-classifier.js +931 -44
  48. package/dist/holmes/guardrail/risk-types.d.ts +6 -0
  49. package/dist/holmes/guardrail/scope-judgment.d.ts +4 -24
  50. package/dist/holmes/guardrail/scope-judgment.js +100 -23
  51. package/dist/holmes/guardrail/shell-words.d.ts +42 -0
  52. package/dist/holmes/guardrail/shell-words.js +1720 -0
  53. package/dist/holmes/guardrail/write-target.d.ts +168 -3
  54. package/dist/holmes/guardrail/write-target.js +2379 -87
  55. package/dist/holmes/hooks/adapters/antigravity.d.ts +3 -1
  56. package/dist/holmes/hooks/adapters/antigravity.js +115 -11
  57. package/dist/holmes/hooks/pre-tool-use.d.ts +32 -6
  58. package/dist/holmes/hooks/pre-tool-use.js +923 -87
  59. package/dist/holmes/hooks/rtm-refresh-child.js +3 -1
  60. package/dist/holmes/hooks/rtm-refresh.js +8 -4
  61. package/dist/holmes/hooks/session-start.d.ts +10 -0
  62. package/dist/holmes/hooks/session-start.js +31 -7
  63. package/dist/holmes/hooks/stop.d.ts +2 -1
  64. package/dist/holmes/hooks/stop.js +197 -91
  65. package/dist/holmes/mcp/approval-commit.d.ts +5 -6
  66. package/dist/holmes/mcp/approval-commit.js +18 -2
  67. package/dist/holmes/mcp/elicit-approval.js +4 -2
  68. package/dist/holmes/mcp/handlers/graph-operations.js +3 -2
  69. package/dist/holmes/mcp/handlers/maintenance-analysis.js +11 -5
  70. package/dist/holmes/mcp/handlers/maintenance-evidence.js +3 -2
  71. package/dist/holmes/mcp/handlers/phase-queries.d.ts +22 -7
  72. package/dist/holmes/mcp/handlers/phase-queries.js +81 -2
  73. package/dist/holmes/mcp/handlers/requirement-triage.js +5 -3
  74. package/dist/holmes/mcp/handlers/review-evidence.js +8 -2
  75. package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +11 -0
  76. package/dist/holmes/mcp/handlers/slice-orchestration.js +115 -16
  77. package/dist/holmes/mcp/handlers/spec-approval.d.ts +9 -0
  78. package/dist/holmes/mcp/handlers/spec-approval.js +110 -17
  79. package/dist/holmes/mcp/handlers/spec-authoring.js +17 -2
  80. package/dist/holmes/mcp/handlers/spec-queries.d.ts +39 -3
  81. package/dist/holmes/mcp/handlers/spec-queries.js +114 -7
  82. package/dist/holmes/mcp/handlers/test-execution.js +9 -3
  83. package/dist/holmes/mcp/handlers.d.ts +81 -9
  84. package/dist/holmes/mcp/handlers.js +70 -23
  85. package/dist/holmes/mcp/harness-attestation.d.ts +20 -0
  86. package/dist/holmes/mcp/harness-attestation.js +179 -0
  87. package/dist/holmes/mcp/requirement-triage-evidence.d.ts +36 -0
  88. package/dist/holmes/mcp/requirement-triage-evidence.js +160 -4
  89. package/dist/holmes/mcp/server.js +20 -1
  90. package/dist/holmes/mcp/tool-schemas.js +26 -9
  91. package/dist/holmes/mcp/validate-args.js +12 -0
  92. package/dist/holmes/project/bounded-io.d.ts +102 -0
  93. package/dist/holmes/project/bounded-io.js +212 -0
  94. package/dist/holmes/project/change-source.js +3 -1
  95. package/dist/holmes/project/ci-runs.js +3 -2
  96. package/dist/holmes/project/ignore.d.ts +31 -2
  97. package/dist/holmes/project/ignore.js +409 -50
  98. package/dist/holmes/project/regular-file-guard.d.ts +13 -0
  99. package/dist/holmes/project/regular-file-guard.js +149 -0
  100. package/dist/holmes/project/root.js +12 -3
  101. package/dist/holmes/reverse/anchor.js +4 -3
  102. package/dist/holmes/reverse/scan.js +6 -2
  103. package/dist/holmes/review/commit-text.js +3 -2
  104. package/dist/holmes/review/condition-hunk-replay.js +3 -2
  105. package/dist/holmes/review/failed-test-names.js +13 -10
  106. package/dist/holmes/review/findings.js +3 -1
  107. package/dist/holmes/review/kills-check.js +6 -1
  108. package/dist/holmes/review/point-in-time-replay.js +5 -4
  109. package/dist/holmes/review/replay-corpus.js +5 -4
  110. package/dist/holmes/review/run-replay.js +3 -2
  111. package/dist/holmes/review/temporal-prior.js +3 -2
  112. package/dist/holmes/review/test-evidence.js +3 -2
  113. package/dist/holmes/review/test-outcomes.js +3 -2
  114. package/dist/holmes/review/test-runner.d.ts +6 -0
  115. package/dist/holmes/review/test-runner.js +36 -15
  116. package/dist/holmes/rtm/advisory-outcomes.js +3 -2
  117. package/dist/holmes/rtm/anchor-ids.js +42 -2
  118. package/dist/holmes/rtm/file-anchors.js +4 -1
  119. package/dist/holmes/rtm/ftt-fulfilment.js +8 -3
  120. package/dist/holmes/rtm/git-changes.js +3 -1
  121. package/dist/holmes/rtm/graph-store.js +3 -2
  122. package/dist/holmes/rtm/test-scope.js +9 -4
  123. package/dist/holmes/spec/compat-impact.d.ts +25 -4
  124. package/dist/holmes/spec/compat-impact.js +682 -11
  125. package/dist/holmes/spec/entity-git-snapshot.js +3 -2
  126. package/dist/holmes/spec/entity-integration.js +3 -2
  127. package/dist/holmes/spec/entity-renumber-transaction.d.ts +19 -0
  128. package/dist/holmes/spec/entity-renumber-transaction.js +79 -6
  129. package/dist/holmes/spec/remote-spec-refs.js +3 -2
  130. package/dist/holmes/spec/renumber.js +25 -10
  131. package/dist/holmes/spec/spec-parser.js +9 -3
  132. package/dist/holmes/spec/yaml-scalar.js +2 -2
  133. package/dist/holmes/update/refresh.js +3 -1
  134. package/dist/holmes/update/update-notice.d.ts +6 -0
  135. package/dist/holmes/update/update-notice.js +18 -1
  136. package/package.json +11 -4
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.regularFileGuardInstalled = regularFileGuardInstalled;
4
+ exports.installRegularFileGuard = installRegularFileGuard;
5
+ exports.uninstallRegularFileGuard = uninstallRegularFileGuard;
6
+ exports.installProcessGuards = installProcessGuards;
7
+ /**
8
+ * The real module object. `import * as fs` yields an interop copy whose members are getters onto it, so
9
+ * the guard assigns on the module every other file's `fs.x(...)` reads at call time.
10
+ */
11
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
12
+ const fs = require('node:fs');
13
+ const C = fs.constants;
14
+ const NONBLOCK = typeof C.O_NONBLOCK === 'number' ? C.O_NONBLOCK : 0;
15
+ const SYNC = typeof C.O_SYNC === 'number' ? C.O_SYNC : 0;
16
+ /** Node's string flags as numbers; null for a spelling this guard does not know (the call then passes as is). */
17
+ function flagsOf(flag, fallback) {
18
+ if (typeof flag === 'number')
19
+ return flag;
20
+ const f = flag === undefined || flag === null ? fallback : flag;
21
+ switch (f) {
22
+ case 'r': return C.O_RDONLY;
23
+ case 'rs':
24
+ case 'sr': return C.O_RDONLY | SYNC;
25
+ case 'r+': return C.O_RDWR;
26
+ case 'rs+':
27
+ case 'sr+': return C.O_RDWR | SYNC;
28
+ case 'w': return C.O_TRUNC | C.O_CREAT | C.O_WRONLY;
29
+ case 'wx':
30
+ case 'xw': return C.O_TRUNC | C.O_CREAT | C.O_WRONLY | C.O_EXCL;
31
+ case 'w+': return C.O_TRUNC | C.O_CREAT | C.O_RDWR;
32
+ case 'wx+':
33
+ case 'xw+': return C.O_TRUNC | C.O_CREAT | C.O_RDWR | C.O_EXCL;
34
+ case 'a': return C.O_APPEND | C.O_CREAT | C.O_WRONLY;
35
+ case 'ax':
36
+ case 'xa': return C.O_APPEND | C.O_CREAT | C.O_WRONLY | C.O_EXCL;
37
+ case 'as':
38
+ case 'sa': return C.O_APPEND | C.O_CREAT | C.O_WRONLY | SYNC;
39
+ case 'a+': return C.O_APPEND | C.O_CREAT | C.O_RDWR;
40
+ case 'ax+':
41
+ case 'xa+': return C.O_APPEND | C.O_CREAT | C.O_RDWR | C.O_EXCL;
42
+ case 'as+':
43
+ case 'sa+': return C.O_APPEND | C.O_CREAT | C.O_RDWR | SYNC;
44
+ default: return null;
45
+ }
46
+ }
47
+ const isPath = (p) => typeof p === 'string' || Buffer.isBuffer(p) || p instanceof URL;
48
+ const optionOf = (o, key) => (o !== null && typeof o === 'object' ? o[key] : undefined);
49
+ /** The caller's options without `flag`, for the call made on the descriptor. */
50
+ const withoutFlag = (o) => {
51
+ if (o === null || typeof o !== 'object')
52
+ return o;
53
+ const { flag: _flag, ...rest } = o;
54
+ void _flag;
55
+ return rest;
56
+ };
57
+ function notRegular(p, syscall) {
58
+ const err = new Error(`EINVAL: not a regular file, ${syscall} '${String(p)}'`);
59
+ err.code = 'EINVAL';
60
+ err.syscall = syscall;
61
+ err.path = String(p);
62
+ return err;
63
+ }
64
+ let originals = null;
65
+ /** Whether the guard is installed in this thread. */
66
+ function regularFileGuardInstalled() { return originals !== null; }
67
+ /** Install the guard for this thread (idempotent). */
68
+ function installRegularFileGuard() {
69
+ if (originals !== null)
70
+ return;
71
+ const o = { readFileSync: fs.readFileSync, writeFileSync: fs.writeFileSync, appendFileSync: fs.appendFileSync, openSync: fs.openSync };
72
+ originals = o;
73
+ const openChecked = (p, flags, mode, syscall) => {
74
+ const fd = o.openSync(p, flags | NONBLOCK, typeof mode === "number" || typeof mode === "string" ? mode : 0o666);
75
+ let ok = false;
76
+ try {
77
+ ok = fs.fstatSync(fd).isFile();
78
+ }
79
+ catch {
80
+ ok = false;
81
+ }
82
+ if (!ok) {
83
+ fs.closeSync(fd);
84
+ throw notRegular(p, syscall);
85
+ }
86
+ return fd;
87
+ };
88
+ const target = fs;
89
+ target.readFileSync = function readFileSync(p, options) {
90
+ if (!isPath(p))
91
+ return o.readFileSync(p, options);
92
+ const flags = flagsOf(optionOf(options, 'flag'), 'r');
93
+ if (flags === null)
94
+ return o.readFileSync(p, options);
95
+ const fd = openChecked(p, flags, undefined, 'open');
96
+ try {
97
+ return o.readFileSync(fd, withoutFlag(options));
98
+ }
99
+ finally {
100
+ fs.closeSync(fd);
101
+ }
102
+ };
103
+ const writeLike = (orig, fallback) => function (p, data, options) {
104
+ if (!isPath(p))
105
+ return orig(p, data, options);
106
+ const flags = flagsOf(typeof options === 'string' ? undefined : optionOf(options, 'flag'), fallback);
107
+ if (flags === null)
108
+ return orig(p, data, options);
109
+ const fd = openChecked(p, flags, optionOf(options, 'mode'), 'open');
110
+ try {
111
+ return orig(fd, data, withoutFlag(options));
112
+ }
113
+ finally {
114
+ fs.closeSync(fd);
115
+ }
116
+ };
117
+ target.writeFileSync = writeLike(o.writeFileSync, 'w');
118
+ target.appendFileSync = writeLike(o.appendFileSync, 'a');
119
+ target.openSync = function openSync(p, flags, mode) {
120
+ if (!isPath(p))
121
+ return o.openSync(p, flags, mode);
122
+ const n = flagsOf(flags, 'r');
123
+ return n === null ? o.openSync(p, flags, mode) : o.openSync(p, n | NONBLOCK, mode);
124
+ };
125
+ }
126
+ /** Test seam: restore the real functions. */
127
+ function uninstallRegularFileGuard() {
128
+ if (originals === null)
129
+ return;
130
+ const target = fs;
131
+ target.readFileSync = originals.readFileSync;
132
+ target.writeFileSync = originals.writeFileSync;
133
+ target.appendFileSync = originals.appendFileSync;
134
+ target.openSync = originals.openSync;
135
+ originals = null;
136
+ }
137
+ /**
138
+ * @implements A-SPEC-734 (round 17) — what every product process does at start: the regular-file guard, and the
139
+ * removal of the variables that relocate the repository a git child reads (`GIT_DIR` and the rest of
140
+ * `REPO_LOCATING_GIT_VARS`). Round 16 dropped them at the call sites it knew; the scanner's nesting queries kept an
141
+ * exported `GIT_DIR` and listed a registered worktree's files (measured). One list of entries, one decision.
142
+ */
143
+ function installProcessGuards() {
144
+ installRegularFileGuard();
145
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
146
+ const { REPO_LOCATING_GIT_VARS } = require('./bounded-io');
147
+ for (const k of REPO_LOCATING_GIT_VARS)
148
+ delete process.env[k];
149
+ }
@@ -38,11 +38,12 @@ exports.cleanSubprocessEnv = cleanSubprocessEnv;
38
38
  exports.cleanTestEnv = cleanTestEnv;
39
39
  exports.sameCanonicalDirectory = sameCanonicalDirectory;
40
40
  exports.resolveProjectRoot = resolveProjectRoot;
41
- // @implements A-SPEC-205, A-SPEC-627
41
+ // @implements A-SPEC-205, A-SPEC-627, A-SPEC-734
42
42
  // @implements A-SPEC-128
43
43
  const fs = __importStar(require("node:fs"));
44
44
  const path = __importStar(require("node:path"));
45
45
  const node_child_process_1 = require("node:child_process");
46
+ const bounded_io_1 = require("./bounded-io");
46
47
  // @implements A-SPEC-194
47
48
  // @implements A-SPEC-196
48
49
  // @implements A-SPEC-205
@@ -56,6 +57,9 @@ function cleanSubprocessEnv(env = process.env) {
56
57
  delete cleaned[k];
57
58
  }
58
59
  }
60
+ // @implements A-SPEC-734 (round 16) — a child git reads the repository at its cwd, not one an exported GIT_DIR names.
61
+ for (const k of bounded_io_1.REPO_LOCATING_GIT_VARS)
62
+ delete cleaned[k];
59
63
  return cleaned;
60
64
  }
61
65
  // @implements A-SPEC-514.1
@@ -140,9 +144,13 @@ function sameCanonicalDirectory(a, b, realpath = exports.canonicalPath) {
140
144
  return spell(a) === spell(b);
141
145
  }
142
146
  function gitTopLevel(dir) {
147
+ // @implements A-SPEC-734 (round 12) — a root whose git timed out is not asked again for a minute
148
+ // (`include.path` naming a FIFO blocked this rev-parse in every hook — measured).
149
+ if ((0, bounded_io_1.gitRootBlocked)(dir, 'repo'))
150
+ return undefined;
143
151
  try {
144
152
  // stderr silenced: "not a git repository" is an expected branch here, not a fault worth printing.
145
- const out = (0, node_child_process_1.execFileSync)('git', ['-C', dir, 'rev-parse', '--show-toplevel'], {
153
+ const out = (0, node_child_process_1.execFileSync)('git', ['-C', dir, 'rev-parse', '--show-toplevel'], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER,
146
154
  encoding: 'utf8',
147
155
  stdio: ['ignore', 'pipe', 'ignore'],
148
156
  env: cleanSubprocessEnv(),
@@ -151,7 +159,8 @@ function gitTopLevel(dir) {
151
159
  // (macOS /var -> /private/var otherwise makes an identical directory look like a mismatch).
152
160
  return out ? canonical(out) : undefined;
153
161
  }
154
- catch {
162
+ catch (e) {
163
+ (0, bounded_io_1.noteGitFailure)(dir, e, 'repo');
155
164
  return undefined;
156
165
  }
157
166
  }
@@ -35,9 +35,10 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.planAnchors = planAnchors;
37
37
  exports.applyAnchors = applyAnchors;
38
- // @implements A-SPEC-126
38
+ // @implements A-SPEC-126, A-SPEC-734
39
39
  const fs = __importStar(require("node:fs"));
40
40
  const path = __importStar(require("node:path"));
41
+ const bounded_io_1 = require("../project/bounded-io");
41
42
  /**
42
43
  * Comment prefix per language, covering every extension in `SCANNABLE_EXTENSIONS`.
43
44
  * An anchor written with the wrong prefix is a syntax error in the target file, so this table is
@@ -113,7 +114,7 @@ function planAnchors(root, mapping, approvedAspecs) {
113
114
  }
114
115
  let code;
115
116
  try {
116
- code = fs.readFileSync(abs, 'utf8');
117
+ code = (0, bounded_io_1.readRegularTextSync)(abs);
117
118
  }
118
119
  catch {
119
120
  refused.push({ file, aspec, reason: 'unreadable' });
@@ -143,7 +144,7 @@ function applyAnchors(root, edits, opts = {}) {
143
144
  for (const e of edits) {
144
145
  try {
145
146
  const abs = path.join(root, e.file);
146
- const code = fs.readFileSync(abs, 'utf8');
147
+ const code = (0, bounded_io_1.readRegularTextSync)(abs);
147
148
  // Match the file's own line ending. Splicing an LF line into a CRLF file leaves one stray
148
149
  // ending, which reads as a whole-file change in some tooling and a lint error in others —
149
150
  // noise attributable to the anchor rather than to the code. Brownfield trees have both.
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.candidates = candidates;
37
37
  exports.reverseScan = reverseScan;
38
- // @implements A-SPEC-126
38
+ // @implements A-SPEC-126, A-SPEC-734
39
39
  const fs = __importStar(require("node:fs"));
40
40
  const path = __importStar(require("node:path"));
41
41
  const node_child_process_1 = require("node:child_process");
@@ -48,6 +48,7 @@ const surface_1 = require("./surface");
48
48
  // @implements A-SPEC-128
49
49
  const ignore_1 = require("../project/ignore");
50
50
  const draft_1 = require("./draft");
51
+ const bounded_io_1 = require("../project/bounded-io");
51
52
  const SCANNABLE_RE = new RegExp(`(${cpg_scanner_1.SCANNABLE_EXTENSIONS.map((e) => e.replace('.', '\\.')).join('|')})$`);
52
53
  /** Walk a non-git tree for test files, mirroring the scanner's own vendor-directory skips. */
53
54
  function walkTestFiles(root) {
@@ -65,6 +66,8 @@ function walkTestFiles(root) {
65
66
  continue;
66
67
  const abs = path.join(dir, e.name);
67
68
  const rel = path.relative(root, abs).split(path.sep).join('/');
69
+ if (e.isDirectory() && (0, cpg_scanner_1.isNestedWorkTree)(abs, root))
70
+ continue; // A-SPEC-734: another repository
68
71
  if (e.isDirectory())
69
72
  walk(abs);
70
73
  else if (SCANNABLE_RE.test(e.name) && (0, test_files_1.isTestFile)(rel))
@@ -87,7 +90,8 @@ function candidates(root, scan) {
87
90
  tracked = new Set(
88
91
  // stderr is silenced: on a non-git tree git's "not a repository" complaint is an expected
89
92
  // branch of this function, not a fault worth printing over the caller's output.
90
- (0, node_child_process_1.execFileSync)('git', ['-C', root, 'ls-files', '-z'], { encoding: 'utf8', maxBuffer: 1 << 28, stdio: ['ignore', 'pipe', 'ignore'] })
93
+ // A-SPEC-734 (round 15): an index read with the fsmonitor hook off (a slow hook read as "not git" — measured).
94
+ (0, node_child_process_1.execFileSync)('git', ['-c', 'core.fsmonitor=false', '-C', root, 'ls-files', '-z'], { timeout: bounded_io_1.GIT_TIMEOUT_MS, encoding: 'utf8', maxBuffer: 1 << 28, stdio: ['ignore', 'pipe', 'ignore'], env: (0, bounded_io_1.gitEnv)() })
91
95
  .split('\0')
92
96
  .filter(Boolean));
93
97
  }
@@ -2,16 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.commitTextProfile = commitTextProfile;
4
4
  exports.rankByCommitText = rankByCommitText;
5
- // @implements A-SPEC-385
5
+ // @implements A-SPEC-385, A-SPEC-734
6
6
  // @implements A-SPEC-386
7
7
  const node_child_process_1 = require("node:child_process");
8
8
  const maintenance_analyze_1 = require("../mcp/maintenance-analyze");
9
9
  const localize_1 = require("../rtm/localize");
10
+ const bounded_io_1 = require("../project/bounded-io");
10
11
  function commitTextProfile(root, before, limit = 400) {
11
12
  const empty = { byFile: new Map(), commits: 0, documentFrequency: new Map(), commitIds: new Set() };
12
13
  let raw;
13
14
  try {
14
- raw = (0, node_child_process_1.execFileSync)('git', ['-C', root, 'log', '--no-merges', `-${limit}`, '--format=%x00%H%x00%s', '--name-only', before], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
15
+ raw = (0, node_child_process_1.execFileSync)('git', ['-C', root, 'log', '--no-merges', `-${limit}`, '--format=%x00%H%x00%s', '--name-only', before], { timeout: bounded_io_1.GIT_TIMEOUT_MS, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
15
16
  }
16
17
  catch {
17
18
  return empty;
@@ -34,13 +34,14 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.replayConditionHunks = replayConditionHunks;
37
- // @implements A-SPEC-717
37
+ // @implements A-SPEC-717, A-SPEC-734
38
38
  // @implements A-SPEC-661
39
39
  /** Historical, read-only measurement for the condition-hunk advisory. */
40
40
  const node_child_process_1 = require("node:child_process");
41
41
  const path = __importStar(require("node:path"));
42
42
  const language_parser_1 = require("../cpg/language-parser");
43
43
  const condition_hunk_resolution_1 = require("./condition-hunk-resolution");
44
+ const bounded_io_1 = require("../project/bounded-io");
44
45
  const SAFE_COMMIT = /^[0-9a-f]{7,64}$/;
45
46
  const sourceLanguage = (file) => {
46
47
  if (/\.(ts|mts|cts)$/.test(file))
@@ -50,7 +51,7 @@ const sourceLanguage = (file) => {
50
51
  return null;
51
52
  };
52
53
  const safePath = (file) => file !== '' && !path.isAbsolute(file) && !file.split(/[\\/]/).includes('..');
53
- const git = (root, args) => (0, node_child_process_1.execFileSync)('git', ['-C', root, ...args], {
54
+ const git = (root, args) => (0, node_child_process_1.execFileSync)('git', ['-C', root, ...args], { timeout: bounded_io_1.GIT_LONG_TIMEOUT_MS,
54
55
  encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: 16 * 1024 * 1024,
55
56
  });
56
57
  /** Replays caller-selected commits only; it never checks out, writes a cache, or inspects another repository. */
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // @implements A-SPEC-582.1
2
+ // @implements A-SPEC-582.1, A-SPEC-733
3
3
  /**
4
4
  * The names behind a red release gate.
5
5
  *
@@ -14,7 +14,9 @@ exports.failedTestNames = failedTestNames;
14
14
  /** How many names a refusal lists before it counts the rest. */
15
15
  exports.FAILED_NAME_CAP = 10;
16
16
  /** Jest's summary marks each failure with `● <suite> › <test>`. */
17
- const SUMMARY_LINE = /^\s*●\s+(.+?)\s*$/;
17
+ // @implements A-SPEC-733 (round 9 census) — `(.+?)\s*$` rescanned a blank run from every lazy step
18
+ // (a name holding 80 KB of blanks: 3.7 s); the greedy capture is trimmed instead.
19
+ const SUMMARY_LINE = /^\s*●\s+(\S.*)$/;
18
20
  /**
19
21
  * Pull the failing test names out of a jest run's output.
20
22
  *
@@ -24,20 +26,21 @@ const SUMMARY_LINE = /^\s*●\s+(.+?)\s*$/;
24
26
  * failure.
25
27
  */
26
28
  function failedTestNames(output) {
27
- const seen = [];
29
+ // @implements A-SPEC-733 (round 11) — a Set: `seen.includes` was quadratic (100k distinct names: 10.5 s).
30
+ const seen = new Set();
28
31
  for (const line of String(output ?? '').split('\n')) {
29
32
  const m = SUMMARY_LINE.exec(line);
30
33
  if (m === null)
31
34
  continue;
32
- const name = m[1];
35
+ const name = m[1].trimEnd();
33
36
  // A `●` line that is not a test name (jest uses the bullet for Console blocks too).
34
37
  if (name === '' || name === 'Console' || !name.includes('›'))
35
38
  continue;
36
- if (!seen.includes(name))
37
- seen.push(name);
39
+ seen.add(name);
38
40
  }
39
- if (seen.length <= exports.FAILED_NAME_CAP)
40
- return seen;
41
- const rest = seen.length - exports.FAILED_NAME_CAP;
42
- return [...seen.slice(0, exports.FAILED_NAME_CAP), `… and ${rest} more`];
41
+ const names = [...seen];
42
+ if (names.length <= exports.FAILED_NAME_CAP)
43
+ return names;
44
+ const rest = names.length - exports.FAILED_NAME_CAP;
45
+ return [...names.slice(0, exports.FAILED_NAME_CAP), `… and ${rest} more`];
43
46
  }
@@ -34,8 +34,10 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.FindingsLedger = void 0;
37
+ // @implements A-SPEC-734
37
38
  const fs = __importStar(require("node:fs"));
38
39
  const path = __importStar(require("node:path"));
40
+ const bounded_io_1 = require("../project/bounded-io");
39
41
  // @implements A-SPEC-102.1
40
42
  /**
41
43
  * Append-only, spec/code-linked audit trail of review findings. Each call to
@@ -67,7 +69,7 @@ class FindingsLedger {
67
69
  list(filter) {
68
70
  let raw;
69
71
  try {
70
- raw = fs.readFileSync(this.path, 'utf8');
72
+ raw = (0, bounded_io_1.readRegularTextSync)(this.path);
71
73
  }
72
74
  catch (err) {
73
75
  // Missing file: no findings recorded yet, not an error. Any other
@@ -52,6 +52,7 @@ exports.anchoredSourceTexts = anchoredSourceTexts;
52
52
  */
53
53
  const fs = __importStar(require("node:fs"));
54
54
  const path = __importStar(require("node:path"));
55
+ const cpg_scanner_1 = require("../cpg/cpg-scanner");
55
56
  // A bare relative path with an extension and no whitespace — the shape all 22 measured entries had.
56
57
  const LOOKS_LIKE_PATH = /^[\w@./-]+\.[A-Za-z0-9]{1,6}$/;
57
58
  /** Reason precedence: empty → no source at all → found (applicable) → path-shaped → not found. Pure. */
@@ -125,12 +126,16 @@ function anchoredSourceTexts(root, aspecId) {
125
126
  if (SKIP_DIRS.has(e.name) || e.name.startsWith('.'))
126
127
  continue;
127
128
  const p = path.join(d, e.name);
129
+ // @implements A-SPEC-734 (round 10) — nested trees skipped, regular files only (a FIFO hung the seal).
128
130
  if (e.isDirectory()) {
129
- walk(p);
131
+ if (!(0, cpg_scanner_1.isNestedWorkTree)(p, root))
132
+ walk(p);
130
133
  continue;
131
134
  }
132
135
  if (!SOURCE.test(e.name) || /\.test\./.test(e.name))
133
136
  continue;
137
+ if (!(0, cpg_scanner_1.isRegularSource)(e, p, root))
138
+ continue;
134
139
  let text;
135
140
  try {
136
141
  text = fs.readFileSync(p, 'utf8');
@@ -35,13 +35,14 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.materializeTreeAt = materializeTreeAt;
37
37
  exports.verifyTreeFidelity = verifyTreeFidelity;
38
- // @implements A-SPEC-599
38
+ // @implements A-SPEC-599, A-SPEC-734
39
39
  // @implements A-SPEC-297
40
40
  const fs = __importStar(require("node:fs"));
41
41
  const os = __importStar(require("node:os"));
42
42
  const path = __importStar(require("node:path"));
43
43
  const crypto = __importStar(require("node:crypto"));
44
44
  const node_child_process_1 = require("node:child_process");
45
+ const bounded_io_1 = require("../project/bounded-io");
45
46
  /**
46
47
  * A pathspec is ours to control, but a caller mistake here writes outside the destination, so it is
47
48
  * checked rather than trusted: repo-relative, no escape, no absolute root.
@@ -53,7 +54,7 @@ function pathspecIsSafe(pathspec) {
53
54
  return !normalized.startsWith('..') && !normalized.split(path.sep).includes('..');
54
55
  }
55
56
  function git(repoRoot, args) {
56
- return (0, node_child_process_1.execFileSync)('git', ['-C', repoRoot, ...args], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
57
+ return (0, node_child_process_1.execFileSync)('git', ['-C', repoRoot, ...args], { timeout: bounded_io_1.GIT_LONG_TIMEOUT_MS, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
57
58
  }
58
59
  /** `path mode sha` triples the commit records for the pathspec, keyed by repo-relative path. */
59
60
  function blobsAt(repoRoot, commitish, pathspec) {
@@ -119,7 +120,7 @@ function materializeTreeAt(repoRoot, commitish, pathspec, destDir, opts) {
119
120
  // the fidelity check would see a file the commit never had.
120
121
  const tarPath = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'pit-tar-')), 'tree.tar');
121
122
  try {
122
- const tar = (0, node_child_process_1.execFileSync)('git', ['-C', repoRoot, 'archive', '--format=tar', commitish, '--', pathspec], { maxBuffer: 512 * 1024 * 1024 });
123
+ const tar = (0, node_child_process_1.execFileSync)('git', ['-C', repoRoot, 'archive', '--format=tar', commitish, '--', pathspec], { timeout: bounded_io_1.GIT_LONG_TIMEOUT_MS, maxBuffer: 512 * 1024 * 1024 });
123
124
  fs.writeFileSync(tarPath, tar);
124
125
  (0, node_child_process_1.execFileSync)('tar', ['-x', '-C', destDir, '-f', tarPath], { maxBuffer: 512 * 1024 * 1024 });
125
126
  // Archive preserves modes/layout, but applies EOL/export substitutions. Read raw objects in
@@ -129,7 +130,7 @@ function materializeTreeAt(repoRoot, commitish, pathspec, destDir, opts) {
129
130
  const refs = fs.openSync(refsPath, 'r');
130
131
  let raw;
131
132
  try {
132
- raw = (0, node_child_process_1.execFileSync)('git', ['-C', repoRoot, 'cat-file', '--batch'], {
133
+ raw = (0, node_child_process_1.execFileSync)('git', ['-C', repoRoot, 'cat-file', '--batch'], { timeout: bounded_io_1.GIT_LONG_TIMEOUT_MS,
133
134
  stdio: [refs, 'pipe', 'pipe'], maxBuffer: 512 * 1024 * 1024,
134
135
  });
135
136
  }
@@ -38,12 +38,13 @@ exports.changedParentLines = changedParentLines;
38
38
  exports.casesFor = casesFor;
39
39
  exports.thinSpecs = thinSpecs;
40
40
  exports.casesAvoidingRecent = casesAvoidingRecent;
41
- // @implements A-SPEC-345
41
+ // @implements A-SPEC-345, A-SPEC-734
42
42
  // @implements A-SPEC-387
43
43
  const os = __importStar(require("node:os"));
44
44
  const path = __importStar(require("node:path"));
45
45
  const node_child_process_1 = require("node:child_process");
46
46
  const maintenance_analyze_1 = require("../mcp/maintenance-analyze");
47
+ const bounded_io_1 = require("../project/bounded-io");
47
48
  const TS_FAMILY = (f) => f.endsWith('.ts') && !f.endsWith('.d.ts');
48
49
  // @implements A-SPEC-573.3
49
50
  /**
@@ -59,7 +60,7 @@ const TS_FAMILY = (f) => f.endsWith('.ts') && !f.endsWith('.d.ts');
59
60
  function changedParentLines(root, commit, file) {
60
61
  let raw;
61
62
  try {
62
- raw = (0, node_child_process_1.execFileSync)('git', ['-C', root, 'show', '--unified=0', '--format=', commit, '--', file], { encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 });
63
+ raw = (0, node_child_process_1.execFileSync)('git', ['-C', root, 'show', '--unified=0', '--format=', commit, '--', file], { timeout: bounded_io_1.GIT_LONG_TIMEOUT_MS, encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 });
63
64
  }
64
65
  catch {
65
66
  return [];
@@ -151,7 +152,7 @@ function casesFor(corpus, limit, offset = 0) {
151
152
  // proved present FIRST; only after that does a pin failure become an error.
152
153
  const here = (() => {
153
154
  try {
154
- (0, node_child_process_1.execFileSync)('git', ['-C', corpus.root, 'rev-parse', '--git-dir'], { encoding: 'utf8', stdio: 'pipe' });
155
+ (0, node_child_process_1.execFileSync)('git', ['-C', corpus.root, 'rev-parse', '--git-dir'], { timeout: bounded_io_1.GIT_LONG_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, encoding: 'utf8', stdio: 'pipe' });
155
156
  return true;
156
157
  }
157
158
  catch {
@@ -164,7 +165,7 @@ function casesFor(corpus, limit, offset = 0) {
164
165
  let raw;
165
166
  try {
166
167
  raw = (0, node_child_process_1.execFileSync)('git', ['-C', corpus.root, 'log', from, '--no-merges', '--format=%H\x1f%s',
167
- '--name-only', '--', ...corpus.sourcePathspec], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
168
+ '--name-only', '--', ...corpus.sourcePathspec], { timeout: bounded_io_1.GIT_LONG_TIMEOUT_MS, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
168
169
  }
169
170
  catch (e) {
170
171
  // The repository is here, so this is a configuration error, not a missing corpus.
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.uncitedDiffs = uncitedDiffs;
37
37
  exports.runReplay = runReplay;
38
38
  exports.semanticCaseRanking = semanticCaseRanking;
39
- // @implements A-SPEC-346
39
+ // @implements A-SPEC-346, A-SPEC-734
40
40
  // @implements A-SPEC-347
41
41
  // @implements A-SPEC-348
42
42
  // @implements A-SPEC-349
@@ -82,6 +82,7 @@ const dense_retrieval_1 = require("./dense-retrieval");
82
82
  const explore_1 = require("../assoc/explore");
83
83
  const temporal_prior_1 = require("./temporal-prior");
84
84
  const commit_text_1 = require("./commit-text");
85
+ const bounded_io_1 = require("../project/bounded-io");
85
86
  /**
86
87
  * @implements A-SPEC-578.7
87
88
  * The paired differences on the UNCITED axis, ready for `pairedPower`.
@@ -374,7 +375,7 @@ async function runReplay(corpus, limit, opts = {}) {
374
375
  const { buildJudgementBundle } = require('./judgement-bundle');
375
376
  const gitQ = (args) => {
376
377
  try {
377
- return (0, node_child_process_1.execFileSync)('git', ['-C', corpus.root, ...args], { encoding: 'utf8', stdio: 'pipe' });
378
+ return (0, node_child_process_1.execFileSync)('git', ['-C', corpus.root, ...args], { timeout: bounded_io_1.GIT_LONG_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, encoding: 'utf8', stdio: 'pipe' });
378
379
  }
379
380
  catch {
380
381
  return '';
@@ -2,13 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.temporalPrior = temporalPrior;
4
4
  exports.priorFor = priorFor;
5
- // @implements A-SPEC-377
5
+ // @implements A-SPEC-377, A-SPEC-734
6
6
  const node_child_process_1 = require("node:child_process");
7
7
  const maintenance_analyze_1 = require("../mcp/maintenance-analyze");
8
+ const bounded_io_1 = require("../project/bounded-io");
8
9
  function temporalPrior(root, before, limit = 200) {
9
10
  let raw;
10
11
  try {
11
- raw = (0, node_child_process_1.execFileSync)('git', ['-C', root, 'log', '--no-merges', `-${limit}`, '--format=%H', '--name-only', before], { encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
12
+ raw = (0, node_child_process_1.execFileSync)('git', ['-C', root, 'log', '--no-merges', `-${limit}`, '--format=%H', '--name-only', before], { timeout: bounded_io_1.GIT_TIMEOUT_MS, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
12
13
  }
13
14
  catch {
14
15
  // A repository or revision this machine does not have is unmeasured, not empty.
@@ -38,9 +38,10 @@ exports.computeExecutedByAspec = computeExecutedByAspec;
38
38
  exports.isFresh = isFresh;
39
39
  exports.writeTestEvidence = writeTestEvidence;
40
40
  exports.readTestEvidence = readTestEvidence;
41
- // @implements A-SPEC-102.1
41
+ // @implements A-SPEC-102.1, A-SPEC-734
42
42
  const fs = __importStar(require("node:fs"));
43
43
  const path = __importStar(require("node:path"));
44
+ const bounded_io_1 = require("../project/bounded-io");
44
45
  /** Map per-test-file executed counts onto the A-SPECs those files @implement (pure). */
45
46
  function computeExecutedByAspec(executedByFile, testAnchors) {
46
47
  const out = {};
@@ -68,7 +69,7 @@ function writeTestEvidence(root, ev) {
68
69
  }
69
70
  function readTestEvidence(root) {
70
71
  try {
71
- const ev = JSON.parse(fs.readFileSync(path.join(root, exports.EVIDENCE_FILE), 'utf8'));
72
+ const ev = JSON.parse((0, bounded_io_1.readRegularTextSync)(path.join(root, exports.EVIDENCE_FILE)));
72
73
  return ev && typeof ev.head === 'string' && ev.executedByAspec && typeof ev.executedByAspec === 'object' ? ev : undefined;
73
74
  }
74
75
  catch {
@@ -42,7 +42,7 @@ exports.appendOutcomes = appendOutcomes;
42
42
  exports.readOutcomes = readOutcomes;
43
43
  exports.buildOutcomeRecords = buildOutcomeRecords;
44
44
  exports.groupOutcomesByAspec = groupOutcomesByAspec;
45
- // @implements A-SPEC-724.1, A-SPEC-714
45
+ // @implements A-SPEC-724.1, A-SPEC-714, A-SPEC-734
46
46
  // @implements A-SPEC-534.3, A-SPEC-625
47
47
  // @implements A-SPEC-645
48
48
  const node_crypto_1 = require("node:crypto");
@@ -50,6 +50,7 @@ const execution_context_1 = require("../project/execution-context");
50
50
  const fs = __importStar(require("node:fs"));
51
51
  const path = __importStar(require("node:path"));
52
52
  const replica_id_1 = require("../governance/replica-id");
53
+ const bounded_io_1 = require("../project/bounded-io");
53
54
  exports.OUTCOMES_FILE = path.join('.ax', 'ledger', 'test-outcomes.jsonl');
54
55
  exports.RELEASE_TEST_LANE_FILE = path.join('.ax', 'evidence', 'release-test-lane.json');
55
56
  exports.RELEASE_TEST_LANE_SCHEMA = 'release-test-lane/1';
@@ -195,7 +196,7 @@ function readOutcomes(root) {
195
196
  for (const name of names) {
196
197
  let text;
197
198
  try {
198
- text = fs.readFileSync(path.join(dir, name), 'utf8');
199
+ text = (0, bounded_io_1.readRegularTextSync)(path.join(dir, name));
199
200
  }
200
201
  catch {
201
202
  continue;
@@ -1,4 +1,10 @@
1
1
  import { RegressionTier, TestScope } from '../rtm/test-scope';
2
+ /**
3
+ * @implements A-SPEC-734 (round 13) — every runner child is bounded, and a tool probe is short. One passing jest
4
+ * test that left a `setInterval` open never returned, and the synchronous MCP call wedged the server (measured).
5
+ * A run stopped at the bound is red and says so — never green.
6
+ */
7
+ export declare const RUNNER_TIMEOUT_MS: number;
2
8
  /**
3
9
  * Operational wiring for the intelligent test-scope (target-arch §5): turn a TestScope decision into
4
10
  * an actual test run. The PLAN is pure/deterministic (testable); the EXECUTE half shells out to jest.