Skip to content

Bootstrap Rust canonical-JSON foundations - #128

Open
0thernet wants to merge 1 commit into
mainfrom
rust-canonical-foundations
Open

0thernet wants to merge 1 commit into
mainfrom
rust-canonical-foundations

Conversation

@0thernet

Copy link
Copy Markdown
Member

Outcome

Introduce a rust/ workspace in oh containing three crates:

  • oh-canonical — strict canonical JSON + SHA-256 digests.
  • oh-canonical-wasmwasm-pack bindings.
  • oh-canonical-napinapi-rs bindings (CI-built, optional).

The core crate implements the same contract as src/canonical.ts. Number
formatting uses an ECMAScript-compatible renderer so Rust output is byte-for-byte
identical to the TypeScript reference for all accepted values.

src/canonical-rust.ts loads the WASM artifact with a transparent fallback to
the TS implementation when the artifact is absent, preserving the package's
"no required runtime dependencies" policy. src/canonical-rust-parity.test.ts
proves equivalence with fast-check on generated inputs plus hand-written edge
cases.

Contract impact

No persisted or exchanged bytes change. The new code is opt-in and additive;
existing canonicalJson / canonicalSha256 callers continue to use the TS
reference. The only new public surface is loadCanonicalRustTextEngine().

Verification

  • Added canonical-rust-parity.test.ts and Rust unit tests.
  • Updated costs.json with rust:canonical-wasm and rust:canonical-napi surfaces.
  • bun run check passes except for one pre-existing flaky custody test unrelated to this change.
  • cargo check --locked, cargo clippy -- -D warnings, and cargo test --locked pass.
  • bun run rust:build:wasm produces a working WASM artifact.
  • Generated tree is unchanged (WASM build output is gitignored).
  • No credentials or private data included.

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.
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
oh-computer Ready Ready Preview Sep 17, 2026 6:38pm UTC

Request Review

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