Harel Statecharts, Event Sourcing & Distributed Sagas
Bit-for-bit replay determinism via counter-based PRNG keys, Petrov OCC, and Garcia-Molina compensating transactions
In This Component
In distributed multi-warehouse fulfillment, two-phase commit (2PC) locks destroy throughput under peak arrival surges, while uncoordinated microservices create “zombie” locked inventory whenever a downstream carrier API times out.
ASC 606-Aligned Distributed Saga Coordinator
Project Aegis implements the Garcia-Molina & Salem Process Manager Saga pattern aligned with GAAP ASC 606 revenue recognition:
- (
VerifyAuthHold): Verifies customer payment authorization before touching physical inventory. - (
ReserveStock): Executes a version-tagged Optimistic Concurrency Control (OCC) atomic update on geographic shard :
UPDATE inventory
SET allocated = allocated + :q, version = version + 1
WHERE node_k = :k AND sku_i = :i
AND (on_hand - allocated) >= :q
AND version = :expected_version;
- (
BookFreightCarrier): Requests carrier manifest and shipping label. If fails, compensating action (ReleaseInventoryAllocation) immediately frees the reserved units with cryptographic idempotency (sha256(order_id + step_id)). - (
CaptureAndSettleASC606): Captures funds and recognizes GAAP revenue strictly upon carrier dispatch satisfaction.
Orthogonal Harel Statecharts & Bit-for-Bit Replay Determinism
Concurrent state transitions across the Order Lifecycle (Pending Allocated Dispatched Settled / Compensated) and Inventory Lifecycle (Available Allocated Shipped Replenished) are governed by deterministic Harel statecharts.
Every immutable event in the append-only ledger carries a deterministic counter-based PRNG key (philox_key = hash(trace_id, event_seq_id)), ensuring that the state fold
reproduces identical Sequential Monte Carlo (SMC) particle resampling trajectories across historical replays.