INTERCHANGE
Binary formats and versions
Store the structure and environment without enumerating supply or reparsing source text.
Two explicit wire formats
| Format | Purpose |
|---|---|
| TSMB / AST wire v1 | Standard-piece compact nodes, D/U conditions and source spans |
| TSDC / document wire v1 | Environment, structured sources, custom IDs, relations and references |
TSMB is followed by wire=1 and RFC=3; TSDC by document-wire=1 and RFC=3. Binary versions and semantic profiles are independent of npm/package versions and test-port versions.
P7P4 is stored as two permutation nodes in a concatenation, not an expanded queue list. Compact storage does not prescribe a host execution representation. Never serialize raw C/Rust structure memory.
Document-wire structure
TSDC uses a 32-bit little-endian section count, IDs, critical flags and lengths. Section 1 is the critical document body. Values have distinct tags for booleans, u64, strings, identifiers, lists, call data and embedded TSMB AST. Strings are not executed or reparsed to recover semantics.
Standard pieces retain small TSMB codes and masks. Custom identifiers remain document registry/string IDs. Hold absence, emptiness, occupancy and turn lock are not collapsed into a single piece code.
Loss prevention and invalid input
Unknown optional sections are preserved as opaque bytes. Unknown required sections yield UNSUPPORTED_CRITICAL_EXTENSION. Duplicate sections, truncated lengths, invalid tags, excessive nesting and trailing bytes are rejected.
With opaque metadata, to_text/doc-decode returns OPAQUE_METADATA_WOULD_BE_LOST rather than discarding it. Consumers must explicitly choose a preservation strategy. Structural roundtrips, including spans, are different from minimizing every logically equivalent document.
Reference implementation limits
| Item | Limit |
|---|---|
| Text input | 65,536 bytes |
| Nesting depth | 48 |
| Syntax nodes / predicates | 4,096 each |
| Finite supply length | 256 |
| Advanced binary | 1 MiB |
| Optional extensions | 64 |
These bound one format-processing request, not the entire host game. Hitting a limit is not successful empty supply or complete search. Large execution belongs to the external consumer.
Structural F1/F2 extension
Existing Present/Before atoms remain unchanged. New filters use mandatory relation tag=2 with a length-prefixed TSFL v1 payload. Nodes are Present, Before, Count, All, Any, Not and In; selectors preserve kind IDs and one-based ordinals. No source reparse or exponential DNF/CNF expansion.