@holmes-lab/holmes-kit 0.38.0 → 0.40.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 (308) hide show
  1. package/CHANGELOG.md +370 -6
  2. package/README.md +58 -40
  3. package/dist/.build-id +1 -1
  4. package/dist/holmes/admission/core/admission-policy.d.ts +37 -0
  5. package/dist/holmes/admission/core/admission-policy.js +147 -0
  6. package/dist/holmes/admission/core/bounded-reader.d.ts +56 -0
  7. package/dist/holmes/admission/core/bounded-reader.js +135 -0
  8. package/dist/holmes/admission/core/change-classifier.d.ts +34 -0
  9. package/dist/holmes/admission/core/change-classifier.js +278 -0
  10. package/dist/holmes/admission/core/config-loader.d.ts +30 -0
  11. package/dist/holmes/admission/core/config-loader.js +145 -0
  12. package/dist/holmes/admission/core/event-judgement.d.ts +37 -0
  13. package/dist/holmes/admission/core/event-judgement.js +251 -0
  14. package/dist/holmes/admission/core/path-rules.d.ts +35 -0
  15. package/dist/holmes/admission/core/path-rules.js +88 -0
  16. package/dist/holmes/admission/core/pin.d.ts +7 -0
  17. package/dist/holmes/admission/core/pin.js +29 -0
  18. package/dist/holmes/admission/core/ports.d.ts +48 -0
  19. package/dist/holmes/admission/core/ports.js +11 -0
  20. package/dist/holmes/admission/core/range-resolver.d.ts +32 -0
  21. package/dist/holmes/admission/core/range-resolver.js +51 -0
  22. package/dist/holmes/admission/core/self-containment.d.ts +1 -0
  23. package/dist/holmes/admission/core/self-containment.js +125 -0
  24. package/dist/holmes/admission/core/signature-source.d.ts +9 -0
  25. package/dist/holmes/admission/core/signature-source.js +4 -0
  26. package/dist/holmes/admission/core/transition-planner.d.ts +15 -0
  27. package/dist/holmes/admission/core/transition-planner.js +14 -0
  28. package/dist/holmes/admission/core/verdict.d.ts +38 -0
  29. package/dist/holmes/admission/core/verdict.js +17 -0
  30. package/dist/holmes/admission/core/wiring.d.ts +44 -0
  31. package/dist/holmes/admission/core/wiring.js +618 -0
  32. package/dist/holmes/admission/forge/git-object-port.d.ts +4 -0
  33. package/dist/holmes/admission/forge/git-object-port.js +132 -0
  34. package/dist/holmes/assoc/assoc-arm.d.ts +1 -1
  35. package/dist/holmes/assoc/assoc-arm.js +1 -1
  36. package/dist/holmes/cli/agents.d.ts +8 -0
  37. package/dist/holmes/cli/agents.js +9 -5
  38. package/dist/holmes/cli/approve-cli.d.ts +2 -0
  39. package/dist/holmes/cli/approve-cli.js +392 -0
  40. package/dist/holmes/cli/approve-ref.d.ts +13 -7
  41. package/dist/holmes/cli/approve-ref.js +30 -10
  42. package/dist/holmes/cli/approve-status.d.ts +26 -2
  43. package/dist/holmes/cli/approve-status.js +98 -18
  44. package/dist/holmes/cli/approve-watch.d.ts +5 -0
  45. package/dist/holmes/cli/approve-watch.js +10 -5
  46. package/dist/holmes/cli/approve.d.ts +50 -13
  47. package/dist/holmes/cli/approve.js +260 -67
  48. package/dist/holmes/cli/attest.js +2 -1
  49. package/dist/holmes/cli/autonomy.d.ts +4 -1
  50. package/dist/holmes/cli/autonomy.js +17 -10
  51. package/dist/holmes/cli/codex-oracle.d.ts +11 -0
  52. package/dist/holmes/cli/codex-oracle.js +5 -1
  53. package/dist/holmes/cli/codex-toml.d.ts +10 -0
  54. package/dist/holmes/cli/codex-toml.js +36 -2
  55. package/dist/holmes/cli/doctor-boundary.d.ts +76 -0
  56. package/dist/holmes/cli/doctor-boundary.js +308 -0
  57. package/dist/holmes/cli/doctor-locks.d.ts +15 -0
  58. package/dist/holmes/cli/doctor-locks.js +119 -0
  59. package/dist/holmes/cli/doctor.d.ts +2 -0
  60. package/dist/holmes/cli/doctor.js +45 -5
  61. package/dist/holmes/cli/flags.d.ts +23 -0
  62. package/dist/holmes/cli/flags.js +89 -0
  63. package/dist/holmes/cli/index.d.ts +5 -1
  64. package/dist/holmes/cli/index.js +206 -424
  65. package/dist/holmes/cli/init.js +33 -0
  66. package/dist/holmes/cli/lock-recover.d.ts +5 -0
  67. package/dist/holmes/cli/lock-recover.js +126 -0
  68. package/dist/holmes/cli/mcp-processes.d.ts +32 -0
  69. package/dist/holmes/cli/mcp-processes.js +132 -0
  70. package/dist/holmes/cli/release-docs.js +1 -1
  71. package/dist/holmes/cli/run-exec.d.ts +141 -0
  72. package/dist/holmes/cli/run-exec.js +1435 -0
  73. package/dist/holmes/cli/run-provision.d.ts +8 -0
  74. package/dist/holmes/cli/run-provision.js +325 -0
  75. package/dist/holmes/cli/run-wiring.d.ts +69 -0
  76. package/dist/holmes/cli/run-wiring.js +270 -0
  77. package/dist/holmes/cli/run.d.ts +26 -0
  78. package/dist/holmes/cli/run.js +364 -83
  79. package/dist/holmes/cli/runtime-binding-approval.js +32 -19
  80. package/dist/holmes/cli/screen-safe.d.ts +3 -92
  81. package/dist/holmes/cli/screen-safe.js +18 -756
  82. package/dist/holmes/config/config.d.ts +2 -0
  83. package/dist/holmes/config/config.js +5 -2
  84. package/dist/holmes/cpg/foundation/language-matrix.js +2 -2
  85. package/dist/holmes/cpg/import-resolver.js +1 -1
  86. package/dist/holmes/governance/approval-decisions.d.ts +47 -0
  87. package/dist/holmes/governance/approval-decisions.js +29 -0
  88. package/dist/holmes/governance/approval-grants.d.ts +220 -1
  89. package/dist/holmes/governance/approval-grants.js +612 -33
  90. package/dist/holmes/governance/approval-queue.d.ts +31 -0
  91. package/dist/holmes/governance/approval-queue.js +122 -11
  92. package/dist/holmes/governance/approval-spend.d.ts +95 -0
  93. package/dist/holmes/governance/approval-spend.js +191 -0
  94. package/dist/holmes/governance/autonomous-shell.d.ts +61 -0
  95. package/dist/holmes/governance/autonomous-shell.js +332 -0
  96. package/dist/holmes/governance/autonomy.d.ts +5 -0
  97. package/dist/holmes/governance/autonomy.js +16 -11
  98. package/dist/holmes/governance/constitution.d.ts +5 -0
  99. package/dist/holmes/governance/constitution.js +32 -12
  100. package/dist/holmes/governance/full-autonomy.d.ts +10 -0
  101. package/dist/holmes/governance/full-autonomy.js +103 -7
  102. package/dist/holmes/governance/harness-catalog.d.ts +103 -0
  103. package/dist/holmes/governance/harness-catalog.js +348 -0
  104. package/dist/holmes/governance/human-channel.d.ts +38 -0
  105. package/dist/holmes/governance/human-channel.js +49 -0
  106. package/dist/holmes/governance/install-manifest.d.ts +22 -0
  107. package/dist/holmes/governance/install-manifest.js +160 -0
  108. package/dist/holmes/governance/ledger-rechain.js +2 -0
  109. package/dist/holmes/governance/ledger-store.conformance.d.ts +7 -1
  110. package/dist/holmes/governance/ledger-store.conformance.js +66 -0
  111. package/dist/holmes/governance/ledger-store.d.ts +88 -11
  112. package/dist/holmes/governance/ledger-store.js +186 -8
  113. package/dist/holmes/governance/provenance-chain.d.ts +16 -4
  114. package/dist/holmes/governance/provenance-chain.js +19 -4
  115. package/dist/holmes/governance/provenance-ledger.d.ts +6 -3
  116. package/dist/holmes/governance/provenance-ledger.js +53 -18
  117. package/dist/holmes/governance/push-gate-runner.js +11 -7
  118. package/dist/holmes/governance/recorded-pairs.d.ts +96 -0
  119. package/dist/holmes/governance/recorded-pairs.js +522 -0
  120. package/dist/holmes/governance/replica-id.d.ts +1 -1
  121. package/dist/holmes/governance/replica-id.js +1 -1
  122. package/dist/holmes/governance/spec-seam.d.ts +59 -0
  123. package/dist/holmes/governance/spec-seam.js +587 -0
  124. package/dist/holmes/governance/spend-kinds.d.ts +16 -0
  125. package/dist/holmes/governance/spend-kinds.js +18 -0
  126. package/dist/holmes/governance/tool-actions.js +2 -0
  127. package/dist/holmes/guardrail/decision-ledger.d.ts +2 -1
  128. package/dist/holmes/guardrail/decision-ledger.js +2 -1
  129. package/dist/holmes/guardrail/impact-gate.d.ts +1 -0
  130. package/dist/holmes/guardrail/impact-gate.js +1 -1
  131. package/dist/holmes/guardrail/line-continuation.d.ts +8 -0
  132. package/dist/holmes/guardrail/line-continuation.js +39 -0
  133. package/dist/holmes/guardrail/operator-person.d.ts +28 -4
  134. package/dist/holmes/guardrail/operator-person.js +57 -11
  135. package/dist/holmes/guardrail/refusal-codes.d.ts +8 -3
  136. package/dist/holmes/guardrail/refusal-codes.js +70 -10
  137. package/dist/holmes/guardrail/risk-classifier.d.ts +15 -9
  138. package/dist/holmes/guardrail/risk-classifier.js +245 -15
  139. package/dist/holmes/guardrail/risk-gate.d.ts +2 -8
  140. package/dist/holmes/guardrail/risk-gate.js +7 -34
  141. package/dist/holmes/guardrail/risk-types.d.ts +10 -0
  142. package/dist/holmes/guardrail/run-plan-scope.js +3 -1
  143. package/dist/holmes/guardrail/run-refusals.d.ts +6 -1
  144. package/dist/holmes/guardrail/run-refusals.js +36 -14
  145. package/dist/holmes/guardrail/run-stages.d.ts +10 -0
  146. package/dist/holmes/guardrail/run-stages.js +46 -6
  147. package/dist/holmes/guardrail/scope-judgment.js +1 -1
  148. package/dist/holmes/guardrail/shell-words.js +24 -3
  149. package/dist/holmes/guardrail/unresolved-write.d.ts +40 -0
  150. package/dist/holmes/guardrail/unresolved-write.js +556 -0
  151. package/dist/holmes/guardrail/write-target.d.ts +3 -0
  152. package/dist/holmes/guardrail/write-target.js +26 -5
  153. package/dist/holmes/hooks/pre-tool-use.d.ts +105 -1
  154. package/dist/holmes/hooks/pre-tool-use.js +1167 -168
  155. package/dist/holmes/hooks/rtm-refresh-child.d.ts +1 -1
  156. package/dist/holmes/hooks/rtm-refresh-child.js +1 -1
  157. package/dist/holmes/hooks/session-start.d.ts +5 -0
  158. package/dist/holmes/hooks/session-start.js +29 -1
  159. package/dist/holmes/hooks/stop.d.ts +23 -0
  160. package/dist/holmes/hooks/stop.js +88 -33
  161. package/dist/holmes/mcp/approval-adapters.js +3 -1
  162. package/dist/holmes/mcp/approval-commit.js +3 -2
  163. package/dist/holmes/mcp/approval-policy.d.ts +2 -1
  164. package/dist/holmes/mcp/approval-policy.js +3 -1
  165. package/dist/holmes/mcp/handlers/adoption.d.ts +1 -1
  166. package/dist/holmes/mcp/handlers/approval-ask.d.ts +14 -0
  167. package/dist/holmes/mcp/handlers/approval-ask.js +31 -6
  168. package/dist/holmes/mcp/handlers/entity-integration.d.ts +3 -3
  169. package/dist/holmes/mcp/handlers/entity-integration.js +29 -11
  170. package/dist/holmes/mcp/handlers/entity-renumber.d.ts +4 -4
  171. package/dist/holmes/mcp/handlers/entity-renumber.js +29 -11
  172. package/dist/holmes/mcp/handlers/entity-store.d.ts +2 -2
  173. package/dist/holmes/mcp/handlers/entity-store.js +133 -59
  174. package/dist/holmes/mcp/handlers/operator-inspection.d.ts +9 -5
  175. package/dist/holmes/mcp/handlers/operator-inspection.js +79 -16
  176. package/dist/holmes/mcp/handlers/phase-queries.d.ts +1 -1
  177. package/dist/holmes/mcp/handlers/requirement-triage.d.ts +4 -4
  178. package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -2
  179. package/dist/holmes/mcp/handlers/review-evidence.js +35 -11
  180. package/dist/holmes/mcp/handlers/review-queries.d.ts +5 -0
  181. package/dist/holmes/mcp/handlers/review-queries.js +8 -1
  182. package/dist/holmes/mcp/handlers/review-verdict.d.ts +3 -0
  183. package/dist/holmes/mcp/handlers/review-verdict.js +10 -3
  184. package/dist/holmes/mcp/handlers/risk-assessment.d.ts +7 -2
  185. package/dist/holmes/mcp/handlers/risk-assessment.js +34 -12
  186. package/dist/holmes/mcp/handlers/runtime-binding-tool.d.ts +2 -2
  187. package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +6 -1
  188. package/dist/holmes/mcp/handlers/slice-orchestration.js +14 -1
  189. package/dist/holmes/mcp/handlers/spec-approval.d.ts +15 -3
  190. package/dist/holmes/mcp/handlers/spec-approval.js +32 -5
  191. package/dist/holmes/mcp/handlers/spec-authoring.d.ts +2 -2
  192. package/dist/holmes/mcp/handlers/spec-authoring.js +19 -2
  193. package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +11 -38
  194. package/dist/holmes/mcp/handlers/spec-lifecycle.js +441 -94
  195. package/dist/holmes/mcp/handlers/spec-queries.d.ts +2 -2
  196. package/dist/holmes/mcp/handlers/taint-screening.d.ts +1 -1
  197. package/dist/holmes/mcp/handlers/taint-screening.js +2 -2
  198. package/dist/holmes/mcp/handlers/test-execution.d.ts +1 -1
  199. package/dist/holmes/mcp/handlers/workspace-preflight.d.ts +5 -0
  200. package/dist/holmes/mcp/handlers/workspace-preflight.js +10 -2
  201. package/dist/holmes/mcp/handlers/workspace-queries.d.ts +2 -2
  202. package/dist/holmes/mcp/handlers.d.ts +99 -79
  203. package/dist/holmes/mcp/handlers.js +93 -25
  204. package/dist/holmes/mcp/harness-attestation.d.ts +78 -5
  205. package/dist/holmes/mcp/harness-attestation.js +325 -53
  206. package/dist/holmes/mcp/maintenance-analyze.d.ts +1 -1
  207. package/dist/holmes/mcp/maintenance-analyze.js +9 -9
  208. package/dist/holmes/mcp/maintenance-evidence.js +31 -2
  209. package/dist/holmes/mcp/requirement-triage-evidence.js +22 -13
  210. package/dist/holmes/mcp/server-staleness.d.ts +43 -0
  211. package/dist/holmes/mcp/server-staleness.js +158 -0
  212. package/dist/holmes/mcp/server.js +34 -9
  213. package/dist/holmes/mcp/spec-id-guard.js +1 -1
  214. package/dist/holmes/mcp/tool-schemas.d.ts +13 -0
  215. package/dist/holmes/mcp/tool-schemas.js +42 -2
  216. package/dist/holmes/project/act-root.d.ts +19 -0
  217. package/dist/holmes/project/act-root.js +100 -0
  218. package/dist/holmes/project/baseline.js +4 -3
  219. package/dist/holmes/project/bounded-group.d.ts +47 -0
  220. package/dist/holmes/project/bounded-group.js +140 -0
  221. package/dist/holmes/project/bounded-io.d.ts +50 -2
  222. package/dist/holmes/project/bounded-io.js +138 -6
  223. package/dist/holmes/project/change-source.js +2 -2
  224. package/dist/holmes/project/instance-id.d.ts +10 -0
  225. package/dist/holmes/project/instance-id.js +233 -0
  226. package/dist/holmes/project/machine-identity.d.ts +25 -0
  227. package/dist/holmes/project/machine-identity.js +133 -0
  228. package/dist/holmes/project/owned-lock.d.ts +84 -0
  229. package/dist/holmes/project/owned-lock.js +263 -0
  230. package/dist/holmes/project/plain-lock-fs.d.ts +2 -0
  231. package/dist/holmes/project/plain-lock-fs.js +126 -0
  232. package/dist/holmes/project/request-lock.d.ts +85 -0
  233. package/dist/holmes/project/request-lock.js +459 -0
  234. package/dist/holmes/project/root.d.ts +12 -4
  235. package/dist/holmes/project/root.js +26 -7
  236. package/dist/holmes/project/run-records.d.ts +19 -0
  237. package/dist/holmes/project/run-records.js +94 -12
  238. package/dist/holmes/project/screen-text.d.ts +94 -0
  239. package/dist/holmes/project/screen-text.js +763 -0
  240. package/dist/holmes/project/spend-lock.d.ts +82 -0
  241. package/dist/holmes/project/spend-lock.js +413 -0
  242. package/dist/holmes/project/workspace-preflight.d.ts +5 -0
  243. package/dist/holmes/project/workspace-preflight.js +24 -1
  244. package/dist/holmes/refresh/freshness-coordinator.d.ts +1 -1
  245. package/dist/holmes/refresh/freshness-coordinator.js +1 -1
  246. package/dist/holmes/review/condition-hunk-replay.js +4 -2
  247. package/dist/holmes/review/confidence-calibration.d.ts +1 -1
  248. package/dist/holmes/review/confidence-calibration.js +1 -1
  249. package/dist/holmes/review/content-verify.js +1 -1
  250. package/dist/holmes/review/hop-ablation.d.ts +4 -4
  251. package/dist/holmes/review/hop-ablation.js +5 -5
  252. package/dist/holmes/review/point-in-time-replay.js +12 -3
  253. package/dist/holmes/review/rank-diagnosis.d.ts +2 -2
  254. package/dist/holmes/review/rank-diagnosis.js +1 -1
  255. package/dist/holmes/review/replay-corpus.d.ts +10 -4
  256. package/dist/holmes/review/replay-corpus.js +25 -9
  257. package/dist/holmes/review/requirement-triage.js +2 -2
  258. package/dist/holmes/review/semantic-arm.d.ts +3 -3
  259. package/dist/holmes/review/semantic-arm.js +3 -3
  260. package/dist/holmes/review/test-outcomes.js +3 -1
  261. package/dist/holmes/review/test-runner.d.ts +11 -0
  262. package/dist/holmes/review/test-runner.js +31 -10
  263. package/dist/holmes/review/test-selection-breadth.js +2 -2
  264. package/dist/holmes/review/verdicts.d.ts +109 -7
  265. package/dist/holmes/review/verdicts.js +653 -34
  266. package/dist/holmes/rtm/anchor-census.d.ts +9 -0
  267. package/dist/holmes/rtm/anchor-census.js +151 -0
  268. package/dist/holmes/rtm/anchor-ids.d.ts +25 -1
  269. package/dist/holmes/rtm/anchor-ids.js +45 -2
  270. package/dist/holmes/rtm/comment-ranges.d.ts +2 -0
  271. package/dist/holmes/rtm/comment-ranges.js +104 -0
  272. package/dist/holmes/rtm/counted-tests.d.ts +1 -0
  273. package/dist/holmes/rtm/counted-tests.js +63 -0
  274. package/dist/holmes/rtm/impact-advisory.d.ts +1 -1
  275. package/dist/holmes/rtm/known-defects.js +1 -1
  276. package/dist/holmes/rtm/localize.js +1 -1
  277. package/dist/holmes/rtm/taint-benchmark.d.ts +1 -1
  278. package/dist/holmes/rtm/taint-vocabulary.d.ts +1 -1
  279. package/dist/holmes/rtm/test-scope.d.ts +31 -0
  280. package/dist/holmes/rtm/test-scope.js +166 -5
  281. package/dist/holmes/rtm/trace-gaps.js +1 -1
  282. package/dist/holmes/runtime/dispatch.d.ts +10 -0
  283. package/dist/holmes/runtime/dispatch.js +12 -1
  284. package/dist/holmes/semantic/cloud-usage.d.ts +1 -1
  285. package/dist/holmes/semantic/cloud-usage.js +1 -1
  286. package/dist/holmes/semantic/unreadable-paths.d.ts +1 -1
  287. package/dist/holmes/semantic/unreadable-paths.js +1 -1
  288. package/dist/holmes/spec/approval-blockers.js +1 -1
  289. package/dist/holmes/spec/entity-store.d.ts +6 -1
  290. package/dist/holmes/spec/entity-store.js +16 -2
  291. package/dist/holmes/spec/entity-transaction.d.ts +7 -2
  292. package/dist/holmes/spec/entity-transaction.js +87 -170
  293. package/dist/holmes/spec/spec-store.d.ts +12 -6
  294. package/dist/holmes/spec/spec-store.js +4 -2
  295. package/dist/holmes/spec/spec-types.js +1 -1
  296. package/dist/holmes/spec/succession-guard.d.ts +56 -0
  297. package/dist/holmes/spec/succession-guard.js +187 -0
  298. package/dist/holmes/spec/succession.d.ts +70 -0
  299. package/dist/holmes/spec/succession.js +171 -0
  300. package/dist/holmes/spec/transition-policy.d.ts +2 -2
  301. package/docs/install-guide.md +9 -3
  302. package/docs/language-support.md +78 -0
  303. package/package.json +4 -3
  304. package/playbooks/author-slice/PLAYBOOK.md +1 -1
  305. package/playbooks/promote-slice/PLAYBOOK.md +5 -1
  306. package/playbooks/publish/PLAYBOOK.md +45 -33
  307. package/dist/holmes/review/manual-baseline.d.ts +0 -209
  308. package/dist/holmes/review/manual-baseline.js +0 -2847
