ex-workflow 1.0.1 → 1.1.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.
- package/CHANGELOG.md +30 -0
- package/README.md +132 -21
- package/dist/adapters/index.cjs +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.mjs +1 -1
- package/dist/{budget-Cx63FX2K.d.ts → budget-Bd8KpGIr.d.ts} +1 -1
- package/dist/{budget-JyNKxP5N.d.cts → budget-CezCinPF.d.cts} +1 -1
- package/dist/chunk-6P3OKXSK.mjs +2 -0
- package/dist/chunk-6P3OKXSK.mjs.map +1 -0
- package/dist/{chunk-5PHK72VM.cjs → chunk-7FS6KWTG.cjs} +2 -2
- package/dist/{chunk-5PHK72VM.cjs.map → chunk-7FS6KWTG.cjs.map} +1 -1
- package/dist/chunk-7QQY4KJ2.mjs +2 -0
- package/dist/chunk-7QQY4KJ2.mjs.map +1 -0
- package/dist/chunk-AD4Z3JBL.cjs +2 -0
- package/dist/chunk-AD4Z3JBL.cjs.map +1 -0
- package/dist/chunk-ATCJ4IHP.mjs +2 -0
- package/dist/{chunk-Z2G7DGDF.mjs.map → chunk-ATCJ4IHP.mjs.map} +1 -1
- package/dist/chunk-C2IYMWE6.cjs +3 -0
- package/dist/chunk-C2IYMWE6.cjs.map +1 -0
- package/dist/chunk-EACZBAP3.cjs +2 -0
- package/dist/chunk-EACZBAP3.cjs.map +1 -0
- package/dist/chunk-EFCUM6DK.mjs +2 -0
- package/dist/chunk-EFCUM6DK.mjs.map +1 -0
- package/dist/chunk-EHBQBXWA.cjs +2 -0
- package/dist/{chunk-VXH2FAKV.cjs.map → chunk-EHBQBXWA.cjs.map} +1 -1
- package/dist/chunk-FTS75UIU.mjs +2 -0
- package/dist/{chunk-U3OXAO67.mjs.map → chunk-FTS75UIU.mjs.map} +1 -1
- package/dist/chunk-HCRVWMG4.cjs +2 -0
- package/dist/chunk-HCRVWMG4.cjs.map +1 -0
- package/dist/chunk-KLWZEXZU.mjs +3 -0
- package/dist/chunk-KLWZEXZU.mjs.map +1 -0
- package/dist/chunk-NDCQTRIV.mjs +2 -0
- package/dist/chunk-NDCQTRIV.mjs.map +1 -0
- package/dist/chunk-PMUGU5UJ.cjs +2 -0
- package/dist/chunk-PMUGU5UJ.cjs.map +1 -0
- package/dist/{chunk-7IG6EQI4.mjs → chunk-QZ6HD6DE.mjs} +3 -3
- package/dist/{chunk-7IG6EQI4.mjs.map → chunk-QZ6HD6DE.mjs.map} +1 -1
- package/dist/{chunk-HIHMBMB5.cjs → chunk-RL27372B.cjs} +2 -2
- package/dist/{chunk-HIHMBMB5.cjs.map → chunk-RL27372B.cjs.map} +1 -1
- package/dist/chunk-SP5MC7RR.mjs +2 -0
- package/dist/{chunk-QDMEM62U.mjs.map → chunk-SP5MC7RR.mjs.map} +1 -1
- package/dist/chunk-SVGTSPZF.cjs +2 -0
- package/dist/chunk-SVGTSPZF.cjs.map +1 -0
- package/dist/chunk-SYLO7FUL.mjs +2 -0
- package/dist/{chunk-3KFQPSRX.mjs.map → chunk-SYLO7FUL.mjs.map} +1 -1
- package/dist/chunk-T3V5UE34.mjs +2 -0
- package/dist/{chunk-UZQV73X7.mjs.map → chunk-T3V5UE34.mjs.map} +1 -1
- package/dist/{chunk-FKTCGQYB.cjs → chunk-TS66RAJR.cjs} +2 -2
- package/dist/{chunk-FKTCGQYB.cjs.map → chunk-TS66RAJR.cjs.map} +1 -1
- package/dist/{chunk-YRATJT7P.cjs → chunk-U23FUYPD.cjs} +4 -4
- package/dist/{chunk-YRATJT7P.cjs.map → chunk-U23FUYPD.cjs.map} +1 -1
- package/dist/chunk-U6GHFKKE.mjs +2 -0
- package/dist/chunk-U6GHFKKE.mjs.map +1 -0
- package/dist/{chunk-CYXVGHQM.cjs → chunk-YJQ5YJ7S.cjs} +2 -2
- package/dist/{chunk-CYXVGHQM.cjs.map → chunk-YJQ5YJ7S.cjs.map} +1 -1
- package/dist/cli/bin.cjs +1 -1
- package/dist/cli/bin.cjs.map +1 -1
- package/dist/cli/bin.mjs +1 -1
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/experimentation/index.cjs +2 -0
- package/dist/experimentation/index.cjs.map +1 -0
- package/dist/experimentation/index.d.cts +28 -0
- package/dist/experimentation/index.d.ts +28 -0
- package/dist/experimentation/index.mjs +2 -0
- package/dist/experimentation/index.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/investigation/index.cjs +2 -0
- package/dist/investigation/index.cjs.map +1 -0
- package/dist/investigation/index.d.cts +13 -0
- package/dist/investigation/index.d.ts +13 -0
- package/dist/investigation/index.mjs +2 -0
- package/dist/investigation/index.mjs.map +1 -0
- package/dist/kanban/index.cjs +1 -1
- package/dist/kanban/index.d.cts +1 -1
- package/dist/kanban/index.d.ts +1 -1
- package/dist/kanban/index.mjs +1 -1
- package/dist/schema/index.cjs +1 -1
- package/dist/schema/index.d.cts +3 -1
- package/dist/schema/index.d.ts +3 -1
- package/dist/schema/index.mjs +1 -1
- package/dist/scrum/index.cjs +1 -1
- package/dist/scrum/index.d.cts +3 -3
- package/dist/scrum/index.d.ts +3 -3
- package/dist/scrum/index.mjs +1 -1
- package/dist/types-BScHXlRx.d.cts +509 -0
- package/dist/types-BScHXlRx.d.ts +509 -0
- package/dist/types.d.cts +1 -388
- package/dist/types.d.ts +1 -388
- package/dist/waterfall/index.cjs +1 -1
- package/dist/waterfall/index.d.cts +1 -1
- package/dist/waterfall/index.d.ts +1 -1
- package/dist/waterfall/index.mjs +1 -1
- package/package.json +46 -21
- package/dist/chunk-3KFQPSRX.mjs +0 -2
- package/dist/chunk-5TXYMLBF.mjs +0 -3
- package/dist/chunk-5TXYMLBF.mjs.map +0 -1
- package/dist/chunk-MQWMQ4PD.mjs +0 -2
- package/dist/chunk-MQWMQ4PD.mjs.map +0 -1
- package/dist/chunk-QDMEM62U.mjs +0 -2
- package/dist/chunk-U3OXAO67.mjs +0 -2
- package/dist/chunk-UZQV73X7.mjs +0 -2
- package/dist/chunk-VXH2FAKV.cjs +0 -2
- package/dist/chunk-WOGK54HB.cjs +0 -3
- package/dist/chunk-WOGK54HB.cjs.map +0 -1
- package/dist/chunk-XMO2RCXB.cjs +0 -2
- package/dist/chunk-XMO2RCXB.cjs.map +0 -1
- package/dist/chunk-YBHHICTZ.mjs +0 -2
- package/dist/chunk-YBHHICTZ.mjs.map +0 -1
- package/dist/chunk-YJN4JEJU.cjs +0 -2
- package/dist/chunk-YJN4JEJU.cjs.map +0 -1
- package/dist/chunk-Z2G7DGDF.mjs +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.1 (2026-10-30)
|
|
4
|
+
|
|
5
|
+
Fix wave for the ten findings of the 1.1.0 code review (Investigation and Experimentation); the decisions are in the design spec, section 25. No new ceremony, key, export, event kind or schema document.
|
|
6
|
+
|
|
7
|
+
- Investigation records are closed objects (R1): a `hypotheses` entry, the `experiment` and its `predictions` entries, the `result` and an `assessments` entry with an unknown key are refused `invalid-input` naming the key. 1.1.0 copied them into `state.json`, which `saveState` then rejected with an error pointing at the state file. Stored records are copied field by field.
|
|
8
|
+
- `preregister` after the round limit or the budget is spent is refused `invalid-input` with the fix naming `stop` (R6); 1.1.0 discarded the experiment, closed the investigation `stopped` and answered `ok: true`.
|
|
9
|
+
- `intake` refuses a workflow of another methodology and runs through the rules like every other ceremony (R7); 1.1.0 could graft an investigation record and iteration onto a Scrum, Kanban or Waterfall state.
|
|
10
|
+
- Experimentation ceremonies accept an input property whose value is `undefined` (R2), as `JSON.stringify` drops it; a host forwarding `{ by, now: options.now, ...input }` was refused `ceremony input must be JSON-safe`.
|
|
11
|
+
- `validate` of a candidate the planner dispatched (`next`) is refused `invalid-input` while its item is still `in_progress`, with the fix naming `complete` (R3): validating first moved the item to `done`, so the builder's `complete` failed and its accounting was never recorded. A candidate the host started by ceremony (`start`) is validated as before.
|
|
12
|
+
- A closed experiment keeps the `endedAt` and `outcome` of its iteration (R5); in 1.1.0 every later ceremony (`cleanup`) re-stamped them.
|
|
13
|
+
- The two `item.dispatch` checks of the `experimentation-lifecycle` rule are removed (R4): no action of that type exists, so they never ran; `candidates()`, `provision` and `start` already refuse dispatch on a stopped or exhausted experiment.
|
|
14
|
+
- Internal: the investigation ceremonies build their methodology once per factory (R9); experimentation spent totals and config are computed once per ceremony instead of once per budget dimension (R8).
|
|
15
|
+
- Finding 10 (the investigation `roleFor` throws `missing-capability` from `next` when no independent deliver role exists) is kept: core `assignRole` throws the same code in the same situation for every methodology, and the error names the item and the fix.
|
|
16
|
+
|
|
17
|
+
Compatibility: no `state.json`, schema document, event kind, export or CLI change; `VERSION` is `"1.1.1"`. Behaviour changes, all for inputs 1.1.0 accepted and then lost or mis-recorded: an unknown key in an investigation record is refused; `preregister` when exhausted is refused instead of closing the investigation; `intake` on a foreign workflow is refused; `validate` of a planner-dispatched candidate waits for the builder's completion; `now: undefined` is accepted; `endedAt` no longer drifts after closure. Size budgets re-recorded at measured size.
|
|
18
|
+
|
|
19
|
+
## 1.1.0 (2026-10-28)
|
|
20
|
+
|
|
21
|
+
Two standalone methodologies, Investigation (#37) and Experimentation (#38); the decisions are in the design spec, section 24. The research reports in `docs/research/` were the input; the standalone decision supersedes their composition recommendation.
|
|
22
|
+
|
|
23
|
+
- Investigation (`ex-workflow/investigation`, #37): `investigation()` with config `{ question, maxRounds, budget }`, roles `investigator`, `replay-worker`, `conclusion-reviewer`, stages `intake`, `execute`, `observed`, and the ceremonies `intake`, `hypotheses`, `preregister`, `observe`, `update-belief`, `conclude`, `review-conclusion`, `stop`. Competing falsifiable hypotheses, preregistered runs executed as items through `next` and `complete`, recorded observations (invalid runs included), belief updates, independent replay and an independent conclusion review before a conclusion is `resolved`; `inconclusive` and `stopped` are first-class outcomes; rounds and budget are bounded.
|
|
24
|
+
- Experimentation (`ex-workflow/experimentation`, #38): `experimentation()` with config `{ objective, direction, tieBreak, concurrencyCap, maxCandidates, candidateBudget, totalBudget }`, roles `coordinator`, `builder`, `validator`, `integrator`, stages `candidate`, `building`, `validation` (gate `experiment-validation`), `done`, and the ceremonies `freeze`, `provision`, `start`, `submit`, `validate`, `compare`, `integrate`, `validate-integration`, `terminate`, `stop`, `cleanup`. Frozen baseline SHA and harness, isolated workspaces recorded by identity, bounded per-candidate and total budgets, independent validation at the exact submitted SHA, deterministic ranking (score, then candidate id), exact-SHA promotion and fresh validation of the integration SHA; all-fail produces no winner.
|
|
25
|
+
- CLI: `exwf init investigation` and `exwf init experimentation`; `ceremony`, `next`, `complete`, `status`, `metrics` and the persistence commands work unchanged.
|
|
26
|
+
- Schema: `investigationConfigSchema` and `experimentationConfigSchema` in `ex-workflow/schema`; `workflowStateSchema` covers the new optional lifecycle records, so `loadState` validates them.
|
|
27
|
+
- Planner: `PlannerOptions.reservedTokens` (optional) deducts tokens reserved for in-flight work from the iteration remainder; Experimentation sets it for running candidates; omitted, dispatch is unchanged.
|
|
28
|
+
- Examples: `scripts/example-investigation.ts` and `scripts/example-experimentation.ts`, synthetic and asserted, run with `pnpm exec tsx`.
|
|
29
|
+
- API-surface test: event kinds are now collected from the TypeScript AST instead of a regex; the 1.0.0 list carried one false positive (`needs-review`, a verdict string, never an event), so the real count moves from 51 to 69.
|
|
30
|
+
|
|
31
|
+
Compatibility: additive. `MethodologyName` gains `investigation` and `experimentation`; `WorkflowState` gains the optional `investigation` and `experimentation` records, written only by those methodologies; the schema documents go from eight to ten; 18 event kinds are added (`investigation.*` 7, `experimentation.*` 11); `PlannerOptions` gains `reservedTokens`. A `.workflow/state.json` written by 1.0.x loads unchanged. Scrum, Kanban and Waterfall behaviour, payloads and messages are unchanged; their minified single-entry bundles grow by 59 B each for the planner hook (budgets at measured). `VERSION` is `"1.1.0"`.
|
|
32
|
+
|
|
3
33
|
## 1.0.1 (2026-10-24)
|
|
4
34
|
|
|
5
35
|
Documentation release; no code, schema, CLI or `state.json` change.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ex-workflow
|
|
2
2
|
|
|
3
|
-
**Methodology engine for AI agent teams.** Scrum, Kanban and
|
|
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
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/ex-workflow) [](LICENSE) Node >= 18 · macOS, Linux, Windows · ESM + CommonJS · no I/O in core
|
|
6
6
|
|
|
@@ -17,18 +17,19 @@
|
|
|
17
17
|
4. [Quick start: Scrum](#quick-start-scrum)
|
|
18
18
|
5. [Quick start: Kanban](#quick-start-kanban)
|
|
19
19
|
6. [Quick start: Waterfall](#quick-start-waterfall)
|
|
20
|
-
7. [
|
|
21
|
-
8. [
|
|
22
|
-
9. [
|
|
23
|
-
10. [
|
|
24
|
-
11. [
|
|
25
|
-
12. [
|
|
26
|
-
13. [
|
|
27
|
-
14. [
|
|
28
|
-
15. [
|
|
29
|
-
16. [
|
|
30
|
-
17. [
|
|
31
|
-
18. [
|
|
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)
|
|
32
33
|
|
|
33
34
|
## Install
|
|
34
35
|
|
|
@@ -37,7 +38,7 @@ npm install ex-workflow # or: pnpm add ex-workflow
|
|
|
37
38
|
npx exwf # prints the CLI usage
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
`latest` is the supported line (1.
|
|
41
|
+
`latest` is the supported line (1.1.1). Pre-releases, when any, are published under the `stage` dist-tag.
|
|
41
42
|
|
|
42
43
|
## Pick a methodology
|
|
43
44
|
|
|
@@ -50,7 +51,9 @@ npx exwf # prints the CLI usage
|
|
|
50
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 |
|
|
51
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 |
|
|
52
53
|
|
|
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.
|
|
54
57
|
|
|
55
58
|
## How a run works
|
|
56
59
|
|
|
@@ -131,6 +134,64 @@ state = decide(state, state.pending[0]!.id, "approve", "human", "ok", undefined,
|
|
|
131
134
|
|
|
132
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`.
|
|
133
136
|
|
|
137
|
+
## Standalone investigation and experimentation
|
|
138
|
+
|
|
139
|
+
**Investigation** runs an evidence-driven inquiry: one bounded question, competing falsifiable hypotheses, preregistered experiments, recorded observations, belief updates and an independent review before a conclusion is resolved. **Experimentation** compares isolated candidates against a frozen baseline and harness: independent validation at the exact submitted SHA, deterministic selection, and fresh validation of the integration SHA. Each runs in its own `.workflow/` state; neither nests inside, migrates into or coordinates Scrum, Kanban, Waterfall or the other. The host executes procedures, provisions workspaces, runs benchmarks and performs Git operations; the engine records and validates the resulting artifacts (see [Known limitations](#known-limitations)).
|
|
140
|
+
|
|
141
|
+
Run the complete synthetic SDK examples from this repository:
|
|
142
|
+
|
|
143
|
+
```sh
|
|
144
|
+
pnpm exec tsx scripts/example-investigation.ts
|
|
145
|
+
pnpm exec tsx scripts/example-experimentation.ts
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
[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.
|
|
149
|
+
|
|
150
|
+
### Investigation
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
import { init } from "ex-workflow";
|
|
154
|
+
import { investigation } from "ex-workflow/investigation";
|
|
155
|
+
|
|
156
|
+
const m = investigation();
|
|
157
|
+
let { state } = init({ methodology: m, config: {
|
|
158
|
+
question: "Why do repeated requests miss the cache?",
|
|
159
|
+
maxRounds: 3, budget: { tokens: 100_000, turns: 20 },
|
|
160
|
+
} });
|
|
161
|
+
state = m.ceremonies["intake"]!(state, { by: "investigator", item: "CACHE" }).state;
|
|
162
|
+
state = m.ceremonies["hypotheses"]!(state, { by: "investigator", hypotheses: [
|
|
163
|
+
{ id: "key", claim: "Keys differ", falsifiedBy: "Identical keys" },
|
|
164
|
+
{ id: "expiry", claim: "Entries expire", falsifiedBy: "Live entries" },
|
|
165
|
+
] }).state;
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Roles: `investigator` (intake, hypotheses, preregistration, observation, belief update, conclusion), `replay-worker` (executes a replay when the investigator ran the original), `conclusion-reviewer` (approves or rejects a conclusion; may not have executed any run). Stages: `intake` → `execute` → `observed`. Each preregistered experiment is an item: `next()` briefs the executor and `complete()` records `experiment-output` evidence before `observe`. A `resolved` conclusion needs a supported hypothesis, valid supporting evidence, a valid replay and an independent review; `inconclusive` and `stopped` are first-class outcomes. Config keys: [Configuration](#investigation-investigationconfig). Ceremonies and their inputs: [Ceremonies](#ceremonies).
|
|
169
|
+
|
|
170
|
+
### Experimentation
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
import { init, addItem } from "ex-workflow";
|
|
174
|
+
import { experimentation } from "ex-workflow/experimentation";
|
|
175
|
+
|
|
176
|
+
const m = experimentation();
|
|
177
|
+
let { state } = init({ methodology: m, config: {
|
|
178
|
+
objective: "Lowest median latency", direction: "minimize", tieBreak: "candidate-id",
|
|
179
|
+
concurrencyCap: 2, maxCandidates: 4,
|
|
180
|
+
candidateBudget: { turns: 10 }, totalBudget: { turns: 40 },
|
|
181
|
+
} });
|
|
182
|
+
state = addItem(state, { id: "A", title: "Candidate A", acceptance: ["Pass frozen benchmark"] }, "coordinator");
|
|
183
|
+
state = m.ceremonies["freeze"]!(state, { by: "coordinator", baseSha: "a".repeat(40),
|
|
184
|
+
harness: "bench-v1", candidates: [{ id: "a", item: "A", author: "builder" }],
|
|
185
|
+
}).state;
|
|
186
|
+
state = m.ceremonies["provision"]!(state, { by: "coordinator", candidate: "a", workspace: "/worktrees/a", baseSha: "a".repeat(40), isolated: true }).state;
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Roles: `coordinator` (freeze, provision, compare, terminate, stop, cleanup), `builder` (start, submit), `validator` (validate, validate-integration), `integrator` (integrate). Stages: `candidate` → `building` → `validation` (gate `experiment-validation`) → `done`. Every candidate is an item dispatched to its author at `building`; `next()` admits at most `concurrencyCap` running candidates and reserves the tokens of in-flight work. Comparison ranks eligible validated candidates by score, then candidate id; when none is eligible the run stops without a winner. Config keys: [Configuration](#experimentation-experimentationconfig). Ceremonies and their inputs: [Ceremonies](#ceremonies).
|
|
190
|
+
|
|
191
|
+
### CLI
|
|
192
|
+
|
|
193
|
+
`exwf init investigation --config investigation.json` or `exwf init experimentation --config experimentation.json`, then the same `ceremony`, `next`, `complete`, `status`, `metrics` and persistence commands. A ceremony input file holds the object documented under [Ceremonies](#ceremonies); pass the role with `--by`.
|
|
194
|
+
|
|
134
195
|
## Persisting state
|
|
135
196
|
|
|
136
197
|
Core performs no I/O. The file adapter is the only part that touches disk, and the CLI is built on it.
|
|
@@ -162,7 +223,7 @@ Run from the directory that holds `.workflow/`. Every command prints JSON on std
|
|
|
162
223
|
|
|
163
224
|
| Command | Returns |
|
|
164
225
|
|---|---|
|
|
165
|
-
| `init <scrum\|kanban\|waterfall> --config <file> [--roles <file>]` | `{ ok, state: { methodology, stages, roles } }` |
|
|
226
|
+
| `init <scrum\|kanban\|waterfall\|investigation\|experimentation> --config <file> [--roles <file>]` | `{ ok, state: { methodology, stages, roles } }` |
|
|
166
227
|
| `add <item.json> [--by who]` | `{ ok, warnings, item }`, checked by the methodology rules |
|
|
167
228
|
| `edit <id> <patch.json> [--by who]` | `{ ok, warnings, item }` |
|
|
168
229
|
| `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) |
|
|
@@ -213,6 +274,28 @@ Run from the directory that holds `.workflow/`. Every command prints JSON on std
|
|
|
213
274
|
| `traceability` | `{ from, to[] }` phase ids: every item of `from` must trace to an item of each `to` phase before that gate |
|
|
214
275
|
| `fallbackTokensPerWeight` | as in Scrum |
|
|
215
276
|
|
|
277
|
+
### Investigation (`InvestigationConfig`)
|
|
278
|
+
|
|
279
|
+
| Key | Meaning |
|
|
280
|
+
|---|---|
|
|
281
|
+
| `question` | the question the investigation answers; it heads every brief's invariants |
|
|
282
|
+
| `maxRounds` | positive integer; a round is one preregistered experiment |
|
|
283
|
+
| `budget` | `{ tokens?, turns?, wallclockMs? }`, at least one, every value finite and positive; when it is spent no further run is dispatched and the investigation closes `stopped` |
|
|
284
|
+
|
|
285
|
+
All three keys are locked after `init` (`config set` refuses them).
|
|
286
|
+
|
|
287
|
+
### Experimentation (`ExperimentationConfig`)
|
|
288
|
+
|
|
289
|
+
| Key | Meaning |
|
|
290
|
+
|---|---|
|
|
291
|
+
| `objective` | what the score measures |
|
|
292
|
+
| `direction` (`minimize` default, or `maximize`) | how scores rank |
|
|
293
|
+
| `tieBreak` (`candidate-id`, the only value) | equal scores rank by candidate id |
|
|
294
|
+
| `concurrencyCap` (default 2), `maxCandidates` (default 4) | candidates running at once, candidates per run; the cap cannot exceed the maximum |
|
|
295
|
+
| `candidateBudget` (default `{ turns: 10 }`), `totalBudget` (default `{ turns: 40 }`) | `{ tokens?, turns?, wallclockMs? }` of positive integers, per candidate and for the whole run including control, validation and integration overhead |
|
|
296
|
+
|
|
297
|
+
Every key is locked after `init`; an unknown key is refused.
|
|
298
|
+
|
|
216
299
|
Every config is validated at `init` (`config-invalid` names the key and an example value).
|
|
217
300
|
|
|
218
301
|
## Ceremonies
|
|
@@ -240,6 +323,29 @@ Every config is validated at `init` (`config-invalid` names the key and an examp
|
|
|
240
323
|
- `changeControlBoard { change, decision, note? }` approves or rejects a change-request; an approval reopens the phases its impact analysis names.
|
|
241
324
|
- `phaseRetrospective { lessons?, adopt?, dismiss?, retire? }`; `adopt` entries are `[{ id }]`. Only `agreement` suggestions apply (baselines and config are locked); others are stored for the host.
|
|
242
325
|
|
|
326
|
+
**Investigation** (`investigator` unless noted; every input also takes `by`; every record is a closed object, an unknown key is refused)
|
|
327
|
+
- `intake { item }` names the question item and opens the investigation.
|
|
328
|
+
- `hypotheses { hypotheses: [{ id, claim, falsifiedBy }], singleHypothesisRationale? }` registers unique, falsifiable, competing hypotheses; a single hypothesis needs the rationale.
|
|
329
|
+
- `preregister { experiment: { id, procedureRef, predictions: [{ hypothesis, prediction }], replayOf? } }` creates the run item; `replayOf` names an earlier valid experiment with the same procedure and predictions, and is executed by a role that did not run it. Refused once `maxRounds` or the budget is spent; `stop` closes the investigation.
|
|
330
|
+
- `observe { experiment, result: { id, valid, summary, provenanceRefs } }` records the outcome once the run item is `done` with `experiment-output` evidence; an invalid run stays recorded.
|
|
331
|
+
- `update-belief { result, assessments: [{ hypothesis, assessment, reason }], next }` with `assessment` `supported` | `refuted` | `uncertain` and `next` `round` | `conclusion`.
|
|
332
|
+
- `conclude { outcome, summary, evidenceRefs, supportedHypothesis? }` with `outcome` `resolved` | `inconclusive`; `resolved` needs a supported hypothesis, valid supporting evidence and a valid replay.
|
|
333
|
+
- `review-conclusion { approve, reason, replayRefs?, next? }` by `conclusion-reviewer`, who may not have contributed a run; a rejection returns to `round` or `conclusion`.
|
|
334
|
+
- `stop { reason }` closes the investigation `stopped`.
|
|
335
|
+
|
|
336
|
+
**Experimentation** (SHAs are full lowercase 40- or 64-character hex; `spent` is `{ tokens?, turns?, wallclockMs? }`, cumulative for the candidate)
|
|
337
|
+
- `freeze { baseSha, harness, candidates: [{ id, item, author }] }` by `coordinator` freezes the baseline and harness and registers each candidate (an existing item and its builder role); nothing runs before the freeze.
|
|
338
|
+
- `provision { candidate, workspace, baseSha, isolated: true }` by `coordinator` records the host-created isolated workspace at the frozen base; the candidate becomes `ready`.
|
|
339
|
+
- `start { candidate }` by the builder marks the dispatched candidate `running`.
|
|
340
|
+
- `submit { candidate, sha, score, baseSha, workspace, harness, command, log, spent }` by the builder records the exact commit, the benchmark result and the usage.
|
|
341
|
+
- `validate { candidate, sha, harness, passed, reproducible, evidence, spent }` by a `validator` other than the author, at the submitted SHA and frozen harness; a failed or nonreproducible candidate is ineligible. A candidate the planner dispatched (`next`) is validated after its builder's `complete`; one the host started by ceremony needs no completion.
|
|
342
|
+
- `compare` by `coordinator` ranks the eligible validated candidates by score, then candidate id, and selects the winner; with none eligible the run stops without a winner.
|
|
343
|
+
- `integrate { selectedSha, targetSha, integrationSha, spent }` by `integrator` records the exact selected SHA merged into the current target.
|
|
344
|
+
- `validate-integration { sha, targetSha, harness, passed, evidence, spent }` by a validator independent of the author and the integrator; a pass closes the run `integrated`, a fail stops it.
|
|
345
|
+
- `terminate { candidate, status, reason, spent, log }` with `status` `failed` | `timed-out` | `cancelled` records a terminal attempt with its final usage; required for every dispatched, running or submitted candidate before `stop`.
|
|
346
|
+
- `stop { reason, spent }` by `coordinator` closes the run; candidates that never started are cancelled automatically.
|
|
347
|
+
- `cleanup { workspaces }` by `coordinator`, after closure, records the host-confirmed release of workspaces.
|
|
348
|
+
|
|
243
349
|
## Items, briefs, handoffs, accounting
|
|
244
350
|
|
|
245
351
|
**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`.
|
|
@@ -282,7 +388,7 @@ Codes: `unknown-item`, `duplicate-item`, `unknown-role`, `duplicate-role`, `unkn
|
|
|
282
388
|
|
|
283
389
|
`ex-workflow/schema` exports draft-07 documents generated from the TypeScript types, plus a dependency-free validator:
|
|
284
390
|
|
|
285
|
-
`workflowStateSchema`, `roleSchema`, `newItemSchema`, `itemPatchSchema`, `handoffSchema`, `scrumConfigSchema`, `kanbanConfigSchema`, `waterfallConfigSchema`
|
|
391
|
+
`workflowStateSchema`, `roleSchema`, `newItemSchema`, `itemPatchSchema`, `handoffSchema`, `scrumConfigSchema`, `kanbanConfigSchema`, `waterfallConfigSchema`, `investigationConfigSchema`, `experimentationConfigSchema`
|
|
286
392
|
|
|
287
393
|
```ts
|
|
288
394
|
import { assertValid, validate, handoffSchema } from "ex-workflow/schema";
|
|
@@ -301,16 +407,18 @@ The CLI validates state, role manifests, items, patches and handoffs with these
|
|
|
301
407
|
| `ex-workflow/scrum` | `scrum()`, `scrumMetrics`, `dailyReport`, `closeSprint`, presets |
|
|
302
408
|
| `ex-workflow/kanban` | `kanban()`, `board`, `kanbanMetrics`, `opsReport`, `riskReport`, `cadencesDue`, `DEFAULT_COLUMNS`, presets |
|
|
303
409
|
| `ex-workflow/waterfall` | `waterfall()`, `phaseReport`, `traceabilityMatrix`, `waterfallMetrics`, `baselinePhase`, `reopenPhases`, presets |
|
|
410
|
+
| `ex-workflow/investigation` | `investigation()`, `validateInvestigationConfig`; types `InvestigationConfig`, `InvestigationState`, `InvestigationRound`, `InvestigationConclusion`, `Hypothesis`, `Experiment`, `Observation`, `BeliefUpdate` |
|
|
411
|
+
| `ex-workflow/experimentation` | `experimentation()`, `validateExperimentationConfig`, `experimentationCeremonies`, `experimentationMetrics`, `experimentationReport`, `experimentationRoles`, `experimentationRules`, `experimentationStages`; types `ExperimentationConfig`, `ExperimentationState`, `ExperimentCandidate` |
|
|
304
412
|
| `ex-workflow/adapters` | `loadState`, `saveState`, `saveBrief`, `saveHandoff`, `withStateLock`, `WORKFLOW_DIR` |
|
|
305
|
-
| `ex-workflow/schema` | the
|
|
413
|
+
| `ex-workflow/schema` | the ten schema documents, `validate`, `assertValid` |
|
|
306
414
|
| `ex-workflow/cli` | `runCommand`, `parseArgs`, `USAGE`: the `exwf` command as a library |
|
|
307
415
|
| `ex-workflow/types` | every public type |
|
|
308
416
|
|
|
309
|
-
Each entry ships ESM, CommonJS and `.d.ts`. Core plus one methodology is about
|
|
417
|
+
Each entry ships ESM, CommonJS and `.d.ts`. Core plus one methodology is about 51–68 kB minified.
|
|
310
418
|
|
|
311
419
|
## Compatibility and versioning
|
|
312
420
|
|
|
313
|
-
- Semver from 1.0.0. The public surface (exports of every entry point, the CLI commands, the
|
|
421
|
+
- Semver from 1.0.0. The public surface (exports of every entry point, the CLI commands, the ten schema documents, the 69 event kinds) is frozen by test: a removal is a major version, an addition a minor one.
|
|
314
422
|
- A `.workflow/state.json` written by any earlier release loads unchanged; the test suite replays state files from every published pre-release.
|
|
315
423
|
- Behaviour changes are listed per release in [CHANGELOG.md](CHANGELOG.md).
|
|
316
424
|
|
|
@@ -330,6 +438,9 @@ Deliberate, documented, and stable within 1.x.
|
|
|
330
438
|
- **Accounting outside a sprint** (a line whose `endedAt` lies in no sprint window) is kept but charged to no sprint.
|
|
331
439
|
- **Reworked items need fresh evidence**: policies and gates count only evidence recorded after the last rework.
|
|
332
440
|
- **CLI flags** take `--flag value` only; `--estimate` is the sole boolean flag.
|
|
441
|
+
- **Investigation and Experimentation run alone.** Neither nests inside, migrates into or coordinates Scrum, Kanban, Waterfall or the other; one `.workflow/` per run.
|
|
442
|
+
- **The host executes.** Core never runs a procedure, benchmark or Git command and never creates or removes a workspace; `provision`, `submit`, `integrate` and `cleanup` record what the host did. A `procedureRef`, `provenanceRefs` entry, `evidence` or `log` is a recorded reference: the engine checks its shape and linkage, not the contents behind it.
|
|
443
|
+
- **Independence is by role id.** Replay, conclusion review and validation must come from a role that did not do the work, judged by the recorded role id; authenticating who runs which role is the host's job.
|
|
333
444
|
|
|
334
445
|
## Contributing
|
|
335
446
|
|
|
@@ -339,7 +450,7 @@ pnpm test # unit, e2e scenarios per methodology, compatibility fixtures,
|
|
|
339
450
|
pnpm run ci # format, lint, typecheck, schema drift, tests, minified build, dist checks, size ratchet
|
|
340
451
|
```
|
|
341
452
|
|
|
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).
|
|
453
|
+
Conventions for branches, commits, tests, the frozen public surface, size budgets, docs and releases are in [CONTRIBUTING.md](CONTRIBUTING.md). 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).
|
|
343
454
|
|
|
344
455
|
## License
|
|
345
456
|
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
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
|
package/dist/adapters/index.d.ts
CHANGED
package/dist/adapters/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as WORKFLOW_DIR,e as loadState,f as saveBrief,g as saveHandoff,d as saveState,b as statePath,c as withStateLock}from'../chunk-
|
|
1
|
+
export{a as WORKFLOW_DIR,e as loadState,f as saveBrief,g as saveHandoff,d as saveState,b as statePath,c as withStateLock}from'../chunk-QZ6HD6DE.mjs';import'../chunk-KLWZEXZU.mjs';import'../chunk-2FRRD6A3.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WorkflowState, Role, Capability, Budget, Accounting } from './types.js';
|
|
1
|
+
import { W as WorkflowState, R as Role, C as Capability, a as Budget, A as Accounting } from './types-BScHXlRx.js';
|
|
2
2
|
|
|
3
3
|
declare function registerRole(state: WorkflowState, role: Role, by: string, now?: string): WorkflowState;
|
|
4
4
|
declare function retireRole(state: WorkflowState, roleId: string, by: string, now?: string): WorkflowState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WorkflowState, Role, Capability, Budget, Accounting } from './types.cjs';
|
|
1
|
+
import { W as WorkflowState, R as Role, C as Capability, a as Budget, A as Accounting } from './types-BScHXlRx.cjs';
|
|
2
2
|
|
|
3
3
|
declare function registerRole(state: WorkflowState, role: Role, by: string, now?: string): WorkflowState;
|
|
4
4
|
declare function retireRole(state: WorkflowState, roleId: string, by: string, now?: string): WorkflowState;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b as b$1,c}from'./chunk-2FRRD6A3.mjs';import {ExFlow,ExFlowRuntimeError}from'ex-flow';function b(t){return t??new Date().toISOString()}function Y(t){let e=new Set;for(let i of t.stages)e.has(i.id)&&b$1("config-invalid",`duplicate stage id "${i.id}"`,"give every stage a unique id"),e.add(i.id);let n={};for(let i of t.roles)c(i.id,"role id"),Object.hasOwn(n,i.id)&&b$1("duplicate-role",`duplicate role id "${i.id}"`,"give every role a unique id"),n[i.id]=i;let o=b(t.now);return {version:1,methodology:t.methodology,config:t.config,items:{},stages:t.stages,roles:n,iterations:[],events:[{seq:1,at:o,type:"state.created",by:"system",payload:{methodology:t.methodology}}],accounting:[],pending:[],lessons:[],agreements:[]}}function h(t,e,n,o,i){let s={seq:(t.events[t.events.length-1]?.seq??0)+1,at:b(i),type:e,by:n,payload:o};return {...t,events:[...t.events,s]}}function je(t,e){for(let n=t.events.length-1;n>=0;n--){let o=t.events[n];if(e===void 0||o.type===e)return o}}function A(t,e){return Object.hasOwn(t.roles,e)?t.roles[e]:void 0}var me=new Set(["in_progress","review","blocked"]);function Ee(t,e,n,o){c(e.id,"role id"),A(t,e.id)&&b$1("duplicate-role",`role "${e.id}" already exists`,`use a different id or retireRole("${e.id}") first`);let i={...t,roles:{...t.roles,[e.id]:e}};return h(i,"role.registered",n,{role:e.id,capabilities:e.capabilities},o)}function Pe(t,e,n,o){A(t,e)||b$1("unknown-role",`role "${e}" does not exist`,`registered roles: ${Object.keys(t.roles).join(", ")||"(none)"}`);let i=Object.values(t.items).filter(s=>s.role===e&&me.has(s.status)).map(s=>s.id);i.length&&b$1("role-has-open-items",`role "${e}" still holds ${i.length} open item(s)`,`complete or reassign ${i.join(", ")} before retiring the role`,{items:i});let r={...t.roles};return delete r[e],h({...t,roles:r},"role.retired",n,{role:e},o)}function J(t,e){return t.capabilities.includes(e)}function F(t,e){return Object.values(t.roles).filter(n=>J(n,e))}function q(t,e,n,o){return Object.values(t.roles).filter(i=>i.id!==o&&i.canApprove.includes(e)&&(n===void 0||i.capabilities.includes(n))).map(i=>i.id)}function Ae(t,e){return F(t,"approve-gate").filter(n=>n.canApprove.includes(e))}function ee(t,e,n){for(let o of e)F(t,o).length===0&&b$1("missing-capability",`no registered role has capability "${o}"`,`register a role whose capabilities include "${o}" (registerRole) before init`);for(let o of n){let i=F(t,o);i.length>1&&b$1("exclusive-capability",`capability "${o}" must belong to exactly one role but is held by ${i.map(r=>r.id).join(", ")}`,`remove "${o}" from all but one role`);}}function te(t,e){return e.length===0?[]:Object.values(t.roles).filter(n=>e.every(o=>J(n,o)))}function ke(t,e,...n){if(e==="human")return true;let o=A(t,e);return !!o&&n.some(i=>J(o,i))}function qe(t,e,...n){if(!ke(t,e,...n)){let o=Object.values(t.roles).filter(i=>n.some(r=>J(i,r))).map(i=>i.id);b$1("missing-capability",`"${e}" lacks capability ${n.map(i=>`"${i}"`).join(" or ")}`,`run this as one of: human${o.map(i=>`, ${i}`).join("")}`);}}function H(t,e){let n=t.stages.find(o=>o.id===e);return n||b$1("unknown-stage",`stage "${e}" does not exist`,`stages are: ${t.stages.map(o=>o.id).join(" \u2192 ")}`),n}function he(t,e){let n=t.stages.findIndex(o=>o.id===e);return n<0&&H(t,e),t.stages[n+1]}function we(t,e){return t.stages[t.stages.length-1]?.id===e}function B(t,e){return {...t,items:{...t.items,[e.id]:e}}}function ye(t,e,n){return B(t,n(j(t,e)))}function ve(t,e,n){return ye(t,e,o=>{let i={...o};for(let r of n)delete i[r];return i})}function j(t,e){let n=Object.hasOwn(t.items,e)?t.items[e]:void 0;return n||b$1("unknown-item",`item "${e}" does not exist`,`add it with addItem first; known items: ${Object.keys(t.items).join(", ")||"(none)"}`,{items:[e]}),n}function V(t,e,n){let o=e.filter(i=>!Object.hasOwn(t.items,i));o.length&&b$1("unknown-item",`${n} refers to unknown item(s) ${o.join(", ")}`,"add those items first or remove the reference",{items:o});}function De(t,e,n,o){c(e.id,"item id"),Object.hasOwn(t.items,e.id)&&b$1("duplicate-item",`item "${e.id}" already exists`,"use editItem to change it, or pick a new id",{items:[e.id]});let i=t.stages[0];i||b$1("config-invalid","state has no stages","create the state with at least one stage");let r=e.stage??i.id;H(t,r),V(t,e.dependsOn??[],`item "${e.id}".dependsOn`),e.affects&&V(t,e.affects,`item "${e.id}".affects`),e.parent!==void 0&&V(t,[e.parent],`item "${e.id}".parent`),e.role!==void 0&&!Object.hasOwn(t.roles,e.role)&&b$1("unknown-role",`role "${e.role}" does not exist`,`registered roles: ${Object.keys(t.roles).join(", ")}`);let{stage:s,...a}=e,l={type:"task",acceptance:[],dependsOn:[],...a,id:e.id,title:e.title,stage:r,status:"todo",evidence:[],blockers:[],transitions:[]},c$1=B(t,l);return h(c$1,"item.added",n,{id:l.id,type:l.type,stage:l.stage,weight:l.weight??null,priority:l.priority??null,phase:l.phase??null,parent:l.parent??null},o)}function _e(t,e,n,o,i){let r=j(t,e);n.dependsOn&&V(t,n.dependsOn,`item "${e}".dependsOn`),n.affects&&V(t,n.affects,`item "${e}".affects`),n.parent!==void 0&&V(t,[n.parent],`item "${e}".parent`),n.role!==void 0&&!Object.hasOwn(t.roles,n.role)&&b$1("unknown-role",`role "${n.role}" does not exist`,`registered roles: ${Object.keys(t.roles).join(", ")}`);let s=Object.keys(n).filter(c=>JSON.stringify(n[c])!==JSON.stringify(r[c]));s.length===0&&b$1("no-op",`editItem("${e}") changes nothing`,"pass at least one field with a different value",{items:[e]});let a={...r};for(let c of s)a[c]=n[c];let l=B(t,a);return h(l,"item.edited",o,{id:e,changed:s},i)}function E(t,e,n,o,i){let r=j(t,e),s=n.stage??r.stage;H(t,s),(r.status==="done"||r.status==="dropped")&&b$1("invalid-transition",`item "${e}" is ${r.status} and cannot move`,"create a new item (or a change-request) instead of reopening a finished one",{items:[e]}),s===r.stage&&n.status===r.status&&b$1("no-op",`item "${e}" is already ${r.status} in "${s}"`,"choose a different stage or status",{items:[e]});let a=b(i),l={...r,stage:s,status:n.status,transitions:[...r.transitions,{from:{stage:r.stage,status:r.status},to:{stage:s,status:n.status},at:a,by:o}]},c=B(t,l);return h(c,"item.transition",o,{id:e,from:{stage:r.stage,status:r.status},to:{stage:s,status:n.status}},a)}function K(t,e){let n=0,o=false;for(let i=t.events.length-1;i>=0;i--){let r=t.events[i];if(r.payload?.id===e.id){if(r.type==="item.rework"){o=true;break}r.type==="item.evidence"&&n++;}}return o?e.evidence.slice(Math.max(0,e.evidence.length-n)):e.evidence}function Fe(t,e,n,o){let i=j(t,e),r=b(o),s={...i,evidence:[...i.evidence,{...n,at:r}]},a=B(t,s);return h(a,"item.evidence",n.by,{id:e,kind:n.kind,ref:n.ref},r)}function oe(t,e,n,o,i,r){let s=j(t,e),a=b(r),l=`${e}-b${s.blockers.length+1}`,c=s.status==="blocked"?null:{from:{stage:s.stage,status:s.status},to:{stage:s.stage,status:"blocked"},at:a,by:i},p={...s,status:"blocked",blockers:[...s.blockers,{id:l,reason:n,owner:o,raisedAt:a}],transitions:c?[...s.transitions,c]:s.transitions},g=B(t,p);return h(g,"blocker.raised",i,{id:e,blocker:l,reason:n,owner:o,transition:c&&{from:c.from,to:c.to}},a)}function ne(t,e){for(let n=t.transitions.length-1;n>=0;n--){let o=t.transitions[n];if(o.to.status===e)return o}}function Ve(t,e,n,o,i,r){let s=j(t,e),a=s.blockers.findIndex(x=>x.id===n&&!x.clearedAt);a<0&&b$1("invalid-input",`item "${e}" has no open blocker "${n}"`,`open blockers: ${s.blockers.filter(x=>!x.clearedAt).map(x=>x.id).join(", ")||"(none)"}`,{items:[e]});let l=b(i),c=s.blockers.map((x,T)=>T===a?{...x,clearedAt:l}:x),p=c.some(x=>!x.clearedAt),g=ne(s,"blocked")?.from.status??"todo",u=s.stage,m=g,y=false;g==="in_progress"?(m="todo",u=ne(s,"in_progress")?.from.stage??s.stage):g==="awaiting_human"&&(m=H(t,s.stage).review?"review":"todo",y=true);let{role:W,...R}=s,v=p?null:{from:{stage:s.stage,status:"blocked"},to:{stage:u,status:m},at:l,by:o},M={...y&&!p?R:s,blockers:c,stage:p?s.stage:u,status:p?"blocked":m,transitions:v?[...s.transitions,v]:s.transitions},N=B(t,M);return h(N,"blocker.cleared",o,{id:e,blocker:n,transition:v&&{from:v.from,to:v.to},note:r??null},l)}function Q(t,e){return ve(t,e,["role"])}function ie(t,e,n,o,i){let r=j(t,e),s=he(t,r.stage);if(!s)return E(t,e,{status:"done"},n,i);if(we(t,s.id))return E(t,e,{stage:s.id,status:"done"},n,i);let a=o||s.review===true?"review":"todo";return Q(E(t,e,{stage:s.id,status:a},n,i),e)}function U(t,e,n){let o=[],i=K(t,e),r=(s,a,l)=>o.push({rule:s,severity:"error",item:e.id,message:a,fix:l});for(let s of n)switch(s.kind){case "evidence":i.some(a=>a.kind===s.evidenceKind)||r("policy:evidence",`item "${e.id}" has no evidence of kind "${s.evidenceKind}"`,`attach evidence { kind: "${s.evidenceKind}" } via addEvidence or in the handoff.produced`);break;case "acceptance-written":e.acceptance.length===0&&r("policy:acceptance-written",`item "${e.id}" has no acceptance criteria`,"editItem with a non-empty acceptance[] (needs define-acceptance)");break;case "estimate-present":e.weight===void 0&&r("policy:estimate-present",`item "${e.id}" has no weight`,"editItem with a weight (story points)");break;case "no-open-blockers":{let a=e.blockers.filter(l=>!l.clearedAt);a.length&&r("policy:no-open-blockers",`item "${e.id}" has ${a.length} open blocker(s)`,`clearBlocker ${a.map(l=>l.id).join(", ")}`);break}case "dependencies-done":{let a=e.dependsOn.filter(l=>t.items[l]?.status!=="done");a.length&&r("policy:dependencies-done",`item "${e.id}" depends on unfinished ${a.join(", ")}`,`finish ${a.join(", ")} first`);break}case "custom":i.some(a=>a.kind===`policy:${s.id}`)||r(`policy:custom:${s.id}`,`item "${e.id}" has not satisfied "${s.description}"`,`attach evidence { kind: "policy:${s.id}" } when it is satisfied`);break}return o}function Je(t,e,n,o){let i=U(t,e,n);i.length&&b$1("policy-unmet",`item "${e.id}" cannot ${o}: ${i.length} polic${i.length===1?"y":"ies"} unmet`,i.map(r=>r.fix).join("; "),{items:[e.id]});}function xe(t,e){let n=new Map(t.stages.map((i,r)=>[i.id,r])),o=n.get(e.stage);if(o!==void 0)for(let i=e.transitions.length-1;i>=0;i--){let r=e.transitions[i],s=n.get(r.from.stage);if(r.to.status==="in_progress"&&s!==void 0&&s<o)return r}}function L(t,e){let n=xe(t,e);if(n)return n.by;for(let o=e.transitions.length-1;o>=0;o--){let i=e.transitions[o];if(i.to.status==="in_progress")return i.by}}function be(t,e,n,o){let i=[],r=K(t,e);for(let a of n.evidence)r.some(l=>l.kind===a)||i.push({rule:"gate:evidence",severity:"error",item:e.id,message:`gate "${n.id}" needs evidence "${a}" on item "${e.id}"`,fix:`attach evidence { kind: "${a}" } before approving`});if(i.length)return {outcome:"fail",violations:i};let s=false;for(let a of n.requires){if(a==="human"){o!=="human"&&(s=true);continue}if(!q(t,n.id,a.capability).includes(o)){i.push({rule:"gate:capability",severity:"error",item:e.id,message:`"${o}" may not approve gate "${n.id}" (needs capability "${a.capability}" and canApprove "${n.id}")`,fix:`approve as one of: ${q(t,n.id,a.capability).join(", ")||"(no role qualifies; register one)"}`});continue}let c=L(t,e);if(c!==void 0&&c===o){let p=q(t,n.id,a.capability,o);i.push({rule:"conflict-of-interest",severity:"error",item:e.id,message:`role "${o}" did the work on "${e.id}" and may not approve it`,fix:`approve as a different role: ${p.join(", ")||"(register another approver)"}`});}}return i.length?{outcome:"fail",violations:i}:s?{outcome:"human"}:{outcome:"pass"}}function Xe(t,e,n){let o=b(n),i=`p${t.events.filter(a=>a.type==="pending.raised").length+1}`,r={...e,id:i,raisedAt:o},s={...t,pending:[...t.pending,r]};return e.item&&j(s,e.item).status!=="awaiting_human"&&(s=E(s,e.item,{status:"awaiting_human"},"system",o)),h(s,"pending.raised","system",{id:i,kind:e.kind,item:e.item??null,gate:e.gate??null},o)}function Ye(t,e,n,o,i,r,s){n!=="approve"&&n!=="reject"&&b$1("invalid-input",`decision must be "approve" or "reject" (got ${JSON.stringify(n)})`,"pass approve or reject");let a=t.pending.find(u=>u.id===e);a||b$1("unknown-pending",`no pending decision "${e}"`,`open decisions: ${t.pending.map(u=>u.id).join(", ")||"(none)"}`);let l=a.kind==="gate"&&a.item?j(t,a.item):void 0,c=l&&(t.stages.find(u=>a.gate!==void 0&&u.gate?.id===a.gate)?.gate??t.stages.find(u=>u.id===l.stage)?.gate);l&&c&&o!=="human"&&(c.requires.includes("human")?void 0:be(t,l,c,o))?.outcome!=="pass"&&b$1("gate-unmet",`"${o}" may not decide gate "${c.id}" on "${l.id}"`,`decide as one of: human${c.requires.flatMap(m=>m==="human"?[]:q(t,c.id,m.capability)).map(m=>`, ${m}`).join("")}`,{items:[l.id],rule:"gate"});let p=b(r),g={...t,pending:t.pending.filter(u=>u.id!==e)};if(g=h(g,"pending.decided",o,{id:e,decision:n,note:i,item:a.item??null,gate:a.gate??null},p),l){let u=l.id,m=a.gate??c?.id??null;if(n==="approve"){let y=false;for(let W=t.events.length-1;W>=0;W--){let R=t.events[W];if(!(R.type!=="item.completed"||R.payload.id!==u)){y=R.payload.verdict==="needs-review";break}}g=ie(g,u,o,y,p),g=h(g,"gate.passed",o,{item:u,gate:m},p);}else {let y=c?.onFail??{action:"block"};y.action==="return-to"?g=Q(E(g,u,{stage:y.stage,status:"todo"},o,p),u):g=oe(g,u,`gate "${m??"?"}" rejected: ${i||"no reason given"}`,o,o,p),g=h(g,"gate.failed",o,{item:u,gate:m,note:i},p);}}return s?.afterDecide&&(g=s.afterDecide(g,a,n,o,i,p)),g}var tt={tokens:0,turns:0,wallclockMs:0};function nt(t,e){return {tokens:t.tokens+e.tokensIn+e.tokensOut,turns:t.turns+1,wallclockMs:t.wallclockMs+e.durationMs}}function re(t,e){let n={};return t.tokens!==void 0&&(n.tokens=Math.max(0,t.tokens-e.tokens)),t.turns!==void 0&&(n.turns=Math.max(0,t.turns-e.turns)),t.wallclockMs!==void 0&&(n.wallclockMs=Math.max(0,t.wallclockMs-e.wallclockMs)),n}function ot(t,e){return t.tokens!==void 0&&e.tokens>=t.tokens||t.turns!==void 0&&e.turns>=t.turns||t.wallclockMs!==void 0&&e.wallclockMs>=t.wallclockMs}function se(t,e,n=2e4,o="per-weight"){let i=e??1,r=[];for(let l of t.accounting){if(l.estimate===true)continue;let c=l.tokensIn+l.tokensOut;if(o==="per-call"){r.push(c);continue}let p=t.items[l.item]?.weight;p===void 0||p<=0||r.push(c/p);}if(r.length===0)return o==="per-call"?n:n*i;r.sort((l,c)=>l-c);let s=Math.floor(r.length/2),a=r.length%2?r[s]:(r[s-1]+r[s])/2;return Math.round(o==="per-call"?a:a*i)}function Z(t){return t.iterations.find(e=>e.endedAt===void 0)}function le(t,e,n){if(e.role){let r=A(t,e.role);return r||b$1("unknown-role",`item "${e.id}" is assigned to unknown role "${e.role}"`,"editItem with an existing role id"),r}let o=n?n(e):void 0;if(o!==void 0){let r=A(t,o);return r||b$1("unknown-role",`the methodology picked unknown role "${o}" for item "${e.id}"`,`registered roles: ${Object.keys(t.roles).join(", ")||"(none)"}`,{items:[e.id]}),r}if(e.status==="review"){let r=L(t,e),s=F(t,"review"),l=s.find(c=>c.id!==r)??(s.length===1?s[0]:void 0);return l||b$1("missing-capability",`no role has capability "review" for item "${e.id}"`,"register a role with capability review",{items:[e.id]}),l}let i=F(t,"deliver")[0];return i||b$1("missing-capability",`no role has capability "deliver" for item "${e.id}"`,"register a role with capability deliver",{items:[e.id]}),i}function ae(t){let e={};for(let n of Object.values(t.roles))n.maxConcurrent!==void 0&&(e[n.resourceClass??n.id]=n.maxConcurrent);return e}function We(t,e,n,o){let i=new Set(t.map(r=>r.id));return t.map(r=>{let s=le(e,r,o),a={id:r.id,data:{id:r.id},dependsOn:r.dependsOn.filter(c=>i.has(c)),resourceClass:s.resourceClass??s.id},l=n?n(r):r.priority;return l!==void 0&&(a.priority=l),r.weight!==void 0&&(a.weight=r.weight),r.deadline!==void 0&&(a.deadline=Date.parse(r.deadline)),a})}function pt(t,e,n={}){let o=b(n.now),i=e.candidates(t),r=i.filter(d=>d.dependsOn.every(k=>t.items[k]?.status==="done"||i.some(S=>S.id===k))),s=i.filter(d=>d.dependsOn.every(k=>t.items[k]?.status==="done"));if(r.length===0)return {state:t,dispatched:[],skipped:[],reason:Z(t)?.closing?"budget-exhausted":"no-candidates"};let a=e.plannerOptions(t),l={schedulerMode:a.schedulerMode,resourceCaps:ae(t)};if(a.concurrencyCap!==void 0&&(l.concurrencyCap=a.concurrencyCap),a.fairnessPolicy!==void 0&&(l.fairnessPolicy=a.fairnessPolicy),a.maxDeferralRounds!==void 0&&(l.maxDeferralRounds=a.maxDeferralRounds),a.deadlineStrategy!==void 0&&(l.deadlineStrategy=a.deadlineStrategy),a.weightStrategy!==void 0&&(l.weightStrategy=a.weightStrategy),a.tieBreaker!==void 0){let d=a.tieBreaker;l.tieBreaker=(k,S)=>d(t.items[k.data.id],t.items[S.data.id]);}let c,p;try{let d=new ExFlow(l);for(let S of We(r,t,a.priorityOf,a.roleFor))d.addEntity(S);let k=d.resolveExecutionDetails();c=(k.plan.batches[0]??[]).map(S=>S.id),p=k.metrics;}catch(d){throw d instanceof ExFlowRuntimeError&&b$1("planner-error",`ex-flow refused the graph: [${d.code}] ${d.message}`,"fix the item graph (cycles, duplicate ids) with editItem; see diagnostics in the message",{items:r.map(k=>k.id)}),d}let g=c.map(d=>t.items[d]).filter(d=>d.dependsOn.every(k=>t.items[k]?.status==="done")),u=Object.values(t.items).filter(d=>d.status==="in_progress"),m=new Set(a.wipCounts??["in_progress"]),y=Object.values(t.items).filter(d=>m.has(d.status)),W={};for(let d of u){let k=d.role?A(t,d.role):void 0,S=k?k.resourceClass??k.id:"?";W[S]=(W[S]??0)+1;}let R=ae(t),v=Z(t),M=v?re(v.budget,v.spent):{},N=M.tokens===void 0?void 0:Math.max(0,M.tokens-(a.reservedTokens??0)),x=v?Object.values(t.items).filter(d=>(d.iteration===v.id||v.committed.includes(d.id))&&d.status==="in_progress").length:0,T=M.turns===void 0?void 0:M.turns-x,fe=M.wallclockMs!==void 0&&M.wallclockMs<=0,ue=a.estimateMode??"per-weight",pe=n.fallbackTokensPerWeight??a.fallbackTokensPerWeight,ge=Math.min(n.max??1/0,a.concurrencyCap??1/0),C=[],O=[],w,$=t;for(let d of g){if(C.length>=ge){w="wip-full";break}let k=typeof a.dispatchStage=="function"?a.dispatchStage(d):a.dispatchStage,S=d.status==="todo"&&k!==void 0?k:d.stage,D=H(t,S),X=d.type==="question"?[]:U(t,d,D.entryPolicy);if(X.length>0){O.push({id:d.id,reason:"entry-policy",detail:X.map(I=>I.message).join("; ")});continue}let z=a.wipLimitOf?a.wipLimitOf(D,d):D.wipLimit;if(z!==void 0&&y.filter(I=>I.stage===D.id&&I.id!==d.id).length+C.filter(I=>I.stage===D.id).length>=z){w="wip-full",O.push({id:d.id,reason:"wip",detail:`stage "${D.id}" is at its WIP limit of ${z}`});continue}let G=le(t,d,a.roleFor),P=G.resourceClass??G.id;if(R[P]!==void 0&&(W[P]??0)>=R[P]){w="wip-full",O.push({id:d.id,reason:"resource-cap",detail:`resource class "${P}" is at its cap of ${R[P]}`});continue}if(T!==void 0&&T<=0){w="budget-exhausted",O.push({id:d.id,reason:"budget",detail:`turns budget spent: ${v.spent.turns} used + ${x+C.length} in flight of ${v.budget.turns}`});continue}if(fe){w="budget-exhausted",O.push({id:d.id,reason:"budget",detail:"wall-clock budget spent"});continue}if(N!==void 0){let I=se(t,d.weight,pe,ue);if(I>N){w="budget-exhausted",O.push({id:d.id,reason:"budget",detail:`needs about ${I} tokens, ${N} left in the iteration`});continue}N-=I;}W[P]=(W[P]??0)+1,T!==void 0&&(T-=1),$=E($,d.id,{stage:S,status:"in_progress"},G.id,o),$={...$,items:{...$.items,[d.id]:{...$.items[d.id],role:G.id}}},C.push($.items[d.id]);}return w===void 0&&O.some(d=>d.reason==="entry-policy")&&(w="policy-blocked"),w===void 0&&C.length<s.length&&(w="wip-full"),C.length===0&&w===void 0&&(w="no-candidates"),$=h($,"planner.resolved","planner",{dispatched:C.map(d=>d.id),reason:w??null,skipped:O,metrics:p},o),w?{state:$,dispatched:C,skipped:O,reason:w}:{state:$,dispatched:C,skipped:O}}function de(t){return [{id:"separation-lost",severity:"warning",check(o,i){return i.type!=="init"&&i.type!=="role.register"?[]:te(o,t.requiredCapabilities).map(r=>({rule:"separation-lost",severity:"warning",message:`role "${r.id}" holds every required capability (${t.requiredCapabilities.join(", ")}); no separation of duties`,fix:"fine for a solo operator; otherwise split capabilities across roles"}))}},{id:"conflict-of-interest",severity:"error",check(o,i){if(i.type!=="complete")return [];let r=i.payload?.handoff;if(!r)return [];let s=r.verdict??"done";if(s!=="done"&&s!=="needs-review")return [];let a=o.items[r.item];if(!a)return [];let l=o.stages.find(p=>p.id===a.stage)?.gate;if(!l||!l.requires.some(p=>p!=="human"))return [];if(L(o,a)!==r.role)return [];let c=q(o,l.id,void 0,r.role);return [{rule:"conflict-of-interest",severity:"error",item:a.id,message:`role "${r.role}" authored "${a.id}" and may not pass gate "${l.id}" on it`,fix:`hand the gate to another approver: ${c.join(", ")||"(register one)"}`}]}}]}function Oe(t,e,n){let o=[];for(let i of [...de(e),...e.rules])o.push(...i.check(t,n));return o}function ce(t,e,n,o){let i=Oe(t,e,n),r=i.filter(s=>s.severity==="error");return r.length&&b$1("rule-violation",`${n.type} violates ${r.map(s=>s.rule).join(", ")}: ${r.map(s=>s.message).join("; ")}`,r.map(s=>s.fix).join("; "),{rule:r[0].rule,items:r.map(s=>s.item).filter(s=>!!s)}),{state:o(t),warnings:i.filter(s=>s.severity==="warning")}}function St(t){let e=t.methodology,n=e.validateConfig(t.config),o=t.stages??e.defaultStages(n),i=t.roles??e.defaultRoles(n),r=t.now!==void 0?{methodology:e.name,config:n,stages:o,roles:i,now:t.now}:{methodology:e.name,config:n,stages:o,roles:i},s=Y(r);return ee(s,e.requiredCapabilities,e.exclusiveCapabilities),ce(s,e,{type:"init",by:t.by??"system"},a=>a)}function $t(t,e,n,o,i){(typeof n!="object"||n===null||Array.isArray(n)||Object.keys(n).length===0)&&b$1("invalid-input","config patch must be a non-empty object",'pass e.g. { "sprintBudget": { "tokens": 1500000 } } to exwf config set');let r=Z(t);r&&b$1("invalid-input",`config cannot change while ${r.id} is open`,"close it first (exwf ceremony review or cancel; a waterfall phase closes at its gate), then run exwf config set");let s=(e.lockedConfigKeys??[]).filter(u=>Object.hasOwn(n,u));s.length&&b$1("invalid-input",`config key(s) ${s.join(", ")} cannot change after init`,e.name==="kanban"?"use the service-delivery-review cadence for columns and classes of service":"start a new workflow with exwf init to change them");let a=t.config??{},l=e.validateConfig({...a,...n}),c=Object.keys(n).filter(u=>!Object.hasOwn(l,u));c.length&&b$1("invalid-input",`unknown config key(s) ${c.join(", ")}`,`known keys: ${Object.keys(l).join(", ")}`);let p=Object.keys(n).filter(u=>JSON.stringify(a[u])!==JSON.stringify(l[u]));p.length===0&&b$1("no-op","config patch changes nothing","pass at least one key with a different value to exwf config set");let g=u=>Object.fromEntries(p.map(m=>[m,u[m]]));return ce(t,e,{type:"config.change",by:o,payload:{patch:n}},u=>{let m=b(i),y=h({...u,config:l},"config.changed",o,{changed:p,before:g(a),after:g(l)},m);return e.afterConfigChange&&(y=e.afterConfigChange(y,m)),y})}export{Ve as A,Q as B,ie as C,U as D,Je as E,xe as F,L as G,be as H,Xe as I,Ye as J,tt as K,nt as L,re as M,ot as N,se as O,Z as P,le as Q,ae as R,We as S,pt as T,de as U,Oe as V,ce as W,St as X,$t as Y,b as a,Y as b,h as c,je as d,A as e,Ee as f,Pe as g,J as h,F as i,q as j,Ae as k,ee as l,te as m,ke as n,qe as o,H as p,he as q,we as r,ye as s,ve as t,j as u,De as v,_e as w,E as x,Fe as y,oe as z};//# sourceMappingURL=chunk-6P3OKXSK.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-6P3OKXSK.mjs.map
|