ex-workflow 0.2.0-stage → 0.4.0-stage
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 +20 -1
- package/README.md +54 -12
- package/dist/adapters/index.cjs +1 -1
- package/dist/adapters/index.mjs +1 -1
- package/dist/chunk-36M6OVUJ.mjs +2 -0
- package/dist/chunk-36M6OVUJ.mjs.map +1 -0
- package/dist/{chunk-472WEDPJ.cjs → chunk-7KF5K3L7.cjs} +2 -2
- package/dist/{chunk-472WEDPJ.cjs.map → chunk-7KF5K3L7.cjs.map} +1 -1
- package/dist/chunk-CWBH7H52.cjs +2 -0
- package/dist/chunk-CWBH7H52.cjs.map +1 -0
- package/dist/chunk-DXC2RSN5.cjs +3 -0
- package/dist/chunk-DXC2RSN5.cjs.map +1 -0
- package/dist/{chunk-XSXHEEJX.mjs → chunk-GATJZYTB.mjs} +2 -2
- package/dist/{chunk-XSXHEEJX.mjs.map → chunk-GATJZYTB.mjs.map} +1 -1
- package/dist/chunk-GFH2FEZH.mjs +2 -0
- package/dist/chunk-GFH2FEZH.mjs.map +1 -0
- package/dist/{chunk-DBR24RTX.cjs → chunk-HHC5EZ54.cjs} +2 -2
- package/dist/{chunk-DBR24RTX.cjs.map → chunk-HHC5EZ54.cjs.map} +1 -1
- package/dist/chunk-KSKEFYY7.cjs +2 -0
- package/dist/chunk-KSKEFYY7.cjs.map +1 -0
- package/dist/chunk-KUUIAKEJ.cjs +2 -0
- package/dist/chunk-KUUIAKEJ.cjs.map +1 -0
- package/dist/{chunk-IBRC36PE.mjs → chunk-L2ZN6HEL.mjs} +2 -2
- package/dist/{chunk-IBRC36PE.mjs.map → chunk-L2ZN6HEL.mjs.map} +1 -1
- package/dist/chunk-NDORREWR.mjs +2 -0
- package/dist/chunk-NDORREWR.mjs.map +1 -0
- package/dist/{chunk-VN2UYV2O.mjs → chunk-NZ2DIDOD.mjs} +2 -2
- package/dist/{chunk-VN2UYV2O.mjs.map → chunk-NZ2DIDOD.mjs.map} +1 -1
- package/dist/chunk-OHSQ52DW.mjs +6 -0
- package/dist/chunk-OHSQ52DW.mjs.map +1 -0
- package/dist/chunk-RSKZVOYC.cjs +6 -0
- package/dist/chunk-RSKZVOYC.cjs.map +1 -0
- package/dist/chunk-S22CPYXJ.mjs +3 -0
- package/dist/chunk-S22CPYXJ.mjs.map +1 -0
- package/dist/chunk-SHAPFMVP.mjs +2 -0
- package/dist/chunk-SHAPFMVP.mjs.map +1 -0
- package/dist/chunk-SJRRQZ3R.cjs +2 -0
- package/dist/chunk-SJRRQZ3R.cjs.map +1 -0
- package/dist/{chunk-D4HNETUL.cjs → chunk-UM5X2JHB.cjs} +2 -2
- package/dist/{chunk-D4HNETUL.cjs.map → chunk-UM5X2JHB.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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/kanban/index.cjs +1 -1
- package/dist/kanban/index.mjs +1 -1
- package/dist/schema/index.cjs +2 -0
- package/dist/schema/index.cjs.map +1 -0
- package/dist/schema/index.d.cts +57 -0
- package/dist/schema/index.d.ts +57 -0
- package/dist/schema/index.mjs +2 -0
- package/dist/schema/index.mjs.map +1 -0
- package/dist/scrum/index.cjs +1 -1
- package/dist/scrum/index.mjs +1 -1
- package/dist/types.d.cts +38 -2
- package/dist/types.d.ts +38 -2
- package/dist/waterfall/index.cjs +2 -0
- package/dist/waterfall/index.cjs.map +1 -0
- package/dist/waterfall/index.d.cts +148 -0
- package/dist/waterfall/index.d.ts +148 -0
- package/dist/waterfall/index.mjs +2 -0
- package/dist/waterfall/index.mjs.map +1 -0
- package/package.json +31 -2
- package/dist/chunk-6R3YFUUV.cjs +0 -6
- package/dist/chunk-6R3YFUUV.cjs.map +0 -1
- package/dist/chunk-JDVE7DQR.cjs +0 -2
- package/dist/chunk-JDVE7DQR.cjs.map +0 -1
- package/dist/chunk-NQU5TH3A.mjs +0 -2
- package/dist/chunk-NQU5TH3A.mjs.map +0 -1
- package/dist/chunk-NRAPI3GV.cjs +0 -2
- package/dist/chunk-NRAPI3GV.cjs.map +0 -1
- package/dist/chunk-PD5FBDN7.mjs +0 -2
- package/dist/chunk-PD5FBDN7.mjs.map +0 -1
- package/dist/chunk-QDT35LXB.cjs +0 -2
- package/dist/chunk-QDT35LXB.cjs.map +0 -1
- package/dist/chunk-VGD4V5BA.mjs +0 -6
- package/dist/chunk-VGD4V5BA.mjs.map +0 -1
- package/dist/chunk-YJNDBKIG.mjs +0 -2
- package/dist/chunk-YJNDBKIG.mjs.map +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {b}from'./chunk-2FRRD6A3.mjs';var f={Accounting:{type:"object",properties:{item:{type:"string"},role:{type:"string"},model:{type:"string"},tokensIn:{type:"number"},tokensOut:{type:"number"},durationMs:{type:"number"},startedAt:{type:"string"},endedAt:{type:"string"}},required:["item","role","model","tokensIn","tokensOut","durationMs","startedAt","endedAt"],additionalProperties:false},Baseline:{type:"object",properties:{phase:{type:"string"},version:{type:"number"},at:{type:"string"},approvedBy:{type:"array",items:{type:"string"}},itemSnapshot:{type:"object",additionalProperties:{$ref:"#/definitions/WorkItem"}}},required:["phase","version","at","approvedBy","itemSnapshot"],additionalProperties:false},Blocker:{type:"object",properties:{id:{type:"string"},reason:{type:"string"},owner:{type:"string"},raisedAt:{type:"string"},clearedAt:{type:"string"}},required:["id","reason","owner","raisedAt"],additionalProperties:false},Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},Capability:{type:"string",enum:["order-backlog","define-acceptance","facilitate","deliver","review","verify","approve-gate","manage-flow","control-change","escalate"]},ClassOfService:{type:"string",enum:["expedite","fixed-date","standard","intangible"]},Event:{type:"object",properties:{seq:{type:"number"},at:{type:"string"},type:{type:"string"},by:{type:"string"},payload:{}},required:["seq","at","type","by","payload"],additionalProperties:false},Evidence:{type:"object",properties:{kind:{type:"string"},ref:{type:"string"},by:{type:"string"},at:{type:"string"}},required:["kind","ref","by","at"],additionalProperties:false},Gate:{type:"object",properties:{id:{type:"string"},requires:{type:"array",items:{$ref:"#/definitions/GateRequirement"}},evidence:{type:"array",items:{type:"string"}},onFail:{anyOf:[{type:"object",properties:{action:{type:"string",const:"block"}},required:["action"],additionalProperties:false},{type:"object",properties:{action:{type:"string",const:"return-to"},stage:{type:"string"}},required:["action","stage"],additionalProperties:false}]}},required:["id","requires","evidence","onFail"],additionalProperties:false},GateRequirement:{anyOf:[{type:"string",const:"human"},{type:"object",properties:{capability:{type:"string"}},required:["capability"],additionalProperties:false}]},Handoff:{type:"object",properties:{item:{type:"string"},role:{type:"string"},produced:{type:"array",items:{type:"object",properties:{kind:{type:"string"},ref:{type:"string"}},required:["kind","ref"],additionalProperties:false}},notes:{type:"string"},do_not:{type:"array",items:{type:"string"}},open_questions:{type:"array",items:{type:"string"}},verdict:{$ref:"#/definitions/Verdict"},follow_ups:{type:"array",items:{$ref:"#/definitions/NewItem"}},lessons:{type:"array",items:{type:"object",properties:{text:{type:"string"},scope:{type:"string",enum:["policy","skill","memory","spec","review"]}},required:["text","scope"],additionalProperties:false}}},required:["item","role","produced","notes","do_not","open_questions"],additionalProperties:false},ImpactAnalysis:{type:"object",properties:{summary:{type:"string"},reopen:{type:"array",items:{type:"string"}},weight:{type:"number"}},required:["summary","reopen","weight"],additionalProperties:false},ItemPatch:{type:"object",properties:{type:{$ref:"#/definitions/ItemType"},title:{type:"string"},description:{type:"string"},dependsOn:{type:"array",items:{type:"string"}},priority:{type:"number"},weight:{type:"number"},deadline:{type:"string"},classOfService:{$ref:"#/definitions/ClassOfService"},role:{type:"string"},parent:{type:"string"},acceptance:{type:"array",items:{type:"string"}},iteration:{type:"string"},traces:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}},affects:{type:"array",items:{type:"string"}},phase:{type:"string"},impactAnalysis:{$ref:"#/definitions/ImpactAnalysis"}},additionalProperties:false},ItemStatus:{type:"string",enum:["todo","in_progress","blocked","review","awaiting_human","done","dropped"]},ItemType:{type:"string",enum:["epic","story","task","bug","change-request","deliverable","question"]},Iteration:{type:"object",properties:{id:{type:"string"},goal:{type:"string"},budget:{$ref:"#/definitions/Budget"},spent:{$ref:"#/definitions/Spent"},startedAt:{type:"string"},endedAt:{type:"string"},committed:{type:"array",items:{type:"string"}},carryover:{type:"array",items:{type:"string"}},outcome:{type:"string",enum:["completed","cancelled"]},closing:{type:"boolean"}},required:["id","goal","budget","spent","startedAt","committed","carryover"],additionalProperties:false},Lesson:{type:"object",properties:{id:{type:"string"},at:{type:"string"},text:{type:"string"},scope:{type:"string",enum:["policy","skill","memory","spec","review"]},status:{type:"string",enum:["raised","adopted","dismissed"]},from:{type:"string"},item:{type:"string"},suggestedChange:{$ref:"#/definitions/LessonChange"}},required:["id","at","text","scope","status"],additionalProperties:false},LessonChange:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"agreement"},text:{type:"string"}},required:["kind","text"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dod"},policy:{$ref:"#/definitions/Policy"}},required:["kind","policy"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"backlog"},item:{$ref:"#/definitions/NewItem"}},required:["kind","item"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"skill"},note:{type:"string"}},required:["kind","note"],additionalProperties:false}]},MethodologyName:{type:"string",enum:["scrum","kanban","waterfall"]},ModelTier:{type:"string",enum:["small","medium","large"]},NewItem:{type:"object",additionalProperties:false,properties:{stage:{type:"string"},type:{$ref:"#/definitions/ItemType"},description:{type:"string"},dependsOn:{type:"array",items:{type:"string"}},priority:{type:"number"},weight:{type:"number"},deadline:{type:"string"},classOfService:{$ref:"#/definitions/ClassOfService"},role:{type:"string"},parent:{type:"string"},acceptance:{type:"array",items:{type:"string"}},iteration:{type:"string"},traces:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}},affects:{type:"array",items:{type:"string"}},phase:{type:"string"},impactAnalysis:{$ref:"#/definitions/ImpactAnalysis"},id:{type:"string"},title:{type:"string"}},required:["id","title"]},PendingHuman:{type:"object",properties:{id:{type:"string"},kind:{type:"string",enum:["gate","decision"]},item:{type:"string"},gate:{type:"string"},question:{type:"string"},raisedAt:{type:"string"}},required:["id","kind","question","raisedAt"],additionalProperties:false},Phase:{type:"object",properties:{id:{type:"string"},name:{type:"string"},deliverables:{type:"array",items:{type:"string"}},gate:{$ref:"#/definitions/Gate"},status:{type:"string",enum:["pending","open","baselined","reopened"]},budget:{$ref:"#/definitions/Budget"},produced:{type:"array",items:{$ref:"#/definitions/Produced"}}},required:["id","name","deliverables","gate","status"],additionalProperties:false},Policy:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"evidence"},evidenceKind:{type:"string"}},required:["kind","evidenceKind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"acceptance-written"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"estimate-present"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"no-open-blockers"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dependencies-done"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"custom"},id:{type:"string"},description:{type:"string"}},required:["kind","id","description"],additionalProperties:false}]},Produced:{type:"object",properties:{kind:{type:"string"},ref:{type:"string"},by:{type:"string"},at:{type:"string"}},required:["kind","ref","by","at"],additionalProperties:false},Role:{type:"object",properties:{id:{type:"string"},name:{type:"string"},modelTier:{$ref:"#/definitions/ModelTier"},resourceClass:{type:"string"},maxConcurrent:{type:"number"},capabilities:{type:"array",items:{$ref:"#/definitions/Capability"}},canApprove:{type:"array",items:{type:"string"}},inputs:{type:"array",items:{type:"string"}},outputs:{type:"array",items:{type:"string"}},do_not:{type:"array",items:{type:"string"}},constraints:{type:"array",items:{type:"string"}}},required:["id","name","modelTier","capabilities","canApprove","inputs","outputs","do_not"],additionalProperties:false},Spent:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},required:["tokens","turns","wallclockMs"],additionalProperties:false},Stage:{type:"object",properties:{id:{type:"string"},name:{type:"string"},wipLimit:{type:"number"},entryPolicy:{type:"array",items:{$ref:"#/definitions/Policy"}},exitPolicy:{type:"array",items:{$ref:"#/definitions/Policy"}},gate:{$ref:"#/definitions/Gate"},commitmentPoint:{type:"boolean"},deliveryPoint:{type:"boolean"},review:{type:"boolean"}},required:["id","name","entryPolicy","exitPolicy"],additionalProperties:false},Transition:{type:"object",properties:{from:{type:"object",properties:{stage:{type:"string"},status:{$ref:"#/definitions/ItemStatus"}},required:["stage","status"],additionalProperties:false},to:{type:"object",properties:{stage:{type:"string"},status:{$ref:"#/definitions/ItemStatus"}},required:["stage","status"],additionalProperties:false},at:{type:"string"},by:{type:"string"}},required:["from","to","at","by"],additionalProperties:false},Verdict:{type:"string",enum:["done","blocked","needs-review","rework","escalate"]},WorkItem:{type:"object",properties:{id:{type:"string"},type:{$ref:"#/definitions/ItemType"},title:{type:"string"},description:{type:"string"},dependsOn:{type:"array",items:{type:"string"}},priority:{type:"number"},weight:{type:"number"},deadline:{type:"string"},classOfService:{$ref:"#/definitions/ClassOfService"},stage:{type:"string"},status:{$ref:"#/definitions/ItemStatus"},role:{type:"string"},parent:{type:"string"},acceptance:{type:"array",items:{type:"string"}},evidence:{type:"array",items:{$ref:"#/definitions/Evidence"}},blockers:{type:"array",items:{$ref:"#/definitions/Blocker"}},transitions:{type:"array",items:{$ref:"#/definitions/Transition"}},iteration:{type:"string"},traces:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}},affects:{type:"array",items:{type:"string"}},phase:{type:"string"},impactAnalysis:{$ref:"#/definitions/ImpactAnalysis"}},required:["id","type","title","dependsOn","stage","status","acceptance","evidence","blockers","transitions"],additionalProperties:false},WorkflowState:{type:"object",properties:{version:{type:"number",const:1},methodology:{$ref:"#/definitions/MethodologyName"},config:{},items:{type:"object",additionalProperties:{$ref:"#/definitions/WorkItem"}},stages:{type:"array",items:{$ref:"#/definitions/Stage"}},roles:{type:"object",additionalProperties:{$ref:"#/definitions/Role"}},iterations:{type:"array",items:{$ref:"#/definitions/Iteration"}},phases:{type:"array",items:{$ref:"#/definitions/Phase"}},baseline:{$ref:"#/definitions/Baseline"},baselines:{type:"array",items:{$ref:"#/definitions/Baseline"}},events:{type:"array",items:{$ref:"#/definitions/Event"}},accounting:{type:"array",items:{$ref:"#/definitions/Accounting"}},pending:{type:"array",items:{$ref:"#/definitions/PendingHuman"}},lessons:{type:"array",items:{$ref:"#/definitions/Lesson"}},agreements:{type:"array",items:{type:"string"}}},required:["version","methodology","config","items","stages","roles","iterations","events","accounting","pending","lessons","agreements"],additionalProperties:false}},k={Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},Policy:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"evidence"},evidenceKind:{type:"string"}},required:["kind","evidenceKind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"acceptance-written"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"estimate-present"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"no-open-blockers"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dependencies-done"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"custom"},id:{type:"string"},description:{type:"string"}},required:["kind","id","description"],additionalProperties:false}]},ScrumConfig:{type:"object",properties:{sprintBudget:{$ref:"#/definitions/Budget"},productGoal:{type:"string"},definitionOfDone:{type:"array",items:{$ref:"#/definitions/Policy"}},refinementSharePct:{type:"number"},allowMidSprintAdd:{type:"string",enum:["never","po-only","any"]},inProgressWipLimit:{type:"number"}},required:["sprintBudget","productGoal","definitionOfDone","refinementSharePct","allowMidSprintAdd"],additionalProperties:false}},P={ClassConfig:{type:"object",properties:{wipBypass:{type:"number"},sle:{$ref:"#/definitions/ServiceLevel"}},additionalProperties:false},KanbanColumn:{type:"object",properties:{id:{type:"string"},name:{type:"string"},wipLimit:{type:"number"},policies:{type:"array",items:{$ref:"#/definitions/Policy"}},commitmentPoint:{type:"boolean"},deliveryPoint:{type:"boolean"},review:{type:"boolean"}},required:["id","name","policies"],additionalProperties:false},KanbanConfig:{type:"object",properties:{columns:{type:"array",items:{$ref:"#/definitions/KanbanColumn"}},classesOfService:{type:"object",properties:{expedite:{$ref:"#/definitions/ClassConfig"},"fixed-date":{$ref:"#/definitions/ClassConfig"},standard:{$ref:"#/definitions/ClassConfig"},intangible:{$ref:"#/definitions/ClassConfig"}},additionalProperties:false},fairness:{type:"object",properties:{aging:{type:"boolean"},maxDeferralRounds:{type:"number"}},required:["aging","maxDeferralRounds"],additionalProperties:false},cadences:{type:"object",properties:{replenishment:{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"delivery-planning":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"service-delivery-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"operations-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"risk-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"strategy-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false}},additionalProperties:false},throughputWindowMs:{type:"number"},maxExpedite:{type:"number"}},required:["columns","classesOfService","fairness","cadences","throughputWindowMs","maxExpedite"],additionalProperties:false},Policy:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"evidence"},evidenceKind:{type:"string"}},required:["kind","evidenceKind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"acceptance-written"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"estimate-present"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"no-open-blockers"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dependencies-done"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"custom"},id:{type:"string"},description:{type:"string"}},required:["kind","id","description"],additionalProperties:false}]},ServiceLevel:{type:"object",properties:{percentile:{type:"number"},targetMs:{type:"number"}},required:["percentile","targetMs"],additionalProperties:false}},$={Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},Gate:{type:"object",properties:{id:{type:"string"},requires:{type:"array",items:{$ref:"#/definitions/GateRequirement"}},evidence:{type:"array",items:{type:"string"}},onFail:{anyOf:[{type:"object",properties:{action:{type:"string",const:"block"}},required:["action"],additionalProperties:false},{type:"object",properties:{action:{type:"string",const:"return-to"},stage:{type:"string"}},required:["action","stage"],additionalProperties:false}]}},required:["id","requires","evidence","onFail"],additionalProperties:false},GateRequirement:{anyOf:[{type:"string",const:"human"},{type:"object",properties:{capability:{type:"string"}},required:["capability"],additionalProperties:false}]},WaterfallConfig:{type:"object",properties:{phases:{type:"array",items:{$ref:"#/definitions/WaterfallPhaseConfig"}},changeControl:{type:"object",properties:{requiresImpactAnalysis:{type:"boolean"},approvers:{type:"array",items:{$ref:"#/definitions/GateRequirement"}}},required:["requiresImpactAnalysis","approvers"],additionalProperties:false},traceability:{type:"object",properties:{from:{type:"string"},to:{type:"array",items:{type:"string"}}},required:["from","to"],additionalProperties:false},humanGates:{anyOf:[{type:"string",const:"all"},{type:"array",items:{type:"string"}}]}},required:["phases","changeControl","traceability","humanGates"],additionalProperties:false},WaterfallPhaseConfig:{type:"object",properties:{id:{type:"string"},name:{type:"string"},deliverables:{type:"array",items:{type:"string"}},gate:{$ref:"#/definitions/Gate"},budget:{$ref:"#/definitions/Budget"},deliverBy:{type:"string"}},required:["id","name","deliverables","gate"],additionalProperties:false}};var j="#/definitions/";function u(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function v(e,t){return e==="integer"?typeof t=="number"&&Number.isInteger(t):u(t)===e}function p(e){let t=JSON.stringify(e);return t===void 0?String(e):t.length>60?`${t.slice(0,57)}...`:t}function S(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function h(e,t){return JSON.stringify(e)===JSON.stringify(t)}function a(e,t,s,n,i){return {path:e===""?"/":e,keyword:t,message:s,expected:n,found:i}}function x(e,t){e.startsWith(j)||b("invalid-input",`schema $ref ${JSON.stringify(e)} is not #/definitions/<name>`,"regenerate the schema with pnpm schema:gen");let s=e.slice(j.length),n=t.definitions&&Object.hasOwn(t.definitions,s)?t.definitions[s]:void 0;return n||b("invalid-input",`schema $ref ${JSON.stringify(e)} names no definition`,"regenerate the schema with pnpm schema:gen"),n}function q(e,t){let s=t===""?"/":t;return e.reduce((n,i)=>n+(i.keyword==="type"&&i.path===s?1e3:i.keyword==="const"?100:1),0)}function O(e){let t=e[0]?.filter(s=>s.keyword==="const")??[];for(let s of t){let n=e.map(r=>r.find(o=>o.keyword==="const"&&o.path===s.path));if(n.some(r=>r===void 0))continue;let i=[...new Set(n.map(r=>r?.expected))].join(" | ");return {path:s.path,keyword:"enum",message:`expected one of ${i}`,expected:i,found:s.found}}}function w(e,t){return l(e,t,e,"")}function l(e,t,s,n){if(e.$ref!==void 0)return l(x(e.$ref,s),t,s,n);let i=[];if(e.type!==void 0){let r=Array.isArray(e.type)?e.type:[e.type];if(!r.some(o=>v(o,t))){let o=r.join(" | ");return [a(n,"type",`expected ${o}, got ${u(t)}`,o,p(t))]}}if(e.const!==void 0&&!h(t,e.const)&&i.push(a(n,"const",`expected ${p(e.const)}`,p(e.const),p(t))),e.enum!==void 0&&!e.enum.some(r=>h(r,t))){let r=e.enum.map(p).join(" | ");i.push(a(n,"enum",`expected one of ${r}`,r,p(t)));}if(typeof t=="number"&&(e.minimum!==void 0&&t<e.minimum&&i.push(a(n,"minimum",`expected >= ${e.minimum}`,`>= ${e.minimum}`,p(t))),e.maximum!==void 0&&t>e.maximum&&i.push(a(n,"maximum",`expected <= ${e.maximum}`,`<= ${e.maximum}`,p(t)))),typeof t=="string"&&(e.minLength!==void 0&&t.length<e.minLength&&i.push(a(n,"minLength",`expected at least ${e.minLength} characters`,`length >= ${e.minLength}`,p(t))),e.pattern!==void 0&&!new RegExp(e.pattern,"u").test(t)&&i.push(a(n,"pattern",`expected to match /${e.pattern}/`,`/${e.pattern}/`,p(t)))),Array.isArray(t)&&e.items!==void 0){let r=e.items;t.forEach((o,c)=>i.push(...l(r,o,s,`${n}/${c}`)));}if(u(t)==="object"){let r=t;for(let[o,c]of Object.entries(r)){let g=e.properties&&Object.hasOwn(e.properties,o)?e.properties[o]:void 0,d=`${n}/${S(o)}`;if(g)i.push(...l(g,c,s,d));else if(e.additionalProperties===false){let b=Object.keys(e.properties??{}).join(", ");i.push(a(d,"additionalProperties",`unknown property ${JSON.stringify(o)}`,b?`one of ${b}`:"no properties",o));}else typeof e.additionalProperties=="object"&&i.push(...l(e.additionalProperties,c,s,d));}for(let o of e.required??[])Object.hasOwn(r,o)||i.push(a(`${n}/${S(o)}`,"required",`missing required property ${JSON.stringify(o)}`,"present","absent"));}if(e.anyOf!==void 0){let r,o=[];for(let g of e.anyOf){let d=l(g,t,s,n);if(d.length===0){r=[];break}o.push(d),(r===void 0||q(d,n)<q(r,n))&&(r=d);}let c=r&&r.length>0?O(o):void 0;c?i.push(c):r&&i.push(...r);}return i}function I(e,t,s){let n=w(e,t),i=n[0];if(!i)return;let r=n.length>1?` (+${n.length-1} more)`:"";b("invalid-input",`${s} does not match its schema: ${i.path} ${i.message}${r}`,`fix ${s} at ${i.path}: expected ${i.expected}, found ${i.found}`);}var A="http://json-schema.org/draft-07/schema#";function y(e,t){return {$schema:A,$ref:`#/definitions/${e}`,definitions:t}}var J=y("WorkflowState",f),R=y("Role",f),B=y("NewItem",f),M=y("ItemPatch",f),L=y("Handoff",f),_=y("ScrumConfig",k),D=y("KanbanConfig",P),F=y("WaterfallConfig",$);
|
|
2
|
+
export{w as a,I as b,A as c,J as d,R as e,B as f,M as g,L as h,_ as i,D as j,F as k};//# sourceMappingURL=chunk-S22CPYXJ.mjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-S22CPYXJ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema/generated.ts","../src/schema/validate.ts","../src/schema/index.ts"],"names":["CORE_DEFINITIONS","SCRUM_DEFINITIONS","KANBAN_DEFINITIONS","WATERFALL_DEFINITIONS","DEFS","kindOf","v","isType","t","show","s","esc","key","same","a","b","err","path","keyword","message","expected","found","resolve","ref","root","fail","name","def","rank","errors","branchPath","own","e","collapse","branches","first","candidate","consts","c","validate","schema","value","walk","out","types","items","i","obj","prop","at","known","best","failed","branch","merged","assertValid","what","more","DRAFT_07","document","definitions","workflowStateSchema","roleSchema","newItemSchema","itemPatchSchema","handoffSchema","scrumConfigSchema","kanbanConfigSchema","waterfallConfigSchema"],"mappings":"qCAIO,IAAMA,CAAAA,CAA+C,CAC1D,UAAA,CAAY,CACV,IAAA,CAAM,QAAA,CACN,UAAA,CAAY,CACV,IAAA,CAAM,CACJ,IAAA,CAAM,QACR,CAAA,CACA,IAAA,CAAM,CACJ,IAAA,CAAM,QACR,CAAA,CACA,KAAA,CAAO,CACL,IAAA,CAAM,QACR,CAAA,CACA,QAAA,CAAU,CACR,IAAA,CAAM,QACR,CAAA,CACA,SAAA,CAAW,CACT,IAAA,CAAM,QACR,CAAA,CACA,UAAA,CAAY,CACV,IAAA,CAAM,QACR,CAAA,CACA,SAAA,CAAW,CACT,IAAA,CAAM,QACR,CAAA,CACA,OAAA,CAAS,CACP,IAAA,CAAM,QACR,CACF,CAAA,CACA,QAAA,CAAU,CACR,MAAA,CACA,MAAA,CACA,OAAA,CACA,UAAA,CACA,WAAA,C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AAA,CAExDiE,CAAAA,CAAgBN,CAAAA,CAAS,SAAA,CAAW3D,CAAgB,CAAA,CAEpDkE,CAAAA,CAAoBP,CAAAA,CAAS,aAAA,CAAe1D,CAAiB,CAAA,CAC7DkE,CAAAA,CAAqBR,CAAAA,CAAS,cAAA,CAAgBzD,CAAkB,CAAA,CAChEkE,CAAAA,CAAwBT,CAAAA,CAAS,iBAAA,CAAmBxD,CAAqB","file":"chunk-S22CPYXJ.mjs","sourcesContent":["// GENERATED by scripts/gen-schema.mjs from src/types.ts and src/{scrum,kanban,waterfall}/config.ts.\n// Do not edit. Run `pnpm schema:gen`; `pnpm schema:check` fails the build when this file is stale.\nimport type { JsonSchema } from \"./types.ts\";\n\nexport const CORE_DEFINITIONS: Record<string, JsonSchema> = {\n Accounting: {\n type: \"object\",\n properties: {\n item: {\n type: \"string\",\n },\n role: {\n type: \"string\",\n },\n model: {\n type: \"string\",\n },\n tokensIn: {\n type: \"number\",\n },\n tokensOut: {\n type: \"number\",\n },\n durationMs: {\n type: \"number\",\n },\n startedAt: {\n type: \"string\",\n },\n endedAt: {\n type: \"string\",\n },\n },\n required: [\n \"item\",\n \"role\",\n \"model\",\n \"tokensIn\",\n \"tokensOut\",\n \"durationMs\",\n \"startedAt\",\n \"endedAt\",\n ],\n additionalProperties: false,\n },\n Baseline: {\n type: \"object\",\n properties: {\n phase: {\n type: \"string\",\n },\n version: {\n type: \"number\",\n },\n at: {\n type: \"string\",\n },\n approvedBy: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n itemSnapshot: {\n type: \"object\",\n additionalProperties: {\n $ref: \"#/definitions/WorkItem\",\n },\n },\n },\n required: [\"phase\", \"version\", \"at\", \"approvedBy\", \"itemSnapshot\"],\n additionalProperties: false,\n },\n Blocker: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n reason: {\n type: \"string\",\n },\n owner: {\n type: \"string\",\n },\n raisedAt: {\n type: \"string\",\n },\n clearedAt: {\n type: \"string\",\n },\n },\n required: [\"id\", \"reason\", \"owner\", \"raisedAt\"],\n additionalProperties: false,\n },\n Budget: {\n type: \"object\",\n properties: {\n tokens: {\n type: \"number\",\n },\n turns: {\n type: \"number\",\n },\n wallclockMs: {\n type: \"number\",\n },\n },\n additionalProperties: false,\n },\n Capability: {\n type: \"string\",\n enum: [\n \"order-backlog\",\n \"define-acceptance\",\n \"facilitate\",\n \"deliver\",\n \"review\",\n \"verify\",\n \"approve-gate\",\n \"manage-flow\",\n \"control-change\",\n \"escalate\",\n ],\n },\n ClassOfService: {\n type: \"string\",\n enum: [\"expedite\", \"fixed-date\", \"standard\", \"intangible\"],\n },\n Event: {\n type: \"object\",\n properties: {\n seq: {\n type: \"number\",\n },\n at: {\n type: \"string\",\n },\n type: {\n type: \"string\",\n },\n by: {\n type: \"string\",\n },\n payload: {},\n },\n required: [\"seq\", \"at\", \"type\", \"by\", \"payload\"],\n additionalProperties: false,\n },\n Evidence: {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n },\n ref: {\n type: \"string\",\n },\n by: {\n type: \"string\",\n },\n at: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"ref\", \"by\", \"at\"],\n additionalProperties: false,\n },\n Gate: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n requires: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/GateRequirement\",\n },\n },\n evidence: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n onFail: {\n anyOf: [\n {\n type: \"object\",\n properties: {\n action: {\n type: \"string\",\n const: \"block\",\n },\n },\n required: [\"action\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n action: {\n type: \"string\",\n const: \"return-to\",\n },\n stage: {\n type: \"string\",\n },\n },\n required: [\"action\", \"stage\"],\n additionalProperties: false,\n },\n ],\n },\n },\n required: [\"id\", \"requires\", \"evidence\", \"onFail\"],\n additionalProperties: false,\n },\n GateRequirement: {\n anyOf: [\n {\n type: \"string\",\n const: \"human\",\n },\n {\n type: \"object\",\n properties: {\n capability: {\n type: \"string\",\n },\n },\n required: [\"capability\"],\n additionalProperties: false,\n },\n ],\n },\n Handoff: {\n type: \"object\",\n properties: {\n item: {\n type: \"string\",\n },\n role: {\n type: \"string\",\n },\n produced: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n },\n ref: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"ref\"],\n additionalProperties: false,\n },\n },\n notes: {\n type: \"string\",\n },\n do_not: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n open_questions: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n verdict: {\n $ref: \"#/definitions/Verdict\",\n },\n follow_ups: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/NewItem\",\n },\n },\n lessons: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n text: {\n type: \"string\",\n },\n scope: {\n type: \"string\",\n enum: [\"policy\", \"skill\", \"memory\", \"spec\", \"review\"],\n },\n },\n required: [\"text\", \"scope\"],\n additionalProperties: false,\n },\n },\n },\n required: [\"item\", \"role\", \"produced\", \"notes\", \"do_not\", \"open_questions\"],\n additionalProperties: false,\n },\n ImpactAnalysis: {\n type: \"object\",\n properties: {\n summary: {\n type: \"string\",\n },\n reopen: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n weight: {\n type: \"number\",\n },\n },\n required: [\"summary\", \"reopen\", \"weight\"],\n additionalProperties: false,\n },\n ItemPatch: {\n type: \"object\",\n properties: {\n type: {\n $ref: \"#/definitions/ItemType\",\n },\n title: {\n type: \"string\",\n },\n description: {\n type: \"string\",\n },\n dependsOn: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n priority: {\n type: \"number\",\n },\n weight: {\n type: \"number\",\n },\n deadline: {\n type: \"string\",\n },\n classOfService: {\n $ref: \"#/definitions/ClassOfService\",\n },\n role: {\n type: \"string\",\n },\n parent: {\n type: \"string\",\n },\n acceptance: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n iteration: {\n type: \"string\",\n },\n traces: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n tags: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n affects: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n phase: {\n type: \"string\",\n },\n impactAnalysis: {\n $ref: \"#/definitions/ImpactAnalysis\",\n },\n },\n additionalProperties: false,\n },\n ItemStatus: {\n type: \"string\",\n enum: [\"todo\", \"in_progress\", \"blocked\", \"review\", \"awaiting_human\", \"done\", \"dropped\"],\n },\n ItemType: {\n type: \"string\",\n enum: [\"epic\", \"story\", \"task\", \"bug\", \"change-request\", \"deliverable\", \"question\"],\n },\n Iteration: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n goal: {\n type: \"string\",\n },\n budget: {\n $ref: \"#/definitions/Budget\",\n },\n spent: {\n $ref: \"#/definitions/Spent\",\n },\n startedAt: {\n type: \"string\",\n },\n endedAt: {\n type: \"string\",\n },\n committed: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n carryover: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n outcome: {\n type: \"string\",\n enum: [\"completed\", \"cancelled\"],\n },\n closing: {\n type: \"boolean\",\n },\n },\n required: [\"id\", \"goal\", \"budget\", \"spent\", \"startedAt\", \"committed\", \"carryover\"],\n additionalProperties: false,\n },\n Lesson: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n at: {\n type: \"string\",\n },\n text: {\n type: \"string\",\n },\n scope: {\n type: \"string\",\n enum: [\"policy\", \"skill\", \"memory\", \"spec\", \"review\"],\n },\n status: {\n type: \"string\",\n enum: [\"raised\", \"adopted\", \"dismissed\"],\n },\n from: {\n type: \"string\",\n },\n item: {\n type: \"string\",\n },\n suggestedChange: {\n $ref: \"#/definitions/LessonChange\",\n },\n },\n required: [\"id\", \"at\", \"text\", \"scope\", \"status\"],\n additionalProperties: false,\n },\n LessonChange: {\n anyOf: [\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"agreement\",\n },\n text: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"text\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"dod\",\n },\n policy: {\n $ref: \"#/definitions/Policy\",\n },\n },\n required: [\"kind\", \"policy\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"backlog\",\n },\n item: {\n $ref: \"#/definitions/NewItem\",\n },\n },\n required: [\"kind\", \"item\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"skill\",\n },\n note: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"note\"],\n additionalProperties: false,\n },\n ],\n },\n MethodologyName: {\n type: \"string\",\n enum: [\"scrum\", \"kanban\", \"waterfall\"],\n },\n ModelTier: {\n type: \"string\",\n enum: [\"small\", \"medium\", \"large\"],\n },\n NewItem: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n stage: {\n type: \"string\",\n },\n type: {\n $ref: \"#/definitions/ItemType\",\n },\n description: {\n type: \"string\",\n },\n dependsOn: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n priority: {\n type: \"number\",\n },\n weight: {\n type: \"number\",\n },\n deadline: {\n type: \"string\",\n },\n classOfService: {\n $ref: \"#/definitions/ClassOfService\",\n },\n role: {\n type: \"string\",\n },\n parent: {\n type: \"string\",\n },\n acceptance: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n iteration: {\n type: \"string\",\n },\n traces: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n tags: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n affects: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n phase: {\n type: \"string\",\n },\n impactAnalysis: {\n $ref: \"#/definitions/ImpactAnalysis\",\n },\n id: {\n type: \"string\",\n },\n title: {\n type: \"string\",\n },\n },\n required: [\"id\", \"title\"],\n },\n PendingHuman: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n kind: {\n type: \"string\",\n enum: [\"gate\", \"decision\"],\n },\n item: {\n type: \"string\",\n },\n gate: {\n type: \"string\",\n },\n question: {\n type: \"string\",\n },\n raisedAt: {\n type: \"string\",\n },\n },\n required: [\"id\", \"kind\", \"question\", \"raisedAt\"],\n additionalProperties: false,\n },\n Phase: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n name: {\n type: \"string\",\n },\n deliverables: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n gate: {\n $ref: \"#/definitions/Gate\",\n },\n status: {\n type: \"string\",\n enum: [\"pending\", \"open\", \"baselined\", \"reopened\"],\n },\n budget: {\n $ref: \"#/definitions/Budget\",\n },\n produced: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Produced\",\n },\n },\n },\n required: [\"id\", \"name\", \"deliverables\", \"gate\", \"status\"],\n additionalProperties: false,\n },\n Policy: {\n anyOf: [\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"evidence\",\n },\n evidenceKind: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"evidenceKind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"acceptance-written\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"estimate-present\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"no-open-blockers\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"dependencies-done\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"custom\",\n },\n id: {\n type: \"string\",\n },\n description: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"id\", \"description\"],\n additionalProperties: false,\n },\n ],\n },\n Produced: {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n },\n ref: {\n type: \"string\",\n },\n by: {\n type: \"string\",\n },\n at: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"ref\", \"by\", \"at\"],\n additionalProperties: false,\n },\n Role: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n name: {\n type: \"string\",\n },\n modelTier: {\n $ref: \"#/definitions/ModelTier\",\n },\n resourceClass: {\n type: \"string\",\n },\n maxConcurrent: {\n type: \"number\",\n },\n capabilities: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Capability\",\n },\n },\n canApprove: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n inputs: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n outputs: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n do_not: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n constraints: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n },\n required: [\n \"id\",\n \"name\",\n \"modelTier\",\n \"capabilities\",\n \"canApprove\",\n \"inputs\",\n \"outputs\",\n \"do_not\",\n ],\n additionalProperties: false,\n },\n Spent: {\n type: \"object\",\n properties: {\n tokens: {\n type: \"number\",\n },\n turns: {\n type: \"number\",\n },\n wallclockMs: {\n type: \"number\",\n },\n },\n required: [\"tokens\", \"turns\", \"wallclockMs\"],\n additionalProperties: false,\n },\n Stage: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n name: {\n type: \"string\",\n },\n wipLimit: {\n type: \"number\",\n },\n entryPolicy: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Policy\",\n },\n },\n exitPolicy: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Policy\",\n },\n },\n gate: {\n $ref: \"#/definitions/Gate\",\n },\n commitmentPoint: {\n type: \"boolean\",\n },\n deliveryPoint: {\n type: \"boolean\",\n },\n review: {\n type: \"boolean\",\n },\n },\n required: [\"id\", \"name\", \"entryPolicy\", \"exitPolicy\"],\n additionalProperties: false,\n },\n Transition: {\n type: \"object\",\n properties: {\n from: {\n type: \"object\",\n properties: {\n stage: {\n type: \"string\",\n },\n status: {\n $ref: \"#/definitions/ItemStatus\",\n },\n },\n required: [\"stage\", \"status\"],\n additionalProperties: false,\n },\n to: {\n type: \"object\",\n properties: {\n stage: {\n type: \"string\",\n },\n status: {\n $ref: \"#/definitions/ItemStatus\",\n },\n },\n required: [\"stage\", \"status\"],\n additionalProperties: false,\n },\n at: {\n type: \"string\",\n },\n by: {\n type: \"string\",\n },\n },\n required: [\"from\", \"to\", \"at\", \"by\"],\n additionalProperties: false,\n },\n Verdict: {\n type: \"string\",\n enum: [\"done\", \"blocked\", \"needs-review\", \"rework\", \"escalate\"],\n },\n WorkItem: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n type: {\n $ref: \"#/definitions/ItemType\",\n },\n title: {\n type: \"string\",\n },\n description: {\n type: \"string\",\n },\n dependsOn: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n priority: {\n type: \"number\",\n },\n weight: {\n type: \"number\",\n },\n deadline: {\n type: \"string\",\n },\n classOfService: {\n $ref: \"#/definitions/ClassOfService\",\n },\n stage: {\n type: \"string\",\n },\n status: {\n $ref: \"#/definitions/ItemStatus\",\n },\n role: {\n type: \"string\",\n },\n parent: {\n type: \"string\",\n },\n acceptance: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n evidence: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Evidence\",\n },\n },\n blockers: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Blocker\",\n },\n },\n transitions: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Transition\",\n },\n },\n iteration: {\n type: \"string\",\n },\n traces: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n tags: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n affects: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n phase: {\n type: \"string\",\n },\n impactAnalysis: {\n $ref: \"#/definitions/ImpactAnalysis\",\n },\n },\n required: [\n \"id\",\n \"type\",\n \"title\",\n \"dependsOn\",\n \"stage\",\n \"status\",\n \"acceptance\",\n \"evidence\",\n \"blockers\",\n \"transitions\",\n ],\n additionalProperties: false,\n },\n WorkflowState: {\n type: \"object\",\n properties: {\n version: {\n type: \"number\",\n const: 1,\n },\n methodology: {\n $ref: \"#/definitions/MethodologyName\",\n },\n config: {},\n items: {\n type: \"object\",\n additionalProperties: {\n $ref: \"#/definitions/WorkItem\",\n },\n },\n stages: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Stage\",\n },\n },\n roles: {\n type: \"object\",\n additionalProperties: {\n $ref: \"#/definitions/Role\",\n },\n },\n iterations: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Iteration\",\n },\n },\n phases: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Phase\",\n },\n },\n baseline: {\n $ref: \"#/definitions/Baseline\",\n },\n baselines: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Baseline\",\n },\n },\n events: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Event\",\n },\n },\n accounting: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Accounting\",\n },\n },\n pending: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/PendingHuman\",\n },\n },\n lessons: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Lesson\",\n },\n },\n agreements: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n },\n required: [\n \"version\",\n \"methodology\",\n \"config\",\n \"items\",\n \"stages\",\n \"roles\",\n \"iterations\",\n \"events\",\n \"accounting\",\n \"pending\",\n \"lessons\",\n \"agreements\",\n ],\n additionalProperties: false,\n },\n};\n\nexport const SCRUM_DEFINITIONS: Record<string, JsonSchema> = {\n Budget: {\n type: \"object\",\n properties: {\n tokens: {\n type: \"number\",\n },\n turns: {\n type: \"number\",\n },\n wallclockMs: {\n type: \"number\",\n },\n },\n additionalProperties: false,\n },\n Policy: {\n anyOf: [\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"evidence\",\n },\n evidenceKind: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"evidenceKind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"acceptance-written\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"estimate-present\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"no-open-blockers\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"dependencies-done\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"custom\",\n },\n id: {\n type: \"string\",\n },\n description: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"id\", \"description\"],\n additionalProperties: false,\n },\n ],\n },\n ScrumConfig: {\n type: \"object\",\n properties: {\n sprintBudget: {\n $ref: \"#/definitions/Budget\",\n },\n productGoal: {\n type: \"string\",\n },\n definitionOfDone: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Policy\",\n },\n },\n refinementSharePct: {\n type: \"number\",\n },\n allowMidSprintAdd: {\n type: \"string\",\n enum: [\"never\", \"po-only\", \"any\"],\n },\n inProgressWipLimit: {\n type: \"number\",\n },\n },\n required: [\n \"sprintBudget\",\n \"productGoal\",\n \"definitionOfDone\",\n \"refinementSharePct\",\n \"allowMidSprintAdd\",\n ],\n additionalProperties: false,\n },\n};\n\nexport const KANBAN_DEFINITIONS: Record<string, JsonSchema> = {\n ClassConfig: {\n type: \"object\",\n properties: {\n wipBypass: {\n type: \"number\",\n },\n sle: {\n $ref: \"#/definitions/ServiceLevel\",\n },\n },\n additionalProperties: false,\n },\n KanbanColumn: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n name: {\n type: \"string\",\n },\n wipLimit: {\n type: \"number\",\n },\n policies: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/Policy\",\n },\n },\n commitmentPoint: {\n type: \"boolean\",\n },\n deliveryPoint: {\n type: \"boolean\",\n },\n review: {\n type: \"boolean\",\n },\n },\n required: [\"id\", \"name\", \"policies\"],\n additionalProperties: false,\n },\n KanbanConfig: {\n type: \"object\",\n properties: {\n columns: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/KanbanColumn\",\n },\n },\n classesOfService: {\n type: \"object\",\n properties: {\n expedite: {\n $ref: \"#/definitions/ClassConfig\",\n },\n \"fixed-date\": {\n $ref: \"#/definitions/ClassConfig\",\n },\n standard: {\n $ref: \"#/definitions/ClassConfig\",\n },\n intangible: {\n $ref: \"#/definitions/ClassConfig\",\n },\n },\n additionalProperties: false,\n },\n fairness: {\n type: \"object\",\n properties: {\n aging: {\n type: \"boolean\",\n },\n maxDeferralRounds: {\n type: \"number\",\n },\n },\n required: [\"aging\", \"maxDeferralRounds\"],\n additionalProperties: false,\n },\n cadences: {\n type: \"object\",\n properties: {\n replenishment: {\n type: \"object\",\n properties: {\n everyTurns: {\n type: \"number\",\n },\n },\n additionalProperties: false,\n },\n \"delivery-planning\": {\n type: \"object\",\n properties: {\n everyTurns: {\n type: \"number\",\n },\n },\n additionalProperties: false,\n },\n \"service-delivery-review\": {\n type: \"object\",\n properties: {\n everyTurns: {\n type: \"number\",\n },\n },\n additionalProperties: false,\n },\n \"operations-review\": {\n type: \"object\",\n properties: {\n everyTurns: {\n type: \"number\",\n },\n },\n additionalProperties: false,\n },\n \"risk-review\": {\n type: \"object\",\n properties: {\n everyTurns: {\n type: \"number\",\n },\n },\n additionalProperties: false,\n },\n \"strategy-review\": {\n type: \"object\",\n properties: {\n everyTurns: {\n type: \"number\",\n },\n },\n additionalProperties: false,\n },\n },\n additionalProperties: false,\n },\n throughputWindowMs: {\n type: \"number\",\n },\n maxExpedite: {\n type: \"number\",\n },\n },\n required: [\n \"columns\",\n \"classesOfService\",\n \"fairness\",\n \"cadences\",\n \"throughputWindowMs\",\n \"maxExpedite\",\n ],\n additionalProperties: false,\n },\n Policy: {\n anyOf: [\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"evidence\",\n },\n evidenceKind: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"evidenceKind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"acceptance-written\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"estimate-present\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"no-open-blockers\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"dependencies-done\",\n },\n },\n required: [\"kind\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n kind: {\n type: \"string\",\n const: \"custom\",\n },\n id: {\n type: \"string\",\n },\n description: {\n type: \"string\",\n },\n },\n required: [\"kind\", \"id\", \"description\"],\n additionalProperties: false,\n },\n ],\n },\n ServiceLevel: {\n type: \"object\",\n properties: {\n percentile: {\n type: \"number\",\n },\n targetMs: {\n type: \"number\",\n },\n },\n required: [\"percentile\", \"targetMs\"],\n additionalProperties: false,\n },\n};\n\nexport const WATERFALL_DEFINITIONS: Record<string, JsonSchema> = {\n Budget: {\n type: \"object\",\n properties: {\n tokens: {\n type: \"number\",\n },\n turns: {\n type: \"number\",\n },\n wallclockMs: {\n type: \"number\",\n },\n },\n additionalProperties: false,\n },\n Gate: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n requires: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/GateRequirement\",\n },\n },\n evidence: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n onFail: {\n anyOf: [\n {\n type: \"object\",\n properties: {\n action: {\n type: \"string\",\n const: \"block\",\n },\n },\n required: [\"action\"],\n additionalProperties: false,\n },\n {\n type: \"object\",\n properties: {\n action: {\n type: \"string\",\n const: \"return-to\",\n },\n stage: {\n type: \"string\",\n },\n },\n required: [\"action\", \"stage\"],\n additionalProperties: false,\n },\n ],\n },\n },\n required: [\"id\", \"requires\", \"evidence\", \"onFail\"],\n additionalProperties: false,\n },\n GateRequirement: {\n anyOf: [\n {\n type: \"string\",\n const: \"human\",\n },\n {\n type: \"object\",\n properties: {\n capability: {\n type: \"string\",\n },\n },\n required: [\"capability\"],\n additionalProperties: false,\n },\n ],\n },\n WaterfallConfig: {\n type: \"object\",\n properties: {\n phases: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/WaterfallPhaseConfig\",\n },\n },\n changeControl: {\n type: \"object\",\n properties: {\n requiresImpactAnalysis: {\n type: \"boolean\",\n },\n approvers: {\n type: \"array\",\n items: {\n $ref: \"#/definitions/GateRequirement\",\n },\n },\n },\n required: [\"requiresImpactAnalysis\", \"approvers\"],\n additionalProperties: false,\n },\n traceability: {\n type: \"object\",\n properties: {\n from: {\n type: \"string\",\n },\n to: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n },\n required: [\"from\", \"to\"],\n additionalProperties: false,\n },\n humanGates: {\n anyOf: [\n {\n type: \"string\",\n const: \"all\",\n },\n {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n ],\n },\n },\n required: [\"phases\", \"changeControl\", \"traceability\", \"humanGates\"],\n additionalProperties: false,\n },\n WaterfallPhaseConfig: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n name: {\n type: \"string\",\n },\n deliverables: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n gate: {\n $ref: \"#/definitions/Gate\",\n },\n budget: {\n $ref: \"#/definitions/Budget\",\n },\n deliverBy: {\n type: \"string\",\n },\n },\n required: [\"id\", \"name\", \"deliverables\", \"gate\"],\n additionalProperties: false,\n },\n};\n","import { fail } from \"../errors.ts\";\nimport type { JsonSchema, SchemaError } from \"./types.ts\";\n\nconst DEFS = \"#/definitions/\";\n\nfunction kindOf(v: unknown): string {\n if (v === null) return \"null\";\n if (Array.isArray(v)) return \"array\";\n return typeof v;\n}\nfunction isType(t: string, v: unknown): boolean {\n if (t === \"integer\") return typeof v === \"number\" && Number.isInteger(v);\n return kindOf(v) === t;\n}\nfunction show(v: unknown): string {\n const s = JSON.stringify(v);\n if (s === undefined) return String(v);\n return s.length > 60 ? `${s.slice(0, 57)}...` : s;\n}\n/** JSON-pointer escaping for one key. */\nfunction esc(key: string): string {\n return key.replace(/~/g, \"~0\").replace(/\\//g, \"~1\");\n}\nfunction same(a: unknown, b: unknown): boolean {\n return JSON.stringify(a) === JSON.stringify(b);\n}\nfunction err(\n path: string,\n keyword: string,\n message: string,\n expected: string,\n found: string,\n): SchemaError {\n return { path: path === \"\" ? \"/\" : path, keyword, message, expected, found };\n}\n\nfunction resolve(ref: string, root: JsonSchema): JsonSchema {\n if (!ref.startsWith(DEFS))\n fail(\n \"invalid-input\",\n `schema $ref ${JSON.stringify(ref)} is not #/definitions/<name>`,\n \"regenerate the schema with pnpm schema:gen\",\n );\n const name = ref.slice(DEFS.length);\n const def =\n root.definitions && Object.hasOwn(root.definitions, name) ? root.definitions[name] : undefined;\n if (!def)\n fail(\n \"invalid-input\",\n `schema $ref ${JSON.stringify(ref)} names no definition`,\n \"regenerate the schema with pnpm schema:gen\",\n );\n return def;\n}\n\n/**\n * Misfit of one anyOf branch (lower is a better fit): a `type` error at the branch's own path (the value is the\n * wrong kind entirely) weighs 1000, a `const` mismatch (a discriminator) 100, anything else 1.\n */\nfunction rank(errors: SchemaError[], branchPath: string): number {\n const own = branchPath === \"\" ? \"/\" : branchPath;\n return errors.reduce(\n (n, e) => n + (e.keyword === \"type\" && e.path === own ? 1000 : e.keyword === \"const\" ? 100 : 1),\n 0,\n );\n}\n\n/** When every failed branch has a `const` error at one pointer (the discriminator), report that once as an enum. */\nfunction collapse(branches: SchemaError[][]): SchemaError | undefined {\n const first = branches[0]?.filter((e) => e.keyword === \"const\") ?? [];\n for (const candidate of first) {\n const consts = branches.map((b) =>\n b.find((e) => e.keyword === \"const\" && e.path === candidate.path),\n );\n if (consts.some((c) => c === undefined)) continue;\n const expected = [...new Set(consts.map((c) => c?.expected))].join(\" | \");\n return {\n path: candidate.path,\n keyword: \"enum\",\n message: `expected one of ${expected}`,\n expected,\n found: candidate.found,\n };\n }\n return undefined;\n}\n\n/** Validate `value` against `schema` (a document: `$ref`s resolve against its `definitions`). Returns every error found. */\nexport function validate(schema: JsonSchema, value: unknown): SchemaError[] {\n return walk(schema, value, schema, \"\");\n}\n\nfunction walk(schema: JsonSchema, value: unknown, root: JsonSchema, path: string): SchemaError[] {\n if (schema.$ref !== undefined) return walk(resolve(schema.$ref, root), value, root, path);\n const out: SchemaError[] = [];\n if (schema.type !== undefined) {\n const types = Array.isArray(schema.type) ? schema.type : [schema.type];\n if (!types.some((t) => isType(t, value))) {\n const expected = types.join(\" | \");\n return [\n err(path, \"type\", `expected ${expected}, got ${kindOf(value)}`, expected, show(value)),\n ];\n }\n }\n if (schema.const !== undefined && !same(value, schema.const))\n out.push(err(path, \"const\", `expected ${show(schema.const)}`, show(schema.const), show(value)));\n if (schema.enum !== undefined && !schema.enum.some((e) => same(e, value))) {\n const expected = schema.enum.map(show).join(\" | \");\n out.push(err(path, \"enum\", `expected one of ${expected}`, expected, show(value)));\n }\n if (typeof value === \"number\") {\n if (schema.minimum !== undefined && value < schema.minimum)\n out.push(\n err(path, \"minimum\", `expected >= ${schema.minimum}`, `>= ${schema.minimum}`, show(value)),\n );\n if (schema.maximum !== undefined && value > schema.maximum)\n out.push(\n err(path, \"maximum\", `expected <= ${schema.maximum}`, `<= ${schema.maximum}`, show(value)),\n );\n }\n if (typeof value === \"string\") {\n if (schema.minLength !== undefined && value.length < schema.minLength)\n out.push(\n err(\n path,\n \"minLength\",\n `expected at least ${schema.minLength} characters`,\n `length >= ${schema.minLength}`,\n show(value),\n ),\n );\n if (schema.pattern !== undefined && !new RegExp(schema.pattern, \"u\").test(value))\n out.push(\n err(\n path,\n \"pattern\",\n `expected to match /${schema.pattern}/`,\n `/${schema.pattern}/`,\n show(value),\n ),\n );\n }\n if (Array.isArray(value) && schema.items !== undefined) {\n const items = schema.items;\n value.forEach((v, i) => out.push(...walk(items, v, root, `${path}/${i}`)));\n }\n if (kindOf(value) === \"object\") {\n const obj = value as Record<string, unknown>;\n for (const [key, v] of Object.entries(obj)) {\n const prop =\n schema.properties && Object.hasOwn(schema.properties, key)\n ? schema.properties[key]\n : undefined;\n const at = `${path}/${esc(key)}`;\n if (prop) out.push(...walk(prop, v, root, at));\n else if (schema.additionalProperties === false) {\n const known = Object.keys(schema.properties ?? {}).join(\", \");\n out.push(\n err(\n at,\n \"additionalProperties\",\n `unknown property ${JSON.stringify(key)}`,\n known ? `one of ${known}` : \"no properties\",\n key,\n ),\n );\n } else if (typeof schema.additionalProperties === \"object\")\n out.push(...walk(schema.additionalProperties, v, root, at));\n }\n for (const key of schema.required ?? [])\n if (!Object.hasOwn(obj, key))\n out.push(\n err(\n `${path}/${esc(key)}`,\n \"required\",\n `missing required property ${JSON.stringify(key)}`,\n \"present\",\n \"absent\",\n ),\n );\n }\n if (schema.anyOf !== undefined) {\n let best: SchemaError[] | undefined;\n const failed: SchemaError[][] = [];\n for (const branch of schema.anyOf) {\n const errors = walk(branch, value, root, path);\n if (errors.length === 0) {\n best = [];\n break;\n }\n failed.push(errors);\n if (best === undefined || rank(errors, path) < rank(best, path)) best = errors;\n }\n const merged = best && best.length > 0 ? collapse(failed) : undefined;\n if (merged) out.push(merged);\n else if (best) out.push(...best);\n }\n return out;\n}\n\n/** Throw WorkflowError(\"invalid-input\") describing the first problem when `value` does not match `schema`. */\nexport function assertValid(schema: JsonSchema, value: unknown, what: string): void {\n const errors = validate(schema, value);\n const first = errors[0];\n if (!first) return;\n const more = errors.length > 1 ? ` (+${errors.length - 1} more)` : \"\";\n fail(\n \"invalid-input\",\n `${what} does not match its schema: ${first.path} ${first.message}${more}`,\n `fix ${what} at ${first.path}: expected ${first.expected}, found ${first.found}`,\n );\n}\n","import {\n CORE_DEFINITIONS,\n KANBAN_DEFINITIONS,\n SCRUM_DEFINITIONS,\n WATERFALL_DEFINITIONS,\n} from \"./generated.ts\";\nimport type { JsonSchema, JsonSchemaDocument } from \"./types.ts\";\n\nexport const DRAFT_07 = \"http://json-schema.org/draft-07/schema#\";\n\nfunction document(name: string, definitions: Record<string, JsonSchema>): JsonSchemaDocument {\n return { $schema: DRAFT_07, $ref: `#/definitions/${name}`, definitions };\n}\n\n/** `.workflow/state.json` */\nexport const workflowStateSchema = document(\"WorkflowState\", CORE_DEFINITIONS);\n/** a role manifest (`.workflow/roles/*.json`, `exwf role add`) */\nexport const roleSchema = document(\"Role\", CORE_DEFINITIONS);\n/** `exwf add <item.json>` */\nexport const newItemSchema = document(\"NewItem\", CORE_DEFINITIONS);\n/** `exwf edit <id> <patch.json>` */\nexport const itemPatchSchema = document(\"ItemPatch\", CORE_DEFINITIONS);\n/** `exwf complete <id> <handoff.json>` */\nexport const handoffSchema = document(\"Handoff\", CORE_DEFINITIONS);\n/** `exwf init scrum --config` / the scrum-master policy.json */\nexport const scrumConfigSchema = document(\"ScrumConfig\", SCRUM_DEFINITIONS);\nexport const kanbanConfigSchema = document(\"KanbanConfig\", KANBAN_DEFINITIONS);\nexport const waterfallConfigSchema = document(\"WaterfallConfig\", WATERFALL_DEFINITIONS);\n\nexport { validate, assertValid } from \"./validate.ts\";\nexport type { JsonSchema, JsonSchemaDocument, SchemaError } from \"./types.ts\";\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b,c}from'./chunk-2FRRD6A3.mjs';function h(t){return t??new Date().toISOString()}function q(t){let e=new Set;for(let n of t.stages)e.has(n.id)&&b("config-invalid",`duplicate stage id "${n.id}"`,"give every stage a unique id"),e.add(n.id);let o={};for(let n of t.roles)c(n.id,"role id"),Object.hasOwn(o,n.id)&&b("duplicate-role",`duplicate role id "${n.id}"`,"give every role a unique id"),o[n.id]=n;let i=h(t.now);return {version:1,methodology:t.methodology,config:t.config,items:{},stages:t.stages,roles:o,iterations:[],events:[{seq:1,at:i,type:"state.created",by:"system",payload:{methodology:t.methodology}}],accounting:[],pending:[],lessons:[],agreements:[]}}function p(t,e,o,i,n){let s={seq:(t.events[t.events.length-1]?.seq??0)+1,at:h(n),type:e,by:o,payload:i};return {...t,events:[...t.events,s]}}function te(t,e){for(let o=t.events.length-1;o>=0;o--){let i=t.events[o];if(e===void 0||i.type===e)return i}}function R(t,e){return Object.hasOwn(t.roles,e)?t.roles[e]:void 0}var H=new Set(["in_progress","review","blocked"]);function re(t,e,o,i){c(e.id,"role id"),R(t,e.id)&&b("duplicate-role",`role "${e.id}" already exists`,`use a different id or retireRole("${e.id}") first`);let n={...t,roles:{...t.roles,[e.id]:e}};return p(n,"role.registered",o,{role:e.id,capabilities:e.capabilities},i)}function se(t,e,o,i){R(t,e)||b("unknown-role",`role "${e}" does not exist`,`registered roles: ${Object.keys(t.roles).join(", ")||"(none)"}`);let n=Object.values(t.items).filter(s=>s.role===e&&H.has(s.status)).map(s=>s.id);n.length&&b("role-has-open-items",`role "${e}" still holds ${n.length} open item(s)`,`complete or reassign ${n.join(", ")} before retiring the role`,{items:n});let r={...t.roles};return delete r[e],p({...t,roles:r},"role.retired",o,{role:e},i)}function x(t,e){return t.capabilities.includes(e)}function O(t,e){return Object.values(t.roles).filter(o=>x(o,e))}function y(t,e,o,i){return Object.values(t.roles).filter(n=>n.id!==i&&n.canApprove.includes(e)&&(o===void 0||n.capabilities.includes(o))).map(n=>n.id)}function ae(t,e){return O(t,"approve-gate").filter(o=>o.canApprove.includes(e))}function P(t,e,o){for(let i of e)O(t,i).length===0&&b("missing-capability",`no registered role has capability "${i}"`,`register a role whose capabilities include "${i}" (registerRole) before init`);for(let i of o){let n=O(t,i);n.length>1&&b("exclusive-capability",`capability "${i}" must belong to exactly one role but is held by ${n.map(r=>r.id).join(", ")}`,`remove "${i}" from all but one role`);}}function E(t,e){return e.length===0?[]:Object.values(t.roles).filter(o=>e.every(i=>x(o,i)))}function G(t,e,...o){if(e==="human")return true;let i=R(t,e);return !!i&&o.some(n=>x(i,n))}function le(t,e,...o){if(!G(t,e,...o)){let i=Object.values(t.roles).filter(n=>o.some(r=>x(n,r))).map(n=>n.id);b("missing-capability",`"${e}" lacks capability ${o.map(n=>`"${n}"`).join(" or ")}`,`run this as one of: human${i.map(n=>`, ${n}`).join("")}`);}}function I(t,e){let o=t.stages.find(i=>i.id===e);return o||b("unknown-stage",`stage "${e}" does not exist`,`stages are: ${t.stages.map(i=>i.id).join(" \u2192 ")}`),o}function K(t,e){let o=t.stages.findIndex(i=>i.id===e);return o<0&&I(t,e),t.stages[o+1]}function J(t,e){return t.stages[t.stages.length-1]?.id===e}function v(t,e){return {...t,items:{...t.items,[e.id]:e}}}function L(t,e,o){return v(t,o(w(t,e)))}function z(t,e,o){return L(t,e,i=>{let n={...i};for(let r of o)delete n[r];return n})}function w(t,e){let o=Object.hasOwn(t.items,e)?t.items[e]:void 0;return o||b("unknown-item",`item "${e}" does not exist`,`add it with addItem first; known items: ${Object.keys(t.items).join(", ")||"(none)"}`,{items:[e]}),o}function S(t,e,o){let i=e.filter(n=>!Object.hasOwn(t.items,n));i.length&&b("unknown-item",`${o} refers to unknown item(s) ${i.join(", ")}`,"add those items first or remove the reference",{items:i});}function ue(t,e,o,i){c(e.id,"item id"),Object.hasOwn(t.items,e.id)&&b("duplicate-item",`item "${e.id}" already exists`,"use editItem to change it, or pick a new id",{items:[e.id]});let n=t.stages[0];n||b("config-invalid","state has no stages","create the state with at least one stage");let r=e.stage??n.id;I(t,r),S(t,e.dependsOn??[],`item "${e.id}".dependsOn`),e.affects&&S(t,e.affects,`item "${e.id}".affects`),e.parent!==void 0&&S(t,[e.parent],`item "${e.id}".parent`),e.role!==void 0&&!Object.hasOwn(t.roles,e.role)&&b("unknown-role",`role "${e.role}" does not exist`,`registered roles: ${Object.keys(t.roles).join(", ")}`);let{stage:s,...a}=e,l={type:"task",acceptance:[],dependsOn:[],...a,id:e.id,title:e.title,stage:r,status:"todo",evidence:[],blockers:[],transitions:[]},c$1=v(t,l);return p(c$1,"item.added",o,{id:l.id,type:l.type,stage:l.stage,weight:l.weight??null,priority:l.priority??null,phase:l.phase??null,parent:l.parent??null},i)}function ge(t,e,o,i,n){let r=w(t,e);o.dependsOn&&S(t,o.dependsOn,`item "${e}".dependsOn`),o.affects&&S(t,o.affects,`item "${e}".affects`),o.parent!==void 0&&S(t,[o.parent],`item "${e}".parent`),o.role!==void 0&&!Object.hasOwn(t.roles,o.role)&&b("unknown-role",`role "${o.role}" does not exist`,`registered roles: ${Object.keys(t.roles).join(", ")}`);let s=Object.keys(o).filter(c=>JSON.stringify(o[c])!==JSON.stringify(r[c]));s.length===0&&b("no-op",`editItem("${e}") changes nothing`,"pass at least one field with a different value",{items:[e]});let a={...r};for(let c of s)a[c]=o[c];let l=v(t,a);return p(l,"item.edited",i,{id:e,changed:s},n)}function W(t,e,o,i,n){let r=w(t,e),s=o.stage??r.stage;I(t,s),(r.status==="done"||r.status==="dropped")&&b("invalid-transition",`item "${e}" is ${r.status} and cannot move`,"create a new item (or a change-request) instead of reopening a finished one",{items:[e]}),s===r.stage&&o.status===r.status&&b("no-op",`item "${e}" is already ${r.status} in "${s}"`,"choose a different stage or status",{items:[e]});let a=h(n),l={...r,stage:s,status:o.status,transitions:[...r.transitions,{from:{stage:r.stage,status:r.status},to:{stage:s,status:o.status},at:a,by:i}]},c=v(t,l);return p(c,"item.transition",i,{id:e,from:{stage:r.stage,status:r.status},to:{stage:s,status:o.status}},a)}function pe(t,e,o,i){let n=w(t,e),r=h(i),s={...n,evidence:[...n.evidence,{...o,at:r}]},a=v(t,s);return p(a,"item.evidence",o.by,{id:e,kind:o.kind,ref:o.ref},r)}function V(t,e,o,i,n,r){let s=w(t,e),a=h(r),l=`${e}-b${s.blockers.length+1}`,c=s.status==="blocked"?null:{from:{stage:s.stage,status:s.status},to:{stage:s.stage,status:"blocked"},at:a,by:n},g={...s,status:"blocked",blockers:[...s.blockers,{id:l,reason:o,owner:i,raisedAt:a}],transitions:c?[...s.transitions,c]:s.transitions},u=v(t,g);return p(u,"blocker.raised",n,{id:e,blocker:l,reason:o,owner:i,transition:c&&{from:c.from,to:c.to}},a)}function M(t,e){for(let o=t.transitions.length-1;o>=0;o--){let i=t.transitions[o];if(i.to.status===e)return i}}function me(t,e,o,i,n){let r=w(t,e),s=r.blockers.findIndex(k=>k.id===o&&!k.clearedAt);s<0&&b("invalid-input",`item "${e}" has no open blocker "${o}"`,`open blockers: ${r.blockers.filter(k=>!k.clearedAt).map(k=>k.id).join(", ")||"(none)"}`,{items:[e]});let a=h(n),l=r.blockers.map((k,F)=>F===s?{...k,clearedAt:a}:k),c=l.some(k=>!k.clearedAt),g=M(r,"blocked")?.from.status??"todo",u=r.stage,d=g,m=false;g==="in_progress"?(d="todo",u=M(r,"in_progress")?.from.stage??r.stage):g==="awaiting_human"&&(d=I(t,r.stage).review?"review":"todo",m=true);let{role:j,...N}=r,b$1=c?null:{from:{stage:r.stage,status:"blocked"},to:{stage:u,status:d},at:a,by:i},B={...m&&!c?N:r,blockers:l,stage:c?r.stage:u,status:c?"blocked":d,transitions:b$1?[...r.transitions,b$1]:r.transitions},D=v(t,B);return p(D,"blocker.cleared",i,{id:e,blocker:o,transition:b$1&&{from:b$1.from,to:b$1.to}},a)}function A(t,e){return z(t,e,["role"])}function _(t,e,o,i,n){let r=w(t,e),s=K(t,r.stage);if(!s)return W(t,e,{status:"done"},o,n);if(J(t,s.id))return W(t,e,{stage:s.id,status:"done"},o,n);let a=i||s.review===true?"review":"todo";return A(W(t,e,{stage:s.id,status:a},o,n),e)}function Q(t,e,o){let i=[],n=(r,s,a)=>i.push({rule:r,severity:"error",item:e.id,message:s,fix:a});for(let r of o)switch(r.kind){case "evidence":e.evidence.some(s=>s.kind===r.evidenceKind)||n("policy:evidence",`item "${e.id}" has no evidence of kind "${r.evidenceKind}"`,`attach evidence { kind: "${r.evidenceKind}" } via addEvidence or in the handoff.produced`);break;case "acceptance-written":e.acceptance.length===0&&n("policy:acceptance-written",`item "${e.id}" has no acceptance criteria`,"editItem with a non-empty acceptance[] (needs define-acceptance)");break;case "estimate-present":e.weight===void 0&&n("policy:estimate-present",`item "${e.id}" has no weight`,"editItem with a weight (story points)");break;case "no-open-blockers":{let s=e.blockers.filter(a=>!a.clearedAt);s.length&&n("policy:no-open-blockers",`item "${e.id}" has ${s.length} open blocker(s)`,`clearBlocker ${s.map(a=>a.id).join(", ")}`);break}case "dependencies-done":{let s=e.dependsOn.filter(a=>t.items[a]?.status!=="done");s.length&&n("policy:dependencies-done",`item "${e.id}" depends on unfinished ${s.join(", ")}`,`finish ${s.join(", ")} first`);break}case "custom":e.evidence.some(s=>s.kind===`policy:${r.id}`)||n(`policy:custom:${r.id}`,`item "${e.id}" has not satisfied "${r.description}"`,`attach evidence { kind: "policy:${r.id}" } when it is satisfied`);break}return i}function we(t,e,o,i){let n=Q(t,e,o);n.length&&b("policy-unmet",`item "${e.id}" cannot ${i}: ${n.length} polic${n.length===1?"y":"ies"} unmet`,n.map(r=>r.fix).join("; "),{items:[e.id]});}function U(t,e){let o=new Map(t.stages.map((n,r)=>[n.id,r])),i=o.get(e.stage);if(i!==void 0)for(let n=e.transitions.length-1;n>=0;n--){let r=e.transitions[n],s=o.get(r.from.stage);if(r.to.status==="in_progress"&&s!==void 0&&s<i)return r}}function C(t,e){let o=U(t,e);if(o)return o.by;for(let i=e.transitions.length-1;i>=0;i--){let n=e.transitions[i];if(n.to.status==="in_progress")return n.by}}function X(t,e,o,i){let n=[];for(let s of o.evidence)e.evidence.some(a=>a.kind===s)||n.push({rule:"gate:evidence",severity:"error",item:e.id,message:`gate "${o.id}" needs evidence "${s}" on item "${e.id}"`,fix:`attach evidence { kind: "${s}" } before approving`});if(n.length)return {outcome:"fail",violations:n};let r=false;for(let s of o.requires){if(s==="human"){i!=="human"&&(r=true);continue}if(!y(t,o.id,s.capability).includes(i)){n.push({rule:"gate:capability",severity:"error",item:e.id,message:`"${i}" may not approve gate "${o.id}" (needs capability "${s.capability}" and canApprove "${o.id}")`,fix:`approve as one of: ${y(t,o.id,s.capability).join(", ")||"(no role qualifies; register one)"}`});continue}let l=C(t,e);if(l!==void 0&&l===i){let c=y(t,o.id,s.capability,i);n.push({rule:"conflict-of-interest",severity:"error",item:e.id,message:`role "${i}" did the work on "${e.id}" and may not approve it`,fix:`approve as a different role: ${c.join(", ")||"(register another approver)"}`});}}return n.length?{outcome:"fail",violations:n}:r?{outcome:"human"}:{outcome:"pass"}}function be(t,e,o){let i=h(o),n=`p${t.events.filter(a=>a.type==="pending.raised").length+1}`,r={...e,id:n,raisedAt:i},s={...t,pending:[...t.pending,r]};return e.item&&w(s,e.item).status!=="awaiting_human"&&(s=W(s,e.item,{status:"awaiting_human"},"system",i)),p(s,"pending.raised","system",{id:n,kind:e.kind,item:e.item??null,gate:e.gate??null},i)}function xe(t,e,o,i,n,r,s){o!=="approve"&&o!=="reject"&&b("invalid-input",`decision must be "approve" or "reject" (got ${JSON.stringify(o)})`,"pass approve or reject");let a=t.pending.find(d=>d.id===e);a||b("unknown-pending",`no pending decision "${e}"`,`open decisions: ${t.pending.map(d=>d.id).join(", ")||"(none)"}`);let l=a.kind==="gate"&&a.item?w(t,a.item):void 0,c=l&&(t.stages.find(d=>a.gate!==void 0&&d.gate?.id===a.gate)?.gate??t.stages.find(d=>d.id===l.stage)?.gate);l&&c&&i!=="human"&&(c.requires.includes("human")?void 0:X(t,l,c,i))?.outcome!=="pass"&&b("gate-unmet",`"${i}" may not decide gate "${c.id}" on "${l.id}"`,`decide as one of: human${c.requires.flatMap(m=>m==="human"?[]:y(t,c.id,m.capability)).map(m=>`, ${m}`).join("")}`,{items:[l.id],rule:"gate"});let g=h(r),u={...t,pending:t.pending.filter(d=>d.id!==e)};if(u=p(u,"pending.decided",i,{id:e,decision:o,note:n,item:a.item??null,gate:a.gate??null},g),l){let d=l.id,m=a.gate??c?.id??null;if(o==="approve")u=_(u,d,i,false,g),u=p(u,"gate.passed",i,{item:d,gate:m},g);else {let j=c?.onFail??{action:"block"};j.action==="return-to"?u=A(W(u,d,{stage:j.stage,status:"todo"},i,g),d):u=V(u,d,`gate "${m??"?"}" rejected: ${n||"no reason given"}`,i,i,g),u=p(u,"gate.failed",i,{item:d,gate:m,note:n},g);}}return s?.afterDecide&&(u=s.afterDecide(u,a,o,i,n,g)),u}function T(t){return [{id:"separation-lost",severity:"warning",check(i,n){return n.type!=="init"&&n.type!=="role.register"?[]:E(i,t.requiredCapabilities).map(r=>({rule:"separation-lost",severity:"warning",message:`role "${r.id}" holds every required capability (${t.requiredCapabilities.join(", ")}); no separation of duties`,fix:"fine for a solo operator; otherwise split capabilities across roles"}))}},{id:"conflict-of-interest",severity:"error",check(i,n){if(n.type!=="complete")return [];let r=n.payload?.handoff;if(!r)return [];let s=r.verdict??"done";if(s!=="done"&&s!=="needs-review")return [];let a=i.items[r.item];if(!a)return [];let l=i.stages.find(g=>g.id===a.stage)?.gate;if(!l||!l.requires.some(g=>g!=="human"))return [];if(C(i,a)!==r.role)return [];let c=y(i,l.id,void 0,r.role);return [{rule:"conflict-of-interest",severity:"error",item:a.id,message:`role "${r.role}" authored "${a.id}" and may not pass gate "${l.id}" on it`,fix:`hand the gate to another approver: ${c.join(", ")||"(register one)"}`}]}}]}function Y(t,e,o){let i=[];for(let n of [...T(e),...e.rules])i.push(...n.check(t,o));return i}function Z(t,e,o,i){let n=Y(t,e,o),r=n.filter(s=>s.severity==="error");return r.length&&b("rule-violation",`${o.type} violates ${r.map(s=>s.rule).join(", ")}: ${r.map(s=>s.message).join("; ")}`,r.map(s=>s.fix).join("; "),{rule:r[0].rule,items:r.map(s=>s.item).filter(s=>!!s)}),{state:i(t),warnings:n.filter(s=>s.severity==="warning")}}function Ee(t){let e=t.methodology,o=e.validateConfig(t.config),i=t.stages??e.defaultStages(o),n=t.roles??e.defaultRoles(o),r=t.now!==void 0?{methodology:e.name,config:o,stages:i,roles:n,now:t.now}:{methodology:e.name,config:o,stages:i,roles:n},s=q(r);return P(s,e.requiredCapabilities,e.exclusiveCapabilities),Z(s,e,{type:"init",by:t.by??"system"},a=>a)}export{me as A,A as B,_ as C,Q as D,we as E,U as F,C as G,X as H,be as I,xe as J,T as K,Y as L,Z as M,Ee as N,h as a,q as b,p as c,te as d,R as e,re as f,se as g,x as h,O as i,y as j,ae as k,P as l,E as m,G as n,le as o,I as p,K as q,J as r,L as s,z as t,w as u,ue as v,ge as w,W as x,pe as y,V as z};//# sourceMappingURL=chunk-SHAPFMVP.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-SHAPFMVP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/state.ts","../src/roles.ts","../src/items.ts","../src/policies.ts","../src/gates.ts","../src/rules.ts","../src/methodology.ts"],"names":["nowOf","now","createState","input","seenStages","st","fail","roles","r","assertId","at","appendEvent","state","type","by","payload","ev","lastEvent","i","roleOf","id","OPEN","registerRole","role","next","retireRole","roleId","open","hasCapability","cap","rolesWith","approverIds","gateId","except","approversFor","requireCapabilities","required","exclusive","holders","separationLost","c","canDo","caps","requireCap","h","stageOf","stageId","s","nextStageOf","idx","isTerminalStage","putItem","item","patchItem","fn","getItem","stripItemFields","keys","copy","k","it","assertKnownItems","ids","what","missing","d","addItem","firstStage","_s","rest","editItem","patch","changed","updated","moveItem","to","toStage","addEvidence","evidence","raiseBlocker","reason","owner","blockerId","t","lastTransitionTo","status","clearBlocker","b","blockers","stillBlocked","prev","toStatus","dropRole","_r","noRole","clearRole","itemId","advanceItem","wantsReview","evaluatePolicies","policies","out","v","rule","message","fix","p","e","notDone","assertPolicies","context","unmet","u","lastDispatchBefore","order","here","from","authorOf","before","checkGate","gate","violations","kind","needsHuman","req","author","others","raisePending","pending","entry","decide","pendingId","decision","note","methodology","item0","q","onFail","coreRulesFor","action","handoff","verdict","validateAction","applyAction","reduce","errors","x","init","m","config","stages","stateInput"],"mappings":"uCAGO,SAASA,CAAAA,CAAMC,EAAsB,CAC1C,OAAOA,GAAO,IAAI,IAAA,GAAO,WAAA,EAC3B,CAUO,SAASC,CAAAA,CAAYC,EAAwC,CAClE,IAAMC,EAAa,IAAI,GAAA,CACvB,IAAA,IAAWC,CAAAA,IAAMF,CAAAA,CAAM,MAAA,CACjBC,EAAW,GAAA,CAAIC,CAAAA,CAAG,EAAE,CAAA,EACtBC,CAAAA,CAAK,iBAAkB,CAAA,oBAAA,EAAuBD,CAAAA,CAAG,EAAE,CAAA,CAAA,CAAA,CAAK,8BAA8B,CAAA,CACxFD,EAAW,GAAA,CAAIC,CAAAA,CAAG,EAAE,CAAA,CAEtB,IAAME,EAA8B,EAAC,CACrC,IAAA,IAAWC,CAAAA,IAAKL,CAAAA,CAAM,KAAA,CACpBM,EAASD,CAAAA,CAAE,EAAA,CAAI,SAAS,CAAA,CACpB,MAAA,CAAO,OAAOD,CAAAA,CAAOC,CAAAA,CAAE,EAAE,CAAA,EAC3BF,CAAAA,CAAK,iBAAkB,CAAA,mBAAA,EAAsBE,CAAAA,CAAE,EAAE,CAAA,CAAA,CAAA,CAAK,6BAA6B,EACrFD,CAAAA,CAAMC,CAAAA,CAAE,EAAE,CAAA,CAAIA,CAAAA,CAEhB,IAAME,EAAKV,CAAAA,CAAMG,CAAAA,CAAM,GAAG,CAAA,CAC1B,OAAO,CACL,OAAA,CAAS,CAAA,CACT,WAAA,CAAaA,CAAAA,CAAM,WAAA,CACnB,MAAA,CAAQA,EAAM,MAAA,CACd,KAAA,CAAO,EAAC,CACR,MAAA,CAAQA,EAAM,MAAA,CACd,KAAA,CAAAI,CAAAA,CACA,UAAA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AClG","file":"chunk-SHAPFMVP.mjs","sourcesContent":["import { assertId, fail } from \"./errors.ts\";\nimport type { Event, MethodologyName, Role, Stage, WorkflowState } from \"./types.ts\";\n\nexport function nowOf(now?: string): string {\n return now ?? new Date().toISOString();\n}\n\nexport interface CreateStateInput {\n methodology: MethodologyName;\n config: unknown;\n stages: Stage[];\n roles: Role[];\n now?: string;\n}\n\nexport function createState(input: CreateStateInput): WorkflowState {\n const seenStages = new Set<string>();\n for (const st of input.stages) {\n if (seenStages.has(st.id))\n fail(\"config-invalid\", `duplicate stage id \"${st.id}\"`, \"give every stage a unique id\");\n seenStages.add(st.id);\n }\n const roles: Record<string, Role> = {};\n for (const r of input.roles) {\n assertId(r.id, \"role id\");\n if (Object.hasOwn(roles, r.id))\n fail(\"duplicate-role\", `duplicate role id \"${r.id}\"`, \"give every role a unique id\");\n roles[r.id] = r;\n }\n const at = nowOf(input.now);\n return {\n version: 1,\n methodology: input.methodology,\n config: input.config,\n items: {},\n stages: input.stages,\n roles,\n iterations: [],\n events: [\n {\n seq: 1,\n at,\n type: \"state.created\",\n by: \"system\",\n payload: { methodology: input.methodology },\n },\n ],\n accounting: [],\n pending: [],\n lessons: [],\n agreements: [],\n };\n}\n\nexport function appendEvent(\n state: WorkflowState,\n type: string,\n by: string,\n payload: unknown,\n now?: string,\n): WorkflowState {\n const last = state.events[state.events.length - 1];\n const ev: Event = { seq: (last?.seq ?? 0) + 1, at: nowOf(now), type, by, payload };\n return { ...state, events: [...state.events, ev] };\n}\n\nexport function lastEvent(state: WorkflowState, type?: string): Event | undefined {\n for (let i = state.events.length - 1; i >= 0; i--) {\n const ev = state.events[i]!;\n if (type === undefined || ev.type === type) return ev;\n }\n return undefined;\n}\n","import { assertId, fail } from \"./errors.ts\";\nimport { appendEvent } from \"./state.ts\";\nimport type { Capability, Role, WorkflowState } from \"./types.ts\";\n\n/** Own-property role lookup (ids such as \"constructor\" never hit the prototype). */\nexport function roleOf(state: WorkflowState, id: string): Role | undefined {\n return Object.hasOwn(state.roles, id) ? state.roles[id] : undefined;\n}\n\nconst OPEN: ReadonlySet<string> = new Set([\"in_progress\", \"review\", \"blocked\"]);\n\nexport function registerRole(\n state: WorkflowState,\n role: Role,\n by: string,\n now?: string,\n): WorkflowState {\n assertId(role.id, \"role id\");\n if (roleOf(state, role.id))\n fail(\n \"duplicate-role\",\n `role \"${role.id}\" already exists`,\n `use a different id or retireRole(\"${role.id}\") first`,\n );\n const next = { ...state, roles: { ...state.roles, [role.id]: role } };\n return appendEvent(\n next,\n \"role.registered\",\n by,\n { role: role.id, capabilities: role.capabilities },\n now,\n );\n}\n\nexport function retireRole(\n state: WorkflowState,\n roleId: string,\n by: string,\n now?: string,\n): WorkflowState {\n if (!roleOf(state, roleId))\n fail(\n \"unknown-role\",\n `role \"${roleId}\" does not exist`,\n `registered roles: ${Object.keys(state.roles).join(\", \") || \"(none)\"}`,\n );\n const open = Object.values(state.items)\n .filter((i) => i.role === roleId && OPEN.has(i.status))\n .map((i) => i.id);\n if (open.length)\n fail(\n \"role-has-open-items\",\n `role \"${roleId}\" still holds ${open.length} open item(s)`,\n `complete or reassign ${open.join(\", \")} before retiring the role`,\n { items: open },\n );\n const roles = { ...state.roles };\n delete roles[roleId];\n return appendEvent({ ...state, roles }, \"role.retired\", by, { role: roleId }, now);\n}\n\nexport function hasCapability(role: Role, cap: Capability): boolean {\n return role.capabilities.includes(cap);\n}\n\nexport function rolesWith(state: WorkflowState, cap: Capability): Role[] {\n return Object.values(state.roles).filter((r) => hasCapability(r, cap));\n}\n\n/** Ids of roles that may approve `gateId`, optionally holding `cap` and excluding one id. */\nexport function approverIds(\n state: WorkflowState,\n gateId: string,\n cap?: string,\n except?: string,\n): string[] {\n return Object.values(state.roles)\n .filter(\n (r) =>\n r.id !== except &&\n r.canApprove.includes(gateId) &&\n (cap === undefined || (r.capabilities as readonly string[]).includes(cap)),\n )\n .map((r) => r.id);\n}\n\nexport function approversFor(state: WorkflowState, gateId: string): Role[] {\n return rolesWith(state, \"approve-gate\").filter((r) => r.canApprove.includes(gateId));\n}\n\nexport function requireCapabilities(\n state: WorkflowState,\n required: Capability[],\n exclusive: Capability[],\n): void {\n for (const cap of required) {\n if (rolesWith(state, cap).length === 0) {\n fail(\n \"missing-capability\",\n `no registered role has capability \"${cap}\"`,\n `register a role whose capabilities include \"${cap}\" (registerRole) before init`,\n );\n }\n }\n for (const cap of exclusive) {\n const holders = rolesWith(state, cap);\n if (holders.length > 1) {\n fail(\n \"exclusive-capability\",\n `capability \"${cap}\" must belong to exactly one role but is held by ${holders.map((r) => r.id).join(\", \")}`,\n `remove \"${cap}\" from all but one role`,\n );\n }\n }\n}\n\nexport function separationLost(state: WorkflowState, required: Capability[]): Role[] {\n if (required.length === 0) return [];\n return Object.values(state.roles).filter((r) => required.every((c) => hasCapability(r, c)));\n}\n\n/** `human` may do anything; a role must hold at least one of `caps`; unknown ids may do nothing. */\nexport function canDo(state: WorkflowState, by: string, ...caps: Capability[]): boolean {\n if (by === \"human\") return true;\n const role = roleOf(state, by);\n return !!role && caps.some((c) => hasCapability(role, c));\n}\n\nexport function requireCap(state: WorkflowState, by: string, ...caps: Capability[]): void {\n if (!canDo(state, by, ...caps)) {\n const holders = Object.values(state.roles)\n .filter((r) => caps.some((c) => hasCapability(r, c)))\n .map((r) => r.id);\n fail(\n \"missing-capability\",\n `\"${by}\" lacks capability ${caps.map((c) => `\"${c}\"`).join(\" or \")}`,\n `run this as one of: human${holders.map((h) => `, ${h}`).join(\"\")}`,\n );\n }\n}\n","import { assertId, fail } from \"./errors.ts\";\nimport type { ItemPatch } from \"./types.ts\";\n\nexport { assertId };\nimport { appendEvent, nowOf } from \"./state.ts\";\nimport type {\n Evidence,\n ItemStatus,\n NewItem,\n Stage,\n Transition,\n WorkItem,\n WorkflowState,\n} from \"./types.ts\";\n\nexport function stageOf(state: WorkflowState, stageId: string): Stage {\n const st = state.stages.find((s) => s.id === stageId);\n if (!st)\n fail(\n \"unknown-stage\",\n `stage \"${stageId}\" does not exist`,\n `stages are: ${state.stages.map((s) => s.id).join(\" → \")}`,\n );\n return st;\n}\n\nexport function nextStageOf(state: WorkflowState, stageId: string): Stage | undefined {\n const idx = state.stages.findIndex((s) => s.id === stageId);\n if (idx < 0) stageOf(state, stageId);\n return state.stages[idx + 1];\n}\n\nexport function isTerminalStage(state: WorkflowState, stageId: string): boolean {\n return state.stages[state.stages.length - 1]?.id === stageId;\n}\n\nfunction putItem(state: WorkflowState, item: WorkItem): WorkflowState {\n return { ...state, items: { ...state.items, [item.id]: item } };\n}\n\n/** Replace one item with `fn(item)`; no event. */\nexport function patchItem(\n state: WorkflowState,\n id: string,\n fn: (item: WorkItem) => WorkItem,\n): WorkflowState {\n return putItem(state, fn(getItem(state, id)));\n}\n\n/** Drop optional fields (iteration, role, ...) from one item; no event. */\nexport function stripItemFields(\n state: WorkflowState,\n id: string,\n keys: Array<\"iteration\" | \"role\">,\n): WorkflowState {\n return patchItem(state, id, (item) => {\n const copy = { ...item };\n for (const k of keys) delete copy[k];\n return copy;\n });\n}\n\nexport function getItem(state: WorkflowState, id: string): WorkItem {\n const it = Object.hasOwn(state.items, id) ? state.items[id] : undefined;\n if (!it)\n fail(\n \"unknown-item\",\n `item \"${id}\" does not exist`,\n `add it with addItem first; known items: ${Object.keys(state.items).join(\", \") || \"(none)\"}`,\n { items: [id] },\n );\n return it;\n}\n\nfunction assertKnownItems(state: WorkflowState, ids: string[], what: string): void {\n const missing = ids.filter((d) => !Object.hasOwn(state.items, d));\n if (missing.length)\n fail(\n \"unknown-item\",\n `${what} refers to unknown item(s) ${missing.join(\", \")}`,\n \"add those items first or remove the reference\",\n { items: missing },\n );\n}\n\nexport function addItem(\n state: WorkflowState,\n input: NewItem,\n by: string,\n now?: string,\n): WorkflowState {\n assertId(input.id, \"item id\");\n if (Object.hasOwn(state.items, input.id))\n fail(\n \"duplicate-item\",\n `item \"${input.id}\" already exists`,\n \"use editItem to change it, or pick a new id\",\n { items: [input.id] },\n );\n const firstStage = state.stages[0];\n if (!firstStage)\n fail(\"config-invalid\", \"state has no stages\", \"create the state with at least one stage\");\n const stageId = input.stage ?? firstStage.id;\n stageOf(state, stageId);\n assertKnownItems(state, input.dependsOn ?? [], `item \"${input.id}\".dependsOn`);\n if (input.affects) assertKnownItems(state, input.affects, `item \"${input.id}\".affects`);\n if (input.parent !== undefined)\n assertKnownItems(state, [input.parent], `item \"${input.id}\".parent`);\n if (input.role !== undefined && !Object.hasOwn(state.roles, input.role))\n fail(\n \"unknown-role\",\n `role \"${input.role}\" does not exist`,\n `registered roles: ${Object.keys(state.roles).join(\", \")}`,\n );\n\n const { stage: _s, ...rest } = input;\n const item: WorkItem = {\n type: \"task\",\n acceptance: [],\n dependsOn: [],\n ...rest,\n id: input.id,\n title: input.title,\n stage: stageId,\n status: \"todo\",\n evidence: [],\n blockers: [],\n transitions: [],\n };\n const next = putItem(state, item);\n return appendEvent(\n next,\n \"item.added\",\n by,\n {\n id: item.id,\n type: item.type,\n stage: item.stage,\n weight: item.weight ?? null,\n priority: item.priority ?? null,\n phase: item.phase ?? null,\n parent: item.parent ?? null,\n },\n now,\n );\n}\n\nexport type { ItemPatch } from \"./types.ts\";\n\nexport function editItem(\n state: WorkflowState,\n id: string,\n patch: ItemPatch,\n by: string,\n now?: string,\n): WorkflowState {\n const item = getItem(state, id);\n if (patch.dependsOn) assertKnownItems(state, patch.dependsOn, `item \"${id}\".dependsOn`);\n if (patch.affects) assertKnownItems(state, patch.affects, `item \"${id}\".affects`);\n if (patch.parent !== undefined) assertKnownItems(state, [patch.parent], `item \"${id}\".parent`);\n if (patch.role !== undefined && !Object.hasOwn(state.roles, patch.role))\n fail(\n \"unknown-role\",\n `role \"${patch.role}\" does not exist`,\n `registered roles: ${Object.keys(state.roles).join(\", \")}`,\n );\n const changed = (Object.keys(patch) as Array<keyof ItemPatch>).filter(\n (k) => JSON.stringify(patch[k]) !== JSON.stringify(item[k]),\n );\n if (changed.length === 0)\n fail(\n \"no-op\",\n `editItem(\"${id}\") changes nothing`,\n \"pass at least one field with a different value\",\n { items: [id] },\n );\n const updated: WorkItem = { ...item };\n for (const k of changed) (updated as unknown as Record<string, unknown>)[k] = patch[k];\n const next = putItem(state, updated);\n return appendEvent(next, \"item.edited\", by, { id, changed }, now);\n}\n\nexport function moveItem(\n state: WorkflowState,\n id: string,\n to: { stage?: string; status: ItemStatus },\n by: string,\n now?: string,\n): WorkflowState {\n const item = getItem(state, id);\n const toStage = to.stage ?? item.stage;\n stageOf(state, toStage);\n if (item.status === \"done\" || item.status === \"dropped\") {\n fail(\n \"invalid-transition\",\n `item \"${id}\" is ${item.status} and cannot move`,\n \"create a new item (or a change-request) instead of reopening a finished one\",\n { items: [id] },\n );\n }\n if (toStage === item.stage && to.status === item.status)\n fail(\n \"no-op\",\n `item \"${id}\" is already ${item.status} in \"${toStage}\"`,\n \"choose a different stage or status\",\n { items: [id] },\n );\n const at = nowOf(now);\n const updated: WorkItem = {\n ...item,\n stage: toStage,\n status: to.status,\n transitions: [\n ...item.transitions,\n {\n from: { stage: item.stage, status: item.status },\n to: { stage: toStage, status: to.status },\n at,\n by,\n },\n ],\n };\n const next = putItem(state, updated);\n return appendEvent(\n next,\n \"item.transition\",\n by,\n {\n id,\n from: { stage: item.stage, status: item.status },\n to: { stage: toStage, status: to.status },\n },\n at,\n );\n}\n\nexport function addEvidence(\n state: WorkflowState,\n id: string,\n evidence: Omit<Evidence, \"at\">,\n now?: string,\n): WorkflowState {\n const item = getItem(state, id);\n const at = nowOf(now);\n const updated: WorkItem = { ...item, evidence: [...item.evidence, { ...evidence, at }] };\n const next = putItem(state, updated);\n return appendEvent(\n next,\n \"item.evidence\",\n evidence.by,\n { id, kind: evidence.kind, ref: evidence.ref },\n at,\n );\n}\n\nexport function raiseBlocker(\n state: WorkflowState,\n id: string,\n reason: string,\n owner: string,\n by: string,\n now?: string,\n): WorkflowState {\n const item = getItem(state, id);\n const at = nowOf(now);\n const blockerId = `${id}-b${item.blockers.length + 1}`;\n const t: Transition | null =\n item.status === \"blocked\"\n ? null\n : {\n from: { stage: item.stage, status: item.status },\n to: { stage: item.stage, status: \"blocked\" },\n at,\n by,\n };\n const updated: WorkItem = {\n ...item,\n status: \"blocked\",\n blockers: [...item.blockers, { id: blockerId, reason, owner, raisedAt: at }],\n transitions: t ? [...item.transitions, t] : item.transitions,\n };\n const next = putItem(state, updated);\n return appendEvent(\n next,\n \"blocker.raised\",\n by,\n { id, blocker: blockerId, reason, owner, transition: t && { from: t.from, to: t.to } },\n at,\n );\n}\n\nfunction lastTransitionTo(item: WorkItem, status: ItemStatus): Transition | undefined {\n for (let i = item.transitions.length - 1; i >= 0; i--) {\n const t = item.transitions[i]!;\n if (t.to.status === status) return t;\n }\n return undefined;\n}\n\nexport function clearBlocker(\n state: WorkflowState,\n id: string,\n blockerId: string,\n by: string,\n now?: string,\n): WorkflowState {\n const item = getItem(state, id);\n const idx = item.blockers.findIndex((b) => b.id === blockerId && !b.clearedAt);\n if (idx < 0)\n fail(\n \"invalid-input\",\n `item \"${id}\" has no open blocker \"${blockerId}\"`,\n `open blockers: ${\n item.blockers\n .filter((b) => !b.clearedAt)\n .map((b) => b.id)\n .join(\", \") || \"(none)\"\n }`,\n { items: [id] },\n );\n const at = nowOf(now);\n const blockers = item.blockers.map((b, i) => (i === idx ? { ...b, clearedAt: at } : b));\n const stillBlocked = blockers.some((b) => !b.clearedAt);\n const prev = lastTransitionTo(item, \"blocked\")?.from.status ?? \"todo\";\n let toStage = item.stage;\n let toStatus: ItemStatus = prev;\n let dropRole = false;\n if (prev === \"in_progress\") {\n toStatus = \"todo\";\n toStage = lastTransitionTo(item, \"in_progress\")?.from.stage ?? item.stage;\n } else if (prev === \"awaiting_human\") {\n // a rejected human gate: the work is re-dispatched in the current stage\n toStatus = stageOf(state, item.stage).review ? \"review\" : \"todo\";\n dropRole = true;\n }\n const { role: _r, ...noRole } = item;\n const t: Transition | null = stillBlocked\n ? null\n : {\n from: { stage: item.stage, status: \"blocked\" },\n to: { stage: toStage, status: toStatus },\n at,\n by,\n };\n const updated: WorkItem = {\n ...(dropRole && !stillBlocked ? (noRole as WorkItem) : item),\n blockers,\n stage: stillBlocked ? item.stage : toStage,\n status: stillBlocked ? \"blocked\" : toStatus,\n transitions: t ? [...item.transitions, t] : item.transitions,\n };\n const next = putItem(state, updated);\n return appendEvent(\n next,\n \"blocker.cleared\",\n by,\n { id, blocker: blockerId, transition: t && { from: t.from, to: t.to } },\n at,\n );\n}\n\n/** Entering a new stage is a new assignment: the role that finished the previous stage is cleared so the planner picks the right one (a reviewer, not the author). */\nexport function clearRole(state: WorkflowState, itemId: string): WorkflowState {\n return stripItemFields(state, itemId, [\"role\"]);\n}\n\n/** Move an item to the next stage (done at the end, review/todo otherwise) and clear its role. */\nexport function advanceItem(\n state: WorkflowState,\n itemId: string,\n by: string,\n wantsReview: boolean,\n now: string,\n): WorkflowState {\n const item = getItem(state, itemId);\n const to = nextStageOf(state, item.stage);\n if (!to) return moveItem(state, itemId, { status: \"done\" }, by, now);\n if (isTerminalStage(state, to.id))\n return moveItem(state, itemId, { stage: to.id, status: \"done\" }, by, now);\n const status = wantsReview || to.review === true ? \"review\" : \"todo\";\n return clearRole(moveItem(state, itemId, { stage: to.id, status }, by, now), itemId);\n}\n","import { fail } from \"./errors.ts\";\nimport type { Policy, Violation, WorkItem, WorkflowState } from \"./types.ts\";\n\nexport function evaluatePolicies(\n state: WorkflowState,\n item: WorkItem,\n policies: Policy[],\n): Violation[] {\n const out: Violation[] = [];\n const v = (rule: string, message: string, fix: string) =>\n out.push({ rule, severity: \"error\", item: item.id, message, fix });\n for (const p of policies) {\n switch (p.kind) {\n case \"evidence\":\n if (!item.evidence.some((e) => e.kind === p.evidenceKind))\n v(\n \"policy:evidence\",\n `item \"${item.id}\" has no evidence of kind \"${p.evidenceKind}\"`,\n `attach evidence { kind: \"${p.evidenceKind}\" } via addEvidence or in the handoff.produced`,\n );\n break;\n case \"acceptance-written\":\n if (item.acceptance.length === 0)\n v(\n \"policy:acceptance-written\",\n `item \"${item.id}\" has no acceptance criteria`,\n \"editItem with a non-empty acceptance[] (needs define-acceptance)\",\n );\n break;\n case \"estimate-present\":\n if (item.weight === undefined)\n v(\n \"policy:estimate-present\",\n `item \"${item.id}\" has no weight`,\n \"editItem with a weight (story points)\",\n );\n break;\n case \"no-open-blockers\": {\n const open = item.blockers.filter((b) => !b.clearedAt);\n if (open.length)\n v(\n \"policy:no-open-blockers\",\n `item \"${item.id}\" has ${open.length} open blocker(s)`,\n `clearBlocker ${open.map((b) => b.id).join(\", \")}`,\n );\n break;\n }\n case \"dependencies-done\": {\n const notDone = item.dependsOn.filter((d) => state.items[d]?.status !== \"done\");\n if (notDone.length)\n v(\n \"policy:dependencies-done\",\n `item \"${item.id}\" depends on unfinished ${notDone.join(\", \")}`,\n `finish ${notDone.join(\", \")} first`,\n );\n break;\n }\n case \"custom\":\n if (!item.evidence.some((e) => e.kind === `policy:${p.id}`))\n v(\n `policy:custom:${p.id}`,\n `item \"${item.id}\" has not satisfied \"${p.description}\"`,\n `attach evidence { kind: \"policy:${p.id}\" } when it is satisfied`,\n );\n break;\n }\n }\n return out;\n}\n\nexport function assertPolicies(\n state: WorkflowState,\n item: WorkItem,\n policies: Policy[],\n context: string,\n): void {\n const unmet = evaluatePolicies(state, item, policies);\n if (unmet.length) {\n fail(\n \"policy-unmet\",\n `item \"${item.id}\" cannot ${context}: ${unmet.length} polic${unmet.length === 1 ? \"y\" : \"ies\"} unmet`,\n unmet.map((u) => u.fix).join(\"; \"),\n { items: [item.id] },\n );\n }\n}\n","import { fail } from \"./errors.ts\";\nimport { advanceItem, clearRole, getItem, moveItem, raiseBlocker } from \"./items.ts\";\nimport { approverIds } from \"./roles.ts\";\nimport { appendEvent, nowOf } from \"./state.ts\";\nimport type {\n Gate,\n Methodology,\n PendingHuman,\n Transition,\n Violation,\n WorkItem,\n WorkflowState,\n} from \"./types.ts\";\n\nexport type GateResult =\n | { outcome: \"pass\" }\n | { outcome: \"human\" }\n | { outcome: \"fail\"; violations: Violation[] };\n\n/** 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). */\nexport function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined {\n const order = new Map(state.stages.map((s, i) => [s.id, i] as const));\n const here = order.get(item.stage);\n if (here === undefined) return undefined;\n for (let i = item.transitions.length - 1; i >= 0; i--) {\n const t = item.transitions[i]!;\n const from = order.get(t.from.stage);\n if (t.to.status === \"in_progress\" && from !== undefined && from < here) return t;\n }\n return undefined;\n}\n\n/** 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. */\nexport function authorOf(state: WorkflowState, item: WorkItem): string | undefined {\n const before = lastDispatchBefore(state, item);\n if (before) return before.by;\n for (let i = item.transitions.length - 1; i >= 0; i--) {\n const t = item.transitions[i]!;\n if (t.to.status === \"in_progress\") return t.by;\n }\n return undefined;\n}\n\nexport function checkGate(\n state: WorkflowState,\n item: WorkItem,\n gate: Gate,\n by: string,\n): GateResult {\n const violations: Violation[] = [];\n for (const kind of gate.evidence) {\n if (!item.evidence.some((e) => e.kind === kind)) {\n violations.push({\n rule: \"gate:evidence\",\n severity: \"error\",\n item: item.id,\n message: `gate \"${gate.id}\" needs evidence \"${kind}\" on item \"${item.id}\"`,\n fix: `attach evidence { kind: \"${kind}\" } before approving`,\n });\n }\n }\n if (violations.length) return { outcome: \"fail\", violations };\n\n let needsHuman = false;\n for (const req of gate.requires) {\n if (req === \"human\") {\n if (by !== \"human\") needsHuman = true;\n continue;\n }\n const ok = approverIds(state, gate.id, req.capability).includes(by);\n if (!ok) {\n violations.push({\n rule: \"gate:capability\",\n severity: \"error\",\n item: item.id,\n message: `\"${by}\" may not approve gate \"${gate.id}\" (needs capability \"${req.capability}\" and canApprove \"${gate.id}\")`,\n fix: `approve as one of: ${approverIds(state, gate.id, req.capability).join(\", \") || \"(no role qualifies; register one)\"}`,\n });\n continue;\n }\n const author = authorOf(state, item);\n if (author !== undefined && author === by) {\n const others = approverIds(state, gate.id, req.capability, by);\n violations.push({\n rule: \"conflict-of-interest\",\n severity: \"error\",\n item: item.id,\n message: `role \"${by}\" did the work on \"${item.id}\" and may not approve it`,\n fix: `approve as a different role: ${others.join(\", \") || \"(register another approver)\"}`,\n });\n }\n }\n if (violations.length) return { outcome: \"fail\", violations };\n return needsHuman ? { outcome: \"human\" } : { outcome: \"pass\" };\n}\n\nexport function raisePending(\n state: WorkflowState,\n pending: Omit<PendingHuman, \"id\" | \"raisedAt\">,\n now?: string,\n): WorkflowState {\n const at = nowOf(now);\n const id = `p${state.events.filter((e) => e.type === \"pending.raised\").length + 1}`;\n const entry: PendingHuman = { ...pending, id, raisedAt: at };\n let next: WorkflowState = { ...state, pending: [...state.pending, entry] };\n if (pending.item) {\n const item = getItem(next, pending.item);\n if (item.status !== \"awaiting_human\")\n next = moveItem(next, pending.item, { status: \"awaiting_human\" }, \"system\", at);\n }\n return appendEvent(\n next,\n \"pending.raised\",\n \"system\",\n { id, kind: pending.kind, item: pending.item ?? null, gate: pending.gate ?? null },\n at,\n );\n}\n\nexport function decide(\n state: WorkflowState,\n pendingId: string,\n decision: \"approve\" | \"reject\",\n by: string,\n note: string,\n now?: string,\n methodology?: Methodology,\n): WorkflowState {\n if (decision !== \"approve\" && decision !== \"reject\")\n fail(\n \"invalid-input\",\n `decision must be \"approve\" or \"reject\" (got ${JSON.stringify(decision)})`,\n \"pass approve or reject\",\n );\n const entry = state.pending.find((p) => p.id === pendingId);\n if (!entry)\n fail(\n \"unknown-pending\",\n `no pending decision \"${pendingId}\"`,\n `open decisions: ${state.pending.map((p) => p.id).join(\", \") || \"(none)\"}`,\n );\n const item0 = entry.kind === \"gate\" && entry.item ? getItem(state, entry.item) : undefined;\n const gate =\n item0 &&\n (state.stages.find((s) => entry.gate !== undefined && s.gate?.id === entry.gate)?.gate ??\n state.stages.find((s) => s.id === item0.stage)?.gate);\n if (item0 && gate && by !== \"human\") {\n const res = gate.requires.includes(\"human\") ? undefined : checkGate(state, item0, gate, by);\n if (res?.outcome !== \"pass\")\n fail(\n \"gate-unmet\",\n `\"${by}\" may not decide gate \"${gate.id}\" on \"${item0.id}\"`,\n `decide as one of: human${gate.requires\n .flatMap((q) => (q === \"human\" ? [] : approverIds(state, gate.id, q.capability)))\n .map((r) => `, ${r}`)\n .join(\"\")}`,\n { items: [item0.id], rule: \"gate\" },\n );\n }\n const at = nowOf(now);\n let next: WorkflowState = { ...state, pending: state.pending.filter((p) => p.id !== pendingId) };\n next = appendEvent(\n next,\n \"pending.decided\",\n by,\n { id: pendingId, decision, note, item: entry.item ?? null, gate: entry.gate ?? null },\n at,\n );\n if (item0) {\n const id = item0.id;\n const gateId = entry.gate ?? gate?.id ?? null;\n if (decision === \"approve\") {\n next = advanceItem(next, id, by, false, at);\n next = appendEvent(next, \"gate.passed\", by, { item: id, gate: gateId }, at);\n } else {\n const onFail = gate?.onFail ?? { action: \"block\" as const };\n if (onFail.action === \"return-to\")\n next = clearRole(moveItem(next, id, { stage: onFail.stage, status: \"todo\" }, by, at), id);\n else\n next = raiseBlocker(\n next,\n id,\n `gate \"${gateId ?? \"?\"}\" rejected: ${note || \"no reason given\"}`,\n by,\n by,\n at,\n );\n next = appendEvent(next, \"gate.failed\", by, { item: id, gate: gateId, note }, at);\n }\n }\n if (methodology?.afterDecide) next = methodology.afterDecide(next, entry, decision, by, note, at);\n return next;\n}\n","import { authorOf } from \"./gates.ts\";\nimport { approverIds, separationLost } from \"./roles.ts\";\nimport type { Action, Handoff, Methodology, Rule, Violation } from \"./types.ts\";\n\nexport function coreRulesFor(methodology: Pick<Methodology, \"requiredCapabilities\">): Rule[] {\n const separation: Rule = {\n id: \"separation-lost\",\n severity: \"warning\",\n check(state, action: Action): Violation[] {\n if (action.type !== \"init\" && action.type !== \"role.register\") return [];\n return separationLost(state, methodology.requiredCapabilities).map((r) => ({\n rule: \"separation-lost\",\n severity: \"warning\" as const,\n message: `role \"${r.id}\" holds every required capability (${methodology.requiredCapabilities.join(\", \")}); no separation of duties`,\n fix: \"fine for a solo operator; otherwise split capabilities across roles\",\n }));\n },\n };\n const coi: Rule = {\n id: \"conflict-of-interest\",\n severity: \"error\",\n check(state, action: Action): Violation[] {\n if (action.type !== \"complete\") return [];\n const handoff = (action.payload as { handoff?: Handoff } | undefined)?.handoff;\n if (!handoff) return [];\n const verdict = handoff.verdict ?? \"done\";\n if (verdict !== \"done\" && verdict !== \"needs-review\") return [];\n const item = state.items[handoff.item];\n if (!item) return [];\n const gate = state.stages.find((s) => s.id === item.stage)?.gate;\n if (!gate || !gate.requires.some((q) => q !== \"human\")) return [];\n if (authorOf(state, item) !== handoff.role) return [];\n const others = approverIds(state, gate.id, undefined, handoff.role);\n return [\n {\n rule: \"conflict-of-interest\",\n severity: \"error\",\n item: item.id,\n message: `role \"${handoff.role}\" authored \"${item.id}\" and may not pass gate \"${gate.id}\" on it`,\n fix: `hand the gate to another approver: ${others.join(\", \") || \"(register one)\"}`,\n },\n ];\n },\n };\n return [separation, coi];\n}\n","import { fail } from \"./errors.ts\";\nimport { requireCapabilities } from \"./roles.ts\";\nimport { coreRulesFor } from \"./rules.ts\";\nimport { createState } from \"./state.ts\";\nimport type {\n Action,\n ApplyResult,\n Methodology,\n Role,\n Stage,\n Violation,\n WorkflowState,\n} from \"./types.ts\";\n\nexport function validateAction(\n state: WorkflowState,\n methodology: Methodology,\n action: Action,\n): Violation[] {\n const out: Violation[] = [];\n for (const rule of [...coreRulesFor(methodology), ...methodology.rules])\n out.push(...rule.check(state, action));\n return out;\n}\n\nexport function applyAction(\n state: WorkflowState,\n methodology: Methodology,\n action: Action,\n reduce: (s: WorkflowState) => WorkflowState,\n): ApplyResult {\n const violations = validateAction(state, methodology, action);\n const errors = violations.filter((v) => v.severity === \"error\");\n if (errors.length) {\n fail(\n \"rule-violation\",\n `${action.type} violates ${errors.map((e) => e.rule).join(\", \")}: ${errors.map((e) => e.message).join(\"; \")}`,\n errors.map((e) => e.fix).join(\"; \"),\n { rule: errors[0]!.rule, items: errors.map((e) => e.item).filter((x): x is string => !!x) },\n );\n }\n return { state: reduce(state), warnings: violations.filter((v) => v.severity === \"warning\") };\n}\n\nexport interface InitInput<C> {\n methodology: Methodology<C>;\n config: unknown;\n roles?: Role[];\n stages?: Stage[];\n by?: string;\n now?: string;\n}\n\nexport function init<C>(input: InitInput<C>): ApplyResult {\n const m = input.methodology;\n const config = m.validateConfig(input.config);\n const stages = input.stages ?? m.defaultStages(config);\n const roles = input.roles ?? m.defaultRoles(config);\n const stateInput =\n input.now !== undefined\n ? { methodology: m.name, config, stages, roles, now: input.now }\n : { methodology: m.name, config, stages, roles };\n const state = createState(stateInput);\n requireCapabilities(state, m.requiredCapabilities, m.exclusiveCapabilities);\n return applyAction(state, m as Methodology, { type: \"init\", by: input.by ?? \"system\" }, (s) => s);\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkS3BXVHO7_cjs=require('./chunk-S3BXVHO7.cjs');function h(t){return t??new Date().toISOString()}function q(t){let e=new Set;for(let n of t.stages)e.has(n.id)&&chunkS3BXVHO7_cjs.b("config-invalid",`duplicate stage id "${n.id}"`,"give every stage a unique id"),e.add(n.id);let o={};for(let n of t.roles)chunkS3BXVHO7_cjs.c(n.id,"role id"),Object.hasOwn(o,n.id)&&chunkS3BXVHO7_cjs.b("duplicate-role",`duplicate role id "${n.id}"`,"give every role a unique id"),o[n.id]=n;let i=h(t.now);return {version:1,methodology:t.methodology,config:t.config,items:{},stages:t.stages,roles:o,iterations:[],events:[{seq:1,at:i,type:"state.created",by:"system",payload:{methodology:t.methodology}}],accounting:[],pending:[],lessons:[],agreements:[]}}function p(t,e,o,i,n){let s={seq:(t.events[t.events.length-1]?.seq??0)+1,at:h(n),type:e,by:o,payload:i};return {...t,events:[...t.events,s]}}function te(t,e){for(let o=t.events.length-1;o>=0;o--){let i=t.events[o];if(e===void 0||i.type===e)return i}}function R(t,e){return Object.hasOwn(t.roles,e)?t.roles[e]:void 0}var H=new Set(["in_progress","review","blocked"]);function re(t,e,o,i){chunkS3BXVHO7_cjs.c(e.id,"role id"),R(t,e.id)&&chunkS3BXVHO7_cjs.b("duplicate-role",`role "${e.id}" already exists`,`use a different id or retireRole("${e.id}") first`);let n={...t,roles:{...t.roles,[e.id]:e}};return p(n,"role.registered",o,{role:e.id,capabilities:e.capabilities},i)}function se(t,e,o,i){R(t,e)||chunkS3BXVHO7_cjs.b("unknown-role",`role "${e}" does not exist`,`registered roles: ${Object.keys(t.roles).join(", ")||"(none)"}`);let n=Object.values(t.items).filter(s=>s.role===e&&H.has(s.status)).map(s=>s.id);n.length&&chunkS3BXVHO7_cjs.b("role-has-open-items",`role "${e}" still holds ${n.length} open item(s)`,`complete or reassign ${n.join(", ")} before retiring the role`,{items:n});let r={...t.roles};return delete r[e],p({...t,roles:r},"role.retired",o,{role:e},i)}function x(t,e){return t.capabilities.includes(e)}function O(t,e){return Object.values(t.roles).filter(o=>x(o,e))}function y(t,e,o,i){return Object.values(t.roles).filter(n=>n.id!==i&&n.canApprove.includes(e)&&(o===void 0||n.capabilities.includes(o))).map(n=>n.id)}function ae(t,e){return O(t,"approve-gate").filter(o=>o.canApprove.includes(e))}function P(t,e,o){for(let i of e)O(t,i).length===0&&chunkS3BXVHO7_cjs.b("missing-capability",`no registered role has capability "${i}"`,`register a role whose capabilities include "${i}" (registerRole) before init`);for(let i of o){let n=O(t,i);n.length>1&&chunkS3BXVHO7_cjs.b("exclusive-capability",`capability "${i}" must belong to exactly one role but is held by ${n.map(r=>r.id).join(", ")}`,`remove "${i}" from all but one role`);}}function E(t,e){return e.length===0?[]:Object.values(t.roles).filter(o=>e.every(i=>x(o,i)))}function G(t,e,...o){if(e==="human")return true;let i=R(t,e);return !!i&&o.some(n=>x(i,n))}function le(t,e,...o){if(!G(t,e,...o)){let i=Object.values(t.roles).filter(n=>o.some(r=>x(n,r))).map(n=>n.id);chunkS3BXVHO7_cjs.b("missing-capability",`"${e}" lacks capability ${o.map(n=>`"${n}"`).join(" or ")}`,`run this as one of: human${i.map(n=>`, ${n}`).join("")}`);}}function I(t,e){let o=t.stages.find(i=>i.id===e);return o||chunkS3BXVHO7_cjs.b("unknown-stage",`stage "${e}" does not exist`,`stages are: ${t.stages.map(i=>i.id).join(" \u2192 ")}`),o}function K(t,e){let o=t.stages.findIndex(i=>i.id===e);return o<0&&I(t,e),t.stages[o+1]}function J(t,e){return t.stages[t.stages.length-1]?.id===e}function v(t,e){return {...t,items:{...t.items,[e.id]:e}}}function L(t,e,o){return v(t,o(w(t,e)))}function z(t,e,o){return L(t,e,i=>{let n={...i};for(let r of o)delete n[r];return n})}function w(t,e){let o=Object.hasOwn(t.items,e)?t.items[e]:void 0;return o||chunkS3BXVHO7_cjs.b("unknown-item",`item "${e}" does not exist`,`add it with addItem first; known items: ${Object.keys(t.items).join(", ")||"(none)"}`,{items:[e]}),o}function S(t,e,o){let i=e.filter(n=>!Object.hasOwn(t.items,n));i.length&&chunkS3BXVHO7_cjs.b("unknown-item",`${o} refers to unknown item(s) ${i.join(", ")}`,"add those items first or remove the reference",{items:i});}function ue(t,e,o,i){chunkS3BXVHO7_cjs.c(e.id,"item id"),Object.hasOwn(t.items,e.id)&&chunkS3BXVHO7_cjs.b("duplicate-item",`item "${e.id}" already exists`,"use editItem to change it, or pick a new id",{items:[e.id]});let n=t.stages[0];n||chunkS3BXVHO7_cjs.b("config-invalid","state has no stages","create the state with at least one stage");let r=e.stage??n.id;I(t,r),S(t,e.dependsOn??[],`item "${e.id}".dependsOn`),e.affects&&S(t,e.affects,`item "${e.id}".affects`),e.parent!==void 0&&S(t,[e.parent],`item "${e.id}".parent`),e.role!==void 0&&!Object.hasOwn(t.roles,e.role)&&chunkS3BXVHO7_cjs.b("unknown-role",`role "${e.role}" does not exist`,`registered roles: ${Object.keys(t.roles).join(", ")}`);let{stage:s,...a}=e,l={type:"task",acceptance:[],dependsOn:[],...a,id:e.id,title:e.title,stage:r,status:"todo",evidence:[],blockers:[],transitions:[]},c=v(t,l);return p(c,"item.added",o,{id:l.id,type:l.type,stage:l.stage,weight:l.weight??null,priority:l.priority??null,phase:l.phase??null,parent:l.parent??null},i)}function ge(t,e,o,i,n){let r=w(t,e);o.dependsOn&&S(t,o.dependsOn,`item "${e}".dependsOn`),o.affects&&S(t,o.affects,`item "${e}".affects`),o.parent!==void 0&&S(t,[o.parent],`item "${e}".parent`),o.role!==void 0&&!Object.hasOwn(t.roles,o.role)&&chunkS3BXVHO7_cjs.b("unknown-role",`role "${o.role}" does not exist`,`registered roles: ${Object.keys(t.roles).join(", ")}`);let s=Object.keys(o).filter(c=>JSON.stringify(o[c])!==JSON.stringify(r[c]));s.length===0&&chunkS3BXVHO7_cjs.b("no-op",`editItem("${e}") changes nothing`,"pass at least one field with a different value",{items:[e]});let a={...r};for(let c of s)a[c]=o[c];let l=v(t,a);return p(l,"item.edited",i,{id:e,changed:s},n)}function W(t,e,o,i,n){let r=w(t,e),s=o.stage??r.stage;I(t,s),(r.status==="done"||r.status==="dropped")&&chunkS3BXVHO7_cjs.b("invalid-transition",`item "${e}" is ${r.status} and cannot move`,"create a new item (or a change-request) instead of reopening a finished one",{items:[e]}),s===r.stage&&o.status===r.status&&chunkS3BXVHO7_cjs.b("no-op",`item "${e}" is already ${r.status} in "${s}"`,"choose a different stage or status",{items:[e]});let a=h(n),l={...r,stage:s,status:o.status,transitions:[...r.transitions,{from:{stage:r.stage,status:r.status},to:{stage:s,status:o.status},at:a,by:i}]},c=v(t,l);return p(c,"item.transition",i,{id:e,from:{stage:r.stage,status:r.status},to:{stage:s,status:o.status}},a)}function pe(t,e,o,i){let n=w(t,e),r=h(i),s={...n,evidence:[...n.evidence,{...o,at:r}]},a=v(t,s);return p(a,"item.evidence",o.by,{id:e,kind:o.kind,ref:o.ref},r)}function V(t,e,o,i,n,r){let s=w(t,e),a=h(r),l=`${e}-b${s.blockers.length+1}`,c=s.status==="blocked"?null:{from:{stage:s.stage,status:s.status},to:{stage:s.stage,status:"blocked"},at:a,by:n},g={...s,status:"blocked",blockers:[...s.blockers,{id:l,reason:o,owner:i,raisedAt:a}],transitions:c?[...s.transitions,c]:s.transitions},u=v(t,g);return p(u,"blocker.raised",n,{id:e,blocker:l,reason:o,owner:i,transition:c&&{from:c.from,to:c.to}},a)}function M(t,e){for(let o=t.transitions.length-1;o>=0;o--){let i=t.transitions[o];if(i.to.status===e)return i}}function me(t,e,o,i,n){let r=w(t,e),s=r.blockers.findIndex(k=>k.id===o&&!k.clearedAt);s<0&&chunkS3BXVHO7_cjs.b("invalid-input",`item "${e}" has no open blocker "${o}"`,`open blockers: ${r.blockers.filter(k=>!k.clearedAt).map(k=>k.id).join(", ")||"(none)"}`,{items:[e]});let a=h(n),l=r.blockers.map((k,F)=>F===s?{...k,clearedAt:a}:k),c=l.some(k=>!k.clearedAt),g=M(r,"blocked")?.from.status??"todo",u=r.stage,d=g,m=false;g==="in_progress"?(d="todo",u=M(r,"in_progress")?.from.stage??r.stage):g==="awaiting_human"&&(d=I(t,r.stage).review?"review":"todo",m=true);let{role:j,...N}=r,b=c?null:{from:{stage:r.stage,status:"blocked"},to:{stage:u,status:d},at:a,by:i},B={...m&&!c?N:r,blockers:l,stage:c?r.stage:u,status:c?"blocked":d,transitions:b?[...r.transitions,b]:r.transitions},D=v(t,B);return p(D,"blocker.cleared",i,{id:e,blocker:o,transition:b&&{from:b.from,to:b.to}},a)}function A(t,e){return z(t,e,["role"])}function _(t,e,o,i,n){let r=w(t,e),s=K(t,r.stage);if(!s)return W(t,e,{status:"done"},o,n);if(J(t,s.id))return W(t,e,{stage:s.id,status:"done"},o,n);let a=i||s.review===true?"review":"todo";return A(W(t,e,{stage:s.id,status:a},o,n),e)}function Q(t,e,o){let i=[],n=(r,s,a)=>i.push({rule:r,severity:"error",item:e.id,message:s,fix:a});for(let r of o)switch(r.kind){case "evidence":e.evidence.some(s=>s.kind===r.evidenceKind)||n("policy:evidence",`item "${e.id}" has no evidence of kind "${r.evidenceKind}"`,`attach evidence { kind: "${r.evidenceKind}" } via addEvidence or in the handoff.produced`);break;case "acceptance-written":e.acceptance.length===0&&n("policy:acceptance-written",`item "${e.id}" has no acceptance criteria`,"editItem with a non-empty acceptance[] (needs define-acceptance)");break;case "estimate-present":e.weight===void 0&&n("policy:estimate-present",`item "${e.id}" has no weight`,"editItem with a weight (story points)");break;case "no-open-blockers":{let s=e.blockers.filter(a=>!a.clearedAt);s.length&&n("policy:no-open-blockers",`item "${e.id}" has ${s.length} open blocker(s)`,`clearBlocker ${s.map(a=>a.id).join(", ")}`);break}case "dependencies-done":{let s=e.dependsOn.filter(a=>t.items[a]?.status!=="done");s.length&&n("policy:dependencies-done",`item "${e.id}" depends on unfinished ${s.join(", ")}`,`finish ${s.join(", ")} first`);break}case "custom":e.evidence.some(s=>s.kind===`policy:${r.id}`)||n(`policy:custom:${r.id}`,`item "${e.id}" has not satisfied "${r.description}"`,`attach evidence { kind: "policy:${r.id}" } when it is satisfied`);break}return i}function we(t,e,o,i){let n=Q(t,e,o);n.length&&chunkS3BXVHO7_cjs.b("policy-unmet",`item "${e.id}" cannot ${i}: ${n.length} polic${n.length===1?"y":"ies"} unmet`,n.map(r=>r.fix).join("; "),{items:[e.id]});}function U(t,e){let o=new Map(t.stages.map((n,r)=>[n.id,r])),i=o.get(e.stage);if(i!==void 0)for(let n=e.transitions.length-1;n>=0;n--){let r=e.transitions[n],s=o.get(r.from.stage);if(r.to.status==="in_progress"&&s!==void 0&&s<i)return r}}function C(t,e){let o=U(t,e);if(o)return o.by;for(let i=e.transitions.length-1;i>=0;i--){let n=e.transitions[i];if(n.to.status==="in_progress")return n.by}}function X(t,e,o,i){let n=[];for(let s of o.evidence)e.evidence.some(a=>a.kind===s)||n.push({rule:"gate:evidence",severity:"error",item:e.id,message:`gate "${o.id}" needs evidence "${s}" on item "${e.id}"`,fix:`attach evidence { kind: "${s}" } before approving`});if(n.length)return {outcome:"fail",violations:n};let r=false;for(let s of o.requires){if(s==="human"){i!=="human"&&(r=true);continue}if(!y(t,o.id,s.capability).includes(i)){n.push({rule:"gate:capability",severity:"error",item:e.id,message:`"${i}" may not approve gate "${o.id}" (needs capability "${s.capability}" and canApprove "${o.id}")`,fix:`approve as one of: ${y(t,o.id,s.capability).join(", ")||"(no role qualifies; register one)"}`});continue}let l=C(t,e);if(l!==void 0&&l===i){let c=y(t,o.id,s.capability,i);n.push({rule:"conflict-of-interest",severity:"error",item:e.id,message:`role "${i}" did the work on "${e.id}" and may not approve it`,fix:`approve as a different role: ${c.join(", ")||"(register another approver)"}`});}}return n.length?{outcome:"fail",violations:n}:r?{outcome:"human"}:{outcome:"pass"}}function be(t,e,o){let i=h(o),n=`p${t.events.filter(a=>a.type==="pending.raised").length+1}`,r={...e,id:n,raisedAt:i},s={...t,pending:[...t.pending,r]};return e.item&&w(s,e.item).status!=="awaiting_human"&&(s=W(s,e.item,{status:"awaiting_human"},"system",i)),p(s,"pending.raised","system",{id:n,kind:e.kind,item:e.item??null,gate:e.gate??null},i)}function xe(t,e,o,i,n,r,s){o!=="approve"&&o!=="reject"&&chunkS3BXVHO7_cjs.b("invalid-input",`decision must be "approve" or "reject" (got ${JSON.stringify(o)})`,"pass approve or reject");let a=t.pending.find(d=>d.id===e);a||chunkS3BXVHO7_cjs.b("unknown-pending",`no pending decision "${e}"`,`open decisions: ${t.pending.map(d=>d.id).join(", ")||"(none)"}`);let l=a.kind==="gate"&&a.item?w(t,a.item):void 0,c=l&&(t.stages.find(d=>a.gate!==void 0&&d.gate?.id===a.gate)?.gate??t.stages.find(d=>d.id===l.stage)?.gate);l&&c&&i!=="human"&&(c.requires.includes("human")?void 0:X(t,l,c,i))?.outcome!=="pass"&&chunkS3BXVHO7_cjs.b("gate-unmet",`"${i}" may not decide gate "${c.id}" on "${l.id}"`,`decide as one of: human${c.requires.flatMap(m=>m==="human"?[]:y(t,c.id,m.capability)).map(m=>`, ${m}`).join("")}`,{items:[l.id],rule:"gate"});let g=h(r),u={...t,pending:t.pending.filter(d=>d.id!==e)};if(u=p(u,"pending.decided",i,{id:e,decision:o,note:n,item:a.item??null,gate:a.gate??null},g),l){let d=l.id,m=a.gate??c?.id??null;if(o==="approve")u=_(u,d,i,false,g),u=p(u,"gate.passed",i,{item:d,gate:m},g);else {let j=c?.onFail??{action:"block"};j.action==="return-to"?u=A(W(u,d,{stage:j.stage,status:"todo"},i,g),d):u=V(u,d,`gate "${m??"?"}" rejected: ${n||"no reason given"}`,i,i,g),u=p(u,"gate.failed",i,{item:d,gate:m,note:n},g);}}return s?.afterDecide&&(u=s.afterDecide(u,a,o,i,n,g)),u}function T(t){return [{id:"separation-lost",severity:"warning",check(i,n){return n.type!=="init"&&n.type!=="role.register"?[]:E(i,t.requiredCapabilities).map(r=>({rule:"separation-lost",severity:"warning",message:`role "${r.id}" holds every required capability (${t.requiredCapabilities.join(", ")}); no separation of duties`,fix:"fine for a solo operator; otherwise split capabilities across roles"}))}},{id:"conflict-of-interest",severity:"error",check(i,n){if(n.type!=="complete")return [];let r=n.payload?.handoff;if(!r)return [];let s=r.verdict??"done";if(s!=="done"&&s!=="needs-review")return [];let a=i.items[r.item];if(!a)return [];let l=i.stages.find(g=>g.id===a.stage)?.gate;if(!l||!l.requires.some(g=>g!=="human"))return [];if(C(i,a)!==r.role)return [];let c=y(i,l.id,void 0,r.role);return [{rule:"conflict-of-interest",severity:"error",item:a.id,message:`role "${r.role}" authored "${a.id}" and may not pass gate "${l.id}" on it`,fix:`hand the gate to another approver: ${c.join(", ")||"(register one)"}`}]}}]}function Y(t,e,o){let i=[];for(let n of [...T(e),...e.rules])i.push(...n.check(t,o));return i}function Z(t,e,o,i){let n=Y(t,e,o),r=n.filter(s=>s.severity==="error");return r.length&&chunkS3BXVHO7_cjs.b("rule-violation",`${o.type} violates ${r.map(s=>s.rule).join(", ")}: ${r.map(s=>s.message).join("; ")}`,r.map(s=>s.fix).join("; "),{rule:r[0].rule,items:r.map(s=>s.item).filter(s=>!!s)}),{state:i(t),warnings:n.filter(s=>s.severity==="warning")}}function Ee(t){let e=t.methodology,o=e.validateConfig(t.config),i=t.stages??e.defaultStages(o),n=t.roles??e.defaultRoles(o),r=t.now!==void 0?{methodology:e.name,config:o,stages:i,roles:n,now:t.now}:{methodology:e.name,config:o,stages:i,roles:n},s=q(r);return P(s,e.requiredCapabilities,e.exclusiveCapabilities),Z(s,e,{type:"init",by:t.by??"system"},a=>a)}exports.A=me;exports.B=A;exports.C=_;exports.D=Q;exports.E=we;exports.F=U;exports.G=C;exports.H=X;exports.I=be;exports.J=xe;exports.K=T;exports.L=Y;exports.M=Z;exports.N=Ee;exports.a=h;exports.b=q;exports.c=p;exports.d=te;exports.e=R;exports.f=re;exports.g=se;exports.h=x;exports.i=O;exports.j=y;exports.k=ae;exports.l=P;exports.m=E;exports.n=G;exports.o=le;exports.p=I;exports.q=K;exports.r=J;exports.s=L;exports.t=z;exports.u=w;exports.v=ue;exports.w=ge;exports.x=W;exports.y=pe;exports.z=V;//# sourceMappingURL=chunk-SJRRQZ3R.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-SJRRQZ3R.cjs.map
|