Repository navigation
Website overhaul, phase 2: real Brutus and Cicero via WebAssembly - #16
Merged
Merged
Conversation
The C++ is fetched at pinned commits and compiled unmodified with Emscripten (scripts/build-wasm.sh); small bindings in wasm/ expose it. The output is committed so the site builds without Emscripten. Cicero loops forever on characters its dictionary has no single-character token for (digits, non-ASCII letters), which is why the old site stripped input. Input is filtered against the loaded dictionary and Cicero runs in a Web Worker with a timeout, so a hang can never freeze the page. Tests run both builds in Node against values from the native CLIs. Brutus casts out-of-range doubles to unsigned long long (undefined behaviour), so x86 builds print different ciphertexts than ARM; WebAssembly matches ARM, i.e. what the Raspberry Pi served on the old site. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Nq9YrSAj91fqZFLCbH3CUM
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.
Phase 2 of the overhaul replaces the demo mocks with the real C++, compiled to WebAssembly.
What's in it
scripts/build-wasm.sh(npm run wasm):wasm/exposebrutusText,ciceroTokenizeand friends.public/wasm/is committed, so building the site doesn't need Emscripten: Brutus 140 KB, Cicero 120 KB, plus the 380 KB dictionary that loads with the demo.cicero/brutusshell commands now run the real code. Cicero shows each token's text and ID, and the dictionary size.Two findings in the C++ (your repos are untouched)
-,'and any non-ASCII letter: nativecicero -i "great 5"never returns, and neither doescicero -i "zażółć". This is presumably why the old site stripped input in PHP. Here, input is filtered against the loaded dictionary, and the page says what it left out. The worker timeout is a second line of defence. A fix in Cicero itself would be to skip, or map to an unknown token, any character with no dictionary entry.genPseudouniqueIntegercasts out-of-range doubles tounsigned long long, which is undefined behaviour. ARM and WebAssembly saturate, while x86-64 does not. So the WebAssembly build matches what the Raspberry Pi produced on the old site, but an x86 build of the same commit prints something else. A fix in Brutus would be an explicit, well-defined conversion (for examplefmodinto range, or saturation), followed by documenting that existing ciphertexts change on one of the two platforms.Checks
npm run verify: lint, type check, 21 tests, build.tests/wasm.test.tsruns both WebAssembly builds in Node and compares them with native clang++ builds of the same commits.🤖 Generated with Claude Code
https://claude.ai/code/session_01Nq9YrSAj91fqZFLCbH3CUM
Generated by Claude Code