ex-workflow 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -1
- package/README.md +125 -40
- package/dist/adapters/index.cjs +1 -1
- package/dist/adapters/index.d.cts +1 -1
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.mjs +1 -1
- package/dist/{budget-CezCinPF.d.cts → budget-Bm839Qw0.d.cts} +8 -7
- package/dist/{budget-Bd8KpGIr.d.ts → budget-Gckmqj74.d.ts} +8 -7
- package/dist/chunk-32NVJV5C.mjs +2 -0
- package/dist/chunk-32NVJV5C.mjs.map +1 -0
- package/dist/chunk-3GKYL6VB.mjs +6 -0
- package/dist/chunk-3GKYL6VB.mjs.map +1 -0
- package/dist/chunk-3O5MPAJT.cjs +2 -0
- package/dist/chunk-3O5MPAJT.cjs.map +1 -0
- package/dist/{chunk-C2IYMWE6.cjs → chunk-43GLYYA2.cjs} +3 -3
- package/dist/chunk-43GLYYA2.cjs.map +1 -0
- package/dist/chunk-4HG6A3SF.mjs +2 -0
- package/dist/chunk-4HG6A3SF.mjs.map +1 -0
- package/dist/chunk-6D6FL3XK.mjs +2 -0
- package/dist/chunk-6D6FL3XK.mjs.map +1 -0
- package/dist/chunk-7EF47R2J.mjs +2 -0
- package/dist/chunk-7EF47R2J.mjs.map +1 -0
- package/dist/chunk-BBI7AKJK.cjs +2 -0
- package/dist/chunk-BBI7AKJK.cjs.map +1 -0
- package/dist/{chunk-KLWZEXZU.mjs → chunk-BD76VFI4.mjs} +3 -3
- package/dist/chunk-BD76VFI4.mjs.map +1 -0
- package/dist/chunk-BHAEPYRJ.cjs +2 -0
- package/dist/chunk-BHAEPYRJ.cjs.map +1 -0
- package/dist/chunk-BYPFTO7P.mjs +2 -0
- package/dist/chunk-BYPFTO7P.mjs.map +1 -0
- package/dist/chunk-C4ISBUZR.mjs +2 -0
- package/dist/chunk-C4ISBUZR.mjs.map +1 -0
- package/dist/chunk-FDZB73PH.mjs +2 -0
- package/dist/chunk-FDZB73PH.mjs.map +1 -0
- package/dist/chunk-GKN5M4B7.cjs +2 -0
- package/dist/chunk-GKN5M4B7.cjs.map +1 -0
- package/dist/chunk-IDZ435YZ.mjs +2 -0
- package/dist/{chunk-KIQOUUEZ.mjs.map → chunk-IDZ435YZ.mjs.map} +1 -1
- package/dist/chunk-IIEKK2S3.cjs +2 -0
- package/dist/chunk-IIEKK2S3.cjs.map +1 -0
- package/dist/chunk-JNLWI4JM.mjs +2 -0
- package/dist/chunk-JNLWI4JM.mjs.map +1 -0
- package/dist/chunk-K4VSMIJZ.cjs +2 -0
- package/dist/chunk-K4VSMIJZ.cjs.map +1 -0
- package/dist/chunk-LCN4UNYK.cjs +2 -0
- package/dist/chunk-LCN4UNYK.cjs.map +1 -0
- package/dist/chunk-LIATP6LY.mjs +2 -0
- package/dist/chunk-LIATP6LY.mjs.map +1 -0
- package/dist/chunk-MB465DI4.mjs +2 -0
- package/dist/chunk-MB465DI4.mjs.map +1 -0
- package/dist/chunk-OSHBJIYD.cjs +2 -0
- package/dist/chunk-OSHBJIYD.cjs.map +1 -0
- package/dist/chunk-OVR5CK3R.cjs +2 -0
- package/dist/chunk-OVR5CK3R.cjs.map +1 -0
- package/dist/chunk-OZAYOPLB.mjs +2 -0
- package/dist/chunk-OZAYOPLB.mjs.map +1 -0
- package/dist/chunk-PNWRA4JU.cjs +2 -0
- package/dist/{chunk-PO2SPQJP.cjs.map → chunk-PNWRA4JU.cjs.map} +1 -1
- package/dist/chunk-QAENYYU6.cjs +2 -0
- package/dist/chunk-QAENYYU6.cjs.map +1 -0
- package/dist/chunk-RXY434DX.cjs +6 -0
- package/dist/chunk-RXY434DX.cjs.map +1 -0
- package/dist/chunk-SFYUJQYW.cjs +2 -0
- package/dist/chunk-SFYUJQYW.cjs.map +1 -0
- package/dist/chunk-TQR3VFZU.mjs +2 -0
- package/dist/chunk-TQR3VFZU.mjs.map +1 -0
- package/dist/chunk-U3RU5LOF.cjs +2 -0
- package/dist/chunk-U3RU5LOF.cjs.map +1 -0
- package/dist/chunk-UUWDQVIJ.mjs +2 -0
- package/dist/chunk-UUWDQVIJ.mjs.map +1 -0
- package/dist/chunk-VXOZIP77.cjs +2 -0
- package/dist/chunk-VXOZIP77.cjs.map +1 -0
- package/dist/chunk-W2P27645.cjs +2 -0
- package/dist/chunk-W2P27645.cjs.map +1 -0
- package/dist/chunk-WPVL27G4.mjs +2 -0
- package/dist/chunk-WPVL27G4.mjs.map +1 -0
- package/dist/chunk-YS6CXERQ.mjs +2 -0
- package/dist/chunk-YS6CXERQ.mjs.map +1 -0
- package/dist/chunk-Z43GUETW.cjs +2 -0
- package/dist/chunk-Z43GUETW.cjs.map +1 -0
- package/dist/cli/bin.cjs +1 -1
- package/dist/cli/bin.cjs.map +1 -1
- package/dist/cli/bin.mjs +1 -1
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/experimentation/index.cjs +1 -1
- package/dist/experimentation/index.d.cts +2 -2
- package/dist/experimentation/index.d.ts +2 -2
- package/dist/experimentation/index.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -15
- package/dist/index.d.ts +143 -15
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/investigation/index.cjs +1 -1
- package/dist/investigation/index.d.cts +2 -2
- package/dist/investigation/index.d.ts +2 -2
- package/dist/investigation/index.mjs +1 -1
- package/dist/kanban/index.cjs +1 -1
- package/dist/kanban/index.d.cts +2 -1
- package/dist/kanban/index.d.ts +2 -1
- package/dist/kanban/index.mjs +1 -1
- package/dist/registry/index.cjs +2 -0
- package/dist/registry/index.cjs.map +1 -0
- package/dist/registry/index.d.cts +25 -0
- package/dist/registry/index.d.ts +25 -0
- package/dist/registry/index.mjs +2 -0
- package/dist/registry/index.mjs.map +1 -0
- package/dist/schema/index.cjs +1 -1
- package/dist/schema/index.d.cts +2 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.mjs +1 -1
- package/dist/scrum/index.cjs +1 -1
- package/dist/scrum/index.d.cts +3 -3
- package/dist/scrum/index.d.ts +3 -3
- package/dist/scrum/index.mjs +1 -1
- package/dist/{types-BScHXlRx.d.cts → types-DjePDfms.d.cts} +61 -22
- package/dist/{types-BScHXlRx.d.ts → types-DjePDfms.d.ts} +61 -22
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.mjs +1 -1
- package/dist/waterfall/index.cjs +1 -1
- package/dist/waterfall/index.d.cts +1 -1
- package/dist/waterfall/index.d.ts +1 -1
- package/dist/waterfall/index.mjs +1 -1
- package/package.json +20 -4
- package/dist/chunk-2FRRD6A3.mjs +0 -2
- package/dist/chunk-2FRRD6A3.mjs.map +0 -1
- package/dist/chunk-6P3OKXSK.mjs +0 -2
- package/dist/chunk-6P3OKXSK.mjs.map +0 -1
- package/dist/chunk-7FS6KWTG.cjs +0 -2
- package/dist/chunk-7FS6KWTG.cjs.map +0 -1
- package/dist/chunk-APKA5FOU.cjs +0 -2
- package/dist/chunk-APKA5FOU.cjs.map +0 -1
- package/dist/chunk-ATCJ4IHP.mjs +0 -2
- package/dist/chunk-ATCJ4IHP.mjs.map +0 -1
- package/dist/chunk-C2IYMWE6.cjs.map +0 -1
- package/dist/chunk-EACZBAP3.cjs +0 -2
- package/dist/chunk-EACZBAP3.cjs.map +0 -1
- package/dist/chunk-EHBQBXWA.cjs +0 -2
- package/dist/chunk-EHBQBXWA.cjs.map +0 -1
- package/dist/chunk-FQW2LETC.cjs +0 -2
- package/dist/chunk-FQW2LETC.cjs.map +0 -1
- package/dist/chunk-FTS75UIU.mjs +0 -2
- package/dist/chunk-FTS75UIU.mjs.map +0 -1
- package/dist/chunk-HCRVWMG4.cjs +0 -2
- package/dist/chunk-HCRVWMG4.cjs.map +0 -1
- package/dist/chunk-KIQOUUEZ.mjs +0 -2
- package/dist/chunk-KLWZEXZU.mjs.map +0 -1
- package/dist/chunk-MW4HR7HC.mjs +0 -2
- package/dist/chunk-MW4HR7HC.mjs.map +0 -1
- package/dist/chunk-NDCQTRIV.mjs +0 -2
- package/dist/chunk-NDCQTRIV.mjs.map +0 -1
- package/dist/chunk-PO2SPQJP.cjs +0 -2
- package/dist/chunk-QZ6HD6DE.mjs +0 -6
- package/dist/chunk-QZ6HD6DE.mjs.map +0 -1
- package/dist/chunk-RL27372B.cjs +0 -2
- package/dist/chunk-RL27372B.cjs.map +0 -1
- package/dist/chunk-S3BXVHO7.cjs +0 -2
- package/dist/chunk-S3BXVHO7.cjs.map +0 -1
- package/dist/chunk-SP5MC7RR.mjs +0 -2
- package/dist/chunk-SP5MC7RR.mjs.map +0 -1
- package/dist/chunk-SYLO7FUL.mjs +0 -2
- package/dist/chunk-SYLO7FUL.mjs.map +0 -1
- package/dist/chunk-T3V5UE34.mjs +0 -2
- package/dist/chunk-T3V5UE34.mjs.map +0 -1
- package/dist/chunk-TS66RAJR.cjs +0 -2
- package/dist/chunk-TS66RAJR.cjs.map +0 -1
- package/dist/chunk-U23FUYPD.cjs +0 -6
- package/dist/chunk-U23FUYPD.cjs.map +0 -1
- package/dist/chunk-YJQ5YJ7S.cjs +0 -2
- package/dist/chunk-YJQ5YJ7S.cjs.map +0 -1
- package/dist/chunk-YOS77GL3.mjs +0 -2
- package/dist/chunk-YOS77GL3.mjs.map +0 -1
- package/dist/chunk-YTG2MOD7.cjs +0 -2
- package/dist/chunk-YTG2MOD7.cjs.map +0 -1
- package/dist/chunk-YZJ6WFH4.mjs +0 -2
- package/dist/chunk-YZJ6WFH4.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/adapters/file.ts"],"names":["WORKFLOW_DIR","statePath","root","path","writeAtomic","file","content","tmp","randomBytes","mkdir","writeFile","rename","e","unlink","fail","withStateLock","fn","opts","retries","intervalMs","staleMs","lock","fsFail","held","attempt","fh","open","snap","stat","now","resolve","notTooDeep","what","saveState","state","json","out","withoutLegacyMirrors","assertValid","workflowStateSchema","loadState","raw","readFile","parsed","key","item","rolesDir","manifests","readdir","f","roles","manifestPath","role","roleSchema","withLegacyMirrors","inWorkflowDir","assertFileId","id","checkBriefNames","ids","dir","taken","batch","name","clash","saveBrief","brief","saveHandoff","handoff","seq"],"mappings":"kWAQO,IAAMA,EAAe,YAErB,SAASC,EAAUC,CAAAA,CAAsB,CAC9C,OAAOC,kBAAAA,CAAK,IAAA,CAAKD,EAAMF,CAAAA,CAAc,YAAY,CACnD,CAEA,eAAeI,EAAYC,CAAAA,CAAcC,CAAAA,CAAgC,CACvE,IAAMC,CAAAA,CAAM,CAAA,EAAGF,CAAI,CAAA,KAAA,EAAQ,OAAA,CAAQ,GAAG,CAAA,CAAA,EAAIG,kBAAAA,CAAY,CAAC,CAAA,CAAE,QAAA,CAAS,KAAK,CAAC,CAAA,CAAA,CACxE,GAAI,CACF,MAAMC,eAAMN,kBAAAA,CAAK,OAAA,CAAQE,CAAI,CAAA,CAAG,CAAE,SAAA,CAAW,CAAA,CAAK,CAAC,CAAA,CACnD,MAAMK,kBAAAA,CAAUH,CAAAA,CAAKD,EAAS,MAAM,CAAA,CACpC,MAAMK,eAAAA,CAAOJ,CAAAA,CAAKF,CAAI,EACxB,CAAA,MAASO,EAAG,CAEV,MAAMC,gBAAON,CAAG,CAAA,CAAE,MAAM,IAAG,CAAA,CAAY,CAAA,CACvCO,mBAAAA,CACE,eAAA,CACA,CAAA,aAAA,EAAgBT,CAAI,CAAA,EAAA,EAAMO,CAAAA,CAAY,OAAO,CAAA,CAAA,CAC7C,4CACF,EACF,CACF,CASA,eAAsBG,CAAAA,CACpBb,CAAAA,CACAc,EACAC,CAAAA,CAAoB,GACR,CACZ,GAAM,CAAE,OAAA,CAAAC,CAAAA,CAAU,GAAI,UAAA,CAAAC,CAAAA,CAAa,GAAI,OAAA,CAAAC,CA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AYC,CAAAA,CAAM,IAAA,CAAK,SAAA,CAAU6D,CAAAA,CAAO,IAAA,CAAM,CAAC,CAAA,CAAI;AAAA,CAAI,CAAA,CACtD7D,CACT,CAEA,eAAsB8D,CAAAA,CAAYjE,EAAckE,CAAAA,CAAkBC,CAAAA,CAA8B,CAC9Fb,CAAAA,CAAaY,CAAAA,CAAQ,IAAA,CAAM,iBAAiB,CAAA,CAAA,CACxC,CAAC,MAAA,CAAO,aAAA,CAAcC,CAAG,CAAA,EAAKA,CAAAA,CAAM,CAAA,GACtCvD,mBAAAA,CACE,eAAA,CACA,CAAA,YAAA,EAAe,MAAA,CAAOuD,CAAG,CAAC,iCAC1B,uEACF,CAAA,CACF,IAAMhE,CAAAA,CAAOkD,CAAAA,CACXrD,CAAAA,CACAC,kBAAAA,CAAK,IAAA,CAAKD,CAAAA,CAAMF,CAAAA,CAAc,UAAA,CAAY,CAAA,EAAGoE,CAAAA,CAAQ,IAAI,IAAIC,CAAG,CAAA,KAAA,CAAO,CACzE,CAAA,CACA,OAAA,MAAMjE,CAAAA,CAAYC,CAAAA,CAAM,IAAA,CAAK,SAAA,CAAU+D,CAAAA,CAAS,IAAA,CAAM,CAAC,CAAA,CAAI;AAAA,CAAI,EACxD/D,CACT","file":"chunk-RXY434DX.cjs","sourcesContent":["import { mkdir, open, readFile, readdir, rename, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { randomBytes } from \"node:crypto\";\nimport path from \"node:path\";\nimport { fail } from \"../core/errors.ts\";\nimport { withLegacyMirrors, withoutLegacyMirrors } from \"../interface/ext.ts\";\nimport { assertValid, roleSchema, workflowStateSchema } from \"../schema/index.ts\";\nimport type { Brief, Handoff, Role, WorkflowState } from \"../core/types.ts\";\n\nexport const WORKFLOW_DIR = \".workflow\";\n\nexport function statePath(root: string): string {\n return path.join(root, WORKFLOW_DIR, \"state.json\");\n}\n\nasync function writeAtomic(file: string, content: string): Promise<void> {\n const tmp = `${file}.tmp-${process.pid}-${randomBytes(4).toString(\"hex\")}`;\n try {\n await mkdir(path.dirname(file), { recursive: true });\n await writeFile(tmp, content, \"utf8\");\n await rename(tmp, file);\n } catch (e) {\n // best effort: remove the temp file if it was created; ignore failure\n await unlink(tmp).catch(() => undefined);\n fail(\n \"invalid-input\",\n `cannot write ${file}: ${(e as Error).message}`,\n \"check the directory exists and is writable\",\n );\n }\n}\n\nexport interface LockOptions {\n retries?: number;\n intervalMs?: number;\n staleMs?: number;\n}\n\n/** Run `fn` while holding `.workflow/state.lock`, so concurrent exwf commands cannot lose each other's updates. */\nexport async function withStateLock<T>(\n root: string,\n fn: () => Promise<T>,\n opts: LockOptions = {},\n): Promise<T> {\n const { retries = 40, intervalMs = 50, staleMs = 60_000 } = opts;\n const lock = path.join(root, WORKFLOW_DIR, \"state.lock\");\n const fsFail = (e: unknown): never =>\n fail(\n \"invalid-input\",\n `cannot create ${lock}: ${(e as Error).message}`,\n `check that ${path.dirname(lock)} is a writable directory`,\n );\n await mkdir(path.dirname(lock), { recursive: true }).catch(fsFail);\n let held = false;\n for (let attempt = 0; !held; attempt++) {\n try {\n const fh = await open(lock, \"wx\");\n await fh.writeFile(`${process.pid} ${new Date().toISOString()}\\n`);\n await fh.close();\n held = true;\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code !== \"EEXIST\") fsFail(e);\n const snap = await stat(lock).catch(() => undefined);\n if (snap && Date.now() - snap.mtimeMs > staleMs) {\n // bounded like the wait below: a stale lock that unlink cannot remove must not loop forever\n if (attempt > retries)\n fail(\n \"invalid-input\",\n `cannot remove the stale lock ${lock}`,\n `delete ${lock} by hand (check its permissions) once no exwf process is running`,\n );\n // re-stat just before unlink: if another recoverer already replaced the lock, leave it alone\n const now = await stat(lock).catch(() => undefined);\n if (now && now.ino === snap.ino && now.mtimeMs === snap.mtimeMs) {\n const removed = await unlink(lock).then(\n () => true,\n () => false,\n );\n if (!removed) await new Promise((resolve) => setTimeout(resolve, intervalMs));\n }\n continue;\n }\n if (attempt >= retries)\n fail(\n \"invalid-input\",\n \"another exwf command holds .workflow/state.lock\",\n \"retry, or delete the file if no exwf process is running\",\n );\n await new Promise((resolve) => setTimeout(resolve, intervalMs));\n }\n }\n try {\n return await fn();\n } finally {\n await unlink(lock).catch(() => undefined);\n }\n}\n\n/** Runs `fn`, turning the stack overflow a pathologically deep value causes into a WorkflowError. */\nfunction notTooDeep<T>(what: string, fn: () => T): T {\n try {\n return fn();\n } catch (e) {\n // only the stack overflow (V8: \"Maximum call stack size exceeded\"); any other RangeError,\n // such as \"Invalid string length\", is not about nesting and is rethrown as it is\n if (e instanceof RangeError && /maximum call stack size exceeded/i.test(e.message))\n fail(\n \"invalid-input\",\n `${what} is nested too deeply to process (${e.message})`,\n \"flatten the deeply nested value (an array or object thousands of levels deep)\",\n );\n throw e;\n }\n}\n\nexport async function saveState(root: string, state: WorkflowState): Promise<void> {\n const json = notTooDeep(statePath(root), () => {\n // on disk only ext.<key>; loadState rebuilds the legacy mirror (spec 26)\n const out = JSON.stringify(withoutLegacyMirrors(state), null, 2) + \"\\n\";\n assertValid(workflowStateSchema, JSON.parse(out), statePath(root));\n return out;\n });\n await writeAtomic(statePath(root), json);\n}\n\nexport async function loadState(root: string): Promise<WorkflowState> {\n const file = statePath(root);\n let raw: string;\n try {\n raw = await readFile(file, \"utf8\");\n } catch {\n fail(\n \"invalid-input\",\n `no workflow state at ${file}`,\n \"run `exwf init <scrum|kanban|waterfall> --config <file>` in this directory first\",\n );\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (e) {\n if (e instanceof RangeError)\n notTooDeep(file, () => {\n throw e;\n });\n fail(\n \"invalid-input\",\n `${file} is not valid JSON: ${(e as Error).message}`,\n \"restore it from git or re-run exwf init\",\n );\n }\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n fail(\n \"invalid-input\",\n `${file} does not contain a workflow state object`,\n \"restore it from git or re-run exwf init\",\n );\n }\n const state = parsed as WorkflowState;\n if (state.version !== 1)\n fail(\n \"state-version\",\n `${file} has schema version ${String(state.version)}; this ex-workflow reads version 1`,\n \"upgrade ex-workflow, or run the migration this version documents in its changelog\",\n );\n notTooDeep(file, () => assertValid(workflowStateSchema, parsed, file));\n for (const [key, item] of Object.entries(state.items))\n if (item.id !== key)\n fail(\n \"invalid-input\",\n `${file}: /items/${key} holds item id ${JSON.stringify(item.id)}`,\n `make the key and the id the same at /items/${key}, or restore the file from git`,\n );\n const rolesDir = path.join(root, WORKFLOW_DIR, \"roles\");\n let manifests: string[] = [];\n try {\n manifests = (await readdir(rolesDir)).filter((f) => f.endsWith(\".json\"));\n } catch {\n /* no extra roles */\n }\n const roles = { ...state.roles };\n for (const f of manifests) {\n const manifestPath = path.join(rolesDir, f);\n let role: Role;\n try {\n role = JSON.parse(await readFile(manifestPath, \"utf8\")) as Role;\n } catch (e) {\n fail(\n \"invalid-input\",\n `role manifest ${manifestPath} is not valid JSON: ${(e as Error).message}`,\n \"fix or delete that manifest\",\n );\n }\n assertValid(roleSchema, role, `role manifest ${manifestPath}`);\n // an existing manifest keeps the 1.1 id rules (spec 26, \"Role manifests\"); as in 1.1.1 the id\n // \"__proto__\" is skipped, since assigning it would set the prototype of roles\n if (role.id === \"__proto__\") continue;\n if (!Object.hasOwn(roles, role.id)) roles[role.id] = role;\n }\n return withLegacyMirrors({ ...state, roles });\n}\n\nfunction inWorkflowDir(root: string, file: string): string {\n if (!path.resolve(file).startsWith(path.resolve(root, WORKFLOW_DIR) + path.sep))\n fail(\n \"invalid-input\",\n `${file} resolves outside ${WORKFLOW_DIR}/`,\n \"use a plain item id (letters, digits, - _ .)\",\n );\n return file;\n}\n\n// what makes `<id>.json` a safe file name. The creation-time rules of assertId (pattern, length cap,\n// device and prototype names) are not applied to an id that already exists (spec 26)\nfunction assertFileId(id: unknown, what: string): asserts id is string {\n if (\n typeof id !== \"string\" ||\n id === \"\" ||\n id.startsWith(\".\") ||\n id.includes(\"..\") ||\n /[/\\\\\\0]/.test(id)\n )\n fail(\n \"invalid-input\",\n `${what} ${JSON.stringify(id)} cannot be a file name under ${WORKFLOW_DIR}/`,\n \"use an id with no / \\\\ NUL or .. and no leading . (e.g. CART-12)\",\n );\n}\n\n/**\n * Checks the brief file names of one dispatch before any is written: each id is a safe file name\n * and no two names, in the batch or against `.workflow/briefs/`, differ only in letter case.\n */\nexport async function checkBriefNames(root: string, ids: readonly string[]): Promise<void> {\n const dir = path.join(root, WORKFLOW_DIR, \"briefs\");\n const taken = new Map<string, string>();\n for (const f of await readdir(dir).catch(() => [] as string[])) taken.set(f.toLowerCase(), f);\n const batch = new Map<string, string>();\n for (const id of ids) {\n assertFileId(id, \"brief item id\");\n const name = `${id}.json`;\n inWorkflowDir(root, path.join(dir, name));\n const key = name.toLowerCase();\n // on a case-insensitive file system A.json and a.json are one file\n const clash = [batch.get(key), taken.get(key)].find((f) => f !== undefined && f !== name);\n if (clash)\n fail(\n \"invalid-input\",\n `item \"${id}\": its brief ${name} differs only in letter case from the brief ${clash} of another item`,\n \"give ids that differ by more than letter case (re-add one item under a new id); briefs/<id>.json would overwrite each other on macOS and Windows\",\n );\n batch.set(key, name);\n }\n}\n\nexport async function saveBrief(root: string, brief: Brief): Promise<string> {\n await checkBriefNames(root, [brief.item.id]);\n const file = path.join(root, WORKFLOW_DIR, \"briefs\", `${brief.item.id}.json`);\n await writeAtomic(file, JSON.stringify(brief, null, 2) + \"\\n\");\n return file;\n}\n\nexport async function saveHandoff(root: string, handoff: Handoff, seq: number): Promise<string> {\n assertFileId(handoff.item, \"handoff item id\");\n if (!Number.isSafeInteger(seq) || seq < 0)\n fail(\n \"invalid-input\",\n `handoff seq ${String(seq)} is not a non-negative integer`,\n \"pass the state's event count after complete (res.state.events.length)\",\n );\n const file = inWorkflowDir(\n root,\n path.join(root, WORKFLOW_DIR, \"handoffs\", `${handoff.item}-${seq}.json`),\n );\n await writeAtomic(file, JSON.stringify(handoff, null, 2) + \"\\n\");\n return file;\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkBHAEPYRJ_cjs=require('./chunk-BHAEPYRJ.cjs'),chunkBBI7AKJK_cjs=require('./chunk-BBI7AKJK.cjs'),chunkZ43GUETW_cjs=require('./chunk-Z43GUETW.cjs'),chunkOSHBJIYD_cjs=require('./chunk-OSHBJIYD.cjs');var g=e=>chunkBBI7AKJK_cjs.a(e,"experimentation"),y=(e,t)=>chunkBBI7AKJK_cjs.b(e,"experimentation",t);var k=["tokens","turns","wallclockMs"];function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function r(e){return chunkOSHBJIYD_cjs.b("invalid-input",e,"supply valid experimentation ceremony input")}function m(e,t){return (typeof e!="string"||!e.trim())&&r(`${t} must be a non-empty string`),e}function v(e,t="sha"){let n=m(e,t);return /^[a-f0-9]{40}$|^[a-f0-9]{64}$/.test(n)||r(`${t} must be a full lowercase commit SHA`),n}function re(e,t){(!C(e)||!k.some(a=>e[a]!==void 0)||Object.keys(e).some(a=>!k.includes(a)))&&r(`${t} needs tokens, turns or wallclockMs limits`);let n={};for(let a of k){let i=e[a];i!==void 0&&((typeof i!="number"||!Number.isSafeInteger(i)||i<=0)&&r(`${t}.${a} must be a positive safe integer`),n[a]=i);}return n}function b(e){try{C(e)||r("experimentation config must be an object");let t=["objective","direction","tieBreak","concurrencyCap","maxCandidates","candidateBudget","totalBudget"];Object.keys(e).some(c=>!t.includes(c))&&r("unknown experimentation config key");let n=m(e.objective,"objective"),a=e.direction??"minimize";a!=="minimize"&&a!=="maximize"&&r("direction must be minimize or maximize");let i=e.tieBreak??"candidate-id";i!=="candidate-id"&&r("tieBreak must be candidate-id");let o=e.concurrencyCap??2,s=e.maxCandidates??4;for(let[c,d]of Object.entries({concurrencyCap:o,maxCandidates:s}))(typeof d!="number"||!Number.isSafeInteger(d)||d<1)&&r(`${c} must be a positive safe integer`);return o>s&&r("concurrencyCap cannot exceed maxCandidates"),{objective:n,direction:a,tieBreak:i,concurrencyCap:o,maxCandidates:s,candidateBudget:re(e.candidateBudget??{turns:10},"candidateBudget"),totalBudget:re(e.totalBudget??{turns:40},"totalBudget")}}catch(t){chunkOSHBJIYD_cjs.b("config-invalid",t instanceof Error?t.message:"invalid experimentation config","provide objective and positive finite limits");}}function S(e){let t=g(e);return (e.methodology!=="experimentation"||!t)&&r("freeze an experimentation workflow first"),t}function de(e,t,n){chunkZ43GUETW_cjs.e(e,t)?.capabilities.includes(n)||chunkOSHBJIYD_cjs.b("missing-capability",`${t} needs ${n}`,"use a role with the required capability");}function ce(e,t,n){return e.events.reduce((a,i)=>{if(i.type!=="item.completed"||!C(i.payload))return a;let o=i.payload;return typeof o.id!="string"||o.role!==i.by||t!==void 0&&o.id!==t||n!==void 0&&o.role!==n||typeof o.tokens!="number"||!Number.isFinite(o.tokens)||o.tokens<0||typeof o.durationMs!="number"||!Number.isFinite(o.durationMs)||o.durationMs<0||t===void 0&&Object.values(g(e)?.candidates??{}).some(s=>s.item===o.id)?a:{tokens:a.tokens+o.tokens,turns:a.turns+1,wallclockMs:a.wallclockMs+o.durationMs}},{tokens:0,turns:0,wallclockMs:0})}function V(e,t){return {tokens:Math.max(e.tokens,t.tokens),turns:Math.max(e.turns,t.turns),wallclockMs:Math.max(e.wallclockMs,t.wallclockMs)}}function E(e,t){return V(t.spent,ce(e,t.item,t.author))}function G(e,t){let n=g(e);if(!n)return e;let a=j(e),i=["stopped","integrated"].includes(n.status);return {...e,iterations:e.iterations.map(o=>o.id==="experiment"?{...o,budget:{...b(e.config).totalBudget},spent:a,...i?{endedAt:o.endedAt??chunkZ43GUETW_cjs.a(t),outcome:o.outcome??(n.status==="integrated"?"completed":"cancelled")}:{}}:o)}}function j(e,t=S(e)){let n=V(t.overhead,ce(e));return Object.values(t.candidates).reduce((a,i)=>{let o=E(e,i);return {tokens:a.tokens+o.tokens,turns:a.turns+o.turns,wallclockMs:a.wallclockMs+o.wallclockMs}},n)}function L(e){return Object.values(g(e)?.candidates??{}).filter(t=>t.status==="running"||e.items[t.item]?.status==="in_progress").length}function U(e){return Object.values(g(e)?.candidates??{}).reduce((t,n)=>{let a=e.items[n.item];return t+(a?.status==="in_progress"?chunkZ43GUETW_cjs.M(e,a.weight,1):0)},0)}function be(e){let t=b(e.config).totalBudget.tokens;if(t!==void 0)return Math.max(0,t-j(e).tokens-U(e))}function Q(e,t){let n=e.items[t.item];return !!n&&(!n.role||n.role===t.author)&&!!chunkZ43GUETW_cjs.e(e,t.author)?.capabilities.includes("deliver")}function X(e,t){let n=b(e.config),a=E(e,t);return k.some(i=>n.candidateBudget[i]!==void 0&&a[i]>=n.candidateBudget[i])}function I(e){if(!g(e))return false;let t=b(e.config),n=j(e);return k.some(a=>t.totalBudget[a]!==void 0&&n[a]>=t.totalBudget[a])}function W(e,t){let n=m(t.candidate,"candidate");return Object.hasOwn(e.candidates,n)||r(`unknown candidate ${n}`),e.candidates[n]}function se(e){let t=e.selected;return (t===void 0||!Object.hasOwn(e.candidates,t))&&chunkOSHBJIYD_cjs.b("invalid-input",`the experiment's selected candidate ${JSON.stringify(t)} is not one of its candidates`,"restore .workflow/state.json from git, or run compare again"),e.candidates[t]}function q(e,t){return typeof e[t]!="boolean"&&r(`${t} must be boolean`),e[t]}function J(e){C(e.spent)||r("spent must contain nonnegative tokens, turns and wallclockMs");let t={};for(let n of k){let a=e.spent[n];(typeof a!="number"||!Number.isSafeInteger(a)||a<0)&&r(`spent.${n} must be a nonnegative safe integer`),t[n]=a;}return t}function $(e,t){return {...e,candidates:{...e.candidates,[t.id]:t}}}function P(e,t){let n=J(t);return {...e,overhead:{tokens:e.overhead.tokens+n.tokens,turns:e.overhead.turns+n.turns,wallclockMs:e.overhead.wallclockMs+n.wallclockMs}}}function D(e,t,n){return chunkZ43GUETW_cjs.u(e,t.item,{stage:"done",status:"dropped"},n.by,n.now)}function A(e){e.status!=="running"&&r("experiment is not running");}function N(e){return ["validated","failed","timed-out","cancelled"].includes(e.status)}function K(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return true;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e)||!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype)return false;t.add(e);let n=Array.isArray(e)?e.every(a=>K(a,t)):Object.values(e).every(a=>a===void 0||K(a,t));return t.delete(e),n}function w(e,t,n){return (a,i)=>((!C(i)||!K(i))&&r("ceremony input must be JSON-safe"),m(i.by,"by"),i.now!==void 0&&(typeof i.now!="string"||!Number.isFinite(Date.parse(i.now)))&&r("now must be a valid timestamp"),de(a,i.by,t),chunkZ43GUETW_cjs.U(a,le(),{type:`ceremony.${e}`,by:i.by,payload:i},o=>chunkZ43GUETW_cjs.c(G(n(o,i),i.now),`experimentation.${e}`,i.by,structuredClone(i),chunkZ43GUETW_cjs.a(i.now))))}function ue(){return {freeze:w("frozen","facilitate",(e,t)=>{(e.methodology!=="experimentation"||g(e))&&r("freeze may run only once in experimentation");let n=b(e.config),a=v(t.baseSha,"baseSha"),i=m(t.harness,"harness");(!Array.isArray(t.candidates)||t.candidates.length<1||t.candidates.length>n.maxCandidates)&&r("candidates must be a nonempty array within maxCandidates");let o={},s=new Set;for(let c of t.candidates){C(c)||r("candidate must be an object");let d=m(c.id,"candidate.id");chunkOSHBJIYD_cjs.c(d,"candidate id"),Object.hasOwn(o,d)&&r("candidate IDs must be unique safe identifiers");let l=m(c.item,"candidate.item"),f=m(c.author,"candidate.author");de(e,f,"deliver");let u=chunkZ43GUETW_cjs.r(e,l);u.role&&u.role!==f&&r("candidate item role must match frozen author"),(s.has(l)||u.stage!=="candidate"||u.status!=="todo"||u.acceptance.length===0)&&r("candidate needs a distinct todo candidate item with acceptance criteria"),s.add(l),o[d]={id:d,item:l,author:f,status:"pending",spent:{tokens:0,turns:0,wallclockMs:0}};}return y({...e,iterations:[...e.iterations,{id:"experiment",goal:n.objective,budget:{...n.totalBudget},spent:{tokens:0,turns:0,wallclockMs:0},startedAt:chunkZ43GUETW_cjs.a(t.now),committed:[...s],carryover:[]}]},{status:"running",baseSha:a,harness:i,candidates:o,released:[],overhead:{tokens:0,turns:0,wallclockMs:0}})}),provision:w("provisioned","manage-flow",(e,t)=>{let n=S(e);A(n),I(e)&&r("total experiment budget exhausted");let a=W(n,t);a.status!=="pending"&&r("candidate already provisioned");let i=m(t.workspace,"workspace");return (chunkBHAEPYRJ_cjs.b({baseSha:n.baseSha},{baseSha:v(t.baseSha,"baseSha")}).length||t.isolated!==true)&&r("provision must attest isolated workspace at the exact frozen base SHA"),Object.values(n.candidates).some(o=>o.workspace===i)&&r("candidate workspaces must be distinct"),n=$(n,{...a,workspace:i,status:"ready"}),y(e,n)}),start:w("started","deliver",(e,t)=>{let n=S(e);A(n);let a=W(n,t);(a.status!=="ready"||a.author!==t.by)&&r("only the candidate author may start a ready candidate"),I(e)&&r("total experiment budget exhausted");let i=b(e.config),o=Object.values(n.candidates).filter(p=>p.status==="running"||e.items[p.item]?.status==="in_progress").length;o>=i.concurrencyCap&&r("candidate concurrency cap reached"),Q(e,a)||r("candidate author assignment or delivery capability changed");let s=j(e);i.totalBudget.turns!==void 0&&s.turns+o>=i.totalBudget.turns&&r("total experiment budget reserved by running candidates");let c=chunkZ43GUETW_cjs.e(e,a.author),d=c.resourceClass??c.id,l=chunkZ43GUETW_cjs.P(e)[d],f=Object.values(e.items).filter(p=>p.status==="in_progress"&&p.role&&(chunkZ43GUETW_cjs.e(e,p.role)?.resourceClass??p.role)===d).length;l!==void 0&&f>=l&&r("role resource capacity reached");let u=chunkZ43GUETW_cjs.r(e,a.item),x=be(e);x!==void 0&&chunkZ43GUETW_cjs.M(e,u.weight,1)>x&&r("total experiment token budget reserved or insufficient"),u.status!=="todo"&&r("candidate item is already dispatched"),chunkZ43GUETW_cjs.C(e,u,[{kind:"dependencies-done"},{kind:"no-open-blockers"},{kind:"acceptance-written"},...e.stages.find(p=>p.id==="building").entryPolicy],"start candidate execution"),X(e,a)&&r("candidate budget exhausted");let h=chunkZ43GUETW_cjs.u(e,a.item,{stage:"building",status:"in_progress"},t.by,t.now);return h=chunkZ43GUETW_cjs.q(h,a.item,p=>({...p,role:t.by})),y(h,$(n,{...a,status:"running"}))}),submit:w("submitted","deliver",(e,t)=>{let n=S(e);A(n);let a=W(n,t),i=chunkZ43GUETW_cjs.r(e,a.item);(a.status!=="running"&&!(a.status==="ready"&&i.status==="in_progress")||a.author!==t.by||i.role!==t.by)&&r("only the running candidate author may submit once");let o=v(t.sha);(chunkBHAEPYRJ_cjs.b({workspace:a.workspace,harness:n.harness},t).length||chunkBHAEPYRJ_cjs.b({baseSha:n.baseSha},{baseSha:v(t.baseSha,"baseSha")}).length)&&r("submission provenance must match frozen base SHA, harness and owned workspace"),(typeof t.score!="number"||!Number.isFinite(t.score))&&r("score must be finite");let s=J(t),c=m(t.command,"command"),d=m(t.log,"log"),l=b(e.config),f=E(e,{...a,spent:s}),u=k.some(p=>l.candidateBudget[p]!==void 0&&f[p]>l.candidateBudget[p]),x={...a,status:u?"timed-out":"submitted",sha:o,score:t.score,spent:f,command:c,log:d};u&&(x.reason="candidate budget exceeded");let h=y(e,$(n,x));return h=chunkZ43GUETW_cjs.y(h,a.item,{kind:"candidate-sha",ref:o,by:t.by},t.now),h=chunkZ43GUETW_cjs.y(h,a.item,{kind:"benchmark-result",ref:JSON.stringify({score:t.score,harness:n.harness,sha:o}),by:t.by},t.now),u?D(h,x,t):h}),terminate:w("terminated","manage-flow",(e,t)=>{let n=S(e);A(n);let a=W(n,t);N(a)&&r("candidate is already terminal"),["failed","timed-out","cancelled"].includes(t.status)||r("status must be failed, timed-out or cancelled");let i=m(t.reason,"reason"),o=J(t),s=m(t.log,"log");return D(y({...e},$(n,{...a,status:t.status,reason:i,spent:V(E(e,a),E(e,{...a,spent:o})),terminalLog:s})),a,t)}),validate:w("validated","verify",(e,t)=>{let n=S(e);A(n);let a=W(n,t);a.status!=="submitted"&&r("validate an unvalidated submitted candidate"),chunkBHAEPYRJ_cjs.a(t.by,[a.author]).length&&r("candidate author cannot independently validate"),!e.events.some(x=>x.type==="experimentation.started"&&C(x.payload)&&x.payload.candidate===a.id)&&chunkZ43GUETW_cjs.r(e,a.item).status==="in_progress"&&chunkOSHBJIYD_cjs.b("invalid-input",`candidate "${a.id}" item "${a.item}" is still in progress under the planner`,`complete item "${a.item}" with the builder's handoff (candidate-sha ${a.sha}) and accounting before validating`,{items:[a.item]});let o=v(t.sha),s=m(t.harness,"harness");chunkBHAEPYRJ_cjs.b({sha:a.sha,harness:n.harness},{sha:o,harness:s}).length&&r("validation must match exact submitted SHA and frozen harness");let c=q(t,"passed"),d=q(t,"reproducible"),l=m(t.evidence,"evidence"),f={sha:o,harness:s,by:t.by,passed:c,reproducible:d,evidence:l},u=y({...e},$(P(n,t),{...a,status:c&&d?"validated":"failed",validation:f}));return u=chunkZ43GUETW_cjs.y(u,a.item,{kind:"validation",ref:l,by:t.by},t.now),u=chunkZ43GUETW_cjs.u(u,a.item,{stage:"done",status:c&&d?"done":"dropped"},t.by,t.now),u}),compare:w("compared","facilitate",(e,t)=>{let n=S(e);A(n);let a=Object.values(n.candidates);a.every(N)||r("comparison requires all candidates terminal and submissions independently validated");let i=b(e.config),o=j(e,n);if(k.some(d=>i.totalBudget[d]!==void 0&&o[d]>i.totalBudget[d]))return y(e,{...n,status:"stopped",reason:"total budget exceeded"});let s=a.filter(d=>{let l=E(e,d);return d.status==="validated"&&d.validation?.passed&&d.validation.reproducible&&!chunkBHAEPYRJ_cjs.b({sha:d.sha,harness:n.harness},d.validation).length&&!k.some(f=>i.candidateBudget[f]!==void 0&&l[f]>i.candidateBudget[f])});s.sort((d,l)=>(d.score-l.score)*(i.direction==="minimize"?1:-1)||(d.id<l.id?-1:d.id>l.id?1:0));let c=s[0];return y({...e},c?{...n,status:"selected",selected:c.id}:{...n,status:"stopped",reason:"no eligible candidate"})}),integrate:w("integration-recorded","control-change",(e,t)=>{let n=S(e);(!["selected","integrating"].includes(n.status)||!n.selected)&&r("compare and select before integration"),I(e)&&r("total budget exhausted before integration");let a=se(n),i=v(t.selectedSha,"selectedSha");(i!==a.sha||a.validation?.sha!==i)&&r("integration must promote the exact selected and validated SHA");let o=v(t.targetSha,"targetSha"),s=v(t.integrationSha,"integrationSha");return n.integration?.sha===s&&n.integration.targetSha===o&&r("integration already recorded"),y(e,{...P(n,t),status:"integrating",integration:{selectedSha:i,targetSha:o,sha:s,by:t.by}})}),"validate-integration":w("integration-validated","verify",(e,t)=>{let n=S(e);(n.status!=="integrating"||!n.integration||!n.selected)&&r("record integration before fresh validation");let a=n.integration,i=se(n);chunkBHAEPYRJ_cjs.a(t.by,[a.by,i.author]).length&&r("integration validation must be independent of candidate author and integrator");let o=v(t.sha),s=v(t.targetSha,"targetSha"),c=m(t.harness,"harness");chunkBHAEPYRJ_cjs.b({sha:a.sha,targetSha:a.targetSha,harness:n.harness},{sha:o,targetSha:s,harness:c}).length&&r("fresh validation must match integration SHA, current target SHA and harness");let d=q(t,"passed"),l=m(t.evidence,"evidence"),f=P(n,t),u=b(e.config),x=j(e,f),h=k.some(p=>u.totalBudget[p]!==void 0&&x[p]>u.totalBudget[p]);return y(e,{...f,status:d&&!h?"integrated":"stopped",...d&&!h?{}:{reason:h?"total budget exceeded":"integration validation failed"},integration:{...a,validation:{by:t.by,sha:o,harness:c,evidence:l,passed:d}}})}),stop:w("stopped","manage-flow",(e,t)=>{let n=S(e);(n.status==="stopped"||n.status==="integrated")&&r("experiment already closed");let a=m(t.reason,"reason");Object.values(n.candidates).some(s=>s.status==="running"||s.status==="submitted"||e.items[s.item]?.status==="in_progress")&&r("terminate active attempts with final usage and log before stopping");let i=Object.fromEntries(Object.values(n.candidates).map(s=>[s.id,N(s)?s:{...s,status:"cancelled",reason:a}])),o=e;for(let s of Object.values(n.candidates))N(s)||(o=D(o,s,t));return y(o,{...P(n,t),status:"stopped",reason:a,candidates:i})}),cleanup:w("cleanup-recorded","manage-flow",(e,t)=>{let n=S(e);return n.status!=="stopped"&&n.status!=="integrated"&&r("cleanup requires a closed experiment"),(!Array.isArray(t.workspaces)||t.workspaces.length===0||t.workspaces.some(a=>typeof a!="string"||!Object.values(n.candidates).some(i=>i.workspace===a)||n.released.includes(a))||new Set(t.workspaces).size!==t.workspaces.length)&&r("workspaces must list distinct owned unreleased identities"),y(e,{...n,released:[...n.released,...t.workspaces]})})}}function pe(e){let t=g(e),n=Object.values(t?.candidates??{});return {candidates:n.length,validated:n.filter(a=>a.status==="validated").length,failed:n.filter(a=>a.status==="failed").length,timedOut:n.filter(a=>a.status==="timed-out").length,cancelled:n.filter(a=>a.status==="cancelled").length,integrated:t?.status==="integrated"?1:0,spent:t?{...j(e)}:{tokens:0,turns:0,wallclockMs:0},candidateTokens:Object.fromEntries(n.map(a=>[a.id,E(e,a).tokens]))}}function me(e){let t=g(e);return {status:t?.status??"unfrozen",baseSha:t?.baseSha??null,harness:t?.harness??null,selected:t?.selected??null,reason:t?.reason??null,integration:t?.integration?structuredClone(t.integration):null,candidates:structuredClone(t?.candidates??{}),cleanup:Object.values(t?.candidates??{}).flatMap(n=>n.workspace&&!t?.released.includes(n.workspace)?[n.workspace]:[]),hostResponsibilities:["provision isolated workspaces at baseSha","execute candidates and the frozen harness","integrate selected SHA at the current target","execute fresh integration validation","release owned workspace identities and record cleanup"]}}function fe(){return [{id:"coordinator",name:"Experiment coordinator",modelTier:"large",capabilities:["facilitate","order-backlog","manage-flow"],canApprove:[],inputs:["objective","budgets"],outputs:["comparison"],do_not:["Change the frozen baseline or harness"]},{id:"builder",name:"Candidate builder",modelTier:"large",capabilities:["deliver"],canApprove:[],inputs:["frozen harness","isolated workspace"],outputs:["candidate-sha","benchmark-result"],do_not:["Validate your own candidate","Change another candidate workspace"]},{id:"validator",name:"Independent validator",modelTier:"large",capabilities:["verify","review","approve-gate"],canApprove:["experiment-validation"],inputs:["exact candidate SHA","frozen harness"],outputs:["validation"],do_not:["Approve your own work"]},{id:"integrator",name:"Selected candidate integrator",modelTier:"large",capabilities:["deliver","control-change"],canApprove:[],inputs:["selected SHA","current target SHA"],outputs:["integration SHA"],do_not:["Declare integration validated"]}]}function ge(){return [{id:"experimentation-lifecycle",severity:"error",check(e,t){let n=[],a=g(e),i=t.payload;if(t.type==="item.complete"){["done","needs-review"].includes(i?.handoff?.verdict??"done")||n.push("unsupported completion verdict: terminate this attempt with final usage and log, then freeze a new experiment for retries");let o=a&&Object.values(a.candidates).find(s=>s.item===i?.item);(!o||!["submitted","validated"].includes(o.status))&&n.push("submit the candidate SHA and benchmark before completing work"),o?.status==="submitted"&&!i?.handoff?.produced?.some(s=>s.kind==="candidate-sha"&&s.ref===o.sha)&&n.push("handoff must retain the exact submitted candidate SHA");}return n.map(o=>({rule:"experimentation-lifecycle",severity:"error",message:o,fix:"follow the frozen experimentation lifecycle"}))}}]}function he(){return [{id:"candidate",name:"Frozen candidate",entryPolicy:[],exitPolicy:[{kind:"acceptance-written"},{kind:"no-open-blockers"},{kind:"dependencies-done"}]},{id:"building",name:"Isolated candidate execution",entryPolicy:[{kind:"acceptance-written"},{kind:"no-open-blockers"},{kind:"dependencies-done"}],exitPolicy:[{kind:"evidence",evidenceKind:"candidate-sha"},{kind:"evidence",evidenceKind:"benchmark-result"}]},{id:"validation",name:"Independent exact-SHA validation",review:true,entryPolicy:[],exitPolicy:[{kind:"evidence",evidenceKind:"validation"}],gate:{id:"experiment-validation",requires:[{capability:"verify"}],evidence:["validation"],onFail:{action:"block"}}},{id:"done",name:"Candidate work complete",entryPolicy:[],exitPolicy:[],deliveryPoint:true}]}function le(){return {name:"experimentation",vocabulary:{backlog:"Candidate pool",item:"Candidate work item",stage:"Experiment stage",iteration:"Experiment run",increment:"Validated integration",ceremony:"Experiment control",gate:"Independent validation"},validateConfig:b,defaultStages:he,defaultRoles:fe,requiredCapabilities:["facilitate","manage-flow","deliver","verify","control-change"],exclusiveCapabilities:[],plannerOptions(e){let t=b(e.config);return {schedulerMode:"throughput",dispatchStage:"building",concurrencyCap:Math.max(1,t.concurrencyCap-L(e)),fallbackTokensPerWeight:1,reservedTokens:U(e),roleFor(n){return Object.values(g(e)?.candidates??{}).find(a=>a.item===n.id)?.author}}},candidates(e){let t=g(e);if(!t||t.status!=="running")return [];let n=b(e.config);return I(e)||L(e)>=n.concurrencyCap?[]:Object.values(t.candidates).filter(a=>a.status==="ready"&&Q(e,a)&&e.items[a.item]?.status==="todo"&&!X(e,a)).map(a=>e.items[a.item])},afterComplete(e,t,n){return G(e,n)},invariants(e,t){let n=g(e),a=Object.values(n?.candidates??{}).find(i=>i.item===t.id);return [`Frozen base SHA: ${n?.baseSha??"unfrozen"}; harness: ${n?.harness??"unfrozen"}`,`Candidate: ${a?.id??"unregistered"}; isolated workspace: ${a?.workspace??"not provisioned"}`,`Objective and budget: ${JSON.stringify(e.config)}`,"Submit an exact commit SHA and harness benchmark before completion; independent validation is mandatory.","Host owns process execution, Git integration and workspace cleanup."]},ceremonies:ue(),rules:ge(),metrics:pe,report:me,humanDefaults:{gates:"none"},lockedConfigKeys:["objective","direction","tieBreak","concurrencyCap","maxCandidates","candidateBudget","totalBudget"]}}exports.a=b;exports.b=ue;exports.c=pe;exports.d=me;exports.e=fe;exports.f=ge;exports.g=he;exports.h=le;//# sourceMappingURL=chunk-SFYUJQYW.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-SFYUJQYW.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/methodologies/experimentation/record.ts","../src/methodologies/experimentation/config.ts","../src/methodologies/experimentation/ceremonies.ts","../src/methodologies/experimentation/metrics.ts","../src/methodologies/experimentation/roles.ts","../src/methodologies/experimentation/rules.ts","../src/methodologies/experimentation/stages.ts","../src/methodologies/experimentation/index.ts"],"names":["readExperimentation","s","readExt","writeExperimentation","x","writeExt","dimensions","object","value","invalid","message","fail","text","label","sha","budget","k","out","n","validateExperimentationConfig","raw","known","objective","direction","tieBreak","concurrencyCap","maxCandidates","key","error","experimentOf","e","authorize","by","capability","roleOf","completedUsage","item","author","sum","event","p","c","maximum","a","b","effectiveSpent","synchronizeBudget","now","usage","totalSpent","closed","it","nowOf","overhead","v","runningCount","reservedTokens","estimateTokens","unreservedTokens","limit","assignedAuthor","work","candidateExhausted","cfg","used","exhausted","candidate","i","id","selectedCandidate","bool","spent","put","charge","cost","closeItem","moveItem","active","done","jsonSafe","seen","valid","reduce","name","fn","applyAction","experimentation","current","appendEvent","experimentationCeremonies","baseSha","harness","candidates","items","assertId","getItem","workspace","frozenChanges","running","role","cls","cap","resourceCapsFor","occupied","w","tokenCapacity","assertPolicies","st","next","patchItem","commit","command","log","measured","over","updated","addEvidence","reason","independenceConflicts","passed","reproducible","evidence","validation","_i","all","eligible","selected","selectedSha","targetSha","integrationSha","integration","charged","experimentationMetrics","experimentationReport","experimentationRoles","experimentationRules","state","action","errors","payload","experimentationStages","_item"],"mappings":"yNAKO,IAAMA,CAAAA,CAAuBC,CAAAA,EAClCC,mBAAAA,CAAQD,CAAAA,CAAG,iBAAiB,CAAA,CAGjBE,CAAAA,CAAuB,CAACF,CAAAA,CAAkBG,CAAAA,GACrDC,mBAAAA,CAASJ,CAAAA,CAAG,iBAAA,CAAmBG,CAAC,CAAA,CCC3B,IAAME,CAAAA,CAAa,CAAC,QAAA,CAAU,OAAA,CAAS,aAAa,CAAA,CACpD,SAASC,CAAAA,CAAOC,CAAAA,CAAkD,CACvE,OAAO,OAAOA,GAAU,QAAA,EAAYA,CAAAA,GAAU,IAAA,EAAQ,CAAC,KAAA,CAAM,OAAA,CAAQA,CAAK,CAC5E,CACO,SAASC,CAAAA,CAAQC,CAAAA,CAAwB,CAC9C,OAAOC,mBAAAA,CAAK,eAAA,CAAiBD,CAAAA,CAAS,6CAA6C,CACrF,CACO,SAASE,CAAAA,CAAKJ,CAAAA,CAAgBK,CAAAA,CAAuB,CAC1D,OAAA,CAAI,OAAOL,CAAAA,EAAU,QAAA,EAAY,CAACA,EAAM,IAAA,EAAK,GAAGC,CAAAA,CAAQ,CAAA,EAAGI,CAAK,CAAA,2BAAA,CAA6B,CAAA,CACtFL,CACT,CACO,SAASM,CAAAA,CAAIN,CAAAA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cxC,CAAAA,CAAG4I,CAAAA,CAAO9F,CAAAA,CAAK,CAC3B,OAAOD,CAAAA,CAAkB7C,CAAAA,CAAG8C,CAAG,CACjC,CAAA,CACA,UAAA,CAAW9C,CAAAA,CAAGmC,CAAAA,CAAM,CAClB,IAAMN,CAAAA,CAAI9B,CAAAA,CAAoBC,CAAC,CAAA,CACzBwC,CAAAA,CAAI,MAAA,CAAO,MAAA,CAAOX,CAAAA,EAAG,UAAA,EAAc,EAAE,CAAA,CAAE,IAAA,CAAMoC,CAAAA,EAAcA,CAAAA,CAAU,OAAS9B,CAAAA,CAAK,EAAE,CAAA,CAC3F,OAAO,CACL,CAAA,iBAAA,EAAoBN,CAAAA,EAAG,OAAA,EAAW,UAAU,CAAA,WAAA,EAAcA,CAAAA,EAAG,OAAA,EAAW,UAAU,CAAA,CAAA,CAClF,CAAA,WAAA,EAAcW,CAAAA,EAAG,EAAA,EAAM,cAAc,CAAA,sBAAA,EAAyBA,CAAAA,EAAG,SAAA,EAAa,iBAAiB,CAAA,CAAA,CAC/F,CAAA,sBAAA,EAAyB,IAAA,CAAK,SAAA,CAAUxC,CAAAA,CAAE,MAAM,CAAC,CAAA,CAAA,CACjD,2GACA,qEACF,CACF,CAAA,CACA,UAAA,CAAYwF,EAAAA,EAA0B,CACtC,KAAA,CAAO8C,EAAAA,EAAqB,CAC5B,OAAA,CAASH,EAAAA,CACT,MAAA,CAAQC,EAAAA,CACR,aAAA,CAAe,CAAE,KAAA,CAAO,MAAO,CAAA,CAC/B,gBAAA,CAAkB,CAChB,WAAA,CACA,WAAA,CACA,UAAA,CACA,gBAAA,CACA,eAAA,CACA,iBAAA,CACA,aACF,CACF,CACF","file":"chunk-SFYUJQYW.cjs","sourcesContent":["import { readExt, writeExt } from \"../../interface/ext.ts\";\nimport type { WorkflowState } from \"../../core/types.ts\";\nimport type { ExperimentationState } from \"./state.ts\";\n\n/** The experimentation record: `ext.experimentation`, or the legacy field of a state written before 1.2. */\nexport const readExperimentation = (s: WorkflowState): ExperimentationState | undefined =>\n readExt(s, \"experimentation\");\n\n/** Stores the experimentation record in `ext.experimentation` and its deprecated legacy mirror (spec 26). */\nexport const writeExperimentation = (s: WorkflowState, x: ExperimentationState): WorkflowState =>\n writeExt(s, \"experimentation\", x);\n","import { fail } from \"../../core/errors.ts\";\nimport type { Budget } from \"../../core/types.ts\";\nexport interface ExperimentationConfig {\n objective: string;\n direction: \"minimize\" | \"maximize\";\n tieBreak: \"candidate-id\";\n concurrencyCap: number;\n maxCandidates: number;\n candidateBudget: Budget;\n totalBudget: Budget;\n}\nexport const dimensions = [\"tokens\", \"turns\", \"wallclockMs\"] as const;\nexport function object(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nexport function invalid(message: string): never {\n return fail(\"invalid-input\", message, \"supply valid experimentation ceremony input\");\n}\nexport function text(value: unknown, label: string): string {\n if (typeof value !== \"string\" || !value.trim()) invalid(`${label} must be a non-empty string`);\n return value;\n}\nexport function sha(value: unknown, label = \"sha\"): string {\n const s = text(value, label);\n if (!/^[a-f0-9]{40}$|^[a-f0-9]{64}$/.test(s))\n invalid(`${label} must be a full lowercase commit SHA`);\n return s;\n}\nfunction budget(value: unknown, label: string): Budget {\n if (\n !object(value) ||\n !dimensions.some((k) => value[k] !== undefined) ||\n Object.keys(value).some((k) => !dimensions.includes(k as (typeof dimensions)[number]))\n )\n invalid(`${label} needs tokens, turns or wallclockMs limits`);\n const out: Budget = {};\n for (const k of dimensions) {\n const n = value[k];\n if (n !== undefined) {\n if (typeof n !== \"number\" || !Number.isSafeInteger(n) || n <= 0)\n invalid(`${label}.${k} must be a positive safe integer`);\n out[k] = n;\n }\n }\n return out;\n}\nexport function validateExperimentationConfig(raw: unknown): ExperimentationConfig {\n try {\n if (!object(raw)) invalid(\"experimentation config must be an object\");\n const known = [\n \"objective\",\n \"direction\",\n \"tieBreak\",\n \"concurrencyCap\",\n \"maxCandidates\",\n \"candidateBudget\",\n \"totalBudget\",\n ];\n if (Object.keys(raw).some((k) => !known.includes(k)))\n invalid(\"unknown experimentation config key\");\n const objective = text(raw.objective, \"objective\");\n const direction = raw.direction ?? \"minimize\";\n if (direction !== \"minimize\" && direction !== \"maximize\")\n invalid(\"direction must be minimize or maximize\");\n const tieBreak = raw.tieBreak ?? \"candidate-id\";\n if (tieBreak !== \"candidate-id\") invalid(\"tieBreak must be candidate-id\");\n const concurrencyCap = raw.concurrencyCap ?? 2;\n const maxCandidates = raw.maxCandidates ?? 4;\n for (const [key, n] of Object.entries({ concurrencyCap, maxCandidates }))\n if (typeof n !== \"number\" || !Number.isSafeInteger(n) || n < 1)\n invalid(`${key} must be a positive safe integer`);\n if ((concurrencyCap as number) > (maxCandidates as number))\n invalid(\"concurrencyCap cannot exceed maxCandidates\");\n return {\n objective,\n direction,\n tieBreak,\n concurrencyCap: concurrencyCap as number,\n maxCandidates: maxCandidates as number,\n candidateBudget: budget(raw.candidateBudget ?? { turns: 10 }, \"candidateBudget\"),\n totalBudget: budget(raw.totalBudget ?? { turns: 40 }, \"totalBudget\"),\n };\n } catch (error) {\n fail(\n \"config-invalid\",\n error instanceof Error ? error.message : \"invalid experimentation config\",\n \"provide objective and positive finite limits\",\n );\n }\n}\n","import { readExperimentation, writeExperimentation } from \"./record.ts\";\nimport { independenceConflicts } from \"../../common/independence.ts\";\nimport { frozenChanges } from \"../../common/frozen.ts\";\nimport { assertId, fail } from \"../../core/errors.ts\";\nimport { estimateTokens } from \"../../core/budget.ts\";\nimport { resourceCapsFor } from \"../../core/planner.ts\";\nimport { roleOf } from \"../../core/roles/lookup.ts\";\nimport { addEvidence } from \"../../core/items/evidence.ts\";\nimport { getItem, patchItem } from \"../../core/items/record.ts\";\nimport { moveItem } from \"../../core/items/move.ts\";\nimport { appendEvent, nowOf } from \"../../core/state.ts\";\nimport { applyAction } from \"../../core/methodology.ts\";\nimport { assertPolicies } from \"../../core/policies.ts\";\nimport { experimentation } from \"./index.ts\";\nimport type {\n Capability,\n Ceremony,\n CeremonyInput,\n Spent,\n WorkflowState,\n} from \"../../core/types.ts\";\nimport { dimensions, invalid, object, sha, text, validateExperimentationConfig } from \"./config.ts\";\nimport type { ExperimentCandidate, ExperimentationState } from \"./state.ts\";\nexport function experimentOf(s: WorkflowState): ExperimentationState {\n const e = readExperimentation(s);\n if (s.methodology !== \"experimentation\" || !e)\n invalid(\"freeze an experimentation workflow first\");\n return e;\n}\nexport function authorize(s: WorkflowState, by: string, capability: Capability): void {\n if (!roleOf(s, by)?.capabilities.includes(capability))\n fail(\n \"missing-capability\",\n `${by} needs ${capability}`,\n \"use a role with the required capability\",\n );\n}\n/** Completion events bind cost to the actual dispatched item/actor; accounting labels are caller supplied. */\nfunction completedUsage(s: WorkflowState, item?: string, author?: string): Spent {\n return s.events.reduce(\n (sum, event) => {\n if (event.type !== \"item.completed\" || !object(event.payload)) return sum;\n const p = event.payload;\n if (\n typeof p.id !== \"string\" ||\n p.role !== event.by ||\n (item !== undefined && p.id !== item) ||\n (author !== undefined && p.role !== author)\n )\n return sum;\n if (\n typeof p.tokens !== \"number\" ||\n !Number.isFinite(p.tokens) ||\n p.tokens < 0 ||\n typeof p.durationMs !== \"number\" ||\n !Number.isFinite(p.durationMs) ||\n p.durationMs < 0\n )\n return sum;\n if (\n item === undefined &&\n Object.values(readExperimentation(s)?.candidates ?? {}).some((c) => c.item === p.id)\n )\n return sum;\n return {\n tokens: sum.tokens + p.tokens,\n turns: sum.turns + 1,\n wallclockMs: sum.wallclockMs + p.durationMs,\n };\n },\n { tokens: 0, turns: 0, wallclockMs: 0 },\n );\n}\nfunction maximum(a: Spent, b: Spent): Spent {\n return {\n tokens: Math.max(a.tokens, b.tokens),\n turns: Math.max(a.turns, b.turns),\n wallclockMs: Math.max(a.wallclockMs, b.wallclockMs),\n };\n}\nexport function effectiveSpent(s: WorkflowState, c: ExperimentCandidate): Spent {\n return maximum(c.spent, completedUsage(s, c.item, c.author));\n}\nexport function synchronizeBudget(s: WorkflowState, now?: string): WorkflowState {\n const e = readExperimentation(s);\n if (!e) return s;\n const usage = totalSpent(s);\n const closed = [\"stopped\", \"integrated\"].includes(e.status);\n return {\n ...s,\n iterations: s.iterations.map((it) =>\n it.id === \"experiment\"\n ? {\n ...it,\n budget: { ...validateExperimentationConfig(s.config).totalBudget },\n spent: usage,\n ...(closed\n ? {\n endedAt: it.endedAt ?? nowOf(now),\n outcome:\n it.outcome ??\n (e.status === \"integrated\" ? (\"completed\" as const) : (\"cancelled\" as const)),\n }\n : {}),\n }\n : it,\n ),\n };\n}\nexport function totalSpent(s: WorkflowState, e = experimentOf(s)): Spent {\n const overhead = maximum(e.overhead, completedUsage(s));\n return Object.values(e.candidates).reduce((sum, c) => {\n const v = effectiveSpent(s, c);\n return {\n tokens: sum.tokens + v.tokens,\n turns: sum.turns + v.turns,\n wallclockMs: sum.wallclockMs + v.wallclockMs,\n };\n }, overhead);\n}\nexport function runningCount(s: WorkflowState): number {\n return Object.values(readExperimentation(s)?.candidates ?? {}).filter(\n (c) => c.status === \"running\" || s.items[c.item]?.status === \"in_progress\",\n ).length;\n}\n/** Remaining token capacity after reserving estimates for currently dispatched work. */\nexport function reservedTokens(s: WorkflowState): number {\n return Object.values(readExperimentation(s)?.candidates ?? {}).reduce((sum, c) => {\n const item = s.items[c.item];\n return sum + (item?.status === \"in_progress\" ? estimateTokens(s, item.weight, 1) : 0);\n }, 0);\n}\nexport function unreservedTokens(s: WorkflowState): number | undefined {\n const limit = validateExperimentationConfig(s.config).totalBudget.tokens;\n if (limit === undefined) return undefined;\n return Math.max(0, limit - totalSpent(s).tokens - reservedTokens(s));\n}\nexport function assignedAuthor(s: WorkflowState, c: ExperimentCandidate): boolean {\n const work = s.items[c.item];\n return (\n !!work &&\n (!work.role || work.role === c.author) &&\n !!roleOf(s, c.author)?.capabilities.includes(\"deliver\")\n );\n}\nexport function candidateExhausted(s: WorkflowState, c: ExperimentCandidate): boolean {\n const cfg = validateExperimentationConfig(s.config);\n const used = effectiveSpent(s, c);\n return dimensions.some(\n (k) => cfg.candidateBudget[k] !== undefined && used[k] >= cfg.candidateBudget[k]!,\n );\n}\nexport function exhausted(s: WorkflowState): boolean {\n if (!readExperimentation(s)) return false;\n const cfg = validateExperimentationConfig(s.config);\n const usage = totalSpent(s);\n return dimensions.some(\n (k) => cfg.totalBudget[k] !== undefined && usage[k] >= cfg.totalBudget[k]!,\n );\n}\nfunction candidate(e: ExperimentationState, i: CeremonyInput): ExperimentCandidate {\n const id = text(i.candidate, \"candidate\");\n if (!Object.hasOwn(e.candidates, id)) invalid(`unknown candidate ${id}`);\n return e.candidates[id]!;\n}\n/** The candidate `e.selected` names; a loaded state may name none (own keys only). */\nfunction selectedCandidate(e: ExperimentationState): ExperimentCandidate {\n const id = e.selected;\n if (id === undefined || !Object.hasOwn(e.candidates, id))\n fail(\n \"invalid-input\",\n `the experiment's selected candidate ${JSON.stringify(id)} is not one of its candidates`,\n \"restore .workflow/state.json from git, or run compare again\",\n );\n return e.candidates[id]!;\n}\nfunction bool(i: CeremonyInput, k: string): boolean {\n if (typeof i[k] !== \"boolean\") invalid(`${k} must be boolean`);\n return i[k] as boolean;\n}\nfunction spent(i: CeremonyInput): Spent {\n if (!object(i.spent)) invalid(\"spent must contain nonnegative tokens, turns and wallclockMs\");\n const out = {} as Spent;\n for (const k of dimensions) {\n const n = i.spent[k];\n if (typeof n !== \"number\" || !Number.isSafeInteger(n) || n < 0)\n invalid(`spent.${k} must be a nonnegative safe integer`);\n out[k] = n;\n }\n return out;\n}\nfunction put(e: ExperimentationState, c: ExperimentCandidate): ExperimentationState {\n return { ...e, candidates: { ...e.candidates, [c.id]: c } };\n}\nfunction charge(e: ExperimentationState, i: CeremonyInput): ExperimentationState {\n const cost = spent(i);\n return {\n ...e,\n overhead: {\n tokens: e.overhead.tokens + cost.tokens,\n turns: e.overhead.turns + cost.turns,\n wallclockMs: e.overhead.wallclockMs + cost.wallclockMs,\n },\n };\n}\nfunction closeItem(s: WorkflowState, c: ExperimentCandidate, i: CeremonyInput): WorkflowState {\n return moveItem(s, c.item, { stage: \"done\", status: \"dropped\" }, i.by, i.now);\n}\nfunction active(e: ExperimentationState): void {\n if (e.status !== \"running\") invalid(\"experiment is not running\");\n}\nfunction done(c: ExperimentCandidate): boolean {\n return [\"validated\", \"failed\", \"timed-out\", \"cancelled\"].includes(c.status);\n}\nfunction jsonSafe(value: unknown, seen = new Set<object>()): boolean {\n if (value === null || typeof value === \"string\" || typeof value === \"boolean\") return true;\n if (typeof value === \"number\") return Number.isFinite(value);\n if (typeof value !== \"object\" || seen.has(value)) return false;\n if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype) return false;\n seen.add(value);\n // JSON.stringify drops an undefined property, so it is safe in an object but not in an array.\n const valid = Array.isArray(value)\n ? value.every((v) => jsonSafe(v, seen))\n : Object.values(value).every((v) => v === undefined || jsonSafe(v, seen));\n seen.delete(value);\n return valid;\n}\nfunction reduce(\n name: string,\n capability: Capability,\n fn: (s: WorkflowState, i: CeremonyInput) => WorkflowState,\n): Ceremony {\n return (s, i) => {\n if (!object(i) || !jsonSafe(i)) invalid(\"ceremony input must be JSON-safe\");\n text(i.by, \"by\");\n if (i.now !== undefined && (typeof i.now !== \"string\" || !Number.isFinite(Date.parse(i.now))))\n invalid(\"now must be a valid timestamp\");\n authorize(s, i.by, capability);\n return applyAction(\n s,\n experimentation(),\n { type: `ceremony.${name}`, by: i.by, payload: i },\n (current) =>\n appendEvent(\n synchronizeBudget(fn(current, i), i.now),\n `experimentation.${name}`,\n i.by,\n structuredClone(i),\n nowOf(i.now),\n ),\n );\n };\n}\nexport function experimentationCeremonies(): Record<string, Ceremony> {\n return {\n freeze: reduce(\"frozen\", \"facilitate\", (s, i) => {\n if (s.methodology !== \"experimentation\" || readExperimentation(s))\n invalid(\"freeze may run only once in experimentation\");\n const cfg = validateExperimentationConfig(s.config);\n const baseSha = sha(i.baseSha, \"baseSha\");\n const harness = text(i.harness, \"harness\");\n if (\n !Array.isArray(i.candidates) ||\n i.candidates.length < 1 ||\n i.candidates.length > cfg.maxCandidates\n )\n invalid(\"candidates must be a nonempty array within maxCandidates\");\n const candidates: Record<string, ExperimentCandidate> = {};\n const items = new Set<string>();\n for (const raw of i.candidates) {\n if (!object(raw)) invalid(\"candidate must be an object\");\n const id = text(raw.id, \"candidate.id\");\n assertId(id, \"candidate id\");\n if (Object.hasOwn(candidates, id)) invalid(\"candidate IDs must be unique safe identifiers\");\n const item = text(raw.item, \"candidate.item\");\n const author = text(raw.author, \"candidate.author\");\n authorize(s, author, \"deliver\");\n const work = getItem(s, item);\n if (work.role && work.role !== author)\n invalid(\"candidate item role must match frozen author\");\n if (\n items.has(item) ||\n work.stage !== \"candidate\" ||\n work.status !== \"todo\" ||\n work.acceptance.length === 0\n )\n invalid(\"candidate needs a distinct todo candidate item with acceptance criteria\");\n items.add(item);\n candidates[id] = {\n id,\n item,\n author,\n status: \"pending\",\n spent: { tokens: 0, turns: 0, wallclockMs: 0 },\n };\n }\n return writeExperimentation(\n {\n ...s,\n iterations: [\n ...s.iterations,\n {\n id: \"experiment\",\n goal: cfg.objective,\n budget: { ...cfg.totalBudget },\n spent: { tokens: 0, turns: 0, wallclockMs: 0 },\n startedAt: nowOf(i.now),\n committed: [...items],\n carryover: [],\n },\n ],\n },\n {\n status: \"running\",\n baseSha,\n harness,\n candidates,\n released: [],\n overhead: { tokens: 0, turns: 0, wallclockMs: 0 },\n },\n );\n }),\n provision: reduce(\"provisioned\", \"manage-flow\", (s, i) => {\n let e = experimentOf(s);\n active(e);\n if (exhausted(s)) invalid(\"total experiment budget exhausted\");\n const c = candidate(e, i);\n if (c.status !== \"pending\") invalid(\"candidate already provisioned\");\n const workspace = text(i.workspace, \"workspace\");\n if (\n frozenChanges({ baseSha: e.baseSha }, { baseSha: sha(i.baseSha, \"baseSha\") }).length ||\n i.isolated !== true\n )\n invalid(\"provision must attest isolated workspace at the exact frozen base SHA\");\n if (Object.values(e.candidates).some((x) => x.workspace === workspace))\n invalid(\"candidate workspaces must be distinct\");\n e = put(e, { ...c, workspace, status: \"ready\" });\n return writeExperimentation(s, e);\n }),\n start: reduce(\"started\", \"deliver\", (s, i) => {\n const e = experimentOf(s);\n active(e);\n const c = candidate(e, i);\n if (c.status !== \"ready\" || c.author !== i.by)\n invalid(\"only the candidate author may start a ready candidate\");\n if (exhausted(s)) invalid(\"total experiment budget exhausted\");\n const cfg = validateExperimentationConfig(s.config);\n const running = Object.values(e.candidates).filter(\n (x) => x.status === \"running\" || s.items[x.item]?.status === \"in_progress\",\n ).length;\n if (running >= cfg.concurrencyCap) invalid(\"candidate concurrency cap reached\");\n if (!assignedAuthor(s, c))\n invalid(\"candidate author assignment or delivery capability changed\");\n const usage = totalSpent(s);\n if (cfg.totalBudget.turns !== undefined && usage.turns + running >= cfg.totalBudget.turns)\n invalid(\"total experiment budget reserved by running candidates\");\n const role = roleOf(s, c.author)!;\n const cls = role.resourceClass ?? role.id;\n const cap = resourceCapsFor(s)[cls];\n const occupied = Object.values(s.items).filter(\n (w) =>\n w.status === \"in_progress\" &&\n w.role &&\n (roleOf(s, w.role)?.resourceClass ?? w.role) === cls,\n ).length;\n if (cap !== undefined && occupied >= cap) invalid(\"role resource capacity reached\");\n const work = getItem(s, c.item);\n const tokenCapacity = unreservedTokens(s);\n if (tokenCapacity !== undefined && estimateTokens(s, work.weight, 1) > tokenCapacity)\n invalid(\"total experiment token budget reserved or insufficient\");\n if (work.status !== \"todo\") invalid(\"candidate item is already dispatched\");\n assertPolicies(\n s,\n work,\n [\n { kind: \"dependencies-done\" },\n { kind: \"no-open-blockers\" },\n { kind: \"acceptance-written\" },\n ...s.stages.find((st) => st.id === \"building\")!.entryPolicy,\n ],\n \"start candidate execution\",\n );\n if (candidateExhausted(s, c)) invalid(\"candidate budget exhausted\");\n let next = moveItem(s, c.item, { stage: \"building\", status: \"in_progress\" }, i.by, i.now);\n next = patchItem(next, c.item, (w) => ({ ...w, role: i.by }));\n return writeExperimentation(next, put(e, { ...c, status: \"running\" }));\n }),\n submit: reduce(\"submitted\", \"deliver\", (s, i) => {\n const e = experimentOf(s);\n active(e);\n const c = candidate(e, i);\n const work = getItem(s, c.item);\n if (\n (c.status !== \"running\" && !(c.status === \"ready\" && work.status === \"in_progress\")) ||\n c.author !== i.by ||\n work.role !== i.by\n )\n invalid(\"only the running candidate author may submit once\");\n const commit = sha(i.sha);\n if (\n frozenChanges({ workspace: c.workspace, harness: e.harness }, i).length ||\n frozenChanges({ baseSha: e.baseSha }, { baseSha: sha(i.baseSha, \"baseSha\") }).length\n )\n invalid(\"submission provenance must match frozen base SHA, harness and owned workspace\");\n if (typeof i.score !== \"number\" || !Number.isFinite(i.score)) invalid(\"score must be finite\");\n const usage = spent(i);\n const command = text(i.command, \"command\");\n const log = text(i.log, \"log\");\n const cfg = validateExperimentationConfig(s.config);\n const measured = effectiveSpent(s, { ...c, spent: usage });\n const over = dimensions.some(\n (k) => cfg.candidateBudget[k] !== undefined && measured[k] > cfg.candidateBudget[k]!,\n );\n const updated: ExperimentCandidate = {\n ...c,\n status: over ? \"timed-out\" : \"submitted\",\n sha: commit,\n score: i.score,\n spent: measured,\n command,\n log,\n };\n if (over) updated.reason = \"candidate budget exceeded\";\n let next: WorkflowState = writeExperimentation(s, put(e, updated));\n next = addEvidence(next, c.item, { kind: \"candidate-sha\", ref: commit, by: i.by }, i.now);\n next = addEvidence(\n next,\n c.item,\n {\n kind: \"benchmark-result\",\n ref: JSON.stringify({ score: i.score, harness: e.harness, sha: commit }),\n by: i.by,\n },\n i.now,\n );\n return over ? closeItem(next, updated, i) : next;\n }),\n terminate: reduce(\"terminated\", \"manage-flow\", (s, i) => {\n const e = experimentOf(s);\n active(e);\n const c = candidate(e, i);\n if (done(c)) invalid(\"candidate is already terminal\");\n if (![\"failed\", \"timed-out\", \"cancelled\"].includes(i.status as string))\n invalid(\"status must be failed, timed-out or cancelled\");\n const reason = text(i.reason, \"reason\");\n const usage = spent(i);\n const log = text(i.log, \"log\");\n return closeItem(\n writeExperimentation(\n { ...s },\n put(e, {\n ...c,\n status: i.status as ExperimentCandidate[\"status\"],\n reason,\n spent: maximum(effectiveSpent(s, c), effectiveSpent(s, { ...c, spent: usage })),\n terminalLog: log,\n }),\n ),\n c,\n i,\n );\n }),\n validate: reduce(\"validated\", \"verify\", (s, i) => {\n const e = experimentOf(s);\n active(e);\n const c = candidate(e, i);\n if (c.status !== \"submitted\") invalid(\"validate an unvalidated submitted candidate\");\n if (independenceConflicts(i.by, [c.author]).length)\n invalid(\"candidate author cannot independently validate\");\n // A candidate the planner dispatched is completed by its builder (handoff and accounting)\n // before validation; one the host started by ceremony has no completion to wait for.\n const started = s.events.some(\n (event) =>\n event.type === \"experimentation.started\" &&\n object(event.payload) &&\n event.payload.candidate === c.id,\n );\n if (!started && getItem(s, c.item).status === \"in_progress\")\n fail(\n \"invalid-input\",\n `candidate \"${c.id}\" item \"${c.item}\" is still in progress under the planner`,\n `complete item \"${c.item}\" with the builder's handoff (candidate-sha ${c.sha}) and accounting before validating`,\n { items: [c.item] },\n );\n const commit = sha(i.sha);\n const harness = text(i.harness, \"harness\");\n if (frozenChanges({ sha: c.sha, harness: e.harness }, { sha: commit, harness }).length)\n invalid(\"validation must match exact submitted SHA and frozen harness\");\n const passed = bool(i, \"passed\");\n const reproducible = bool(i, \"reproducible\");\n const evidence = text(i.evidence, \"evidence\");\n const validation = { sha: commit, harness, by: i.by, passed, reproducible, evidence };\n let next: WorkflowState = writeExperimentation(\n { ...s },\n put(charge(e, i), {\n ...c,\n status: passed && reproducible ? \"validated\" : \"failed\",\n validation,\n }),\n );\n next = addEvidence(next, c.item, { kind: \"validation\", ref: evidence, by: i.by }, i.now);\n next = moveItem(\n next,\n c.item,\n { stage: \"done\", status: passed && reproducible ? \"done\" : \"dropped\" },\n i.by,\n i.now,\n );\n return next;\n }),\n compare: reduce(\"compared\", \"facilitate\", (s, _i) => {\n const e = experimentOf(s);\n active(e);\n const all = Object.values(e.candidates);\n if (!all.every(done))\n invalid(\n \"comparison requires all candidates terminal and submissions independently validated\",\n );\n const cfg = validateExperimentationConfig(s.config);\n const usage = totalSpent(s, e);\n if (\n dimensions.some((k) => cfg.totalBudget[k] !== undefined && usage[k] > cfg.totalBudget[k]!)\n )\n return writeExperimentation(s, {\n ...e,\n status: \"stopped\",\n reason: \"total budget exceeded\",\n });\n const eligible = all.filter((c) => {\n const used = effectiveSpent(s, c);\n return (\n c.status === \"validated\" &&\n c.validation?.passed &&\n c.validation.reproducible &&\n !frozenChanges({ sha: c.sha, harness: e.harness }, c.validation).length &&\n !dimensions.some(\n (k) => cfg.candidateBudget[k] !== undefined && used[k] > cfg.candidateBudget[k]!,\n )\n );\n });\n eligible.sort((a, b) => {\n const delta = (a.score! - b.score!) * (cfg.direction === \"minimize\" ? 1 : -1);\n return delta || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0);\n });\n const selected = eligible[0];\n return writeExperimentation(\n { ...s },\n selected\n ? { ...e, status: \"selected\", selected: selected.id }\n : { ...e, status: \"stopped\", reason: \"no eligible candidate\" },\n );\n }),\n integrate: reduce(\"integration-recorded\", \"control-change\", (s, i) => {\n const e = experimentOf(s);\n if (![\"selected\", \"integrating\"].includes(e.status) || !e.selected)\n invalid(\"compare and select before integration\");\n if (exhausted(s)) invalid(\"total budget exhausted before integration\");\n const c = selectedCandidate(e);\n const selectedSha = sha(i.selectedSha, \"selectedSha\");\n if (selectedSha !== c.sha || c.validation?.sha !== selectedSha)\n invalid(\"integration must promote the exact selected and validated SHA\");\n const targetSha = sha(i.targetSha, \"targetSha\");\n const integrationSha = sha(i.integrationSha, \"integrationSha\");\n if (e.integration?.sha === integrationSha && e.integration.targetSha === targetSha)\n invalid(\"integration already recorded\");\n return writeExperimentation(s, {\n ...charge(e, i),\n status: \"integrating\",\n integration: { selectedSha, targetSha, sha: integrationSha, by: i.by },\n });\n }),\n \"validate-integration\": reduce(\"integration-validated\", \"verify\", (s, i) => {\n const e = experimentOf(s);\n if (e.status !== \"integrating\" || !e.integration || !e.selected)\n invalid(\"record integration before fresh validation\");\n const integration = e.integration;\n const c = selectedCandidate(e);\n if (independenceConflicts(i.by, [integration.by, c.author]).length)\n invalid(\"integration validation must be independent of candidate author and integrator\");\n const commit = sha(i.sha);\n const targetSha = sha(i.targetSha, \"targetSha\");\n const harness = text(i.harness, \"harness\");\n if (\n frozenChanges(\n { sha: integration.sha, targetSha: integration.targetSha, harness: e.harness },\n { sha: commit, targetSha, harness },\n ).length\n )\n invalid(\"fresh validation must match integration SHA, current target SHA and harness\");\n const passed = bool(i, \"passed\");\n const evidence = text(i.evidence, \"evidence\");\n const charged = charge(e, i);\n const cfg = validateExperimentationConfig(s.config);\n const usage = totalSpent(s, charged);\n const over = dimensions.some(\n (k) => cfg.totalBudget[k] !== undefined && usage[k] > cfg.totalBudget[k]!,\n );\n return writeExperimentation(s, {\n ...charged,\n status: passed && !over ? \"integrated\" : \"stopped\",\n ...(passed && !over\n ? {}\n : { reason: over ? \"total budget exceeded\" : \"integration validation failed\" }),\n integration: {\n ...integration,\n validation: { by: i.by, sha: commit, harness, evidence, passed },\n },\n });\n }),\n stop: reduce(\"stopped\", \"manage-flow\", (s, i) => {\n const e = experimentOf(s);\n if (e.status === \"stopped\" || e.status === \"integrated\") invalid(\"experiment already closed\");\n const reason = text(i.reason, \"reason\");\n if (\n Object.values(e.candidates).some(\n (c) =>\n c.status === \"running\" ||\n c.status === \"submitted\" ||\n s.items[c.item]?.status === \"in_progress\",\n )\n )\n invalid(\"terminate active attempts with final usage and log before stopping\");\n const candidates = Object.fromEntries(\n Object.values(e.candidates).map((c) => [\n c.id,\n done(c) ? c : { ...c, status: \"cancelled\" as const, reason },\n ]),\n );\n let next = s;\n for (const c of Object.values(e.candidates)) if (!done(c)) next = closeItem(next, c, i);\n return writeExperimentation(next, {\n ...charge(e, i),\n status: \"stopped\",\n reason,\n candidates,\n });\n }),\n cleanup: reduce(\"cleanup-recorded\", \"manage-flow\", (s, i) => {\n const e = experimentOf(s);\n if (e.status !== \"stopped\" && e.status !== \"integrated\")\n invalid(\"cleanup requires a closed experiment\");\n if (\n !Array.isArray(i.workspaces) ||\n i.workspaces.length === 0 ||\n i.workspaces.some(\n (w) =>\n typeof w !== \"string\" ||\n !Object.values(e.candidates).some((c) => c.workspace === w) ||\n e.released.includes(w),\n ) ||\n new Set(i.workspaces).size !== i.workspaces.length\n )\n invalid(\"workspaces must list distinct owned unreleased identities\");\n return writeExperimentation(s, {\n ...e,\n released: [...e.released, ...(i.workspaces as string[])],\n });\n }),\n };\n}\n","import { readExperimentation } from \"./record.ts\";\nimport type { WorkflowState } from \"../../core/types.ts\";\nimport { effectiveSpent, totalSpent } from \"./ceremonies.ts\";\nexport function experimentationMetrics(\n s: WorkflowState,\n): Record<string, number | Record<string, number>> {\n const e = readExperimentation(s);\n const all = Object.values(e?.candidates ?? {});\n return {\n candidates: all.length,\n validated: all.filter((c) => c.status === \"validated\").length,\n failed: all.filter((c) => c.status === \"failed\").length,\n timedOut: all.filter((c) => c.status === \"timed-out\").length,\n cancelled: all.filter((c) => c.status === \"cancelled\").length,\n integrated: e?.status === \"integrated\" ? 1 : 0,\n spent: e ? { ...totalSpent(s) } : { tokens: 0, turns: 0, wallclockMs: 0 },\n candidateTokens: Object.fromEntries(all.map((c) => [c.id, effectiveSpent(s, c).tokens])),\n };\n}\nexport function experimentationReport(s: WorkflowState): Record<string, unknown> {\n const e = readExperimentation(s);\n return {\n status: e?.status ?? \"unfrozen\",\n baseSha: e?.baseSha ?? null,\n harness: e?.harness ?? null,\n selected: e?.selected ?? null,\n reason: e?.reason ?? null,\n integration: e?.integration ? structuredClone(e.integration) : null,\n candidates: structuredClone(e?.candidates ?? {}),\n cleanup: Object.values(e?.candidates ?? {}).flatMap((c) =>\n c.workspace && !e?.released.includes(c.workspace) ? [c.workspace] : [],\n ),\n hostResponsibilities: [\n \"provision isolated workspaces at baseSha\",\n \"execute candidates and the frozen harness\",\n \"integrate selected SHA at the current target\",\n \"execute fresh integration validation\",\n \"release owned workspace identities and record cleanup\",\n ],\n };\n}\n","import type { Role } from \"../../core/types.ts\";\nexport function experimentationRoles(): Role[] {\n return [\n {\n id: \"coordinator\",\n name: \"Experiment coordinator\",\n modelTier: \"large\",\n capabilities: [\"facilitate\", \"order-backlog\", \"manage-flow\"],\n canApprove: [],\n inputs: [\"objective\", \"budgets\"],\n outputs: [\"comparison\"],\n do_not: [\"Change the frozen baseline or harness\"],\n },\n {\n id: \"builder\",\n name: \"Candidate builder\",\n modelTier: \"large\",\n capabilities: [\"deliver\"],\n canApprove: [],\n inputs: [\"frozen harness\", \"isolated workspace\"],\n outputs: [\"candidate-sha\", \"benchmark-result\"],\n do_not: [\"Validate your own candidate\", \"Change another candidate workspace\"],\n },\n {\n id: \"validator\",\n name: \"Independent validator\",\n modelTier: \"large\",\n capabilities: [\"verify\", \"review\", \"approve-gate\"],\n canApprove: [\"experiment-validation\"],\n inputs: [\"exact candidate SHA\", \"frozen harness\"],\n outputs: [\"validation\"],\n do_not: [\"Approve your own work\"],\n },\n {\n id: \"integrator\",\n name: \"Selected candidate integrator\",\n modelTier: \"large\",\n capabilities: [\"deliver\", \"control-change\"],\n canApprove: [],\n inputs: [\"selected SHA\", \"current target SHA\"],\n outputs: [\"integration SHA\"],\n do_not: [\"Declare integration validated\"],\n },\n ];\n}\n","import { readExperimentation } from \"./record.ts\";\nimport type { Rule } from \"../../core/types.ts\";\nexport function experimentationRules(): Rule[] {\n return [\n {\n id: \"experimentation-lifecycle\",\n severity: \"error\",\n check(state, action) {\n const errors: string[] = [];\n const e = readExperimentation(state);\n const payload = action.payload as\n | {\n item?: string;\n handoff?: { verdict?: string; produced?: { kind: string; ref: string }[] };\n }\n | undefined;\n if (action.type === \"item.complete\") {\n if (![\"done\", \"needs-review\"].includes(payload?.handoff?.verdict ?? \"done\"))\n errors.push(\n \"unsupported completion verdict: terminate this attempt with final usage and log, then freeze a new experiment for retries\",\n );\n const c =\n e && Object.values(e.candidates).find((candidate) => candidate.item === payload?.item);\n if (!c || ![\"submitted\", \"validated\"].includes(c.status))\n errors.push(\"submit the candidate SHA and benchmark before completing work\");\n if (\n c?.status === \"submitted\" &&\n !payload?.handoff?.produced?.some((p) => p.kind === \"candidate-sha\" && p.ref === c.sha)\n )\n errors.push(\"handoff must retain the exact submitted candidate SHA\");\n }\n return errors.map((message) => ({\n rule: \"experimentation-lifecycle\",\n severity: \"error\" as const,\n message,\n fix: \"follow the frozen experimentation lifecycle\",\n }));\n },\n },\n ];\n}\n","import type { Stage } from \"../../core/types.ts\";\nexport function experimentationStages(): Stage[] {\n return [\n {\n id: \"candidate\",\n name: \"Frozen candidate\",\n entryPolicy: [],\n exitPolicy: [\n { kind: \"acceptance-written\" },\n { kind: \"no-open-blockers\" },\n { kind: \"dependencies-done\" },\n ],\n },\n {\n id: \"building\",\n name: \"Isolated candidate execution\",\n entryPolicy: [\n { kind: \"acceptance-written\" },\n { kind: \"no-open-blockers\" },\n { kind: \"dependencies-done\" },\n ],\n exitPolicy: [\n { kind: \"evidence\", evidenceKind: \"candidate-sha\" },\n { kind: \"evidence\", evidenceKind: \"benchmark-result\" },\n ],\n },\n {\n id: \"validation\",\n name: \"Independent exact-SHA validation\",\n review: true,\n entryPolicy: [],\n exitPolicy: [{ kind: \"evidence\", evidenceKind: \"validation\" }],\n gate: {\n id: \"experiment-validation\",\n requires: [{ capability: \"verify\" }],\n evidence: [\"validation\"],\n onFail: { action: \"block\" },\n },\n },\n {\n id: \"done\",\n name: \"Candidate work complete\",\n entryPolicy: [],\n exitPolicy: [],\n deliveryPoint: true,\n },\n ];\n}\n","import { readExperimentation } from \"./record.ts\";\nimport type { Methodology } from \"../../core/types.ts\";\nimport {\n experimentationCeremonies,\n candidateExhausted,\n exhausted,\n runningCount,\n assignedAuthor,\n synchronizeBudget,\n reservedTokens,\n} from \"./ceremonies.ts\";\nimport { validateExperimentationConfig, type ExperimentationConfig } from \"./config.ts\";\nimport { experimentationMetrics, experimentationReport } from \"./metrics.ts\";\nimport { experimentationRoles } from \"./roles.ts\";\nimport { experimentationRules } from \"./rules.ts\";\nimport { experimentationStages } from \"./stages.ts\";\nexport {\n validateExperimentationConfig,\n experimentationCeremonies,\n experimentationMetrics,\n experimentationReport,\n experimentationRoles,\n experimentationRules,\n experimentationStages,\n};\nexport type { ExperimentationConfig } from \"./config.ts\";\nexport type { ExperimentationState, ExperimentCandidate } from \"./state.ts\";\nexport function experimentation(): Methodology<ExperimentationConfig> {\n return {\n name: \"experimentation\",\n vocabulary: {\n backlog: \"Candidate pool\",\n item: \"Candidate work item\",\n stage: \"Experiment stage\",\n iteration: \"Experiment run\",\n increment: \"Validated integration\",\n ceremony: \"Experiment control\",\n gate: \"Independent validation\",\n },\n validateConfig: validateExperimentationConfig,\n defaultStages: experimentationStages,\n defaultRoles: experimentationRoles,\n requiredCapabilities: [\"facilitate\", \"manage-flow\", \"deliver\", \"verify\", \"control-change\"],\n exclusiveCapabilities: [],\n plannerOptions(s) {\n const cfg = validateExperimentationConfig(s.config);\n return {\n schedulerMode: \"throughput\",\n dispatchStage: \"building\",\n concurrencyCap: Math.max(1, cfg.concurrencyCap - runningCount(s)),\n fallbackTokensPerWeight: 1,\n reservedTokens: reservedTokens(s),\n roleFor(item) {\n return Object.values(readExperimentation(s)?.candidates ?? {}).find(\n (candidate) => candidate.item === item.id,\n )?.author;\n },\n };\n },\n candidates(s) {\n const e = readExperimentation(s);\n if (!e || e.status !== \"running\") return [];\n const cfg = validateExperimentationConfig(s.config);\n if (exhausted(s) || runningCount(s) >= cfg.concurrencyCap) return [];\n return Object.values(e.candidates)\n .filter(\n (c) =>\n c.status === \"ready\" &&\n assignedAuthor(s, c) &&\n s.items[c.item]?.status === \"todo\" &&\n !candidateExhausted(s, c),\n )\n .map((c) => s.items[c.item]!);\n },\n afterComplete(s, _item, now) {\n return synchronizeBudget(s, now);\n },\n invariants(s, item) {\n const e = readExperimentation(s);\n const c = Object.values(e?.candidates ?? {}).find((candidate) => candidate.item === item.id);\n return [\n `Frozen base SHA: ${e?.baseSha ?? \"unfrozen\"}; harness: ${e?.harness ?? \"unfrozen\"}`,\n `Candidate: ${c?.id ?? \"unregistered\"}; isolated workspace: ${c?.workspace ?? \"not provisioned\"}`,\n `Objective and budget: ${JSON.stringify(s.config)}`,\n \"Submit an exact commit SHA and harness benchmark before completion; independent validation is mandatory.\",\n \"Host owns process execution, Git integration and workspace cleanup.\",\n ];\n },\n ceremonies: experimentationCeremonies(),\n rules: experimentationRules(),\n metrics: experimentationMetrics,\n report: experimentationReport,\n humanDefaults: { gates: \"none\" },\n lockedConfigKeys: [\n \"objective\",\n \"direction\",\n \"tieBreak\",\n \"concurrencyCap\",\n \"maxCandidates\",\n \"candidateBudget\",\n \"totalBudget\",\n ],\n };\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {c as c$1}from'./chunk-YS6CXERQ.mjs';var a=["investigation","experimentation"],c=t=>t==="investigation"||t==="experimentation";function x(t,e){return c$1(e,"ext key"),t.ext&&Object.hasOwn(t.ext,e)?t.ext[e]:c(e)?t[e]:void 0}function d(t,e,o){c$1(e,"ext key");let n={...t.ext},r={...t,ext:n};for(let s of c(e)?[n,r]:[n])o===void 0?delete s[e]:s[e]=o;return !t.ext&&!Object.keys(n).length&&delete r.ext,r}function g(t){let e=t.ext;if(!e)return t;let o={...t};for(let n of a)Object.hasOwn(e,n)&&delete o[n];return o}function u(t){let e=t.ext;if(!e)return t;let o={...t};for(let n of a)Object.hasOwn(e,n)&&(o[n]=e[n]);return o}export{x as a,d as b,g as c,u as d};//# sourceMappingURL=chunk-TQR3VFZU.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-TQR3VFZU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/interface/ext.ts"],"names":["LEGACY_KEYS","isLegacy","key","readExt","state","assertId","writeExt","value","ext","out","target","withoutLegacyMirrors","withLegacyMirrors"],"mappings":"4CAeA,IAAMA,EAAoC,CAAC,eAAA,CAAiB,iBAAiB,CAAA,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CAAG,CAAA,CAC1E,OAAOO,CACT,CAOO,SAASG,CAAAA,CAAmDR,CAAAA,CAAa,CAC9E,IAAMI,EAAMJ,CAAAA,CAAM,GAAA,CAClB,GAAI,CAACI,CAAAA,CAAK,OAAOJ,CAAAA,CACjB,IAAMK,CAAAA,CAAM,CAAE,GAAGL,CAAM,CAAA,CACvB,QAAWF,CAAAA,IAAOF,CAAAA,CAAiB,OAAO,MAAA,CAAOQ,CAAAA,CAAKN,CAAG,CAAA,GAAGO,EAAIP,CAAG,CAAA,CAAIM,EAAIN,CAAG,CAAA,CAAA,CAC9E,OAAOO,CACT","file":"chunk-TQR3VFZU.mjs","sourcesContent":["import { assertId } from \"../core/errors.ts\";\nimport type { ExperimentationState } from \"../core/records/experimentation.ts\";\nimport type { InvestigationState } from \"../core/records/investigation.ts\";\nimport type { WorkflowState } from \"../core/types.ts\";\n\n/**\n * Extension records that 1.1 stored as top-level state fields. Writing one also writes its\n * deprecated legacy mirror (`state.investigation`, `state.experimentation`) in memory; on disk\n * only `ext` is stored (spec 26). 2.0 drops the mirror.\n */\nexport interface LegacyExtRecords {\n investigation: InvestigationState;\n experimentation: ExperimentationState;\n}\ntype LegacyKey = keyof LegacyExtRecords;\nconst LEGACY_KEYS: readonly LegacyKey[] = [\"investigation\", \"experimentation\"];\nconst isLegacy = (key: string): key is LegacyKey =>\n key === \"investigation\" || key === \"experimentation\";\n\n/**\n * Reads the extension record `key` (a methodology name or a common piece id) from `state.ext`.\n * A state written before 1.2 has no `ext`; for `investigation` and `experimentation` the legacy\n * top-level field is read instead.\n */\nexport function readExt<K extends LegacyKey>(\n state: WorkflowState<string>,\n key: K,\n): LegacyExtRecords[K] | undefined;\nexport function readExt<T = unknown>(state: WorkflowState<string>, key: string): T | undefined;\nexport function readExt(state: WorkflowState<string>, key: string): unknown {\n assertId(key, \"ext key\");\n if (state.ext && Object.hasOwn(state.ext, key)) return state.ext[key];\n return isLegacy(key) ? state[key] : undefined;\n}\n\n/**\n * Returns a copy of `state` with `state.ext[key] = value`; `undefined` removes the key, and adds\n * no empty `ext` to a state that had none. For `investigation` and `experimentation` the legacy\n * top-level field is written (or removed) too, so SDK code reading `state.investigation` /\n * `state.experimentation` sees the same record (dual-write, spec 26). The mirror is read-only:\n * once `ext.<key>` exists, `readExt` ignores the legacy field. It does not make the state\n * loadable by 1.1.x, whose schema rejects `ext`.\n */\nexport function writeExt<N extends string, K extends LegacyKey>(\n state: WorkflowState<N>,\n key: K,\n value: LegacyExtRecords[K] | undefined,\n): WorkflowState<N>;\nexport function writeExt<N extends string, T>(\n state: WorkflowState<N>,\n key: string,\n value: T | undefined,\n): WorkflowState<N>;\nexport function writeExt<N extends string>(\n state: WorkflowState<N>,\n key: string,\n value: unknown,\n): WorkflowState<N> {\n assertId(key, \"ext key\");\n const ext: Record<string, unknown> = { ...state.ext };\n const out: Record<string, unknown> = { ...state, ext };\n for (const target of isLegacy(key) ? [ext, out] : [ext]) {\n if (value === undefined) delete target[key];\n else target[key] = value;\n }\n // removing a key from a state that had no ext adds no empty ext (U11 N4)\n if (!state.ext && !Object.keys(ext).length) delete out.ext;\n return out as unknown as WorkflowState<N>;\n}\n\n/**\n * The state as the file adapter stores it: a legacy mirror whose `ext.<key>` exists is left out,\n * so the record is written once (spec 26, U10 F1). A legacy field without `ext.<key>` (a state\n * written before 1.2) is kept. Does not mutate `state`.\n */\nexport function withoutLegacyMirrors<S extends WorkflowState<string>>(state: S): S {\n const ext = state.ext;\n if (!ext) return state;\n const out = { ...state } as Record<string, unknown>;\n for (const key of LEGACY_KEYS) if (Object.hasOwn(ext, key)) delete out[key];\n return out as S;\n}\n\n/**\n * The reverse of `withoutLegacyMirrors` for a loaded state: each legacy field whose `ext.<key>`\n * exists is set to that record by reference, replacing whatever the file held there (`ext` wins\n * over a hand-edited legacy field). Does not mutate `state`.\n */\nexport function withLegacyMirrors<S extends WorkflowState<string>>(state: S): S {\n const ext = state.ext;\n if (!ext) return state;\n const out = { ...state } as Record<string, unknown>;\n for (const key of LEGACY_KEYS) if (Object.hasOwn(ext, key)) out[key] = ext[key];\n return out as S;\n}\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkK4VSMIJZ_cjs=require('./chunk-K4VSMIJZ.cjs'),chunkIIEKK2S3_cjs=require('./chunk-IIEKK2S3.cjs'),chunkVXOZIP77_cjs=require('./chunk-VXOZIP77.cjs'),chunkQAENYYU6_cjs=require('./chunk-QAENYYU6.cjs'),chunkSFYUJQYW_cjs=require('./chunk-SFYUJQYW.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:chunkK4VSMIJZ_cjs.l,kanban:chunkIIEKK2S3_cjs.I,waterfall:chunkVXOZIP77_cjs.N,investigation:chunkQAENYYU6_cjs.b,experimentation:chunkSFYUJQYW_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-U3RU5LOF.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-U3RU5LOF.cjs.map
|
|
@@ -0,0 +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,C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F,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-U3RU5LOF.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"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {b as b$1,c}from'./chunk-YS6CXERQ.mjs';import {ExFlow,ExFlowRuntimeError}from'ex-flow';function h(e){return e??new Date().toISOString()}function Y(e){let t=new Set;for(let i of e.stages)t.has(i.id)&&b$1("config-invalid",`duplicate stage id "${i.id}"`,"give every stage a unique id"),t.add(i.id);let o={};for(let i of e.roles)c(i.id,"role id"),Object.hasOwn(o,i.id)&&b$1("duplicate-role",`duplicate role id "${i.id}"`,"give every role a unique id"),o[i.id]=i;let n=h(e.now);return {version:1,methodology:e.methodology,config:e.config,items:{},stages:e.stages,roles:o,iterations:[],events:[{seq:1,at:n,type:"state.created",by:"system",payload:{methodology:e.methodology}}],accounting:[],pending:[],lessons:[],agreements:[]}}function w(e,t,o,n,i){let s={seq:(e.events[e.events.length-1]?.seq??0)+1,at:h(i),type:t,by:o,payload:n};return {...e,events:[...e.events,s]}}function $e(e,t){for(let o=e.events.length-1;o>=0;o--){let n=e.events[o];if(t===void 0||n.type===t)return n}}function V(e,t){return Object.hasOwn(e.roles,t)?e.roles[t]:void 0}function G(e,t){return e.capabilities.includes(t)}function q(e,t){return Object.values(e.roles).filter(o=>G(o,t))}function B(e,t,o,n){return Object.values(e.roles).filter(i=>i.id!==n&&i.canApprove.includes(t)&&(o===void 0||i.capabilities.includes(o))).map(i=>i.id)}function Re(e,t){return q(e,"approve-gate").filter(o=>o.canApprove.includes(t))}function ee(e,t,o){for(let n of t)q(e,n).length===0&&b$1("missing-capability",`no registered role has capability "${n}"`,`register a role whose capabilities include "${n}" (registerRole) before init`);for(let n of o){let i=q(e,n);i.length>1&&b$1("exclusive-capability",`capability "${n}" must belong to exactly one role but is held by ${i.map(r=>r.id).join(", ")}`,`remove "${n}" from all but one role`);}}function te(e,t){return t.length===0?[]:Object.values(e.roles).filter(o=>t.every(n=>G(o,n)))}function he(e,t,...o){if(t==="human")return true;let n=V(e,t);return !!n&&o.some(i=>G(n,i))}function Ee(e,t,...o){if(!he(e,t,...o)){let n=Object.values(e.roles).filter(i=>o.some(r=>G(i,r))).map(i=>i.id);b$1("missing-capability",`"${t}" lacks capability ${o.map(i=>`"${i}"`).join(" or ")}`,`run this as one of: human${n.map(i=>`, ${i}`).join("")}`);}}function M(e,t){let o=e.stages.find(n=>n.id===t);return o||b$1("unknown-stage",`stage "${t}" does not exist`,`stages are: ${e.stages.map(n=>n.id).join(" \u2192 ")}`),o}function oe(e,t){let o=e.stages.findIndex(n=>n.id===t);return o<0&&M(e,t),e.stages[o+1]}function ne(e,t){return e.stages[e.stages.length-1]?.id===t}function R(e,t){return {...e,items:{...e.items,[t.id]:t}}}function ie(e,t,o){return R(e,o(b(e,t)))}function b(e,t){let o=Object.hasOwn(e.items,t)?e.items[t]:void 0;return o||b$1("unknown-item",`item "${t}" does not exist`,`add it with addItem first; known items: ${Object.keys(e.items).join(", ")||"(none)"}`,{items:[t]}),o}function _(e,t,o){let n=t.filter(i=>!Object.hasOwn(e.items,i));n.length&&b$1("unknown-item",`${o} refers to unknown item(s) ${n.join(", ")}`,"add those items first or remove the reference",{items:n});}function De(e,t,o,n){c(t.id,"item id"),Object.hasOwn(e.items,t.id)&&b$1("duplicate-item",`item "${t.id}" already exists`,"use editItem to change it, or pick a new id",{items:[t.id]});let i=e.stages[0];i||b$1("config-invalid","state has no stages","create the state with at least one stage");let r=t.stage??i.id;M(e,r),_(e,t.dependsOn??[],`item "${t.id}".dependsOn`),t.affects&&_(e,t.affects,`item "${t.id}".affects`),t.parent!==void 0&&_(e,[t.parent],`item "${t.id}".parent`),t.role!==void 0&&!Object.hasOwn(e.roles,t.role)&&b$1("unknown-role",`role "${t.role}" does not exist`,`registered roles: ${Object.keys(e.roles).join(", ")}`);let{stage:s,...a}=t,l={type:"task",acceptance:[],dependsOn:[],...a,id:t.id,title:t.title,stage:r,status:"todo",evidence:[],blockers:[],transitions:[]},f=R(e,l);return w(f,"item.added",o,{id:l.id,type:l.type,stage:l.stage,weight:l.weight??null,priority:l.priority??null,phase:l.phase??null,parent:l.parent??null},n)}function Ve(e,t,o,n,i){let r=b(e,t);o.dependsOn&&_(e,o.dependsOn,`item "${t}".dependsOn`),o.affects&&_(e,o.affects,`item "${t}".affects`),o.parent!==void 0&&_(e,[o.parent],`item "${t}".parent`),o.role!==void 0&&!Object.hasOwn(e.roles,o.role)&&b$1("unknown-role",`role "${o.role}" does not exist`,`registered roles: ${Object.keys(e.roles).join(", ")}`);let s=Object.keys(o).filter(f=>JSON.stringify(o[f])!==JSON.stringify(r[f]));s.length===0&&b$1("no-op",`editItem("${t}") changes nothing`,"pass at least one field with a different value",{items:[t]});let a={...r};for(let f of s)a[f]=o[f];let l=R(e,a);return w(l,"item.edited",n,{id:t,changed:s},i)}function P(e,t,o,n,i){let r=b(e,t),s=o.stage??r.stage;M(e,s),(r.status==="done"||r.status==="dropped")&&b$1("invalid-transition",`item "${t}" is ${r.status} and cannot move`,"create a new item (or a change-request) instead of reopening a finished one",{items:[t]}),s===r.stage&&o.status===r.status&&b$1("no-op",`item "${t}" is already ${r.status} in "${s}"`,"choose a different stage or status",{items:[t]});let a=h(i),l={...r,stage:s,status:o.status,transitions:[...r.transitions,{from:{stage:r.stage,status:r.status},to:{stage:s,status:o.status},at:a,by:n}]},f=R(e,l);return w(f,"item.transition",n,{id:t,from:{stage:r.stage,status:r.status},to:{stage:s,status:o.status}},a)}function Q(e,t){return ye(e,t,["role"])}function re(e,t,o,n,i){let r=b(e,t),s=oe(e,r.stage);if(!s)return P(e,t,{status:"done"},o,i);if(ne(e,s.id))return P(e,t,{stage:s.id,status:"done"},o,i);let a=n||s.review===true?"review":"todo";return Q(P(e,t,{stage:s.id,status:a},o,i),t)}function ye(e,t,o){return ie(e,t,n=>{let i={...n};for(let r of o)delete i[r];return i})}function K(e,t){let o=0,n=false;for(let i=e.events.length-1;i>=0;i--){let r=e.events[i];if(r.payload?.id===t.id){if(r.type==="item.rework"){n=true;break}r.type==="item.evidence"&&o++;}}return n?t.evidence.slice(Math.max(0,t.evidence.length-o)):t.evidence}function Qe(e,t,o,n){let i=b(e,t),r=h(n),s={...i,evidence:[...i.evidence,{...o,at:r}]},a=R(e,s);return w(a,"item.evidence",o.by,{id:t,kind:o.kind,ref:o.ref},r)}function ae(e,t,o,n,i,r){let s=b(e,t),a=h(r),l=`${t}-b${s.blockers.length+1}`,f=s.status==="blocked"?null:{from:{stage:s.stage,status:s.status},to:{stage:s.stage,status:"blocked"},at:a,by:i},g={...s,status:"blocked",blockers:[...s.blockers,{id:l,reason:o,owner:n,raisedAt:a}],transitions:f?[...s.transitions,f]:s.transitions},p=R(e,g);return w(p,"blocker.raised",i,{id:t,blocker:l,reason:o,owner:n,transition:f&&{from:f.from,to:f.to}},a)}function se(e,t){for(let o=e.transitions.length-1;o>=0;o--){let n=e.transitions[o];if(n.to.status===t)return n}}function ot(e,t,o,n,i,r){let s=b(e,t),a=s.blockers.findIndex(W=>W.id===o&&!W.clearedAt);a<0&&b$1("invalid-input",`item "${t}" has no open blocker "${o}"`,`open blockers: ${s.blockers.filter(W=>!W.clearedAt).map(W=>W.id).join(", ")||"(none)"}`,{items:[t]});let l=h(i),f=s.blockers.map((W,F)=>F===a?{...W,clearedAt:l}:W),g=f.some(W=>!W.clearedAt),p=se(s,"blocked")?.from.status??"todo",u=s.stage,m=p,x=false;p==="in_progress"?(m="todo",u=se(s,"in_progress")?.from.stage??s.stage):p==="awaiting_human"&&(m=M(e,s.stage).review?"review":"todo",x=true);let{role:I,...C}=s,S=g?null:{from:{stage:s.stage,status:"blocked"},to:{stage:u,status:m},at:l,by:n},E={...x&&!g?C:s,blockers:f,stage:g?s.stage:u,status:g?"blocked":m,transitions:S?[...s.transitions,S]:s.transitions},T=R(e,E);return w(T,"blocker.cleared",n,{id:t,blocker:o,transition:S&&{from:S.from,to:S.to},note:r??null},l)}function U(e,t,o){let n=[],i=K(e,t),r=(s,a,l)=>n.push({rule:s,severity:"error",item:t.id,message:a,fix:l});for(let s of o)switch(s.kind){case "evidence":i.some(a=>a.kind===s.evidenceKind)||r("policy:evidence",`item "${t.id}" has no evidence of kind "${s.evidenceKind}"`,`attach evidence { kind: "${s.evidenceKind}" } via addEvidence or in the handoff.produced`);break;case "acceptance-written":t.acceptance.length===0&&r("policy:acceptance-written",`item "${t.id}" has no acceptance criteria`,"editItem with a non-empty acceptance[] (needs define-acceptance)");break;case "estimate-present":t.weight===void 0&&r("policy:estimate-present",`item "${t.id}" has no weight`,"editItem with a weight (story points)");break;case "no-open-blockers":{let a=t.blockers.filter(l=>!l.clearedAt);a.length&&r("policy:no-open-blockers",`item "${t.id}" has ${a.length} open blocker(s)`,`clearBlocker ${a.map(l=>l.id).join(", ")}`);break}case "dependencies-done":{let a=t.dependsOn.filter(l=>e.items[l]?.status!=="done");a.length&&r("policy:dependencies-done",`item "${t.id}" depends on unfinished ${a.join(", ")}`,`finish ${a.join(", ")} first`);break}case "custom":i.some(a=>a.kind===`policy:${s.id}`)||r(`policy:custom:${s.id}`,`item "${t.id}" has not satisfied "${s.description}"`,`attach evidence { kind: "policy:${s.id}" } when it is satisfied`);break}return n}function st(e,t,o,n){let i=U(e,t,o);i.length&&b$1("policy-unmet",`item "${t.id}" cannot ${n}: ${i.length} polic${i.length===1?"y":"ies"} unmet`,i.map(r=>r.fix).join("; "),{items:[t.id]});}function xe(e,t){let o=new Map(e.stages.map((i,r)=>[i.id,r])),n=o.get(t.stage);if(n!==void 0)for(let i=t.transitions.length-1;i>=0;i--){let r=t.transitions[i],s=o.get(r.from.stage);if(r.to.status==="in_progress"&&s!==void 0&&s<n)return r}}function H(e,t){let o=xe(e,t);if(o)return o.by;for(let n=t.transitions.length-1;n>=0;n--){let i=t.transitions[n];if(i.to.status==="in_progress")return i.by}}function Se(e,t,o,n){let i=[],r=K(e,t);for(let a of o.evidence)r.some(l=>l.kind===a)||i.push({rule:"gate:evidence",severity:"error",item:t.id,message:`gate "${o.id}" needs evidence "${a}" on item "${t.id}"`,fix:`attach evidence { kind: "${a}" } before approving`});if(i.length)return {outcome:"fail",violations:i};let s=false;for(let a of o.requires){if(a==="human"){n!=="human"&&(s=true);continue}if(!B(e,o.id,a.capability).includes(n)){i.push({rule:"gate:capability",severity:"error",item:t.id,message:`"${n}" may not approve gate "${o.id}" (needs capability "${a.capability}" and canApprove "${o.id}")`,fix:`approve as one of: ${B(e,o.id,a.capability).join(", ")||"(no role qualifies; register one)"}`});continue}let f=H(e,t);if(f!==void 0&&f===n){let g=B(e,o.id,a.capability,n);i.push({rule:"conflict-of-interest",severity:"error",item:t.id,message:`role "${n}" did the work on "${t.id}" and may not approve it`,fix:`approve as a different role: ${g.join(", ")||"(register another approver)"}`});}}return i.length?{outcome:"fail",violations:i}:s?{outcome:"human"}:{outcome:"pass"}}function mt(e,t,o){let n=h(o),i=`p${e.events.filter(a=>a.type==="pending.raised").length+1}`,r={...t,id:i,raisedAt:n},s={...e,pending:[...e.pending,r]};return t.item&&b(s,t.item).status!=="awaiting_human"&&(s=P(s,t.item,{status:"awaiting_human"},"system",n)),w(s,"pending.raised","system",{id:i,kind:t.kind,item:t.item??null,gate:t.gate??null},n)}function kt(e,t,o,n,i,r,s){o!=="approve"&&o!=="reject"&&b$1("invalid-input",`decision must be "approve" or "reject" (got ${JSON.stringify(o)})`,"pass approve or reject");let a=e.pending.find(u=>u.id===t);a||b$1("unknown-pending",`no pending decision "${t}"`,`open decisions: ${e.pending.map(u=>u.id).join(", ")||"(none)"}`);let l=a.kind==="gate"&&a.item?b(e,a.item):void 0,f=l&&(e.stages.find(u=>a.gate!==void 0&&u.gate?.id===a.gate)?.gate??e.stages.find(u=>u.id===l.stage)?.gate);l&&f&&n!=="human"&&(f.requires.includes("human")?void 0:Se(e,l,f,n))?.outcome!=="pass"&&b$1("gate-unmet",`"${n}" may not decide gate "${f.id}" on "${l.id}"`,`decide as one of: human${f.requires.flatMap(m=>m==="human"?[]:B(e,f.id,m.capability)).map(m=>`, ${m}`).join("")}`,{items:[l.id],rule:"gate"});let g=h(r),p={...e,pending:e.pending.filter(u=>u.id!==t)};if(p=w(p,"pending.decided",n,{id:t,decision:o,note:i,item:a.item??null,gate:a.gate??null},g),l){let u=l.id,m=a.gate??f?.id??null;if(o==="approve"){let x=false;for(let I=e.events.length-1;I>=0;I--){let C=e.events[I];if(!(C.type!=="item.completed"||C.payload.id!==u)){x=C.payload.verdict==="needs-review";break}}p=re(p,u,n,x,g),p=w(p,"gate.passed",n,{item:u,gate:m},g);}else {let x=f?.onFail??{action:"block"};x.action==="return-to"?p=Q(P(p,u,{stage:x.stage,status:"todo"},n,g),u):p=ae(p,u,`gate "${m??"?"}" rejected: ${i||"no reason given"}`,n,n,g),p=w(p,"gate.failed",n,{item:u,gate:m,note:i},g);}}return s?.afterDecide&&(p=s.afterDecide(p,a,o,n,i,g)),p}var ht=Object.freeze({tokens:0,turns:0,wallclockMs:0});function yt(e,t){return {tokens:e.tokens+t.tokensIn+t.tokensOut,turns:e.turns+1,wallclockMs:e.wallclockMs+t.durationMs}}function le(e,t){let o={};return e.tokens!==void 0&&(o.tokens=Math.max(0,e.tokens-t.tokens)),e.turns!==void 0&&(o.turns=Math.max(0,e.turns-t.turns)),e.wallclockMs!==void 0&&(o.wallclockMs=Math.max(0,e.wallclockMs-t.wallclockMs)),o}function xt(e,t){return e.tokens!==void 0&&t.tokens>=e.tokens||e.turns!==void 0&&t.turns>=e.turns||e.wallclockMs!==void 0&&t.wallclockMs>=e.wallclockMs}function de(e,t,o=2e4,n="per-weight"){let i=t??1,r=[];for(let l of e.accounting){if(l.estimate===true)continue;let f=l.tokensIn+l.tokensOut;if(n==="per-call"){r.push(f);continue}let g=e.items[l.item]?.weight;g===void 0||g<=0||r.push(f/g);}if(r.length===0)return n==="per-call"?o:o*i;r.sort((l,f)=>l-f);let s=Math.floor(r.length/2),a=r.length%2?r[s]:(r[s-1]+r[s])/2;return Math.round(n==="per-call"?a:a*i)}function z(e){return e.iterations.find(t=>t.endedAt===void 0)}function ce(e,t,o){if(t.role){let r=V(e,t.role);return r||b$1("unknown-role",`item "${t.id}" is assigned to unknown role "${t.role}"`,"editItem with an existing role id"),r}let n=o?o(t):void 0;if(n!==void 0){let r=V(e,n);return r||b$1("unknown-role",`the methodology picked unknown role "${n}" for item "${t.id}"`,`registered roles: ${Object.keys(e.roles).join(", ")||"(none)"}`,{items:[t.id]}),r}if(t.status==="review"){let r=H(e,t),s=q(e,"review"),l=s.find(f=>f.id!==r)??(s.length===1?s[0]:void 0);return l||b$1("missing-capability",`no role has capability "review" for item "${t.id}"`,"register a role with capability review",{items:[t.id]}),l}let i=q(e,"deliver")[0];return i||b$1("missing-capability",`no role has capability "deliver" for item "${t.id}"`,"register a role with capability deliver",{items:[t.id]}),i}function fe(e){let t={};for(let o of Object.values(e.roles))o.maxConcurrent!==void 0&&(t[o.resourceClass??o.id]=o.maxConcurrent);return t}function be(e,t,o,n){let i=new Set(e.map(r=>r.id));return e.map(r=>{let s=ce(t,r,n),a={id:r.id,data:{id:r.id},dependsOn:r.dependsOn.filter(f=>i.has(f)),resourceClass:s.resourceClass??s.id},l=o?o(r):r.priority;return l!==void 0&&(a.priority=l),r.weight!==void 0&&(a.weight=r.weight),r.deadline!==void 0&&(a.deadline=Date.parse(r.deadline)),a})}function jt(e,t,o={}){let n=h(o.now),i=t.candidates(e),r=i.filter(d=>d.dependsOn.every(k=>e.items[k]?.status==="done"||i.some(v=>v.id===k))),s=i.filter(d=>d.dependsOn.every(k=>e.items[k]?.status==="done"));if(r.length===0)return {state:e,dispatched:[],skipped:[],reason:z(e)?.closing?"budget-exhausted":"no-candidates"};let a=t.plannerOptions(e),l={schedulerMode:a.schedulerMode,resourceCaps:fe(e)};if(a.concurrencyCap!==void 0&&(l.concurrencyCap=a.concurrencyCap),a.fairnessPolicy!==void 0&&(l.fairnessPolicy=a.fairnessPolicy),a.maxDeferralRounds!==void 0&&(l.maxDeferralRounds=a.maxDeferralRounds),a.deadlineStrategy!==void 0&&(l.deadlineStrategy=a.deadlineStrategy),a.weightStrategy!==void 0&&(l.weightStrategy=a.weightStrategy),a.tieBreaker!==void 0){let d=a.tieBreaker;l.tieBreaker=(k,v)=>d(e.items[k.data.id],e.items[v.data.id]);}let f,g;try{let d=new ExFlow(l);for(let v of be(r,e,a.priorityOf,a.roleFor))d.addEntity(v);let k=d.resolveExecutionDetails();f=(k.plan.batches[0]??[]).map(v=>v.id),g=k.metrics;}catch(d){throw d instanceof ExFlowRuntimeError&&b$1("planner-error",`ex-flow refused the graph: [${d.code}] ${d.message}`,"fix the item graph (cycles, duplicate ids) with editItem; see diagnostics in the message",{items:r.map(k=>k.id)}),d}let p=f.map(d=>e.items[d]).filter(d=>d.dependsOn.every(k=>e.items[k]?.status==="done")),u=Object.values(e.items).filter(d=>d.status==="in_progress"),m=new Set(a.wipCounts??["in_progress"]),x=Object.values(e.items).filter(d=>m.has(d.status)),I={};for(let d of u){let k=d.role?V(e,d.role):void 0,v=k?k.resourceClass??k.id:"?";I[v]=(I[v]??0)+1;}let C=fe(e),S=z(e),E=S?le(S.budget,S.spent):{},T=E.tokens===void 0?void 0:Math.max(0,E.tokens-(a.reservedTokens??0)),W=S?Object.values(e.items).filter(d=>(d.iteration===S.id||S.committed.includes(d.id))&&d.status==="in_progress").length:0,F=E.turns===void 0?void 0:E.turns-W,pe=E.wallclockMs!==void 0&&E.wallclockMs<=0,me=a.estimateMode??"per-weight",ke=o.fallbackTokensPerWeight??a.fallbackTokensPerWeight,we=Math.min(o.max??1/0,a.concurrencyCap??1/0),j=[],$=[],y,N=e;for(let d of p){if(j.length>=we){y="wip-full";break}let k=typeof a.dispatchStage=="function"?a.dispatchStage(d):a.dispatchStage,v=d.status==="todo"&&k!==void 0?k:d.stage,D=M(e,v),X=d.type==="question"?[]:U(e,d,D.entryPolicy);if(X.length>0){$.push({id:d.id,reason:"entry-policy",detail:X.map(O=>O.message).join("; ")});continue}let Z=a.wipLimitOf?a.wipLimitOf(D,d):D.wipLimit;if(Z!==void 0&&x.filter(O=>O.stage===D.id&&O.id!==d.id).length+j.filter(O=>O.stage===D.id).length>=Z){y="wip-full",$.push({id:d.id,reason:"wip",detail:`stage "${D.id}" is at its WIP limit of ${Z}`});continue}let L=ce(e,d,a.roleFor),A=L.resourceClass??L.id;if(C[A]!==void 0&&(I[A]??0)>=C[A]){y="wip-full",$.push({id:d.id,reason:"resource-cap",detail:`resource class "${A}" is at its cap of ${C[A]}`});continue}if(F!==void 0&&F<=0){y="budget-exhausted",$.push({id:d.id,reason:"budget",detail:`turns budget spent: ${S.spent.turns} used + ${W+j.length} in flight of ${S.budget.turns}`});continue}if(pe){y="budget-exhausted",$.push({id:d.id,reason:"budget",detail:"wall-clock budget spent"});continue}if(T!==void 0){let O=de(e,d.weight,ke,me);if(O>T){y="budget-exhausted",$.push({id:d.id,reason:"budget",detail:`needs about ${O} tokens, ${T} left in the iteration`});continue}T-=O;}I[A]=(I[A]??0)+1,F!==void 0&&(F-=1),N=P(N,d.id,{stage:v,status:"in_progress"},L.id,n),N={...N,items:{...N.items,[d.id]:{...N.items[d.id],role:L.id}}},j.push(N.items[d.id]);}return y===void 0&&$.some(d=>d.reason==="entry-policy")&&(y="policy-blocked"),y===void 0&&j.length<s.length&&(y="wip-full"),j.length===0&&y===void 0&&(y="no-candidates"),N=w(N,"planner.resolved","planner",{dispatched:j.map(d=>d.id),reason:y??null,skipped:$,metrics:g},n),y?{state:N,dispatched:j,skipped:$,reason:y}:{state:N,dispatched:j,skipped:$}}function ue(e){return [{id:"separation-lost",severity:"warning",check(n,i){return i.type!=="init"&&i.type!=="role.register"?[]:te(n,e.requiredCapabilities).map(r=>({rule:"separation-lost",severity:"warning",message:`role "${r.id}" holds every required capability (${e.requiredCapabilities.join(", ")}); no separation of duties`,fix:"fine for a solo operator; otherwise split capabilities across roles"}))}},{id:"conflict-of-interest",severity:"error",check(n,i){if(i.type!=="complete")return [];let r=i.payload?.handoff;if(!r)return [];let s=r.verdict??"done";if(s!=="done"&&s!=="needs-review")return [];let a=n.items[r.item];if(!a)return [];let l=n.stages.find(g=>g.id===a.stage)?.gate;if(!l||!l.requires.some(g=>g!=="human"))return [];if(H(n,a)!==r.role)return [];let f=B(n,l.id,void 0,r.role);return [{rule:"conflict-of-interest",severity:"error",item:a.id,message:`role "${r.role}" authored "${a.id}" and may not pass gate "${l.id}" on it`,fix:`hand the gate to another approver: ${f.join(", ")||"(register one)"}`}]}}]}function Ne(e,t,o){let n=[];for(let i of [...ue(t),...t.rules])n.push(...i.check(e,o));return n}function ge(e,t,o,n){let i=Ne(e,t,o),r=i.filter(s=>s.severity==="error");return r.length&&b$1("rule-violation",`${o.type} violates ${r.map(s=>s.rule).join(", ")}: ${r.map(s=>s.message).join("; ")}`,r.map(s=>s.fix).join("; "),{rule:r[0].rule,items:r.map(s=>s.item).filter(s=>!!s)}),{state:n(e),warnings:i.filter(s=>s.severity==="warning")}}function _t(e){let t=e.methodology,o=t.validateConfig(e.config),n=e.stages??t.defaultStages(o),i=e.roles??t.defaultRoles(o),r=e.now!==void 0?{methodology:t.name,config:o,stages:n,roles:i,now:e.now}:{methodology:t.name,config:o,stages:n,roles:i},s=Y(r);return ee(s,t.requiredCapabilities,t.exclusiveCapabilities),ge(s,t,{type:"init",by:e.by??"system"},a=>a)}function Gt(e,t,o,n,i){(typeof o!="object"||o===null||Array.isArray(o)||Object.keys(o).length===0)&&b$1("invalid-input","config patch must be a non-empty object",'pass e.g. { "sprintBudget": { "tokens": 1500000 } } to exwf config set');let r=z(e);r&&b$1("invalid-input",`config cannot change while ${r.id} is open`,"close it first (exwf ceremony review or cancel; a waterfall phase closes at its gate), then run exwf config set");let s=(t.lockedConfigKeys??[]).filter(u=>Object.hasOwn(o,u));s.length&&b$1("invalid-input",`config key(s) ${s.join(", ")} cannot change after init`,t.name==="kanban"?"use the service-delivery-review cadence for columns and classes of service":"start a new workflow with exwf init to change them");let a=e.config??{},l=t.validateConfig({...a,...o}),f=Object.keys(o).filter(u=>!Object.hasOwn(l,u));f.length&&b$1("invalid-input",`unknown config key(s) ${f.join(", ")}`,`known keys: ${Object.keys(l).join(", ")}`);let g=Object.keys(o).filter(u=>JSON.stringify(a[u])!==JSON.stringify(l[u]));g.length===0&&b$1("no-op","config patch changes nothing","pass at least one key with a different value to exwf config set");let p=u=>Object.fromEntries(g.map(m=>[m,u[m]]));return ge(e,t,{type:"config.change",by:n,payload:{patch:o}},u=>{let m=h(i),x=w({...u,config:l},"config.changed",n,{changed:g,before:p(a),after:p(l)},m);return t.afterConfigChange&&(x=t.afterConfigChange(x,m)),x})}export{ot as A,U as B,st as C,xe as D,H as E,Se as F,mt as G,kt as H,ht as I,yt as J,le as K,xt as L,de as M,z as N,ce as O,fe as P,be as Q,jt as R,ue as S,Ne as T,ge as U,_t as V,Gt as W,h as a,Y as b,w as c,$e as d,V as e,G as f,q as g,B as h,Re as i,ee as j,te as k,he as l,Ee as m,M as n,oe as o,ne as p,ie as q,b as r,De as s,Ve as t,P as u,Q as v,re as w,ye as x,Qe as y,ae as z};//# sourceMappingURL=chunk-UUWDQVIJ.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-UUWDQVIJ.mjs.map
|