ex-workflow 1.1.0 → 1.1.1
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 +27 -1
- package/README.md +63 -11
- package/dist/chunk-7QQY4KJ2.mjs +2 -0
- package/dist/chunk-7QQY4KJ2.mjs.map +1 -0
- package/dist/chunk-AD4Z3JBL.cjs +2 -0
- package/dist/chunk-AD4Z3JBL.cjs.map +1 -0
- package/dist/{chunk-YOS77GL3.mjs → chunk-EFCUM6DK.mjs} +2 -2
- package/dist/{chunk-YOS77GL3.mjs.map → chunk-EFCUM6DK.mjs.map} +1 -1
- package/dist/{chunk-APKA5FOU.cjs → chunk-PMUGU5UJ.cjs} +2 -2
- package/dist/{chunk-APKA5FOU.cjs.map → chunk-PMUGU5UJ.cjs.map} +1 -1
- package/dist/chunk-SVGTSPZF.cjs +2 -0
- package/dist/chunk-SVGTSPZF.cjs.map +1 -0
- package/dist/chunk-U6GHFKKE.mjs +2 -0
- package/dist/chunk-U6GHFKKE.mjs.map +1 -0
- package/dist/cli/bin.cjs +1 -1
- package/dist/cli/bin.mjs +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.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/investigation/index.cjs +1 -1
- package/dist/investigation/index.mjs +1 -1
- package/package.json +4 -2
- package/dist/chunk-FQW2LETC.cjs +0 -2
- package/dist/chunk-FQW2LETC.cjs.map +0 -1
- package/dist/chunk-MW4HR7HC.mjs +0 -2
- package/dist/chunk-MW4HR7HC.mjs.map +0 -1
- package/dist/chunk-YTG2MOD7.cjs +0 -2
- package/dist/chunk-YTG2MOD7.cjs.map +0 -1
- package/dist/chunk-YZJ6WFH4.mjs +0 -2
- package/dist/chunk-YZJ6WFH4.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/investigation/execution.ts","../src/investigation/config.ts","../src/investigation/ceremonies.ts","../src/investigation/rules.ts","../src/investigation/roles.ts","../src/investigation/stages.ts","../src/investigation/index.ts"],"names":["executionActors","state","item","event","transition","freshOutputRefs","completion","index","output","validateInvestigationConfig","raw","c","k","v","fail","reject","name","message","fix","x","sameHypothesis","a","b","text","refs","authorize","by","cap","roleOf","save","appendEvent","nowOf","closeInvestigation","outcome","reason","at","n","it","candidate","r","moveItem","investigationCeremonies","factory","make","phase","fn","s","i","applyAction","bad","addItem","h","isExhausted","e","p","prior","q","id","iteration","ref","target","replayRefs","actor","investigationRules","round","investigationRoles","investigationStages","investigation","excluded","roles","selected","role","now"],"mappings":"qHASO,SAASA,EAAgBC,CAAAA,CAAsBC,CAAAA,CAAwB,CAC5E,OAAO,CACL,GAAG,IAAI,GAAA,CAAI,CACT,GAAGD,CAAAA,CAAM,MAAA,CACN,MAAA,CACEE,CAAAA,EAAUA,EAAM,IAAA,GAAS,gBAAA,EAAqBA,CAAAA,CAAM,OAAA,CAAuB,KAAOD,CACrF,CAAA,CACC,GAAA,CAAKC,CAAAA,EAAUA,EAAM,EAAE,CAAA,CAC1B,GAAA,CAAIF,CAAAA,CAAM,MAAMC,CAAI,CAAA,EAAG,WAAA,EAAe,IACnC,MAAA,CAAQE,CAAAA,EAAeA,CAAAA,CAAW,EAAA,CAAG,SAAW,aAAa,CAAA,CAC7D,GAAA,CAAKA,CAAAA,EAAeA,EAAW,EAAE,CACtC,CAAC,CACH,CACF,CAGO,SAASC,CAAAA,CAAgBJ,CAAAA,CAAsBC,EAAwB,CAC5E,IAAII,CAAAA,CACJ,IAAA,IAASC,EAAQN,CAAAA,CAAM,MAAA,CAAO,MAAA,CAAS,CAAA,CAAGM,GAAS,CAAA,CAAGA,CAAAA,EAAAA,CAAS,CAC7D,IAA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AQ,GACvD,mGACF,CAAA,CACA,KAAA,CAAO6D,CAAAA,GACP,OAAA,CAAU,CAAA,GAAO,CACf,MAAA,CAAQ,EAAE,aAAA,EAAe,MAAA,CAAO,MAAA,EAAU,CAAA,CAC1C,UAAW,CAAA,CAAE,aAAA,EAAe,MAAA,CAAO,MAAA,CAAQxB,GAAMA,CAAAA,CAAE,MAAA,EAAQ,KAAK,CAAA,CAAE,QAAU,CAAA,CAC5E,WAAA,CAAa,EAAE,aAAA,EAAe,MAAA,CAAO,OAAQA,CAAAA,EAAMA,CAAAA,CAAE,MAAA,EAAU,CAACA,EAAE,MAAA,CAAO,KAAK,CAAA,CAAE,MAAA,EAAU,CAC5F,CAAA,CAAA,CACA,MAAA,CAAS,CAAA,GAAO,CACd,MAAO,CAAA,CAAE,aAAA,EAAe,KAAA,EAAS,QAAA,CACjC,QAAS,CAAA,CAAE,aAAA,EAAe,OAAA,EAAW,IAAA,CACrC,OAAQ,CAAA,CAAE,aAAA,EAAe,MAAA,CAAO,MAAA,EAAU,EAC1C,UAAA,CAAY,CAAA,CAAE,aAAA,EAAe,UAAA,EAAc,KAC3C,UAAA,CAAY,CAAA,CAAE,eAAe,UAAA,EAAc,IAC7C,EACF,CACF","file":"chunk-YTG2MOD7.cjs","sourcesContent":["import type { Handoff, Verdict, WorkflowState } from \"../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 \"../errors.ts\";\nimport type { Budget } from \"../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 { executionActors, freshOutputRefs } from \"./execution.ts\";\nimport { fail } from \"../errors.ts\";\nimport { roleOf } from \"../roles.ts\";\nimport { addItem, moveItem } from \"../items.ts\";\nimport { applyAction } from \"../methodology.ts\";\nimport { appendEvent, nowOf } from \"../state.ts\";\nimport { isExhausted } from \"../budget.ts\";\nimport type { Capability, Ceremony, CeremonyInput, Methodology, WorkflowState } from \"../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 = s.investigation;\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 && a.id === b.id && a.claim === b.claim && a.falsifiedBy === b.falsifiedBy;\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;\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 { ...s, investigation: 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 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 = s.investigation;\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, factory(), { 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.investigation)\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 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 {\n state: 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 warnings: [],\n };\n },\n hypotheses: make(\"hypotheses\", \"define-acceptance\", \"hypotheses\", (s, x, i, bad) => {\n const h = i.hypotheses as Hypothesis[];\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: structuredClone(h),\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 return closeInvestigation(s, x, i, \"stopped\", \"budget or round limit exhausted\");\n const e = i.experiment as Experiment;\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 prior.experiment.procedureRef !== e.procedureRef ||\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) => q.hypothesis === p.hypothesis && q.prediction === p.prediction,\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: structuredClone(e),\n hypotheses: structuredClone(x.hypotheses),\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 = x.rounds.at(-1)!,\n o = i.result as Observation;\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) => (v === r ? { ...v, result: structuredClone(o) } : v)),\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 = x.rounds.at(-1)!,\n a = i.assessments as BeliefUpdate[\"assessments\"];\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 if (!r.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 ? { ...v, update: { result: i.result as string, assessments: structuredClone(a) } }\n : v,\n ),\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"belief-updated\",\n );\n const it = n.iterations.find((v) => v.id === \"investigation\")!;\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 n.investigation!,\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 if (x.contributors.includes(i.by))\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 = s.iterations.find((it) => it.id === \"investigation\")!;\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 n.investigation!,\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 x.conclusion!.outcome === \"resolved\" &&\n (!refs(replayRefs) ||\n !x.rounds.some(\n (r) =>\n r.experiment.replayOf &&\n !executionActors(s, r.item).some((actor) =>\n executionActors(\n s,\n x.rounds.find((p) => p.experiment.id === r.experiment.replayOf)!.item,\n ).includes(actor),\n ) &&\n sameHypothesis(\n r.hypotheses.find((h) => h.id === x.conclusion!.supportedHypothesis),\n x.rounds.at(-1)!.hypotheses.find((h) => h.id === x.conclusion!.supportedHypothesis),\n ) &&\n r.result?.valid &&\n replayRefs.includes(r.result.id) &&\n r.update?.assessments.some(\n (a) =>\n a.hypothesis === x.conclusion!.supportedHypothesis &&\n 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 x.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 { executionActors } from \"./execution.ts\";\nimport type { Rule } from \"../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 = s.investigation?.rounds.find(\n (r) => r.item === (a.payload as { item?: string })?.item,\n );\n const prior = s.investigation?.rounds.find(\n (r) => r.experiment.id === round?.experiment.replayOf,\n );\n return prior && executionActors(s, prior.item).includes(a.by)\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 = s.investigation;\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 \"../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 \"../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 { fail } from \"../errors.ts\";\nimport { executionActors } from \"./execution.ts\";\nimport { closeInvestigation, investigationCeremonies } from \"./ceremonies.ts\";\nimport { investigationRules } from \"./rules.ts\";\nimport { investigationRoles } from \"./roles.ts\";\nimport { investigationStages } from \"./stages.ts\";\nimport { isExhausted } from \"../budget.ts\";\nimport type { Methodology } from \"../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 = state.investigation?.rounds.find((candidate) => candidate.item === item.id);\n const prior = state.investigation?.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) => role.capabilities.includes(\"deliver\") && !excluded.includes(role.id),\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 s.investigation?.phase === \"observe\" &&\n !isExhausted(\n (s.config as InvestigationConfig).budget,\n s.iterations.find((it) => it.id === \"investigation\")!.spent,\n )\n ? Object.values(s.items).filter(\n (i) =>\n i.id === s.investigation!.rounds.at(-1)?.item &&\n i.stage === \"execute\" &&\n i.status === \"todo\",\n )\n : [],\n afterComplete: (state, item, now) => {\n const x = state.investigation;\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: s.investigation?.rounds.length ?? 0,\n validRuns: s.investigation?.rounds.filter((r) => r.result?.valid).length ?? 0,\n invalidRuns: s.investigation?.rounds.filter((r) => r.result && !r.result.valid).length ?? 0,\n }),\n report: (s) => ({\n phase: s.investigation?.phase ?? \"intake\",\n outcome: s.investigation?.outcome ?? null,\n rounds: s.investigation?.rounds.length ?? 0,\n conclusion: s.investigation?.conclusion ?? null,\n stopReason: s.investigation?.stopReason ?? null,\n }),\n };\n}\n"]}
|
package/dist/chunk-YZJ6WFH4.mjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import {N,a,x,v,c as c$1,W as W$1,e}from'./chunk-6P3OKXSK.mjs';import {b as b$1}from'./chunk-2FRRD6A3.mjs';function f(s,n){return [...new Set([...s.events.filter(i=>i.type==="item.completed"&&i.payload.id===n).map(i=>i.by),...(s.items[n]?.transitions??[]).filter(i=>i.to.status==="in_progress").map(i=>i.by)])]}function $(s,n){let i;for(let e=s.events.length-1;e>=0;e--){let t=s.events[e];if(t.type==="item.completed"&&t.payload.id===n){i=t.payload;break}}return i&&["done","needs-review"].includes(i.verdict)?i.produced.filter(e=>e.kind==="experiment-output").map(e=>e.ref):[]}function h(s){let n=s;return (!n||typeof n!="object"||Array.isArray(n)||typeof n.question!="string"||!n.question.trim()||!Number.isSafeInteger(n.maxRounds)||n.maxRounds<1||!n.budget||typeof n.budget!="object"||Array.isArray(n.budget)||!Object.keys(n.budget).length||Object.entries(n.budget).some(([i,e])=>!["tokens","turns","wallclockMs"].includes(i)||typeof e!="number"||!Number.isFinite(e)||e<=0))&&b$1("config-invalid","investigation requires question, positive maxRounds and a finite positive budget","provide bounded investigation config"),{question:n.question,maxRounds:n.maxRounds,budget:{...n.budget}}}function R(s,n,i,e){let t=s.investigation;return b$1("invalid-input",`${n} (phase ${t?.phase??"intake"}): ${i}`,e,{items:t?[t.item,...t.rounds.at(-1)?[t.rounds.at(-1).item]:[]]:[]})}var q=(s,n)=>!!s&&!!n&&s.id===n.id&&s.claim===n.claim&&s.falsifiedBy===n.falsifiedBy,c=s=>typeof s=="string"&&s.trim().length>0,C=s=>Array.isArray(s)&&s.length>0&&s.every(c)&&new Set(s).size===s.length;function O(s,n,i){e(s,n)?.capabilities.includes(i)||b$1("missing-capability",`${n} needs ${i}`,"use a registered role with the required capability");}function g(s,n,i,e){return c$1({...s,investigation:n},`investigation.${e}`,i.by,{...n},a(i.now))}function b(s,n,i,e,t){let p=a(i.now),r=g(s,{...n,phase:"closed",outcome:e,...t?{stopReason:t}:{}},i,e);r={...r,iterations:r.iterations.map(o=>o.id==="investigation"?{...o,endedAt:p,outcome:e==="stopped"?"cancelled":"completed"}:o)};for(let o of Object.values(r.items).filter(a=>a.id===n.item||n.rounds.some(l=>l.item===a.id)))o.status!=="done"&&o.status!=="dropped"&&(r=x(r,o.id,{status:e==="resolved"&&o.id===n.item?"done":"dropped"},i.by,p));return r}function j(s){let n=(i,e,t,p)=>(r,o)=>{O(r,o.by,e);let a=r.investigation;return (!a||a.phase==="closed")&&R(r,i,"no active investigation","start a new investigation with intake {item}"),t&&a.phase!==t&&!(i==="hypotheses"&&a.phase==="preregister")&&R(r,i,`expected ${t}, got ${a.phase}`,`finish phase ${a.phase} before calling ${i}; ${i} requires phase ${t}`),W$1(r,s(),{type:`ceremony.${i}`,by:o.by,payload:o},()=>p(r,a,o,(l,u)=>R(r,i,l,u)))};return {intake(i,e){O(i,e.by,"facilitate");let t=(o,a)=>R(i,"intake",o,a);i.investigation&&t("investigation already started","use the existing investigation or initialize a new workflow"),c(e.item)||t("item is required","set intake.item to a unique investigation item ID");let p=h(i.config),r=v(i,{id:e.item,title:p.question,acceptance:["Independent evidence-based conclusion"],stage:"intake"},e.by,e.now);return r={...r,iterations:[...r.iterations,{id:"investigation",goal:p.question,budget:{...p.budget},spent:{tokens:0,turns:0,wallclockMs:0},startedAt:a(e.now),committed:[],carryover:[]}]},{state:g(r,{item:e.item,phase:"hypotheses",hypotheses:[],rounds:[],contributors:[e.by]},e,"intake"),warnings:[]}},hypotheses:n("hypotheses","define-acceptance","hypotheses",(i,e,t,p)=>{let r=t.hypotheses;return (!Array.isArray(r)||!r.length||r.some(o=>!o||!c(o.id)||!c(o.claim)||!c(o.falsifiedBy))||new Set(r.map(o=>o.id)).size!==r.length||r.length<2&&!c(t.singleHypothesisRationale))&&p("provide competing falsifiable hypotheses or single-testable rationale","set hypotheses to unique {id, claim, falsifiedBy} entries; supply singleHypothesisRationale when there is only one"),g(i,{...e,hypotheses:structuredClone(r),...c(t.singleHypothesisRationale)?{singleHypothesisRationale:t.singleHypothesisRationale}:{},contributors:[...new Set([...e.contributors,t.by])],phase:"preregister"},t,"hypotheses")}),preregister:n("preregister","define-acceptance","preregister",(i,e,t,p)=>{let r=h(i.config),o=i.iterations.find(d=>d.id==="investigation");if(e.rounds.length>=r.maxRounds||!o||N(r.budget,o.spent))return b(i,e,t,"stopped","budget or round limit exhausted");let a=t.experiment;if((!a||!c(a.id)||!c(a.procedureRef)||e.rounds.some(d=>d.experiment.id===a.id)||!Array.isArray(a.predictions)||a.predictions.length!==e.hypotheses.length||e.hypotheses.some(d=>a.predictions.filter(m=>m?.hypothesis===d.id&&c(m.prediction)).length!==1)||new Set(a.predictions.map(d=>d.prediction)).size!==a.predictions.length)&&p("preregister unique experiment with differing predictions for every hypothesis","set experiment.id to a new ID, experiment.procedureRef, and one distinct experiment.predictions entry per hypothesis"),a.replayOf){let d=e.rounds.find(m=>m.experiment.id===a.replayOf&&m.result?.valid);(!d||d.experiment.procedureRef!==a.procedureRef||d.hypotheses.length!==e.hypotheses.length||e.hypotheses.some(m=>!q(m,d.hypotheses.find(w=>w.id===m.id)))||a.predictions.some(m=>!d.experiment.predictions.some(w=>w.hypothesis===m.hypothesis&&w.prediction===m.prediction)))&&p("replay must repeat the procedure, predictions and hypotheses of a prior valid experiment","set experiment.replayOf to a valid prior experiment with identical procedureRef, predictions and hypothesis definitions");}let l=`${e.item}-run-${e.rounds.length+1}`,u=v(i,{id:l,title:`Experiment ${a.id}`,stage:"execute",acceptance:[a.procedureRef],iteration:"investigation"},t.by,t.now);return u={...u,iterations:u.iterations.map(d=>d.id==="investigation"?{...d,committed:[...d.committed,l]}:d)},g(u,{...e,phase:"observe",rounds:[...e.rounds,{experiment:structuredClone(a),hypotheses:structuredClone(e.hypotheses),item:l,by:t.by}],contributors:[...new Set([...e.contributors,t.by])]},t,"preregister")}),observe:n("observe","verify","observe",(i,e,t,p)=>{let r=e.rounds.at(-1),o=t.result;return (t.experiment!==r.experiment.id||!o||!c(o.id)||typeof o.valid!="boolean"||!c(o.summary)||!C(o.provenanceRefs)||e.rounds.some(a=>a.result?.id===o.id))&&p("observation needs current experiment, unique result and provenance","set experiment to the active experiment ID and result to {id, valid, summary, provenanceRefs} with a new result.id"),i.items[r.item]?.status!=="done"&&p("complete experiment execution before recording observations","dispatch and complete the active experiment item before calling observe"),$(i,r.item).some(a=>o.provenanceRefs.includes(a))||p("observation must link fresh experiment-output evidence from the latest completion",`include an experiment-output ref produced by the latest successful completion of item "${r.item}" in result.provenanceRefs`),g(i,{...e,phase:"update-belief",rounds:e.rounds.map(a=>a===r?{...a,result:structuredClone(o)}:a),contributors:[...new Set([...e.contributors,t.by,...f(i,r.item)])]},t,"observe")}),"update-belief":n("update-belief","define-acceptance","update-belief",(i,e,t,p)=>{let r=e.rounds.at(-1),o=t.assessments;(t.result!==r.result?.id||!Array.isArray(o)||o.length!==e.hypotheses.length||e.hypotheses.some(u=>o.filter(d=>d?.hypothesis===u.id&&["supported","refuted","uncertain"].includes(d.assessment)&&c(d.reason)).length!==1)||!["round","conclusion"].includes(t.next))&&p("belief update must assess every hypothesis against current result","set result to the latest result ID, assessments to one {hypothesis, assessment, reason} per hypothesis, and next to round or conclusion"),!r.result.valid&&o.some(u=>u.assessment!=="uncertain")&&p("invalid experiments cannot support beliefs","set every assessment to uncertain for an invalid experiment result");let a=g(i,{...e,phase:t.next==="round"?"preregister":"conclusion",rounds:e.rounds.map(u=>u===r?{...u,update:{result:t.result,assessments:structuredClone(o)}}:u),contributors:[...new Set([...e.contributors,t.by])]},t,"belief-updated"),l=a.iterations.find(u=>u.id==="investigation");return t.next==="round"&&(e.rounds.length>=h(i.config).maxRounds||N(l.budget,l.spent))&&(a=b(a,a.investigation,t,"stopped","budget or round limit exhausted")),a}),conclude:n("conclude","define-acceptance","conclusion",(i,e,t,p)=>{let r=t;return (!["resolved","inconclusive"].includes(r.outcome)||!c(r.summary)||!C(r.evidenceRefs)||r.evidenceRefs.some(o=>!e.rounds.some(a=>a.result?.provenanceRefs.includes(o))))&&p("conclusion needs observed evidence references","set outcome, summary and evidenceRefs to references preserved in recorded observations"),r.outcome==="resolved"&&(!c(r.supportedHypothesis)||!e.rounds.slice(-1).some(o=>o.result?.valid&&o.update?.assessments.some(a=>a.hypothesis===r.supportedHypothesis&&a.assessment==="supported")))&&p("resolved conclusion needs a supported hypothesis","set supportedHypothesis to a hypothesis supported by the latest valid round, or choose outcome inconclusive"),g(i,{...e,phase:"review",conclusion:{outcome:r.outcome,summary:r.summary,evidenceRefs:[...r.evidenceRefs],...r.supportedHypothesis?{supportedHypothesis:r.supportedHypothesis}:{},by:t.by},contributors:[...new Set([...e.contributors,t.by])]},t,"conclusion")}),"review-conclusion":n("review-conclusion","review","review",(i,e,t,p)=>{if(e.contributors.includes(t.by)&&p("conclusion reviewer must be independent of investigation contributors","use a review-capable role that did not contribute to or execute this investigation"),(typeof t.approve!="boolean"||!c(t.reason))&&p("review needs approval and reason","set approve to a boolean and reason to a nonempty review explanation"),!t.approve){let o=t.next??"conclusion";o!=="round"&&o!=="conclusion"&&p("review rejection next must be round or conclusion","set next to round for more evidence or conclusion for a revised conclusion");let a=g(i,{...e,phase:o==="round"?"preregister":"conclusion",reviewHistory:[...e.reviewHistory??[],{by:t.by,reason:t.reason,approve:false,next:o,replayRefs:[]}]},t,"review-rejected"),l=i.iterations.find(u=>u.id==="investigation");return o==="round"&&(e.rounds.length>=h(i.config).maxRounds||N(l.budget,l.spent))?b(a,a.investigation,t,"stopped","budget or round limit exhausted after review requested another round"):a}let r=Array.isArray(t.replayRefs)?t.replayRefs:[];return e.conclusion.outcome==="resolved"&&(!C(r)||!e.rounds.some(o=>o.experiment.replayOf&&!f(i,o.item).some(a=>f(i,e.rounds.find(l=>l.experiment.id===o.experiment.replayOf).item).includes(a))&&q(o.hypotheses.find(a=>a.id===e.conclusion.supportedHypothesis),e.rounds.at(-1).hypotheses.find(a=>a.id===e.conclusion.supportedHypothesis))&&o.result?.valid&&r.includes(o.result.id)&&o.update?.assessments.some(a=>a.hypothesis===e.conclusion.supportedHypothesis&&a.assessment==="supported")))&&p("resolved conclusion requires valid replay result and supporting belief update","set replayRefs to a valid independent replay result supporting the latest supported hypothesis definition, or reject with next round"),b(i,{...e,review:{by:t.by,reason:t.reason,replayRefs:r},reviewHistory:[...e.reviewHistory??[],{by:t.by,reason:t.reason,approve:true,replayRefs:r}]},t,e.conclusion.outcome)}),stop:n("stop","facilitate",void 0,(i,e,t,p)=>(c(t.reason)||p("stop needs reason","set reason to a nonempty explanation for stopping this investigation"),b(i,e,t,"stopped",t.reason)))}}function W(){return [{id:"independent-replay",severity:"error",check(s,n){if(n.type!=="item.complete")return [];let i=s.investigation?.rounds.find(t=>t.item===n.payload?.item),e=s.investigation?.rounds.find(t=>t.experiment.id===i?.experiment.replayOf);return e&&f(s,e.item).includes(n.by)?[{rule:"independent-replay",item:i.item,severity:"error",message:"Replay executor also executed the original experiment",fix:"assign a different deliver-capable role"}]:[]}},{id:"investigation-execution-only",severity:"error",check(s,n){if(n.type!=="item.complete")return [];let i=n.payload,e=s.investigation;return e?.phase==="observe"&&e.rounds.at(-1)?.item===i.item?[]:[{rule:"investigation-execution-only",item:i.item,severity:"error",message:"Only the active preregistered experiment can complete",fix:`complete only the active experiment item in phase observe; current phase is ${e?.phase??"intake"}`}]}}]}function D(){return [{id:"replay-worker",name:"Independent replay worker",modelTier:"small",capabilities:["deliver","verify"],canApprove:[],inputs:["preregistered-experiment"],outputs:["experiment-output"],do_not:["Do not change the replay procedure"]},{id:"investigator",name:"Investigator",modelTier:"large",capabilities:["facilitate","define-acceptance","deliver","verify"],canApprove:[],inputs:["question","prior-results"],outputs:["hypotheses","preregistered-experiment","belief-update"],do_not:["Do not revise predictions after execution","Do not approve your own conclusions"]},{id:"conclusion-reviewer",name:"Independent conclusion reviewer",modelTier:"large",capabilities:["review"],canApprove:["investigation-conclusion"],inputs:["evidence","replay","conclusion"],outputs:["conclusion-review"],do_not:["Do not approve unsupported conclusions"]}]}function E(){return [{id:"intake",name:"Intake",entryPolicy:[],exitPolicy:[{kind:"acceptance-written"}]},{id:"execute",name:"Execute preregistered experiment",entryPolicy:[{kind:"acceptance-written"},{kind:"no-open-blockers"}],exitPolicy:[{kind:"evidence",evidenceKind:"experiment-output"}]},{id:"observed",name:"Execution recorded",entryPolicy:[],exitPolicy:[]}]}function B(){return {name:"investigation",validateConfig:h,lockedConfigKeys:["question","maxRounds","budget"],vocabulary:{backlog:"Questions",item:"Investigation artifact",stage:"Investigation phase",iteration:"Investigation budget",increment:"Conclusion",ceremony:"Investigation ceremony",gate:"Independent conclusion review"},defaultStages:E,defaultRoles:D,requiredCapabilities:["facilitate","define-acceptance","deliver","verify","review"],exclusiveCapabilities:[],humanDefaults:{gates:"none"},ceremonies:j(B),plannerOptions:s=>({schedulerMode:"level",concurrencyCap:1,roleFor:n=>{let i=s.investigation?.rounds.find(o=>o.item===n.id),e=s.investigation?.rounds.find(o=>o.experiment.id===i?.experiment.replayOf),t=e?f(s,e.item):[],p=Object.values(s.roles),r=(e?void 0:p.find(o=>o.capabilities.includes("deliver")&&o.capabilities.includes("define-acceptance")))??p.find(o=>o.capabilities.includes("deliver")&&!t.includes(o.id));return r||b$1("missing-capability",`No eligible executor for experiment item "${n.id}"`,e?`register an independent deliver-capable role that did not execute "${e.item}"`:"register a role with deliver capability",{items:[n.id]}),r.id},estimateMode:"per-call",fallbackTokensPerWeight:1}),candidates:s=>s.investigation?.phase==="observe"&&!N(s.config.budget,s.iterations.find(n=>n.id==="investigation").spent)?Object.values(s.items).filter(n=>n.id===s.investigation.rounds.at(-1)?.item&&n.stage==="execute"&&n.status==="todo"):[],afterComplete:(s,n,i)=>{let e=s.investigation,t=s.iterations.find(p=>p.id==="investigation");return e?.phase!=="observe"||e.rounds.at(-1)?.item!==n||s.items[n]?.status==="done"||!t||!N(t.budget,t.spent)?s:b(s,e,{by:"investigation",now:i},"stopped",`budget exhausted before experiment item "${n}" completed; start a new investigation with sufficient budget`)},invariants:s=>[`Question: ${s.config.question}`,"Execute only the preregistered procedure; retain raw observation provenance; report invalid runs."],rules:W(),metrics:s=>({rounds:s.investigation?.rounds.length??0,validRuns:s.investigation?.rounds.filter(n=>n.result?.valid).length??0,invalidRuns:s.investigation?.rounds.filter(n=>n.result&&!n.result.valid).length??0}),report:s=>({phase:s.investigation?.phase??"intake",outcome:s.investigation?.outcome??null,rounds:s.investigation?.rounds.length??0,conclusion:s.investigation?.conclusion??null,stopReason:s.investigation?.stopReason??null})}}export{h as a,B as b};//# sourceMappingURL=chunk-YZJ6WFH4.mjs.map
|
|
2
|
-
//# sourceMappingURL=chunk-YZJ6WFH4.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/investigation/execution.ts","../src/investigation/config.ts","../src/investigation/ceremonies.ts","../src/investigation/rules.ts","../src/investigation/roles.ts","../src/investigation/stages.ts","../src/investigation/index.ts"],"names":["executionActors","state","item","event","transition","freshOutputRefs","completion","index","output","validateInvestigationConfig","raw","c","k","v","fail","reject","name","message","fix","x","sameHypothesis","a","b","text","refs","authorize","by","cap","roleOf","save","appendEvent","nowOf","closeInvestigation","outcome","reason","at","n","it","candidate","r","moveItem","investigationCeremonies","factory","make","phase","fn","s","i","applyAction","bad","addItem","h","isExhausted","e","p","prior","q","id","iteration","ref","target","replayRefs","actor","investigationRules","round","investigationRoles","investigationStages","investigation","excluded","roles","selected","role","now"],"mappings":"2GASO,SAASA,EAAgBC,CAAAA,CAAsBC,CAAAA,CAAwB,CAC5E,OAAO,CACL,GAAG,IAAI,GAAA,CAAI,CACT,GAAGD,CAAAA,CAAM,MAAA,CACN,MAAA,CACEE,CAAAA,EAAUA,EAAM,IAAA,GAAS,gBAAA,EAAqBA,CAAAA,CAAM,OAAA,CAAuB,KAAOD,CACrF,CAAA,CACC,GAAA,CAAKC,CAAAA,EAAUA,EAAM,EAAE,CAAA,CAC1B,GAAA,CAAIF,CAAAA,CAAM,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A,EAAG,MAAA,GAAW,MAAA,EAC9B,CAACwD,GACD,CAACN,CAAAA,CAAYM,CAAAA,CAAU,MAAA,CAAQA,EAAU,KAAK,CAAA,CAEvCzD,CAAAA,CACF+B,CAAAA,CACL/B,EACAkB,CAAAA,CACA,CAAE,EAAA,CAAI,eAAA,CAAiB,IAAAqD,CAAI,CAAA,CAC3B,UACA,CAAA,yCAAA,EAA4CtE,CAAI,+DAClD,CACF,CAAA,CACA,UAAA,CAAa,CAAA,EAAM,CACjB,CAAA,UAAA,EAAc,CAAA,CAAE,MAAA,CAA+B,QAAQ,GACvD,mGACF,CAAA,CACA,KAAA,CAAO6D,CAAAA,GACP,OAAA,CAAU,CAAA,GAAO,CACf,MAAA,CAAQ,EAAE,aAAA,EAAe,MAAA,CAAO,MAAA,EAAU,CAAA,CAC1C,UAAW,CAAA,CAAE,aAAA,EAAe,MAAA,CAAO,MAAA,CAAQxB,GAAMA,CAAAA,CAAE,MAAA,EAAQ,KAAK,CAAA,CAAE,QAAU,CAAA,CAC5E,WAAA,CAAa,EAAE,aAAA,EAAe,MAAA,CAAO,OAAQA,CAAAA,EAAMA,CAAAA,CAAE,MAAA,EAAU,CAACA,EAAE,MAAA,CAAO,KAAK,CAAA,CAAE,MAAA,EAAU,CAC5F,CAAA,CAAA,CACA,MAAA,CAAS,CAAA,GAAO,CACd,MAAO,CAAA,CAAE,aAAA,EAAe,KAAA,EAAS,QAAA,CACjC,QAAS,CAAA,CAAE,aAAA,EAAe,OAAA,EAAW,IAAA,CACrC,OAAQ,CAAA,CAAE,aAAA,EAAe,MAAA,CAAO,MAAA,EAAU,EAC1C,UAAA,CAAY,CAAA,CAAE,aAAA,EAAe,UAAA,EAAc,KAC3C,UAAA,CAAY,CAAA,CAAE,eAAe,UAAA,EAAc,IAC7C,EACF,CACF","file":"chunk-YZJ6WFH4.mjs","sourcesContent":["import type { Handoff, Verdict, WorkflowState } from \"../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 \"../errors.ts\";\nimport type { Budget } from \"../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 { executionActors, freshOutputRefs } from \"./execution.ts\";\nimport { fail } from \"../errors.ts\";\nimport { roleOf } from \"../roles.ts\";\nimport { addItem, moveItem } from \"../items.ts\";\nimport { applyAction } from \"../methodology.ts\";\nimport { appendEvent, nowOf } from \"../state.ts\";\nimport { isExhausted } from \"../budget.ts\";\nimport type { Capability, Ceremony, CeremonyInput, Methodology, WorkflowState } from \"../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 = s.investigation;\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 && a.id === b.id && a.claim === b.claim && a.falsifiedBy === b.falsifiedBy;\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;\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 { ...s, investigation: 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 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 = s.investigation;\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, factory(), { 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.investigation)\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 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 {\n state: 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 warnings: [],\n };\n },\n hypotheses: make(\"hypotheses\", \"define-acceptance\", \"hypotheses\", (s, x, i, bad) => {\n const h = i.hypotheses as Hypothesis[];\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: structuredClone(h),\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 return closeInvestigation(s, x, i, \"stopped\", \"budget or round limit exhausted\");\n const e = i.experiment as Experiment;\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 prior.experiment.procedureRef !== e.procedureRef ||\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) => q.hypothesis === p.hypothesis && q.prediction === p.prediction,\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: structuredClone(e),\n hypotheses: structuredClone(x.hypotheses),\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 = x.rounds.at(-1)!,\n o = i.result as Observation;\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) => (v === r ? { ...v, result: structuredClone(o) } : v)),\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 = x.rounds.at(-1)!,\n a = i.assessments as BeliefUpdate[\"assessments\"];\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 if (!r.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 ? { ...v, update: { result: i.result as string, assessments: structuredClone(a) } }\n : v,\n ),\n contributors: [...new Set([...x.contributors, i.by])],\n },\n i,\n \"belief-updated\",\n );\n const it = n.iterations.find((v) => v.id === \"investigation\")!;\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 n.investigation!,\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 if (x.contributors.includes(i.by))\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 = s.iterations.find((it) => it.id === \"investigation\")!;\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 n.investigation!,\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 x.conclusion!.outcome === \"resolved\" &&\n (!refs(replayRefs) ||\n !x.rounds.some(\n (r) =>\n r.experiment.replayOf &&\n !executionActors(s, r.item).some((actor) =>\n executionActors(\n s,\n x.rounds.find((p) => p.experiment.id === r.experiment.replayOf)!.item,\n ).includes(actor),\n ) &&\n sameHypothesis(\n r.hypotheses.find((h) => h.id === x.conclusion!.supportedHypothesis),\n x.rounds.at(-1)!.hypotheses.find((h) => h.id === x.conclusion!.supportedHypothesis),\n ) &&\n r.result?.valid &&\n replayRefs.includes(r.result.id) &&\n r.update?.assessments.some(\n (a) =>\n a.hypothesis === x.conclusion!.supportedHypothesis &&\n 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 x.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 { executionActors } from \"./execution.ts\";\nimport type { Rule } from \"../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 = s.investigation?.rounds.find(\n (r) => r.item === (a.payload as { item?: string })?.item,\n );\n const prior = s.investigation?.rounds.find(\n (r) => r.experiment.id === round?.experiment.replayOf,\n );\n return prior && executionActors(s, prior.item).includes(a.by)\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 = s.investigation;\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 \"../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 \"../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 { fail } from \"../errors.ts\";\nimport { executionActors } from \"./execution.ts\";\nimport { closeInvestigation, investigationCeremonies } from \"./ceremonies.ts\";\nimport { investigationRules } from \"./rules.ts\";\nimport { investigationRoles } from \"./roles.ts\";\nimport { investigationStages } from \"./stages.ts\";\nimport { isExhausted } from \"../budget.ts\";\nimport type { Methodology } from \"../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 = state.investigation?.rounds.find((candidate) => candidate.item === item.id);\n const prior = state.investigation?.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) => role.capabilities.includes(\"deliver\") && !excluded.includes(role.id),\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 s.investigation?.phase === \"observe\" &&\n !isExhausted(\n (s.config as InvestigationConfig).budget,\n s.iterations.find((it) => it.id === \"investigation\")!.spent,\n )\n ? Object.values(s.items).filter(\n (i) =>\n i.id === s.investigation!.rounds.at(-1)?.item &&\n i.stage === \"execute\" &&\n i.status === \"todo\",\n )\n : [],\n afterComplete: (state, item, now) => {\n const x = state.investigation;\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: s.investigation?.rounds.length ?? 0,\n validRuns: s.investigation?.rounds.filter((r) => r.result?.valid).length ?? 0,\n invalidRuns: s.investigation?.rounds.filter((r) => r.result && !r.result.valid).length ?? 0,\n }),\n report: (s) => ({\n phase: s.investigation?.phase ?? \"intake\",\n outcome: s.investigation?.outcome ?? null,\n rounds: s.investigation?.rounds.length ?? 0,\n conclusion: s.investigation?.conclusion ?? null,\n stopReason: s.investigation?.stopReason ?? null,\n }),\n };\n}\n"]}
|