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
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAqCA,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAoDD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA2F/B"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAmGA,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAoDD,wBAAsB,WAAW,CAC/B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAwI/B"}
@@ -15,17 +15,74 @@
15
15
  You should have received a copy of the GNU Affero General Public License
16
16
  along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
  */
18
- import { existsSync } from "node:fs";
18
+ import { existsSync, lstatSync, realpathSync } from "node:fs";
19
19
  import * as path from "node:path";
20
20
  import { fileURLToPath } from "node:url";
21
21
  import { classifyActivation } from "../operations/bootstrap/activation.js";
22
22
  import { nodeFilesystem } from "../public/operations/node-ports.js";
23
23
  import { resolveBranchAttachment } from "../utils/branch-resolver.js";
24
+ import { resolveGitRepository, } from "../utils/git-repository-context.js";
24
25
  import { scaffoldGitHubIntegration } from "./github-init.js";
25
26
  import { copySchemaFiles, createKbDirectoryStructure, createManifestFile, ensureSymbolsManifestFile, installGitHooks, updateGitIgnore, } from "./init-helpers.js";
26
27
  const __filename = fileURLToPath(import.meta.url);
27
28
  const __dirname = path.dirname(__filename);
28
- async function initNextAction() {
29
+ /**
30
+ * A hooks directory may be auto-managed only when Git resolves it inside this
31
+ * repository: under the common Git directory (the default hooks location) or
32
+ * under the current worktree root (repository-local relative core.hooksPath).
33
+ * Anything else — global configs, other repositories, external directories —
34
+ * must never receive auto-installed hooks.
35
+ * implements REQ-git-hook-effective-install
36
+ */
37
+ function isRepositoryManagedHooksDir(context) {
38
+ const realpathAllowMissingTail = (candidate) => {
39
+ let current = path.resolve(candidate);
40
+ const missingSegments = [];
41
+ while (true) {
42
+ try {
43
+ return path.resolve(realpathSync.native(current), ...missingSegments);
44
+ }
45
+ catch (error) {
46
+ const code = error.code;
47
+ if (code !== "ENOENT" && code !== "ENOTDIR")
48
+ return null;
49
+ // A dangling symlink cannot be canonicalized. Do not treat it as an
50
+ // ordinary missing suffix: mkdir could follow it into an external
51
+ // directory when Git's hooks path is created.
52
+ try {
53
+ if (lstatSync(current).isSymbolicLink())
54
+ return null;
55
+ }
56
+ catch (statError) {
57
+ const statCode = statError.code;
58
+ if (statCode !== "ENOENT" && statCode !== "ENOTDIR")
59
+ return null;
60
+ }
61
+ const parent = path.dirname(current);
62
+ if (parent === current)
63
+ return null;
64
+ missingSegments.unshift(path.basename(current));
65
+ current = parent;
66
+ }
67
+ }
68
+ };
69
+ const isWithin = (candidate, root) => {
70
+ const relative = path.relative(root, candidate);
71
+ return (relative === "" ||
72
+ (relative !== ".." &&
73
+ !relative.startsWith(`..${path.sep}`) &&
74
+ !path.isAbsolute(relative)));
75
+ };
76
+ const hooksDir = realpathAllowMissingTail(context.effectiveHooksDir);
77
+ const commonGitDir = realpathAllowMissingTail(context.commonGitDir);
78
+ const worktreeRoot = realpathAllowMissingTail(context.worktreeRoot);
79
+ if (!hooksDir || !commonGitDir || !worktreeRoot)
80
+ return false;
81
+ // The default hooks dir in a linked worktree is shared under the common Git
82
+ // directory, which can sit outside the current worktree root.
83
+ return isWithin(hooksDir, commonGitDir) || isWithin(hooksDir, worktreeRoot);
84
+ }
85
+ async function initNextAction(projectRoot) {
29
86
  const sourceFiles = await nodeFilesystem.glob([
30
87
  ".kb/requirements/**/*.md",
31
88
  ".kb/scenarios/**/*.md",
@@ -35,9 +92,9 @@ async function initNextAction() {
35
92
  ".kb/flags/**/*.md",
36
93
  ".kb/events/**/*.md",
37
94
  ".kb/facts/**/*.md",
38
- ], { cwd: process.cwd() });
95
+ ], { cwd: projectRoot });
39
96
  const activation = await classifyActivation({
40
- workspaceRoot: process.cwd(),
97
+ workspaceRoot: projectRoot,
41
98
  signal: new AbortController().signal,
42
99
  clock: () => new Date(),
43
100
  fs: nodeFilesystem,
@@ -67,12 +124,35 @@ export async function initCommand(options) {
67
124
  console.error("Error: --badge-only requires --github. The recommended integration is `kibi init --github` (badge + full report).");
68
125
  return { exitCode: 1 };
69
126
  }
70
- const kbDir = path.join(process.cwd(), ".kb");
127
+ // Resolve the repository once and derive every project path from Git's own
128
+ // answer, so init works from linked worktrees (.git is a file there) and
129
+ // from subdirectories (cwd has no .kb or .git at all). Bare repositories,
130
+ // unreadable contexts, and operational Git refusals are rejected before any
131
+ // workspace write — even when KIBI_BRANCH makes a standalone fallback
132
+ // available for genuinely non-repository directories.
133
+ // implements REQ-git-hook-effective-install
134
+ const resolution = resolveGitRepository(process.cwd());
135
+ if (resolution.status === "git-refused") {
136
+ console.error(`Error: ${resolution.reason}`);
137
+ console.error("Kibi cannot verify this directory's Git context; refusing to create workspace state.");
138
+ return { exitCode: 1 };
139
+ }
140
+ if (resolution.status === "unsupported") {
141
+ console.error(`Error: ${resolution.reason}`);
142
+ console.error("Kibi requires a working-tree checkout; refusing to create workspace state.");
143
+ return { exitCode: 1 };
144
+ }
145
+ const repoContext = resolution.status === "ok" ? resolution.context : null;
146
+ const projectRoot = repoContext?.worktreeRoot ?? process.cwd();
147
+ const kbDir = path.join(projectRoot, ".kb");
71
148
  const kbExists = existsSync(kbDir);
72
- // Resolve the exact active Git branch. Standalone use must be explicit via
73
- // KIBI_BRANCH; there is no implicit default branch.
149
+ // Resolve the exact active Git branch against the project root (not cwd):
150
+ // recovery journals, legacy stores, and identity manifests are read from
151
+ // the same .kb tree init is about to write.
152
+ // Standalone use must be explicit via KIBI_BRANCH; there is no implicit
153
+ // default branch.
74
154
  let currentBranch;
75
- const result = resolveBranchAttachment();
155
+ const result = resolveBranchAttachment(projectRoot);
76
156
  if ("error" in result) {
77
157
  const isNonGitError = result.code === "NOT_A_GIT_REPO" || result.code === "GIT_NOT_AVAILABLE";
78
158
  console.error("Error: Failed to resolve the active git branch.");
@@ -90,7 +170,7 @@ export async function initCommand(options) {
90
170
  if (!kbExists) {
91
171
  createKbDirectoryStructure(kbDir, currentBranch);
92
172
  createManifestFile(kbDir);
93
- updateGitIgnore(process.cwd());
173
+ updateGitIgnore(projectRoot);
94
174
  const schemaSourceDir = path.resolve(__dirname, "..", "..", "schema");
95
175
  await copySchemaFiles(kbDir, schemaSourceDir);
96
176
  }
@@ -104,14 +184,29 @@ export async function initCommand(options) {
104
184
  createManifestFile(kbDir);
105
185
  }
106
186
  }
107
- ensureSymbolsManifestFile(process.cwd());
187
+ ensureSymbolsManifestFile(projectRoot);
108
188
  if (options.hooks) {
109
- const gitDir = path.join(process.cwd(), ".git");
110
- if (!existsSync(gitDir)) {
189
+ if (!repoContext) {
111
190
  console.error("Warning: No git repository found, skipping hooks");
112
191
  }
192
+ else if (!isRepositoryManagedHooksDir(repoContext)) {
193
+ // core.hooksPath is only the culprit when it is configured; the
194
+ // default hooks directory can also escape the repository through a
195
+ // symlink, and blaming a setting the operator never made misleads.
196
+ const cause = repoContext.hooksPathConfig
197
+ ? "core.hooksPath points outside this repository"
198
+ : "The Git hooks directory resolves outside this repository (for example through a symlink)";
199
+ console.error(`Warning: ${cause} (${repoContext.effectiveHooksDir}); refusing to install hooks into unrelated directories. Kibi enforcement stays OFF for this repository until the hooks path is repository-managed.`);
200
+ }
113
201
  else {
114
- installGitHooks(gitDir);
202
+ installGitHooks(repoContext.effectiveHooksDir, {
203
+ hooksPathOrigin: repoContext.hooksPathOrigin,
204
+ });
205
+ if (repoContext.isLinkedWorktree && !repoContext.hooksPathConfig) {
206
+ // Only the default common hooks directory is shared by Git across
207
+ // worktrees; a configured hooksPath resolves per checkout.
208
+ console.log(`✓ Repository-common hooks directory shared with all worktrees (${repoContext.effectiveHooksDir})`);
209
+ }
115
210
  }
116
211
  }
117
212
  console.log("\n✓ Kibi initialized. Kibi infrastructure is ready for this repository.");
@@ -119,11 +214,11 @@ export async function initCommand(options) {
119
214
  if (kbExists) {
120
215
  console.log(" Existing Kibi source knowledge was preserved.");
121
216
  }
122
- console.log((await initNextAction()).message);
217
+ console.log((await initNextAction(projectRoot)).message);
123
218
  console.log(" Optional diagnostic: run 'kibi doctor' if setup appears degraded.");
124
219
  if (options.github === true) {
125
220
  scaffoldGitHubIntegration({
126
- cwd: process.cwd(),
221
+ cwd: projectRoot,
127
222
  badgeOnly: options.badgeOnly === true,
128
223
  });
129
224
  }
@@ -0,0 +1,10 @@
1
+ export type ProofExplainOptions = Readonly<{
2
+ id?: string;
3
+ requirement?: string;
4
+ symbol?: string;
5
+ json?: boolean;
6
+ }>;
7
+ export declare function proofExplainCommand(options: ProofExplainOptions): Promise<{
8
+ exitCode: number;
9
+ }>;
10
+ //# sourceMappingURL=proof-explain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof-explain.d.ts","sourceRoot":"","sources":["../../src/commands/proof-explain.ts"],"names":[],"mappings":"AAkBA,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC,CAAC;AAGH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAuC/B"}
@@ -0,0 +1,45 @@
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 { classifyExplainTarget, executeProofExplain, renderProofExplain, } from "../operations/proof/explain.js";
11
+ import { createCliRuntime } from "../runtime/cli-runtime.js";
12
+ // implements REQ-kibi-verification-evidence-contract
13
+ export async function proofExplainCommand(options) {
14
+ const target = classifyExplainTarget(options.id, {
15
+ ...(options.requirement === undefined
16
+ ? {}
17
+ : { requirement: options.requirement }),
18
+ ...(options.symbol === undefined ? {} : { symbol: options.symbol }),
19
+ });
20
+ const runtime = createCliRuntime();
21
+ const context = await runtime.open({
22
+ name: "kibi_proof_explain",
23
+ effects: [],
24
+ requiresProlog: true,
25
+ execute: async () => undefined,
26
+ }, {});
27
+ let completed = false;
28
+ try {
29
+ const { view } = await executeProofExplain(target, context);
30
+ if (options.json) {
31
+ process.stdout.write(`${JSON.stringify(view, null, 2)}\n`);
32
+ }
33
+ else {
34
+ process.stdout.write(renderProofExplain(view));
35
+ }
36
+ completed = true;
37
+ await runtime.afterSuccess({ name: "kibi_proof_explain" }, context);
38
+ return { exitCode: 0 };
39
+ }
40
+ finally {
41
+ await runtime.close(context, completed
42
+ ? { status: "success", result: 0 }
43
+ : { status: "error", error: 1 });
44
+ }
45
+ }
@@ -0,0 +1,7 @@
1
+ export type ProofImpactOptions = Readonly<{
2
+ json?: boolean;
3
+ }>;
4
+ export declare function proofImpactCommand(options: ProofImpactOptions): Promise<{
5
+ exitCode: number;
6
+ }>;
7
+ //# sourceMappingURL=proof-impact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"proof-impact.d.ts","sourceRoot":"","sources":["../../src/commands/proof-impact.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC,CAAC;AAGH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CA8B/B"}
@@ -0,0 +1,39 @@
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 { executeProofImpact, proofImpactExitCode, } from "../operations/proof/impact.js";
11
+ import { createCliRuntime } from "../runtime/cli-runtime.js";
12
+ // implements REQ-kibi-verification-evidence-contract
13
+ export async function proofImpactCommand(options) {
14
+ const runtime = createCliRuntime();
15
+ const context = await runtime.open({
16
+ name: "kibi_proof_impact",
17
+ effects: [],
18
+ requiresProlog: true,
19
+ execute: async () => undefined,
20
+ }, {});
21
+ let completed = false;
22
+ try {
23
+ const { result, text } = await executeProofImpact(context);
24
+ if (options.json) {
25
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
26
+ }
27
+ else {
28
+ process.stdout.write(text);
29
+ }
30
+ completed = true;
31
+ await runtime.afterSuccess({ name: "kibi_proof_impact" }, context);
32
+ return { exitCode: proofImpactExitCode(result) };
33
+ }
34
+ finally {
35
+ await runtime.close(context, completed
36
+ ? { status: "success", result: 0 }
37
+ : { status: "error", error: 1 });
38
+ }
39
+ }
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import { executeMigrateLegacyReceipts } from "../operations/proof/migrate-legacy-receipts.js";
19
19
  import { createCliRuntime } from "../runtime/cli-runtime.js";
20
- // implements REQ-kibi-proof-evidence-protocol
20
+ // implements REQ-kibi-verification-evidence-contract
21
21
  export async function proofMigrateLegacyCommand(options) {
22
22
  const runtime = createCliRuntime();
23
23
  const context = await runtime.open({
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import { executePruneReceipts } from "../operations/proof/prune-receipts.js";
19
19
  import { createCliRuntime } from "../runtime/cli-runtime.js";
20
- // implements REQ-kibi-proof-evidence-protocol
20
+ // implements REQ-kibi-verification-evidence-contract
21
21
  export async function proofPruneCommand(options) {
22
22
  const keepRaw = options.keep ?? "1";
23
23
  const keep = Number.parseInt(keepRaw, 10);
@@ -1 +1 @@
1
- {"version":3,"file":"prove.d.ts","sourceRoot":"","sources":["../../src/commands/prove.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAk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,CAUb;AAQD,wBAAgB,MAAM,CAAC,IAAI,EAAE,YAAY,GAAG,MAAM,CAEjD;AAkCD,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,gBAAgB,EAC7B,WAAW,EAAE,SAAS,MAAM,EAAE,EAC9B,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,UAAU,EAAE,MAAM,GACjB,MAAM,CAAC,UAAU,CAWnB;AAsKD,wBAAsB,YAAY,CAChC,OAAO,EAAE,mBAAmB,EAC5B,IAAI,GAAE,wBAA6B,GAClC,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgL/B"}
@@ -16,7 +16,7 @@ import { createCliRuntime } from "../runtime/cli-runtime.js";
16
16
  * Snapshot-relevant changes come first (receipt-only and ignored edits do
17
17
  * not affect the hash), and the list is capped to keep the error readable.
18
18
  */
19
- // implements REQ-kibi-proof-evidence-protocol
19
+ // implements REQ-kibi-verification-evidence-contract
20
20
  export function describeWorkspaceDrift(snapshot) {
21
21
  if (!snapshot.available)
22
22
  return " (workspace snapshot unavailable)";
@@ -40,7 +40,7 @@ export function describeWorkspaceDrift(snapshot) {
40
40
  * trimmed, non-empty ids. Empty selectors yield an empty set; blank items
41
41
  * fail fast instead of silently narrowing the selection.
42
42
  */
43
- // implements REQ-kibi-proof-evidence-protocol
43
+ // implements REQ-kibi-verification-evidence-contract
44
44
  export function parseIntegrationSelector(value, flagName) {
45
45
  if (value === undefined || value.trim() === "")
46
46
  return new Set();
@@ -84,7 +84,7 @@ async function runChild(commandArgv, cwd, env) {
84
84
  child.once("close", (code) => resolve(code ?? 1));
85
85
  });
86
86
  }
87
- // implements REQ-kibi-proof-evidence-protocol
87
+ // implements REQ-kibi-verification-evidence-contract
88
88
  export function commandEnvironment(integration, commandArgv, snapshot, workspaceRoot, testIds, outputPath) {
89
89
  return {
90
90
  ...process.env,
@@ -151,33 +151,25 @@ function markAggregateFailure(results) {
151
151
  return results.map((result) => ({ ...result, outcome: "failed" }));
152
152
  }
153
153
  async function selectTests(context, options) {
154
- // Paginated: loading every test entity with full props in one query can
155
- // exceed the Prolog output buffer once receipt histories grow.
156
- const loadAll = async () => {
157
- const pageSize = 25;
158
- const all = [];
159
- for (let offset = 0;; offset += pageSize) {
160
- const page = await loadEntities(context.prolog, {
161
- type: "test",
162
- limit: pageSize,
163
- offset,
164
- });
165
- all.push(...page);
166
- if (page.length < pageSize)
167
- return all;
168
- }
169
- };
154
+ // Contract plus bindings only. Receipt histories are loaded again at ingest
155
+ // and blow the Prolog output buffer when selected up front. JUnit and TAP
156
+ // conversion needs the bindings before that reload.
157
+ const loadAll = async () => loadEntities(context.prolog, {
158
+ type: "test",
159
+ projection: "proof_contract",
160
+ });
170
161
  let candidates = [];
171
162
  if (options.testId) {
172
163
  const found = await loadEntities(context.prolog, {
173
164
  id: options.testId,
174
165
  type: "test",
166
+ projection: "proof_contract",
175
167
  });
176
168
  candidates = found.map(withId);
177
169
  }
178
170
  else if (options.requirement) {
179
171
  const requirementId = options.requirement;
180
- const scenarioResult = await context.prolog?.query(`findall([S,T], (kb_relationship(specified_by, '${requirementId}', S), (kb_relationship(verified_by, S, T) ; kb_relationship(validates, T, S)), kb_entity(T, test, _)), Rows)`);
172
+ const scenarioResult = await context.prolog?.query(`findall([S,T], (kb_relationship(specified_by, '${requirementId}', S), (kb_relationship(verified_by, S, T) ; kb_relationship(validates, T, S))), Rows)`);
181
173
  const rowsRaw = scenarioResult?.success
182
174
  ? scenarioResult.bindings.Rows
183
175
  : undefined;
@@ -189,7 +181,7 @@ async function selectTests(context, options) {
189
181
  ids.add(test.trim());
190
182
  }
191
183
  }
192
- const directResult = await context.prolog?.query(`findall(T, (kb_relationship(validates, T, '${requirementId}'), kb_entity(T, test, _)), Rows)`);
184
+ const directResult = await context.prolog?.query(`findall(T, kb_relationship(validates, T, '${requirementId}'), Rows)`);
193
185
  const directRaw = directResult?.success
194
186
  ? directResult.bindings.Rows
195
187
  : undefined;
@@ -240,7 +232,7 @@ function summarize(result) {
240
232
  parts.push(`unchanged ${result.unchanged}`);
241
233
  return parts.join(", ");
242
234
  }
243
- // implements REQ-kibi-proof-evidence-protocol
235
+ // implements REQ-kibi-verification-evidence-contract
244
236
  export async function proveCommand(options, deps = {}) {
245
237
  const workspaceRoot = options.workspaceRoot ?? process.cwd();
246
238
  const ingestProof = deps.ingestProof ?? executeIngestProof;
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/commands/report.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,KAAK,cAAc,GAAG,QAAQ,CAAC;IAC7B,YAAY,EAAE,kBAAkB,CAAC;IACjC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,YAAY,CAAC,EAAE,CACb,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,cAAc,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,CAAC,C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AAsB,aAAa,CACjC,OAAO,EAAE,aAAa,EACtB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAyEjB"}
@@ -7,7 +7,6 @@ import { coverageSpec } from "../public/operations/specs/reporting.js";
7
7
  import { KIBI_BRAND, renderKibiBadge } from "../report/brand.js";
8
8
  import { renderHtmlReport, } from "../report/html-report.js";
9
9
  import { resolveReportRepository, } from "../report/repository.js";
10
- import { createCliRuntime } from "../runtime/cli-runtime.js";
11
10
  import { listGitRemotes } from "./github-init.js";
12
11
  function gitCommitSha(cwd) {
13
12
  try {
@@ -79,6 +78,9 @@ async function executeCoverageInContext(context, tags, limit) {
79
78
  };
80
79
  }
81
80
  async function loadCoverage(tags, limit) {
81
+ // Lazy-load the CLI runtime so coverage suites that inject loadCoverage do
82
+ // not pull the engine/plugin graph into every reportCommand import.
83
+ const { createCliRuntime } = await import("../runtime/cli-runtime.js");
82
84
  const runtime = createCliRuntime();
83
85
  const runtimeSpec = coverageSpec;
84
86
  const context = await runtime.open(runtimeSpec);
@@ -118,8 +120,21 @@ export async function openReport(filePath) {
118
120
  detached: true,
119
121
  stdio: "ignore",
120
122
  });
121
- child.once("error", reject);
123
+ const timer = setTimeout(() => {
124
+ try {
125
+ child.unref();
126
+ }
127
+ catch {
128
+ // Best-effort unref if the child never spawned.
129
+ }
130
+ reject(new Error(`Timed out opening report via ${command}`));
131
+ }, 5_000);
132
+ child.once("error", (error) => {
133
+ clearTimeout(timer);
134
+ reject(error);
135
+ });
122
136
  child.once("spawn", () => {
137
+ clearTimeout(timer);
123
138
  child.unref();
124
139
  resolve();
125
140
  });
@@ -21,6 +21,8 @@ export type SyncCache = {
21
21
  seenAt: Record<string, string>;
22
22
  semanticHashes: Record<string, string>;
23
23
  semanticContracts: Record<string, boolean>;
24
+ /** Compiler contract that produced the cached compilation; see below. */
25
+ compilerFingerprint?: string;
24
26
  };
25
27
  /**
26
28
  * v2: cache identities are workspace-root relative instead of process-cwd
@@ -30,6 +32,20 @@ export type SyncCache = {
30
32
  */
31
33
  export declare const SYNC_CACHE_VERSION = 2;
32
34
  export declare const SYNC_CACHE_TTL_MS: number;
35
+ /**
36
+ * Identity of the entity property contract this CLI compiles against. Sync
37
+ * skips unchanged sources by content hash, so a store compiled by a CLI with a
38
+ * different contract (an older build that drops properties it does not know)
39
+ * would otherwise keep that lossy compilation forever. A cache stamped with a
40
+ * different fingerprint is discarded, which re-imports every source once.
41
+ */
42
+ export declare const SYNC_COMPILER_FINGERPRINT: string;
43
+ /**
44
+ * Stale reason for a branch store whose last compilation used a different
45
+ * compiler contract than the running CLI. Status reports it so a lossy store is
46
+ * visible before the next sync repairs it.
47
+ */
48
+ export declare function compilerFingerprintReason(storePath: string, deps?: Partial<SyncCacheDeps>): Record<string, unknown> | null;
33
49
  export declare function toCacheKey(workspaceRoot: string, filePath: string): string;
34
50
  export declare function hashFile(workspaceRoot: string, filePath: string, deps?: Partial<SyncCacheDeps>): string;
35
51
  /** Deterministically hash a JSON-compatible compiler payload. */
@@ -41,7 +57,10 @@ export declare function hashNormalized(value: unknown): string;
41
57
  * source hash even though the authored YAML bytes stay identical.
42
58
  */
43
59
  export declare function hashManifestWithCoordinates(workspaceRoot: string, manifestPath: string, coordinatesPath: string | null, deps?: Partial<SyncCacheDeps>): string;
44
- export declare function readSyncCache(cachePath: string, deps?: Partial<SyncCacheDeps>): SyncCache;
60
+ export declare function readSyncCache(cachePath: string, deps?: Partial<SyncCacheDeps>, options?: {
61
+ /** Discard a cache produced under a different compiler contract. */
62
+ readonly compilerFingerprint?: string;
63
+ }): SyncCache;
45
64
  export declare function writeSyncCache(cachePath: string, cache: SyncCache, deps?: Partial<SyncCacheDeps>): void;
46
65
  export declare function copySyncCache(livePath: string, stagingPath: string, deps?: Partial<SyncCacheDeps>): void;
47
66
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/cache.ts"],"names":[],"mappings":"AAkBA,OAAO,EA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,KAAK,EAAE,OAAO,GAAG,MAAM,CAerD;AAED;;;;;GAKG;AAEH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,eAAe,EAAE,MAAM,GAAG,IAAI,EAC9B,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC5B,MAAM,CA4FR;AAED,wBAAgB,aAAa,CAE3B,SAAS,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,EAC7B,OAAO,GAAE;IACP,oEAAoE;IACpE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAClC,GACL,SAAS,CA8DX;AAED,wBAAgB,cAAc,CAE5B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,SAAS,EAChB,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC5B,IAAI,CAaN;AAED,wBAAgB,aAAa,CAE3B,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAC5B,IAAI,CASN"}
@@ -19,6 +19,9 @@ import { createHash } from "node:crypto";
19
19
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
20
20
  import * as path from "node:path";
21
21
  import { load as parseYAML } from "js-yaml";
22
+ import entitySchema from "../../schemas/entity.schema.json" with {
23
+ type: "json"
24
+ };
22
25
  function resolveDeps(overrides) {
23
26
  return {
24
27
  createHash,
@@ -37,6 +40,47 @@ function resolveDeps(overrides) {
37
40
  */
38
41
  export const SYNC_CACHE_VERSION = 2;
39
42
  export const SYNC_CACHE_TTL_MS = 30 * 24 * 60 * 60 * 1000;
43
+ /**
44
+ * Identity of the entity property contract this CLI compiles against. Sync
45
+ * skips unchanged sources by content hash, so a store compiled by a CLI with a
46
+ * different contract (an older build that drops properties it does not know)
47
+ * would otherwise keep that lossy compilation forever. A cache stamped with a
48
+ * different fingerprint is discarded, which re-imports every source once.
49
+ */
50
+ // implements REQ-cli-canonical-runtime
51
+ export const SYNC_COMPILER_FINGERPRINT = createHash("sha256")
52
+ .update(JSON.stringify(entitySchema))
53
+ .digest("hex");
54
+ /**
55
+ * Stale reason for a branch store whose last compilation used a different
56
+ * compiler contract than the running CLI. Status reports it so a lossy store is
57
+ * visible before the next sync repairs it.
58
+ */
59
+ // implements REQ-cli-canonical-runtime
60
+ export function compilerFingerprintReason(storePath, deps) {
61
+ const resolved = resolveDeps(deps);
62
+ const cachePath = path.join(storePath, "sync-cache.json");
63
+ if (!resolved.existsSync(cachePath))
64
+ return null;
65
+ let recorded;
66
+ try {
67
+ recorded = JSON.parse(resolved.readFileSync(cachePath, "utf8")).compilerFingerprint;
68
+ }
69
+ catch {
70
+ return null;
71
+ }
72
+ if (recorded === SYNC_COMPILER_FINGERPRINT)
73
+ return null;
74
+ return {
75
+ code: "compiler_changed",
76
+ path: cachePath,
77
+ entityIds: [],
78
+ detail: typeof recorded === "string"
79
+ ? "The branch KB was compiled by a Kibi CLI with a different entity property contract, so unchanged sources may lack properties this CLI keeps. The next kibi sync re-imports every source."
80
+ : "The branch KB was compiled by a Kibi CLI that did not record its entity property contract, so unchanged sources may lack properties this CLI keeps. The next kibi sync re-imports every source.",
81
+ remediation: { command_argv: ["kibi", "sync"], applyRequired: false },
82
+ };
83
+ }
40
84
  export function toCacheKey(workspaceRoot, filePath) {
41
85
  const root = path.resolve(workspaceRoot);
42
86
  const target = path.isAbsolute(filePath)
@@ -165,7 +209,7 @@ export function hashManifestWithCoordinates(workspaceRoot, manifestPath, coordin
165
209
  }
166
210
  export function readSyncCache(
167
211
  // implements REQ-003
168
- cachePath, deps) {
212
+ cachePath, deps, options = {}) {
169
213
  const resolved = resolveDeps(deps);
170
214
  if (!resolved.existsSync(cachePath)) {
171
215
  return {
@@ -178,7 +222,9 @@ cachePath, deps) {
178
222
  }
179
223
  try {
180
224
  const parsed = JSON.parse(resolved.readFileSync(cachePath, "utf8"));
181
- if (parsed.version !== SYNC_CACHE_VERSION) {
225
+ if (parsed.version !== SYNC_CACHE_VERSION ||
226
+ (options.compilerFingerprint !== undefined &&
227
+ parsed.compilerFingerprint !== options.compilerFingerprint)) {
182
228
  return {
183
229
  version: SYNC_CACHE_VERSION,
184
230
  hashes: {},
@@ -206,6 +252,9 @@ cachePath, deps) {
206
252
  if (parsed.shardRelationships !== undefined) {
207
253
  cache.shardRelationships = parsed.shardRelationships;
208
254
  }
255
+ if (parsed.compilerFingerprint !== undefined) {
256
+ cache.compilerFingerprint = parsed.compilerFingerprint;
257
+ }
209
258
  return cache;
210
259
  }
211
260
  catch {
@@ -1 +1 @@
1
- {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/discovery.ts"],"names":[],"mappings":"AAkCA,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,+EAA+E;IAC/E,6BAA6B,CAAC,EAAE,OAAO,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAyFH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOlD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAShE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAUxD;AAED,wBAAgB,mCAAmC,CACjD,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,SAAS,4BAA4B,EAAE,GAChD,IAAI,CA6CN;AAsBD,wBAAgB,qBAAqB,CACnC,OAAO,EAA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X,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC;IACT,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,4BAA4B,EAAE,4BAA4B,EAAE,CAAC;CAC9D,CAAC,CA+FD"}
@@ -67,7 +67,7 @@ function pendingSourcePaths(cwd, recoverMissing) {
67
67
  });
68
68
  continue;
69
69
  }
70
- throw new Error(`Pending source is missing: ${relative}`);
70
+ throw new Error(`Pending source is missing: ${relative}. If the file was deleted on purpose, run 'kibi branch recover --apply' to rebuild the branch KB from the sources that remain.`);
71
71
  }
72
72
  const actual = createHash("sha256")
73
73
  .update(readFileSync(absolute))
@@ -31,6 +31,7 @@ export { COARSE_GRANULARITY_REASONS };
31
31
  export declare function isCoarseGranularityAnchor(entry: ManifestSymbolEntry): boolean;
32
32
  export declare function refreshManifestCoordinates(manifestPath: string, workspaceRoot: string, deps?: Partial<ManifestDeps> & {
33
33
  refreshSymbolCoordinates?: boolean;
34
+ quiet?: boolean;
34
35
  }): Promise<void>;
35
36
  export declare function hasAllGeneratedCoordinates(entry: ManifestSymbolEntry): boolean;
36
37
  export declare function isEligibleForCoordinateRefresh(sourceFile: string | undefined, workspaceRoot: string, deps?: Partial<ManifestDeps>): boolean;