@holmes-lab/holmes-kit 0.39.0 → 0.40.1

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 (325) hide show
  1. package/CHANGELOG.md +578 -6
  2. package/README.md +120 -41
  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 +49 -13
  47. package/dist/holmes/cli/approve.js +249 -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 +34 -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 +226 -442
  65. package/dist/holmes/cli/init.js +33 -0
  66. package/dist/holmes/cli/interactive-prompt.d.ts +39 -2
  67. package/dist/holmes/cli/interactive-prompt.js +98 -16
  68. package/dist/holmes/cli/lock-recover.d.ts +5 -0
  69. package/dist/holmes/cli/lock-recover.js +126 -0
  70. package/dist/holmes/cli/mcp-processes.js +1 -1
  71. package/dist/holmes/cli/release-docs.js +1 -1
  72. package/dist/holmes/cli/run-exec.d.ts +141 -0
  73. package/dist/holmes/cli/run-exec.js +1435 -0
  74. package/dist/holmes/cli/run-provision.d.ts +3 -1
  75. package/dist/holmes/cli/run-provision.js +255 -44
  76. package/dist/holmes/cli/run-wiring.d.ts +69 -0
  77. package/dist/holmes/cli/run-wiring.js +270 -0
  78. package/dist/holmes/cli/run.d.ts +21 -0
  79. package/dist/holmes/cli/run.js +341 -92
  80. package/dist/holmes/cli/runtime-binding-approval.js +32 -19
  81. package/dist/holmes/cli/screen-safe.d.ts +3 -92
  82. package/dist/holmes/cli/screen-safe.js +18 -756
  83. package/dist/holmes/config/config.d.ts +19 -0
  84. package/dist/holmes/config/config.js +18 -3
  85. package/dist/holmes/cpg/foundation/language-matrix.js +2 -2
  86. package/dist/holmes/cpg/import-resolver.js +1 -1
  87. package/dist/holmes/governance/approval-decisions.d.ts +47 -0
  88. package/dist/holmes/governance/approval-decisions.js +29 -0
  89. package/dist/holmes/governance/approval-grants.d.ts +220 -1
  90. package/dist/holmes/governance/approval-grants.js +612 -33
  91. package/dist/holmes/governance/approval-queue.d.ts +26 -0
  92. package/dist/holmes/governance/approval-queue.js +109 -11
  93. package/dist/holmes/governance/approval-spend.d.ts +95 -0
  94. package/dist/holmes/governance/approval-spend.js +191 -0
  95. package/dist/holmes/governance/autonomous-shell.d.ts +61 -0
  96. package/dist/holmes/governance/autonomous-shell.js +332 -0
  97. package/dist/holmes/governance/autonomy.d.ts +12 -0
  98. package/dist/holmes/governance/autonomy.js +51 -15
  99. package/dist/holmes/governance/constitution.d.ts +5 -0
  100. package/dist/holmes/governance/constitution.js +32 -12
  101. package/dist/holmes/governance/full-autonomy.d.ts +10 -0
  102. package/dist/holmes/governance/full-autonomy.js +103 -7
  103. package/dist/holmes/governance/harness-catalog.d.ts +103 -0
  104. package/dist/holmes/governance/harness-catalog.js +348 -0
  105. package/dist/holmes/governance/human-channel.d.ts +38 -0
  106. package/dist/holmes/governance/human-channel.js +49 -0
  107. package/dist/holmes/governance/install-manifest.d.ts +22 -0
  108. package/dist/holmes/governance/install-manifest.js +160 -0
  109. package/dist/holmes/governance/ledger-rechain.js +2 -0
  110. package/dist/holmes/governance/ledger-store.conformance.d.ts +7 -1
  111. package/dist/holmes/governance/ledger-store.conformance.js +66 -0
  112. package/dist/holmes/governance/ledger-store.d.ts +88 -11
  113. package/dist/holmes/governance/ledger-store.js +186 -8
  114. package/dist/holmes/governance/provenance-chain.d.ts +16 -4
  115. package/dist/holmes/governance/provenance-chain.js +19 -4
  116. package/dist/holmes/governance/provenance-ledger.d.ts +6 -3
  117. package/dist/holmes/governance/provenance-ledger.js +53 -18
  118. package/dist/holmes/governance/push-gate-runner.d.ts +2 -0
  119. package/dist/holmes/governance/push-gate-runner.js +50 -9
  120. package/dist/holmes/governance/push-gate.d.ts +13 -2
  121. package/dist/holmes/governance/push-gate.js +106 -14
  122. package/dist/holmes/governance/recorded-pairs.d.ts +96 -0
  123. package/dist/holmes/governance/recorded-pairs.js +522 -0
  124. package/dist/holmes/governance/replica-id.d.ts +1 -1
  125. package/dist/holmes/governance/replica-id.js +1 -1
  126. package/dist/holmes/governance/spec-seam.d.ts +59 -0
  127. package/dist/holmes/governance/spec-seam.js +587 -0
  128. package/dist/holmes/governance/spend-kinds.d.ts +16 -0
  129. package/dist/holmes/governance/spend-kinds.js +18 -0
  130. package/dist/holmes/guardrail/advisory-line.d.ts +102 -0
  131. package/dist/holmes/guardrail/advisory-line.js +718 -0
  132. package/dist/holmes/guardrail/decision-ledger.d.ts +2 -1
  133. package/dist/holmes/guardrail/decision-ledger.js +2 -1
  134. package/dist/holmes/guardrail/impact-gate.d.ts +7 -0
  135. package/dist/holmes/guardrail/impact-gate.js +33 -6
  136. package/dist/holmes/guardrail/line-continuation.d.ts +8 -0
  137. package/dist/holmes/guardrail/line-continuation.js +39 -0
  138. package/dist/holmes/guardrail/operator-person.d.ts +28 -4
  139. package/dist/holmes/guardrail/operator-person.js +57 -11
  140. package/dist/holmes/guardrail/refusal-codes.d.ts +8 -3
  141. package/dist/holmes/guardrail/refusal-codes.js +64 -10
  142. package/dist/holmes/guardrail/risk-classifier.d.ts +15 -9
  143. package/dist/holmes/guardrail/risk-classifier.js +228 -16
  144. package/dist/holmes/guardrail/risk-gate.d.ts +2 -8
  145. package/dist/holmes/guardrail/risk-gate.js +7 -34
  146. package/dist/holmes/guardrail/risk-types.d.ts +10 -0
  147. package/dist/holmes/guardrail/run-plan-scope.js +3 -1
  148. package/dist/holmes/guardrail/run-refusals.js +24 -8
  149. package/dist/holmes/guardrail/run-stages.d.ts +5 -0
  150. package/dist/holmes/guardrail/run-stages.js +25 -5
  151. package/dist/holmes/guardrail/scope-judgment.js +1 -1
  152. package/dist/holmes/guardrail/shell-words.js +24 -3
  153. package/dist/holmes/guardrail/unresolved-write.d.ts +40 -0
  154. package/dist/holmes/guardrail/unresolved-write.js +556 -0
  155. package/dist/holmes/guardrail/write-target.d.ts +3 -0
  156. package/dist/holmes/guardrail/write-target.js +26 -5
  157. package/dist/holmes/hooks/pre-tool-use.d.ts +116 -1
  158. package/dist/holmes/hooks/pre-tool-use.js +1176 -170
  159. package/dist/holmes/hooks/rtm-refresh-child.d.ts +1 -1
  160. package/dist/holmes/hooks/rtm-refresh-child.js +1 -1
  161. package/dist/holmes/hooks/session-start.js +17 -1
  162. package/dist/holmes/hooks/stop.d.ts +23 -0
  163. package/dist/holmes/hooks/stop.js +86 -33
  164. package/dist/holmes/mcp/approval-adapters.js +3 -1
  165. package/dist/holmes/mcp/approval-commit.js +3 -2
  166. package/dist/holmes/mcp/approval-policy.d.ts +2 -1
  167. package/dist/holmes/mcp/approval-policy.js +3 -1
  168. package/dist/holmes/mcp/handlers/adoption.d.ts +1 -1
  169. package/dist/holmes/mcp/handlers/approval-ask.d.ts +3 -0
  170. package/dist/holmes/mcp/handlers/approval-ask.js +18 -7
  171. package/dist/holmes/mcp/handlers/entity-integration.d.ts +3 -3
  172. package/dist/holmes/mcp/handlers/entity-integration.js +29 -11
  173. package/dist/holmes/mcp/handlers/entity-renumber.d.ts +4 -4
  174. package/dist/holmes/mcp/handlers/entity-renumber.js +29 -11
  175. package/dist/holmes/mcp/handlers/entity-store.d.ts +2 -2
  176. package/dist/holmes/mcp/handlers/entity-store.js +133 -59
  177. package/dist/holmes/mcp/handlers/maintenance-analysis.d.ts +13 -0
  178. package/dist/holmes/mcp/handlers/maintenance-analysis.js +59 -2
  179. package/dist/holmes/mcp/handlers/operator-inspection.d.ts +9 -5
  180. package/dist/holmes/mcp/handlers/operator-inspection.js +79 -16
  181. package/dist/holmes/mcp/handlers/phase-queries.d.ts +1 -1
  182. package/dist/holmes/mcp/handlers/requirement-triage.d.ts +4 -4
  183. package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -2
  184. package/dist/holmes/mcp/handlers/review-evidence.js +35 -11
  185. package/dist/holmes/mcp/handlers/review-queries.d.ts +5 -0
  186. package/dist/holmes/mcp/handlers/review-queries.js +8 -1
  187. package/dist/holmes/mcp/handlers/review-verdict.d.ts +3 -0
  188. package/dist/holmes/mcp/handlers/review-verdict.js +10 -3
  189. package/dist/holmes/mcp/handlers/risk-assessment.d.ts +7 -2
  190. package/dist/holmes/mcp/handlers/risk-assessment.js +34 -12
  191. package/dist/holmes/mcp/handlers/runtime-binding-tool.d.ts +2 -2
  192. package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +6 -1
  193. package/dist/holmes/mcp/handlers/slice-orchestration.js +14 -1
  194. package/dist/holmes/mcp/handlers/spec-approval.d.ts +15 -3
  195. package/dist/holmes/mcp/handlers/spec-approval.js +32 -5
  196. package/dist/holmes/mcp/handlers/spec-authoring.d.ts +2 -2
  197. package/dist/holmes/mcp/handlers/spec-authoring.js +19 -2
  198. package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +11 -38
  199. package/dist/holmes/mcp/handlers/spec-lifecycle.js +441 -94
  200. package/dist/holmes/mcp/handlers/spec-queries.d.ts +2 -2
  201. package/dist/holmes/mcp/handlers/taint-screening.d.ts +1 -1
  202. package/dist/holmes/mcp/handlers/taint-screening.js +2 -2
  203. package/dist/holmes/mcp/handlers/test-execution.d.ts +471 -4
  204. package/dist/holmes/mcp/handlers/test-execution.js +199 -21
  205. package/dist/holmes/mcp/handlers/workspace-queries.d.ts +2 -2
  206. package/dist/holmes/mcp/handlers.d.ts +557 -82
  207. package/dist/holmes/mcp/handlers.js +74 -23
  208. package/dist/holmes/mcp/harness-attestation.d.ts +78 -5
  209. package/dist/holmes/mcp/harness-attestation.js +325 -53
  210. package/dist/holmes/mcp/maintenance-analyze.d.ts +6 -1
  211. package/dist/holmes/mcp/maintenance-analyze.js +13 -11
  212. package/dist/holmes/mcp/maintenance-evidence.d.ts +9 -0
  213. package/dist/holmes/mcp/maintenance-evidence.js +35 -3
  214. package/dist/holmes/mcp/requirement-triage-evidence.js +22 -13
  215. package/dist/holmes/mcp/server-staleness.js +1 -1
  216. package/dist/holmes/mcp/server.js +9 -8
  217. package/dist/holmes/mcp/spec-id-guard.js +1 -1
  218. package/dist/holmes/mcp/tool-schemas.d.ts +13 -0
  219. package/dist/holmes/mcp/tool-schemas.js +42 -9
  220. package/dist/holmes/project/act-root.d.ts +19 -0
  221. package/dist/holmes/project/act-root.js +100 -0
  222. package/dist/holmes/project/baseline.d.ts +15 -2
  223. package/dist/holmes/project/baseline.js +14 -8
  224. package/dist/holmes/project/bounded-group.d.ts +47 -0
  225. package/dist/holmes/project/bounded-group.js +140 -0
  226. package/dist/holmes/project/bounded-io.d.ts +51 -2
  227. package/dist/holmes/project/bounded-io.js +140 -6
  228. package/dist/holmes/project/change-source.d.ts +4 -0
  229. package/dist/holmes/project/change-source.js +14 -6
  230. package/dist/holmes/project/instance-id.d.ts +10 -0
  231. package/dist/holmes/project/instance-id.js +233 -0
  232. package/dist/holmes/project/machine-identity.d.ts +25 -0
  233. package/dist/holmes/project/machine-identity.js +133 -0
  234. package/dist/holmes/project/owned-lock.d.ts +84 -0
  235. package/dist/holmes/project/owned-lock.js +263 -0
  236. package/dist/holmes/project/plain-lock-fs.d.ts +2 -0
  237. package/dist/holmes/project/plain-lock-fs.js +126 -0
  238. package/dist/holmes/project/request-lock.d.ts +85 -0
  239. package/dist/holmes/project/request-lock.js +459 -0
  240. package/dist/holmes/project/root.d.ts +12 -4
  241. package/dist/holmes/project/root.js +29 -8
  242. package/dist/holmes/project/run-records.d.ts +19 -0
  243. package/dist/holmes/project/run-records.js +94 -12
  244. package/dist/holmes/project/screen-text.d.ts +94 -0
  245. package/dist/holmes/project/screen-text.js +763 -0
  246. package/dist/holmes/project/spend-lock.d.ts +82 -0
  247. package/dist/holmes/project/spend-lock.js +413 -0
  248. package/dist/holmes/refresh/freshness-coordinator.d.ts +1 -1
  249. package/dist/holmes/refresh/freshness-coordinator.js +1 -1
  250. package/dist/holmes/review/condition-hunk-replay.js +4 -2
  251. package/dist/holmes/review/confidence-calibration.d.ts +1 -1
  252. package/dist/holmes/review/confidence-calibration.js +1 -1
  253. package/dist/holmes/review/content-verify.js +1 -1
  254. package/dist/holmes/review/evidence-mode.d.ts +21 -0
  255. package/dist/holmes/review/evidence-mode.js +33 -0
  256. package/dist/holmes/review/head-worktree.d.ts +55 -0
  257. package/dist/holmes/review/head-worktree.js +329 -0
  258. package/dist/holmes/review/hop-ablation.d.ts +4 -4
  259. package/dist/holmes/review/hop-ablation.js +5 -5
  260. package/dist/holmes/review/mrp.js +13 -3
  261. package/dist/holmes/review/point-in-time-replay.js +12 -3
  262. package/dist/holmes/review/rank-diagnosis.d.ts +2 -2
  263. package/dist/holmes/review/rank-diagnosis.js +1 -1
  264. package/dist/holmes/review/replay-corpus.d.ts +10 -4
  265. package/dist/holmes/review/replay-corpus.js +25 -9
  266. package/dist/holmes/review/requirement-triage.js +2 -2
  267. package/dist/holmes/review/run-provenance.d.ts +45 -0
  268. package/dist/holmes/review/run-provenance.js +314 -0
  269. package/dist/holmes/review/semantic-arm.d.ts +3 -3
  270. package/dist/holmes/review/semantic-arm.js +3 -3
  271. package/dist/holmes/review/test-evidence.d.ts +174 -0
  272. package/dist/holmes/review/test-evidence.js +330 -2
  273. package/dist/holmes/review/test-outcomes.js +3 -1
  274. package/dist/holmes/review/test-reports.d.ts +94 -0
  275. package/dist/holmes/review/test-reports.js +382 -0
  276. package/dist/holmes/review/test-runner.d.ts +180 -58
  277. package/dist/holmes/review/test-runner.js +560 -324
  278. package/dist/holmes/review/test-selection-breadth.js +2 -2
  279. package/dist/holmes/review/test-units.d.ts +159 -0
  280. package/dist/holmes/review/test-units.js +814 -0
  281. package/dist/holmes/review/verdicts.d.ts +105 -8
  282. package/dist/holmes/review/verdicts.js +640 -36
  283. package/dist/holmes/rtm/anchor-census.d.ts +9 -0
  284. package/dist/holmes/rtm/anchor-census.js +151 -0
  285. package/dist/holmes/rtm/anchor-ids.d.ts +25 -1
  286. package/dist/holmes/rtm/anchor-ids.js +45 -2
  287. package/dist/holmes/rtm/comment-ranges.d.ts +2 -0
  288. package/dist/holmes/rtm/comment-ranges.js +104 -0
  289. package/dist/holmes/rtm/counted-tests.d.ts +1 -0
  290. package/dist/holmes/rtm/counted-tests.js +63 -0
  291. package/dist/holmes/rtm/impact-advisory.d.ts +1 -1
  292. package/dist/holmes/rtm/known-defects.js +1 -1
  293. package/dist/holmes/rtm/localize.js +1 -1
  294. package/dist/holmes/rtm/taint-benchmark.d.ts +1 -1
  295. package/dist/holmes/rtm/taint-vocabulary.d.ts +1 -1
  296. package/dist/holmes/rtm/test-scope.d.ts +31 -0
  297. package/dist/holmes/rtm/test-scope.js +166 -5
  298. package/dist/holmes/rtm/trace-gaps.js +1 -1
  299. package/dist/holmes/runtime/dispatch.d.ts +10 -0
  300. package/dist/holmes/runtime/dispatch.js +12 -1
  301. package/dist/holmes/semantic/cloud-usage.d.ts +1 -1
  302. package/dist/holmes/semantic/cloud-usage.js +1 -1
  303. package/dist/holmes/semantic/unreadable-paths.d.ts +1 -1
  304. package/dist/holmes/semantic/unreadable-paths.js +1 -1
  305. package/dist/holmes/spec/approval-blockers.js +1 -1
  306. package/dist/holmes/spec/entity-store.d.ts +6 -1
  307. package/dist/holmes/spec/entity-store.js +16 -2
  308. package/dist/holmes/spec/entity-transaction.d.ts +7 -2
  309. package/dist/holmes/spec/entity-transaction.js +87 -170
  310. package/dist/holmes/spec/spec-store.d.ts +12 -6
  311. package/dist/holmes/spec/spec-store.js +4 -2
  312. package/dist/holmes/spec/spec-types.js +1 -1
  313. package/dist/holmes/spec/succession-guard.d.ts +56 -0
  314. package/dist/holmes/spec/succession-guard.js +187 -0
  315. package/dist/holmes/spec/succession.d.ts +70 -0
  316. package/dist/holmes/spec/succession.js +171 -0
  317. package/dist/holmes/spec/transition-policy.d.ts +2 -2
  318. package/docs/install-guide.md +9 -3
  319. package/docs/language-support.md +78 -0
  320. package/package.json +4 -3
  321. package/playbooks/author-slice/PLAYBOOK.md +1 -1
  322. package/playbooks/promote-slice/PLAYBOOK.md +5 -1
  323. package/playbooks/publish/PLAYBOOK.md +47 -34
  324. package/dist/holmes/review/manual-baseline.d.ts +0 -209
  325. package/dist/holmes/review/manual-baseline.js +0 -2847
