@holmes-lab/holmes-kit 0.39.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (298) hide show
  1. package/CHANGELOG.md +344 -6
  2. package/README.md +54 -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 +202 -424
  65. package/dist/holmes/cli/init.js +33 -0
  66. package/dist/holmes/cli/lock-recover.d.ts +5 -0
  67. package/dist/holmes/cli/lock-recover.js +126 -0
  68. package/dist/holmes/cli/mcp-processes.js +1 -1
  69. package/dist/holmes/cli/release-docs.js +1 -1
  70. package/dist/holmes/cli/run-exec.d.ts +141 -0
  71. package/dist/holmes/cli/run-exec.js +1435 -0
  72. package/dist/holmes/cli/run-provision.d.ts +3 -1
  73. package/dist/holmes/cli/run-provision.js +255 -44
  74. package/dist/holmes/cli/run-wiring.d.ts +69 -0
  75. package/dist/holmes/cli/run-wiring.js +270 -0
  76. package/dist/holmes/cli/run.d.ts +21 -0
  77. package/dist/holmes/cli/run.js +341 -92
  78. package/dist/holmes/cli/runtime-binding-approval.js +32 -19
  79. package/dist/holmes/cli/screen-safe.d.ts +3 -92
  80. package/dist/holmes/cli/screen-safe.js +18 -756
  81. package/dist/holmes/config/config.d.ts +2 -0
  82. package/dist/holmes/config/config.js +5 -2
  83. package/dist/holmes/cpg/foundation/language-matrix.js +2 -2
  84. package/dist/holmes/cpg/import-resolver.js +1 -1
  85. package/dist/holmes/governance/approval-decisions.d.ts +47 -0
  86. package/dist/holmes/governance/approval-decisions.js +29 -0
  87. package/dist/holmes/governance/approval-grants.d.ts +220 -1
  88. package/dist/holmes/governance/approval-grants.js +612 -33
  89. package/dist/holmes/governance/approval-queue.d.ts +26 -0
  90. package/dist/holmes/governance/approval-queue.js +109 -11
  91. package/dist/holmes/governance/approval-spend.d.ts +95 -0
  92. package/dist/holmes/governance/approval-spend.js +191 -0
  93. package/dist/holmes/governance/autonomous-shell.d.ts +61 -0
  94. package/dist/holmes/governance/autonomous-shell.js +332 -0
  95. package/dist/holmes/governance/autonomy.d.ts +5 -0
  96. package/dist/holmes/governance/autonomy.js +16 -11
  97. package/dist/holmes/governance/constitution.d.ts +5 -0
  98. package/dist/holmes/governance/constitution.js +32 -12
  99. package/dist/holmes/governance/full-autonomy.d.ts +10 -0
  100. package/dist/holmes/governance/full-autonomy.js +103 -7
  101. package/dist/holmes/governance/harness-catalog.d.ts +103 -0
  102. package/dist/holmes/governance/harness-catalog.js +348 -0
  103. package/dist/holmes/governance/human-channel.d.ts +38 -0
  104. package/dist/holmes/governance/human-channel.js +49 -0
  105. package/dist/holmes/governance/install-manifest.d.ts +22 -0
  106. package/dist/holmes/governance/install-manifest.js +160 -0
  107. package/dist/holmes/governance/ledger-rechain.js +2 -0
  108. package/dist/holmes/governance/ledger-store.conformance.d.ts +7 -1
  109. package/dist/holmes/governance/ledger-store.conformance.js +66 -0
  110. package/dist/holmes/governance/ledger-store.d.ts +88 -11
  111. package/dist/holmes/governance/ledger-store.js +186 -8
  112. package/dist/holmes/governance/provenance-chain.d.ts +16 -4
  113. package/dist/holmes/governance/provenance-chain.js +19 -4
  114. package/dist/holmes/governance/provenance-ledger.d.ts +6 -3
  115. package/dist/holmes/governance/provenance-ledger.js +53 -18
  116. package/dist/holmes/governance/push-gate-runner.js +11 -7
  117. package/dist/holmes/governance/recorded-pairs.d.ts +96 -0
  118. package/dist/holmes/governance/recorded-pairs.js +522 -0
  119. package/dist/holmes/governance/replica-id.d.ts +1 -1
  120. package/dist/holmes/governance/replica-id.js +1 -1
  121. package/dist/holmes/governance/spec-seam.d.ts +59 -0
  122. package/dist/holmes/governance/spec-seam.js +587 -0
  123. package/dist/holmes/governance/spend-kinds.d.ts +16 -0
  124. package/dist/holmes/governance/spend-kinds.js +18 -0
  125. package/dist/holmes/guardrail/decision-ledger.d.ts +2 -1
  126. package/dist/holmes/guardrail/decision-ledger.js +2 -1
  127. package/dist/holmes/guardrail/impact-gate.d.ts +1 -0
  128. package/dist/holmes/guardrail/impact-gate.js +1 -1
  129. package/dist/holmes/guardrail/line-continuation.d.ts +8 -0
  130. package/dist/holmes/guardrail/line-continuation.js +39 -0
  131. package/dist/holmes/guardrail/operator-person.d.ts +28 -4
  132. package/dist/holmes/guardrail/operator-person.js +57 -11
  133. package/dist/holmes/guardrail/refusal-codes.d.ts +8 -3
  134. package/dist/holmes/guardrail/refusal-codes.js +64 -10
  135. package/dist/holmes/guardrail/risk-classifier.d.ts +15 -9
  136. package/dist/holmes/guardrail/risk-classifier.js +228 -16
  137. package/dist/holmes/guardrail/risk-gate.d.ts +2 -8
  138. package/dist/holmes/guardrail/risk-gate.js +7 -34
  139. package/dist/holmes/guardrail/risk-types.d.ts +10 -0
  140. package/dist/holmes/guardrail/run-plan-scope.js +3 -1
  141. package/dist/holmes/guardrail/run-refusals.js +24 -8
  142. package/dist/holmes/guardrail/run-stages.d.ts +5 -0
  143. package/dist/holmes/guardrail/run-stages.js +25 -5
  144. package/dist/holmes/guardrail/scope-judgment.js +1 -1
  145. package/dist/holmes/guardrail/shell-words.js +24 -3
  146. package/dist/holmes/guardrail/unresolved-write.d.ts +40 -0
  147. package/dist/holmes/guardrail/unresolved-write.js +556 -0
  148. package/dist/holmes/guardrail/write-target.d.ts +3 -0
  149. package/dist/holmes/guardrail/write-target.js +26 -5
  150. package/dist/holmes/hooks/pre-tool-use.d.ts +105 -1
  151. package/dist/holmes/hooks/pre-tool-use.js +1134 -167
  152. package/dist/holmes/hooks/rtm-refresh-child.d.ts +1 -1
  153. package/dist/holmes/hooks/rtm-refresh-child.js +1 -1
  154. package/dist/holmes/hooks/stop.d.ts +23 -0
  155. package/dist/holmes/hooks/stop.js +86 -33
  156. package/dist/holmes/mcp/approval-adapters.js +3 -1
  157. package/dist/holmes/mcp/approval-commit.js +3 -2
  158. package/dist/holmes/mcp/approval-policy.d.ts +2 -1
  159. package/dist/holmes/mcp/approval-policy.js +3 -1
  160. package/dist/holmes/mcp/handlers/adoption.d.ts +1 -1
  161. package/dist/holmes/mcp/handlers/approval-ask.d.ts +3 -0
  162. package/dist/holmes/mcp/handlers/approval-ask.js +18 -7
  163. package/dist/holmes/mcp/handlers/entity-integration.d.ts +3 -3
  164. package/dist/holmes/mcp/handlers/entity-integration.js +29 -11
  165. package/dist/holmes/mcp/handlers/entity-renumber.d.ts +4 -4
  166. package/dist/holmes/mcp/handlers/entity-renumber.js +29 -11
  167. package/dist/holmes/mcp/handlers/entity-store.d.ts +2 -2
  168. package/dist/holmes/mcp/handlers/entity-store.js +133 -59
  169. package/dist/holmes/mcp/handlers/operator-inspection.d.ts +9 -5
  170. package/dist/holmes/mcp/handlers/operator-inspection.js +79 -16
  171. package/dist/holmes/mcp/handlers/phase-queries.d.ts +1 -1
  172. package/dist/holmes/mcp/handlers/requirement-triage.d.ts +4 -4
  173. package/dist/holmes/mcp/handlers/review-evidence.d.ts +2 -2
  174. package/dist/holmes/mcp/handlers/review-evidence.js +35 -11
  175. package/dist/holmes/mcp/handlers/review-queries.d.ts +5 -0
  176. package/dist/holmes/mcp/handlers/review-queries.js +8 -1
  177. package/dist/holmes/mcp/handlers/review-verdict.d.ts +3 -0
  178. package/dist/holmes/mcp/handlers/review-verdict.js +10 -3
  179. package/dist/holmes/mcp/handlers/risk-assessment.d.ts +7 -2
  180. package/dist/holmes/mcp/handlers/risk-assessment.js +34 -12
  181. package/dist/holmes/mcp/handlers/runtime-binding-tool.d.ts +2 -2
  182. package/dist/holmes/mcp/handlers/slice-orchestration.d.ts +6 -1
  183. package/dist/holmes/mcp/handlers/slice-orchestration.js +14 -1
  184. package/dist/holmes/mcp/handlers/spec-approval.d.ts +15 -3
  185. package/dist/holmes/mcp/handlers/spec-approval.js +32 -5
  186. package/dist/holmes/mcp/handlers/spec-authoring.d.ts +2 -2
  187. package/dist/holmes/mcp/handlers/spec-authoring.js +19 -2
  188. package/dist/holmes/mcp/handlers/spec-lifecycle.d.ts +11 -38
  189. package/dist/holmes/mcp/handlers/spec-lifecycle.js +441 -94
  190. package/dist/holmes/mcp/handlers/spec-queries.d.ts +2 -2
  191. package/dist/holmes/mcp/handlers/taint-screening.d.ts +1 -1
  192. package/dist/holmes/mcp/handlers/taint-screening.js +2 -2
  193. package/dist/holmes/mcp/handlers/test-execution.d.ts +1 -1
  194. package/dist/holmes/mcp/handlers/workspace-queries.d.ts +2 -2
  195. package/dist/holmes/mcp/handlers.d.ts +89 -79
  196. package/dist/holmes/mcp/handlers.js +69 -22
  197. package/dist/holmes/mcp/harness-attestation.d.ts +78 -5
  198. package/dist/holmes/mcp/harness-attestation.js +325 -53
  199. package/dist/holmes/mcp/maintenance-analyze.d.ts +1 -1
  200. package/dist/holmes/mcp/maintenance-analyze.js +9 -9
  201. package/dist/holmes/mcp/maintenance-evidence.js +31 -2
  202. package/dist/holmes/mcp/requirement-triage-evidence.js +22 -13
  203. package/dist/holmes/mcp/server-staleness.js +1 -1
  204. package/dist/holmes/mcp/server.js +9 -8
  205. package/dist/holmes/mcp/spec-id-guard.js +1 -1
  206. package/dist/holmes/mcp/tool-schemas.d.ts +13 -0
  207. package/dist/holmes/mcp/tool-schemas.js +29 -2
  208. package/dist/holmes/project/act-root.d.ts +19 -0
  209. package/dist/holmes/project/act-root.js +100 -0
  210. package/dist/holmes/project/baseline.js +4 -3
  211. package/dist/holmes/project/bounded-group.d.ts +47 -0
  212. package/dist/holmes/project/bounded-group.js +140 -0
  213. package/dist/holmes/project/bounded-io.d.ts +50 -2
  214. package/dist/holmes/project/bounded-io.js +138 -6
  215. package/dist/holmes/project/change-source.js +2 -2
  216. package/dist/holmes/project/instance-id.d.ts +10 -0
  217. package/dist/holmes/project/instance-id.js +233 -0
  218. package/dist/holmes/project/machine-identity.d.ts +25 -0
  219. package/dist/holmes/project/machine-identity.js +133 -0
  220. package/dist/holmes/project/owned-lock.d.ts +84 -0
  221. package/dist/holmes/project/owned-lock.js +263 -0
  222. package/dist/holmes/project/plain-lock-fs.d.ts +2 -0
  223. package/dist/holmes/project/plain-lock-fs.js +126 -0
  224. package/dist/holmes/project/request-lock.d.ts +85 -0
  225. package/dist/holmes/project/request-lock.js +459 -0
  226. package/dist/holmes/project/root.d.ts +12 -4
  227. package/dist/holmes/project/root.js +26 -7
  228. package/dist/holmes/project/run-records.d.ts +19 -0
  229. package/dist/holmes/project/run-records.js +94 -12
  230. package/dist/holmes/project/screen-text.d.ts +94 -0
  231. package/dist/holmes/project/screen-text.js +763 -0
  232. package/dist/holmes/project/spend-lock.d.ts +82 -0
  233. package/dist/holmes/project/spend-lock.js +413 -0
  234. package/dist/holmes/refresh/freshness-coordinator.d.ts +1 -1
  235. package/dist/holmes/refresh/freshness-coordinator.js +1 -1
  236. package/dist/holmes/review/condition-hunk-replay.js +4 -2
  237. package/dist/holmes/review/confidence-calibration.d.ts +1 -1
  238. package/dist/holmes/review/confidence-calibration.js +1 -1
  239. package/dist/holmes/review/content-verify.js +1 -1
  240. package/dist/holmes/review/hop-ablation.d.ts +4 -4
  241. package/dist/holmes/review/hop-ablation.js +5 -5
  242. package/dist/holmes/review/point-in-time-replay.js +12 -3
  243. package/dist/holmes/review/rank-diagnosis.d.ts +2 -2
  244. package/dist/holmes/review/rank-diagnosis.js +1 -1
  245. package/dist/holmes/review/replay-corpus.d.ts +10 -4
  246. package/dist/holmes/review/replay-corpus.js +25 -9
  247. package/dist/holmes/review/requirement-triage.js +2 -2
  248. package/dist/holmes/review/semantic-arm.d.ts +3 -3
  249. package/dist/holmes/review/semantic-arm.js +3 -3
  250. package/dist/holmes/review/test-outcomes.js +3 -1
  251. package/dist/holmes/review/test-runner.d.ts +11 -0
  252. package/dist/holmes/review/test-runner.js +31 -10
  253. package/dist/holmes/review/test-selection-breadth.js +2 -2
  254. package/dist/holmes/review/verdicts.d.ts +105 -8
  255. package/dist/holmes/review/verdicts.js +640 -36
  256. package/dist/holmes/rtm/anchor-census.d.ts +9 -0
  257. package/dist/holmes/rtm/anchor-census.js +151 -0
  258. package/dist/holmes/rtm/anchor-ids.d.ts +25 -1
  259. package/dist/holmes/rtm/anchor-ids.js +45 -2
  260. package/dist/holmes/rtm/comment-ranges.d.ts +2 -0
  261. package/dist/holmes/rtm/comment-ranges.js +104 -0
  262. package/dist/holmes/rtm/counted-tests.d.ts +1 -0
  263. package/dist/holmes/rtm/counted-tests.js +63 -0
  264. package/dist/holmes/rtm/impact-advisory.d.ts +1 -1
  265. package/dist/holmes/rtm/known-defects.js +1 -1
  266. package/dist/holmes/rtm/localize.js +1 -1
  267. package/dist/holmes/rtm/taint-benchmark.d.ts +1 -1
  268. package/dist/holmes/rtm/taint-vocabulary.d.ts +1 -1
  269. package/dist/holmes/rtm/test-scope.d.ts +31 -0
  270. package/dist/holmes/rtm/test-scope.js +166 -5
  271. package/dist/holmes/rtm/trace-gaps.js +1 -1
  272. package/dist/holmes/runtime/dispatch.d.ts +10 -0
  273. package/dist/holmes/runtime/dispatch.js +12 -1
  274. package/dist/holmes/semantic/cloud-usage.d.ts +1 -1
  275. package/dist/holmes/semantic/cloud-usage.js +1 -1
  276. package/dist/holmes/semantic/unreadable-paths.d.ts +1 -1
  277. package/dist/holmes/semantic/unreadable-paths.js +1 -1
  278. package/dist/holmes/spec/approval-blockers.js +1 -1
  279. package/dist/holmes/spec/entity-store.d.ts +6 -1
  280. package/dist/holmes/spec/entity-store.js +16 -2
  281. package/dist/holmes/spec/entity-transaction.d.ts +7 -2
  282. package/dist/holmes/spec/entity-transaction.js +87 -170
  283. package/dist/holmes/spec/spec-store.d.ts +12 -6
  284. package/dist/holmes/spec/spec-store.js +4 -2
  285. package/dist/holmes/spec/spec-types.js +1 -1
  286. package/dist/holmes/spec/succession-guard.d.ts +56 -0
  287. package/dist/holmes/spec/succession-guard.js +187 -0
  288. package/dist/holmes/spec/succession.d.ts +70 -0
  289. package/dist/holmes/spec/succession.js +171 -0
  290. package/dist/holmes/spec/transition-policy.d.ts +2 -2
  291. package/docs/install-guide.md +9 -3
  292. package/docs/language-support.md +78 -0
  293. package/package.json +4 -3
  294. package/playbooks/author-slice/PLAYBOOK.md +1 -1
  295. package/playbooks/promote-slice/PLAYBOOK.md +5 -1
  296. package/playbooks/publish/PLAYBOOK.md +45 -33
  297. package/dist/holmes/review/manual-baseline.d.ts +0 -209
  298. package/dist/holmes/review/manual-baseline.js +0 -2847
@@ -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
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The ports of the admission core (A-SPEC-792.50): git objects and graph through `ObjectPort`, time through `Clock`.
3
+ * The core receives bytes and graph answers only through these; it imports no file system, process or network module.
4
+ */
5
+ /** One tree entry of a commit, recursive, trees included (so an ancestor's type is visible). */
6
+ export interface TreeEntry {
7
+ path: string;
8
+ mode: string;
9
+ type: 'blob' | 'tree' | 'commit';
10
+ oid: string;
11
+ }
12
+ export interface ObjectPort {
13
+ /** Every entry of the commit's tree, recursive, trees included. */
14
+ entries(commit: string): TreeEntry[];
15
+ size(oid: string): number;
16
+ /** The blob's bytes, or null when it is larger than `max`. */
17
+ bytes(oid: string, max: number): Buffer | null;
18
+ /** Many blobs in one read (each null when larger than `max`): the head's spec documents for the frontmatter-id index. */
19
+ bytesMany(oids: readonly string[], max: number): Map<string, Buffer | null>;
20
+ /** sha256 hex of the blob's first `length` bytes, read in chunks. */
21
+ prefixSha256(oid: string, length: number): string;
22
+ /** The blob's last byte, or null when it is empty. */
23
+ lastByte(oid: string): number | null;
24
+ /** Short hashes of the blob's lines, in order, or null above `maxLines` lines. */
25
+ lineHashes(oid: string, maxLines: number): string[] | null;
26
+ isAncestor(a: string, b: string): boolean;
27
+ mergeBases(a: string, b: string): string[];
28
+ exists(commit: string): boolean;
29
+ shallow(): boolean;
30
+ }
31
+ export interface Clock {
32
+ now(): number;
33
+ }
34
+ export type Axis = 'single' | 'introduction' | 'rollback';
35
+ export interface PushEvent {
36
+ event: 'push';
37
+ ref: string;
38
+ before: string;
39
+ after: string;
40
+ }
41
+ export interface PullRequestEvent {
42
+ event: 'pull_request_target';
43
+ base: string;
44
+ head: string;
45
+ }
46
+ export type AdmissionEvent = PushEvent | PullRequestEvent;
47
+ /** A zero object id (a branch creation's `before`, a deletion's `after`), SHA-1 or SHA-256. */
48
+ export declare const isZero: (oid: string) => boolean;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ // @implements A-SPEC-792.50
3
+ /**
4
+ * The ports of the admission core (A-SPEC-792.50): git objects and graph through `ObjectPort`, time through `Clock`.
5
+ * The core receives bytes and graph answers only through these; it imports no file system, process or network module.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.isZero = void 0;
9
+ /** A zero object id (a branch creation's `before`, a deletion's `after`), SHA-1 or SHA-256. */
10
+ const isZero = (oid) => /^(?:0{40}|0{64})$/.test(oid);
11
+ exports.isZero = isZero;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The range of an event (A-SPEC-792.37 §5). A push is a fast-forward, a force push (with or without one merge base), a
3
+ * branch creation or a deletion; a pull request is `merge-base(base, head)..head`. A range that cannot be judged as an
4
+ * ordinary range — both sides zero, a missing object, a shallow repository, a deletion — is the event's `incomplete`
5
+ * with `rangeUndefined`. No single merge base is a force push judged on its rollback axis alone, also `rangeUndefined`.
6
+ */
7
+ import { AdmissionEvent, ObjectPort } from './ports';
8
+ import { EventIncomplete } from './bounded-reader';
9
+ export type Range = {
10
+ kind: 'fast-forward';
11
+ before: string;
12
+ after: string;
13
+ } | {
14
+ kind: 'force';
15
+ before: string;
16
+ after: string;
17
+ mergeBase: string | null;
18
+ } | {
19
+ kind: 'create';
20
+ after: string;
21
+ } | {
22
+ kind: 'pr';
23
+ base: string;
24
+ head: string;
25
+ mergeBase: string;
26
+ };
27
+ /** The range, or throws EventIncomplete. A deletion throws with its `before` for the listing. */
28
+ export declare class DeletedBranch extends EventIncomplete {
29
+ readonly before: string;
30
+ constructor(before: string);
31
+ }
32
+ export declare function resolveRange(event: AdmissionEvent, port: ObjectPort): Range;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeletedBranch = void 0;
4
+ exports.resolveRange = resolveRange;
5
+ // @implements A-SPEC-792.50
6
+ /**
7
+ * The range of an event (A-SPEC-792.37 §5). A push is a fast-forward, a force push (with or without one merge base), a
8
+ * branch creation or a deletion; a pull request is `merge-base(base, head)..head`. A range that cannot be judged as an
9
+ * ordinary range — both sides zero, a missing object, a shallow repository, a deletion — is the event's `incomplete`
10
+ * with `rangeUndefined`. No single merge base is a force push judged on its rollback axis alone, also `rangeUndefined`.
11
+ */
12
+ const ports_1 = require("./ports");
13
+ const bounded_reader_1 = require("./bounded-reader");
14
+ /** The range, or throws EventIncomplete. A deletion throws with its `before` for the listing. */
15
+ class DeletedBranch extends bounded_reader_1.EventIncomplete {
16
+ before;
17
+ constructor(before) {
18
+ super('branch deleted', true);
19
+ this.before = before;
20
+ }
21
+ }
22
+ exports.DeletedBranch = DeletedBranch;
23
+ function resolveRange(event, port) {
24
+ if (port.shallow())
25
+ throw new bounded_reader_1.EventIncomplete('shallow repository', true);
26
+ if (event.event === 'pull_request_target') {
27
+ for (const c of [event.base, event.head])
28
+ if (!port.exists(c))
29
+ throw new bounded_reader_1.EventIncomplete('missing object', true);
30
+ const mbs = port.mergeBases(event.base, event.head);
31
+ if (mbs.length !== 1)
32
+ throw new bounded_reader_1.EventIncomplete('range undefined: no single merge base', true);
33
+ return { kind: 'pr', base: event.base, head: event.head, mergeBase: mbs[0] };
34
+ }
35
+ const { before, after } = event;
36
+ if ((0, ports_1.isZero)(before) && (0, ports_1.isZero)(after))
37
+ throw new bounded_reader_1.EventIncomplete('zero on both sides', true);
38
+ if ((0, ports_1.isZero)(after)) {
39
+ if (!port.exists(before))
40
+ throw new bounded_reader_1.EventIncomplete('missing object', true);
41
+ throw new DeletedBranch(before);
42
+ }
43
+ if (!port.exists(after) || (!(0, ports_1.isZero)(before) && !port.exists(before)))
44
+ throw new bounded_reader_1.EventIncomplete('missing object', true);
45
+ if ((0, ports_1.isZero)(before))
46
+ return { kind: 'create', after };
47
+ if (port.isAncestor(before, after))
48
+ return { kind: 'fast-forward', before, after };
49
+ const mbs = port.mergeBases(before, after);
50
+ return { kind: 'force', before, after, mergeBase: mbs.length === 1 ? mbs[0] : null };
51
+ }
@@ -0,0 +1 @@
1
+ export declare function selfContainmentFindings(bytes: Buffer): string[];