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
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.1.1 (2026-10-30)
|
|
4
|
+
|
|
5
|
+
Fix wave for the ten findings of the 1.1.0 code review (Investigation and Experimentation); the decisions are in the design spec, section 25. No new ceremony, key, export, event kind or schema document.
|
|
6
|
+
|
|
7
|
+
- Investigation records are closed objects (R1): a `hypotheses` entry, the `experiment` and its `predictions` entries, the `result` and an `assessments` entry with an unknown key are refused `invalid-input` naming the key. 1.1.0 copied them into `state.json`, which `saveState` then rejected with an error pointing at the state file. Stored records are copied field by field.
|
|
8
|
+
- `preregister` after the round limit or the budget is spent is refused `invalid-input` with the fix naming `stop` (R6); 1.1.0 discarded the experiment, closed the investigation `stopped` and answered `ok: true`.
|
|
9
|
+
- `intake` refuses a workflow of another methodology and runs through the rules like every other ceremony (R7); 1.1.0 could graft an investigation record and iteration onto a Scrum, Kanban or Waterfall state.
|
|
10
|
+
- Experimentation ceremonies accept an input property whose value is `undefined` (R2), as `JSON.stringify` drops it; a host forwarding `{ by, now: options.now, ...input }` was refused `ceremony input must be JSON-safe`.
|
|
11
|
+
- `validate` of a candidate the planner dispatched (`next`) is refused `invalid-input` while its item is still `in_progress`, with the fix naming `complete` (R3): validating first moved the item to `done`, so the builder's `complete` failed and its accounting was never recorded. A candidate the host started by ceremony (`start`) is validated as before.
|
|
12
|
+
- A closed experiment keeps the `endedAt` and `outcome` of its iteration (R5); in 1.1.0 every later ceremony (`cleanup`) re-stamped them.
|
|
13
|
+
- The two `item.dispatch` checks of the `experimentation-lifecycle` rule are removed (R4): no action of that type exists, so they never ran; `candidates()`, `provision` and `start` already refuse dispatch on a stopped or exhausted experiment.
|
|
14
|
+
- Internal: the investigation ceremonies build their methodology once per factory (R9); experimentation spent totals and config are computed once per ceremony instead of once per budget dimension (R8).
|
|
15
|
+
- Finding 10 (the investigation `roleFor` throws `missing-capability` from `next` when no independent deliver role exists) is kept: core `assignRole` throws the same code in the same situation for every methodology, and the error names the item and the fix.
|
|
16
|
+
|
|
17
|
+
Compatibility: no `state.json`, schema document, event kind, export or CLI change; `VERSION` is `"1.1.1"`. Behaviour changes, all for inputs 1.1.0 accepted and then lost or mis-recorded: an unknown key in an investigation record is refused; `preregister` when exhausted is refused instead of closing the investigation; `intake` on a foreign workflow is refused; `validate` of a planner-dispatched candidate waits for the builder's completion; `now: undefined` is accepted; `endedAt` no longer drifts after closure. Size budgets re-recorded at measured size.
|
|
18
|
+
|
|
3
19
|
## 1.1.0 (2026-10-28)
|
|
4
20
|
|
|
5
|
-
|
|
21
|
+
Two standalone methodologies, Investigation (#37) and Experimentation (#38); the decisions are in the design spec, section 24. The research reports in `docs/research/` were the input; the standalone decision supersedes their composition recommendation.
|
|
22
|
+
|
|
23
|
+
- Investigation (`ex-workflow/investigation`, #37): `investigation()` with config `{ question, maxRounds, budget }`, roles `investigator`, `replay-worker`, `conclusion-reviewer`, stages `intake`, `execute`, `observed`, and the ceremonies `intake`, `hypotheses`, `preregister`, `observe`, `update-belief`, `conclude`, `review-conclusion`, `stop`. Competing falsifiable hypotheses, preregistered runs executed as items through `next` and `complete`, recorded observations (invalid runs included), belief updates, independent replay and an independent conclusion review before a conclusion is `resolved`; `inconclusive` and `stopped` are first-class outcomes; rounds and budget are bounded.
|
|
24
|
+
- Experimentation (`ex-workflow/experimentation`, #38): `experimentation()` with config `{ objective, direction, tieBreak, concurrencyCap, maxCandidates, candidateBudget, totalBudget }`, roles `coordinator`, `builder`, `validator`, `integrator`, stages `candidate`, `building`, `validation` (gate `experiment-validation`), `done`, and the ceremonies `freeze`, `provision`, `start`, `submit`, `validate`, `compare`, `integrate`, `validate-integration`, `terminate`, `stop`, `cleanup`. Frozen baseline SHA and harness, isolated workspaces recorded by identity, bounded per-candidate and total budgets, independent validation at the exact submitted SHA, deterministic ranking (score, then candidate id), exact-SHA promotion and fresh validation of the integration SHA; all-fail produces no winner.
|
|
25
|
+
- CLI: `exwf init investigation` and `exwf init experimentation`; `ceremony`, `next`, `complete`, `status`, `metrics` and the persistence commands work unchanged.
|
|
26
|
+
- Schema: `investigationConfigSchema` and `experimentationConfigSchema` in `ex-workflow/schema`; `workflowStateSchema` covers the new optional lifecycle records, so `loadState` validates them.
|
|
27
|
+
- Planner: `PlannerOptions.reservedTokens` (optional) deducts tokens reserved for in-flight work from the iteration remainder; Experimentation sets it for running candidates; omitted, dispatch is unchanged.
|
|
28
|
+
- Examples: `scripts/example-investigation.ts` and `scripts/example-experimentation.ts`, synthetic and asserted, run with `pnpm exec tsx`.
|
|
29
|
+
- API-surface test: event kinds are now collected from the TypeScript AST instead of a regex; the 1.0.0 list carried one false positive (`needs-review`, a verdict string, never an event), so the real count moves from 51 to 69.
|
|
30
|
+
|
|
31
|
+
Compatibility: additive. `MethodologyName` gains `investigation` and `experimentation`; `WorkflowState` gains the optional `investigation` and `experimentation` records, written only by those methodologies; the schema documents go from eight to ten; 18 event kinds are added (`investigation.*` 7, `experimentation.*` 11); `PlannerOptions` gains `reservedTokens`. A `.workflow/state.json` written by 1.0.x loads unchanged. Scrum, Kanban and Waterfall behaviour, payloads and messages are unchanged; their minified single-entry bundles grow by 59 B each for the planner hook (budgets at measured). `VERSION` is `"1.1.0"`.
|
|
6
32
|
|
|
7
33
|
## 1.0.1 (2026-10-24)
|
|
8
34
|
|
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ npm install ex-workflow # or: pnpm add ex-workflow
|
|
|
38
38
|
npx exwf # prints the CLI usage
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
`latest` is the supported line (1.1.1). Pre-releases, when any, are published under the `stage` dist-tag.
|
|
42
42
|
|
|
43
43
|
## Pick a methodology
|
|
44
44
|
|
|
@@ -136,6 +136,8 @@ Phases open one at a time (`kickoff`) and close through a gate (`gateReview`), h
|
|
|
136
136
|
|
|
137
137
|
## Standalone investigation and experimentation
|
|
138
138
|
|
|
139
|
+
**Investigation** runs an evidence-driven inquiry: one bounded question, competing falsifiable hypotheses, preregistered experiments, recorded observations, belief updates and an independent review before a conclusion is resolved. **Experimentation** compares isolated candidates against a frozen baseline and harness: independent validation at the exact submitted SHA, deterministic selection, and fresh validation of the integration SHA. Each runs in its own `.workflow/` state; neither nests inside, migrates into or coordinates Scrum, Kanban, Waterfall or the other. The host executes procedures, provisions workspaces, runs benchmarks and performs Git operations; the engine records and validates the resulting artifacts (see [Known limitations](#known-limitations)).
|
|
140
|
+
|
|
139
141
|
Run the complete synthetic SDK examples from this repository:
|
|
140
142
|
|
|
141
143
|
```sh
|
|
@@ -145,7 +147,7 @@ pnpm exec tsx scripts/example-experimentation.ts
|
|
|
145
147
|
|
|
146
148
|
[Investigation example](scripts/example-investigation.ts) exercises execution, observation, rejected review, independent replay and a resolved conclusion. [Experimentation example](scripts/example-experimentation.ts) compares two candidates (one nonreproducible), records exact-SHA integration, validates it afresh and cleans up. Both use explicitly synthetic in-memory host outputs and assert their final outcomes; they do not execute procedures, benchmarks, Git or filesystem operations.
|
|
147
149
|
|
|
148
|
-
|
|
150
|
+
### Investigation
|
|
149
151
|
|
|
150
152
|
```ts
|
|
151
153
|
import { init } from "ex-workflow";
|
|
@@ -163,7 +165,9 @@ state = m.ceremonies["hypotheses"]!(state, { by: "investigator", hypotheses: [
|
|
|
163
165
|
] }).state;
|
|
164
166
|
```
|
|
165
167
|
|
|
166
|
-
|
|
168
|
+
Roles: `investigator` (intake, hypotheses, preregistration, observation, belief update, conclusion), `replay-worker` (executes a replay when the investigator ran the original), `conclusion-reviewer` (approves or rejects a conclusion; may not have executed any run). Stages: `intake` → `execute` → `observed`. Each preregistered experiment is an item: `next()` briefs the executor and `complete()` records `experiment-output` evidence before `observe`. A `resolved` conclusion needs a supported hypothesis, valid supporting evidence, a valid replay and an independent review; `inconclusive` and `stopped` are first-class outcomes. Config keys: [Configuration](#investigation-investigationconfig). Ceremonies and their inputs: [Ceremonies](#ceremonies).
|
|
169
|
+
|
|
170
|
+
### Experimentation
|
|
167
171
|
|
|
168
172
|
```ts
|
|
169
173
|
import { init, addItem } from "ex-workflow";
|
|
@@ -182,11 +186,11 @@ state = m.ceremonies["freeze"]!(state, { by: "coordinator", baseSha: "a".repeat(
|
|
|
182
186
|
state = m.ceremonies["provision"]!(state, { by: "coordinator", candidate: "a", workspace: "/worktrees/a", baseSha: "a".repeat(40), isolated: true }).state;
|
|
183
187
|
```
|
|
184
188
|
|
|
185
|
-
|
|
189
|
+
Roles: `coordinator` (freeze, provision, compare, terminate, stop, cleanup), `builder` (start, submit), `validator` (validate, validate-integration), `integrator` (integrate). Stages: `candidate` → `building` → `validation` (gate `experiment-validation`) → `done`. Every candidate is an item dispatched to its author at `building`; `next()` admits at most `concurrencyCap` running candidates and reserves the tokens of in-flight work. Comparison ranks eligible validated candidates by score, then candidate id; when none is eligible the run stops without a winner. Config keys: [Configuration](#experimentation-experimentationconfig). Ceremonies and their inputs: [Ceremonies](#ceremonies).
|
|
186
190
|
|
|
187
|
-
|
|
191
|
+
### CLI
|
|
188
192
|
|
|
189
|
-
|
|
193
|
+
`exwf init investigation --config investigation.json` or `exwf init experimentation --config experimentation.json`, then the same `ceremony`, `next`, `complete`, `status`, `metrics` and persistence commands. A ceremony input file holds the object documented under [Ceremonies](#ceremonies); pass the role with `--by`.
|
|
190
194
|
|
|
191
195
|
## Persisting state
|
|
192
196
|
|
|
@@ -270,6 +274,28 @@ Run from the directory that holds `.workflow/`. Every command prints JSON on std
|
|
|
270
274
|
| `traceability` | `{ from, to[] }` phase ids: every item of `from` must trace to an item of each `to` phase before that gate |
|
|
271
275
|
| `fallbackTokensPerWeight` | as in Scrum |
|
|
272
276
|
|
|
277
|
+
### Investigation (`InvestigationConfig`)
|
|
278
|
+
|
|
279
|
+
| Key | Meaning |
|
|
280
|
+
|---|---|
|
|
281
|
+
| `question` | the question the investigation answers; it heads every brief's invariants |
|
|
282
|
+
| `maxRounds` | positive integer; a round is one preregistered experiment |
|
|
283
|
+
| `budget` | `{ tokens?, turns?, wallclockMs? }`, at least one, every value finite and positive; when it is spent no further run is dispatched and the investigation closes `stopped` |
|
|
284
|
+
|
|
285
|
+
All three keys are locked after `init` (`config set` refuses them).
|
|
286
|
+
|
|
287
|
+
### Experimentation (`ExperimentationConfig`)
|
|
288
|
+
|
|
289
|
+
| Key | Meaning |
|
|
290
|
+
|---|---|
|
|
291
|
+
| `objective` | what the score measures |
|
|
292
|
+
| `direction` (`minimize` default, or `maximize`) | how scores rank |
|
|
293
|
+
| `tieBreak` (`candidate-id`, the only value) | equal scores rank by candidate id |
|
|
294
|
+
| `concurrencyCap` (default 2), `maxCandidates` (default 4) | candidates running at once, candidates per run; the cap cannot exceed the maximum |
|
|
295
|
+
| `candidateBudget` (default `{ turns: 10 }`), `totalBudget` (default `{ turns: 40 }`) | `{ tokens?, turns?, wallclockMs? }` of positive integers, per candidate and for the whole run including control, validation and integration overhead |
|
|
296
|
+
|
|
297
|
+
Every key is locked after `init`; an unknown key is refused.
|
|
298
|
+
|
|
273
299
|
Every config is validated at `init` (`config-invalid` names the key and an example value).
|
|
274
300
|
|
|
275
301
|
## Ceremonies
|
|
@@ -297,6 +323,29 @@ Every config is validated at `init` (`config-invalid` names the key and an examp
|
|
|
297
323
|
- `changeControlBoard { change, decision, note? }` approves or rejects a change-request; an approval reopens the phases its impact analysis names.
|
|
298
324
|
- `phaseRetrospective { lessons?, adopt?, dismiss?, retire? }`; `adopt` entries are `[{ id }]`. Only `agreement` suggestions apply (baselines and config are locked); others are stored for the host.
|
|
299
325
|
|
|
326
|
+
**Investigation** (`investigator` unless noted; every input also takes `by`; every record is a closed object, an unknown key is refused)
|
|
327
|
+
- `intake { item }` names the question item and opens the investigation.
|
|
328
|
+
- `hypotheses { hypotheses: [{ id, claim, falsifiedBy }], singleHypothesisRationale? }` registers unique, falsifiable, competing hypotheses; a single hypothesis needs the rationale.
|
|
329
|
+
- `preregister { experiment: { id, procedureRef, predictions: [{ hypothesis, prediction }], replayOf? } }` creates the run item; `replayOf` names an earlier valid experiment with the same procedure and predictions, and is executed by a role that did not run it. Refused once `maxRounds` or the budget is spent; `stop` closes the investigation.
|
|
330
|
+
- `observe { experiment, result: { id, valid, summary, provenanceRefs } }` records the outcome once the run item is `done` with `experiment-output` evidence; an invalid run stays recorded.
|
|
331
|
+
- `update-belief { result, assessments: [{ hypothesis, assessment, reason }], next }` with `assessment` `supported` | `refuted` | `uncertain` and `next` `round` | `conclusion`.
|
|
332
|
+
- `conclude { outcome, summary, evidenceRefs, supportedHypothesis? }` with `outcome` `resolved` | `inconclusive`; `resolved` needs a supported hypothesis, valid supporting evidence and a valid replay.
|
|
333
|
+
- `review-conclusion { approve, reason, replayRefs?, next? }` by `conclusion-reviewer`, who may not have contributed a run; a rejection returns to `round` or `conclusion`.
|
|
334
|
+
- `stop { reason }` closes the investigation `stopped`.
|
|
335
|
+
|
|
336
|
+
**Experimentation** (SHAs are full lowercase 40- or 64-character hex; `spent` is `{ tokens?, turns?, wallclockMs? }`, cumulative for the candidate)
|
|
337
|
+
- `freeze { baseSha, harness, candidates: [{ id, item, author }] }` by `coordinator` freezes the baseline and harness and registers each candidate (an existing item and its builder role); nothing runs before the freeze.
|
|
338
|
+
- `provision { candidate, workspace, baseSha, isolated: true }` by `coordinator` records the host-created isolated workspace at the frozen base; the candidate becomes `ready`.
|
|
339
|
+
- `start { candidate }` by the builder marks the dispatched candidate `running`.
|
|
340
|
+
- `submit { candidate, sha, score, baseSha, workspace, harness, command, log, spent }` by the builder records the exact commit, the benchmark result and the usage.
|
|
341
|
+
- `validate { candidate, sha, harness, passed, reproducible, evidence, spent }` by a `validator` other than the author, at the submitted SHA and frozen harness; a failed or nonreproducible candidate is ineligible. A candidate the planner dispatched (`next`) is validated after its builder's `complete`; one the host started by ceremony needs no completion.
|
|
342
|
+
- `compare` by `coordinator` ranks the eligible validated candidates by score, then candidate id, and selects the winner; with none eligible the run stops without a winner.
|
|
343
|
+
- `integrate { selectedSha, targetSha, integrationSha, spent }` by `integrator` records the exact selected SHA merged into the current target.
|
|
344
|
+
- `validate-integration { sha, targetSha, harness, passed, evidence, spent }` by a validator independent of the author and the integrator; a pass closes the run `integrated`, a fail stops it.
|
|
345
|
+
- `terminate { candidate, status, reason, spent, log }` with `status` `failed` | `timed-out` | `cancelled` records a terminal attempt with its final usage; required for every dispatched, running or submitted candidate before `stop`.
|
|
346
|
+
- `stop { reason, spent }` by `coordinator` closes the run; candidates that never started are cancelled automatically.
|
|
347
|
+
- `cleanup { workspaces }` by `coordinator`, after closure, records the host-confirmed release of workspaces.
|
|
348
|
+
|
|
300
349
|
## Items, briefs, handoffs, accounting
|
|
301
350
|
|
|
302
351
|
**Item** (`NewItem`): `id`, `title`, `acceptance[]`, and optionally `type` (`epic`, `story`, `task`, `bug`, `change-request`, `deliverable`, `question`), `description`, `dependsOn[]`, `priority`, `weight`, `deadline`, `classOfService`, `role`, `traces[]`, `tags[]`, `phase` (Waterfall), and for bugs and change-requests `affects[]` and `impactAnalysis`. Status moves through `todo`, `in_progress`, `blocked`, `review`, `awaiting_human`, `done` or `dropped`.
|
|
@@ -358,18 +407,18 @@ The CLI validates state, role manifests, items, patches and handoffs with these
|
|
|
358
407
|
| `ex-workflow/scrum` | `scrum()`, `scrumMetrics`, `dailyReport`, `closeSprint`, presets |
|
|
359
408
|
| `ex-workflow/kanban` | `kanban()`, `board`, `kanbanMetrics`, `opsReport`, `riskReport`, `cadencesDue`, `DEFAULT_COLUMNS`, presets |
|
|
360
409
|
| `ex-workflow/waterfall` | `waterfall()`, `phaseReport`, `traceabilityMatrix`, `waterfallMetrics`, `baselinePhase`, `reopenPhases`, presets |
|
|
361
|
-
| `ex-workflow/investigation` | `investigation()`,
|
|
362
|
-
| `ex-workflow/experimentation` | `experimentation()`,
|
|
410
|
+
| `ex-workflow/investigation` | `investigation()`, `validateInvestigationConfig`; types `InvestigationConfig`, `InvestigationState`, `InvestigationRound`, `InvestigationConclusion`, `Hypothesis`, `Experiment`, `Observation`, `BeliefUpdate` |
|
|
411
|
+
| `ex-workflow/experimentation` | `experimentation()`, `validateExperimentationConfig`, `experimentationCeremonies`, `experimentationMetrics`, `experimentationReport`, `experimentationRoles`, `experimentationRules`, `experimentationStages`; types `ExperimentationConfig`, `ExperimentationState`, `ExperimentCandidate` |
|
|
363
412
|
| `ex-workflow/adapters` | `loadState`, `saveState`, `saveBrief`, `saveHandoff`, `withStateLock`, `WORKFLOW_DIR` |
|
|
364
413
|
| `ex-workflow/schema` | the ten schema documents, `validate`, `assertValid` |
|
|
365
414
|
| `ex-workflow/cli` | `runCommand`, `parseArgs`, `USAGE`: the `exwf` command as a library |
|
|
366
415
|
| `ex-workflow/types` | every public type |
|
|
367
416
|
|
|
368
|
-
Each entry ships ESM, CommonJS and `.d.ts`. Core plus one methodology is about
|
|
417
|
+
Each entry ships ESM, CommonJS and `.d.ts`. Core plus one methodology is about 51–68 kB minified.
|
|
369
418
|
|
|
370
419
|
## Compatibility and versioning
|
|
371
420
|
|
|
372
|
-
- Semver from 1.0.0. The public surface (exports of every entry point, the CLI commands, the ten schema documents, the event kinds) is frozen by test: a removal is a major version, an addition a minor one.
|
|
421
|
+
- Semver from 1.0.0. The public surface (exports of every entry point, the CLI commands, the ten schema documents, the 69 event kinds) is frozen by test: a removal is a major version, an addition a minor one.
|
|
373
422
|
- A `.workflow/state.json` written by any earlier release loads unchanged; the test suite replays state files from every published pre-release.
|
|
374
423
|
- Behaviour changes are listed per release in [CHANGELOG.md](CHANGELOG.md).
|
|
375
424
|
|
|
@@ -389,6 +438,9 @@ Deliberate, documented, and stable within 1.x.
|
|
|
389
438
|
- **Accounting outside a sprint** (a line whose `endedAt` lies in no sprint window) is kept but charged to no sprint.
|
|
390
439
|
- **Reworked items need fresh evidence**: policies and gates count only evidence recorded after the last rework.
|
|
391
440
|
- **CLI flags** take `--flag value` only; `--estimate` is the sole boolean flag.
|
|
441
|
+
- **Investigation and Experimentation run alone.** Neither nests inside, migrates into or coordinates Scrum, Kanban, Waterfall or the other; one `.workflow/` per run.
|
|
442
|
+
- **The host executes.** Core never runs a procedure, benchmark or Git command and never creates or removes a workspace; `provision`, `submit`, `integrate` and `cleanup` record what the host did. A `procedureRef`, `provenanceRefs` entry, `evidence` or `log` is a recorded reference: the engine checks its shape and linkage, not the contents behind it.
|
|
443
|
+
- **Independence is by role id.** Replay, conclusion review and validation must come from a role that did not do the work, judged by the recorded role id; authenticating who runs which role is the host's job.
|
|
392
444
|
|
|
393
445
|
## Contributing
|
|
394
446
|
|
|
@@ -398,7 +450,7 @@ pnpm test # unit, e2e scenarios per methodology, compatibility fixtures,
|
|
|
398
450
|
pnpm run ci # format, lint, typecheck, schema drift, tests, minified build, dist checks, size ratchet
|
|
399
451
|
```
|
|
400
452
|
|
|
401
|
-
The design, including every decision log since the first release, lives in [docs/superpowers/specs/2026-10-19-ex-workflow-design.md](docs/superpowers/specs/2026-10-19-ex-workflow-design.md). The end-to-end scenarios (`test/sprint.e2e.test.ts`, `test/kanban.e2e.test.ts`, `test/waterfall.e2e.test.ts`) are the best long-form examples: rework, blockers, escalations, retros, change-requests and metrics in one run each. Issues and pull requests: [github.com/Ink01101011/ex-workflow](https://github.com/Ink01101011/ex-workflow).
|
|
453
|
+
Conventions for branches, commits, tests, the frozen public surface, size budgets, docs and releases are in [CONTRIBUTING.md](CONTRIBUTING.md). The design, including every decision log since the first release, lives in [docs/superpowers/specs/2026-10-19-ex-workflow-design.md](docs/superpowers/specs/2026-10-19-ex-workflow-design.md). The end-to-end scenarios (`test/sprint.e2e.test.ts`, `test/kanban.e2e.test.ts`, `test/waterfall.e2e.test.ts`) are the best long-form examples: rework, blockers, escalations, retros, change-requests and metrics in one run each. Issues and pull requests: [github.com/Ink01101011/ex-workflow](https://github.com/Ink01101011/ex-workflow).
|
|
402
454
|
|
|
403
455
|
## License
|
|
404
456
|
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import {N,a,x as x$1,W as W$1,v as v$1,c,e}from'./chunk-6P3OKXSK.mjs';import {b}from'./chunk-2FRRD6A3.mjs';function v(t,n){return [...new Set([...t.events.filter(u=>u.type==="item.completed"&&u.payload.id===n).map(u=>u.by),...(t.items[n]?.transitions??[]).filter(u=>u.to.status==="in_progress").map(u=>u.by)])]}function W(t,n){let u;for(let d=t.events.length-1;d>=0;d--){let s=t.events[d];if(s.type==="item.completed"&&s.payload.id===n){u=s.payload;break}}return u&&["done","needs-review"].includes(u.verdict)?u.produced.filter(d=>d.kind==="experiment-output").map(d=>d.ref):[]}function x(t){let n=t;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(([u,d])=>!["tokens","turns","wallclockMs"].includes(u)||typeof d!="number"||!Number.isFinite(d)||d<=0))&&b("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 C(t,n,u,d){let s=t.investigation;return b("invalid-input",`${n} (phase ${s?.phase??"intake"}): ${u}`,d,{items:s?[s.item,...s.rounds.at(-1)?[s.rounds.at(-1).item]:[]]:[]})}var E=(t,n)=>!!t&&!!n&&t.id===n.id&&t.claim===n.claim&&t.falsifiedBy===n.falsifiedBy,m=t=>typeof t=="string"&&t.trim().length>0,A=t=>Array.isArray(t)&&t.length>0&&t.every(m)&&new Set(t).size===t.length,H=(t,n)=>t&&typeof t=="object"&&!Array.isArray(t)?Object.keys(t).find(u=>!n.includes(u)):void 0,O=(t,n)=>Array.isArray(t)?t.map(u=>H(u,n)).find(Boolean):void 0;function D(t,n,u){e(t,n)?.capabilities.includes(u)||b("missing-capability",`${n} needs ${u}`,"use a registered role with the required capability");}function h(t,n,u,d){return c({...t,investigation:n},`investigation.${d}`,u.by,{...n},a(u.now))}function R(t,n,u,d,s){let e=a(u.now),i=h(t,{...n,phase:"closed",outcome:d,...s?{stopReason:s}:{}},u,d);i={...i,iterations:i.iterations.map(p=>p.id==="investigation"?{...p,endedAt:e,outcome:d==="stopped"?"cancelled":"completed"}:p)};for(let p of Object.values(i.items).filter(r=>r.id===n.item||n.rounds.some(a=>a.item===r.id)))p.status!=="done"&&p.status!=="dropped"&&(i=x$1(i,p.id,{status:d==="resolved"&&p.id===n.item?"done":"dropped"},u.by,e));return i}function M(t){let n,u=()=>n??=t(),d=(s,e,i,p)=>(r,a)=>{D(r,a.by,e);let o=r.investigation;return (!o||o.phase==="closed")&&C(r,s,"no active investigation","start a new investigation with intake {item}"),i&&o.phase!==i&&!(s==="hypotheses"&&o.phase==="preregister")&&C(r,s,`expected ${i}, got ${o.phase}`,`finish phase ${o.phase} before calling ${s}; ${s} requires phase ${i}`),W$1(r,u(),{type:`ceremony.${s}`,by:a.by,payload:a},()=>p(r,o,a,(l,g)=>C(r,s,l,g)))};return {intake(s,e){D(s,e.by,"facilitate");let i=(r,a)=>C(s,"intake",r,a);s.methodology!=="investigation"&&i(`workflow methodology is ${s.methodology}, not investigation`,"init a workflow with the investigation methodology before intake"),s.investigation&&i("investigation already started","use the existing investigation or initialize a new workflow"),m(e.item)||i("item is required","set intake.item to a unique investigation item ID");let p=x(s.config);return W$1(s,u(),{type:"ceremony.intake",by:e.by,payload:e},()=>{let r=v$1(s,{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:[]}]},h(r,{item:e.item,phase:"hypotheses",hypotheses:[],rounds:[],contributors:[e.by]},e,"intake")})},hypotheses:d("hypotheses","define-acceptance","hypotheses",(s,e,i,p)=>{let r=i.hypotheses,a=O(r,["id","claim","falsifiedBy"]);return a&&p(`unknown key "${a}" in a hypotheses entry`,"use only id, claim and falsifiedBy in each hypotheses entry"),(!Array.isArray(r)||!r.length||r.some(o=>!o||!m(o.id)||!m(o.claim)||!m(o.falsifiedBy))||new Set(r.map(o=>o.id)).size!==r.length||r.length<2&&!m(i.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"),h(s,{...e,hypotheses:r.map(o=>({id:o.id,claim:o.claim,falsifiedBy:o.falsifiedBy})),...m(i.singleHypothesisRationale)?{singleHypothesisRationale:i.singleHypothesisRationale}:{},contributors:[...new Set([...e.contributors,i.by])],phase:"preregister"},i,"hypotheses")}),preregister:d("preregister","define-acceptance","preregister",(s,e,i,p)=>{let r=x(s.config),a=s.iterations.find(c=>c.id==="investigation");(e.rounds.length>=r.maxRounds||!a||N(r.budget,a.spent))&&p(`round limit or budget exhausted (${e.rounds.length} of ${r.maxRounds} rounds used)`,"call stop {reason} to close this investigation, or start a new one with a larger maxRounds or budget");let o=i.experiment,l=H(o,["id","procedureRef","predictions","replayOf"])??O(o?.predictions,["hypothesis","prediction"]);if(l&&p(`unknown key "${l}" in experiment`,"use only id, procedureRef, predictions [{hypothesis, prediction}] and replayOf in experiment"),(!o||!m(o.id)||!m(o.procedureRef)||e.rounds.some(c=>c.experiment.id===o.id)||!Array.isArray(o.predictions)||o.predictions.length!==e.hypotheses.length||e.hypotheses.some(c=>o.predictions.filter(y=>y?.hypothesis===c.id&&m(y.prediction)).length!==1)||new Set(o.predictions.map(c=>c.prediction)).size!==o.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"),o.replayOf){let c=e.rounds.find(y=>y.experiment.id===o.replayOf&&y.result?.valid);(!c||c.experiment.procedureRef!==o.procedureRef||c.hypotheses.length!==e.hypotheses.length||e.hypotheses.some(y=>!E(y,c.hypotheses.find(k=>k.id===y.id)))||o.predictions.some(y=>!c.experiment.predictions.some(k=>k.hypothesis===y.hypothesis&&k.prediction===y.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 g=`${e.item}-run-${e.rounds.length+1}`,f=v$1(s,{id:g,title:`Experiment ${o.id}`,stage:"execute",acceptance:[o.procedureRef],iteration:"investigation"},i.by,i.now);return f={...f,iterations:f.iterations.map(c=>c.id==="investigation"?{...c,committed:[...c.committed,g]}:c)},h(f,{...e,phase:"observe",rounds:[...e.rounds,{experiment:{id:o.id,procedureRef:o.procedureRef,predictions:o.predictions.map(c=>({hypothesis:c.hypothesis,prediction:c.prediction})),...o.replayOf?{replayOf:o.replayOf}:{}},hypotheses:e.hypotheses.map(c=>({...c})),item:g,by:i.by}],contributors:[...new Set([...e.contributors,i.by])]},i,"preregister")}),observe:d("observe","verify","observe",(s,e,i,p)=>{let r=e.rounds.at(-1),a=i.result,o=H(a,["id","valid","summary","provenanceRefs"]);return o&&p(`unknown key "${o}" in result`,"use only id, valid, summary and provenanceRefs in result"),(i.experiment!==r.experiment.id||!a||!m(a.id)||typeof a.valid!="boolean"||!m(a.summary)||!A(a.provenanceRefs)||e.rounds.some(l=>l.result?.id===a.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"),s.items[r.item]?.status!=="done"&&p("complete experiment execution before recording observations","dispatch and complete the active experiment item before calling observe"),W(s,r.item).some(l=>a.provenanceRefs.includes(l))||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`),h(s,{...e,phase:"update-belief",rounds:e.rounds.map(l=>l===r?{...l,result:{id:a.id,valid:a.valid,summary:a.summary,provenanceRefs:[...a.provenanceRefs]}}:l),contributors:[...new Set([...e.contributors,i.by,...v(s,r.item)])]},i,"observe")}),"update-belief":d("update-belief","define-acceptance","update-belief",(s,e,i,p)=>{let r=e.rounds.at(-1),a=i.assessments,o=O(a,["hypothesis","assessment","reason"]);o&&p(`unknown key "${o}" in an assessments entry`,"use only hypothesis, assessment and reason in each assessments entry"),(i.result!==r.result?.id||!Array.isArray(a)||a.length!==e.hypotheses.length||e.hypotheses.some(f=>a.filter(c=>c?.hypothesis===f.id&&["supported","refuted","uncertain"].includes(c.assessment)&&m(c.reason)).length!==1)||!["round","conclusion"].includes(i.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&&a.some(f=>f.assessment!=="uncertain")&&p("invalid experiments cannot support beliefs","set every assessment to uncertain for an invalid experiment result");let l=h(s,{...e,phase:i.next==="round"?"preregister":"conclusion",rounds:e.rounds.map(f=>f===r?{...f,update:{result:i.result,assessments:a.map(c=>({hypothesis:c.hypothesis,assessment:c.assessment,reason:c.reason}))}}:f),contributors:[...new Set([...e.contributors,i.by])]},i,"belief-updated"),g=l.iterations.find(f=>f.id==="investigation");return i.next==="round"&&(e.rounds.length>=x(s.config).maxRounds||N(g.budget,g.spent))&&(l=R(l,l.investigation,i,"stopped","budget or round limit exhausted")),l}),conclude:d("conclude","define-acceptance","conclusion",(s,e,i,p)=>{let r=i;return (!["resolved","inconclusive"].includes(r.outcome)||!m(r.summary)||!A(r.evidenceRefs)||r.evidenceRefs.some(a=>!e.rounds.some(o=>o.result?.provenanceRefs.includes(a))))&&p("conclusion needs observed evidence references","set outcome, summary and evidenceRefs to references preserved in recorded observations"),r.outcome==="resolved"&&(!m(r.supportedHypothesis)||!e.rounds.slice(-1).some(a=>a.result?.valid&&a.update?.assessments.some(o=>o.hypothesis===r.supportedHypothesis&&o.assessment==="supported")))&&p("resolved conclusion needs a supported hypothesis","set supportedHypothesis to a hypothesis supported by the latest valid round, or choose outcome inconclusive"),h(s,{...e,phase:"review",conclusion:{outcome:r.outcome,summary:r.summary,evidenceRefs:[...r.evidenceRefs],...r.supportedHypothesis?{supportedHypothesis:r.supportedHypothesis}:{},by:i.by},contributors:[...new Set([...e.contributors,i.by])]},i,"conclusion")}),"review-conclusion":d("review-conclusion","review","review",(s,e,i,p)=>{if(e.contributors.includes(i.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 i.approve!="boolean"||!m(i.reason))&&p("review needs approval and reason","set approve to a boolean and reason to a nonempty review explanation"),!i.approve){let a=i.next??"conclusion";a!=="round"&&a!=="conclusion"&&p("review rejection next must be round or conclusion","set next to round for more evidence or conclusion for a revised conclusion");let o=h(s,{...e,phase:a==="round"?"preregister":"conclusion",reviewHistory:[...e.reviewHistory??[],{by:i.by,reason:i.reason,approve:false,next:a,replayRefs:[]}]},i,"review-rejected"),l=s.iterations.find(g=>g.id==="investigation");return a==="round"&&(e.rounds.length>=x(s.config).maxRounds||N(l.budget,l.spent))?R(o,o.investigation,i,"stopped","budget or round limit exhausted after review requested another round"):o}let r=Array.isArray(i.replayRefs)?i.replayRefs:[];return e.conclusion.outcome==="resolved"&&(!A(r)||!e.rounds.some(a=>a.experiment.replayOf&&!v(s,a.item).some(o=>v(s,e.rounds.find(l=>l.experiment.id===a.experiment.replayOf).item).includes(o))&&E(a.hypotheses.find(o=>o.id===e.conclusion.supportedHypothesis),e.rounds.at(-1).hypotheses.find(o=>o.id===e.conclusion.supportedHypothesis))&&a.result?.valid&&r.includes(a.result.id)&&a.update?.assessments.some(o=>o.hypothesis===e.conclusion.supportedHypothesis&&o.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"),R(s,{...e,review:{by:i.by,reason:i.reason,replayRefs:r},reviewHistory:[...e.reviewHistory??[],{by:i.by,reason:i.reason,approve:true,replayRefs:r}]},i,e.conclusion.outcome)}),stop:d("stop","facilitate",void 0,(s,e,i,p)=>(m(i.reason)||p("stop needs reason","set reason to a nonempty explanation for stopping this investigation"),R(s,e,i,"stopped",i.reason)))}}function P(){return [{id:"independent-replay",severity:"error",check(t,n){if(n.type!=="item.complete")return [];let u=t.investigation?.rounds.find(s=>s.item===n.payload?.item),d=t.investigation?.rounds.find(s=>s.experiment.id===u?.experiment.replayOf);return d&&v(t,d.item).includes(n.by)?[{rule:"independent-replay",item:u.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(t,n){if(n.type!=="item.complete")return [];let u=n.payload,d=t.investigation;return d?.phase==="observe"&&d.rounds.at(-1)?.item===u.item?[]:[{rule:"investigation-execution-only",item:u.item,severity:"error",message:"Only the active preregistered experiment can complete",fix:`complete only the active experiment item in phase observe; current phase is ${d?.phase??"intake"}`}]}}]}function z(){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 K(){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 T(){return {name:"investigation",validateConfig:x,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:K,defaultRoles:z,requiredCapabilities:["facilitate","define-acceptance","deliver","verify","review"],exclusiveCapabilities:[],humanDefaults:{gates:"none"},ceremonies:M(T),plannerOptions:t=>({schedulerMode:"level",concurrencyCap:1,roleFor:n=>{let u=t.investigation?.rounds.find(p=>p.item===n.id),d=t.investigation?.rounds.find(p=>p.experiment.id===u?.experiment.replayOf),s=d?v(t,d.item):[],e=Object.values(t.roles),i=(d?void 0:e.find(p=>p.capabilities.includes("deliver")&&p.capabilities.includes("define-acceptance")))??e.find(p=>p.capabilities.includes("deliver")&&!s.includes(p.id));return i||b("missing-capability",`No eligible executor for experiment item "${n.id}"`,d?`register an independent deliver-capable role that did not execute "${d.item}"`:"register a role with deliver capability",{items:[n.id]}),i.id},estimateMode:"per-call",fallbackTokensPerWeight:1}),candidates:t=>t.investigation?.phase==="observe"&&!N(t.config.budget,t.iterations.find(n=>n.id==="investigation").spent)?Object.values(t.items).filter(n=>n.id===t.investigation.rounds.at(-1)?.item&&n.stage==="execute"&&n.status==="todo"):[],afterComplete:(t,n,u)=>{let d=t.investigation,s=t.iterations.find(e=>e.id==="investigation");return d?.phase!=="observe"||d.rounds.at(-1)?.item!==n||t.items[n]?.status==="done"||!s||!N(s.budget,s.spent)?t:R(t,d,{by:"investigation",now:u},"stopped",`budget exhausted before experiment item "${n}" completed; start a new investigation with sufficient budget`)},invariants:t=>[`Question: ${t.config.question}`,"Execute only the preregistered procedure; retain raw observation provenance; report invalid runs."],rules:P(),metrics:t=>({rounds:t.investigation?.rounds.length??0,validRuns:t.investigation?.rounds.filter(n=>n.result?.valid).length??0,invalidRuns:t.investigation?.rounds.filter(n=>n.result&&!n.result.valid).length??0}),report:t=>({phase:t.investigation?.phase??"intake",outcome:t.investigation?.outcome??null,rounds:t.investigation?.rounds.length??0,conclusion:t.investigation?.conclusion??null,stopReason:t.investigation?.stopReason??null})}}export{x as a,T as b};//# sourceMappingURL=chunk-7QQY4KJ2.mjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-7QQY4KJ2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
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","s","name","message","fix","x","sameHypothesis","a","b","text","refs","extraKey","keys","extraKeyIn","list","authorize","by","cap","roleOf","save","i","appendEvent","nowOf","closeInvestigation","outcome","reason","at","n","it","candidate","r","moveItem","investigationCeremonies","factory","built","methodology","make","phase","fn","applyAction","bad","addItem","h","extra","isExhausted","e","extraExperiment","p","prior","q","id","iteration","o","ref","entry","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,EAAM,MAAA,CACN,MAAA,CACEE,GAAUA,CAAAA,CAAM,IAAA,GAAS,kBAAqBA,CAAAA,CAAM,OAAA,CAAuB,EAAA,GAAOD,CACrF,EACC,GAAA,CAAKC,CAAAA,EAAUA,EAAM,EAAE,CAAA,CAC1B,IAAIF,CAAAA,CAAM,KAAA,CAAMC,CAAI,CAAA,EAAG,aAAe,EAAC,EACpC,OAAQE,CAAAA,EAAeA,CAAAA,CAAW,GAAG,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,CAAA,CAAGM,CAAAA,EAAS,EAAGA,CAAAA,EAAAA,CAAS,CAC7D,IAAMJ,CAAAA,CAAQF,C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AAK,CAAA,CAEvCjE,EACFqC,CAAAA,CACLrC,CAAAA,CACAmB,EACA,CAAE,EAAA,CAAI,gBAAiB,GAAA,CAAA8D,CAAI,CAAA,CAC3B,SAAA,CACA,4CAA4ChF,CAAI,CAAA,6DAAA,CAClD,CACF,CAAA,CACA,UAAA,CAAac,GAAM,CACjB,CAAA,UAAA,EAAcA,CAAAA,CAAE,MAAA,CAA+B,QAAQ,CAAA,CAAA,CACvD,mGACF,EACA,KAAA,CAAOyD,CAAAA,GACP,OAAA,CAAUzD,CAAAA,GAAO,CACf,MAAA,CAAQA,EAAE,aAAA,EAAe,MAAA,CAAO,QAAU,CAAA,CAC1C,SAAA,CAAWA,EAAE,aAAA,EAAe,MAAA,CAAO,MAAA,CAAQ6B,CAAAA,EAAMA,EAAE,MAAA,EAAQ,KAAK,EAAE,MAAA,EAAU,CAAA,CAC5E,YAAa7B,CAAAA,CAAE,aAAA,EAAe,MAAA,CAAO,MAAA,CAAQ6B,GAAMA,CAAAA,CAAE,MAAA,EAAU,CAACA,CAAAA,CAAE,MAAA,CAAO,KAAK,CAAA,CAAE,MAAA,EAAU,CAC5F,CAAA,CAAA,CACA,OAAS7B,CAAAA,GAAO,CACd,MAAOA,CAAAA,CAAE,aAAA,EAAe,OAAS,QAAA,CACjC,OAAA,CAASA,CAAAA,CAAE,aAAA,EAAe,SAAW,IAAA,CACrC,MAAA,CAAQA,EAAE,aAAA,EAAe,MAAA,CAAO,QAAU,CAAA,CAC1C,UAAA,CAAYA,EAAE,aAAA,EAAe,UAAA,EAAc,KAC3C,UAAA,CAAYA,CAAAA,CAAE,eAAe,UAAA,EAAc,IAC7C,EACF,CACF","file":"chunk-7QQY4KJ2.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;\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 { ...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 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 = 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, 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 (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 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 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: {\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 = x.rounds.at(-1)!,\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 = x.rounds.at(-1)!,\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 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 ? {\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 = 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"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkEACZBAP3_cjs=require('./chunk-EACZBAP3.cjs'),chunkS3BXVHO7_cjs=require('./chunk-S3BXVHO7.cjs');var y=["tokens","turns","wallclockMs"];function w(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function r(e){return chunkS3BXVHO7_cjs.b("invalid-input",e,"supply valid experimentation ceremony input")}function m(e,t){return (typeof e!="string"||!e.trim())&&r(`${t} must be a non-empty string`),e}function x(e,t="sha"){let n=m(e,t);return /^[a-f0-9]{40}$|^[a-f0-9]{64}$/.test(n)||r(`${t} must be a full lowercase commit SHA`),n}function ee(e,t){(!w(e)||!y.some(a=>e[a]!==void 0)||Object.keys(e).some(a=>!y.includes(a)))&&r(`${t} needs tokens, turns or wallclockMs limits`);let n={};for(let a of y){let i=e[a];i!==void 0&&((typeof i!="number"||!Number.isSafeInteger(i)||i<=0)&&r(`${t}.${a} must be a positive safe integer`),n[a]=i);}return n}function b(e){try{w(e)||r("experimentation config must be an object");let t=["objective","direction","tieBreak","concurrencyCap","maxCandidates","candidateBudget","totalBudget"];Object.keys(e).some(c=>!t.includes(c))&&r("unknown experimentation config key");let n=m(e.objective,"objective"),a=e.direction??"minimize";a!=="minimize"&&a!=="maximize"&&r("direction must be minimize or maximize");let i=e.tieBreak??"candidate-id";i!=="candidate-id"&&r("tieBreak must be candidate-id");let o=e.concurrencyCap??2,s=e.maxCandidates??4;for(let[c,d]of Object.entries({concurrencyCap:o,maxCandidates:s}))(typeof d!="number"||!Number.isSafeInteger(d)||d<1)&&r(`${c} must be a positive safe integer`);return o>s&&r("concurrencyCap cannot exceed maxCandidates"),{objective:n,direction:a,tieBreak:i,concurrencyCap:o,maxCandidates:s,candidateBudget:ee(e.candidateBudget??{turns:10},"candidateBudget"),totalBudget:ee(e.totalBudget??{turns:40},"totalBudget")}}catch(t){chunkS3BXVHO7_cjs.b("config-invalid",t instanceof Error?t.message:"invalid experimentation config","provide objective and positive finite limits");}}function v(e){return (e.methodology!=="experimentation"||!e.experimentation)&&r("freeze an experimentation workflow first"),e.experimentation}function te(e,t,n){chunkEACZBAP3_cjs.e(e,t)?.capabilities.includes(n)||chunkS3BXVHO7_cjs.b("missing-capability",`${t} needs ${n}`,"use a role with the required capability");}function ne(e,t,n){return e.events.reduce((a,i)=>{if(i.type!=="item.completed"||!w(i.payload))return a;let o=i.payload;return typeof o.id!="string"||o.role!==i.by||t!==void 0&&o.id!==t||n!==void 0&&o.role!==n||typeof o.tokens!="number"||!Number.isFinite(o.tokens)||o.tokens<0||typeof o.durationMs!="number"||!Number.isFinite(o.durationMs)||o.durationMs<0||t===void 0&&Object.values(e.experimentation?.candidates??{}).some(s=>s.item===o.id)?a:{tokens:a.tokens+o.tokens,turns:a.turns+1,wallclockMs:a.wallclockMs+o.durationMs}},{tokens:0,turns:0,wallclockMs:0})}function q(e,t){return {tokens:Math.max(e.tokens,t.tokens),turns:Math.max(e.turns,t.turns),wallclockMs:Math.max(e.wallclockMs,t.wallclockMs)}}function S(e,t){return q(t.spent,ne(e,t.item,t.author))}function D(e,t){if(!e.experimentation)return e;let n=C(e),a=["stopped","integrated"].includes(e.experimentation.status);return {...e,iterations:e.iterations.map(i=>i.id==="experiment"?{...i,budget:{...b(e.config).totalBudget},spent:n,...a?{endedAt:i.endedAt??chunkEACZBAP3_cjs.a(t),outcome:i.outcome??(e.experimentation.status==="integrated"?"completed":"cancelled")}:{}}:i)}}function C(e,t=v(e)){let n=q(t.overhead,ne(e));return Object.values(t.candidates).reduce((a,i)=>{let o=S(e,i);return {tokens:a.tokens+o.tokens,turns:a.turns+o.turns,wallclockMs:a.wallclockMs+o.wallclockMs}},n)}function K(e){return Object.values(e.experimentation?.candidates??{}).filter(t=>t.status==="running"||e.items[t.item]?.status==="in_progress").length}function J(e){return Object.values(e.experimentation?.candidates??{}).reduce((t,n)=>{let a=e.items[n.item];return t+(a?.status==="in_progress"?chunkEACZBAP3_cjs.O(e,a.weight,1):0)},0)}function ue(e){let t=b(e.config).totalBudget.tokens;if(t!==void 0)return Math.max(0,t-C(e).tokens-J(e))}function V(e,t){let n=e.items[t.item];return !!n&&(!n.role||n.role===t.author)&&!!chunkEACZBAP3_cjs.e(e,t.author)?.capabilities.includes("deliver")}function G(e,t){let n=b(e.config),a=S(e,t);return y.some(i=>n.candidateBudget[i]!==void 0&&a[i]>=n.candidateBudget[i])}function z(e){if(!e.experimentation)return false;let t=b(e.config),n=C(e);return y.some(a=>t.totalBudget[a]!==void 0&&n[a]>=t.totalBudget[a])}function A(e,t){let n=m(t.candidate,"candidate");return Object.hasOwn(e.candidates,n)||r(`unknown candidate ${n}`),e.candidates[n]}function P(e,t){return typeof e[t]!="boolean"&&r(`${t} must be boolean`),e[t]}function T(e){w(e.spent)||r("spent must contain nonnegative tokens, turns and wallclockMs");let t={};for(let n of y){let a=e.spent[n];(typeof a!="number"||!Number.isSafeInteger(a)||a<0)&&r(`spent.${n} must be a nonnegative safe integer`),t[n]=a;}return t}function M(e,t){return {...e,candidates:{...e.candidates,[t.id]:t}}}function H(e,t){let n=T(t);return {...e,overhead:{tokens:e.overhead.tokens+n.tokens,turns:e.overhead.turns+n.turns,wallclockMs:e.overhead.wallclockMs+n.wallclockMs}}}function N(e,t,n){return chunkEACZBAP3_cjs.x(e,t.item,{stage:"done",status:"dropped"},n.by,n.now)}function B(e){e.status!=="running"&&r("experiment is not running");}function R(e){return ["validated","failed","timed-out","cancelled"].includes(e.status)}function F(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return true;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e)||!Array.isArray(e)&&Object.getPrototypeOf(e)!==Object.prototype)return false;t.add(e);let n=Array.isArray(e)?e.every(a=>F(a,t)):Object.values(e).every(a=>a===void 0||F(a,t));return t.delete(e),n}function k(e,t,n){return (a,i)=>((!w(i)||!F(i))&&r("ceremony input must be JSON-safe"),m(i.by,"by"),i.now!==void 0&&(typeof i.now!="string"||!Number.isFinite(Date.parse(i.now)))&&r("now must be a valid timestamp"),te(a,i.by,t),chunkEACZBAP3_cjs.W(a,ie(),{type:`ceremony.${e}`,by:i.by,payload:i},o=>chunkEACZBAP3_cjs.c(D(n(o,i),i.now),`experimentation.${e}`,i.by,structuredClone(i),chunkEACZBAP3_cjs.a(i.now))))}function ae(){return {freeze:k("frozen","facilitate",(e,t)=>{(e.methodology!=="experimentation"||e.experimentation)&&r("freeze may run only once in experimentation");let n=b(e.config),a=x(t.baseSha,"baseSha"),i=m(t.harness,"harness");(!Array.isArray(t.candidates)||t.candidates.length<1||t.candidates.length>n.maxCandidates)&&r("candidates must be a nonempty array within maxCandidates");let o={},s=new Set;for(let c of t.candidates){w(c)||r("candidate must be an object");let d=m(c.id,"candidate.id");chunkS3BXVHO7_cjs.c(d,"candidate id"),Object.hasOwn(o,d)&&r("candidate IDs must be unique safe identifiers");let l=m(c.item,"candidate.item"),f=m(c.author,"candidate.author");te(e,f,"deliver");let u=chunkEACZBAP3_cjs.u(e,l);u.role&&u.role!==f&&r("candidate item role must match frozen author"),(s.has(l)||u.stage!=="candidate"||u.status!=="todo"||u.acceptance.length===0)&&r("candidate needs a distinct todo candidate item with acceptance criteria"),s.add(l),o[d]={id:d,item:l,author:f,status:"pending",spent:{tokens:0,turns:0,wallclockMs:0}};}return {...e,iterations:[...e.iterations,{id:"experiment",goal:n.objective,budget:{...n.totalBudget},spent:{tokens:0,turns:0,wallclockMs:0},startedAt:chunkEACZBAP3_cjs.a(t.now),committed:[...s],carryover:[]}],experimentation:{status:"running",baseSha:a,harness:i,candidates:o,released:[],overhead:{tokens:0,turns:0,wallclockMs:0}}}}),provision:k("provisioned","manage-flow",(e,t)=>{let n=v(e);B(n),z(e)&&r("total experiment budget exhausted");let a=A(n,t);a.status!=="pending"&&r("candidate already provisioned");let i=m(t.workspace,"workspace");return (x(t.baseSha,"baseSha")!==n.baseSha||t.isolated!==true)&&r("provision must attest isolated workspace at the exact frozen base SHA"),Object.values(n.candidates).some(o=>o.workspace===i)&&r("candidate workspaces must be distinct"),n=M(n,{...a,workspace:i,status:"ready"}),{...e,experimentation:n}}),start:k("started","deliver",(e,t)=>{let n=v(e);B(n);let a=A(n,t);(a.status!=="ready"||a.author!==t.by)&&r("only the candidate author may start a ready candidate"),z(e)&&r("total experiment budget exhausted");let i=b(e.config),o=Object.values(n.candidates).filter(p=>p.status==="running"||e.items[p.item]?.status==="in_progress").length;o>=i.concurrencyCap&&r("candidate concurrency cap reached"),V(e,a)||r("candidate author assignment or delivery capability changed");let s=C(e);i.totalBudget.turns!==void 0&&s.turns+o>=i.totalBudget.turns&&r("total experiment budget reserved by running candidates");let c=chunkEACZBAP3_cjs.e(e,a.author),d=c.resourceClass??c.id,l=chunkEACZBAP3_cjs.R(e)[d],f=Object.values(e.items).filter(p=>p.status==="in_progress"&&p.role&&(chunkEACZBAP3_cjs.e(e,p.role)?.resourceClass??p.role)===d).length;l!==void 0&&f>=l&&r("role resource capacity reached");let u=chunkEACZBAP3_cjs.u(e,a.item),h=ue(e);h!==void 0&&chunkEACZBAP3_cjs.O(e,u.weight,1)>h&&r("total experiment token budget reserved or insufficient"),u.status!=="todo"&&r("candidate item is already dispatched"),chunkEACZBAP3_cjs.E(e,u,[{kind:"dependencies-done"},{kind:"no-open-blockers"},{kind:"acceptance-written"},...e.stages.find(p=>p.id==="building").entryPolicy],"start candidate execution"),G(e,a)&&r("candidate budget exhausted");let g=chunkEACZBAP3_cjs.x(e,a.item,{stage:"building",status:"in_progress"},t.by,t.now);return g=chunkEACZBAP3_cjs.s(g,a.item,p=>({...p,role:t.by})),{...g,experimentation:M(n,{...a,status:"running"})}}),submit:k("submitted","deliver",(e,t)=>{let n=v(e);B(n);let a=A(n,t),i=chunkEACZBAP3_cjs.u(e,a.item);(a.status!=="running"&&!(a.status==="ready"&&i.status==="in_progress")||a.author!==t.by||i.role!==t.by)&&r("only the running candidate author may submit once");let o=x(t.sha);(t.workspace!==a.workspace||t.harness!==n.harness||x(t.baseSha,"baseSha")!==n.baseSha)&&r("submission provenance must match frozen base SHA, harness and owned workspace"),(typeof t.score!="number"||!Number.isFinite(t.score))&&r("score must be finite");let s=T(t),c=m(t.command,"command"),d=m(t.log,"log"),l=b(e.config),f=S(e,{...a,spent:s}),u=y.some(p=>l.candidateBudget[p]!==void 0&&f[p]>l.candidateBudget[p]),h={...a,status:u?"timed-out":"submitted",sha:o,score:t.score,spent:f,command:c,log:d};u&&(h.reason="candidate budget exceeded");let g={...e,experimentation:M(n,h)};return g=chunkEACZBAP3_cjs.y(g,a.item,{kind:"candidate-sha",ref:o,by:t.by},t.now),g=chunkEACZBAP3_cjs.y(g,a.item,{kind:"benchmark-result",ref:JSON.stringify({score:t.score,harness:n.harness,sha:o}),by:t.by},t.now),u?N(g,h,t):g}),terminate:k("terminated","manage-flow",(e,t)=>{let n=v(e);B(n);let a=A(n,t);R(a)&&r("candidate is already terminal"),["failed","timed-out","cancelled"].includes(t.status)||r("status must be failed, timed-out or cancelled");let i=m(t.reason,"reason"),o=T(t),s=m(t.log,"log");return N({...e,experimentation:M(n,{...a,status:t.status,reason:i,spent:q(S(e,a),S(e,{...a,spent:o})),terminalLog:s})},a,t)}),validate:k("validated","verify",(e,t)=>{let n=v(e);B(n);let a=A(n,t);a.status!=="submitted"&&r("validate an unvalidated submitted candidate"),t.by===a.author&&r("candidate author cannot independently validate"),!e.events.some(h=>h.type==="experimentation.started"&&w(h.payload)&&h.payload.candidate===a.id)&&chunkEACZBAP3_cjs.u(e,a.item).status==="in_progress"&&chunkS3BXVHO7_cjs.b("invalid-input",`candidate "${a.id}" item "${a.item}" is still in progress under the planner`,`complete item "${a.item}" with the builder's handoff (candidate-sha ${a.sha}) and accounting before validating`,{items:[a.item]});let o=x(t.sha),s=m(t.harness,"harness");(o!==a.sha||s!==n.harness)&&r("validation must match exact submitted SHA and frozen harness");let c=P(t,"passed"),d=P(t,"reproducible"),l=m(t.evidence,"evidence"),f={sha:o,harness:s,by:t.by,passed:c,reproducible:d,evidence:l},u={...e,experimentation:M(H(n,t),{...a,status:c&&d?"validated":"failed",validation:f})};return u=chunkEACZBAP3_cjs.y(u,a.item,{kind:"validation",ref:l,by:t.by},t.now),u=chunkEACZBAP3_cjs.x(u,a.item,{stage:"done",status:c&&d?"done":"dropped"},t.by,t.now),u}),compare:k("compared","facilitate",(e,t)=>{let n=v(e);B(n);let a=Object.values(n.candidates);a.every(R)||r("comparison requires all candidates terminal and submissions independently validated");let i=b(e.config),o=C(e,n);if(y.some(d=>i.totalBudget[d]!==void 0&&o[d]>i.totalBudget[d]))return {...e,experimentation:{...n,status:"stopped",reason:"total budget exceeded"}};let s=a.filter(d=>{let l=S(e,d);return d.status==="validated"&&d.validation?.passed&&d.validation.reproducible&&d.validation.sha===d.sha&&d.validation.harness===n.harness&&!y.some(f=>i.candidateBudget[f]!==void 0&&l[f]>i.candidateBudget[f])});s.sort((d,l)=>(d.score-l.score)*(i.direction==="minimize"?1:-1)||(d.id<l.id?-1:d.id>l.id?1:0));let c=s[0];return {...e,experimentation:c?{...n,status:"selected",selected:c.id}:{...n,status:"stopped",reason:"no eligible candidate"}}}),integrate:k("integration-recorded","control-change",(e,t)=>{let n=v(e);(!["selected","integrating"].includes(n.status)||!n.selected)&&r("compare and select before integration"),z(e)&&r("total budget exhausted before integration");let a=n.candidates[n.selected],i=x(t.selectedSha,"selectedSha");(i!==a.sha||a.validation?.sha!==i)&&r("integration must promote the exact selected and validated SHA");let o=x(t.targetSha,"targetSha"),s=x(t.integrationSha,"integrationSha");return n.integration?.sha===s&&n.integration.targetSha===o&&r("integration already recorded"),{...e,experimentation:{...H(n,t),status:"integrating",integration:{selectedSha:i,targetSha:o,sha:s,by:t.by}}}}),"validate-integration":k("integration-validated","verify",(e,t)=>{let n=v(e);(n.status!=="integrating"||!n.integration||!n.selected)&&r("record integration before fresh validation");let a=n.integration,i=n.candidates[n.selected];(t.by===a.by||t.by===i.author)&&r("integration validation must be independent of candidate author and integrator");let o=x(t.sha),s=x(t.targetSha,"targetSha"),c=m(t.harness,"harness");(o!==a.sha||s!==a.targetSha||c!==n.harness)&&r("fresh validation must match integration SHA, current target SHA and harness");let d=P(t,"passed"),l=m(t.evidence,"evidence"),f=H(n,t),u=b(e.config),h=C(e,f),g=y.some(p=>u.totalBudget[p]!==void 0&&h[p]>u.totalBudget[p]);return {...e,experimentation:{...f,status:d&&!g?"integrated":"stopped",...d&&!g?{}:{reason:g?"total budget exceeded":"integration validation failed"},integration:{...a,validation:{by:t.by,sha:o,harness:c,evidence:l,passed:d}}}}}),stop:k("stopped","manage-flow",(e,t)=>{let n=v(e);(n.status==="stopped"||n.status==="integrated")&&r("experiment already closed");let a=m(t.reason,"reason");Object.values(n.candidates).some(s=>s.status==="running"||s.status==="submitted"||e.items[s.item]?.status==="in_progress")&&r("terminate active attempts with final usage and log before stopping");let i=Object.fromEntries(Object.values(n.candidates).map(s=>[s.id,R(s)?s:{...s,status:"cancelled",reason:a}])),o=e;for(let s of Object.values(n.candidates))R(s)||(o=N(o,s,t));return {...o,experimentation:{...H(n,t),status:"stopped",reason:a,candidates:i}}}),cleanup:k("cleanup-recorded","manage-flow",(e,t)=>{let n=v(e);return n.status!=="stopped"&&n.status!=="integrated"&&r("cleanup requires a closed experiment"),(!Array.isArray(t.workspaces)||t.workspaces.length===0||t.workspaces.some(a=>typeof a!="string"||!Object.values(n.candidates).some(i=>i.workspace===a)||n.released.includes(a))||new Set(t.workspaces).size!==t.workspaces.length)&&r("workspaces must list distinct owned unreleased identities"),{...e,experimentation:{...n,released:[...n.released,...t.workspaces]}}})}}function oe(e){let t=e.experimentation,n=Object.values(t?.candidates??{});return {candidates:n.length,validated:n.filter(a=>a.status==="validated").length,failed:n.filter(a=>a.status==="failed").length,timedOut:n.filter(a=>a.status==="timed-out").length,cancelled:n.filter(a=>a.status==="cancelled").length,integrated:t?.status==="integrated"?1:0,spent:t?{...C(e)}:{tokens:0,turns:0,wallclockMs:0},candidateTokens:Object.fromEntries(n.map(a=>[a.id,S(e,a).tokens]))}}function re(e){let t=e.experimentation;return {status:t?.status??"unfrozen",baseSha:t?.baseSha??null,harness:t?.harness??null,selected:t?.selected??null,reason:t?.reason??null,integration:t?.integration?structuredClone(t.integration):null,candidates:structuredClone(t?.candidates??{}),cleanup:Object.values(t?.candidates??{}).flatMap(n=>n.workspace&&!t?.released.includes(n.workspace)?[n.workspace]:[]),hostResponsibilities:["provision isolated workspaces at baseSha","execute candidates and the frozen harness","integrate selected SHA at the current target","execute fresh integration validation","release owned workspace identities and record cleanup"]}}function se(){return [{id:"coordinator",name:"Experiment coordinator",modelTier:"large",capabilities:["facilitate","order-backlog","manage-flow"],canApprove:[],inputs:["objective","budgets"],outputs:["comparison"],do_not:["Change the frozen baseline or harness"]},{id:"builder",name:"Candidate builder",modelTier:"large",capabilities:["deliver"],canApprove:[],inputs:["frozen harness","isolated workspace"],outputs:["candidate-sha","benchmark-result"],do_not:["Validate your own candidate","Change another candidate workspace"]},{id:"validator",name:"Independent validator",modelTier:"large",capabilities:["verify","review","approve-gate"],canApprove:["experiment-validation"],inputs:["exact candidate SHA","frozen harness"],outputs:["validation"],do_not:["Approve your own work"]},{id:"integrator",name:"Selected candidate integrator",modelTier:"large",capabilities:["deliver","control-change"],canApprove:[],inputs:["selected SHA","current target SHA"],outputs:["integration SHA"],do_not:["Declare integration validated"]}]}function de(){return [{id:"experimentation-lifecycle",severity:"error",check(e,t){let n=[],a=e.experimentation,i=t.payload;if(t.type==="item.complete"){["done","needs-review"].includes(i?.handoff?.verdict??"done")||n.push("unsupported completion verdict: terminate this attempt with final usage and log, then freeze a new experiment for retries");let o=a&&Object.values(a.candidates).find(s=>s.item===i?.item);(!o||!["submitted","validated"].includes(o.status))&&n.push("submit the candidate SHA and benchmark before completing work"),o?.status==="submitted"&&!i?.handoff?.produced?.some(s=>s.kind==="candidate-sha"&&s.ref===o.sha)&&n.push("handoff must retain the exact submitted candidate SHA");}return n.map(o=>({rule:"experimentation-lifecycle",severity:"error",message:o,fix:"follow the frozen experimentation lifecycle"}))}}]}function ce(){return [{id:"candidate",name:"Frozen candidate",entryPolicy:[],exitPolicy:[{kind:"acceptance-written"},{kind:"no-open-blockers"},{kind:"dependencies-done"}]},{id:"building",name:"Isolated candidate execution",entryPolicy:[{kind:"acceptance-written"},{kind:"no-open-blockers"},{kind:"dependencies-done"}],exitPolicy:[{kind:"evidence",evidenceKind:"candidate-sha"},{kind:"evidence",evidenceKind:"benchmark-result"}]},{id:"validation",name:"Independent exact-SHA validation",review:true,entryPolicy:[],exitPolicy:[{kind:"evidence",evidenceKind:"validation"}],gate:{id:"experiment-validation",requires:[{capability:"verify"}],evidence:["validation"],onFail:{action:"block"}}},{id:"done",name:"Candidate work complete",entryPolicy:[],exitPolicy:[],deliveryPoint:true}]}function ie(){return {name:"experimentation",vocabulary:{backlog:"Candidate pool",item:"Candidate work item",stage:"Experiment stage",iteration:"Experiment run",increment:"Validated integration",ceremony:"Experiment control",gate:"Independent validation"},validateConfig:b,defaultStages:ce,defaultRoles:se,requiredCapabilities:["facilitate","manage-flow","deliver","verify","control-change"],exclusiveCapabilities:[],plannerOptions(e){let t=b(e.config);return {schedulerMode:"throughput",dispatchStage:"building",concurrencyCap:Math.max(1,t.concurrencyCap-K(e)),fallbackTokensPerWeight:1,reservedTokens:J(e),roleFor(n){return Object.values(e.experimentation?.candidates??{}).find(a=>a.item===n.id)?.author}}},candidates(e){let t=e.experimentation;if(!t||t.status!=="running")return [];let n=b(e.config);return z(e)||K(e)>=n.concurrencyCap?[]:Object.values(t.candidates).filter(a=>a.status==="ready"&&V(e,a)&&e.items[a.item]?.status==="todo"&&!G(e,a)).map(a=>e.items[a.item])},afterComplete(e,t,n){return D(e,n)},invariants(e,t){let n=e.experimentation,a=Object.values(n?.candidates??{}).find(i=>i.item===t.id);return [`Frozen base SHA: ${n?.baseSha??"unfrozen"}; harness: ${n?.harness??"unfrozen"}`,`Candidate: ${a?.id??"unregistered"}; isolated workspace: ${a?.workspace??"not provisioned"}`,`Objective and budget: ${JSON.stringify(e.config)}`,"Submit an exact commit SHA and harness benchmark before completion; independent validation is mandatory.","Host owns process execution, Git integration and workspace cleanup."]},ceremonies:ae(),rules:de(),metrics:oe,report:re,humanDefaults:{gates:"none"},lockedConfigKeys:["objective","direction","tieBreak","concurrencyCap","maxCandidates","candidateBudget","totalBudget"]}}exports.a=b;exports.b=ae;exports.c=oe;exports.d=re;exports.e=se;exports.f=de;exports.g=ce;exports.h=ie;//# sourceMappingURL=chunk-AD4Z3JBL.cjs.map
|
|
2
|
+
//# sourceMappingURL=chunk-AD4Z3JBL.cjs.map
|