From c88db663ad4193d12de595a1c8df8c784ad92c7d Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Nov 2026 22:29:37 +0000 Subject: [PATCH 1/3] Add kinetic invariants and the paraneoplastic exposure experiment Library (reusable): ReactionNetwork.kinetic_invariant_basis() and kinetic_residuals() find conserved linear quantities that depend on rate values. Reactions are grouped by reactant monomial; w is invariant for every state exactly when it annihilates each group's rate-weighted stoichiometry. Solved with the existing exact rational row reduction. The span contains the stoichiometric pools; extra vectors turn integral identities into exact checks, e.g. eliminated amount = k * AUC and the exposure identity H + (kappa/delta) E - (kappa alpha/delta) U. Experiment (fork-specific, for Project Asma): an invented tumor-effector- neuron-marker network with burden-driven or release-driven antigen presentation, surgery as a retain event and chemotherapy as instantaneous or continuous kill. Checked against exact invariants, closed-form integrals and, optionally, Asma's exact rational module from a trusted local checkout. Tests: 16 new focused cases; full suite 231 passed with no skips; JavaScript engine checks pass. Invented units only; no biological or clinical claim. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CoFhtGJLght7YiLeEMReMt --- README.md | 3 +- .../report.md | 107 ++++++ auto-research/README.md | 1 + docs/project-asma-integration.md | 24 ++ docs/reaction_experiments.md | 34 ++ scripts/validate_paraneoplastic_exposure.py | 335 ++++++++++++++++++ tests/test_kinetic_invariants.py | 106 ++++++ tests/test_paraneoplastic_exposure.py | 69 ++++ vh/graph/reactions.py | 63 ++++ 9 files changed, 741 insertions(+), 1 deletion(-) create mode 100644 auto-research/2026-11-05-E-paraneoplastic-exposure/report.md create mode 100644 scripts/validate_paraneoplastic_exposure.py create mode 100644 tests/test_kinetic_invariants.py create mode 100644 tests/test_paraneoplastic_exposure.py diff --git a/README.md b/README.md index 6e41556..96a864a 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ faster than real time. | `vh.molecular` | From-scratch JAX engine: AMBER ff14SB force field, GB-OBC2 implicit water, autodiff forces, Langevin (BAOAB) and Verlet dynamics, L-BFGS minimization | Matches OpenMM (used only as a referee) term by term to ~1e-14 relative on real proteins; trajectories identical step by step; energy conserved ([`docs/validation_molecular.md`](docs/validation_molecular.md)) | | `vh.body` | From-scratch whole-body PBPK: 13 organs + blood, Rodgers & Rowland tissue partitioning, liver (well-stirred, IVIVE), kidney (filtration), oral absorption (stomach + 7-segment intestine) with gut-wall first-pass, virtual populations; solved exactly with matrix exponentials | Bottom-up midazolam predictions vs 100 clinical datasets (IV and oral) digitized by the Open Systems Pharmacology project | | `vh.bridge` | Unbound drug at the target organ → receptor occupancy over time; Kd ↔ binding free energy | Analytic round-trip; kinetic occupancy | -| `vh.graph` | **Formalizes the body as a typed graph** across scales (organs↔blood flow, species↔reactions, atoms↔bonds); graph algorithms for reachability, pathways, cycles, flow balance, bottlenecks; renders and verifies subgraphs; imports SBML reaction networks with exact conservation and consistency invariants | Blood conservation (Kirchhoff) to 1e-16 on the real PBPK model; a pure graph BFS reproduces the force field's exclusion list exactly; SBML trajectories and steady states match libRoadRunner to ~1e-9 ([`docs/graph_formalization.md`](docs/graph_formalization.md)) | +| `vh.graph` | **Formalizes the body as a typed graph** across scales (organs↔blood flow, species↔reactions, atoms↔bonds); graph algorithms for reachability, pathways, cycles, flow balance, bottlenecks; renders and verifies subgraphs; imports SBML reaction networks with exact conservation and consistency invariants; finds rate-dependent kinetic invariants such as exposure (AUC) identities | Blood conservation (Kirchhoff) to 1e-16 on the real PBPK model; a pure graph BFS reproduces the force field's exclusion list exactly; SBML trajectories and steady states match libRoadRunner to ~1e-9 ([`docs/graph_formalization.md`](docs/graph_formalization.md)) | | `web/` | Real-time demo: atom-level protein dynamics and a virtual patient, live in the browser | JS engine checked against the Python engine to ≤1e-12 | The explicit-solvent engine (`vh.molecular.periodic`, `.constraints`, `.explicit_md`) adds rung 3 of the accuracy ladder: every water molecule, exact long-range electrostatics (Ewald / smooth PME), rigid-water SHAKE/RATTLE and a Monte-Carlo barostat — validated term-by-term against OpenMM Ewald (energy to 1e-13, PME to 1e-11, constraints to 1e-16). @@ -189,6 +189,7 @@ research tracks, and how to publish work under [`auto-research/`](auto-research/ - **Claude** (Anthropic) — implemented and validated the engines under the above direction, in pair with the maintainer. - **OpenAI Codex** — graph interface contracts, clearance reference validation, and conserved reaction/intervention experiments, under the direction of [@ahrazzle](https://github.com/ahrazzle). - **Claude** (Anthropic), Foundation-0 fork — SBML import with exact conservation and positive-mass consistency invariants. +- **Claude** (Anthropic), Foundation-0 fork — rate-dependent kinetic invariants (exposure/AUC and clearance identities) and the paraneoplastic antigen-exposure experiment for Project Asma. New contributors (human or agent): add yourself here in your pull request. See [`auto-research.md`](auto-research.md) for how to help. diff --git a/auto-research/2026-11-05-E-paraneoplastic-exposure/report.md b/auto-research/2026-11-05-E-paraneoplastic-exposure/report.md new file mode 100644 index 0000000..81f87fe --- /dev/null +++ b/auto-research/2026-11-05-E-paraneoplastic-exposure/report.md @@ -0,0 +1,107 @@ +# Kinetic invariants and paraneoplastic antigen exposure + +- **Track**: E (graph and reaction formalization) +- **Author**: Claude (Anthropic), Foundation-0 fork, under the Project Asma owner's direction +- **Date**: 2026-11-05 +- **Branch**: `claude/admiring-cori-0qyybb` +- **Code added**: `vh/graph/reactions.py` (`kinetic_invariant_basis`, `kinetic_residuals`), + `scripts/validate_paraneoplastic_exposure.py`, `tests/test_kinetic_invariants.py`, + `tests/test_paraneoplastic_exposure.py` + +## Question + +Project Asma asked what an irreversible, immune-mediated neural injury records +about a tumor's antigen over time, and whether treatment order can change it when +order provably cannot change the tumor endpoint. Answering that on this engine +needs a reusable capability the engine lacked: exact detection of conserved +quantities that depend on **rate values**, which is how an integral such as an +antigen exposure (AUC) or an eliminated amount becomes checkable. + +## Method + +**Library.** For mass-action `dC/dt = S v(C)`, group reactions by reactant +monomial. Distinct monomials are linearly independent functions, so `w` is a +linear invariant for every state exactly when `w` annihilates each group's +rate-weighted stoichiometry. `kinetic_invariant_basis()` solves that system with +the existing exact rational row reduction. Rates are the exact values of the +stored floats unless rationals are supplied whose float equals the stored rate. +`kinetic_residuals()` checks a declared invariant per monomial. Stoichiometric +pools are always included; rate-dependent vectors appear only when reactions share +a monomial. + +**Experiment.** An invented, dimensionless network contains tumor burden `A`, an +antigen-driven effector `E`, target neurons `N`, an injury marker `F`, an +optional self-sustaining CNS effector `C`, and accumulators for burden exposure +`U`, burden killed in the body `R` and cumulative hazard `H`. Rate scales select +**burden-driven** presentation (`A -> A + E`) or **release-driven** presentation +(chemotherapy kill `A -> E + R`). Surgery is an instantaneous retain on `A`. +Schedules place one surgery among six chemotherapy cycles, either as instantaneous +operations matching Asma's exact null case, or with chemotherapy as a continuous +kill over one unit. Quantities are reused as mol/L and seconds only because the +engine requires units. + +## Validation + +Authorities: exact kinetic invariants, closed-form integrals and, as an optional +bridge, Project Asma's exact rational module `tools/analyze_paraneoplastic_exposure.py`. +Fixed-step RK4 with step 0.005. + +| Quantity | This work | Authority | Error | +|---|---|---|---| +| Exposure identity `H + (κ/δ)E − (κα/δ)·source` | Found by the finder | Hand derivation | Exact (4/4 hypothesis × chemotherapy settings) | +| Clearance identity `X − kU` | Found by the finder | Hand derivation; bolus `dose/k` | Exact; numerical `≤ 1e-12` | +| Invariant drift along all discrete protocols | RK4 trajectories | Constant of motion | max `8.7e-14` | +| Hazard difference between surgery positions | RK4 | Identity at finite time | max `8.9e-14` | +| Survival `N = exp(−H)` | RK4 | Exact solution | max `1.2e-12` | +| Exposure and release by position (28 values) | `U`, `R` accumulators | Asma exact rationals | max `8.5e-12` absolute | +| Continuous-chemotherapy exposure, release, endpoint | RK4 | Closed-form integrals | max `5.0e-12` relative | +| Committed hazard after complete antigen removal | RK4 | `κE(t*)(1−e^{−δT})/δ` | `2.6e-15` | + +Executed findings on the invented fixture: + +| Finding | Result | +| --- | --- | +| Equal tumor endpoint, different neural exposure | Surgery first versus after three cycles, surgery retaining 1/10: hazard difference 0.700 (burden) and 0.7875 (release), each equal to κ times Asma's exact exposure difference of 70 and 78.75 | +| Hypotheses disagree when surgery is weak | Surgery retaining 3/4: burden-driven exposure is lowest with surgery last; release is lowest with surgery first | +| Continuous chemotherapy moves the threshold | Burden-driven optimum is surgery-first when `q < 1/(1 + c)` (here `q < 0.591`), not `q < a`; both endpoints confirmed by simulation | +| Regimes after antigen removal | Marker ratio t=20 to t=2: `1.5e-4` antigen-driven versus `0.15` autonomous | +| No-rise theorem | From steady state, burden-driven effector never rises (largest step `7.2e-13`, numerical noise); release-driven rises during the first chemotherapy cycle | + +A wiring error was caught by the finder during development: the first version of +the release hypothesis left burden presentation on, and the pure release identity +correctly failed. The test suite now asserts that the pure identity fails for the +mixture. + +## Limits + +- Every rate, burden and unit is invented. Hazard differences show bookkeeping and + direction, not effect sizes. No anti-Yo biology, NfL behavior, patient course or + treatment benefit is claimed or validated. +- Tumor growth, resistance, order-dependent surgical effectiveness and drug + pharmacokinetics are omitted; each can change the order conclusions. +- The invariant finder is exact for the supplied mass-action equations only. It + does not find nonlinear invariants such as `ln N + H`, which is checked here + numerically. Exact rational elimination can be expensive for large networks. +- The Asma bridge needs a trusted local checkout and imports its module; Asma is + not a dependency of the library or the test suite. + +## Reproduce + +```bash +PYTHONPATH=. python -m pytest -q tests/test_kinetic_invariants.py tests/test_paraneoplastic_exposure.py +PYTHONPATH=. python scripts/validate_paraneoplastic_exposure.py > results.json +PYTHONPATH=. python scripts/validate_paraneoplastic_exposure.py \ + --asma-root /path/to/project-asma > bridge-results.json +``` + +`results.json` and `bridge-results.json` in this folder record the executed runs, +checkout commits, dirty flags and SHA-256 hashes of the executed sources. + +## References + +- Project Asma record: [What the brain records](https://github.com/Foundation-0/project-asma/blob/main/docs/research/paraneoplastic-exposure-observability.md) + (public literature premises, exact rational results and the proposed study design). +- Albert ML et al. Tumor-specific killer cells in paraneoplastic cerebellar + degeneration. Nat Med 1998;4:1321–1324. doi:10.1038/3315 (motivates release-driven presentation). +- Venkatraman A, Opal P. Paraneoplastic cerebellar degeneration with anti-Yo + antibodies – a review. Ann Clin Transl Neurol 2016;3:655–663. doi:10.1002/acn3.328. diff --git a/auto-research/README.md b/auto-research/README.md index 41d7577..00c961d 100644 --- a/auto-research/README.md +++ b/auto-research/README.md @@ -27,3 +27,4 @@ auto-research/ | 2026-11-05 | E | [Clearance reference validation](2026-11-05-E-clearance-reference/report.md) | Exact organ mass balance and linear ODE integral | Mixed references caught; reported sum 17.104405 L/h, dose/AUC 17.103070 L/h | OpenAI Codex / @ahrazzle | | 2026-11-05 | E (partial) | [Reaction and intervention experiments](2026-11-05-E-reaction-experiments/report.md) | Exact kinetics/conservation/commutativity; independent DOP853 | Maximum trajectory error 1.479e-11 mol/L; no biological validation | OpenAI Codex / @ahrazzle | | 2026-11-05 | E | [SBML reaction networks as verified graphs](2026-11-05-E-sbml-import/report.md) | Exact rational algebra; libRoadRunner as independent SBML engine | 3 CC0 BioModels: exact conservation laws, trajectories ≤7e-10, steady states ≤2e-12; positive-mass invariant flags 8 of 49 surveyed models with exact certificates | Claude (Anthropic) | +| 2026-11-05 | E (partial) | [Kinetic invariants and paraneoplastic antigen exposure](2026-11-05-E-paraneoplastic-exposure/report.md) | Exact kinetic invariants; closed-form integrals; Project Asma exact rationals | Identities exact; drift ≤8.7e-14; 28 bridge values ≤8.5e-12; no biological validation | Claude (Anthropic) | diff --git a/docs/project-asma-integration.md b/docs/project-asma-integration.md index a39b392..4234bd4 100644 --- a/docs/project-asma-integration.md +++ b/docs/project-asma-integration.md @@ -183,3 +183,27 @@ Verification for this increment: **153 Python tests passed with no skips** in against both checked-in and regenerated fixtures, with worst plasma-profile relative error 4.8e-13 over 48 points. Regenerated molecular fixtures were not retained. This is numerical software verification, not biological validation. + +## 2026-11-05 update: kinetic invariants and paraneoplastic antigen exposure + +Project Asma's [exposure and observability record](https://github.com/Foundation-0/project-asma/blob/main/docs/research/paraneoplastic-exposure-observability.md) +asks what irreversible immune-mediated neural injury records about a tumor's +antigen over time. Its exact result is that final neural survival depends on a +schedule only through antigen exposure, so treatment order can change neural +outcome while the tumor endpoint cannot. Which order minimizes exposure depends +on whether antigen is presented in proportion to living burden or released by +cells killed in the body. + +The reusable library change is `kinetic_invariant_basis()` and +`kinetic_residuals()` in `vh.graph.reactions`. They find conserved quantities +that depend on rate values, which turns integral identities into exact checks. +The same finder recovers the clearance identity (amount eliminated equals rate +times AUC) behind the earlier clearance-reference work. The fork-specific +experiment is [`scripts/validate_paraneoplastic_exposure.py`](../scripts/validate_paraneoplastic_exposure.py), +with its [report](../auto-research/2026-11-05-E-paraneoplastic-exposure/report.md). +Its optional bridge compares 28 exposure and release values with Asma's exact +rational module, using a trusted local checkout as before. + +All rates, burdens and units are invented. No patient data, anti-Yo mechanism, +neurofilament-light validity or treatment benefit enters the library, the +experiment or the bridge. diff --git a/docs/reaction_experiments.md b/docs/reaction_experiments.md index 3041c72..15f5fd9 100644 --- a/docs/reaction_experiments.md +++ b/docs/reaction_experiments.md @@ -70,6 +70,39 @@ survive export; catalysts occur on both sides. Prefixes disambiguate a species and a reaction with the same identifier. The exported graph does not register executable callbacks and is not an SBML representation or round-trip importer. +## Kinetic invariants and cumulative exposure + +Some conserved quantities depend on rate values, not stoichiometry alone. Group +the reactions by their reactant monomial (for example `A`, `E` or `N*E`). Distinct +monomials are independent functions of the state, so a weight vector `w` keeps +`sum(w_i C_i)` constant along **every** trajectory exactly when it annihilates the +rate-weighted stoichiometry of each group. `kinetic_invariant_basis()` returns an +exact rational basis of all such vectors; `kinetic_residuals(weights)` checks a +declared one per monomial. The span always contains the stoichiometric pools of +`conservation_basis()`. Extra vectors appear only when reactions share a monomial. + +Path functionals become invariants once an accumulator is added. A catalytic +reaction `A -> A + U` at rate 1 makes `U` the integral of `A` (its exposure or +AUC). With elimination `C -> X` at rate `k` and `C -> C + U`, the finder returns +`X - k U`: amount eliminated equals clearance times AUC. With an antigen-driven +effector (`A -> A + E` at `alpha`, `E -> 0` at `delta`) and a cumulative hazard +`E -> E + H` at `kappa`, it returns `H + (kappa/delta) E - (kappa alpha/delta) U`. +Final hazard therefore depends on the antigen history only through its exposure. + +```python +basis = network.kinetic_invariant_basis(rate_scales={"present": 0}, + exact_rates={"decay": Fraction(1, 4)}) +residuals = network.kinetic_residuals({"H": 1, "E": Fraction(1, 25)}) +``` + +Rates are taken as the exact values of the stored binary floats unless +`exact_rates` supplies rationals whose float equals the stored rate. Rate scales +follow the same per-phase meaning as in `simulate`, so an invariant can hold in +one phase and not another. Retain/add events change the weighted sum by their +weighted jump and must be accounted for separately; an event that touches only +zero-weight species leaves it unchanged. Like the stoichiometric basis, the +result is a statement about the equations supplied, not about biology. + ## Numerical execution and sensitivity The solver is from-scratch classical fixed-step RK4. Each requested observation @@ -125,6 +158,7 @@ Run the report and tests with: ```bash PYTHONPATH=. python scripts/validate_reaction_experiments.py PYTHONPATH=. python -m pytest -q tests/test_reaction_experiments.py +PYTHONPATH=. python -m pytest -q tests/test_kinetic_invariants.py tests/test_paraneoplastic_exposure.py ``` The [report](../auto-research/2026-11-05-E-reaction-experiments/report.md) records diff --git a/scripts/validate_paraneoplastic_exposure.py b/scripts/validate_paraneoplastic_exposure.py new file mode 100644 index 0000000..ef1458c --- /dev/null +++ b/scripts/validate_paraneoplastic_exposure.py @@ -0,0 +1,335 @@ +"""Paraneoplastic antigen-exposure experiment on the VH reaction engine. + +Every quantity is invented and dimensionless, reused as mol/L and seconds only +because the engine requires units. This is not a physiological conversion, an +anti-Yo disease model, a patient simulation or a treatment comparison. + +Authorities: exact kinetic invariants found by ``kinetic_invariant_basis``, +closed-form integrals, and (optionally) Project Asma's exact rational module +``tools/analyze_paraneoplastic_exposure.py`` from a trusted local checkout. +""" +from __future__ import annotations + +import argparse +from fractions import Fraction as F +from hashlib import sha256 +import importlib.util +import json +from math import exp, log +from pathlib import Path +import subprocess + +import numpy as np + +from vh.graph.reactions import Phase, Reaction, ReactionNetwork, Species, rate_unit, run_protocol + +SOURCE = ("Original artificial fixture for Project Asma exposure mathematics; no empirical calibration",) +ROOT = Path(__file__).resolve().parents[1] +# Base rates: effector gain/decay, injury, marker clearance, autonomous seeding/injury. +RATES = {"present": F(1), "exposure": F(1), "kill_release": F(1), "kill_silent": F(1), + "decay": F(1), "hazard": F(1, 100), "injure": F(1, 100), "clear": F(1, 2), + "seed": F(1, 4), "cns_decay": F(1), "cns_hazard": F(1, 200), "cns_injure": F(1, 200)} +SPECIES = ("A", "E", "N", "F", "U", "R", "H", "C") +STEP = 0.005 + + +def build_network(): + """Tumor burden A, effector E, neurons N, injury marker F, CNS effector C. + + U accumulates burden exposure (integral of A), R burden killed in the body, + H cumulative hazard. Rate scales choose the hypothesis in each phase. + """ + first = "1/s" + reactions = [ + Reaction("present", {"A": 1}, {"A": 1, "E": 1}, 1.0, first, SOURCE), + Reaction("exposure", {"A": 1}, {"A": 1, "U": 1}, 1.0, first, SOURCE), + Reaction("kill_release", {"A": 1}, {"E": 1, "R": 1}, 1.0, first, SOURCE), + Reaction("kill_silent", {"A": 1}, {"R": 1}, 1.0, first, SOURCE), + Reaction("decay", {"E": 1}, {}, 1.0, first, SOURCE), + Reaction("hazard", {"E": 1}, {"E": 1, "H": 1}, 0.01, first, SOURCE), + Reaction("injure", {"N": 1, "E": 1}, {"E": 1, "F": 1}, 0.01, rate_unit(2), SOURCE), + Reaction("clear", {"F": 1}, {}, 0.5, first, SOURCE), + Reaction("seed", {"E": 1}, {"E": 1, "C": 1}, 0.25, first, SOURCE), + Reaction("cns_decay", {"C": 1}, {}, 1.0, first, SOURCE), + Reaction("cns_hazard", {"C": 1}, {"C": 1, "H": 1}, 0.005, first, SOURCE), + Reaction("cns_injure", {"N": 1, "C": 1}, {"C": 1, "F": 1}, 0.005, rate_unit(2), SOURCE), + ] + return ReactionNetwork([Species(s, SOURCE) for s in SPECIES], reactions, + context={"system": "synthetic", "compartment": "constant-volume, dimensionless"}, + provenance=SOURCE) + + +def scales(hypothesis, *, chemo=0.0, presentation=None, autonomous=False): + """Rate scales for one phase; chemo is the kill rate constant in that phase. + + Pure hypotheses by default: burden-driven presentation scale 1, release-driven + presentation scale 0. A positive ``presentation`` with ``release`` is the + mixture (spontaneous turnover plus treatment release). + """ + s = {"kill_release": 0.0, "kill_silent": 0.0, "seed": 0.0, "cns_decay": 1.0, + "cns_hazard": 0.0, "cns_injure": 0.0, "present": 0.0} + if hypothesis == "burden": + s.update(present=1.0 if presentation is None else presentation, kill_silent=chemo) + elif hypothesis == "release": + s.update(present=0.0 if presentation is None else presentation, kill_release=chemo) + else: + raise ValueError("hypothesis must be burden or release") + if autonomous: + s.update(seed=1.0, cns_decay=0.0, cns_hazard=1.0, cns_injure=1.0) + return s + + +def initial(burden=100.0, effector=0.0): + state = dict.fromkeys(SPECIES, 0.0) + state.update(A=burden, E=effector, N=1.0) + return state + + +def final(results): + return results[-1].trajectory.final + + +def run(network, state, phases): + return run_protocol(network, state, phases, max_step_s=STEP) + + +def discrete_schedule(network, hypothesis, operations, tail=0.0): + """Instantaneous operations, each followed by one holding unit (Asma's null case). + + A chemotherapy release is explicit caller logic: in the release hypothesis the + killed burden is added to E and R at the event; otherwise only to R. + """ + state, phases = initial(), [] + held = scales(hypothesis) + for i, (kind, keep) in enumerate(operations): + killed = state["A"] * (1 - keep) if kind == "chemo" else 0.0 + add = {"R": killed} + if hypothesis == "release": + add["E"] = killed + phase = Phase(f"{i}-{kind}", 1, SOURCE, retain={"A": keep}, add=add, rate_scales=held) + state = final(run(network, state, [phase])) + phases.append(state) + if tail: + state = final(run(network, state, [Phase("tail", tail, SOURCE, rate_scales=held)])) + return state + + +def continuous_schedule(network, hypothesis, operations): + """Surgery is instantaneous then held; chemotherapy kills continuously for one unit.""" + phases = [] + for i, (kind, keep) in enumerate(operations): + if kind == "surgery": + phases.append(Phase(f"{i}-surgery", 1, SOURCE, retain={"A": keep}, rate_scales=scales(hypothesis))) + else: + phases.append(Phase(f"{i}-chemo", 1, SOURCE, rate_scales=scales(hypothesis, chemo=-log(keep)))) + return final(run(network, initial(), phases)) + + +def continuous_closed_form(operations, burden=100.0): + """Exact integrals for the continuous schedule: exposure, release, end burden.""" + exposure = released = removed = 0.0 + for kind, keep in operations: + if kind == "surgery": + removed += burden * (1 - keep) + burden *= keep + exposure += burden + else: + exposure += burden * (1 - keep) / -log(keep) + released += burden * (1 - keep) + burden *= keep + return {"exposure": exposure, "released": released, "removed": removed, "final": burden} + + +def sweep(q, a, cycles=6): + rows = [] + for position in range(cycles + 1): + ops = [("chemo", a)] * cycles + ops.insert(position, ("surgery", q)) + rows.append(ops) + return rows + + +def invariant_weights(hypothesis): + """Exposure identity H + (kappa/delta) E - (kappa*gain/delta) * source, exactly.""" + kappa, delta = RATES["hazard"], RATES["decay"] + source = "U" if hypothesis == "burden" else "R" + return {"H": F(1), "E": kappa / delta, source: -kappa * RATES["present" if hypothesis == "burden" else "kill_release"] / delta} + + +def invariant_value(state, weights): + return sum(float(w) * state[s] for s, w in weights.items()) + + +def revision(root): + def git(*args): + return subprocess.check_output(["git", "-C", str(root), *args], text=True).strip() + try: + return {"commit": git("rev-parse", "HEAD"), "dirty": bool(git("status", "--porcelain"))} + except (OSError, subprocess.CalledProcessError): + return {"commit": None, "dirty": None} + + +def load_asma(asma_root): + path = asma_root / "tools/analyze_paraneoplastic_exposure.py" + spec = importlib.util.spec_from_file_location("asma_exposure", path) + if spec is None or spec.loader is None: + raise ValueError("cannot load the trusted Asma exact module") + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module, path + + +def validate(asma_root=None): + network = build_network() + exact = {k: v for k, v in RATES.items()} + checks = {} + + # 1. The finder recovers the exposure identity for each hypothesis, exactly. + found = {} + for hypothesis in ("burden", "release"): + for chemo in (0.0, 1.0): + w = invariant_weights(hypothesis) + residuals = network.kinetic_residuals(w, rate_scales=scales(hypothesis, chemo=chemo), exact_rates=exact) + found[f"{hypothesis}_chemo_{int(chemo)}"] = all(v == 0 for v in residuals.values()) + checks["exposure_identity_is_exact_kinetic_invariant"] = found + + # 2. Discrete schedules: exposure/release bookkeeping, invariant drift, Asma bridge. + discrete, drift, asma_errors = [], 0.0, [] + asma = None + if asma_root is not None: + asma, asma_path = load_asma(asma_root) + for q in (0.1, 0.75): + for hypothesis in ("burden", "release"): + w = invariant_weights(hypothesis) + states = [discrete_schedule(network, hypothesis, ops, tail=12.0) for ops in sweep(q, 0.5)] + for s in states: + drift = max(drift, abs(invariant_value(s, w) - invariant_value(initial(), w))) + key = "U" if hypothesis == "burden" else "R" + gain = float(RATES["hazard"] * RATES["present" if hypothesis == "burden" else "kill_release"] / RATES["decay"]) + k_over_d = float(RATES["hazard"] / RATES["decay"]) + # Hazard difference between surgery positions 3 and 0 from the identity at finite time. + late, early = states[3], states[0] + identity_dh = gain * (late[key] - early[key]) - k_over_d * (late["E"] - early["E"]) + discrete.append({"surgery_keep": q, "hypothesis": hypothesis, + "exposure_by_position": [s[key] for s in states], + "best_position": int(np.argmin([s[key] for s in states])), + "hazard_difference_late_minus_early": late["H"] - early["H"], + "identity_prediction": identity_dh, + "identity_error": abs(late["H"] - early["H"] - identity_dh), + "survival_ratio_late_to_early": late["N"] / early["N"], + "survival_exp_minus_h_error": max(abs(s["N"] - exp(-s["H"])) for s in states)}) + if asma is not None: + for position, s in enumerate(states): + ops = [("chemo", F(1, 2))] * 6 + ops.insert(position, ("surgery", F(1, 10) if q == 0.1 else F(3, 4))) + expected = asma.run_schedule(F(100), ops) + target = expected["burden_auc"] if hypothesis == "burden" else expected["killed_in_body"] + # Tail adds final burden x tail duration to U; release is complete at the last event. + if hypothesis == "burden": + target += expected["final"] * 12 + asma_errors.append(abs(s[key] - float(target))) + checks["discrete_schedules"] = discrete + checks["max_exposure_invariant_drift"] = drift + + # 3. Continuous chemotherapy: closed-form integrals and the order criteria. + continuous, closed_error = [], 0.0 + for q in (0.1, 0.75): + for hypothesis in ("burden", "release"): + rows = sweep(q, 0.5) + states = [continuous_schedule(network, hypothesis, ops) for ops in rows] + forms = [continuous_closed_form(ops) for ops in rows] + for s, c in zip(states, forms): + closed_error = max(closed_error, abs(s["U"] - c["exposure"]) / c["exposure"], + abs(s["R"] - c["released"]) / max(c["released"], 1e-300), + abs(s["A"] - c["final"]) / c["final"]) + exposures = [s["U" if hypothesis == "burden" else "R"] for s in states] + continuous.append({"surgery_keep": q, "hypothesis": hypothesis, + "best_position": int(np.argmin(exposures)), + "continuous_criterion_surgery_first": q < 1 / (1 + log(2)) if hypothesis == "burden" else True}) + checks["continuous_schedules"] = continuous + checks["max_continuous_closed_form_relative_error"] = closed_error + + # 4. Committed injury after complete antigen removal, and the autonomous contrast. + regimes = {} + for label, autonomous in (("antigen_driven", False), ("autonomous_cns", True)): + start = initial(burden=10.0, effector=10.0) + held = scales("burden", autonomous=autonomous) + at_removal = final(run(network, start, [Phase("established", 5, SOURCE, rate_scales=held)])) + removed = {**at_removal, "A": 0.0} + trajectory = network.simulate(removed, list(np.arange(0, 20.0001, 1.0)), max_step_s=STEP, + rate_scales=held) + f_series = trajectory.concentrations[:, SPECIES.index("F")] + row = {"marker_ratio_t10_to_t2": float(f_series[10] / f_series[2]), + "marker_ratio_t20_to_t2": float(f_series[20] / f_series[2]), + "remaining_neurons_at_end": trajectory.final["N"]} + if not autonomous: + bound = float(RATES["hazard"] / RATES["decay"]) * at_removal["E"] * (1 - exp(-20)) + row["committed_hazard_bound"] = bound + row["committed_hazard_observed"] = trajectory.final["H"] - at_removal["H"] + row["committed_error"] = abs(row["committed_hazard_observed"] - bound) + regimes[label] = row + checks["regimes_after_removal"] = regimes + + # 5. No-rise theorem in continuous time, and the release signature. + signature = {} + turnover = 0.1 + for hypothesis in ("burden", "release"): + steady = turnover * 100.0 # alpha*d*A0/delta with alpha = delta = 1 + state = initial(effector=steady) + phases = [Phase("chemo-1", 1, SOURCE, rate_scales=scales(hypothesis, chemo=log(2), presentation=turnover)), + Phase("hold", 1, SOURCE, rate_scales=scales(hypothesis, presentation=turnover)), + Phase("surgery", 2, SOURCE, retain={"A": 0.5}, rate_scales=scales(hypothesis, presentation=turnover))] + series = [] + for result in run_protocol(network, state, phases, max_step_s=STEP): + traj = network.simulate(result.after, list(np.linspace(0, result.phase.duration_s, 21)), + max_step_s=STEP, rate_scales=result.phase.rate_scales) + series.extend(traj.concentrations[:, SPECIES.index("E")].tolist()) + diffs = np.diff(series) + signature[hypothesis] = {"max_rise": float(diffs.max()), + "never_rises": bool(diffs.max() <= 1e-12), + "rises_during_first_chemo": bool(series[20] > series[0] + 1e-9)} + checks["steady_state_signature"] = signature + + tolerances = {"identity": 1e-10, "drift": 1e-10, "closed_form_relative": 1e-8, "survival": 1e-8, + "committed": 1e-8, "asma": 1e-9} + passed = (all(found.values()) + and drift <= tolerances["drift"] + and all(r["identity_error"] <= tolerances["identity"] for r in discrete) + and all(r["survival_exp_minus_h_error"] <= tolerances["survival"] for r in discrete) + and closed_error <= tolerances["closed_form_relative"] + and all(r["best_position"] == (0 if r["continuous_criterion_surgery_first"] else 6) for r in continuous) + and regimes["antigen_driven"]["committed_error"] <= tolerances["committed"] + and regimes["autonomous_cns"]["marker_ratio_t20_to_t2"] > 10 * regimes["antigen_driven"]["marker_ratio_t20_to_t2"] + and signature["burden"]["never_rises"] and signature["release"]["rises_during_first_chemo"] + and (not asma_errors or max(asma_errors) <= tolerances["asma"])) + result = { + "status": "pass" if passed else "fail", + "scope": "synthetic_mathematics_and_software_only_not_biological_validation", + "as_of": "2026-11-05", + "authorities": ["exact kinetic invariants (rational nullspace)", "closed-form integrals", + "Project Asma exact rational module (optional bridge)"], + "integration": {"method": "fixed-step RK4", "max_step": STEP}, + "tolerances": tolerances, + "checks": checks, + "virtual_human_checkout": revision(ROOT), + "source_sha256": {"vh_reactions_module": sha256((ROOT / "vh/graph/reactions.py").read_bytes()).hexdigest(), + "validation_script": sha256(Path(__file__).read_bytes()).hexdigest()}, + "limitations": ["invented rates, burdens and units", "no physiological conversion", + "tumor growth, resistance and order-dependent surgery omitted", + "no anti-Yo, NfL, patient or treatment-benefit claim"], + } + if asma is not None: + result["asma_bridge"] = {"asma_checkout": revision(asma_root), + "asma_module_sha256": sha256(asma_path.read_bytes()).hexdigest(), + "comparisons": len(asma_errors), + "max_absolute_error": max(asma_errors)} + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--asma-root", type=Path, help="trusted local Project Asma checkout (optional bridge)") + args = parser.parse_args() + outcome = validate(args.asma_root.resolve() if args.asma_root else None) + print(json.dumps(outcome, indent=2, sort_keys=True)) + raise SystemExit(0 if outcome["status"] == "pass" else 1) diff --git a/tests/test_kinetic_invariants.py b/tests/test_kinetic_invariants.py new file mode 100644 index 0000000..3746542 --- /dev/null +++ b/tests/test_kinetic_invariants.py @@ -0,0 +1,106 @@ +"""Rate-dependent linear invariants: exact algebra, numerical drift and inputs.""" +from fractions import Fraction +from math import exp + +import numpy as np +import pytest + +from vh.graph.reactions import Phase, Reaction, ReactionNetwork, Species, rate_unit, run_protocol + +SOURCE = ("Artificial mathematical fixture; not a biological measurement",) + + +def reaction(name, left, right, rate): + return Reaction(name, left, right, rate, rate_unit(sum(left.values())), SOURCE) + + +def network(ids, reactions): + return ReactionNetwork([Species(s, SOURCE) for s in ids], reactions, + context={"system": "synthetic", "compartment": "constant-volume"}, + provenance=SOURCE) + + +def span_rank(vectors, ids): + return np.linalg.matrix_rank(np.array([[float(v.get(s, 0)) for s in ids] for v in vectors])) if vectors else 0 + + +def clearance(): + # Bolus C eliminated at k; U accumulates AUC; X accumulates the amount eliminated. + return network(["C", "X", "U"], [reaction("eliminate", {"C": 1}, {"X": 1}, 0.25), + reaction("auc", {"C": 1}, {"C": 1, "U": 1}, 1.0)]) + + +def test_stoichiometric_pools_are_kinetic_invariants_for_any_rates(): + for rates in ((0.3, 0.7), (2.0, 0.0), (0.125, 5.0)): + model = network(["A", "B", "D"], [reaction("dimerize", {"A": 2}, {"D": 1}, rates[0]), + reaction("convert", {"A": 1}, {"B": 1}, rates[1])]) + kinetic = model.kinetic_invariant_basis() + for pool in model.conservation_basis(): + assert all(r == 0 for r in model.kinetic_residuals(pool).values()) + assert span_rank(kinetic + model.conservation_basis(), model.ids) == span_rank(kinetic, model.ids) + + +def test_distinct_monomials_add_no_invariant(): + model = network(["A", "B", "C"], [reaction("ab", {"A": 1}, {"B": 1}, 0.4), + reaction("bc", {"B": 1}, {"C": 1}, 0.9)]) + assert span_rank(model.kinetic_invariant_basis(), model.ids) == span_rank(model.conservation_basis(), model.ids) == 1 + + +def test_clearance_identity_found_exactly_and_holds_numerically(): + model = clearance() + exact = {"eliminate": Fraction(1, 4), "auc": 1} + basis = model.kinetic_invariant_basis(exact_rates=exact) + identity = {"X": 1, "U": Fraction(-1, 4)} # eliminated amount = k * AUC + assert all(r == 0 for r in model.kinetic_residuals(identity, exact_rates=exact).values()) + assert span_rank(basis + (identity,), model.ids) == span_rank(basis, model.ids) == 2 + final = model.simulate({"C": 8.0, "X": 0.0, "U": 0.0}, [0, 3, 40], max_step_s=0.01).final + assert abs(final["X"] - 0.25 * final["U"]) < 1e-12 + assert abs(final["U"] - 8.0 / 0.25 * (1 - exp(-0.25 * 40))) < 1e-8 # dose / k + + +def test_exposure_identity_and_rate_scale_dependence(): + model = network(["A", "E", "H", "U"], [ + reaction("present", {"A": 1}, {"A": 1, "E": 1}, 0.5), + reaction("exposure", {"A": 1}, {"A": 1, "U": 1}, 1.0), + reaction("decay", {"E": 1}, {}, 0.25), + reaction("hazard", {"E": 1}, {"E": 1, "H": 1}, 0.01)]) + exact = {"present": Fraction(1, 2), "decay": Fraction(1, 4), "hazard": Fraction(1, 100)} + identity = {"H": 1, "E": Fraction(1, 25), "U": Fraction(-1, 50)} + assert all(r == 0 for r in model.kinetic_residuals(identity, exact_rates=exact).values()) + # Doubling presentation changes the rate-dependent coefficient, not the pool A. + doubled = model.kinetic_residuals(identity, rate_scales={"present": 2}, exact_rates=exact) + assert doubled["A"] == Fraction(1, 25) * Fraction(1, 2) + fixed = {"H": 1, "E": Fraction(1, 25), "U": Fraction(-1, 25)} + assert all(r == 0 for r in model.kinetic_residuals(fixed, rate_scales={"present": 2}, exact_rates=exact).values()) + # Retaining A is an external event that leaves the weighted sum unchanged. + phases = [Phase("hold", 3, SOURCE), Phase("cut", 4, SOURCE, retain={"A": 0.1})] + out = run_protocol(model, {"A": 10.0, "E": 1.0, "H": 0.0, "U": 0.0}, phases, max_step_s=0.01) + value = lambda s: s["H"] + s["E"] / 25 - s["U"] / 50 + assert abs(value(out[-1].trajectory.final) - value({"H": 0, "E": 1.0, "U": 0})) < 1e-13 + + +def test_float_rates_are_converted_exactly(): + model = network(["A", "U", "X"], [reaction("loss", {"A": 1}, {"X": 1}, 0.1), + reaction("auc", {"A": 1}, {"A": 1, "U": 1}, 1.0)]) + assert all(r == 0 for r in model.kinetic_residuals({"X": 1, "U": -Fraction(0.1)}).values()) + assert model.kinetic_residuals({"X": 1, "U": Fraction(-1, 10)})["A"] != 0 + exact = {"loss": Fraction(1, 10)} + assert all(r == 0 for r in model.kinetic_residuals({"X": 1, "U": Fraction(-1, 10)}, exact_rates=exact).values()) + + +@pytest.mark.parametrize("exact", [{"missing": 1}, {"eliminate": Fraction(1, 3)}, {"eliminate": True}, + {"eliminate": -Fraction(1, 4)}, {"eliminate": 0.25}]) +def test_invalid_exact_rates_rejected(exact): + with pytest.raises(ValueError): + clearance().kinetic_invariant_basis(exact_rates=exact) + + +def test_invalid_weights_and_scales_rejected(): + model = clearance() + for weights in ({}, {"Z": 1}, {"X": 0.5}, {"X": True}): + with pytest.raises(ValueError): + model.kinetic_residuals(weights) + with pytest.raises(ValueError): + model.kinetic_invariant_basis(rate_scales={"unknown": 1}) + with pytest.raises(ValueError): + model.kinetic_invariant_basis(rate_scales={"auc": -1}) diff --git a/tests/test_paraneoplastic_exposure.py b/tests/test_paraneoplastic_exposure.py new file mode 100644 index 0000000..67bd646 --- /dev/null +++ b/tests/test_paraneoplastic_exposure.py @@ -0,0 +1,69 @@ +"""Exposure experiment on the engine versus closed forms; no Asma dependency.""" +from fractions import Fraction +import importlib.util +from math import exp, log +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +spec = importlib.util.spec_from_file_location("exposure_script", ROOT / "scripts/validate_paraneoplastic_exposure.py") +script = importlib.util.module_from_spec(spec) +spec.loader.exec_module(script) +NETWORK = script.build_network() + + +def test_exposure_identity_is_exact_for_both_hypotheses(): + for hypothesis in ("burden", "release"): + for chemo in (0.0, 1.0): + residuals = NETWORK.kinetic_residuals(script.invariant_weights(hypothesis), + rate_scales=script.scales(hypothesis, chemo=chemo), + exact_rates=script.RATES) + assert all(r == 0 for r in residuals.values()) + # The pure release hypothesis is not burden-driven: its identity fails with presentation on. + mixed = NETWORK.kinetic_residuals(script.invariant_weights("release"), + rate_scales=script.scales("release", presentation=1.0), + exact_rates=script.RATES) + assert any(r != 0 for r in mixed.values()) + + +def test_discrete_order_comparison_matches_exact_exposure(): + early, late = script.sweep(0.1, 0.5)[0], script.sweep(0.1, 0.5)[3] + b0 = script.discrete_schedule(NETWORK, "burden", early) + b3 = script.discrete_schedule(NETWORK, "burden", late) + assert abs(b0["A"] - 5 / 32) < 1e-12 and abs(b3["A"] - 5 / 32) < 1e-12 + assert abs(b0["U"] - 635 / 32) < 1e-9 and abs(b3["U"] - 2875 / 32) < 1e-9 + predicted = 0.01 * (b3["U"] - b0["U"]) - 0.01 * (b3["E"] - b0["E"]) + assert abs((b3["H"] - b0["H"]) - predicted) < 1e-12 + r0 = script.discrete_schedule(NETWORK, "release", early) + r3 = script.discrete_schedule(NETWORK, "release", late) + assert abs(r3["R"] - r0["R"] - 78.75) < 1e-9 + assert abs(r0["N"] - exp(-r0["H"])) < 1e-11 + + +def test_continuous_schedule_matches_closed_form(): + ops = script.sweep(0.75, 0.5)[2] + for hypothesis in ("burden", "release"): + state = script.continuous_schedule(NETWORK, hypothesis, ops) + closed = script.continuous_closed_form(ops) + assert abs(state["U"] - closed["exposure"]) / closed["exposure"] < 1e-9 + assert abs(state["R"] - closed["released"]) / closed["released"] < 1e-9 + assert abs(state["R"] - (100 - closed["final"] - closed["removed"])) < 1e-8 + # Continuous chemotherapy shifts the burden-driven threshold to q < 1/(1 + c). + assert 0.5 < 1 / (1 + log(2)) < 0.75 + + +def test_committed_injury_after_complete_removal(): + held = script.scales("burden") + state = script.initial(burden=0.0, effector=3.0) + out = NETWORK.simulate(state, [0, 10], max_step_s=script.STEP, rate_scales=held).final + assert abs(out["H"] - 0.01 * 3.0 * (1 - exp(-10))) < 1e-10 + + +def test_no_rise_from_steady_state_and_release_rise(): + for hypothesis, expect_rise in (("burden", False), ("release", True)): + state = script.initial(effector=10.0) + traj = NETWORK.simulate(state, [0, 0.25, 0.5, 0.75, 1.0], max_step_s=script.STEP, + rate_scales=script.scales(hypothesis, chemo=log(2), presentation=0.1)) + effector = traj.concentrations[:, script.SPECIES.index("E")] + assert (effector[-1] > effector[0] + 1e-9) == expect_rise + if not expect_rise: + assert all(b <= a + 1e-12 for a, b in zip(effector, effector[1:])) diff --git a/vh/graph/reactions.py b/vh/graph/reactions.py index f915481..430eefe 100644 --- a/vh/graph/reactions.py +++ b/vh/graph/reactions.py @@ -169,6 +169,69 @@ def pool_residuals(self, weights): for i, s in enumerate(self.ids)), Fraction(0)) for j, r in enumerate(self.reaction_ids)} + def _exact_effective_rates(self, rate_scales, exact_rates): + """Exact rationals of the effective rates the integrator would use.""" + scales = {} if rate_scales is None else dict(rate_scales) + exact = {} if exact_rates is None else dict(exact_rates) + self._rates(scales) # same validation as simulate + if set(exact) - set(self.reaction_ids): + raise ValueError("exact rates name an unknown reaction") + values = [] + for r in self.reactions: + if r.id in exact: + k = exact[r.id] + if isinstance(k, bool) or not isinstance(k, (int, Fraction)) or k < 0 or float(k) != r.rate: + raise ValueError(f"exact rate for {r.id!r} must be a rational whose float is the rate") + k = Fraction(k) + else: + k = Fraction(r.rate) # exact value of the stored binary float + scale = scales.get(r.id, 1) + values.append(k * (scale if isinstance(scale, Fraction) else Fraction(scale))) + return values + + def _monomial_columns(self, rates): + """Rate-weighted stoichiometry summed over reactions sharing a reactant monomial.""" + groups = {} + for j, r in enumerate(self.reactions): + groups.setdefault(tuple(sorted(r.reactants.items())), []).append(j) + columns = {} + for key, members in groups.items(): + column = [sum((rates[j] * self._stoich_exact[i][j] for j in members), Fraction(0)) + for i in range(len(self.ids))] + label = "*".join(s if n == 1 else f"{s}^{n}" for s, n in key) or "1" + columns[label] = column + return columns + + def kinetic_invariant_basis(self, rate_scales=None, exact_rates=None): + """Exact basis of w with w . dC/dt = 0 for every state at these effective rates. + + Mass-action dC/dt is a sum, over distinct reactant monomials m, of m(C) + times the rate-weighted stoichiometry of the reactions sharing m. Distinct + monomials are independent functions, so w is invariant iff it annihilates + every such column. The span contains every stoichiometric pool; extra + vectors depend on rate values, e.g. an exposure (AUC) or clearance identity. + Rates are the exact values of the stored floats unless ``exact_rates`` + supplies rationals whose float equals the stored rate. + """ + columns = self._monomial_columns(self._exact_effective_rates(rate_scales, exact_rates)) + return tuple({s: w for s, w in zip(self.ids, vector) if w} + for vector in _nullspace(list(columns.values()), len(self.ids))) + + def kinetic_residuals(self, weights, rate_scales=None, exact_rates=None): + """Exact residual of a declared linear invariant per reactant monomial. + + All zeros means ``sum(w_i C_i)`` is constant along every trajectory of + these effective rates. External retain/add events change it by their + weighted jump; check those separately. + """ + if not weights or set(weights) - set(self.ids): + raise ValueError("invariant must name known species") + if any(isinstance(w, bool) or not isinstance(w, (int, Fraction)) for w in weights.values()): + raise ValueError("invariant weights must be integers or Fractions") + columns = self._monomial_columns(self._exact_effective_rates(rate_scales, exact_rates)) + return {label: sum((Fraction(weights.get(s, 0)) * column[i] for i, s in enumerate(self.ids)), Fraction(0)) + for label, column in columns.items()} + def to_graph(self): """Bipartite topology preserves multi-reactant stoichiometry and catalysts.""" graph = Graph("reaction network") From d0d27302eec27984b6a0ea9450698c85065f4ca2 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 5 Nov 2026 22:31:10 +0000 Subject: [PATCH 2/3] Record paraneoplastic exposure validation and Asma bridge results Both runs pass on clean checkouts: VH c88db66 and Project Asma a5086b8. Exposure invariant drift 8.7e-14; identity error 8.9e-14; survival exp(-H) error 1.2e-12; continuous closed forms 5.0e-12 relative; committed hazard 2.6e-15; 28 Asma exact values matched within 8.5e-12. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CoFhtGJLght7YiLeEMReMt --- .../bridge-results.json | 186 ++++++++++++++++++ .../results.json | 177 +++++++++++++++++ 2 files changed, 363 insertions(+) create mode 100644 auto-research/2026-11-05-E-paraneoplastic-exposure/bridge-results.json create mode 100644 auto-research/2026-11-05-E-paraneoplastic-exposure/results.json diff --git a/auto-research/2026-11-05-E-paraneoplastic-exposure/bridge-results.json b/auto-research/2026-11-05-E-paraneoplastic-exposure/bridge-results.json new file mode 100644 index 0000000..cf2595a --- /dev/null +++ b/auto-research/2026-11-05-E-paraneoplastic-exposure/bridge-results.json @@ -0,0 +1,186 @@ +{ + "as_of": "2026-11-05", + "asma_bridge": { + "asma_checkout": { + "commit": "a5086b8ccd19dcee50c2b34f0d1104e07e48d1e0", + "dirty": false + }, + "asma_module_sha256": "baa093bb4162ce6f680d45a79f3a52190a3ae5e82d6d36ffd5cb811eda59b7fa", + "comparisons": 28, + "max_absolute_error": 8.526512829121202e-12 + }, + "authorities": [ + "exact kinetic invariants (rational nullspace)", + "closed-form integrals", + "Project Asma exact rational module (optional bridge)" + ], + "checks": { + "continuous_schedules": [ + { + "best_position": 0, + "continuous_criterion_surgery_first": true, + "hypothesis": "burden", + "surgery_keep": 0.1 + }, + { + "best_position": 0, + "continuous_criterion_surgery_first": true, + "hypothesis": "release", + "surgery_keep": 0.1 + }, + { + "best_position": 6, + "continuous_criterion_surgery_first": false, + "hypothesis": "burden", + "surgery_keep": 0.75 + }, + { + "best_position": 0, + "continuous_criterion_surgery_first": true, + "hypothesis": "release", + "surgery_keep": 0.75 + } + ], + "discrete_schedules": [ + { + "best_position": 0, + "exposure_by_position": [ + 21.71874999999823, + 61.718750000007105, + 81.71875000000739, + 91.71875000000682, + 96.71875000000796, + 99.21875000000853, + 100.46875000000739 + ], + "hazard_difference_late_minus_early": 0.6999999838016645, + "hypothesis": "burden", + "identity_error": 8.881784197001252e-14, + "identity_prediction": 0.6999999838017533, + "surgery_keep": 0.1, + "survival_exp_minus_h_error": 1.0345058143457209e-12, + "survival_ratio_late_to_early": 0.49658531183443677 + }, + { + "best_position": 0, + "exposure_by_position": [ + 9.84375, + 54.84375, + 77.34375, + 88.59375, + 94.21875, + 97.03125, + 98.4375 + ], + "hazard_difference_late_minus_early": 0.7874999914193581, + "hypothesis": "release", + "identity_error": 3.3306690738754696e-16, + "identity_prediction": 0.7874999914193578, + "surgery_keep": 0.1, + "survival_exp_minus_h_error": 1.2218004385999848e-12, + "survival_ratio_late_to_early": 0.45498083062086825 + }, + { + "best_position": 6, + "exposure_by_position": [ + 162.890625, + 137.890625, + 125.390625, + 119.140625, + 116.015625, + 114.453125, + 113.671875 + ], + "hazard_difference_late_minus_early": -0.437499989876045, + "hypothesis": "burden", + "identity_error": 2.886579864025407e-15, + "identity_prediction": -0.4374999898760421, + "surgery_keep": 0.75, + "survival_exp_minus_h_error": 7.252254352607679e-13, + "survival_ratio_late_to_early": 1.5488302829569598 + }, + { + "best_position": 0, + "exposure_by_position": [ + 73.828125, + 86.328125, + 92.578125, + 95.703125, + 97.265625, + 98.046875, + 98.4375 + ], + "hazard_difference_late_minus_early": 0.2187500122399817, + "hypothesis": "release", + "identity_error": 1.2490009027033011e-15, + "identity_prediction": 0.21875001223998294, + "surgery_keep": 0.75, + "survival_exp_minus_h_error": 1.1678991107544334e-12, + "survival_ratio_late_to_early": 0.8035225638529566 + } + ], + "exposure_identity_is_exact_kinetic_invariant": { + "burden_chemo_0": true, + "burden_chemo_1": true, + "release_chemo_0": true, + "release_chemo_1": true + }, + "max_continuous_closed_form_relative_error": 5.0162540787823674e-12, + "max_exposure_invariant_drift": 8.651109342783236e-14, + "regimes_after_removal": { + "antigen_driven": { + "committed_error": 2.5673907444456745e-15, + "committed_hazard_bound": 0.09999999979388464, + "committed_hazard_observed": 0.09999999979388208, + "marker_ratio_t10_to_t2": 0.021889566863806328, + "marker_ratio_t20_to_t2": 0.00014793495189425375, + "remaining_neurons_at_end": 0.5488116362071094 + }, + "autonomous_cns": { + "marker_ratio_t10_to_t2": 0.3275330811131708, + "marker_ratio_t20_to_t2": 0.15051984165370738, + "remaining_neurons_at_end": 0.1060600326085199 + } + }, + "steady_state_signature": { + "burden": { + "max_rise": 7.220890552162018e-13, + "never_rises": true, + "rises_during_first_chemo": false + }, + "release": { + "max_rise": 3.3137062052728794, + "never_rises": false, + "rises_during_first_chemo": true + } + } + }, + "integration": { + "max_step": 0.005, + "method": "fixed-step RK4" + }, + "limitations": [ + "invented rates, burdens and units", + "no physiological conversion", + "tumor growth, resistance and order-dependent surgery omitted", + "no anti-Yo, NfL, patient or treatment-benefit claim" + ], + "scope": "synthetic_mathematics_and_software_only_not_biological_validation", + "source_sha256": { + "validation_script": "66c506dc5f36d30776fb485b7a27736a2c044e540b876a915f5f4386eeb2ddca", + "vh_reactions_module": "c062e08a19e6a9ed39df2b2eec2d4f6de98c260e1c63f78381586d2108a51cde" + }, + "status": "pass", + "tolerances": { + "asma": 1e-09, + "closed_form_relative": 1e-08, + "committed": 1e-08, + "drift": 1e-10, + "identity": 1e-10, + "survival": 1e-08 + }, + "virtual_human_checkout": { + "commit": "c88db663ad4193d12de595a1c8df8c784ad92c7d", + "dirty": false + } +} diff --git a/auto-research/2026-11-05-E-paraneoplastic-exposure/results.json b/auto-research/2026-11-05-E-paraneoplastic-exposure/results.json new file mode 100644 index 0000000..f8fbeb2 --- /dev/null +++ b/auto-research/2026-11-05-E-paraneoplastic-exposure/results.json @@ -0,0 +1,177 @@ +{ + "as_of": "2026-11-05", + "authorities": [ + "exact kinetic invariants (rational nullspace)", + "closed-form integrals", + "Project Asma exact rational module (optional bridge)" + ], + "checks": { + "continuous_schedules": [ + { + "best_position": 0, + "continuous_criterion_surgery_first": true, + "hypothesis": "burden", + "surgery_keep": 0.1 + }, + { + "best_position": 0, + "continuous_criterion_surgery_first": true, + "hypothesis": "release", + "surgery_keep": 0.1 + }, + { + "best_position": 6, + "continuous_criterion_surgery_first": false, + "hypothesis": "burden", + "surgery_keep": 0.75 + }, + { + "best_position": 0, + "continuous_criterion_surgery_first": true, + "hypothesis": "release", + "surgery_keep": 0.75 + } + ], + "discrete_schedules": [ + { + "best_position": 0, + "exposure_by_position": [ + 21.71874999999823, + 61.718750000007105, + 81.71875000000739, + 91.71875000000682, + 96.71875000000796, + 99.21875000000853, + 100.46875000000739 + ], + "hazard_difference_late_minus_early": 0.6999999838016645, + "hypothesis": "burden", + "identity_error": 8.881784197001252e-14, + "identity_prediction": 0.6999999838017533, + "surgery_keep": 0.1, + "survival_exp_minus_h_error": 1.0345058143457209e-12, + "survival_ratio_late_to_early": 0.49658531183443677 + }, + { + "best_position": 0, + "exposure_by_position": [ + 9.84375, + 54.84375, + 77.34375, + 88.59375, + 94.21875, + 97.03125, + 98.4375 + ], + "hazard_difference_late_minus_early": 0.7874999914193581, + "hypothesis": "release", + "identity_error": 3.3306690738754696e-16, + "identity_prediction": 0.7874999914193578, + "surgery_keep": 0.1, + "survival_exp_minus_h_error": 1.2218004385999848e-12, + "survival_ratio_late_to_early": 0.45498083062086825 + }, + { + "best_position": 6, + "exposure_by_position": [ + 162.890625, + 137.890625, + 125.390625, + 119.140625, + 116.015625, + 114.453125, + 113.671875 + ], + "hazard_difference_late_minus_early": -0.437499989876045, + "hypothesis": "burden", + "identity_error": 2.886579864025407e-15, + "identity_prediction": -0.4374999898760421, + "surgery_keep": 0.75, + "survival_exp_minus_h_error": 7.252254352607679e-13, + "survival_ratio_late_to_early": 1.5488302829569598 + }, + { + "best_position": 0, + "exposure_by_position": [ + 73.828125, + 86.328125, + 92.578125, + 95.703125, + 97.265625, + 98.046875, + 98.4375 + ], + "hazard_difference_late_minus_early": 0.2187500122399817, + "hypothesis": "release", + "identity_error": 1.2490009027033011e-15, + "identity_prediction": 0.21875001223998294, + "surgery_keep": 0.75, + "survival_exp_minus_h_error": 1.1678991107544334e-12, + "survival_ratio_late_to_early": 0.8035225638529566 + } + ], + "exposure_identity_is_exact_kinetic_invariant": { + "burden_chemo_0": true, + "burden_chemo_1": true, + "release_chemo_0": true, + "release_chemo_1": true + }, + "max_continuous_closed_form_relative_error": 5.0162540787823674e-12, + "max_exposure_invariant_drift": 8.651109342783236e-14, + "regimes_after_removal": { + "antigen_driven": { + "committed_error": 2.5673907444456745e-15, + "committed_hazard_bound": 0.09999999979388464, + "committed_hazard_observed": 0.09999999979388208, + "marker_ratio_t10_to_t2": 0.021889566863806328, + "marker_ratio_t20_to_t2": 0.00014793495189425375, + "remaining_neurons_at_end": 0.5488116362071094 + }, + "autonomous_cns": { + "marker_ratio_t10_to_t2": 0.3275330811131708, + "marker_ratio_t20_to_t2": 0.15051984165370738, + "remaining_neurons_at_end": 0.1060600326085199 + } + }, + "steady_state_signature": { + "burden": { + "max_rise": 7.220890552162018e-13, + "never_rises": true, + "rises_during_first_chemo": false + }, + "release": { + "max_rise": 3.3137062052728794, + "never_rises": false, + "rises_during_first_chemo": true + } + } + }, + "integration": { + "max_step": 0.005, + "method": "fixed-step RK4" + }, + "limitations": [ + "invented rates, burdens and units", + "no physiological conversion", + "tumor growth, resistance and order-dependent surgery omitted", + "no anti-Yo, NfL, patient or treatment-benefit claim" + ], + "scope": "synthetic_mathematics_and_software_only_not_biological_validation", + "source_sha256": { + "validation_script": "66c506dc5f36d30776fb485b7a27736a2c044e540b876a915f5f4386eeb2ddca", + "vh_reactions_module": "c062e08a19e6a9ed39df2b2eec2d4f6de98c260e1c63f78381586d2108a51cde" + }, + "status": "pass", + "tolerances": { + "asma": 1e-09, + "closed_form_relative": 1e-08, + "committed": 1e-08, + "drift": 1e-10, + "identity": 1e-10, + "survival": 1e-08 + }, + "virtual_human_checkout": { + "commit": "c88db663ad4193d12de595a1c8df8c784ad92c7d", + "dirty": false + } +} From 94fa800abb418854417bd9cafc065f416392fa0c Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 00:55:35 +0000 Subject: [PATCH 3/3] Reflect kinetic invariants and exposure work across docs and ledger - Parameter ledger rows P023-P031: five abstract-only premises (CONJECTURE) and four missing kinetic inputs (MISSING) for the paraneoplastic exposure experiment; README section; pinned label counts updated and a row test. All 17 DOIs pass the Crossref title/first-author check, which caught a typographic-apostrophe mismatch now fixed. - Roadmap item 10 status and next steps; graph formalization section on rate-dependent invariants; research foundation toy example of order- dependent exposure with commuting endpoints, plus a dated snapshot update; README layout lists reactions.py. - Integration record: verification for the increment, runtime versions and a Debian setuptools/venv environment note. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01CoFhtGJLght7YiLeEMReMt --- README.md | 3 +- .../README-ovarian-parameter-ledger.md | 12 ++ .../ovarian_hgsoc_parameter_ledger.json | 164 +++++++++++++++++- docs/graph_formalization.md | 15 ++ docs/project-asma-integration.md | 24 +++ docs/research-foundation.md | 33 ++++ docs/roadmap.md | 5 + tests/test_ovarian_parameter_ledger.py | 13 +- 8 files changed, 265 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 96a864a..88eabdc 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,8 @@ vh/molecular energy.py (force field), integrate.py, minimize.py, prep.py, io.p vh/body physiology.py, partition.py, compound.py, pbpk.py vh/bridge molecular → body coupling (Kd ↔ ΔG, receptor occupancy) vh/graph core.py (typed property graph), algorithms.py, physiology_graph.py, render.py, - contracts.py (model interfaces), sbml.py (SBML import), stoichiometry.py (exact algebra) + contracts.py (model interfaces), sbml.py (SBML import), stoichiometry.py (exact algebra), + reactions.py (mass-action dynamics, ordered interventions, kinetic invariants) tests/ pytest suite scripts/ validation report + figure generators docs/ accuracy_ladder, graph_formalization, feasibility, validation reports, architecture, roadmap diff --git a/data/clinical/README-ovarian-parameter-ledger.md b/data/clinical/README-ovarian-parameter-ledger.md index 70bc361..443252f 100644 --- a/data/clinical/README-ovarian-parameter-ledger.md +++ b/data/clinical/README-ovarian-parameter-ledger.md @@ -32,6 +32,18 @@ The citation/locator/label pattern follows the public registry style introduced Schema remains compatible with that registry vocabulary; downstream tools may ignore unknown quantitative keys. +## Paraneoplastic exposure rows (P023–P031) + +Added 2026-11-06 for the [paraneoplastic antigen-exposure experiment](../../auto-research/2026-11-05-E-paraneoplastic-exposure/report.md) +and Project Asma's exposure and observability record. P023–P027 are +abstract-only values (**CONJECTURE**): anti-Yo functional outcome, time to +clinical plateau and survival, and the serum or plasma neurofilament light rises +caused by taxane chemotherapy and by surgery. P028–P031 are the model's kinetic +inputs with no adequate human estimate (**MISSING**): effector decay after antigen +removal, Purkinje-cell loss rate, neurofilament light clearance, and the mode and +gain of antigen presentation. Filling any MISSING row needs a primary source; the +experiment's invented rates are not estimates of them. + ## Validation **Offline (CI):** diff --git a/data/clinical/ovarian_hgsoc_parameter_ledger.json b/data/clinical/ovarian_hgsoc_parameter_ledger.json index 82b8684..8d67748 100644 --- a/data/clinical/ovarian_hgsoc_parameter_ledger.json +++ b/data/clinical/ovarian_hgsoc_parameter_ledger.json @@ -2,7 +2,7 @@ "schema_version": 1, "ledger_id": "ovarian-hgsoc-treatment-sequence", "checked_on": "2026-11-05", - "scope": "Published population and trial parameters for high-grade serous ovarian cancer (HGSOC) and first-line or maintenance treatment-sequence modeling. Public primary literature only; supports Foundation-0/project-asma PR #47 assumption audits and virtual-human graph reaction experiments. Not fitted to private data.", + "scope": "Published population and trial parameters for high-grade serous ovarian cancer (HGSOC) and first-line or maintenance treatment-sequence modeling. Public primary literature only; supports Foundation-0/project-asma PR #47 assumption audits and virtual-human graph reaction experiments. Not fitted to private data. Rows P023-P031 support the paraneoplastic antigen-exposure experiment (anti-Yo cerebellar degeneration and neural injury-rate measurement).", "extends": { "description": "Row identifiers, citation blocks (doi, title, locator) and label vocabulary {KNOWN, CONJECTURE, MISSING} follow the public registry pattern in Foundation-0/project-asma PR #47 (registries/*-sources.json). Quantitative value/range/units/population fields are virtual-human extensions stored under data/clinical/ alongside other provenance-annotated inputs.", "references": [ @@ -414,6 +414,168 @@ "label": "CONJECTURE", "derivation": "value from abstract only", "limits": "Includes bevacizumab maintenance." + }, + { + "id": "P023", + "quantity": "Fraction of anti-Yo paraneoplastic cerebellar degeneration patients remaining ambulatory at last follow-up", + "value": 0.21, + "range": { "kind": "point", "low": null, "high": null, "level": null }, + "units": "fraction of patients", + "population": "Antibody-associated paraneoplastic cerebellar degeneration; Rotterdam antineuronal-antibody laboratory, 12-year retrospective series (n=50; anti-Yo n=19)", + "citation": { + "doi": "10.1093/brain/awg133", + "first_author_surname": "Shams’ili", + "year": 2003, + "title": "Paraneoplastic cerebellar degeneration associated with antineuronal antibodies: analysis of 50 patients" + }, + "locator": "Europe PMC abstract (PMID 12764061); full article not openly accessible", + "label": "CONJECTURE", + "derivation": "value from abstract only; 4 of 19 anti-Yo patients remained ambulatory, 4/19 = 0.21", + "limits": "Functional state at last follow-up or death, not an injury rate; mixed gynecological and breast tumors; small retrospective series." + }, + { + "id": "P024", + "quantity": "Upper bound on time from onset to clinical plateau of antibody-associated cerebellar ataxia", + "value": 6, + "range": { "kind": "min_max", "low": null, "high": 6, "level": null }, + "units": "months", + "population": "Antibody-associated paraneoplastic cerebellar degeneration; Rotterdam antineuronal-antibody laboratory, 12-year retrospective series (n=50; anti-Yo n=19)", + "citation": { + "doi": "10.1093/brain/awg133", + "first_author_surname": "Shams’ili", + "year": 2003, + "title": "Paraneoplastic cerebellar degeneration associated with antineuronal antibodies: analysis of 50 patients" + }, + "locator": "Europe PMC abstract (PMID 12764061)", + "label": "CONJECTURE", + "derivation": "value from abstract only; all patients had ataxia 'progressive over weeks to months and stabilized within 6 months'", + "limits": "A plateau can reflect an ended attack or a depleted target; functional scores cannot distinguish them (Asma exposure and observability record)." + }, + { + "id": "P025", + "quantity": "Median survival from diagnosis in anti-Yo paraneoplastic cerebellar degeneration", + "value": 13, + "range": { "kind": "point", "low": null, "high": null, "level": null }, + "units": "months", + "population": "Antibody-associated paraneoplastic cerebellar degeneration; Rotterdam antineuronal-antibody laboratory, 12-year retrospective series (n=50; anti-Yo n=19)", + "citation": { + "doi": "10.1093/brain/awg133", + "first_author_surname": "Shams’ili", + "year": 2003, + "title": "Paraneoplastic cerebellar degeneration associated with antineuronal antibodies: analysis of 50 patients" + }, + "locator": "Europe PMC abstract (PMID 12764061)", + "label": "CONJECTURE", + "derivation": "value from abstract only; median 13 months for anti-Yo versus 7 for anti-Hu, >113 for anti-Tr and >69 for anti-Ri", + "limits": "Not HGSOC-specific; survival from neurological diagnosis, not cancer diagnosis; era 1990s-2000s." + }, + { + "id": "P026", + "quantity": "Peak serum neurofilament light chain during taxane chemotherapy", + "value": 129.9, + "range": { "kind": "point", "low": null, "high": null, "level": null }, + "units": "pg/mL", + "population": "Adults prescribed at least four cycles of oxaliplatin, cisplatin, docetaxel or paclitaxel; n=42 completed (36 platinum, 6 taxane)", + "citation": { + "doi": "10.1136/bmjno-2025-001312", + "first_author_surname": "Smyth", + "year": 2026, + "title": "Prospective assessment of serum neurofilament light chain in platinum-induced and taxane-induced peripheral neuropathy" + }, + "locator": "Europe PMC abstract (PMID 41509522), Results", + "label": "CONJECTURE", + "derivation": "value from abstract only; peak sNfL 129.9 pg/mL with taxanes versus 31.0 pg/mL with platinum agents", + "limits": "Peripheral neuropathy context with six taxane patients. Shows that serum NfL during carboplatin-paclitaxel cannot be read as cerebellar injury without a comparator." + }, + { + "id": "P027", + "quantity": "Plasma neurofilament light chain 48 hours after surgery relative to baseline", + "value": 1.6, + "range": { "kind": "point", "low": null, "high": null, "level": null }, + "units": "fold change", + "population": "Older surgical patients; n=79, mean age 69", + "citation": { + "doi": "10.1213/ANE.0000000000008163", + "first_author_surname": "Atkins", + "year": 2026, + "title": "Postoperative Delirium and Neurocognitive Disorders Associated With Inflammatory and Neuronal Injury Biomarkers: A Prospective, Longitudinal, Cohort Study" + }, + "locator": "Europe PMC abstract (PMID 42302277), Results", + "label": "CONJECTURE", + "derivation": "value from abstract only; NfL 1.6 times higher at 48 hours postsurgery than baseline", + "limits": "Not gynecologic oncology surgery; magnitude and duration after debulking unknown; confounds NfL around surgery." + }, + { + "id": "P028", + "quantity": "Decay rate of antigen-driven anti-Yo (cdr2/CDR2L-specific) effector activity after antigen removal", + "value": null, + "range": null, + "units": null, + "population": "Anti-Yo paraneoplastic cerebellar degeneration with gynecologic or breast cancer", + "citation": { + "doi": "10.1038/3315", + "first_author_surname": "Albert", + "year": 1998, + "title": "Tumor-specific killer cells in paraneoplastic cerebellar degeneration" + }, + "locator": "Europe PMC abstract (PMID 9809559): expanded cdr2-specific CTLs in 3/3 HLA-A2.1+ patients; no kinetics reported", + "label": "MISSING", + "derivation": null, + "limits": "Sets the injury committed after complete antigen removal (kappa * E / delta) in the exposure model; no human estimate located." + }, + { + "id": "P029", + "quantity": "Rate of Purkinje-cell loss per unit effector activity in anti-Yo paraneoplastic cerebellar degeneration", + "value": null, + "range": null, + "units": null, + "population": "Anti-Yo paraneoplastic cerebellar degeneration", + "citation": { + "doi": "10.1002/acn3.328", + "first_author_surname": "Venkatraman", + "year": 2016, + "title": "Paraneoplastic cerebellar degeneration with anti-Yo antibodies - a review" + }, + "locator": "PMC4999597, Pathogenesis > Pathology: 'the loss of PCs is often very rapid'; no rate reported", + "label": "MISSING", + "derivation": null, + "limits": "Neuropathology describes extent, not kinetics; required to turn exposure differences into neural-outcome differences." + }, + { + "id": "P030", + "quantity": "Clearance half-life of serum and CSF neurofilament light chain applicable to cerebellar injury", + "value": null, + "range": null, + "units": null, + "population": "Autoimmune or paraneoplastic CNS disease", + "citation": { + "doi": "10.1212/WNL.0000000000207221", + "first_author_surname": "Brenner", + "year": 2023, + "title": "Predictive Value of Serum Neurofilament Light Chain Levels in Anti-NMDA Receptor Encephalitis" + }, + "locator": "Europe PMC abstract (PMID 37015822): serial NfL 'roughly follow clinical disease activity, albeit with delay'; no half-life", + "label": "MISSING", + "derivation": null, + "limits": "Sets the sampling interval needed to resolve injury-rate changes. A 43-day serum estimate seen as a secondary citation was not traced to a primary source and is not entered." + }, + { + "id": "P031", + "quantity": "Antigen presentation mode and gain in anti-Yo disease: proportional to living tumor burden versus released by in-body tumor death", + "value": null, + "range": null, + "units": null, + "population": "Anti-Yo paraneoplastic cerebellar degeneration", + "citation": { + "doi": "10.1038/3315", + "first_author_surname": "Albert", + "year": 1998, + "title": "Tumor-specific killer cells in paraneoplastic cerebellar degeneration" + }, + "locator": "Europe PMC abstract (PMID 9809559): cross-presentation of apoptotic cells by dendritic cells led to a potent CTL response; no quantitative comparison", + "label": "MISSING", + "derivation": null, + "limits": "Decides which treatment order minimizes neural exposure in the exposure model; the two pure modes disagree when surgery retains more than one cycle." } ] } diff --git a/docs/graph_formalization.md b/docs/graph_formalization.md index efac275..f232477 100644 --- a/docs/graph_formalization.md +++ b/docs/graph_formalization.md @@ -138,6 +138,21 @@ flowchart LR The full imported graph, including reaction nodes and moieties, is in [`img/kholodenko_mapk_sbml.mmd`](img/kholodenko_mapk_sbml.mmd). +## Rate-dependent invariants: integrals become checks + +Stoichiometric conservation laws depend only on the reaction structure. Some +useful identities also depend on rate values. Grouping mass-action reactions by +their reactant monomial gives an exact linear system whose nullspace is every +weight vector conserved along every trajectory; `ReactionNetwork.kinetic_invariant_basis()` +returns it in exact rationals. Adding an accumulator (`A -> A + U`) turns a +path integral into a state, so identities such as *amount eliminated = k × AUC* +or a cumulative-hazard/exposure balance become invariants the finder discovers +on its own. In the [paraneoplastic exposure experiment](../auto-research/2026-11-05-E-paraneoplastic-exposure/report.md) +it recovered Project Asma's exposure identity, then caught a wiring error: a +hypothesis meant to be release-only still had burden presentation switched on, +and the pure identity correctly failed. Details and limits are in +[reaction experiments](reaction_experiments.md#kinetic-invariants-and-cumulative-exposure). + ## The graph verifying the physics engine The sharpest demonstration that the formalization is faithful: a **pure graph diff --git a/docs/project-asma-integration.md b/docs/project-asma-integration.md index 4234bd4..71b4eae 100644 --- a/docs/project-asma-integration.md +++ b/docs/project-asma-integration.md @@ -207,3 +207,27 @@ rational module, using a trusted local checkout as before. All rates, burdens and units are invented. No patient data, anti-Yo mechanism, neurofilament-light validity or treatment benefit enters the library, the experiment or the bridge. + +Verification for this increment (2026-11-05): **231 Python tests passed with no +skips** in 70.4 seconds, including 16 new focused cases; JavaScript engine checks +passed. Recorded runs are pinned to clean checkouts (VH `c88db66`, Asma +`a5086b8`) in [`results.json`](../auto-research/2026-11-05-E-paraneoplastic-exposure/results.json) +and [`bridge-results.json`](../auto-research/2026-11-05-E-paraneoplastic-exposure/bridge-results.json). +Runtime: Linux x86_64, Python 3.13 in a fresh virtual environment, NumPy 2.5.4, +SciPy 1.18.1, JAX 0.12.0.1, OpenMM 8.6.1, PDBFixer from source, PySCF 2.15.0, +geomeTRIC 1.1.1, libRoadRunner 2.11.0, pytest 9.2.0, Node 22. + +**Environment note.** On Debian/Ubuntu system Python, `pip install -e '.[dev]'` +fails to build geomeTRIC and PDBFixer because the distribution's patched +setuptools lacks `install_layout`. A fresh `python -m venv` with upgraded `pip`, +`setuptools` and `wheel`, as in the commands above, installs everything. Write +validation output outside the checkout (or commit first); a redirect into the +working tree marks the recorded checkout as dirty. + +**2026-11-06 follow-up.** The [ovarian parameter ledger](../data/clinical/README-ovarian-parameter-ledger.md) +now records the experiment's premises and gaps as rows P023–P031. All 17 ledger +DOIs passed the Crossref title and first-author check, which caught and fixed a +typographic-apostrophe mismatch in one new surname. Open next steps for both +repositories are listed in Asma's +[continuation section](https://github.com/Foundation-0/project-asma/blob/main/docs/research/paraneoplastic-exposure-observability.md#continuation-for-the-team) +and in [roadmap item 10](roadmap.md). diff --git a/docs/research-foundation.md b/docs/research-foundation.md index 4a516e2..9f17218 100644 --- a/docs/research-foundation.md +++ b/docs/research-foundation.md @@ -111,6 +111,31 @@ in every model: two fixed diagonal removal operations still commute. Scalar proportional retention commutes with any fixed homogeneous linear flow. These null cases should be retained alongside counterexamples. +Commuting endpoints do not mean commuting histories. Hold each result for one +time unit and add up the burden along the way, its exposure (area under the +curve). With A retaining one half and B one tenth, both orders end at 5, but +the exposure differs: + +```python +from fractions import Fraction + +def exposure(order, burden=Fraction(100)): + total = Fraction(0) + for retain in order: + burden *= retain + total += burden # one time unit at this level + return burden, total + +assert exposure([Fraction(1, 2), Fraction(1, 10)]) == (5, 55) +assert exposure([Fraction(1, 10), Fraction(1, 2)]) == (5, 15) +``` + +Any outcome that accumulates, such as irreversible injury driven by what is +present, can therefore depend on order when the endpoint cannot. Asma's +[exposure and observability record](https://github.com/Foundation-0/project-asma/blob/main/docs/research/paraneoplastic-exposure-observability.md) +develops this for paraneoplastic neural injury; the engine's kinetic invariants +check it ([reaction experiments](reaction_experiments.md#kinetic-invariants-and-cumulative-exposure)). + Asma's [treatment-sequence assumption audit][sequence-result] compares proportional retention with a capped fixed-residual rule, using artificial sensitive/resistant burdens and exact rational arithmetic. It preserves negative results and explains @@ -156,6 +181,14 @@ automatically updated status dashboard. validation. The [roadmap](roadmap.md) is an ambition and acceptance-test list, not proof that these capabilities already exist. +**Update, 2026-11-06.** The SBML importer from PR #4 has since merged (main +`2f23ae5`). Branch `claude/admiring-cori-0qyybb` (commit `d0d2730`, not yet merged) +adds rate-dependent kinetic invariants and a paraneoplastic antigen-exposure +experiment cross-checked against Asma's exact module +([report](../auto-research/2026-11-05-E-paraneoplastic-exposure/report.md)). The +[ovarian ledger](../data/clinical/README-ovarian-parameter-ledger.md) now also lists +that experiment's published premises and its missing kinetic parameters. + ## 5. How to start from this foundation For one specific research question, use the [question template](research-question-template.md): diff --git a/docs/roadmap.md b/docs/roadmap.md index 6b78fe3..9c8f8df 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -78,6 +78,11 @@ A cell is ~10¹⁴ atoms, so pure CCSD(T) will never reach it. The path up: *Started 2026-11-05:* a from-scratch SBML core reader with exact conservation and positive-mass invariants, validated against libRoadRunner ([report](../auto-research/2026-11-05-E-sbml-import/report.md)). Still open: events, rate rules, delays, units checking, and wiring `vh.bridge` occupancy into a pathway. + *Added 2026-11-05:* rate-dependent **kinetic invariants** for mass-action networks + (`kinetic_invariant_basis`, `kinetic_residuals`), which make exposure (AUC) and clearance identities exact + checks ([report](../auto-research/2026-11-05-E-paraneoplastic-exposure/report.md)). Next: run the finder on + the imported BioModels and the PBPK graph to see whether any rate-dependent identity is present or violated, + and add derivatives of invariants across phases. 11. **Uncertainty end to end.** Propagate parameter uncertainty across scales; Bayesian calibration; because every layer is differentiable (JAX), gradients of a clinical endpoint with respect to molecular parameters. diff --git a/tests/test_ovarian_parameter_ledger.py b/tests/test_ovarian_parameter_ledger.py index dca4e5b..d38bce1 100644 --- a/tests/test_ovarian_parameter_ledger.py +++ b/tests/test_ovarian_parameter_ledger.py @@ -59,8 +59,8 @@ def test_missing_rows_have_null_value(): def test_label_counts_stable(): counts = label_counts(load_ledger()) assert counts["KNOWN"] == 4 - assert counts["CONJECTURE"] == 6 - assert counts["MISSING"] == 12 + assert counts["CONJECTURE"] == 11 + assert counts["MISSING"] == 16 assert sum(counts.values()) == len(load_ledger()["entries"]) @@ -77,3 +77,12 @@ def test_crossref_doi_check_live(): report = check_dois(load_ledger()) assert report["failures"] == 0 assert report["unique_dois_checked"] >= 10 + + +def test_paraneoplastic_rows_keep_values_and_gaps(): + by_id = {e["id"]: e for e in load_ledger()["entries"]} + assert by_id["P023"]["value"] == 0.21 + assert by_id["P026"]["value"] == 129.9 + assert by_id["P027"]["value"] == 1.6 + for missing in ("P028", "P029", "P030", "P031"): + assert by_id[missing]["label"] == "MISSING" and by_id[missing]["value"] is None