# How to design an assay: an executable casebook

Companion to manuscript 63, SHA-256 `648302e05466fa7eb109e8e5299bacb868589480ddbdee61d888cef9754c11c8`. Python 3.11+. This is a synthesis paper, so its example executes the eight distinct source models and the reporting workflow they motivate. It does not invent a universal biochemical model into which those sources must fit.

```sh
python -m venv .venv
# Activate the environment using your platform's command.
python -m pip install -r requirements.txt
python -m unittest -v
python example.py --output outputs
```

## The design loop

The saved `workflow.json` makes the paper's sequence concrete:

1. Name the claim the result must support.
2. Fix the original specimen, denominator, task and deadline.
3. Trace material and observations through preparation and measurement.
4. Construct another explanation with the same record and a different answer.
5. Choose a repair and budget material, error, time and disturbance together.
6. Validate the complete prespecified reporting procedure, including missing and unresolved outcomes.

The code carries out mathematical checks for these synthetic sources. Step six's biological validation remains an external requirement; a `True` model-premise flag in an illustration is not evidence that a laboratory has calibrated it.

`decisions.py` supplies three small, deliberately different contracts. `DeterministicEnclosure` requires a feasible witness before issuing a threshold conclusion. It distinguishes missing/unevaluable, proved empty or inconsistent/incompatible, valid but unresolved, supported (lower>=threshold), and excluded (upper<threshold). A solver's failure is not an empty-set proof; a nonempty outer enclosure is not a feasible witness. `IssuanceGuarantee` records the entire experiment and an unconditional joint error. `PredictionRegion` records a future endpoint, preparation law and coverage. None converts another's guarantee into a posterior probability. All six illustrative decision records remain in the workflow denominator.

## Eight independently reusable examples

**Enzyme activity and recovery.** `enzyme.py` implements the literal inhibited enzyme law, scalar carrier task, exact passage bounds and capacity family. `population.py` supplies weighted populations, separated support, functional readout calibration and a finite-feature row-span test. The example first verifies the kinetic classification: the lower capacity band fails the task and the upper band completes it. It then constructs uniform and heterogeneous populations with equal mean and exactly equal pooled rates at several clamped conditions. The mean-one two-band class has sharp recovery interval [20/41,1]. Readout sensitivity [.9,1], false positives [0,.02] and positive fraction [.68,.72] narrow it to [33/49,4/5]; explicit endpoint populations and readout parameters verify nonemptiness. The lower decision margin above two-thirds is 1/147. No inference of whole-cell survival is made. Changing the task must trigger new kinetic classification before reusing a population result.

**Sandwich immunoassay.** `sandwich.py` retains the physical reagent mass balances and stable occupancy roots, plus exact Bernstein polynomial margin certificates. At unit reagents, u=.08 and u=50 have the same neat signal but different tenfold-diluted signals. A fully accessible .1-native state and a 100-native state with availability .001 instead share every illustrated accessible-spike/dilution record. The latter is explicitly outside the positive availability [.8,1] contract. Dilution occurs before adding fresh reagents; diluting an already assembled reaction is another protocol. The exact continuum source margin is .04 on the declared box and accessible high range [20,100]. A per-reading error .009 leaves strict separation; .01 is the boundary and does not. Without a two-class promise, the interface returns only the corresponding class exclusions. Unbounded high analyte cannot be ruled out by treating a numerical cutoff as a validated ceiling. The plotted curve is numerical, not the continuum proof.

**Original-specimen exclusion.** The exact polynomial maximum reproduces 0.04987721425 for two unique fractions .45, threshold six and nine independent native-reference pairs. The sharp source assigns recovery states (0,0) and (1,0) with an exactly constructed mixture. Its gate probability times its future negative probability equals the bound. The future negative probability *conditional on gate passage* is larger than .05, demonstrating why the joint guarantee cannot be relabeled. References consume 18 external native inputs/preparations; the target specimen consumes two distinct preparations. A missing reference record does not issue a claim. Blank availability .96^9 is an illustrative source-specific utility, not a worst-case reporting guarantee. The statement is “fewer than six original native targets,” not zero targets or absence of disease.

**Complete recovery paths.** `path_floor` implements the full-range sharp expression `(c^2-t^2)/4`, t=min(d,c,2-c), with attaining stage probabilities. For c>1, the floor is at least c-1; the demonstration includes c=1.5 with floor .5 rather than artificially capping coverage at the old quarter-range. The source also constructs available-but-mismatched stages (1,0) and (0,1), yielding no complete path. Uncovered types and recording failure reduce the usable floor. Independent units and a bound valid conditional on every valid calibration environment then give `delta+(1-delta)*(1-theta*g)^n`. The example requires an even allocation and retains the calibration-failure term. This is not a guarantee obtained from pooled stage averages or observed-success timing alone.

