-
-
Notifications
You must be signed in to change notification settings - Fork 6
Swift/TS: Use extracted schemas rather than raw facet Shapes #282
Copy link
Copy link
Open
Description
Currently all codegen targets (Swift, TypeScript, wire) independently walk raw facet Shapes to generate encode/decode logic. This means each target independently re-derives decisions like is_bytes, named vs anonymous types, transparent aliases, etc.
extract_schemas already makes these decisions correctly and produces a clean, language-agnostic Schema representation. That's the single source of truth — it's already what gets serialized to CBOR and sent over the wire for schema compatibility checking.
The codegen should consume Schema nodes instead of Shape nodes. The flow should be:
facet Shape → extract_schemas → Schema → all targets
Benefits:
is_bytes, variant classification, struct/enum recognition etc. are decided once, correctly, in one place — not duplicated and potentially inconsistently across every target- Codegen and runtime schema compatibility checking are provably describing the same type system and cannot drift apart
- Codegen logic becomes simpler —
Schemais a clean tagged union with noShapeKind::Pointer,ShapeKind::TupleStruct, transparent aliases, or other reflection artifacts to handle - Adding a new language target just means consuming
Schema, not understandingfacetinternals
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels