Outputs and compatibility · v0.12.0

WIT type mappings and evolution verdicts

Inspect exactly how every supported WIT type compiles into Rust, TypeScript, Python, Go, Java 21, C# 12, Protobuf, JSON Schema, and checked glue, and how schema edits behave across wire lockfiles, 4-view diffs, and generated version adapters.

Type projection

WIT to Rust, Protobuf, JSON Schema, and Glue

Every row reflects the normative emitter specification. Unsupported constructs (resources, handles, tuples, futures, streams, async functions, and unsupported map keys) are rejected up front by witforge check.

Primitives

Scalar WIT types keep exact integer widths and signedness in Rust, use explicit proto3 presence when required, and enforce narrow ranges and Unicode scalar validity in checked glue.

WIT constructPlain RustProtobuf (proto3)JSON SchemaChecked glue and notes
boolbooloptional bool (required) / bool in flags{"type":"boolean"}Required record fields reject absent proto optional with GlueError::MissingField.
u8, u16, u32u8, u16, u32optional uint32integer with exact min/max (0..255, 0..65535, 0..4294967295)Glue range-checks u8 and u16 from uint32 (GlueError::IntegerOutOfRange).
u64u64optional uint64integer (0..18446744073709551615)Proto3-JSON encodes u64 as decimal strings; Rust Serde emits exact JSON numbers.
s8, s16, s32i8, i16, i32optional sint32integer with exact signed min/maxZigZag-encoded sint32; glue range-checks s8 and s16 into i8/i16 (GlueError::IntegerOutOfRange).
s64i64optional sint64integer (-9223372036854775808..9223372036854775807)ZigZag-encoded sint64; proto3-JSON encodes s64 as decimal strings.
f32, f64f32, f64optional float / optional doublenumber (f32 bounded to finite IEEE-754 range)Types containing floats omit Eq and Hash even when --eq-hash is enabled.
charcharoptional uint32{"type":"string","minLength":1,"maxLength":1}Glue validates Unicode scalar values via char::from_u32 (GlueError::InvalidChar).
string::std::string::String (::alloc::string::String under --no-std)optional string{"type":"string"}UTF-8 string; presence-checked when required.
Polyglot emitters

Built-in TypeScript, Python, Go, Java, and C# projections

Every polyglot emitter generates zero-dependency plain types plus bidirectional version adapters alongside a checked protobuf glue emitter verified against witforge conformance in CI. Inspect committed files under examples/polyglot.

Ecosystem targets and runtimes

Plain types depend only on each language's standard library. Checked protobuf glue pairs those plain types with the canonical protobuf runtime for each ecosystem.

LanguageTarget baselineCLI commandsPlain type shapesVersion adaptersChecked glue runtime
TypeScriptStrict ESM (NodeNext)ts, ts-gluereadonly interfaces, as-const string enums, discriminated unionsconvert.ts@bufbuild/protobuf
PythonPython 3.11+ stdlibpy, py-gluefrozen dataclasses (slots=True), StrEnum, Protocol, py.typedconvert.pygoogle.protobuf (protoc --python_out)
GoGo 1.22+ stdlibgo, go-gluegofmt structs, Valid()/String() enums, sealed variant interfacesconvert/google.golang.org/protobuf (protoc-gen-go)
JavaJava 21+ stdlibjava, java-gluedefensive records, enums, sealed interface ... permits variantsConvert.javacom.google.protobuf (protoc --java_out)
C#C# 12+ / .NET 8+ stdlibcsharp, csharp-glue#nullable enable sealed records, value-equality lists, abstract record variantsConvert.csGoogle.Protobuf (protoc --csharp_out)

Key WIT type projections across all five languages

Checked glue enforces exact narrow integer ranges, Unicode scalar values, required field presence, closed enums, and fixed lengths across both decode and encode boundaries.

WIT typeTypeScriptPython 3.11+Go 1.22+Java 21+C# 12+ / .NET 8+
u8, u16, u32numberintuint8, uint16, uint32int (unsigned range)byte, ushort, uint
s8, s16, s32numberintint8, int16, int32byte, short, intsbyte, short, int
u64 / s64bigintintuint64 / int64long (unsigned 64-bit for u64)ulong / long
charstring (1 scalar)str (1 scalar)runeint (Unicode scalar)System.Text.Rune
list<u8> / list<T>Uint8Array / readonly T[]bytes / tuple[T, ...][]byte / []Tbyte[] / List<T>byte[] / IReadOnlyList<T>
list<u8, N> / list<T, N>Uint8Array / readonly T[] (len N)bytes / tuple[T, ...] (len N)[N]byte / [N]Tbyte[] / List<T> (len N)byte[] / IReadOnlyList<T> (len N)
map<K, V>ReadonlyMap<K, V>Mapping[K, V]map[K]VMap<K, V>IReadOnlyDictionary<K, V>
option<T>Option<T>T | None (nested: Option[T])*T (nested: Option[T])Optional<T>T? (nested: WitforgeOption<T>)
result<T, E>{ tag: "ok"; value: T } | { tag: "err"; error: E }Ok[T] | Err[E]Result[T, E]WitforgeResult<T, E>WitforgeResult<T, E>
Opt-in emitter options

Explicit profiles, zero surprise dependencies

Default plain types require zero external dependencies across all six languages. Enable Rust traits or no_std, Draft 2020-12 JSON Schema, protobuf language options, selective --only generation, conformance bundles, or opt-in plugins per project in witforge.toml or via CLI flags.

--serdeRust emitter

Adds plain #[derive(Serialize, Deserialize)] using Rust field names, plus private helpers for [T; N] with N > 32.

--no-stdRust, convert.rs, glue

Replaces ::std paths with ::core and ::alloc (including alloc::collections::BTreeMap and core::error::Error on Rust 1.88+).

--eq-hashRust emitter

Derives Eq and Hash on every generated type that does not transitively contain f32 or f64.

--try-fromRust convert.rs

Emits both borrowed TryFrom<&From> and owned TryFrom<From> impls in both directions for converted nominal types (records, variants, enums, flags).

--draft 2020-12JSON Schema emitter

Switches JSON Schema from Draft 7 (definitions) to Draft 2020-12 ($defs and native deprecated: true annotations).

--go-package / --java-package / --csharp-namespaceProtobuf emitter

Embeds derived Go, Java (with --java-multiple-files and --java-outer-classname), and C# protobuf file options without changing wire numbers.

--only <GEN[,GEN...]>witforge generate

Runs or checks a validated subset of configured generators across rust, proto, schema, glue, doc, polyglot emitters, and opt-in plugins.

witforge conformanceCross-language bundle

Exports canonical WIT, .proto (with optional --polyglot-proto-options), and deterministic binary plus proto3-JSON vectors proving glue parity.

witforge plugin / --allow-pluginsThird-party emitters

Invokes external witforge-gen-<name> binaries over bounded JSON-on-stdio (protocol_version = 1); explicit opt-in only, never run implicitly.

Versioned workflow

How contracts evolve without shifting wire numbers

Released directories are immutable. A minor change lives in a new sibling directory that continues the prior wire.lock; a wire-breaking change starts a new major package.

witforge contract evolution lifecycleFive-step contract evolution flow: a frozen released v0.1 baseline is copied by witforge new-version into draft v0.2, validated and locked against v0.1 wire.lock, reviewed with 4-view diff and version adapters, and finally marked released and enforced by witforge freeze in CI.RELEASEDwit/v0.1Immutable WIT+ wire.lockFrozen in GitSTEP 1new-versionCreates wit/v0.2Copies lock + depsEdit draft safelySTEP 2lock & checkAgainst v0.1 lockAppend-only tags+ deps syncSTEP 3diff & generate4-view diff / policyVersion adapters--check in CIFROZENrelease & freezeRecords wit/v0.2in wit/releasedHistory checked
Compatibility verdicts

Four-view diff and adapter behavior

witforge diff --check gates wire,source,api by default. Select binary decode gating explicitly with --check=wire,decode or [project.<name>.policy].

Contract change (within one major)wiresourceapidecode (binary)Version adapter
Add option<T>, non-byte list<T>, or map<K, V> fieldCompatibleBreakingBreakingCompatibleold -> new defaults (None / empty)
Add required list<u8> fieldCompatibleBreakingBreakingBreaking (new<-old)old -> new defaults to empty bytes; wire optional bytes rejects absence
Add required scalar, string, char, list<T, N>, or record fieldCompatibleBreakingBreakingBreaking (new<-old)Refused within a major (WF2002); omitted old -> new across majors
Add enum or variant caseCompatibleBreakingBreakingBreaking (old<-new)new -> old returns UnknownCase for new case
Remove option<T>, non-byte list<T>, or map<K, V> fieldCompatible (reserved)BreakingBreakingCompatibleold -> new drops field; new -> old defaults
Remove required list<u8> fieldCompatible (reserved)BreakingBreakingBreaking (old<-new)old -> new drops field; new -> old defaults to empty bytes
Remove required scalar, string, char, list<T, N>, or record fieldCompatible (reserved)BreakingBreakingBreaking (old<-new)new -> old returns MissingMember
Remove enum or variant caseCompatible (reserved)BreakingBreakingBreaking (new<-old)old -> new returns UnknownCase for removed case
Add a flag memberCompatibleBreakingBreakingCompatibleold -> new sets false; new -> old drops
Remove a flag memberCompatible (reserved)BreakingBreakingCompatibleold -> new drops; new -> old sets false
Add interface functionCompatibleBreakingBreakingBreaking (old<-new)n/a (extends interface definition and method enum)
Renumber an existing member in wire.lock (same major)BreakingCompatibleCompatibleBreaking (both)Refused by lockfile continuity check (WF1100)
Retype field, change type kind, or reuse a reserved tag on a new memberBreakingBreakingBreakingBreaking (both)Refused within a major (WF2002); omitted across majors (use new major)
Update docs or stability/deprecation metadata (in a new version)CompatibleCompatibleCompatibleCompatibleFull round-trip (never edit a released version in place)

Key boundary: binary decode vs in-process version adapters

Generated version adapters (convert.rs, convert.ts, convert.py, convert/, Convert.java, Convert.cs) convert plain values inside one process and default an added or removed list<u8> field to an empty byte sequence. On the wire, required list<u8> is proto3 optional bytes, so a reader rejects an omitted field from the opposite side with MissingField (reported as decode: BREAKING (new<-old) on addition and decode: BREAKING (old<-new) on removal). Strict proto3-JSON parsers also reject unknown fields unless configured to ignore them.