ex-workflow 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +314 -141
  3. package/dist/adapters/index.cjs +1 -1
  4. package/dist/adapters/index.d.cts +1 -1
  5. package/dist/adapters/index.d.ts +1 -1
  6. package/dist/adapters/index.mjs +1 -1
  7. package/dist/{budget-Cx63FX2K.d.ts → budget-Bd8KpGIr.d.ts} +1 -1
  8. package/dist/{budget-JyNKxP5N.d.cts → budget-CezCinPF.d.cts} +1 -1
  9. package/dist/chunk-6P3OKXSK.mjs +2 -0
  10. package/dist/chunk-6P3OKXSK.mjs.map +1 -0
  11. package/dist/{chunk-5PHK72VM.cjs → chunk-7FS6KWTG.cjs} +2 -2
  12. package/dist/{chunk-5PHK72VM.cjs.map → chunk-7FS6KWTG.cjs.map} +1 -1
  13. package/dist/chunk-APKA5FOU.cjs +2 -0
  14. package/dist/chunk-APKA5FOU.cjs.map +1 -0
  15. package/dist/chunk-ATCJ4IHP.mjs +2 -0
  16. package/dist/{chunk-Z2G7DGDF.mjs.map → chunk-ATCJ4IHP.mjs.map} +1 -1
  17. package/dist/chunk-C2IYMWE6.cjs +3 -0
  18. package/dist/chunk-C2IYMWE6.cjs.map +1 -0
  19. package/dist/chunk-EACZBAP3.cjs +2 -0
  20. package/dist/chunk-EACZBAP3.cjs.map +1 -0
  21. package/dist/chunk-EHBQBXWA.cjs +2 -0
  22. package/dist/{chunk-VXH2FAKV.cjs.map → chunk-EHBQBXWA.cjs.map} +1 -1
  23. package/dist/chunk-FQW2LETC.cjs +2 -0
  24. package/dist/chunk-FQW2LETC.cjs.map +1 -0
  25. package/dist/chunk-FTS75UIU.mjs +2 -0
  26. package/dist/{chunk-U3OXAO67.mjs.map → chunk-FTS75UIU.mjs.map} +1 -1
  27. package/dist/chunk-HCRVWMG4.cjs +2 -0
  28. package/dist/chunk-HCRVWMG4.cjs.map +1 -0
  29. package/dist/chunk-KLWZEXZU.mjs +3 -0
  30. package/dist/chunk-KLWZEXZU.mjs.map +1 -0
  31. package/dist/chunk-MW4HR7HC.mjs +2 -0
  32. package/dist/chunk-MW4HR7HC.mjs.map +1 -0
  33. package/dist/chunk-NDCQTRIV.mjs +2 -0
  34. package/dist/chunk-NDCQTRIV.mjs.map +1 -0
  35. package/dist/{chunk-7IG6EQI4.mjs → chunk-QZ6HD6DE.mjs} +3 -3
  36. package/dist/{chunk-7IG6EQI4.mjs.map → chunk-QZ6HD6DE.mjs.map} +1 -1
  37. package/dist/{chunk-HIHMBMB5.cjs → chunk-RL27372B.cjs} +2 -2
  38. package/dist/{chunk-HIHMBMB5.cjs.map → chunk-RL27372B.cjs.map} +1 -1
  39. package/dist/chunk-SP5MC7RR.mjs +2 -0
  40. package/dist/{chunk-QDMEM62U.mjs.map → chunk-SP5MC7RR.mjs.map} +1 -1
  41. package/dist/chunk-SYLO7FUL.mjs +2 -0
  42. package/dist/{chunk-3KFQPSRX.mjs.map → chunk-SYLO7FUL.mjs.map} +1 -1
  43. package/dist/chunk-T3V5UE34.mjs +2 -0
  44. package/dist/{chunk-UZQV73X7.mjs.map → chunk-T3V5UE34.mjs.map} +1 -1
  45. package/dist/{chunk-FKTCGQYB.cjs → chunk-TS66RAJR.cjs} +2 -2
  46. package/dist/{chunk-FKTCGQYB.cjs.map → chunk-TS66RAJR.cjs.map} +1 -1
  47. package/dist/{chunk-YRATJT7P.cjs → chunk-U23FUYPD.cjs} +4 -4
  48. package/dist/{chunk-YRATJT7P.cjs.map → chunk-U23FUYPD.cjs.map} +1 -1
  49. package/dist/{chunk-CYXVGHQM.cjs → chunk-YJQ5YJ7S.cjs} +2 -2
  50. package/dist/{chunk-CYXVGHQM.cjs.map → chunk-YJQ5YJ7S.cjs.map} +1 -1
  51. package/dist/chunk-YOS77GL3.mjs +2 -0
  52. package/dist/chunk-YOS77GL3.mjs.map +1 -0
  53. package/dist/chunk-YTG2MOD7.cjs +2 -0
  54. package/dist/chunk-YTG2MOD7.cjs.map +1 -0
  55. package/dist/chunk-YZJ6WFH4.mjs +2 -0
  56. package/dist/chunk-YZJ6WFH4.mjs.map +1 -0
  57. package/dist/cli/bin.cjs +1 -1
  58. package/dist/cli/bin.cjs.map +1 -1
  59. package/dist/cli/bin.mjs +1 -1
  60. package/dist/cli/bin.mjs.map +1 -1
  61. package/dist/cli/index.cjs +1 -1
  62. package/dist/cli/index.mjs +1 -1
  63. package/dist/experimentation/index.cjs +2 -0
  64. package/dist/experimentation/index.cjs.map +1 -0
  65. package/dist/experimentation/index.d.cts +28 -0
  66. package/dist/experimentation/index.d.ts +28 -0
  67. package/dist/experimentation/index.mjs +2 -0
  68. package/dist/experimentation/index.mjs.map +1 -0
  69. package/dist/index.cjs +1 -1
  70. package/dist/index.cjs.map +1 -1
  71. package/dist/index.d.cts +4 -4
  72. package/dist/index.d.ts +4 -4
  73. package/dist/index.mjs +1 -1
  74. package/dist/index.mjs.map +1 -1
  75. package/dist/investigation/index.cjs +2 -0
  76. package/dist/investigation/index.cjs.map +1 -0
  77. package/dist/investigation/index.d.cts +13 -0
  78. package/dist/investigation/index.d.ts +13 -0
  79. package/dist/investigation/index.mjs +2 -0
  80. package/dist/investigation/index.mjs.map +1 -0
  81. package/dist/kanban/index.cjs +1 -1
  82. package/dist/kanban/index.d.cts +1 -1
  83. package/dist/kanban/index.d.ts +1 -1
  84. package/dist/kanban/index.mjs +1 -1
  85. package/dist/schema/index.cjs +1 -1
  86. package/dist/schema/index.d.cts +3 -1
  87. package/dist/schema/index.d.ts +3 -1
  88. package/dist/schema/index.mjs +1 -1
  89. package/dist/scrum/index.cjs +1 -1
  90. package/dist/scrum/index.d.cts +3 -3
  91. package/dist/scrum/index.d.ts +3 -3
  92. package/dist/scrum/index.mjs +1 -1
  93. package/dist/types-BScHXlRx.d.cts +509 -0
  94. package/dist/types-BScHXlRx.d.ts +509 -0
  95. package/dist/types.d.cts +1 -388
  96. package/dist/types.d.ts +1 -388
  97. package/dist/waterfall/index.cjs +1 -1
  98. package/dist/waterfall/index.d.cts +1 -1
  99. package/dist/waterfall/index.d.ts +1 -1
  100. package/dist/waterfall/index.mjs +1 -1
  101. package/package.json +43 -20
  102. package/dist/chunk-3KFQPSRX.mjs +0 -2
  103. package/dist/chunk-5TXYMLBF.mjs +0 -3
  104. package/dist/chunk-5TXYMLBF.mjs.map +0 -1
  105. package/dist/chunk-MQWMQ4PD.mjs +0 -2
  106. package/dist/chunk-MQWMQ4PD.mjs.map +0 -1
  107. package/dist/chunk-QDMEM62U.mjs +0 -2
  108. package/dist/chunk-U3OXAO67.mjs +0 -2
  109. package/dist/chunk-UZQV73X7.mjs +0 -2
  110. package/dist/chunk-VXH2FAKV.cjs +0 -2
  111. package/dist/chunk-WOGK54HB.cjs +0 -3
  112. package/dist/chunk-WOGK54HB.cjs.map +0 -1
  113. package/dist/chunk-XMO2RCXB.cjs +0 -2
  114. package/dist/chunk-XMO2RCXB.cjs.map +0 -1
  115. package/dist/chunk-YBHHICTZ.mjs +0 -2
  116. package/dist/chunk-YBHHICTZ.mjs.map +0 -1
  117. package/dist/chunk-YJN4JEJU.cjs +0 -2
  118. package/dist/chunk-YJN4JEJU.cjs.map +0 -1
  119. package/dist/chunk-Z2G7DGDF.mjs +0 -2
package/dist/types.d.ts CHANGED
@@ -1,388 +1 @@
1
- type ItemType = "epic" | "story" | "task" | "bug" | "change-request" | "deliverable" | "question";
2
- type ItemStatus = "todo" | "in_progress" | "blocked" | "review" | "awaiting_human" | "done" | "dropped";
3
- type ClassOfService = "expedite" | "fixed-date" | "standard" | "intangible";
4
- interface Evidence {
5
- kind: string;
6
- ref: string;
7
- by: string;
8
- at: string;
9
- }
10
- interface Blocker {
11
- id: string;
12
- reason: string;
13
- owner: string;
14
- raisedAt: string;
15
- clearedAt?: string;
16
- }
17
- interface Transition {
18
- from: {
19
- stage: string;
20
- status: ItemStatus;
21
- };
22
- to: {
23
- stage: string;
24
- status: ItemStatus;
25
- };
26
- at: string;
27
- by: string;
28
- }
29
- /** Change-request: what the change touches and what it costs (waterfall change control). */
30
- interface ImpactAnalysis {
31
- summary: string;
32
- /** phase ids to reopen when the change is approved (each must be baselined or open) */
33
- reopen: string[];
34
- /** estimated rework weight (story points / size) */
35
- weight: number;
36
- }
37
- interface WorkItem {
38
- id: string;
39
- type: ItemType;
40
- title: string;
41
- description?: string;
42
- dependsOn: string[];
43
- priority?: number;
44
- weight?: number;
45
- deadline?: string;
46
- classOfService?: ClassOfService;
47
- stage: string;
48
- status: ItemStatus;
49
- role?: string;
50
- parent?: string;
51
- acceptance: string[];
52
- evidence: Evidence[];
53
- blockers: Blocker[];
54
- transitions: Transition[];
55
- iteration?: string;
56
- traces?: string[];
57
- tags?: string[];
58
- /** bug / change-request: ids of items whose finished work this invalidates */
59
- affects?: string[];
60
- /** waterfall: Phase.id this item belongs to; questions and follow-ups inherit their parent's */
61
- phase?: string;
62
- /** change-request: impact analysis required before the change control board decides */
63
- impactAnalysis?: ImpactAnalysis;
64
- }
65
- /** Fields `editItem` / `exwf edit` may change. */
66
- type ItemPatch = Partial<Omit<WorkItem, "id" | "stage" | "status" | "transitions" | "evidence" | "blockers">>;
67
- /** Fields a caller supplies to addItem; the rest are defaulted. */
68
- type NewItem = Pick<WorkItem, "id" | "title"> & Partial<Omit<WorkItem, "id" | "title" | "stage" | "status" | "evidence" | "blockers" | "transitions">> & {
69
- stage?: string;
70
- };
71
- type Policy = {
72
- kind: "evidence";
73
- evidenceKind: string;
74
- } | {
75
- kind: "acceptance-written";
76
- } | {
77
- kind: "estimate-present";
78
- } | {
79
- kind: "no-open-blockers";
80
- } | {
81
- kind: "dependencies-done";
82
- } | {
83
- kind: "custom";
84
- id: string;
85
- description: string;
86
- };
87
- type GateRequirement = "human" | {
88
- capability: string;
89
- };
90
- interface Gate {
91
- id: string;
92
- requires: GateRequirement[];
93
- evidence: string[];
94
- onFail: {
95
- action: "block";
96
- } | {
97
- action: "return-to";
98
- stage: string;
99
- };
100
- }
101
- interface Stage {
102
- id: string;
103
- name: string;
104
- wipLimit?: number;
105
- entryPolicy: Policy[];
106
- exitPolicy: Policy[];
107
- gate?: Gate;
108
- commitmentPoint?: boolean;
109
- deliveryPoint?: boolean;
110
- /** Items entering this stage wait for a reviewer (status "review") instead of "todo". */
111
- review?: boolean;
112
- }
113
- interface Budget {
114
- tokens?: number;
115
- turns?: number;
116
- wallclockMs?: number;
117
- }
118
- interface Spent {
119
- tokens: number;
120
- turns: number;
121
- wallclockMs: number;
122
- }
123
- interface Iteration {
124
- id: string;
125
- goal: string;
126
- budget: Budget;
127
- spent: Spent;
128
- startedAt: string;
129
- endedAt?: string;
130
- committed: string[];
131
- carryover: string[];
132
- outcome?: "completed" | "cancelled";
133
- /** Budget is exhausted; in-flight items may finish, nothing new is dispatched. */
134
- closing?: boolean;
135
- }
136
- type ModelTier = "small" | "medium" | "large";
137
- type Capability = "order-backlog" | "define-acceptance" | "facilitate" | "deliver" | "review" | "verify" | "approve-gate" | "manage-flow" | "control-change" | "escalate";
138
- interface Role {
139
- id: string;
140
- name: string;
141
- modelTier: ModelTier;
142
- resourceClass?: string;
143
- maxConcurrent?: number;
144
- capabilities: Capability[];
145
- canApprove: string[];
146
- inputs: string[];
147
- outputs: string[];
148
- do_not: string[];
149
- constraints?: string[];
150
- }
151
- type Verdict = "done" | "blocked" | "needs-review" | "rework" | "escalate";
152
- interface Handoff {
153
- item: string;
154
- role: string;
155
- produced: Array<{
156
- kind: string;
157
- ref: string;
158
- }>;
159
- notes: string;
160
- do_not: string[];
161
- open_questions: string[];
162
- verdict?: Verdict;
163
- /** new work discovered while doing this item; lands in the FIRST stage (backlog), never in the iteration */
164
- follow_ups?: NewItem[];
165
- /** raised by the worker the moment it happens, e.g. "spec was vague here" */
166
- lessons?: Array<{
167
- text: string;
168
- scope: Lesson["scope"];
169
- }>;
170
- }
171
- interface Accounting {
172
- item: string;
173
- role: string;
174
- model: string;
175
- tokensIn: number;
176
- tokensOut: number;
177
- durationMs: number;
178
- startedAt: string;
179
- endedAt: string;
180
- /** The tokens are a placeholder the host will correct with correctAccounting, not the host's usage figures. */
181
- estimate?: boolean;
182
- }
183
- interface Event {
184
- seq: number;
185
- at: string;
186
- type: string;
187
- by: string;
188
- payload: unknown;
189
- }
190
- interface PendingHuman {
191
- id: string;
192
- kind: "gate" | "decision";
193
- item?: string;
194
- gate?: string;
195
- question: string;
196
- raisedAt: string;
197
- }
198
- type LessonChange = {
199
- kind: "agreement";
200
- text: string;
201
- replaces?: string;
202
- } | {
203
- kind: "dod";
204
- policy: Policy;
205
- } | {
206
- kind: "backlog";
207
- item: NewItem;
208
- } | {
209
- kind: "skill";
210
- note: string;
211
- };
212
- interface Lesson {
213
- id: string;
214
- at: string;
215
- text: string;
216
- scope: "policy" | "skill" | "memory" | "spec" | "review";
217
- status: "raised" | "adopted" | "dismissed";
218
- from?: string;
219
- item?: string;
220
- suggestedChange?: LessonChange;
221
- }
222
- /** A deliverable recorded on a phase (gateReview input or engine-generated). */
223
- interface Produced {
224
- kind: string;
225
- ref: string;
226
- by: string;
227
- at: string;
228
- }
229
- interface Phase {
230
- id: string;
231
- name: string;
232
- deliverables: string[];
233
- gate: Gate;
234
- status: "pending" | "open" | "baselined" | "reopened";
235
- /** planned budget; spent is tracked on the Iteration kickoff opens for the phase */
236
- budget?: Budget;
237
- /** phase-level deliverables (item evidence counts too) */
238
- produced?: Produced[];
239
- }
240
- interface Baseline {
241
- phase: string;
242
- version: number;
243
- at: string;
244
- approvedBy: string[];
245
- itemSnapshot: Record<string, WorkItem>;
246
- }
247
- type MethodologyName = "scrum" | "kanban" | "waterfall";
248
- interface WorkflowState {
249
- version: 1;
250
- methodology: MethodologyName;
251
- config: unknown;
252
- items: Record<string, WorkItem>;
253
- stages: Stage[];
254
- roles: Record<string, Role>;
255
- iterations: Iteration[];
256
- phases?: Phase[];
257
- baseline?: Baseline;
258
- /** waterfall: every baseline ever taken, oldest first; `baseline` is the last one */
259
- baselines?: Baseline[];
260
- events: Event[];
261
- accounting: Accounting[];
262
- pending: PendingHuman[];
263
- lessons: Lesson[];
264
- /** adopted working agreements; synthesizeBrief appends them to invariants */
265
- agreements: string[];
266
- }
267
- interface Action {
268
- type: string;
269
- by: string;
270
- payload?: unknown;
271
- }
272
- interface Violation {
273
- rule: string;
274
- severity: "error" | "warning";
275
- item?: string;
276
- message: string;
277
- fix: string;
278
- }
279
- interface Rule {
280
- id: string;
281
- severity: "error" | "warning";
282
- check(state: WorkflowState, action: Action): Violation[];
283
- }
284
- interface ApplyResult {
285
- state: WorkflowState;
286
- warnings: Violation[];
287
- }
288
- interface Brief {
289
- item: WorkItem;
290
- role: Role;
291
- modelTier: ModelTier;
292
- invariants: string[];
293
- do_not: string[];
294
- acceptance: string[];
295
- upstream: Array<{
296
- item: string;
297
- produced: Handoff["produced"];
298
- notes: string;
299
- }>;
300
- /** earlier completions of THIS item (rework feedback) */
301
- priorHandoffs: Array<{
302
- role: string;
303
- verdict: Verdict;
304
- notes: string;
305
- produced: Handoff["produced"];
306
- at: string;
307
- }>;
308
- /** open bug/change-request items whose `affects` touches this item or its dependsOn */
309
- relatedBugs: Array<{
310
- id: string;
311
- title: string;
312
- affects: string[];
313
- }>;
314
- budgetRemaining: Budget;
315
- gateAhead?: Gate;
316
- /** for a question item: the escalating item's last handoff */
317
- parent?: {
318
- item: string;
319
- role: string;
320
- notes: string;
321
- produced: Handoff["produced"];
322
- open_questions: string[];
323
- do_not: string[];
324
- };
325
- }
326
- type CoreTerm = "backlog" | "item" | "stage" | "iteration" | "increment" | "ceremony" | "gate";
327
- type CeremonyInput = {
328
- by: string;
329
- now?: string;
330
- } & Record<string, unknown>;
331
- type Ceremony = (state: WorkflowState, input: CeremonyInput) => ApplyResult;
332
- interface PlannerOptions {
333
- schedulerMode: "level" | "throughput";
334
- /** Stage a todo item is pulled into when dispatched; a function decides per item; omitted/undefined = stay in its current stage. */
335
- dispatchStage?: string | ((item: WorkItem) => string | undefined);
336
- concurrencyCap?: number;
337
- fairnessPolicy?: "none" | "aging";
338
- maxDeferralRounds?: number;
339
- deadlineStrategy?: "earliest-first" | "latest-first";
340
- weightStrategy?: "higher-first" | "lower-first";
341
- /** Priority the planner orders by; defaults to item.priority. */
342
- priorityOf?(item: WorkItem): number | undefined;
343
- /** Orders items of equal priority (after deadline/weight strategies); e.g. class of service, then age. */
344
- tieBreaker?(a: WorkItem, b: WorkItem): number;
345
- /** Statuses that occupy a stage's wipLimit slot; default ["in_progress"]. */
346
- wipCounts?: ItemStatus[];
347
- /** Per-item replacement for the target stage's wipLimit (e.g. an expedite bypass); undefined = no limit. */
348
- wipLimitOf?(stage: Stage, item: WorkItem): number | undefined;
349
- /** Role id to dispatch a todo item to (e.g. the phase's deliverer); undefined = default (item.role, then reviewer/deliverer by capability). */
350
- roleFor?(item: WorkItem): string | undefined;
351
- /** How estimateTokens prices a candidate; default "per-weight". */
352
- estimateMode?: "per-weight" | "per-call";
353
- /** Tokens per weight unit when no accounting history exists; default 20000. PlanOptions.fallbackTokensPerWeight wins. */
354
- fallbackTokensPerWeight?: number;
355
- }
356
- interface Methodology<C = unknown> {
357
- name: MethodologyName;
358
- vocabulary: Record<CoreTerm, string>;
359
- validateConfig(config: unknown): C;
360
- defaultStages(config: C): Stage[];
361
- defaultRoles(config: C): Role[];
362
- requiredCapabilities: Capability[];
363
- exclusiveCapabilities: Capability[];
364
- plannerOptions(state: WorkflowState): PlannerOptions;
365
- candidates(state: WorkflowState): WorkItem[];
366
- invariants(state: WorkflowState, item: WorkItem): string[];
367
- ceremonies: Record<string, Ceremony>;
368
- rules: Rule[];
369
- metrics(state: WorkflowState): Record<string, number | number[] | Record<string, number>>;
370
- humanDefaults: {
371
- gates: "all" | "none" | string[];
372
- };
373
- /** Called after complete(); lets the methodology react (e.g. close a sprint when the budget is gone). */
374
- afterComplete?(state: WorkflowState, itemId: string, now: string): WorkflowState;
375
- /** Config keys that cannot change after init (changeConfig refuses them). */
376
- lockedConfigKeys?: string[];
377
- /** Called by changeConfig after the new config is stored; keeps derived state (e.g. stage policies) in step. */
378
- afterConfigChange?(state: WorkflowState, now: string): WorkflowState;
379
- /** Methodology-specific status for hosts (e.g. cadences due); printed by `exwf status`. */
380
- report?(state: WorkflowState): Record<string, unknown>;
381
- /** Called by decide() after a pending entry is resolved; lets the methodology act on it (e.g. baseline a phase gate, apply a change-request decision). */
382
- afterDecide?(state: WorkflowState, entry: PendingHuman, decision: "approve" | "reject", by: string, note: string, now: string): WorkflowState;
383
- }
384
- type ErrorCode = "unknown-item" | "duplicate-item" | "unknown-role" | "duplicate-role" | "unknown-stage" | "missing-capability" | "exclusive-capability" | "role-has-open-items" | "invalid-transition" | "policy-unmet" | "gate-unmet"
385
- /** reserved: never thrown; kept for type compatibility */
386
- | "conflict-of-interest" | "handoff-invalid" | "accounting-invalid" | "rule-violation" | "planner-error" | "no-op" | "unknown-pending" | "unknown-ceremony" | "state-version" | "config-invalid" | "budget-exhausted" | "invalid-input";
387
-
388
- export type { Accounting, Action, ApplyResult, Baseline, Blocker, Brief, Budget, Capability, Ceremony, CeremonyInput, ClassOfService, CoreTerm, ErrorCode, Event, Evidence, Gate, GateRequirement, Handoff, ImpactAnalysis, ItemPatch, ItemStatus, ItemType, Iteration, Lesson, LessonChange, Methodology, MethodologyName, ModelTier, NewItem, PendingHuman, Phase, PlannerOptions, Policy, Produced, Role, Rule, Spent, Stage, Transition, Verdict, Violation, WorkItem, WorkflowState };
1
+ export { A as Accounting, y as Action, x as ApplyResult, z as Baseline, D as Blocker, B as Brief, a as Budget, C as Capability, f as Ceremony, n as CeremonyInput, m as ClassOfService, k as CoreTerm, s as ErrorCode, o as Event, u as Evidence, G as Gate, p as GateRequirement, H as Handoff, F as ImpactAnalysis, v as ItemPatch, j as ItemStatus, J as ItemType, w as Iteration, L as Lesson, K as LessonChange, M as Methodology, t as MethodologyName, Q as ModelTier, N as NewItem, r as PendingHuman, q as Phase, U as PlannerOptions, P as Policy, X as Produced, R as Role, g as Rule, Y as Spent, S as Stage, T as Transition, Z as Verdict, V as Violation, l as WorkItem, W as WorkflowState } from './types-BScHXlRx.js';
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkFKTCGQYB_cjs=require('../chunk-FKTCGQYB.cjs');require('../chunk-VXH2FAKV.cjs'),require('../chunk-XMO2RCXB.cjs'),require('../chunk-S3BXVHO7.cjs');Object.defineProperty(exports,"CHANGE_GATE",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.e}});Object.defineProperty(exports,"DEFAULT_DELIVERABLES",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.b}});Object.defineProperty(exports,"DEFAULT_DELIVER_BY",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.c}});Object.defineProperty(exports,"DEFAULT_PHASE_IDS",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.a}});Object.defineProperty(exports,"DONE",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.k}});Object.defineProperty(exports,"GATE_ID",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.d}});Object.defineProperty(exports,"REVIEW",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.j}});Object.defineProperty(exports,"WATERFALL_VOCABULARY",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.K}});Object.defineProperty(exports,"WORK",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.i}});Object.defineProperty(exports,"approveChange",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.z}});Object.defineProperty(exports,"baselinePhase",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.x}});Object.defineProperty(exports,"configOf",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.g}});Object.defineProperty(exports,"currentPhase",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.s}});Object.defineProperty(exports,"defaultPhases",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.f}});Object.defineProperty(exports,"deliverRoleFor",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.L}});Object.defineProperty(exports,"getPhase",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.o}});Object.defineProperty(exports,"isFrozen",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.t}});Object.defineProperty(exports,"itemsInPhase",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.q}});Object.defineProperty(exports,"lastToPhase",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.w}});Object.defineProperty(exports,"missingDeliverables",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.v}});Object.defineProperty(exports,"missingTraces",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.C}});Object.defineProperty(exports,"openPhase",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.r}});Object.defineProperty(exports,"phaseIndex",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.n}});Object.defineProperty(exports,"phaseOf",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.p}});Object.defineProperty(exports,"phaseReport",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.M}});Object.defineProperty(exports,"phasesOf",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.l}});Object.defineProperty(exports,"producedKinds",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.u}});Object.defineProperty(exports,"rejectChange",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.A}});Object.defineProperty(exports,"reopenPhases",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.y}});Object.defineProperty(exports,"traceabilityMatrix",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.B}});Object.defineProperty(exports,"validateWaterfallConfig",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.h}});Object.defineProperty(exports,"wantPhase",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.D}});Object.defineProperty(exports,"waterfall",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.N}});Object.defineProperty(exports,"waterfallAfterDecide",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.F}});Object.defineProperty(exports,"waterfallCeremonies",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.E}});Object.defineProperty(exports,"waterfallMetrics",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.G}});Object.defineProperty(exports,"waterfallRoles",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.H}});Object.defineProperty(exports,"waterfallRules",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.I}});Object.defineProperty(exports,"waterfallStages",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.J}});Object.defineProperty(exports,"withPhases",{enumerable:true,get:function(){return chunkFKTCGQYB_cjs.m}});//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunkTS66RAJR_cjs=require('../chunk-TS66RAJR.cjs');require('../chunk-EHBQBXWA.cjs'),require('../chunk-HCRVWMG4.cjs'),require('../chunk-EACZBAP3.cjs'),require('../chunk-S3BXVHO7.cjs');Object.defineProperty(exports,"CHANGE_GATE",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.e}});Object.defineProperty(exports,"DEFAULT_DELIVERABLES",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.b}});Object.defineProperty(exports,"DEFAULT_DELIVER_BY",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.c}});Object.defineProperty(exports,"DEFAULT_PHASE_IDS",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.a}});Object.defineProperty(exports,"DONE",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.k}});Object.defineProperty(exports,"GATE_ID",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.d}});Object.defineProperty(exports,"REVIEW",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.j}});Object.defineProperty(exports,"WATERFALL_VOCABULARY",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.K}});Object.defineProperty(exports,"WORK",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.i}});Object.defineProperty(exports,"approveChange",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.z}});Object.defineProperty(exports,"baselinePhase",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.x}});Object.defineProperty(exports,"configOf",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.g}});Object.defineProperty(exports,"currentPhase",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.s}});Object.defineProperty(exports,"defaultPhases",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.f}});Object.defineProperty(exports,"deliverRoleFor",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.L}});Object.defineProperty(exports,"getPhase",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.o}});Object.defineProperty(exports,"isFrozen",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.t}});Object.defineProperty(exports,"itemsInPhase",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.q}});Object.defineProperty(exports,"lastToPhase",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.w}});Object.defineProperty(exports,"missingDeliverables",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.v}});Object.defineProperty(exports,"missingTraces",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.C}});Object.defineProperty(exports,"openPhase",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.r}});Object.defineProperty(exports,"phaseIndex",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.n}});Object.defineProperty(exports,"phaseOf",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.p}});Object.defineProperty(exports,"phaseReport",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.M}});Object.defineProperty(exports,"phasesOf",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.l}});Object.defineProperty(exports,"producedKinds",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.u}});Object.defineProperty(exports,"rejectChange",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.A}});Object.defineProperty(exports,"reopenPhases",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.y}});Object.defineProperty(exports,"traceabilityMatrix",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.B}});Object.defineProperty(exports,"validateWaterfallConfig",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.h}});Object.defineProperty(exports,"wantPhase",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.D}});Object.defineProperty(exports,"waterfall",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.N}});Object.defineProperty(exports,"waterfallAfterDecide",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.F}});Object.defineProperty(exports,"waterfallCeremonies",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.E}});Object.defineProperty(exports,"waterfallMetrics",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.G}});Object.defineProperty(exports,"waterfallRoles",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.H}});Object.defineProperty(exports,"waterfallRules",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.I}});Object.defineProperty(exports,"waterfallStages",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.J}});Object.defineProperty(exports,"withPhases",{enumerable:true,get:function(){return chunkTS66RAJR_cjs.m}});//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import { Gate, Budget, GateRequirement, WorkflowState, Phase, WorkItem, Stage, Role, Rule, CeremonyInput, PendingHuman, Methodology, Ceremony, CoreTerm } from '../types.cjs';
1
+ import { G as Gate, a as Budget, p as GateRequirement, W as WorkflowState, q as Phase, l as WorkItem, S as Stage, R as Role, g as Rule, n as CeremonyInput, r as PendingHuman, M as Methodology, f as Ceremony, k as CoreTerm } from '../types-BScHXlRx.cjs';
2
2
 
3
3
  interface WaterfallPhaseConfig {
4
4
  id: string;
@@ -1,4 +1,4 @@
1
- import { Gate, Budget, GateRequirement, WorkflowState, Phase, WorkItem, Stage, Role, Rule, CeremonyInput, PendingHuman, Methodology, Ceremony, CoreTerm } from '../types.js';
1
+ import { G as Gate, a as Budget, p as GateRequirement, W as WorkflowState, q as Phase, l as WorkItem, S as Stage, R as Role, g as Rule, n as CeremonyInput, r as PendingHuman, M as Methodology, f as Ceremony, k as CoreTerm } from '../types-BScHXlRx.js';
2
2
 
3
3
  interface WaterfallPhaseConfig {
4
4
  id: string;
@@ -1,2 +1,2 @@
1
- export{e as CHANGE_GATE,b as DEFAULT_DELIVERABLES,c as DEFAULT_DELIVER_BY,a as DEFAULT_PHASE_IDS,k as DONE,d as GATE_ID,j as REVIEW,K as WATERFALL_VOCABULARY,i as WORK,z as approveChange,x as baselinePhase,g as configOf,s as currentPhase,f as defaultPhases,L as deliverRoleFor,o as getPhase,t as isFrozen,q as itemsInPhase,w as lastToPhase,v as missingDeliverables,C as missingTraces,r as openPhase,n as phaseIndex,p as phaseOf,M as phaseReport,l as phasesOf,u as producedKinds,A as rejectChange,y as reopenPhases,B as traceabilityMatrix,h as validateWaterfallConfig,D as wantPhase,N as waterfall,F as waterfallAfterDecide,E as waterfallCeremonies,G as waterfallMetrics,H as waterfallRoles,I as waterfallRules,J as waterfallStages,m as withPhases}from'../chunk-3KFQPSRX.mjs';import'../chunk-U3OXAO67.mjs';import'../chunk-YBHHICTZ.mjs';import'../chunk-2FRRD6A3.mjs';//# sourceMappingURL=index.mjs.map
1
+ export{e as CHANGE_GATE,b as DEFAULT_DELIVERABLES,c as DEFAULT_DELIVER_BY,a as DEFAULT_PHASE_IDS,k as DONE,d as GATE_ID,j as REVIEW,K as WATERFALL_VOCABULARY,i as WORK,z as approveChange,x as baselinePhase,g as configOf,s as currentPhase,f as defaultPhases,L as deliverRoleFor,o as getPhase,t as isFrozen,q as itemsInPhase,w as lastToPhase,v as missingDeliverables,C as missingTraces,r as openPhase,n as phaseIndex,p as phaseOf,M as phaseReport,l as phasesOf,u as producedKinds,A as rejectChange,y as reopenPhases,B as traceabilityMatrix,h as validateWaterfallConfig,D as wantPhase,N as waterfall,F as waterfallAfterDecide,E as waterfallCeremonies,G as waterfallMetrics,H as waterfallRoles,I as waterfallRules,J as waterfallStages,m as withPhases}from'../chunk-SYLO7FUL.mjs';import'../chunk-FTS75UIU.mjs';import'../chunk-NDCQTRIV.mjs';import'../chunk-6P3OKXSK.mjs';import'../chunk-2FRRD6A3.mjs';//# sourceMappingURL=index.mjs.map
2
2
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ex-workflow",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Methodology engine for AI teams: Scrum, Kanban and Waterfall as data-driven state machines on top of ex-flow",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,7 +19,6 @@
19
19
  "ai-agents",
20
20
  "ex-flow"
21
21
  ],
22
- "packageManager": "pnpm@10.24.0",
23
22
  "engines": {
24
23
  "node": ">=18"
25
24
  },
@@ -110,6 +109,26 @@
110
109
  "types": "./dist/types.d.cts",
111
110
  "default": "./dist/types.cjs"
112
111
  }
112
+ },
113
+ "./investigation": {
114
+ "import": {
115
+ "types": "./dist/investigation/index.d.ts",
116
+ "default": "./dist/investigation/index.mjs"
117
+ },
118
+ "require": {
119
+ "types": "./dist/investigation/index.d.cts",
120
+ "default": "./dist/investigation/index.cjs"
121
+ }
122
+ },
123
+ "./experimentation": {
124
+ "import": {
125
+ "types": "./dist/experimentation/index.d.ts",
126
+ "default": "./dist/experimentation/index.mjs"
127
+ },
128
+ "require": {
129
+ "types": "./dist/experimentation/index.d.cts",
130
+ "default": "./dist/experimentation/index.cjs"
131
+ }
113
132
  }
114
133
  },
115
134
  "typesVersions": {
@@ -134,6 +153,12 @@
134
153
  ],
135
154
  "types": [
136
155
  "dist/types.d.ts"
156
+ ],
157
+ "investigation": [
158
+ "dist/investigation/index.d.ts"
159
+ ],
160
+ "experimentation": [
161
+ "dist/experimentation/index.d.ts"
137
162
  ]
138
163
  }
139
164
  },
@@ -143,23 +168,6 @@
143
168
  "LICENSE",
144
169
  "CHANGELOG.md"
145
170
  ],
146
- "scripts": {
147
- "test": "node scripts/run-tests.mjs",
148
- "build": "tsup",
149
- "minify": "tsup --minify",
150
- "lint": "oxlint src test",
151
- "format": "oxfmt src test",
152
- "format:check": "oxfmt --check src test",
153
- "typecheck": "tsc --noEmit",
154
- "size": "node scripts/size.mjs",
155
- "check:dist": "node scripts/check-dist.mjs && node scripts/check-exports.mjs",
156
- "schema:gen": "node scripts/gen-schema.mjs",
157
- "schema:check": "node scripts/gen-schema.mjs --check",
158
- "ci": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm schema:check && pnpm test && pnpm minify && pnpm check:dist && pnpm size",
159
- "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
160
- "prepublishOnly": "pnpm run ci",
161
- "prepare": "husky"
162
- },
163
171
  "dependencies": {
164
172
  "ex-flow": "^1.1.0",
165
173
  "exsorted": "^1.2.3"
@@ -173,5 +181,20 @@
173
181
  "tsup": "^8.5.1",
174
182
  "tsx": "^4.20.6",
175
183
  "typescript": "^5.9.3"
184
+ },
185
+ "scripts": {
186
+ "test": "node scripts/run-tests.mjs",
187
+ "build": "tsup",
188
+ "minify": "tsup --minify",
189
+ "lint": "oxlint src test",
190
+ "format": "oxfmt src test",
191
+ "format:check": "oxfmt --check src test",
192
+ "typecheck": "tsc --noEmit",
193
+ "size": "node scripts/size.mjs",
194
+ "check:dist": "node scripts/check-dist.mjs && node scripts/check-exports.mjs",
195
+ "schema:gen": "node scripts/gen-schema.mjs",
196
+ "schema:check": "node scripts/gen-schema.mjs --check",
197
+ "ci": "pnpm format:check && pnpm lint && pnpm typecheck && pnpm schema:check && pnpm test && pnpm minify && pnpm check:dist && pnpm size",
198
+ "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\""
176
199
  }
177
- }
200
+ }
@@ -1,2 +0,0 @@
1
- import {a as a$1,b as b$2}from'./chunk-U3OXAO67.mjs';import {c,u,x,o,n,i,j as j$1,I,R as R$1,N,Y as Y$1,a,K as K$1,M as M$1}from'./chunk-YBHHICTZ.mjs';import {b as b$1,c as c$1}from'./chunk-2FRRD6A3.mjs';import {timSort}from'exsorted';var De=["requirements","design","implementation","verification","deployment","maintenance"],pe={requirements:["srs"],design:["design-doc","interface-spec"],implementation:["code-baseline"],verification:["test-report","traceability-matrix"],deployment:["release-notes","deployment-record"],maintenance:["change-log"]},fe={requirements:"business-analyst",design:"architect",deployment:"release-manager"},ue=e=>`${e}-gate`,me="change-control",je=["order-backlog","define-acceptance","facilitate","deliver","review","verify","approve-gate","manage-flow","control-change","escalate"],Be=e=>e.charAt(0).toUpperCase()+e.slice(1);function Me(){return De.map(e=>{let t={id:e,name:Be(e),deliverables:[...pe[e]??[]],gate:{id:ue(e),requires:[{capability:"approve-gate"}],evidence:[],onFail:{action:"block"}}},n=fe[e];return n!==void 0&&(t.deliverBy=n),t})}function w(e){return e.config}var G=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),re=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.trim()!=="");function Ye(e,t){if(e===void 0)return;G(e)||b$1("config-invalid",`${t}.budget must be an object`,'e.g. { "tokens": 400000 }');let n={};for(let a of ["tokens","turns","wallclockMs"]){let p=e[a];p!==void 0&&((typeof p!="number"||!Number.isFinite(p)||p<0)&&b$1("config-invalid",`${t}.budget.${a} must be a non-negative number`,"omit it for no limit"),n[a]=p);}return n}function Ge(e,t){return (!Array.isArray(e)||e.length===0)&&b$1("config-invalid",`${t} must be a non-empty array of "human" | { capability }`,'e.g. ["human", { "capability": "approve-gate" }]'),e.map(n=>n==="human"?"human":G(n)&&typeof n.capability=="string"&&je.includes(n.capability)?{capability:n.capability}:b$1("config-invalid",`${t} entry ${JSON.stringify(n)} is not "human" or a known capability`,`use "human" or { "capability": one of ${je.join(", ")} }`))}function Ee(e,t,n){let a=`waterfall config.phases[${t}]`;G(e)||b$1("config-invalid",`${a} must be an object`,'e.g. { "id": "design" }'),c$1(e.id,`${a}.id`);let p=e.id,c=e.deliverables??pe[p]??[];re(c)||b$1("config-invalid",`${a}.deliverables must be a string[] of evidence kinds`,'e.g. ["srs"]');let o;if(e.gate===void 0)o={id:ue(p),requires:[{capability:"approve-gate"}],evidence:[],onFail:{action:"block"}};else {let l=e.gate;(!G(l)||typeof l.id!="string"||l.id.trim()==="")&&b$1("config-invalid",`${a}.gate must be a Gate with an id`,'e.g. { "id": "design-gate", "requires": [{ "capability": "approve-gate" }], "evidence": [] }');let f=l.evidence??[];re(f)||b$1("config-invalid",`${a}.gate.evidence must be a string[]`,"list evidence kinds or omit it"),o={id:l.id,requires:Ge(l.requires??[{capability:"approve-gate"}],`${a}.gate.requires`),evidence:[...f],onFail:{action:"block"}};}n(p)&&!o.requires.includes("human")&&(o.requires=["human",...o.requires]);let d={id:p,name:typeof e.name=="string"&&e.name.trim()!==""?e.name:Be(p),deliverables:[...c],gate:o},i=Ye(e.budget,a);i!==void 0&&(d.budget=i);let s=e.deliverBy??fe[p];return s!==void 0&&((typeof s!="string"||s.trim()==="")&&b$1("config-invalid",`${a}.deliverBy must be a role id`,"name the role that delivers this phase or omit it"),d.deliverBy=s),d}function ge(e){let t=e??{};t.phases!==void 0&&!Array.isArray(t.phases)&&b$1("config-invalid","waterfall config.phases must be an array of phases","omit phases for the six classic phases");let n=t.humanGates??"all";n!=="all"&&!re(n)&&b$1("config-invalid",'waterfall config.humanGates must be "all" or a string[] of phase ids','omit it for "all"');let a=n==="all"?()=>true:r=>n.includes(r),p=t.phases===void 0?Me().map((r,m)=>Ee(r,m,a)):t.phases.map((r,m)=>Ee(r,m,a));p.length===0&&b$1("config-invalid","waterfall config.phases needs at least one phase",'e.g. [{ "id": "requirements" }]');let c=p.map(r=>r.id),o=c.find((r,m)=>c.indexOf(r)!==m);if(o!==void 0&&b$1("config-invalid",`duplicate phase id "${o}"`,"give every phase a unique id"),n!=="all")for(let r of n)c.includes(r)||b$1("config-invalid",`waterfall config.humanGates names unknown phase "${r}"`,`phases are: ${c.join(", ")}`);let d=t.changeControl??{};G(d)||b$1("config-invalid","waterfall config.changeControl must be an object",'e.g. { "requiresImpactAnalysis": true, "approvers": ["human"] }'),d.requiresImpactAnalysis!==void 0&&typeof d.requiresImpactAnalysis!="boolean"&&b$1("config-invalid","waterfall config.changeControl.requiresImpactAnalysis must be a boolean","omit it for true");let i={requiresImpactAnalysis:d.requiresImpactAnalysis===void 0?true:d.requiresImpactAnalysis,approvers:Ge(d.approvers??["human",{capability:"control-change"}],"waterfall config.changeControl.approvers")},s=t.traceability,l;if(s===void 0)l=c.includes("requirements")&&c.includes("design")&&c.includes("verification")?{from:"requirements",to:["design","verification"]}:{from:c[0],to:[]};else {(!G(s)||typeof s.from!="string"||!c.includes(s.from))&&b$1("config-invalid","waterfall config.traceability.from must be a phase id",`phases are: ${c.join(", ")}`);let r=s.to??[];re(r)||b$1("config-invalid","waterfall config.traceability.to must be a string[] of phase ids",`phases are: ${c.join(", ")}`);for(let m of r)c.includes(m)||b$1("config-invalid",`waterfall config.traceability.to names unknown phase "${m}"`,`phases are: ${c.join(", ")}`),c.indexOf(m)<=c.indexOf(s.from)&&b$1("config-invalid",`waterfall config.traceability.to phase "${m}" must come after "${s.from}"`,"trace forward only: from an earlier phase to later ones");l={from:s.from,to:[...r]};}let f=t.fallbackTokensPerWeight;f!==void 0&&(typeof f!="number"||!Number.isFinite(f)||f<=0)&&b$1("config-invalid","waterfall config.fallbackTokensPerWeight must be a positive finite number","omit it for the default 20000");let u={phases:p,changeControl:i,traceability:l,humanGates:n==="all"?"all":[...n]};return f!==void 0&&(u.fallbackTokensPerWeight=f),u}var L="work",V="review",H="done";function b(e){return e.phases?e.phases:w(e).phases.map(t=>{let n={id:t.id,name:t.name,deliverables:[...t.deliverables],gate:t.gate,status:"pending"};return t.budget&&(n.budget=t.budget),n})}function j(e,t){return {...e,phases:t}}function E(e,t){let n=b(e).findIndex(a=>a.id===t);return n<0&&b$1("config-invalid",`unknown phase "${t}"`,`phases are: ${b(e).map(a=>a.id).join(" \u2192 ")}`),n}function _(e,t){return b(e)[E(e,t)]}function q(e,t){let n=new Set,a=t;for(;a&&!n.has(a.id);){if(a.phase!==void 0)return a.phase;n.add(a.id),a=a.parent!==void 0&&Object.hasOwn(e.items,a.parent)?e.items[a.parent]:void 0;}}function P(e,t){return Object.values(e.items).filter(n=>n.status!=="dropped"&&q(e,n)===t)}function D(e){return b(e).find(t=>t.status==="open")}function he(e){return b(e).find(t=>t.status!=="baselined")}function Je(e,t){let n=q(e,t);return n!==void 0&&b(e).find(a=>a.id===n)?.status==="baselined"}function _e(e,t){let n=new Set((t.produced??[]).map(a=>a.kind));for(let a of P(e,t.id))for(let p of a.evidence)n.add(p.kind);return n}function U(e,t,n=[]){let a=_e(e,t);for(let c of n)a.add(c);let p=[];for(let c of [...t.deliverables,...t.gate.evidence])p.includes(c)||p.push(c);return p.filter(c=>!a.has(c))}function B(e){let t=b(e).map(a=>a.id),n=w(e).traceability.to.filter(a=>t.includes(a));if(n.length!==0)return n.reduce((a,p)=>t.indexOf(a)>=t.indexOf(p)?a:p)}function Fe(e,t,n,a){let p=R$1(e);return !p||!p.id.startsWith(`${t}#`)?e:{...e,iterations:e.iterations.map(c=>c.id===p.id?{...c,endedAt:a,outcome:n}:c)}}function ae(e,t,n,a){let p=_(e,t);p.status!=="open"&&b$1("invalid-transition",`phase "${t}" is ${p.status}, not open`,p.status==="baselined"?"it is already baselined; a change-request reopens it":"kickoff the phase first");let c$1=P(e,t),o={};for(let l of c$1)o[l.id]=l;let d=(e.baselines??[]).filter(l=>l.phase===t).length,i={phase:t,version:d+1,at:a,approvedBy:n,itemSnapshot:o},s=j(e,b(e).map(l=>l.id===t?{...l,status:"baselined"}:l));return s={...s,baseline:i,baselines:[...s.baselines??[],i]},s=Fe(s,t,"completed",a),c(s,"phase.baselined",n[n.length-1]??"system",{phase:t,version:i.version,approvedBy:n,items:c$1.map(l=>l.id)},a)}function ye(e,t,n){let a=[];for(let d of t){let i=_(e,d);i.status==="pending"&&b$1("invalid-input",`phase "${d}" was never baselined; there is nothing to reopen`,"remove it from impactAnalysis.reopen"),i.status==="baselined"&&!a.includes(d)&&a.push(d);}let p=b(e).map(d=>a.includes(d.id)?{...d,status:"reopened"}:d),c=null,o=e;if(a.length){let d=Math.min(...a.map(s=>E(e,s))),i=p.find((s,l)=>s.status==="open"&&l>d);i&&(c=i.id,p=p.map(s=>s.id===i.id?{...s,status:"reopened"}:s),o=Fe(o,i.id,"cancelled",n));}return {state:j(o,p),reopened:a,suspended:c}}function z(e,t,n,a,p){let c$1=u(e,t),o=c$1.impactAnalysis,d=ye(e,o?.reopen??[],p),i=x(d.state,t,{stage:H,status:"done"},n,p);for(let s of d.reopened)i=c(i,"phase.reopened",n,{phase:s,change:t},p);return d.suspended!==null&&(i=c(i,"phase.suspended",n,{phase:d.suspended,change:t},p)),c(i,"change.decided",n,{change:t,decision:"approve",by:n,note:a,reopened:d.reopened,suspended:d.suspended,weight:o?.weight??0,affects:c$1.affects??[]},p)}function K(e,t,n,a,p){let c$1=u(e,t),o=x(e,t,{status:"dropped"},n,p);return c(o,"change.decided",n,{change:t,decision:"reject",by:n,note:a,reopened:[],suspended:null,weight:0,affects:c$1.affects??[]},p)}function Ne(e){return (t,n)=>{o(t,n.by,"facilitate");let a$2=n.phase===void 0?void 0:Y(t,n,"phaseRetrospective"),p=a$1(t,n,"phaseRetrospective");return Y$1(t,e(),{type:"ceremony.phaseRetrospective",by:n.by,payload:n},c$1=>{let o=c$1,d=a(n.now),i=b$2(o,p,n.by,d);return o=i.state,c(o,"phase.retrospective",n.by,{phase:a$2?.id??null,lessons:i.created,adopted:i.adopted.slice(i.created.length),dismissed:i.dismissed,agreements:i.agreements,retired:i.retired},d)})}}var Ze=(e,t)=>e.id<t.id?-1:e.id>t.id?1:0,Le=(e,t)=>timSort(P(e,t).filter(n=>n.type!=="question"&&n.type!=="change-request"),Ze),Xe=(e,t)=>(e.traces??[]).includes(t.id)||(t.traces??[]).includes(e.id);function O(e){let t=w(e).traceability,n=b(e).map(o=>o.id),a=t.to.filter(o=>n.includes(o)),p=Le(e,t.from).map(o=>{let d={};for(let i of a)d[i]=Le(e,i).filter(s=>Xe(o,s)).map(s=>s.id);return {item:o.id,links:d}}),c=p.map(o=>({item:o.item,phases:a.filter(d=>o.links[d].length===0)})).filter(o=>o.phases.length>0);return {from:t.from,to:a,rows:p,missing:c,coverage:{traced:p.length-c.length,total:p.length}}}function J(e,t){return O(e).rows.filter(n=>(n.links[t]??[]).length===0).map(n=>n.item)}var et=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Y(e,t,n){let a=t.phase;return (typeof a!="string"||a.trim()==="")&&b$1("invalid-input",`${n} needs phase: string`,`pass one of: ${b(e).map(p=>p.id).join(", ")}`),_(e,a)}function Ve(e,t,n,a,p,c$1){let o=j(e,b(e).map(d=>d.id===t?{...d,produced:[...d.produced??[],{kind:n,ref:a,by:p,at:c$1}]}:d));return c(o,"phase.deliverable",p,{phase:t,kind:n,ref:a},c$1)}function be(e){let t=(c,o,d,i)=>Y$1(c,e(),{type:o,by:d.by,payload:d},s=>i(s,a(d.now)));return {kickoff:(c$1,o$1)=>{o(c$1,o$1.by,"facilitate");let d=Y(c$1,o$1,"kickoff");return t(c$1,"ceremony.kickoff",o$1,(i,s)=>{let l=i.events.filter(r=>r.type==="phase.opened"&&r.payload.phase===d.id).length+1,f=P(i,d.id).filter(r=>r.status!=="done").map(r=>r.id);i=j(i,b(i).map(r=>r.id===d.id?{...r,status:"open"}:r));let u=d.budget??{};return i={...i,iterations:[...i.iterations,{id:`${d.id}#${l}`,goal:d.name,budget:u,spent:M$1,startedAt:s,committed:f,carryover:[]}]},c(i,"phase.opened",o$1.by,{phase:d.id,version:l,items:f,budget:u},s)})},gateReview:(c$1,o)=>{let d=Y(c$1,o,"gateReview");d.status!=="open"&&b$1("invalid-transition",`phase "${d.id}" is ${d.status}, not open`,d.status==="baselined"?"it is already baselined; a change-request reopens it":`kickoff "${d.id}" first`);let i=d.gate,s=j$1(c$1,i.id,"approve-gate");o.by!=="human"&&!s.includes(o.by)&&b$1("gate-unmet",`"${o.by}" may not review gate "${i.id}"`,`review as one of: human${s.map(r=>`, ${r}`).join("")}`,{rule:"gate"});let l=c$1.pending.find(r=>r.kind==="gate"&&r.item===void 0&&r.gate===i.id);l&&b$1("no-op",`gate "${i.id}" is already awaiting a decision (${l.id})`,`decide ${l.id} approve|reject`);let f=o.deliverables??[];(!Array.isArray(f)||!f.every(r=>et(r)&&typeof r.kind=="string"&&r.kind.trim()!==""&&typeof r.ref=="string"))&&b$1("invalid-input","gateReview.deliverables must be [{ kind, ref }]",'e.g. { "deliverables": [{ "kind": "srs", "ref": "docs/srs.md" }] }');let u=f;return t(c$1,"ceremony.gateReview",o,(r,m)=>{for(let h of u)r=Ve(r,d.id,h.kind,h.ref,o.by,m);if(w(r).traceability.to.includes(d.id)){let h=O(r);r=c(r,"traceability.computed",o.by,{phase:d.id,from:h.from,to:h.to,coverage:h.coverage,missing:h.missing,rows:h.rows},m),d.id===B(r)&&h.missing.length===0&&(r=Ve(r,d.id,"traceability-matrix",`traceability.computed#${r.events[r.events.length-1].seq}`,o.by,m));}if(i.requires.includes("human")&&o.by!=="human"){r=K$1(r,{kind:"gate",gate:i.id,question:`Approve gate "${i.id}" and baseline phase "${d.name}"?`},m);let h=r.pending[r.pending.length-1].id;return c(r,"phase.gate-pending",o.by,{phase:d.id,gate:i.id,by:o.by,pending:h},m)}return ae(r,d.id,[o.by],m)})},changeControlBoard:(c$1,o$1)=>{o(c$1,o$1.by,"control-change");let d=o$1.change;(typeof d!="string"||d.trim()==="")&&b$1("invalid-input","changeControlBoard needs change: string (a change-request id)",'e.g. { "change": "CR-1", "decision": "approve", "note": "why" }');let i$1=u(c$1,d);if(i$1.type!=="change-request"&&b$1("invalid-input",`item "${d}" is a ${i$1.type}, not a change-request`,"only change-request items go through the board",{items:[d]}),(i$1.status==="done"||i$1.status==="dropped")&&b$1("invalid-transition",`change "${d}" is already ${i$1.status==="done"?"approved":"rejected"}`,"raise a new change-request",{items:[d]}),i$1.status==="awaiting_human"){let r=c$1.pending.find(m=>m.item===d);b$1("no-op",`change "${d}" is awaiting the human decision${r?` (${r.id})`:""}`,`decide ${r?.id??"<pending id>"} approve|reject`,{items:[d]});}let s=o$1.decision;s!=="approve"&&s!=="reject"&&b$1("invalid-input",'changeControlBoard.decision must be "approve" or "reject"',"state the board's decision");let l=typeof o$1.note=="string"?o$1.note:"",f=w(c$1).changeControl.approvers;for(let r of f)r==="human"||o$1.by==="human"||n(c$1,o$1.by,r.capability)||b$1("gate-unmet",`"${o$1.by}" lacks capability "${r.capability}" required by change control`,`decide as one of: human${i(c$1,r.capability).map(m=>`, ${m.id}`).join("")}`,{rule:"change-control",items:[d]});let u$1=f.includes("human")&&o$1.by!=="human";return t(c$1,"ceremony.changeControlBoard",o$1,(r,m)=>{if(u$1){r=K$1(r,{kind:"decision",item:d,question:`Change "${d}" (${i$1.title}): the board (${o$1.by}) recommends ${s}${l?`: ${l}`:""}. Approve or reject the change?`},m);let h=r.pending[r.pending.length-1].id;return c(r,"change.recommended",o$1.by,{change:d,decision:s,note:l,pending:h},m)}return s==="approve"?z(r,d,o$1.by,l,m):K(r,d,o$1.by,l,m)})},phaseRetrospective:Ne(e)}}function ve(e,t,n,a,p,c$1){if(t.kind==="gate"&&t.item===void 0&&t.gate!==void 0){let o=b(e).find(s=>s.gate.id===t.gate);if(!o)return e;a!=="human"&&b$1("gate-unmet",`"${a}" may not decide phase gate "${t.gate}" (${t.id}); it awaits a human`,`decide ${t.id} as human`,{rule:"gate"});let d;for(let s=e.events.length-1;s>=0;s--){let l=e.events[s];if(l.type==="phase.gate-pending"&&l.payload.pending===t.id){d=l.by;break}}let i=d!==void 0&&d!==a?[d,a]:[a];return n==="approve"?ae(e,o.id,i,c$1):c(e,"phase.gate-failed",a,{phase:o.id,gate:t.gate,note:p},c$1)}if(t.kind==="decision"&&t.item!==void 0&&Object.hasOwn(e.items,t.item)){let o=e.items[t.item];return o.type!=="change-request"?e:(a!=="human"&&b$1("gate-unmet",`"${a}" may not decide change "${o.id}" (${t.id}); change control awaits a human`,`decide ${t.id} as human`,{rule:"change-control",items:[o.id]}),n==="approve"?z(e,o.id,a,p,c$1):K(e,o.id,a,p,c$1))}return e}function ke(e){let t=w(e).phases.map($=>$.id),n=()=>Object.fromEntries(t.map($=>[$,0])),a=n(),p=n(),c=n(),o=n(),d=n(),i=new Map,s=new Map,l=new Map,f=0,u=0,r=0,m=0,h=0,v=$=>{let W=s.get($),y=i.get($);return W!=="question"&&W!=="change-request"&&y!==void 0&&y in a};for(let $ of e.events){let W=$.payload??{};switch($.type){case "item.added":{let y=W,T=y.phase??(y.parent!==null?i.get(y.parent):void 0);i.set(y.id,T),s.set(y.id,y.type),l.set(y.id,"todo"),y.type==="change-request"&&(f+=1),v(y.id)&&(a[T]+=1,y.type==="bug"&&(d[T]+=1));break}case "item.transition":{let y=W.id,T=W.to.status,Pe=l.get(y);if(l.set(y,T),!v(y))break;let de=i.get(y);T==="done"&&Pe!=="done"&&(p[de]+=1),T==="dropped"&&(a[de]-=1,Pe==="done"&&(p[de]-=1));break}case "item.completed":{let y=i.get(W.id);y!==void 0&&y in o&&(o[y]+=W.tokens??0);break}case "phase.opened":{let y=W.phase;y in c&&(c[y]=(W.budget??{}).tokens??0);break}case "change.decided":{W.decision==="approve"?(u+=1,m+=W.weight??0,h+=(W.reopened??[]).length):r+=1;break}}}let Z=n(),I=n();for(let $ of t){let W=a[$]??0;Z[$]=W===0?0:(p[$]??0)/W*100,I[$]=o[$]-c[$];}let{traced:x,total:se}=O(e).coverage,Re=u+r;return {phaseCompletion:Z,budgetPlanned:c,budgetSpent:o,scheduleVariance:I,requirementCoverage:se===0?0:x/se,requirementsTraced:x,requirementsTotal:se,defectsPerPhase:d,changeRequests:f,changesApproved:u,changesRejected:r,changeApprovalRate:Re===0?0:u/Re,reworkWeight:m,phasesReopened:h}}function we(e){let t=e.phases.map(n=>n.gate.id);return [{id:"project-manager",name:"Project Manager",modelTier:"large",capabilities:["facilitate","control-change","approve-gate","escalate"],canApprove:[...t,me],inputs:["phase-plan","deliverables","change-requests"],outputs:["gate-decisions","baselines","change-decisions"],do_not:["do not implement items yourself","do not reopen a phase without an approved change-request"]},{id:"developer",name:"Developer",modelTier:"small",capabilities:["deliver"],canApprove:[],inputs:["design-doc","interface-spec","brief"],outputs:["code","code-baseline","test-output"],do_not:["do not change requirements or designs; raise a change-request","do not approve your own work"]},{id:"business-analyst",name:"Business Analyst",modelTier:"medium",capabilities:["define-acceptance","deliver"],canApprove:[],inputs:["stakeholder-needs"],outputs:["srs","acceptance-criteria"],do_not:["do not design or implement","do not edit a baselined requirement; raise a change-request"]},{id:"architect",name:"Architect",modelTier:"medium",capabilities:["deliver"],canApprove:[],inputs:["srs"],outputs:["design-doc","interface-spec"],do_not:["do not change requirements; raise a change-request","do not implement"]},{id:"qa",name:"QA",modelTier:"small",capabilities:["verify","review"],canApprove:[],inputs:["srs","design-doc","code-baseline"],outputs:["test-report","review-notes"],do_not:["do not fix defects yourself; raise bugs","do not approve phase gates"]},{id:"release-manager",name:"Release Manager",modelTier:"small",capabilities:["deliver"],canApprove:[],inputs:["code-baseline","test-report"],outputs:["release-notes","deployment-record"],do_not:["do not deploy an unbaselined verification phase"]}]}var k=(e,t,n,a)=>a?{rule:e,severity:"error",item:a,message:t,fix:n}:{rule:e,severity:"error",message:t,fix:n},R=e=>e.payload??{},C=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Q=e=>{let t=R(e).phase;return typeof t=="string"?t:void 0},S=(e,t)=>b(e).find(n=>n.id===t),oe=e=>b(e).map(t=>t.id).join(", "),M=(e,t)=>typeof t=="string"&&Object.hasOwn(e.items,t)?e.items[t]:void 0;function He(e,t){if(t.phase!==void 0)return t.phase;let n=M(e,t.parent);return n?q(e,n):void 0}var Ue=e=>e.type!=="change-request"&&e.type!=="question",ze=(e,t)=>`raise a change-request: addItem({ type: "change-request", affects: ["${e}"], impactAnalysis: { summary, reopen: ["${t}"], weight } }) and decide it in changeControlBoard`;function Ke(e,t){let n=M(e,R(t).change);return n&&n.type==="change-request"?n:void 0}function $e(e,t,n){let a="change-needs-impact-analysis",p=`editItem("${t}", { impactAnalysis: { summary: "what changes and why", reopen: ["<phase>"], weight: <points> } })`;if(n===void 0)return w(e).changeControl.requiresImpactAnalysis?[k(a,`change "${t}" has no impact analysis`,p,t)]:[];let c=[],o=C(n)?n:{};return (typeof o.summary!="string"||o.summary.trim()==="")&&c.push(k(a,`change "${t}" impactAnalysis.summary is empty`,p,t)),(!Array.isArray(o.reopen)||!o.reopen.every(d=>typeof d=="string"))&&c.push(k(a,`change "${t}" impactAnalysis.reopen must be a string[] of phase ids`,p,t)),(typeof o.weight!="number"||!Number.isFinite(o.weight)||o.weight<0)&&c.push(k(a,`change "${t}" impactAnalysis.weight must be a non-negative number`,p,t)),c}function We(){return [{id:"phase-sequential",severity:"error",check(i,s){let l=[];if(s.type==="ceremony.kickoff"){let f=Q(s),u=f===void 0?void 0:S(i,f);if(!u)return [];u.status==="open"&&l.push(k("phase-sequential",`phase "${u.id}" is already open`,`gateReview "${u.id}" when its work is done`)),u.status==="baselined"&&l.push(k("phase-sequential",`phase "${u.id}" is baselined`,"only an approved change-request reopens a baselined phase"));let r=D(i);r&&r.id!==u.id&&l.push(k("phase-sequential",`phase "${r.id}" is still open`,`pass its gate (gateReview "${r.id}") before opening "${u.id}"`));}else if(s.type==="item.add"){let f=R(s).item;if(!C(f)||!Ue(f))return [];let u=He(i,f);u===void 0?l.push(k("phase-sequential",`item "${f.id}" belongs to no phase`,`set phase to one of: ${oe(i)}`,f.id)):S(i,u)||l.push(k("phase-sequential",`item "${f.id}" names unknown phase "${u}"`,`phases are: ${oe(i)}`,f.id));}else if(s.type==="item.edit"){let f=R(s).id,u=R(s).patch,r=M(i,f);if(!r||!C(u)||u.phase===void 0||u.phase===r.phase)return [];l.push(k("phase-sequential",`item "${r.id}" cannot move from phase "${r.phase??"(none)"}" to "${String(u.phase)}"`,`drop "${r.id}" and add a new item in phase "${String(u.phase)}"`,r.id));}return l}},{id:"gate-before-next-phase",severity:"error",check(i,s){if(s.type!=="ceremony.kickoff")return [];let l=Q(s),f=b(i),u=l===void 0?-1:f.findIndex(m=>m.id===l);if(u<0)return [];let r=f.slice(0,u).filter(m=>m.status!=="baselined").map(m=>m.id);return r.length===0?[]:[k("gate-before-next-phase",`phase(s) ${r.join(", ")} before "${l}" are not baselined`,`kickoff and gateReview them in order, starting with "${r[0]}"`)]}},{id:"baseline-immutable",severity:"error",check(i,s){let l=f=>(i.baselines??[]).filter(u=>u.phase===f).length||1;if(s.type==="item.edit"){let f=M(i,R(s).id);if(!f)return [];let u=q(i,f);return u===void 0||S(i,u)?.status!=="baselined"?[]:[k("baseline-immutable",`item "${f.id}" is frozen: phase "${u}" is baselined (v${l(u)})`,ze(f.id,u),f.id)]}if(s.type==="item.add"){let f=R(s).item;if(!C(f)||!Ue(f))return [];let u=He(i,f);return u===void 0||S(i,u)?.status!=="baselined"?[]:[k("baseline-immutable",`cannot add "${f.id}" to baselined phase "${u}" (v${l(u)})`,ze(f.id,u),f.id)]}return []}},{id:"change-needs-impact-analysis",severity:"error",check(i,s){if(s.type==="item.add"){let r=R(s).item;return !C(r)||r.type!=="change-request"?[]:$e(i,String(r.id),r.impactAnalysis)}if(s.type==="item.edit"){let r=R(s).patch,m=M(i,R(s).id);return !m||m.type!=="change-request"||!C(r)||!("impactAnalysis"in r)?[]:$e(i,m.id,r.impactAnalysis)}if(s.type!=="ceremony.changeControlBoard")return [];let l=Ke(i,s);if(!l)return [];let f=$e(i,l.id,l.impactAnalysis);if(f.length||l.impactAnalysis===void 0)return f;let u=R(s).decision==="approve";for(let r of l.impactAnalysis.reopen){let m=S(i,r);m?u&&m.status==="pending"&&f.push(k("change-needs-impact-analysis",`phase "${r}" was never baselined; it cannot be reopened`,`remove "${r}" from impactAnalysis.reopen`,l.id)):f.push(k("change-needs-impact-analysis",`change "${l.id}" impactAnalysis.reopen names unknown phase "${r}"`,`phases are: ${oe(i)}`,l.id));}return f}},{id:"requirement-traced",severity:"error",check(i,s){if(s.type!=="ceremony.gateReview")return [];let l=Q(s),f=w(i).traceability;return l===void 0||!f.to.includes(l)||!S(i,l)?[]:J(i,l).map(u=>k("requirement-traced",`item "${u}" of phase "${f.from}" has no trace into "${l}"`,`editItem a "${l}" item with traces: ["${u}"] (or editItem("${u}", { traces: [...] }) while "${f.from}" is not baselined)`,u))}},{id:"deliverables-present",severity:"error",check(i,s){if(s.type!=="ceremony.gateReview")return [];let l=Q(s),f=l===void 0?void 0:S(i,l);if(!f)return [];let u=[],r=P(i,f.id).filter(v=>v.status!=="done").map(v=>v.id);r.length&&u.push(k("deliverables-present",`${r.length} item(s) in phase "${f.id}" are not done: ${r.join(", ")}`,"finish them (next/complete) or drop them before the gate"));let m=R(s).deliverables,h=Array.isArray(m)?m.filter(v=>C(v)&&typeof v.kind=="string").map(v=>v.kind):[];f.id===B(i)&&h.push("traceability-matrix");for(let v of U(i,f,h))u.push(k("deliverables-present",`phase "${f.id}" has no deliverable "${v}"`,`pass deliverables: [{ "kind": "${v}", "ref": "<where it lives>" }] to gateReview, or attach evidence of kind "${v}" on an item of the phase`));return u}},{id:"approver-not-author",severity:"error",check(i$1,s){if(s.by==="human")return [];if(s.type==="ceremony.gateReview"){let l=Q(s),f=l===void 0?void 0:S(i$1,l);if(!f)return [];let u=P(i$1,f.id).filter(m=>I(i$1,m)===s.by).map(m=>m.id);if(u.length===0)return [];let r=j$1(i$1,f.gate.id,"approve-gate",s.by);return [k("approver-not-author",`"${s.by}" authored ${u.join(", ")} in phase "${f.id}" and may not approve its gate`,`review the gate as one of: human${r.map(m=>`, ${m}`).join("")}`)]}if(s.type==="ceremony.changeControlBoard"){let l=Ke(i$1,s);if(!l)return [];let f=i$1.events.find(r=>r.type==="item.added"&&r.payload.id===l.id);if(!f||f.by!==s.by)return [];let u=i(i$1,"control-change").map(r=>r.id).filter(r=>r!==s.by);return [k("approver-not-author",`"${s.by}" raised change "${l.id}" and may not decide it`,`decide as human${u.map(r=>`, ${r}`).join("")}`,l.id)]}return []}},{id:"trace-ids-valid",severity:"error",check(i,s){let l,f,u,r;if(s.type==="item.add"){let h=R(s).item;if(!C(h))return [];l=String(h.id),f=h.traces,u=h.impactAnalysis,r=h.type==="change-request";}else if(s.type==="item.edit"){let h=M(i,R(s).id),v=R(s).patch;if(!h||!C(v))return [];l=h.id,f=v.traces,u=v.impactAnalysis,r=h.type==="change-request";}else return [];let m=[];if(Array.isArray(f)){let h=w(i).traceability,v=[h.from,...h.to].flatMap(I=>P(i,I).filter(x=>x.type!=="question"&&x.type!=="change-request").map(x=>x.id)),Z=`traceable items: ${v.length?v.join(", "):"(none yet)"}`;for(let I of f){if(typeof I!="string")continue;let x=M(i,I);(!x||x.status==="dropped")&&m.push(k("trace-ids-valid",`item "${l}" traces unknown item "${I}"`,Z,l));}}if(r&&C(u)&&Array.isArray(u.reopen))for(let h of u.reopen)typeof h=="string"&&!S(i,h)&&m.push(k("trace-ids-valid",`change "${l}" impactAnalysis.reopen names unknown phase "${h}"`,`phases are: ${oe(i)}`,l));return m}}]}function Ae(e){return [{id:L,name:"Work",entryPolicy:[{kind:"dependencies-done"}],exitPolicy:[]},{id:V,name:"Review",entryPolicy:[],exitPolicy:[{kind:"no-open-blockers"}],review:true},{id:H,name:"Done",entryPolicy:[],exitPolicy:[]}]}var tt={backlog:"Requirements Baseline",item:"Work Package",stage:"Step",iteration:"Phase",increment:"Deliverable",ceremony:"Review",gate:"Phase Gate"};function nt(e,t){let n=q(e,t);if(n!==void 0)return w(e).phases.find(a=>a.id===n)?.deliverBy}function it(e){return {phases:b(e).map(n=>{let a=P(e,n.id),p=a.filter(s=>s.status==="done").length,o=w(e).traceability.to.includes(n.id)?J(e,n.id):[],d=n.id===B(e)&&o.length===0?["traceability-matrix"]:[],i=U(e,n,d);return {id:n.id,name:n.name,status:n.status,items:a.length,done:p,missingDeliverables:i,missingTraces:o,readyForGate:n.status==="open"&&p===a.length&&i.length===0&&o.length===0}}),current:he(e)?.id??null,open:D(e)?.id??null,pendingGates:e.pending.filter(n=>n.kind==="gate"&&n.item===void 0&&n.gate!==void 0).map(n=>({pending:n.id,gate:n.gate}))}}function rt(){return {name:"waterfall",vocabulary:tt,validateConfig:ge,defaultStages:Ae,defaultRoles:we,requiredCapabilities:["facilitate","control-change","approve-gate","deliver","verify"],exclusiveCapabilities:[],plannerOptions(e){let t={schedulerMode:"level",roleFor:a=>a.status==="todo"&&a.type!=="question"?nt(e,a):void 0},n=w(e).fallbackTokensPerWeight;return n!==void 0&&(t.fallbackTokensPerWeight=n),t},candidates(e){let t=D(e);return t?Object.values(e.items).filter(n=>(n.status==="todo"||n.status==="review")&&(n.stage===L||n.stage===V)&&n.type!=="change-request"&&q(e,n)===t.id):[]},invariants(e,t){let n=w(e),a=b(e),p=q(e,t),c=p===void 0?void 0:a[E(e,p)],o=a.filter(i=>i.status==="baselined").map(i=>i.id),d=c?.gate.requires.includes("human");return [c?`Phase "${c.name}" (${E(e,c.id)+1}/${a.length}); deliverables: ${c.deliverables.join(", ")||"(none)"}; gate "${c.gate.id}"${d?" needs human approval":""}`:"This item belongs to no phase; it is dispatched only through its parent's phase",`Baselined phases are frozen: ${o.join(", ")||"(none yet)"}; to change their items, raise a change-request with an impact analysis`,n.traceability.to.length?`Traceability: every item of phase "${n.traceability.from}" must trace to an item in ${n.traceability.to.join(", ")} (set traces on either side)`:"Traceability: none configured",`Do not change the scope of "${t.id}" or its acceptance criteria; raise open_questions instead`]},ceremonies:be(rt),rules:We(),metrics:e=>({...ke(e)}),humanDefaults:{gates:"all"},lockedConfigKeys:["phases","traceability","humanGates"],report:e=>({...it(e),coverage:O(e).coverage}),afterDecide:ve,afterComplete(e,t,n){let a=R$1(e),p=D(e);if(!a||!p||a.committed.includes(t))return e;let c=e.items[t];if(!c||q(e,c)!==p.id)return e;let o=e.accounting[e.accounting.length-1];return !o||o.item!==t?e:{...e,iterations:e.iterations.map(d=>d.id===a.id?{...d,committed:[...d.committed,t],spent:N(d.spent,o)}:d)}}}}export{K as A,O as B,J as C,Y as D,be as E,ve as F,ke as G,we as H,We as I,Ae as J,tt as K,nt as L,it as M,rt as N,De as a,pe as b,fe as c,ue as d,me as e,Me as f,w as g,ge as h,L as i,V as j,H as k,b as l,j as m,E as n,_ as o,q as p,P as q,D as r,he as s,Je as t,_e as u,U as v,B as w,ae as x,ye as y,z};//# sourceMappingURL=chunk-3KFQPSRX.mjs.map
2
- //# sourceMappingURL=chunk-3KFQPSRX.mjs.map