@@ -38,6 +38,9 @@ exports.architectureGoverningFiles = architectureGoverningFiles;
38
38
  exports.accountChangedFiles = accountChangedFiles;
39
39
  exports.stripCode = stripCode;
40
40
  exports.countTestCases = countTestCases;
41
+ exports.testCountDetail = testCountDetail;
42
+ exports.zeroCountReason = zeroCountReason;
43
+ exports.zeroCountDiagnostics = zeroCountDiagnostics;
41
44
  exports.extractAnchors = extractAnchors;
42
45
  exports.scanTestAnchors = scanTestAnchors;
43
46
  exports.scanTestAnchorDiagnostics = scanTestAnchorDiagnostics;
@@ -245,7 +248,19 @@ function stripCode(src, js) {
245
248
  let regexOk = true;
246
249
  let regexOffUntil = -1;
247
250
  const interp = [];
248
- const emit = (text, next) => { out.push(src.slice(start, i), text); i = next; start = next; };
251
+ // @implements A-SPEC-750.4 — what is removed keeps its line breaks, so an offset in the stripped code names its line
252
+ const emit = (text, next) => {
253
+ let breaks = 0;
254
+ for (let k = i; k < next; k++)
255
+ if (src.charCodeAt(k) === 10)
256
+ breaks++;
257
+ for (let k = 0; k < text.length; k++)
258
+ if (text.charCodeAt(k) === 10)
259
+ breaks--;
260
+ out.push(src.slice(start, i), text, breaks > 0 ? '\n'.repeat(breaks) : '');
261
+ i = next;
262
+ start = next;
263
+ };
249
264
  const template = (from, lead) => {
250
265
  const t = scanTemplate(src, from);
251
266
  if (t.interp) {
@@ -398,9 +413,105 @@ const JEST_ALIAS = /(?<![\w$.])(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*(?::[^=;
398
413
  * followed by `(`, or by `.each(…)(` / `.each` + template + `(`. Method calls (`re.test(`) never match: the head must not
399
414
  * follow a `.`. `it.skip(`/`it.todo(`/`xit(` never match, so nothing is subtracted.
400
415
  */
401
- function jestCount(code) {
402
- if (JEST_SUITE_SKIP.test(code))
403
- return 0;
416
+ function jestCount(code) { return jestCountDetail(code).cases; }
417
+ const JEST_SUITE_SKIP_ALL = new RegExp(JEST_SUITE_SKIP.source, 'g');
418
+ /** Index after a `.each(…)` or `.each` + template that follows `j`, or `j` itself. */
419
+ function skipEach(code, j) {
420
+ if (code[j] !== '.')
421
+ return j;
422
+ let k = skipSpace(code, j + 1);
423
+ if (!code.startsWith('each', k) || /[\w$]/.test(code[k + 4] ?? ''))
424
+ return j;
425
+ k = skipSpace(code, k + 4);
426
+ if (code[k] !== '(' && code[k] !== '`')
427
+ return j;
428
+ return skipSpace(code, skipGroup(code, k));
429
+ }
430
+ /**
431
+ * @implements A-SPEC-750.2 — the code a jest suite-skip marks, as ranges: a `describe.skip(…)`, `describe[…](…)` or
432
+ * `xdescribe(…)` call's group, and every call of a `const` alias whose declaration ends in a conditional of `describe`
433
+ * and a skip (an opt-in suite: it does not run by default). A marker in any other shape, or an alias used any other way,
434
+ * cannot be placed: the whole file is forfeited, as before.
435
+ */
436
+ /**
437
+ * @implements A-SPEC-750.3 — is the second argument of the call whose group opens at `open` a function literal (an arrow,
438
+ * a `function` expression, or an `async` form of either). A body passed by name is defined elsewhere, out of the group.
439
+ */
440
+ function bodyIsFunctionLiteral(code, open) {
441
+ const end = skipGroup(code, open) - 1;
442
+ let start = -1;
443
+ for (let k = open + 1; k < end; k++) {
444
+ const ch = code[k];
445
+ if (ch === '(' || ch === '[' || ch === '{' || ch === '`') {
446
+ k = skipGroup(code, k) - 1;
447
+ continue;
448
+ }
449
+ if (ch === ',') {
450
+ start = k + 1;
451
+ break;
452
+ }
453
+ }
454
+ if (start < 0)
455
+ return false;
456
+ let j = skipSpace(code, start);
457
+ if (code.startsWith('async', j) && !/[\w$]/.test(code[j + 5] ?? ''))
458
+ j = skipSpace(code, j + 5);
459
+ if (code.startsWith('function', j) && !/[\w$]/.test(code[j + 8] ?? ''))
460
+ return true;
461
+ if (code[j] === '(')
462
+ return code.startsWith('=>', skipSpace(code, skipGroup(code, j)));
463
+ const id = /^[A-Za-z_$][\w$]*/.exec(code.slice(j, j + 256));
464
+ return id !== null && code.startsWith('=>', skipSpace(code, j + id[0].length));
465
+ }
466
+ function jestSkipRanges(code) {
467
+ const ranges = [];
468
+ const aliases = [];
469
+ for (const m of code.matchAll(JEST_SUITE_SKIP_ALL)) {
470
+ const p = m.index;
471
+ let j = p + m[0].length;
472
+ if (m[0].endsWith('['))
473
+ j = skipGroup(code, j - 1);
474
+ j = skipEach(code, skipSpace(code, j));
475
+ if (code[j] === '(') {
476
+ if (!bodyIsFunctionLiteral(code, j))
477
+ return { forfeit: 'suite-skip body passed by name', at: p }; // @implements A-SPEC-750.3
478
+ ranges.push([p, skipGroup(code, j)]);
479
+ continue;
480
+ }
481
+ const before = code.slice(0, p);
482
+ const stmt = Math.max(before.lastIndexOf(';'), before.lastIndexOf('\n'), before.lastIndexOf('{'), before.lastIndexOf('}')) + 1;
483
+ const decl = /^\s*(?:export\s+)?const\s+([A-Za-z_$][\w$]*)\s*(?::[^=;]*)?=\s*[^;()[\]{}]*$/.exec(code.slice(stmt, p));
484
+ const endAt = (() => { const e = code.slice(j).search(/[;\n]/); return e < 0 ? code.length : j + e; })();
485
+ if (decl === null || !/^[\s\w$.:?]*$/.test(code.slice(j, endAt)))
486
+ return { forfeit: 'suite-skip marker in a shape the counter cannot place', at: p };
487
+ if (JEST_HEADS.includes(decl[1]) || JEST_HELPERS.has(decl[1]))
488
+ return { forfeit: `suite-skip alias ${decl[1]} shadows a case head`, at: p };
489
+ aliases.push({ name: decl[1], at: stmt + code.slice(stmt, p).indexOf(decl[1]) });
490
+ }
491
+ for (const a of aliases) {
492
+ for (const m of code.matchAll(new RegExp(`(?<![\\w$.])${a.name.replace(/\$/g, '\\$')}(?![\\w$])`, 'g'))) {
493
+ if (m.index === a.at)
494
+ continue;
495
+ const k = skipEach(code, skipSpace(code, m.index + a.name.length));
496
+ if (code[k] !== '(')
497
+ return { forfeit: `suite-skip alias ${a.name} is used other than as a call`, at: m.index };
498
+ if (!bodyIsFunctionLiteral(code, k))
499
+ return { forfeit: 'suite-skip body passed by name', at: m.index }; // @implements A-SPEC-750.3
500
+ ranges.push([m.index, skipGroup(code, k)]);
501
+ }
502
+ }
503
+ return { ranges };
504
+ }
505
+ /** @implements A-SPEC-750.2 — the jest count, with the reason a file was forfeited whole. */
506
+ function jestCountDetail(code) {
507
+ let ranges = [];
508
+ if (JEST_SUITE_SKIP.test(code)) {
509
+ const placed = jestSkipRanges(code);
510
+ if ('forfeit' in placed)
511
+ return { cases: 0, forfeit: placed.forfeit, forfeitAt: placed.at }; // @implements A-SPEC-750.4
512
+ ranges = placed.ranges;
513
+ }
514
+ const skipped = (at) => ranges.some(([s, e]) => at >= s && at < e);
404
515
  const direct = new Set(JEST_HEADS);
405
516
  // Most files bind no alias; the declaration scan below visits every `const`, so it runs only when an alias can exist.
406
517
  if (JEST_ALIAS_HINT.test(code))
@@ -424,6 +535,8 @@ function jestCount(code) {
424
535
  // has its later typed tables left uncounted, which is the direction a lower bound may err in.
425
536
  let typeArgumentWork = 2 * code.length + 1024;
426
537
  for (const m of code.matchAll(new RegExp(`(?<![\\w$.])(?:${names.join('|')})(?![\\w$])`, 'g'))) {
538
+ if (skipped(m.index))
539
+ continue; // @implements A-SPEC-750.2 — inside a skipped block
427
540
  let j = m.index + m[0].length;
428
541
  if (!direct.has(m[0])) {
429
542
  j = skipSpace(code, j);
@@ -457,7 +570,7 @@ function jestCount(code) {
457
570
  if (code[k] === '(')
458
571
  cases++;
459
572
  }
460
- return cases;
573
+ return { cases, ...(ranges.length > 0 ? { placed: true } : {}) };
461
574
  }
462
575
  /** Strip block/line comments and string literals from C-family source (no regex literals, no interpolation). */
463
576
  const stripCFamily = (src) => stripCode(src, false);
@@ -568,6 +681,54 @@ function countTestCases(source, filePath) {
568
681
  const skips = rule.caseSkip ? (stripped.match(rule.caseSkip) ?? []).length : 0;
569
682
  return Math.max(0, heads.length - skips);
570
683
  }
684
+ /**
685
+ * @implements A-SPEC-750.2 — the count with what explains a zero: the first line holding a suite-skip marker (each
686
+ * original line stripped alone), and the reason the whole file was forfeited when it was.
687
+ */
688
+ function testCountDetail(source, filePath) {
689
+ const rule = ruleFor(filePath);
690
+ if (rule.id === 'jest') {
691
+ // @implements A-SPEC-750.4 — lines from the stripped code, which keeps every line break: a marker in a comment or a
692
+ // template is not one, and the forfeit names the marker that caused it
693
+ const code = stripCode(source, true);
694
+ const lineAt = (offset) => { let n = 1; for (let k = 0; k < offset; k++)
695
+ if (code.charCodeAt(k) === 10)
696
+ n++; return n; };
697
+ const first = code.search(JEST_SUITE_SKIP);
698
+ const d = jestCountDetail(code);
699
+ return { cases: d.cases, ...(first >= 0 ? { markerLine: lineAt(first) } : {}), ...(d.placed ? { placedSkip: true } : {}),
700
+ ...(d.forfeit ? { forfeit: { line: lineAt(d.forfeitAt ?? first), reason: d.forfeit } } : {}) };
701
+ }
702
+ const at = source.split('\n').findIndex((l) => rule.suiteSkip.test(l));
703
+ const markerLine = at < 0 ? undefined : at + 1;
704
+ const cases = countTestCases(source, filePath);
705
+ return { cases, ...(markerLine ? { markerLine } : {}), ...(rule.suiteSkip.test(source) ? { forfeit: { line: markerLine ?? 1, reason: 'suite-skip marker' } } : {}) };
706
+ }
707
+ /** @implements A-SPEC-750.4 — why an anchored file counts zero, in the words ART-4, remediate and review_prepare use. */
708
+ function zeroCountReason(d) {
709
+ if (d.forfeit)
710
+ return `forfeit: ${d.forfeit.reason} at line ${d.forfeit.line}`;
711
+ if (d.placedSkip)
712
+ return 'all cases inside skipped blocks';
713
+ return 'no case heads';
714
+ }
715
+ /**
716
+ * @implements A-SPEC-750.2 — every anchored test file that counts zero, with its A-SPECs and why: `suite-skip marker at
717
+ * line N`, or `no case heads`. What ART-4, spec_remediate and review_prepare say instead of "anchor the tests".
718
+ */
719
+ function zeroCountDiagnostics(root) {
720
+ const out = [];
721
+ forEachTestFile(root, (rel, text) => {
722
+ const aspecs = extractAnchors(text);
723
+ if (aspecs.length === 0)
724
+ return;
725
+ const d = testCountDetail(text, rel);
726
+ if (d.cases > 0)
727
+ return;
728
+ out.push({ file: rel, aspecs, reason: zeroCountReason(d) }); // @implements A-SPEC-750.4
729
+ });
730
+ return out.sort((a, b) => a.file.localeCompare(b.file));
731
+ }
571
732
  // An anchor must be a STANDALONE COMMENT LINE, and string/template literals are removed first
572
733
  // (adversarial review C2: a raw whole-file match credited a test file's entire executed count to
573
734
  // every id merely MENTIONED in it — a live run credited 50 cases to the nonexistent A-SPEC-999 from
@@ -11,7 +11,7 @@ exports.traceGaps = traceGaps;
11
11
  * is not "no impact", it is "cannot see" — and until now the two had the same shape (silence).
12
12
  * Measured 2026-09-17 on this repository: 24 of the 72 unlinked approved specs (REQ-655's census)
13
13
  * declare 34 scanned production files in their Files to Touch — change `hooks/pre-tool-use.ts`
14
- * today and A-SPEC-202 / A-SPEC-250 stay unmentioned. The jarvis incident was the same shape
14
+ * today and A-SPEC-202 / A-SPEC-250 stay unmentioned. The consumer workspace's incident was the same shape
15
15
  * (`_fmt_at` changed, REQ-347 unreported).
16
16
  *
17
17
  * Pure: the population is the same one REQ-655 counts (approved A-SPEC minus scanned anchors), the
@@ -1,4 +1,14 @@
1
1
  import type { RuntimeHarness, RuntimeEntry } from './binding';
2
+ /**
3
+ * @implements A-SPEC-245.24 (item 1) — the dispatcher's own refusal line. The dispatcher runs as a standalone copy and
4
+ * imports nothing of the gate, so the row is written here; deny-code-census.test.ts pins it to the refusal table's
5
+ * gate.unjudgeable row.
6
+ */
7
+ export declare const DISPATCH_REFUSAL: {
8
+ readonly code: "gate.unjudgeable";
9
+ readonly class: "retryable";
10
+ readonly remediation: readonly ["split the command or edit into smaller parts", "retry; if it repeats, ask the operator"];
11
+ };
2
12
  export interface DispatchOptions {
3
13
  registryPath: string;
4
14
  harness: RuntimeHarness;
@@ -33,12 +33,22 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.DISPATCH_REFUSAL = void 0;
36
37
  exports.runDispatch = runDispatch;
37
38
  // @implements A-SPEC-751, A-SPEC-751.1, A-SPEC-751.5, A-SPEC-751.6, A-SPEC-751.7, A-SPEC-754, A-SPEC-769.10, A-SPEC-772.1
38
39
  const path = __importStar(require("node:path"));
39
40
  const node_child_process_1 = require("node:child_process");
40
41
  const binding_1 = require("./binding");
41
42
  const hook_process_1 = require("./hook-process");
43
+ /**
44
+ * @implements A-SPEC-245.24 (item 1) — the dispatcher's own refusal line. The dispatcher runs as a standalone copy and
45
+ * imports nothing of the gate, so the row is written here; deny-code-census.test.ts pins it to the refusal table's
46
+ * gate.unjudgeable row.
47
+ */
48
+ exports.DISPATCH_REFUSAL = {
49
+ code: 'gate.unjudgeable', class: 'retryable',
50
+ remediation: ['split the command or edit into smaller parts', 'retry; if it repeats, ask the operator'],
51
+ };
42
52
  function hookInput(budget) {
43
53
  return new Promise((resolve, reject) => {
44
54
  const chunks = [];
@@ -221,7 +231,8 @@ async function runDispatch(opts) {
221
231
  }
222
232
  const output = opts.harness === 'antigravity' ? { decision: opts.entry === 'stop' ? 'continue' : 'deny', reason }
223
233
  : opts.entry === 'stop' ? { decision: 'block', reason }
224
- : { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: reason } };
234
+ // @implements A-SPEC-245.24 (item 1) — this output does not pass hookOutputFor, so the site writes its own line
235
+ : { hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'deny', permissionDecisionReason: `${reason}\n[holmes-refusal] ${JSON.stringify(exports.DISPATCH_REFUSAL)}` } };
225
236
  process.stdout.write(`${JSON.stringify(output)}\n`);
226
237
  process.exitCode = 0;
227
238
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Cloud embedding egress, counted where it leaves: one JSON line per HTTP request the cloud embedder sends (retries
3
- * included), per project, by local calendar day. Supervisor 2026-10-19 00:20 (b): the jarvis ledger counts only its
3
+ * included), per project, by local calendar day. Supervisor 2026-10-19 00:20 (b): a consumer workspace's ledger counts only its
4
4
  * Python processes, so holmes-kit's own requests were invisible. The record is advisory — it never fails an embedding,
5
5
  * and it holds neither the key nor any text.
6
6
  */
@@ -42,7 +42,7 @@ const fs = __importStar(require("node:fs"));
42
42
  const path = __importStar(require("node:path"));
43
43
  /**
44
44
  * Cloud embedding egress, counted where it leaves: one JSON line per HTTP request the cloud embedder sends (retries
45
- * included), per project, by local calendar day. Supervisor 2026-10-19 00:20 (b): the jarvis ledger counts only its
45
+ * included), per project, by local calendar day. Supervisor 2026-10-19 00:20 (b): a consumer workspace's ledger counts only its
46
46
  * Python processes, so holmes-kit's own requests were invisible. The record is advisory — it never fails an embedding,
47
47
  * and it holds neither the key nor any text.
48
48
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Cosine at or above which an unreadable file's path words are "about" a non-ASCII request, keyed by
3
3
  * the semantic runtime label. Measured 2026-09-30 (docs/goals/EVIDENCE-nonlatin-relevance-2026-09-30.md):
4
- * on gemini-embedding-001 mixed requests naming the file scored 0.701–0.765 and no unmatched jarvis
4
+ * on gemini-embedding-001 mixed requests naming the file scored 0.701–0.765 and no unmatched consumer-corpus
5
5
  * request exceeded 0.640. On local bge-m3 the populations overlapped (pin 0.486 against 0.489), so it
6
6
  * has no entry — a label without a threshold keeps the language relevant.
7
7
  */
@@ -52,7 +52,7 @@ const MAX_UNREADABLE_FILES = 5000;
52
52
  /**
53
53
  * Cosine at or above which an unreadable file's path words are "about" a non-ASCII request, keyed by
54
54
  * the semantic runtime label. Measured 2026-09-30 (docs/goals/EVIDENCE-nonlatin-relevance-2026-09-30.md):
55
- * on gemini-embedding-001 mixed requests naming the file scored 0.701–0.765 and no unmatched jarvis
55
+ * on gemini-embedding-001 mixed requests naming the file scored 0.701–0.765 and no unmatched consumer-corpus
56
56
  * request exceeded 0.640. On local bge-m3 the populations overlapped (pin 0.486 against 0.489), so it
57
57
  * has no entry — a label without a threshold keeps the language relevant.
58
58
  */
@@ -154,7 +154,7 @@ function placeholderSections(spec) {
154
154
  }
155
155
  /**
156
156
  * @implements A-SPEC-182.1 — the bodies `spec_slice_init` writes. They are prose, not `TODO`, so `placeholderSections`
157
- * never saw them: measured 2026-10-18, 421 approved specs here and 303 in a jarvis copy still carried one. A section
157
+ * never saw them: measured 2026-10-18, 421 approved specs here and 303 in a consumer workspace's copy still carried one. A section
158
158
  * counts only when its WHOLE body (whitespace normalised) is the scaffold; Open Questions, Assumptions, Non-Functional
159
159
  * and Scope are left out because their scaffold ("None.") can be a real answer.
160
160
  */
@@ -76,9 +76,14 @@ export declare function readEntityRenumberSnapshot(storeRoot: string): {
76
76
  };
77
77
  /** Supply a validated snapshot while retaining the same store ownership through publication. */
78
78
  export declare function withEntityRenumberSnapshot<T>(storeRoot: string, act: (snapshot: ReturnType<typeof readEntityRenumberSnapshot>, assertCurrent: () => void) => T | Promise<T>): Promise<T>;
79
+ /**
80
+ * @implements A-SPEC-245.15 (item 3) — call a publish hook synchronously: one that returns a promise (an async function
81
+ * passed through a cast) throws here, before anything is written, since its result would never be awaited.
82
+ */
83
+ export declare function callBeforePublish(hook: (() => undefined) | undefined): void;
79
84
  export declare function writeEntityRepository(storeRoot: string, spec: Spec, targetPath: string, expectedVersion: string | undefined, legacyWrite: () => Promise<{
80
85
  version: string;
81
- }>): Promise<{
86
+ }>, beforePublish?: () => undefined): Promise<{
82
87
  version: string;
83
88
  }>;
84
89
  /** Inspection is not authorization to execute a journal or remove its lock. */
@@ -44,13 +44,14 @@ exports.assertEntityRepositoryReadable = assertEntityRepositoryReadable;
44
44
  exports.readEntityRepositorySnapshot = readEntityRepositorySnapshot;
45
45
  exports.readEntityRenumberSnapshot = readEntityRenumberSnapshot;
46
46
  exports.withEntityRenumberSnapshot = withEntityRenumberSnapshot;
47
+ exports.callBeforePublish = callBeforePublish;
47
48
  exports.writeEntityRepository = writeEntityRepository;
48
49
  exports.planEntityRecovery = planEntityRecovery;
49
50
  exports.validateEntityRecoveryPlan = validateEntityRecoveryPlan;
50
51
  exports.entityRecoveryTarget = entityRecoveryTarget;
51
52
  exports.recoverEntityStore = recoverEntityStore;
52
53
  exports.adoptEntityStore = adoptEntityStore;
53
- // @implements A-SPEC-629, A-SPEC-628, A-SPEC-627, A-SPEC-627.1
54
+ // @implements A-SPEC-629, A-SPEC-628, A-SPEC-627, A-SPEC-627.1, A-SPEC-245.14, A-SPEC-245.15
54
55
  // @implements A-SPEC-640
55
56
  // @implements A-SPEC-639
56
57
  // @implements A-SPEC-638
@@ -508,7 +509,19 @@ function renumberSnapshot(bound) {
508
509
  const referenceNamespaces = allEntityRecords(bound).map(record => ({ entityId: record.entityId, displayId: record.displayId, storeId: record.storeId, workspaceId: record.workspaceId }));
509
510
  return { workspaceId: active.workspaceId, storeId: active.storeId, storeLocator: bound.locator, registrationVersion: (0, entity_transaction_1.entityContentVersion)(registrationBytes), entries, referenceNamespaces };
510
511
  }
511
- async function writeEntityRepository(storeRoot, spec, targetPath, expectedVersion, legacyWrite) {
512
+ /**
513
+ * @implements A-SPEC-245.15 (item 3) — call a publish hook synchronously: one that returns a promise (an async function
514
+ * passed through a cast) throws here, before anything is written, since its result would never be awaited.
515
+ */
516
+ function callBeforePublish(hook) {
517
+ if (hook === undefined)
518
+ return;
519
+ const result = hook();
520
+ if (result !== null && (typeof result === 'object' || typeof result === 'function') && typeof result.then === 'function') {
521
+ throw new entity_transaction_1.EntityStoreError('invalid-hook', 'The publish hook returned a promise; it must run synchronously. Nothing was written.');
522
+ }
523
+ }
524
+ async function writeEntityRepository(storeRoot, spec, targetPath, expectedVersion, legacyWrite, beforePublish) {
512
525
  const bound = bindingWithEntityState(storeRoot, false);
513
526
  if (!bound)
514
527
  return legacyWrite();
@@ -558,6 +571,7 @@ async function writeEntityRepository(storeRoot, spec, targetPath, expectedVersio
558
571
  changes.push(change(oldFile, before, null));
559
572
  for (const c of changes)
560
573
  (0, entity_transaction_1.assertEntityByteInput)(bound.root, c);
574
+ callBeforePublish(beforePublish); // A-SPEC-245.14 — every check passed, inside the entity-store lock, before the journal
561
575
  const journal = path.join('.ax/state/entity-transactions', operationId, 'journal.json');
562
576
  const journalText = JSON.stringify({ schema: 'holmes-entity-write-journal/1', operationId, workspaceId: active.workspaceId, storeId: active.storeId, storeLocator: bound.locator, changes }) + '\n';
563
577
  (0, entity_transaction_1.publishEntityRecord)(bound.root, journal, journalText);
@@ -1,4 +1,5 @@
1
1
  import * as fs from 'node:fs';
2
+ import { LOCK_STAGING_STALE_MS } from '../project/owned-lock';
2
3
  export declare class EntityStoreError extends Error {
3
4
  readonly code: string;
4
5
  readonly holmesRefusal = true;
@@ -88,10 +89,14 @@ export declare function renameWithTransientRetry(from: string, to: string, deps?
88
89
  delayMs?: number;
89
90
  sleep?: (ms: number) => void;
90
91
  }): void;
92
+ /**
93
+ * @implements A-SPEC-245.8 — the lock protocol lives in owned-lock.ts; its errors become this store's, with the busy
94
+ * message of each site and every other code and message unchanged. Anything that is not a LockError passes through.
95
+ */
96
+ export declare function toEntityStoreError(e: unknown): unknown;
91
97
  /** The shared source-publication coordination namespace, independent of every configured spec store (A-SPEC-634: exported so recovery can release it without importing the renumber module). */
92
98
  export declare const SOURCE_PUBLICATION_LOCATOR = ".ax/state/entity-renumber-source-publication";
93
- /** Age after which a `.staging-*` entry beside the locks is treated as abandoned by a publisher that died before its rename (A-SPEC-633). */
94
- export declare const LOCK_STAGING_STALE_MS: number;
99
+ export { LOCK_STAGING_STALE_MS };
95
100
  export declare function withEntityStoreLock<T>(root: string, locator: string, act: () => T): T;
96
101
  /** Keep ownership through asynchronous repository lookups and final publication. */
97
102
  export declare function withEntityStoreLockAsync<T>(root: string, locator: string, act: () => T | Promise<T>): Promise<T>;