Skip to content

Harden UUIDv7 custom RNG guidance#75

Merged
dexcompiler merged 3 commits into
mainfrom
codex/72-uuidv7-rng-guidance
May 15, 2026
Merged

Harden UUIDv7 custom RNG guidance#75
dexcompiler merged 3 commits into
mainfrom
codex/72-uuidv7-rng-guidance

Conversation

@dexcompiler
Copy link
Copy Markdown
Owner

Summary

  • document the UuidV7Factory custom RNG contract in XML docs, README, the UUIDv7 guide, and changelog
  • add C# tests showing same-seed deterministic replay and derived deterministic streams for independent test nodes
  • add an F# property proving deterministic RNG replay for same seed/time/call pattern
  • replace HashCode.Combine in deterministic RNG derivation with a stable explicit integer mixer for replayable derived streams
  • make the UUIDv7 demo call out that deterministic RNG injection is for tests/simulations, not production UUID issuance

Why

UuidV7Factory accepts a caller-provided RandomNumberGenerator for deterministic testing and simulation replay. That capability is valuable, but identical deterministic RNG state plus identical time and call patterns intentionally reproduces UUID output. The production path should remain rng: null or an independent CSPRNG per factory.

Validation

  • dotnet test tests/Clockworks.Tests.csproj --filter UuidV7FactoryTests -v minimal
  • dotnet test property-tests/Clockworks.PropertyTests.fsproj --filter "Deterministic RNG replays UUID sequence" -v minimal
  • dotnet test Clockworks.sln -v minimal -m:1
  • DOCS_VERSION=dev npm run docs:build

Fixes #72

@dexcompiler dexcompiler marked this pull request as ready for review May 14, 2026 22:32
@dexcompiler dexcompiler changed the title [codex] Harden UUIDv7 custom RNG guidance Harden UUIDv7 custom RNG guidance May 14, 2026
@dexcompiler
Copy link
Copy Markdown
Owner Author

@codex[agent] review this pr

@chatgpt-codex-connector
Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

Co-authored-by: dexcompiler <115876036+dexcompiler@users.noreply.github.com>
@Codex
Copy link
Copy Markdown
Contributor

Codex AI commented May 14, 2026

@codex[agent] review this pr

Reviewed; added follow-up commit 16e1fa4 to (1) remove brittle claims about System.Random’s internal algorithm in deterministic RNG XML docs, (2) fix the stray // <summary> in the demo RNG, and (3) update the UUIDv7 guide snippet to avoid referencing a non-library DeterministicRandomNumberGenerator type. Targeted UUIDv7 replay tests still pass.

@dexcompiler
Copy link
Copy Markdown
Owner Author

Verification after remote commit 16e1fa4:

  • Reviewed the commit contents. The changes are good: removing claims about System.Random internals is more accurate, fixing the demo XML summary marker is correct, and the docs snippet is better because it no longer implies Clockworks ships a public deterministic RNG type.
  • I do not see a more performant or lower-allocation replacement needed for this PR. The production UuidV7Factory path is untouched. The stable seed mixer remains allocation-free, and the deterministic RNG/helper allocations are test/demo-only.
  • Re-ran targeted and full local validation:
    • dotnet test tests/Clockworks.Tests.csproj --filter UuidV7FactoryTests -v minimal
    • dotnet test property-tests/Clockworks.PropertyTests.fsproj --filter "Deterministic RNG replays UUID sequence" -v minimal
    • dotnet test Clockworks.sln -v minimal -m:1
    • DOCS_VERSION=dev npm run docs:build
  • Adjacent issue found during verification: one full FsCheck run exposed a VectorClock zero-counter canonicalization edge case unrelated to this PR. I filed it separately as Property: canonicalize or exclude zero-counter VectorClock entries #76 rather than mixing it into the UUIDv7 RNG guidance work.

Conclusion: #75 looks good from my side; no additional PR changes needed from this verification pass.

@dexcompiler dexcompiler merged commit c68b938 into main May 15, 2026
6 checks passed
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.

Docs/Test: harden custom RNG guidance for UUIDv7 collision safety

2 participants