Skip to content

chore: add missing rng and factory keywords to random/base PRNGs#13095

Draft
Planeshifter wants to merge 5 commits into
developfrom
philipp/drift-random-base-2026-06-24
Draft

chore: add missing rng and factory keywords to random/base PRNGs#13095
Planeshifter wants to merge 5 commits into
developfrom
philipp/drift-random-base-2026-06-24

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request corrects two package.json keywords drift findings in @stdlib/random/base, surfaced by majority-vote analysis across all 43 direct child packages. Five packages were missing one or both of the convention keywords rng and factory despite implementing the relevant pattern; the omissions are normalized to the sibling convention. Metadata only; no source, test, or behavioral change.

Namespace summary

  • Target namespace: @stdlib/random/base
  • Member count: 43 non-autogenerated direct child packages.
  • Features analyzed: file tree, package.json top-level / scripts / directories / keywords shape, README ## / ### heading list, manifest.json shape, test/ / benchmark/ / examples/ filenames, public signatures, returnKind, validation prologue (via direct read of every lib/validate.js, lib/factory.js, and lib/main.js), error construction, JSDoc shape, require()-derived dependencies.
  • Features with a clear majority (≥75%): package.json top-level key set (18 keys, 100%); directories.{benchmark,doc,example,lib,test} (100%); main = './lib', types = './docs/types', engines, os (100%); 8 universal keywords (stdlib, stdmath, mathematics, math, statistics, stats, seed, seedable — each 41/43, omitted only by reviver/shared); pseudorandom/generator (42/43); rng (40/43 = 93.0%); factory (36/43 = 83.7%); lib/factory.js presence (41/43, omitted only by reviver/shared); error construction = format (100% of the 41 packages that throw — reviver/shared perform no validation); the canonical README sequence ## Usage## Notes## Examples## See Also (41/43, omitted only by reviver/shared).
  • Features without a clear majority (excluded): native-bindings file group (manifest.json, binding.gyp, include/, src/, lib/native.js) at 7/43 = 16.3% (tied to whether a package has a C addon, not drift); references README sub-section (10/43 = 23.3%, content-driven); per-package keyword tails (distribution-specific naming).

Per outlier package

random/base/minstd

Adds rng and factory to the keywords array. The package implements the Park-Miller LCG and ships lib/factory.js exposing a factory() constructor matching the sibling convention, yet was absent from the 93.0% of siblings tagged rng and the 83.7% tagged factory. Insertion follows randu: rng between prng and pseudorandom, factory appended after seedable.

random/base/minstd-shuffle

Adds rng and factory to the keywords array. The package is a Park-Miller LCG with Bays-Durham shuffle and ships lib/factory.js, but was missing from both the 93.0% rng cohort and the 83.7% factory cohort. Insertion mirrors randu.

random/base/mt19937

Adds rng and factory to the keywords array. This is the canonical 32-bit Mersenne Twister backing every sibling factory() as the default PRNG, so its omission from the 93.0% rng cohort and 83.7% factory cohort was the most conspicuous gap in the namespace. Insertion follows randu: rng between prng and pseudorandom, factory after seedable.

random/base/box-muller

Adds factory to the keywords array. The package generates normally distributed values via the Box-Muller transform and ships lib/factory.js with the standard factory() constructor, placing it among the 5 outliers excluded from the 83.7% sibling cohort. factory is appended after the existing trailing keyword.

random/base/improved-ziggurat

Adds factory to the keywords array. The package generates normally distributed values via the improved Ziggurat method and ships lib/factory.js with the standard factory() constructor, leaving it among the 5 outliers excluded from the 83.7% sibling cohort. factory is appended after the existing trailing keyword.

Related Issues

Does this pull request have any related issues?

No.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Validation

Checked:

  • Structural feature extraction (file tree, package.json shape, README headings, manifest.json shape, test//benchmark//examples/ filenames) across all 43 members.
  • Semantic feature extraction (error construction, validation prologues, lib/factory.js presence and shape) across all 43 members by direct read of lib/main.js, lib/factory.js, and lib/validate.js.
  • Cross-run dedup against open and recently merged PRs in this repository: no open or recent PR proposes either keyword change to any of the five packages. Open PRs touching random/base (fix: widen seed/state types in random/base/randi #12568 randi TypeScript decl widening; docs: fix TSDoc errors and inconsistencies in random TypeScript declarations #12571 random-namespace TSDoc fixes; feat: add random/base/tinymt32 #6177 / feat(random): add a new pseudorandom number generator random/base/xorshift32 #6333 / feat(random): add a new pseudorandom number generator random/base/pcg32 #6551 / feat: add xorshift32 pseudorandom number generator #10343 / feat: xorshift128plus pseudorandom generator #11089 new-PRNG additions) are disjoint from this run's outlier set.
  • Three-agent drift validation (run in parallel against all seven (correction, package) pairs):
    • opus semantic-review — confirmed each omission is unintentional drift relative to the sibling convention, not a semantic distinction. The three rng-cohort omitters (minstd, minstd-shuffle, mt19937) share an older template that predates the rng-keyword convention used by every other PRNG in the namespace; the five factory-cohort omitters all ship lib/factory.js and expose a factory() matching randu.
    • opus cross-reference — confirmed no test, example, or downstream consumer relies on the current keyword shape. The _tools consumers of package.json keywords (the package-search lunr index in _tools/search/pkg-index, the namespace-TOC filter in _tools/markdown/namespace-toc, and the published-package GitHub-topics mapper in _tools/scripts/publish_packages) all treat the array additively. All additions satisfy the package-json/schema keyword regex and remain unique within each array.
    • sonnet structural-review — confirmed the conformance counts (rng 40/43, factory 36/43) and that the majority pattern is what should be applied. The two packages excluded from the factory cohort that are NOT outliers (reviver, shared) genuinely lack lib/factory.js and are correctly excluded.

Deliberately excluded:

  • Sibling random/base/reviver and random/base/shared — missing rng, factory, pseudorandom, generator, lib/factory.js, benchmark/benchmark.js, examples/index.js, and the canonical README sequence. These are infrastructure packages (a JSON reviver and a shared-API module respectively); the omissions reflect their genuinely different purpose and are intentional deviations rather than drift.
  • directories.include / directories.src split (35/43 vs 7/43) — tied to whether a package has a native C addon, not drift.
  • Per-package keyword tails (distribution-specific terminology like lognormal, gumbel, weibull) — local to each package's subject matter; not drift candidates.
  • README ## References section (10/43 = 23.3% prevalence) — content-driven, no clear majority.

A local report with the full audit trail (feature distributions, dropped candidates and rationale, namespace random seed) lives at ~/drift-reports/drift-random-base-2026-06-24.md.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

This PR was authored by Claude Code running as a scheduled cross-package drift-detection routine targeting @stdlib/random/base. Structural and semantic features were extracted across all 43 namespace members, deviations from the ≥75% majority pattern were surfaced, and three independent reviewer agents (opus semantic-review, opus cross-reference, sonnet structural-review) validated each candidate fix as confirmed-drift/confirmed-safe in parallel before any file was edited. All edits are pure package.json keywords additions; no source, test, behavioral, doc, or generator output is touched. A human will audit and promote this PR out of draft.


@stdlib-js/reviewers


Generated by Claude Code

claude added 5 commits June 24, 2026 00:13
Adds the `rng` keyword (present in 40/43 = 93.0% of `random/base`
siblings; the three omitters are this package, `minstd-shuffle`, and
`mt19937`) and the `factory` keyword (present in 36/43 = 83.7% of
`random/base` siblings; this package ships `lib/factory.js` and exposes
the same factory pattern as `randu`, which carries the keyword).
Metadata only; no source or behavioral change.
Adds the `rng` keyword (40/43 = 93.0% sibling conformance in
`random/base`) and the `factory` keyword (36/43 = 83.7% conformance;
this package ships `lib/factory.js`). Same drift class as sibling
`minstd`. Metadata only; no source or behavioral change.
Adds the `rng` keyword (40/43 = 93.0% sibling conformance in
`random/base`) and the `factory` keyword (36/43 = 83.7% conformance;
this package ships `lib/factory.js` and is the canonical MT19937
generator referenced by sibling PRNGs that already carry both keywords).
Metadata only; no source or behavioral change.
Adds the `factory` keyword (present in 36/43 = 83.7% of `random/base`
siblings). This package ships `lib/factory.js` and exposes a
`factory()` method matching the sibling convention; only the keyword
advertisement was missing. Metadata only; no source or behavioral
change.
Adds the `factory` keyword (present in 36/43 = 83.7% of `random/base`
siblings). This package ships `lib/factory.js` and exposes a
`factory()` method matching the sibling convention; only the keyword
advertisement was missing. Metadata only; no source or behavioral
change.
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
random/base/box-muller $\\color{green}563/563$
$\\color{green}+100.00\\%$
$\\color{green}50/50$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}563/563$
$\\color{green}+100.00\\%$
random/base/improved-ziggurat $\\color{green}647/647$
$\\color{green}+100.00\\%$
$\\color{green}57/57$
$\\color{green}+100.00\\%$
$\\color{green}13/13$
$\\color{green}+100.00\\%$
$\\color{green}647/647$
$\\color{green}+100.00\\%$
random/base/minstd-shuffle $\\color{green}752/752$
$\\color{green}+100.00\\%$
$\\color{green}78/78$
$\\color{green}+100.00\\%$
$\\color{green}14/14$
$\\color{green}+100.00\\%$
$\\color{green}752/752$
$\\color{green}+100.00\\%$
random/base/minstd $\\color{green}627/627$
$\\color{green}+100.00\\%$
$\\color{green}68/68$
$\\color{green}+100.00\\%$
$\\color{green}12/12$
$\\color{green}+100.00\\%$
$\\color{green}627/627$
$\\color{green}+100.00\\%$
random/base/mt19937 $\\color{green}913/913$
$\\color{green}+100.00\\%$
$\\color{green}88/88$
$\\color{green}+100.00\\%$
$\\color{green}15/15$
$\\color{green}+100.00\\%$
$\\color{green}913/913$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

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.

3 participants