ex-workflow 1.1.1 → 1.2.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 +35 -0
- package/README.md +64 -31
- 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-CezCinPF.d.cts → budget-Bm839Qw0.d.cts} +8 -7
- package/dist/{budget-Bd8KpGIr.d.ts → budget-Gckmqj74.d.ts} +8 -7
- package/dist/chunk-32NVJV5C.mjs +2 -0
- package/dist/chunk-32NVJV5C.mjs.map +1 -0
- package/dist/chunk-3GKYL6VB.mjs +6 -0
- package/dist/chunk-3GKYL6VB.mjs.map +1 -0
- package/dist/chunk-3O5MPAJT.cjs +2 -0
- package/dist/chunk-3O5MPAJT.cjs.map +1 -0
- package/dist/{chunk-C2IYMWE6.cjs → chunk-43GLYYA2.cjs} +3 -3
- package/dist/chunk-43GLYYA2.cjs.map +1 -0
- package/dist/chunk-4HG6A3SF.mjs +2 -0
- package/dist/chunk-4HG6A3SF.mjs.map +1 -0
- package/dist/chunk-6D6FL3XK.mjs +2 -0
- package/dist/chunk-6D6FL3XK.mjs.map +1 -0
- package/dist/chunk-7EF47R2J.mjs +2 -0
- package/dist/chunk-7EF47R2J.mjs.map +1 -0
- package/dist/chunk-BBI7AKJK.cjs +2 -0
- package/dist/chunk-BBI7AKJK.cjs.map +1 -0
- package/dist/{chunk-KLWZEXZU.mjs → chunk-BD76VFI4.mjs} +3 -3
- package/dist/chunk-BD76VFI4.mjs.map +1 -0
- package/dist/chunk-BHAEPYRJ.cjs +2 -0
- package/dist/chunk-BHAEPYRJ.cjs.map +1 -0
- package/dist/chunk-BYPFTO7P.mjs +2 -0
- package/dist/chunk-BYPFTO7P.mjs.map +1 -0
- package/dist/chunk-C4ISBUZR.mjs +2 -0
- package/dist/chunk-C4ISBUZR.mjs.map +1 -0
- package/dist/chunk-FDZB73PH.mjs +2 -0
- package/dist/chunk-FDZB73PH.mjs.map +1 -0
- package/dist/chunk-GKN5M4B7.cjs +2 -0
- package/dist/chunk-GKN5M4B7.cjs.map +1 -0
- package/dist/chunk-IDZ435YZ.mjs +2 -0
- package/dist/{chunk-KIQOUUEZ.mjs.map → chunk-IDZ435YZ.mjs.map} +1 -1
- package/dist/chunk-IIEKK2S3.cjs +2 -0
- package/dist/chunk-IIEKK2S3.cjs.map +1 -0
- package/dist/chunk-JNLWI4JM.mjs +2 -0
- package/dist/chunk-JNLWI4JM.mjs.map +1 -0
- package/dist/chunk-K4VSMIJZ.cjs +2 -0
- package/dist/chunk-K4VSMIJZ.cjs.map +1 -0
- package/dist/chunk-LCN4UNYK.cjs +2 -0
- package/dist/chunk-LCN4UNYK.cjs.map +1 -0
- package/dist/chunk-LIATP6LY.mjs +2 -0
- package/dist/chunk-LIATP6LY.mjs.map +1 -0
- package/dist/chunk-MB465DI4.mjs +2 -0
- package/dist/chunk-MB465DI4.mjs.map +1 -0
- package/dist/chunk-OSHBJIYD.cjs +2 -0
- package/dist/chunk-OSHBJIYD.cjs.map +1 -0
- package/dist/chunk-OVR5CK3R.cjs +2 -0
- package/dist/chunk-OVR5CK3R.cjs.map +1 -0
- package/dist/chunk-OZAYOPLB.mjs +2 -0
- package/dist/chunk-OZAYOPLB.mjs.map +1 -0
- package/dist/chunk-PNWRA4JU.cjs +2 -0
- package/dist/{chunk-PO2SPQJP.cjs.map → chunk-PNWRA4JU.cjs.map} +1 -1
- package/dist/chunk-QAENYYU6.cjs +2 -0
- package/dist/chunk-QAENYYU6.cjs.map +1 -0
- package/dist/chunk-RXY434DX.cjs +6 -0
- package/dist/chunk-RXY434DX.cjs.map +1 -0
- package/dist/chunk-SFYUJQYW.cjs +2 -0
- package/dist/chunk-SFYUJQYW.cjs.map +1 -0
- package/dist/chunk-TQR3VFZU.mjs +2 -0
- package/dist/chunk-TQR3VFZU.mjs.map +1 -0
- package/dist/chunk-U3RU5LOF.cjs +2 -0
- package/dist/chunk-U3RU5LOF.cjs.map +1 -0
- package/dist/chunk-UUWDQVIJ.mjs +2 -0
- package/dist/chunk-UUWDQVIJ.mjs.map +1 -0
- package/dist/chunk-VXOZIP77.cjs +2 -0
- package/dist/chunk-VXOZIP77.cjs.map +1 -0
- package/dist/chunk-W2P27645.cjs +2 -0
- package/dist/chunk-W2P27645.cjs.map +1 -0
- package/dist/chunk-WPVL27G4.mjs +2 -0
- package/dist/chunk-WPVL27G4.mjs.map +1 -0
- package/dist/chunk-YS6CXERQ.mjs +2 -0
- package/dist/chunk-YS6CXERQ.mjs.map +1 -0
- package/dist/chunk-Z43GUETW.cjs +2 -0
- package/dist/chunk-Z43GUETW.cjs.map +1 -0
- 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 +143 -15
- package/dist/index.d.ts +143 -15
- 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 +2 -1
- package/dist/kanban/index.d.ts +2 -1
- package/dist/kanban/index.mjs +1 -1
- package/dist/registry/index.cjs +2 -0
- package/dist/registry/index.cjs.map +1 -0
- package/dist/registry/index.d.cts +25 -0
- package/dist/registry/index.d.ts +25 -0
- package/dist/registry/index.mjs +2 -0
- package/dist/registry/index.mjs.map +1 -0
- package/dist/schema/index.cjs +1 -1
- package/dist/schema/index.d.cts +2 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.mjs +1 -1
- package/dist/scrum/index.cjs +1 -1
- package/dist/scrum/index.d.cts +3 -3
- package/dist/scrum/index.d.ts +3 -3
- package/dist/scrum/index.mjs +1 -1
- package/dist/{types-BScHXlRx.d.ts → types-DjePDfms.d.cts} +61 -22
- package/dist/{types-BScHXlRx.d.cts → types-DjePDfms.d.ts} +61 -22
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.mjs +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 +17 -3
- package/dist/chunk-2FRRD6A3.mjs +0 -2
- package/dist/chunk-2FRRD6A3.mjs.map +0 -1
- package/dist/chunk-6P3OKXSK.mjs +0 -2
- package/dist/chunk-6P3OKXSK.mjs.map +0 -1
- package/dist/chunk-7FS6KWTG.cjs +0 -2
- package/dist/chunk-7FS6KWTG.cjs.map +0 -1
- package/dist/chunk-7QQY4KJ2.mjs +0 -2
- package/dist/chunk-7QQY4KJ2.mjs.map +0 -1
- package/dist/chunk-AD4Z3JBL.cjs +0 -2
- package/dist/chunk-AD4Z3JBL.cjs.map +0 -1
- package/dist/chunk-ATCJ4IHP.mjs +0 -2
- package/dist/chunk-ATCJ4IHP.mjs.map +0 -1
- package/dist/chunk-C2IYMWE6.cjs.map +0 -1
- package/dist/chunk-EACZBAP3.cjs +0 -2
- package/dist/chunk-EACZBAP3.cjs.map +0 -1
- package/dist/chunk-EFCUM6DK.mjs +0 -2
- package/dist/chunk-EFCUM6DK.mjs.map +0 -1
- package/dist/chunk-EHBQBXWA.cjs +0 -2
- package/dist/chunk-EHBQBXWA.cjs.map +0 -1
- package/dist/chunk-FTS75UIU.mjs +0 -2
- package/dist/chunk-FTS75UIU.mjs.map +0 -1
- package/dist/chunk-HCRVWMG4.cjs +0 -2
- package/dist/chunk-HCRVWMG4.cjs.map +0 -1
- package/dist/chunk-KIQOUUEZ.mjs +0 -2
- package/dist/chunk-KLWZEXZU.mjs.map +0 -1
- package/dist/chunk-NDCQTRIV.mjs +0 -2
- package/dist/chunk-NDCQTRIV.mjs.map +0 -1
- package/dist/chunk-PMUGU5UJ.cjs +0 -2
- package/dist/chunk-PMUGU5UJ.cjs.map +0 -1
- package/dist/chunk-PO2SPQJP.cjs +0 -2
- package/dist/chunk-QZ6HD6DE.mjs +0 -6
- package/dist/chunk-QZ6HD6DE.mjs.map +0 -1
- package/dist/chunk-RL27372B.cjs +0 -2
- package/dist/chunk-RL27372B.cjs.map +0 -1
- package/dist/chunk-S3BXVHO7.cjs +0 -2
- package/dist/chunk-S3BXVHO7.cjs.map +0 -1
- package/dist/chunk-SP5MC7RR.mjs +0 -2
- package/dist/chunk-SP5MC7RR.mjs.map +0 -1
- package/dist/chunk-SVGTSPZF.cjs +0 -2
- package/dist/chunk-SVGTSPZF.cjs.map +0 -1
- package/dist/chunk-SYLO7FUL.mjs +0 -2
- package/dist/chunk-SYLO7FUL.mjs.map +0 -1
- package/dist/chunk-T3V5UE34.mjs +0 -2
- package/dist/chunk-T3V5UE34.mjs.map +0 -1
- package/dist/chunk-TS66RAJR.cjs +0 -2
- package/dist/chunk-TS66RAJR.cjs.map +0 -1
- package/dist/chunk-U23FUYPD.cjs +0 -6
- package/dist/chunk-U23FUYPD.cjs.map +0 -1
- package/dist/chunk-U6GHFKKE.mjs +0 -2
- package/dist/chunk-U6GHFKKE.mjs.map +0 -1
- package/dist/chunk-YJQ5YJ7S.cjs +0 -2
- package/dist/chunk-YJQ5YJ7S.cjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as ErrorCode, W as WorkflowState, t as MethodologyName, S as Stage, R as Role, o as Event,
|
|
2
|
-
export { z as Baseline, D as Blocker, a as Budget,
|
|
3
|
-
export { E as EstimateMode, Z as ZERO_SPENT, a as addSpent,
|
|
1
|
+
import { s as ErrorCode, W as WorkflowState, t as MethodologyName, S as Stage, R as Role, o as Event, C as Capability, N as NewItem, u as ItemPatch, l as WorkItem, j as ItemStatus, v as Evidence, P as Policy, V as Violation, G as Gate, M as Methodology, T as Transition, r as PendingHuman, w as Iteration, B as Brief, H as Handoff, A as Accounting, x as ApplyResult, g as Rule, y as Action, e as InvestigationState, i as ExperimentationState } from './types-DjePDfms.cjs';
|
|
2
|
+
export { z as Baseline, D as Blocker, a as Budget, f as Ceremony, n as CeremonyInput, m as ClassOfService, k as CoreTerm, p as GateRequirement, F as ImpactAnalysis, J as ItemType, L as Lesson, K as LessonChange, Q as ModelTier, q as Phase, U as PlannerOptions, X as Produced, Y as Spent, Z as Verdict, _ as WorkflowExt } from './types-DjePDfms.cjs';
|
|
3
|
+
export { E as EstimateMode, Z as ZERO_SPENT, a as addSpent, c as canDo, e as estimateTokens, i as isExhausted, r as remaining, b as requireCap, d as requireCapabilities, s as separationLost } from './budget-Bm839Qw0.cjs';
|
|
4
4
|
import { ExNode } from 'ex-flow';
|
|
5
5
|
|
|
6
6
|
interface WorkflowErrorExtra {
|
|
@@ -22,45 +22,86 @@ declare class WorkflowError extends Error {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
declare function fail(code: ErrorCode, message: string, fix: string, extra?: WorkflowErrorExtra): never;
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Ids become object keys and file names: at most 128 of letters, digits, `.`, `_`, `-`; no `..`,
|
|
27
|
+
* no `Object.prototype` member name, no Windows device name (`CON`, `NUL.txt`, `COM1`, ...).
|
|
28
|
+
*/
|
|
26
29
|
declare function assertId(id: unknown, what: string): void;
|
|
27
30
|
|
|
28
31
|
declare function nowOf(now?: string): string;
|
|
29
|
-
interface CreateStateInput {
|
|
30
|
-
methodology:
|
|
32
|
+
interface CreateStateInput<N extends string = MethodologyName> {
|
|
33
|
+
methodology: N;
|
|
31
34
|
config: unknown;
|
|
32
35
|
stages: Stage[];
|
|
33
36
|
roles: Role[];
|
|
34
37
|
now?: string;
|
|
35
38
|
}
|
|
36
39
|
declare function createState(input: CreateStateInput): WorkflowState;
|
|
40
|
+
declare function createState<N extends string>(input: CreateStateInput<N>): WorkflowState<N>;
|
|
41
|
+
declare function createState(input: CreateStateInput): WorkflowState;
|
|
42
|
+
declare function appendEvent<N extends string>(state: WorkflowState<N>, type: string, by: string, payload: unknown, now?: string): WorkflowState<N>;
|
|
37
43
|
declare function appendEvent(state: WorkflowState, type: string, by: string, payload: unknown, now?: string): WorkflowState;
|
|
44
|
+
declare function lastEvent(state: WorkflowState<string>, type?: string): Event | undefined;
|
|
38
45
|
declare function lastEvent(state: WorkflowState, type?: string): Event | undefined;
|
|
39
46
|
|
|
47
|
+
declare function registerRole<N extends string>(state: WorkflowState<N>, role: Role, by: string, now?: string): WorkflowState<N>;
|
|
48
|
+
declare function registerRole(state: WorkflowState, role: Role, by: string, now?: string): WorkflowState;
|
|
49
|
+
declare function retireRole<N extends string>(state: WorkflowState<N>, roleId: string, by: string, now?: string): WorkflowState<N>;
|
|
50
|
+
declare function retireRole(state: WorkflowState, roleId: string, by: string, now?: string): WorkflowState;
|
|
51
|
+
|
|
52
|
+
declare function hasCapability(role: Role, cap: Capability): boolean;
|
|
53
|
+
declare function rolesWith(state: WorkflowState<string>, cap: Capability): Role[];
|
|
54
|
+
declare function rolesWith(state: WorkflowState, cap: Capability): Role[];
|
|
55
|
+
declare function approversFor(state: WorkflowState<string>, gateId: string): Role[];
|
|
56
|
+
declare function approversFor(state: WorkflowState, gateId: string): Role[];
|
|
57
|
+
|
|
58
|
+
declare function stageOf(state: WorkflowState<string>, stageId: string): Stage;
|
|
40
59
|
declare function stageOf(state: WorkflowState, stageId: string): Stage;
|
|
60
|
+
declare function nextStageOf(state: WorkflowState<string>, stageId: string): Stage | undefined;
|
|
41
61
|
declare function nextStageOf(state: WorkflowState, stageId: string): Stage | undefined;
|
|
62
|
+
declare function isTerminalStage(state: WorkflowState<string>, stageId: string): boolean;
|
|
42
63
|
declare function isTerminalStage(state: WorkflowState, stageId: string): boolean;
|
|
64
|
+
|
|
65
|
+
declare function getItem(state: WorkflowState<string>, id: string): WorkItem;
|
|
43
66
|
declare function getItem(state: WorkflowState, id: string): WorkItem;
|
|
67
|
+
declare function addItem<N extends string>(state: WorkflowState<N>, input: NewItem, by: string, now?: string): WorkflowState<N>;
|
|
44
68
|
declare function addItem(state: WorkflowState, input: NewItem, by: string, now?: string): WorkflowState;
|
|
45
|
-
|
|
69
|
+
declare function editItem<N extends string>(state: WorkflowState<N>, id: string, patch: ItemPatch, by: string, now?: string): WorkflowState<N>;
|
|
46
70
|
declare function editItem(state: WorkflowState, id: string, patch: ItemPatch, by: string, now?: string): WorkflowState;
|
|
71
|
+
|
|
72
|
+
declare function moveItem<N extends string>(state: WorkflowState<N>, id: string, to: {
|
|
73
|
+
stage?: string;
|
|
74
|
+
status: ItemStatus;
|
|
75
|
+
}, by: string, now?: string): WorkflowState<N>;
|
|
47
76
|
declare function moveItem(state: WorkflowState, id: string, to: {
|
|
48
77
|
stage?: string;
|
|
49
78
|
status: ItemStatus;
|
|
50
79
|
}, by: string, now?: string): WorkflowState;
|
|
80
|
+
|
|
81
|
+
declare function addEvidence<N extends string>(state: WorkflowState<N>, id: string, evidence: Omit<Evidence, "at">, now?: string): WorkflowState<N>;
|
|
51
82
|
declare function addEvidence(state: WorkflowState, id: string, evidence: Omit<Evidence, "at">, now?: string): WorkflowState;
|
|
83
|
+
|
|
84
|
+
declare function raiseBlocker<N extends string>(state: WorkflowState<N>, id: string, reason: string, owner: string, by: string, now?: string): WorkflowState<N>;
|
|
52
85
|
declare function raiseBlocker(state: WorkflowState, id: string, reason: string, owner: string, by: string, now?: string): WorkflowState;
|
|
86
|
+
declare function clearBlocker<N extends string>(state: WorkflowState<N>, id: string, blockerId: string, by: string, now?: string, note?: string): WorkflowState<N>;
|
|
53
87
|
declare function clearBlocker(state: WorkflowState, id: string, blockerId: string, by: string, now?: string, note?: string): WorkflowState;
|
|
54
88
|
|
|
55
89
|
/** Adds an agreement (idempotent); with `replaces`, retires that one in the same step. */
|
|
90
|
+
declare function applyAgreement<N extends string>(state: WorkflowState<N>, change: {
|
|
91
|
+
text: string;
|
|
92
|
+
replaces?: string;
|
|
93
|
+
}, by: string, now: string): WorkflowState<N>;
|
|
56
94
|
declare function applyAgreement(state: WorkflowState, change: {
|
|
57
95
|
text: string;
|
|
58
96
|
replaces?: string;
|
|
59
97
|
}, by: string, now: string): WorkflowState;
|
|
60
98
|
/** Removes an agreement and records why it left (replacedBy null). */
|
|
99
|
+
declare function retireAgreement<N extends string>(state: WorkflowState<N>, text: string, by: string, now: string): WorkflowState<N>;
|
|
61
100
|
declare function retireAgreement(state: WorkflowState, text: string, by: string, now: string): WorkflowState;
|
|
62
101
|
|
|
102
|
+
declare function evaluatePolicies(state: WorkflowState<string>, item: WorkItem, policies: Policy[]): Violation[];
|
|
63
103
|
declare function evaluatePolicies(state: WorkflowState, item: WorkItem, policies: Policy[]): Violation[];
|
|
104
|
+
declare function assertPolicies(state: WorkflowState<string>, item: WorkItem, policies: Policy[], context: string): void;
|
|
64
105
|
declare function assertPolicies(state: WorkflowState, item: WorkItem, policies: Policy[], context: string): void;
|
|
65
106
|
|
|
66
107
|
type GateResult = {
|
|
@@ -72,19 +113,28 @@ type GateResult = {
|
|
|
72
113
|
violations: Violation[];
|
|
73
114
|
};
|
|
74
115
|
/** Last in_progress dispatch made from a stage that comes STRICTLY BEFORE the item's current stage in `state.stages` order (unknown stage ids count as not-before). */
|
|
116
|
+
declare function lastDispatchBefore(state: WorkflowState<string>, item: WorkItem): Transition | undefined;
|
|
75
117
|
declare function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined;
|
|
76
118
|
/** Role that did the work the gate guards: the last dispatch made from a stage strictly before the current one (so a reviewer dispatched into the gated stage is not its author); else the last dispatch of any stage; undefined if never dispatched. */
|
|
119
|
+
declare function authorOf(state: WorkflowState<string>, item: WorkItem): string | undefined;
|
|
77
120
|
declare function authorOf(state: WorkflowState, item: WorkItem): string | undefined;
|
|
121
|
+
declare function checkGate(state: WorkflowState<string>, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
78
122
|
declare function checkGate(state: WorkflowState, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
123
|
+
declare function raisePending<N extends string>(state: WorkflowState<N>, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState<N>;
|
|
79
124
|
declare function raisePending(state: WorkflowState, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState;
|
|
125
|
+
declare function decide<N extends string>(state: WorkflowState<N>, pendingId: string, decision: "approve" | "reject", by: string, note: string, now?: string, methodology?: Methodology<unknown, N>): WorkflowState<N>;
|
|
80
126
|
declare function decide(state: WorkflowState, pendingId: string, decision: "approve" | "reject", by: string, note: string, now?: string, methodology?: Methodology): WorkflowState;
|
|
81
127
|
|
|
82
128
|
type NodeData = {
|
|
83
129
|
id: string;
|
|
84
130
|
};
|
|
131
|
+
declare function openIteration(state: WorkflowState<string>): Iteration | undefined;
|
|
85
132
|
declare function openIteration(state: WorkflowState): Iteration | undefined;
|
|
133
|
+
declare function assignRole(state: WorkflowState<string>, item: WorkItem, roleFor?: (item: WorkItem) => string | undefined): Role;
|
|
86
134
|
declare function assignRole(state: WorkflowState, item: WorkItem, roleFor?: (item: WorkItem) => string | undefined): Role;
|
|
135
|
+
declare function resourceCapsFor(state: WorkflowState<string>): Record<string, number>;
|
|
87
136
|
declare function resourceCapsFor(state: WorkflowState): Record<string, number>;
|
|
137
|
+
declare function toExNodes(items: WorkItem[], state: WorkflowState<string>, priorityOf?: (item: WorkItem) => number | undefined, roleFor?: (item: WorkItem) => string | undefined): ExNode<NodeData>[];
|
|
88
138
|
declare function toExNodes(items: WorkItem[], state: WorkflowState, priorityOf?: (item: WorkItem) => number | undefined, roleFor?: (item: WorkItem) => string | undefined): ExNode<NodeData>[];
|
|
89
139
|
interface PlanOptions {
|
|
90
140
|
max?: number;
|
|
@@ -98,30 +148,40 @@ interface Skipped {
|
|
|
98
148
|
reason: "entry-policy" | "wip" | "resource-cap" | "budget";
|
|
99
149
|
detail: string;
|
|
100
150
|
}
|
|
101
|
-
interface PlanResult {
|
|
102
|
-
state: WorkflowState
|
|
151
|
+
interface PlanResult<N extends string = MethodologyName> {
|
|
152
|
+
state: WorkflowState<N>;
|
|
103
153
|
dispatched: WorkItem[];
|
|
104
154
|
skipped: Skipped[];
|
|
105
155
|
reason?: PlanReason;
|
|
106
156
|
}
|
|
157
|
+
declare function plan<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, opts?: PlanOptions): PlanResult<N>;
|
|
107
158
|
declare function plan(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): PlanResult;
|
|
108
159
|
|
|
160
|
+
declare function synthesizeBrief<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, item: WorkItem): Brief;
|
|
109
161
|
declare function synthesizeBrief(state: WorkflowState, methodology: Methodology, item: WorkItem): Brief;
|
|
110
162
|
/** Open questions of finished items: the last completion per item, verdict done/needs-review, with open_questions left unanswered. */
|
|
163
|
+
declare function openQuestions(state: WorkflowState<string>): Array<{
|
|
164
|
+
item: string;
|
|
165
|
+
role: string;
|
|
166
|
+
questions: string[];
|
|
167
|
+
at: string;
|
|
168
|
+
}>;
|
|
111
169
|
declare function openQuestions(state: WorkflowState): Array<{
|
|
112
170
|
item: string;
|
|
113
171
|
role: string;
|
|
114
172
|
questions: string[];
|
|
115
173
|
at: string;
|
|
116
174
|
}>;
|
|
117
|
-
interface NextResult {
|
|
118
|
-
state: WorkflowState
|
|
175
|
+
interface NextResult<N extends string = MethodologyName> {
|
|
176
|
+
state: WorkflowState<N>;
|
|
119
177
|
briefs: Brief[];
|
|
120
178
|
skipped: Skipped[];
|
|
121
179
|
reason?: PlanReason;
|
|
122
180
|
}
|
|
181
|
+
declare function next<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, opts?: PlanOptions): NextResult<N>;
|
|
123
182
|
declare function next(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): NextResult;
|
|
124
183
|
|
|
184
|
+
declare function complete<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, handoff: Handoff, acc: Accounting, now?: string): ApplyResult<N>;
|
|
125
185
|
declare function complete(state: WorkflowState, methodology: Methodology, handoff: Handoff, acc: Accounting, now?: string): ApplyResult;
|
|
126
186
|
|
|
127
187
|
interface AccountingPatch {
|
|
@@ -134,14 +194,18 @@ interface AccountingPatch {
|
|
|
134
194
|
* Rewrite one accounting line of an item (`line` is 1-based among the item's lines, default the last).
|
|
135
195
|
* The owning iteration's spent follows the delta, open or closed; the event records before/after.
|
|
136
196
|
*/
|
|
197
|
+
declare function correctAccounting<N extends string>(state: WorkflowState<N>, itemId: string, patch: AccountingPatch, by: string, now?: string, line?: number): WorkflowState<N>;
|
|
137
198
|
declare function correctAccounting(state: WorkflowState, itemId: string, patch: AccountingPatch, by: string, now?: string, line?: number): WorkflowState;
|
|
138
199
|
|
|
200
|
+
declare function coreRulesFor<N extends string = MethodologyName>(methodology: Pick<Methodology, "requiredCapabilities">): Rule<N>[];
|
|
139
201
|
declare function coreRulesFor(methodology: Pick<Methodology, "requiredCapabilities">): Rule[];
|
|
140
202
|
|
|
203
|
+
declare function validateAction<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, action: Action): Violation[];
|
|
141
204
|
declare function validateAction(state: WorkflowState, methodology: Methodology, action: Action): Violation[];
|
|
205
|
+
declare function applyAction<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, action: Action, reduce: (s: WorkflowState<N>) => WorkflowState<N>): ApplyResult<N>;
|
|
142
206
|
declare function applyAction(state: WorkflowState, methodology: Methodology, action: Action, reduce: (s: WorkflowState) => WorkflowState): ApplyResult;
|
|
143
|
-
interface InitInput<C> {
|
|
144
|
-
methodology: Methodology<C>;
|
|
207
|
+
interface InitInput<C, N extends string = MethodologyName> {
|
|
208
|
+
methodology: Methodology<C, N>;
|
|
145
209
|
config: unknown;
|
|
146
210
|
roles?: Role[];
|
|
147
211
|
stages?: Stage[];
|
|
@@ -149,9 +213,73 @@ interface InitInput<C> {
|
|
|
149
213
|
now?: string;
|
|
150
214
|
}
|
|
151
215
|
declare function init<C>(input: InitInput<C>): ApplyResult;
|
|
216
|
+
declare function init<C, N extends string>(input: InitInput<C, N>): ApplyResult<N>;
|
|
217
|
+
declare function init<C>(input: InitInput<C>): ApplyResult;
|
|
152
218
|
/** Change the config between iterations: re-validated, recorded as config.changed, derived state kept in step by the methodology hook. */
|
|
219
|
+
declare function changeConfig<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, patch: Record<string, unknown>, by: string, now?: string): ApplyResult<N>;
|
|
153
220
|
declare function changeConfig(state: WorkflowState, methodology: Methodology, patch: Record<string, unknown>, by: string, now?: string): ApplyResult;
|
|
154
221
|
|
|
155
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Extension records that 1.1 stored as top-level state fields. Writing one also writes its
|
|
224
|
+
* deprecated legacy mirror (`state.investigation`, `state.experimentation`) in memory; on disk
|
|
225
|
+
* only `ext` is stored (spec 26). 2.0 drops the mirror.
|
|
226
|
+
*/
|
|
227
|
+
interface LegacyExtRecords {
|
|
228
|
+
investigation: InvestigationState;
|
|
229
|
+
experimentation: ExperimentationState;
|
|
230
|
+
}
|
|
231
|
+
type LegacyKey = keyof LegacyExtRecords;
|
|
232
|
+
/**
|
|
233
|
+
* Reads the extension record `key` (a methodology name or a common piece id) from `state.ext`.
|
|
234
|
+
* A state written before 1.2 has no `ext`; for `investigation` and `experimentation` the legacy
|
|
235
|
+
* top-level field is read instead.
|
|
236
|
+
*/
|
|
237
|
+
declare function readExt<K extends LegacyKey>(state: WorkflowState<string>, key: K): LegacyExtRecords[K] | undefined;
|
|
238
|
+
declare function readExt<T = unknown>(state: WorkflowState<string>, key: string): T | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Returns a copy of `state` with `state.ext[key] = value`; `undefined` removes the key, and adds
|
|
241
|
+
* no empty `ext` to a state that had none. For `investigation` and `experimentation` the legacy
|
|
242
|
+
* top-level field is written (or removed) too, so SDK code reading `state.investigation` /
|
|
243
|
+
* `state.experimentation` sees the same record (dual-write, spec 26). The mirror is read-only:
|
|
244
|
+
* once `ext.<key>` exists, `readExt` ignores the legacy field. It does not make the state
|
|
245
|
+
* loadable by 1.1.x, whose schema rejects `ext`.
|
|
246
|
+
*/
|
|
247
|
+
declare function writeExt<N extends string, K extends LegacyKey>(state: WorkflowState<N>, key: K, value: LegacyExtRecords[K] | undefined): WorkflowState<N>;
|
|
248
|
+
declare function writeExt<N extends string, T>(state: WorkflowState<N>, key: string, value: T | undefined): WorkflowState<N>;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Independence check: a verifying role must not be one that did the work.
|
|
252
|
+
*
|
|
253
|
+
* Returns the ids in `verifiers` that also appear in `workers`, each once, in verifier order;
|
|
254
|
+
* an empty array means the verification is independent. Ids are compared exactly. The caller
|
|
255
|
+
* decides how a conflict fails (a rule violation, a refused ceremony, a skipped role), so the
|
|
256
|
+
* check carries no message of its own.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* // a validator may not validate a candidate it built or integrated
|
|
260
|
+
* if (independenceConflicts(by, [candidate.author, integration.by]).length) refuse();
|
|
261
|
+
*/
|
|
262
|
+
declare function independenceConflicts(verifiers: string | readonly string[], workers: readonly string[]): string[];
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Frozen-input check: a frozen or preregistered record may not change after freeze.
|
|
266
|
+
*
|
|
267
|
+
* Compares each key of `frozen` (or only `keys`, when given) with the same key of `supplied`
|
|
268
|
+
* and returns the keys whose value differs, in key order; an empty array means the supplied
|
|
269
|
+
* input matches the freeze. Values are compared by identity (`!==`), so freeze primitive
|
|
270
|
+
* fields such as ids, SHAs and refs. Only own fields of `supplied` are read: a missing record,
|
|
271
|
+
* a missing field or an inherited one reads as `undefined`, which counts as a change unless the
|
|
272
|
+
* frozen value is `undefined` too. The caller decides how a change fails, so the check carries
|
|
273
|
+
* no message of its own.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* // a submission must reuse the frozen harness and base SHA
|
|
277
|
+
* if (frozenChanges({ harness, baseSha }, input).length) refuse();
|
|
278
|
+
*/
|
|
279
|
+
declare function frozenChanges<K extends string>(frozen: {
|
|
280
|
+
readonly [P in K]?: unknown;
|
|
281
|
+
}, supplied: object | undefined, keys?: readonly K[]): K[];
|
|
282
|
+
|
|
283
|
+
declare const VERSION = "1.2.0";
|
|
156
284
|
|
|
157
|
-
export { Accounting, type AccountingPatch, Action, ApplyResult, Brief, ErrorCode, Event, Evidence, Gate, type GateResult, Handoff, type InitInput, ItemPatch, ItemStatus, Iteration, Methodology, MethodologyName, NewItem, type NextResult, PendingHuman, type PlanOptions, type PlanReason, type PlanResult, Policy, Role, Rule, type Skipped, Stage, Transition, VERSION, Violation, WorkItem, WorkflowError, WorkflowState, addEvidence, addItem, appendEvent, applyAction, applyAgreement, assertId, assertPolicies, assignRole, authorOf, changeConfig, checkGate, clearBlocker, complete, coreRulesFor, correctAccounting, createState, decide, editItem, evaluatePolicies, fail, getItem, init, isTerminalStage, lastDispatchBefore, lastEvent, moveItem, next, nextStageOf, nowOf, openIteration, openQuestions, plan, raiseBlocker, raisePending, resourceCapsFor, retireAgreement, stageOf, synthesizeBrief, toExNodes, validateAction };
|
|
285
|
+
export { Accounting, type AccountingPatch, Action, ApplyResult, Brief, Capability, ErrorCode, Event, Evidence, Gate, type GateResult, Handoff, type InitInput, ItemPatch, ItemStatus, Iteration, type LegacyExtRecords, Methodology, MethodologyName, NewItem, type NextResult, PendingHuman, type PlanOptions, type PlanReason, type PlanResult, Policy, Role, Rule, type Skipped, Stage, Transition, VERSION, Violation, WorkItem, WorkflowError, WorkflowState, addEvidence, addItem, appendEvent, applyAction, applyAgreement, approversFor, assertId, assertPolicies, assignRole, authorOf, changeConfig, checkGate, clearBlocker, complete, coreRulesFor, correctAccounting, createState, decide, editItem, evaluatePolicies, fail, frozenChanges, getItem, hasCapability, independenceConflicts, init, isTerminalStage, lastDispatchBefore, lastEvent, moveItem, next, nextStageOf, nowOf, openIteration, openQuestions, plan, raiseBlocker, raisePending, readExt, registerRole, resourceCapsFor, retireAgreement, retireRole, rolesWith, stageOf, synthesizeBrief, toExNodes, validateAction, writeExt };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as ErrorCode, W as WorkflowState, t as MethodologyName, S as Stage, R as Role, o as Event,
|
|
2
|
-
export { z as Baseline, D as Blocker, a as Budget,
|
|
3
|
-
export { E as EstimateMode, Z as ZERO_SPENT, a as addSpent,
|
|
1
|
+
import { s as ErrorCode, W as WorkflowState, t as MethodologyName, S as Stage, R as Role, o as Event, C as Capability, N as NewItem, u as ItemPatch, l as WorkItem, j as ItemStatus, v as Evidence, P as Policy, V as Violation, G as Gate, M as Methodology, T as Transition, r as PendingHuman, w as Iteration, B as Brief, H as Handoff, A as Accounting, x as ApplyResult, g as Rule, y as Action, e as InvestigationState, i as ExperimentationState } from './types-DjePDfms.js';
|
|
2
|
+
export { z as Baseline, D as Blocker, a as Budget, f as Ceremony, n as CeremonyInput, m as ClassOfService, k as CoreTerm, p as GateRequirement, F as ImpactAnalysis, J as ItemType, L as Lesson, K as LessonChange, Q as ModelTier, q as Phase, U as PlannerOptions, X as Produced, Y as Spent, Z as Verdict, _ as WorkflowExt } from './types-DjePDfms.js';
|
|
3
|
+
export { E as EstimateMode, Z as ZERO_SPENT, a as addSpent, c as canDo, e as estimateTokens, i as isExhausted, r as remaining, b as requireCap, d as requireCapabilities, s as separationLost } from './budget-Gckmqj74.js';
|
|
4
4
|
import { ExNode } from 'ex-flow';
|
|
5
5
|
|
|
6
6
|
interface WorkflowErrorExtra {
|
|
@@ -22,45 +22,86 @@ declare class WorkflowError extends Error {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
declare function fail(code: ErrorCode, message: string, fix: string, extra?: WorkflowErrorExtra): never;
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Ids become object keys and file names: at most 128 of letters, digits, `.`, `_`, `-`; no `..`,
|
|
27
|
+
* no `Object.prototype` member name, no Windows device name (`CON`, `NUL.txt`, `COM1`, ...).
|
|
28
|
+
*/
|
|
26
29
|
declare function assertId(id: unknown, what: string): void;
|
|
27
30
|
|
|
28
31
|
declare function nowOf(now?: string): string;
|
|
29
|
-
interface CreateStateInput {
|
|
30
|
-
methodology:
|
|
32
|
+
interface CreateStateInput<N extends string = MethodologyName> {
|
|
33
|
+
methodology: N;
|
|
31
34
|
config: unknown;
|
|
32
35
|
stages: Stage[];
|
|
33
36
|
roles: Role[];
|
|
34
37
|
now?: string;
|
|
35
38
|
}
|
|
36
39
|
declare function createState(input: CreateStateInput): WorkflowState;
|
|
40
|
+
declare function createState<N extends string>(input: CreateStateInput<N>): WorkflowState<N>;
|
|
41
|
+
declare function createState(input: CreateStateInput): WorkflowState;
|
|
42
|
+
declare function appendEvent<N extends string>(state: WorkflowState<N>, type: string, by: string, payload: unknown, now?: string): WorkflowState<N>;
|
|
37
43
|
declare function appendEvent(state: WorkflowState, type: string, by: string, payload: unknown, now?: string): WorkflowState;
|
|
44
|
+
declare function lastEvent(state: WorkflowState<string>, type?: string): Event | undefined;
|
|
38
45
|
declare function lastEvent(state: WorkflowState, type?: string): Event | undefined;
|
|
39
46
|
|
|
47
|
+
declare function registerRole<N extends string>(state: WorkflowState<N>, role: Role, by: string, now?: string): WorkflowState<N>;
|
|
48
|
+
declare function registerRole(state: WorkflowState, role: Role, by: string, now?: string): WorkflowState;
|
|
49
|
+
declare function retireRole<N extends string>(state: WorkflowState<N>, roleId: string, by: string, now?: string): WorkflowState<N>;
|
|
50
|
+
declare function retireRole(state: WorkflowState, roleId: string, by: string, now?: string): WorkflowState;
|
|
51
|
+
|
|
52
|
+
declare function hasCapability(role: Role, cap: Capability): boolean;
|
|
53
|
+
declare function rolesWith(state: WorkflowState<string>, cap: Capability): Role[];
|
|
54
|
+
declare function rolesWith(state: WorkflowState, cap: Capability): Role[];
|
|
55
|
+
declare function approversFor(state: WorkflowState<string>, gateId: string): Role[];
|
|
56
|
+
declare function approversFor(state: WorkflowState, gateId: string): Role[];
|
|
57
|
+
|
|
58
|
+
declare function stageOf(state: WorkflowState<string>, stageId: string): Stage;
|
|
40
59
|
declare function stageOf(state: WorkflowState, stageId: string): Stage;
|
|
60
|
+
declare function nextStageOf(state: WorkflowState<string>, stageId: string): Stage | undefined;
|
|
41
61
|
declare function nextStageOf(state: WorkflowState, stageId: string): Stage | undefined;
|
|
62
|
+
declare function isTerminalStage(state: WorkflowState<string>, stageId: string): boolean;
|
|
42
63
|
declare function isTerminalStage(state: WorkflowState, stageId: string): boolean;
|
|
64
|
+
|
|
65
|
+
declare function getItem(state: WorkflowState<string>, id: string): WorkItem;
|
|
43
66
|
declare function getItem(state: WorkflowState, id: string): WorkItem;
|
|
67
|
+
declare function addItem<N extends string>(state: WorkflowState<N>, input: NewItem, by: string, now?: string): WorkflowState<N>;
|
|
44
68
|
declare function addItem(state: WorkflowState, input: NewItem, by: string, now?: string): WorkflowState;
|
|
45
|
-
|
|
69
|
+
declare function editItem<N extends string>(state: WorkflowState<N>, id: string, patch: ItemPatch, by: string, now?: string): WorkflowState<N>;
|
|
46
70
|
declare function editItem(state: WorkflowState, id: string, patch: ItemPatch, by: string, now?: string): WorkflowState;
|
|
71
|
+
|
|
72
|
+
declare function moveItem<N extends string>(state: WorkflowState<N>, id: string, to: {
|
|
73
|
+
stage?: string;
|
|
74
|
+
status: ItemStatus;
|
|
75
|
+
}, by: string, now?: string): WorkflowState<N>;
|
|
47
76
|
declare function moveItem(state: WorkflowState, id: string, to: {
|
|
48
77
|
stage?: string;
|
|
49
78
|
status: ItemStatus;
|
|
50
79
|
}, by: string, now?: string): WorkflowState;
|
|
80
|
+
|
|
81
|
+
declare function addEvidence<N extends string>(state: WorkflowState<N>, id: string, evidence: Omit<Evidence, "at">, now?: string): WorkflowState<N>;
|
|
51
82
|
declare function addEvidence(state: WorkflowState, id: string, evidence: Omit<Evidence, "at">, now?: string): WorkflowState;
|
|
83
|
+
|
|
84
|
+
declare function raiseBlocker<N extends string>(state: WorkflowState<N>, id: string, reason: string, owner: string, by: string, now?: string): WorkflowState<N>;
|
|
52
85
|
declare function raiseBlocker(state: WorkflowState, id: string, reason: string, owner: string, by: string, now?: string): WorkflowState;
|
|
86
|
+
declare function clearBlocker<N extends string>(state: WorkflowState<N>, id: string, blockerId: string, by: string, now?: string, note?: string): WorkflowState<N>;
|
|
53
87
|
declare function clearBlocker(state: WorkflowState, id: string, blockerId: string, by: string, now?: string, note?: string): WorkflowState;
|
|
54
88
|
|
|
55
89
|
/** Adds an agreement (idempotent); with `replaces`, retires that one in the same step. */
|
|
90
|
+
declare function applyAgreement<N extends string>(state: WorkflowState<N>, change: {
|
|
91
|
+
text: string;
|
|
92
|
+
replaces?: string;
|
|
93
|
+
}, by: string, now: string): WorkflowState<N>;
|
|
56
94
|
declare function applyAgreement(state: WorkflowState, change: {
|
|
57
95
|
text: string;
|
|
58
96
|
replaces?: string;
|
|
59
97
|
}, by: string, now: string): WorkflowState;
|
|
60
98
|
/** Removes an agreement and records why it left (replacedBy null). */
|
|
99
|
+
declare function retireAgreement<N extends string>(state: WorkflowState<N>, text: string, by: string, now: string): WorkflowState<N>;
|
|
61
100
|
declare function retireAgreement(state: WorkflowState, text: string, by: string, now: string): WorkflowState;
|
|
62
101
|
|
|
102
|
+
declare function evaluatePolicies(state: WorkflowState<string>, item: WorkItem, policies: Policy[]): Violation[];
|
|
63
103
|
declare function evaluatePolicies(state: WorkflowState, item: WorkItem, policies: Policy[]): Violation[];
|
|
104
|
+
declare function assertPolicies(state: WorkflowState<string>, item: WorkItem, policies: Policy[], context: string): void;
|
|
64
105
|
declare function assertPolicies(state: WorkflowState, item: WorkItem, policies: Policy[], context: string): void;
|
|
65
106
|
|
|
66
107
|
type GateResult = {
|
|
@@ -72,19 +113,28 @@ type GateResult = {
|
|
|
72
113
|
violations: Violation[];
|
|
73
114
|
};
|
|
74
115
|
/** Last in_progress dispatch made from a stage that comes STRICTLY BEFORE the item's current stage in `state.stages` order (unknown stage ids count as not-before). */
|
|
116
|
+
declare function lastDispatchBefore(state: WorkflowState<string>, item: WorkItem): Transition | undefined;
|
|
75
117
|
declare function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined;
|
|
76
118
|
/** Role that did the work the gate guards: the last dispatch made from a stage strictly before the current one (so a reviewer dispatched into the gated stage is not its author); else the last dispatch of any stage; undefined if never dispatched. */
|
|
119
|
+
declare function authorOf(state: WorkflowState<string>, item: WorkItem): string | undefined;
|
|
77
120
|
declare function authorOf(state: WorkflowState, item: WorkItem): string | undefined;
|
|
121
|
+
declare function checkGate(state: WorkflowState<string>, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
78
122
|
declare function checkGate(state: WorkflowState, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
123
|
+
declare function raisePending<N extends string>(state: WorkflowState<N>, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState<N>;
|
|
79
124
|
declare function raisePending(state: WorkflowState, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState;
|
|
125
|
+
declare function decide<N extends string>(state: WorkflowState<N>, pendingId: string, decision: "approve" | "reject", by: string, note: string, now?: string, methodology?: Methodology<unknown, N>): WorkflowState<N>;
|
|
80
126
|
declare function decide(state: WorkflowState, pendingId: string, decision: "approve" | "reject", by: string, note: string, now?: string, methodology?: Methodology): WorkflowState;
|
|
81
127
|
|
|
82
128
|
type NodeData = {
|
|
83
129
|
id: string;
|
|
84
130
|
};
|
|
131
|
+
declare function openIteration(state: WorkflowState<string>): Iteration | undefined;
|
|
85
132
|
declare function openIteration(state: WorkflowState): Iteration | undefined;
|
|
133
|
+
declare function assignRole(state: WorkflowState<string>, item: WorkItem, roleFor?: (item: WorkItem) => string | undefined): Role;
|
|
86
134
|
declare function assignRole(state: WorkflowState, item: WorkItem, roleFor?: (item: WorkItem) => string | undefined): Role;
|
|
135
|
+
declare function resourceCapsFor(state: WorkflowState<string>): Record<string, number>;
|
|
87
136
|
declare function resourceCapsFor(state: WorkflowState): Record<string, number>;
|
|
137
|
+
declare function toExNodes(items: WorkItem[], state: WorkflowState<string>, priorityOf?: (item: WorkItem) => number | undefined, roleFor?: (item: WorkItem) => string | undefined): ExNode<NodeData>[];
|
|
88
138
|
declare function toExNodes(items: WorkItem[], state: WorkflowState, priorityOf?: (item: WorkItem) => number | undefined, roleFor?: (item: WorkItem) => string | undefined): ExNode<NodeData>[];
|
|
89
139
|
interface PlanOptions {
|
|
90
140
|
max?: number;
|
|
@@ -98,30 +148,40 @@ interface Skipped {
|
|
|
98
148
|
reason: "entry-policy" | "wip" | "resource-cap" | "budget";
|
|
99
149
|
detail: string;
|
|
100
150
|
}
|
|
101
|
-
interface PlanResult {
|
|
102
|
-
state: WorkflowState
|
|
151
|
+
interface PlanResult<N extends string = MethodologyName> {
|
|
152
|
+
state: WorkflowState<N>;
|
|
103
153
|
dispatched: WorkItem[];
|
|
104
154
|
skipped: Skipped[];
|
|
105
155
|
reason?: PlanReason;
|
|
106
156
|
}
|
|
157
|
+
declare function plan<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, opts?: PlanOptions): PlanResult<N>;
|
|
107
158
|
declare function plan(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): PlanResult;
|
|
108
159
|
|
|
160
|
+
declare function synthesizeBrief<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, item: WorkItem): Brief;
|
|
109
161
|
declare function synthesizeBrief(state: WorkflowState, methodology: Methodology, item: WorkItem): Brief;
|
|
110
162
|
/** Open questions of finished items: the last completion per item, verdict done/needs-review, with open_questions left unanswered. */
|
|
163
|
+
declare function openQuestions(state: WorkflowState<string>): Array<{
|
|
164
|
+
item: string;
|
|
165
|
+
role: string;
|
|
166
|
+
questions: string[];
|
|
167
|
+
at: string;
|
|
168
|
+
}>;
|
|
111
169
|
declare function openQuestions(state: WorkflowState): Array<{
|
|
112
170
|
item: string;
|
|
113
171
|
role: string;
|
|
114
172
|
questions: string[];
|
|
115
173
|
at: string;
|
|
116
174
|
}>;
|
|
117
|
-
interface NextResult {
|
|
118
|
-
state: WorkflowState
|
|
175
|
+
interface NextResult<N extends string = MethodologyName> {
|
|
176
|
+
state: WorkflowState<N>;
|
|
119
177
|
briefs: Brief[];
|
|
120
178
|
skipped: Skipped[];
|
|
121
179
|
reason?: PlanReason;
|
|
122
180
|
}
|
|
181
|
+
declare function next<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, opts?: PlanOptions): NextResult<N>;
|
|
123
182
|
declare function next(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): NextResult;
|
|
124
183
|
|
|
184
|
+
declare function complete<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, handoff: Handoff, acc: Accounting, now?: string): ApplyResult<N>;
|
|
125
185
|
declare function complete(state: WorkflowState, methodology: Methodology, handoff: Handoff, acc: Accounting, now?: string): ApplyResult;
|
|
126
186
|
|
|
127
187
|
interface AccountingPatch {
|
|
@@ -134,14 +194,18 @@ interface AccountingPatch {
|
|
|
134
194
|
* Rewrite one accounting line of an item (`line` is 1-based among the item's lines, default the last).
|
|
135
195
|
* The owning iteration's spent follows the delta, open or closed; the event records before/after.
|
|
136
196
|
*/
|
|
197
|
+
declare function correctAccounting<N extends string>(state: WorkflowState<N>, itemId: string, patch: AccountingPatch, by: string, now?: string, line?: number): WorkflowState<N>;
|
|
137
198
|
declare function correctAccounting(state: WorkflowState, itemId: string, patch: AccountingPatch, by: string, now?: string, line?: number): WorkflowState;
|
|
138
199
|
|
|
200
|
+
declare function coreRulesFor<N extends string = MethodologyName>(methodology: Pick<Methodology, "requiredCapabilities">): Rule<N>[];
|
|
139
201
|
declare function coreRulesFor(methodology: Pick<Methodology, "requiredCapabilities">): Rule[];
|
|
140
202
|
|
|
203
|
+
declare function validateAction<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, action: Action): Violation[];
|
|
141
204
|
declare function validateAction(state: WorkflowState, methodology: Methodology, action: Action): Violation[];
|
|
205
|
+
declare function applyAction<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, action: Action, reduce: (s: WorkflowState<N>) => WorkflowState<N>): ApplyResult<N>;
|
|
142
206
|
declare function applyAction(state: WorkflowState, methodology: Methodology, action: Action, reduce: (s: WorkflowState) => WorkflowState): ApplyResult;
|
|
143
|
-
interface InitInput<C> {
|
|
144
|
-
methodology: Methodology<C>;
|
|
207
|
+
interface InitInput<C, N extends string = MethodologyName> {
|
|
208
|
+
methodology: Methodology<C, N>;
|
|
145
209
|
config: unknown;
|
|
146
210
|
roles?: Role[];
|
|
147
211
|
stages?: Stage[];
|
|
@@ -149,9 +213,73 @@ interface InitInput<C> {
|
|
|
149
213
|
now?: string;
|
|
150
214
|
}
|
|
151
215
|
declare function init<C>(input: InitInput<C>): ApplyResult;
|
|
216
|
+
declare function init<C, N extends string>(input: InitInput<C, N>): ApplyResult<N>;
|
|
217
|
+
declare function init<C>(input: InitInput<C>): ApplyResult;
|
|
152
218
|
/** Change the config between iterations: re-validated, recorded as config.changed, derived state kept in step by the methodology hook. */
|
|
219
|
+
declare function changeConfig<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, patch: Record<string, unknown>, by: string, now?: string): ApplyResult<N>;
|
|
153
220
|
declare function changeConfig(state: WorkflowState, methodology: Methodology, patch: Record<string, unknown>, by: string, now?: string): ApplyResult;
|
|
154
221
|
|
|
155
|
-
|
|
222
|
+
/**
|
|
223
|
+
* Extension records that 1.1 stored as top-level state fields. Writing one also writes its
|
|
224
|
+
* deprecated legacy mirror (`state.investigation`, `state.experimentation`) in memory; on disk
|
|
225
|
+
* only `ext` is stored (spec 26). 2.0 drops the mirror.
|
|
226
|
+
*/
|
|
227
|
+
interface LegacyExtRecords {
|
|
228
|
+
investigation: InvestigationState;
|
|
229
|
+
experimentation: ExperimentationState;
|
|
230
|
+
}
|
|
231
|
+
type LegacyKey = keyof LegacyExtRecords;
|
|
232
|
+
/**
|
|
233
|
+
* Reads the extension record `key` (a methodology name or a common piece id) from `state.ext`.
|
|
234
|
+
* A state written before 1.2 has no `ext`; for `investigation` and `experimentation` the legacy
|
|
235
|
+
* top-level field is read instead.
|
|
236
|
+
*/
|
|
237
|
+
declare function readExt<K extends LegacyKey>(state: WorkflowState<string>, key: K): LegacyExtRecords[K] | undefined;
|
|
238
|
+
declare function readExt<T = unknown>(state: WorkflowState<string>, key: string): T | undefined;
|
|
239
|
+
/**
|
|
240
|
+
* Returns a copy of `state` with `state.ext[key] = value`; `undefined` removes the key, and adds
|
|
241
|
+
* no empty `ext` to a state that had none. For `investigation` and `experimentation` the legacy
|
|
242
|
+
* top-level field is written (or removed) too, so SDK code reading `state.investigation` /
|
|
243
|
+
* `state.experimentation` sees the same record (dual-write, spec 26). The mirror is read-only:
|
|
244
|
+
* once `ext.<key>` exists, `readExt` ignores the legacy field. It does not make the state
|
|
245
|
+
* loadable by 1.1.x, whose schema rejects `ext`.
|
|
246
|
+
*/
|
|
247
|
+
declare function writeExt<N extends string, K extends LegacyKey>(state: WorkflowState<N>, key: K, value: LegacyExtRecords[K] | undefined): WorkflowState<N>;
|
|
248
|
+
declare function writeExt<N extends string, T>(state: WorkflowState<N>, key: string, value: T | undefined): WorkflowState<N>;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Independence check: a verifying role must not be one that did the work.
|
|
252
|
+
*
|
|
253
|
+
* Returns the ids in `verifiers` that also appear in `workers`, each once, in verifier order;
|
|
254
|
+
* an empty array means the verification is independent. Ids are compared exactly. The caller
|
|
255
|
+
* decides how a conflict fails (a rule violation, a refused ceremony, a skipped role), so the
|
|
256
|
+
* check carries no message of its own.
|
|
257
|
+
*
|
|
258
|
+
* @example
|
|
259
|
+
* // a validator may not validate a candidate it built or integrated
|
|
260
|
+
* if (independenceConflicts(by, [candidate.author, integration.by]).length) refuse();
|
|
261
|
+
*/
|
|
262
|
+
declare function independenceConflicts(verifiers: string | readonly string[], workers: readonly string[]): string[];
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Frozen-input check: a frozen or preregistered record may not change after freeze.
|
|
266
|
+
*
|
|
267
|
+
* Compares each key of `frozen` (or only `keys`, when given) with the same key of `supplied`
|
|
268
|
+
* and returns the keys whose value differs, in key order; an empty array means the supplied
|
|
269
|
+
* input matches the freeze. Values are compared by identity (`!==`), so freeze primitive
|
|
270
|
+
* fields such as ids, SHAs and refs. Only own fields of `supplied` are read: a missing record,
|
|
271
|
+
* a missing field or an inherited one reads as `undefined`, which counts as a change unless the
|
|
272
|
+
* frozen value is `undefined` too. The caller decides how a change fails, so the check carries
|
|
273
|
+
* no message of its own.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* // a submission must reuse the frozen harness and base SHA
|
|
277
|
+
* if (frozenChanges({ harness, baseSha }, input).length) refuse();
|
|
278
|
+
*/
|
|
279
|
+
declare function frozenChanges<K extends string>(frozen: {
|
|
280
|
+
readonly [P in K]?: unknown;
|
|
281
|
+
}, supplied: object | undefined, keys?: readonly K[]): K[];
|
|
282
|
+
|
|
283
|
+
declare const VERSION = "1.2.0";
|
|
156
284
|
|
|
157
|
-
export { Accounting, type AccountingPatch, Action, ApplyResult, Brief, ErrorCode, Event, Evidence, Gate, type GateResult, Handoff, type InitInput, ItemPatch, ItemStatus, Iteration, Methodology, MethodologyName, NewItem, type NextResult, PendingHuman, type PlanOptions, type PlanReason, type PlanResult, Policy, Role, Rule, type Skipped, Stage, Transition, VERSION, Violation, WorkItem, WorkflowError, WorkflowState, addEvidence, addItem, appendEvent, applyAction, applyAgreement, assertId, assertPolicies, assignRole, authorOf, changeConfig, checkGate, clearBlocker, complete, coreRulesFor, correctAccounting, createState, decide, editItem, evaluatePolicies, fail, getItem, init, isTerminalStage, lastDispatchBefore, lastEvent, moveItem, next, nextStageOf, nowOf, openIteration, openQuestions, plan, raiseBlocker, raisePending, resourceCapsFor, retireAgreement, stageOf, synthesizeBrief, toExNodes, validateAction };
|
|
285
|
+
export { Accounting, type AccountingPatch, Action, ApplyResult, Brief, Capability, ErrorCode, Event, Evidence, Gate, type GateResult, Handoff, type InitInput, ItemPatch, ItemStatus, Iteration, type LegacyExtRecords, Methodology, MethodologyName, NewItem, type NextResult, PendingHuman, type PlanOptions, type PlanReason, type PlanResult, Policy, Role, Rule, type Skipped, Stage, Transition, VERSION, Violation, WorkItem, WorkflowError, WorkflowState, addEvidence, addItem, appendEvent, applyAction, applyAgreement, approversFor, assertId, assertPolicies, assignRole, authorOf, changeConfig, checkGate, clearBlocker, complete, coreRulesFor, correctAccounting, createState, decide, editItem, evaluatePolicies, fail, frozenChanges, getItem, hasCapability, independenceConflicts, init, isTerminalStage, lastDispatchBefore, lastEvent, moveItem, next, nextStageOf, nowOf, openIteration, openQuestions, plan, raiseBlocker, raisePending, readExt, registerRole, resourceCapsFor, retireAgreement, retireRole, rolesWith, stageOf, synthesizeBrief, toExNodes, validateAction, writeExt };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{f as complete,g as correctAccounting,e as next,d as openQuestions,a as registerRole,b as retireRole,c as synthesizeBrief}from'./chunk-MB465DI4.mjs';import'./chunk-IDZ435YZ.mjs';export{a as applyAgreement,b as retireAgreement}from'./chunk-LIATP6LY.mjs';export{b as frozenChanges,a as independenceConflicts}from'./chunk-FDZB73PH.mjs';export{a as readExt,b as writeExt}from'./chunk-TQR3VFZU.mjs';export{I as ZERO_SPENT,y as addEvidence,s as addItem,J as addSpent,c as appendEvent,U as applyAction,i as approversFor,C as assertPolicies,O as assignRole,E as authorOf,l as canDo,W as changeConfig,F as checkGate,A as clearBlocker,S as coreRulesFor,b as createState,H as decide,t as editItem,M as estimateTokens,B as evaluatePolicies,r as getItem,f as hasCapability,V as init,L as isExhausted,p as isTerminalStage,D as lastDispatchBefore,d as lastEvent,u as moveItem,o as nextStageOf,a as nowOf,N as openIteration,R as plan,z as raiseBlocker,G as raisePending,K as remaining,m as requireCap,j as requireCapabilities,P as resourceCapsFor,g as rolesWith,k as separationLost,n as stageOf,Q as toExNodes,T as validateAction}from'./chunk-UUWDQVIJ.mjs';export{a as WorkflowError,c as assertId,b as fail}from'./chunk-YS6CXERQ.mjs';var ae="1.2.0";export{ae as VERSION};//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["VERSION"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["VERSION"],"mappings":"wsCAAO,IAAMA,EAAAA,CAAU","file":"index.mjs","sourcesContent":["export const VERSION = \"1.2.0\";\nexport * from \"./core/types.ts\";\nexport { WorkflowError, fail } from \"./core/errors.ts\";\nexport { createState, appendEvent, lastEvent, nowOf } from \"./core/state.ts\";\nexport { registerRole, retireRole } from \"./core/roles/registry.ts\";\nexport { hasCapability, rolesWith, approversFor } from \"./core/roles/lookup.ts\";\nexport { requireCapabilities, separationLost, canDo, requireCap } from \"./core/roles/guards.ts\";\nexport { assertId } from \"./core/errors.ts\";\nexport { stageOf, nextStageOf, isTerminalStage } from \"./core/items/stage.ts\";\nexport { getItem, addItem, editItem } from \"./core/items/record.ts\";\nexport { moveItem } from \"./core/items/move.ts\";\nexport { addEvidence } from \"./core/items/evidence.ts\";\nexport { raiseBlocker, clearBlocker } from \"./core/items/blockers.ts\";\nexport type { ItemPatch } from \"./core/types.ts\";\nexport { applyAgreement, retireAgreement } from \"./core/agreements.ts\";\nexport { evaluatePolicies, assertPolicies } from \"./core/policies.ts\";\nexport { checkGate, authorOf, lastDispatchBefore, raisePending, decide } from \"./core/gates.ts\";\nexport type { GateResult } from \"./core/gates.ts\";\nexport { ZERO_SPENT, addSpent, remaining, isExhausted, estimateTokens } from \"./core/budget.ts\";\nexport type { EstimateMode } from \"./core/budget.ts\";\nexport { plan, toExNodes, assignRole, resourceCapsFor, openIteration } from \"./core/planner.ts\";\nexport type { PlanOptions, PlanReason, PlanResult, Skipped } from \"./core/planner.ts\";\nexport { synthesizeBrief, next, openQuestions } from \"./core/brief.ts\";\nexport type { NextResult } from \"./core/brief.ts\";\nexport { complete } from \"./core/complete.ts\";\nexport { correctAccounting } from \"./core/accounting.ts\";\nexport type { AccountingPatch } from \"./core/accounting.ts\";\nexport { coreRulesFor } from \"./core/rules.ts\";\nexport { applyAction, validateAction, init, changeConfig } from \"./core/methodology.ts\";\nexport type { InitInput } from \"./core/methodology.ts\";\nexport { readExt, writeExt } from \"./interface/ext.ts\";\nexport type { LegacyExtRecords } from \"./interface/ext.ts\";\nexport { independenceConflicts } from \"./common/independence.ts\";\nexport { frozenChanges } from \"./common/frozen.ts\";\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkQAENYYU6_cjs=require('../chunk-QAENYYU6.cjs');require('../chunk-BHAEPYRJ.cjs'),require('../chunk-BBI7AKJK.cjs'),require('../chunk-Z43GUETW.cjs'),require('../chunk-OSHBJIYD.cjs');Object.defineProperty(exports,"investigation",{enumerable:true,get:function(){return chunkQAENYYU6_cjs.b}});Object.defineProperty(exports,"validateInvestigationConfig",{enumerable:true,get:function(){return chunkQAENYYU6_cjs.a}});//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as Budget, M as Methodology } from '../types-
|
|
2
|
-
export { b as BeliefUpdate, E as Experiment, c as Hypothesis, I as InvestigationConclusion, d as InvestigationRound, e as InvestigationState, O as Observation } from '../types-
|
|
1
|
+
import { a as Budget, M as Methodology } from '../types-DjePDfms.cjs';
|
|
2
|
+
export { b as BeliefUpdate, E as Experiment, c as Hypothesis, I as InvestigationConclusion, d as InvestigationRound, e as InvestigationState, O as Observation } from '../types-DjePDfms.cjs';
|
|
3
3
|
|
|
4
4
|
interface InvestigationConfig {
|
|
5
5
|
question: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as Budget, M as Methodology } from '../types-
|
|
2
|
-
export { b as BeliefUpdate, E as Experiment, c as Hypothesis, I as InvestigationConclusion, d as InvestigationRound, e as InvestigationState, O as Observation } from '../types-
|
|
1
|
+
import { a as Budget, M as Methodology } from '../types-DjePDfms.js';
|
|
2
|
+
export { b as BeliefUpdate, E as Experiment, c as Hypothesis, I as InvestigationConclusion, d as InvestigationRound, e as InvestigationState, O as Observation } from '../types-DjePDfms.js';
|
|
3
3
|
|
|
4
4
|
interface InvestigationConfig {
|
|
5
5
|
question: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{b as investigation,a as validateInvestigationConfig}from'../chunk-
|
|
1
|
+
export{b as investigation,a as validateInvestigationConfig}from'../chunk-7EF47R2J.mjs';import'../chunk-FDZB73PH.mjs';import'../chunk-TQR3VFZU.mjs';import'../chunk-UUWDQVIJ.mjs';import'../chunk-YS6CXERQ.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|