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
@@ -23,6 +23,7 @@ per operation. Effects are authoritative for mutability and adapter annotations.
23
23
  | `kb_upsert` | `upsert` | --input JSON | write | yes | kb-write, workspace-write | peer; capability-selected | kibi.kb_upsert.v1 | yes | unsafe | no | yes |
24
24
  | `kb_delete` | `delete` | --input JSON | write | yes | kb-write, workspace-write | peer; capability-selected | kibi.kb_delete.v1 | yes | unsafe | no | yes |
25
25
  | `kb_check` | `check` | --input JSON or flags | read | yes | kb-read, workspace-read | peer; capability-selected | kibi.kb_check.v1 | no | safe | no | yes |
26
+ | `kb_prepare_impact_review` | `prepare-impact-review` | --input JSON | read | no | workspace-read, kb-read | peer; capability-selected | kibi.kb_prepare_impact_review.v1 | no | safe | no | yes |
26
27
  | `kb_sparql_remote` | `sparql-remote` | --input JSON | read | no | network-read | peer; capability-selected | kibi.kb_sparql_remote.v1 | no | safe | yes | yes |
27
28
  | `kb_compile_intent` | `compile-intent` | --input JSON | read | yes | kb-read, workspace-read | peer; capability-selected | kibi.kb_compile_intent.v1 | no | safe | no | yes |
28
29
  | `kb_apply_plan` | `apply-plan` | --input JSON | write | yes | kb-read, kb-write, workspace-read, workspace-write | peer; capability-selected | kibi.kb_apply_plan.v1 | yes | unsafe | no | yes |
@@ -12,6 +12,7 @@
12
12
  | `constrains` | req -> fact(subject) | Requirement constrains a strict-lane domain fact |
13
13
  | `requires_property` | req -> fact(property_value) | Requirement requires a specific property value fact |
14
14
  | `supersedes` | new-req -> old-req | New requirement formally replaces an old requirement |
15
+ | `restates` | req -> req | Requirement intentionally restates another current requirement (for example a product requirement echoed in a platform requirement); suppresses `domain-redundancy` for that pair without retiring either side |
15
16
  | `covered_by` | symbol -> test | Production symbol has test coverage evidence |
16
17
 
17
18
  ## Valid Payload Examples
@@ -20,32 +21,32 @@
20
21
  ```yaml
21
22
  relationships:
22
23
  - type: implements
23
- from: SYM-001
24
- to: REQ-001
24
+ from: SYM-operation-execute-check
25
+ to: REQ-cli-check
25
26
  ```
26
27
 
27
28
  ### specified_by
28
29
  ```yaml
29
30
  relationships:
30
31
  - type: specified_by
31
- from: REQ-001
32
- to: SCEN-001
32
+ from: REQ-mcp-search-discovery
33
+ to: SCEN-mcp-search-discovery
33
34
  ```
34
35
 
35
36
  ### verified_by
36
37
  ```yaml
37
38
  relationships:
38
39
  - type: verified_by
39
- from: REQ-001
40
- to: TEST-001
40
+ from: REQ-mcp-search-discovery
41
+ to: TEST-mcp-search-discovery
41
42
  ```
42
43
 
43
44
  ### validates
44
45
  ```yaml
45
46
  relationships:
46
47
  - type: validates
47
- from: TEST-001
48
- to: SCEN-001
48
+ from: TEST-mcp-search-discovery
49
+ to: SCEN-mcp-search-discovery
49
50
  ```
50
51
 
51
52
  ### executable_for
@@ -53,39 +54,56 @@ relationships:
53
54
  relationships:
54
55
  - type: executable_for
55
56
  from: SYM-test-login
56
- to: TEST-001
57
+ to: TEST-mcp-search-discovery
57
58
  ```
58
59
 
59
60
  ### constrains
60
61
  ```yaml
61
62
  relationships:
62
63
  - type: constrains
63
- from: REQ-019
64
- to: FACT-USER-ROLE
64
+ from: REQ-cli-check
65
+ to: FACT-SUBJECT-KIBI-CHECK
65
66
  ```
66
67
 
67
68
  ### requires_property
68
69
  ```yaml
