fix(sdk): make ProofBundle types round-trip with the Rust runtime#22
Merged
Conversation
The @witnex/sdk types did not match the serde-derived JSON the Rust runtime actually emits, so a bundle produced by `witnex demo summarize` could not round-trip through the SDK: - struct fields are snake_case (input_hash, model_id, tool_calls, ...), not camelCase; - Digest, Nonce, and Proof.bytes serialize as byte arrays (number[]), not hex/base64 strings; - ProofBundle was missing the top-level `commitment` field that the Rust ProofBundle and every emitted bundle include. Align the SDK interfaces with witnex-core / witnex-prover, document the byte-array encoding, and note the planned hex/base64 follow-up. Also flesh out the previously empty examples package with a runnable round-trip example that parses and structurally validates a bundle, wire real build/typecheck/test scripts (replacing the echo stubs), and make the SDK `test` script run a typecheck instead of a no-op. Refresh stale module docs: witnex-core no longer "types only" (it owns the hashing/commitment logic), witnex-prover no longer references the completed "Prompt 2", and the CLI `verify` help reflects the Phase 1 structural recompute.
… baseUrl Two CI fixes for the examples package: - pnpm-lock.yaml: add the typescript devDependency to the packages/examples importer so `pnpm install --frozen-lockfile` passes (it was rejecting the stale lockfile). - packages/examples/tsconfig.json: remove `baseUrl`, which TypeScript 6.0 reports as a hard error (TS5101). `paths` resolves relative to the tsconfig without it. Verified with the repo toolchain (pnpm 9, typescript 6.0.3): frozen-lockfile install, `pnpm lint`, `pnpm typecheck`, and the examples build + run all pass.
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.
Summary
Make the
@witnex/sdkTypeScript types faithfully mirror the serde-derived JSON the Rust runtime emits, so aProofBundleproduced bywitnex demo summarizeround-trips through the SDK. Also fill in the previously emptyexamplespackage and refresh a few stale module docs.Why
The SDK claimed to "mirror the canonical Rust types so a proof bundle round-trips," but it didn't:
inputHash,modelId,toolCalls), Rust serde emits snake_case (input_hash,model_id,tool_calls).Digest/Nonce/proof.bytesas hex/base64 strings; Rust serializes[u8; 32]/Vec<u8>as byte arrays (number[]).ProofBundlelacked the top-levelcommitmentdigest that the RustProofBundleand every emitted bundle include.Changes
packages/sdk/src/index.ts— align interfaces withwitnex-core/witnex-prover: snake_case fields, byte-arrayDigest/Nonce/Proof.bytes, addcommitment. Document the encoding and note the planned hex/base64 follow-up tracked inwitnex-core.packages/examples/— add a runnableround-trip.tsthat parses and structurally validates a bundle in the exact shape the CLI emits; wire realbuild/typecheck/testscripts (replacing theecho "(no examples yet)"stubs). Typecheck resolves the SDK from source (matching the no-build CI flow); build/run resolves it from the builtdist.packages/sdk/package.json—testnow runs a typecheck instead of a no-op echo.witnex-coreis no longer "types only" (it owns the hashing/commitment logic);witnex-proverno longer references the completed "Prompt 2"; the CLIverifyhelp reflects the Phase 1 structural recompute.Verification
Run locally (no Rust toolchain required):
node dist/round-trip.js— runs, prints the parsed bundleNo Rust logic was changed (only doc comments); the ZK proving path is untouched.