ex-workflow 0.4.0-stage → 0.6.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +43 -2
  2. package/README.md +58 -28
  3. package/dist/adapters/index.cjs +1 -1
  4. package/dist/adapters/index.mjs +1 -1
  5. package/dist/{roles-BLBRKhUZ.d.ts → budget-Cx63FX2K.d.ts} +9 -2
  6. package/dist/{roles-aneKYJ3Z.d.cts → budget-JyNKxP5N.d.cts} +9 -2
  7. package/dist/{chunk-UM5X2JHB.cjs → chunk-2OVYXXNV.cjs} +2 -2
  8. package/dist/chunk-2OVYXXNV.cjs.map +1 -0
  9. package/dist/chunk-3CLDZCHN.cjs +2 -0
  10. package/dist/chunk-3CLDZCHN.cjs.map +1 -0
  11. package/dist/chunk-5TXYMLBF.mjs +3 -0
  12. package/dist/chunk-5TXYMLBF.mjs.map +1 -0
  13. package/dist/chunk-7CDGPTEJ.mjs +2 -0
  14. package/dist/chunk-7CDGPTEJ.mjs.map +1 -0
  15. package/dist/chunk-7IG6EQI4.mjs +6 -0
  16. package/dist/chunk-7IG6EQI4.mjs.map +1 -0
  17. package/dist/chunk-GT57PLUT.mjs +2 -0
  18. package/dist/chunk-GT57PLUT.mjs.map +1 -0
  19. package/dist/chunk-IHE5K4X3.mjs +2 -0
  20. package/dist/chunk-IHE5K4X3.mjs.map +1 -0
  21. package/dist/chunk-KF5VQH3M.mjs +2 -0
  22. package/dist/chunk-KF5VQH3M.mjs.map +1 -0
  23. package/dist/chunk-MH66G5KV.cjs +2 -0
  24. package/dist/chunk-MH66G5KV.cjs.map +1 -0
  25. package/dist/chunk-N3QB2S7R.cjs +2 -0
  26. package/dist/chunk-N3QB2S7R.cjs.map +1 -0
  27. package/dist/chunk-NA53TZE4.mjs +2 -0
  28. package/dist/chunk-NA53TZE4.mjs.map +1 -0
  29. package/dist/chunk-TEPK5Y36.mjs +2 -0
  30. package/dist/chunk-TEPK5Y36.mjs.map +1 -0
  31. package/dist/chunk-UBFIKDIP.cjs +2 -0
  32. package/dist/chunk-UBFIKDIP.cjs.map +1 -0
  33. package/dist/chunk-UUOMQMWT.cjs +2 -0
  34. package/dist/chunk-UUOMQMWT.cjs.map +1 -0
  35. package/dist/chunk-WOGK54HB.cjs +3 -0
  36. package/dist/chunk-WOGK54HB.cjs.map +1 -0
  37. package/dist/chunk-YRATJT7P.cjs +6 -0
  38. package/dist/chunk-YRATJT7P.cjs.map +1 -0
  39. package/dist/chunk-Z3PU6EBI.mjs +2 -0
  40. package/dist/chunk-Z3PU6EBI.mjs.map +1 -0
  41. package/dist/chunk-ZTE7LREB.cjs +2 -0
  42. package/dist/chunk-ZTE7LREB.cjs.map +1 -0
  43. package/dist/cli/bin.cjs +1 -1
  44. package/dist/cli/bin.mjs +1 -1
  45. package/dist/cli/index.cjs +1 -1
  46. package/dist/cli/index.mjs +1 -1
  47. package/dist/index.cjs +1 -1
  48. package/dist/index.cjs.map +1 -1
  49. package/dist/index.d.cts +35 -12
  50. package/dist/index.d.ts +35 -12
  51. package/dist/index.mjs +1 -1
  52. package/dist/index.mjs.map +1 -1
  53. package/dist/kanban/index.cjs +1 -1
  54. package/dist/kanban/index.mjs +1 -1
  55. package/dist/schema/index.cjs +1 -1
  56. package/dist/schema/index.mjs +1 -1
  57. package/dist/scrum/index.cjs +1 -1
  58. package/dist/scrum/index.d.cts +18 -3
  59. package/dist/scrum/index.d.ts +18 -3
  60. package/dist/scrum/index.mjs +1 -1
  61. package/dist/types.d.cts +23 -1
  62. package/dist/types.d.ts +23 -1
  63. package/dist/waterfall/index.cjs +1 -1
  64. package/dist/waterfall/index.d.cts +2 -0
  65. package/dist/waterfall/index.d.ts +2 -0
  66. package/dist/waterfall/index.mjs +1 -1
  67. package/package.json +1 -1
  68. package/dist/chunk-36M6OVUJ.mjs +0 -2
  69. package/dist/chunk-36M6OVUJ.mjs.map +0 -1
  70. package/dist/chunk-7KF5K3L7.cjs +0 -2
  71. package/dist/chunk-7KF5K3L7.cjs.map +0 -1
  72. package/dist/chunk-CWBH7H52.cjs +0 -2
  73. package/dist/chunk-CWBH7H52.cjs.map +0 -1
  74. package/dist/chunk-DXC2RSN5.cjs +0 -3
  75. package/dist/chunk-DXC2RSN5.cjs.map +0 -1
  76. package/dist/chunk-GATJZYTB.mjs +0 -2
  77. package/dist/chunk-GATJZYTB.mjs.map +0 -1
  78. package/dist/chunk-GFH2FEZH.mjs +0 -2
  79. package/dist/chunk-GFH2FEZH.mjs.map +0 -1
  80. package/dist/chunk-HHC5EZ54.cjs +0 -2
  81. package/dist/chunk-HHC5EZ54.cjs.map +0 -1
  82. package/dist/chunk-KSKEFYY7.cjs +0 -2
  83. package/dist/chunk-KSKEFYY7.cjs.map +0 -1
  84. package/dist/chunk-KUUIAKEJ.cjs +0 -2
  85. package/dist/chunk-KUUIAKEJ.cjs.map +0 -1
  86. package/dist/chunk-L2ZN6HEL.mjs +0 -2
  87. package/dist/chunk-L2ZN6HEL.mjs.map +0 -1
  88. package/dist/chunk-NDORREWR.mjs +0 -2
  89. package/dist/chunk-NDORREWR.mjs.map +0 -1
  90. package/dist/chunk-NZ2DIDOD.mjs +0 -2
  91. package/dist/chunk-NZ2DIDOD.mjs.map +0 -1
  92. package/dist/chunk-OHSQ52DW.mjs +0 -6
  93. package/dist/chunk-OHSQ52DW.mjs.map +0 -1
  94. package/dist/chunk-RSKZVOYC.cjs +0 -6
  95. package/dist/chunk-RSKZVOYC.cjs.map +0 -1
  96. package/dist/chunk-S22CPYXJ.mjs +0 -3
  97. package/dist/chunk-S22CPYXJ.mjs.map +0 -1
  98. package/dist/chunk-SHAPFMVP.mjs +0 -2
  99. package/dist/chunk-SHAPFMVP.mjs.map +0 -1
  100. package/dist/chunk-SJRRQZ3R.cjs +0 -2
  101. package/dist/chunk-SJRRQZ3R.cjs.map +0 -1
  102. package/dist/chunk-UM5X2JHB.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema/generated.ts","../src/schema/validate.ts","../src/schema/index.ts"],"names":["CORE_DEFINITIONS","SCRUM_DEFINITIONS","KANBAN_DEFINITIONS","WATERFALL_DEFINITIONS","DEFS","kindOf","v","isType","t","show","s","esc","key","same","a","b","err","path","keyword","message","expected","found","resolve","ref","root","fail","name","def","rank","errors","branchPath","own","e","collapse","branches","first","candidate","consts","c","validate","schema","value","walk","out","types","items","i","obj","prop","at","known","best","failed","branch","merged","assertValid","what","more","DRAFT_07","document","definitions","workflowStateSchema","roleSchema","newItemSchema","itemPatchSchema","handoffSchema","scrumConfigSchema","kanbanConfigSchema","waterfallConfigSchema"],"mappings":"qCAIO,IAAMA,CAAAA,CAA+C,CAC1D,UAAA,CAAY,CACV,IAAA,CAAM,QAAA,CACN,UAAA,CAAY,CACV,IAAA,CAAM,CACJ,IAAA,CAAM,QACR,CAAA,CACA,IAAA,CAAM,CACJ,IAAA,CAAM,QACR,CAAA,CACA,KAAA,CAAO,CACL,IAAA,CAAM,QACR,CAAA,CACA,QAAA,CAAU,CACR,IAAA,CAAM,QACR,CAAA,CACA,SAAA,CAAW,CACT,IAAA,CAAM,QACR,CAAA,CACA,UAAA,CAAY,CACV,IAAA,CAAM,QACR,CAAA,CACA,SAAA,CAAW,CACT,IAAA,CAAM,QACR,CAAA,CACA,OAAA,CAAS,CACP,IAAA,CAAM,QACR,CAAA,CACA,QAAA,CAAU,CACR,IAAA,CAAM,SACR,CACF,CAAA,CACA,QAAA,CAAU,CACR,MAAA,CACA,MAAA,CACA,OAAA,CACA,UAAA,CACA,WAAA,CACA,aACA,WAAA,CACA,SACF,CAAA,CACA,oBAAA,CAAsB,KACxB,CAAA,CACA,QAAA,CAAU,CACR,IAAA,CAAM,QAAA,CACN,UAAA,CAAY,CACV,KAAA,CAAO,CACL,IAAA,CAAM,QACR,CAAA,CACA,OAAA,CAAS,CACP,IAAA,CAAM,QACR,CAAA,CACA,EAAA,CAAI,CACF,IAAA,CAAM,QACR,CAAA,CACA,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B3D,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-5TXYMLBF.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 estimate: {\n type: \"boolean\",\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 replaces: {\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 EstimateMode: {\n type: \"string\",\n enum: [\"per-weight\", \"per-call\"],\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 autoClose: {\n type: \"boolean\",\n },\n estimateMode: {\n $ref: \"#/definitions/EstimateMode\",\n },\n fallbackTokensPerWeight: {\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 fallbackTokensPerWeight: {\n type: \"number\",\n },\n },\n required: [\"phases\", \"changeControl\", \"traceability\", \"humanGates\"],\n additionalProperties: false,\n },\n WaterfallPhaseConfig: {\n type: \"object\",\n properties: {\n id: {\n type: \"string\",\n },\n name: {\n type: \"string\",\n },\n deliverables: {\n type: \"array\",\n items: {\n type: \"string\",\n },\n },\n gate: {\n $ref: \"#/definitions/Gate\",\n },\n budget: {\n $ref: \"#/definitions/Budget\",\n },\n deliverBy: {\n type: \"string\",\n },\n },\n required: [\"id\", \"name\", \"deliverables\", \"gate\"],\n additionalProperties: false,\n },\n};\n","import { fail } from \"../errors.ts\";\nimport type { JsonSchema, SchemaError } from \"./types.ts\";\n\nconst DEFS = \"#/definitions/\";\n\nfunction kindOf(v: unknown): string {\n if (v === null) return \"null\";\n if (Array.isArray(v)) return \"array\";\n return typeof v;\n}\nfunction isType(t: string, v: unknown): boolean {\n if (t === \"integer\") return typeof v === \"number\" && Number.isInteger(v);\n return kindOf(v) === t;\n}\nfunction show(v: unknown): string {\n const s = JSON.stringify(v);\n if (s === undefined) return String(v);\n return s.length > 60 ? `${s.slice(0, 57)}...` : s;\n}\n/** JSON-pointer escaping for one key. */\nfunction esc(key: string): string {\n return key.replace(/~/g, \"~0\").replace(/\\//g, \"~1\");\n}\nfunction same(a: unknown, b: unknown): boolean {\n return JSON.stringify(a) === JSON.stringify(b);\n}\nfunction err(\n path: string,\n keyword: string,\n message: string,\n expected: string,\n found: string,\n): SchemaError {\n return { path: path === \"\" ? \"/\" : path, keyword, message, expected, found };\n}\n\nfunction resolve(ref: string, root: JsonSchema): JsonSchema {\n if (!ref.startsWith(DEFS))\n fail(\n \"invalid-input\",\n `schema $ref ${JSON.stringify(ref)} is not #/definitions/<name>`,\n \"regenerate the schema with pnpm schema:gen\",\n );\n const name = ref.slice(DEFS.length);\n const def =\n root.definitions && Object.hasOwn(root.definitions, name) ? root.definitions[name] : undefined;\n if (!def)\n fail(\n \"invalid-input\",\n `schema $ref ${JSON.stringify(ref)} names no definition`,\n \"regenerate the schema with pnpm schema:gen\",\n );\n return def;\n}\n\n/**\n * Misfit of one anyOf branch (lower is a better fit): a `type` error at the branch's own path (the value is the\n * wrong kind entirely) weighs 1000, a `const` mismatch (a discriminator) 100, anything else 1.\n */\nfunction rank(errors: SchemaError[], branchPath: string): number {\n const own = branchPath === \"\" ? \"/\" : branchPath;\n return errors.reduce(\n (n, e) => n + (e.keyword === \"type\" && e.path === own ? 1000 : e.keyword === \"const\" ? 100 : 1),\n 0,\n );\n}\n\n/** When every failed branch has a `const` error at one pointer (the discriminator), report that once as an enum. */\nfunction collapse(branches: SchemaError[][]): SchemaError | undefined {\n const first = branches[0]?.filter((e) => e.keyword === \"const\") ?? [];\n for (const candidate of first) {\n const consts = branches.map((b) =>\n b.find((e) => e.keyword === \"const\" && e.path === candidate.path),\n );\n if (consts.some((c) => c === undefined)) continue;\n const expected = [...new Set(consts.map((c) => c?.expected))].join(\" | \");\n return {\n path: candidate.path,\n keyword: \"enum\",\n message: `expected one of ${expected}`,\n expected,\n found: candidate.found,\n };\n }\n return undefined;\n}\n\n/** Validate `value` against `schema` (a document: `$ref`s resolve against its `definitions`). Returns every error found. */\nexport function validate(schema: JsonSchema, value: unknown): SchemaError[] {\n return walk(schema, value, schema, \"\");\n}\n\nfunction walk(schema: JsonSchema, value: unknown, root: JsonSchema, path: string): SchemaError[] {\n if (schema.$ref !== undefined) return walk(resolve(schema.$ref, root), value, root, path);\n const out: SchemaError[] = [];\n if (schema.type !== undefined) {\n const types = Array.isArray(schema.type) ? schema.type : [schema.type];\n if (!types.some((t) => isType(t, value))) {\n const expected = types.join(\" | \");\n return [\n err(path, \"type\", `expected ${expected}, got ${kindOf(value)}`, expected, show(value)),\n ];\n }\n }\n if (schema.const !== undefined && !same(value, schema.const))\n out.push(err(path, \"const\", `expected ${show(schema.const)}`, show(schema.const), show(value)));\n if (schema.enum !== undefined && !schema.enum.some((e) => same(e, value))) {\n const expected = schema.enum.map(show).join(\" | \");\n out.push(err(path, \"enum\", `expected one of ${expected}`, expected, show(value)));\n }\n if (typeof value === \"number\") {\n if (schema.minimum !== undefined && value < schema.minimum)\n out.push(\n err(path, \"minimum\", `expected >= ${schema.minimum}`, `>= ${schema.minimum}`, show(value)),\n );\n if (schema.maximum !== undefined && value > schema.maximum)\n out.push(\n err(path, \"maximum\", `expected <= ${schema.maximum}`, `<= ${schema.maximum}`, show(value)),\n );\n }\n if (typeof value === \"string\") {\n if (schema.minLength !== undefined && value.length < schema.minLength)\n out.push(\n err(\n path,\n \"minLength\",\n `expected at least ${schema.minLength} characters`,\n `length >= ${schema.minLength}`,\n show(value),\n ),\n );\n if (schema.pattern !== undefined && !new RegExp(schema.pattern, \"u\").test(value))\n out.push(\n err(\n path,\n \"pattern\",\n `expected to match /${schema.pattern}/`,\n `/${schema.pattern}/`,\n show(value),\n ),\n );\n }\n if (Array.isArray(value) && schema.items !== undefined) {\n const items = schema.items;\n value.forEach((v, i) => out.push(...walk(items, v, root, `${path}/${i}`)));\n }\n if (kindOf(value) === \"object\") {\n const obj = value as Record<string, unknown>;\n for (const [key, v] of Object.entries(obj)) {\n const prop =\n schema.properties && Object.hasOwn(schema.properties, key)\n ? schema.properties[key]\n : undefined;\n const at = `${path}/${esc(key)}`;\n if (prop) out.push(...walk(prop, v, root, at));\n else if (schema.additionalProperties === false) {\n const known = Object.keys(schema.properties ?? {}).join(\", \");\n out.push(\n err(\n at,\n \"additionalProperties\",\n `unknown property ${JSON.stringify(key)}`,\n known ? `one of ${known}` : \"no properties\",\n key,\n ),\n );\n } else if (typeof schema.additionalProperties === \"object\")\n out.push(...walk(schema.additionalProperties, v, root, at));\n }\n for (const key of schema.required ?? [])\n if (!Object.hasOwn(obj, key))\n out.push(\n err(\n `${path}/${esc(key)}`,\n \"required\",\n `missing required property ${JSON.stringify(key)}`,\n \"present\",\n \"absent\",\n ),\n );\n }\n if (schema.anyOf !== undefined) {\n let best: SchemaError[] | undefined;\n const failed: SchemaError[][] = [];\n for (const branch of schema.anyOf) {\n const errors = walk(branch, value, root, path);\n if (errors.length === 0) {\n best = [];\n break;\n }\n failed.push(errors);\n if (best === undefined || rank(errors, path) < rank(best, path)) best = errors;\n }\n const merged = best && best.length > 0 ? collapse(failed) : undefined;\n if (merged) out.push(merged);\n else if (best) out.push(...best);\n }\n return out;\n}\n\n/** Throw WorkflowError(\"invalid-input\") describing the first problem when `value` does not match `schema`. */\nexport function assertValid(schema: JsonSchema, value: unknown, what: string): void {\n const errors = validate(schema, value);\n const first = errors[0];\n if (!first) return;\n const more = errors.length > 1 ? ` (+${errors.length - 1} more)` : \"\";\n fail(\n \"invalid-input\",\n `${what} does not match its schema: ${first.path} ${first.message}${more}`,\n `fix ${what} at ${first.path}: expected ${first.expected}, found ${first.found}`,\n );\n}\n","import {\n CORE_DEFINITIONS,\n KANBAN_DEFINITIONS,\n SCRUM_DEFINITIONS,\n WATERFALL_DEFINITIONS,\n} from \"./generated.ts\";\nimport type { JsonSchema, JsonSchemaDocument } from \"./types.ts\";\n\nexport const DRAFT_07 = \"http://json-schema.org/draft-07/schema#\";\n\nfunction document(name: string, definitions: Record<string, JsonSchema>): JsonSchemaDocument {\n return { $schema: DRAFT_07, $ref: `#/definitions/${name}`, definitions };\n}\n\n/** `.workflow/state.json` */\nexport const workflowStateSchema = document(\"WorkflowState\", CORE_DEFINITIONS);\n/** a role manifest (`.workflow/roles/*.json`, `exwf role add`) */\nexport const roleSchema = document(\"Role\", CORE_DEFINITIONS);\n/** `exwf add <item.json>` */\nexport const newItemSchema = document(\"NewItem\", CORE_DEFINITIONS);\n/** `exwf edit <id> <patch.json>` */\nexport const itemPatchSchema = document(\"ItemPatch\", CORE_DEFINITIONS);\n/** `exwf complete <id> <handoff.json>` */\nexport const handoffSchema = document(\"Handoff\", CORE_DEFINITIONS);\n/** `exwf init scrum --config` / the scrum-master policy.json */\nexport const scrumConfigSchema = document(\"ScrumConfig\", SCRUM_DEFINITIONS);\nexport const kanbanConfigSchema = document(\"KanbanConfig\", KANBAN_DEFINITIONS);\nexport const waterfallConfigSchema = document(\"WaterfallConfig\", WATERFALL_DEFINITIONS);\n\nexport { validate, assertValid } from \"./validate.ts\";\nexport type { JsonSchema, JsonSchemaDocument, SchemaError } from \"./types.ts\";\n"]}
