Skip to content

Wire sample_hidden_graph RNG through RNGRoot for cross-component reproducibility #9

Closed

Description

@shaypal5

Context

sample_hidden_graph(seed) in leadforge/structure/sampler.py currently constructs a fresh np.random.default_rng(seed) directly from the integer seed. The repo convention (established in leadforge/core/rng.py) is that all stochastic components derive their randomness from a single RNGRoot(seed) with named child streams.

Problem

Bypassing RNGRoot makes cross-component RNG coupling harder to control when the sampler is integrated with the simulation engine. It also means the seed space isn't partitioned the same way as other components.

Proposed fix

When the sampler is wired into Generator/the simulation pipeline (M5/M6), change the API to accept an RNGRoot or a named substream:

rng_root = RNGRoot(seed)
graph_rng = rng_root.child("hidden_graph")
g = sample_hidden_graph(rng=graph_rng, motif_family_name=...)

Why deferred

The right substream name and API shape depends on how Generator calls the sampler — which is defined in Milestone 5 (population generation). Designing the interface now would be premature.

Raised by Copilot in PR #8.

Activity

  1. added
    type: refactor
    layer: structure
    on Apr 22, 2026
  2. added 3 commits that reference this issue on May 1, 2026
    1406c82
    f2fc4a2
    d62faf8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    layer: structuretype: refactor

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions