ex-workflow 0.6.0-stage → 1.0.1

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 (70) hide show
  1. package/CHANGELOG.md +25 -2
  2. package/README.md +255 -135
  3. package/dist/chunk-3KFQPSRX.mjs +2 -0
  4. package/dist/chunk-3KFQPSRX.mjs.map +1 -0
  5. package/dist/{chunk-MH66G5KV.cjs → chunk-5PHK72VM.cjs} +2 -2
  6. package/dist/{chunk-MH66G5KV.cjs.map → chunk-5PHK72VM.cjs.map} +1 -1
  7. package/dist/chunk-CYXVGHQM.cjs +2 -0
  8. package/dist/chunk-CYXVGHQM.cjs.map +1 -0
  9. package/dist/chunk-FKTCGQYB.cjs +2 -0
  10. package/dist/chunk-FKTCGQYB.cjs.map +1 -0
  11. package/dist/chunk-HIHMBMB5.cjs +2 -0
  12. package/dist/chunk-HIHMBMB5.cjs.map +1 -0
  13. package/dist/{chunk-KF5VQH3M.mjs → chunk-MQWMQ4PD.mjs} +2 -2
  14. package/dist/{chunk-KF5VQH3M.mjs.map → chunk-MQWMQ4PD.mjs.map} +1 -1
  15. package/dist/chunk-QDMEM62U.mjs +2 -0
  16. package/dist/chunk-QDMEM62U.mjs.map +1 -0
  17. package/dist/chunk-U3OXAO67.mjs +2 -0
  18. package/dist/chunk-U3OXAO67.mjs.map +1 -0
  19. package/dist/chunk-UZQV73X7.mjs +2 -0
  20. package/dist/chunk-UZQV73X7.mjs.map +1 -0
  21. package/dist/chunk-VXH2FAKV.cjs +2 -0
  22. package/dist/chunk-VXH2FAKV.cjs.map +1 -0
  23. package/dist/chunk-XMO2RCXB.cjs +2 -0
  24. package/dist/chunk-XMO2RCXB.cjs.map +1 -0
  25. package/dist/chunk-YBHHICTZ.mjs +2 -0
  26. package/dist/chunk-YBHHICTZ.mjs.map +1 -0
  27. package/dist/{chunk-3CLDZCHN.cjs → chunk-YJN4JEJU.cjs} +2 -2
  28. package/dist/{chunk-3CLDZCHN.cjs.map → chunk-YJN4JEJU.cjs.map} +1 -1
  29. package/dist/chunk-Z2G7DGDF.mjs +2 -0
  30. package/dist/{chunk-TEPK5Y36.mjs.map → chunk-Z2G7DGDF.mjs.map} +1 -1
  31. package/dist/cli/bin.cjs +1 -1
  32. package/dist/cli/bin.mjs +1 -1
  33. package/dist/cli/index.cjs +1 -1
  34. package/dist/cli/index.mjs +1 -1
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.cjs.map +1 -1
  37. package/dist/index.d.cts +1 -1
  38. package/dist/index.d.ts +1 -1
  39. package/dist/index.mjs +1 -1
  40. package/dist/index.mjs.map +1 -1
  41. package/dist/kanban/index.cjs +1 -1
  42. package/dist/kanban/index.mjs +1 -1
  43. package/dist/scrum/index.cjs +1 -1
  44. package/dist/scrum/index.mjs +1 -1
  45. package/dist/waterfall/index.cjs +1 -1
  46. package/dist/waterfall/index.d.cts +2 -1
  47. package/dist/waterfall/index.d.ts +2 -1
  48. package/dist/waterfall/index.mjs +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-2OVYXXNV.cjs +0 -2
  51. package/dist/chunk-2OVYXXNV.cjs.map +0 -1
  52. package/dist/chunk-7CDGPTEJ.mjs +0 -2
  53. package/dist/chunk-7CDGPTEJ.mjs.map +0 -1
  54. package/dist/chunk-GT57PLUT.mjs +0 -2
  55. package/dist/chunk-GT57PLUT.mjs.map +0 -1
  56. package/dist/chunk-IHE5K4X3.mjs +0 -2
  57. package/dist/chunk-IHE5K4X3.mjs.map +0 -1
  58. package/dist/chunk-N3QB2S7R.cjs +0 -2
  59. package/dist/chunk-N3QB2S7R.cjs.map +0 -1
  60. package/dist/chunk-NA53TZE4.mjs +0 -2
  61. package/dist/chunk-NA53TZE4.mjs.map +0 -1
  62. package/dist/chunk-TEPK5Y36.mjs +0 -2
  63. package/dist/chunk-UBFIKDIP.cjs +0 -2
  64. package/dist/chunk-UBFIKDIP.cjs.map +0 -1
  65. package/dist/chunk-UUOMQMWT.cjs +0 -2
  66. package/dist/chunk-UUOMQMWT.cjs.map +0 -1
  67. package/dist/chunk-Z3PU6EBI.mjs +0 -2
  68. package/dist/chunk-Z3PU6EBI.mjs.map +0 -1
  69. package/dist/chunk-ZTE7LREB.cjs +0 -2
  70. package/dist/chunk-ZTE7LREB.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,29 @@
1
1
  # Changelog
2
2
 
3
- ## 0.6.0-stage (unreleased)
3
+ ## 1.0.1 (2026-10-24)
4
+
5
+ Documentation release; no code, schema, CLI or `state.json` change.
6
+
7
+ - 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.
8
+ - 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.
9
+ - `VERSION` is `"1.0.1"`.
10
+
11
+ ## 1.0.0 (2026-10-24)
12
+
13
+ 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.
14
+
15
+ - Trace and reopen ids (#23): a Waterfall `item.add` or `item.edit` is refused (`rule-violation`) when a `traces` id does not name an existing, non-dropped item, or when a change-request's `impactAnalysis.reopen` names a phase that is not configured; the fix lists the ids or phases that are valid.
16
+ - Impact analysis at add (#24): with `changeControl.requiresImpactAnalysis: true`, a change-request without an impact analysis is refused at `item.add` and `item.edit`, and a present one is shape-checked (`summary`, `reopen`, `weight`).
17
+ - Coverage recount (#25): the traceability matrix no longer counts change-requests; `waterfallMetrics.requirementsTraced`, `requirementsTotal` and `requirementCoverage` are computed from the same matrix as `status.report.coverage`, so the two agree.
18
+ - `readyForGate` (#26): `readyForGate` is true as soon as the gate would pass; `PhaseReportRow` gains `missingTraces`, and the generated `traceability-matrix` counts as present for the last traced phase when nothing is missing.
19
+ - Kanban lessons (#27): `service-delivery-review` takes `lessons`, `adopt`, `dismiss` and `retire` with the Scrum retro semantics for agreements; the `cadence.service-delivery-review` payload gains five arrays (`lessons`, `adopted`, `dismissed`, `agreements`, `retired`).
20
+ - Shared lesson helper: the Scrum `retro`, the Waterfall `phaseRetrospective` and the Kanban review share one core helper (`src/lessons.ts`), so a malformed `lessons[]` or `adopt[]` entry on the Scrum retro is refused `invalid-input` (`retro.lessons entries need a text and a scope`) where it was silently accepted before; valid inputs, payloads and messages are unchanged.
21
+ - Compatibility test: `test/compat.test.ts` loads `state.json` fixtures written by the published 0.1.0, 0.2.0, 0.3.0, 0.4.0 and 0.6.0 stage releases (`test/fixtures/compat`, regenerated by `scripts/gen-compat-fixtures.mjs`) and runs `status`, `metrics` and `next` on each; 0.5.0-stage was never published.
22
+ - API-surface freeze: `test/api-surface.test.ts` compares the runtime exports of the five entry points, the CLI `USAGE` lines (10), the schema documents (8) and the event kinds (52) with `test/api-surface.json`; a removal is now a major version, an addition a minor one.
23
+
24
+ Migration: from any 0.N.0-stage a `.workflow/state.json` loads unchanged; the compatibility test proves it for every stage release. Coming from an earlier stage, the behaviour changes of 0.5.0 and 0.6.0 listed below apply. New in 1.0.0: a Waterfall `add` or `edit` is refused for an unknown `traces` or `reopen` id and for a change-request without an impact analysis when the config requires one (#23, #24); `status.report.coverage` and `metrics.requirements*` no longer count change-requests and agree with each other (#25); `readyForGate` is true as soon as the gate would pass (#26); Kanban `service-delivery-review` takes lessons (#27); a malformed `lessons[]`, `adopt[]` or `dismiss[]` entry on the Scrum `retro` is refused `invalid-input` (shared helper); `PhaseReportRow.missingTraces` is added and the `cadence.service-delivery-review` payload gains five arrays. No schema document, event kind or `state.json` change. Versioning from here: semver, `latest`.
25
+
26
+ ## 0.6.0-stage (2026-10-24)
4
27
 
5
28
  Pre-release under the `stage` dist-tag. Phase 6 (backlog zero) fixes or explicitly accepts all 24 items the 1.0 definition named; the decisions are in the design spec, section 22, and the accepted limitations are in the README.
6
29
 
@@ -21,7 +44,7 @@ Pre-release under the `stage` dist-tag. Phase 6 (backlog zero) fixes or explicit
21
44
 
22
45
  Compatibility: no `state.json` schema change and no new event kind; every `.workflow/state.json` written by an earlier stage loads unchanged. The generated `WaterfallConfig` schema document gains one optional key, `fallbackTokensPerWeight`. Behaviour changes, all deliberate: rules run on `item.complete` (B02); custom rules on `item.complete` can refuse a completion (`rule-violation`) and their warnings are returned; `decide(approve)` honours `needs-review` (B05); `ceremony commit` is refused into a closing sprint (B07); a freshly reworked item needs fresh evidence before it passes (B10); a blocked or awaiting-human carryover in review resumes at review (B22); `plan auto` applies tokens and turns together (B20); a value-taking flag without a value is refused (B24); Scrum's `status.report` is no longer `null`.
23
46
 
24
- ## 0.5.0-stage (unreleased)
47
+ ## 0.5.0-stage (unreleased; never published, shipped inside 0.6.0-stage)
25
48
 
26
49
  Pre-release under the `stage` dist-tag. Phase 5 closes the engine gaps the workflowAI scrum-master dogfood raised (issues #8–#21); the decisions are in the design spec, section 21.
27
50
 
package/README.md CHANGED
@@ -1,226 +1,346 @@
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 and Waterfall 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. [Persisting state](#persisting-state)
21
+ 8. [CLI reference (`exwf`)](#cli-reference-exwf)
22
+ 9. [Configuration](#configuration)
23
+ 10. [Ceremonies](#ceremonies)
24
+ 11. [Items, briefs, handoffs, accounting](#items-briefs-handoffs-accounting)
25
+ 12. [Errors](#errors)
26
+ 13. [JSON Schema](#json-schema)
27
+ 14. [Package entry points](#package-entry-points)
28
+ 15. [Compatibility and versioning](#compatibility-and-versioning)
29
+ 16. [Known limitations](#known-limitations)
30
+ 17. [Contributing](#contributing)
31
+ 18. [License](#license)
6
32
 
7
33
  ## Install
8
34
 
9
35
  ```sh
10
- pnpm add ex-workflow@stage
36
+ npm install ex-workflow # or: pnpm add ex-workflow
37
+ npx exwf # prints the CLI usage
11
38
  ```
12
39
 
13
- Pre-releases are published under the `stage` dist-tag (currently `0.6.0-stage`); `latest` is reserved for 0.1.0.
40
+ `latest` is the supported line (1.0.1). Pre-releases, when any, are published under the `stage` dist-tag.
41
+
42
+ ## Pick a methodology
43
+
44
+ | | Scrum (`ex-workflow/scrum`) | Kanban (`ex-workflow/kanban`) | Waterfall (`ex-workflow/waterfall`) |
45
+ |---|---|---|---|
46
+ | Fits | a goal delivered in budgeted sprints | a continuous flow of requests | a phase-gated project with a frozen baseline |
47
+ | Unit of control | sprint budget (tokens, turns, wall-clock) | WIP limits per column, classes of service | human-approved gate per phase |
48
+ | Flow | backlog → sprint → review | options → ready → dev → review → done | work → review → done, inside each phase |
49
+ | Preset roles | product-owner, scrum-master, developer | service-request-manager, service-delivery-manager, worker | project-manager, business-analyst, architect, developer, qa, release-manager |
50
+ | 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 |
51
+ | 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 |
52
+
53
+ All three 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`.
54
+
55
+ ## How a run works
56
+
57
+ ```
58
+ addItem ──▶ next() ──▶ Brief per item ──▶ your agent ──▶ Handoff + Accounting ──▶ complete()
59
+ ▲ │
60
+ └──────────── ceremonies, decide(), unblock ─────────────────────────┘
61
+ ```
14
62
 
15
- Node >= 18. Runs on macOS, Linux and Windows.
63
+ 1. **Add items** with acceptance criteria. Rules check them at add time.
64
+ 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.
65
+ 3. **Run each brief** with whatever agent or model you like. The engine never calls an LLM.
66
+ 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.
67
+ 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.
16
68
 
17
- ## Quick start
69
+ ## Quick start: Scrum
18
70
 
19
71
  ```ts
20
72
  import { init, addItem, next, complete } from "ex-workflow";
21
73
  import { scrum } from "ex-workflow/scrum";
22
74
 
23
75
  const m = scrum();
24
- const config = { sprintBudget: { tokens: 300_000 }, productGoal: "ship the checkout", definitionOfDone: [{ kind: "evidence", evidenceKind: "test-output" }] };
76
+ const config = {
77
+ sprintBudget: { tokens: 300_000 },
78
+ productGoal: "ship the checkout",
79
+ definitionOfDone: [{ kind: "evidence", evidenceKind: "test-output" }],
80
+ };
25
81
  let state = init({ methodology: m, config }).state;
26
82
  state = addItem(state, { id: "CART", title: "cart API", weight: 3, priority: 5, acceptance: ["add/remove items"] }, "product-owner");
27
83
  state = m.ceremonies["plan"]!(state, { by: "scrum-master", goal: "customers can pay", items: "auto" }).state;
28
84
 
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:
85
+ const { state: s2, briefs } = next(state, m); // one brief per dispatched item
86
+ // run each brief with your agent, then:
31
87
  // state = complete(s2, m, handoff, accounting).state;
32
88
  // state = m.ceremonies["review"]!(state, { by: "human", accepted: true, goalMet: true }).state;
33
89
  ```
34
90
 
35
- To persist state, use the file adapter (the only part of the package that touches disk):
91
+ 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.
36
92
 
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.
47
-
48
- ### Kanban
93
+ ## Quick start: Kanban
49
94
 
50
95
  ```ts
51
- import { addItem, complete, init, next } from "ex-workflow";
52
- import { board, kanban, kanbanMetrics } from "ex-workflow/kanban";
96
+ import { init, addItem, next, complete } from "ex-workflow";
97
+ import { kanban, board, kanbanMetrics } from "ex-workflow/kanban";
53
98
 
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;
99
+ const m = kanban(); // options → ready (commitment point, WIP 4) → dev (WIP 3) → review (WIP 2) → done
100
+ let state = init({
101
+ methodology: m,
102
+ config: { classesOfService: { standard: { sle: { percentile: 85, targetMs: 7 * 86_400_000 } } } },
103
+ }).state;
56
104
  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
- ```
105
+ state = m.ceremonies["replenishment"]!(state, { by: "service-request-manager", items: ["SEARCH"] }).state; // the only push
63
106
 
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.
107
+ const { state: s2, briefs, skipped } = next(state, m); // pulls ready → dev within WIP; expedite jumps the queue
108
+ board(s2, new Date().toISOString()); // columns, active/queued counts, card ages
109
+ kanbanMetrics(s2); // lead time, cycle time per column, throughput, WIP, flow efficiency, SLE compliance
110
+ ```
65
111
 
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.
112
+ `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.
67
113
 
68
- ### Waterfall
114
+ ## Quick start: Waterfall
69
115
 
70
116
  ```ts
71
117
  import { init, addItem, applyAction, next, complete, decide } from "ex-workflow";
72
118
  import { waterfall } from "ex-workflow/waterfall";
73
119
 
74
- const m = waterfall();
75
- let { state } = init({ methodology: m, config: {} }); // six classic phases, every gate human-approved
120
+ const m = waterfall(); // requirements → design → implementation → verification → deployment → maintenance
121
+ let { state } = init({ methodology: m, config: {} });
76
122
  const r1 = { id: "R1", title: "login", phase: "requirements", acceptance: ["user can log in"] };
77
123
  state = applyAction(state, m, { type: "item.add", by: "business-analyst", payload: { item: r1 } }, (s) =>
78
124
  addItem(s, r1, "business-analyst"),
79
125
  ).state;
80
126
  state = m.ceremonies["kickoff"]!(state, { by: "project-manager", phase: "requirements" }).state;
81
- // next() → complete() as with any methodology; items go work → review → done
82
- state = m.ceremonies["gateReview"]!(state, { by: "project-manager", phase: "requirements" }).state; // pending decision
83
- state = decide(state, state.pending[0]!.id, "approve", "human", "ok", undefined, m); // baselines the phase
127
+ // next() → complete() as usual; items go work → review → done
128
+ state = m.ceremonies["gateReview"]!(state, { by: "project-manager", phase: "requirements" }).state; // raises a pending decision
129
+ state = decide(state, state.pending[0]!.id, "approve", "human", "ok", undefined, m); // baselines the phase
130
+ ```
131
+
132
+ 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`.
133
+
134
+ ## Persisting state
135
+
136
+ Core performs no I/O. The file adapter is the only part that touches disk, and the CLI is built on it.
137
+
138
+ ```ts
139
+ import { loadState, saveState, withStateLock } from "ex-workflow/adapters";
140
+
141
+ await withStateLock(process.cwd(), async () => {
142
+ const state = await loadState(process.cwd());
143
+ await saveState(process.cwd(), complete(state, m, handoff, accounting).state);
144
+ });
145
+ ```
146
+
147
+ Layout under the project root:
148
+
149
+ ```
150
+ .workflow/
151
+ state.json the whole state (validated on load and before every write)
152
+ briefs/<id>.json written by `next`
153
+ handoffs/<id>-<n>.json written by `complete`
154
+ state.lock one writer at a time
84
155
  ```
85
156
 
86
- Phases open one at a time (`kickoff`), close through a gate (`gateReview`, human-approved by default) that
87
- baselines their items, and reopen only through an approved change-request (`changeControlBoard`, with an
88
- impact analysis). Requirements must trace to design and verification items before those gates; the engine
89
- generates the `traceability-matrix` deliverable. Edits to baselined items are refused by the rules when
90
- they go through `applyAction` or the CLI. `test/waterfall.e2e.test.ts` is a full project with a
91
- change-request that reopens two baselined phases.
157
+ 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.
92
158
 
93
- ## CLI
159
+ ## CLI reference (`exwf`)
94
160
 
95
- State lives in `.workflow/`. Every command prints JSON; errors exit 1, bad usage exits 2.
161
+ 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.
96
162
 
97
163
  | Command | Returns |
98
164
  |---|---|
99
165
  | `init <scrum\|kanban\|waterfall> --config <file> [--roles <file>]` | `{ ok, state: { methodology, stages, roles } }` |
100
- | `add <item.json>` | `{ ok, warnings, item }` (checked by the methodology rules) |
101
- | `edit <id> <patch.json>` | `{ ok, warnings, item }` (checked by the methodology rules) |
102
- | `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`) |
103
- | `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` |
104
- | `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` |
166
+ | `add <item.json> [--by who]` | `{ ok, warnings, item }`, checked by the methodology rules |
167
+ | `edit <id> <patch.json> [--by who]` | `{ ok, warnings, item }` |
168
+ | `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) |
169
+ | `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 |
170
+ | `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 |
105
171
  | `ceremony <name> [input.json] [--by who]` | `{ ok, warnings, lastEvent }` |
106
- | `decide <pendingId> approve\|reject --by who [--note text]` | `{ ok, item }` (runs the methodology's `afterDecide`, e.g. a Waterfall phase baseline) |
107
- | `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` |
108
- | `unblock <item> [--blocker id] [--note text] [--by who]` | `{ ok, warnings, item }`: clears the named open blocker, or every open one |
109
- | `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) |
172
+ | `decide <pendingId> approve\|reject [--by who] [--note text]` | `{ ok, item }`; runs the methodology's after-decide hook (a Waterfall gate approval baselines the phase) |
173
+ | `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 |
174
+ | `unblock <item> [--blocker id] [--note text] [--by who]` | `{ ok, warnings, item }`: clears one open blocker, or all |
175
+ | `status` | `{ ok, methodology, openIteration, counts, pending, openQuestions, lastEvent, report }`; `report` is methodology-specific (Scrum: closing sprint; Kanban: cadences due; Waterfall: phases, pending gates, coverage) |
110
176
  | `board` | `{ ok, columns }` |
111
- | `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) |
177
+ | `metrics` | `{ ok, metrics }` |
112
178
  | `pending` / `lessons` | the arrays |
113
- | `validate <action.json>` | `{ ok: true, violations }` |
179
+ | `validate <action.json>` | `{ ok: true, violations }`, a dry run of the rules |
114
180
  | `role add <manifest.json>` / `role list` | `{ ok, roles }` |
115
181
 
116
- `--by` defaults to `human`.
182
+ ## Configuration
117
183
 
118
- ### Scrum configuration
184
+ ### Scrum (`ScrumConfig`)
119
185
 
120
- `init scrum --config <file>` takes a `ScrumConfig`. Three keys were added in 0.5.0-stage, all optional:
186
+ | Key | Meaning |
187
+ |---|---|
188
+ | `sprintBudget` | `{ tokens?, turns?, wallclockMs? }`, at least one. `turns` counts one per completion. The planner gates on every dimension set |
189
+ | `productGoal` | the goal every sprint serves |
190
+ | `definitionOfDone` | policies an item must meet to be done, e.g. `{ kind: "evidence", evidenceKind: "test-output" }` |
191
+ | `refinementSharePct`, `allowMidSprintAdd` (`never` \| `po-only` \| `any`), `inProgressWipLimit?` | refinement share, mid-sprint additions, optional WIP cap |
192
+ | `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` |
193
+ | `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) |
194
+ | `fallbackTokensPerWeight` (default 20000) | pricing when there is no history |
121
195
 
122
- - `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.
123
- - `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.
124
- - `fallbackTokensPerWeight` (default 20000): tokens per weight unit when there is no history.
196
+ ### Kanban (`KanbanConfig`)
125
197
 
126
- 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.
198
+ | Key | Meaning |
199
+ |---|---|
200
+ | `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 |
201
+ | `classesOfService` | per class (`expedite`, `fixed-date`, `standard`, `intangible`): `sle: { percentile, targetMs }` and `wipBypass` |
202
+ | `fairness` | `{ aging, maxDeferralRounds }` anti-starvation |
203
+ | `cadences` | `{ <cadence>: { everyTurns } }`; `exwf status` reports which are due |
204
+ | `throughputWindowMs`, `maxExpedite` | metrics window, cap on simultaneous expedites |
205
+
206
+ ### Waterfall (`WaterfallConfig`)
127
207
 
128
- ### Scrum retrospective
208
+ | Key | Meaning |
209
+ |---|---|
210
+ | `phases` | ordered phases with deliverables, delivering role and gate; the default is the six classic phases |
211
+ | `humanGates` | `"all"` (default) or the phase ids whose gate needs a human |
212
+ | `changeControl` | `{ requiresImpactAnalysis, approvers }`; with impact analysis required, a change-request without one is refused at `add` |
213
+ | `traceability` | `{ from, to[] }` phase ids: every item of `from` must trace to an item of each `to` phase before that gate |
214
+ | `fallbackTokensPerWeight` | as in Scrum |
129
215
 
130
- `ceremony retro <input.json>` runs between sprints. Its input:
216
+ Every config is validated at `init` (`config-invalid` names the key and an example value).
131
217
 
132
- - `lessons[]`: `{ text, scope, from?, item?, suggestedChange? }`. `from` is `"human"` or a role id (default: the `--by` who); `item` must name an existing item.
133
- - `adopt[]` / `dismiss[]`: raised lessons, by id, each once.
134
- - `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.
135
- - `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.
136
- - `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`.
218
+ ## Ceremonies
137
219
 
138
- `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.
220
+ `ceremony <name> [input.json] --by <role>`; the caller needs the ceremony's capability.
139
221
 
140
- ### Concurrency
222
+ **Scrum**
223
+ - `refine { reestimate?: string[] }` confirms backlog weights.
224
+ - `plan { goal, items: string[] | "auto" }` commits a sprint; `auto` fills the budget from priority and history.
225
+ - `commit { items }` / `uncommit { items }` adjust the sprint (a closing sprint can only shrink).
226
+ - `daily` reports progress; `review { accepted, goalMet }` closes the sprint; `cancel` abandons it.
227
+ - `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`.
141
228
 
142
- 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.
229
+ **Kanban**
230
+ - `replenishment { items }` moves options to the commitment column (the only push on the board).
231
+ - `delivery-planning { items }` (non-empty) plans the release of done cards.
232
+ - `service-delivery-review { wip?, policies?, sle?, lessons?, adopt?, dismiss?, retire? }` tunes the board; lessons follow the Scrum retro semantics.
233
+ - `operations-review { assign?: [{ item, blocker, owner }] }` reviews blockers and aging WIP.
234
+ - `risk-review { staleAfterMs? }` reports fixed-date risk, stale blockers and active expedites.
235
+ - `strategy-review { classesOfService?, maxExpedite? }` changes classes of service.
143
236
 
144
- ### Schema
237
+ **Waterfall**
238
+ - `kickoff { phase }` opens the next phase.
239
+ - `gateReview { phase }` checks deliverables and traceability, then raises a pending gate decision; `decide … approve` baselines the phase.
240
+ - `changeControlBoard { change, decision, note? }` approves or rejects a change-request; an approval reopens the phases its impact analysis names.
241
+ - `phaseRetrospective { lessons?, adopt?, dismiss?, retire? }`; `adopt` entries are `[{ id }]`. Only `agreement` suggestions apply (baselines and config are locked); others are stored for the host.
145
242
 
146
- `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:
243
+ ## Items, briefs, handoffs, accounting
244
+
245
+ **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`.
246
+
247
+ **Brief** (what `next` gives your agent):
147
248
 
148
249
  ```ts
149
- import { assertValid, validate, workflowStateSchema } from "ex-workflow/schema";
250
+ { item, role, modelTier, invariants, do_not, acceptance,
251
+ upstream, // results of the items this one depends on
252
+ priorHandoffs, // earlier attempts at this item (rework feedback)
253
+ relatedBugs, budgetRemaining, gateAhead }
254
+ ```
255
+
256
+ **Handoff** (what your agent gives back):
150
257
 
151
- const errors = validate(workflowStateSchema, JSON.parse(raw)); // SchemaError[] with JSON-pointer paths
152
- assertValid(workflowStateSchema, JSON.parse(raw), ".workflow/state.json"); // throws WorkflowError("invalid-input")
258
+ ```ts
259
+ { item, role,
260
+ produced: [{ kind, ref }], // evidence; policies match on `kind`
261
+ notes, do_not: string[], open_questions: string[],
262
+ verdict?: "done" | "blocked" | "needs-review" | "rework" | "escalate",
263
+ follow_ups?: NewItem[], // new work; lands in the first stage, never in the iteration
264
+ lessons?: [{ text, scope }] }
153
265
  ```
154
266
 
155
- `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.
267
+ `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`.
156
268
 
157
- ## Layers
269
+ **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.
158
270
 
159
- ```
160
- L3 MCP server (planned) daemon, hook enforcement, dashboard, team mode
161
- L2 agent adapters Claude Code agents/*.md, future Cursor/Codex formats (planned)
162
- L1 skills SKILL.md + scripts/wf.js (bundled L0) (planned)
163
- L0 ex-workflow this spec: state, policy, planner, accounting (npm, free)
164
- ```
271
+ ## Errors
165
272
 
166
- This package is L0. All layers read and write the same `.workflow/` files.
273
+ Every failure is a `WorkflowError` (CLI: exit 1) with the same shape:
167
274
 
168
- ## Status
275
+ ```json
276
+ { "ok": false, "error": { "code": "policy-unmet", "message": "…", "fix": "…", "items": ["CART"], "rule": "dod" } }
277
+ ```
278
+
279
+ 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.
169
280
 
170
- 0.6.0-stage closes 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).
281
+ ## JSON Schema
171
282
 
172
- ## Accepted limitations
283
+ `ex-workflow/schema` exports draft-07 documents generated from the TypeScript types, plus a dependency-free validator:
173
284
 
174
- 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.
285
+ `workflowStateSchema`, `roleSchema`, `newItemSchema`, `itemPatchSchema`, `handoffSchema`, `scrumConfigSchema`, `kanbanConfigSchema`, `waterfallConfigSchema`
175
286
 
176
- - 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.
177
- - 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.
178
- - 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.
179
- - Scrum stage ids (B06): `backlog`, `sprint` and `review` are owned by the module (about twenty uses); init refuses a config that lacks them.
180
- - Uncommit while closing (B07): `ceremony uncommit` stays allowed during `closing` because it only shrinks the sprint.
181
- - Roles on load (B09): state wins on an id conflict, `exwf role add` is the audited path, and re-merging is idempotent.
182
- - Scrum size row (B11): budgets sit at measured size by the owner's standing decision; the row stays as a tripwire.
183
- - Kanban WIP (B12): the engine must not refuse a card it advanced itself; operations-review surfaces queued cards.
184
- - Kanban `wipBypass` (B13): it is a column total; re-scoping the key after 1.0 would break configs.
185
- - Kanban cadences (B14): the key is `everyTurns` because the engine has no clock; wall-clock schedules are the host's job.
186
- - 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.
187
- - Direct primitives (B17): `editItem` and `addItem` bypass `baseline-immutable` by design; `applyAction` and the CLI enforce it.
188
- - Phase budgets (B18): a phase budget reuses `Iteration` and `status` shows `openIteration`; the naming is accepted, and `fallbackTokensPerWeight` covers the no-history case.
189
- - Phase retrospective (B19): baselines and config are locked in Waterfall, so only `agreement` lessons apply; `dod` and `backlog` suggestions are stored for the host.
190
- - Accounting outside sprints (B23): a line whose `endedAt` lies outside every sprint window has no sprint to charge.
191
- - Waterfall deliverables (B10): `deliverables-present` aggregates raw item evidence while stage gates use fresh evidence; the two diverge only when one config uses both.
192
- - 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.
193
- - 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.
194
- - 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.
195
- - Scrum `status.report.reason`: it is always `budget`; the engine has no other closing cause yet.
196
- - 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.
287
+ ```ts
288
+ import { assertValid, validate, handoffSchema } from "ex-workflow/schema";
197
289
 
198
- ## Development gate
290
+ const errors = validate(handoffSchema, JSON.parse(raw)); // SchemaError[] with JSON-pointer paths
291
+ assertValid(handoffSchema, JSON.parse(raw), "inbox/CART.json"); // throws WorkflowError("invalid-input")
292
+ ```
199
293
 
200
- There is no hosted CI. A husky pre-commit hook runs the local gate on every commit
201
- (`pnpm format:check && pnpm lint && pnpm typecheck && pnpm schema:check && pnpm test`); `pnpm run ci` adds the
202
- minified build, the dist identity check and the size ratchet, and `prepublishOnly` runs it
203
- before any publish. oxfmt and oxlint need Node ^20.19 or >=22.12 on the developer machine; the
204
- package itself supports Node >=18 (verified on ubuntu, macOS and Windows x Node 18/20/22
205
- before the hosted workflow was removed). 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.
294
+ 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.
206
295
 
207
- ## Publishing
296
+ ## Package entry points
208
297
 
209
- For the owner. The `stage` dist-tag keeps `latest` free for 0.1.0:
298
+ | Import | Contents |
299
+ |---|---|
300
+ | `ex-workflow` | core: `init`, `addItem`, `editItem`, `next`, `complete`, `decide`, `applyAction`, `validateAction`, `changeConfig`, `correctAccounting`, `clearBlocker`, `raiseBlocker`, `registerRole`, `openQuestions`, `WorkflowError`, `VERSION`, … |
301
+ | `ex-workflow/scrum` | `scrum()`, `scrumMetrics`, `dailyReport`, `closeSprint`, presets |
302
+ | `ex-workflow/kanban` | `kanban()`, `board`, `kanbanMetrics`, `opsReport`, `riskReport`, `cadencesDue`, `DEFAULT_COLUMNS`, presets |
303
+ | `ex-workflow/waterfall` | `waterfall()`, `phaseReport`, `traceabilityMatrix`, `waterfallMetrics`, `baselinePhase`, `reopenPhases`, presets |
304
+ | `ex-workflow/adapters` | `loadState`, `saveState`, `saveBrief`, `saveHandoff`, `withStateLock`, `WORKFLOW_DIR` |
305
+ | `ex-workflow/schema` | the eight schema documents, `validate`, `assertValid` |
306
+ | `ex-workflow/cli` | `runCommand`, `parseArgs`, `USAGE`: the `exwf` command as a library |
307
+ | `ex-workflow/types` | every public type |
308
+
309
+ Each entry ships ESM, CommonJS and `.d.ts`. Core plus one methodology is about 60–68 kB minified.
310
+
311
+ ## Compatibility and versioning
312
+
313
+ - Semver from 1.0.0. The public surface (exports of every entry point, the CLI commands, the eight schema documents, the 52 event kinds) is frozen by test: a removal is a major version, an addition a minor one.
314
+ - A `.workflow/state.json` written by any earlier release loads unchanged; the test suite replays state files from every published pre-release.
315
+ - Behaviour changes are listed per release in [CHANGELOG.md](CHANGELOG.md).
316
+
317
+ ## Known limitations
318
+
319
+ Deliberate, documented, and stable within 1.x.
320
+
321
+ - **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.
322
+ - **Blockers are owned by a human.** Finishing a follow-up does not clear its blocker; `unblock` does.
323
+ - **Direct primitives bypass the baseline.** `addItem` and `editItem` called directly do not check `baseline-immutable`; `applyAction` and the CLI do.
324
+ - **Kanban cadences count turns, not time.** The engine has no clock; wall-clock schedules are the host's job. `wipBypass` is a column total.
325
+ - **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`.
326
+ - **Waterfall traceability is keyed by phase**, not by item type: phase membership says what counts as a requirement, design or test item.
327
+ - **Waterfall retrospectives apply only `agreement` lessons**; `dod` and `backlog` suggestions are stored for the host because baselines and config are locked.
328
+ - **Scrum stage ids** `backlog`, `sprint` and `review` are fixed; `init` refuses a config without them. `status.report.reason` is always `budget`.
329
+ - **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.
330
+ - **Accounting outside a sprint** (a line whose `endedAt` lies in no sprint window) is kept but charged to no sprint.
331
+ - **Reworked items need fresh evidence**: policies and gates count only evidence recorded after the last rework.
332
+ - **CLI flags** take `--flag value` only; `--estimate` is the sole boolean flag.
333
+
334
+ ## Contributing
210
335
 
211
336
  ```sh
212
- pnpm run ci && npm publish --tag stage
337
+ pnpm install
338
+ pnpm test # unit, e2e scenarios per methodology, compatibility fixtures, API-surface freeze
339
+ pnpm run ci # format, lint, typecheck, schema drift, tests, minified build, dist checks, size ratchet
213
340
  ```
214
341
 
215
- ## Design principles
216
-
217
- 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).
218
- 2. The program decides, the LLM executes. Which item may move, who may approve, whether a stage may start: engine, not prompt.
219
- 3. Roles are data. Methodologies reference capabilities, never role names.
220
- 4. Pure, serialisable state. Every operation is `(state, action) -> state` or `(state) -> view`. No I/O in core.
221
- 5. Zero runtime dependencies beyond `ex-flow` and `exsorted` (both MIT, both the owner's). Runs on Node on macOS, Linux and Windows.
222
- 6. Errors resolve: every violation names the exact rule, the exact item, and a concrete fix.
342
+ 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).
223
343
 
224
344
  ## License
225
345
 
226
- MIT
346
+ [MIT](LICENSE)