Boundary leaves never reuse a node downstream of the root complex — the welded-loop defect (held-out +173) - #91
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A root-input complex's subunit leaf is a boundary input.
_leaf_uuidreused 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 weldsroot 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/018P8, pre-registered; production solver, no solver rule; both axes)cat_os)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;anyrestores 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