69
70
  relationships:
70
71
  - type: requires_property
71
- from: REQ-019
72
- to: FACT-LIMIT-3
72
+ from: REQ-cli-check
73
+ to: FACT-PROP-CHECK-FAILURE-EXIT-CODE
73
74
  ```
74
75
 
75
76
  ### supersedes
76
77
  ```yaml
77
78
  relationships:
78
79
  - type: supersedes
79
- from: REQ-001-v2
80
- to: REQ-001
80
+ from: REQ-opencode-kibi-briefing-v2
81
+ to: REQ-opencode-kibi-briefing-v1
81
82
  ```
82
83
 
84
+ A `-v2` suffix is acceptable only for a direct superseding replacement like
85
+ this one; otherwise name the new requirement by the behavior it governs.
86
+
87
+ ### restates
88
+ ```yaml
89
+ # Illustrative: a product requirement echoes a platform requirement verbatim.
90
+ relationships:
91
+ - type: restates
92
+ from: REQ-billing-invoice-retention
93
+ to: REQ-platform-record-retention
94
+ ```
95
+
96
+ Use `restates` only when two current requirements deliberately ground the same
97
+ logical term (same predicate, property tuple, or rule semantic key). It keeps
98
+ both requirements current and tells `domain-redundancy` the duplication is
99
+ intentional. If one requirement replaces the other, use `supersedes` instead.
100
+
83
101
  ### covered_by
84
102
  ```yaml
85
103
  relationships:
86
104
  - type: covered_by
87
- from: SYM-handler
88
- to: TEST-005
105
+ from: SYM-operation-execute-check
106
+ to: TEST-mcp-search-discovery
89
107
  ```
90
108
 
91
109
  ## Invalid Test-Fact Shortcuts
@@ -29,3 +29,39 @@ Cancellation follows the same rule: wait for the terminal journal state. A
29
29
  pre-commit rollback is retryable, a committed source with a failed derivative
30
30
  is repairable, and an indeterminate outcome is non-retryable until its recovery
31
31
  action resolves the journal.
32
+
33
+ ## Naming entities
34
+
35
+ Name every entity by what it governs, the way you would name a source file.
36
+ Never choose "the next number": parallel branches pick the same next number and
37
+ collide even when they touch unrelated behavior.
38
+
39
+ - Use `<TYPE>-<area>-<behavior>` in kebab-case, with the type prefix kept
40
+ uppercase: `REQ-cli-gc`, `SCEN-mcp-search-discovery`,
41
+ `TEST-mcp-search-discovery`, `ADR-capability-plugins-v1`,
42
+ `EVT-exact-branch-store-ensure`, and a flag named after its gate such as
43
+ `FLAG-scip-symbol-extraction`.
44
+ - The filename stem equals the frontmatter `id`
45
+ (`.kb/requirements/REQ-cli-gc.md` has `id: REQ-cli-gc`). Always set `id`
46
+ explicitly; a missing `id` falls back to a path-and-title hash that changes
47
+ when the file is renamed.
48
+ - Before creating an entity, `kb_search` the area. If an existing entity already
49
+ covers the behavior, update it, or create a replacement and link it with
50
+ `supersedes`. A `-v2` suffix is acceptable only for that direct superseding
51
+ replacement.
52
+ - A name collision with another branch usually means the same work was done
53
+ twice. Reconcile the two entities; do not rename one of them to dodge the
54
+ collision.
55
+ - The area prefix is for humans. Whether two requirements are about the same
56
+ thing is decided by their facts: a shared `subject_key` and identical
57
+ predicate or property signatures, which `domain-redundancy` and
58
+ `domain-contradictions` compare deterministically. Reuse existing subject keys
59
+ (dotted `component.aspect[.sub]`, lowercase snake segments such as
60
+ `kibi.cli.check.staged`) instead of deriving a subject from the requirement
61
+ ID.
62
+
63
+ `entity-id-style` reports new purely numeric IDs (`REQ-123`) and IDs whose
64
+ filename stem differs from `id` as non-blocking quality diagnostics. Legacy
65
+ numbered entities created before the naming standard are grandfathered and are
66
+ not renamed, because code comments such as `// implements REQ-003` still
67
+ reference them.
@@ -33,11 +33,62 @@ surfaces are a release defect: require a new package version and label any
33
33
  project override temporary. This skill never selects a package manager or
