@lumenflow/cli 5.5.0 → 5.7.12

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 (213) hide show
  1. package/README.md +42 -40
  2. package/dist/db-journal-recover.js +400 -0
  3. package/dist/db-journal-recover.js.map +1 -0
  4. package/dist/docs-sync.js +8 -3
  5. package/dist/docs-sync.js.map +1 -1
  6. package/dist/gate-defaults.js +37 -0
  7. package/dist/gate-defaults.js.map +1 -1
  8. package/dist/gates/monolithic-file-contention-guard.js +167 -0
  9. package/dist/gates/monolithic-file-contention-guard.js.map +1 -0
  10. package/dist/gates/prod-migration-drift.js +207 -0
  11. package/dist/gates/prod-migration-drift.js.map +1 -0
  12. package/dist/gates/test-over-deletion-guard.js +255 -0
  13. package/dist/gates/test-over-deletion-guard.js.map +1 -0
  14. package/dist/gates-runners.js +44 -3
  15. package/dist/gates-runners.js.map +1 -1
  16. package/dist/gates.js +3 -2
  17. package/dist/gates.js.map +1 -1
  18. package/dist/lumenflow-setup.js +144 -0
  19. package/dist/lumenflow-setup.js.map +1 -0
  20. package/dist/lumenflow-upgrade.js +2 -1
  21. package/dist/lumenflow-upgrade.js.map +1 -1
  22. package/dist/mem-create.js +10 -1
  23. package/dist/mem-create.js.map +1 -1
  24. package/dist/mem-signal.js +21 -4
  25. package/dist/mem-signal.js.map +1 -1
  26. package/dist/orchestrate-initiative.js +28 -3
  27. package/dist/orchestrate-initiative.js.map +1 -1
  28. package/dist/public-manifest.js +17 -0
  29. package/dist/public-manifest.js.map +1 -1
  30. package/dist/release.js +53 -18
  31. package/dist/release.js.map +1 -1
  32. package/dist/wu-done-gates.js +13 -9
  33. package/dist/wu-done-gates.js.map +1 -1
  34. package/dist/wu-edit-operations.js +74 -0
  35. package/dist/wu-edit-operations.js.map +1 -1
  36. package/dist/wu-edit-validators.js +58 -0
  37. package/dist/wu-edit-validators.js.map +1 -1
  38. package/dist/wu-edit.js +106 -4
  39. package/dist/wu-edit.js.map +1 -1
  40. package/dist/wu-prep.js +41 -7
  41. package/dist/wu-prep.js.map +1 -1
  42. package/dist/wu-recover.js +6 -0
  43. package/dist/wu-recover.js.map +1 -1
  44. package/dist/wu-release.js +120 -2
  45. package/dist/wu-release.js.map +1 -1
  46. package/dist/wu-sizing-validation.js +47 -17
  47. package/dist/wu-sizing-validation.js.map +1 -1
  48. package/dist/wu-status.js +33 -0
  49. package/dist/wu-status.js.map +1 -1
  50. package/package.json +13 -11
  51. package/packs/agent-runtime/package.json +1 -1
  52. package/packs/sidekick/package.json +1 -1
  53. package/packs/software-delivery/package.json +1 -1
  54. package/templates/core/AGENTS.md.template +67 -3
  55. package/templates/core/LUMENFLOW.md.template +197 -47
  56. package/packs/agent-runtime/agent-heartbeat.ts +0 -163
  57. package/packs/agent-runtime/auto-session-integration.ts +0 -888
  58. package/packs/agent-runtime/capability-factory.ts +0 -104
  59. package/packs/agent-runtime/constants.ts +0 -21
  60. package/packs/agent-runtime/delegation-registry-schema.ts +0 -220
  61. package/packs/agent-runtime/delegation-registry-store.ts +0 -269
  62. package/packs/agent-runtime/delegation-tree.ts +0 -328
  63. package/packs/agent-runtime/index.ts +0 -20
  64. package/packs/agent-runtime/manifest.ts +0 -348
  65. package/packs/agent-runtime/memory-coordination-contract.ts +0 -86
  66. package/packs/agent-runtime/orchestration.ts +0 -2027
  67. package/packs/agent-runtime/pack-registration.ts +0 -110
  68. package/packs/agent-runtime/policy-factory.ts +0 -165
  69. package/packs/agent-runtime/remote-controls/index.ts +0 -7
  70. package/packs/agent-runtime/remote-controls/operations.ts +0 -405
  71. package/packs/agent-runtime/remote-controls/port.ts +0 -48
  72. package/packs/agent-runtime/remote-controls/state-store.ts +0 -258
  73. package/packs/agent-runtime/remote-controls/types.ts +0 -105
  74. package/packs/agent-runtime/session-schema.ts +0 -467
  75. package/packs/agent-runtime/tool-impl/agent-turn-tools.ts +0 -793
  76. package/packs/agent-runtime/tool-impl/index.ts +0 -6
  77. package/packs/agent-runtime/tool-impl/provider-adapters.ts +0 -1245
  78. package/packs/agent-runtime/tool-impl/remote-controls.mock.ts +0 -256
  79. package/packs/agent-runtime/tool-impl/remote-controls.ts +0 -273
  80. package/packs/agent-runtime/tools/index.ts +0 -4
  81. package/packs/agent-runtime/tools/types.ts +0 -47
  82. package/packs/agent-runtime/turn-lifecycle-events.ts +0 -590
  83. package/packs/agent-runtime/types.ts +0 -128
  84. package/packs/agent-runtime/vitest.config.ts +0 -11
  85. package/packs/sidekick/channel-ingress.ts +0 -137
  86. package/packs/sidekick/constants.ts +0 -10
  87. package/packs/sidekick/index.ts +0 -8
  88. package/packs/sidekick/manifest-schema.ts +0 -49
  89. package/packs/sidekick/manifest.ts +0 -512
  90. package/packs/sidekick/pack-registration.ts +0 -110
  91. package/packs/sidekick/policy-factory.ts +0 -38
  92. package/packs/sidekick/sidekick-events.ts +0 -694
  93. package/packs/sidekick/src/adapters/cloud-queue.ts +0 -101
  94. package/packs/sidekick/src/adapters/control-plane-bridge.adapter.ts +0 -386
  95. package/packs/sidekick/src/adapters/filesystem-bridge.adapter.ts +0 -228
  96. package/packs/sidekick/src/domain/channel.types.ts +0 -64
  97. package/packs/sidekick/src/ports/channel-bridge.port.ts +0 -92
  98. package/packs/sidekick/src/routines/commit.ts +0 -74
  99. package/packs/sidekick/tool-impl/channel-tools.ts +0 -577
  100. package/packs/sidekick/tool-impl/channel-transports.ts +0 -75
  101. package/packs/sidekick/tool-impl/index.ts +0 -29
  102. package/packs/sidekick/tool-impl/memory-tools.ts +0 -290
  103. package/packs/sidekick/tool-impl/routine-commit.ts +0 -102
  104. package/packs/sidekick/tool-impl/routine-tools.ts +0 -440
  105. package/packs/sidekick/tool-impl/runtime-context.ts +0 -28
  106. package/packs/sidekick/tool-impl/shared.ts +0 -125
  107. package/packs/sidekick/tool-impl/storage.ts +0 -325
  108. package/packs/sidekick/tool-impl/system-tools.ts +0 -160
  109. package/packs/sidekick/tool-impl/task-tools.ts +0 -506
  110. package/packs/sidekick/tools/channel-tools.ts +0 -53
  111. package/packs/sidekick/tools/index.ts +0 -9
  112. package/packs/sidekick/tools/memory-tools.ts +0 -53
  113. package/packs/sidekick/tools/routine-tools.ts +0 -53
  114. package/packs/sidekick/tools/system-tools.ts +0 -47
  115. package/packs/sidekick/tools/task-tools.ts +0 -61
  116. package/packs/sidekick/tools/types.ts +0 -57
  117. package/packs/sidekick/vitest.config.ts +0 -11
  118. package/packs/software-delivery/constants.ts +0 -10
  119. package/packs/software-delivery/extensions.ts +0 -140
  120. package/packs/software-delivery/gate-policies.ts +0 -134
  121. package/packs/software-delivery/index.ts +0 -8
  122. package/packs/software-delivery/manifest-schema.ts +0 -268
  123. package/packs/software-delivery/manifest.ts +0 -657
  124. package/packs/software-delivery/pack-registration.ts +0 -113
  125. package/packs/software-delivery/src/commands/index.ts +0 -5
  126. package/packs/software-delivery/src/config/delivery-review-contract.ts +0 -256
  127. package/packs/software-delivery/src/config/env-accessors.ts +0 -66
  128. package/packs/software-delivery/src/config/index.ts +0 -8
  129. package/packs/software-delivery/src/config/normalize-config-keys.ts +0 -9
  130. package/packs/software-delivery/src/config/schemas/lumenflow-config-schema-types.ts +0 -460
  131. package/packs/software-delivery/src/config/workspace-reader.ts +0 -375
  132. package/packs/software-delivery/src/constants/backlog-patterns.ts +0 -31
  133. package/packs/software-delivery/src/constants/client-ids.ts +0 -19
  134. package/packs/software-delivery/src/constants/config-contract.ts +0 -7
  135. package/packs/software-delivery/src/constants/docs-layout-presets.ts +0 -50
  136. package/packs/software-delivery/src/constants/duration-constants.ts +0 -20
  137. package/packs/software-delivery/src/constants/gate-constants.ts +0 -32
  138. package/packs/software-delivery/src/constants/index.ts +0 -29
  139. package/packs/software-delivery/src/constants/lock-constants.ts +0 -35
  140. package/packs/software-delivery/src/constants/object-guards.ts +0 -12
  141. package/packs/software-delivery/src/constants/section-headings.ts +0 -107
  142. package/packs/software-delivery/src/constants/wu-cli-constants.ts +0 -500
  143. package/packs/software-delivery/src/constants/wu-domain-constants.ts +0 -466
  144. package/packs/software-delivery/src/constants/wu-git-constants.ts +0 -7
  145. package/packs/software-delivery/src/constants/wu-id-format.ts +0 -327
  146. package/packs/software-delivery/src/constants/wu-paths-constants.ts +0 -384
  147. package/packs/software-delivery/src/constants/wu-statuses.ts +0 -287
  148. package/packs/software-delivery/src/constants/wu-type-helpers.ts +0 -67
  149. package/packs/software-delivery/src/constants/wu-ui-constants.ts +0 -267
  150. package/packs/software-delivery/src/constants/wu-validation-constants.ts +0 -73
  151. package/packs/software-delivery/src/domain/index.ts +0 -5
  152. package/packs/software-delivery/src/domain/orchestration.constants.ts +0 -166
  153. package/packs/software-delivery/src/domain/orchestration.schemas.ts +0 -238
  154. package/packs/software-delivery/src/domain/orchestration.types.ts +0 -176
  155. package/packs/software-delivery/src/methodology/incremental-test.ts +0 -122
  156. package/packs/software-delivery/src/methodology/index.ts +0 -6
  157. package/packs/software-delivery/src/methodology/manual-test-validator.ts +0 -292
  158. package/packs/software-delivery/src/policy/coverage-gate.ts +0 -270
  159. package/packs/software-delivery/src/policy/gates-agent-mode.ts +0 -223
  160. package/packs/software-delivery/src/policy/gates-config-internal.ts +0 -121
  161. package/packs/software-delivery/src/policy/gates-config.ts +0 -300
  162. package/packs/software-delivery/src/policy/gates-coverage.ts +0 -356
  163. package/packs/software-delivery/src/policy/gates-presets.ts +0 -134
  164. package/packs/software-delivery/src/policy/gates-schemas.ts +0 -173
  165. package/packs/software-delivery/src/policy/index.ts +0 -22
  166. package/packs/software-delivery/src/policy/package-manager-resolver.ts +0 -319
  167. package/packs/software-delivery/src/policy/resolve-policy.ts +0 -601
  168. package/packs/software-delivery/src/ports/config.ports.ts +0 -90
  169. package/packs/software-delivery/src/ports/dashboard-renderer.port.ts +0 -125
  170. package/packs/software-delivery/src/ports/index.ts +0 -10
  171. package/packs/software-delivery/src/ports/sync-validator.ports.ts +0 -59
  172. package/packs/software-delivery/src/ports/wu-helpers.ports.ts +0 -168
  173. package/packs/software-delivery/src/ports/wu-state.ports.ts +0 -241
  174. package/packs/software-delivery/src/primitives/index.ts +0 -5
  175. package/packs/software-delivery/src/runtime/index.ts +0 -6
  176. package/packs/software-delivery/src/runtime/work-classifier.ts +0 -561
  177. package/packs/software-delivery/src/sandbox/index.ts +0 -10
  178. package/packs/software-delivery/src/sandbox/sandbox-allowlist.ts +0 -118
  179. package/packs/software-delivery/src/sandbox/sandbox-backend-linux.ts +0 -88
  180. package/packs/software-delivery/src/sandbox/sandbox-backend-macos.ts +0 -154
  181. package/packs/software-delivery/src/sandbox/sandbox-backend-windows.ts +0 -47
  182. package/packs/software-delivery/src/sandbox/sandbox-profile.ts +0 -153
  183. package/packs/software-delivery/src/schemas/index.ts +0 -5
  184. package/packs/software-delivery/src/state/date-utils.ts +0 -158
  185. package/packs/software-delivery/src/state/index.ts +0 -15
  186. package/packs/software-delivery/src/state/state-machine.ts +0 -119
  187. package/packs/software-delivery/src/state/wu-doc-types.ts +0 -51
  188. package/packs/software-delivery/src/state/wu-paths.ts +0 -381
  189. package/packs/software-delivery/src/state/wu-schema.ts +0 -1139
  190. package/packs/software-delivery/src/state/wu-state-schema.ts +0 -255
  191. package/packs/software-delivery/src/state/wu-yaml.ts +0 -338
  192. package/packs/software-delivery/tool-impl/agent-tools.ts +0 -263
  193. package/packs/software-delivery/tool-impl/delegation-tools.ts +0 -66
  194. package/packs/software-delivery/tool-impl/flow-metrics-tools.ts +0 -219
  195. package/packs/software-delivery/tool-impl/git-runner.ts +0 -113
  196. package/packs/software-delivery/tool-impl/git-tools.ts +0 -316
  197. package/packs/software-delivery/tool-impl/index.ts +0 -15
  198. package/packs/software-delivery/tool-impl/initiative-orchestration-tools.ts +0 -720
  199. package/packs/software-delivery/tool-impl/lane-lock.ts +0 -246
  200. package/packs/software-delivery/tool-impl/memory-tools.ts +0 -470
  201. package/packs/software-delivery/tool-impl/pending-runtime-tools.ts +0 -21
  202. package/packs/software-delivery/tool-impl/runtime-cli-adapter.ts +0 -329
  203. package/packs/software-delivery/tool-impl/runtime-native-tools.ts +0 -687
  204. package/packs/software-delivery/tool-impl/worker-loader.ts +0 -52
  205. package/packs/software-delivery/tool-impl/worktree-tools.ts +0 -46
  206. package/packs/software-delivery/tool-impl/wu-lifecycle-tools.ts +0 -807
  207. package/packs/software-delivery/tools/delegation-tools.ts +0 -23
  208. package/packs/software-delivery/tools/git-tools.ts +0 -55
  209. package/packs/software-delivery/tools/index.ts +0 -8
  210. package/packs/software-delivery/tools/lane-lock-tool.ts +0 -37
  211. package/packs/software-delivery/tools/types.ts +0 -71
  212. package/packs/software-delivery/tools/worktree-tools.ts +0 -49
  213. package/packs/software-delivery/vitest.config.ts +0 -11
