Testing architecture for non-deterministic multi-agent Claude Code plugin

Session: brainstorm-testing-nondeterministic-plugin-20260319-143543
deep yolo mode 3 rounds 6 agents 2026-03-19T18:35:43Z
Research
Setup
Ideation
Evaluation
Synthesis
Red Team
Arbiter
Complete
96
Ideas Generated
3
Duplicates Removed
93
Final Ideas
9
Clusters

Agents

Delusional Visionary
sonnet · 16 ideas ( R1:8 R2:5 R3:3)
Customer Voice
sonnet · 16 ideas ( R1:8 R2:5 R3:3)
Formal Methods Purist
sonnet · 16 ideas ( R1:8 R2:5 R3:3)
Battle Scarred Sre
sonnet · 16 ideas ( R1:8 R2:5 R3:3)
Testing Economist
sonnet · 16 ideas ( R1:8 R2:5 R3:3)
Bash Whisperer
sonnet · 16 ideas ( R1:8 R2:5 R3:3)

Idea Flow by Round

R1
48 ideas −3 dedup → 45
R2
30 ideas → 30
R3
18 ideas → 18
96 generated → 3 deduped → 93 final
Round 1 — Independent Ideation — 48 ideas from 6 agents, 3 deduped → 45 final
Delusional Visionary (8 ideas)
1. Treat non-determinism as the test oracle itself: run the pipeline 1000 times with live LLM calls and assert that the *distribution* of state-file transitions has zero structural variance — if orchestration is correct, only content varies, never the graph of phase edges traversed.
2. Replace the test suite entirely with a formal specification language that compiles bash scripts directly from a state-machine DSL, making the implementation and its correctness proofs a single artifact with no separate test code to maintain.
3. Use the LLM itself as the test harness: feed every state file produced by the pipeline back to a separate "judge" LLM that was trained exclusively on the pipeline's own schema contracts, and let it flag structural violations in real time with no human-authored assertions.
4. Collapse the mock/real boundary by building a "quantum superposition runner" that executes every pipeline phase simultaneously against both a mock LLM and the real LLM, and flags any orchestration divergence between the two runs as an automatic regression alert.
5. Invert the testing model entirely — instead of testing that the pipeline produces correct outputs, instrument each bash phase so it continuously tries to corrupt its own state file and then validates that its own guard conditions detect and reject the corruption, turning every production run into a
6. Build a self-healing pipeline where the state machine is defined as a TLA+ specification, and at runtime each phase automatically model-checks the current global state against the spec before executing, making every live production invocation a formal verification pass.
7. Abolish regression tests in favor of a living diff engine: record every CI run's full structured trace permanently, and instead of asserting pass/fail, surface a semantic diff of orchestration behavior across runs so developers see *how* behavior evolved rather than whether it broke a fixed threshol
8. Generate the entire test suite automatically by having an LLM analyze the bash scripts once, infer all implicit contracts and invariants, write them as executable BATS assertions, and then continuously re-generate the suite whenever the scripts change — so test maintenance cost asymptotes to zero.
Customer Voice (8 ideas)
1. Start with BATS tests for the bash orchestration layer first and only expand to more exotic tooling after those tests have actually caught a real regression, not before.
2. Every test fixture (state file, mock LLM response) should live in a plain directory next to the test that uses it so a new contributor can find, read, and modify it without reading documentation.
3. JSON Schema validation of state files is the single highest-ROI investment: define the schema once, run `ajv` or `jv` in one line per phase, and every malformed state transition becomes a CI failure automatically.
4. The LLM boundary mock should be a dead-simple bash function that reads a canned response from a flat file, not a networked mock server that itself needs maintenance and a port allocation strategy.
5. Record-replay is only worth building if re-recording a fixture takes under five minutes and can be done by running a single documented command, otherwise the corpus will rot and become a liability within months.
6. Any property-based or stateful Hypothesis test that duplicates the state machine logic in Python should be rejected until the BATS layer has existed long enough to prove that class of bug is actually escaping it.
7. The CI gate must be a single `make test` command with zero required environment variables, zero credentials, and a pass/fail exit code, so that onboarding a new contributor to the test suite takes less than ten minutes.
8. Chaos and fault-injection tests belong in a clearly labeled `tests/resilience/` directory that is explicitly excluded from the commit gate, so they can be run deliberately without ever surprising a developer who just wants a green check.
Formal Methods Purist (8 ideas)
1. Define the pipeline state machine as a formal tuple (S, E, delta, s0, F) where S is the complete set of states, E the event alphabet, and delta the total transition function — any unspecified (state, event) pair is a test-generating obligation, not an implementation gap to ignore.
2. The coverage-vs-reliability contradiction dissolves entirely once you acknowledge that coverage of orchestration correctness means coverage of invariants, not coverage of code paths — enumerate every invariant formally, and testing only those invariants is by definition complete coverage of what mat
3. Treat every JSON state file as a typed value in a formal schema language (JSON Schema or better, a dependently-typed spec), and assert not just structural conformance but semantic constraints such as "phase_status = complete implies results array is non-empty" at every read and write point
4. Model ephemeral in-memory state and persistent disk state as two separate state spaces whose consistency is itself an invariant — the hidden coupling between these two spaces is where the most dangerous unspecified transitions live and where property-based tests should be concentrated.
5. Generate the test suite automatically from the formal state machine definition by enumerating all legal and illegal (state, event) pairs, so that adding a new state or transition simultaneously adds the corresponding tests without any manual test-writing step.
6. Specify every phase as a Hoare triple {P} phase_script {Q} where P is the precondition on state files and environment and Q is the postcondition, and make the test harness mechanically verify that no execution of the script can satisfy P yet violate Q regardless of what string the mocked LLM returns
7. Require that every error-handling path in the orchestration layer be reachable from a formally specified fault model — if a fault (timeout, malformed JSON, exit code non-zero) is not listed in the fault model, the error handler for it is untested speculation and must be treated as dead code until th
8. Adopt a monotonicity invariant as a first-class executable property: encode "phase index never decreases except via an explicit retry event" as a Hypothesis stateful rule that fires on every generated command sequence, giving automatic regression detection for any code change that accident
Battle Scarred Sre (8 ideas)
1. Fault injection must be a first-class citizen on every commit run, not a weekly luxury — a mock LLM that returns malformed JSON, a mid-stream connection drop, or a 429 at the right boundary catches more real bugs in 5 seconds than a full end-to-end happy-path run in 5 minutes.
2. After every test that injects any failure — disk full, bad JSON, timeout, permission denied — the test harness must atomically verify the entire state file tree for corruption, because a pipeline that silently writes partial JSON to disk is worse than one that crashes loudly.
3. The pipeline's execution trace must be structured, append-only, and emitted unconditionally so that every CI failure doubles as a replay artifact for post-incident investigation — without a deterministic reproduction path, debugging production failures is archaeology, not engineering.
4. Race condition tests for concurrent agent writes to shared state files belong in the commit-gating suite, not the nightly suite, because state file corruption from concurrent access is the silent killer that only surfaces under load after you've already shipped.
5. Every environment variable the pipeline consumes must be individually withdrawn mid-execution in a dedicated fault injection test, not just checked at startup, because the failure mode that actually bites is a variable that disappears between phase 2 and phase 3.
6. Treat the test infrastructure itself as a system under test: the mock LLM stub, the state file fixtures, and the BATS harness must each have their own failure scenarios verified, because a mock that silently returns success when it should fail is the most dangerous bug in your entire test suite.
7. Partial streaming response injection — where the mock LLM drops the connection at a random byte offset — must be a standard test fixture, because a pipeline that accepts a half-formed JSON response as complete will corrupt state in a way that no schema validator will catch until three phases later.
8. Every test run must record and pin the model version, prompt version, plugin version, and config hash alongside the structured trace, because without that four-tuple you cannot distinguish a regression from an LLM behavior drift, and every incident investigation starts with that question.
Testing Economist (8 ideas)
1. The minimum viable test suite is BATS unit tests for state file I/O plus JSON Schema validation for inter-phase contracts — these two layers alone catch roughly 80% of orchestration regressions at under 20% of the total infrastructure cost.
2. Before building record/replay infrastructure, measure the actual frequency of multi-phase integration bugs over the past three months; if the answer is "fewer than one per month," Layer 2 schema validation is sufficient and record/replay is expensive insurance against a rare event.
3. Every proposed test layer must answer "what is the most expensive bug this catches?" — for this plugin, that answer is almost certainly a phase-transition error that silently corrupts a state file and causes downstream agents to run on stale data, making BATS phase-transition tests the sin
4. Treat JSON Schema definitions as a capital asset, not a cost: written once in a few hours, they validate state files at every phase boundary forever, double as living documentation, and eliminate an entire class of structural regressions at near-zero marginal maintenance cost.
5. A "Layer 1.5" of lightweight integration smoke tests — BATS scripts that chain two adjacent phases with fixture state files and assert only on output schema validity, not content — captures most multi-phase integration value without the upfront cost of a full record/replay system.
6. Property-based stateful testing (Hypothesis) carries a hidden synchronization tax: the state machine model must be kept in sync with the bash implementation, creating two codebases that can diverge, so defer this layer until the state machine has demonstrated instability that manual transition enume
7. Fault injection tests for LLM timeout and malformed-response handling have HIGH ROI because these failure modes are guaranteed to occur in production and the cost of a corrupted state file is hours of manual recovery, but exotic fault injection (disk full, permission errors) has near-zero ROI in a t
8. Define a suite-level efficiency metric from day one — bugs caught per hour of test execution and bugs caught per hour of maintenance — so the team has an empirical signal for when the test suite's upkeep cost has crossed the break-even point against the bugs it prevents.
Bash Whisperer (8 ideas)
1. Implement a single `call_llm()` function as the exclusive LLM entry point, controlled by a `PIPELINE_MODE` env var that swaps in fixture-file reads instead of live `curl` calls, making the entire non-deterministic boundary a one-function toggle with zero test-infrastructure overhead.
2. Write a `bats-state-helpers.bash` shared library of jq-backed assertions (`assert_state_has_key`, `assert_phase_is`, `assert_valid_json`) loaded via BATS `load`, so every test file gets consistent, reusable state-file checks without duplicating jq invocations.
3. Use `setup() { TEST_DIR=$(mktemp -d); export STATE_DIR="$TEST_DIR"; }` with a matching `teardown()` that `rm -rf`s it, giving every BATS test an isolated, clean filesystem surface so no test can corrupt another's state files.
4. Build a record/replay trace naming convention keyed on `${PHASE}_${AGENT_ID}_${CALL_SEQ}.json` so replay mode deterministically locates the right fixture for every LLM call site without ambiguity, making multi-agent coordination tests fully reproducible from a single recorded session.
5. Write the highest-ROI test category first — error-path tests that feed malformed JSON, missing required files, and unset env vars into each phase script — because these catch the silent-corruption bugs that `set -e` misses in subshells, pipes, and command substitutions.
6. Source individual phase scripts in unit tests and call their internal functions directly (rather than running the full pipeline binary), so each function's preconditions and postconditions can be asserted in isolation without triggering agent spawns or downstream state writes.
7. Add a `jq -e` guard pattern as a bash-native schema validator: a shared helper that iterates required-key assertions and types using `jq`'s exit-code semantics, avoiding the Node.js/Python JSON Schema toolchain dependency while still catching missing-field regressions at state file boundaries.
8. Instrument the `call_llm()` wrapper to append a structured log line (`phase, call_seq, fixture_file, timestamp, exit_code`) to a per-test-run trace file, turning test execution artifacts into both debugging output and a ready-made record for the replay corpus without any separate recording step.
Dedup Report (3 removed)
Diversity Assessment (Score: ?/10)
Compiled Board (45 ideas)
[1] (bash_whisperer) Implement a single `call_llm()` function as the exclusive LLM entry point, controlled by a `PIPELINE_MODE` env var that swaps in fixture-file reads instead of live `curl` calls, making the entire non-
[2] (bash_whisperer) Write a `bats-state-helpers.bash` shared library of jq-backed assertions (`assert_state_has_key`, `assert_phase_is`, `assert_valid_json`) loaded via BATS `load`, so every test file gets consistent, re
[3] (bash_whisperer) Use `setup() { TEST_DIR=$(mktemp -d); export STATE_DIR="$TEST_DIR"; }` with a matching `teardown()` that `rm -rf`s it, giving every BATS test an isolated, clean filesystem surface so no test
[4] (bash_whisperer) Build a record/replay trace naming convention keyed on `${PHASE}_${AGENT_ID}_${CALL_SEQ}.json` so replay mode deterministically locates the right fixture for every LLM call site without ambiguity, mak
[5] (bash_whisperer) Write the highest-ROI test category first — error-path tests that feed malformed JSON, missing required files, and unset env vars into each phase script — because these catch the silent-corruption bug
[6] (bash_whisperer) Source individual phase scripts in unit tests and call their internal functions directly (rather than running the full pipeline binary), so each function's preconditions and postconditions can be asse
[7] (bash_whisperer) Add a `jq -e` guard pattern as a bash-native schema validator: a shared helper that iterates required-key assertions and types using `jq`'s exit-code semantics, avoiding the Node.js/Python JSON Schema
[8] (bash_whisperer) Instrument the `call_llm()` wrapper to append a structured log line (`phase, call_seq, fixture_file, timestamp, exit_code`) to a per-test-run trace file, turning test execution artifacts into both deb
[9] (battle_scarred_sre) Fault injection must be a first-class citizen on every commit run, not a weekly luxury — a mock LLM that returns malformed JSON, a mid-stream connection drop, or a 429 at the right boundary catches mo
[10] (battle_scarred_sre) After every test that injects any failure — disk full, bad JSON, timeout, permission denied — the test harness must atomically verify the entire state file tree for corruption, because a pipeline that
[11] (battle_scarred_sre) The pipeline's execution trace must be structured, append-only, and emitted unconditionally so that every CI failure doubles as a replay artifact for post-incident investigation — without a determinis
[12] (battle_scarred_sre) Race condition tests for concurrent agent writes to shared state files belong in the commit-gating suite, not the nightly suite, because state file corruption from concurrent access is the silent kill
[13] (battle_scarred_sre) Every environment variable the pipeline consumes must be individually withdrawn mid-execution in a dedicated fault injection test, not just checked at startup, because the failure mode that actually b
[14] (battle_scarred_sre) Treat the test infrastructure itself as a system under test: the mock LLM stub, the state file fixtures, and the BATS harness must each have their own failure scenarios verified, because a mock that s
[15] (battle_scarred_sre) Partial streaming response injection — where the mock LLM drops the connection at a random byte offset — must be a standard test fixture, because a pipeline that accepts a half-formed JSON response as
[16] (battle_scarred_sre) Every test run must record and pin the model version, prompt version, plugin version, and config hash alongside the structured trace, because without that four-tuple you cannot distinguish a regressio
[17] (customer_voice) Start with BATS tests for the bash orchestration layer first and only expand to more exotic tooling after those tests have actually caught a real regression, not before.
[18] (customer_voice) Every test fixture (state file, mock LLM response) should live in a plain directory next to the test that uses it so a new contributor can find, read, and modify it without reading documentation.
[19] (customer_voice) JSON Schema validation of state files is the single highest-ROI investment: define the schema once, run `ajv` or `jv` in one line per phase, and every malformed state transition becomes a CI failure a
[21] (customer_voice) Record-replay is only worth building if re-recording a fixture takes under five minutes and can be done by running a single documented command, otherwise the corpus will rot and become a liability wit
[23] (customer_voice) The CI gate must be a single `make test` command with zero required environment variables, zero credentials, and a pass/fail exit code, so that onboarding a new contributor to the test suite takes les
[24] (customer_voice) Chaos and fault-injection tests belong in a clearly labeled `tests/resilience/` directory that is explicitly excluded from the commit gate, so they can be run deliberately without ever surprising a de
[25] (delusional_visionary) Treat non-determinism as the test oracle itself: run the pipeline 1000 times with live LLM calls and assert that the *distribution* of state-file transitions has zero structural variance — if orchestr
[26] (delusional_visionary) Replace the test suite entirely with a formal specification language that compiles bash scripts directly from a state-machine DSL, making the implementation and its correctness proofs a single artifac
[27] (delusional_visionary) Use the LLM itself as the test harness: feed every state file produced by the pipeline back to a separate "judge" LLM that was trained exclusively on the pipeline's own schema contracts, and
[28] (delusional_visionary) Collapse the mock/real boundary by building a "quantum superposition runner" that executes every pipeline phase simultaneously against both a mock LLM and the real LLM, and flags any orchest
[29] (delusional_visionary) Invert the testing model entirely — instead of testing that the pipeline produces correct outputs, instrument each bash phase so it continuously tries to corrupt its own state file and then validates
[30] (delusional_visionary) Build a self-healing pipeline where the state machine is defined as a TLA+ specification, and at runtime each phase automatically model-checks the current global state against the spec before executin
[31] (delusional_visionary) Abolish regression tests in favor of a living diff engine: record every CI run's full structured trace permanently, and instead of asserting pass/fail, surface a semantic diff of orchestration behavio
[32] (delusional_visionary) Generate the entire test suite automatically by having an LLM analyze the bash scripts once, infer all implicit contracts and invariants, write them as executable BATS assertions, and then continuousl
[33] (formal_methods_purist) Define the pipeline state machine as a formal tuple (S, E, delta, s0, F) where S is the complete set of states, E the event alphabet, and delta the total transition function — any unspecified (state,
[34] (formal_methods_purist) The coverage-vs-reliability contradiction dissolves entirely once you acknowledge that coverage of orchestration correctness means coverage of invariants, not coverage of code paths — enumerate every
[35] (formal_methods_purist) Treat every JSON state file as a typed value in a formal schema language (JSON Schema or better, a dependently-typed spec), and assert not just structural conformance but semantic constraints such as
[36] (formal_methods_purist) Model ephemeral in-memory state and persistent disk state as two separate state spaces whose consistency is itself an invariant — the hidden coupling between these two spaces is where the most dangero
[37] (formal_methods_purist) Generate the test suite automatically from the formal state machine definition by enumerating all legal and illegal (state, event) pairs, so that adding a new state or transition simultaneously adds t
[38] (formal_methods_purist) Specify every phase as a Hoare triple {P} phase_script {Q} where P is the precondition on state files and environment and Q is the postcondition, and make the test harness mechanically verify that no
[39] (formal_methods_purist) Require that every error-handling path in the orchestration layer be reachable from a formally specified fault model — if a fault (timeout, malformed JSON, exit code non-zero) is not listed in the fau
[40] (formal_methods_purist) Adopt a monotonicity invariant as a first-class executable property: encode "phase index never decreases except via an explicit retry event" as a Hypothesis stateful rule that fires on every
[41] (testing_economist) The minimum viable test suite is BATS unit tests for state file I/O plus JSON Schema validation for inter-phase contracts — these two layers alone catch roughly 80% of orchestration regressions at und
[42] (testing_economist) Before building record/replay infrastructure, measure the actual frequency of multi-phase integration bugs over the past three months; if the answer is "fewer than one per month," Layer 2 sc
[43] (testing_economist) Every proposed test layer must answer "what is the most expensive bug this catches?" — for this plugin, that answer is almost certainly a phase-transition error that silently corrupts a stat
[45] (testing_economist) A "Layer 1.5" of lightweight integration smoke tests — BATS scripts that chain two adjacent phases with fixture state files and assert only on output schema validity, not content — captures
[46] (testing_economist) Property-based stateful testing (Hypothesis) carries a hidden synchronization tax: the state machine model must be kept in sync with the bash implementation, creating two codebases that can diverge, s
[47] (testing_economist) Fault injection tests for LLM timeout and malformed-response handling have HIGH ROI because these failure modes are guaranteed to occur in production and the cost of a corrupted state file is hours of
[48] (testing_economist) Define a suite-level efficiency metric from day one — bugs caught per hour of test execution and bugs caught per hour of maintenance — so the team has an empirical signal for when the test suite's upk
Round 2 — Piggybacking — 30 ideas from 6 agents, 0 deduped → 30 final
Delusional Visionary (5 ideas)
1. **INVERSION: The pipeline should test its environment, not the other way around.** Instead of an external test suite validating the pipeline, each pipeline invocation begins with a self-diagnostic phase that verifies: all required tools are installed and at compatible versions, all state files from
2. **SUBTRACTION: Abolish state files entirely — use the filesystem as the state machine.** Remove JSON state files and instead represent state as a directory structure: the existence of `round1/compiled.md` means round 1 compilation is complete; the existence of `round2/` means round 2 has started. Ph
3. **CROSS-DOMAIN (from biological immune systems): Adversarial co-evolution of tests and pipeline.** Build two LLM agents that co-evolve: one tries to generate inputs that break the pipeline's orchestration logic, the other patches the pipeline to survive. Run them in a loop. After N iterations, the p
4. **INVERSION: Make non-determinism the security model.** Instead of mocking the LLM for determinism, run every critical phase with THREE different LLM calls and require 2-of-3 consensus on structural output (not content). If the orchestration is correct, all three produce structurally identical state
5. **CROSS-DOMAIN (from compiler construction): Build an intermediate representation for pipeline execution.** Compile the bash pipeline into an IR (a directed acyclic graph of phase dependencies, data flows, and state mutations) before execution. Test the IR statically for: unreachable phases, cycles,
Customer Voice (5 ideas)
1. **INVERSION: Instead of writing tests, write a linter for the orchestration scripts.** A shellcheck-style linter that statically analyzes phase scripts for common orchestration anti-patterns — unguarded `jq` calls, state file writes without temp-then-rename, missing error traps in subshells, env var
2. **SUBTRACTION: Remove the test infrastructure discussion and ship self-contained example scripts.** Instead of building a test framework, ship 5 example scripts in `examples/` that demonstrate: (a) adding a new phase, (b) modifying a state file schema, (c) handling an LLM failure, (d) running the pi
3. **CROSS-DOMAIN (from API contract testing): Generate test stubs from state file diffs.** When a developer changes a state file's structure, a pre-commit hook diffs the old and new schema, and auto-generates a BATS test stub that validates the new fields. The developer fills in the expected values. T
4. **INVERSION: Test by running the pipeline backwards.** Given a known-good final output, can the pipeline's own error-recovery logic reconstruct intermediate states? If each phase can validate its own preconditions and detect "I'm being asked to redo work," then running backwards tests both
5. **CROSS-DOMAIN (from game save systems): Checkpoint/restore snapshots for pipeline state.** Borrow the save-game pattern: before each phase, serialize the complete pipeline state to a snapshot file. Tests can restore any snapshot and re-run from that point. If the output diverges from the recorded s
Formal Methods Purist (5 ideas)
1. **INVERSION: Specify what the pipeline must NOT do, instead of what it must do.** Define a set of "forbidden state predicates" — invariants that must NEVER be true at any point during execution (e.g., "two phases are both marked 'running' simultaneously," "a state file conta
2. **SUBTRACTION: Remove the state machine model and replace it with a constraint solver.** Instead of defining legal transitions and testing against them, define only the constraints (invariants) that must hold and let a constraint solver (Z3, or even a simpler SAT-based approach) verify that no seque
3. **CROSS-DOMAIN (from type theory): Dependent types for state files via refinement predicates.** Move beyond JSON Schema's structural types to refinement types: `{ phase_status: "complete", results: Array<non-empty> }` where the type of `results` depends on the value of `phase_status`
4. **INVERSION: Instead of testing transitions, test the unreachable states.** Enumerate the state space and formally prove that certain states are unreachable from the initial state via any legal sequence of events. If a test run produces a state that was proven unreachable, the formal model is wrong
5. **CROSS-DOMAIN (from hardware verification): Bounded model checking with increasing depth.** Apply bounded model checking to the pipeline: exhaustively explore all possible execution paths up to depth K (where K = number of phases). At K=1, verify all single-phase behaviors. At K=2, verify all two-p
Battle Scarred Sre (5 ideas)
1. **INVERSION: Test the cleanup path, not the execution path.** Instead of testing "does the pipeline produce correct output," test "if I kill the pipeline at every possible point (SIGTERM, SIGKILL, OOM), is the state recoverable?" Write a test harness that launches the pipeline an
2. **SUBTRACTION: Remove background agents from the unit-test surface entirely.** The pre-mortem identified agent lifecycle as a missing domain. Instead of testing agent coordination in the pipeline, extract agent-spawn logic into a standalone "agent supervisor" script that can be tested inde
3. **CROSS-DOMAIN (from Kubernetes liveness probes): Health-check contracts for each phase.** Each phase script exports a `healthcheck()` function that returns a machine-readable status: "ready", "running", "degraded", "failed". The test suite calls `healthcheck(
4. **INVERSION: Make the state file the test harness, not the test target.** Instead of tests asserting on state file contents, embed validation rules directly in the state file format — a `_constraints` key that lists invariants the file must satisfy. A generic validator reads any state file, evaluate
5. **CROSS-DOMAIN (from financial auditing): Append-only audit trail with tamper detection.** Every state file write appends a cryptographic hash of the previous state to the new state. A test can verify the hash chain at any point to detect: out-of-order writes, missing intermediate states, or state c
Testing Economist (5 ideas)
1. **INVERSION: Measure the cost of NOT testing each component, rather than the ROI of testing it.** For each pipeline component, estimate the expected cost of a production failure (hours to diagnose + hours to fix + blast radius) multiplied by the probability of failure per month. Rank components by t
2. **SUBTRACTION: Remove the test pyramid entirely and replace it with a single invariant monitor.** Instead of building five layers of tests, build one thing: a state-file invariant monitor that runs as a git pre-commit hook. It validates every state file in the repo against its schema and semantic co
3. **CROSS-DOMAIN (from insurance actuarial science): Premium-based test allocation.** Treat each test as an insurance premium: you pay a known cost (maintenance hours) to protect against an uncertain loss (production bug). Use historical bug data (or estimates) to compute the "loss ratio" fo
4. **INVERSION: Let production failures drive test creation, not speculation.** Instead of speculatively building tests for imagined failure modes, instrument the pipeline to emit machine-readable failure reports. Every production failure automatically generates a failing test case (the state files at
5. **CROSS-DOMAIN (from venture capital): Test portfolio with options thinking.** Treat the test architecture as a portfolio of options, not a fixed plan. Layer 1 (BATS) is the "safe investment" — build it now. Layer 2 (schema validation) is a "growth investment" — build it next. La
Bash Whisperer (5 ideas)
1. **INVERSION: Extract the state machine from bash entirely.** Instead of testing bash scripts that contain state logic, extract the state transition table into a standalone JSON/YAML file that a trivial bash dispatcher reads. The dispatcher is 20 lines of bash (untestable things become trivially test
2. **SUBTRACTION: Remove the mock layer entirely by making real scripts idempotent.** Instead of building a mock `call_llm()`, modify each phase script so that if the output state file already exists and is valid, the script exits 0 immediately. Testing becomes: pre-populate output fixtures, run the re
3. **CROSS-DOMAIN (from database migrations): Schema versioning with forward/backward migration tests.** Borrow the migration-test pattern from Rails/Django: every state file schema change ships with an up/down migration script, and CI runs a test that loads state files from every previous schema versi
4. **INVERSION: Test by diffing two pipeline runs instead of asserting expected output.** Instead of writing assertions for each phase, run the pipeline twice with different LLM fixture responses and diff the state file trees. Any structural difference (different keys, different phase transitions, diff
5. **CROSS-DOMAIN (from distributed systems): Adopt a write-ahead log for state mutations.** Before any state file write, append the intended mutation to a WAL file. If the script crashes mid-write, the WAL enables recovery and also serves as a test assertion target — tests can assert on the WAL entrie
Compiled Board (30 ideas)
[49] (bash_whisperer) INVERSION: Extract the state machine from bash entirely — move the transition table into a standalone JSON/YAML file that a trivial bash dispatcher reads, making the orchestration testable with any la
[50] (bash_whisperer) SUBTRACTION: Remove the mock layer entirely by making real scripts idempotent — if the output state file already exists and is valid, the script exits 0 immediately, so testing becomes pre-populating
[51] (bash_whisperer) CROSS-DOMAIN (database migrations): Schema versioning with forward/backward migration tests — every state file schema change ships with an up/down migration script, and CI validates state files from e
[52] (bash_whisperer) INVERSION: Test by diffing two pipeline runs with different LLM fixture responses — any structural difference is a regression; any content-only difference is expected.
[53] (bash_whisperer) CROSS-DOMAIN (distributed systems): Write-ahead log for state mutations — append intended mutations to a WAL before writing state files, enabling crash recovery and deterministic test assertions on in
[54] (battle_scarred_sre) INVERSION: Test the cleanup path, not the execution path — launch the pipeline and kill it at random delays (SIGTERM, SIGKILL, OOM), then assert state is either consistent or recoverable via a documen
[55] (battle_scarred_sre) SUBTRACTION: Remove background agents from the unit-test surface — extract agent-spawn logic into a standalone "agent supervisor" script testable in isolation for zombie reaping, SIGCHLD han
[56] (battle_scarred_sre) CROSS-DOMAIN (Kubernetes liveness probes): Health-check contracts — each phase script exports a `healthcheck()` function returning machine-readable status, and the test suite asserts lifecycle state c
[57] (battle_scarred_sre) INVERSION: Make the state file the test harness — embed validation rules as a `_constraints` key within the state file format itself, so a generic validator reads any state file and evaluates its own
[58] (battle_scarred_sre) CROSS-DOMAIN (financial auditing): Append-only audit trail with tamper detection — each state file write appends a cryptographic hash of the previous state, enabling hash-chain verification for out-of
[59] (customer_voice) INVERSION: Write a linter instead of tests — a shellcheck-style static analyzer for orchestration scripts that catches unguarded jq calls, non-atomic state writes, missing error traps, and env var rea
[60] (customer_voice) SUBTRACTION: Remove the test framework and ship self-contained example scripts — 5 examples in `examples/` that demonstrate adding a phase, modifying schema, handling LLM failure, running mock mode, a
[61] (customer_voice) CROSS-DOMAIN (API contract testing): Auto-generate test stubs from state file diffs — a pre-commit hook diffs old/new schema and generates BATS test stubs for the developer to fill in, reducing test-w
[62] (customer_voice) INVERSION: Test by running the pipeline backwards — given a known-good final output, use error-recovery logic to reconstruct intermediate states, testing both recovery and precondition checks simultan
[63] (customer_voice) CROSS-DOMAIN (game save systems): Checkpoint/restore snapshots at phase boundaries — serialize complete pipeline state before each phase, tests restore any snapshot and re-run from that point, detecti
[64] (delusional_visionary) INVERSION: The pipeline tests its environment, not the other way around — each invocation begins with a self-diagnostic phase verifying tool versions, state consistency, filesystem capabilities, and a
[65] (delusional_visionary) SUBTRACTION: Abolish state files entirely — represent state as a directory structure where file/directory existence IS the state (round1/compiled.md exists = round 1 compiled), making phase transition
[66] (delusional_visionary) CROSS-DOMAIN (biological immune systems): Adversarial co-evolution — two LLM agents co-evolve, one generating inputs that break orchestration logic and one patching the pipeline to survive, with the a
[67] (delusional_visionary) INVERSION: Non-determinism as security model — run every critical phase with THREE LLM calls requiring 2-of-3 structural consensus, merging testing and fault tolerance into one mechanism.
[68] (delusional_visionary) CROSS-DOMAIN (compiler construction): Compile the bash pipeline into an intermediate representation (DAG of phase dependencies, data flows, state mutations) and statically analyze it for unreachable p
[69] (formal_methods_purist) INVERSION: Specify forbidden state predicates instead of postconditions — define invariants that must NEVER be true at any execution point and monitor the full trace for violations, proving absence of
[70] (formal_methods_purist) SUBTRACTION: Replace the state machine model with a constraint solver — define only constraints/invariants and let Z3 or a SAT solver verify that no execution sequence can violate them, eliminating th
[71] (formal_methods_purist) CROSS-DOMAIN (type theory): Dependent/refinement types for state files — cross-field constraints like "phase_status = complete implies results is non-empty" implemented as jq-based validator
[72] (formal_methods_purist) INVERSION: Test unreachable states — formally prove certain states are unreachable from the initial state, then flag any test run that produces a "proven unreachable" state as either a spec
[73] (formal_methods_purist) CROSS-DOMAIN (hardware verification): Bounded model checking with increasing depth — exhaustively explore all execution paths up to depth K (K = number of phases), giving provable coverage guarantees
[74] (testing_economist) INVERSION: Measure cost of NOT testing each component — estimate expected loss (hours to diagnose + fix * probability of failure per month) and rank components by expected loss, testing the most expen
[75] (testing_economist) SUBTRACTION: Remove the test pyramid — replace all five layers with a single state-file invariant monitor running as a git pre-commit hook, one validator, zero test files to maintain.
[76] (testing_economist) CROSS-DOMAIN (insurance actuarial science): Premium-based test allocation — compute loss ratios (bug-value-caught / maintenance-cost) for each test category and allocate investment proportionally, zer
[77] (testing_economist) INVERSION: Let production failures drive test creation — instrument the pipeline to emit machine-readable failure reports that automatically become failing test cases with real state files as fixtures
[78] (testing_economist) CROSS-DOMAIN (venture capital): Options thinking for test architecture — build Layers 1-2 now, but for Layers 3-5 invest only in defining interfaces and extension points, preserving the option to buil
Round 3 — Wild Card — 18 ideas from 6 agents, 0 deduped → 18 final
Delusional Visionary (3 ideas)
1. **Reframe 2 response — Prove pipeline correctness from the git history, not the code.** Treat the git log as a formal specification: each commit that modifies a phase script implicitly asserts "this change preserves all existing invariants." Build a tool that replays the git history of sta
2. **Reframe 1 response — A universal "pipeline genome" encoding.** Encode the pipeline's complete structure as a linear sequence (like DNA): phase order, input/output schemas, error handlers, timeout values, agent counts. Define mutation operators (add phase, remove handler, change schema).
3. **Reframe 3 response — The pipeline becomes a distributed sensor network.** Every pipeline execution across every user is a sensor reading of the orchestration logic's health. Build a federated anomaly detection system: each user's local pipeline computes a structural fingerprint (hash of the phase
Customer Voice (3 ideas)
1. **Reframe 1 response — "Test recipe" templates for common pipeline modifications.** Ship a `test-recipes/` directory containing copy-paste-modify templates: "I added a new phase," "I changed a state file field," "I added an error handler," "I changed the
2. **Reframe 3 response — Opt-in "did it work?" signal from real users.** After every pipeline run, prompt the user with a single yes/no question: "Did this run produce the expected result?" Store the answer alongside the structural trace. Aggregate across users. If a commit causes
3. **Reframe 2 response — Dependency graph visualization as a testing artifact.** Generate a visual dependency graph (Mermaid or Graphviz DOT) from the bash scripts by statically parsing which scripts source which files, which scripts read/write which state files, and which scripts spawn which agents.
Formal Methods Purist (3 ideas)
1. **Reframe 2 response — Abstract interpretation of bash state transitions.** Build an abstract interpreter for the subset of bash used in phase scripts: track the abstract value of `$phase_status` (an enum), `$round_num` (a bounded integer), and `$state_file` (exists/absent/corrupted). Execute each s
2. **Reframe 1 response — A portable state machine specification language that generates both tests and validators.** Define a DSL like: `phase "round1" requires [state_file_exists("problem.md")] produces [state_file("round1_compiled.md", schema: "round1_schema")
3. **Reframe 3 response — Invariant inference from production traces.** Collect structural execution traces from real pipeline runs (anonymized). Apply invariant inference (a la Daikon): automatically discover likely invariants such as "round_num is always <= 3", "phase_status transit
Battle Scarred Sre (3 ideas)
1. **Reframe 3 response — Canary deployments for pipeline changes.** When a developer modifies a phase script, deploy the change to 10% of pipeline runs (via a feature flag in the env) and compare the structural trace distributions between canary and baseline. If the canary produces different phase tra
2. **Reframe 2 response — Symbolic execution of bash error paths.** Use a bash symbolic executor (or build a lightweight one using bash's `-n` parse mode plus manual variable tracking) to enumerate all paths through each phase script. For each path, determine: does it reach a state file write? Does it
3. **Reframe 1 response — "Pipeline crash black box" recorder.** Build a generic wrapper that captures the complete execution context at the moment of any pipeline failure: all env vars, all state files, the structured trace up to the crash point, the stderr output, and the process tree. Pack
Testing Economist (3 ideas)
1. **Reframe 2 response — Cost-benefit analysis of static vs. dynamic testing for this specific codebase.** Estimate: the codebase has ~20 bash scripts averaging ~100 lines each. Static analysis (linting + dataflow) covers ~60% of bug classes at ~8 hours of setup and ~0 hours/month maintenance. Dynamic
2. **Reframe 3 response — The "cost of a wasted run" metric as the ultimate test KPI.** For this plugin, a failed pipeline run wastes the user's time and LLM API credits. Define the KPI: "wasted run rate" = (runs that failed due to orchestration bugs) / (total runs). Track this metr
3. **Reframe 1 response — Open-source the testing framework to amortize maintenance cost.** If the testing framework is generalized (per Reframe 1), open-sourcing it means the maintenance cost is shared across all users. Other bash-pipeline projects contribute fixes, patterns, and test recipes. The plu
Bash Whisperer (3 ideas)
1. **Reframe 2 response — Static dataflow analysis of bash scripts via ShellCheck AST.** Parse each phase script into ShellCheck's AST (using `shellcheck --format=json`), then write a custom analyzer that traces the dataflow of state file variables: which functions read `$STATE_DIR/*.json`, which write
2. **Reframe 1 response — Extract a reusable `bash-pipeline-test-kit` library.** Factor out the testing patterns from this plugin into a generic library: `bpt_assert_state_schema`, `bpt_mock_boundary`, `bpt_checkpoint_restore`, `bpt_trace_verify`. Any bash pipeline that follows a state-file-per-phase c
3. **Reframe 3 response — Structural telemetry from production runs as regression canary.** Instrument the pipeline to emit a content-free structural trace on every real user run: phase names, transition edges, timing buckets (fast/medium/slow), error codes, state file sizes (not contents). Collect the
Compiled Board (18 ideas)
[79] (bash_whisperer) Static dataflow analysis of bash scripts via ShellCheck AST — parse phase scripts into ShellCheck's JSON AST, trace state file variable dataflow, and catch non-atomic writes, unvalidated reads, and de
[80] (bash_whisperer) Extract a reusable `bash-pipeline-test-kit` library — factor out testing patterns into generic helpers (`bpt_assert_state_schema`, `bpt_mock_boundary`, `bpt_checkpoint_restore`, `bpt_trace_verify`) us
[81] (bash_whisperer) Structural telemetry from production runs as regression canary — emit content-free structural traces (phase names, transition edges, timing buckets, error codes, state file sizes) to a local SQLite da
[82] (battle_scarred_sre) Canary deployments for pipeline changes — deploy changes to 10% of pipeline runs via feature flag and compare structural trace distributions between canary and baseline, blocking rollout on divergent
[83] (battle_scarred_sre) Symbolic execution of bash error paths — enumerate all paths through each phase script using bash parse mode plus variable tracking, identifying error paths that silently succeed, success paths reachi
[84] (battle_scarred_sre) "Pipeline crash black box" recorder — capture complete execution context at failure (env vars, state files, structured trace, stderr, process tree) as a self-contained reproduction archive w
[85] (customer_voice) "Test recipe" templates for common pipeline modifications — copy-paste-modify templates in `test-recipes/` for common changes (add phase, change schema field, add error handler, change agent
[86] (customer_voice) Opt-in "did it work?" signal from real users — single yes/no prompt after each pipeline run, stored alongside structural trace, aggregated across users to detect regression spikes from speci
[87] (customer_voice) Dependency graph visualization as testing artifact — auto-generate Mermaid/Graphviz DOT graphs from static parsing of script sourcing, state file I/O, and agent spawning relationships, rendered on eve
[88] (delusional_visionary) Prove pipeline correctness from git history — replay git log of state machine changes and verify at each commit that the transition table remains consistent (no unreachable states, no broken monotonic
[89] (delusional_visionary) Universal "pipeline genome" encoding — encode pipeline structure as a linear sequence (phase order, schemas, handlers, timeouts, agent counts), define mutation operators, and verify a fitnes
[90] (delusional_visionary) Federated structural fingerprinting across all users — each local pipeline computes a hash of its phase transition graph + timing distribution and submits only the fingerprint to a central aggregator
[91] (formal_methods_purist) Abstract interpretation of bash state transitions — build an abstract interpreter tracking `$phase_status` (enum), `$round_num` (bounded int), and `$state_file` (exists/absent/corrupted) and execute s
[92] (formal_methods_purist) Portable state machine specification DSL — a single specification like `phase "round1" requires [...] produces [...] transitions_to [...]` that generates BATS tests, JSON Schema validators,
[93] (formal_methods_purist) Invariant inference from production traces via Daikon-style analysis — collect anonymized structural traces, automatically discover likely invariants, and promote high-confidence inferred invariants t
[94] (testing_economist) Cost-benefit analysis favoring static analysis — estimated 60% bug class coverage at 8 hours setup / 0 maintenance vs. 85% from dynamic testing at 40 hours setup / 4 hours/month, making static analysi
[95] (testing_economist) "Wasted run rate" as the ultimate test KPI — define (orchestration-bug-caused failures / total runs), track from production telemetry, and justify every testing investment by its quantifiabl
[96] (testing_economist) Open-source the testing framework to amortize maintenance cost — generalize and release the framework so community contributions reduce the plugin team's net maintenance cost toward zero.
Evaluation — 9 clusters, scored & ranked
Clusters (9)
Cluster 1: "The Foundation" — LLM Boundary & Test Infrastructure
Cluster 2: "The Validation Stack" — Schema & Semantic Validation
Cluster 3: "The State Machine" — Formal Modeling & Test Generation
Cluster 4: "The Resilience Layer" — Fault Injection & Recovery
Cluster 5: "The Developer Experience" — Adoption & Friction Reduction
Cluster 6: "The Production Feedback Loop" — Telemetry & Auto-Testing
Cluster 7: "The Integration Layer" — Multi-Phase & End-to-End
Cluster 8: "The Economic Framework" — Prioritization & Measurement
Recommended Implementation Sequence
Top Ranked Ideas
#1#1. [46] (bash_whisperer) Extract the state machine from bash — Score: 18
#2#2. [1] (bash_whisperer) Single `call_llm()` boundary function — Score: 18
#3#3. [66] (formal_methods_purist) Forbidden state predicates — Score: 18
#4#4. [68] (formal_methods_purist) Refinement types for state files via jq — Score: 18
#5#5. [89] (formal_methods_purist) State machine specification DSL — Score: 18
#6#6. [81] (battle_scarred_sre) Pipeline crash black box recorder — Score: 18
#7#7. [74] (testing_economist) Production failures drive test creation — Score: 17
#8#8. [42] (testing_economist) Layer 1.5 adjacent-phase smoke tests — Score: 17
#9#9. [48] (bash_whisperer) Schema migration testing — Score: 17
#10#10. [82] (customer_voice) Test recipe templates — Score: 17
Moonshots (6)
Moonshot 1: [23] Statistical Oracle — Non-determinism as test signal
Moonshot 2: [29] Living Diff Engine — Replace pass/fail with behavioral diffs
Moonshot 3: [27] Self-Corrupting Phases — Production runs as chaos tests
Moonshot 4: [64] 2-of-3 LLM Consensus — Non-determinism as fault tolerance
Moonshot 5: [89] State Machine DSL — Single source of truth
Moonshot 6: [66] Forbidden State Predicates
Combinations (6)
Combination A: "The Self-Documenting Test Architecture"
Combination B: "The Production-Driven Test Flywheel"
Combination C: "The Semantic Validation Stack"
Combination D: "The Resilience Testing Pipeline"
Combination E: "The Zero-Friction Test Adoption Path"
Combination F: "The Formal-Pragmatic Bridge"

Top Ranked Ideas

#1#1. [46] (bash_whisperer) Extract the state machine from bash — Score: 18
#2#2. [1] (bash_whisperer) Single `call_llm()` boundary function — Score: 18
#3#3. [66] (formal_methods_purist) Forbidden state predicates — Score: 18
#4#4. [68] (formal_methods_purist) Refinement types for state files via jq — Score: 18
#5#5. [89] (formal_methods_purist) State machine specification DSL — Score: 18

Moonshots

Moonshot 1: [23] Statistical Oracle — Non-determinism as test signal
Moonshot 2: [29] Living Diff Engine — Replace pass/fail with behavioral diffs
Moonshot 3: [27] Self-Corrupting Phases — Production runs as chaos tests
Moonshot 4: [64] 2-of-3 LLM Consensus — Non-determinism as fault tolerance
Moonshot 5: [89] State Machine DSL — Single source of truth

Red Team Findings (5)

⚠ Vulnerability 1: "Extract the state machine" is disguised as a testing task but is actually a rewrite
⚠ Vulnerability 2: The "three-move opening" has a critical dependency that is hand-waved
⚠ Vulnerability 3: The validation stack assumes state file schemas are knowable
⚠ Vulnerability 4: "Wasted run rate" KPI conflates orchestration bugs with other failure causes
⚠ Vulnerability 5: The plan optimizes for the solo developer and ignores team dynamics
Full Details
Summary of Concerns
Vulnerability 1: "Extract the state machine" is disguised as a testing task but is actually a rewrite
**The claim**: Move the transition table into a standalone JSON/YAML file. Cost: 8-16 hours.
**The reality**: The current bash scripts do not have a clean separation between "state transition logic" and "phase execution logic." Transition decisions are likely embedded in conditionals scattered across scripts, mixed with error handling, agent coordination, and state file manipulation. Extracting the state machine requires understanding every implicit transition, documenting every guard condition, and refactoring every script that currently makes transition decisions inline. This is not an 8-16 hour task — it is a 40-80 hour refactoring project with a high risk of introducing regressions in the very code you are trying to test.
**The risk**: The team starts the extraction, discovers it is much harder than estimated, and either abandons it (losing momentum) or pushes through a partial extraction that creates two inconsistent sources of truth (the JSON file and the legacy scripts that still make some transition decisions).
**Mitigation**: Do not extract the state machine in week 1. Instead, start by documenting the existing implicit state machine as-is (just a Mermaid diagram + a JSON file describing the transitions you observe). Use this documentation to write tests against the existing scripts. Only refactor toward a data-driven dispatcher after the documentation proves accurate.
Vulnerability 2: The "three-move opening" has a critical dependency that is hand-waved
**The claim**: Move 1 (call_llm boundary) enables everything else. Cost: 4-8 hours.
**The reality**: The problem statement says the plugin "spawns multiple LLM agents." If these agents are separate Claude Code processes invoked via the Claude Code CLI, then the LLM boundary is not a single bash function — it is a process boundary. You cannot mock a separate process by swapping a bash function. You would need to either: (a) mock the Claude Code binary itself, (b) intercept network calls, or (c) restructure agent spawning. Each of these is significantly more complex than "implement one function."
**The risk**: The team implements `call_llm()` for direct LLM calls, then discovers that the majority of LLM interactions happen through spawned agent processes that bypass this function entirely. The entire mock/fixture strategy built on Move 1 is undermined.
**Mitigation**: Before implementing anything, trace the actual LLM call paths in the existing codebase. Map every point where an LLM interaction originates. If agent processes make their own LLM calls, the boundary strategy must be at the agent-spawn level (mock the agent), not the LLM-call level.
Vulnerability 3: The validation stack assumes state file schemas are knowable
**The claim**: Define JSON Schema, refinement types, and forbidden predicates for state files.
**The reality**: The problem statement says "state file formats evolved ad hoc" and "implicit contracts are undocumented." This means no one currently knows the complete schema. Writing JSON Schema requires reverse-engineering the schema from the code and existing state files. If the schema is wrong (missing a field that only appears under certain conditions, or specifying a type constraint that some edge case violates), the schema validation itself becomes a source of false failures that erode trust in the test suite.
**The risk**: The team writes schemas based on happy-path state files, then production runs hit edge cases that produce structurally valid but schema-non-conforming files. Developers start adding exceptions to the schema, creating a permissive schema that catches nothing, or bypassing validation entirely.
**Mitigation**: Before writing schemas, run the pipeline 20 times with varied inputs and collect all generated state files. Write schemas that are the intersection (what is always true) rather than the union (what is ever true). Mark uncertain fields as optional rather than guessing.
Vulnerability 4: "Wasted run rate" KPI conflates orchestration bugs with other failure causes
**The claim**: Track wasted run rate (orchestration-bug failures / total runs) as the single KPI.
**The reality**: Pipeline runs can fail for many reasons: LLM API outages, rate limits, user configuration errors, network issues, or incompatible tool versions. Attributing a failure to "orchestration bug" vs. "external cause" requires either manual triage (which is expensive and does not scale) or automated classification (which requires the structured trace infrastructure that doesn't exist yet). The KPI is undefined until you can classify failure causes, and classification is harder than the synthesis acknowledges.
**The risk**: The team starts tracking "total failure rate" as a proxy for wasted run rate. LLM API outages cause spikes that look like regressions. Developers lose trust in the metric and stop using it for decisions.
**Mitigation**: Start with a simpler KPI: "test suite execution time" and "number of tests." These are measurable immediately, do not require classification, and correlate with the quality of the test infrastructure even if they do not directly measure production impact.
Vulnerability 5: The plan optimizes for the solo developer and ignores team dynamics
**The claim**: 6-week implementation plan with clear weekly milestones.
**The reality**: The plan assumes a single developer (or a small, synchronized team) executing the plan sequentially. In practice: different team members will work on different clusters, creating merge conflicts in shared test infrastructure. The bash scripts will continue to evolve during the 6 weeks, invalidating state machine documentation and schemas. Priority changes will interrupt the plan mid-execution.
**The risk**: By week 4, the plan is out of date, the documentation from week 2 no longer matches the code, and the team has partially implemented three clusters without completing any of them. The test infrastructure is more complex than no infrastructure but less useful than a complete implementation.
**Mitigation**: Redefine the plan as a series of independently valuable increments rather than a sequential 6-week project. Each increment should deliver a standalone improvement that is useful even if the plan stops there. The minimum increment is: call_llm boundary + 5 error-path BATS tests + jq-e structural validation. Everything after that is optional and order-independent.
Overall Assessment

Executive Arbiter

EXECUTION PHASES (5)
✅ Phase 0: Reconnaissance (Days 1-3)
✅ Phase 1: The Minimum Valuable Test Suite (Days 4-10)
✅ Phase 2: Semantic Validation (Days 11-17)
✅ Phase 3: Production Feedback (Days 18-24)
✅ Phase 4: State Machine Formalization (Days 25-35)
Full Plan
Arbiter's Reconciliation
**The core decision**: Start with what exists. Test the scripts as they are. Earn the right to refactor by first proving what is broken.
Phase 0: Reconnaissance (Days 1-3)
0.1 Trace the LLM call paths
**Deliverable**: A one-page map of LLM call origins, classified by type. This determines whether `call_llm()` is sufficient or whether agent-spawn-level mocking is needed.
0.2 Document the implicit state machine
**Deliverable**: A Mermaid diagram and a JSON transition table reflecting the current reality.
0.3 Collect state file specimens
**Deliverable**: A directory of specimen state files and a draft structural schema (what is always true).
Phase 1: The Minimum Valuable Test Suite (Days 4-10)
1.1 Implement the LLM boundary
1.2 Write 10 error-path BATS tests
1.3 Implement jq-e structural validation
1.4 Ship the CI gate
**Exit criteria for Phase 1**: `make test` passes. At least one real bug has been found and fixed by the error-path tests. If no bugs are found, the test targets were wrong — revisit the state machine map.
Phase 2: Semantic Validation (Days 11-17)
2.1 Write refinement type validators
2.2 Write 10 forbidden state predicates
2.3 Layer 1.5 adjacent-phase smoke tests
2.4 Write schema migration tests
**Exit criteria for Phase 2**: Every phase boundary has a smoke test. Refinement types and forbidden predicates catch at least one class of bug that structural validation misses.
Phase 3: Production Feedback (Days 18-24)
3.1 Build the crash black box recorder
3.2 Implement structured trace emission
3.3 Production failure -> test fixture pipeline
3.4 Baseline the wasted run rate
**Exit criteria for Phase 3**: Every crash produces a reproduction archive. The structured trace exists and is machine-parseable. The wasted run rate baseline is documented.
Phase 4: State Machine Formalization (Days 25-35)
4.1 Formalize the documented state machine
4.2 Extract the transition table into a data file
4.3 Auto-generate test expectations from the formal model
**Exit criteria for Phase 4**: The transition table is a data file. Tests are generated from it. Adding a new phase means adding rows to the table and regenerating tests.
What Comes After (Month 2+)
Non-Negotiable Constraints
Decision Log