Repository navigation
refactor(pfft): share the cloud draw sequence from published src - #384
Conversation
Move the LCG, the 400-per-1 000 mm³ density rule and the bar draw loop into src/pfft/cloud_draws.rs, a dependency-free file inside the packaged `src/**/*.rs` include. The library's `#[cfg(test)]` `profile::cloud` declares it with `#[path]` at near.rs's file level (outside `mod profile`, where the path resolves against src/pfft/), and benches/support.rs includes it inward and re-exports `lcg`, `cloud_side` and `COPPER`, so tests/pfft.rs keeps working untouched. The multiplier and the density rule each drop to exactly one site, dissolving the "must stay byte-for-byte equivalent" invariant instead of checking it. Closes #372
|
PR #384's |
|
✅ Approved! A refactor that deletes an invariant instead of checking it, implementing the What I verified independently1. The draw sequences are bit-identical — measured, not inferred. This is This is a stronger oracle than the checksum it replaces: it compares all 2. Packaging — the architectural justification holds end-to-end. This is That last line is the part worth stating plainly: the 3. Single-definition AC — exactly one hit each, as claimed.
4. No public API change. 5. Test Execution
The final AC row was
Non-blocking, trivial — a doc reference that is now wrong
The loose reference is inherited from the old Scope note (not a defect)Sharing Merge state |
|
PR #384's |
|
Champion Auto-Merge This PR meets all safety criteria for automatic merging:
Proceeding with merge... If this was merged in error, you can revert with: Automated by Champion role |
Summary
Dissolves the "must stay byte-for-byte equivalent" invariant between
profile::cloud(fasterhenry/src/pfft/near.rs) andsupport::cloud(
fasterhenry/benches/support.rs) by deleting the second copy instead ofchecking it: the draw sequence (LCG, the 400-per-1 000 mm³ density rule,
the bar loop,
COPPER) now lives in one file,src/pfft/cloud_draws.rs,which both sides read — the library via a
#[cfg(test)]#[path]includeat
near.rsfile level, the bench suite via an inward#[path]includefrom
benches/support.rswith re-exports. This is the curation'srecommended approach (Hermit's suggestion, compile-verified during
curation), not the golden-digest fallback.
The include direction is what makes it publishable:
cloud_draws.rsisinside the manifest's
include = ["src/**/*.rs"], so it ships in thetarball while
benches/— the includer — does not, turning #364 step 4'spackaging objection around (that objection was direction-specific: a
#[path]out of publishedsrc/intobenches/).Changes
fasterhenry/src/pfft/cloud_draws.rs(new) — the shared drawsequence:
COPPER,lcg,cloud_side,Bar { a, b, width, height }(plain numbers) and
bars(n, side, manhattan, seed). Nocrate::/fasterhenry::paths and nocfgattributes of its own, so the samebytes compile in the lib test build and in
harness = falsebenchcrates.
fasterhenry/src/pfft/near.rs— declares#[cfg(test)] #[path = "cloud_draws.rs"] mod cloud_draws;at the file'sown level (outside
mod profile, where the path resolves againstsrc/pfft/— the load-bearing placement from the curation); dropsprofile's privateconst COPPER; rewritesprofile::cloudas a mapover
bars; replaces the "must stay byte-for-byte equivalent … nothingchecks that they do" doc comment with one describing the shared file.
fasterhenry/benches/support.rs— includes the shared file inwardwith
#[path = "../src/pfft/cloud_draws.rs"], re-exportslcg/cloud_side/COPPER(folding the constant in per the guidance'soptional step 5), rebuilds
random_setfrombars, and updates themodule and
clouddoc comments that pointed atprofile::cloudas "theone copy that cannot read this definition".
fasterhenry/tests/pfft.rs— deliberately untouched: the re-exportskeep its
use support::{cloud_side, lcg, random_set};working as-is.Acceptance Criteria Verification
grep -rn "6_364_136_223_846_793_005"andgrep -rn "400\.0)\.cbrt()"overfasterhenry/src,benches/support.rs,tests/pfft.rseach return exactly one hitfasterhenry/src/pfft/cloud_draws.rs:40/:54. Excluded-by-scope sites (benches/kernels.rs,tests/inductance.rs) untouched.cargo test -p fasterhenry --test pfftgreen1e-6accuracy bounds are seed- and draw-order-sensitive. AdditionallyFASTERHENRY_PROFILE_N=200 … --lib pfft::near::profile -- --ignored --nocaptureran to completion with checksum1.6067308777704494e0, bit-identical to the checksum the curation observed on unmodified main.cargo package -p fasterhenrysucceeds;cargo test --no-runbuilds inside the extracted tarball (empty[workspace]added)cargo packagegreen;tar tzfshowssrc/pfft/cloud_draws.rspresent and zerobenches/entries; extracted, appended[workspace],cargo test --no-runinside — green (8.16s).#[doc(hidden)] pubAPI#[cfg(test)]module insidenear.rs, absent from the non-test build; #359 untouched.near.rsdoc comment replaced by a note describing the shared filecloud_draws.rsas the one file both sides read.cargo test --workspace+cargo clippy --workspace --all-targets -- -D warningsgreen on all three CI platformscargo clippy --workspace --all-targets -- -D warningsgreen andcargo fmt --all --checkclean. The three-platform run (ubuntu-latest,ubuntu-24.04-arm,macos-latest) is the PR's own CI run — pending at PR creation; nothing is hashed, so nocbrtbit-stability argument is needed.Test Plan
cargo check -p fasterhenry --all-targets— green (lib, lib-test, allfive benches, all integration tests).
cargo clippy --workspace --all-targets -- -D warnings— green.cargo fmt --all --check— clean.cargo test -p fasterhenry --test pfft— 14 passed / 0 failed / 1ignored; both
random_setbranches (manhattan and normalizedgeneral-position) are exercised by that suite, confirming the shared
barsserves both paths.FASTERHENRY_PROFILE_N=200 cargo test -p fasterhenry --lib pfft::near::profile -- --ignored --nocapture— runs, prints its phase table, checksum identical to main.cargo package -p fasterhenrygreen; tarball containssrc/pfft/cloud_draws.rs, nobenches/;cargo test --no-rungreeninside the extracted tarball with an empty
[workspace]table appended.TDD: no — pure refactor whose regression oracle is the existing
seed-sensitive suite; the issue's test plan states no new test is required
by the recommended approach, and the pre-existing suite pinned the
behavior before the change (observed 14/14 before-and-after, identical
profile checksum).
Closes #372
loom dashboard