ex-workflow 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +6 -4
  3. package/dist/{chunk-PFHVB2WT.mjs → chunk-3QUIRAXO.mjs} +2 -2
  4. package/dist/{chunk-PFHVB2WT.mjs.map → chunk-3QUIRAXO.mjs.map} +1 -1
  5. package/dist/chunk-3RJ4RNPG.cjs +2 -0
  6. package/dist/chunk-3RJ4RNPG.cjs.map +1 -0
  7. package/dist/chunk-66BO7JFR.cjs +2 -0
  8. package/dist/chunk-66BO7JFR.cjs.map +1 -0
  9. package/dist/{chunk-UMG3WOD7.cjs → chunk-76ITDJDM.cjs} +2 -2
  10. package/dist/{chunk-UMG3WOD7.cjs.map → chunk-76ITDJDM.cjs.map} +1 -1
  11. package/dist/chunk-AWFR3Q4M.mjs +2 -0
  12. package/dist/{chunk-5ZGNEY2I.mjs.map → chunk-AWFR3Q4M.mjs.map} +1 -1
  13. package/dist/chunk-BGKXIRGS.mjs +2 -0
  14. package/dist/chunk-BGKXIRGS.mjs.map +1 -0
  15. package/dist/chunk-BNKKOAMP.mjs +2 -0
  16. package/dist/{chunk-ILDXZWEL.mjs.map → chunk-BNKKOAMP.mjs.map} +1 -1
  17. package/dist/{chunk-YGCNLXPJ.cjs → chunk-CPM2SPDX.cjs} +2 -2
  18. package/dist/{chunk-YGCNLXPJ.cjs.map → chunk-CPM2SPDX.cjs.map} +1 -1
  19. package/dist/{chunk-EQXYFHHD.cjs → chunk-G6QELJRL.cjs} +2 -2
  20. package/dist/{chunk-EQXYFHHD.cjs.map → chunk-G6QELJRL.cjs.map} +1 -1
  21. package/dist/{chunk-UT7QV6CE.mjs → chunk-HXEJP6KF.mjs} +2 -2
  22. package/dist/{chunk-UT7QV6CE.mjs.map → chunk-HXEJP6KF.mjs.map} +1 -1
  23. package/dist/chunk-ILNSTPPV.mjs +2 -0
  24. package/dist/chunk-ILNSTPPV.mjs.map +1 -0
  25. package/dist/chunk-LQJPLXFR.cjs +2 -0
  26. package/dist/{chunk-RGHM3JJM.cjs.map → chunk-LQJPLXFR.cjs.map} +1 -1
  27. package/dist/chunk-MUQ4FKVH.mjs +2 -0
  28. package/dist/chunk-MUQ4FKVH.mjs.map +1 -0
  29. package/dist/chunk-N2NANHRW.mjs +2 -0
  30. package/dist/{chunk-5DCOXGRW.mjs.map → chunk-N2NANHRW.mjs.map} +1 -1
  31. package/dist/chunk-NNQ3RHDP.mjs +2 -0
  32. package/dist/chunk-NNQ3RHDP.mjs.map +1 -0
  33. package/dist/chunk-OAJ4KV4F.mjs +2 -0
  34. package/dist/{chunk-3S7F5QXK.mjs.map → chunk-OAJ4KV4F.mjs.map} +1 -1
  35. package/dist/chunk-OFFQTZEY.cjs +2 -0
  36. package/dist/chunk-OFFQTZEY.cjs.map +1 -0
  37. package/dist/chunk-QKW26EV2.mjs +2 -0
  38. package/dist/chunk-QKW26EV2.mjs.map +1 -0
  39. package/dist/{chunk-BANKVCYY.cjs → chunk-RMXEQ5HN.cjs} +2 -2
  40. package/dist/{chunk-BANKVCYY.cjs.map → chunk-RMXEQ5HN.cjs.map} +1 -1
  41. package/dist/chunk-TBLIZIWH.cjs +2 -0
  42. package/dist/chunk-TBLIZIWH.cjs.map +1 -0
  43. package/dist/{chunk-4F5HZLKD.cjs → chunk-U23IRPFF.cjs} +2 -2
  44. package/dist/{chunk-4F5HZLKD.cjs.map → chunk-U23IRPFF.cjs.map} +1 -1
  45. package/dist/chunk-WM3JM3H7.mjs +2 -0
  46. package/dist/chunk-WM3JM3H7.mjs.map +1 -0
  47. package/dist/chunk-YNYIHJOC.mjs +2 -0
  48. package/dist/{chunk-5GXB6GMX.mjs.map → chunk-YNYIHJOC.mjs.map} +1 -1
  49. package/dist/chunk-YRXFEM3F.cjs +2 -0
  50. package/dist/chunk-YRXFEM3F.cjs.map +1 -0
  51. package/dist/{chunk-3ZUBCA7Q.cjs → chunk-ZDT2BZGU.cjs} +2 -2
  52. package/dist/{chunk-3ZUBCA7Q.cjs.map → chunk-ZDT2BZGU.cjs.map} +1 -1
  53. package/dist/{chunk-H26KXQ3I.cjs → chunk-ZK3V66NC.cjs} +2 -2
  54. package/dist/{chunk-H26KXQ3I.cjs.map → chunk-ZK3V66NC.cjs.map} +1 -1
  55. package/dist/cli/bin.cjs +1 -1
  56. package/dist/cli/bin.cjs.map +1 -1
  57. package/dist/cli/bin.mjs +1 -1
  58. package/dist/cli/bin.mjs.map +1 -1
  59. package/dist/cli/index.cjs +1 -1
  60. package/dist/cli/index.mjs +1 -1
  61. package/dist/experimentation/index.cjs +1 -1
  62. package/dist/experimentation/index.mjs +1 -1
  63. package/dist/index.cjs +1 -1
  64. package/dist/index.cjs.map +1 -1
  65. package/dist/index.d.cts +9 -8
  66. package/dist/index.d.ts +9 -8
  67. package/dist/index.mjs +1 -1
  68. package/dist/index.mjs.map +1 -1
  69. package/dist/investigation/index.cjs +1 -1
  70. package/dist/investigation/index.mjs +1 -1
  71. package/dist/kanban/index.cjs +1 -1
  72. package/dist/kanban/index.mjs +1 -1
  73. package/dist/policies/index.cjs +1 -1
  74. package/dist/policies/index.cjs.map +1 -1
  75. package/dist/policies/index.d.cts +4 -1
  76. package/dist/policies/index.d.ts +4 -1
  77. package/dist/policies/index.mjs +1 -1
  78. package/dist/policies/index.mjs.map +1 -1
  79. package/dist/registry/index.cjs +1 -1
  80. package/dist/registry/index.mjs +1 -1
  81. package/dist/scrum/index.cjs +1 -1
  82. package/dist/scrum/index.mjs +1 -1
  83. package/dist/waterfall/index.cjs +1 -1
  84. package/dist/waterfall/index.mjs +1 -1
  85. package/package.json +1 -1
  86. package/dist/chunk-2FBA7RBS.cjs +0 -2
  87. package/dist/chunk-2FBA7RBS.cjs.map +0 -1
  88. package/dist/chunk-3S7F5QXK.mjs +0 -2
  89. package/dist/chunk-5DCOXGRW.mjs +0 -2
  90. package/dist/chunk-5GXB6GMX.mjs +0 -2
  91. package/dist/chunk-5ZGNEY2I.mjs +0 -2
  92. package/dist/chunk-COPYGMHE.mjs +0 -2
  93. package/dist/chunk-COPYGMHE.mjs.map +0 -1
  94. package/dist/chunk-CVGEIXW6.cjs +0 -2
  95. package/dist/chunk-CVGEIXW6.cjs.map +0 -1
  96. package/dist/chunk-CX2E7ZTQ.mjs +0 -2
  97. package/dist/chunk-CX2E7ZTQ.mjs.map +0 -1
  98. package/dist/chunk-ILDXZWEL.mjs +0 -2
  99. package/dist/chunk-LG23WXAP.mjs +0 -2
  100. package/dist/chunk-LG23WXAP.mjs.map +0 -1
  101. package/dist/chunk-MU26QW32.cjs +0 -2
  102. package/dist/chunk-MU26QW32.cjs.map +0 -1
  103. package/dist/chunk-OEHVWRJG.mjs +0 -2
  104. package/dist/chunk-OEHVWRJG.mjs.map +0 -1
  105. package/dist/chunk-RGHM3JJM.cjs +0 -2
@@ -1,2 +1,2 @@
1
- 'use strict';var chunk3ZUBCA7Q_cjs=require('./chunk-3ZUBCA7Q.cjs'),chunkYGCNLXPJ_cjs=require('./chunk-YGCNLXPJ.cjs'),chunk2FBA7RBS_cjs=require('./chunk-2FBA7RBS.cjs'),chunkUMG3WOD7_cjs=require('./chunk-UMG3WOD7.cjs'),chunk4F5HZLKD_cjs=require('./chunk-4F5HZLKD.cjs'),chunkOSHBJIYD_cjs=require('./chunk-OSHBJIYD.cjs');var N=[["vocabulary","object"],["validateConfig","function"],["defaultStages","function"],["defaultRoles","function"],["requiredCapabilities","array"],["exclusiveCapabilities","array"],["plannerOptions","function"],["candidates","function"],["invariants","function"],["ceremonies","object"],["rules","array"],["metrics","function"],["humanDefaults","object"]],b=r=>{try{return String(r)}catch{return "a non-Error value"}};function M(r){let e=new Map,l=(o,t,w=false)=>{if(chunkOSHBJIYD_cjs.c(o,"methodology name"),typeof t!="function"&&chunkOSHBJIYD_cjs.b("invalid-input",`methodology "${o}" factory must be a function`,'pass the factory itself, e.g. registerMethodology("triage", triage)'),e.has(o)&&chunkOSHBJIYD_cjs.b("invalid-input",`methodology "${o}" is already registered`,`pick a name that is not one of: ${[...e.keys()].join(", ")}`),!w){let n;try{n=t();}catch(i){if(i instanceof chunkOSHBJIYD_cjs.a)throw i;chunkOSHBJIYD_cjs.b("invalid-input",`methodology "${o}" factory threw: ${b(i)}`,"fix the factory: registration calls it once");}let y=typeof n!="object"||n===null?"an object":n.name!==o?`name "${o}"`:N.find(([i,d])=>d==="array"?!Array.isArray(n[i]):typeof n[i]!==d||!n[i])?.[0];y&&chunkOSHBJIYD_cjs.b("invalid-input",`methodology "${o}" factory must return a Methodology; it lacks ${y}`,"return the full Methodology object (name, vocabulary, validateConfig, defaultStages, defaultRoles, capabilities, plannerOptions, candidates, invariants, ceremonies, rules, metrics, humanDefaults)");}e.set(o,t);};for(let[o,t]of Object.entries(r))l(o,t,true);return {registerMethodology:(o,t)=>l(o,t),methodologyFactory(o){chunkOSHBJIYD_cjs.c(o,"methodology name");let t=e.get(o);return t||chunkOSHBJIYD_cjs.b("invalid-input",`unknown methodology "${o}"`,`known methodologies: ${[...e.keys()].join(", ")||"(none)"}; register a custom one with registerMethodology`),t},registeredMethodologies:()=>[...e.keys()]}}var v,g=()=>v??=M({scrum:chunk3ZUBCA7Q_cjs.l,kanban:chunkYGCNLXPJ_cjs.I,waterfall:chunk2FBA7RBS_cjs.N,investigation:chunkUMG3WOD7_cjs.b,experimentation:chunk4F5HZLKD_cjs.h});function S(r,e){g().registerMethodology(r,e);}function O(r){return g().methodologyFactory(r)}function A(){return g().registeredMethodologies()}exports.a=S;exports.b=O;exports.c=A;//# sourceMappingURL=chunk-EQXYFHHD.cjs.map
2
- //# sourceMappingURL=chunk-EQXYFHHD.cjs.map
1
+ 'use strict';var chunkZDT2BZGU_cjs=require('./chunk-ZDT2BZGU.cjs'),chunkCPM2SPDX_cjs=require('./chunk-CPM2SPDX.cjs'),chunkOFFQTZEY_cjs=require('./chunk-OFFQTZEY.cjs'),chunk76ITDJDM_cjs=require('./chunk-76ITDJDM.cjs'),chunkU23IRPFF_cjs=require('./chunk-U23IRPFF.cjs'),chunkOSHBJIYD_cjs=require('./chunk-OSHBJIYD.cjs');var N=[["vocabulary","object"],["validateConfig","function"],["defaultStages","function"],["defaultRoles","function"],["requiredCapabilities","array"],["exclusiveCapabilities","array"],["plannerOptions","function"],["candidates","function"],["invariants","function"],["ceremonies","object"],["rules","array"],["metrics","function"],["humanDefaults","object"]],b=r=>{try{return String(r)}catch{return "a non-Error value"}};function M(r){let e=new Map,l=(o,t,w=false)=>{if(chunkOSHBJIYD_cjs.c(o,"methodology name"),typeof t!="function"&&chunkOSHBJIYD_cjs.b("invalid-input",`methodology "${o}" factory must be a function`,'pass the factory itself, e.g. registerMethodology("triage", triage)'),e.has(o)&&chunkOSHBJIYD_cjs.b("invalid-input",`methodology "${o}" is already registered`,`pick a name that is not one of: ${[...e.keys()].join(", ")}`),!w){let n;try{n=t();}catch(i){if(i instanceof chunkOSHBJIYD_cjs.a)throw i;chunkOSHBJIYD_cjs.b("invalid-input",`methodology "${o}" factory threw: ${b(i)}`,"fix the factory: registration calls it once");}let y=typeof n!="object"||n===null?"an object":n.name!==o?`name "${o}"`:N.find(([i,d])=>d==="array"?!Array.isArray(n[i]):typeof n[i]!==d||!n[i])?.[0];y&&chunkOSHBJIYD_cjs.b("invalid-input",`methodology "${o}" factory must return a Methodology; it lacks ${y}`,"return the full Methodology object (name, vocabulary, validateConfig, defaultStages, defaultRoles, capabilities, plannerOptions, candidates, invariants, ceremonies, rules, metrics, humanDefaults)");}e.set(o,t);};for(let[o,t]of Object.entries(r))l(o,t,true);return {registerMethodology:(o,t)=>l(o,t),methodologyFactory(o){chunkOSHBJIYD_cjs.c(o,"methodology name");let t=e.get(o);return t||chunkOSHBJIYD_cjs.b("invalid-input",`unknown methodology "${o}"`,`known methodologies: ${[...e.keys()].join(", ")||"(none)"}; register a custom one with registerMethodology`),t},registeredMethodologies:()=>[...e.keys()]}}var v,g=()=>v??=M({scrum:chunkZDT2BZGU_cjs.l,kanban:chunkCPM2SPDX_cjs.I,waterfall:chunkOFFQTZEY_cjs.N,investigation:chunk76ITDJDM_cjs.b,experimentation:chunkU23IRPFF_cjs.h});function S(r,e){g().registerMethodology(r,e);}function O(r){return g().methodologyFactory(r)}function A(){return g().registeredMethodologies()}exports.a=S;exports.b=O;exports.c=A;//# sourceMappingURL=chunk-G6QELJRL.cjs.map
2
+ //# sourceMappingURL=chunk-G6QELJRL.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/registry.ts","../src/registry.ts"],"names":["MEMBERS","thrown","e","createMethodologyRegistry","initial","table","register","name","factory","builtIn","assertId","fail","m","WorkflowError","missing","key","kind","registry","builtins","scrum","kanban","waterfall","investigation","experimentation","registerMethodology","methodologyFactory","registeredMethodologies"],"mappings":"6TAoBA,IAAMA,EAAU,CACd,CAAC,YAAA,CAAc,QAAQ,EACvB,CAAC,gBAAA,CAAkB,UAAU,CAAA,CAC7B,CAAC,eAAA,CAAiB,UAAU,CAAA,CAC5B,CAAC,eAAgB,UAAU,CAAA,CAC3B,CAAC,sBAAA,CAAwB,OAAO,CAAA,CAChC,CAAC,uBAAA,CAAyB,OAAO,EACjC,CAAC,gBAAA,CAAkB,UAAU,CAAA,CAC7B,CAAC,YAAA,CAAc,UAAU,EACzB,CAAC,YAAA,CAAc,UAAU,CAAA,CACzB,CAAC,YAAA,CAAc,QAAQ,EACvB,CAAC,OAAA,CAAS,OAAO,CAAA,CACjB,CAAC,SAAA,CAAW,UAAU,CAAA,CACtB,CAAC,gBAAiB,QAAQ,CAC5B,EAOMC,CAAAA,CAAUC,CAAAA,EAAuB,CACrC,GAAI,CACF,OAAO,MAAA,CAAOA,CAAC,CACjB,CAAA,KAAQ,CACN,OAAO,mBACT,CACF,CAAA,CAEO,SAASC,CAAAA,CAGdC,EACqB,CACrB,IAAMC,EAAQ,IAAI,GAAA,CACZC,EAAW,CAACC,CAAAA,CAAcC,CAAAA,CAAkBC,CAAAA,CAA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cesContent":["import { WorkflowError, assertId, fail } from \"../core/errors.ts\";\nimport type { Methodology } from \"../core/types.ts\";\n\n/** A methodology factory, as the built-in entries export them (`scrum`, `kanban`, ...). */\nexport type MethodologyFactory<N extends string = string> = () => Methodology<unknown, N>;\n\n/** Name -> factory lookup: what `exwf init <name>` and a state's `methodology` resolve through. */\nexport interface MethodologyRegistry {\n /**\n * Adds `name`; a name already registered (a built-in included) fails `invalid-input`. The\n * factory is called once to check that it returns a Methodology named `name`.\n */\n registerMethodology<C, N extends string>(name: N, factory: () => Methodology<C, N>): void;\n /** The factory registered under `name`; an unknown name fails `invalid-input` listing the known ones. */\n methodologyFactory<N extends string = string>(name: N): MethodologyFactory<N>;\n /** Registered names, pre-registered ones first, then in registration order. */\n registeredMethodologies(): string[];\n}\n\n// the required members of a Methodology (src/core/types.ts) and their runtime kinds\nconst MEMBERS = [\n [\"vocabulary\", \"object\"],\n [\"validateConfig\", \"function\"],\n [\"defaultStages\", \"function\"],\n [\"defaultRoles\", \"function\"],\n [\"requiredCapabilities\", \"array\"],\n [\"exclusiveCapabilities\", \"array\"],\n [\"plannerOptions\", \"function\"],\n [\"candidates\", \"function\"],\n [\"invariants\", \"function\"],\n [\"ceremonies\", \"object\"],\n [\"rules\", \"array\"],\n [\"metrics\", \"function\"],\n [\"humanDefaults\", \"object\"],\n] as const;\n\n/**\n * A registry pre-registered with `initial`. The interface layer cannot import the methodologies,\n * so the outer ring passes the five built-ins in (design spec section 26, \"Registry placement\").\n */\n// String() throws on a null-prototype value; for an Error it reads `Name: message`\nconst thrown = (e: unknown): string => {\n try {\n return String(e);\n } catch {\n return \"a non-Error value\";\n }\n};\n\nexport function createMethodologyRegistry(\n // factories of different names share no sound common type (a ceremony is contravariant in\n // its state's name), so the table stores them untyped and lookup restores the name\n initial: Record<string, () => unknown>,\n): MethodologyRegistry {\n const table = new Map<string, () => unknown>();\n const register = (name: string, factory: unknown, builtIn = false) => {\n assertId(name, \"methodology name\");\n if (typeof factory !== \"function\")\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory must be a function`,\n 'pass the factory itself, e.g. registerMethodology(\"triage\", triage)',\n );\n if (table.has(name))\n fail(\n \"invalid-input\",\n `methodology \"${name}\" is already registered`,\n `pick a name that is not one of: ${[...table.keys()].join(\", \")}`,\n );\n // a custom factory runs once here, so a wrong result fails at registration, not at init\n if (!builtIn) {\n let m: Record<string, unknown> | null;\n try {\n m = (factory as () => unknown)() as Record<string, unknown> | null;\n } catch (e) {\n if (e instanceof WorkflowError) throw e;\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory threw: ${thrown(e)}`,\n \"fix the factory: registration calls it once\",\n );\n }\n const missing =\n typeof m !== \"object\" || m === null\n ? \"an object\"\n : m[\"name\"] !== name\n ? `name \"${name}\"`\n : MEMBERS.find(([key, kind]) =>\n kind === \"array\" ? !Array.isArray(m[key]) : typeof m[key] !== kind || !m[key],\n )?.[0];\n if (missing)\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory must return a Methodology; it lacks ${missing}`,\n \"return the full Methodology object (name, vocabulary, validateConfig, defaultStages, defaultRoles, capabilities, plannerOptions, candidates, invariants, ceremonies, rules, metrics, humanDefaults)\",\n );\n }\n table.set(name, factory as () => unknown);\n };\n for (const [name, factory] of Object.entries(initial)) register(name, factory, true);\n return {\n registerMethodology: (name, factory) => register(name, factory),\n methodologyFactory<N extends string>(name: N): MethodologyFactory<N> {\n assertId(name, \"methodology name\");\n const factory = table.get(name);\n if (!factory)\n fail(\n \"invalid-input\",\n `unknown methodology \"${name}\"`,\n `known methodologies: ${[...table.keys()].join(\", \") || \"(none)\"}; register a custom one with registerMethodology`,\n );\n return factory as MethodologyFactory<N>;\n },\n registeredMethodologies: () => [...table.keys()],\n };\n}\n","// The `ex-workflow/registry` entry: the methodology registry with the five built-ins\n// pre-registered (design spec section 26, \"Registry placement\"). Outer ring: src/interface/ may\n// not import src/methodologies/, so the built-in table lives here; the CLI resolves through it. The registry is created on first use, so a bundle that never\n// calls these functions does not keep the built-in factories.\nimport { experimentation } from \"./methodologies/experimentation/index.ts\";\nimport { investigation } from \"./methodologies/investigation/index.ts\";\nimport { kanban } from \"./methodologies/kanban/index.ts\";\nimport { scrum } from \"./methodologies/scrum/index.ts\";\nimport { waterfall } from \"./methodologies/waterfall/index.ts\";\nimport {\n createMethodologyRegistry,\n type MethodologyFactory,\n type MethodologyRegistry,\n} from \"./interface/registry.ts\";\nimport type { Methodology } from \"./core/types.ts\";\n\nexport type { MethodologyFactory, MethodologyRegistry };\n\nlet registry: MethodologyRegistry | undefined;\nconst builtins = (): MethodologyRegistry =>\n (registry ??= createMethodologyRegistry({\n scrum,\n kanban,\n waterfall,\n investigation,\n experimentation,\n }));\n\n/** Registers a custom methodology (SDK only in 1.2); a taken name, a built-in included, fails `invalid-input`. */\nexport function registerMethodology<C, N extends string>(\n name: N,\n factory: () => Methodology<C, N>,\n): void {\n builtins().registerMethodology(name, factory);\n}\n\n/** The factory registered under `name`; an unknown name fails `invalid-input` listing the known ones. */\nexport function methodologyFactory<N extends string = string>(name: N): MethodologyFactory<N> {\n return builtins().methodologyFactory(name);\n}\n\n/** The registered names: the five built-ins, then custom ones in registration order. */\nexport function registeredMethodologies(): string[] {\n return builtins().registeredMethodologies();\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/registry.ts","../src/registry.ts"],"names":["MEMBERS","thrown","e","createMethodologyRegistry","initial","table","register","name","factory","builtIn","assertId","fail","m","WorkflowError","missing","key","kind","registry","builtins","scrum","kanban","waterfall","investigation","experimentation","registerMethodology","methodologyFactory","registeredMethodologies"],"mappings":"6TAoBA,IAAMA,EAAU,CACd,CAAC,YAAA,CAAc,QAAQ,EACvB,CAAC,gBAAA,CAAkB,UAAU,CAAA,CAC7B,CAAC,eAAA,CAAiB,UAAU,CAAA,CAC5B,CAAC,eAAgB,UAAU,CAAA,CAC3B,CAAC,sBAAA,CAAwB,OAAO,CAAA,CAChC,CAAC,uBAAA,CAAyB,OAAO,EACjC,CAAC,gBA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CACEC,CAAAA,CAAW,IACdD,CAAAA,GAAad,CAAAA,CAA0B,CACtC,KAAA,CAAAgB,mBAAAA,CACA,MAAA,CAAAC,mBAAAA,CACA,UAAAC,mBAAAA,CACA,aAAA,CAAAC,mBAAAA,CACA,eAAA,CAAAC,mBACF,CAAC,CAAA,CAGI,SAASC,CAAAA,CACdjB,EACAC,CAAAA,CACM,CACNU,GAAS,CAAE,mBAAA,CAAoBX,EAAMC,CAAO,EAC9C,CAGO,SAASiB,EAA8ClB,CAAAA,CAAgC,CAC5F,OAAOW,CAAAA,GAAW,kBAAA,CAAmBX,CAAI,CAC3C,CAGO,SAASmB,CAAAA,EAAoC,CAClD,OAAOR,CAAAA,EAAS,CAAE,yBACpB","file":"chunk-G6QELJRL.cjs","sourcesContent":["import { WorkflowError, assertId, fail } from \"../core/errors.ts\";\nimport type { Methodology } from \"../core/types.ts\";\n\n/** A methodology factory, as the built-in entries export them (`scrum`, `kanban`, ...). */\nexport type MethodologyFactory<N extends string = string> = () => Methodology<unknown, N>;\n\n/** Name -> factory lookup: what `exwf init <name>` and a state's `methodology` resolve through. */\nexport interface MethodologyRegistry {\n /**\n * Adds `name`; a name already registered (a built-in included) fails `invalid-input`. The\n * factory is called once to check that it returns a Methodology named `name`.\n */\n registerMethodology<C, N extends string>(name: N, factory: () => Methodology<C, N>): void;\n /** The factory registered under `name`; an unknown name fails `invalid-input` listing the known ones. */\n methodologyFactory<N extends string = string>(name: N): MethodologyFactory<N>;\n /** Registered names, pre-registered ones first, then in registration order. */\n registeredMethodologies(): string[];\n}\n\n// the required members of a Methodology (src/core/types.ts) and their runtime kinds\nconst MEMBERS = [\n [\"vocabulary\", \"object\"],\n [\"validateConfig\", \"function\"],\n [\"defaultStages\", \"function\"],\n [\"defaultRoles\", \"function\"],\n [\"requiredCapabilities\", \"array\"],\n [\"exclusiveCapabilities\", \"array\"],\n [\"plannerOptions\", \"function\"],\n [\"candidates\", \"function\"],\n [\"invariants\", \"function\"],\n [\"ceremonies\", \"object\"],\n [\"rules\", \"array\"],\n [\"metrics\", \"function\"],\n [\"humanDefaults\", \"object\"],\n] as const;\n\n/**\n * A registry pre-registered with `initial`. The interface layer cannot import the methodologies,\n * so the outer ring passes the five built-ins in (design spec section 26, \"Registry placement\").\n */\n// String() throws on a null-prototype value; for an Error it reads `Name: message`\nconst thrown = (e: unknown): string => {\n try {\n return String(e);\n } catch {\n return \"a non-Error value\";\n }\n};\n\nexport function createMethodologyRegistry(\n // factories of different names share no sound common type (a ceremony is contravariant in\n // its state's name), so the table stores them untyped and lookup restores the name\n initial: Record<string, () => unknown>,\n): MethodologyRegistry {\n const table = new Map<string, () => unknown>();\n const register = (name: string, factory: unknown, builtIn = false) => {\n assertId(name, \"methodology name\");\n if (typeof factory !== \"function\")\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory must be a function`,\n 'pass the factory itself, e.g. registerMethodology(\"triage\", triage)',\n );\n if (table.has(name))\n fail(\n \"invalid-input\",\n `methodology \"${name}\" is already registered`,\n `pick a name that is not one of: ${[...table.keys()].join(\", \")}`,\n );\n // a custom factory runs once here, so a wrong result fails at registration, not at init\n if (!builtIn) {\n let m: Record<string, unknown> | null;\n try {\n m = (factory as () => unknown)() as Record<string, unknown> | null;\n } catch (e) {\n if (e instanceof WorkflowError) throw e;\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory threw: ${thrown(e)}`,\n \"fix the factory: registration calls it once\",\n );\n }\n const missing =\n typeof m !== \"object\" || m === null\n ? \"an object\"\n : m[\"name\"] !== name\n ? `name \"${name}\"`\n : MEMBERS.find(([key, kind]) =>\n kind === \"array\" ? !Array.isArray(m[key]) : typeof m[key] !== kind || !m[key],\n )?.[0];\n if (missing)\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory must return a Methodology; it lacks ${missing}`,\n \"return the full Methodology object (name, vocabulary, validateConfig, defaultStages, defaultRoles, capabilities, plannerOptions, candidates, invariants, ceremonies, rules, metrics, humanDefaults)\",\n );\n }\n table.set(name, factory as () => unknown);\n };\n for (const [name, factory] of Object.entries(initial)) register(name, factory, true);\n return {\n registerMethodology: (name, factory) => register(name, factory),\n methodologyFactory<N extends string>(name: N): MethodologyFactory<N> {\n assertId(name, \"methodology name\");\n const factory = table.get(name);\n if (!factory)\n fail(\n \"invalid-input\",\n `unknown methodology \"${name}\"`,\n `known methodologies: ${[...table.keys()].join(\", \") || \"(none)\"}; register a custom one with registerMethodology`,\n );\n return factory as MethodologyFactory<N>;\n },\n registeredMethodologies: () => [...table.keys()],\n };\n}\n","// The `ex-workflow/registry` entry: the methodology registry with the five built-ins\n// pre-registered (design spec section 26, \"Registry placement\"). Outer ring: src/interface/ may\n// not import src/methodologies/, so the built-in table lives here; the CLI resolves through it. The registry is created on first use, so a bundle that never\n// calls these functions does not keep the built-in factories.\nimport { experimentation } from \"./methodologies/experimentation/index.ts\";\nimport { investigation } from \"./methodologies/investigation/index.ts\";\nimport { kanban } from \"./methodologies/kanban/index.ts\";\nimport { scrum } from \"./methodologies/scrum/index.ts\";\nimport { waterfall } from \"./methodologies/waterfall/index.ts\";\nimport {\n createMethodologyRegistry,\n type MethodologyFactory,\n type MethodologyRegistry,\n} from \"./interface/registry.ts\";\nimport type { Methodology } from \"./core/types.ts\";\n\nexport type { MethodologyFactory, MethodologyRegistry };\n\nlet registry: MethodologyRegistry | undefined;\nconst builtins = (): MethodologyRegistry =>\n (registry ??= createMethodologyRegistry({\n scrum,\n kanban,\n waterfall,\n investigation,\n experimentation,\n }));\n\n/** Registers a custom methodology (SDK only in 1.2); a taken name, a built-in included, fails `invalid-input`. */\nexport function registerMethodology<C, N extends string>(\n name: N,\n factory: () => Methodology<C, N>,\n): void {\n builtins().registerMethodology(name, factory);\n}\n\n/** The factory registered under `name`; an unknown name fails `invalid-input` listing the known ones. */\nexport function methodologyFactory<N extends string = string>(name: N): MethodologyFactory<N> {\n return builtins().methodologyFactory(name);\n}\n\n/** The registered names: the five built-ins, then custom ones in registration order. */\nexport function registeredMethodologies(): string[] {\n return builtins().registeredMethodologies();\n}\n"]}
@@ -1,2 +1,2 @@
1
- import {l}from'./chunk-5ZGNEY2I.mjs';import {I}from'./chunk-3S7F5QXK.mjs';import {N as N$1}from'./chunk-CX2E7ZTQ.mjs';import {b as b$2}from'./chunk-OEHVWRJG.mjs';import {h}from'./chunk-ILDXZWEL.mjs';import {c,b as b$1,a}from'./chunk-YS6CXERQ.mjs';var N=[["vocabulary","object"],["validateConfig","function"],["defaultStages","function"],["defaultRoles","function"],["requiredCapabilities","array"],["exclusiveCapabilities","array"],["plannerOptions","function"],["candidates","function"],["invariants","function"],["ceremonies","object"],["rules","array"],["metrics","function"],["humanDefaults","object"]],b=r=>{try{return String(r)}catch{return "a non-Error value"}};function M(r){let e=new Map,l=(o,t,w=false)=>{if(c(o,"methodology name"),typeof t!="function"&&b$1("invalid-input",`methodology "${o}" factory must be a function`,'pass the factory itself, e.g. registerMethodology("triage", triage)'),e.has(o)&&b$1("invalid-input",`methodology "${o}" is already registered`,`pick a name that is not one of: ${[...e.keys()].join(", ")}`),!w){let n;try{n=t();}catch(i){if(i instanceof a)throw i;b$1("invalid-input",`methodology "${o}" factory threw: ${b(i)}`,"fix the factory: registration calls it once");}let y=typeof n!="object"||n===null?"an object":n.name!==o?`name "${o}"`:N.find(([i,d])=>d==="array"?!Array.isArray(n[i]):typeof n[i]!==d||!n[i])?.[0];y&&b$1("invalid-input",`methodology "${o}" factory must return a Methodology; it lacks ${y}`,"return the full Methodology object (name, vocabulary, validateConfig, defaultStages, defaultRoles, capabilities, plannerOptions, candidates, invariants, ceremonies, rules, metrics, humanDefaults)");}e.set(o,t);};for(let[o,t]of Object.entries(r))l(o,t,true);return {registerMethodology:(o,t)=>l(o,t),methodologyFactory(o){c(o,"methodology name");let t=e.get(o);return t||b$1("invalid-input",`unknown methodology "${o}"`,`known methodologies: ${[...e.keys()].join(", ")||"(none)"}; register a custom one with registerMethodology`),t},registeredMethodologies:()=>[...e.keys()]}}var v,g=()=>v??=M({scrum:l,kanban:I,waterfall:N$1,investigation:b$2,experimentation:h});function S(r,e){g().registerMethodology(r,e);}function O(r){return g().methodologyFactory(r)}function A(){return g().registeredMethodologies()}export{S as a,O as b,A as c};//# sourceMappingURL=chunk-UT7QV6CE.mjs.map
2
- //# sourceMappingURL=chunk-UT7QV6CE.mjs.map
1
+ import {l}from'./chunk-AWFR3Q4M.mjs';import {I}from'./chunk-OAJ4KV4F.mjs';import {N as N$1}from'./chunk-BGKXIRGS.mjs';import {b as b$2}from'./chunk-ILNSTPPV.mjs';import {h}from'./chunk-BNKKOAMP.mjs';import {c,b as b$1,a}from'./chunk-YS6CXERQ.mjs';var N=[["vocabulary","object"],["validateConfig","function"],["defaultStages","function"],["defaultRoles","function"],["requiredCapabilities","array"],["exclusiveCapabilities","array"],["plannerOptions","function"],["candidates","function"],["invariants","function"],["ceremonies","object"],["rules","array"],["metrics","function"],["humanDefaults","object"]],b=r=>{try{return String(r)}catch{return "a non-Error value"}};function M(r){let e=new Map,l=(o,t,w=false)=>{if(c(o,"methodology name"),typeof t!="function"&&b$1("invalid-input",`methodology "${o}" factory must be a function`,'pass the factory itself, e.g. registerMethodology("triage", triage)'),e.has(o)&&b$1("invalid-input",`methodology "${o}" is already registered`,`pick a name that is not one of: ${[...e.keys()].join(", ")}`),!w){let n;try{n=t();}catch(i){if(i instanceof a)throw i;b$1("invalid-input",`methodology "${o}" factory threw: ${b(i)}`,"fix the factory: registration calls it once");}let y=typeof n!="object"||n===null?"an object":n.name!==o?`name "${o}"`:N.find(([i,d])=>d==="array"?!Array.isArray(n[i]):typeof n[i]!==d||!n[i])?.[0];y&&b$1("invalid-input",`methodology "${o}" factory must return a Methodology; it lacks ${y}`,"return the full Methodology object (name, vocabulary, validateConfig, defaultStages, defaultRoles, capabilities, plannerOptions, candidates, invariants, ceremonies, rules, metrics, humanDefaults)");}e.set(o,t);};for(let[o,t]of Object.entries(r))l(o,t,true);return {registerMethodology:(o,t)=>l(o,t),methodologyFactory(o){c(o,"methodology name");let t=e.get(o);return t||b$1("invalid-input",`unknown methodology "${o}"`,`known methodologies: ${[...e.keys()].join(", ")||"(none)"}; register a custom one with registerMethodology`),t},registeredMethodologies:()=>[...e.keys()]}}var v,g=()=>v??=M({scrum:l,kanban:I,waterfall:N$1,investigation:b$2,experimentation:h});function S(r,e){g().registerMethodology(r,e);}function O(r){return g().methodologyFactory(r)}function A(){return g().registeredMethodologies()}export{S as a,O as b,A as c};//# sourceMappingURL=chunk-HXEJP6KF.mjs.map
2
+ //# sourceMappingURL=chunk-HXEJP6KF.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/registry.ts","../src/registry.ts"],"names":["MEMBERS","thrown","e","createMethodologyRegistry","initial","table","register","name","factory","builtIn","assertId","fail","m","WorkflowError","missing","key","kind","registry","builtins","scrum","kanban","waterfall","investigation","experimentation","registerMethodology","methodologyFactory","registeredMethodologies"],"mappings":"uPAoBA,IAAMA,EAAU,CACd,CAAC,YAAA,CAAc,QAAQ,EACvB,CAAC,gBAAA,CAAkB,UAAU,CAAA,CAC7B,CAAC,eAAA,CAAiB,UAAU,CAAA,CAC5B,CAAC,eAAgB,UAAU,CAAA,CAC3B,CAAC,sBAAA,CAAwB,OAAO,CAAA,CAChC,CAAC,uBAAA,CAAyB,OAAO,EACjC,CAAC,gBAAA,CAAkB,UAAU,CAAA,CAC7B,CAAC,YAAA,CAAc,UAAU,EACzB,CAAC,YAAA,CAAc,UAAU,CAAA,CACzB,CAAC,YAAA,CAAc,QAAQ,EACvB,CAAC,OAAA,CAAS,OAAO,CAAA,CACjB,CAAC,SAAA,CAAW,UAAU,CAAA,CACtB,CAAC,gBAAiB,QAAQ,CAC5B,EAOMC,CAAAA,CAAUC,CAAAA,EAAuB,CACrC,GAAI,CACF,OAAO,MAAA,CAAOA,CAAC,CACjB,CAAA,KAAQ,CACN,OAAO,mBACT,CACF,CAAA,CAEO,SAASC,CAAAA,CAGdC,EACqB,CACrB,IAAMC,EAAQ,IAAI,GAAA,CACZC,E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E,yBACpB","file":"chunk-UT7QV6CE.mjs","sourcesContent":["import { WorkflowError, assertId, fail } from \"../core/errors.ts\";\nimport type { Methodology } from \"../core/types.ts\";\n\n/** A methodology factory, as the built-in entries export them (`scrum`, `kanban`, ...). */\nexport type MethodologyFactory<N extends string = string> = () => Methodology<unknown, N>;\n\n/** Name -> factory lookup: what `exwf init <name>` and a state's `methodology` resolve through. */\nexport interface MethodologyRegistry {\n /**\n * Adds `name`; a name already registered (a built-in included) fails `invalid-input`. The\n * factory is called once to check that it returns a Methodology named `name`.\n */\n registerMethodology<C, N extends string>(name: N, factory: () => Methodology<C, N>): void;\n /** The factory registered under `name`; an unknown name fails `invalid-input` listing the known ones. */\n methodologyFactory<N extends string = string>(name: N): MethodologyFactory<N>;\n /** Registered names, pre-registered ones first, then in registration order. */\n registeredMethodologies(): string[];\n}\n\n// the required members of a Methodology (src/core/types.ts) and their runtime kinds\nconst MEMBERS = [\n [\"vocabulary\", \"object\"],\n [\"validateConfig\", \"function\"],\n [\"defaultStages\", \"function\"],\n [\"defaultRoles\", \"function\"],\n [\"requiredCapabilities\", \"array\"],\n [\"exclusiveCapabilities\", \"array\"],\n [\"plannerOptions\", \"function\"],\n [\"candidates\", \"function\"],\n [\"invariants\", \"function\"],\n [\"ceremonies\", \"object\"],\n [\"rules\", \"array\"],\n [\"metrics\", \"function\"],\n [\"humanDefaults\", \"object\"],\n] as const;\n\n/**\n * A registry pre-registered with `initial`. The interface layer cannot import the methodologies,\n * so the outer ring passes the five built-ins in (design spec section 26, \"Registry placement\").\n */\n// String() throws on a null-prototype value; for an Error it reads `Name: message`\nconst thrown = (e: unknown): string => {\n try {\n return String(e);\n } catch {\n return \"a non-Error value\";\n }\n};\n\nexport function createMethodologyRegistry(\n // factories of different names share no sound common type (a ceremony is contravariant in\n // its state's name), so the table stores them untyped and lookup restores the name\n initial: Record<string, () => unknown>,\n): MethodologyRegistry {\n const table = new Map<string, () => unknown>();\n const register = (name: string, factory: unknown, builtIn = false) => {\n assertId(name, \"methodology name\");\n if (typeof factory !== \"function\")\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory must be a function`,\n 'pass the factory itself, e.g. registerMethodology(\"triage\", triage)',\n );\n if (table.has(name))\n fail(\n \"invalid-input\",\n `methodology \"${name}\" is already registered`,\n `pick a name that is not one of: ${[...table.keys()].join(\", \")}`,\n );\n // a custom factory runs once here, so a wrong result fails at registration, not at init\n if (!builtIn) {\n let m: Record<string, unknown> | null;\n try {\n m = (factory as () => unknown)() as Record<string, unknown> | null;\n } catch (e) {\n if (e instanceof WorkflowError) throw e;\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory threw: ${thrown(e)}`,\n \"fix the factory: registration calls it once\",\n );\n }\n const missing =\n typeof m !== \"object\" || m === null\n ? \"an object\"\n : m[\"name\"] !== name\n ? `name \"${name}\"`\n : MEMBERS.find(([key, kind]) =>\n kind === \"array\" ? !Array.isArray(m[key]) : typeof m[key] !== kind || !m[key],\n )?.[0];\n if (missing)\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory must return a Methodology; it lacks ${missing}`,\n \"return the full Methodology object (name, vocabulary, validateConfig, defaultStages, defaultRoles, capabilities, plannerOptions, candidates, invariants, ceremonies, rules, metrics, humanDefaults)\",\n );\n }\n table.set(name, factory as () => unknown);\n };\n for (const [name, factory] of Object.entries(initial)) register(name, factory, true);\n return {\n registerMethodology: (name, factory) => register(name, factory),\n methodologyFactory<N extends string>(name: N): MethodologyFactory<N> {\n assertId(name, \"methodology name\");\n const factory = table.get(name);\n if (!factory)\n fail(\n \"invalid-input\",\n `unknown methodology \"${name}\"`,\n `known methodologies: ${[...table.keys()].join(\", \") || \"(none)\"}; register a custom one with registerMethodology`,\n );\n return factory as MethodologyFactory<N>;\n },\n registeredMethodologies: () => [...table.keys()],\n };\n}\n","// The `ex-workflow/registry` entry: the methodology registry with the five built-ins\n// pre-registered (design spec section 26, \"Registry placement\"). Outer ring: src/interface/ may\n// not import src/methodologies/, so the built-in table lives here; the CLI resolves through it. The registry is created on first use, so a bundle that never\n// calls these functions does not keep the built-in factories.\nimport { experimentation } from \"./methodologies/experimentation/index.ts\";\nimport { investigation } from \"./methodologies/investigation/index.ts\";\nimport { kanban } from \"./methodologies/kanban/index.ts\";\nimport { scrum } from \"./methodologies/scrum/index.ts\";\nimport { waterfall } from \"./methodologies/waterfall/index.ts\";\nimport {\n createMethodologyRegistry,\n type MethodologyFactory,\n type MethodologyRegistry,\n} from \"./interface/registry.ts\";\nimport type { Methodology } from \"./core/types.ts\";\n\nexport type { MethodologyFactory, MethodologyRegistry };\n\nlet registry: MethodologyRegistry | undefined;\nconst builtins = (): MethodologyRegistry =>\n (registry ??= createMethodologyRegistry({\n scrum,\n kanban,\n waterfall,\n investigation,\n experimentation,\n }));\n\n/** Registers a custom methodology (SDK only in 1.2); a taken name, a built-in included, fails `invalid-input`. */\nexport function registerMethodology<C, N extends string>(\n name: N,\n factory: () => Methodology<C, N>,\n): void {\n builtins().registerMethodology(name, factory);\n}\n\n/** The factory registered under `name`; an unknown name fails `invalid-input` listing the known ones. */\nexport function methodologyFactory<N extends string = string>(name: N): MethodologyFactory<N> {\n return builtins().methodologyFactory(name);\n}\n\n/** The registered names: the five built-ins, then custom ones in registration order. */\nexport function registeredMethodologies(): string[] {\n return builtins().registeredMethodologies();\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/registry.ts","../src/registry.ts"],"names":["MEMBERS","thrown","e","createMethodologyRegistry","initial","table","register","name","factory","builtIn","assertId","fail","m","WorkflowError","missing","key","kind","registry","builtins","scrum","kanban","waterfall","investigation","experimentation","registerMethodology","methodologyFactory","registeredMethodologies"],"mappings":"uPAoBA,IAAMA,EAAU,CACd,CAAC,YAAA,CAAc,QAAQ,EACvB,CAAC,gBAAA,CAAkB,UAAU,CAAA,CAC7B,CAAC,eAAA,CAAiB,UAAU,CAAA,CAC5B,CAAC,eAAgB,UAAU,CAAA,CAC3B,CAAC,sBAAA,CAAwB,OAAO,CAAA,CAChC,CAAC,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CACF,CCjGA,IAAIY,CAAAA,CACEC,CAAAA,CAAW,IACdD,CAAAA,GAAad,CAAAA,CAA0B,CACtC,KAAA,CAAAgB,CAAAA,CACA,MAAA,CAAAC,CAAAA,CACA,UAAAC,GAAAA,CACA,aAAA,CAAAC,GAAAA,CACA,eAAA,CAAAC,CACF,CAAC,CAAA,CAGI,SAASC,CAAAA,CACdjB,EACAC,CAAAA,CACM,CACNU,GAAS,CAAE,mBAAA,CAAoBX,EAAMC,CAAO,EAC9C,CAGO,SAASiB,EAA8ClB,CAAAA,CAAgC,CAC5F,OAAOW,CAAAA,GAAW,kBAAA,CAAmBX,CAAI,CAC3C,CAGO,SAASmB,CAAAA,EAAoC,CAClD,OAAOR,CAAAA,EAAS,CAAE,yBACpB","file":"chunk-HXEJP6KF.mjs","sourcesContent":["import { WorkflowError, assertId, fail } from \"../core/errors.ts\";\nimport type { Methodology } from \"../core/types.ts\";\n\n/** A methodology factory, as the built-in entries export them (`scrum`, `kanban`, ...). */\nexport type MethodologyFactory<N extends string = string> = () => Methodology<unknown, N>;\n\n/** Name -> factory lookup: what `exwf init <name>` and a state's `methodology` resolve through. */\nexport interface MethodologyRegistry {\n /**\n * Adds `name`; a name already registered (a built-in included) fails `invalid-input`. The\n * factory is called once to check that it returns a Methodology named `name`.\n */\n registerMethodology<C, N extends string>(name: N, factory: () => Methodology<C, N>): void;\n /** The factory registered under `name`; an unknown name fails `invalid-input` listing the known ones. */\n methodologyFactory<N extends string = string>(name: N): MethodologyFactory<N>;\n /** Registered names, pre-registered ones first, then in registration order. */\n registeredMethodologies(): string[];\n}\n\n// the required members of a Methodology (src/core/types.ts) and their runtime kinds\nconst MEMBERS = [\n [\"vocabulary\", \"object\"],\n [\"validateConfig\", \"function\"],\n [\"defaultStages\", \"function\"],\n [\"defaultRoles\", \"function\"],\n [\"requiredCapabilities\", \"array\"],\n [\"exclusiveCapabilities\", \"array\"],\n [\"plannerOptions\", \"function\"],\n [\"candidates\", \"function\"],\n [\"invariants\", \"function\"],\n [\"ceremonies\", \"object\"],\n [\"rules\", \"array\"],\n [\"metrics\", \"function\"],\n [\"humanDefaults\", \"object\"],\n] as const;\n\n/**\n * A registry pre-registered with `initial`. The interface layer cannot import the methodologies,\n * so the outer ring passes the five built-ins in (design spec section 26, \"Registry placement\").\n */\n// String() throws on a null-prototype value; for an Error it reads `Name: message`\nconst thrown = (e: unknown): string => {\n try {\n return String(e);\n } catch {\n return \"a non-Error value\";\n }\n};\n\nexport function createMethodologyRegistry(\n // factories of different names share no sound common type (a ceremony is contravariant in\n // its state's name), so the table stores them untyped and lookup restores the name\n initial: Record<string, () => unknown>,\n): MethodologyRegistry {\n const table = new Map<string, () => unknown>();\n const register = (name: string, factory: unknown, builtIn = false) => {\n assertId(name, \"methodology name\");\n if (typeof factory !== \"function\")\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory must be a function`,\n 'pass the factory itself, e.g. registerMethodology(\"triage\", triage)',\n );\n if (table.has(name))\n fail(\n \"invalid-input\",\n `methodology \"${name}\" is already registered`,\n `pick a name that is not one of: ${[...table.keys()].join(\", \")}`,\n );\n // a custom factory runs once here, so a wrong result fails at registration, not at init\n if (!builtIn) {\n let m: Record<string, unknown> | null;\n try {\n m = (factory as () => unknown)() as Record<string, unknown> | null;\n } catch (e) {\n if (e instanceof WorkflowError) throw e;\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory threw: ${thrown(e)}`,\n \"fix the factory: registration calls it once\",\n );\n }\n const missing =\n typeof m !== \"object\" || m === null\n ? \"an object\"\n : m[\"name\"] !== name\n ? `name \"${name}\"`\n : MEMBERS.find(([key, kind]) =>\n kind === \"array\" ? !Array.isArray(m[key]) : typeof m[key] !== kind || !m[key],\n )?.[0];\n if (missing)\n fail(\n \"invalid-input\",\n `methodology \"${name}\" factory must return a Methodology; it lacks ${missing}`,\n \"return the full Methodology object (name, vocabulary, validateConfig, defaultStages, defaultRoles, capabilities, plannerOptions, candidates, invariants, ceremonies, rules, metrics, humanDefaults)\",\n );\n }\n table.set(name, factory as () => unknown);\n };\n for (const [name, factory] of Object.entries(initial)) register(name, factory, true);\n return {\n registerMethodology: (name, factory) => register(name, factory),\n methodologyFactory<N extends string>(name: N): MethodologyFactory<N> {\n assertId(name, \"methodology name\");\n const factory = table.get(name);\n if (!factory)\n fail(\n \"invalid-input\",\n `unknown methodology \"${name}\"`,\n `known methodologies: ${[...table.keys()].join(\", \") || \"(none)\"}; register a custom one with registerMethodology`,\n );\n return factory as MethodologyFactory<N>;\n },\n registeredMethodologies: () => [...table.keys()],\n };\n}\n","// The `ex-workflow/registry` entry: the methodology registry with the five built-ins\n// pre-registered (design spec section 26, \"Registry placement\"). Outer ring: src/interface/ may\n// not import src/methodologies/, so the built-in table lives here; the CLI resolves through it. The registry is created on first use, so a bundle that never\n// calls these functions does not keep the built-in factories.\nimport { experimentation } from \"./methodologies/experimentation/index.ts\";\nimport { investigation } from \"./methodologies/investigation/index.ts\";\nimport { kanban } from \"./methodologies/kanban/index.ts\";\nimport { scrum } from \"./methodologies/scrum/index.ts\";\nimport { waterfall } from \"./methodologies/waterfall/index.ts\";\nimport {\n createMethodologyRegistry,\n type MethodologyFactory,\n type MethodologyRegistry,\n} from \"./interface/registry.ts\";\nimport type { Methodology } from \"./core/types.ts\";\n\nexport type { MethodologyFactory, MethodologyRegistry };\n\nlet registry: MethodologyRegistry | undefined;\nconst builtins = (): MethodologyRegistry =>\n (registry ??= createMethodologyRegistry({\n scrum,\n kanban,\n waterfall,\n investigation,\n experimentation,\n }));\n\n/** Registers a custom methodology (SDK only in 1.2); a taken name, a built-in included, fails `invalid-input`. */\nexport function registerMethodology<C, N extends string>(\n name: N,\n factory: () => Methodology<C, N>,\n): void {\n builtins().registerMethodology(name, factory);\n}\n\n/** The factory registered under `name`; an unknown name fails `invalid-input` listing the known ones. */\nexport function methodologyFactory<N extends string = string>(name: N): MethodologyFactory<N> {\n return builtins().methodologyFactory(name);\n}\n\n/** The registered names: the five built-ins, then custom ones in registration order. */\nexport function registeredMethodologies(): string[] {\n return builtins().registeredMethodologies();\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import {a as a$3}from'./chunk-BD665RYK.mjs';import {a}from'./chunk-WU5JELOM.mjs';import {a as a$1,b as b$2}from'./chunk-TQR3VFZU.mjs';import {M,a as a$2,v as v$1,V as V$1,t,c,e}from'./chunk-NNQ3RHDP.mjs';import {b as b$1}from'./chunk-YS6CXERQ.mjs';var m=e=>a$1(e,"investigation"),_=(e,i)=>b$2(e,"investigation",i);function v(e,i){return [...new Set([...e.events.filter(d=>d.type==="item.completed"&&d.payload.id===i).map(d=>d.by),...(e.items[i]?.transitions??[]).filter(d=>d.to.status==="in_progress").map(d=>d.by)])]}function N(e,i){let d;for(let p=e.events.length-1;p>=0;p--){let s=e.events[p];if(s.type==="item.completed"&&s.payload.id===i){d=s.payload;break}}return d&&["done","needs-review"].includes(d.verdict)?d.produced.filter(p=>p.kind==="experiment-output").map(p=>p.ref):[]}function I(e){return b$1("invalid-input",`the investigation state is inconsistent: ${e}`,"restore .workflow/state.json from git, or start a new investigation")}function O(e){return e.rounds.at(-1)??I(`phase ${e.phase} has no round`)}function S(e){return e.iterations.find(i=>i.id==="investigation")??I('there is no "investigation" iteration')}function R(e){let i=e;return (!i||typeof i!="object"||Array.isArray(i)||typeof i.question!="string"||!i.question.trim()||!Number.isSafeInteger(i.maxRounds)||i.maxRounds<1||!i.budget||typeof i.budget!="object"||Array.isArray(i.budget)||!Object.keys(i.budget).length||Object.entries(i.budget).some(([d,p])=>!["tokens","turns","wallclockMs"].includes(d)||typeof p!="number"||!Number.isFinite(p)||p<=0))&&b$1("config-invalid","investigation requires question, positive maxRounds and a finite positive budget","provide bounded investigation config"),{question:i.question,maxRounds:i.maxRounds,budget:{...i.budget}}}function H(e,i,d,p){let s=m(e);return b$1("invalid-input",`${i} (phase ${s?.phase??"intake"}): ${d}`,p,{items:s?[s.item,...s.rounds.at(-1)?[s.rounds.at(-1).item]:[]]:[]})}var F=(e,i)=>!!e&&!!i&&!a$3(e,i,["id","claim","falsifiedBy"]).length,y=e=>typeof e=="string"&&e.trim().length>0,B=e=>Array.isArray(e)&&e.length>0&&e.every(y)&&new Set(e).size===e.length,D=(e,i)=>e&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e).find(d=>!i.includes(d)):void 0,E=(e,i)=>Array.isArray(e)?e.map(d=>D(d,i)).find(Boolean):void 0;function Q(e$1,i,d){e(e$1,i)?.capabilities.includes(d)||b$1("missing-capability",`${i} needs ${d}`,"use a registered role with the required capability");}function b(e,i,d,p){return c(_(e,i),`investigation.${p}`,d.by,{...i},a$2(d.now))}function C(e,i,d,p,s){let n=a$2(d.now),t=b(e,{...i,phase:"closed",outcome:p,...s?{stopReason:s}:{}},d,p);t={...t,iterations:t.iterations.map(a=>a.id==="investigation"?{...a,endedAt:n,outcome:p==="stopped"?"cancelled":"completed"}:a)};for(let a of Object.values(t.items).filter(r=>r.id===i.item||i.rounds.some(u=>u.item===r.id)))a.status!=="done"&&a.status!=="dropped"&&(t=v$1(t,a.id,{status:p==="resolved"&&a.id===i.item?"done":"dropped"},d.by,n));return t}function U(e){let i,d=()=>i??=e(),p=(s,n,t,a)=>(r,u)=>{Q(r,u.by,n);let o=m(r);return (!o||o.phase==="closed")&&H(r,s,"no active investigation","start a new investigation with intake {item}"),t&&o.phase!==t&&!(s==="hypotheses"&&o.phase==="preregister")&&H(r,s,`expected ${t}, got ${o.phase}`,`finish phase ${o.phase} before calling ${s}; ${s} requires phase ${t}`),V$1(r,d(),{type:`ceremony.${s}`,by:u.by,payload:u},()=>a(r,o,u,(l,g)=>H(r,s,l,g)))};return {intake(s,n){Q(s,n.by,"facilitate");let t$1=(r,u)=>H(s,"intake",r,u);s.methodology!=="investigation"&&t$1(`workflow methodology is ${s.methodology}, not investigation`,"init a workflow with the investigation methodology before intake"),m(s)&&t$1("investigation already started","use the existing investigation or initialize a new workflow"),y(n.item)||t$1("item is required","set intake.item to a unique investigation item ID");let a=R(s.config);return V$1(s,d(),{type:"ceremony.intake",by:n.by,payload:n},()=>{let r=t(s,{id:n.item,title:a.question,acceptance:["Independent evidence-based conclusion"],stage:"intake"},n.by,n.now);return r={...r,iterations:[...r.iterations,{id:"investigation",goal:a.question,budget:{...a.budget},spent:{tokens:0,turns:0,wallclockMs:0},startedAt:a$2(n.now),committed:[],carryover:[]}]},b(r,{item:n.item,phase:"hypotheses",hypotheses:[],rounds:[],contributors:[n.by]},n,"intake")})},hypotheses:p("hypotheses","define-acceptance","hypotheses",(s,n,t,a)=>{let r=t.hypotheses,u=E(r,["id","claim","falsifiedBy"]);return u&&a(`unknown key "${u}" in a hypotheses entry`,"use only id, claim and falsifiedBy in each hypotheses entry"),(!Array.isArray(r)||!r.length||r.some(o=>!o||!y(o.id)||!y(o.claim)||!y(o.falsifiedBy))||new Set(r.map(o=>o.id)).size!==r.length||r.length<2&&!y(t.singleHypothesisRationale))&&a("provide competing falsifiable hypotheses or single-testable rationale","set hypotheses to unique {id, claim, falsifiedBy} entries; supply singleHypothesisRationale when there is only one"),b(s,{...n,hypotheses:r.map(o=>({id:o.id,claim:o.claim,falsifiedBy:o.falsifiedBy})),...y(t.singleHypothesisRationale)?{singleHypothesisRationale:t.singleHypothesisRationale}:{},contributors:[...new Set([...n.contributors,t.by])],phase:"preregister"},t,"hypotheses")}),preregister:p("preregister","define-acceptance","preregister",(s,n,t$1,a)=>{let r=R(s.config),u=s.iterations.find(c=>c.id==="investigation");(n.rounds.length>=r.maxRounds||!u||M(r.budget,u.spent))&&a(`round limit or budget exhausted (${n.rounds.length} of ${r.maxRounds} rounds used)`,"call stop {reason} to close this investigation, or start a new one with a larger maxRounds or budget");let o=t$1.experiment,l=D(o,["id","procedureRef","predictions","replayOf"])??E(o?.predictions,["hypothesis","prediction"]);if(l&&a(`unknown key "${l}" in experiment`,"use only id, procedureRef, predictions [{hypothesis, prediction}] and replayOf in experiment"),(!o||!y(o.id)||!y(o.procedureRef)||n.rounds.some(c=>c.experiment.id===o.id)||!Array.isArray(o.predictions)||o.predictions.length!==n.hypotheses.length||n.hypotheses.some(c=>o.predictions.filter(f=>f?.hypothesis===c.id&&y(f.prediction)).length!==1)||new Set(o.predictions.map(c=>c.prediction)).size!==o.predictions.length)&&a("preregister unique experiment with differing predictions for every hypothesis","set experiment.id to a new ID, experiment.procedureRef, and one distinct experiment.predictions entry per hypothesis"),o.replayOf){let c=n.rounds.find(f=>f.experiment.id===o.replayOf&&f.result?.valid);(!c||a$3(c.experiment,o,["procedureRef"]).length||c.hypotheses.length!==n.hypotheses.length||n.hypotheses.some(f=>!F(f,c.hypotheses.find(q=>q.id===f.id)))||o.predictions.some(f=>!c.experiment.predictions.some(q=>!a$3(q,f,["hypothesis","prediction"]).length)))&&a("replay must repeat the procedure, predictions and hypotheses of a prior valid experiment","set experiment.replayOf to a valid prior experiment with identical procedureRef, predictions and hypothesis definitions");}let g=`${n.item}-run-${n.rounds.length+1}`,w=t(s,{id:g,title:`Experiment ${o.id}`,stage:"execute",acceptance:[o.procedureRef],iteration:"investigation"},t$1.by,t$1.now);return w={...w,iterations:w.iterations.map(c=>c.id==="investigation"?{...c,committed:[...c.committed,g]}:c)},b(w,{...n,phase:"observe",rounds:[...n.rounds,{experiment:{id:o.id,procedureRef:o.procedureRef,predictions:o.predictions.map(c=>({hypothesis:c.hypothesis,prediction:c.prediction})),...o.replayOf?{replayOf:o.replayOf}:{}},hypotheses:n.hypotheses.map(c=>({...c})),item:g,by:t$1.by}],contributors:[...new Set([...n.contributors,t$1.by])]},t$1,"preregister")}),observe:p("observe","verify","observe",(s,n,t,a)=>{let r=O(n),u=t.result,o=D(u,["id","valid","summary","provenanceRefs"]);return o&&a(`unknown key "${o}" in result`,"use only id, valid, summary and provenanceRefs in result"),(t.experiment!==r.experiment.id||!u||!y(u.id)||typeof u.valid!="boolean"||!y(u.summary)||!B(u.provenanceRefs)||n.rounds.some(l=>l.result?.id===u.id))&&a("observation needs current experiment, unique result and provenance","set experiment to the active experiment ID and result to {id, valid, summary, provenanceRefs} with a new result.id"),s.items[r.item]?.status!=="done"&&a("complete experiment execution before recording observations","dispatch and complete the active experiment item before calling observe"),N(s,r.item).some(l=>u.provenanceRefs.includes(l))||a("observation must link fresh experiment-output evidence from the latest completion",`include an experiment-output ref produced by the latest successful completion of item "${r.item}" in result.provenanceRefs`),b(s,{...n,phase:"update-belief",rounds:n.rounds.map(l=>l===r?{...l,result:{id:u.id,valid:u.valid,summary:u.summary,provenanceRefs:[...u.provenanceRefs]}}:l),contributors:[...new Set([...n.contributors,t.by,...v(s,r.item)])]},t,"observe")}),"update-belief":p("update-belief","define-acceptance","update-belief",(s,n,t,a)=>{let r=O(n),u=t.assessments,o=E(u,["hypothesis","assessment","reason"]);o&&a(`unknown key "${o}" in an assessments entry`,"use only hypothesis, assessment and reason in each assessments entry"),(t.result!==r.result?.id||!Array.isArray(u)||u.length!==n.hypotheses.length||n.hypotheses.some(c=>u.filter(f=>f?.hypothesis===c.id&&["supported","refuted","uncertain"].includes(f.assessment)&&y(f.reason)).length!==1)||!["round","conclusion"].includes(t.next))&&a("belief update must assess every hypothesis against current result","set result to the latest result ID, assessments to one {hypothesis, assessment, reason} per hypothesis, and next to round or conclusion"),!(r.result??I(`round ${r.experiment.id} has no result`)).valid&&u.some(c=>c.assessment!=="uncertain")&&a("invalid experiments cannot support beliefs","set every assessment to uncertain for an invalid experiment result");let g=b(s,{...n,phase:t.next==="round"?"preregister":"conclusion",rounds:n.rounds.map(c=>c===r?{...c,update:{result:t.result,assessments:u.map(f=>({hypothesis:f.hypothesis,assessment:f.assessment,reason:f.reason}))}}:c),contributors:[...new Set([...n.contributors,t.by])]},t,"belief-updated"),w=S(g);return t.next==="round"&&(n.rounds.length>=R(s.config).maxRounds||M(w.budget,w.spent))&&(g=C(g,m(g),t,"stopped","budget or round limit exhausted")),g}),conclude:p("conclude","define-acceptance","conclusion",(s,n,t,a)=>{let r=t;return (!["resolved","inconclusive"].includes(r.outcome)||!y(r.summary)||!B(r.evidenceRefs)||r.evidenceRefs.some(u=>!n.rounds.some(o=>o.result?.provenanceRefs.includes(u))))&&a("conclusion needs observed evidence references","set outcome, summary and evidenceRefs to references preserved in recorded observations"),r.outcome==="resolved"&&(!y(r.supportedHypothesis)||!n.rounds.slice(-1).some(u=>u.result?.valid&&u.update?.assessments.some(o=>o.hypothesis===r.supportedHypothesis&&o.assessment==="supported")))&&a("resolved conclusion needs a supported hypothesis","set supportedHypothesis to a hypothesis supported by the latest valid round, or choose outcome inconclusive"),b(s,{...n,phase:"review",conclusion:{outcome:r.outcome,summary:r.summary,evidenceRefs:[...r.evidenceRefs],...r.supportedHypothesis?{supportedHypothesis:r.supportedHypothesis}:{},by:t.by},contributors:[...new Set([...n.contributors,t.by])]},t,"conclusion")}),"review-conclusion":p("review-conclusion","review","review",(s,n,t,a$1)=>{let r=n.conclusion??I("phase review has no conclusion");if(a(t.by,n.contributors).length&&a$1("conclusion reviewer must be independent of investigation contributors","use a review-capable role that did not contribute to or execute this investigation"),(typeof t.approve!="boolean"||!y(t.reason))&&a$1("review needs approval and reason","set approve to a boolean and reason to a nonempty review explanation"),!t.approve){let o=t.next??"conclusion";o!=="round"&&o!=="conclusion"&&a$1("review rejection next must be round or conclusion","set next to round for more evidence or conclusion for a revised conclusion");let l=b(s,{...n,phase:o==="round"?"preregister":"conclusion",reviewHistory:[...n.reviewHistory??[],{by:t.by,reason:t.reason,approve:false,next:o,replayRefs:[]}]},t,"review-rejected"),g=S(s);return o==="round"&&(n.rounds.length>=R(s.config).maxRounds||M(g.budget,g.spent))?C(l,m(l),t,"stopped","budget or round limit exhausted after review requested another round"):l}let u=Array.isArray(t.replayRefs)?t.replayRefs:[];return r.outcome==="resolved"&&(!B(u)||!n.rounds.some(o=>o.experiment.replayOf&&!a(v(s,o.item),v(s,(n.rounds.find(l=>l.experiment.id===o.experiment.replayOf)??I(`round ${o.experiment.id} replays the unknown experiment ${o.experiment.replayOf}`)).item)).length&&F(o.hypotheses.find(l=>l.id===r.supportedHypothesis),O(n).hypotheses.find(l=>l.id===r.supportedHypothesis))&&o.result?.valid&&u.includes(o.result.id)&&o.update?.assessments.some(l=>l.hypothesis===r.supportedHypothesis&&l.assessment==="supported")))&&a$1("resolved conclusion requires valid replay result and supporting belief update","set replayRefs to a valid independent replay result supporting the latest supported hypothesis definition, or reject with next round"),C(s,{...n,review:{by:t.by,reason:t.reason,replayRefs:u},reviewHistory:[...n.reviewHistory??[],{by:t.by,reason:t.reason,approve:true,replayRefs:u}]},t,r.outcome)}),stop:p("stop","facilitate",void 0,(s,n,t,a)=>(y(t.reason)||a("stop needs reason","set reason to a nonempty explanation for stopping this investigation"),C(s,n,t,"stopped",t.reason)))}}function V(){return [{id:"independent-replay",severity:"error",check(e,i){if(i.type!=="item.complete")return [];let d=m(e)?.rounds.find(s=>s.item===i.payload?.item),p=m(e)?.rounds.find(s=>s.experiment.id===d?.experiment.replayOf);return p&&a(i.by,v(e,p.item)).length?[{rule:"independent-replay",item:d.item,severity:"error",message:"Replay executor also executed the original experiment",fix:"assign a different deliver-capable role"}]:[]}},{id:"investigation-execution-only",severity:"error",check(e,i){if(i.type!=="item.complete")return [];let d=i.payload,p=m(e);return p?.phase==="observe"&&p.rounds.at(-1)?.item===d.item?[]:[{rule:"investigation-execution-only",item:d.item,severity:"error",message:"Only the active preregistered experiment can complete",fix:`complete only the active experiment item in phase observe; current phase is ${p?.phase??"intake"}`}]}}]}function G(){return [{id:"replay-worker",name:"Independent replay worker",modelTier:"small",capabilities:["deliver","verify"],canApprove:[],inputs:["preregistered-experiment"],outputs:["experiment-output"],do_not:["Do not change the replay procedure"]},{id:"investigator",name:"Investigator",modelTier:"large",capabilities:["facilitate","define-acceptance","deliver","verify"],canApprove:[],inputs:["question","prior-results"],outputs:["hypotheses","preregistered-experiment","belief-update"],do_not:["Do not revise predictions after execution","Do not approve your own conclusions"]},{id:"conclusion-reviewer",name:"Independent conclusion reviewer",modelTier:"large",capabilities:["review"],canApprove:["investigation-conclusion"],inputs:["evidence","replay","conclusion"],outputs:["conclusion-review"],do_not:["Do not approve unsupported conclusions"]}]}function J(){return [{id:"intake",name:"Intake",entryPolicy:[],exitPolicy:[{kind:"acceptance-written"}]},{id:"execute",name:"Execute preregistered experiment",entryPolicy:[{kind:"acceptance-written"},{kind:"no-open-blockers"}],exitPolicy:[{kind:"evidence",evidenceKind:"experiment-output"}]},{id:"observed",name:"Execution recorded",entryPolicy:[],exitPolicy:[]}]}function L(){return {name:"investigation",validateConfig:R,lockedConfigKeys:["question","maxRounds","budget"],vocabulary:{backlog:"Questions",item:"Investigation artifact",stage:"Investigation phase",iteration:"Investigation budget",increment:"Conclusion",ceremony:"Investigation ceremony",gate:"Independent conclusion review"},defaultStages:J,defaultRoles:G,requiredCapabilities:["facilitate","define-acceptance","deliver","verify","review"],exclusiveCapabilities:[],humanDefaults:{gates:"none"},ceremonies:U(L),plannerOptions:e=>({schedulerMode:"level",concurrencyCap:1,roleFor:i=>{let d=m(e)?.rounds.find(a=>a.item===i.id),p=m(e)?.rounds.find(a=>a.experiment.id===d?.experiment.replayOf),s=p?v(e,p.item):[],n=Object.values(e.roles),t=(p?void 0:n.find(a=>a.capabilities.includes("deliver")&&a.capabilities.includes("define-acceptance")))??n.find(a$1=>a$1.capabilities.includes("deliver")&&!a(a$1.id,s).length);return t||b$1("missing-capability",`No eligible executor for experiment item "${i.id}"`,p?`register an independent deliver-capable role that did not execute "${p.item}"`:"register a role with deliver capability",{items:[i.id]}),t.id},estimateMode:"per-call",fallbackTokensPerWeight:1}),candidates:e=>{let i=m(e),d=i?.rounds.at(-1)?.item;return i?.phase==="observe"&&!M(e.config.budget,S(e).spent)?Object.values(e.items).filter(p=>p.id===d&&p.stage==="execute"&&p.status==="todo"):[]},afterComplete:(e,i,d)=>{let p=m(e),s=e.iterations.find(n=>n.id==="investigation");return p?.phase!=="observe"||p.rounds.at(-1)?.item!==i||e.items[i]?.status==="done"||!s||!M(s.budget,s.spent)?e:C(e,p,{by:"investigation",now:d},"stopped",`budget exhausted before experiment item "${i}" completed; start a new investigation with sufficient budget`)},invariants:e=>[`Question: ${e.config.question}`,"Execute only the preregistered procedure; retain raw observation provenance; report invalid runs."],rules:V(),metrics:e=>({rounds:m(e)?.rounds.length??0,validRuns:m(e)?.rounds.filter(i=>i.result?.valid).length??0,invalidRuns:m(e)?.rounds.filter(i=>i.result&&!i.result.valid).length??0}),report:e=>({phase:m(e)?.phase??"intake",outcome:m(e)?.outcome??null,rounds:m(e)?.rounds.length??0,conclusion:m(e)?.conclusion??null,stopReason:m(e)?.stopReason??null})}}export{R as a,L as b};//# sourceMappingURL=chunk-ILNSTPPV.mjs.map
2
+ //# sourceMappingURL=chunk-ILNSTPPV.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/methodologies/investigation/record.ts","../src/methodologies/investigation/execution.ts","../src/methodologies/investigation/invariants.ts","../src/methodologies/investigation/config.ts","../src/methodologies/investigation/ceremonies.ts","../src/methodologies/investigation/rules.ts","../src/methodologies/investigation/roles.ts","../src/methodologies/investigation/stages.ts","../src/methodologies/investigation/index.ts"],"names":["readInvestigation","s","readExt","writeInvestigation","x","writeExt","executionActors","state","item","event","transition","freshOutputRefs","completion","index","output","brokenInvestigation","what","fail","lastRound","investigationIteration","it","validateInvestigationConfig","raw","c","k","v","reject","name","message","fix","sameHypothesis","a","b","frozenChanges","text","refs","extraKey","keys","extraKeyIn","list","authorize","by","cap","roleOf","save","i","appendEvent","nowOf","closeInvestigation","outcome","reason","at","n","candidate","r","moveItem","investigationCeremonies","factory","built","methodology","make","phase","fn","applyAction","bad","addItem","h","extra","isExhausted","e","extraExperiment","p","prior","id","iteration","o","ref","entry","conclusion","independenceConflicts","target","replayRefs","investigationRules","round","investigationRoles","investigationStages","investigation","excluded","roles","selected","role","now"],"mappings":"wPAKO,IAAMA,EAAqBC,CAAAA,EAChCC,GAAAA,CAAQD,EAAG,eAAe,CAAA,CAGfE,EAAqB,CAACF,CAAAA,CAAkBG,CAAAA,GACnDC,GAAAA,CAASJ,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/ext.ts\";\nimport type { WorkflowState } from \"../../core/types.ts\";\nimport type { InvestigationState } from \"./state.ts\";\n\n/** The investigation record: `ext.investigation`, or the legacy field of a state written before 1.2. */\nexport const readInvestigation = (s: WorkflowState): InvestigationState | undefined =>\n readExt(s, \"investigation\");\n\n/** Stores the investigation record in `ext.investigation` and its deprecated legacy mirror (spec 26). */\nexport const writeInvestigation = (s: WorkflowState, x: InvestigationState): WorkflowState =>\n writeExt(s, \"investigation\", x);\n","import type { Handoff, Verdict, WorkflowState } from \"../../core/types.ts\";\n\ninterface Completion {\n id: string;\n verdict: Verdict;\n produced: Handoff[\"produced\"];\n}\n\n/** Completion actors come from validated handoffs, never caller-supplied accounting identity. */\nexport function executionActors(state: WorkflowState, item: string): string[] {\n return [\n ...new Set([\n ...state.events\n .filter(\n (event) => event.type === \"item.completed\" && (event.payload as Completion).id === item,\n )\n .map((event) => event.by),\n ...(state.items[item]?.transitions ?? [])\n .filter((transition) => transition.to.status === \"in_progress\")\n .map((transition) => transition.by),\n ]),\n ];\n}\n\n/** Only outputs of the latest successful completion can establish observation provenance. */\nexport function freshOutputRefs(state: WorkflowState, item: string): string[] {\n let completion: Completion | undefined;\n for (let index = state.events.length - 1; index >= 0; index--) {\n const event = state.events[index]!;\n if (event.type === \"item.completed\" && (event.payload as Completion).id === item) {\n completion = event.payload as Completion;\n break;\n }\n }\n return completion && [\"done\", \"needs-review\"].includes(completion.verdict)\n ? completion.produced\n .filter((output) => output.kind === \"experiment-output\")\n .map((output) => output.ref)\n : [];\n}\n","import { fail } from \"../../core/errors.ts\";\nimport type { Iteration, WorkflowState } from \"../../core/types.ts\";\nimport type { InvestigationState } from \"./state.ts\";\n\n/** A loaded state that breaks an invariant the ceremonies keep (a hand-edited or damaged file). */\nexport function brokenInvestigation(what: string): never {\n return fail(\n \"invalid-input\",\n `the investigation state is inconsistent: ${what}`,\n \"restore .workflow/state.json from git, or start a new investigation\",\n );\n}\n\n/** The latest round; the phases after preregister always have one. */\nexport function lastRound(x: InvestigationState): InvestigationState[\"rounds\"][number] {\n return x.rounds.at(-1) ?? brokenInvestigation(`phase ${x.phase} has no round`);\n}\n\n/** The `investigation` iteration intake opens; its budget bounds every round. */\nexport function investigationIteration(s: WorkflowState<string>): Iteration {\n return (\n s.iterations.find((it) => it.id === \"investigation\") ??\n brokenInvestigation('there is no \"investigation\" iteration')\n );\n}\n","import { fail } from \"../../core/errors.ts\";\nimport type { Budget } from \"../../core/types.ts\";\nexport interface InvestigationConfig {\n question: string;\n maxRounds: number;\n budget: Budget;\n}\nexport function validateInvestigationConfig(raw: unknown): InvestigationConfig {\n const c = raw as InvestigationConfig;\n if (\n !c ||\n typeof c !== \"object\" ||\n Array.isArray(c) ||\n typeof c.question !== \"string\" ||\n !c.question.trim() ||\n !Number.isSafeInteger(c.maxRounds) ||\n c.maxRounds < 1 ||\n !c.budget ||\n typeof c.budget !== \"object\" ||\n Array.isArray(c.budget) ||\n !Object.keys(c.budget).length ||\n Object.entries(c.budget).some(\n ([k, v]) =>\n ![\"tokens\", \"turns\", \"wallclockMs\"].includes(k) ||\n typeof v !== \"number\" ||\n !Number.isFinite(v) ||\n v <= 0,\n )\n )\n fail(\n \"config-invalid\",\n \"investigation requires question, positive maxRounds and a finite positive budget\",\n \"provide bounded investigation config\",\n );\n return { question: c.question, maxRounds: c.maxRounds, budget: { ...c.budget } };\n}\n","import { readInvestigation, writeInvestigation } from \"./record.ts\";\nimport { executionActors, freshOutputRefs } from \"./execution.ts\";\nimport { independenceConflicts } from \"../../common/independence.ts\";\nimport { frozenChanges } from \"../../common/frozen.ts\";\nimport { fail } from \"../../core/errors.ts\";\nimport { brokenInvestigation, investigationIteration, lastRound } from \"./invariants.ts\";\nimport { roleOf } from \"../../core/roles/lookup.ts\";\nimport { addItem } from \"../../core/items/record.ts\";\nimport { moveItem } from \"../../core/items/move.ts\";\nimport { applyAction } from \"../../core/methodology.ts\";\nimport { appendEvent, nowOf } from \"../../core/state.ts\";\nimport { isExhausted } from \"../../core/budget.ts\";\nimport type {\n Capability,\n Ceremony,\n CeremonyInput,\n Methodology,\n WorkflowState,\n} from \"../../core/types.ts\";\nimport { validateInvestigationConfig, type InvestigationConfig } from \"./config.ts\";\nimport type {\n BeliefUpdate,\n Experiment,\n Hypothesis,\n InvestigationConclusion,\n InvestigationState,\n Observation,\n} from \"./state.ts\";\nfunction reject(s: WorkflowState, name: string, message: string, fix: string): never {\n const x = readInvestigation(s);\n return fail(\"invalid-input\", `${name} (phase ${x?.phase ?? \"intake\"}): ${message}`, fix, {\n items: x ? [x.item, ...(x.rounds.at(-1) ? [x.rounds.at(-1)!.item] : [])] : [],\n });\n}\nconst sameHypothesis = (a: Hypothesis | undefined, b: Hypothesis | undefined) =>\n !!a && !!b && !frozenChanges(a, b, [\"id\", \"claim\", \"falsifiedBy\"]).length;\nconst text = (v: unknown): v is string => typeof v === \"string\" && v.trim().length > 0;\nconst refs = (v: unknown): v is string[] =>\n Array.isArray(v) && v.length > 0 && v.every(text) && new Set(v).size === v.length;\n/** First key of a caller record outside its contract; stored records are closed objects (state schema). */\nconst extraKey = (v: unknown, keys: readonly string[]): string | undefined =>\n v && typeof v === \"object\" && !Array.isArray(v)\n ? Object.keys(v).find((k) => !keys.includes(k))\n : undefined;\nconst extraKeyIn = (list: unknown, keys: readonly string[]): string | undefined =>\n Array.isArray(list) ? list.map((v) => extraKey(v, keys)).find(Boolean) : undefined;\nfunction authorize(s: WorkflowState, by: string, cap: Capability) {\n if (!roleOf(s, by)?.capabilities.includes(cap))\n fail(\n \"missing-capability\",\n `${by} needs ${cap}`,\n \"use a registered role with the required capability\",\n );\n}\nfunction save(s: WorkflowState, x: InvestigationState, i: CeremonyInput, name: string) {\n return appendEvent(\n writeInvestigation(s, x),\n `investigation.${name}`,\n i.by,\n { ...x },\n nowOf(i.now),\n );\n}\nexport function closeInvestigation(\n s: WorkflowState,\n x: InvestigationState,\n i: CeremonyInput,\n outcome: \"stopped\" | \"resolved\" | \"inconclusive\",\n reason?: string,\n) {\n const at = nowOf(i.now);\n let n = save(\n s,\n { ...x, phase: \"closed\", outcome, ...(reason ? { stopReason: reason } : {}) },\n i,\n outcome,\n );\n n = {\n ...n,\n iterations: n.iterations.map((it) =>\n it.id === \"investigation\"\n ? { ...it, endedAt: at, outcome: outcome === \"stopped\" ? \"cancelled\" : \"completed\" }\n : it,\n ),\n };\n for (const item of Object.values(n.items).filter(\n (candidate) => candidate.id === x.item || x.rounds.some((r) => r.item === candidate.id),\n ))\n if (item.status !== \"done\" && item.status !== \"dropped\")\n n = moveItem(\n n,\n item.id,\n { status: outcome === \"resolved\" && item.id === x.item ? \"done\" : \"dropped\" },\n i.by,\n at,\n );\n return n;\n}\nexport function investigationCeremonies(\n factory: () => Methodology<InvestigationConfig>,\n): Record<string, Ceremony> {\n let built: Methodology<InvestigationConfig> | undefined;\n const methodology = () => (built ??= factory());\n const make =\n (\n name: string,\n cap: Capability,\n phase: string | undefined,\n fn: (\n s: WorkflowState,\n x: InvestigationState,\n i: CeremonyInput,\n bad: (message: string, fix: string) => never,\n ) => WorkflowState,\n ): Ceremony =>\n (s, i) => {\n authorize(s, i.by, cap);\n const x = readInvestigation(s);\n if (!x || x.phase === \"closed\")\n reject(s, name, \"no active investigation\", \"start a new investigation with intake {item}\");\n if (phase && x.phase !== phase && !(name === \"hypotheses\" && x.phase === \"preregister\"))\n reject(\n s,\n name,\n `expected ${phase}, got ${x.phase}`,\n `finish phase ${x.phase} before calling ${name}; ${name} requires phase ${phase}`,\n );\n return applyAction(s, methodology(), { type: `ceremony.${name}`, by: i.by, payload: i }, () =>\n fn(s, x, i, (message, fix) => reject(s, name, message, fix)),\n );\n };\n return {\n intake(s, i) {\n authorize(s, i.by, \"facilitate\");\n const bad = (message: string, fix: string) => reject(s, \"intake\", message, fix);\n if (s.methodology !== \"investigation\")\n bad(\n `workflow methodology is ${s.methodology}, not investigation`,\n \"init a workflow with the investigation methodology before intake\",\n );\n if (readInvestigation(s))\n bad(\n \"investigation already started\",\n \"use the existing investigation or initialize a new workflow\",\n );\n if (!text(i.item))\n bad(\"item is required\", \"set intake.item to a unique investigation item ID\");\n const c = validateInvestigationConfig(s.config);\n return applyAction(\n s,\n methodology(),\n { type: \"ceremony.intake\", by: i.by, payload: i },\n () => {\n let n = addItem(\n s,\n {\n id: i.item as string,\n title: c.question,\n acceptance: [\"Independent evidence-based conclusion\"],\n stage: \"intake\",\n },\n i.by,\n i.now,\n );\n n = {\n ...n,\n iterations: [\n ...n.iterations,\n {\n id: \"investigation\",\n goal: c.question,\n budget: { ...c.budget },\n spent: { tokens: 0, turns: 0, wallclockMs: 0 },\n startedAt: nowOf(i.now),\n committed: [],\n carryover: [],\n },\n ],\n };\n return save(\n n,\n {\n item: i.item as string,\n phase: \"hypotheses\",\n hypotheses: [],\n rounds: [],\n contributors: [i.by],\n },\n i,\n \"intake\",\n );\n },\n );\n },\n hypotheses: make(\"hypotheses\", \"define-acceptance\", \"hypotheses\", (s, x, i, bad) => {\n const h = i.hypotheses as Hypothesis[];\n const extra = extraKeyIn(h, [\"id\", \"claim\", \"falsifiedBy\"]);\n if (extra)\n bad(\n `unknown key \"${extra}\" in a hypotheses entry`,\n \"use only id, claim and falsifiedBy in each hypotheses entry\",\n );\n if (\n !Array.isArray(h) ||\n !h.length ||\n h.some((v) => !v || !text(v.id) || !text(v.claim) || !text(v.falsifiedBy)) ||\n new Set(h.map((v) => v.id)).size !== h.length ||\n (h.length < 2 && !text(i.singleHypothesisRationale))\n )\n bad(\n \"provide competing falsifiable hypotheses or single-testable rationale\",\n \"set hypotheses to unique {id, claim, falsifiedBy} entries; supply singleHypothesisRationale when there is only one\",\n );\n return save(\n s,\n {\n ...x,\n hypotheses: h.map((v) => ({ id: v.id, claim: v.claim, falsifiedBy: v.falsifiedBy })),\n ...(text(i.singleHypothesisRationale)\n ? { singleHypothesisRationale: i.singleHypothesisRationale }\n : {}),\n contributors: [...new Set([...x.contributors, i.by])],\n phase: \"preregister\",\n },\n i,\n \"hypotheses\",\n );\n }),\n preregister: make(\"preregister\", \"define-acceptance\", \"preregister\", (s, x, i, bad) => {\n const c = validateInvestigationConfig(s.config),\n it = s.iterations.find((v) => v.id === \"investigation\");\n if (x.rounds.length >= c.maxRounds || !it || isExhausted(c.budget, it.spent))\n bad(\n `round limit or budget exhausted (${x.rounds.length} of ${c.maxRounds} rounds used)`,\n \"call stop {reason} to close this investigation, or start a new one with a larger maxRounds or budget\",\n );\n const e = i.experiment as Experiment;\n const extraExperiment =\n extraKey(e, [\"id\", \"procedureRef\", \"predictions\", \"replayOf\"]) ??\n extraKeyIn(e?.predictions, [\"hypothesis\", \"prediction\"]);\n if (extraExperiment)\n bad(\n `unknown key \"${extraExperiment}\" in experiment`,\n \"use only id, procedureRef, predictions [{hypothesis, prediction}] and replayOf in experiment\",\n );\n if (\n !e ||\n !text(e.id) ||\n !text(e.procedureRef) ||\n x.rounds.some((r) => r.experiment.id === e.id) ||\n !Array.isArray(e.predictions) ||\n e.predictions.length !== x.hypotheses.length ||\n x.hypotheses.some(\n (h) =>\n e.predictions.filter((p) => p?.hypothesis === h.id && text(p.prediction)).length !== 1,\n ) ||\n new Set(e.predictions.map((p) => p.prediction)).size !== e.predictions.length\n )\n bad(\n \"preregister unique experiment with differing predictions for every hypothesis\",\n \"set experiment.id to a new ID, experiment.procedureRef, and one distinct experiment.predictions entry per hypothesis\",\n );\n if (e.replayOf) {\n const prior = x.rounds.find((r) => r.experiment.id === e.replayOf && r.result?.valid);\n if (\n !prior ||\n frozenChanges(prior.experiment, e, [\"procedureRef\"]).length ||\n prior.hypotheses.length !== x.hypotheses.length ||\n x.hypotheses.some(\n (h) =>\n !sameHypothesis(\n h,\n prior.hypotheses.find((p) => p.id === h.id),\n ),\n ) ||\n e.predictions.some(\n (p) =>\n !prior.experiment.predictions.some(\n (q) => !frozenChanges(q, p, [\"hypothesis\", \"prediction\"]).length,\n ),\n )\n )\n bad(\n \"replay must repeat the procedure, predictions and hypotheses of a prior valid experiment\",\n \"set experiment.replayOf to a valid prior experiment with identical procedureRef, predictions and hypothesis definitions\",\n );\n }\n const id = `${x.item}-run-${x.rounds.length + 1}`;\n let n = addItem(\n s,\n {\n id,\n title: `Experiment ${e.id}`,\n stage: \"execute\",\n acceptance: [e.procedureRef],\n iteration: \"investigation\",\n },\n i.by,\n i.now,\n );\n n = {\n ...n,\n iterations: n.iterations.map((iteration) =>\n iteration.id === \"investigation\"\n ? { ...iteration, committed: [...iteration.committed, id] }\n : iteration,\n ),\n };\n return save(\n n,\n {\n ...x,\n phase: \"observe\",\n rounds: [\n ...x.rounds,\n {\n experiment: {\n id: e.id,\n procedureRef: e.procedureRef,\n predictions: e.predictions.map((p) => ({\n hypothesis: p.hypothesis,\n prediction: p.prediction,\n })),\n ...(e.replayOf ? { replayOf: e.replayOf } : {}),\n },\n hypotheses: x.hypotheses.map((v) => ({ ...v })),\n item: id,\n by: i.by,\n },\n ],\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"preregister\",\n );\n }),\n observe: make(\"observe\", \"verify\", \"observe\", (s, x, i, bad) => {\n const r = lastRound(x),\n o = i.result as Observation;\n const extra = extraKey(o, [\"id\", \"valid\", \"summary\", \"provenanceRefs\"]);\n if (extra)\n bad(\n `unknown key \"${extra}\" in result`,\n \"use only id, valid, summary and provenanceRefs in result\",\n );\n if (\n i.experiment !== r.experiment.id ||\n !o ||\n !text(o.id) ||\n typeof o.valid !== \"boolean\" ||\n !text(o.summary) ||\n !refs(o.provenanceRefs) ||\n x.rounds.some((prior) => prior.result?.id === o.id)\n )\n bad(\n \"observation needs current experiment, unique result and provenance\",\n \"set experiment to the active experiment ID and result to {id, valid, summary, provenanceRefs} with a new result.id\",\n );\n if (s.items[r.item]?.status !== \"done\")\n bad(\n \"complete experiment execution before recording observations\",\n \"dispatch and complete the active experiment item before calling observe\",\n );\n if (!freshOutputRefs(s, r.item).some((ref) => o.provenanceRefs.includes(ref)))\n bad(\n \"observation must link fresh experiment-output evidence from the latest completion\",\n `include an experiment-output ref produced by the latest successful completion of item \"${r.item}\" in result.provenanceRefs`,\n );\n return save(\n s,\n {\n ...x,\n phase: \"update-belief\",\n rounds: x.rounds.map((v) =>\n v === r\n ? {\n ...v,\n result: {\n id: o.id,\n valid: o.valid,\n summary: o.summary,\n provenanceRefs: [...o.provenanceRefs],\n },\n }\n : v,\n ),\n contributors: [...new Set([...x.contributors, i.by, ...executionActors(s, r.item)])],\n },\n i,\n \"observe\",\n );\n }),\n \"update-belief\": make(\"update-belief\", \"define-acceptance\", \"update-belief\", (s, x, i, bad) => {\n const r = lastRound(x),\n a = i.assessments as BeliefUpdate[\"assessments\"];\n const extra = extraKeyIn(a, [\"hypothesis\", \"assessment\", \"reason\"]);\n if (extra)\n bad(\n `unknown key \"${extra}\" in an assessments entry`,\n \"use only hypothesis, assessment and reason in each assessments entry\",\n );\n if (\n i.result !== r.result?.id ||\n !Array.isArray(a) ||\n a.length !== x.hypotheses.length ||\n x.hypotheses.some(\n (h) =>\n a.filter(\n (v) =>\n v?.hypothesis === h.id &&\n [\"supported\", \"refuted\", \"uncertain\"].includes(v.assessment) &&\n text(v.reason),\n ).length !== 1,\n ) ||\n ![\"round\", \"conclusion\"].includes(i.next as string)\n )\n bad(\n \"belief update must assess every hypothesis against current result\",\n \"set result to the latest result ID, assessments to one {hypothesis, assessment, reason} per hypothesis, and next to round or conclusion\",\n );\n const result = r.result ?? brokenInvestigation(`round ${r.experiment.id} has no result`);\n if (!result.valid && a.some((v) => v.assessment !== \"uncertain\"))\n bad(\n \"invalid experiments cannot support beliefs\",\n \"set every assessment to uncertain for an invalid experiment result\",\n );\n let n = save(\n s,\n {\n ...x,\n phase: i.next === \"round\" ? \"preregister\" : \"conclusion\",\n rounds: x.rounds.map((v) =>\n v === r\n ? {\n ...v,\n update: {\n result: i.result as string,\n assessments: a.map((entry) => ({\n hypothesis: entry.hypothesis,\n assessment: entry.assessment,\n reason: entry.reason,\n })),\n },\n }\n : v,\n ),\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"belief-updated\",\n );\n const it = investigationIteration(n);\n if (\n i.next === \"round\" &&\n (x.rounds.length >= validateInvestigationConfig(s.config).maxRounds ||\n isExhausted(it.budget, it.spent))\n )\n n = closeInvestigation(\n n,\n readInvestigation(n)!,\n i,\n \"stopped\",\n \"budget or round limit exhausted\",\n );\n return n;\n }),\n conclude: make(\"conclude\", \"define-acceptance\", \"conclusion\", (s, x, i, bad) => {\n const c = i as unknown as InvestigationConclusion;\n if (\n ![\"resolved\", \"inconclusive\"].includes(c.outcome) ||\n !text(c.summary) ||\n !refs(c.evidenceRefs) ||\n c.evidenceRefs.some((ref) => !x.rounds.some((r) => r.result?.provenanceRefs.includes(ref)))\n )\n bad(\n \"conclusion needs observed evidence references\",\n \"set outcome, summary and evidenceRefs to references preserved in recorded observations\",\n );\n if (\n c.outcome === \"resolved\" &&\n (!text(c.supportedHypothesis) ||\n !x.rounds\n .slice(-1)\n .some(\n (r) =>\n r.result?.valid &&\n r.update?.assessments.some(\n (a) => a.hypothesis === c.supportedHypothesis && a.assessment === \"supported\",\n ),\n ))\n )\n bad(\n \"resolved conclusion needs a supported hypothesis\",\n \"set supportedHypothesis to a hypothesis supported by the latest valid round, or choose outcome inconclusive\",\n );\n return save(\n s,\n {\n ...x,\n phase: \"review\",\n conclusion: {\n outcome: c.outcome,\n summary: c.summary,\n evidenceRefs: [...c.evidenceRefs],\n ...(c.supportedHypothesis ? { supportedHypothesis: c.supportedHypothesis } : {}),\n by: i.by,\n },\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"conclusion\",\n );\n }),\n \"review-conclusion\": make(\"review-conclusion\", \"review\", \"review\", (s, x, i, bad) => {\n const conclusion = x.conclusion ?? brokenInvestigation(\"phase review has no conclusion\");\n if (independenceConflicts(i.by, x.contributors).length)\n bad(\n \"conclusion reviewer must be independent of investigation contributors\",\n \"use a review-capable role that did not contribute to or execute this investigation\",\n );\n if (typeof i.approve !== \"boolean\" || !text(i.reason))\n bad(\n \"review needs approval and reason\",\n \"set approve to a boolean and reason to a nonempty review explanation\",\n );\n if (!i.approve) {\n const target = i.next ?? \"conclusion\";\n if (target !== \"round\" && target !== \"conclusion\")\n bad(\n \"review rejection next must be round or conclusion\",\n \"set next to round for more evidence or conclusion for a revised conclusion\",\n );\n const n = save(\n s,\n {\n ...x,\n phase: target === \"round\" ? \"preregister\" : \"conclusion\",\n reviewHistory: [\n ...(x.reviewHistory ?? []),\n {\n by: i.by,\n reason: i.reason as string,\n approve: false,\n next: target as \"round\" | \"conclusion\",\n replayRefs: [],\n },\n ],\n },\n i,\n \"review-rejected\",\n );\n const iteration = investigationIteration(s);\n if (\n target === \"round\" &&\n (x.rounds.length >= validateInvestigationConfig(s.config).maxRounds ||\n isExhausted(iteration.budget, iteration.spent))\n )\n return closeInvestigation(\n n,\n readInvestigation(n)!,\n i,\n \"stopped\",\n \"budget or round limit exhausted after review requested another round\",\n );\n return n;\n }\n const replayRefs = Array.isArray(i.replayRefs) ? i.replayRefs : [];\n if (\n conclusion.outcome === \"resolved\" &&\n (!refs(replayRefs) ||\n !x.rounds.some(\n (r) =>\n r.experiment.replayOf &&\n !independenceConflicts(\n executionActors(s, r.item),\n executionActors(\n s,\n (\n x.rounds.find((p) => p.experiment.id === r.experiment.replayOf) ??\n brokenInvestigation(\n `round ${r.experiment.id} replays the unknown experiment ${r.experiment.replayOf}`,\n )\n ).item,\n ),\n ).length &&\n sameHypothesis(\n r.hypotheses.find((h) => h.id === conclusion.supportedHypothesis),\n lastRound(x).hypotheses.find((h) => h.id === conclusion.supportedHypothesis),\n ) &&\n r.result?.valid &&\n replayRefs.includes(r.result.id) &&\n r.update?.assessments.some(\n (a) =>\n a.hypothesis === conclusion.supportedHypothesis && a.assessment === \"supported\",\n ),\n ))\n )\n bad(\n \"resolved conclusion requires valid replay result and supporting belief update\",\n \"set replayRefs to a valid independent replay result supporting the latest supported hypothesis definition, or reject with next round\",\n );\n return closeInvestigation(\n s,\n {\n ...x,\n review: { by: i.by, reason: i.reason as string, replayRefs: replayRefs as string[] },\n reviewHistory: [\n ...(x.reviewHistory ?? []),\n {\n by: i.by,\n reason: i.reason as string,\n approve: true,\n replayRefs: replayRefs as string[],\n },\n ],\n },\n i,\n conclusion.outcome,\n );\n }),\n stop: make(\"stop\", \"facilitate\", undefined, (s, x, i, bad) => {\n if (!text(i.reason))\n bad(\n \"stop needs reason\",\n \"set reason to a nonempty explanation for stopping this investigation\",\n );\n return closeInvestigation(s, x, i, \"stopped\", i.reason as string);\n }),\n };\n}\n","import { readInvestigation } from \"./record.ts\";\nimport { executionActors } from \"./execution.ts\";\nimport { independenceConflicts } from \"../../common/independence.ts\";\nimport type { Rule } from \"../../core/types.ts\";\nexport function investigationRules(): Rule[] {\n return [\n {\n id: \"independent-replay\",\n severity: \"error\",\n check(s, a) {\n if (a.type !== \"item.complete\") return [];\n const round = readInvestigation(s)?.rounds.find(\n (r) => r.item === (a.payload as { item?: string })?.item,\n );\n const prior = readInvestigation(s)?.rounds.find(\n (r) => r.experiment.id === round?.experiment.replayOf,\n );\n return prior && independenceConflicts(a.by, executionActors(s, prior.item)).length\n ? [\n {\n rule: \"independent-replay\",\n item: round!.item,\n severity: \"error\",\n message: \"Replay executor also executed the original experiment\",\n fix: \"assign a different deliver-capable role\",\n },\n ]\n : [];\n },\n },\n {\n id: \"investigation-execution-only\",\n severity: \"error\",\n check(s, a) {\n if (a.type !== \"item.complete\") return [];\n const p = a.payload as { item: string };\n const x = readInvestigation(s);\n return x?.phase === \"observe\" && x.rounds.at(-1)?.item === p.item\n ? []\n : [\n {\n rule: \"investigation-execution-only\",\n item: p.item,\n severity: \"error\",\n message: \"Only the active preregistered experiment can complete\",\n fix: `complete only the active experiment item in phase observe; current phase is ${x?.phase ?? \"intake\"}`,\n },\n ];\n },\n },\n ];\n}\n","import type { Role } from \"../../core/types.ts\";\nexport function investigationRoles(): Role[] {\n return [\n {\n id: \"replay-worker\",\n name: \"Independent replay worker\",\n modelTier: \"small\",\n capabilities: [\"deliver\", \"verify\"],\n canApprove: [],\n inputs: [\"preregistered-experiment\"],\n outputs: [\"experiment-output\"],\n do_not: [\"Do not change the replay procedure\"],\n },\n {\n id: \"investigator\",\n name: \"Investigator\",\n modelTier: \"large\",\n capabilities: [\"facilitate\", \"define-acceptance\", \"deliver\", \"verify\"],\n canApprove: [],\n inputs: [\"question\", \"prior-results\"],\n outputs: [\"hypotheses\", \"preregistered-experiment\", \"belief-update\"],\n do_not: [\"Do not revise predictions after execution\", \"Do not approve your own conclusions\"],\n },\n {\n id: \"conclusion-reviewer\",\n name: \"Independent conclusion reviewer\",\n modelTier: \"large\",\n capabilities: [\"review\"],\n canApprove: [\"investigation-conclusion\"],\n inputs: [\"evidence\", \"replay\", \"conclusion\"],\n outputs: [\"conclusion-review\"],\n do_not: [\"Do not approve unsupported conclusions\"],\n },\n ];\n}\n","import type { Stage } from \"../../core/types.ts\";\nexport function investigationStages(): Stage[] {\n return [\n {\n id: \"intake\",\n name: \"Intake\",\n entryPolicy: [],\n exitPolicy: [{ kind: \"acceptance-written\" }],\n },\n {\n id: \"execute\",\n name: \"Execute preregistered experiment\",\n entryPolicy: [{ kind: \"acceptance-written\" }, { kind: \"no-open-blockers\" }],\n exitPolicy: [{ kind: \"evidence\", evidenceKind: \"experiment-output\" }],\n },\n { id: \"observed\", name: \"Execution recorded\", entryPolicy: [], exitPolicy: [] },\n ];\n}\n","import { readInvestigation } from \"./record.ts\";\nimport { fail } from \"../../core/errors.ts\";\nimport { executionActors } from \"./execution.ts\";\nimport { independenceConflicts } from \"../../common/independence.ts\";\nimport { closeInvestigation, investigationCeremonies } from \"./ceremonies.ts\";\nimport { investigationIteration } from \"./invariants.ts\";\nimport { investigationRules } from \"./rules.ts\";\nimport { investigationRoles } from \"./roles.ts\";\nimport { investigationStages } from \"./stages.ts\";\nimport { isExhausted } from \"../../core/budget.ts\";\nimport type { Methodology } from \"../../core/types.ts\";\nimport { validateInvestigationConfig, type InvestigationConfig } from \"./config.ts\";\nexport { validateInvestigationConfig };\nexport type { InvestigationConfig };\nexport type * from \"./state.ts\";\nexport function investigation(): Methodology<InvestigationConfig> {\n return {\n name: \"investigation\",\n validateConfig: validateInvestigationConfig,\n lockedConfigKeys: [\"question\", \"maxRounds\", \"budget\"],\n vocabulary: {\n backlog: \"Questions\",\n item: \"Investigation artifact\",\n stage: \"Investigation phase\",\n iteration: \"Investigation budget\",\n increment: \"Conclusion\",\n ceremony: \"Investigation ceremony\",\n gate: \"Independent conclusion review\",\n },\n defaultStages: investigationStages,\n defaultRoles: investigationRoles,\n requiredCapabilities: [\"facilitate\", \"define-acceptance\", \"deliver\", \"verify\", \"review\"],\n exclusiveCapabilities: [],\n humanDefaults: { gates: \"none\" },\n ceremonies: investigationCeremonies(investigation),\n plannerOptions: (state) => ({\n schedulerMode: \"level\",\n concurrencyCap: 1,\n roleFor: (item) => {\n const r = readInvestigation(state)?.rounds.find((candidate) => candidate.item === item.id);\n const prior = readInvestigation(state)?.rounds.find(\n (p) => p.experiment.id === r?.experiment.replayOf,\n );\n const excluded = prior ? executionActors(state, prior.item) : [];\n const roles = Object.values(state.roles);\n const selected =\n (!prior\n ? roles.find(\n (role) =>\n role.capabilities.includes(\"deliver\") &&\n role.capabilities.includes(\"define-acceptance\"),\n )\n : undefined) ??\n roles.find(\n (role) =>\n role.capabilities.includes(\"deliver\") &&\n !independenceConflicts(role.id, excluded).length,\n );\n if (!selected)\n fail(\n \"missing-capability\",\n `No eligible executor for experiment item \"${item.id}\"`,\n prior\n ? `register an independent deliver-capable role that did not execute \"${prior.item}\"`\n : \"register a role with deliver capability\",\n { items: [item.id] },\n );\n return selected.id;\n },\n estimateMode: \"per-call\",\n fallbackTokensPerWeight: 1,\n }),\n candidates: (s) => {\n // read the record once, not once per item (U10 F2)\n const x = readInvestigation(s);\n const round = x?.rounds.at(-1)?.item;\n return x?.phase === \"observe\" &&\n !isExhausted((s.config as InvestigationConfig).budget, investigationIteration(s).spent)\n ? Object.values(s.items).filter(\n (i) => i.id === round && i.stage === \"execute\" && i.status === \"todo\",\n )\n : [];\n },\n afterComplete: (state, item, now) => {\n const x = readInvestigation(state);\n const iteration = state.iterations.find((it) => it.id === \"investigation\");\n if (\n x?.phase !== \"observe\" ||\n x.rounds.at(-1)?.item !== item ||\n state.items[item]?.status === \"done\" ||\n !iteration ||\n !isExhausted(iteration.budget, iteration.spent)\n )\n return state;\n return closeInvestigation(\n state,\n x,\n { by: \"investigation\", now },\n \"stopped\",\n `budget exhausted before experiment item \"${item}\" completed; start a new investigation with sufficient budget`,\n );\n },\n invariants: (s) => [\n `Question: ${(s.config as InvestigationConfig).question}`,\n \"Execute only the preregistered procedure; retain raw observation provenance; report invalid runs.\",\n ],\n rules: investigationRules(),\n metrics: (s) => ({\n rounds: readInvestigation(s)?.rounds.length ?? 0,\n validRuns: readInvestigation(s)?.rounds.filter((r) => r.result?.valid).length ?? 0,\n invalidRuns:\n readInvestigation(s)?.rounds.filter((r) => r.result && !r.result.valid).length ?? 0,\n }),\n report: (s) => ({\n phase: readInvestigation(s)?.phase ?? \"intake\",\n outcome: readInvestigation(s)?.outcome ?? null,\n rounds: readInvestigation(s)?.rounds.length ?? 0,\n conclusion: readInvestigation(s)?.conclusion ?? null,\n stopReason: readInvestigation(s)?.stopReason ?? null,\n }),\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkYRXFEM3F_cjs=require('./chunk-YRXFEM3F.cjs'),chunkTBLIZIWH_cjs=require('./chunk-TBLIZIWH.cjs'),chunkOSHBJIYD_cjs=require('./chunk-OSHBJIYD.cjs');var oe=new Set(["in_progress","review","blocked"]);function ue(n,o,e,s){chunkOSHBJIYD_cjs.c(o.id,"role id"),chunkTBLIZIWH_cjs.e(n,o.id)&&chunkOSHBJIYD_cjs.b("duplicate-role",`role "${o.id}" already exists`,`use a different id or retireRole("${o.id}") first`);let u={...n,roles:{...n.roles,[o.id]:o}};return chunkTBLIZIWH_cjs.c(u,"role.registered",e,{role:o.id,capabilities:o.capabilities},s)}function pe(n,o,e,s){chunkTBLIZIWH_cjs.e(n,o)||chunkOSHBJIYD_cjs.b("unknown-role",`role "${o}" does not exist`,`registered roles: ${Object.keys(n.roles).join(", ")||"(none)"}`);let u=Object.values(n.items).filter(i=>i.role===o&&oe.has(i.status)).map(i=>i.id);u.length&&chunkOSHBJIYD_cjs.b("role-has-open-items",`role "${o}" still holds ${u.length} open item(s)`,`complete or reassign ${u.join(", ")} before retiring the role`,{items:u});let l={...n.roles};return delete l[o],chunkTBLIZIWH_cjs.c({...n,roles:l},"role.retired",e,{role:o},s)}function K(n,o){let e=[];for(let s of n.events)s.type==="item.completed"&&s.payload.id===o&&e.push({...s.payload,at:s.at});return e}function X(n,o){let e=K(n,o);return e[e.length-1]}function ne(n,o,e){e.role||chunkOSHBJIYD_cjs.b("unknown-role",`item "${e.id}" has no role assigned`,"dispatch it with next() or set item.role",{items:[e.id]});let s=chunkTBLIZIWH_cjs.e(n,e.role);s||chunkOSHBJIYD_cjs.b("unknown-role",`role "${e.role}" does not exist`,`registered roles: ${Object.keys(n.roles).join(", ")}`);let u=[],l=[...s.do_not],i=[...e.dependsOn,...e.type==="bug"||e.type==="change-request"?e.affects??[]:[]];for(let r of i){let g=X(n,r);if(g){u.push({item:r,produced:g.produced,notes:g.notes});for(let m of g.do_not)l.includes(m)||l.push(m);}}let d=K(n,e.id).map(r=>({role:r.role,verdict:r.verdict,notes:r.notes,produced:r.produced,at:r.at})),t=new Set([e.id,...e.dependsOn]),f=Object.values(n.items).filter(r=>(r.type==="bug"||r.type==="change-request")&&r.id!==e.id&&r.status!=="done"&&r.status!=="dropped"&&(r.affects??[]).some(g=>t.has(g))).map(r=>({id:r.id,title:r.title,affects:r.affects??[]})),S=chunkTBLIZIWH_cjs.O(n),k=chunkTBLIZIWH_cjs.n(n,e.stage).gate,w={item:e,role:s,modelTier:s.modelTier,invariants:[...o.invariants(n,e),...n.agreements],do_not:l,acceptance:e.acceptance,upstream:u,priorHandoffs:d,relatedBugs:f,budgetRemaining:S?chunkTBLIZIWH_cjs.L(S.budget,S.spent):{}};k&&(w.gateAhead=k);let a=o.briefContext?.(n,e);if(a&&(w.context=a),e.type==="question"&&e.parent){let r=X(n,e.parent);if(r){w.parent={item:e.parent,role:r.role,notes:r.notes,produced:r.produced,open_questions:r.open_questions??[],do_not:r.do_not};for(let g of r.do_not)l.includes(g)||l.push(g);}}return w}function he(n){let o=new Map;for(let e of n.events){if(e.type!=="item.completed")continue;let s=e.payload;o.delete(s.id),o.set(s.id,{...s,at:e.at});}return [...o.values()].filter(e=>(e.verdict==="done"||e.verdict==="needs-review")&&(e.open_questions??[]).length>0).map(e=>({item:e.id,role:e.role,questions:e.open_questions??[],at:e.at}))}function ve(n,o,e={}){let s=chunkTBLIZIWH_cjs.S(n,o,e),u=s.dispatched.map(l=>ne(s.state,o,s.state.items[l.id]));return s.reason?{state:s.state,briefs:u,skipped:s.skipped,reason:s.reason}:{state:s.state,briefs:u,skipped:s.skipped}}var Y=["done","needs-review","rework","blocked","escalate"],Z=["policy","skill","memory","spec","review"],P=n=>typeof n=="object"&&n!==null&&!Array.isArray(n),W=n=>typeof n=="string";function se(n,o,e){let s=chunkTBLIZIWH_cjs.s(n,o.item);s.status!=="in_progress"&&chunkOSHBJIYD_cjs.b("invalid-transition",`item "${s.id}" is ${s.status}, not in_progress`,"only dispatched items can be completed; call next() first",{items:[s.id]}),Array.isArray(o.do_not)||chunkOSHBJIYD_cjs.b("handoff-invalid",`handoff for "${s.id}" has no do_not array`,"set handoff.do_not to [] when there is nothing to forbid",{items:[s.id]}),(!Array.isArray(o.produced)||!Array.isArray(o.open_questions))&&chunkOSHBJIYD_cjs.b("handoff-invalid",`handoff for "${s.id}" needs produced[] and open_questions[]`,"pass empty arrays when there is nothing",{items:[s.id]});let u=(t,f)=>chunkOSHBJIYD_cjs.b("handoff-invalid",`handoff for "${s.id}": ${t}`,f,{items:[s.id]}),l=o.verdict??"done";Y.includes(l)||u(`unknown verdict ${JSON.stringify(l)}`,`use one of: ${Y.join(", ")}`),o.produced.every(t=>P(t)&&W(t.kind)&&W(t.ref))||u("produced[] entries need string kind and ref",'use { "kind": "code", "ref": "src/a.ts" }');let i=o.lessons??[];(!Array.isArray(i)||!i.every(t=>P(t)&&W(t.text)&&Z.includes(t.scope)))&&u("lessons[] entries need a text and a scope",`scope is one of: ${Z.join(", ")}`);let d=o.follow_ups??[];(!Array.isArray(d)||!d.every(t=>P(t)&&W(t.id)&&W(t.title)))&&u("follow_ups[] entries need a string id and title","describe each follow-up as a new item"),o.role!==s.role&&chunkOSHBJIYD_cjs.b("handoff-invalid",`handoff role "${o.role}" differs from the dispatched role "${s.role}"`,`complete as "${s.role}" or re-dispatch`,{items:[s.id]}),(!e.model||e.model.trim()==="")&&chunkOSHBJIYD_cjs.b("accounting-invalid",`accounting for "${s.id}" has no model`,"record the model id that actually ran the work",{items:[s.id]});for(let t of ["tokensIn","tokensOut","durationMs"])(!Number.isFinite(e[t])||e[t]<0)&&chunkOSHBJIYD_cjs.b("accounting-invalid",`accounting.${t} must be a non-negative number`,`measure ${t} from the host's usage report`,{items:[s.id]});e.tokensIn+e.tokensOut===0&&e.estimate!==true&&chunkOSHBJIYD_cjs.b("accounting-invalid",`accounting for "${s.id}" records 0 tokens`,"pass the host's usage figures, or set estimate: true (CLI --estimate) to record a placeholder and correct it later with correctAccounting / exwf account",{items:[s.id]});}function ee(n){for(let o=n.transitions.length-1;o>=0;o--){let e=n.transitions[o];if(e.to.status==="in_progress")return e.from.stage}return n.stage}function ie(n,o){return chunkTBLIZIWH_cjs.G(n,o)?.from.stage??ee(o)}function Ce(n,o,e,s,u){se(n,e,s);let l,i=chunkTBLIZIWH_cjs.V(n,o,{type:"item.complete",by:e.role,payload:{item:e.item,handoff:e}},()=>(l=re(n,o,e,s,u),l.state));return {state:i.state,warnings:[...i.warnings,...l.warnings]}}function re(n,o,e,s,u){let l=chunkTBLIZIWH_cjs.a(u),i=e.item,d=e.role,t={...n,accounting:[...n.accounting,s]};for(let a of e.produced)t=chunkTBLIZIWH_cjs.A(t,i,{kind:a.kind,ref:a.ref,by:d},l);let f=chunkTBLIZIWH_cjs.O(t);f&&(f.committed.includes(i)||chunkTBLIZIWH_cjs.s(t,i).iteration===f.id)&&(t={...t,iterations:t.iterations.map(a=>a.id===f.id?{...a,spent:chunkTBLIZIWH_cjs.K(a.spent,s)}:a)});for(let a of e.lessons??[]){let r=`L${t.lessons.length+1}`;t={...t,lessons:[...t.lessons,{id:r,at:l,text:a.text,scope:a.scope,status:"raised",from:d,item:i}]},t=chunkTBLIZIWH_cjs.c(t,"lesson.raised",d,{id:r,from:d,item:i,scope:a.scope},l);}let S=[];for(let a of e.follow_ups??[]){let r=t.stages[0],{iteration:g,...m}=a;t=chunkTBLIZIWH_cjs.t(t,{...m,stage:r.id,parent:i,tags:[...a.tags??[],"follow-up"]},d,l),S.push(a.id);}let k=e.verdict??"done",w=[];if((k==="done"||k==="needs-review")&&e.open_questions.length>0&&w.push({rule:"open-questions-ignored",severity:"warning",item:i,message:`"${i}" finished with ${e.open_questions.length} open question(s) nobody will see: ${e.open_questions.join(" | ")}`,fix:'use verdict "escalate" to route them to a role with capability escalate, or answer them in the next brief'}),k==="rework"){(!e.notes||e.notes.trim()==="")&&chunkOSHBJIYD_cjs.b("handoff-invalid",`rework on "${i}" needs notes`,"say what must change in handoff.notes",{items:[i]});let a=chunkTBLIZIWH_cjs.s(t,i);t=chunkTBLIZIWH_cjs.w(chunkTBLIZIWH_cjs.v(t,i,{stage:ie(t,a),status:"todo"},d,l),i),t=chunkTBLIZIWH_cjs.c(t,"item.rework",d,{id:i,by:d,notes:e.notes},l);}else if((k==="done"||k==="needs-review")&&chunkTBLIZIWH_cjs.s(t,i).type==="question"){let a=t.stages[t.stages.length-1].id;t=chunkTBLIZIWH_cjs.v(t,i,{stage:a,status:"done"},d,l);}else if(k==="done"||k==="needs-review"){let a=chunkTBLIZIWH_cjs.s(t,i),r=chunkTBLIZIWH_cjs.n(t,a.stage);if(chunkTBLIZIWH_cjs.C(t,a,r.exitPolicy,`leave "${r.id}"`,o),r.gate){let g=o.escalateGate?.(t,a,r.gate),m=chunkYRXFEM3F_cjs.c(r.gate,g),v=chunkYRXFEM3F_cjs.d(t,a,m,d);v.outcome==="fail"&&chunkOSHBJIYD_cjs.b("gate-unmet",`gate "${m.id}" blocks "${i}": ${v.violations.map(h=>h.message).join("; ")}`,v.violations.map(h=>h.fix).join("; "),{items:[i],rule:v.violations[0].rule}),o.escalateGate&&(t=chunkTBLIZIWH_cjs.c(t,"gate.resolved",d,{item:i,gate:m.id,requires:m.requires,evidence:m.evidence,reason:g?.reason??{}},l)),v.outcome==="human"?t=chunkYRXFEM3F_cjs.e(t,{kind:"gate",item:i,gate:r.gate.id,question:`Approve gate "${r.gate.id}" for "${a.title}" (${i})?`},l):t=chunkTBLIZIWH_cjs.c(chunkTBLIZIWH_cjs.x(t,i,d,k==="needs-review",l),"gate.passed",d,{item:i,gate:r.gate.id},l);}else t=chunkTBLIZIWH_cjs.x(t,i,d,k==="needs-review",l);}else if(k==="blocked")t=chunkYRXFEM3F_cjs.a(t,i,e.notes||"blocked by worker",d,d,l);else if(k==="escalate"){let a=chunkTBLIZIWH_cjs.g(t,"escalate")[0];a||chunkOSHBJIYD_cjs.b("missing-capability",`no role has capability "escalate" to receive the question from "${i}"`,"register a role with capability escalate",{items:[i]});let r=Object.keys(t.items).filter(N=>N.startsWith(`${i}-q`)).length+1,g=`${i}-q${r}`,m=chunkTBLIZIWH_cjs.s(t,i),v=ee(m),h={id:g,type:"question",title:e.open_questions.join(" | ")||e.notes||`question from ${i}`,parent:i,role:a.id,priority:Number.MAX_SAFE_INTEGER,stage:v};m.iteration!==void 0&&(h.iteration=m.iteration),t=chunkTBLIZIWH_cjs.t(t,h,d,l),t=chunkTBLIZIWH_cjs.v(t,i,{stage:v,status:"todo"},d,l),t=chunkTBLIZIWH_cjs.r(t,i,N=>({...N,dependsOn:[...N.dependsOn,g]})),t=chunkTBLIZIWH_cjs.c(t,"item.escalated",d,{id:i,question:g,to:a.id},l);}return t=chunkTBLIZIWH_cjs.c(t,"item.completed",d,{id:i,role:d,verdict:k,produced:e.produced,notes:e.notes,do_not:e.do_not,open_questions:e.open_questions,followUps:S,tokens:s.tokensIn+s.tokensOut,durationMs:s.durationMs,model:s.model},l),o.afterComplete&&(t=o.afterComplete(t,i,l)),{state:t,warnings:w}}var ae=[["tokensIn","tokens-in"],["tokensOut","tokens-out"],["durationMs","duration-ms"]],te=n=>({tokensIn:n.tokensIn,tokensOut:n.tokensOut,durationMs:n.durationMs,model:n.model});function Ve(n,o,e,s,u,l){chunkTBLIZIWH_cjs.s(n,o);let i=[];n.accounting.forEach((p,b)=>{p.item===o&&i.push(b);}),i.length===0&&chunkOSHBJIYD_cjs.b("invalid-input",`item "${o}" has no accounting line to correct`,`complete "${o}" first (exwf complete), then exwf account`,{items:[o]});let d=l??i.length;(!Number.isInteger(d)||d<1||d>i.length)&&chunkOSHBJIYD_cjs.b("invalid-input",`item "${o}" has ${i.length} accounting line(s), not line ${String(l)}`,`pass --line 1..${i.length}`,{items:[o]});let t=i[d-1],f=n.accounting[t];for(let[p,b]of ae){let q=e[p];q!==void 0&&(!Number.isFinite(q)||q<0)&&chunkOSHBJIYD_cjs.b("accounting-invalid",`${p} must be a non-negative number`,`pass --${b} <n> with a measured figure`,{items:[o]});}e.model!==void 0&&e.model.trim()===""&&chunkOSHBJIYD_cjs.b("accounting-invalid","model must not be empty","pass --model with the model id that ran the work",{items:[o]});let{estimate:S,...k}=f,w={...k,tokensIn:e.tokensIn??f.tokensIn,tokensOut:e.tokensOut??f.tokensOut,durationMs:e.durationMs??f.durationMs,model:e.model??f.model};w.tokensIn+w.tokensOut===0&&chunkOSHBJIYD_cjs.b("accounting-invalid",`the correction leaves "${o}" at 0 tokens`,"pass the host's usage figures with --tokens-in / --tokens-out",{items:[o]});let a=te(f),r=te(w);a.tokensIn===r.tokensIn&&a.tokensOut===r.tokensOut&&a.durationMs===r.durationMs&&a.model===r.model&&f.estimate!==true&&chunkOSHBJIYD_cjs.b("no-op",`accounting for "${o}" line ${d} already has these figures`,"pass at least one different value to exwf account",{items:[o]});let m={tokens:r.tokensIn+r.tokensOut-(a.tokensIn+a.tokensOut),durationMs:r.durationMs-a.durationMs},v=n.items[o],h;for(let p of n.iterations)(p.committed.includes(o)||v.iteration===p.id)&&p.startedAt<=f.endedAt&&(p.endedAt===void 0||f.endedAt<=p.endedAt)&&(h=p);let N={...n,accounting:n.accounting.map((p,b)=>b===t?w:p)};return h&&(N={...N,iterations:N.iterations.map(p=>p.id===h.id?{...p,spent:{...p.spent,tokens:Math.max(0,p.spent.tokens+m.tokens),wallclockMs:Math.max(0,p.spent.wallclockMs+m.durationMs)}}:p)}),chunkTBLIZIWH_cjs.c(N,"accounting.corrected",s,{item:o,line:d,iteration:h?.id??null,before:a,after:r,delta:m},chunkTBLIZIWH_cjs.a(u))}exports.a=ue;exports.b=pe;exports.c=ne;exports.d=he;exports.e=ve;exports.f=Ce;exports.g=Ve;//# sourceMappingURL=chunk-LQJPLXFR.cjs.map
2
+ //# sourceMappingURL=chunk-LQJPLXFR.cjs.map