@holmes-lab/holmes-kit 0.29.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 (169) hide show
  1. package/CHANGELOG.md +556 -0
  2. package/README.md +15 -5
  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-guidance-history.d.ts +1 -1
  9. package/dist/holmes/cli/agents-guidance-history.js +11 -2
  10. package/dist/holmes/cli/agents-guidance.d.ts +1 -0
  11. package/dist/holmes/cli/agents-guidance.js +11 -8
  12. package/dist/holmes/cli/agents.d.ts +41 -0
  13. package/dist/holmes/cli/agents.js +382 -2
  14. package/dist/holmes/cli/attest.d.ts +2 -0
  15. package/dist/holmes/cli/attest.js +66 -15
  16. package/dist/holmes/cli/ci-gate.js +16 -1
  17. package/dist/holmes/cli/claude-switches.d.ts +95 -0
  18. package/dist/holmes/cli/claude-switches.js +967 -0
  19. package/dist/holmes/cli/codex-hooks.d.ts +77 -0
  20. package/dist/holmes/cli/codex-hooks.js +802 -0
  21. package/dist/holmes/cli/codex-oracle.d.ts +194 -0
  22. package/dist/holmes/cli/codex-oracle.js +1245 -0
  23. package/dist/holmes/cli/codex-toml.d.ts +58 -1
  24. package/dist/holmes/cli/codex-toml.js +456 -40
  25. package/dist/holmes/cli/doctor.d.ts +108 -8
  26. package/dist/holmes/cli/doctor.js +1408 -98
  27. package/dist/holmes/cli/index.js +23 -11
  28. package/dist/holmes/cli/init.d.ts +13 -0
  29. package/dist/holmes/cli/init.js +749 -77
  30. package/dist/holmes/cli/interactive-prompt.js +2 -2
  31. package/dist/holmes/cli/mcp-launcher.d.ts +64 -6
  32. package/dist/holmes/cli/mcp-launcher.js +189 -6
  33. package/dist/holmes/cli/mcp-version.js +13 -2
  34. package/dist/holmes/cli/settings-merge.js +8 -2
  35. package/dist/holmes/cli/upgrade.d.ts +13 -0
  36. package/dist/holmes/cli/upgrade.js +116 -23
  37. package/dist/holmes/cli/workspace-scope.d.ts +22 -0
  38. package/dist/holmes/cli/workspace-scope.js +375 -0
  39. package/dist/holmes/cli/worktree-readiness.d.ts +1 -0
  40. package/dist/holmes/cli/worktree-readiness.js +17 -3
  41. package/dist/holmes/cpg/cpg-scanner.d.ts +29 -0
  42. package/dist/holmes/cpg/cpg-scanner.js +403 -3
  43. package/dist/holmes/cpg/cycle-detect.js +2 -1
  44. package/dist/holmes/cpg/forbidden-edges.js +9 -2
  45. package/dist/holmes/cpg/required-calls.js +8 -1
  46. package/dist/holmes/governance/autonomy.d.ts +9 -0
  47. package/dist/holmes/governance/autonomy.js +28 -1
  48. package/dist/holmes/governance/constitution-debt.js +3 -2
  49. package/dist/holmes/governance/constitution.js +15 -3
  50. package/dist/holmes/governance/provenance-chain.js +3 -2
  51. package/dist/holmes/governance/push-gate-runner.js +4 -3
  52. package/dist/holmes/guardrail/dependency-delta.js +4 -3
  53. package/dist/holmes/guardrail/linear-match.d.ts +57 -0
  54. package/dist/holmes/guardrail/linear-match.js +256 -0
  55. package/dist/holmes/guardrail/risk-classifier.d.ts +6 -7
  56. package/dist/holmes/guardrail/risk-classifier.js +931 -44
  57. package/dist/holmes/guardrail/risk-types.d.ts +6 -0
  58. package/dist/holmes/guardrail/scope-judgment.d.ts +4 -24
  59. package/dist/holmes/guardrail/scope-judgment.js +100 -23
  60. package/dist/holmes/guardrail/shell-words.d.ts +42 -0
  61. package/dist/holmes/guardrail/shell-words.js +1720 -0
  62. package/dist/holmes/guardrail/write-target.d.ts +168 -3
  63. package/dist/holmes/guardrail/write-target.js +2379 -87
  64. package/dist/holmes/hooks/adapters/antigravity.d.ts +3 -1
  65. package/dist/holmes/hooks/adapters/antigravity.js +115 -11
  66. package/dist/holmes/hooks/pre-tool-use.d.ts +32 -6
  67. package/dist/holmes/hooks/pre-tool-use.js +923 -87
  68. package/dist/holmes/hooks/rtm-refresh-child.d.ts +22 -1
  69. package/dist/holmes/hooks/rtm-refresh-child.js +102 -18
  70. package/dist/holmes/hooks/rtm-refresh.d.ts +20 -1
  71. package/dist/holmes/hooks/rtm-refresh.js +60 -15
  72. package/dist/holmes/hooks/session-start.d.ts +10 -0
  73. package/dist/holmes/hooks/session-start.js +31 -7
  74. package/dist/holmes/hooks/stop.d.ts +2 -1
  75. package/dist/holmes/hooks/stop.js +197 -91
  76. package/dist/holmes/mcp/approval-adapters.d.ts +22 -0
  77. package/dist/holmes/mcp/approval-adapters.js +21 -0
  78. package/dist/holmes/mcp/approval-commit.d.ts +20 -0
  79. package/dist/holmes/mcp/approval-commit.js +108 -0
  80. package/dist/holmes/mcp/approval-intent.d.ts +44 -0
  81. package/dist/holmes/mcp/approval-intent.js +67 -0
  82. package/dist/holmes/mcp/approval-policy.d.ts +14 -0
  83. package/dist/holmes/mcp/approval-policy.js +18 -0
  84. package/dist/holmes/mcp/elicit-approval.d.ts +2 -0
  85. package/dist/holmes/mcp/elicit-approval.js +8 -3
  86. package/dist/holmes/mcp/handlers/graph-operations.d.ts +17 -1
  87. package/dist/holmes/mcp/handlers/graph-operations.js +15 -6
  88. package/dist/holmes/mcp/handlers/maintenance-analysis.js +11 -5
  89. package/dist/holmes/mcp/handlers/maintenance-evidence.js +3 -2
  90. package/dist/holmes/mcp/handlers/phase-queries.d.ts +22 -7
  91. package/dist/holmes/mcp/handlers/phase-queries.js +81 -2
  92. package/dist/holmes/mcp/handlers/requirement-triage.d.ts +26 -0
  93. package/dist/holmes/mcp/handlers/requirement-triage.js +48 -11
  94. package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -1
  95. package/dist/holmes/mcp/handlers/review-evidence.js +15 -5
  96. package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +18 -0
  97. package/dist/holmes/mcp/handlers/slice-orchestration.js +122 -16
  98. package/dist/holmes/mcp/handlers/spec-approval.d.ts +35 -2
  99. package/dist/holmes/mcp/handlers/spec-approval.js +175 -57
  100. package/dist/holmes/mcp/handlers/spec-authoring.js +36 -3
  101. package/dist/holmes/mcp/handlers/spec-queries.d.ts +39 -3
  102. package/dist/holmes/mcp/handlers/spec-queries.js +114 -7
  103. package/dist/holmes/mcp/handlers/test-execution.js +9 -3
  104. package/dist/holmes/mcp/handlers.d.ts +126 -8
  105. package/dist/holmes/mcp/handlers.js +109 -18
  106. package/dist/holmes/mcp/harness-attestation.d.ts +20 -0
  107. package/dist/holmes/mcp/harness-attestation.js +179 -0
  108. package/dist/holmes/mcp/maintenance-analyze.js +28 -4
  109. package/dist/holmes/mcp/maintenance-evidence.js +1 -1
  110. package/dist/holmes/mcp/requirement-triage-evidence.d.ts +72 -2
  111. package/dist/holmes/mcp/requirement-triage-evidence.js +227 -1
  112. package/dist/holmes/mcp/server.js +24 -3
  113. package/dist/holmes/mcp/supervisor.js +7 -3
  114. package/dist/holmes/mcp/tool-schemas.d.ts +8 -0
  115. package/dist/holmes/mcp/tool-schemas.js +54 -7
  116. package/dist/holmes/mcp/validate-args.js +12 -0
  117. package/dist/holmes/project/bounded-io.d.ts +102 -0
  118. package/dist/holmes/project/bounded-io.js +212 -0
  119. package/dist/holmes/project/change-source.js +3 -1
  120. package/dist/holmes/project/ci-runs.js +3 -2
  121. package/dist/holmes/project/ignore.d.ts +31 -2
  122. package/dist/holmes/project/ignore.js +409 -50
  123. package/dist/holmes/project/regular-file-guard.d.ts +13 -0
  124. package/dist/holmes/project/regular-file-guard.js +149 -0
  125. package/dist/holmes/project/root.js +12 -3
  126. package/dist/holmes/refresh/freshness-coordinator.d.ts +67 -0
  127. package/dist/holmes/refresh/freshness-coordinator.js +230 -0
  128. package/dist/holmes/reverse/anchor.js +4 -3
  129. package/dist/holmes/reverse/scan.js +6 -2
  130. package/dist/holmes/review/commit-text.js +3 -2
  131. package/dist/holmes/review/condition-hunk-replay.d.ts +12 -0
  132. package/dist/holmes/review/condition-hunk-replay.js +13 -2
  133. package/dist/holmes/review/condition-hunk-resolution.js +59 -8
  134. package/dist/holmes/review/failed-test-names.js +13 -10
  135. package/dist/holmes/review/findings.js +3 -1
  136. package/dist/holmes/review/kills-check.js +6 -1
  137. package/dist/holmes/review/point-in-time-replay.js +5 -4
  138. package/dist/holmes/review/replay-corpus.js +5 -4
  139. package/dist/holmes/review/requirement-triage-human-records.d.ts +59 -0
  140. package/dist/holmes/review/requirement-triage-human-records.js +119 -0
  141. package/dist/holmes/review/run-replay.js +3 -2
  142. package/dist/holmes/review/scope.js +6 -1
  143. package/dist/holmes/review/temporal-prior.js +3 -2
  144. package/dist/holmes/review/test-evidence.js +3 -2
  145. package/dist/holmes/review/test-outcomes.d.ts +28 -0
  146. package/dist/holmes/review/test-outcomes.js +92 -2
  147. package/dist/holmes/review/test-runner.d.ts +6 -0
  148. package/dist/holmes/review/test-runner.js +36 -15
  149. package/dist/holmes/rtm/advisory-outcomes.js +3 -2
  150. package/dist/holmes/rtm/anchor-ids.js +42 -2
  151. package/dist/holmes/rtm/file-anchors.js +4 -1
  152. package/dist/holmes/rtm/ftt-fulfilment.js +8 -3
  153. package/dist/holmes/rtm/git-changes.js +3 -1
  154. package/dist/holmes/rtm/graph-store.js +3 -2
  155. package/dist/holmes/rtm/test-scope.js +9 -4
  156. package/dist/holmes/spec/compat-impact.d.ts +25 -4
  157. package/dist/holmes/spec/compat-impact.js +682 -11
  158. package/dist/holmes/spec/entity-git-snapshot.js +3 -2
  159. package/dist/holmes/spec/entity-integration.js +3 -2
  160. package/dist/holmes/spec/entity-renumber-transaction.d.ts +19 -0
  161. package/dist/holmes/spec/entity-renumber-transaction.js +79 -6
  162. package/dist/holmes/spec/remote-spec-refs.js +3 -2
  163. package/dist/holmes/spec/renumber.js +25 -10
  164. package/dist/holmes/spec/spec-parser.js +9 -3
  165. package/dist/holmes/spec/yaml-scalar.js +2 -2
  166. package/dist/holmes/update/refresh.js +3 -1
  167. package/dist/holmes/update/update-notice.d.ts +6 -0
  168. package/dist/holmes/update/update-notice.js +18 -1
  169. package/package.json +11 -4
@@ -33,20 +33,110 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.OUTCOMES_FILE = void 0;
36
+ exports.RELEASE_TEST_LANE_SCHEMA = exports.RELEASE_TEST_LANE_FILE = exports.OUTCOMES_FILE = void 0;
37
+ exports.writeReleaseTestLaneReceipt = writeReleaseTestLaneReceipt;
38
+ exports.validateReleaseTestLaneReceipt = validateReleaseTestLaneReceipt;
37
39
  exports.outcomesFilename = outcomesFilename;
38
40
  exports.isOutcomesFilename = isOutcomesFilename;
39
41
  exports.appendOutcomes = appendOutcomes;
40
42
  exports.readOutcomes = readOutcomes;
41
43
  exports.buildOutcomeRecords = buildOutcomeRecords;
42
44
  exports.groupOutcomesByAspec = groupOutcomesByAspec;
45
+ // @implements A-SPEC-724.1, A-SPEC-714, A-SPEC-734
43
46
  // @implements A-SPEC-534.3, A-SPEC-625
44
47
  // @implements A-SPEC-645
48
+ const node_crypto_1 = require("node:crypto");
45
49
  const execution_context_1 = require("../project/execution-context");
46
50
  const fs = __importStar(require("node:fs"));
47
51
  const path = __importStar(require("node:path"));
