kibi-cli 2.31.1 → 2.35.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 (302) hide show
  1. package/dist/cli-register-proof.d.ts.map +1 -1
  2. package/dist/cli-register-proof.js +19 -7
  3. package/dist/cli-register-reporting.d.ts.map +1 -1
  4. package/dist/cli-register-reporting.js +2 -0
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +5 -1
  7. package/dist/commands/check-generated.d.ts +5 -1
  8. package/dist/commands/check-generated.d.ts.map +1 -1
  9. package/dist/commands/check-generated.js +24 -35
  10. package/dist/commands/check.d.ts +1 -0
  11. package/dist/commands/check.d.ts.map +1 -1
  12. package/dist/commands/check.js +14 -5
  13. package/dist/commands/discovery-table.d.ts.map +1 -1
  14. package/dist/commands/discovery-table.js +51 -4
  15. package/dist/commands/doctor.js +19 -4
  16. package/dist/commands/init-helpers.d.ts.map +1 -1
  17. package/dist/commands/init-helpers.js +8 -5
  18. package/dist/commands/migrate.d.ts.map +1 -1
  19. package/dist/commands/migrate.js +109 -5
  20. package/dist/commands/prove.d.ts +48 -1
  21. package/dist/commands/prove.d.ts.map +1 -1
  22. package/dist/commands/prove.js +293 -8
  23. package/dist/commands/report.d.ts +1 -0
  24. package/dist/commands/report.d.ts.map +1 -1
  25. package/dist/commands/report.js +70 -5
  26. package/dist/commands/signoff.d.ts.map +1 -1
  27. package/dist/commands/signoff.js +20 -1
  28. package/dist/commands/sync/manifest.d.ts +10 -1
  29. package/dist/commands/sync/manifest.d.ts.map +1 -1
  30. package/dist/commands/sync/manifest.js +106 -17
  31. package/dist/commands/sync/persistence.d.ts.map +1 -1
  32. package/dist/commands/sync/persistence.js +16 -5
  33. package/dist/commands/sync.d.ts.map +1 -1
  34. package/dist/commands/sync.js +19 -0
  35. package/dist/diagnostics.js +1 -1
  36. package/dist/engine.js +1 -1
  37. package/dist/extractors/markdown.d.ts +4 -2
  38. package/dist/extractors/markdown.d.ts.map +1 -1
  39. package/dist/extractors/markdown.js +17 -0
  40. package/dist/extractors/symbol-coordinates.js +2 -2
  41. package/dist/extractors/symbols-coordinator.d.ts +2 -4
  42. package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
  43. package/dist/extractors/symbols-coordinator.js +1 -2
  44. package/dist/operations/bootstrap/candidate-helpers.d.ts +3 -0
  45. package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
  46. package/dist/operations/bootstrap/candidate-helpers.js +4 -0
  47. package/dist/operations/migration/evidence-floor.d.ts +41 -0
  48. package/dist/operations/migration/evidence-floor.d.ts.map +1 -0
  49. package/dist/operations/migration/evidence-floor.js +230 -0
  50. package/dist/operations/migration/proof-contract-claims.d.ts +72 -0
  51. package/dist/operations/migration/proof-contract-claims.d.ts.map +1 -0
  52. package/dist/operations/migration/proof-contract-claims.js +215 -0
  53. package/dist/operations/migration/schema6.d.ts +6 -0
  54. package/dist/operations/migration/schema6.d.ts.map +1 -1
  55. package/dist/operations/migration/schema6.js +92 -0
  56. package/dist/operations/migration/symbol-coordinates-refresh.d.ts +3 -2
  57. package/dist/operations/migration/symbol-coordinates-refresh.d.ts.map +1 -1
  58. package/dist/operations/migration/symbol-coordinates-refresh.js +4 -3
  59. package/dist/operations/migration/untrack-symbol-coordinates.d.ts +23 -0
  60. package/dist/operations/migration/untrack-symbol-coordinates.d.ts.map +1 -0
  61. package/dist/operations/migration/untrack-symbol-coordinates.js +67 -0
  62. package/dist/operations/modeling/requirement-modeler.d.ts.map +1 -1
  63. package/dist/operations/modeling/requirement-modeler.js +48 -1
  64. package/dist/operations/modeling/requirement-types.d.ts +2 -1
  65. package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
  66. package/dist/operations/modeling/requirement-utils.d.ts +1 -1
  67. package/dist/operations/modeling/requirement-utils.d.ts.map +1 -1
  68. package/dist/operations/modeling/requirement-utils.js +8 -1
  69. package/dist/operations/mutation/omitted-properties.d.ts +11 -0
  70. package/dist/operations/mutation/omitted-properties.d.ts.map +1 -0
  71. package/dist/operations/mutation/omitted-properties.js +76 -0
  72. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  73. package/dist/operations/mutation/serialization.js +1 -0
  74. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  75. package/dist/operations/mutation/source-authoring.js +39 -20
  76. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  77. package/dist/operations/mutation/strict-fact.js +6 -2
  78. package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
  79. package/dist/operations/mutation/symbol-granularity.js +5 -3
  80. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  81. package/dist/operations/mutation/upsert.js +7 -1
  82. package/dist/operations/mutation/validation.d.ts +2 -0
  83. package/dist/operations/mutation/validation.d.ts.map +1 -1
  84. package/dist/operations/mutation/validation.js +4 -0
  85. package/dist/operations/proof/claim-bindings.d.ts +41 -0
  86. package/dist/operations/proof/claim-bindings.d.ts.map +1 -0
  87. package/dist/operations/proof/claim-bindings.js +364 -0
  88. package/dist/operations/proof/code-certificates.d.ts +155 -0
  89. package/dist/operations/proof/code-certificates.d.ts.map +1 -0
  90. package/dist/operations/proof/code-certificates.js +894 -0
  91. package/dist/operations/proof/code-models.d.ts +96 -0
  92. package/dist/operations/proof/code-models.d.ts.map +1 -0
  93. package/dist/operations/proof/code-models.js +601 -0
  94. package/dist/operations/proof/code-runner.d.ts +40 -0
  95. package/dist/operations/proof/code-runner.d.ts.map +1 -0
  96. package/dist/operations/proof/code-runner.js +164 -0
  97. package/dist/operations/proof/code-scope.d.ts +14 -1
  98. package/dist/operations/proof/code-scope.d.ts.map +1 -1
  99. package/dist/operations/proof/code-scope.js +44 -2
  100. package/dist/operations/proof/compact-receipts.d.ts.map +1 -1
  101. package/dist/operations/proof/compact-receipts.js +4 -3
  102. package/dist/operations/proof/explain.d.ts +32 -0
  103. package/dist/operations/proof/explain.d.ts.map +1 -1
  104. package/dist/operations/proof/explain.js +91 -0
  105. package/dist/operations/proof/ingest-proof.d.ts +9 -1
  106. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  107. package/dist/operations/proof/ingest-proof.js +42 -2
  108. package/dist/operations/proof/receipt-compaction.d.ts +2 -0
  109. package/dist/operations/proof/receipt-compaction.d.ts.map +1 -1
  110. package/dist/operations/proof/receipt-compaction.js +6 -2
  111. package/dist/operations/proof/regular-language.d.ts +89 -0
  112. package/dist/operations/proof/regular-language.d.ts.map +1 -0
  113. package/dist/operations/proof/regular-language.js +943 -0
  114. package/dist/operations/proof/source-code-readers.d.ts +12 -0
  115. package/dist/operations/proof/source-code-readers.d.ts.map +1 -0
  116. package/dist/operations/proof/source-code-readers.js +699 -0
  117. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  118. package/dist/operations/semantic-advisor/analyze-prose.js +2 -1
  119. package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
  120. package/dist/operations/semantic-advisor/shared.js +4 -0
  121. package/dist/operations/semantic-advisor/strict-count-rules.d.ts.map +1 -1
  122. package/dist/operations/semantic-advisor/strict-count-rules.js +8 -2
  123. package/dist/operations/semantic-advisor/strict-rules.d.ts +8 -0
  124. package/dist/operations/semantic-advisor/strict-rules.d.ts.map +1 -1
  125. package/dist/operations/semantic-advisor/strict-rules.js +234 -4
  126. package/dist/operations/semantic-advisor/types.d.ts +3 -2
  127. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  128. package/dist/plugins/approved-source-analyzers.generated.d.ts +6 -6
  129. package/dist/plugins/approved-source-analyzers.generated.js +6 -6
  130. package/dist/prolog.d.ts.map +1 -1
  131. package/dist/prolog.js +13 -3
  132. package/dist/proof/command-test-report.d.ts +4 -3
  133. package/dist/proof/command-test-report.d.ts.map +1 -1
  134. package/dist/proof/command-test-report.js +4 -10
  135. package/dist/proof/evaluate.d.ts.map +1 -1
  136. package/dist/proof/evaluate.js +18 -2
  137. package/dist/proof/inspect.d.ts.map +1 -1
  138. package/dist/proof/inspect.js +58 -0
  139. package/dist/proof/producers/playwright-reporter.d.ts +3 -0
  140. package/dist/proof/producers/playwright-reporter.d.ts.map +1 -1
  141. package/dist/proof/producers/playwright-reporter.js +25 -2
  142. package/dist/proof/step-runner.d.ts +36 -0
  143. package/dist/proof/step-runner.d.ts.map +1 -0
  144. package/dist/proof/step-runner.js +234 -0
  145. package/dist/public/evidence-levels.d.ts +12 -0
  146. package/dist/public/evidence-levels.d.ts.map +1 -0
  147. package/dist/public/evidence-levels.js +19 -0
  148. package/dist/public/impact/coverage-depth-quality.d.ts +7 -0
  149. package/dist/public/impact/coverage-depth-quality.d.ts.map +1 -1
  150. package/dist/public/impact/coverage-depth-quality.js +59 -0
  151. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  152. package/dist/public/impact/full-kb-quality.js +3 -1
  153. package/dist/public/operations/catalog.d.ts +315 -11
  154. package/dist/public/operations/catalog.d.ts.map +1 -1
  155. package/dist/public/operations/check-executor.d.ts +2 -0
  156. package/dist/public/operations/check-executor.d.ts.map +1 -1
  157. package/dist/public/operations/check-executor.js +6 -0
  158. package/dist/public/operations/evidence-floor.d.ts +48 -0
  159. package/dist/public/operations/evidence-floor.d.ts.map +1 -0
  160. package/dist/public/operations/evidence-floor.js +143 -0
  161. package/dist/public/operations/migration-plan.d.ts +19 -5
  162. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  163. package/dist/public/operations/migration-plan.js +22 -5
  164. package/dist/public/operations/node-ports.d.ts.map +1 -1
  165. package/dist/public/operations/node-ports.js +4 -1
  166. package/dist/public/operations/proof-contract-claims.d.ts +26 -0
  167. package/dist/public/operations/proof-contract-claims.d.ts.map +1 -0
  168. package/dist/public/operations/proof-contract-claims.js +71 -0
  169. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  170. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  171. package/dist/public/operations/specs/check-rules.generated.js +3 -1
  172. package/dist/public/operations/specs/check.d.ts +1 -1
  173. package/dist/public/operations/specs/composite.d.ts +16 -3
  174. package/dist/public/operations/specs/composite.d.ts.map +1 -1
  175. package/dist/public/operations/specs/modeling.d.ts +16 -3
  176. package/dist/public/operations/specs/modeling.d.ts.map +1 -1
  177. package/dist/public/operations/specs/modeling.js +22 -3
  178. package/dist/public/operations/specs/mutation-schemas.d.ts +289 -7
  179. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  180. package/dist/public/operations/specs/mutation-schemas.js +28 -4
  181. package/dist/public/operations/specs/proof.d.ts +9 -0
  182. package/dist/public/operations/specs/proof.d.ts.map +1 -1
  183. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  184. package/dist/public/operations/specs/reporting.js +19 -10
  185. package/dist/public/operations/specs/upsert.d.ts +289 -7
  186. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  187. package/dist/public/proof-certificates.d.ts +163 -0
  188. package/dist/public/proof-certificates.d.ts.map +1 -0
  189. package/dist/public/proof-certificates.js +419 -0
  190. package/dist/public/proof-protocol.d.ts +259 -3
  191. package/dist/public/proof-protocol.d.ts.map +1 -1
  192. package/dist/public/proof-protocol.js +524 -3
  193. package/dist/public/proof-receipt.d.ts +90 -6
  194. package/dist/public/proof-receipt.d.ts.map +1 -1
  195. package/dist/public/proof-receipt.js +88 -7
  196. package/dist/public/proof-sources.d.ts +102 -0
  197. package/dist/public/proof-sources.d.ts.map +1 -0
  198. package/dist/public/proof-sources.js +1292 -0
  199. package/dist/public/schemas/entity.d.ts.map +1 -1
  200. package/dist/public/schemas/entity.js +39 -2
  201. package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
  202. package/dist/public/skills/kibi-commit-review/SKILL.md +8 -8
  203. package/dist/public/skills/kibi-commit-review/resources/staged-gate.md +12 -7
  204. package/dist/public/skills/kibi-decisions/SKILL.md +13 -2
  205. package/dist/public/skills/kibi-decisions/resources/decision-records.md +9 -1
  206. package/dist/public/skills/kibi-freshness/SKILL.md +5 -1
  207. package/dist/public/skills/kibi-traceability/SKILL.md +12 -1
  208. package/dist/public/skills/kibi-usage/SKILL.md +8 -4
  209. package/dist/public/skills/kibi-usage/resources/proof.md +221 -20
  210. package/dist/public/skills/kibi-usage/resources/workflows.md +4 -4
  211. package/dist/report/html-report.css +83 -11
  212. package/dist/report/html-report.d.ts +8 -0
  213. package/dist/report/html-report.d.ts.map +1 -1
  214. package/dist/report/html-report.js +214 -22
  215. package/dist/report/report-view.d.ts +2 -2
  216. package/dist/report/report-view.d.ts.map +1 -1
  217. package/dist/report/report-view.js +8 -0
  218. package/dist/schemas/entity.schema.json +404 -5
  219. package/dist/search-answer.d.ts.map +1 -1
  220. package/dist/search-answer.js +1 -0
  221. package/dist/signoff/html.d.ts.map +1 -1
  222. package/dist/signoff/html.js +3 -0
  223. package/dist/signoff/markdown.d.ts.map +1 -1
  224. package/dist/signoff/markdown.js +3 -0
  225. package/dist/signoff/model.d.ts +20 -0
  226. package/dist/signoff/model.d.ts.map +1 -1
  227. package/dist/signoff/model.js +20 -1
  228. package/dist/traceability/evidence-model.d.ts +13 -12
  229. package/dist/traceability/evidence-model.d.ts.map +1 -1
  230. package/dist/traceability/evidence-model.js +1 -1
  231. package/dist/traceability/impact-knowledge.d.ts.map +1 -1
  232. package/dist/traceability/impact-knowledge.js +1 -0
  233. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  234. package/dist/traceability/staged-diagnostics.js +24 -20
  235. package/dist/traceability/staged-impact-contract.d.ts +4 -4
  236. package/dist/traceability/staged-impact-contract.js +9 -9
  237. package/dist/traceability/staged-symbols-manifest.d.ts +11 -3
  238. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  239. package/dist/traceability/staged-symbols-manifest.js +47 -140
  240. package/dist/traceability/temp-kb.d.ts.map +1 -1
  241. package/dist/traceability/temp-kb.js +1 -0
  242. package/dist/types/entities.d.ts +5 -2
  243. package/dist/types/entities.d.ts.map +1 -1
  244. package/dist/utils/merge-driver-setup.d.ts +8 -1
  245. package/dist/utils/merge-driver-setup.d.ts.map +1 -1
  246. package/dist/utils/merge-driver-setup.js +23 -2
  247. package/dist/utils/rule-registry.generated.d.ts +10 -0
  248. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  249. package/dist/utils/rule-registry.generated.js +12 -0
  250. package/dist/utils/schema-version.d.ts +1 -1
  251. package/dist/utils/schema-version.d.ts.map +1 -1
  252. package/dist/utils/schema-version.js +7 -1
  253. package/dist/utils/strict-modeling.d.ts +3 -2
  254. package/dist/utils/strict-modeling.d.ts.map +1 -1
  255. package/dist/utils/strict-modeling.js +37 -4
  256. package/dist/workspace-cwd.d.ts +15 -0
  257. package/dist/workspace-cwd.d.ts.map +1 -0
  258. package/dist/workspace-cwd.js +86 -0
  259. package/package.json +6 -2
  260. package/schema/entities.pl +6 -0
  261. package/schema/validation.pl +7 -2
  262. package/src/public/evidence-levels.ts +23 -0
  263. package/src/public/impact/coverage-depth-quality.ts +73 -0
  264. package/src/public/impact/full-kb-quality.ts +6 -1
  265. package/src/public/operations/check-executor.ts +13 -0
  266. package/src/public/operations/evidence-floor.ts +203 -0
  267. package/src/public/operations/migration-plan.ts +39 -6
  268. package/src/public/operations/node-ports.ts +3 -1
  269. package/src/public/operations/proof-contract-claims.ts +103 -0
  270. package/src/public/operations/specs/check-rules.generated.ts +3 -1
  271. package/src/public/operations/specs/modeling.ts +24 -5
  272. package/src/public/operations/specs/mutation-schemas.ts +30 -4
  273. package/src/public/operations/specs/reporting.ts +20 -10
  274. package/src/public/proof-certificates.ts +566 -0
  275. package/src/public/proof-protocol-types.d.ts +69 -1
  276. package/src/public/proof-protocol.ts +694 -3
  277. package/src/public/proof-receipt.ts +133 -7
  278. package/src/public/proof-sources.ts +1656 -0
  279. package/src/public/schemas/entity.ts +51 -3
  280. package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
  281. package/src/public/skills/kibi-commit-review/SKILL.md +8 -8
  282. package/src/public/skills/kibi-commit-review/resources/staged-gate.md +12 -7
  283. package/src/public/skills/kibi-decisions/SKILL.md +13 -2
  284. package/src/public/skills/kibi-decisions/resources/decision-records.md +9 -1
  285. package/src/public/skills/kibi-freshness/SKILL.md +5 -1
  286. package/src/public/skills/kibi-traceability/SKILL.md +12 -1
  287. package/src/public/skills/kibi-usage/SKILL.md +8 -4
  288. package/src/public/skills/kibi-usage/resources/proof.md +221 -20
  289. package/src/public/skills/kibi-usage/resources/workflows.md +4 -4
  290. package/src/schemas/entity.schema.json +404 -5
  291. package/dist/commands/proof-impact.d.ts +0 -7
  292. package/dist/commands/proof-impact.d.ts.map +0 -1
  293. package/dist/commands/proof-impact.js +0 -39
  294. package/dist/operations/proof/baseline-diff.d.ts +0 -41
  295. package/dist/operations/proof/baseline-diff.d.ts.map +0 -1
  296. package/dist/operations/proof/baseline-diff.js +0 -153
  297. package/dist/operations/proof/impact.d.ts +0 -51
  298. package/dist/operations/proof/impact.d.ts.map +0 -1
  299. package/dist/operations/proof/impact.js +0 -138
  300. package/dist/traceability/reviewed-coordinate-refresh.d.ts +0 -10
  301. package/dist/traceability/reviewed-coordinate-refresh.d.ts.map +0 -1
  302. package/dist/traceability/reviewed-coordinate-refresh.js +0 -49
@@ -2,8 +2,23 @@
2
2
  export const PROOF_RUN_VERSION = "kibi.proof-run.v1";
3
3
  // implements REQ-kibi-verification-evidence-contract
4
4
  export const PROOF_CONTRACT_VERSION = "kibi.proof-contract.v1";
5
- // implements REQ-kibi-verification-evidence-contract
6
- export const PROOF_RECEIPT_VERSION = "kibi.proof-receipt.v1";
5
+ /**
6
+ * Receipts Kibi writes. v2 adds the contract's kind, the evidence level the
7
+ * receipt supports, and for certificate kinds the re-checked certificate.
8
+ */
9
+ // implements REQ-kibi-verification-evidence-contract, REQ-kibi-code-proof-kinds
10
+ export const PROOF_RECEIPT_VERSION = "kibi.proof-receipt.v2";
11
+ /** Receipts written before v2; still read, as e2e evidence at tested. */
12
+ // implements REQ-kibi-code-proof-kinds
13
+ export const PROOF_RECEIPT_V1_VERSION = "kibi.proof-receipt.v1";
14
+ // implements REQ-kibi-code-proof-kinds
15
+ export const PROOF_RECEIPT_VERSIONS = [
16
+ PROOF_RECEIPT_V1_VERSION,
17
+ PROOF_RECEIPT_VERSION,
18
+ ];
19
+ /** The certificate a certificate-kind proof leaves for Kibi to re-check. */
20
+ // implements REQ-kibi-code-proof-kinds
21
+ export const CODE_CERTIFICATE_VERSION = "kibi.code-certificate.v1";
7
22
  // implements REQ-kibi-verification-evidence-contract
8
23
  export const PROOF_INTEGRATION_VERSION = "kibi.proof-integration.v1";
9
24
  export const PROOF_RUN_OUTCOMES = [
@@ -32,7 +47,58 @@ export const RUN_FAILURE_PHASES = [
32
47
  "teardown",
33
48
  "infrastructure",
34
49
  ];
35
- export const SUCCESS_POLICIES = ["all_required_first_attempt"];
50
+ /**
51
+ * `all_required_first_attempt`: the whole run must pass and every obligation's
52
+ * own result must pass on its first attempt.
53
+ * `own_results_first_attempt`: a run whose only failures are other test cases
54
+ * (outcome `failed` in the execution phase) still proves an obligation whose
55
+ * own native-case result passed on its first attempt, so one unrelated
56
+ * failing case does not erase a suite's evidence. Aggregate-run obligations
57
+ * still need the whole run to pass.
58
+ */
59
+ export const SUCCESS_POLICIES = [
60
+ "all_required_first_attempt",
61
+ "own_results_first_attempt",
62
+ ];
63
+ /**
64
+ * What a proof contract's checker establishes. Runner kinds (e2e, example,
65
+ * property) sample cases and support tested evidence; certificate kinds
66
+ * (exhaustive, typecheck, arithmetic, smt, rule, state_machine, regex,
67
+ * source) cover every case and support proved evidence once Kibi re-checks
68
+ * the certificate the run left. A source certificate is Kibi's own read of a
69
+ * project source (a JSON or YAML file, a glob, an OpenAPI document, the
70
+ * references the code makes, a data schema, a route table, a validator).
71
+ */
72
+ // implements REQ-kibi-code-proof-kinds
73
+ export const PROOF_KINDS = [
74
+ "e2e",
75
+ "example",
76
+ "property",
77
+ "exhaustive",
78
+ "typecheck",
79
+ "arithmetic",
80
+ "smt",
81
+ "rule",
82
+ "state_machine",
83
+ "regex",
84
+ "source",
85
+ ];
86
+ // implements REQ-kibi-code-proof-kinds, REQ-kibi-non-numeric-proof-kinds, REQ-kibi-source-proof-kinds
87
+ export const CERTIFICATE_PROOF_KINDS = [
88
+ "exhaustive",
89
+ "typecheck",
90
+ "arithmetic",
91
+ "smt",
92
+ "rule",
93
+ "state_machine",
94
+ "regex",
95
+ "source",
96
+ ];
97
+ // implements REQ-kibi-code-proof-kinds
98
+ export function isCertificateProofKind(kind) {
99
+ return CERTIFICATE_PROOF_KINDS.includes(kind);
100
+ }
101
+ import { SOURCE_READERS, normalizeSourceSpec, sourceSpecErrors, } from "./proof-sources.js";
36
102
  export const PROOF_RESULT_SCHEMA = {
37
103
  type: "object",
38
104
  description: "One observed proof result. binding distinguishes native-case observations from aggregate-run bindings; attempts must report facts only.",
@@ -152,6 +218,56 @@ export const PROOF_RUN_ARTIFACT_SCHEMA = {
152
218
  type: "array",
153
219
  items: { type: "string", minLength: 1 },
154
220
  },
221
+ certificates: {
222
+ type: "array",
223
+ description: "kibi.code-certificate.v1 objects the run left for certificate-kind contracts, one per test. Kibi re-checks each before a receipt counts as proved.",
224
+ maxItems: 1000,
225
+ items: { type: "object", required: ["version", "kind", "test_id"] },
226
+ },
227
+ },
228
+ additionalProperties: false,
229
+ };
230
+ const SOURCE_REFERENCE_SCHEMA = {
231
+ type: "object",
232
+ required: ["symbol_id"],
233
+ properties: {
234
+ symbol_id: { type: "string", minLength: 1 },
235
+ export: { type: "string", minLength: 1 },
236
+ },
237
+ additionalProperties: false,
238
+ };
239
+ // implements REQ-kibi-source-proof-kinds
240
+ const SOURCE_SPEC_SCHEMA = {
241
+ type: "object",
242
+ description: "A project source Kibi reads by itself. reader json or yaml: {file, path?, select?: keys|values|items}. glob: {pattern, capture?, ignore?} (capture true reads what each * matched). openapi: {file, select?: operations|unsecured_operations|security_schemes|responses}. references: {files, extract: env|imports|calls|string_args|thrown|property, callee?, key?, ignore?}. schema: {format: drizzle|prisma|sql, file (drizzle, prisma) or files (sql migrations), exports?, table?, select?: tables|columns|required_columns|nullable_columns|foreign_keys}. routes: {file, export, framework?: hono|express, path_prefix?, names_from?, select?: routes|middleware}. validator: {file, export, select?: fields|required_fields|optional_fields}. Paths are repository-relative. A member Kibi cannot read statically fails the read with its location.",
243
+ required: ["reader"],
244
+ properties: {
245
+ reader: { type: "string", enum: [...SOURCE_READERS] },
246
+ },
247
+ additionalProperties: true,
248
+ };
249
+ const SOURCE_DOMAIN_SCHEMA = {
250
+ type: "object",
251
+ required: ["source"],
252
+ properties: { source: SOURCE_SPEC_SCHEMA },
253
+ additionalProperties: false,
254
+ };
255
+ const PREDICATE_SOURCE_SCHEMA = {
256
+ type: "object",
257
+ required: ["symbol_id"],
258
+ properties: {
259
+ symbol_id: { type: "string", minLength: 1 },
260
+ export: {
261
+ type: "string",
262
+ minLength: 1,
263
+ description: "The exported function's name in the symbol's source file. Without it Kibi reads the export named by the symbol's title.",
264
+ },
265
+ harness_for: {
266
+ type: "array",
267
+ minItems: 1,
268
+ items: { type: "string", minLength: 1 },
269
+ description: "The predicate is a test harness that decides the predicate by driving these code symbols (for example by calling the handler with each role). The symbols must be covered_by the test; a claim the harness proves is bound with scope harness.",
270
+ },
155
271
  },
156
272
  additionalProperties: false,
157
273
  };
