Overview
GS1 (GLYPH Stream v1) is a stream framing protocol for transporting a sequence of GLYPH payloads over streaming transports.Spec ID:
Status: Frozen (v1.0)
Date: 2025-06-20
gs1-1.0.0Status: Frozen (v1.0)
Date: 2025-06-20
What GS1 Provides
Stream Multiplexing
Multiple logical streams over one connection (SID-based routing)
Sequence Tracking
Monotonic sequence numbers per stream for ordering and gap detection
Integrity Checking
CRC-32 checksums to detect transmission corruption
State Verification
SHA-256 base hashes for safe patch application
Supported Transports
- TCP sockets
- WebSocket (text and binary frames)
- Server-Sent Events (SSE)
- Unix pipes
- Files (log replay, batch processing)
Relationship to GLYPH
A GS1 frame contains:- A GS1 header (stream metadata)
- A payload that is valid GLYPH text (UTF-8 bytes)
payloadBytes to the normal GLYPH decoder.
Terminology
| Term | Definition |
|---|---|
| Frame | One message in the stream (header + payload) |
| SID | Stream identifier (multiplex key) |
| SEQ | Per-SID sequence number (monotonic) |
| KIND | Semantic category of the payload |
| BASE | Optional state hash for patch safety |
| CRC | Optional CRC-32 checksum for integrity |
Frame Kinds
| Value | Name | Meaning |
|---|---|---|
| 0 | doc | Snapshot or general GLYPH document/value |
| 1 | patch | GLYPH patch doc (@patch ... @end) |
| 2 | row | Single row value (streaming tabular data) |
| 3 | ui | UI event value (progress/log/artifact refs) |
| 4 | ack | Acknowledgement (usually no payload) |
| 5 | err | Error event (payload describes error) |
| 6 | ping | Keepalive / liveness check |
| 7 | pong | Ping response |
Implementations MUST accept unknown kinds and surface them as
unknown(<byte>).GS1-T (Text Framing)
GS1-T is the text-based wire format, suitable for SSE, WebSocket text frames, logs, and debugging.Frame Structure
Header Grammar
The header line starts with@frame{ and ends with }\n.
Inside {} is a space-separated or comma-separated list of key=value pairs.
Required keys:
| Key | Type | Description |
|---|---|---|
v | uint8 | Protocol version (MUST be 1) |
sid | uint64 | Stream identifier |
seq | uint64 | Sequence number (per-SID, monotonic) |
kind | string/uint8 | Frame kind (name or number) |
len | uint32 | Payload length in bytes |
| Key | Type | Description |
|---|---|---|
crc | string | CRC-32 of payload: crc32:<8hex> or <8hex> |
base | string | State hash: sha256:<64hex> |
final | bool | End-of-stream marker for this SID |
flags | uint8 | Bitmask (hex) |
Payload Reading Rule (Critical)
This is critical for correctness. The payload may contain@frame{ sequences or other patterns that look like frame boundaries. Always read exactly len bytes.
Example Frames
CRC-32 Integrity Checking
Whencrc is present:
- Algorithm: CRC-32 IEEE (polynomial 0xEDB88320)
- Input: Payload bytes as transmitted
- Format in GS1-T:
crc=<8 lowercase hex digits>orcrc=crc32:<8hex>
Example: Computing CRC-32
CRC-32 is not cryptographic. It only detects accidental corruption. Use TLS for transport security.
SHA-256 Base Hash for Patch Safety
Whenbase is present:
- Algorithm: SHA-256
- Input:
CanonicalizeStrict(stateDoc)orCanonicalizeLoose(stateDoc) - Format in GS1-T:
base=sha256:<64 lowercase hex digits>
State Hash Definition
Patch Application Rule
Forkind=patch frames with base:
- Receiver MUST NOT apply patch if
receiverStateHash != base - On mismatch, receiver SHOULD:
- Request a
docsnapshot, OR - Emit an
errframe, OR - Emit an
ackwith failure payload
- Request a
Example: Safe Patch Application
Ordering and Acknowledgement
SEQ Monotonicity
For eachsid:
seqMUST be monotonically increasing by 1- Receivers SHOULD detect gaps and handle appropriately
ACK Frames
kind=ackacknowledges receipt of(sid, seq)ackframes typically havelen=0ackwith payload may carry error/status details
FINAL Flag
final=trueindicates no more frames for thissid- Receiver may clean up per-SID state
Stream Multiplexing
Use stream IDs (SID) to multiplex multiple logical streams over one connection.Example: Multi-Agent Coordination
Security Considerations
Conformance Checklist
A GS1 implementation is conformant if it:- ✅ Correctly reads/writes GS1-T frames per this spec
- ✅ Enforces
lenlimits - ✅ Verifies CRC-32 when present
- ✅ Parses
basehash correctly - ✅ Exposes
(sid, seq, kind, payloadBytes, base?, crc?)to caller - ✅ Does not require GLYPH parser changes
- ✅ Does not treat GS1 headers as part of GLYPH canonicalization
Next Steps
Patches
Learn how to create and apply incremental state updates
Fingerprinting
Understand SHA-256 hashing for state verification
Loose Mode
Explore schema-optional GLYPH for flexible data
Agent Patterns
See GS1 streaming in multi-agent systems