kibi-cli 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (377) hide show
  1. package/dist/cli-protocol.d.ts.map +1 -1
  2. package/dist/cli-protocol.js +3 -2
  3. package/dist/cli-register-proof.d.ts.map +1 -1
  4. package/dist/cli-register-proof.js +25 -1
  5. package/dist/cli-register-reporting.d.ts.map +1 -1
  6. package/dist/cli-register-reporting.js +6 -0
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +2 -0
  9. package/dist/commands/aggregated-checks.d.ts +7 -0
  10. package/dist/commands/aggregated-checks.d.ts.map +1 -1
  11. package/dist/commands/aggregated-checks.js +25 -1
  12. package/dist/commands/check-generated.d.ts +7 -0
  13. package/dist/commands/check-generated.d.ts.map +1 -0
  14. package/dist/commands/check-generated.js +192 -0
  15. package/dist/commands/check.d.ts.map +1 -1
  16. package/dist/commands/check.js +24 -15
  17. package/dist/commands/doctor.d.ts.map +1 -1
  18. package/dist/commands/doctor.js +227 -25
  19. package/dist/commands/engine.d.ts.map +1 -1
  20. package/dist/commands/engine.js +3 -1
  21. package/dist/commands/github-init.d.ts +1 -1
  22. package/dist/commands/github-init.d.ts.map +1 -1
  23. package/dist/commands/github-init.js +1 -1
  24. package/dist/commands/init-helpers.d.ts +17 -2
  25. package/dist/commands/init-helpers.d.ts.map +1 -1
  26. package/dist/commands/init-helpers.js +136 -30
  27. package/dist/commands/init.d.ts.map +1 -1
  28. package/dist/commands/init.js +110 -15
  29. package/dist/commands/proof-explain.d.ts +10 -0
  30. package/dist/commands/proof-explain.d.ts.map +1 -0
  31. package/dist/commands/proof-explain.js +45 -0
  32. package/dist/commands/proof-impact.d.ts +7 -0
  33. package/dist/commands/proof-impact.d.ts.map +1 -0
  34. package/dist/commands/proof-impact.js +39 -0
  35. package/dist/commands/proof-migrate-legacy.js +1 -1
  36. package/dist/commands/proof-prune.js +1 -1
  37. package/dist/commands/prove.d.ts.map +1 -1
  38. package/dist/commands/prove.js +14 -22
  39. package/dist/commands/report.d.ts.map +1 -1
  40. package/dist/commands/report.js +17 -2
  41. package/dist/commands/sync/cache.d.ts +20 -1
  42. package/dist/commands/sync/cache.d.ts.map +1 -1
  43. package/dist/commands/sync/cache.js +51 -2
  44. package/dist/commands/sync/discovery.d.ts.map +1 -1
  45. package/dist/commands/sync/discovery.js +1 -1
  46. package/dist/commands/sync/manifest.d.ts +1 -0
  47. package/dist/commands/sync/manifest.d.ts.map +1 -1
  48. package/dist/commands/sync/manifest.js +18 -16
  49. package/dist/commands/sync/persistence.d.ts.map +1 -1
  50. package/dist/commands/sync/persistence.js +14 -0
  51. package/dist/commands/sync.d.ts.map +1 -1
  52. package/dist/commands/sync.js +11 -3
  53. package/dist/engine.d.ts +29 -1
  54. package/dist/engine.d.ts.map +1 -1
  55. package/dist/engine.js +259 -89
  56. package/dist/env/bootstrap.d.ts +84 -0
  57. package/dist/env/bootstrap.d.ts.map +1 -0
  58. package/dist/env/bootstrap.js +310 -0
  59. package/dist/extractors/manifest.d.ts.map +1 -1
  60. package/dist/extractors/manifest.js +67 -29
  61. package/dist/extractors/markdown.d.ts +4 -0
  62. package/dist/extractors/markdown.d.ts.map +1 -1
  63. package/dist/extractors/markdown.js +33 -3
  64. package/dist/extractors/relationships.d.ts.map +1 -1
  65. package/dist/extractors/relationships.js +1 -0
  66. package/dist/extractors/symbols-coordinator.d.ts +8 -0
  67. package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
  68. package/dist/extractors/symbols-coordinator.js +40 -0
  69. package/dist/extractors/symbols-ts.d.ts +8 -19
  70. package/dist/extractors/symbols-ts.d.ts.map +1 -1
  71. package/dist/extractors/symbols-ts.js +33 -503
  72. package/dist/intent-search.d.ts.map +1 -1
  73. package/dist/intent-search.js +68 -30
  74. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  75. package/dist/operations/bootstrap/generate.js +4 -3
  76. package/dist/operations/modeling/model-requirement.d.ts +1 -1
  77. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  78. package/dist/operations/modeling/model-requirement.js +179 -9
  79. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  80. package/dist/operations/modeling/predicate-applyplan.js +14 -2
  81. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  82. package/dist/operations/modeling/predicate-loader.js +24 -0
  83. package/dist/operations/modeling/predicate-types.d.ts +4 -0
  84. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  85. package/dist/operations/modeling/predicate-vocabulary.d.ts +54 -0
  86. package/dist/operations/modeling/predicate-vocabulary.d.ts.map +1 -0
  87. package/dist/operations/modeling/predicate-vocabulary.js +169 -0
  88. package/dist/operations/modeling/requirement-types.d.ts +5 -0
  89. package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
  90. package/dist/operations/modeling/suggest-predicates.d.ts +1 -1
  91. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  92. package/dist/operations/modeling/suggest-predicates.js +30 -3
  93. package/dist/operations/modeling/vocabulary-alignment.d.ts +60 -0
  94. package/dist/operations/modeling/vocabulary-alignment.d.ts.map +1 -0
  95. package/dist/operations/modeling/vocabulary-alignment.js +178 -0
  96. package/dist/operations/mutation/contradictions.d.ts +3 -0
  97. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  98. package/dist/operations/mutation/contradictions.js +29 -0
  99. package/dist/operations/mutation/delete.d.ts.map +1 -1
  100. package/dist/operations/mutation/delete.js +33 -1
  101. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +8 -0
  102. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -0
  103. package/dist/operations/mutation/predicate-vocabulary-guard.js +64 -0
  104. package/dist/operations/mutation/relationships.d.ts +1 -1
  105. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  106. package/dist/operations/mutation/relationships.js +1 -0
  107. package/dist/operations/mutation/saga.d.ts +5 -0
  108. package/dist/operations/mutation/saga.d.ts.map +1 -1
  109. package/dist/operations/mutation/saga.js +10 -0
  110. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  111. package/dist/operations/mutation/serialization.js +2 -0
  112. package/dist/operations/mutation/source-authoring.d.ts +6 -0
  113. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  114. package/dist/operations/mutation/source-authoring.js +65 -26
  115. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  116. package/dist/operations/mutation/strict-fact.js +5 -0
  117. package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
  118. package/dist/operations/mutation/symbol-granularity.js +9 -87
  119. package/dist/operations/mutation/types.d.ts +17 -0
  120. package/dist/operations/mutation/types.d.ts.map +1 -1
  121. package/dist/operations/mutation/upsert.d.ts +6 -0
  122. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  123. package/dist/operations/mutation/upsert.js +72 -4
  124. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  125. package/dist/operations/mutation/validate-upsert.js +24 -1
  126. package/dist/operations/mutation/validation.d.ts.map +1 -1
  127. package/dist/operations/mutation/validation.js +16 -3
  128. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  129. package/dist/operations/planning/apply-plan.js +61 -17
  130. package/dist/operations/planning/compile-intent.d.ts +49 -0
  131. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  132. package/dist/operations/planning/compile-intent.js +66 -4
  133. package/dist/operations/proof/baseline-diff.d.ts +41 -0
  134. package/dist/operations/proof/baseline-diff.d.ts.map +1 -0
  135. package/dist/operations/proof/baseline-diff.js +153 -0
  136. package/dist/operations/proof/code-scope.d.ts +17 -0
  137. package/dist/operations/proof/code-scope.d.ts.map +1 -0
  138. package/dist/operations/proof/code-scope.js +60 -0
  139. package/dist/operations/proof/explain.d.ts +75 -0
  140. package/dist/operations/proof/explain.d.ts.map +1 -0
  141. package/dist/operations/proof/explain.js +294 -0
  142. package/dist/operations/proof/impact.d.ts +45 -0
  143. package/dist/operations/proof/impact.d.ts.map +1 -0
  144. package/dist/operations/proof/impact.js +118 -0
  145. package/dist/operations/proof/ingest-proof.d.ts +4 -2
  146. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  147. package/dist/operations/proof/ingest-proof.js +251 -77
  148. package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
  149. package/dist/operations/proof/migrate-legacy-receipts.js +28 -22
  150. package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
  151. package/dist/operations/proof/prune-receipts.js +8 -6
  152. package/dist/operations/proof/receipt-document.js +2 -2
  153. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  154. package/dist/operations/semantic-advisor/analysis-receipt.js +3 -9
  155. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  156. package/dist/operations/semantic-advisor/analyze-prose.js +18 -67
  157. package/dist/operations/semantic-advisor/plugin-orchestration.d.ts +63 -0
  158. package/dist/operations/semantic-advisor/plugin-orchestration.d.ts.map +1 -0
  159. package/dist/operations/semantic-advisor/plugin-orchestration.js +489 -0
  160. package/dist/operations/semantic-advisor/predicate-rules-core.d.ts +15 -2
  161. package/dist/operations/semantic-advisor/predicate-rules-core.d.ts.map +1 -1
  162. package/dist/operations/semantic-advisor/predicate-rules-core.js +7 -140
  163. package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts +11 -12
  164. package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts.map +1 -1
  165. package/dist/operations/semantic-advisor/predicate-rules-launcher.js +6 -94
  166. package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts +16 -0
  167. package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts.map +1 -1
  168. package/dist/operations/semantic-advisor/predicate-rules-policy.js +7 -150
  169. package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts +9 -0
  170. package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts.map +1 -1
  171. package/dist/operations/semantic-advisor/predicate-rules-product-tail.js +7 -102
  172. package/dist/operations/semantic-advisor/predicate-rules-product.d.ts +13 -0
  173. package/dist/operations/semantic-advisor/predicate-rules-product.d.ts.map +1 -1
  174. package/dist/operations/semantic-advisor/predicate-rules-product.js +7 -133
  175. package/dist/operations/semantic-advisor/types.d.ts +1 -0
  176. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  177. package/dist/plugins/compose-ontology-packs.d.ts +51 -0
  178. package/dist/plugins/compose-ontology-packs.d.ts.map +1 -0
  179. package/dist/plugins/compose-ontology-packs.js +257 -0
  180. package/dist/plugins/compose-semantic-classifier.d.ts +47 -0
  181. package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -0
  182. package/dist/plugins/compose-semantic-classifier.js +216 -0
  183. package/dist/plugins/compose-vocabulary-alignment.d.ts +23 -0
  184. package/dist/plugins/compose-vocabulary-alignment.d.ts.map +1 -0
  185. package/dist/plugins/compose-vocabulary-alignment.js +141 -0
  186. package/dist/plugins/external-allowlist.d.ts +17 -0
  187. package/dist/plugins/external-allowlist.d.ts.map +1 -0
  188. package/dist/plugins/external-allowlist.js +29 -0
  189. package/dist/plugins/index.d.ts +11 -0
  190. package/dist/plugins/index.d.ts.map +1 -0
  191. package/dist/plugins/index.js +37 -0
  192. package/dist/plugins/load-plugin.d.ts +19 -0
  193. package/dist/plugins/load-plugin.d.ts.map +1 -0
  194. package/dist/plugins/load-plugin.js +59 -0
  195. package/dist/plugins/project-config.d.ts +28 -0
  196. package/dist/plugins/project-config.d.ts.map +1 -0
  197. package/dist/plugins/project-config.js +90 -0
  198. package/dist/plugins/registry.d.ts +94 -0
  199. package/dist/plugins/registry.d.ts.map +1 -0
  200. package/dist/plugins/registry.js +359 -0
  201. package/dist/plugins/resolve-package.d.ts +47 -0
  202. package/dist/plugins/resolve-package.d.ts.map +1 -0
  203. package/dist/plugins/resolve-package.js +262 -0
  204. package/dist/plugins/source-analysis-service.d.ts +44 -0
  205. package/dist/plugins/source-analysis-service.d.ts.map +1 -0
  206. package/dist/plugins/source-analysis-service.js +232 -0
  207. package/dist/prolog/codec.d.ts.map +1 -1
  208. package/dist/prolog/codec.js +2 -0
  209. package/dist/prolog/janitor.d.ts.map +1 -1
  210. package/dist/prolog/janitor.js +1 -1
  211. package/dist/prolog/store-lock.d.ts +1 -1
  212. package/dist/prolog/store-lock.d.ts.map +1 -1
  213. package/dist/prolog.d.ts +36 -0
  214. package/dist/prolog.d.ts.map +1 -1
  215. package/dist/prolog.js +78 -9
  216. package/dist/proof/inspect.js +1 -1
  217. package/dist/proof/producers/playwright-case-id.js +2 -2
  218. package/dist/proof/producers/playwright-reporter.js +4 -4
  219. package/dist/public/diagnostic-usage.d.ts.map +1 -1
  220. package/dist/public/diagnostic-usage.js +7 -25
  221. package/dist/public/extractors/symbols-coordinator.d.ts +1 -1
  222. package/dist/public/extractors/symbols-coordinator.d.ts.map +1 -1
  223. package/dist/public/extractors/symbols-coordinator.js +1 -1
  224. package/dist/public/impact/analyzer.d.ts +1 -1
  225. package/dist/public/impact/analyzer.d.ts.map +1 -1
  226. package/dist/public/impact/analyzer.js +6 -4
  227. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  228. package/dist/public/impact/full-kb-quality.js +4 -12
  229. package/dist/public/operations/catalog.d.ts +39 -7
  230. package/dist/public/operations/catalog.d.ts.map +1 -1
  231. package/dist/public/operations/check-executor.d.ts.map +1 -1
  232. package/dist/public/operations/check-executor.js +11 -3
  233. package/dist/public/operations/check-helpers.d.ts +7 -1
  234. package/dist/public/operations/check-helpers.d.ts.map +1 -1
  235. package/dist/public/operations/check-helpers.js +22 -2
  236. package/dist/public/operations/contracts.d.ts.map +1 -1
  237. package/dist/public/operations/contracts.js +51 -12
  238. package/dist/public/operations/discovery-entities.d.ts +53 -1
  239. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  240. package/dist/public/operations/discovery-entities.js +219 -12
  241. package/dist/public/operations/discovery-executors.d.ts +1 -0
  242. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  243. package/dist/public/operations/discovery-executors.js +93 -59
  244. package/dist/public/operations/migration-plan.d.ts +2 -0
  245. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  246. package/dist/public/operations/migration-plan.js +50 -0
  247. package/dist/public/operations/predicate-schema-conformance.d.ts +41 -0
  248. package/dist/public/operations/predicate-schema-conformance.d.ts.map +1 -0
  249. package/dist/public/operations/predicate-schema-conformance.js +242 -0
  250. package/dist/public/operations/prolog-json.d.ts +1 -1
  251. package/dist/public/operations/prolog-json.d.ts.map +1 -1
  252. package/dist/public/operations/prolog-json.js +16 -10
  253. package/dist/public/operations/result-envelope.d.ts +34 -1
  254. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  255. package/dist/public/operations/result-envelope.js +78 -2
  256. package/dist/public/operations/runtime-types.d.ts +17 -2
  257. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  258. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  259. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  260. package/dist/public/operations/specs/check-rules.generated.js +9 -1
  261. package/dist/public/operations/specs/check.d.ts +1 -1
  262. package/dist/public/operations/specs/discovery.d.ts +10 -1
  263. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  264. package/dist/public/operations/specs/discovery.js +10 -1
  265. package/dist/public/operations/specs/mutation-schemas.d.ts +27 -4
  266. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  267. package/dist/public/operations/specs/mutation-schemas.js +21 -3
  268. package/dist/public/operations/specs/proof.js +1 -1
  269. package/dist/public/operations/specs/reporting.d.ts +9 -0
  270. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  271. package/dist/public/operations/specs/reporting.js +48 -17
  272. package/dist/public/operations/specs/semantic.d.ts +1 -1
  273. package/dist/public/operations/specs/semantic.d.ts.map +1 -1
  274. package/dist/public/operations/specs/semantic.js +54 -4
  275. package/dist/public/operations/specs/upsert.d.ts +28 -5
  276. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  277. package/dist/public/operations/specs/upsert.js +1 -1
  278. package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
  279. package/dist/public/operations/symbol-repair-plan.js +11 -4
  280. package/dist/public/operations/types.d.ts +5 -0
  281. package/dist/public/operations/types.d.ts.map +1 -1
  282. package/dist/public/proof-protocol.js +4 -4
  283. package/dist/public/schemas/entity.d.ts.map +1 -1
  284. package/dist/public/schemas/entity.js +22 -0
  285. package/dist/public/schemas/relationship.d.ts.map +1 -1
  286. package/dist/public/schemas/relationship.js +1 -0
  287. package/dist/public/skills/kibi-usage/SKILL.md +10 -3
  288. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
  289. package/dist/public/skills/kibi-usage/resources/proof.md +45 -0
  290. package/dist/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
  291. package/dist/public/skills/kibi-usage/resources/source-authoring.md +36 -0
  292. package/dist/public/skills/kibi-usage/resources/workflows.md +52 -1
  293. package/dist/public/symbol-granularity.d.ts +1 -1
  294. package/dist/public/symbol-granularity.d.ts.map +1 -1
  295. package/dist/public/symbol-granularity.generated.d.ts.map +1 -1
  296. package/dist/public/symbol-granularity.generated.js +38 -5
  297. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  298. package/dist/public/telemetry-acceptance.js +21 -5
  299. package/dist/relationships/shards.d.ts +6 -0
  300. package/dist/relationships/shards.d.ts.map +1 -1
  301. package/dist/relationships/shards.js +26 -19
  302. package/dist/report/html-report.css +1239 -281
  303. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  304. package/dist/runtime/cli-runtime.js +18 -0
  305. package/dist/schemas/entity.schema.json +32 -0
  306. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  307. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  308. package/dist/traceability/staged-entity-id-style.d.ts +12 -0
  309. package/dist/traceability/staged-entity-id-style.d.ts.map +1 -0
  310. package/dist/traceability/staged-entity-id-style.js +68 -0
  311. package/dist/traceability/symbol-extract.d.ts +24 -7
  312. package/dist/traceability/symbol-extract.d.ts.map +1 -1
  313. package/dist/traceability/symbol-extract.js +64 -208
  314. package/dist/traceability/temp-kb.d.ts.map +1 -1
  315. package/dist/traceability/temp-kb.js +8 -0
  316. package/dist/traceability/validate.js +1 -1
  317. package/dist/types/entities.d.ts +2 -0
  318. package/dist/types/entities.d.ts.map +1 -1
  319. package/dist/types/relationships.d.ts +1 -1
  320. package/dist/types/relationships.d.ts.map +1 -1
  321. package/dist/utils/entity-id-style.d.ts +27 -0
  322. package/dist/utils/entity-id-style.d.ts.map +1 -0
  323. package/dist/utils/entity-id-style.js +81 -0
  324. package/dist/utils/git-repository-context.d.ts +50 -0
  325. package/dist/utils/git-repository-context.d.ts.map +1 -0
  326. package/dist/utils/git-repository-context.js +259 -0
  327. package/dist/utils/rule-registry.d.ts +5 -0
  328. package/dist/utils/rule-registry.d.ts.map +1 -1
  329. package/dist/utils/rule-registry.generated.d.ts +42 -0
  330. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  331. package/dist/utils/rule-registry.generated.js +50 -0
  332. package/dist/utils/strict-modeling.d.ts +7 -0
  333. package/dist/utils/strict-modeling.d.ts.map +1 -1
  334. package/dist/utils/strict-modeling.js +11 -0
  335. package/package.json +14 -11
  336. package/schema/entities.pl +60 -1
  337. package/schema/relationships.pl +17 -4
  338. package/schema/validation.pl +118 -20
  339. package/src/public/diagnostic-usage.ts +16 -24
  340. package/src/public/extractors/symbols-coordinator.ts +1 -0
  341. package/src/public/impact/analyzer.ts +15 -12
  342. package/src/public/impact/full-kb-quality.ts +4 -16
  343. package/src/public/operations/check-executor.ts +13 -2
  344. package/src/public/operations/check-helpers.ts +29 -3
  345. package/src/public/operations/contracts.ts +59 -12
  346. package/src/public/operations/discovery-entities.ts +327 -12
  347. package/src/public/operations/discovery-executors.ts +110 -61
  348. package/src/public/operations/migration-plan.ts +57 -0
  349. package/src/public/operations/predicate-schema-conformance.ts +362 -0
  350. package/src/public/operations/prolog-json.ts +22 -8
  351. package/src/public/operations/result-envelope.ts +114 -2
  352. package/src/public/operations/runtime-types.ts +22 -3
  353. package/src/public/operations/specs/check-rules.generated.ts +9 -1
  354. package/src/public/operations/specs/discovery.ts +11 -1
  355. package/src/public/operations/specs/mutation-schemas.ts +23 -3
  356. package/src/public/operations/specs/proof.ts +1 -1
  357. package/src/public/operations/specs/reporting.ts +71 -24
  358. package/src/public/operations/specs/semantic.ts +79 -17
  359. package/src/public/operations/specs/upsert.ts +1 -1
  360. package/src/public/operations/symbol-repair-plan.ts +16 -7
  361. package/src/public/operations/types.ts +5 -0
  362. package/src/public/proof-fingerprint.ts +1 -1
  363. package/src/public/proof-protocol-types.d.ts +1 -1
  364. package/src/public/proof-protocol.ts +4 -4
  365. package/src/public/schemas/entity.ts +22 -0
  366. package/src/public/schemas/relationship.ts +1 -0
  367. package/src/public/skills/kibi-usage/SKILL.md +10 -3
  368. package/src/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
  369. package/src/public/skills/kibi-usage/resources/proof.md +45 -0
  370. package/src/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
  371. package/src/public/skills/kibi-usage/resources/source-authoring.md +36 -0
  372. package/src/public/skills/kibi-usage/resources/workflows.md +52 -1
  373. package/src/public/symbol-granularity.generated.ts +45 -12
  374. package/src/public/symbol-granularity.ts +3 -3
  375. package/src/public/telemetry-acceptance.ts +37 -6
  376. package/src/schemas/entity.schema.json +32 -0
  377. package/src/schemas/relationship.schema.json +1 -0
@@ -0,0 +1,257 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { validateOntologyMatchCandidate, validatePredicateSchema, } from "kibi-plugin-sdk";
19
+ import { PluginResolutionError } from "./resolve-package.js";
20
+ function candidateKey(candidate, claimKey) {
21
+ return [
22
+ claimKey ?? "",
23
+ candidate.schemaId,
24
+ candidate.polarity,
25
+ ...candidate.arguments,
26
+ ].join("\0");
27
+ }
28
+ function packOwnedSchemas(binding) {
29
+ const schemas = binding.capability
30
+ .schemas()
31
+ .map((schema) => validatePredicateSchema(schema));
32
+ const owned = new Set(schemas.map((schema) => schema.schemaId));
33
+ return { schemas, owned };
34
+ }
35
+ function tryPackOwnedSchemas(binding, diagnostics) {
36
+ try {
37
+ return packOwnedSchemas(binding);
38
+ }
39
+ catch (error) {
40
+ const message = error instanceof Error ? error.message : String(error);
41
+ diagnostics.push(`ontology pack '${binding.capability.id}' schemas() failed: ${message}`);
42
+ return null;
43
+ }
44
+ }
45
+ /**
46
+ * Collect active ontology schemas with replace / augment / shadow semantics.
47
+ * Schema id collisions across packs are rejected. Shadow packs do not alter
48
+ * the canonical catalog.
49
+ *
50
+ * Replace semantics:
51
+ * - A successful replace pack *replaces* the builtin provider catalog.
52
+ * - Provider exception / invalid catalog construction falls back to builtin.
53
+ * - Shadow packs are never merged into the canonical catalog.
54
+ */
55
+ // implements REQ-capability-plugin-activation-disclosure-v1
56
+ export function composeOntologyCatalog(resolution) {
57
+ const stamps = [];
58
+ const ownership = new Map();
59
+ const schemasById = new Map();
60
+ const diagnostics = [];
61
+ let replaced = false;
62
+ const addPack = (binding) => {
63
+ const { schemas, owned } = packOwnedSchemas(binding);
64
+ for (const schema of schemas) {
65
+ const existing = schemasById.get(schema.schemaId);
66
+ if (existing && existing.predicateName !== schema.predicateName) {
67
+ throw new PluginResolutionError("ONTOLOGY_SCHEMA_COLLISION", `Ontology schema id '${schema.schemaId}' collides across packs`);
68
+ }
69
+ if (!existing) {
70
+ schemasById.set(schema.schemaId, schema);
71
+ }
72
+ owned.add(schema.schemaId);
73
+ }
74
+ ownership.set(binding.capability.id, owned);
75
+ stamps.push(binding.stamp);
76
+ };
77
+ if (resolution.replace) {
78
+ try {
79
+ addPack(resolution.replace);
80
+ replaced = true;
81
+ }
82
+ catch (error) {
83
+ const message = error instanceof Error ? error.message : String(error);
84
+ diagnostics.push(`replace ontology pack '${resolution.replace.pluginId}' failed catalog construction (${message}); falling back to builtin`);
85
+ addPack(resolution.builtin);
86
+ }
87
+ }
88
+ else {
89
+ addPack(resolution.builtin);
90
+ for (const augment of resolution.augment) {
91
+ addPack(augment);
92
+ }
93
+ }
94
+ for (const shadow of resolution.shadow) {
95
+ stamps.push(shadow.stamp);
96
+ }
97
+ return {
98
+ schemas: [...schemasById.values()],
99
+ stamps,
100
+ ownership,
101
+ replaced,
102
+ diagnostics,
103
+ };
104
+ }
105
+ function runPackMatches(binding, context, ownedSchemaIds, packSchemas, target, seen, diagnostics) {
106
+ let raw;
107
+ try {
108
+ raw = binding.capability.match(context);
109
+ }
110
+ catch (error) {
111
+ const message = error instanceof Error ? error.message : String(error);
112
+ diagnostics.push(`ontology pack '${binding.capability.id}' match() threw: ${message}`);
113
+ return "failed";
114
+ }
115
+ if (!Array.isArray(raw)) {
116
+ diagnostics.push(`ontology pack '${binding.capability.id}' match() returned a non-array; treating as provider failure`);
117
+ return "failed";
118
+ }
119
+ let accepted = 0;
120
+ for (const entry of raw) {
121
+ try {
122
+ if (entry &&
123
+ typeof entry === "object" &&
124
+ "schemaId" in entry &&
125
+ typeof entry.schemaId === "string" &&
126
+ !ownedSchemaIds.has(entry.schemaId)) {
127
+ diagnostics.push(`ontology pack '${binding.capability.id}' returned schema '${entry.schemaId}' it does not own; rejected`);
128
+ continue;
129
+ }
130
+ const candidate = validateOntologyMatchCandidate(entry, packSchemas);
131
+ if (!ownedSchemaIds.has(candidate.schemaId)) {
132
+ diagnostics.push(`ontology pack '${binding.capability.id}' returned schema '${candidate.schemaId}' it does not own; rejected`);
133
+ continue;
134
+ }
135
+ const key = candidateKey(candidate, context.claimKey);
136
+ if (seen.has(key))
137
+ continue;
138
+ seen.add(key);
139
+ target.push({
140
+ ...candidate,
141
+ claimKey: context.claimKey,
142
+ packId: binding.capability.id,
143
+ stamp: binding.stamp,
144
+ });
145
+ accepted += 1;
146
+ }
147
+ catch (error) {
148
+ const message = error instanceof Error ? error.message : String(error);
149
+ diagnostics.push(`ontology pack '${binding.capability.id}' produced an invalid candidate: ${message}`);
150
+ }
151
+ }
152
+ if (raw.length === 0) {
153
+ diagnostics.push(`ontology pack '${binding.capability.id}' abstained (valid empty match)`);
154
+ return "abstained";
155
+ }
156
+ if (accepted === 0 && raw.length > 0) {
157
+ // Every candidate was invalid → treat as provider failure for replace fallback.
158
+ diagnostics.push(`ontology pack '${binding.capability.id}' returned only invalid candidates`);
159
+ return "failed";
160
+ }
161
+ return "ok";
162
+ }
163
+ /**
164
+ * Match ontology candidates across the active catalog.
165
+ *
166
+ * Replace abstention (`[]`) is *not* failure: it means the replacement pack
167
+ * found no match and builtin must not run. Builtin fallback happens only on
168
+ * provider exception / malformed output / invalid catalog construction.
169
+ *
170
+ * Shadow packs validate against their own schemas and use a separate dedupe
171
+ * set so a canonical candidate never suppresses the corresponding shadow
172
+ * comparison.
173
+ */
174
+ // implements REQ-capability-plugin-activation-disclosure-v1
175
+ export function composeOntologyMatches(resolution, context) {
176
+ const catalog = composeOntologyCatalog(resolution);
177
+ const diagnostics = [...catalog.diagnostics];
178
+ const canonical = [];
179
+ const shadow = [];
180
+ const canonicalSeen = new Set();
181
+ const shadowSeen = new Set();
182
+ const ownedFor = (binding) => {
183
+ // Prefer the already-validated catalog schemas so we never re-invoke
184
+ // schemas() for packs that survived catalog construction (and so a
185
+ // replace pack that already failed catalog cannot crash matching).
186
+ const fromCatalog = catalog.ownership.get(binding.capability.id);
187
+ if (fromCatalog) {
188
+ const schemas = catalog.schemas.filter((schema) => fromCatalog.has(schema.schemaId));
189
+ return { owned: fromCatalog, schemas };
190
+ }
191
+ // Shadow packs (and replace packs that failed catalog construction) are
192
+ // not in the canonical catalog; load their schemas with containment.
193
+ return tryPackOwnedSchemas(binding, diagnostics);
194
+ };
195
+ if (resolution.replace) {
196
+ const replaceOwned = ownedFor(resolution.replace);
197
+ if (!replaceOwned) {
198
+ diagnostics.push(`replace ontology pack '${resolution.replace.pluginId}' schemas unavailable for match; falling back to builtin`);
199
+ const builtin = ownedFor(resolution.builtin);
200
+ if (builtin) {
201
+ runPackMatches(resolution.builtin, context, builtin.owned, builtin.schemas, canonical, canonicalSeen, diagnostics);
202
+ }
203
+ }
204
+ else {
205
+ const outcome = runPackMatches(resolution.replace, context, replaceOwned.owned, replaceOwned.schemas, canonical, canonicalSeen, diagnostics);
206
+ if (outcome === "failed") {
207
+ diagnostics.push(`replace ontology pack '${resolution.replace.pluginId}' match failed; falling back to builtin`);
208
+ const builtin = ownedFor(resolution.builtin);
209
+ if (builtin) {
210
+ runPackMatches(resolution.builtin, context, builtin.owned, builtin.schemas, canonical, canonicalSeen, diagnostics);
211
+ }
212
+ }
213
+ else if (outcome === "abstained") {
214
+ diagnostics.push(`replace ontology pack '${resolution.replace.pluginId}' abstained; builtin match not consulted`);
215
+ }
216
+ }
217
+ }
218
+ else {
219
+ const builtin = ownedFor(resolution.builtin);
220
+ if (builtin) {
221
+ runPackMatches(resolution.builtin, context, builtin.owned, builtin.schemas, canonical, canonicalSeen, diagnostics);
222
+ }
223
+ for (const augment of resolution.augment) {
224
+ const pack = ownedFor(augment);
225
+ if (!pack)
226
+ continue;
227
+ runPackMatches(augment, context, pack.owned, pack.schemas, canonical, canonicalSeen, diagnostics);
228
+ }
229
+ }
230
+ for (const shadowBinding of resolution.shadow) {
231
+ const pack = ownedFor(shadowBinding);
232
+ if (!pack) {
233
+ // Shadow must never fail the host operation; skip this pack.
234
+ continue;
235
+ }
236
+ runPackMatches(shadowBinding, context, pack.owned, pack.schemas, shadow, shadowSeen, diagnostics);
237
+ }
238
+ canonical.sort((a, b) => {
239
+ const pack = a.packId.localeCompare(b.packId);
240
+ if (pack !== 0)
241
+ return pack;
242
+ const schema = a.schemaId.localeCompare(b.schemaId);
243
+ if (schema !== 0)
244
+ return schema;
245
+ const polarity = a.polarity.localeCompare(b.polarity);
246
+ if (polarity !== 0)
247
+ return polarity;
248
+ return a.arguments.join("\0").localeCompare(b.arguments.join("\0"));
249
+ });
250
+ return {
251
+ canonical,
252
+ shadow,
253
+ stamps: catalog.stamps,
254
+ replaced: catalog.replaced,
255
+ diagnostics,
256
+ };
257
+ }
@@ -0,0 +1,47 @@
1
+ import { type PluginMode, type PluginProviderStamp, type SemanticClassificationDecision, type SemanticClassifierInput, type SemanticClassifierV1 } from "kibi-plugin-sdk";
2
+ import type { CapabilityModeResolution, CapabilityProviderBinding } from "./registry.js";
3
+ export type SemanticClassifierDiagnostic = Readonly<{
4
+ pluginId: string;
5
+ packageName: string | null;
6
+ mode: PluginMode | "builtin";
7
+ code: string;
8
+ message: string;
9
+ model?: string;
10
+ }>;
11
+ export type ComposedSemanticClassifierResult = Readonly<{
12
+ decisions: readonly SemanticClassificationDecision[];
13
+ stamps: readonly PluginProviderStamp[];
14
+ shadowComparisons: readonly {
15
+ readonly stamp: PluginProviderStamp;
16
+ readonly decisions: readonly SemanticClassificationDecision[];
17
+ }[];
18
+ fallbackUsed: boolean;
19
+ diagnostics: readonly SemanticClassifierDiagnostic[];
20
+ }>;
21
+ /** Bounded provenance copied onto advisor and compile-intent results. */
22
+ export declare function publicCapabilityStamp(stamp: PluginProviderStamp): {
23
+ pluginId: string;
24
+ pluginVersion: string;
25
+ capability: string;
26
+ mode: string;
27
+ external: boolean;
28
+ network: boolean;
29
+ metered: boolean;
30
+ fallbackUsed?: boolean;
31
+ model?: string;
32
+ };
33
+ export declare function withFallback(stamp: PluginProviderStamp, fallbackUsed: boolean): PluginProviderStamp;
34
+ /** Bound and redact provider error text before it reaches diagnostics. */
35
+ export declare function redactClassifierMessage(message: string): string;
36
+ /** Typed, redacted diagnostic for a failed provider call of any capability. */
37
+ export declare function diagnosticFromError(binding: CapabilityProviderBinding<unknown>, error: unknown): SemanticClassifierDiagnostic;
38
+ /**
39
+ * Compose semantic classifiers according to replace / augment / shadow modes.
40
+ *
41
+ * External providers are skipped unless `operationName` is on the allowlist
42
+ * (`kb_semantic_advisor`, `kb_compile_intent`).
43
+ */
44
+ export declare function composeSemanticClassification(resolution: CapabilityModeResolution<SemanticClassifierV1>, input: SemanticClassifierInput, options: Readonly<{
45
+ operationName: string;
46
+ }>): Promise<ComposedSemanticClassifierResult>;
47
+ //# sourceMappingURL=compose-semantic-classifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose-semantic-classifier.d.ts","sourceRoot":"","sources":["../../src/plugins/compose-semantic-classifier.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,mBAAmB,EAExB,KAAK,8BAA8B,EACnC,KAAK,uBAAuB,EAE5B,KAAK,oBAAoB,EAE1B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAGH,MAAM,MAAM,gCAAgC,GAAG,QAAQ,CAAC;IACtD,SAAS,EAAE,SAAS,8BAA8B,EAAE,CAAC;IACrD,MAAM,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACvC,iBAAiB,EAAE,SAAS;QAC1B,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;QACpC,QAAQ,CAAC,SAAS,EAAE,SAAS,8BAA8B,EAAE,CAAC;KAC/D,EAAE,CAAC;IACJ,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,SAAS,4BAA4B,EAAE,CAAC;CACtD,CAAC,CAAC;AAMH,yEAAyE;AAEzE,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,mBAAmB,GAAG;IACjE,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAYA;AAGD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,mBAAmB,EAC1B,YAAY,EAAE,OAAO,GACpB,mBAAmB,CAErB;AAWD,0EAA0E;AAE1E,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK/D;AAED,+EAA+E;AAE/E,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,EAC3C,KAAK,EAAE,OAAO,GACb,4BAA4B,CAgC9B;AA6CD;;;;;GAKG;AAEH,wBAAsB,6BAA6B,CACjD,UAAU,EAAE,wBAAwB,CAAC,oBAAoB,CAAC,EAC1D,KAAK,EAAE,uBAAuB,EAC9B,OAAO,EAAE,QAAQ,CAAC;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,GAC3C,OAAO,CAAC,gCAAgC,CAAC,CA0G3C"}
@@ -0,0 +1,216 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { PluginValidationError, validateSemanticClassifierResult, } from "kibi-plugin-sdk";
19
+ import { allowsExternalSemanticClassifier } from "./external-allowlist.js";
20
+ /** Bounded provenance copied onto advisor and compile-intent results. */
21
+ // implements REQ-capability-plugin-activation-disclosure-v1, REQ-capability-plugin-observable-behavior-v1
22
+ export function publicCapabilityStamp(stamp) {
23
+ return {
24
+ pluginId: stamp.pluginId,
25
+ pluginVersion: stamp.pluginVersion,
26
+ capability: stamp.capability,
27
+ mode: stamp.mode,
28
+ external: stamp.external,
29
+ network: stamp.network,
30
+ metered: stamp.metered,
31
+ ...(stamp.fallbackUsed === true ? { fallbackUsed: true } : {}),
32
+ ...(stamp.model !== undefined ? { model: stamp.model } : {}),
33
+ };
34
+ }
35
+ // implements REQ-capability-plugin-activation-disclosure-v1
36
+ export function withFallback(stamp, fallbackUsed) {
37
+ return fallbackUsed ? { ...stamp, fallbackUsed: true } : stamp;
38
+ }
39
+ function isUnresolved(decision) {
40
+ if (!decision)
41
+ return true;
42
+ if (decision.lane === "none")
43
+ return true;
44
+ if (decision.ambiguity?.ambiguous === true)
45
+ return true;
46
+ return false;
47
+ }
48
+ /** Bound and redact provider error text before it reaches diagnostics. */
49
+ // implements REQ-capability-plugin-activation-disclosure-v1
50
+ export function redactClassifierMessage(message) {
51
+ return message
52
+ .replace(/sk-[A-Za-z0-9_-]+/g, "[redacted]")
53
+ .replace(/(api[_-]?key\s*[:=]\s*)\S+/gi, "$1[redacted]")
54
+ .slice(0, 300);
55
+ }
56
+ /** Typed, redacted diagnostic for a failed provider call of any capability. */
57
+ // implements REQ-capability-plugin-activation-disclosure-v1
58
+ export function diagnosticFromError(binding, error) {
59
+ const message = redactClassifierMessage(error instanceof Error ? error.message : String(error));
60
+ let code = "unknown";
61
+ let model;
62
+ if (error instanceof PluginValidationError) {
63
+ code = error.code;
64
+ }
65
+ else if (typeof error === "object" &&
66
+ error !== null &&
67
+ "code" in error &&
68
+ typeof error.code === "string") {
69
+ code = error.code;
70
+ }
71
+ if (typeof error === "object" &&
72
+ error !== null &&
73
+ "model" in error &&
74
+ typeof error.model === "string") {
75
+ model = error.model;
76
+ }
77
+ return {
78
+ pluginId: binding.pluginId,
79
+ packageName: binding.packageName,
80
+ mode: binding.mode,
81
+ code,
82
+ message,
83
+ ...(model !== undefined ? { model } : {}),
84
+ };
85
+ }
86
+ async function runClassifier(binding, input) {
87
+ try {
88
+ const raw = await binding.capability.classify(input);
89
+ return {
90
+ ok: true,
91
+ result: validateSemanticClassifierResult(raw, {
92
+ expectedClaimKeys: input.propositions.map((proposition) => proposition.claimKey),
93
+ }),
94
+ };
95
+ }
96
+ catch (error) {
97
+ return { ok: false, diagnostic: diagnosticFromError(binding, error) };
98
+ }
99
+ }
100
+ function fillMissingDecisions(input, decisions, builtin) {
101
+ const byKey = new Map(decisions.map((decision) => [decision.claimKey, decision]));
102
+ const builtinByKey = new Map((builtin?.decisions ?? []).map((decision) => [decision.claimKey, decision]));
103
+ return input.propositions.map((proposition) => {
104
+ const existing = byKey.get(proposition.claimKey);
105
+ if (existing)
106
+ return existing;
107
+ const fallback = builtinByKey.get(proposition.claimKey);
108
+ if (fallback)
109
+ return fallback;
110
+ return {
111
+ claimKey: proposition.claimKey,
112
+ lane: "none",
113
+ confidence: 0,
114
+ };
115
+ });
116
+ }
117
+ /**
118
+ * Compose semantic classifiers according to replace / augment / shadow modes.
119
+ *
120
+ * External providers are skipped unless `operationName` is on the allowlist
121
+ * (`kb_semantic_advisor`, `kb_compile_intent`).
122
+ */
123
+ // implements REQ-capability-plugin-activation-disclosure-v1, REQ-capability-plugin-observable-behavior-v1
124
+ export async function composeSemanticClassification(resolution, input, options) {
125
+ const allowExternal = allowsExternalSemanticClassifier(options.operationName);
126
+ const stamps = [];
127
+ const diagnostics = [];
128
+ const shadowComparisons = [];
129
+ let fallbackUsed = false;
130
+ let decisions = [];
131
+ if (allowExternal && resolution.replace) {
132
+ const replaced = await runClassifier(resolution.replace, input);
133
+ if (replaced.ok) {
134
+ // Replace success: missing decisions get conservative `none`, not builtin
135
+ // fill. Valid empty decisions[] is abstention (same as ontology replace).
136
+ decisions = fillMissingDecisions(input, replaced.result.decisions, null);
137
+ stamps.push(resolution.replace.stamp);
138
+ }
139
+ else {
140
+ diagnostics.push(replaced.diagnostic);
141
+ const builtinResult = await runClassifier(resolution.builtin, input);
142
+ if (builtinResult.ok) {
143
+ decisions = [...builtinResult.result.decisions];
144
+ stamps.push(withFallback(resolution.builtin.stamp, true));
145
+ }
146
+ else {
147
+ diagnostics.push(builtinResult.diagnostic);
148
+ decisions = [];
149
+ }
150
+ fallbackUsed = true;
151
+ }
152
+ }
153
+ else {
154
+ const builtinResult = await runClassifier(resolution.builtin, input);
155
+ if (builtinResult.ok) {
156
+ decisions = [...builtinResult.result.decisions];
157
+ stamps.push(resolution.builtin.stamp);
158
+ }
159
+ else {
160
+ diagnostics.push(builtinResult.diagnostic);
161
+ decisions = [];
162
+ }
163
+ if (allowExternal) {
164
+ for (const augment of resolution.augment) {
165
+ const unresolvedKeys = new Set(input.propositions
166
+ .filter((proposition) => {
167
+ const current = decisions.find((decision) => decision.claimKey === proposition.claimKey);
168
+ return isUnresolved(current);
169
+ })
170
+ .map((proposition) => proposition.claimKey));
171
+ if (unresolvedKeys.size === 0)
172
+ break;
173
+ const subset = {
174
+ propositions: input.propositions.filter((proposition) => unresolvedKeys.has(proposition.claimKey)),
175
+ };
176
+ const augmentResult = await runClassifier(augment, subset);
177
+ if (!augmentResult.ok) {
178
+ diagnostics.push(augmentResult.diagnostic);
179
+ continue;
180
+ }
181
+ stamps.push(augment.stamp);
182
+ const byKey = new Map(decisions.map((decision) => [decision.claimKey, decision]));
183
+ for (const decision of augmentResult.result.decisions) {
184
+ if (!unresolvedKeys.has(decision.claimKey))
185
+ continue;
186
+ if (decision.lane === "none")
187
+ continue;
188
+ byKey.set(decision.claimKey, decision);
189
+ }
190
+ decisions = fillMissingDecisions(input, [...byKey.values()], builtinResult.ok ? builtinResult.result : null);
191
+ }
192
+ }
193
+ }
194
+ decisions = fillMissingDecisions(input, decisions, null);
195
+ if (allowExternal) {
196
+ for (const shadow of resolution.shadow) {
197
+ const shadowResult = await runClassifier(shadow, input);
198
+ if (!shadowResult.ok) {
199
+ diagnostics.push(shadowResult.diagnostic);
200
+ continue;
201
+ }
202
+ stamps.push(shadow.stamp);
203
+ shadowComparisons.push({
204
+ stamp: shadow.stamp,
205
+ decisions: shadowResult.result.decisions,
206
+ });
207
+ }
208
+ }
209
+ return {
210
+ decisions,
211
+ stamps,
212
+ shadowComparisons,
213
+ fallbackUsed,
214
+ diagnostics,
215
+ };
216
+ }
@@ -0,0 +1,23 @@
1
+ import { type ClaimComparisonJudgment, type CompareClaimsInput, type PluginProviderStamp, type RankSubjectsInput, type SubjectRankingDecision, type VocabularyAlignmentV1 } from "kibi-plugin-sdk";
2
+ import { type SemanticClassifierDiagnostic } from "./compose-semantic-classifier.js";
3
+ import type { CapabilityModeResolution } from "./registry.js";
4
+ export type VocabularyAlignmentDiagnostic = SemanticClassifierDiagnostic;
5
+ export type ComposedVocabularyResult<T> = Readonly<{
6
+ results: readonly T[];
7
+ stamps: readonly PluginProviderStamp[];
8
+ shadowComparisons: readonly {
9
+ readonly stamp: PluginProviderStamp;
10
+ readonly results: readonly T[];
11
+ }[];
12
+ fallbackUsed: boolean;
13
+ diagnostics: readonly VocabularyAlignmentDiagnostic[];
14
+ }>;
15
+ /** Choose an existing subject (or new_subject) for each clause. */
16
+ export declare function composeSubjectRanking(resolution: CapabilityModeResolution<VocabularyAlignmentV1>, input: RankSubjectsInput, options: Readonly<{
17
+ operationName: string;
18
+ }>): Promise<ComposedVocabularyResult<SubjectRankingDecision>>;
19
+ /** Judge claim pairs; true judgments are review candidates, never verdicts. */
20
+ export declare function composeClaimComparison(resolution: CapabilityModeResolution<VocabularyAlignmentV1>, input: CompareClaimsInput, options: Readonly<{
21
+ operationName: string;
22
+ }>): Promise<ComposedVocabularyResult<ClaimComparisonJudgment>>;
23
+ //# sourceMappingURL=compose-vocabulary-alignment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose-vocabulary-alignment.d.ts","sourceRoot":"","sources":["../../src/plugins/compose-vocabulary-alignment.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EAEvB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAG3B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,KAAK,4BAA4B,EAGlC,MAAM,kCAAkC,CAAC;AAE1C,OAAO,KAAK,EACV,wBAAwB,EAEzB,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,6BAA6B,GAAG,4BAA4B,CAAC;AAGzE,MAAM,MAAM,wBAAwB,CAAC,CAAC,IAAI,QAAQ,CAAC;IACjD,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;IACtB,MAAM,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACvC,iBAAiB,EAAE,SAAS;QAC1B,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;QACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;KAChC,EAAE,CAAC;IACJ,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,SAAS,6BAA6B,EAAE,CAAC;CACvD,CAAC,CAAC;AA0KH,mEAAmE;AAEnE,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,wBAAwB,CAAC,qBAAqB,CAAC,EAC3D,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,QAAQ,CAAC;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,GAC3C,OAAO,CAAC,wBAAwB,CAAC,sBAAsB,CAAC,CAAC,CAE3D;AAED,+EAA+E;AAE/E,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,wBAAwB,CAAC,qBAAqB,CAAC,EAC3D,KAAK,EAAE,kBAAkB,EACzB,OAAO,EAAE,QAAQ,CAAC;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,GAC3C,OAAO,CAAC,wBAAwB,CAAC,uBAAuB,CAAC,CAAC,CAE5D"}