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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kibi-cli",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "description": "Kibi CLI for knowledge base management",
6
6
  "engines": {
@@ -10,14 +10,7 @@
10
10
  "bin": {
11
11
  "kibi": "bin/kibi"
12
12
  },
13
- "files": [
14
- "dist",
15
- "bin",
16
- "schema",
17
- "src/schemas",
18
- "src/public",
19
- "templates"
20
- ],
13
+ "files": ["dist", "bin", "schema", "src/schemas", "src/public", "templates"],
21
14
  "scripts": {
22
15
  "build": "tsc -p tsconfig.json && rm -rf dist/public/skills && mkdir -p dist/public/skills dist/report && cp -r src/public/skills/. dist/public/skills/ && cp src/report/html-report.css dist/report/html-report.css && node ../../scripts/generate-entity-schema.mjs --check",
23
16
  "test": "node ../../scripts/run-owned-engine-tests.mjs -- bun test --timeout 15000 .",
@@ -55,6 +48,10 @@
55
48
  "types": "./dist/runtime/cli-runtime.d.ts",
56
49
  "default": "./dist/runtime/cli-runtime.js"
57
50
  },
51
+ "./plugins": {
52
+ "types": "./dist/plugins/index.d.ts",
53
+ "default": "./dist/plugins/index.js"
54
+ },
58
55
  "./operations/node-ports": {
59
56
  "types": "./dist/public/operations/node-ports.d.ts",
60
57
  "default": "./dist/public/operations/node-ports.js"
@@ -216,6 +213,10 @@
216
213
  "types": "./dist/public/ignore-policy.d.ts",
217
214
  "import": "./dist/public/ignore-policy.js",
218
215
  "default": "./dist/public/ignore-policy.js"
216
+ },
217
+ "./env-bootstrap": {
218
+ "types": "./dist/env/bootstrap.d.ts",
219
+ "default": "./dist/env/bootstrap.js"
219
220
  }
220
221
  },
221
222
  "types": "./dist/cli.d.ts",
@@ -226,15 +227,17 @@
226
227
  "fast-glob": "^3.2.12",
227
228
  "gray-matter": "^4.0.3",
228
229
  "js-yaml": "^4.1.0",
229
- "kibi-core": "^0.12.0",
230
+ "kibi-core": "^0.14.0",
231
+ "kibi-plugin-builtin": "^0.3.0",
232
+ "kibi-plugin-sdk": "^0.3.0",
230
233
  "saxes": "^6.0.0",
231
- "ts-morph": "^23.0.0",
232
234
  "ignore": "^5.3.0",
233
235
  "yaml": "^2.9.0"
234
236
  },
235
237
  "devDependencies": {
236
238
  "@types/node": "latest",
237
239
  "semver": "^7.7.4",
240
+ "ts-morph": "^23.0.0",
238
241
  "typescript": "^5.7.0"
239
242
  },
240
243
  "license": "AGPL-3.0-or-later",
@@ -3,6 +3,7 @@
3
3
  :- module(kibi_entities, [entity_type/1, entity_property/3, required_property/2, optional_property/2]).
4
4
 
5
5
  % Entity types
6
+ % implements REQ-004
6
7
  entity_type(req).
7
8
  entity_type(scenario).
8
9
  entity_type(test).
@@ -20,7 +21,6 @@ entity_property(_, status, atom).
20
21
  entity_property(_, created_at, datetime).
21
22
  entity_property(_, updated_at, datetime).
22
23
  entity_property(_, source, uri).
23
- entity_property(_, sourceFile, uri).
24
24
 
25
25
  % Optional properties
26
26
  entity_property(_, tags, list).
@@ -29,6 +29,16 @@ entity_property(_, priority, atom).
29
29
  entity_property(_, severity, atom).
30
30
  entity_property(_, links, list).
31
31
  entity_property(_, text_ref, uri).
32
+ entity_property(_, sourceFile, uri).
33
+ entity_property(req, semantic_text, string).
34
+ entity_property(req, logic_claims, list).
35
+ entity_property(req, semantic_clauses, list).
36
+ entity_property(req, semantic_inventory_version, string).
37
+ entity_property(req, semantic_source_field, string).
38
+ entity_property(req, semantic_source_hash, string).
39
+ entity_property(req, semantic_inventory, list_or_json).
40
+ entity_property(req, proof_exempt, boolean).
41
+ entity_property(req, proof_exempt_reason, string).
32
42
 
33
43
  % Typed fact fields - only valid for fact entities
34
44
  entity_property(fact, fact_kind, atom).
@@ -47,10 +57,45 @@ entity_property(fact, closed_world, boolean).
47
57
  entity_property(fact, valid_from, datetime).
48
58
  entity_property(fact, valid_to, datetime).
49
59
  entity_property(fact, canonical_key, string).
60
+ entity_property(fact, claim_key, string).
61
+ entity_property(fact, claim_text, string).
62
+ entity_property(fact, predicate_name, string).
63
+ entity_property(fact, predicate_namespace, string).
64
+ entity_property(fact, predicate_arity, integer).
65
+ entity_property(fact, argument_names, list).
66
+ entity_property(fact, argument_types, list).
67
+ entity_property(fact, argument_descriptions, list).
68
+ % Predicate-schema vocabularies are JSON objects serialized as strings.
69
+ entity_property(fact, argument_constants, string).
70
+ entity_property(fact, argument_aliases, string).
71
+ entity_property(fact, aliases, list).
72
+ entity_property(fact, examples, list).
73
+ entity_property(fact, predicate_args, list).
74
+ entity_property(fact, rule_ir, string).
75
+ entity_property(fact, rule_hash, string).
76
+ % Rule schema references are JSON strings at the public boundary, but the
77
+ % Prolog peer represents entity identifiers as atoms. Accept both forms so
78
+ % decoded rule facts validate without losing the typed reference.
79
+ entity_property(fact, rule_schema_id, atom_or_string).
80
+ entity_property(fact, rule_name, string).
81
+ entity_property(fact, semantic_key, string).
82
+ entity_property(fact, claim_span_start, integer).
83
+ entity_property(fact, claim_span_end, integer).
50
84
 
51
85
  % Typed symbol metadata fields - only valid for symbol entities
52
86
  entity_property(symbol, symbol_role, atom).
53
87
  entity_property(symbol, granularity_reason, atom).
88
+ entity_property(symbol, sourceLine, integer).
89
+ entity_property(symbol, sourceColumn, integer).
90
+ entity_property(symbol, sourceEndLine, integer).
91
+ entity_property(symbol, sourceEndColumn, integer).
92
+
93
+ % Typed test verification fields - only valid for test entities
94
+ entity_property(test, verification_scope, atom).
95
+ entity_property(test, verification_perspective, atom).
96
+ entity_property(test, proof_contract, list_or_json).
97
+ entity_property(test, proof_bindings, string).
98
+ entity_property(test, proof_receipts, string).
54
99
 
55
100
  % Required properties for all entity types
56
101
  required_property(Type, id) :- entity_type(Type).
@@ -67,6 +112,20 @@ optional_property(Type, priority) :- entity_type(Type).
67
112
  optional_property(Type, severity) :- entity_type(Type).
68
113
  optional_property(Type, links) :- entity_type(Type).
69
114
  optional_property(Type, text_ref) :- entity_type(Type).
115
+ optional_property(req, semantic_text).
116
+ optional_property(req, logic_claims).
117
+ optional_property(req, semantic_clauses).
118
+ optional_property(req, semantic_inventory_version).
119
+ optional_property(req, semantic_source_field).
120
+ optional_property(req, semantic_source_hash).
121
+ optional_property(req, semantic_inventory).
122
+ optional_property(req, proof_exempt).
123
+ optional_property(req, proof_exempt_reason).
124
+ optional_property(test, verification_scope).
125
+ optional_property(test, verification_perspective).
126
+ optional_property(test, proof_contract).
127
+ optional_property(test, proof_bindings).
128
+ optional_property(test, proof_receipts).
70
129
 
71
130
  % Documentation helpers
72
131
  % list all entity types
@@ -3,32 +3,36 @@
3
3
  :- module(kibi_relationships, [relationship_type/1, valid_relationship/3, relationship_metadata/1]).
4
4
 
5
5
  % Relationship types
6
+ % implements REQ-005
6
7
  relationship_type(depends_on).
8
+ relationship_type(executable_for).
7
9
  relationship_type(specified_by).
8
10
  relationship_type(verified_by).
9
11
  relationship_type(validates).
10
12
  relationship_type(implements).
11
13
  relationship_type(covered_by).
12
- relationship_type(executable_for).
13
14
  relationship_type(constrained_by).
14
15
  relationship_type(guards).
15
16
  relationship_type(publishes).
16
17
  relationship_type(consumes).
17
18
  relationship_type(relates_to).
18
19
  relationship_type(supersedes).
20
+ relationship_type(restates).
19
21
  relationship_type(constrains).
20
22
  relationship_type(requires_property).
23
+ relationship_type(requires_predicate).
24
+ relationship_type(requires_rule).
21
25
 
22
26
  % valid_relationship(RelType, FromType, ToType).
23
27
  valid_relationship(depends_on, req, req).
28
+ valid_relationship(executable_for, symbol, test).
24
29
  valid_relationship(specified_by, req, scenario).
25
30
  valid_relationship(verified_by, req, test).
31
+ valid_relationship(verified_by, scenario, test).
26
32
  valid_relationship(validates, test, req).
33
+ valid_relationship(validates, test, scenario).
27
34
  valid_relationship(implements, symbol, req).
28
35
  valid_relationship(covered_by, symbol, test).
29
- valid_relationship(executable_for, symbol, test).
30
- valid_relationship(verified_by, scenario, test).
31
- valid_relationship(validates, test, scenario).
32
36
  valid_relationship(constrained_by, symbol, adr).
33
37
  % guards can target symbol, event, or req
34
38
  valid_relationship(guards, flag, symbol).
@@ -38,12 +42,21 @@ valid_relationship(publishes, symbol, event).
38
42
  valid_relationship(consumes, symbol, event).
39
43
  valid_relationship(constrains, req, fact).
40
44
  valid_relationship(requires_property, req, fact).
45
+ valid_relationship(requires_predicate, req, fact).
46
+ valid_relationship(requires_rule, req, fact).
41
47
 
42
48
  %% supersedes(+NewAdrId, +OldAdrId)
43
49
  %% NewAdrId is the decision that replaces OldAdrId.
44
50
  %% OldAdrId's status should be archived or deprecated as a consequence.
45
51
  valid_relationship(supersedes, adr, adr).
46
52
  valid_relationship(supersedes, req, req).
53
+
54
+ %% restates(+ReqId, +OtherReqId)
55
+ %% ReqId intentionally restates OtherReqId (for example a product requirement
56
+ %% echoed in a platform requirement). Both stay current; the pair is exempt
57
+ %% from domain-redundancy. Use supersedes when one replaces the other.
58
+ % implements REQ-kibi-restates-relationship
59
+ valid_relationship(restates, req, req).
47
60
  % escape hatch - allow any to any
48
61
  valid_relationship(relates_to, _, _).
49
62
 
@@ -42,8 +42,10 @@ validate_property_type(Type, Prop, Value) :-
42
42
  % check_kind(Kind, Value) succeeds if Value matches Kind
43
43
  check_kind(atom, V) :- atom(V).
44
44
  check_kind(string, V) :- string(V).
45
+ check_kind(atom_or_string, V) :- atom(V) ; string(V).
45
46
  check_kind(datetime, V) :- string(V). % accept ISO strings for now
46
47
  check_kind(list, V) :- is_list(V).
48
+ check_kind(list_or_json, V) :- is_list(V) ; string(V) ; atom(V).
47
49
  check_kind(uri, V) :- string(V).
48
50
  check_kind(integer, V) :- integer(V).
49
51
  check_kind(number, V) :- number(V).
@@ -59,11 +61,24 @@ validate_entity_shape(fact, Props) :-
59
61
  !,
60
62
  valid_optional_fact_enums(Props),
61
63
  valid_polarity_in_props(Props),
64
+ valid_claim_provenance(Props),
62
65
  ( memberchk(fact_kind=RawKind, Props) -> validate_fact_shape(RawKind, Props) ; true ).
66
+ validate_entity_shape(test, Props) :-
67
+ !,
68
+ valid_optional_test_enums(Props),
69
+ forall(member(Key=_, Props), \+ is_fact_only_field(Key)).
70
+ validate_entity_shape(req, Props) :-
71
+ !,
72
+ forall(member(Key=_, Props), \+ is_fact_only_field(Key)),
73
+ forall(member(Key=_, Props), \+ is_test_only_field(Key)).
63
74
  validate_entity_shape(Type, Props) :-
64
75
  Type \= fact,
65
- % Non-fact entities cannot have fact-only fields
66
- forall(member(Key=_Val, Props), \+ is_fact_only_field(Key)).
76
+ Type \= test,
77
+ Type \= req,
78
+ % Non-fact/non-test entities cannot have type-specific fields
79
+ forall(member(Key=_, Props), \+ is_fact_only_field(Key)),
80
+ forall(member(Key=_, Props), \+ is_test_only_field(Key)),
81
+ forall(member(Key=_, Props), Key \= logic_claims).
67
82
 
68
83
  % is_fact_only_field(+Key) - true if Key is a fact-specific field
69
84
  is_fact_only_field(fact_kind).
@@ -82,12 +97,39 @@ is_fact_only_field(closed_world).
82
97
  is_fact_only_field(valid_from).
83
98
  is_fact_only_field(valid_to).
84
99
  is_fact_only_field(canonical_key).
100
+ is_fact_only_field(claim_key).
101
+ is_fact_only_field(claim_text).
102
+ is_fact_only_field(predicate_name).
103
+ is_fact_only_field(predicate_namespace).
104
+ is_fact_only_field(predicate_arity).
105
+ is_fact_only_field(argument_names).
106
+ is_fact_only_field(argument_types).
107
+ is_fact_only_field(argument_descriptions).
108
+ is_fact_only_field(argument_constants).
109
+ is_fact_only_field(argument_aliases).
110
+ is_fact_only_field(aliases).
111
+ is_fact_only_field(examples).
112
+ is_fact_only_field(predicate_args).
113
+ is_fact_only_field(rule_ir).
114
+ is_fact_only_field(rule_hash).
115
+ is_fact_only_field(rule_schema_id).
116
+ is_fact_only_field(rule_name).
117
+ is_fact_only_field(semantic_key).
118
+ is_fact_only_field(claim_span_start).
119
+ is_fact_only_field(claim_span_end).
120
+
121
+ % is_test_only_field(+Key) - true if Key is a test-specific field
122
+ is_test_only_field(verification_scope).
123
+ is_test_only_field(verification_perspective).
124
+ is_test_only_field(proof_contract).
125
+ is_test_only_field(proof_bindings).
126
+ is_test_only_field(proof_receipts).
85
127
 
86
128
  % validate_fact_shape(+Kind, +Props)
87
129
  validate_fact_shape(subject, Props) :-
88
130
  memberchk(subject_key=_Val, Props),
89
131
  valid_optional_fact_enums(Props),
90
- valid_polarity_in_props(Props).
132
+ valid_strict_polarity_in_props(Props), !.
91
133
  validate_fact_shape(property_value, Props) :-
92
134
  memberchk(subject_key=_Subject, Props),
93
135
  memberchk(property_key=_Property, Props),
@@ -98,48 +140,104 @@ validate_fact_shape(property_value, Props) :-
98
140
  exactly_one_value_field(Props),
99
141
  value_type_matches_field(VT, Props),
100
142
  valid_optional_fact_enums(Props),
101
- valid_polarity_in_props(Props).
143
+ valid_strict_polarity_in_props(Props), !.
102
144
  validate_fact_shape(observation, Props) :-
103
- % Observation facts are allowed but don't require full strict property tuple yet
104
145
  valid_optional_fact_enums(Props),
105
- valid_polarity_in_props(Props).
146
+ valid_polarity_in_props(Props), !.
106
147
  validate_fact_shape(meta, Props) :-
107
148
  % Meta facts are allowed but don't require full strict property tuple yet
108
149
  valid_optional_fact_enums(Props),
109
- valid_polarity_in_props(Props).
150
+ valid_polarity_in_props(Props), !.
151
+ validate_fact_shape(predicate_schema, Props) :-
152
+ memberchk(predicate_name=_Name, Props),
153
+ memberchk(predicate_arity=Arity, Props),
154
+ Arity >= 1,
155
+ memberchk(argument_names=ArgumentNames, Props),
156
+ memberchk(argument_types=ArgumentTypes, Props),
157
+ same_length(ArgumentNames, ArgumentTypes),
158
+ length(ArgumentNames, Arity),
159
+ valid_optional_fact_enums(Props),
160
+ valid_polarity_in_props(Props), !.
161
+ validate_fact_shape(predicate, Props) :-
162
+ memberchk(predicate_name=_Name, Props),
163
+ memberchk(predicate_args=Args, Props),
164
+ Args \= [],
165
+ memberchk(canonical_key=_CanonicalKey, Props),
166
+ valid_optional_fact_enums(Props),
167
+ valid_predicate_polarity_in_props(Props), !.
168
+ validate_fact_shape(rule_schema, Props) :-
169
+ memberchk(rule_name=_Name, Props),
170
+ memberchk(argument_names=ArgumentNames, Props),
171
+ memberchk(argument_types=ArgumentTypes, Props),
172
+ same_length(ArgumentNames, ArgumentTypes),
173
+ valid_optional_fact_enums(Props),
174
+ valid_polarity_in_props(Props), !.
175
+ validate_fact_shape(rule, Props) :-
176
+ memberchk(rule_ir=RuleIr, Props),
177
+ nonempty_claim_value(RuleIr),
178
+ memberchk(rule_hash=_Hash, Props),
179
+ memberchk(rule_schema_id=_SchemaId, Props),
180
+ memberchk(semantic_key=_SemanticKey, Props),
181
+ valid_optional_fact_enums(Props),
182
+ valid_polarity_in_props(Props), !.
110
183
  validate_fact_shape(Kind, _Props) :-
111
184
  % Unknown fact_kind values fail validation
112
- \+ memberchk(Kind, [subject, property_value, observation, meta]),
185
+ \+ memberchk(Kind, [subject, property_value, observation, meta, predicate_schema, predicate, rule_schema, rule]),
113
186
  fail.
114
187
 
115
188
  % valid_operator(+Op)
116
- valid_operator(eq).
117
- valid_operator(neq).
118
- valid_operator(lt).
119
- valid_operator(lte).
120
- valid_operator(gt).
121
- valid_operator(gte).
189
+ valid_operator(Op) :- memberchk(Op, [eq, neq, lt, lte, gt, gte]), !.
122
190
 
123
191
  % valid_value_type(+VT)
124
- valid_value_type(string).
125
- valid_value_type(int).
126
- valid_value_type(number).
127
- valid_value_type(bool).
192
+ valid_value_type(ValueType) :- memberchk(ValueType, [string, int, number, bool]), !.
128
193
 
129
194
  % valid_polarity_in_props(+Props)
130
195
  % Validates polarity if present; succeeds if no polarity in props
131
196
  valid_polarity_in_props(Props) :-
132
197
  ( memberchk(polarity=P, Props) -> valid_polarity(P) ; true ).
133
198
 
199
+ valid_strict_polarity_in_props(Props) :-
200
+ ( memberchk(polarity=P, Props) -> valid_strict_polarity(P) ; true ).
201
+
202
+ valid_predicate_polarity_in_props(Props) :-
203
+ ( memberchk(polarity=P, Props) -> valid_predicate_polarity(P) ; true ).
204
+
205
+ % claim_key and claim_text form one auditable provenance pair.
206
+ valid_claim_provenance(Props) :-
207
+ ( memberchk(claim_key=Key, Props)
208
+ -> memberchk(claim_text=Text, Props),
209
+ nonempty_claim_value(Key),
210
+ nonempty_claim_value(Text)
211
+ ; \+ memberchk(claim_text=_, Props)
212
+ ).
213
+
214
+ nonempty_claim_value(Value) :- string(Value), Value \= "", !.
215
+ nonempty_claim_value(Value) :- atom(Value), Value \= '', !.
216
+
134
217
  % valid_optional_fact_enums(+Props)
135
218
  % Validates enum-typed fact fields whenever they are present
136
219
  valid_optional_fact_enums(Props) :-
137
220
  ( memberchk(operator=Op, Props) -> valid_operator(Op) ; true ),
138
221
  ( memberchk(value_type=VT, Props) -> valid_value_type(VT) ; true ).
139
222
 
223
+ % valid_optional_test_enums(+Props)
224
+ % Validates enum-typed test fields whenever they are present
225
+ valid_optional_test_enums(Props) :-
226
+ ( memberchk(verification_scope=Scope, Props) -> valid_verification_scope(Scope) ; true ),
227
+ ( memberchk(verification_perspective=Perspective, Props) -> valid_verification_perspective(Perspective) ; true ).
228
+
140
229
  % valid_polarity(+P)
141
- valid_polarity(require).
142
- valid_polarity(forbid).
230
+ valid_polarity(Polarity) :- memberchk(Polarity, [require, forbid, assert, deny]), !.
231
+
232
+ valid_strict_polarity(Polarity) :- memberchk(Polarity, [require, forbid]), !.
233
+
234
+ valid_predicate_polarity(Polarity) :- memberchk(Polarity, [assert, deny]), !.
235
+
236
+ % valid_verification_scope(+Scope)
237
+ valid_verification_scope(Scope) :- memberchk(Scope, [unit, integration, end_to_end]), !.
238
+
239
+ % valid_verification_perspective(+Perspective)
240
+ valid_verification_perspective(Perspective) :- memberchk(Perspective, [internal, consumer]), !.
143
241
 
144
242
  % exactly_one_value_field(+Props)
145
243
  exactly_one_value_field(Props) :-
@@ -2,6 +2,11 @@ import { createHash, randomUUID } from "node:crypto";
2
2
  import { appendFileSync, mkdirSync } from "node:fs";
3
3
  import path from "node:path";
4
4
 
5
+ import {
6
+ appendPayloadCountField,
7
+ normalizeResultPayload,
8
+ } from "./operations/result-envelope.js";
9
+
5
10
  export interface DiagnosticUsageInput {
6
11
  readonly workspaceRoot: string;
7
12
  readonly tool: string;
@@ -20,16 +25,6 @@ function isRecord(value: unknown): value is Record<string, unknown> {
20
25
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
21
26
  }
22
27
 
23
- function resultRecord(result: unknown): Record<string, unknown> | undefined {
24
- if (!isRecord(result)) return undefined;
25
- if (isRecord(result.structuredContent)) return result.structuredContent;
26
- // CLI JSON operations return the same versioned KibiResult envelope as MCP
27
- // structuredContent. Unwrap its data before deriving operation-specific
28
- // telemetry fields (coverage/proof fields in particular).
29
- if (result.kibiProtocol === 1 && isRecord(result.data)) return result.data;
30
- return result;
31
- }
32
-
33
28
  function stringArray(value: unknown): string[] {
34
29
  return Array.isArray(value)
35
30
  ? value.filter((item): item is string => typeof item === "string")
@@ -188,11 +183,7 @@ export function deriveDiagnosticUsageFields(
188
183
  }
189
184
  }
190
185
 
191
- const structured = resultRecord(result);
192
- const envelope =
193
- isRecord(structured) && structured.kibiProtocol === 1
194
- ? structured
195
- : undefined;
186
+ const { envelope, data: structured } = normalizeResultPayload(result);
196
187
  if (envelope) {
197
188
  fields.protocol_version = envelope.kibiProtocol;
198
189
  fields.result_version =
@@ -214,18 +205,19 @@ export function deriveDiagnosticUsageFields(
214
205
  fields.unsafe_original_retry = telemetry?.unsafe_original_retry === true;
215
206
  }
216
207
  if (tool === "kb_query" || tool === "kb_search") {
217
- const resultCount = Number(structured?.count ?? 0);
218
- fields.result_count = resultCount;
219
- fields.zero_results = resultCount === 0;
220
- fields.result_summary =
221
- resultCount === 0 ? "0 results" : `${resultCount} results`;
208
+ appendPayloadCountField(fields, "result_count", "results", structured);
209
+ if (typeof fields.result_count === "number") {
210
+ fields.zero_results = fields.result_count === 0;
211
+ }
222
212
  }
223
213
  if (tool === "kb_check") {
224
- const count = Number(structured?.count ?? 0);
225
- fields.violation_count = count;
214
+ appendPayloadCountField(
215
+ fields,
216
+ "violation_count",
217
+ "violations",
218
+ structured,
219
+ );
226
220
  fields.requested_rules = Array.isArray(args.rules) ? args.rules : [];
227
- fields.result_summary =
228
- count === 0 ? "0 violations" : `${count} violations`;
229
221
  }
230
222
  if (tool === "kb_coverage" && structured) {
231
223
  appendCoverageFields(fields, args, structured);
@@ -18,6 +18,7 @@
18
18
 
19
19
  export {
20
20
  analyzeSourceText,
21
+ analyzeSourceTextWithRegistry,
21
22
  enrichSymbolCoordinates,
22
23
  type ManifestSymbolEntry,
23
24
  type AnalyzeSourceTextOptions,
@@ -1,6 +1,6 @@
1
1
  import * as path from "node:path";
2
2
  import type { ExtractedSymbol } from "../../traceability/symbol-extract.js";
3
- import { extractSymbolsFromStagedFile } from "../../traceability/symbol-extract.js";
3
+ import { extractSymbolsFromStagedFileAsync } from "../../traceability/symbol-extract.js";
4
4
  import {
5
5
  createSemanticReviewDiagnostics,
6
6
  createSymbolGranularityDiagnostics,
@@ -21,9 +21,9 @@ import type {
21
21
  ChangedFileImpactResult,
22
22
  } from "./types.js";
23
23
 
24
- export function analyzeChangedFileImpact(
24
+ export async function analyzeChangedFileImpact(
25
25
  options: ChangedFileImpactOptions,
26
- ): ChangedFileImpactResult {
26
+ ): Promise<ChangedFileImpactResult> {
27
27
  const workspaceRoot = path.resolve(options.workspaceRoot);
28
28
  const sourceChanges = collectSourceChanges({ ...options, workspaceRoot });
29
29
  const sourceFiles = uniqueSorted(sourceChanges.map((change) => change.file));
@@ -34,17 +34,20 @@ export function analyzeChangedFileImpact(
34
34
 
35
35
  for (const change of sourceChanges) {
36
36
  sourceContentByFile.set(change.file, change.content);
37
+ // Maintenance path: builtin-only (do not pass registry / workspaceRoot).
38
+ const extracted = await extractSymbolsFromStagedFileAsync(
39
+ {
40
+ path: change.file,
41
+ status: change.status,
42
+ hunkRanges: [...change.hunkRanges],
43
+ content: change.content,
44
+ },
45
+ manifestLookup,
46
+ {},
47
+ );
37
48
  symbolsByFile.set(
38
49
  change.file,
39
- extractSymbolsFromStagedFile(
40
- {
41
- path: change.file,
42
- status: change.status,
43
- hunkRanges: [...change.hunkRanges],
44
- content: change.content,
45
- },
46
- manifestLookup,
47
- ).filter((symbol) => symbol.hunkRanges.length > 0),
50
+ extracted.filter((symbol) => symbol.hunkRanges.length > 0),
48
51
  );
49
52
  }
50
53
 
@@ -568,22 +568,10 @@ export async function loadKbExtractionResults(
568
568
  prolog.queryEntities.bind(prolog),
569
569
  );
570
570
  } else {
571
- const entityResult = await prolog.query(
572
- "findall([Id,Type,Props], kb_entity(Id, Type, Props), Results)",
573
- );
574
- if (entityResult.success) {
575
- entities = entityResult.bindings.Results
576
- ? parseListOfLists(entityResult.bindings.Results).map(
577
- parseEntityFromList,
578
- )
579
- : [];
580
- } else if (isOutputCapacityError(entityResult.error)) {
581
- entities = await loadBoundedEntityProjection(prolog);
582
- } else {
583
- throw new Error(
584
- `Full KB entity projection query failed: ${entityResult.error ?? "Unknown error"}`,
585
- );
586
- }
571
+ // Never probe with an unbounded all-entities findall: receipt histories
572
+ // make that answer grow without limit, and an overflow terminates the
573
+ // interactive Prolog process that serves every later query.
574
+ entities = await loadBoundedEntityProjection(prolog);
587
575
  }
588
576
  const relationships = new Map<string, ExtractionResult["relationships"]>();
589
577
 
@@ -31,6 +31,7 @@ import {
31
31
  partitionCheckFindings,
32
32
  qualityDiagnosticsFromImpact,
33
33
  resolveCheckRules,
34
+ stagedEntityIdStyleDiagnostics,
34
35
  } from "./check-helpers.js";
35
36
  import { executeStatus } from "./discovery-executors.js";
36
37
  import {
@@ -38,6 +39,7 @@ import {
38
39
  buildMigrationPlan,
39
40
  mergeMigrationPlans,
40
41
  } from "./migration-plan.js";
42
+ import { collectPredicateSchemaConformanceViolations } from "./predicate-schema-conformance.js";
41
43
  import type { OperationContext, PrologPort } from "./runtime-types.js";
42
44
  import { collectSourceRelationshipParityViolations } from "./source-relationship-parity.js";
43
45
  import type { OperationResult } from "./types.js";
@@ -135,8 +137,11 @@ export async function executeCheck(
135
137
  // version. `args.rules` is an invocation-time diagnostic selector only.
136
138
  const rulesAllowlist = resolveCheckRules(args);
137
139
  const hasExplicitRules = args.rules !== undefined;
138
- const impactResult = analyzeKbCheckImpact(workspaceRoot, args);
139
- const impactQualityDiagnostics = qualityDiagnosticsFromImpact(impactResult);
140
+ const impactResult = await analyzeKbCheckImpact(workspaceRoot, args);
141
+ const impactQualityDiagnostics = [
142
+ ...qualityDiagnosticsFromImpact(impactResult),
143
+ ...stagedEntityIdStyleDiagnostics(workspaceRoot, args),
144
+ ];
140
145
  const maxDiagnosticsOption =
141
146
  args.maxDiagnostics !== undefined
142
147
  ? { maxDiagnostics: args.maxDiagnostics }
@@ -201,10 +206,16 @@ export async function executeCheck(
201
206
  )
202
207
  ? await collectSourceRelationshipParityViolations(workspaceRoot, prolog)
203
208
  : [];
209
+ const predicateConformanceFindings = rulesAllowlist.has(
210
+ "predicate-schema-conformance",
211
+ )
212
+ ? await collectPredicateSchemaConformanceViolations(prolog)
213
+ : [];
204
214
  const partitioned = partitionCheckFindings([
205
215
  ...aggregatedFindings,
206
216
  ...queryPlanViolations,
207
217
  ...sourceRelationshipParityViolations,
218
+ ...predicateConformanceFindings,
208
219
  ]);
209
220
  const violations: Violation[] = partitioned.violations;
210
221