pkg:clod/com.clodhub/fair-shuffle 0.11.0 Random numbers behind one interface: a seeded generator that tests can replay, a crypto-backed generator for play, and a Fisher-Yates shuffle over either. Games need two kinds of randomness: unpredictable for real play, and repeatable for tests and replays. This component gives both behind one `RandomSource` (next, int, shuffle, pick). `secure` reads the platform's cryptographic generator; `seeded` runs Mulberry32 from a number or text seed so the same seed always gives the same sequence on every platform. The shuffle is Fisher-Yates over whichever source is injected. Examples A test run seeds the source with the test name and expects the same deal every time. A live room uses the secure source. A support engineer replays a disputed deal by recording the seed. Package URL: pkg:clod/com.clodhub/fair-shuffle@0.11.0 Class: Fair shuffle (pkg:clod/com.clodhub/fair-shuffle-class@1.1.0): Uniform shuffles and random choices from a cryptographic or seeded source. Any component of this class can fill a recipe slot that asks for it. Category games/randomness; https://clodhub.com/classes/fair-shuffle-class.txt; 0 other components of this class: https://clodhub.com/components.txt?class=pkg%3Aclod%2Fcom.clodhub%2Ffair-shuffle-class Provides (1) - random-source (com.clodhub/random-source 1.0.0): Random numbers behind one interface: a seeded generator (Mulberry32) tests can replay, and a source backed by the platform's cryptographic generator. TypeScript, `implementation/server/random.ts`. Methods named `RandomSource.` are members of the object the factories return. components that use it: https://clodhub.com/components.txt?requires=com.clodhub%2Frandom-source Requires (0) - none Settings (2) The installer collects two settings. `source` is `secure` (default, for play) or `seeded` (for replayable runs and tests). `seed` is the text used when `source` is `seeded`; as an installer setting it is a label (letters, digits, spaces and hyphens, starting with a letter, such as `replay-7`) and is turned into a number by `seedFromText`; code may also pass a number; a seeded source without a seed is refused. - source: string (slug); optional, default "secure" - seed: string (label); optional, no default Depends on components: none How to use in a recipe A recipe uses it through a slot of class Fair shuffle (pkg:clod/com.clodhub/fair-shuffle-class 1.1.0), naming pkg:clod/com.clodhub/fair-shuffle as the slot's preferred component or substituting it for another component of the class. The recipe connects what it provides (random-source) to the slots that use it. The recipe sets source and seed; any it leaves out takes its default. - as a slot in recipe.json components: {"id":"fair-shuffle","class":{"name":"pkg:clod/com.clodhub/fair-shuffle-class","version":"1.1.0","digest":"2512dd98a1468fe8f98ec8e83c9974a989c2f7266eb4362874af8ad611db8cb7"},"preferred":{"name":"pkg:clod/com.clodhub/fair-shuffle","version":"0.11.0"}} - in place of another component of the class: clod fetch fair-shuffle@0.11.0 --store store --from https://clodhub.com, then clod design RECIPE@VERSION --store store --answers answers.json --substitute SLOT=fair-shuffle@0.11.0 --out definition.json Used by recipes: pkg:clod/com.clodhub/ourpoker-recipe 0.13.0 (slot fair-shuffle) For developers: how an application uses it Code that needs randomness takes a `RandomSource` as an argument and never calls `Math.random`. The game engine's `rng: () => number` becomes `source.next`; a function-style generator is wrapped with `sourceFrom`. `card-deck` requires this interface and shuffles through `source.shuffle`. Single platform: server TypeScript. The file uses only standard globals (`crypto`), so it also runs unchanged in a browser, but only the server copy is installed. Accounts and services No deployed service and no accounts. The secure source needs the platform's `crypto.getRandomValues` (Node 20 or later, Workers, browsers). How it is checked `tests/web.test.ts` checks the Mulberry32 reference sequence, replay by seed, shuffle permutation and input immutability, uniformity over all six orders of three items, bounds and error handling, and the secure source with an injected generator and the real one. Also checks that a label-style seed replays the same deal and that the source's `shuffle(items)` works detached, as card-deck calls it. - `node --test tests/web.test.ts` (web, required-local; tools: node 26.5) Updates Patch updates replace the files only. The sequence produced by a given seed is part of the contract: a change to it is a new major version. Removing the component leaves callers without a random source, so supply another `random-source`. Tags: fair, games, randomness, shuffle Targets: client none; server none Publisher: George McIntyre (george-mcintyre) Guardians: Level N Ltd (guardian key 08775f20) Source: clodhub/fair-shuffle release v0.11.0; digest sha256:62ed6b9d57f7570fe6d6860b67c0cee714161d24473db059cbacfade9c8bf01a Release: features Line 0.11: no security releases Quality: Integration-tested, certified Known vulnerabilities: none known (checked 2026-11-26 at OSV); https://clodhub.com/api/components/fair-shuffle/0.11.0/vulnerabilities Downloads: 1 in 30 days; 1 of this version Classes: https://clodhub.com/classes.txt; this component as JSON: https://clodhub.com/api/components/fair-shuffle/0.11.0 Bundle download: GET https://clodhub.com/api/components/fair-shuffle/0.11.0/bundle returns a link valid for one hour Implements: pkg:clod/com.clodhub/fair-shuffle-class@1.1.0 2512dd98a1468fe8f98ec8e83c9974a989c2f7266eb4362874af8ad611db8cb7 com.clodhub/random-source 1.0.0 entry modules: server server/index.ts shared behaviour suites: shared Platforms: server Toolchains: node >=26.5.0 <27.0.0 Frameworks: none Styles: scope none; 0 namespaces; 0 conflicts Licence: Apache-2.0; 0 upstream sources, 0 exact dependencies, 22 files (listed on the details page) Suitable for jobs: fair-shuffle profile any: cost none; load none; regions any; compliance none Notes: Pure library; no provider limits apply. The secure source relies on the host's cryptographic generator. Data migration: this component keeps no data Maintainers: Level N Ltd; https://github.com/clodhub/fair-shuffle/issues; updates https://github.com/clodhub/fair-shuffle/releases (manual) What you download fair-shuffle-0.11.0.tar, from release v0.11.0 of clodhub/fair-shuffle: 22 files - Documents and manifests (8): CONTRACT.md, INSTRUCTIONS.md, LICENCE, NOTICE, PROVENANCE.md, SOURCE.md, ... - Source code (2): server/ (2) - Tests (2): fixtures/ (1), web.test.ts - Interface documents (1): random-source.json - Class files: the class's interfaces and shared checks (3): fair-shuffle-class/ (3) - Examples (1): consumer.ts - Diagrams (5): definition.json, examples/ (1), output/ (3) Installing copies 2 of them into the application under components/fair-shuffle/: server 2 Not included: the values of its settings, which the recipe writes; any secret The archive is a release file on the publisher's public GitHub repository; ClodHub keeps this page and a pointer to the release, not the code. clod checks the archive's sha256 fingerprint before anything is copied, and installing runs none of the package's code. Versions - 0.11.0 features (2026-11-26T11:26:34.361Z) sha256:62ed6b9d57f7570fe6d6860b67c0cee714161d24473db059cbacfade9c8bf01a Links Details (package foundations, upstream sources, exact dependencies, styles, class inventories, files): https://clodhub.com/components/fair-shuffle/details.txt?version=0.11.0 Page: https://clodhub.com/components/fair-shuffle; JSON: https://clodhub.com/api/components/fair-shuffle/0.11.0; connections diagram: https://clodhub.com/api/components/fair-shuffle/0.11.0/connections.svg Copyright Level N Ltd 2026