kibi-cli 2.0.0 → 2.2.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 (377) hide show
  1. package/dist/cli-protocol.d.ts.map +1 -1
  2. package/dist/cli-protocol.js +3 -2
  3. package/dist/cli-register-proof.d.ts.map +1 -1
  4. package/dist/cli-register-proof.js +25 -1
  5. package/dist/cli-register-reporting.d.ts.map +1 -1
  6. package/dist/cli-register-reporting.js +6 -0
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +2 -0
  9. package/dist/commands/aggregated-checks.d.ts +7 -0
  10. package/dist/commands/aggregated-checks.d.ts.map +1 -1
  11. package/dist/commands/aggregated-checks.js +25 -1
  12. package/dist/commands/check-generated.d.ts +7 -0
  13. package/dist/commands/check-generated.d.ts.map +1 -0
  14. package/dist/commands/check-generated.js +192 -0
  15. package/dist/commands/check.d.ts.map +1 -1
  16. package/dist/commands/check.js +24 -15
  17. package/dist/commands/doctor.d.ts.map +1 -1
  18. package/dist/commands/doctor.js +227 -25
  19. package/dist/commands/engine.d.ts.map +1 -1
  20. package/dist/commands/engine.js +3 -1
  21. package/dist/commands/github-init.d.ts +1 -1
  22. package/dist/commands/github-init.d.ts.map +1 -1
  23. package/dist/commands/github-init.js +1 -1
  24. package/dist/commands/init-helpers.d.ts +17 -2
  25. package/dist/commands/init-helpers.d.ts.map +1 -1
  26. package/dist/commands/init-helpers.js +136 -30
  27. package/dist/commands/init.d.ts.map +1 -1
  28. package/dist/commands/init.js +110 -15
  29. package/dist/commands/proof-explain.d.ts +10 -0
  30. package/dist/commands/proof-explain.d.ts.map +1 -0
  31. package/dist/commands/proof-explain.js +45 -0
  32. package/dist/commands/proof-impact.d.ts +7 -0
  33. package/dist/commands/proof-impact.d.ts.map +1 -0
  34. package/dist/commands/proof-impact.js +39 -0
  35. package/dist/commands/proof-migrate-legacy.js +1 -1
  36. package/dist/commands/proof-prune.js +1 -1
  37. package/dist/commands/prove.d.ts.map +1 -1
  38. package/dist/commands/prove.js +14 -22
  39. package/dist/commands/report.d.ts.map +1 -1
  40. package/dist/commands/report.js +17 -2
  41. package/dist/commands/sync/cache.d.ts +20 -1
  42. package/dist/commands/sync/cache.d.ts.map +1 -1
  43. package/dist/commands/sync/cache.js +51 -2
  44. package/dist/commands/sync/discovery.d.ts.map +1 -1
  45. package/dist/commands/sync/discovery.js +1 -1
  46. package/dist/commands/sync/manifest.d.ts +1 -0
  47. package/dist/commands/sync/manifest.d.ts.map +1 -1
  48. package/dist/commands/sync/manifest.js +18 -16
  49. package/dist/commands/sync/persistence.d.ts.map +1 -1
  50. package/dist/commands/sync/persistence.js +14 -0
  51. package/dist/commands/sync.d.ts.map +1 -1
  52. package/dist/commands/sync.js +11 -3
  53. package/dist/engine.d.ts +29 -1
  54. package/dist/engine.d.ts.map +1 -1
  55. package/dist/engine.js +259 -89
  56. package/dist/env/bootstrap.d.ts +84 -0
  57. package/dist/env/bootstrap.d.ts.map +1 -0
  58. package/dist/env/bootstrap.js +310 -0
  59. package/dist/extractors/manifest.d.ts.map +1 -1
  60. package/dist/extractors/manifest.js +67 -29
  61. package/dist/extractors/markdown.d.ts +4 -0
  62. package/dist/extractors/markdown.d.ts.map +1 -1
  63. package/dist/extractors/markdown.js +33 -3
  64. package/dist/extractors/relationships.d.ts.map +1 -1
  65. package/dist/extractors/relationships.js +1 -0
  66. package/dist/extractors/symbols-coordinator.d.ts +8 -0
  67. package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
  68. package/dist/extractors/symbols-coordinator.js +40 -0
  69. package/dist/extractors/symbols-ts.d.ts +8 -19
  70. package/dist/extractors/symbols-ts.d.ts.map +1 -1
  71. package/dist/extractors/symbols-ts.js +33 -503
  72. package/dist/intent-search.d.ts.map +1 -1
  73. package/dist/intent-search.js +68 -30
  74. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  75. package/dist/operations/bootstrap/generate.js +4 -3
  76. package/dist/operations/modeling/model-requirement.d.ts +1 -1
  77. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  78. package/dist/operations/modeling/model-requirement.js +179 -9
  79. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  80. package/dist/operations/modeling/predicate-applyplan.js +14 -2
  81. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  82. package/dist/operations/modeling/predicate-loader.js +24 -0
  83. package/dist/operations/modeling/predicate-types.d.ts +4 -0
  84. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  85. package/dist/operations/modeling/predicate-vocabulary.d.ts +54 -0
  86. package/dist/operations/modeling/predicate-vocabulary.d.ts.map +1 -0
  87. package/dist/operations/modeling/predicate-vocabulary.js +169 -0
  88. package/dist/operations/modeling/requirement-types.d.ts +5 -0
  89. package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
  90. package/dist/operations/modeling/suggest-predicates.d.ts +1 -1
  91. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  92. package/dist/operations/modeling/suggest-predicates.js +30 -3
  93. package/dist/operations/modeling/vocabulary-alignment.d.ts +60 -0
  94. package/dist/operations/modeling/vocabulary-alignment.d.ts.map +1 -0
  95. package/dist/operations/modeling/vocabulary-alignment.js +178 -0
  96. package/dist/operations/mutation/contradictions.d.ts +3 -0
  97. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  98. package/dist/operations/mutation/contradictions.js +29 -0
  99. package/dist/operations/mutation/delete.d.ts.map +1 -1
  100. package/dist/operations/mutation/delete.js +33 -1
  101. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +8 -0
  102. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -0
  103. package/dist/operations/mutation/predicate-vocabulary-guard.js +64 -0
  104. package/dist/operations/mutation/relationships.d.ts +1 -1
  105. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  106. package/dist/operations/mutation/relationships.js +1 -0
  107. package/dist/operations/mutation/saga.d.ts +5 -0
  108. package/dist/operations/mutation/saga.d.ts.map +1 -1
  109. package/dist/operations/mutation/saga.js +10 -0
  110. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  111. package/dist/operations/mutation/serialization.js +2 -0
  112. package/dist/operations/mutation/source-authoring.d.ts +6 -0
  113. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  114. package/dist/operations/mutation/source-authoring.js +65 -26
  115. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  116. package/dist/operations/mutation/strict-fact.js +5 -0
  117. package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
  118. package/dist/operations/mutation/symbol-granularity.js +9 -87
  119. package/dist/operations/mutation/types.d.ts +17 -0
  120. package/dist/operations/mutation/types.d.ts.map +1 -1
  121. package/dist/operations/mutation/upsert.d.ts +6 -0
  122. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  123. package/dist/operations/mutation/upsert.js +72 -4
  124. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  125. package/dist/operations/mutation/validate-upsert.js +24 -1
  126. package/dist/operations/mutation/validation.d.ts.map +1 -1
  127. package/dist/operations/mutation/validation.js +16 -3
  128. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  129. package/dist/operations/planning/apply-plan.js +61 -17
  130. package/dist/operations/planning/compile-intent.d.ts +49 -0
  131. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  132. package/dist/operations/planning/compile-intent.js +66 -4
  133. package/dist/operations/proof/baseline-diff.d.ts +41 -0
  134. package/dist/operations/proof/baseline-diff.d.ts.map +1 -0
  135. package/dist/operations/proof/baseline-diff.js +153 -0
  136. package/dist/operations/proof/code-scope.d.ts +17 -0
  137. package/dist/operations/proof/code-scope.d.ts.map +1 -0
  138. package/dist/operations/proof/code-scope.js +60 -0
  139. package/dist/operations/proof/explain.d.ts +75 -0
  140. package/dist/operations/proof/explain.d.ts.map +1 -0
  141. package/dist/operations/proof/explain.js +294 -0
  142. package/dist/operations/proof/impact.d.ts +45 -0
  143. package/dist/operations/proof/impact.d.ts.map +1 -0
  144. package/dist/operations/proof/impact.js +118 -0
  145. package/dist/operations/proof/ingest-proof.d.ts +4 -2
  146. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  147. package/dist/operations/proof/ingest-proof.js +251 -77
  148. package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
  149. package/dist/operations/proof/migrate-legacy-receipts.js +28 -22
  150. package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
  151. package/dist/operations/proof/prune-receipts.js +8 -6
  152. package/dist/operations/proof/receipt-document.js +2 -2
  153. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  154. package/dist/operations/semantic-advisor/analysis-receipt.js +3 -9
  155. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  156. package/dist/operations/semantic-advisor/analyze-prose.js +18 -67
  157. package/dist/operations/semantic-advisor/plugin-orchestration.d.ts +63 -0
  158. package/dist/operations/semantic-advisor/plugin-orchestration.d.ts.map +1 -0
  159. package/dist/operations/semantic-advisor/plugin-orchestration.js +489 -0
  160. package/dist/operations/semantic-advisor/predicate-rules-core.d.ts +15 -2
  161. package/dist/operations/semantic-advisor/predicate-rules-core.d.ts.map +1 -1
  162. package/dist/operations/semantic-advisor/predicate-rules-core.js +7 -140
  163. package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts +11 -12
  164. package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts.map +1 -1
  165. package/dist/operations/semantic-advisor/predicate-rules-launcher.js +6 -94
  166. package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts +16 -0
  167. package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts.map +1 -1
  168. package/dist/operations/semantic-advisor/predicate-rules-policy.js +7 -150
  169. package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts +9 -0
  170. package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts.map +1 -1
  171. package/dist/operations/semantic-advisor/predicate-rules-product-tail.js +7 -102
  172. package/dist/operations/semantic-advisor/predicate-rules-product.d.ts +13 -0
  173. package/dist/operations/semantic-advisor/predicate-rules-product.d.ts.map +1 -1
  174. package/dist/operations/semantic-advisor/predicate-rules-product.js +7 -133
  175. package/dist/operations/semantic-advisor/types.d.ts +1 -0
  176. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  177. package/dist/plugins/compose-ontology-packs.d.ts +51 -0
  178. package/dist/plugins/compose-ontology-packs.d.ts.map +1 -0
  179. package/dist/plugins/compose-ontology-packs.js +257 -0
  180. package/dist/plugins/compose-semantic-classifier.d.ts +47 -0
  181. package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -0
  182. package/dist/plugins/compose-semantic-classifier.js +216 -0
  183. package/dist/plugins/compose-vocabulary-alignment.d.ts +23 -0
  184. package/dist/plugins/compose-vocabulary-alignment.d.ts.map +1 -0
  185. package/dist/plugins/compose-vocabulary-alignment.js +141 -0
  186. package/dist/plugins/external-allowlist.d.ts +17 -0
  187. package/dist/plugins/external-allowlist.d.ts.map +1 -0
  188. package/dist/plugins/external-allowlist.js +29 -0
  189. package/dist/plugins/index.d.ts +11 -0
  190. package/dist/plugins/index.d.ts.map +1 -0
  191. package/dist/plugins/index.js +37 -0
  192. package/dist/plugins/load-plugin.d.ts +19 -0
  193. package/dist/plugins/load-plugin.d.ts.map +1 -0
  194. package/dist/plugins/load-plugin.js +59 -0
  195. package/dist/plugins/project-config.d.ts +28 -0
  196. package/dist/plugins/project-config.d.ts.map +1 -0
  197. package/dist/plugins/project-config.js +90 -0
  198. package/dist/plugins/registry.d.ts +94 -0
  199. package/dist/plugins/registry.d.ts.map +1 -0
  200. package/dist/plugins/registry.js +359 -0
  201. package/dist/plugins/resolve-package.d.ts +47 -0
  202. package/dist/plugins/resolve-package.d.ts.map +1 -0
  203. package/dist/plugins/resolve-package.js +262 -0
  204. package/dist/plugins/source-analysis-service.d.ts +44 -0
  205. package/dist/plugins/source-analysis-service.d.ts.map +1 -0
  206. package/dist/plugins/source-analysis-service.js +232 -0
  207. package/dist/prolog/codec.d.ts.map +1 -1
  208. package/dist/prolog/codec.js +2 -0
  209. package/dist/prolog/janitor.d.ts.map +1 -1
  210. package/dist/prolog/janitor.js +1 -1
  211. package/dist/prolog/store-lock.d.ts +1 -1
  212. package/dist/prolog/store-lock.d.ts.map +1 -1
  213. package/dist/prolog.d.ts +36 -0
  214. package/dist/prolog.d.ts.map +1 -1
  215. package/dist/prolog.js +78 -9
  216. package/dist/proof/inspect.js +1 -1
  217. package/dist/proof/producers/playwright-case-id.js +2 -2
  218. package/dist/proof/producers/playwright-reporter.js +4 -4
  219. package/dist/public/diagnostic-usage.d.ts.map +1 -1
  220. package/dist/public/diagnostic-usage.js +7 -25
  221. package/dist/public/extractors/symbols-coordinator.d.ts +1 -1
  222. package/dist/public/extractors/symbols-coordinator.d.ts.map +1 -1
  223. package/dist/public/extractors/symbols-coordinator.js +1 -1
  224. package/dist/public/impact/analyzer.d.ts +1 -1
  225. package/dist/public/impact/analyzer.d.ts.map +1 -1
  226. package/dist/public/impact/analyzer.js +6 -4
  227. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  228. package/dist/public/impact/full-kb-quality.js +4 -12
  229. package/dist/public/operations/catalog.d.ts +39 -7
  230. package/dist/public/operations/catalog.d.ts.map +1 -1
  231. package/dist/public/operations/check-executor.d.ts.map +1 -1
  232. package/dist/public/operations/check-executor.js +11 -3
  233. package/dist/public/operations/check-helpers.d.ts +7 -1
  234. package/dist/public/operations/check-helpers.d.ts.map +1 -1
  235. package/dist/public/operations/check-helpers.js +22 -2
  236. package/dist/public/operations/contracts.d.ts.map +1 -1
  237. package/dist/public/operations/contracts.js +51 -12
  238. package/dist/public/operations/discovery-entities.d.ts +53 -1
  239. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  240. package/dist/public/operations/discovery-entities.js +219 -12
  241. package/dist/public/operations/discovery-executors.d.ts +1 -0
  242. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  243. package/dist/public/operations/discovery-executors.js +93 -59
  244. package/dist/public/operations/migration-plan.d.ts +2 -0
  245. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  246. package/dist/public/operations/migration-plan.js +50 -0
  247. package/dist/public/operations/predicate-schema-conformance.d.ts +41 -0
  248. package/dist/public/operations/predicate-schema-conformance.d.ts.map +1 -0
  249. package/dist/public/operations/predicate-schema-conformance.js +242 -0
  250. package/dist/public/operations/prolog-json.d.ts +1 -1
  251. package/dist/public/operations/prolog-json.d.ts.map +1 -1
  252. package/dist/public/operations/prolog-json.js +16 -10
  253. package/dist/public/operations/result-envelope.d.ts +34 -1
  254. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  255. package/dist/public/operations/result-envelope.js +78 -2
  256. package/dist/public/operations/runtime-types.d.ts +17 -2
  257. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  258. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  259. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  260. package/dist/public/operations/specs/check-rules.generated.js +9 -1
  261. package/dist/public/operations/specs/check.d.ts +1 -1
  262. package/dist/public/operations/specs/discovery.d.ts +10 -1
  263. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  264. package/dist/public/operations/specs/discovery.js +10 -1
  265. package/dist/public/operations/specs/mutation-schemas.d.ts +27 -4
  266. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  267. package/dist/public/operations/specs/mutation-schemas.js +21 -3
  268. package/dist/public/operations/specs/proof.js +1 -1
  269. package/dist/public/operations/specs/reporting.d.ts +9 -0
  270. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  271. package/dist/public/operations/specs/reporting.js +48 -17
  272. package/dist/public/operations/specs/semantic.d.ts +1 -1
  273. package/dist/public/operations/specs/semantic.d.ts.map +1 -1
  274. package/dist/public/operations/specs/semantic.js +54 -4
  275. package/dist/public/operations/specs/upsert.d.ts +28 -5
  276. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  277. package/dist/public/operations/specs/upsert.js +1 -1
  278. package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
  279. package/dist/public/operations/symbol-repair-plan.js +11 -4
  280. package/dist/public/operations/types.d.ts +5 -0
  281. package/dist/public/operations/types.d.ts.map +1 -1
  282. package/dist/public/proof-protocol.js +4 -4
  283. package/dist/public/schemas/entity.d.ts.map +1 -1
  284. package/dist/public/schemas/entity.js +22 -0
  285. package/dist/public/schemas/relationship.d.ts.map +1 -1
  286. package/dist/public/schemas/relationship.js +1 -0
  287. package/dist/public/skills/kibi-usage/SKILL.md +10 -3
  288. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
  289. package/dist/public/skills/kibi-usage/resources/proof.md +45 -0
  290. package/dist/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
  291. package/dist/public/skills/kibi-usage/resources/source-authoring.md +36 -0
  292. package/dist/public/skills/kibi-usage/resources/workflows.md +52 -1
  293. package/dist/public/symbol-granularity.d.ts +1 -1
  294. package/dist/public/symbol-granularity.d.ts.map +1 -1
  295. package/dist/public/symbol-granularity.generated.d.ts.map +1 -1
  296. package/dist/public/symbol-granularity.generated.js +38 -5
  297. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  298. package/dist/public/telemetry-acceptance.js +21 -5
  299. package/dist/relationships/shards.d.ts +6 -0
  300. package/dist/relationships/shards.d.ts.map +1 -1
  301. package/dist/relationships/shards.js +26 -19
  302. package/dist/report/html-report.css +1239 -281
  303. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  304. package/dist/runtime/cli-runtime.js +18 -0
  305. package/dist/schemas/entity.schema.json +32 -0
  306. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  307. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  308. package/dist/traceability/staged-entity-id-style.d.ts +12 -0
  309. package/dist/traceability/staged-entity-id-style.d.ts.map +1 -0
  310. package/dist/traceability/staged-entity-id-style.js +68 -0
  311. package/dist/traceability/symbol-extract.d.ts +24 -7
  312. package/dist/traceability/symbol-extract.d.ts.map +1 -1
  313. package/dist/traceability/symbol-extract.js +64 -208
  314. package/dist/traceability/temp-kb.d.ts.map +1 -1
  315. package/dist/traceability/temp-kb.js +8 -0
  316. package/dist/traceability/validate.js +1 -1
  317. package/dist/types/entities.d.ts +2 -0
  318. package/dist/types/entities.d.ts.map +1 -1
  319. package/dist/types/relationships.d.ts +1 -1
  320. package/dist/types/relationships.d.ts.map +1 -1
  321. package/dist/utils/entity-id-style.d.ts +27 -0
  322. package/dist/utils/entity-id-style.d.ts.map +1 -0
  323. package/dist/utils/entity-id-style.js +81 -0
  324. package/dist/utils/git-repository-context.d.ts +50 -0
  325. package/dist/utils/git-repository-context.d.ts.map +1 -0
  326. package/dist/utils/git-repository-context.js +259 -0
  327. package/dist/utils/rule-registry.d.ts +5 -0
  328. package/dist/utils/rule-registry.d.ts.map +1 -1
  329. package/dist/utils/rule-registry.generated.d.ts +42 -0
  330. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  331. package/dist/utils/rule-registry.generated.js +50 -0
  332. package/dist/utils/strict-modeling.d.ts +7 -0
  333. package/dist/utils/strict-modeling.d.ts.map +1 -1
  334. package/dist/utils/strict-modeling.js +11 -0
  335. package/package.json +14 -11
  336. package/schema/entities.pl +60 -1
  337. package/schema/relationships.pl +17 -4
  338. package/schema/validation.pl +118 -20
  339. package/src/public/diagnostic-usage.ts +16 -24
  340. package/src/public/extractors/symbols-coordinator.ts +1 -0
  341. package/src/public/impact/analyzer.ts +15 -12
  342. package/src/public/impact/full-kb-quality.ts +4 -16
  343. package/src/public/operations/check-executor.ts +13 -2
  344. package/src/public/operations/check-helpers.ts +29 -3
  345. package/src/public/operations/contracts.ts +59 -12
  346. package/src/public/operations/discovery-entities.ts +327 -12
  347. package/src/public/operations/discovery-executors.ts +110 -61
  348. package/src/public/operations/migration-plan.ts +57 -0
  349. package/src/public/operations/predicate-schema-conformance.ts +362 -0
  350. package/src/public/operations/prolog-json.ts +22 -8
  351. package/src/public/operations/result-envelope.ts +114 -2
  352. package/src/public/operations/runtime-types.ts +22 -3
  353. package/src/public/operations/specs/check-rules.generated.ts +9 -1
  354. package/src/public/operations/specs/discovery.ts +11 -1
  355. package/src/public/operations/specs/mutation-schemas.ts +23 -3
  356. package/src/public/operations/specs/proof.ts +1 -1
  357. package/src/public/operations/specs/reporting.ts +71 -24
  358. package/src/public/operations/specs/semantic.ts +79 -17
  359. package/src/public/operations/specs/upsert.ts +1 -1
  360. package/src/public/operations/symbol-repair-plan.ts +16 -7
  361. package/src/public/operations/types.ts +5 -0
  362. package/src/public/proof-fingerprint.ts +1 -1
  363. package/src/public/proof-protocol-types.d.ts +1 -1
  364. package/src/public/proof-protocol.ts +4 -4
  365. package/src/public/schemas/entity.ts +22 -0
  366. package/src/public/schemas/relationship.ts +1 -0
  367. package/src/public/skills/kibi-usage/SKILL.md +10 -3
  368. package/src/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
  369. package/src/public/skills/kibi-usage/resources/proof.md +45 -0
  370. package/src/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
  371. package/src/public/skills/kibi-usage/resources/source-authoring.md +36 -0
  372. package/src/public/skills/kibi-usage/resources/workflows.md +52 -1
  373. package/src/public/symbol-granularity.generated.ts +45 -12
  374. package/src/public/symbol-granularity.ts +3 -3
  375. package/src/public/telemetry-acceptance.ts +37 -6
  376. package/src/schemas/entity.schema.json +32 -0
  377. package/src/schemas/relationship.schema.json +1 -0
