kibi-cli 2.4.0 → 2.5.1

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 (354) hide show
  1. package/dist/cli-json-command.d.ts +6 -0
  2. package/dist/cli-json-command.d.ts.map +1 -1
  3. package/dist/cli-json-command.js +37 -9
  4. package/dist/cli-operation-loader.d.ts.map +1 -1
  5. package/dist/cli-operation-loader.js +7 -0
  6. package/dist/cli-operation-metadata.d.ts +12 -4
  7. package/dist/cli-operation-metadata.d.ts.map +1 -1
  8. package/dist/cli-operation-metadata.js +14 -4
  9. package/dist/cli-protocol.d.ts +14 -0
  10. package/dist/cli-protocol.d.ts.map +1 -1
  11. package/dist/cli-protocol.js +31 -2
  12. package/dist/cli-register-proof.d.ts.map +1 -1
  13. package/dist/cli-register-proof.js +13 -0
  14. package/dist/commands/check.d.ts.map +1 -1
  15. package/dist/commands/check.js +11 -2
  16. package/dist/commands/discovery-shared.d.ts.map +1 -1
  17. package/dist/commands/discovery-shared.js +8 -2
  18. package/dist/commands/engine.d.ts.map +1 -1
  19. package/dist/commands/engine.js +4 -2
  20. package/dist/commands/gc.d.ts.map +1 -1
  21. package/dist/commands/gc.js +7 -0
  22. package/dist/commands/init-helpers.d.ts.map +1 -1
  23. package/dist/commands/init-helpers.js +38 -12
  24. package/dist/commands/init.d.ts.map +1 -1
  25. package/dist/commands/init.js +10 -15
  26. package/dist/commands/migrate.d.ts.map +1 -1
  27. package/dist/commands/migrate.js +281 -14
  28. package/dist/commands/proof-compact.d.ts +9 -0
  29. package/dist/commands/proof-compact.d.ts.map +1 -0
  30. package/dist/commands/proof-compact.js +58 -0
  31. package/dist/commands/prove.d.ts +38 -0
  32. package/dist/commands/prove.d.ts.map +1 -1
  33. package/dist/commands/prove.js +222 -47
  34. package/dist/commands/sync/persistence.d.ts.map +1 -1
  35. package/dist/commands/sync/persistence.js +61 -16
  36. package/dist/commands/sync.d.ts +8 -0
  37. package/dist/commands/sync.d.ts.map +1 -1
  38. package/dist/commands/sync.js +42 -16
  39. package/dist/diagnostics.js +1 -1
  40. package/dist/engine-limits.d.ts +74 -0
  41. package/dist/engine-limits.d.ts.map +1 -0
  42. package/dist/engine-limits.js +201 -0
  43. package/dist/engine.d.ts +10 -0
  44. package/dist/engine.d.ts.map +1 -1
  45. package/dist/engine.js +57 -9
  46. package/dist/extractors/manifest.d.ts +8 -0
  47. package/dist/extractors/manifest.d.ts.map +1 -1
  48. package/dist/extractors/manifest.js +34 -5
  49. package/dist/extractors/markdown.d.ts +8 -0
  50. package/dist/extractors/markdown.d.ts.map +1 -1
  51. package/dist/extractors/markdown.js +57 -0
  52. package/dist/extractors/relationships.d.ts.map +1 -1
  53. package/dist/extractors/relationships.js +2 -0
  54. package/dist/intent-search.d.ts +4 -1
  55. package/dist/intent-search.d.ts.map +1 -1
  56. package/dist/intent-search.js +186 -33
  57. package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
  58. package/dist/operations/bootstrap/candidate-helpers.js +8 -1
  59. package/dist/operations/bootstrap/candidates.d.ts.map +1 -1
  60. package/dist/operations/bootstrap/candidates.js +54 -38
  61. package/dist/operations/bootstrap/generate.d.ts +2 -0
  62. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  63. package/dist/operations/bootstrap/generate.js +87 -33
  64. package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
  65. package/dist/operations/bootstrap/intent-claims.js +12 -4
  66. package/dist/operations/bootstrap/markdown-candidates.d.ts +2 -0
  67. package/dist/operations/bootstrap/markdown-candidates.d.ts.map +1 -1
  68. package/dist/operations/bootstrap/markdown-candidates.js +32 -10
  69. package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
  70. package/dist/operations/bootstrap/presentation.js +6 -2
  71. package/dist/operations/bootstrap/requirement-claims.d.ts +1 -0
  72. package/dist/operations/bootstrap/requirement-claims.d.ts.map +1 -1
  73. package/dist/operations/bootstrap/requirement-claims.js +13 -1
  74. package/dist/operations/bootstrap/validation.d.ts +4 -0
  75. package/dist/operations/bootstrap/validation.d.ts.map +1 -0
  76. package/dist/operations/bootstrap/validation.js +20 -0
  77. package/dist/operations/migration/inventory-rederive.d.ts +81 -0
  78. package/dist/operations/migration/inventory-rederive.d.ts.map +1 -0
  79. package/dist/operations/migration/inventory-rederive.js +484 -0
  80. package/dist/operations/migration/kb-sources.d.ts +53 -0
  81. package/dist/operations/migration/kb-sources.d.ts.map +1 -0
  82. package/dist/operations/migration/kb-sources.js +233 -0
  83. package/dist/operations/migration/origin-backfill.d.ts +39 -0
  84. package/dist/operations/migration/origin-backfill.d.ts.map +1 -0
  85. package/dist/operations/migration/origin-backfill.js +164 -0
  86. package/dist/operations/migration/polarity-values.d.ts +10 -0
  87. package/dist/operations/migration/polarity-values.d.ts.map +1 -0
  88. package/dist/operations/migration/polarity-values.js +60 -0
  89. package/dist/operations/migration/schema6.d.ts +59 -0
  90. package/dist/operations/migration/schema6.d.ts.map +1 -0
  91. package/dist/operations/migration/schema6.js +379 -0
  92. package/dist/operations/migration/source-paths.d.ts +131 -0
  93. package/dist/operations/migration/source-paths.d.ts.map +1 -0
  94. package/dist/operations/migration/source-paths.js +308 -0
  95. package/dist/operations/migration/superseded-closure.d.ts +54 -0
  96. package/dist/operations/migration/superseded-closure.d.ts.map +1 -0
  97. package/dist/operations/migration/superseded-closure.js +187 -0
  98. package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
  99. package/dist/operations/modeling/logic-modeling.js +3 -5
  100. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  101. package/dist/operations/modeling/model-requirement.js +225 -67
  102. package/dist/operations/mutation/contradictions.d.ts +16 -0
  103. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  104. package/dist/operations/mutation/contradictions.js +32 -0
  105. package/dist/operations/mutation/delete.d.ts.map +1 -1
  106. package/dist/operations/mutation/delete.js +15 -7
  107. package/dist/operations/mutation/origin.d.ts +21 -0
  108. package/dist/operations/mutation/origin.d.ts.map +1 -0
  109. package/dist/operations/mutation/origin.js +78 -0
  110. package/dist/operations/mutation/plan-apply-journal.d.ts +182 -0
  111. package/dist/operations/mutation/plan-apply-journal.d.ts.map +1 -0
  112. package/dist/operations/mutation/plan-apply-journal.js +613 -0
  113. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +3 -1
  114. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -1
  115. package/dist/operations/mutation/predicate-vocabulary-guard.js +13 -2
  116. package/dist/operations/mutation/relationships.d.ts +5 -5
  117. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  118. package/dist/operations/mutation/relationships.js +31 -11
  119. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  120. package/dist/operations/mutation/serialization.js +3 -1
  121. package/dist/operations/mutation/source-authoring.d.ts +6 -0
  122. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  123. package/dist/operations/mutation/source-authoring.js +7 -1
  124. package/dist/operations/mutation/types.d.ts +14 -0
  125. package/dist/operations/mutation/types.d.ts.map +1 -1
  126. package/dist/operations/mutation/upsert.d.ts +30 -3
  127. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  128. package/dist/operations/mutation/upsert.js +105 -35
  129. package/dist/operations/mutation/validate-upsert.d.ts +6 -0
  130. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  131. package/dist/operations/mutation/validate-upsert.js +34 -30
  132. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  133. package/dist/operations/planning/apply-plan.js +753 -145
  134. package/dist/operations/planning/compile-intent.d.ts +34 -1
  135. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  136. package/dist/operations/planning/compile-intent.js +314 -98
  137. package/dist/operations/proof/code-scope.d.ts +28 -0
  138. package/dist/operations/proof/code-scope.d.ts.map +1 -1
  139. package/dist/operations/proof/code-scope.js +72 -0
  140. package/dist/operations/proof/compact-receipts.d.ts +49 -0
  141. package/dist/operations/proof/compact-receipts.d.ts.map +1 -0
  142. package/dist/operations/proof/compact-receipts.js +160 -0
  143. package/dist/operations/proof/ingest-proof.d.ts +2 -0
  144. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  145. package/dist/operations/proof/ingest-proof.js +44 -23
  146. package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
  147. package/dist/operations/proof/prune-receipts.js +5 -9
  148. package/dist/operations/proof/receipt-compaction.d.ts +48 -0
  149. package/dist/operations/proof/receipt-compaction.d.ts.map +1 -0
  150. package/dist/operations/proof/receipt-compaction.js +121 -0
  151. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  152. package/dist/operations/semantic-advisor/analysis-receipt.js +12 -1
  153. package/dist/operations/semantic-advisor/analyze-prose.d.ts +2 -1
  154. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  155. package/dist/operations/semantic-advisor/analyze-prose.js +51 -5
  156. package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
  157. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  158. package/dist/operations/semantic-advisor/clauses.js +11 -1
  159. package/dist/operations/semantic-advisor/conditional-rules.d.ts +33 -0
  160. package/dist/operations/semantic-advisor/conditional-rules.d.ts.map +1 -0
  161. package/dist/operations/semantic-advisor/conditional-rules.js +262 -0
  162. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +3 -1
  163. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
  164. package/dist/operations/semantic-advisor/ingestion-boundary.js +14 -6
  165. package/dist/operations/semantic-advisor/plugin-orchestration.js +1 -1
  166. package/dist/prolog/codec.d.ts.map +1 -1
  167. package/dist/prolog/codec.js +2 -1
  168. package/dist/prolog.d.ts +9 -0
  169. package/dist/prolog.d.ts.map +1 -1
  170. package/dist/prolog.js +56 -10
  171. package/dist/proof/command-test-report.d.ts +74 -0
  172. package/dist/proof/command-test-report.d.ts.map +1 -0
  173. package/dist/proof/command-test-report.js +206 -0
  174. package/dist/public/branch-resolver.d.ts +1 -0
  175. package/dist/public/branch-resolver.d.ts.map +1 -1
  176. package/dist/public/branch-resolver.js +1 -0
  177. package/dist/public/entity-origin.d.ts +69 -0
  178. package/dist/public/entity-origin.d.ts.map +1 -0
  179. package/dist/public/entity-origin.js +142 -0
  180. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  181. package/dist/public/impact/full-kb-quality.js +1 -0
  182. package/dist/public/impact/requirement-quality.js +1 -1
  183. package/dist/public/operations/catalog.d.ts +130 -19
  184. package/dist/public/operations/catalog.d.ts.map +1 -1
  185. package/dist/public/operations/catalog.js +3 -0
  186. package/dist/public/operations/check-executor.d.ts.map +1 -1
  187. package/dist/public/operations/check-executor.js +8 -0
  188. package/dist/public/operations/contracts.d.ts +0 -5
  189. package/dist/public/operations/contracts.d.ts.map +1 -1
  190. package/dist/public/operations/contracts.js +63 -14
  191. package/dist/public/operations/discovery-entities.d.ts +15 -0
  192. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  193. package/dist/public/operations/discovery-entities.js +59 -0
  194. package/dist/public/operations/discovery-executors.d.ts +6 -1
  195. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  196. package/dist/public/operations/discovery-executors.js +65 -6
  197. package/dist/public/operations/index.d.ts +1 -0
  198. package/dist/public/operations/index.d.ts.map +1 -1
  199. package/dist/public/operations/index.js +1 -0
  200. package/dist/public/operations/migration-plan.d.ts +5 -0
  201. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  202. package/dist/public/operations/migration-plan.js +26 -1
  203. package/dist/public/operations/node-ports.d.ts.map +1 -1
  204. package/dist/public/operations/node-ports.js +24 -3
  205. package/dist/public/operations/origin-review.d.ts +51 -0
  206. package/dist/public/operations/origin-review.d.ts.map +1 -0
  207. package/dist/public/operations/origin-review.js +307 -0
  208. package/dist/public/operations/predicate-schema-conformance.js +1 -1
  209. package/dist/public/operations/repair-plan.d.ts.map +1 -1
  210. package/dist/public/operations/repair-plan.js +4 -0
  211. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  212. package/dist/public/operations/result-envelope.js +17 -5
  213. package/dist/public/operations/runtime-types.d.ts +9 -0
  214. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  215. package/dist/public/operations/schema6-check-actions.d.ts +127 -0
  216. package/dist/public/operations/schema6-check-actions.d.ts.map +1 -0
  217. package/dist/public/operations/schema6-check-actions.js +575 -0
  218. package/dist/public/operations/source-path-dangling.d.ts +17 -0
  219. package/dist/public/operations/source-path-dangling.d.ts.map +1 -0
  220. package/dist/public/operations/source-path-dangling.js +66 -0
  221. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  222. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  223. package/dist/public/operations/specs/check-rules.generated.js +15 -1
  224. package/dist/public/operations/specs/check.d.ts +2 -2
  225. package/dist/public/operations/specs/check.js +1 -1
  226. package/dist/public/operations/specs/composite.d.ts +351 -0
  227. package/dist/public/operations/specs/composite.d.ts.map +1 -0
  228. package/dist/public/operations/specs/composite.js +96 -0
  229. package/dist/public/operations/specs/discovery.d.ts +8 -3
  230. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  231. package/dist/public/operations/specs/discovery.js +8 -3
  232. package/dist/public/operations/specs/modeling.d.ts +2 -2
  233. package/dist/public/operations/specs/modeling.js +2 -2
  234. package/dist/public/operations/specs/mutation-schemas.d.ts +73 -8
  235. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  236. package/dist/public/operations/specs/mutation-schemas.js +43 -7
  237. package/dist/public/operations/specs/mutation.d.ts +1 -1
  238. package/dist/public/operations/specs/mutation.js +1 -1
  239. package/dist/public/operations/specs/planning.d.ts +2 -2
  240. package/dist/public/operations/specs/planning.js +4 -4
  241. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  242. package/dist/public/operations/specs/reporting.js +13 -26
  243. package/dist/public/operations/specs/upsert.d.ts +79 -9
  244. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  245. package/dist/public/operations/specs/upsert.js +6 -1
  246. package/dist/public/operations/types.d.ts +1 -1
  247. package/dist/public/operations/types.d.ts.map +1 -1
  248. package/dist/public/proof-receipt.d.ts +1 -0
  249. package/dist/public/proof-receipt.d.ts.map +1 -1
  250. package/dist/public/schemas/entity.d.ts.map +1 -1
  251. package/dist/public/schemas/entity.js +52 -0
  252. package/dist/public/schemas/relationship.d.ts.map +1 -1
  253. package/dist/public/schemas/relationship.js +2 -0
  254. package/dist/public/skills/kibi-bootstrap/SKILL.md +35 -67
  255. package/dist/public/skills/kibi-bootstrap/resources/bootstrap.md +6 -0
  256. package/dist/public/skills/kibi-usage/SKILL.md +68 -18
  257. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
  258. package/dist/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
  259. package/dist/public/skills/kibi-usage/resources/logic-ir.md +2 -2
  260. package/dist/public/skills/kibi-usage/resources/operation-access.md +25 -1
  261. package/dist/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
  262. package/dist/public/skills/kibi-usage/resources/workflows.md +42 -25
  263. package/dist/public/telemetry-acceptance.d.ts +58 -2
  264. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  265. package/dist/public/telemetry-acceptance.js +136 -10
  266. package/dist/public/telemetry-remediation.d.ts.map +1 -1
  267. package/dist/public/telemetry-remediation.js +26 -10
  268. package/dist/relationships/shards.d.ts +13 -0
  269. package/dist/relationships/shards.d.ts.map +1 -1
  270. package/dist/relationships/shards.js +54 -28
  271. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  272. package/dist/runtime/cli-runtime.js +44 -3
  273. package/dist/runtime/detached-snapshot.d.ts +38 -0
  274. package/dist/runtime/detached-snapshot.d.ts.map +1 -0
  275. package/dist/runtime/detached-snapshot.js +92 -0
  276. package/dist/schemas/entity.schema.json +122 -0
  277. package/dist/search-answer.d.ts +157 -0
  278. package/dist/search-answer.d.ts.map +1 -0
  279. package/dist/search-answer.js +846 -0
  280. package/dist/traceability/impact-knowledge.d.ts.map +1 -1
  281. package/dist/traceability/impact-knowledge.js +7 -0
  282. package/dist/traceability/symbol-extract.js +3 -3
  283. package/dist/traceability/temp-kb.d.ts.map +1 -1
  284. package/dist/traceability/temp-kb.js +12 -0
  285. package/dist/types/entities.d.ts +13 -0
  286. package/dist/types/entities.d.ts.map +1 -1
  287. package/dist/types/relationships.d.ts +1 -1
  288. package/dist/types/relationships.d.ts.map +1 -1
  289. package/dist/utils/branch-resolver.d.ts +37 -1
  290. package/dist/utils/branch-resolver.d.ts.map +1 -1
  291. package/dist/utils/branch-resolver.js +130 -3
  292. package/dist/utils/repo-relative-path.d.ts +18 -0
  293. package/dist/utils/repo-relative-path.d.ts.map +1 -0
  294. package/dist/utils/repo-relative-path.js +58 -0
  295. package/dist/utils/rule-registry.generated.d.ts +75 -3
  296. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  297. package/dist/utils/rule-registry.generated.js +89 -3
  298. package/dist/utils/schema-version.d.ts +1 -1
  299. package/dist/utils/schema-version.d.ts.map +1 -1
  300. package/dist/utils/schema-version.js +4 -3
  301. package/dist/utils/strict-modeling.d.ts +1 -1
  302. package/dist/utils/strict-modeling.d.ts.map +1 -1
  303. package/dist/utils/strict-modeling.js +23 -3
  304. package/package.json +3 -3
  305. package/schema/entities.pl +22 -0
  306. package/schema/relationships.pl +14 -0
  307. package/schema/validation.pl +45 -1
  308. package/src/public/branch-resolver.ts +1 -0
  309. package/src/public/entity-origin.ts +175 -0
  310. package/src/public/impact/full-kb-quality.ts +1 -0
  311. package/src/public/impact/requirement-quality.ts +1 -1
  312. package/src/public/operations/catalog.ts +3 -0
  313. package/src/public/operations/check-executor.ts +15 -0
  314. package/src/public/operations/contracts.ts +75 -15
  315. package/src/public/operations/discovery-entities.ts +74 -0
  316. package/src/public/operations/discovery-executors.ts +88 -10
  317. package/src/public/operations/index.ts +1 -0
  318. package/src/public/operations/migration-plan.ts +30 -1
  319. package/src/public/operations/node-ports.ts +24 -3
  320. package/src/public/operations/origin-review.ts +375 -0
  321. package/src/public/operations/predicate-schema-conformance.ts +1 -1
  322. package/src/public/operations/repair-plan.ts +4 -0
  323. package/src/public/operations/result-envelope.ts +18 -6
  324. package/src/public/operations/runtime-types.ts +9 -0
  325. package/src/public/operations/schema6-check-actions.ts +699 -0
  326. package/src/public/operations/source-path-dangling.ts +81 -0
  327. package/src/public/operations/specs/check-rules.generated.ts +15 -1
  328. package/src/public/operations/specs/check.ts +1 -1
  329. package/src/public/operations/specs/composite.ts +141 -0
  330. package/src/public/operations/specs/discovery.ts +9 -3
  331. package/src/public/operations/specs/modeling.ts +2 -2
  332. package/src/public/operations/specs/mutation-schemas.ts +49 -7
  333. package/src/public/operations/specs/mutation.ts +1 -1
  334. package/src/public/operations/specs/planning.ts +4 -4
  335. package/src/public/operations/specs/reporting.ts +13 -38
  336. package/src/public/operations/specs/upsert.ts +7 -1
  337. package/src/public/operations/types.ts +2 -0
  338. package/src/public/proof-receipt.ts +1 -0
  339. package/src/public/schemas/entity.ts +57 -0
  340. package/src/public/schemas/relationship.ts +2 -0
  341. package/src/public/skills/kibi-bootstrap/SKILL.md +35 -67
  342. package/src/public/skills/kibi-bootstrap/resources/bootstrap.md +6 -0
  343. package/src/public/skills/kibi-usage/SKILL.md +68 -18
  344. package/src/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
  345. package/src/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
  346. package/src/public/skills/kibi-usage/resources/logic-ir.md +2 -2
  347. package/src/public/skills/kibi-usage/resources/operation-access.md +25 -1
  348. package/src/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
  349. package/src/public/skills/kibi-usage/resources/workflows.md +42 -25
  350. package/src/public/telemetry-acceptance-types.d.ts +4 -1
  351. package/src/public/telemetry-acceptance.ts +204 -10
  352. package/src/public/telemetry-remediation.ts +39 -10
  353. package/src/schemas/entity.schema.json +122 -0
  354. package/src/schemas/relationship.schema.json +2 -0
@@ -1 +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"}
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;AAoFH,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"}
@@ -18,6 +18,8 @@ function semanticEntityFingerprint(result) {
18
18
  "updated_at",
19
19
  "title",
20
20
  "proof_receipts",
21
+ // Provenance metadata, not authored meaning.
22
+ "origin",
21
23
  ].includes(key))
22
24
  .sort(([a], [b]) => a.localeCompare(b)));
23
25
  if (entity.type === "req") {
@@ -27,11 +29,16 @@ function semanticEntityFingerprint(result) {
27
29
  semantic.text_ref = entity.text_ref;
28
30
  else
29
31
  semantic.semantic_text = entity.semantic_text;
32
+ // rationale explains why a requirement exists; it is not checked meaning,
33
+ // so editing it does not count as a semantic change.
30
34
  for (const key of [
31
35
  "semantic_clauses",
32
36
  "logic_claims",
33
37
  "proof_exempt",
34
38
  "proof_exempt_reason",
39
+ "approved_by",
40
+ "approval_ref",
41
+ "exempts_claims",
35
42
  "proof_contract",
36
43
  "proof_bindings",
37
44
  ])
@@ -11,7 +11,7 @@ const REQUIREMENT_ID_PATTERN = /^[A-Za-z][A-Za-z0-9\-_]*$/;
11
11
  const LOCAL_MANIFEST_NAMES = ["symbols.yaml", "symbols.yml"];
12
12
  const MANIFEST_SENTINEL_PREFIX = "__manifest__:";
13
13
  export function createManifestLookupSentinelKey(manifestPath) {
14
- // implements REQ-008
14
+ // implements REQ-cli-staged-impact-enforcement
15
15
  return `${MANIFEST_SENTINEL_PREFIX}${manifestPath}`;
16
16
  }
17
17
  function getCandidateManifestPaths(filePath) {
@@ -164,7 +164,7 @@ function analyzeWithBuiltinFallback(filePath, content) {
164
164
  return provider.analyzeText(filePath, content);
165
165
  }
166
166
  export function extractSymbolsFromStagedFile(
167
- // implements REQ-008
167
+ // implements REQ-cli-staged-impact-enforcement
168
168
  stagedFile, manifestLookup, options) {
169
169
  const content = stagedFile.content ?? "";
170
170
  const sha = computeContentSha(`${content}|${stagedFile.path}|${options?.analyzeText ? "custom" : "builtin"}`);
@@ -260,7 +260,7 @@ function intersectingHunks(startLine, endLine, hunks) {
260
260
  }
261
261
  return out;
262
262
  }
263
- // implements REQ-008
263
+ // implements REQ-cli-staged-impact-enforcement
264
264
  function sourceSymbolLocator(symbol, symbols, filePath, lookup) {
265
265
  const qualified = symbol.qualifiedName;
266
266
  if (!qualified || qualified === symbol.name)
@@ -1 +1 @@
1
- {"version":3,"file":"temp-kb.d.ts","sourceRoot":"","sources":["../../src/traceability/temp-kb.ts"],"names":[],"mappings":"AAMA,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,OAAO,CAET;AACD,OAAO,KAAK,EAGV,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,KAAK,EAAE,eAA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W,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,aAAa,CAAC;CACvB;AAMD;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CASvC;AAQD;;;GAGG;AACH,wBAAgB,iBAAiB,CAE/B,OAAO,EAAE,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,KAAK,aAAa,GACpE,IAAI,CAEN;AAyRD,iBAAe,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB/D;AAED,OAAO,EAAE,cAAc,EAAE,CAAC;AAe1B,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,gBAAgB,EAAE,GAC1B,OAAO,CAAC,IAAI,CAAC,CA4Df;AAED,wBAAsB,YAAY,CAChC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,aAAa,CAAC,CA+CxB;AAGD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,CAkBrE;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BlE"}
@@ -74,6 +74,7 @@ const FACT_STRING_ARRAY_FIELDS = new Set([
74
74
  "argument_names",
75
75
  "argument_types",
76
76
  "argument_descriptions",
77
+ "key_arguments",
77
78
  "aliases",
78
79
  "examples",
79
80
  "predicate_args",
@@ -185,6 +186,17 @@ function buildEntityAssertionGoal(entity, sourceFile) {
185
186
  if (entity.type === "req" && entity.semantic_inventory) {
186
187
  props.push(`semantic_inventory=${toPrologString(JSON.stringify(entity.semantic_inventory))}`);
187
188
  }
189
+ for (const field of ["approved_by", "approval_ref", "rationale"]) {
190
+ const value = entity.type === "req" ? entity[field] : undefined;
191
+ if (value !== undefined)
192
+ props.push(`${field}=${toPrologString(value)}`);
193
+ }
194
+ if (entity.type === "req" && entity.exempts_claims) {
195
+ props.push(`exempts_claims=[${entity.exempts_claims.map(toPrologAtom).join(",")}]`);
196
+ }
197
+ if (entity.origin !== undefined) {
198
+ props.push(`origin=${toPrologString(JSON.stringify(entity.origin))}`);
199
+ }
188
200
  if (sourceFile)
189
201
  props.push(`sourceFile=${toPrologString(sourceFile)}`);
190
202
  if (entity.type === "symbol") {
@@ -1,3 +1,4 @@
1
+ import type { EntityOrigin } from "../public/entity-origin.js";
1
2
  import type { ProofBinding, ProofContract } from "../public/proof-protocol.js";
2
3
  import type { ProofReceipt } from "../public/proof-receipt.js";
3
4
  export interface BaseEntity {
@@ -13,6 +14,8 @@ export interface BaseEntity {
13
14
  severity?: string;
14
15
  links?: string[];
15
16
  text_ref?: string;
17
+ /** Provenance: who authored the entity and on what authority. */
18
+ origin?: EntityOrigin;
16
19
  }
17
20
  export interface FactFields {
18
21
  fact_kind?: "subject" | "property_value" | "observation" | "meta" | "predicate_schema" | "predicate";
@@ -39,6 +42,8 @@ export interface FactFields {
39
42
  argument_names?: string[];
40
43
  argument_types?: string[];
41
44
  argument_descriptions?: string[];
45
+ /** predicate_schema only: argument names that determine the others. */
46
+ key_arguments?: string[];
42
47
  argument_constants?: Record<string, string[]>;
43
48
  argument_aliases?: Record<string, Record<string, string>>;
44
49
  aliases?: string[];
@@ -56,6 +61,14 @@ export type Requirement = BaseEntity & {
56
61
  type: "req";
57
62
  semantic_text?: string;
58
63
  logic_claims?: string[];
64
+ /** Exception requirements only: who approved the exception. */
65
+ approved_by?: string;
66
+ /** Optional reference to the approval decision record. */
67
+ approval_ref?: string;
68
+ /** Why the requirement exists; explanation, not checked meaning. */
69
+ rationale?: string;
70
+ /** Exception requirements only: claim keys of the exempted requirement it waives. */
71
+ exempts_claims?: string[];
59
72
  };
60
73
  export type Scenario = BaseEntity & {
61
74
  type: "scenario";
@@ -1 +1 @@
1
- {"version":3,"file":"entities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EAAE,UAAU,CAAA;CAAE,CAAC;AACzD,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,sBAAsB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAChF,MAAM,MAAM,GAAG,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAC/C,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACjD,MAAM,MAAM,KAAK,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AACnD,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AACrD,MAAM,MAAM,IAAI,GAAG,UAAU,GAAG,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,MAAM,GACd,WAAW,GACX,QAAQ,GACR,UAAU,GACV,GAAG,GACH,IAAI,GACJ,KAAK,GACL,MAAM,GACN,IAAI,CAAC"}
@@ -1,5 +1,5 @@
1
1
  export interface BaseRelationship {
2
- type: "depends_on" | "specified_by" | "verified_by" | "validates" | "implements" | "covered_by" | "executable_for" | "constrained_by" | "constrains" | "requires_property" | "requires_predicate" | "requires_rule" | "guards" | "publishes" | "consumes" | "supersedes" | "restates" | "relates_to";
2
+ type: "depends_on" | "specified_by" | "verified_by" | "validates" | "implements" | "covered_by" | "executable_for" | "constrained_by" | "constrains" | "requires_property" | "requires_predicate" | "requires_rule" | "guards" | "publishes" | "consumes" | "supersedes" | "restates" | "assumes" | "exempts" | "relates_to";
3
3
  from: string;
4
4
  to: string;
5
5
  created_at?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/types/relationships.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EACA,YAAY,GACZ,cAAc,GACd,aAAa,GACb,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,oBAAoB,GACpB,eAAe,GACf,QAAQ,GACR,WAAW,GACX,UAAU,GACV,YAAY,GACZ,UAAU,GACV,YAAY,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/types/relationships.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EACA,YAAY,GACZ,cAAc,GACd,aAAa,GACb,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,gBAAgB,GAChB,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,oBAAoB,GACpB,eAAe,GACf,QAAQ,GACR,WAAW,GACX,UAAU,GACV,YAAY,GACZ,UAAU,GACV,SAAS,GACT,SAAS,GACT,YAAY,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAe,gBAAgB,CAAC"}
@@ -12,9 +12,29 @@ export type BranchAttachment = {
12
12
  kbBranch: string;
13
13
  /** The resolved compiled-store path. Never derive this path at call sites. */
14
14
  storePath: string;
15
- kind: "exact" | "explicit_override" | "legacy_compat";
15
+ kind: "exact" | "explicit_override" | "legacy_compat" | "detached_snapshot";
16
16
  migrationRequired: boolean;
17
+ /**
18
+ * Present only on a detached HEAD that no single local branch points at.
19
+ * The attachment then serves reads from a snapshot compiled from the
20
+ * checkout, and every write route must refuse it.
21
+ */
22
+ readOnly?: DetachedReadOnlyAttachment;
17
23
  };
24
+ export type DetachedReadOnlyAttachment = {
25
+ /** The checked-out commit. */
26
+ head: string;
27
+ /** Local branches whose tip is HEAD (zero, or two or more). */
28
+ branchesAtHead: readonly string[];
29
+ /** Human-readable account of the store used and the write refusal. */
30
+ notice: string;
31
+ };
32
+ /**
33
+ * Store identity of the read-only snapshot compiled from a detached checkout.
34
+ * It is never a Git branch's KB: reads on a bare SHA (CI checkouts) use it so
35
+ * no branch identity is guessed, and writes are refused while it is attached.
36
+ */
37
+ export declare const DETACHED_SNAPSHOT_KB_BRANCH = "kibi-internal/detached-head-snapshot";
18
38
  export type BranchErrorCode = "ENV_OVERRIDE" | "DETACHED_HEAD" | "UNBORN_BRANCH" | "GIT_NOT_AVAILABLE" | "NOT_A_GIT_REPO" | "AMBIGUOUS_ATTACHMENT" | "MIGRATION_RECOVERY_REQUIRED" | "UNKNOWN_ERROR";
19
39
  export interface BranchResolverDeps {
20
40
  execSync: typeof import("node:child_process").execSync;
@@ -31,6 +51,22 @@ export declare function _setBranchResolverDepsForTests(deps: Partial<BranchResol
31
51
  * @returns BranchResolutionResult with either the branch name or an error
32
52
  */
33
53
  export declare function resolveActiveBranch(workspaceRoot?: string): BranchResolutionResult;
54
+ /**
55
+ * Resolve the attachment for a read-only operation.
56
+ *
57
+ * Identical to {@link resolveBranchAttachment} except on a detached HEAD that
58
+ * no single local branch points at (a CI checkout of a bare SHA, or a commit
59
+ * two branches share). Such a checkout has no exact branch identity, and no
60
+ * other branch's KB may stand in for it, so reads are served from a snapshot
61
+ * compiled from this checkout's tracked sources. The result carries a notice
62
+ * naming that store and stating that writes are refused.
63
+ */
64
+ export declare function resolveReadBranchAttachment(workspaceRoot?: string): BranchAttachment | BranchResolutionError;
65
+ /**
66
+ * Actionable refusal for a write attempted on a detached HEAD. Reads keep
67
+ * working through the snapshot; a write needs an exact branch identity.
68
+ */
69
+ export declare function detachedHeadWriteRefusal(operation: string, workspaceRoot?: string): string;
34
70
  /**
35
71
  * Resolve the storage namespace without treating any branch as canonical.
36
72
  * Literal branch-named stores are read-compatible legacy storage only. The
@@ -1 +1 @@
1
- {"version":3,"file":"branch-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/branch-resolver.ts"],"names":[],"mappings":"AAsCA,MAAM,MAAM,uBAAuB,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACzD,MAAM,MAAM,qBAAqB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC;AAC7E,MAAM,MAAM,sBAAsB,GAC9B,uBAAuB,GACvB,qBAAqB,CAAC;AAE1B,wBAAgB,+BAA+B,CAC7C,WAAW,EAAE,MAAM,GAClB,qBAAqB,CAKvB;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,OAAO,GAAG,mBAAmB,GAAG,eAAe,CAAC;IACtD,iBAAiB,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,eAAe,GACvB,cAAc,GACd,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,gBAAgB,GAChB,sBAAsB,GACtB,6BAA6B,GAC7B,eAAe,CAAC;AAEpB,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,cAAc,oBAAoB,EAAE,QAAQ,CAAC;IACvD,YAAY,EAAE,cAAc,oBAAoB,EAAE,YAAY,CAAC;CAChE;AAOD,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAChC,IAAI,CAIN;AA8BD;;;;;;;;GAQG;AACH,wBAAgB,mBAA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B,GACpC,MAAM,CAYR;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,aAAa,GAAE,MAAsB,GACpC,gBAAgB,GAAG,qBAAqB,CAiE1C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,aAAa,GAAE,MAAsB,GAAG,OAAO,CAgB7E;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,KAAK,EAAE,MAAM,GACZ,MAAM,CAuBR;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAkDvD;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,IAAI,CAUN;AA6BD;;;;;GAKG;AACH,wBAAgB,2BAA2B,IAAI,MAAM,EAAE,CAMtD;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,GAAE,MAAsB,EAC3B,OAAO,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA+BtD"}
@@ -26,12 +26,19 @@ export function unreadableMigrationJournalError(journalName) {
26
26
  code: "MIGRATION_RECOVERY_REQUIRED",
27
27
  };
28
28
  }
29
+ /**
30
+ * Store identity of the read-only snapshot compiled from a detached checkout.
31
+ * It is never a Git branch's KB: reads on a bare SHA (CI checkouts) use it so
32
+ * no branch identity is guessed, and writes are refused while it is attached.
33
+ */
34
+ // implements REQ-branch-store-recovery-v4
35
+ export const DETACHED_SNAPSHOT_KB_BRANCH = "kibi-internal/detached-head-snapshot";
29
36
  const defaultDeps = {
30
37
  execSync: rawExecSync,
31
38
  execFileSync: rawExecFileSync,
32
39
  };
33
40
  export function _setBranchResolverDepsForTests(deps) {
34
- // implements REQ-008
41
+ // implements REQ-branch-store-recovery-v4
35
42
  defaultDeps.execSync = deps.execSync ?? rawExecSync;
36
43
  defaultDeps.execFileSync = deps.execFileSync ?? rawExecFileSync;
37
44
  }
@@ -70,7 +77,7 @@ function isVolatileArtifact(fileName) {
70
77
  * @returns BranchResolutionResult with either the branch name or an error
71
78
  */
72
79
  export function resolveActiveBranch(workspaceRoot = process.cwd()) {
73
- // implements REQ-008
80
+ // implements REQ-branch-store-recovery-v4
74
81
  // 1. Check KIBI_BRANCH env var first (highest precedence)
75
82
  const envBranch = getBranchOverride();
76
83
  if (envBranch) {
@@ -95,6 +102,9 @@ export function resolveActiveBranch(workspaceRoot = process.cwd()) {
95
102
  .trim();
96
103
  if (!branch) {
97
104
  // Empty result means detached HEAD
105
+ const atHead = uniqueBranchAtHead(workspaceRoot);
106
+ if (atHead)
107
+ return { branch: atHead };
98
108
  return {
99
109
  error: getBranchDiagnostic(undefined, "Git is in detached HEAD state"),
100
110
  code: "DETACHED_HEAD",
@@ -123,6 +133,9 @@ export function resolveActiveBranch(workspaceRoot = process.cwd()) {
123
133
  })
124
134
  .trim();
125
135
  if (branch === "HEAD") {
136
+ const atHead = uniqueBranchAtHead(workspaceRoot);
137
+ if (atHead)
138
+ return { branch: atHead };
126
139
  return {
127
140
  error: getBranchDiagnostic(undefined, "Git is in detached HEAD state"),
128
141
  code: "DETACHED_HEAD",
@@ -165,6 +178,120 @@ export function resolveActiveBranch(workspaceRoot = process.cwd()) {
165
178
  }
166
179
  }
167
180
  }
181
+ // implements REQ-branch-store-recovery-v4
182
+ /**
183
+ * A detached HEAD that exactly one local branch points at is that branch's
184
+ * commit, so its knowledge base is the exact one for this checkout (a
185
+ * `git checkout <sha>` of a branch tip, or a tool that detaches before
186
+ * running). Zero or several candidates stay a DETACHED_HEAD diagnostic: no
187
+ * branch is guessed.
188
+ */
189
+ function uniqueBranchAtHead(workspaceRoot) {
190
+ const names = branchesAtHead(workspaceRoot);
191
+ if (names.length !== 1)
192
+ return null;
193
+ const [name] = names;
194
+ return name !== undefined && isValidBranchName(name) ? name : null;
195
+ }
196
+ /** Local branch names whose tip is HEAD, sorted; empty when Git cannot say. */
197
+ function branchesAtHead(workspaceRoot) {
198
+ try {
199
+ return defaultDeps
200
+ .execFileSync("git", ["branch", "--points-at", "HEAD", "--format=%(refname:short)"], {
201
+ cwd: workspaceRoot,
202
+ encoding: "utf8",
203
+ timeout: 5000,
204
+ stdio: ["pipe", "pipe", "pipe"],
205
+ })
206
+ .toString()
207
+ .split("\n")
208
+ .map((name) => name.trim())
209
+ .filter((name) => name.length > 0 && !name.startsWith("("))
210
+ .sort();
211
+ }
212
+ catch {
213
+ return [];
214
+ }
215
+ }
216
+ function headCommit(workspaceRoot) {
217
+ try {
218
+ const head = defaultDeps
219
+ .execFileSync("git", ["rev-parse", "--verify", "HEAD"], {
220
+ cwd: workspaceRoot,
221
+ encoding: "utf8",
222
+ timeout: 5000,
223
+ stdio: ["pipe", "pipe", "pipe"],
224
+ })
225
+ .toString()
226
+ .trim();
227
+ return /^[0-9a-f]{40,64}$/u.test(head) ? head : null;
228
+ }
229
+ catch {
230
+ return null;
231
+ }
232
+ }
233
+ function describeBranchesAtHead(branches) {
234
+ return branches.length === 0
235
+ ? "no local branch points at it"
236
+ : `${branches.length} local branches point at it (${branches.join(", ")}), so no single branch KB is implied`;
237
+ }
238
+ /**
239
+ * Resolve the attachment for a read-only operation.
240
+ *
241
+ * Identical to {@link resolveBranchAttachment} except on a detached HEAD that
242
+ * no single local branch points at (a CI checkout of a bare SHA, or a commit
243
+ * two branches share). Such a checkout has no exact branch identity, and no
244
+ * other branch's KB may stand in for it, so reads are served from a snapshot
245
+ * compiled from this checkout's tracked sources. The result carries a notice
246
+ * naming that store and stating that writes are refused.
247
+ */
248
+ // implements REQ-branch-store-recovery-v4
249
+ export function resolveReadBranchAttachment(workspaceRoot = process.cwd()) {
250
+ const attachment = resolveBranchAttachment(workspaceRoot);
251
+ if (!("error" in attachment) || attachment.code !== "DETACHED_HEAD") {
252
+ return attachment;
253
+ }
254
+ const head = headCommit(workspaceRoot);
255
+ if (head === null)
256
+ return attachment;
257
+ const branches = branchesAtHead(workspaceRoot);
258
+ const storePath = branchStorePath(workspaceRoot, DETACHED_SNAPSHOT_KB_BRANCH);
259
+ if (existsSync(storePath) &&
260
+ !branchStoreManifestMatches(storePath, DETACHED_SNAPSHOT_KB_BRANCH)) {
261
+ return {
262
+ error: `Detached HEAD snapshot store identity mismatch at ${storePath}; refusing to read it.`,
263
+ code: "AMBIGUOUS_ATTACHMENT",
264
+ };
265
+ }
266
+ return {
267
+ gitBranch: "HEAD",
268
+ kbBranch: DETACHED_SNAPSHOT_KB_BRANCH,
269
+ storePath,
270
+ kind: "detached_snapshot",
271
+ migrationRequired: false,
272
+ readOnly: {
273
+ head,
274
+ branchesAtHead: branches,
275
+ notice: `Detached HEAD at ${head.slice(0, 12)}: ${describeBranchesAtHead(branches)}. Read-only answers come from a snapshot compiled from this checkout's tracked sources (store ${storePath}); writes are refused until a branch is checked out.`,
276
+ },
277
+ };
278
+ }
279
+ /**
280
+ * Actionable refusal for a write attempted on a detached HEAD. Reads keep
281
+ * working through the snapshot; a write needs an exact branch identity.
282
+ */
283
+ // implements REQ-branch-store-recovery-v4
284
+ export function detachedHeadWriteRefusal(operation, workspaceRoot = process.cwd()) {
285
+ const head = headCommit(workspaceRoot);
286
+ const branches = branchesAtHead(workspaceRoot);
287
+ const where = head === null
288
+ ? "HEAD is detached"
289
+ : `HEAD is detached at ${head.slice(0, 12)} and ${describeBranchesAtHead(branches)}`;
290
+ const switchHint = branches.length > 0
291
+ ? `'git switch ${branches[0]}' (or another branch at HEAD)`
292
+ : "'git switch -c <branch>'";
293
+ return `${operation} writes the branch KB, but ${where}. Check out a branch first: ${switchHint}, or set KIBI_BRANCH to name the branch explicitly. Read-only operations (search, query, status, check, coverage, graph) keep working on a detached HEAD from a read-only snapshot of the checkout.`;
294
+ }
168
295
  /**
169
296
  * Resolve the storage namespace without treating any branch as canonical.
170
297
  * Literal branch-named stores are read-compatible legacy storage only. The
@@ -237,7 +364,7 @@ export function resolveBranchAttachment(workspaceRoot = process.cwd()) {
237
364
  * @returns true if in detached HEAD, false otherwise
238
365
  */
239
366
  export function isDetachedHead(workspaceRoot = process.cwd()) {
240
- // implements REQ-008
367
+ // implements REQ-branch-store-recovery-v4
241
368
  try {
242
369
  const branch = defaultDeps
243
370
  .execSync("git rev-parse --abbrev-ref HEAD", {
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Canonical repository-relative form of a recorded path, as proof freshness
3
+ * reads it: POSIX separators and no `.` segments. An absolute path that
4
+ * points inside `workspaceRoot` is re-expressed relative to it, so
5
+ * `packages/a.ts`, `./packages/a.ts`, `packages\a.ts` and
6
+ * `<root>/packages/a.ts` all name the same file. Returns null for a path that
7
+ * leaves the repository (a `..` escape, another machine's absolute path, a
8
+ * drive letter or UNC share outside the root): such a location exists on one
9
+ * machine only, so hashing it would make the same commit prove differently
10
+ * in CI and on a developer checkout.
11
+ *
12
+ * The Unicode form of each name is kept as recorded: the result is used to
13
+ * read the file, and a case- or normalization-sensitive filesystem only finds
14
+ * a name under the exact bytes git checked out. Where a path is an identity
15
+ * (the workspace snapshot), the caller compares it in NFC.
16
+ */
17
+ export declare function normalizeRepoRelativePath(workspaceRoot: string, candidate: string): string | null;
18
+ //# sourceMappingURL=repo-relative-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repo-relative-path.d.ts","sourceRoot":"","sources":["../../src/utils/repo-relative-path.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB,MAAM,GAAG,IAAI,CAsBf"}
@@ -0,0 +1,58 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import path from "node:path";
19
+ /**
20
+ * Canonical repository-relative form of a recorded path, as proof freshness
21
+ * reads it: POSIX separators and no `.` segments. An absolute path that
22
+ * points inside `workspaceRoot` is re-expressed relative to it, so
23
+ * `packages/a.ts`, `./packages/a.ts`, `packages\a.ts` and
24
+ * `<root>/packages/a.ts` all name the same file. Returns null for a path that
25
+ * leaves the repository (a `..` escape, another machine's absolute path, a
26
+ * drive letter or UNC share outside the root): such a location exists on one
27
+ * machine only, so hashing it would make the same commit prove differently
28
+ * in CI and on a developer checkout.
29
+ *
30
+ * The Unicode form of each name is kept as recorded: the result is used to
31
+ * read the file, and a case- or normalization-sensitive filesystem only finds
32
+ * a name under the exact bytes git checked out. Where a path is an identity
33
+ * (the workspace snapshot), the caller compares it in NFC.
34
+ */
35
+ // implements REQ-kibi-fresh-verification-receipts-v2
36
+ export function normalizeRepoRelativePath(workspaceRoot, candidate) {
37
+ if (candidate.trim() === "")
38
+ return null;
39
+ let slashed = candidate.replaceAll("\\", "/");
40
+ const foreignAbsolute = /^[A-Za-z]:\//.test(slashed) || slashed.startsWith("//");
41
+ if (slashed.startsWith("/") || foreignAbsolute) {
42
+ if (foreignAbsolute && path.sep === "/")
43
+ return null;
44
+ const root = path.resolve(workspaceRoot);
45
+ const relative = path.relative(root, path.resolve(candidate));
46
+ if (relative === "" || path.isAbsolute(relative))
47
+ return null;
48
+ slashed = relative.replaceAll("\\", "/");
49
+ }
50
+ const normalized = path.posix.normalize(slashed).replace(/\/+$/, "");
51
+ if (normalized === "" ||
52
+ normalized === "." ||
53
+ normalized === ".." ||
54
+ normalized.startsWith("../")) {
55
+ return null;
56
+ }
57
+ return normalized;
58
+ }
@@ -23,6 +23,11 @@ export declare const GENERATED_RULES: readonly [{
23
23
  readonly description: "Authored Markdown and relationship-shard edges must exactly match the compiled KB";
24
24
  readonly enforcementClass: "canonical";
25
25
  readonly category: "integrity";
26
+ }, {
27
+ readonly name: "source-path-dangling";
28
+ readonly description: "An authored entity's source field must name an existing workspace path (a #anchor suffix is ignored), an existing entity id, or an http(s) URL; a missing source is allowed";
29
+ readonly enforcementClass: "canonical";
30
+ readonly category: "integrity";
26
31
  }, {
27
32
  readonly name: "no-cycles";
28
33
  readonly description: "No circular dependency chains in requirements";
@@ -38,6 +43,36 @@ export declare const GENERATED_RULES: readonly [{
38
43
  readonly description: "Deprecated ADRs must have a successor ADR that supersedes them";
39
44
  readonly enforcementClass: "canonical";
40
45
  readonly category: "lifecycle";
46
+ }, {
47
+ readonly name: "superseded-requirement-open";
48
+ readonly description: "A requirement that another requirement supersedes must have status closed, and supersedes links between requirements must not form a cycle";
49
+ readonly enforcementClass: "canonical";
50
+ readonly category: "lifecycle";
51
+ }, {
52
+ readonly name: "scenario-feasibility";
53
+ readonly description: "A scenario that expects success must not assume property values that cannot hold, alone or together, with what current requirements require through typed property values or rules, unless an approved exception requirement waives that requirement or the listed clauses";
54
+ readonly enforcementClass: "canonical";
55
+ readonly category: "integrity";
56
+ }, {
57
+ readonly name: "scenario-feasibility-unknown";
58
+ readonly description: "Advisory: a scenario that expects success assumes nothing, assumes values that contradict each other, assumes a property value no governing requirement constrains comparably (type, unit or operator mismatch, or conflicting requirements), leaves a governing rule's conditions undecided, or conflicts only with constraints whose validity window may not cover it, so its feasibility cannot be decided";
59
+ readonly enforcementClass: "advisory";
60
+ readonly category: "integrity";
61
+ }, {
62
+ readonly name: "exception-claim-keys";
63
+ readonly description: "An exception requirement's exempts_claims must name claim keys of a requirement it exempts, and requires an exempts link";
64
+ readonly enforcementClass: "canonical";
65
+ readonly category: "integrity";
66
+ }, {
67
+ readonly name: "numeric-string-value";
68
+ readonly description: "Advisory: a property value stores a numeric-looking string where the comparison is numeric (ordering operator, or an int/number fact on the same property); the finding names the fact and the typed value, without converting it";
69
+ readonly enforcementClass: "advisory";
70
+ readonly category: "integrity";
71
+ }, {
72
+ readonly name: "rule-key-arguments-missing";
73
+ readonly description: "Advisory: an opposing rule pair stays unresolved only because a body predicate declares no key_arguments; the finding names the predicate and the key positions that would decide the pair";
74
+ readonly enforcementClass: "advisory";
75
+ readonly category: "integrity";
41
76
  }, {
42
77
  readonly name: "domain-contradictions";
43
78
  readonly description: "Detect contradictions between requirements constraining the same fact";
@@ -71,7 +106,7 @@ export declare const GENERATED_RULES: readonly [{
71
106
  }, {
72
107
  readonly name: "strict-fact-shape";
73
108
  readonly description: "Detect malformed strict facts (facts with fact_kind that are missing required fields)";
74
- readonly enforcementClass: "advisory";
109
+ readonly enforcementClass: "canonical";
75
110
  readonly category: "integrity";
76
111
  }, {
77
112
  readonly name: "strict-req-fact-pairing";
@@ -116,12 +151,12 @@ export declare const GENERATED_RULES: readonly [{
116
151
  readonly diagnosticSeverity: "info";
117
152
  }, {
118
153
  readonly name: "subject-key-identity";
119
- readonly description: "Subject keys must name a shared component, not be derived from a requirement ID";
154
+ readonly description: "Subject keys must name a shared component, not be derived from a requirement ID, and one subject or claim must not be minted as several active subject facts or identical property_value facts";
120
155
  readonly enforcementClass: "advisory";
121
156
  readonly category: "integrity";
122
157
  }, {
123
158
  readonly name: "subject-key-shape";
124
- readonly description: "Subject keys follow dotted component.aspect[.sub] with lowercase snake segments";
159
+ readonly description: "Subject keys follow dotted component.aspect[.sub] with lowercase snake segments, and property keys name a property rather than a numbered clause (clause_NN)";
125
160
  readonly enforcementClass: "advisory";
126
161
  readonly category: "integrity";
127
162
  }, {
@@ -130,6 +165,43 @@ export declare const GENERATED_RULES: readonly [{
130
165
  readonly enforcementClass: "advisory";
131
166
  readonly category: "integrity";
132
167
  readonly diagnosticSeverity: "info";
168
+ }, {
169
+ readonly name: "exception-unapproved";
170
+ readonly description: "Advisory: a current exception requirement exempts another requirement but has no approved_by, so it exempts nothing until a human approves it";
171
+ readonly enforcementClass: "advisory";
172
+ readonly category: "integrity";
173
+ }, {
174
+ readonly name: "exception-approval-self-attested";
175
+ readonly description: "Advisory: an agent-authored exception records approved_by but no human corroborated it (origin.approved_by or approval_ref is missing), so a human should confirm the approval";
176
+ readonly enforcementClass: "advisory";
177
+ readonly category: "integrity";
178
+ }, {
179
+ readonly name: "agent-requirement-unapproved";
180
+ readonly description: "Informational: current requirements authored by an agent (origin.kind agent) that no human has approved (origin.approved_by), listed up to 25 per check";
181
+ readonly enforcementClass: "advisory";
182
+ readonly category: "lifecycle";
183
+ readonly diagnosticSeverity: "info";
184
+ }, {
185
+ readonly name: "requirement-rationale-missing";
186
+ readonly description: "Advisory: a current requirement authored by a human or an agent (origin.kind human or agent) states no rationale: no rationale field, no Rationale or Why section in its body, and no link to an ADR; listed up to 25 per check plus one summary finding";
187
+ readonly enforcementClass: "advisory";
188
+ readonly category: "lifecycle";
189
+ }, {
190
+ readonly name: "symbol-owner-superseded";
191
+ readonly description: "Advisory: a symbol whose every implements target is superseded or deprecated has no current owning requirement; listed up to 25 per check plus one summary finding";
192
+ readonly enforcementClass: "advisory";
193
+ readonly category: "traceability";
194
+ }, {
195
+ readonly name: "adr-unlinked";
196
+ readonly description: "Advisory: an accepted ADR that no requirement or other ADR is linked with (relates_to, supersedes or any typed edge, in either direction)";
197
+ readonly enforcementClass: "advisory";
198
+ readonly category: "lifecycle";
199
+ }, {
200
+ readonly name: "adr-proposed";
201
+ readonly description: "Informational: an ADR that is still proposed and not superseded, so nobody accepted or withdrew the decision";
202
+ readonly enforcementClass: "advisory";
203
+ readonly category: "lifecycle";
204
+ readonly diagnosticSeverity: "info";
133
205
  }, {
134
206
  readonly name: "predicate-schema-conformance";
135
207
  readonly description: "Predicate facts match a predicate_schema (project-local, or the built-in catalog in the default namespace) and use its declared argument constants";
@@ -1 +1 @@
1
- {"version":3,"file":"rule-registry.generated.d.ts","sourceRoot":"","sources":["../../src/utils/rule-registry.generated.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6LlB,CAAC"}
1
+ {"version":3,"file":"rule-registry.generated.d.ts","sourceRoot":"","sources":["../../src/utils/rule-registry.generated.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiSlB,CAAC"}