ex-workflow 1.1.1 → 1.3.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 +60 -0
- package/README.md +209 -44
- 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-Bd8KpGIr.d.ts → budget-BuQ9GWsg.d.ts} +8 -7
- package/dist/{budget-CezCinPF.d.cts → budget-DDqQQIgp.d.cts} +8 -7
- package/dist/chunk-2FBA7RBS.cjs +2 -0
- package/dist/chunk-2FBA7RBS.cjs.map +1 -0
- package/dist/chunk-3S7F5QXK.mjs +2 -0
- package/dist/chunk-3S7F5QXK.mjs.map +1 -0
- package/dist/chunk-3ZUBCA7Q.cjs +2 -0
- package/dist/chunk-3ZUBCA7Q.cjs.map +1 -0
- package/dist/chunk-4F5HZLKD.cjs +2 -0
- package/dist/chunk-4F5HZLKD.cjs.map +1 -0
- package/dist/chunk-5DCOXGRW.mjs +2 -0
- package/dist/chunk-5DCOXGRW.mjs.map +1 -0
- package/dist/chunk-5GXB6GMX.mjs +2 -0
- package/dist/chunk-5GXB6GMX.mjs.map +1 -0
- package/dist/chunk-5ZGNEY2I.mjs +2 -0
- package/dist/chunk-5ZGNEY2I.mjs.map +1 -0
- package/dist/chunk-6PFJYRM7.cjs +2 -0
- package/dist/chunk-6PFJYRM7.cjs.map +1 -0
- package/dist/chunk-BANKVCYY.cjs +2 -0
- package/dist/chunk-BANKVCYY.cjs.map +1 -0
- package/dist/chunk-BBI7AKJK.cjs +2 -0
- package/dist/chunk-BBI7AKJK.cjs.map +1 -0
- package/dist/chunk-BD665RYK.mjs +2 -0
- package/dist/chunk-BD665RYK.mjs.map +1 -0
- package/dist/chunk-C4ISBUZR.mjs +2 -0
- package/dist/chunk-C4ISBUZR.mjs.map +1 -0
- package/dist/chunk-COPYGMHE.mjs +2 -0
- package/dist/chunk-COPYGMHE.mjs.map +1 -0
- package/dist/chunk-CVGEIXW6.cjs +2 -0
- package/dist/chunk-CVGEIXW6.cjs.map +1 -0
- package/dist/chunk-CX2E7ZTQ.mjs +2 -0
- package/dist/chunk-CX2E7ZTQ.mjs.map +1 -0
- package/dist/chunk-DVFTTBCT.cjs +3 -0
- package/dist/chunk-DVFTTBCT.cjs.map +1 -0
- package/dist/chunk-EQXYFHHD.cjs +2 -0
- package/dist/chunk-EQXYFHHD.cjs.map +1 -0
- package/dist/chunk-GKN5M4B7.cjs +2 -0
- package/dist/chunk-GKN5M4B7.cjs.map +1 -0
- package/dist/chunk-H26KXQ3I.cjs +2 -0
- package/dist/chunk-H26KXQ3I.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-ILDXZWEL.mjs +2 -0
- package/dist/chunk-ILDXZWEL.mjs.map +1 -0
- package/dist/chunk-KA6DVHO5.cjs +6 -0
- package/dist/chunk-KA6DVHO5.cjs.map +1 -0
- package/dist/chunk-KLOSFZFK.cjs +2 -0
- package/dist/chunk-KLOSFZFK.cjs.map +1 -0
- package/dist/chunk-LG23WXAP.mjs +2 -0
- package/dist/chunk-LG23WXAP.mjs.map +1 -0
- package/dist/chunk-MU26QW32.cjs +2 -0
- package/dist/chunk-MU26QW32.cjs.map +1 -0
- package/dist/chunk-OEHVWRJG.mjs +2 -0
- package/dist/chunk-OEHVWRJG.mjs.map +1 -0
- package/dist/chunk-ONVAUZOD.mjs +6 -0
- package/dist/chunk-ONVAUZOD.mjs.map +1 -0
- package/dist/chunk-OSHBJIYD.cjs +2 -0
- package/dist/chunk-OSHBJIYD.cjs.map +1 -0
- package/dist/chunk-PFHVB2WT.mjs +2 -0
- package/dist/chunk-PFHVB2WT.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-QJMOCISZ.mjs +3 -0
- package/dist/chunk-QJMOCISZ.mjs.map +1 -0
- package/dist/chunk-RGHM3JJM.cjs +2 -0
- package/dist/chunk-RGHM3JJM.cjs.map +1 -0
- package/dist/chunk-TQR3VFZU.mjs +2 -0
- package/dist/chunk-TQR3VFZU.mjs.map +1 -0
- package/dist/chunk-UMG3WOD7.cjs +2 -0
- package/dist/chunk-UMG3WOD7.cjs.map +1 -0
- package/dist/chunk-UT7QV6CE.mjs +2 -0
- package/dist/chunk-UT7QV6CE.mjs.map +1 -0
- package/dist/chunk-WU5JELOM.mjs +2 -0
- package/dist/chunk-WU5JELOM.mjs.map +1 -0
- package/dist/chunk-YGCNLXPJ.cjs +2 -0
- package/dist/chunk-YGCNLXPJ.cjs.map +1 -0
- package/dist/chunk-YS6CXERQ.mjs +2 -0
- package/dist/chunk-YS6CXERQ.mjs.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 +145 -15
- package/dist/index.d.ts +145 -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/policies/index.cjs +2 -0
- package/dist/policies/index.cjs.map +1 -0
- package/dist/policies/index.d.cts +199 -0
- package/dist/policies/index.d.ts +199 -0
- package/dist/policies/index.mjs +2 -0
- package/dist/policies/index.mjs.map +1 -0
- 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-DLOtndDY.d.cts} +121 -22
- package/dist/{types-BScHXlRx.d.cts → types-DLOtndDY.d.ts} +121 -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 +30 -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 +0 -3
- 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 +0 -3
- 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 {
|
|
2
|
-
export {
|
|
3
|
-
export { E as EstimateMode, Z as ZERO_SPENT, a as addSpent,
|
|
1
|
+
import { w as ErrorCode, W as WorkflowState, x as MethodologyName, S as Stage, R as Role, t as Event, C as Capability, N as NewItem, y as ItemPatch, l as WorkItem, j as ItemStatus, z as Evidence, P as Policy, M as Methodology, V as Violation, m as Gate, T as Transition, v as PendingHuman, D as Iteration, B as Brief, H as Handoff, A as Accounting, o as ApplyResult, g as Rule, F as Action, e as InvestigationState, i as ExperimentationState } from './types-DLOtndDY.cjs';
|
|
2
|
+
export { J as Baseline, K as Blocker, q as BriefContext, a as Budget, f as Ceremony, s as CeremonyInput, r as ClassOfService, p as ContextAssumption, L as ContextSnapshotData, k as CoreTerm, n as GateEscalation, G as GateRequirement, Q as ImpactAnalysis, U as ItemType, X as Lesson, Y as LessonChange, Z as ModelTier, u as Phase, _ as PlannerOptions, $ as Produced, a0 as Spent, a1 as Verdict, a2 as WorkflowExt } from './types-DLOtndDY.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-DDqQQIgp.cjs';
|
|
4
4
|
import { ExNode } from 'ex-flow';
|
|
5
5
|
|
|
6
6
|
interface WorkflowErrorExtra {
|
|
@@ -22,45 +22,88 @@ 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
|
+
/** The part of a methodology policy evaluation reads: its `customPolicy` hook (spec 27, #36). */
|
|
103
|
+
type PolicyHook<N extends string> = Pick<Methodology<unknown, N>, "customPolicy">;
|
|
104
|
+
declare function evaluatePolicies<N extends string>(state: WorkflowState<N>, item: WorkItem, policies: Policy[], methodology?: PolicyHook<N>): Violation[];
|
|
63
105
|
declare function evaluatePolicies(state: WorkflowState, item: WorkItem, policies: Policy[]): Violation[];
|
|
106
|
+
declare function assertPolicies<N extends string>(state: WorkflowState<N>, item: WorkItem, policies: Policy[], context: string, methodology?: PolicyHook<N>): void;
|
|
64
107
|
declare function assertPolicies(state: WorkflowState, item: WorkItem, policies: Policy[], context: string): void;
|
|
65
108
|
|
|
66
109
|
type GateResult = {
|
|
@@ -72,19 +115,28 @@ type GateResult = {
|
|
|
72
115
|
violations: Violation[];
|
|
73
116
|
};
|
|
74
117
|
/** 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). */
|
|
118
|
+
declare function lastDispatchBefore(state: WorkflowState<string>, item: WorkItem): Transition | undefined;
|
|
75
119
|
declare function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined;
|
|
76
120
|
/** 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. */
|
|
121
|
+
declare function authorOf(state: WorkflowState<string>, item: WorkItem): string | undefined;
|
|
77
122
|
declare function authorOf(state: WorkflowState, item: WorkItem): string | undefined;
|
|
123
|
+
declare function checkGate(state: WorkflowState<string>, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
78
124
|
declare function checkGate(state: WorkflowState, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
125
|
+
declare function raisePending<N extends string>(state: WorkflowState<N>, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState<N>;
|
|
79
126
|
declare function raisePending(state: WorkflowState, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState;
|
|
127
|
+
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
128
|
declare function decide(state: WorkflowState, pendingId: string, decision: "approve" | "reject", by: string, note: string, now?: string, methodology?: Methodology): WorkflowState;
|
|
81
129
|
|
|
82
130
|
type NodeData = {
|
|
83
131
|
id: string;
|
|
84
132
|
};
|
|
133
|
+
declare function openIteration(state: WorkflowState<string>): Iteration | undefined;
|
|
85
134
|
declare function openIteration(state: WorkflowState): Iteration | undefined;
|
|
135
|
+
declare function assignRole(state: WorkflowState<string>, item: WorkItem, roleFor?: (item: WorkItem) => string | undefined): Role;
|
|
86
136
|
declare function assignRole(state: WorkflowState, item: WorkItem, roleFor?: (item: WorkItem) => string | undefined): Role;
|
|
137
|
+
declare function resourceCapsFor(state: WorkflowState<string>): Record<string, number>;
|
|
87
138
|
declare function resourceCapsFor(state: WorkflowState): Record<string, number>;
|
|
139
|
+
declare function toExNodes(items: WorkItem[], state: WorkflowState<string>, priorityOf?: (item: WorkItem) => number | undefined, roleFor?: (item: WorkItem) => string | undefined): ExNode<NodeData>[];
|
|
88
140
|
declare function toExNodes(items: WorkItem[], state: WorkflowState, priorityOf?: (item: WorkItem) => number | undefined, roleFor?: (item: WorkItem) => string | undefined): ExNode<NodeData>[];
|
|
89
141
|
interface PlanOptions {
|
|
90
142
|
max?: number;
|
|
@@ -98,30 +150,40 @@ interface Skipped {
|
|
|
98
150
|
reason: "entry-policy" | "wip" | "resource-cap" | "budget";
|
|
99
151
|
detail: string;
|
|
100
152
|
}
|
|
101
|
-
interface PlanResult {
|
|
102
|
-
state: WorkflowState
|
|
153
|
+
interface PlanResult<N extends string = MethodologyName> {
|
|
154
|
+
state: WorkflowState<N>;
|
|
103
155
|
dispatched: WorkItem[];
|
|
104
156
|
skipped: Skipped[];
|
|
105
157
|
reason?: PlanReason;
|
|
106
158
|
}
|
|
159
|
+
declare function plan<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, opts?: PlanOptions): PlanResult<N>;
|
|
107
160
|
declare function plan(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): PlanResult;
|
|
108
161
|
|
|
162
|
+
declare function synthesizeBrief<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, item: WorkItem): Brief;
|
|
109
163
|
declare function synthesizeBrief(state: WorkflowState, methodology: Methodology, item: WorkItem): Brief;
|
|
110
164
|
/** Open questions of finished items: the last completion per item, verdict done/needs-review, with open_questions left unanswered. */
|
|
165
|
+
declare function openQuestions(state: WorkflowState<string>): Array<{
|
|
166
|
+
item: string;
|
|
167
|
+
role: string;
|
|
168
|
+
questions: string[];
|
|
169
|
+
at: string;
|
|
170
|
+
}>;
|
|
111
171
|
declare function openQuestions(state: WorkflowState): Array<{
|
|
112
172
|
item: string;
|
|
113
173
|
role: string;
|
|
114
174
|
questions: string[];
|
|
115
175
|
at: string;
|
|
116
176
|
}>;
|
|
117
|
-
interface NextResult {
|
|
118
|
-
state: WorkflowState
|
|
177
|
+
interface NextResult<N extends string = MethodologyName> {
|
|
178
|
+
state: WorkflowState<N>;
|
|
119
179
|
briefs: Brief[];
|
|
120
180
|
skipped: Skipped[];
|
|
121
181
|
reason?: PlanReason;
|
|
122
182
|
}
|
|
183
|
+
declare function next<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, opts?: PlanOptions): NextResult<N>;
|
|
123
184
|
declare function next(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): NextResult;
|
|
124
185
|
|
|
186
|
+
declare function complete<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, handoff: Handoff, acc: Accounting, now?: string): ApplyResult<N>;
|
|
125
187
|
declare function complete(state: WorkflowState, methodology: Methodology, handoff: Handoff, acc: Accounting, now?: string): ApplyResult;
|
|
126
188
|
|
|
127
189
|
interface AccountingPatch {
|
|
@@ -134,14 +196,18 @@ interface AccountingPatch {
|
|
|
134
196
|
* Rewrite one accounting line of an item (`line` is 1-based among the item's lines, default the last).
|
|
135
197
|
* The owning iteration's spent follows the delta, open or closed; the event records before/after.
|
|
136
198
|
*/
|
|
199
|
+
declare function correctAccounting<N extends string>(state: WorkflowState<N>, itemId: string, patch: AccountingPatch, by: string, now?: string, line?: number): WorkflowState<N>;
|
|
137
200
|
declare function correctAccounting(state: WorkflowState, itemId: string, patch: AccountingPatch, by: string, now?: string, line?: number): WorkflowState;
|
|
138
201
|
|
|
202
|
+
declare function coreRulesFor<N extends string = MethodologyName>(methodology: Pick<Methodology, "requiredCapabilities">): Rule<N>[];
|
|
139
203
|
declare function coreRulesFor(methodology: Pick<Methodology, "requiredCapabilities">): Rule[];
|
|
140
204
|
|
|
205
|
+
declare function validateAction<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, action: Action): Violation[];
|
|
141
206
|
declare function validateAction(state: WorkflowState, methodology: Methodology, action: Action): Violation[];
|
|
207
|
+
declare function applyAction<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, action: Action, reduce: (s: WorkflowState<N>) => WorkflowState<N>): ApplyResult<N>;
|
|
142
208
|
declare function applyAction(state: WorkflowState, methodology: Methodology, action: Action, reduce: (s: WorkflowState) => WorkflowState): ApplyResult;
|
|
143
|
-
interface InitInput<C> {
|
|
144
|
-
methodology: Methodology<C>;
|
|
209
|
+
interface InitInput<C, N extends string = MethodologyName> {
|
|
210
|
+
methodology: Methodology<C, N>;
|
|
145
211
|
config: unknown;
|
|
146
212
|
roles?: Role[];
|
|
147
213
|
stages?: Stage[];
|
|
@@ -149,9 +215,73 @@ interface InitInput<C> {
|
|
|
149
215
|
now?: string;
|
|
150
216
|
}
|
|
151
217
|
declare function init<C>(input: InitInput<C>): ApplyResult;
|
|
218
|
+
declare function init<C, N extends string>(input: InitInput<C, N>): ApplyResult<N>;
|
|
219
|
+
declare function init<C>(input: InitInput<C>): ApplyResult;
|
|
152
220
|
/** Change the config between iterations: re-validated, recorded as config.changed, derived state kept in step by the methodology hook. */
|
|
221
|
+
declare function changeConfig<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, patch: Record<string, unknown>, by: string, now?: string): ApplyResult<N>;
|
|
153
222
|
declare function changeConfig(state: WorkflowState, methodology: Methodology, patch: Record<string, unknown>, by: string, now?: string): ApplyResult;
|
|
154
223
|
|
|
155
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Extension records that 1.1 stored as top-level state fields. Writing one also writes its
|
|
226
|
+
* deprecated legacy mirror (`state.investigation`, `state.experimentation`) in memory; on disk
|
|
227
|
+
* only `ext` is stored (spec 26). 2.0 drops the mirror.
|
|
228
|
+
*/
|
|
229
|
+
interface LegacyExtRecords {
|
|
230
|
+
investigation: InvestigationState;
|
|
231
|
+
experimentation: ExperimentationState;
|
|
232
|
+
}
|
|
233
|
+
type LegacyKey = keyof LegacyExtRecords;
|
|
234
|
+
/**
|
|
235
|
+
* Reads the extension record `key` (a methodology name or a common piece id) from `state.ext`.
|
|
236
|
+
* A state written before 1.2 has no `ext`; for `investigation` and `experimentation` the legacy
|
|
237
|
+
* top-level field is read instead.
|
|
238
|
+
*/
|
|
239
|
+
declare function readExt<K extends LegacyKey>(state: WorkflowState<string>, key: K): LegacyExtRecords[K] | undefined;
|
|
240
|
+
declare function readExt<T = unknown>(state: WorkflowState<string>, key: string): T | undefined;
|
|
241
|
+
/**
|
|
242
|
+
* Returns a copy of `state` with `state.ext[key] = value`; `undefined` removes the key, and adds
|
|
243
|
+
* no empty `ext` to a state that had none. For `investigation` and `experimentation` the legacy
|
|
244
|
+
* top-level field is written (or removed) too, so SDK code reading `state.investigation` /
|
|
245
|
+
* `state.experimentation` sees the same record (dual-write, spec 26). The mirror is read-only:
|
|
246
|
+
* once `ext.<key>` exists, `readExt` ignores the legacy field. It does not make the state
|
|
247
|
+
* loadable by 1.1.x, whose schema rejects `ext`.
|
|
248
|
+
*/
|
|
249
|
+
declare function writeExt<N extends string, K extends LegacyKey>(state: WorkflowState<N>, key: K, value: LegacyExtRecords[K] | undefined): WorkflowState<N>;
|
|
250
|
+
declare function writeExt<N extends string, T>(state: WorkflowState<N>, key: string, value: T | undefined): WorkflowState<N>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Independence check: a verifying role must not be one that did the work.
|
|
254
|
+
*
|
|
255
|
+
* Returns the ids in `verifiers` that also appear in `workers`, each once, in verifier order;
|
|
256
|
+
* an empty array means the verification is independent. Ids are compared exactly. The caller
|
|
257
|
+
* decides how a conflict fails (a rule violation, a refused ceremony, a skipped role), so the
|
|
258
|
+
* check carries no message of its own.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* // a validator may not validate a candidate it built or integrated
|
|
262
|
+
* if (independenceConflicts(by, [candidate.author, integration.by]).length) refuse();
|
|
263
|
+
*/
|
|
264
|
+
declare function independenceConflicts(verifiers: string | readonly string[], workers: readonly string[]): string[];
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Frozen-input check: a frozen or preregistered record may not change after freeze.
|
|
268
|
+
*
|
|
269
|
+
* Compares each key of `frozen` (or only `keys`, when given) with the same key of `supplied`
|
|
270
|
+
* and returns the keys whose value differs, in key order; an empty array means the supplied
|
|
271
|
+
* input matches the freeze. Values are compared by identity (`!==`), so freeze primitive
|
|
272
|
+
* fields such as ids, SHAs and refs. Only own fields of `supplied` are read: a missing record,
|
|
273
|
+
* a missing field or an inherited one reads as `undefined`, which counts as a change unless the
|
|
274
|
+
* frozen value is `undefined` too. The caller decides how a change fails, so the check carries
|
|
275
|
+
* no message of its own.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* // a submission must reuse the frozen harness and base SHA
|
|
279
|
+
* if (frozenChanges({ harness, baseSha }, input).length) refuse();
|
|
280
|
+
*/
|
|
281
|
+
declare function frozenChanges<K extends string>(frozen: {
|
|
282
|
+
readonly [P in K]?: unknown;
|
|
283
|
+
}, supplied: object | undefined, keys?: readonly K[]): K[];
|
|
284
|
+
|
|
285
|
+
declare const VERSION = "1.3.0";
|
|
156
286
|
|
|
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 };
|
|
287
|
+
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 {
|
|
2
|
-
export {
|
|
3
|
-
export { E as EstimateMode, Z as ZERO_SPENT, a as addSpent,
|
|
1
|
+
import { w as ErrorCode, W as WorkflowState, x as MethodologyName, S as Stage, R as Role, t as Event, C as Capability, N as NewItem, y as ItemPatch, l as WorkItem, j as ItemStatus, z as Evidence, P as Policy, M as Methodology, V as Violation, m as Gate, T as Transition, v as PendingHuman, D as Iteration, B as Brief, H as Handoff, A as Accounting, o as ApplyResult, g as Rule, F as Action, e as InvestigationState, i as ExperimentationState } from './types-DLOtndDY.js';
|
|
2
|
+
export { J as Baseline, K as Blocker, q as BriefContext, a as Budget, f as Ceremony, s as CeremonyInput, r as ClassOfService, p as ContextAssumption, L as ContextSnapshotData, k as CoreTerm, n as GateEscalation, G as GateRequirement, Q as ImpactAnalysis, U as ItemType, X as Lesson, Y as LessonChange, Z as ModelTier, u as Phase, _ as PlannerOptions, $ as Produced, a0 as Spent, a1 as Verdict, a2 as WorkflowExt } from './types-DLOtndDY.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-BuQ9GWsg.js';
|
|
4
4
|
import { ExNode } from 'ex-flow';
|
|
5
5
|
|
|
6
6
|
interface WorkflowErrorExtra {
|
|
@@ -22,45 +22,88 @@ 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
|
+
/** The part of a methodology policy evaluation reads: its `customPolicy` hook (spec 27, #36). */
|
|
103
|
+
type PolicyHook<N extends string> = Pick<Methodology<unknown, N>, "customPolicy">;
|
|
104
|
+
declare function evaluatePolicies<N extends string>(state: WorkflowState<N>, item: WorkItem, policies: Policy[], methodology?: PolicyHook<N>): Violation[];
|
|
63
105
|
declare function evaluatePolicies(state: WorkflowState, item: WorkItem, policies: Policy[]): Violation[];
|
|
106
|
+
declare function assertPolicies<N extends string>(state: WorkflowState<N>, item: WorkItem, policies: Policy[], context: string, methodology?: PolicyHook<N>): void;
|
|
64
107
|
declare function assertPolicies(state: WorkflowState, item: WorkItem, policies: Policy[], context: string): void;
|
|
65
108
|
|
|
66
109
|
type GateResult = {
|
|
@@ -72,19 +115,28 @@ type GateResult = {
|
|
|
72
115
|
violations: Violation[];
|
|
73
116
|
};
|
|
74
117
|
/** 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). */
|
|
118
|
+
declare function lastDispatchBefore(state: WorkflowState<string>, item: WorkItem): Transition | undefined;
|
|
75
119
|
declare function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined;
|
|
76
120
|
/** 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. */
|
|
121
|
+
declare function authorOf(state: WorkflowState<string>, item: WorkItem): string | undefined;
|
|
77
122
|
declare function authorOf(state: WorkflowState, item: WorkItem): string | undefined;
|
|
123
|
+
declare function checkGate(state: WorkflowState<string>, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
78
124
|
declare function checkGate(state: WorkflowState, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
125
|
+
declare function raisePending<N extends string>(state: WorkflowState<N>, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState<N>;
|
|
79
126
|
declare function raisePending(state: WorkflowState, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState;
|
|
127
|
+
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
128
|
declare function decide(state: WorkflowState, pendingId: string, decision: "approve" | "reject", by: string, note: string, now?: string, methodology?: Methodology): WorkflowState;
|
|
81
129
|
|
|
82
130
|
type NodeData = {
|
|
83
131
|
id: string;
|
|
84
132
|
};
|
|
133
|
+
declare function openIteration(state: WorkflowState<string>): Iteration | undefined;
|
|
85
134
|
declare function openIteration(state: WorkflowState): Iteration | undefined;
|
|
135
|
+
declare function assignRole(state: WorkflowState<string>, item: WorkItem, roleFor?: (item: WorkItem) => string | undefined): Role;
|
|
86
136
|
declare function assignRole(state: WorkflowState, item: WorkItem, roleFor?: (item: WorkItem) => string | undefined): Role;
|
|
137
|
+
declare function resourceCapsFor(state: WorkflowState<string>): Record<string, number>;
|
|
87
138
|
declare function resourceCapsFor(state: WorkflowState): Record<string, number>;
|
|
139
|
+
declare function toExNodes(items: WorkItem[], state: WorkflowState<string>, priorityOf?: (item: WorkItem) => number | undefined, roleFor?: (item: WorkItem) => string | undefined): ExNode<NodeData>[];
|
|
88
140
|
declare function toExNodes(items: WorkItem[], state: WorkflowState, priorityOf?: (item: WorkItem) => number | undefined, roleFor?: (item: WorkItem) => string | undefined): ExNode<NodeData>[];
|
|
89
141
|
interface PlanOptions {
|
|
90
142
|
max?: number;
|
|
@@ -98,30 +150,40 @@ interface Skipped {
|
|
|
98
150
|
reason: "entry-policy" | "wip" | "resource-cap" | "budget";
|
|
99
151
|
detail: string;
|
|
100
152
|
}
|
|
101
|
-
interface PlanResult {
|
|
102
|
-
state: WorkflowState
|
|
153
|
+
interface PlanResult<N extends string = MethodologyName> {
|
|
154
|
+
state: WorkflowState<N>;
|
|
103
155
|
dispatched: WorkItem[];
|
|
104
156
|
skipped: Skipped[];
|
|
105
157
|
reason?: PlanReason;
|
|
106
158
|
}
|
|
159
|
+
declare function plan<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, opts?: PlanOptions): PlanResult<N>;
|
|
107
160
|
declare function plan(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): PlanResult;
|
|
108
161
|
|
|
162
|
+
declare function synthesizeBrief<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, item: WorkItem): Brief;
|
|
109
163
|
declare function synthesizeBrief(state: WorkflowState, methodology: Methodology, item: WorkItem): Brief;
|
|
110
164
|
/** Open questions of finished items: the last completion per item, verdict done/needs-review, with open_questions left unanswered. */
|
|
165
|
+
declare function openQuestions(state: WorkflowState<string>): Array<{
|
|
166
|
+
item: string;
|
|
167
|
+
role: string;
|
|
168
|
+
questions: string[];
|
|
169
|
+
at: string;
|
|
170
|
+
}>;
|
|
111
171
|
declare function openQuestions(state: WorkflowState): Array<{
|
|
112
172
|
item: string;
|
|
113
173
|
role: string;
|
|
114
174
|
questions: string[];
|
|
115
175
|
at: string;
|
|
116
176
|
}>;
|
|
117
|
-
interface NextResult {
|
|
118
|
-
state: WorkflowState
|
|
177
|
+
interface NextResult<N extends string = MethodologyName> {
|
|
178
|
+
state: WorkflowState<N>;
|
|
119
179
|
briefs: Brief[];
|
|
120
180
|
skipped: Skipped[];
|
|
121
181
|
reason?: PlanReason;
|
|
122
182
|
}
|
|
183
|
+
declare function next<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, opts?: PlanOptions): NextResult<N>;
|
|
123
184
|
declare function next(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): NextResult;
|
|
124
185
|
|
|
186
|
+
declare function complete<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, handoff: Handoff, acc: Accounting, now?: string): ApplyResult<N>;
|
|
125
187
|
declare function complete(state: WorkflowState, methodology: Methodology, handoff: Handoff, acc: Accounting, now?: string): ApplyResult;
|
|
126
188
|
|
|
127
189
|
interface AccountingPatch {
|
|
@@ -134,14 +196,18 @@ interface AccountingPatch {
|
|
|
134
196
|
* Rewrite one accounting line of an item (`line` is 1-based among the item's lines, default the last).
|
|
135
197
|
* The owning iteration's spent follows the delta, open or closed; the event records before/after.
|
|
136
198
|
*/
|
|
199
|
+
declare function correctAccounting<N extends string>(state: WorkflowState<N>, itemId: string, patch: AccountingPatch, by: string, now?: string, line?: number): WorkflowState<N>;
|
|
137
200
|
declare function correctAccounting(state: WorkflowState, itemId: string, patch: AccountingPatch, by: string, now?: string, line?: number): WorkflowState;
|
|
138
201
|
|
|
202
|
+
declare function coreRulesFor<N extends string = MethodologyName>(methodology: Pick<Methodology, "requiredCapabilities">): Rule<N>[];
|
|
139
203
|
declare function coreRulesFor(methodology: Pick<Methodology, "requiredCapabilities">): Rule[];
|
|
140
204
|
|
|
205
|
+
declare function validateAction<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, action: Action): Violation[];
|
|
141
206
|
declare function validateAction(state: WorkflowState, methodology: Methodology, action: Action): Violation[];
|
|
207
|
+
declare function applyAction<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, action: Action, reduce: (s: WorkflowState<N>) => WorkflowState<N>): ApplyResult<N>;
|
|
142
208
|
declare function applyAction(state: WorkflowState, methodology: Methodology, action: Action, reduce: (s: WorkflowState) => WorkflowState): ApplyResult;
|
|
143
|
-
interface InitInput<C> {
|
|
144
|
-
methodology: Methodology<C>;
|
|
209
|
+
interface InitInput<C, N extends string = MethodologyName> {
|
|
210
|
+
methodology: Methodology<C, N>;
|
|
145
211
|
config: unknown;
|
|
146
212
|
roles?: Role[];
|
|
147
213
|
stages?: Stage[];
|
|
@@ -149,9 +215,73 @@ interface InitInput<C> {
|
|
|
149
215
|
now?: string;
|
|
150
216
|
}
|
|
151
217
|
declare function init<C>(input: InitInput<C>): ApplyResult;
|
|
218
|
+
declare function init<C, N extends string>(input: InitInput<C, N>): ApplyResult<N>;
|
|
219
|
+
declare function init<C>(input: InitInput<C>): ApplyResult;
|
|
152
220
|
/** Change the config between iterations: re-validated, recorded as config.changed, derived state kept in step by the methodology hook. */
|
|
221
|
+
declare function changeConfig<N extends string>(state: WorkflowState<N>, methodology: Methodology<unknown, N>, patch: Record<string, unknown>, by: string, now?: string): ApplyResult<N>;
|
|
153
222
|
declare function changeConfig(state: WorkflowState, methodology: Methodology, patch: Record<string, unknown>, by: string, now?: string): ApplyResult;
|
|
154
223
|
|
|
155
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Extension records that 1.1 stored as top-level state fields. Writing one also writes its
|
|
226
|
+
* deprecated legacy mirror (`state.investigation`, `state.experimentation`) in memory; on disk
|
|
227
|
+
* only `ext` is stored (spec 26). 2.0 drops the mirror.
|
|
228
|
+
*/
|
|
229
|
+
interface LegacyExtRecords {
|
|
230
|
+
investigation: InvestigationState;
|
|
231
|
+
experimentation: ExperimentationState;
|
|
232
|
+
}
|
|
233
|
+
type LegacyKey = keyof LegacyExtRecords;
|
|
234
|
+
/**
|
|
235
|
+
* Reads the extension record `key` (a methodology name or a common piece id) from `state.ext`.
|
|
236
|
+
* A state written before 1.2 has no `ext`; for `investigation` and `experimentation` the legacy
|
|
237
|
+
* top-level field is read instead.
|
|
238
|
+
*/
|
|
239
|
+
declare function readExt<K extends LegacyKey>(state: WorkflowState<string>, key: K): LegacyExtRecords[K] | undefined;
|
|
240
|
+
declare function readExt<T = unknown>(state: WorkflowState<string>, key: string): T | undefined;
|
|
241
|
+
/**
|
|
242
|
+
* Returns a copy of `state` with `state.ext[key] = value`; `undefined` removes the key, and adds
|
|
243
|
+
* no empty `ext` to a state that had none. For `investigation` and `experimentation` the legacy
|
|
244
|
+
* top-level field is written (or removed) too, so SDK code reading `state.investigation` /
|
|
245
|
+
* `state.experimentation` sees the same record (dual-write, spec 26). The mirror is read-only:
|
|
246
|
+
* once `ext.<key>` exists, `readExt` ignores the legacy field. It does not make the state
|
|
247
|
+
* loadable by 1.1.x, whose schema rejects `ext`.
|
|
248
|
+
*/
|
|
249
|
+
declare function writeExt<N extends string, K extends LegacyKey>(state: WorkflowState<N>, key: K, value: LegacyExtRecords[K] | undefined): WorkflowState<N>;
|
|
250
|
+
declare function writeExt<N extends string, T>(state: WorkflowState<N>, key: string, value: T | undefined): WorkflowState<N>;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Independence check: a verifying role must not be one that did the work.
|
|
254
|
+
*
|
|
255
|
+
* Returns the ids in `verifiers` that also appear in `workers`, each once, in verifier order;
|
|
256
|
+
* an empty array means the verification is independent. Ids are compared exactly. The caller
|
|
257
|
+
* decides how a conflict fails (a rule violation, a refused ceremony, a skipped role), so the
|
|
258
|
+
* check carries no message of its own.
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* // a validator may not validate a candidate it built or integrated
|
|
262
|
+
* if (independenceConflicts(by, [candidate.author, integration.by]).length) refuse();
|
|
263
|
+
*/
|
|
264
|
+
declare function independenceConflicts(verifiers: string | readonly string[], workers: readonly string[]): string[];
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Frozen-input check: a frozen or preregistered record may not change after freeze.
|
|
268
|
+
*
|
|
269
|
+
* Compares each key of `frozen` (or only `keys`, when given) with the same key of `supplied`
|
|
270
|
+
* and returns the keys whose value differs, in key order; an empty array means the supplied
|
|
271
|
+
* input matches the freeze. Values are compared by identity (`!==`), so freeze primitive
|
|
272
|
+
* fields such as ids, SHAs and refs. Only own fields of `supplied` are read: a missing record,
|
|
273
|
+
* a missing field or an inherited one reads as `undefined`, which counts as a change unless the
|
|
274
|
+
* frozen value is `undefined` too. The caller decides how a change fails, so the check carries
|
|
275
|
+
* no message of its own.
|
|
276
|
+
*
|
|
277
|
+
* @example
|
|
278
|
+
* // a submission must reuse the frozen harness and base SHA
|
|
279
|
+
* if (frozenChanges({ harness, baseSha }, input).length) refuse();
|
|
280
|
+
*/
|
|
281
|
+
declare function frozenChanges<K extends string>(frozen: {
|
|
282
|
+
readonly [P in K]?: unknown;
|
|
283
|
+
}, supplied: object | undefined, keys?: readonly K[]): K[];
|
|
284
|
+
|
|
285
|
+
declare const VERSION = "1.3.0";
|
|
156
286
|
|
|
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 };
|
|
287
|
+
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-5GXB6GMX.mjs';import'./chunk-IDZ435YZ.mjs';export{a as applyAgreement,b as retireAgreement}from'./chunk-PFHVB2WT.mjs';export{a as frozenChanges}from'./chunk-BD665RYK.mjs';export{a as independenceConflicts}from'./chunk-WU5JELOM.mjs';export{a as readExt,b as writeExt}from'./chunk-TQR3VFZU.mjs';export{K as ZERO_SPENT,z as addEvidence,s as addItem,L as addSpent,c as appendEvent,W as applyAction,i as approversFor,D as assertPolicies,Q as assignRole,G as authorOf,l as canDo,Y as changeConfig,H as checkGate,B as clearBlocker,U as coreRulesFor,b as createState,J as decide,t as editItem,O as estimateTokens,C as evaluatePolicies,r as getItem,f as hasCapability,X as init,N as isExhausted,p as isTerminalStage,F as lastDispatchBefore,d as lastEvent,u as moveItem,o as nextStageOf,a as nowOf,P as openIteration,T as plan,A as raiseBlocker,I as raisePending,M as remaining,m as requireCap,j as requireCapabilities,R as resourceCapsFor,g as rolesWith,k as separationLost,n as stageOf,S as toExNodes,V as validateAction}from'./chunk-COPYGMHE.mjs';export{a as WorkflowError,c as assertId,b as fail}from'./chunk-YS6CXERQ.mjs';var ae="1.3.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":"0uCAAO,IAAMA,EAAAA,CAAU","file":"index.mjs","sourcesContent":["export const VERSION = \"1.3.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 chunkUMG3WOD7_cjs=require('../chunk-UMG3WOD7.cjs');require('../chunk-KLOSFZFK.cjs'),require('../chunk-6PFJYRM7.cjs'),require('../chunk-BBI7AKJK.cjs'),require('../chunk-MU26QW32.cjs'),require('../chunk-OSHBJIYD.cjs');Object.defineProperty(exports,"investigation",{enumerable:true,get:function(){return chunkUMG3WOD7_cjs.b}});Object.defineProperty(exports,"validateInvestigationConfig",{enumerable:true,get:function(){return chunkUMG3WOD7_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-DLOtndDY.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-DLOtndDY.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-DLOtndDY.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-DLOtndDY.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-OEHVWRJG.mjs';import'../chunk-BD665RYK.mjs';import'../chunk-WU5JELOM.mjs';import'../chunk-TQR3VFZU.mjs';import'../chunk-COPYGMHE.mjs';import'../chunk-YS6CXERQ.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|