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
@@ -0,0 +1,270 @@
1
+ import entitySchema from "../schemas/entity.schema.json" with { type: "json" };
2
+ import { analysisObligation } from "./analysis-gate.js";
3
+ import { entityRowsWithRelationships, rawKnowledgeFingerprint, requirementScope, semanticKnowledgeFingerprint, } from "./impact-knowledge.js";
4
+ import { approvedPartialClass, loadBaseImpactPolicy } from "./impact-policy.js";
5
+ import impactPolicySchema from "./impact-policy.v1.schema.json" with {
6
+ type: "json"
7
+ };
8
+ import { recordFromCapturedTree, same, validateAnalysisReviews, validateDecisionAgainstSnapshot, } from "./impact-record-validation.js";
9
+ import { IMPACT_EVALUATOR_VERSION, IMPACT_REVIEW_PATH, IMPACT_REVIEW_VERSION, assertSha256, fingerprint, parseImpactReviewRecord, } from "./impact-review.js";
10
+ import impactReviewSchema from "./impact-review.schema.json" with {
11
+ type: "json"
12
+ };
13
+ import { assertAnalysisInput, exactPathProjection, isReceiptOnlyChange, projectedPathEvidence, sideEvidence, } from "./impact-side-evidence.js";
14
+ /**
15
+ * Identify the trusted evaluator by the contract it implements, not by where
16
+ * it is installed. The identity is the evaluator contract version plus the
17
+ * canonical JSON of every schema the evaluator and KB normalization consume.
18
+ * Schemas are imported (and therefore inlined by bundlers), so the CLI, the
19
+ * bundled runtime and CI compute the same value for the same release on any
20
+ * machine or Node version. Bump IMPACT_EVALUATOR_VERSION whenever decision
21
+ * semantics change so reviews bound to the old evaluator become stale.
22
+ */
23
+ // implements REQ-impact-policy-stage-e-content-bound-review
24
+ export function fingerprintImpactEvaluator() {
25
+ return fingerprint({
26
+ contractVersion: "kibi.impact-evaluator-identity.v2",
27
+ evaluatorVersion: IMPACT_EVALUATOR_VERSION,
28
+ schemas: {
29
+ entity: fingerprint(entitySchema),
30
+ impactPolicy: fingerprint(impactPolicySchema),
31
+ impactReview: fingerprint(impactReviewSchema),
32
+ },
33
+ });
34
+ }
35
+ export function prepareImpactReview(snapshot, options) {
36
+ assertSha256(options.providerSetFingerprint, "Provider-set fingerprint");
37
+ assertSha256(options.evaluatorFingerprint, "Evaluator fingerprint");
38
+ const policy = loadBaseImpactPolicy(snapshot);
39
+ const policyFingerprint = fingerprint(policy);
40
+ const baseEntities = entityRowsWithRelationships(snapshot, snapshot.baseTree);
41
+ const headEntities = entityRowsWithRelationships(snapshot, snapshot.headTree);
42
+ const knowledgeFingerprint = fingerprint({
43
+ baseRaw: rawKnowledgeFingerprint(snapshot, snapshot.baseTree),
44
+ headRaw: rawKnowledgeFingerprint(snapshot, snapshot.headTree),
45
+ baseSemantic: semanticKnowledgeFingerprint(baseEntities),
46
+ headSemantic: semanticKnowledgeFingerprint(headEntities),
47
+ });
48
+ const sourceInventory = impactReviewInventory(snapshot);
49
+ const inventoryPaths = new Set(sourceInventory.map((file) => file.path));
50
+ const receiptOnlyPaths = new Set(snapshot.inventory.filter(isReceiptOnlyChange).map((file) => file.path));
51
+ for (const path of options.analyses.keys())
52
+ if (path !== IMPACT_REVIEW_PATH &&
53
+ !inventoryPaths.has(path) &&
54
+ !receiptOnlyPaths.has(path))
55
+ throw new Error(`Analysis contains an extraneous changed path: ${path}`);
56
+ const files = [];
57
+ const scopeFiles = [];
58
+ const scopedRequirementIdsByPath = new Map();
59
+ for (const file of sourceInventory) {
60
+ const suppliedChange = options.analyses.get(file.path);
61
+ const projectedFile = projectedPathEvidence(suppliedChange?.after?.status === "ok"
62
+ ? { ...file, analysisDepth: "symbol", disposition: "checked" }
63
+ : file);
64
+ const change = file.analysisDepth === "metadata" || file.skipReason
65
+ ? undefined
66
+ : suppliedChange;
67
+ assertAnalysisInput(file, change);
68
+ const previousPath = file.oldPath ?? file.copyFromPath ?? file.path;
69
+ const before = file.status === "A"
70
+ ? null
71
+ : sideEvidence(snapshot, snapshot.baseTree, previousPath, change?.before ?? null, file.previousContent);
72
+ const after = file.status === "D"
73
+ ? null
74
+ : sideEvidence(snapshot, snapshot.headTree, file.path, change?.after ?? null, file.content);
75
+ if (before === null && after === null)
76
+ throw new Error(`Changed path has no captured Git side: ${file.path}`);
77
+ const reviews = [];
78
+ const reqIds = new Set();
79
+ for (const [side, evidence, path] of [
80
+ ["before", before, previousPath],
81
+ ["after", after, file.path],
82
+ ]) {
83
+ const sourcePaths = path === file.path ? [file.path] : [path];
84
+ for (const id of requirementScope(baseEntities, sourcePaths))
85
+ reqIds.add(id);
86
+ for (const id of requirementScope(headEntities, sourcePaths))
87
+ reqIds.add(id);
88
+ const obligation = analysisObligation(side, evidence?.analysis, projectedFile.hunkRanges);
89
+ if (obligation.kind === "blocked")
90
+ throw new Error(`Required source analysis cannot pass for ${file.path} (${side}): ${obligation.reason}`);
91
+ if (obligation.kind === "unsupported_review" &&
92
+ !policy.allowUnsupportedReview)
93
+ throw new Error(`Unsupported source analysis is not reviewable by policy for ${file.path} (${side})`);
94
+ // The prepared snapshot lists what a reviewer must cover; it never
95
+ // manufactures the review itself. The record must supply rationale.
96
+ if (obligation.kind === "partial_review" &&
97
+ evidence?.analysis &&
98
+ !approvedPartialClass(policy, evidence.analysis))
99
+ throw new Error(`Partial source analysis is not allowed by trusted policy for ${file.path} (${side})`);
100
+ }
101
+ files.push({
102
+ path: projectedFile.path,
103
+ status: projectedFile.status,
104
+ ...(projectedFile.oldPath ? { oldPath: projectedFile.oldPath } : {}),
105
+ ...(projectedFile.copyFromPath
106
+ ? { copyFromPath: projectedFile.copyFromPath }
107
+ : {}),
108
+ analysisDepth: projectedFile.analysisDepth,
109
+ disposition: projectedFile.disposition,
110
+ ...(projectedFile.skipReason
111
+ ? { skipReason: projectedFile.skipReason }
112
+ : {}),
113
+ ...(projectedFile.gitMode ? { gitMode: projectedFile.gitMode } : {}),
114
+ ...(projectedFile.previousMode
115
+ ? { previousMode: projectedFile.previousMode }
116
+ : {}),
117
+ oldHunkRanges: projectedFile.oldHunkRanges ?? [],
118
+ newHunkRanges: projectedFile.hunkRanges,
119
+ before,
120
+ after,
121
+ analysisReviews: reviews,
122
+ });
123
+ scopeFiles.push(exactPathProjection(projectedFile, before, after));
124
+ scopedRequirementIdsByPath.set(file.path, [...reqIds].sort());
125
+ }
126
+ const scopePayload = {
127
+ contractVersion: IMPACT_EVALUATOR_VERSION,
128
+ policyFingerprint,
129
+ evaluatorFingerprint: options.evaluatorFingerprint,
130
+ providerSetFingerprint: options.providerSetFingerprint,
131
+ knowledgeFingerprint,
132
+ files: scopeFiles,
133
+ };
134
+ const scopeFingerprint = fingerprint(scopePayload);
135
+ return {
136
+ policy,
137
+ policyFingerprint,
138
+ evaluatorFingerprint: options.evaluatorFingerprint,
139
+ providerSetFingerprint: options.providerSetFingerprint,
140
+ knowledgeFingerprint,
141
+ scopeFingerprint,
142
+ files,
143
+ scopedRequirementIdsByPath,
144
+ baseEntities,
145
+ headEntities,
146
+ scopePayload,
147
+ };
148
+ }
149
+ export function createImpactReviewRecord(prepared, decisions, reviewerId, reviewedAt = new Date().toISOString()) {
150
+ if (!reviewerId.trim())
151
+ throw new Error("Reviewer id is required");
152
+ const expected = new Set(prepared.files.map((file) => file.path));
153
+ if (decisions.size !== expected.size ||
154
+ [...decisions.keys()].some((path) => !expected.has(path)))
155
+ throw new Error("Decisions must cover exactly the complete non-receipt inventory");
156
+ const files = prepared.files.map((file) => {
157
+ const item = decisions.get(file.path);
158
+ if (!item)
159
+ throw new Error(`Missing decision for ${file.path}`);
160
+ const authoredReviews = item.analysisReviews ?? [];
161
+ return {
162
+ ...file,
163
+ analysisReviews: authoredReviews,
164
+ decision: item.decision,
165
+ };
166
+ });
167
+ for (const file of files)
168
+ validateAnalysisReviews(file, prepared.policy);
169
+ return parseImpactReviewRecord({
170
+ contractVersion: IMPACT_REVIEW_VERSION,
171
+ policy: {
172
+ id: prepared.policy.id,
173
+ version: prepared.policy.version,
174
+ fingerprint: prepared.policyFingerprint,
175
+ },
176
+ evaluator: {
177
+ contractVersion: IMPACT_EVALUATOR_VERSION,
178
+ fingerprint: prepared.evaluatorFingerprint,
179
+ },
180
+ scope: {
181
+ fingerprint: prepared.scopeFingerprint,
182
+ knowledgeFingerprint: prepared.knowledgeFingerprint,
183
+ providerSetFingerprint: prepared.providerSetFingerprint,
184
+ },
185
+ reviewer: { id: reviewerId, source: "self-claimed-local" },
186
+ reviewedAt,
187
+ files,
188
+ });
189
+ }
190
+ export function evaluateImpactReview(snapshot, options) {
191
+ const diagnostics = [];
192
+ try {
193
+ const record = recordFromCapturedTree(snapshot);
194
+ const prepared = prepareImpactReview(snapshot, options);
195
+ if (record.policy.id !== prepared.policy.id ||
196
+ record.policy.version !== prepared.policy.version ||
197
+ record.policy.fingerprint !== prepared.policyFingerprint)
198
+ throw new Error("Review policy binding does not match trusted base policy");
199
+ if (record.evaluator.contractVersion !== IMPACT_EVALUATOR_VERSION ||
200
+ record.evaluator.fingerprint !== prepared.evaluatorFingerprint)
201
+ throw new Error("Review evaluator binding is stale");
202
+ if (record.scope.providerSetFingerprint !== prepared.providerSetFingerprint)
203
+ throw new Error("Review provider-set binding is stale");
204
+ if (record.scope.knowledgeFingerprint !== prepared.knowledgeFingerprint)
205
+ throw new Error("Review captured-knowledge binding is stale");
206
+ const expected = new Map(prepared.files.map((file) => [file.path, file]));
207
+ if (record.files.length !== expected.size)
208
+ throw new Error("Review omits or adds changed paths");
209
+ const changedPaths = new Set(snapshot.inventory.map((file) => file.path));
210
+ const seen = new Set();
211
+ for (const file of record.files) {
212
+ if (seen.has(file.path))
213
+ throw new Error(`Duplicate review path: ${file.path}`);
214
+ seen.add(file.path);
215
+ const captured = expected.get(file.path);
216
+ if (!captured)
217
+ throw new Error(`Review contains extraneous path: ${file.path}`);
218
+ const { decision: _decision, analysisReviews: _analysisReviews, ...capturedEvidence } = file;
219
+ const { analysisReviews: _capturedReviews, ...expectedEvidence } = captured;
220
+ if (!same(capturedEvidence, expectedEvidence)) {
221
+ const capturedFields = capturedEvidence;
222
+ const expectedFields = expectedEvidence;
223
+ const changedFields = [
224
+ ...new Set([
225
+ ...Object.keys(capturedFields),
226
+ ...Object.keys(expectedFields),
227
+ ]),
228
+ ]
229
+ .filter((field) => !same(capturedFields[field], expectedFields[field]))
230
+ .sort();
231
+ throw new Error(`Per-file Git or analysis fingerprint is stale: ${file.path} (${changedFields.join(", ")})`);
232
+ }
233
+ validateAnalysisReviews(file, prepared.policy);
234
+ validateDecisionAgainstSnapshot(file.path, file.decision, prepared, changedPaths);
235
+ }
236
+ for (const path of expected.keys())
237
+ if (!seen.has(path))
238
+ throw new Error(`Missing review path: ${path}`);
239
+ if (record.scope.fingerprint !== prepared.scopeFingerprint)
240
+ throw new Error(`Review scope fingerprint is stale (record ${record.scope.fingerprint}; prepared ${prepared.scopeFingerprint})`);
241
+ snapshot.assertUnchanged();
242
+ return {
243
+ passed: true,
244
+ scopeFingerprint: prepared.scopeFingerprint,
245
+ diagnostics,
246
+ reviewerAuthority: "self-claimed-local",
247
+ };
248
+ }
249
+ catch (error) {
250
+ diagnostics.push({
251
+ code: "impact_review_invalid",
252
+ message: error instanceof Error ? error.message : String(error),
253
+ });
254
+ return { passed: false, diagnostics, reviewerAuthority: "none" };
255
+ }
256
+ }
257
+ /** Verify that the transport path is unique and that no second path is excluded. */
258
+ export function impactReviewInventory(snapshot) {
259
+ const transport = snapshot.inventory.filter((file) => file.path === IMPACT_REVIEW_PATH);
260
+ if (transport.length > 1)
261
+ throw new Error("Duplicate impact review transport path");
262
+ const receipt = transport[0];
263
+ if (receipt &&
264
+ ((receipt.status !== "A" && receipt.status !== "M") ||
265
+ receipt.oldPath !== undefined ||
266
+ receipt.copyFromPath !== undefined))
267
+ throw new Error("Impact review receipt may only be added or modified at its exact path; rename/copy cannot hide another changed path");
268
+ return snapshot.inventory.filter((file) => file.path !== IMPACT_REVIEW_PATH && !isReceiptOnlyChange(file));
269
+ }
270
+ export { hasValidBaseImpactPolicy, impactPolicyFingerprint, loadBaseImpactPolicy, } from "./impact-policy.js";
@@ -0,0 +1,12 @@
1
+ import type { GitChangeSnapshot } from "./git-change-snapshot.js";
2
+ /** Read Git tree rows and blobs from a captured snapshot. */
3
+ export type TreeEntry = Readonly<{
4
+ mode: string;
5
+ type: string;
6
+ objectId: string;
7
+ path: string;
8
+ }>;
9
+ export declare function entriesForTree(snapshot: GitChangeSnapshot, tree: string): TreeEntry[];
10
+ export declare function treeEntry(snapshot: GitChangeSnapshot, tree: string, path: string): TreeEntry | undefined;
11
+ export declare function blobBytes(snapshot: GitChangeSnapshot, entry: TreeEntry): Buffer | undefined;
12
+ //# sourceMappingURL=impact-git-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"impact-git-tree.d.ts","sourceRoot":"","sources":["../../src/traceability/impact-git-tree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,6DAA6D;AAE7D,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AA2BH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,MAAM,GACX,SAAS,EAAE,CAEb;AAGD,wBAAgB,SAAS,CACvB,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,SAAS,GAAG,SAAS,CASvB;AAGD,wBAAgB,SAAS,CACvB,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,SAAS,GACf,MAAM,GAAG,SAAS,CAMpB"}
@@ -0,0 +1,46 @@
1
+ import { isGitObjectId } from "./impact-review.js";
2
+ function decodePath(bytes) {
3
+ return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
4
+ }
5
+ function parseTreeRows(bytes) {
6
+ const rows = [];
7
+ for (const raw of bytes.toString("binary").split("\0").filter(Boolean)) {
8
+ const tab = raw.indexOf("\t");
9
+ if (tab < 0)
10
+ throw new Error("Malformed Git tree listing");
11
+ const [mode, type, objectId] = raw.slice(0, tab).split(" ");
12
+ const path = decodePath(Buffer.from(raw.slice(tab + 1), "binary"));
13
+ if (!mode || !type || !objectId || !isGitObjectId(objectId))
14
+ throw new Error("Malformed Git tree entry");
15
+ if (path.startsWith("/") ||
16
+ path.includes("\\") ||
17
+ path.split("/").includes(".."))
18
+ throw new Error("Git snapshot path is not normalized");
19
+ rows.push({ mode, type, objectId, path });
20
+ }
21
+ return rows;
22
+ }
23
+ // implements REQ-impact-policy-stage-e-content-bound-review
24
+ export function entriesForTree(snapshot, tree) {
25
+ return parseTreeRows(snapshot.readGit(["ls-tree", "-r", "-z", tree]));
26
+ }
27
+ // implements REQ-impact-policy-stage-e-content-bound-review
28
+ export function treeEntry(snapshot, tree, path) {
29
+ const output = snapshot.readGit([
30
+ "ls-tree",
31
+ "-z",
32
+ tree,
33
+ "--",
34
+ `:(literal)${path}`,
35
+ ]);
36
+ return parseTreeRows(output).find((entry) => entry.path === path);
37
+ }
38
+ // implements REQ-impact-policy-stage-e-content-bound-review
39
+ export function blobBytes(snapshot, entry) {
40
+ if (entry.type !== "blob")
41
+ return undefined;
42
+ const bytes = snapshot.readBlobs([entry.objectId]).get(entry.objectId);
43
+ if (!bytes)
44
+ throw new Error(`Snapshot did not return blob bytes for ${entry.path}`);
45
+ return bytes;
46
+ }
@@ -0,0 +1,16 @@
1
+ import type { GitChangeSnapshot } from "./git-change-snapshot.js";
2
+ import { type Fingerprint } from "./impact-review.js";
3
+ /** Captured knowledge rows, semantic fingerprints and requirement scope. */
4
+ export type EntityRow = Readonly<{
5
+ id: string;
6
+ type: string;
7
+ fingerprint: Fingerprint;
8
+ artifactPath: string;
9
+ sourcePath?: string;
10
+ }>;
11
+ export declare function entityRows(snapshot: GitChangeSnapshot, tree: string, knowledge?: import("../extractors/markdown.js").ExtractionResult[]): Map<string, EntityRow>;
12
+ export declare function rawKnowledgeFingerprint(snapshot: GitChangeSnapshot, tree: string): Fingerprint;
13
+ export declare function semanticKnowledgeFingerprint(rows: ReadonlyMap<string, EntityRow>): Fingerprint;
14
+ export declare function requirementScope(rows: ReadonlyMap<string, EntityRow>, pathCandidates: readonly string[]): string[];
15
+ export declare function entityRowsWithRelationships(snapshot: GitChangeSnapshot, tree: string): Map<string, EntityRow>;
16
+ //# sourceMappingURL=impact-knowledge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"impact-knowledge.d.ts","sourceRoot":"","sources":["../../src/traceability/impact-knowledge.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EACL,KAAK,WAAW,EAIjB,MAAM,oBAAoB,CAAC;AAI5B,4EAA4E;AAE5E,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC;AA6EH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,MAAM,EACZ,SAAS,yDAAoE,GAC5E,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAyCxB;AAGD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,MAAM,GACX,WAAW,CAiBb;AAGD,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,GACnC,WAAW,CAoBb;AAGD,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,EACpC,cAAc,EAAE,SAAS,MAAM,EAAE,GAChC,MAAM,EAAE,CAsBV;AAeD,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,MAAM,GACX,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAiBxB"}
@@ -0,0 +1,165 @@
1
+ import { load as parseYaml } from "js-yaml";
2
+ import { snapshotFileContent } from "../public/operations/proof-receipt-projection.js";
3
+ import { blobBytes, entriesForTree } from "./impact-git-tree.js";
4
+ import { canonicalJson, fingerprint, fingerprintBytes, } from "./impact-review.js";
5
+ import { isKnowledgeMarkdown } from "./impact-side-evidence.js";
6
+ import { readSnapshotKnowledge } from "./snapshot-knowledge.js";
7
+ function semanticEntityFingerprint(result) {
8
+ const entity = result.entity;
9
+ // This is a narrow authored-field projection, not a claim of natural-language
10
+ // equivalence. Metadata edits still change the raw KB binding and require a
11
+ // refreshed record, but do not prove that requirement meaning changed.
12
+ const semantic = entity.type === "req"
13
+ ? { id: entity.id, type: entity.type }
14
+ : Object.fromEntries(Object.entries(entity)
15
+ .filter(([key]) => ![
16
+ "source",
17
+ "created_at",
18
+ "updated_at",
19
+ "title",
20
+ "proof_receipts",
21
+ ].includes(key))
22
+ .sort(([a], [b]) => a.localeCompare(b)));
23
+ if (entity.type === "req") {
24
+ if (entity.semantic_source_field === "title")
25
+ semantic.title = entity.title;
26
+ else if (entity.semantic_source_field === "text_ref")
27
+ semantic.text_ref = entity.text_ref;
28
+ else
29
+ semantic.semantic_text = entity.semantic_text;
30
+ for (const key of [
31
+ "semantic_clauses",
32
+ "logic_claims",
33
+ "proof_exempt",
34
+ "proof_exempt_reason",
35
+ "proof_contract",
36
+ "proof_bindings",
37
+ ])
38
+ if (entity[key] !== undefined)
39
+ semantic[key] = entity[key];
40
+ if (Array.isArray(entity.semantic_inventory)) {
41
+ semantic.semantic_inventory = entity.semantic_inventory
42
+ .map((raw) => {
43
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw))
44
+ throw new Error("Requirement semantic inventory row is invalid");
45
+ const row = raw;
46
+ return Object.fromEntries(["claim_key", "claim_text", "role", "semantic_key"].flatMap((key) => (row[key] === undefined ? [] : [[key, row[key]]])));
47
+ })
48
+ .sort((a, b) => canonicalJson(a).localeCompare(canonicalJson(b)));
49
+ }
50
+ }
51
+ const semanticRelationshipTypes = new Set([
52
+ "constrains",
53
+ "depends_on",
54
+ "requires_predicate",
55
+ "requires_property",
56
+ "requires_rule",
57
+ "specified_by",
58
+ "supersedes",
59
+ "validates",
60
+ "verified_by",
61
+ ]);
62
+ const relationships = result.relationships
63
+ .filter(({ type }) => entity.type !== "req" || semanticRelationshipTypes.has(type))
64
+ .map(({ type, from, to }) => ({ type, from, to }))
65
+ .sort((a, b) => canonicalJson(a).localeCompare(canonicalJson(b)));
66
+ return fingerprint({ entity: semantic, relationships });
67
+ }
68
+ // implements REQ-impact-policy-stage-e-content-bound-review
69
+ export function entityRows(snapshot, tree, knowledge = readSnapshotKnowledge(snapshot.readGit, tree, snapshot.readBlobs)) {
70
+ const mdFiles = entriesForTree(snapshot, tree).filter((entry) => entry.type === "blob" &&
71
+ entry.path.startsWith(".kb/") &&
72
+ entry.path.endsWith(".md"));
73
+ const symbolsPath = entriesForTree(snapshot, tree).find((entry) => entry.path === ".kb/symbols.yaml" || entry.path === ".kb/symbols.yml")?.path ?? "";
74
+ const artifactById = new Map();
75
+ for (const entry of mdFiles) {
76
+ const bytes = blobBytes(snapshot, entry);
77
+ if (!bytes)
78
+ continue;
79
+ const source = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
80
+ const frontmatter = /^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/.exec(source)?.[1];
81
+ if (!frontmatter)
82
+ continue;
83
+ const parsed = parseYaml(frontmatter);
84
+ if (parsed && typeof parsed.id === "string")
85
+ artifactById.set(parsed.id, entry.path);
86
+ }
87
+ const rows = new Map();
88
+ for (const result of knowledge) {
89
+ const id = result.entity.id;
90
+ const artifactPath = result.entity.type === "symbol"
91
+ ? symbolsPath
92
+ : (artifactById.get(id) ?? "");
93
+ rows.set(id, {
94
+ id,
95
+ type: result.entity.type,
96
+ fingerprint: semanticEntityFingerprint(result),
97
+ artifactPath,
98
+ ...(result.sourceFile ? { sourcePath: result.sourceFile } : {}),
99
+ });
100
+ }
101
+ return rows;
102
+ }
103
+ // implements REQ-impact-policy-stage-e-content-bound-review
104
+ export function rawKnowledgeFingerprint(snapshot, tree) {
105
+ const entries = entriesForTree(snapshot, tree).filter((entry) => entry.path === ".kb" || entry.path.startsWith(".kb/"));
106
+ const rows = entries.map((entry) => {
107
+ const bytes = blobBytes(snapshot, entry);
108
+ return {
109
+ path: entry.path,
110
+ mode: entry.mode,
111
+ type: entry.type,
112
+ ...(!isKnowledgeMarkdown(entry.path) ? { objectId: entry.objectId } : {}),
113
+ bytes: bytes
114
+ ? fingerprintBytes(snapshotFileContent(entry.path, bytes))
115
+ : null,
116
+ };
117
+ });
118
+ return fingerprint(rows);
119
+ }
120
+ // implements REQ-impact-policy-stage-e-content-bound-review
121
+ export function semanticKnowledgeFingerprint(rows) {
122
+ return fingerprint([...rows.values()]
123
+ .map(({ id, type, fingerprint: entityFingerprint, artifactPath, sourcePath, }) => ({
124
+ id,
125
+ type,
126
+ fingerprint: entityFingerprint,
127
+ artifactPath,
128
+ sourcePath: sourcePath ?? null,
129
+ }))
130
+ .sort((a, b) => a.id.localeCompare(b.id)));
131
+ }
132
+ // implements REQ-impact-policy-stage-e-content-bound-review
133
+ export function requirementScope(rows, pathCandidates) {
134
+ const knowledge = [...rows.values()];
135
+ const symbols = knowledge.filter((row) => row.type === "symbol" &&
136
+ (pathCandidates.includes(row.sourcePath ?? "") ||
137
+ pathCandidates.includes(row.artifactPath)));
138
+ const relationshipRows = readOnlyRelationships(rows);
139
+ const ids = new Set();
140
+ for (const entity of knowledge)
141
+ if (entity.type === "req" && pathCandidates.includes(entity.artifactPath))
142
+ ids.add(entity.id);
143
+ for (const symbol of symbols)
144
+ for (const relation of relationshipRows.get(symbol.id) ?? []) {
145
+ if (relation.type === "implements" &&
146
+ rows.get(relation.to)?.type === "req")
147
+ ids.add(relation.to);
148
+ }
149
+ return [...ids].sort();
150
+ }
151
+ function readOnlyRelationships(rows) {
152
+ // Filled by the private semantic side-table below; kept separate from public entity fingerprints.
153
+ return relationshipSideTables.get(rows) ?? new Map();
154
+ }
155
+ const relationshipSideTables = new WeakMap();
156
+ // implements REQ-impact-policy-stage-e-content-bound-review
157
+ export function entityRowsWithRelationships(snapshot, tree) {
158
+ const knowledge = readSnapshotKnowledge(snapshot.readGit, tree, snapshot.readBlobs);
159
+ const rows = entityRows(snapshot, tree, knowledge);
160
+ relationshipSideTables.set(rows, new Map(knowledge.map((result) => [
161
+ result.entity.id,
162
+ result.relationships.map(({ type, to }) => ({ type, to })),
163
+ ])));
164
+ return rows;
165
+ }
@@ -0,0 +1,15 @@
1
+ import type { GitChangeSnapshot } from "./git-change-snapshot.js";
2
+ import { type Fingerprint, type ImpactPolicy, type SideEvidence } from "./impact-review.js";
3
+ /** Trusted base impact policy loading and partial-analysis allowances. */
4
+ export declare function approvedPartialClass(policy: ImpactPolicy, analysis: NonNullable<SideEvidence["analysis"]>): string | null;
5
+ export declare function loadBaseImpactPolicy(snapshot: GitChangeSnapshot): ImpactPolicy;
6
+ /**
7
+ * A staged review is enabled only after a valid policy exists in the captured
8
+ * base tree. A staged policy addition cannot authorize its own review, and a
9
+ * candidate deletion cannot disable a policy already trusted by the base.
10
+ * Any present but invalid entry fails closed through loadBaseImpactPolicy.
11
+ */
12
+ export declare function hasValidBaseImpactPolicy(snapshot: GitChangeSnapshot): boolean;
13
+ /** Policy digest helper for tooling that prints a reviewable base policy. */
14
+ export declare function impactPolicyFingerprint(policy: ImpactPolicy): Fingerprint;
15
+ //# sourceMappingURL=impact-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"impact-policy.d.ts","sourceRoot":"","sources":["../../src/traceability/impact-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,YAAY,EACjB,KAAK,YAAY,EAGlB,MAAM,oBAAoB,CAAC;AAE5B,0EAA0E;AAE1E,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,YAAY,EACpB,QAAQ,EAAE,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,GAC9C,MAAM,GAAG,IAAI,CAoBf;AAED,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,iBAAiB,GAC1B,YAAY,CAed;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAI7E;AAED,6EAA6E;AAC7E,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,YAAY,GAAG,WAAW,CAEzE"}
@@ -0,0 +1,48 @@
1
+ import { blobBytes, treeEntry } from "./impact-git-tree.js";
2
+ import { IMPACT_POLICY_PATH, fingerprint, parseImpactPolicy, } from "./impact-review.js";
3
+ /** Trusted base impact policy loading and partial-analysis allowances. */
4
+ // implements REQ-impact-policy-stage-e-content-bound-review
5
+ export function approvedPartialClass(policy, analysis) {
6
+ if (analysis.status !== "partial" ||
7
+ !analysis.providerId ||
8
+ !analysis.providerFingerprint ||
9
+ analysis.diagnosticCodes.length === 0)
10
+ return null;
11
+ const classes = new Set();
12
+ for (const code of analysis.diagnosticCodes) {
13
+ const entry = policy.allowedPartial.find((candidate) => candidate.providerId === analysis.providerId &&
14
+ candidate.providerFingerprint === analysis.providerFingerprint &&
15
+ candidate.diagnosticCode === code);
16
+ if (!entry)
17
+ return null;
18
+ classes.add(entry.limitationClass);
19
+ }
20
+ return classes.size === 1 ? ([...classes][0] ?? null) : null;
21
+ }
22
+ export function loadBaseImpactPolicy(snapshot) {
23
+ const entry = treeEntry(snapshot, snapshot.baseTree, IMPACT_POLICY_PATH);
24
+ if (!entry ||
25
+ entry.type !== "blob" ||
26
+ (entry.mode !== "100644" && entry.mode !== "100755"))
27
+ throw new Error(`Trusted base policy missing or not a regular file: ${IMPACT_POLICY_PATH}`);
28
+ const bytes = blobBytes(snapshot, entry);
29
+ if (!bytes)
30
+ throw new Error("Trusted impact policy blob is missing");
31
+ return parseImpactPolicy(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes)));
32
+ }
33
+ /**
34
+ * A staged review is enabled only after a valid policy exists in the captured
35
+ * base tree. A staged policy addition cannot authorize its own review, and a
36
+ * candidate deletion cannot disable a policy already trusted by the base.
37
+ * Any present but invalid entry fails closed through loadBaseImpactPolicy.
38
+ */
39
+ export function hasValidBaseImpactPolicy(snapshot) {
40
+ if (!treeEntry(snapshot, snapshot.baseTree, IMPACT_POLICY_PATH))
41
+ return false;
42
+ loadBaseImpactPolicy(snapshot);
43
+ return true;
44
+ }
45
+ /** Policy digest helper for tooling that prints a reviewable base policy. */
46
+ export function impactPolicyFingerprint(policy) {
47
+ return fingerprint(parseImpactPolicy(policy));
48
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:kibi:impact-policy:v1",
4
+ "title": "Kibi trusted base-tree impact policy",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "contractVersion",
9
+ "id",
10
+ "version",
11
+ "allowUnsupportedReview",
12
+ "allowedPartial",
13
+ "notApplicablePaths"
14
+ ],
15
+ "properties": {
16
+ "contractVersion": { "const": "kibi.impact-policy.v1" },
17
+ "id": { "type": "string", "minLength": 1 },
18
+ "version": { "type": "string", "minLength": 1 },
19
+ "allowUnsupportedReview": { "type": "boolean" },
20
+ "allowedPartial": {
21
+ "type": "array",
22
+ "items": {
23
+ "type": "object",
24
+ "additionalProperties": false,
25
+ "required": [
26
+ "providerId",
27
+ "providerFingerprint",
28
+ "diagnosticCode",
29
+ "limitationClass"
30
+ ],
31
+ "properties": {
32
+ "providerId": { "type": "string", "minLength": 1 },
33
+ "providerFingerprint": { "$ref": "#/$defs/sha256" },
34
+ "diagnosticCode": { "type": "string", "minLength": 1 },
35
+ "limitationClass": { "type": "string", "minLength": 1 }
36
+ }
37
+ }
38
+ },
39
+ "notApplicablePaths": {
40
+ "type": "array",
41
+ "uniqueItems": true,
42
+ "items": { "type": "string", "minLength": 1, "pattern": "^[^/].*$" }
43
+ }
44
+ },
45
+ "$defs": {
46
+ "sha256": { "type": "string", "pattern": "^sha256:[0-9a-f]{64}$" }
47
+ }
48
+ }
@@ -0,0 +1,5 @@
1
+ import type { GitChangeSnapshot } from "./git-change-snapshot.js";
2
+ import type { TrustedPullRequestSnapshot } from "./trusted-pr-event.js";
3
+ /** Require a merge-base snapshot that still reflects the protected target state. */
4
+ export declare function assertTrustedPullRequestBaseline(snapshot: GitChangeSnapshot, event: TrustedPullRequestSnapshot): void;
5
+ //# sourceMappingURL=impact-pr-diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"impact-pr-diff.d.ts","sourceRoot":"","sources":["../../src/traceability/impact-pr-diff.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAqExE,oFAAoF;AACpF,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,iBAAiB,EAC3B,KAAK,EAAE,0BAA0B,GAChC,IAAI,CA6CN"}