Skip to content

Import the Foundation-0 graph stack: contracts, reactions, SBML, evidence, clearance - #6

Open
ahrazzle wants to merge 16 commits into
fix/reported-numbersfrom
import/foundation-graph-stack
Open

ahrazzle wants to merge 16 commits into
fix/reported-numbersfrom
import/foundation-graph-stack

Conversation

@ahrazzle

@ahrazzle ahrazzle commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

What this is

Stack: #5 → #6 → #7 → #8 (this PR is layer 2 of 4). Each branch contains the previous layer, so merging in order with merge commits lands the whole stack in one sweep with no conflicts (verified locally: four sequential merges, final tree identical to the #8 tip, 304 tests passing). GitHub retargets each child to main as its parent merges. Please avoid squash- or rebase-merging individual layers, which would strand the child branches' copies of the parent commits.
One integration PR moving all merged work from the interim fork Foundation-0/virtual-human (its main at 6b10b45) onto upstream main (d6a5963), now that direct contribution here is possible. It is a true merge commit, so fork history and authorship are preserved. Per-feature review already happened on the fork; this PR links that record instead of re-posting it as seven PRs:

Fork PR Contents
#1 Graph model contracts (vh/graph/contracts.py), plasma-referenced clearance reporting (17.104 L/h replaces mixed-basis 28.488 L/h)
#2 Deterministic subgraph node order (hash-seed independent)
#3 Conserved reaction networks + explicit intervention experiments (reactions.py)
#4 SBML import as verified graphs (sbml.py, stoichiometry.py, 3 CC0 BioModels in data/sbml/)
#5 Ovarian HGSOC parameter ledger (data/clinical/, standalone validator)
#6 Research-foundation and Asma-integration docs
#7 Explicit evidence bindings at scalar model boundaries (evidence.py)

The graph stack is kept in one PR because its parts are interdependent (evidence → contracts, sbml → stoichiometry, shared vh/graph/__init__, render.py, README): splitting it would re-conflict on the same files in every piece. If size is a problem, the one clean split is the ledger + Asma docs (no vh imports) into a follow-up; happy to do that on request.

Merge resolutions (the only 4 conflicted files)

  • vh/graph/render.py — union of both style/label registries (flow reservoir/junction/conduit + SBML species/reaction/moiety/reactant/product/modifier/member); clears keeps the units/reference-basis-aware label.
  • auto-research/README.md — union of index rows (4 fork + vein-flow + evidence-bindings entry).
  • README.md, docs/graph_formalization.md — prose union: upstream flow/Bernoulli sections and fork SBML/clearance sections both kept; the stale 28.488 L/h claim, pbpk_graph.png embed, and "every edge carries the validated model" wording retired in favour of the corrected plasma-referenced reporting (fork PR Welcome to virtual-human Discussions! #1). The fork banner was dropped for upstream. Docs now reference checked-in Mermaid sources; scripts/validate_graph.py render targets updated from the deleted .svg paths to those .mmd sources (2 lines, folded into the merge commit).
  • pyproject.toml / CI take the fork versions: libroadrunner dev dependency (SBML referee, tests only), network marker with pytest -q -m "not network" (keeps the live-Crossref DOI test out of default CI), and the offline ledger-validation step. Without these, the merged tree would run a live-network test in CI and silently skip the 9 SBML referee tests.

Verification (merged tree, this branch)

  • pytest -q -m "not network": 251 passed, 6 skipped (py3.12 + libroadrunner; skips are openmm/pyscf gates), 0 failed. Bare numpy/scipy env: 242 passed (= 218 fork + 24 upstream flow, composed cleanly).
  • Validators exit 0: validate_model_contracts, validate_reaction_experiments, validate_evidence_bindings, validate_ovarian_parameter_ledger, validate_flow (venous headline unchanged: 88.7 mmHg standing), validate_body, validate_sbml (libRoadRunner referee). node web/test_engines.mjs: all JS engine checks pass.
  • CI was green on both merge parents (6b10b45 fork, d6a5963 here).

Flagged for maintainer call (no action taken)

Raz Arif and others added 15 commits November 5, 2026 14:15
Validate graph model interfaces and correct clearance reference reporting
…#3)

* Add conserved mass-action networks and explicit intervention protocols

* Record Asma intervention bridge verification and merged baseline

* Link review PRs and pin clean Asma bridge source revision

---------

Co-authored-by: Raz Arif <a@askaconsult.com>
Graph.subgraph iterated a set of node ids, so the order of nodes in a
subgraph, and in its JSON and Mermaid output, changed with
PYTHONHASHSEED. Regenerating docs/img/pbpk_elimination_subgraph.mmd
reordered its node lines on every run, with no change in content.

Subgraphs now keep the parent graph's insertion order and raise KeyError
naming any unknown ids. A new test renders the PBPK elimination
subgraph under four hash seeds and requires identical output; the test
fails on the previous implementation. The regenerated Mermaid source is
committed; the graph JSON and validation outputs are unchanged.


Claude-Session: https://claude.ai/code/session_01CoFhtFtE7wJgvHKAzNB3xD

Co-authored-by: Claude <noreply@anthropic.com>
* Add cited ovarian HGSOC parameter ledger with Crossref checks

Introduce a machine-readable treatment-sequence parameter ledger under
data/clinical/, extending the project-asma PR #47 registry citation shape
with quantitative rows (KNOWN, CONJECTURE, MISSING). Include schema
validation, offline pytest coverage, CI hook, and a pinned script with an
optional Crossref DOI title/author verification step.

Co-authored-by: Orda <orda@askaconsult.com>

* Re-verify ledger rows against open full text only

Restrict KNOWN to TCGA values read from PMC3163504; downgrade trial
and meta-analysis figures to CONJECTURE (abstract only) or MISSING when
full text is paywalled or the abstract lacks the quantity. Correct CA-125
and HRD rows and document verification locators.

Co-authored-by: Orda <orda@askaconsult.com>

* Fix pytest import path and pin TCGA KNOWN ledger values

Set pytest pythonpath to the repo root so CI can import scripts without
PYTHONPATH. Correct P005 PMC section locators and add regression tests for
verified KNOWN numeric values P002–P005.

Co-authored-by: Orda <orda@askaconsult.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
* Import SBML reaction networks as verified graphs

Add a from-scratch reader for SBML Level 2/3 core (vh/graph/sbml.py):
compartments, species, global and local parameters, function
definitions, initial assignments, assignment rules and reactions with
MathML kinetic laws. Unsupported constructs (events, rate and algebraic
rules, delays, fast reactions, stoichiometryMath, conversion factors,
variable compartments, required packages) are refused by name.
Documents with a DOCTYPE are refused and MathML compiles to closures
over a fixed operator table. Models simulate, solve for steady states
on the conservation-reduced system and report reduced eigenvalues.

vh/graph/stoichiometry.py does exact rational algebra: canonical
conservation laws (RREF of the left nullspace) and positive-mass
stoichiometric consistency (Gevorgyan et al. 2008) with exactly checked
certificates. SBML graphs carry species, reaction, compartment and
moiety nodes; the schema recomputes N from edges and checks
stoichiometry, location, exact complete conservation and consistency.

Validation (scripts/validate_sbml.py, auto-research report): three CC0
BioModels vendored with SHA-256 provenance agree with libRoadRunner,
an independent SBML engine used only as a test referee, to <=6.9e-10 on
trajectories, <=1.7e-12 on steady states and <=1.3e-9 on reduced
eigenvalues; periods match to ~1e-11. Across BIOMD0000000001-060, 49
models are read and 11 refused by name; trajectories of all 49 agree
with the referee (median 1.7e-9). The consistency invariant flags 8
models with exact certificates, including a stoichiometry used as a
unit conversion in Chassagnole 2002, as its own notes describe.

libroadrunner joins the dev extras as a test-only referee.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CoFhtFtE7wJgvHKAzNB3xD

* Refuse DTDs in any encoding, not only ASCII-compatible bytes

The DOCTYPE/entity refusal scanned raw bytes for "<!doctype" and
"<!entity". In UTF-16 those markers are interleaved with NUL bytes, so
a UTF-16 document with an internal entity passed the scan and
ElementTree expanded it (reported in review on #4).

read_sbml now pre-parses with expat, which decodes the declared
encoding, and refuses on any DOCTYPE or entity declaration. Input expat
cannot decode (for example UTF-32), empty input and truncated XML raise
SBMLError instead of passing through. New tests cover UTF-16 with and
without a byte-order mark in both byte orders, a UTF-16 document
without a DOCTYPE that must still load, and unreadable input; six of
the seven fail on the previous code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CoFhtFtE7wJgvHKAzNB3xD

---------

Co-authored-by: Claude <noreply@anthropic.com>
…261106

Preserve evidence context and uncertainty at scalar model boundaries
…-graph-stack

# Conflicts:
#	README.md
#	auto-research/README.md
#	docs/graph_formalization.md
#	vh/graph/render.py
…t/foundation-graph-stack

# Conflicts:
#	README.md
#	auto-research/README.md
Comment thread vh/graph/sbml.py

def residual(y):
x = y * sizes
f = self.amount_derivative(x) / sizes

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A rate that happens to vanish at time zero can produce a false steady state.

amount_derivative(x) defaults to t=0. For a one-species SBML model with initial amount A=10 and the decay law dA/dt = -t*A (using the SBML time symbol), steady_state() returns A=10, success=True, and zero residual. Evaluating that same state at t=1 gives dA/dt=-10.

Please reject steady-state analysis for time-dependent kinetics, including time dependence through assignment rules, or expose this explicitly as a root at a fixed time. The trajectory solver should continue to support time-dependent laws.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants