kibi-cli 2.3.0 → 2.5.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 (380) hide show
  1. package/dist/cli-json-command.d.ts +6 -0
  2. package/dist/cli-json-command.d.ts.map +1 -1
  3. package/dist/cli-json-command.js +39 -11
  4. package/dist/cli-operation-loader.d.ts.map +1 -1
  5. package/dist/cli-operation-loader.js +7 -0
  6. package/dist/cli-operation-metadata.d.ts +13 -5
  7. package/dist/cli-operation-metadata.d.ts.map +1 -1
  8. package/dist/cli-operation-metadata.js +15 -5
  9. package/dist/cli-protocol.d.ts +14 -0
  10. package/dist/cli-protocol.d.ts.map +1 -1
  11. package/dist/cli-protocol.js +31 -2
  12. package/dist/cli-register-maintenance.d.ts.map +1 -1
  13. package/dist/cli-register-maintenance.js +7 -0
  14. package/dist/cli-register-proof.d.ts.map +1 -1
  15. package/dist/cli-register-proof.js +13 -0
  16. package/dist/commands/check.d.ts.map +1 -1
  17. package/dist/commands/check.js +11 -2
  18. package/dist/commands/discovery-shared.d.ts.map +1 -1
  19. package/dist/commands/discovery-shared.js +8 -2
  20. package/dist/commands/engine.d.ts.map +1 -1
  21. package/dist/commands/engine.js +4 -2
  22. package/dist/commands/gc.d.ts.map +1 -1
  23. package/dist/commands/gc.js +7 -0
  24. package/dist/commands/init-helpers.d.ts.map +1 -1
  25. package/dist/commands/init-helpers.js +0 -1
  26. package/dist/commands/merge-driver.d.ts +31 -0
  27. package/dist/commands/merge-driver.d.ts.map +1 -0
  28. package/dist/commands/merge-driver.js +268 -0
  29. package/dist/commands/migrate.d.ts.map +1 -1
  30. package/dist/commands/migrate.js +281 -14
  31. package/dist/commands/proof-compact.d.ts +9 -0
  32. package/dist/commands/proof-compact.d.ts.map +1 -0
  33. package/dist/commands/proof-compact.js +58 -0
  34. package/dist/commands/prove.d.ts +38 -0
  35. package/dist/commands/prove.d.ts.map +1 -1
  36. package/dist/commands/prove.js +222 -47
  37. package/dist/commands/sync/persistence.d.ts.map +1 -1
  38. package/dist/commands/sync/persistence.js +61 -16
  39. package/dist/commands/sync.d.ts +8 -0
  40. package/dist/commands/sync.d.ts.map +1 -1
  41. package/dist/commands/sync.js +42 -16
  42. package/dist/diagnostics.js +1 -1
  43. package/dist/engine-limits.d.ts +74 -0
  44. package/dist/engine-limits.d.ts.map +1 -0
  45. package/dist/engine-limits.js +201 -0
  46. package/dist/engine.d.ts +10 -0
  47. package/dist/engine.d.ts.map +1 -1
  48. package/dist/engine.js +57 -9
  49. package/dist/extractors/manifest.d.ts +8 -0
  50. package/dist/extractors/manifest.d.ts.map +1 -1
  51. package/dist/extractors/manifest.js +34 -5
  52. package/dist/extractors/markdown.d.ts +8 -0
  53. package/dist/extractors/markdown.d.ts.map +1 -1
  54. package/dist/extractors/markdown.js +57 -0
  55. package/dist/extractors/relationships.d.ts.map +1 -1
  56. package/dist/extractors/relationships.js +2 -0
  57. package/dist/intent-search.d.ts +4 -1
  58. package/dist/intent-search.d.ts.map +1 -1
  59. package/dist/intent-search.js +186 -33
  60. package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
  61. package/dist/operations/bootstrap/candidate-helpers.js +8 -1
  62. package/dist/operations/bootstrap/candidates.d.ts.map +1 -1
  63. package/dist/operations/bootstrap/candidates.js +55 -39
  64. package/dist/operations/bootstrap/discovery.js +1 -1
  65. package/dist/operations/bootstrap/generate.d.ts +2 -0
  66. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  67. package/dist/operations/bootstrap/generate.js +107 -37
  68. package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
  69. package/dist/operations/bootstrap/guidance-actions.js +3 -0
  70. package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
  71. package/dist/operations/bootstrap/guidance.js +7 -1
  72. package/dist/operations/bootstrap/intent-claims.d.ts +17 -0
  73. package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -0
  74. package/dist/operations/bootstrap/intent-claims.js +103 -0
  75. package/dist/operations/bootstrap/markdown-candidates.d.ts +2 -0
  76. package/dist/operations/bootstrap/markdown-candidates.d.ts.map +1 -1
  77. package/dist/operations/bootstrap/markdown-candidates.js +32 -10
  78. package/dist/operations/bootstrap/presentation.d.ts +2 -0
  79. package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
  80. package/dist/operations/bootstrap/presentation.js +66 -3
  81. package/dist/operations/bootstrap/requirement-claims.d.ts +1 -0
  82. package/dist/operations/bootstrap/requirement-claims.d.ts.map +1 -1
  83. package/dist/operations/bootstrap/requirement-claims.js +13 -1
  84. package/dist/operations/bootstrap/types.d.ts +28 -0
  85. package/dist/operations/bootstrap/types.d.ts.map +1 -1
  86. package/dist/operations/bootstrap/types.js +16 -0
  87. package/dist/operations/bootstrap/validation.d.ts +4 -0
  88. package/dist/operations/bootstrap/validation.d.ts.map +1 -0
  89. package/dist/operations/bootstrap/validation.js +20 -0
  90. package/dist/operations/migration/inventory-rederive.d.ts +81 -0
  91. package/dist/operations/migration/inventory-rederive.d.ts.map +1 -0
  92. package/dist/operations/migration/inventory-rederive.js +484 -0
  93. package/dist/operations/migration/kb-sources.d.ts +53 -0
  94. package/dist/operations/migration/kb-sources.d.ts.map +1 -0
  95. package/dist/operations/migration/kb-sources.js +233 -0
  96. package/dist/operations/migration/origin-backfill.d.ts +39 -0
  97. package/dist/operations/migration/origin-backfill.d.ts.map +1 -0
  98. package/dist/operations/migration/origin-backfill.js +164 -0
  99. package/dist/operations/migration/polarity-values.d.ts +10 -0
  100. package/dist/operations/migration/polarity-values.d.ts.map +1 -0
  101. package/dist/operations/migration/polarity-values.js +60 -0
  102. package/dist/operations/migration/schema6.d.ts +59 -0
  103. package/dist/operations/migration/schema6.d.ts.map +1 -0
  104. package/dist/operations/migration/schema6.js +379 -0
  105. package/dist/operations/migration/source-paths.d.ts +131 -0
  106. package/dist/operations/migration/source-paths.d.ts.map +1 -0
  107. package/dist/operations/migration/source-paths.js +308 -0
  108. package/dist/operations/migration/superseded-closure.d.ts +54 -0
  109. package/dist/operations/migration/superseded-closure.d.ts.map +1 -0
  110. package/dist/operations/migration/superseded-closure.js +187 -0
  111. package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
  112. package/dist/operations/modeling/logic-modeling.js +3 -5
  113. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  114. package/dist/operations/modeling/model-requirement.js +225 -67
  115. package/dist/operations/mutation/contradictions.d.ts +16 -0
  116. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  117. package/dist/operations/mutation/contradictions.js +32 -0
  118. package/dist/operations/mutation/delete.d.ts.map +1 -1
  119. package/dist/operations/mutation/delete.js +15 -7
  120. package/dist/operations/mutation/origin.d.ts +21 -0
  121. package/dist/operations/mutation/origin.d.ts.map +1 -0
  122. package/dist/operations/mutation/origin.js +78 -0
  123. package/dist/operations/mutation/plan-apply-journal.d.ts +182 -0
  124. package/dist/operations/mutation/plan-apply-journal.d.ts.map +1 -0
  125. package/dist/operations/mutation/plan-apply-journal.js +613 -0
  126. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +3 -1
  127. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -1
  128. package/dist/operations/mutation/predicate-vocabulary-guard.js +13 -2
  129. package/dist/operations/mutation/relationships.d.ts +5 -5
  130. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  131. package/dist/operations/mutation/relationships.js +31 -11
  132. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  133. package/dist/operations/mutation/serialization.js +3 -1
  134. package/dist/operations/mutation/source-authoring.d.ts +6 -0
  135. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  136. package/dist/operations/mutation/source-authoring.js +7 -1
  137. package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -1
  138. package/dist/operations/mutation/symbol-refresh.js +4 -1
  139. package/dist/operations/mutation/types.d.ts +14 -0
  140. package/dist/operations/mutation/types.d.ts.map +1 -1
  141. package/dist/operations/mutation/upsert.d.ts +30 -3
  142. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  143. package/dist/operations/mutation/upsert.js +105 -35
  144. package/dist/operations/mutation/validate-upsert.d.ts +6 -0
  145. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  146. package/dist/operations/mutation/validate-upsert.js +34 -30
  147. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  148. package/dist/operations/planning/apply-plan.js +751 -144
  149. package/dist/operations/planning/compile-intent.d.ts +34 -1
  150. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  151. package/dist/operations/planning/compile-intent.js +314 -98
  152. package/dist/operations/proof/code-scope.d.ts +28 -0
  153. package/dist/operations/proof/code-scope.d.ts.map +1 -1
  154. package/dist/operations/proof/code-scope.js +72 -0
  155. package/dist/operations/proof/compact-receipts.d.ts +49 -0
  156. package/dist/operations/proof/compact-receipts.d.ts.map +1 -0
  157. package/dist/operations/proof/compact-receipts.js +160 -0
  158. package/dist/operations/proof/ingest-proof.d.ts +2 -0
  159. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  160. package/dist/operations/proof/ingest-proof.js +44 -23
  161. package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
  162. package/dist/operations/proof/prune-receipts.js +5 -9
  163. package/dist/operations/proof/receipt-compaction.d.ts +48 -0
  164. package/dist/operations/proof/receipt-compaction.d.ts.map +1 -0
  165. package/dist/operations/proof/receipt-compaction.js +121 -0
  166. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  167. package/dist/operations/semantic-advisor/analysis-receipt.js +12 -1
  168. package/dist/operations/semantic-advisor/analyze-prose.d.ts +2 -1
  169. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  170. package/dist/operations/semantic-advisor/analyze-prose.js +51 -5
  171. package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
  172. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  173. package/dist/operations/semantic-advisor/clauses.js +11 -1
  174. package/dist/operations/semantic-advisor/conditional-rules.d.ts +33 -0
  175. package/dist/operations/semantic-advisor/conditional-rules.d.ts.map +1 -0
  176. package/dist/operations/semantic-advisor/conditional-rules.js +262 -0
  177. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +3 -1
  178. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
  179. package/dist/operations/semantic-advisor/ingestion-boundary.js +14 -6
  180. package/dist/operations/semantic-advisor/plugin-orchestration.js +1 -1
  181. package/dist/prolog/codec.d.ts.map +1 -1
  182. package/dist/prolog/codec.js +2 -1
  183. package/dist/prolog.d.ts +9 -0
  184. package/dist/prolog.d.ts.map +1 -1
  185. package/dist/prolog.js +56 -10
  186. package/dist/proof/command-test-report.d.ts +74 -0
  187. package/dist/proof/command-test-report.d.ts.map +1 -0
  188. package/dist/proof/command-test-report.js +206 -0
  189. package/dist/public/branch-resolver.d.ts +1 -0
  190. package/dist/public/branch-resolver.d.ts.map +1 -1
  191. package/dist/public/branch-resolver.js +1 -0
  192. package/dist/public/diagnostic-usage.d.ts +14 -0
  193. package/dist/public/diagnostic-usage.d.ts.map +1 -1
  194. package/dist/public/diagnostic-usage.js +55 -1
  195. package/dist/public/entity-origin.d.ts +69 -0
  196. package/dist/public/entity-origin.d.ts.map +1 -0
  197. package/dist/public/entity-origin.js +142 -0
  198. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  199. package/dist/public/impact/full-kb-quality.js +1 -0
  200. package/dist/public/impact/requirement-quality.js +1 -1
  201. package/dist/public/operations/catalog.d.ts +203 -20
  202. package/dist/public/operations/catalog.d.ts.map +1 -1
  203. package/dist/public/operations/catalog.js +3 -0
  204. package/dist/public/operations/check-executor.d.ts.map +1 -1
  205. package/dist/public/operations/check-executor.js +8 -0
  206. package/dist/public/operations/contracts.d.ts +0 -5
  207. package/dist/public/operations/contracts.d.ts.map +1 -1
  208. package/dist/public/operations/contracts.js +63 -14
  209. package/dist/public/operations/discovery-entities.d.ts +15 -0
  210. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  211. package/dist/public/operations/discovery-entities.js +59 -0
  212. package/dist/public/operations/discovery-executors.d.ts +6 -1
  213. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  214. package/dist/public/operations/discovery-executors.js +65 -6
  215. package/dist/public/operations/index.d.ts +1 -0
  216. package/dist/public/operations/index.d.ts.map +1 -1
  217. package/dist/public/operations/index.js +1 -0
  218. package/dist/public/operations/migration-plan.d.ts +5 -0
  219. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  220. package/dist/public/operations/migration-plan.js +26 -1
  221. package/dist/public/operations/node-ports.d.ts.map +1 -1
  222. package/dist/public/operations/node-ports.js +24 -3
  223. package/dist/public/operations/origin-review.d.ts +51 -0
  224. package/dist/public/operations/origin-review.d.ts.map +1 -0
  225. package/dist/public/operations/origin-review.js +307 -0
  226. package/dist/public/operations/predicate-schema-conformance.js +1 -1
  227. package/dist/public/operations/repair-plan.d.ts.map +1 -1
  228. package/dist/public/operations/repair-plan.js +4 -0
  229. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  230. package/dist/public/operations/result-envelope.js +17 -5
  231. package/dist/public/operations/runtime-types.d.ts +9 -0
  232. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  233. package/dist/public/operations/schema6-check-actions.d.ts +127 -0
  234. package/dist/public/operations/schema6-check-actions.d.ts.map +1 -0
  235. package/dist/public/operations/schema6-check-actions.js +575 -0
  236. package/dist/public/operations/source-path-dangling.d.ts +17 -0
  237. package/dist/public/operations/source-path-dangling.d.ts.map +1 -0
  238. package/dist/public/operations/source-path-dangling.js +66 -0
  239. package/dist/public/operations/specs/bootstrap.d.ts +73 -1
  240. package/dist/public/operations/specs/bootstrap.d.ts.map +1 -1
  241. package/dist/public/operations/specs/bootstrap.js +66 -1
  242. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  243. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  244. package/dist/public/operations/specs/check-rules.generated.js +15 -1
  245. package/dist/public/operations/specs/check.d.ts +2 -2
  246. package/dist/public/operations/specs/check.js +1 -1
  247. package/dist/public/operations/specs/composite.d.ts +351 -0
  248. package/dist/public/operations/specs/composite.d.ts.map +1 -0
  249. package/dist/public/operations/specs/composite.js +96 -0
  250. package/dist/public/operations/specs/discovery.d.ts +8 -3
  251. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  252. package/dist/public/operations/specs/discovery.js +8 -3
  253. package/dist/public/operations/specs/modeling.d.ts +2 -2
  254. package/dist/public/operations/specs/modeling.js +2 -2
  255. package/dist/public/operations/specs/mutation-schemas.d.ts +73 -8
  256. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  257. package/dist/public/operations/specs/mutation-schemas.js +43 -7
  258. package/dist/public/operations/specs/mutation.d.ts +1 -1
  259. package/dist/public/operations/specs/mutation.js +1 -1
  260. package/dist/public/operations/specs/planning.d.ts +2 -2
  261. package/dist/public/operations/specs/planning.js +4 -4
  262. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  263. package/dist/public/operations/specs/reporting.js +13 -26
  264. package/dist/public/operations/specs/upsert.d.ts +79 -9
  265. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  266. package/dist/public/operations/specs/upsert.js +6 -1
  267. package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
  268. package/dist/public/operations/symbol-repair-plan.js +3 -1
  269. package/dist/public/operations/types.d.ts +1 -1
  270. package/dist/public/operations/types.d.ts.map +1 -1
  271. package/dist/public/proof-receipt.d.ts +1 -0
  272. package/dist/public/proof-receipt.d.ts.map +1 -1
  273. package/dist/public/schemas/entity.d.ts.map +1 -1
  274. package/dist/public/schemas/entity.js +52 -0
  275. package/dist/public/schemas/relationship.d.ts.map +1 -1
  276. package/dist/public/schemas/relationship.js +2 -0
  277. package/dist/public/skills/kibi-bootstrap/SKILL.md +52 -11
  278. package/dist/public/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
  279. package/dist/public/skills/kibi-usage/SKILL.md +82 -18
  280. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
  281. package/dist/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
  282. package/dist/public/skills/kibi-usage/resources/logic-ir.md +2 -2
  283. package/dist/public/skills/kibi-usage/resources/operation-access.md +29 -1
  284. package/dist/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
  285. package/dist/public/skills/kibi-usage/resources/workflows.md +42 -25
  286. package/dist/public/telemetry-acceptance.d.ts +64 -0
  287. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  288. package/dist/public/telemetry-acceptance.js +143 -7
  289. package/dist/public/telemetry-remediation.d.ts.map +1 -1
  290. package/dist/public/telemetry-remediation.js +26 -10
  291. package/dist/relationships/shards.d.ts +13 -0
  292. package/dist/relationships/shards.d.ts.map +1 -1
  293. package/dist/relationships/shards.js +54 -28
  294. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  295. package/dist/runtime/cli-runtime.js +44 -3
  296. package/dist/runtime/detached-snapshot.d.ts +38 -0
  297. package/dist/runtime/detached-snapshot.d.ts.map +1 -0
  298. package/dist/runtime/detached-snapshot.js +92 -0
  299. package/dist/schemas/entity.schema.json +122 -0
  300. package/dist/search-answer.d.ts +157 -0
  301. package/dist/search-answer.d.ts.map +1 -0
  302. package/dist/search-answer.js +846 -0
  303. package/dist/traceability/impact-knowledge.d.ts.map +1 -1
  304. package/dist/traceability/impact-knowledge.js +7 -0
  305. package/dist/traceability/symbol-extract.js +3 -3
  306. package/dist/traceability/temp-kb.d.ts.map +1 -1
  307. package/dist/traceability/temp-kb.js +12 -0
  308. package/dist/types/entities.d.ts +13 -0
  309. package/dist/types/entities.d.ts.map +1 -1
  310. package/dist/types/relationships.d.ts +1 -1
  311. package/dist/types/relationships.d.ts.map +1 -1
  312. package/dist/utils/branch-resolver.d.ts +37 -1
  313. package/dist/utils/branch-resolver.d.ts.map +1 -1
  314. package/dist/utils/branch-resolver.js +130 -3
  315. package/dist/utils/repo-relative-path.d.ts +18 -0
  316. package/dist/utils/repo-relative-path.d.ts.map +1 -0
  317. package/dist/utils/repo-relative-path.js +58 -0
  318. package/dist/utils/rule-registry.generated.d.ts +75 -3
  319. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  320. package/dist/utils/rule-registry.generated.js +89 -3
  321. package/dist/utils/schema-version.d.ts +1 -1
  322. package/dist/utils/schema-version.d.ts.map +1 -1
  323. package/dist/utils/schema-version.js +4 -3
  324. package/dist/utils/strict-modeling.d.ts +1 -1
  325. package/dist/utils/strict-modeling.d.ts.map +1 -1
  326. package/dist/utils/strict-modeling.js +23 -3
  327. package/package.json +3 -3
  328. package/schema/entities.pl +22 -0
  329. package/schema/relationships.pl +14 -0
  330. package/schema/validation.pl +45 -1
  331. package/src/public/branch-resolver.ts +1 -0
  332. package/src/public/diagnostic-usage.ts +59 -1
  333. package/src/public/entity-origin.ts +175 -0
  334. package/src/public/impact/full-kb-quality.ts +1 -0
  335. package/src/public/impact/requirement-quality.ts +1 -1
  336. package/src/public/operations/catalog.ts +3 -0
  337. package/src/public/operations/check-executor.ts +15 -0
  338. package/src/public/operations/contracts.ts +75 -15
  339. package/src/public/operations/discovery-entities.ts +74 -0
  340. package/src/public/operations/discovery-executors.ts +88 -10
  341. package/src/public/operations/index.ts +1 -0
  342. package/src/public/operations/migration-plan.ts +30 -1
  343. package/src/public/operations/node-ports.ts +24 -3
  344. package/src/public/operations/origin-review.ts +375 -0
  345. package/src/public/operations/predicate-schema-conformance.ts +1 -1
  346. package/src/public/operations/repair-plan.ts +4 -0
  347. package/src/public/operations/result-envelope.ts +18 -6
  348. package/src/public/operations/runtime-types.ts +9 -0
  349. package/src/public/operations/schema6-check-actions.ts +699 -0
  350. package/src/public/operations/source-path-dangling.ts +81 -0
  351. package/src/public/operations/specs/bootstrap.ts +78 -4
  352. package/src/public/operations/specs/check-rules.generated.ts +15 -1
  353. package/src/public/operations/specs/check.ts +1 -1
  354. package/src/public/operations/specs/composite.ts +141 -0
  355. package/src/public/operations/specs/discovery.ts +9 -3
  356. package/src/public/operations/specs/modeling.ts +2 -2
  357. package/src/public/operations/specs/mutation-schemas.ts +49 -7
  358. package/src/public/operations/specs/mutation.ts +1 -1
  359. package/src/public/operations/specs/planning.ts +4 -4
  360. package/src/public/operations/specs/reporting.ts +13 -38
  361. package/src/public/operations/specs/upsert.ts +7 -1
  362. package/src/public/operations/symbol-repair-plan.ts +3 -1
  363. package/src/public/operations/types.ts +2 -0
  364. package/src/public/proof-receipt.ts +1 -0
  365. package/src/public/schemas/entity.ts +57 -0
  366. package/src/public/schemas/relationship.ts +2 -0
  367. package/src/public/skills/kibi-bootstrap/SKILL.md +52 -11
  368. package/src/public/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
  369. package/src/public/skills/kibi-usage/SKILL.md +82 -18
  370. package/src/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
  371. package/src/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
  372. package/src/public/skills/kibi-usage/resources/logic-ir.md +2 -2
  373. package/src/public/skills/kibi-usage/resources/operation-access.md +29 -1
  374. package/src/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
  375. package/src/public/skills/kibi-usage/resources/workflows.md +42 -25
  376. package/src/public/telemetry-acceptance-types.d.ts +4 -1
  377. package/src/public/telemetry-acceptance.ts +210 -7
  378. package/src/public/telemetry-remediation.ts +39 -10
  379. package/src/schemas/entity.schema.json +122 -0
  380. package/src/schemas/relationship.schema.json +2 -0
@@ -0,0 +1,121 @@
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 { canonicalJson } from "../../public/proof-fingerprint.js";
19
+ // implements REQ-kibi-fresh-verification-receipts-v2
20
+ export const PROOF_RECEIPT_COMPACTION_POLICY = "kibi.proof-receipt-compaction.v1";
21
+ function finishedStamp(receipt) {
22
+ const value = receipt.finished_at;
23
+ const parsed = typeof value === "string" ? Date.parse(value) : Number.NaN;
24
+ return Number.isFinite(parsed) ? parsed : Number.NEGATIVE_INFINITY;
25
+ }
26
+ /** Newest by finished_at; equal stamps resolve to the later history entry. */
27
+ function newest(receipts, indices) {
28
+ let best;
29
+ for (const index of indices) {
30
+ const receipt = receipts[index];
31
+ if (best === undefined ||
32
+ finishedStamp(receipt) >= finishedStamp(receipts[best])) {
33
+ best = index;
34
+ }
35
+ }
36
+ return best;
37
+ }
38
+ /**
39
+ * Deterministic, decision-preserving compaction of one test's proof-receipt
40
+ * history (policy kibi.proof-receipt-compaction.v1).
41
+ *
42
+ * Coverage decides a test from one selector group: receipts whose
43
+ * `binding_hash` equals the test's current binding, or, when there are none,
44
+ * receipts whose `code_snapshot` equals the live snapshot. Within that group
45
+ * it reads the newest receipt per (scope, contract_hash) and the set of
46
+ * contract hashes present. Compaction keeps exactly what those reads can
47
+ * observe, plus two history anchors:
48
+ *
49
+ * - per selector group, the newest receipt for each (scope, contract_hash);
50
+ * - the newest receipt overall (what the last run reported);
51
+ * - the newest passing receipt (last known good, so reverting a change
52
+ * finds its proof again without a re-run).
53
+ *
54
+ * Everything else is superseded evidence: it can never be the deciding
55
+ * receipt again for the current snapshot or binding. The result is an
56
+ * ordered subsequence of the input, so it stays a valid history, and the
57
+ * function is idempotent for a fixed anchor. Inputs that are not structurally
58
+ * valid histories must not be compacted (callers validate first): an invalid
59
+ * history decides `invalid`, and dropping the offending entry would change
60
+ * that decision.
61
+ */
62
+ // implements REQ-kibi-fresh-verification-receipts-v2
63
+ export function compactProofReceipts(receipts, anchor) {
64
+ if (receipts.length === 0)
65
+ return { kept: [], removed: 0 };
66
+ const all = receipts.map((_, index) => index);
67
+ const keep = new Set();
68
+ const add = (index) => {
69
+ if (index !== undefined)
70
+ keep.add(index);
71
+ };
72
+ add(newest(receipts, all));
73
+ add(newest(receipts, all.filter((index) => receipts[index]?.outcome === "passed")));
74
+ const selectors = [];
75
+ if (anchor.bindingHash !== undefined && anchor.bindingHash !== "") {
76
+ const bindingHash = anchor.bindingHash;
77
+ selectors.push((receipt) => receipt.binding_hash === bindingHash);
78
+ }
79
+ if (anchor.codeSnapshot !== undefined && anchor.codeSnapshot !== "") {
80
+ const codeSnapshot = anchor.codeSnapshot;
81
+ selectors.push((receipt) => receipt.code_snapshot === codeSnapshot);
82
+ }
83
+ for (const selector of selectors) {
84
+ const groups = new Map();
85
+ for (const index of all) {
86
+ const receipt = receipts[index];
87
+ if (!selector(receipt))
88
+ continue;
89
+ const key = `${String(receipt.scope)}\0${String(receipt.contract_hash)}`;
90
+ const group = groups.get(key) ?? [];
91
+ group.push(index);
92
+ groups.set(key, group);
93
+ }
94
+ for (const group of groups.values())
95
+ add(newest(receipts, group));
96
+ }
97
+ const kept = all
98
+ .filter((index) => keep.has(index))
99
+ .map((index) => receipts[index]);
100
+ return { kept, removed: receipts.length - kept.length };
101
+ }
102
+ /**
103
+ * True when `subset` is `superset` with entries removed and nothing changed or
104
+ * reordered. Compaction may only drop receipts; this guard keeps every other
105
+ * rewrite of a receipt history fail-closed.
106
+ */
107
+ // implements REQ-kibi-fresh-verification-receipts-v2
108
+ export function isOrderedReceiptSubsequence(subset, superset) {
109
+ let cursor = 0;
110
+ for (const receipt of subset) {
111
+ const wanted = canonicalJson(receipt);
112
+ while (cursor < superset.length &&
113
+ canonicalJson(superset[cursor]) !== wanted) {
114
+ cursor += 1;
115
+ }
116
+ if (cursor === superset.length)
117
+ return false;
118
+ cursor += 1;
119
+ }
120
+ return true;
121
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"analysis-receipt.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/analysis-receipt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,KAAK,OAAO,EAMb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,6BAA6B,EAI7B,4BAA4B,EAC5B,0BAA0B,EAC1B,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACf,MAAM,YAAY,CAAC;AAyBpB,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,SAAS,0BAA0B,EAAE,EAClD,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,YAAY,EAAE,SAAS,mBAAmB,EAAE,EAC5C,eAAe,EAAE,SAAS,4BAA4B,EAAE,EACxD,cAAc,EAAE,SAAS,iBAAiB,EAAE,GAC3C,6BAA6B,CA2H/B"}
1
+ {"version":3,"file":"analysis-receipt.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/analysis-receipt.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,KAAK,OAAO,EAMb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACV,6BAA6B,EAI7B,4BAA4B,EAC5B,0BAA0B,EAC1B,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACf,MAAM,YAAY,CAAC;AAqCpB,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,SAAS,0BAA0B,EAAE,EAClD,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,YAAY,EAAE,SAAS,mBAAmB,EAAE,EAC5C,eAAe,EAAE,SAAS,4BAA4B,EAAE,EACxD,cAAc,EAAE,SAAS,iBAAiB,EAAE,GAC3C,6BAA6B,CA2H/B"}
@@ -17,6 +17,17 @@ function summary(readiness, lane) {
17
17
  return "Requirement prose has a typed interpretation candidate; validate and persist it as a safe kibi.logic.v1 rule.";
18
18
  return "Requirement prose appears normative but needs review before it can participate in logic checks.";
19
19
  }
