Conversation
Add a rust/ workspace with oh-canonical, oh-canonical-wasm, and oh-canonical-napi crates. The core crate implements the strict canonical JSON contract from src/canonical.ts, including ECMAScript-compatible number formatting so Rust output is byte-for-byte identical to the TypeScript oracle. The WASM bindings load from src/canonical-rust.ts with a transparent TS fallback, keeping the base package free of required runtime dependencies. A fast-check parity test proves equivalence on generated and hand-written edge cases. Also register the new artifact surfaces in costs.json, add a Rust CI job, and ignore Rust build outputs.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Outcome
Introduce a
rust/workspace inohcontaining three crates:oh-canonical— strict canonical JSON + SHA-256 digests.oh-canonical-wasm—wasm-packbindings.oh-canonical-napi—napi-rsbindings (CI-built, optional).The core crate implements the same contract as
src/canonical.ts. Numberformatting uses an ECMAScript-compatible renderer so Rust output is byte-for-byte
identical to the TypeScript reference for all accepted values.
src/canonical-rust.tsloads the WASM artifact with a transparent fallback tothe TS implementation when the artifact is absent, preserving the package's
"no required runtime dependencies" policy.
src/canonical-rust-parity.test.tsproves equivalence with
fast-checkon generated inputs plus hand-written edgecases.
Contract impact
No persisted or exchanged bytes change. The new code is opt-in and additive;
existing
canonicalJson/canonicalSha256callers continue to use the TSreference. The only new public surface is
loadCanonicalRustTextEngine().Verification
canonical-rust-parity.test.tsand Rust unit tests.costs.jsonwithrust:canonical-wasmandrust:canonical-napisurfaces.bun run checkpasses except for one pre-existing flaky custody test unrelated to this change.cargo check --locked,cargo clippy -- -D warnings, andcargo test --lockedpass.bun run rust:build:wasmproduces a working WASM artifact.