@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,30 @@
1
+ /**
2
+ * The admission configuration (A-SPEC-792.37 §4), read at the range's base commit. JSON with a duplicate-key check:
3
+ * bytes that do not parse or a `version` other than 1 are `incomplete`; a duplicate key, an unknown field, a wrong type
4
+ * or an `autonomous` that is neither absent nor null is `refused` (configuration invalid). There is no spec-root field
5
+ * in 0.40.0. `extraSignatureKinds` only adds `needs-signature` kinds.
6
+ */
7
+ export interface AdmissionConfig {
8
+ version: 1;
9
+ appId: number;
10
+ replicaAllow: string[];
11
+ extraSignatureKinds: string[];
12
+ }
13
+ export type ConfigResult = {
14
+ config: AdmissionConfig;
15
+ } | {
16
+ absent: true;
17
+ } | {
18
+ incomplete: string;
19
+ } | {
20
+ refused: string;
21
+ };
22
+ export declare class DuplicateKey extends Error {
23
+ constructor(key: string);
24
+ }
25
+ /** JSON.parse with one more refusal: an object holding the same key twice (DuplicateKey). */
26
+ export declare function parseStrictJson(text: string): unknown;
27
+ /** The configuration a commit holds, or what stands in its place. */
28
+ export declare function loadConfig(bytes: Buffer | undefined): ConfigResult;
29
+ /** Whether a path matches one `extraSignatureKinds` pattern (`**` any depth, `*` one segment's characters). */
30
+ export declare function matchesKind(pattern: string, path: string): boolean;
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+ // @implements A-SPEC-792.50
3
+ /**
4
+ * The admission configuration (A-SPEC-792.37 §4), read at the range's base commit. JSON with a duplicate-key check:
5
+ * bytes that do not parse or a `version` other than 1 are `incomplete`; a duplicate key, an unknown field, a wrong type
6
+ * or an `autonomous` that is neither absent nor null is `refused` (configuration invalid). There is no spec-root field
7
+ * in 0.40.0. `extraSignatureKinds` only adds `needs-signature` kinds.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.DuplicateKey = void 0;
11
+ exports.parseStrictJson = parseStrictJson;
12
+ exports.loadConfig = loadConfig;
13
+ exports.matchesKind = matchesKind;
14
+ class DuplicateKey extends Error {
15
+ constructor(key) { super(`duplicate key ${JSON.stringify(key)}`); this.name = 'DuplicateKey'; }
16
+ }
17
+ exports.DuplicateKey = DuplicateKey;
18
+ /** JSON.parse with one more refusal: an object holding the same key twice (DuplicateKey). */
19
+ function parseStrictJson(text) {
20
+ let i = 0;
21
+ const ws = () => { while (i < text.length && ' \t\n\r'.includes(text[i]))
22
+ i++; };
23
+ const fail = () => { throw new SyntaxError(`invalid JSON at ${i}`); };
24
+ const str = () => {
25
+ const start = i;
26
+ if (text[i] !== '"')
27
+ fail();
28
+ i++;
29
+ while (i < text.length && text[i] !== '"') {
30
+ if (text[i] === '\\')
31
+ i++;
32
+ i++;
33
+ }
34
+ if (text[i] !== '"')
35
+ fail();
36
+ i++;
37
+ return JSON.parse(text.slice(start, i));
38
+ };
39
+ const value = () => {
40
+ ws();
41
+ const c = text[i];
42
+ if (c === '{') {
43
+ i++;
44
+ const out = Object.create(null);
45
+ const seen = new Set();
46
+ ws();
47
+ if (text[i] === '}') {
48
+ i++;
49
+ return out;
50
+ }
51
+ for (;;) {
52
+ ws();
53
+ const k = str();
54
+ if (seen.has(k))
55
+ throw new DuplicateKey(k);
56
+ seen.add(k);
57
+ ws();
58
+ if (text[i] !== ':')
59
+ fail();
60
+ i++;
61
+ Object.defineProperty(out, k, { value: value(), enumerable: true, writable: true, configurable: true });
62
+ ws();
63
+ if (text[i] === ',') {
64
+ i++;
65
+ continue;
66
+ }
67
+ if (text[i] === '}') {
68
+ i++;
69
+ return out;
70
+ }
71
+ fail();
72
+ }
73
+ }
74
+ if (c === '[') {
75
+ i++;
76
+ const out = [];
77
+ ws();
78
+ if (text[i] === ']') {
79
+ i++;
80
+ return out;
81
+ }
82
+ for (;;) {
83
+ out.push(value());
84
+ ws();
85
+ if (text[i] === ',') {
86
+ i++;
87
+ continue;
88
+ }
89
+ if (text[i] === ']') {
90
+ i++;
91
+ return out;
92
+ }
93
+ fail();
94
+ }
95
+ }
96
+ if (c === '"')
97
+ return str();
98
+ const m = /^(?:true|false|null|-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?)/.exec(text.slice(i));
99
+ if (!m)
100
+ fail();
101
+ i += m[0].length;
102
+ return JSON.parse(m[0]);
103
+ };
104
+ const v = value();
105
+ ws();
106
+ if (i !== text.length)
107
+ fail();
108
+ return v;
109
+ }
110
+ const FIELDS = new Set(['version', 'appId', 'replicaAllow', 'extraSignatureKinds', 'autonomous']);
111
+ const isStringList = (v) => Array.isArray(v) && v.every((x) => typeof x === 'string');
112
+ /** The configuration a commit holds, or what stands in its place. */
113
+ function loadConfig(bytes) {
114
+ if (bytes === undefined)
115
+ return { absent: true };
116
+ let raw;
117
+ try {
118
+ raw = parseStrictJson(bytes.toString('utf8'));
119
+ }
120
+ catch (e) {
121
+ return e instanceof DuplicateKey ? { refused: `configuration invalid: ${e.message}` } : { incomplete: 'configuration does not parse' };
122
+ }
123
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
124
+ return { incomplete: 'configuration does not parse' };
125
+ const o = raw;
126
+ if (o.version !== 1)
127
+ return { incomplete: `configuration version ${JSON.stringify(o.version)} is not 1` };
128
+ const unknown = Object.keys(o).filter((k) => !FIELDS.has(k));
129
+ if (unknown.length > 0)
130
+ return { refused: `configuration invalid: unknown field ${unknown.join(', ')}` };
131
+ if (!Number.isSafeInteger(o.appId) || o.appId <= 0)
132
+ return { refused: 'configuration invalid: appId is not a positive integer' };
133
+ if (o.replicaAllow !== undefined && !isStringList(o.replicaAllow))
134
+ return { refused: 'configuration invalid: replicaAllow is not a list of strings' };
135
+ if (o.extraSignatureKinds !== undefined && !isStringList(o.extraSignatureKinds))
136
+ return { refused: 'configuration invalid: extraSignatureKinds is not a list of strings' };
137
+ if (o.autonomous !== undefined && o.autonomous !== null)
138
+ return { refused: 'configuration invalid: autonomous is not null' };
139
+ return { config: { version: 1, appId: o.appId, replicaAllow: o.replicaAllow ?? [], extraSignatureKinds: o.extraSignatureKinds ?? [] } };
140
+ }
141
+ /** Whether a path matches one `extraSignatureKinds` pattern (`**` any depth, `*` one segment's characters). */
142
+ function matchesKind(pattern, path) {
143
+ const re = new RegExp(`^${pattern.split('**').map((part) => part.split('*').map((s) => s.replace(/[.+?^${}()|[\]\\]/g, '\\$&')).join('[^/]*')).join('.*')}$`);
144
+ return re.test(path);
145
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * One event's judgement (A-SPEC-792.37 §8). Event level, in order (review B-M4): the pin, the range, the configuration,
3
+ * and the canonical wiring at every judged head (the head of both force-push axes is `after`); the first that fails
4
+ * makes the whole event `incomplete` and lists its protected paths with no verdict. A wiring file, or a wiring
5
+ * directory, at a judged head that is not a plain file (mode 100644) or a directory makes the event `incomplete` too
6
+ * (review A-H1: a symlinked wiring file hides a non-canonical target). Entry level: key rules, configuration,
7
+ * findings, the table, parents and relations, on each axis; the stricter wins across levels and axes, and the entry
8
+ * names what decided it. Every path of an id or fold collision is an entry, unchanged ones included (review B-M5).
9
+ * Port failures are answers, never exceptions (review A-M2). The conclusion is always `neutral`. Nothing is kept
10
+ * between events.
11
+ */
12
+ import { AdmissionEvent, Clock, ObjectPort } from './ports';
13
+ import { CONCLUSION, Entry, Verdict } from './verdict';
14
+ import { MAX_DOC_BYTES } from './bounded-reader';
15
+ export interface EventResult {
16
+ conclusion: typeof CONCLUSION;
17
+ reason?: string;
18
+ rangeUndefined: boolean;
19
+ firstInstallation: boolean;
20
+ appIds: {
21
+ base: number | null;
22
+ rollback?: number | null;
23
+ };
24
+ counts: Record<Verdict | 'definition', number>;
25
+ entries: Entry[];
26
+ discarded: string[];
27
+ listedPaths: string[];
28
+ listedTruncated: number;
29
+ }
30
+ export declare function judgeEvent(event: AdmissionEvent, ports: {
31
+ port: ObjectPort;
32
+ clock: Clock;
33
+ }, pin: {
34
+ pinBytes: Buffer | undefined;
35
+ bundleDigest: string;
36
+ }): EventResult;
37
+ export { MAX_DOC_BYTES };
@@ -0,0 +1,251 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_DOC_BYTES = void 0;
4
+ exports.judgeEvent = judgeEvent;
5
+ const verdict_1 = require("./verdict");
6
+ const bounded_reader_1 = require("./bounded-reader");
7
+ Object.defineProperty(exports, "MAX_DOC_BYTES", { enumerable: true, get: function () { return bounded_reader_1.MAX_DOC_BYTES; } });
8
+ const range_resolver_1 = require("./range-resolver");
9
+ const transition_planner_1 = require("./transition-planner");
10
+ const config_loader_1 = require("./config-loader");
11
+ const pin_1 = require("./pin");
12
+ const wiring_1 = require("./wiring");
13
+ const path_rules_1 = require("./path-rules");
14
+ const change_classifier_1 = require("./change-classifier");
15
+ const admission_policy_1 = require("./admission-policy");
16
+ const signature_source_1 = require("./signature-source");
17
+ const blobsOf = (entries) => new Map(entries.filter((e) => e.type !== 'tree').map((e) => [e.path, e]));
18
+ /** The protected changes between two trees: blobs, links and gitlinks, plus ancestors that are not trees. */
19
+ function changesBetween(base, head) {
20
+ const b = new Map(base.map((e) => [e.path, e]));
21
+ const h = new Map(head.map((e) => [e.path, e]));
22
+ const out = [];
23
+ for (const p of new Set([...b.keys(), ...h.keys()])) {
24
+ const kind = (0, path_rules_1.kindOf)(p);
25
+ if (kind === null)
26
+ continue;
27
+ const x = b.get(p), y = h.get(p);
28
+ if (kind === 'ancestor') {
29
+ if ((x?.type ?? 'tree') === 'tree' && (y?.type ?? 'tree') === 'tree')
30
+ continue;
31
+ if (x?.oid === y?.oid && x?.type === y?.type)
32
+ continue;
33
+ out.push({ path: p, kind, base: x, head: y });
34
+ continue;
35
+ }
36
+ if ((x?.type === 'tree' || !x) && (y?.type === 'tree' || !y))
37
+ continue;
38
+ const bx = x?.type === 'tree' ? undefined : x, hy = y?.type === 'tree' ? undefined : y;
39
+ if (bx?.oid === hy?.oid && bx?.mode === hy?.mode)
40
+ continue;
41
+ out.push({ path: p, kind, base: bx, head: hy });
42
+ }
43
+ return out;
44
+ }
45
+ function emptyResult() {
46
+ return { conclusion: verdict_1.CONCLUSION, rangeUndefined: false, firstInstallation: false, appIds: { base: null },
47
+ counts: { admit: 0, 'needs-signature': 0, refused: 0, incomplete: 0, definition: 0 }, entries: [], discarded: [], listedPaths: [], listedTruncated: 0 };
48
+ }
49
+ function judgeEvent(event, ports, pin) {
50
+ const port = (0, bounded_reader_1.guardPort)(ports.port);
51
+ const clock = (0, bounded_reader_1.guardClock)(ports.clock);
52
+ let started;
53
+ try {
54
+ started = new bounded_reader_1.BoundedObjectReader(port, clock);
55
+ }
56
+ catch (e) {
57
+ if (!(e instanceof bounded_reader_1.EventIncomplete))
58
+ throw e;
59
+ }
60
+ if (started === undefined) {
61
+ const out = emptyResult();
62
+ out.reason = 'clock failed';
63
+ return out;
64
+ }
65
+ const reader = started;
66
+ const result = emptyResult();
67
+ void (0, signature_source_1.emptySignatures)(); // 0.40.0 recognises no signature (A-SPEC-792.37 §8)
68
+ /** The protected paths the event lists when it is incomplete as a whole (best effort; a failure lists none). */
69
+ let listing = { paths: [], kinds: [] };
70
+ const listChanges = (pairs) => {
71
+ const seen = new Map();
72
+ for (const pair of pairs)
73
+ for (const c of changesBetween(reader.entries(pair.base), reader.entries(pair.head)))
74
+ if (!seen.has(c.path))
75
+ seen.set(c.path, c);
76
+ const changed = [...seen.values()];
77
+ listing = { paths: changed.map((c) => c.path), kinds: changed.map((c) => c.kind) };
78
+ return changed;
79
+ };
80
+ try {
81
+ // 1. the pin
82
+ const pinAnswer = (0, pin_1.checkPin)(pin.pinBytes, pin.bundleDigest);
83
+ if (!pinAnswer.ok) {
84
+ try {
85
+ listChanges((0, transition_planner_1.planTransitions)((0, range_resolver_1.resolveRange)(event, port)));
86
+ }
87
+ catch (e) {
88
+ if (e instanceof range_resolver_1.DeletedBranch) {
89
+ const held = reader.entries(e.before).filter((x) => x.type !== 'tree' && (0, path_rules_1.kindOf)(x.path) !== null);
90
+ listing = { paths: held.map((x) => x.path), kinds: held.map((x) => (0, path_rules_1.kindOf)(x.path)) };
91
+ }
92
+ }
93
+ throw new bounded_reader_1.EventIncomplete(pinAnswer.reason);
94
+ }
95
+ // 2. the range
96
+ let range;
97
+ try {
98
+ range = (0, range_resolver_1.resolveRange)(event, port);
99
+ }
100
+ catch (e) {
101
+ if (e instanceof range_resolver_1.DeletedBranch) {
102
+ const held = reader.entries(e.before).filter((x) => x.type !== 'tree' && (0, path_rules_1.kindOf)(x.path) !== null);
103
+ listing = { paths: held.map((x) => x.path), kinds: held.map((x) => (0, path_rules_1.kindOf)(x.path)) };
104
+ }
105
+ throw e;
106
+ }
107
+ const pairs = (0, transition_planner_1.planTransitions)(range);
108
+ if (range.kind === 'force' && range.mergeBase === null)
109
+ result.rangeUndefined = true;
110
+ const changed = listChanges(pairs);
111
+ if (changed.length > bounded_reader_1.MAX_ENTRIES)
112
+ throw new bounded_reader_1.EventIncomplete('entry limit');
113
+ // 3. the configuration of each pair
114
+ const configAt = new Map();
115
+ const configFor = (c) => {
116
+ if (configAt.has(c))
117
+ return configAt.get(c);
118
+ let v;
119
+ if (c === null)
120
+ v = { none: true };
121
+ else {
122
+ const e = blobsOf(reader.entries(c)).get(path_rules_1.CONFIG_PATH);
123
+ const r = (0, config_loader_1.loadConfig)(e ? (reader.doc(e.oid) ?? undefined) : undefined);
124
+ if ('incomplete' in r)
125
+ throw new bounded_reader_1.EventIncomplete(r.incomplete);
126
+ v = 'absent' in r ? { absent: `no configuration at ${c}` } : r;
127
+ }
128
+ configAt.set(c, v);
129
+ return v;
130
+ };
131
+ for (const pair of pairs)
132
+ configFor(pair.configAt);
133
+ // 4. the canonical wiring at every judged head
134
+ for (const head of new Set(pairs.map((p) => p.head))) {
135
+ const tree = reader.entries(head);
136
+ const pkg = tree.find((e) => e.path === 'package.json' && e.type === 'blob');
137
+ let devForm = false;
138
+ try {
139
+ devForm = !!pkg && JSON.parse(reader.doc(pkg.oid)?.toString('utf8') ?? '{}').name === '@holmes-lab/holmes-kit';
140
+ }
141
+ catch {
142
+ devForm = false;
143
+ }
144
+ for (const e of tree) {
145
+ if (path_rules_1.WIRING_ANCESTORS.includes((0, path_rules_1.fold)(e.path)) && e.type !== 'tree')
146
+ throw new bounded_reader_1.EventIncomplete('non-canonical harness wiring');
147
+ if (!(0, path_rules_1.isWiring)(e.path) || e.type === 'tree')
148
+ continue;
149
+ if (e.type !== 'blob' || e.mode !== '100644')
150
+ throw new bounded_reader_1.EventIncomplete('non-canonical harness wiring');
151
+ const bytes = reader.doc(e.oid);
152
+ // review 11:19 H2: an exception from the grammar is the event's incomplete, never an escape
153
+ // review 12:32 design: and it names the exception's kind, so a programming error is not read as wiring
154
+ let canonical = false;
155
+ try {
156
+ canonical = bytes !== null && (0, wiring_1.canonicalWiring)(e.path, bytes, { devForm }).ok;
157
+ }
158
+ catch (err) {
159
+ throw new bounded_reader_1.EventIncomplete(`non-canonical harness wiring (the grammar threw ${err instanceof Error ? err.name : typeof err})`);
160
+ }
161
+ if (!canonical)
162
+ throw new bounded_reader_1.EventIncomplete('non-canonical harness wiring');
163
+ }
164
+ }
165
+ const appIdAt = (c) => { const cfg = configFor(c); return 'config' in cfg ? cfg.config.appId : null; };
166
+ result.firstInstallation = range.kind !== 'create' && 'absent' in configFor(pairs[0].configAt);
167
+ result.appIds = range.kind === 'force' && range.mergeBase !== null
168
+ ? { base: appIdAt(range.mergeBase), rollback: appIdAt(range.before) }
169
+ : { base: appIdAt(pairs[0].configAt) };
170
+ // entries
171
+ const contributions = new Map();
172
+ const add = (path, kind, cs) => {
173
+ const slot = contributions.get(path) ?? { kind, list: [] };
174
+ slot.list.push(...cs);
175
+ contributions.set(path, slot);
176
+ };
177
+ for (const pair of pairs) {
178
+ const headTree = reader.entries(pair.head);
179
+ const headBlobs = blobsOf(headTree);
180
+ const headPaths = [...headBlobs.keys()];
181
+ const specPaths = headPaths.filter((p) => (0, path_rules_1.kindOf)(p) === 'spec');
182
+ const specBytes = reader.docs(specPaths.map((p) => headBlobs.get(p).oid));
183
+ const readHead = (p) => { const e = headBlobs.get(p); return (e && (specBytes.get(e.oid) ?? reader.doc(e.oid))) ?? Buffer.alloc(0); };
184
+ const headIndex = (0, change_classifier_1.specIndex)(specPaths, (p) => specBytes.get(headBlobs.get(p).oid) ?? null);
185
+ const collisions = (0, change_classifier_1.foldCollisions)(headPaths.filter((p) => (0, path_rules_1.kindOf)(p) !== null));
186
+ const ctx = { reader, axis: pair.axis, config: configFor(pair.configAt), headIndex, readHead, collisions };
187
+ const changedHere = changesBetween(reader.entries(pair.base), headTree);
188
+ for (const c of changedHere) {
189
+ reader.tick();
190
+ add(c.path, c.kind, (0, admission_policy_1.judgeChange)(c, ctx));
191
+ }
192
+ // every path of a collision a changed path is in, unchanged ones too
193
+ const changedPaths = new Set(changedHere.map((c) => c.path));
194
+ const groups = new Map();
195
+ for (const p of collisions)
196
+ groups.set((0, path_rules_1.fold)(p), [...(groups.get((0, path_rules_1.fold)(p)) ?? []), p]);
197
+ for (const ids of headIndex.values())
198
+ if (ids.length > 1)
199
+ groups.set(`id:${ids.join('|')}`, ids);
200
+ for (const members of groups.values()) {
201
+ if (!members.some((m) => changedPaths.has(m)))
202
+ continue;
203
+ for (const m of members) {
204
+ if (changedPaths.has(m))
205
+ continue;
206
+ add(m, (0, path_rules_1.kindOf)(m) ?? 'ax-other', [{ level: 'key', axis: pair.axis, verdict: 'refused', reason: `a collision with ${members.filter((x) => x !== m).join(', ')}` }]);
207
+ }
208
+ }
209
+ }
210
+ for (const [path, { kind, list: cs }] of contributions) {
211
+ const d = (0, verdict_1.decide)(cs);
212
+ result.entries.push({ path, kind, verdict: d.verdict, ...(d.row !== undefined ? { row: d.row } : {}),
213
+ decision: { level: d.level, ...(d.row !== undefined ? { row: d.row } : {}), reason: d.reason },
214
+ contributing: cs, definition: kind === 'definition', basis: 'policy' });
215
+ }
216
+ result.entries.sort((a, b) => (0, path_rules_1.comparePaths)(a.path, b.path));
217
+ for (const e of result.entries) {
218
+ result.counts[e.verdict]++;
219
+ if (e.definition)
220
+ result.counts.definition++;
221
+ }
222
+ // discarded: what the rollback axis took away
223
+ if (range.kind === 'force') {
224
+ const before = blobsOf(reader.entries(range.before)), after = blobsOf(reader.entries(range.after));
225
+ for (const [p, e] of before) {
226
+ const kind = (0, path_rules_1.kindOf)(p);
227
+ if (kind === null || kind === 'ancestor')
228
+ continue;
229
+ const a = after.get(p);
230
+ const gone = kind === 'ledger' || kind === 'queue' ? !reader.isPrefix(e.oid, a?.oid ?? null) : a?.oid !== e.oid;
231
+ if (gone)
232
+ result.discarded.push(p);
233
+ }
234
+ result.discarded.sort(path_rules_1.comparePaths);
235
+ }
236
+ reader.tick();
237
+ return result;
238
+ }
239
+ catch (e) {
240
+ if (!(e instanceof bounded_reader_1.EventIncomplete))
241
+ throw e;
242
+ const out = emptyResult();
243
+ out.reason = e.reason;
244
+ out.rangeUndefined = e.rangeUndefined;
245
+ const sorted = [...listing.paths].sort(path_rules_1.comparePaths);
246
+ out.listedPaths = sorted.slice(0, bounded_reader_1.MAX_ENTRIES);
247
+ out.listedTruncated = Math.max(0, sorted.length - bounded_reader_1.MAX_ENTRIES);
248
+ out.counts.definition = listing.kinds.filter((k) => k === 'definition').length;
249
+ return out;
250
+ }
251
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Which paths the admission detector protects, and their kinds (A-SPEC-792.37 §2–§3 as draft 13 amends them).
3
+ * Matching is case-folded and NFC, so `.AX/…` is `.ax/…`. One spec root, `.ax/specs`. The harness wiring is a
4
+ * detection definition (row 3), and the wiring directories are ancestors: a tree entry at an ancestor path that is a
5
+ * symlink, a gitlink or a blob is row 1.
6
+ */
7
+ export type Kind = 'ancestor' | 'definition' | 'spec' | 'decision' | 'ledger' | 'queue' | 'audit' | 'ax-other';
8
+ export declare const SPEC_ROOT = ".ax/specs";
9
+ export declare const DETECTOR_WORKFLOWS: readonly string[];
10
+ export declare const CONFIG_PATH = ".github/holmes/admission.json";
11
+ export declare const PIN_PATH = ".github/holmes/verifier.json";
12
+ export declare const QUEUE_PATH = ".ax/approvals/queue.jsonl";
13
+ export declare const ANCESTORS: readonly string[];
14
+ /** The ancestors that are wiring directories: at any judged head they must be directories (review A-H1). */
15
+ export declare const WIRING_ANCESTORS: readonly string[];
16
+ /** Wiring files at fixed paths; wiring prefixes below. */
17
+ export declare const WIRING_FILES: readonly string[];
18
+ export declare const WIRING_PREFIXES: readonly string[];
19
+ /** The tracked `.ax` top-level names this detector knows (a trailing `*` is a prefix). */
20
+ export declare const AX_VOCABULARY: readonly string[];
21
+ /**
22
+ * Case folding for matching, as a case-insensitive file system folds: NFC (which maps U+212A to K), then full case
23
+ * mapping up and down, so U+017F (long s) folds to `s`, the `fi` and `ff` ligatures to `fi` and `ff`, and `ß` to `ss`
24
+ * (review A-C2: APFS opened `ſettings.json` as `settings.json`). NFKC is not applied: a compatibility character such as a
25
+ * full-width letter is a different name to APFS and NTFS, and folding it would invent collisions between distinct files.
26
+ */
27
+ export declare const fold: (p: string) => string;
28
+ export declare const isWiring: (p: string) => boolean;
29
+ /** The kind of a path, or null when it is not protected. */
30
+ export declare function kindOf(p: string): Kind | null;
31
+ /** A ledger's replica id, or null for a legacy ledger. */
32
+ export declare function replicaOf(p: string): string | null;
33
+ export declare const isDetectorWorkflow: (p: string) => boolean;
34
+ /** Sort key: NFC, then UTF-8 bytes. */
35
+ export declare function comparePaths(a: string, b: string): number;
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ // @implements A-SPEC-792.50
3
+ /**
4
+ * Which paths the admission detector protects, and their kinds (A-SPEC-792.37 §2–§3 as draft 13 amends them).
5
+ * Matching is case-folded and NFC, so `.AX/…` is `.ax/…`. One spec root, `.ax/specs`. The harness wiring is a
6
+ * detection definition (row 3), and the wiring directories are ancestors: a tree entry at an ancestor path that is a
7
+ * symlink, a gitlink or a blob is row 1.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.isDetectorWorkflow = exports.isWiring = exports.fold = exports.AX_VOCABULARY = exports.WIRING_PREFIXES = exports.WIRING_FILES = exports.WIRING_ANCESTORS = exports.ANCESTORS = exports.QUEUE_PATH = exports.PIN_PATH = exports.CONFIG_PATH = exports.DETECTOR_WORKFLOWS = exports.SPEC_ROOT = void 0;
11
+ exports.kindOf = kindOf;
12
+ exports.replicaOf = replicaOf;
13
+ exports.comparePaths = comparePaths;
14
+ exports.SPEC_ROOT = '.ax/specs';
15
+ exports.DETECTOR_WORKFLOWS = ['.github/workflows/holmes-admission.yml', '.github/workflows/holmes-admission-audit.yml'];
16
+ exports.CONFIG_PATH = '.github/holmes/admission.json';
17
+ exports.PIN_PATH = '.github/holmes/verifier.json';
18
+ exports.QUEUE_PATH = '.ax/approvals/queue.jsonl';
19
+ exports.ANCESTORS = [
20
+ '.ax', '.github', '.github/workflows', '.github/actions', '.github/holmes', '.claude', '.claude-plugin', '.codex',
21
+ '.agents', '.agents/plugins', '.agent', '_agents', '_agent', '.holmes', '.holmes/codex-plugin',
22
+ ];
23
+ /** The ancestors that are wiring directories: at any judged head they must be directories (review A-H1). */
24
+ exports.WIRING_ANCESTORS = [
25
+ '.claude', '.claude-plugin', '.codex', '.agents', '.agents/plugins', '.agent', '_agents', '_agent', '.holmes', '.holmes/codex-plugin',
26
+ ];
27
+ /** Wiring files at fixed paths; wiring prefixes below. */
28
+ exports.WIRING_FILES = [
29
+ '.mcp.json', '.claude/settings.json', '.claude/settings.local.json', '.codex/config.toml', '.agents/mcp_config.json',
30
+ '.claude-plugin/marketplace.json', '.agents/hooks.json', '.agent/hooks.json', '_agents/hooks.json', '_agent/hooks.json',
31
+ ];
32
+ exports.WIRING_PREFIXES = ['.holmes/codex-plugin/', '.agents/plugins/'];
33
+ const CODEOWNERS = ['codeowners', '.github/codeowners', 'docs/codeowners'];
34
+ /** The tracked `.ax` top-level names this detector knows (a trailing `*` is a prefix). */
35
+ exports.AX_VOCABULARY = [
36
+ 'approvals', 'badges', 'decisions', 'evidence', 'ledger', 'orchestrator_state.json', 'orchestrator.sqlite*', 'roles',
37
+ 'specs', 'state', 'telemetry', 'templates', 'reviews',
38
+ ];
39
+ const AUDIT_PREFIXES = ['.ax/evidence/', '.ax/state/baselines/', '.ax/reviews/'];
40
+ const LEDGER = /^\.ax\/ledger\/[a-z][a-z-]*(?:\.([A-Za-z0-9][A-Za-z0-9._-]{0,63}))?\.jsonl$/i;
41
+ const DECISION = /^\.ax\/decisions\/adr-[0-9]+_[^/]+\.md$/;
42
+ /**
43
+ * Case folding for matching, as a case-insensitive file system folds: NFC (which maps U+212A to K), then full case
44
+ * mapping up and down, so U+017F (long s) folds to `s`, the `fi` and `ff` ligatures to `fi` and `ff`, and `ß` to `ss`
45
+ * (review A-C2: APFS opened `ſettings.json` as `settings.json`). NFKC is not applied: a compatibility character such as a
46
+ * full-width letter is a different name to APFS and NTFS, and folding it would invent collisions between distinct files.
47
+ */
48
+ // review 08:37: lower first, so U+1E9E (capital sharp s, whose upper case is itself) reaches `ß` and then `ss`
49
+ const fold = (p) => p.normalize('NFC').toLowerCase().toUpperCase().toLowerCase();
50
+ exports.fold = fold;
51
+ const isWiring = (p) => {
52
+ const f = (0, exports.fold)(p);
53
+ return exports.WIRING_FILES.includes(f) || exports.WIRING_PREFIXES.some((x) => f.startsWith(x));
54
+ };
55
+ exports.isWiring = isWiring;
56
+ /** The kind of a path, or null when it is not protected. */
57
+ function kindOf(p) {
58
+ const f = (0, exports.fold)(p);
59
+ if (exports.ANCESTORS.includes(f))
60
+ return 'ancestor';
61
+ if (f.startsWith('.github/workflows/') || f.startsWith('.github/actions/') || f === exports.CONFIG_PATH || f === exports.PIN_PATH
62
+ || f === 'ax.config.json' || CODEOWNERS.includes(f) || (0, exports.isWiring)(p))
63
+ return 'definition';
64
+ if (!f.startsWith('.ax/'))
65
+ return null;
66
+ if (f.startsWith(`${exports.SPEC_ROOT}/`) && f.endsWith('.md'))
67
+ return 'spec';
68
+ if (DECISION.test(f))
69
+ return 'decision';
70
+ if (f === exports.QUEUE_PATH)
71
+ return 'queue';
72
+ if (LEDGER.test(p.normalize('NFC')))
73
+ return 'ledger';
74
+ if (AUDIT_PREFIXES.some((x) => f.startsWith(x)))
75
+ return 'audit';
76
+ return 'ax-other';
77
+ }
78
+ /** A ledger's replica id, or null for a legacy ledger. */
79
+ function replicaOf(p) {
80
+ return LEDGER.exec(p.normalize('NFC'))?.[1] ?? null;
81
+ }
82
+ const isDetectorWorkflow = (p) => exports.DETECTOR_WORKFLOWS.includes((0, exports.fold)(p));
83
+ exports.isDetectorWorkflow = isDetectorWorkflow;
84
+ /** Sort key: NFC, then UTF-8 bytes. */
85
+ function comparePaths(a, b) {
86
+ const x = Buffer.from(a.normalize('NFC'), 'utf8'), y = Buffer.from(b.normalize('NFC'), 'utf8');
87
+ return Buffer.compare(x, y);
88
+ }
@@ -0,0 +1,7 @@
1
+ export type PinAnswer = {
2
+ ok: true;
3
+ } | {
4
+ ok: false;
5
+ reason: string;
6
+ };
7
+ export declare function checkPin(pinBytes: Buffer | undefined, bundleDigest: string): PinAnswer;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkPin = checkPin;
4
+ // @implements A-SPEC-792.50
5
+ /**
6
+ * The verifier pin check (A-SPEC-792.37 §3): the caller passes the pin's bytes (read at `github.workflow_sha`, 1c) and
7
+ * the running bundle's digest. An absent or unparseable pin, a `version` other than 1, or a digest that differs makes
8
+ * the whole event `incomplete`; the pin never decides an entry's verdict.
9
+ */
10
+ const config_loader_1 = require("./config-loader");
11
+ function checkPin(pinBytes, bundleDigest) {
12
+ if (pinBytes === undefined)
13
+ return { ok: false, reason: 'pin absent' };
14
+ let pin;
15
+ try {
16
+ pin = (0, config_loader_1.parseStrictJson)(pinBytes.toString('utf8'));
17
+ }
18
+ catch {
19
+ return { ok: false, reason: 'pin does not parse' };
20
+ }
21
+ const p = pin;
22
+ if (typeof p !== 'object' || p === null)
23
+ return { ok: false, reason: 'pin does not parse' };
24
+ if (p.version !== 1)
25
+ return { ok: false, reason: `pin version ${JSON.stringify(p.version)} is not 1` };
26
+ if (p.bundle !== bundleDigest)
27
+ return { ok: false, reason: 'pin bundle digest does not match the running bundle' };
28
+ return { ok: true };
29
+ }