Skip to main content

Data model (fluxMsg)

This section details the specific wire formats (CBOR), field dictionaries, and entity identification used in the fluxrig ecosystem.

Future Roadmap (v0.5.0+): We are currently re-implementing the Registry to leverage NATS KV [Roadmap] for all state governance. This will move the architecture from a "Push" model to a "Distributed State Watcher" model, increasing resilience and simplifying the handling of concurrent updates.

NOTE

For the conceptual architecture and philosophy behind these models, see the Architecture: Data Model guide.

Message specification (header spec)

All messages traversing the bus MUST adhere to the Signal Metadata standard for context propagation.

Wire headers (transport level)

These headers are used during message propagation across the NATS network or HTTP boundaries. Note: These are distinct from the internal Metadata map found within the payload body.

Header KeyStandardDescription
Nats-Msg-IdNATSUnique Message Deduplication ID.
TraceparentW3C OTelDistributed Tracing ID (00-{trace_id}-{span_id}-{flags}).

fluxMsg structure (payload)

The payload is always a CBOR-encoded fluxMsg struct.

// fluxMsg is the atomic unit of data in the system.
type FluxMsg struct {
// --- Identity & Tracing ---
fluxID uint64 `cbor:"id"` // Global Unique ID (Sonyflake)
RefFluxID uint64 `cbor:"ref_id"` // Correlation / Parent ID
traceID string `cbor:"trace"` // OpenTelemetry traceID (Hex)
SrcGearID uint64 `cbor:"src_id"` // Originator EntityID

// --- Context (Metadata) ---
// Routing flags, source IP, protocol headers.
// Values MUST be valid UTF-8 strings.
Metadata map[string]string `cbor:"meta"`

// --- The Business Data ---
// Unified Field Map (ISO8583 tags, JSON keys).
Data map[string]any `cbor:"data"`

// --- Fallback & Audit ---
RawPayload []byte `cbor:"raw"` // Original wire bytes
Path []*Hop `cbor:"path"` // Audit Trail
TsInit int64 `cbor:"ts"` // Timestamp of creation (Unix Nanos)
}

```go
type Hop struct {
GearID uint64 `cbor:"g"`
PortID uint64 `cbor:"p"`
TsNano int64 `cbor:"t"`
}

Field dictionary

FieldTypeTagDescription
fluxIDuint64idGlobally unique transactional ID (Sonyflake).
RefFluxIDuint64ref_idCorrelation ID (references a Parent signal).
traceIDstringtraceW3C Otel Trace ID for distributed observability.
SrcGearIDuint64src_idThe fluxEntityID of the originating Gear.
Metadatamap[string]stringmetaSignal Metadata (Routing flags, protocol headers).
Datamap[string]anydataBusiness fields (ISO8583 tags, user-defined keys).
Flagsuint32flagsSystem-level signaling (e.g., 0x01 = Sync Probe).
RawPayload[]byterawThe original, bit-perfect wire bytes.
Path[]*HoppathCryptographically signed hoptrail for auditability.
TsInitint64tsUnix Nanoseconds of entry into the Rig.

System signaling (flags)

The Flags field is a 32-bit bitmask used for high-speed, system-level signaling that must be processed without parsing the business Data map.

BitHexNameDescription
00x01FlagSyncProbeData-Plane Sync: Used by the Relentless Handshake (ADR 0036) to verify data-plane availability.
1..31-ReservedReserved for future system orchestration signals.


Signal metadata dictionary

To ensure interoperability across the fleet, fluxrig distinguishes between Industry Standard keys and project-specific internal keys.

W3C trace context (standard)

These keys adhere strictly to the W3C Trace Context standard used by OpenTelemetry. They use no-dot notation.

KeyDescriptionSource
traceparentW3C Trace Parent (00-{trace_id}-{span_id}-{flags}).Ingress / TCP I/O
tracestateW3C Trace State (vendor-specific trace data).Ingress / TCP I/O

fluxrig signal metadata

Internal keys follow the Dot Notation convention (namespace.property).

KeyTypeDescriptionSource
conn.idHex StringUnique connection ID (Session) for routing responses.TCP I/O
fluxrig.sourceStringName/ID of the gear that emitted the message.Architecture
spec.idHex StringThe fluxEntityID of the Spec used to parse this message.Codec Gear
peer.ipStringIP Address of the remote sender.TCP I/O
peer.portStringPort of the remote sender.TCP I/O
http.methodStringHTTP Method (GET, POST) if applicable.HTTP I/O
http.pathStringURL Path.HTTP I/O
iso8583.mtiStringMessage Type Indicator (e.g., "0200").ISO8583 I/O
iso8583.bitmapsStringCount of bitmaps present (e.g., "1", "2").ISO8583 I/O
iso8583.fieldsStringList of active fields (e.g., "[2, 3, 4]").ISO8583 I/O
iso8583.raw_headerHex StringPreserved raw framing header (Prefixed with hex:).ISO8583 I/O
iso8583.src_idStringRouting Header Source ID.ISO8583 I/O
iso8583.dst_idStringRouting Header Destination ID.ISO8583 I/O
coatcheck.ttlStringDuration Override (e.g., "5m", "120s").Coat Check
event.typeStringEvent ID (e.g., "fluxrig.event.timeout").Coat Check
timeout.keyStringThe key that expired.Coat Check
timeout.bucketStringThe bucket where the key expired.Coat Check

Payments glossary (industry standard aliases)

To ensure Coat Check and Correlator logic functions uniformly regardless of the underlying dialect (Visa, Mastercard, Base24), we enforce exact standard aliases mapped within the Codec SDL.

Alias KeyTypeDescription
card.panStringPrimary Account Number (Often Field 2).
card.expStringExpiration Date (YYMM format).
routing.binStringThe Bank Identification Number (extrapolated or explicit).
amount.transactionStringThe nominal transaction amount. Kept as a String (with implied decimals, e.g., 000000010000 for 100.00) to strictly avoid floating-point errors.
trace.stanStringSystem Trace Audit Number (Often Field 11).
trace.rrnStringRetrieval Reference Number.

IMPORTANT

Metadata Integrity Guard (v0.4.5-dev+e5eff62) To ensure cross-language interoperability and wire compatibility with CBOR (RFC 8949), all Metadata values MUST be UTF-8 compliant.

  • Binary Data: Must be hex-encoded and prefixed with hex: (e.g., hex:4e62...).
  • Validation: The system will authoritativey reject messages containing non-UTF-8 metadata at the Bus boundary.

fluxEntityID structure

The fluxEntityID identifies a persistent component (Rack, Gear, specific Spec Version). It uses a 64-bit Hierarchical ID structure: [ Type (8) ] [ MachineID (16) ] [ Local Sequence (40) ]

Prefix (Hex)Entity TypeRelation to MachineID
0x00ReservedSystem Broadcast / Null
0x01ClusterPhysical infrastructure (HA cluster)
0x02MixerLogical tenant unit
0x03fluxMsgMessage Instance
0x04RackLower 16 bits = Sonyflake MachineID
0x05GearRackID + Local Index
0x06PortInputSink (Standard In)
0x07PortOutputSource (Standard Out)
0x08WireConnection between ports
0x09SnakeTransport Tunnel
0x0aScenarioConfig Definition
0x0bSessionRuntime Context
0x0cSpecVersionImmutable Spec Blob ID

Registry and identity mapping

The Registry manages the MachineID allocations that make up the fluxEntityID. To support clustering and observability, MachineIDs (uint16) are allocated according to a strict policy.

Machine ID policy

RangeRoleAssignmentDescription
0Pending / OfflineStaticRepresents a node without an assigned Identity (e.g., during initial handshake or offline mode).
1-99Mixer NodesReservedReserved for internal infrastructure, specifically Mixer nodes (Core).
100-65535Rack NodesSequentialAutomatically assigned by the Registry to enrolled Racks.

Identity assignment strategy

ComponentStrategyMechanismEntity Type
MixerStaticConfig (fluxrig-mixer.toml)0x02
RackDynamicSequence (seq_machine_id_server)0x04
SnakeImplicitConnection0x09

Mixers use static assignment ([mixer] machine_id = 1) to ensure stable leadership. Racks receive their ID dynamically during enrollment. This ID is then embedded into the fluxEntityID (Type 0x04). Snakes (Type 0x09) represent the connection path (NATS Link) from a Rack to a Mixer. They inherit identity from their host.

Unified registry schema

To provide a single pane of glass for all infrastructure, the Mixer maintains a Unified Registry table (registry) in its embedded DuckDB. This stores fluxID -> PublicKey mappings.

Table: registry

ColumnTypeDescription
entity_idUBIGINTPK. Full 64-bit fluxEntityID.
type_idUSMALLINT2=Mixer, 3=Rack, 8=Snake.
machine_idUSMALLINTThe assigned MachineID (1-65535).
nameTEXTUnique Hostname (e.g., rack-01).
statusTEXTactive, pending, offline.
versionTEXTBuild Version (e.g., v0.1.0).
statsJSONReal-time metrics (e.g., CPU, Goroutines). Note: Transported via CBOR.
attributesJSONStatic Metadata. Note: Transported via CBOR.
started_atTIMESTAMPProcess start time.
last_seenTIMESTAMPHeartbeat timestamp.

fluxMsg vs traceID

Before diving into distributed tracing concepts elsewhere, it is important to delineate between our two primary identifiers:

  • fluxID: The physical, unique pointer to the record in our internal data store (e.g., DuckDB, parquet). Generated by Sonyflake for high-speed local issuance.
  • traceID: The logical, distributed trace (opentelemetry/w3c) that ties this fluxID to external systems traversing outside the fluxrig boundary.