Files
suaveplan/openspec/archive/2026-04-19-enterprise-random-family/tasks.md
2026-05-27 23:29:53 +01:00

5.8 KiB

Closed 2026-04-19 — all tasks landed.

Tasks: enterprise-random-family

Pre-work

  • 1. Add catalog entries to root package.json (if not already present from crypto-family): no new external deps needed for pseudo-random or random; noise needs none either

Wave 1 — @suaveplan/pseudo-random (no workspace deps beyond error + types)

  • 2. Scaffold packages/universal/pseudo-random: package.json (deps: @suaveplan/error, @suaveplan/types, tslib, zod), tsconfig.lib.json, vite.config.ts, vitest.config.ts (100% thresholds)
  • 3. errors/: PseudoRandomError, PRNG_CODES
  • 4. seed/normalize.ts + test + md: normalizeSeed(seed: string | number): number — splitmix64 mixing, rejects NaN/Infinity/non-safe-int
  • 5. types/seeded-rng.types.ts + md: SeededRng interface, RngCheckpoint
  • 6. algorithms/mulberry32.ts + test + md: implements SeededRng; byte-identical to @suaveplan/testing inline impl
  • 7. algorithms/sfc32.ts + test + md: 128-bit state, 12 warmup rounds; byte-identical to bingo BulletproofPRNG (SFC32 mode)
  • 8. algorithms/xoshiro256.ts + test + md: 256-bit state, algebraic jump for 2^128 and 2^192
  • 9. algorithms/counter-rng.ts + test + md: splitmix64 hash counter, O(1) at(offset)
  • 10. Verify all SeededRng shared behaviours: fork, checkpoint/restore, at returns new instance, skip mutates self
  • 11. utils/shuffle.ts + test + md: shuffle, shuffleInPlace
  • 12. utils/sample.ts + test + md: sample, weightedChoice
  • 13. constants/index.ts; barrel src/index.ts; subpath exports in package.json
  • 14. fast-check property tests: determinism, fork independence (10k samples, correlation < 0.01), checkpoint round-trip
  • 15. mitata benchmarks: nextUint32 throughput for each algorithm
  • 16. tests/no-disallowed.test.ts (no Math.random, crypto.getRandomValues in src/); tests/tree-shake.test.ts
  • 17. README.md
  • 18. bunx turbo lint typecheck test:coverage --filter=@suaveplan/pseudo-random --force → green at 100%
  • 19. bun scripts/publish.ts --package @suaveplan/pseudo-random

Wave 2 — @suaveplan/random (depends on types + error; pseudo-random optional peer)

  • 20. Scaffold packages/universal/random: package.json (deps: @suaveplan/types, @suaveplan/error, tslib, zod), configs, 100% thresholds
  • 21. errors/: RandomError, RANDOM_CODES
  • 22. source/crypto-rng.ts + test + md: cryptoRng() factory — single crypto.getRandomValues callsite
  • 23. source/default-rng.ts + test + md: getDefaultRng, setDefaultRng
  • 24. bytes/random-bytes.ts + test + md
  • 25. numbers/random-int.ts + test + md; numbers/random-float.ts + test + md
  • 26. strings/random-string.ts + test + md: all 8 presets + custom charset, mutual-exclusion validation
  • 27. ids/uuid.ts + test + md: v4 + v7 (monotonic sequence counter within same ms)
  • 28. ids/uuid.ts (cont.): randomULID, randomNanoid
  • 29. collections/shuffle.ts + sample.ts + choice.ts + weighted.ts + tests + mds
  • 30. objects/random-key.ts + random-value.ts + random-entry.ts + random-subset.ts + tests + mds
  • 31. game/dice.ts + test + md: coin, dice, roll
  • 32. distributions/continuous/normal.ts + test + md (Box-Muller)
  • 33. distributions/continuous/log-normal.ts, exponential.ts, gamma.ts (Marsaglia-Tsang + Ahrens-Dieter), beta.ts + tests + mds
  • 34. distributions/continuous/pareto.ts, weibull.ts, cauchy.ts, logistic.ts + tests + mds
  • 35. distributions/discrete/bernoulli.ts, geometric.ts, binomial.ts, poisson.ts (Knuth + rejection) + tests + mds
  • 36. distributions/sampler.ts + test + md: DistributionConfig, createSampler, sample
  • 37. fast-check: mean/variance within 5% of theoretical values for each distribution at 10k samples
  • 38. DistributionConfig JSON round-trip test for all distribution types
  • 39. constants/index.ts; barrel src/index.ts; subpath exports
  • 40. tests/no-disallowed.test.ts (no Math.random, crypto.getRandomValues outside src/source/crypto-rng.ts); tests/tree-shake.test.ts
  • 41. mitata benchmarks: randomInt, shuffle(1000), normal sampler throughput
  • 42. README.md
  • 43. bunx turbo lint typecheck test:coverage --filter=@suaveplan/random --force → green at 100%
  • 44. bun scripts/publish.ts --package @suaveplan/random

Wave 3 — @suaveplan/noise (independent, only needs error)

  • 45. Scaffold packages/universal/noise: package.json (deps: @suaveplan/error, tslib), configs, 100% thresholds
  • 46. errors/: NoiseError, NOISE_CODES
  • 47. perlin/perlin.ts + test + md: perlin2, perlin3
  • 48. simplex/simplex.ts + test + md: simplex2, simplex3, simplex4
  • 49. value/value.ts + test + md: value2, value3
  • 50. worley/worley.ts + test + md: worley2, worley3, WorleyMode
  • 51. fbm/fbm.ts + test + md: fbm2, fbm3, FbmOptions
  • 52. blue/blue.ts + test + md: blueNoiseSample, Bridson's algorithm, maxSamples guard
  • 53. constants/index.ts; barrel src/index.ts; subpath exports
  • 54. fast-check: determinism + output range [-1,1] (or [0,1] for Worley) for all functions
  • 55. mitata benchmarks: each function at 1k and 100k evaluations
  • 56. tests/tree-shake.test.ts
  • 57. README.md
  • 58. bunx turbo lint typecheck test:coverage --filter=@suaveplan/noise --force → green at 100%
  • 59. bun scripts/publish.ts --package @suaveplan/noise

Close-out

  • 60. Update CLAUDE.md package listing and counts for all 3 new packages
  • 61. Update PACKAGES.yml / STRUCTURE.yml
  • 62. Archive openspec/changes/enterprise-random-family/ → openspec/archive/2026-04-18-enterprise-random-family/