ex-workflow 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +147 -13
- 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-Gckmqj74.d.ts → budget-BuQ9GWsg.d.ts} +1 -1
- package/dist/{budget-Bm839Qw0.d.cts → budget-DDqQQIgp.d.cts} +1 -1
- package/dist/{chunk-LIATP6LY.mjs → chunk-3QUIRAXO.mjs} +2 -2
- package/dist/{chunk-LIATP6LY.mjs.map → chunk-3QUIRAXO.mjs.map} +1 -1
- package/dist/chunk-3RJ4RNPG.cjs +2 -0
- package/dist/chunk-3RJ4RNPG.cjs.map +1 -0
- package/dist/chunk-66BO7JFR.cjs +2 -0
- package/dist/chunk-66BO7JFR.cjs.map +1 -0
- package/dist/chunk-6PFJYRM7.cjs +2 -0
- package/dist/chunk-6PFJYRM7.cjs.map +1 -0
- package/dist/chunk-76ITDJDM.cjs +2 -0
- package/dist/{chunk-QAENYYU6.cjs.map → chunk-76ITDJDM.cjs.map} +1 -1
- package/dist/chunk-AWFR3Q4M.mjs +2 -0
- package/dist/{chunk-32NVJV5C.mjs.map → chunk-AWFR3Q4M.mjs.map} +1 -1
- package/dist/chunk-BD665RYK.mjs +2 -0
- package/dist/chunk-BD665RYK.mjs.map +1 -0
- package/dist/chunk-BGKXIRGS.mjs +2 -0
- package/dist/chunk-BGKXIRGS.mjs.map +1 -0
- package/dist/chunk-BNKKOAMP.mjs +2 -0
- package/dist/{chunk-OZAYOPLB.mjs.map → chunk-BNKKOAMP.mjs.map} +1 -1
- package/dist/{chunk-IIEKK2S3.cjs → chunk-CPM2SPDX.cjs} +2 -2
- package/dist/{chunk-IIEKK2S3.cjs.map → chunk-CPM2SPDX.cjs.map} +1 -1
- package/dist/chunk-DVFTTBCT.cjs +3 -0
- package/dist/chunk-DVFTTBCT.cjs.map +1 -0
- package/dist/{chunk-U3RU5LOF.cjs → chunk-G6QELJRL.cjs} +2 -2
- package/dist/{chunk-U3RU5LOF.cjs.map → chunk-G6QELJRL.cjs.map} +1 -1
- package/dist/{chunk-6D6FL3XK.mjs → chunk-HXEJP6KF.mjs} +2 -2
- package/dist/{chunk-6D6FL3XK.mjs.map → chunk-HXEJP6KF.mjs.map} +1 -1
- package/dist/chunk-ILNSTPPV.mjs +2 -0
- package/dist/chunk-ILNSTPPV.mjs.map +1 -0
- package/dist/{chunk-RXY434DX.cjs → chunk-KA6DVHO5.cjs} +4 -4
- package/dist/{chunk-RXY434DX.cjs.map → chunk-KA6DVHO5.cjs.map} +1 -1
- package/dist/chunk-KLOSFZFK.cjs +2 -0
- package/dist/chunk-KLOSFZFK.cjs.map +1 -0
- package/dist/chunk-LQJPLXFR.cjs +2 -0
- package/dist/chunk-LQJPLXFR.cjs.map +1 -0
- package/dist/chunk-MUQ4FKVH.mjs +2 -0
- package/dist/chunk-MUQ4FKVH.mjs.map +1 -0
- package/dist/chunk-N2NANHRW.mjs +2 -0
- package/dist/{chunk-4HG6A3SF.mjs.map → chunk-N2NANHRW.mjs.map} +1 -1
- package/dist/chunk-NNQ3RHDP.mjs +2 -0
- package/dist/chunk-NNQ3RHDP.mjs.map +1 -0
- package/dist/chunk-OAJ4KV4F.mjs +2 -0
- package/dist/{chunk-BYPFTO7P.mjs.map → chunk-OAJ4KV4F.mjs.map} +1 -1
- package/dist/chunk-OFFQTZEY.cjs +2 -0
- package/dist/chunk-OFFQTZEY.cjs.map +1 -0
- package/dist/{chunk-3GKYL6VB.mjs → chunk-ONVAUZOD.mjs} +3 -3
- package/dist/{chunk-3GKYL6VB.mjs.map → chunk-ONVAUZOD.mjs.map} +1 -1
- package/dist/chunk-QJMOCISZ.mjs +3 -0
- package/dist/chunk-QJMOCISZ.mjs.map +1 -0
- package/dist/chunk-QKW26EV2.mjs +2 -0
- package/dist/chunk-QKW26EV2.mjs.map +1 -0
- package/dist/{chunk-W2P27645.cjs → chunk-RMXEQ5HN.cjs} +2 -2
- package/dist/{chunk-W2P27645.cjs.map → chunk-RMXEQ5HN.cjs.map} +1 -1
- package/dist/chunk-TBLIZIWH.cjs +2 -0
- package/dist/chunk-TBLIZIWH.cjs.map +1 -0
- package/dist/chunk-U23IRPFF.cjs +2 -0
- package/dist/{chunk-SFYUJQYW.cjs.map → chunk-U23IRPFF.cjs.map} +1 -1
- package/dist/chunk-WM3JM3H7.mjs +2 -0
- package/dist/chunk-WM3JM3H7.mjs.map +1 -0
- package/dist/chunk-WU5JELOM.mjs +2 -0
- package/dist/chunk-WU5JELOM.mjs.map +1 -0
- package/dist/chunk-YNYIHJOC.mjs +2 -0
- package/dist/chunk-YNYIHJOC.mjs.map +1 -0
- package/dist/chunk-YRXFEM3F.cjs +2 -0
- package/dist/chunk-YRXFEM3F.cjs.map +1 -0
- package/dist/{chunk-K4VSMIJZ.cjs → chunk-ZDT2BZGU.cjs} +2 -2
- package/dist/{chunk-K4VSMIJZ.cjs.map → chunk-ZDT2BZGU.cjs.map} +1 -1
- package/dist/{chunk-OVR5CK3R.cjs → chunk-ZK3V66NC.cjs} +2 -2
- package/dist/{chunk-OVR5CK3R.cjs.map → chunk-ZK3V66NC.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 +1 -1
- package/dist/experimentation/index.d.cts +2 -2
- package/dist/experimentation/index.d.ts +2 -2
- package/dist/experimentation/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -12
- package/dist/index.d.ts +15 -12
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/investigation/index.cjs +1 -1
- package/dist/investigation/index.d.cts +2 -2
- package/dist/investigation/index.d.ts +2 -2
- package/dist/investigation/index.mjs +1 -1
- 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/policies/index.cjs +2 -0
- package/dist/policies/index.cjs.map +1 -0
- package/dist/policies/index.d.cts +202 -0
- package/dist/policies/index.d.ts +202 -0
- package/dist/policies/index.mjs +2 -0
- package/dist/policies/index.mjs.map +1 -0
- package/dist/registry/index.cjs +1 -1
- package/dist/registry/index.d.cts +1 -1
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.mjs +1 -1
- package/dist/schema/index.cjs +1 -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-DjePDfms.d.cts → types-DLOtndDY.d.cts} +61 -1
- package/dist/{types-DjePDfms.d.ts → types-DLOtndDY.d.ts} +61 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- 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 +14 -1
- package/dist/chunk-32NVJV5C.mjs +0 -2
- package/dist/chunk-3O5MPAJT.cjs +0 -2
- package/dist/chunk-3O5MPAJT.cjs.map +0 -1
- package/dist/chunk-43GLYYA2.cjs +0 -3
- package/dist/chunk-43GLYYA2.cjs.map +0 -1
- package/dist/chunk-4HG6A3SF.mjs +0 -2
- package/dist/chunk-7EF47R2J.mjs +0 -2
- package/dist/chunk-7EF47R2J.mjs.map +0 -1
- package/dist/chunk-BD76VFI4.mjs +0 -3
- package/dist/chunk-BD76VFI4.mjs.map +0 -1
- package/dist/chunk-BHAEPYRJ.cjs +0 -2
- package/dist/chunk-BHAEPYRJ.cjs.map +0 -1
- package/dist/chunk-BYPFTO7P.mjs +0 -2
- package/dist/chunk-FDZB73PH.mjs +0 -2
- package/dist/chunk-FDZB73PH.mjs.map +0 -1
- package/dist/chunk-JNLWI4JM.mjs +0 -2
- package/dist/chunk-JNLWI4JM.mjs.map +0 -1
- package/dist/chunk-LCN4UNYK.cjs +0 -2
- package/dist/chunk-LCN4UNYK.cjs.map +0 -1
- package/dist/chunk-MB465DI4.mjs +0 -2
- package/dist/chunk-MB465DI4.mjs.map +0 -1
- package/dist/chunk-OZAYOPLB.mjs +0 -2
- package/dist/chunk-QAENYYU6.cjs +0 -2
- package/dist/chunk-SFYUJQYW.cjs +0 -2
- package/dist/chunk-UUWDQVIJ.mjs +0 -2
- package/dist/chunk-UUWDQVIJ.mjs.map +0 -1
- package/dist/chunk-VXOZIP77.cjs +0 -2
- package/dist/chunk-VXOZIP77.cjs.map +0 -1
- package/dist/chunk-WPVL27G4.mjs +0 -2
- package/dist/chunk-WPVL27G4.mjs.map +0 -1
- package/dist/chunk-Z43GUETW.cjs +0 -2
- package/dist/chunk-Z43GUETW.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.4.0 (2026-11-09)
|
|
4
|
+
|
|
5
|
+
Owner follow-ups of 1.3.0: three independence holes closed, each failing closed (a check that passed in 1.3 may refuse in 1.4, never the reverse): a worker self-attesting `context-grounded` (#47), a gate approved by an earlier author (#48), and a later snapshot dropping a required claim (#49). The decisions, the reproductions and the release-gate rows are in the design spec, section 28. The owner chose a minor release for these tightenings; the migration for each is below.
|
|
6
|
+
|
|
7
|
+
- Reserved policy `context-grounded` (#47): `evaluatePolicies` no longer accepts evidence `policy:context-grounded` for it. When no `customPolicy` hook answers it, the policy fails `policy:custom:context-grounded`, and the fix names `withContextGrounding` and `recordContextSnapshot`. A worker can therefore no longer attest the policy through `handoff.produced`. Every other custom policy keeps the 1.2 evidence check.
|
|
8
|
+
- CLI and context grounding (#47): every `exwf` command runs the registry methodology with the grounding hooks added (internal `withGroundingHooks`, which `withContextGrounding` now builds on). `exwf next`, `complete` and `brief` judge a `context-grounded` stage by the snapshots an SDK host recorded. No command or flag changes.
|
|
9
|
+
- Ceremonies (#47, gate): `withContextGrounding` refuses, with `invalid-input`, a stage whose policies a built-in ceremony checks without the hook: the Kanban first column's exit (`replenishment`), the Scrum `backlog` exit (Sprint Planning) and the Experimentation `building` entry. A policy there could never pass.
|
|
10
|
+
- Conflict of interest (#48): `checkGate`, `decide` and the Waterfall rule `approver-not-author` refuse an approval by any author of the item, not only the last one. The authors are every role dispatched from a stage before the gated one since the last rework, plus earlier work the rework did not send back, plus `authorOf`. A dispatch from a stage not in `state.stages` counts. A reviewer dispatched into the gated stage is still not an author. The fix names only non-authors, or says to register one.
|
|
11
|
+
- Planner (#48): a review goes to a reviewer that did none of the work when one exists, else to the first reviewer (whom the gate then refuses until a non-author approver is registered). One item can no longer fail the whole `next`.
|
|
12
|
+
- Context snapshots (#49): `contextOf` carries the `required` claims of every other valid fresh snapshot of the item (earlier or later), whoever recorded it. A carried claim the latest snapshot lacks is reported unverified, so `context-grounded` fails. Only an `item.rework` clears carried claims.
|
|
13
|
+
- Internal: `authorOf` and `lastDispatchBefore` move from `src/core/gates.ts` to `src/core/authors.ts` (still exported from the root entry), and the event index moves from `src/common` to `src/core`.
|
|
14
|
+
- Size: owner approved 2026-11-09 (spec 28), measured. `core+scrum` 61884 → 63954 B; every `core+<methodology>` and `core+registry` grows about +2070 B. `core+policies` 56597 → 58726 B, `dist/index.mjs` 1364 → 1398 B, `dist/{waterfall,registry}/index.mjs` +30 B each. `dist/policies/index.mjs` ratchets down 19820 → 9115 B. The version bump changed no size.
|
|
15
|
+
|
|
16
|
+
**Behaviour changes and migration.**
|
|
17
|
+
|
|
18
|
+
- **`context-grounded`:** without the hook, an item that passed on `policy:context-grounded` evidence is now skipped by `next` (reason `entry-policy`) and refused by `complete` (`policy-unmet`). Plan and complete through `withContextGrounding(m, { entry })` (or `exwf`), and record a qualifying snapshot with `recordContextSnapshot` (by `human` or a registered role that did not work on the item). If one of your own custom policies is named `context-grounded`, rename it.
|
|
19
|
+
- **Conflict of interest:** a role that worked on an item in any earlier stage (for example the developer or the tester before a `code-review` gate) may no longer approve its gate. Register another role with the gate's capability and `canApprove`, or decide as `human`.
|
|
20
|
+
- **Snapshots:** a later snapshot that drops a required claim no longer grounds the item. Repeat the claim with a source, or rework the item.
|
|
21
|
+
|
|
22
|
+
Compatibility: `state.json` unchanged (no new field), and a `.workflow/state.json` written by any earlier release loads unchanged (`test/compat.test.ts` replays the fixtures through 1.3.0). Schema documents: unchanged (ten). Event kinds: unchanged (71). Exports: unchanged (`test/api-surface.json` has no diff; `authorOf` and `lastDispatchBefore` keep their root export). CLI: unchanged (`USAGE`, commands, flags). Error codes: unchanged. Runtime dependencies: unchanged (`ex-flow`, `exsorted`). The deliberate behaviour changes are the three above; there is none for a run where no author approves its own item, no `context-grounded` policy rests on evidence, and snapshots repeat their required claims. `VERSION` is `"1.4.0"`.
|
|
23
|
+
|
|
24
|
+
## 1.3.0 (2026-11-06)
|
|
25
|
+
|
|
26
|
+
Composable policies: three opt-in policies a host adds to any methodology by wrapping it, risk-adaptive gates (#35), context-grounded entry (#36) and run comparison (#34), shipped from the new entry `ex-workflow/policies`; core gains only optional hooks that do nothing when unused. The decisions are in the design spec, section 27. Every change is additive.
|
|
27
|
+
|
|
28
|
+
- Entry point: `ex-workflow/policies` (ESM, CommonJS, `.d.ts`) exports `withRiskGate`, `recordRiskAssessment`, `riskEscalation`, `DEFAULT_RISK_TABLE`, `withContextGrounding`, `recordContextSnapshot`, `recordRepoChange`, `contextOf`, `contextGroundedViolations` and `compareRuns`, with the types `RiskLevel`, `RiskTable`, `RiskAssessmentData`, `RiskAssessmentInput`, `RiskGateOptions`, `ContextGroundingOptions`, `ContextSnapshotInput`, `RepoChangeInput`, `CompareRunsOptions`, `RunRecord`, `RunMetrics`, `VariantResult` and `RunComparison`. The root entry exports no new runtime name, so core plus one methodology does not carry the policies. The policies are SDK-only; the CLI is unchanged.
|
|
29
|
+
- Core hooks: `Methodology` gains three optional members, `escalateGate(state, item, gate)` (returns a `GateEscalation`), `customPolicy(state, item, policy)` (answers a `custom` stage policy) and `briefContext(state, item)` (fills the new optional `Brief.context`). `Evidence` gains the optional `data` (structured content a policy reads). `evaluatePolicies` and `assertPolicies` take an optional trailing methodology; their 1.1 signature stays the last overload. New root types `GateEscalation`, `BriefContext`, `ContextAssumption`, `ContextSnapshotData` (type-only).
|
|
30
|
+
- Risk-adaptive gates (#35): `recordRiskAssessment` records evidence `risk-assessment` (`data: { level, factors, subject? }`, action `risk.assess`) by `human` or an independent role with `verify`. `withRiskGate(m, { gates, table? })` makes the listed gates add the requirements of the strictest valid fresh assessment's level (`DEFAULT_RISK_TABLE`: `high` and `critical` add `"human"`; a missing, invalid or non-independent assessment counts as `critical`); a custom table must be monotone. Escalation only ever appends to the static gate (principles rule 17). `complete()` appends the new event **`gate.resolved`** `{ item, gate, requires, evidence, reason }` before `gate.passed` or `pending.raised`, and `decide()` (also `exwf decide`) judges a pending against the resolution recorded with it, so a role cannot approve a pending escalated to a human. `riskEscalation` is the resolver on its own.
|
|
31
|
+
- Context-grounded entry (#36): `recordContextSnapshot` records evidence `context-snapshot` (`data: { revision, assumptions }`, each assumption a `claim` with optional `required` and `source { path, lines?, hash }`, action `context.snapshot`); `recordRepoChange({ revision, paths })` appends the new event **`repo.changed`** (action `repo.change`) and warns `context-stale` for each in-flight item whose snapshot it made stale. `withContextGrounding(m, { entry, exit? })` adds the custom policy `context-grounded` to those stages: an item needs a fresh, non-stale qualifying snapshot (at least one sourced assumption, recorded by `human` or a registered role that did not work on the item) with every `required` claim sourced; `next` skips it otherwise with reason `entry-policy`, and its brief carries `context` (what was verified, what went stale, what is unverified). `contextOf` and `contextGroundedViolations` answer on their own. Paths are repository-relative POSIX paths as Git lists them (`git diff --name-only -z`), matched exactly.
|
|
32
|
+
- Run comparison (#34): `compareRuns(runs, { baseline, mustPass?, passTolerance?, costTolerance? })` derives per run tokens, duration, turns, human interventions, reworks, escalations and items done, ranks the variants (scenario-weighted pass rate, then cost) and names a winner only when an eligible variant beats the baseline beyond the tolerances, else `winner: null` with the reason. Scenario suites, running variants and scoring stay host-side.
|
|
33
|
+
- Principles: rule 5 adds the snapshot stale rule (a later `repo.changed` citing a source path, by event order); new rule 17 "Gate escalation only tightens".
|
|
34
|
+
- Tests: 1.2.0 compatibility fixtures (all five methodologies) load unchanged.
|
|
35
|
+
- Size: owner approved 2026-11-06 (spec 27), measured: `core+scrum` 61031 → 61884 B, `core+kanban` 68951 → 69804 B, `core+waterfall` 69379 → 70232 B, `core+investigation` 53566 → 54419 B, `core+experimentation` 57058 → 57911 B, `core+registry` 159765 → 160618 B (+853 B each: the three core hooks, `gate.resolved` and the `decide` lookup), `schema` 28942 → 28987 B (`Evidence.data`), `dist/index.mjs` 1330 → 1364 B, `dist/{investigation,experimentation,registry}/index.mjs` +30 B each (one more shared chunk import); `dist/policies/index.mjs` (19820 B) and `core+policies` (56597 B) seeded at measured size. The version bump changed no size.
|
|
36
|
+
|
|
37
|
+
Fixed (release gate of 1.3.0, spec 27 rows F1/F2), in code new in this release:
|
|
38
|
+
|
|
39
|
+
- Independence: both policies compare the assessor or snapshot recorder with every role dispatched on the item since its last rework, its `role` and its author (G1-1, G2-12), counting the transitions blockers append (G5-1); a snapshot qualifies only with a sourced assumption and a non-worker `human` or registered recorder, at record and at read time (G1-2, G2-1, G2-2).
|
|
40
|
+
- `decide` reads the `gate.resolved` recorded with its pending in one backward scan, so a resolution appended later cannot relax it and a long log costs no more than in 1.2 (G3-1, G2-5); a malformed requirement is skipped, never a `TypeError` (G1-7, G2-4).
|
|
41
|
+
- `recordRepoChange`, `contextOf` and the planner read the log through a cached per-log index: 10,000 in-flight items 9.6 s → 24 ms (G3-2 to G3-5, G2-6); `contextOf` returns copies (G2-9).
|
|
42
|
+
- Paths: control, bidirectional and non-NFC characters, surrounding whitespace and paths over 4096 characters are refused (G2-8, G4-4, G4-5).
|
|
43
|
+
- Risk options: one validator for `withRiskGate` and `riskEscalation` (no `TypeError` on `{}`), a monotone table required with requirements and evidence kinds compared apart, own properties only (G1-4, G1-6, G2-10, G5-4, G5-5).
|
|
44
|
+
- `compareRuns`: scenario-weighted pass rate (G1-3), non-finite totals refused and inputs read as own properties only (G2-7, G4-8).
|
|
45
|
+
- The `ex-workflow/policies` barrel is `src/policies/index.ts` (G4-3); 1.2.0 compatibility fixtures added (G4-2).
|
|
46
|
+
|
|
47
|
+
Compatibility: additive. `state.json` gains one optional field, `Evidence.data`, written only by the policy recorders; a `.workflow/state.json` written by any earlier release loads unchanged (`test/compat.test.ts` replays the fixtures through 1.2.0). No downgrade: 1.2.x cannot load a state carrying `Evidence.data`, because its schema closes `Evidence` (README Known limitations). Schema documents: still ten; `workflowStateSchema` gains the optional open `data` on `Evidence`. Event kinds: 69 → 71 (`gate.resolved`, `repo.changed`); existing payloads unchanged. Exports: the new entry `ex-workflow/policies` (ten runtime exports above); the root entry and `ex-workflow/types` gain the types `GateEscalation`, `BriefContext`, `ContextAssumption` and `ContextSnapshotData`; `Methodology` gains the optional `escalateGate`, `customPolicy` and `briefContext`, `Brief` the optional `context`; `evaluatePolicies` and `assertPolicies` an optional trailing parameter (1.1 signature last); nothing is removed (`test/api-surface.json` gains rows only). CLI: unchanged (`USAGE`, commands, flags); `exwf decide` honours an escalation an SDK run recorded, `exwf complete` checks the static gate, and without the wrapper a `context-grounded` stage falls back to the 1.2 `policy:context-grounded` evidence check. Error codes: unchanged (the recorders and options refuse with `invalid-input`; an unmet widened gate fails `gate-unmet`). Behaviour changes: none for a methodology without the hooks, so none for the built-ins and the CLI on states they wrote; `decide` on a pending raised under an escalation requires what the escalation added. Runtime dependencies: unchanged (`ex-flow`, `exsorted`). `VERSION` is `"1.3.0"`.
|
|
48
|
+
|
|
3
49
|
## 1.2.0 (2026-11-03)
|
|
4
50
|
|
|
5
51
|
Layered architecture: the engine is split into four code layers (core → common → interface → methodologies) under one written set of principles, so a methodology, built-in or custom, is a composition of shared pieces; the decisions are in the design spec, section 26. Every change is additive.
|
package/README.md
CHANGED
|
@@ -20,17 +20,18 @@
|
|
|
20
20
|
6. [Standalone investigation and experimentation](#standalone-investigation-and-experimentation)
|
|
21
21
|
7. [Persisting state](#persisting-state)
|
|
22
22
|
8. [Custom methodologies and extension state](#custom-methodologies-and-extension-state)
|
|
23
|
-
9. [
|
|
24
|
-
10. [
|
|
25
|
-
11. [
|
|
26
|
-
12. [
|
|
27
|
-
13. [
|
|
28
|
-
14. [
|
|
29
|
-
15. [
|
|
30
|
-
16. [
|
|
31
|
-
17. [
|
|
32
|
-
18. [
|
|
33
|
-
19. [
|
|
23
|
+
9. [Composable policies](#composable-policies)
|
|
24
|
+
10. [CLI reference (`exwf`)](#cli-reference-exwf)
|
|
25
|
+
11. [Configuration](#configuration)
|
|
26
|
+
12. [Ceremonies](#ceremonies)
|
|
27
|
+
13. [Items, briefs, handoffs, accounting](#items-briefs-handoffs-accounting)
|
|
28
|
+
14. [Errors](#errors)
|
|
29
|
+
15. [JSON Schema](#json-schema)
|
|
30
|
+
16. [Package entry points](#package-entry-points)
|
|
31
|
+
17. [Compatibility and versioning](#compatibility-and-versioning)
|
|
32
|
+
18. [Known limitations](#known-limitations)
|
|
33
|
+
19. [Contributing](#contributing)
|
|
34
|
+
20. [License](#license)
|
|
34
35
|
|
|
35
36
|
## Pick a methodology
|
|
36
37
|
|
|
@@ -243,6 +244,129 @@ state = writeExt(state, "triage", [...queue, "T-1"]); // returns a new state; un
|
|
|
243
244
|
|
|
244
245
|
Investigation and Experimentation store their record under `ext.investigation` / `ext.experimentation` and mirror it to the deprecated top-level `state.investigation` / `state.experimentation` in memory, so SDK code that reads those fields keeps working. On disk only `ext` is stored: `saveState` leaves the mirror out and `loadState` sets it back to the same record (if a hand-edited `state.json` carries both, `ext` wins). The mirrors are read-only: once `ext.<name>` exists the engine reads only it, and a write to the legacy field is ignored; write through `writeExt`. `readExt(state, "investigation")` (or `"experimentation"`) is typed, and on a state written before 1.2, which has no `ext`, it reads the legacy field.
|
|
245
246
|
|
|
247
|
+
## Composable policies
|
|
248
|
+
|
|
249
|
+
`ex-workflow/policies` holds policies you opt into per run by wrapping a methodology. A wrapped methodology keeps every other member, its `name` included, so it runs on the same core and its state persists through the file adapter like the plain one's. The policies are SDK-only: `exwf` runs the built-in factory with only the context-grounding hooks added, so it judges a `context-grounded` stage by the snapshots an SDK host recorded (see [Known limitations](#known-limitations)).
|
|
250
|
+
|
|
251
|
+
### Risk-adaptive gates
|
|
252
|
+
|
|
253
|
+
A gate's requirements are static: the same approval for a typo fix and a production change. `withRiskGate` lets the item's recorded risk add to them, never take away:
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
import { addItem, complete, decide, init, next } from "ex-workflow";
|
|
257
|
+
import { kanban } from "ex-workflow/kanban";
|
|
258
|
+
import { recordRiskAssessment, withRiskGate } from "ex-workflow/policies";
|
|
259
|
+
|
|
260
|
+
const m = withRiskGate(kanban(), { gates: ["code-review"] }); // only these gate ids escalate
|
|
261
|
+
// ... init with a review stage carrying gate { id: "code-review", requires: [{ capability: "review" }], ... }
|
|
262
|
+
|
|
263
|
+
// after the work, an independent role with capability verify (or "human") assesses the item
|
|
264
|
+
state = recordRiskAssessment(state, m, {
|
|
265
|
+
item: "CART-12",
|
|
266
|
+
level: "high", // "low" | "medium" | "high" | "critical"
|
|
267
|
+
factors: ["prod-infra", "secrets"], // free strings
|
|
268
|
+
ref: "risk/CART-12.md", // the host's assessment artifact
|
|
269
|
+
subject: "3f2c1e0", // optional: the SHA or ref assessed
|
|
270
|
+
by: "risk-reviewer",
|
|
271
|
+
}).state;
|
|
272
|
+
|
|
273
|
+
// the reviewer completes as usual: low passes on the static gate, high raises a human pending
|
|
274
|
+
const done = complete(state, m, handoff, accounting);
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
- **The assessment** is evidence `risk-assessment` with `data: { level, factors, subject? }`, recorded through `applyAction` (action `risk.assess`, so your rules see it). `recordRiskAssessment` refuses `invalid-input` for an unknown key or level, a non-string factor, an empty `ref`, an assessor that is neither `human` nor a role with capability `verify`, and an assessor that worked on the item: any role that dispatched it since its last rework (every stage, not only the last), its assigned role, or its author.
|
|
278
|
+
- **Which assessment counts:** only fresh ones (recorded after the item's last rework), with well-formed `data`, by a qualified and independent assessor (re-checked when the gate is resolved). The strictest one wins, so a later, lower assessment does not relax an earlier one; only rework does. With none, the level is `critical`.
|
|
279
|
+
- **The table** says what each level adds to the static gate. `DEFAULT_RISK_TABLE`:
|
|
280
|
+
|
|
281
|
+
| Level | Adds |
|
|
282
|
+
|---|---|
|
|
283
|
+
| `low`, `medium` | nothing |
|
|
284
|
+
| `high`, `critical` | `"human"` |
|
|
285
|
+
|
|
286
|
+
Pass your own as `withRiskGate(m, { gates, table })`: every level needs a row `{ requires: GateRequirement[]; evidence?: string[] }`, and a stricter level must include everything the level below it adds, so a missing or rejected assessment (`critical`) never asks for less than a `low` one. E.g. `medium: { requires: [{ capability: "security-review" }], evidence: ["sbom"] }` with `high` and `critical` both `{ requires: [{ capability: "security-review" }, "human"], evidence: ["sbom"] }`. Invalid options fail `invalid-input` when you wrap.
|
|
287
|
+
- **`gate.resolved`**: on a gated completion, `complete()` appends `gate.resolved { item, gate, requires, evidence, reason }` before `gate.passed` or `pending.raised`, with the requirements actually checked and `reason: { level, why, assessment, by }` (`why` is `assessed`, `missing`, `invalid` or `not-independent`). A gate the policy does not name records the static gate with `reason: {}`.
|
|
288
|
+
- **`decide`** judges a pending gate against the `gate.resolved` that `complete()` recorded with that pending (a resolution appended later does not apply; with none, the static gate applies), so a role cannot approve an escalation to a human, also through `exwf decide`.
|
|
289
|
+
- **Any methodology** may implement the hook itself: `Methodology.escalateGate(state, item, gate)` returns `{ requires, evidence, reason }` or `undefined`. Core only appends what it returns to the static gate, so a hook can tighten a gate but never loosen it. `withRiskGate` keeps an existing hook and widens with both.
|
|
290
|
+
- `riskEscalation(state, item, gate, options)` is the resolver on its own, for hosts that want the answer without wrapping; it validates `options` the same way (`invalid-input`).
|
|
291
|
+
|
|
292
|
+
### Context-grounded entry
|
|
293
|
+
|
|
294
|
+
A worker that starts from a stale picture of the repository builds on assumptions nobody checked. `withContextGrounding` lets an item enter a stage only with a fresh context snapshot that cites at least one source and that `human` or a registered role other than the item's workers recorded:
|
|
295
|
+
|
|
296
|
+
```ts
|
|
297
|
+
import { next } from "ex-workflow";
|
|
298
|
+
import { kanban } from "ex-workflow/kanban";
|
|
299
|
+
import {
|
|
300
|
+
recordContextSnapshot,
|
|
301
|
+
recordRepoChange,
|
|
302
|
+
withContextGrounding,
|
|
303
|
+
} from "ex-workflow/policies";
|
|
304
|
+
|
|
305
|
+
const m = withContextGrounding(kanban(), { entry: ["dev"] }); // optional: exit: ["dev"]
|
|
306
|
+
// init with m: the dev column's entry policies gain { kind: "custom", id: "context-grounded" }
|
|
307
|
+
|
|
308
|
+
// a scout (a registered role that does not work on the item, or "human") records what it verified
|
|
309
|
+
state = recordContextSnapshot(state, m, {
|
|
310
|
+
item: "CART-12",
|
|
311
|
+
revision: "4f2c1e0",
|
|
312
|
+
assumptions: [
|
|
313
|
+
{
|
|
314
|
+
claim: "cart totals are integer cents",
|
|
315
|
+
required: true,
|
|
316
|
+
source: { path: "src/cart.ts", lines: [10, 24], hash: "9b1d…" },
|
|
317
|
+
},
|
|
318
|
+
{ claim: "no caching layer in front of the cart" }, // no source: unverified
|
|
319
|
+
],
|
|
320
|
+
ref: "ctx/CART-12.json", // the host's snapshot artifact
|
|
321
|
+
by: "scout", // a role registered in the state
|
|
322
|
+
}).state;
|
|
323
|
+
|
|
324
|
+
const { briefs } = next(state, m); // brief.context: what was verified, where, what went stale
|
|
325
|
+
|
|
326
|
+
// the host reports what each new revision changed
|
|
327
|
+
const changed = recordRepoChange(state, m, {
|
|
328
|
+
revision: "a71b2d9",
|
|
329
|
+
paths: ["src/cart.ts"], // as `git diff --name-only -z` lists them
|
|
330
|
+
by: "ci",
|
|
331
|
+
});
|
|
332
|
+
changed.warnings; // context-stale for each in-flight item whose snapshot cites a changed path
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
- **The snapshot** is evidence `context-snapshot` with `data: { revision, assumptions }`, recorded through `applyAction` (action `context.snapshot`). An assumption is `{ claim, required?, source?: { path, lines?: [from, to], hash } }`; one without a `source` is unverified. `recordContextSnapshot` refuses `invalid-input` for a snapshot with no sourced assumption and for a `by` that is neither `human` nor a registered role, or that worked on the item (dispatched it since its last rework, is assigned to it, or authored it). The engine compares paths and hashes, it never reads a file.
|
|
336
|
+
- **Paths** are repository-relative POSIX paths as Git lists them, compared exactly (case included): `src/cart.ts`, not `./src/cart.ts`, `/src/cart.ts` or `src\cart.ts`. They must also be Unicode NFC (macOS file systems may hand you NFD), at most 4096 characters, with no control or bidirectional formatting character and no leading or trailing whitespace. Read them from `git diff --name-only -z` (NUL-separated and unquoted) or with `git -c core.quotePath=false`: by default Git prints a non-ASCII name quoted and escaped (`"caf\303\251.ts"`), which is refused. Both recorders refuse any other spelling with `invalid-input`.
|
|
337
|
+
- **`repo.changed`**: `recordRepoChange` (action `repo.change`) appends `repo.changed { revision, paths }`. A snapshot is stale when a later `repo.changed` lists a path it cites (event order, not timestamps; the revision alone does not decide). No item status changes: an item in `in_progress`, `review` or `awaiting_human` gets a `context-stale` warning in `ApplyResult.warnings` when this change made its snapshot stale, and a `todo` item is re-checked by its entry policy when the planner reaches it.
|
|
338
|
+
- **The policy** (`contextGroundedViolations`, rule `policy:custom:context-grounded`) fails an item with no qualifying fresh snapshot, with a stale one, or with a `required` assumption that has no source. A snapshot qualifies when its data is valid, it has at least one sourced assumption and `human` or a registered role that does not work on the item recorded it; the latest qualifying one counts, so a snapshot a worker wrote into the state by hand never replaces an independent one, and one recorded by a role that later works on the item stops counting. Rework drops every snapshot. `next` reports such a `todo` item under `skipped` with reason `entry-policy` and the message. A qualifying snapshot whose required claims are all sourced passes; unverified optional claims are listed in `brief.context.unverified`.
|
|
339
|
+
- **`brief.context`** is `contextOf(state, item)`: `{ revision, assumptions, snapshot, by, stale, unverified }`.
|
|
340
|
+
- **Any methodology** may answer custom policies itself: `Methodology.customPolicy(state, item, policy)` returns the violations, or `undefined` for the default check (evidence `policy:<id>`); `Methodology.briefContext(state, item)` fills `brief.context`. `withContextGrounding` keeps existing hooks for every other policy id and composes with `withRiskGate` in either order.
|
|
341
|
+
|
|
342
|
+
### Comparing runs
|
|
343
|
+
|
|
344
|
+
`compareRuns` compares finished runs of two or more variants (a variant is whatever the host changed: a role's model tier, a config, a methodology). It is a pure function over `WorkflowState` values; the scenario suite, running each variant and scoring stay with the host.
|
|
345
|
+
|
|
346
|
+
```ts
|
|
347
|
+
import { loadState } from "ex-workflow/adapters";
|
|
348
|
+
import { compareRuns } from "ex-workflow/policies";
|
|
349
|
+
|
|
350
|
+
const result = compareRuns(
|
|
351
|
+
[
|
|
352
|
+
{ variant: "V0", scenario: "bug-fix-1", passed: true, state: await loadState(dirV0Bug1) },
|
|
353
|
+
{ variant: "V1", scenario: "bug-fix-1", passed: true, state: await loadState(dirV1Bug1) },
|
|
354
|
+
// ... one record per variant and scenario run; a scenario may run more than once
|
|
355
|
+
],
|
|
356
|
+
{ baseline: "V0", mustPass: ["bug-fix-1"], passTolerance: 0.1, costTolerance: 0.05 },
|
|
357
|
+
);
|
|
358
|
+
result.winner; // "V1", or null when no eligible variant beats the baseline beyond the tolerances
|
|
359
|
+
result.reason; // why
|
|
360
|
+
result.variants; // ranked VariantResult[]: { variant, runs, passed, passRate, mean, regressions, missing, eligible }
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
- **`passed`** is your scorer's verdict for that run. The engine derives the rest from the state: `mean` holds, per variant, the mean of `tokens` (accounting `tokensIn + tokensOut`, after corrections), `durationMs`, `turns` (accounting lines), `humanInterventions` (`pending.raised` plus `blocker.cleared` events), `reworks`, `escalations` and `itemsDone`.
|
|
364
|
+
- **`passRate`** weighs each scenario once: the mean over the scenarios the variant ran of the share of that scenario's runs that passed, so more runs of an easy scenario do not raise it; `runs` and `passed` count runs.
|
|
365
|
+
- **Eligible** means no `mustPass` scenario has a failing run (`regressions`) and the variant ran every scenario the baseline ran and every `mustPass` one (`missing`).
|
|
366
|
+
- **Ranking**: eligible first, then `passRate` descending, then mean tokens, mean duration and mean human interventions ascending, then the variant id in code-unit order. The input order of `runs` never changes the result.
|
|
367
|
+
- **Winner**: the first ranked eligible variant other than the baseline whose `passRate` is at least the baseline's minus `passTolerance` and that is better, by a `passRate` above the baseline's plus `passTolerance` or by mean tokens below the baseline's times `1 - costTolerance`. Tolerances are fractions in `[0, 1]`, default `0`.
|
|
368
|
+
- **Refused with `invalid-input`**: no runs, a non-array `runs`, an id that is not a valid id (`__proto__`, `toString` and the like included), a baseline or `mustPass` scenario no run names, a tolerance outside `[0, 1]`, a non-boolean `passed`, a state without `events`, `accounting` and `items`, a non-finite or negative token or duration figure, and token or duration totals or means that overflow to infinity. Only own properties of the options, run records and states are read (an inherited `{ __proto__: … }` value counts as absent). Variants of different methodologies compare on the same metrics.
|
|
369
|
+
|
|
246
370
|
## CLI reference (`exwf`)
|
|
247
371
|
|
|
248
372
|
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.
|
|
@@ -382,7 +506,8 @@ Every config is validated at `init` (`config-invalid` names the key and an examp
|
|
|
382
506
|
{ item, role, modelTier, invariants, do_not, acceptance,
|
|
383
507
|
upstream, // results of the items this one depends on
|
|
384
508
|
priorHandoffs, // earlier attempts at this item (rework feedback)
|
|
385
|
-
relatedBugs, budgetRemaining, gateAhead
|
|
509
|
+
relatedBugs, budgetRemaining, gateAhead,
|
|
510
|
+
context } // with withContextGrounding: the item's context snapshot
|
|
386
511
|
```
|
|
387
512
|
|
|
388
513
|
**Handoff** (what your agent gives back):
|
|
@@ -436,6 +561,7 @@ The CLI validates state, role manifests, items, patches and handoffs with these
|
|
|
436
561
|
| `ex-workflow/investigation` | `investigation()`, `validateInvestigationConfig`; types `InvestigationConfig`, `InvestigationState`, `InvestigationRound`, `InvestigationConclusion`, `Hypothesis`, `Experiment`, `Observation`, `BeliefUpdate` |
|
|
437
562
|
| `ex-workflow/experimentation` | `experimentation()`, `validateExperimentationConfig`, `experimentationCeremonies`, `experimentationMetrics`, `experimentationReport`, `experimentationRoles`, `experimentationRules`, `experimentationStages`; types `ExperimentationConfig`, `ExperimentationState`, `ExperimentCandidate` |
|
|
438
563
|
| `ex-workflow/registry` | `registerMethodology`, `methodologyFactory`, `registeredMethodologies` (five built-ins pre-registered); types `MethodologyFactory`, `MethodologyRegistry` |
|
|
564
|
+
| `ex-workflow/policies` | `withRiskGate`, `recordRiskAssessment`, `riskEscalation`, `DEFAULT_RISK_TABLE`, `withContextGrounding`, `recordContextSnapshot`, `recordRepoChange`, `contextOf`, `contextGroundedViolations`, `compareRuns`; types `RiskLevel`, `RiskTable`, `RiskAssessmentData`, `RiskAssessmentInput`, `RiskGateOptions`, `ContextGroundingOptions`, `ContextSnapshotInput`, `RepoChangeInput`, `CompareRunsOptions`, `RunRecord`, `RunMetrics`, `VariantResult`, `RunComparison` (`ContextAssumption`, `ContextSnapshotData` and `BriefContext` come from the root entry) |
|
|
439
565
|
| `ex-workflow/adapters` | `loadState`, `saveState`, `saveBrief`, `saveHandoff`, `withStateLock`, `WORKFLOW_DIR` |
|
|
440
566
|
| `ex-workflow/schema` | the ten schema documents, `validate`, `assertValid` |
|
|
441
567
|
| `ex-workflow/cli` | `runCommand`, `parseArgs`, `USAGE`: the `exwf` command as a library |
|
|
@@ -445,7 +571,7 @@ Each entry ships ESM, CommonJS and `.d.ts`. Core plus one methodology is about 5
|
|
|
445
571
|
|
|
446
572
|
## Compatibility and versioning
|
|
447
573
|
|
|
448
|
-
- Semver from 1.0.0. The public surface (exports of every entry point, the CLI commands, the ten schema documents, the
|
|
574
|
+
- Semver from 1.0.0. The public surface (exports of every entry point, the CLI commands, the ten schema documents, the 71 event kinds) is frozen by test: a removal is a major version, an addition a minor one.
|
|
449
575
|
- A `.workflow/state.json` written by any earlier release loads unchanged; the test suite replays state files from every published pre-release.
|
|
450
576
|
- **Deprecated in 1.2:** the top-level `state.investigation` and `state.experimentation` fields. They are still set in memory and for SDK readers, as read-only mirrors of `ext.investigation` / `ext.experimentation` (on disk only `ext` is written; `loadState` restores the mirror), so SDK code reading `state.investigation` / `state.experimentation` sees the same record; once `ext.<name>` exists a write to the legacy field is ignored. Read with `readExt` and write with `writeExt` instead. The mirrors do not make a 1.2 state loadable by 1.1.x (see [Known limitations](#known-limitations)). 2.0 removes the mirrors.
|
|
451
577
|
- Behaviour changes are listed per release in [CHANGELOG.md](CHANGELOG.md).
|
|
@@ -456,6 +582,14 @@ Deliberate, documented, and stable within 1.x.
|
|
|
456
582
|
|
|
457
583
|
- **A custom methodology's state cannot go through the file adapter or the CLI.** The state schema accepts only the five built-in names in `methodology`, so `saveState`, `loadState` and every `exwf` command refuse it. Keep such a state through the SDK and persist it yourself.
|
|
458
584
|
- **No downgrade for Investigation and Experimentation.** 1.1.x cannot load a state that 1.2 wrote for those two methodologies: the 1.1 state schema rejects the `ext` field, and the legacy mirrors do not change that. Keep a run on 1.2 once 1.2 has saved it.
|
|
585
|
+
- **No downgrade for a state with evidence `data`.** 1.2.x cannot load a state carrying `Evidence.data` (a risk assessment or context snapshot recorded by `ex-workflow/policies`): its schema closes `Evidence`. Keep such a run on 1.3.
|
|
586
|
+
- **Policies are SDK-only.** `exwf` runs the built-in methodology with only the context-grounding hooks added (no risk gate), so `exwf complete` checks a gate's static requirements only. `exwf decide` does honour an escalation the SDK recorded (`gate.resolved`). Run completions of a risk-gated run through the SDK. There is no CLI command for snapshots or repository changes.
|
|
587
|
+
- **`context-grounded` is a reserved custom policy id.** Since 1.4 only the context-grounding hook answers it: `withContextGrounding` in the SDK, and every `exwf` command, which judges it by the snapshots an SDK host recorded with `recordContextSnapshot` (the CLI records none). An SDK call with the plain methodology fails closed: `next` skips the item with reason `entry-policy` and `complete` refuses `policy-unmet`; evidence `policy:context-grounded` never satisfies it, so a worker cannot attest it through `handoff.produced`. If one of your own custom policies is called `context-grounded`, rename it.
|
|
588
|
+
- **Ceremonies do not consult the grounding hook.** A built-in ceremony that checks stage policies (Kanban `replenishment` on the first column's exit, Scrum Sprint Planning on `backlog`'s exit, Experimentation on `building`'s entry) uses the plain methodology, so a `context-grounded` policy there could never pass; `withContextGrounding` refuses those stages with `invalid-input`. Ground a later stage, such as Kanban `dev`.
|
|
589
|
+
- **Ground a stage the engine evaluates.** The policy is checked where the engine reads stage policies: the planner on the entry of the stage it dispatches into, `complete()` on the exit of the item's stage. A policy on a stage neither reaches is never checked, for example Kanban `exit: ["ready"]` (Kanban copies the commitment column's exit into `dev`'s entry when the board is built, before the wrapper adds the policy) or Scrum `sprint`. Ground Kanban `dev` (`entry: ["dev"]`) or Scrum `in_progress`.
|
|
590
|
+
- **Context grounding on an existing state, and Kanban policy changes.** `withContextGrounding` adds its policy through `defaultStages`, so it reaches a state at `init`; for a state created before wrapping, add `{ kind: "custom", id: "context-grounded", description }` to the stage's `entryPolicy` yourself. A Kanban `operations-review` that changes the commitment column's policies rewrites the next column's entry policies and drops it; add it back the same way.
|
|
591
|
+
- **Independence at entry needs a known worker.** The policy compares the snapshot's recorder with the roles that worked on the item. A `todo` item never dispatched and without a `role` has no worker yet (the planner picks one after the entry check), so a snapshot by the role the planner then picks passes the entry check. Once that role is dispatched its snapshot stops counting: `contextOf` falls back to the latest earlier qualifying snapshot, which may be stale (the brief carries it with its `stale` paths, and an `exit` policy fails on it), or, with none, the brief has no `context` and an `exit` policy fails. Since 1.4 a later snapshot keeps the `required` claims of the snapshots it supersedes (one it omits is reported unverified), so that future worker cannot drop them; only a rework clears them. Set `role` on the item, or also pass `exit`, to have the check apply before the work.
|
|
592
|
+
- **`checkGate` alone sees the static gate.** The risk escalation is applied by `complete()` and `decide()`; a host calling `checkGate` directly gets the 1.2 answer.
|
|
459
593
|
|
|
460
594
|
- **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), the command gives up after its retries with `invalid-input` naming the lock file; delete it by hand.
|
|
461
595
|
- **Item ids that differ only in letter case cannot both get a brief file.** On macOS and Windows `briefs/A.json` and `briefs/a.json` are one file, so `exwf next` checks every brief name of the batch first and, when an item's id differs from another item's (in the same batch, or with an existing brief) only in case, refuses the whole dispatch with `invalid-input` naming both: no brief is written and the state is unchanged. `saveBrief` refuses such an id the same way. Give ids that differ by more than case (re-add one item under a new id).
|
package/dist/adapters/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkKA6DVHO5_cjs=require('../chunk-KA6DVHO5.cjs');require('../chunk-BBI7AKJK.cjs'),require('../chunk-DVFTTBCT.cjs'),require('../chunk-OSHBJIYD.cjs');Object.defineProperty(exports,"WORKFLOW_DIR",{enumerable:true,get:function(){return chunkKA6DVHO5_cjs.a}});Object.defineProperty(exports,"loadState",{enumerable:true,get:function(){return chunkKA6DVHO5_cjs.e}});Object.defineProperty(exports,"saveBrief",{enumerable:true,get:function(){return chunkKA6DVHO5_cjs.g}});Object.defineProperty(exports,"saveHandoff",{enumerable:true,get:function(){return chunkKA6DVHO5_cjs.h}});Object.defineProperty(exports,"saveState",{enumerable:true,get:function(){return chunkKA6DVHO5_cjs.d}});Object.defineProperty(exports,"statePath",{enumerable:true,get:function(){return chunkKA6DVHO5_cjs.b}});Object.defineProperty(exports,"withStateLock",{enumerable:true,get:function(){return chunkKA6DVHO5_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,g as saveBrief,h as saveHandoff,d as saveState,b as statePath,c as withStateLock}from'../chunk-
|
|
1
|
+
export{a as WORKFLOW_DIR,e as loadState,g as saveBrief,h as saveHandoff,d as saveState,b as statePath,c as withStateLock}from'../chunk-ONVAUZOD.mjs';import'../chunk-TQR3VFZU.mjs';import'../chunk-QJMOCISZ.mjs';import'../chunk-YS6CXERQ.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { W as WorkflowState, C as Capability, R as Role, a as Budget, A as Accounting } from './types-
|
|
1
|
+
import { W as WorkflowState, C as Capability, R as Role, a as Budget, A as Accounting } from './types-DLOtndDY.js';
|
|
2
2
|
|
|
3
3
|
declare function requireCapabilities(state: WorkflowState<string>, required: Capability[], exclusive: Capability[]): void;
|
|
4
4
|
declare function requireCapabilities(state: WorkflowState, required: Capability[], exclusive: Capability[]): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { W as WorkflowState, C as Capability, R as Role, a as Budget, A as Accounting } from './types-
|
|
1
|
+
import { W as WorkflowState, C as Capability, R as Role, a as Budget, A as Accounting } from './types-DLOtndDY.cjs';
|
|
2
2
|
|
|
3
3
|
declare function requireCapabilities(state: WorkflowState<string>, required: Capability[], exclusive: Capability[]): void;
|
|
4
4
|
declare function requireCapabilities(state: WorkflowState, required: Capability[], exclusive: Capability[]): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {c}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {c}from'./chunk-NNQ3RHDP.mjs';import {b}from'./chunk-YS6CXERQ.mjs';var l=r=>r.agreements.length===0?"(none)":r.agreements.map(e=>`"${e}"`).join(", ");function a(r,e,n){return b("invalid-input",`no working agreement ${JSON.stringify(e)} to ${n}`,`current agreements: ${l(r)}; name one of them exactly`)}function m(r,e,n,s){if(e.replaces===e.text)return r;let t=r;return e.replaces!==void 0&&((typeof e.replaces!="string"||!t.agreements.includes(e.replaces))&&a(t,e.replaces,"replace"),t={...t,agreements:t.agreements.filter(i=>i!==e.replaces)},t=c(t,"agreement.retired",n,{text:e.replaces,replacedBy:e.text},s)),t.agreements.includes(e.text)||(t={...t,agreements:[...t.agreements,e.text]}),t}function w(r,e,n,s){(typeof e!="string"||!r.agreements.includes(e))&&a(r,e,"retire");let t={...r,agreements:r.agreements.filter(i=>i!==e)};return c(t,"agreement.retired",n,{text:e,replacedBy:null},s)}export{m as a,w as b};//# sourceMappingURL=chunk-3QUIRAXO.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-3QUIRAXO.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/agreements.ts"],"names":["listed","s","a","absent","text","what","fail","applyAgreement","state","change","by","now","appendEvent","retireAgreement"],"mappings":"0EAIA,IAAMA,EAAUC,CAAAA,EACdA,CAAAA,CAAE,WAAW,MAAA,GAAW,CAAA,CAAI,SAAWA,CAAAA,CAAE,UAAA,CAAW,GAAA,CAAKC,CAAAA,EAAM,IAAIA,CAAC,CAAA,CAAA,CAAG,EAAE,IAAA,CAAK,IAAI,EAEpF,SAASC,CAAAA,CAAOF,CAAAA,CAA0BG,CAAAA,CAAeC,EAAqB,CAC5E,OAAOC,EACL,eAAA,CACA,CAAA,qBAAA,EAAwB,KAAK,SAAA,CAAUF,CAAI,CAAC,CAAA,IAAA,EAAOC,CAAI,GACvD,CAAA,oBAAA,EAAuBL,CAAAA,CAAOC,CAAC,CAAC,CAAA,0BAAA,CAClC,CACF,CAeO,SAASM,CAAAA,CACdC,CAAAA,CACAC,EACAC,CAAAA,CACAC,CAAAA,CACkB,CAClB,GAAIF,CAAAA,CAAO,WAAaA,CAAAA,CAAO,IA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|
|
1
|
+
{"version":3,"sources":["../src/core/agreements.ts"],"names":["listed","s","a","absent","text","what","fail","applyAgreement","state","change","by","now","appendEvent","retireAgreement"],"mappings":"0EAIA,IAAMA,EAAUC,CAAAA,EACdA,CAAAA,CAAE,WAAW,MAAA,GAAW,CAAA,CAAI,SAAWA,CAAAA,CAAE,UAAA,CAAW,GAAA,CAAKC,CAAAA,EAAM,IAAIA,CAAC,CAAA,CAAA,CAAG,EAAE,IAAA,CAAK,IAAI,EAEpF,SAASC,CAAAA,CAAOF,CAAAA,CAA0BG,CAAAA,CAAeC,EAAqB,CAC5E,OAAOC,EACL,eAAA,CACA,CAAA,qBAAA,EAAwB,KAAK,SAAA,CAAUF,CAAI,CAAC,CAAA,IAAA,EAAOC,CAAI,GACvD,CAAA,oBAAA,EAAuBL,CAAAA,CAAOC,CAAC,CAAC,CAAA,0BAAA,CAClC,CACF,CAeO,SAASM,CAAAA,CACdC,CAAAA,CACAC,EACAC,CAAAA,CACAC,CAAAA,CACkB,CAClB,GAAIF,CAAAA,CAAO,WAAaA,CAAAA,CAAO,IAAA,CAAM,OAAOD,CAAAA,CAC5C,IAAIP,CAAAA,CAAIO,CAAAA,CACR,OAAIC,CAAAA,CAAO,QAAA,GAAa,UAClB,OAAOA,CAAAA,CAAO,QAAA,EAAa,QAAA,EAAY,CAACR,CAAAA,CAAE,UAAA,CAAW,SAASQ,CAAAA,CAAO,QAAQ,IAC/EN,CAAAA,CAAOF,CAAAA,CAAGQ,EAAO,QAAA,CAAU,SAAS,EACtCR,CAAAA,CAAI,CAAE,GAAGA,CAAAA,CAAG,UAAA,CAAYA,EAAE,UAAA,CAAW,MAAA,CAAQC,CAAAA,EAAMA,CAAAA,GAAMO,EAAO,QAAQ,CAAE,EAC1ER,CAAAA,CAAIW,CAAAA,CACFX,EACA,mBAAA,CACAS,CAAAA,CACA,CAAE,IAAA,CAAMD,EAAO,QAAA,CAAU,UAAA,CAAYA,EAAO,IAAK,CAAA,CACjDE,CACF,CAAA,CAAA,CAEGV,CAAAA,CAAE,UAAA,CAAW,QAAA,CAASQ,EAAO,IAAI,CAAA,GAAGR,EAAI,CAAE,GAAGA,EAAG,UAAA,CAAY,CAAC,GAAGA,CAAAA,CAAE,UAAA,CAAYQ,EAAO,IAAI,CAAE,GACzFR,CACT,CAeO,SAASY,CAAAA,CACdL,CAAAA,CACAJ,CAAAA,CACAM,CAAAA,CACAC,EACkB,CAAA,CACd,OAAOP,GAAS,QAAA,EAAY,CAACI,EAAM,UAAA,CAAW,QAAA,CAASJ,CAAI,CAAA,GAAGD,CAAAA,CAAOK,EAAOJ,CAAAA,CAAM,QAAQ,EAC9F,IAAMH,CAAAA,CAAI,CAAE,GAAGO,CAAAA,CAAO,UAAA,CAAYA,CAAAA,CAAM,WAAW,MAAA,CAAQN,CAAAA,EAAMA,IAAME,CAAI,CAAE,EAC7E,OAAOQ,CAAAA,CAAYX,EAAG,mBAAA,CAAqBS,CAAAA,CAAI,CAAE,IAAA,CAAAN,CAAAA,CAAM,WAAY,IAAK,CAAA,CAAGO,CAAG,CAChF","file":"chunk-3QUIRAXO.mjs","sourcesContent":["import { fail } from \"./errors.ts\";\nimport { appendEvent } from \"./state.ts\";\nimport type { WorkflowState } from \"./types.ts\";\n\nconst listed = (s: WorkflowState<string>) =>\n s.agreements.length === 0 ? \"(none)\" : s.agreements.map((a) => `\"${a}\"`).join(\", \");\n\nfunction absent(s: WorkflowState<string>, text: unknown, what: string): never {\n return fail(\n \"invalid-input\",\n `no working agreement ${JSON.stringify(text)} to ${what}`,\n `current agreements: ${listed(s)}; name one of them exactly`,\n );\n}\n\n/** Adds an agreement (idempotent); with `replaces`, retires that one in the same step. */\nexport function applyAgreement<N extends string>(\n state: WorkflowState<N>,\n change: { text: string; replaces?: string },\n by: string,\n now: string,\n): WorkflowState<N>;\nexport function applyAgreement(\n state: WorkflowState,\n change: { text: string; replaces?: string },\n by: string,\n now: string,\n): WorkflowState;\nexport function applyAgreement<N extends string>(\n state: WorkflowState<N>,\n change: { text: string; replaces?: string },\n by: string,\n now: string,\n): WorkflowState<N> {\n if (change.replaces === change.text) return state;\n let s = state;\n if (change.replaces !== undefined) {\n if (typeof change.replaces !== \"string\" || !s.agreements.includes(change.replaces))\n absent(s, change.replaces, \"replace\");\n s = { ...s, agreements: s.agreements.filter((a) => a !== change.replaces) };\n s = appendEvent(\n s,\n \"agreement.retired\",\n by,\n { text: change.replaces, replacedBy: change.text },\n now,\n );\n }\n if (!s.agreements.includes(change.text)) s = { ...s, agreements: [...s.agreements, change.text] };\n return s;\n}\n\n/** Removes an agreement and records why it left (replacedBy null). */\nexport function retireAgreement<N extends string>(\n state: WorkflowState<N>,\n text: string,\n by: string,\n now: string,\n): WorkflowState<N>;\nexport function retireAgreement(\n state: WorkflowState,\n text: string,\n by: string,\n now: string,\n): WorkflowState;\nexport function retireAgreement<N extends string>(\n state: WorkflowState<N>,\n text: string,\n by: string,\n now: string,\n): WorkflowState<N> {\n if (typeof text !== \"string\" || !state.agreements.includes(text)) absent(state, text, \"retire\");\n const s = { ...state, agreements: state.agreements.filter((a) => a !== text) };\n return appendEvent(s, \"agreement.retired\", by, { text, replacedBy: null }, now);\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkG6QELJRL_cjs=require('./chunk-G6QELJRL.cjs'),chunk66BO7JFR_cjs=require('./chunk-66BO7JFR.cjs'),chunkKA6DVHO5_cjs=require('./chunk-KA6DVHO5.cjs'),chunkLQJPLXFR_cjs=require('./chunk-LQJPLXFR.cjs'),chunkYRXFEM3F_cjs=require('./chunk-YRXFEM3F.cjs'),chunkTBLIZIWH_cjs=require('./chunk-TBLIZIWH.cjs'),chunkDVFTTBCT_cjs=require('./chunk-DVFTTBCT.cjs'),chunkOSHBJIYD_cjs=require('./chunk-OSHBJIYD.cjs'),promises=require('fs/promises'),y=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var y__default=/*#__PURE__*/_interopDefault(y);var et=r=>r!==void 0&&chunkG6QELJRL_cjs.c().includes(r)?chunkG6QELJRL_cjs.b(r):void 0,h=["exwf init <scrum|kanban|waterfall|investigation|experimentation> --config <file> [--roles <file>]","exwf add <item.json> [--by who] exwf edit <id> <patch.json> [--by who]","exwf next [--max n] [--fallback-tokens-per-weight n]","exwf complete <id> <handoff.json> --tokens-in n --tokens-out n --duration-ms n --model m [--estimate] [--role r]","exwf account <item> [--line n] [--tokens-in n] [--tokens-out n] [--duration-ms n] [--model m] [--by who]","exwf ceremony <name> [input.json] [--by who]","exwf decide <pendingId> approve|reject [--by who] [--note text]","exwf config set <patch.json> [--by who] exwf unblock <item> [--blocker id] [--note text] [--by who]","exwf status | board | metrics | pending | lessons","exwf validate <action.json> exwf role add <manifest.json> | role list"],at=new Set(["estimate"]);function ot(r){let t=[],u={};for(let a=0;a<r.length;a++){let S=r[a];if(S.startsWith("--")){let n=S.slice(2);if(at.has(n)){u[n]="true";continue}let f=r[a+1];(f===void 0||f.startsWith("--"))&&chunkOSHBJIYD_cjs.b("invalid-input",`--${n} needs a value`,`pass --${n} <text>`),u[n]=f,a++;}else t.push(S);}return {positional:t,flags:u}}async function x(r){try{return JSON.parse(await promises.readFile(r,"utf8"))}catch(t){return chunkOSHBJIYD_cjs.b("invalid-input",`cannot read JSON from ${r}: ${t.message}`,"check the path and that the file is valid JSON")}}function w(r){let t=et(r.methodology);return t||chunkOSHBJIYD_cjs.b("config-invalid",`methodology "${r.methodology}" is not available in this build`,`available: ${chunkG6QELJRL_cjs.c().join(", ")}`),chunk66BO7JFR_cjs.k(t())}function b(r,t){let u=Number(r[t]);return Number.isFinite(u)||chunkOSHBJIYD_cjs.b("invalid-input",`--${t} must be a number (got ${JSON.stringify(r[t])})`,`pass --${t} <n>`),u}var rt=new Set(["init","add","edit","next","complete","account","ceremony","decide","unblock"]);async function $t(r,t){try{let[u,a]=ot(r).positional;return u!==void 0&&(rt.has(u)||u==="role"&&a==="add"||u==="config"&&a==="set")?await chunkKA6DVHO5_cjs.c(t,()=>tt(r,t)):await tt(r,t)}catch(u){if(u instanceof chunkOSHBJIYD_cjs.a)return {exit:1,out:{ok:false,error:u.toJSON()}};throw u}}async function tt(r,t){let{positional:u,flags:a}=ot(r),[S,...n]=u,f=a.by??"human",d=new Date().toISOString();switch(S){case "init":{let[o]=n,e=et(o);if(!e||!a.config)return {exit:2,out:{ok:false,usage:h}};try{await promises.stat(chunkKA6DVHO5_cjs.b(t)),chunkOSHBJIYD_cjs.b("invalid-input",`${chunkKA6DVHO5_cjs.b(t)} already exists`,"delete .workflow/state.json to start over");}catch(c){if(c instanceof chunkOSHBJIYD_cjs.a||c.code!=="ENOENT")throw c}let i=await x(y__default.default.resolve(t,a.config)),s=a.roles?await x(y__default.default.resolve(t,a.roles)):void 0;if(s!==void 0){Array.isArray(s)||chunkOSHBJIYD_cjs.b("invalid-input",`roles file ${a.roles} must contain an array of role manifests`,"wrap the manifests in [ ... ]");for(let c of s)chunkDVFTTBCT_cjs.b(chunkDVFTTBCT_cjs.e,c,`roles file ${a.roles}`);}let l=chunkTBLIZIWH_cjs.W(s?{methodology:e(),config:i,roles:s,by:f,now:d}:{methodology:e(),config:i,by:f,now:d});return await chunkKA6DVHO5_cjs.d(t,l.state),{exit:0,out:{ok:true,warnings:l.warnings,state:{methodology:l.state.methodology,stages:l.state.stages.map(c=>c.id),roles:Object.keys(l.state.roles)}}}}case "add":{if(!n[0])return {exit:2,out:{ok:false,usage:h}};let o=await chunkKA6DVHO5_cjs.e(t),e=await x(y__default.default.resolve(t,n[0]));chunkDVFTTBCT_cjs.b(chunkDVFTTBCT_cjs.f,e,`item file ${n[0]}`);let i=chunkTBLIZIWH_cjs.V(o,w(o),{type:"item.add",by:f,payload:{item:e}},s=>chunkTBLIZIWH_cjs.t(s,e,f,d));return await chunkKA6DVHO5_cjs.d(t,i.state),{exit:0,out:{ok:true,warnings:i.warnings,item:chunkTBLIZIWH_cjs.s(i.state,e.id)}}}case "edit":{if(!n[0]||!n[1])return {exit:2,out:{ok:false,usage:h}};let o=await chunkKA6DVHO5_cjs.e(t),e=n[0],i=await x(y__default.default.resolve(t,n[1]));chunkDVFTTBCT_cjs.b(chunkDVFTTBCT_cjs.g,i,`patch file ${n[1]}`);let s=chunkTBLIZIWH_cjs.V(o,w(o),{type:"item.edit",by:f,payload:{id:e,patch:i}},l=>chunkTBLIZIWH_cjs.u(l,e,i,f,d));return await chunkKA6DVHO5_cjs.d(t,s.state),{exit:0,out:{ok:true,warnings:s.warnings,item:chunkTBLIZIWH_cjs.s(s.state,e)}}}case "next":{let o=await chunkKA6DVHO5_cjs.e(t),e={now:d};a.max&&(e.max=b(a,"max")),a["fallback-tokens-per-weight"]&&(e.fallbackTokensPerWeight=b(a,"fallback-tokens-per-weight"));let i=chunkLQJPLXFR_cjs.e(o,w(o),e);await chunkKA6DVHO5_cjs.f(t,i.briefs.map(s=>s.item.id));for(let s of i.briefs)await chunkKA6DVHO5_cjs.g(t,s);return await chunkKA6DVHO5_cjs.d(t,i.state),{exit:0,out:{ok:true,reason:i.reason??null,skipped:i.skipped,briefs:i.briefs}}}case "complete":{if(!n[0]||!n[1])return {exit:2,out:{ok:false,usage:h}};let o=await chunkKA6DVHO5_cjs.e(t),e=await x(y__default.default.resolve(t,n[1]));chunkDVFTTBCT_cjs.b(chunkDVFTTBCT_cjs.h,e,`handoff file ${n[1]}`),e.item!==n[0]&&chunkOSHBJIYD_cjs.b("handoff-invalid",`handoff.item "${e.item}" differs from the command's item "${n[0]}"`,"make them match");let i=a.role??e.role,s=b(a,"duration-ms"),l=Date.parse(d)-s;(!Number.isFinite(s)||Number.isNaN(new Date(l).getTime()))&&chunkOSHBJIYD_cjs.b("invalid-input",`--duration-ms must be a number of milliseconds that dates the start (got ${a["duration-ms"]})`,"pass the measured wall-clock time in ms, e.g. --duration-ms 42000");let c={item:n[0],role:i,model:a.model??"",tokensIn:b(a,"tokens-in"),tokensOut:b(a,"tokens-out"),durationMs:s,startedAt:new Date(l).toISOString(),endedAt:d};a.estimate==="true"&&(c.estimate=true);let k=chunkLQJPLXFR_cjs.f(o,w(o),{...e,role:i},c,d);return await chunkKA6DVHO5_cjs.h(t,e,k.state.events.length),await chunkKA6DVHO5_cjs.d(t,k.state),{exit:0,out:{ok:true,warnings:k.warnings,item:chunkTBLIZIWH_cjs.s(k.state,n[0])}}}case "account":{if(!n[0])return {exit:2,out:{ok:false,usage:h}};let o=await chunkKA6DVHO5_cjs.e(t),e={};a["tokens-in"]!==void 0&&(e.tokensIn=b(a,"tokens-in")),a["tokens-out"]!==void 0&&(e.tokensOut=b(a,"tokens-out")),a["duration-ms"]!==void 0&&(e.durationMs=b(a,"duration-ms")),a.model!==void 0&&(e.model=a.model);let i=a.line!==void 0?b(a,"line"):void 0,s=chunkLQJPLXFR_cjs.g(o,n[0],e,a.by??"human",d,i);await chunkKA6DVHO5_cjs.d(t,s);let l=chunkTBLIZIWH_cjs.d(s),c=l.payload.line;return {exit:0,out:{ok:true,line:s.accounting.filter(A=>A.item===n[0])[c-1],event:l}}}case "ceremony":{if(!n[0])return {exit:2,out:{ok:false,usage:h}};let o=await chunkKA6DVHO5_cjs.e(t),e=w(o),i=Object.hasOwn(e.ceremonies,n[0])?e.ceremonies[n[0]]:void 0;i||chunkOSHBJIYD_cjs.b("unknown-ceremony",`"${n[0]}" is not a ${e.name} ceremony`,`available: ${Object.keys(e.ceremonies).join(", ")}`);let s=n[1]?await x(y__default.default.resolve(t,n[1])):{},l=i(o,{...s,by:f,now:d});return await chunkKA6DVHO5_cjs.d(t,l.state),{exit:0,out:{ok:true,warnings:l.warnings,lastEvent:chunkTBLIZIWH_cjs.d(l.state)}}}case "config":{if(n[0]!=="set"||!n[1])return {exit:2,out:{ok:false,usage:h}};let o=await chunkKA6DVHO5_cjs.e(t),e=await x(y__default.default.resolve(t,n[1])),i=chunkTBLIZIWH_cjs.X(o,w(o),e,f,d);return await chunkKA6DVHO5_cjs.d(t,i.state),{exit:0,out:{ok:true,warnings:i.warnings,changed:chunkTBLIZIWH_cjs.d(i.state).payload.changed,config:i.state.config}}}case "unblock":{if(!n[0])return {exit:2,out:{ok:false,usage:h}};let o=n[0],e=await chunkKA6DVHO5_cjs.e(t),i=chunkTBLIZIWH_cjs.s(e,o).blockers.filter(k=>!k.clearedAt).map(k=>k.id);i.length===0&&chunkOSHBJIYD_cjs.b("invalid-input",`item ${o} has no open blocker`,"nothing to clear; check exwf board");let s=a.blocker!==void 0?[a.blocker]:i,l=a.note,c=chunkTBLIZIWH_cjs.V(e,w(e),{type:"blocker.clear",by:f,payload:{id:o,blockers:s,note:l??null}},k=>s.reduce((A,nt)=>chunkYRXFEM3F_cjs.b(A,o,nt,f,d,l),k));return await chunkKA6DVHO5_cjs.d(t,c.state),{exit:0,out:{ok:true,warnings:c.warnings,item:chunkTBLIZIWH_cjs.s(c.state,o)}}}case "decide":{if(!n[0]||n[1]!=="approve"&&n[1]!=="reject")return {exit:2,out:{ok:false,usage:h}};let o=await chunkKA6DVHO5_cjs.e(t),e=o.pending.find(s=>s.id===n[0]),i=chunkYRXFEM3F_cjs.f(o,n[0],n[1],f,a.note??"",d,w(o));return await chunkKA6DVHO5_cjs.d(t,i),{exit:0,out:{ok:true,item:e?.item?chunkTBLIZIWH_cjs.s(i,e.item):null}}}case "status":{let o=await chunkKA6DVHO5_cjs.e(t),e=w(o),i={todo:0,in_progress:0,blocked:0,review:0,awaiting_human:0,done:0,dropped:0};for(let s of Object.values(o.items))i[s.status]+=1;return {exit:0,out:{ok:true,methodology:o.methodology,openIteration:chunkTBLIZIWH_cjs.O(o)??null,counts:i,pending:o.pending,openQuestions:chunkLQJPLXFR_cjs.d(o),lastEvent:chunkTBLIZIWH_cjs.d(o),report:e.report?e.report(o):null}}}case "board":{let o=await chunkKA6DVHO5_cjs.e(t);return {exit:0,out:{ok:true,columns:o.stages.map(i=>({stage:i.id,wipLimit:i.wipLimit??null,items:Object.values(o.items).filter(s=>s.stage===i.id&&s.status!=="dropped").map(s=>({id:s.id,title:s.title,status:s.status,role:s.role??null,age:s.transitions.length?Date.parse(d)-Date.parse(s.transitions[s.transitions.length-1].at):null}))}))}}}case "metrics":{let o=await chunkKA6DVHO5_cjs.e(t);return {exit:0,out:{ok:true,metrics:w(o).metrics(o)}}}case "pending":return {exit:0,out:{ok:true,pending:(await chunkKA6DVHO5_cjs.e(t)).pending}};case "lessons":return {exit:0,out:{ok:true,lessons:(await chunkKA6DVHO5_cjs.e(t)).lessons}};case "validate":{if(!n[0])return {exit:2,out:{ok:false,usage:h}};let o=await chunkKA6DVHO5_cjs.e(t),e=await x(y__default.default.resolve(t,n[0]));return (typeof e!="object"||e===null||Array.isArray(e)||typeof e.type!="string")&&chunkOSHBJIYD_cjs.b("invalid-input",`action file ${n[0]} must hold an object with a string "type"`,'write the action as { "type": "...", "by": "<role>", "payload": { ... } }'),{exit:0,out:{ok:true,violations:chunkTBLIZIWH_cjs.U(o,w(o),e)}}}case "role":{let o=await chunkKA6DVHO5_cjs.e(t);if(n[0]==="list")return {exit:0,out:{ok:true,roles:Object.keys(o.roles),detail:o.roles}};if(n[0]==="add"&&n[1]){let e=await x(y__default.default.resolve(t,n[1]));chunkDVFTTBCT_cjs.b(chunkDVFTTBCT_cjs.e,e,`role manifest ${n[1]}`);let i=chunkLQJPLXFR_cjs.a(o,e,f,d);return await chunkKA6DVHO5_cjs.d(t,i),{exit:0,out:{ok:true,roles:Object.keys(i.roles)}}}return {exit:2,out:{ok:false,usage:h}}}default:return {exit:2,out:{ok:false,usage:h}}}}exports.a=h;exports.b=ot;exports.c=$t;//# sourceMappingURL=chunk-3RJ4RNPG.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-3RJ4RNPG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands.ts"],"names":["factoryOf","name","registeredMethodologies","methodologyFactory","USAGE","BOOLEAN_FLAGS","parseArgs","argv","positional","flags","i","a","key","val","fail","readJson","file","readFile","e","methodologyOf","state","f","withGroundingHooks","num","v","WRITERS","runCommand","cwd","cmd","sub","withStateLock","execute","WorkflowError","rest","by","now","stat","statePath","config","path","roles","r","assertValid","roleSchema","res","init","saveState","s","loadState","item","newItemSchema","applyAction","addItem","getItem","id","patch","itemPatchSchema","editItem","opts","next","checkBriefNames","b","saveBrief","handoff","handoffSchema","role","durationMs","startedAt","acc","complete","saveHandoff","line","s2","correctAccounting","ev","lastEvent","idx","m","c","input","changeConfig","open","blockers","note","clearBlocker","entry","p","decide","counts","openIteration","openQuestions","st","action","validateAction","manifest","registerRole"],"mappings":"mkBA4CA,IAAMA,EAAAA,CAAaC,CAAAA,EACjBA,CAAAA,GAAS,MAAA,EAAaC,mBAAAA,EAAwB,CAAE,QAAA,CAASD,CAAI,CAAA,CACxDE,mBAAAA,CAAmBF,CAAI,CAAA,CACxB,MAAA,CAEOG,CAAAA,CAAQ,CACnB,mGAAA,CACA,6EAAA,CACA,sDAAA,CACA,kHAAA,CACA,0GAAA,CACA,+CACA,iEAAA,CACA,2GAAA,CACA,mDAAA,CACA,gFACF,CAAA,CAOMC,EAAAA,CAAgB,IAAI,GAAA,CAAI,CAAC,UAAU,CAAC,EAEnC,SAASC,EAAAA,CAAUC,CAAAA,CAAwB,CAChD,IAAMC,CAAAA,CAAuB,EAAC,CACxBC,CAAAA,CAAgC,EAAC,CACvC,IAAA,IAASC,CAAAA,CAAI,CAAA,CAAGA,CAAAA,CAAIH,CAAAA,CAAK,MAAA,CAAQG,CAAAA,EAAAA,CAAK,CACpC,IAAMC,CAAAA,CAAIJ,CAAAA,CAAKG,CAAC,CAAA,CAChB,GAAIC,CAAAA,CAAE,UAAA,CAAW,IAAI,CAAA,CAAG,CACtB,IAAMC,CAAAA,CAAMD,CAAAA,CAAE,KAAA,CAAM,CAAC,CAAA,CACrB,GAAIN,EAAAA,CAAc,GAAA,CAAIO,CAAG,CAAA,CAAG,CAC1BH,CAAAA,CAAMG,CAAG,CAAA,CAAI,MAAA,CACb,QACF,CACA,IAAMC,CAAAA,CAAMN,CAAAA,CAA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4RNPG.cjs","sourcesContent":["import { readFile, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport {\n checkBriefNames,\n loadState,\n saveBrief,\n saveHandoff,\n saveState,\n statePath,\n withStateLock,\n} from \"../adapters/file.ts\";\nimport { next as planNext, openQuestions } from \"../core/brief.ts\";\nimport { complete } from \"../core/complete.ts\";\nimport { correctAccounting, type AccountingPatch } from \"../core/accounting.ts\";\nimport { WorkflowError, fail } from \"../core/errors.ts\";\nimport { decide } from \"../core/gates.ts\";\nimport { addItem, editItem, getItem } from \"../core/items/record.ts\";\nimport { clearBlocker } from \"../core/items/blockers.ts\";\nimport type { ItemPatch } from \"../core/types.ts\";\nimport { applyAction, changeConfig, init, validateAction } from \"../core/methodology.ts\";\nimport { openIteration, type PlanOptions } from \"../core/planner.ts\";\nimport { registerRole } from \"../core/roles/registry.ts\";\nimport {\n assertValid,\n handoffSchema,\n itemPatchSchema,\n newItemSchema,\n roleSchema,\n} from \"../schema/index.ts\";\nimport { lastEvent } from \"../core/state.ts\";\nimport { withGroundingHooks } from \"../interface/policies.ts\";\nimport { methodologyFactory, registeredMethodologies } from \"../registry.ts\";\nimport type {\n Accounting,\n Action,\n Handoff,\n ItemStatus,\n Methodology,\n NewItem,\n Role,\n WorkflowState,\n} from \"../core/types.ts\";\n\n/** The factory `name` resolves to in the methodology registry (built-ins pre-registered), if any. */\nconst factoryOf = (name: string | undefined): (() => Methodology) | undefined =>\n name !== undefined && registeredMethodologies().includes(name)\n ? (methodologyFactory(name) as () => Methodology)\n : undefined;\n\nexport const USAGE = [\n \"exwf init <scrum|kanban|waterfall|investigation|experimentation> --config <file> [--roles <file>]\",\n \"exwf add <item.json> [--by who] exwf edit <id> <patch.json> [--by who]\",\n \"exwf next [--max n] [--fallback-tokens-per-weight n]\",\n \"exwf complete <id> <handoff.json> --tokens-in n --tokens-out n --duration-ms n --model m [--estimate] [--role r]\",\n \"exwf account <item> [--line n] [--tokens-in n] [--tokens-out n] [--duration-ms n] [--model m] [--by who]\",\n \"exwf ceremony <name> [input.json] [--by who]\",\n \"exwf decide <pendingId> approve|reject [--by who] [--note text]\",\n \"exwf config set <patch.json> [--by who] exwf unblock <item> [--blocker id] [--note text] [--by who]\",\n \"exwf status | board | metrics | pending | lessons\",\n \"exwf validate <action.json> exwf role add <manifest.json> | role list\",\n];\n\nexport interface Parsed {\n positional: string[];\n flags: Record<string, string>;\n}\n/** Flags that take no value; every other flag needs one. */\nconst BOOLEAN_FLAGS = new Set([\"estimate\"]);\n\nexport function parseArgs(argv: string[]): Parsed {\n const positional: string[] = [];\n const flags: Record<string, string> = {};\n for (let i = 0; i < argv.length; i++) {\n const a = argv[i]!;\n if (a.startsWith(\"--\")) {\n const key = a.slice(2);\n if (BOOLEAN_FLAGS.has(key)) {\n flags[key] = \"true\";\n continue;\n }\n const val = argv[i + 1];\n if (val === undefined || val.startsWith(\"--\"))\n fail(\"invalid-input\", `--${key} needs a value`, `pass --${key} <text>`);\n flags[key] = val;\n i++;\n } else positional.push(a);\n }\n return { positional, flags };\n}\n\nasync function readJson<T>(file: string): Promise<T> {\n try {\n return JSON.parse(await readFile(file, \"utf8\")) as T;\n } catch (e) {\n return fail(\n \"invalid-input\",\n `cannot read JSON from ${file}: ${(e as Error).message}`,\n \"check the path and that the file is valid JSON\",\n );\n }\n}\n\nfunction methodologyOf(state: WorkflowState): Methodology {\n const f = factoryOf(state.methodology);\n if (!f)\n fail(\n \"config-invalid\",\n `methodology \"${state.methodology}\" is not available in this build`,\n `available: ${registeredMethodologies().join(\", \")}`,\n );\n // the reserved context-grounded policy is judged by the SDK's snapshots here too (spec 28, #47)\n return withGroundingHooks(f());\n}\n\nfunction num(flags: Record<string, string>, key: string): number {\n const v = Number(flags[key]);\n if (!Number.isFinite(v))\n fail(\n \"invalid-input\",\n `--${key} must be a number (got ${JSON.stringify(flags[key])})`,\n `pass --${key} <n>`,\n );\n return v;\n}\n\nexport interface CommandResult {\n exit: 0 | 1 | 2;\n out: unknown;\n}\n\n/** Commands that load, change and save the state: they run under .workflow/state.lock. */\nconst WRITERS = new Set([\n \"init\",\n \"add\",\n \"edit\",\n \"next\",\n \"complete\",\n \"account\",\n \"ceremony\",\n \"decide\",\n \"unblock\",\n]);\n\nexport async function runCommand(argv: string[], cwd: string): Promise<CommandResult> {\n try {\n const [cmd, sub] = parseArgs(argv).positional;\n const writes =\n cmd !== undefined &&\n (WRITERS.has(cmd) ||\n (cmd === \"role\" && sub === \"add\") ||\n (cmd === \"config\" && sub === \"set\"));\n return writes ? await withStateLock(cwd, () => execute(argv, cwd)) : await execute(argv, cwd);\n } catch (e) {\n if (e instanceof WorkflowError) return { exit: 1, out: { ok: false, error: e.toJSON() } };\n throw e;\n }\n}\n\nasync function execute(argv: string[], cwd: string): Promise<CommandResult> {\n const { positional, flags } = parseArgs(argv);\n const [cmd, ...rest] = positional;\n const by = flags[\"by\"] ?? \"human\";\n const now = new Date().toISOString();\n switch (cmd) {\n case \"init\": {\n const [name] = rest;\n const f = factoryOf(name);\n if (!f || !flags[\"config\"]) return { exit: 2, out: { ok: false, usage: USAGE } };\n try {\n await stat(statePath(cwd));\n fail(\n \"invalid-input\",\n `${statePath(cwd)} already exists`,\n \"delete .workflow/state.json to start over\",\n );\n } catch (e) {\n if (e instanceof WorkflowError) throw e;\n if ((e as NodeJS.ErrnoException).code !== \"ENOENT\") throw e;\n }\n const config = await readJson<unknown>(path.resolve(cwd, flags[\"config\"]));\n const roles = flags[\"roles\"]\n ? await readJson<Role[]>(path.resolve(cwd, flags[\"roles\"]))\n : undefined;\n if (roles !== undefined) {\n if (!Array.isArray(roles))\n fail(\n \"invalid-input\",\n `roles file ${flags[\"roles\"]} must contain an array of role manifests`,\n \"wrap the manifests in [ ... ]\",\n );\n for (const r of roles) assertValid(roleSchema, r, `roles file ${flags[\"roles\"]}`);\n }\n const res = init(\n roles\n ? { methodology: f(), config, roles, by, now }\n : { methodology: f(), config, by, now },\n );\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n warnings: res.warnings,\n state: {\n methodology: res.state.methodology,\n stages: res.state.stages.map((s) => s.id),\n roles: Object.keys(res.state.roles),\n },\n },\n };\n }\n case \"add\": {\n if (!rest[0]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const item = await readJson<NewItem>(path.resolve(cwd, rest[0]));\n assertValid(newItemSchema, item, `item file ${rest[0]}`);\n const res = applyAction(\n state,\n methodologyOf(state),\n { type: \"item.add\", by, payload: { item } },\n (s) => addItem(s, item, by, now),\n );\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n warnings: res.warnings,\n item: getItem(res.state, item.id),\n },\n };\n }\n case \"edit\": {\n if (!rest[0] || !rest[1]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const id = rest[0];\n const patch = await readJson<ItemPatch>(path.resolve(cwd, rest[1]));\n assertValid(itemPatchSchema, patch, `patch file ${rest[1]}`);\n const res = applyAction(\n state,\n methodologyOf(state),\n { type: \"item.edit\", by, payload: { id, patch } },\n (s) => editItem(s, id, patch, by, now),\n );\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: { ok: true, warnings: res.warnings, item: getItem(res.state, id) },\n };\n }\n case \"next\": {\n const state = await loadState(cwd);\n const opts: PlanOptions = { now };\n if (flags[\"max\"]) opts.max = num(flags, \"max\");\n if (flags[\"fallback-tokens-per-weight\"])\n opts.fallbackTokensPerWeight = num(flags, \"fallback-tokens-per-weight\");\n const res = planNext(state, methodologyOf(state), opts);\n // every brief name is checked first, so a refusal writes none of the batch\n await checkBriefNames(\n cwd,\n res.briefs.map((b) => b.item.id),\n );\n // briefs first: a crash then leaves an orphan brief (overwritten next dispatch), never a dispatched item without one\n for (const b of res.briefs) await saveBrief(cwd, b);\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n reason: res.reason ?? null,\n skipped: res.skipped,\n briefs: res.briefs,\n },\n };\n }\n case \"complete\": {\n if (!rest[0] || !rest[1]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const handoff = await readJson<Handoff>(path.resolve(cwd, rest[1]));\n assertValid(handoffSchema, handoff, `handoff file ${rest[1]}`);\n if (handoff.item !== rest[0])\n fail(\n \"handoff-invalid\",\n `handoff.item \"${handoff.item}\" differs from the command's item \"${rest[0]}\"`,\n \"make them match\",\n );\n const role = flags[\"role\"] ?? handoff.role;\n const durationMs = num(flags, \"duration-ms\");\n const startedAt = Date.parse(now) - durationMs;\n // a negative duration stays accounting-invalid (complete) and a fraction is accepted, as in\n // 1.1; only refuse what Date cannot hold\n if (!Number.isFinite(durationMs) || Number.isNaN(new Date(startedAt).getTime()))\n fail(\n \"invalid-input\",\n `--duration-ms must be a number of milliseconds that dates the start (got ${flags[\"duration-ms\"]})`,\n \"pass the measured wall-clock time in ms, e.g. --duration-ms 42000\",\n );\n const acc: Accounting = {\n item: rest[0],\n role,\n model: flags[\"model\"] ?? \"\",\n tokensIn: num(flags, \"tokens-in\"),\n tokensOut: num(flags, \"tokens-out\"),\n durationMs,\n startedAt: new Date(startedAt).toISOString(),\n endedAt: now,\n };\n if (flags[\"estimate\"] === \"true\") acc.estimate = true;\n const res = complete(state, methodologyOf(state), { ...handoff, role }, acc, now);\n // handoff first: a retry of the same command reproduces the same seq and overwrites an orphan\n await saveHandoff(cwd, handoff, res.state.events.length);\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n warnings: res.warnings,\n item: getItem(res.state, rest[0]),\n },\n };\n }\n case \"account\": {\n if (!rest[0]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const patch: AccountingPatch = {};\n if (flags[\"tokens-in\"] !== undefined) patch.tokensIn = num(flags, \"tokens-in\");\n if (flags[\"tokens-out\"] !== undefined) patch.tokensOut = num(flags, \"tokens-out\");\n if (flags[\"duration-ms\"] !== undefined) patch.durationMs = num(flags, \"duration-ms\");\n if (flags[\"model\"] !== undefined) patch.model = flags[\"model\"];\n const line = flags[\"line\"] !== undefined ? num(flags, \"line\") : undefined;\n const s2 = correctAccounting(state, rest[0], patch, flags[\"by\"] ?? \"human\", now, line);\n await saveState(cwd, s2);\n const ev = lastEvent(s2)!;\n const idx = (ev.payload as { line: number }).line;\n const mine = s2.accounting.filter((a) => a.item === rest[0]);\n return { exit: 0, out: { ok: true, line: mine[idx - 1], event: ev } };\n }\n case \"ceremony\": {\n if (!rest[0]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const m = methodologyOf(state);\n const c = Object.hasOwn(m.ceremonies, rest[0]) ? m.ceremonies[rest[0]] : undefined;\n if (!c)\n fail(\n \"unknown-ceremony\",\n `\"${rest[0]}\" is not a ${m.name} ceremony`,\n `available: ${Object.keys(m.ceremonies).join(\", \")}`,\n );\n const input = rest[1]\n ? await readJson<Record<string, unknown>>(path.resolve(cwd, rest[1]))\n : {};\n const res = c(state, { ...input, by, now });\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n warnings: res.warnings,\n lastEvent: lastEvent(res.state),\n },\n };\n }\n case \"config\": {\n if (rest[0] !== \"set\" || !rest[1]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const patch = await readJson<Record<string, unknown>>(path.resolve(cwd, rest[1]));\n const res = changeConfig(state, methodologyOf(state), patch, by, now);\n await saveState(cwd, res.state);\n return {\n exit: 0,\n out: {\n ok: true,\n warnings: res.warnings,\n changed: (lastEvent(res.state)!.payload as { changed: string[] }).changed,\n config: res.state.config,\n },\n };\n }\n case \"unblock\": {\n if (!rest[0]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const id = rest[0];\n const state = await loadState(cwd);\n const open = getItem(state, id)\n .blockers.filter((b) => !b.clearedAt)\n .map((b) => b.id);\n if (open.length === 0)\n fail(\n \"invalid-input\",\n `item ${id} has no open blocker`,\n \"nothing to clear; check exwf board\",\n );\n const blockers = flags[\"blocker\"] !== undefined ? [flags[\"blocker\"]] : open;\n const note = flags[\"note\"];\n const res = applyAction(\n state,\n methodologyOf(state),\n { type: \"blocker.clear\", by, payload: { id, blockers, note: note ?? null } },\n (s) => blockers.reduce((acc, b) => clearBlocker(acc, id, b, by, now, note), s),\n );\n await saveState(cwd, res.state);\n return { exit: 0, out: { ok: true, warnings: res.warnings, item: getItem(res.state, id) } };\n }\n case \"decide\": {\n if (!rest[0] || (rest[1] !== \"approve\" && rest[1] !== \"reject\"))\n return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const entry = state.pending.find((p) => p.id === rest[0]);\n const s2 = decide(\n state,\n rest[0],\n rest[1],\n by,\n flags[\"note\"] ?? \"\",\n now,\n methodologyOf(state),\n );\n await saveState(cwd, s2);\n return {\n exit: 0,\n out: { ok: true, item: entry?.item ? getItem(s2, entry.item) : null },\n };\n }\n case \"status\": {\n const state = await loadState(cwd);\n const m = methodologyOf(state);\n const counts: Record<ItemStatus, number> = {\n todo: 0,\n in_progress: 0,\n blocked: 0,\n review: 0,\n awaiting_human: 0,\n done: 0,\n dropped: 0,\n };\n for (const i of Object.values(state.items)) counts[i.status] += 1;\n return {\n exit: 0,\n out: {\n ok: true,\n methodology: state.methodology,\n openIteration: openIteration(state) ?? null,\n counts,\n pending: state.pending,\n openQuestions: openQuestions(state),\n lastEvent: lastEvent(state),\n report: m.report ? m.report(state) : null,\n },\n };\n }\n case \"board\": {\n const state = await loadState(cwd);\n const columns = state.stages.map((st) => ({\n stage: st.id,\n wipLimit: st.wipLimit ?? null,\n items: Object.values(state.items)\n .filter((i) => i.stage === st.id && i.status !== \"dropped\")\n .map((i) => ({\n id: i.id,\n title: i.title,\n status: i.status,\n role: i.role ?? null,\n age: i.transitions.length\n ? Date.parse(now) - Date.parse(i.transitions[i.transitions.length - 1]!.at)\n : null,\n })),\n }));\n return { exit: 0, out: { ok: true, columns } };\n }\n case \"metrics\": {\n const state = await loadState(cwd);\n return {\n exit: 0,\n out: { ok: true, metrics: methodologyOf(state).metrics(state) },\n };\n }\n case \"pending\":\n return {\n exit: 0,\n out: { ok: true, pending: (await loadState(cwd)).pending },\n };\n case \"lessons\":\n return {\n exit: 0,\n out: { ok: true, lessons: (await loadState(cwd)).lessons },\n };\n case \"validate\": {\n if (!rest[0]) return { exit: 2, out: { ok: false, usage: USAGE } };\n const state = await loadState(cwd);\n const action = await readJson<Action>(path.resolve(cwd, rest[0]));\n if (\n typeof action !== \"object\" ||\n action === null ||\n Array.isArray(action) ||\n typeof action.type !== \"string\"\n )\n fail(\n \"invalid-input\",\n `action file ${rest[0]} must hold an object with a string \"type\"`,\n 'write the action as { \"type\": \"...\", \"by\": \"<role>\", \"payload\": { ... } }',\n );\n return {\n exit: 0,\n out: {\n ok: true,\n violations: validateAction(state, methodologyOf(state), action),\n },\n };\n }\n case \"role\": {\n const state = await loadState(cwd);\n if (rest[0] === \"list\")\n return {\n exit: 0,\n out: {\n ok: true,\n roles: Object.keys(state.roles),\n detail: state.roles,\n },\n };\n if (rest[0] === \"add\" && rest[1]) {\n const manifest = await readJson<Role>(path.resolve(cwd, rest[1]));\n assertValid(roleSchema, manifest, `role manifest ${rest[1]}`);\n const s2 = registerRole(state, manifest, by, now);\n await saveState(cwd, s2);\n return { exit: 0, out: { ok: true, roles: Object.keys(s2.roles) } };\n }\n return { exit: 2, out: { ok: false, usage: USAGE } };\n }\n default:\n return { exit: 2, out: { ok: false, usage: USAGE } };\n }\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkGKN5M4B7_cjs=require('./chunk-GKN5M4B7.cjs'),chunk6PFJYRM7_cjs=require('./chunk-6PFJYRM7.cjs'),chunkTBLIZIWH_cjs=require('./chunk-TBLIZIWH.cjs'),chunkOSHBJIYD_cjs=require('./chunk-OSHBJIYD.cjs');function $(e,n){let i=chunkTBLIZIWH_cjs.D(e),o=i.transitions.get(n.id)??[],t=n.transitions,c=chunkTBLIZIWH_cjs.F(i,n.id,o),d=c===void 0||o.length!==t.length?t:t.slice(t.length-c),r=new Set;for(let s of d)s.to.status==="in_progress"&&r.add(s.by);for(let s of [n.role,chunkTBLIZIWH_cjs.H(e,n)])s!==void 0&&r.add(s);return [...r]}var v=chunkGKN5M4B7_cjs.a(["low","medium","high","critical"]),G=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),R=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0,Y=new WeakSet;function I(e,n){if(typeof e=="object"&&e!==null&&Y.has(e))return e;let i=(a,p)=>chunkOSHBJIYD_cjs.b("invalid-input",`${n} options: ${a}`,p),o=(a,p,m)=>{for(let y of Object.keys(a))p.includes(y)||i(`unknown key "${y}" in ${m}`,`use only: ${p.join(", ")}`);},t=(a,p)=>{if(a==="human")return a;let m=G(a)?R(a,"capability"):void 0;return (typeof m!="string"||m.trim()===""||Object.keys(a).length!==1)&&i(`${p} must be "human" or { capability: <name> }`,'e.g. ["human"] or [{ "capability": "review" }]'),{capability:m}};G(e)||i("must be an object",'pass { "gates": ["code-review"] }');let c=e;o(c,["gates","table"],"options");let d=R(c,"gates");Array.isArray(d)||i("gates must be an array of gate ids",'e.g. "gates": ["code-review"]');let r=d.map(a=>(chunkOSHBJIYD_cjs.c(a,"risk gate id"),a)),s=R(c,"table"),u;if(s!==void 0){G(s)||i("table must be an object keyed by risk level",`levels: ${v.join(", ")}`);let a=s;o(a,v,"table"),u={};let p=[];for(let m of v){let y=R(a,m);G(y)||i(`table is missing level "${m}"`,`give every level a row, e.g. "${m}": { "requires": [] }`);let h=y;o(h,["requires","evidence"],`table.${m}`);let l=R(h,"requires");Array.isArray(l)||i(`table.${m}.requires must be an array`,'e.g. "requires": ["human"]');let g=R(h,"evidence");g!==void 0&&(!Array.isArray(g)||!g.every(k=>typeof k=="string"&&k.trim()!==""))&&i(`table.${m}.evidence must be an array of evidence kinds`,'e.g. "evidence": ["sbom"]');let w=l.map((k,oe)=>t(k,`table.${m}.requires[${oe}]`)),O=g===void 0?void 0:[...g],V=[...w.map(k=>JSON.stringify(k)),...(O??[]).map(k=>`evidence ${JSON.stringify(k)}`)],J=p.filter(k=>!V.includes(k));J.length&&i(`table.${m} must include everything the level below it adds (missing ${J.join(", ")})`,"a stricter level only adds: copy the lower level's requires and evidence into it"),p=V,u[m]={requires:w,...O===void 0?{}:{evidence:O}};}}let f=chunkGKN5M4B7_cjs.a(u?{gates:r,table:u}:{gates:r});return Y.add(f),f}var re=chunkGKN5M4B7_cjs.a({low:{requires:[]},medium:{requires:[]},high:{requires:["human"]},critical:{requires:["human"]}}),se=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function ae(e){return se(e)&&v.includes(e.level)&&Array.isArray(e.factors)&&e.factors.every(n=>typeof n=="string")&&(e.subject===void 0||typeof e.subject=="string")}function ce(e,n,i,o=$(e,n)){return chunkTBLIZIWH_cjs.l(e,i,"verify")?chunk6PFJYRM7_cjs.a(i,o).length?"not-independent":void 0:"invalid"}function Z(e,n,i,o){let t=I(o,"riskEscalation");if(!t.gates.includes(i.id))return;let c,d="missing",r,s;for(let a of chunkTBLIZIWH_cjs.z(e,n)){if(a.kind!=="risk-assessment")continue;let p=ae(a.data)?ce(e,n,a.by,s??=$(e,n)):"invalid";if(p){c||(d=p,r=a);continue}let m=a.data.level;(!c||v.indexOf(m)>=v.indexOf(c))&&(c=m,d="assessed",r=a);}let u=c??"critical",f=(t.table??re)[u];return {requires:f.requires.map(a=>a==="human"?a:{capability:a.capability}),evidence:[...f.evidence??[]],reason:{level:u,why:d,assessment:r?.ref??null,by:r?.by??null}}}var N=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),C=e=>typeof e=="string"&&e.trim()!=="",W=(e,n)=>Object.keys(e).find(i=>!n.includes(i));function ue(e){return e<32||e>=127&&e<=159||e===1564||e===8206||e===8207||e>=8234&&e<=8238||e>=8294&&e<=8297}function de(e){let n=typeof e!="string"?"not a string":e.length>4096?"longer than 4096 characters":[...e].some(o=>ue(o.codePointAt(0)))?"has a control or bidirectional formatting character":e!==e.trim()?"has leading or trailing whitespace":e!==e.normalize("NFC")?"is not Unicode NFC":e.includes("\\")||/^[A-Za-z]:/.test(e)||!e.split("/").every(o=>o!==""&&o!=="."&&o!=="..")?"is not relative with / separators and no empty, . or .. segment":void 0;return n?`${JSON.stringify(typeof e=="string"&&e.length>80?`${e.slice(0,80)}\u2026`:e)} is not a repository-relative POSIX path (${n})`:void 0}function L(e){if(!N(e))return "data must be an object";let n=W(e,["revision","assumptions"]);if(n)return `unknown key "${n}"`;if(!C(e.revision))return "revision must be a non-empty string";let i=e.assumptions;if(!Array.isArray(i))return "assumptions must be an array";for(let[o,t]of i.entries()){let c=`assumptions[${o}]`;if(!N(t))return `${c} must be an object`;let d=W(t,["claim","required","source"]);if(d)return `unknown key "${d}" in ${c}`;if(!C(t.claim))return `${c}.claim must be a non-empty string`;if(t.required!==void 0&&typeof t.required!="boolean")return `${c}.required must be a boolean`;let r=t.source;if(r===void 0)continue;if(!N(r))return `${c}.source must be an object`;let s=W(r,["path","lines","hash"]);if(s)return `unknown key "${s}" in ${c}.source`;let u=de(r.path);if(u)return `${c}.source.path ${u}`;if(!C(r.hash))return `${c}.source.hash must be a non-empty string`;let f=r.lines;if(f!==void 0&&!(Array.isArray(f)&&f.length===2&&Number.isInteger(f[0])&&Number.isInteger(f[1])&&1<=f[0]&&f[0]<=f[1]))return `${c}.source.lines must be two integers [from, to] with 1 <= from <= to`}}function ee(e,n,i){return typeof n!="string"||n!=="human"&&!Object.hasOwn(e.roles,n)?`${JSON.stringify(n)} is neither human nor a registered role`:i.includes(n)?`"${n}" worked on the item`:void 0}var ne=e=>e.assumptions.some(n=>n.source),Q=({source:e,...n})=>e?{...n,source:{...e,...e.lines?{lines:[...e.lines]}:{}}}:n;function E(e,n){let i=chunkTBLIZIWH_cjs.D(e),o=i.evidence.get(n.id)??[],t=n.evidence,c=chunkTBLIZIWH_cjs.F(i,n.id,o),d=c===void 0?t.length:Math.min(c,t.length),r,s=u=>{let f=t[u];if(f.kind!=="context-snapshot"||L(f.data)!==void 0)return;let a=f.data;return !ne(a)||ee(e,f.by,r??=$(e,n))?void 0:a};for(let u=t.length-1;u>=t.length-d;u--){let f=t[u],a=s(u);if(!a)continue;let p=new Set;for(let l=t.length-1;l>=t.length-d;l--){let g=t[l];if(l!==u&&g.kind==="context-snapshot"&&L(g.data)===void 0)for(let w of g.data.assumptions)w.required&&p.add(w.claim);}let m=a.assumptions.map(l=>p.has(l.claim)?{...Q(l),required:true}:Q(l));for(let l of p)a.assumptions.some(g=>g.claim===l)||m.push({claim:l,required:true});let y=o[u+o.length-t.length]??-1,h=[];for(let l of new Set(a.assumptions.map(g=>g.source?.path))){let g=l===void 0?void 0:i.changed.get(l),w=g?chunkTBLIZIWH_cjs.E(g,y,O=>O[0]):0;g&&w<g.length&&h.push([g[w][0],g[w][1],l]);}return h.sort((l,g)=>l[0]-g[0]||l[1]-g[1]),{revision:a.revision,assumptions:m,snapshot:f.ref,by:f.by,stale:h.map(l=>l[2]),unverified:m.filter(l=>!l.source).map(l=>l.claim)}}}var D=["item","revision","assumptions","ref","by","now"],b=(e,n)=>chunkOSHBJIYD_cjs.b("invalid-input",`context snapshot: ${e}`,n);function Ee(e,n,i){N(i)||b("input must be an object",`pass { ${D.join(", ")} }`);let o=W(i,D);o&&b(`unknown key "${o}"`,`use only: ${D.join(", ")}`);let{item:t,revision:c,assumptions:d,ref:r,by:s,now:u}=i;typeof t!="string"&&b("item must be an item id",'e.g. "item": "CART-12"');let f=chunkTBLIZIWH_cjs.s(e,t),a={revision:c,assumptions:d},p=L(a);p&&b(p,'e.g. { "revision": "4f2c1e0", "assumptions": [{ "claim": "totals are cents", "source": { "path": "src/cart.ts", "hash": "\u2026" } }] }'),C(r)||b("ref must be a non-empty string",'name the snapshot artifact, e.g. "ctx/CART-12.json"'),C(s)||b("by must name who recorded it",'e.g. "by": "scout"');let m=ee(e,s,$(e,f));m&&b(`${m} and may not record its context`,"record as human or a registered role that did not work on the item"),ne(a)||b("a snapshot needs at least one assumption with a source (nothing was verified)",'cite what was checked, e.g. "source": { "path": "src/cart.ts", "hash": "\u2026" }'),u!==void 0&&typeof u!="string"&&b("now must be an ISO timestamp string","omit now to use the clock");let y=JSON.parse(JSON.stringify(a));return chunkTBLIZIWH_cjs.V(e,n,{type:"context.snapshot",by:s,payload:{item:t,ref:r,...y}},h=>chunkTBLIZIWH_cjs.A(h,t,{kind:"context-snapshot",ref:r,by:s,data:y},u))}var fe="policy:custom:context-grounded",P="record a fresh one with recordContextSnapshot";function te(e,n){let i=[],o=(s,u)=>i.push({rule:fe,severity:"error",item:n.id,message:s,fix:u}),t=E(e,n);if(!t)return o(`item "${n.id}" has no qualifying context snapshot (none since its last rework is valid, cites a source and was recorded by human or a registered role that did not work on it)`,`have an independent role or a human verify the context and ${P}`),i;let c=`context snapshot "${t.snapshot}" of "${n.id}"`;t.stale.length&&o(`${c} is stale: ${t.stale.join(", ")} changed since`,`re-verify the claims and ${P}`);let r=t.assumptions.filter(s=>s.required).filter(s=>!s.source).map(s=>s.claim);return r.length&&o(`${c} has unverified required assumption(s): ${r.join(" | ")}`,`cite a source { path, hash } for each and ${P}`),i}var le=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function _e(e,n){let i=I(n,"withRiskGate"),o=e.escalateGate;return {...e,escalateGate(t,c,d){let r=Z(t,c,d,i),s=o?.call(e,t,c,d);return !s||!r?s??r:{requires:[...s.requires,...r.requires],evidence:[...s.evidence,...r.evidence],reason:{...s.reason,...r.reason}}}}}var T="context-grounded",me={kind:"custom",id:T,description:"grounded in a fresh, verified context snapshot"},M=(e,n)=>chunkOSHBJIYD_cjs.b("invalid-input",`withContextGrounding options: ${e}`,n);function ie(e,n){let i=e[n];return i===void 0&&n==="exit"?[]:(Array.isArray(i)||M(`${n} must be an array of stage ids`,`e.g. "${n}": ["dev"]`),i.map(o=>(chunkOSHBJIYD_cjs.c(o,`context-grounded ${n} stage id`),o)))}function ze(e,n){le(n)||M("must be an object",'pass { "entry": ["dev"] }');let i=n;for(let d of Object.keys(i))d!=="entry"&&d!=="exit"&&M(`unknown key "${d}"`,"use only: entry, exit");let o=ie(i,"entry"),t=ie(i,"exit"),c=(d,r)=>r&&!d.some(s=>s.kind==="custom"&&s.id===T)?[...d,me]:d;return {...ge(e),defaultStages(d){let r=e.defaultStages(d);for(let u of [...o,...t])r.some(f=>f.id===u)||chunkOSHBJIYD_cjs.b("invalid-input",`withContextGrounding: unknown stage "${u}"`,`stages: ${r.map(f=>f.id).join(", ")}`);let s=pe(e.name,r);for(let[u,f]of [["entry",o],["exit",t]])for(let a of f)s[u].includes(a)&&chunkOSHBJIYD_cjs.b("invalid-input",`withContextGrounding: the ${e.name} ceremony that moves items ${u==="entry"?"into":"out of"} "${a}" checks its ${u} policies without the grounding hook`,`ground a later stage instead, e.g. ${u} ["${r.find(p=>!s.entry.includes(p.id)&&!s.exit.includes(p.id)&&p.id!==r[0].id)?.id??"dev"}"]`);return r.map(u=>({...u,entryPolicy:c(u.entryPolicy,o.includes(u.id)),exitPolicy:c(u.exitPolicy,t.includes(u.id))}))}}}function pe(e,n){return e==="kanban"?{entry:[],exit:n[0]?[n[0].id]:[]}:e==="scrum"?{entry:[],exit:["backlog"]}:e==="experimentation"?{entry:["building"],exit:[]}:{entry:[],exit:[]}}function ge(e){let{customPolicy:n,briefContext:i}=e;return {...e,customPolicy(o,t,c){return c.id===T?te(o,t):n?.call(e,o,t,c)},briefContext(o,t){return E(o,t)??i?.call(e,o,t)}}}exports.a=v;exports.b=re;exports.c=ce;exports.d=Z;exports.e=de;exports.f=E;exports.g=Ee;exports.h=te;exports.i=_e;exports.j=ze;exports.k=ge;//# sourceMappingURL=chunk-66BO7JFR.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-66BO7JFR.cjs.map
|