34
34
  edits dependency configuration.
35
35
 
36
+ ## Choosing a discovery mode
37
+
38
+ `kb_search` is not one behavior. It selects deterministic intent ranking when
39
+ you pass `rankingMode: "intent-v1"`, `semanticFacets`, or `sourceLocations`,
40
+ and legacy lexical ranking otherwise. Naming the tool is not enough; the inputs
41
+ decide the path.
42
+
43
+ - **Exact identity** — you already know the ID. Use `kb_query`, not search.
44
+ - **Literal token** — a symbol, file, or error string that appears verbatim.
45
+ Use lexical `kb_search` and keep the query close to the literal text.
46
+ - **Conceptual or behavioral** — "how does checkout handle a declined card".
47
+ Use intent mode and ground it in what you actually know:
48
+
49
+ ```json
50
+ {
51
+ "query": "declined card during checkout",
52
+ "rankingMode": "intent-v1",
53
+ "semanticFacets": {
54
+ "actors": ["shopper"],
55
+ "actions": ["pay"],
56
+ "objects": ["card"],
57
+ "constraints": ["declined"]
58
+ }
59
+ }
60
+ ```
61
+
62
+ - **Before changing code** — pass the file you are about to edit as a source
63
+ location, so results are matched against source-linked symbols and return
64
+ source evidence:
65
+
66
+ ```json
67
+ {
68
+ "query": "checkout total rounding",
69
+ "rankingMode": "intent-v1",
70
+ "sourceLocations": [{ "path": "src/checkout.ts", "symbol": "computeTotal" }]
71
+ }
72
+ ```
73
+
74
+ Supply facets only from the request, the code, or prior results. Inventing
75
+ facets fabricates evidence and biases ranking. Intent mode abstains below
76
+ `minScore` instead of returning weak matches; an abstention is an explicit
77
+ no-answer, so widen the query or drop to lexical search rather than treating it
78
+ as "nothing exists". There is no target percentage of intent-mode calls — a
79
+ literal identifier lookup is still best served lexically.
80
+
81
+ Results are summaries by default: identifying metadata, score, reasons, and a
82
+ snippet. Read them to pick candidates, then `kb_query` those IDs for full
83
+ bodies, or pass `fields: "full"` when you genuinely need every body. Extract
84
+ the relevant existing constraints and decisions from the response before
85
+ planning a behavior change; a search receipt is not comprehension.
86
+
36
87
  ## Discovery to Validation Sequence
37
88
 
38
89
  The canonical workflow for any KB operation follows this pattern:
39
90
 
40
- 1. **Discover**: `kb_search` with focused probes
91
+ 1. **Discover**: `kb_search` with focused probes; pick the mode above
41
92
  2. **Confirm**: `kb_query` for exact IDs and state
42
93
  3. **Inspect**: `kb_status` when freshness matters
43
94
  4. **Decompose**: `kb_semantic_advisor` on the complete normative prose; verify or supply every atomic clause
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-acceptance.d.ts","sourceRoot":"","sources":["../../src/public/telemetry-acceptance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,KAAK,EAEV,yBAAyB,EACzB,yBAAyB,EAGzB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAEzC,YAAY,EACV,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB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G,SAAS,EAC1B,QAAQ,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG,EAC3B,QAAQ,EAAE,MAAM,GACf,qBAAqB,CAKvB;AA0dD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,mBAAmB,EAAE,EACtC,GAAG,GAAE,IAAiB,EACtB,MAAM,GAAE,yBAA+D,GACtE,yBAAyB,CA6D3B;AA+DD,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,yBAAyB,GAChC,SAAS,iBAAiB,EAAE,CA+E9B"}
@@ -251,14 +251,30 @@ function advisorBeforeRequirementWriteMetric(all, recentStart, policy) {
251
251
  },
