# Reliable operation under coupling and mechanistic refinement

Runnable companion to **Reliable productive operation of coupled autocatalytic reactors under mechanistic refinement** (17 September 2026). Manuscript SHA-256: `6939f07afd2c656577771d525062a8375f3ec59a0a20e453f06c736e638d0820`.

The question is operational: after a molecular withdrawal, loss, and refill, does every reactor recover, collect product, and stay within food and reaction-service budgets? This implementation retains the intermediate introduced by reaction splitting, transports every species over one symmetric graph, and repeats from actual endpoints. It also implements the six-species donor and its exact material-forced deterministic reduction.

## Run and edit

```sh
python -m venv .venv
# Windows: .venv\Scripts\activate
# macOS/Linux: source .venv/bin/activate
python -m pip install -r requirements.txt
python -m unittest -v test_example.py
python example.py --output outputs
python example.py --simulate --output outputs-small-count
```

Python 3.11+; dependencies are pinned. The default deterministic illustration and audits take seconds. The optional direct molecular simulation can take longer and has an explicit event budget. It runs at V=1400, **not** at the theorem witness scale. Budget exhaustion is `unfinished`, never a reported failure or success. No network or external dataset is required. Source and output hashes appear in `run_metadata.json`.

The top of `example.py` contains editable node rates, exchange graph, intermediate lifetime, exact rational initial densities, mission size, failure allowance, deterministic cycle count, policy choice, small-count scale and event budget. `HistoryPolicy` supplies the default q=1/4, all-species survival 0.98, zero refill error; instantiate `Intervention` to change those inputs. Every node may choose a different admitted action, synchronously at the cycle boundary. The feedback option uses actual previous collection to choose larger retention after a small result.

Counts are literal integers: the initial rational density must become integral at the requested V. The default witness is divisible by 20 and 28. The declared initial readiness is checked with exact integer inequalities before a probability certificate is returned. Editing theta away from 0.01 disables that stochastic theorem; the local deterministic theorem permits 0<theta≤0.01. The numerical solvers themselves are available separately for exploratory parameters.

## Reusable pieces

`reactor.py` keeps chemistry, transport, interventions and simulation separate:

* `Channel` owns consumption, production, a rational coefficient, falling-factorial propensity and physical marks. `Chemistry` constructs the literal 23-label refined source or 20-label donor and shares stoichiometry across density and count calculations. The reversible 2X→Z propensity is `r N_X(N_X−1)/V`, with **no factorial divisor**.
* `CommonExchange` validates a finite symmetric, nonnegative, zero-diagonal graph. Equal node scales and the same graph for every species are part of the theorem. It also supplies the exact-form material semigroup. Certificate degree uses rational values of the represented graph weights, avoiding downward rounding of a floating row sum.
* `Intervention` enforces q∈[1/4,3/4], survival∈[0.98,1], and food errors∈[−0.005,0.005]. Its molecular implementation draws retained, withdrawn, and lost categories with probabilities qℓ, 1−q, q(1−ℓ), then adds the exact integer floor of the refill. Withdrawn and lost molecules are distinct accounts.
* `ReactorNetwork` integrates the full local fields plus transport, splitting at the collection boundary. `donor_reduced` evolves only four productive phases, retaining both material histories and reconstructing foods. It applies only to deterministic donor flow segments.
* `DeterministicMission` and `MolecularMission` apply a policy, carry actual returned states, and log all physical outputs. Failed molecular cycles remain in the law and do not trigger an artificial reset or rejection sample. Exchange events move an actual molecule between nodes and create no product mark.
* `MissionCertificate` applies the manuscript's sufficient finite-mission theorem, with an outward-rounded tail calculation using interval arithmetic. It reports integer quotas, the sufficient scale, and pathwise net-synthesis consequences. It is not an empirical estimator.

Example composition:

```python
from reactor import Chemistry, CommonExchange, ReactorNetwork, HistoryPolicy, DeterministicMission

network = ReactorNetwork(
    [Chemistry(r='19', d='1/50'), Chemistry(r='21', d='1/25')],
    CommonExchange([[0, .5], [.5, 0]]),
)
initial = [[.95, .95, .05, 0, 0, 0, 0],
           [13/14, 13/14, 0, 0, 1/28, 0, 0]]
run = DeterministicMission(network, HistoryPolicy(feedback=True)).run(initial, 8)
print(run['history'][-1])
```

To add a mechanism, supply its literal channels, material identities and marks, then establish its scope separately. A method-compatible object alone does not inherit the theorem. Selective transport, asymmetric transport, unequal count scales, asynchronous pulses, and arbitrary lifetime parameters are outside the stated stochastic result.

## Mechanism, storage, and reduction

The productive route is X+U⇄C1, C1+W⇄C2, C2⇄Z, Z⇄2X. The donor cleavage X⇄U+W has rates d x and d η u w. The refined source replaces it with X⇄D⇄U+W, with beta=0.01:

`j5 = d(1+beta)x − d beta h/theta`

`j6 = d h/theta − d eta(1+beta)u w/beta`.

Here h is D concentration. All species wash out at unit rate; U and W each have unit feed. The chemical source has maintained external-drive bookkeeping, but this package assigns no chemical potentials or energy costs.

Augmented materials are A=u+x+2c1+2c2+2z+h and B=w+x+c1+2c2+2z+h. They obey `A'=1−A+DA`, `B'=1−B+DB` under common exchange. For the donor, the same formulas without h give the material histories exactly; substituting them into the four phase equations reconstructs the six-state trajectory. **Resetting A=B=1 after a pulse is not that reduction.** Species-specific survival and actual refill are retained before computing the next material initial data. The default full/reduced endpoint difference is around 2×10⁻¹² numerically.

Deleting h from the refined source is different. Two ready states with identical six retained coordinates and h=0 versus h=1/200 have different projected drifts: each food derivative changes by 0.015 and the X derivative by 0.00015 at d=0.03, theta=beta=0.01. They also have different projected event rates. The package checks this explicit nonclosure witness.

The local algebraic filter equilibrium is implemented as `filter_equilibrium`. At finite theta it satisfies `j5−j6=h`, a real intermediate washout loss. Its theta→0 rate-matching limit does not prove trajectory or jump-law convergence. The default theta sweep is labelled numerical illustration and keeps the intermediate as a state at every finite value.

## What the certificate means

A ready refined state has both materials in [159/160,161/160], stock `Y=x+(9/8)c1+(7/5)c2+(9/5)z≥1/20`, and h≤1.101 theta. Every cycle is one intervention followed by four normalized time units. Product collection uses only washout events in **(3,4]**. X,C1,C2,Z washouts contribute 1,1,1,2 to QI; only X washout contributes to QX. D washout is not product. Food counters include continuous arrivals plus integer refill. Gross service counts **both directions of X⇄D** on (0,4]; it does not count only the net flux or all seven chemical pairs.

At theta=0.01, node number n, degree bound Delta, and V≥10,000, the imported theorem gives

`P(all m cycles succeed) ≥ max(0, 1 − 29 n m exp[−V/(2·10^12(1+Delta)^3)])`.

Success requires each actual endpoint to be ready, QI≥ceil(V/56), QX≥ceil(V/1080), each food≤5V and gross service≤floor(V/5), in every node and every cycle. History-dependent policies are allowed without assuming independent nodes or independent cycles. The donor has prefactor 27 and denominator 2·10^14. The donor's weaker bound at the same scale is not evidence that the refined chemistry is physically more reliable; the difference arises from proof error budgets.

