@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
@@ -0,0 +1,332 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.governanceStagingOnly = governanceStagingOnly;
37
+ exports.stagingGrammar = stagingGrammar;
38
+ exports.autonomousShellVerdict = autonomousShellVerdict;
39
+ exports.realShellDeps = realShellDeps;
40
+ exports.renderAutonomousApprovals = renderAutonomousApprovals;
41
+ const crypto = __importStar(require("node:crypto"));
42
+ const fs = __importStar(require("node:fs"));
43
+ const path = __importStar(require("node:path"));
44
+ const spec_parser_1 = require("../spec/spec-parser");
45
+ const succession_1 = require("../spec/succession");
46
+ const spec_seam_1 = require("./spec-seam");
47
+ /** The classifier's two verdicts on staging the governance store (risk-classifier.ts; full-autonomy.ts reads the same). */
48
+ const STAGING_REASONS = [/^staging command reaches changed files in the protected \.ax spec store/, /^shell command over a protected \.ax governance path is not recognisably read-only/];
49
+ function governanceStagingOnly(reasons) {
50
+ return reasons.length > 0 && reasons.every((r) => STAGING_REASONS.some((re) => re.test(r)));
51
+ }
52
+ const PATH_WORD = /^[A-Za-z0-9_./@+,=-]+$/;
53
+ const STATUS_OPTIONS = new Set(['--porcelain', '--porcelain=v1', '-s', '--short', '--untracked-files=all', '-uall']);
54
+ /**
55
+ * @implements A-SPEC-792.33 — a path word in its one canonical spelling: git normalises `.ax/./x`, `.ax//x`,
56
+ * `.ax/a/../x`, `./x`, an absolute path and (on a case-folding disk) `.AX/x` to the file it stages, while the verdict
57
+ * compares spellings — an alias proved nothing and staged a forged file (measured 2026-10-26, in production).
58
+ */
59
+ function canonicalPathWord(w) {
60
+ if (w.startsWith('/') || w.startsWith('./'))
61
+ return false;
62
+ const body = w.endsWith('/') ? w.slice(0, -1) : w;
63
+ if (body === '' || body.split('/').some((s) => s === '' || s === '.' || s === '..'))
64
+ return false;
65
+ if (path.posix.normalize(w) !== w)
66
+ return false;
67
+ const first = body.split('/')[0];
68
+ return !(first.toLowerCase() === '.ax' && first !== '.ax');
69
+ }
70
+ /**
71
+ * Every segment of `rel` that exists under `root` exists in exactly this spelling (a segment that exists in no spelling
72
+ * ends the walk: git then stages nothing new there).
73
+ */
74
+ function exactCaseOnDisk(root, rel) {
75
+ let dir = root;
76
+ for (const seg of rel.replace(/\/+$/, '').split('/')) {
77
+ let names;
78
+ try {
79
+ names = fs.readdirSync(dir);
80
+ }
81
+ catch {
82
+ return true;
83
+ }
84
+ if (names.includes(seg)) {
85
+ dir = path.join(dir, seg);
86
+ continue;
87
+ }
88
+ return !names.some((n) => n.toLowerCase() === seg.toLowerCase());
89
+ }
90
+ return true;
91
+ }
92
+ /** 1. Grammar: `git add|stage` (-A, --all or literal paths), then `&& git status …` with an optional counted pipe. */
93
+ function stagingGrammar(command) {
94
+ const bad = (detail) => ({ ok: false, detail });
95
+ if (/[;$`<>()\n\r\\]|\|\|/.test(command) || /(?:^|[^&])&(?:[^&]|$)/.test(command))
96
+ return bad('an operator, a redirect or a substitution outside the staging grammar');
97
+ const segs = command.split('&&').map((s) => s.trim());
98
+ let pathspecs = null;
99
+ for (const [i, seg] of segs.entries()) {
100
+ const [head, ...pipes] = seg.split('|').map((p) => p.trim());
101
+ const words = head.split(/\s+/).filter(Boolean);
102
+ if (words.some((w) => /["']/.test(w)))
103
+ return bad(`a quote in ${head}`);
104
+ if (words[0] !== 'git')
105
+ return bad(`${words[0] ?? '(empty)'} is not in the staging grammar`);
106
+ if (i === 0) {
107
+ if ((words[1] !== 'add' && words[1] !== 'stage') || pipes.length > 0)
108
+ return bad('the command must start with git add or git stage');
109
+ const args = words.slice(2).filter((w) => w !== '--');
110
+ if (args.length === 0)
111
+ return bad('git add names nothing');
112
+ const all = args.every((a) => a === '-A' || a === '--all');
113
+ if (all) {
114
+ pathspecs = null;
115
+ continue;
116
+ }
117
+ if (!args.every((a) => PATH_WORD.test(a) && !a.startsWith('-') && !a.startsWith(':')))
118
+ return bad('git add takes -A, --all or literal paths only');
119
+ const alias = args.find((a) => !canonicalPathWord(a));
120
+ if (alias !== undefined)
121
+ return bad(`${alias} is not a canonical path (no ./, /./, //, .., leading / or case variant of .ax)`);
122
+ pathspecs = args;
123
+ continue;
124
+ }
125
+ if (words[1] !== 'status' || !words.slice(2).every((w) => STATUS_OPTIONS.has(w) || (PATH_WORD.test(w) && !w.startsWith('-'))))
126
+ return bad(`${head} is not a plain git status`);
127
+ const statusAlias = words.slice(2).find((w) => !STATUS_OPTIONS.has(w) && !canonicalPathWord(w));
128
+ if (statusAlias !== undefined)
129
+ return bad(`${statusAlias} is not a canonical path (no ./, /./, //, .., leading / or case variant of .ax)`);
130
+ for (const p of pipes) {
131
+ if (!/^grep\s+-c\s+(['"])[^'"$`\\]*\1$/.test(p) && !/^wc\s+-l$/.test(p))
132
+ return bad(`${p} is not a counted pipe`);
133
+ }
134
+ }
135
+ return { ok: true, pathspecs };
136
+ }
137
+ const sha256 = (text) => crypto.createHash('sha256').update(text).digest('hex');
138
+ const inputsOf = (e) => (Array.isArray(e.inputs) ? e.inputs.map(String) : []);
139
+ const jsonLines = (text) => text.split('\n').filter((l) => l.trim() !== '').every((l) => {
140
+ try {
141
+ const v = JSON.parse(l);
142
+ return v !== null && typeof v === 'object' && !Array.isArray(v);
143
+ }
144
+ catch {
145
+ return false;
146
+ }
147
+ });
148
+ const PROVERS = [
149
+ { matches: (r) => /^\.ax\/specs\/.+\.md$/.test(r), prove: (r, text, events) => {
150
+ let s;
151
+ try {
152
+ s = (0, spec_parser_1.parseSpec)(text);
153
+ }
154
+ catch {
155
+ return `${r} is not a readable spec`;
156
+ }
157
+ const has = (kind, pred) => events.some((e) => e.kind === kind && pred(inputsOf(e)));
158
+ if (s.status === 'approved') {
159
+ const d = String(s.frontmatter.approved_digest ?? '');
160
+ return (0, succession_1.sealHolds)(s) && has('spec-approved', (i) => i[0] === s.id && i[1] === d) ? null : `${r}: its seal does not hold or no spec-approved event names it`;
161
+ }
162
+ if (s.status === 'outdated')
163
+ return has('spec-retired', (i) => i[0] === s.id) ? null : `${r}: no spec-retired event names ${s.id}`;
164
+ return has('spec-created', (i) => i[0] === s.id) ? null : `${r}: no spec-created event names ${s.id} (written by hand)`;
165
+ } },
166
+ { matches: (r) => /^\.ax\/evidence\/maintenance\/[0-9a-f]{64}\.json$/.test(r), prove: (r, text, events) => {
167
+ const d = `sha256:${path.basename(r, '.json')}`;
168
+ return events.some((e) => e.kind === 'analysis-persisted' && inputsOf(e)[0] === d && inputsOf(e)[1] === `content:${sha256(text)}`) ? null : `${r}: no analysis-persisted event names its content`;
169
+ } },
170
+ { matches: (r) => /^\.ax\/evidence\/requirement-triage\/[0-9a-f]{64}\.json$/.test(r), prove: (r, text, events) => {
171
+ const hex = path.basename(r, '.json');
172
+ return sha256(text) === hex && events.some((e) => e.kind === 'triage-issued' && inputsOf(e)[0] === `sha256:${hex}`) ? null : `${r}: not issued triage evidence`;
173
+ } },
174
+ { matches: (r) => /^\.ax\/state\/baselines\/[^/]+\.json$/.test(r), prove: (r, text, events) => {
175
+ const { baselineDigest } = require('../project/baseline');
176
+ let files;
177
+ try {
178
+ files = JSON.parse(text).files ?? {};
179
+ }
180
+ catch {
181
+ return `${r} is not a readable baseline`;
182
+ }
183
+ const d = baselineDigest(files);
184
+ return events.some((e) => e.kind === 'baseline-recorded' && inputsOf(e)[0] === path.basename(r, '.json') && inputsOf(e)[1] === d) ? null : `${r}: no baseline-recorded event names it`;
185
+ } },
186
+ { matches: (r) => r === '.ax/state/install-manifest.json', prove: (r, _t, _e, deps) => (deps.productProblems([]) === null ? null : `${r}: the manifest is not the one init recorded`) },
187
+ // @implements A-SPEC-222.10 — H-A (b): only this writer's own ledger file; staging another replica's file would put it
188
+ // into HEAD, where the trusted-events port counts it, so a person stages that
189
+ { matches: (r) => /^\.ax\/ledger\/provenance[^/]*\.jsonl$/.test(r), prove: (r, _t, _e, deps) => (r !== deps.ownLedgerFile?.()
190
+ ? `${r} is not this writer's ledger file — staging another replica's ledger goes to a person`
191
+ : deps.chainsVerify() ? null : `${r}: the chain does not verify`) },
192
+ // the weakest proof: an append-only JSON-lines record no agent tool can write (the gate refuses writes under .ax)
193
+ { matches: (r) => /^\.ax\/(?:ledger|approvals|reviews)\/[^/]+\.jsonl$/.test(r), prove: (r, text) => (jsonLines(text) ? null : `${r}: a line is not a JSON object`) },
194
+ ];
195
+ function autonomousShellVerdict(input, deps) {
196
+ const fail = (failed, detail) => ({ ok: false, failed, detail });
197
+ if (input.shellStaging !== 'on')
198
+ return fail('switch', 'autonomy.shellStaging is off');
199
+ // @implements A-SPEC-792.32 — one path base: the verdict resolves pathspecs from the root, so the act must run there (N2)
200
+ if (input.base !== undefined && path.resolve(input.base) !== path.resolve(input.root))
201
+ return fail('base', `the command runs from ${input.base}, not the workspace root; its paths are judged only from the root`);
202
+ const g = stagingGrammar(input.command);
203
+ if (!g.ok)
204
+ return fail('grammar', g.detail);
205
+ // @implements A-SPEC-792.33 — a word spelled otherwise than on disk (a case variant on a case-folding volume) names
206
+ // the file git stages, not the spelling the verdict compares
207
+ const miscased = (g.pathspecs ?? []).find((p) => !exactCaseOnDisk(input.root, p));
208
+ if (miscased !== undefined)
209
+ return fail('grammar', `${miscased} is not spelled as it is on disk`);
210
+ const staged = deps.statusPaths(g.pathspecs);
211
+ if (staged === null)
212
+ return fail('provenance', 'git could not say what the command stages');
213
+ const governance = staged.filter((s) => s.path === '.ax' || s.path.startsWith('.ax/'));
214
+ // @implements A-SPEC-792.31 — safety stop: the spec store goes to a person until its grant has one source of truth,
215
+ // and a staging the gate classed as governance with nothing here to prove is the verdict and the act disagreeing
216
+ if (governance.length === 0)
217
+ return fail('provenance', 'the command stages no governance path this verdict can prove (its paths resolve elsewhere than the root)');
218
+ // 4. reversible: the grammar admits no remote write and no rm; a staged deletion of a governance path is a deletion
219
+ const deleted = governance.filter((s) => s.deleted);
220
+ if (deleted.length > 0)
221
+ return fail('reversible', `the command stages the deletion of ${deleted.slice(0, 3).map((s) => s.path).join(', ')}`);
222
+ // 3. integrity before provenance: a broken record proves nothing
223
+ // @implements A-SPEC-222.10 — and before the product check, which reads the manifest record through the trusted port
224
+ if (!deps.chainsVerify())
225
+ return fail('integrity', 'a provenance chain does not verify');
226
+ const malformed = deps.queueMalformed();
227
+ if (malformed > 0)
228
+ return fail('integrity', `the approval queue has ${malformed} malformed line(s)`);
229
+ const product = deps.productProblems(staged.map((s) => s.path));
230
+ if (product !== null)
231
+ return fail('product-installed', product);
232
+ const events = deps.ledgerEvents();
233
+ // @implements A-SPEC-792.32 — what was proven is named by the bytes that proved it: the recorder writes only this
234
+ const proven = [];
235
+ for (const s of governance) {
236
+ const prover = PROVERS.find((p) => p.matches(s.path));
237
+ if (!prover)
238
+ return fail('provenance', `${s.path} is not an artifact holmes writes`);
239
+ const bytes = deps.readBytes(s.path);
240
+ if (bytes === null)
241
+ return fail('provenance', `${s.path} cannot be read as a regular, non-executable file`);
242
+ const why = prover.prove(s.path, bytes.toString('utf8'), events, deps);
243
+ // @implements A-SPEC-222.9 — an unproven path names the ledger entries that were not trusted
244
+ if (why !== null) {
245
+ const ignored = deps.ignoredEvents?.() ?? '';
246
+ return fail('provenance', ignored ? `${why} (${ignored})` : why);
247
+ }
248
+ proven.push({ path: s.path, blob: (0, spec_seam_1.blobOf)(bytes, deps.objectFormat?.() ?? 'sha1') });
249
+ }
250
+ // @implements A-SPEC-792.31 — last, so every other condition is still named as before: a spec path is out of scope
251
+ // (A-SPEC-792.32: `specStaging` lifts the stop for the tests only; the gate sets it from no environment or config)
252
+ const specsRel = (input.specsRel ?? '.ax/specs').replace(/\/+$/, '');
253
+ const spec = governance.find((s) => s.path === specsRel || s.path.startsWith(`${specsRel}/`));
254
+ if (spec && input.specStaging !== true)
255
+ return fail('scope', `${spec.path} is in the spec store, which autonomous approval does not cover; a person approves spec staging`);
256
+ return { ok: true, paths: governance.map((s) => s.path).sort(), proven, conditions: { grammar: 'pass', reversible: 'pass', 'product-installed': 'pass', integrity: 'pass', provenance: 'pass' } };
257
+ }
258
+ /** The real readers: git in the workspace, its provenance ledger, its queue and its install manifest. */
259
+ function realShellDeps(root) {
260
+ const { FileLedgerStore } = require('./ledger-store');
261
+ const store = new FileLedgerStore(path.join(root, '.ax', 'ledger'));
262
+ // @implements A-SPEC-222.9 — H1: a proof is taken only from trusted events (one port with the gate and spec_retire);
263
+ // read once per verdict
264
+ const { trustedLedgerEvents, describeIgnored } = require('./recorded-pairs');
265
+ let trusted;
266
+ const read = () => {
267
+ if (trusted === undefined) {
268
+ try {
269
+ trusted = trustedLedgerEvents(root);
270
+ }
271
+ catch {
272
+ trusted = { events: [], ignored: [{ file: '.ax/ledger', why: 'the ledger could not be read' }] };
273
+ }
274
+ }
275
+ return trusted;
276
+ };
277
+ return {
278
+ // @implements A-SPEC-792.32 — no `git status` (a racily clean file is re-hashed through the agent's clean filter)
279
+ statusPaths(pathspecs) {
280
+ try {
281
+ return (0, spec_seam_1.worktreeChanges)(root, pathspecs).map((c) => ({ path: c.path, deleted: c.deleted }));
282
+ }
283
+ catch {
284
+ return null;
285
+ }
286
+ },
287
+ ledgerEvents: () => read().events,
288
+ ignoredEvents: () => describeIgnored(read().ignored),
289
+ ownLedgerFile: () => { try {
290
+ return `.ax/ledger/provenance.${store.replicaId()}.jsonl`;
291
+ }
292
+ catch {
293
+ return null;
294
+ } },
295
+ chainsVerify: () => { try {
296
+ return store.verifyAll().ok;
297
+ }
298
+ catch {
299
+ return false;
300
+ } },
301
+ queueMalformed: () => {
302
+ const { readQueue } = require('./approval-queue');
303
+ try {
304
+ return readQueue(root).malformedLines;
305
+ }
306
+ catch {
307
+ return 1;
308
+ }
309
+ },
310
+ productProblems: (staged) => {
311
+ const { productInstalledProblems, describeProductInstalled } = require('./install-manifest');
312
+ const problems = productInstalledProblems(root, staged);
313
+ return problems.length === 0 ? null : describeProductInstalled(problems);
314
+ },
315
+ // @implements A-SPEC-792.30, A-SPEC-792.32 — only a regular, non-executable file proves: a link would prove its
316
+ // target, an executable is not the 100644 entry the seam grants
317
+ readBytes: (rel) => (0, spec_seam_1.grantableBytes)(path.join(root, rel)),
318
+ objectFormat: () => (0, spec_seam_1.objectFormatOf)(root),
319
+ };
320
+ }
321
+ /** For approve --list: the last autonomous shell approvals (time, command digest, path count). */
322
+ function renderAutonomousApprovals(events, limit = 20) {
323
+ const rows = events.filter((e) => e.kind === 'autonomous-shell-approved').slice(-limit);
324
+ if (rows.length === 0)
325
+ return '';
326
+ return ['autonomous shell approvals (A-SPEC-792.28):', ...rows.map((e) => {
327
+ const i = inputsOf(e);
328
+ const cmd = (i.find((x) => x.startsWith('command:')) ?? 'command:?').slice('command:'.length, 'command:'.length + 12);
329
+ const n = (i.find((x) => x.startsWith('count:')) ?? 'count:?').slice('count:'.length);
330
+ return ` auto-approved ${e.ts ?? '?'} command ${cmd} · ${n} governance path(s)`;
331
+ })].join('\n');
332
+ }
@@ -60,9 +60,21 @@ export declare function sessionAutonomyActive(root: string, now: string): boolea
60
60
  /** Whether autonomous approval is enabled — the out-of-band env switch, OR a valid session envelope
61
61
  * (A-SPEC-553.1). `root`/`now` are optional so env-only callers are byte-identical. */
62
62
  export declare function projectDefaultAutonomy(root: string): boolean;
63
+ /**
64
+ * @implements A-SPEC-552.3 — the project default as init and the runtime both read it, so init's question shows the
65
+ * posture the hooks will act on. `undefined`: no `.mcp.json`, or one with no Holmes-Kit entry and no switch (a first
66
+ * install). `true`: any server's env holds a non-empty switch. `false`: everything else — an unreadable or unparsable
67
+ * file (a BOM included), a wrong shape, or a Holmes-Kit entry without the switch.
68
+ */
69
+ export declare function projectAutonomyState(root: string): boolean | undefined;
63
70
  export declare function autonomousApprovalEnabled(env: NodeJS.ProcessEnv, root?: string, now?: string): boolean;
64
71
  /** @implements A-SPEC-792.7 — the full profile covering `root`, as one line (without the banner prefix), or ''. */
65
72
  export declare function fullAutonomyLine(root: string, home?: string): string;
73
+ /**
74
+ * @implements A-SPEC-794.55 — what a full profile does, in one sentence every surface prints: spec staging still goes to a
75
+ * person's form, and push and publish without their flag to the owner.
76
+ */
77
+ export declare const FULL_PROFILE_MEANING = "judgments it covers do not wait for a person; spec staging still goes to a person's form, and push and publish without their flag to the owner";
66
78
  export declare function autonomyBanner(env: NodeJS.ProcessEnv, root: string, now: string, home?: string): string;
67
79
  export declare function autonomyMarkerShouldPrune(root: string, now: string): boolean;
68
80
  export declare function versionBumpKind(from: string, to: string): 'major' | 'minor' | 'patch' | 'none';
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.SESSION_AUTONOMY_MARKER = exports.AUTONOMY_ENV = void 0;
36
+ exports.FULL_PROFILE_MEANING = exports.SESSION_AUTONOMY_MARKER = exports.AUTONOMY_ENV = void 0;
37
37
  exports.isHighRiskPath = isHighRiskPath;
38
38
  exports.descendantAspecs = descendantAspecs;
39
39
  exports.specApprovalAutonomy = specApprovalAutonomy;
@@ -45,13 +45,14 @@ exports.ceilingRefusal = ceilingRefusal;
45
45
  exports.requiresAutonomousApprovalPrompt = requiresAutonomousApprovalPrompt;
46
46
  exports.sessionAutonomyActive = sessionAutonomyActive;
47
47
  exports.projectDefaultAutonomy = projectDefaultAutonomy;
48
+ exports.projectAutonomyState = projectAutonomyState;
48
49
  exports.autonomousApprovalEnabled = autonomousApprovalEnabled;
49
50
  exports.fullAutonomyLine = fullAutonomyLine;
50
51
  exports.autonomyBanner = autonomyBanner;
51
52
  exports.autonomyMarkerShouldPrune = autonomyMarkerShouldPrune;
52
53
  exports.versionBumpKind = versionBumpKind;
53
54
  exports.releaseAutonomy = releaseAutonomy;
54
- // @implements A-SPEC-532.1, A-SPEC-718, A-SPEC-532.3, A-SPEC-532.4, A-SPEC-532.7, A-SPEC-792.7
55
+ // @implements A-SPEC-794.55, A-SPEC-552.3, A-SPEC-552.4,A-SPEC-532.1, A-SPEC-718, A-SPEC-532.3, A-SPEC-532.4, A-SPEC-532.7, A-SPEC-792.7, A-SPEC-794.47, A-SPEC-794.49
55
56
  // Whether a spec approval may be sealed AUTONOMOUSLY by the agent, or must still ask a human through
56
57
  // the MCP elicitation TUI. The governance chain (REQ→H→A→T→CPG + RTM + taint + phase gate) already
57
58
  // forces quality structurally, so a low/mid-risk spec self-approving under an explicitly-enabled
@@ -354,17 +355,47 @@ function sessionAutonomyActive(root, now) {
354
355
  // is agent-write-protected, so this opens no self-grant channel; a live read also removes the
355
356
  // restart-lag footgun (the owner's edit takes effect at the next hook run).
356
357
  function projectDefaultAutonomy(root) {
358
+ return projectAutonomyState(root) === true;
359
+ }
360
+ /**
361
+ * @implements A-SPEC-552.3 — the project default as init and the runtime both read it, so init's question shows the
362
+ * posture the hooks will act on. `undefined`: no `.mcp.json`, or one with no Holmes-Kit entry and no switch (a first
363
+ * install). `true`: any server's env holds a non-empty switch. `false`: everything else — an unreadable or unparsable
364
+ * file (a BOM included), a wrong shape, or a Holmes-Kit entry without the switch.
365
+ */
366
+ function projectAutonomyState(root) {
367
+ const file = path.join(root, '.mcp.json');
368
+ // @implements A-SPEC-552.4 — only a file that is not there at all is a first install; a dangling link is there
357
369
  try {
358
- const parsed = JSON.parse(fs.readFileSync(path.join(root, '.mcp.json'), 'utf8'));
359
- for (const server of Object.values(parsed.mcpServers ?? {})) {
370
+ fs.lstatSync(file);
371
+ }
372
+ catch (e) {
373
+ return e.code === 'ENOENT' ? undefined : false;
374
+ }
375
+ let text;
376
+ try {
377
+ text = fs.readFileSync(file, 'utf8');
378
+ }
379
+ catch {
380
+ return false;
381
+ }
382
+ try {
383
+ const parsed = JSON.parse(text);
384
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
385
+ return false;
386
+ const servers = parsed.mcpServers;
387
+ // A-SPEC-552.4 — `{}` and a non-object `mcpServers` (an array included) are odd files, read as OFF
388
+ if (servers === null || typeof servers !== 'object' || Array.isArray(servers))
389
+ return false;
390
+ for (const server of Object.values(servers)) {
360
391
  const v = server?.env?.[exports.AUTONOMY_ENV];
361
392
  if (typeof v === 'string' && v !== '')
362
393
  return true; // same truthiness convention as the env switch
363
394
  }
364
- return false;
395
+ return 'holmes-kit' in servers ? false : undefined;
365
396
  }
366
397
  catch {
367
- return false; // absent / unparseable file is no signal — never a throw
398
+ return false; // an unparsable file is no signal — never a throw, and never a first install
368
399
  }
369
400
  }
370
401
  function autonomousApprovalEnabled(env, root, now) {
@@ -393,8 +424,13 @@ function fullAutonomyLine(root, home = os.homedir()) {
393
424
  return '';
394
425
  const f = s.entry.flags;
395
426
  const onOff = (b) => (b ? 'on' : 'off');
396
- return `full autonomy: ON (scope ${s.entry.scope}; push ${onOff(f.push)}, publish ${onOff(f.publish)}, architecture ${onOff(f.architecture)}) — no judgment here waits for a person`;
427
+ return `full autonomy: ON (scope ${s.entry.scope}; push ${onOff(f.push)}, publish ${onOff(f.publish)}, architecture ${onOff(f.architecture)}) — ${exports.FULL_PROFILE_MEANING}`;
397
428
  }
429
+ /**
430
+ * @implements A-SPEC-794.55 — what a full profile does, in one sentence every surface prints: spec staging still goes to a
431
+ * person's form, and push and publish without their flag to the owner.
432
+ */
433
+ exports.FULL_PROFILE_MEANING = 'judgments it covers do not wait for a person; spec staging still goes to a person\'s form, and push and publish without their flag to the owner';
398
434
  function autonomyBanner(env, root, now, home) {
399
435
  // @implements A-SPEC-792.7 — an active full profile is named first; without one the banner is what it was.
400
436
  const full = fullAutonomyLine(root, home);
@@ -441,8 +477,8 @@ function autonomyMarkerShouldPrune(root, now) {
441
477
  // @implements A-SPEC-555.1 — the semver bump between two `major.minor.patch` strings (non-numeric
442
478
  // fields read as 0; never throws).
443
479
  // @implements A-SPEC-558.1 — a DOWNGRADE (to < from) is not a normal forward bump; it is treated as
444
- // 'major' so a mis-set lower version can never self-publish (releaseAutonomy sends non-patch/minor
445
- // to a human).
480
+ // 'major' so a mis-set lower version never classifies as low-risk (releaseAutonomy answers 'hitl' for
481
+ // non-patch/minor).
446
482
  function versionBumpKind(from, to) {
447
483
  const tri = (v) => {
448
484
  const [a, b, c] = v.split('.').map((n) => { const x = parseInt(n, 10); return Number.isFinite(x) ? x : 0; });
@@ -462,15 +498,15 @@ function versionBumpKind(from, to) {
462
498
  }
463
499
  // @implements A-SPEC-555.1 — the RELEASE risk verdict, decided by what the release CONTAINS (reusing
464
500
  // the per-spec grade), never by the publish act. npm publish is irreversible + outward, so the
465
- // conservative default is 'hitl': a release self-publishes ONLY when autonomy is on, the bump is not
466
- // major, and every spec is auto-grade; any governance-critical spec, a major bump, or autonomy off
467
- // keeps a human in the loop. Wired below (RED-first).
501
+ // conservative default is 'hitl': the answer is 'auto' ONLY when autonomy is on, the bump is not
502
+ // major, and every spec is auto-grade. No product code calls this (A-SPEC-794.47, measured): nothing
503
+ // self-publishes, and the publish playbook uses these rules to classify the report to the owner.
468
504
  function releaseAutonomy(specs, versionBump, env, root, now) {
469
505
  if (!autonomousApprovalEnabled(env, root, now))
470
- return 'hitl'; // no autonomy ⇒ a human publishes
506
+ return 'hitl';
471
507
  // @implements A-SPEC-558.1 — fail-closed on the edges: an empty/unknown spec set is not positive
472
- // evidence of a low-risk release, and only a positive patch/minor bump self-publishes (a 'major',
473
- // a downgrade-graded-major, or a no-op 'none' all keep a human in the loop).
508
+ // evidence of a low-risk release, and only a positive patch/minor bump answers 'auto' (a 'major',
509
+ // a downgrade-graded-major, or a no-op 'none' all answer 'hitl').
474
510
  if (specs.length === 0)
475
511
  return 'hitl';
476
512
  if (versionBump !== 'patch' && versionBump !== 'minor')
@@ -82,6 +82,11 @@ export interface ConstitutionContext {
82
82
  };
83
83
  /** A-SPEC id -> count of real test cases in anchored test files (H1 syntactic lower bound). */
84
84
  testCasesByAspec?: Record<string, number>;
85
+ /** @implements A-SPEC-750.2 — A-SPEC id -> the anchored files that counted zero, and why. */
86
+ zeroCountCauses?: Record<string, Array<{
87
+ file: string;
88
+ reason: string;
89
+ }>>;
85
90
  /**
86
91
  * A-SPEC id -> cases that ACTUALLY EXECUTED in a recorded PASSING test run.
87
92
  *
@@ -9,6 +9,7 @@ const rtm_check_1 = require("../rtm/rtm-check");
9
9
  // @implements A-SPEC-574.4 — the same detector the design-time advisory calls.
10
10
  const cycle_detect_1 = require("../cpg/cycle-detect");
11
11
  const validator_1 = require("../spec/validator");
12
+ const succession_1 = require("../spec/succession"); // @implements A-SPEC-222.7
12
13
  /**
13
14
  * @implements A-SPEC-534.2
14
15
  * ART-8 RED-first check (pure). For each changed A-SPEC that HAS recorded outcomes, require a
@@ -100,18 +101,37 @@ function verifyConstitution(ctx) {
100
101
  for (const t of governed) {
101
102
  if (t.type !== 'T-SPEC' || t.status !== 'approved')
102
103
  continue;
103
- const aspec = t.dependsOn[0];
104
- if (!aspec)
105
- continue;
106
- // BASELINE (always enforced): the syntactic lower bound. Evidence can never waive it.
107
- if (ctx.testCasesByAspec && (familySum(ctx.testCasesByAspec, aspec) ?? 0) === 0) {
108
- v.push({ article: 'ART-4', detail: `${t.id}: declared coverage but NO anchored test file with real cases for ${aspec} (anchor the covering tests with the @implements marker for ${aspec})` });
109
- continue;
110
- }
111
- // ADDITIVE: a recorded run that covered this A-SPEC and executed nothing is an extra violation.
112
- const executed = familySum(ctx.executedByAspec, aspec);
113
- if (executed === 0) {
114
- v.push({ article: 'ART-4', detail: `${t.id}: a recorded test run covered ${aspec} but EXECUTED no cases` });
104
+ // @implements A-SPEC-222.7 — H1: every A-SPEC the T-SPEC depends on, as the T-SPEC gate reads them (it reads the
105
+ // whole depends_on); a T-SPEC with no A-SPEC edge keeps the first one, as before
106
+ const aspecIds = t.dependsOn.filter((id) => id.startsWith('A-SPEC-'));
107
+ for (const aspec of aspecIds.length > 0 ? aspecIds : t.dependsOn.slice(0, 1)) {
108
+ // BASELINE (always enforced): the syntactic lower bound. Evidence can never waive it.
109
+ if (ctx.testCasesByAspec && (familySum(ctx.testCasesByAspec, aspec) ?? 0) === 0) {
110
+ // @implements A-SPEC-750.2 — a zero is never silent about its cause, and a zero against executed runs is called a
111
+ // suspected counter defect (the floor still holds: it stays a violation)
112
+ const causes = Object.entries(ctx.zeroCountCauses ?? {}).filter(([id]) => id === aspec || id.startsWith(`${aspec}.`)).flatMap(([, c]) => c);
113
+ const why = causes.length > 0 ? ` — anchored file(s) counted zero: ${causes.slice(0, 5).map((c) => `${c.file} (${c.reason})`).join('; ')}` : '';
114
+ const ran = familySum(ctx.executedByAspec, aspec) ?? 0;
115
+ // @implements A-SPEC-222.5 — AU1-d: a T-SPEC whose A-SPEC was superseded, with an approved T-SPEC over the
116
+ // successor, names the autonomous exit (the debt still blocks code writes; only the exit is shown)
117
+ const via = String(resolve(aspec)?.frontmatter?.superseded_by ?? '').trim();
118
+ const succ = resolve(aspec)?.status === 'outdated' && via !== ''
119
+ ? ctx.specs.find((s) => s.type === 'T-SPEC' && s.status === 'approved' && s.id !== t.id && s.dependsOn.includes(via)) : undefined;
120
+ // @implements A-SPEC-222.7 — L4: the exit is the judgment's own answer (the same function spec_retire uses)
121
+ const blocked = succ ? (0, succession_1.tspecSuccessionRefusal)(t, succ, succ.id, ctx.specs, (a) => familySum(ctx.testCasesByAspec, a) ?? 0) : null;
122
+ const exit = !succ ? '' : blocked === null
123
+ ? `; ${aspec} is superseded by ${via} — spec_retire({ id: "${t.id}", supersededBy: "${succ.id}", directive: "<the directive>" }) retires ${t.id} without a person under full autonomy`
124
+ : `; ${aspec} is superseded by ${via}, but there is no autonomous exit to ${succ.id}: ${blocked}`;
125
+ v.push({ article: 'ART-4', detail: (ran > 0
126
+ ? `${t.id}: the syntactic count and the recorded runs disagree for ${aspec} (0 counted, ${ran} executed) — a counter defect is suspected${why}; the floor still holds: make a case head countable or report the defect`
127
+ : `${t.id}: declared coverage but NO anchored test file with real cases for ${aspec}${why} (anchor the covering tests with the @implements marker for ${aspec})`) + exit });
128
+ continue;
129
+ }
130
+ // ADDITIVE: a recorded run that covered this A-SPEC and executed nothing is an extra violation.
131
+ const executed = familySum(ctx.executedByAspec, aspec);
132
+ if (executed === 0) {
133
+ v.push({ article: 'ART-4', detail: `${t.id}: a recorded test run covered ${aspec} but EXECUTED no cases` });
134
+ }
115
135
  }
116
136
  }
117
137
  }
@@ -39,7 +39,15 @@ export type FullShellVerdict = {
39
39
  } | {
40
40
  outcome: 'refuse';
41
41
  route: string;
42
+ } | {
43
+ outcome: 'ask';
42
44
  };
45
+ /**
46
+ * @implements A-SPEC-792.10, A-SPEC-792.11 — whether every clause of `command` is `git add` or `git stage` whose
47
+ * pathspecs are each a literal path inside the spec store. A pipe, a glob, a quote, an option, pathspec magic (a word
48
+ * starting with `:`), a directory above the store, `git commit` or any other clause makes it not spec staging.
49
+ */
50
+ export declare function onlyStagesSpecs(command: string, cwd: string, workspace: string): boolean;
43
51
  /**
44
52
  * @implements A-SPEC-792.5 — what a full scope does with a hard-HITL shell verdict. Every reason must be approvable:
45
53
  * a workspace-local destructive git act, an rm whose every target sits strictly inside the scope or the scratch root,
@@ -54,6 +62,8 @@ export declare function fullModeShellVerdict(input: {
54
62
  scratchRoot: string | null;
55
63
  entry: FullProfileEntry;
56
64
  }): FullShellVerdict;
65
+ /** @implements A-SPEC-794.49, A-SPEC-794.50 — REQ-792's flags: what to do about the first outward act this profile leaves to the owner, or null. */
66
+ export declare function fullModeOutwardRefusal(acts: ReadonlyArray<'push' | 'publish'>, entry: FullProfileEntry): string | null;
57
67
  /** The tail a full-scope refusal carries instead of a queued request (config, secrets, approvals, code under debt). */
58
68
  export declare function fullModeRefusalTail(kind: 'shell' | 'config-write' | 'code-write', route?: string): string;
59
69
  /**