Skip to content

fix(universe): close a live G2 blocklist gap — REAL_WORDS missed 43 real element names - #32

Open
MrReasonable wants to merge 2 commits into
mainfrom
fix-real-name-blocklist-gap
Open

fix(universe): close a live G2 blocklist gap — REAL_WORDS missed 43 real element names#32
MrReasonable wants to merge 2 commits into
mainfrom
fix-real-name-blocklist-gap

Conversation

@MrReasonable

@MrReasonable MrReasonable commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Summary

REAL_WORDS in crates/borbax-universe/src/naming.rs jumped from cerium
(Z=58) straight to tungsten (Z=74), silently dropping the whole
lanthanide run plus Z=75-77, Z=91, and everything from Z=95 onward — 43
real element names missing out of 118. The shipped generator could
therefore mint a fictional element and have is_real() report it clean.
Live on main today, independent of anything else in flight: reproduced
at seed 1631, ("Tu", "thulium").

Exhaustive enumeration of the naming grammar (four specialist reviewers,
independently) shows only 6 of the 118 real names are even producible by
the current grammar — thulium was the entire live exposure. The other 42
still belong in the blocklist: REAL_WORDS has a second consumer,
xtask's literal-content scan, which has no grammar constraint and would
flag any of the 118 hardcoded as a label or comment regardless of
reachability.

What changed

  • Added the 43 missing names to REAL_WORDS (and xtask's deliberately
    duplicated copy, which has its own consistency test).
  • Added an exhaustive test (every_name_the_grammar_can_produce_is_checked_against_the_blocklist)
    that checks the full grammar (22,880 productions) against is_real()
    directly — deterministic, complete, sub-millisecond.
  • Added a completeness test (the_blocklist_names_every_real_element)
    against an independent 118-entry reference array, with a distinctness
    check — a first draft only checked the array's length, which a
    duplicated-entry-hiding-a-dropped-one mutation passes silently.
    Demonstrated and fixed.
  • Reduced the probabilistic seed sweep from 20,000 to 2,000 seeds (measured
    identical discriminating power at ~10x less cost, since the grammar —
    checked exhaustively above — is what bounds reachable collisions, not
    the seed count), and fixed its examined counter to track
    Provenance::Generated specifically so it can detect the fallback path
    (Q{n}/quorium{n}, which never reaches is_real at all) going quiet.

Two rounds of /review-pr (4 specialists + CodeRabbit each round). Every
mutation this PR's own tests exist to catch was planted and confirmed
caught before landing:

  • Deleting thulium from REAL_WORDS alone → caught by the exhaustive test.
  • Deleting thulium from both REAL_WORDS and the reference oracle,
    hidden behind a duplicated neighbour (keeping the oracle's length at
    118) → caught by the new distinctness check.

CodeRabbit findings, investigated and not applied

  • "47 names missing, not 43" — verified wrong. Exact diff of the real
    REAL_WORDS before/after (138 − 95 = 43, cross-checked with comm) gives
    43. CodeRabbit's range-based approximation (Z=59..=77 + Z=91..=118)
    double-counts tungsten and the three actinides that were already
    present within those ranges.
  • "Remove the real-element dataset from this crate" (flagging the new
    test-only reference array as a G1 breach) — investigated by a dedicated
    specialist pass, which found existing project precedent that test
    fixtures may legitimately spell out real element names (a name is an
    identifier, not physics data), matching this file's own header
    justification for the pre-existing, analogous REAL_ELEMENT_SYMBOLS/
    REAL_WORDS constants, which are the canonical G2 enforcement mechanism.

Test plan

  • cargo fmt --all --check
  • cargo clippy --locked --workspace --all-targets -- -D warnings
  • cargo test --locked --workspace
  • cargo test --locked --workspace --release
  • RUSTDOCFLAGS=-Dwarnings cargo doc --locked --workspace --no-deps --document-private-items
  • cargo run --locked -p xtask
  • Both discriminating mutations planted and confirmed caught (above)
  • Two /review-pr rounds (determinism, emergence, rust-developer-expert, no-brief lane, CodeRabbit)

Summary by CodeRabbit

  • Bug Fixes
    • Improved generated-name filtering to recognize all 118 official chemical element names.
    • Prevented generated names from matching missing lanthanide and actinide element names.
    • Increased reliability across a broad range of generated names and random inputs.

…eal element names

REAL_WORDS jumped from cerium (Z=58) straight to tungsten (Z=74),
silently dropping the whole lanthanide run plus Z=75-77, Z=91 and
everything from Z=95 onward. The shipped generator could therefore
mint a fictional element named after a real one and have is_real()
report it clean — reproduced at 43 of the first 20,000 seeds, first
at seed 1631 ("Tu" / "thulium").

Neither pinned universe digest can see this class of regression:
both sweep seeds 0..64 only, and this collision doesn't occur until
seed 1631. `symbol`/`name` are mixed into the digest, so it correctly
reports "unchanged" while a much wider seed range ships a falsely-real
name.

Two new tests, not one — the empirical seed-sweep alone would have
shipped vacuous. A first draft checked minted names against is_real()
itself, and passed cleanly with the bug still present: mint() already
filters every candidate through is_real() before returning it, so
nothing mint() ever returns can fail an is_real()-based check. Fixed
to check against an independent reference list built from atomic
number, never from REAL_WORDS.

xtask keeps its own deliberately-duplicated copy of the blocklist
(so deleting the real one fails the build rather than the gate) —
updated in the same commit, in the same order, or its own
consistency test fails.

MrReasonable <4990954+MrReasonable@users.noreply.github.com>
…ness check, honest framing

Four specialists plus CodeRabbit reviewed the previous commit. Real,
corroborated findings, applied here:

- The completeness test only checked REAL_ELEMENT_NAMES.len(), never
  that its 118 entries are distinct. A duplicated line hiding a dropped
  one would pass silently — reproduced by hand, now caught by a
  BTreeSet distinctness assertion.
- The 20,000-seed sweep was probabilistic and ~1000x more expensive
  than necessary. Four reviewers independently enumerated the
  generator's full grammar (22,880 productions) and found only 6 of
  the 118 real names are producible at all — thulium was the entire
  live mint-time exposure; the other 42 matter for a different reason
  (xtask's literal-content scan, unconstrained by the grammar). Added
  an exhaustive test that checks the full grammar directly against
  is_real() — deterministic, complete, sub-millisecond — and reduced
  the seed sweep to 2,000 (measured: identical discriminating power to
  20,000, since the grammar is what bounds reachable collisions).
- The commit message and doc comments overstated the live scope
  ("43 of 20,000 seeds") when only one name was ever reachable, and
  had an internal inconsistency (78 vs 43 vs 118 don't reconcile —
  the correct pre-fix coverage figure is 75). Corrected throughout.
- The sweep's examined counter tracked every mint attempt rather than
  Provenance::Generated specifically, so it couldn't detect the
  fallback path (which never reaches is_real at all) going quiet.
  Fixed to count generated draws, matching the project's own
  "probe the guard's bookkeeping" discipline.
- Dropped an unneeded to_ascii_lowercase() allocation — mint's
  generated path is lowercase by construction.

Both new mutations probed directly: deleting thulium from REAL_WORDS
alone is caught by the exhaustive test; deleting it from both
REAL_WORDS and the oracle (hidden behind a duplicate, keeping the
oracle's length at 118) is caught by the new distinctness check.

CodeRabbit flagged the new REAL_ELEMENT_NAMES test array as a G1
breach; the emergence-auditor's independent analysis found existing
project precedent (test fixtures may legitimately spell out real
element names, since a name is an identifier, not property data) and
the same reasoning already documented in this file's own header for
the pre-existing, analogous REAL_WORDS/REAL_ELEMENT_SYMBOLS constants.
CodeRabbit's factual claim that 47 names were missing (not 43) was
independently verified wrong: exact diff of the old and new REAL_WORDS
gives 43.

MrReasonable <4990954+MrReasonable@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The runtime and copied element-name blocklists now include all 118 elements. Tests validate completeness, uniqueness, grammar rejection, and generated names across 2,000 seeds.

Changes

Element-name exclusion coverage

Layer / File(s) Summary
Complete element blocklists
crates/borbax-universe/src/naming.rs, xtask/src/main.rs
Both blocklists now include the missing element names from praseodymium through oganesson.
Element-name validation
crates/borbax-universe/src/naming.rs
Tests use an independent 118-name oracle, verify blocklist completeness and uniqueness, exhaustively check grammar-produced names, and sweep 2,000 seeds without fallback provenance.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the fix to the REAL_WORDS blocklist and the 43 missing real element names.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-real-name-blocklist-gap

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/borbax-universe/src/naming.rs`:
- Around line 88-106: Remove all added real element names from REAL_WORDS in
crates/borbax-universe/src/naming.rs at lines 88-106 and 120-147, and delete the
hardcoded real-element oracle from the test module at lines 333-474. Ensure the
crate contains no real chemistry data while preserving the remaining naming
behavior and tests.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 40407538-38e3-405d-9159-4654c44f7b5b

📥 Commits

Reviewing files that changed from the base of the PR and between cb3a28c and 9280ad7.

📒 Files selected for processing (2)
  • crates/borbax-universe/src/naming.rs
  • xtask/src/main.rs

Comment on lines +88 to +106
"praseodymium",
"neodymium",
"promethium",
"samarium",
"europium",
"gadolinium",
"terbium",
"dysprosium",
"holmium",
"erbium",
"thulium",
"ytterbium",
"lutetium",
"hafnium",
"tantalum",
"tungsten",
"rhenium",
"osmium",
"iridium",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift

Remove real chemistry data from crates/borbax-universe.

The runtime blocklist and test oracle share one root cause: both hardcode real element data in a prohibited crate.

  • crates/borbax-universe/src/naming.rs#L88-L106: remove the added real element names from REAL_WORDS.
  • crates/borbax-universe/src/naming.rs#L120-L147: remove the added real element names from REAL_WORDS.
  • crates/borbax-universe/src/naming.rs#L333-L474: remove the hardcoded real-element oracle from the test module.

As per coding guidelines, crates/{borbax-universe,borbax-molecule,borbax-reaction}/**/* must not include “real chemistry data, element tables, reaction databases, molecular structures, sequence data, or real-world mapping/calibration data.”

📍 Affects 1 file
  • crates/borbax-universe/src/naming.rs#L88-L106 (this comment)
  • crates/borbax-universe/src/naming.rs#L120-L147
  • crates/borbax-universe/src/naming.rs#L333-L474
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/borbax-universe/src/naming.rs` around lines 88 - 106, Remove all added
real element names from REAL_WORDS in crates/borbax-universe/src/naming.rs at
lines 88-106 and 120-147, and delete the hardcoded real-element oracle from the
test module at lines 333-474. Ensure the crate contains no real chemistry data
while preserving the remaining naming behavior and tests.

Source: Coding guidelines

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.

1 participant