ex-workflow 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +314 -141
  3. package/dist/adapters/index.cjs +1 -1
  4. package/dist/adapters/index.d.cts +1 -1
  5. package/dist/adapters/index.d.ts +1 -1
  6. package/dist/adapters/index.mjs +1 -1
  7. package/dist/{budget-Cx63FX2K.d.ts → budget-Bd8KpGIr.d.ts} +1 -1
  8. package/dist/{budget-JyNKxP5N.d.cts → budget-CezCinPF.d.cts} +1 -1
  9. package/dist/chunk-6P3OKXSK.mjs +2 -0
  10. package/dist/chunk-6P3OKXSK.mjs.map +1 -0
  11. package/dist/{chunk-5PHK72VM.cjs → chunk-7FS6KWTG.cjs} +2 -2
  12. package/dist/{chunk-5PHK72VM.cjs.map → chunk-7FS6KWTG.cjs.map} +1 -1
  13. package/dist/chunk-APKA5FOU.cjs +2 -0
  14. package/dist/chunk-APKA5FOU.cjs.map +1 -0
  15. package/dist/chunk-ATCJ4IHP.mjs +2 -0
  16. package/dist/{chunk-Z2G7DGDF.mjs.map → chunk-ATCJ4IHP.mjs.map} +1 -1
  17. package/dist/chunk-C2IYMWE6.cjs +3 -0
  18. package/dist/chunk-C2IYMWE6.cjs.map +1 -0
  19. package/dist/chunk-EACZBAP3.cjs +2 -0
  20. package/dist/chunk-EACZBAP3.cjs.map +1 -0
  21. package/dist/chunk-EHBQBXWA.cjs +2 -0
  22. package/dist/{chunk-VXH2FAKV.cjs.map → chunk-EHBQBXWA.cjs.map} +1 -1
  23. package/dist/chunk-FQW2LETC.cjs +2 -0
  24. package/dist/chunk-FQW2LETC.cjs.map +1 -0
  25. package/dist/chunk-FTS75UIU.mjs +2 -0
  26. package/dist/{chunk-U3OXAO67.mjs.map → chunk-FTS75UIU.mjs.map} +1 -1
  27. package/dist/chunk-HCRVWMG4.cjs +2 -0
  28. package/dist/chunk-HCRVWMG4.cjs.map +1 -0
  29. package/dist/chunk-KLWZEXZU.mjs +3 -0
  30. package/dist/chunk-KLWZEXZU.mjs.map +1 -0
  31. package/dist/chunk-MW4HR7HC.mjs +2 -0
  32. package/dist/chunk-MW4HR7HC.mjs.map +1 -0
  33. package/dist/chunk-NDCQTRIV.mjs +2 -0
  34. package/dist/chunk-NDCQTRIV.mjs.map +1 -0
  35. package/dist/{chunk-7IG6EQI4.mjs → chunk-QZ6HD6DE.mjs} +3 -3
  36. package/dist/{chunk-7IG6EQI4.mjs.map → chunk-QZ6HD6DE.mjs.map} +1 -1
  37. package/dist/{chunk-HIHMBMB5.cjs → chunk-RL27372B.cjs} +2 -2
  38. package/dist/{chunk-HIHMBMB5.cjs.map → chunk-RL27372B.cjs.map} +1 -1
  39. package/dist/chunk-SP5MC7RR.mjs +2 -0
  40. package/dist/{chunk-QDMEM62U.mjs.map → chunk-SP5MC7RR.mjs.map} +1 -1
  41. package/dist/chunk-SYLO7FUL.mjs +2 -0
  42. package/dist/{chunk-3KFQPSRX.mjs.map → chunk-SYLO7FUL.mjs.map} +1 -1
  43. package/dist/chunk-T3V5UE34.mjs +2 -0
  44. package/dist/{chunk-UZQV73X7.mjs.map → chunk-T3V5UE34.mjs.map} +1 -1
  45. package/dist/{chunk-FKTCGQYB.cjs → chunk-TS66RAJR.cjs} +2 -2
  46. package/dist/{chunk-FKTCGQYB.cjs.map → chunk-TS66RAJR.cjs.map} +1 -1
  47. package/dist/{chunk-YRATJT7P.cjs → chunk-U23FUYPD.cjs} +4 -4
  48. package/dist/{chunk-YRATJT7P.cjs.map → chunk-U23FUYPD.cjs.map} +1 -1
  49. package/dist/{chunk-CYXVGHQM.cjs → chunk-YJQ5YJ7S.cjs} +2 -2
  50. package/dist/{chunk-CYXVGHQM.cjs.map → chunk-YJQ5YJ7S.cjs.map} +1 -1
  51. package/dist/chunk-YOS77GL3.mjs +2 -0
  52. package/dist/chunk-YOS77GL3.mjs.map +1 -0
  53. package/dist/chunk-YTG2MOD7.cjs +2 -0
  54. package/dist/chunk-YTG2MOD7.cjs.map +1 -0
  55. package/dist/chunk-YZJ6WFH4.mjs +2 -0
  56. package/dist/chunk-YZJ6WFH4.mjs.map +1 -0
  57. package/dist/cli/bin.cjs +1 -1
  58. package/dist/cli/bin.cjs.map +1 -1
  59. package/dist/cli/bin.mjs +1 -1
  60. package/dist/cli/bin.mjs.map +1 -1
  61. package/dist/cli/index.cjs +1 -1
  62. package/dist/cli/index.mjs +1 -1
  63. package/dist/experimentation/index.cjs +2 -0
  64. package/dist/experimentation/index.cjs.map +1 -0
  65. package/dist/experimentation/index.d.cts +28 -0
  66. package/dist/experimentation/index.d.ts +28 -0
  67. package/dist/experimentation/index.mjs +2 -0
  68. package/dist/experimentation/index.mjs.map +1 -0
  69. package/dist/index.cjs +1 -1
  70. package/dist/index.cjs.map +1 -1
  71. package/dist/index.d.cts +4 -4
  72. package/dist/index.d.ts +4 -4
  73. package/dist/index.mjs +1 -1
  74. package/dist/index.mjs.map +1 -1
  75. package/dist/investigation/index.cjs +2 -0
  76. package/dist/investigation/index.cjs.map +1 -0
  77. package/dist/investigation/index.d.cts +13 -0
  78. package/dist/investigation/index.d.ts +13 -0
  79. package/dist/investigation/index.mjs +2 -0
  80. package/dist/investigation/index.mjs.map +1 -0
  81. package/dist/kanban/index.cjs +1 -1
  82. package/dist/kanban/index.d.cts +1 -1
  83. package/dist/kanban/index.d.ts +1 -1
  84. package/dist/kanban/index.mjs +1 -1
  85. package/dist/schema/index.cjs +1 -1
  86. package/dist/schema/index.d.cts +3 -1
  87. package/dist/schema/index.d.ts +3 -1
  88. package/dist/schema/index.mjs +1 -1
  89. package/dist/scrum/index.cjs +1 -1
  90. package/dist/scrum/index.d.cts +3 -3
  91. package/dist/scrum/index.d.ts +3 -3
  92. package/dist/scrum/index.mjs +1 -1
  93. package/dist/types-BScHXlRx.d.cts +509 -0
  94. package/dist/types-BScHXlRx.d.ts +509 -0
  95. package/dist/types.d.cts +1 -388
  96. package/dist/types.d.ts +1 -388
  97. package/dist/waterfall/index.cjs +1 -1
  98. package/dist/waterfall/index.d.cts +1 -1
  99. package/dist/waterfall/index.d.ts +1 -1
  100. package/dist/waterfall/index.mjs +1 -1
  101. package/package.json +43 -20
  102. package/dist/chunk-3KFQPSRX.mjs +0 -2
  103. package/dist/chunk-5TXYMLBF.mjs +0 -3
  104. package/dist/chunk-5TXYMLBF.mjs.map +0 -1
  105. package/dist/chunk-MQWMQ4PD.mjs +0 -2
  106. package/dist/chunk-MQWMQ4PD.mjs.map +0 -1
  107. package/dist/chunk-QDMEM62U.mjs +0 -2
  108. package/dist/chunk-U3OXAO67.mjs +0 -2
  109. package/dist/chunk-UZQV73X7.mjs +0 -2
  110. package/dist/chunk-VXH2FAKV.cjs +0 -2
  111. package/dist/chunk-WOGK54HB.cjs +0 -3
  112. package/dist/chunk-WOGK54HB.cjs.map +0 -1
  113. package/dist/chunk-XMO2RCXB.cjs +0 -2
  114. package/dist/chunk-XMO2RCXB.cjs.map +0 -1
  115. package/dist/chunk-YBHHICTZ.mjs +0 -2
  116. package/dist/chunk-YBHHICTZ.mjs.map +0 -1
  117. package/dist/chunk-YJN4JEJU.cjs +0 -2
  118. package/dist/chunk-YJN4JEJU.cjs.map +0 -1
  119. package/dist/chunk-Z2G7DGDF.mjs +0 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.0 (2026-10-28)
4
+
5
+ - Add standalone Investigation (#37) and Experimentation (#38) methodologies, public subpath entries, CLI initialization, persisted lifecycle artifacts, configuration schemas and integration coverage. Investigation records falsifiable hypotheses, preregistered runs, observations, belief updates, replay and independent conclusion review. Experimentation records frozen baselines and harnesses, isolated candidate identities, bounded execution, exact-SHA validation, deterministic selection and freshly validated integration. Hosts own execution, Git and workspace lifecycle; cross-methodology workflows are unsupported.
6
+
7
+ ## 1.0.1 (2026-10-24)
8
+
9
+ Documentation release; no code, schema, CLI or `state.json` change.
10
+
11
+ - README rewritten for users of the package: a contents table, a methodology comparison (roles, flow, ceremonies, metrics), the run loop, quick starts for Scrum, Kanban and Waterfall, the `.workflow/` layout, the full CLI reference, configuration keys per methodology, every ceremony with its input shape, the item, brief, handoff and accounting contracts, the error shape with every code, the JSON Schema entry point, the package entry points, the compatibility promise and the known limitations written as what happens and what to do.
12
+ - Removed from the README: the workflowAI layer roadmap, the per-stage status history, the development gate, the publishing notes and the internal reasoning behind each accepted limitation; the design spec and CHANGELOG keep that history.
13
+ - `VERSION` is `"1.0.1"`.
14
+
3
15
  ## 1.0.0 (2026-10-24)
4
16
 
5
17
  First stable release, published to `latest`. Phase 7 fixes the five engine gaps the workflowAI S2 dogfood raised (#23-#27) and closes the 1.0 definition; the decisions are in the design spec, section 23.
package/README.md CHANGED
@@ -1,232 +1,405 @@
1
1
  # ex-workflow
2
2
 
3
- Methodology engine for AI teams. Scrum, Kanban and Waterfall are modelled as data (stages, roles, policies, gates, ceremonies) and driven by a pure state machine on top of the [`ex-flow`](https://www.npmjs.com/package/ex-flow) DAG planner. The program decides, the LLM executes: which item may move, who may approve, whether a sprint may close is enforced by the engine, not by a prompt.
4
-
5
- State is plain JSON, every operation is `(state, action) -> state`, and every error names the rule, the item and a concrete fix. Core performs no I/O; a small file adapter and the `exwf` CLI sit on top. Runtime dependencies are exactly `ex-flow` and `exsorted`.
3
+ **Methodology engine for AI agent teams.** Scrum, Kanban, Waterfall, Investigation and Experimentation as data-driven state machines in TypeScript: the engine decides which item may move, who may approve and whether an iteration may close; your agents only do the work.
4
+
5
+ [![npm](https://img.shields.io/npm/v/ex-workflow)](https://www.npmjs.com/package/ex-workflow) [![license](https://img.shields.io/npm/l/ex-workflow)](LICENSE) Node >= 18 · macOS, Linux, Windows · ESM + CommonJS · no I/O in core
6
+
7
+ - State is plain JSON. Every operation is `(state, action) -> state`.
8
+ - Every error names the rule, the item and a concrete fix.
9
+ - Two runtime dependencies: [`ex-flow`](https://www.npmjs.com/package/ex-flow) (DAG planner) and [`exsorted`](https://www.npmjs.com/package/exsorted).
10
+ - Works with any LLM host: the engine hands out **briefs**, you run them with your agents and hand back **handoffs**.
11
+
12
+ ## Contents
13
+
14
+ 1. [Install](#install)
15
+ 2. [Pick a methodology](#pick-a-methodology)
16
+ 3. [How a run works](#how-a-run-works)
17
+ 4. [Quick start: Scrum](#quick-start-scrum)
18
+ 5. [Quick start: Kanban](#quick-start-kanban)
19
+ 6. [Quick start: Waterfall](#quick-start-waterfall)
20
+ 7. [Standalone investigation and experimentation](#standalone-investigation-and-experimentation)
21
+ 8. [Persisting state](#persisting-state)
22
+ 9. [CLI reference (`exwf`)](#cli-reference-exwf)
23
+ 10. [Configuration](#configuration)
24
+ 11. [Ceremonies](#ceremonies)
25
+ 12. [Items, briefs, handoffs, accounting](#items-briefs-handoffs-accounting)
26
+ 13. [Errors](#errors)
27
+ 14. [JSON Schema](#json-schema)
28
+ 15. [Package entry points](#package-entry-points)
29
+ 16. [Compatibility and versioning](#compatibility-and-versioning)
30
+ 17. [Known limitations](#known-limitations)
31
+ 18. [Contributing](#contributing)
32
+ 19. [License](#license)
6
33
 
7
34
  ## Install
8
35
 
9
36
  ```sh
10
- npm install ex-workflow
37
+ npm install ex-workflow # or: pnpm add ex-workflow
38
+ npx exwf # prints the CLI usage
11
39
  ```
12
40
 
13
- `npm install ex-workflow` resolves to 1.0.0 (`pnpm add ex-workflow` likewise). Stage pre-releases may still appear under the `stage` dist-tag.
41
+ This source tree targets version 1.1.0. Pre-releases, when any, are published under the `stage` dist-tag.
42
+
43
+ ## Pick a methodology
44
+
45
+ | | Scrum (`ex-workflow/scrum`) | Kanban (`ex-workflow/kanban`) | Waterfall (`ex-workflow/waterfall`) |
46
+ |---|---|---|---|
47
+ | Fits | a goal delivered in budgeted sprints | a continuous flow of requests | a phase-gated project with a frozen baseline |
48
+ | Unit of control | sprint budget (tokens, turns, wall-clock) | WIP limits per column, classes of service | human-approved gate per phase |
49
+ | Flow | backlog → sprint → review | options → ready → dev → review → done | work → review → done, inside each phase |
50
+ | Preset roles | product-owner, scrum-master, developer | service-request-manager, service-delivery-manager, worker | project-manager, business-analyst, architect, developer, qa, release-manager |
51
+ | Ceremonies | refine, plan, commit, uncommit, daily, review, retro, cancel | replenishment, delivery-planning, service-delivery-review, operations-review, risk-review, strategy-review | kickoff, gateReview, changeControlBoard, phaseRetrospective |
52
+ | Metrics | velocity, cost per point, budget utilisation | lead and cycle time, throughput, WIP, flow efficiency, aging, CFD, SLE compliance | phase report, requirement coverage, traceability matrix |
53
+
54
+ Scrum, Kanban and Waterfall share one core: the same item model, the same brief and handoff contracts, the same CLI and the same `.workflow/` files. Roles are data (capabilities, not names), so you can replace or extend the presets with `exwf role add`.
55
+
56
+ Standalone [Investigation and Experimentation](#standalone-investigation-and-experimentation) add evidence-driven inquiry and isolated candidate comparison; each runs in its own state.
14
57
 
15
- Node >= 18. Runs on macOS, Linux and Windows.
58
+ ## How a run works
16
59
 
17
- ## Quick start
60
+ ```
61
+ addItem ──▶ next() ──▶ Brief per item ──▶ your agent ──▶ Handoff + Accounting ──▶ complete()
62
+ ▲ │
63
+ └──────────── ceremonies, decide(), unblock ─────────────────────────┘
64
+ ```
65
+
66
+ 1. **Add items** with acceptance criteria. Rules check them at add time.
67
+ 2. **`next()`** asks the planner which items may be dispatched now (dependencies, WIP, policies, budget, roles) and returns one brief per item: the item, its acceptance, the invariants in force, upstream results, prior attempts and what not to do.
68
+ 3. **Run each brief** with whatever agent or model you like. The engine never calls an LLM.
69
+ 4. **`complete()`** records the handoff (what was produced, verdict, follow-ups, lessons) and the accounting (tokens, duration, model). Policies and gates decide whether the item advances, needs review, is blocked or is reworked.
70
+ 5. **Ceremonies** move the iteration: plan and review a sprint, replenish a board, open and gate a phase. Anything that needs a human lands in `pending`, and `decide()` resolves it.
71
+
72
+ ## Quick start: Scrum
18
73
 
19
74
  ```ts
20
75
  import { init, addItem, next, complete } from "ex-workflow";
21
76
  import { scrum } from "ex-workflow/scrum";
22
77
 
23
78
  const m = scrum();
24
- const config = { sprintBudget: { tokens: 300_000 }, productGoal: "ship the checkout", definitionOfDone: [{ kind: "evidence", evidenceKind: "test-output" }] };
79
+ const config = {
80
+ sprintBudget: { tokens: 300_000 },
81
+ productGoal: "ship the checkout",
82
+ definitionOfDone: [{ kind: "evidence", evidenceKind: "test-output" }],
83
+ };
25
84
  let state = init({ methodology: m, config }).state;
26
85
  state = addItem(state, { id: "CART", title: "cart API", weight: 3, priority: 5, acceptance: ["add/remove items"] }, "product-owner");
27
86
  state = m.ceremonies["plan"]!(state, { by: "scrum-master", goal: "customers can pay", items: "auto" }).state;
28
87
 
29
- const { state: s2, briefs } = next(state, m); // dispatches work, returns one brief per item
30
- // ...run each brief with your agent, then record the result:
88
+ const { state: s2, briefs } = next(state, m); // one brief per dispatched item
89
+ // run each brief with your agent, then:
31
90
  // state = complete(s2, m, handoff, accounting).state;
32
91
  // state = m.ceremonies["review"]!(state, { by: "human", accepted: true, goalMet: true }).state;
33
92
  ```
34
93
 
35
- To persist state, use the file adapter (the only part of the package that touches disk):
36
-
37
- ```ts
38
- import { loadState, saveState, withStateLock } from "ex-workflow/adapters";
39
-
40
- await withStateLock(process.cwd(), async () => {
41
- const state = await loadState(process.cwd());
42
- await saveState(process.cwd(), complete(state, m, handoff, accounting).state);
43
- });
44
- ```
45
-
46
- `test/sprint.e2e.test.ts` is a complete two-sprint scenario: rework, a blocker, an escalation, a retro that changes the working agreements, and metrics.
94
+ The sprint closes when its budget is spent and nothing is in flight (`autoClose`), or through `review` / `cancel`. `retro` turns lessons into working agreements that every later brief carries.
47
95
 
48
- ### Kanban
96
+ ## Quick start: Kanban
49
97
 
50
98
  ```ts
51
- import { addItem, complete, init, next } from "ex-workflow";
52
- import { board, kanban, kanbanMetrics } from "ex-workflow/kanban";
99
+ import { init, addItem, next, complete } from "ex-workflow";
100
+ import { kanban, board, kanbanMetrics } from "ex-workflow/kanban";
53
101
 
54
- const m = kanban(); // default board: options → ready (commit, WIP 4) → dev (WIP 3) → review (WIP 2) → done
55
- let state = init({ methodology: m, config: { classesOfService: { standard: { sle: { percentile: 85, targetMs: 7 * 86_400_000 } } } } }).state;
102
+ const m = kanban(); // options → ready (commitment point, WIP 4) → dev (WIP 3) → review (WIP 2) → done
103
+ let state = init({
104
+ methodology: m,
105
+ config: { classesOfService: { standard: { sle: { percentile: 85, targetMs: 7 * 86_400_000 } } } },
106
+ }).state;
56
107
  state = addItem(state, { id: "SEARCH", title: "search box", acceptance: ["finds by name"] }, "service-request-manager");
57
- state = m.ceremonies["replenishment"]!(state, { by: "service-request-manager", items: ["SEARCH"] }).state; // the only push: options → commitment point
58
- const { state: s2, briefs } = next(state, m); // the planner pulls ready → dev within WIP; expedite cards jump the queue
59
- // ...run each brief, then complete(s2, m, handoff, accounting); cards advance column by column
60
- board(s2, new Date().toISOString()); // columns with active/queued counts and card ages
61
- kanbanMetrics(s2); // lead time, cycle time per column, throughput, WIP, flow efficiency, aging, CFD, SLE compliance
62
- ```
63
-
64
- Cadences are ceremonies: `replenishment`, `delivery-planning`, `service-delivery-review` (WIP, policies, SLEs), `operations-review` (blockers, aging WIP), `risk-review` (fixed-date risk, stale blockers), `strategy-review` (classes of service). `exwf status` reports which cadences are due (`config.cadences.<name>.everyTurns`). `delivery-planning` needs a non-empty `items` list, and the `operations-review` assign entries need an existing blocker id. `test/kanban.e2e.test.ts` is a full week with an expedite, an escalation and a blocker.
108
+ state = m.ceremonies["replenishment"]!(state, { by: "service-request-manager", items: ["SEARCH"] }).state; // the only push
65
109
 
66
- `next()` also returns `skipped`: each ready card it did not pull, with `reason` (`entry-policy`, `wip`, `resource-cap` or `budget`) and a `detail`; the commitment column's policies gate the pull out of it (escalation `question` cards are exempt, as from exit policies and gates). Ordering is by class band (question, expedite, fixed-date, standard, intangible) and, with `fairness.aging` on (the default), priority stays primary inside a window of `fairness.maxDeferralRounds` passes (default 5); each full window a card is passed over promotes it one step above any priority difference, and an intangible card reaching the first window is ranked as standard, so nothing is starved.
110
+ const { state: s2, briefs, skipped } = next(state, m); // pulls ready → dev within WIP; expedite jumps the queue
111
+ board(s2, new Date().toISOString()); // columns, active/queued counts, card ages
112
+ kanbanMetrics(s2); // lead time, cycle time per column, throughput, WIP, flow efficiency, SLE compliance
113
+ ```
67
114
 
68
- `service-delivery-review` also takes `lessons`, `adopt`, `dismiss` and `retire`, with the Scrum retro semantics for agreements.
115
+ `skipped` lists every ready card the planner did not pull, with a `reason` (`entry-policy`, `wip`, `resource-cap`, `budget`) and a `detail`. Ordering is by class (expedite, fixed-date, standard, intangible), then priority; with `fairness.aging` on (default) a card passed over for `fairness.maxDeferralRounds` passes (default 5) is promoted, so nothing starves.
69
116
 
70
- ### Waterfall
117
+ ## Quick start: Waterfall
71
118
 
72
119
  ```ts
73
120
  import { init, addItem, applyAction, next, complete, decide } from "ex-workflow";
74
121
  import { waterfall } from "ex-workflow/waterfall";
75
122
 
76
- const m = waterfall();
77
- let { state } = init({ methodology: m, config: {} }); // six classic phases, every gate human-approved
123
+ const m = waterfall(); // requirements → design → implementation → verification → deployment → maintenance
124
+ let { state } = init({ methodology: m, config: {} });
78
125
  const r1 = { id: "R1", title: "login", phase: "requirements", acceptance: ["user can log in"] };
79
126
  state = applyAction(state, m, { type: "item.add", by: "business-analyst", payload: { item: r1 } }, (s) =>
80
127
  addItem(s, r1, "business-analyst"),
81
128
  ).state;
82
129
  state = m.ceremonies["kickoff"]!(state, { by: "project-manager", phase: "requirements" }).state;
83
- // next() → complete() as with any methodology; items go work → review → done
84
- state = m.ceremonies["gateReview"]!(state, { by: "project-manager", phase: "requirements" }).state; // pending decision
85
- state = decide(state, state.pending[0]!.id, "approve", "human", "ok", undefined, m); // baselines the phase
130
+ // next() → complete() as usual; items go work → review → done
131
+ state = m.ceremonies["gateReview"]!(state, { by: "project-manager", phase: "requirements" }).state; // raises a pending decision
132
+ state = decide(state, state.pending[0]!.id, "approve", "human", "ok", undefined, m); // baselines the phase
133
+ ```
134
+
135
+ Phases open one at a time (`kickoff`) and close through a gate (`gateReview`), human-approved by default. An approved gate **baselines** the phase: its items are frozen and can only change through an approved change-request (`changeControlBoard`, with an impact analysis). Requirements must trace to design and verification items before those gates close; the engine generates the `traceability-matrix` deliverable. Default deliverables per phase: `srs`; `design-doc`, `interface-spec`; `code-baseline`; `test-report`, `traceability-matrix`; `release-notes`, `deployment-record`; `change-log`.
136
+
137
+ ## Standalone investigation and experimentation
138
+
139
+ Run the complete synthetic SDK examples from this repository:
140
+
141
+ ```sh
142
+ pnpm exec tsx scripts/example-investigation.ts
143
+ pnpm exec tsx scripts/example-experimentation.ts
86
144
  ```
87
145
 
88
- Phases open one at a time (`kickoff`), close through a gate (`gateReview`, human-approved by default) that
89
- baselines their items, and reopen only through an approved change-request (`changeControlBoard`, with an
90
- impact analysis). Requirements must trace to design and verification items before those gates; the engine
91
- generates the `traceability-matrix` deliverable. Edits to baselined items are refused by the rules when
92
- they go through `applyAction` or the CLI. `test/waterfall.e2e.test.ts` is a full project with a
93
- change-request that reopens two baselined phases.
146
+ [Investigation example](scripts/example-investigation.ts) exercises execution, observation, rejected review, independent replay and a resolved conclusion. [Experimentation example](scripts/example-experimentation.ts) compares two candidates (one nonreproducible), records exact-SHA integration, validates it afresh and cleans up. Both use explicitly synthetic in-memory host outputs and assert their final outcomes; they do not execute procedures, benchmarks, Git or filesystem operations.
147
+
148
+ These methodologies run in their own workflow state. They do not nest inside, migrate into, or coordinate Scrum, Kanban, Waterfall or each other. The host executes procedures, creates isolated workspaces, runs benchmarks and performs Git operations; the engine records and validates the resulting artifacts.
149
+
150
+ ```ts
151
+ import { init } from "ex-workflow";
152
+ import { investigation } from "ex-workflow/investigation";
153
+
154
+ const m = investigation();
155
+ let { state } = init({ methodology: m, config: {
156
+ question: "Why do repeated requests miss the cache?",
157
+ maxRounds: 3, budget: { tokens: 100_000, turns: 20 },
158
+ } });
159
+ state = m.ceremonies["intake"]!(state, { by: "investigator", item: "CACHE" }).state;
160
+ state = m.ceremonies["hypotheses"]!(state, { by: "investigator", hypotheses: [
161
+ { id: "key", claim: "Keys differ", falsifiedBy: "Identical keys" },
162
+ { id: "expiry", claim: "Entries expire", falsifiedBy: "Live entries" },
163
+ ] }).state;
164
+ ```
165
+
166
+ Investigation requires a question, positive `maxRounds` and a finite positive `budget` (`tokens`, `turns`, `wallclockMs`). Its ceremonies are `intake { item }`, `hypotheses { hypotheses: [{ id, claim, falsifiedBy }], singleHypothesisRationale? }`, `preregister { experiment: { id, procedureRef, predictions: [{ hypothesis, prediction }], replayOf? } }`, `observe { experiment, result: { id, valid, summary, provenanceRefs } }`, `update-belief { result, assessments: [{ hypothesis, assessment, reason }], next: "round" | "conclusion" }`, `conclude { outcome, summary, evidenceRefs, supportedHypothesis? }`, `review-conclusion { approve, reason, replayRefs?, next?: "round" | "conclusion" }` and `stop { reason }`. Assessments are `supported`, `refuted` or `uncertain`; outcomes are `resolved` or `inconclusive`. Execute each preregistered run with `next()` and `complete()` before observing it, producing `experiment-output` evidence. A resolved conclusion needs supporting valid evidence, a valid replay and an independent `conclusion-reviewer`; `investigator` handles the other ceremonies. Invalid runs remain recorded.
167
+
168
+ ```ts
169
+ import { init, addItem } from "ex-workflow";
170
+ import { experimentation } from "ex-workflow/experimentation";
171
+
172
+ const m = experimentation();
173
+ let { state } = init({ methodology: m, config: {
174
+ objective: "Lowest median latency", direction: "minimize", tieBreak: "candidate-id",
175
+ concurrencyCap: 2, maxCandidates: 4,
176
+ candidateBudget: { turns: 10 }, totalBudget: { turns: 40 },
177
+ } });
178
+ state = addItem(state, { id: "A", title: "Candidate A", acceptance: ["Pass frozen benchmark"] }, "coordinator");
179
+ state = m.ceremonies["freeze"]!(state, { by: "coordinator", baseSha: "a".repeat(40),
180
+ harness: "bench-v1", candidates: [{ id: "a", item: "A", author: "builder" }],
181
+ }).state;
182
+ state = m.ceremonies["provision"]!(state, { by: "coordinator", candidate: "a", workspace: "/worktrees/a", baseSha: "a".repeat(40), isolated: true }).state;
183
+ ```
94
184
 
95
- `add` and `edit` validate `traces` ids and the impact analysis of a change-request, and `status` phase rows carry `missingTraces`.
185
+ Experimentation requires `objective`; `direction` defaults to `minimize` (`maximize` also supported), `tieBreak` to `candidate-id`, `concurrencyCap` to 2, `maxCandidates` to 4, and positive `candidateBudget` / `totalBudget` to 10 / 40 turns. Freeze the full baseline SHA, harness identity and candidate authors before work. The host must provision distinct isolated workspaces at that baseline and enforce their ownership; workspace strings are recorded identities, not filesystem operations.
96
186
 
97
- ## CLI
187
+ Ceremonies continue with `start { candidate }` and `submit { candidate, sha, score, baseSha, workspace, harness, command, log, spent: { tokens, turns, wallclockMs } }` by the builder; `validate { candidate, sha, harness, passed, reproducible, evidence, spent }` by an independent validator; `compare` by the coordinator; `integrate { selectedSha, targetSha, integrationSha, spent }` by the integrator; and `validate-integration { sha, targetSha, harness, passed, evidence, spent }` by a validator independent of the author and integrator. SHAs are full lowercase commit hashes. Comparison ranks eligible validated candidates by score then candidate id. Promotion records the exact selected SHA; fresh validation checks the integration SHA against the current target and frozen harness. The coordinator may `terminate { candidate, status: "failed" | "timed-out" | "cancelled", reason, spent, log }`, `stop { reason, spent }`, then `cleanup { workspaces }` after closure. Terminate every dispatched, running or submitted candidate with final cumulative usage and logs before stopping; stop only automatically cancels candidates that never started. Cleanup records host-confirmed release; the host removes workspaces itself.
98
188
 
99
- State lives in `.workflow/`. Every command prints JSON; errors exit 1, bad usage exits 2.
189
+ The CLI supports `exwf init investigation --config investigation.json` and `exwf init experimentation --config experimentation.json`, followed by the same `ceremony`, `next`, `complete`, `status`, `metrics` and persistence commands. Ceremony input files contain the objects above; pass the role with `--by`.
190
+
191
+ ## Persisting state
192
+
193
+ Core performs no I/O. The file adapter is the only part that touches disk, and the CLI is built on it.
194
+
195
+ ```ts
196
+ import { loadState, saveState, withStateLock } from "ex-workflow/adapters";
197
+
198
+ await withStateLock(process.cwd(), async () => {
199
+ const state = await loadState(process.cwd());
200
+ await saveState(process.cwd(), complete(state, m, handoff, accounting).state);
201
+ });
202
+ ```
203
+
204
+ Layout under the project root:
205
+
206
+ ```
207
+ .workflow/
208
+ state.json the whole state (validated on load and before every write)
209
+ briefs/<id>.json written by `next`
210
+ handoffs/<id>-<n>.json written by `complete`
211
+ state.lock one writer at a time
212
+ ```
213
+
214
+ The lock is created exclusively, retried for about two seconds and taken over when older than 60 s. Read-only commands do not lock. If a crashed process left a lock behind and a command reports that another `exwf` holds it, delete the file.
215
+
216
+ ## CLI reference (`exwf`)
217
+
218
+ Run from the directory that holds `.workflow/`. Every command prints JSON on stdout. Exit 0 = ok, exit 1 = `{ ok: false, error }`, exit 2 = usage. `--by` defaults to `human`. Flags take `--flag value` (not `--flag=value`); a value that starts with `--` must come through a JSON input file.
100
219
 
101
220
  | Command | Returns |
102
221
  |---|---|
103
- | `init <scrum\|kanban\|waterfall> --config <file> [--roles <file>]` | `{ ok, state: { methodology, stages, roles } }` |
104
- | `add <item.json>` | `{ ok, warnings, item }` (checked by the methodology rules) |
105
- | `edit <id> <patch.json>` | `{ ok, warnings, item }` (checked by the methodology rules) |
106
- | `next [--max n] [--fallback-tokens-per-weight n]` | `{ ok, reason, skipped, briefs }`; writes `.workflow/briefs/<id>.json`. `--fallback-tokens-per-weight` prices a candidate when there is no accounting history (default 20000 per weight unit, or `ScrumConfig.fallbackTokensPerWeight`) |
107
- | `complete <id> <handoff.json> --tokens-in n --tokens-out n --duration-ms n --model m [--role r] [--estimate]` | `{ ok, item, warnings }`. Zero tokens is refused unless `--estimate` marks the line as a placeholder; correct it later with `account` |
108
- | `account <item> [--line n] [--tokens-in n] [--tokens-out n] [--duration-ms n] [--model m] [--by who]` | `{ ok, line, event }`: rewrites one accounting line of an item (the last by default), adjusts the owning sprint or phase, clears the placeholder flag and records `accounting.corrected` |
222
+ | `init <scrum\|kanban\|waterfall\|investigation\|experimentation> --config <file> [--roles <file>]` | `{ ok, state: { methodology, stages, roles } }` |
223
+ | `add <item.json> [--by who]` | `{ ok, warnings, item }`, checked by the methodology rules |
224
+ | `edit <id> <patch.json> [--by who]` | `{ ok, warnings, item }` |
225
+ | `next [--max n] [--fallback-tokens-per-weight n]` | `{ ok, reason, skipped, briefs }`; writes `.workflow/briefs/<id>.json`. `--max` caps the briefs returned; the fallback prices a candidate with no accounting history (default 20000 tokens per weight unit) |
226
+ | `complete <id> <handoff.json> --tokens-in n --tokens-out n --duration-ms n --model m [--role r] [--estimate]` | `{ ok, item, warnings }`. Zero tokens is refused unless `--estimate` marks the line as a placeholder |
227
+ | `account <item> [--line n] [--tokens-in n] [--tokens-out n] [--duration-ms n] [--model m] [--by who]` | `{ ok, line, event }`: corrects one accounting line (the last by default) and clears the placeholder flag |
109
228
  | `ceremony <name> [input.json] [--by who]` | `{ ok, warnings, lastEvent }` |
110
- | `decide <pendingId> approve\|reject --by who [--note text]` | `{ ok, item }` (runs the methodology's `afterDecide`, e.g. a Waterfall phase baseline) |
111
- | `config set <patch.json> [--by who]` | `{ ok, warnings, changed, config }`: merges a patch into the methodology config between iterations (refused while an iteration is open, and for locked keys); the merge is shallow: top-level keys replace wholesale, so `{ "sprintBudget": { "tokens": N } }` drops `turns`/`wallclockMs` |
112
- | `unblock <item> [--blocker id] [--note text] [--by who]` | `{ ok, warnings, item }`: clears the named open blocker, or every open one |
113
- | `status` | `{ ok, methodology, openIteration, counts, pending, openQuestions, lastEvent, report }` (`openQuestions` lists the questions a `done` completion left open; `report` is the methodology's own status: Scrum's closing sprint, Kanban's cadences due, Waterfall's phases, pending gates and traceability coverage) |
229
+ | `decide <pendingId> approve\|reject [--by who] [--note text]` | `{ ok, item }`; runs the methodology's after-decide hook (a Waterfall gate approval baselines the phase) |
230
+ | `config set <patch.json> [--by who]` | `{ ok, warnings, changed, config }`: shallow-merges a patch between iterations; refused while an iteration is open and for locked keys |
231
+ | `unblock <item> [--blocker id] [--note text] [--by who]` | `{ ok, warnings, item }`: clears one open blocker, or all |
232
+ | `status` | `{ ok, methodology, openIteration, counts, pending, openQuestions, lastEvent, report }`; `report` is methodology-specific (Scrum: closing sprint; Kanban: cadences due; Waterfall: phases, pending gates, coverage) |
114
233
  | `board` | `{ ok, columns }` |
115
- | `metrics` | `{ ok, metrics }` (Scrum adds `current`, the open sprint's spent, committed and done weight, cost per point and budget utilisation; zeros when no sprint is open) |
234
+ | `metrics` | `{ ok, metrics }` |
116
235
  | `pending` / `lessons` | the arrays |
117
- | `validate <action.json>` | `{ ok: true, violations }` |
236
+ | `validate <action.json>` | `{ ok: true, violations }`, a dry run of the rules |
118
237
  | `role add <manifest.json>` / `role list` | `{ ok, roles }` |
119
238
 
120
- `--by` defaults to `human`.
239
+ ## Configuration
121
240
 
122
- ### Scrum configuration
241
+ ### Scrum (`ScrumConfig`)
123
242
 
124
- `init scrum --config <file>` takes a `ScrumConfig`. Three keys were added in 0.5.0-stage, all optional:
243
+ | Key | Meaning |
244
+ |---|---|
245
+ | `sprintBudget` | `{ tokens?, turns?, wallclockMs? }`, at least one. `turns` counts one per completion. The planner gates on every dimension set |
246
+ | `productGoal` | the goal every sprint serves |
247
+ | `definitionOfDone` | policies an item must meet to be done, e.g. `{ kind: "evidence", evidenceKind: "test-output" }` |
248
+ | `refinementSharePct`, `allowMidSprintAdd` (`never` \| `po-only` \| `any`), `inProgressWipLimit?` | refinement share, mid-sprint additions, optional WIP cap |
249
+ | `autoClose` (default `true`) | close the sprint when its budget is spent and nothing is in flight; `false` keeps it in `closing` until `review` or `cancel` |
250
+ | `estimateMode` (`per-weight` default, or `per-call`) | how candidates are priced: median tokens per weight unit, or median tokens per completion (for hosts that bill one total per call) |
251
+ | `fallbackTokensPerWeight` (default 20000) | pricing when there is no history |
125
252
 
126
- - `autoClose` (default `true`): close the sprint automatically when its budget is spent and nothing is in flight. `false` leaves an exhausted sprint in `closing` until `ceremony review` or `ceremony cancel` closes it, so the human gate is never skipped.
127
- - `estimateMode` (`"per-weight"` by default, or `"per-call"`): how the planner and `plan auto` price a candidate. `per-weight` uses the median tokens per weight unit from history. `per-call` uses the median tokens per completion regardless of weight, which fits a host that bills one all-inclusive total per worker call.
128
- - `fallbackTokensPerWeight` (default 20000): tokens per weight unit when there is no history.
253
+ ### Kanban (`KanbanConfig`)
129
254
 
130
- The planner gates on every budget dimension. `sprintBudget.turns` counts one per completion, so a host with a calls budget sets `turns` and `estimateMode: "per-call"` rather than a `calls` key.
255
+ | Key | Meaning |
256
+ |---|---|
257
+ | `columns` | ordered columns with `wipLimit`, `commitmentPoint` and entry/exit `policies`; the default board is options, ready (commit, WIP 4), dev (WIP 3), review (WIP 2), done |
258
+ | `classesOfService` | per class (`expedite`, `fixed-date`, `standard`, `intangible`): `sle: { percentile, targetMs }` and `wipBypass` |
259
+ | `fairness` | `{ aging, maxDeferralRounds }` anti-starvation |
260
+ | `cadences` | `{ <cadence>: { everyTurns } }`; `exwf status` reports which are due |
261
+ | `throughputWindowMs`, `maxExpedite` | metrics window, cap on simultaneous expedites |
131
262
 
132
- ### Scrum retrospective
263
+ ### Waterfall (`WaterfallConfig`)
133
264
 
134
- `ceremony retro <input.json>` runs between sprints. Its input:
265
+ | Key | Meaning |
266
+ |---|---|
267
+ | `phases` | ordered phases with deliverables, delivering role and gate; the default is the six classic phases |
268
+ | `humanGates` | `"all"` (default) or the phase ids whose gate needs a human |
269
+ | `changeControl` | `{ requiresImpactAnalysis, approvers }`; with impact analysis required, a change-request without one is refused at `add` |
270
+ | `traceability` | `{ from, to[] }` phase ids: every item of `from` must trace to an item of each `to` phase before that gate |
271
+ | `fallbackTokensPerWeight` | as in Scrum |
135
272
 
136
- - `lessons[]`: `{ text, scope, from?, item?, suggestedChange? }`. `from` is `"human"` or a role id (default: the `--by` who); `item` must name an existing item.
137
- - `adopt[]` / `dismiss[]`: raised lessons, by id, each once.
138
- - `retire: string[]`: agreement texts to remove, matched by exact text (never by index). An agreement that is not current fails `invalid-input` and lists the current ones.
139
- - `suggestedChange` (on a lesson or an adopt entry): `{ kind: "agreement", text, replaces? }` adds a working agreement, and `replaces` retires the earlier agreement with that exact text; `{ kind: "dod", policy }` appends one Definition of Done policy; `{ kind: "backlog", item }` queues work; `{ kind: "skill", note }` is for the host.
140
- - `dodChanges: Policy[]` replaces the whole Definition of Done. Dropping a current policy is refused by `dod-not-weakened` unless the retro input also sets `allowWeaken: true`.
273
+ Every config is validated at `init` (`config-invalid` names the key and an example value).
141
274
 
142
- `ceremony refine` takes `reestimate: string[]`: confirm the weight of backlog items (each gets `item.reestimated`) without changing them. An item carried over from `review` re-enters at review and is not re-estimated.
275
+ ## Ceremonies
143
276
 
144
- ### Concurrency
277
+ `ceremony <name> [input.json] --by <role>`; the caller needs the ceremony's capability.
145
278
 
146
- One writer at a time per `.workflow/`: `exwf` serialises writers with `.workflow/state.lock` (created exclusively, retried for about two seconds, taken over when older than 60 s). If a crashed process left the lock behind and a command reports that another `exwf` holds it, delete the file. Read-only commands do not lock. Use `withStateLock` from `ex-workflow/adapters` when you write state yourself.
279
+ **Scrum**
280
+ - `refine { reestimate?: string[] }` confirms backlog weights.
281
+ - `plan { goal, items: string[] | "auto" }` commits a sprint; `auto` fills the budget from priority and history.
282
+ - `commit { items }` / `uncommit { items }` adjust the sprint (a closing sprint can only shrink).
283
+ - `daily` reports progress; `review { accepted, goalMet }` closes the sprint; `cancel` abandons it.
284
+ - `retro { lessons?, adopt?, dismiss?, retire?, dodChanges?, allowWeaken? }`. A lesson is `{ text, scope, from?, item?, suggestedChange? }`; `suggestedChange` may add an `agreement` (optionally `replaces` an earlier one), append a `dod` policy, queue `backlog` work, or leave a `skill` note for the host. `retire` removes agreements by exact text. Dropping a Definition of Done policy is refused unless `allowWeaken: true`.
147
285
 
148
- ### Schema
286
+ **Kanban**
287
+ - `replenishment { items }` moves options to the commitment column (the only push on the board).
288
+ - `delivery-planning { items }` (non-empty) plans the release of done cards.
289
+ - `service-delivery-review { wip?, policies?, sle?, lessons?, adopt?, dismiss?, retire? }` tunes the board; lessons follow the Scrum retro semantics.
290
+ - `operations-review { assign?: [{ item, blocker, owner }] }` reviews blockers and aging WIP.
291
+ - `risk-review { staleAfterMs? }` reports fixed-date risk, stale blockers and active expedites.
292
+ - `strategy-review { classesOfService?, maxExpedite? }` changes classes of service.
149
293
 
150
- `ex-workflow/schema` exports JSON Schema (draft-07) documents generated from the TypeScript types — `workflowStateSchema`, `roleSchema`, `newItemSchema`, `itemPatchSchema`, `handoffSchema`, `scrumConfigSchema`, `kanbanConfigSchema`, `waterfallConfigSchema` — and a small validator with no runtime dependencies:
294
+ **Waterfall**
295
+ - `kickoff { phase }` opens the next phase.
296
+ - `gateReview { phase }` checks deliverables and traceability, then raises a pending gate decision; `decide … approve` baselines the phase.
297
+ - `changeControlBoard { change, decision, note? }` approves or rejects a change-request; an approval reopens the phases its impact analysis names.
298
+ - `phaseRetrospective { lessons?, adopt?, dismiss?, retire? }`; `adopt` entries are `[{ id }]`. Only `agreement` suggestions apply (baselines and config are locked); others are stored for the host.
151
299
 
152
- ```ts
153
- import { assertValid, validate, workflowStateSchema } from "ex-workflow/schema";
300
+ ## Items, briefs, handoffs, accounting
154
301
 
155
- const errors = validate(workflowStateSchema, JSON.parse(raw)); // SchemaError[] with JSON-pointer paths
156
- assertValid(workflowStateSchema, JSON.parse(raw), ".workflow/state.json"); // throws WorkflowError("invalid-input")
157
- ```
302
+ **Item** (`NewItem`): `id`, `title`, `acceptance[]`, and optionally `type` (`epic`, `story`, `task`, `bug`, `change-request`, `deliverable`, `question`), `description`, `dependsOn[]`, `priority`, `weight`, `deadline`, `classOfService`, `role`, `traces[]`, `tags[]`, `phase` (Waterfall), and for bugs and change-requests `affects[]` and `impactAnalysis`. Status moves through `todo`, `in_progress`, `blocked`, `review`, `awaiting_human`, `done` or `dropped`.
158
303
 
159
- `exwf` validates `state.json`, role manifests, item files, `exwf edit` patches, `--roles` files and handoff files with these schemas before acting on them, and `saveState` validates a state before writing it, so the CLI cannot write a file the loader would refuse. The documents are standard JSON Schema, so editors and ajv read them too. They are regenerated with `pnpm schema:gen`; `pnpm schema:check` (in `ci` and the pre-commit hook) fails when they drift from the types.
160
-
161
- ## Layers
304
+ **Brief** (what `next` gives your agent):
162
305
 
306
+ ```ts
307
+ { item, role, modelTier, invariants, do_not, acceptance,
308
+ upstream, // results of the items this one depends on
309
+ priorHandoffs, // earlier attempts at this item (rework feedback)
310
+ relatedBugs, budgetRemaining, gateAhead }
163
311
  ```
164
- L3 MCP server (planned) daemon, hook enforcement, dashboard, team mode
165
- L2 agent adapters Claude Code agents/*.md, future Cursor/Codex formats (planned)
166
- L1 skills SKILL.md + scripts/wf.js (bundled L0) (planned)
167
- L0 ex-workflow this spec: state, policy, planner, accounting (npm, free)
312
+
313
+ **Handoff** (what your agent gives back):
314
+
315
+ ```ts
316
+ { item, role,
317
+ produced: [{ kind, ref }], // evidence; policies match on `kind`
318
+ notes, do_not: string[], open_questions: string[],
319
+ verdict?: "done" | "blocked" | "needs-review" | "rework" | "escalate",
320
+ follow_ups?: NewItem[], // new work; lands in the first stage, never in the iteration
321
+ lessons?: [{ text, scope }] }
168
322
  ```
169
323
 
170
- This package is L0. All layers read and write the same `.workflow/` files.
324
+ `escalate` creates a question item for a role that can answer it, and the original item is re-briefed with the decision as upstream. `blocked` raises a blocker that `unblock` clears. An item whose `done` handoff still has `open_questions` is reported under `status.openQuestions`.
171
325
 
172
- ## Status
326
+ **Accounting**: `{ item, role, model, tokensIn, tokensOut, durationMs, startedAt, endedAt, estimate? }`. The planner uses accounting history to price future candidates against the budget, so record real figures; `--estimate` plus `account` is the path when the host reports them late.
173
327
 
174
- 1.0.0 (2026-10-24) closes the Phase 7 engine gaps (#23-#27) and freezes the public API (exports, CLI commands, schema documents, event kinds — test/api-surface.json) with a compatibility test over state files from every stage release; from here versioning is semver and `latest` is the supported line. 0.6.0-stage closed the Phase 6 backlog: every item the 1.0 definition named is either fixed or an accepted limitation (see [Accepted limitations](#accepted-limitations)). 0.5.0-stage closes the engine gaps from the workflowAI dogfood (Scrum budget gates, configuration between iterations, accounting corrections, agreements that can be replaced or retired, question briefs with their parent); see [CHANGELOG.md](CHANGELOG.md). 0.4.0-stage added `ex-workflow/schema` (JSON Schema documents and a validator, checked by `exwf` on load and on input). 0.3.0-stage added the Waterfall module; all three methodologies ship. Design: [docs/superpowers/specs/2026-10-19-ex-workflow-design.md](docs/superpowers/specs/2026-10-19-ex-workflow-design.md).
328
+ ## Errors
175
329
 
176
- ## Accepted limitations
330
+ Every failure is a `WorkflowError` (CLI: exit 1) with the same shape:
177
331
 
178
- The 1.0 definition requires every known gap to be fixed or accepted as a documented limitation. These are the accepted ones (design spec, section 22). Each has one line of reasoning.
332
+ ```json
333
+ { "ok": false, "error": { "code": "policy-unmet", "message": "…", "fix": "…", "items": ["CART"], "rule": "dod" } }
334
+ ```
179
335
 
180
- - Stale-lock takeover (B01): the re-stat narrows the race to the gap between the stat and the `unlink`, which no portable call closes; `ino` may be 0 (FAT/exFAT, some shares), in which case only the mtime is compared.
181
- - Conflict of interest (B02): `"conflict-of-interest"` stays a declared, reserved `ErrorCode` that is never thrown, and the core rule matching action type `complete` stays dormant; `checkGate` already refuses the case as `gate-unmet`, and removing the code would narrow a public type.
182
- - Blockers (B03): a blocker is owned by a human, and clearing it would need a link from the follow-up that the schema does not carry; `exwf unblock` is the path.
183
- - Scrum stage ids (B06): `backlog`, `sprint` and `review` are owned by the module (about twenty uses); init refuses a config that lacks them.
184
- - Uncommit while closing (B07): `ceremony uncommit` stays allowed during `closing` because it only shrinks the sprint.
185
- - Roles on load (B09): state wins on an id conflict, `exwf role add` is the audited path, and re-merging is idempotent.
186
- - Scrum size row (B11): budgets sit at measured size by the owner's standing decision; the row stays as a tripwire.
187
- - Kanban WIP (B12): the engine must not refuse a card it advanced itself; operations-review surfaces queued cards.
188
- - Kanban `wipBypass` (B13): it is a column total; re-scoping the key after 1.0 would break configs.
189
- - Kanban cadences (B14): the key is `everyTurns` because the engine has no clock; wall-clock schedules are the host's job.
190
- - Waterfall traceability (B16): it is keyed by phase ids because the core item union has no requirement, design or test types; phase membership classifies items.
191
- - Direct primitives (B17): `editItem` and `addItem` bypass `baseline-immutable` by design; `applyAction` and the CLI enforce it.
192
- - Phase budgets (B18): a phase budget reuses `Iteration` and `status` shows `openIteration`; the naming is accepted, and `fallbackTokensPerWeight` covers the no-history case.
193
- - Phase retrospective (B19): baselines and config are locked in Waterfall, so only `agreement` lessons apply; `dod` and `backlog` suggestions are stored for the host.
194
- - Accounting outside sprints (B23): a line whose `endedAt` lies outside every sprint window has no sprint to charge.
195
- - Waterfall deliverables (B10): `deliverables-present` aggregates raw item evidence while stage gates use fresh evidence; the two diverge only when one config uses both.
196
- - Rework in flight (B10): an item reworked mid-flight in a state written before 0.6.0-stage needs fresh evidence before it can pass.
197
- - Flag values (B24): CLI flags take `--flag value` only; a value beginning with `--` must come via a JSON input file; `--flag=value` is not supported.
198
- - Stale lock unlink: `withStateLock` retries without reaching the retry cap when a stale lock's unlink keeps failing (EPERM, read-only directory); delete the file by hand.
199
- - Scrum `status.report.reason`: it is always `budget`; the engine has no other closing cause yet.
200
- - Carryover in an unflagged stage (B22): a carryover that was `blocked` or `awaiting_human` in a stage without `review: true` restarts at the sprint start and needs a reestimate; only a stage flagged `review`, or an item still at status `review`, resumes where it was. Flag the stage `review: true` to resume there.
336
+ Codes: `unknown-item`, `duplicate-item`, `unknown-role`, `duplicate-role`, `unknown-stage`, `missing-capability`, `exclusive-capability`, `role-has-open-items`, `invalid-transition`, `policy-unmet`, `gate-unmet`, `handoff-invalid`, `accounting-invalid`, `rule-violation`, `planner-error`, `no-op`, `unknown-pending`, `unknown-ceremony`, `state-version`, `config-invalid`, `budget-exhausted`, `invalid-input`. `fix` always says what to change; act on it rather than on the state.
201
337
 
202
- ## Development gate
338
+ ## JSON Schema
203
339
 
204
- There is no hosted CI. A husky pre-commit hook runs the local gate on every commit
205
- (`pnpm format:check && pnpm lint && pnpm typecheck && pnpm schema:check && pnpm test`); `pnpm run ci` adds the
206
- minified build, the dist identity check and the size ratchet, and `prepublishOnly` runs it
207
- before any publish. oxfmt and oxlint need Node ^20.19 or >=22.12 on the developer machine; the
208
- package itself supports Node >=18 (verified on ubuntu, macOS and Windows x Node 18/20/22
209
- before the hosted workflow was removed). `pnpm test` includes the compatibility fixtures (`test/fixtures/compat`, `state.json` files written by the published 0.1.0, 0.2.0, 0.3.0, 0.4.0 and 0.6.0 stage releases; 0.5.0-stage was never published); `node scripts/gen-compat-fixtures.mjs` regenerates them (network needed). Schema drift is guarded by `pnpm schema:check` alone, not by a test, because the generator needs Node >=22 and the test suite must run on >=18.
340
+ `ex-workflow/schema` exports draft-07 documents generated from the TypeScript types, plus a dependency-free validator:
210
341
 
211
- ## Publishing
342
+ `workflowStateSchema`, `roleSchema`, `newItemSchema`, `itemPatchSchema`, `handoffSchema`, `scrumConfigSchema`, `kanbanConfigSchema`, `waterfallConfigSchema`, `investigationConfigSchema`, `experimentationConfigSchema`
212
343
 
213
- For the owner. A release moves `latest`:
344
+ ```ts
345
+ import { assertValid, validate, handoffSchema } from "ex-workflow/schema";
214
346
 
215
- ```sh
216
- pnpm run ci && npm publish
347
+ const errors = validate(handoffSchema, JSON.parse(raw)); // SchemaError[] with JSON-pointer paths
348
+ assertValid(handoffSchema, JSON.parse(raw), "inbox/CART.json"); // throws WorkflowError("invalid-input")
217
349
  ```
218
350
 
219
- Use `npm publish --tag stage` only for a pre-release.
351
+ The CLI validates state, role manifests, items, patches and handoffs with these documents before acting, and `saveState` validates before writing. They are standard JSON Schema, so editors and ajv read them too.
352
+
353
+ ## Package entry points
220
354
 
221
- ## Design principles
355
+ | Import | Contents |
356
+ |---|---|
357
+ | `ex-workflow` | core: `init`, `addItem`, `editItem`, `next`, `complete`, `decide`, `applyAction`, `validateAction`, `changeConfig`, `correctAccounting`, `clearBlocker`, `raiseBlocker`, `registerRole`, `openQuestions`, `WorkflowError`, `VERSION`, … |
358
+ | `ex-workflow/scrum` | `scrum()`, `scrumMetrics`, `dailyReport`, `closeSprint`, presets |
359
+ | `ex-workflow/kanban` | `kanban()`, `board`, `kanbanMetrics`, `opsReport`, `riskReport`, `cadencesDue`, `DEFAULT_COLUMNS`, presets |
360
+ | `ex-workflow/waterfall` | `waterfall()`, `phaseReport`, `traceabilityMatrix`, `waterfallMetrics`, `baselinePhase`, `reopenPhases`, presets |
361
+ | `ex-workflow/investigation` | `investigation()`, config validation and artifact types |
362
+ | `ex-workflow/experimentation` | `experimentation()`, config validation and artifact types |
363
+ | `ex-workflow/adapters` | `loadState`, `saveState`, `saveBrief`, `saveHandoff`, `withStateLock`, `WORKFLOW_DIR` |
364
+ | `ex-workflow/schema` | the ten schema documents, `validate`, `assertValid` |
365
+ | `ex-workflow/cli` | `runCommand`, `parseArgs`, `USAGE`: the `exwf` command as a library |
366
+ | `ex-workflow/types` | every public type |
367
+
368
+ Each entry ships ESM, CommonJS and `.d.ts`. Core plus one methodology is about 60–68 kB minified.
369
+
370
+ ## Compatibility and versioning
371
+
372
+ - Semver from 1.0.0. The public surface (exports of every entry point, the CLI commands, the ten schema documents, the event kinds) is frozen by test: a removal is a major version, an addition a minor one.
373
+ - A `.workflow/state.json` written by any earlier release loads unchanged; the test suite replays state files from every published pre-release.
374
+ - Behaviour changes are listed per release in [CHANGELOG.md](CHANGELOG.md).
375
+
376
+ ## Known limitations
377
+
378
+ Deliberate, documented, and stable within 1.x.
379
+
380
+ - **Stale lock takeover** narrows the race to the gap between the stat and the unlink; no portable call closes it. On file systems without inodes (FAT, exFAT, some shares) only the mtime is compared. If a stale lock cannot be unlinked (read-only directory, EPERM), delete it by hand.
381
+ - **Blockers are owned by a human.** Finishing a follow-up does not clear its blocker; `unblock` does.
382
+ - **Direct primitives bypass the baseline.** `addItem` and `editItem` called directly do not check `baseline-immutable`; `applyAction` and the CLI do.
383
+ - **Kanban cadences count turns, not time.** The engine has no clock; wall-clock schedules are the host's job. `wipBypass` is a column total.
384
+ - **Kanban WIP is not enforced against the engine's own moves**; a column the engine over-fills by advancing a card is surfaced by `operations-review`.
385
+ - **Waterfall traceability is keyed by phase**, not by item type: phase membership says what counts as a requirement, design or test item.
386
+ - **Waterfall retrospectives apply only `agreement` lessons**; `dod` and `backlog` suggestions are stored for the host because baselines and config are locked.
387
+ - **Scrum stage ids** `backlog`, `sprint` and `review` are fixed; `init` refuses a config without them. `status.report.reason` is always `budget`.
388
+ - **Carryover**: an item that was `blocked` or `awaiting_human` in a stage not flagged `review: true` restarts at the sprint start and needs a re-estimate; flag the stage `review: true` to resume there.
389
+ - **Accounting outside a sprint** (a line whose `endedAt` lies in no sprint window) is kept but charged to no sprint.
390
+ - **Reworked items need fresh evidence**: policies and gates count only evidence recorded after the last rework.
391
+ - **CLI flags** take `--flag value` only; `--estimate` is the sole boolean flag.
392
+
393
+ ## Contributing
394
+
395
+ ```sh
396
+ pnpm install
397
+ pnpm test # unit, e2e scenarios per methodology, compatibility fixtures, API-surface freeze
398
+ pnpm run ci # format, lint, typecheck, schema drift, tests, minified build, dist checks, size ratchet
399
+ ```
222
400
 
223
- 1. One engine, three methodologies, modelled as completely as the canonical texts describe them (Scrum Guide 2020; the Kanban Method's six practices, cadences, classes of service and flow metrics; classic phase-gate Waterfall with change control and traceability).
224
- 2. The program decides, the LLM executes. Which item may move, who may approve, whether a stage may start: engine, not prompt.
225
- 3. Roles are data. Methodologies reference capabilities, never role names.
226
- 4. Pure, serialisable state. Every operation is `(state, action) -> state` or `(state) -> view`. No I/O in core.
227
- 5. Zero runtime dependencies beyond `ex-flow` and `exsorted` (both MIT, both the owner's). Runs on Node on macOS, Linux and Windows.
228
- 6. Errors resolve: every violation names the exact rule, the exact item, and a concrete fix.
401
+ The design, including every decision log since the first release, lives in [docs/superpowers/specs/2026-10-19-ex-workflow-design.md](docs/superpowers/specs/2026-10-19-ex-workflow-design.md). The end-to-end scenarios (`test/sprint.e2e.test.ts`, `test/kanban.e2e.test.ts`, `test/waterfall.e2e.test.ts`) are the best long-form examples: rework, blockers, escalations, retros, change-requests and metrics in one run each. Issues and pull requests: [github.com/Ink01101011/ex-workflow](https://github.com/Ink01101011/ex-workflow).
229
402
 
230
403
  ## License
231
404
 
232
- MIT
405
+ [MIT](LICENSE)
@@ -1,2 +1,2 @@
1
- 'use strict';var chunkYRATJT7P_cjs=require('../chunk-YRATJT7P.cjs');require('../chunk-WOGK54HB.cjs'),require('../chunk-S3BXVHO7.cjs');Object.defineProperty(exports,"WORKFLOW_DIR",{enumerable:true,get:function(){return chunkYRATJT7P_cjs.a}});Object.defineProperty(exports,"loadState",{enumerable:true,get:function(){return chunkYRATJT7P_cjs.e}});Object.defineProperty(exports,"saveBrief",{enumerable:true,get:function(){return chunkYRATJT7P_cjs.f}});Object.defineProperty(exports,"saveHandoff",{enumerable:true,get:function(){return chunkYRATJT7P_cjs.g}});Object.defineProperty(exports,"saveState",{enumerable:true,get:function(){return chunkYRATJT7P_cjs.d}});Object.defineProperty(exports,"statePath",{enumerable:true,get:function(){return chunkYRATJT7P_cjs.b}});Object.defineProperty(exports,"withStateLock",{enumerable:true,get:function(){return chunkYRATJT7P_cjs.c}});//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var chunkU23FUYPD_cjs=require('../chunk-U23FUYPD.cjs');require('../chunk-C2IYMWE6.cjs'),require('../chunk-S3BXVHO7.cjs');Object.defineProperty(exports,"WORKFLOW_DIR",{enumerable:true,get:function(){return chunkU23FUYPD_cjs.a}});Object.defineProperty(exports,"loadState",{enumerable:true,get:function(){return chunkU23FUYPD_cjs.e}});Object.defineProperty(exports,"saveBrief",{enumerable:true,get:function(){return chunkU23FUYPD_cjs.f}});Object.defineProperty(exports,"saveHandoff",{enumerable:true,get:function(){return chunkU23FUYPD_cjs.g}});Object.defineProperty(exports,"saveState",{enumerable:true,get:function(){return chunkU23FUYPD_cjs.d}});Object.defineProperty(exports,"statePath",{enumerable:true,get:function(){return chunkU23FUYPD_cjs.b}});Object.defineProperty(exports,"withStateLock",{enumerable:true,get:function(){return chunkU23FUYPD_cjs.c}});//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import { WorkflowState, Brief, Handoff } from '../types.cjs';
1
+ import { W as WorkflowState, B as Brief, H as Handoff } from '../types-BScHXlRx.cjs';
2
2
 
3
3
  declare const WORKFLOW_DIR = ".workflow";
4
4
  declare function statePath(root: string): string;