ex-workflow 1.2.0 → 1.4.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 (157) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/README.md +147 -13
  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-Gckmqj74.d.ts → budget-BuQ9GWsg.d.ts} +1 -1
  8. package/dist/{budget-Bm839Qw0.d.cts → budget-DDqQQIgp.d.cts} +1 -1
  9. package/dist/{chunk-LIATP6LY.mjs → chunk-3QUIRAXO.mjs} +2 -2
  10. package/dist/{chunk-LIATP6LY.mjs.map → chunk-3QUIRAXO.mjs.map} +1 -1
  11. package/dist/chunk-3RJ4RNPG.cjs +2 -0
  12. package/dist/chunk-3RJ4RNPG.cjs.map +1 -0
  13. package/dist/chunk-66BO7JFR.cjs +2 -0
  14. package/dist/chunk-66BO7JFR.cjs.map +1 -0
  15. package/dist/chunk-6PFJYRM7.cjs +2 -0
  16. package/dist/chunk-6PFJYRM7.cjs.map +1 -0
  17. package/dist/chunk-76ITDJDM.cjs +2 -0
  18. package/dist/{chunk-QAENYYU6.cjs.map → chunk-76ITDJDM.cjs.map} +1 -1
  19. package/dist/chunk-AWFR3Q4M.mjs +2 -0
  20. package/dist/{chunk-32NVJV5C.mjs.map → chunk-AWFR3Q4M.mjs.map} +1 -1
  21. package/dist/chunk-BD665RYK.mjs +2 -0
  22. package/dist/chunk-BD665RYK.mjs.map +1 -0
  23. package/dist/chunk-BGKXIRGS.mjs +2 -0
  24. package/dist/chunk-BGKXIRGS.mjs.map +1 -0
  25. package/dist/chunk-BNKKOAMP.mjs +2 -0
  26. package/dist/{chunk-OZAYOPLB.mjs.map → chunk-BNKKOAMP.mjs.map} +1 -1
  27. package/dist/{chunk-IIEKK2S3.cjs → chunk-CPM2SPDX.cjs} +2 -2
  28. package/dist/{chunk-IIEKK2S3.cjs.map → chunk-CPM2SPDX.cjs.map} +1 -1
  29. package/dist/chunk-DVFTTBCT.cjs +3 -0
  30. package/dist/chunk-DVFTTBCT.cjs.map +1 -0
  31. package/dist/{chunk-U3RU5LOF.cjs → chunk-G6QELJRL.cjs} +2 -2
  32. package/dist/{chunk-U3RU5LOF.cjs.map → chunk-G6QELJRL.cjs.map} +1 -1
  33. package/dist/{chunk-6D6FL3XK.mjs → chunk-HXEJP6KF.mjs} +2 -2
  34. package/dist/{chunk-6D6FL3XK.mjs.map → chunk-HXEJP6KF.mjs.map} +1 -1
  35. package/dist/chunk-ILNSTPPV.mjs +2 -0
  36. package/dist/chunk-ILNSTPPV.mjs.map +1 -0
  37. package/dist/{chunk-RXY434DX.cjs → chunk-KA6DVHO5.cjs} +4 -4
  38. package/dist/{chunk-RXY434DX.cjs.map → chunk-KA6DVHO5.cjs.map} +1 -1
  39. package/dist/chunk-KLOSFZFK.cjs +2 -0
  40. package/dist/chunk-KLOSFZFK.cjs.map +1 -0
  41. package/dist/chunk-LQJPLXFR.cjs +2 -0
  42. package/dist/chunk-LQJPLXFR.cjs.map +1 -0
  43. package/dist/chunk-MUQ4FKVH.mjs +2 -0
  44. package/dist/chunk-MUQ4FKVH.mjs.map +1 -0
  45. package/dist/chunk-N2NANHRW.mjs +2 -0
  46. package/dist/{chunk-4HG6A3SF.mjs.map → chunk-N2NANHRW.mjs.map} +1 -1
  47. package/dist/chunk-NNQ3RHDP.mjs +2 -0
  48. package/dist/chunk-NNQ3RHDP.mjs.map +1 -0
  49. package/dist/chunk-OAJ4KV4F.mjs +2 -0
  50. package/dist/{chunk-BYPFTO7P.mjs.map → chunk-OAJ4KV4F.mjs.map} +1 -1
  51. package/dist/chunk-OFFQTZEY.cjs +2 -0
  52. package/dist/chunk-OFFQTZEY.cjs.map +1 -0
  53. package/dist/{chunk-3GKYL6VB.mjs → chunk-ONVAUZOD.mjs} +3 -3
  54. package/dist/{chunk-3GKYL6VB.mjs.map → chunk-ONVAUZOD.mjs.map} +1 -1
  55. package/dist/chunk-QJMOCISZ.mjs +3 -0
  56. package/dist/chunk-QJMOCISZ.mjs.map +1 -0
  57. package/dist/chunk-QKW26EV2.mjs +2 -0
  58. package/dist/chunk-QKW26EV2.mjs.map +1 -0
  59. package/dist/{chunk-W2P27645.cjs → chunk-RMXEQ5HN.cjs} +2 -2
  60. package/dist/{chunk-W2P27645.cjs.map → chunk-RMXEQ5HN.cjs.map} +1 -1
  61. package/dist/chunk-TBLIZIWH.cjs +2 -0
  62. package/dist/chunk-TBLIZIWH.cjs.map +1 -0
  63. package/dist/chunk-U23IRPFF.cjs +2 -0
  64. package/dist/{chunk-SFYUJQYW.cjs.map → chunk-U23IRPFF.cjs.map} +1 -1
  65. package/dist/chunk-WM3JM3H7.mjs +2 -0
  66. package/dist/chunk-WM3JM3H7.mjs.map +1 -0
  67. package/dist/chunk-WU5JELOM.mjs +2 -0
  68. package/dist/chunk-WU5JELOM.mjs.map +1 -0
  69. package/dist/chunk-YNYIHJOC.mjs +2 -0
  70. package/dist/chunk-YNYIHJOC.mjs.map +1 -0
  71. package/dist/chunk-YRXFEM3F.cjs +2 -0
  72. package/dist/chunk-YRXFEM3F.cjs.map +1 -0
  73. package/dist/{chunk-K4VSMIJZ.cjs → chunk-ZDT2BZGU.cjs} +2 -2
  74. package/dist/{chunk-K4VSMIJZ.cjs.map → chunk-ZDT2BZGU.cjs.map} +1 -1
  75. package/dist/{chunk-OVR5CK3R.cjs → chunk-ZK3V66NC.cjs} +2 -2
  76. package/dist/{chunk-OVR5CK3R.cjs.map → chunk-ZK3V66NC.cjs.map} +1 -1
  77. package/dist/cli/bin.cjs +1 -1
  78. package/dist/cli/bin.cjs.map +1 -1
  79. package/dist/cli/bin.mjs +1 -1
  80. package/dist/cli/bin.mjs.map +1 -1
  81. package/dist/cli/index.cjs +1 -1
  82. package/dist/cli/index.mjs +1 -1
  83. package/dist/experimentation/index.cjs +1 -1
  84. package/dist/experimentation/index.d.cts +2 -2
  85. package/dist/experimentation/index.d.ts +2 -2
  86. package/dist/experimentation/index.mjs +1 -1
  87. package/dist/index.cjs +1 -1
  88. package/dist/index.cjs.map +1 -1
  89. package/dist/index.d.cts +15 -12
  90. package/dist/index.d.ts +15 -12
  91. package/dist/index.mjs +1 -1
  92. package/dist/index.mjs.map +1 -1
  93. package/dist/investigation/index.cjs +1 -1
  94. package/dist/investigation/index.d.cts +2 -2
  95. package/dist/investigation/index.d.ts +2 -2
  96. package/dist/investigation/index.mjs +1 -1
  97. package/dist/kanban/index.cjs +1 -1
  98. package/dist/kanban/index.d.cts +1 -1
  99. package/dist/kanban/index.d.ts +1 -1
  100. package/dist/kanban/index.mjs +1 -1
  101. package/dist/policies/index.cjs +2 -0
  102. package/dist/policies/index.cjs.map +1 -0
  103. package/dist/policies/index.d.cts +202 -0
  104. package/dist/policies/index.d.ts +202 -0
  105. package/dist/policies/index.mjs +2 -0
  106. package/dist/policies/index.mjs.map +1 -0
  107. package/dist/registry/index.cjs +1 -1
  108. package/dist/registry/index.d.cts +1 -1
  109. package/dist/registry/index.d.ts +1 -1
  110. package/dist/registry/index.mjs +1 -1
  111. package/dist/schema/index.cjs +1 -1
  112. package/dist/schema/index.mjs +1 -1
  113. package/dist/scrum/index.cjs +1 -1
  114. package/dist/scrum/index.d.cts +3 -3
  115. package/dist/scrum/index.d.ts +3 -3
  116. package/dist/scrum/index.mjs +1 -1
  117. package/dist/{types-DjePDfms.d.cts → types-DLOtndDY.d.cts} +61 -1
  118. package/dist/{types-DjePDfms.d.ts → types-DLOtndDY.d.ts} +61 -1
  119. package/dist/types.d.cts +1 -1
  120. package/dist/types.d.ts +1 -1
  121. package/dist/waterfall/index.cjs +1 -1
  122. package/dist/waterfall/index.d.cts +1 -1
  123. package/dist/waterfall/index.d.ts +1 -1
  124. package/dist/waterfall/index.mjs +1 -1
  125. package/package.json +14 -1
  126. package/dist/chunk-32NVJV5C.mjs +0 -2
  127. package/dist/chunk-3O5MPAJT.cjs +0 -2
  128. package/dist/chunk-3O5MPAJT.cjs.map +0 -1
  129. package/dist/chunk-43GLYYA2.cjs +0 -3
  130. package/dist/chunk-43GLYYA2.cjs.map +0 -1
  131. package/dist/chunk-4HG6A3SF.mjs +0 -2
  132. package/dist/chunk-7EF47R2J.mjs +0 -2
  133. package/dist/chunk-7EF47R2J.mjs.map +0 -1
  134. package/dist/chunk-BD76VFI4.mjs +0 -3
  135. package/dist/chunk-BD76VFI4.mjs.map +0 -1
  136. package/dist/chunk-BHAEPYRJ.cjs +0 -2
  137. package/dist/chunk-BHAEPYRJ.cjs.map +0 -1
  138. package/dist/chunk-BYPFTO7P.mjs +0 -2
  139. package/dist/chunk-FDZB73PH.mjs +0 -2
  140. package/dist/chunk-FDZB73PH.mjs.map +0 -1
  141. package/dist/chunk-JNLWI4JM.mjs +0 -2
  142. package/dist/chunk-JNLWI4JM.mjs.map +0 -1
  143. package/dist/chunk-LCN4UNYK.cjs +0 -2
  144. package/dist/chunk-LCN4UNYK.cjs.map +0 -1
  145. package/dist/chunk-MB465DI4.mjs +0 -2
  146. package/dist/chunk-MB465DI4.mjs.map +0 -1
  147. package/dist/chunk-OZAYOPLB.mjs +0 -2
  148. package/dist/chunk-QAENYYU6.cjs +0 -2
  149. package/dist/chunk-SFYUJQYW.cjs +0 -2
  150. package/dist/chunk-UUWDQVIJ.mjs +0 -2
  151. package/dist/chunk-UUWDQVIJ.mjs.map +0 -1
  152. package/dist/chunk-VXOZIP77.cjs +0 -2
  153. package/dist/chunk-VXOZIP77.cjs.map +0 -1
  154. package/dist/chunk-WPVL27G4.mjs +0 -2
  155. package/dist/chunk-WPVL27G4.mjs.map +0 -1
  156. package/dist/chunk-Z43GUETW.cjs +0 -2
  157. package/dist/chunk-Z43GUETW.cjs.map +0 -1
@@ -121,6 +121,8 @@ interface Evidence {
121
121
  ref: string;
122
122
  by: string;
123
123
  at: string;
124
+ /** Structured content a policy reads (e.g. a risk level); the policy that owns the kind validates it. */
125
+ data?: Record<string, unknown>;
124
126
  }
125
127
  interface Blocker {
126
128
  id: string;
@@ -213,6 +215,48 @@ interface Gate {
213
215
  stage: string;
214
216
  };
215
217
  }
218
+ /**
219
+ * What a methodology's `escalateGate` hook adds to a static gate (design spec section 27, #35).
220
+ * Core only appends these to the gate (`widenGate`); it never removes or replaces a requirement.
221
+ */
222
+ interface GateEscalation {
223
+ requires: GateRequirement[];
224
+ evidence: string[];
225
+ /** Why the gate was widened; recorded in the `gate.resolved` event (e.g. the risk level and its assessment). */
226
+ reason: Record<string, string | null>;
227
+ }
228
+ /**
229
+ * One claim of a context snapshot (design spec section 27, #36). With no `source` it is
230
+ * unverified. `source.path` is repository-relative POSIX (as Git lists it); the engine compares
231
+ * paths and hashes only, it never reads a file.
232
+ */
233
+ interface ContextAssumption {
234
+ claim: string;
235
+ /** A required claim must be verified (carry a `source`) for the context-grounded policy to pass. */
236
+ required?: boolean;
237
+ source?: {
238
+ path: string;
239
+ lines?: [number, number];
240
+ hash: string;
241
+ };
242
+ }
243
+ /** `data` of a `context-snapshot` evidence entry. */
244
+ interface ContextSnapshotData {
245
+ /** The repository revision the snapshot was taken at. */
246
+ revision: string;
247
+ assumptions: ContextAssumption[];
248
+ }
249
+ /** An item's current context snapshot as a worker's brief carries it. */
250
+ interface BriefContext extends ContextSnapshotData {
251
+ /** The snapshot artifact (the evidence `ref`). */
252
+ snapshot: string;
253
+ /** Who recorded it. */
254
+ by: string;
255
+ /** Cited paths a later `repo.changed` event listed; empty while the snapshot is fresh. */
256
+ stale: string[];
257
+ /** Claims with no `source`. */
258
+ unverified: string[];
259
+ }
216
260
  interface Stage {
217
261
  id: string;
218
262
  name: string;
@@ -467,6 +511,8 @@ interface Brief {
467
511
  }>;
468
512
  budgetRemaining: Budget;
469
513
  gateAhead?: Gate;
514
+ /** the item's context snapshot, from the methodology's `briefContext` hook (spec 27, #36) */
515
+ context?: BriefContext;
470
516
  /** for a question item: the escalating item's last handoff */
471
517
  parent?: {
472
518
  item: string;
@@ -540,9 +586,23 @@ interface Methodology<C = unknown, N extends string = MethodologyName> {
540
586
  report?(state: WorkflowState<N>): Record<string, unknown>;
541
587
  /** 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). */
542
588
  afterDecide?(state: WorkflowState<N>, entry: PendingHuman, decision: "approve" | "reject", by: string, note: string, now: string): WorkflowState<N>;
589
+ /**
590
+ * Called by complete() before a gated completion is checked; what it returns is appended to the
591
+ * static gate (escalation only) and the widened gate is recorded as `gate.resolved`.
592
+ */
593
+ escalateGate?(state: WorkflowState<N>, item: WorkItem, gate: Gate): GateEscalation | undefined;
594
+ /**
595
+ * Answers a `custom` stage policy (spec 27, #36) for `plan()` and `complete()`: an array is the
596
+ * policy's violations (empty passes); `undefined` keeps the 1.2 check (`policy:<id>` evidence).
597
+ */
598
+ customPolicy?(state: WorkflowState<N>, item: WorkItem, policy: Extract<Policy, {
599
+ kind: "custom";
600
+ }>): Violation[] | undefined;
601
+ /** What `synthesizeBrief` puts in `Brief.context` (spec 27, #36); `undefined` leaves it out. */
602
+ briefContext?(state: WorkflowState<N>, item: WorkItem): BriefContext | undefined;
543
603
  }
544
604
  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"
545
605
  /** reserved: never thrown; kept for type compatibility */
546
606
  | "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";
547
607
 
548
- 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, WorkflowExt as _, 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, ItemPatch as u, Evidence as v, Iteration as w, ApplyResult as x, Action as y, Baseline as z };
608
+ export type { Produced as $, Accounting as A, Brief as B, Capability as C, Iteration as D, Experiment as E, Action as F, GateRequirement as G, Handoff as H, InvestigationConclusion as I, Baseline as J, Blocker as K, ContextSnapshotData as L, Methodology as M, NewItem as N, Observation as O, Policy as P, ImpactAnalysis as Q, Role as R, Stage as S, Transition as T, ItemType as U, Violation as V, WorkflowState as W, Lesson as X, LessonChange as Y, ModelTier as Z, PlannerOptions as _, Budget as a, Spent as a0, Verdict as a1, WorkflowExt as a2, 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, Gate as m, GateEscalation as n, ApplyResult as o, ContextAssumption as p, BriefContext as q, ClassOfService as r, CeremonyInput as s, Event as t, Phase as u, PendingHuman as v, ErrorCode as w, MethodologyName as x, ItemPatch as y, Evidence as z };
@@ -121,6 +121,8 @@ interface Evidence {
121
121
  ref: string;
122
122
  by: string;
123
123
  at: string;
124
+ /** Structured content a policy reads (e.g. a risk level); the policy that owns the kind validates it. */
125
+ data?: Record<string, unknown>;
124
126
  }
125
127
  interface Blocker {
126
128
  id: string;
@@ -213,6 +215,48 @@ interface Gate {
213
215
  stage: string;
214
216
  };
215
217
  }
218
+ /**
219
+ * What a methodology's `escalateGate` hook adds to a static gate (design spec section 27, #35).
220
+ * Core only appends these to the gate (`widenGate`); it never removes or replaces a requirement.
221
+ */
222
+ interface GateEscalation {
223
+ requires: GateRequirement[];
224
+ evidence: string[];
225
+ /** Why the gate was widened; recorded in the `gate.resolved` event (e.g. the risk level and its assessment). */
226
+ reason: Record<string, string | null>;
227
+ }
228
+ /**
229
+ * One claim of a context snapshot (design spec section 27, #36). With no `source` it is
230
+ * unverified. `source.path` is repository-relative POSIX (as Git lists it); the engine compares
231
+ * paths and hashes only, it never reads a file.
232
+ */
233
+ interface ContextAssumption {
234
+ claim: string;
235
+ /** A required claim must be verified (carry a `source`) for the context-grounded policy to pass. */
236
+ required?: boolean;
237
+ source?: {
238
+ path: string;
239
+ lines?: [number, number];
240
+ hash: string;
241
+ };
242
+ }
243
+ /** `data` of a `context-snapshot` evidence entry. */
244
+ interface ContextSnapshotData {
245
+ /** The repository revision the snapshot was taken at. */
246
+ revision: string;
247
+ assumptions: ContextAssumption[];
248
+ }
249
+ /** An item's current context snapshot as a worker's brief carries it. */
250
+ interface BriefContext extends ContextSnapshotData {
251
+ /** The snapshot artifact (the evidence `ref`). */
252
+ snapshot: string;
253
+ /** Who recorded it. */
254
+ by: string;
255
+ /** Cited paths a later `repo.changed` event listed; empty while the snapshot is fresh. */
256
+ stale: string[];
257
+ /** Claims with no `source`. */
258
+ unverified: string[];
259
+ }
216
260
  interface Stage {
217
261
  id: string;
218
262
  name: string;
@@ -467,6 +511,8 @@ interface Brief {
467
511
  }>;
468
512
  budgetRemaining: Budget;
469
513
  gateAhead?: Gate;
514
+ /** the item's context snapshot, from the methodology's `briefContext` hook (spec 27, #36) */
515
+ context?: BriefContext;
470
516
  /** for a question item: the escalating item's last handoff */
471
517
  parent?: {
472
518
  item: string;
@@ -540,9 +586,23 @@ interface Methodology<C = unknown, N extends string = MethodologyName> {
540
586
  report?(state: WorkflowState<N>): Record<string, unknown>;
541
587
  /** 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). */
542
588
  afterDecide?(state: WorkflowState<N>, entry: PendingHuman, decision: "approve" | "reject", by: string, note: string, now: string): WorkflowState<N>;
589
+ /**
590
+ * Called by complete() before a gated completion is checked; what it returns is appended to the
591
+ * static gate (escalation only) and the widened gate is recorded as `gate.resolved`.
592
+ */
593
+ escalateGate?(state: WorkflowState<N>, item: WorkItem, gate: Gate): GateEscalation | undefined;
594
+ /**
595
+ * Answers a `custom` stage policy (spec 27, #36) for `plan()` and `complete()`: an array is the
596
+ * policy's violations (empty passes); `undefined` keeps the 1.2 check (`policy:<id>` evidence).
597
+ */
598
+ customPolicy?(state: WorkflowState<N>, item: WorkItem, policy: Extract<Policy, {
599
+ kind: "custom";
600
+ }>): Violation[] | undefined;
601
+ /** What `synthesizeBrief` puts in `Brief.context` (spec 27, #36); `undefined` leaves it out. */
602
+ briefContext?(state: WorkflowState<N>, item: WorkItem): BriefContext | undefined;
543
603
  }
544
604
  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"
545
605
  /** reserved: never thrown; kept for type compatibility */
546
606
  | "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";
547
607
 
548
- 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, WorkflowExt as _, 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, ItemPatch as u, Evidence as v, Iteration as w, ApplyResult as x, Action as y, Baseline as z };
608
+ export type { Produced as $, Accounting as A, Brief as B, Capability as C, Iteration as D, Experiment as E, Action as F, GateRequirement as G, Handoff as H, InvestigationConclusion as I, Baseline as J, Blocker as K, ContextSnapshotData as L, Methodology as M, NewItem as N, Observation as O, Policy as P, ImpactAnalysis as Q, Role as R, Stage as S, Transition as T, ItemType as U, Violation as V, WorkflowState as W, Lesson as X, LessonChange as Y, ModelTier as Z, PlannerOptions as _, Budget as a, Spent as a0, Verdict as a1, WorkflowExt as a2, 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, Gate as m, GateEscalation as n, ApplyResult as o, ContextAssumption as p, BriefContext as q, ClassOfService as r, CeremonyInput as s, Event as t, Phase as u, PendingHuman as v, ErrorCode as w, MethodologyName as x, ItemPatch as y, Evidence as z };
package/dist/types.d.cts CHANGED
@@ -1 +1 @@
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, v as Evidence, G as Gate, p as GateRequirement, H as Handoff, F as ImpactAnalysis, u 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, _ as WorkflowExt, W as WorkflowState } from './types-DjePDfms.cjs';
1
+ export { A as Accounting, F as Action, o as ApplyResult, J as Baseline, K as Blocker, B as Brief, q as BriefContext, a as Budget, C as Capability, f as Ceremony, s as CeremonyInput, r as ClassOfService, p as ContextAssumption, L as ContextSnapshotData, k as CoreTerm, w as ErrorCode, t as Event, z as Evidence, m as Gate, n as GateEscalation, G as GateRequirement, H as Handoff, Q as ImpactAnalysis, y as ItemPatch, j as ItemStatus, U as ItemType, D as Iteration, X as Lesson, Y as LessonChange, M as Methodology, x as MethodologyName, Z as ModelTier, N as NewItem, v as PendingHuman, u as Phase, _ as PlannerOptions, P as Policy, $ as Produced, R as Role, g as Rule, a0 as Spent, S as Stage, T as Transition, a1 as Verdict, V as Violation, l as WorkItem, a2 as WorkflowExt, W as WorkflowState } from './types-DLOtndDY.cjs';
package/dist/types.d.ts CHANGED
@@ -1 +1 @@
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, v as Evidence, G as Gate, p as GateRequirement, H as Handoff, F as ImpactAnalysis, u 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, _ as WorkflowExt, W as WorkflowState } from './types-DjePDfms.js';
1
+ export { A as Accounting, F as Action, o as ApplyResult, J as Baseline, K as Blocker, B as Brief, q as BriefContext, a as Budget, C as Capability, f as Ceremony, s as CeremonyInput, r as ClassOfService, p as ContextAssumption, L as ContextSnapshotData, k as CoreTerm, w as ErrorCode, t as Event, z as Evidence, m as Gate, n as GateEscalation, G as GateRequirement, H as Handoff, Q as ImpactAnalysis, y as ItemPatch, j as ItemStatus, U as ItemType, D as Iteration, X as Lesson, Y as LessonChange, M as Methodology, x as MethodologyName, Z as ModelTier, N as NewItem, v as PendingHuman, u as Phase, _ as PlannerOptions, P as Policy, $ as Produced, R as Role, g as Rule, a0 as Spent, S as Stage, T as Transition, a1 as Verdict, V as Violation, l as WorkItem, a2 as WorkflowExt, W as WorkflowState } from './types-DLOtndDY.js';
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkVXOZIP77_cjs=require('../chunk-VXOZIP77.cjs');require('../chunk-GKN5M4B7.cjs'),require('../chunk-W2P27645.cjs'),require('../chunk-OVR5CK3R.cjs'),require('../chunk-Z43GUETW.cjs'),require('../chunk-OSHBJIYD.cjs');Object.defineProperty(exports,"CHANGE_GATE",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.e}});Object.defineProperty(exports,"DEFAULT_DELIVERABLES",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.b}});Object.defineProperty(exports,"DEFAULT_DELIVER_BY",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.c}});Object.defineProperty(exports,"DEFAULT_PHASE_IDS",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.a}});Object.defineProperty(exports,"DONE",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.k}});Object.defineProperty(exports,"GATE_ID",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.d}});Object.defineProperty(exports,"REVIEW",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.j}});Object.defineProperty(exports,"WATERFALL_VOCABULARY",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.K}});Object.defineProperty(exports,"WORK",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.i}});Object.defineProperty(exports,"approveChange",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.z}});Object.defineProperty(exports,"baselinePhase",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.x}});Object.defineProperty(exports,"configOf",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.g}});Object.defineProperty(exports,"currentPhase",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.s}});Object.defineProperty(exports,"defaultPhases",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.f}});Object.defineProperty(exports,"deliverRoleFor",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.L}});Object.defineProperty(exports,"getPhase",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.o}});Object.defineProperty(exports,"isFrozen",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.t}});Object.defineProperty(exports,"itemsInPhase",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.q}});Object.defineProperty(exports,"lastToPhase",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.w}});Object.defineProperty(exports,"missingDeliverables",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.v}});Object.defineProperty(exports,"missingTraces",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.C}});Object.defineProperty(exports,"openPhase",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.r}});Object.defineProperty(exports,"phaseIndex",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.n}});Object.defineProperty(exports,"phaseOf",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.p}});Object.defineProperty(exports,"phaseReport",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.M}});Object.defineProperty(exports,"phasesOf",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.l}});Object.defineProperty(exports,"producedKinds",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.u}});Object.defineProperty(exports,"rejectChange",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.A}});Object.defineProperty(exports,"reopenPhases",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.y}});Object.defineProperty(exports,"traceabilityMatrix",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.B}});Object.defineProperty(exports,"validateWaterfallConfig",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.h}});Object.defineProperty(exports,"wantPhase",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.D}});Object.defineProperty(exports,"waterfall",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.N}});Object.defineProperty(exports,"waterfallAfterDecide",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.F}});Object.defineProperty(exports,"waterfallCeremonies",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.E}});Object.defineProperty(exports,"waterfallMetrics",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.G}});Object.defineProperty(exports,"waterfallRoles",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.H}});Object.defineProperty(exports,"waterfallRules",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.I}});Object.defineProperty(exports,"waterfallStages",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.J}});Object.defineProperty(exports,"withPhases",{enumerable:true,get:function(){return chunkVXOZIP77_cjs.m}});//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunkOFFQTZEY_cjs=require('../chunk-OFFQTZEY.cjs');require('../chunk-YRXFEM3F.cjs'),require('../chunk-GKN5M4B7.cjs'),require('../chunk-RMXEQ5HN.cjs'),require('../chunk-ZK3V66NC.cjs'),require('../chunk-TBLIZIWH.cjs'),require('../chunk-OSHBJIYD.cjs');Object.defineProperty(exports,"CHANGE_GATE",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.e}});Object.defineProperty(exports,"DEFAULT_DELIVERABLES",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.b}});Object.defineProperty(exports,"DEFAULT_DELIVER_BY",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.c}});Object.defineProperty(exports,"DEFAULT_PHASE_IDS",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.a}});Object.defineProperty(exports,"DONE",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.k}});Object.defineProperty(exports,"GATE_ID",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.d}});Object.defineProperty(exports,"REVIEW",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.j}});Object.defineProperty(exports,"WATERFALL_VOCABULARY",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.K}});Object.defineProperty(exports,"WORK",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.i}});Object.defineProperty(exports,"approveChange",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.z}});Object.defineProperty(exports,"baselinePhase",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.x}});Object.defineProperty(exports,"configOf",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.g}});Object.defineProperty(exports,"currentPhase",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.s}});Object.defineProperty(exports,"defaultPhases",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.f}});Object.defineProperty(exports,"deliverRoleFor",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.L}});Object.defineProperty(exports,"getPhase",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.o}});Object.defineProperty(exports,"isFrozen",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.t}});Object.defineProperty(exports,"itemsInPhase",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.q}});Object.defineProperty(exports,"lastToPhase",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.w}});Object.defineProperty(exports,"missingDeliverables",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.v}});Object.defineProperty(exports,"missingTraces",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.C}});Object.defineProperty(exports,"openPhase",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.r}});Object.defineProperty(exports,"phaseIndex",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.n}});Object.defineProperty(exports,"phaseOf",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.p}});Object.defineProperty(exports,"phaseReport",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.M}});Object.defineProperty(exports,"phasesOf",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.l}});Object.defineProperty(exports,"producedKinds",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.u}});Object.defineProperty(exports,"rejectChange",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.A}});Object.defineProperty(exports,"reopenPhases",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.y}});Object.defineProperty(exports,"traceabilityMatrix",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.B}});Object.defineProperty(exports,"validateWaterfallConfig",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.h}});Object.defineProperty(exports,"wantPhase",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.D}});Object.defineProperty(exports,"waterfall",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.N}});Object.defineProperty(exports,"waterfallAfterDecide",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.F}});Object.defineProperty(exports,"waterfallCeremonies",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.E}});Object.defineProperty(exports,"waterfallMetrics",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.G}});Object.defineProperty(exports,"waterfallRoles",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.H}});Object.defineProperty(exports,"waterfallRules",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.I}});Object.defineProperty(exports,"waterfallStages",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.J}});Object.defineProperty(exports,"withPhases",{enumerable:true,get:function(){return chunkOFFQTZEY_cjs.m}});//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
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-DjePDfms.cjs';
1
+ import { m as Gate, a as Budget, G as GateRequirement, W as WorkflowState, u as Phase, l as WorkItem, S as Stage, R as Role, g as Rule, s as CeremonyInput, v as PendingHuman, M as Methodology, f as Ceremony, k as CoreTerm } from '../types-DLOtndDY.cjs';
2
2
 
3
3
  interface WaterfallPhaseConfig {
4
4
  id: string;
@@ -1,4 +1,4 @@
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-DjePDfms.js';
1
+ import { m as Gate, a as Budget, G as GateRequirement, W as WorkflowState, u as Phase, l as WorkItem, S as Stage, R as Role, g as Rule, s as CeremonyInput, v as PendingHuman, M as Methodology, f as Ceremony, k as CoreTerm } from '../types-DLOtndDY.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-JNLWI4JM.mjs';import'../chunk-C4ISBUZR.mjs';import'../chunk-4HG6A3SF.mjs';import'../chunk-LIATP6LY.mjs';import'../chunk-UUWDQVIJ.mjs';import'../chunk-YS6CXERQ.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-BGKXIRGS.mjs';import'../chunk-MUQ4FKVH.mjs';import'../chunk-C4ISBUZR.mjs';import'../chunk-N2NANHRW.mjs';import'../chunk-3QUIRAXO.mjs';import'../chunk-NNQ3RHDP.mjs';import'../chunk-YS6CXERQ.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.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "Methodology engine for AI teams: Scrum, Kanban, Waterfall, Investigation and Experimentation as data-driven state machines on top of ex-flow",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -141,6 +141,16 @@
141
141
  "types": "./dist/registry/index.d.cts",
142
142
  "default": "./dist/registry/index.cjs"
143
143
  }
144
+ },
145
+ "./policies": {
146
+ "import": {
147
+ "types": "./dist/policies/index.d.ts",
148
+ "default": "./dist/policies/index.mjs"
149
+ },
150
+ "require": {
151
+ "types": "./dist/policies/index.d.cts",
152
+ "default": "./dist/policies/index.cjs"
153
+ }
144
154
  }
145
155
  },
146
156
  "typesVersions": {
@@ -174,6 +184,9 @@
174
184
  ],
175
185
  "registry": [
176
186
  "dist/registry/index.d.ts"
187
+ ],
188
+ "policies": [
189
+ "dist/policies/index.d.ts"
177
190
  ]
178
191
  }
179
192
  },
@@ -1,2 +0,0 @@
1
- import {a,b as b$1}from'./chunk-4HG6A3SF.mjs';import {N as N$1,K as K$1,m,h,r,l,c,L,U as U$1,a as a$1,s,u,x,q,t,C,n,B,M}from'./chunk-UUWDQVIJ.mjs';import {b}from'./chunk-YS6CXERQ.mjs';import {timSort}from'exsorted';var ye=["todo","in_progress","blocked","review","awaiting_human","done","dropped"];function be(o){let n=o.events.filter(i=>i.type==="sprint.closed"&&i.payload.reason!=="cancel");return n.length===0?null:n.reduce((i,r)=>i+r.payload.doneWeight,0)/n.length}function ae(o){let n=N$1(o),i=Object.fromEntries(ye.map(t=>[t,0])),r=[],g=0;for(let t of n?.committed??[]){let e=Object.hasOwn(o.items,t)?o.items[t]:void 0;if(e){i[e.status]+=1,e.status!=="done"&&(g+=e.weight??0);for(let s of e.blockers)s.clearedAt||r.push({item:t,blocker:s.id,owner:s.owner,reason:s.reason});}}let p=n?.spent??{tokens:0,turns:0,wallclockMs:0},f=n?K$1(n.budget,n.spent):{},y=be(o),k="unknown";if(n&&y!==null&&n.budget.tokens){let t=(f.tokens??0)/n.budget.tokens;k=g<=y*t?"on-track":"at-risk";}let d=o.lessons.filter(t=>t.status==="raised").length;return {sprint:n?.id??null,goal:n?.goal??null,byStatus:i,blockers:r,spent:p,remaining:f,remainingWeight:g,raisedLessons:d,velocity:y,forecast:k}}function U(o){for(let n=o.iterations.length-1;n>=0;n--){let i=o.iterations[n];if(i.endedAt!==void 0)return i}}function F(o,n){return o.events.find(i=>i.type==="sprint.closed"&&i.payload.id===n)?.seq??Number.POSITIVE_INFINITY}function he(o){let n=new Set(U(o)?.carryover??[]),i=Object.values(o.items).filter(r=>r.stage==="backlog"&&r.status==="todo"&&r.type!=="question");return timSort([...i],(r,g)=>{let p=n.has(r.id)?1:0,f=n.has(g.id)?1:0;return p!==f?f-p:(g.priority??0)-(r.priority??0)})}function re(o,n$1){let i=r(o,n$1);(i.stage!=="backlog"||i.status!=="todo")&&b("invalid-input",`item "${n$1}" is not in the Product Backlog (${i.stage}/${i.status})`,"only backlog items can be committed",{items:[n$1]}),C(o,i,n(o,"backlog").exitPolicy,"enter the Sprint Backlog");}function se(o,n,i,r,g){let p=o;for(let f of Object.values(o.items))f.type!=="question"||f.parent===void 0||!n.includes(f.parent)||f.status==="done"||f.status==="dropped"||((f.stage!=="sprint"||f.status!=="todo")&&(p=u(p,f.id,{stage:"sprint",status:"todo"},r,g)),p=q(p,f.id,y=>({...y,iteration:i})));return p}function N(o,n){return {...o,config:{...W(o),definitionOfDone:n},stages:o.stages.map(i=>i.id==="review"?{...i,exitPolicy:n}:i)}}function ke(o,n$1){let i=W(o),r=[],g=[],p=n(o,"backlog").exitPolicy,f=0;for(let y of he(o)){let k=B(o,y,p);if(k.length>0){g.push({id:y.id,reason:"policy",detail:k.map(d=>d.message).join("; ")});continue}if(n$1.turns!==void 0&&r.length>=n$1.turns){g.push({id:y.id,reason:"budget",detail:"turns budget full"});continue}if(n$1.tokens!==void 0){let d=M(o,y.weight,i.fallbackTokensPerWeight,i.estimateMode);if(f+d>n$1.tokens){g.push({id:y.id,reason:"budget",detail:`needs about ${d} tokens, ${n$1.tokens-f} left`});continue}f+=d;}r.push(y.id);}return {ids:r,skipped:g}}function K(o){let n=(t,e,s,m)=>U$1(t,o(),{type:e,by:s.by,payload:s},c=>m(c,a$1(s.now)));return {refine:(t$1,e)=>{m(t$1,e.by,"define-acceptance","deliver");let s$1=e.items??[],m$1=e.split??[],c$1=e.reestimate??[];(!Array.isArray(c$1)||!c$1.every(u=>typeof u=="string"))&&b("invalid-input","refine.reestimate must be a list of item ids",'pass reestimate: ["A"]');let l=c$1;s$1.length===0&&m$1.length===0&&l.length===0&&b("invalid-input","refine needs items[], split[] or reestimate[]","pass at least one patch, split or reestimate");for(let u of l){let h=r(t$1,u);(h.stage!=="backlog"||h.status!=="todo"||h.weight===void 0)&&b("invalid-input",`item "${u}" has no weight to confirm in the Product Backlog`,"refine it with a patch { weight } instead",{items:[u]});}return n(t$1,"ceremony.refine",e,(u$1,h)=>{for(let{id:a,patch:w}of s$1)u$1=t(u$1,a,w,e.by,h);for(let a of l)u$1=c(u$1,"item.reestimated",e.by,{id:a,weight:r(u$1,a).weight},h);for(let a of m$1){r(u$1,a.from);for(let w of a.into)u$1=s(u$1,{...w,parent:a.from},e.by,h);u$1=u(u$1,a.from,{status:"dropped"},e.by,h);}return c(u$1,"ceremony.refine",e.by,{edited:s$1.map(a=>a.id),split:m$1.map(a=>({from:a.from,into:a.into.map(w=>w.id)})),reestimated:l},h)})},plan:(t,e)=>{m(t,e.by,"facilitate");let s=e.goal;(typeof s!="string"||s.trim()==="")&&b("invalid-input","sprint planning needs a non-empty goal","state the Sprint Goal in one sentence");let m$1=W(t),c$1=e.budget??m$1.sprintBudget,l=e.items==="auto"?ke(t,c$1):void 0,u$1=l?.skipped??[],h=l?l.ids:e.items;Array.isArray(h)||b("invalid-input",'sprint planning needs items: string[] or "auto"','pass ["A","B"] or "auto"'),h.length===0&&b("invalid-input",`no backlog items fit the sprint${u$1.length?`; skipped: ${u$1.map(a=>`${a.id} (${a.reason}: ${a.detail})`).join(", ")}`:""}`,"refine the backlog (acceptance + estimates) or raise the budget with exwf config set");for(let a of h)re(t,a);return n(t,"ceremony.plan",e,(a,w)=>{let C=`S${a.iterations.length+1}`,M=U(a),O=h.filter(A=>M?.carryover.includes(A)),B=[];for(let A of h){let T=j(r(a,A),a);T&&B.push(A),a=u(a,A,T?{stage:T,status:"review"}:{stage:"sprint",status:"todo"},e.by,w),a=q(a,A,fe=>({...fe,iteration:C}));}a=se(a,h,C,e.by,w);let J=h.reduce((A,T)=>A+(a.items[T]?.weight??0),0);return a={...a,iterations:[...a.iterations,{id:C,goal:s,budget:c$1,spent:{tokens:0,turns:0,wallclockMs:0},startedAt:w,committed:[...h],carryover:O}]},c(a,"sprint.opened",e.by,{id:C,goal:s,committed:h,committedWeight:J,budget:c$1,skipped:u$1,resumed:B},w)})},commit:(t,e)=>{let s=N$1(t);s||b("invalid-input","no open sprint to commit into","run the plan ceremony first");let m=e.items;(!Array.isArray(m)||m.length===0)&&b("invalid-input","commit needs items[]",'pass ["A"]');let c$1=new Set;for(let l of m)c$1.has(l)&&b("invalid-input",`item "${l}" appears twice in items[]`,"list each item once",{items:[l]}),c$1.add(l),r(t,l),s.committed.includes(l)&&b("invalid-input",`item "${l}" is already committed to ${s.id}`,"nothing to do",{items:[l]}),re(t,l);return n(t,"ceremony.commit",e,(l,u$1)=>{let h=[];for(let a of m){let w=j(r(l,a),l);w&&h.push(a),l=u(l,a,w?{stage:w,status:"review"}:{stage:"sprint",status:"todo"},e.by,u$1),l=q(l,a,C=>({...C,iteration:s.id}));}return l=se(l,m,s.id,e.by,u$1),l={...l,iterations:l.iterations.map(a=>a.id===s.id?{...a,committed:[...a.committed,...m]}:a)},c(l,"sprint.committed",e.by,{id:s.id,items:m,goalImpact:e.goalImpact??null,resumed:h},u$1)})},uncommit:(t,e)=>{m(t,e.by,"order-backlog");let s=N$1(t);s||b("invalid-input","no open sprint","nothing to uncommit from");let m$1=e.items;(!Array.isArray(m$1)||m$1.length===0)&&b("invalid-input","uncommit needs items[]",'pass ["A"]');for(let c of m$1)r(t,c).status==="done"&&b("invalid-input",`item "${c}" is done`,"finished work cannot be uncommitted",{items:[c]});for(let c of m$1)s.committed.includes(c)||b("invalid-input",`item "${c}" is not committed to ${s.id}`,`committed: ${s.committed.join(", ")}`,{items:[c]});return n(t,"ceremony.uncommit",e,(c$1,l)=>{for(let u$1 of m$1)c$1=u(c$1,u$1,{stage:"backlog",status:"todo"},e.by,l),c$1=x(c$1,u$1,["iteration","role"]);return c$1={...c$1,iterations:c$1.iterations.map(u=>u.id===s.id?{...u,committed:u.committed.filter(h=>!m$1.includes(h))}:u)},c(c$1,"sprint.uncommitted",e.by,{id:s.id,items:m$1,reason:e.reason??""},l)})},daily:(t,e)=>n(t,"ceremony.daily",e,(s,m)=>c(s,"daily",e.by,ae(s),m)),review:(t,e)=>{let s$1=N$1(t);s$1||b("invalid-input","no open sprint to review","run the plan ceremony first");let m=h(t,"sprint-review");e.by!=="human"&&!m.includes(e.by)&&b("gate-unmet",`"${e.by}" may not accept the Sprint Review`,`run review as "human" or as ${m.join(", ")||"a role with canApprove sprint-review"}`,{rule:"sprint-review"});let c$1=e.feedback??[];return n(t,"ceremony.review",e,(l,u)=>{for(let a of c$1)l=s(l,{...a,stage:"backlog"},e.by,u);let h=s$1.committed.filter(a=>l.items[a]?.status==="done");return l=c(l,"increment",e.by,{sprint:s$1.id,done:h,goalMet:e.goalMet===true,accepted:e.accepted===true,feedback:c$1.map(a=>a.id)},u),E(l,"review",u)})},retro:(t,e)=>{m(t,e.by,"facilitate");let s$1=U(t);s$1||b("invalid-input","no closed sprint to retrospect","close the sprint (review or cancel) first"),N$1(t)&&b("invalid-input","a sprint is still open","retro runs between sprints; review or cancel the open one");let m$1=F(t,s$1.id);t.events.some(u=>u.type==="retro"&&u.seq>m$1)&&b("invalid-input",`sprint ${s$1.id} already has a retrospective`,"plan the next sprint");let c$1=a(t,e,"retro"),l=e.dodChanges;return n(t,"ceremony.retro",e,(u,h)=>{let a=[],w=false,C=b$1(u,c$1,e.by,h,(M,O)=>{if(O.kind==="dod"){let B=W(M).definitionOfDone;return B.some(J=>JSON.stringify(J)===JSON.stringify(O.policy))?M:(w=true,N(M,[...B,O.policy]))}return O.kind==="backlog"?(a.push(O.item.id),s(M,{...O.item,stage:"backlog",tags:[...O.item.tags??[],"retro"]},e.by,h)):M});return u=C.state,l&&(w=true,u=N(u,l)),c(u,"retro",e.by,{sprint:s$1.id,adopted:C.adopted,dismissed:C.dismissed,agreements:C.agreements,retired:C.retired,dodChanged:w,backlogAdded:a},h)})},cancel:(t,e)=>{m(t,e.by,"order-backlog");let s=N$1(t);return s||b("invalid-input","no open sprint to cancel","nothing to do"),n(t,"ceremony.cancel",e,(m,c$1)=>(m=c(m,"sprint.cancelled",e.by,{id:s.id,reason:e.reason??""},c$1),E(m,"cancel",c$1)))}}}var ve=new Set(["never","po-only","any"]);function ce(o){let n=o??{},i=n.sprintBudget;(!i||typeof i!="object"||i.tokens===void 0&&i.turns===void 0&&i.wallclockMs===void 0)&&b("config-invalid","scrum config.sprintBudget must define tokens, turns or wallclockMs",'e.g. { "sprintBudget": { "tokens": 400000, "turns": 60 } }'),(typeof n.productGoal!="string"||n.productGoal.trim()==="")&&b("config-invalid","scrum config.productGoal must be a non-empty string","state the Product Goal in one sentence"),Array.isArray(n.definitionOfDone)||b("config-invalid","scrum config.definitionOfDone must be a Policy[]",'e.g. [{ "kind": "evidence", "evidenceKind": "test-output" }]');let r=n.refinementSharePct??10;(typeof r!="number"||r<0||r>100)&&b("config-invalid","scrum config.refinementSharePct must be 0..100","omit it for the default 10");let g=n.allowMidSprintAdd??"po-only";(typeof g!="string"||!ve.has(g))&&b("config-invalid",`scrum config.allowMidSprintAdd must be never | po-only | any (got ${JSON.stringify(g)})`,'use "po-only" unless you have a reason');let p=n.inProgressWipLimit;p!==void 0&&(typeof p!="number"||p<1)&&b("config-invalid","scrum config.inProgressWipLimit must be a positive number","omit it for no limit");let f=n.autoClose;f!==void 0&&typeof f!="boolean"&&b("config-invalid","scrum config.autoClose must be true or false","omit it for the default true");let y=n.estimateMode;y!==void 0&&y!=="per-weight"&&y!=="per-call"&&b("config-invalid",`scrum config.estimateMode must be per-weight | per-call (got ${JSON.stringify(y)})`,'use "per-weight" (the default) or "per-call"');let k=n.fallbackTokensPerWeight;k!==void 0&&(typeof k!="number"||!Number.isFinite(k)||k<=0)&&b("config-invalid","scrum config.fallbackTokensPerWeight must be a positive finite number","omit it for the default 20000");let d={sprintBudget:i,productGoal:n.productGoal,definitionOfDone:n.definitionOfDone,refinementSharePct:r,allowMidSprintAdd:g};return p!==void 0&&(d.inProgressWipLimit=p),f!==void 0&&(d.autoClose=f),y!==void 0&&(d.estimateMode=y),k!==void 0&&(d.fallbackTokensPerWeight=k),d}var $=(o,n)=>n===0?0:o/n;function de(o){let n=o.events.filter(t=>t.type==="accounting.corrected"),i=o.events.filter(t=>t.type==="sprint.closed").map(t=>{let e=t.payload,s=n.filter(m=>m.seq>t.seq&&e.id!==void 0&&m.payload.iteration===e.id).reduce((m,c)=>m+c.payload.delta.tokens,0);return s===0?e:{...e,spent:{...e.spent,tokens:e.spent.tokens+s}}}),r=i.filter(t=>t.reason!=="cancel"),g=r.map(t=>t.doneWeight),p=r.reduce((t,e)=>t+e.doneWeight,0),f=r.reduce((t,e)=>t+e.committedWeight,0),y=o.events.filter(t=>t.type==="increment").map(t=>t.payload),k=i.filter(t=>t.budget.tokens!==void 0),d=r.reduce((t,e)=>t+e.spent.tokens,0);return {velocity:g,meanVelocity:$(g.reduce((t,e)=>t+e,0),g.length),burndown:o.events.filter(t=>t.type==="daily").map(t=>t.payload.remainingWeight),commitmentReliability:$(p,f),sprintGoalHitRate:$(y.filter(t=>t.goalMet).length,y.length),carryoverRatio:$(i.reduce((t,e)=>t+e.carryover.length,0),i.reduce((t,e)=>t+e.done.length+e.carryover.length,0)),budgetUtilisation:$(k.reduce((t,e)=>t+e.spent.tokens,0),k.reduce((t,e)=>t+(e.budget.tokens??0),0)),costPerPoint:$(d,p),current:we(o)}}function we(o){let n=N$1(o),i=(n?.committed??[]).map(k=>o.items[k]).filter(k=>k!==void 0),r=k=>k.reduce((d,t)=>d+(t.weight??0),0),g=r(i),p=r(i.filter(k=>k.status==="done")),f=n?.spent.tokens??0,y=n?.budget.tokens??0;return {spentTokens:f,spentTurns:n?.spent.turns??0,budgetTokens:y,committedWeight:g,doneWeight:p,remainingWeight:g-p,costPerPoint:$(f,p),budgetUtilisation:$(f,y)}}function le(){return [{id:"product-owner",name:"Product Owner",modelTier:"large",capabilities:["order-backlog","define-acceptance","escalate"],canApprove:["sprint-review"],inputs:["stakeholder-needs","product-goal"],outputs:["ordered-backlog","acceptance-criteria"],do_not:["do not implement items yourself"]},{id:"scrum-master",name:"Scrum Master",modelTier:"large",capabilities:["facilitate","escalate"],canApprove:[],inputs:["board","blockers"],outputs:["ceremony-records","lessons"],do_not:["do not reorder the Product Backlog","do not assign work; the planner pulls"]},{id:"developer",name:"Developer",modelTier:"small",capabilities:["deliver","review","verify"],canApprove:[],inputs:["brief"],outputs:["code","test-output"],do_not:["do not change acceptance criteria","do not touch items outside your brief"]}]}var I=(o,n,i,r,g)=>g?{rule:o,severity:n,item:g,message:i,fix:r}:{rule:o,severity:n,message:i,fix:r};function me(o){for(let n=o.iterations.length-1;n>=0;n--){let i=o.iterations[n];if(i.endedAt!==void 0)return i}}var H=o=>o.kind==="evidence"?`evidence:${o.evidenceKind}`:o.kind==="custom"?`custom:${o.id}`:o.kind;function ue(){return [{id:"one-open-sprint",severity:"error",check:(d,t)=>t.type==="ceremony.plan"&&N$1(d)?[I("one-open-sprint","error",`sprint ${N$1(d).id} is still open`,"review or cancel it before planning the next sprint")]:[]},{id:"retro-before-plan",severity:"error",check:(d,t)=>{if(t.type!=="ceremony.plan")return [];let e=me(d);if(!e)return [];let s=F(d,e.id);if(d.events.some(c=>c.type==="retro"&&c.seq>s))return [];let m=e.outcome==="cancelled"?"warning":"error";return [I("retro-before-plan",m,`sprint ${e.id} has no retrospective yet`,"run the retro ceremony first (lessons may be empty)")]}},{id:"sprint-budget-fixed",severity:"error",check:(d,t)=>{if(t.type!=="ceremony.plan")return [];let e=t.payload?.budget;return e===void 0||JSON.stringify(e)===JSON.stringify(W(d).sprintBudget)?[]:[I("sprint-budget-fixed","error","sprint length is fixed by config.sprintBudget","change sprintBudget between sprints with changeConfig / exwf config set, not per plan")]}},{id:"sprint-closing",severity:"error",check:(d,t)=>{let e=N$1(d);return t.type==="ceremony.commit"&&e?.closing?[I("sprint-closing","error",`sprint ${e.id} is closing: its budget is spent and no new work can start`,"run ceremony review or cancel first, then plan the next sprint")]:[]}},{id:"scrum-stage-ids",severity:"error",check:(d,t)=>{if(t.type!=="init")return [];let e=["backlog","sprint","review"].filter(s=>!d.stages.some(m=>m.id===s));return e.length&&b("config-invalid",`scrum stages lack the required id(s): ${e.join(", ")}`,"keep the stages backlog, sprint and review (omit stages to use the defaults), then run exwf init scrum again"),[]}},{id:"scope-protects-goal",severity:"error",check:(d,t)=>{if(t.type!=="ceremony.commit")return [];let e=W(d),s=t.payload??{};return e.allowMidSprintAdd==="never"?[I("scope-protects-goal","error","mid-sprint additions are disabled",'set allowMidSprintAdd to "po-only" or wait for the next sprint')]:e.allowMidSprintAdd==="po-only"&&!l(d,t.by,"order-backlog")?[I("scope-protects-goal","error",`"${t.by}" may not add work mid-sprint`,"ask the Product Owner (order-backlog) to commit it")]:s.goalImpact!=="none"?[I("scope-protects-goal","error",`adding work with goalImpact "${s.goalImpact??"unset"}" endangers the Sprint Goal`,'only commit items with goalImpact: "none"; otherwise cancel and re-plan')]:[]}},{id:"po-orders-backlog",severity:"error",check:(d,t)=>t.type!=="ceremony.refine"||l(d,t.by,"order-backlog")?[]:((t.payload??{}).items??[]).filter(s=>s.patch.priority!==void 0).map(s=>I("po-orders-backlog","error",`"${t.by}" may not change the priority of "${s.id}"`,"only the Product Owner orders the backlog; drop priority from the patch",s.id))},{id:"dod-not-weakened",severity:"error",check:(d,t)=>{if(t.type!=="ceremony.retro")return [];let e=t.payload??{};if(e.dodChanges===void 0)return [];if(N$1(d))return [I("dod-not-weakened","error","Definition of Done cannot change while a sprint is open","close the sprint first; DoD changes apply to the next sprint")];if(!Array.isArray(e.dodChanges)||e.allowWeaken===true)return [];let s=e.dodChanges,m=new Set(s.map(H)),c=W(d).definitionOfDone.filter(u=>!m.has(H(u)));if(c.length===0)return [];let l=c.map(u=>H(u).replace(":"," "));return [I("dod-not-weakened","error",`retro dodChanges drops ${c.length} Definition of Done policy(ies): ${l.join(", ")}`,'keep them in dodChanges (it replaces the whole list; suggestedChange { kind: "dod" } appends one), or pass allowWeaken: true to weaken the Definition of Done knowingly')]}},{id:"carryover-reestimated",severity:"error",check:(d,t)=>{if(t.type!=="ceremony.plan")return [];let e=t.payload?.items;if(!Array.isArray(e))return [];let s=me(d);if(!s)return [];let m=F(d,s.id);return e.filter(c=>s.carryover.includes(c)&&!(d.items[c]&&j(d.items[c],d)!==void 0)&&!d.events.some(l=>l.seq>m&&l.payload.id===c&&(l.type==="item.edited"&&l.payload.changed.includes("weight")||l.type==="item.reestimated"))).map(c=>I("carryover-reestimated","error",`carried-over item "${c}" was not re-estimated after ${s.id}`,"refine it with a new weight before committing",c))}}]}function pe(o){let n={id:"in_progress",name:"In progress",entryPolicy:[{kind:"dependencies-done"}],exitPolicy:[]};return o.inProgressWipLimit!==void 0&&(n.wipLimit=o.inProgressWipLimit),[{id:"backlog",name:"Product Backlog",entryPolicy:[],exitPolicy:[{kind:"acceptance-written"},{kind:"estimate-present"}]},{id:"sprint",name:"Sprint Backlog",entryPolicy:[],exitPolicy:[]},n,{id:"review",name:"Review",entryPolicy:[],exitPolicy:o.definitionOfDone,review:true},{id:"done",name:"Increment",entryPolicy:[],exitPolicy:[]}]}var Se=Object.freeze({backlog:"Product Backlog",item:"Product Backlog Item",stage:"Column",iteration:"Sprint",increment:"Increment",ceremony:"Scrum Event",gate:"Sprint Review"});function W(o){return o.config}function j(o,n){let i=o.transitions.at(-1);return !i||i.by!=="system"||i.to.stage!=="backlog"||i.to.status!=="todo"?void 0:n?n.stages.find(g=>g.id===i.from.stage)?.review||i.from.status==="review"?i.from.stage:void 0:i.from.status==="review"?i.from.stage:void 0}function Pe(o,n,i){let r$1=o,g=r(r$1,n).blockers.filter(f=>!f.clearedAt);if(g.length){r$1=q(r$1,n,f=>({...f,blockers:f.blockers.map(y=>y.clearedAt?y:{...y,clearedAt:i})}));for(let f of g)r$1=c(r$1,"blocker.cleared","system",{id:n,blocker:f.id,reason:"sprint closed"},i);}for(let f of r$1.pending.filter(y=>y.item===n))r$1={...r$1,pending:r$1.pending.filter(y=>y.id!==f.id)},r$1=c(r$1,"pending.dropped","system",{id:f.id,item:n,reason:"sprint closed"},i);let p=r(r$1,n);return (p.stage!=="backlog"||p.status!=="todo")&&(r$1=u(r$1,n,{stage:"backlog",status:"todo"},"system",i)),x(r$1,n,p.type==="question"?["iteration"]:["iteration","role"])}function E(o,n,i){let r$1=N$1(o);if(!r$1)return o;let g=r$1.committed.map(e=>r(o,e)),p=g.filter(e=>e.status==="done").map(e=>e.id),f=g.filter(e=>e.status==="dropped").map(e=>e.id),y=g.filter(e=>e.status!=="done"&&e.status!=="dropped").map(e=>e.id),k=Object.values(o.items).filter(e=>e.type==="question"&&e.parent!==void 0&&y.includes(e.parent)&&e.status!=="done"&&e.status!=="dropped").map(e=>e.id),d=o;for(let e of [...y,...k])d=Pe(d,e,i);let t=e=>e.reduce((s,m)=>s+(o.items[m]?.weight??0),0);return d={...d,iterations:d.iterations.map(e=>{if(e.id!==r$1.id)return e;let{closing:s,...m}=e;return {...m,endedAt:i,outcome:n==="cancel"?"cancelled":"completed",carryover:y}})},c(d,"sprint.closed","system",{id:r$1.id,reason:n,done:p,carryover:y,carriedQuestions:k,dropped:f,doneWeight:t(p),committedWeight:t(r$1.committed),spent:r$1.spent,budget:r$1.budget},i)}function We(){return {name:"scrum",vocabulary:Se,validateConfig:ce,defaultStages:pe,defaultRoles:le,requiredCapabilities:["order-backlog","facilitate","deliver"],exclusiveCapabilities:["order-backlog"],plannerOptions(o){let n=W(o),i={schedulerMode:"level",dispatchStage:"in_progress"};return n.inProgressWipLimit!==void 0&&(i.concurrencyCap=n.inProgressWipLimit),n.estimateMode!==void 0&&(i.estimateMode=n.estimateMode),n.fallbackTokensPerWeight!==void 0&&(i.fallbackTokensPerWeight=n.fallbackTokensPerWeight),i},candidates(o){let n=N$1(o);return !n||n.closing?[]:Object.values(o.items).filter(i=>i.iteration===n.id&&(i.status==="todo"||i.status==="review")&&(i.stage==="sprint"||i.stage==="review"))},invariants(o,n){let i=N$1(o),r=W(o),g=i?K$1(i.budget,i.spent):{};return [`Sprint Goal: ${i?.goal??"(no open sprint)"}; Product Goal: ${r.productGoal}`,`Budget remaining: ${JSON.stringify(g)}; stop and hand off when it is gone`,`Definition of Done: ${r.definitionOfDone.map(p=>p.kind==="evidence"?`evidence ${p.evidenceKind}`:p.kind).join(", ")||"(none)"}`,`Do not change the scope of "${n.id}" or its acceptance criteria; raise open_questions instead`]},ceremonies:K(We),rules:ue(),metrics:o=>({...de(o)}),report(o){let n=N$1(o);return {closing:n?.closing===true,sprint:n?.id??null,reason:n?.closing?"budget":null,inFlight:n?Object.values(o.items).filter(i=>(i.iteration===n.id||n.committed.includes(i.id))&&i.status==="in_progress").map(i=>i.id):[]}},humanDefaults:{gates:["sprint-review"]},afterConfigChange(o){return N(o,W(o).definitionOfDone)},afterComplete(o,n,i){let r=N$1(o);return !r||!r.closing&&!L(r.budget,r.spent)?o:!Object.values(o.items).some(p=>(p.iteration===r.id||r.committed.includes(p.id))&&p.status==="in_progress")&&W(o).autoClose!==false?E(o,"budget",i):r.closing?o:c({...o,iterations:o.iterations.map(p=>p.id===r.id?{...p,closing:true}:p)},"sprint.closing","system",{id:r.id},i)}}}export{ae as a,K as b,ce as c,de as d,le as e,ue as f,pe as g,Se as h,W as i,j,E as k,We as l};//# sourceMappingURL=chunk-32NVJV5C.mjs.map
2
- //# sourceMappingURL=chunk-32NVJV5C.mjs.map
@@ -1,2 +0,0 @@
1
- 'use strict';var chunkU3RU5LOF_cjs=require('./chunk-U3RU5LOF.cjs'),chunkRXY434DX_cjs=require('./chunk-RXY434DX.cjs'),chunkLCN4UNYK_cjs=require('./chunk-LCN4UNYK.cjs'),chunkZ43GUETW_cjs=require('./chunk-Z43GUETW.cjs'),chunk43GLYYA2_cjs=require('./chunk-43GLYYA2.cjs'),chunkOSHBJIYD_cjs=require('./chunk-OSHBJIYD.cjs'),promises=require('fs/promises'),y=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var y__default=/*#__PURE__*/_interopDefault(y);var tt=r=>r!==void 0&&chunkU3RU5LOF_cjs.c().includes(r)?chunkU3RU5LOF_cjs.b(r):void 0,h=["exwf init <scrum|kanban|waterfall|investigation|experimentation> --config <file> [--roles <file>]","exwf add <item.json> [--by who] exwf edit <id> <patch.json> [--by who]","exwf next [--max n] [--fallback-tokens-per-weight n]","exwf complete <id> <handoff.json> --tokens-in n --tokens-out n --duration-ms n --model m [--estimate] [--role r]","exwf account <item> [--line n] [--tokens-in n] [--tokens-out n] [--duration-ms n] [--model m] [--by who]","exwf ceremony <name> [input.json] [--by who]","exwf decide <pendingId> approve|reject [--by who] [--note text]","exwf config set <patch.json> [--by who] exwf unblock <item> [--blocker id] [--note text] [--by who]","exwf status | board | metrics | pending | lessons","exwf validate <action.json> exwf role add <manifest.json> | role list"],st=new Set(["estimate"]);function et(r){let t=[],u={};for(let a=0;a<r.length;a++){let S=r[a];if(S.startsWith("--")){let n=S.slice(2);if(st.has(n)){u[n]="true";continue}let f=r[a+1];(f===void 0||f.startsWith("--"))&&chunkOSHBJIYD_cjs.b("invalid-input",`--${n} needs a value`,`pass --${n} <text>`),u[n]=f,a++;}else t.push(S);}return {positional:t,flags:u}}async function x(r){try{return JSON.parse(await promises.readFile(r,"utf8"))}catch(t){return chunkOSHBJIYD_cjs.b("invalid-input",`cannot read JSON from ${r}: ${t.message}`,"check the path and that the file is valid JSON")}}function w(r){let t=tt(r.methodology);return t||chunkOSHBJIYD_cjs.b("config-invalid",`methodology "${r.methodology}" is not available in this build`,`available: ${chunkU3RU5LOF_cjs.c().join(", ")}`),t()}function b(r,t){let u=Number(r[t]);return Number.isFinite(u)||chunkOSHBJIYD_cjs.b("invalid-input",`--${t} must be a number (got ${JSON.stringify(r[t])})`,`pass --${t} <n>`),u}var at=new Set(["init","add","edit","next","complete","account","ceremony","decide","unblock"]);async function St(r,t){try{let[u,a]=et(r).positional;return u!==void 0&&(at.has(u)||u==="role"&&a==="add"||u==="config"&&a==="set")?await chunkRXY434DX_cjs.c(t,()=>Z(r,t)):await Z(r,t)}catch(u){if(u instanceof chunkOSHBJIYD_cjs.a)return {exit:1,out:{ok:false,error:u.toJSON()}};throw u}}async function Z(r,t){let{positional:u,flags:a}=et(r),[S,...n]=u,f=a.by??"human",d=new Date().toISOString();switch(S){case "init":{let[o]=n,e=tt(o);if(!e||!a.config)return {exit:2,out:{ok:false,usage:h}};try{await promises.stat(chunkRXY434DX_cjs.b(t)),chunkOSHBJIYD_cjs.b("invalid-input",`${chunkRXY434DX_cjs.b(t)} already exists`,"delete .workflow/state.json to start over");}catch(c){if(c instanceof chunkOSHBJIYD_cjs.a||c.code!=="ENOENT")throw c}let i=await x(y__default.default.resolve(t,a.config)),s=a.roles?await x(y__default.default.resolve(t,a.roles)):void 0;if(s!==void 0){Array.isArray(s)||chunkOSHBJIYD_cjs.b("invalid-input",`roles file ${a.roles} must contain an array of role manifests`,"wrap the manifests in [ ... ]");for(let c of s)chunk43GLYYA2_cjs.b(chunk43GLYYA2_cjs.e,c,`roles file ${a.roles}`);}let l=chunkZ43GUETW_cjs.V(s?{methodology:e(),config:i,roles:s,by:f,now:d}:{methodology:e(),config:i,by:f,now:d});return await chunkRXY434DX_cjs.d(t,l.state),{exit:0,out:{ok:true,warnings:l.warnings,state:{methodology:l.state.methodology,stages:l.state.stages.map(c=>c.id),roles:Object.keys(l.state.roles)}}}}case "add":{if(!n[0])return {exit:2,out:{ok:false,usage:h}};let o=await chunkRXY434DX_cjs.e(t),e=await x(y__default.default.resolve(t,n[0]));chunk43GLYYA2_cjs.b(chunk43GLYYA2_cjs.f,e,`item file ${n[0]}`);let i=chunkZ43GUETW_cjs.U(o,w(o),{type:"item.add",by:f,payload:{item:e}},s=>chunkZ43GUETW_cjs.s(s,e,f,d));return await chunkRXY434DX_cjs.d(t,i.state),{exit:0,out:{ok:true,warnings:i.warnings,item:chunkZ43GUETW_cjs.r(i.state,e.id)}}}case "edit":{if(!n[0]||!n[1])return {exit:2,out:{ok:false,usage:h}};let o=await chunkRXY434DX_cjs.e(t),e=n[0],i=await x(y__default.default.resolve(t,n[1]));chunk43GLYYA2_cjs.b(chunk43GLYYA2_cjs.g,i,`patch file ${n[1]}`);let s=chunkZ43GUETW_cjs.U(o,w(o),{type:"item.edit",by:f,payload:{id:e,patch:i}},l=>chunkZ43GUETW_cjs.t(l,e,i,f,d));return await chunkRXY434DX_cjs.d(t,s.state),{exit:0,out:{ok:true,warnings:s.warnings,item:chunkZ43GUETW_cjs.r(s.state,e)}}}case "next":{let o=await chunkRXY434DX_cjs.e(t),e={now:d};a.max&&(e.max=b(a,"max")),a["fallback-tokens-per-weight"]&&(e.fallbackTokensPerWeight=b(a,"fallback-tokens-per-weight"));let i=chunkLCN4UNYK_cjs.e(o,w(o),e);await chunkRXY434DX_cjs.f(t,i.briefs.map(s=>s.item.id));for(let s of i.briefs)await chunkRXY434DX_cjs.g(t,s);return await chunkRXY434DX_cjs.d(t,i.state),{exit:0,out:{ok:true,reason:i.reason??null,skipped:i.skipped,briefs:i.briefs}}}case "complete":{if(!n[0]||!n[1])return {exit:2,out:{ok:false,usage:h}};let o=await chunkRXY434DX_cjs.e(t),e=await x(y__default.default.resolve(t,n[1]));chunk43GLYYA2_cjs.b(chunk43GLYYA2_cjs.h,e,`handoff file ${n[1]}`),e.item!==n[0]&&chunkOSHBJIYD_cjs.b("handoff-invalid",`handoff.item "${e.item}" differs from the command's item "${n[0]}"`,"make them match");let i=a.role??e.role,s=b(a,"duration-ms"),l=Date.parse(d)-s;(!Number.isFinite(s)||Number.isNaN(new Date(l).getTime()))&&chunkOSHBJIYD_cjs.b("invalid-input",`--duration-ms must be a number of milliseconds that dates the start (got ${a["duration-ms"]})`,"pass the measured wall-clock time in ms, e.g. --duration-ms 42000");let c={item:n[0],role:i,model:a.model??"",tokensIn:b(a,"tokens-in"),tokensOut:b(a,"tokens-out"),durationMs:s,startedAt:new Date(l).toISOString(),endedAt:d};a.estimate==="true"&&(c.estimate=true);let k=chunkLCN4UNYK_cjs.f(o,w(o),{...e,role:i},c,d);return await chunkRXY434DX_cjs.h(t,e,k.state.events.length),await chunkRXY434DX_cjs.d(t,k.state),{exit:0,out:{ok:true,warnings:k.warnings,item:chunkZ43GUETW_cjs.r(k.state,n[0])}}}case "account":{if(!n[0])return {exit:2,out:{ok:false,usage:h}};let o=await chunkRXY434DX_cjs.e(t),e={};a["tokens-in"]!==void 0&&(e.tokensIn=b(a,"tokens-in")),a["tokens-out"]!==void 0&&(e.tokensOut=b(a,"tokens-out")),a["duration-ms"]!==void 0&&(e.durationMs=b(a,"duration-ms")),a.model!==void 0&&(e.model=a.model);let i=a.line!==void 0?b(a,"line"):void 0,s=chunkLCN4UNYK_cjs.g(o,n[0],e,a.by??"human",d,i);await chunkRXY434DX_cjs.d(t,s);let l=chunkZ43GUETW_cjs.d(s),c=l.payload.line;return {exit:0,out:{ok:true,line:s.accounting.filter(A=>A.item===n[0])[c-1],event:l}}}case "ceremony":{if(!n[0])return {exit:2,out:{ok:false,usage:h}};let o=await chunkRXY434DX_cjs.e(t),e=w(o),i=Object.hasOwn(e.ceremonies,n[0])?e.ceremonies[n[0]]:void 0;i||chunkOSHBJIYD_cjs.b("unknown-ceremony",`"${n[0]}" is not a ${e.name} ceremony`,`available: ${Object.keys(e.ceremonies).join(", ")}`);let s=n[1]?await x(y__default.default.resolve(t,n[1])):{},l=i(o,{...s,by:f,now:d});return await chunkRXY434DX_cjs.d(t,l.state),{exit:0,out:{ok:true,warnings:l.warnings,lastEvent:chunkZ43GUETW_cjs.d(l.state)}}}case "config":{if(n[0]!=="set"||!n[1])return {exit:2,out:{ok:false,usage:h}};let o=await chunkRXY434DX_cjs.e(t),e=await x(y__default.default.resolve(t,n[1])),i=chunkZ43GUETW_cjs.W(o,w(o),e,f,d);return await chunkRXY434DX_cjs.d(t,i.state),{exit:0,out:{ok:true,warnings:i.warnings,changed:chunkZ43GUETW_cjs.d(i.state).payload.changed,config:i.state.config}}}case "unblock":{if(!n[0])return {exit:2,out:{ok:false,usage:h}};let o=n[0],e=await chunkRXY434DX_cjs.e(t),i=chunkZ43GUETW_cjs.r(e,o).blockers.filter(k=>!k.clearedAt).map(k=>k.id);i.length===0&&chunkOSHBJIYD_cjs.b("invalid-input",`item ${o} has no open blocker`,"nothing to clear; check exwf board");let s=a.blocker!==void 0?[a.blocker]:i,l=a.note,c=chunkZ43GUETW_cjs.U(e,w(e),{type:"blocker.clear",by:f,payload:{id:o,blockers:s,note:l??null}},k=>s.reduce((A,ot)=>chunkZ43GUETW_cjs.A(A,o,ot,f,d,l),k));return await chunkRXY434DX_cjs.d(t,c.state),{exit:0,out:{ok:true,warnings:c.warnings,item:chunkZ43GUETW_cjs.r(c.state,o)}}}case "decide":{if(!n[0]||n[1]!=="approve"&&n[1]!=="reject")return {exit:2,out:{ok:false,usage:h}};let o=await chunkRXY434DX_cjs.e(t),e=o.pending.find(s=>s.id===n[0]),i=chunkZ43GUETW_cjs.H(o,n[0],n[1],f,a.note??"",d,w(o));return await chunkRXY434DX_cjs.d(t,i),{exit:0,out:{ok:true,item:e?.item?chunkZ43GUETW_cjs.r(i,e.item):null}}}case "status":{let o=await chunkRXY434DX_cjs.e(t),e=w(o),i={todo:0,in_progress:0,blocked:0,review:0,awaiting_human:0,done:0,dropped:0};for(let s of Object.values(o.items))i[s.status]+=1;return {exit:0,out:{ok:true,methodology:o.methodology,openIteration:chunkZ43GUETW_cjs.N(o)??null,counts:i,pending:o.pending,openQuestions:chunkLCN4UNYK_cjs.d(o),lastEvent:chunkZ43GUETW_cjs.d(o),report:e.report?e.report(o):null}}}case "board":{let o=await chunkRXY434DX_cjs.e(t);return {exit:0,out:{ok:true,columns:o.stages.map(i=>({stage:i.id,wipLimit:i.wipLimit??null,items:Object.values(o.items).filter(s=>s.stage===i.id&&s.status!=="dropped").map(s=>({id:s.id,title:s.title,status:s.status,role:s.role??null,age:s.transitions.length?Date.parse(d)-Date.parse(s.transitions[s.transitions.length-1].at):null}))}))}}}case "metrics":{let o=await chunkRXY434DX_cjs.e(t);return {exit:0,out:{ok:true,metrics:w(o).metrics(o)}}}case "pending":return {exit:0,out:{ok:true,pending:(await chunkRXY434DX_cjs.e(t)).pending}};case "lessons":return {exit:0,out:{ok:true,lessons:(await chunkRXY434DX_cjs.e(t)).lessons}};case "validate":{if(!n[0])return {exit:2,out:{ok:false,usage:h}};let o=await chunkRXY434DX_cjs.e(t),e=await x(y__default.default.resolve(t,n[0]));return (typeof e!="object"||e===null||Array.isArray(e)||typeof e.type!="string")&&chunkOSHBJIYD_cjs.b("invalid-input",`action file ${n[0]} must hold an object with a string "type"`,'write the action as { "type": "...", "by": "<role>", "payload": { ... } }'),{exit:0,out:{ok:true,violations:chunkZ43GUETW_cjs.T(o,w(o),e)}}}case "role":{let o=await chunkRXY434DX_cjs.e(t);if(n[0]==="list")return {exit:0,out:{ok:true,roles:Object.keys(o.roles),detail:o.roles}};if(n[0]==="add"&&n[1]){let e=await x(y__default.default.resolve(t,n[1]));chunk43GLYYA2_cjs.b(chunk43GLYYA2_cjs.e,e,`role manifest ${n[1]}`);let i=chunkLCN4UNYK_cjs.a(o,e,f,d);return await chunkRXY434DX_cjs.d(t,i),{exit:0,out:{ok:true,roles:Object.keys(i.roles)}}}return {exit:2,out:{ok:false,usage:h}}}default:return {exit:2,out:{ok:false,usage:h}}}}exports.a=h;exports.b=et;exports.c=St;//# sourceMappingURL=chunk-3O5MPAJT.cjs.map
2
- //# sourceMappingURL=chunk-3O5MPAJT.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cli/commands.ts"],"names":["factoryOf","name","registeredMethodologies","methodologyFactory","USAGE","BOOLEAN_FLAGS","parseArgs","argv","positional","flags","i","a","key","val","fail","readJson","file","readFile","e","methodologyOf","state","f","num","v","WRITERS","runCommand","cwd","cmd","sub","withStateLock","execute","WorkflowError","rest","by","now","stat","statePath","config","path","roles","r","assertValid","roleSchema","res","init","saveState","s","loadState","item","newItemSchema","applyAction","addItem","getItem","id","patch","itemPatchSchema","editItem","opts","next","checkBriefNames","b","saveBrief","handoff","handoffSchema","role","durationMs","startedAt","acc","complete","saveHandoff","line","s2","correctAccounting","ev","lastEvent","idx","m","c","input","changeConfig","open","blockers","note","clearBlocker","entry","p","decide","counts","openIteration","openQuestions","st","action","validateAction","manifest","registerRole"],"mappings":"+dA2CA,IAAMA,EAAAA,CAAaC,CAAAA,EACjBA,CAAAA,GAAS,MAAA,EAAaC,mBAAAA,EAAwB,CAAE,QAAA,CAASD,CAAI,CAAA,CACxDE,mBAAAA,CAAmBF,CAAI,CAAA,CACxB,MAAA,CAEOG,CAAAA,CAAQ,CACnB,mGAAA,CACA,6EAAA,CACA,sDAAA,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BAAAA,CAAYC,mBAAAA,CAAYmD,CAAAA,CAAU,iBAAiB7D,CAAAA,CAAK,CAAC,CAAC,CAAA,CAAE,CAAA,CAC5D,IAAMuC,CAAAA,CAAKuB,mBAAAA,CAAa1E,CAAAA,CAAOyE,CAAAA,CAAU5D,CAAAA,CAAIC,CAAG,CAAA,CAChD,OAAA,MAAMW,mBAAAA,CAAUnB,CAAAA,CAAK6C,CAAE,CAAA,CAChB,CAAE,IAAA,CAAM,CAAA,CAAG,GAAA,CAAK,CAAE,EAAA,CAAI,IAAA,CAAM,KAAA,CAAO,MAAA,CAAO,IAAA,CAAKA,CAAAA,CAAG,KAAK,CAAE,CAAE,CACpE,CACA,OAAO,CAAE,IAAA,CAAM,CAAA,CAAG,GAAA,CAAK,CAAE,EAAA,CAAI,KAAA,CAAO,KAAA,CAAOnE,CAAM,CAAE,CACrD,CACA,QACE,OAAO,CAAE,IAAA,CAAM,CAAA,CAAG,GAAA,CAAK,CAAE,EAAA,CAAI,KAAA,CAAO,KAAA,CAAOA,CAAM,CAAE,CACvD,CACF","file":"chunk-3O5MPAJT.cjs","sourcesContent":["import { readFile, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n checkBriefNames,\n loadState,\n saveBrief,\n saveHandoff,\n saveState,\n statePath,\n withStateLock,\n} from \"../adapters/file.ts\";\nimport { next as planNext, openQuestions } from \"../core/brief.ts\";\nimport { complete } from \"../core/complete.ts\";\nimport { correctAccounting, type AccountingPatch } from \"../core/accounting.ts\";\nimport { WorkflowError, fail } from \"../core/errors.ts\";\nimport { decide } from \"../core/gates.ts\";\nimport { addItem, editItem, getItem } from \"../core/items/record.ts\";\nimport { clearBlocker } from \"../core/items/blockers.ts\";\nimport type { ItemPatch } from \"../core/types.ts\";\nimport { applyAction, changeConfig, init, validateAction } from \"../core/methodology.ts\";\nimport { openIteration, type PlanOptions } from \"../core/planner.ts\";\nimport { registerRole } from \"../core/roles/registry.ts\";\nimport {\n assertValid,\n handoffSchema,\n itemPatchSchema,\n newItemSchema,\n roleSchema,\n} from \"../schema/index.ts\";\nimport { lastEvent } from \"../core/state.ts\";\nimport { methodologyFactory, registeredMethodologies } from \"../registry.ts\";\nimport type {\n Accounting,\n Action,\n Handoff,\n ItemStatus,\n Methodology,\n NewItem,\n Role,\n WorkflowState,\n} from \"../core/types.ts\";\n\n/** The factory `name` resolves to in the methodology registry (built-ins pre-registered), if any. */\nconst factoryOf = (name: string | undefined): (() => Methodology) | undefined =>\n name !== undefined && registeredMethodologies().includes(name)\n ? (methodologyFactory(name) as () => Methodology)\n : undefined;\n\nexport const USAGE = [\n \"exwf init <scrum|kanban|waterfall|investigation|experimentation> --config <file> [--roles <file>]\",\n \"exwf add <item.json> [--by who] exwf edit <id> <patch.json> [--by who]\",\n \"exwf next [--max n] [--fallback-tokens-per-weight n]\",\n \"exwf complete <id> <handoff.json> --tokens-in n --tokens-out n --duration-ms n --model m [--estimate] [--role r]\",\n \"exwf account <item> [--line n] [--tokens-in n] [--tokens-out n] [--duration-ms n] [--model m] [--by who]\",\n \"exwf ceremony <name> [input.json] [--by who]\",\n \"exwf decide <pendingId> approve|reject [--by who] [--note text]\",\n \"exwf config set <patch.json> [--by who] exwf unblock <item> [--blocker id] [--note text] [--by who]\",\n \"exwf status | board | metrics | pending | lessons\",\n \"exwf validate <action.json> exwf role add <manifest.json> | role list\",\n];\n\nexport interface Parsed {\n positional: string[];\n flags: Record<string, string>;\n}\n/** Flags that take no value; every other flag needs one. */\nconst BOOLEAN_FLAGS = new Set([\"estimate\"]);\n\nexport function parseArgs(argv: string[]): Parsed {\n const positional: string[] = [];\n const flags: Record<string, string> = {};\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i]!;\n if (a.startsWith(\"--\")) {\n const key = a.slice(2);\n if (BOOLEAN_FLAGS.has(key)) {\n flags[key] = \"true\";\n continue;\n }\n const val = argv[i + 1];\n if (val === undefined || val.startsWith(\"--\"))\n fail(\"invalid-input\", `--${key} needs a value`, `pass --${key} <text>`);\n flags[key] = val;\n i++;\n } else positional.push(a);\n }\n return { positional, flags };\n}\n\nasync function readJson<T>(file: string): Promise<T> {\n try {\n return JSON.parse(await readFile(file, \"utf8\")) as T;\n } catch (e) {\n return fail(\n \"invalid-input\",\n `cannot read JSON from ${file}: ${(e as Error).message}`,\n \"check the path and that the file is valid JSON\",\n );\n }\n}\n\nfunction methodologyOf(state: WorkflowState): Methodology {\n const f = factoryOf(state.methodology);\n if (!f)\n fail(\n \"config-invalid\",\n `methodology \"${state.methodology}\" is not available in this build`,\n `available: ${registeredMethodologies().join(\", \")}`,\n );\n return f();\n}\n\nfunction num(flags: Record<string, string>, key: string): number {\n const v = Number(flags[key]);\n if (!Number.isFinite(v))\n fail(\n \"invalid-input\",\n `--${key} must be a number (got ${JSON.stringify(flags[key])})`,\n `pass --${key} <n>`,\n );\n return v;\n}\n\nexport interface CommandResult {\n exit: 0 | 1 | 2;\n out: unknown;\n}\n\n/** Commands that load, change and save the state: they run under .workflow/state.lock. */\nconst WRITERS = new Set([\n \"init\",\n \"add\",\n \"edit\",\n \"next\",\n \"complete\",\n \"account\",\n \"ceremony\",\n \"decide\",\n \"unblock\",\n]);\n\nexport async function runCommand(argv: string[], cwd: string): Promise<CommandResult> {\n try {\n const [cmd, sub] = parseArgs(argv).positional;\n const writes =\n cmd !== undefined &&\n (WRITERS.has(cmd) ||\n (cmd === \"role\" && sub === \"add\") ||\n (cmd === \"config\" && sub === \"set\"));\n return writes ? await withStateLock(cwd, () => execute(argv, cwd)) : await execute(argv, cwd);\n } catch (e) {\n if (e instanceof WorkflowError) return { exit: 1, out: { ok: false, error: e.toJSON() } };\n throw e;\n }\n}\n\nasync function execute(argv: string[], cwd: string): Promise<CommandResult> {\n const { positional, flags } = parseArgs(argv);\n const [cmd, ...rest] = positional;\n const by = flags[\"by\"] ?? \"human\";\n const now = new Date().toISOString();\n switch (cmd) {\n case \"init\": {\n const [name] = rest;\n const f = factoryOf(name);\n if (!f || !flags[\"config\"]) return { exit: 2, out: { ok: false, usage: USAGE } };\n try {\n await stat(statePath(cwd));\n fail(\n \"invalid-input\",\n `${statePath(cwd)} already exists`,\n \"delete .workflow/state.json to start over\",\n );\n } catch (e) {\n if (e instanceof WorkflowError) throw e;\n if ((e as NodeJS.ErrnoException).code !== \"ENOENT\") throw e;\n }\n const config = await readJson<unknown>(path.resolve(cwd, flags[\"config\"]));\n const roles = flags[\"roles\"]\n ? await readJson<Role[]>(path.resolve(cwd, flags[\"roles\"]))\n : undefined;\n if (roles !== undefined) {\n if (!Array.isArray(roles))\n fail(\n \"invalid-input\",\n `roles file ${flags[\"roles\"]} must contain an array of role manifests`,\n \"wrap the manifests in [ ... ]\",\n );\n for (const r of roles) assertValid(roleSchema, r, `roles file ${flags[\"roles\"]}`);\n }\n const res = init(\n roles\n ? { methodology: f(), config, roles, by, now }\n : { methodology: f(), config, by, now },\n );\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n warnings: res.warnings,\n state: {\n methodology: res.state.methodology,\n stages: res.state.stages.map((s) => s.id),\n roles: Object.keys(res.state.roles),\n },\n },\n };\n }\n case \"add\": {\n if (!rest[0]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const item = await readJson<NewItem>(path.resolve(cwd, rest[0]));\n assertValid(newItemSchema, item, `item file ${rest[0]}`);\n const res = applyAction(\n state,\n methodologyOf(state),\n { type: \"item.add\", by, payload: { item } },\n (s) => addItem(s, item, by, now),\n );\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n warnings: res.warnings,\n item: getItem(res.state, item.id),\n },\n };\n }\n case \"edit\": {\n if (!rest[0] || !rest[1]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const id = rest[0];\n const patch = await readJson<ItemPatch>(path.resolve(cwd, rest[1]));\n assertValid(itemPatchSchema, patch, `patch file ${rest[1]}`);\n const res = applyAction(\n state,\n methodologyOf(state),\n { type: \"item.edit\", by, payload: { id, patch } },\n (s) => editItem(s, id, patch, by, now),\n );\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: { ok: true, warnings: res.warnings, item: getItem(res.state, id) },\n };\n }\n case \"next\": {\n const state = await loadState(cwd);\n const opts: PlanOptions = { now };\n if (flags[\"max\"]) opts.max = num(flags, \"max\");\n if (flags[\"fallback-tokens-per-weight\"])\n opts.fallbackTokensPerWeight = num(flags, \"fallback-tokens-per-weight\");\n const res = planNext(state, methodologyOf(state), opts);\n // every brief name is checked first, so a refusal writes none of the batch\n await checkBriefNames(\n cwd,\n res.briefs.map((b) => b.item.id),\n );\n // briefs first: a crash then leaves an orphan brief (overwritten next dispatch), never a dispatched item without one\n for (const b of res.briefs) await saveBrief(cwd, b);\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n reason: res.reason ?? null,\n skipped: res.skipped,\n briefs: res.briefs,\n },\n };\n }\n case \"complete\": {\n if (!rest[0] || !rest[1]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const handoff = await readJson<Handoff>(path.resolve(cwd, rest[1]));\n assertValid(handoffSchema, handoff, `handoff file ${rest[1]}`);\n if (handoff.item !== rest[0])\n fail(\n \"handoff-invalid\",\n `handoff.item \"${handoff.item}\" differs from the command's item \"${rest[0]}\"`,\n \"make them match\",\n );\n const role = flags[\"role\"] ?? handoff.role;\n const durationMs = num(flags, \"duration-ms\");\n const startedAt = Date.parse(now) - durationMs;\n // a negative duration stays accounting-invalid (complete) and a fraction is accepted, as in\n // 1.1; only refuse what Date cannot hold\n if (!Number.isFinite(durationMs) || Number.isNaN(new Date(startedAt).getTime()))\n fail(\n \"invalid-input\",\n `--duration-ms must be a number of milliseconds that dates the start (got ${flags[\"duration-ms\"]})`,\n \"pass the measured wall-clock time in ms, e.g. --duration-ms 42000\",\n );\n const acc: Accounting = {\n item: rest[0],\n role,\n model: flags[\"model\"] ?? \"\",\n tokensIn: num(flags, \"tokens-in\"),\n tokensOut: num(flags, \"tokens-out\"),\n durationMs,\n startedAt: new Date(startedAt).toISOString(),\n endedAt: now,\n };\n if (flags[\"estimate\"] === \"true\") acc.estimate = true;\n const res = complete(state, methodologyOf(state), { ...handoff, role }, acc, now);\n // handoff first: a retry of the same command reproduces the same seq and overwrites an orphan\n await saveHandoff(cwd, handoff, res.state.events.length);\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n warnings: res.warnings,\n item: getItem(res.state, rest[0]),\n },\n };\n }\n case \"account\": {\n if (!rest[0]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const patch: AccountingPatch = {};\n if (flags[\"tokens-in\"] !== undefined) patch.tokensIn = num(flags, \"tokens-in\");\n if (flags[\"tokens-out\"] !== undefined) patch.tokensOut = num(flags, \"tokens-out\");\n if (flags[\"duration-ms\"] !== undefined) patch.durationMs = num(flags, \"duration-ms\");\n if (flags[\"model\"] !== undefined) patch.model = flags[\"model\"];\n const line = flags[\"line\"] !== undefined ? num(flags, \"line\") : undefined;\n const s2 = correctAccounting(state, rest[0], patch, flags[\"by\"] ?? \"human\", now, line);\n await saveState(cwd, s2);\n const ev = lastEvent(s2)!;\n const idx = (ev.payload as { line: number }).line;\n const mine = s2.accounting.filter((a) => a.item === rest[0]);\n return { exit: 0, out: { ok: true, line: mine[idx - 1], event: ev } };\n }\n case \"ceremony\": {\n if (!rest[0]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const m = methodologyOf(state);\n const c = Object.hasOwn(m.ceremonies, rest[0]) ? m.ceremonies[rest[0]] : undefined;\n if (!c)\n fail(\n \"unknown-ceremony\",\n `\"${rest[0]}\" is not a ${m.name} ceremony`,\n `available: ${Object.keys(m.ceremonies).join(\", \")}`,\n );\n const input = rest[1]\n ? await readJson<Record<string, unknown>>(path.resolve(cwd, rest[1]))\n : {};\n const res = c(state, { ...input, by, now });\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n warnings: res.warnings,\n lastEvent: lastEvent(res.state),\n },\n };\n }\n case \"config\": {\n if (rest[0] !== \"set\" || !rest[1]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const patch = await readJson<Record<string, unknown>>(path.resolve(cwd, rest[1]));\n const res = changeConfig(state, methodologyOf(state), patch, by, now);\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n warnings: res.warnings,\n changed: (lastEvent(res.state)!.payload as { changed: string[] }).changed,\n config: res.state.config,\n },\n };\n }\n case \"unblock\": {\n if (!rest[0]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const id = rest[0];\n const state = await loadState(cwd);\n const open = getItem(state, id)\n .blockers.filter((b) => !b.clearedAt)\n .map((b) => b.id);\n if (open.length === 0)\n fail(\n \"invalid-input\",\n `item ${id} has no open blocker`,\n \"nothing to clear; check exwf board\",\n );\n const blockers = flags[\"blocker\"] !== undefined ? [flags[\"blocker\"]] : open;\n const note = flags[\"note\"];\n const res = applyAction(\n state,\n methodologyOf(state),\n { type: \"blocker.clear\", by, payload: { id, blockers, note: note ?? null } },\n (s) => blockers.reduce((acc, b) => clearBlocker(acc, id, b, by, now, note), s),\n );\n await saveState(cwd, res.state);\n return { exit: 0, out: { ok: true, warnings: res.warnings, item: getItem(res.state, id) } };\n }\n case \"decide\": {\n if (!rest[0] || (rest[1] !== \"approve\" && rest[1] !== \"reject\"))\n return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const entry = state.pending.find((p) => p.id === rest[0]);\n const s2 = decide(\n state,\n rest[0],\n rest[1],\n by,\n flags[\"note\"] ?? \"\",\n now,\n methodologyOf(state),\n );\n await saveState(cwd, s2);\n return {\n exit: 0,\n out: { ok: true, item: entry?.item ? getItem(s2, entry.item) : null },\n };\n }\n case \"status\": {\n const state = await loadState(cwd);\n const m = methodologyOf(state);\n const counts: Record<ItemStatus, number> = {\n todo: 0,\n in_progress: 0,\n blocked: 0,\n review: 0,\n awaiting_human: 0,\n done: 0,\n dropped: 0,\n };\n for (const i of Object.values(state.items)) counts[i.status] += 1;\n return {\n exit: 0,\n out: {\n ok: true,\n methodology: state.methodology,\n openIteration: openIteration(state) ?? null,\n counts,\n pending: state.pending,\n openQuestions: openQuestions(state),\n lastEvent: lastEvent(state),\n report: m.report ? m.report(state) : null,\n },\n };\n }\n case \"board\": {\n const state = await loadState(cwd);\n const columns = state.stages.map((st) => ({\n stage: st.id,\n wipLimit: st.wipLimit ?? null,\n items: Object.values(state.items)\n .filter((i) => i.stage === st.id && i.status !== \"dropped\")\n .map((i) => ({\n id: i.id,\n title: i.title,\n status: i.status,\n role: i.role ?? null,\n age: i.transitions.length\n ? Date.parse(now) - Date.parse(i.transitions[i.transitions.length - 1]!.at)\n : null,\n })),\n }));\n return { exit: 0, out: { ok: true, columns } };\n }\n case \"metrics\": {\n const state = await loadState(cwd);\n return {\n exit: 0,\n out: { ok: true, metrics: methodologyOf(state).metrics(state) },\n };\n }\n case \"pending\":\n return {\n exit: 0,\n out: { ok: true, pending: (await loadState(cwd)).pending },\n };\n case \"lessons\":\n return {\n exit: 0,\n out: { ok: true, lessons: (await loadState(cwd)).lessons },\n };\n case \"validate\": {\n if (!rest[0]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const action = await readJson<Action>(path.resolve(cwd, rest[0]));\n if (\n typeof action !== \"object\" ||\n action === null ||\n Array.isArray(action) ||\n typeof action.type !== \"string\"\n )\n fail(\n \"invalid-input\",\n `action file ${rest[0]} must hold an object with a string \"type\"`,\n 'write the action as { \"type\": \"...\", \"by\": \"<role>\", \"payload\": { ... } }',\n );\n return {\n exit: 0,\n out: {\n ok: true,\n violations: validateAction(state, methodologyOf(state), action),\n },\n };\n }\n case \"role\": {\n const state = await loadState(cwd);\n if (rest[0] === \"list\")\n return {\n exit: 0,\n out: {\n ok: true,\n roles: Object.keys(state.roles),\n detail: state.roles,\n },\n };\n if (rest[0] === \"add\" && rest[1]) {\n const manifest = await readJson<Role>(path.resolve(cwd, rest[1]));\n assertValid(roleSchema, manifest, `role manifest ${rest[1]}`);\n const s2 = registerRole(state, manifest, by, now);\n await saveState(cwd, s2);\n return { exit: 0, out: { ok: true, roles: Object.keys(s2.roles) } };\n }\n return { exit: 2, out: { ok: false, usage: USAGE } };\n }\n default:\n return { exit: 2, out: { ok: false, usage: USAGE } };\n }\n}\n"]}
@@ -1,3 +0,0 @@
1
- 'use strict';var chunkOSHBJIYD_cjs=require('./chunk-OSHBJIYD.cjs');var l={Accounting:{type:"object",properties:{item:{type:"string"},role:{type:"string"},model:{type:"string"},tokensIn:{type:"number"},tokensOut:{type:"number"},durationMs:{type:"number"},startedAt:{type:"string"},endedAt:{type:"string"},estimate:{type:"boolean"}},required:["item","role","model","tokensIn","tokensOut","durationMs","startedAt","endedAt"],additionalProperties:false},Baseline:{type:"object",properties:{phase:{type:"string"},version:{type:"number"},at:{type:"string"},approvedBy:{type:"array",items:{type:"string"}},itemSnapshot:{type:"object",additionalProperties:{$ref:"#/definitions/WorkItem"}}},required:["phase","version","at","approvedBy","itemSnapshot"],additionalProperties:false},BeliefUpdate:{type:"object",properties:{result:{type:"string"},assessments:{type:"array",items:{type:"object",properties:{hypothesis:{type:"string"},assessment:{type:"string",enum:["supported","refuted","uncertain"]},reason:{type:"string"}},required:["hypothesis","assessment","reason"],additionalProperties:false}}},required:["result","assessments"],additionalProperties:false},Blocker:{type:"object",properties:{id:{type:"string"},reason:{type:"string"},owner:{type:"string"},raisedAt:{type:"string"},clearedAt:{type:"string"}},required:["id","reason","owner","raisedAt"],additionalProperties:false},Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},Capability:{type:"string",enum:["order-backlog","define-acceptance","facilitate","deliver","review","verify","approve-gate","manage-flow","control-change","escalate"]},ClassOfService:{type:"string",enum:["expedite","fixed-date","standard","intangible"]},Event:{type:"object",properties:{seq:{type:"number"},at:{type:"string"},type:{type:"string"},by:{type:"string"},payload:{}},required:["seq","at","type","by","payload"],additionalProperties:false},Evidence:{type:"object",properties:{kind:{type:"string"},ref:{type:"string"},by:{type:"string"},at:{type:"string"}},required:["kind","ref","by","at"],additionalProperties:false},Experiment:{type:"object",properties:{id:{type:"string"},procedureRef:{type:"string"},predictions:{type:"array",items:{type:"object",properties:{hypothesis:{type:"string"},prediction:{type:"string"}},required:["hypothesis","prediction"],additionalProperties:false}},replayOf:{type:"string"}},required:["id","procedureRef","predictions"],additionalProperties:false},ExperimentCandidate:{type:"object",properties:{id:{type:"string"},item:{type:"string"},author:{type:"string"},status:{type:"string",enum:["pending","ready","running","submitted","validated","failed","timed-out","cancelled"]},workspace:{type:"string"},sha:{type:"string"},score:{type:"number"},spent:{$ref:"#/definitions/Spent"},validation:{type:"object",properties:{sha:{type:"string"},harness:{type:"string"},by:{type:"string"},passed:{type:"boolean"},reproducible:{type:"boolean"},evidence:{type:"string"}},required:["sha","harness","by","passed","reproducible","evidence"],additionalProperties:false},reason:{type:"string"},command:{type:"string"},log:{type:"string"},terminalLog:{type:"string"}},required:["id","item","author","status","spent"],additionalProperties:false},ExperimentationState:{type:"object",properties:{status:{type:"string",enum:["running","selected","integrating","integrated","stopped"]},baseSha:{type:"string"},harness:{type:"string"},candidates:{type:"object",additionalProperties:{$ref:"#/definitions/ExperimentCandidate"}},selected:{type:"string"},reason:{type:"string"},integration:{type:"object",properties:{selectedSha:{type:"string"},targetSha:{type:"string"},sha:{type:"string"},by:{type:"string"},validation:{type:"object",properties:{by:{type:"string"},sha:{type:"string"},harness:{type:"string"},evidence:{type:"string"},passed:{type:"boolean"}},required:["by","sha","harness","evidence","passed"],additionalProperties:false}},required:["selectedSha","targetSha","sha","by"],additionalProperties:false},released:{type:"array",items:{type:"string"}},overhead:{$ref:"#/definitions/Spent"}},required:["status","baseSha","harness","candidates","released","overhead"],additionalProperties:false},Gate:{type:"object",properties:{id:{type:"string"},requires:{type:"array",items:{$ref:"#/definitions/GateRequirement"}},evidence:{type:"array",items:{type:"string"}},onFail:{anyOf:[{type:"object",properties:{action:{type:"string",const:"block"}},required:["action"],additionalProperties:false},{type:"object",properties:{action:{type:"string",const:"return-to"},stage:{type:"string"}},required:["action","stage"],additionalProperties:false}]}},required:["id","requires","evidence","onFail"],additionalProperties:false},GateRequirement:{anyOf:[{type:"string",const:"human"},{type:"object",properties:{capability:{type:"string"}},required:["capability"],additionalProperties:false}]},Handoff:{type:"object",properties:{item:{type:"string"},role:{type:"string"},produced:{type:"array",items:{type:"object",properties:{kind:{type:"string"},ref:{type:"string"}},required:["kind","ref"],additionalProperties:false}},notes:{type:"string"},do_not:{type:"array",items:{type:"string"}},open_questions:{type:"array",items:{type:"string"}},verdict:{$ref:"#/definitions/Verdict"},follow_ups:{type:"array",items:{$ref:"#/definitions/NewItem"}},lessons:{type:"array",items:{type:"object",properties:{text:{type:"string"},scope:{type:"string",enum:["policy","skill","memory","spec","review"]}},required:["text","scope"],additionalProperties:false}}},required:["item","role","produced","notes","do_not","open_questions"],additionalProperties:false},Hypothesis:{type:"object",properties:{id:{type:"string"},claim:{type:"string"},falsifiedBy:{type:"string"}},required:["id","claim","falsifiedBy"],additionalProperties:false},ImpactAnalysis:{type:"object",properties:{summary:{type:"string"},reopen:{type:"array",items:{type:"string"}},weight:{type:"number"}},required:["summary","reopen","weight"],additionalProperties:false},InvestigationConclusion:{type:"object",properties:{outcome:{type:"string",enum:["resolved","inconclusive"]},summary:{type:"string"},supportedHypothesis:{type:"string"},evidenceRefs:{type:"array",items:{type:"string"}},by:{type:"string"}},required:["outcome","summary","evidenceRefs","by"],additionalProperties:false},InvestigationRound:{type:"object",properties:{hypotheses:{type:"array",items:{$ref:"#/definitions/Hypothesis"}},experiment:{$ref:"#/definitions/Experiment"},item:{type:"string"},by:{type:"string"},result:{$ref:"#/definitions/Observation"},update:{$ref:"#/definitions/BeliefUpdate"}},required:["hypotheses","experiment","item","by"],additionalProperties:false},InvestigationState:{type:"object",properties:{item:{type:"string"},phase:{type:"string",enum:["hypotheses","preregister","observe","update-belief","conclusion","review","closed"]},hypotheses:{type:"array",items:{$ref:"#/definitions/Hypothesis"}},singleHypothesisRationale:{type:"string"},rounds:{type:"array",items:{$ref:"#/definitions/InvestigationRound"}},conclusion:{$ref:"#/definitions/InvestigationConclusion"},outcome:{type:"string",enum:["resolved","inconclusive","stopped"]},stopReason:{type:"string"},contributors:{type:"array",items:{type:"string"}},reviewHistory:{type:"array",items:{type:"object",properties:{by:{type:"string"},reason:{type:"string"},approve:{type:"boolean"},next:{type:"string",enum:["round","conclusion"]},replayRefs:{type:"array",items:{type:"string"}}},required:["by","reason","approve","replayRefs"],additionalProperties:false}},review:{type:"object",properties:{by:{type:"string"},reason:{type:"string"},replayRefs:{type:"array",items:{type:"string"}}},required:["by","reason","replayRefs"],additionalProperties:false}},required:["item","phase","hypotheses","rounds","contributors"],additionalProperties:false},ItemPatch:{type:"object",properties:{type:{$ref:"#/definitions/ItemType"},title:{type:"string"},description:{type:"string"},dependsOn:{type:"array",items:{type:"string"}},priority:{type:"number"},weight:{type:"number"},deadline:{type:"string"},classOfService:{$ref:"#/definitions/ClassOfService"},role:{type:"string"},parent:{type:"string"},acceptance:{type:"array",items:{type:"string"}},iteration:{type:"string"},traces:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}},affects:{type:"array",items:{type:"string"}},phase:{type:"string"},impactAnalysis:{$ref:"#/definitions/ImpactAnalysis"}},additionalProperties:false},ItemStatus:{type:"string",enum:["todo","in_progress","blocked","review","awaiting_human","done","dropped"]},ItemType:{type:"string",enum:["epic","story","task","bug","change-request","deliverable","question"]},Iteration:{type:"object",properties:{id:{type:"string"},goal:{type:"string"},budget:{$ref:"#/definitions/Budget"},spent:{$ref:"#/definitions/Spent"},startedAt:{type:"string"},endedAt:{type:"string"},committed:{type:"array",items:{type:"string"}},carryover:{type:"array",items:{type:"string"}},outcome:{type:"string",enum:["completed","cancelled"]},closing:{type:"boolean"}},required:["id","goal","budget","spent","startedAt","committed","carryover"],additionalProperties:false},Lesson:{type:"object",properties:{id:{type:"string"},at:{type:"string"},text:{type:"string"},scope:{type:"string",enum:["policy","skill","memory","spec","review"]},status:{type:"string",enum:["raised","adopted","dismissed"]},from:{type:"string"},item:{type:"string"},suggestedChange:{$ref:"#/definitions/LessonChange"}},required:["id","at","text","scope","status"],additionalProperties:false},LessonChange:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"agreement"},text:{type:"string"},replaces:{type:"string"}},required:["kind","text"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dod"},policy:{$ref:"#/definitions/Policy"}},required:["kind","policy"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"backlog"},item:{$ref:"#/definitions/NewItem"}},required:["kind","item"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"skill"},note:{type:"string"}},required:["kind","note"],additionalProperties:false}]},MethodologyName:{type:"string",enum:["scrum","kanban","waterfall","investigation","experimentation"]},ModelTier:{type:"string",enum:["small","medium","large"]},NewItem:{type:"object",additionalProperties:false,properties:{stage:{type:"string"},type:{$ref:"#/definitions/ItemType"},description:{type:"string"},dependsOn:{type:"array",items:{type:"string"}},priority:{type:"number"},weight:{type:"number"},deadline:{type:"string"},classOfService:{$ref:"#/definitions/ClassOfService"},role:{type:"string"},parent:{type:"string"},acceptance:{type:"array",items:{type:"string"}},iteration:{type:"string"},traces:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}},affects:{type:"array",items:{type:"string"}},phase:{type:"string"},impactAnalysis:{$ref:"#/definitions/ImpactAnalysis"},id:{type:"string"},title:{type:"string"}},required:["id","title"]},Observation:{type:"object",properties:{id:{type:"string"},valid:{type:"boolean"},summary:{type:"string"},provenanceRefs:{type:"array",items:{type:"string"}}},required:["id","valid","summary","provenanceRefs"],additionalProperties:false},PendingHuman:{type:"object",properties:{id:{type:"string"},kind:{type:"string",enum:["gate","decision"]},item:{type:"string"},gate:{type:"string"},question:{type:"string"},raisedAt:{type:"string"}},required:["id","kind","question","raisedAt"],additionalProperties:false},Phase:{type:"object",properties:{id:{type:"string"},name:{type:"string"},deliverables:{type:"array",items:{type:"string"}},gate:{$ref:"#/definitions/Gate"},status:{type:"string",enum:["pending","open","baselined","reopened"]},budget:{$ref:"#/definitions/Budget"},produced:{type:"array",items:{$ref:"#/definitions/Produced"}}},required:["id","name","deliverables","gate","status"],additionalProperties:false},Policy:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"evidence"},evidenceKind:{type:"string"}},required:["kind","evidenceKind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"acceptance-written"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"estimate-present"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"no-open-blockers"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dependencies-done"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"custom"},id:{type:"string"},description:{type:"string"}},required:["kind","id","description"],additionalProperties:false}]},Produced:{type:"object",properties:{kind:{type:"string"},ref:{type:"string"},by:{type:"string"},at:{type:"string"}},required:["kind","ref","by","at"],additionalProperties:false},Role:{type:"object",properties:{id:{type:"string"},name:{type:"string"},modelTier:{$ref:"#/definitions/ModelTier"},resourceClass:{type:"string"},maxConcurrent:{type:"number"},capabilities:{type:"array",items:{$ref:"#/definitions/Capability"}},canApprove:{type:"array",items:{type:"string"}},inputs:{type:"array",items:{type:"string"}},outputs:{type:"array",items:{type:"string"}},do_not:{type:"array",items:{type:"string"}},constraints:{type:"array",items:{type:"string"}}},required:["id","name","modelTier","capabilities","canApprove","inputs","outputs","do_not"],additionalProperties:false},Spent:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},required:["tokens","turns","wallclockMs"],additionalProperties:false},Stage:{type:"object",properties:{id:{type:"string"},name:{type:"string"},wipLimit:{type:"number"},entryPolicy:{type:"array",items:{$ref:"#/definitions/Policy"}},exitPolicy:{type:"array",items:{$ref:"#/definitions/Policy"}},gate:{$ref:"#/definitions/Gate"},commitmentPoint:{type:"boolean"},deliveryPoint:{type:"boolean"},review:{type:"boolean"}},required:["id","name","entryPolicy","exitPolicy"],additionalProperties:false},Transition:{type:"object",properties:{from:{type:"object",properties:{stage:{type:"string"},status:{$ref:"#/definitions/ItemStatus"}},required:["stage","status"],additionalProperties:false},to:{type:"object",properties:{stage:{type:"string"},status:{$ref:"#/definitions/ItemStatus"}},required:["stage","status"],additionalProperties:false},at:{type:"string"},by:{type:"string"}},required:["from","to","at","by"],additionalProperties:false},Verdict:{type:"string",enum:["done","blocked","needs-review","rework","escalate"]},WorkItem:{type:"object",properties:{id:{type:"string"},type:{$ref:"#/definitions/ItemType"},title:{type:"string"},description:{type:"string"},dependsOn:{type:"array",items:{type:"string"}},priority:{type:"number"},weight:{type:"number"},deadline:{type:"string"},classOfService:{$ref:"#/definitions/ClassOfService"},stage:{type:"string"},status:{$ref:"#/definitions/ItemStatus"},role:{type:"string"},parent:{type:"string"},acceptance:{type:"array",items:{type:"string"}},evidence:{type:"array",items:{$ref:"#/definitions/Evidence"}},blockers:{type:"array",items:{$ref:"#/definitions/Blocker"}},transitions:{type:"array",items:{$ref:"#/definitions/Transition"}},iteration:{type:"string"},traces:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}},affects:{type:"array",items:{type:"string"}},phase:{type:"string"},impactAnalysis:{$ref:"#/definitions/ImpactAnalysis"}},required:["id","type","title","dependsOn","stage","status","acceptance","evidence","blockers","transitions"],additionalProperties:false},WorkflowExt:{type:"object",properties:{investigation:{$ref:"#/definitions/InvestigationState"},experimentation:{$ref:"#/definitions/ExperimentationState"}},additionalProperties:{}},WorkflowState:{type:"object",properties:{version:{type:"number",const:1},methodology:{$ref:"#/definitions/MethodologyName"},config:{},investigation:{$ref:"#/definitions/InvestigationState",deprecated:true},experimentation:{$ref:"#/definitions/ExperimentationState",deprecated:true},ext:{$ref:"#/definitions/WorkflowExt"},items:{type:"object",additionalProperties:{$ref:"#/definitions/WorkItem"}},stages:{type:"array",items:{$ref:"#/definitions/Stage"}},roles:{type:"object",additionalProperties:{$ref:"#/definitions/Role"}},iterations:{type:"array",items:{$ref:"#/definitions/Iteration"}},phases:{type:"array",items:{$ref:"#/definitions/Phase"}},baseline:{$ref:"#/definitions/Baseline"},baselines:{type:"array",items:{$ref:"#/definitions/Baseline"}},events:{type:"array",items:{$ref:"#/definitions/Event"}},accounting:{type:"array",items:{$ref:"#/definitions/Accounting"}},pending:{type:"array",items:{$ref:"#/definitions/PendingHuman"}},lessons:{type:"array",items:{$ref:"#/definitions/Lesson"}},agreements:{type:"array",items:{type:"string"}}},required:["version","methodology","config","items","stages","roles","iterations","events","accounting","pending","lessons","agreements"],additionalProperties:false}},h={Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},EstimateMode:{type:"string",enum:["per-weight","per-call"]},Policy:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"evidence"},evidenceKind:{type:"string"}},required:["kind","evidenceKind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"acceptance-written"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"estimate-present"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"no-open-blockers"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dependencies-done"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"custom"},id:{type:"string"},description:{type:"string"}},required:["kind","id","description"],additionalProperties:false}]},ScrumConfig:{type:"object",properties:{sprintBudget:{$ref:"#/definitions/Budget"},productGoal:{type:"string"},definitionOfDone:{type:"array",items:{$ref:"#/definitions/Policy"}},refinementSharePct:{type:"number"},allowMidSprintAdd:{type:"string",enum:["never","po-only","any"]},inProgressWipLimit:{type:"number"},autoClose:{type:"boolean"},estimateMode:{$ref:"#/definitions/EstimateMode"},fallbackTokensPerWeight:{type:"number"}},required:["sprintBudget","productGoal","definitionOfDone","refinementSharePct","allowMidSprintAdd"],additionalProperties:false}},P={ClassConfig:{type:"object",properties:{wipBypass:{type:"number"},sle:{$ref:"#/definitions/ServiceLevel"}},additionalProperties:false},KanbanColumn:{type:"object",properties:{id:{type:"string"},name:{type:"string"},wipLimit:{type:"number"},policies:{type:"array",items:{$ref:"#/definitions/Policy"}},commitmentPoint:{type:"boolean"},deliveryPoint:{type:"boolean"},review:{type:"boolean"}},required:["id","name","policies"],additionalProperties:false},KanbanConfig:{type:"object",properties:{columns:{type:"array",items:{$ref:"#/definitions/KanbanColumn"}},classesOfService:{type:"object",properties:{expedite:{$ref:"#/definitions/ClassConfig"},"fixed-date":{$ref:"#/definitions/ClassConfig"},standard:{$ref:"#/definitions/ClassConfig"},intangible:{$ref:"#/definitions/ClassConfig"}},additionalProperties:false},fairness:{type:"object",properties:{aging:{type:"boolean"},maxDeferralRounds:{type:"number"}},required:["aging","maxDeferralRounds"],additionalProperties:false},cadences:{type:"object",properties:{replenishment:{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"delivery-planning":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"service-delivery-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"operations-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"risk-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"strategy-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false}},additionalProperties:false},throughputWindowMs:{type:"number"},maxExpedite:{type:"number"}},required:["columns","classesOfService","fairness","cadences","throughputWindowMs","maxExpedite"],additionalProperties:false},Policy:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"evidence"},evidenceKind:{type:"string"}},required:["kind","evidenceKind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"acceptance-written"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"estimate-present"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"no-open-blockers"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dependencies-done"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"custom"},id:{type:"string"},description:{type:"string"}},required:["kind","id","description"],additionalProperties:false}]},ServiceLevel:{type:"object",properties:{percentile:{type:"number"},targetMs:{type:"number"}},required:["percentile","targetMs"],additionalProperties:false}},k={Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},Gate:{type:"object",properties:{id:{type:"string"},requires:{type:"array",items:{$ref:"#/definitions/GateRequirement"}},evidence:{type:"array",items:{type:"string"}},onFail:{anyOf:[{type:"object",properties:{action:{type:"string",const:"block"}},required:["action"],additionalProperties:false},{type:"object",properties:{action:{type:"string",const:"return-to"},stage:{type:"string"}},required:["action","stage"],additionalProperties:false}]}},required:["id","requires","evidence","onFail"],additionalProperties:false},GateRequirement:{anyOf:[{type:"string",const:"human"},{type:"object",properties:{capability:{type:"string"}},required:["capability"],additionalProperties:false}]},WaterfallConfig:{type:"object",properties:{phases:{type:"array",items:{$ref:"#/definitions/WaterfallPhaseConfig"}},changeControl:{type:"object",properties:{requiresImpactAnalysis:{type:"boolean"},approvers:{type:"array",items:{$ref:"#/definitions/GateRequirement"}}},required:["requiresImpactAnalysis","approvers"],additionalProperties:false},traceability:{type:"object",properties:{from:{type:"string"},to:{type:"array",items:{type:"string"}}},required:["from","to"],additionalProperties:false},humanGates:{anyOf:[{type:"string",const:"all"},{type:"array",items:{type:"string"}}]},fallbackTokensPerWeight:{type:"number"}},required:["phases","changeControl","traceability","humanGates"],additionalProperties:false},WaterfallPhaseConfig:{type:"object",properties:{id:{type:"string"},name:{type:"string"},deliverables:{type:"array",items:{type:"string"}},gate:{$ref:"#/definitions/Gate"},budget:{$ref:"#/definitions/Budget"},deliverBy:{type:"string"}},required:["id","name","deliverables","gate"],additionalProperties:false}},$={Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},InvestigationConfig:{type:"object",properties:{question:{type:"string"},maxRounds:{type:"number"},budget:{$ref:"#/definitions/Budget"}},required:["question","maxRounds","budget"],additionalProperties:false}},j={Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},ExperimentationConfig:{type:"object",properties:{objective:{type:"string"},direction:{type:"string",enum:["minimize","maximize"]},tieBreak:{type:"string",const:"candidate-id"},concurrencyCap:{type:"number"},maxCandidates:{type:"number"},candidateBudget:{$ref:"#/definitions/Budget"},totalBudget:{$ref:"#/definitions/Budget"}},required:["objective","direction","tieBreak","concurrencyCap","maxCandidates","candidateBudget","totalBudget"],additionalProperties:false}};var S="#/definitions/";function m(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function w(e,t){return e==="integer"?typeof t=="number"&&Number.isInteger(t):m(t)===e}function p(e){let t=JSON.stringify(e);return t===void 0?String(e):t.length>60?`${t.slice(0,57)}...`:t}function q(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function v(e,t){return JSON.stringify(e)===JSON.stringify(t)}function d(e,t,s,n,i){return {path:e===""?"/":e,keyword:t,message:s,expected:n,found:i}}function O(e,t){e.startsWith(S)||chunkOSHBJIYD_cjs.b("invalid-input",`schema $ref ${JSON.stringify(e)} is not #/definitions/<name>`,"regenerate the schema with pnpm schema:gen");let s=e.slice(S.length),n=t.definitions&&Object.hasOwn(t.definitions,s)?t.definitions[s]:void 0;return n||chunkOSHBJIYD_cjs.b("invalid-input",`schema $ref ${JSON.stringify(e)} names no definition`,"regenerate the schema with pnpm schema:gen"),n}function x(e,t){let s=t===""?"/":t;return e.reduce((n,i)=>n+(i.keyword==="type"&&i.path===s?1e3:i.keyword==="const"?100:1),0)}function E(e){let t=e[0]?.filter(s=>s.keyword==="const")??[];for(let s of t){let n=e.map(r=>r.find(o=>o.keyword==="const"&&o.path===s.path));if(n.some(r=>r===void 0))continue;let i=[...new Set(n.map(r=>r?.expected))].join(" | ");return {path:s.path,keyword:"enum",message:`expected one of ${i}`,expected:i,found:s.found}}}function I(e,t){return f(e,t,e,"")}function f(e,t,s,n){if(e.$ref!==void 0)return f(O(e.$ref,s),t,s,n);let i=[];if(e.type!==void 0){let r=Array.isArray(e.type)?e.type:[e.type];if(!r.some(o=>w(o,t))){let o=r.join(" | ");return [d(n,"type",`expected ${o}, got ${m(t)}`,o,p(t))]}}if(e.const!==void 0&&!v(t,e.const)&&i.push(d(n,"const",`expected ${p(e.const)}`,p(e.const),p(t))),e.enum!==void 0&&!e.enum.some(r=>v(r,t))){let r=e.enum.map(p).join(" | ");i.push(d(n,"enum",`expected one of ${r}`,r,p(t)));}if(typeof t=="number"&&(e.minimum!==void 0&&t<e.minimum&&i.push(d(n,"minimum",`expected >= ${e.minimum}`,`>= ${e.minimum}`,p(t))),e.maximum!==void 0&&t>e.maximum&&i.push(d(n,"maximum",`expected <= ${e.maximum}`,`<= ${e.maximum}`,p(t)))),typeof t=="string"&&(e.minLength!==void 0&&t.length<e.minLength&&i.push(d(n,"minLength",`expected at least ${e.minLength} characters`,`length >= ${e.minLength}`,p(t))),e.pattern!==void 0&&!new RegExp(e.pattern,"u").test(t)&&i.push(d(n,"pattern",`expected to match /${e.pattern}/`,`/${e.pattern}/`,p(t)))),Array.isArray(t)&&e.items!==void 0){let r=e.items;t.forEach((o,c)=>i.push(...f(r,o,s,`${n}/${c}`)));}if(m(t)==="object"){let r=t;for(let[o,c]of Object.entries(r)){let g=e.properties&&Object.hasOwn(e.properties,o)?e.properties[o]:void 0,y=`${n}/${q(o)}`;if(g)i.push(...f(g,c,s,y));else if(e.additionalProperties===false){let b=Object.keys(e.properties??{}).join(", ");i.push(d(y,"additionalProperties",`unknown property ${JSON.stringify(o)}`,b?`one of ${b}`:"no properties",o));}else typeof e.additionalProperties=="object"&&i.push(...f(e.additionalProperties,c,s,y));}for(let o of e.required??[])Object.hasOwn(r,o)||i.push(d(`${n}/${q(o)}`,"required",`missing required property ${JSON.stringify(o)}`,"present","absent"));}if(e.anyOf!==void 0){let r,o=[];for(let g of e.anyOf){let y=f(g,t,s,n);if(y.length===0){r=[];break}o.push(y),(r===void 0||x(y,n)<x(r,n))&&(r=y);}let c=r&&r.length>0?E(o):void 0;c?i.push(c):r&&i.push(...r);}return i}function C(e,t,s){let n=I(e,t),i=n[0];if(!i)return;let r=n.length>1?` (+${n.length-1} more)`:"";chunkOSHBJIYD_cjs.b("invalid-input",`${s} does not match its schema: ${i.path} ${i.message}${r}`,`fix ${s} at ${i.path}: expected ${i.expected}, found ${i.found}`);}var N="http://json-schema.org/draft-07/schema#";function a(e,t){return {$schema:N,$ref:`#/definitions/${e}`,definitions:t}}var J=a("WorkflowState",l),M=a("Role",l),_=a("NewItem",l),D=a("ItemPatch",l),F=a("Handoff",l),L=a("ScrumConfig",h),W=a("KanbanConfig",P),G=a("WaterfallConfig",k),K=a("InvestigationConfig",$),H=a("ExperimentationConfig",j);
2
- exports.a=I;exports.b=C;exports.c=N;exports.d=J;exports.e=M;exports.f=_;exports.g=D;exports.h=F;exports.i=L;exports.j=W;exports.k=G;exports.l=K;exports.m=H;//# sourceMappingURL=chunk-43GLYYA2.cjs.map
3
- //# sourceMappingURL=chunk-43GLYYA2.cjs.map