core.ingress_ledger module
Atomic, content-bound publication for inbound platform events.
Platform SDKs may deliver the same immutable message callback more than once.
The ingress ledger binds that logical event to one deterministic trace ID and
one Redis Stream entry. The binding and XADD happen in one Lua script, so
a lost gateway response can be retried without creating a second turn.
- class core.ingress_ledger.IngressPublishAction(*values)
-
- PUBLISHED = 'PUBLISHED'
- CACHED = 'CACHED'
- exception core.ingress_ledger.IngressLedgerError
Bases:
RuntimeErrorBase class for durable ingress publication failures.
- exception core.ingress_ledger.IngressPayloadConflict
Bases:
IngressLedgerErrorThe same immutable platform event arrived with different content.
- class core.ingress_ledger.IngressPublishResult(action, trace_id, stream_id, payload_fingerprint, identity_hash, trace_identity_hash, trace_key, history_key, active_key, legacy_untracked=False, lifecycle_expired=False)
Bases:
object- Parameters:
- action: IngressPublishAction
- core.ingress_ledger.ingress_event_identity(envelope)
Return the immutable logical identity for a ledger-eligible event.
A platform, channel, message ID, and event kind are all required. Callers can use
is_ledger_eligible()for synthetic/batch envelopes that do not have an immutable platform message ID.
- core.ingress_ledger.is_ledger_eligible(envelope)
Whether the envelope carries a complete immutable platform identity.
- core.ingress_ledger.canonical_ingress_trace_id(envelope)
Derive the one trace ID assigned to an immutable inbound event.
- core.ingress_ledger.ingress_payload_fingerprint(envelope)
Hash every logical ingress field, excluding transport-only values.
- class core.ingress_ledger.IngressLedger(redis, *, ttl_seconds=691200, proof_ttl_seconds=604800, namespace='sg:ingress:v1:')
Bases:
objectPublish one content-bound stream entry per immutable platform event.
- async publish(stream, envelope)
Atomically bind envelope and append its canonical stream entry.
- Return type:
- Parameters:
- async publish_unkeyed(stream, envelope)
Atomically append synthetic ingress using its durable trace as identity.
Synthetic events lack an immutable platform message ID, so callers must retain the generated trace ID to retry a lost Redis response. The event bus passes a mutable envelope; storing the generated value back into that object makes a same-object retry first-writer safe.
- Return type:
- Parameters: