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
@@ -41,7 +41,7 @@ export const querySpec = {
41
41
  id: {
42
42
  type: "string",
43
43
  description:
44
- "Optional exact entity ID. Example: 'REQ-001'. If omitted, returns matching entities by other filters.",
44
+ "Optional exact entity ID. Example: 'REQ-cli-gc'. If omitted, returns matching entities by other filters.",
45
45
  },
46
46
  tags: {
47
47
  type: "array",
@@ -70,6 +70,7 @@ export const querySpec = {
70
70
  },
71
71
  requiresProlog: true,
72
72
  effects: ["kb-read"],
73
+ agentVisibleStructuredData: true,
73
74
  execute: executeQuery,
74
75
  } as const satisfies OperationSpec<QueryInput, QueryPayload>;
75
76
 
@@ -160,10 +161,18 @@ export const searchSpec = {
160
161
  description:
161
162
  "Intent-v1 acceptance threshold between 0 and 1. Low-confidence queries abstain instead of returning misleading matches.",
162
163
  },
164
+ fields: {
165
+ type: "string",
166
+ enum: ["summary", "full"],
167
+ default: "summary",
168
+ description:
169
+ "Optional result detail. 'summary' returns identifying metadata plus the match snippet for discovery. Use 'full' to include complete entity bodies, or follow up with kb_query for the exact entities you need.",
170
+ },
163
171
  },
164
172
  },
165
173
  requiresProlog: true,
166
174
  effects: ["kb-read"],
175
+ agentVisibleStructuredData: true,
167
176
  execute: executeSearch,
168
177
  } as const satisfies OperationSpec<SearchInput, SearchPayload>;
169
178
 
@@ -176,5 +185,6 @@ export const statusSpec = {
176
185
  // Status must remain available when the branch store cannot be attached.
177
186
  requiresProlog: false,
178
187
  effects: ["kb-read", "workspace-read"],
188
+ agentVisibleStructuredData: true,
179
189
  execute: executeStatus,
180
190
  } as const satisfies OperationSpec<StatusInput, StatusPayload>;
@@ -46,7 +46,7 @@ export const ENTITY_PROPERTIES_SCHEMA = {
46
46
  source: {
47
47
  type: "string",
48
48
  description:
49
- "Optional provenance string. Example: 'docs/requirements/REQ-123.md'. Defaults to 'mcp://kibi/upsert'.",
49
+ "Optional provenance string. Example: '.kb/requirements/REQ-cli-gc.md'. Defaults to 'mcp://kibi/upsert'.",
50
50
  },
51
51
  tags: {
52
52
  type: "array",
@@ -69,7 +69,7 @@ export const ENTITY_PROPERTIES_SCHEMA = {
69
69
  type: "array",
70
70
  items: { type: "string" },
71
71
  description:
72
- "Optional references. Example: ['REQ-010','https://example.com/spec'].",
72
+ "Optional references. Example: ['REQ-cli-gc','https://example.com/spec'].",
73
73
  },
74
74
  text_ref: {
75
75
  type: "string",
@@ -295,6 +295,25 @@ export const ENTITY_PROPERTIES_SCHEMA = {
295
295
  items: { type: "string" },
296
296
  description: "Optional ordered argument explanations.",
297
297
  },
298
+ argument_constants: {
299
+ type: "object",
300
+ additionalProperties: {
301
+ type: "array",
302
+ items: { type: "string", minLength: 1 },
303
+ minItems: 1,
304
+ },
305
+ description:
306
+ 'predicate_schema only: allowed constants keyed by argument name, e.g. {"severity": ["warning", "info"]}. Predicate facts must use a listed constant for those arguments; unlisted arguments stay open.',
307
+ },
308
+ argument_aliases: {
309
+ type: "object",
310
+ additionalProperties: {
311
+ type: "object",
312
+ additionalProperties: { type: "string", minLength: 1 },
313
+ },
314
+ description:
315
+ 'predicate_schema only: legacy spellings keyed by argument name, each mapped to a declared constant, e.g. {"severity": {"warn": "warning"}}. kibi migrate rewrites facts that still use an alias.',
316
+ },
298
317
  aliases: {
299
318
  type: "array",
300
319
  items: { type: "string" },
@@ -371,6 +390,7 @@ export const RELATIONSHIPS_SCHEMA = {
371
390
  "publishes",
372
391
  "consumes",
373
392
  "supersedes",
393
+ "restates",
374
394
  "relates_to",
375
395
  ],
376
396
  description:
@@ -383,7 +403,7 @@ export const RELATIONSHIPS_SCHEMA = {
383
403
  },
384
404
  to: {
385
405
  type: "string",
386
- description: "Target entity ID (must exist). Example: 'REQ-001'.",
406
+ description: "Target entity ID (must exist). Example: 'REQ-cli-gc'.",
387
407
  },
388
408
  },
389
409
  },
@@ -12,7 +12,7 @@ export type {
12
12
  } from "../../../operations/proof/ingest-proof.js";
13
13
  export { executeIngestProof } from "../../../operations/proof/ingest-proof.js";
14
14
 
15
- // implements REQ-kibi-proof-evidence-protocol
15
+ // implements REQ-kibi-verification-evidence-contract
16
16
  export const ingestProofSpec = {
17
17
  name: "kb_ingest_proof",
18
18
  cliName: "ingest-proof",
@@ -193,14 +193,14 @@ export const findGapsSpec = {
193
193
  * KIBI_PROOF_BINDING_MODE=strict-snapshot opts out (receipts then match only
194
194
  * against the whole-workspace snapshot they were proven on).
195
195
  */
196
- // implements REQ-kibi-proof-evidence-protocol
196
+ // implements REQ-kibi-verification-evidence-contract
197
197
  export function currentProofBindingMode(): "per_contract" | "strict_snapshot" {
198
198
  return process.env.KIBI_PROOF_BINDING_MODE?.trim() === "strict-snapshot"
199
199
  ? "strict_snapshot"
200
200
  : "per_contract";
201
201
  }
202
202
 
203
- async function perContractTestBindings(
203
+ export async function perContractTestBindings(
204
204
  context: OperationContext,
205
205
  ): Promise<string | null> {
206
206
  if (currentProofBindingMode() !== "per_contract") return null;
@@ -209,12 +209,26 @@ async function perContractTestBindings(
209
209
  const { removeFrontmatterBlock } = await import(
210
210
  "../../../operations/proof/receipt-document.js"
211
211
  );
212
+ const { loadCoveredBySymbolsByTest, receiptCodeScopeSymbolIds } =
213
+ await import("../../../operations/proof/code-scope.js");
214
+ // Only the contract, scoped code, and authored source feed the binding
215
+ // hash. The paged projection never materializes receipt histories, which
216
+ // grow without bound and previously overflowed the bounded Prolog output
217
+ // on real stores. Engine failures must surface: silently dropping to strict
218
+ // snapshot semantics would hide an unhealthy engine behind stale receipts.
212
219
  let tests: Record<string, unknown>[];
213
220
  try {
214
- tests = await loadEntities(context.prolog as never, { type: "test" });
215
- } catch {
216
- return null;
221
+ tests = await loadEntities(requireProlog(context), {
222
+ type: "test",
223
+ projection: "proof_contract",
224
+ });
225
+ } catch (error) {
226
+ const message = error instanceof Error ? error.message : String(error);
227
+ throw new Error(`Per-contract receipt binding query failed: ${message}`);
217
228
  }
229
+ const coveredBy = tests.length
230
+ ? await loadCoveredBySymbolsByTest(requireProlog(context))
231
+ : new Map<string, readonly string[]>();
218
232
  const entries: string[] = [];
219
233
  const manifestPath = join(context.workspaceRoot, ".kb", "symbols.yaml");
220
234
  for (const test of tests) {
@@ -233,17 +247,14 @@ async function perContractTestBindings(
233
247
  const absolute = join(context.workspaceRoot, source);
234
248
  const authored = await context.fs.readFile(absolute);
235
249
  const stripped = removeFrontmatterBlock(authored, "proof_receipts");
236
- const rawBindings: ReadonlyArray<{ symbol_id?: unknown }> = Array.isArray(
237
- test.proof_bindings,
238
- )
239
- ? (test.proof_bindings as ReadonlyArray<{ symbol_id?: unknown }>)
240
- : [];
241
- const boundIds = rawBindings
242
- .map((binding) =>
243
- typeof binding.symbol_id === "string" ? binding.symbol_id : "",
244
- )
245
- .filter((id) => id !== "");
246
- const codeScope = resolveBoundSymbolScope(manifestPath, boundIds);
250
+ const codeScope = resolveBoundSymbolScope(
251
+ manifestPath,
252
+ receiptCodeScopeSymbolIds(
253
+ contract,
254
+ test.proof_bindings,
255
+ coveredBy.get(testId) ?? [],
256
+ ),
257
+ );
247
258
  const binding = receiptBindingHash(
248
259
  contract as never,
249
260
  stripped ?? authored,
@@ -258,6 +269,42 @@ async function perContractTestBindings(
258
269
  return `_{${entries.join(", ")}}`;
259
270
  }
260
271
 
272
+ /**
273
+ * Coverage rows can be large (full proof stages per requirement), so a
274
+ * whole-KB report in one answer approaches the engine's bounded output cap.
275
+ * Fetch it in small row pages instead; the engine memoizes the computed
276
+ * report per store generation, so later pages only paginate and encode.
277
+ */
278
+ export const COVERAGE_ROW_PAGE_SIZE = 10;
279
+
280
+ // implements REQ-kibi-verification-evidence-contract
281
+ export async function readCoveragePages(
282
+ prolog: NonNullable<OperationContext["prolog"]>,
283
+ goalFor: (limit: number, offset: number) => string,
284
+ limit: number,
285
+ offset: number,
286
+ ): Promise<CoveragePayload> {
287
+ const read = (pageLimit: number, pageOffset: number) =>
288
+ runOperationJsonQuery<CoveragePayload>(
289
+ prolog,
290
+ "discovery.pl",
291
+ goalFor(pageLimit, pageOffset),
292
+ "Coverage execution",
293
+ );
294
+ if (limit <= COVERAGE_ROW_PAGE_SIZE) return read(limit, offset);
295
+ const first = await read(COVERAGE_ROW_PAGE_SIZE, offset);
296
+ const rows = [...first.rows];
297
+ let lastPageSize = first.rows.length;
298
+ let lastPageLimit = COVERAGE_ROW_PAGE_SIZE;
299
+ while (lastPageSize === lastPageLimit && rows.length < limit) {
300
+ lastPageLimit = Math.min(COVERAGE_ROW_PAGE_SIZE, limit - rows.length);
301
+ const page = await read(lastPageLimit, offset + rows.length);
302
+ rows.push(...page.rows);
303
+ lastPageSize = page.rows.length;
304
+ }
305
+ return { ...first, rows };
306
+ }
307
+
261
308
  export async function executeCoverage(
262
309
  input: CoverageInput,
263
310
  context: OperationContext,
@@ -275,17 +322,17 @@ export async function executeCoverage(
275
322
  statuses.length === 0 && (input.by ?? "req") === "req"
276
323
  ? await perContractTestBindings(context)
277
324
  : null;
278
- const goal =
325
+ const goalFor = (limit: number, offset: number): string =>
279
326
  bindingsDict !== null
280
- ? `discovery:coverage_report_json('${input.by ?? "req"}', ${toPrologList(input.tags)}, ${input.includePassing ?? false}, per_contract, ${bindingsDict}, ${input.includeTransitive ?? true}, ${input.limit ?? 100}, ${input.offset ?? 0}, ${toPrologAtom(codeSnapshot)}, ${toPrologAtom(checkedAt)}, ${PROOF_RECEIPT_MAX_AGE_SECONDS}, JsonString)`
327
+ ? `discovery:coverage_report_json('${input.by ?? "req"}', ${toPrologList(input.tags)}, ${input.includePassing ?? false}, per_contract, ${bindingsDict}, ${input.includeTransitive ?? true}, ${limit}, ${offset}, ${toPrologAtom(codeSnapshot)}, ${toPrologAtom(checkedAt)}, ${PROOF_RECEIPT_MAX_AGE_SECONDS}, JsonString)`
281
328
  : statuses.length > 0
282
- ? `discovery:coverage_report_json('${input.by ?? "req"}', ${toPrologList(input.tags)}, ${input.includePassing ?? false}, ${toPrologList(statuses)}, ${input.includeTransitive ?? true}, ${input.limit ?? 100}, ${input.offset ?? 0}, ${toPrologAtom(codeSnapshot)}, ${toPrologAtom(checkedAt)}, ${PROOF_RECEIPT_MAX_AGE_SECONDS}, JsonString)`
283
- : `discovery:coverage_report_json('${input.by ?? "req"}', ${toPrologList(input.tags)}, ${input.includePassing ?? false}, ${input.includeTransitive ?? true}, ${input.limit ?? 100}, ${input.offset ?? 0}, ${toPrologAtom(codeSnapshot)}, ${toPrologAtom(checkedAt)}, ${PROOF_RECEIPT_MAX_AGE_SECONDS}, JsonString)`;
284
- const payload = await runOperationJsonQuery<CoveragePayload>(
329
+ ? `discovery:coverage_report_json('${input.by ?? "req"}', ${toPrologList(input.tags)}, ${input.includePassing ?? false}, ${toPrologList(statuses)}, ${input.includeTransitive ?? true}, ${limit}, ${offset}, ${toPrologAtom(codeSnapshot)}, ${toPrologAtom(checkedAt)}, ${PROOF_RECEIPT_MAX_AGE_SECONDS}, JsonString)`
330
+ : `discovery:coverage_report_json('${input.by ?? "req"}', ${toPrologList(input.tags)}, ${input.includePassing ?? false}, ${input.includeTransitive ?? true}, ${limit}, ${offset}, ${toPrologAtom(codeSnapshot)}, ${toPrologAtom(checkedAt)}, ${PROOF_RECEIPT_MAX_AGE_SECONDS}, JsonString)`;
331
+ const payload = await readCoveragePages(
285
332
  requireProlog(context),
286
- "discovery.pl",
287
- goal,
288
- "Coverage execution",
333
+ goalFor,
334
+ input.limit ?? 100,
335
+ input.offset ?? 0,
289
336
  );
290
337
  const rows =
291
338
  (input.by ?? "req") === "req"
@@ -1,9 +1,10 @@
1
1
  import { InputError } from "../../../cli-errors.js";
2
- import { analyzeSemanticAdvisorInput } from "../../../operations/semantic-advisor/analyze-prose.js";
2
+ import { analyzeSemanticAdvisorInputWithPlugins } from "../../../operations/semantic-advisor/plugin-orchestration.js";
3
3
  import type {
4
4
  SemanticAdvisorArgs,
5
5
  SemanticAdvisorOperationResult,
6
6
  } from "../../../operations/semantic-advisor/types.js";
7
+ import { publicCapabilityStamp } from "../../../plugins/compose-semantic-classifier.js";
7
8
  import type { OperationContext } from "../runtime-types.js";
8
9
  import type { OperationSpec } from "../types.js";
9
10
 
@@ -25,28 +26,85 @@ function optionalString(value: unknown): string | undefined {
25
26
 
26
27
  export async function executeSemanticAdvisor(
27
28
  args: SemanticAdvisorArgs,
28
- _context?: OperationContext,
29
+ context?: OperationContext,
29
30
  ): Promise<SemanticAdvisorOperationResult> {
30
31
  const text = requiredText(args.text);
31
32
  const id = optionalString(args.id) ?? "REQ-SEMANTIC-ADVISOR-PREVIEW";
32
33
  const title = optionalString(args.title) ?? text.split(/[.!?]/, 1)[0] ?? text;
33
34
  const source = optionalString(args.source) ?? "mcp://kibi/semantic-advisor";
34
- const result = analyzeSemanticAdvisorInput({
35
- payload: {
36
- type: optionalString(args.type) ?? "req",
37
- id,
38
- properties: {
39
- title,
40
- status: optionalString(args.status) ?? "open",
41
- source,
42
- semantic_text: text,
35
+ const orchestrated = await analyzeSemanticAdvisorInputWithPlugins(
36
+ {
37
+ payload: {
38
+ type: optionalString(args.type) ?? "req",
39
+ id,
40
+ properties: {
41
+ title,
42
+ status: optionalString(args.status) ?? "open",
43
+ source,
44
+ semantic_text: text,
45
+ },
43
46
  },
47
+ ...(args.clauses !== undefined ? { clauses: args.clauses } : {}),
48
+ ...(args.interpretations !== undefined
49
+ ? { interpretations: args.interpretations }
50
+ : {}),
51
+ },
52
+ {
53
+ operationName: "kb_semantic_advisor",
54
+ ...(context?.ensurePlugins
55
+ ? { ensurePlugins: context.ensurePlugins }
56
+ : {}),
44
57
  },
45
- ...(args.clauses !== undefined ? { clauses: args.clauses } : {}),
46
- ...(args.interpretations !== undefined
47
- ? { interpretations: args.interpretations }
48
- : {}),
49
- });
58
+ );
59
+ const result = orchestrated.analysis;
60
+ const pluginWarnings =
61
+ orchestrated.stamps.length > 0
62
+ ? [
63
+ `Capability plugins consulted: ${orchestrated.stamps
64
+ .map((stamp) => `${stamp.pluginId}/${stamp.capability}`)
65
+ .join(", ")}.`,
66
+ ]
67
+ : [];
68
+ const capabilityPlugins =
69
+ orchestrated.stamps.length > 0 ||
70
+ (orchestrated.classification?.shadowComparisons.length ?? 0) > 0 ||
71
+ orchestrated.ontologyShadowMatches.length > 0
72
+ ? {
73
+ stamps: orchestrated.stamps.map((stamp) =>
74
+ publicCapabilityStamp(stamp),
75
+ ),
76
+ classification: orchestrated.classification
77
+ ? {
78
+ fallbackUsed: orchestrated.classification.fallbackUsed,
79
+ decisions: orchestrated.classification.decisions,
80
+ shadowComparisons:
81
+ orchestrated.classification.shadowComparisons.map(
82
+ (comparison) => ({
83
+ ...publicCapabilityStamp(comparison.stamp),
84
+ decisions: comparison.decisions.map((decision) => ({
85
+ claimKey: decision.claimKey,
86
+ lane: decision.lane,
87
+ confidence: decision.confidence,
88
+ })),
89
+ }),
90
+ ),
91
+ }
92
+ : null,
93
+ ontology: {
94
+ replaced: orchestrated.ontologyCatalog?.replaced ?? false,
95
+ matchCount: orchestrated.ontologyMatches.length,
96
+ shadowMatchCount: orchestrated.ontologyShadowMatches.length,
97
+ shadowMatches: orchestrated.ontologyShadowMatches.map(
98
+ (candidate) => ({
99
+ packId: candidate.packId,
100
+ schemaId: candidate.schemaId,
101
+ predicateName: candidate.predicateName,
102
+ confidence: candidate.confidence,
103
+ }),
104
+ ),
105
+ },
106
+ }
107
+ : undefined;
50
108
  return {
51
109
  content: [
52
110
  {
@@ -54,7 +112,11 @@ export async function executeSemanticAdvisor(
54
112
  text: `kb_semantic_advisor: ${result.receipt.summary} Suggestions: ${result.receipt.suggestions.map(({ kind }) => kind).join(", ") || "none"}.`,
55
113
  },
56
114
  ],
57
- structuredContent: { receipt: result.receipt, warnings: result.warnings },
115
+ structuredContent: {
116
+ receipt: result.receipt,
117
+ warnings: [...result.warnings, ...pluginWarnings],
118
+ ...(capabilityPlugins ? { capabilityPlugins } : {}),
119
+ },
58
120
  };
59
121
  }
60
122
 
@@ -28,7 +28,7 @@ export const upsertSpec = {
28
28
  id: {
29
29
  type: "string",
30
30
  description:
31
- "Unique entity ID (string). Example: 'REQ-123'. Existing ID updates the entity; new ID creates it.",
31
+ "Unique entity ID (string). Example: 'REQ-cli-gc'. Name entities by the behavior they govern (<TYPE>-<area>-<behavior>), never by the next free number. Existing ID updates the entity; new ID creates it.",
32
32
  },
33
33
  properties: ENTITY_PROPERTIES_SCHEMA,
34
34
  relationships: RELATIONSHIPS_SCHEMA,
@@ -7,7 +7,13 @@ import {
7
7
  enrichSymbolCoordinates,
8
8
  } from "../../extractors/symbols-coordinator.js";
9
9
  import { isCoarseGranularityReason } from "../symbol-granularity.js";
10
- import { loadEntities } from "./discovery-entities.js";
10
+ import { loadEntitiesPaged } from "./discovery-entities.js";
11
+
12
+ /**
13
+ * Symbol pages for repair planning. The full symbol inventory is already half
14
+ * of the bounded engine output on large workspaces, so it is read in pages.
15
+ */
16
+ const SYMBOL_PAGE_SIZE = 250;
11
17
  import type { OperationContext } from "./runtime-types.js";
12
18
 
13
19
  export const SYMBOL_REPAIR_PLAN_VERSION = "kibi.symbol-repair-plan.v1" as const;
@@ -131,7 +137,7 @@ export async function addCoordinateRepairEvidence(
131
137
  const ids = new Set(missingByRow.flat());
132
138
  if (ids.size === 0 || !context.prolog) return rows;
133
139
  const symbols = (
134
- await loadEntities(context.prolog, { type: "symbol" })
140
+ await loadEntitiesPaged(context.prolog, "symbol", SYMBOL_PAGE_SIZE)
135
141
  ).filter((symbol) => ids.has(String(symbol.id)));
136
142
  const evidence = await inspectCoordinateRepairs(
137
143
  symbols,
@@ -227,7 +233,11 @@ export async function buildSymbolRepairPlan(
227
233
  context: OperationContext,
228
234
  ): Promise<SymbolRepairPlan | undefined> {
229
235
  if (!context.prolog || rows.length === 0) return undefined;
230
- const symbols = await loadEntities(context.prolog, { type: "symbol" });
236
+ const symbols = await loadEntitiesPaged(
237
+ context.prolog,
238
+ "symbol",
239
+ SYMBOL_PAGE_SIZE,
240
+ );
231
241
  const extractedByPath = new Map<
232
242
  string,
233
243
  readonly { name: string; kind: string }[]
@@ -240,10 +250,9 @@ export async function buildSymbolRepairPlan(
240
250
  : path.resolve(context.workspaceRoot, source);
241
251
  if (!existsSync(absolute)) continue;
242
252
  try {
243
- const analysis = analyzeSourceText(
244
- absolute,
245
- readFileSync(absolute, "utf8"),
246
- );
253
+ const content = readFileSync(absolute, "utf8");
254
+ // Coverage/impact is a maintenance path: never import project plugins.
255
+ const analysis = analyzeSourceText(absolute, content);
247
256
  if (analysis.providerId === null) continue;
248
257
  extractedByPath.set(
249
258
  source,
@@ -93,6 +93,11 @@ export interface OperationSpec<
93
93
  readonly businessInputSchema: Readonly<Record<string, unknown>>;
94
94
  readonly requiresProlog: boolean;
95
95
  readonly effects: readonly OperationEffect[];
96
+ /**
97
+ * When true, MCP duplicates envelope `data` into tool `content` text so hosts
98
+ * that hide `structuredContent` still expose discovery/proof payloads.
99
+ */
100
+ readonly agentVisibleStructuredData?: boolean;
96
101
  /** Generated effect metadata used by MCP annotations and telemetry. */
97
102
  readonly declaredEffects?: readonly OperationEffectDeclaration[];
98
103
  /** Version of the machine-readable result data for this operation. */
@@ -71,7 +71,7 @@ export function proofContractHash(contract: ProofContract): string {
71
71
  * workspace state changes, and goes stale the moment the test's own contract
72
72
  * or document does. Callers pass the receipt-stripped document content.
73
73
  */
74
- // implements REQ-kibi-proof-evidence-protocol
74
+ // implements REQ-kibi-verification-evidence-contract
75
75
  export interface ReceiptCodeScopeEntry {
76
76
  readonly symbolId: string;
77
77
  readonly sourceHash: string;
@@ -1,4 +1,4 @@
1
- // implements REQ-kibi-proof-evidence-protocol
1
+ // implements REQ-kibi-verification-evidence-contract
2
2
  export type ProofRunOutcome =
3
3
  | "passed"
4
4
  | "failed"
@@ -1,10 +1,10 @@
1
- // implements REQ-kibi-proof-evidence-protocol
1
+ // implements REQ-kibi-verification-evidence-contract
2
2
  export const PROOF_RUN_VERSION = "kibi.proof-run.v1" as const;
3
- // implements REQ-kibi-proof-evidence-protocol
3
+ // implements REQ-kibi-verification-evidence-contract
4
4
  export const PROOF_CONTRACT_VERSION = "kibi.proof-contract.v1" as const;
5
- // implements REQ-kibi-proof-evidence-protocol
5
+ // implements REQ-kibi-verification-evidence-contract
6
6
  export const PROOF_RECEIPT_VERSION = "kibi.proof-receipt.v1" as const;
7
- // implements REQ-kibi-proof-evidence-protocol
7
+ // implements REQ-kibi-verification-evidence-contract
8
8
  export const PROOF_INTEGRATION_VERSION = "kibi.proof-integration.v1" as const;
9
9
 
10
10
  export const PROOF_RUN_OUTCOMES = [
@@ -531,6 +531,26 @@ const entitySchema: Record<string, unknown> = {
531
531
  aliases: { type: "array", items: { type: "string" } },
532
532
  examples: { type: "array", items: { type: "string" } },
533
533
  predicate_args: { type: "array", items: { type: "string" } },
534
+ // predicate_schema only: allowed constants per argument name. Arguments
535
+ // without an entry stay open; predicate facts must use a listed constant.
536
+ argument_constants: {
537
+ type: "object",
538
+ additionalProperties: {
539
+ type: "array",
540
+ minItems: 1,
541
+ uniqueItems: true,
542
+ items: { type: "string", minLength: 1 },
543
+ },
544
+ },
545
+ // predicate_schema only: legacy spellings per argument name, each mapped
546
+ // to one declared constant. kibi migrate rewrites facts that use them.
547
+ argument_aliases: {
548
+ type: "object",
549
+ additionalProperties: {
550
+ type: "object",
551
+ additionalProperties: { type: "string", minLength: 1 },
552
+ },
553
+ },
534
554
  rule_ir: { $ref: "#/$defs/logicRule" },
535
555
  rule_hash: { type: "string", pattern: "^[a-f0-9]{64}$" },
536
556
  rule_schema_id: { type: "string", minLength: 1 },
@@ -594,6 +614,8 @@ const entitySchema: Record<string, unknown> = {
594
614
  { required: ["aliases"] },
595
615
  { required: ["examples"] },
596
616
  { required: ["predicate_args"] },
617
+ { required: ["argument_constants"] },
618
+ { required: ["argument_aliases"] },
597
619
  { required: ["rule_ir"] },
598
620
  { required: ["rule_hash"] },
599
621
  { required: ["rule_schema_id"] },
@@ -40,6 +40,7 @@ const relationshipSchema = {
40
40
  "publishes",
41
41
  "consumes",
42
42
  "supersedes",
43
+ "restates",
43
44
  "relates_to",
44
45
  ],
45
46
  },
@@ -2,7 +2,7 @@
2
2
  id: kibi-usage
3
3
  name: Kibi Usage
4
4
  description: Use Kibi's source-first, exact-Git, migration-aware, proof-aware operations safely across MCP or the trusted local CLI, including partial completion repair.
5
- version: 2.1.2
5
+ version: 2.2.0
6
6
  kibiCompatibility: ">=1.0.0"
7
7
  tags:
8
8
  - kibi
@@ -59,7 +59,11 @@ mutability, and Prolog requirements of each operation.
59
59
  ## Safe workflow
60
60
 
61
61
  1. Always discover before you mutate: start with `kb_search`, then exact-filter with `kb_query`. Use
62
- `kb_status` when branch or freshness confidence matters.
62
+ `kb_status` when branch or freshness confidence matters. `kb_search` ranks
63
+ lexically unless you pass `rankingMode: "intent-v1"`, `semanticFacets`, or
64
+ `sourceLocations`; use intent mode with grounded facets for conceptual
65
+ questions and before changing a source file, and keep lexical search for
66
+ literal identifiers. See `resources/workflows.md` for the mode recipe.
63
67
  2. Resolve genuine ambiguity with the human; use semantic advisor/modeling
64
68
  operations for deterministic interpretation and typed facts.
65
69
  3. Create endpoints before relationships and upsert small batches sequentially.
@@ -133,6 +137,9 @@ safe normative claims; use `observation` or `meta` for bug/workaround notes and
133
137
  tests, symbol ownership, and fresh proof-bearing receipts before claiming proof.
134
138
  For an existing product KB that needs semantic backfill, read
135
139
  `resources/kb-improvement.md`, and `resources/proof.md` for the proof workflow.
140
+ When a proof ratchet fails, follow Debugging proof regressions in
141
+ `resources/proof.md`: use `kibi proof explain` and compare current proof state
142
+ to committed `proof/baseline.json` with `kibi proof impact`.
136
143
 
137
144
  ## Predicate Ontology Decision Tree
138
145
 
@@ -157,7 +164,7 @@ Represent implementation ownership with a `symbol` entity that has
157
164
  `sourceFile`, `implements` to the requirement, and `covered_by` to the test.
158
165
  Prolog `symbol-coverage` also requires the test to `validates` the requirement
159
166
  (or the requirement `verified_by` the test). `covered_by` alone is not
160
- enough. Do not rely on legacy `// implements REQ-xxx` comments as the
167
+ enough. Do not rely on legacy `// implements REQ-<area>-<behavior>` comments as the
161
168
  traceability record.
162
169
 
163
170
  ## Complete Logical Coverage
@@ -55,6 +55,10 @@ relationship: { type: requires_predicate, from: REQ-EDITOR-DRAFT-AUTOSAVE, to: F
55
55
 
56
56
  The project-local schema endpoint must exist before this fact is linked. When ontology extension is explicitly authorized, define it first with `fact_kind: predicate_schema`, `predicate_name`, `predicate_arity`, and equally sized `argument_names` and `argument_types`. Without an authorized stable signature, record `review:ontology-gap` instead of inventing a schema.
57
57
 
58
+ ### Closed argument vocabularies
59
+
60
+ A schema can close an argument with `argument_constants` (allowed values keyed by argument name) and map older spellings with `argument_aliases`. Reuse a declared constant; `kb_upsert` rejects any other value and names the constant to use for an alias. When a genuinely new value is needed, extend `argument_constants` on the schema first. To converge existing facts, declare aliases for their spellings and let `kibi migrate` rewrite them (`predicate_schema_alignment` actions). Close only arguments with a natural shared vocabulary, such as the governed component or a severity; forcing distinct obligations into a few constants makes different requirements share one ground term.
61
+
58
62
  ### Deny predicate
59
63
 
60
64
  Claim: “Suspended users must not publish articles.” When `permission_rule` fits, preserve its positive schema name and encode prohibition as polarity:
@@ -103,3 +103,48 @@ re-run `kibi prove` for the affected selection, then confirm `kb_status` and
103
103
  `kb_coverage` before handoff.
104
104
 
105
105
  Full reference: `docs/proving-requirements.md`.
106
+
107
+ ## Debugging proof regressions
108
+
109
+ When a proof ratchet fails, diagnose first. Do not treat
110
+ `proof/baseline.json` as the thing to edit.
111
+
112
+ 1. Do not refresh `proof/baseline.json` as the first fix.
113
+ 2. Identify the exact requirement and symbol responsible for the regression.
114
+ 3. Use Kibi proof diagnostics rather than reverse-engineering
115
+ `requirement_proof.pl`:
116
+
117
+ ```bash
118
+ kibi proof explain REQ-<id>
119
+ kibi proof explain SYM-<id>
120
+ kibi proof impact
121
+ ```
122
+
123
+ `kibi proof impact` compares the current Proof projection to
124
+ `HEAD:proof/baseline.json` (the committed ratchet snapshot, not the
125
+ working-tree file). It is diagnostic: fingerprint differences are reported
126
+ and the command exits 0 on successful evaluation. The strict ratchet remains
127
+ `scripts/check-proof-baseline.mjs`.
128
+ 4. For `missing_production_symbol_coverage`, inspect symbol role, owning
129
+ requirement, `covered_by`, candidate test scope, the requirement scenario
130
+ chain, and the current proof receipt. `kibi proof explain` prints those as
131
+ three labeled blocks so they cannot be confused:
132
+ `required_proofs` (TEST contract obligations), `executable_for` (test-code
133
+ identity), and `covered_by` (production coverage candidates with primary
134
+ plus optional secondary reasons).
135
+ 5. A behavioral production symbol requires qualifying behavioral/E2E evidence
136
+ under the current proof model.
137
+ 6. Unit coverage can satisfy structural/type-shape requirements only when the
138
+ symbol genuinely represents structural shape and the proof model allows it.
139
+ 7. `executable_for` identifies executable test code. Never use it on
140
+ production helpers merely to remove production coverage obligations.
141
+ 8. Do not trust TEST names. Resolve
142
+ `TEST -> proof_contract.required_proofs -> SYM -> source` and inspect what
143
+ the executable test actually exercises. Kibi does not infer “this TEST name
144
+ does not match that source file.”
145
+ 9. A passing proof producer does not automatically make every authored
146
+ `covered_by` relationship semantically correct.
147
+ 10. Prefer one meaningful E2E scenario covering multiple internal functions
148
+ plus focused unit tests for edge cases, rather than an E2E test per helper.
149
+ 11. Refresh the baseline only after a genuine intentional proof-state
150
+ improvement requires the ratchet snapshot to be updated.