@@ -0,0 +1,153 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+ */
10
+ // implements REQ-kibi-verification-evidence-contract
11
+ export const PROOF_BASELINE_VERSION = "kibi.proof-baseline.v2";
12
+ function asStringArray(value) {
13
+ if (!Array.isArray(value))
14
+ return [];
15
+ return value
16
+ .map((item) => (typeof item === "string" ? item : String(item)))
17
+ .sort();
18
+ }
19
+ // implements REQ-kibi-verification-evidence-contract
20
+ export function fingerprintRequirements(rows) {
21
+ const requirements = {};
22
+ for (const row of rows) {
23
+ const id = typeof row.id === "string" ? row.id : "";
24
+ const proofStatus = typeof row.proofStatus === "string" ? row.proofStatus : "";
25
+ if (id === "" || proofStatus === "not_applicable")
26
+ continue;
27
+ requirements[id] = {
28
+ proofStatus,
29
+ gaps: asStringArray(row.proofGaps),
30
+ uncoveredSymbols: asStringArray(row.proofStages?.productionSymbols?.uncoveredSymbols),
31
+ };
32
+ }
33
+ return requirements;
34
+ }
35
+ // implements REQ-kibi-verification-evidence-contract
36
+ export function diffFingerprints(baseline, current) {
37
+ const before = baseline ?? {};
38
+ const ids = [
39
+ ...new Set([...Object.keys(before), ...Object.keys(current)]),
40
+ ].sort();
41
+ const changes = [];
42
+ for (const id of ids) {
43
+ const left = before[id];
44
+ const right = current[id];
45
+ if (left === undefined && right !== undefined) {
46
+ changes.push({ id, kind: "added", after: right });
47
+ continue;
48
+ }
49
+ if (left !== undefined && right === undefined) {
50
+ changes.push({ id, kind: "removed", before: left });
51
+ continue;
52
+ }
53
+ if (left === undefined || right === undefined)
54
+ continue;
55
+ if (left.proofStatus !== right.proofStatus ||
56
+ JSON.stringify(left.gaps) !== JSON.stringify(right.gaps) ||
57
+ JSON.stringify(left.uncoveredSymbols) !==
58
+ JSON.stringify(right.uncoveredSymbols)) {
59
+ changes.push({ id, kind: "changed", before: left, after: right });
60
+ }
61
+ }
62
+ return changes;
63
+ }
64
+ export function explanationsForRequirement(rows, requirementId) {
65
+ const row = rows.find((item) => item.id === requirementId);
66
+ const explanations = row?.proofStages?.productionSymbols?.explanations;
67
+ return Array.isArray(explanations)
68
+ ? explanations
69
+ : [];
70
+ }
71
+ function renderCandidate(candidate) {
72
+ const testId = typeof candidate.testId === "string" ? candidate.testId : "?";
73
+ const reason = typeof candidate.reason === "string" ? candidate.reason : "";
74
+ const secondaries = Array.isArray(candidate.secondaryReasons)
75
+ ? candidate.secondaryReasons.filter((item) => typeof item === "string")
76
+ : [];
77
+ const secondaryText = secondaries.length > 0 ? ` secondary=${secondaries.join(",")}` : "";
78
+ return ` covered_by ${testId}: ${reason}${secondaryText}`;
79
+ }
80
+ // implements REQ-kibi-verification-evidence-contract
81
+ export function renderRequirementDiffs(changes, rows = []) {
82
+ if (changes.length === 0)
83
+ return "";
84
+ const lines = [
85
+ "Requirement fingerprint diffs vs committed proof/baseline.json:",
86
+ ];
87
+ for (const change of changes) {
88
+ if (change.kind === "added" && change.after) {
89
+ lines.push(` ${change.id}: added (${change.after.proofStatus}; gaps=${change.after.gaps.join(",") || "none"})`);
90
+ }
91
+ else if (change.kind === "removed" && change.before) {
92
+ lines.push(` ${change.id}: removed (was ${change.before.proofStatus})`);
93
+ }
94
+ else if (change.kind === "changed" && change.before && change.after) {
95
+ if (change.before.proofStatus !== change.after.proofStatus) {
96
+ lines.push(` ${change.id}: ${change.before.proofStatus} -> ${change.after.proofStatus}`);
97
+ }
98
+ else {
99
+ lines.push(` ${change.id}: fingerprint changed`);
100
+ }
101
+ const beforeGaps = new Set(change.before.gaps);
102
+ const afterGaps = new Set(change.after.gaps);
103
+ for (const gap of change.after.gaps) {
104
+ if (!beforeGaps.has(gap))
105
+ lines.push(` gap added: ${gap}`);
106
+ }
107
+ for (const gap of change.before.gaps) {
108
+ if (!afterGaps.has(gap))
109
+ lines.push(` gap removed: ${gap}`);
110
+ }
111
+ const beforeSymbols = new Set(change.before.uncoveredSymbols);
112
+ const afterSymbols = new Set(change.after.uncoveredSymbols);
113
+ for (const symbol of change.after.uncoveredSymbols) {
114
+ if (!beforeSymbols.has(symbol))
115
+ lines.push(` uncovered symbol added: ${symbol}`);
116
+ }
117
+ for (const symbol of change.before.uncoveredSymbols) {
118
+ if (!afterSymbols.has(symbol))
119
+ lines.push(` uncovered symbol removed: ${symbol}`);
120
+ }
121
+ }
122
+ const explanations = explanationsForRequirement(rows, change.id);
123
+ for (const explanation of explanations) {
124
+ const symbolId = typeof explanation.symbolId === "string" ? explanation.symbolId : "";
125
+ const reason = typeof explanation.reason === "string" ? explanation.reason : "";
126
+ if (symbolId !== "")
127
+ lines.push(` ${symbolId}: ${reason}`);
128
+ const candidates = Array.isArray(explanation.coverageCandidates)
129
+ ? explanation.coverageCandidates
130
+ : [];
131
+ for (const candidate of candidates) {
132
+ if (candidate && typeof candidate === "object")
133
+ lines.push(renderCandidate(candidate));
134
+ }
135
+ }
136
+ }
137
+ return `${lines.join("\n")}\n`;
138
+ }
139
+ export function parseSpawnJson(result) {
140
+ if (result.error)
141
+ throw result.error;
142
+ const text = `${result.stdout ?? ""}`.trim();
143
+ try {
144
+ return JSON.parse(text);
145
+ }
146
+ catch (error) {
147
+ const detail = `${result.stderr || result.stdout || ""}`.trim();
148
+ if (result.status !== 0 && result.status !== null) {
149
+ throw new Error(detail || String(error));
150
+ }
151
+ throw error;
152
+ }
153
+ }
@@ -0,0 +1,17 @@
1
+ import type { PrologPort } from "../../public/operations/runtime-types.js";
2
+ /**
3
+ * Which symbols a proof receipt's per-contract binding covers. Receipt ingest
4
+ * (which writes `binding_hash`) and coverage (which checks it) must derive
5
+ * the same set, so both go through this module:
6
+ *
7
+ * - the contract's required proof symbols (the test's own executable code),
8
+ * - any symbols the test declares in `proof_bindings`,
9
+ * - every production symbol linked `covered_by` this test.
10
+ *
11
+ * Editing any of those symbols' source files changes the binding hash, so the
12
+ * receipt goes stale until the test is proven again on the new code.
13
+ */
14
+ export declare function receiptCodeScopeSymbolIds(contract: unknown, bindings: unknown, coveredBySymbols: readonly string[]): string[];
15
+ /** Map each test id to the symbols linked `covered_by` it, in one query. */
16
+ export declare function loadCoveredBySymbolsByTest(prolog: Pick<PrologPort, "query">): Promise<ReadonlyMap<string, readonly string[]>>;
17
+ //# sourceMappingURL=code-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-scope.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/code-scope.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E;;;;;;;;;;;GAWG;AAEH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,gBAAgB,EAAE,SAAS,MAAM,EAAE,GAClC,MAAM,EAAE,CAoBV;AAED,4EAA4E;AAE5E,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,GAChC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAiBjD"}
@@ -0,0 +1,60 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+ */
10
+ import { normalizeEntityId, parseTriples } from "../../prolog/codec.js";
11
+ /**
12
+ * Which symbols a proof receipt's per-contract binding covers. Receipt ingest
13
+ * (which writes `binding_hash`) and coverage (which checks it) must derive
14
+ * the same set, so both go through this module:
15
+ *
16
+ * - the contract's required proof symbols (the test's own executable code),
17
+ * - any symbols the test declares in `proof_bindings`,
18
+ * - every production symbol linked `covered_by` this test.
19
+ *
20
+ * Editing any of those symbols' source files changes the binding hash, so the
21
+ * receipt goes stale until the test is proven again on the new code.
22
+ */
23
+ // implements REQ-kibi-verification-evidence-contract
24
+ export function receiptCodeScopeSymbolIds(contract, bindings, coveredBySymbols) {
25
+ const ids = new Set();
26
+ const requiredProofs = contract !== null &&
27
+ typeof contract === "object" &&
28
+ Array.isArray(contract.required_proofs)
29
+ ? contract.required_proofs
30
+ : [];
31
+ for (const entry of [
32
+ ...requiredProofs,
33
+ ...(Array.isArray(bindings) ? bindings : []),
34
+ ]) {
35
+ const symbolId = entry !== null && typeof entry === "object"
36
+ ? entry.symbol_id
37
+ : undefined;
38
+ if (typeof symbolId === "string" && symbolId !== "")
39
+ ids.add(symbolId);
40
+ }
41
+ for (const symbolId of coveredBySymbols)
42
+ ids.add(symbolId);
43
+ return [...ids].sort();
44
+ }
45
+ /** Map each test id to the symbols linked `covered_by` it, in one query. */
46
+ // implements REQ-kibi-verification-evidence-contract
47
+ export async function loadCoveredBySymbolsByTest(prolog) {
48
+ const result = await prolog.query("findall([From,To,'covered_by'], kb_relationship(covered_by, From, To), Rels)");
49
+ if (!result.success) {
50
+ throw new Error(`covered_by relationship query failed: ${result.error ?? "Unknown error"}`);
51
+ }
52
+ const byTest = new Map();
53
+ for (const [rawFrom, rawTo] of parseTriples(result.bindings.Rels ?? "[]")) {
54
+ const testId = normalizeEntityId(rawTo);
55
+ const symbols = byTest.get(testId) ?? [];
56
+ symbols.push(normalizeEntityId(rawFrom));
57
+ byTest.set(testId, symbols);
58
+ }
59
+ return byTest;
60
+ }
@@ -0,0 +1,75 @@
1
+ import type { OperationContext } from "../../public/operations/runtime-types.js";
2
+ export type ProofExplainKind = "requirement" | "symbol";
3
+ export type ProofResolutionRef = {
4
+ readonly id?: string;
5
+ readonly sourceFile?: string;
6
+ readonly path?: string;
7
+ readonly role?: string;
8
+ readonly exists?: boolean;
9
+ };
10
+ export type ProofCoverageCandidate = {
11
+ readonly testId: string;
12
+ readonly relationship: string;
13
+ readonly qualifies: boolean;
14
+ readonly reason: string;
15
+ readonly reasonText?: string;
16
+ readonly secondaryReasons: readonly string[];
17
+ readonly scope?: string;
18
+ readonly receiptState?: string;
19
+ };
20
+ export type ProofExplainTestBlock = {
21
+ readonly testId: string;
22
+ readonly requiredProofs: readonly ProofResolutionRef[];
23
+ readonly executableFor: readonly ProofResolutionRef[];
24
+ };
25
+ export type ProofExplainSymbolBlock = {
26
+ readonly symbolId: string;
27
+ readonly classification: string;
28
+ readonly status: string;
29
+ readonly reason: string;
30
+ readonly reasonText?: string;
31
+ readonly coverageCandidates: readonly ProofCoverageCandidate[];
32
+ };
33
+ export type RequirementProofExplainView = {
34
+ readonly kind: "requirement";
35
+ readonly id: string;
36
+ readonly proofVersion: string;
37
+ readonly proofStatus: string;
38
+ readonly proofGaps: readonly string[];
39
+ readonly scenarios: readonly {
40
+ id: string;
41
+ tests: readonly string[];
42
+ }[];
43
+ readonly tests: readonly ProofExplainTestBlock[];
44
+ readonly productionSymbols: readonly ProofExplainSymbolBlock[];
45
+ readonly structuralSymbols: readonly ProofExplainSymbolBlock[];
46
+ };
47
+ export type SymbolProofExplainView = {
48
+ readonly kind: "symbol";
49
+ readonly id: string;
50
+ readonly role: string;
51
+ readonly executableTest: boolean;
52
+ readonly implementingRequirements: readonly string[];
53
+ readonly executableFor: readonly string[];
54
+ readonly coveredBy: readonly string[];
55
+ readonly proofs: readonly RequirementProofExplainView[];
56
+ };
57
+ export type ProofExplainView = RequirementProofExplainView | SymbolProofExplainView;
58
+ export declare function projectRequirementExplain(proof: Record<string, unknown>): RequirementProofExplainView;
59
+ export declare function projectSymbolExplain(payload: Record<string, unknown>): SymbolProofExplainView;
60
+ export declare function renderProofExplain(view: ProofExplainView): string;
61
+ export declare function classifyExplainTarget(id: string | undefined, options: {
62
+ requirement?: string;
63
+ symbol?: string;
64
+ }): {
65
+ kind: ProofExplainKind;
66
+ id: string;
67
+ };
68
+ export declare function executeProofExplain(target: {
69
+ kind: ProofExplainKind;
70
+ id: string;
71
+ }, context: OperationContext): Promise<{
72
+ view: ProofExplainView;
73
+ payload: Record<string, unknown>;
74
+ }>;
75
+ //# sourceMappingURL=explain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/explain.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,0CAA0C,CAAC;AAQlD,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,QAAQ,CAAC;AAExD,MA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oB,CAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,sBAAsB,CAcxB;AAGD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAGjE;AAgGD,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAcxC;AAwBD,wBAAsB,mBAAmB,CACvC,MAAM,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,EAC9C,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC,CAmBvE"}
@@ -0,0 +1,294 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+ */
10
+ import { runOperationJsonQuery, toPrologAtom, } from "../../public/operations/prolog-json.js";
11
+ import { currentProofBindingMode, perContractTestBindings, } from "../../public/operations/specs/reporting.js";
12
+ import { readWorkspaceSnapshot } from "../../public/operations/workspace-snapshot.js";
13
+ import { PROOF_RECEIPT_MAX_AGE_SECONDS } from "../../public/proof-receipt.js";
14
+ function requireProlog(context) {
15
+ if (context.prolog === undefined) {
16
+ throw new Error("Proof explain requires a Prolog runtime");
17
+ }
18
+ return context.prolog;
19
+ }
20
+ function asRecord(value) {
21
+ return value !== null && typeof value === "object"
22
+ ? value
23
+ : {};
24
+ }
25
+ function asString(value, fallback = "") {
26
+ return typeof value === "string" ? value : fallback;
27
+ }
28
+ function asStringArray(value) {
29
+ if (!Array.isArray(value))
30
+ return [];
31
+ return value.map((item) => asString(item)).filter((item) => item !== "");
32
+ }
33
+ function asBoolean(value) {
34
+ return value === true;
35
+ }
36
+ function asRef(value) {
37
+ const row = asRecord(value);
38
+ return {
39
+ ...(typeof row.id === "string" ? { id: row.id } : {}),
40
+ ...(typeof row.sourceFile === "string"
41
+ ? { sourceFile: row.sourceFile }
42
+ : {}),
43
+ ...(typeof row.path === "string" ? { path: row.path } : {}),
44
+ ...(typeof row.role === "string" ? { role: row.role } : {}),
45
+ ...(row.exists === true || row.exists === false
46
+ ? { exists: row.exists }
47
+ : {}),
48
+ };
49
+ }
50
+ function asCandidate(value) {
51
+ const row = asRecord(value);
52
+ return {
53
+ testId: asString(row.testId),
54
+ relationship: asString(row.relationship, "covered_by"),
55
+ qualifies: asBoolean(row.qualifies),
56
+ reason: asString(row.reason),
57
+ ...(typeof row.reasonText === "string"
58
+ ? { reasonText: row.reasonText }
59
+ : {}),
60
+ secondaryReasons: asStringArray(row.secondaryReasons),
61
+ ...(typeof row.scope === "string" ? { scope: row.scope } : {}),
62
+ ...(typeof row.receiptState === "string"
63
+ ? { receiptState: row.receiptState }
64
+ : {}),
65
+ };
66
+ }
67
+ function asSymbolBlock(value) {
68
+ const row = asRecord(value);
69
+ return {
70
+ symbolId: asString(row.symbolId),
71
+ classification: asString(row.classification, "unknown"),
72
+ status: asString(row.status),
73
+ reason: asString(row.reason),
74
+ ...(typeof row.reasonText === "string"
75
+ ? { reasonText: row.reasonText }
76
+ : {}),
77
+ coverageCandidates: Array.isArray(row.coverageCandidates)
78
+ ? row.coverageCandidates.map(asCandidate)
79
+ : [],
80
+ };
81
+ }
82
+ // implements REQ-kibi-verification-evidence-contract
83
+ export function projectRequirementExplain(proof) {
84
+ const stages = asRecord(proof.proofStages);
85
+ const scenarioStage = asRecord(stages.scenarios);
86
+ const scenarioTestStage = asRecord(stages.scenarioTests);
87
+ const production = asRecord(stages.productionSymbols);
88
+ const obligations = Array.isArray(scenarioTestStage.obligations)
89
+ ? scenarioTestStage.obligations.map(asRecord)
90
+ : [];
91
+ const resolutions = Array.isArray(proof.testResolutions ?? scenarioTestStage.resolutions)
92
+ ? (proof.testResolutions ?? scenarioTestStage.resolutions)
93
+ : [];
94
+ const resolutionByTest = new Map();
95
+ for (const item of resolutions) {
96
+ const row = asRecord(item);
97
+ const testId = asString(row.testId);
98
+ if (testId === "")
99
+ continue;
100
+ resolutionByTest.set(testId, {
101
+ testId,
102
+ requiredProofs: Array.isArray(row.requiredProofs)
103
+ ? row.requiredProofs.map(asRef)
104
+ : [],
105
+ executableFor: Array.isArray(row.executableFor)
106
+ ? row.executableFor.map(asRef)
107
+ : [],
108
+ });
109
+ }
110
+ const tests = asStringArray(scenarioTestStage.tests).map((testId) => {
111
+ return (resolutionByTest.get(testId) ?? {
112
+ testId,
113
+ requiredProofs: [],
114
+ executableFor: [],
115
+ });
116
+ });
117
+ const scenarios = (Array.isArray(scenarioStage.scenarios)
118
+ ? scenarioStage.scenarios
119
+ : asStringArray(scenarioStage.scenarios)).map((scenarioId) => {
120
+ const id = asString(scenarioId);
121
+ const obligation = obligations.find((item) => asString(item.scenarioId) === id);
122
+ return {
123
+ id,
124
+ tests: asStringArray(obligation?.tests),
125
+ };
126
+ });
127
+ const explanations = Array.isArray(production.explanations)
128
+ ? production.explanations.map(asSymbolBlock)
129
+ : [];
130
+ const structuralIds = new Set(asStringArray(production.structuralSymbols));
131
+ return {
132
+ kind: "requirement",
133
+ id: asString(proof.id),
134
+ proofVersion: asString(proof.proofVersion),
135
+ proofStatus: asString(proof.proofStatus),
136
+ proofGaps: asStringArray(proof.proofGaps),
137
+ scenarios,
138
+ tests,
139
+ productionSymbols: explanations.filter((item) => !structuralIds.has(item.symbolId)),
140
+ structuralSymbols: explanations.filter((item) => structuralIds.has(item.symbolId)),
141
+ };
142
+ }
143
+ // implements REQ-kibi-verification-evidence-contract
144
+ export function projectSymbolExplain(payload) {
145
+ const proofs = Array.isArray(payload.proofs)
146
+ ? payload.proofs.map((item) => projectRequirementExplain(asRecord(item)))
147
+ : [];
148
+ return {
149
+ kind: "symbol",
150
+ id: asString(payload.symbolId ?? payload.id),
151
+ role: asString(payload.role, "unknown"),
152
+ executableTest: asBoolean(payload.executableTest),
153
+ implementingRequirements: asStringArray(payload.implementingRequirements),
154
+ executableFor: asStringArray(payload.executableFor),
155
+ coveredBy: asStringArray(payload.coveredBy),
156
+ proofs,
157
+ };
158
+ }
159
+ // implements REQ-kibi-verification-evidence-contract
160
+ export function renderProofExplain(view) {
161
+ if (view.kind === "symbol")
162
+ return renderSymbolExplain(view);
163
+ return renderRequirementExplain(view);
164
+ }
165
+ function renderRequirementExplain(view) {
166
+ const lines = [
167
+ `Proof explain for ${view.id}`,
168
+ `proofVersion: ${view.proofVersion}`,
169
+ `proofStatus: ${view.proofStatus}`,
170
+ `proofGaps: ${view.proofGaps.join(", ") || "(none)"}`,
171
+ "",
172
+ "Scenarios",
173
+ ];
174
+ if (view.scenarios.length === 0)
175
+ lines.push(" (none)");
176
+ for (const scenario of view.scenarios) {
177
+ lines.push(` ${scenario.id} -> ${scenario.tests.join(", ") || "(no tests)"}`);
178
+ }
179
+ lines.push("");
180
+ for (const test of view.tests) {
181
+ lines.push(`TEST ${test.testId}`);
182
+ lines.push(" required_proofs");
183
+ if (test.requiredProofs.length === 0)
184
+ lines.push(" (none)");
185
+ for (const ref of test.requiredProofs) {
186
+ lines.push(` ${formatRef(ref)}`);
187
+ }
188
+ lines.push(" executable_for");
189
+ if (test.executableFor.length === 0)
190
+ lines.push(" (none)");
191
+ for (const ref of test.executableFor) {
192
+ lines.push(` ${formatRef(ref)}`);
193
+ }
194
+ lines.push("");
195
+ }
196
+ lines.push("Production symbols");
197
+ if (view.productionSymbols.length === 0)
198
+ lines.push(" (none)");
199
+ for (const symbol of view.productionSymbols) {
200
+ lines.push(renderSymbolCoverage(symbol));
201
+ }
202
+ if (view.structuralSymbols.length > 0) {
203
+ lines.push("");
204
+ lines.push("Structural symbols");
205
+ for (const symbol of view.structuralSymbols) {
206
+ lines.push(renderSymbolCoverage(symbol));
207
+ }
208
+ }
209
+ return `${lines.join("\n")}\n`;
210
+ }
211
+ function renderSymbolExplain(view) {
212
+ const lines = [
213
+ `Proof explain for ${view.id}`,
214
+ `role: ${view.role}`,
215
+ `executable_test: ${view.executableTest ? "true" : "false"}`,
216
+ `implementing requirements: ${view.implementingRequirements.join(", ") || "(none)"}`,
217
+ "executable_for",
218
+ ...(view.executableFor.length === 0
219
+ ? [" (none)"]
220
+ : view.executableFor.map((id) => ` ${id}`)),
221
+ "covered_by",
222
+ ...(view.coveredBy.length === 0
223
+ ? [" (none)"]
224
+ : view.coveredBy.map((id) => ` ${id}`)),
225
+ ];
226
+ for (const proof of view.proofs) {
227
+ lines.push("");
228
+ lines.push(`Requirement ${proof.id} (${proof.proofStatus})`);
229
+ lines.push(renderRequirementExplain(proof).trimEnd());
230
+ }
231
+ return `${lines.join("\n")}\n`;
232
+ }
233
+ function renderSymbolCoverage(symbol) {
234
+ const lines = [
235
+ ` ${symbol.symbolId} [${symbol.classification}] ${symbol.status} ${symbol.reason}`,
236
+ " covered_by",
237
+ ];
238
+ if (symbol.coverageCandidates.length === 0)
239
+ lines.push(" (none)");
240
+ for (const candidate of symbol.coverageCandidates) {
241
+ const secondaries = candidate.secondaryReasons.length > 0
242
+ ? ` secondary=${candidate.secondaryReasons.join(",")}`
243
+ : "";
244
+ lines.push(` ${candidate.testId} qualifies=${candidate.qualifies} reason=${candidate.reason}${secondaries}`);
245
+ }
246
+ return lines.join("\n");
247
+ }
248
+ function formatRef(ref) {
249
+ const id = ref.id ?? "(unresolved)";
250
+ const path = ref.path ?? ref.sourceFile ?? "";
251
+ const role = ref.role ? ` role=${ref.role}` : "";
252
+ return path === "" ? `${id}${role}` : `${id} ${path}${role}`;
253
+ }
254
+ // implements REQ-kibi-verification-evidence-contract
255
+ export function classifyExplainTarget(id, options) {
256
+ if (options.requirement && options.symbol) {
257
+ throw new Error("proof explain: choose either --requirement or --symbol, not both");
258
+ }
259
+ if (options.requirement)
260
+ return { kind: "requirement", id: options.requirement };
261
+ if (options.symbol)
262
+ return { kind: "symbol", id: options.symbol };
263
+ if (id?.startsWith("REQ-"))
264
+ return { kind: "requirement", id };
265
+ if (id?.startsWith("SYM-"))
266
+ return { kind: "symbol", id };
267
+ throw new Error("proof explain: pass REQ-* or SYM-* (or --requirement / --symbol)");
268
+ }
269
+ async function proofQueryContext(context) {
270
+ const snapshotEvidence = await readWorkspaceSnapshot(context);
271
+ const snapshot = snapshotEvidence.available
272
+ ? snapshotEvidence.snapshot.hash
273
+ : "unknown";
274
+ const checkedAt = context.clock().toISOString();
275
+ const bindingsDict = await perContractTestBindings(context);
276
+ const bindingMode = bindingsDict !== null ? "per_contract" : currentProofBindingMode();
277
+ const bindings = bindingsDict ?? "_{}";
278
+ return {
279
+ snapshot,
280
+ checkedAt,
281
+ bindingsGoal: `${bindingMode}, ${bindings}, ${toPrologAtom(snapshot)}, ${toPrologAtom(checkedAt)}, ${PROOF_RECEIPT_MAX_AGE_SECONDS}`,
282
+ };
283
+ }
284
+ // implements REQ-kibi-verification-evidence-contract
285
+ export async function executeProofExplain(target, context) {
286
+ const query = await proofQueryContext(context);
287
+ if (target.kind === "requirement") {
288
+ const payload = await runOperationJsonQuery(requireProlog(context), "discovery.pl", `discovery:requirement_proof_json(${toPrologAtom(target.id)}, ${query.bindingsGoal}, JsonString)`, "Proof explain");
289
+ const withId = { id: target.id, ...payload };
290
+ return { view: projectRequirementExplain(withId), payload: withId };
291
+ }
292
+ const payload = await runOperationJsonQuery(requireProlog(context), "discovery.pl", `discovery:symbol_proof_json(${toPrologAtom(target.id)}, ${query.bindingsGoal}, JsonString)`, "Proof explain");
293
+ return { view: projectSymbolExplain(payload), payload };
294
+ }
@@ -0,0 +1,45 @@
1
+ import type { OperationContext } from "../../public/operations/runtime-types.js";
2
+ import { type CoverageRowLike, type RequirementFingerprints, diffFingerprints } from "./baseline-diff.js";
3
+ export declare const COMMITTED_BASELINE_PATH = "proof/baseline.json";
4
+ export type ProofBaselineFile = {
5
+ readonly version?: string;
6
+ readonly mode?: string;
7
+ readonly currentRequirements?: number;
8
+ readonly proofProven?: number;
9
+ readonly currentUnproven?: number;
10
+ readonly trackedGaps?: Record<string, number>;
11
+ readonly requirements?: RequirementFingerprints;
12
+ };
13
+ export type ProofImpactResult = {
14
+ readonly comparisonTarget: typeof COMMITTED_BASELINE_PATH;
15
+ readonly baselineVersion: string;
16
+ readonly currentRequirements: number;
17
+ readonly proofProven: number;
18
+ readonly currentUnproven: number;
19
+ readonly changes: ReturnType<typeof diffFingerprints>;
20
+ };
21
+ export type ReadCommittedFile = (workspaceRoot: string, relativePath: string) => string | Promise<string>;
22
+ export type ProofImpactExecuteOptions = {
23
+ readonly readCommittedFile?: ReadCommittedFile;
24
+ readonly loadCoverage?: (context: OperationContext) => Promise<{
25
+ structuredContent: unknown;
26
+ }>;
27
+ };
28
+ export declare function readCommittedHeadFile(workspaceRoot: string, relativePath: string): string;
29
+ export declare function loadCommittedBaseline(workspaceRoot: string, readCommittedFile?: ReadCommittedFile): Promise<ProofBaselineFile>;
30
+ /** Diagnostic only: successful evaluation always exits 0. Ratchet lives in check-proof-baseline.mjs. */
31
+ export declare function proofImpactExitCode(_result: ProofImpactResult): 0;
32
+ export declare function buildProofImpact(baseline: ProofBaselineFile, coverage: {
33
+ summary?: Record<string, unknown>;
34
+ rows?: unknown;
35
+ }): {
36
+ result: ProofImpactResult;
37
+ rows: CoverageRowLike[];
38
+ };
39
+ export declare function renderProofImpact(result: ProofImpactResult, rows: readonly CoverageRowLike[]): string;
40
+ export declare function executeProofImpact(context: OperationContext, options?: ProofImpactExecuteOptions): Promise<{
41
+ result: ProofImpactResult;
42
+ rows: CoverageRowLike[];
43
+ text: string;
44
+ }>;
45
+ //#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