@@ -1,356 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * Gates Coverage Policy Resolution
6
- *
7
- * WU-2037: Extracted from gates-config.ts
8
- *
9
- * Resolves coverage configuration and test policy from methodology settings.
10
- * Uses resolvePolicy() to derive thresholds and modes from workspace.yaml.
11
- *
12
- * @module gates-coverage
13
- */
14
-
15
- import { minimatch } from 'minimatch';
16
- import { asRecord, isBoolean, isNumber } from '../constants/object-guards.js';
17
- import {
18
- resolvePolicy,
19
- getDefaultPolicy,
20
- MethodologyConfigSchema,
21
- TddDiffEvidenceConfigSchema,
22
- TddOrderingConfigSchema,
23
- type TddDiffEvidenceConfig,
24
- type TddDiffEvidencePolicy,
25
- type TddOrderingConfig,
26
- type TddOrderingPolicy,
27
- } from './resolve-policy.js';
28
- import type { CoverageConfig, TestPolicy } from './gates-schemas.js';
29
- import {
30
- GATES_RUNTIME_DEFAULTS,
31
- SOFTWARE_DELIVERY_FIELDS,
32
- GATES_FIELDS,
33
- loadSoftwareDeliveryConfig,
34
- } from './gates-config-internal.js';
35
-
36
- // ---------------------------------------------------------------------------
37
- // Private helpers for reading typed fields from raw config
38
- // ---------------------------------------------------------------------------
39
-
40
- function readNumberField(
41
- source: Record<string, unknown> | undefined,
42
- primaryKey: string,
43
- secondaryKey: string,
44
- ): number | undefined {
45
- const primary = source?.[primaryKey];
46
- if (isNumber(primary)) {
47
- return primary;
48
- }
49
- const secondary = source?.[secondaryKey];
50
- return isNumber(secondary) ? secondary : undefined;
51
- }
52
-
53
- function readBooleanField(
54
- source: Record<string, unknown> | undefined,
55
- primaryKey: string,
56
- secondaryKey: string,
57
- ): boolean | undefined {
58
- const primary = source?.[primaryKey];
59
- if (isBoolean(primary)) {
60
- return primary;
61
- }
62
- const secondary = source?.[secondaryKey];
63
- return isBoolean(secondary) ? secondary : undefined;
64
- }
65
-
66
- function readGateMinCoverage(gatesRaw: Record<string, unknown> | undefined): number | undefined {
67
- return readNumberField(gatesRaw, GATES_FIELDS.MIN_COVERAGE, GATES_FIELDS.MIN_COVERAGE_SNAKE);
68
- }
69
-
70
- function readGateEnableCoverage(
71
- gatesRaw: Record<string, unknown> | undefined,
72
- ): boolean | undefined {
73
- return readBooleanField(
74
- gatesRaw,
75
- GATES_FIELDS.ENABLE_COVERAGE,
76
- GATES_FIELDS.ENABLE_COVERAGE_SNAKE,
77
- );
78
- }
79
-
80
- function readTddDiffEvidenceConfig(
81
- gatesRaw: Record<string, unknown> | undefined,
82
- ): TddDiffEvidenceConfig | undefined {
83
- const raw = asRecord(gatesRaw?.[GATES_FIELDS.TDD_DIFF_EVIDENCE]) ?? undefined;
84
- return TddDiffEvidenceConfigSchema.optional().parse(raw);
85
- }
86
-
87
- function readTddOrderingConfig(
88
- gatesRaw: Record<string, unknown> | undefined,
89
- ): TddOrderingConfig | undefined {
90
- const raw = asRecord(gatesRaw?.[GATES_FIELDS.TDD_ORDERING]) ?? undefined;
91
- return TddOrderingConfigSchema.optional().parse(raw);
92
- }
93
-
94
- // ---------------------------------------------------------------------------
95
- // Shared policy resolution helper (DRY: used by both public functions)
96
- // ---------------------------------------------------------------------------
97
-
98
- function resolvePolicyFromConfig(rawConfig: Record<string, unknown>) {
99
- const methodologyRaw = asRecord(rawConfig[SOFTWARE_DELIVERY_FIELDS.METHODOLOGY]) ?? undefined;
100
- const gatesRaw = asRecord(rawConfig[SOFTWARE_DELIVERY_FIELDS.GATES]) ?? undefined;
101
- const minCoverage = readGateMinCoverage(gatesRaw);
102
- const enableCoverage = readGateEnableCoverage(gatesRaw);
103
- const tddDiffEvidence = readTddDiffEvidenceConfig(gatesRaw);
104
- const tddOrdering = readTddOrderingConfig(gatesRaw);
105
-
106
- // Parse methodology with Zod to get defaults
107
- const methodology = MethodologyConfigSchema.parse(methodologyRaw ?? {});
108
-
109
- // Build the config structure that resolvePolicy expects
110
- const minimalConfig = {
111
- methodology: methodologyRaw, // Pass raw methodology for explicit detection
112
- gates: {
113
- minCoverage,
114
- enableCoverage,
115
- tdd_diff_evidence: tddDiffEvidence,
116
- tdd_ordering: tddOrdering,
117
- },
118
- };
119
-
120
- // Resolve policy using the methodology configuration
121
- // Pass rawConfig to detect explicit gates.* settings vs Zod defaults
122
- return resolvePolicy(
123
- {
124
- methodology,
125
- gates: {
126
- // Default gates values from schema
127
- maxEslintWarnings: GATES_RUNTIME_DEFAULTS.MAX_ESLINT_WARNINGS,
128
- enableCoverage: enableCoverage ?? GATES_RUNTIME_DEFAULTS.DEFAULT_ENABLE_COVERAGE,
129
- minCoverage: minCoverage ?? GATES_RUNTIME_DEFAULTS.DEFAULT_MIN_COVERAGE,
130
- enableSafetyCriticalTests: true,
131
- enableInvariants: true,
132
- tdd_diff_evidence: tddDiffEvidence,
133
- tdd_ordering: tddOrdering,
134
- },
135
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Minimal type for config
136
- } as unknown as Parameters<typeof resolvePolicy>[0],
137
- {
138
- rawConfig: minimalConfig,
139
- },
140
- );
141
- }
142
-
143
- // ---------------------------------------------------------------------------
144
- // Public API
145
- // ---------------------------------------------------------------------------
146
-
147
- /**
148
- * WU-1262: Resolve coverage configuration from methodology policy
149
- *
150
- * Uses resolvePolicy() to determine coverage defaults based on methodology.testing:
151
- * - tdd: 90% threshold, block mode
152
- * - test-after: 70% threshold, warn mode
153
- * - none: 0% threshold, off mode
154
- *
155
- * Precedence (highest to lowest):
156
- * 1. Explicit gates.minCoverage / gates.enableCoverage
157
- * 2. methodology.overrides.coverage_threshold / coverage_mode
158
- * 3. methodology.testing template defaults
159
- *
160
- * @param projectRoot - Project root directory
161
- * @returns Resolved coverage configuration
162
- */
163
- export function resolveCoverageConfig(projectRoot: string): CoverageConfig {
164
- const rawConfig = loadSoftwareDeliveryConfig(projectRoot) ?? {};
165
-
166
- // If no config file, use default policy
167
- if (Object.keys(rawConfig).length === 0) {
168
- const defaultPolicy = getDefaultPolicy();
169
- return {
170
- threshold: defaultPolicy.coverage_threshold,
171
- mode: defaultPolicy.coverage_mode,
172
- };
173
- }
174
-
175
- const policy = resolvePolicyFromConfig(rawConfig);
176
-
177
- return {
178
- threshold: policy.coverage_threshold,
179
- mode: policy.coverage_mode,
180
- };
181
- }
182
-
183
- /**
184
- * WU-1280: Resolve test policy from methodology configuration
185
- *
186
- * Returns the full test policy including coverage config AND tests_required.
187
- * This is used by gates to determine whether test failures should block or warn.
188
- *
189
- * Methodology mapping:
190
- * - tdd: 90% threshold, block mode, tests_required=true
191
- * - test-after: 70% threshold, warn mode, tests_required=true
192
- * - none: 0% threshold, off mode, tests_required=false
193
- *
194
- * When tests_required=false:
195
- * - Test failures produce WARNINGS instead of FAILURES
196
- * - Gates continue but log the test failures
197
- * - Coverage gate is effectively skipped (mode='off')
198
- *
199
- * @param projectRoot - Project root directory
200
- * @returns Resolved test policy including tests_required
201
- */
202
- export function resolveTestPolicy(projectRoot: string): TestPolicy {
203
- const rawConfig = loadSoftwareDeliveryConfig(projectRoot) ?? {};
204
-
205
- // If no config file, use default policy (TDD)
206
- if (Object.keys(rawConfig).length === 0) {
207
- const defaultPolicy = getDefaultPolicy();
208
- return {
209
- threshold: defaultPolicy.coverage_threshold,
210
- mode: defaultPolicy.coverage_mode,
211
- tests_required: defaultPolicy.tests_required,
212
- };
213
- }
214
-
215
- const policy = resolvePolicyFromConfig(rawConfig);
216
-
217
- return {
218
- threshold: policy.coverage_threshold,
219
- mode: policy.coverage_mode,
220
- tests_required: policy.tests_required,
221
- };
222
- }
223
-
224
- /**
225
- * Resolve the tdd_diff_evidence policy for a project.
226
- *
227
- * WU-2905: The returned policy now also exposes resolved
228
- * `test_file_patterns` (globs) and `code_file_extensions` so non-TS/JS
229
- * consumers (.NET, Python, Go, ...) can opt their toolchain into the gate
230
- * via `software_delivery.gates.tdd_diff_evidence.test_file_patterns` /
231
- * `code_file_extensions` in workspace.yaml. Defaults preserve TS/JS
232
- * behaviour byte-for-byte for existing consumers.
233
- */
234
- export function resolveTddDiffEvidencePolicy(projectRoot: string): TddDiffEvidencePolicy {
235
- const rawConfig = loadSoftwareDeliveryConfig(projectRoot) ?? {};
236
-
237
- if (Object.keys(rawConfig).length === 0) {
238
- return getDefaultPolicy().tdd_diff_evidence;
239
- }
240
-
241
- return resolvePolicyFromConfig(rawConfig).tdd_diff_evidence;
242
- }
243
-
244
- const TDD_GLOB_MATCH_OPTIONS = { dot: true } as const;
245
-
246
- /**
247
- * Result of evaluating whether a WU is waived from the TDD diff-evidence
248
- * test-path requirement based on the resolved tdd_diff_evidence policy.
249
- *
250
- * Used by both wu:create (test-path requirement) and wu:prep
251
- * (diff-evidence enforcement) so that the two surfaces stay in lockstep.
252
- *
253
- * WU-2881: Surfacing the rationale via `reason` lets callers print an
254
- * audit-trail line so reviewers can see WHY a WU bypassed test paths.
255
- */
256
- export type TddDiffEvidenceWaiver =
257
- | { waived: false }
258
- | { waived: true; reason: TddDiffEvidenceWaiverReason; detail: string };
259
-
260
- export type TddDiffEvidenceWaiverReason = 'mode-off' | 'type-not-applicable' | 'all-paths-exempt';
261
-
262
- /**
263
- * WU-2881: Pure helper used by wu:create (and reusable by wu:prep) to decide
264
- * whether the resolved tdd_diff_evidence policy waives the test-path
265
- * requirement for a given WU shape.
266
- *
267
- * Returns waived=true when ANY of the following hold:
268
- * 1. policy.mode === 'off'
269
- * 2. policy.applies_to_types does not include the WU's type
270
- * 3. The WU has at least one code_path AND every code_path matches one of
271
- * policy.exempt_paths globs
272
- *
273
- * Mixed cases (some code_paths exempt, others not) are NOT waived — strict
274
- * behavior preserved per WU-2881 acceptance criteria.
275
- */
276
- export function evaluateTddDiffEvidenceWaiver(options: {
277
- policy: TddDiffEvidencePolicy;
278
- type: string | undefined;
279
- codePaths: readonly string[];
280
- }): TddDiffEvidenceWaiver {
281
- const { policy, type, codePaths } = options;
282
-
283
- if (policy.mode === 'off') {
284
- return {
285
- waived: true,
286
- reason: 'mode-off',
287
- detail: 'tdd_diff_evidence.mode=off (workspace.yaml)',
288
- };
289
- }
290
-
291
- if (typeof type !== 'string' || !policy.applies_to_types.some((t) => t === type)) {
292
- return {
293
- waived: true,
294
- reason: 'type-not-applicable',
295
- detail: `WU type '${type ?? '<unknown>'}' not in tdd_diff_evidence.applies_to_types=[${policy.applies_to_types.join(', ')}]`,
296
- };
297
- }
298
-
299
- if (codePaths.length > 0 && policy.exempt_paths.length > 0) {
300
- const matchedPatterns = new Set<string>();
301
- const allExempt = codePaths.every((codePath) => {
302
- const normalized = codePath.replace(/\\/g, '/');
303
- const matchedPattern = policy.exempt_paths.find((pattern) =>
304
- minimatch(normalized, pattern, TDD_GLOB_MATCH_OPTIONS),
305
- );
306
- if (matchedPattern) {
307
- matchedPatterns.add(matchedPattern);
308
- return true;
309
- }
310
- return false;
311
- });
312
-
313
- if (allExempt) {
314
- return {
315
- waived: true,
316
- reason: 'all-paths-exempt',
317
- detail: `all code_paths under exempt_paths globs (${[...matchedPatterns].join(', ')})`,
318
- };
319
- }
320
- }
321
-
322
- return { waived: false };
323
- }
324
-
325
- /**
326
- * WU-2881: Match a single file path against the policy's exempt_paths globs.
327
- *
328
- * Centralizes the minimatch invocation so wu:prep and other callers can share
329
- * one canonical exempt-path matcher.
330
- */
331
- export function isPathExemptByTddDiffEvidence(
332
- filePath: string,
333
- exemptPaths: readonly string[],
334
- ): boolean {
335
- if (exemptPaths.length === 0) {
336
- return false;
337
- }
338
- const normalized = filePath.replace(/\\/g, '/');
339
- return exemptPaths.some((pattern) => minimatch(normalized, pattern, TDD_GLOB_MATCH_OPTIONS));
340
- }
341
-
342
- /**
343
- * WU-2650: Resolve the commit-order (RED-first) policy.
344
- *
345
- * Mirrors resolveTddDiffEvidencePolicy. Enforces only for feature/bug WUs
346
- * under TDD methodology by default; docs/chore/process/tooling WUs bypass.
347
- */
348
- export function resolveTddOrderingPolicy(projectRoot: string): TddOrderingPolicy {
349
- const rawConfig = loadSoftwareDeliveryConfig(projectRoot) ?? {};
350
-
351
- if (Object.keys(rawConfig).length === 0) {
352
- return getDefaultPolicy().tdd_ordering;
353
- }
354
-
355
- return resolvePolicyFromConfig(rawConfig).tdd_ordering;
356
- }
@@ -1,134 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * Gates Presets
6
- *
7
- * WU-2037: Extracted from gates-config.ts
8
- *
9
- * Language ecosystem preset definitions and expansion logic.
10
- *
11
- * @module gates-presets
12
- */
13
-
14
- import type { GatesExecutionConfig } from './gates-schemas.js';
15
-
16
- /**
17
- * Gate preset definitions
18
- *
19
- * These provide sensible defaults for common language ecosystems.
20
- * Users can override fields via workspace.yaml software_delivery
21
- */
22
- export const GATE_PRESETS: Record<string, Partial<GatesExecutionConfig>> = {
23
- node: {
24
- setup: 'npm ci || npm install',
25
- format: 'npx prettier --check .',
26
- lint: 'npx eslint .',
27
- typecheck: 'npx tsc --noEmit',
28
- test: 'npm test',
29
- },
30
- python: {
31
- setup: 'pip install -e ".[dev]" || pip install -r requirements.txt',
32
- format: 'ruff format --check .',
33
- lint: 'ruff check .',
34
- typecheck: 'mypy .',
35
- test: 'pytest',
36
- },
37
- go: {
38
- format: 'gofmt -l . | grep -v "^$" && exit 1 || exit 0',
39
- lint: 'golangci-lint run',
40
- typecheck: 'go vet ./...',
41
- test: 'go test ./...',
42
- },
43
- rust: {
44
- format: 'cargo fmt --check',
45
- lint: 'cargo clippy -- -D warnings',
46
- typecheck: 'cargo check',
47
- test: 'cargo test',
48
- },
49
- dotnet: {
50
- setup: 'dotnet restore',
51
- format: 'dotnet format --verify-no-changes',
52
- lint: 'dotnet build --no-restore -warnaserror',
53
- test: 'dotnet test --no-restore',
54
- },
55
- // WU-1118: Java/JVM, Ruby, and PHP presets
56
- java: {
57
- format: 'mvn spotless:check || ./gradlew spotlessCheck',
58
- lint: 'mvn checkstyle:check || ./gradlew checkstyleMain',
59
- typecheck: 'mvn compile -DskipTests || ./gradlew compileJava',
60
- test: 'mvn test || ./gradlew test',
61
- },
62
- ruby: {
63
- setup: 'bundle install',
64
- format: 'bundle exec rubocop --format simple --fail-level W',
65
- lint: 'bundle exec rubocop',
66
- test: 'bundle exec rspec',
67
- },
68
- php: {
69
- setup: 'composer install',
70
- format: 'vendor/bin/php-cs-fixer fix --dry-run --diff',
71
- lint: 'vendor/bin/phpstan analyse',
72
- test: 'vendor/bin/phpunit',
73
- },
74
- };
75
-
76
- /**
77
- * Expand a preset name into its default gate commands
78
- *
79
- * @param preset - Preset name (node, python, go, rust, dotnet) or undefined
80
- * @returns Partial gates config with preset defaults, or empty object if unknown
81
- */
82
- export function expandPreset(preset: string | undefined): Partial<GatesExecutionConfig> {
83
- if (!preset) {
84
- return {};
85
- }
86
-
87
- return GATE_PRESETS[preset] ?? {};
88
- }
89
-
90
- /**
91
- * WU-2547: Preset-specific format-fix remediation commands.
92
- *
93
- * The `format` key in GATE_PRESETS above is the *verification* command used
94
- * by gates (e.g. `dotnet format --verify-no-changes`). When an agent or
95
- * user needs to actually fix a formatting failure they need the mutating
96
- * equivalent of that command — `dotnet format`, `cargo fmt`, etc.
97
- *
98
- * Onboarding templates used to hardcode `pnpm prettier --write <file>`,
99
- * which silently teaches agents the wrong habit in non-JS repos. init.ts
100
- * now resolves this map against the chosen preset and substitutes the
101
- * result into the `{{format_fix_command}}` placeholder.
102
- */
103
- export const PRESET_FIX_COMMANDS: Record<string, string> = {
104
- node: 'pnpm prettier --write <file>',
105
- python: 'ruff format <file>',
106
- go: 'gofmt -w <file>',
107
- rust: 'cargo fmt',
108
- dotnet: 'dotnet format',
109
- java: 'mvn spotless:apply',
110
- ruby: 'bundle exec rubocop -a <file>',
111
- php: 'vendor/bin/php-cs-fixer fix <file>',
112
- };
113
-
114
- /**
115
- * WU-2547: Safe fallback when a caller passes an unknown preset.
116
- * Mirrors PRESET_FIX_COMMANDS.node so the two always match; kept as its own
117
- * constant to satisfy noUncheckedIndexedAccess without a non-null assertion.
118
- */
119
- const DEFAULT_FORMAT_FIX_COMMAND = 'pnpm prettier --write <file>';
120
-
121
- /**
122
- * WU-2547: Resolve the format-fix remediation command for a preset.
123
- *
124
- * Used by init.ts to populate the `{{format_fix_command}}` token in
125
- * onboarding templates so a .NET repo gets `dotnet format` guidance
126
- * instead of `pnpm prettier --write`.
127
- *
128
- * @param preset - Gate preset name (node, dotnet, python, etc.)
129
- * @returns The remediation command for the preset, or the node default
130
- * if the preset is unknown (never returns empty).
131
- */
132
- export function getFormatFixCommand(preset: string): string {
133
- return PRESET_FIX_COMMANDS[preset] ?? DEFAULT_FORMAT_FIX_COMMAND;
134
- }
@@ -1,173 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * Gates Schemas and Types
6
- *
7
- * WU-2037: Extracted from gates-config.ts
8
- *
9
- * Zod schema definitions, TypeScript types, and interfaces for gates configuration.
10
- * This module contains only shape definitions -- no runtime logic.
11
- *
12
- * @module gates-schemas
13
- */
14
-
15
- import { z } from 'zod';
16
- import type { CoverageMode } from './resolve-policy.js';
17
-
18
- // ---------------------------------------------------------------------------
19
- // Gate command schemas
20
- // ---------------------------------------------------------------------------
21
-
22
- /**
23
- * Schema for a gate command object with options
24
- */
25
- const GateCommandObjectSchema = z.object({
26
- /** The shell command to execute */
27
- command: z.string(),
28
- /** Whether to continue if this gate fails (default: false) */
29
- continueOnError: z.boolean().optional(),
30
- /** Timeout in milliseconds */
31
- timeout: z.number().int().positive().optional(),
32
- });
33
-
34
- /**
35
- * Schema for a gate command - either a string or an object with options
36
- */
37
- export const GateCommandConfigSchema = z.union([z.string(), GateCommandObjectSchema]);
38
-
39
- /**
40
- * Type for parsed gate command configuration
41
- */
42
- export type GateCommandConfig = z.infer<typeof GateCommandConfigSchema>;
43
-
44
- /**
45
- * Schema for the gates execution configuration section
46
- */
47
- export const GatesExecutionConfigSchema = z.object({
48
- /** Preset to use for default commands (node, python, go, rust, dotnet) */
49
- preset: z.string().optional(),
50
- /** Setup command (e.g., install dependencies) */
51
- setup: GateCommandConfigSchema.optional(),
52
- /** Format check command */
53
- format: GateCommandConfigSchema.optional(),
54
- /** Lint command */
55
- lint: GateCommandConfigSchema.optional(),
56
- /** Type check command */
57
- typecheck: GateCommandConfigSchema.optional(),
58
- /** Test command */
59
- test: GateCommandConfigSchema.optional(),
60
- /** Coverage configuration */
61
- coverage: z
62
- .union([
63
- z.string(),
64
- z.object({
65
- command: z.string(),
66
- threshold: z.number().min(0).max(100).optional(),
67
- }),
68
- ])
69
- .optional(),
70
- });
71
-
72
- /**
73
- * Type for gates execution configuration
74
- */
75
- export type GatesExecutionConfig = z.infer<typeof GatesExecutionConfigSchema>;
76
-
77
- // ---------------------------------------------------------------------------
78
- // Parsed gate command interface
79
- // ---------------------------------------------------------------------------
80
-
81
- /**
82
- * Parsed gate command ready for execution
83
- */
84
- export interface ParsedGateCommand {
85
- /** The shell command to execute */
86
- command: string;
87
- /** Whether to continue if this gate fails */
88
- continueOnError: boolean;
89
- /** Timeout in milliseconds */
90
- timeout: number;
91
- }
92
-
93
- // ---------------------------------------------------------------------------
94
- // Lane health types
95
- // ---------------------------------------------------------------------------
96
-
97
- /**
98
- * WU-1191: Lane health gate mode
99
- * Controls how lane health check behaves during gates
100
- */
101
- export type LaneHealthMode = 'warn' | 'error' | 'off';
102
-
103
- /**
104
- * Schema for lane health mode validation
105
- */
106
- export const LaneHealthModeSchema = z.enum(['warn', 'error', 'off']);
107
-
108
- /**
109
- * Default lane health mode (advisory by default)
110
- */
111
- export const DEFAULT_LANE_HEALTH_MODE: LaneHealthMode = 'warn';
112
-
113
- // ---------------------------------------------------------------------------
114
- // Coverage / test policy interfaces
115
- // ---------------------------------------------------------------------------
116
-
117
- /**
118
- * WU-1262: Resolved coverage configuration
119
- * Contains threshold and mode derived from methodology policy
120
- */
121
- export interface CoverageConfig {
122
- /** Coverage threshold (0-100) */
123
- threshold: number;
124
- /** Coverage mode (block, warn, or off) */
125
- mode: CoverageMode;
126
- }
127
-
128
- /**
129
- * WU-2020: Focused coverage policy interface (ISP-compliant).
130
- * Single-responsibility: coverage threshold and enforcement mode.
131
- */
132
- export interface CoveragePolicy {
133
- /** Coverage threshold (0-100) */
134
- threshold: number;
135
- /** Coverage mode (block, warn, or off) */
136
- mode: CoverageMode;
137
- }
138
-
139
- /**
140
- * WU-2020: Focused test runner policy interface (ISP-compliant).
141
- * Single-responsibility: whether tests are mandatory for completion.
142
- */
143
- export interface TestRunnerPolicy {
144
- /** Whether tests are required for completion (from methodology.testing) */
145
- tests_required: boolean;
146
- }
147
-
148
- /**
149
- * WU-1280: Resolved test policy configuration
150
- * Extends CoverageConfig with tests_required from methodology policy.
151
- *
152
- * WU-2020: Now defined as the intersection of CoveragePolicy and
153
- * TestRunnerPolicy. Consumers that only need coverage or test-runner
154
- * semantics should prefer the focused interfaces.
155
- */
156
- export interface TestPolicy extends CoveragePolicy, TestRunnerPolicy {}
157
-
158
- // ---------------------------------------------------------------------------
159
- // Gates commands interface
160
- // ---------------------------------------------------------------------------
161
-
162
- /**
163
- * WU-1356: Gates commands configuration type
164
- */
165
- export interface GatesCommands {
166
- test_full: string;
167
- test_docs_only: string;
168
- test_incremental: string;
169
- lint?: string;
170
- typecheck?: string;
171
- format?: string;
172
- migration_verify: string;
173
- }
@@ -1,22 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: LicenseRef-LumenFlow-Proprietary
3
-
4
- /**
5
- * Software Delivery Pack — Policy Barrel
6
- *
7
- * WU-2674 (INIT-058 L3): Cohesion-closed policy bundle moved from
8
- * @lumenflow/core/src/. These modules share tight internal coupling
9
- * (CoverageMode crosses them) and evolve together.
10
- *
11
- * @module packs/software-delivery/policy
12
- */
13
-
14
- export * from './gates-schemas.js';
15
- export * from './resolve-policy.js';
16
- export * from './coverage-gate.js';
17
- export * from './gates-config.js';
18
- export * from './gates-presets.js';
19
- export * from './gates-config-internal.js';
20
- export * from './gates-agent-mode.js';
21
- export * from './gates-coverage.js';
22
- export * from './package-manager-resolver.js';