ex-workflow 0.3.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 +11 -1
- package/README.md +16 -3
- 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-4A4TD4MH.cjs → chunk-7KF5K3L7.cjs} +2 -2
- package/dist/{chunk-4A4TD4MH.cjs.map → chunk-7KF5K3L7.cjs.map} +1 -1
- package/dist/{chunk-2IKIBB73.cjs → chunk-CWBH7H52.cjs} +2 -2
- package/dist/{chunk-2IKIBB73.cjs.map → chunk-CWBH7H52.cjs.map} +1 -1
- package/dist/chunk-DXC2RSN5.cjs +3 -0
- package/dist/chunk-DXC2RSN5.cjs.map +1 -0
- package/dist/{chunk-UOGNVWVO.mjs → chunk-GATJZYTB.mjs} +2 -2
- package/dist/{chunk-UOGNVWVO.mjs.map → chunk-GATJZYTB.mjs.map} +1 -1
- package/dist/{chunk-ZX4DAMTG.mjs → chunk-GFH2FEZH.mjs} +2 -2
- package/dist/{chunk-ZX4DAMTG.mjs.map → chunk-GFH2FEZH.mjs.map} +1 -1
- package/dist/{chunk-NN3XJUHP.cjs → chunk-HHC5EZ54.cjs} +2 -2
- package/dist/{chunk-NN3XJUHP.cjs.map → chunk-HHC5EZ54.cjs.map} +1 -1
- package/dist/{chunk-TMKCALFT.cjs → chunk-KSKEFYY7.cjs} +2 -2
- package/dist/{chunk-TMKCALFT.cjs.map → chunk-KSKEFYY7.cjs.map} +1 -1
- package/dist/chunk-KUUIAKEJ.cjs +2 -0
- package/dist/chunk-KUUIAKEJ.cjs.map +1 -0
- package/dist/{chunk-R27STIER.mjs → chunk-L2ZN6HEL.mjs} +2 -2
- package/dist/{chunk-R27STIER.mjs.map → chunk-L2ZN6HEL.mjs.map} +1 -1
- package/dist/{chunk-BJEOTG6P.mjs → chunk-NDORREWR.mjs} +2 -2
- package/dist/{chunk-BJEOTG6P.mjs.map → chunk-NDORREWR.mjs.map} +1 -1
- package/dist/{chunk-WOKNWJKU.mjs → chunk-NZ2DIDOD.mjs} +2 -2
- package/dist/{chunk-WOKNWJKU.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-FLCYD2QF.mjs → chunk-SHAPFMVP.mjs} +2 -2
- package/dist/{chunk-FLCYD2QF.mjs.map → chunk-SHAPFMVP.mjs.map} +1 -1
- package/dist/{chunk-23P7C25E.cjs → chunk-SJRRQZ3R.cjs} +2 -2
- package/dist/{chunk-23P7C25E.cjs.map → chunk-SJRRQZ3R.cjs.map} +1 -1
- package/dist/{chunk-7HZXZF3L.cjs → chunk-UM5X2JHB.cjs} +2 -2
- package/dist/{chunk-7HZXZF3L.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 +5 -5
- package/dist/index.d.ts +5 -5
- 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 +9 -2
- package/dist/types.d.ts +9 -2
- package/dist/waterfall/index.cjs +1 -1
- package/dist/waterfall/index.mjs +1 -1
- package/package.json +18 -2
- package/dist/chunk-6R3YFUUV.cjs +0 -6
- package/dist/chunk-6R3YFUUV.cjs.map +0 -1
- package/dist/chunk-AUZIQPFT.cjs +0 -2
- package/dist/chunk-AUZIQPFT.cjs.map +0 -1
- package/dist/chunk-P4P4JTE5.mjs +0 -2
- package/dist/chunk-P4P4JTE5.mjs.map +0 -1
- package/dist/chunk-VGD4V5BA.mjs +0 -6
- package/dist/chunk-VGD4V5BA.mjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {f,c,j,b as b$1}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {f,c,j,b as b$1}from'./chunk-GFH2FEZH.mjs';import {e,p,a,y,u,c as c$1,v as v$1,B,x,E,H,I as I$1,C,z as z$1,i,s,F}from'./chunk-SHAPFMVP.mjs';import {b}from'./chunk-2FRRD6A3.mjs';function D(i,a){let t=[];for(let o of i.events)o.type==="item.completed"&&o.payload.id===a&&t.push({...o.payload,at:o.at});return t}function z(i,a){let t=D(i,a);return t[t.length-1]}function J(i,a,t){t.role||b("unknown-role",`item "${t.id}" has no role assigned`,"dispatch it with next() or set item.role",{items:[t.id]});let o=e(i,t.role);o||b("unknown-role",`role "${t.role}" does not exist`,`registered roles: ${Object.keys(i.roles).join(", ")}`);let u=[],d=[...o.do_not],s=[...t.dependsOn,...t.type==="bug"||t.type==="change-request"?t.affects??[]:[]];for(let n of s){let c=z(i,n);if(c){u.push({item:n,produced:c.produced,notes:c.notes});for(let m of c.do_not)d.includes(m)||d.push(m);}}let l=D(i,t.id).map(n=>({role:n.role,verdict:n.verdict,notes:n.notes,produced:n.produced,at:n.at})),e$1=new Set([t.id,...t.dependsOn]),g=Object.values(i.items).filter(n=>(n.type==="bug"||n.type==="change-request")&&n.id!==t.id&&n.status!=="done"&&n.status!=="dropped"&&(n.affects??[]).some(c=>e$1.has(c))).map(n=>({id:n.id,title:n.title,affects:n.affects??[]})),k=f(i),f$1=p(i,t.stage).gate,r={item:t,role:o,modelTier:o.modelTier,invariants:[...a.invariants(i,t),...i.agreements],do_not:d,acceptance:t.acceptance,upstream:u,priorHandoffs:l,relatedBugs:g,budgetRemaining:k?c(k.budget,k.spent):{}};return f$1&&(r.gateAhead=f$1),r}function oe(i,a,t={}){let o=j(i,a,t),u=o.dispatched.map(d=>J(o.state,a,o.state.items[d.id]));return o.reason?{state:o.state,briefs:u,skipped:o.skipped,reason:o.reason}:{state:o.state,briefs:u,skipped:o.skipped}}var G=["done","needs-review","rework","blocked","escalate"],L=["policy","skill","memory","spec","review"],I=i=>typeof i=="object"&&i!==null&&!Array.isArray(i),v=i=>typeof i=="string";function X(i,a,t){let o=u(i,a.item);o.status!=="in_progress"&&b("invalid-transition",`item "${o.id}" is ${o.status}, not in_progress`,"only dispatched items can be completed; call next() first",{items:[o.id]}),Array.isArray(a.do_not)||b("handoff-invalid",`handoff for "${o.id}" has no do_not array`,"set handoff.do_not to [] when there is nothing to forbid",{items:[o.id]}),(!Array.isArray(a.produced)||!Array.isArray(a.open_questions))&&b("handoff-invalid",`handoff for "${o.id}" needs produced[] and open_questions[]`,"pass empty arrays when there is nothing",{items:[o.id]});let u$1=(e,g)=>b("handoff-invalid",`handoff for "${o.id}": ${e}`,g,{items:[o.id]}),d=a.verdict??"done";G.includes(d)||u$1(`unknown verdict ${JSON.stringify(d)}`,`use one of: ${G.join(", ")}`),a.produced.every(e=>I(e)&&v(e.kind)&&v(e.ref))||u$1("produced[] entries need string kind and ref",'use { "kind": "code", "ref": "src/a.ts" }');let s=a.lessons??[];(!Array.isArray(s)||!s.every(e=>I(e)&&v(e.text)&&L.includes(e.scope)))&&u$1("lessons[] entries need a text and a scope",`scope is one of: ${L.join(", ")}`);let l=a.follow_ups??[];(!Array.isArray(l)||!l.every(e=>I(e)&&v(e.id)&&v(e.title)))&&u$1("follow_ups[] entries need a string id and title","describe each follow-up as a new item"),a.role!==o.role&&b("handoff-invalid",`handoff role "${a.role}" differs from the dispatched role "${o.role}"`,`complete as "${o.role}" or re-dispatch`,{items:[o.id]}),(!t.model||t.model.trim()==="")&&b("accounting-invalid",`accounting for "${o.id}" has no model`,"record the model id that actually ran the work",{items:[o.id]});for(let e of ["tokensIn","tokensOut","durationMs"])(!Number.isFinite(t[e])||t[e]<0)&&b("accounting-invalid",`accounting.${e} must be a non-negative number`,`measure ${e} from the host's usage report`,{items:[o.id]});}function U(i){for(let a=i.transitions.length-1;a>=0;a--){let t=i.transitions[a];if(t.to.status==="in_progress")return t.from.stage}return i.stage}function K(i,a){return F(i,a)?.from.stage??U(a)}function fe(i$1,a$1,t,o,u$1){X(i$1,t,o);let d=a(u$1),s$1=t.item,l=t.role,e={...i$1,accounting:[...i$1.accounting,o]};for(let r of t.produced)e=y(e,s$1,{kind:r.kind,ref:r.ref,by:l},d);let g=f(e);g&&(g.committed.includes(s$1)||u(e,s$1).iteration===g.id)&&(e={...e,iterations:e.iterations.map(r=>r.id===g.id?{...r,spent:b$1(r.spent,o)}:r)});for(let r of t.lessons??[]){let n=`L${e.lessons.length+1}`;e={...e,lessons:[...e.lessons,{id:n,at:d,text:r.text,scope:r.scope,status:"raised",from:l,item:s$1}]},e=c$1(e,"lesson.raised",l,{id:n,from:l,item:s$1,scope:r.scope},d);}let k=[];for(let r of t.follow_ups??[]){let n=e.stages[0],{iteration:c,...m}=r;e=v$1(e,{...m,stage:n.id,parent:s$1,tags:[...r.tags??[],"follow-up"]},l,d),k.push(r.id);}let f$1=t.verdict??"done";if(f$1==="rework"){(!t.notes||t.notes.trim()==="")&&b("handoff-invalid",`rework on "${s$1}" needs notes`,"say what must change in handoff.notes",{items:[s$1]});let r=u(e,s$1);e=B(x(e,s$1,{stage:K(e,r),status:"todo"},l,d),s$1),e=c$1(e,"item.rework",l,{id:s$1,by:l,notes:t.notes},d);}else if((f$1==="done"||f$1==="needs-review")&&u(e,s$1).type==="question"){let r=e.stages[e.stages.length-1].id;e=x(e,s$1,{stage:r,status:"done"},l,d);}else if(f$1==="done"||f$1==="needs-review"){let r=u(e,s$1),n=p(e,r.stage);if(E(e,r,n.exitPolicy,`leave "${n.id}"`),n.gate){let c=H(e,r,n.gate,l);c.outcome==="fail"&&b("gate-unmet",`gate "${n.gate.id}" blocks "${s$1}": ${c.violations.map(m=>m.message).join("; ")}`,c.violations.map(m=>m.fix).join("; "),{items:[s$1],rule:c.violations[0].rule}),c.outcome==="human"?e=I$1(e,{kind:"gate",item:s$1,gate:n.gate.id,question:`Approve gate "${n.gate.id}" for "${r.title}" (${s$1})?`},d):e=c$1(C(e,s$1,l,f$1==="needs-review",d),"gate.passed",l,{item:s$1,gate:n.gate.id},d);}else e=C(e,s$1,l,f$1==="needs-review",d);}else if(f$1==="blocked")e=z$1(e,s$1,t.notes||"blocked by worker",l,l,d);else if(f$1==="escalate"){let r=i(e,"escalate")[0];r||b("missing-capability",`no role has capability "escalate" to receive the question from "${s$1}"`,"register a role with capability escalate",{items:[s$1]});let n=Object.keys(e.items).filter(h=>h.startsWith(`${s$1}-q`)).length+1,c=`${s$1}-q${n}`,m=u(e,s$1),O=U(m),W={id:c,type:"question",title:t.open_questions.join(" | ")||t.notes||`question from ${s$1}`,parent:s$1,role:r.id,priority:Number.MAX_SAFE_INTEGER,stage:O};m.iteration!==void 0&&(W.iteration=m.iteration),e=v$1(e,W,l,d),e=x(e,s$1,{stage:O,status:"todo"},l,d),e=s(e,s$1,h=>({...h,dependsOn:[...h.dependsOn,c]})),e=c$1(e,"item.escalated",l,{id:s$1,question:c,to:r.id},d);}return e=c$1(e,"item.completed",l,{id:s$1,role:l,verdict:f$1,produced:t.produced,notes:t.notes,do_not:t.do_not,open_questions:t.open_questions,followUps:k,tokens:o.tokensIn+o.tokensOut,durationMs:o.durationMs,model:o.model},d),a$1.afterComplete&&(e=a$1.afterComplete(e,s$1,d)),{state:e,warnings:[]}}export{J as a,oe as b,fe as c};//# sourceMappingURL=chunk-NZ2DIDOD.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-NZ2DIDOD.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/brief.ts","../src/complete.ts"],"names":["completions","state","itemId","out","ev","lastCompletion","all","synthesizeBrief","methodology","item","fail","role","roleOf","upstream","doNot","sources","dep","p","d","priorHandoffs","touched","relatedBugs","b","a","it","openIteration","gate","stageOf","brief","remaining","next","opts","res","plan","briefs","VERDICTS","LESSON_SCOPES","isObj","x","str","validate","handoff","acc","getItem","bad","what","fix","verdict","lessons","l","followUps","f","k","pulledFromStage","i","reworkStage","lastDispatchBefore","complete","now","at","nowOf","id","s","addEvidence","addSpent","lid","appendEvent","n","first","_drop","rest","addItem","clearRole","moveItem","lastStageId","stage","assertPolicies","checkGate","v","raisePending","advanceItem","raiseBlocker","thinker","rolesWith","qid","parent","pulledFrom","q","patchItem"],"mappings":"wLAgBA,SAASA,EACPC,CAAAA,CACAC,CAAAA,CAC0C,CAC1C,IAAMC,CAAAA,CAAgD,EAAC,CACvD,IAAA,IAAWC,CAAAA,IAAMH,CAAAA,CAAM,OACjBG,CAAAA,CAAG,IAAA,GAAS,kBAAqBA,CAAAA,CAAG,OAAA,CAA6B,KAAOF,CAAAA,EAC1EC,CAAAA,CAAI,IAAA,CAAK,CAAE,GAAIC,CAAAA,CAAG,OAAA,CAA8B,GAAIA,CAAAA,CAAG,EAAG,CAAC,CAAA,CAE/D,OAAOD,CACT,CAEA,SAASE,EAAeJ,CAAAA,CAAsBC,CAAAA,CAA8C,CAC1F,IAAMI,CAAAA,CAAMN,EAAYC,CAAAA,CAAOC,CAAM,CAAA,CACrC,OAAOI,EAAIA,CAAAA,CAAI,MAAA,CAAS,CAAC,CAC3B,CAEO,SAASC,CAAAA,C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AAAkD,GAAAA,CAAI,SAAUuB,CAAAA,CAAK,EAAA,CAAIF,EAAQ,EAAG,CAAA,CAAGvB,CAAE,EACtF,CAEA,OAAAG,CAAAA,CAAII,GAAAA,CACFJ,EACA,gBAAA,CACAnD,CAAAA,CACA,CACE,EAAA,CAAAkD,GAAAA,CACA,KAAAlD,CAAAA,CACA,OAAA,CAAAoC,GAAAA,CACA,QAAA,CAAUN,EAAQ,QAAA,CAClB,KAAA,CAAOA,EAAQ,KAAA,CACf,MAAA,CAAQA,EAAQ,MAAA,CAChB,cAAA,CAAgBA,EAAQ,cAAA,CACxB,SAAA,CAAAS,EACA,MAAA,CAAQR,CAAAA,CAAI,SAAWA,CAAAA,CAAI,SAAA,CAC3B,WAAYA,CAAAA,CAAI,UAAA,CAChB,KAAA,CAAOA,CAAAA,CAAI,KACb,CAAA,CACAiB,CACF,EACInD,GAAAA,CAAY,aAAA,GAAesD,EAAItD,GAAAA,CAAY,aAAA,CAAcsD,EAAGD,GAAAA,CAAIF,CAAE,GAC/D,CAAE,KAAA,CAAOG,EAAG,QAAA,CAAU,EAAG,CAClC","file":"chunk-WOKNWJKU.mjs","sourcesContent":["import { remaining } from \"./budget.ts\";\nimport { fail } from \"./errors.ts\";\nimport { stageOf } from \"./items.ts\";\nimport { openIteration, plan, type PlanOptions, type PlanReason, type Skipped } from \"./planner.ts\";\nimport { roleOf } from \"./roles.ts\";\nimport type { Brief, Handoff, Methodology, Verdict, WorkItem, WorkflowState } from \"./types.ts\";\n\ninterface CompletedPayload {\n id: string;\n role: string;\n verdict: Verdict;\n produced: Handoff[\"produced\"];\n notes: string;\n do_not: string[];\n}\n\nfunction completions(\n state: WorkflowState,\n itemId: string,\n): Array<CompletedPayload & { at: string }> {\n const out: Array<CompletedPayload & { at: string }> = [];\n for (const ev of state.events) {\n if (ev.type === \"item.completed\" && (ev.payload as CompletedPayload).id === itemId)\n out.push({ ...(ev.payload as CompletedPayload), at: ev.at });\n }\n return out;\n}\n\nfunction lastCompletion(state: WorkflowState, itemId: string): CompletedPayload | undefined {\n const all = completions(state, itemId);\n return all[all.length - 1];\n}\n\nexport function synthesizeBrief(\n state: WorkflowState,\n methodology: Methodology,\n item: WorkItem,\n): Brief {\n if (!item.role)\n fail(\n \"unknown-role\",\n `item \"${item.id}\" has no role assigned`,\n \"dispatch it with next() or set item.role\",\n { items: [item.id] },\n );\n const role = roleOf(state, item.role);\n if (!role)\n fail(\n \"unknown-role\",\n `role \"${item.role}\" does not exist`,\n `registered roles: ${Object.keys(state.roles).join(\", \")}`,\n );\n const upstream: Brief[\"upstream\"] = [];\n const doNot = [...role.do_not];\n const sources = [\n ...item.dependsOn,\n ...(item.type === \"bug\" || item.type === \"change-request\" ? (item.affects ?? []) : []),\n ];\n for (const dep of sources) {\n const p = lastCompletion(state, dep);\n if (!p) continue;\n upstream.push({ item: dep, produced: p.produced, notes: p.notes });\n for (const d of p.do_not) if (!doNot.includes(d)) doNot.push(d);\n }\n const priorHandoffs: Brief[\"priorHandoffs\"] = completions(state, item.id).map((p) => ({\n role: p.role,\n verdict: p.verdict,\n notes: p.notes,\n produced: p.produced,\n at: p.at,\n }));\n const touched = new Set([item.id, ...item.dependsOn]);\n const relatedBugs: Brief[\"relatedBugs\"] = Object.values(state.items)\n .filter(\n (b) =>\n (b.type === \"bug\" || b.type === \"change-request\") &&\n b.id !== item.id &&\n b.status !== \"done\" &&\n b.status !== \"dropped\" &&\n (b.affects ?? []).some((a) => touched.has(a)),\n )\n .map((b) => ({ id: b.id, title: b.title, affects: b.affects ?? [] }));\n const it = openIteration(state);\n const gate = stageOf(state, item.stage).gate;\n const brief: Brief = {\n item,\n role,\n modelTier: role.modelTier,\n invariants: [...methodology.invariants(state, item), ...state.agreements],\n do_not: doNot,\n acceptance: item.acceptance,\n upstream,\n priorHandoffs,\n relatedBugs,\n budgetRemaining: it ? remaining(it.budget, it.spent) : {},\n };\n if (gate) brief.gateAhead = gate;\n return brief;\n}\n\nexport interface NextResult {\n state: WorkflowState;\n briefs: Brief[];\n skipped: Skipped[];\n reason?: PlanReason;\n}\n\nexport function next(\n state: WorkflowState,\n methodology: Methodology,\n opts: PlanOptions = {},\n): NextResult {\n const res = plan(state, methodology, opts);\n const briefs = res.dispatched.map((d) =>\n synthesizeBrief(res.state, methodology, res.state.items[d.id]!),\n );\n return res.reason\n ? { state: res.state, briefs, skipped: res.skipped, reason: res.reason }\n : { state: res.state, briefs, skipped: res.skipped };\n}\n","import { addSpent } from \"./budget.ts\";\nimport { fail } from \"./errors.ts\";\nimport { checkGate, lastDispatchBefore, raisePending } from \"./gates.ts\";\nimport {\n addEvidence,\n addItem,\n advanceItem,\n clearRole,\n getItem,\n moveItem,\n patchItem,\n raiseBlocker,\n stageOf,\n} from \"./items.ts\";\nimport { assertPolicies } from \"./policies.ts\";\nimport { openIteration } from \"./planner.ts\";\nimport { rolesWith } from \"./roles.ts\";\nimport { appendEvent, nowOf } from \"./state.ts\";\nimport type {\n Accounting,\n ApplyResult,\n Handoff,\n Methodology,\n NewItem,\n WorkItem,\n WorkflowState,\n} from \"./types.ts\";\n\nconst VERDICTS: readonly string[] = [\"done\", \"needs-review\", \"rework\", \"blocked\", \"escalate\"];\nconst LESSON_SCOPES: readonly string[] = [\"policy\", \"skill\", \"memory\", \"spec\", \"review\"];\n\nconst isObj = (x: unknown): x is Record<string, unknown> =>\n typeof x === \"object\" && x !== null && !Array.isArray(x);\nconst str = (x: unknown) => typeof x === \"string\";\n\nfunction validate(state: WorkflowState, handoff: Handoff, acc: Accounting): void {\n const item = getItem(state, handoff.item);\n if (item.status !== \"in_progress\")\n fail(\n \"invalid-transition\",\n `item \"${item.id}\" is ${item.status}, not in_progress`,\n \"only dispatched items can be completed; call next() first\",\n { items: [item.id] },\n );\n if (!Array.isArray(handoff.do_not))\n fail(\n \"handoff-invalid\",\n `handoff for \"${item.id}\" has no do_not array`,\n \"set handoff.do_not to [] when there is nothing to forbid\",\n { items: [item.id] },\n );\n if (!Array.isArray(handoff.produced) || !Array.isArray(handoff.open_questions))\n fail(\n \"handoff-invalid\",\n `handoff for \"${item.id}\" needs produced[] and open_questions[]`,\n \"pass empty arrays when there is nothing\",\n { items: [item.id] },\n );\n const bad = (what: string, fix: string) =>\n fail(\"handoff-invalid\", `handoff for \"${item.id}\": ${what}`, fix, { items: [item.id] });\n const verdict = handoff.verdict ?? \"done\";\n if (!VERDICTS.includes(verdict))\n bad(`unknown verdict ${JSON.stringify(verdict)}`, `use one of: ${VERDICTS.join(\", \")}`);\n if (!handoff.produced.every((p) => isObj(p) && str(p.kind) && str(p.ref)))\n bad(\"produced[] entries need string kind and ref\", 'use { \"kind\": \"code\", \"ref\": \"src/a.ts\" }');\n const lessons: unknown = handoff.lessons ?? [];\n if (\n !Array.isArray(lessons) ||\n !lessons.every((l) => isObj(l) && str(l.text) && LESSON_SCOPES.includes(l.scope as string))\n )\n bad(\n \"lessons[] entries need a text and a scope\",\n `scope is one of: ${LESSON_SCOPES.join(\", \")}`,\n );\n const followUps: unknown = handoff.follow_ups ?? [];\n if (!Array.isArray(followUps) || !followUps.every((f) => isObj(f) && str(f.id) && str(f.title)))\n bad(\"follow_ups[] entries need a string id and title\", \"describe each follow-up as a new item\");\n if (handoff.role !== item.role)\n fail(\n \"handoff-invalid\",\n `handoff role \"${handoff.role}\" differs from the dispatched role \"${item.role}\"`,\n `complete as \"${item.role}\" or re-dispatch`,\n { items: [item.id] },\n );\n if (!acc.model || acc.model.trim() === \"\")\n fail(\n \"accounting-invalid\",\n `accounting for \"${item.id}\" has no model`,\n \"record the model id that actually ran the work\",\n { items: [item.id] },\n );\n for (const k of [\"tokensIn\", \"tokensOut\", \"durationMs\"] as const) {\n if (!Number.isFinite(acc[k]) || acc[k] < 0)\n fail(\n \"accounting-invalid\",\n `accounting.${k} must be a non-negative number`,\n `measure ${k} from the host's usage report`,\n { items: [item.id] },\n );\n }\n}\n\n/** Stage the item was pulled from: the `from.stage` of its last transition into in_progress, else its current stage. */\nfunction pulledFromStage(item: WorkItem): string {\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.from.stage;\n }\n return item.stage;\n}\n\n/** Stage a reworked item returns to: the from.stage of the last dispatch made from a stage strictly before the current one (so a reviewer's rework lands where the work was pulled from), else the plain pulled-from stage. */\nfunction reworkStage(state: WorkflowState, item: WorkItem): string {\n return lastDispatchBefore(state, item)?.from.stage ?? pulledFromStage(item);\n}\n\nexport function complete(\n state: WorkflowState,\n methodology: Methodology,\n handoff: Handoff,\n acc: Accounting,\n now?: string,\n): ApplyResult {\n validate(state, handoff, acc);\n const at = nowOf(now);\n const id = handoff.item;\n const role = handoff.role;\n let s: WorkflowState = { ...state, accounting: [...state.accounting, acc] };\n for (const p of handoff.produced)\n s = addEvidence(s, id, { kind: p.kind, ref: p.ref, by: role }, at);\n const it = openIteration(s);\n if (it && (it.committed.includes(id) || getItem(s, id).iteration === it.id)) {\n s = {\n ...s,\n iterations: s.iterations.map((x) =>\n x.id === it.id ? { ...x, spent: addSpent(x.spent, acc) } : x,\n ),\n };\n }\n\n for (const l of handoff.lessons ?? []) {\n const lid = `L${s.lessons.length + 1}`;\n s = {\n ...s,\n lessons: [\n ...s.lessons,\n { id: lid, at, text: l.text, scope: l.scope, status: \"raised\", from: role, item: id },\n ],\n };\n s = appendEvent(\n s,\n \"lesson.raised\",\n role,\n { id: lid, from: role, item: id, scope: l.scope },\n at,\n );\n }\n\n const followUps: string[] = [];\n for (const n of handoff.follow_ups ?? []) {\n const first = s.stages[0]!;\n const { iteration: _drop, ...rest } = n;\n s = addItem(\n s,\n { ...rest, stage: first.id, parent: id, tags: [...(n.tags ?? []), \"follow-up\"] },\n role,\n at,\n );\n followUps.push(n.id);\n }\n\n const verdict = handoff.verdict ?? \"done\";\n if (verdict === \"rework\") {\n if (!handoff.notes || handoff.notes.trim() === \"\")\n fail(\n \"handoff-invalid\",\n `rework on \"${id}\" needs notes`,\n \"say what must change in handoff.notes\",\n { items: [id] },\n );\n const item = getItem(s, id);\n s = clearRole(moveItem(s, id, { stage: reworkStage(s, item), status: \"todo\" }, role, at), id);\n s = appendEvent(s, \"item.rework\", role, { id, by: role, notes: handoff.notes }, at);\n } else if (\n (verdict === \"done\" || verdict === \"needs-review\") &&\n getItem(s, id).type === \"question\"\n ) {\n // a question is answered, not delivered: it skips exit policies and gates\n const lastStageId = s.stages[s.stages.length - 1]!.id;\n s = moveItem(s, id, { stage: lastStageId, status: \"done\" }, role, at);\n } else if (verdict === \"done\" || verdict === \"needs-review\") {\n const item = getItem(s, id);\n const stage = stageOf(s, item.stage);\n assertPolicies(s, item, stage.exitPolicy, `leave \"${stage.id}\"`);\n if (stage.gate) {\n const res = checkGate(s, item, stage.gate, role);\n if (res.outcome === \"fail\")\n fail(\n \"gate-unmet\",\n `gate \"${stage.gate.id}\" blocks \"${id}\": ${res.violations.map((v) => v.message).join(\"; \")}`,\n res.violations.map((v) => v.fix).join(\"; \"),\n { items: [id], rule: res.violations[0]!.rule },\n );\n if (res.outcome === \"human\") {\n s = raisePending(\n s,\n {\n kind: \"gate\",\n item: id,\n gate: stage.gate.id,\n question: `Approve gate \"${stage.gate.id}\" for \"${item.title}\" (${id})?`,\n },\n at,\n );\n } else {\n s = appendEvent(\n advanceItem(s, id, role, verdict === \"needs-review\", at),\n \"gate.passed\",\n role,\n { item: id, gate: stage.gate.id },\n at,\n );\n }\n } else {\n s = advanceItem(s, id, role, verdict === \"needs-review\", at);\n }\n } else if (verdict === \"blocked\") {\n s = raiseBlocker(s, id, handoff.notes || \"blocked by worker\", role, role, at);\n } else if (verdict === \"escalate\") {\n const thinker = rolesWith(s, \"escalate\")[0];\n if (!thinker)\n fail(\n \"missing-capability\",\n `no role has capability \"escalate\" to receive the question from \"${id}\"`,\n \"register a role with capability escalate\",\n { items: [id] },\n );\n const n = Object.keys(s.items).filter((k) => k.startsWith(`${id}-q`)).length + 1;\n const qid = `${id}-q${n}`;\n const parent = getItem(s, id);\n const pulledFrom = pulledFromStage(parent);\n const q: NewItem = {\n id: qid,\n type: \"question\",\n title: handoff.open_questions.join(\" | \") || handoff.notes || `question from ${id}`,\n parent: id,\n role: thinker.id,\n priority: Number.MAX_SAFE_INTEGER,\n stage: pulledFrom,\n };\n if (parent.iteration !== undefined) q.iteration = parent.iteration;\n s = addItem(s, q, role, at);\n s = moveItem(s, id, { stage: pulledFrom, status: \"todo\" }, role, at);\n s = patchItem(s, id, (x) => ({ ...x, dependsOn: [...x.dependsOn, qid] }));\n s = appendEvent(s, \"item.escalated\", role, { id, question: qid, to: thinker.id }, at);\n }\n\n s = appendEvent(\n s,\n \"item.completed\",\n role,\n {\n id,\n role,\n verdict,\n produced: handoff.produced,\n notes: handoff.notes,\n do_not: handoff.do_not,\n open_questions: handoff.open_questions,\n followUps,\n tokens: acc.tokensIn + acc.tokensOut,\n durationMs: acc.durationMs,\n model: acc.model,\n },\n at,\n );\n if (methodology.afterComplete) s = methodology.afterComplete(s, id, at);\n return { state: s, warnings: [] };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/brief.ts","../src/complete.ts"],"names":["completions","state","itemId","out","ev","lastCompletion","all","synthesizeBrief","methodology","item","fail","role","roleOf","upstream","doNot","sources","dep","p","d","priorHandoffs","touched","relatedBugs","b","a","it","openIteration","gate","stageOf","brief","remaining","next","opts","res","plan","briefs","VERDICTS","LESSON_SCOPES","isObj","x","str","validate","handoff","acc","getItem","bad","what","fix","verdict","lessons","l","followUps","f","k","pulledFromStage","i","reworkStage","lastDispatchBefore","complete","now","at","nowOf","id","s","addEvidence","addSpent","lid","appendEvent","n","first","_drop","rest","addItem","clearRole","moveItem","lastStageId","stage","assertPolicies","checkGate","v","raisePending","advanceItem","raiseBlocker","thinker","rolesWith","qid","parent","pulledFrom","q","patchItem"],"mappings":"wLAgBA,SAASA,EACPC,CAAAA,CACAC,CAAAA,CAC0C,CAC1C,IAAMC,CAAAA,CAAgD,EAAC,CACvD,IAAA,IAAWC,CAAAA,IAAMH,CAAAA,CAAM,OACjB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CAAAA,CAAIW,CAAAA,CAASX,EAAGD,GAAAA,CAAI,CAAE,MAAOyB,CAAAA,CAAY,MAAA,CAAQ,MAAO,CAAA,CAAG3E,CAAAA,CAAMgD,CAAE,CAAA,CACnEG,CAAAA,CAAI0B,CAAAA,CAAU1B,CAAAA,CAAGD,IAAKvB,CAAAA,GAAO,CAAE,GAAGA,CAAAA,CAAG,SAAA,CAAW,CAAC,GAAGA,CAAAA,CAAE,SAAA,CAAW8C,CAAG,CAAE,CAAA,CAAE,CAAA,CACxEtB,EAAII,GAAAA,CAAYJ,CAAAA,CAAG,iBAAkBnD,CAAAA,CAAM,CAAE,EAAA,CAAAkD,GAAAA,CAAI,SAAUuB,CAAAA,CAAK,EAAA,CAAIF,EAAQ,EAAG,CAAA,CAAGvB,CAAE,EACtF,CAEA,OAAAG,CAAAA,CAAII,GAAAA,CACFJ,EACA,gBAAA,CACAnD,CAAAA,CACA,CACE,EAAA,CAAAkD,GAAAA,CACA,KAAAlD,CAAAA,CACA,OAAA,CAAAoC,GAAAA,CACA,QAAA,CAAUN,EAAQ,QAAA,CAClB,KAAA,CAAOA,EAAQ,KAAA,CACf,MAAA,CAAQA,EAAQ,MAAA,CAChB,cAAA,CAAgBA,EAAQ,cAAA,CACxB,SAAA,CAAAS,EACA,MAAA,CAAQR,CAAAA,CAAI,SAAWA,CAAAA,CAAI,SAAA,CAC3B,WAAYA,CAAAA,CAAI,UAAA,CAChB,KAAA,CAAOA,CAAAA,CAAI,KACb,CAAA,CACAiB,CACF,EACInD,GAAAA,CAAY,aAAA,GAAesD,EAAItD,GAAAA,CAAY,aAAA,CAAcsD,EAAGD,GAAAA,CAAIF,CAAE,GAC/D,CAAE,KAAA,CAAOG,EAAG,QAAA,CAAU,EAAG,CAClC","file":"chunk-NZ2DIDOD.mjs","sourcesContent":["import { remaining } from \"./budget.ts\";\nimport { fail } from \"./errors.ts\";\nimport { stageOf } from \"./items.ts\";\nimport { openIteration, plan, type PlanOptions, type PlanReason, type Skipped } from \"./planner.ts\";\nimport { roleOf } from \"./roles.ts\";\nimport type { Brief, Handoff, Methodology, Verdict, WorkItem, WorkflowState } from \"./types.ts\";\n\ninterface CompletedPayload {\n id: string;\n role: string;\n verdict: Verdict;\n produced: Handoff[\"produced\"];\n notes: string;\n do_not: string[];\n}\n\nfunction completions(\n state: WorkflowState,\n itemId: string,\n): Array<CompletedPayload & { at: string }> {\n const out: Array<CompletedPayload & { at: string }> = [];\n for (const ev of state.events) {\n if (ev.type === \"item.completed\" && (ev.payload as CompletedPayload).id === itemId)\n out.push({ ...(ev.payload as CompletedPayload), at: ev.at });\n }\n return out;\n}\n\nfunction lastCompletion(state: WorkflowState, itemId: string): CompletedPayload | undefined {\n const all = completions(state, itemId);\n return all[all.length - 1];\n}\n\nexport function synthesizeBrief(\n state: WorkflowState,\n methodology: Methodology,\n item: WorkItem,\n): Brief {\n if (!item.role)\n fail(\n \"unknown-role\",\n `item \"${item.id}\" has no role assigned`,\n \"dispatch it with next() or set item.role\",\n { items: [item.id] },\n );\n const role = roleOf(state, item.role);\n if (!role)\n fail(\n \"unknown-role\",\n `role \"${item.role}\" does not exist`,\n `registered roles: ${Object.keys(state.roles).join(\", \")}`,\n );\n const upstream: Brief[\"upstream\"] = [];\n const doNot = [...role.do_not];\n const sources = [\n ...item.dependsOn,\n ...(item.type === \"bug\" || item.type === \"change-request\" ? (item.affects ?? []) : []),\n ];\n for (const dep of sources) {\n const p = lastCompletion(state, dep);\n if (!p) continue;\n upstream.push({ item: dep, produced: p.produced, notes: p.notes });\n for (const d of p.do_not) if (!doNot.includes(d)) doNot.push(d);\n }\n const priorHandoffs: Brief[\"priorHandoffs\"] = completions(state, item.id).map((p) => ({\n role: p.role,\n verdict: p.verdict,\n notes: p.notes,\n produced: p.produced,\n at: p.at,\n }));\n const touched = new Set([item.id, ...item.dependsOn]);\n const relatedBugs: Brief[\"relatedBugs\"] = Object.values(state.items)\n .filter(\n (b) =>\n (b.type === \"bug\" || b.type === \"change-request\") &&\n b.id !== item.id &&\n b.status !== \"done\" &&\n b.status !== \"dropped\" &&\n (b.affects ?? []).some((a) => touched.has(a)),\n )\n .map((b) => ({ id: b.id, title: b.title, affects: b.affects ?? [] }));\n const it = openIteration(state);\n const gate = stageOf(state, item.stage).gate;\n const brief: Brief = {\n item,\n role,\n modelTier: role.modelTier,\n invariants: [...methodology.invariants(state, item), ...state.agreements],\n do_not: doNot,\n acceptance: item.acceptance,\n upstream,\n priorHandoffs,\n relatedBugs,\n budgetRemaining: it ? remaining(it.budget, it.spent) : {},\n };\n if (gate) brief.gateAhead = gate;\n return brief;\n}\n\nexport interface NextResult {\n state: WorkflowState;\n briefs: Brief[];\n skipped: Skipped[];\n reason?: PlanReason;\n}\n\nexport function next(\n state: WorkflowState,\n methodology: Methodology,\n opts: PlanOptions = {},\n): NextResult {\n const res = plan(state, methodology, opts);\n const briefs = res.dispatched.map((d) =>\n synthesizeBrief(res.state, methodology, res.state.items[d.id]!),\n );\n return res.reason\n ? { state: res.state, briefs, skipped: res.skipped, reason: res.reason }\n : { state: res.state, briefs, skipped: res.skipped };\n}\n","import { addSpent } from \"./budget.ts\";\nimport { fail } from \"./errors.ts\";\nimport { checkGate, lastDispatchBefore, raisePending } from \"./gates.ts\";\nimport {\n addEvidence,\n addItem,\n advanceItem,\n clearRole,\n getItem,\n moveItem,\n patchItem,\n raiseBlocker,\n stageOf,\n} from \"./items.ts\";\nimport { assertPolicies } from \"./policies.ts\";\nimport { openIteration } from \"./planner.ts\";\nimport { rolesWith } from \"./roles.ts\";\nimport { appendEvent, nowOf } from \"./state.ts\";\nimport type {\n Accounting,\n ApplyResult,\n Handoff,\n Methodology,\n NewItem,\n WorkItem,\n WorkflowState,\n} from \"./types.ts\";\n\nconst VERDICTS: readonly string[] = [\"done\", \"needs-review\", \"rework\", \"blocked\", \"escalate\"];\nconst LESSON_SCOPES: readonly string[] = [\"policy\", \"skill\", \"memory\", \"spec\", \"review\"];\n\nconst isObj = (x: unknown): x is Record<string, unknown> =>\n typeof x === \"object\" && x !== null && !Array.isArray(x);\nconst str = (x: unknown) => typeof x === \"string\";\n\nfunction validate(state: WorkflowState, handoff: Handoff, acc: Accounting): void {\n const item = getItem(state, handoff.item);\n if (item.status !== \"in_progress\")\n fail(\n \"invalid-transition\",\n `item \"${item.id}\" is ${item.status}, not in_progress`,\n \"only dispatched items can be completed; call next() first\",\n { items: [item.id] },\n );\n if (!Array.isArray(handoff.do_not))\n fail(\n \"handoff-invalid\",\n `handoff for \"${item.id}\" has no do_not array`,\n \"set handoff.do_not to [] when there is nothing to forbid\",\n { items: [item.id] },\n );\n if (!Array.isArray(handoff.produced) || !Array.isArray(handoff.open_questions))\n fail(\n \"handoff-invalid\",\n `handoff for \"${item.id}\" needs produced[] and open_questions[]`,\n \"pass empty arrays when there is nothing\",\n { items: [item.id] },\n );\n const bad = (what: string, fix: string) =>\n fail(\"handoff-invalid\", `handoff for \"${item.id}\": ${what}`, fix, { items: [item.id] });\n const verdict = handoff.verdict ?? \"done\";\n if (!VERDICTS.includes(verdict))\n bad(`unknown verdict ${JSON.stringify(verdict)}`, `use one of: ${VERDICTS.join(\", \")}`);\n if (!handoff.produced.every((p) => isObj(p) && str(p.kind) && str(p.ref)))\n bad(\"produced[] entries need string kind and ref\", 'use { \"kind\": \"code\", \"ref\": \"src/a.ts\" }');\n const lessons: unknown = handoff.lessons ?? [];\n if (\n !Array.isArray(lessons) ||\n !lessons.every((l) => isObj(l) && str(l.text) && LESSON_SCOPES.includes(l.scope as string))\n )\n bad(\n \"lessons[] entries need a text and a scope\",\n `scope is one of: ${LESSON_SCOPES.join(\", \")}`,\n );\n const followUps: unknown = handoff.follow_ups ?? [];\n if (!Array.isArray(followUps) || !followUps.every((f) => isObj(f) && str(f.id) && str(f.title)))\n bad(\"follow_ups[] entries need a string id and title\", \"describe each follow-up as a new item\");\n if (handoff.role !== item.role)\n fail(\n \"handoff-invalid\",\n `handoff role \"${handoff.role}\" differs from the dispatched role \"${item.role}\"`,\n `complete as \"${item.role}\" or re-dispatch`,\n { items: [item.id] },\n );\n if (!acc.model || acc.model.trim() === \"\")\n fail(\n \"accounting-invalid\",\n `accounting for \"${item.id}\" has no model`,\n \"record the model id that actually ran the work\",\n { items: [item.id] },\n );\n for (const k of [\"tokensIn\", \"tokensOut\", \"durationMs\"] as const) {\n if (!Number.isFinite(acc[k]) || acc[k] < 0)\n fail(\n \"accounting-invalid\",\n `accounting.${k} must be a non-negative number`,\n `measure ${k} from the host's usage report`,\n { items: [item.id] },\n );\n }\n}\n\n/** Stage the item was pulled from: the `from.stage` of its last transition into in_progress, else its current stage. */\nfunction pulledFromStage(item: WorkItem): string {\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.from.stage;\n }\n return item.stage;\n}\n\n/** Stage a reworked item returns to: the from.stage of the last dispatch made from a stage strictly before the current one (so a reviewer's rework lands where the work was pulled from), else the plain pulled-from stage. */\nfunction reworkStage(state: WorkflowState, item: WorkItem): string {\n return lastDispatchBefore(state, item)?.from.stage ?? pulledFromStage(item);\n}\n\nexport function complete(\n state: WorkflowState,\n methodology: Methodology,\n handoff: Handoff,\n acc: Accounting,\n now?: string,\n): ApplyResult {\n validate(state, handoff, acc);\n const at = nowOf(now);\n const id = handoff.item;\n const role = handoff.role;\n let s: WorkflowState = { ...state, accounting: [...state.accounting, acc] };\n for (const p of handoff.produced)\n s = addEvidence(s, id, { kind: p.kind, ref: p.ref, by: role }, at);\n const it = openIteration(s);\n if (it && (it.committed.includes(id) || getItem(s, id).iteration === it.id)) {\n s = {\n ...s,\n iterations: s.iterations.map((x) =>\n x.id === it.id ? { ...x, spent: addSpent(x.spent, acc) } : x,\n ),\n };\n }\n\n for (const l of handoff.lessons ?? []) {\n const lid = `L${s.lessons.length + 1}`;\n s = {\n ...s,\n lessons: [\n ...s.lessons,\n { id: lid, at, text: l.text, scope: l.scope, status: \"raised\", from: role, item: id },\n ],\n };\n s = appendEvent(\n s,\n \"lesson.raised\",\n role,\n { id: lid, from: role, item: id, scope: l.scope },\n at,\n );\n }\n\n const followUps: string[] = [];\n for (const n of handoff.follow_ups ?? []) {\n const first = s.stages[0]!;\n const { iteration: _drop, ...rest } = n;\n s = addItem(\n s,\n { ...rest, stage: first.id, parent: id, tags: [...(n.tags ?? []), \"follow-up\"] },\n role,\n at,\n );\n followUps.push(n.id);\n }\n\n const verdict = handoff.verdict ?? \"done\";\n if (verdict === \"rework\") {\n if (!handoff.notes || handoff.notes.trim() === \"\")\n fail(\n \"handoff-invalid\",\n `rework on \"${id}\" needs notes`,\n \"say what must change in handoff.notes\",\n { items: [id] },\n );\n const item = getItem(s, id);\n s = clearRole(moveItem(s, id, { stage: reworkStage(s, item), status: \"todo\" }, role, at), id);\n s = appendEvent(s, \"item.rework\", role, { id, by: role, notes: handoff.notes }, at);\n } else if (\n (verdict === \"done\" || verdict === \"needs-review\") &&\n getItem(s, id).type === \"question\"\n ) {\n // a question is answered, not delivered: it skips exit policies and gates\n const lastStageId = s.stages[s.stages.length - 1]!.id;\n s = moveItem(s, id, { stage: lastStageId, status: \"done\" }, role, at);\n } else if (verdict === \"done\" || verdict === \"needs-review\") {\n const item = getItem(s, id);\n const stage = stageOf(s, item.stage);\n assertPolicies(s, item, stage.exitPolicy, `leave \"${stage.id}\"`);\n if (stage.gate) {\n const res = checkGate(s, item, stage.gate, role);\n if (res.outcome === \"fail\")\n fail(\n \"gate-unmet\",\n `gate \"${stage.gate.id}\" blocks \"${id}\": ${res.violations.map((v) => v.message).join(\"; \")}`,\n res.violations.map((v) => v.fix).join(\"; \"),\n { items: [id], rule: res.violations[0]!.rule },\n );\n if (res.outcome === \"human\") {\n s = raisePending(\n s,\n {\n kind: \"gate\",\n item: id,\n gate: stage.gate.id,\n question: `Approve gate \"${stage.gate.id}\" for \"${item.title}\" (${id})?`,\n },\n at,\n );\n } else {\n s = appendEvent(\n advanceItem(s, id, role, verdict === \"needs-review\", at),\n \"gate.passed\",\n role,\n { item: id, gate: stage.gate.id },\n at,\n );\n }\n } else {\n s = advanceItem(s, id, role, verdict === \"needs-review\", at);\n }\n } else if (verdict === \"blocked\") {\n s = raiseBlocker(s, id, handoff.notes || \"blocked by worker\", role, role, at);\n } else if (verdict === \"escalate\") {\n const thinker = rolesWith(s, \"escalate\")[0];\n if (!thinker)\n fail(\n \"missing-capability\",\n `no role has capability \"escalate\" to receive the question from \"${id}\"`,\n \"register a role with capability escalate\",\n { items: [id] },\n );\n const n = Object.keys(s.items).filter((k) => k.startsWith(`${id}-q`)).length + 1;\n const qid = `${id}-q${n}`;\n const parent = getItem(s, id);\n const pulledFrom = pulledFromStage(parent);\n const q: NewItem = {\n id: qid,\n type: \"question\",\n title: handoff.open_questions.join(\" | \") || handoff.notes || `question from ${id}`,\n parent: id,\n role: thinker.id,\n priority: Number.MAX_SAFE_INTEGER,\n stage: pulledFrom,\n };\n if (parent.iteration !== undefined) q.iteration = parent.iteration;\n s = addItem(s, q, role, at);\n s = moveItem(s, id, { stage: pulledFrom, status: \"todo\" }, role, at);\n s = patchItem(s, id, (x) => ({ ...x, dependsOn: [...x.dependsOn, qid] }));\n s = appendEvent(s, \"item.escalated\", role, { id, question: qid, to: thinker.id }, at);\n }\n\n s = appendEvent(\n s,\n \"item.completed\",\n role,\n {\n id,\n role,\n verdict,\n produced: handoff.produced,\n notes: handoff.notes,\n do_not: handoff.do_not,\n open_questions: handoff.open_questions,\n followUps,\n tokens: acc.tokensIn + acc.tokensOut,\n durationMs: acc.durationMs,\n model: acc.model,\n },\n at,\n );\n if (methodology.afterComplete) s = methodology.afterComplete(s, id, at);\n return { state: s, warnings: [] };\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {b as b$1,d,e}from'./chunk-S22CPYXJ.mjs';import {b}from'./chunk-2FRRD6A3.mjs';import {mkdir,open,stat,unlink,readFile,readdir,writeFile,rename}from'fs/promises';import {randomBytes}from'crypto';import n from'path';var f=".workflow";function v(t){return n.join(t,f,"state.json")}async function y(t,e){let i=`${t}.tmp-${process.pid}-${randomBytes(4).toString("hex")}`;try{await mkdir(n.dirname(t),{recursive:!0}),await writeFile(i,e,"utf8"),await rename(i,t);}catch(r){await unlink(i).catch(()=>{}),b("invalid-input",`cannot write ${t}: ${r.message}`,"check the directory exists and is writable");}}async function T(t,e,i={}){let{retries:r=40,intervalMs:l=50,staleMs:d=6e4}=i,a=n.join(t,f,"state.lock");await mkdir(n.dirname(a),{recursive:true});let m=false;for(let c=0;!m;c++)try{let o=await open(a,"wx");await o.writeFile(`${process.pid} ${new Date().toISOString()}
|
|
2
|
+
`),await o.close(),m=!0;}catch(o){if(o.code!=="EEXIST")throw o;if(await stat(a).then(u=>Date.now()-u.mtimeMs,()=>0)>d){await unlink(a).catch(()=>{});continue}c>=r&&b("invalid-input","another exwf command holds .workflow/state.lock","retry, or delete the file if no exwf process is running"),await new Promise(u=>setTimeout(u,l));}try{return await e()}finally{await unlink(a).catch(()=>{});}}async function B(t,e){let i=JSON.stringify(e,null,2)+`
|
|
3
|
+
`;b$1(d,JSON.parse(i),v(t)),await y(v(t),i);}async function F(t){let e$1=v(t),i;try{i=await readFile(e$1,"utf8");}catch{b("invalid-input",`no workflow state at ${e$1}`,"run `exwf init <scrum|kanban|waterfall> --config <file>` in this directory first");}let r;try{r=JSON.parse(i);}catch(c){b("invalid-input",`${e$1} is not valid JSON: ${c.message}`,"restore it from git or re-run exwf init");}(typeof r!="object"||r===null||Array.isArray(r))&&b("invalid-input",`${e$1} does not contain a workflow state object`,"restore it from git or re-run exwf init");let l=r;l.version!==1&&b("state-version",`${e$1} has schema version ${String(l.version)}; this ex-workflow reads version 1`,"upgrade ex-workflow, or run the migration this version documents in its changelog"),b$1(d,r,e$1);let d$1=n.join(t,f,"roles"),a=[];try{a=(await readdir(d$1)).filter(c=>c.endsWith(".json"));}catch{}let m={...l.roles};for(let c of a){let o=n.join(d$1,c),w;try{w=JSON.parse(await readFile(o,"utf8"));}catch(u){b("invalid-input",`role manifest ${o} is not valid JSON: ${u.message}`,"fix or delete that manifest");}b$1(e,w,`role manifest ${o}`),m[w.id]||(m[w.id]=w);}return {...l,roles:m}}function x(t,e){return n.resolve(e).startsWith(n.resolve(t,f)+n.sep)||b("invalid-input",`${e} resolves outside ${f}/`,"use a plain item id (letters, digits, - _ .)"),e}async function L(t,e){let i=x(t,n.join(t,f,"briefs",`${e.item.id}.json`));return await y(i,JSON.stringify(e,null,2)+`
|
|
4
|
+
`),i}async function A(t,e,i){let r=x(t,n.join(t,f,"handoffs",`${e.item}-${i}.json`));return await y(r,JSON.stringify(e,null,2)+`
|
|
5
|
+
`),r}export{f as a,v as b,T as c,B as d,F as e,L as f,A as g};//# sourceMappingURL=chunk-OHSQ52DW.mjs.map
|
|
6
|
+
//# sourceMappingURL=chunk-OHSQ52DW.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/file.ts"],"names":["WORKFLOW_DIR","statePath","root","path","writeAtomic","file","content","tmp","randomBytes","mkdir","writeFile","rename","e","unlink","fail","withStateLock","fn","opts","retries","intervalMs","staleMs","lock","held","attempt","fh","open","stat","st","resolve","saveState","state","json","assertValid","workflowStateSchema","loadState","raw","readFile","parsed","rolesDir","manifests","readdir","f","roles","manifestPath","role","roleSchema","inWorkflowDir","saveBrief","brief","saveHandoff","handoff","seq"],"mappings":"6NAOO,IAAMA,EAAe,YAErB,SAASC,EAAUC,CAAAA,CAAsB,CAC9C,OAAOC,CAAAA,CAAK,KAAKD,CAAAA,CAAMF,CAAAA,CAAc,YAAY,CACnD,CAEA,eAAeI,CAAAA,CAAYC,CAAAA,CAAcC,CAAAA,CAAgC,CACvE,IAAMC,CAAAA,CAAM,CAAA,EAAGF,CAAI,CAAA,KAAA,EAAQ,OAAA,CAAQ,GAAG,CAAA,CAAA,EAAIG,WAAAA,CAAY,CAAC,CAAA,CAAE,SAAS,KAAK,CAAC,GACxE,GAAI,CACF,MAAMC,KAAAA,CAAMN,CAAAA,CAAK,O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,CAAK,KAAKD,CAAAA,CAAMF,CAAAA,CAAc,UAAA,CAAY,CAAA,EAAGkD,CAAAA,CAAQ,IAAI,CAAA,CAAA,EAAIC,CAAG,OAAO,CACzE,CAAA,CACA,OAAA,MAAM/C,CAAAA,CAAYC,EAAM,IAAA,CAAK,SAAA,CAAU6C,CAAAA,CAAS,IAAA,CAAM,CAAC,CAAA,CAAI;AAAA,CAAI,EACxD7C,CACT","file":"chunk-OHSQ52DW.mjs","sourcesContent":["import { mkdir, open, readFile, readdir, rename, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { randomBytes } from \"node:crypto\";\nimport path from \"node:path\";\nimport { fail } from \"../errors.ts\";\nimport { assertValid, roleSchema, workflowStateSchema } from \"../schema/index.ts\";\nimport type { Brief, Handoff, Role, WorkflowState } from \"../types.ts\";\n\nexport const WORKFLOW_DIR = \".workflow\";\n\nexport function statePath(root: string): string {\n return path.join(root, WORKFLOW_DIR, \"state.json\");\n}\n\nasync function writeAtomic(file: string, content: string): Promise<void> {\n const tmp = `${file}.tmp-${process.pid}-${randomBytes(4).toString(\"hex\")}`;\n try {\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(tmp, content, \"utf8\");\n await rename(tmp, file);\n } catch (e) {\n // best effort: remove the temp file if it was created; ignore failure\n await unlink(tmp).catch(() => undefined);\n fail(\n \"invalid-input\",\n `cannot write ${file}: ${(e as Error).message}`,\n \"check the directory exists and is writable\",\n );\n }\n}\n\nexport interface LockOptions {\n retries?: number;\n intervalMs?: number;\n staleMs?: number;\n}\n\n/** Run `fn` while holding `.workflow/state.lock`, so concurrent exwf commands cannot lose each other's updates. */\nexport async function withStateLock<T>(\n root: string,\n fn: () => Promise<T>,\n opts: LockOptions = {},\n): Promise<T> {\n const { retries = 40, intervalMs = 50, staleMs = 60_000 } = opts;\n const lock = path.join(root, WORKFLOW_DIR, \"state.lock\");\n await mkdir(path.dirname(lock), { recursive: true });\n let held = false;\n for (let attempt = 0; !held; attempt++) {\n try {\n const fh = await open(lock, \"wx\");\n await fh.writeFile(`${process.pid} ${new Date().toISOString()}\\n`);\n await fh.close();\n held = true;\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code !== \"EEXIST\") throw e;\n const age = await stat(lock).then(\n (st) => Date.now() - st.mtimeMs,\n () => 0,\n );\n if (age > staleMs) {\n await unlink(lock).catch(() => undefined);\n continue;\n }\n if (attempt >= retries)\n fail(\n \"invalid-input\",\n \"another exwf command holds .workflow/state.lock\",\n \"retry, or delete the file if no exwf process is running\",\n );\n await new Promise((resolve) => setTimeout(resolve, intervalMs));\n }\n }\n try {\n return await fn();\n } finally {\n await unlink(lock).catch(() => undefined);\n }\n}\n\nexport async function saveState(root: string, state: WorkflowState): Promise<void> {\n const json = JSON.stringify(state, null, 2) + \"\\n\";\n assertValid(workflowStateSchema, JSON.parse(json), statePath(root));\n await writeAtomic(statePath(root), json);\n}\n\nexport async function loadState(root: string): Promise<WorkflowState> {\n const file = statePath(root);\n let raw: string;\n try {\n raw = await readFile(file, \"utf8\");\n } catch {\n fail(\n \"invalid-input\",\n `no workflow state at ${file}`,\n \"run `exwf init <scrum|kanban|waterfall> --config <file>` in this directory first\",\n );\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (e) {\n fail(\n \"invalid-input\",\n `${file} is not valid JSON: ${(e as Error).message}`,\n \"restore it from git or re-run exwf init\",\n );\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n fail(\n \"invalid-input\",\n `${file} does not contain a workflow state object`,\n \"restore it from git or re-run exwf init\",\n );\n }\n const state = parsed as WorkflowState;\n if (state.version !== 1)\n fail(\n \"state-version\",\n `${file} has schema version ${String(state.version)}; this ex-workflow reads version 1`,\n \"upgrade ex-workflow, or run the migration this version documents in its changelog\",\n );\n assertValid(workflowStateSchema, parsed, file);\n const rolesDir = path.join(root, WORKFLOW_DIR, \"roles\");\n let manifests: string[] = [];\n try {\n manifests = (await readdir(rolesDir)).filter((f) => f.endsWith(\".json\"));\n } catch {\n /* no extra roles */\n }\n const roles = { ...state.roles };\n for (const f of manifests) {\n const manifestPath = path.join(rolesDir, f);\n let role: Role;\n try {\n role = JSON.parse(await readFile(manifestPath, \"utf8\")) as Role;\n } catch (e) {\n fail(\n \"invalid-input\",\n `role manifest ${manifestPath} is not valid JSON: ${(e as Error).message}`,\n \"fix or delete that manifest\",\n );\n }\n assertValid(roleSchema, role, `role manifest ${manifestPath}`);\n if (!roles[role.id]) roles[role.id] = role;\n }\n return { ...state, roles };\n}\n\nfunction inWorkflowDir(root: string, file: string): string {\n if (!path.resolve(file).startsWith(path.resolve(root, WORKFLOW_DIR) + path.sep))\n fail(\n \"invalid-input\",\n `${file} resolves outside ${WORKFLOW_DIR}/`,\n \"use a plain item id (letters, digits, - _ .)\",\n );\n return file;\n}\n\nexport async function saveBrief(root: string, brief: Brief): Promise<string> {\n const file = inWorkflowDir(\n root,\n path.join(root, WORKFLOW_DIR, \"briefs\", `${brief.item.id}.json`),\n );\n await writeAtomic(file, JSON.stringify(brief, null, 2) + \"\\n\");\n return file;\n}\n\nexport async function saveHandoff(root: string, handoff: Handoff, seq: number): Promise<string> {\n const file = inWorkflowDir(\n root,\n path.join(root, WORKFLOW_DIR, \"handoffs\", `${handoff.item}-${seq}.json`),\n );\n await writeAtomic(file, JSON.stringify(handoff, null, 2) + \"\\n\");\n return file;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';var chunkDXC2RSN5_cjs=require('./chunk-DXC2RSN5.cjs'),chunkS3BXVHO7_cjs=require('./chunk-S3BXVHO7.cjs'),promises=require('fs/promises'),crypto=require('crypto'),n=require('path');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var n__default=/*#__PURE__*/_interopDefault(n);var f=".workflow";function v(t){return n__default.default.join(t,f,"state.json")}async function y(t,e){let i=`${t}.tmp-${process.pid}-${crypto.randomBytes(4).toString("hex")}`;try{await promises.mkdir(n__default.default.dirname(t),{recursive:!0}),await promises.writeFile(i,e,"utf8"),await promises.rename(i,t);}catch(r){await promises.unlink(i).catch(()=>{}),chunkS3BXVHO7_cjs.b("invalid-input",`cannot write ${t}: ${r.message}`,"check the directory exists and is writable");}}async function T(t,e,i={}){let{retries:r=40,intervalMs:l=50,staleMs:d=6e4}=i,a=n__default.default.join(t,f,"state.lock");await promises.mkdir(n__default.default.dirname(a),{recursive:true});let m=false;for(let c=0;!m;c++)try{let o=await promises.open(a,"wx");await o.writeFile(`${process.pid} ${new Date().toISOString()}
|
|
2
|
+
`),await o.close(),m=!0;}catch(o){if(o.code!=="EEXIST")throw o;if(await promises.stat(a).then(u=>Date.now()-u.mtimeMs,()=>0)>d){await promises.unlink(a).catch(()=>{});continue}c>=r&&chunkS3BXVHO7_cjs.b("invalid-input","another exwf command holds .workflow/state.lock","retry, or delete the file if no exwf process is running"),await new Promise(u=>setTimeout(u,l));}try{return await e()}finally{await promises.unlink(a).catch(()=>{});}}async function B(t,e){let i=JSON.stringify(e,null,2)+`
|
|
3
|
+
`;chunkDXC2RSN5_cjs.b(chunkDXC2RSN5_cjs.d,JSON.parse(i),v(t)),await y(v(t),i);}async function F(t){let e=v(t),i;try{i=await promises.readFile(e,"utf8");}catch{chunkS3BXVHO7_cjs.b("invalid-input",`no workflow state at ${e}`,"run `exwf init <scrum|kanban|waterfall> --config <file>` in this directory first");}let r;try{r=JSON.parse(i);}catch(c){chunkS3BXVHO7_cjs.b("invalid-input",`${e} is not valid JSON: ${c.message}`,"restore it from git or re-run exwf init");}(typeof r!="object"||r===null||Array.isArray(r))&&chunkS3BXVHO7_cjs.b("invalid-input",`${e} does not contain a workflow state object`,"restore it from git or re-run exwf init");let l=r;l.version!==1&&chunkS3BXVHO7_cjs.b("state-version",`${e} has schema version ${String(l.version)}; this ex-workflow reads version 1`,"upgrade ex-workflow, or run the migration this version documents in its changelog"),chunkDXC2RSN5_cjs.b(chunkDXC2RSN5_cjs.d,r,e);let d=n__default.default.join(t,f,"roles"),a=[];try{a=(await promises.readdir(d)).filter(c=>c.endsWith(".json"));}catch{}let m={...l.roles};for(let c of a){let o=n__default.default.join(d,c),w;try{w=JSON.parse(await promises.readFile(o,"utf8"));}catch(u){chunkS3BXVHO7_cjs.b("invalid-input",`role manifest ${o} is not valid JSON: ${u.message}`,"fix or delete that manifest");}chunkDXC2RSN5_cjs.b(chunkDXC2RSN5_cjs.e,w,`role manifest ${o}`),m[w.id]||(m[w.id]=w);}return {...l,roles:m}}function x(t,e){return n__default.default.resolve(e).startsWith(n__default.default.resolve(t,f)+n__default.default.sep)||chunkS3BXVHO7_cjs.b("invalid-input",`${e} resolves outside ${f}/`,"use a plain item id (letters, digits, - _ .)"),e}async function L(t,e){let i=x(t,n__default.default.join(t,f,"briefs",`${e.item.id}.json`));return await y(i,JSON.stringify(e,null,2)+`
|
|
4
|
+
`),i}async function A(t,e,i){let r=x(t,n__default.default.join(t,f,"handoffs",`${e.item}-${i}.json`));return await y(r,JSON.stringify(e,null,2)+`
|
|
5
|
+
`),r}exports.a=f;exports.b=v;exports.c=T;exports.d=B;exports.e=F;exports.f=L;exports.g=A;//# sourceMappingURL=chunk-RSKZVOYC.cjs.map
|
|
6
|
+
//# sourceMappingURL=chunk-RSKZVOYC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/file.ts"],"names":["WORKFLOW_DIR","statePath","root","path","writeAtomic","file","content","tmp","randomBytes","mkdir","writeFile","rename","e","unlink","fail","withStateLock","fn","opts","retries","intervalMs","staleMs","lock","held","attempt","fh","open","stat","st","resolve","saveState","state","json","assertValid","workflowStateSchema","loadState","raw","readFile","parsed","rolesDir","manifests","readdir","f","roles","manifestPath","role","roleSchema","inWorkflowDir","saveBrief","brief","saveHandoff","handoff","seq"],"mappings":"gTAOO,IAAMA,EAAe,YAErB,SAASC,EAAUC,CAAAA,CAAsB,CAC9C,OAAOC,kBAAAA,CAAK,KAAKD,CAAAA,CAAMF,CAAAA,CAAc,YAAY,CACnD,CAEA,eA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AAA,CACA,OAAA,MAAM5C,CAAAA,CAAYC,CAAAA,CAAM,IAAA,CAAK,SAAA,CAAU2C,CAAAA,CAAO,IAAA,CAAM,CAAC,CAAA,CAAI;AAAA,CAAI,CAAA,CACtD3C,CACT,CAEA,eAAsB4C,EAAY/C,CAAAA,CAAcgD,CAAAA,CAAkBC,CAAAA,CAA8B,CAC9F,IAAM9C,CAAAA,CAAOyC,CAAAA,CACX5C,CAAAA,CACAC,kBAAAA,CAAK,KAAKD,CAAAA,CAAMF,CAAAA,CAAc,UAAA,CAAY,CAAA,EAAGkD,CAAAA,CAAQ,IAAI,CAAA,CAAA,EAAIC,CAAG,OAAO,CACzE,CAAA,CACA,OAAA,MAAM/C,CAAAA,CAAYC,EAAM,IAAA,CAAK,SAAA,CAAU6C,CAAAA,CAAS,IAAA,CAAM,CAAC,CAAA,CAAI;AAAA,CAAI,EACxD7C,CACT","file":"chunk-RSKZVOYC.cjs","sourcesContent":["import { mkdir, open, readFile, readdir, rename, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { randomBytes } from \"node:crypto\";\nimport path from \"node:path\";\nimport { fail } from \"../errors.ts\";\nimport { assertValid, roleSchema, workflowStateSchema } from \"../schema/index.ts\";\nimport type { Brief, Handoff, Role, WorkflowState } from \"../types.ts\";\n\nexport const WORKFLOW_DIR = \".workflow\";\n\nexport function statePath(root: string): string {\n return path.join(root, WORKFLOW_DIR, \"state.json\");\n}\n\nasync function writeAtomic(file: string, content: string): Promise<void> {\n const tmp = `${file}.tmp-${process.pid}-${randomBytes(4).toString(\"hex\")}`;\n try {\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(tmp, content, \"utf8\");\n await rename(tmp, file);\n } catch (e) {\n // best effort: remove the temp file if it was created; ignore failure\n await unlink(tmp).catch(() => undefined);\n fail(\n \"invalid-input\",\n `cannot write ${file}: ${(e as Error).message}`,\n \"check the directory exists and is writable\",\n );\n }\n}\n\nexport interface LockOptions {\n retries?: number;\n intervalMs?: number;\n staleMs?: number;\n}\n\n/** Run `fn` while holding `.workflow/state.lock`, so concurrent exwf commands cannot lose each other's updates. */\nexport async function withStateLock<T>(\n root: string,\n fn: () => Promise<T>,\n opts: LockOptions = {},\n): Promise<T> {\n const { retries = 40, intervalMs = 50, staleMs = 60_000 } = opts;\n const lock = path.join(root, WORKFLOW_DIR, \"state.lock\");\n await mkdir(path.dirname(lock), { recursive: true });\n let held = false;\n for (let attempt = 0; !held; attempt++) {\n try {\n const fh = await open(lock, \"wx\");\n await fh.writeFile(`${process.pid} ${new Date().toISOString()}\\n`);\n await fh.close();\n held = true;\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code !== \"EEXIST\") throw e;\n const age = await stat(lock).then(\n (st) => Date.now() - st.mtimeMs,\n () => 0,\n );\n if (age > staleMs) {\n await unlink(lock).catch(() => undefined);\n continue;\n }\n if (attempt >= retries)\n fail(\n \"invalid-input\",\n \"another exwf command holds .workflow/state.lock\",\n \"retry, or delete the file if no exwf process is running\",\n );\n await new Promise((resolve) => setTimeout(resolve, intervalMs));\n }\n }\n try {\n return await fn();\n } finally {\n await unlink(lock).catch(() => undefined);\n }\n}\n\nexport async function saveState(root: string, state: WorkflowState): Promise<void> {\n const json = JSON.stringify(state, null, 2) + \"\\n\";\n assertValid(workflowStateSchema, JSON.parse(json), statePath(root));\n await writeAtomic(statePath(root), json);\n}\n\nexport async function loadState(root: string): Promise<WorkflowState> {\n const file = statePath(root);\n let raw: string;\n try {\n raw = await readFile(file, \"utf8\");\n } catch {\n fail(\n \"invalid-input\",\n `no workflow state at ${file}`,\n \"run `exwf init <scrum|kanban|waterfall> --config <file>` in this directory first\",\n );\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (e) {\n fail(\n \"invalid-input\",\n `${file} is not valid JSON: ${(e as Error).message}`,\n \"restore it from git or re-run exwf init\",\n );\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n fail(\n \"invalid-input\",\n `${file} does not contain a workflow state object`,\n \"restore it from git or re-run exwf init\",\n );\n }\n const state = parsed as WorkflowState;\n if (state.version !== 1)\n fail(\n \"state-version\",\n `${file} has schema version ${String(state.version)}; this ex-workflow reads version 1`,\n \"upgrade ex-workflow, or run the migration this version documents in its changelog\",\n );\n assertValid(workflowStateSchema, parsed, file);\n const rolesDir = path.join(root, WORKFLOW_DIR, \"roles\");\n let manifests: string[] = [];\n try {\n manifests = (await readdir(rolesDir)).filter((f) => f.endsWith(\".json\"));\n } catch {\n /* no extra roles */\n }\n const roles = { ...state.roles };\n for (const f of manifests) {\n const manifestPath = path.join(rolesDir, f);\n let role: Role;\n try {\n role = JSON.parse(await readFile(manifestPath, \"utf8\")) as Role;\n } catch (e) {\n fail(\n \"invalid-input\",\n `role manifest ${manifestPath} is not valid JSON: ${(e as Error).message}`,\n \"fix or delete that manifest\",\n );\n }\n assertValid(roleSchema, role, `role manifest ${manifestPath}`);\n if (!roles[role.id]) roles[role.id] = role;\n }\n return { ...state, roles };\n}\n\nfunction inWorkflowDir(root: string, file: string): string {\n if (!path.resolve(file).startsWith(path.resolve(root, WORKFLOW_DIR) + path.sep))\n fail(\n \"invalid-input\",\n `${file} resolves outside ${WORKFLOW_DIR}/`,\n \"use a plain item id (letters, digits, - _ .)\",\n );\n return file;\n}\n\nexport async function saveBrief(root: string, brief: Brief): Promise<string> {\n const file = inWorkflowDir(\n root,\n path.join(root, WORKFLOW_DIR, \"briefs\", `${brief.item.id}.json`),\n );\n await writeAtomic(file, JSON.stringify(brief, null, 2) + \"\\n\");\n return file;\n}\n\nexport async function saveHandoff(root: string, handoff: Handoff, seq: number): Promise<string> {\n const file = inWorkflowDir(\n root,\n path.join(root, WORKFLOW_DIR, \"handoffs\", `${handoff.item}-${seq}.json`),\n );\n await writeAtomic(file, JSON.stringify(handoff, null, 2) + \"\\n\");\n return file;\n}\n"]}
|
|
@@ -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","k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,CAAAA,CAAM,QAAQ,CAAA,QAAA,EAAWA,CAAAA,CAAM,KAAK,CAAA,CAChF,EACF,CC3MO,IAAMuB,CAAAA,CAAW,0CAExB,SAASC,CAAAA,CAASjC,CAAAA,CAAckC,CAAAA,CAA6D,CAC3F,OAAO,CAAE,OAAA,CAASF,CAAAA,CAAU,IAAA,CAAM,CAAA,cAAA,EAAiBhC,CAAI,CAAA,CAAA,CAAI,WAAA,CAAAkC,CAAY,CACzE,CAGO,IAAMC,CAAAA,CAAsBF,CAAAA,CAAS,eAAA,CAAiB3D,CAAgB,CAAA,CAEhE8D,CAAAA,CAAaH,CAAAA,CAAS,MAAA,CAAQ3D,CAAgB,CAAA,CAE9C+D,CAAAA,CAAgBJ,CAAAA,CAAS,SAAA,CAAW3D,CAAgB,CAAA,CAEpDgE,CAAAA,CAAkBL,CAAAA,CAAS,WAAA,CAAa3D,CAAgB,CAAA,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"]}
|