252
252
  };
253
253
  }
254
+ function sourceLookupMessage(zeroResults, lookups, unobservable) {
255
+ const unreadable = unobservable > 0
256
+ ? `${unobservable} source-linked lookups recorded no readable result count.`
257
+ : "";
258
+ if (lookups === 0) {
259
+ return (unreadable ||
260
+ "No source-linked query or search calls occurred in the evaluated window.");
261
+ }
262
+ const observed = `${zeroResults}/${lookups} source-linked lookups returned zero results.`;
263
+ return unreadable ? `${observed} ${unreadable}` : observed;
264
+ }
254
265
  function sourceLookupMetric(recent, policy) {
255
- const lookups = recent.filter(({ event }) => {
266
+ const sourceLinked = recent.filter(({ event }) => {
256
267
  if ((event.tool !== "kb_query" && event.tool !== "kb_search") ||
257
268
  !eventSucceeded(event)) {
258
269
  return false;
259
270
  }
260
271
  return typeof eventArgs(event).sourceFile === "string";
261
272
  });
273
+ // A row whose count could not be read is unobservable, not a hit. Counting
274
+ // it as a non-zero result would let a broken logger report a healthy rate.
275
+ const lookups = sourceLinked.filter(({ event }) => typeof event.result_count === "number" ||
276
+ typeof event.zero_results === "boolean");
277
+ const unobservable = sourceLinked.length - lookups.length;
262
278
  const zeroResults = lookups.filter(({ event }) => event.zero_results === true || event.result_count === 0);
263
279
  const actual = rate(zeroResults.length, lookups.length);
264
280
  const sourceCounts = new Map();
@@ -268,7 +284,9 @@ function sourceLookupMetric(recent, policy) {
268
284
  }
269
285
  return {
270
286
  id: "source_lookup_zero_result_rate",
271
- status: thresholdStatus(actual, "<=", policy.sourceLookupZeroResultMaximum),
287
+ status: lookups.length === 0 && unobservable > 0
288
+ ? "insufficient_evidence"
289
+ : thresholdStatus(actual, "<=", policy.sourceLookupZeroResultMaximum),
272
290
  numerator: zeroResults.length,
273
291
  denominator: lookups.length,
274
292
  ...(actual !== undefined ? { rate: actual } : {}),
@@ -276,9 +294,7 @@ function sourceLookupMetric(recent, policy) {
276
294
  operator: "<=",
277
295
  value: policy.sourceLookupZeroResultMaximum,
278
296
  },
279
- message: lookups.length === 0
280
- ? "No source-linked query or search calls occurred in the evaluated window."
281
- : `${zeroResults.length}/${lookups.length} source-linked lookups returned zero results.`,
297
+ message: sourceLookupMessage(zeroResults.length, lookups.length, unobservable),
282
298
  evidence: {
283
299
  zeroResultSourceFiles: [...sourceCounts.entries()]
284
300
  .sort(([leftFile, leftCount], [rightFile, rightCount]) => rightCount - leftCount || leftFile.localeCompare(rightFile))
@@ -50,6 +50,12 @@ export type RemovedRelationshipRecords = Readonly<{
50
50
  * Remove exact legacy-shard relationships using an atomic temp-file rename.
51
51
  * The caller is responsible for retracting the compiled RDF edge afterwards.
52
52
  */
53
+ /**
54
+ * A shard's YAML without the selected relationships. The sequence is patched in
55
+ * place so comments, ordering, and unrelated records survive; callers that must
56
+ * approve the bytes before writing (deletion plans) render without writing.
57
+ */
58
+ export declare function renderShardWithout(text: string, selectors: readonly RelationshipSelector[], shardPath: string): string;
53
59
  export declare function removeRelationshipsFromShards(kbRoot: string, selectors: readonly RelationshipSelector[]): RemovedRelationshipRecords[];
54
60
  /**
55
61
  * Appends a relationship to the appropriate shard.
@@ -1 +1 @@
1
- {"version":3,"file":"shards.d.ts","sourceRoot":"","sources":["../../src/relationships/shards.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAA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;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,kBAAkB,EAAE,EAC7B,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAC1B,kBAAkB,EAAE,CAKtB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAE1B,QAAQ,EAAE,kBAAkB,EAAE,EAC9B,QAAQ,EAAE,kBAAkB,EAAE,GAC7B,kBAAkB,EAAE,CAgCtB"}
@@ -163,6 +163,31 @@ function atomicWriteText(targetPath, body) {
163
163
  * Remove exact legacy-shard relationships using an atomic temp-file rename.
164
164
  * The caller is responsible for retracting the compiled RDF edge afterwards.
165
165
  */
166
+ /**
167
+ * A shard's YAML without the selected relationships. The sequence is patched in
168
+ * place so comments, ordering, and unrelated records survive; callers that must
169
+ * approve the bytes before writing (deletion plans) render without writing.
170
+ */
171
+ // implements REQ-kibi-operation-interface-parity
172
+ export function renderShardWithout(text, selectors, shardPath) {
173
+ const wanted = new Set(selectors.map((selector) => `${selector.type}\0${selector.from}\0${selector.to}`));
174
+ const document = parseDocument(text);
175
+ const sequence = document.get("relationships", true);
176
+ if (!sequence || typeof sequence !== "object" || !("items" in sequence)) {
177
+ throw new Error(`Invalid shard file: missing 'relationships' array at ${shardPath}`);
178
+ }
179
+ const items = sequence.items;
180
+ for (let index = items.length - 1; index >= 0; index -= 1) {
181
+ const item = items[index];
182
+ if (!item || typeof item !== "object" || !("get" in item))
183
+ continue;
184
+ const get = item.get.bind(item);
185
+ if (wanted.has(`${String(get("type"))}\0${String(get("from"))}\0${String(get("to"))}`)) {
186
+ document.deleteIn(["relationships", index]);
187
+ }
188
+ }
189
+ return document.toString();
190
+ }
166
191
  export function removeRelationshipsFromShards(kbRoot, selectors) {
167
192
  const wanted = new Set(selectors.map((selector) => `${selector.type}\0${selector.from}\0${selector.to}`));
168
193
  const removed = new Map();
@@ -171,25 +196,7 @@ export function removeRelationshipsFromShards(kbRoot, selectors) {
171
196
  const matching = records.filter((record) => wanted.has(`${record.type}\0${record.from}\0${record.to}`));
172
197
  if (matching.length === 0)
173
198
  continue;
174
- // Patch the YAML sequence in place so comments, ordering, and unrelated
175
- // records survive a relationship deletion. The compiled store is never
176
- // the mutation target; this shard remains the canonical source artifact.
177
- const document = parseDocument(fs.readFileSync(shardPath, "utf8"));
178
- const sequence = document.get("relationships", true);
179
- if (!sequence || typeof sequence !== "object" || !("items" in sequence)) {
180
- throw new Error(`Invalid shard file: missing 'relationships' array at ${shardPath}`);
181
- }
182
- const items = sequence.items;
183
- for (let index = items.length - 1; index >= 0; index -= 1) {
184
- const item = items[index];
185
- if (!item || typeof item !== "object" || !("get" in item))
186
- continue;
187
- const get = item.get.bind(item);
188
- if (wanted.has(`${String(get("type"))}\0${String(get("from"))}\0${String(get("to"))}`)) {
189
- document.deleteIn(["relationships", index]);
190
- }
191
- }
192
- atomicWriteText(shardPath, document.toString());
199
+ atomicWriteText(shardPath, renderShardWithout(fs.readFileSync(shardPath, "utf8"), selectors, shardPath));
193
200
  for (const record of matching) {
194
201
  const key = `${record.type}\0${record.from}\0${record.to}`;
195
202
  const entry = removed.get(key) ?? { paths: [], sources: [] };
@@ -1173,6 +1173,28 @@
1173
1173
  "type": "string"
1174
1174
  }
1175
1175
  },
1176
+ "argument_constants": {
1177
+ "type": "object",
1178
+ "additionalProperties": {
1179
+ "type": "array",
1180
+ "minItems": 1,
1181
+ "uniqueItems": true,
1182
+ "items": {
1183
+ "type": "string",
1184
+ "minLength": 1
1185
+ }
1186
+ }
1187
+ },
1188
+ "argument_aliases": {
1189
+ "type": "object",
1190
+ "additionalProperties": {
1191
+ "type": "object",
1192
+ "additionalProperties": {
1193
+ "type": "string",
1194
+ "minLength": 1
1195
+ }
1196
+ }
1197
+ },
1176
1198
  "rule_ir": {
1177
1199
  "$ref": "#/$defs/logicRule"
1178
1200
  },
@@ -1373,6 +1395,16 @@
1373
1395
  "predicate_args"
1374
1396
  ]
1375
1397
  },
1398
+ {
1399
+ "required": [
1400
+ "argument_constants"
1401
+ ]
1402
+ },
1403
+ {
1404
+ "required": [
1405
+ "argument_aliases"
1406
+ ]
1407
+ },
1376
1408
  {
1377
1409
  "required": [
1378
1410
  "rule_ir"
@@ -0,0 +1,39 @@
1
+ import type { HunkRange } from "./git-staged.js";
2
+ type LineRange = Readonly<{
3
+ startLine: number;
4
+ endLine: number;
5
+ }>;
6
+ export type GateAnalysis<Range extends LineRange> = Readonly<{
7
+ status: "ok" | "partial" | "unsupported" | "failed";
8
+ diagnosticCodes: readonly string[];
9
+ uncoveredRanges: readonly (Range & Readonly<{
10
+ reason: string;
11
+ }>)[];
12
+ }>;
13
+ /** What one side of a changed file needs before it can pass. */
14
+ type AnalysisObligation<Range extends LineRange> = Readonly<{
15
+ kind: "none";
16
+ }> | Readonly<{
17
+ kind: "blocked";
18
+ reason: string;
19
+ }> | Readonly<{
20
+ kind: "unsupported_review";
21
+ }> | Readonly<{
22
+ kind: "partial_review";
23
+ ranges: readonly Range[];
24
+ }>;
25
+ /**
26
+ * The single rule for when incomplete source analysis blocks a change.
27
+ *
28
+ * - The before side is historical and cannot be corrected by the author, so it
29
+ * is informational and never blocks or needs review.
30
+ * - On the after side, failed analysis and non-local gaps (syntax, parse,
31
+ * timeout, integrity) always block.
32
+ * - A local gap (a macro, decorator or other declared limitation) matters only
33
+ * where it overlaps the changed lines; elsewhere the file was already in that
34
+ * state and this change did not touch it.
35
+ * - Unsupported after-side analysis needs one whole-file review.
36
+ */
37
+ export declare function analysisObligation<Range extends LineRange>(side: "before" | "after", analysis: GateAnalysis<Range> | null | undefined, newHunkRanges: readonly HunkRange[]): AnalysisObligation<Range>;
38
+ export {};
39
+ //# sourceMappingURL=analysis-gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis-gate.d.ts","sourceRoot":"","sources":["../../src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+ * A deleted brace can surface as a syntax error far from the edited lines, so
4
+ * these never narrow to the changed hunks and never accept a residual review.
5
+ */
6
+ const NON_LOCAL_ANALYSIS_MARKER = /(?:syntax|parse|timeout|timed[\s_-]*out|integrity|checksum|failed|failure|error|input[\s_-]*limit)/i;
7
+ function hasNonLocalAnalysisGap(analysis) {
8
+ return NON_LOCAL_ANALYSIS_MARKER.test([
9
+ ...analysis.diagnosticCodes,
10
+ ...analysis.uncoveredRanges.map((range) => range.reason),
11
+ ].join("\n"));
12
+ }
13
+ /** Uncovered ranges that overlap a changed line of the after side. */
14
+ function rangesTouchingHunks(ranges, hunks) {
15
+ return ranges.filter((range) => hunks.some((hunk) => range.startLine <= hunk.end && hunk.start <= range.endLine));
16
+ }
17
+ /**
18
+ * The single rule for when incomplete source analysis blocks a change.
19
+ *
20
+ * - The before side is historical and cannot be corrected by the author, so it
21
+ * is informational and never blocks or needs review.
22
+ * - On the after side, failed analysis and non-local gaps (syntax, parse,
23
+ * timeout, integrity) always block.
24
+ * - A local gap (a macro, decorator or other declared limitation) matters only
25
+ * where it overlaps the changed lines; elsewhere the file was already in that
26
+ * state and this change did not touch it.
27
+ * - Unsupported after-side analysis needs one whole-file review.
28
+ */
29
+ // implements REQ-source-analysis-v2
30
+ export function analysisObligation(side, analysis, newHunkRanges) {
31
+ if (side === "before" || !analysis || analysis.status === "ok")
32
+ return { kind: "none" };
33
+ if (analysis.status === "failed")
34
+ return { kind: "blocked", reason: "source analysis failed" };
35
+ if (analysis.status === "unsupported")
36
+ return { kind: "unsupported_review" };
37
+ if (analysis.uncoveredRanges.length === 0)
38
+ return {
39
+ kind: "blocked",
40
+ reason: "partial analysis did not report which ranges it left uncovered",
41
+ };
42
+ if (hasNonLocalAnalysisGap(analysis))
43
+ return {
44
+ kind: "blocked",
45
+ reason: "a parser, syntax, timeout or integrity diagnostic affects the whole file",
46
+ };
47
+ const ranges = rangesTouchingHunks(analysis.uncoveredRanges, newHunkRanges);
48
+ return ranges.length === 0
49
+ ? { kind: "none" }
50
+ : { kind: "partial_review", ranges };
51
+ }
@@ -0,0 +1,27 @@
1
+ import type { StagedPath } from "./git-staged.js";
2
+ export type SnapshotGitReader = (args: readonly string[]) => Buffer;
3
+ export interface GitChangeSnapshot {
4
+ /** Tree at the captured base commit, or the canonical empty tree when unborn. */
5
+ baseTree: string;
6
+ /** The single tree written from the captured index (staged snapshots). */
7
+ headTree: string;
8
+ /** Captured base commit, or null for an unborn repository. */
9
+ headCommit: string | null;
10
+ /** Run a Git command against immutable captured trees/blobs. */
11
+ readGit(args: readonly string[]): Buffer;
12
+ /** Read immutable object IDs in one process; no working-tree reads. */
13
+ readBlobs(oids: readonly string[]): ReadonlyMap<string, Buffer>;
14
+ /** Reject a changed HEAD or index tree after staged analysis. */
15
+ assertUnchanged(): void;
16
+ inventory: StagedPath[];
17
+ }
18
+ /** Capture one immutable tree from the index and inventory only Git objects. */
19
+ export declare function captureStagedSnapshot(workspaceRoot: string): GitChangeSnapshot;
20
+ /**
21
+ * Capture changes between explicit revisions. The caller chooses `base`; for
22
+ * merge-impact analysis this is commonly the merge base computed with
23
+ * `git merge-base target head`. This helper resolves each input once and does
24
+ * not silently choose a merge base of its own.
25
+ */
26
+ export declare function captureDiffSnapshot(workspaceRoot: string, base: string, head: string): GitChangeSnapshot;
27
+ //# sourceMappingURL=git-change-snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-change-snapshot.d.ts","sourceRoot":"","sources":["../../src/traceability/git-change-snapshot.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAIV,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAKzB,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,KAAK,MAAM,CAAC;AAGpE,MAAM,WAAW,iBAAiB;IAChC,iFAAiF;IACjF,QAAQ,EAAE,MAAM,CAAC;IACjB,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gEAAgE;IAChE,OAAO,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAAC;IACzC,uEAAuE;IACvE,SAAS,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChE,iEAAiE;IACjE,eAAe,IAAI,IAAI,CAAC;IACxB,SAAS,EAAE,UAAU,EAAE,CAAC;CACzB;AA4cD,gFAAgF;AAEhF,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,GACpB,iBAAiB,CAuBnB;AAED;;;;;GAKG;AAEH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,iBAAiB,CAyBnB"}