kibi-cli 2.1.0 → 2.3.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 (398) hide show
  1. package/dist/cli-operation-loader.d.ts.map +1 -1
  2. package/dist/cli-operation-loader.js +3 -0
  3. package/dist/cli-operation-metadata.d.ts +4 -0
  4. package/dist/cli-operation-metadata.d.ts.map +1 -1
  5. package/dist/cli-operation-metadata.js +5 -0
  6. package/dist/cli-protocol.d.ts.map +1 -1
  7. package/dist/cli-protocol.js +3 -2
  8. package/dist/cli-register-reporting.d.ts.map +1 -1
  9. package/dist/cli-register-reporting.js +4 -0
  10. package/dist/commands/aggregated-checks.d.ts +7 -0
  11. package/dist/commands/aggregated-checks.d.ts.map +1 -1
  12. package/dist/commands/aggregated-checks.js +25 -1
  13. package/dist/commands/check-diff.d.ts +5 -0
  14. package/dist/commands/check-diff.d.ts.map +1 -0
  15. package/dist/commands/check-diff.js +62 -0
  16. package/dist/commands/check-generated.d.ts.map +1 -1
  17. package/dist/commands/check-generated.js +41 -18
  18. package/dist/commands/check.d.ts.map +1 -1
  19. package/dist/commands/check.js +231 -86
  20. package/dist/commands/doctor.d.ts.map +1 -1
  21. package/dist/commands/doctor.js +168 -53
  22. package/dist/commands/github-init.d.ts +1 -1
  23. package/dist/commands/github-init.d.ts.map +1 -1
  24. package/dist/commands/github-init.js +10 -3
  25. package/dist/commands/init-helpers.d.ts +17 -2
  26. package/dist/commands/init-helpers.d.ts.map +1 -1
  27. package/dist/commands/init-helpers.js +123 -23
  28. package/dist/commands/init.d.ts.map +1 -1
  29. package/dist/commands/init.js +110 -15
  30. package/dist/commands/prove.d.ts.map +1 -1
  31. package/dist/commands/prove.js +10 -18
  32. package/dist/commands/sync/cache.d.ts +20 -1
  33. package/dist/commands/sync/cache.d.ts.map +1 -1
  34. package/dist/commands/sync/cache.js +51 -2
  35. package/dist/commands/sync/discovery.d.ts.map +1 -1
  36. package/dist/commands/sync/discovery.js +1 -1
  37. package/dist/commands/sync/manifest.d.ts.map +1 -1
  38. package/dist/commands/sync/manifest.js +3 -1
  39. package/dist/commands/sync/persistence.d.ts.map +1 -1
  40. package/dist/commands/sync/persistence.js +8 -0
  41. package/dist/commands/sync.d.ts.map +1 -1
  42. package/dist/commands/sync.js +11 -3
  43. package/dist/engine.d.ts +41 -1
  44. package/dist/engine.d.ts.map +1 -1
  45. package/dist/engine.js +377 -80
  46. package/dist/extractors/manifest.d.ts.map +1 -1
  47. package/dist/extractors/manifest.js +66 -28
  48. package/dist/extractors/markdown.d.ts +2 -0
  49. package/dist/extractors/markdown.d.ts.map +1 -1
  50. package/dist/extractors/markdown.js +14 -3
  51. package/dist/extractors/relationships.d.ts.map +1 -1
  52. package/dist/extractors/relationships.js +1 -0
  53. package/dist/extractors/symbols-coordinator.d.ts +7 -0
  54. package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
  55. package/dist/extractors/symbols-coordinator.js +75 -39
  56. package/dist/intent-search.d.ts.map +1 -1
  57. package/dist/intent-search.js +68 -29
  58. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  59. package/dist/operations/bootstrap/generate.js +4 -3
  60. package/dist/operations/modeling/model-requirement.d.ts +1 -1
  61. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  62. package/dist/operations/modeling/model-requirement.js +176 -10
  63. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  64. package/dist/operations/modeling/predicate-applyplan.js +14 -2
  65. package/dist/operations/modeling/predicate-inference-1.js +1 -1
  66. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  67. package/dist/operations/modeling/predicate-loader.js +24 -0
  68. package/dist/operations/modeling/predicate-types.d.ts +4 -0
  69. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  70. package/dist/operations/modeling/predicate-vocabulary.d.ts +54 -0
  71. package/dist/operations/modeling/predicate-vocabulary.d.ts.map +1 -0
  72. package/dist/operations/modeling/predicate-vocabulary.js +169 -0
  73. package/dist/operations/modeling/requirement-types.d.ts +5 -0
  74. package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
  75. package/dist/operations/modeling/vocabulary-alignment.d.ts +60 -0
  76. package/dist/operations/modeling/vocabulary-alignment.d.ts.map +1 -0
  77. package/dist/operations/modeling/vocabulary-alignment.js +178 -0
  78. package/dist/operations/mutation/contradictions.d.ts +3 -0
  79. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  80. package/dist/operations/mutation/contradictions.js +29 -0
  81. package/dist/operations/mutation/delete.d.ts.map +1 -1
  82. package/dist/operations/mutation/delete.js +33 -1
  83. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +8 -0
  84. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -0
  85. package/dist/operations/mutation/predicate-vocabulary-guard.js +64 -0
  86. package/dist/operations/mutation/relationships.d.ts +1 -1
  87. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  88. package/dist/operations/mutation/relationships.js +1 -0
  89. package/dist/operations/mutation/saga.d.ts +5 -0
  90. package/dist/operations/mutation/saga.d.ts.map +1 -1
  91. package/dist/operations/mutation/saga.js +10 -0
  92. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  93. package/dist/operations/mutation/serialization.js +2 -0
  94. package/dist/operations/mutation/source-authoring.d.ts +6 -0
  95. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  96. package/dist/operations/mutation/source-authoring.js +213 -52
  97. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  98. package/dist/operations/mutation/strict-fact.js +5 -0
  99. package/dist/operations/mutation/types.d.ts +17 -0
  100. package/dist/operations/mutation/types.d.ts.map +1 -1
  101. package/dist/operations/mutation/upsert.d.ts +6 -0
  102. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  103. package/dist/operations/mutation/upsert.js +77 -11
  104. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  105. package/dist/operations/mutation/validate-upsert.js +24 -1
  106. package/dist/operations/mutation/validation.d.ts.map +1 -1
  107. package/dist/operations/mutation/validation.js +16 -3
  108. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  109. package/dist/operations/planning/apply-plan.js +66 -26
  110. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  111. package/dist/operations/planning/compile-intent.js +3 -1
  112. package/dist/operations/proof/code-scope.d.ts +17 -0
  113. package/dist/operations/proof/code-scope.d.ts.map +1 -0
  114. package/dist/operations/proof/code-scope.js +60 -0
  115. package/dist/operations/proof/ingest-proof.d.ts +4 -2
  116. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  117. package/dist/operations/proof/ingest-proof.js +208 -74
  118. package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
  119. package/dist/operations/proof/migrate-legacy-receipts.js +7 -5
  120. package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
  121. package/dist/operations/proof/prune-receipts.js +7 -5
  122. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  123. package/dist/operations/semantic-advisor/analysis-receipt.js +7 -1
  124. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  125. package/dist/operations/semantic-advisor/analyze-prose.js +26 -4
  126. package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
  127. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  128. package/dist/operations/semantic-advisor/clauses.js +7 -1
  129. package/dist/performance-trace.d.ts +17 -0
  130. package/dist/performance-trace.d.ts.map +1 -0
  131. package/dist/performance-trace.js +134 -0
  132. package/dist/plugins/approved-source-analyzers.d.ts +13 -0
  133. package/dist/plugins/approved-source-analyzers.d.ts.map +1 -0
  134. package/dist/plugins/approved-source-analyzers.generated.d.ts +71 -0
  135. package/dist/plugins/approved-source-analyzers.generated.d.ts.map +1 -0
  136. package/dist/plugins/approved-source-analyzers.generated.js +77 -0
  137. package/dist/plugins/approved-source-analyzers.js +3 -0
  138. package/dist/plugins/compose-semantic-classifier.d.ts +6 -1
  139. package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -1
  140. package/dist/plugins/compose-semantic-classifier.js +8 -3
  141. package/dist/plugins/compose-vocabulary-alignment.d.ts +23 -0
  142. package/dist/plugins/compose-vocabulary-alignment.d.ts.map +1 -0
  143. package/dist/plugins/compose-vocabulary-alignment.js +141 -0
  144. package/dist/plugins/external-allowlist.d.ts +7 -0
  145. package/dist/plugins/external-allowlist.d.ts.map +1 -1
  146. package/dist/plugins/external-allowlist.js +13 -0
  147. package/dist/plugins/index.d.ts +2 -0
  148. package/dist/plugins/index.d.ts.map +1 -1
  149. package/dist/plugins/index.js +4 -0
  150. package/dist/plugins/maintenance-source-analysis.d.ts +14 -0
  151. package/dist/plugins/maintenance-source-analysis.d.ts.map +1 -0
  152. package/dist/plugins/maintenance-source-analysis.js +191 -0
  153. package/dist/plugins/registry.d.ts +3 -1
  154. package/dist/plugins/registry.d.ts.map +1 -1
  155. package/dist/plugins/registry.js +27 -1
  156. package/dist/plugins/source-analysis-service.d.ts +36 -1
  157. package/dist/plugins/source-analysis-service.d.ts.map +1 -1
  158. package/dist/plugins/source-analysis-service.js +184 -27
  159. package/dist/plugins/source-change-analysis.d.ts +15 -0
  160. package/dist/plugins/source-change-analysis.d.ts.map +1 -0
  161. package/dist/plugins/source-change-analysis.js +54 -0
  162. package/dist/plugins/source-classification.d.ts +41 -0
  163. package/dist/plugins/source-classification.d.ts.map +1 -0
  164. package/dist/plugins/source-classification.js +490 -0
  165. package/dist/prolog/codec.d.ts.map +1 -1
  166. package/dist/prolog/codec.js +2 -0
  167. package/dist/prolog/swipl-resolver.d.ts +88 -0
  168. package/dist/prolog/swipl-resolver.d.ts.map +1 -0
  169. package/dist/prolog/swipl-resolver.js +446 -0
  170. package/dist/prolog.d.ts +51 -1
  171. package/dist/prolog.d.ts.map +1 -1
  172. package/dist/prolog.js +145 -15
  173. package/dist/public/diagnostic-usage.d.ts.map +1 -1
  174. package/dist/public/diagnostic-usage.js +7 -25
  175. package/dist/public/impact/analyzer.d.ts.map +1 -1
  176. package/dist/public/impact/analyzer.js +56 -5
  177. package/dist/public/impact/diagnostics.d.ts.map +1 -1
  178. package/dist/public/impact/diagnostics.js +3 -1
  179. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  180. package/dist/public/impact/full-kb-quality.js +4 -12
  181. package/dist/public/impact/manifest.d.ts.map +1 -1
  182. package/dist/public/impact/manifest.js +15 -1
  183. package/dist/public/impact/source-changes.d.ts.map +1 -1
  184. package/dist/public/impact/source-changes.js +35 -27
  185. package/dist/public/impact/types.d.ts +2 -0
  186. package/dist/public/impact/types.d.ts.map +1 -1
  187. package/dist/public/operations/catalog.d.ts +80 -7
  188. package/dist/public/operations/catalog.d.ts.map +1 -1
  189. package/dist/public/operations/catalog.js +2 -0
  190. package/dist/public/operations/check-executor.d.ts.map +1 -1
  191. package/dist/public/operations/check-executor.js +10 -2
  192. package/dist/public/operations/check-helpers.d.ts +6 -0
  193. package/dist/public/operations/check-helpers.d.ts.map +1 -1
  194. package/dist/public/operations/check-helpers.js +21 -1
  195. package/dist/public/operations/contracts.d.ts.map +1 -1
  196. package/dist/public/operations/contracts.js +325 -8
  197. package/dist/public/operations/discovery-entities.d.ts +42 -2
  198. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  199. package/dist/public/operations/discovery-entities.js +195 -22
  200. package/dist/public/operations/discovery-executors.d.ts +1 -0
  201. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  202. package/dist/public/operations/discovery-executors.js +75 -46
  203. package/dist/public/operations/impact-review-preparation.d.ts +14 -0
  204. package/dist/public/operations/impact-review-preparation.d.ts.map +1 -0
  205. package/dist/public/operations/impact-review-preparation.js +379 -0
  206. package/dist/public/operations/index.d.ts +2 -0
  207. package/dist/public/operations/index.d.ts.map +1 -1
  208. package/dist/public/operations/index.js +2 -0
  209. package/dist/public/operations/migration-plan.d.ts +2 -0
  210. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  211. package/dist/public/operations/migration-plan.js +50 -0
  212. package/dist/public/operations/node-ports.d.ts.map +1 -1
  213. package/dist/public/operations/node-ports.js +1 -35
  214. package/dist/public/operations/predicate-schema-conformance.d.ts +41 -0
  215. package/dist/public/operations/predicate-schema-conformance.d.ts.map +1 -0
  216. package/dist/public/operations/predicate-schema-conformance.js +242 -0
  217. package/dist/public/operations/prolog-json.d.ts.map +1 -1
  218. package/dist/public/operations/prolog-json.js +9 -3
  219. package/dist/public/operations/proof-receipt-projection.d.ts +5 -0
  220. package/dist/public/operations/proof-receipt-projection.d.ts.map +1 -0
  221. package/dist/public/operations/proof-receipt-projection.js +36 -0
  222. package/dist/public/operations/result-envelope.d.ts +34 -1
  223. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  224. package/dist/public/operations/result-envelope.js +78 -2
  225. package/dist/public/operations/runtime-types.d.ts +1 -1
  226. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  227. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  228. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  229. package/dist/public/operations/specs/check-rules.generated.js +8 -1
  230. package/dist/public/operations/specs/check.d.ts +1 -1
  231. package/dist/public/operations/specs/discovery.d.ts +7 -1
  232. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  233. package/dist/public/operations/specs/discovery.js +7 -1
  234. package/dist/public/operations/specs/impact-review-preparation.d.ts +47 -0
  235. package/dist/public/operations/specs/impact-review-preparation.d.ts.map +1 -0
  236. package/dist/public/operations/specs/impact-review-preparation.js +43 -0
  237. package/dist/public/operations/specs/mutation-schemas.d.ts +27 -4
  238. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  239. package/dist/public/operations/specs/mutation-schemas.js +21 -3
  240. package/dist/public/operations/specs/reporting.d.ts +8 -0
  241. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  242. package/dist/public/operations/specs/reporting.js +46 -15
  243. package/dist/public/operations/specs/upsert.d.ts +28 -5
  244. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  245. package/dist/public/operations/specs/upsert.js +1 -1
  246. package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
  247. package/dist/public/operations/symbol-repair-plan.js +8 -3
  248. package/dist/public/operations/types.d.ts +1 -1
  249. package/dist/public/operations/types.d.ts.map +1 -1
  250. package/dist/public/schemas/entity.d.ts.map +1 -1
  251. package/dist/public/schemas/entity.js +22 -0
  252. package/dist/public/schemas/relationship.d.ts.map +1 -1
  253. package/dist/public/schemas/relationship.js +1 -0
  254. package/dist/public/skills/kibi-usage/SKILL.md +7 -3
  255. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
  256. package/dist/public/skills/kibi-usage/resources/operation-access.md +1 -0
  257. package/dist/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
  258. package/dist/public/skills/kibi-usage/resources/source-authoring.md +36 -0
  259. package/dist/public/skills/kibi-usage/resources/workflows.md +52 -1
  260. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  261. package/dist/public/telemetry-acceptance.js +21 -5
  262. package/dist/relationships/shards.d.ts +6 -0
  263. package/dist/relationships/shards.d.ts.map +1 -1
  264. package/dist/relationships/shards.js +26 -19
  265. package/dist/schemas/entity.schema.json +32 -0
  266. package/dist/traceability/analysis-gate.d.ts +39 -0
  267. package/dist/traceability/analysis-gate.d.ts.map +1 -0
  268. package/dist/traceability/analysis-gate.js +51 -0
  269. package/dist/traceability/git-change-snapshot.d.ts +27 -0
  270. package/dist/traceability/git-change-snapshot.d.ts.map +1 -0
  271. package/dist/traceability/git-change-snapshot.js +411 -0
  272. package/dist/traceability/git-staged.d.ts +5 -1
  273. package/dist/traceability/git-staged.d.ts.map +1 -1
  274. package/dist/traceability/git-staged.js +16 -11
  275. package/dist/traceability/impact-evaluator.d.ts +54 -0
  276. package/dist/traceability/impact-evaluator.d.ts.map +1 -0
  277. package/dist/traceability/impact-evaluator.js +270 -0
  278. package/dist/traceability/impact-git-tree.d.ts +12 -0
  279. package/dist/traceability/impact-git-tree.d.ts.map +1 -0
  280. package/dist/traceability/impact-git-tree.js +46 -0
  281. package/dist/traceability/impact-knowledge.d.ts +16 -0
  282. package/dist/traceability/impact-knowledge.d.ts.map +1 -0
  283. package/dist/traceability/impact-knowledge.js +165 -0
  284. package/dist/traceability/impact-policy.d.ts +15 -0
  285. package/dist/traceability/impact-policy.d.ts.map +1 -0
  286. package/dist/traceability/impact-policy.js +48 -0
  287. package/dist/traceability/impact-policy.v1.schema.json +48 -0
  288. package/dist/traceability/impact-pr-diff.d.ts +5 -0
  289. package/dist/traceability/impact-pr-diff.d.ts.map +1 -0
  290. package/dist/traceability/impact-pr-diff.js +83 -0
  291. package/dist/traceability/impact-record-validation.d.ts +9 -0
  292. package/dist/traceability/impact-record-validation.d.ts.map +1 -0
  293. package/dist/traceability/impact-record-validation.js +113 -0
  294. package/dist/traceability/impact-review.d.ts +148 -0
  295. package/dist/traceability/impact-review.d.ts.map +1 -0
  296. package/dist/traceability/impact-review.js +494 -0
  297. package/dist/traceability/impact-review.schema.json +365 -0
  298. package/dist/traceability/impact-side-evidence.d.ts +13 -0
  299. package/dist/traceability/impact-side-evidence.d.ts.map +1 -0
  300. package/dist/traceability/impact-side-evidence.js +240 -0
  301. package/dist/traceability/reviewed-coordinate-refresh.d.ts +10 -0
  302. package/dist/traceability/reviewed-coordinate-refresh.d.ts.map +1 -0
  303. package/dist/traceability/reviewed-coordinate-refresh.js +49 -0
  304. package/dist/traceability/snapshot-knowledge.d.ts +4 -0
  305. package/dist/traceability/snapshot-knowledge.d.ts.map +1 -0
  306. package/dist/traceability/snapshot-knowledge.js +98 -0
  307. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  308. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  309. package/dist/traceability/staged-entity-id-style.d.ts +12 -0
  310. package/dist/traceability/staged-entity-id-style.d.ts.map +1 -0
  311. package/dist/traceability/staged-entity-id-style.js +68 -0
  312. package/dist/traceability/staged-file-coverage.d.ts +23 -0
  313. package/dist/traceability/staged-file-coverage.d.ts.map +1 -1
  314. package/dist/traceability/staged-impact-contract.d.ts.map +1 -1
  315. package/dist/traceability/staged-impact-contract.js +2 -16
  316. package/dist/traceability/staged-symbols-manifest.d.ts +4 -0
  317. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  318. package/dist/traceability/staged-symbols-manifest.js +17 -6
  319. package/dist/traceability/symbol-extract.d.ts +3 -5
  320. package/dist/traceability/symbol-extract.d.ts.map +1 -1
  321. package/dist/traceability/symbol-extract.js +49 -34
  322. package/dist/traceability/temp-kb.d.ts +1 -1
  323. package/dist/traceability/temp-kb.d.ts.map +1 -1
  324. package/dist/traceability/temp-kb.js +57 -13
  325. package/dist/traceability/trusted-pr-event.d.ts +13 -0
  326. package/dist/traceability/trusted-pr-event.d.ts.map +1 -0
  327. package/dist/traceability/trusted-pr-event.js +105 -0
  328. package/dist/traceability/validate.js +1 -1
  329. package/dist/types/entities.d.ts +2 -0
  330. package/dist/types/entities.d.ts.map +1 -1
  331. package/dist/types/relationships.d.ts +1 -1
  332. package/dist/types/relationships.d.ts.map +1 -1
  333. package/dist/utils/canonical-path.d.ts +3 -0
  334. package/dist/utils/canonical-path.d.ts.map +1 -0
  335. package/dist/utils/canonical-path.js +33 -0
  336. package/dist/utils/entity-id-style.d.ts +27 -0
  337. package/dist/utils/entity-id-style.d.ts.map +1 -0
  338. package/dist/utils/entity-id-style.js +81 -0
  339. package/dist/utils/git-repository-context.d.ts +50 -0
  340. package/dist/utils/git-repository-context.d.ts.map +1 -0
  341. package/dist/utils/git-repository-context.js +259 -0
  342. package/dist/utils/rule-registry.d.ts +5 -0
  343. package/dist/utils/rule-registry.d.ts.map +1 -1
  344. package/dist/utils/rule-registry.generated.d.ts +37 -0
  345. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  346. package/dist/utils/rule-registry.generated.js +44 -0
  347. package/dist/utils/strict-modeling.d.ts +7 -0
  348. package/dist/utils/strict-modeling.d.ts.map +1 -1
  349. package/dist/utils/strict-modeling.js +11 -0
  350. package/package.json +14 -5
  351. package/schema/entities.pl +60 -1
  352. package/schema/relationships.pl +17 -4
  353. package/schema/validation.pl +118 -20
  354. package/src/public/diagnostic-usage.ts +16 -24
  355. package/src/public/impact/analyzer.ts +88 -5
  356. package/src/public/impact/diagnostics.ts +7 -5
  357. package/src/public/impact/full-kb-quality.ts +4 -16
  358. package/src/public/impact/manifest.ts +14 -1
  359. package/src/public/impact/source-changes.ts +39 -34
  360. package/src/public/impact/types.ts +5 -0
  361. package/src/public/operations/catalog.ts +2 -0
  362. package/src/public/operations/check-executor.ts +12 -1
  363. package/src/public/operations/check-helpers.ts +27 -1
  364. package/src/public/operations/contracts.ts +404 -9
  365. package/src/public/operations/discovery-entities.ts +292 -23
  366. package/src/public/operations/discovery-executors.ts +91 -55
  367. package/src/public/operations/impact-review-preparation.ts +548 -0
  368. package/src/public/operations/index.ts +2 -0
  369. package/src/public/operations/migration-plan.ts +57 -0
  370. package/src/public/operations/node-ports.ts +1 -39
  371. package/src/public/operations/predicate-schema-conformance.ts +362 -0
  372. package/src/public/operations/prolog-json.ts +9 -3
  373. package/src/public/operations/proof-receipt-projection.ts +39 -0
  374. package/src/public/operations/result-envelope.ts +114 -2
  375. package/src/public/operations/runtime-types.ts +1 -1
  376. package/src/public/operations/specs/check-rules.generated.ts +8 -1
  377. package/src/public/operations/specs/discovery.ts +8 -1
  378. package/src/public/operations/specs/impact-review-preparation.ts +46 -0
  379. package/src/public/operations/specs/mutation-schemas.ts +23 -3
  380. package/src/public/operations/specs/reporting.ts +69 -22
  381. package/src/public/operations/specs/upsert.ts +1 -1
  382. package/src/public/operations/symbol-repair-plan.ts +13 -3
  383. package/src/public/operations/types.ts +1 -0
  384. package/src/public/schemas/entity.ts +22 -0
  385. package/src/public/schemas/relationship.ts +1 -0
  386. package/src/public/skills/kibi-usage/SKILL.md +7 -3
  387. package/src/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
  388. package/src/public/skills/kibi-usage/resources/operation-access.md +1 -0
  389. package/src/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
  390. package/src/public/skills/kibi-usage/resources/source-authoring.md +36 -0
  391. package/src/public/skills/kibi-usage/resources/workflows.md +52 -1
  392. package/src/public/telemetry-acceptance.ts +37 -6
  393. package/src/schemas/entity.schema.json +32 -0
  394. package/src/schemas/relationship.schema.json +1 -0
  395. package/src/traceability/impact-policy.v1.schema.json +48 -0
  396. package/src/traceability/impact-review.schema.json +365 -0
  397. package/templates/github/kibi-badge.yml +0 -4
  398. package/templates/github/kibi-report.yml +0 -4
@@ -107,6 +107,14 @@ function serializeTypedFactFields(entity) {
107
107
  if (ruleIr !== undefined && ruleIr !== null) {
108
108
  fields.push(`rule_ir=${toPrologString(JSON.stringify(ruleIr))}`);
109
109
  }
110
+ // Predicate-schema vocabularies are objects; like rule_ir they travel as
111
+ // JSON strings and are decoded again at the public boundary.
112
+ for (const field of ["argument_constants", "argument_aliases"]) {
113
+ const value = getEntityField(entity, field);
114
+ if (value !== undefined && value !== null) {
115
+ fields.push(`${field}=${toPrologString(JSON.stringify(value))}`);
116
+ }
117
+ }
110
118
  for (const field of FACT_ATOM_FIELDS) {
111
119
  const value = getEntityField(entity, field);
112
120
  if (value !== undefined && value !== null) {
@@ -258,29 +266,62 @@ async function consultOverlay(ctx) {
258
266
  }
259
267
  }
260
268
  export { consultOverlay };
269
+ const PROJECTION_BATCH_SIZE = 128;
270
+ // implements REQ-014
271
+ function contextualProjectionGoal(goal, context) {
272
+ const label = toPrologString(context);
273
+ // A failed goal must abort the transaction just like an exception. Keep the
274
+ // individual record in the error even when it belongs to a larger batch.
275
+ // Use the existing structured validation-error transport; unrecognized error
276
+ // terms can lose their record context during generic error classification.
277
+ return `catch((${goal} -> true ; throw(staged_goal_failed)), ProjectionError, (message_to_string(ProjectionError, ProjectionDetail), format(atom(ProjectionMessage), '~s: ~s', [${label}, ProjectionDetail]), throw(error(validation_error(ProjectionMessage), context(projectStagedEntities, ${label})))))`;
278
+ }
261
279
  // implements REQ-014
262
280
  export async function projectStagedEntities(prolog, results) {
263
- for (const { entity, sourceFile } of results) {
264
- // Retract stale relationships before re-asserting entity
265
- // (kb_assert_entity_no_audit preserves relationships on upsert)
266
- await prolog.query(`kb_retract_entity_relationships('${entity.id}')`);
267
- const assertEntityResult = await prolog.query(buildEntityAssertionGoal(entity, sourceFile));
268
- if (!assertEntityResult.success) {
269
- throw new Error(`Failed to assert staged entity ${entity.id}: ${assertEntityResult.error || "unknown error"}`);
281
+ for (let offset = 0; offset < results.length; offset += PROJECTION_BATCH_SIZE) {
282
+ const batch = results.slice(offset, offset + PROJECTION_BATCH_SIZE);
283
+ const goals = batch.flatMap(({ entity, sourceFile }) => [
284
+ // Upserts preserve relationships, so replace them with snapshot edges.
285
+ contextualProjectionGoal(`kb_retract_entity_relationships(${toPrologAtom(entity.id)})`, `retract staged relationships for entity ${entity.id}`),
286
+ contextualProjectionGoal(buildEntityAssertionGoal(entity, sourceFile), `assert staged entity ${entity.id}`),
287
+ ]);
288
+ // query(array) wraps the batch in an RDF transaction and saves once.
289
+ const result = await prolog.query(goals);
290
+ if (!result.success) {
291
+ const label = batch.map(({ entity }) => entity.id).join(", ");
292
+ throw new Error(`Failed to assert staged entity ${label}: ${result.error || "unknown error"}`);
270
293
  }
271
294
  }
295
+ // Finish every entity before adding any relationships, including endpoints
296
+ // in later batches. Keep only one bounded batch of relationship goals.
297
+ let relationshipGoals = [];
298
+ let relationshipLabels = [];
299
+ // implements REQ-014
300
+ const flushRelationships = async () => {
301
+ if (relationshipGoals.length === 0)
302
+ return;
303
+ const result = await prolog.query(relationshipGoals);
304
+ if (!result.success) {
305
+ const label = relationshipLabels.join(", ");
306
+ throw new Error(`Failed to assert staged relationship ${label}: ${result.error || "unknown error"}`);
307
+ }
308
+ relationshipGoals = [];
309
+ relationshipLabels = [];
310
+ };
272
311
  for (const { relationships } of results) {
273
312
  for (const relationship of relationships) {
274
- const assertRelationshipResult = await prolog.query(buildRelationshipAssertionGoal(relationship));
275
- if (!assertRelationshipResult.success) {
276
- throw new Error(`Failed to assert staged relationship ${relationship.type} ${relationship.from} -> ${relationship.to}: ${assertRelationshipResult.error || "unknown error"}`);
277
- }
313
+ const label = `${relationship.type} ${relationship.from} -> ${relationship.to}`;
314
+ relationshipLabels.push(label);
315
+ relationshipGoals.push(contextualProjectionGoal(buildRelationshipAssertionGoal(relationship), `assert staged relationship ${label}`));
316
+ if (relationshipGoals.length === PROJECTION_BATCH_SIZE)
317
+ await flushRelationships();
278
318
  }
279
319
  }
320
+ await flushRelationships();
280
321
  }
281
322
  export async function createTempKb(baseKbPath) {
282
323
  // implements REQ-014
283
- if (!existsSync(baseKbPath)) {
324
+ if (baseKbPath !== undefined && !existsSync(baseKbPath)) {
284
325
  throw new Error(`Base KB path does not exist: ${baseKbPath}`);
285
326
  }
286
327
  // Use crypto.randomUUID() for uniqueness across concurrent calls
@@ -290,7 +331,10 @@ export async function createTempKb(baseKbPath) {
290
331
  trace(`creating temp KB directory ${tempDir}`);
291
332
  await mkdir(tempDir, { recursive: true });
292
333
  trace(`copying base KB ${baseKbPath} -> ${kbPath}`);
293
- await cp(baseKbPath, kbPath, { recursive: true });
334
+ if (baseKbPath !== undefined)
335
+ await cp(baseKbPath, kbPath, { recursive: true });
336
+ else
337
+ await mkdir(kbPath, { recursive: true });
294
338
  await writeFile(overlayPath, "", "utf8");
295
339
  const prolog = _createProlog({ timeout: 120000, oneShot: false });
296
340
  await prolog.start();
@@ -0,0 +1,13 @@
1
+ export type TrustedPullRequestSnapshot = Readonly<{
2
+ repository: string;
3
+ targetRef: string;
4
+ targetCommit: string;
5
+ targetTree: string;
6
+ headCommit: string;
7
+ headTree: string;
8
+ mergeBaseCommit: string;
9
+ mergeBaseTree: string;
10
+ }>;
11
+ /** Verify a GitHub pull_request_target envelope against the protected checkout. */
12
+ export declare function resolveTrustedPullRequestSnapshot(workspaceRoot: string, environment?: NodeJS.ProcessEnv): TrustedPullRequestSnapshot;
13
+ //# sourceMappingURL=trusted-pr-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trusted-pr-event.d.ts","sourceRoot":"","sources":["../../src/traceability/trusted-pr-event.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAAC;IAChD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC,CAAC;AAkDH,mFAAmF;AACnF,wBAAgB,iCAAiC,CAC/C,aAAa,EAAE,MAAM,EACrB,WAAW,GAAE,MAAM,CAAC,UAAwB,GAC3C,0BAA0B,CAqF5B"}
@@ -0,0 +1,105 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { readFileSync } from "node:fs";
3
+ const OBJECT_ID = /^[0-9a-f]{40}(?:[0-9a-f]{24})?$/;
4
+ function runGit(root, args) {
5
+ return execFileSync("git", [...args], {
6
+ cwd: root,
7
+ encoding: "utf8",
8
+ maxBuffer: 16 * 1024 * 1024,
9
+ stdio: ["ignore", "pipe", "ignore"],
10
+ }).trim();
11
+ }
12
+ function resolveCommit(root, input) {
13
+ if (!OBJECT_ID.test(input))
14
+ throw new Error("PR event contains an invalid Git object ID");
15
+ const resolved = runGit(root, [
16
+ "rev-parse",
17
+ "--verify",
18
+ "--end-of-options",
19
+ `${input}^{commit}`,
20
+ ]);
21
+ if (!OBJECT_ID.test(resolved))
22
+ throw new Error("Git returned an invalid commit ID");
23
+ return resolved;
24
+ }
25
+ function resolveTree(root, commit) {
26
+ const tree = runGit(root, [
27
+ "rev-parse",
28
+ "--verify",
29
+ "--end-of-options",
30
+ `${commit}^{tree}`,
31
+ ]);
32
+ if (!OBJECT_ID.test(tree))
33
+ throw new Error("Git returned an invalid tree ID");
34
+ return tree;
35
+ }
36
+ /** Verify a GitHub pull_request_target envelope against the protected checkout. */
37
+ export function resolveTrustedPullRequestSnapshot(workspaceRoot, environment = process.env) {
38
+ if (environment.GITHUB_EVENT_NAME !== "pull_request_target")
39
+ throw new Error("Trusted impact gate requires pull_request_target context");
40
+ const eventPath = environment.GITHUB_EVENT_PATH;
41
+ const repository = environment.GITHUB_REPOSITORY;
42
+ const trustedTargetRef = environment.KIBI_IMPACT_TRUSTED_TARGET_REF;
43
+ const githubSha = environment.GITHUB_SHA;
44
+ if (!eventPath || !repository || !trustedTargetRef || !githubSha)
45
+ throw new Error("Trusted PR event, repository, target ref and GitHub event SHA are required");
46
+ if (!/^[^/]+\/[^/]+$/.test(repository))
47
+ throw new Error("GitHub repository identity is invalid");
48
+ if (!/^refs\/heads\/[A-Za-z0-9._/-]+$/.test(trustedTargetRef))
49
+ throw new Error("Trusted target must be a full refs/heads/... name");
50
+ const payload = JSON.parse(readFileSync(eventPath, "utf8"));
51
+ const request = payload.pull_request;
52
+ const base = request?.base;
53
+ const head = request?.head;
54
+ const baseRef = base?.ref;
55
+ const targetInput = base?.sha;
56
+ const headInput = head?.sha;
57
+ if (typeof baseRef !== "string" ||
58
+ typeof targetInput !== "string" ||
59
+ typeof headInput !== "string" ||
60
+ base?.repo?.full_name !== repository)
61
+ throw new Error("PR event does not identify this repository's base and head");
62
+ if (trustedTargetRef !== `refs/heads/${baseRef}`)
63
+ throw new Error("PR target does not match the configured protected branch");
64
+ if (payload.repository?.full_name !== repository)
65
+ throw new Error("PR event repository identity does not match the trusted checkout");
66
+ const targetCommit = resolveCommit(workspaceRoot, targetInput);
67
+ const headCommit = resolveCommit(workspaceRoot, headInput);
68
+ if (resolveCommit(workspaceRoot, githubSha) !== targetCommit)
69
+ throw new Error("GitHub event target SHA does not match its trusted payload");
70
+ const checkoutCommit = resolveCommit(workspaceRoot, runGit(workspaceRoot, ["rev-parse", "HEAD"]));
71
+ if (checkoutCommit !== targetCommit)
72
+ throw new Error("Trusted evaluator checkout is not the PR target commit");
73
+ if (runGit(workspaceRoot, ["rev-parse", "--is-shallow-repository"]) !== "false")
74
+ throw new Error("Complete Git history is required for impact evaluation");
75
+ const missing = runGit(workspaceRoot, [
76
+ "rev-list",
77
+ "--objects",
78
+ "--missing=print",
79
+ targetCommit,
80
+ headCommit,
81
+ ]);
82
+ if (missing.split("\n").some((line) => line.startsWith("?")))
83
+ throw new Error("PR target or head has missing reachable Git objects");
84
+ const mergeBases = runGit(workspaceRoot, [
85
+ "merge-base",
86
+ "--all",
87
+ targetCommit,
88
+ headCommit,
89
+ ])
90
+ .split("\n")
91
+ .filter(Boolean);
92
+ if (mergeBases.length !== 1)
93
+ throw new Error("PR target and head must have exactly one merge base");
94
+ const mergeBaseCommit = resolveCommit(workspaceRoot, mergeBases[0] ?? "");
95
+ return {
96
+ repository,
97
+ targetRef: trustedTargetRef,
98
+ targetCommit,
99
+ targetTree: resolveTree(workspaceRoot, targetCommit),
100
+ headCommit,
101
+ headTree: resolveTree(workspaceRoot, headCommit),
102
+ mergeBaseCommit,
103
+ mergeBaseTree: resolveTree(workspaceRoot, mergeBaseCommit),
104
+ };
105
+ }
@@ -153,7 +153,7 @@ export function formatViolations(violations) {
153
153
  const loc = `${v.file}:${v.line}`;
154
154
  const name = `${v.name}()`;
155
155
  // Suggest adding requirement links with role-specific guidance
156
- const suggestion = "Add ownership: implements: REQ-001 (production code), use covered_by for production coverage, or executable_for for executable test code";
156
+ const suggestion = "Add ownership: implements: REQ-<area>-<behavior> (production code), use covered_by for production coverage, or executable_for for executable test code";
157
157
  lines.push(`${loc} ${name} -> ${suggestion}`);
158
158
  }
159
159
  return lines.join("\n");
@@ -39,6 +39,8 @@ export interface FactFields {
39
39
  argument_names?: string[];
40
40
  argument_types?: string[];
41
41
  argument_descriptions?: string[];
42
+ argument_constants?: Record<string, string[]>;
43
+ argument_aliases?: Record<string, Record<string, string>>;
42
44
  aliases?: string[];
43
45
  examples?: string[];
44
46
  predicate_args?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/types/entities.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAGD,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EACN,SAAS,GACT,gBAAgB,GAChB,aAAa,GACb,MAAM,GACN,kBAAkB,GAClB,WAAW,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;IACtD,UAAU,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAA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,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,MAAM,GACd,WAAW,GACX,QAAQ,GACR,UAAU,GACV,GAAG,GACH,IAAI,GACJ,KAAK,GACL,MAAM,GACN,IAAI,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export interface BaseRelationship {
2
- type: "depends_on" | "specified_by" | "verified_by" | "validates" | "implements" | "covered_by" | "executable_for" | "constrained_by" | "constrains" | "requires_property" | "requires_predicate" | "requires_rule" | "guards" | "publishes" | "consumes" | "supersedes" | "relates_to";
2
+ type: "depends_on" | "specified_by" | "verified_by" | "validates" | "implements" | "covered_by" | "executable_for" | "constrained_by" | "constrains" | "requires_property" | "requires_predicate" | "requires_rule" | "guards" | "publishes" | "consumes" | "supersedes" | "restates" | "relates_to";
3
3
  from: string;
4
4
  to: string;
5
5
  created_at?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/types/relationships.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EACA,YAAY,GACZ,cAAc,GACd,aAAa,GACb,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,oBAAoB,GACpB,eAAe,GACf,QAAQ,GACR,WAAW,GACX,UAAU,GACV,YAAY,GACZ,YAAY,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/types/relationships.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EACA,YAAY,GACZ,cAAc,GACd,aAAa,GACb,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,oBAAoB,GACpB,eAAe,GACf,QAAQ,GACR,WAAW,GACX,UAAU,GACV,YAAY,GACZ,UAAU,GACV,YAAY,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Resolve filesystem aliases while preserving a suffix that does not exist yet. */
2
+ export declare function canonicalFilesystemPath(candidate: string): string;
3
+ //# sourceMappingURL=canonical-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical-path.d.ts","sourceRoot":"","sources":["../../src/utils/canonical-path.ts"],"names":[],"mappings":"AAGA,oFAAoF;AACpF,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAwBjE"}
@@ -0,0 +1,33 @@
1
+ import { lstatSync, realpathSync } from "node:fs";
2
+ import path from "node:path";
3
+ /** Resolve filesystem aliases while preserving a suffix that does not exist yet. */
4
+ export function canonicalFilesystemPath(candidate) {
5
+ let existing = path.resolve(candidate);
6
+ const missing = [];
7
+ for (;;) {
8
+ try {
9
+ return path.resolve(realpathSync.native(existing), ...missing);
10
+ }
11
+ catch (error) {
12
+ if (error.code !== "ENOENT")
13
+ throw error;
14
+ // A dangling symlink is an existing entry, not a missing path segment.
15
+ // Refuse it rather than allowing a later write to follow an unknown target.
16
+ let entry;
17
+ try {
18
+ entry = lstatSync(existing);
19
+ }
20
+ catch (statError) {
21
+ if (statError.code !== "ENOENT")
22
+ throw statError;
23
+ }
24
+ if (entry !== undefined)
25
+ throw error;
26
+ const parent = path.dirname(existing);
27
+ if (parent === existing)
28
+ throw error;
29
+ missing.unshift(path.basename(existing));
30
+ existing = parent;
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,27 @@
1
+ /** Purely numeric entity ID such as `REQ-001` or `ADR-12`. */
2
+ export declare const NUMERIC_ENTITY_ID_PATTERN: RegExp;
3
+ export type EntityIdStyleIssue = Readonly<{
4
+ code: "numeric_id" | "stem_mismatch";
5
+ message: string;
6
+ suggestion: string;
7
+ }>;
8
+ export declare function isNumericEntityId(id: string): boolean;
9
+ /**
10
+ * Filename stem for an authored Markdown source, or undefined for non-Markdown
11
+ * sources (symbol manifests, code files, runtime `mcp://` provenance).
12
+ */
13
+ export declare function markdownSourceStem(sourcePath: string | undefined): string | undefined;
14
+ /**
15
+ * Style issues for one newly created entity. Callers decide whether the entity
16
+ * is new; this function never inspects the KB.
17
+ */
18
+ export declare function entityIdStyleIssues(input: {
19
+ readonly id: string;
20
+ readonly sourcePath?: string | undefined;
21
+ }): EntityIdStyleIssue[];
22
+ /** Plain-text warnings for mutation receipts. */
23
+ export declare function entityIdStyleWarnings(input: {
24
+ readonly id: string;
25
+ readonly sourcePath?: string | undefined;
26
+ }): string[];
27
+ //# sourceMappingURL=entity-id-style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-id-style.d.ts","sourceRoot":"","sources":["../../src/utils/entity-id-style.ts"],"names":[],"mappings":"AAiCA,8DAA8D;AAE9D,eAAO,MAAM,yBAAyB,QAAiB,CAAC;AAGxD,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,YAAY,GAAG,eAAe,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC,CAAC;AAGH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;GAGG;AAEH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,MAAM,GAAG,SAAS,CAOpB;AAED;;;GAGG;AAEH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,GAAG,kBAAkB,EAAE,CAoBvB;AAED,iDAAiD;AAEjD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,GAAG,MAAM,EAAE,CAIX"}
@@ -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
+ * Entity naming style (`entity-id-style`).
20
+ *
21
+ * Entities are named by what they govern (`REQ-cli-gc`), never by "the next
22
+ * number". The compiled KB cannot tell a legacy numbered entity from a new one
23
+ * (`created_at` is stamped at sync time when frontmatter omits it), so purely
24
+ * numeric IDs are reported only at creation boundaries: a `kb_upsert` that
25
+ * creates the entity, and staged added/renamed entity Markdown. Committed
26
+ * legacy entities such as `REQ-003` are therefore never flagged. The Prolog
27
+ * half of the rule (`check_entity_id_style/1`) reports filename-stem/`id`
28
+ * mismatches over the whole KB.
29
+ */
30
+ import * as path from "node:path";
31
+ /** Purely numeric entity ID such as `REQ-001` or `ADR-12`. */
32
+ // implements REQ-kibi-entity-id-style
33
+ export const NUMERIC_ENTITY_ID_PATTERN = /^[A-Z]+-\d+$/;
34
+ // implements REQ-kibi-entity-id-style
35
+ export function isNumericEntityId(id) {
36
+ return NUMERIC_ENTITY_ID_PATTERN.test(id.trim());
37
+ }
38
+ /**
39
+ * Filename stem for an authored Markdown source, or undefined for non-Markdown
40
+ * sources (symbol manifests, code files, runtime `mcp://` provenance).
41
+ */
42
+ // implements REQ-kibi-entity-id-style
43
+ export function markdownSourceStem(sourcePath) {
44
+ if (sourcePath === undefined)
45
+ return undefined;
46
+ const normalized = sourcePath.trim().replaceAll("\\", "/");
47
+ if (!normalized.endsWith(".md") || normalized.includes("://")) {
48
+ return undefined;
49
+ }
50
+ return path.posix.basename(normalized, ".md");
51
+ }
52
+ /**
53
+ * Style issues for one newly created entity. Callers decide whether the entity
54
+ * is new; this function never inspects the KB.
55
+ */
56
+ // implements REQ-kibi-entity-id-style
57
+ export function entityIdStyleIssues(input) {
58
+ const id = input.id.trim();
59
+ const issues = [];
60
+ if (isNumericEntityId(id)) {
61
+ issues.push({
62
+ code: "numeric_id",
63
+ message: `Entity ID ${id} is a sequence number; parallel branches pick the same next number and collide.`,
64
+ suggestion: "Name the entity by what it governs: <TYPE>-<area>-<behavior> in kebab-case (for example REQ-cli-gc). kb_search the area first and update or supersede an existing entity when one already covers the behavior.",
65
+ });
66
+ }
67
+ const stem = markdownSourceStem(input.sourcePath);
68
+ if (stem !== undefined && stem !== id) {
69
+ issues.push({
70
+ code: "stem_mismatch",
71
+ message: `Entity ID ${id} does not match its filename stem ${stem}.`,
72
+ suggestion: `Rename the file to ${id}.md or set frontmatter id: ${stem} so the file name and identity stay aligned.`,
73
+ });
74
+ }
75
+ return issues;
76
+ }
77
+ /** Plain-text warnings for mutation receipts. */
78
+ // implements REQ-kibi-entity-id-style
79
+ export function entityIdStyleWarnings(input) {
80
+ return entityIdStyleIssues(input).map((issue) => `entity-id-style: ${issue.message} ${issue.suggestion}`);
81
+ }
@@ -0,0 +1,50 @@
1
+ export interface GitRepositoryContext {
2
+ /** Root of the current working tree (the worktree, when linked). */
3
+ worktreeRoot: string;
4
+ /** Absolute Git directory of the current worktree. */
5
+ gitDir: string;
6
+ /** Absolute repository-common Git directory (shared across worktrees). */
7
+ commonGitDir: string;
8
+ /** Absolute hooks directory Git will actually execute (honors core.hooksPath). */
9
+ effectiveHooksDir: string;
10
+ isLinkedWorktree: boolean;
11
+ /**
12
+ * Primary checkout root, only when it can be validated as a real checkout
13
+ * (`git -C <candidate> rev-parse --show-toplevel` resolves to the
14
+ * candidate). Null for bare repositories, separate-git-dir layouts, and any
15
+ * candidate that is not itself a working tree.
16
+ */
17
+ primaryWorktreeRoot: string | null;
18
+ /** Raw core.hooksPath value when configured, else null. */
19
+ hooksPathConfig: string | null;
20
+ /** Config origin line (from --show-origin) for the configured hooksPath. */
21
+ hooksPathOrigin: string | null;
22
+ }
23
+ export type GitRepositoryResolution = {
24
+ status: "ok";
25
+ context: GitRepositoryContext;
26
+ } | {
27
+ status: "not-a-repository";
28
+ } | {
29
+ status: "git-unavailable";
30
+ } | {
31
+ status: "git-refused";
32
+ /** First Git diagnostic (or fs detail) explaining the refusal. */
33
+ reason: string;
34
+ } | {
35
+ status: "unsupported";
36
+ reason: string;
37
+ };
38
+ /**
39
+ * Resolve the effective Git repository context for `cwd` by asking Git
40
+ * instead of assuming `<cwd>/.git`. The result distinguishes "no repository"
41
+ * (callers may fall back to standalone-workspace behavior) from repositories
42
+ * Kibi must not touch (bare repositories) and directories where Git refused
43
+ * operationally (dubious ownership, unreadable `.git`, access failures) — the
44
+ * last must never be mistaken for "no repository", because that would send
45
+ * callers into standalone workspace writes.
46
+ *
47
+ * implements REQ-git-hook-effective-install
48
+ */
49
+ export declare function resolveGitRepository(cwd?: string): GitRepositoryResolution;
50
+ //# sourceMappingURL=git-repository-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-repository-context.d.ts","sourceRoot":"","sources":["../../src/utils/git-repository-context.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,oBAAoB;IACnC,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,YAAY,EAAE,MAAM,CAAC;IACrB,kFAAkF;IAClF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;;;;OAKG;IACH,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,2DAA2D;IAC3D,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,4EAA4E;IAC5E,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,MAAM,uBAAuB,GAC/B;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,oBAAoB,CAAA;CAAE,GAC/C;IAAE,MAAM,EAAE,kBAAkB,CAAA;CAAE,GAC9B;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,GAC7B;IACE,MAAM,EAAE,aAAa,CAAC;IACtB,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAqH9C;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,MAAsB,GAC1B,uBAAuB,CAmJzB"}