@@ -35,7 +35,7 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.createRiskAssessmentHandlers = createRiskAssessmentHandlers;
37
37
  // @implements A-SPEC-607, A-SPEC-100.2, A-SPEC-128
38
- // @implements A-SPEC-642
38
+ // @implements A-SPEC-642, A-SPEC-245.9
39
39
  const path = __importStar(require("node:path"));
40
40
  const spec_parser_1 = require("../../spec/spec-parser");
41
41
  const rtm_graph_1 = require("../../rtm/rtm-graph");
@@ -45,11 +45,33 @@ const risk_gate_1 = require("../../guardrail/risk-gate");
45
45
  const cspec_change_1 = require("../../guardrail/cspec-change");
46
46
  const provenance_chain_1 = require("../../governance/provenance-chain");
47
47
  const ledger_store_1 = require("../../governance/ledger-store");
48
+ const approval_spend_1 = require("../../governance/approval-spend");
48
49
  const decision_ledger_1 = require("../../guardrail/decision-ledger");
50
+ const human_channel_1 = require("../../governance/human-channel");
49
51
  function createRiskAssessmentHandlers(context) {
50
52
  return {
51
53
  // @implements A-SPEC-125.4
52
- async risk_check(a) {
54
+ async risk_check(raw) {
55
+ // @implements A-SPEC-792.25 — a tool's input never speaks for a person: an approval or actor that claims a
56
+ // person channel is refused outright, and every other actor from the input is recorded as tool-input:<actor>
57
+ // (F1-e.0d: a forged elicitation:claude-code approval was ledgered as a person's)
58
+ if ((0, human_channel_1.isHumanChannelActor)(raw.approval?.actor) || (0, human_channel_1.isHumanChannelActor)(raw.actor)) {
59
+ const assessment = (0, risk_classifier_1.assessRisk)({ ...raw.action });
60
+ const reasons = ['a tool input cannot carry a person\'s approval — a person-channel actor is written only by the server after its form gate'];
61
+ // @implements A-SPEC-792.26 — the refused forgery leaves a trace (nothing is spent): a blocked row by the input
62
+ const claim = (0, human_channel_1.isHumanChannelActor)(raw.approval?.actor) ? raw.approval?.actor : raw.actor;
63
+ const bound = context.boundNonceLedger();
64
+ try {
65
+ new decision_ledger_1.DecisionLedger(bound !== null ? path.join(path.dirname(bound), 'decisions.jsonl') : path.join(raw.root ?? '.', '.ax', 'ledger', 'decisions.jsonl')).record([{
66
+ ts: raw.ts, actor: (0, human_channel_1.toolInputActor)(claim), action: { ...raw.action }, level: assessment.level, decision: 'blocked',
67
+ rationale: raw.rationale ?? '', reasons: ['refused: a person-channel claim from tool input', ...assessment.reasons]
68
+ }]);
69
+ }
70
+ catch { /* 기록 실패가 이미 계산된 판정을 뒤집지 않는다 */ }
71
+ return { assessment, gate: { blocked: true, level: assessment.level, requiresApproval: true, reasons } };
72
+ }
73
+ const a = { ...raw, ...(raw.actor !== undefined ? { actor: (0, human_channel_1.toolInputActor)(raw.actor) } : {}),
74
+ ...(raw.approval ? { approval: { ...raw.approval, actor: (0, human_channel_1.toolInputActor)(raw.approval.actor) } } : {}) };
53
75
  const action = { ...a.action };
54
76
  if (a.root && a.changedSymbols && a.changedSymbols.length) {
55
77
  // @implements A-SPEC-189 §14 (round 13) — the derivation was computed and discarded, so the
@@ -114,22 +136,22 @@ function createRiskAssessmentHandlers(context) {
114
136
  }
115
137
  if (assessment.level === 'hard-hitl' && !gate.blocked && covers && (0, provenance_chain_1.nonceDeclared)(a.approval?.nonce)) {
116
138
  const ledgerFile = context.boundNonceLedger();
117
- let won = false;
139
+ // @implements A-SPEC-245.9 (1b-1) — spent through spendApprovals under the workspace spend lock
140
+ let spent = 'error';
118
141
  try {
119
- won = ledgerFile !== null && (0, provenance_chain_1.consumeNonceExclusively)(String(a.approval.nonce), ledgerFile, {
120
- ts: a.ts, actor: a.approval.actor, kind: 'nonce-consumed',
121
- summary: `consumed single-use approval for: ${coverTarget.kind} ${(0, provenance_chain_1.redactTarget)('command', coverTarget.target)}`.slice(0, 200),
122
- inputs: [(0, provenance_chain_1.nonceFingerprint)(String(a.approval.nonce))], rationale: a.approval.rationale,
123
- authorization: (0, provenance_chain_1.authorizationRef)(a.approval.actor, a.approval.token),
124
- }, { isNonceConsumed: (0, ledger_store_1.nonceConsumedIn)(ledgerFile) });
142
+ spent = ledgerFile === null ? 'error' : (0, approval_spend_1.spendApprovals)((0, approval_spend_1.projectRootOfChain)(ledgerFile), [{
143
+ nonce: String(a.approval.nonce), actor: a.approval.actor,
144
+ summary: `consumed single-use approval for: ${coverTarget.kind} ${(0, provenance_chain_1.redactTarget)('command', coverTarget.target)}`.slice(0, 200),
145
+ rationale: a.approval.rationale, authorization: (0, provenance_chain_1.authorizationRef)(a.approval.actor, a.approval.token),
146
+ }], {});
125
147
  }
126
148
  catch {
127
- won = false;
149
+ spent = 'error';
128
150
  } // 배타 확보 실패 = 허용 불가(fail-closed)
129
- if (!won) {
151
+ if (spent === 'error' || spent.ok === false) {
130
152
  gate = { ...gate, blocked: true, reasons: [...gate.reasons, ledgerFile === null
131
153
  ? '단일 사용 승인(nonce)을 기록할 프로젝트 원장을 확정할 수 없습니다 — 1회성을 보장할 수 없어 거부합니다(.ax 를 가진 프로젝트에 바인딩된 서버에서 호출하십시오)'
132
- : '단일 사용 승인(nonce)이 이미 소비되었습니다 — 재사용은 부재와 같이 거부됩니다'] };
154
+ : (0, approval_spend_1.spendRefusalReason)(spent)] };
133
155
  }
134
156
  }
135
157
  // Honest provenance: a confirm-level action that was NOT blocked but received no COVERING
@@ -44,7 +44,7 @@ export declare function createRuntimeBindingToolHandlers(context: RuntimeBinding
44
44
  ok: boolean;
45
45
  applied: boolean;
46
46
  operation: string;
47
- reason?: undefined;
47
+ readonly reason?: undefined;
48
48
  } | {
49
49
  planDigest: string;
50
50
  conflicts: string[];
@@ -55,7 +55,7 @@ export declare function createRuntimeBindingToolHandlers(context: RuntimeBinding
55
55
  }[];
56
56
  ok: boolean;
57
57
  applied: boolean;
58
- reason?: undefined;
58
+ readonly reason?: undefined;
59
59
  } | {
60
60
  planDigest: string;
61
61
  conflicts: string[];
@@ -59,7 +59,7 @@ export declare function createSliceOrchestrationHandlers(context: SliceOrchestra
59
59
  ok: boolean;
60
60
  specsCreated: string[];
61
61
  unreadable: string[];
62
- reason?: undefined;
62
+ readonly reason?: undefined;
63
63
  existing?: undefined;
64
64
  }>;
65
65
  spec_slice_approve(a: {
@@ -80,6 +80,11 @@ export declare function createSliceOrchestrationHandlers(context: SliceOrchestra
80
80
  targetFile?: string;
81
81
  aspecId?: string;
82
82
  }): Promise<{
83
+ diagnosis?: {
84
+ file: string;
85
+ aspecs: string[];
86
+ reason: string;
87
+ }[] | undefined;
83
88
  ok: boolean;
84
89
  actionsTaken: string[];
85
90
  refused: {
@@ -462,6 +462,19 @@ depends_on:
462
462
  }
463
463
  }
464
464
  }
465
+ // @implements A-SPEC-750.2 — an anchored test file that counts zero is diagnosed, not answered with "nothing to do"
466
+ let diagnosis;
467
+ if (a.aspecId) {
468
+ const family = (id) => id === a.aspecId || id.startsWith(`${a.aspecId}.`);
469
+ try {
470
+ diagnosis = require('../../rtm/test-scope').zeroCountDiagnostics(root).filter((d) => d.aspecs.some(family));
471
+ for (const d of diagnosis)
472
+ actionsTaken.push(`Diagnosed: ${d.file} counts no real cases for ${a.aspecId} (${d.reason}) — ART-4 reads this file as empty; fix the counted shape, do not unseal the spec`);
473
+ }
474
+ catch {
475
+ diagnosis = undefined;
476
+ }
477
+ }
465
478
  const rawHandlers = context.rawHandlersForStore(rawStore);
466
479
  const approveRes = await rawHandlers.spec_slice_approve({ root, sliceName: a.aspecId ?? 'slice' });
467
480
  if (approveRes.approvedSpecs?.length > 0) {
@@ -473,7 +486,7 @@ depends_on:
473
486
  const refused = approveRes.refused ?? [];
474
487
  for (const r of refused)
475
488
  actionsTaken.push(`Refused ${r.id}: ${r.reason}`);
476
- return { ok: refused.length === 0, actionsTaken, refused };
489
+ return { ok: refused.length === 0, actionsTaken, refused, ...(diagnosis ? { diagnosis } : {}) };
477
490
  },
478
491
  };
479
492
  }
@@ -72,18 +72,28 @@ export declare function createSpecApprovalHandlers(context: SpecApprovalContext)
72
72
  reason: string;
73
73
  blockers: string[];
74
74
  approvalIntent?: undefined;
75
+ code?: undefined;
75
76
  conflict?: undefined;
76
77
  } | {
77
78
  ok: boolean;
78
79
  reason: string;
79
80
  blockers?: undefined;
80
81
  approvalIntent?: undefined;
82
+ code?: undefined;
81
83
  conflict?: undefined;
82
84
  } | {
83
85
  ok: boolean;
84
86
  reason: string;
85
87
  approvalIntent: ApprovalIntent;
86
88
  blockers?: undefined;
89
+ code?: undefined;
90
+ conflict?: undefined;
91
+ } | {
92
+ ok: boolean;
93
+ code: string;
94
+ reason: string;
95
+ blockers?: undefined;
96
+ approvalIntent?: undefined;
87
97
  conflict?: undefined;
88
98
  } | {
89
99
  ok: boolean;
@@ -91,6 +101,7 @@ export declare function createSpecApprovalHandlers(context: SpecApprovalContext)
91
101
  conflict: import("../../spec/version-conflict").ConflictDetail;
92
102
  blockers?: undefined;
93
103
  approvalIntent?: undefined;
104
+ code?: undefined;
94
105
  } | {
95
106
  ancestorWarning?: string | undefined;
96
107
  scaffoldWarning?: string | undefined;
@@ -99,7 +110,7 @@ export declare function createSpecApprovalHandlers(context: SpecApprovalContext)
99
110
  advisoryIds?: Partial<Record<string, string>> | undefined;
100
111
  killsAdvisory?: import("../../review/kills-check").KillsAdvisory | undefined;
101
112
  fttFulfilment?: import("../../rtm/ftt-fulfilment").FttFulfilment | undefined;
102
- impactAdvisoryUnavailable?: "unreadable" | "empty" | undefined;
113
+ impactAdvisoryUnavailable?: "empty" | "unreadable" | undefined;
103
114
  impactGraph?: {
104
115
  status: "current" | "stale" | "unverified";
105
116
  sourceCommit: string | null;
@@ -111,9 +122,10 @@ export declare function createSpecApprovalHandlers(context: SpecApprovalContext)
111
122
  approved: string;
112
123
  digest: string;
113
124
  ok?: undefined;
114
- reason?: undefined;
125
+ readonly reason?: undefined;
115
126
  blockers?: undefined;
116
127
  approvalIntent?: undefined;
128
+ code?: undefined;
117
129
  conflict?: undefined;
118
130
  }>;
119
131
  /**
@@ -144,7 +156,7 @@ export declare function createSpecApprovalHandlers(context: SpecApprovalContext)
144
156
  pinned: string[];
145
157
  findings: import("../../spec/validator").Finding[];
146
158
  citations: unknown[];
147
- reason?: undefined;
159
+ readonly reason?: undefined;
148
160
  }>;
149
161
  };
150
162
  /**
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.createSpecApprovalHandlers = createSpecApprovalHandlers;
37
37
  exports.readProjectFile = readProjectFile;
38
38
  // @implements A-SPEC-182.3, A-SPEC-718.3, A-SPEC-770.6, A-SPEC-718.1,A-SPEC-718.2, A-SPEC-718, A-SPEC-551.1, A-SPEC-551.2, A-SPEC-627.1, A-SPEC-622, A-SPEC-100.2, A-SPEC-128, A-SPEC-132, A-SPEC-133, A-SPEC-151, A-SPEC-188, A-SPEC-189, A-SPEC-244, A-SPEC-245, A-SPEC-729, A-SPEC-532.7, A-SPEC-792.1, A-SPEC-792.4
39
- // @implements A-SPEC-631, A-SPEC-733
39
+ // @implements A-SPEC-631, A-SPEC-733, A-SPEC-245.9, A-SPEC-245.15
40
40
  const fs = __importStar(require("node:fs"));
41
41
  const compat_impact_1 = require("../../spec/compat-impact");
42
42
  const path = __importStar(require("node:path"));
@@ -437,10 +437,34 @@ function createSpecApprovalHandlers(context) {
437
437
  // conflict the EDIT wins and the APPROVAL loses: the edit is what a person just wrote; the
438
438
  // approval is an act that can simply be retried. The reverse (the old behaviour) sealed
439
439
  // stale content over a destroyed edit with no notice.
440
+ // @implements A-SPEC-245.3 — the grant is claimed for the seal it authorizes (a second seal on the same grant loses
441
+ // the claim), committed by the write and returned by a refusal or a throw
442
+ const claim = approveResolved.source === 'grant' && approveResolved.root && approveResolved.approval.nonce
443
+ ? (0, approval_grants_1.claimGrant)(approveResolved.root, approveResolved.approval.nonce) : undefined;
444
+ if (claim === null) {
445
+ return { ok: false, code: 'grant-in-use', reason: `the approval grant for sealing ${a.id} is in use by another act — nothing was sealed; retry, or ask for a new approval` };
446
+ }
447
+ let spent = false;
440
448
  try {
441
- await store.write(candidate, { expectedVersion: cur.version });
449
+ // @implements A-SPEC-245.9 (1b-1) — the grant is spent once across replicas where the seal's first byte is
450
+ // written: after the store's version and destination checks, inside the entity-store lock (A-SPEC-245.14)
451
+ await store.write(candidate, { expectedVersion: cur.version, beforePublish: (0, approval_grants_1.grantSpend)(claim ? approveResolved : undefined, `spec-approve ${a.id}`, () => { spent = true; }) });
442
452
  }
443
453
  catch (e) {
454
+ // @implements A-SPEC-245.15 (item 2) — after the spend was recorded the grant is used: committed, never returned
455
+ if (spent) {
456
+ try {
457
+ claim?.commit();
458
+ }
459
+ catch (c) {
460
+ process.stderr.write(`[Holmes-Kit] ${c.message}\n`);
461
+ }
462
+ }
463
+ else
464
+ claim?.release();
465
+ if (e instanceof approval_grants_1.GrantSpendRefusal) {
466
+ return { ok: false, code: 'grant-spend-refused', reason: `${a.id} was not sealed: ${e.message}` };
467
+ }
444
468
  if (e instanceof spec_store_1.SpecVersionConflictError) {
445
469
  // @implements A-SPEC-538.4 — the refusal is unchanged (refuse, write nothing, the edit
446
470
  // wins); it now also CARRIES the conflict: the version this act read, the version now on
@@ -494,9 +518,12 @@ function createSpecApprovalHandlers(context) {
494
518
  }
495
519
  catch { /* a missed routing signal is not a broken seal */ }
496
520
  }
497
- // @implements A-SPEC-245 — single-use: the grant is spent by the seal it authorized.
498
- if (approveResolved.source === 'grant' && approveResolved.root && approveResolved.approval.nonce) {
499
- (0, approval_grants_1.consumeGrantFile)(approveResolved.root, approveResolved.approval.nonce);
521
+ // @implements A-SPEC-245, A-SPEC-245.3 — single-use: the grant is spent by the seal it authorized.
522
+ try {
523
+ claim?.commit();
524
+ }
525
+ catch (e) {
526
+ process.stderr.write(`[Holmes-Kit] ${e.message}\n`);
500
527
  }
501
528
  // @implements A-SPEC-566.2 — the impact advisory rides the SUCCESS, after the seal is done:
502
529
  // the verdict is already committed, so nothing here can change it (advisory, never gate —
@@ -13,7 +13,7 @@ export declare function createSpecAuthoringHandlers(context: SpecAuthoringContex
13
13
  } | {
14
14
  created: any;
15
15
  ok?: undefined;
16
- reason?: undefined;
16
+ readonly reason?: undefined;
17
17
  }>;
18
18
  /**
19
19
  * @implements A-SPEC-184
@@ -52,6 +52,6 @@ export declare function createSpecAuthoringHandlers(context: SpecAuthoringContex
52
52
  type: import("../../spec/spec-types").SpecType;
53
53
  legacyStatus: string;
54
54
  remaining: import("../../spec/validator").Finding[];
55
- reason?: undefined;
55
+ readonly reason?: undefined;
56
56
  }>;
57
57
  };
@@ -116,8 +116,8 @@ function createSpecAuthoringHandlers(context) {
116
116
  // `projectRootOf` below already expands Windows 8.3 aliases (it ends in `canonicalPath`,
117
117
  // i.e. `realpathSync.native`); the JS `fs.realpathSync` that used to stand here does not.
118
118
  // So the same directory arrived under two spellings and the containment test said "another
119
- // project": measured 2026-09-19, `C:\Users\SUNGNA~1\…\probe83` was refused while
120
- // `C:\Users\SungNam Park\…\probe83` — the same directory — created. `change-source.ts`
119
+ // project": measured 2026-09-19, `C:\Users\FIRSTL~1\…\probe83` was refused while
120
+ // `C:\Users\First Last\…\probe83` — the same directory — created. `change-source.ts`
121
121
  // named this rule on 2026-08-23 after the identical failure; this is the same rule, here.
122
122
  const real = (p2) => { try {
123
123
  return (0, root_1.canonicalPath)(p2);
@@ -289,6 +289,23 @@ function createSpecAuthoringHandlers(context) {
289
289
  e.message += spentNote;
290
290
  throw e;
291
291
  }
292
+ // @implements A-SPEC-792.28 — the tool's own record of what it wrote (the provenance a draft is staged on). Best
293
+ // effort: the spec is written; a ledger that cannot take the line leaves the draft unproven, never the act failed.
294
+ // Only into a ledger that already exists beside the store (`<root>/.ax/specs` and `<root>/.ax/ledger`): creating
295
+ // nothing keeps a reader footprint-free (A-SPEC-148) and a store outside .ax unledgered (as before).
296
+ try {
297
+ const specsRoot = store.specsRoot;
298
+ const axDir = typeof specsRoot === 'string' ? path.dirname(path.resolve(specsRoot)) : '';
299
+ const ledgerDir = path.join(axDir, 'ledger');
300
+ if (typeof specsRoot === 'string' && path.basename(path.resolve(specsRoot)) === 'specs' && path.basename(axDir) === '.ax'
301
+ && fs.existsSync(ledgerDir) && fs.lstatSync(ledgerDir).isDirectory()) {
302
+ const { FileLedgerStore } = require('../../governance/ledger-store');
303
+ new FileLedgerStore(ledgerDir).append({
304
+ ts: new Date().toISOString(), actor: 'holmes-kit', kind: 'spec-created', summary: `created ${id}`, inputs: [id],
305
+ });
306
+ }
307
+ }
308
+ catch { /* the draft stays unproven for autonomous staging */ }
292
309
  return { created: id };
293
310
  },
