ex-workflow 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +6 -4
- package/dist/{chunk-PFHVB2WT.mjs → chunk-3QUIRAXO.mjs} +2 -2
- package/dist/{chunk-PFHVB2WT.mjs.map → chunk-3QUIRAXO.mjs.map} +1 -1
- package/dist/chunk-3RJ4RNPG.cjs +2 -0
- package/dist/chunk-3RJ4RNPG.cjs.map +1 -0
- package/dist/chunk-66BO7JFR.cjs +2 -0
- package/dist/chunk-66BO7JFR.cjs.map +1 -0
- package/dist/{chunk-UMG3WOD7.cjs → chunk-76ITDJDM.cjs} +2 -2
- package/dist/{chunk-UMG3WOD7.cjs.map → chunk-76ITDJDM.cjs.map} +1 -1
- package/dist/chunk-AWFR3Q4M.mjs +2 -0
- package/dist/{chunk-5ZGNEY2I.mjs.map → chunk-AWFR3Q4M.mjs.map} +1 -1
- package/dist/chunk-BGKXIRGS.mjs +2 -0
- package/dist/chunk-BGKXIRGS.mjs.map +1 -0
- package/dist/chunk-BNKKOAMP.mjs +2 -0
- package/dist/{chunk-ILDXZWEL.mjs.map → chunk-BNKKOAMP.mjs.map} +1 -1
- package/dist/{chunk-YGCNLXPJ.cjs → chunk-CPM2SPDX.cjs} +2 -2
- package/dist/{chunk-YGCNLXPJ.cjs.map → chunk-CPM2SPDX.cjs.map} +1 -1
- package/dist/{chunk-EQXYFHHD.cjs → chunk-G6QELJRL.cjs} +2 -2
- package/dist/{chunk-EQXYFHHD.cjs.map → chunk-G6QELJRL.cjs.map} +1 -1
- package/dist/{chunk-UT7QV6CE.mjs → chunk-HXEJP6KF.mjs} +2 -2
- package/dist/{chunk-UT7QV6CE.mjs.map → chunk-HXEJP6KF.mjs.map} +1 -1
- package/dist/chunk-ILNSTPPV.mjs +2 -0
- package/dist/chunk-ILNSTPPV.mjs.map +1 -0
- package/dist/chunk-LQJPLXFR.cjs +2 -0
- package/dist/{chunk-RGHM3JJM.cjs.map → chunk-LQJPLXFR.cjs.map} +1 -1
- package/dist/chunk-MUQ4FKVH.mjs +2 -0
- package/dist/chunk-MUQ4FKVH.mjs.map +1 -0
- package/dist/chunk-N2NANHRW.mjs +2 -0
- package/dist/{chunk-5DCOXGRW.mjs.map → chunk-N2NANHRW.mjs.map} +1 -1
- package/dist/chunk-NNQ3RHDP.mjs +2 -0
- package/dist/chunk-NNQ3RHDP.mjs.map +1 -0
- package/dist/chunk-OAJ4KV4F.mjs +2 -0
- package/dist/{chunk-3S7F5QXK.mjs.map → chunk-OAJ4KV4F.mjs.map} +1 -1
- package/dist/chunk-OFFQTZEY.cjs +2 -0
- package/dist/chunk-OFFQTZEY.cjs.map +1 -0
- package/dist/chunk-QKW26EV2.mjs +2 -0
- package/dist/chunk-QKW26EV2.mjs.map +1 -0
- package/dist/{chunk-BANKVCYY.cjs → chunk-RMXEQ5HN.cjs} +2 -2
- package/dist/{chunk-BANKVCYY.cjs.map → chunk-RMXEQ5HN.cjs.map} +1 -1
- package/dist/chunk-TBLIZIWH.cjs +2 -0
- package/dist/chunk-TBLIZIWH.cjs.map +1 -0
- package/dist/{chunk-4F5HZLKD.cjs → chunk-U23IRPFF.cjs} +2 -2
- package/dist/{chunk-4F5HZLKD.cjs.map → chunk-U23IRPFF.cjs.map} +1 -1
- package/dist/chunk-WM3JM3H7.mjs +2 -0
- package/dist/chunk-WM3JM3H7.mjs.map +1 -0
- package/dist/chunk-YNYIHJOC.mjs +2 -0
- package/dist/{chunk-5GXB6GMX.mjs.map → chunk-YNYIHJOC.mjs.map} +1 -1
- package/dist/chunk-YRXFEM3F.cjs +2 -0
- package/dist/chunk-YRXFEM3F.cjs.map +1 -0
- package/dist/{chunk-3ZUBCA7Q.cjs → chunk-ZDT2BZGU.cjs} +2 -2
- package/dist/{chunk-3ZUBCA7Q.cjs.map → chunk-ZDT2BZGU.cjs.map} +1 -1
- package/dist/{chunk-H26KXQ3I.cjs → chunk-ZK3V66NC.cjs} +2 -2
- package/dist/{chunk-H26KXQ3I.cjs.map → chunk-ZK3V66NC.cjs.map} +1 -1
- package/dist/cli/bin.cjs +1 -1
- package/dist/cli/bin.cjs.map +1 -1
- package/dist/cli/bin.mjs +1 -1
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/experimentation/index.cjs +1 -1
- package/dist/experimentation/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/investigation/index.cjs +1 -1
- package/dist/investigation/index.mjs +1 -1
- package/dist/kanban/index.cjs +1 -1
- package/dist/kanban/index.mjs +1 -1
- package/dist/policies/index.cjs +1 -1
- package/dist/policies/index.cjs.map +1 -1
- package/dist/policies/index.d.cts +4 -1
- package/dist/policies/index.d.ts +4 -1
- package/dist/policies/index.mjs +1 -1
- package/dist/policies/index.mjs.map +1 -1
- package/dist/registry/index.cjs +1 -1
- package/dist/registry/index.mjs +1 -1
- package/dist/scrum/index.cjs +1 -1
- package/dist/scrum/index.mjs +1 -1
- package/dist/waterfall/index.cjs +1 -1
- package/dist/waterfall/index.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-2FBA7RBS.cjs +0 -2
- package/dist/chunk-2FBA7RBS.cjs.map +0 -1
- package/dist/chunk-3S7F5QXK.mjs +0 -2
- package/dist/chunk-5DCOXGRW.mjs +0 -2
- package/dist/chunk-5GXB6GMX.mjs +0 -2
- package/dist/chunk-5ZGNEY2I.mjs +0 -2
- package/dist/chunk-COPYGMHE.mjs +0 -2
- package/dist/chunk-COPYGMHE.mjs.map +0 -1
- package/dist/chunk-CVGEIXW6.cjs +0 -2
- package/dist/chunk-CVGEIXW6.cjs.map +0 -1
- package/dist/chunk-CX2E7ZTQ.mjs +0 -2
- package/dist/chunk-CX2E7ZTQ.mjs.map +0 -1
- package/dist/chunk-ILDXZWEL.mjs +0 -2
- package/dist/chunk-LG23WXAP.mjs +0 -2
- package/dist/chunk-LG23WXAP.mjs.map +0 -1
- package/dist/chunk-MU26QW32.cjs +0 -2
- package/dist/chunk-MU26QW32.cjs.map +0 -1
- package/dist/chunk-OEHVWRJG.mjs +0 -2
- package/dist/chunk-OEHVWRJG.mjs.map +0 -1
- package/dist/chunk-RGHM3JJM.cjs +0 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkLQJPLXFR_cjs=require('./chunk-LQJPLXFR.cjs');require('./chunk-PNWRA4JU.cjs');var chunkYRXFEM3F_cjs=require('./chunk-YRXFEM3F.cjs'),chunkZK3V66NC_cjs=require('./chunk-ZK3V66NC.cjs'),chunkKLOSFZFK_cjs=require('./chunk-KLOSFZFK.cjs'),chunk6PFJYRM7_cjs=require('./chunk-6PFJYRM7.cjs'),chunkBBI7AKJK_cjs=require('./chunk-BBI7AKJK.cjs'),chunkTBLIZIWH_cjs=require('./chunk-TBLIZIWH.cjs'),chunkOSHBJIYD_cjs=require('./chunk-OSHBJIYD.cjs');var ae="1.4.0";Object.defineProperty(exports,"complete",{enumerable:true,get:function(){return chunkLQJPLXFR_cjs.f}});Object.defineProperty(exports,"correctAccounting",{enumerable:true,get:function(){return chunkLQJPLXFR_cjs.g}});Object.defineProperty(exports,"next",{enumerable:true,get:function(){return chunkLQJPLXFR_cjs.e}});Object.defineProperty(exports,"openQuestions",{enumerable:true,get:function(){return chunkLQJPLXFR_cjs.d}});Object.defineProperty(exports,"registerRole",{enumerable:true,get:function(){return chunkLQJPLXFR_cjs.a}});Object.defineProperty(exports,"retireRole",{enumerable:true,get:function(){return chunkLQJPLXFR_cjs.b}});Object.defineProperty(exports,"synthesizeBrief",{enumerable:true,get:function(){return chunkLQJPLXFR_cjs.c}});Object.defineProperty(exports,"checkGate",{enumerable:true,get:function(){return chunkYRXFEM3F_cjs.d}});Object.defineProperty(exports,"clearBlocker",{enumerable:true,get:function(){return chunkYRXFEM3F_cjs.b}});Object.defineProperty(exports,"decide",{enumerable:true,get:function(){return chunkYRXFEM3F_cjs.f}});Object.defineProperty(exports,"raiseBlocker",{enumerable:true,get:function(){return chunkYRXFEM3F_cjs.a}});Object.defineProperty(exports,"raisePending",{enumerable:true,get:function(){return chunkYRXFEM3F_cjs.e}});Object.defineProperty(exports,"applyAgreement",{enumerable:true,get:function(){return chunkZK3V66NC_cjs.a}});Object.defineProperty(exports,"retireAgreement",{enumerable:true,get:function(){return chunkZK3V66NC_cjs.b}});Object.defineProperty(exports,"frozenChanges",{enumerable:true,get:function(){return chunkKLOSFZFK_cjs.a}});Object.defineProperty(exports,"independenceConflicts",{enumerable:true,get:function(){return chunk6PFJYRM7_cjs.a}});Object.defineProperty(exports,"readExt",{enumerable:true,get:function(){return chunkBBI7AKJK_cjs.a}});Object.defineProperty(exports,"writeExt",{enumerable:true,get:function(){return chunkBBI7AKJK_cjs.b}});Object.defineProperty(exports,"ZERO_SPENT",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.J}});Object.defineProperty(exports,"addEvidence",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.A}});Object.defineProperty(exports,"addItem",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.t}});Object.defineProperty(exports,"addSpent",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.K}});Object.defineProperty(exports,"appendEvent",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.c}});Object.defineProperty(exports,"applyAction",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.V}});Object.defineProperty(exports,"approversFor",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.i}});Object.defineProperty(exports,"assertPolicies",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.C}});Object.defineProperty(exports,"assignRole",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.P}});Object.defineProperty(exports,"authorOf",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.H}});Object.defineProperty(exports,"canDo",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.l}});Object.defineProperty(exports,"changeConfig",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.X}});Object.defineProperty(exports,"coreRulesFor",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.T}});Object.defineProperty(exports,"createState",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.b}});Object.defineProperty(exports,"editItem",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.u}});Object.defineProperty(exports,"estimateTokens",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.N}});Object.defineProperty(exports,"evaluatePolicies",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.B}});Object.defineProperty(exports,"getItem",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.s}});Object.defineProperty(exports,"hasCapability",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.f}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.W}});Object.defineProperty(exports,"isExhausted",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.M}});Object.defineProperty(exports,"isTerminalStage",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.p}});Object.defineProperty(exports,"lastDispatchBefore",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.G}});Object.defineProperty(exports,"lastEvent",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.d}});Object.defineProperty(exports,"moveItem",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.v}});Object.defineProperty(exports,"nextStageOf",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.o}});Object.defineProperty(exports,"nowOf",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.a}});Object.defineProperty(exports,"openIteration",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.O}});Object.defineProperty(exports,"plan",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.S}});Object.defineProperty(exports,"remaining",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.L}});Object.defineProperty(exports,"requireCap",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.m}});Object.defineProperty(exports,"requireCapabilities",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.j}});Object.defineProperty(exports,"resourceCapsFor",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.Q}});Object.defineProperty(exports,"rolesWith",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.g}});Object.defineProperty(exports,"separationLost",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.k}});Object.defineProperty(exports,"stageOf",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.n}});Object.defineProperty(exports,"toExNodes",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.R}});Object.defineProperty(exports,"validateAction",{enumerable:true,get:function(){return chunkTBLIZIWH_cjs.U}});Object.defineProperty(exports,"WorkflowError",{enumerable:true,get:function(){return chunkOSHBJIYD_cjs.a}});Object.defineProperty(exports,"assertId",{enumerable:true,get:function(){return chunkOSHBJIYD_cjs.c}});Object.defineProperty(exports,"fail",{enumerable:true,get:function(){return chunkOSHBJIYD_cjs.b}});exports.VERSION=ae;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["VERSION"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["VERSION"],"mappings":"qcAAO,IAAMA,EAAAA,CAAU","file":"index.cjs","sourcesContent":["export const VERSION = \"1.4.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, raisePending, decide } from \"./core/gates.ts\";\nexport { authorOf, lastDispatchBefore } from \"./core/authors.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"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
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, v as PendingHuman, T as Transition, 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
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
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';
|
|
@@ -114,12 +114,6 @@ type GateResult = {
|
|
|
114
114
|
outcome: "fail";
|
|
115
115
|
violations: Violation[];
|
|
116
116
|
};
|
|
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;
|
|
119
|
-
declare function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined;
|
|
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;
|
|
122
|
-
declare function authorOf(state: WorkflowState, item: WorkItem): string | undefined;
|
|
123
117
|
declare function checkGate(state: WorkflowState<string>, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
124
118
|
declare function checkGate(state: WorkflowState, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
125
119
|
declare function raisePending<N extends string>(state: WorkflowState<N>, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState<N>;
|
|
@@ -127,6 +121,13 @@ declare function raisePending(state: WorkflowState, pending: Omit<PendingHuman,
|
|
|
127
121
|
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>;
|
|
128
122
|
declare function decide(state: WorkflowState, pendingId: string, decision: "approve" | "reject", by: string, note: string, now?: string, methodology?: Methodology): WorkflowState;
|
|
129
123
|
|
|
124
|
+
/** 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). */
|
|
125
|
+
declare function lastDispatchBefore(state: WorkflowState<string>, item: WorkItem): Transition | undefined;
|
|
126
|
+
declare function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined;
|
|
127
|
+
/** 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. */
|
|
128
|
+
declare function authorOf(state: WorkflowState<string>, item: WorkItem): string | undefined;
|
|
129
|
+
declare function authorOf(state: WorkflowState, item: WorkItem): string | undefined;
|
|
130
|
+
|
|
130
131
|
type NodeData = {
|
|
131
132
|
id: string;
|
|
132
133
|
};
|
|
@@ -282,6 +283,6 @@ declare function frozenChanges<K extends string>(frozen: {
|
|
|
282
283
|
readonly [P in K]?: unknown;
|
|
283
284
|
}, supplied: object | undefined, keys?: readonly K[]): K[];
|
|
284
285
|
|
|
285
|
-
declare const VERSION = "1.
|
|
286
|
+
declare const VERSION = "1.4.0";
|
|
286
287
|
|
|
287
288
|
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,4 +1,4 @@
|
|
|
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,
|
|
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, v as PendingHuman, T as Transition, 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
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
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';
|
|
@@ -114,12 +114,6 @@ type GateResult = {
|
|
|
114
114
|
outcome: "fail";
|
|
115
115
|
violations: Violation[];
|
|
116
116
|
};
|
|
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;
|
|
119
|
-
declare function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined;
|
|
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;
|
|
122
|
-
declare function authorOf(state: WorkflowState, item: WorkItem): string | undefined;
|
|
123
117
|
declare function checkGate(state: WorkflowState<string>, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
124
118
|
declare function checkGate(state: WorkflowState, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
125
119
|
declare function raisePending<N extends string>(state: WorkflowState<N>, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState<N>;
|
|
@@ -127,6 +121,13 @@ declare function raisePending(state: WorkflowState, pending: Omit<PendingHuman,
|
|
|
127
121
|
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>;
|
|
128
122
|
declare function decide(state: WorkflowState, pendingId: string, decision: "approve" | "reject", by: string, note: string, now?: string, methodology?: Methodology): WorkflowState;
|
|
129
123
|
|
|
124
|
+
/** 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). */
|
|
125
|
+
declare function lastDispatchBefore(state: WorkflowState<string>, item: WorkItem): Transition | undefined;
|
|
126
|
+
declare function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined;
|
|
127
|
+
/** 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. */
|
|
128
|
+
declare function authorOf(state: WorkflowState<string>, item: WorkItem): string | undefined;
|
|
129
|
+
declare function authorOf(state: WorkflowState, item: WorkItem): string | undefined;
|
|
130
|
+
|
|
130
131
|
type NodeData = {
|
|
131
132
|
id: string;
|
|
132
133
|
};
|
|
@@ -282,6 +283,6 @@ declare function frozenChanges<K extends string>(frozen: {
|
|
|
282
283
|
readonly [P in K]?: unknown;
|
|
283
284
|
}, supplied: object | undefined, keys?: readonly K[]): K[];
|
|
284
285
|
|
|
285
|
-
declare const VERSION = "1.
|
|
286
|
+
declare const VERSION = "1.4.0";
|
|
286
287
|
|
|
287
288
|
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{f as complete,g as correctAccounting,e as next,d as openQuestions,a as registerRole,b as retireRole,c as synthesizeBrief}from'./chunk-
|
|
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-YNYIHJOC.mjs';import'./chunk-IDZ435YZ.mjs';export{d as checkGate,b as clearBlocker,f as decide,a as raiseBlocker,e as raisePending}from'./chunk-MUQ4FKVH.mjs';export{a as applyAgreement,b as retireAgreement}from'./chunk-3QUIRAXO.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{J as ZERO_SPENT,A as addEvidence,t as addItem,K as addSpent,c as appendEvent,V as applyAction,i as approversFor,C as assertPolicies,P as assignRole,H as authorOf,l as canDo,X as changeConfig,T as coreRulesFor,b as createState,u as editItem,N as estimateTokens,B as evaluatePolicies,s as getItem,f as hasCapability,W as init,M as isExhausted,p as isTerminalStage,G as lastDispatchBefore,d as lastEvent,v as moveItem,o as nextStageOf,a as nowOf,O as openIteration,S as plan,L as remaining,m as requireCap,j as requireCapabilities,Q as resourceCapsFor,g as rolesWith,k as separationLost,n as stageOf,R as toExNodes,U as validateAction}from'./chunk-NNQ3RHDP.mjs';export{a as WorkflowError,c as assertId,b as fail}from'./chunk-YS6CXERQ.mjs';var ae="1.4.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":"4wCAAO,IAAMA,EAAAA,CAAU","file":"index.mjs","sourcesContent":["export const VERSION = \"1.4.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, raisePending, decide } from \"./core/gates.ts\";\nexport { authorOf, lastDispatchBefore } from \"./core/authors.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 chunk76ITDJDM_cjs=require('../chunk-76ITDJDM.cjs');require('../chunk-KLOSFZFK.cjs'),require('../chunk-6PFJYRM7.cjs'),require('../chunk-BBI7AKJK.cjs'),require('../chunk-TBLIZIWH.cjs'),require('../chunk-OSHBJIYD.cjs');Object.defineProperty(exports,"investigation",{enumerable:true,get:function(){return chunk76ITDJDM_cjs.b}});Object.defineProperty(exports,"validateInvestigationConfig",{enumerable:true,get:function(){return chunk76ITDJDM_cjs.a}});//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{b as investigation,a as validateInvestigationConfig}from'../chunk-
|
|
1
|
+
export{b as investigation,a as validateInvestigationConfig}from'../chunk-ILNSTPPV.mjs';import'../chunk-BD665RYK.mjs';import'../chunk-WU5JELOM.mjs';import'../chunk-TQR3VFZU.mjs';import'../chunk-NNQ3RHDP.mjs';import'../chunk-YS6CXERQ.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/kanban/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkCPM2SPDX_cjs=require('../chunk-CPM2SPDX.cjs');require('../chunk-GKN5M4B7.cjs'),require('../chunk-RMXEQ5HN.cjs'),require('../chunk-ZK3V66NC.cjs'),require('../chunk-TBLIZIWH.cjs'),require('../chunk-OSHBJIYD.cjs');Object.defineProperty(exports,"ACTIVE",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.a}});Object.defineProperty(exports,"CADENCE_EVENT",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.s}});Object.defineProperty(exports,"CLASSES",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.k}});Object.defineProperty(exports,"DAY_MS",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.l}});Object.defineProperty(exports,"DEFAULT_COLUMNS",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.n}});Object.defineProperty(exports,"KANBAN_CADENCES",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.j}});Object.defineProperty(exports,"KANBAN_VOCABULARY",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.F}});Object.defineProperty(exports,"OPEN",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.b}});Object.defineProperty(exports,"activeExpedites",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.h}});Object.defineProperty(exports,"addedAt",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.p}});Object.defineProperty(exports,"board",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.r}});Object.defineProperty(exports,"byClassThenAge",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.H}});Object.defineProperty(exports,"cadencesDue",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.t}});Object.defineProperty(exports,"cardAge",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.q}});Object.defineProperty(exports,"columnIndex",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.f}});Object.defineProperty(exports,"columnStays",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.w}});Object.defineProperty(exports,"commitmentColumn",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.d}});Object.defineProperty(exports,"configOf",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.m}});Object.defineProperty(exports,"deliveryColumn",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.e}});Object.defineProperty(exports,"enteredStageAt",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.i}});Object.defineProperty(exports,"kanban",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.I}});Object.defineProperty(exports,"kanbanCeremonies",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.B}});Object.defineProperty(exports,"kanbanMetrics",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.x}});Object.defineProperty(exports,"kanbanRoles",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.C}});Object.defineProperty(exports,"kanbanRules",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.D}});Object.defineProperty(exports,"kanbanStages",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.E}});Object.defineProperty(exports,"onBoard",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.g}});Object.defineProperty(exports,"opsReport",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.y}});Object.defineProperty(exports,"optionsColumn",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.c}});Object.defineProperty(exports,"percentile",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.v}});Object.defineProperty(exports,"priorityByClass",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.G}});Object.defineProperty(exports,"replay",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.u}});Object.defineProperty(exports,"riskReport",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.z}});Object.defineProperty(exports,"validateKanbanConfig",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.o}});Object.defineProperty(exports,"wantItems",{enumerable:true,get:function(){return chunkCPM2SPDX_cjs.A}});//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/kanban/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as ACTIVE,s as CADENCE_EVENT,k as CLASSES,l as DAY_MS,n as DEFAULT_COLUMNS,j as KANBAN_CADENCES,F as KANBAN_VOCABULARY,b as OPEN,h as activeExpedites,p as addedAt,r as board,H as byClassThenAge,t as cadencesDue,q as cardAge,f as columnIndex,w as columnStays,d as commitmentColumn,m as configOf,e as deliveryColumn,i as enteredStageAt,I as kanban,B as kanbanCeremonies,x as kanbanMetrics,C as kanbanRoles,D as kanbanRules,E as kanbanStages,g as onBoard,y as opsReport,c as optionsColumn,v as percentile,G as priorityByClass,u as replay,z as riskReport,o as validateKanbanConfig,A as wantItems}from'../chunk-
|
|
1
|
+
export{a as ACTIVE,s as CADENCE_EVENT,k as CLASSES,l as DAY_MS,n as DEFAULT_COLUMNS,j as KANBAN_CADENCES,F as KANBAN_VOCABULARY,b as OPEN,h as activeExpedites,p as addedAt,r as board,H as byClassThenAge,t as cadencesDue,q as cardAge,f as columnIndex,w as columnStays,d as commitmentColumn,m as configOf,e as deliveryColumn,i as enteredStageAt,I as kanban,B as kanbanCeremonies,x as kanbanMetrics,C as kanbanRoles,D as kanbanRules,E as kanbanStages,g as onBoard,y as opsReport,c as optionsColumn,v as percentile,G as priorityByClass,u as replay,z as riskReport,o as validateKanbanConfig,A as wantItems}from'../chunk-OAJ4KV4F.mjs';import'../chunk-C4ISBUZR.mjs';import'../chunk-N2NANHRW.mjs';import'../chunk-3QUIRAXO.mjs';import'../chunk-NNQ3RHDP.mjs';import'../chunk-YS6CXERQ.mjs';//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/policies/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkGKN5M4B7_cjs=require('../chunk-GKN5M4B7.cjs'),chunk6PFJYRM7_cjs=require('../chunk-6PFJYRM7.cjs'),chunkMU26QW32_cjs=require('../chunk-MU26QW32.cjs'),chunkOSHBJIYD_cjs=require('../chunk-OSHBJIYD.cjs');var ke=new WeakMap;function X(e,n,t){let s=e.get(n);s?s.push(t):e.set(n,[t]);}function je(e){let n={evidence:new Map,transitions:new Map,rework:new Map,changed:new Map};for(let t=0;t<e.length;t++){let s=e[t],r=s.payload;if(s.type==="item.evidence")X(n.evidence,r?.id,t);else if(s.type==="item.transition"||r?.transition)X(n.transitions,r?.id,t);else if(s.type==="item.rework")n.rework.set(r?.id,t);else if(s.type==="repo.changed"&&Array.isArray(r?.paths)){let i=r.paths;for(let a=0;a<i.length;a++)typeof i[a]=="string"&&X(n.changed,i[a],[t,a]);}}return n}function _(e){let n=e.events,t=n.length,s=ke.get(n);if(s&&s.n===t&&s.last===n[t-1])return s.index;let r=je(n);return ke.set(n,{n:t,last:n[t-1],index:r}),r}function Z(e,n,t){let s=0,r=e.length;for(;s<r;){let i=s+r>>1;t(e[i])>n?r=i:s=i+1;}return s}function F(e,n,t){let s=e.rework.get(n);if(s===void 0)return;let r=t??[];return r.length-Z(r,s,i=>i)}function T(e,n){let t=_(e),s=t.transitions.get(n.id)??[],r=n.transitions,i=F(t,n.id,s),a=i===void 0||s.length!==r.length?r:r.slice(r.length-i),u=new Set;for(let o of a)o.to.status==="in_progress"&&u.add(o.by);for(let o of [n.role,chunkMU26QW32_cjs.G(e,n)])o!==void 0&&u.add(o);return [...u]}var j=chunkGKN5M4B7_cjs.a(["low","medium","high","critical"]),J=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),P=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0,be=new WeakSet;function U(e,n){if(typeof e=="object"&&e!==null&&be.has(e))return e;let t=(l,m)=>chunkOSHBJIYD_cjs.b("invalid-input",`${n} options: ${l}`,m),s=(l,m,f)=>{for(let g of Object.keys(l))m.includes(g)||t(`unknown key "${g}" in ${f}`,`use only: ${m.join(", ")}`);},r=(l,m)=>{if(l==="human")return l;let f=J(l)?P(l,"capability"):void 0;return (typeof f!="string"||f.trim()===""||Object.keys(l).length!==1)&&t(`${m} must be "human" or { capability: <name> }`,'e.g. ["human"] or [{ "capability": "review" }]'),{capability:f}};J(e)||t("must be an object",'pass { "gates": ["code-review"] }');let i=e;s(i,["gates","table"],"options");let a=P(i,"gates");Array.isArray(a)||t("gates must be an array of gate ids",'e.g. "gates": ["code-review"]');let u=a.map(l=>(chunkOSHBJIYD_cjs.c(l,"risk gate id"),l)),o=P(i,"table"),d;if(o!==void 0){J(o)||t("table must be an object keyed by risk level",`levels: ${j.join(", ")}`);let l=o;s(l,j,"table"),d={};let m=[];for(let f of j){let g=P(l,f);J(g)||t(`table is missing level "${f}"`,`give every level a row, e.g. "${f}": { "requires": [] }`);let h=g;s(h,["requires","evidence"],`table.${f}`);let I=P(h,"requires");Array.isArray(I)||t(`table.${f}.requires must be an array`,'e.g. "requires": ["human"]');let p=P(h,"evidence");p!==void 0&&(!Array.isArray(p)||!p.every(b=>typeof b=="string"&&b.trim()!==""))&&t(`table.${f}.evidence must be an array of evidence kinds`,'e.g. "evidence": ["sbom"]');let y=I.map((b,w)=>r(b,`table.${f}.requires[${w}]`)),R=p===void 0?void 0:[...p],M=[...y.map(b=>JSON.stringify(b)),...(R??[]).map(b=>`evidence ${JSON.stringify(b)}`)],O=m.filter(b=>!M.includes(b));O.length&&t(`table.${f} must include everything the level below it adds (missing ${O.join(", ")})`,"a stricter level only adds: copy the lower level's requires and evidence into it"),m=M,d[f]={requires:y,...R===void 0?{}:{evidence:R}};}}let c=chunkGKN5M4B7_cjs.a(d?{gates:u,table:d}:{gates:u});return be.add(c),c}var we=chunkGKN5M4B7_cjs.a({low:{requires:[]},medium:{requires:[]},high:{requires:["human"]},critical:{requires:["human"]}}),Ie=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Ce(e){return Ie(e)&&j.includes(e.level)&&Array.isArray(e.factors)&&e.factors.every(n=>typeof n=="string")&&(e.subject===void 0||typeof e.subject=="string")}function Q(e,n,t,s=T(e,n)){return chunkMU26QW32_cjs.l(e,t,"verify")?chunk6PFJYRM7_cjs.a(t,s).length?"not-independent":void 0:"invalid"}function ee(e,n,t,s){let r=U(s,"riskEscalation");if(!r.gates.includes(t.id))return;let i,a="missing",u,o;for(let l of chunkMU26QW32_cjs.y(e,n)){if(l.kind!=="risk-assessment")continue;let m=Ce(l.data)?Q(e,n,l.by,o??=T(e,n)):"invalid";if(m){i||(a=m,u=l);continue}let f=l.data.level;(!i||j.indexOf(f)>=j.indexOf(i))&&(i=f,a="assessed",u=l);}let d=i??"critical",c=(r.table??we)[d];return {requires:c.requires.map(l=>l==="human"?l:{capability:l.capability}),evidence:[...c.evidence??[]],reason:{level:d,why:a,assessment:u?.ref??null,by:u?.by??null}}}var ne=["item","level","factors","ref","subject","by","now"],S=(e,n)=>chunkOSHBJIYD_cjs.b("invalid-input",`risk assessment: ${e}`,n);function Me(e,n,t){(typeof t!="object"||t===null||Array.isArray(t))&&S("input must be an object",`pass { ${ne.join(", ")} }`);for(let f of Object.keys(t))ne.includes(f)||S(`unknown key "${f}"`,`use only: ${ne.join(", ")}`);let{item:s,level:r,factors:i,ref:a,subject:u,by:o,now:d}=t;typeof s!="string"&&S("item must be an item id",'e.g. "item": "CART-12"');let c=chunkMU26QW32_cjs.r(e,s);j.includes(r)||S(`unknown level ${JSON.stringify(r)}`,`use one of: ${j.join(", ")}`),(!Array.isArray(i)||!i.every(f=>typeof f=="string"))&&S("factors must be an array of strings",'e.g. "factors": ["ci-cd", "secrets"]'),(typeof a!="string"||a.trim()==="")&&S("ref must be a non-empty string",'name the assessment artifact, e.g. "risk/CART-12.md"'),u!==void 0&&typeof u!="string"&&S("subject must be a string","pass the assessed SHA or ref, or omit it"),d!==void 0&&typeof d!="string"&&S("now must be an ISO timestamp string","omit now to use the clock"),(typeof o!="string"||o==="")&&S("by must name the assessor",'e.g. "by": "human"');let l=Q(e,c,o);l==="invalid"&&S(`"${o}" may not assess risk (needs capability "verify")`,`assess as human or one of: ${chunkMU26QW32_cjs.g(e,"verify").map(f=>f.id).join(", ")||"(no role has verify; register one)"}`),l&&S(`"${o}" did the work on "${s}" and may not assess its risk`,"assess as human or an independent role with capability verify");let m={level:r,factors:[...i]};return u!==void 0&&(m.subject=u),chunkMU26QW32_cjs.W(e,n,{type:"risk.assess",by:o,payload:{item:s,ref:a,...m}},f=>chunkMU26QW32_cjs.z(f,s,{kind:"risk-assessment",ref:a,by:o,data:m},d))}var z=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),V=e=>typeof e=="string"&&e.trim()!=="",B=(e,n)=>Object.keys(e).find(t=>!n.includes(t));function Ee(e){return e<32||e>=127&&e<=159||e===1564||e===8206||e===8207||e>=8234&&e<=8238||e>=8294&&e<=8297}function se(e){let n=typeof e!="string"?"not a string":e.length>4096?"longer than 4096 characters":[...e].some(s=>Ee(s.codePointAt(0)))?"has a control or bidirectional formatting character":e!==e.trim()?"has leading or trailing whitespace":e!==e.normalize("NFC")?"is not Unicode NFC":e.includes("\\")||/^[A-Za-z]:/.test(e)||!e.split("/").every(s=>s!==""&&s!=="."&&s!=="..")?"is not relative with / separators and no empty, . or .. segment":void 0;return n?`${JSON.stringify(typeof e=="string"&&e.length>80?`${e.slice(0,80)}\u2026`:e)} is not a repository-relative POSIX path (${n})`:void 0}function ve(e){if(!z(e))return "data must be an object";let n=B(e,["revision","assumptions"]);if(n)return `unknown key "${n}"`;if(!V(e.revision))return "revision must be a non-empty string";let t=e.assumptions;if(!Array.isArray(t))return "assumptions must be an array";for(let[s,r]of t.entries()){let i=`assumptions[${s}]`;if(!z(r))return `${i} must be an object`;let a=B(r,["claim","required","source"]);if(a)return `unknown key "${a}" in ${i}`;if(!V(r.claim))return `${i}.claim must be a non-empty string`;if(r.required!==void 0&&typeof r.required!="boolean")return `${i}.required must be a boolean`;let u=r.source;if(u===void 0)continue;if(!z(u))return `${i}.source must be an object`;let o=B(u,["path","lines","hash"]);if(o)return `unknown key "${o}" in ${i}.source`;let d=se(u.path);if(d)return `${i}.source.path ${d}`;if(!V(u.hash))return `${i}.source.hash must be a non-empty string`;let c=u.lines;if(c!==void 0&&!(Array.isArray(c)&&c.length===2&&Number.isInteger(c[0])&&Number.isInteger(c[1])&&1<=c[0]&&c[0]<=c[1]))return `${i}.source.lines must be two integers [from, to] with 1 <= from <= to`}}function xe(e,n,t){return typeof n!="string"||n!=="human"&&!Object.hasOwn(e.roles,n)?`${JSON.stringify(n)} is neither human nor a registered role`:t.includes(n)?`"${n}" worked on the item`:void 0}var $e=e=>e.assumptions.some(n=>n.source),Ne=({source:e,...n})=>e?{...n,source:{...e,...e.lines?{lines:[...e.lines]}:{}}}:n;function E(e,n){let t=_(e),s=t.evidence.get(n.id)??[],r=n.evidence,i=F(t,n.id,s),a=i===void 0?r.length:Math.min(i,r.length),u;for(let o=r.length-1;o>=r.length-a;o--){let d=r[o];if(d.kind!=="context-snapshot"||ve(d.data)!==void 0)continue;let c=d.data;if(!$e(c)||xe(e,d.by,u??=T(e,n)))continue;let l=s[o+s.length-r.length]??-1,m=[];for(let f of new Set(c.assumptions.map(g=>g.source?.path))){let g=f===void 0?void 0:t.changed.get(f),h=g?Z(g,l,I=>I[0]):0;g&&h<g.length&&m.push([g[h][0],g[h][1],f]);}return m.sort((f,g)=>f[0]-g[0]||f[1]-g[1]),{revision:c.revision,assumptions:c.assumptions.map(Ne),snapshot:d.ref,by:d.by,stale:m.map(f=>f[2]),unverified:c.assumptions.filter(f=>!f.source).map(f=>f.claim)}}}var te=["item","revision","assumptions","ref","by","now"],C=(e,n)=>chunkOSHBJIYD_cjs.b("invalid-input",`context snapshot: ${e}`,n);function Ge(e,n,t){z(t)||C("input must be an object",`pass { ${te.join(", ")} }`);let s=B(t,te);s&&C(`unknown key "${s}"`,`use only: ${te.join(", ")}`);let{item:r,revision:i,assumptions:a,ref:u,by:o,now:d}=t;typeof r!="string"&&C("item must be an item id",'e.g. "item": "CART-12"');let c=chunkMU26QW32_cjs.r(e,r),l={revision:i,assumptions:a},m=ve(l);m&&C(m,'e.g. { "revision": "4f2c1e0", "assumptions": [{ "claim": "totals are cents", "source": { "path": "src/cart.ts", "hash": "\u2026" } }] }'),V(u)||C("ref must be a non-empty string",'name the snapshot artifact, e.g. "ctx/CART-12.json"'),V(o)||C("by must name who recorded it",'e.g. "by": "scout"');let f=xe(e,o,T(e,c));f&&C(`${f} and may not record its context`,"record as human or a registered role that did not work on the item"),$e(l)||C("a snapshot needs at least one assumption with a source (nothing was verified)",'cite what was checked, e.g. "source": { "path": "src/cart.ts", "hash": "\u2026" }'),d!==void 0&&typeof d!="string"&&C("now must be an ISO timestamp string","omit now to use the clock");let g=JSON.parse(JSON.stringify(l));return chunkMU26QW32_cjs.W(e,n,{type:"context.snapshot",by:o,payload:{item:r,ref:u,...g}},h=>chunkMU26QW32_cjs.z(h,r,{kind:"context-snapshot",ref:u,by:o,data:g},d))}var We="policy:custom:context-grounded",oe="record a fresh one with recordContextSnapshot";function re(e,n){let t=[],s=(o,d)=>t.push({rule:We,severity:"error",item:n.id,message:o,fix:d}),r=E(e,n);if(!r)return s(`item "${n.id}" has no qualifying context snapshot (none since its last rework is valid, cites a source and was recorded by human or a registered role that did not work on it)`,`have an independent role or a human verify the context and ${oe}`),t;let i=`context snapshot "${r.snapshot}" of "${n.id}"`;r.stale.length&&s(`${i} is stale: ${r.stale.join(", ")} changed since`,`re-verify the claims and ${oe}`);let u=r.assumptions.filter(o=>o.required).filter(o=>!o.source).map(o=>o.claim);return u.length&&s(`${i} has unverified required assumption(s): ${u.join(" | ")}`,`cite a source { path, hash } for each and ${oe}`),t}var qe=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function Te(e,n){let t=U(n,"withRiskGate"),s=e.escalateGate;return {...e,escalateGate(r,i,a){let u=ee(r,i,a,t),o=s?.call(e,r,i,a);return !o||!u?o??u:{requires:[...o.requires,...u.requires],evidence:[...o.evidence,...u.evidence],reason:{...o.reason,...u.reason}}}}}var ie="context-grounded",Pe={kind:"custom",id:ie,description:"grounded in a fresh, verified context snapshot"},ae=(e,n)=>chunkOSHBJIYD_cjs.b("invalid-input",`withContextGrounding options: ${e}`,n);function Re(e,n){let t=e[n];return t===void 0&&n==="exit"?[]:(Array.isArray(t)||ae(`${n} must be an array of stage ids`,`e.g. "${n}": ["dev"]`),t.map(s=>(chunkOSHBJIYD_cjs.c(s,`context-grounded ${n} stage id`),s)))}function Le(e,n){qe(n)||ae("must be an object",'pass { "entry": ["dev"] }');let t=n;for(let o of Object.keys(t))o!=="entry"&&o!=="exit"&&ae(`unknown key "${o}"`,"use only: entry, exit");let s=Re(t,"entry"),r=Re(t,"exit"),{customPolicy:i,briefContext:a}=e,u=(o,d)=>d&&!o.some(c=>c.kind==="custom"&&c.id===ie)?[...o,Pe]:o;return {...e,defaultStages(o){let d=e.defaultStages(o);for(let c of [...s,...r])d.some(l=>l.id===c)||chunkOSHBJIYD_cjs.b("invalid-input",`withContextGrounding: unknown stage "${c}"`,`stages: ${d.map(l=>l.id).join(", ")}`);return d.map(c=>({...c,entryPolicy:u(c.entryPolicy,s.includes(c.id)),exitPolicy:u(c.exitPolicy,r.includes(c.id))}))},customPolicy(o,d,c){return c.id===ie?re(o,d):i?.call(e,o,d,c)},briefContext(o,d){return E(o,d)??a?.call(e,o,d)}}}var ce=["revision","paths","by","now"],Ve=["in_progress","review","awaiting_human"],N=(e,n)=>chunkOSHBJIYD_cjs.b("invalid-input",`repo change: ${e}`,n);function De(e,n,t){(typeof t!="object"||t===null||Array.isArray(t))&&N("input must be an object",`pass { ${ce.join(", ")} }`);for(let c of Object.keys(t))ce.includes(c)||N(`unknown key "${c}"`,`use only: ${ce.join(", ")}`);let{revision:s,paths:r,by:i,now:a}=t;(typeof s!="string"||s.trim()==="")&&N("revision must be a non-empty string",'e.g. "revision": "4f2c1e0"'),(!Array.isArray(r)||r.length===0)&&N("paths must be a non-empty array of paths",'e.g. "paths": ["src/cart.ts"]'),r.forEach((c,l)=>{let m=se(c);m&&N(`paths[${l}] ${m}`,'send paths as `git diff --name-only -z` lists them (NUL-separated, unquoted; or with `-c core.quotePath=false`), e.g. "src/cart.ts"');}),(typeof i!="string"||i==="")&&N("by must name the reporter",'e.g. "by": "ci"'),a!==void 0&&typeof a!="string"&&N("now must be an ISO timestamp string","omit now to use the clock");let u=[...new Set(r)],o=chunkMU26QW32_cjs.W(e,n,{type:"repo.change",by:i,payload:{revision:s,paths:u}},c=>chunkMU26QW32_cjs.c(c,"repo.changed",i,{revision:s,paths:u},chunkMU26QW32_cjs.a(a))),d=[];for(let c of Object.values(o.state.items)){if(!Ve.includes(c.status))continue;let l=E(e,c);if(!l)continue;let m=new Set(l.assumptions.map(h=>h.source?.path)),f=new Set(l.stale),g=u.filter(h=>m.has(h)&&!f.has(h));g.length&&d.push({rule:"context-stale",severity:"warning",item:c.id,message:`context snapshot "${l.snapshot}" of "${c.id}" is stale: ${g.join(", ")} changed at ${s}`,fix:`re-verify and record a fresh snapshot of "${c.id}" with recordContextSnapshot`});}return {state:o.state,warnings:[...o.warnings,...d]}}var Ae=["baseline","mustPass","passTolerance","costTolerance"],Ke=["tokens","durationMs","turns","humanInterventions","reworks","escalations","itemsDone"],k=(e,n)=>chunkOSHBJIYD_cjs.b("invalid-input",`compareRuns: ${e}`,n),$=e=>typeof e=="string"?JSON.stringify(e):typeof e=="object"&&e!==null?Array.isArray(e)?"an array":"an object":typeof e=="function"||typeof e=="symbol"?typeof e:String(e),G=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),x=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0,fe=(e,n)=>Number.isFinite(e)?e:k(`${n} is not finite (${e})`,"pass the host's measured usage figures"),Y=(e,n)=>(typeof e!="string"&&k(`${n} is ${$(e)}, not an id`,'pass a string id such as "V0"'),chunkOSHBJIYD_cjs.c(e,n),e),Se=(e,n)=>e===void 0?0:((typeof e!="number"||!Number.isFinite(e)||e<0||e>1)&&k(`${n} is ${$(e)}, not a fraction in [0, 1]`,`pass e.g. "${n}": 0.05`),e);function _e(e,n){if(!G(e))return k(`${n}.state is ${$(e)}, not a workflow state`,"pass the finished state.json");let[t,s,r]=["events","accounting","items"].map(a=>x(e,a));if(!Array.isArray(t)||!Array.isArray(s))return k(`${n}.state has no events and accounting arrays`,"pass a WorkflowState as loaded by loadState");if(!G(r))return k(`${n}.state.items is ${$(r)}, not an object`,"pass a WorkflowState as loaded by loadState");let i={tokens:0,durationMs:0,turns:s.length,humanInterventions:0,reworks:0,escalations:0,itemsDone:0};s.forEach((a,u)=>{if(!G(a))return k(`${n}.state.accounting[${u}] is ${$(a)}`,"pass accounting lines as recorded by complete");for(let o of ["tokensIn","tokensOut","durationMs"]){let d=x(a,o);(typeof d!="number"||!Number.isFinite(d)||d<0)&&k(`${n}.state.accounting[${u}].${o} is ${$(d)}, not a finite non-negative number`,"pass the host's measured usage figures");}i.tokens+=a.tokensIn+a.tokensOut,i.durationMs+=a.durationMs;}),fe(i.tokens,`${n}.state token total`),fe(i.durationMs,`${n}.state duration total`),t.forEach((a,u)=>{if(!G(a)||typeof x(a,"type")!="string")return k(`${n}.state.events[${u}] is ${$(a)}, not an event`,"pass events as recorded by the engine");let o=a.type;o==="pending.raised"||o==="blocker.cleared"?i.humanInterventions++:o==="item.rework"?i.reworks++:o==="item.escalated"&&i.escalations++;});for(let a of Object.values(r))G(a)&&x(a,"status")==="done"&&i.itemsDone++;return i}var Oe=e=>e.sort((n,t)=>n-t).reduce((n,t)=>n+t,0)/e.length,ue=(e,n)=>e<n?-1:e>n?1:0;function Fe(e,n){if(Array.isArray(e)||k(`runs is ${$(e)}, not an array`,"pass an array of { variant, scenario, state, passed }"),e.length===0&&k("no runs to compare","pass at least the baseline's finished runs"),!G(n))return k(`options is ${$(n)}, not an object`,'pass { baseline: "V0" }');for(let p of Object.keys(n))Ae.includes(p)||k(`unknown option "${p}"`,`use only: ${Ae.join(", ")}`);let t=n,s=Y(x(t,"baseline"),"baseline"),r=x(t,"mustPass");r!==void 0&&!Array.isArray(r)&&k(`mustPass is ${$(r)}, not an array`,'pass e.g. "mustPass": ["s1"]');let i=[...new Set((r??[]).map(p=>Y(p,"mustPass scenario")))],a=Se(x(t,"passTolerance"),"passTolerance"),u=Se(x(t,"costTolerance"),"costTolerance"),o=new Map,d=new Set;e.forEach((p,y)=>{let R=`runs[${y}]`;if(!G(p))return k(`${R} is ${$(p)}, not a run record`,"pass { variant, scenario, state, passed }");let M=Y(x(p,"variant"),`${R}.variant`),O=Y(x(p,"scenario"),`${R}.scenario`),b=x(p,"passed");typeof b!="boolean"&&k(`${R}.passed is ${$(b)}, not a boolean`,"pass the scorer's verdict as true or false");let w=_e(x(p,"state"),R),A=o.get(M);A||o.set(M,A={metrics:[],passed:0,ran:new Map,failed:new Set}),A.metrics.push(w);let H=A.ran.get(O)??[0,0];A.ran.set(O,H),H[1]++,d.add(O),b?(A.passed++,H[0]++):A.failed.add(O);});let c=o.get(s);c||k(`baseline "${s}" has no run`,"name a variant that appears in runs");for(let p of i)d.has(p)||k(`mustPass scenario "${p}" has no run`,"name a scenario that appears in runs");let l=[...new Set([...c.ran.keys(),...i])].sort(ue),m=[...o].map(([p,y])=>{let R=y.metrics.length,M={};for(let w of Ke)M[w]=fe(Oe(y.metrics.map(A=>A[w])),`variant ${p} mean ${w}`);let O=i.filter(w=>y.failed.has(w)).sort(ue),b=l.filter(w=>!y.ran.has(w));return {variant:p,runs:R,passed:y.passed,passRate:Oe([...y.ran.values()].map(([w,A])=>w/A)),mean:M,regressions:O,missing:b,eligible:O.length===0&&b.length===0}});m.sort((p,y)=>Number(y.eligible)-Number(p.eligible)||y.passRate-p.passRate||p.mean.tokens-y.mean.tokens||p.mean.durationMs-y.mean.durationMs||p.mean.humanInterventions-y.mean.humanInterventions||ue(p.variant,y.variant));let f=m.find(p=>p.variant===s),g=m.find(p=>p.variant!==s&&p.eligible&&p.passRate>=f.passRate-a&&(p.passRate>f.passRate+a||p.mean.tokens<f.mean.tokens*(1-u)));if(g)return {baseline:s,variants:m,winner:g.variant,reason:`${g.variant} beats baseline ${s}: pass rate ${g.passRate} vs ${f.passRate}, mean tokens ${g.mean.tokens} vs ${f.mean.tokens}`};let h=m.filter(p=>p.variant!==s),I;if(h.length===0)I=`no variant to compare with baseline ${s}`;else if(h.some(p=>p.eligible))I=`within noise: no eligible variant beats baseline ${s} beyond the tolerances`;else {let p=h.map(y=>`${y.variant} (${(y.regressions.length?y.regressions:y.missing).join(", ")})`).join("; ");I=`${h.some(y=>y.regressions.length)?"must-pass regression":"no eligible variant, missing runs"}: ${p}`;}return {baseline:s,variants:m,winner:null,reason:I}}exports.DEFAULT_RISK_TABLE=we;exports.compareRuns=Fe;exports.contextGroundedViolations=re;exports.contextOf=E;exports.recordContextSnapshot=Ge;exports.recordRepoChange=De;exports.recordRiskAssessment=Me;exports.riskEscalation=ee;exports.withContextGrounding=Le;exports.withRiskGate=Te;//# sourceMappingURL=index.cjs.map
|
|
1
|
+
'use strict';var chunk66BO7JFR_cjs=require('../chunk-66BO7JFR.cjs');require('../chunk-GKN5M4B7.cjs'),require('../chunk-6PFJYRM7.cjs');var chunkTBLIZIWH_cjs=require('../chunk-TBLIZIWH.cjs'),chunkOSHBJIYD_cjs=require('../chunk-OSHBJIYD.cjs');var L=["item","level","factors","ref","subject","by","now"],w=(s,e)=>chunkOSHBJIYD_cjs.b("invalid-input",`risk assessment: ${s}`,e);function os(s,e,a){(typeof a!="object"||a===null||Array.isArray(a))&&w("input must be an object",`pass { ${L.join(", ")} }`);for(let f of Object.keys(a))L.includes(f)||w(`unknown key "${f}"`,`use only: ${L.join(", ")}`);let{item:o,level:m,factors:i,ref:t,subject:l,by:r,now:d}=a;typeof o!="string"&&w("item must be an item id",'e.g. "item": "CART-12"');let p=chunkTBLIZIWH_cjs.s(s,o);chunk66BO7JFR_cjs.a.includes(m)||w(`unknown level ${JSON.stringify(m)}`,`use one of: ${chunk66BO7JFR_cjs.a.join(", ")}`),(!Array.isArray(i)||!i.every(f=>typeof f=="string"))&&w("factors must be an array of strings",'e.g. "factors": ["ci-cd", "secrets"]'),(typeof t!="string"||t.trim()==="")&&w("ref must be a non-empty string",'name the assessment artifact, e.g. "risk/CART-12.md"'),l!==void 0&&typeof l!="string"&&w("subject must be a string","pass the assessed SHA or ref, or omit it"),d!==void 0&&typeof d!="string"&&w("now must be an ISO timestamp string","omit now to use the clock"),(typeof r!="string"||r==="")&&w("by must name the assessor",'e.g. "by": "human"');let h=chunk66BO7JFR_cjs.c(s,p,r);h==="invalid"&&w(`"${r}" may not assess risk (needs capability "verify")`,`assess as human or one of: ${chunkTBLIZIWH_cjs.g(s,"verify").map(f=>f.id).join(", ")||"(no role has verify; register one)"}`),h&&w(`"${r}" did the work on "${o}" and may not assess its risk`,"assess as human or an independent role with capability verify");let g={level:m,factors:[...i]};return l!==void 0&&(g.subject=l),chunkTBLIZIWH_cjs.V(s,e,{type:"risk.assess",by:r,payload:{item:o,ref:t,...g}},f=>chunkTBLIZIWH_cjs.A(f,o,{kind:"risk-assessment",ref:t,by:r,data:g},d))}var W=["revision","paths","by","now"],rs=["in_progress","review","awaiting_human"],S=(s,e)=>chunkOSHBJIYD_cjs.b("invalid-input",`repo change: ${s}`,e);function as(s,e,a){(typeof a!="object"||a===null||Array.isArray(a))&&S("input must be an object",`pass { ${W.join(", ")} }`);for(let p of Object.keys(a))W.includes(p)||S(`unknown key "${p}"`,`use only: ${W.join(", ")}`);let{revision:o,paths:m,by:i,now:t}=a;(typeof o!="string"||o.trim()==="")&&S("revision must be a non-empty string",'e.g. "revision": "4f2c1e0"'),(!Array.isArray(m)||m.length===0)&&S("paths must be a non-empty array of paths",'e.g. "paths": ["src/cart.ts"]'),m.forEach((p,h)=>{let g=chunk66BO7JFR_cjs.e(p);g&&S(`paths[${h}] ${g}`,'send paths as `git diff --name-only -z` lists them (NUL-separated, unquoted; or with `-c core.quotePath=false`), e.g. "src/cart.ts"');}),(typeof i!="string"||i==="")&&S("by must name the reporter",'e.g. "by": "ci"'),t!==void 0&&typeof t!="string"&&S("now must be an ISO timestamp string","omit now to use the clock");let l=[...new Set(m)],r=chunkTBLIZIWH_cjs.V(s,e,{type:"repo.change",by:i,payload:{revision:o,paths:l}},p=>chunkTBLIZIWH_cjs.c(p,"repo.changed",i,{revision:o,paths:l},chunkTBLIZIWH_cjs.a(t))),d=[];for(let p of Object.values(r.state.items)){if(!rs.includes(p.status))continue;let h=chunk66BO7JFR_cjs.f(s,p);if(!h)continue;let g=new Set(h.assumptions.map(R=>R.source?.path)),f=new Set(h.stale),v=l.filter(R=>g.has(R)&&!f.has(R));v.length&&d.push({rule:"context-stale",severity:"warning",item:p.id,message:`context snapshot "${h.snapshot}" of "${p.id}" is stale: ${v.join(", ")} changed at ${o}`,fix:`re-verify and record a fresh snapshot of "${p.id}" with recordContextSnapshot`});}return {state:r.state,warnings:[...r.warnings,...d]}}var z=["baseline","mustPass","passTolerance","costTolerance"],is=["tokens","durationMs","turns","humanInterventions","reworks","escalations","itemsDone"],u=(s,e)=>chunkOSHBJIYD_cjs.b("invalid-input",`compareRuns: ${s}`,e),b=s=>typeof s=="string"?JSON.stringify(s):typeof s=="object"&&s!==null?Array.isArray(s)?"an array":"an object":typeof s=="function"||typeof s=="symbol"?typeof s:String(s),j=s=>typeof s=="object"&&s!==null&&!Array.isArray(s),y=(s,e)=>Object.hasOwn(s,e)?s[e]:void 0,D=(s,e)=>Number.isFinite(s)?s:u(`${e} is not finite (${s})`,"pass the host's measured usage figures"),T=(s,e)=>(typeof s!="string"&&u(`${e} is ${b(s)}, not an id`,'pass a string id such as "V0"'),chunkOSHBJIYD_cjs.c(s,e),s),B=(s,e)=>s===void 0?0:((typeof s!="number"||!Number.isFinite(s)||s<0||s>1)&&u(`${e} is ${b(s)}, not a fraction in [0, 1]`,`pass e.g. "${e}": 0.05`),s);function cs(s,e){if(!j(s))return u(`${e}.state is ${b(s)}, not a workflow state`,"pass the finished state.json");let[a,o,m]=["events","accounting","items"].map(t=>y(s,t));if(!Array.isArray(a)||!Array.isArray(o))return u(`${e}.state has no events and accounting arrays`,"pass a WorkflowState as loaded by loadState");if(!j(m))return u(`${e}.state.items is ${b(m)}, not an object`,"pass a WorkflowState as loaded by loadState");let i={tokens:0,durationMs:0,turns:o.length,humanInterventions:0,reworks:0,escalations:0,itemsDone:0};o.forEach((t,l)=>{if(!j(t))return u(`${e}.state.accounting[${l}] is ${b(t)}`,"pass accounting lines as recorded by complete");for(let r of ["tokensIn","tokensOut","durationMs"]){let d=y(t,r);(typeof d!="number"||!Number.isFinite(d)||d<0)&&u(`${e}.state.accounting[${l}].${r} is ${b(d)}, not a finite non-negative number`,"pass the host's measured usage figures");}i.tokens+=t.tokensIn+t.tokensOut,i.durationMs+=t.durationMs;}),D(i.tokens,`${e}.state token total`),D(i.durationMs,`${e}.state duration total`),a.forEach((t,l)=>{if(!j(t)||typeof y(t,"type")!="string")return u(`${e}.state.events[${l}] is ${b(t)}, not an event`,"pass events as recorded by the engine");let r=t.type;r==="pending.raised"||r==="blocker.cleared"?i.humanInterventions++:r==="item.rework"?i.reworks++:r==="item.escalated"&&i.escalations++;});for(let t of Object.values(m))j(t)&&y(t,"status")==="done"&&i.itemsDone++;return i}var Q=s=>s.sort((e,a)=>e-a).reduce((e,a)=>e+a,0)/s.length,_=(s,e)=>s<e?-1:s>e?1:0;function us(s,e){if(Array.isArray(s)||u(`runs is ${b(s)}, not an array`,"pass an array of { variant, scenario, state, passed }"),s.length===0&&u("no runs to compare","pass at least the baseline's finished runs"),!j(e))return u(`options is ${b(e)}, not an object`,'pass { baseline: "V0" }');for(let n of Object.keys(e))z.includes(n)||u(`unknown option "${n}"`,`use only: ${z.join(", ")}`);let a=e,o=T(y(a,"baseline"),"baseline"),m=y(a,"mustPass");m!==void 0&&!Array.isArray(m)&&u(`mustPass is ${b(m)}, not an array`,'pass e.g. "mustPass": ["s1"]');let i=[...new Set((m??[]).map(n=>T(n,"mustPass scenario")))],t=B(y(a,"passTolerance"),"passTolerance"),l=B(y(a,"costTolerance"),"costTolerance"),r=new Map,d=new Set;s.forEach((n,c)=>{let A=`runs[${c}]`;if(!j(n))return u(`${A} is ${b(n)}, not a run record`,"pass { variant, scenario, state, passed }");let M=T(y(n,"variant"),`${A}.variant`),x=T(y(n,"scenario"),`${A}.scenario`),I=y(n,"passed");typeof I!="boolean"&&u(`${A}.passed is ${b(I)}, not a boolean`,"pass the scorer's verdict as true or false");let k=cs(y(n,"state"),A),$=r.get(M);$||r.set(M,$={metrics:[],passed:0,ran:new Map,failed:new Set}),$.metrics.push(k);let E=$.ran.get(x)??[0,0];$.ran.set(x,E),E[1]++,d.add(x),I?($.passed++,E[0]++):$.failed.add(x);});let p=r.get(o);p||u(`baseline "${o}" has no run`,"name a variant that appears in runs");for(let n of i)d.has(n)||u(`mustPass scenario "${n}" has no run`,"name a scenario that appears in runs");let h=[...new Set([...p.ran.keys(),...i])].sort(_),g=[...r].map(([n,c])=>{let A=c.metrics.length,M={};for(let k of is)M[k]=D(Q(c.metrics.map($=>$[k])),`variant ${n} mean ${k}`);let x=i.filter(k=>c.failed.has(k)).sort(_),I=h.filter(k=>!c.ran.has(k));return {variant:n,runs:A,passed:c.passed,passRate:Q([...c.ran.values()].map(([k,$])=>k/$)),mean:M,regressions:x,missing:I,eligible:x.length===0&&I.length===0}});g.sort((n,c)=>Number(c.eligible)-Number(n.eligible)||c.passRate-n.passRate||n.mean.tokens-c.mean.tokens||n.mean.durationMs-c.mean.durationMs||n.mean.humanInterventions-c.mean.humanInterventions||_(n.variant,c.variant));let f=g.find(n=>n.variant===o),v=g.find(n=>n.variant!==o&&n.eligible&&n.passRate>=f.passRate-t&&(n.passRate>f.passRate+t||n.mean.tokens<f.mean.tokens*(1-l)));if(v)return {baseline:o,variants:g,winner:v.variant,reason:`${v.variant} beats baseline ${o}: pass rate ${v.passRate} vs ${f.passRate}, mean tokens ${v.mean.tokens} vs ${f.mean.tokens}`};let R=g.filter(n=>n.variant!==o),C;if(R.length===0)C=`no variant to compare with baseline ${o}`;else if(R.some(n=>n.eligible))C=`within noise: no eligible variant beats baseline ${o} beyond the tolerances`;else {let n=R.map(c=>`${c.variant} (${(c.regressions.length?c.regressions:c.missing).join(", ")})`).join("; ");C=`${R.some(c=>c.regressions.length)?"must-pass regression":"no eligible variant, missing runs"}: ${n}`;}return {baseline:o,variants:g,winner:null,reason:C}}Object.defineProperty(exports,"DEFAULT_RISK_TABLE",{enumerable:true,get:function(){return chunk66BO7JFR_cjs.b}});Object.defineProperty(exports,"contextGroundedViolations",{enumerable:true,get:function(){return chunk66BO7JFR_cjs.h}});Object.defineProperty(exports,"contextOf",{enumerable:true,get:function(){return chunk66BO7JFR_cjs.f}});Object.defineProperty(exports,"recordContextSnapshot",{enumerable:true,get:function(){return chunk66BO7JFR_cjs.g}});Object.defineProperty(exports,"riskEscalation",{enumerable:true,get:function(){return chunk66BO7JFR_cjs.d}});Object.defineProperty(exports,"withContextGrounding",{enumerable:true,get:function(){return chunk66BO7JFR_cjs.j}});Object.defineProperty(exports,"withRiskGate",{enumerable:true,get:function(){return chunk66BO7JFR_cjs.i}});exports.compareRuns=us;exports.recordRepoChange=as;exports.recordRiskAssessment=os;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|