**Shared preparation and count prediction.** Exact two-founder CDFs yield 245/256 versus 121/128 at cutoff six under independent and shared latent growth classes. Cutoff seven covers both at .95, while six covers only the independent preparation. These are biological-count predictions at T=log(2), with identical single-founder chronological mixture laws. An exact thinning calculation additionally shows that the probability of recorded count <=2 loses its preparation contrast at detection .5 and reverses below it. Equality of this one statistic does not prove equality of the full observed law, and a recorded-count bound is not a biological-count bound. Calibration must occur at the relevant independent-well level.

**Stochastic amplification.** `amplification.py` retains the finite pure-birth source with rates `(b+g*z)*(1-z/R)`, threshold=capacity=5, b/g=.01 and Poisson loading four. Empty loaded reactions remain in the denominator. Exact rational uniformization bounds at times four, five and seven are recomputed. `timing_certificate.py` checks the source density sign cells; together with the companion's conventional likelihood-ratio connection they give a dual intercept exceeding .1055, hence miss>.0555 when blank error<=.01 for any timing-only classifier. This is not inferred from a deadline grid. A conditional identity channel at time seven has blank upper <.0003 and miss upper <.0423. The separate loading floor is exp(-4)*.99. Identity error, kinetic nonperturbation and the source connection are explicit premises, not empirical achievements.

**Fresh microbial conversion.** `material.py` and `material_certificate.py` validate ordered nonnegative transfers, pool-specific recovery and the five-expression exact minimum. The washed/unwashed reports reproduce 1.69/1.52 at target 1.6. An explicit attaining schedule proves feasibility for the configured direct-reserve class. The perspective's Appendix A.6 uses recovery input .2 and matched true second collections **4.2 and 5.9**, at the upper edges of the displayed 4 and 5.7 error envelopes; the saved histories follow that version. This differs from the technical companion's other valid witness with zero realised recovery input and exact collections 4/5.7. The initial reserve cannot silently replace the pre-wash reserve. The adapted module preserves the distinct uptake-cap alternative. All amounts remain per original aliquot; fresh credited entry is not substrate-specific atom attribution, viability or future function.

**Reporter storage.** `reporter.py` integrates the literal cofactor source, bound reporter complex, matched reference, product and native deficit. The main casebook independently integrates native loss and checks the finite account. Complete loss per product is `k*(1+p/c)/(p+k)`, giving cost three versus instantaneous .5 at p=k=1,c=.2. Schedules change exposure and product but not this fixed-product source coefficient. The component supports fading schedules and retains the remaining association tail rather than assuming finite waiting eliminates it. Native/background aliasing and biochemical calibration remain limitations; detailed uniform design certificates are available in the dedicated companion example.

## Provenance and reuse

The standalone files below adapt our separately authored examples for the perspective's cited technical sources. They are included locally so the ZIP runs without a repository checkout or dynamic imports from another paper. Their existing source-specific APIs are preserved; their units, model assumptions and calibration inputs do not transfer across cases.

| Included component | Companion example |
|---|---|
| `enzyme.py`, `population.py` | 58, enzyme activity to functional recovery |
| `sandwich.py` | 54, sandwich-immunoassay dilution certificates |
| `material.py`, `material_certificate.py` | 62, certifying fresh microbial conversion |
| `reporter.py` | 61, biochemical readouts and native function |
| `amplification.py`, `timing_certificate.py` | 57, stochastic amplification assays |
| Exact specimen/path/count reductions in `decisions.py` | Perspective appendices A.3–A.5; technical sources 60,53,56 |

The original technical examples provide deeper parameter studies and implementation details. The perspective casebook adds the cross-case reporting workflow, declaration of guarantee types, same-record alternatives and matched comparison. The helper modules retain extra reusable functions; only the functions exercised by the casebook and its seven test groups are claimed as freshly checked here. Direct module reuse requires honoring its documented premises.

Inputs at the top of `example.py` alter the relevant case only. Constants that define fixed reference examples remain labeled as such. The output directory contains eight source-result JSON files, a workflow record retaining all outcomes, a reporter trajectory, figures and file hashes. Exact fractions support the decisions; numeric ODEs and equilibrium plots remain illustrations. Hashes identify every included module and generated result.

No biological validation, statistical calibration dataset, clinical interpretation or Lean rerun is supplied. General source existence/comparison and likelihood-ratio statements remain manuscript dependencies where identified. This distinction is part of the example's lesson: a correct calculation answers the intended question only under the assumptions that connect the specimen, observation and target.

## License

MIT is proposed for this example, pending the owner's decision. No new license grant is asserted by this package; manuscript and repository terms remain separate.
