Skip to main content
Version: v0.6.0

Data model (fluxMsg)

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

Future Roadmap (future releases): 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 uuid.UUID `cbor:"id"` // Global Unique ID (UUID v7)
RefFluxID uuid.UUID `cbor:"ref_id"` // Correlation / Parent ID
TraceID string `cbor:"trace"` // OpenTelemetry trace_id (Hex)
SrcGearID uuid.UUID `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"`

// --- Signaling ---
Flags uint32 `cbor:"flags"` // System-level signaling (e.g., 0x01 = Sync Probe)

// --- Fallback & Audit ---
RawPayload []byte `cbor:"raw"` // Original wire bytes
Path []*Hop `cbor:"path"` // Audit Trail
TsInit int64 `cbor:"ts"` // Timestamp of creation (Unix Nanos)
}
type Hop struct {
GearID uuid.UUID `cbor:"g"`
PortID uuid.UUID `cbor:"p"`
TsNano int64 `cbor:"t"`
}

Field dictionary

FieldTypeTagDescription
FluxIDuuid.UUIDidGlobally unique transactional ID (UUID v7).
RefFluxIDuuid.UUIDref_idCorrelation ID (references a Parent signal).
TraceIDstringtraceW3C Otel Trace ID for distributed observability.
SrcGearIDuuid.UUIDsrc_idThe entity_id 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 entity_id 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").Codec / IO (Heuristic)
iso8583.bitmapsStringCount of bitmaps present (e.g., "1", "2").Codec / IO (Heuristic)
iso8583.fieldsStringList of active fields (e.g., "[2, 3, 4]").Codec / IO (Heuristic)
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 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.

entity_id structure

The entity_id identifies a persistent component (Rack, Gear, specific Spec Version). It uses a 128-bit UUID v7 structure that embeds technical hints: [ Timestamp (48) ] [ Version (4) ] [ Variant (2) ] [ EntityType (8) ] [ Machine ID Hint (32) ] [ Random (34) ]

Prefix (Hex)Entity TypeRelation to machine_id
0x00ReservedSystem Broadcast / Null
0x01ClusterPhysical infrastructure (HA cluster)
0x02MixerLogical tenant unit
0x03fluxMsgMessage Instance
0x04RackIncludes machine_id
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 machine_id allocations that make up the entity_id. To support clustering and observability, machine_ids are now 128-bit UUIDs.

Machine ID policy

IdentityPersistenceAssignmentDescription
uuid.NilTransientDefaultRepresents a node without an assigned Identity (e.g., during initial handshake or offline mode).
UUID v7PermanentRegistryUnique identifier assigned to Mixers and Racks. Includes a 32-bit machine hint for log traceability.

Identity assignment strategy

ComponentStrategyMechanismEntity Type
MixerPersistentConfiguration or Autonomous0x02
RackDynamicRegistry Assignment0x04
SnakeImplicitConnection0x09

Mixers use static assignment via configuration to ensure stable leadership. Racks receive their ID dynamically during enrollment. This ID is then embedded into the entity_id (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 flux_id -> PublicKey mappings.

Table: registry

ColumnTypeDescription
entity_idUUIDPK. Full 128-bit entity_id.
type_idUSMALLINT2=Mixer, 3=Rack, 8=Snake.
machine_idUUIDThe assigned Identity (128-bit).
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 trace_id

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

  • flux_id: The physical, unique pointer to the record in our internal data store (e.g., DuckDB, parquet). Generated using the UUID v7 standard for high-speed local issuance with time-ordering.
  • trace_id: The logical, distributed trace (opentelemetry/w3c) that ties this flux_id to external systems traversing outside the fluxrig boundary.