Stoffel Typed Client IO Bindings
Scope: AI-agent-agnostic playbook for building applications with the Stoffel framework. This is not a maintainer guide for compiler, VM, protocol, or release engineering work. Dependency assumption: use the public 0.1.0 install snippets from these docs. When developing against a local checkout, make that source-based workflow explicit.
Use when
Use this playbook when a Stoffel app usesClientStore and a Rust client/server wants compile-time input/output structs generated from the exact app bytecode.
Goal
Generate Rust bindings from the exact.stflb program the app will execute, use those bindings for typed client IO, and let the manifest select/validate backend and client-slot IO shape.
Current source of truth
crates/stoffel-rust-sdk/src/codegen.rscrates/stoffel-rust-sdk/src/types.rscrates/stoffel-rust-sdk/src/program.rscrates/stoffel-rust-sdk/src/client.rscrates/stoffel-rust-sdk/tests/sdk_usage.rscrates/stoffel-rust-sdk/tests/compile_fail.rs
Generate bindings in build.rs
Generated shapes
The generator emits:ProgramManifestimpl stoffel::GeneratedProgramManifest for ProgramManifestClient{slot}Inputsfor each client slot with declared inputsClient{slot}Outputsfor each client slot with declared outputs- ordered fields such as
input_0,input_1,output_0 TypedClientInputs/TypedClientOutputsimplementations
- integer shares ->
i64 - boolean secret integers ->
bool - fixed-point shares ->
f64
ProgramManifest and a comment that no client IO was declared.
Use manifest-backed config
Typed client call
Bytecode must be the contract
Treat.stflb as the app/client contract:
- Write or update
.stflsource. - Build bytecode with the same backend/curve/topology assumptions that will be used at runtime.
- Generate Rust bindings from that bytecode.
- Compile the Rust client/server code.
- At runtime, load the same bytecode and validate manifest/client IO shape before submitting inputs.
Multi-client and ordered-input guidance
If a program has:Validation / done criteria
- Regenerate bindings after bytecode changes.
- Run
cargo checkto catch type mismatches. - Run the app’s local smoke with the same bytecode.
- For network/off-chain submissions, validate the runtime’s program manifest against generated types before submitting.
Common pitfalls
- Bindings must come from the exact
.stflbdeployed/executed. - Rebuild bytecode and regenerate bindings after any source, backend, or curve change.
- Do not hand-edit generated binding files.
- Do not bypass manifest validation when network clients submit real inputs.
- Do not assume slot order from Rust struct field order alone; it follows ordered ClientStore metadata from bytecode.
- When using path or git dependencies, avoid using the same local SDK as both app dependency and build-dependency if it causes Cargo duplicate-crate/output-collision failures. Pre-generate bindings or use a dedicated build step.