20
+ /**
21
+ * How an agent reaches a catalog operation: MCP serves the modeling
22
+ * operations as modes of kb_model.
23
+ */
24
+ function hostToolName(operation) {
25
+ if (operation === "kb_model_requirement")
26
+ return "kb_model (mode requirement)";
27
+ if (operation === "kb_suggest_predicates")
28
+ return "kb_model (mode predicates)";
29
+ return operation;
30
+ }
20
31
  // implements REQ-mcp-semantic-advisor-preflight
21
32
  export function buildAdvisorResult(payload, signals, modeled, suggestions, clauses, propositions, interpretations, shadowAnalysis) {
22
33
  const semanticSource = semanticSourceOf(payload);
@@ -119,7 +130,7 @@ export function buildAdvisorResult(payload, signals, modeled, suggestions, claus
119
130
  receipt,
120
131
  warnings: readiness === "needs_modeling"
121
132
  ? [
122
- `Semantic advisor: ${receipt.summary} Next action: call ${tools.join(" or ")} before treating this requirement as Prolog-checkable.`,
133
+ `Semantic advisor: ${receipt.summary} Next action: call ${tools.map(hostToolName).join(" or ")} before treating this requirement as Prolog-checkable.`,
123
134
  ]
124
135
  : [],
125
136
  };
@@ -1,6 +1,7 @@
1
- import type { SemanticAdvisorAnalysisResult, SemanticAdvisorInput } from "./types.js";
1
+ import type { SemanticAdvisorAnalysisResult, SemanticAdvisorInput, SemanticPropositionRole } from "./types.js";
2
2
  export declare const SEMANTIC_ADVISOR_VERSION = "semantic-advisor-v2";
3
3
  export { semanticClaimKey } from "./clauses.js";
4
4
  export declare function stringLogicClaims(value: unknown): string[];
5
+ export declare function propositionRole(statement: string, normative: boolean): SemanticPropositionRole;
5
6
  export declare function analyzeSemanticAdvisorInput(input: SemanticAdvisorInput): SemanticAdvisorAnalysisResult;
6
7
  //# sourceMappingURL=analyze-prose.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"analyze-prose.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/analyze-prose.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EACV,6BAA6B,EAC7B,oBAAoB,EAWrB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAI1D;AAk2BD,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,oBAAoB,GAC1B,6BAA6B,CA+D/B"}
1
+ {"version":3,"file":"analyze-prose.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/analyze-prose.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EACV,6BAA6B,EAC7B,oBAAoB,EAKpB,uBAAuB,EAMxB,MAAM,YAAY,CAAC;AAEpB,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAI1D;AAwgBD,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,OAAO,GACjB,uBAAuB,CAuDzB;AA4VD,wBAAgB,2BAA2B,CACzC,KAAK,EAAE,oBAAoB,GAC1B,6BAA6B,CA+D/B"}
@@ -3,6 +3,7 @@ import { utf8Span, validateLogicIr, } from "../../logic/ir.js";
3
3
  import { logicRuleFactId } from "../modeling/logic-modeling.js";
4
4
  import { buildAdvisorResult } from "./analysis-receipt.js";
5
5
  import { extractSemanticClauses, hasNormativeAssertion, semanticClaimKey, } from "./clauses.js";
6
+ import { detectConditionalRule, } from "./conditional-rules.js";
6
7
  import { observationPlan } from "./observation-plan.js";
7
8
  import { predicateSuggestion as buildPredicateSuggestion, isRecord, payloadHash, propertiesOf, relationship, semanticClausesOf, semanticSourceHash, semanticSourceOf, sourceOf, statementOf, stringValue, } from "./shared.js";
8
9
  import { detectStrictSuggestion } from "./strict-rules.js";
@@ -126,7 +127,8 @@ function predicateSuggestion(payload, statement) {
126
127
  return null;
127
128
  return buildPredicateSuggestion(payload, hit.evidence, hit.predicateName, hit.arguments, hit.rationale ?? "", hit.polarity);
128
129
  }
129
- function ruleSuggestion(payload, candidate) {
130
+ const HOST_RULE_RATIONALE = "The host supplied a typed kibi.logic.v1 interpretation. Kibi validated its safety, canonicalized it, and will persist it as data-backed rule evidence.";
131
+ function ruleSuggestion(payload, candidate, rationale = HOST_RULE_RATIONALE) {
130
132
  const validation = validateLogicIr(candidate.ir);
131
133
  if (!validation.valid ||
132
134
  !validation.normalized ||
@@ -163,7 +165,7 @@ function ruleSuggestion(payload, candidate) {
163
165
  claim_text: candidate.claim_text,
164
166
  confidence: candidate.confidence ?? 0.75,
165
167
  evidence: candidate.claim_text,
166
- rationale: "The host supplied a typed kibi.logic.v1 interpretation. Kibi validated its safety, canonicalized it, and will persist it as data-backed rule evidence.",
168
+ rationale,
167
169
  suggested_next_tool: "kb_model_requirement",
168
170
  rule: validation.normalized,
169
171
  semantic_key: semanticKey,
@@ -175,7 +177,7 @@ function ruleSuggestion(payload, candidate) {
175
177
  type: "fact",
176
178
  id: factId,
177
179
  properties: {
178
- title: `${candidate.ir.kind} rule ${semanticKey}`,
180
+ title: `Rule: ${candidate.claim_text}`,
179
181
  status: "active",
180
182
  source: sourceOf(payload),
181
183
  fact_kind: "rule",
@@ -199,6 +201,46 @@ function ruleSuggestion(payload, candidate) {
199
201
  : null,
200
202
  };
201
203
  }
204
+ // implements REQ-kibi-truthful-consistency
205
+ // "X may happen only when C" and "X must not happen unless C" are conditional
206
+ // requirements: they restrict an action, not a property of every situation.
207
+ // Route them to the rule lane as a typed forbid-unless rule, so scenario
208
+ // feasibility and contradiction checks see the action and its condition.
209
+ function conditionalRuleSuggestion(payload, clause, match) {
210
+ if (match?.kind !== "rule")
211
+ return null;
212
+ return ruleSuggestion(payload, {
213
+ claim_key: clause.claim_key,
214
+ claim_text: clause.text,
215
+ ir: match.ir,
216
+ confidence: 0.8,
217
+ }, `Conditional requirement (${match.shape === "only_when" ? "only when" : "must not ... unless"}): ${match.action} is forbidden unless ${match.subjectKey}.${match.propertyKey} meets the stated condition${match.scope ? ` in scope ${match.scope}` : ""}. Kibi modeled it as a typed forbid-unless rule; assume ${match.subjectKey}.${match.propertyKey} property values in scenarios to check them against it.`);
218
+ }
219
+ // implements REQ-kibi-truthful-consistency
220
+ // A conditional clause that is neither a translatable rule nor a catalog
221
+ // predicate stays an ontology gap (unresolved), never a strict property or an
222
+ // observation that looks modeled: the strict lane would drop the condition.
223
+ function unresolvedConditionalSuggestion(payload, clause, match) {
224
+ if (match === null)
225
+ return null;
226
+ return {
227
+ kind: "ontology_gap",
228
+ claim_key: clause.claim_key,
229
+ claim_text: clause.text,
230
+ confidence: 0.6,
231
+ evidence: match.evidence,
232
+ rationale: match.kind === "unparsed"
233
+ ? `${match.reason} Supply a typed kibi.logic.v1 interpretation (forbid the action unless the condition holds) instead of an observation.`
234
+ : "The conditional clause did not produce a valid kibi.logic.v1 rule; supply a typed interpretation instead of an observation.",
235
+ suggested_next_tool: "kb_suggest_predicates",
236
+ recommendedPredicateSchema: null,
237
+ applyPlan: observationPlan(payload, "Ontology gap: conditional clause", [
238
+ "semantic-advisor-suggestion",
239
+ "review:ontology-gap",
240
+ "needs_rule_interpretation",
241
+ ]),
242
+ };
243
+ }
202
244
  function modelingSuggestions(payload, modeled, clauses, interpretations) {
203
245
  if (!isRequirement(payload) || modeled)
204
246
  return [];
@@ -209,7 +251,10 @@ function modelingSuggestions(payload, modeled, clauses, interpretations) {
209
251
  .map((clause) => clause.claim_key);
210
252
  for (const clause of clauses) {
211
253
  const candidate = clause.text;
212
- const rawSuggestion = predicateSuggestion(payload, candidate) ??
254
+ const conditional = detectConditionalRule(candidate);
255
+ const rawSuggestion = conditionalRuleSuggestion(payload, clause, conditional) ??
256
+ predicateSuggestion(payload, candidate) ??
257
+ unresolvedConditionalSuggestion(payload, clause, conditional) ??
213
258
  ontologyGapSuggestion(payload, candidate) ??
214
259
  ambiguitySuggestion(payload, candidate) ??
215
260
  detectStrictSuggestion(payload, candidate);
@@ -370,7 +415,8 @@ function unmatchedClauseSuggestion(payload, clause, clauses, expectedClaimKeys)
370
415
  ]),
371
416
  }, clause, clauses, expectedClaimKeys, statementOf(payload), semanticSourceOf(payload).field);
372
417
  }
373
- function propositionRole(statement, normative) {
418
+ // implements REQ-kibi-conditional-requirement-authoring
419
+ export function propositionRole(statement, normative) {
374
420
  // Explicit context labels may quote obligations. Incidental explanatory
375
421
  // words within an asserted obligation must not exempt it from grounding.
376
422
  const assertedNormative = normative && hasNormativeAssertion(statement);
@@ -6,6 +6,7 @@ export type SemanticClause = Readonly<{
6
6
  source: "detected" | "supplied";
7
7
  }>;
8
8
  export declare function hasNormativeAssertion(text: string): boolean;
9
+ export declare function modeledClaimRole(text: string, modality?: string): "normative" | "descriptive";
9
10
  export declare function normalizeSemanticClause(value: string): string;
10
11
  export declare function semanticClaimKey(text: string): string;
11
12
  export declare function extractSemanticClauses(text: string, suppliedClauses?: readonly string[]): readonly SemanticClause[];
@@ -1 +1 @@
1
- {"version":3,"file":"clauses.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/clauses.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACjC,CAAC,CAAC;AAYH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIrD;AA4BD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,GAClC,SAAS,cAAc,EAAE,CA4B3B"}
1
+ {"version":3,"file":"clauses.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/clauses.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;CACjC,CAAC,CAAC;AAYH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AAQD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,GAChB,WAAW,GAAG,aAAa,CAG7B;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIrD;AA4BD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,GAClC,SAAS,cAAc,EAAE,CA4B3B"}
@@ -1,11 +1,21 @@
1
1
  import { createHash } from "node:crypto";
2
- const NORMATIVE_ASSERTION_PATTERN = /\b(?:must|shall|should|required|requires?|may\s+only|may\s+(?:have\s+)?(?:at\s+most|at\s+least|exactly|no\s+more\s+than|up\s+to)|only\s+.+?\s+(?:may|can)|must\s+not|shall\s+not|cannot|can't|denied|forbidden|prohibited|(?:is|are|be|become|becomes|remain|remains)\s+(?:invalid|rejected|prohibited|forbidden)|(?:reject|rejects|rejected|rejection)\s+(?:invalid|unresolved|ambiguous)|fail(?:s|ed)?\s+(?:clearly|explicitly|with)|expires?\s+(?:after|within|in)|failure\s+(?:behavior|policy|outcome)|error\s+(?:handling|behavior|policy|outcome)|required\s+outcome|defaults?\s+to)\b/i;
2
+ const NORMATIVE_ASSERTION_PATTERN = /\b(?:must|shall|should|required|requires?|may\s+only|may\s+(?:not\s+)?(?:be\s+)?\w+\s+only\b|may\s+(?:have\s+)?(?:at\s+most|at\s+least|exactly|no\s+more\s+than|up\s+to)|only\s+.+?\s+(?:may|can)|must\s+not|shall\s+not|cannot|can't|denied|forbidden|prohibited|(?:is|are|be|become|becomes|remain|remains)\s+(?:invalid|rejected|prohibited|forbidden)|(?:reject|rejects|rejected|rejection)\s+(?:invalid|unresolved|ambiguous)|fail(?:s|ed)?\s+(?:clearly|explicitly|with)|expires?\s+(?:after|within|in)|failure\s+(?:behavior|policy|outcome)|error\s+(?:handling|behavior|policy|outcome)|required\s+outcome|defaults?\s+to)\b/i;
3
3
  // Conditional/temporal cues help discover clauses but do not by themselves
4
4
  // turn explanatory or subjective context into an asserted obligation.
5
5
  const NORMATIVE_PATTERN = new RegExp(`${NORMATIVE_ASSERTION_PATTERN.source}|\\b(?:before|unless|when|if)\\b`, "i");
6
6
  export function hasNormativeAssertion(text) {
7
7
  return NORMATIVE_ASSERTION_PATTERN.test(text);
8
8
  }
9
+ const NORMATIVE_MODALITIES = new Set(["oblige", "forbid", "permit"]);
10
+ // implements REQ-kibi-truthful-consistency
11
+ // Role for a clause that was just modeled. A deontic rule modality is decisive;
12
+ // otherwise the same assertion pattern the semantic advisor uses decides, so a
13
+ // modeled inventory entry never disagrees with the advisor's own analysis.
14
+ export function modeledClaimRole(text, modality) {
15
+ if (modality && NORMATIVE_MODALITIES.has(modality))
16
+ return "normative";
17
+ return hasNormativeAssertion(text) ? "normative" : "descriptive";
18
+ }
9
19
  export function normalizeSemanticClause(value) {
10
20
  return (value
11
21
  .replace(/^\s*(?:[-*+]\s+|\d+[.)]\s+)/, "")
@@ -0,0 +1,33 @@
1
+ import type { LogicRuleIR } from "../../logic/ir.js";
2
+ /**
3
+ * Conditional requirement shapes routed to the rule lane.
4
+ *
5
+ * "<Action> may|can|must|shall happen only when|if <condition>"
6
+ * "<Action> may|can only happen when|if <condition>"
7
+ * "<Action> must|shall|may|can not (or cannot) happen unless <condition>"
8
+ *
9
+ * Both say the action is forbidden unless the condition holds, so both become
10
+ * one typed kibi.logic.v1 rule: forbid <action>(X) :- <subject>:<property>(X,
11
+ * V) unless V <op> <value>. A leading "In the EU," or "For EU orders," scopes
12
+ * the rule. A clause with one of these shapes whose action or condition this
13
+ * reader cannot translate is reported as `unparsed`, so the caller keeps it
14
+ * unresolved instead of downgrading it to an observation that looks modeled.
15
+ */
16
+ export type ConditionalRuleShape = "only_when" | "unless";
17
+ export type ConditionalRuleMatch = Readonly<{
18
+ kind: "rule";
19
+ shape: ConditionalRuleShape;
20
+ evidence: string;
21
+ action: string;
22
+ subjectKey: string;
23
+ propertyKey: string;
24
+ scope: string | null;
25
+ ir: LogicRuleIR;
26
+ }> | Readonly<{
27
+ kind: "unparsed";
28
+ shape: ConditionalRuleShape;
29
+ evidence: string;
30
+ reason: string;
31
+ }>;
32
+ export declare function detectConditionalRule(statement: string): ConditionalRuleMatch | null;
33
+ //# sourceMappingURL=conditional-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditional-rules.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/conditional-rules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,mBAAmB,CAAC;AAGhE;;;;;;;;;;;;;GAaG;AAEH,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAG1D,MAAM,MAAM,oBAAoB,GAC5B,QAAQ,CAAC;IACP,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,oBAAoB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,EAAE,EAAE,WAAW,CAAC;CACjB,CAAC,GACF,QAAQ,CAAC;IACP,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,oBAAoB,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAuMP,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,GAChB,oBAAoB,GAAG,IAAI,CA0F7B"}
@@ -0,0 +1,262 @@
1
+ import { normalizeKey } from "./shared.js";
2
+ const ONLY_WHEN = /^(?<action>.+?)\s+(?:may|can|must|shall|should)\s+(?:only\s+(?<verbBefore>.+?)|(?<verbAfter>.+?)\s+only)\s+(?:when|if)\s+(?<condition>.+)$/i;
3
+ const ONLY_WHEN_ANYWHERE = /\bonly\s+(?:when|if)\b|\b(?:may|can|must|shall|should)\s+only\s+[^.;]*?\b(?:when|if)\b/i;
4
+ const UNLESS = /^(?<action>.+?)\s+(?:(?:may|can|must|shall|should)\s+not|cannot|can't|must\s+never|shall\s+never)\s+(?<verb>.+?)\s+unless\s+(?<condition>.+)$/i;
5
+ const NEGATED_UNLESS_ANYWHERE = /\b(?:not|cannot|can't|never)\b[^.;]*\bunless\b/i;
6
+ const SCOPE_PREFIX = /^(?:[Ii]n|[Ff]or|[Ww]ithin)\s+(?:[Tt]he\s+)?(?<scope>[A-Z]{2,})(?:\s+[a-z]+)?\s*,\s*/;
7
+ // Verbs that only say the action takes place: the action is the subject.
8
+ const OCCURRENCE_VERB = /^(?:happen|occur|proceed|start|begin|run|complete|take\s+place|be\s+(?:performed|placed|submitted|started|completed|processed|executed))$/i;
9
+ const NUMBER_WORDS = {
10
+ zero: 0,
11
+ one: 1,
12
+ two: 2,
13
+ three: 3,
14
+ four: 4,
15
+ five: 5,
16
+ six: 6,
17
+ seven: 7,
18
+ eight: 8,
19
+ nine: 9,
20
+ ten: 10,
21
+ };
22
+ const DURATION_UNITS = {
23
+ ms: "ms",
24
+ millisecond: "ms",
25
+ milliseconds: "ms",
26
+ s: "s",
27
+ sec: "s",
28
+ second: "s",
29
+ seconds: "s",
30
+ min: "m",
31
+ minute: "m",
32
+ minutes: "m",
33
+ h: "h",
34
+ hour: "h",
35
+ hours: "h",
36
+ d: "d",
37
+ day: "d",
38
+ days: "d",
39
+ w: "w",
40
+ week: "w",
41
+ weeks: "w",
42
+ };
43
+ function identifier(text) {
44
+ return normalizeKey(text.replace(/\b(?:a|an|the)\b/gi, " "));
45
+ }
46
+ function numberValue(text) {
47
+ const trimmed = text.trim().toLowerCase();
48
+ if (/^-?\d+(?:\.\d+)?$/.test(trimmed))
49
+ return Number(trimmed);
50
+ return NUMBER_WORDS[trimmed] ?? null;
51
+ }
52
+ // "5", "five", "30 minutes", "2.5"
53
+ function quantity(text) {
54
+ const match = text
55
+ .trim()
56
+ .match(/^(?<amount>-?\d+(?:\.\d+)?|[a-z]+)(?:\s+(?<unit>[a-z]+))?$/i);
57
+ if (!match?.groups?.amount)
58
+ return null;
59
+ const amount = numberValue(match.groups.amount);
60
+ if (amount === null)
61
+ return null;
62
+ const unitText = match.groups.unit?.toLowerCase();
63
+ if (unitText === undefined)
64
+ return { value: { kind: "number", value: amount }, valueType: "number" };
65
+ const unit = DURATION_UNITS[unitText];
66
+ if (unit === undefined || amount < 0)
67
+ return null;
68
+ return {
69
+ value: { kind: "duration", value: amount, unit },
70
+ valueType: "duration",
71
+ };
72
+ }
73
+ const ZERO = { kind: "number", value: 0 };
74
+ function comparison(predicate) {
75
+ const text = predicate
76
+ .trim()
77
+ .replace(/[.!?]+$/, "")
78
+ .toLowerCase();
79
+ const fixed = {
80
+ positive: { operator: "gt", value: ZERO, valueType: "number" },
81
+ "greater than zero": { operator: "gt", value: ZERO, valueType: "number" },
82
+ "above zero": { operator: "gt", value: ZERO, valueType: "number" },
83
+ "more than zero": { operator: "gt", value: ZERO, valueType: "number" },
84
+ negative: { operator: "lt", value: ZERO, valueType: "number" },
85
+ "below zero": { operator: "lt", value: ZERO, valueType: "number" },
86
+ "less than zero": { operator: "lt", value: ZERO, valueType: "number" },
87
+ zero: { operator: "eq", value: ZERO, valueType: "number" },
88
+ "non-negative": { operator: "gte", value: ZERO, valueType: "number" },
89
+ nonnegative: { operator: "gte", value: ZERO, valueType: "number" },
90
+ "not negative": { operator: "gte", value: ZERO, valueType: "number" },
91
+ "non-zero": { operator: "neq", value: ZERO, valueType: "number" },
92
+ "not zero": { operator: "neq", value: ZERO, valueType: "number" },
93
+ };
94
+ const known = fixed[text];
95
+ if (known)
96
+ return known;
97
+ const comparators = [
98
+ [/^(?:greater|more|higher)\s+than\s+(?<q>.+)$/, "gt"],
99
+ [/^(?:above|over|exceeds?)\s+(?<q>.+)$/, "gt"],
100
+ [/^(?:at\s+least|no\s+less\s+than|not\s+less\s+than)\s+(?<q>.+)$/, "gte"],
101
+ [/^(?<q>.+?)\s+or\s+more$/, "gte"],
102
+ [/^(?:less|fewer|lower)\s+than\s+(?<q>.+)$/, "lt"],
103
+ [/^(?:below|under)\s+(?<q>.+)$/, "lt"],
104
+ [
105
+ /^(?:at\s+most|no\s+more\s+than|not\s+more\s+than|up\s+to)\s+(?<q>.+)$/,
106
+ "lte",
107
+ ],
108
+ [/^(?<q>.+?)\s+or\s+(?:less|fewer)$/, "lte"],
109
+ [/^(?:not\s+equal\s+to|different\s+from|not)\s+(?<q>.+)$/, "neq"],
110
+ [/^(?:equal\s+to|exactly)\s+(?<q>.+)$/, "eq"],
111
+ ];
112
+ for (const [pattern, operator] of comparators) {
113
+ const match = text.match(pattern);
114
+ const parsed = match?.groups?.q ? quantity(match.groups.q) : null;
115
+ if (parsed)
116
+ return { operator, ...parsed };
117
+ }
118
+ const bare = quantity(text);
119
+ if (bare)
120
+ return { operator: "eq", ...bare };
121
+ // A single word state ("active", "verified") is a symbolic value.
122
+ if (/^[a-z][a-z_-]*$/.test(text) && !/^(?:not|no|any|some)$/.test(text))
123
+ return {
124
+ operator: "eq",
125
+ value: { kind: "const", value: text.replace(/-/g, "_"), type: "string" },
126
+ valueType: "string",
127
+ };
128
+ return null;
129
+ }
130
+ // "the cart total is positive", "the cart's total is at least 5"
131
+ function condition(text) {
132
+ if (/\b(?:and|or|but)\b|,/i.test(text))
133
+ return null;
134
+ const match = text
135
+ .trim()
136
+ .replace(/[.!?]+$/, "")
137
+ .match(/^(?<subject>.+?)\s+(?<verb>is|are|stays|remains|equals)\s+(?<predicate>.+)$/i);
138
+ if (!match?.groups?.subject || !match.groups.verb || !match.groups.predicate)
139
+ return null;
140
+ const parsed = comparison(match.groups.verb.toLowerCase() === "equals"
141
+ ? `equal to ${match.groups.predicate}`
142
+ : match.groups.predicate);
143
+ if (!parsed)
144
+ return null;
145
+ const subjectText = match.groups.subject.replace(/\b(?:a|an|the)\b/gi, " ");
146
+ let subjectPart;
147
+ let propertyPart;
148
+ const possessive = subjectText.match(/^(?<owner>.+?)['’]s\s+(?<prop>.+)$/);
149
+ const ofForm = subjectText.match(/^(?<prop>.+?)\s+of\s+(?<owner>.+)$/i);
150
+ if (possessive?.groups?.owner && possessive.groups.prop) {
151
+ subjectPart = possessive.groups.owner;
152
+ propertyPart = possessive.groups.prop;
153
+ }
154
+ else if (ofForm?.groups?.owner && ofForm.groups.prop) {
155
+ subjectPart = ofForm.groups.owner;
156
+ propertyPart = ofForm.groups.prop;
157
+ }
158
+ else {
159
+ const words = subjectText.trim().split(/\s+/);
160
+ if (words.length < 2)
161
+ return null;
162
+ propertyPart = words.slice(-1).join(" ");
163
+ subjectPart = words.slice(0, -1).join(" ");
164
+ }
165
+ const subjectKey = identifier(subjectPart);
166
+ const propertyKey = identifier(propertyPart);
167
+ if (!/^[a-z]/.test(subjectKey) || !/^[a-z]/.test(propertyKey))
168
+ return null;
169
+ return { subjectKey, propertyKey, comparison: parsed };
170
+ }
171
+ function actionName(subject, verb) {
172
+ const verbText = verb.trim();
173
+ return OCCURRENCE_VERB.test(verbText)
174
+ ? identifier(subject)
175
+ : identifier(`${subject} ${verbText.replace(/^be\s+/i, "")}`);
176
+ }
177
+ // implements REQ-kibi-conditional-requirement-authoring
178
+ export function detectConditionalRule(statement) {
179
+ const text = statement.trim().replace(/[.!?]+$/, "");
180
+ const shape = ONLY_WHEN_ANYWHERE.test(text)
181
+ ? "only_when"
182
+ : NEGATED_UNLESS_ANYWHERE.test(text)
183
+ ? "unless"
184
+ : null;
185
+ if (shape === null)
186
+ return null;
187
+ const scopeMatch = text.match(SCOPE_PREFIX);
188
+ const scope = scopeMatch?.groups?.scope
189
+ ? scopeMatch.groups.scope.toLowerCase()
190
+ : null;
191
+ const body = scopeMatch ? text.slice(scopeMatch[0].length) : text;
192
+ const unparsed = (reason) => ({
193
+ kind: "unparsed",
194
+ shape,
195
+ evidence: text,
196
+ reason,
197
+ });
198
+ let action;
199
+ let conditionText;
200
+ if (shape === "only_when") {
201
+ const match = body.match(ONLY_WHEN);
202
+ const verb = match?.groups?.verbBefore ?? match?.groups?.verbAfter;
203
+ if (!match?.groups?.action || !verb || !match.groups.condition)
204
+ return unparsed("The clause says an action happens only under a condition, but its action could not be read.");
205
+ action = actionName(match.groups.action, verb);
206
+ conditionText = match.groups.condition;
207
+ }
208
+ else {
209
+ const match = body.match(UNLESS);
210
+ if (!match?.groups?.action || !match.groups.verb || !match.groups.condition)
211
+ return unparsed("The clause forbids an action unless a condition holds, but its action could not be read.");
212
+ action = actionName(match.groups.action, match.groups.verb);
213
+ conditionText = match.groups.condition;
214
+ }
215
+ if (!/^[a-z]/.test(action))
216
+ return unparsed("The conditional clause names no action that can become a rule head.");
217
+ const parsed = condition(conditionText);
218
+ if (!parsed)
219
+ return unparsed("The condition is not a single comparison of one subject property (for example 'the cart total is positive'); define its terms before grounding it.");
220
+ const instanceType = parsed.subjectKey;
221
+ const instance = { kind: "var", name: "X", type: instanceType };
222
+ const value = {
223
+ kind: "var",
224
+ name: "V",
225
+ type: parsed.comparison.valueType,
226
+ };
227
+ const ir = {
228
+ version: "kibi.logic.v1",
229
+ kind: "rule",
230
+ modality: "forbid",
231
+ head: { kind: "atom", name: action, args: [instance] },
232
+ body: {
233
+ kind: "atom",
234
+ namespace: parsed.subjectKey,
235
+ name: parsed.propertyKey,
236
+ args: [instance, value],
237
+ },
238
+ exceptions: [
239
+ {
240
+ kind: "compare",
241
+ operator: parsed.comparison.operator,
242
+ left: value,
243
+ right: parsed.comparison.value,
244
+ },
245
+ ],
246
+ variables: [
247
+ { name: "X", type: instanceType },
248
+ { name: "V", type: parsed.comparison.valueType },
249
+ ],
250
+ ...(scope ? { scope: { name: scope } } : {}),
251
+ };
252
+ return {
253
+ kind: "rule",
254
+ shape,
255
+ evidence: text,
256
+ action,
257
+ subjectKey: parsed.subjectKey,
258
+ propertyKey: parsed.propertyKey,
259
+ scope,
260
+ ir,
261
+ };
262
+ }
@@ -13,6 +13,8 @@ type SemanticRelationship = Readonly<{
13
13
  }>;
14
14
  export declare function validateSemanticInventoryBoundary(payload: Payload, relationships: readonly SemanticRelationship[], receipt: SemanticAdvisorReceipt): SemanticInventoryBoundaryResult;
15
15
  export declare function assertSemanticInventoryBoundary(payload: Payload, relationships: readonly SemanticRelationship[], receipt: SemanticAdvisorReceipt): void;
16
- export declare function assertLogicalGroundingClaimKeys(prolog: PrologPort, payload: Payload, relationships: readonly SemanticRelationship[]): Promise<void>;
16
+ export declare function assertLogicalGroundingClaimKeys(prolog: PrologPort, payload: Payload, relationships: readonly SemanticRelationship[], staged?: Readonly<{
17
+ entities: ReadonlyMap<string, Readonly<Record<string, unknown>>>;
18
+ }>): Promise<void>;
17
19
  export {};
18
20
  //# sourceMappingURL=ingestion-boundary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ingestion-boundary.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/ingestion-boundary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,EACL,KAAK,OAAO,EAOb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,sBAAsB,EAAuB,MAAM,YAAY,CAAC;AAgB9E,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,KAAK,oBAAoB,GAAG,QAAQ,CAAC;IACnC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,CAAC,CAAC;AAgCH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,OAAO,EAAE,sBAAsB,GAC9B,+BAA+B,CA0IjC;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,OAAO,EAAE,sBAAsB,GAC9B,IAAI,CAWN;AAGD,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,GAC7C,OAAO,CAAC,IAAI,CAAC,CA+Cf"}
1
+ {"version":3,"file":"ingestion-boundary.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/ingestion-boundary.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,EACL,KAAK,OAAO,EAOb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,sBAAsB,EAAuB,MAAM,YAAY,CAAC;AAgB9E,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,KAAK,oBAAoB,GAAG,QAAQ,CAAC;IACnC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,EAAE,CAAC,EAAE,OAAO,CAAC;CACd,CAAC,CAAC;AAgCH,wBAAgB,iCAAiC,CAC/C,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,OAAO,EAAE,sBAAsB,GAC9B,+BAA+B,CA0IjC;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,OAAO,EAAE,sBAAsB,GAC9B,IAAI,CAWN;AAGD,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,SAAS,oBAAoB,EAAE,EAC9C,MAAM,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CAClE,CAAC,GACD,OAAO,CAAC,IAAI,CAAC,CAsDf"}