@@ -0,0 +1,2 @@
1
+ import {b as b$1,a as a$1}from'./chunk-IHE5K4X3.mjs';import {P,M,o,u,j,n,c,N,W,a,v,x,t,s,w,E,p,D,O}from'./chunk-Z3PU6EBI.mjs';import {b}from'./chunk-2FRRD6A3.mjs';import {timSort}from'exsorted';var we=["todo","in_progress","blocked","review","awaiting_human","done","dropped"];function Se(i){let n=i.events.filter(o=>o.type==="sprint.closed"&&o.payload.reason!=="cancel");return n.length===0?null:n.reduce((o,r)=>o+r.payload.doneWeight,0)/n.length}function fe(i){let n=P(i),o=Object.fromEntries(we.map(t=>[t,0])),r=[],y=0;for(let t of n?.committed??[]){let e=i.items[t];if(e){o[e.status]+=1,e.status!=="done"&&(y+=e.weight??0);for(let s of e.blockers)s.clearedAt||r.push({item:t,blocker:s.id,owner:s.owner,reason:s.reason});}}let p=n?.spent??{tokens:0,turns:0,wallclockMs:0},g=n?M(n.budget,n.spent):{},h=Se(i),w="unknown";if(n&&h!==null&&n.budget.tokens){let t=(g.tokens??0)/n.budget.tokens;w=y<=h*t?"on-track":"at-risk";}let c=i.lessons.filter(t=>t.status==="raised").length;return {sprint:n?.id??null,goal:n?.goal??null,byStatus:o,blockers:r,spent:p,remaining:g,remainingWeight:y,raisedLessons:c,velocity:h,forecast:w}}function z(i){for(let n=i.iterations.length-1;n>=0;n--){let o=i.iterations[n];if(o.endedAt!==void 0)return o}}function H(i,n){return i.events.find(o=>o.type==="sprint.closed"&&o.payload.id===n)?.seq??Number.POSITIVE_INFINITY}function Ce(i){let n=new Set(z(i)?.carryover??[]),o=Object.values(i.items).filter(r=>r.stage==="backlog"&&r.status==="todo"&&r.type!=="question");return timSort([...o],(r,y)=>{let p=n.has(r.id)?1:0,g=n.has(y.id)?1:0;return p!==g?g-p:(y.priority??0)-(r.priority??0)})}function me(i,n){let o=u(i,n);(o.stage!=="backlog"||o.status!=="todo")&&b("invalid-input",`item "${n}" is not in the Product Backlog (${o.stage}/${o.status})`,"only backlog items can be committed",{items:[n]}),E(i,o,p(i,"backlog").exitPolicy,"enter the Sprint Backlog");}function ue(i,n,o,r,y){let p=i;for(let g of Object.values(i.items))g.type!=="question"||g.parent===void 0||!n.includes(g.parent)||g.status==="done"||g.status==="dropped"||((g.stage!=="sprint"||g.status!=="todo")&&(p=x(p,g.id,{stage:"sprint",status:"todo"},r,y)),p=s(p,g.id,h=>({...h,iteration:o})));return p}function U(i,n){return {...i,config:{...$(i),definitionOfDone:n},stages:i.stages.map(o=>o.id==="review"?{...o,exitPolicy:n}:o)}}function Pe(i,n){let o=$(i),r=[],y=[],p$1=p(i,"backlog").exitPolicy,g=0;for(let h of Ce(i)){let w=D(i,h,p$1);if(w.length>0){y.push({id:h.id,reason:"policy",detail:w.map(c=>c.message).join("; ")});continue}if(n.turns!==void 0&&r.length>=n.turns){y.push({id:h.id,reason:"budget",detail:"turns budget full"});continue}if(n.tokens!==void 0){let c=O(i,h.weight,o.fallbackTokensPerWeight,o.estimateMode);if(g+c>n.tokens){y.push({id:h.id,reason:"budget",detail:`needs about ${c} tokens, ${n.tokens-g} left`});continue}g+=c;}r.push(h.id);}return {ids:r,skipped:y}}function X(i){let n=(t,e,s,l)=>W(t,i(),{type:e,by:s.by,payload:s},a$1=>l(a$1,a(s.now)));return {refine:(t,e)=>{o(t,e.by,"define-acceptance","deliver");let s=e.items??[],l=e.split??[],a=e.reestimate??[];(!Array.isArray(a)||!a.every(f=>typeof f=="string"))&&b("invalid-input","refine.reestimate must be a list of item ids",'pass reestimate: ["A"]');let m=a;s.length===0&&l.length===0&&m.length===0&&b("invalid-input","refine needs items[], split[] or reestimate[]","pass at least one patch, split or reestimate");for(let f of m){let v=u(t,f);(v.stage!=="backlog"||v.status!=="todo"||v.weight===void 0)&&b("invalid-input",`item "${f}" has no weight to confirm in the Product Backlog`,"refine it with a patch { weight } instead",{items:[f]});}return n(t,"ceremony.refine",e,(f,v$1)=>{for(let{id:d,patch:C}of s)f=w(f,d,C,e.by,v$1);for(let d of m)f=c(f,"item.reestimated",e.by,{id:d,weight:u(f,d).weight},v$1);for(let d of l){u(f,d.from);for(let C of d.into)f=v(f,{...C,parent:d.from},e.by,v$1);f=x(f,d.from,{status:"dropped"},e.by,v$1);}return c(f,"ceremony.refine",e.by,{edited:s.map(d=>d.id),split:l.map(d=>({from:d.from,into:d.into.map(C=>C.id)})),reestimated:m},v$1)})},plan:(t,e)=>{o(t,e.by,"facilitate");let s$1=e.goal;(typeof s$1!="string"||s$1.trim()==="")&&b("invalid-input","sprint planning needs a non-empty goal","state the Sprint Goal in one sentence");let l=$(t),a=e.budget??l.sprintBudget,m=e.items==="auto"?Pe(t,a):void 0,f=m?.skipped??[],v=m?m.ids:e.items;Array.isArray(v)||b("invalid-input",'sprint planning needs items: string[] or "auto"','pass ["A","B"] or "auto"'),v.length===0&&b("invalid-input",`no backlog items fit the sprint${f.length?`; skipped: ${f.map(d=>`${d.id} (${d.reason}: ${d.detail})`).join(", ")}`:""}`,"refine the backlog (acceptance + estimates) or raise the budget with exwf config set");for(let d of v)me(t,d);return n(t,"ceremony.plan",e,(d,C)=>{let M=`S${d.iterations.length+1}`,L=z(d),G=v.filter(P=>L?.carryover.includes(P)),u$1=[];for(let P of v){let x$1=_(u(d,P),d);x$1&&u$1.push(P),d=x(d,P,x$1?{stage:x$1,status:"review"}:{stage:"sprint",status:"todo"},e.by,C),d=s(d,P,E=>({...E,iteration:M}));}d=ue(d,v,M,e.by,C);let W=v.reduce((P,x)=>P+(d.items[x]?.weight??0),0);return d={...d,iterations:[...d.iterations,{id:M,goal:s$1,budget:a,spent:{tokens:0,turns:0,wallclockMs:0},startedAt:C,committed:[...v],carryover:G}]},c(d,"sprint.opened",e.by,{id:M,goal:s$1,committed:v,committedWeight:W,budget:a,skipped:f,resumed:u$1},C)})},commit:(t,e)=>{let s$1=P(t);s$1||b("invalid-input","no open sprint to commit into","run the plan ceremony first");let l=e.items;(!Array.isArray(l)||l.length===0)&&b("invalid-input","commit needs items[]",'pass ["A"]');let a=new Set;for(let m of l)a.has(m)&&b("invalid-input",`item "${m}" appears twice in items[]`,"list each item once",{items:[m]}),a.add(m),u(t,m),s$1.committed.includes(m)&&b("invalid-input",`item "${m}" is already committed to ${s$1.id}`,"nothing to do",{items:[m]}),me(t,m);return n(t,"ceremony.commit",e,(m,f)=>{let v=[];for(let d of l){let C=_(u(m,d),m);C&&v.push(d),m=x(m,d,C?{stage:C,status:"review"}:{stage:"sprint",status:"todo"},e.by,f),m=s(m,d,M=>({...M,iteration:s$1.id}));}return m=ue(m,l,s$1.id,e.by,f),m={...m,iterations:m.iterations.map(d=>d.id===s$1.id?{...d,committed:[...d.committed,...l]}:d)},c(m,"sprint.committed",e.by,{id:s$1.id,items:l,goalImpact:e.goalImpact??null,resumed:v},f)})},uncommit:(t$1,e)=>{o(t$1,e.by,"order-backlog");let s=P(t$1);s||b("invalid-input","no open sprint","nothing to uncommit from");let l=e.items;(!Array.isArray(l)||l.length===0)&&b("invalid-input","uncommit needs items[]",'pass ["A"]');for(let a of l)u(t$1,a).status==="done"&&b("invalid-input",`item "${a}" is done`,"finished work cannot be uncommitted",{items:[a]});for(let a of l)s.committed.includes(a)||b("invalid-input",`item "${a}" is not committed to ${s.id}`,`committed: ${s.committed.join(", ")}`,{items:[a]});return n(t$1,"ceremony.uncommit",e,(a,m)=>{for(let f of l)a=x(a,f,{stage:"backlog",status:"todo"},e.by,m),a=t(a,f,["iteration","role"]);return a={...a,iterations:a.iterations.map(f=>f.id===s.id?{...f,committed:f.committed.filter(v=>!l.includes(v))}:f)},c(a,"sprint.uncommitted",e.by,{id:s.id,items:l,reason:e.reason??""},m)})},daily:(t,e)=>n(t,"ceremony.daily",e,(s,l)=>c(s,"daily",e.by,fe(s),l)),review:(t,e)=>{let s=P(t);s||b("invalid-input","no open sprint to review","run the plan ceremony first");let l=j(t,"sprint-review");e.by!=="human"&&!l.includes(e.by)&&b("gate-unmet",`"${e.by}" may not accept the Sprint Review`,`run review as "human" or as ${l.join(", ")||"a role with canApprove sprint-review"}`,{rule:"sprint-review"});let a=e.feedback??[];return n(t,"ceremony.review",e,(m,f)=>{for(let d of a)m=v(m,{...d,stage:"backlog"},e.by,f);let v$1=s.committed.filter(d=>m.items[d]?.status==="done");return m=c(m,"increment",e.by,{sprint:s.id,done:v$1,goalMet:e.goalMet===true,accepted:e.accepted===true,feedback:a.map(d=>d.id)},f),K(m,"review",f)})},retro:(t,e)=>{o(t,e.by,"facilitate");let s=z(t);s||b("invalid-input","no closed sprint to retrospect","close the sprint (review or cancel) first"),P(t)&&b("invalid-input","a sprint is still open","retro runs between sprints; review or cancel the open one");let l=H(t,s.id);t.events.some(u=>u.type==="retro"&&u.seq>l)&&b("invalid-input",`sprint ${s.id} already has a retrospective`,"plan the next sprint");let a=e.lessons??[],m=["human",...Object.keys(t.roles)];for(let u$1 of a)u$1.from!==void 0&&(typeof u$1.from!="string"||!m.includes(u$1.from))&&b("invalid-input",`lesson from ${JSON.stringify(u$1.from)} is not a role`,`from is "human" or one of the roles: ${Object.keys(t.roles).join(", ")||"(none)"}`),u$1.item!==void 0&&(typeof u$1.item!="string"&&b("invalid-input","lesson item must be an item id","name an item with addItem first"),u(t,u$1.item));let f=e.retire??[];(!Array.isArray(f)||!f.every(u=>typeof u=="string")||f.some((u,W)=>f.indexOf(u)!==W))&&b("invalid-input","retro.retire must be a list of distinct agreement texts",'e.g. { "retire": ["review in a fresh worker"] }; each agreement once');let v$1=f,d=e.adopt??[],C=e.dismiss??[],M=e.dodChanges,L=[...d.map(u=>u.id),...C],G=L.find((u,W)=>L.indexOf(u)!==W);G&&b("invalid-input",`lesson "${G}" is referenced more than once`,"adopt or dismiss each lesson once");for(let u of L){let W=t.lessons.find(P=>P.id===u);W||b("invalid-input",`no lesson "${u}"`,`raised lessons: ${t.lessons.filter(P=>P.status==="raised").map(P=>P.id).join(", ")||"(none)"}`),W.status!=="raised"&&b("invalid-input",`lesson "${u}" is already ${W.status}`,"only raised lessons can be adopted or dismissed");}return n(t,"ceremony.retro",e,(u,W)=>{let P=[],x=[],E=[],Q=false,ee=k=>{if(k)if(k.kind==="agreement")u=a$1(u,k,e.by,W),x.push(k.text);else if(k.kind==="dod"){let I=$(u).definitionOfDone;I.some(j=>JSON.stringify(j)===JSON.stringify(k.policy))||(Q=true,u=U(u,[...I,k.policy]));}else k.kind==="backlog"&&(u=v(u,{...k.item,stage:"backlog",tags:[...k.item.tags??[],"retro"]},e.by,W),E.push(k.item.id));};for(let k of a){let I=`L${u.lessons.length+1}`,j={id:I,at:W,text:k.text,scope:k.scope,status:"adopted",from:k.from??e.by};k.item!==void 0&&(j.item=k.item),k.suggestedChange&&(j.suggestedChange=k.suggestedChange),u={...u,lessons:[...u.lessons,j]},P.push(I),ee(k.suggestedChange);}for(let k of d)u={...u,lessons:u.lessons.map(I=>I.id===k.id?{...I,status:"adopted",...k.suggestedChange?{suggestedChange:k.suggestedChange}:{}}:I)},P.push(k.id),ee(k.suggestedChange??u.lessons.find(I=>I.id===k.id)?.suggestedChange);for(let k of C)u={...u,lessons:u.lessons.map(I=>I.id===k?{...I,status:"dismissed"}:I)};for(let k of v$1)u=b$1(u,k,e.by,W);return M&&(Q=true,u=U(u,M)),c(u,"retro",e.by,{sprint:s.id,adopted:P,dismissed:C,agreements:x,retired:v$1,dodChanged:Q,backlogAdded:E},W)})},cancel:(t,e)=>{o(t,e.by,"order-backlog");let s=P(t);return s||b("invalid-input","no open sprint to cancel","nothing to do"),n(t,"ceremony.cancel",e,(l,a)=>(l=c(l,"sprint.cancelled",e.by,{id:s.id,reason:e.reason??""},a),K(l,"cancel",a)))}}}var We=new Set(["never","po-only","any"]);function pe(i){let n=i??{},o=n.sprintBudget;(!o||typeof o!="object"||o.tokens===void 0&&o.turns===void 0&&o.wallclockMs===void 0)&&b("config-invalid","scrum config.sprintBudget must define tokens, turns or wallclockMs",'e.g. { "sprintBudget": { "tokens": 400000, "turns": 60 } }'),(typeof n.productGoal!="string"||n.productGoal.trim()==="")&&b("config-invalid","scrum config.productGoal must be a non-empty string","state the Product Goal in one sentence"),Array.isArray(n.definitionOfDone)||b("config-invalid","scrum config.definitionOfDone must be a Policy[]",'e.g. [{ "kind": "evidence", "evidenceKind": "test-output" }]');let r=n.refinementSharePct??10;(typeof r!="number"||r<0||r>100)&&b("config-invalid","scrum config.refinementSharePct must be 0..100","omit it for the default 10");let y=n.allowMidSprintAdd??"po-only";(typeof y!="string"||!We.has(y))&&b("config-invalid",`scrum config.allowMidSprintAdd must be never | po-only | any (got ${JSON.stringify(y)})`,'use "po-only" unless you have a reason');let p=n.inProgressWipLimit;p!==void 0&&(typeof p!="number"||p<1)&&b("config-invalid","scrum config.inProgressWipLimit must be a positive number","omit it for no limit");let g=n.autoClose;g!==void 0&&typeof g!="boolean"&&b("config-invalid","scrum config.autoClose must be true or false","omit it for the default true");let h=n.estimateMode;h!==void 0&&h!=="per-weight"&&h!=="per-call"&&b("config-invalid",`scrum config.estimateMode must be per-weight | per-call (got ${JSON.stringify(h)})`,'use "per-weight" (the default) or "per-call"');let w=n.fallbackTokensPerWeight;w!==void 0&&(typeof w!="number"||!Number.isFinite(w)||w<=0)&&b("config-invalid","scrum config.fallbackTokensPerWeight must be a positive finite number","omit it for the default 20000");let c={sprintBudget:o,productGoal:n.productGoal,definitionOfDone:n.definitionOfDone,refinementSharePct:r,allowMidSprintAdd:y};return p!==void 0&&(c.inProgressWipLimit=p),g!==void 0&&(c.autoClose=g),h!==void 0&&(c.estimateMode=h),w!==void 0&&(c.fallbackTokensPerWeight=w),c}var B=(i,n)=>n===0?0:i/n;function ge(i){let n=i.events.filter(t=>t.type==="accounting.corrected"),o=i.events.filter(t=>t.type==="sprint.closed").map(t=>{let e=t.payload,s=n.filter(l=>l.seq>t.seq&&e.id!==void 0&&l.payload.iteration===e.id).reduce((l,a)=>l+a.payload.delta.tokens,0);return s===0?e:{...e,spent:{...e.spent,tokens:e.spent.tokens+s}}}),r=o.filter(t=>t.reason!=="cancel"),y=r.map(t=>t.doneWeight),p=r.reduce((t,e)=>t+e.doneWeight,0),g=r.reduce((t,e)=>t+e.committedWeight,0),h=i.events.filter(t=>t.type==="increment").map(t=>t.payload),w=o.filter(t=>t.budget.tokens!==void 0),c=r.reduce((t,e)=>t+e.spent.tokens,0);return {velocity:y,meanVelocity:B(y.reduce((t,e)=>t+e,0),y.length),burndown:i.events.filter(t=>t.type==="daily").map(t=>t.payload.remainingWeight),commitmentReliability:B(p,g),sprintGoalHitRate:B(h.filter(t=>t.goalMet).length,h.length),carryoverRatio:B(o.reduce((t,e)=>t+e.carryover.length,0),o.reduce((t,e)=>t+e.done.length+e.carryover.length,0)),budgetUtilisation:B(w.reduce((t,e)=>t+e.spent.tokens,0),w.reduce((t,e)=>t+(e.budget.tokens??0),0)),costPerPoint:B(c,p),current:Ie(i)}}function Ie(i){let n=P(i),o=(n?.committed??[]).map(w=>i.items[w]).filter(w=>w!==void 0),r=w=>w.reduce((c,t)=>c+(t.weight??0),0),y=r(o),p=r(o.filter(w=>w.status==="done")),g=n?.spent.tokens??0,h=n?.budget.tokens??0;return {spentTokens:g,spentTurns:n?.spent.turns??0,budgetTokens:h,committedWeight:y,doneWeight:p,remainingWeight:y-p,costPerPoint:B(g,p),budgetUtilisation:B(g,h)}}function ye(){return [{id:"product-owner",name:"Product Owner",modelTier:"large",capabilities:["order-backlog","define-acceptance","escalate"],canApprove:["sprint-review"],inputs:["stakeholder-needs","product-goal"],outputs:["ordered-backlog","acceptance-criteria"],do_not:["do not implement items yourself"]},{id:"scrum-master",name:"Scrum Master",modelTier:"large",capabilities:["facilitate","escalate"],canApprove:[],inputs:["board","blockers"],outputs:["ceremony-records","lessons"],do_not:["do not reorder the Product Backlog","do not assign work; the planner pulls"]},{id:"developer",name:"Developer",modelTier:"small",capabilities:["deliver","review","verify"],canApprove:[],inputs:["brief"],outputs:["code","test-output"],do_not:["do not change acceptance criteria","do not touch items outside your brief"]}]}var R=(i,n,o,r,y)=>y?{rule:i,severity:n,item:y,message:o,fix:r}:{rule:i,severity:n,message:o,fix:r};function he(i){for(let n=i.iterations.length-1;n>=0;n--){let o=i.iterations[n];if(o.endedAt!==void 0)return o}}var Z=i=>i.kind==="evidence"?`evidence:${i.evidenceKind}`:i.kind==="custom"?`custom:${i.id}`:i.kind;function be(){return [{id:"one-open-sprint",severity:"error",check:(c,t)=>t.type==="ceremony.plan"&&P(c)?[R("one-open-sprint","error",`sprint ${P(c).id} is still open`,"review or cancel it before planning the next sprint")]:[]},{id:"retro-before-plan",severity:"error",check:(c,t)=>{if(t.type!=="ceremony.plan")return [];let e=he(c);if(!e)return [];let s=H(c,e.id);if(c.events.some(a=>a.type==="retro"&&a.seq>s))return [];let l=e.outcome==="cancelled"?"warning":"error";return [R("retro-before-plan",l,`sprint ${e.id} has no retrospective yet`,"run the retro ceremony first (lessons may be empty)")]}},{id:"sprint-budget-fixed",severity:"error",check:(c,t)=>{if(t.type!=="ceremony.plan")return [];let e=t.payload?.budget;return e===void 0||JSON.stringify(e)===JSON.stringify($(c).sprintBudget)?[]:[R("sprint-budget-fixed","error","sprint length is fixed by config.sprintBudget","change sprintBudget between sprints with changeConfig / exwf config set, not per plan")]}},{id:"sprint-closing",severity:"error",check:(c,t)=>{let e=P(c);return t.type==="ceremony.commit"&&e?.closing?[R("sprint-closing","error",`sprint ${e.id} is closing: its budget is spent and no new work can start`,"run ceremony review or cancel first, then plan the next sprint")]:[]}},{id:"scrum-stage-ids",severity:"error",check:(c,t)=>{if(t.type!=="init")return [];let e=["backlog","sprint","review"].filter(s=>!c.stages.some(l=>l.id===s));return e.length&&b("config-invalid",`scrum stages lack the required id(s): ${e.join(", ")}`,"keep the stages backlog, sprint and review (omit stages to use the defaults), then run exwf init scrum again"),[]}},{id:"scope-protects-goal",severity:"error",check:(c,t)=>{if(t.type!=="ceremony.commit")return [];let e=$(c),s=t.payload??{};return e.allowMidSprintAdd==="never"?[R("scope-protects-goal","error","mid-sprint additions are disabled",'set allowMidSprintAdd to "po-only" or wait for the next sprint')]:e.allowMidSprintAdd==="po-only"&&!n(c,t.by,"order-backlog")?[R("scope-protects-goal","error",`"${t.by}" may not add work mid-sprint`,"ask the Product Owner (order-backlog) to commit it")]:s.goalImpact!=="none"?[R("scope-protects-goal","error",`adding work with goalImpact "${s.goalImpact??"unset"}" endangers the Sprint Goal`,'only commit items with goalImpact: "none"; otherwise cancel and re-plan')]:[]}},{id:"po-orders-backlog",severity:"error",check:(c,t)=>t.type!=="ceremony.refine"||n(c,t.by,"order-backlog")?[]:((t.payload??{}).items??[]).filter(s=>s.patch.priority!==void 0).map(s=>R("po-orders-backlog","error",`"${t.by}" may not change the priority of "${s.id}"`,"only the Product Owner orders the backlog; drop priority from the patch",s.id))},{id:"dod-not-weakened",severity:"error",check:(c,t)=>{if(t.type!=="ceremony.retro")return [];let e=t.payload??{};if(e.dodChanges===void 0)return [];if(P(c))return [R("dod-not-weakened","error","Definition of Done cannot change while a sprint is open","close the sprint first; DoD changes apply to the next sprint")];if(!Array.isArray(e.dodChanges)||e.allowWeaken===true)return [];let s=e.dodChanges,l=new Set(s.map(Z)),a=$(c).definitionOfDone.filter(f=>!l.has(Z(f)));if(a.length===0)return [];let m=a.map(f=>Z(f).replace(":"," "));return [R("dod-not-weakened","error",`retro dodChanges drops ${a.length} Definition of Done policy(ies): ${m.join(", ")}`,'keep them in dodChanges (it replaces the whole list; suggestedChange { kind: "dod" } appends one), or pass allowWeaken: true to weaken the Definition of Done knowingly')]}},{id:"carryover-reestimated",severity:"error",check:(c,t)=>{if(t.type!=="ceremony.plan")return [];let e=t.payload?.items;if(!Array.isArray(e))return [];let s=he(c);if(!s)return [];let l=H(c,s.id);return e.filter(a=>s.carryover.includes(a)&&!(c.items[a]&&_(c.items[a],c)!==void 0)&&!c.events.some(m=>m.seq>l&&m.payload.id===a&&(m.type==="item.edited"&&m.payload.changed.includes("weight")||m.type==="item.reestimated"))).map(a=>R("carryover-reestimated","error",`carried-over item "${a}" was not re-estimated after ${s.id}`,"refine it with a new weight before committing",a))}}]}function ke(i){let n={id:"in_progress",name:"In progress",entryPolicy:[{kind:"dependencies-done"}],exitPolicy:[]};return i.inProgressWipLimit!==void 0&&(n.wipLimit=i.inProgressWipLimit),[{id:"backlog",name:"Product Backlog",entryPolicy:[],exitPolicy:[{kind:"acceptance-written"},{kind:"estimate-present"}]},{id:"sprint",name:"Sprint Backlog",entryPolicy:[],exitPolicy:[]},n,{id:"review",name:"Review",entryPolicy:[],exitPolicy:i.definitionOfDone,review:true},{id:"done",name:"Increment",entryPolicy:[],exitPolicy:[]}]}var Ae={backlog:"Product Backlog",item:"Product Backlog Item",stage:"Column",iteration:"Sprint",increment:"Increment",ceremony:"Scrum Event",gate:"Sprint Review"};function $(i){return i.config}function _(i,n){let o=i.transitions.at(-1);return !o||o.by!=="system"||o.to.stage!=="backlog"||o.to.status!=="todo"?void 0:n?n.stages.find(y=>y.id===o.from.stage)?.review||o.from.status==="review"?o.from.stage:void 0:o.from.status==="review"?o.from.stage:void 0}function Oe(i,n,o){let r=i,y=u(r,n).blockers.filter(g=>!g.clearedAt);if(y.length){r=s(r,n,g=>({...g,blockers:g.blockers.map(h=>h.clearedAt?h:{...h,clearedAt:o})}));for(let g of y)r=c(r,"blocker.cleared","system",{id:n,blocker:g.id,reason:"sprint closed"},o);}for(let g of r.pending.filter(h=>h.item===n))r={...r,pending:r.pending.filter(h=>h.id!==g.id)},r=c(r,"pending.dropped","system",{id:g.id,item:n,reason:"sprint closed"},o);let p=u(r,n);return (p.stage!=="backlog"||p.status!=="todo")&&(r=x(r,n,{stage:"backlog",status:"todo"},"system",o)),t(r,n,p.type==="question"?["iteration"]:["iteration","role"])}function K(i,n,o){let r=P(i);if(!r)return i;let y=r.committed.map(e=>u(i,e)),p=y.filter(e=>e.status==="done").map(e=>e.id),g=y.filter(e=>e.status==="dropped").map(e=>e.id),h=y.filter(e=>e.status!=="done"&&e.status!=="dropped").map(e=>e.id),w=Object.values(i.items).filter(e=>e.type==="question"&&e.parent!==void 0&&h.includes(e.parent)&&e.status!=="done"&&e.status!=="dropped").map(e=>e.id),c$1=i;for(let e of [...h,...w])c$1=Oe(c$1,e,o);let t=e=>e.reduce((s,l)=>s+(i.items[l]?.weight??0),0);return c$1={...c$1,iterations:c$1.iterations.map(e=>{if(e.id!==r.id)return e;let{closing:s,...l}=e;return {...l,endedAt:o,outcome:n==="cancel"?"cancelled":"completed",carryover:h}})},c(c$1,"sprint.closed","system",{id:r.id,reason:n,done:p,carryover:h,carriedQuestions:w,dropped:g,doneWeight:t(p),committedWeight:t(r.committed),spent:r.spent,budget:r.budget},o)}function $e(){return {name:"scrum",vocabulary:Ae,validateConfig:pe,defaultStages:ke,defaultRoles:ye,requiredCapabilities:["order-backlog","facilitate","deliver"],exclusiveCapabilities:["order-backlog"],plannerOptions(i){let n=$(i),o={schedulerMode:"level",dispatchStage:"in_progress"};return n.inProgressWipLimit!==void 0&&(o.concurrencyCap=n.inProgressWipLimit),n.estimateMode!==void 0&&(o.estimateMode=n.estimateMode),n.fallbackTokensPerWeight!==void 0&&(o.fallbackTokensPerWeight=n.fallbackTokensPerWeight),o},candidates(i){let n=P(i);return !n||n.closing?[]:Object.values(i.items).filter(o=>o.iteration===n.id&&(o.status==="todo"||o.status==="review")&&(o.stage==="sprint"||o.stage==="review"))},invariants(i,n){let o=P(i),r=$(i),y=o?M(o.budget,o.spent):{};return [`Sprint Goal: ${o?.goal??"(no open sprint)"}; Product Goal: ${r.productGoal}`,`Budget remaining: ${JSON.stringify(y)}; stop and hand off when it is gone`,`Definition of Done: ${r.definitionOfDone.map(p=>p.kind==="evidence"?`evidence ${p.evidenceKind}`:p.kind).join(", ")||"(none)"}`,`Do not change the scope of "${n.id}" or its acceptance criteria; raise open_questions instead`]},ceremonies:X($e),rules:be(),metrics:i=>({...ge(i)}),report(i){let n=P(i);return {closing:n?.closing===true,sprint:n?.id??null,reason:n?.closing?"budget":null,inFlight:n?Object.values(i.items).filter(o=>(o.iteration===n.id||n.committed.includes(o.id))&&o.status==="in_progress").map(o=>o.id):[]}},humanDefaults:{gates:["sprint-review"]},afterConfigChange(i){return U(i,$(i).definitionOfDone)},afterComplete(i,n,o){let r=P(i);return !r||!r.closing&&!N(r.budget,r.spent)?i:!Object.values(i.items).some(p=>(p.iteration===r.id||r.committed.includes(p.id))&&p.status==="in_progress")&&$(i).autoClose!==false?K(i,"budget",o):r.closing?i:c({...i,iterations:i.iterations.map(p=>p.id===r.id?{...p,closing:true}:p)},"sprint.closing","system",{id:r.id},o)}}}export{fe as a,X as b,pe as c,ge as d,ye as e,be as f,ke as g,Ae as h,$ as i,_ as j,K as k,$e as l};//# sourceMappingURL=chunk-7CDGPTEJ.mjs.map
2
+ //# sourceMappingURL=chunk-7CDGPTEJ.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/scrum/ceremonies.ts","../src/scrum/config.ts","../src/scrum/metrics.ts","../src/scrum/roles.ts","../src/scrum/rules.ts","../src/scrum/stages.ts","../src/scrum/index.ts"],"names":["STATUSES","velocityOf","state","closed","e","sum","dailyReport","it","openIteration","byStatus","s","blockers","remainingWeight","id","item","b","spent","rem","remaining","velocity","forecast","share","raisedLessons","l","lastClosedIteration","i","closedSeq","backlogOrdered","carry","items","timSort","x","cx","cy","assertCommittable","getItem","fail","assertPolicies","stageOf","attachQuestions","parentIds","iterationId","by","now","q","moveItem","patchItem","setDod","policies","configOf","st","selectAuto","budget","cfg","ids","skipped","exit","tokens","unmet","evaluatePolicies","u","est","estimateTokens","scrumCeremonies","methodology","act","type","input","reduce","applyAction","nowOf","requireCap","split","reestimateRaw","reestimate","patch","editItem","appendEvent","sp","n","addItem","goal","auto","wanted","last","carryover","w","resumed","rs","resumeStageOf","committedWeight","seen","stripItemFields","c","approvers","approverIds","feedback","done","f","closeSprint","closedAt","newLessons","roleIds","retireRaw","retire","adopt","dismiss","dod","refs","a","dupe","r","ref","adopted","agreements","backlogAdded","dodChanged","applyChange","applyAgreement","cur","p","lesson","d","text","retireAgreement","ADD_MODES","validateScrumConfig","raw","add","wip","autoClose","mode","fallback","out","ratio","num","den","scrumMetrics","corrections","late","counted","doneWeight","increments","withTokens","tokensSpent","currentSprint","weight","list","spentTokens","budgetTokens","scrumRoles","v","rule","severity","message","fix","lastClosed","policyKey","scrumRules","seq","sev","missing","canDo","next","kept","removed","describe","scrumStages","config","inProgress","SCRUM_VOCABULARY","t","toBacklog","open","reason","committed","dropped","carriedQuestions","weightOf","_c","rest","scrum","po","left","_itemId","isExhausted"],"mappings":"kMAoCA,IAAMA,GAAyB,CAC7B,MAAA,CACA,aAAA,CACA,SAAA,CACA,QAAA,CACA,gBAAA,CACA,MAAA,CACA,SACF,EAeO,SAASC,EAAAA,CAAWC,CAAAA,CAAqC,CAC9D,IAAMC,CAAAA,CAASD,CAAAA,CAAM,MAAA,CAAO,OACzBE,CAAAA,EAAMA,CAAAA,CAAE,IAAA,GAAS,eAAA,EAAoBA,CAAAA,CAAE,OAAA,CAA+B,MAAA,GAAW,QACpF,EACA,OAAID,CAAAA,CAAO,MAAA,GAAW,CAAA,CAAU,IAAA,CAE9BA,CAAAA,CAAO,MAAA,CAAO,CAACE,EAAKD,CAAAA,GAAMC,CAAAA,CAAOD,CAAAA,CAAE,OAAA,CAAmC,UAAA,CAAY,CAAC,CAAA,CACnFD,CAAAA,CAAO,MAEX,CAEO,SAASG,EAAAA,CAAYJ,CAAAA,CAAmC,CAC7D,IAAMK,CAAAA,CAAKC,CAAAA,CAAcN,CAAK,CAAA,CACxBO,CAAA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AAKC,CAAAA,CAAcN,CAAK,CAAA,CAC9B,OAAI,CAACK,CAAAA,EAAO,CAACA,CAAAA,CAAG,OAAA,EAAW,CAACkL,EAAYlL,CAAAA,CAAG,MAAA,CAAQA,CAAAA,CAAG,KAAK,CAAA,CAAWL,CAAAA,CAIlE,CAHa,MAAA,CAAO,OAAOA,CAAAA,CAAM,KAAK,CAAA,CAAE,IAAA,CACzCuB,CAAAA,EAAAA,CAAOA,CAAAA,CAAE,SAAA,GAAclB,CAAAA,CAAG,IAAMA,CAAAA,CAAG,SAAA,CAAU,QAAA,CAASkB,CAAAA,CAAE,EAAE,CAAA,GAAMA,CAAAA,CAAE,MAAA,GAAW,aAChF,CAAA,EACiBwB,CAAAA,CAAS/C,CAAK,CAAA,CAAE,SAAA,GAAc,KAAA,CACtCiG,CAAAA,CAAYjG,CAAAA,CAAO,SAAUyC,CAAG,CAAA,CACrCpC,CAAAA,CAAG,OAAA,CAAgBL,CAAAA,CAChB2E,CAAAA,CACL,CACE,GAAG3E,EACH,UAAA,CAAYA,CAAAA,CAAM,UAAA,CAAW,GAAA,CAAK6B,CAAAA,EAAOA,CAAAA,CAAE,EAAA,GAAOxB,CAAAA,CAAG,GAAK,CAAE,GAAGwB,CAAAA,CAAG,OAAA,CAAS,IAAK,CAAA,CAAIA,CAAE,CACxF,EACA,gBAAA,CACA,QAAA,CACA,CAAE,EAAA,CAAIxB,EAAG,EAAG,CAAA,CACZoC,CACF,CACF,CACF,CACF","file":"chunk-7CDGPTEJ.mjs","sourcesContent":["import { timSort } from \"exsorted\";\nimport { estimateTokens, remaining } from \"../budget.ts\";\nimport { applyAgreement, retireAgreement } from \"../agreements.ts\";\nimport { fail } from \"../errors.ts\";\nimport {\n addItem,\n editItem,\n getItem,\n moveItem,\n patchItem,\n stageOf,\n stripItemFields,\n type ItemPatch,\n} from \"../items.ts\";\nimport { applyAction } from \"../methodology.ts\";\nimport { assertPolicies, evaluatePolicies } from \"../policies.ts\";\nimport { openIteration } from \"../planner.ts\";\nimport { approverIds, canDo, requireCap } from \"../roles.ts\";\nexport { canDo };\nimport { appendEvent, nowOf } from \"../state.ts\";\nimport type {\n Budget,\n Ceremony,\n CeremonyInput,\n ItemStatus,\n Iteration,\n Lesson,\n LessonChange,\n Methodology,\n NewItem,\n Policy,\n WorkItem,\n WorkflowState,\n} from \"../types.ts\";\nimport { closeSprint, configOf, resumeStageOf } from \"./index.ts\";\n\nconst STATUSES: ItemStatus[] = [\n \"todo\",\n \"in_progress\",\n \"blocked\",\n \"review\",\n \"awaiting_human\",\n \"done\",\n \"dropped\",\n];\n\nexport interface DailyReport {\n sprint: string | null;\n goal: string | null;\n byStatus: Record<ItemStatus, number>;\n blockers: Array<{ item: string; blocker: string; owner: string; reason: string }>;\n spent: Required<Budget>;\n remaining: Budget;\n remainingWeight: number;\n raisedLessons: number;\n velocity: number | null;\n forecast: \"on-track\" | \"at-risk\" | \"unknown\";\n}\n\nexport function velocityOf(state: WorkflowState): number | null {\n const closed = state.events.filter(\n (e) => e.type === \"sprint.closed\" && (e.payload as { reason: string }).reason !== \"cancel\",\n );\n if (closed.length === 0) return null;\n return (\n closed.reduce((sum, e) => sum + (e.payload as { doneWeight: number }).doneWeight, 0) /\n closed.length\n );\n}\n\nexport function dailyReport(state: WorkflowState): DailyReport {\n const it = openIteration(state);\n const byStatus = Object.fromEntries(STATUSES.map((s) => [s, 0])) as Record<ItemStatus, number>;\n const blockers: DailyReport[\"blockers\"] = [];\n let remainingWeight = 0;\n for (const id of it?.committed ?? []) {\n const item = state.items[id];\n if (!item) continue;\n byStatus[item.status] += 1;\n if (item.status !== \"done\") remainingWeight += item.weight ?? 0;\n for (const b of item.blockers)\n if (!b.clearedAt)\n blockers.push({ item: id, blocker: b.id, owner: b.owner, reason: b.reason });\n }\n const spent = it?.spent ?? { tokens: 0, turns: 0, wallclockMs: 0 };\n const rem = it ? remaining(it.budget, it.spent) : {};\n const velocity = velocityOf(state);\n let forecast: DailyReport[\"forecast\"] = \"unknown\";\n if (it && velocity !== null && it.budget.tokens) {\n const share = (rem.tokens ?? 0) / it.budget.tokens;\n forecast = remainingWeight <= velocity * share ? \"on-track\" : \"at-risk\";\n }\n const raisedLessons = state.lessons.filter((l) => l.status === \"raised\").length;\n return {\n sprint: it?.id ?? null,\n goal: it?.goal ?? null,\n byStatus,\n blockers,\n spent,\n remaining: rem,\n remainingWeight,\n raisedLessons,\n velocity,\n forecast,\n };\n}\n\nfunction lastClosedIteration(state: WorkflowState): Iteration | undefined {\n for (let i = state.iterations.length - 1; i >= 0; i--) {\n const it = state.iterations[i]!;\n if (it.endedAt !== undefined) return it;\n }\n return undefined;\n}\n\n/** Event seq of the sprint.closed event of `id`; infinity when it is missing, so nothing counts as \"after\" it. */\nexport function closedSeq(state: WorkflowState, id: string): number {\n return (\n state.events.find((e) => e.type === \"sprint.closed\" && (e.payload as { id: string }).id === id)\n ?.seq ?? Number.POSITIVE_INFINITY\n );\n}\n\nfunction backlogOrdered(state: WorkflowState): WorkItem[] {\n const carry = new Set(lastClosedIteration(state)?.carryover ?? []);\n const items = Object.values(state.items).filter(\n (i) => i.stage === \"backlog\" && i.status === \"todo\" && i.type !== \"question\",\n );\n return timSort([...items], (x, y) => {\n const cx = carry.has(x.id) ? 1 : 0;\n const cy = carry.has(y.id) ? 1 : 0;\n if (cx !== cy) return cy - cx;\n return (y.priority ?? 0) - (x.priority ?? 0);\n });\n}\n\n/** Throw unless the item sits in the Product Backlog and meets the backlog exit policy. */\nfunction assertCommittable(state: WorkflowState, id: string): void {\n const item = getItem(state, id);\n if (item.stage !== \"backlog\" || item.status !== \"todo\")\n fail(\n \"invalid-input\",\n `item \"${id}\" is not in the Product Backlog (${item.stage}/${item.status})`,\n \"only backlog items can be committed\",\n { items: [id] },\n );\n assertPolicies(state, item, stageOf(state, \"backlog\").exitPolicy, \"enter the Sprint Backlog\");\n}\n\n/** Open questions raised by the given parents travel with them into the sprint (they carry no weight). */\nfunction attachQuestions(\n state: WorkflowState,\n parentIds: string[],\n iterationId: string,\n by: string,\n now: string,\n): WorkflowState {\n let s = state;\n for (const q of Object.values(state.items)) {\n if (\n q.type !== \"question\" ||\n q.parent === undefined ||\n !parentIds.includes(q.parent) ||\n q.status === \"done\" ||\n q.status === \"dropped\"\n )\n continue;\n if (q.stage !== \"sprint\" || q.status !== \"todo\")\n s = moveItem(s, q.id, { stage: \"sprint\", status: \"todo\" }, by, now);\n s = patchItem(s, q.id, (it) => ({ ...it, iteration: iterationId }));\n }\n return s;\n}\n\n/** Set the Definition of Done in the config and on the review stage. */\nexport function setDod(state: WorkflowState, policies: Policy[]): WorkflowState {\n return {\n ...state,\n config: { ...configOf(state), definitionOfDone: policies },\n stages: state.stages.map((st) => (st.id === \"review\" ? { ...st, exitPolicy: policies } : st)),\n };\n}\n\ninterface Skipped {\n id: string;\n reason: \"policy\" | \"budget\";\n detail: string;\n}\n\nfunction selectAuto(state: WorkflowState, budget: Budget): { ids: string[]; skipped: Skipped[] } {\n const cfg = configOf(state);\n const ids: string[] = [];\n const skipped: Skipped[] = [];\n const exit = stageOf(state, \"backlog\").exitPolicy;\n let tokens = 0;\n for (const item of backlogOrdered(state)) {\n const unmet = evaluatePolicies(state, item, exit);\n if (unmet.length > 0) {\n skipped.push({\n id: item.id,\n reason: \"policy\",\n detail: unmet.map((u) => u.message).join(\"; \"),\n });\n continue;\n }\n if (budget.turns !== undefined && ids.length >= budget.turns) {\n skipped.push({ id: item.id, reason: \"budget\", detail: \"turns budget full\" });\n continue;\n }\n if (budget.tokens !== undefined) {\n const est = estimateTokens(state, item.weight, cfg.fallbackTokensPerWeight, cfg.estimateMode);\n if (tokens + est > budget.tokens) {\n skipped.push({\n id: item.id,\n reason: \"budget\",\n detail: `needs about ${est} tokens, ${budget.tokens - tokens} left`,\n });\n continue;\n }\n tokens += est;\n }\n ids.push(item.id);\n }\n return { ids, skipped };\n}\n\nexport function scrumCeremonies(methodology: () => Methodology): Record<string, Ceremony> {\n const act = (\n state: WorkflowState,\n type: string,\n input: CeremonyInput,\n reduce: (s: WorkflowState, now: string) => WorkflowState,\n ) =>\n applyAction(state, methodology(), { type, by: input.by, payload: input }, (s) =>\n reduce(s, nowOf(input.now)),\n );\n\n const refine: Ceremony = (state, input) => {\n requireCap(state, input.by, \"define-acceptance\", \"deliver\");\n const items = (input[\"items\"] ?? []) as Array<{ id: string; patch: ItemPatch }>;\n const split = (input[\"split\"] ?? []) as Array<{ from: string; into: NewItem[] }>;\n const reestimateRaw: unknown = input[\"reestimate\"] ?? [];\n if (!Array.isArray(reestimateRaw) || !reestimateRaw.every((x) => typeof x === \"string\"))\n fail(\n \"invalid-input\",\n \"refine.reestimate must be a list of item ids\",\n 'pass reestimate: [\"A\"]',\n );\n const reestimate = reestimateRaw as string[];\n if (items.length === 0 && split.length === 0 && reestimate.length === 0)\n fail(\n \"invalid-input\",\n \"refine needs items[], split[] or reestimate[]\",\n \"pass at least one patch, split or reestimate\",\n );\n for (const id of reestimate) {\n const it = getItem(state, id);\n if (it.stage !== \"backlog\" || it.status !== \"todo\" || it.weight === undefined)\n fail(\n \"invalid-input\",\n `item \"${id}\" has no weight to confirm in the Product Backlog`,\n \"refine it with a patch { weight } instead\",\n { items: [id] },\n );\n }\n return act(state, \"ceremony.refine\", input, (s, now) => {\n for (const { id, patch } of items) s = editItem(s, id, patch, input.by, now);\n for (const id of reestimate)\n s = appendEvent(\n s,\n \"item.reestimated\",\n input.by,\n { id, weight: getItem(s, id).weight },\n now,\n );\n for (const sp of split) {\n getItem(s, sp.from);\n for (const n of sp.into) s = addItem(s, { ...n, parent: sp.from }, input.by, now);\n s = moveItem(s, sp.from, { status: \"dropped\" }, input.by, now);\n }\n return appendEvent(\n s,\n \"ceremony.refine\",\n input.by,\n {\n edited: items.map((i) => i.id),\n split: split.map((x) => ({ from: x.from, into: x.into.map((n) => n.id) })),\n reestimated: reestimate,\n },\n now,\n );\n });\n };\n\n const plan: Ceremony = (state, input) => {\n requireCap(state, input.by, \"facilitate\");\n const goal = input[\"goal\"];\n if (typeof goal !== \"string\" || goal.trim() === \"\")\n fail(\n \"invalid-input\",\n \"sprint planning needs a non-empty goal\",\n \"state the Sprint Goal in one sentence\",\n );\n const cfg = configOf(state);\n const budget = (input[\"budget\"] as Budget | undefined) ?? cfg.sprintBudget;\n const auto = input[\"items\"] === \"auto\" ? selectAuto(state, budget) : undefined;\n const skipped = auto?.skipped ?? [];\n const wanted = auto ? auto.ids : (input[\"items\"] as string[] | undefined);\n if (!Array.isArray(wanted))\n fail(\n \"invalid-input\",\n 'sprint planning needs items: string[] or \"auto\"',\n 'pass [\"A\",\"B\"] or \"auto\"',\n );\n if (wanted.length === 0)\n fail(\n \"invalid-input\",\n `no backlog items fit the sprint${\n skipped.length\n ? `; skipped: ${skipped.map((x) => `${x.id} (${x.reason}: ${x.detail})`).join(\", \")}`\n : \"\"\n }`,\n \"refine the backlog (acceptance + estimates) or raise the budget with exwf config set\",\n );\n for (const id of wanted) assertCommittable(state, id);\n return act(state, \"ceremony.plan\", input, (s, now) => {\n const id = `S${s.iterations.length + 1}`;\n const last = lastClosedIteration(s);\n const carryover = wanted.filter((w) => last?.carryover.includes(w));\n const resumed: string[] = [];\n for (const w of wanted) {\n const rs = resumeStageOf(getItem(s, w), s);\n if (rs) resumed.push(w);\n s = moveItem(\n s,\n w,\n rs ? { stage: rs, status: \"review\" } : { stage: \"sprint\", status: \"todo\" },\n input.by,\n now,\n );\n s = patchItem(s, w, (it) => ({ ...it, iteration: id }));\n }\n s = attachQuestions(s, wanted, id, input.by, now);\n const committedWeight = wanted.reduce((sum, w) => sum + (s.items[w]?.weight ?? 0), 0);\n s = {\n ...s,\n iterations: [\n ...s.iterations,\n {\n id,\n goal,\n budget,\n spent: { tokens: 0, turns: 0, wallclockMs: 0 },\n startedAt: now,\n committed: [...wanted],\n carryover,\n },\n ],\n };\n return appendEvent(\n s,\n \"sprint.opened\",\n input.by,\n { id, goal, committed: wanted, committedWeight, budget, skipped, resumed },\n now,\n );\n });\n };\n\n const commit: Ceremony = (state, input) => {\n const it = openIteration(state);\n if (!it) fail(\"invalid-input\", \"no open sprint to commit into\", \"run the plan ceremony first\");\n const items = input[\"items\"] as string[] | undefined;\n if (!Array.isArray(items) || items.length === 0)\n fail(\"invalid-input\", \"commit needs items[]\", 'pass [\"A\"]');\n const seen = new Set<string>();\n for (const id of items) {\n if (seen.has(id))\n fail(\"invalid-input\", `item \"${id}\" appears twice in items[]`, \"list each item once\", {\n items: [id],\n });\n seen.add(id);\n getItem(state, id);\n if (it.committed.includes(id))\n fail(\"invalid-input\", `item \"${id}\" is already committed to ${it.id}`, \"nothing to do\", {\n items: [id],\n });\n assertCommittable(state, id);\n }\n return act(state, \"ceremony.commit\", input, (s, now) => {\n const resumed: string[] = [];\n for (const id of items) {\n const rs = resumeStageOf(getItem(s, id), s);\n if (rs) resumed.push(id);\n s = moveItem(\n s,\n id,\n rs ? { stage: rs, status: \"review\" } : { stage: \"sprint\", status: \"todo\" },\n input.by,\n now,\n );\n s = patchItem(s, id, (x) => ({ ...x, iteration: it.id }));\n }\n s = attachQuestions(s, items, it.id, input.by, now);\n s = {\n ...s,\n iterations: s.iterations.map((x) =>\n x.id === it.id ? { ...x, committed: [...x.committed, ...items] } : x,\n ),\n };\n return appendEvent(\n s,\n \"sprint.committed\",\n input.by,\n { id: it.id, items, goalImpact: input[\"goalImpact\"] ?? null, resumed },\n now,\n );\n });\n };\n\n const uncommit: Ceremony = (state, input) => {\n requireCap(state, input.by, \"order-backlog\");\n const it = openIteration(state);\n if (!it) fail(\"invalid-input\", \"no open sprint\", \"nothing to uncommit from\");\n const items = input[\"items\"] as string[] | undefined;\n if (!Array.isArray(items) || items.length === 0)\n fail(\"invalid-input\", \"uncommit needs items[]\", 'pass [\"A\"]');\n for (const id of items) {\n if (getItem(state, id).status === \"done\")\n fail(\"invalid-input\", `item \"${id}\" is done`, \"finished work cannot be uncommitted\", {\n items: [id],\n });\n }\n for (const id of items)\n if (!it.committed.includes(id))\n fail(\n \"invalid-input\",\n `item \"${id}\" is not committed to ${it.id}`,\n `committed: ${it.committed.join(\", \")}`,\n { items: [id] },\n );\n return act(state, \"ceremony.uncommit\", input, (s, now) => {\n for (const id of items) {\n s = moveItem(s, id, { stage: \"backlog\", status: \"todo\" }, input.by, now);\n s = stripItemFields(s, id, [\"iteration\", \"role\"]);\n }\n s = {\n ...s,\n iterations: s.iterations.map((x) =>\n x.id === it.id ? { ...x, committed: x.committed.filter((c) => !items.includes(c)) } : x,\n ),\n };\n return appendEvent(\n s,\n \"sprint.uncommitted\",\n input.by,\n { id: it.id, items, reason: input[\"reason\"] ?? \"\" },\n now,\n );\n });\n };\n\n const daily: Ceremony = (state, input) =>\n act(state, \"ceremony.daily\", input, (s, now) =>\n appendEvent(s, \"daily\", input.by, dailyReport(s), now),\n );\n\n const review: Ceremony = (state, input) => {\n const it = openIteration(state);\n if (!it) fail(\"invalid-input\", \"no open sprint to review\", \"run the plan ceremony first\");\n const approvers = approverIds(state, \"sprint-review\");\n if (input.by !== \"human\" && !approvers.includes(input.by)) {\n fail(\n \"gate-unmet\",\n `\"${input.by}\" may not accept the Sprint Review`,\n `run review as \"human\" or as ${approvers.join(\", \") || \"a role with canApprove sprint-review\"}`,\n { rule: \"sprint-review\" },\n );\n }\n const feedback = (input[\"feedback\"] ?? []) as NewItem[];\n return act(state, \"ceremony.review\", input, (s, now) => {\n for (const n of feedback) s = addItem(s, { ...n, stage: \"backlog\" }, input.by, now);\n const done = it.committed.filter((id) => s.items[id]?.status === \"done\");\n s = appendEvent(\n s,\n \"increment\",\n input.by,\n {\n sprint: it.id,\n done,\n goalMet: input[\"goalMet\"] === true,\n accepted: input[\"accepted\"] === true,\n feedback: feedback.map((f) => f.id),\n },\n now,\n );\n return closeSprint(s, \"review\", now);\n });\n };\n\n const retro: Ceremony = (state, input) => {\n requireCap(state, input.by, \"facilitate\");\n const last = lastClosedIteration(state);\n if (!last)\n fail(\n \"invalid-input\",\n \"no closed sprint to retrospect\",\n \"close the sprint (review or cancel) first\",\n );\n if (openIteration(state))\n fail(\n \"invalid-input\",\n \"a sprint is still open\",\n \"retro runs between sprints; review or cancel the open one\",\n );\n const closedAt = closedSeq(state, last.id);\n if (state.events.some((e) => e.type === \"retro\" && e.seq > closedAt))\n fail(\n \"invalid-input\",\n `sprint ${last.id} already has a retrospective`,\n \"plan the next sprint\",\n );\n const newLessons = (input[\"lessons\"] ?? []) as Array<{\n text: string;\n scope: Lesson[\"scope\"];\n from?: string;\n item?: string;\n suggestedChange?: LessonChange;\n }>;\n const roleIds = [\"human\", ...Object.keys(state.roles)];\n for (const l of newLessons) {\n if (l.from !== undefined && (typeof l.from !== \"string\" || !roleIds.includes(l.from)))\n fail(\n \"invalid-input\",\n `lesson from ${JSON.stringify(l.from)} is not a role`,\n `from is \"human\" or one of the roles: ${Object.keys(state.roles).join(\", \") || \"(none)\"}`,\n );\n if (l.item !== undefined) {\n if (typeof l.item !== \"string\")\n fail(\n \"invalid-input\",\n \"lesson item must be an item id\",\n \"name an item with addItem first\",\n );\n getItem(state, l.item);\n }\n }\n const retireRaw: unknown = input[\"retire\"] ?? [];\n if (\n !Array.isArray(retireRaw) ||\n !retireRaw.every((x) => typeof x === \"string\") ||\n retireRaw.some((x, i) => retireRaw.indexOf(x) !== i)\n )\n fail(\n \"invalid-input\",\n \"retro.retire must be a list of distinct agreement texts\",\n 'e.g. { \"retire\": [\"review in a fresh worker\"] }; each agreement once',\n );\n const retire = retireRaw as string[];\n const adopt = (input[\"adopt\"] ?? []) as Array<{ id: string; suggestedChange?: LessonChange }>;\n const dismiss = (input[\"dismiss\"] ?? []) as string[];\n const dod = input[\"dodChanges\"] as Policy[] | undefined;\n const refs = [...adopt.map((a) => a.id), ...dismiss];\n const dupe = refs.find((r, i) => refs.indexOf(r) !== i);\n if (dupe)\n fail(\n \"invalid-input\",\n `lesson \"${dupe}\" is referenced more than once`,\n \"adopt or dismiss each lesson once\",\n );\n for (const ref of refs) {\n const l = state.lessons.find((x) => x.id === ref);\n if (!l)\n fail(\n \"invalid-input\",\n `no lesson \"${ref}\"`,\n `raised lessons: ${\n state.lessons\n .filter((x) => x.status === \"raised\")\n .map((x) => x.id)\n .join(\", \") || \"(none)\"\n }`,\n );\n if (l.status !== \"raised\")\n fail(\n \"invalid-input\",\n `lesson \"${ref}\" is already ${l.status}`,\n \"only raised lessons can be adopted or dismissed\",\n );\n }\n return act(state, \"ceremony.retro\", input, (s, now) => {\n const adopted: string[] = [];\n const agreements: string[] = [];\n const backlogAdded: string[] = [];\n let dodChanged = false;\n const applyChange = (c: LessonChange | undefined) => {\n if (!c) return;\n if (c.kind === \"agreement\") {\n s = applyAgreement(s, c, input.by, now);\n agreements.push(c.text);\n } else if (c.kind === \"dod\") {\n const cur = configOf(s).definitionOfDone;\n if (!cur.some((p) => JSON.stringify(p) === JSON.stringify(c.policy))) {\n dodChanged = true;\n s = setDod(s, [...cur, c.policy]);\n }\n } else if (c.kind === \"backlog\") {\n s = addItem(\n s,\n { ...c.item, stage: \"backlog\", tags: [...(c.item.tags ?? []), \"retro\"] },\n input.by,\n now,\n );\n backlogAdded.push(c.item.id);\n }\n };\n for (const l of newLessons) {\n const id = `L${s.lessons.length + 1}`;\n const lesson: Lesson = {\n id,\n at: now,\n text: l.text,\n scope: l.scope,\n status: \"adopted\",\n from: l.from ?? input.by,\n };\n if (l.item !== undefined) lesson.item = l.item;\n if (l.suggestedChange) lesson.suggestedChange = l.suggestedChange;\n s = { ...s, lessons: [...s.lessons, lesson] };\n adopted.push(id);\n applyChange(l.suggestedChange);\n }\n for (const a of adopt) {\n s = {\n ...s,\n lessons: s.lessons.map((x) =>\n x.id === a.id\n ? {\n ...x,\n status: \"adopted\" as const,\n ...(a.suggestedChange ? { suggestedChange: a.suggestedChange } : {}),\n }\n : x,\n ),\n };\n adopted.push(a.id);\n applyChange(a.suggestedChange ?? s.lessons.find((x) => x.id === a.id)?.suggestedChange);\n }\n for (const d of dismiss)\n s = {\n ...s,\n lessons: s.lessons.map((x) => (x.id === d ? { ...x, status: \"dismissed\" as const } : x)),\n };\n for (const text of retire) s = retireAgreement(s, text, input.by, now);\n if (dod) {\n dodChanged = true;\n s = setDod(s, dod);\n }\n return appendEvent(\n s,\n \"retro\",\n input.by,\n {\n sprint: last.id,\n adopted,\n dismissed: dismiss,\n agreements,\n retired: retire,\n dodChanged,\n backlogAdded,\n },\n now,\n );\n });\n };\n\n const cancel: Ceremony = (state, input) => {\n requireCap(state, input.by, \"order-backlog\");\n const it = openIteration(state);\n if (!it) fail(\"invalid-input\", \"no open sprint to cancel\", \"nothing to do\");\n return act(state, \"ceremony.cancel\", input, (s, now) => {\n s = appendEvent(\n s,\n \"sprint.cancelled\",\n input.by,\n { id: it.id, reason: input[\"reason\"] ?? \"\" },\n now,\n );\n return closeSprint(s, \"cancel\", now);\n });\n };\n\n return { refine, plan, commit, uncommit, daily, review, retro, cancel };\n}\n","import type { EstimateMode } from \"../budget.ts\";\nimport { fail } from \"../errors.ts\";\nimport type { Budget, Policy } from \"../types.ts\";\n\nexport interface ScrumConfig {\n sprintBudget: Budget;\n productGoal: string;\n definitionOfDone: Policy[];\n refinementSharePct: number;\n allowMidSprintAdd: \"never\" | \"po-only\" | \"any\";\n inProgressWipLimit?: number;\n /** Close the sprint automatically when its budget is spent and nothing is in flight; default true. */\n autoClose?: boolean;\n /** How the planner and sprint planning price a candidate; default \"per-weight\". */\n estimateMode?: EstimateMode;\n /** Tokens per weight unit when no accounting history exists; default 20000. */\n fallbackTokensPerWeight?: number;\n}\n\nconst ADD_MODES = new Set([\"never\", \"po-only\", \"any\"]);\n\nexport function validateScrumConfig(raw: unknown): ScrumConfig {\n const c = (raw ?? {}) as Record<string, unknown>;\n const budget = c[\"sprintBudget\"] as Budget | undefined;\n if (\n !budget ||\n typeof budget !== \"object\" ||\n (budget.tokens === undefined && budget.turns === undefined && budget.wallclockMs === undefined)\n ) {\n fail(\n \"config-invalid\",\n \"scrum config.sprintBudget must define tokens, turns or wallclockMs\",\n 'e.g. { \"sprintBudget\": { \"tokens\": 400000, \"turns\": 60 } }',\n );\n }\n if (typeof c[\"productGoal\"] !== \"string\" || c[\"productGoal\"].trim() === \"\")\n fail(\n \"config-invalid\",\n \"scrum config.productGoal must be a non-empty string\",\n \"state the Product Goal in one sentence\",\n );\n if (!Array.isArray(c[\"definitionOfDone\"]))\n fail(\n \"config-invalid\",\n \"scrum config.definitionOfDone must be a Policy[]\",\n 'e.g. [{ \"kind\": \"evidence\", \"evidenceKind\": \"test-output\" }]',\n );\n const share = c[\"refinementSharePct\"] ?? 10;\n if (typeof share !== \"number\" || share < 0 || share > 100)\n fail(\n \"config-invalid\",\n \"scrum config.refinementSharePct must be 0..100\",\n \"omit it for the default 10\",\n );\n const add = c[\"allowMidSprintAdd\"] ?? \"po-only\";\n if (typeof add !== \"string\" || !ADD_MODES.has(add))\n fail(\n \"config-invalid\",\n `scrum config.allowMidSprintAdd must be never | po-only | any (got ${JSON.stringify(add)})`,\n 'use \"po-only\" unless you have a reason',\n );\n const wip = c[\"inProgressWipLimit\"];\n if (wip !== undefined && (typeof wip !== \"number\" || wip < 1))\n fail(\n \"config-invalid\",\n \"scrum config.inProgressWipLimit must be a positive number\",\n \"omit it for no limit\",\n );\n const autoClose = c[\"autoClose\"];\n if (autoClose !== undefined && typeof autoClose !== \"boolean\")\n fail(\n \"config-invalid\",\n \"scrum config.autoClose must be true or false\",\n \"omit it for the default true\",\n );\n const mode = c[\"estimateMode\"];\n if (mode !== undefined && mode !== \"per-weight\" && mode !== \"per-call\")\n fail(\n \"config-invalid\",\n `scrum config.estimateMode must be per-weight | per-call (got ${JSON.stringify(mode)})`,\n 'use \"per-weight\" (the default) or \"per-call\"',\n );\n const fallback = c[\"fallbackTokensPerWeight\"];\n if (\n fallback !== undefined &&\n (typeof fallback !== \"number\" || !Number.isFinite(fallback) || fallback <= 0)\n )\n fail(\n \"config-invalid\",\n \"scrum config.fallbackTokensPerWeight must be a positive finite number\",\n \"omit it for the default 20000\",\n );\n const out: ScrumConfig = {\n sprintBudget: budget,\n productGoal: c[\"productGoal\"],\n definitionOfDone: c[\"definitionOfDone\"] as Policy[],\n refinementSharePct: share,\n allowMidSprintAdd: add as ScrumConfig[\"allowMidSprintAdd\"],\n };\n if (wip !== undefined) out.inProgressWipLimit = wip as number;\n if (autoClose !== undefined) out.autoClose = autoClose as boolean;\n if (mode !== undefined) out.estimateMode = mode as EstimateMode;\n if (fallback !== undefined) out.fallbackTokensPerWeight = fallback as number;\n return out;\n}\n","import { openIteration } from \"../planner.ts\";\nimport type { Budget, WorkflowState } from \"../types.ts\";\n\ninterface Closed {\n id?: string;\n reason: string;\n done: string[];\n carryover: string[];\n doneWeight: number;\n committedWeight: number;\n spent: Required<Budget>;\n budget: Budget;\n}\n\nexport interface ScrumMetrics {\n velocity: number[];\n meanVelocity: number;\n burndown: number[];\n commitmentReliability: number;\n sprintGoalHitRate: number;\n carryoverRatio: number;\n budgetUtilisation: number;\n costPerPoint: number;\n /** The open sprint right now; all zeros when none is open. */\n current: Record<string, number>;\n}\n\nconst ratio = (num: number, den: number) => (den === 0 ? 0 : num / den);\n\nexport function scrumMetrics(state: WorkflowState): ScrumMetrics {\n const corrections = state.events.filter((e) => e.type === \"accounting.corrected\");\n const closed = state.events\n .filter((e) => e.type === \"sprint.closed\")\n .map((e) => {\n const c = e.payload as Closed;\n // corrections recorded after the close still belong to that sprint's spend\n const late = corrections\n .filter(\n (x) =>\n x.seq > e.seq &&\n c.id !== undefined &&\n (x.payload as { iteration: string | null }).iteration === c.id,\n )\n .reduce((sum, x) => sum + (x.payload as { delta: { tokens: number } }).delta.tokens, 0);\n return late === 0 ? c : { ...c, spent: { ...c.spent, tokens: c.spent.tokens + late } };\n });\n const counted = closed.filter((c) => c.reason !== \"cancel\");\n const velocity = counted.map((c) => c.doneWeight);\n const doneWeight = counted.reduce((s, c) => s + c.doneWeight, 0);\n const committedWeight = counted.reduce((s, c) => s + c.committedWeight, 0);\n const increments = state.events\n .filter((e) => e.type === \"increment\")\n .map((e) => e.payload as { goalMet: boolean });\n const withTokens = closed.filter((c) => c.budget.tokens !== undefined);\n const tokensSpent = counted.reduce((s, c) => s + c.spent.tokens, 0);\n return {\n velocity,\n meanVelocity: ratio(\n velocity.reduce((s, x) => s + x, 0),\n velocity.length,\n ),\n burndown: state.events\n .filter((e) => e.type === \"daily\")\n .map((e) => (e.payload as { remainingWeight: number }).remainingWeight),\n commitmentReliability: ratio(doneWeight, committedWeight),\n sprintGoalHitRate: ratio(increments.filter((i) => i.goalMet).length, increments.length),\n carryoverRatio: ratio(\n closed.reduce((s, c) => s + c.carryover.length, 0),\n closed.reduce((s, c) => s + c.done.length + c.carryover.length, 0),\n ),\n budgetUtilisation: ratio(\n withTokens.reduce((s, c) => s + c.spent.tokens, 0),\n withTokens.reduce((s, c) => s + (c.budget.tokens ?? 0), 0),\n ),\n costPerPoint: ratio(tokensSpent, doneWeight), // cost per delivered point over completed sprints\n current: currentSprint(state),\n };\n}\n\nfunction currentSprint(state: WorkflowState): Record<string, number> {\n const it = openIteration(state);\n const items = (it?.committed ?? []).map((id) => state.items[id]).filter((i) => i !== undefined);\n const weight = (list: typeof items) => list.reduce((sum, i) => sum + (i.weight ?? 0), 0);\n const committedWeight = weight(items);\n const doneWeight = weight(items.filter((i) => i.status === \"done\"));\n const spentTokens = it?.spent.tokens ?? 0;\n const budgetTokens = it?.budget.tokens ?? 0;\n return {\n spentTokens,\n spentTurns: it?.spent.turns ?? 0,\n budgetTokens,\n committedWeight,\n doneWeight,\n remainingWeight: committedWeight - doneWeight,\n costPerPoint: ratio(spentTokens, doneWeight),\n budgetUtilisation: ratio(spentTokens, budgetTokens),\n };\n}\n","import type { Role } from \"../types.ts\";\n\nexport function scrumRoles(): Role[] {\n return [\n {\n id: \"product-owner\",\n name: \"Product Owner\",\n modelTier: \"large\",\n capabilities: [\"order-backlog\", \"define-acceptance\", \"escalate\"],\n canApprove: [\"sprint-review\"],\n inputs: [\"stakeholder-needs\", \"product-goal\"],\n outputs: [\"ordered-backlog\", \"acceptance-criteria\"],\n do_not: [\"do not implement items yourself\"],\n },\n {\n id: \"scrum-master\",\n name: \"Scrum Master\",\n modelTier: \"large\",\n capabilities: [\"facilitate\", \"escalate\"],\n canApprove: [],\n inputs: [\"board\", \"blockers\"],\n outputs: [\"ceremony-records\", \"lessons\"],\n do_not: [\"do not reorder the Product Backlog\", \"do not assign work; the planner pulls\"],\n },\n {\n id: \"developer\",\n name: \"Developer\",\n modelTier: \"small\",\n capabilities: [\"deliver\", \"review\", \"verify\"],\n canApprove: [],\n inputs: [\"brief\"],\n outputs: [\"code\", \"test-output\"],\n do_not: [\"do not change acceptance criteria\", \"do not touch items outside your brief\"],\n },\n ];\n}\n","import { fail } from \"../errors.ts\";\nimport { openIteration } from \"../planner.ts\";\nimport type { Budget, Iteration, Policy, Rule, Violation, WorkflowState } from \"../types.ts\";\nimport type { ItemPatch } from \"../items.ts\";\nimport { canDo, closedSeq } from \"./ceremonies.ts\";\nimport { configOf, resumeStageOf } from \"./index.ts\";\n\nconst v = (\n rule: string,\n severity: Violation[\"severity\"],\n message: string,\n fix: string,\n item?: string,\n): Violation => (item ? { rule, severity, item, message, fix } : { rule, severity, message, fix });\n\nfunction lastClosed(state: WorkflowState): Iteration | undefined {\n for (let i = state.iterations.length - 1; i >= 0; i--) {\n const it = state.iterations[i]!;\n if (it.endedAt !== undefined) return it;\n }\n return undefined;\n}\n/** Canonical identity of a Definition of Done policy, independent of JSON key order. */\nconst policyKey = (p: Policy): string =>\n p.kind === \"evidence\"\n ? `evidence:${p.evidenceKind}`\n : p.kind === \"custom\"\n ? `custom:${p.id}`\n : p.kind;\n\nexport function scrumRules(): Rule[] {\n const oneOpen: Rule = {\n id: \"one-open-sprint\",\n severity: \"error\",\n check: (s, a) =>\n a.type === \"ceremony.plan\" && openIteration(s)\n ? [\n v(\n \"one-open-sprint\",\n \"error\",\n `sprint ${openIteration(s)!.id} is still open`,\n \"review or cancel it before planning the next sprint\",\n ),\n ]\n : [],\n };\n\n const retroFirst: Rule = {\n id: \"retro-before-plan\",\n severity: \"error\",\n check: (s, a) => {\n if (a.type !== \"ceremony.plan\") return [];\n const last = lastClosed(s);\n if (!last) return [];\n const seq = closedSeq(s, last.id);\n if (s.events.some((e) => e.type === \"retro\" && e.seq > seq)) return [];\n const sev = last.outcome === \"cancelled\" ? \"warning\" : \"error\";\n return [\n v(\n \"retro-before-plan\",\n sev,\n `sprint ${last.id} has no retrospective yet`,\n \"run the retro ceremony first (lessons may be empty)\",\n ),\n ];\n },\n };\n\n const budgetFixed: Rule = {\n id: \"sprint-budget-fixed\",\n severity: \"error\",\n check: (s, a) => {\n if (a.type !== \"ceremony.plan\") return [];\n const b = (a.payload as { budget?: Budget } | undefined)?.budget;\n if (b === undefined || JSON.stringify(b) === JSON.stringify(configOf(s).sprintBudget))\n return [];\n return [\n v(\n \"sprint-budget-fixed\",\n \"error\",\n \"sprint length is fixed by config.sprintBudget\",\n \"change sprintBudget between sprints with changeConfig / exwf config set, not per plan\",\n ),\n ];\n },\n };\n\n const scope: Rule = {\n id: \"scope-protects-goal\",\n severity: \"error\",\n check: (s, a) => {\n if (a.type !== \"ceremony.commit\") return [];\n const cfg = configOf(s);\n const p = (a.payload ?? {}) as { goalImpact?: string };\n if (cfg.allowMidSprintAdd === \"never\")\n return [\n v(\n \"scope-protects-goal\",\n \"error\",\n \"mid-sprint additions are disabled\",\n 'set allowMidSprintAdd to \"po-only\" or wait for the next sprint',\n ),\n ];\n if (cfg.allowMidSprintAdd === \"po-only\" && !canDo(s, a.by, \"order-backlog\"))\n return [\n v(\n \"scope-protects-goal\",\n \"error\",\n `\"${a.by}\" may not add work mid-sprint`,\n \"ask the Product Owner (order-backlog) to commit it\",\n ),\n ];\n if (p.goalImpact !== \"none\")\n return [\n v(\n \"scope-protects-goal\",\n \"error\",\n `adding work with goalImpact \"${p.goalImpact ?? \"unset\"}\" endangers the Sprint Goal`,\n 'only commit items with goalImpact: \"none\"; otherwise cancel and re-plan',\n ),\n ];\n return [];\n },\n };\n\n const closing: Rule = {\n id: \"sprint-closing\",\n severity: \"error\",\n check: (s, a) => {\n const it = openIteration(s);\n return a.type === \"ceremony.commit\" && it?.closing\n ? [\n v(\n \"sprint-closing\",\n \"error\",\n `sprint ${it.id} is closing: its budget is spent and no new work can start`,\n \"run ceremony review or cancel first, then plan the next sprint\",\n ),\n ]\n : [];\n },\n };\n\n const stageIds: Rule = {\n id: \"scrum-stage-ids\",\n severity: \"error\",\n check: (s, a) => {\n if (a.type !== \"init\") return [];\n const missing = [\"backlog\", \"sprint\", \"review\"].filter(\n (id) => !s.stages.some((st) => st.id === id),\n );\n if (missing.length)\n fail(\n \"config-invalid\",\n `scrum stages lack the required id(s): ${missing.join(\", \")}`,\n \"keep the stages backlog, sprint and review (omit stages to use the defaults), then run exwf init scrum again\",\n );\n return [];\n },\n };\n\n const poOrders: Rule = {\n id: \"po-orders-backlog\",\n severity: \"error\",\n check: (s, a) => {\n if (a.type !== \"ceremony.refine\" || canDo(s, a.by, \"order-backlog\")) return [];\n const items =\n ((a.payload ?? {}) as { items?: Array<{ id: string; patch: ItemPatch }> }).items ?? [];\n return items\n .filter((i) => i.patch.priority !== undefined)\n .map((i) =>\n v(\n \"po-orders-backlog\",\n \"error\",\n `\"${a.by}\" may not change the priority of \"${i.id}\"`,\n \"only the Product Owner orders the backlog; drop priority from the patch\",\n i.id,\n ),\n );\n },\n };\n\n const dod: Rule = {\n id: \"dod-not-weakened\",\n severity: \"error\",\n check: (s, a) => {\n if (a.type !== \"ceremony.retro\") return [];\n const p = (a.payload ?? {}) as { dodChanges?: unknown; allowWeaken?: boolean };\n if (p.dodChanges === undefined) return [];\n if (openIteration(s))\n return [\n v(\n \"dod-not-weakened\",\n \"error\",\n \"Definition of Done cannot change while a sprint is open\",\n \"close the sprint first; DoD changes apply to the next sprint\",\n ),\n ];\n if (!Array.isArray(p.dodChanges) || p.allowWeaken === true) return [];\n const next = p.dodChanges as Policy[];\n const kept = new Set(next.map(policyKey));\n const removed = configOf(s).definitionOfDone.filter((q) => !kept.has(policyKey(q)));\n if (removed.length === 0) return [];\n const describe = removed.map((q) => policyKey(q).replace(\":\", \" \"));\n return [\n v(\n \"dod-not-weakened\",\n \"error\",\n `retro dodChanges drops ${removed.length} Definition of Done policy(ies): ${describe.join(\", \")}`,\n 'keep them in dodChanges (it replaces the whole list; suggestedChange { kind: \"dod\" } appends one), or pass allowWeaken: true to weaken the Definition of Done knowingly',\n ),\n ];\n },\n };\n\n const carry: Rule = {\n id: \"carryover-reestimated\",\n severity: \"error\",\n check: (s, a) => {\n if (a.type !== \"ceremony.plan\") return [];\n const items = (a.payload as { items?: string[] | \"auto\" } | undefined)?.items;\n if (!Array.isArray(items)) return [];\n const last = lastClosed(s);\n if (!last) return [];\n const seq = closedSeq(s, last.id);\n return items\n .filter(\n (id) =>\n last.carryover.includes(id) &&\n !(s.items[id] && resumeStageOf(s.items[id], s) !== undefined) &&\n !s.events.some(\n (e) =>\n e.seq > seq &&\n (e.payload as { id: string }).id === id &&\n ((e.type === \"item.edited\" &&\n (e.payload as { changed: string[] }).changed.includes(\"weight\")) ||\n e.type === \"item.reestimated\"),\n ),\n )\n .map((id) =>\n v(\n \"carryover-reestimated\",\n \"error\",\n `carried-over item \"${id}\" was not re-estimated after ${last.id}`,\n \"refine it with a new weight before committing\",\n id,\n ),\n );\n },\n };\n\n return [oneOpen, retroFirst, budgetFixed, closing, stageIds, scope, poOrders, dod, carry];\n}\n","import type { Stage } from \"../types.ts\";\nimport type { ScrumConfig } from \"./config.ts\";\n\nexport function scrumStages(config: ScrumConfig): Stage[] {\n const inProgress: Stage = {\n id: \"in_progress\",\n name: \"In progress\",\n entryPolicy: [{ kind: \"dependencies-done\" }],\n exitPolicy: [],\n };\n if (config.inProgressWipLimit !== undefined) inProgress.wipLimit = config.inProgressWipLimit;\n return [\n {\n id: \"backlog\",\n name: \"Product Backlog\",\n entryPolicy: [],\n exitPolicy: [{ kind: \"acceptance-written\" }, { kind: \"estimate-present\" }],\n },\n { id: \"sprint\", name: \"Sprint Backlog\", entryPolicy: [], exitPolicy: [] },\n inProgress,\n {\n id: \"review\",\n name: \"Review\",\n entryPolicy: [],\n exitPolicy: config.definitionOfDone,\n review: true,\n },\n { id: \"done\", name: \"Increment\", entryPolicy: [], exitPolicy: [] },\n ];\n}\n","import { isExhausted, remaining } from \"../budget.ts\";\nimport { getItem, moveItem, patchItem, stripItemFields } from \"../items.ts\";\nimport { openIteration } from \"../planner.ts\";\nimport { appendEvent } from \"../state.ts\";\nimport type { CoreTerm, Methodology, PlannerOptions, WorkItem, WorkflowState } from \"../types.ts\";\nimport { scrumCeremonies, setDod } from \"./ceremonies.ts\";\nimport { validateScrumConfig, type ScrumConfig } from \"./config.ts\";\nimport { scrumMetrics, type ScrumMetrics } from \"./metrics.ts\";\nimport { scrumRoles } from \"./roles.ts\";\nimport { scrumRules } from \"./rules.ts\";\nimport { scrumStages } from \"./stages.ts\";\n\nexport { validateScrumConfig, scrumRoles, scrumRules, scrumStages, scrumMetrics };\nexport type { ScrumMetrics };\nexport type { ScrumConfig };\nexport { scrumCeremonies, dailyReport, canDo } from \"./ceremonies.ts\";\nexport type { DailyReport } from \"./ceremonies.ts\";\n\nexport const SCRUM_VOCABULARY: Record<CoreTerm, string> = {\n backlog: \"Product Backlog\",\n item: \"Product Backlog Item\",\n stage: \"Column\",\n iteration: \"Sprint\",\n increment: \"Increment\",\n ceremony: \"Scrum Event\",\n gate: \"Sprint Review\",\n};\n\n/** Advanced; used by ceremonies. */\nexport function configOf(state: WorkflowState): ScrumConfig {\n return state.config as ScrumConfig;\n}\n\n/**\n * The stage a carried-over item was returned from when it was in a review stage: it resumes there, not at the\n * sprint start. closeSprint releases blocked and awaiting_human items, so the stage (its `review` flag) is read from\n * the last system transition, not the status. Without `state` only a `review` status is recognised.\n */\nexport function resumeStageOf(item: WorkItem, state?: WorkflowState): string | undefined {\n const t = item.transitions.at(-1);\n if (!t || t.by !== \"system\" || t.to.stage !== \"backlog\" || t.to.status !== \"todo\")\n return undefined;\n if (!state) return t.from.status === \"review\" ? t.from.stage : undefined;\n const st = state.stages.find((x) => x.id === t.from.stage);\n return st?.review || t.from.status === \"review\" ? t.from.stage : undefined;\n}\n\n/** Send an item back to the backlog: clear its open blockers and pending decisions, strip iteration and role. */\nfunction toBacklog(state: WorkflowState, id: string, now: string): WorkflowState {\n let s = state;\n const open = getItem(s, id).blockers.filter((b) => !b.clearedAt);\n if (open.length) {\n s = patchItem(s, id, (it) => ({\n ...it,\n blockers: it.blockers.map((b) => (b.clearedAt ? b : { ...b, clearedAt: now })),\n }));\n for (const b of open)\n s = appendEvent(\n s,\n \"blocker.cleared\",\n \"system\",\n { id, blocker: b.id, reason: \"sprint closed\" },\n now,\n );\n }\n for (const p of s.pending.filter((x) => x.item === id)) {\n s = { ...s, pending: s.pending.filter((x) => x.id !== p.id) };\n s = appendEvent(\n s,\n \"pending.dropped\",\n \"system\",\n { id: p.id, item: id, reason: \"sprint closed\" },\n now,\n );\n }\n const cur = getItem(s, id);\n if (cur.stage !== \"backlog\" || cur.status !== \"todo\")\n s = moveItem(s, id, { stage: \"backlog\", status: \"todo\" }, \"system\", now);\n // a question keeps its role: only the escalation target can answer it\n return stripItemFields(s, id, cur.type === \"question\" ? [\"iteration\"] : [\"iteration\", \"role\"]);\n}\n\n/** Advanced; used by ceremonies. Closes the open sprint and returns unfinished work (and its open questions) to the backlog. */\nexport function closeSprint(\n state: WorkflowState,\n reason: \"budget\" | \"review\" | \"cancel\",\n now: string,\n): WorkflowState {\n const it = openIteration(state);\n if (!it) return state;\n const committed = it.committed.map((id) => getItem(state, id));\n const done = committed.filter((i) => i.status === \"done\").map((i) => i.id);\n const dropped = committed.filter((i) => i.status === \"dropped\").map((i) => i.id);\n const carryover = committed\n .filter((i) => i.status !== \"done\" && i.status !== \"dropped\")\n .map((i) => i.id);\n const carriedQuestions = Object.values(state.items)\n .filter(\n (i) =>\n i.type === \"question\" &&\n i.parent !== undefined &&\n carryover.includes(i.parent) &&\n i.status !== \"done\" &&\n i.status !== \"dropped\",\n )\n .map((i) => i.id);\n let s: WorkflowState = state;\n for (const id of [...carryover, ...carriedQuestions]) s = toBacklog(s, id, now);\n const weightOf = (ids: string[]) =>\n ids.reduce((sum, id) => sum + (state.items[id]?.weight ?? 0), 0);\n s = {\n ...s,\n iterations: s.iterations.map((x) => {\n if (x.id !== it.id) return x;\n const { closing: _c, ...rest } = x;\n return {\n ...rest,\n endedAt: now,\n outcome: reason === \"cancel\" ? \"cancelled\" : \"completed\",\n carryover,\n };\n }),\n };\n return appendEvent(\n s,\n \"sprint.closed\",\n \"system\",\n {\n id: it.id,\n reason,\n done,\n carryover,\n carriedQuestions,\n dropped,\n doneWeight: weightOf(done),\n committedWeight: weightOf(it.committed),\n spent: it.spent,\n budget: it.budget,\n },\n now,\n );\n}\n\nexport function scrum(): Methodology<ScrumConfig> {\n return {\n name: \"scrum\",\n vocabulary: SCRUM_VOCABULARY,\n validateConfig: validateScrumConfig,\n defaultStages: scrumStages,\n defaultRoles: scrumRoles,\n requiredCapabilities: [\"order-backlog\", \"facilitate\", \"deliver\"],\n exclusiveCapabilities: [\"order-backlog\"],\n plannerOptions(state): PlannerOptions {\n const cfg = configOf(state);\n const po: PlannerOptions = { schedulerMode: \"level\", dispatchStage: \"in_progress\" };\n if (cfg.inProgressWipLimit !== undefined) po.concurrencyCap = cfg.inProgressWipLimit;\n if (cfg.estimateMode !== undefined) po.estimateMode = cfg.estimateMode;\n if (cfg.fallbackTokensPerWeight !== undefined)\n po.fallbackTokensPerWeight = cfg.fallbackTokensPerWeight;\n return po;\n },\n candidates(state): WorkItem[] {\n const it = openIteration(state);\n if (!it || it.closing) return [];\n return Object.values(state.items).filter(\n (i) =>\n i.iteration === it.id &&\n (i.status === \"todo\" || i.status === \"review\") &&\n (i.stage === \"sprint\" || i.stage === \"review\"),\n );\n },\n invariants(state, item): string[] {\n const it = openIteration(state);\n const cfg = configOf(state);\n const left = it ? remaining(it.budget, it.spent) : {};\n return [\n `Sprint Goal: ${it?.goal ?? \"(no open sprint)\"}; Product Goal: ${cfg.productGoal}`,\n `Budget remaining: ${JSON.stringify(left)}; stop and hand off when it is gone`,\n `Definition of Done: ${cfg.definitionOfDone.map((p) => (p.kind === \"evidence\" ? `evidence ${p.evidenceKind}` : p.kind)).join(\", \") || \"(none)\"}`,\n `Do not change the scope of \"${item.id}\" or its acceptance criteria; raise open_questions instead`,\n ];\n },\n ceremonies: scrumCeremonies(scrum),\n rules: scrumRules(),\n metrics: (state) => ({ ...scrumMetrics(state) }),\n report(state) {\n const it = openIteration(state);\n return {\n closing: it?.closing === true,\n sprint: it?.id ?? null,\n reason: it?.closing ? \"budget\" : null,\n inFlight: it\n ? Object.values(state.items)\n .filter(\n (i) =>\n (i.iteration === it.id || it.committed.includes(i.id)) &&\n i.status === \"in_progress\",\n )\n .map((i) => i.id)\n : [],\n };\n },\n humanDefaults: { gates: [\"sprint-review\"] },\n afterConfigChange(state) {\n return setDod(state, configOf(state).definitionOfDone);\n },\n afterComplete(state, _itemId, now) {\n const it = openIteration(state);\n if (!it || (!it.closing && !isExhausted(it.budget, it.spent))) return state;\n const inFlight = Object.values(state.items).some(\n (i) => (i.iteration === it.id || it.committed.includes(i.id)) && i.status === \"in_progress\",\n );\n if (!inFlight && configOf(state).autoClose !== false)\n return closeSprint(state, \"budget\", now);\n if (it.closing) return state;\n return appendEvent(\n {\n ...state,\n iterations: state.iterations.map((x) => (x.id === it.id ? { ...x, closing: true } : x)),\n },\n \"sprint.closing\",\n \"system\",\n { id: it.id },\n now,\n );\n },\n };\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import {b as b$1,d,e}from'./chunk-5TXYMLBF.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 m=".workflow";function v(t){return n.join(t,m,"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:w=50,staleMs:u=6e4}=i,s=n.join(t,m,"state.lock");await mkdir(n.dirname(s),{recursive:true});let d=false;for(let f=0;!d;f++)try{let a=await open(s,"wx");await a.writeFile(`${process.pid} ${new Date().toISOString()}
2
+ `),await a.close(),d=!0;}catch(a){if(a.code!=="EEXIST")throw a;let o=await stat(s).catch(()=>{});if(o&&Date.now()-o.mtimeMs>u){let l=await stat(s).catch(()=>{});l&&l.ino===o.ino&&l.mtimeMs===o.mtimeMs&&await unlink(s).catch(()=>{});continue}f>=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(l=>setTimeout(l,w));}try{return await e()}finally{await unlink(s).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(f){b("invalid-input",`${e$1} is not valid JSON: ${f.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 w=r;w.version!==1&&b("state-version",`${e$1} has schema version ${String(w.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 u=n.join(t,m,"roles"),s=[];try{s=(await readdir(u)).filter(f=>f.endsWith(".json"));}catch{}let d$1={...w.roles};for(let f of s){let a=n.join(u,f),o;try{o=JSON.parse(await readFile(a,"utf8"));}catch(l){b("invalid-input",`role manifest ${a} is not valid JSON: ${l.message}`,"fix or delete that manifest");}b$1(e,o,`role manifest ${a}`),d$1[o.id]||(d$1[o.id]=o);}return {...w,roles:d$1}}function j(t,e){return n.resolve(e).startsWith(n.resolve(t,m)+n.sep)||b("invalid-input",`${e} resolves outside ${m}/`,"use a plain item id (letters, digits, - _ .)"),e}async function L(t,e){let i=j(t,n.join(t,m,"briefs",`${e.item.id}.json`));return await y(i,JSON.stringify(e,null,2)+`
4
+ `),i}async function A(t,e,i){let r=j(t,n.join(t,m,"handoffs",`${e.item}-${i}.json`));return await y(r,JSON.stringify(e,null,2)+`
5
+ `),r}export{m as a,v as b,T as c,B as d,F as e,L as f,A as g};//# sourceMappingURL=chunk-7IG6EQI4.mjs.map
6
+ //# sourceMappingURL=chunk-7IG6EQI4.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","snap","stat","now","resolve","saveState","state","json","assertValid","workflowStateSchema","loadState","raw","readFile","parsed","rolesDir","manifests","readdir","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,OAAA,CAAQE,CAAI,EAAG,CAAE,SAAA,CAAW,EAAK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AM5C,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,CAAAA,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-7IG6EQI4.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 snap = await stat(lock).catch(() => undefined);\n if (snap && Date.now() - snap.mtimeMs > staleMs) {\n // re-stat just before unlink: if another recoverer already replaced the lock, leave it alone\n const now = await stat(lock).catch(() => undefined);\n if (now && now.ino === snap.ino && now.mtimeMs === snap.mtimeMs)\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"]}