For the connected two-node, 100-cycle witness at V=224,000,000,000,000 and edge rate 1, the evaluated lower bound is **0.9951771334**. Fresh rational Taylor arithmetic proves `exp(14)>600000`, which independently certifies a lower probability above 0.99. The sufficient sizing curve scales logarithmically with mission length and has a cubic degree factor. It is a sufficient proof bound, not an optimized count requirement or an observed failure curve. A zero lower bound means the certificate is uninformative, not certain failure. Sizing alone does not ensure a proposed rational initialization is integral; validate the actual chosen scale and counts.

The actual marked process is not simulated at the enormous witness scale. Optional SSA draws exponential holding times and rate-proportional channels using ordinary floating random numbers; it is an implementation of the literal direct method, not an exact-real arithmetic proof. Unit tests additionally evaluate exact rational propensities and confirm physical telescopes on completed small paths.

## Honest material and service accounts

Collected QX is included in QI; do not add them as independent products. Carried inventory is `J=X+C1+C2+2Z+D`, including the intermediate, and its forward chemical increments are `(1,0,0,1,0,0,−1)`. The ledger checks

`net synthesis = J_final − J_initial + all J washout + withdrawn J + pulse-loss J`.

It also checks upstream-minus-downstream conversion against change in stored D plus D washout, withdrawal and pulse loss. Global exchange cancels in both identities. Deterministic accounts integrate the same quantities; molecular accounts count actual events.

On the success event, the worst-ready net-synthesis bound is `n V (m/56+1/28−161/160)`. It first becomes strictly positive at **55 cycles**. For the witness it gives **365,200,000,000,000 newly created inventory equivalents**, in addition to at least 800,000,000,000,000 collected equivalents. This excludes explaining the entire mission by draining initial productive stock or intermediate. It does not identify atoms or define thermodynamic efficiency. Using the actual initialized inventory can improve the bound; both are reported.

Food and service yields are division-free on the success event: FU+FW≤560 QI and ≤10800 QX; G≤(56/5)QI and ≤216 QX. These are common-event consequences and need no extra probability penalty.

## Evidence and outputs

Fresh symbolic/rational checks establish the displayed material identities, exact falling-factorial drift correction, stock correction, finite phase polynomial, exponential enclosure, graph-noise margin, integer product margins, nonclosure witness and the 55-cycle algebra. They support the implementation; they do not reconstruct the entire stochastic proof. **Lean is not rerun.** The refined operational theorems are attributed to the manuscript's formal development; donor reliability and additional inventory consequences are conventional manuscript results.

Ten deterministic cycles start from and return actual seven-species states, with h carried through every pulse. First-cycle inventory collections are about 0.275164 and 0.275162, free-X collections 0.128711 and 0.128710, and service 0.007416 and 0.007401. Each food account is 4.75. The tests rerun the first cycle with tighter tolerances and compare the full donor with the separately integrated material-forced reduction. The local deterministic theorem alone is not claimed to certify a deterministic graph extension; network trajectories are numerical illustrations. Plotted dashed corridors are the theorem's conditional good-event bounds, not measured stochastic confidence bands.

`cycles.csv` records per-node physical accounts and returned states. `first_cycle.csv` gives the full first-flow trajectory and observables. `sizing.csv` records sufficient count scales. `results.json` separates exact checks, theorem application, numerical reduction/mission results, unit conversion, and optional molecular outcomes. Figures are available as PNG and SVG.

The dimensionless model has no calibrated molecular identity. Choosing concentration unit c* and time unit tau gives V=N_A Ω c*, cycle duration 4 tau, washout 1/tau and unit feed c*/tau. At c*=1 mM the witness corresponds to roughly 0.372 μL per reactor; at 1 μM it is roughly 0.372 mL. The defaults take tau=60 s only as an illustration. These conversions do not validate a laboratory preparation, startup from food alone, indefinite persistence, or universal inheritance under reaction splitting.

## License

MIT is proposed for the newly authored example, pending owner confirmation. This note does not grant a license. The manuscript and cited material retain their own terms.
