# Shared NADPH regeneration and joint service

This is a reusable implementation of the maintained GPx/glutathione and Prx/thioredoxin subsystem in **Shared NADPH regeneration sets sharp limits on joint glutathione and thioredoxin service** (16 September 2026). Manuscript SHA-256: `b1f97e45d58820881a8f2d779660a9f6e27270fadf9df8596477b2a7c787becd`.

Two branches can succeed in separate preparations yet fail their specified pair of requirements when they share one NADPH source. The obstacle is actual kinetic demand: a branch can consume more than its quota. This package reconstructs every steady species, computes the attained repair, and integrates the literal retained-state kinetics. It also demonstrates why relaxing a quota, removing a branch, and changing enzyme abundance are three different operations.

## Run

Python 3.11 or newer; the checked environment uses the pinned packages below.

```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
```

No external data, network, symbolic solver, or unpublished modules are needed. Runtime is a few seconds. The ZIP includes source, tests, this guide, dependencies, and generated outputs. CSV/JSON carry numerical results; figures are PNG/SVG. `run_metadata.json` records the source and manuscript hashes and output checksums. Floating-point digits can vary with numerical-library versions. The tests recompute claims; they do not accept saved PASS flags.

## Inputs and physical ownership

The editable block at the top of `example.py` holds all nominal rates, conserved pools, quotas, source settings, perturbations, and horizon. Concentrations are **μM**, unimolecular rates **s⁻¹**, bimolecular rates **μM⁻¹ s⁻¹**, and currents **μM s⁻¹**. The paper's declared values inherit effective kinetics from Adimora, Jones and Kemp (2010), DOI `10.1089/ars.2009.2968`; they are not a new homogeneous enzyme calibration. Quotas 10 and 4 and the maintained peroxide challenge 0.01 μM are design choices.

The peroxide-dependent constants a_G, a_T and b_T already absorb that challenge. To change it, supply consistent revised constants; changing a caption or a nominal peroxide number alone cannot change these equations. NADPH and NADP+ share total P=30.3. Regeneration has baseline P0=0.3 and law `s V (N-x)/(D-x)`, N=P−P0 and D=K+P. **Capacity sV is not realized current.** The substrate and energy drive remain externally maintained.

The glutathione branch retains free g, oxidized z and three GPx states. Its exact inventory is `g+2z+e2=G`, including enzyme-bound glutathione; `e0+e1+e2=E_G`. The Trx branch retains y,zT and r,h,w,v with `y+zT=T` and `r+h+w+v=E_T`. The hyperoxidized-to-sulfenic repair w→h remains an external maintenance current; its ATP/thiol costs are not resolved by this model.

## Components and reuse

* `QuadraticResponse` owns the positive carrier root, stable evaluation, current, derivative, quota inversion and rational root enclosure. It implements `A u²+(B+C/x)u−Gamma=0`, with current `p u/(v u+w)`. B may be negative. Rational input coefficients preserve rational inversion and polynomial evaluation.
* `GlutathioneBranch` and `ThioredoxinBranch` translate their own kinetics and inventories into that response and reconstruct all private species. Constructors check the positive-pool conditions. `GlutathioneBranch.redesign` returns **both** algebraic candidates with explicit admissibility results.
* `Regeneration` owns the source. `InhibitedSource` composes an illustrative NADPH product inhibition of this source. It does not stand for substrate inhibition inside a consuming branch.
* `ServiceDesign` accepts any finite tuple of admitted private quadratic branches and a source satisfying the `DecreasingSource` contract. It locates the unique scalar equilibrium and computes ceilings, carrier floors, NADPH floors, isolation requirements, the true minimum, and the quota-only estimate. An impossible quota returns `repairable=False`; it does not produce a spurious finite solution.
* `MaintainedKinetics` contains the full eight-variable dynamics, physical-domain checks, actual instantaneous currents, complex-step Jacobian, and implicit integration. Its source must expose the pyridine total as `Regeneration` does. The response curves are used for **equilibria only**; they never replace private transient states.
* `exact_paper_audit` and `declared_parameter_box` are fixed, independent audits of the manuscript instance. Editing the top inputs does not silently turn those certificates into certificates for a different preparation.
* `NonmonotoneExample` is a separate dimensionless model illustrating failure of an unlimited regeneration threshold. It is intentionally outside the monotone branch contract.

For a sweep or custom trajectory:

```python
from dataclasses import replace
import numpy as np
from example import nominal

model = nominal()
for quota_T in (2., 3., 4., 5.):
    print(model.design.decision((10., quota_T)))

changed = replace(model, trx=replace(model.trx, E=20.))
decision = changed.design.decision((10., 4.))
if decision['repairable']:
    scale = 1.1 * decision['minimum']
    initial = changed.state(changed.design.equilibrium(scale))
    initial[4] += .01  # oxidize Trx, retaining its total
    states = changed.integrate(initial, scale, np.linspace(0, 2000, 401))
```

The full coordinate order is `(x,z,e1,e2,zT,h,w,v)`; `full(state)` recovers g,e0,y,r and NADP+. Invalid initial preparations raise an error. Arbitrary edits must respect inventory and baseline constraints. Removing a branch means removing its response from `ServiceDesign`; lowering its quota does not remove its consumption. Additional independent branches fit the scalar design object, but their full dynamics require their own retained-state implementation. Shared private carriers, cross-inhibition, multiple cofactors, or a nonmonotone service law require new analysis; the contract cannot be asserted solely because an object exposes the same methods.

## What the default run establishes

At source scale 0.1, separate preparations deliver about 10.351411 and 5.129763 μM/s, each with its own full source. The joint preparation delivers 10.344228 and 2.440510, failing the Trx quota. Aggregate peroxide turnover can nevertheless increase: branch-resolved failure does not mean lower total clearance.

Quota inversion gives exact NADPH floors `3294375/138400918` and `460180/489387`. The Trx floor binds at L≈0.940319216 μM. At L the currents are 10.348943552 and 4. The true minimum scale is **0.113712667752**, with capacity **42.642250407 μM/s**, but realized NADPH demand only **14.348943552 μM/s**. Fresh Fraction arithmetic encloses the minimum inside `[0.11371266,0.11371268]`, corresponding to a 13.71266–13.71268% increase from 0.1. This narrow enclosure is mathematical precision, not biological uncertainty.

The quota-only scale is 0.110947356002. Its deficit equals `(j_G(L)−10+j_T(L)−4)/R1(L)`: GPx overdelivers 0.348943552 μM/s. That extra peroxide clearance is real; “overhead” refers only to the declared quotas. Lowering the nonbinding GPx quota leaves the true minimum unchanged. The ceiling currents are about 10.351642 and 5.143547. A quota at or above a ceiling cannot be achieved by finite regeneration. The sweep resolves the small interval from the GPx binding switch to its ceiling rather than rounding them into one point.

The larger redesign root gives g≈361.350554 and **E_G≈48.313664**, a 3.37267% reduction, attaining the quota-only bound with both services exactly at quota. The smaller root also passes the declared mathematical positive-pool condition but requires over 90,000 μM enzyme. It is retained in the output and rejected as a smaller-inventory design choice, not falsely classified as an impossible state. The matching lower bound holds because the unchanged Trx requirement still forces x≥X_T and decreasing regeneration then bounds the available source current. Even the optimum needs scale greater than 0.1. This is a narrow maintained-system design result, not a recommendation to inhibit an enzyme in a cell.

The rational Appendix B bound covers the **continuum** E_G,E_T±1% and k_G,k_T±5% with other coefficients fixed. It gives sufficient scale `11621793767394811/92312851976765625≈0.125895729`, using target x=1.5 μM. It does not presume corner extremality or claim optimality. A separate 5% constant source-setting tolerance divides a requirement by 0.95. If both assumptions apply, divide the box bound by 0.95; the two individually sufficient rows are not automatically a simultaneous guarantee.

## Full kinetics and limits

Six Radau runs apply the paper's carrier-oxidation and enzyme-redistribution perturbations at reference, boundary, and slack settings. The default equilibria have negative numerical Jacobian real parts (largest about −0.003 s⁻¹). Current recovery can take seconds while full-state relaxation has a roughly 333 s slow mode. At the exact steady boundary the perturbed Trx oxidation current temporarily falls below quota; at scale 0.12 the sampled services remain above their requirements. CSV retains all eight states, both service observables, total reductase demand, total peroxide sink, external repair current and state distance. Sampled inequalities are not interval-in-time certificates or a global-attraction proof. Changing initial perturbations changes these conclusions.

Away from equilibrium, GPx peroxide consumption is a_G e0, Trx oxidation is e_T yv, NADPH demand is the sum of the two reductase currents, and total peroxide consumption is a_G e0+a_T r+b_T h. They need not coincide. At steady state the external Prx repair is 0.000192 μM/s and peroxide turnover is 14.349135552 μM/s; the latter exceeds NADPH turnover by the hyperoxidation contribution. The clamp, source drive and Prx maintenance are explicit maintained inputs, not free energy or finite reservoirs.

The exact sign obstruction `∂e1dot/∂e2<0<∂e2dot/∂e1` rules out an orthant sign transformation making this Jacobian cooperative near the boundary. It does not rule out other cones or other stability arguments. The separate dimensionless example `j=x(6/5−x)`, `r=1−x`, quota 3/10 has one locally stable equilibrium for every positive source scale but succeeds only on approximately `[0.465153,1.934847]`. Increasing regeneration beyond the upper endpoint destroys service without bistability.

These are kinetic statements for a maintained subsystem. No standard potentials, chemical work model, whole-cell protection thresholds, donor data or clinical predictions are supplied. The manuscript's Lean theorems are reported as manuscript results; **Lean is not rerun**. Fresh rational checks substantiate the fixed instance, while root solves, trajectories and spectra are numerical. The package does not implement Nernst endpoint conversion or certified dynamical Lyapunov regions.

## License

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