@@ -177,6 +293,97 @@ export const PROOF_CONTRACT_SCHEMA = {
177
293
  },
178
294
  },
179
295
  success_policy: { type: "string", enum: [...SUCCESS_POLICIES] },
296
+ kind: {
297
+ type: "string",
298
+ enum: [...PROOF_KINDS],
299
+ description: "What the checker establishes; absent means e2e. exhaustive, typecheck, arithmetic, smt, rule, state_machine and regex must leave a kibi.code-certificate.v1 that Kibi re-checks before the receipt counts as proved. source reads the contract's source itself: the run may leave {version, kind: source, test_id, source} or nothing, and Kibi stores its own read as the certificate.",
300
+ },
301
+ source: {
302
+ ...SOURCE_SPEC_SCHEMA,
303
+ description: `source: the project source a source proof reads. ${SOURCE_SPEC_SCHEMA.description}`,
304
+ },
305
+ domain_source: {
306
+ type: "object",
307
+ description: "exhaustive and typecheck: the symbol that defines the finite domain (typecheck: also the type whose fields a required_fields fact names). state_machine: the transition table or next-state function. The proof must import it from its source file; a hand-listed domain downgrades the receipt to example. Kibi reads the export named `export`, or the symbol's title when `export` is absent.",
308
+ required: ["symbol_id"],
309
+ properties: {
310
+ symbol_id: { type: "string", minLength: 1 },
311
+ export: {
312
+ type: "string",
313
+ minLength: 1,
314
+ description: "The name the domain is exported under in the symbol's source file, when the symbol's title is not that name.",
315
+ },
316
+ },
317
+ additionalProperties: false,
318
+ },
319
+ witness: {
320
+ type: "object",
321
+ description: "typecheck: the repository-relative witness file Kibi compiles (an exhaustive switch ending in never, or a mapped type over the domain).",
322
+ required: ["path"],
323
+ properties: { path: { type: "string", minLength: 1 } },
324
+ additionalProperties: false,
325
+ },
326
+ proves: {
327
+ type: "array",
328
+ description: "Certificate kinds: the requirement claim keys (CLAIM-...) this certificate proves. Each must be a modeled claim of a current requirement the test reaches through its scenarios. Kibi derives what the certificate must establish from the claim's grounding fact (a set fact for exhaustive or typecheck, a numeric fact for arithmetic or smt, a rule, predicate or set fact for rule and state_machine, a string fact for regex); a claim with no such derivation is only attested and never counts as proved.",
329
+ minItems: 1,
330
+ items: { type: "string", pattern: "^CLAIM-" },
331
+ uniqueItems: true,
332
+ },
333
+ value_source: {
334
+ type: "array",
335
+ description: "arithmetic and smt: code constants the assumptions read. Kibi evaluates each export at ingest and requires the certificate to assume the variable equals that value, so the proof is about the code and not only the knowledge base. With measure count the value is the size of a list, set, map or object export, so a count claim reads the collection itself. An entry {source, measure: count} counts the members Kibi reads from a project source (routes, tables, environment variables).",
336
+ minItems: 1,
337
+ items: {
338
+ type: "object",
339
+ properties: {
340
+ symbol_id: { type: "string", minLength: 1 },
341
+ export: { type: "string", minLength: 1 },
342
+ source: SOURCE_SPEC_SCHEMA,
343
+ measure: {
344
+ type: "string",
345
+ enum: ["value", "count"],
346
+ description: "value (default for an export): the export is a number. count (the only measure of a source): the number of members of a list, set, map or object export, or of a source.",
347
+ },
348
+ },
349
+ additionalProperties: false,
350
+ },
351
+ },
352
+ predicate_source: {
353
+ type: "object",
354
+ description: "rule: the code function behind each predicate a claim's rule, predicate or set fact names, keyed by predicate name. Each export takes the predicate's arguments in order and returns a boolean; Kibi calls it on every combination of its argument domains.",
355
+ minProperties: 1,
356
+ additionalProperties: PREDICATE_SOURCE_SCHEMA,
357
+ },
358
+ domains: {
359
+ type: "object",
360
+ description: "rule: the finite domain of each argument type, keyed by type name (an array, Set, Map or object export, or a Python list, set, dict or Enum), or {source} for the members Kibi reads from a project source (every route, every table, every environment variable). state_machine with a next-state function: the `state` and `event` domains it is called on.",
361
+ minProperties: 1,
362
+ additionalProperties: {
363
+ anyOf: [SOURCE_REFERENCE_SCHEMA, SOURCE_DOMAIN_SCHEMA],
364
+ },
365
+ },
366
+ initial_source: {
367
+ ...SOURCE_REFERENCE_SCHEMA,
368
+ description: "state_machine: the export holding the initial state (or states), needed for initial_states and reachable_states facts.",
369
+ },
370
+ pattern_source: {
371
+ ...SOURCE_REFERENCE_SCHEMA,
372
+ description: "regex: the export holding the code's pattern (a RegExp, or a Python re.Pattern) or string constant that a string fact is about.",
373
+ },
374
+ constraint_source: {
375
+ type: "object",
376
+ description: "arithmetic and smt: the typed numeric property_value facts the certificate's assumptions come from. Kibi checks the assumptions (or the query's assertions) are exactly these facts' constraints, so the proof is about the knowledge base, not numbers the test chose.",
377
+ required: ["fact_ids"],
378
+ properties: {
379
+ fact_ids: {
380
+ type: "array",
381
+ minItems: 1,
382
+ items: { type: "string", minLength: 1 },
383
+ },
384
+ },
385
+ additionalProperties: false,
386
+ },
180
387
  },
181
388
  additionalProperties: false,
182
389
  };
@@ -371,6 +578,20 @@ export function proofRunArtifactErrors(value) {
371
578
  !artifact.diagnostics.every((entry) => nonEmptyString(entry)))
372
579
  errors.push("artifact.diagnostics must be an array of non-empty strings");
373
580
  }
581
+ if (artifact.certificates !== undefined) {
582
+ if (!Array.isArray(artifact.certificates))
583
+ errors.push("artifact.certificates must be an array when present");
584
+ else
585
+ artifact.certificates.forEach((entry, index) => {
586
+ const row = record(entry);
587
+ if (!row ||
588
+ !nonEmptyString(row.version) ||
589
+ !includes(CERTIFICATE_PROOF_KINDS, row.kind) ||
590
+ !nonEmptyString(row.test_id) ||
591
+ !isPlainJson(row))
592
+ errors.push(`artifact.certificates[${index}] must be a JSON object with version, a certificate kind (${CERTIFICATE_PROOF_KINDS.join(", ")}) and test_id`);
593
+ });
594
+ }
374
595
  return errors;
375
596
  }
376
597
  export function proofContractErrors(value) {
@@ -413,8 +634,308 @@ export function proofContractErrors(value) {
413
634
  }
414
635
  if (!includes(SUCCESS_POLICIES, contract.success_policy))
415
636
  errors.push(`proof_contract.success_policy must be one of: ${SUCCESS_POLICIES.join(", ")}; received ${JSON.stringify(contract.success_policy ?? null)}`);
637
+ errors.push(...proofContractKindErrors(contract));
638
+ return errors;
639
+ }
640
+ // implements REQ-kibi-code-proof-kinds
641
+ function proofContractKindErrors(contract) {
642
+ const errors = [];
643
+ const kind = contract.kind;
644
+ if (kind !== undefined && !includes(PROOF_KINDS, kind))
645
+ errors.push(`proof_contract.kind must be one of: ${PROOF_KINDS.join(", ")}; received ${JSON.stringify(kind)}`);
646
+ const domain = contract.domain_source;
647
+ if (domain !== undefined) {
648
+ const row = record(domain);
649
+ if (!row ||
650
+ !nonEmptyString(row.symbol_id) ||
651
+ (row.export !== undefined && !nonEmptyString(row.export)) ||
652
+ Object.keys(row).some((key) => key !== "symbol_id" && key !== "export"))
653
+ errors.push("proof_contract.domain_source must be {symbol_id, export?} naming the symbol that defines the domain and, when its title is not the export name, the export to read");
654
+ }
655
+ else if (kind === "exhaustive" || kind === "typecheck")
656
+ errors.push(`proof_contract.domain_source is required for kind ${String(kind)}: name the symbol the proof reads its domain from`);
657
+ const witness = contract.witness;
658
+ if (witness !== undefined) {
659
+ const row = record(witness);
660
+ if (!row || !nonEmptyString(row.path) || Object.keys(row).length !== 1)
661
+ errors.push("proof_contract.witness must be {path} naming the repository-relative witness file");
662
+ }
663
+ else if (kind === "typecheck")
664
+ errors.push("proof_contract.witness is required for kind typecheck: name the file the type checker compiles");
665
+ const source = contract.constraint_source;
666
+ if (source !== undefined) {
667
+ const row = record(source);
668
+ const ids = row?.fact_ids;
669
+ if (!row ||
670
+ Object.keys(row).length !== 1 ||
671
+ !Array.isArray(ids) ||
672
+ ids.length === 0 ||
673
+ !ids.every(nonEmptyString))
674
+ errors.push("proof_contract.constraint_source must be {fact_ids: [FACT-...]} naming the facts the assumptions come from");
675
+ }
676
+ else if ((kind === "arithmetic" || kind === "smt") &&
677
+ contract.value_source === undefined)
678
+ errors.push(`proof_contract.constraint_source or value_source is required for kind ${String(kind)}: name the typed facts or code constants its assumptions come from`);
679
+ const valueSource = contract.value_source;
680
+ if (valueSource !== undefined) {
681
+ if (Array.isArray(valueSource))
682
+ valueSource.forEach((entry, index) => {
683
+ const row = record(entry);
684
+ if (row === null || row.source === undefined)
685
+ return;
686
+ errors.push(...sourceSpecErrors(row.source, `proof_contract.value_source[${index}].source`));
687
+ if (row.symbol_id !== undefined || row.export !== undefined)
688
+ errors.push(`proof_contract.value_source[${index}] names a source, so it takes no symbol_id or export`);
689
+ if (row.measure !== undefined && row.measure !== "count")
690
+ errors.push(`proof_contract.value_source[${index}].measure must be count for a source: Kibi counts the members it reads`);
691
+ });
692
+ if (!Array.isArray(valueSource) ||
693
+ valueSource.length === 0 ||
694
+ !valueSource.every((entry) => {
695
+ const row = record(entry);
696
+ if (row !== null && row.source !== undefined)
697
+ return true;
698
+ return (row !== null &&
699
+ nonEmptyString(row.symbol_id) &&
700
+ (row.export === undefined || nonEmptyString(row.export)) &&
701
+ (row.measure === undefined ||
702
+ row.measure === "value" ||
703
+ row.measure === "count") &&
704
+ Object.keys(row).every((key) => key === "symbol_id" || key === "export" || key === "measure"));
705
+ }))
706
+ errors.push("proof_contract.value_source must be [{symbol_id, export?, measure?: value|count} or {source, measure?: count}] naming the code constants or project sources the assumptions read");
707
+ else if (kind !== "arithmetic" && kind !== "smt")
708
+ errors.push(`proof_contract.value_source applies only to kind arithmetic or smt, not ${String(kind ?? "e2e")}`);
709
+ }
710
+ errors.push(...nonNumericContractErrors(contract));
711
+ errors.push(...sourceContractErrors(contract));
712
+ const proves = contract.proves;
713
+ if (proves !== undefined) {
714
+ if (!Array.isArray(proves) ||
715
+ proves.length === 0 ||
716
+ !proves.every((key) => typeof key === "string" && /^CLAIM-[A-Za-z0-9]+$/.test(key)) ||
717
+ new Set(proves).size !== proves.length)
718
+ errors.push("proof_contract.proves must be a non-empty list of distinct claim keys (CLAIM-...) the certificate proves");
719
+ else if (!isCertificateProofKind(kind))
720
+ errors.push(`proof_contract.proves applies only to certificate kinds (${CERTIFICATE_PROOF_KINDS.join(", ")}), not ${String(kind ?? "e2e")}`);
721
+ }
722
+ return errors;
723
+ }
724
+ function isSourceReference(value) {
725
+ const row = record(value);
726
+ return (row !== null &&
727
+ nonEmptyString(row.symbol_id) &&
728
+ (row.export === undefined || nonEmptyString(row.export)) &&
729
+ Object.keys(row).every((key) => key === "symbol_id" || key === "export"));
730
+ }
731
+ function isSourceMap(value, accepts = isSourceReference) {
732
+ const row = record(value);
733
+ return (row !== null &&
734
+ Object.keys(row).length > 0 &&
735
+ Object.entries(row).every(([key, entry]) => key.trim() !== "" && accepts(entry)));
736
+ }
737
+ function isPredicateReference(value) {
738
+ const row = record(value);
739
+ if (row === null || row.harness_for === undefined)
740
+ return isSourceReference(value);
741
+ const { harness_for: harness, ...reference } = row;
742
+ return (isSourceReference(reference) &&
743
+ Array.isArray(harness) &&
744
+ harness.length > 0 &&
745
+ harness.every(nonEmptyString));
746
+ }
747
+ function isSourceDomain(value) {
748
+ const row = record(value);
749
+ return (row !== null && Object.keys(row).length === 1 && row.source !== undefined);
750
+ }
751
+ /**
752
+ * The source kind and the source-backed rule domains: a well-formed source
753
+ * spec, required for kind source and only there.
754
+ */
755
+ // implements REQ-kibi-source-proof-kinds
756
+ function sourceContractErrors(contract) {
757
+ const errors = [];
758
+ const kind = contract.kind;
759
+ if (contract.source !== undefined) {
760
+ errors.push(...sourceSpecErrors(contract.source, "proof_contract.source"));
761
+ if (kind !== "source")
762
+ errors.push(`proof_contract.source applies only to kind source, not ${String(kind ?? "e2e")}`);
763
+ }
764
+ else if (kind === "source")
765
+ errors.push("proof_contract.source is required for kind source: name the project source Kibi reads (reader json, yaml, glob, openapi, references, schema, routes or validator)");
766
+ const domains = record(contract.domains);
767
+ for (const [type, entry] of Object.entries(domains ?? {}))
768
+ if (isSourceDomain(entry)) {
769
+ errors.push(...sourceSpecErrors(record(entry)?.source, `proof_contract.domains.${type}.source`));
770
+ if (kind !== "rule")
771
+ errors.push(`proof_contract.domains.${type}.source applies only to kind rule: a state machine's domains are the code's`);
772
+ }
416
773
  return errors;
417
774
  }
