Repository navigation
fix(moid): reduce the check character's sum as it goes - #2
Merged
adammharris merged 1 commit intoOct 29, 2026
Merged
Conversation
Alphabet::check_char summed ordinal × position in a usize and reduced once at the end. On wasm32 that overflowed at about 17,500 symbols of noid_xdigit: a panic in a debug build, and in a release build a check character that a 64-bit build and moid-ts disagree with. It now takes the remainder at every step, as moid-ts does, so the result is unchanged for every body that did not overflow. Closes docs/tasks/check-char-overflows-a-32-bit-sum.md. Behavioural-change: on 32-bit targets, check_char, verify_check and Minter::validate no longer panic (debug) or answer a wrapped check character (release) for bodies whose sum passed u32::MAX; they give what 64-bit builds and moid-ts give.
adammharris
deleted the
agent/backlog-check-char-overflows-a-32-bit-sum
branch
October 30, 2026 01:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Alphabet::check_char(moid/src/alphabet.rs) now takes the remainder by the radix at every step, of the position as well as of the running sum, instead of summingordinal × positionin ausizeand reducing once at the end. Every term now stays under radix², so the sum can't overflow on any target. This is the same reduction moid-ts'scheckCharalready does.Why
The sum grew with the square of the body's length. On wasm32, where
usizeis 32 bits, a body of about 17,500 of noid_xdigit's last symbol passedu32::MAX. A debug build panicked, and a release build gave a check character that a 64-bit build and moid-ts disagree with ('w'instead of'f'at 20,000 symbols). The change gives the same result for every body that did not overflow.Closes
docs/tasks/check-char-overflows-a-32-bit-sum.md. Its status is nowdone, and it names this fix.How it was verified
check_char_of_a_body_past_a_32_bit_sumpins the 20,000-symbol body to'f'and the 17,000-symbol body to'8'. Before the fix it panicked with an overflow onwasm32-wasip1(run under Node'snode:wasias the cargo runner). After the fix, all moid lib tests pass on wasm32-wasip1 in both debug and release.cargo fmt --all --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo testwith default features,--no-default-featuresand--all-featuresvectors.jsonandts-minted.tsvwith no drift, thencargo test -p moid-paritycargo +1.70 check -p moidwith default features,--no-default-featuresand--features js