ex-workflow 1.2.0 → 1.3.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 +25 -0
- package/README.md +145 -13
- 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-Gckmqj74.d.ts → budget-BuQ9GWsg.d.ts} +1 -1
- package/dist/{budget-Bm839Qw0.d.cts → budget-DDqQQIgp.d.cts} +1 -1
- package/dist/{chunk-VXOZIP77.cjs → chunk-2FBA7RBS.cjs} +2 -2
- package/dist/{chunk-VXOZIP77.cjs.map → chunk-2FBA7RBS.cjs.map} +1 -1
- package/dist/chunk-3S7F5QXK.mjs +2 -0
- package/dist/{chunk-BYPFTO7P.mjs.map → chunk-3S7F5QXK.mjs.map} +1 -1
- package/dist/{chunk-K4VSMIJZ.cjs → chunk-3ZUBCA7Q.cjs} +2 -2
- package/dist/{chunk-K4VSMIJZ.cjs.map → chunk-3ZUBCA7Q.cjs.map} +1 -1
- package/dist/chunk-4F5HZLKD.cjs +2 -0
- package/dist/{chunk-SFYUJQYW.cjs.map → chunk-4F5HZLKD.cjs.map} +1 -1
- package/dist/{chunk-4HG6A3SF.mjs → chunk-5DCOXGRW.mjs} +2 -2
- package/dist/{chunk-4HG6A3SF.mjs.map → chunk-5DCOXGRW.mjs.map} +1 -1
- package/dist/chunk-5GXB6GMX.mjs +2 -0
- package/dist/chunk-5GXB6GMX.mjs.map +1 -0
- package/dist/chunk-5ZGNEY2I.mjs +2 -0
- package/dist/{chunk-32NVJV5C.mjs.map → chunk-5ZGNEY2I.mjs.map} +1 -1
- package/dist/chunk-6PFJYRM7.cjs +2 -0
- package/dist/chunk-6PFJYRM7.cjs.map +1 -0
- package/dist/{chunk-W2P27645.cjs → chunk-BANKVCYY.cjs} +2 -2
- package/dist/{chunk-W2P27645.cjs.map → chunk-BANKVCYY.cjs.map} +1 -1
- package/dist/chunk-BD665RYK.mjs +2 -0
- package/dist/chunk-BD665RYK.mjs.map +1 -0
- package/dist/chunk-COPYGMHE.mjs +2 -0
- package/dist/chunk-COPYGMHE.mjs.map +1 -0
- package/dist/{chunk-3O5MPAJT.cjs → chunk-CVGEIXW6.cjs} +2 -2
- package/dist/{chunk-3O5MPAJT.cjs.map → chunk-CVGEIXW6.cjs.map} +1 -1
- package/dist/chunk-CX2E7ZTQ.mjs +2 -0
- package/dist/{chunk-JNLWI4JM.mjs.map → chunk-CX2E7ZTQ.mjs.map} +1 -1
- package/dist/chunk-DVFTTBCT.cjs +3 -0
- package/dist/chunk-DVFTTBCT.cjs.map +1 -0
- package/dist/{chunk-U3RU5LOF.cjs → chunk-EQXYFHHD.cjs} +2 -2
- package/dist/{chunk-U3RU5LOF.cjs.map → chunk-EQXYFHHD.cjs.map} +1 -1
- package/dist/{chunk-OVR5CK3R.cjs → chunk-H26KXQ3I.cjs} +2 -2
- package/dist/{chunk-OVR5CK3R.cjs.map → chunk-H26KXQ3I.cjs.map} +1 -1
- package/dist/chunk-ILDXZWEL.mjs +2 -0
- package/dist/{chunk-OZAYOPLB.mjs.map → chunk-ILDXZWEL.mjs.map} +1 -1
- package/dist/{chunk-RXY434DX.cjs → chunk-KA6DVHO5.cjs} +4 -4
- package/dist/{chunk-RXY434DX.cjs.map → chunk-KA6DVHO5.cjs.map} +1 -1
- package/dist/chunk-KLOSFZFK.cjs +2 -0
- package/dist/chunk-KLOSFZFK.cjs.map +1 -0
- package/dist/{chunk-WPVL27G4.mjs → chunk-LG23WXAP.mjs} +2 -2
- package/dist/{chunk-WPVL27G4.mjs.map → chunk-LG23WXAP.mjs.map} +1 -1
- package/dist/chunk-MU26QW32.cjs +2 -0
- package/dist/chunk-MU26QW32.cjs.map +1 -0
- package/dist/chunk-OEHVWRJG.mjs +2 -0
- package/dist/{chunk-7EF47R2J.mjs.map → chunk-OEHVWRJG.mjs.map} +1 -1
- package/dist/{chunk-3GKYL6VB.mjs → chunk-ONVAUZOD.mjs} +3 -3
- package/dist/{chunk-3GKYL6VB.mjs.map → chunk-ONVAUZOD.mjs.map} +1 -1
- package/dist/{chunk-LIATP6LY.mjs → chunk-PFHVB2WT.mjs} +2 -2
- package/dist/{chunk-LIATP6LY.mjs.map → chunk-PFHVB2WT.mjs.map} +1 -1
- package/dist/chunk-QJMOCISZ.mjs +3 -0
- package/dist/chunk-QJMOCISZ.mjs.map +1 -0
- package/dist/chunk-RGHM3JJM.cjs +2 -0
- package/dist/chunk-RGHM3JJM.cjs.map +1 -0
- package/dist/chunk-UMG3WOD7.cjs +2 -0
- package/dist/{chunk-QAENYYU6.cjs.map → chunk-UMG3WOD7.cjs.map} +1 -1
- package/dist/{chunk-6D6FL3XK.mjs → chunk-UT7QV6CE.mjs} +2 -2
- package/dist/{chunk-6D6FL3XK.mjs.map → chunk-UT7QV6CE.mjs.map} +1 -1
- package/dist/chunk-WU5JELOM.mjs +2 -0
- package/dist/chunk-WU5JELOM.mjs.map +1 -0
- package/dist/{chunk-IIEKK2S3.cjs → chunk-YGCNLXPJ.cjs} +2 -2
- package/dist/{chunk-IIEKK2S3.cjs.map → chunk-YGCNLXPJ.cjs.map} +1 -1
- package/dist/cli/bin.cjs +1 -1
- package/dist/cli/bin.cjs.map +1 -1
- package/dist/cli/bin.mjs +1 -1
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/cli/index.cjs +1 -1
- package/dist/cli/index.mjs +1 -1
- package/dist/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 +8 -6
- package/dist/index.d.ts +8 -6
- 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 +1 -1
- package/dist/kanban/index.d.ts +1 -1
- package/dist/kanban/index.mjs +1 -1
- package/dist/policies/index.cjs +2 -0
- package/dist/policies/index.cjs.map +1 -0
- package/dist/policies/index.d.cts +199 -0
- package/dist/policies/index.d.ts +199 -0
- package/dist/policies/index.mjs +2 -0
- package/dist/policies/index.mjs.map +1 -0
- package/dist/registry/index.cjs +1 -1
- package/dist/registry/index.d.cts +1 -1
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.mjs +1 -1
- package/dist/schema/index.cjs +1 -1
- 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-DjePDfms.d.cts → types-DLOtndDY.d.cts} +61 -1
- package/dist/{types-DjePDfms.d.ts → types-DLOtndDY.d.ts} +61 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +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 +14 -1
- package/dist/chunk-32NVJV5C.mjs +0 -2
- package/dist/chunk-43GLYYA2.cjs +0 -3
- package/dist/chunk-43GLYYA2.cjs.map +0 -1
- package/dist/chunk-7EF47R2J.mjs +0 -2
- package/dist/chunk-BD76VFI4.mjs +0 -3
- package/dist/chunk-BD76VFI4.mjs.map +0 -1
- package/dist/chunk-BHAEPYRJ.cjs +0 -2
- package/dist/chunk-BHAEPYRJ.cjs.map +0 -1
- package/dist/chunk-BYPFTO7P.mjs +0 -2
- package/dist/chunk-FDZB73PH.mjs +0 -2
- package/dist/chunk-FDZB73PH.mjs.map +0 -1
- package/dist/chunk-JNLWI4JM.mjs +0 -2
- package/dist/chunk-LCN4UNYK.cjs +0 -2
- package/dist/chunk-LCN4UNYK.cjs.map +0 -1
- package/dist/chunk-MB465DI4.mjs +0 -2
- package/dist/chunk-MB465DI4.mjs.map +0 -1
- package/dist/chunk-OZAYOPLB.mjs +0 -2
- package/dist/chunk-QAENYYU6.cjs +0 -2
- package/dist/chunk-SFYUJQYW.cjs +0 -2
- package/dist/chunk-UUWDQVIJ.mjs +0 -2
- package/dist/chunk-UUWDQVIJ.mjs.map +0 -1
- package/dist/chunk-Z43GUETW.cjs +0 -2
- package/dist/chunk-Z43GUETW.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/methodologies/investigation/record.ts","../src/methodologies/investigation/execution.ts","../src/methodologies/investigation/invariants.ts","../src/methodologies/investigation/config.ts","../src/methodologies/investigation/ceremonies.ts","../src/methodologies/investigation/rules.ts","../src/methodologies/investigation/roles.ts","../src/methodologies/investigation/stages.ts","../src/methodologies/investigation/index.ts"],"names":["readInvestigation","s","readExt","writeInvestigation","x","writeExt","executionActors","state","item","event","transition","freshOutputRefs","completion","index","output","brokenInvestigation","what","fail","lastRound","investigationIteration","it","validateInvestigationConfig","raw","c","k","v","reject","name","message","fix","sameHypothesis","a","b","frozenChanges","text","refs","extraKey","keys","extraKeyIn","list","authorize","by","cap","roleOf","save","i","appendEvent","nowOf","closeInvestigation","outcome","reason","at","n","candidate","r","moveItem","investigationCeremonies","factory","built","methodology","make","phase","fn","applyAction","bad","addItem","h","extra","isExhausted","e","extraExperiment","p","prior","id","iteration","o","ref","entry","conclusion","independenceConflicts","target","replayRefs","investigationRules","round","investigationRoles","investigationStages","investigation","excluded","roles","selected","role","now"],"mappings":"qNAKO,IAAMA,EAAqBC,CAAAA,EAChCC,GAAAA,CAAQD,EAAG,eAAe,CAAA,CAGfE,EAAqB,CAACF,CAAAA,CAAkBG,CAAAA,GACnDC,GAAAA,CAASJ,EAAG,eAAA,CAAiBG,CAAC,ECDzB,SAASE,CAAAA,CAAgBC,EAAsBC,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E,CAAAA,EACD,CAACN,IAAYM,CAAAA,CAAU,MAAA,CAAQA,EAAU,KAAK,CAAA,CAEvCnE,EACFyC,CAAAA,CACLzC,CAAAA,CACAH,EACA,CAAE,EAAA,CAAI,gBAAiB,GAAA,CAAAuF,CAAI,EAC3B,SAAA,CACA,CAAA,yCAAA,EAA4CnF,CAAI,CAAA,6DAAA,CAClD,CACF,CAAA,CACA,UAAA,CAAaP,GAAM,CACjB,CAAA,UAAA,EAAcA,EAAE,MAAA,CAA+B,QAAQ,GACvD,mGACF,CAAA,CACA,KAAA,CAAOiF,CAAAA,GACP,OAAA,CAAUjF,CAAAA,GAAO,CACf,MAAA,CAAQD,CAAAA,CAAkBC,CAAC,CAAA,EAAG,MAAA,CAAO,MAAA,EAAU,CAAA,CAC/C,UAAWD,CAAAA,CAAkBC,CAAC,GAAG,MAAA,CAAO,MAAA,CAAQqD,GAAMA,CAAAA,CAAE,MAAA,EAAQ,KAAK,CAAA,CAAE,MAAA,EAAU,EACjF,WAAA,CACEtD,CAAAA,CAAkBC,CAAC,CAAA,EAAG,MAAA,CAAO,OAAQqD,CAAAA,EAAMA,CAAAA,CAAE,MAAA,EAAU,CAACA,EAAE,MAAA,CAAO,KAAK,EAAE,MAAA,EAAU,CACtF,GACA,MAAA,CAASrD,CAAAA,GAAO,CACd,KAAA,CAAOD,CAAAA,CAAkBC,CAAC,CAAA,EAAG,KAAA,EAAS,SACtC,OAAA,CAASD,CAAAA,CAAkBC,CAAC,CAAA,EAAG,OAAA,EAAW,IAAA,CAC1C,MAAA,CAAQD,EAAkBC,CAAC,CAAA,EAAG,OAAO,MAAA,EAAU,CAAA,CAC/C,WAAYD,CAAAA,CAAkBC,CAAC,GAAG,UAAA,EAAc,IAAA,CAChD,WAAYD,CAAAA,CAAkBC,CAAC,GAAG,UAAA,EAAc,IAClD,EACF,CACF","file":"chunk-7EF47R2J.mjs","sourcesContent":["import { readExt, writeExt } from \"../../interface/ext.ts\";\nimport type { WorkflowState } from \"../../core/types.ts\";\nimport type { InvestigationState } from \"./state.ts\";\n\n/** The investigation record: `ext.investigation`, or the legacy field of a state written before 1.2. */\nexport const readInvestigation = (s: WorkflowState): InvestigationState | undefined =>\n readExt(s, \"investigation\");\n\n/** Stores the investigation record in `ext.investigation` and its deprecated legacy mirror (spec 26). */\nexport const writeInvestigation = (s: WorkflowState, x: InvestigationState): WorkflowState =>\n writeExt(s, \"investigation\", x);\n","import type { Handoff, Verdict, WorkflowState } from \"../../core/types.ts\";\n\ninterface Completion {\n id: string;\n verdict: Verdict;\n produced: Handoff[\"produced\"];\n}\n\n/** Completion actors come from validated handoffs, never caller-supplied accounting identity. */\nexport function executionActors(state: WorkflowState, item: string): string[] {\n return [\n ...new Set([\n ...state.events\n .filter(\n (event) => event.type === \"item.completed\" && (event.payload as Completion).id === item,\n )\n .map((event) => event.by),\n ...(state.items[item]?.transitions ?? [])\n .filter((transition) => transition.to.status === \"in_progress\")\n .map((transition) => transition.by),\n ]),\n ];\n}\n\n/** Only outputs of the latest successful completion can establish observation provenance. */\nexport function freshOutputRefs(state: WorkflowState, item: string): string[] {\n let completion: Completion | undefined;\n for (let index = state.events.length - 1; index >= 0; index--) {\n const event = state.events[index]!;\n if (event.type === \"item.completed\" && (event.payload as Completion).id === item) {\n completion = event.payload as Completion;\n break;\n }\n }\n return completion && [\"done\", \"needs-review\"].includes(completion.verdict)\n ? completion.produced\n .filter((output) => output.kind === \"experiment-output\")\n .map((output) => output.ref)\n : [];\n}\n","import { fail } from \"../../core/errors.ts\";\nimport type { Iteration, WorkflowState } from \"../../core/types.ts\";\nimport type { InvestigationState } from \"./state.ts\";\n\n/** A loaded state that breaks an invariant the ceremonies keep (a hand-edited or damaged file). */\nexport function brokenInvestigation(what: string): never {\n return fail(\n \"invalid-input\",\n `the investigation state is inconsistent: ${what}`,\n \"restore .workflow/state.json from git, or start a new investigation\",\n );\n}\n\n/** The latest round; the phases after preregister always have one. */\nexport function lastRound(x: InvestigationState): InvestigationState[\"rounds\"][number] {\n return x.rounds.at(-1) ?? brokenInvestigation(`phase ${x.phase} has no round`);\n}\n\n/** The `investigation` iteration intake opens; its budget bounds every round. */\nexport function investigationIteration(s: WorkflowState<string>): Iteration {\n return (\n s.iterations.find((it) => it.id === \"investigation\") ??\n brokenInvestigation('there is no \"investigation\" iteration')\n );\n}\n","import { fail } from \"../../core/errors.ts\";\nimport type { Budget } from \"../../core/types.ts\";\nexport interface InvestigationConfig {\n question: string;\n maxRounds: number;\n budget: Budget;\n}\nexport function validateInvestigationConfig(raw: unknown): InvestigationConfig {\n const c = raw as InvestigationConfig;\n if (\n !c ||\n typeof c !== \"object\" ||\n Array.isArray(c) ||\n typeof c.question !== \"string\" ||\n !c.question.trim() ||\n !Number.isSafeInteger(c.maxRounds) ||\n c.maxRounds < 1 ||\n !c.budget ||\n typeof c.budget !== \"object\" ||\n Array.isArray(c.budget) ||\n !Object.keys(c.budget).length ||\n Object.entries(c.budget).some(\n ([k, v]) =>\n ![\"tokens\", \"turns\", \"wallclockMs\"].includes(k) ||\n typeof v !== \"number\" ||\n !Number.isFinite(v) ||\n v <= 0,\n )\n )\n fail(\n \"config-invalid\",\n \"investigation requires question, positive maxRounds and a finite positive budget\",\n \"provide bounded investigation config\",\n );\n return { question: c.question, maxRounds: c.maxRounds, budget: { ...c.budget } };\n}\n","import { readInvestigation, writeInvestigation } from \"./record.ts\";\nimport { executionActors, freshOutputRefs } from \"./execution.ts\";\nimport { independenceConflicts } from \"../../common/independence.ts\";\nimport { frozenChanges } from \"../../common/frozen.ts\";\nimport { fail } from \"../../core/errors.ts\";\nimport { brokenInvestigation, investigationIteration, lastRound } from \"./invariants.ts\";\nimport { roleOf } from \"../../core/roles/lookup.ts\";\nimport { addItem } from \"../../core/items/record.ts\";\nimport { moveItem } from \"../../core/items/move.ts\";\nimport { applyAction } from \"../../core/methodology.ts\";\nimport { appendEvent, nowOf } from \"../../core/state.ts\";\nimport { isExhausted } from \"../../core/budget.ts\";\nimport type {\n Capability,\n Ceremony,\n CeremonyInput,\n Methodology,\n WorkflowState,\n} from \"../../core/types.ts\";\nimport { validateInvestigationConfig, type InvestigationConfig } from \"./config.ts\";\nimport type {\n BeliefUpdate,\n Experiment,\n Hypothesis,\n InvestigationConclusion,\n InvestigationState,\n Observation,\n} from \"./state.ts\";\nfunction reject(s: WorkflowState, name: string, message: string, fix: string): never {\n const x = readInvestigation(s);\n return fail(\"invalid-input\", `${name} (phase ${x?.phase ?? \"intake\"}): ${message}`, fix, {\n items: x ? [x.item, ...(x.rounds.at(-1) ? [x.rounds.at(-1)!.item] : [])] : [],\n });\n}\nconst sameHypothesis = (a: Hypothesis | undefined, b: Hypothesis | undefined) =>\n !!a && !!b && !frozenChanges(a, b, [\"id\", \"claim\", \"falsifiedBy\"]).length;\nconst text = (v: unknown): v is string => typeof v === \"string\" && v.trim().length > 0;\nconst refs = (v: unknown): v is string[] =>\n Array.isArray(v) && v.length > 0 && v.every(text) && new Set(v).size === v.length;\n/** First key of a caller record outside its contract; stored records are closed objects (state schema). */\nconst extraKey = (v: unknown, keys: readonly string[]): string | undefined =>\n v && typeof v === \"object\" && !Array.isArray(v)\n ? Object.keys(v).find((k) => !keys.includes(k))\n : undefined;\nconst extraKeyIn = (list: unknown, keys: readonly string[]): string | undefined =>\n Array.isArray(list) ? list.map((v) => extraKey(v, keys)).find(Boolean) : undefined;\nfunction authorize(s: WorkflowState, by: string, cap: Capability) {\n if (!roleOf(s, by)?.capabilities.includes(cap))\n fail(\n \"missing-capability\",\n `${by} needs ${cap}`,\n \"use a registered role with the required capability\",\n );\n}\nfunction save(s: WorkflowState, x: InvestigationState, i: CeremonyInput, name: string) {\n return appendEvent(\n writeInvestigation(s, x),\n `investigation.${name}`,\n i.by,\n { ...x },\n nowOf(i.now),\n );\n}\nexport function closeInvestigation(\n s: WorkflowState,\n x: InvestigationState,\n i: CeremonyInput,\n outcome: \"stopped\" | \"resolved\" | \"inconclusive\",\n reason?: string,\n) {\n const at = nowOf(i.now);\n let n = save(\n s,\n { ...x, phase: \"closed\", outcome, ...(reason ? { stopReason: reason } : {}) },\n i,\n outcome,\n );\n n = {\n ...n,\n iterations: n.iterations.map((it) =>\n it.id === \"investigation\"\n ? { ...it, endedAt: at, outcome: outcome === \"stopped\" ? \"cancelled\" : \"completed\" }\n : it,\n ),\n };\n for (const item of Object.values(n.items).filter(\n (candidate) => candidate.id === x.item || x.rounds.some((r) => r.item === candidate.id),\n ))\n if (item.status !== \"done\" && item.status !== \"dropped\")\n n = moveItem(\n n,\n item.id,\n { status: outcome === \"resolved\" && item.id === x.item ? \"done\" : \"dropped\" },\n i.by,\n at,\n );\n return n;\n}\nexport function investigationCeremonies(\n factory: () => Methodology<InvestigationConfig>,\n): Record<string, Ceremony> {\n let built: Methodology<InvestigationConfig> | undefined;\n const methodology = () => (built ??= factory());\n const make =\n (\n name: string,\n cap: Capability,\n phase: string | undefined,\n fn: (\n s: WorkflowState,\n x: InvestigationState,\n i: CeremonyInput,\n bad: (message: string, fix: string) => never,\n ) => WorkflowState,\n ): Ceremony =>\n (s, i) => {\n authorize(s, i.by, cap);\n const x = readInvestigation(s);\n if (!x || x.phase === \"closed\")\n reject(s, name, \"no active investigation\", \"start a new investigation with intake {item}\");\n if (phase && x.phase !== phase && !(name === \"hypotheses\" && x.phase === \"preregister\"))\n reject(\n s,\n name,\n `expected ${phase}, got ${x.phase}`,\n `finish phase ${x.phase} before calling ${name}; ${name} requires phase ${phase}`,\n );\n return applyAction(s, methodology(), { type: `ceremony.${name}`, by: i.by, payload: i }, () =>\n fn(s, x, i, (message, fix) => reject(s, name, message, fix)),\n );\n };\n return {\n intake(s, i) {\n authorize(s, i.by, \"facilitate\");\n const bad = (message: string, fix: string) => reject(s, \"intake\", message, fix);\n if (s.methodology !== \"investigation\")\n bad(\n `workflow methodology is ${s.methodology}, not investigation`,\n \"init a workflow with the investigation methodology before intake\",\n );\n if (readInvestigation(s))\n bad(\n \"investigation already started\",\n \"use the existing investigation or initialize a new workflow\",\n );\n if (!text(i.item))\n bad(\"item is required\", \"set intake.item to a unique investigation item ID\");\n const c = validateInvestigationConfig(s.config);\n return applyAction(\n s,\n methodology(),\n { type: \"ceremony.intake\", by: i.by, payload: i },\n () => {\n let n = addItem(\n s,\n {\n id: i.item as string,\n title: c.question,\n acceptance: [\"Independent evidence-based conclusion\"],\n stage: \"intake\",\n },\n i.by,\n i.now,\n );\n n = {\n ...n,\n iterations: [\n ...n.iterations,\n {\n id: \"investigation\",\n goal: c.question,\n budget: { ...c.budget },\n spent: { tokens: 0, turns: 0, wallclockMs: 0 },\n startedAt: nowOf(i.now),\n committed: [],\n carryover: [],\n },\n ],\n };\n return save(\n n,\n {\n item: i.item as string,\n phase: \"hypotheses\",\n hypotheses: [],\n rounds: [],\n contributors: [i.by],\n },\n i,\n \"intake\",\n );\n },\n );\n },\n hypotheses: make(\"hypotheses\", \"define-acceptance\", \"hypotheses\", (s, x, i, bad) => {\n const h = i.hypotheses as Hypothesis[];\n const extra = extraKeyIn(h, [\"id\", \"claim\", \"falsifiedBy\"]);\n if (extra)\n bad(\n `unknown key \"${extra}\" in a hypotheses entry`,\n \"use only id, claim and falsifiedBy in each hypotheses entry\",\n );\n if (\n !Array.isArray(h) ||\n !h.length ||\n h.some((v) => !v || !text(v.id) || !text(v.claim) || !text(v.falsifiedBy)) ||\n new Set(h.map((v) => v.id)).size !== h.length ||\n (h.length < 2 && !text(i.singleHypothesisRationale))\n )\n bad(\n \"provide competing falsifiable hypotheses or single-testable rationale\",\n \"set hypotheses to unique {id, claim, falsifiedBy} entries; supply singleHypothesisRationale when there is only one\",\n );\n return save(\n s,\n {\n ...x,\n hypotheses: h.map((v) => ({ id: v.id, claim: v.claim, falsifiedBy: v.falsifiedBy })),\n ...(text(i.singleHypothesisRationale)\n ? { singleHypothesisRationale: i.singleHypothesisRationale }\n : {}),\n contributors: [...new Set([...x.contributors, i.by])],\n phase: \"preregister\",\n },\n i,\n \"hypotheses\",\n );\n }),\n preregister: make(\"preregister\", \"define-acceptance\", \"preregister\", (s, x, i, bad) => {\n const c = validateInvestigationConfig(s.config),\n it = s.iterations.find((v) => v.id === \"investigation\");\n if (x.rounds.length >= c.maxRounds || !it || isExhausted(c.budget, it.spent))\n bad(\n `round limit or budget exhausted (${x.rounds.length} of ${c.maxRounds} rounds used)`,\n \"call stop {reason} to close this investigation, or start a new one with a larger maxRounds or budget\",\n );\n const e = i.experiment as Experiment;\n const extraExperiment =\n extraKey(e, [\"id\", \"procedureRef\", \"predictions\", \"replayOf\"]) ??\n extraKeyIn(e?.predictions, [\"hypothesis\", \"prediction\"]);\n if (extraExperiment)\n bad(\n `unknown key \"${extraExperiment}\" in experiment`,\n \"use only id, procedureRef, predictions [{hypothesis, prediction}] and replayOf in experiment\",\n );\n if (\n !e ||\n !text(e.id) ||\n !text(e.procedureRef) ||\n x.rounds.some((r) => r.experiment.id === e.id) ||\n !Array.isArray(e.predictions) ||\n e.predictions.length !== x.hypotheses.length ||\n x.hypotheses.some(\n (h) =>\n e.predictions.filter((p) => p?.hypothesis === h.id && text(p.prediction)).length !== 1,\n ) ||\n new Set(e.predictions.map((p) => p.prediction)).size !== e.predictions.length\n )\n bad(\n \"preregister unique experiment with differing predictions for every hypothesis\",\n \"set experiment.id to a new ID, experiment.procedureRef, and one distinct experiment.predictions entry per hypothesis\",\n );\n if (e.replayOf) {\n const prior = x.rounds.find((r) => r.experiment.id === e.replayOf && r.result?.valid);\n if (\n !prior ||\n frozenChanges(prior.experiment, e, [\"procedureRef\"]).length ||\n prior.hypotheses.length !== x.hypotheses.length ||\n x.hypotheses.some(\n (h) =>\n !sameHypothesis(\n h,\n prior.hypotheses.find((p) => p.id === h.id),\n ),\n ) ||\n e.predictions.some(\n (p) =>\n !prior.experiment.predictions.some(\n (q) => !frozenChanges(q, p, [\"hypothesis\", \"prediction\"]).length,\n ),\n )\n )\n bad(\n \"replay must repeat the procedure, predictions and hypotheses of a prior valid experiment\",\n \"set experiment.replayOf to a valid prior experiment with identical procedureRef, predictions and hypothesis definitions\",\n );\n }\n const id = `${x.item}-run-${x.rounds.length + 1}`;\n let n = addItem(\n s,\n {\n id,\n title: `Experiment ${e.id}`,\n stage: \"execute\",\n acceptance: [e.procedureRef],\n iteration: \"investigation\",\n },\n i.by,\n i.now,\n );\n n = {\n ...n,\n iterations: n.iterations.map((iteration) =>\n iteration.id === \"investigation\"\n ? { ...iteration, committed: [...iteration.committed, id] }\n : iteration,\n ),\n };\n return save(\n n,\n {\n ...x,\n phase: \"observe\",\n rounds: [\n ...x.rounds,\n {\n experiment: {\n id: e.id,\n procedureRef: e.procedureRef,\n predictions: e.predictions.map((p) => ({\n hypothesis: p.hypothesis,\n prediction: p.prediction,\n })),\n ...(e.replayOf ? { replayOf: e.replayOf } : {}),\n },\n hypotheses: x.hypotheses.map((v) => ({ ...v })),\n item: id,\n by: i.by,\n },\n ],\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"preregister\",\n );\n }),\n observe: make(\"observe\", \"verify\", \"observe\", (s, x, i, bad) => {\n const r = lastRound(x),\n o = i.result as Observation;\n const extra = extraKey(o, [\"id\", \"valid\", \"summary\", \"provenanceRefs\"]);\n if (extra)\n bad(\n `unknown key \"${extra}\" in result`,\n \"use only id, valid, summary and provenanceRefs in result\",\n );\n if (\n i.experiment !== r.experiment.id ||\n !o ||\n !text(o.id) ||\n typeof o.valid !== \"boolean\" ||\n !text(o.summary) ||\n !refs(o.provenanceRefs) ||\n x.rounds.some((prior) => prior.result?.id === o.id)\n )\n bad(\n \"observation needs current experiment, unique result and provenance\",\n \"set experiment to the active experiment ID and result to {id, valid, summary, provenanceRefs} with a new result.id\",\n );\n if (s.items[r.item]?.status !== \"done\")\n bad(\n \"complete experiment execution before recording observations\",\n \"dispatch and complete the active experiment item before calling observe\",\n );\n if (!freshOutputRefs(s, r.item).some((ref) => o.provenanceRefs.includes(ref)))\n bad(\n \"observation must link fresh experiment-output evidence from the latest completion\",\n `include an experiment-output ref produced by the latest successful completion of item \"${r.item}\" in result.provenanceRefs`,\n );\n return save(\n s,\n {\n ...x,\n phase: \"update-belief\",\n rounds: x.rounds.map((v) =>\n v === r\n ? {\n ...v,\n result: {\n id: o.id,\n valid: o.valid,\n summary: o.summary,\n provenanceRefs: [...o.provenanceRefs],\n },\n }\n : v,\n ),\n contributors: [...new Set([...x.contributors, i.by, ...executionActors(s, r.item)])],\n },\n i,\n \"observe\",\n );\n }),\n \"update-belief\": make(\"update-belief\", \"define-acceptance\", \"update-belief\", (s, x, i, bad) => {\n const r = lastRound(x),\n a = i.assessments as BeliefUpdate[\"assessments\"];\n const extra = extraKeyIn(a, [\"hypothesis\", \"assessment\", \"reason\"]);\n if (extra)\n bad(\n `unknown key \"${extra}\" in an assessments entry`,\n \"use only hypothesis, assessment and reason in each assessments entry\",\n );\n if (\n i.result !== r.result?.id ||\n !Array.isArray(a) ||\n a.length !== x.hypotheses.length ||\n x.hypotheses.some(\n (h) =>\n a.filter(\n (v) =>\n v?.hypothesis === h.id &&\n [\"supported\", \"refuted\", \"uncertain\"].includes(v.assessment) &&\n text(v.reason),\n ).length !== 1,\n ) ||\n ![\"round\", \"conclusion\"].includes(i.next as string)\n )\n bad(\n \"belief update must assess every hypothesis against current result\",\n \"set result to the latest result ID, assessments to one {hypothesis, assessment, reason} per hypothesis, and next to round or conclusion\",\n );\n const result = r.result ?? brokenInvestigation(`round ${r.experiment.id} has no result`);\n if (!result.valid && a.some((v) => v.assessment !== \"uncertain\"))\n bad(\n \"invalid experiments cannot support beliefs\",\n \"set every assessment to uncertain for an invalid experiment result\",\n );\n let n = save(\n s,\n {\n ...x,\n phase: i.next === \"round\" ? \"preregister\" : \"conclusion\",\n rounds: x.rounds.map((v) =>\n v === r\n ? {\n ...v,\n update: {\n result: i.result as string,\n assessments: a.map((entry) => ({\n hypothesis: entry.hypothesis,\n assessment: entry.assessment,\n reason: entry.reason,\n })),\n },\n }\n : v,\n ),\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"belief-updated\",\n );\n const it = investigationIteration(n);\n if (\n i.next === \"round\" &&\n (x.rounds.length >= validateInvestigationConfig(s.config).maxRounds ||\n isExhausted(it.budget, it.spent))\n )\n n = closeInvestigation(\n n,\n readInvestigation(n)!,\n i,\n \"stopped\",\n \"budget or round limit exhausted\",\n );\n return n;\n }),\n conclude: make(\"conclude\", \"define-acceptance\", \"conclusion\", (s, x, i, bad) => {\n const c = i as unknown as InvestigationConclusion;\n if (\n ![\"resolved\", \"inconclusive\"].includes(c.outcome) ||\n !text(c.summary) ||\n !refs(c.evidenceRefs) ||\n c.evidenceRefs.some((ref) => !x.rounds.some((r) => r.result?.provenanceRefs.includes(ref)))\n )\n bad(\n \"conclusion needs observed evidence references\",\n \"set outcome, summary and evidenceRefs to references preserved in recorded observations\",\n );\n if (\n c.outcome === \"resolved\" &&\n (!text(c.supportedHypothesis) ||\n !x.rounds\n .slice(-1)\n .some(\n (r) =>\n r.result?.valid &&\n r.update?.assessments.some(\n (a) => a.hypothesis === c.supportedHypothesis && a.assessment === \"supported\",\n ),\n ))\n )\n bad(\n \"resolved conclusion needs a supported hypothesis\",\n \"set supportedHypothesis to a hypothesis supported by the latest valid round, or choose outcome inconclusive\",\n );\n return save(\n s,\n {\n ...x,\n phase: \"review\",\n conclusion: {\n outcome: c.outcome,\n summary: c.summary,\n evidenceRefs: [...c.evidenceRefs],\n ...(c.supportedHypothesis ? { supportedHypothesis: c.supportedHypothesis } : {}),\n by: i.by,\n },\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"conclusion\",\n );\n }),\n \"review-conclusion\": make(\"review-conclusion\", \"review\", \"review\", (s, x, i, bad) => {\n const conclusion = x.conclusion ?? brokenInvestigation(\"phase review has no conclusion\");\n if (independenceConflicts(i.by, x.contributors).length)\n bad(\n \"conclusion reviewer must be independent of investigation contributors\",\n \"use a review-capable role that did not contribute to or execute this investigation\",\n );\n if (typeof i.approve !== \"boolean\" || !text(i.reason))\n bad(\n \"review needs approval and reason\",\n \"set approve to a boolean and reason to a nonempty review explanation\",\n );\n if (!i.approve) {\n const target = i.next ?? \"conclusion\";\n if (target !== \"round\" && target !== \"conclusion\")\n bad(\n \"review rejection next must be round or conclusion\",\n \"set next to round for more evidence or conclusion for a revised conclusion\",\n );\n const n = save(\n s,\n {\n ...x,\n phase: target === \"round\" ? \"preregister\" : \"conclusion\",\n reviewHistory: [\n ...(x.reviewHistory ?? []),\n {\n by: i.by,\n reason: i.reason as string,\n approve: false,\n next: target as \"round\" | \"conclusion\",\n replayRefs: [],\n },\n ],\n },\n i,\n \"review-rejected\",\n );\n const iteration = investigationIteration(s);\n if (\n target === \"round\" &&\n (x.rounds.length >= validateInvestigationConfig(s.config).maxRounds ||\n isExhausted(iteration.budget, iteration.spent))\n )\n return closeInvestigation(\n n,\n readInvestigation(n)!,\n i,\n \"stopped\",\n \"budget or round limit exhausted after review requested another round\",\n );\n return n;\n }\n const replayRefs = Array.isArray(i.replayRefs) ? i.replayRefs : [];\n if (\n conclusion.outcome === \"resolved\" &&\n (!refs(replayRefs) ||\n !x.rounds.some(\n (r) =>\n r.experiment.replayOf &&\n !independenceConflicts(\n executionActors(s, r.item),\n executionActors(\n s,\n (\n x.rounds.find((p) => p.experiment.id === r.experiment.replayOf) ??\n brokenInvestigation(\n `round ${r.experiment.id} replays the unknown experiment ${r.experiment.replayOf}`,\n )\n ).item,\n ),\n ).length &&\n sameHypothesis(\n r.hypotheses.find((h) => h.id === conclusion.supportedHypothesis),\n lastRound(x).hypotheses.find((h) => h.id === conclusion.supportedHypothesis),\n ) &&\n r.result?.valid &&\n replayRefs.includes(r.result.id) &&\n r.update?.assessments.some(\n (a) =>\n a.hypothesis === conclusion.supportedHypothesis && a.assessment === \"supported\",\n ),\n ))\n )\n bad(\n \"resolved conclusion requires valid replay result and supporting belief update\",\n \"set replayRefs to a valid independent replay result supporting the latest supported hypothesis definition, or reject with next round\",\n );\n return closeInvestigation(\n s,\n {\n ...x,\n review: { by: i.by, reason: i.reason as string, replayRefs: replayRefs as string[] },\n reviewHistory: [\n ...(x.reviewHistory ?? []),\n {\n by: i.by,\n reason: i.reason as string,\n approve: true,\n replayRefs: replayRefs as string[],\n },\n ],\n },\n i,\n conclusion.outcome,\n );\n }),\n stop: make(\"stop\", \"facilitate\", undefined, (s, x, i, bad) => {\n if (!text(i.reason))\n bad(\n \"stop needs reason\",\n \"set reason to a nonempty explanation for stopping this investigation\",\n );\n return closeInvestigation(s, x, i, \"stopped\", i.reason as string);\n }),\n };\n}\n","import { readInvestigation } from \"./record.ts\";\nimport { executionActors } from \"./execution.ts\";\nimport { independenceConflicts } from \"../../common/independence.ts\";\nimport type { Rule } from \"../../core/types.ts\";\nexport function investigationRules(): Rule[] {\n return [\n {\n id: \"independent-replay\",\n severity: \"error\",\n check(s, a) {\n if (a.type !== \"item.complete\") return [];\n const round = readInvestigation(s)?.rounds.find(\n (r) => r.item === (a.payload as { item?: string })?.item,\n );\n const prior = readInvestigation(s)?.rounds.find(\n (r) => r.experiment.id === round?.experiment.replayOf,\n );\n return prior && independenceConflicts(a.by, executionActors(s, prior.item)).length\n ? [\n {\n rule: \"independent-replay\",\n item: round!.item,\n severity: \"error\",\n message: \"Replay executor also executed the original experiment\",\n fix: \"assign a different deliver-capable role\",\n },\n ]\n : [];\n },\n },\n {\n id: \"investigation-execution-only\",\n severity: \"error\",\n check(s, a) {\n if (a.type !== \"item.complete\") return [];\n const p = a.payload as { item: string };\n const x = readInvestigation(s);\n return x?.phase === \"observe\" && x.rounds.at(-1)?.item === p.item\n ? []\n : [\n {\n rule: \"investigation-execution-only\",\n item: p.item,\n severity: \"error\",\n message: \"Only the active preregistered experiment can complete\",\n fix: `complete only the active experiment item in phase observe; current phase is ${x?.phase ?? \"intake\"}`,\n },\n ];\n },\n },\n ];\n}\n","import type { Role } from \"../../core/types.ts\";\nexport function investigationRoles(): Role[] {\n return [\n {\n id: \"replay-worker\",\n name: \"Independent replay worker\",\n modelTier: \"small\",\n capabilities: [\"deliver\", \"verify\"],\n canApprove: [],\n inputs: [\"preregistered-experiment\"],\n outputs: [\"experiment-output\"],\n do_not: [\"Do not change the replay procedure\"],\n },\n {\n id: \"investigator\",\n name: \"Investigator\",\n modelTier: \"large\",\n capabilities: [\"facilitate\", \"define-acceptance\", \"deliver\", \"verify\"],\n canApprove: [],\n inputs: [\"question\", \"prior-results\"],\n outputs: [\"hypotheses\", \"preregistered-experiment\", \"belief-update\"],\n do_not: [\"Do not revise predictions after execution\", \"Do not approve your own conclusions\"],\n },\n {\n id: \"conclusion-reviewer\",\n name: \"Independent conclusion reviewer\",\n modelTier: \"large\",\n capabilities: [\"review\"],\n canApprove: [\"investigation-conclusion\"],\n inputs: [\"evidence\", \"replay\", \"conclusion\"],\n outputs: [\"conclusion-review\"],\n do_not: [\"Do not approve unsupported conclusions\"],\n },\n ];\n}\n","import type { Stage } from \"../../core/types.ts\";\nexport function investigationStages(): Stage[] {\n return [\n {\n id: \"intake\",\n name: \"Intake\",\n entryPolicy: [],\n exitPolicy: [{ kind: \"acceptance-written\" }],\n },\n {\n id: \"execute\",\n name: \"Execute preregistered experiment\",\n entryPolicy: [{ kind: \"acceptance-written\" }, { kind: \"no-open-blockers\" }],\n exitPolicy: [{ kind: \"evidence\", evidenceKind: \"experiment-output\" }],\n },\n { id: \"observed\", name: \"Execution recorded\", entryPolicy: [], exitPolicy: [] },\n ];\n}\n","import { readInvestigation } from \"./record.ts\";\nimport { fail } from \"../../core/errors.ts\";\nimport { executionActors } from \"./execution.ts\";\nimport { independenceConflicts } from \"../../common/independence.ts\";\nimport { closeInvestigation, investigationCeremonies } from \"./ceremonies.ts\";\nimport { investigationIteration } from \"./invariants.ts\";\nimport { investigationRules } from \"./rules.ts\";\nimport { investigationRoles } from \"./roles.ts\";\nimport { investigationStages } from \"./stages.ts\";\nimport { isExhausted } from \"../../core/budget.ts\";\nimport type { Methodology } from \"../../core/types.ts\";\nimport { validateInvestigationConfig, type InvestigationConfig } from \"./config.ts\";\nexport { validateInvestigationConfig };\nexport type { InvestigationConfig };\nexport type * from \"./state.ts\";\nexport function investigation(): Methodology<InvestigationConfig> {\n return {\n name: \"investigation\",\n validateConfig: validateInvestigationConfig,\n lockedConfigKeys: [\"question\", \"maxRounds\", \"budget\"],\n vocabulary: {\n backlog: \"Questions\",\n item: \"Investigation artifact\",\n stage: \"Investigation phase\",\n iteration: \"Investigation budget\",\n increment: \"Conclusion\",\n ceremony: \"Investigation ceremony\",\n gate: \"Independent conclusion review\",\n },\n defaultStages: investigationStages,\n defaultRoles: investigationRoles,\n requiredCapabilities: [\"facilitate\", \"define-acceptance\", \"deliver\", \"verify\", \"review\"],\n exclusiveCapabilities: [],\n humanDefaults: { gates: \"none\" },\n ceremonies: investigationCeremonies(investigation),\n plannerOptions: (state) => ({\n schedulerMode: \"level\",\n concurrencyCap: 1,\n roleFor: (item) => {\n const r = readInvestigation(state)?.rounds.find((candidate) => candidate.item === item.id);\n const prior = readInvestigation(state)?.rounds.find(\n (p) => p.experiment.id === r?.experiment.replayOf,\n );\n const excluded = prior ? executionActors(state, prior.item) : [];\n const roles = Object.values(state.roles);\n const selected =\n (!prior\n ? roles.find(\n (role) =>\n role.capabilities.includes(\"deliver\") &&\n role.capabilities.includes(\"define-acceptance\"),\n )\n : undefined) ??\n roles.find(\n (role) =>\n role.capabilities.includes(\"deliver\") &&\n !independenceConflicts(role.id, excluded).length,\n );\n if (!selected)\n fail(\n \"missing-capability\",\n `No eligible executor for experiment item \"${item.id}\"`,\n prior\n ? `register an independent deliver-capable role that did not execute \"${prior.item}\"`\n : \"register a role with deliver capability\",\n { items: [item.id] },\n );\n return selected.id;\n },\n estimateMode: \"per-call\",\n fallbackTokensPerWeight: 1,\n }),\n candidates: (s) => {\n // read the record once, not once per item (U10 F2)\n const x = readInvestigation(s);\n const round = x?.rounds.at(-1)?.item;\n return x?.phase === \"observe\" &&\n !isExhausted((s.config as InvestigationConfig).budget, investigationIteration(s).spent)\n ? Object.values(s.items).filter(\n (i) => i.id === round && i.stage === \"execute\" && i.status === \"todo\",\n )\n : [];\n },\n afterComplete: (state, item, now) => {\n const x = readInvestigation(state);\n const iteration = state.iterations.find((it) => it.id === \"investigation\");\n if (\n x?.phase !== \"observe\" ||\n x.rounds.at(-1)?.item !== item ||\n state.items[item]?.status === \"done\" ||\n !iteration ||\n !isExhausted(iteration.budget, iteration.spent)\n )\n return state;\n return closeInvestigation(\n state,\n x,\n { by: \"investigation\", now },\n \"stopped\",\n `budget exhausted before experiment item \"${item}\" completed; start a new investigation with sufficient budget`,\n );\n },\n invariants: (s) => [\n `Question: ${(s.config as InvestigationConfig).question}`,\n \"Execute only the preregistered procedure; retain raw observation provenance; report invalid runs.\",\n ],\n rules: investigationRules(),\n metrics: (s) => ({\n rounds: readInvestigation(s)?.rounds.length ?? 0,\n validRuns: readInvestigation(s)?.rounds.filter((r) => r.result?.valid).length ?? 0,\n invalidRuns:\n readInvestigation(s)?.rounds.filter((r) => r.result && !r.result.valid).length ?? 0,\n }),\n report: (s) => ({\n phase: readInvestigation(s)?.phase ?? \"intake\",\n outcome: readInvestigation(s)?.outcome ?? null,\n rounds: readInvestigation(s)?.rounds.length ?? 0,\n conclusion: readInvestigation(s)?.conclusion ?? null,\n stopReason: readInvestigation(s)?.stopReason ?? null,\n }),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/methodologies/investigation/record.ts","../src/methodologies/investigation/execution.ts","../src/methodologies/investigation/invariants.ts","../src/methodologies/investigation/config.ts","../src/methodologies/investigation/ceremonies.ts","../src/methodologies/investigation/rules.ts","../src/methodologies/investigation/roles.ts","../src/methodologies/investigation/stages.ts","../src/methodologies/investigation/index.ts"],"names":["readInvestigation","s","readExt","writeInvestigation","x","writeExt","executionActors","state","item","event","transition","freshOutputRefs","completion","index","output","brokenInvestigation","what","fail","lastRound","investigationIteration","it","validateInvestigationConfig","raw","c","k","v","reject","name","message","fix","sameHypothesis","a","b","frozenChanges","text","refs","extraKey","keys","extraKeyIn","list","authorize","by","cap","roleOf","save","i","appendEvent","nowOf","closeInvestigation","outcome","reason","at","n","candidate","r","moveItem","investigationCeremonies","factory","built","methodology","make","phase","fn","applyAction","bad","addItem","h","extra","isExhausted","e","extraExperiment","p","prior","id","iteration","o","ref","entry","conclusion","independenceConflicts","target","replayRefs","investigationRules","round","investigationRoles","investigationStages","investigation","excluded","roles","selected","role","now"],"mappings":"iPAKO,IAAMA,EAAqBC,CAAAA,EAChCC,GAAAA,CAAQD,EAAG,eAAe,CAAA,CAGfE,EAAqB,CAACF,CAAAA,CAAkBG,CAAAA,GACnDC,GAAAA,CAASJ,EAAG,eAAA,CAAiBG,CAAC,ECDzB,SAASE,CAAAA,CAAgBC,EAAsBC,CAAAA,CAAwB,CAC5E,OAAO,CACL,GAAG,IAAI,GAAA,CAAI,CACT,GAAGD,CAAAA,CAAM,OACN,MAAA,CACEE,CAAAA,EAAUA,EAAM,IAAA,GAAS,gBAAA,EAAqBA,EAAM,OAAA,CAAuB,EAAA,GAAOD,CACrF,CAAA,CACC,GAAA,CAAKC,GAAUA,CAAAA,CAAM,EAAE,CAAA,CAC1B,GAAA,CAAIF,EAAM,KAAA,CAAMC,CAAI,GAAG,WAAA,EAAe,IACnC,MAAA,CAAQE,CAAAA,EAAeA,EAAW,EAAA,CAAG,MAAA,GAAW,aAAa,CAAA,CAC7D,GAAA,CAAKA,GAAeA,CAAAA,CAAW,EAAE,CACtC,CAAC,CACH,CACF,CAGO,SAASC,CAAAA,CAAgBJ,CAAAA,CAAsBC,EAAwB,CAC5E,IAAII,EACJ,IAAA,IAASC,CAAAA,CAAQN,EAAM,MAAA,CAAO,MAAA,CAAS,EAAGM,CAAAA,EAAS,CAAA,CAAGA,IAAS,CAC7D,IAAMJ,EAAQF,CAAAA,CAAM,MAAA,CAAOM,CAAK,CAAA,CAChC,GAAIJ,CAAAA,CAAM,IAAA,GAAS,kBAAqBA,CAAAA,CAAM,OAAA,CAAuB,KAAOD,CAAAA,CAAM,CAChFI,CAAAA,CAAaH,CAAAA,CAAM,QACnB,KACF,CACF,CACA,OAAOG,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AAkBC,CAAC,CAAA,EAAG,KAAA,EAAS,SACtC,OAAA,CAASD,CAAAA,CAAkBC,CAAC,CAAA,EAAG,OAAA,EAAW,IAAA,CAC1C,MAAA,CAAQD,EAAkBC,CAAC,CAAA,EAAG,OAAO,MAAA,EAAU,CAAA,CAC/C,WAAYD,CAAAA,CAAkBC,CAAC,GAAG,UAAA,EAAc,IAAA,CAChD,WAAYD,CAAAA,CAAkBC,CAAC,GAAG,UAAA,EAAc,IAClD,EACF,CACF","file":"chunk-OEHVWRJG.mjs","sourcesContent":["import { readExt, writeExt } from \"../../interface/ext.ts\";\nimport type { WorkflowState } from \"../../core/types.ts\";\nimport type { InvestigationState } from \"./state.ts\";\n\n/** The investigation record: `ext.investigation`, or the legacy field of a state written before 1.2. */\nexport const readInvestigation = (s: WorkflowState): InvestigationState | undefined =>\n readExt(s, \"investigation\");\n\n/** Stores the investigation record in `ext.investigation` and its deprecated legacy mirror (spec 26). */\nexport const writeInvestigation = (s: WorkflowState, x: InvestigationState): WorkflowState =>\n writeExt(s, \"investigation\", x);\n","import type { Handoff, Verdict, WorkflowState } from \"../../core/types.ts\";\n\ninterface Completion {\n id: string;\n verdict: Verdict;\n produced: Handoff[\"produced\"];\n}\n\n/** Completion actors come from validated handoffs, never caller-supplied accounting identity. */\nexport function executionActors(state: WorkflowState, item: string): string[] {\n return [\n ...new Set([\n ...state.events\n .filter(\n (event) => event.type === \"item.completed\" && (event.payload as Completion).id === item,\n )\n .map((event) => event.by),\n ...(state.items[item]?.transitions ?? [])\n .filter((transition) => transition.to.status === \"in_progress\")\n .map((transition) => transition.by),\n ]),\n ];\n}\n\n/** Only outputs of the latest successful completion can establish observation provenance. */\nexport function freshOutputRefs(state: WorkflowState, item: string): string[] {\n let completion: Completion | undefined;\n for (let index = state.events.length - 1; index >= 0; index--) {\n const event = state.events[index]!;\n if (event.type === \"item.completed\" && (event.payload as Completion).id === item) {\n completion = event.payload as Completion;\n break;\n }\n }\n return completion && [\"done\", \"needs-review\"].includes(completion.verdict)\n ? completion.produced\n .filter((output) => output.kind === \"experiment-output\")\n .map((output) => output.ref)\n : [];\n}\n","import { fail } from \"../../core/errors.ts\";\nimport type { Iteration, WorkflowState } from \"../../core/types.ts\";\nimport type { InvestigationState } from \"./state.ts\";\n\n/** A loaded state that breaks an invariant the ceremonies keep (a hand-edited or damaged file). */\nexport function brokenInvestigation(what: string): never {\n return fail(\n \"invalid-input\",\n `the investigation state is inconsistent: ${what}`,\n \"restore .workflow/state.json from git, or start a new investigation\",\n );\n}\n\n/** The latest round; the phases after preregister always have one. */\nexport function lastRound(x: InvestigationState): InvestigationState[\"rounds\"][number] {\n return x.rounds.at(-1) ?? brokenInvestigation(`phase ${x.phase} has no round`);\n}\n\n/** The `investigation` iteration intake opens; its budget bounds every round. */\nexport function investigationIteration(s: WorkflowState<string>): Iteration {\n return (\n s.iterations.find((it) => it.id === \"investigation\") ??\n brokenInvestigation('there is no \"investigation\" iteration')\n );\n}\n","import { fail } from \"../../core/errors.ts\";\nimport type { Budget } from \"../../core/types.ts\";\nexport interface InvestigationConfig {\n question: string;\n maxRounds: number;\n budget: Budget;\n}\nexport function validateInvestigationConfig(raw: unknown): InvestigationConfig {\n const c = raw as InvestigationConfig;\n if (\n !c ||\n typeof c !== \"object\" ||\n Array.isArray(c) ||\n typeof c.question !== \"string\" ||\n !c.question.trim() ||\n !Number.isSafeInteger(c.maxRounds) ||\n c.maxRounds < 1 ||\n !c.budget ||\n typeof c.budget !== \"object\" ||\n Array.isArray(c.budget) ||\n !Object.keys(c.budget).length ||\n Object.entries(c.budget).some(\n ([k, v]) =>\n ![\"tokens\", \"turns\", \"wallclockMs\"].includes(k) ||\n typeof v !== \"number\" ||\n !Number.isFinite(v) ||\n v <= 0,\n )\n )\n fail(\n \"config-invalid\",\n \"investigation requires question, positive maxRounds and a finite positive budget\",\n \"provide bounded investigation config\",\n );\n return { question: c.question, maxRounds: c.maxRounds, budget: { ...c.budget } };\n}\n","import { readInvestigation, writeInvestigation } from \"./record.ts\";\nimport { executionActors, freshOutputRefs } from \"./execution.ts\";\nimport { independenceConflicts } from \"../../common/independence.ts\";\nimport { frozenChanges } from \"../../common/frozen.ts\";\nimport { fail } from \"../../core/errors.ts\";\nimport { brokenInvestigation, investigationIteration, lastRound } from \"./invariants.ts\";\nimport { roleOf } from \"../../core/roles/lookup.ts\";\nimport { addItem } from \"../../core/items/record.ts\";\nimport { moveItem } from \"../../core/items/move.ts\";\nimport { applyAction } from \"../../core/methodology.ts\";\nimport { appendEvent, nowOf } from \"../../core/state.ts\";\nimport { isExhausted } from \"../../core/budget.ts\";\nimport type {\n Capability,\n Ceremony,\n CeremonyInput,\n Methodology,\n WorkflowState,\n} from \"../../core/types.ts\";\nimport { validateInvestigationConfig, type InvestigationConfig } from \"./config.ts\";\nimport type {\n BeliefUpdate,\n Experiment,\n Hypothesis,\n InvestigationConclusion,\n InvestigationState,\n Observation,\n} from \"./state.ts\";\nfunction reject(s: WorkflowState, name: string, message: string, fix: string): never {\n const x = readInvestigation(s);\n return fail(\"invalid-input\", `${name} (phase ${x?.phase ?? \"intake\"}): ${message}`, fix, {\n items: x ? [x.item, ...(x.rounds.at(-1) ? [x.rounds.at(-1)!.item] : [])] : [],\n });\n}\nconst sameHypothesis = (a: Hypothesis | undefined, b: Hypothesis | undefined) =>\n !!a && !!b && !frozenChanges(a, b, [\"id\", \"claim\", \"falsifiedBy\"]).length;\nconst text = (v: unknown): v is string => typeof v === \"string\" && v.trim().length > 0;\nconst refs = (v: unknown): v is string[] =>\n Array.isArray(v) && v.length > 0 && v.every(text) && new Set(v).size === v.length;\n/** First key of a caller record outside its contract; stored records are closed objects (state schema). */\nconst extraKey = (v: unknown, keys: readonly string[]): string | undefined =>\n v && typeof v === \"object\" && !Array.isArray(v)\n ? Object.keys(v).find((k) => !keys.includes(k))\n : undefined;\nconst extraKeyIn = (list: unknown, keys: readonly string[]): string | undefined =>\n Array.isArray(list) ? list.map((v) => extraKey(v, keys)).find(Boolean) : undefined;\nfunction authorize(s: WorkflowState, by: string, cap: Capability) {\n if (!roleOf(s, by)?.capabilities.includes(cap))\n fail(\n \"missing-capability\",\n `${by} needs ${cap}`,\n \"use a registered role with the required capability\",\n );\n}\nfunction save(s: WorkflowState, x: InvestigationState, i: CeremonyInput, name: string) {\n return appendEvent(\n writeInvestigation(s, x),\n `investigation.${name}`,\n i.by,\n { ...x },\n nowOf(i.now),\n );\n}\nexport function closeInvestigation(\n s: WorkflowState,\n x: InvestigationState,\n i: CeremonyInput,\n outcome: \"stopped\" | \"resolved\" | \"inconclusive\",\n reason?: string,\n) {\n const at = nowOf(i.now);\n let n = save(\n s,\n { ...x, phase: \"closed\", outcome, ...(reason ? { stopReason: reason } : {}) },\n i,\n outcome,\n );\n n = {\n ...n,\n iterations: n.iterations.map((it) =>\n it.id === \"investigation\"\n ? { ...it, endedAt: at, outcome: outcome === \"stopped\" ? \"cancelled\" : \"completed\" }\n : it,\n ),\n };\n for (const item of Object.values(n.items).filter(\n (candidate) => candidate.id === x.item || x.rounds.some((r) => r.item === candidate.id),\n ))\n if (item.status !== \"done\" && item.status !== \"dropped\")\n n = moveItem(\n n,\n item.id,\n { status: outcome === \"resolved\" && item.id === x.item ? \"done\" : \"dropped\" },\n i.by,\n at,\n );\n return n;\n}\nexport function investigationCeremonies(\n factory: () => Methodology<InvestigationConfig>,\n): Record<string, Ceremony> {\n let built: Methodology<InvestigationConfig> | undefined;\n const methodology = () => (built ??= factory());\n const make =\n (\n name: string,\n cap: Capability,\n phase: string | undefined,\n fn: (\n s: WorkflowState,\n x: InvestigationState,\n i: CeremonyInput,\n bad: (message: string, fix: string) => never,\n ) => WorkflowState,\n ): Ceremony =>\n (s, i) => {\n authorize(s, i.by, cap);\n const x = readInvestigation(s);\n if (!x || x.phase === \"closed\")\n reject(s, name, \"no active investigation\", \"start a new investigation with intake {item}\");\n if (phase && x.phase !== phase && !(name === \"hypotheses\" && x.phase === \"preregister\"))\n reject(\n s,\n name,\n `expected ${phase}, got ${x.phase}`,\n `finish phase ${x.phase} before calling ${name}; ${name} requires phase ${phase}`,\n );\n return applyAction(s, methodology(), { type: `ceremony.${name}`, by: i.by, payload: i }, () =>\n fn(s, x, i, (message, fix) => reject(s, name, message, fix)),\n );\n };\n return {\n intake(s, i) {\n authorize(s, i.by, \"facilitate\");\n const bad = (message: string, fix: string) => reject(s, \"intake\", message, fix);\n if (s.methodology !== \"investigation\")\n bad(\n `workflow methodology is ${s.methodology}, not investigation`,\n \"init a workflow with the investigation methodology before intake\",\n );\n if (readInvestigation(s))\n bad(\n \"investigation already started\",\n \"use the existing investigation or initialize a new workflow\",\n );\n if (!text(i.item))\n bad(\"item is required\", \"set intake.item to a unique investigation item ID\");\n const c = validateInvestigationConfig(s.config);\n return applyAction(\n s,\n methodology(),\n { type: \"ceremony.intake\", by: i.by, payload: i },\n () => {\n let n = addItem(\n s,\n {\n id: i.item as string,\n title: c.question,\n acceptance: [\"Independent evidence-based conclusion\"],\n stage: \"intake\",\n },\n i.by,\n i.now,\n );\n n = {\n ...n,\n iterations: [\n ...n.iterations,\n {\n id: \"investigation\",\n goal: c.question,\n budget: { ...c.budget },\n spent: { tokens: 0, turns: 0, wallclockMs: 0 },\n startedAt: nowOf(i.now),\n committed: [],\n carryover: [],\n },\n ],\n };\n return save(\n n,\n {\n item: i.item as string,\n phase: \"hypotheses\",\n hypotheses: [],\n rounds: [],\n contributors: [i.by],\n },\n i,\n \"intake\",\n );\n },\n );\n },\n hypotheses: make(\"hypotheses\", \"define-acceptance\", \"hypotheses\", (s, x, i, bad) => {\n const h = i.hypotheses as Hypothesis[];\n const extra = extraKeyIn(h, [\"id\", \"claim\", \"falsifiedBy\"]);\n if (extra)\n bad(\n `unknown key \"${extra}\" in a hypotheses entry`,\n \"use only id, claim and falsifiedBy in each hypotheses entry\",\n );\n if (\n !Array.isArray(h) ||\n !h.length ||\n h.some((v) => !v || !text(v.id) || !text(v.claim) || !text(v.falsifiedBy)) ||\n new Set(h.map((v) => v.id)).size !== h.length ||\n (h.length < 2 && !text(i.singleHypothesisRationale))\n )\n bad(\n \"provide competing falsifiable hypotheses or single-testable rationale\",\n \"set hypotheses to unique {id, claim, falsifiedBy} entries; supply singleHypothesisRationale when there is only one\",\n );\n return save(\n s,\n {\n ...x,\n hypotheses: h.map((v) => ({ id: v.id, claim: v.claim, falsifiedBy: v.falsifiedBy })),\n ...(text(i.singleHypothesisRationale)\n ? { singleHypothesisRationale: i.singleHypothesisRationale }\n : {}),\n contributors: [...new Set([...x.contributors, i.by])],\n phase: \"preregister\",\n },\n i,\n \"hypotheses\",\n );\n }),\n preregister: make(\"preregister\", \"define-acceptance\", \"preregister\", (s, x, i, bad) => {\n const c = validateInvestigationConfig(s.config),\n it = s.iterations.find((v) => v.id === \"investigation\");\n if (x.rounds.length >= c.maxRounds || !it || isExhausted(c.budget, it.spent))\n bad(\n `round limit or budget exhausted (${x.rounds.length} of ${c.maxRounds} rounds used)`,\n \"call stop {reason} to close this investigation, or start a new one with a larger maxRounds or budget\",\n );\n const e = i.experiment as Experiment;\n const extraExperiment =\n extraKey(e, [\"id\", \"procedureRef\", \"predictions\", \"replayOf\"]) ??\n extraKeyIn(e?.predictions, [\"hypothesis\", \"prediction\"]);\n if (extraExperiment)\n bad(\n `unknown key \"${extraExperiment}\" in experiment`,\n \"use only id, procedureRef, predictions [{hypothesis, prediction}] and replayOf in experiment\",\n );\n if (\n !e ||\n !text(e.id) ||\n !text(e.procedureRef) ||\n x.rounds.some((r) => r.experiment.id === e.id) ||\n !Array.isArray(e.predictions) ||\n e.predictions.length !== x.hypotheses.length ||\n x.hypotheses.some(\n (h) =>\n e.predictions.filter((p) => p?.hypothesis === h.id && text(p.prediction)).length !== 1,\n ) ||\n new Set(e.predictions.map((p) => p.prediction)).size !== e.predictions.length\n )\n bad(\n \"preregister unique experiment with differing predictions for every hypothesis\",\n \"set experiment.id to a new ID, experiment.procedureRef, and one distinct experiment.predictions entry per hypothesis\",\n );\n if (e.replayOf) {\n const prior = x.rounds.find((r) => r.experiment.id === e.replayOf && r.result?.valid);\n if (\n !prior ||\n frozenChanges(prior.experiment, e, [\"procedureRef\"]).length ||\n prior.hypotheses.length !== x.hypotheses.length ||\n x.hypotheses.some(\n (h) =>\n !sameHypothesis(\n h,\n prior.hypotheses.find((p) => p.id === h.id),\n ),\n ) ||\n e.predictions.some(\n (p) =>\n !prior.experiment.predictions.some(\n (q) => !frozenChanges(q, p, [\"hypothesis\", \"prediction\"]).length,\n ),\n )\n )\n bad(\n \"replay must repeat the procedure, predictions and hypotheses of a prior valid experiment\",\n \"set experiment.replayOf to a valid prior experiment with identical procedureRef, predictions and hypothesis definitions\",\n );\n }\n const id = `${x.item}-run-${x.rounds.length + 1}`;\n let n = addItem(\n s,\n {\n id,\n title: `Experiment ${e.id}`,\n stage: \"execute\",\n acceptance: [e.procedureRef],\n iteration: \"investigation\",\n },\n i.by,\n i.now,\n );\n n = {\n ...n,\n iterations: n.iterations.map((iteration) =>\n iteration.id === \"investigation\"\n ? { ...iteration, committed: [...iteration.committed, id] }\n : iteration,\n ),\n };\n return save(\n n,\n {\n ...x,\n phase: \"observe\",\n rounds: [\n ...x.rounds,\n {\n experiment: {\n id: e.id,\n procedureRef: e.procedureRef,\n predictions: e.predictions.map((p) => ({\n hypothesis: p.hypothesis,\n prediction: p.prediction,\n })),\n ...(e.replayOf ? { replayOf: e.replayOf } : {}),\n },\n hypotheses: x.hypotheses.map((v) => ({ ...v })),\n item: id,\n by: i.by,\n },\n ],\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"preregister\",\n );\n }),\n observe: make(\"observe\", \"verify\", \"observe\", (s, x, i, bad) => {\n const r = lastRound(x),\n o = i.result as Observation;\n const extra = extraKey(o, [\"id\", \"valid\", \"summary\", \"provenanceRefs\"]);\n if (extra)\n bad(\n `unknown key \"${extra}\" in result`,\n \"use only id, valid, summary and provenanceRefs in result\",\n );\n if (\n i.experiment !== r.experiment.id ||\n !o ||\n !text(o.id) ||\n typeof o.valid !== \"boolean\" ||\n !text(o.summary) ||\n !refs(o.provenanceRefs) ||\n x.rounds.some((prior) => prior.result?.id === o.id)\n )\n bad(\n \"observation needs current experiment, unique result and provenance\",\n \"set experiment to the active experiment ID and result to {id, valid, summary, provenanceRefs} with a new result.id\",\n );\n if (s.items[r.item]?.status !== \"done\")\n bad(\n \"complete experiment execution before recording observations\",\n \"dispatch and complete the active experiment item before calling observe\",\n );\n if (!freshOutputRefs(s, r.item).some((ref) => o.provenanceRefs.includes(ref)))\n bad(\n \"observation must link fresh experiment-output evidence from the latest completion\",\n `include an experiment-output ref produced by the latest successful completion of item \"${r.item}\" in result.provenanceRefs`,\n );\n return save(\n s,\n {\n ...x,\n phase: \"update-belief\",\n rounds: x.rounds.map((v) =>\n v === r\n ? {\n ...v,\n result: {\n id: o.id,\n valid: o.valid,\n summary: o.summary,\n provenanceRefs: [...o.provenanceRefs],\n },\n }\n : v,\n ),\n contributors: [...new Set([...x.contributors, i.by, ...executionActors(s, r.item)])],\n },\n i,\n \"observe\",\n );\n }),\n \"update-belief\": make(\"update-belief\", \"define-acceptance\", \"update-belief\", (s, x, i, bad) => {\n const r = lastRound(x),\n a = i.assessments as BeliefUpdate[\"assessments\"];\n const extra = extraKeyIn(a, [\"hypothesis\", \"assessment\", \"reason\"]);\n if (extra)\n bad(\n `unknown key \"${extra}\" in an assessments entry`,\n \"use only hypothesis, assessment and reason in each assessments entry\",\n );\n if (\n i.result !== r.result?.id ||\n !Array.isArray(a) ||\n a.length !== x.hypotheses.length ||\n x.hypotheses.some(\n (h) =>\n a.filter(\n (v) =>\n v?.hypothesis === h.id &&\n [\"supported\", \"refuted\", \"uncertain\"].includes(v.assessment) &&\n text(v.reason),\n ).length !== 1,\n ) ||\n ![\"round\", \"conclusion\"].includes(i.next as string)\n )\n bad(\n \"belief update must assess every hypothesis against current result\",\n \"set result to the latest result ID, assessments to one {hypothesis, assessment, reason} per hypothesis, and next to round or conclusion\",\n );\n const result = r.result ?? brokenInvestigation(`round ${r.experiment.id} has no result`);\n if (!result.valid && a.some((v) => v.assessment !== \"uncertain\"))\n bad(\n \"invalid experiments cannot support beliefs\",\n \"set every assessment to uncertain for an invalid experiment result\",\n );\n let n = save(\n s,\n {\n ...x,\n phase: i.next === \"round\" ? \"preregister\" : \"conclusion\",\n rounds: x.rounds.map((v) =>\n v === r\n ? {\n ...v,\n update: {\n result: i.result as string,\n assessments: a.map((entry) => ({\n hypothesis: entry.hypothesis,\n assessment: entry.assessment,\n reason: entry.reason,\n })),\n },\n }\n : v,\n ),\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"belief-updated\",\n );\n const it = investigationIteration(n);\n if (\n i.next === \"round\" &&\n (x.rounds.length >= validateInvestigationConfig(s.config).maxRounds ||\n isExhausted(it.budget, it.spent))\n )\n n = closeInvestigation(\n n,\n readInvestigation(n)!,\n i,\n \"stopped\",\n \"budget or round limit exhausted\",\n );\n return n;\n }),\n conclude: make(\"conclude\", \"define-acceptance\", \"conclusion\", (s, x, i, bad) => {\n const c = i as unknown as InvestigationConclusion;\n if (\n ![\"resolved\", \"inconclusive\"].includes(c.outcome) ||\n !text(c.summary) ||\n !refs(c.evidenceRefs) ||\n c.evidenceRefs.some((ref) => !x.rounds.some((r) => r.result?.provenanceRefs.includes(ref)))\n )\n bad(\n \"conclusion needs observed evidence references\",\n \"set outcome, summary and evidenceRefs to references preserved in recorded observations\",\n );\n if (\n c.outcome === \"resolved\" &&\n (!text(c.supportedHypothesis) ||\n !x.rounds\n .slice(-1)\n .some(\n (r) =>\n r.result?.valid &&\n r.update?.assessments.some(\n (a) => a.hypothesis === c.supportedHypothesis && a.assessment === \"supported\",\n ),\n ))\n )\n bad(\n \"resolved conclusion needs a supported hypothesis\",\n \"set supportedHypothesis to a hypothesis supported by the latest valid round, or choose outcome inconclusive\",\n );\n return save(\n s,\n {\n ...x,\n phase: \"review\",\n conclusion: {\n outcome: c.outcome,\n summary: c.summary,\n evidenceRefs: [...c.evidenceRefs],\n ...(c.supportedHypothesis ? { supportedHypothesis: c.supportedHypothesis } : {}),\n by: i.by,\n },\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"conclusion\",\n );\n }),\n \"review-conclusion\": make(\"review-conclusion\", \"review\", \"review\", (s, x, i, bad) => {\n const conclusion = x.conclusion ?? brokenInvestigation(\"phase review has no conclusion\");\n if (independenceConflicts(i.by, x.contributors).length)\n bad(\n \"conclusion reviewer must be independent of investigation contributors\",\n \"use a review-capable role that did not contribute to or execute this investigation\",\n );\n if (typeof i.approve !== \"boolean\" || !text(i.reason))\n bad(\n \"review needs approval and reason\",\n \"set approve to a boolean and reason to a nonempty review explanation\",\n );\n if (!i.approve) {\n const target = i.next ?? \"conclusion\";\n if (target !== \"round\" && target !== \"conclusion\")\n bad(\n \"review rejection next must be round or conclusion\",\n \"set next to round for more evidence or conclusion for a revised conclusion\",\n );\n const n = save(\n s,\n {\n ...x,\n phase: target === \"round\" ? \"preregister\" : \"conclusion\",\n reviewHistory: [\n ...(x.reviewHistory ?? []),\n {\n by: i.by,\n reason: i.reason as string,\n approve: false,\n next: target as \"round\" | \"conclusion\",\n replayRefs: [],\n },\n ],\n },\n i,\n \"review-rejected\",\n );\n const iteration = investigationIteration(s);\n if (\n target === \"round\" &&\n (x.rounds.length >= validateInvestigationConfig(s.config).maxRounds ||\n isExhausted(iteration.budget, iteration.spent))\n )\n return closeInvestigation(\n n,\n readInvestigation(n)!,\n i,\n \"stopped\",\n \"budget or round limit exhausted after review requested another round\",\n );\n return n;\n }\n const replayRefs = Array.isArray(i.replayRefs) ? i.replayRefs : [];\n if (\n conclusion.outcome === \"resolved\" &&\n (!refs(replayRefs) ||\n !x.rounds.some(\n (r) =>\n r.experiment.replayOf &&\n !independenceConflicts(\n executionActors(s, r.item),\n executionActors(\n s,\n (\n x.rounds.find((p) => p.experiment.id === r.experiment.replayOf) ??\n brokenInvestigation(\n `round ${r.experiment.id} replays the unknown experiment ${r.experiment.replayOf}`,\n )\n ).item,\n ),\n ).length &&\n sameHypothesis(\n r.hypotheses.find((h) => h.id === conclusion.supportedHypothesis),\n lastRound(x).hypotheses.find((h) => h.id === conclusion.supportedHypothesis),\n ) &&\n r.result?.valid &&\n replayRefs.includes(r.result.id) &&\n r.update?.assessments.some(\n (a) =>\n a.hypothesis === conclusion.supportedHypothesis && a.assessment === \"supported\",\n ),\n ))\n )\n bad(\n \"resolved conclusion requires valid replay result and supporting belief update\",\n \"set replayRefs to a valid independent replay result supporting the latest supported hypothesis definition, or reject with next round\",\n );\n return closeInvestigation(\n s,\n {\n ...x,\n review: { by: i.by, reason: i.reason as string, replayRefs: replayRefs as string[] },\n reviewHistory: [\n ...(x.reviewHistory ?? []),\n {\n by: i.by,\n reason: i.reason as string,\n approve: true,\n replayRefs: replayRefs as string[],\n },\n ],\n },\n i,\n conclusion.outcome,\n );\n }),\n stop: make(\"stop\", \"facilitate\", undefined, (s, x, i, bad) => {\n if (!text(i.reason))\n bad(\n \"stop needs reason\",\n \"set reason to a nonempty explanation for stopping this investigation\",\n );\n return closeInvestigation(s, x, i, \"stopped\", i.reason as string);\n }),\n };\n}\n","import { readInvestigation } from \"./record.ts\";\nimport { executionActors } from \"./execution.ts\";\nimport { independenceConflicts } from \"../../common/independence.ts\";\nimport type { Rule } from \"../../core/types.ts\";\nexport function investigationRules(): Rule[] {\n return [\n {\n id: \"independent-replay\",\n severity: \"error\",\n check(s, a) {\n if (a.type !== \"item.complete\") return [];\n const round = readInvestigation(s)?.rounds.find(\n (r) => r.item === (a.payload as { item?: string })?.item,\n );\n const prior = readInvestigation(s)?.rounds.find(\n (r) => r.experiment.id === round?.experiment.replayOf,\n );\n return prior && independenceConflicts(a.by, executionActors(s, prior.item)).length\n ? [\n {\n rule: \"independent-replay\",\n item: round!.item,\n severity: \"error\",\n message: \"Replay executor also executed the original experiment\",\n fix: \"assign a different deliver-capable role\",\n },\n ]\n : [];\n },\n },\n {\n id: \"investigation-execution-only\",\n severity: \"error\",\n check(s, a) {\n if (a.type !== \"item.complete\") return [];\n const p = a.payload as { item: string };\n const x = readInvestigation(s);\n return x?.phase === \"observe\" && x.rounds.at(-1)?.item === p.item\n ? []\n : [\n {\n rule: \"investigation-execution-only\",\n item: p.item,\n severity: \"error\",\n message: \"Only the active preregistered experiment can complete\",\n fix: `complete only the active experiment item in phase observe; current phase is ${x?.phase ?? \"intake\"}`,\n },\n ];\n },\n },\n ];\n}\n","import type { Role } from \"../../core/types.ts\";\nexport function investigationRoles(): Role[] {\n return [\n {\n id: \"replay-worker\",\n name: \"Independent replay worker\",\n modelTier: \"small\",\n capabilities: [\"deliver\", \"verify\"],\n canApprove: [],\n inputs: [\"preregistered-experiment\"],\n outputs: [\"experiment-output\"],\n do_not: [\"Do not change the replay procedure\"],\n },\n {\n id: \"investigator\",\n name: \"Investigator\",\n modelTier: \"large\",\n capabilities: [\"facilitate\", \"define-acceptance\", \"deliver\", \"verify\"],\n canApprove: [],\n inputs: [\"question\", \"prior-results\"],\n outputs: [\"hypotheses\", \"preregistered-experiment\", \"belief-update\"],\n do_not: [\"Do not revise predictions after execution\", \"Do not approve your own conclusions\"],\n },\n {\n id: \"conclusion-reviewer\",\n name: \"Independent conclusion reviewer\",\n modelTier: \"large\",\n capabilities: [\"review\"],\n canApprove: [\"investigation-conclusion\"],\n inputs: [\"evidence\", \"replay\", \"conclusion\"],\n outputs: [\"conclusion-review\"],\n do_not: [\"Do not approve unsupported conclusions\"],\n },\n ];\n}\n","import type { Stage } from \"../../core/types.ts\";\nexport function investigationStages(): Stage[] {\n return [\n {\n id: \"intake\",\n name: \"Intake\",\n entryPolicy: [],\n exitPolicy: [{ kind: \"acceptance-written\" }],\n },\n {\n id: \"execute\",\n name: \"Execute preregistered experiment\",\n entryPolicy: [{ kind: \"acceptance-written\" }, { kind: \"no-open-blockers\" }],\n exitPolicy: [{ kind: \"evidence\", evidenceKind: \"experiment-output\" }],\n },\n { id: \"observed\", name: \"Execution recorded\", entryPolicy: [], exitPolicy: [] },\n ];\n}\n","import { readInvestigation } from \"./record.ts\";\nimport { fail } from \"../../core/errors.ts\";\nimport { executionActors } from \"./execution.ts\";\nimport { independenceConflicts } from \"../../common/independence.ts\";\nimport { closeInvestigation, investigationCeremonies } from \"./ceremonies.ts\";\nimport { investigationIteration } from \"./invariants.ts\";\nimport { investigationRules } from \"./rules.ts\";\nimport { investigationRoles } from \"./roles.ts\";\nimport { investigationStages } from \"./stages.ts\";\nimport { isExhausted } from \"../../core/budget.ts\";\nimport type { Methodology } from \"../../core/types.ts\";\nimport { validateInvestigationConfig, type InvestigationConfig } from \"./config.ts\";\nexport { validateInvestigationConfig };\nexport type { InvestigationConfig };\nexport type * from \"./state.ts\";\nexport function investigation(): Methodology<InvestigationConfig> {\n return {\n name: \"investigation\",\n validateConfig: validateInvestigationConfig,\n lockedConfigKeys: [\"question\", \"maxRounds\", \"budget\"],\n vocabulary: {\n backlog: \"Questions\",\n item: \"Investigation artifact\",\n stage: \"Investigation phase\",\n iteration: \"Investigation budget\",\n increment: \"Conclusion\",\n ceremony: \"Investigation ceremony\",\n gate: \"Independent conclusion review\",\n },\n defaultStages: investigationStages,\n defaultRoles: investigationRoles,\n requiredCapabilities: [\"facilitate\", \"define-acceptance\", \"deliver\", \"verify\", \"review\"],\n exclusiveCapabilities: [],\n humanDefaults: { gates: \"none\" },\n ceremonies: investigationCeremonies(investigation),\n plannerOptions: (state) => ({\n schedulerMode: \"level\",\n concurrencyCap: 1,\n roleFor: (item) => {\n const r = readInvestigation(state)?.rounds.find((candidate) => candidate.item === item.id);\n const prior = readInvestigation(state)?.rounds.find(\n (p) => p.experiment.id === r?.experiment.replayOf,\n );\n const excluded = prior ? executionActors(state, prior.item) : [];\n const roles = Object.values(state.roles);\n const selected =\n (!prior\n ? roles.find(\n (role) =>\n role.capabilities.includes(\"deliver\") &&\n role.capabilities.includes(\"define-acceptance\"),\n )\n : undefined) ??\n roles.find(\n (role) =>\n role.capabilities.includes(\"deliver\") &&\n !independenceConflicts(role.id, excluded).length,\n );\n if (!selected)\n fail(\n \"missing-capability\",\n `No eligible executor for experiment item \"${item.id}\"`,\n prior\n ? `register an independent deliver-capable role that did not execute \"${prior.item}\"`\n : \"register a role with deliver capability\",\n { items: [item.id] },\n );\n return selected.id;\n },\n estimateMode: \"per-call\",\n fallbackTokensPerWeight: 1,\n }),\n candidates: (s) => {\n // read the record once, not once per item (U10 F2)\n const x = readInvestigation(s);\n const round = x?.rounds.at(-1)?.item;\n return x?.phase === \"observe\" &&\n !isExhausted((s.config as InvestigationConfig).budget, investigationIteration(s).spent)\n ? Object.values(s.items).filter(\n (i) => i.id === round && i.stage === \"execute\" && i.status === \"todo\",\n )\n : [];\n },\n afterComplete: (state, item, now) => {\n const x = readInvestigation(state);\n const iteration = state.iterations.find((it) => it.id === \"investigation\");\n if (\n x?.phase !== \"observe\" ||\n x.rounds.at(-1)?.item !== item ||\n state.items[item]?.status === \"done\" ||\n !iteration ||\n !isExhausted(iteration.budget, iteration.spent)\n )\n return state;\n return closeInvestigation(\n state,\n x,\n { by: \"investigation\", now },\n \"stopped\",\n `budget exhausted before experiment item \"${item}\" completed; start a new investigation with sufficient budget`,\n );\n },\n invariants: (s) => [\n `Question: ${(s.config as InvestigationConfig).question}`,\n \"Execute only the preregistered procedure; retain raw observation provenance; report invalid runs.\",\n ],\n rules: investigationRules(),\n metrics: (s) => ({\n rounds: readInvestigation(s)?.rounds.length ?? 0,\n validRuns: readInvestigation(s)?.rounds.filter((r) => r.result?.valid).length ?? 0,\n invalidRuns:\n readInvestigation(s)?.rounds.filter((r) => r.result && !r.result.valid).length ?? 0,\n }),\n report: (s) => ({\n phase: readInvestigation(s)?.phase ?? \"intake\",\n outcome: readInvestigation(s)?.outcome ?? null,\n rounds: readInvestigation(s)?.rounds.length ?? 0,\n conclusion: readInvestigation(s)?.conclusion ?? null,\n stopReason: readInvestigation(s)?.stopReason ?? null,\n }),\n };\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {d,c as c$1}from'./chunk-TQR3VFZU.mjs';import {b as b$1,e,d as d$1}from'./chunk-
|
|
1
|
+
import {d,c as c$1}from'./chunk-TQR3VFZU.mjs';import {b as b$1,e,d as d$1}from'./chunk-QJMOCISZ.mjs';import {b}from'./chunk-YS6CXERQ.mjs';import {mkdir,open,stat,unlink,readFile,readdir,writeFile,rename}from'fs/promises';import {randomBytes}from'crypto';import c from'path';var u=".workflow";function g(t){return c.join(t,u,"state.json")}async function k(t,e){let i=`${t}.tmp-${process.pid}-${randomBytes(4).toString("hex")}`;try{await mkdir(c.dirname(t),{recursive:!0}),await writeFile(i,e,"utf8"),await rename(i,t);}catch(n){await unlink(i).catch(()=>{}),b("invalid-input",`cannot write ${t}: ${n.message}`,"check the directory exists and is writable");}}async function z(t,e,i={}){let{retries:n=40,intervalMs:l=50,staleMs:d=6e4}=i,r=c.join(t,u,"state.lock"),m=a=>b("invalid-input",`cannot create ${r}: ${a.message}`,`check that ${c.dirname(r)} is a writable directory`);await mkdir(c.dirname(r),{recursive:true}).catch(m);let s=false;for(let a=0;!s;a++)try{let f=await open(r,"wx");await f.writeFile(`${process.pid} ${new Date().toISOString()}
|
|
2
2
|
`),await f.close(),s=!0;}catch(f){f.code!=="EEXIST"&&m(f);let w=await stat(r).catch(()=>{});if(w&&Date.now()-w.mtimeMs>d){a>n&&b("invalid-input",`cannot remove the stale lock ${r}`,`delete ${r} by hand (check its permissions) once no exwf process is running`);let h=await stat(r).catch(()=>{});h&&h.ino===w.ino&&h.mtimeMs===w.mtimeMs&&(await unlink(r).then(()=>true,()=>false)||await new Promise(T=>setTimeout(T,l)));continue}a>=n&&b("invalid-input","another exwf command holds .workflow/state.lock","retry, or delete the file if no exwf process is running"),await new Promise(h=>setTimeout(h,l));}try{return await e()}finally{await unlink(r).catch(()=>{});}}function $(t,e){try{return e()}catch(i){throw i instanceof RangeError&&/maximum call stack size exceeded/i.test(i.message)&&b("invalid-input",`${t} is nested too deeply to process (${i.message})`,"flatten the deeply nested value (an array or object thousands of levels deep)"),i}}async function K(t,e){let i=$(g(t),()=>{let n=JSON.stringify(c$1(e),null,2)+`
|
|
3
3
|
`;return b$1(d$1,JSON.parse(n),g(t)),n});await k(g(t),i);}async function U(t){let e$1=g(t),i;try{i=await readFile(e$1,"utf8");}catch{b("invalid-input",`no workflow state at ${e$1}`,"run `exwf init <scrum|kanban|waterfall> --config <file>` in this directory first");}let n;try{n=JSON.parse(i);}catch(s){s instanceof RangeError&&$(e$1,()=>{throw s}),b("invalid-input",`${e$1} is not valid JSON: ${s.message}`,"restore it from git or re-run exwf init");}(typeof n!="object"||n===null||Array.isArray(n))&&b("invalid-input",`${e$1} does not contain a workflow state object`,"restore it from git or re-run exwf init");let l=n;l.version!==1&&b("state-version",`${e$1} has schema version ${String(l.version)}; this ex-workflow reads version 1`,"upgrade ex-workflow, or run the migration this version documents in its changelog"),$(e$1,()=>b$1(d$1,n,e$1));for(let[s,a]of Object.entries(l.items))a.id!==s&&b("invalid-input",`${e$1}: /items/${s} holds item id ${JSON.stringify(a.id)}`,`make the key and the id the same at /items/${s}, or restore the file from git`);let d$2=c.join(t,u,"roles"),r=[];try{r=(await readdir(d$2)).filter(s=>s.endsWith(".json"));}catch{}let m={...l.roles};for(let s of r){let a=c.join(d$2,s),f;try{f=JSON.parse(await readFile(a,"utf8"));}catch(w){b("invalid-input",`role manifest ${a} is not valid JSON: ${w.message}`,"fix or delete that manifest");}b$1(e,f,`role manifest ${a}`),f.id!=="__proto__"&&(Object.hasOwn(m,f.id)||(m[f.id]=f));}return d({...l,roles:m})}function J(t,e){return c.resolve(e).startsWith(c.resolve(t,u)+c.sep)||b("invalid-input",`${e} resolves outside ${u}/`,"use a plain item id (letters, digits, - _ .)"),e}function M(t,e){(typeof t!="string"||t===""||t.startsWith(".")||t.includes("..")||/[/\\\0]/.test(t))&&b("invalid-input",`${e} ${JSON.stringify(t)} cannot be a file name under ${u}/`,"use an id with no / \\ NUL or .. and no leading . (e.g. CART-12)");}async function _(t,e){let i=c.join(t,u,"briefs"),n=new Map;for(let d of await readdir(i).catch(()=>[]))n.set(d.toLowerCase(),d);let l=new Map;for(let d of e){M(d,"brief item id");let r=`${d}.json`;J(t,c.join(i,r));let m=r.toLowerCase(),s=[l.get(m),n.get(m)].find(a=>a!==void 0&&a!==r);s&&b("invalid-input",`item "${d}": its brief ${r} differs only in letter case from the brief ${s} of another item`,"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"),l.set(m,r);}}async function V(t,e){await _(t,[e.item.id]);let i=c.join(t,u,"briefs",`${e.item.id}.json`);return await k(i,JSON.stringify(e,null,2)+`
|
|
4
4
|
`),i}async function X(t,e,i){M(e.item,"handoff item id"),(!Number.isSafeInteger(i)||i<0)&&b("invalid-input",`handoff seq ${String(i)} is not a non-negative integer`,"pass the state's event count after complete (res.state.events.length)");let n=J(t,c.join(t,u,"handoffs",`${e.item}-${i}.json`));return await k(n,JSON.stringify(e,null,2)+`
|
|
5
|
-
`),n}export{u as a,g as b,z as c,K as d,U as e,_ as f,V as g,X as h};//# sourceMappingURL=chunk-
|
|
6
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
`),n}export{u as a,g as b,z as c,K as d,U as e,_ as f,V as g,X as h};//# sourceMappingURL=chunk-ONVAUZOD.mjs.map
|
|
6
|
+
//# sourceMappingURL=chunk-ONVAUZOD.mjs.map
|
|
@@ -1 +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","sa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AcC,CAAG,CAAA,EAAKA,CAAAA,CAAM,CAAA,GACtCvD,CAAAA,CACE,eAAA,CACA,CAAA,YAAA,EAAe,MAAA,CAAOuD,CAAG,CAAC,iCAC1B,uEACF,CAAA,CACF,IAAMhE,CAAAA,CAAOkD,CAAAA,CACXrD,CAAAA,CACAC,CAAAA,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-3GKYL6VB.mjs","sourcesContent":["import { mkdir, open, readFile, readdir, rename, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { randomBytes } from \"node:crypto\";\nimport path from \"node:path\";\nimport { fail } from \"../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"]}
|
|
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":"kRAQO,IAAMA,EAAe,YAErB,SAASC,EAAUC,CAAAA,CAAsB,CAC9C,OAAOC,CAAAA,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,WAAAA,CAAY,CAAC,CAAA,CAAE,QAAA,CAAS,KAAK,CAAC,CAAA,CAAA,CACxE,GAAI,CACF,MAAMC,MAAMN,CAAAA,CAAK,OAAA,CAAQE,CAAI,CAAA,CAAG,CAAE,SAAA,CAAW,CAAA,CAAK,CAAC,CAAA,CACnD,MAAMK,SAAAA,CAAUH,CAAAA,CAAKD,EAAS,MAAM,CAAA,CACpC,MAAMK,MAAAA,CAAOJ,CAAAA,CAAKF,CAAI,EACxB,CAAA,MAASO,EAAG,CAEV,MAAMC,OAAON,CAAG,CAAA,CAAE,MAAM,IAAG,CAAA,CAAY,CAAA,CACvCO,CAAAA,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,CAAAA,CAAU,GAAO,CAAA,CAAIH,CAAAA,CACtDI,EAAOlB,CAAAA,CAAK,IAAA,CAAKD,EAAMF,CAAAA,CAAc,YAAY,EACjDsB,CAAAA,CAAUV,CAAAA,EACdE,EACE,eAAA,CACA,CAAA,cAAA,EAAiBO,CAAI,CAAA,EA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,iBAAiB,CAAA,CAAA,CACxC,CAAC,MAAA,CAAO,aAAA,CAAcC,CAAG,CAAA,EAAKA,CAAAA,CAAM,CAAA,GACtCvD,CAAAA,CACE,eAAA,CACA,CAAA,YAAA,EAAe,MAAA,CAAOuD,CAAG,CAAC,iCAC1B,uEACF,CAAA,CACF,IAAMhE,CAAAA,CAAOkD,CAAAA,CACXrD,CAAAA,CACAC,CAAAA,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-ONVAUZOD.mjs","sourcesContent":["import { mkdir, open, readFile, readdir, rename, stat, unlink, writeFile } from \"node:fs/promises\";\nimport { randomBytes } from \"node:crypto\";\nimport path from \"node:path\";\nimport { fail } from \"../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"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {c}from'./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import {c}from'./chunk-COPYGMHE.mjs';import {b}from'./chunk-YS6CXERQ.mjs';var l=r=>r.agreements.length===0?"(none)":r.agreements.map(e=>`"${e}"`).join(", ");function a(r,e,n){return b("invalid-input",`no working agreement ${JSON.stringify(e)} to ${n}`,`current agreements: ${l(r)}; name one of them exactly`)}function m(r,e,n,s){if(e.replaces===e.text)return r;let t=r;return e.replaces!==void 0&&((typeof e.replaces!="string"||!t.agreements.includes(e.replaces))&&a(t,e.replaces,"replace"),t={...t,agreements:t.agreements.filter(i=>i!==e.replaces)},t=c(t,"agreement.retired",n,{text:e.replaces,replacedBy:e.text},s)),t.agreements.includes(e.text)||(t={...t,agreements:[...t.agreements,e.text]}),t}function w(r,e,n,s){(typeof e!="string"||!r.agreements.includes(e))&&a(r,e,"retire");let t={...r,agreements:r.agreements.filter(i=>i!==e)};return c(t,"agreement.retired",n,{text:e,replacedBy:null},s)}export{m as a,w as b};//# sourceMappingURL=chunk-PFHVB2WT.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-PFHVB2WT.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/agreements.ts"],"names":["listed","s","a","absent","text","what","fail","applyAgreement","state","change","by","now","appendEvent","retireAgreement"],"mappings":"0EAIA,IAAMA,EAAUC,CAAAA,EACdA,CAAAA,CAAE,WAAW,MAAA,GAAW,CAAA,CAAI,SAAWA,CAAAA,CAAE,UAAA,CAAW,GAAA,CAAKC,CAAAA,EAAM,IAAIA,CAAC,CAAA,CAAA,CAAG,EAAE,IAAA,CAAK,IAAI,EAEpF,SAASC,CAAAA,CAAOF,CAAAA,CAA0BG,CAAAA,CAAeC,EAAqB,CAC5E,OAAOC,EACL,eAAA,CACA,CAAA,qBAAA,EAAwB,KAAK,SAAA,CAAUF,CAAI,CAAC,CAAA,IAAA,EAAOC,CAAI,GACvD,CAAA,oBAAA,EAAuBL,CAAAA,CAAOC,CAAC,CAAC,CAAA,0BAAA,CAClC,CACF,CAeO,SAASM,CAAAA,CACdC,CAAAA,CACAC,EACAC,CAAAA,CACAC,CAAAA,CACkB,CAClB,GAAIF,CAAAA,CAAO,WAAaA,CAAAA,CAAO,IAAA,CAAM,OAAOD,CAAAA,CAC5C,IAAIP,CAAAA,CAAIO,CAAAA,C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AI,CAAA,GAAGR,EAAI,CAAE,GAAGA,EAAG,UAAA,CAAY,CAAC,GAAGA,CAAAA,CAAE,UAAA,CAAYQ,EAAO,IAAI,CAAE,GACzFR,CACT,CAeO,SAASY,CAAAA,CACdL,CAAAA,CACAJ,CAAAA,CACAM,CAAAA,CACAC,EACkB,CAAA,CACd,OAAOP,GAAS,QAAA,EAAY,CAACI,EAAM,UAAA,CAAW,QAAA,CAASJ,CAAI,CAAA,GAAGD,CAAAA,CAAOK,EAAOJ,CAAAA,CAAM,QAAQ,EAC9F,IAAMH,CAAAA,CAAI,CAAE,GAAGO,CAAAA,CAAO,UAAA,CAAYA,CAAAA,CAAM,WAAW,MAAA,CAAQN,CAAAA,EAAMA,IAAME,CAAI,CAAE,EAC7E,OAAOQ,CAAAA,CAAYX,EAAG,mBAAA,CAAqBS,CAAAA,CAAI,CAAE,IAAA,CAAAN,CAAAA,CAAM,WAAY,IAAK,CAAA,CAAGO,CAAG,CAChF","file":"chunk-PFHVB2WT.mjs","sourcesContent":["import { fail } from \"./errors.ts\";\nimport { appendEvent } from \"./state.ts\";\nimport type { WorkflowState } from \"./types.ts\";\n\nconst listed = (s: WorkflowState<string>) =>\n s.agreements.length === 0 ? \"(none)\" : s.agreements.map((a) => `\"${a}\"`).join(\", \");\n\nfunction absent(s: WorkflowState<string>, text: unknown, what: string): never {\n return fail(\n \"invalid-input\",\n `no working agreement ${JSON.stringify(text)} to ${what}`,\n `current agreements: ${listed(s)}; name one of them exactly`,\n );\n}\n\n/** Adds an agreement (idempotent); with `replaces`, retires that one in the same step. */\nexport function applyAgreement<N extends string>(\n state: WorkflowState<N>,\n change: { text: string; replaces?: string },\n by: string,\n now: string,\n): WorkflowState<N>;\nexport function applyAgreement(\n state: WorkflowState,\n change: { text: string; replaces?: string },\n by: string,\n now: string,\n): WorkflowState;\nexport function applyAgreement<N extends string>(\n state: WorkflowState<N>,\n change: { text: string; replaces?: string },\n by: string,\n now: string,\n): WorkflowState<N> {\n if (change.replaces === change.text) return state;\n let s = state;\n if (change.replaces !== undefined) {\n if (typeof change.replaces !== \"string\" || !s.agreements.includes(change.replaces))\n absent(s, change.replaces, \"replace\");\n s = { ...s, agreements: s.agreements.filter((a) => a !== change.replaces) };\n s = appendEvent(\n s,\n \"agreement.retired\",\n by,\n { text: change.replaces, replacedBy: change.text },\n now,\n );\n }\n if (!s.agreements.includes(change.text)) s = { ...s, agreements: [...s.agreements, change.text] };\n return s;\n}\n\n/** Removes an agreement and records why it left (replacedBy null). */\nexport function retireAgreement<N extends string>(\n state: WorkflowState<N>,\n text: string,\n by: string,\n now: string,\n): WorkflowState<N>;\nexport function retireAgreement(\n state: WorkflowState,\n text: string,\n by: string,\n now: string,\n): WorkflowState;\nexport function retireAgreement<N extends string>(\n state: WorkflowState<N>,\n text: string,\n by: string,\n now: string,\n): WorkflowState<N> {\n if (typeof text !== \"string\" || !state.agreements.includes(text)) absent(state, text, \"retire\");\n const s = { ...state, agreements: state.agreements.filter((a) => a !== text) };\n return appendEvent(s, \"agreement.retired\", by, { text, replacedBy: null }, now);\n}\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {b}from'./chunk-YS6CXERQ.mjs';var l={Accounting:{type:"object",properties:{item:{type:"string"},role:{type:"string"},model:{type:"string"},tokensIn:{type:"number"},tokensOut:{type:"number"},durationMs:{type:"number"},startedAt:{type:"string"},endedAt:{type:"string"},estimate:{type:"boolean"}},required:["item","role","model","tokensIn","tokensOut","durationMs","startedAt","endedAt"],additionalProperties:false},Baseline:{type:"object",properties:{phase:{type:"string"},version:{type:"number"},at:{type:"string"},approvedBy:{type:"array",items:{type:"string"}},itemSnapshot:{type:"object",additionalProperties:{$ref:"#/definitions/WorkItem"}}},required:["phase","version","at","approvedBy","itemSnapshot"],additionalProperties:false},BeliefUpdate:{type:"object",properties:{result:{type:"string"},assessments:{type:"array",items:{type:"object",properties:{hypothesis:{type:"string"},assessment:{type:"string",enum:["supported","refuted","uncertain"]},reason:{type:"string"}},required:["hypothesis","assessment","reason"],additionalProperties:false}}},required:["result","assessments"],additionalProperties:false},Blocker:{type:"object",properties:{id:{type:"string"},reason:{type:"string"},owner:{type:"string"},raisedAt:{type:"string"},clearedAt:{type:"string"}},required:["id","reason","owner","raisedAt"],additionalProperties:false},Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},Capability:{type:"string",enum:["order-backlog","define-acceptance","facilitate","deliver","review","verify","approve-gate","manage-flow","control-change","escalate"]},ClassOfService:{type:"string",enum:["expedite","fixed-date","standard","intangible"]},Event:{type:"object",properties:{seq:{type:"number"},at:{type:"string"},type:{type:"string"},by:{type:"string"},payload:{}},required:["seq","at","type","by","payload"],additionalProperties:false},Evidence:{type:"object",properties:{kind:{type:"string"},ref:{type:"string"},by:{type:"string"},at:{type:"string"},data:{type:"object",additionalProperties:{}}},required:["kind","ref","by","at"],additionalProperties:false},Experiment:{type:"object",properties:{id:{type:"string"},procedureRef:{type:"string"},predictions:{type:"array",items:{type:"object",properties:{hypothesis:{type:"string"},prediction:{type:"string"}},required:["hypothesis","prediction"],additionalProperties:false}},replayOf:{type:"string"}},required:["id","procedureRef","predictions"],additionalProperties:false},ExperimentCandidate:{type:"object",properties:{id:{type:"string"},item:{type:"string"},author:{type:"string"},status:{type:"string",enum:["pending","ready","running","submitted","validated","failed","timed-out","cancelled"]},workspace:{type:"string"},sha:{type:"string"},score:{type:"number"},spent:{$ref:"#/definitions/Spent"},validation:{type:"object",properties:{sha:{type:"string"},harness:{type:"string"},by:{type:"string"},passed:{type:"boolean"},reproducible:{type:"boolean"},evidence:{type:"string"}},required:["sha","harness","by","passed","reproducible","evidence"],additionalProperties:false},reason:{type:"string"},command:{type:"string"},log:{type:"string"},terminalLog:{type:"string"}},required:["id","item","author","status","spent"],additionalProperties:false},ExperimentationState:{type:"object",properties:{status:{type:"string",enum:["running","selected","integrating","integrated","stopped"]},baseSha:{type:"string"},harness:{type:"string"},candidates:{type:"object",additionalProperties:{$ref:"#/definitions/ExperimentCandidate"}},selected:{type:"string"},reason:{type:"string"},integration:{type:"object",properties:{selectedSha:{type:"string"},targetSha:{type:"string"},sha:{type:"string"},by:{type:"string"},validation:{type:"object",properties:{by:{type:"string"},sha:{type:"string"},harness:{type:"string"},evidence:{type:"string"},passed:{type:"boolean"}},required:["by","sha","harness","evidence","passed"],additionalProperties:false}},required:["selectedSha","targetSha","sha","by"],additionalProperties:false},released:{type:"array",items:{type:"string"}},overhead:{$ref:"#/definitions/Spent"}},required:["status","baseSha","harness","candidates","released","overhead"],additionalProperties:false},Gate:{type:"object",properties:{id:{type:"string"},requires:{type:"array",items:{$ref:"#/definitions/GateRequirement"}},evidence:{type:"array",items:{type:"string"}},onFail:{anyOf:[{type:"object",properties:{action:{type:"string",const:"block"}},required:["action"],additionalProperties:false},{type:"object",properties:{action:{type:"string",const:"return-to"},stage:{type:"string"}},required:["action","stage"],additionalProperties:false}]}},required:["id","requires","evidence","onFail"],additionalProperties:false},GateRequirement:{anyOf:[{type:"string",const:"human"},{type:"object",properties:{capability:{type:"string"}},required:["capability"],additionalProperties:false}]},Handoff:{type:"object",properties:{item:{type:"string"},role:{type:"string"},produced:{type:"array",items:{type:"object",properties:{kind:{type:"string"},ref:{type:"string"}},required:["kind","ref"],additionalProperties:false}},notes:{type:"string"},do_not:{type:"array",items:{type:"string"}},open_questions:{type:"array",items:{type:"string"}},verdict:{$ref:"#/definitions/Verdict"},follow_ups:{type:"array",items:{$ref:"#/definitions/NewItem"}},lessons:{type:"array",items:{type:"object",properties:{text:{type:"string"},scope:{type:"string",enum:["policy","skill","memory","spec","review"]}},required:["text","scope"],additionalProperties:false}}},required:["item","role","produced","notes","do_not","open_questions"],additionalProperties:false},Hypothesis:{type:"object",properties:{id:{type:"string"},claim:{type:"string"},falsifiedBy:{type:"string"}},required:["id","claim","falsifiedBy"],additionalProperties:false},ImpactAnalysis:{type:"object",properties:{summary:{type:"string"},reopen:{type:"array",items:{type:"string"}},weight:{type:"number"}},required:["summary","reopen","weight"],additionalProperties:false},InvestigationConclusion:{type:"object",properties:{outcome:{type:"string",enum:["resolved","inconclusive"]},summary:{type:"string"},supportedHypothesis:{type:"string"},evidenceRefs:{type:"array",items:{type:"string"}},by:{type:"string"}},required:["outcome","summary","evidenceRefs","by"],additionalProperties:false},InvestigationRound:{type:"object",properties:{hypotheses:{type:"array",items:{$ref:"#/definitions/Hypothesis"}},experiment:{$ref:"#/definitions/Experiment"},item:{type:"string"},by:{type:"string"},result:{$ref:"#/definitions/Observation"},update:{$ref:"#/definitions/BeliefUpdate"}},required:["hypotheses","experiment","item","by"],additionalProperties:false},InvestigationState:{type:"object",properties:{item:{type:"string"},phase:{type:"string",enum:["hypotheses","preregister","observe","update-belief","conclusion","review","closed"]},hypotheses:{type:"array",items:{$ref:"#/definitions/Hypothesis"}},singleHypothesisRationale:{type:"string"},rounds:{type:"array",items:{$ref:"#/definitions/InvestigationRound"}},conclusion:{$ref:"#/definitions/InvestigationConclusion"},outcome:{type:"string",enum:["resolved","inconclusive","stopped"]},stopReason:{type:"string"},contributors:{type:"array",items:{type:"string"}},reviewHistory:{type:"array",items:{type:"object",properties:{by:{type:"string"},reason:{type:"string"},approve:{type:"boolean"},next:{type:"string",enum:["round","conclusion"]},replayRefs:{type:"array",items:{type:"string"}}},required:["by","reason","approve","replayRefs"],additionalProperties:false}},review:{type:"object",properties:{by:{type:"string"},reason:{type:"string"},replayRefs:{type:"array",items:{type:"string"}}},required:["by","reason","replayRefs"],additionalProperties:false}},required:["item","phase","hypotheses","rounds","contributors"],additionalProperties:false},ItemPatch:{type:"object",properties:{type:{$ref:"#/definitions/ItemType"},title:{type:"string"},description:{type:"string"},dependsOn:{type:"array",items:{type:"string"}},priority:{type:"number"},weight:{type:"number"},deadline:{type:"string"},classOfService:{$ref:"#/definitions/ClassOfService"},role:{type:"string"},parent:{type:"string"},acceptance:{type:"array",items:{type:"string"}},iteration:{type:"string"},traces:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}},affects:{type:"array",items:{type:"string"}},phase:{type:"string"},impactAnalysis:{$ref:"#/definitions/ImpactAnalysis"}},additionalProperties:false},ItemStatus:{type:"string",enum:["todo","in_progress","blocked","review","awaiting_human","done","dropped"]},ItemType:{type:"string",enum:["epic","story","task","bug","change-request","deliverable","question"]},Iteration:{type:"object",properties:{id:{type:"string"},goal:{type:"string"},budget:{$ref:"#/definitions/Budget"},spent:{$ref:"#/definitions/Spent"},startedAt:{type:"string"},endedAt:{type:"string"},committed:{type:"array",items:{type:"string"}},carryover:{type:"array",items:{type:"string"}},outcome:{type:"string",enum:["completed","cancelled"]},closing:{type:"boolean"}},required:["id","goal","budget","spent","startedAt","committed","carryover"],additionalProperties:false},Lesson:{type:"object",properties:{id:{type:"string"},at:{type:"string"},text:{type:"string"},scope:{type:"string",enum:["policy","skill","memory","spec","review"]},status:{type:"string",enum:["raised","adopted","dismissed"]},from:{type:"string"},item:{type:"string"},suggestedChange:{$ref:"#/definitions/LessonChange"}},required:["id","at","text","scope","status"],additionalProperties:false},LessonChange:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"agreement"},text:{type:"string"},replaces:{type:"string"}},required:["kind","text"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dod"},policy:{$ref:"#/definitions/Policy"}},required:["kind","policy"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"backlog"},item:{$ref:"#/definitions/NewItem"}},required:["kind","item"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"skill"},note:{type:"string"}},required:["kind","note"],additionalProperties:false}]},MethodologyName:{type:"string",enum:["scrum","kanban","waterfall","investigation","experimentation"]},ModelTier:{type:"string",enum:["small","medium","large"]},NewItem:{type:"object",additionalProperties:false,properties:{stage:{type:"string"},type:{$ref:"#/definitions/ItemType"},description:{type:"string"},dependsOn:{type:"array",items:{type:"string"}},priority:{type:"number"},weight:{type:"number"},deadline:{type:"string"},classOfService:{$ref:"#/definitions/ClassOfService"},role:{type:"string"},parent:{type:"string"},acceptance:{type:"array",items:{type:"string"}},iteration:{type:"string"},traces:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}},affects:{type:"array",items:{type:"string"}},phase:{type:"string"},impactAnalysis:{$ref:"#/definitions/ImpactAnalysis"},id:{type:"string"},title:{type:"string"}},required:["id","title"]},Observation:{type:"object",properties:{id:{type:"string"},valid:{type:"boolean"},summary:{type:"string"},provenanceRefs:{type:"array",items:{type:"string"}}},required:["id","valid","summary","provenanceRefs"],additionalProperties:false},PendingHuman:{type:"object",properties:{id:{type:"string"},kind:{type:"string",enum:["gate","decision"]},item:{type:"string"},gate:{type:"string"},question:{type:"string"},raisedAt:{type:"string"}},required:["id","kind","question","raisedAt"],additionalProperties:false},Phase:{type:"object",properties:{id:{type:"string"},name:{type:"string"},deliverables:{type:"array",items:{type:"string"}},gate:{$ref:"#/definitions/Gate"},status:{type:"string",enum:["pending","open","baselined","reopened"]},budget:{$ref:"#/definitions/Budget"},produced:{type:"array",items:{$ref:"#/definitions/Produced"}}},required:["id","name","deliverables","gate","status"],additionalProperties:false},Policy:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"evidence"},evidenceKind:{type:"string"}},required:["kind","evidenceKind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"acceptance-written"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"estimate-present"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"no-open-blockers"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dependencies-done"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"custom"},id:{type:"string"},description:{type:"string"}},required:["kind","id","description"],additionalProperties:false}]},Produced:{type:"object",properties:{kind:{type:"string"},ref:{type:"string"},by:{type:"string"},at:{type:"string"}},required:["kind","ref","by","at"],additionalProperties:false},Role:{type:"object",properties:{id:{type:"string"},name:{type:"string"},modelTier:{$ref:"#/definitions/ModelTier"},resourceClass:{type:"string"},maxConcurrent:{type:"number"},capabilities:{type:"array",items:{$ref:"#/definitions/Capability"}},canApprove:{type:"array",items:{type:"string"}},inputs:{type:"array",items:{type:"string"}},outputs:{type:"array",items:{type:"string"}},do_not:{type:"array",items:{type:"string"}},constraints:{type:"array",items:{type:"string"}}},required:["id","name","modelTier","capabilities","canApprove","inputs","outputs","do_not"],additionalProperties:false},Spent:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},required:["tokens","turns","wallclockMs"],additionalProperties:false},Stage:{type:"object",properties:{id:{type:"string"},name:{type:"string"},wipLimit:{type:"number"},entryPolicy:{type:"array",items:{$ref:"#/definitions/Policy"}},exitPolicy:{type:"array",items:{$ref:"#/definitions/Policy"}},gate:{$ref:"#/definitions/Gate"},commitmentPoint:{type:"boolean"},deliveryPoint:{type:"boolean"},review:{type:"boolean"}},required:["id","name","entryPolicy","exitPolicy"],additionalProperties:false},Transition:{type:"object",properties:{from:{type:"object",properties:{stage:{type:"string"},status:{$ref:"#/definitions/ItemStatus"}},required:["stage","status"],additionalProperties:false},to:{type:"object",properties:{stage:{type:"string"},status:{$ref:"#/definitions/ItemStatus"}},required:["stage","status"],additionalProperties:false},at:{type:"string"},by:{type:"string"}},required:["from","to","at","by"],additionalProperties:false},Verdict:{type:"string",enum:["done","blocked","needs-review","rework","escalate"]},WorkItem:{type:"object",properties:{id:{type:"string"},type:{$ref:"#/definitions/ItemType"},title:{type:"string"},description:{type:"string"},dependsOn:{type:"array",items:{type:"string"}},priority:{type:"number"},weight:{type:"number"},deadline:{type:"string"},classOfService:{$ref:"#/definitions/ClassOfService"},stage:{type:"string"},status:{$ref:"#/definitions/ItemStatus"},role:{type:"string"},parent:{type:"string"},acceptance:{type:"array",items:{type:"string"}},evidence:{type:"array",items:{$ref:"#/definitions/Evidence"}},blockers:{type:"array",items:{$ref:"#/definitions/Blocker"}},transitions:{type:"array",items:{$ref:"#/definitions/Transition"}},iteration:{type:"string"},traces:{type:"array",items:{type:"string"}},tags:{type:"array",items:{type:"string"}},affects:{type:"array",items:{type:"string"}},phase:{type:"string"},impactAnalysis:{$ref:"#/definitions/ImpactAnalysis"}},required:["id","type","title","dependsOn","stage","status","acceptance","evidence","blockers","transitions"],additionalProperties:false},WorkflowExt:{type:"object",properties:{investigation:{$ref:"#/definitions/InvestigationState"},experimentation:{$ref:"#/definitions/ExperimentationState"}},additionalProperties:{}},WorkflowState:{type:"object",properties:{version:{type:"number",const:1},methodology:{$ref:"#/definitions/MethodologyName"},config:{},investigation:{$ref:"#/definitions/InvestigationState",deprecated:true},experimentation:{$ref:"#/definitions/ExperimentationState",deprecated:true},ext:{$ref:"#/definitions/WorkflowExt"},items:{type:"object",additionalProperties:{$ref:"#/definitions/WorkItem"}},stages:{type:"array",items:{$ref:"#/definitions/Stage"}},roles:{type:"object",additionalProperties:{$ref:"#/definitions/Role"}},iterations:{type:"array",items:{$ref:"#/definitions/Iteration"}},phases:{type:"array",items:{$ref:"#/definitions/Phase"}},baseline:{$ref:"#/definitions/Baseline"},baselines:{type:"array",items:{$ref:"#/definitions/Baseline"}},events:{type:"array",items:{$ref:"#/definitions/Event"}},accounting:{type:"array",items:{$ref:"#/definitions/Accounting"}},pending:{type:"array",items:{$ref:"#/definitions/PendingHuman"}},lessons:{type:"array",items:{$ref:"#/definitions/Lesson"}},agreements:{type:"array",items:{type:"string"}}},required:["version","methodology","config","items","stages","roles","iterations","events","accounting","pending","lessons","agreements"],additionalProperties:false}},h={Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},EstimateMode:{type:"string",enum:["per-weight","per-call"]},Policy:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"evidence"},evidenceKind:{type:"string"}},required:["kind","evidenceKind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"acceptance-written"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"estimate-present"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"no-open-blockers"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dependencies-done"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"custom"},id:{type:"string"},description:{type:"string"}},required:["kind","id","description"],additionalProperties:false}]},ScrumConfig:{type:"object",properties:{sprintBudget:{$ref:"#/definitions/Budget"},productGoal:{type:"string"},definitionOfDone:{type:"array",items:{$ref:"#/definitions/Policy"}},refinementSharePct:{type:"number"},allowMidSprintAdd:{type:"string",enum:["never","po-only","any"]},inProgressWipLimit:{type:"number"},autoClose:{type:"boolean"},estimateMode:{$ref:"#/definitions/EstimateMode"},fallbackTokensPerWeight:{type:"number"}},required:["sprintBudget","productGoal","definitionOfDone","refinementSharePct","allowMidSprintAdd"],additionalProperties:false}},P={ClassConfig:{type:"object",properties:{wipBypass:{type:"number"},sle:{$ref:"#/definitions/ServiceLevel"}},additionalProperties:false},KanbanColumn:{type:"object",properties:{id:{type:"string"},name:{type:"string"},wipLimit:{type:"number"},policies:{type:"array",items:{$ref:"#/definitions/Policy"}},commitmentPoint:{type:"boolean"},deliveryPoint:{type:"boolean"},review:{type:"boolean"}},required:["id","name","policies"],additionalProperties:false},KanbanConfig:{type:"object",properties:{columns:{type:"array",items:{$ref:"#/definitions/KanbanColumn"}},classesOfService:{type:"object",properties:{expedite:{$ref:"#/definitions/ClassConfig"},"fixed-date":{$ref:"#/definitions/ClassConfig"},standard:{$ref:"#/definitions/ClassConfig"},intangible:{$ref:"#/definitions/ClassConfig"}},additionalProperties:false},fairness:{type:"object",properties:{aging:{type:"boolean"},maxDeferralRounds:{type:"number"}},required:["aging","maxDeferralRounds"],additionalProperties:false},cadences:{type:"object",properties:{replenishment:{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"delivery-planning":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"service-delivery-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"operations-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"risk-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false},"strategy-review":{type:"object",properties:{everyTurns:{type:"number"}},additionalProperties:false}},additionalProperties:false},throughputWindowMs:{type:"number"},maxExpedite:{type:"number"}},required:["columns","classesOfService","fairness","cadences","throughputWindowMs","maxExpedite"],additionalProperties:false},Policy:{anyOf:[{type:"object",properties:{kind:{type:"string",const:"evidence"},evidenceKind:{type:"string"}},required:["kind","evidenceKind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"acceptance-written"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"estimate-present"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"no-open-blockers"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"dependencies-done"}},required:["kind"],additionalProperties:false},{type:"object",properties:{kind:{type:"string",const:"custom"},id:{type:"string"},description:{type:"string"}},required:["kind","id","description"],additionalProperties:false}]},ServiceLevel:{type:"object",properties:{percentile:{type:"number"},targetMs:{type:"number"}},required:["percentile","targetMs"],additionalProperties:false}},k={Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},Gate:{type:"object",properties:{id:{type:"string"},requires:{type:"array",items:{$ref:"#/definitions/GateRequirement"}},evidence:{type:"array",items:{type:"string"}},onFail:{anyOf:[{type:"object",properties:{action:{type:"string",const:"block"}},required:["action"],additionalProperties:false},{type:"object",properties:{action:{type:"string",const:"return-to"},stage:{type:"string"}},required:["action","stage"],additionalProperties:false}]}},required:["id","requires","evidence","onFail"],additionalProperties:false},GateRequirement:{anyOf:[{type:"string",const:"human"},{type:"object",properties:{capability:{type:"string"}},required:["capability"],additionalProperties:false}]},WaterfallConfig:{type:"object",properties:{phases:{type:"array",items:{$ref:"#/definitions/WaterfallPhaseConfig"}},changeControl:{type:"object",properties:{requiresImpactAnalysis:{type:"boolean"},approvers:{type:"array",items:{$ref:"#/definitions/GateRequirement"}}},required:["requiresImpactAnalysis","approvers"],additionalProperties:false},traceability:{type:"object",properties:{from:{type:"string"},to:{type:"array",items:{type:"string"}}},required:["from","to"],additionalProperties:false},humanGates:{anyOf:[{type:"string",const:"all"},{type:"array",items:{type:"string"}}]},fallbackTokensPerWeight:{type:"number"}},required:["phases","changeControl","traceability","humanGates"],additionalProperties:false},WaterfallPhaseConfig:{type:"object",properties:{id:{type:"string"},name:{type:"string"},deliverables:{type:"array",items:{type:"string"}},gate:{$ref:"#/definitions/Gate"},budget:{$ref:"#/definitions/Budget"},deliverBy:{type:"string"}},required:["id","name","deliverables","gate"],additionalProperties:false}},$={Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},InvestigationConfig:{type:"object",properties:{question:{type:"string"},maxRounds:{type:"number"},budget:{$ref:"#/definitions/Budget"}},required:["question","maxRounds","budget"],additionalProperties:false}},j={Budget:{type:"object",properties:{tokens:{type:"number"},turns:{type:"number"},wallclockMs:{type:"number"}},additionalProperties:false},ExperimentationConfig:{type:"object",properties:{objective:{type:"string"},direction:{type:"string",enum:["minimize","maximize"]},tieBreak:{type:"string",const:"candidate-id"},concurrencyCap:{type:"number"},maxCandidates:{type:"number"},candidateBudget:{$ref:"#/definitions/Budget"},totalBudget:{$ref:"#/definitions/Budget"}},required:["objective","direction","tieBreak","concurrencyCap","maxCandidates","candidateBudget","totalBudget"],additionalProperties:false}};var S="#/definitions/";function m(e){return e===null?"null":Array.isArray(e)?"array":typeof e}function w(e,t){return e==="integer"?typeof t=="number"&&Number.isInteger(t):m(t)===e}function p(e){let t=JSON.stringify(e);return t===void 0?String(e):t.length>60?`${t.slice(0,57)}...`:t}function q(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function v(e,t){return JSON.stringify(e)===JSON.stringify(t)}function d(e,t,s,n,i){return {path:e===""?"/":e,keyword:t,message:s,expected:n,found:i}}function O(e,t){e.startsWith(S)||b("invalid-input",`schema $ref ${JSON.stringify(e)} is not #/definitions/<name>`,"regenerate the schema with pnpm schema:gen");let s=e.slice(S.length),n=t.definitions&&Object.hasOwn(t.definitions,s)?t.definitions[s]:void 0;return n||b("invalid-input",`schema $ref ${JSON.stringify(e)} names no definition`,"regenerate the schema with pnpm schema:gen"),n}function x(e,t){let s=t===""?"/":t;return e.reduce((n,i)=>n+(i.keyword==="type"&&i.path===s?1e3:i.keyword==="const"?100:1),0)}function E(e){let t=e[0]?.filter(s=>s.keyword==="const")??[];for(let s of t){let n=e.map(r=>r.find(o=>o.keyword==="const"&&o.path===s.path));if(n.some(r=>r===void 0))continue;let i=[...new Set(n.map(r=>r?.expected))].join(" | ");return {path:s.path,keyword:"enum",message:`expected one of ${i}`,expected:i,found:s.found}}}function I(e,t){return f(e,t,e,"")}function f(e,t,s,n){if(e.$ref!==void 0)return f(O(e.$ref,s),t,s,n);let i=[];if(e.type!==void 0){let r=Array.isArray(e.type)?e.type:[e.type];if(!r.some(o=>w(o,t))){let o=r.join(" | ");return [d(n,"type",`expected ${o}, got ${m(t)}`,o,p(t))]}}if(e.const!==void 0&&!v(t,e.const)&&i.push(d(n,"const",`expected ${p(e.const)}`,p(e.const),p(t))),e.enum!==void 0&&!e.enum.some(r=>v(r,t))){let r=e.enum.map(p).join(" | ");i.push(d(n,"enum",`expected one of ${r}`,r,p(t)));}if(typeof t=="number"&&(e.minimum!==void 0&&t<e.minimum&&i.push(d(n,"minimum",`expected >= ${e.minimum}`,`>= ${e.minimum}`,p(t))),e.maximum!==void 0&&t>e.maximum&&i.push(d(n,"maximum",`expected <= ${e.maximum}`,`<= ${e.maximum}`,p(t)))),typeof t=="string"&&(e.minLength!==void 0&&t.length<e.minLength&&i.push(d(n,"minLength",`expected at least ${e.minLength} characters`,`length >= ${e.minLength}`,p(t))),e.pattern!==void 0&&!new RegExp(e.pattern,"u").test(t)&&i.push(d(n,"pattern",`expected to match /${e.pattern}/`,`/${e.pattern}/`,p(t)))),Array.isArray(t)&&e.items!==void 0){let r=e.items;t.forEach((o,c)=>i.push(...f(r,o,s,`${n}/${c}`)));}if(m(t)==="object"){let r=t;for(let[o,c]of Object.entries(r)){let g=e.properties&&Object.hasOwn(e.properties,o)?e.properties[o]:void 0,y=`${n}/${q(o)}`;if(g)i.push(...f(g,c,s,y));else if(e.additionalProperties===false){let b=Object.keys(e.properties??{}).join(", ");i.push(d(y,"additionalProperties",`unknown property ${JSON.stringify(o)}`,b?`one of ${b}`:"no properties",o));}else typeof e.additionalProperties=="object"&&i.push(...f(e.additionalProperties,c,s,y));}for(let o of e.required??[])Object.hasOwn(r,o)||i.push(d(`${n}/${q(o)}`,"required",`missing required property ${JSON.stringify(o)}`,"present","absent"));}if(e.anyOf!==void 0){let r,o=[];for(let g of e.anyOf){let y=f(g,t,s,n);if(y.length===0){r=[];break}o.push(y),(r===void 0||x(y,n)<x(r,n))&&(r=y);}let c=r&&r.length>0?E(o):void 0;c?i.push(c):r&&i.push(...r);}return i}function C(e,t,s){let n=I(e,t),i=n[0];if(!i)return;let r=n.length>1?` (+${n.length-1} more)`:"";b("invalid-input",`${s} does not match its schema: ${i.path} ${i.message}${r}`,`fix ${s} at ${i.path}: expected ${i.expected}, found ${i.found}`);}var N="http://json-schema.org/draft-07/schema#";function a(e,t){return {$schema:N,$ref:`#/definitions/${e}`,definitions:t}}var J=a("WorkflowState",l),M=a("Role",l),_=a("NewItem",l),D=a("ItemPatch",l),F=a("Handoff",l),L=a("ScrumConfig",h),W=a("KanbanConfig",P),G=a("WaterfallConfig",k),K=a("InvestigationConfig",$),H=a("ExperimentationConfig",j);
|
|
2
|
+
export{I as a,C as b,N as c,J as d,M as e,_ as f,D as g,F as h,L as i,W as j,G as k,K as l,H as m};//# sourceMappingURL=chunk-QJMOCISZ.mjs.map
|
|
3
|
+
//# sourceMappingURL=chunk-QJMOCISZ.mjs.map
|