@lumenflow/core 4.24.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/dist/arg-parser.d.ts.map +1 -1
  2. package/dist/arg-parser.js +16 -0
  3. package/dist/arg-parser.js.map +1 -1
  4. package/dist/atomic-merge.d.ts.map +1 -1
  5. package/dist/atomic-merge.js +25 -18
  6. package/dist/atomic-merge.js.map +1 -1
  7. package/dist/client-ids.d.ts +1 -15
  8. package/dist/client-ids.d.ts.map +1 -1
  9. package/dist/client-ids.js +4 -13
  10. package/dist/client-ids.js.map +1 -1
  11. package/dist/code-path-validator.d.ts.map +1 -1
  12. package/dist/code-path-validator.js +6 -3
  13. package/dist/code-path-validator.js.map +1 -1
  14. package/dist/config-contract.d.ts +1 -30
  15. package/dist/config-contract.d.ts.map +1 -1
  16. package/dist/config-contract.js +4 -60
  17. package/dist/config-contract.js.map +1 -1
  18. package/dist/constants/backlog-patterns.d.ts +1 -20
  19. package/dist/constants/backlog-patterns.d.ts.map +1 -1
  20. package/dist/constants/backlog-patterns.js +2 -23
  21. package/dist/constants/backlog-patterns.js.map +1 -1
  22. package/dist/constants/duration-constants.d.ts +1 -28
  23. package/dist/constants/duration-constants.d.ts.map +1 -1
  24. package/dist/constants/duration-constants.js +4 -28
  25. package/dist/constants/duration-constants.js.map +1 -1
  26. package/dist/constants/gate-constants.d.ts +1 -23
  27. package/dist/constants/gate-constants.d.ts.map +1 -1
  28. package/dist/constants/gate-constants.js +4 -23
  29. package/dist/constants/gate-constants.js.map +1 -1
  30. package/dist/constants/lock-constants.d.ts +1 -28
  31. package/dist/constants/lock-constants.d.ts.map +1 -1
  32. package/dist/constants/lock-constants.js +2 -28
  33. package/dist/constants/lock-constants.js.map +1 -1
  34. package/dist/core/tool.schemas.d.ts +11 -11
  35. package/dist/core/worktree-guard.js +2 -2
  36. package/dist/core/worktree-guard.js.map +1 -1
  37. package/dist/cycle-detector.d.ts +4 -48
  38. package/dist/cycle-detector.d.ts.map +1 -1
  39. package/dist/cycle-detector.js +4 -78
  40. package/dist/cycle-detector.js.map +1 -1
  41. package/dist/date-utils.d.ts +1 -65
  42. package/dist/date-utils.d.ts.map +1 -1
  43. package/dist/date-utils.js +4 -140
  44. package/dist/date-utils.js.map +1 -1
  45. package/dist/delegation-monitor.d.ts +2 -0
  46. package/dist/delegation-monitor.d.ts.map +1 -1
  47. package/dist/delegation-monitor.js +29 -2
  48. package/dist/delegation-monitor.js.map +1 -1
  49. package/dist/delegation-recovery.d.ts +36 -17
  50. package/dist/delegation-recovery.d.ts.map +1 -1
  51. package/dist/delegation-recovery.js +285 -82
  52. package/dist/delegation-recovery.js.map +1 -1
  53. package/dist/delegation-registry-schema.d.ts +257 -31
  54. package/dist/delegation-registry-schema.d.ts.map +1 -1
  55. package/dist/delegation-registry-schema.js +43 -34
  56. package/dist/delegation-registry-schema.js.map +1 -1
  57. package/dist/delegation-registry-store.d.ts +4 -128
  58. package/dist/delegation-registry-store.d.ts.map +1 -1
  59. package/dist/delegation-registry-store.js +39 -178
  60. package/dist/delegation-registry-store.js.map +1 -1
  61. package/dist/delegation-tree.d.ts +12 -20
  62. package/dist/delegation-tree.d.ts.map +1 -1
  63. package/dist/delegation-tree.js +40 -29
  64. package/dist/delegation-tree.js.map +1 -1
  65. package/dist/delivery-review-contract.d.ts +1 -1
  66. package/dist/delivery-review-contract.d.ts.map +1 -1
  67. package/dist/docs-layout-presets.d.ts +1 -30
  68. package/dist/docs-layout-presets.d.ts.map +1 -1
  69. package/dist/docs-layout-presets.js +4 -38
  70. package/dist/docs-layout-presets.js.map +1 -1
  71. package/dist/domain/context.schemas.d.ts +3 -3
  72. package/dist/domain/orchestration.constants.d.ts +1 -110
  73. package/dist/domain/orchestration.constants.d.ts.map +1 -1
  74. package/dist/domain/orchestration.constants.js +2 -127
  75. package/dist/domain/orchestration.constants.js.map +1 -1
  76. package/dist/domain/orchestration.schemas.d.ts +1 -306
  77. package/dist/domain/orchestration.schemas.d.ts.map +1 -1
  78. package/dist/domain/orchestration.schemas.js +2 -211
  79. package/dist/domain/orchestration.schemas.js.map +1 -1
  80. package/dist/domain/orchestration.types.d.ts +1 -133
  81. package/dist/domain/orchestration.types.d.ts.map +1 -1
  82. package/dist/domain/orchestration.types.js +2 -2
  83. package/dist/domain/orchestration.types.js.map +1 -1
  84. package/dist/domain/recovery.schemas.d.ts +3 -3
  85. package/dist/domain/validation.schemas.d.ts +4 -4
  86. package/dist/error-handler.d.ts +4 -173
  87. package/dist/error-handler.d.ts.map +1 -1
  88. package/dist/error-handler.js +4 -244
  89. package/dist/error-handler.js.map +1 -1
  90. package/dist/file-classifiers.d.ts.map +1 -1
  91. package/dist/file-classifiers.js +26 -0
  92. package/dist/file-classifiers.js.map +1 -1
  93. package/dist/git-adapter.d.ts +4 -448
  94. package/dist/git-adapter.d.ts.map +1 -1
  95. package/dist/git-adapter.js +4 -772
  96. package/dist/git-adapter.js.map +1 -1
  97. package/dist/git-context-extractor.d.ts +4 -98
  98. package/dist/git-context-extractor.d.ts.map +1 -1
  99. package/dist/git-context-extractor.js +4 -563
  100. package/dist/git-context-extractor.js.map +1 -1
  101. package/dist/git-staged-validator.d.ts +4 -29
  102. package/dist/git-staged-validator.d.ts.map +1 -1
  103. package/dist/git-staged-validator.js +4 -46
  104. package/dist/git-staged-validator.js.map +1 -1
  105. package/dist/incremental-lint.d.ts.map +1 -1
  106. package/dist/incremental-lint.js +3 -2
  107. package/dist/incremental-lint.js.map +1 -1
  108. package/dist/incremental-test.d.ts +1 -32
  109. package/dist/incremental-test.d.ts.map +1 -1
  110. package/dist/incremental-test.js +4 -61
  111. package/dist/incremental-test.js.map +1 -1
  112. package/dist/index.d.ts +3 -2
  113. package/dist/index.d.ts.map +1 -1
  114. package/dist/index.js +10 -2
  115. package/dist/index.js.map +1 -1
  116. package/dist/integration-target.d.ts +30 -0
  117. package/dist/integration-target.d.ts.map +1 -0
  118. package/dist/integration-target.js +51 -0
  119. package/dist/integration-target.js.map +1 -0
  120. package/dist/lane-checker.d.ts.map +1 -1
  121. package/dist/lane-checker.js +8 -0
  122. package/dist/lane-checker.js.map +1 -1
  123. package/dist/lumenflow-config-schema.d.ts +73 -29
  124. package/dist/lumenflow-config-schema.d.ts.map +1 -1
  125. package/dist/lumenflow-config-schema.js +1 -1
  126. package/dist/lumenflow-config-schema.js.map +1 -1
  127. package/dist/lumenflow-config.d.ts +10 -34
  128. package/dist/lumenflow-config.d.ts.map +1 -1
  129. package/dist/lumenflow-config.js +32 -142
  130. package/dist/lumenflow-config.js.map +1 -1
  131. package/dist/manual-test-validator.d.ts +1 -96
  132. package/dist/manual-test-validator.d.ts.map +1 -1
  133. package/dist/manual-test-validator.js +4 -245
  134. package/dist/manual-test-validator.js.map +1 -1
  135. package/dist/micro-worktree-shared.d.ts.map +1 -1
  136. package/dist/micro-worktree-shared.js +10 -9
  137. package/dist/micro-worktree-shared.js.map +1 -1
  138. package/dist/micro-worktree.d.ts.map +1 -1
  139. package/dist/micro-worktree.js +26 -23
  140. package/dist/micro-worktree.js.map +1 -1
  141. package/dist/normalize-config-keys.d.ts +1 -10
  142. package/dist/normalize-config-keys.d.ts.map +1 -1
  143. package/dist/normalize-config-keys.js +7 -73
  144. package/dist/normalize-config-keys.js.map +1 -1
  145. package/dist/object-guards.d.ts +1 -10
  146. package/dist/object-guards.d.ts.map +1 -1
  147. package/dist/object-guards.js +7 -20
  148. package/dist/object-guards.js.map +1 -1
  149. package/dist/ports/config.ports.d.ts +1 -82
  150. package/dist/ports/config.ports.d.ts.map +1 -1
  151. package/dist/ports/config.ports.js +2 -1
  152. package/dist/ports/config.ports.js.map +1 -1
  153. package/dist/ports/dashboard-renderer.port.d.ts +1 -112
  154. package/dist/ports/dashboard-renderer.port.d.ts.map +1 -1
  155. package/dist/ports/dashboard-renderer.port.js +2 -1
  156. package/dist/ports/dashboard-renderer.port.js.map +1 -1
  157. package/dist/ports/git-validator.ports.d.ts +5 -110
  158. package/dist/ports/git-validator.ports.d.ts.map +1 -1
  159. package/dist/ports/git-validator.ports.js +8 -1
  160. package/dist/ports/git-validator.ports.js.map +1 -1
  161. package/dist/ports/sync-validator.ports.d.ts +1 -51
  162. package/dist/ports/sync-validator.ports.d.ts.map +1 -1
  163. package/dist/ports/sync-validator.ports.js +2 -1
  164. package/dist/ports/sync-validator.ports.js.map +1 -1
  165. package/dist/ports/wu-helpers.ports.d.ts +1 -156
  166. package/dist/ports/wu-helpers.ports.d.ts.map +1 -1
  167. package/dist/ports/wu-helpers.ports.js +2 -1
  168. package/dist/ports/wu-helpers.ports.js.map +1 -1
  169. package/dist/ports/wu-state.ports.d.ts +1 -208
  170. package/dist/ports/wu-state.ports.d.ts.map +1 -1
  171. package/dist/ports/wu-state.ports.js +2 -1
  172. package/dist/ports/wu-state.ports.js.map +1 -1
  173. package/dist/rebase-artifact-cleanup.d.ts.map +1 -1
  174. package/dist/rebase-artifact-cleanup.js +6 -3
  175. package/dist/rebase-artifact-cleanup.js.map +1 -1
  176. package/dist/sandbox-allowlist.d.ts +1 -15
  177. package/dist/sandbox-allowlist.d.ts.map +1 -1
  178. package/dist/sandbox-allowlist.js +4 -74
  179. package/dist/sandbox-allowlist.js.map +1 -1
  180. package/dist/sandbox-backend-linux.d.ts +1 -5
  181. package/dist/sandbox-backend-linux.d.ts.map +1 -1
  182. package/dist/sandbox-backend-linux.js +4 -64
  183. package/dist/sandbox-backend-linux.js.map +1 -1
  184. package/dist/sandbox-backend-macos.d.ts +1 -5
  185. package/dist/sandbox-backend-macos.d.ts.map +1 -1
  186. package/dist/sandbox-backend-macos.js +4 -109
  187. package/dist/sandbox-backend-macos.js.map +1 -1
  188. package/dist/sandbox-backend-windows.d.ts +1 -5
  189. package/dist/sandbox-backend-windows.d.ts.map +1 -1
  190. package/dist/sandbox-backend-windows.js +4 -27
  191. package/dist/sandbox-backend-windows.js.map +1 -1
  192. package/dist/sandbox-profile.d.ts +1 -57
  193. package/dist/sandbox-profile.d.ts.map +1 -1
  194. package/dist/sandbox-profile.js +4 -65
  195. package/dist/sandbox-profile.js.map +1 -1
  196. package/dist/schemas/agents-config.d.ts +47 -0
  197. package/dist/schemas/agents-config.d.ts.map +1 -1
  198. package/dist/schemas/agents-config.js +59 -0
  199. package/dist/schemas/agents-config.js.map +1 -1
  200. package/dist/schemas/command-schemas.d.ts +4 -4
  201. package/dist/schemas/flow-arg-validators.d.ts +2 -2
  202. package/dist/schemas/flow-schemas.d.ts +4 -4
  203. package/dist/schemas/gates-section-config.d.ts +32 -13
  204. package/dist/schemas/gates-section-config.d.ts.map +1 -1
  205. package/dist/schemas/gates-section-config.js +16 -1
  206. package/dist/schemas/gates-section-config.js.map +1 -1
  207. package/dist/schemas/initiative-arg-validators.d.ts +2 -2
  208. package/dist/schemas/initiative-schemas.d.ts +12 -12
  209. package/dist/schemas/lanes-config.d.ts +5 -5
  210. package/dist/schemas/memory-arg-validators.d.ts +6 -0
  211. package/dist/schemas/memory-arg-validators.d.ts.map +1 -1
  212. package/dist/schemas/memory-config.d.ts +4 -4
  213. package/dist/schemas/memory-schemas.d.ts +12 -0
  214. package/dist/schemas/memory-schemas.d.ts.map +1 -1
  215. package/dist/schemas/memory-schemas.js +12 -0
  216. package/dist/schemas/memory-schemas.js.map +1 -1
  217. package/dist/schemas/operational-config.d.ts +4 -4
  218. package/dist/schemas/setup-arg-validators.d.ts +3 -3
  219. package/dist/schemas/setup-schemas.d.ts +8 -8
  220. package/dist/schemas/wu-config.d.ts +3 -3
  221. package/dist/schemas/wu-lifecycle-arg-validators.d.ts +2 -2
  222. package/dist/schemas/wu-lifecycle-schemas.d.ts +4 -4
  223. package/dist/section-headings.d.ts +1 -34
  224. package/dist/section-headings.d.ts.map +1 -1
  225. package/dist/section-headings.js +2 -51
  226. package/dist/section-headings.js.map +1 -1
  227. package/dist/spawn-constraints-generator.js +3 -3
  228. package/dist/spawn-constraints-generator.js.map +1 -1
  229. package/dist/spawn-guidance-generators.d.ts +1 -1
  230. package/dist/spawn-guidance-generators.d.ts.map +1 -1
  231. package/dist/spawn-policy-resolver.d.ts +1 -1
  232. package/dist/spawn-policy-resolver.d.ts.map +1 -1
  233. package/dist/spawn-task-builder.d.ts +17 -1
  234. package/dist/spawn-task-builder.d.ts.map +1 -1
  235. package/dist/spawn-task-builder.js +63 -1
  236. package/dist/spawn-task-builder.js.map +1 -1
  237. package/dist/spawn-template-assembler.d.ts +1 -1
  238. package/dist/spawn-template-assembler.d.ts.map +1 -1
  239. package/dist/state-machine.d.ts +1 -9
  240. package/dist/state-machine.d.ts.map +1 -1
  241. package/dist/state-machine.js +2 -86
  242. package/dist/state-machine.js.map +1 -1
  243. package/dist/sync-validator.d.ts.map +1 -1
  244. package/dist/sync-validator.js +15 -12
  245. package/dist/sync-validator.js.map +1 -1
  246. package/dist/telemetry.d.ts.map +1 -1
  247. package/dist/telemetry.js +3 -2
  248. package/dist/telemetry.js.map +1 -1
  249. package/dist/work-classifier.d.ts +1 -102
  250. package/dist/work-classifier.d.ts.map +1 -1
  251. package/dist/work-classifier.js +2 -424
  252. package/dist/work-classifier.js.map +1 -1
  253. package/dist/worktree-symlink.d.ts +2 -2
  254. package/dist/worktree-symlink.d.ts.map +1 -1
  255. package/dist/worktree-symlink.js +37 -12
  256. package/dist/worktree-symlink.js.map +1 -1
  257. package/dist/wu-cli-constants.d.ts +1 -433
  258. package/dist/wu-cli-constants.d.ts.map +1 -1
  259. package/dist/wu-cli-constants.js +4 -436
  260. package/dist/wu-cli-constants.js.map +1 -1
  261. package/dist/wu-consistency-file-repairs.d.ts.map +1 -1
  262. package/dist/wu-consistency-file-repairs.js +5 -3
  263. package/dist/wu-consistency-file-repairs.js.map +1 -1
  264. package/dist/wu-context-constants.d.ts +22 -0
  265. package/dist/wu-context-constants.d.ts.map +1 -1
  266. package/dist/wu-context-constants.js +22 -0
  267. package/dist/wu-context-constants.js.map +1 -1
  268. package/dist/wu-doc-types.d.ts +1 -47
  269. package/dist/wu-doc-types.d.ts.map +1 -1
  270. package/dist/wu-domain-constants.d.ts +1 -295
  271. package/dist/wu-domain-constants.d.ts.map +1 -1
  272. package/dist/wu-domain-constants.js +4 -397
  273. package/dist/wu-domain-constants.js.map +1 -1
  274. package/dist/wu-done-branch-only.d.ts +1 -1
  275. package/dist/wu-done-branch-only.d.ts.map +1 -1
  276. package/dist/wu-done-branch-only.js +22 -13
  277. package/dist/wu-done-branch-only.js.map +1 -1
  278. package/dist/wu-done-branch-utils.d.ts.map +1 -1
  279. package/dist/wu-done-branch-utils.js +5 -3
  280. package/dist/wu-done-branch-utils.js.map +1 -1
  281. package/dist/wu-done-cleanup.d.ts.map +1 -1
  282. package/dist/wu-done-cleanup.js +66 -22
  283. package/dist/wu-done-cleanup.js.map +1 -1
  284. package/dist/wu-done-concurrent-merge.d.ts.map +1 -1
  285. package/dist/wu-done-concurrent-merge.js +9 -6
  286. package/dist/wu-done-concurrent-merge.js.map +1 -1
  287. package/dist/wu-done-errors.d.ts +3 -3
  288. package/dist/wu-done-errors.d.ts.map +1 -1
  289. package/dist/wu-done-inputs.d.ts.map +1 -1
  290. package/dist/wu-done-inputs.js +3 -0
  291. package/dist/wu-done-inputs.js.map +1 -1
  292. package/dist/wu-done-merge-phase.d.ts.map +1 -1
  293. package/dist/wu-done-merge-phase.js +4 -2
  294. package/dist/wu-done-merge-phase.js.map +1 -1
  295. package/dist/wu-done-merge.d.ts.map +1 -1
  296. package/dist/wu-done-merge.js +16 -8
  297. package/dist/wu-done-merge.js.map +1 -1
  298. package/dist/wu-done-merged-worktree.d.ts.map +1 -1
  299. package/dist/wu-done-merged-worktree.js +7 -8
  300. package/dist/wu-done-merged-worktree.js.map +1 -1
  301. package/dist/wu-done-messages.d.ts.map +1 -1
  302. package/dist/wu-done-messages.js +12 -5
  303. package/dist/wu-done-messages.js.map +1 -1
  304. package/dist/wu-done-metadata.d.ts.map +1 -1
  305. package/dist/wu-done-metadata.js +3 -8
  306. package/dist/wu-done-metadata.js.map +1 -1
  307. package/dist/wu-done-preflight-checks.d.ts.map +1 -1
  308. package/dist/wu-done-preflight-checks.js +21 -15
  309. package/dist/wu-done-preflight-checks.js.map +1 -1
  310. package/dist/wu-done-rebase.d.ts.map +1 -1
  311. package/dist/wu-done-rebase.js +10 -8
  312. package/dist/wu-done-rebase.js.map +1 -1
  313. package/dist/wu-done-retry-helpers.d.ts.map +1 -1
  314. package/dist/wu-done-retry-helpers.js +13 -11
  315. package/dist/wu-done-retry-helpers.js.map +1 -1
  316. package/dist/wu-done-validation.d.ts.map +1 -1
  317. package/dist/wu-done-validation.js +4 -2
  318. package/dist/wu-done-validation.js.map +1 -1
  319. package/dist/wu-done-worktree-services.d.ts.map +1 -1
  320. package/dist/wu-done-worktree-services.js +4 -2
  321. package/dist/wu-done-worktree-services.js.map +1 -1
  322. package/dist/wu-done-worktree.d.ts.map +1 -1
  323. package/dist/wu-done-worktree.js +4 -2
  324. package/dist/wu-done-worktree.js.map +1 -1
  325. package/dist/wu-git-constants.d.ts +1 -175
  326. package/dist/wu-git-constants.d.ts.map +1 -1
  327. package/dist/wu-git-constants.js +4 -175
  328. package/dist/wu-git-constants.js.map +1 -1
  329. package/dist/wu-helpers.d.ts +24 -0
  330. package/dist/wu-helpers.d.ts.map +1 -1
  331. package/dist/wu-helpers.js +37 -4
  332. package/dist/wu-helpers.js.map +1 -1
  333. package/dist/wu-id-format.d.ts +1 -137
  334. package/dist/wu-id-format.d.ts.map +1 -1
  335. package/dist/wu-id-format.js +2 -249
  336. package/dist/wu-id-format.js.map +1 -1
  337. package/dist/wu-id-generator.d.ts.map +1 -1
  338. package/dist/wu-id-generator.js +8 -5
  339. package/dist/wu-id-generator.js.map +1 -1
  340. package/dist/wu-paths-constants.d.ts +1 -253
  341. package/dist/wu-paths-constants.d.ts.map +1 -1
  342. package/dist/wu-paths-constants.js +4 -273
  343. package/dist/wu-paths-constants.js.map +1 -1
  344. package/dist/wu-paths.d.ts +1 -274
  345. package/dist/wu-paths.d.ts.map +1 -1
  346. package/dist/wu-paths.js +4 -236
  347. package/dist/wu-paths.js.map +1 -1
  348. package/dist/wu-rules-resolvers.d.ts.map +1 -1
  349. package/dist/wu-rules-resolvers.js +11 -6
  350. package/dist/wu-rules-resolvers.js.map +1 -1
  351. package/dist/wu-schema.d.ts +1 -830
  352. package/dist/wu-schema.d.ts.map +1 -1
  353. package/dist/wu-schema.js +4 -929
  354. package/dist/wu-schema.js.map +1 -1
  355. package/dist/wu-spawn-helpers.d.ts.map +1 -1
  356. package/dist/wu-spawn-helpers.js +5 -2
  357. package/dist/wu-spawn-helpers.js.map +1 -1
  358. package/dist/wu-spawn.d.ts +2 -2
  359. package/dist/wu-spawn.d.ts.map +1 -1
  360. package/dist/wu-spawn.js +2 -2
  361. package/dist/wu-spawn.js.map +1 -1
  362. package/dist/wu-state-schema.d.ts +1 -291
  363. package/dist/wu-state-schema.d.ts.map +1 -1
  364. package/dist/wu-state-schema.js +4 -212
  365. package/dist/wu-state-schema.js.map +1 -1
  366. package/dist/wu-status-transition.d.ts +3 -1
  367. package/dist/wu-status-transition.d.ts.map +1 -1
  368. package/dist/wu-status-transition.js +9 -24
  369. package/dist/wu-status-transition.js.map +1 -1
  370. package/dist/wu-statuses.d.ts +1 -208
  371. package/dist/wu-statuses.d.ts.map +1 -1
  372. package/dist/wu-statuses.js +4 -242
  373. package/dist/wu-statuses.js.map +1 -1
  374. package/dist/wu-transaction-collectors.d.ts +1 -0
  375. package/dist/wu-transaction-collectors.d.ts.map +1 -1
  376. package/dist/wu-transaction-collectors.js +13 -8
  377. package/dist/wu-transaction-collectors.js.map +1 -1
  378. package/dist/wu-type-helpers.d.ts +1 -27
  379. package/dist/wu-type-helpers.d.ts.map +1 -1
  380. package/dist/wu-type-helpers.js +4 -46
  381. package/dist/wu-type-helpers.js.map +1 -1
  382. package/dist/wu-ui-constants.d.ts +1 -235
  383. package/dist/wu-ui-constants.d.ts.map +1 -1
  384. package/dist/wu-ui-constants.js +5 -235
  385. package/dist/wu-ui-constants.js.map +1 -1
  386. package/dist/wu-validation-constants.d.ts +1 -60
  387. package/dist/wu-validation-constants.d.ts.map +1 -1
  388. package/dist/wu-validation-constants.js +4 -66
  389. package/dist/wu-validation-constants.js.map +1 -1
  390. package/dist/wu-yaml.d.ts +1 -112
  391. package/dist/wu-yaml.d.ts.map +1 -1
  392. package/dist/wu-yaml.js +4 -304
  393. package/dist/wu-yaml.js.map +1 -1
  394. package/package.json +12 -9
  395. package/dist/coverage-gate.d.ts +0 -128
  396. package/dist/coverage-gate.d.ts.map +0 -1
  397. package/dist/coverage-gate.js +0 -211
  398. package/dist/coverage-gate.js.map +0 -1
  399. package/dist/gates-agent-mode.d.ts +0 -108
  400. package/dist/gates-agent-mode.d.ts.map +0 -1
  401. package/dist/gates-agent-mode.js +0 -138
  402. package/dist/gates-agent-mode.js.map +0 -1
  403. package/dist/gates-config-internal.d.ts +0 -54
  404. package/dist/gates-config-internal.d.ts.map +0 -1
  405. package/dist/gates-config-internal.js +0 -107
  406. package/dist/gates-config-internal.js.map +0 -1
  407. package/dist/gates-config.d.ts +0 -68
  408. package/dist/gates-config.d.ts.map +0 -1
  409. package/dist/gates-config.js +0 -193
  410. package/dist/gates-config.js.map +0 -1
  411. package/dist/gates-coverage.d.ts +0 -42
  412. package/dist/gates-coverage.d.ts.map +0 -1
  413. package/dist/gates-coverage.js +0 -162
  414. package/dist/gates-coverage.js.map +0 -1
  415. package/dist/gates-presets.d.ts +0 -52
  416. package/dist/gates-presets.d.ts.map +0 -1
  417. package/dist/gates-presets.js +0 -117
  418. package/dist/gates-presets.js.map +0 -1
  419. package/dist/gates-schemas.d.ts +0 -143
  420. package/dist/gates-schemas.d.ts.map +0 -1
  421. package/dist/gates-schemas.js +0 -67
  422. package/dist/gates-schemas.js.map +0 -1
  423. package/dist/package-manager-resolver.d.ts +0 -80
  424. package/dist/package-manager-resolver.d.ts.map +0 -1
  425. package/dist/package-manager-resolver.js +0 -245
  426. package/dist/package-manager-resolver.js.map +0 -1
  427. package/dist/resolve-policy.d.ts +0 -293
  428. package/dist/resolve-policy.d.ts.map +0 -1
  429. package/dist/resolve-policy.js +0 -303
  430. package/dist/resolve-policy.js.map +0 -1
package/dist/wu-schema.js CHANGED
@@ -1,932 +1,7 @@
1
1
  // Copyright (c) 2026 Hellmai Ltd
2
2
  // SPDX-License-Identifier: AGPL-3.0-only
3
- /**
4
- * Work Unit YAML Schema
5
- *
6
- * Zod schema for runtime validation of WU YAML structure.
7
- * Provides compile-time type inference and semantic validation.
8
- *
9
- * Part of WU-1162: Add Zod schema validation to prevent placeholder WU completions
10
- * Part of WU-1539: Add BaseWUSchema pattern for create/edit validation
11
- *
12
- * Schema Architecture (DRY pattern):
13
- * - BaseWUSchema: Structural validation only (field types, formats, lengths)
14
- * - WUSchema: Extends base + placeholder rejection (for wu:claim, wu:done)
15
- * - ReadyWUSchema: Alias for BaseWUSchema (for wu:create, wu:edit)
16
- *
17
- * @see {@link packages/@lumenflow/cli/src/wu-done.ts} - Consumer (validates spec completeness, uses WUSchema)
18
- * @see {@link packages/@lumenflow/cli/src/wu-claim.ts} - Consumer (validates spec completeness, uses WUSchema)
19
- * @see {@link packages/@lumenflow/cli/src/wu-create.ts} - Consumer (structural validation, uses ReadyWUSchema)
20
- * @see {@link packages/@lumenflow/cli/src/wu-edit.ts} - Consumer (structural validation, uses ReadyWUSchema)
21
- * @see {@link packages/@lumenflow/cli/src/validate.ts} - Consumer (CI validation)
22
- * @see {@link apps/web/src/lib/llm/schemas/orchestrator.ts} - Pattern reference
23
- */
24
- import { z } from 'zod';
25
- import { WU_STATUS_GROUPS, WU_DEFAULTS, STRING_LITERALS, WU_EXPOSURE_VALUES, WU_TYPES, WU_TYPE_VALUES, } from './wu-constants.js';
26
- import { createWuPaths } from './wu-paths.js';
27
- import { normalizeISODateTime } from './date-utils.js';
28
- import { isDocsOrProcessType, isWUType } from './wu-type-helpers.js';
29
- // WU-2225: getConfig import removed (getEscalationEmail was the only consumer)
30
- /**
31
- * Valid WU status values derived from WU_STATUS constant (DRY principle)
32
- * Used for Zod enum validation with improved error messages
33
- * Note: Defined as tuple for Zod enum compatibility
34
- */
35
- const VALID_STATUSES = [
36
- 'todo',
37
- 'ready',
38
- 'backlog',
39
- 'in_progress',
40
- 'blocked',
41
- 'done',
42
- 'completed',
43
- 'cancelled',
44
- 'abandoned',
45
- 'deferred',
46
- 'closed',
47
- 'superseded',
48
- ];
49
- /**
50
- * Placeholder sentinel constant
51
- *
52
- * Used in wu:create template generation and validation.
53
- * Single source of truth for placeholder detection (DRY principle).
54
- *
55
- * @example
56
- * // tools/wu-create.ts
57
- * description: `${PLACEHOLDER_SENTINEL} Describe the work...`
58
- *
59
- * @example
60
- * // tools/validate.ts
61
- * if (doc.description.includes(PLACEHOLDER_SENTINEL)) { error(); }
62
- */
63
- export const PLACEHOLDER_SENTINEL = '[PLACEHOLDER]';
64
- /**
65
- * Minimum description length requirement
66
- * Stored as constant for DRY error message generation
67
- */
68
- const MIN_DESCRIPTION_LENGTH = 50;
69
- /**
70
- * WU ID format validation message (DRY principle)
71
- * Used across blocks, blocked_by, and ui_pairing_wus fields
72
- */
73
- const WU_ID_FORMAT_MESSAGE = 'Must be WU-XXX format';
74
- /**
75
- * Acceptance criterion error message
76
- * Stored as constant for DRY error message generation (sonarjs/no-duplicate-string)
77
- */
78
- const ACCEPTANCE_REQUIRED_MSG = 'At least one acceptance criterion required';
79
- const CONTEXT_REQUIRED_TYPES = [WU_TYPES.FEATURE, WU_TYPES.BUG, WU_TYPES.REFACTOR];
80
- // =============================================================================
81
- // WU-1750: NORMALIZATION TRANSFORMS (Watertight YAML validation)
82
- // =============================================================================
83
- /**
84
- * Regex pattern matching embedded newlines (both literal and escaped)
85
- * Handles: "a\nb" (literal newline) and "a\\nb" (escaped backslash-n)
86
- */
87
- const NEWLINE_PATTERN = /\\n|\n/;
88
- /**
89
- * Transform: Normalize string arrays by splitting embedded newlines
90
- *
91
- * WU-1750: Agents sometimes pass multi-item content as single strings with \n.
92
- * This transform auto-repairs: ["a\nb\nc"] → ["a", "b", "c"]
93
- *
94
- * @example
95
- * // Input: ["tools/a.ts\ntools/b.js"]
96
- * // Output: ["tools/a.js", "tools/b.js"]
97
- */
98
- const normalizedStringArray = z.array(z.string()).transform((arr) => arr
99
- .flatMap((s) => s.split(NEWLINE_PATTERN))
100
- .map((s) => s.trim())
101
- .filter(Boolean));
102
- /**
103
- * Transform: Normalize description/notes strings by converting escaped newlines
104
- *
105
- * WU-1750: YAML quoted strings preserve literal \\n as two characters.
106
- * This transform converts them to actual newlines: "a\\n\\nb" → "a\n\nb"
107
- *
108
- * @example
109
- * // Input: "Problem:\\n\\n1. First issue"
110
- * // Output: "Problem:\n\n1. First issue"
111
- */
112
- const _normalizedMultilineString = z.string().transform((s) => s.replace(/\\n/g, '\n'));
113
- /**
114
- * Refinement: File path cannot contain newlines (post-normalization safety check)
115
- *
116
- * WU-1750: After normalization, paths should be clean. This catches UnsafeAny edge cases.
117
- */
118
- const filePathItem = z.string().refine((s) => !s.includes('\n') && !s.includes('\\n'), {
119
- message: 'File path cannot contain newlines - split into separate array items',
120
- });
121
- /**
122
- * Normalized code_paths: split embedded newlines + validate each path
123
- */
124
- const normalizedCodePaths = normalizedStringArray.pipe(z.array(filePathItem)).default([]);
125
- /**
126
- * Normalized test paths object: all test arrays normalized
127
- */
128
- const normalizedTestPaths = z
129
- .object({
130
- manual: normalizedStringArray.optional(),
131
- unit: normalizedStringArray.optional(),
132
- integration: normalizedStringArray.optional(),
133
- e2e: normalizedStringArray.optional(),
134
- })
135
- .optional();
136
- // =============================================================================
137
- // BASE FIELD DEFINITIONS (DRY - shared between BaseWUSchema and WUSchema)
138
- // =============================================================================
139
- /**
140
- * Base description field (structural validation only)
141
- * WU-1539: Fixed template string bug (single quotes → function message)
142
- * WU-1750: Added normalization of escaped newlines (\\n → actual newlines)
143
- */
144
- const baseDescriptionField = z
145
- .string()
146
- .min(1, 'Description is required')
147
- .transform((s) => s.replace(/\\n/g, '\n')) // WU-1750: Normalize escaped newlines
148
- .refine((val) => val.trim().length >= MIN_DESCRIPTION_LENGTH, {
149
- // WU-1539 fix: Use function message for dynamic interpolation
150
- message: `Description must be at least ${MIN_DESCRIPTION_LENGTH} characters`,
151
- });
152
- /**
153
- * Strict description field (with placeholder rejection)
154
- * Used by wu:claim and wu:done to ensure placeholders are filled
155
- * WU-1750: Added normalization of escaped newlines (\\n → actual newlines)
156
- */
157
- const strictDescriptionField = z
158
- .string()
159
- .min(1, 'Description is required')
160
- .transform((s) => s.replace(/\\n/g, '\n')) // WU-1750: Normalize escaped newlines
161
- .refine((val) => !val.includes(PLACEHOLDER_SENTINEL), {
162
- message: `Description cannot contain ${PLACEHOLDER_SENTINEL} marker`,
163
- })
164
- .refine((val) => val.trim().length >= MIN_DESCRIPTION_LENGTH, {
165
- // WU-1539 fix: Use function message for dynamic interpolation
166
- message: `Description must be at least ${MIN_DESCRIPTION_LENGTH} characters`,
167
- });
168
- /**
169
- * Recursive helper: Check all nested values for at least one item
170
- * Shared between base and strict acceptance schemas
171
- */
172
- const hasItems = (value) => {
173
- if (Array.isArray(value)) {
174
- return value.length > 0;
175
- }
176
- if (typeof value === 'object' && value !== null) {
177
- return Object.values(value).some(hasItems);
178
- }
179
- return false;
180
- };
181
- /**
182
- * Recursive helper: Check all strings for PLACEHOLDER_SENTINEL
183
- * Used only by strict acceptance schema
184
- */
185
- const checkStringsForPlaceholder = (value) => {
186
- if (typeof value === 'string') {
187
- return !value.includes(PLACEHOLDER_SENTINEL);
188
- }
189
- if (Array.isArray(value)) {
190
- return value.every(checkStringsForPlaceholder);
191
- }
192
- if (typeof value === 'object' && value !== null) {
193
- return Object.values(value).every(checkStringsForPlaceholder);
194
- }
195
- return true;
196
- };
197
- /**
198
- * Base acceptance field (structural validation only)
199
- * Validates format but allows placeholder markers
200
- * WU-1750: Added normalization of embedded newlines in array items
201
- */
202
- const baseAcceptanceField = z.union([
203
- // Flat array format (legacy): acceptance: ["item1", "item2"]
204
- // WU-1750: Normalize embedded newlines: ["1. a\n2. b"] → ["1. a", "2. b"]
205
- normalizedStringArray.pipe(z.array(z.string()).min(1, ACCEPTANCE_REQUIRED_MSG)),
206
- // Nested object format (structured): acceptance: { category1: ["item1"], category2: ["item2"] }
207
- z.record(z.string(), normalizedStringArray).refine((obj) => Object.values(obj).some(hasItems), {
208
- message: ACCEPTANCE_REQUIRED_MSG,
209
- }),
210
- ]);
211
- /**
212
- * Strict acceptance field (with placeholder rejection)
213
- * Used by wu:claim and wu:done to ensure placeholders are filled
214
- * WU-1750: Added normalization of embedded newlines in array items
215
- */
216
- const strictAcceptanceField = z.union([
217
- // Flat array format (legacy): acceptance: ["item1", "item2"]
218
- // WU-1750: Normalize embedded newlines: ["1. a\n2. b"] → ["1. a", "2. b"]
219
- normalizedStringArray
220
- .pipe(z.array(z.string()).min(1, ACCEPTANCE_REQUIRED_MSG))
221
- .refine((arr) => !arr.some((item) => item.includes(PLACEHOLDER_SENTINEL)), {
222
- message: `Acceptance criteria cannot contain ${PLACEHOLDER_SENTINEL} markers`,
223
- }),
224
- // Nested object format (structured): acceptance: { category1: ["item1"], category2: ["item2"] }
225
- z
226
- .record(z.string(), normalizedStringArray)
227
- .refine((obj) => Object.values(obj).some(hasItems), {
228
- message: ACCEPTANCE_REQUIRED_MSG,
229
- })
230
- .refine((obj) => checkStringsForPlaceholder(obj), {
231
- message: `Acceptance criteria cannot contain ${PLACEHOLDER_SENTINEL} markers`,
232
- }),
233
- ]);
234
- /**
235
- * Shared field definitions (same for both base and strict schemas)
236
- * DRY: Defined once, used in both schema variants
237
- */
238
- const sharedFields = {
239
- /** WU identifier (e.g., WU-1162) */
240
- id: z.string().regex(/^WU-\d+$/, 'ID must match pattern WU-XXX'),
241
- /** Short title describing the work */
242
- title: z.string().min(1, 'Title is required'),
243
- /** Lane assignment (parent or sub-lane) */
244
- lane: z.string().min(1, 'Lane is required'),
245
- /** Work type classification */
246
- type: z
247
- .enum(WU_TYPE_VALUES, {
248
- error: `Invalid type. Valid values: ${WU_TYPE_VALUES.join(', ')}`,
249
- })
250
- .default(WU_DEFAULTS.type),
251
- /** Current status in workflow */
252
- status: z
253
- .enum(VALID_STATUSES, {
254
- error: `Invalid status. Valid values: ${VALID_STATUSES.join(', ')}`,
255
- })
256
- .default(WU_DEFAULTS.status),
257
- /** Priority level */
258
- priority: z
259
- .enum(['P0', 'P1', 'P2', 'P3'], {
260
- error: 'Invalid priority',
261
- })
262
- .default(WU_DEFAULTS.priority),
263
- /** Creation date (YYYY-MM-DD) */
264
- created: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, 'Created must be YYYY-MM-DD'),
265
- /** Files modified by this WU - WU-1750: Normalized to split embedded newlines */
266
- code_paths: normalizedCodePaths,
267
- /** Test specifications - WU-1750: All test arrays normalized */
268
- tests: normalizedTestPaths.default(WU_DEFAULTS.tests),
269
- /** Output artifacts (stamps, docs, etc.) - WU-1750: Normalized */
270
- artifacts: normalizedStringArray.optional().default(WU_DEFAULTS.artifacts),
271
- /** Upstream WU dependencies (informational, legacy field) - WU-1750: Normalized */
272
- dependencies: normalizedStringArray.optional().default(WU_DEFAULTS.dependencies),
273
- // === Initiative System Fields (WU-1246) ===
274
- /** Parent initiative reference (format: INIT-{number} or slug) */
275
- initiative: z.string().optional(),
276
- /** Phase number within parent initiative */
277
- phase: z.number().int().positive().optional(),
278
- /** WU IDs that this WU blocks (downstream dependencies) - WU-1750: Normalized + validated */
279
- blocks: normalizedStringArray
280
- .pipe(z.array(z.string().regex(/^WU-\d+$/, WU_ID_FORMAT_MESSAGE)))
281
- .optional(),
282
- /** WU IDs that block this WU (upstream dependencies) - WU-1750: Normalized + validated */
283
- blocked_by: normalizedStringArray
284
- .pipe(z.array(z.string().regex(/^WU-\d+$/, WU_ID_FORMAT_MESSAGE)))
285
- .optional(),
286
- /** Cross-cutting tags (orthogonal to initiative) - WU-1750: Normalized */
287
- labels: normalizedStringArray.optional(),
288
- // === End Initiative System Fields ===
289
- /**
290
- * WU-1683: First-class plan field, symmetric with initiative `related_plan`.
291
- * Set via wu:create --plan, wu:edit --plan, or plan:link --id WU-XXX.
292
- */
293
- plan: z.string().optional(),
294
- /**
295
- * WU-1833: References to plans, design docs, external specifications
296
- * WU-1834: Supports both flat string array AND nested object format for backwards compatibility
297
- *
298
- * Flat format (WU-1833+): ['docs/plans/WU-XXX-plan.md']
299
- * Nested format (legacy): [{file: 'docs/path.md', section: 'heading'}]
300
- * Mixed format allowed: ['path.md', {section: 'heading'}]
301
- * Bare object (WU-428): {file: 'docs/path.md', section: 'heading'}
302
- */
303
- spec_refs: z
304
- .union([
305
- // Single object format (WU-428 style): {file: '...', section: '...'}
306
- z.object({
307
- file: z.string().optional(),
308
- section: z.string(),
309
- }),
310
- // Array format (WU-1833+): strings, objects, or mixed
311
- z.array(z.union([
312
- z.string(), // Flat format: 'docs/path.md'
313
- z.object({
314
- // Nested format: {file: 'path', section: 'heading'}
315
- file: z.string().optional(),
316
- section: z.string(),
317
- }),
318
- ])),
319
- ])
320
- .optional(),
321
- /** Known risks or constraints - WU-1750: Normalized */
322
- risks: normalizedStringArray.optional().default(WU_DEFAULTS.risks),
323
- /**
324
- * Free-form notes - supports string or array (auto-converted to string)
325
- * WU-1750: Normalizes escaped newlines (\\n → actual newlines)
326
- */
327
- notes: z
328
- .union([
329
- z.string(),
330
- z.array(z.string()), // Legacy array format - will be converted
331
- ])
332
- .optional()
333
- .transform((val) => {
334
- // Convert array to newline-joined string (legacy format)
335
- if (Array.isArray(val)) {
336
- return val.filter((s) => s.trim().length > 0).join(STRING_LITERALS.NEWLINE);
337
- }
338
- // WU-1750: Normalize escaped newlines in string format
339
- if (typeof val === 'string') {
340
- return val.replace(/\\n/g, '\n');
341
- }
342
- return val ?? WU_DEFAULTS.notes;
343
- }),
344
- /** Requires human review before merge */
345
- requires_review: z.boolean().optional().default(WU_DEFAULTS.requires_review),
346
- /** Locked state (done WUs only) */
347
- locked: z.boolean().optional(),
348
- /** Completion date (done WUs only) - auto-normalized to ISO datetime */
349
- completed_at: z
350
- .string()
351
- .optional()
352
- .transform((val) => normalizeISODateTime(val)),
353
- /** Claimed mode (worktree/branch-only/worktree-pr/branch-pr) */
354
- claimed_mode: z.enum(['worktree', 'branch-only', 'worktree-pr', 'branch-pr']).optional(),
355
- /**
356
- * WU-1589: Canonical branch name for this WU claim.
357
- *
358
- * Set at claim time to record the actual branch used.
359
- * Used by defaultBranchFrom() as highest-priority source for branch resolution.
360
- * Essential for branch-pr mode where cloud agents may use non-lane-derived branch names.
361
- * Cleared on rollback/release/recover when resetting to ready.
362
- */
363
- claimed_branch: z.string().optional(),
364
- /** Assigned agent email */
365
- assigned_to: z.string().email().optional(),
366
- /** Claim timestamp - auto-normalized to ISO datetime */
367
- claimed_at: z
368
- .string()
369
- .optional()
370
- .transform((val) => normalizeISODateTime(val)),
371
- /** Block reason (blocked WUs only) */
372
- blocked_reason: z.string().optional(),
373
- /** Worktree path (claimed WUs only) */
374
- worktree_path: z.string().optional(),
375
- /** Current active session ID (WU-1438: auto-set on claim, cleared on done) */
376
- session_id: z.string().uuid().optional(),
377
- /** Agent sessions (issue logging metadata, WU-1231) */
378
- agent_sessions: z
379
- .array(z.object({
380
- session_id: z.string().uuid(),
381
- started: z.string().datetime(),
382
- completed: z.string().datetime().optional(),
383
- agent_type: z.enum([
384
- 'claude-code',
385
- 'codex-cli',
386
- 'cursor',
387
- 'gemini-cli',
388
- 'windsurf',
389
- 'copilot',
390
- 'other',
391
- ]),
392
- context_tier: z.union([z.literal(1), z.literal(2), z.literal(3)]),
393
- incidents_logged: z.number().int().min(0).default(0),
394
- incidents_major: z.number().int().min(0).default(0),
395
- artifacts: z.array(z.string()).optional(),
396
- }))
397
- .optional(),
398
- // === Exposure System Fields (WU-1998) ===
399
- /**
400
- * WU-1998: Exposure level - defines how the WU exposes functionality to users
401
- *
402
- * Valid values:
403
- * - 'ui': User-facing UI changes (pages, components, widgets)
404
- * - 'api': API endpoints called by UI or external clients
405
- * - 'backend-only': Backend-only changes (no user visibility)
406
- * - 'documentation': Documentation changes only
407
- *
408
- * Optional during transition period, will become required after backlog update.
409
- */
410
- exposure: z
411
- .enum(WU_EXPOSURE_VALUES, {
412
- error: `Invalid exposure value. Valid values: ${WU_EXPOSURE_VALUES.join(', ')}`,
413
- })
414
- .optional(),
415
- /**
416
- * WU-1998: User journey description for user-facing WUs
417
- *
418
- * Recommended for exposure: 'ui' and 'api'.
419
- * Describes the end-user interaction flow affected by this WU.
420
- */
421
- user_journey: z.string().optional(),
422
- /**
423
- * WU-1998: Related UI WUs for backend/API changes
424
- *
425
- * For WUs with exposure: 'api', this field lists UI WUs that consume the API.
426
- * Ensures backend features have corresponding UI coverage.
427
- * Each entry must match WU-XXX format.
428
- */
429
- ui_pairing_wus: normalizedStringArray
430
- .pipe(z.array(z.string().regex(/^WU-\d+$/, WU_ID_FORMAT_MESSAGE)))
431
- .optional(),
432
- /**
433
- * WU-2022: Navigation path for UI-exposed features
434
- *
435
- * For WUs with exposure: 'ui', specifies the route where the feature is accessible.
436
- * Used by wu:done to verify that UI features are actually navigable.
437
- * Prevents "orphaned code" where features exist but users cannot access them.
438
- *
439
- * Example: '/dashboard', '/settings/preferences', '/space'
440
- */
441
- navigation_path: z.string().optional(),
442
- // === End Exposure System Fields ===
443
- // === Sizing Estimate Fields (WU-2141) ===
444
- /**
445
- * WU-2141: Optional sizing estimate metadata.
446
- *
447
- * Records expected WU complexity for tooling-backed sizing enforcement.
448
- * Absent for historical WUs (backward compatible).
449
- *
450
- * Fields:
451
- * - estimated_files: Expected number of files to modify
452
- * - estimated_tool_calls: Expected tool call count
453
- * - strategy: Execution strategy from wu-sizing-guide.md
454
- * - exception_type: Override type when thresholds intentionally exceeded
455
- * - exception_reason: Justification for the exception (required with exception_type)
456
- */
457
- sizing_estimate: z
458
- .object({
459
- estimated_files: z.number().int().min(0),
460
- estimated_tool_calls: z.number().int().min(0),
461
- strategy: z.enum([
462
- 'single-session',
463
- 'checkpoint-resume',
464
- 'orchestrator-worker',
465
- 'decomposition',
466
- ]),
467
- exception_type: z.enum(['docs-only', 'shallow-multi-file']).optional(),
468
- exception_reason: z.string().optional(),
469
- })
470
- .refine((data) => {
471
- if (data.exception_type !== undefined) {
472
- return data.exception_reason !== undefined && data.exception_reason.trim().length > 0;
473
- }
474
- return true;
475
- }, {
476
- message: 'sizing_estimate.exception_reason is required and must be non-empty when exception_type is set',
477
- path: ['exception_reason'],
478
- })
479
- .optional(),
480
- // === End Sizing Estimate Fields ===
481
- // === Agent-First Approval Fields (WU-2079 → WU-2080) ===
482
- /**
483
- * WU-2080: Escalation triggers detected for this WU
484
- *
485
- * Agent-first model: agents auto-approve by default.
486
- * Human escalation only when these triggers are detected:
487
- * - sensitive_data: Changes to sensitive data handling
488
- * - security_p0: P0 security incident or vulnerability
489
- * - budget: Budget/resource allocation above threshold
490
- * - cross_lane_arch: Cross-lane architectural decision
491
- *
492
- * Empty array = no escalation needed, agent proceeds autonomously.
493
- */
494
- escalation_triggers: z
495
- .array(z.enum(['sensitive_data', 'security_p0', 'budget', 'cross_lane_arch']))
496
- .optional()
497
- .default([]),
498
- /**
499
- * WU-2080: Human escalation required flag
500
- *
501
- * Auto-set to true when escalation_triggers is non-empty.
502
- * When true, wu:done requires human confirmation before completion.
503
- */
504
- requires_human_escalation: z.boolean().optional().default(false),
505
- /**
506
- * WU-2080: Email(s) of approvers who signed off
507
- *
508
- * Auto-populated with claiming agent at wu:claim.
509
- * Additional human approvers added when escalation is resolved.
510
- */
511
- approved_by: z.array(z.string().email()).optional(),
512
- /**
513
- * WU-2080: Timestamp when approval was granted
514
- *
515
- * Auto-set at wu:claim for agent auto-approval.
516
- * Updated when human escalation is resolved.
517
- */
518
- approved_at: z
519
- .string()
520
- .optional()
521
- .transform((val) => normalizeISODateTime(val)),
522
- /**
523
- * WU-2080: Human who resolved escalation (if UnsafeAny)
524
- *
525
- * Only set when requires_human_escalation was true and resolved.
526
- */
527
- escalation_resolved_by: z.string().email().optional(),
528
- /**
529
- * WU-2080: Timestamp when human resolved escalation
530
- */
531
- escalation_resolved_at: z
532
- .string()
533
- .optional()
534
- .transform((val) => normalizeISODateTime(val)),
535
- // Legacy fields (deprecated, kept for backwards compatibility)
536
- /** @deprecated Use escalation_triggers instead */
537
- requires_cso_approval: z.boolean().optional().default(false),
538
- /** @deprecated Use escalation_triggers instead */
539
- requires_cto_approval: z.boolean().optional().default(false),
540
- /** @deprecated Use escalation_triggers instead */
541
- requires_design_approval: z.boolean().optional().default(false),
542
- // === End Agent-First Approval Fields ===
543
- };
544
- // =============================================================================
545
- // SCHEMA DEFINITIONS
546
- // =============================================================================
547
- /**
548
- * Base WU Schema (structural validation only)
549
- *
550
- * WU-1539: Used by wu:create and wu:edit for fail-fast structural validation.
551
- * Allows placeholder markers - only checks field types, formats, and lengths.
552
- *
553
- * Use case: Validate WU structure at creation/edit time before placeholders are filled.
554
- */
555
- export const BaseWUSchema = z.object({
556
- ...sharedFields,
557
- description: baseDescriptionField,
558
- acceptance: baseAcceptanceField,
559
- });
560
- /**
561
- * Ready WU Schema (alias for BaseWUSchema)
562
- *
563
- * WU-1539: Semantic alias for clarity in wu:create and wu:edit.
564
- * Same validation as BaseWUSchema - allows placeholders, enforces structure.
565
- */
566
- export const ReadyWUSchema = BaseWUSchema;
567
- /**
568
- * Strict WU Schema (structural + placeholder rejection)
569
- *
570
- * Validates WU files against LumenFlow requirements:
571
- * - No placeholder text in done WUs
572
- * - Minimum description length (50 chars)
573
- * - Code paths present for non-documentation WUs
574
- * - Proper status/lane/type enums
575
- *
576
- * Used by wu:claim and wu:done to ensure specs are complete.
577
- * Provides runtime validation and TypeScript type inference.
578
- */
579
- export const WUSchema = z.object({
580
- ...sharedFields,
581
- description: strictDescriptionField,
582
- acceptance: strictAcceptanceField,
583
- });
584
- /**
585
- * TypeScript type inferred from schema
586
- *
587
- * Single source of truth for both runtime validation and compile-time types.
588
- * Replaces manual WU interfaces (DRY principle).
589
- *
590
- * Note: Type inference available in TypeScript via z.infer<typeof WUSchema>
591
- * This is a JavaScript file, so the type export is not needed here.
592
- *
593
- * @typedef {import('zod').z.infer<typeof WUSchema>} WU
594
- */
595
- /**
596
- * Validates WU data against strict schema (placeholder rejection)
597
- *
598
- * Used by wu:claim and wu:done to ensure specs are complete.
599
- * Rejects WUs with placeholder markers.
600
- *
601
- * @param {unknown} data - Parsed YAML data to validate
602
- * @returns {z.SafeParseReturnType<WU, WU>} Validation result
603
- *
604
- * @example
605
- * const result = validateWU(yamlData);
606
- * if (!result.success) {
607
- * result.error.issues.forEach(issue => {
608
- * console.error(`${issue.path.join('.')}: ${issue.message}`);
609
- * });
610
- * }
611
- */
612
- export function validateWU(data) {
613
- return WUSchema.safeParse(data);
614
- }
615
- /**
616
- * Validates WU data against base schema (structural only)
617
- *
618
- * WU-1539: Used by wu:create and wu:edit for fail-fast structural validation.
619
- * Allows placeholder markers - only checks field types, formats, and lengths.
620
- *
621
- * @param {unknown} data - Parsed YAML data to validate
622
- * @returns {z.SafeParseReturnType<WU, WU>} Validation result
623
- *
624
- * @example
625
- * const result = validateReadyWU(yamlData);
626
- * if (!result.success) {
627
- * const errors = result.error.issues
628
- * .map(issue => ` • ${issue.path.join('.')}: ${issue.message}`)
629
- * .join('\n');
630
- * die(`WU YAML validation failed:\n\n${errors}`);
631
- * }
632
- */
633
- export function validateReadyWU(data) {
634
- return ReadyWUSchema.safeParse(data);
635
- }
636
- /**
637
- * Validates WU spec completeness for done status
638
- *
639
- * Additional validation beyond schema for WUs marked as done:
640
- * - Code paths required for non-documentation WUs
641
- * - Locked must be true
642
- * - Completed timestamp must be present
643
- *
644
- * @param {WU} wu - Validated WU data
645
- * @returns {{valid: boolean, errors: string[]}} Validation result
646
- *
647
- * @example
648
- * const schemaResult = validateWU(data);
649
- * if (schemaResult.success && data.status === 'done') {
650
- * const completenessResult = validateDoneWU(schemaResult.data);
651
- * if (!completenessResult.valid) {
652
- * console.error(completenessResult.errors);
653
- * }
654
- * }
655
- */
656
- export function validateDoneWU(wu) {
657
- const errors = [];
658
- // Check code_paths for non-documentation WUs
659
- if (!isDocsOrProcessType(wu.type)) {
660
- if (!wu.code_paths || wu.code_paths.length === 0) {
661
- errors.push('Code paths required for non-documentation WUs');
662
- }
663
- }
664
- // Note: locked and completed_at are set automatically by wu:done
665
- // No need to validate them here (they don't exist yet at validation time)
666
- return {
667
- valid: errors.length === 0,
668
- errors,
669
- };
670
- }
671
- /**
672
- * WU-2080: Valid escalation trigger types
673
- *
674
- * These are the only conditions that require human intervention.
675
- * Everything else is auto-approved by agents.
676
- */
677
- export const ESCALATION_TRIGGER_TYPES = [
678
- 'sensitive_data', // Sensitive data handling changes
679
- 'security_p0', // P0 security incident
680
- 'budget', // Budget/resource above threshold
681
- 'cross_lane_arch', // Cross-lane architectural decision
682
- ];
683
- /**
684
- * WU-2080: Agent-first approval validation
685
- *
686
- * AGENT-FIRST MODEL: Agents auto-approve by default.
687
- * Human escalation only when escalation_triggers is non-empty
688
- * AND requires_human_escalation is true AND not yet resolved.
689
- *
690
- * Returns:
691
- * - valid: true if agent can proceed (no unresolved escalation)
692
- * - errors: blocking issues requiring human resolution
693
- * - warnings: advisory messages (non-blocking)
694
- *
695
- * @param {object} wu - Validated WU data
696
- * @returns {{valid: boolean, errors: string[], warnings: string[]}}
697
- */
698
- export function validateApprovalGates(wu) {
699
- const errors = [];
700
- const warnings = [];
701
- // Agent-first: check for unresolved escalation triggers
702
- const triggers = wu.escalation_triggers || [];
703
- const requiresEscalation = wu.requires_human_escalation || triggers.length > 0;
704
- if (requiresEscalation) {
705
- // Check if escalation was resolved by human
706
- const resolved = wu.escalation_resolved_by && wu.escalation_resolved_at;
707
- if (!resolved) {
708
- errors.push(`Human escalation required for: ${triggers.join(', ')}\n` +
709
- ` To resolve: pnpm wu:escalate --resolve --id ${wu.id}`);
710
- }
711
- }
712
- // Legacy backwards compatibility: map old fields to new model
713
- if (wu.requires_cso_approval || wu.requires_cto_approval || wu.requires_design_approval) {
714
- warnings.push('Using deprecated requires_X_approval fields. Migrate to escalation_triggers model.');
715
- }
716
- return {
717
- valid: errors.length === 0,
718
- errors,
719
- warnings,
720
- };
721
- }
722
- /**
723
- * WU-2080: Detect escalation triggers from WU content
724
- *
725
- * Analyzes WU metadata to detect conditions requiring human escalation.
726
- * Called by wu:claim to auto-set escalation_triggers.
727
- *
728
- * @param {object} wu - WU data with lane, type, code_paths
729
- * @returns {string[]} Array of triggered escalation types
730
- */
731
- export function detectEscalationTriggers(wu) {
732
- const triggers = [];
733
- const lane = (wu.lane || '').toLowerCase();
734
- const codePaths = wu.code_paths || [];
735
- // Sensitive data: Changes to user data or auth
736
- const sensitivePatterns = ['pii', 'user-data', 'auth', 'credentials'];
737
- const touchesSensitive = codePaths.some((p) => sensitivePatterns.some((pat) => p.toLowerCase().includes(pat)));
738
- if (touchesSensitive || lane.includes('pii')) {
739
- triggers.push('sensitive_data');
740
- }
741
- // Security P0: Explicit security lane or auth changes
742
- if (wu.priority === 'P0' && lane.includes('security')) {
743
- triggers.push('security_p0');
744
- }
745
- return triggers;
746
- }
747
- /**
748
- * WU-2080: Generate auto-approval metadata for wu:claim
749
- *
750
- * Called by wu:claim to auto-approve agents within policy.
751
- * Sets approved_by and approved_at, detects escalation triggers.
752
- *
753
- * @param {object} wu - WU data
754
- * @param {string} agentEmail - Email of claiming agent
755
- * @returns {{approved_by: string[], approved_at: string, escalation_triggers: string[], requires_human_escalation: boolean}}
756
- */
757
- export function generateAutoApproval(wu, agentEmail) {
758
- const triggers = detectEscalationTriggers(wu);
759
- const now = new Date().toISOString();
760
- return {
761
- approved_by: [agentEmail],
762
- approved_at: now,
763
- escalation_triggers: triggers,
764
- requires_human_escalation: triggers.length > 0,
765
- };
766
- }
767
- /**
768
- * @deprecated Use detectEscalationTriggers instead
769
- * WU-2079: Legacy function for backwards compatibility
770
- */
771
- export function determineRequiredApprovals(wu) {
772
- const triggers = detectEscalationTriggers(wu);
773
- return {
774
- requires_cso_approval: triggers.includes('security_p0') || triggers.includes('sensitive_data'),
775
- requires_cto_approval: triggers.includes('cross_lane_arch'),
776
- requires_design_approval: false, // Design no longer requires human escalation
777
- };
778
- }
779
- /**
780
- * WU-1811: Validates and normalizes WU YAML data with auto-fixable normalisations
781
- *
782
- * This function validates the WU YAML schema and applies fixable normalisations:
783
- * - Trimming whitespace from string fields
784
- * - Normalizing escaped newlines (\\n → \n)
785
- * - Splitting embedded newlines in arrays (["a\nb"] → ["a", "b"])
786
- *
787
- * Returns:
788
- * - valid: true if schema validation passes (after normalisations)
789
- * - normalized: the normalized data (even if validation fails, partial normalization is returned)
790
- * - errors: validation errors if UnsafeAny
791
- * - wasNormalized: true if UnsafeAny normalisations were applied
792
- *
793
- * @param {unknown} data - Parsed YAML data to validate and normalize
794
- * @returns {{valid: boolean, normalized: object|null, errors: string[], wasNormalized: boolean}}
795
- *
796
- * @example
797
- * const { valid, normalized, errors, wasNormalized } = validateAndNormalizeWUYAML(yamlData);
798
- * if (valid && wasNormalized) {
799
- * // Write normalized data back to YAML file
800
- * writeWU(wuPath, normalized);
801
- * }
802
- * if (!valid) {
803
- * die(`Validation failed:\n${errors.join('\n')}`);
804
- * }
805
- */
806
- export function validateAndNormalizeWUYAML(data) {
807
- // First try to parse with schema (which applies normalizations)
808
- const result = WUSchema.safeParse(data);
809
- if (!result.success) {
810
- // Schema validation failed - return errors
811
- const errors = result.error.issues.map((issue) => `${issue.path.join('.')}: ${issue.message}`);
812
- return {
813
- valid: false,
814
- normalized: null,
815
- errors,
816
- wasNormalized: false,
817
- };
818
- }
819
- // Schema passed - check if data was normalized (compare key fields)
820
- const normalized = result.data;
821
- const original = typeof data === 'object' && data !== null ? data : {};
822
- const wasNormalized = detectNormalizationChanges(original, normalized);
823
- return {
824
- valid: true,
825
- normalized,
826
- errors: [],
827
- wasNormalized,
828
- };
829
- }
830
- /**
831
- * WU-1833: Validate WU spec completeness with advisory warnings
832
- *
833
- * Provides soft validation that warns (doesn't fail) when recommended fields are missing.
834
- * Used by wu:validate command to surface quality issues without blocking workflow.
835
- *
836
- * Feature and bug WUs should have:
837
- * - notes (implementation context, deployment instructions)
838
- * - tests.manual (verification steps)
839
- * - spec_refs (links to plans, design docs) - for features only
840
- *
841
- * @param {object} wu - Validated WU data (must pass WUSchema first)
842
- * @returns {{warnings: string[]}} Array of warning messages
843
- *
844
- * @example
845
- * const schemaResult = validateWU(data);
846
- * if (schemaResult.success) {
847
- * const { warnings } = validateWUCompleteness(schemaResult.data);
848
- * if (warnings.length > 0) {
849
- * console.warn('Quality warnings:');
850
- * warnings.forEach(w => console.warn(` ⚠️ ${w}`));
851
- * }
852
- * }
853
- */
854
- export function validateWUCompleteness(wu) {
855
- const warnings = [];
856
- // WU-1384: Skip completeness checks for terminal WUs (done, cancelled, etc.)
857
- // These are immutable historical records - enforcing completeness is pointless
858
- const status = wu.status ?? '';
859
- const isTerminal = WU_STATUS_GROUPS.TERMINAL.includes(status);
860
- if (isTerminal) {
861
- return { warnings };
862
- }
863
- const type = isWUType(wu.type) ? wu.type : WU_TYPES.FEATURE;
864
- // Only feature, bug, and refactor WUs require completeness context.
865
- const requiresContext = CONTEXT_REQUIRED_TYPES.includes(type);
866
- if (!requiresContext) {
867
- return { warnings };
868
- }
869
- // Check for notes (implementation context)
870
- if (!wu.notes || wu.notes.trim().length === 0) {
871
- warnings.push(`${wu.id}: Missing 'notes' field. Add implementation context, deployment instructions, or plan links.`);
872
- }
873
- // Check for manual tests
874
- const hasManualTests = wu.tests?.manual && wu.tests.manual.length > 0;
875
- if (!hasManualTests) {
876
- warnings.push(`${wu.id}: Missing 'tests.manual' field. Add manual verification steps for acceptance criteria.`);
877
- }
878
- // Check for spec_refs (features should link to plans/specs)
879
- // WU-1062: Accepts both repo-relative paths (<configured plansDir>/) and
880
- // external paths (~/.lumenflow/plans/, $LUMENFLOW_HOME/plans/, lumenflow://plans/)
881
- if (type === 'feature') {
882
- const specRefs = wu.spec_refs;
883
- const hasSpecRefs = !!specRefs && (specRefs.length ?? 0) > 0;
884
- if (!hasSpecRefs) {
885
- const plansDirHint = `${createWuPaths().PLANS_DIR().replace(/\/+$/, '')}/`;
886
- warnings.push(`${wu.id}: Missing 'spec_refs' field. Link to plan file (${plansDirHint}, lumenflow://plans/, or ~/.lumenflow/plans/) for traceability.`);
887
- }
888
- }
889
- return { warnings };
890
- }
891
- /**
892
- * WU-1811: Detect if normalizations were applied by comparing original and normalized data
893
- *
894
- * Compares fields that are commonly normalized:
895
- * - description (escaped newlines)
896
- * - code_paths (embedded newlines split)
897
- * - acceptance (embedded newlines split)
898
- *
899
- * @param {object} original - Original parsed YAML data
900
- * @param {object} normalized - Schema-normalized data
901
- * @returns {boolean} True if UnsafeAny normalisations were applied
902
- */
903
- function detectNormalizationChanges(original, normalized) {
904
- // Compare description (newline normalization)
905
- if (original.description !== normalized.description) {
906
- return true;
907
- }
908
- // Compare code_paths (array splitting)
909
- const origPaths = Array.isArray(original.code_paths) ? original.code_paths : [];
910
- const normPaths = Array.isArray(normalized.code_paths) ? normalized.code_paths : [];
911
- if (origPaths.length !== normPaths.length) {
912
- return true;
913
- }
914
- for (let i = 0; i < origPaths.length; i++) {
915
- if (origPaths[i] !== normPaths[i]) {
916
- return true;
917
- }
918
- }
919
- // Compare acceptance if both are arrays (most common case)
920
- if (Array.isArray(original.acceptance) && Array.isArray(normalized.acceptance)) {
921
- if (original.acceptance.length !== normalized.acceptance.length) {
922
- return true;
923
- }
924
- for (let i = 0; i < original.acceptance.length; i++) {
925
- if (original.acceptance[i] !== normalized.acceptance[i]) {
926
- return true;
927
- }
928
- }
929
- }
930
- return false;
931
- }
3
+ // WU-2689 (INIT-058 L4): Shim — real module lives in @lumenflow/packs-software-delivery.
4
+ // Re-export preserves the `@lumenflow/core/wu-schema` subpath for existing consumers
5
+ // until Layer 7 removes the shim.
6
+ export * from '@lumenflow/packs-software-delivery/state/wu-schema';
932
7
  //# sourceMappingURL=wu-schema.js.map