48
52
  const replica_id_1 = require("../governance/replica-id");
53
+ const bounded_io_1 = require("../project/bounded-io");
49
54
  exports.OUTCOMES_FILE = path.join('.ax', 'ledger', 'test-outcomes.jsonl');
55
+ exports.RELEASE_TEST_LANE_FILE = path.join('.ax', 'evidence', 'release-test-lane.json');
56
+ exports.RELEASE_TEST_LANE_SCHEMA = 'release-test-lane/1';
57
+ const RELEASE_TEST_LANE_MAX_AGE_MS = 24 * 60 * 60 * 1000;
58
+ const stableReceipt = (receipt) => JSON.stringify({
59
+ schema: receipt.schema, root: receipt.root, head: receipt.head, completedAt: receipt.completedAt,
60
+ passed: receipt.passed, externalAccess: receipt.externalAccess, command: receipt.command,
61
+ include: receipt.include, exclusions: receipt.exclusions,
62
+ });
63
+ const releaseReceiptDigest = (receipt) => `sha256:${(0, node_crypto_1.createHash)('sha256').update(stableReceipt(receipt)).digest('hex')}`;
64
+ /** Persist only evidence whose scope is explicit and bounded; callers cannot choose its path. */
65
+ function writeReleaseTestLaneReceipt(root, input) {
66
+ // The writer owns the current schema; only persisted input is required to
67
+ // state it explicitly so an older or unknown schema cannot be reinterpreted.
68
+ const receipt = normalizeReleaseTestLaneReceipt(root, { ...input, schema: exports.RELEASE_TEST_LANE_SCHEMA });
69
+ if (receipt === null)
70
+ return null;
71
+ const file = path.join(path.resolve(root), exports.RELEASE_TEST_LANE_FILE);
72
+ const tmp = `${file}.${process.pid}.${Date.now()}.tmp`;
73
+ try {
74
+ fs.mkdirSync(path.dirname(file), { recursive: true });
75
+ fs.writeFileSync(tmp, `${JSON.stringify(receipt)}\n`, { encoding: 'utf8', mode: 0o600 });
76
+ fs.renameSync(tmp, file);
77
+ return receipt;
78
+ }
79
+ catch {
80
+ try {
81
+ fs.unlinkSync(tmp);
82
+ }
83
+ catch { /* no partial receipt is valid */ }
84
+ return null;
85
+ }
86
+ }
87
+ /** Read the sole project-local receipt and fail closed for every missing or unprovable condition. */
88
+ function validateReleaseTestLaneReceipt(root, head, now = Date.now()) {
89
+ const expectedRoot = path.resolve(root);
90
+ if (typeof head !== 'string' || head === '' || head.includes('/') || head.includes('\\'))
91
+ return { valid: false, reason: 'invalid current HEAD' };
92
+ let parsed;
93
+ try {
94
+ parsed = JSON.parse(fs.readFileSync(path.join(expectedRoot, exports.RELEASE_TEST_LANE_FILE), 'utf8'));
95
+ }
96
+ catch {
97
+ return { valid: false, reason: 'release test-lane receipt is absent or malformed' };
98
+ }
99
+ const receipt = normalizeReleaseTestLaneReceipt(expectedRoot, parsed);
100
+ if (receipt === null)
101
+ return { valid: false, reason: 'release test-lane receipt omits required bounded scope or policy' };
102
+ if (receipt.digest !== parsed.digest)
103
+ return { valid: false, reason: 'release test-lane receipt digest is invalid' };
104
+ if (receipt.root !== expectedRoot)
105
+ return { valid: false, reason: 'release test-lane receipt belongs to a different root' };
106
+ if (receipt.head !== head)
107
+ return { valid: false, reason: 'release test-lane receipt HEAD does not match' };
108
+ const completedMs = Date.parse(receipt.completedAt);
109
+ if (!Number.isFinite(completedMs) || completedMs > now || now - completedMs > RELEASE_TEST_LANE_MAX_AGE_MS) {
110
+ return { valid: false, reason: 'release test-lane receipt is stale or has an invalid timestamp' };
111
+ }
112
+ return { valid: true, receipt };
113
+ }
114
+ function normalizeReleaseTestLaneReceipt(root, input) {
115
+ if (!input || typeof input !== 'object')
116
+ return null;
117
+ const value = input;
118
+ const rootPath = path.resolve(root);
119
+ if (value.schema !== exports.RELEASE_TEST_LANE_SCHEMA
120
+ || typeof value.root !== 'string' || path.resolve(value.root) !== rootPath || value.root !== rootPath
121
+ || typeof value.head !== 'string' || value.head === '' || /[\\/]/.test(value.head)
122
+ || typeof value.completedAt !== 'string' || !Number.isFinite(Date.parse(value.completedAt))
123
+ || value.passed !== true || value.externalAccess !== 'forbidden')
124
+ return null;
125
+ if (!Array.isArray(value.command) || value.command.some((part) => typeof part !== 'string' || part === '')
126
+ || value.command.length < 5 || value.command[0] !== 'npm' || value.command[1] !== 'test'
127
+ || value.command[2] !== '--' || !value.command.includes('--runInBand')
128
+ || !value.command.some((part) => part.startsWith('--testPathIgnorePatterns=')))
129
+ return null;
130
+ if (!Array.isArray(value.include) || value.include.length === 0 || value.include.some((part) => typeof part !== 'string' || part.trim() === ''))
131
+ return null;
132
+ if (!Array.isArray(value.exclusions) || value.exclusions.length === 0 || value.exclusions.some((entry) => !entry || typeof entry.pattern !== 'string'
133
+ || entry.pattern.trim() === '' || entry.pattern.includes('..') || typeof entry.reason !== 'string' || entry.reason.trim() === ''))
134
+ return null;
135
+ const unsigned = { schema: exports.RELEASE_TEST_LANE_SCHEMA, root: rootPath, head: value.head, completedAt: value.completedAt,
136
+ passed: true, externalAccess: 'forbidden', command: [...value.command], include: [...value.include],
137
+ exclusions: value.exclusions.map((entry) => ({ pattern: entry.pattern, reason: entry.reason })) };
138
+ return { ...unsigned, digest: releaseReceiptDigest(unsigned) };
139
+ }
50
140
  // @implements A-SPEC-562.1 — outcomes join the ledger's REPLICA convention (A-SPEC-148): one file per
