This doc captures the shared envelope structure used across allocator and OMS flows, and the Redis stream/key naming conventions.
All cross‑box messages share the same envelope abstraction (Python Envelope model in runtime_common.envelope):
Envelope(
kind: str, # e.g. "alloc.submit", "oms.submit", "oms.flatten"
tenant: str, # usually "nts"
ts: int, # ms since epoch (server-side timestamp)
nonce: str, # URL-safe base64 random bytes (16 bytes)
payload: dict, # message-specific body
idem_key: str | None,
sig: str | None, # HMAC-SHA256 over canonical payload
)
Messages are signed with sign(...) in runtime_common.envelope:
env = sign(
kind="oms.submit",
tenant="nts",
payload=payload_dict,
secret=ENVELOPE_SECRET,
idem_key=idem_key, # optional
ts_ms=None, # optional, auto now()
)
The signature is HMAC‑SHA256 over a canonical JSON representation of the envelope fields.
Each worker verifies incoming messages with verify(env_dict, secret=ENVELOPE_SECRET).
On Redis streams, you always send a single field named "json" whose value is a JSON string:
{
"json": "{ \"envelope\": { ... } }"
}
The outer object (container) may contain an envelope field; if not, the worker treats the container itself as the envelope.
Workers do roughly:
raw = fields.get("json")
container = json.loads(raw)
env_dict = container.get("envelope", container)
env = verify(env_dict, secret=ENVELOPE_SECRET)
allocator:jobsallocator_api (POST /allocator/jobs)allocatorFields:
kind: "alloc.submit"version: API version stringsource: "allocator_api"tenant: "nts"idem_key: idem keyjson: JSON string container with the signed envelopeStatus hash: allocator:job:{job_id}
allocator_worker.Typical fields:
status: "PENDING" | "RUNNING" | "DONE" | "ERROR"tenant: "nts"created_at, updated_at: ISO timestampsartifact_s3_key: S3 key to reporterror: optional error messageIdempotency key: idem:ops:{idem_key}
allocator_api with EX=600 and NX for 10‑minute idempotency window.oms:commandssend_ib_submit_bracket.py)omsEnvelope kind values:
"oms.ping""oms.submit""oms.flatten""oms.gateway_status"Stream: ib:events
ibgatekeeper worker.XRANGE/XREVRANGE or via ib_events_api."json" is a JSON object representing a single event.These conventions let you safely add new event types without changing the HTTP APIs or the stream handling boilerplate.