294
311
  /**
@@ -24,7 +24,12 @@ export interface SpecLifecycleContext {
24
24
  why: string;
25
25
  title?: string;
26
26
  }): string;
27
+ fullAutonomyHome?(): string;
27
28
  }
29
+ type Supersession = {
30
+ id: string;
31
+ supersededBy: string;
32
+ };
28
33
  export declare function createSpecLifecycleHandlers(context: SpecLifecycleContext): {
29
34
  /**
30
35
  * Move a document to `outdated` — the only path there.
@@ -47,25 +52,10 @@ export declare function createSpecLifecycleHandlers(context: SpecLifecycleContex
47
52
  root?: string;
48
53
  id: string;
49
54
  reason?: string;
50
- }): Promise<{
51
- ok: boolean;
52
- reason: string;
53
- retired?: undefined;
54
- id?: undefined;
55
- dependents?: undefined;
56
- } | {
57
- ok: boolean;
58
- retired: boolean;
59
- id: string;
60
- dependents: never[];
61
- reason: string;
62
- } | {
63
- ok: boolean;
64
- retired: boolean;
65
- id: string;
66
- dependents: string[];
67
- reason?: undefined;
68
- }>;
55
+ supersededBy?: string;
56
+ directive?: string;
57
+ also?: Supersession[];
58
+ }): Promise<Record<string, unknown>>;
69
59
  /**
70
60
  * @implements A-SPEC-700.2
71
61
  * The plan a person SAW, executed under ONE approval, before the merge. `plan` reads; `apply`
@@ -117,23 +107,6 @@ export declare function createSpecLifecycleHandlers(context: SpecLifecycleContex
117
107
  spec_unseal(a: {
118
108
  root?: string;
119
109
  id: string;
120
- }): Promise<{
121
- ok: boolean;
122
- reason: string;
123
- unsealed?: undefined;
124
- id?: undefined;
125
- dependents?: undefined;
126
- } | {
127
- ok: boolean;
128
- unsealed: boolean;
129
- id: string;
130
- dependents: never[];
131
- reason: string;
132
- } | {
133
- ok: boolean;
134
- unsealed: boolean;
135
- id: string;
136
- dependents: string[];
137
- reason?: undefined;
138
- }>;
110
+ }): Promise<Record<string, unknown>>;
139
111
  };
112
+ export {};