51
141
  // machine, so two machines appending never conflict on merge and a colleague's clone carries both
52
142
  // histories. The shape mirrors `isLedgerFilename` exactly — legacy single file OR a dot-free segment —
@@ -106,7 +196,7 @@ function readOutcomes(root) {
106
196
  for (const name of names) {
107
197
  let text;
108
198
  try {
109
- text = fs.readFileSync(path.join(dir, name), 'utf8');
199
+ text = (0, bounded_io_1.readRegularTextSync)(path.join(dir, name));
110
200
  }
111
201
  catch {
112
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.
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.TAIL_MAX_CHARS = void 0;
36
+ exports.TAIL_MAX_CHARS = exports.RUNNER_TIMEOUT_MS = void 0;
37
37
  exports.planTestRun = planTestRun;
38
38
  exports.ecosystemOf = ecosystemOf;
39
39
  exports.parseGoTestJson = parseGoTestJson;
@@ -56,6 +56,7 @@ exports.failedTestSummary = failedTestSummary;
56
56
  exports.summarizeJestJson = summarizeJestJson;
57
57
  // @implements A-SPEC-102.1
58
58
  // @implements A-SPEC-647
59
+ // @implements A-SPEC-734
59
60
  const node_child_process_1 = require("node:child_process");
60
61
  const fs = __importStar(require("node:fs"));
61
62
  const os = __importStar(require("node:os"));
@@ -70,6 +71,25 @@ const python_env_1 = require("./python-env");
70
71
  // recorded and the push gate could never be satisfied). Every runner spawn shares this ceiling:
71
72
  // evidence-bearing output must never be truncated into a false red.
72
73
  const RUNNER_MAX_BUFFER = 256 * 1024 * 1024;
74
+ /**
75
+ * @implements A-SPEC-734 (round 13) — every runner child is bounded, and a tool probe is short. One passing jest
76
+ * test that left a `setInterval` open never returned, and the synchronous MCP call wedged the server (measured).
77
+ * A run stopped at the bound is red and says so — never green.
78
+ */
79
+ exports.RUNNER_TIMEOUT_MS = 30 * 60_000;
80
+ const PROBE_TIMEOUT_MS = 10_000;
81
+ /** Round 14: the stop is recorded here and appended AFTER the runner's tail is taken (`tailOf` cut it — measured). */
82
+ let STOPPED = null;
83
+ function runBounded(cmd, args, opts) {
84
+ try {
85
+ return (0, node_child_process_1.execFileSync)(cmd, args, { ...opts, timeout: exports.RUNNER_TIMEOUT_MS, killSignal: 'SIGKILL' });
86
+ }
87
+ catch (e) {
88
+ if (e.code === 'ETIMEDOUT')
89
+ STOPPED = `[holmes-kit] the test run was stopped after ${exports.RUNNER_TIMEOUT_MS / 60_000} minutes — not judged`;
90
+ throw e;
91
+ }
92
+ }
73
93
  function planTestRun(scope) {
74
94
  if (scope.tier === 'full') {
75
95
  return { mode: 'full', testFiles: [], reason: 'full regression — run the entire suite' };
@@ -296,10 +316,10 @@ function runJest(files, mode, cwd) {
296
316
  const entry = jestEntry(cwd);
297
317
  const [cmd, ...pre] = entry !== null ? [process.execPath, entry] : ['npx', 'jest'];
298
318
  const args = mode === 'scoped'
299
- ? [...pre, '--silent', '--json', '--runTestsByPath', '--', ...safeFiles]
300
- : [...pre, '--silent', '--json'];
319
+ ? [...pre, '--silent', '--json', '--forceExit', '--runTestsByPath', '--', ...safeFiles]
320
+ : [...pre, '--silent', '--json', '--forceExit']; // round 13: an open handle after the last test must not hold the run
301
321
  try {
302
- const out = (0, node_child_process_1.execFileSync)(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
322
+ const out = runBounded(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
303
323
  // @implements A-SPEC-515.1 — the green path says what happened instead of handing back the
304
324
  // whole `--json` document. `tailOf` wraps the result too, so an unexpectedly long summary is
305
325
  // still bounded: a cap that any one path can escape is not a cap.
@@ -478,7 +498,7 @@ function runPytest(files, mode, cwd) {
478
498
  // @implements A-SPEC-651.1 — launch from the canonical spelling: pytest keys its JUnit `file`
479
499
  // attribute relative to its rootdir, and an 8.3 invocation dir made that key climb out of the
480
500
  // project (`../../…/tests/test_calc.py`, measured 2026-09-14 on Windows).
481
- const out = (0, node_child_process_1.execFileSync)(python, args, { cwd: fs.existsSync(cwd) ? (0, root_1.canonicalPath)(cwd) : cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
501
+ const out = runBounded(python, args, { cwd: fs.existsSync(cwd) ? (0, root_1.canonicalPath)(cwd) : cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
482
502
  return { passed: true, tail: tailOf(out), executed: read(), outcomes: readOutcomes(true) };
483
503
  }
484
504
  catch (e) {
@@ -520,7 +540,7 @@ function parseCargoTest(out) {
520
540
  function runCargo(files, _mode, cwd, opts) {
521
541
  const present = opts?.cargoPresent ?? (() => {
522
542
  try {
523
- (0, node_child_process_1.execFileSync)('cargo', ['--version'], { cwd, stdio: 'ignore' });
543
+ (0, node_child_process_1.execFileSync)('cargo', ['--version'], { cwd, stdio: 'ignore', timeout: PROBE_TIMEOUT_MS });
524
544
  return true;
525
545
  }
526
546
  catch {
@@ -533,7 +553,7 @@ function runCargo(files, _mode, cwd, opts) {
533
553
  let out = '';
534
554
  let ok = true;
535
555
  try {
536
- out = (0, node_child_process_1.execFileSync)('cargo', ['test'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
556
+ out = runBounded('cargo', ['test'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
537
557
  }
538
558
  catch (e) {
539
559
  const err = e;
@@ -586,7 +606,7 @@ function readJUnitReports(dir, ext) {
586
606
  function runGradle(files, _mode, cwd, opts) {
587
607
  const present = opts?.javaPresent ?? (() => {
588
608
  try {
589
- (0, node_child_process_1.execFileSync)('java', ['-version'], { cwd, stdio: 'ignore' });
609
+ (0, node_child_process_1.execFileSync)('java', ['-version'], { cwd, stdio: 'ignore', timeout: PROBE_TIMEOUT_MS });
590
610
  return true;
591
611
  }
592
612
  catch {
@@ -626,7 +646,7 @@ function runGradle(files, _mode, cwd, opts) {
626
646
  }
627
647
  let ok = true;
628
648
  try {
629
- (0, node_child_process_1.execFileSync)(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
649
+ runBounded(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
630
650
  }
631
651
  catch {
632
652
  ok = false;
@@ -644,7 +664,7 @@ function runGradle(files, _mode, cwd, opts) {
644
664
  function runDotnet(files, _mode, cwd, opts) {
645
665
  const present = opts?.dotnetPresent ?? (() => {
646
666
  try {
647
- (0, node_child_process_1.execFileSync)('dotnet', ['--version'], { cwd, stdio: 'ignore' });
667
+ (0, node_child_process_1.execFileSync)('dotnet', ['--version'], { cwd, stdio: 'ignore', timeout: PROBE_TIMEOUT_MS });
648
668
  return true;
649
669
  }
650
670
  catch {
@@ -658,7 +678,7 @@ function runDotnet(files, _mode, cwd, opts) {
658
678
  const report = path.join(dir, 'junit.xml');
659
679
  let ok = true;
660
680
  try {
661
- (0, node_child_process_1.execFileSync)('dotnet', ['test', '--logger', `junit;LogFilePath=${report}`], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
681
+ runBounded('dotnet', ['test', '--logger', `junit;LogFilePath=${report}`], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
662
682
  }
663
683
  catch {
664
684
  ok = false;
@@ -685,7 +705,7 @@ function runDotnet(files, _mode, cwd, opts) {
685
705
  function runGo(files, mode, cwd, opts) {
686
706
  const present = opts?.goPresent ?? (() => {
687
707
  try {
688
- (0, node_child_process_1.execFileSync)('go', ['version'], { cwd, stdio: 'ignore' });
708
+ (0, node_child_process_1.execFileSync)('go', ['version'], { cwd, stdio: 'ignore', timeout: PROBE_TIMEOUT_MS });
689
709
  return true;
690
710
  }
691
711
  catch {
@@ -705,7 +725,7 @@ function runGo(files, mode, cwd, opts) {
705
725
  const runDir = (dirArg, creditFiles) => {
706
726
  let out = '';
707
727
  try {
708
- out = (0, node_child_process_1.execFileSync)('go', ['test', '-json', dirArg], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
728
+ out = runBounded('go', ['test', '-json', dirArg], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: RUNNER_MAX_BUFFER, env: (0, root_1.cleanTestEnv)() });
709
729
  }
710
730
  catch (e) {
711
731
  const err = e;
@@ -792,10 +812,11 @@ function runTestScope(scope, cwd) {
792
812
  const executedByFile = {};
793
813
  const outcomeByFile = {}; // @implements A-SPEC-534.5 — jest only
794
814
  for (const eco of [...groups.keys()].sort()) {
815
+ STOPPED = null;
795
816
  const r = runners[eco](groups.get(eco), plan.mode, cwd);
796
817
  ran.push(eco);
797
- passed = passed && r.passed;
798
- tails.push(`[${eco}] ${r.tail}`);
818
+ passed = passed && r.passed && STOPPED === null;
819
+ tails.push(`[${eco}] ${r.tail}${STOPPED !== null ? `\n${STOPPED}` : ''}`);
799
820
  Object.assign(executedByFile, r.executed);
800
821
  const adapterOutcomes = r.outcomes;
801
822
  if (adapterOutcomes)
@@ -48,7 +48,7 @@ exports.recordAdvisoryOutcomes = recordAdvisoryOutcomes;
48
48
  exports.traceGapFiles = traceGapFiles;
49
49
  exports.gitHeadOf = gitHeadOf;
50
50
  exports.traceGapFor = traceGapFor;
51
- // @implements A-SPEC-663
51
+ // @implements A-SPEC-663, A-SPEC-734
52
52
  /**
53
53
  * The advisory REACTION ledger — the numerator every promotion decision has been missing.
54
54
  *
@@ -69,6 +69,7 @@ const path = __importStar(require("node:path"));
69
69
  const replica_id_1 = require("../governance/replica-id");
70
70
  const ftt_fulfilment_1 = require("./ftt-fulfilment");
71
71
  const trace_gaps_1 = require("./trace-gaps");
72
+ const bounded_io_1 = require("../project/bounded-io");
72
73
  /** Canonical JSON: sorted keys, arrays kept in order — the same payload always gives the same id. */
73
74
  function canonical(value) {
74
75
  if (Array.isArray(value))
@@ -294,7 +295,7 @@ function traceGapFiles(spec, scanned, root = '') {
294
295
  /** The commit a reaction row is judged at; 'nogit' when git cannot say. Never throws. */
295
296
  function gitHeadOf(root) {
296
297
  try {
297
- return (0, node_child_process_1.execFileSync)('git', ['rev-parse', 'HEAD'], { cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || 'nogit';
298
+ return (0, node_child_process_1.execFileSync)('git', ['rev-parse', 'HEAD'], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, cwd: root, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || 'nogit';
298
299
  }
299
300
  catch {
300
301
  return 'nogit';
@@ -19,9 +19,49 @@ exports.wrongKindAnchorIds = wrongKindAnchorIds;
19
19
  // fixture string was refused twice as an "unapproved claim" — and that friction bred the
20
20
  // '@'+'implements' evasion habit. A string-anchor is an anchor to nobody and must be a claim to
21
21
  // nobody; one definition here keeps the two judgments from drifting apart again.
22
- const STRINGS_RE = /'(?:\\.|[^'\\\n])*'|"(?:\\.|[^"\\\n])*"|`(?:\\.|[^`\\])*`/g;
22
+ //
23
+ // @implements A-SPEC-728 (rule 42) — the same result as `text.replace(/'(?:\\.|[^'\\\n])*'|"(?:\\.|[^"\\\n])*"|`(?:\\.|[^`\\])*`/g,
24
+ // '""')`, in linear time: the regex restarted at every quote, and 48 KB of `\"` in a code Write took 3.5 s (256 KB met the
25
+ // hook's 20 s wall — measured). A scan from a quote is deterministic; when its literal is unterminated it fails at a fixed
26
+ // place, and every later quote of the same kind before that place is an escaped character of that scan, so it fails there
27
+ // too. `.` in the regex does not match a line terminator; a quote or double-quote body also ends at `\n`.
23
28
  function stripStringLiterals(text) {
24
- return text.replace(STRINGS_RE, '""');
29
+ const lineEnd = (c) => c === '\n' || c === '\r' || c === '\u2028' || c === '\u2029';
30
+ const failUntil = { "'": -1, '"': -1, '`': -1 };
31
+ let out = '';
32
+ let last = 0;
33
+ for (let p = 0; p < text.length; p++) {
34
+ const q = text[p];
35
+ if ((q !== "'" && q !== '"' && q !== '`') || p < failUntil[q])
36
+ continue;
37
+ let j = p + 1;
38
+ let end = -1;
39
+ while (j < text.length) {
40
+ const c = text[j];
41
+ if (c === q) {
42
+ end = j;
43
+ break;
44
+ }
45
+ if (c === '\\') {
46
+ if (j + 1 < text.length && !lineEnd(text[j + 1])) {
47
+ j += 2;
48
+ continue;
49
+ }
50
+ break;
51
+ }
52
+ if (c === '\n' && q !== '`')
53
+ break;
54
+ j++;
55
+ }
56
+ if (end < 0) {
57
+ failUntil[q] = j;
58
+ continue;
59
+ }
60
+ out += `${text.slice(last, p)}""`;
61
+ last = end + 1;
62
+ p = end;
63
+ }
64
+ return out + text.slice(last);
25
65
  }
26
66
  const ID = String.raw `(?:REQ|A-SPEC|H-SPEC|C-SPEC|T-SPEC)-\d{3,}(?:\.\d+)?`;
27
67
  const LIST_RE = new RegExp(String.raw `@implements[ \t]+(${ID}(?:[ \t]*,[ \t]*${ID})*)`, 'g');
@@ -102,8 +102,11 @@ function scanFileAnchors(root) {
102
102
  if (SKIP_DIRS.has(e.name))
103
103
  continue;
104
104
  const abs = path.join(dir, e.name);
105
+ // @implements A-SPEC-734 (round 9) — a nested working tree is another repository (measured: 44 agent
106
+ // worktrees' scripts read into the link census, 28,160 foreign files, 1.4 s against 96 ms).
105
107
  if (e.isDirectory()) {
106
- walk(abs);
108
+ if (!(0, cpg_scanner_1.isNestedWorkTree)(abs, root))
109
+ walk(abs);
107
110
  continue;
108
111
  }
109
112
  if (!e.isFile())
@@ -38,7 +38,7 @@ exports.fttFulfilment = fttFulfilment;
38
38
  exports.locateByBasename = locateByBasename;
39
39
  exports.appendFttFulfilment = appendFttFulfilment;
40
40
  exports.readFttFulfilments = readFttFulfilments;
41
- // @implements A-SPEC-656
41
+ // @implements A-SPEC-733, A-SPEC-734, A-SPEC-656
42
42
  /**
43
43
  * Files-to-Touch fulfilment — the paths a sealed A-SPEC promised and never made.
44
44
  *
@@ -56,7 +56,9 @@ exports.readFttFulfilments = readFttFulfilments;
56
56
  const fs = __importStar(require("node:fs"));
57
57
  const path = __importStar(require("node:path"));
58
58
  const scope_judgment_1 = require("../guardrail/scope-judgment");
59
+ const linear_match_1 = require("../guardrail/linear-match");
59
60
  const replica_id_1 = require("../governance/replica-id");
61
+ const cpg_scanner_1 = require("../cpg/cpg-scanner");
60
62
  const NEW_RE = /\((신규|new)\)/i;
61
63
  const ALT_RE = /또는|\bor\b/;
62
64
  const SLASHED = /^[\w@.-]+(?:\/[\w@.-]+)+$/;
@@ -96,7 +98,7 @@ function fttItems(fttText) {
96
98
  const pieces = line.split(TOKEN_SPLIT).filter((w) => w !== '');
97
99
  for (let i = 0; i < pieces.length; i += 1) {
98
100
  // Trailing sentence punctuation is not part of a path; a leading `./` is not part of its identity.
99
- const token = pieces[i].replace(/^\.\//, '').replace(/[.,;:]+$/, '');
101
+ const token = (0, linear_match_1.trimTrailing)(pieces[i].replace(/^\.\//, ''), '.,;:');
100
102
  if (!token || token.includes('*') || !HAS_EXT.test(token))
101
103
  continue;
102
104
  // A SLASHED path is admitted wherever it sits — that is the whole point of REQ-670, and a
@@ -169,8 +171,11 @@ function locateByBasename(root) {
169
171
  if (SKIP_DIRS.has(e.name))
170
172
  continue;
171
173
  const abs = path.join(dir, e.name);
174
+ // @implements A-SPEC-734 — another repository's working tree (a reviewer worktree) proposed its
175
+ // copies as `moved` locations (measured).
172
176
  if (e.isDirectory()) {
173
- walk(abs);
177
+ if (!(0, cpg_scanner_1.isNestedWorkTree)(abs, root))
178
+ walk(abs);
174
179
  continue;
175
180
  }
176
181
  if (!e.isFile())
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseNameStatus = parseNameStatus;
4
4
  exports.assertSafeRev = assertSafeRev;
5
5
  exports.gitChangedFiles = gitChangedFiles;
6
+ // @implements A-SPEC-734
6
7
  const node_child_process_1 = require("node:child_process");
8
+ const bounded_io_1 = require("../project/bounded-io");
7
9
  // @implements A-SPEC-113.1
8
10
  /**
9
11
  * Pure parser for `git diff --name-status` output. Paths are already
@@ -67,6 +69,6 @@ function assertSafeRev(v) {
67
69
  function gitChangedFiles(repoRoot, base, head) {
68
70
  assertSafeRev(base);
69
71
  assertSafeRev(head);
70
- const raw = (0, node_child_process_1.execFileSync)('git', ['-C', repoRoot, 'diff', '--name-status', '--end-of-options', base, head], { encoding: 'utf8' });
72
+ const raw = (0, node_child_process_1.execFileSync)('git', ['-C', repoRoot, 'diff', '--name-status', '--end-of-options', base, head], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, encoding: 'utf8' });
71
73
  return parseNameStatus(raw);
72
74
  }
@@ -40,13 +40,14 @@ exports.openReusableGraph = openReusableGraph;
40
40
  exports.publishGraph = publishGraph;
41
41
  exports.openPublishedGraph = openPublishedGraph;
42
42
  exports.headCommitOf = headCommitOf;
43
- // @implements A-SPEC-282
43
+ // @implements A-SPEC-282, A-SPEC-734
44
44
  // @implements A-SPEC-631
45
45
  const fs = __importStar(require("node:fs"));
46
46
  const path = __importStar(require("node:path"));
47
47
  const node_crypto_1 = require("node:crypto");
48
48
  const node_child_process_1 = require("node:child_process");
49
49
  const rtm_graph_1 = require("./rtm-graph");
50
+ const bounded_io_1 = require("../project/bounded-io");
50
51
  const BASIS_FIELDS = [
51
52
  'graphSchema', 'extractorVersion', 'sourceCommit', 'specFingerprint', 'scanDigest',
52
53
  ];
@@ -368,7 +369,7 @@ function openPublishable(livePath, expected) {
368
369
  /** HEAD of the repository at `root`, or null outside Git — the only freshness input a consumer pays for (no scan). */
369
370
  function headCommitOf(root, env = process.env) {
370
371
  try {
371
- const out = (0, node_child_process_1.execFileSync)('git', ['-C', root, 'rev-parse', 'HEAD'], { encoding: 'utf8', env, stdio: ['ignore', 'pipe', 'pipe'] }).trim();
372
+ const out = (0, node_child_process_1.execFileSync)('git', ['-C', root, 'rev-parse', 'HEAD'], { timeout: bounded_io_1.GIT_TIMEOUT_MS, maxBuffer: bounded_io_1.GIT_MAX_BUFFER, encoding: 'utf8', env, stdio: ['ignore', 'pipe', 'pipe'] }).trim();
372
373
  return /^[0-9a-f]{40}$/.test(out) ? out : null;
373
374
  }
374
375
  catch {
@@ -40,7 +40,7 @@ exports.countTestCases = countTestCases;
40
40
  exports.extractAnchors = extractAnchors;
41
41
  exports.scanTestAnchors = scanTestAnchors;
42
42
  exports.computeTestScope = computeTestScope;
43
- // @implements A-SPEC-121.2
43
+ // @implements A-SPEC-121.2, A-SPEC-734
44
44
  const anchor_ids_1 = require("./anchor-ids");
45
45
  const fs = __importStar(require("node:fs"));
46
46
  const path = __importStar(require("node:path"));
@@ -183,7 +183,9 @@ const FRAMEWORKS = [
183
183
  strip: stripPython,
184
184
  // Module-level `pytestmark = pytest.mark.skip` disables the whole file, the direct analogue of
185
185
  // `describe.skip`.
186
- suiteSkip: /^\s*pytestmark\s*=\s*[^\n]*\bskip/m,
186
+ // A-SPEC-733 (round 12 census): `[ \t]*` at a multi-line anchor — `^\s*` ran across a 2 MB run of blank
187
+ // lines from every line start (1.2 s — measured).
188
+ suiteSkip: /^[ \t]*pytestmark[ \t]*=[ \t]*[^\n]*\bskip/m,
187
189
  head: /^[ \t]*(?:async[ \t]+)?def[ \t]+test_?\w*[ \t]*\(/gm,
188
190
  caseSkip: /@\s*(?:pytest\.mark\.skip\w*|unittest\.skip\w*)\b/g,
189
191
  },
@@ -319,12 +321,15 @@ function scanTestAnchors(root) {
319
321
  continue;
320
322
  const abs = path.join(dir, e.name);
321
323
  if (e.isDirectory()) {
322
- walk(abs);
324
+ if (!(0, cpg_scanner_1.isNestedWorkTree)(abs, root))
325
+ walk(abs);
323
326
  continue;
324
- }
327
+ } // A-SPEC-734
325
328
  const rel = path.relative(root, abs).split(path.sep).join('/');
326
329
  if (!(0, cpg_scanner_1.isTestFile)(rel))
327
330
  continue;
331
+ if (!(0, cpg_scanner_1.isRegularSource)(e, abs, root))
332
+ continue; // A-SPEC-734 (round 8): a FIFO named like a test blocked the read forever
328
333
  let text;
329
334
  try {
330
335
  text = fs.readFileSync(abs, 'utf8');
@@ -23,9 +23,30 @@ export interface CompatCheckOpts {
23
23
  /** Repo-relative reader for the OS cross-check; null = file absent (skip, fail-open). */
24
24
  readFile?: (rel: string) => string | null;
25
25
  }
26
- /** `src/…` path tokens out of the Files to Touch section — backticks, bullets and commas tolerated.
27
- * Backslashes normalize to `/` FIRST (adversarial round-1): a Windows author legitimately writes
28
- * `src\holmes\hooks\stop.ts`, and un-normalized it walked straight past the surface prefixes —
29
- * an OS-compat gate defeated by an OS path convention would be its own counterexample. */
26
+ /**
27
+ * @implements A-SPEC-733 (round 5) — thrown by a reader for a file too large to judge. The OS check
28
+ * refuses on it ("never by skipping"); any other reader error still reads as unreadable.
29
+ */
30
+ export declare class FileTooLargeError extends Error {
31
+ readonly rel: string;
32
+ readonly size: number;
33
+ constructor(rel: string, size: number);
34
+ }
35
+ /** The first line of `text` that handles the platform or processes in `file`'s own language. */
36
+ export declare function osSignalOf(file: string, text: string): {
37
+ line: number;
38
+ text: string;
39
+ signal: string;
40
+ } | null;
30
41
  export declare function filesToTouch(spec: Spec): string[];
42
+ /**
43
+ * @implements A-SPEC-733 (round 11) — a linear segment-stack normalizer. `posix.normalize` is quadratic on
44
+ * any `..` that climbs above the first real segment (round 10 stripped only a LEADING run: `x/` + 170,000
45
+ * `../` took 5.4 s through `approvalBlockers` — every Edit that anchors such a draft — measured).
46
+ * `climbs` counts the `..` components that leave the root; `path` is what remains.
47
+ */
48
+ export declare function normalizePosixPath(t: string): {
49
+ path: string;
50
+ climbs: number;
51
+ };
31
52
  export declare function checkCompatDeclared(spec: Spec, opts?: CompatCheckOpts): string | null;