775
+ /**
776
+ * The contract fields of the rule, state_machine and regex kinds: where the
777
+ * code Kibi evaluates lives, and only on the kinds that read it.
778
+ */
779
+ // implements REQ-kibi-non-numeric-proof-kinds
780
+ function nonNumericContractErrors(contract) {
781
+ const errors = [];
782
+ const kind = contract.kind;
783
+ const only = (field, kinds) => {
784
+ if (contract[field] !== undefined && !kinds.includes(String(kind)))
785
+ errors.push(`proof_contract.${field} applies only to kind ${kinds.join(" or ")}, not ${String(kind ?? "e2e")}`);
786
+ };
787
+ if (contract.predicate_source !== undefined &&
788
+ !isSourceMap(contract.predicate_source, isPredicateReference))
789
+ errors.push("proof_contract.predicate_source must map each predicate name to {symbol_id, export?, harness_for?} naming the function that decides it");
790
+ if (contract.domains !== undefined &&
791
+ !isSourceMap(contract.domains, (entry) => isSourceReference(entry) || isSourceDomain(entry)))
792
+ errors.push("proof_contract.domains must map each argument type to {symbol_id, export?} naming the export that lists its values, or {source} naming the project source Kibi reads them from");
793
+ for (const field of ["initial_source", "pattern_source"])
794
+ if (contract[field] !== undefined && !isSourceReference(contract[field]))
795
+ errors.push(`proof_contract.${field} must be {symbol_id, export?} naming the export Kibi reads`);
796
+ only("predicate_source", ["rule"]);
797
+ only("domains", ["rule", "state_machine"]);
798
+ only("initial_source", ["state_machine"]);
799
+ only("pattern_source", ["regex"]);
800
+ if (kind === "rule") {
801
+ if (contract.predicate_source === undefined)
802
+ errors.push("proof_contract.predicate_source is required for kind rule: name the function behind each predicate the claims use");
803
+ if (contract.domains === undefined)
804
+ errors.push("proof_contract.domains is required for kind rule: name the export listing each argument type's values");
805
+ }
806
+ if (kind === "state_machine") {
807
+ if (contract.domain_source === undefined)
808
+ errors.push("proof_contract.domain_source is required for kind state_machine: name the transition table or next-state function");
809
+ const domains = record(contract.domains);
810
+ if (domains !== null &&
811
+ (Object.keys(domains).length !== 2 ||
812
+ domains.state === undefined ||
813
+ domains.event === undefined))
814
+ errors.push("proof_contract.domains for kind state_machine must name exactly the state and event domains a next-state function is called on");
815
+ }
816
+ if (kind === "regex" && contract.pattern_source === undefined)
817
+ errors.push("proof_contract.pattern_source is required for kind regex: name the export holding the pattern or string");
818
+ return errors;
819
+ }
820
+ /**
821
+ * The optional contract fields beyond the v1 core, copied only when present
822
+ * so existing contracts keep their hash.
823
+ */
824
+ // implements REQ-kibi-code-proof-kinds
825
+ export function optionalProofContractFields(contract) {
826
+ const fields = {};
827
+ if (typeof contract.kind === "string")
828
+ fields.kind = contract.kind;
829
+ const domain = record(contract.domain_source);
830
+ if (domain && typeof domain.symbol_id === "string")
831
+ fields.domain_source = {
832
+ symbol_id: domain.symbol_id,
833
+ ...(typeof domain.export === "string" ? { export: domain.export } : {}),
834
+ };
835
+ const witness = record(contract.witness);
836
+ if (witness && typeof witness.path === "string")
837
+ fields.witness = { path: witness.path };
838
+ const source = record(contract.constraint_source);
839
+ if (source && Array.isArray(source.fact_ids))
840
+ fields.constraint_source = {
841
+ fact_ids: source.fact_ids.filter((id) => typeof id === "string"),
842
+ };
843
+ if (Array.isArray(contract.value_source))
844
+ fields.value_source = contract.value_source
845
+ .map((entry) => record(entry))
846
+ .map((row) => {
847
+ if (row === null)
848
+ return null;
849
+ const spec = normalizeSourceSpec(row.source);
850
+ if (spec !== undefined)
851
+ return { source: spec, measure: "count" };
852
+ if (typeof row.symbol_id !== "string")
853
+ return null;
854
+ return {
855
+ symbol_id: row.symbol_id,
856
+ ...(typeof row.export === "string" ? { export: row.export } : {}),
857
+ ...(row.measure === "value" || row.measure === "count"
858
+ ? { measure: row.measure }
859
+ : {}),
860
+ };
861
+ })
862
+ .filter((row) => row !== null);
863
+ if (Array.isArray(contract.proves))
864
+ fields.proves = contract.proves.filter((key) => typeof key === "string");
865
+ const predicates = predicateMap(contract.predicate_source);
866
+ if (predicates !== undefined)
867
+ fields.predicate_source = predicates;
868
+ const domains = domainMap(contract.domains);
869
+ if (domains !== undefined)
870
+ fields.domains = domains;
871
+ const spec = normalizeSourceSpec(contract.source);
872
+ if (spec !== undefined)
873
+ fields.source = spec;
874
+ const initial = sourceReference(contract.initial_source);
875
+ if (initial !== undefined)
876
+ fields.initial_source = initial;
877
+ const pattern = sourceReference(contract.pattern_source);
878
+ if (pattern !== undefined)
879
+ fields.pattern_source = pattern;
880
+ return fields;
881
+ }
882
+ function predicateMap(value) {
883
+ const row = record(value);
884
+ if (!row)
885
+ return undefined;
886
+ const out = {};
887
+ for (const [key, entry] of Object.entries(row)) {
888
+ const reference = sourceReference(entry);
889
+ if (reference === undefined)
890
+ continue;
891
+ const harness = record(entry)?.harness_for;
892
+ out[key] = Array.isArray(harness)
893
+ ? {
894
+ ...reference,
895
+ harness_for: harness.filter((id) => typeof id === "string"),
896
+ }
897
+ : reference;
898
+ }
899
+ return Object.keys(out).length > 0 ? out : undefined;
900
+ }
901
+ function domainMap(value) {
902
+ const row = record(value);
903
+ if (!row)
904
+ return undefined;
905
+ const out = {};
906
+ for (const [key, entry] of Object.entries(row)) {
907
+ const spec = normalizeSourceSpec(record(entry)?.source);
908
+ if (spec !== undefined) {
909
+ out[key] = { source: spec };
910
+ continue;
911
+ }
912
+ const reference = sourceReference(entry);
913
+ if (reference !== undefined)
914
+ out[key] = reference;
915
+ }
916
+ return Object.keys(out).length > 0 ? out : undefined;
917
+ }
918
+ function sourceReference(value) {
919
+ const row = record(value);
920
+ if (!row || typeof row.symbol_id !== "string")
921
+ return undefined;
922
+ return {
923
+ symbol_id: row.symbol_id,
924
+ ...(typeof row.export === "string" ? { export: row.export } : {}),
925
+ };
926
+ }
927
+ function sourceMap(value) {
928
+ const row = record(value);
929
+ if (!row)
930
+ return undefined;
931
+ const out = {};
932
+ for (const [key, entry] of Object.entries(row)) {
933
+ const reference = sourceReference(entry);
934
+ if (reference !== undefined)
935
+ out[key] = reference;
936
+ }
937
+ return Object.keys(out).length > 0 ? out : undefined;
938
+ }
418
939
  export function proofBindingsErrors(value) {
419
940
  if (!Array.isArray(value))
420
941
  return ["proof_bindings must be an array of binding objects"];