Skip to content

Boundary leaves never reuse a node downstream of the root complex — the welded-loop defect (held-out +173) - #91

Merged
adamjohnwright merged 3 commits into
mainfrom
fix/boundary-leaf-no-produced-reuse
Sep 20, 2026
Merged

adamjohnwright merged 3 commits into
mainfrom
fix/boundary-leaf-no-produced-reuse

Conversation

@adamjohnwright

@adamjohnwright adamjohnwright commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

What

A root-input complex's subunit leaf is a boundary input. _leaf_uuid reused the leaf's existing node whenever the protein already had one anywhere in the network — including a copy the root complex itself reaches downstream. That welds root complex → reactions → … → produced protein → (assembly) → root complex, a cycle Neo4j never had (Adam's diagnosis). On the v97 catalog 1,994 of the 2,077 cycle-carrying assembly edges have exactly this shape.

Rule (second version, after adversarial review): a leaf may reuse any existing node the root complex cannot reach — reachability over every edge emitted so far (bridges and depletion included). The first version refused every produced node and also severed 752 acyclic feed-forward links (Mitotic G1 −28, no_path +174); this version removes exactly the cycles Reactome lacks and keeps every link. LNG_BOUNDARY_LEAF_REUSE=downstream_free (default) | any (old behaviour).

Measured (deltasignal specs/018 P8, pre-registered; production solver, no solver rule; both axes)

before (cat_os) after
stable-id edge multiset identical in all 92 pathways; +336 fresh leaf nodes, nothing else
cyclic components / TP53 / DSB largest 258 / 836 / 1,127 210 / 56 / 290
cycle-carrying assembly edges 2,077 36
curator, all 82 pathways 83.47% / mF1 0.8009 84.71% / 0.8137
held-out, conditioned +173 (199 fixed / 26 broke, p < 1e-4)
tuning +109 (121 / 12)
false change 1,437 1,150
experimental (conditioned) +3
AKT-KO → TP53 (of 102) 100 100
Mitotic G1 −4

Stated plainly: 94% of the held-out gain is DSB Repair (its 1,127-node welded component was collapsing to zero under PARP1/2, FEN1, POLQ, RTEL1, XRCC5/6, MUS81 knockouts), and 187 of the 199 fixes are DOWN → NORMAL where the truth is NORMAL. Adopted on correctness grounds; the accuracy gain is one pathway's, and is reported as such. The production catalog must be regenerated with this generator for any of it to reach the API.

Tests

tests/test_boundary_leaf_reuse.py (6): a downstream produced copy gets a fresh leaf; a bridge-reached copy counts as downstream; a produced copy that is not downstream is reused (the Mitotic G1 shape); two root complexes sharing a subunit each get an acyclic leaf; any restores the weld; a bad mode errors. Suite: 1,021 pass, 1 pre-existing MHC failure.

Includes #90's commit (sharing / composition edges, both off by default) as its base.

🤖 Generated with Claude Code

adamjohnwright and others added 2 commits September 19, 2026 21:34
LNG_SHARE_VARIANT_NODES=1: the same entity in the same role across the
variant reactions of ONE Reactome reaction shares one UUID (BCDX2 in HDR was
33 nodes from 5 reactions). Full catalog: nodes 107,893 -> 70,402 (-35%),
oracle root->terminal reachability identical in all 92 pathways. Measured in
deltasignal specs/016: prediction-neutral on held-out (-1 vs cat_os),
-64 tuning (a TP53 loop basin flip), experimental +1 conditioned. A
correctness change, not an accuracy change.

LNG_COMPOSITION_EDGES=1: complex node -> node of a complex that contains it
(hasComponent, <=2 hops), edge_type "composition". Measured under three
solver semantics; the entire held-out gain is Interferon alpha/beta (+100,
the branch the curator oracle found severed at ISGF3) and it is negative
everywhere else. Stays off. Two design defects recorded for follow-up: 33%
of the edges duplicate a curated reaction, and the edge targets every
positional copy of the container (up to 28 per pair).

Adversarial review fixes: the containing-complex Cypher labels the entity so
the stId index is used (was a full-store scan, ~700 ms/call); label lookup
failures narrow to unknown-stId errors instead of swallowing connection
errors; a reaction id read back as the string "nan" is no longer a shared
key; unmapped variants are counted and warned. Tests: 4 added/strengthened.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A root-input complex's subunit leaf is a boundary INPUT. `_leaf_uuid` reused
the leaf's existing node whenever the protein already had one anywhere in the
network -- including a copy some reaction PRODUCES downstream of the root.
That welds root complex -> reactions -> produced protein -> (assembly) -> root
complex, a cycle Neo4j never had. On the v97 catalog 1,994 of the 2,077
cycle-carrying assembly edges have exactly this shape (produced source, root-
complex target), and removing them takes TP53's strongly connected component
from 836 nodes to 56 and DSB's from 1,127 to ~290. MP-BioPath's hand-curated
networks carry none of them.

Reuse now applies only to unproduced nodes (a free protein that is itself a
root, a catalyst, a regulator); a produced copy gets a fresh boundary leaf.
LNG_BOUNDARY_LEAF_REUSE=any restores the old behaviour for the A/B. Adam's
diagnosis: "the breaking apart of complexes in terminal outputs and root
inputs should not create loops as they would get different uuids."

Tests: tests/test_boundary_leaf_reuse.py (3); suite 1,018 pass, 1 pre-existing
MHC failure. Measurement: deltasignal specs/018.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Adversarial review of the first version: refusing every produced node also
severed 752 acyclic feed-forward links (a produced protein that is a subunit
of a root complex, joined by hasComponent with no reaction), and Mitotic G1
lost 28 cases that the old behaviour got right by accident; no_path grew by
174. The precise rule: a leaf may reuse any existing node the root complex
cannot reach -- reachability over every edge emitted so far, bridges and
depletion edges included (the output-only definition let 28 welds survive).
Exactly the cycles Neo4j lacks are removed; every feed-forward link is kept.

LNG_BOUNDARY_LEAF_REUSE: downstream_free (default) | any (old behaviour).
Tests: 6 in tests/test_boundary_leaf_reuse.py, incl. the Mitotic G1 shape
(produced copy not downstream -> reused) and two roots sharing a subunit.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@adamjohnwright adamjohnwright changed the title Boundary leaves never reuse a produced node — the welded-loop defect (held-out +222) Boundary leaves never reuse a node downstream of the root complex — the welded-loop defect (held-out +173) Sep 20, 2026
@adamjohnwright
adamjohnwright merged commit 13847fa into main Sep 20, 2026
4 checks passed
@adamjohnwright
adamjohnwright deleted the fix/boundary-leaf-no-produced-reuse branch September 20, 2026 16:16
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.

1 participant