Skip to content

Route standalone create_*/survival generators through the seed primitive for package-wide RNG isolation #47

Description

@DougManuel

Follow-up from the #38 seed-contract whole-branch review.

The v0.5 seed contract (#38) makes .with_mock_seed() — save/restore .Random.seed + RNGkind, L'Ecuyer-CMRG sub-streams — the seeding primitive for the paths reachable through create_mock_data() (native, postprocess, simstudy, legacy loop). But the standalone exported generators, when called directly with a seed, still use a bare set.seed(seed) under the ambient RNG kind and clobber the caller's RNG stream:

  • create_cat_var(), create_con_var(), create_date_var()
  • sample_with_proportions(), make_garbage(), apply_garbage() (R/mockdata_helpers.R)
  • create_survival_dates(), create_wide_survival_data()

These are not reachable from create_mock_data() (the orchestrator passes seed = NULL to them and owns the seeding), so there is no isolation gap in the main entry point — this is about direct callers of the standalone functions. The v0.5 NEWS note is already scoped to seeded create_mock_data()/generate_mock_data_*()/postprocess_mock_data() calls to avoid over-promising.

Fix direction: route these through .with_mock_seed() (or a shared seeding helper) so a directly-supplied seed gets the same isolation + L'Ecuyer contract. Decide whether the survival generators warrant their own frozen stage index. Add isolation tests (caller .Random.seed/RNGkind unchanged) for each exported generator.

Sized S–M. Additive; but note it would change seeded output of direct standalone calls (MT→L'Ecuyer) — bundle with the v0.5 break or document as a further break.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Nice to have, lower urgency

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions