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
@@ -0,0 +1,509 @@
1
+ interface Hypothesis {
2
+ id: string;
3
+ claim: string;
4
+ falsifiedBy: string;
5
+ }
6
+ interface Experiment {
7
+ id: string;
8
+ procedureRef: string;
9
+ predictions: Array<{
10
+ hypothesis: string;
11
+ prediction: string;
12
+ }>;
13
+ replayOf?: string;
14
+ }
15
+ interface Observation {
16
+ id: string;
17
+ valid: boolean;
18
+ summary: string;
19
+ provenanceRefs: string[];
20
+ }
21
+ interface BeliefUpdate {
22
+ result: string;
23
+ assessments: Array<{
24
+ hypothesis: string;
25
+ assessment: "supported" | "refuted" | "uncertain";
26
+ reason: string;
27
+ }>;
28
+ }
29
+ interface InvestigationRound {
30
+ hypotheses: Hypothesis[];
31
+ experiment: Experiment;
32
+ item: string;
33
+ by: string;
34
+ result?: Observation;
35
+ update?: BeliefUpdate;
36
+ }
37
+ interface InvestigationConclusion {
38
+ outcome: "resolved" | "inconclusive";
39
+ summary: string;
40
+ supportedHypothesis?: string;
41
+ evidenceRefs: string[];
42
+ by: string;
43
+ }
44
+ interface InvestigationState {
45
+ item: string;
46
+ phase: "hypotheses" | "preregister" | "observe" | "update-belief" | "conclusion" | "review" | "closed";
47
+ hypotheses: Hypothesis[];
48
+ singleHypothesisRationale?: string;
49
+ rounds: InvestigationRound[];
50
+ conclusion?: InvestigationConclusion;
51
+ outcome?: "resolved" | "inconclusive" | "stopped";
52
+ stopReason?: string;
53
+ contributors: string[];
54
+ reviewHistory?: Array<{
55
+ by: string;
56
+ reason: string;
57
+ approve: boolean;
58
+ next?: "round" | "conclusion";
59
+ replayRefs: string[];
60
+ }>;
61
+ review?: {
62
+ by: string;
63
+ reason: string;
64
+ replayRefs: string[];
65
+ };
66
+ }
67
+
68
+ interface ExperimentCandidate {
69
+ id: string;
70
+ item: string;
71
+ author: string;
72
+ status: "pending" | "ready" | "running" | "submitted" | "validated" | "failed" | "timed-out" | "cancelled";
73
+ workspace?: string;
74
+ sha?: string;
75
+ score?: number;
76
+ spent: Spent;
77
+ validation?: {
78
+ sha: string;
79
+ harness: string;
80
+ by: string;
81
+ passed: boolean;
82
+ reproducible: boolean;
83
+ evidence: string;
84
+ };
85
+ reason?: string;
86
+ command?: string;
87
+ log?: string;
88
+ /** Final failed/cancelled attempt report, separate from the submitted benchmark log. */
89
+ terminalLog?: string;
90
+ }
91
+ interface ExperimentationState {
92
+ status: "running" | "selected" | "integrating" | "integrated" | "stopped";
93
+ baseSha: string;
94
+ harness: string;
95
+ candidates: Record<string, ExperimentCandidate>;
96
+ selected?: string;
97
+ reason?: string;
98
+ integration?: {
99
+ selectedSha: string;
100
+ targetSha: string;
101
+ sha: string;
102
+ by: string;
103
+ validation?: {
104
+ by: string;
105
+ sha: string;
106
+ harness: string;
107
+ evidence: string;
108
+ passed: boolean;
109
+ };
110
+ };
111
+ released: string[];
112
+ /** Host-reported control, validation and integration cost, additional to candidate execution. */
113
+ overhead: Spent;
114
+ }
115
+
116
+ type ItemType = "epic" | "story" | "task" | "bug" | "change-request" | "deliverable" | "question";
117
+ type ItemStatus = "todo" | "in_progress" | "blocked" | "review" | "awaiting_human" | "done" | "dropped";
118
+ type ClassOfService = "expedite" | "fixed-date" | "standard" | "intangible";
119
+ interface Evidence {
120
+ kind: string;
121
+ ref: string;
122
+ by: string;
123
+ at: string;
124
+ }
125
+ interface Blocker {
126
+ id: string;
127
+ reason: string;
128
+ owner: string;
129
+ raisedAt: string;
130
+ clearedAt?: string;
131
+ }
132
+ interface Transition {
133
+ from: {
134
+ stage: string;
135
+ status: ItemStatus;
136
+ };
137
+ to: {
138
+ stage: string;
139
+ status: ItemStatus;
140
+ };
141
+ at: string;
142
+ by: string;
143
+ }
144
+ /** Change-request: what the change touches and what it costs (waterfall change control). */
145
+ interface ImpactAnalysis {
146
+ summary: string;
147
+ /** phase ids to reopen when the change is approved (each must be baselined or open) */
148
+ reopen: string[];
149
+ /** estimated rework weight (story points / size) */
150
+ weight: number;
151
+ }
152
+ interface WorkItem {
153
+ id: string;
154
+ type: ItemType;
155
+ title: string;
156
+ description?: string;
157
+ dependsOn: string[];
158
+ priority?: number;
159
+ weight?: number;
160
+ deadline?: string;
161
+ classOfService?: ClassOfService;
162
+ stage: string;
163
+ status: ItemStatus;
164
+ role?: string;
165
+ parent?: string;
166
+ acceptance: string[];
167
+ evidence: Evidence[];
168
+ blockers: Blocker[];
169
+ transitions: Transition[];
170
+ iteration?: string;
171
+ traces?: string[];
172
+ tags?: string[];
173
+ /** bug / change-request: ids of items whose finished work this invalidates */
174
+ affects?: string[];
175
+ /** waterfall: Phase.id this item belongs to; questions and follow-ups inherit their parent's */
176
+ phase?: string;
177
+ /** change-request: impact analysis required before the change control board decides */
178
+ impactAnalysis?: ImpactAnalysis;
179
+ }
180
+ /** Fields `editItem` / `exwf edit` may change. */
181
+ type ItemPatch = Partial<Omit<WorkItem, "id" | "stage" | "status" | "transitions" | "evidence" | "blockers">>;
182
+ /** Fields a caller supplies to addItem; the rest are defaulted. */
183
+ type NewItem = Pick<WorkItem, "id" | "title"> & Partial<Omit<WorkItem, "id" | "title" | "stage" | "status" | "evidence" | "blockers" | "transitions">> & {
184
+ stage?: string;
185
+ };
186
+ type Policy = {
187
+ kind: "evidence";
188
+ evidenceKind: string;
189
+ } | {
190
+ kind: "acceptance-written";
191
+ } | {
192
+ kind: "estimate-present";
193
+ } | {
194
+ kind: "no-open-blockers";
195
+ } | {
196
+ kind: "dependencies-done";
197
+ } | {
198
+ kind: "custom";
199
+ id: string;
200
+ description: string;
201
+ };
202
+ type GateRequirement = "human" | {
203
+ capability: string;
204
+ };
205
+ interface Gate {
206
+ id: string;
207
+ requires: GateRequirement[];
208
+ evidence: string[];
209
+ onFail: {
210
+ action: "block";
211
+ } | {
212
+ action: "return-to";
213
+ stage: string;
214
+ };
215
+ }
216
+ interface Stage {
217
+ id: string;
218
+ name: string;
219
+ wipLimit?: number;
220
+ entryPolicy: Policy[];
221
+ exitPolicy: Policy[];
222
+ gate?: Gate;
223
+ commitmentPoint?: boolean;
224
+ deliveryPoint?: boolean;
225
+ /** Items entering this stage wait for a reviewer (status "review") instead of "todo". */
226
+ review?: boolean;
227
+ }
228
+ interface Budget {
229
+ tokens?: number;
230
+ turns?: number;
231
+ wallclockMs?: number;
232
+ }
233
+ interface Spent {
234
+ tokens: number;
235
+ turns: number;
236
+ wallclockMs: number;
237
+ }
238
+ interface Iteration {
239
+ id: string;
240
+ goal: string;
241
+ budget: Budget;
242
+ spent: Spent;
243
+ startedAt: string;
244
+ endedAt?: string;
245
+ committed: string[];
246
+ carryover: string[];
247
+ outcome?: "completed" | "cancelled";
248
+ /** Budget is exhausted; in-flight items may finish, nothing new is dispatched. */
249
+ closing?: boolean;
250
+ }
251
+ type ModelTier = "small" | "medium" | "large";
252
+ type Capability = "order-backlog" | "define-acceptance" | "facilitate" | "deliver" | "review" | "verify" | "approve-gate" | "manage-flow" | "control-change" | "escalate";
253
+ interface Role {
254
+ id: string;
255
+ name: string;
256
+ modelTier: ModelTier;
257
+ resourceClass?: string;
258
+ maxConcurrent?: number;
259
+ capabilities: Capability[];
260
+ canApprove: string[];
261
+ inputs: string[];
262
+ outputs: string[];
263
+ do_not: string[];
264
+ constraints?: string[];
265
+ }
266
+ type Verdict = "done" | "blocked" | "needs-review" | "rework" | "escalate";
267
+ interface Handoff {
268
+ item: string;
269
+ role: string;
270
+ produced: Array<{
271
+ kind: string;
272
+ ref: string;
273
+ }>;
274
+ notes: string;
275
+ do_not: string[];
276
+ open_questions: string[];
277
+ verdict?: Verdict;
278
+ /** new work discovered while doing this item; lands in the FIRST stage (backlog), never in the iteration */
279
+ follow_ups?: NewItem[];
280
+ /** raised by the worker the moment it happens, e.g. "spec was vague here" */
281
+ lessons?: Array<{
282
+ text: string;
283
+ scope: Lesson["scope"];
284
+ }>;
285
+ }
286
+ interface Accounting {
287
+ item: string;
288
+ role: string;
289
+ model: string;
290
+ tokensIn: number;
291
+ tokensOut: number;
292
+ durationMs: number;
293
+ startedAt: string;
294
+ endedAt: string;
295
+ /** The tokens are a placeholder the host will correct with correctAccounting, not the host's usage figures. */
296
+ estimate?: boolean;
297
+ }
298
+ interface Event {
299
+ seq: number;
300
+ at: string;
301
+ type: string;
302
+ by: string;
303
+ payload: unknown;
304
+ }
305
+ interface PendingHuman {
306
+ id: string;
307
+ kind: "gate" | "decision";
308
+ item?: string;
309
+ gate?: string;
310
+ question: string;
311
+ raisedAt: string;
312
+ }
313
+ type LessonChange = {
314
+ kind: "agreement";
315
+ text: string;
316
+ replaces?: string;
317
+ } | {
318
+ kind: "dod";
319
+ policy: Policy;
320
+ } | {
321
+ kind: "backlog";
322
+ item: NewItem;
323
+ } | {
324
+ kind: "skill";
325
+ note: string;
326
+ };
327
+ interface Lesson {
328
+ id: string;
329
+ at: string;
330
+ text: string;
331
+ scope: "policy" | "skill" | "memory" | "spec" | "review";
332
+ status: "raised" | "adopted" | "dismissed";
333
+ from?: string;
334
+ item?: string;
335
+ suggestedChange?: LessonChange;
336
+ }
337
+ /** A deliverable recorded on a phase (gateReview input or engine-generated). */
338
+ interface Produced {
339
+ kind: string;
340
+ ref: string;
341
+ by: string;
342
+ at: string;
343
+ }
344
+ interface Phase {
345
+ id: string;
346
+ name: string;
347
+ deliverables: string[];
348
+ gate: Gate;
349
+ status: "pending" | "open" | "baselined" | "reopened";
350
+ /** planned budget; spent is tracked on the Iteration kickoff opens for the phase */
351
+ budget?: Budget;
352
+ /** phase-level deliverables (item evidence counts too) */
353
+ produced?: Produced[];
354
+ }
355
+ interface Baseline {
356
+ phase: string;
357
+ version: number;
358
+ at: string;
359
+ approvedBy: string[];
360
+ itemSnapshot: Record<string, WorkItem>;
361
+ }
362
+ type MethodologyName = "scrum" | "kanban" | "waterfall" | "investigation" | "experimentation";
363
+ interface WorkflowState {
364
+ version: 1;
365
+ methodology: MethodologyName;
366
+ config: unknown;
367
+ /** Standalone investigation lifecycle, created by its intake ceremony. */
368
+ investigation?: InvestigationState;
369
+ /** Standalone isolated candidate experiment, created by its freeze ceremony. */
370
+ experimentation?: ExperimentationState;
371
+ items: Record<string, WorkItem>;
372
+ stages: Stage[];
373
+ roles: Record<string, Role>;
374
+ iterations: Iteration[];
375
+ phases?: Phase[];
376
+ baseline?: Baseline;
377
+ /** waterfall: every baseline ever taken, oldest first; `baseline` is the last one */
378
+ baselines?: Baseline[];
379
+ events: Event[];
380
+ accounting: Accounting[];
381
+ pending: PendingHuman[];
382
+ lessons: Lesson[];
383
+ /** adopted working agreements; synthesizeBrief appends them to invariants */
384
+ agreements: string[];
385
+ }
386
+ interface Action {
387
+ type: string;
388
+ by: string;
389
+ payload?: unknown;
390
+ }
391
+ interface Violation {
392
+ rule: string;
393
+ severity: "error" | "warning";
394
+ item?: string;
395
+ message: string;
396
+ fix: string;
397
+ }
398
+ interface Rule {
399
+ id: string;
400
+ severity: "error" | "warning";
401
+ check(state: WorkflowState, action: Action): Violation[];
402
+ }
403
+ interface ApplyResult {
404
+ state: WorkflowState;
405
+ warnings: Violation[];
406
+ }
407
+ interface Brief {
408
+ item: WorkItem;
409
+ role: Role;
410
+ modelTier: ModelTier;
411
+ invariants: string[];
412
+ do_not: string[];
413
+ acceptance: string[];
414
+ upstream: Array<{
415
+ item: string;
416
+ produced: Handoff["produced"];
417
+ notes: string;
418
+ }>;
419
+ /** earlier completions of THIS item (rework feedback) */
420
+ priorHandoffs: Array<{
421
+ role: string;
422
+ verdict: Verdict;
423
+ notes: string;
424
+ produced: Handoff["produced"];
425
+ at: string;
426
+ }>;
427
+ /** open bug/change-request items whose `affects` touches this item or its dependsOn */
428
+ relatedBugs: Array<{
429
+ id: string;
430
+ title: string;
431
+ affects: string[];
432
+ }>;
433
+ budgetRemaining: Budget;
434
+ gateAhead?: Gate;
435
+ /** for a question item: the escalating item's last handoff */
436
+ parent?: {
437
+ item: string;
438
+ role: string;
439
+ notes: string;
440
+ produced: Handoff["produced"];
441
+ open_questions: string[];
442
+ do_not: string[];
443
+ };
444
+ }
445
+ type CoreTerm = "backlog" | "item" | "stage" | "iteration" | "increment" | "ceremony" | "gate";
446
+ type CeremonyInput = {
447
+ by: string;
448
+ now?: string;
449
+ } & Record<string, unknown>;
450
+ type Ceremony = (state: WorkflowState, input: CeremonyInput) => ApplyResult;
451
+ interface PlannerOptions {
452
+ schedulerMode: "level" | "throughput";
453
+ /** Stage a todo item is pulled into when dispatched; a function decides per item; omitted/undefined = stay in its current stage. */
454
+ dispatchStage?: string | ((item: WorkItem) => string | undefined);
455
+ concurrencyCap?: number;
456
+ fairnessPolicy?: "none" | "aging";
457
+ maxDeferralRounds?: number;
458
+ deadlineStrategy?: "earliest-first" | "latest-first";
459
+ weightStrategy?: "higher-first" | "lower-first";
460
+ /** Priority the planner orders by; defaults to item.priority. */
461
+ priorityOf?(item: WorkItem): number | undefined;
462
+ /** Orders items of equal priority (after deadline/weight strategies); e.g. class of service, then age. */
463
+ tieBreaker?(a: WorkItem, b: WorkItem): number;
464
+ /** Statuses that occupy a stage's wipLimit slot; default ["in_progress"]. */
465
+ wipCounts?: ItemStatus[];
466
+ /** Per-item replacement for the target stage's wipLimit (e.g. an expedite bypass); undefined = no limit. */
467
+ wipLimitOf?(stage: Stage, item: WorkItem): number | undefined;
468
+ /** Role id to dispatch a todo item to (e.g. the phase's deliverer); undefined = default (item.role, then reviewer/deliverer by capability). */
469
+ roleFor?(item: WorkItem): string | undefined;
470
+ /** Tokens reserved for work already in flight, deducted from the iteration remainder. */
471
+ reservedTokens?: number;
472
+ /** How estimateTokens prices a candidate; default "per-weight". */
473
+ estimateMode?: "per-weight" | "per-call";
474
+ /** Tokens per weight unit when no accounting history exists; default 20000. PlanOptions.fallbackTokensPerWeight wins. */
475
+ fallbackTokensPerWeight?: number;
476
+ }
477
+ interface Methodology<C = unknown> {
478
+ name: MethodologyName;
479
+ vocabulary: Record<CoreTerm, string>;
480
+ validateConfig(config: unknown): C;
481
+ defaultStages(config: C): Stage[];
482
+ defaultRoles(config: C): Role[];
483
+ requiredCapabilities: Capability[];
484
+ exclusiveCapabilities: Capability[];
485
+ plannerOptions(state: WorkflowState): PlannerOptions;
486
+ candidates(state: WorkflowState): WorkItem[];
487
+ invariants(state: WorkflowState, item: WorkItem): string[];
488
+ ceremonies: Record<string, Ceremony>;
489
+ rules: Rule[];
490
+ metrics(state: WorkflowState): Record<string, number | number[] | Record<string, number>>;
491
+ humanDefaults: {
492
+ gates: "all" | "none" | string[];
493
+ };
494
+ /** Called after complete(); lets the methodology react (e.g. close a sprint when the budget is gone). */
495
+ afterComplete?(state: WorkflowState, itemId: string, now: string): WorkflowState;
496
+ /** Config keys that cannot change after init (changeConfig refuses them). */
497
+ lockedConfigKeys?: string[];
498
+ /** Called by changeConfig after the new config is stored; keeps derived state (e.g. stage policies) in step. */
499
+ afterConfigChange?(state: WorkflowState, now: string): WorkflowState;
500
+ /** Methodology-specific status for hosts (e.g. cadences due); printed by `exwf status`. */
501
+ report?(state: WorkflowState): Record<string, unknown>;
502
+ /** 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). */
503
+ afterDecide?(state: WorkflowState, entry: PendingHuman, decision: "approve" | "reject", by: string, note: string, now: string): WorkflowState;
504
+ }
505
+ 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"
506
+ /** reserved: never thrown; kept for type compatibility */
507
+ | "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";
508
+
509
+ export type { Accounting as A, Brief as B, Capability as C, Blocker as D, Experiment as E, ImpactAnalysis as F, Gate as G, Handoff as H, InvestigationConclusion as I, ItemType as J, LessonChange as K, Lesson as L, Methodology as M, NewItem as N, Observation as O, Policy as P, ModelTier as Q, Role as R, Stage as S, Transition as T, PlannerOptions as U, Violation as V, WorkflowState as W, Produced as X, Spent as Y, Verdict as Z, Budget as a, BeliefUpdate as b, Hypothesis as c, InvestigationRound as d, InvestigationState as e, Ceremony as f, Rule as g, ExperimentCandidate as h, ExperimentationState as i, ItemStatus as j, CoreTerm as k, WorkItem as l, ClassOfService as m, CeremonyInput as n, Event as o, GateRequirement as p, Phase as q, PendingHuman as r, ErrorCode as s, MethodologyName as t, Evidence as u, ItemPatch as v, Iteration as w, ApplyResult as x, Action as y, Baseline as z };