Skip to content

fix(sdk): make ProofBundle types round-trip with the Rust runtime#22

Merged
eonedgeproject-code merged 2 commits into
mainfrom
fix/sdk-proofbundle-roundtrip
Jun 23, 2026
Merged

fix(sdk): make ProofBundle types round-trip with the Rust runtime#22
eonedgeproject-code merged 2 commits into
mainfrom
fix/sdk-proofbundle-roundtrip

Conversation

@eonedgeproject-code

Copy link
Copy Markdown
Member

Summary

Make the @witnex/sdk TypeScript types faithfully mirror the serde-derived JSON the Rust runtime emits, so a ProofBundle produced by witnex demo summarize round-trips through the SDK. Also fill in the previously empty examples package 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:

  • Field casing: SDK used camelCase (inputHash, modelId, toolCalls), Rust serde emits snake_case (input_hash, model_id, tool_calls).
  • Encoding: SDK typed Digest/Nonce/proof.bytes as hex/base64 strings; Rust serializes [u8; 32]/Vec<u8> as byte arrays (number[]).
  • Missing field: ProofBundle lacked the top-level commitment digest that the Rust ProofBundle and every emitted bundle include.

Changes

  • packages/sdk/src/index.ts — align interfaces with witnex-core/witnex-prover: snake_case fields, byte-array Digest/Nonce/Proof.bytes, add commitment. Document the encoding and note the planned hex/base64 follow-up tracked in witnex-core.
  • packages/examples/ — add a runnable round-trip.ts that parses and structurally validates a bundle in the exact shape the CLI emits; wire real build/typecheck/test scripts (replacing the echo "(no examples yet)" stubs). Typecheck resolves the SDK from source (matching the no-build CI flow); build/run resolves it from the built dist.
  • packages/sdk/package.jsontest now runs a typecheck instead of a no-op echo.
  • Docs: witnex-core is no longer "types only" (it owns the hashing/commitment logic); witnex-prover no longer references the completed "Prompt 2"; the CLI verify help reflects the Phase 1 structural recompute.

Verification

Run locally (no Rust toolchain required):

  • SDK typecheck — pass
  • Examples typecheck (SDK from source) — pass
  • SDK build + examples build + node dist/round-trip.js — runs, prints the parsed bundle
  • ESLint on changed files — clean

No Rust logic was changed (only doc comments); the ZK proving path is untouched.

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.
@eonedgeproject-code eonedgeproject-code merged commit 8f3ce99 into main Jun 23, 2026
3 checks passed
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