kibi-cli 1.0.1 → 2.0.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 (450) hide show
  1. package/dist/cli-errors.d.ts +3 -1
  2. package/dist/cli-errors.d.ts.map +1 -1
  3. package/dist/cli-errors.js +4 -1
  4. package/dist/cli-json-command.d.ts +1 -0
  5. package/dist/cli-json-command.d.ts.map +1 -1
  6. package/dist/cli-json-command.js +13 -4
  7. package/dist/cli-operation-loader.js +3 -3
  8. package/dist/cli-operation-metadata.d.ts +4 -3
  9. package/dist/cli-operation-metadata.d.ts.map +1 -1
  10. package/dist/cli-operation-metadata.js +7 -5
  11. package/dist/cli-protocol.js +1 -1
  12. package/dist/cli-register-maintenance.d.ts.map +1 -1
  13. package/dist/cli-register-maintenance.js +7 -0
  14. package/dist/cli-register-proof.d.ts +3 -0
  15. package/dist/cli-register-proof.d.ts.map +1 -0
  16. package/dist/cli-register-proof.js +103 -0
  17. package/dist/cli-register-reporting.d.ts.map +1 -1
  18. package/dist/cli-register-reporting.js +1 -0
  19. package/dist/cli.d.ts +4 -0
  20. package/dist/cli.d.ts.map +1 -1
  21. package/dist/cli.js +17 -10
  22. package/dist/commands/branch.d.ts +1 -0
  23. package/dist/commands/branch.d.ts.map +1 -1
  24. package/dist/commands/branch.js +8 -4
  25. package/dist/commands/check.d.ts +14 -0
  26. package/dist/commands/check.d.ts.map +1 -1
  27. package/dist/commands/check.js +190 -44
  28. package/dist/commands/coverage.d.ts +1 -0
  29. package/dist/commands/coverage.d.ts.map +1 -1
  30. package/dist/commands/coverage.js +6 -0
  31. package/dist/commands/doctor.d.ts +22 -0
  32. package/dist/commands/doctor.d.ts.map +1 -1
  33. package/dist/commands/doctor.js +48 -22
  34. package/dist/commands/engine.d.ts +12 -0
  35. package/dist/commands/engine.d.ts.map +1 -1
  36. package/dist/commands/engine.js +40 -0
  37. package/dist/commands/github-init.d.ts +1 -0
  38. package/dist/commands/github-init.d.ts.map +1 -1
  39. package/dist/commands/github-init.js +9 -5
  40. package/dist/commands/init-helpers.d.ts.map +1 -1
  41. package/dist/commands/init-helpers.js +38 -5
  42. package/dist/commands/migrate.d.ts +4 -0
  43. package/dist/commands/migrate.d.ts.map +1 -1
  44. package/dist/commands/migrate.js +7 -7
  45. package/dist/commands/proof-migrate-legacy.d.ts +7 -0
  46. package/dist/commands/proof-migrate-legacy.d.ts.map +1 -0
  47. package/dist/commands/proof-migrate-legacy.js +45 -0
  48. package/dist/commands/proof-prune.d.ts +8 -0
  49. package/dist/commands/proof-prune.d.ts.map +1 -0
  50. package/dist/commands/proof-prune.js +53 -0
  51. package/dist/commands/prove.d.ts +37 -0
  52. package/dist/commands/prove.d.ts.map +1 -0
  53. package/dist/commands/prove.js +470 -0
  54. package/dist/commands/report.js +1 -1
  55. package/dist/commands/sync/discovery.d.ts +3 -0
  56. package/dist/commands/sync/discovery.d.ts.map +1 -1
  57. package/dist/commands/sync/discovery.js +36 -28
  58. package/dist/commands/sync/manifest.d.ts +1 -1
  59. package/dist/commands/sync/manifest.d.ts.map +1 -1
  60. package/dist/commands/sync/manifest.js +53 -21
  61. package/dist/commands/sync/persistence.d.ts +4 -1
  62. package/dist/commands/sync/persistence.d.ts.map +1 -1
  63. package/dist/commands/sync/persistence.js +25 -14
  64. package/dist/commands/sync/staging.d.ts +1 -0
  65. package/dist/commands/sync/staging.d.ts.map +1 -1
  66. package/dist/commands/sync/staging.js +5 -2
  67. package/dist/commands/sync/untracked-targets.d.ts +24 -0
  68. package/dist/commands/sync/untracked-targets.d.ts.map +1 -0
  69. package/dist/commands/sync/untracked-targets.js +108 -0
  70. package/dist/commands/sync.d.ts +11 -1
  71. package/dist/commands/sync.d.ts.map +1 -1
  72. package/dist/commands/sync.js +74 -30
  73. package/dist/engine-daemon.d.ts +3 -1
  74. package/dist/engine-daemon.d.ts.map +1 -1
  75. package/dist/engine-daemon.js +49 -20
  76. package/dist/engine.d.ts +14 -76
  77. package/dist/engine.d.ts.map +1 -1
  78. package/dist/engine.js +197 -30
  79. package/dist/extractors/manifest.d.ts +5 -0
  80. package/dist/extractors/manifest.d.ts.map +1 -1
  81. package/dist/extractors/manifest.js +46 -1
  82. package/dist/extractors/markdown.d.ts +5 -3
  83. package/dist/extractors/markdown.d.ts.map +1 -1
  84. package/dist/extractors/markdown.js +41 -24
  85. package/dist/extractors/playwright-cases.js +1 -1
  86. package/dist/extractors/relationships.d.ts +6 -0
  87. package/dist/extractors/relationships.d.ts.map +1 -1
  88. package/dist/extractors/relationships.js +1 -1
  89. package/dist/extractors/symbol-coordinates.d.ts.map +1 -1
  90. package/dist/extractors/symbols-ts.d.ts +1 -0
  91. package/dist/extractors/symbols-ts.d.ts.map +1 -1
  92. package/dist/extractors/symbols-ts.js +142 -67
  93. package/dist/intent-search.d.ts +1 -0
  94. package/dist/intent-search.d.ts.map +1 -1
  95. package/dist/intent-search.js +7 -3
  96. package/dist/logic/ir.d.ts +1 -0
  97. package/dist/logic/ir.d.ts.map +1 -1
  98. package/dist/logic/ir.js +1 -1
  99. package/dist/operations/bootstrap/activation.d.ts +2 -1
  100. package/dist/operations/bootstrap/activation.d.ts.map +1 -1
  101. package/dist/operations/bootstrap/activation.js +11 -3
  102. package/dist/operations/bootstrap/generate.d.ts +2 -1
  103. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  104. package/dist/operations/bootstrap/generate.js +6 -3
  105. package/dist/operations/bootstrap/guidance.d.ts +1 -0
  106. package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
  107. package/dist/operations/bootstrap/guidance.js +1 -1
  108. package/dist/operations/modeling/model-requirement.d.ts +5 -0
  109. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  110. package/dist/operations/modeling/model-requirement.js +53 -46
  111. package/dist/operations/modeling/predicate-applicability.d.ts.map +1 -1
  112. package/dist/operations/modeling/predicate-applicability.js +103 -4
  113. package/dist/operations/modeling/predicate-catalog-2.d.ts.map +1 -1
  114. package/dist/operations/modeling/predicate-catalog-2.js +18 -2
  115. package/dist/operations/modeling/predicate-catalog-3.d.ts.map +1 -1
  116. package/dist/operations/modeling/predicate-catalog-3.js +17 -1
  117. package/dist/operations/modeling/predicate-catalog-5.d.ts +10 -0
  118. package/dist/operations/modeling/predicate-catalog-5.d.ts.map +1 -0
  119. package/dist/operations/modeling/predicate-catalog-5.js +291 -0
  120. package/dist/operations/modeling/predicate-catalog.d.ts.map +1 -1
  121. package/dist/operations/modeling/predicate-catalog.js +4 -0
  122. package/dist/operations/modeling/predicate-loader.d.ts +1 -0
  123. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  124. package/dist/operations/modeling/predicate-loader.js +4 -3
  125. package/dist/operations/modeling/predicate-ranker.d.ts.map +1 -1
  126. package/dist/operations/modeling/predicate-ranker.js +4 -1
  127. package/dist/operations/modeling/predicate-types.d.ts +1 -1
  128. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  129. package/dist/operations/modeling/predicate-usage-hints-4.d.ts +3 -0
  130. package/dist/operations/modeling/predicate-usage-hints-4.d.ts.map +1 -0
  131. package/dist/operations/modeling/predicate-usage-hints-4.js +84 -0
  132. package/dist/operations/modeling/suggest-predicates.d.ts +3 -1
  133. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  134. package/dist/operations/modeling/suggest-predicates.js +52 -19
  135. package/dist/operations/mutation/contradictions.d.ts +2 -1
  136. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  137. package/dist/operations/mutation/contradictions.js +26 -5
  138. package/dist/operations/mutation/delete.d.ts +3 -0
  139. package/dist/operations/mutation/delete.d.ts.map +1 -1
  140. package/dist/operations/mutation/delete.js +100 -32
  141. package/dist/operations/mutation/relationships.d.ts +1 -0
  142. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  143. package/dist/operations/mutation/relationships.js +6 -4
  144. package/dist/operations/mutation/saga.d.ts +51 -0
  145. package/dist/operations/mutation/saga.d.ts.map +1 -0
  146. package/dist/operations/mutation/saga.js +67 -0
  147. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  148. package/dist/operations/mutation/serialization.js +3 -2
  149. package/dist/operations/mutation/source-authoring.d.ts +5 -1
  150. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  151. package/dist/operations/mutation/source-authoring.js +79 -46
  152. package/dist/operations/mutation/strict-fact.d.ts +1 -0
  153. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  154. package/dist/operations/mutation/strict-fact.js +8 -5
  155. package/dist/operations/mutation/symbol-compiler-lock.d.ts +5 -2
  156. package/dist/operations/mutation/symbol-compiler-lock.d.ts.map +1 -1
  157. package/dist/operations/mutation/symbol-compiler-lock.js +65 -2
  158. package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
  159. package/dist/operations/mutation/symbol-granularity.js +2 -2
  160. package/dist/operations/mutation/symbol-refresh.d.ts +1 -0
  161. package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -1
  162. package/dist/operations/mutation/symbol-refresh.js +10 -8
  163. package/dist/operations/mutation/upsert.d.ts +18 -2
  164. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  165. package/dist/operations/mutation/upsert.js +86 -54
  166. package/dist/operations/mutation/validate-upsert.js +2 -2
  167. package/dist/operations/mutation/validation.d.ts.map +1 -1
  168. package/dist/operations/mutation/validation.js +46 -4
  169. package/dist/operations/mutation/warnings.d.ts +1 -0
  170. package/dist/operations/mutation/warnings.d.ts.map +1 -1
  171. package/dist/operations/mutation/warnings.js +7 -5
  172. package/dist/operations/mutation/workspace-mutation-lock.d.ts +60 -0
  173. package/dist/operations/mutation/workspace-mutation-lock.d.ts.map +1 -0
  174. package/dist/operations/mutation/workspace-mutation-lock.js +362 -0
  175. package/dist/operations/planning/apply-plan.d.ts +8 -106
  176. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  177. package/dist/operations/planning/apply-plan.js +113 -36
  178. package/dist/operations/planning/compile-intent.d.ts +2 -0
  179. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  180. package/dist/operations/planning/compile-intent.js +70 -14
  181. package/dist/operations/proof/ingest-proof.d.ts +34 -0
  182. package/dist/operations/proof/ingest-proof.d.ts.map +1 -0
  183. package/dist/operations/proof/ingest-proof.js +307 -0
  184. package/dist/operations/proof/migrate-legacy-receipts.d.ts +30 -0
  185. package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -0
  186. package/dist/operations/proof/migrate-legacy-receipts.js +88 -0
  187. package/dist/operations/proof/prune-receipts.d.ts +35 -0
  188. package/dist/operations/proof/prune-receipts.d.ts.map +1 -0
  189. package/dist/operations/proof/prune-receipts.js +91 -0
  190. package/dist/operations/proof/receipt-document.d.ts +29 -0
  191. package/dist/operations/proof/receipt-document.d.ts.map +1 -0
  192. package/dist/operations/proof/receipt-document.js +117 -0
  193. package/dist/operations/semantic-advisor/analyze-prose.d.ts +1 -0
  194. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  195. package/dist/operations/semantic-advisor/analyze-prose.js +46 -26
  196. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  197. package/dist/operations/semantic-advisor/clauses.js +20 -7
  198. package/dist/operations/semantic-advisor/strict-count-rules.d.ts +2 -0
  199. package/dist/operations/semantic-advisor/strict-count-rules.d.ts.map +1 -1
  200. package/dist/operations/semantic-advisor/strict-count-rules.js +40 -25
  201. package/dist/prolog/codec.d.ts +13 -1
  202. package/dist/prolog/codec.d.ts.map +1 -1
  203. package/dist/prolog/codec.js +269 -154
  204. package/dist/prolog/error-terms.d.ts +47 -0
  205. package/dist/prolog/error-terms.d.ts.map +1 -0
  206. package/dist/prolog/error-terms.js +334 -0
  207. package/dist/prolog/janitor.d.ts +50 -0
  208. package/dist/prolog/janitor.d.ts.map +1 -0
  209. package/dist/prolog/janitor.js +154 -0
  210. package/dist/prolog/store-lock.d.ts +45 -0
  211. package/dist/prolog/store-lock.d.ts.map +1 -0
  212. package/dist/prolog/store-lock.js +195 -0
  213. package/dist/prolog.d.ts +7 -0
  214. package/dist/prolog.d.ts.map +1 -1
  215. package/dist/prolog.js +55 -17
  216. package/dist/proof/evaluate.d.ts +27 -0
  217. package/dist/proof/evaluate.d.ts.map +1 -0
  218. package/dist/proof/evaluate.js +151 -0
  219. package/dist/proof/inspect.d.ts +12 -0
  220. package/dist/proof/inspect.d.ts.map +1 -0
  221. package/dist/proof/inspect.js +236 -0
  222. package/dist/proof/integrations.d.ts +35 -0
  223. package/dist/proof/integrations.d.ts.map +1 -0
  224. package/dist/proof/integrations.js +123 -0
  225. package/dist/proof/producers/junit-adapter.d.ts +26 -0
  226. package/dist/proof/producers/junit-adapter.d.ts.map +1 -0
  227. package/dist/proof/producers/junit-adapter.js +186 -0
  228. package/dist/{public → proof/producers}/playwright-case-id.d.ts +1 -1
  229. package/dist/proof/producers/playwright-case-id.d.ts.map +1 -0
  230. package/dist/{public → proof/producers}/playwright-case-id.js +3 -3
  231. package/dist/proof/producers/playwright-reporter.d.ts +27 -0
  232. package/dist/proof/producers/playwright-reporter.d.ts.map +1 -0
  233. package/dist/proof/producers/playwright-reporter.js +138 -0
  234. package/dist/proof/producers/tap-adapter.d.ts +10 -0
  235. package/dist/proof/producers/tap-adapter.d.ts.map +1 -0
  236. package/dist/proof/producers/tap-adapter.js +200 -0
  237. package/dist/proof/receipt-outcome.d.ts +2 -0
  238. package/dist/proof/receipt-outcome.d.ts.map +1 -0
  239. package/dist/proof/receipt-outcome.js +1 -0
  240. package/dist/public/diagnostic-usage.js +6 -6
  241. package/dist/public/distribution-parity.d.ts +7 -1
  242. package/dist/public/distribution-parity.d.ts.map +1 -1
  243. package/dist/public/distribution-parity.js +15 -10
  244. package/dist/public/impact/coverage-depth-quality.d.ts +1 -0
  245. package/dist/public/impact/coverage-depth-quality.d.ts.map +1 -1
  246. package/dist/public/impact/coverage-depth-quality.js +1 -1
  247. package/dist/public/impact/diagnostics.d.ts.map +1 -1
  248. package/dist/public/impact/diagnostics.js +2 -2
  249. package/dist/public/impact/diff-meaning.d.ts +1 -0
  250. package/dist/public/impact/diff-meaning.d.ts.map +1 -1
  251. package/dist/public/impact/diff-meaning.js +5 -2
  252. package/dist/public/impact/full-kb-quality.d.ts +5 -2
  253. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  254. package/dist/public/impact/full-kb-quality.js +329 -64
  255. package/dist/public/operations/catalog.d.ts +447 -196
  256. package/dist/public/operations/catalog.d.ts.map +1 -1
  257. package/dist/public/operations/catalog.js +6 -4
  258. package/dist/public/operations/check-executor.d.ts.map +1 -1
  259. package/dist/public/operations/check-executor.js +3 -7
  260. package/dist/public/operations/contracts.d.ts +7 -0
  261. package/dist/public/operations/contracts.d.ts.map +1 -1
  262. package/dist/public/operations/contracts.js +31 -22
  263. package/dist/public/operations/discovery-entities.d.ts +3 -0
  264. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  265. package/dist/public/operations/discovery-entities.js +4 -0
  266. package/dist/public/operations/discovery-executors.d.ts +9 -9
  267. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  268. package/dist/public/operations/discovery-executors.js +17 -14
  269. package/dist/public/operations/index.d.ts +1 -1
  270. package/dist/public/operations/index.d.ts.map +1 -1
  271. package/dist/public/operations/index.js +1 -1
  272. package/dist/public/operations/migration-plan.d.ts +4 -3
  273. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  274. package/dist/public/operations/migration-plan.js +23 -21
  275. package/dist/public/operations/node-ports.js +6 -6
  276. package/dist/public/operations/repair-plan.d.ts +3 -3
  277. package/dist/public/operations/repair-plan.d.ts.map +1 -1
  278. package/dist/public/operations/repair-plan.js +49 -19
  279. package/dist/public/operations/result-envelope.d.ts +1 -0
  280. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  281. package/dist/public/operations/result-envelope.js +12 -10
  282. package/dist/public/operations/runtime-types.d.ts +5 -0
  283. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  284. package/dist/public/operations/specs/check-rules.generated.d.ts +5 -0
  285. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -0
  286. package/dist/public/operations/specs/check-rules.generated.js +34 -0
  287. package/dist/public/operations/specs/check.d.ts +7 -2
  288. package/dist/public/operations/specs/check.d.ts.map +1 -1
  289. package/dist/public/operations/specs/check.js +8 -20
  290. package/dist/public/operations/specs/mutation-schemas.d.ts +257 -163
  291. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  292. package/dist/public/operations/specs/mutation-schemas.js +15 -7
  293. package/dist/public/operations/specs/planning.d.ts +9 -0
  294. package/dist/public/operations/specs/planning.d.ts.map +1 -1
  295. package/dist/public/operations/specs/planning.js +6 -0
  296. package/dist/public/operations/specs/proof.d.ts +212 -0
  297. package/dist/public/operations/specs/proof.d.ts.map +1 -0
  298. package/dist/public/operations/specs/proof.js +30 -0
  299. package/dist/public/operations/specs/reporting.d.ts +19 -0
  300. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  301. package/dist/public/operations/specs/reporting.js +112 -12
  302. package/dist/public/operations/specs/upsert.d.ts +257 -163
  303. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  304. package/dist/public/operations/symbol-repair-plan.d.ts +11 -0
  305. package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
  306. package/dist/public/operations/symbol-repair-plan.js +118 -3
  307. package/dist/public/operations/types.d.ts +1 -1
  308. package/dist/public/operations/types.d.ts.map +1 -1
  309. package/dist/public/proof-fingerprint.d.ts +54 -0
  310. package/dist/public/proof-fingerprint.d.ts.map +1 -0
  311. package/dist/public/proof-fingerprint.js +141 -0
  312. package/dist/public/proof-protocol.d.ts +354 -0
  313. package/dist/public/proof-protocol.d.ts.map +1 -0
  314. package/dist/public/proof-protocol.js +454 -0
  315. package/dist/public/proof-receipt.d.ts +279 -0
  316. package/dist/public/proof-receipt.d.ts.map +1 -0
  317. package/dist/public/proof-receipt.js +377 -0
  318. package/dist/public/schemas/entity.d.ts.map +1 -1
  319. package/dist/public/schemas/entity.js +21 -7
  320. package/dist/public/skills/kibi-freshness/SKILL.md +1 -1
  321. package/dist/public/skills/kibi-usage/SKILL.md +41 -12
  322. package/dist/public/skills/kibi-usage/resources/operation-access.md +1 -1
  323. package/dist/public/skills/kibi-usage/resources/proof.md +105 -0
  324. package/dist/public/skills/kibi-usage/resources/workflows.md +6 -6
  325. package/dist/public/symbol-granularity.d.ts +3 -14
  326. package/dist/public/symbol-granularity.d.ts.map +1 -1
  327. package/dist/public/symbol-granularity.generated.d.ts +16 -0
  328. package/dist/public/symbol-granularity.generated.d.ts.map +1 -0
  329. package/dist/public/symbol-granularity.generated.js +20 -0
  330. package/dist/public/symbol-granularity.js +6 -47
  331. package/dist/public/telemetry-acceptance.d.ts +3 -77
  332. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  333. package/dist/public/telemetry-acceptance.js +4 -2
  334. package/dist/public/telemetry-remediation.js +1 -1
  335. package/dist/report/html-report.css +282 -0
  336. package/dist/report/html-report.d.ts +4 -2
  337. package/dist/report/html-report.d.ts.map +1 -1
  338. package/dist/report/html-report.js +37 -300
  339. package/dist/runtime/cli-runtime.d.ts +2 -0
  340. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  341. package/dist/runtime/cli-runtime.js +14 -7
  342. package/dist/schemas/entity.schema.json +355 -215
  343. package/dist/search-ranking.d.ts +1 -0
  344. package/dist/search-ranking.d.ts.map +1 -1
  345. package/dist/search-ranking.js +3 -0
  346. package/dist/traceability/evidence-model.d.ts +28 -0
  347. package/dist/traceability/evidence-model.d.ts.map +1 -1
  348. package/dist/traceability/git-staged.d.ts +20 -0
  349. package/dist/traceability/git-staged.d.ts.map +1 -1
  350. package/dist/traceability/git-staged.js +145 -1
  351. package/dist/traceability/staged-diagnostics.d.ts +7 -0
  352. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  353. package/dist/traceability/staged-diagnostics.js +78 -7
  354. package/dist/traceability/staged-file-coverage.d.ts +33 -0
  355. package/dist/traceability/staged-file-coverage.d.ts.map +1 -0
  356. package/dist/traceability/staged-file-coverage.js +284 -0
  357. package/dist/traceability/staged-impact-contract.js +4 -4
  358. package/dist/traceability/staged-symbols-manifest.d.ts +13 -0
  359. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  360. package/dist/traceability/staged-symbols-manifest.js +138 -27
  361. package/dist/traceability/symbol-extract.d.ts +5 -0
  362. package/dist/traceability/symbol-extract.d.ts.map +1 -1
  363. package/dist/traceability/symbol-extract.js +1 -1
  364. package/dist/traceability/temp-kb.d.ts +2 -0
  365. package/dist/traceability/temp-kb.d.ts.map +1 -1
  366. package/dist/traceability/temp-kb.js +13 -4
  367. package/dist/types/entities.d.ts +5 -3
  368. package/dist/types/entities.d.ts.map +1 -1
  369. package/dist/utils/branch-resolver.d.ts +1 -0
  370. package/dist/utils/branch-resolver.d.ts.map +1 -1
  371. package/dist/utils/branch-resolver.js +7 -4
  372. package/dist/utils/branch-store.d.ts +6 -0
  373. package/dist/utils/branch-store.d.ts.map +1 -1
  374. package/dist/utils/branch-store.js +27 -0
  375. package/dist/utils/kb-paths.d.ts +1 -1
  376. package/dist/utils/kb-paths.d.ts.map +1 -1
  377. package/dist/utils/kb-paths.js +1 -1
  378. package/dist/utils/rule-registry.d.ts +1 -11
  379. package/dist/utils/rule-registry.d.ts.map +1 -1
  380. package/dist/utils/rule-registry.generated.d.ts +97 -0
  381. package/dist/utils/rule-registry.generated.d.ts.map +1 -0
  382. package/dist/utils/rule-registry.generated.js +125 -0
  383. package/dist/utils/rule-registry.js +12 -113
  384. package/dist/utils/strict-modeling.d.ts +1 -0
  385. package/dist/utils/strict-modeling.d.ts.map +1 -1
  386. package/dist/utils/strict-modeling.js +1 -1
  387. package/package.json +8 -11
  388. package/src/public/diagnostic-usage.ts +6 -6
  389. package/src/public/distribution-parity.ts +17 -10
  390. package/src/public/impact/coverage-depth-quality.ts +1 -1
  391. package/src/public/impact/diagnostics.ts +2 -1
  392. package/src/public/impact/diff-meaning.ts +11 -4
  393. package/src/public/impact/full-kb-quality.ts +463 -72
  394. package/src/public/operations/catalog.ts +10 -4
  395. package/src/public/operations/check-executor.ts +3 -7
  396. package/src/public/operations/contracts.ts +38 -22
  397. package/src/public/operations/discovery-entities.ts +7 -0
  398. package/src/public/operations/discovery-executors.ts +26 -23
  399. package/src/public/operations/index.ts +1 -1
  400. package/src/public/operations/migration-plan.ts +32 -25
  401. package/src/public/operations/node-ports.ts +6 -6
  402. package/src/public/operations/repair-plan.ts +60 -23
  403. package/src/public/operations/result-envelope.ts +15 -10
  404. package/src/public/operations/runtime-types.ts +5 -0
  405. package/src/public/operations/specs/check-rules.generated.ts +37 -0
  406. package/src/public/operations/specs/check.ts +12 -21
  407. package/src/public/operations/specs/mutation-schemas.ts +22 -9
  408. package/src/public/operations/specs/planning.ts +7 -0
  409. package/src/public/operations/specs/proof.ts +43 -0
  410. package/src/public/operations/specs/reporting.ts +140 -13
  411. package/src/public/operations/symbol-repair-plan.ts +163 -3
  412. package/src/public/operations/types.ts +1 -1
  413. package/src/public/proof-fingerprint.ts +216 -0
  414. package/src/public/proof-protocol-types.d.ts +96 -0
  415. package/src/public/proof-protocol.ts +589 -0
  416. package/src/public/proof-receipt.ts +499 -0
  417. package/src/public/schemas/entity.ts +26 -10
  418. package/src/public/skills/kibi-freshness/SKILL.md +1 -1
  419. package/src/public/skills/kibi-usage/SKILL.md +41 -12
  420. package/src/public/skills/kibi-usage/resources/operation-access.md +1 -1
  421. package/src/public/skills/kibi-usage/resources/proof.md +105 -0
  422. package/src/public/skills/kibi-usage/resources/workflows.md +6 -6
  423. package/src/public/symbol-granularity.generated.ts +41 -0
  424. package/src/public/symbol-granularity.ts +35 -60
  425. package/src/public/telemetry-acceptance-types.d.ts +98 -0
  426. package/src/public/telemetry-acceptance.ts +22 -100
  427. package/src/public/telemetry-remediation.ts +1 -1
  428. package/src/schemas/entity.schema.json +355 -215
  429. package/dist/cli-register-verification.d.ts +0 -3
  430. package/dist/cli-register-verification.d.ts.map +0 -1
  431. package/dist/cli-register-verification.js +0 -16
  432. package/dist/commands/verify.d.ts +0 -10
  433. package/dist/commands/verify.d.ts.map +0 -1
  434. package/dist/commands/verify.js +0 -126
  435. package/dist/operations/verification/ingest-verification.d.ts +0 -29
  436. package/dist/operations/verification/ingest-verification.d.ts.map +0 -1
  437. package/dist/operations/verification/ingest-verification.js +0 -192
  438. package/dist/public/operations/specs/verification.d.ts +0 -78
  439. package/dist/public/operations/specs/verification.d.ts.map +0 -1
  440. package/dist/public/operations/specs/verification.js +0 -62
  441. package/dist/public/playwright-case-id.d.ts.map +0 -1
  442. package/dist/public/verification-receipt.d.ts +0 -242
  443. package/dist/public/verification-receipt.d.ts.map +0 -1
  444. package/dist/public/verification-receipt.js +0 -296
  445. package/dist/verification/playwright-reporter.d.ts +0 -21
  446. package/dist/verification/playwright-reporter.d.ts.map +0 -1
  447. package/dist/verification/playwright-reporter.js +0 -114
  448. package/src/public/operations/specs/verification.ts +0 -78
  449. package/src/public/playwright-case-id.ts +0 -35
  450. package/src/public/verification-receipt.ts +0 -412
@@ -1,4 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
+ import { randomUUID } from "node:crypto";
2
3
  import fs from "node:fs";
3
4
  import path from "node:path";
4
5
  import { dump as dumpYaml, load as loadYaml } from "js-yaml";
@@ -196,7 +197,7 @@ function symbolManifestRecord(entity, relationships = []) {
196
197
  }
197
198
  return record;
198
199
  }
199
- function manifestRelationships(item) {
200
+ export function manifestRelationships(item) {
200
201
  if (item === null ||
201
202
  typeof item !== "object" ||
202
203
  !("get" in item) ||
@@ -452,7 +453,7 @@ function renderSourceDocument(input, entity, existingContent, relativePath) {
452
453
  }
453
454
  return renderEntityDocument(input, entity, existingContent);
454
455
  }
455
- export async function writeSourceForUpsert(input, entity, existing, context) {
456
+ export async function writeSourceForUpsert(input, entity, existing, context, sourceDocumentOverride) {
456
457
  if (!context?.fs)
457
458
  return null;
458
459
  const absolute = sourcePath(context, input, entity, existing);
@@ -466,16 +467,30 @@ export async function writeSourceForUpsert(input, entity, existing, context) {
466
467
  catch {
467
468
  before = undefined;
468
469
  }
469
- const after = renderSourceDocument(input, entity, before, relative);
470
+ // Proof-receipt ingest supplies pre-patched bytes so unrelated frontmatter
471
+ // keeps its authored formatting (and the workspace snapshot stays stable).
472
+ // Only valid when the document already exists; a new document still needs
473
+ // the canonical render.
474
+ const after = before !== undefined && sourceDocumentOverride !== undefined
475
+ ? sourceDocumentOverride
476
+ : renderSourceDocument(input, entity, before, relative);
470
477
  await context.fs.mkdir(path.dirname(absolute));
471
- const temporary = `${absolute}.kibi-source-${digest(relative).slice(0, 12)}`;
472
- await context.fs.writeFile(temporary, after);
473
- if (context.fs.rename) {
474
- await context.fs.rename(temporary, absolute);
478
+ const temporary = `${absolute}.kibi-source-${process.pid}-${randomUUID()}`;
479
+ try {
480
+ await context.fs.writeFile(temporary, after);
481
+ if (context.fs.rename) {
482
+ await context.fs.rename(temporary, absolute);
483
+ }
484
+ else {
485
+ await context.fs.writeFile(absolute, after);
486
+ await context.fs.unlink?.(temporary).catch(() => undefined);
487
+ }
475
488
  }
476
- else {
477
- await context.fs.writeFile(absolute, after);
489
+ catch (error) {
490
+ // A failed rename must not leak the unique temp file into the authored
491
+ // tree; the published target (if any) is untouched at this point.
478
492
  await context.fs.unlink?.(temporary).catch(() => undefined);
493
+ throw error;
479
494
  }
480
495
  const receipt = {
481
496
  path: relative,
@@ -484,46 +499,40 @@ export async function writeSourceForUpsert(input, entity, existing, context) {
484
499
  afterHash: digest(after),
485
500
  created: before === undefined,
486
501
  };
487
- const pendingReceipt = pendingReceiptPath(context.workspaceRoot, relative);
488
- if (receipt.afterHash !== null &&
489
- (before === undefined || fs.existsSync(pendingReceipt))) {
490
- writePendingSourceReceipt(context.workspaceRoot, relative, receipt.afterHash);
491
- }
492
- return {
493
- receipt,
494
- rollback: async () => {
495
- const fsPort = context.fs;
496
- if (fsPort === undefined)
497
- return;
498
- // Compare before restore: a concurrent writer may have replaced the file
499
- // after our publication. Never clobber newer bytes; keep the recovery
500
- // receipt so the next sync reconciles deterministically instead.
501
- let current;
502
+ const rollback = async () => {
503
+ const fsPort = context.fs;
504
+ if (fsPort === undefined)
505
+ return;
506
+ // Compare before restore: a concurrent writer may have replaced the file
507
+ // after our publication. Never clobber newer bytes; keep the recovery
508
+ // receipt so the next sync reconciles deterministically instead.
509
+ let current;
510
+ try {
511
+ current = await fsPort.readFile(absolute);
512
+ }
513
+ catch {
514
+ current = undefined;
515
+ }
516
+ if (current !== undefined && digest(current) !== digest(after)) {
517
+ writePendingSourceReceipt(context.workspaceRoot, relative, receipt.afterHash);
518
+ console.warn(`Skipped source rollback for ${relative}: file changed after the Kibi write; kept concurrent content and recorded recovery metadata.`);
519
+ return;
520
+ }
521
+ if (before === undefined) {
522
+ if (fsPort.unlink)
523
+ await fsPort.unlink(absolute);
524
+ else
525
+ await fsPort.writeFile(absolute, "");
502
526
  try {
503
- current = await fsPort.readFile(absolute);
527
+ fs.unlinkSync(pendingReceiptPath(context.workspaceRoot, relative));
504
528
  }
505
529
  catch {
506
- current = undefined;
530
+ // The pending receipt is advisory recovery metadata.
507
531
  }
508
- if (current !== undefined && digest(current) !== digest(after)) {
509
- writePendingSourceReceipt(context.workspaceRoot, relative, receipt.afterHash);
510
- console.warn(`Skipped source rollback for ${relative}: file changed after the Kibi write; kept concurrent content and recorded recovery metadata.`);
511
- return;
512
- }
513
- if (before === undefined) {
514
- if (fsPort.unlink)
515
- await fsPort.unlink(absolute);
516
- else
517
- await fsPort.writeFile(absolute, "");
518
- try {
519
- fs.unlinkSync(pendingReceiptPath(context.workspaceRoot, relative));
520
- }
521
- catch {
522
- // The pending receipt is advisory recovery metadata.
523
- }
524
- }
525
- else {
526
- const rollbackTemp = `${absolute}.kibi-rollback-${digest(relative).slice(0, 12)}`;
532
+ }
533
+ else {
534
+ const rollbackTemp = `${absolute}.kibi-rollback-${process.pid}-${randomUUID()}`;
535
+ try {
527
536
  await fsPort.writeFile(rollbackTemp, before);
528
537
  if (fsPort.rename)
529
538
  await fsPort.rename(rollbackTemp, absolute);
@@ -532,8 +541,32 @@ export async function writeSourceForUpsert(input, entity, existing, context) {
532
541
  await fsPort.unlink?.(rollbackTemp).catch(() => undefined);
533
542
  }
534
543
  }
535
- },
544
+ catch (error) {
545
+ await fsPort.unlink?.(rollbackTemp).catch(() => undefined);
546
+ throw error;
547
+ }
548
+ }
536
549
  };
550
+ const pendingReceipt = pendingReceiptPath(context.workspaceRoot, relative);
551
+ try {
552
+ if (receipt.afterHash !== null &&
553
+ (before === undefined || fs.existsSync(pendingReceipt))) {
554
+ writePendingSourceReceipt(context.workspaceRoot, relative, receipt.afterHash);
555
+ }
556
+ }
557
+ catch (receiptError) {
558
+ // The source bytes are already published but the caller has not received
559
+ // the rollback handle yet. Unwind the publication here so no failed call
560
+ // ever leaves a half-registered source write behind.
561
+ try {
562
+ await rollback();
563
+ }
564
+ catch (rollbackError) {
565
+ throw new AggregateError([receiptError, rollbackError], `Source published for ${relative}, but pending receipt publication and rollback both failed; recover from the pending-source receipt or restore the authored file manually`);
566
+ }
567
+ throw receiptError;
568
+ }
569
+ return { receipt, rollback };
537
570
  }
538
571
  /** Resolve and normalize the canonical authored path for an entity. */
539
572
  export function canonicalSourcePath(context, input, entity, existing) {
@@ -1,4 +1,5 @@
1
1
  export declare function valueFieldHint(value: unknown): string;
2
2
  export declare function factKindShapeHints(entity: Readonly<Record<string, unknown>>): string[];
3
+ export declare function assertRuleSchemaArity(argumentNames: unknown, argumentTypes: unknown): void;
3
4
  export declare function validateFactModelingShape(entity: Readonly<Record<string, unknown>>): void;
4
5
  //# sourceMappingURL=strict-fact.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"strict-fact.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/strict-fact.ts"],"names":[],"mappings":"AAUA,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAarD;AAGD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,MAAM,EAAE,CA+EV;AAGD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,IAAI,CAuDN"}
1
+ {"version":3,"file":"strict-fact.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/strict-fact.ts"],"names":[],"mappings":"AAUA,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAarD;AAGD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,MAAM,EAAE,CA+EV;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,OAAO,EACtB,aAAa,EAAE,OAAO,GACrB,IAAI,CAUN;AAGD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,IAAI,CA+CN"}
@@ -93,6 +93,13 @@ export function factKindShapeHints(entity) {
93
93
  ];
94
94
  return [];
95
95
  }
96
+ export function assertRuleSchemaArity(argumentNames, argumentTypes) {
97
+ if (!Array.isArray(argumentNames) ||
98
+ !Array.isArray(argumentTypes) ||
99
+ argumentNames.length !== argumentTypes.length) {
100
+ throw new Error("Entity validation failed: rule_schema argument_names and argument_types must have equal lengths");
101
+ }
102
+ }
96
103
  // implements REQ-kibi-operation-interface-parity
97
104
  export function validateFactModelingShape(entity) {
98
105
  const hints = factKindShapeHints(entity);
@@ -123,10 +130,6 @@ export function validateFactModelingShape(entity) {
123
130
  entity.rule_name.trim() === "") {
124
131
  throw new Error("Entity validation failed: fact_kind 'rule_schema' requires rule_name");
125
132
  }
126
- if (!Array.isArray(entity.argument_names) ||
127
- !Array.isArray(entity.argument_types) ||
128
- entity.argument_names.length !== entity.argument_types.length) {
129
- throw new Error("Entity validation failed: rule_schema argument_names and argument_types must have equal lengths");
130
- }
133
+ assertRuleSchemaArity(entity.argument_names, entity.argument_types);
131
134
  }
132
135
  }
@@ -15,6 +15,7 @@ export interface SymbolCompilerLockOptions {
15
15
  readonly now?: () => number;
16
16
  readonly sleep?: (ms: number) => Promise<void>;
17
17
  readonly fileSystem?: SymbolCompilerLockFileSystem;
18
+ readonly isProcessAlive?: (pid: number) => boolean;
18
19
  }
19
20
  export declare class SymbolCompilerLockError extends Error {
20
21
  readonly name = "SymbolCompilerLockError";
@@ -31,7 +32,7 @@ export interface SymbolCompilerLockHandle {
31
32
  }
32
33
  export declare function releaseSymbolCompilerLock(handle: SymbolCompilerLockHandle | undefined, operationFailure?: {
33
34
  readonly error: unknown;
34
- }): void;
35
+ }, committed?: boolean): void;
35
36
  /**
36
37
  * Acquire the workspace symbol compiler lock without a callback shape, for
37
38
  * operations whose lock must span several awaits (source publication,
@@ -44,7 +45,9 @@ export declare function acquireSymbolCompilerLock(workspaceRoot: string, options
44
45
  * Atomic directory creation is the lock authority. Owner metadata is
45
46
  * release authorization and diagnostics: every existing target, including a
46
47
  * legacy file or a directory with missing/corrupt metadata, blocks contenders
47
- * until timeout.
48
+ * until timeout. A well-formed owner record whose holder pid is provably
49
+ * dead is stolen immediately instead of blocking for the full timeout;
50
+ * corrupt metadata and live holders stay fail-closed.
48
51
  * Release failures propagate so successful work is never reported unlocked.
49
52
  */
50
53
  export declare function withSymbolCompilerLock<T>(workspaceRoot: string, operation: () => Promise<T>, options?: SymbolCompilerLockOptions): Promise<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"symbol-compiler-lock.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-compiler-lock.ts"],"names":[],"mappings":"AAyBA,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,SAAS,EAAE,CAClB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,KACvC,IAAI,CAAC;IACV,QAAQ,CAAC,YAAY,EAA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;IAChD,SAAkB,IAAI,6BAA6B;CACpD;AA8MD,MAAM,WAAW,wBAAwB;IACvC;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B;AAGD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,wBAAwB,GAAG,SAAS,EAC5C,gBAAgB,CAAC,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAC9C,SAAS,UAAQ,GAChB,IAAI,CAoBN;AAED;;;;GAIG;AAEH,wBAAsB,yBAAyB,CAC7C,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,wBAAwB,CAAC,CA2InC;AAED;;;;;;;;;;GAUG;AAEH,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,CAAC,CAAC,CAWZ"}
@@ -1,5 +1,6 @@
1
1
  import { mkdirSync, readFileSync, rmdirSync, unlinkSync, writeFileSync, } from "node:fs";
2
2
  import * as path from "node:path";
3
+ import { OperationError } from "../../cli-errors.js";
3
4
  /**
4
5
  * Workspace-scoped mutex serializing every writer of the symbol compiler
5
6
  * surface: authored manifest edits, targeted coordinate refresh, full
@@ -125,17 +126,73 @@ function existingLockDescription(fileSystem, target, ownerPath) {
125
126
  }
126
127
  }
127
128
  }
129
+ function defaultIsProcessAlive(pid) {
130
+ try {
131
+ process.kill(pid, 0);
132
+ return true;
133
+ }
134
+ catch (error) {
135
+ return !(error instanceof Error &&
136
+ "code" in error &&
137
+ error.code === "ESRCH");
138
+ }
139
+ }
140
+ /**
141
+ * Read the current lock owner record and steal the lock only when the
142
+ * recorded holder pid is provably dead. A readable owner.json identifies a
143
+ * directory lock; a readable lock path itself identifies a legacy file lock.
144
+ * Corrupt, missing, or unreadable metadata stays fail-closed: an
145
+ * initializing writer must never be stolen from, and a live holder (or an
146
+ * unverifiable pid) keeps the mutex.
147
+ */
148
+ function stealStaleLockIfHolderIsDead(fileSystem, target, ownerPath, isProcessAlive) {
149
+ let record = null;
150
+ let legacyFileLock = false;
151
+ try {
152
+ record = readLockRecord(fileSystem.readFileSync(ownerPath));
153
+ }
154
+ catch {
155
+ try {
156
+ record = readLockRecord(fileSystem.readFileSync(target));
157
+ legacyFileLock = true;
158
+ }
159
+ catch {
160
+ return "unknown";
161
+ }
162
+ }
163
+ if (record === null)
164
+ return "unknown";
165
+ if (isProcessAlive(record.pid))
166
+ return "live";
167
+ try {
168
+ if (legacyFileLock) {
169
+ const removal = retryTransientFilesystemOperation(() => fileSystem.unlinkSync(target));
170
+ if (!removal.ok)
171
+ return "unknown";
172
+ return "stolen";
173
+ }
174
+ removeLockOwner(fileSystem, target, ownerPath, true);
175
+ removeLockDirectory(fileSystem, target);
176
+ }
177
+ catch {
178
+ return "unknown";
179
+ }
180
+ return "stolen";
181
+ }
128
182
  async function defaultSleep(ms) {
129
183
  await new Promise((resolvePromise) => setTimeout(resolvePromise, ms));
130
184
  }
131
185
  // implements REQ-generated-coordinate-persistence
132
- export function releaseSymbolCompilerLock(handle, operationFailure) {
186
+ export function releaseSymbolCompilerLock(handle, operationFailure, committed = false) {
133
187
  if (handle === undefined)
134
188
  return;
135
189
  try {
136
190
  handle.release();
137
191
  }
138
192
  catch (releaseError) {
193
+ if (committed) {
194
+ throw new OperationError("SYMBOL_COMPILER_LOCK_RELEASE_FAILED", `Mutation committed, but symbol compiler lock release failed: ${errorDetail(releaseError)}; do not retry the mutation until the lock is manually verified and released`, false);
195
+ }
139
196
  if (operationFailure !== undefined) {
140
197
  throw new AggregateError([operationFailure.error, releaseError], "Operation failed and symbol compiler lock release failed");
141
198
  }
@@ -153,6 +210,7 @@ export async function acquireSymbolCompilerLock(workspaceRoot, options = {}) {
153
210
  const now = options.now ?? Date.now;
154
211
  const sleep = options.sleep ?? defaultSleep;
155
212
  const fileSystem = options.fileSystem ?? NODE_FILE_SYSTEM;
213
+ const isProcessAlive = options.isProcessAlive ?? defaultIsProcessAlive;
156
214
  const target = lockPath(workspaceRoot);
157
215
  const ownerPath = path.join(target, OWNER_FILE);
158
216
  const token = randomToken();
@@ -177,6 +235,9 @@ export async function acquireSymbolCompilerLock(workspaceRoot, options = {}) {
177
235
  throw new SymbolCompilerLockError(`failed to acquire symbol compiler lock directory at ${target} after ${targetResult.attempts} attempt(s): ${errorDetail(targetResult.error)}`);
178
236
  }
179
237
  lastBlocker = existingLockDescription(fileSystem, target, ownerPath);
238
+ if (stealStaleLockIfHolderIsDead(fileSystem, target, ownerPath, isProcessAlive) === "stolen") {
239
+ continue;
240
+ }
180
241
  await sleep(RETRY_INTERVAL_MS);
181
242
  }
182
243
  if (!acquired) {
@@ -254,7 +315,9 @@ export async function acquireSymbolCompilerLock(workspaceRoot, options = {}) {
254
315
  * Atomic directory creation is the lock authority. Owner metadata is
255
316
  * release authorization and diagnostics: every existing target, including a
256
317
  * legacy file or a directory with missing/corrupt metadata, blocks contenders
257
- * until timeout.
318
+ * until timeout. A well-formed owner record whose holder pid is provably
319
+ * dead is stolen immediately instead of blocking for the full timeout;
320
+ * corrupt metadata and live holders stay fail-closed.
258
321
  * Release failures propagate so successful work is never reported unlocked.
259
322
  */
260
323
  // implements REQ-generated-coordinate-persistence
@@ -1 +1 @@
1
- {"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-granularity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAUjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA+FpD,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAuCf"}
1
+ {"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-granularity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAWjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA+FpD,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAuCf"}
@@ -1,6 +1,6 @@
1
1
  import path from "node:path";
2
2
  import { Project, ScriptKind, SyntaxKind } from "ts-morph";
3
- import { getBehavioralSymbolNames, getNonBehavioralSymbolNames, inferSymbolRole, isAllowedGranularityReason, isTraceabilityRelationshipType, } from "../../public/symbol-granularity.js";
3
+ import { ALLOWED_GRANULARITY_REASONS_PROSE, getBehavioralSymbolNames, getNonBehavioralSymbolNames, inferSymbolRole, isAllowedGranularityReason, isTraceabilityRelationshipType, } from "../../public/symbol-granularity.js";
4
4
  function scriptKind(filePath) {
5
5
  const extension = path.extname(filePath).toLowerCase();
6
6
  if (extension === ".tsx")
@@ -136,5 +136,5 @@ export async function validateSymbolGranularity(entity, relationships, context)
136
136
  const ignored = nonBehavioral.length > 0
137
137
  ? ` Non-behavioral symbols in the file were ignored for this decision: ${summarized(nonBehavioral)}.`
138
138
  : "";
139
- throw new Error(`Symbol ${String(entity.id)} links ${entity.sourceFile} coarsely while granular symbols are available (behavioral only): ${summarized(behavioral)}. Move relationships to a behavioral symbol, add a manifest behavioral anchor, or set granularity_reason to config-artifact, module-level-behavior, extractor-miss, legacy-link, or test-suite.${ignored}`);
139
+ throw new Error(`Symbol ${String(entity.id)} links ${entity.sourceFile} coarsely while granular symbols are available (behavioral only): ${summarized(behavioral)}. Move relationships to a behavioral symbol, add a manifest behavioral anchor, or set granularity_reason to ${ALLOWED_GRANULARITY_REASONS_PROSE}.${ignored}`);
140
140
  }
@@ -13,6 +13,7 @@ export type ArtifactPublicationReceipt = {
13
13
  rollback(): void;
14
14
  };
15
15
  type RefreshImplementation = (symbolId: string, context: OperationContext) => Promise<RefreshResult>;
16
+ export declare function restoreOrUnlinkCoordinateArtifact(targetPath: string, before: string | null): void;
16
17
  /** Targeted coordinate refresh under the workspace symbol compiler lock. */
17
18
  export declare function refreshSymbolCoordinates(symbolId: string, context: OperationContext): Promise<RefreshResult>;
18
19
  /** Run one refresh step without acquiring the lock (caller holds it). */
@@ -1 +1 @@
1
- {"version":3,"file":"symbol-refresh.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/symbol-refresh.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAgBjF,MAAM,MAAM,sBAAsB,GAC9B,SAAS,GACT,WAAW,GACX,SAAS,GACT,WAAW,CAAC;AAGhB,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,OAAO,CAAC,EAAE,sBAAsB,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,0BAA0B,CAAC;CACnD,CAAC;AAGF,MAAM,MAAM,0BAA0B,GAAG;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,IAAI,IAAI,CAAC;CAClB,CAAC;AAEF,KAAK,qBAAqB,GAAG,CAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,KACtB,OAAO,CAAC,aAAa,CAAC,CA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M,EAChB,OAAO,EAAE,gBAAgB,KACtB,OAAO,CAAC,aAAa,CAAC,CAAC;AAsD5B,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GAAG,IAAI,GACpB,IAAI,CAMN;AA6OD,4EAA4E;AAC5E,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,aAAa,CAAC,CASxB;AAED,yEAAyE;AAEzE,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,aAAa,CAAC,CAGxB;AAED;;;GAGG;AAEH,wBAAsB,mCAAmC,CACvD,QAAQ,EAAE,MAAM,EAChB,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,aAAa,CAAC,CAOxB;AAGD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,qBAAqB,GAAG,SAAS,GACzC,IAAI,CAEN"}
@@ -1,4 +1,4 @@
1
- import { createHash } from "node:crypto";
1
+ import { createHash, randomUUID } from "node:crypto";
2
2
  import { existsSync, readFileSync, renameSync, unlinkSync, writeFileSync, } from "node:fs";
3
3
  import * as path from "node:path";
4
4
  import { load as parseYaml } from "js-yaml";
@@ -46,8 +46,15 @@ function sourceTextFor(sourceFile, workspaceRoot) {
46
46
  function contentHash(content) {
47
47
  return createHash("sha256").update(content).digest("hex");
48
48
  }
49
+ export function restoreOrUnlinkCoordinateArtifact(targetPath, before) {
50
+ if (before === null) {
51
+ unlinkSync(targetPath);
52
+ return;
53
+ }
54
+ replaceArtifactAtomically(targetPath, before);
55
+ }
49
56
  function replaceArtifactAtomically(targetPath, content) {
50
- const temporary = `${targetPath}.kibi-tmp-${process.pid}`;
57
+ const temporary = `${targetPath}.kibi-tmp-${process.pid}-${randomUUID()}`;
51
58
  try {
52
59
  writeFileSync(temporary, content, "utf8");
53
60
  renameSync(temporary, targetPath);
@@ -81,12 +88,7 @@ function publishArtifact(targetPath, content) {
81
88
  if (contentHash(current) !== afterHash) {
82
89
  throw new CoordinateArtifactError(`coordinate artifact changed after publication; refusing rollback: ${targetPath}`);
83
90
  }
84
- if (before === null) {
85
- unlinkSync(targetPath);
86
- }
87
- else {
88
- replaceArtifactAtomically(targetPath, before);
89
- }
91
+ restoreOrUnlinkCoordinateArtifact(targetPath, before);
90
92
  },
91
93
  };
92
94
  }
@@ -1,7 +1,23 @@
1
1
  import type { OperationContext } from "../../public/operations/runtime-types.js";
2
2
  import type { OperationResult } from "../../public/operations/types.js";
3
3
  import type { RelationshipInput, UpsertInput, UpsertPayload } from "./types.js";
4
- export declare function validateAppendOnlyVerificationReceipts(entity: Readonly<Record<string, unknown>>, context: OperationContext): Promise<void>;
4
+ export declare function validateAppendOnlyProofReceipts(entity: Readonly<Record<string, unknown>>, context: OperationContext): Promise<void>;
5
5
  export declare function effectiveRelationships(input: UpsertInput, entity: Readonly<Record<string, unknown>>, relationships: readonly RelationshipInput[], context: OperationContext): Promise<readonly RelationshipInput[]>;
6
- export declare function executeUpsert(input: UpsertInput, context: OperationContext): Promise<OperationResult<UpsertPayload>>;
6
+ export type UpsertExecutionOptions = Readonly<{
7
+ /**
8
+ * Internal escape hatch for proof-receipt ingest: when provided, the
9
+ * authored document is written with exactly these bytes instead of the
10
+ * canonical re-render. Receipt appends must not canonicalize unrelated
11
+ * frontmatter — a mid-campaign reformat would change the workspace
12
+ * snapshot hash and make every later `kibi prove` integration refuse.
13
+ */
14
+ readonly sourceDocumentOverride?: string;
15
+ /**
16
+ * Internal escape hatch for `kibi proof prune`: the prune maintenance
17
+ * command deliberately shrinks a test's receipt history to its newest
18
+ * entries. Everything else keeps the append-only invariant fail-closed.
19
+ */
20
+ readonly allowReceiptsPrune?: boolean;
21
+ }>;
22
+ export declare function executeUpsert(input: UpsertInput, context: OperationContext, options?: UpsertExecutionOptions): Promise<OperationResult<UpsertPayload>>;
7
23
  //# sourceMappingURL=upsert.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAkCxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAkGhF,wBAAsB,sCAAsC,CAC1D,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAuBvC;AAkCD,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAqZzC"}
1
+ {"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAkCxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAuGhF,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,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