kibi-cli 2.4.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 (352) 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 +37 -9
  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 +12 -4
  7. package/dist/cli-operation-metadata.d.ts.map +1 -1
  8. package/dist/cli-operation-metadata.js +14 -4
  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-proof.d.ts.map +1 -1
  13. package/dist/cli-register-proof.js +13 -0
  14. package/dist/commands/check.d.ts.map +1 -1
  15. package/dist/commands/check.js +11 -2
  16. package/dist/commands/discovery-shared.d.ts.map +1 -1
  17. package/dist/commands/discovery-shared.js +8 -2
  18. package/dist/commands/engine.d.ts.map +1 -1
  19. package/dist/commands/engine.js +4 -2
  20. package/dist/commands/gc.d.ts.map +1 -1
  21. package/dist/commands/gc.js +7 -0
  22. package/dist/commands/init-helpers.d.ts.map +1 -1
  23. package/dist/commands/init-helpers.js +0 -1
  24. package/dist/commands/migrate.d.ts.map +1 -1
  25. package/dist/commands/migrate.js +281 -14
  26. package/dist/commands/proof-compact.d.ts +9 -0
  27. package/dist/commands/proof-compact.d.ts.map +1 -0
  28. package/dist/commands/proof-compact.js +58 -0
  29. package/dist/commands/prove.d.ts +38 -0
  30. package/dist/commands/prove.d.ts.map +1 -1
  31. package/dist/commands/prove.js +222 -47
  32. package/dist/commands/sync/persistence.d.ts.map +1 -1
  33. package/dist/commands/sync/persistence.js +61 -16
  34. package/dist/commands/sync.d.ts +8 -0
  35. package/dist/commands/sync.d.ts.map +1 -1
  36. package/dist/commands/sync.js +42 -16
  37. package/dist/diagnostics.js +1 -1
  38. package/dist/engine-limits.d.ts +74 -0
  39. package/dist/engine-limits.d.ts.map +1 -0
  40. package/dist/engine-limits.js +201 -0
  41. package/dist/engine.d.ts +10 -0
  42. package/dist/engine.d.ts.map +1 -1
  43. package/dist/engine.js +57 -9
  44. package/dist/extractors/manifest.d.ts +8 -0
  45. package/dist/extractors/manifest.d.ts.map +1 -1
  46. package/dist/extractors/manifest.js +34 -5
  47. package/dist/extractors/markdown.d.ts +8 -0
  48. package/dist/extractors/markdown.d.ts.map +1 -1
  49. package/dist/extractors/markdown.js +57 -0
  50. package/dist/extractors/relationships.d.ts.map +1 -1
  51. package/dist/extractors/relationships.js +2 -0
  52. package/dist/intent-search.d.ts +4 -1
  53. package/dist/intent-search.d.ts.map +1 -1
  54. package/dist/intent-search.js +186 -33
  55. package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
  56. package/dist/operations/bootstrap/candidate-helpers.js +8 -1
  57. package/dist/operations/bootstrap/candidates.d.ts.map +1 -1
  58. package/dist/operations/bootstrap/candidates.js +54 -38
  59. package/dist/operations/bootstrap/generate.d.ts +2 -0
  60. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  61. package/dist/operations/bootstrap/generate.js +87 -33
  62. package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
  63. package/dist/operations/bootstrap/intent-claims.js +12 -4
  64. package/dist/operations/bootstrap/markdown-candidates.d.ts +2 -0
  65. package/dist/operations/bootstrap/markdown-candidates.d.ts.map +1 -1
  66. package/dist/operations/bootstrap/markdown-candidates.js +32 -10
  67. package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
  68. package/dist/operations/bootstrap/presentation.js +6 -2
  69. package/dist/operations/bootstrap/requirement-claims.d.ts +1 -0
  70. package/dist/operations/bootstrap/requirement-claims.d.ts.map +1 -1
  71. package/dist/operations/bootstrap/requirement-claims.js +13 -1
  72. package/dist/operations/bootstrap/validation.d.ts +4 -0
  73. package/dist/operations/bootstrap/validation.d.ts.map +1 -0
  74. package/dist/operations/bootstrap/validation.js +20 -0
  75. package/dist/operations/migration/inventory-rederive.d.ts +81 -0
  76. package/dist/operations/migration/inventory-rederive.d.ts.map +1 -0
  77. package/dist/operations/migration/inventory-rederive.js +484 -0
  78. package/dist/operations/migration/kb-sources.d.ts +53 -0
  79. package/dist/operations/migration/kb-sources.d.ts.map +1 -0
  80. package/dist/operations/migration/kb-sources.js +233 -0
  81. package/dist/operations/migration/origin-backfill.d.ts +39 -0
  82. package/dist/operations/migration/origin-backfill.d.ts.map +1 -0
  83. package/dist/operations/migration/origin-backfill.js +164 -0
  84. package/dist/operations/migration/polarity-values.d.ts +10 -0
  85. package/dist/operations/migration/polarity-values.d.ts.map +1 -0
  86. package/dist/operations/migration/polarity-values.js +60 -0
  87. package/dist/operations/migration/schema6.d.ts +59 -0
  88. package/dist/operations/migration/schema6.d.ts.map +1 -0
  89. package/dist/operations/migration/schema6.js +379 -0
  90. package/dist/operations/migration/source-paths.d.ts +131 -0
  91. package/dist/operations/migration/source-paths.d.ts.map +1 -0
  92. package/dist/operations/migration/source-paths.js +308 -0
  93. package/dist/operations/migration/superseded-closure.d.ts +54 -0
  94. package/dist/operations/migration/superseded-closure.d.ts.map +1 -0
  95. package/dist/operations/migration/superseded-closure.js +187 -0
  96. package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
  97. package/dist/operations/modeling/logic-modeling.js +3 -5
  98. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  99. package/dist/operations/modeling/model-requirement.js +225 -67
  100. package/dist/operations/mutation/contradictions.d.ts +16 -0
  101. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  102. package/dist/operations/mutation/contradictions.js +32 -0
  103. package/dist/operations/mutation/delete.d.ts.map +1 -1
  104. package/dist/operations/mutation/delete.js +15 -7
  105. package/dist/operations/mutation/origin.d.ts +21 -0
  106. package/dist/operations/mutation/origin.d.ts.map +1 -0
  107. package/dist/operations/mutation/origin.js +78 -0
  108. package/dist/operations/mutation/plan-apply-journal.d.ts +182 -0
  109. package/dist/operations/mutation/plan-apply-journal.d.ts.map +1 -0
  110. package/dist/operations/mutation/plan-apply-journal.js +613 -0
  111. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +3 -1
  112. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -1
  113. package/dist/operations/mutation/predicate-vocabulary-guard.js +13 -2
  114. package/dist/operations/mutation/relationships.d.ts +5 -5
  115. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  116. package/dist/operations/mutation/relationships.js +31 -11
  117. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  118. package/dist/operations/mutation/serialization.js +3 -1
  119. package/dist/operations/mutation/source-authoring.d.ts +6 -0
  120. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  121. package/dist/operations/mutation/source-authoring.js +7 -1
  122. package/dist/operations/mutation/types.d.ts +14 -0
  123. package/dist/operations/mutation/types.d.ts.map +1 -1
  124. package/dist/operations/mutation/upsert.d.ts +30 -3
  125. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  126. package/dist/operations/mutation/upsert.js +105 -35
  127. package/dist/operations/mutation/validate-upsert.d.ts +6 -0
  128. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  129. package/dist/operations/mutation/validate-upsert.js +34 -30
  130. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  131. package/dist/operations/planning/apply-plan.js +751 -144
  132. package/dist/operations/planning/compile-intent.d.ts +34 -1
  133. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  134. package/dist/operations/planning/compile-intent.js +314 -98
  135. package/dist/operations/proof/code-scope.d.ts +28 -0
  136. package/dist/operations/proof/code-scope.d.ts.map +1 -1
  137. package/dist/operations/proof/code-scope.js +72 -0
  138. package/dist/operations/proof/compact-receipts.d.ts +49 -0
  139. package/dist/operations/proof/compact-receipts.d.ts.map +1 -0
  140. package/dist/operations/proof/compact-receipts.js +160 -0
  141. package/dist/operations/proof/ingest-proof.d.ts +2 -0
  142. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  143. package/dist/operations/proof/ingest-proof.js +44 -23
  144. package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
  145. package/dist/operations/proof/prune-receipts.js +5 -9
  146. package/dist/operations/proof/receipt-compaction.d.ts +48 -0
  147. package/dist/operations/proof/receipt-compaction.d.ts.map +1 -0
  148. package/dist/operations/proof/receipt-compaction.js +121 -0
  149. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  150. package/dist/operations/semantic-advisor/analysis-receipt.js +12 -1
  151. package/dist/operations/semantic-advisor/analyze-prose.d.ts +2 -1
  152. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  153. package/dist/operations/semantic-advisor/analyze-prose.js +51 -5
  154. package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
  155. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  156. package/dist/operations/semantic-advisor/clauses.js +11 -1
  157. package/dist/operations/semantic-advisor/conditional-rules.d.ts +33 -0
  158. package/dist/operations/semantic-advisor/conditional-rules.d.ts.map +1 -0
  159. package/dist/operations/semantic-advisor/conditional-rules.js +262 -0
  160. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +3 -1
  161. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
  162. package/dist/operations/semantic-advisor/ingestion-boundary.js +14 -6
  163. package/dist/operations/semantic-advisor/plugin-orchestration.js +1 -1
  164. package/dist/prolog/codec.d.ts.map +1 -1
  165. package/dist/prolog/codec.js +2 -1
  166. package/dist/prolog.d.ts +9 -0
  167. package/dist/prolog.d.ts.map +1 -1
  168. package/dist/prolog.js +56 -10
  169. package/dist/proof/command-test-report.d.ts +74 -0
  170. package/dist/proof/command-test-report.d.ts.map +1 -0
  171. package/dist/proof/command-test-report.js +206 -0
  172. package/dist/public/branch-resolver.d.ts +1 -0
  173. package/dist/public/branch-resolver.d.ts.map +1 -1
  174. package/dist/public/branch-resolver.js +1 -0
  175. package/dist/public/entity-origin.d.ts +69 -0
  176. package/dist/public/entity-origin.d.ts.map +1 -0
  177. package/dist/public/entity-origin.js +142 -0
  178. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  179. package/dist/public/impact/full-kb-quality.js +1 -0
  180. package/dist/public/impact/requirement-quality.js +1 -1
  181. package/dist/public/operations/catalog.d.ts +130 -19
  182. package/dist/public/operations/catalog.d.ts.map +1 -1
  183. package/dist/public/operations/catalog.js +3 -0
  184. package/dist/public/operations/check-executor.d.ts.map +1 -1
  185. package/dist/public/operations/check-executor.js +8 -0
  186. package/dist/public/operations/contracts.d.ts +0 -5
  187. package/dist/public/operations/contracts.d.ts.map +1 -1
  188. package/dist/public/operations/contracts.js +63 -14
  189. package/dist/public/operations/discovery-entities.d.ts +15 -0
  190. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  191. package/dist/public/operations/discovery-entities.js +59 -0
  192. package/dist/public/operations/discovery-executors.d.ts +6 -1
  193. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  194. package/dist/public/operations/discovery-executors.js +65 -6
  195. package/dist/public/operations/index.d.ts +1 -0
  196. package/dist/public/operations/index.d.ts.map +1 -1
  197. package/dist/public/operations/index.js +1 -0
  198. package/dist/public/operations/migration-plan.d.ts +5 -0
  199. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  200. package/dist/public/operations/migration-plan.js +26 -1
  201. package/dist/public/operations/node-ports.d.ts.map +1 -1
  202. package/dist/public/operations/node-ports.js +24 -3
  203. package/dist/public/operations/origin-review.d.ts +51 -0
  204. package/dist/public/operations/origin-review.d.ts.map +1 -0
  205. package/dist/public/operations/origin-review.js +307 -0
  206. package/dist/public/operations/predicate-schema-conformance.js +1 -1
  207. package/dist/public/operations/repair-plan.d.ts.map +1 -1
  208. package/dist/public/operations/repair-plan.js +4 -0
  209. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  210. package/dist/public/operations/result-envelope.js +17 -5
  211. package/dist/public/operations/runtime-types.d.ts +9 -0
  212. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  213. package/dist/public/operations/schema6-check-actions.d.ts +127 -0
  214. package/dist/public/operations/schema6-check-actions.d.ts.map +1 -0
  215. package/dist/public/operations/schema6-check-actions.js +575 -0
  216. package/dist/public/operations/source-path-dangling.d.ts +17 -0
  217. package/dist/public/operations/source-path-dangling.d.ts.map +1 -0
  218. package/dist/public/operations/source-path-dangling.js +66 -0
  219. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  220. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  221. package/dist/public/operations/specs/check-rules.generated.js +15 -1
  222. package/dist/public/operations/specs/check.d.ts +2 -2
  223. package/dist/public/operations/specs/check.js +1 -1
  224. package/dist/public/operations/specs/composite.d.ts +351 -0
  225. package/dist/public/operations/specs/composite.d.ts.map +1 -0
  226. package/dist/public/operations/specs/composite.js +96 -0
  227. package/dist/public/operations/specs/discovery.d.ts +8 -3
  228. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  229. package/dist/public/operations/specs/discovery.js +8 -3
  230. package/dist/public/operations/specs/modeling.d.ts +2 -2
  231. package/dist/public/operations/specs/modeling.js +2 -2
  232. package/dist/public/operations/specs/mutation-schemas.d.ts +73 -8
  233. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  234. package/dist/public/operations/specs/mutation-schemas.js +43 -7
  235. package/dist/public/operations/specs/mutation.d.ts +1 -1
  236. package/dist/public/operations/specs/mutation.js +1 -1
  237. package/dist/public/operations/specs/planning.d.ts +2 -2
  238. package/dist/public/operations/specs/planning.js +4 -4
  239. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  240. package/dist/public/operations/specs/reporting.js +13 -26
  241. package/dist/public/operations/specs/upsert.d.ts +79 -9
  242. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  243. package/dist/public/operations/specs/upsert.js +6 -1
  244. package/dist/public/operations/types.d.ts +1 -1
  245. package/dist/public/operations/types.d.ts.map +1 -1
  246. package/dist/public/proof-receipt.d.ts +1 -0
  247. package/dist/public/proof-receipt.d.ts.map +1 -1
  248. package/dist/public/schemas/entity.d.ts.map +1 -1
  249. package/dist/public/schemas/entity.js +52 -0
  250. package/dist/public/schemas/relationship.d.ts.map +1 -1
  251. package/dist/public/schemas/relationship.js +2 -0
  252. package/dist/public/skills/kibi-bootstrap/SKILL.md +6 -1
  253. package/dist/public/skills/kibi-bootstrap/resources/bootstrap.md +6 -0
  254. package/dist/public/skills/kibi-usage/SKILL.md +68 -18
  255. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
  256. package/dist/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
  257. package/dist/public/skills/kibi-usage/resources/logic-ir.md +2 -2
  258. package/dist/public/skills/kibi-usage/resources/operation-access.md +25 -1
  259. package/dist/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
  260. package/dist/public/skills/kibi-usage/resources/workflows.md +42 -25
  261. package/dist/public/telemetry-acceptance.d.ts +58 -2
  262. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  263. package/dist/public/telemetry-acceptance.js +136 -10
  264. package/dist/public/telemetry-remediation.d.ts.map +1 -1
  265. package/dist/public/telemetry-remediation.js +26 -10
  266. package/dist/relationships/shards.d.ts +13 -0
  267. package/dist/relationships/shards.d.ts.map +1 -1
  268. package/dist/relationships/shards.js +54 -28
  269. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  270. package/dist/runtime/cli-runtime.js +44 -3
  271. package/dist/runtime/detached-snapshot.d.ts +38 -0
  272. package/dist/runtime/detached-snapshot.d.ts.map +1 -0
  273. package/dist/runtime/detached-snapshot.js +92 -0
  274. package/dist/schemas/entity.schema.json +122 -0
  275. package/dist/search-answer.d.ts +157 -0
  276. package/dist/search-answer.d.ts.map +1 -0
  277. package/dist/search-answer.js +846 -0
  278. package/dist/traceability/impact-knowledge.d.ts.map +1 -1
  279. package/dist/traceability/impact-knowledge.js +7 -0
  280. package/dist/traceability/symbol-extract.js +3 -3
  281. package/dist/traceability/temp-kb.d.ts.map +1 -1
  282. package/dist/traceability/temp-kb.js +12 -0
  283. package/dist/types/entities.d.ts +13 -0
  284. package/dist/types/entities.d.ts.map +1 -1
  285. package/dist/types/relationships.d.ts +1 -1
  286. package/dist/types/relationships.d.ts.map +1 -1
  287. package/dist/utils/branch-resolver.d.ts +37 -1
  288. package/dist/utils/branch-resolver.d.ts.map +1 -1
  289. package/dist/utils/branch-resolver.js +130 -3
  290. package/dist/utils/repo-relative-path.d.ts +18 -0
  291. package/dist/utils/repo-relative-path.d.ts.map +1 -0
  292. package/dist/utils/repo-relative-path.js +58 -0
  293. package/dist/utils/rule-registry.generated.d.ts +75 -3
  294. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  295. package/dist/utils/rule-registry.generated.js +89 -3
  296. package/dist/utils/schema-version.d.ts +1 -1
  297. package/dist/utils/schema-version.d.ts.map +1 -1
  298. package/dist/utils/schema-version.js +4 -3
  299. package/dist/utils/strict-modeling.d.ts +1 -1
  300. package/dist/utils/strict-modeling.d.ts.map +1 -1
  301. package/dist/utils/strict-modeling.js +23 -3
  302. package/package.json +3 -3
  303. package/schema/entities.pl +22 -0
  304. package/schema/relationships.pl +14 -0
  305. package/schema/validation.pl +45 -1
  306. package/src/public/branch-resolver.ts +1 -0
  307. package/src/public/entity-origin.ts +175 -0
  308. package/src/public/impact/full-kb-quality.ts +1 -0
  309. package/src/public/impact/requirement-quality.ts +1 -1
  310. package/src/public/operations/catalog.ts +3 -0
  311. package/src/public/operations/check-executor.ts +15 -0
  312. package/src/public/operations/contracts.ts +75 -15
  313. package/src/public/operations/discovery-entities.ts +74 -0
  314. package/src/public/operations/discovery-executors.ts +88 -10
  315. package/src/public/operations/index.ts +1 -0
  316. package/src/public/operations/migration-plan.ts +30 -1
  317. package/src/public/operations/node-ports.ts +24 -3
  318. package/src/public/operations/origin-review.ts +375 -0
  319. package/src/public/operations/predicate-schema-conformance.ts +1 -1
  320. package/src/public/operations/repair-plan.ts +4 -0
  321. package/src/public/operations/result-envelope.ts +18 -6
  322. package/src/public/operations/runtime-types.ts +9 -0
  323. package/src/public/operations/schema6-check-actions.ts +699 -0
  324. package/src/public/operations/source-path-dangling.ts +81 -0
  325. package/src/public/operations/specs/check-rules.generated.ts +15 -1
  326. package/src/public/operations/specs/check.ts +1 -1
  327. package/src/public/operations/specs/composite.ts +141 -0
  328. package/src/public/operations/specs/discovery.ts +9 -3
  329. package/src/public/operations/specs/modeling.ts +2 -2
  330. package/src/public/operations/specs/mutation-schemas.ts +49 -7
  331. package/src/public/operations/specs/mutation.ts +1 -1
  332. package/src/public/operations/specs/planning.ts +4 -4
  333. package/src/public/operations/specs/reporting.ts +13 -38
  334. package/src/public/operations/specs/upsert.ts +7 -1
  335. package/src/public/operations/types.ts +2 -0
  336. package/src/public/proof-receipt.ts +1 -0
  337. package/src/public/schemas/entity.ts +57 -0
  338. package/src/public/schemas/relationship.ts +2 -0
  339. package/src/public/skills/kibi-bootstrap/SKILL.md +6 -1
  340. package/src/public/skills/kibi-bootstrap/resources/bootstrap.md +6 -0
  341. package/src/public/skills/kibi-usage/SKILL.md +68 -18
  342. package/src/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
  343. package/src/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
  344. package/src/public/skills/kibi-usage/resources/logic-ir.md +2 -2
  345. package/src/public/skills/kibi-usage/resources/operation-access.md +25 -1
  346. package/src/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
  347. package/src/public/skills/kibi-usage/resources/workflows.md +42 -25
  348. package/src/public/telemetry-acceptance-types.d.ts +4 -1
  349. package/src/public/telemetry-acceptance.ts +204 -10
  350. package/src/public/telemetry-remediation.ts +39 -10
  351. package/src/schemas/entity.schema.json +122 -0
  352. package/src/schemas/relationship.schema.json +2 -0
@@ -0,0 +1,81 @@
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
+
19
+ import {
20
+ type SourceRepair,
21
+ findDanglingSources,
22
+ shownSourceValue,
23
+ } from "../../operations/migration/source-paths.js";
24
+ import type { Violation } from "../../utils/rule-registry.js";
25
+
26
+ /** An authored source field that names no path, entity or URL. */
27
+ // implements REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
28
+ export const SOURCE_PATH_DANGLING_RULE = "source-path-dangling";
29
+
30
+ function suggestion(source: SourceRepair): string {
31
+ const compiled = `The compiled source is always the entity's own file (${source.file}), so the field carries nothing Kibi compiles.`;
32
+ if (source.refused !== undefined) {
33
+ return `kibi migrate cannot edit this source field safely (${source.refused}), so it plans a review_source_path_dangling action for a person. ${compiled}`;
34
+ }
35
+ if (source.fix.kind === "rewrite") {
36
+ return `The file moved to ${source.fix.to}; kibi migrate rewrites the source field there (source_path_rewrite). ${compiled}`;
37
+ }
38
+ const why =
39
+ source.fix.reason === "self"
40
+ ? "it names the entity's own file"
41
+ : "nothing it names can be mapped";
42
+ return `kibi migrate removes this source field (source_path_rewrite) because ${why}. ${compiled}`;
43
+ }
44
+
45
+ /**
46
+ * One blocking finding per authored source that resolves to nothing. The
47
+ * evidence names the automatic fix (`rewrite` or `remove`) and, when the
48
+ * edit is not safe, why (`refused`).
49
+ */
50
+ // implements REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
51
+ export function sourcePathDanglingViolations(
52
+ dangling: readonly SourceRepair[],
53
+ ): Violation[] {
54
+ return dangling.map((source) => ({
55
+ rule: SOURCE_PATH_DANGLING_RULE,
56
+ entityId: source.entityId,
57
+ description: `${source.entityId} names source '${shownSourceValue(source.value)}', which is not an existing workspace path, an entity id or an http(s) URL`,
58
+ suggestion: suggestion(source),
59
+ source: source.file,
60
+ evidence: {
61
+ value: source.value,
62
+ file: source.file,
63
+ ...(source.fix.kind === "rewrite"
64
+ ? { rewrite: source.fix.to }
65
+ : { remove: source.fix.reason }),
66
+ ...(source.refused !== undefined ? { refused: source.refused } : {}),
67
+ },
68
+ }));
69
+ }
70
+
71
+ /**
72
+ * Read the authored `source` field of every entity file once and report the
73
+ * values that resolve to nothing. The compiled `source` (the entity's own
74
+ * file) always resolves, so the check reads authored frontmatter.
75
+ */
76
+ // implements REQ-core-validation-rules, REQ-kibi-kb-lifecycle-integrity
77
+ export function collectSourcePathDanglingViolations(
78
+ workspaceRoot: string,
79
+ ): Violation[] {
80
+ return sourcePathDanglingViolations(findDanglingSources(workspaceRoot));
81
+ }
@@ -15,9 +15,16 @@ export const SELECTABLE_RULE_NAMES: readonly string[] = [
15
15
  "symbol-traceability",
16
16
  "no-dangling-refs",
17
17
  "source-relationship-parity",
18
+ "source-path-dangling",
18
19
  "no-cycles",
19
20
  "required-fields",
20
21
  "deprecated-adr-no-successor",
22
+ "superseded-requirement-open",
23
+ "scenario-feasibility",
24
+ "scenario-feasibility-unknown",
25
+ "exception-claim-keys",
26
+ "numeric-string-value",
27
+ "rule-key-arguments-missing",
21
28
  "domain-contradictions",
22
29
  "logic-coverage",
23
30
  "rule-safety",
@@ -36,10 +43,17 @@ export const SELECTABLE_RULE_NAMES: readonly string[] = [
36
43
  "subject-key-identity",
37
44
  "subject-key-shape",
38
45
  "ontology-quality",
46
+ "exception-unapproved",
47
+ "exception-approval-self-attested",
48
+ "agent-requirement-unapproved",
49
+ "requirement-rationale-missing",
50
+ "symbol-owner-superseded",
51
+ "adr-unlinked",
52
+ "adr-proposed",
39
53
  "predicate-schema-conformance",
40
54
  ];
41
55
 
42
56
  // implements REQ-006
43
57
  /** Comma-separated "Allowed:" fragment for the kb_check rules description. */
44
58
  export const SELECTABLE_RULES_ALLOWED =
45
- "must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, no-cycles, required-fields, deprecated-adr-no-successor, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, predicate-schema-conformance";
59
+ "must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, source-relationship-parity, source-path-dangling, no-cycles, required-fields, deprecated-adr-no-successor, superseded-requirement-open, scenario-feasibility, scenario-feasibility-unknown, exception-claim-keys, numeric-string-value, rule-key-arguments-missing, domain-contradictions, logic-coverage, rule-safety, rule-verifiability, query-plan-safety, req-status-vocabulary, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, strict-readiness, semantic-completeness, proof-contract-symbols, entity-id-style, domain-redundancy, domain-implication, subject-key-identity, subject-key-shape, ontology-quality, exception-unapproved, exception-approval-self-attested, agent-requirement-unapproved, requirement-rationale-missing, symbol-owner-superseded, adr-unlinked, adr-proposed, predicate-schema-conformance";
@@ -57,7 +57,7 @@ export const checkSpec = {
57
57
  type: "boolean",
58
58
  default: false,
59
59
  description:
60
- "When true, start the check as a background job and return a kibi.job.v1 receipt immediately instead of holding the request until the tool timeout. Poll kb_job_status with the returned jobId. Use for full checks on large KBs that exceed the configured tool timeout.",
60
+ "When true, start the check as a background job and return a kibi.job.v1 receipt immediately instead of holding the request until the tool timeout. Poll kb_job_status with the returned jobId. Use for full checks on large KBs that exceed the configured tool timeout. The MCP server registers kb_job_status only when KIBI_MCP_OPTIONAL_TOOLS includes it; otherwise async runs the check synchronously.",
61
61
  },
62
62
  },
63
63
  },
@@ -0,0 +1,141 @@
1
+ import type { OperationContext } from "../runtime-types.js";
2
+ import type { OperationResult, OperationSpec } from "../types.js";
3
+ import { modelRequirementSpec, suggestPredicatesSpec } from "./modeling.js";
4
+ import { semanticAdvisorSpec } from "./semantic.js";
5
+ import { skillsListSpec, skillsLoadSpec, skillsReadSpec } from "./skills.js";
6
+
7
+ // implements REQ-kibi-mcp-tool-consolidation
8
+ /**
9
+ * Composite operations keep the agent-facing tool list short. Each one
10
+ * dispatches to an existing operation by `action` or `mode` and returns that
11
+ * operation's payload unchanged plus the selector, so the narrower CLI routes
12
+ * and the composite tool always agree.
13
+ */
14
+ type Executor = (input: never, context: OperationContext) => Promise<unknown>;
15
+
16
+ function properties(spec: {
17
+ readonly businessInputSchema: Readonly<Record<string, unknown>>;
18
+ }): Readonly<Record<string, unknown>> {
19
+ const props = spec.businessInputSchema.properties;
20
+ return props && typeof props === "object"
21
+ ? (props as Readonly<Record<string, unknown>>)
22
+ : {};
23
+ }
24
+
25
+ function requiredFields(spec: {
26
+ readonly businessInputSchema: Readonly<Record<string, unknown>>;
27
+ }): readonly string[] {
28
+ const required = spec.businessInputSchema.required;
29
+ return Array.isArray(required) ? (required as string[]) : [];
30
+ }
31
+
32
+ export async function dispatchComposite(
33
+ selector: "action" | "mode",
34
+ routes: Readonly<
35
+ Record<
36
+ string,
37
+ {
38
+ readonly execute: Executor;
39
+ readonly businessInputSchema: Readonly<Record<string, unknown>>;
40
+ }
41
+ >
42
+ >,
43
+ input: Readonly<Record<string, unknown>>,
44
+ context: OperationContext,
45
+ ): Promise<OperationResult<Record<string, unknown>>> {
46
+ const choice = input[selector];
47
+ const route = typeof choice === "string" ? routes[choice] : undefined;
48
+ if (route === undefined) {
49
+ throw new Error(
50
+ `${selector} must be one of: ${Object.keys(routes).join(", ")}`,
51
+ );
52
+ }
53
+ const { [selector]: _selector, ...rest } = input;
54
+ for (const field of requiredFields(route)) {
55
+ if (rest[field] === undefined) {
56
+ throw new Error(`${field} is required when ${selector} is ${choice}`);
57
+ }
58
+ }
59
+ const result = await route.execute(rest as never, context);
60
+ // Routed executors return an OperationResult; host adapters may hand back
61
+ // the bare payload, which is used as-is.
62
+ const isRecord = (value: unknown): value is Record<string, unknown> =>
63
+ value !== null && typeof value === "object" && !Array.isArray(value);
64
+ const wrapped =
65
+ isRecord(result) && ("structuredContent" in result || "content" in result);
66
+ const structured = wrapped ? result.structuredContent : result;
67
+ const payload = isRecord(structured) ? structured : {};
68
+ const content =
69
+ wrapped && Array.isArray(result.content)
70
+ ? (result.content as OperationResult["content"])
71
+ : [{ type: "text", text: `${selector} ${String(choice)} completed` }];
72
+ return {
73
+ content,
74
+ structuredContent: { [selector]: choice, ...payload },
75
+ };
76
+ }
77
+
78
+ // implements REQ-kibi-mcp-tool-consolidation
79
+ export const SKILL_ROUTES = {
80
+ list: skillsListSpec,
81
+ load: skillsLoadSpec,
82
+ read: skillsReadSpec,
83
+ } as const;
84
+
85
+ // implements REQ-kibi-mcp-tool-consolidation
86
+ export const MODEL_ROUTES = {
87
+ analyze: semanticAdvisorSpec,
88
+ requirement: modelRequirementSpec,
89
+ predicates: suggestPredicatesSpec,
90
+ } as const;
91
+
92
+ // implements REQ-kibi-mcp-tool-consolidation
93
+ export const skillsSpec = {
94
+ name: "kb_skills",
95
+ cliName: "skill",
96
+ description:
97
+ "Read bundled Kibi agent skills (workflow guidance). action:list returns the catalog; action:load returns a skill's metadata, Markdown body, declared resources and content hash (start with id 'kibi-usage'); action:read returns one manifest-declared resource. Read-only; does not require Prolog.",
98
+ businessInputSchema: {
99
+ type: "object",
100
+ required: ["action"],
101
+ properties: {
102
+ action: {
103
+ type: "string",
104
+ enum: ["list", "load", "read"],
105
+ description: "list, load (needs id) or read (needs id and resource).",
106
+ },
107
+ ...properties(skillsReadSpec),
108
+ },
109
+ },
110
+ requiresProlog: false,
111
+ effects: ["local-read"],
112
+ execute: (input, context) =>
113
+ dispatchComposite("action", SKILL_ROUTES, input, context),
114
+ } as const satisfies OperationSpec;
115
+
116
+ // implements REQ-kibi-mcp-tool-consolidation
117
+ export const modelSpec = {
118
+ name: "kb_model",
119
+ cliName: "model",
120
+ description:
121
+ "Turn requirement prose into checkable structure without writing the KB. mode:analyze returns the semantic advisor receipt: the clause ledger, what is grounded, what is ambiguous and suggested modeling (pass clauses for compound prose and optional typed kibi.logic.v1 interpretations). mode:requirement converts one claim (subjectKey, propertyKey, operator, value, or typed logic) into a strict-lane write set and applyPlan. mode:predicates ranks ontology predicate schemas and returns an applicable predicate-fact plan only for reviewed bindings, otherwise an ontology-gap observation. Apply returned plans with kb_upsert.",
122
+ businessInputSchema: {
123
+ type: "object",
124
+ required: ["mode", "text"],
125
+ properties: {
126
+ mode: {
127
+ type: "string",
128
+ enum: ["analyze", "requirement", "predicates"],
129
+ description:
130
+ "analyze (advisor receipt), requirement (strict claim write set) or predicates (ontology predicate plan).",
131
+ },
132
+ ...properties(semanticAdvisorSpec),
133
+ ...properties(suggestPredicatesSpec),
134
+ ...properties(modelRequirementSpec),
135
+ },
136
+ },
137
+ requiresProlog: true,
138
+ effects: ["kb-read"],
139
+ execute: (input, context) =>
140
+ dispatchComposite("mode", MODEL_ROUTES, input, context),
141
+ } as const satisfies OperationSpec;
@@ -78,7 +78,7 @@ export const searchSpec = {
78
78
  name: "kb_search",
79
79
  cliName: "search",
80
80
  description:
81
- "Search KB entities for discovery using legacy lexical ranking or deterministic intent-v1 ranking. Intent mode accepts host-agent semantic facets and source locations, returns evidence and abstains below its confidence threshold. Use for exploratory lookup before exact follow-up with kb_query. No mutation side effects.",
81
+ "Ask the KB a question or search it. Default intent-v1 ranking accepts questions, host-agent semantic facets and changed-code source locations, returns evidence, abstains below its confidence threshold and adds an answer layer: the current requirements that govern the topic, what must stay true (linked facts), why (ADRs) and what verifies it (scenarios, tests). Use before changing behavior, then kb_query for exact follow-up. No mutation side effects.",
82
82
  businessInputSchema: {
83
83
  type: "object",
84
84
  required: ["query"],
@@ -111,9 +111,15 @@ export const searchSpec = {
111
111
  rankingMode: {
112
112
  type: "string",
113
113
  enum: ["legacy", "intent-v1"],
114
- default: "legacy",
114
+ default: "intent-v1",
115
115
  description:
116
- "Optional deterministic ranking mode. Omit for backward-compatible lexical search; use intent-v1 for semantic facets, source-aware evidence, graph boosts, and abstention.",
116
+ "Optional deterministic ranking mode. Default intent-v1: question-aware ranking with semantic facets, source-aware evidence, graph boosts, superseded demotion and abstention. Use legacy for the older lexical ranking.",
117
+ },
118
+ answer: {
119
+ type: "boolean",
120
+ default: true,
121
+ description:
122
+ "Intent-v1 only, first page only. When true (default) the result includes an answer layer: current governing requirements with their linked facts, scenarios, tests and ADRs, superseded requirements listed separately, and observation facts labelled as notes. Bounded in size; discovery, not proof.",
117
123
  },
118
124
  semanticFacets: {
119
125
  type: "object",
@@ -55,9 +55,9 @@ export const modelRequirementSpec = {
55
55
  },
56
56
  operator: {
57
57
  type: "string",
58
- enum: ["eq", "gte", "lte", "neq", "bool", "polarity"],
58
+ enum: ["eq", "gt", "gte", "lt", "lte", "neq", "bool", "polarity"],
59
59
  description:
60
- "Optional extracted semantic claim operator. Example: 'eq'.",
60
+ "Optional extracted semantic claim operator. Use gt/lt for strict bounds ('greater than zero' is gt 0, not gte 0). Example: 'eq'.",
61
61
  },
62
62
  value: {
63
63
  description:
@@ -1,3 +1,4 @@
1
+ import { ENTITY_ORIGIN_SCHEMA } from "../../entity-origin.js";
1
2
  import {
2
3
  PROOF_BINDINGS_SCHEMA,
3
4
  PROOF_CONTRACT_SCHEMA,
@@ -76,6 +77,11 @@ export const ENTITY_PROPERTIES_SCHEMA = {
76
77
  description:
77
78
  "Optional text anchor/reference. Example: 'requirements.md#L40'.",
78
79
  },
80
+ origin: {
81
+ ...ENTITY_ORIGIN_SCHEMA,
82
+ description:
83
+ "Optional provenance: who authored the entity (kind: human, agent, migration, import) and on what authority (ref, approved_by, recorded_at). Omit it to keep an existing entity's origin; a new entity written without one is recorded as {kind: agent, recorded_at: <write time>}. A supplied origin without recorded_at gets the write time.",
84
+ },
79
85
  semantic_text: {
80
86
  type: "string",
81
87
  description:
@@ -87,20 +93,20 @@ export const ENTITY_PROPERTIES_SCHEMA = {
87
93
  uniqueItems: true,
88
94
  items: { type: "string", pattern: "^CLAIM-[A-F0-9]{16}$" },
89
95
  description:
90
- "Requirement-only manifest of every atomic normative claim key returned by kb_semantic_advisor. A requirement is logic-complete only when every key is grounded by a linked property_value or predicate fact with the same claim_key.",
96
+ "Requirement-only manifest of every atomic normative claim key returned by kb_model mode analyze (CLI: semantic-advisor). A requirement is logic-complete only when every key is grounded by a linked property_value or predicate fact with the same claim_key.",
91
97
  },
92
98
  semantic_clauses: {
93
99
  type: "array",
94
100
  minItems: 1,
95
101
  items: { type: "string", minLength: 1 },
96
102
  description:
97
- "Optional complete atomic decomposition used by kb_semantic_advisor and proposition-complete ingestion. Preserve it when automatic sentence splitting needs a reviewed override.",
103
+ "Optional complete atomic decomposition used by kb_model mode analyze and proposition-complete ingestion. Preserve it when automatic sentence splitting needs a reviewed override.",
98
104
  },
99
105
  semantic_inventory_version: {
100
106
  type: "string",
101
107
  const: "kibi.semantic-inventory.v1",
102
108
  description:
103
- "Requirement-only proposition ledger contract version returned by kb_semantic_advisor.",
109
+ "Requirement-only proposition ledger contract version returned by kb_model mode analyze (CLI: semantic-advisor).",
104
110
  },
105
111
  semantic_source_field: {
106
112
  type: "string",
@@ -108,6 +114,32 @@ export const ENTITY_PROPERTIES_SCHEMA = {
108
114
  description:
109
115
  "Requirement field whose exact UTF-8 bytes anchor semantic_inventory spans.",
110
116
  },
117
+ approved_by: {
118
+ type: "string",
119
+ minLength: 1,
120
+ description:
121
+ "Requirement-only. The human who approved this exception requirement. An exception that exempts a requirement and is specified_by a success scenario makes that scenario feasible only when approved_by is set.",
122
+ },
123
+ approval_ref: {
124
+ type: "string",
125
+ minLength: 1,
126
+ description:
127
+ "Requirement-only. Optional reference to the exception's approval decision record.",
128
+ },
129
+ rationale: {
130
+ type: "string",
131
+ minLength: 1,
132
+ description:
133
+ "Requirement-only. Why the requirement exists, in one or two sentences from whoever stated the intent; not part of the checked meaning.",
134
+ },
135
+ exempts_claims: {
136
+ type: "array",
137
+ minItems: 1,
138
+ uniqueItems: true,
139
+ items: { type: "string", pattern: "^CLAIM-[A-F0-9]{16}$" },
140
+ description:
141
+ "Requirement-only. Claim keys of the exempted requirement whose constraints this exception waives; omit to waive the whole requirement.",
142
+ },
111
143
  semantic_source_hash: {
112
144
  type: "string",
113
145
  pattern: "^[a-f0-9]{64}$",
@@ -186,7 +218,7 @@ export const ENTITY_PROPERTIES_SCHEMA = {
186
218
  "rule",
187
219
  ],
188
220
  description:
189
- "Optional fact lane kind for fact entities. Strict lane uses 'subject' and 'property_value'; context lane uses 'observation' or 'meta'; ontology lane uses 'predicate_schema' or 'predicate'. Use kb_model_requirement or kb_suggest_predicates when starting from prose.",
221
+ "Optional fact lane kind for fact entities. Strict lane uses 'subject' and 'property_value'; context lane uses 'observation' or 'meta'; ontology lane uses 'predicate_schema' or 'predicate'. Use kb_model (mode requirement or predicates) when starting from prose.",
190
222
  },
191
223
  subject_key: {
192
224
  type: "string",
@@ -263,13 +295,13 @@ export const ENTITY_PROPERTIES_SCHEMA = {
263
295
  predicate_name: {
264
296
  type: "string",
265
297
  description:
266
- "Optional predicate name for ontology predicate facts. Prefer kb_suggest_predicates before hand-writing predicate_name.",
298
+ "Optional predicate name for ontology predicate facts. Prefer kb_model mode predicates before hand-writing predicate_name.",
267
299
  },
268
300
  predicate_args: {
269
301
  type: "array",
270
302
  items: { type: "string" },
271
303
  description:
272
- "Optional ordered predicate arguments for ontology predicate facts. Prefer kb_suggest_predicates before hand-writing predicate_args.",
304
+ "Optional ordered predicate arguments for ontology predicate facts. Prefer kb_model mode predicates before hand-writing predicate_args.",
273
305
  },
274
306
  predicate_namespace: {
275
307
  type: "string",
@@ -295,6 +327,14 @@ export const ENTITY_PROPERTIES_SCHEMA = {
295
327
  items: { type: "string" },
296
328
  description: "Optional ordered argument explanations.",
297
329
  },
330
+ key_arguments: {
331
+ type: "array",
332
+ items: { type: "string", minLength: 1 },
333
+ minItems: 1,
334
+ uniqueItems: true,
335
+ description:
336
+ 'predicate_schema only: argument names that determine the remaining arguments (a functional dependency), e.g. ["sensor"] for reading(sensor, value). Rule contradiction analysis treats two atoms with identical keys as the same fact; without it the predicate is multivalued and opposing rules stay unresolved instead of disjoint.',
337
+ },
298
338
  argument_constants: {
299
339
  type: "object",
300
340
  additionalProperties: {
@@ -327,7 +367,7 @@ export const ENTITY_PROPERTIES_SCHEMA = {
327
367
  semantic_inventory: {
328
368
  type: "array",
329
369
  description:
330
- "Requirement proposition ledger returned by kb_semantic_advisor; preserve entries while modeling each assertive span.",
370
+ "Requirement proposition ledger returned by kb_model mode analyze (CLI: semantic-advisor); preserve entries while modeling each assertive span.",
331
371
  items: { type: "object" },
332
372
  },
333
373
  rule_ir: {
@@ -391,6 +431,8 @@ export const RELATIONSHIPS_SCHEMA = {
391
431
  "consumes",
392
432
  "supersedes",
393
433
  "restates",
434
+ "assumes",
435
+ "exempts",
394
436
  "relates_to",
395
437
  ],
396
438
  description:
@@ -15,7 +15,7 @@ export const validateUpsertSpec = {
15
15
  name: "kb_validate_upsert",
16
16
  cliName: "validate-upsert",
17
17
  description:
18
- "Validate a kb_upsert payload without mutating the KB. Use this read-only preflight before kb_upsert, especially for requirements, because it returns schema/modeling errors plus semantic advisor receipts that identify prose likely needing kb_model_requirement, kb_suggest_predicates, ambiguity review, or an ontology-gap observation.",
18
+ "Validate a kb_upsert payload without mutating the KB. Use this read-only preflight before kb_upsert, especially for requirements, because it returns schema/modeling errors plus semantic advisor receipts that identify prose likely needing kb_model mode requirement or predicates, ambiguity review, or an ontology-gap observation.",
19
19
  businessInputSchema: {
20
20
  type: "object",
21
21
  required: ["type", "id", "properties"],
@@ -27,7 +27,7 @@ export type { MigrationPlan } from "../migration-plan.js";
27
27
  export { executeApplyPlan } from "../../../operations/planning/apply-plan.js";
28
28
  export { executeCompileIntent } from "../../../operations/planning/compile-intent.js";
29
29
 
30
- // implements REQ-kibi-change-to-proof-plan-compiler
30
+ // implements REQ-kibi-change-to-proof-plan-compiler-v2
31
31
  export const compileIntentSpec = {
32
32
  name: "kb_compile_intent",
33
33
  cliName: "compile-intent",
@@ -184,12 +184,12 @@ export const compileIntentSpec = {
184
184
  execute: executeCompileIntent,
185
185
  } as const satisfies OperationSpec<CompileIntentArgs, CompilePlanV1>;
186
186
 
187
- // implements REQ-kibi-change-to-proof-plan-compiler
187
+ // implements REQ-kibi-change-to-proof-plan-compiler-v2
188
188
  export const applyPlanSpec = {
189
189
  name: "kb_apply_plan",
190
190
  cliName: "apply-plan",
191
191
  description:
192
- "Apply an explicitly approved kibi.bootstrap-plan.v1, kibi.compile-plan.v1, kibi.migration-plan.v2, or entity-deletion plan after revalidating its canonical hash and live snapshots. Bootstrap actions are dependency-ordered, sequential, source-first, and recoverable from a typed journal.",
192
+ "Apply an explicitly approved kibi.bootstrap-plan.v1, kibi.compile-plan.v1, kibi.migration-plan.v2, or entity-deletion plan after revalidating its canonical hash and live snapshots. Compile plans apply all-or-nothing: a durable journal records every source write and store mutation before the first write, all steps commit in one store transaction, and an interrupted application is completed or rolled back by the next mutating call. Bootstrap actions are dependency-ordered, sequential, source-first, and recoverable from a typed journal.",
193
193
  businessInputSchema: {
194
194
  type: "object",
195
195
  oneOf: [
@@ -227,7 +227,7 @@ export const applyPlanSpec = {
227
227
  type: "string",
228
228
  pattern: "^[A-Za-z0-9._-]+$",
229
229
  description:
230
- "Typed recovery journal identifier returned by a committed_with_repairs result. Recovery replays only the immutable journal and never the original plan request.",
230
+ "Typed recovery journal identifier returned by a committed_with_repairs result or a PLAN_APPLY_RECOVERY_REQUIRED error. Recovery replays only the immutable journal and never the original plan request; a compile-plan journal (plan-apply-*) is completed or rolled back deterministically and reports which.",
231
231
  },
232
232
  },
233
233
  },
@@ -1,6 +1,3 @@
1
- import { join } from "node:path";
2
-
3
- import { resolveBoundSymbolScope } from "../../../extractors/manifest.js";
4
1
  import { PROOF_RECEIPT_MAX_AGE_SECONDS } from "../../proof-receipt.js";
5
2
  import { executeStatus } from "../discovery-executors.js";
6
3
  import {
@@ -200,16 +197,13 @@ export function currentProofBindingMode(): "per_contract" | "strict_snapshot" {
200
197
  : "per_contract";
201
198
  }
202
199
 
200
+ // implements REQ-kibi-verification-evidence-contract
203
201
  export async function perContractTestBindings(
204
202
  context: OperationContext,
205
203
  ): Promise<string | null> {
206
204
  if (currentProofBindingMode() !== "per_contract") return null;
207
205
  const { loadEntities } = await import("../discovery-entities.js");
208
- const { receiptBindingHash } = await import("../../proof-fingerprint.js");
209
- const { removeFrontmatterBlock } = await import(
210
- "../../../operations/proof/receipt-document.js"
211
- );
212
- const { loadCoveredBySymbolsByTest, receiptCodeScopeSymbolIds } =
206
+ const { currentReceiptBindingHash, loadCoveredBySymbolsByTest } =
213
207
  await import("../../../operations/proof/code-scope.js");
214
208
  // Only the contract, scoped code, and authored source feed the binding
215
209
  // hash. The paged projection never materializes receipt histories, which
@@ -230,39 +224,20 @@ export async function perContractTestBindings(
230
224
  ? await loadCoveredBySymbolsByTest(requireProlog(context))
231
225
  : new Map<string, readonly string[]>();
232
226
  const entries: string[] = [];
233
- const manifestPath = join(context.workspaceRoot, ".kb", "symbols.yaml");
227
+ const fs = context.fs;
234
228
  for (const test of tests) {
235
229
  const testId = typeof test.id === "string" ? test.id : "";
236
- const contract =
237
- test.proof_contract !== undefined &&
238
- test.proof_contract !== null &&
239
- typeof test.proof_contract === "object"
240
- ? (test.proof_contract as Record<string, unknown>)
241
- : undefined;
242
- const source = typeof test.source === "string" ? test.source : "";
243
- if (testId === "" || contract === undefined || source === "") continue;
244
- if (!/\.(md|mdx)$/i.test(source)) continue;
245
- if (!context.fs) continue;
246
- try {
247
- const absolute = join(context.workspaceRoot, source);
248
- const authored = await context.fs.readFile(absolute);
249
- const stripped = removeFrontmatterBlock(authored, "proof_receipts");
250
- const codeScope = resolveBoundSymbolScope(
251
- manifestPath,
252
- receiptCodeScopeSymbolIds(
253
- contract,
254
- test.proof_bindings,
255
- coveredBy.get(testId) ?? [],
256
- ),
257
- );
258
- const binding = receiptBindingHash(
259
- contract as never,
260
- stripped ?? authored,
261
- codeScope,
262
- );
230
+ if (testId === "" || fs === undefined) continue;
231
+ // The same computation ingest uses to write binding_hash. Unreadable or
232
+ // non-markdown documents keep strict snapshot semantics for that test.
233
+ const binding = await currentReceiptBindingHash({
234
+ workspaceRoot: context.workspaceRoot,
235
+ readFile: (absolute) => fs.readFile(absolute),
236
+ test,
237
+ coveredBySymbols: coveredBy.get(testId) ?? [],
238
+ });
239
+ if (binding !== undefined) {
263
240
  entries.push(`${toPrologAtom(testId)}: ${toPrologAtom(binding)}`);
264
- } catch {
265
- // Unreadable documents keep strict semantics for that test.
266
241
  }
267
242
  }
268
243
  if (entries.length === 0) return null;
@@ -14,7 +14,7 @@ export const upsertSpec = {
14
14
  name: "kb_upsert",
15
15
  cliName: "upsert",
16
16
  description:
17
- "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer kb_validate_upsert first because it returns semantic advisor receipts for prose-heavy requirements. Use kb_model_requirement before hand-writing strict property facts from prose, and kb_suggest_predicates before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request. Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates.",
17
+ "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer a dryRun:true call first because it validates without writing and returns semantic advisor receipts for prose-heavy requirements. Use kb_model (mode requirement) before hand-writing strict property facts from prose, and kb_model (mode predicates) before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request, then upsert the old requirement with status closed (kb_check blocks a superseded requirement that is not closed). Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates; dryRun:true writes nothing.",
18
18
  businessInputSchema: {
19
19
  type: "object",
20
20
  required: ["type", "id", "properties"],
@@ -32,6 +32,12 @@ export const upsertSpec = {
32
32
  },
33
33
  properties: ENTITY_PROPERTIES_SCHEMA,
34
34
  relationships: RELATIONSHIPS_SCHEMA,
35
+ dryRun: {
36
+ type: "boolean",
37
+ default: false,
38
+ description:
39
+ "Validate the payload and return schema/modeling errors, a normalized preview and the semantic advisor receipt without writing the KB or workspace. Use it as the preflight before the real write.",
40
+ },
35
41
  document: {
36
42
  type: "object",
37
43
  additionalProperties: false,
@@ -7,6 +7,7 @@ export type OperationName =
7
7
  | "kb_skills_list"
8
8
  | "kb_skills_load"
9
9
  | "kb_skills_read"
10
+ | "kb_skills"
10
11
  | "kb_find_gaps"
11
12
  | "kb_coverage"
12
13
  | "kb_graph"
@@ -19,6 +20,7 @@ export type OperationName =
19
20
  | "kb_prepare_impact_review"
20
21
  | "kb_model_requirement"
21
22
  | "kb_suggest_predicates"
23
+ | "kb_model"
22
24
  | "kb_plan_bootstrap"
23
25
  | "kb_compile_intent"
24
26
  | "kb_apply_plan"
@@ -173,6 +173,7 @@ export type ProofReceipt = Readonly<{
173
173
  finished_at: string;
174
174
  artifact_digest: string;
175
175
  contract_hash: string;
176
+ binding_hash?: string;
176
177
  fingerprint: string;
177
178
  fingerprint_components: ProofFingerprintComponents;
178
179
  integration_id: string;