Skip to content

effects: a seeded PCG32 generator for deterministic simulation (specs/effects/sim_rand.t27) #9010

Closed as not planned

Description

@gHashTag

Part of epic #9008 (effects at the edge); deterministic simulation primitives for #9002. Write it in t27 only. DRY rule (AGENTS.md, see #8963): first search for an existing implementation with t27c dupes --name <fn> and grep -rn over specs/. If one exists, use it and extend it instead of writing a copy. No hand-written code in other languages (see #8236).

Requirements

  • FR-001: specs/effects/sim_rand.t27 defines a PCG32 generator (the pcg32 XSH RR variant of pcg-c-basic) as a struct with state and increment. It has pcg32_seed(initstate: u64, initseq: u64) and pcg32_next(rng: *Pcg32) -> u32. All arithmetic wraps mod 2^64, as the reference does.
  • FR-002: A test named pcg32_reference_vectors seeds with initstate 42 and initseq 54, then asserts that the first six outputs are exactly 0xa15c02b7, 0x7b47f409, 0xba1d3330, 0x83d2f293, 0xbfa4784b, 0xcbed606e (the pcg32-demo reference).
  • FR-003: A test named pcg32_same_seed_same_stream asserts that two generators with the same seed give the same 100 outputs, and a different seed gives a different first output.
  • FR-004: Do NOT edit docs/reports/t27b_expectations.json or .trinity/seals/: they are shared hot files, and listing them made the Queen skip this issue as a file conflict. The steward adds the ledger row and re-saves the seal when the PR merges.

Success Criteria

  • t27c spec-status specs/effects/sim_rand.t27 prints IMPLEMENTED
  • grep -c 'test "pcg32_reference_vectors"' specs/effects/sim_rand.t27 prints 1
  • grep -c '0xcbed606e' specs/effects/sim_rand.t27 prints 1

Boundary

  • specs/effects/sim_rand.t27

User Scenarios

  • Given a need for deterministic random number generation in simulation, When a developer seeds a PCG32 generator with initstate 42 and initseq 54, Then the first six outputs match the pcg32-demo reference vectors exactly.
  • Given two PCG32 generators initialized with the same seed, When both generate 100 values, Then the sequences are identical; and when initialized with different seeds, Then the first outputs differ.
  • Given the spec file specs/effects/sim_rand.t27 is implemented and passes t27b, When the expectations report is updated, Then docs/reports/t27b_expectations.json contains a passing row for that spec and max_not_pass is recounted.

Activity

  1. added
    P0Critical priority - must fix immediately
    on Oct 11, 2026
  2. tri-claw commented on Oct 11, 2026

    @tri-claw

    The Queen cannot take this issue yet. A bee starts only on an issue whose body has every section below, and this one lacks:

    • missing: ## Success Criteria -- an outcome a machine can settle: a number with a unit, a backticked file, exit 0, or a backticked command

    She tried to write them 2 times and could not (last: refused: still missing: ## Success Criteria). Add them and the next round takes it. The rule is specs/policy/issue_shape.t27.

  3. gHashTag commented on Oct 20, 2026

    @gHashTag
    CollaboratorAuthor

    lane done on playras-MacBook-Pro: branch claude/evolve-lane-9010-playras-MacBook-Pro, tests 2/2, 0 vacuous passes, reference vectors match. Seal and ledger row left to the steward per FR-004.

  4. gHashTag commented on Oct 20, 2026

    @gHashTag
    CollaboratorAuthor

    Re-filed as #11418 (newest first for the Queen).

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

    P0Critical priority - must fix immediatelyqueen-shaped

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions