kibi-cli 2.4.0 → 2.5.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 (352) 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 +0 -1
  24. package/dist/commands/migrate.d.ts.map +1 -1
  25. package/dist/commands/migrate.js +281 -14
  26. package/dist/commands/proof-compact.d.ts +9 -0
  27. package/dist/commands/proof-compact.d.ts.map +1 -0
  28. package/dist/commands/proof-compact.js +58 -0
  29. package/dist/commands/prove.d.ts +38 -0
  30. package/dist/commands/prove.d.ts.map +1 -1
  31. package/dist/commands/prove.js +222 -47
  32. package/dist/commands/sync/persistence.d.ts.map +1 -1
  33. package/dist/commands/sync/persistence.js +61 -16
  34. package/dist/commands/sync.d.ts +8 -0
  35. package/dist/commands/sync.d.ts.map +1 -1
  36. package/dist/commands/sync.js +42 -16
  37. package/dist/diagnostics.js +1 -1
  38. package/dist/engine-limits.d.ts +74 -0
  39. package/dist/engine-limits.d.ts.map +1 -0
  40. package/dist/engine-limits.js +201 -0
  41. package/dist/engine.d.ts +10 -0
  42. package/dist/engine.d.ts.map +1 -1
  43. package/dist/engine.js +57 -9
  44. package/dist/extractors/manifest.d.ts +8 -0
  45. package/dist/extractors/manifest.d.ts.map +1 -1
  46. package/dist/extractors/manifest.js +34 -5
  47. package/dist/extractors/markdown.d.ts +8 -0
  48. package/dist/extractors/markdown.d.ts.map +1 -1
  49. package/dist/extractors/markdown.js +57 -0
  50. package/dist/extractors/relationships.d.ts.map +1 -1
  51. package/dist/extractors/relationships.js +2 -0
  52. package/dist/intent-search.d.ts +4 -1
  53. package/dist/intent-search.d.ts.map +1 -1
  54. package/dist/intent-search.js +186 -33
  55. package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
  56. package/dist/operations/bootstrap/candidate-helpers.js +8 -1
  57. package/dist/operations/bootstrap/candidates.d.ts.map +1 -1
  58. package/dist/operations/bootstrap/candidates.js +54 -38
  59. package/dist/operations/bootstrap/generate.d.ts +2 -0
  60. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  61. package/dist/operations/bootstrap/generate.js +87 -33
  62. package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
  63. package/dist/operations/bootstrap/intent-claims.js +12 -4
  64. package/dist/operations/bootstrap/markdown-candidates.d.ts +2 -0
  65. package/dist/operations/bootstrap/markdown-candidates.d.ts.map +1 -1
  66. package/dist/operations/bootstrap/markdown-candidates.js +32 -10
  67. package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
  68. package/dist/operations/bootstrap/presentation.js +6 -2
  69. package/dist/operations/bootstrap/requirement-claims.d.ts +1 -0
  70. package/dist/operations/bootstrap/requirement-claims.d.ts.map +1 -1
  71. package/dist/operations/bootstrap/requirement-claims.js +13 -1
  72. package/dist/operations/bootstrap/validation.d.ts +4 -0
  73. package/dist/operations/bootstrap/validation.d.ts.map +1 -0
  74. package/dist/operations/bootstrap/validation.js +20 -0
  75. package/dist/operations/migration/inventory-rederive.d.ts +81 -0
  76. package/dist/operations/migration/inventory-rederive.d.ts.map +1 -0
  77. package/dist/operations/migration/inventory-rederive.js +484 -0
  78. package/dist/operations/migration/kb-sources.d.ts +53 -0
  79. package/dist/operations/migration/kb-sources.d.ts.map +1 -0
  80. package/dist/operations/migration/kb-sources.js +233 -0
  81. package/dist/operations/migration/origin-backfill.d.ts +39 -0
  82. package/dist/operations/migration/origin-backfill.d.ts.map +1 -0
  83. package/dist/operations/migration/origin-backfill.js +164 -0
  84. package/dist/operations/migration/polarity-values.d.ts +10 -0
  85. package/dist/operations/migration/polarity-values.d.ts.map +1 -0
  86. package/dist/operations/migration/polarity-values.js +60 -0
  87. package/dist/operations/migration/schema6.d.ts +59 -0
  88. package/dist/operations/migration/schema6.d.ts.map +1 -0
  89. package/dist/operations/migration/schema6.js +379 -0
  90. package/dist/operations/migration/source-paths.d.ts +131 -0
  91. package/dist/operations/migration/source-paths.d.ts.map +1 -0
  92. package/dist/operations/migration/source-paths.js +308 -0
  93. package/dist/operations/migration/superseded-closure.d.ts +54 -0
  94. package/dist/operations/migration/superseded-closure.d.ts.map +1 -0
  95. package/dist/operations/migration/superseded-closure.js +187 -0
  96. package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
  97. package/dist/operations/modeling/logic-modeling.js +3 -5
  98. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  99. package/dist/operations/modeling/model-requirement.js +225 -67
  100. package/dist/operations/mutation/contradictions.d.ts +16 -0
  101. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  102. package/dist/operations/mutation/contradictions.js +32 -0
  103. package/dist/operations/mutation/delete.d.ts.map +1 -1
  104. package/dist/operations/mutation/delete.js +15 -7
  105. package/dist/operations/mutation/origin.d.ts +21 -0
  106. package/dist/operations/mutation/origin.d.ts.map +1 -0
  107. package/dist/operations/mutation/origin.js +78 -0
  108. package/dist/operations/mutation/plan-apply-journal.d.ts +182 -0
  109. package/dist/operations/mutation/plan-apply-journal.d.ts.map +1 -0
  110. package/dist/operations/mutation/plan-apply-journal.js +613 -0
  111. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +3 -1
  112. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -1
  113. package/dist/operations/mutation/predicate-vocabulary-guard.js +13 -2
  114. package/dist/operations/mutation/relationships.d.ts +5 -5
  115. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  116. package/dist/operations/mutation/relationships.js +31 -11
  117. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  118. package/dist/operations/mutation/serialization.js +3 -1
  119. package/dist/operations/mutation/source-authoring.d.ts +6 -0
  120. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  121. package/dist/operations/mutation/source-authoring.js +7 -1
  122. package/dist/operations/mutation/types.d.ts +14 -0
  123. package/dist/operations/mutation/types.d.ts.map +1 -1
  124. package/dist/operations/mutation/upsert.d.ts +30 -3
  125. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  126. package/dist/operations/mutation/upsert.js +105 -35
  127. package/dist/operations/mutation/validate-upsert.d.ts +6 -0
  128. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  129. package/dist/operations/mutation/validate-upsert.js +34 -30
  130. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  131. package/dist/operations/planning/apply-plan.js +751 -144
  132. package/dist/operations/planning/compile-intent.d.ts +34 -1
  133. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  134. package/dist/operations/planning/compile-intent.js +314 -98
  135. package/dist/operations/proof/code-scope.d.ts +28 -0
  136. package/dist/operations/proof/code-scope.d.ts.map +1 -1
  137. package/dist/operations/proof/code-scope.js +72 -0
  138. package/dist/operations/proof/compact-receipts.d.ts +49 -0
  139. package/dist/operations/proof/compact-receipts.d.ts.map +1 -0
  140. package/dist/operations/proof/compact-receipts.js +160 -0
  141. package/dist/operations/proof/ingest-proof.d.ts +2 -0
  142. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  143. package/dist/operations/proof/ingest-proof.js +44 -23
  144. package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
  145. package/dist/operations/proof/prune-receipts.js +5 -9
  146. package/dist/operations/proof/receipt-compaction.d.ts +48 -0
  147. package/dist/operations/proof/receipt-compaction.d.ts.map +1 -0
  148. package/dist/operations/proof/receipt-compaction.js +121 -0
  149. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  150. package/dist/operations/semantic-advisor/analysis-receipt.js +12 -1
  151. package/dist/operations/semantic-advisor/analyze-prose.d.ts +2 -1
  152. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  153. package/dist/operations/semantic-advisor/analyze-prose.js +51 -5
  154. package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
  155. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  156. package/dist/operations/semantic-advisor/clauses.js +11 -1
  157. package/dist/operations/semantic-advisor/conditional-rules.d.ts +33 -0
  158. package/dist/operations/semantic-advisor/conditional-rules.d.ts.map +1 -0
  159. package/dist/operations/semantic-advisor/conditional-rules.js +262 -0
  160. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +3 -1
  161. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
  162. package/dist/operations/semantic-advisor/ingestion-boundary.js +14 -6
  163. package/dist/operations/semantic-advisor/plugin-orchestration.js +1 -1
  164. package/dist/prolog/codec.d.ts.map +1 -1
  165. package/dist/prolog/codec.js +2 -1
  166. package/dist/prolog.d.ts +9 -0
  167. package/dist/prolog.d.ts.map +1 -1
  168. package/dist/prolog.js +56 -10
  169. package/dist/proof/command-test-report.d.ts +74 -0
  170. package/dist/proof/command-test-report.d.ts.map +1 -0
  171. package/dist/proof/command-test-report.js +206 -0
  172. package/dist/public/branch-resolver.d.ts +1 -0
  173. package/dist/public/branch-resolver.d.ts.map +1 -1
  174. package/dist/public/branch-resolver.js +1 -0
  175. package/dist/public/entity-origin.d.ts +69 -0
  176. package/dist/public/entity-origin.d.ts.map +1 -0
  177. package/dist/public/entity-origin.js +142 -0
  178. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  179. package/dist/public/impact/full-kb-quality.js +1 -0
  180. package/dist/public/impact/requirement-quality.js +1 -1
  181. package/dist/public/operations/catalog.d.ts +130 -19
  182. package/dist/public/operations/catalog.d.ts.map +1 -1
  183. package/dist/public/operations/catalog.js +3 -0
  184. package/dist/public/operations/check-executor.d.ts.map +1 -1
  185. package/dist/public/operations/check-executor.js +8 -0
  186. package/dist/public/operations/contracts.d.ts +0 -5
  187. package/dist/public/operations/contracts.d.ts.map +1 -1
  188. package/dist/public/operations/contracts.js +63 -14
  189. package/dist/public/operations/discovery-entities.d.ts +15 -0
  190. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  191. package/dist/public/operations/discovery-entities.js +59 -0
  192. package/dist/public/operations/discovery-executors.d.ts +6 -1
  193. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  194. package/dist/public/operations/discovery-executors.js +65 -6
  195. package/dist/public/operations/index.d.ts +1 -0
  196. package/dist/public/operations/index.d.ts.map +1 -1
  197. package/dist/public/operations/index.js +1 -0
  198. package/dist/public/operations/migration-plan.d.ts +5 -0
  199. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  200. package/dist/public/operations/migration-plan.js +26 -1
  201. package/dist/public/operations/node-ports.d.ts.map +1 -1
  202. package/dist/public/operations/node-ports.js +24 -3
  203. package/dist/public/operations/origin-review.d.ts +51 -0
  204. package/dist/public/operations/origin-review.d.ts.map +1 -0
  205. package/dist/public/operations/origin-review.js +307 -0
  206. package/dist/public/operations/predicate-schema-conformance.js +1 -1
  207. package/dist/public/operations/repair-plan.d.ts.map +1 -1
  208. package/dist/public/operations/repair-plan.js +4 -0
  209. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  210. package/dist/public/operations/result-envelope.js +17 -5
  211. package/dist/public/operations/runtime-types.d.ts +9 -0
  212. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  213. package/dist/public/operations/schema6-check-actions.d.ts +127 -0
  214. package/dist/public/operations/schema6-check-actions.d.ts.map +1 -0
  215. package/dist/public/operations/schema6-check-actions.js +575 -0
  216. package/dist/public/operations/source-path-dangling.d.ts +17 -0
  217. package/dist/public/operations/source-path-dangling.d.ts.map +1 -0
  218. package/dist/public/operations/source-path-dangling.js +66 -0
  219. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  220. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  221. package/dist/public/operations/specs/check-rules.generated.js +15 -1
  222. package/dist/public/operations/specs/check.d.ts +2 -2
  223. package/dist/public/operations/specs/check.js +1 -1
  224. package/dist/public/operations/specs/composite.d.ts +351 -0
  225. package/dist/public/operations/specs/composite.d.ts.map +1 -0
  226. package/dist/public/operations/specs/composite.js +96 -0
  227. package/dist/public/operations/specs/discovery.d.ts +8 -3
  228. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  229. package/dist/public/operations/specs/discovery.js +8 -3
  230. package/dist/public/operations/specs/modeling.d.ts +2 -2
  231. package/dist/public/operations/specs/modeling.js +2 -2
  232. package/dist/public/operations/specs/mutation-schemas.d.ts +73 -8
  233. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  234. package/dist/public/operations/specs/mutation-schemas.js +43 -7
  235. package/dist/public/operations/specs/mutation.d.ts +1 -1
  236. package/dist/public/operations/specs/mutation.js +1 -1
  237. package/dist/public/operations/specs/planning.d.ts +2 -2
  238. package/dist/public/operations/specs/planning.js +4 -4
  239. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  240. package/dist/public/operations/specs/reporting.js +13 -26
  241. package/dist/public/operations/specs/upsert.d.ts +79 -9
  242. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  243. package/dist/public/operations/specs/upsert.js +6 -1
  244. package/dist/public/operations/types.d.ts +1 -1
  245. package/dist/public/operations/types.d.ts.map +1 -1
  246. package/dist/public/proof-receipt.d.ts +1 -0
  247. package/dist/public/proof-receipt.d.ts.map +1 -1
  248. package/dist/public/schemas/entity.d.ts.map +1 -1
  249. package/dist/public/schemas/entity.js +52 -0
  250. package/dist/public/schemas/relationship.d.ts.map +1 -1
  251. package/dist/public/schemas/relationship.js +2 -0
  252. package/dist/public/skills/kibi-bootstrap/SKILL.md +6 -1
  253. package/dist/public/skills/kibi-bootstrap/resources/bootstrap.md +6 -0
  254. package/dist/public/skills/kibi-usage/SKILL.md +68 -18
  255. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
  256. package/dist/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
  257. package/dist/public/skills/kibi-usage/resources/logic-ir.md +2 -2
  258. package/dist/public/skills/kibi-usage/resources/operation-access.md +25 -1
  259. package/dist/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
  260. package/dist/public/skills/kibi-usage/resources/workflows.md +42 -25
  261. package/dist/public/telemetry-acceptance.d.ts +58 -2
  262. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  263. package/dist/public/telemetry-acceptance.js +136 -10
  264. package/dist/public/telemetry-remediation.d.ts.map +1 -1
  265. package/dist/public/telemetry-remediation.js +26 -10
  266. package/dist/relationships/shards.d.ts +13 -0
  267. package/dist/relationships/shards.d.ts.map +1 -1
  268. package/dist/relationships/shards.js +54 -28
  269. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  270. package/dist/runtime/cli-runtime.js +44 -3
  271. package/dist/runtime/detached-snapshot.d.ts +38 -0
  272. package/dist/runtime/detached-snapshot.d.ts.map +1 -0
  273. package/dist/runtime/detached-snapshot.js +92 -0
  274. package/dist/schemas/entity.schema.json +122 -0
  275. package/dist/search-answer.d.ts +157 -0
  276. package/dist/search-answer.d.ts.map +1 -0
  277. package/dist/search-answer.js +846 -0
  278. package/dist/traceability/impact-knowledge.d.ts.map +1 -1
  279. package/dist/traceability/impact-knowledge.js +7 -0
  280. package/dist/traceability/symbol-extract.js +3 -3
  281. package/dist/traceability/temp-kb.d.ts.map +1 -1
  282. package/dist/traceability/temp-kb.js +12 -0
  283. package/dist/types/entities.d.ts +13 -0
  284. package/dist/types/entities.d.ts.map +1 -1
  285. package/dist/types/relationships.d.ts +1 -1
  286. package/dist/types/relationships.d.ts.map +1 -1
  287. package/dist/utils/branch-resolver.d.ts +37 -1
  288. package/dist/utils/branch-resolver.d.ts.map +1 -1
  289. package/dist/utils/branch-resolver.js +130 -3
  290. package/dist/utils/repo-relative-path.d.ts +18 -0
  291. package/dist/utils/repo-relative-path.d.ts.map +1 -0
  292. package/dist/utils/repo-relative-path.js +58 -0
  293. package/dist/utils/rule-registry.generated.d.ts +75 -3
  294. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  295. package/dist/utils/rule-registry.generated.js +89 -3
  296. package/dist/utils/schema-version.d.ts +1 -1
  297. package/dist/utils/schema-version.d.ts.map +1 -1
  298. package/dist/utils/schema-version.js +4 -3
  299. package/dist/utils/strict-modeling.d.ts +1 -1
  300. package/dist/utils/strict-modeling.d.ts.map +1 -1
  301. package/dist/utils/strict-modeling.js +23 -3
  302. package/package.json +3 -3
  303. package/schema/entities.pl +22 -0
  304. package/schema/relationships.pl +14 -0
  305. package/schema/validation.pl +45 -1
  306. package/src/public/branch-resolver.ts +1 -0
  307. package/src/public/entity-origin.ts +175 -0
  308. package/src/public/impact/full-kb-quality.ts +1 -0
  309. package/src/public/impact/requirement-quality.ts +1 -1
  310. package/src/public/operations/catalog.ts +3 -0
  311. package/src/public/operations/check-executor.ts +15 -0
  312. package/src/public/operations/contracts.ts +75 -15
  313. package/src/public/operations/discovery-entities.ts +74 -0
  314. package/src/public/operations/discovery-executors.ts +88 -10
  315. package/src/public/operations/index.ts +1 -0
  316. package/src/public/operations/migration-plan.ts +30 -1
  317. package/src/public/operations/node-ports.ts +24 -3
  318. package/src/public/operations/origin-review.ts +375 -0
  319. package/src/public/operations/predicate-schema-conformance.ts +1 -1
  320. package/src/public/operations/repair-plan.ts +4 -0
  321. package/src/public/operations/result-envelope.ts +18 -6
  322. package/src/public/operations/runtime-types.ts +9 -0
  323. package/src/public/operations/schema6-check-actions.ts +699 -0
  324. package/src/public/operations/source-path-dangling.ts +81 -0
  325. package/src/public/operations/specs/check-rules.generated.ts +15 -1
  326. package/src/public/operations/specs/check.ts +1 -1
  327. package/src/public/operations/specs/composite.ts +141 -0
  328. package/src/public/operations/specs/discovery.ts +9 -3
  329. package/src/public/operations/specs/modeling.ts +2 -2
  330. package/src/public/operations/specs/mutation-schemas.ts +49 -7
  331. package/src/public/operations/specs/mutation.ts +1 -1
  332. package/src/public/operations/specs/planning.ts +4 -4
  333. package/src/public/operations/specs/reporting.ts +13 -38
  334. package/src/public/operations/specs/upsert.ts +7 -1
  335. package/src/public/operations/types.ts +2 -0
  336. package/src/public/proof-receipt.ts +1 -0
  337. package/src/public/schemas/entity.ts +57 -0
  338. package/src/public/schemas/relationship.ts +2 -0
  339. package/src/public/skills/kibi-bootstrap/SKILL.md +6 -1
  340. package/src/public/skills/kibi-bootstrap/resources/bootstrap.md +6 -0
  341. package/src/public/skills/kibi-usage/SKILL.md +68 -18
  342. package/src/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
  343. package/src/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
  344. package/src/public/skills/kibi-usage/resources/logic-ir.md +2 -2
  345. package/src/public/skills/kibi-usage/resources/operation-access.md +25 -1
  346. package/src/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
  347. package/src/public/skills/kibi-usage/resources/workflows.md +42 -25
  348. package/src/public/telemetry-acceptance-types.d.ts +4 -1
  349. package/src/public/telemetry-acceptance.ts +204 -10
  350. package/src/public/telemetry-remediation.ts +39 -10
  351. package/src/schemas/entity.schema.json +122 -0
  352. package/src/schemas/relationship.schema.json +2 -0
@@ -4,42 +4,37 @@ import { extractFromMarkdownString } from "../../extractors/markdown.js";
4
4
  import { confidenceBand, slug, upsert } from "./candidate-helpers.js";
5
5
  import { markdownCandidates, } from "./markdown-candidates.js";
6
6
  function typedCandidates(item, existingIds) {
7
- try {
8
- const results = item.kind === "symbol_manifest"
9
- ? extractFromManifestString(item.content ?? "", item.relativePath ?? item.label)
10
- : [
11
- extractFromMarkdownString(item.content ?? "", item.relativePath ?? item.label),
12
- ];
13
- return results.flatMap(({ entity, relationships }) => {
14
- if (existingIds.has(entity.id))
15
- return [];
16
- const sourceKind = item.kind === "symbol_manifest" ? "symbol_manifest" : "typed_markdown";
17
- return [
18
- {
19
- candidateId: `${sourceKind === "symbol_manifest" ? "mf" : "md"}:${item.relativePath}:${entity.id}`,
20
- entityType: entity.type,
21
- title: entity.title,
22
- sourceKind,
23
- sourcePath: item.absolutePath ?? item.label,
24
- confidence: sourceKind === "symbol_manifest" ? 0.98 : 1,
25
- confidenceBand: "high",
26
- evidence: [
27
- `extracted_from_${sourceKind}:${item.relativePath}`,
28
- `entity_id:${entity.id}`,
29
- ],
30
- relationships: relationships.map(({ type, from, to }) => ({
31
- type,
32
- from,
33
- to,
34
- })),
35
- applyPlan: [upsert(entity, relationships)],
36
- },
37
- ];
38
- });
39
- }
40
- catch {
41
- return [];
42
- }
7
+ const results = item.kind === "symbol_manifest"
8
+ ? extractFromManifestString(item.content ?? "", item.relativePath ?? item.label)
9
+ : [
10
+ extractFromMarkdownString(item.content ?? "", item.relativePath ?? item.label),
11
+ ];
12
+ return results.flatMap(({ entity, relationships }) => {
13
+ if (existingIds.has(entity.id))
14
+ return [];
15
+ const sourceKind = item.kind === "symbol_manifest" ? "symbol_manifest" : "typed_markdown";
16
+ return [
17
+ {
18
+ candidateId: `${sourceKind === "symbol_manifest" ? "mf" : "md"}:${item.relativePath}:${entity.id}`,
19
+ entityType: entity.type,
20
+ title: entity.title,
21
+ sourceKind,
22
+ sourcePath: item.absolutePath ?? item.label,
23
+ confidence: sourceKind === "symbol_manifest" ? 0.98 : 1,
24
+ confidenceBand: "high",
25
+ evidence: [
26
+ `extracted_from_${sourceKind}:${item.relativePath}`,
27
+ `entity_id:${entity.id}`,
28
+ ],
29
+ relationships: relationships.map(({ type, from, to }) => ({
30
+ type,
31
+ from,
32
+ to,
33
+ })),
34
+ applyPlan: [upsert(entity, relationships)],
35
+ },
36
+ ];
37
+ });
43
38
  }
44
39
  function providerCandidate(item, existingIds, minConfidence) {
45
40
  if (!new Set([
@@ -96,13 +91,32 @@ function providerCandidate(item, existingIds, minConfidence) {
96
91
  export function buildBootstrapCandidates(evidence, existingIds, minConfidence, includeGenericMarkdown) {
97
92
  const candidates = [];
98
93
  const sourceOnlySignals = [];
94
+ const diagnostics = [];
95
+ const suppressed = [];
99
96
  for (const item of evidence) {
100
- if (item.kind === "typed_markdown" || item.kind === "symbol_manifest")
101
- candidates.push(...typedCandidates(item, existingIds));
97
+ if (item.kind === "typed_markdown" || item.kind === "symbol_manifest") {
98
+ try {
99
+ candidates.push(...typedCandidates(item, existingIds));
100
+ }
101
+ catch (error) {
102
+ const message = error instanceof Error ? error.message : String(error);
103
+ const sourcePath = item.relativePath ?? item.label;
104
+ diagnostics.push(`Bootstrap extraction failed at ${sourcePath}: ${message}`);
105
+ suppressed.push({
106
+ candidateId: "",
107
+ sourcePath,
108
+ entityType: "",
109
+ reason: "extraction_failed",
110
+ message,
111
+ });
112
+ }
113
+ }
102
114
  if (item.kind === "generic_markdown" && includeGenericMarkdown) {
103
115
  const built = markdownCandidates(item, existingIds, minConfidence);
104
116
  candidates.push(...built.candidates);
105
117
  sourceOnlySignals.push(...built.sourceOnlySignals);
118
+ diagnostics.push(...built.diagnostics);
119
+ suppressed.push(...built.suppressed);
106
120
  }
107
121
  if (item.kind === "test_topology") {
108
122
  const confidence = typeof item.data.confidence === "number" ? item.data.confidence : 0.8;
@@ -122,6 +136,8 @@ export function buildBootstrapCandidates(evidence, existingIds, minConfidence, i
122
136
  }
123
137
  return {
124
138
  candidates,
139
+ diagnostics,
140
+ suppressed,
125
141
  sourceOnlySignals: sourceOnlySignals.sort((left, right) => right.confidence - left.confidence ||
126
142
  left.sourcePath.localeCompare(right.sourcePath)),
127
143
  };
@@ -4,6 +4,8 @@ export declare function filterSourceOnlySignals(signals: readonly SourceOnlySign
4
4
  export declare function selectBootstrapCandidates(input: readonly Candidate[], existingIds: ReadonlySet<string>, entityTypes: readonly string[] | undefined, maximum: number): {
5
5
  readonly candidates: readonly Candidate[];
6
6
  readonly suppressed: readonly Readonly<Record<string, unknown>>[];
7
+ readonly sourceOnlySignals: readonly SourceOnlySignal[];
8
+ readonly diagnostics: readonly string[];
7
9
  };
8
10
  export declare function executePlanBootstrap(args: PlanBootstrapArgs, context: OperationContext): Promise<PlanBootstrapResult>;
9
11
  //# sourceMappingURL=generate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/generate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAMjF,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACzC,SAAS,gBAAgB,EAAE,CAI7B;AA2BD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC1C,OAAO,EAAE,MAAM,GACd;IACD,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;CACnE,CAiDA;AA+GD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CA4E9B"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/generate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAOjF,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,SAAS,gBAAgB,EAAE,EACpC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,GACzC,SAAS,gBAAgB,EAAE,CAI7B;AA8BD,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,SAAS,EAAE,EAC3B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,EAC1C,OAAO,EAAE,MAAM,GACd;IACD,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAsFA;AAiHD,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,iBAAiB,EACvB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,mBAAmB,CAAC,CA6F9B"}
@@ -7,6 +7,7 @@ import { buildBootstrapCandidates } from "./candidates.js";
7
7
  import { discoverBootstrap } from "./discovery.js";
8
8
  import { buildIntentClaimCandidates } from "./intent-claims.js";
9
9
  import { normalizeBootstrapContext, presentBootstrap } from "./presentation.js";
10
+ import { validateBootstrapPayload } from "./validation.js";
10
11
  export function filterSourceOnlySignals(signals, entityTypes) {
11
12
  return entityTypes && entityTypes.length > 0
12
13
  ? signals.filter((signal) => entityTypes.includes(signal.kind))
@@ -20,7 +21,7 @@ function titleKey(candidate) {
20
21
  return `${candidate.entityType}::${candidate.title.trim().toLowerCase().replace(/\s+/g, " ")}`;
21
22
  }
22
23
  function firstUpsertId(candidate) {
23
- const first = candidate.applyPlan[0];
24
+ const first = candidate.applyPlan.find((payload) => payload.type === candidate.entityType) ?? candidate.applyPlan[0];
24
25
  if (typeof first?.id === "string")
25
26
  return first.id;
26
27
  const properties = first?.properties;
@@ -35,48 +36,84 @@ function sha256(value) {
35
36
  return createHash("sha256").update(value).digest("hex");
36
37
  }
37
38
  export function selectBootstrapCandidates(input, existingIds, entityTypes, maximum) {
38
- const allowed = entityTypes && entityTypes.length > 0 ? new Set(entityTypes) : null;
39
- const sorted = input
40
- .filter((candidate) => allowed?.has(candidate.entityType) ?? true)
41
- .sort((left, right) => right.confidence - left.confidence ||
42
- left.sourcePath.localeCompare(right.sourcePath))
43
- .slice(0, maximum);
44
- const typedTitles = new Set(sorted
45
- .filter((candidate) => candidate.sourceKind === "typed_markdown")
46
- .map(titleKey));
47
- const selected = new Map();
39
+ const allowed = entityTypes?.length ? new Set(entityTypes) : null;
40
+ const lane = (candidate) => {
41
+ if (candidate.sourceKind === "intent_claim")
42
+ return 0;
43
+ if (candidate.entityType === "req" &&
44
+ ["typed_markdown", "generic_markdown"].includes(candidate.sourceKind))
45
+ return 1;
46
+ return 2;
47
+ };
48
48
  const suppressed = [];
49
- const suppress = (candidate, reason) => {
49
+ const sourceOnlySignals = [];
50
+ const diagnostics = [];
51
+ const suppress = (candidate, reason, message) => {
50
52
  suppressed.push({
51
53
  candidateId: candidate.candidateId,
52
54
  reason,
53
55
  sourcePath: candidate.sourcePath,
54
56
  entityType: candidate.entityType,
57
+ ...(message ? { message } : {}),
55
58
  });
56
59
  };
57
- for (const candidate of sorted) {
60
+ const writable = input
61
+ .filter((candidate) => {
62
+ if (allowed && !allowed.has(candidate.entityType))
63
+ return false;
58
64
  if (existingIds.has(firstUpsertId(candidate))) {
59
65
  suppress(candidate, "entity_exists");
60
- continue;
66
+ return false;
67
+ }
68
+ try {
69
+ if (candidate.applyPlan.length === 0)
70
+ throw new Error("Candidate has no write actions");
71
+ for (const payload of candidate.applyPlan)
72
+ validateBootstrapPayload(payload, new Date());
73
+ return true;
61
74
  }
75
+ catch (error) {
76
+ const message = error instanceof Error ? error.message : String(error);
77
+ suppress(candidate, "invalid_write", message);
78
+ diagnostics.push(`Invalid bootstrap candidate at ${candidate.sourcePath}: ${message}`);
79
+ sourceOnlySignals.push({
80
+ kind: "req",
81
+ title: `Author requirement: ${candidate.title}`,
82
+ sourcePath: candidate.sourcePath,
83
+ confidence: candidate.confidence,
84
+ evidence: candidate.evidence,
85
+ });
86
+ return false;
87
+ }
88
+ })
89
+ .sort((left, right) => lane(left) - lane(right) ||
90
+ right.confidence - left.confidence ||
91
+ left.sourcePath.localeCompare(right.sourcePath) ||
92
+ left.candidateId.localeCompare(right.candidateId));
93
+ const typedTitles = new Set(writable
94
+ .filter((candidate) => candidate.sourceKind === "typed_markdown")
95
+ .map(titleKey));
96
+ const selected = new Map();
97
+ for (const candidate of writable) {
62
98
  const key = titleKey(candidate);
63
99
  if (candidate.sourceKind === "generic_markdown" && typedTitles.has(key)) {
64
100
  suppress(candidate, "shadowed_by_typed_source");
65
- continue;
66
101
  }
67
- const previous = selected.get(key);
68
- if (!previous) {
69
- selected.set(key, candidate);
70
- continue;
102
+ else if (selected.has(key)) {
103
+ suppress(candidate, "duplicate_title");
71
104
  }
72
- const keepCandidate = candidate.confidence > previous.confidence ||
73
- (candidate.confidence === previous.confidence &&
74
- candidate.sourcePath < previous.sourcePath);
75
- suppress(keepCandidate ? previous : candidate, "duplicate_title");
76
- if (keepCandidate)
105
+ else
77
106
  selected.set(key, candidate);
78
107
  }
79
- return { candidates: [...selected.values()], suppressed };
108
+ const unique = [...selected.values()];
109
+ for (const candidate of unique.slice(maximum))
110
+ suppress(candidate, "over_limit");
111
+ return {
112
+ candidates: unique.slice(0, maximum),
113
+ suppressed,
114
+ sourceOnlySignals,
115
+ diagnostics,
116
+ };
80
117
  }
81
118
  async function existingEntityIds(context) {
82
119
  if (!context.prolog)
@@ -86,8 +123,8 @@ async function existingEntityIds(context) {
86
123
  // just to build this set exceeds the bounded engine output.
87
124
  return new Set((await loadEntityIds(context.prolog)).filter(Boolean));
88
125
  }
89
- catch {
90
- return new Set();
126
+ catch (error) {
127
+ throw new Error(`Bootstrap binding could not read existing entity IDs: ${error instanceof Error ? error.message : String(error)}`);
91
128
  }
92
129
  }
93
130
  async function expectedSnapshots(context, evidencePaths) {
@@ -171,9 +208,13 @@ export async function executePlanBootstrap(args, context) {
171
208
  const includeGenericMarkdown = args.includeGenericMarkdown ?? true;
172
209
  const minConfidence = clamp(args.minConfidence ?? 0.8, 0.6, 0.95);
173
210
  const maxCandidates = clamp(Math.trunc(args.maxCandidates ?? 50), 1, 200);
211
+ const entityBindingDiagnostics = [];
174
212
  const [discovery, existingIds] = await Promise.all([
175
213
  discoverBootstrap(context),
176
- existingEntityIds(context),
214
+ existingEntityIds(context).catch((error) => {
215
+ entityBindingDiagnostics.push(error.message);
216
+ return new Set();
217
+ }),
177
218
  ]);
178
219
  // Discovery runs before planning so its evidence paths can be bound into
179
220
  // the exact plan rather than leaving the reviewer to reconstruct them.
@@ -181,8 +222,13 @@ export async function executePlanBootstrap(args, context) {
181
222
  .map((evidence) => evidence.relativePath)
182
223
  .filter((value) => Boolean(value)));
183
224
  const built = discovery.activation.allowCandidateGeneration
184
- ? buildBootstrapCandidates(discovery.evidence, existingIds, minConfidence, includeGenericMarkdown)
185
- : { candidates: [], sourceOnlySignals: [] };
225
+ ? buildBootstrapCandidates(discovery.evidence, new Set(), minConfidence, includeGenericMarkdown)
226
+ : {
227
+ candidates: [],
228
+ sourceOnlySignals: [],
229
+ suppressed: [],
230
+ diagnostics: [],
231
+ };
186
232
  // Intent harvested from declared knowledge sources joins the repository
187
233
  // evidence under the same activation policy, filters, and selection.
188
234
  const claimed = discovery.activation.allowCandidateGeneration
@@ -211,14 +257,22 @@ export async function executePlanBootstrap(args, context) {
211
257
  ? { bootstrapContext: args.bootstrapContext }
212
258
  : {}),
213
259
  candidates: selected.candidates,
214
- sourceOnlySignals: filteredSignals,
260
+ sourceOnlySignals: [
261
+ ...filteredSignals,
262
+ ...filterSourceOnlySignals(selected.sourceOnlySignals, args.entityTypes),
263
+ ],
215
264
  suppressedCandidates: [
216
265
  ...selected.suppressed,
217
266
  ...claimed.suppressed,
267
+ ...built.suppressed,
218
268
  ...ignored,
219
269
  ],
220
270
  expected,
221
- bindingDiagnostics,
222
- contextDiagnostics: claimed.diagnostics,
271
+ bindingDiagnostics: [...bindingDiagnostics, ...entityBindingDiagnostics],
272
+ contextDiagnostics: [
273
+ ...claimed.diagnostics,
274
+ ...built.diagnostics,
275
+ ...selected.diagnostics,
276
+ ],
223
277
  });
224
278
  }
@@ -1 +1 @@
1
- {"version":3,"file":"intent-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/intent-claims.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EAGxB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAQpB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAcF;;;;;;;GAOG;AAEH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,GACpB,sBAAsB,CAgFxB"}
1
+ {"version":3,"file":"intent-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/intent-claims.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EAGxB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAQpB,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAClE,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC;AAcF;;;;;;;GAOG;AAEH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,wBAAwB,EAClC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,GACpB,sBAAsB,CA2FxB"}
@@ -49,10 +49,18 @@ export function buildIntentClaimCandidates(declared, existingIds, minConfidence)
49
49
  const confidence = AUTHORITY_CONFIDENCE[source.authority];
50
50
  const evidence = citation(source, claim);
51
51
  const provenance = `${source.id}:${claim.reference}`;
52
- const modeled = claimFor(claim.statement, `knowledge-source:${source.id}`, confidence, provenance);
53
- const writeSet = modeled
54
- ? buildStrictWriteSet({ claim: modeled, statement: claim.statement })
55
- : null;
52
+ let writeSet = null;
53
+ try {
54
+ const modeled = claimFor(claim.statement, `knowledge-source:${source.id}`, confidence, provenance);
55
+ writeSet = modeled
56
+ ? buildStrictWriteSet({ claim: modeled, statement: claim.statement })
57
+ : null;
58
+ if (!modeled)
59
+ diagnostics.push(`Intent claim needs authoring at ${source.id}:${claim.reference}: ${claim.statement}`);
60
+ }
61
+ catch (error) {
62
+ diagnostics.push(`Intent claim extraction failed at ${source.id}:${claim.reference}: ${error instanceof Error ? error.message : String(error)}`);
63
+ }
56
64
  if (writeSet?.isStrict &&
57
65
  confidence >= minConfidence &&
58
66
  !existingIds.has(writeSet.req.id)) {
@@ -2,6 +2,8 @@ import type { BootstrapEvidence, Candidate, SourceOnlySignal } from "./types.js"
2
2
  export type CandidateBuildResult = {
3
3
  readonly candidates: readonly Candidate[];
4
4
  readonly sourceOnlySignals: readonly SourceOnlySignal[];
5
+ readonly diagnostics: readonly string[];
6
+ readonly suppressed: readonly Readonly<Record<string, unknown>>[];
5
7
  };
6
8
  export declare function markdownCandidates(item: BootstrapEvidence, existingIds: ReadonlySet<string>, minConfidence: number): CandidateBuildResult;
7
9
  //# sourceMappingURL=markdown-candidates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"markdown-candidates.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/markdown-candidates.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACzD,CAAC;AA4HF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,GACpB,oBAAoB,CAoDtB"}
1
+ {"version":3,"file":"markdown-candidates.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/markdown-candidates.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;CACnE,CAAC;AA4HF,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,EAChC,aAAa,EAAE,MAAM,GACpB,oBAAoB,CAkFtB"}
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
2
  import { buildStrictWriteSet } from "../../utils/strict-modeling.js";
3
3
  import { confidenceBand, slug, strictPlan, upsert, } from "./candidate-helpers.js";
4
- import { claimFor } from "./requirement-claims.js";
4
+ import { claimFor, normalizeClaimStatement } from "./requirement-claims.js";
5
5
  function headingSignals(heading, sourcePath, textRef, minConfidence) {
6
6
  const result = [];
7
7
  for (const [kind, pattern, confidence] of [
@@ -74,7 +74,7 @@ function requirementCandidate(item, statement, line, heading, headingLine, exist
74
74
  if (!claim)
75
75
  return null;
76
76
  const writeSet = buildStrictWriteSet({ claim, statement });
77
- if (!writeSet.isStrict || existingIds.has(writeSet.req.id))
77
+ if (!writeSet.isStrict)
78
78
  return null;
79
79
  return {
80
80
  candidateId: `norm:${writeSet.req.id.toLowerCase()}`,
@@ -100,6 +100,7 @@ function requirementCandidate(item, statement, line, heading, headingLine, exist
100
100
  export function markdownCandidates(item, existingIds, minConfidence) {
101
101
  const candidates = [];
102
102
  const sourceOnlySignals = [];
103
+ const diagnostics = [];
103
104
  const relativePath = item.relativePath ?? item.label;
104
105
  let heading;
105
106
  let headingLine = 0;
@@ -121,15 +122,36 @@ export function markdownCandidates(item, existingIds, minConfidence) {
121
122
  sourceOnlySignals.push(...headingSignals(heading, item.absolutePath ?? relativePath, `${relativePath}#L${headingLine}`, minConfidence));
122
123
  continue;
123
124
  }
124
- const statement = line
125
- .replace(/^\s*[-*+]\s+/, "")
126
- .replace(/^\s*\d+[.)]\s+/, "")
127
- .trim();
125
+ const statement = normalizeClaimStatement(line);
128
126
  if (!statement || !/\b(must|shall|should)\b/i.test(statement))
129
127
  continue;
130
- const candidate = requirementCandidate(item, statement, index + 1, heading, headingLine, existingIds, minConfidence);
131
- if (candidate)
132
- candidates.push(candidate);
128
+ try {
129
+ const candidate = requirementCandidate(item, statement, index + 1, heading, headingLine, existingIds, minConfidence);
130
+ if (candidate) {
131
+ if (!candidate.applyPlan.some((payload) => payload.type === "req" && existingIds.has(String(payload.id))))
132
+ candidates.push(candidate);
133
+ }
134
+ else {
135
+ diagnostics.push(`Requirement needs authoring at ${relativePath}#L${index + 1}: ${statement}`);
136
+ sourceOnlySignals.push({
137
+ kind: "req",
138
+ title: `Author requirement: ${statement}`,
139
+ sourcePath: `${relativePath}#L${index + 1}`,
140
+ confidence: 0.8,
141
+ evidence: [`normative_statement:${relativePath}#L${index + 1}`],
142
+ });
143
+ }
144
+ }
145
+ catch (error) {
146
+ diagnostics.push(`Requirement extraction failed at ${relativePath}#L${index + 1}: ${error instanceof Error ? error.message : String(error)}`);
147
+ sourceOnlySignals.push({
148
+ kind: "req",
149
+ title: `Review requirement: ${statement}`,
150
+ sourcePath: `${relativePath}#L${index + 1}`,
151
+ confidence: 0.8,
152
+ evidence: [`normative_statement:${relativePath}#L${index + 1}`],
153
+ });
154
+ }
133
155
  }
134
- return { candidates, sourceOnlySignals };
156
+ return { candidates, sourceOnlySignals, diagnostics, suppressed: [] };
135
157
  }
@@ -1 +1 @@
1
- {"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/presentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EAChB,wBAAwB,EAGxB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAwEpB,wBAAgB,yBAAyB,CACvC,KAAK,CAAC,EAAE,gBAAgB,GACvB,wBAAwB,CAa1B;AAiBD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,oBAAoB,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAC5E,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IAC/C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChD,wEAAwE;IACxE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjD,GAAG,mBAAmB,CA+KtB"}
1
+ {"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/presentation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAEhB,gBAAgB,EAChB,wBAAwB,EAGxB,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAwEpB,wBAAgB,yBAAyB,CACvC,KAAK,CAAC,EAAE,gBAAgB,GACvB,wBAAwB,CAa1B;AAiBD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACxD,QAAQ,CAAC,oBAAoB,EAAE,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IAC5E,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,CAAC;IAC/C,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChD,wEAAwE;IACxE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjD,GAAG,mBAAmB,CAsLtB"}
@@ -107,9 +107,13 @@ export function presentBootstrap(input) {
107
107
  input.candidates.length + input.sourceOnlySignals.length > 0
108
108
  ? `Bootstrap plan is ready for review with ${input.candidates.length} safe candidate(s) and ${input.sourceOnlySignals.length} source-only authoring follow-up(s).`
109
109
  : (input.activation.handoffMessage ?? blockedFallback);
110
- const tldr = confidenceLevel === "low" && !input.activation.applyBlocked
110
+ const overLimitCount = input.suppressedCandidates.filter((row) => row.reason === "over_limit").length;
111
+ const limitSummary = overLimitCount > 0
112
+ ? ` ${overLimitCount} candidate(s) exceeded maxCandidates; raise the limit or narrow entityTypes.`
113
+ : "";
114
+ const tldr = (confidenceLevel === "low" && !input.activation.applyBlocked
111
115
  ? `Low-confidence bootstrap (${String(guidance.confidence.score)}): review diagnostics before proceeding. ${baseTldr}`
112
- : baseTldr;
116
+ : baseTldr) + limitSummary;
113
117
  const rawActions = input.candidates.flatMap((candidate) => candidate.applyPlan.map((payload) => ({ candidate, payload })));
114
118
  const actionIds = new Map();
115
119
  rawActions.forEach(({ payload }, index) => {
@@ -1,3 +1,4 @@
1
1
  import type { SemanticClaim } from "../../utils/strict-modeling.js";
2
+ export declare function normalizeClaimStatement(statement: string): string;
2
3
  export declare function claimFor(statement: string, source: string, confidence: number, provenance: string): SemanticClaim | null;
3
4
  //# sourceMappingURL=requirement-claims.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"requirement-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/requirement-claims.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE,wBAAgB,QAAQ,CACtB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,aAAa,GAAG,IAAI,CAsDtB"}
1
+ {"version":3,"file":"requirement-claims.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/requirement-claims.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAGpE,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAKjE;AAED,wBAAgB,QAAQ,CACtB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,aAAa,GAAG,IAAI,CA0DtB"}
@@ -1,5 +1,17 @@
1
+ // implements REQ-KIBI-BOOTSTRAP-PLAN
2
+ export function normalizeClaimStatement(statement) {
3
+ return statement
4
+ .replace(/^\s*(?:[-*+]|\d+[.)])\s+/, "")
5
+ .replace(/^\s*\[(?: |x)\]\s*/i, "")
6
+ .trim();
7
+ }
1
8
  export function claimFor(statement, source, confidence, provenance) {
2
- const normalized = statement.replace(/^\s*(?:[-*+]|\d+[.)])\s+/, "").trim();
9
+ const cleaned = normalizeClaimStatement(statement);
10
+ if (cleaned.endsWith("?"))
11
+ return null;
12
+ const normalized = /^(?:must|shall|should)\s+/i.test(cleaned)
13
+ ? `System ${cleaned}`
14
+ : cleaned;
3
15
  const retention = normalized.match(/^(?<subject>.+?)\s+(?:must|shall|should)\s+be\s+retained\s+for\s+(?<value>\d+)\s+(?<unit>day|days|month|months|year|years)\.?$/i);
4
16
  if (retention?.groups?.subject &&
5
17
  retention.groups.value &&
@@ -0,0 +1,4 @@
1
+ import type { UpsertInput } from "../mutation/types.js";
2
+ /** Validate the original payload without dropping malformed relationships. */
3
+ export declare function validateBootstrapPayload(payload: Readonly<Record<string, unknown>>, now: Date): UpsertInput;
4
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAKxD,8EAA8E;AAE9E,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC1C,GAAG,EAAE,IAAI,GACR,WAAW,CAsBb"}
@@ -0,0 +1,20 @@
1
+ import { validateUpsertInput } from "../mutation/validation.js";
2
+ import { analyzeSemanticAdvisorInput } from "../semantic-advisor/analyze-prose.js";
3
+ import { assertSemanticInventoryBoundary } from "../semantic-advisor/ingestion-boundary.js";
4
+ /** Validate the original payload without dropping malformed relationships. */
5
+ // implements REQ-KIBI-BOOTSTRAP-PLAN
6
+ export function validateBootstrapPayload(payload, now) {
7
+ if (!payload || typeof payload !== "object" || Array.isArray(payload))
8
+ throw new Error("Bootstrap action payload must be an upsert object");
9
+ if (payload.relationships !== undefined &&
10
+ !Array.isArray(payload.relationships))
11
+ throw new Error("Relationship validation failed: relationships must be an array");
12
+ const input = payload;
13
+ validateUpsertInput(input, now);
14
+ const relationships = input.relationships ?? [];
15
+ const semantic = analyzeSemanticAdvisorInput({
16
+ payload: { ...input, relationships },
17
+ });
18
+ assertSemanticInventoryBoundary({ ...input, relationships }, relationships, semantic.receipt);
19
+ return input;
20
+ }
@@ -0,0 +1,81 @@
1
+ type InventoryEntry = {
2
+ claim_key: string;
3
+ claim_text: string;
4
+ role: string;
5
+ status: string;
6
+ span: {
7
+ start: number;
8
+ end: number;
9
+ };
10
+ semantic_key?: string;
11
+ reason?: string;
12
+ };
13
+ /** What re-derivation changed for one claim. */
14
+ export type InventoryClaimChange = Readonly<{
15
+ claim_key: string;
16
+ change: "kept" | "role_changed" | "span_changed" | "new_unresolved" | "new_context" | "now_unresolved" | "now_context" | "dropped";
17
+ before?: Readonly<{
18
+ role: string;
19
+ status: string;
20
+ }>;
21
+ after?: Readonly<{
22
+ role: string;
23
+ status: string;
24
+ }>;
25
+ }>;
26
+ export type InventoryRederivationSummary = Readonly<{
27
+ keptModeled: number;
28
+ roleChanges: number;
29
+ newlyUnresolved: number;
30
+ droppedClaims: number;
31
+ downgradedModeled: number;
32
+ }>;
33
+ /** The re-derived inventory contract written to the requirement. */
34
+ export type InventoryContract = Readonly<{
35
+ semantic_inventory_version: string;
36
+ semantic_source_field: string;
37
+ semantic_source_hash: string;
38
+ semantic_inventory: readonly InventoryEntry[];
39
+ logic_claims: readonly string[];
40
+ }>;
41
+ export type InventoryRederivation = Readonly<{
42
+ requirementId: string;
43
+ path: string;
44
+ /** Ingestion errors the stored inventory produces today. */
45
+ errors: readonly string[];
46
+ safe: boolean;
47
+ /** Why re-derivation is left to a person (empty when safe). */
48
+ reasons: readonly string[];
49
+ summary: InventoryRederivationSummary;
50
+ changes: readonly InventoryClaimChange[];
51
+ contract: InventoryContract;
52
+ /** SHA-256 of the canonical re-derived contract; the apply step re-checks it. */
53
+ contractHash: string;
54
+ }>;
55
+ /**
56
+ * Every current requirement whose stored inventory contract no longer matches
57
+ * the current semantic advisor, with its re-derived contract. Read-only;
58
+ * reports all of them instead of stopping at the first. `onlyId` limits the
59
+ * scan to one requirement.
60
+ */
61
+ export declare function planInventoryRederivation(workspaceRoot: string, onlyId?: string): InventoryRederivation[];
62
+ export type InventoryRederivationOutcome = Readonly<{
63
+ requirementId: string;
64
+ path: string;
65
+ outcome: "rederived" | "unchanged";
66
+ summary?: InventoryRederivationSummary;
67
+ }>;
68
+ /**
69
+ * Apply the safe re-derivation of one requirement. When `expectedContractHash`
70
+ * is given (the migration plan's evidence), the current re-derivation must
71
+ * still produce exactly that contract. A requirement that no longer drifts is
72
+ * left unchanged, so repeated runs are no-ops.
73
+ */
74
+ export declare function applyInventoryRederivation(workspaceRoot: string, requirementId: string, expectedContractHash?: string): InventoryRederivationOutcome;
75
+ /** Apply every safe re-derivation; unsafe ones are returned untouched. */
76
+ export declare function applySafeInventoryRederivations(workspaceRoot: string): {
77
+ rederived: InventoryRederivationOutcome[];
78
+ manual: InventoryRederivation[];
79
+ };
80
+ export {};
81
+ //# sourceMappingURL=inventory-rederive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inventory-rederive.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/inventory-rederive.ts"],"names":[],"mappings":"AA2EA,KAAK,cAAc,GAAG;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,gDAAgD;AAEhD,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EACF,MAAM,GACN,cAAc,GACd,cAAc,GACd,gBAAgB,GAChB,aAAa,GACb,gBAAgB,GAChB,aAAa,GACb,SAAS,CAAC;IACd,MAAM,CAAC,EAAE,QAAQ,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,KAAK,CAAC,EAAE,QAAQ,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD,CAAC,CAAC;AAGH,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC,CAAC;AAEH,oEAAoE;AAEpE,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,0BAA0B,EAAE,MAAM,CAAC;IACnC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,SAAS,cAAc,EAAE,CAAC;IAC9C,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC,CAAC,CAAC;AAGH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,+DAA+D;IAC/D,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,4BAA4B,CAAC;IACtC,OAAO,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACzC,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,iFAAiF;IACjF,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC;AA2UH;;;;;GAKG;AAEH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,MAAM,GACd,qBAAqB,EAAE,CA+BzB;AA0FD,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,WAAW,GAAG,WAAW,CAAC;IACnC,OAAO,CAAC,EAAE,4BAA4B,CAAC;CACxC,CAAC,CAAC;AAEH;;;;;GAKG;AAEH,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,EACrB,oBAAoB,CAAC,EAAE,MAAM,GAC5B,4BAA4B,CA0C9B;AAED,0EAA0E;AAE1E,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,GAAG;IACtE,SAAS,EAAE,4BAA4B,EAAE,CAAC;IAC1C,MAAM,EAAE,qBAAqB,EAAE,CAAC;CACjC,CAaA"}