FireDevOps FireMUD & Ops Projects

⚙️ FireMUD System Architecture: Transaction Strategies

This document explains how FireMUD coordinates data consistency across its independent microservices. It distinguishes between real-time gameplay commands (executed within ticks using Redis) and long-running business workflows (executed via a Saga pattern using a shared orchestration library). It clarifies when sagas are needed — and when they are not.


🧠 Terminology Clarification

TermMeaning
CommandA gameplay action issued by a player or AI (e.g., attack, move, use item). Executed inside a tick as a self-contained transaction, backed by Redis.
TransactionA unit of work that must either fully succeed or be rolled back. Each in-game command is treated as an atomic transaction.
TickA scheduled gameplay loop slice. Each tick processes one command per entity and uses Redis for coordination, rollback, and fairness. Ticks are not atomic across all commands — each command is executed as an independent transaction.
SagaA long-running, cross-service workflow composed of multiple local transactions. Used only for non-gameplay, out-of-band operations (e.g., account creation, game publishing). Sagas rely on compensating actions for rollback and eventual consistency.

🎮 In-Game Command Transactions (No Sagas Needed)

All real-time gameplay logic — movement, combat, item use, AI — is executed inside ticks. Each command is:

This model provides:

🔗 See Tick System and Runtime Design and Redis Architecture for detail on how ticks provide transactional guarantees.


🧩 When Sagas Are Used (Out-of-Band Workflows)

Sagas are only used for non-tick, multi-service workflows involving persistent state changes that cannot be coordinated via Redis. These include:

Use CaseDescription
Account CreationCreate account → provision default character → initialize world state
Game PublishingValidate and persist design → push to World Service → toggle publish flags
Admin OperationsIssue bans, content revocation, or entity cleanup with audit logging
In-Game Purchase (rare)Only if involving external billing or cross-service coordination beyond Redis tick safety

These workflows:


✅ FireMUD Saga Architecture

FireMUD uses a shared saga orchestration library, not a separate microservice.

Characteristics:

Fluent API Example:

sagaBuilder("accountCreation")
.step("createAccount", accountClient::createAccount)
.step("provisionCharacter", entityClient::createPlayer)
.step("assignStartingRoom", worldClient::placeInWorld)
.onFailure("provisionCharacter", accountClient::deleteAccount)
.run();

This design centralizes logic, improves visibility, and avoids coupling orchestration directly into gameplay services.


🔁 When Not to Use Sagas

Do not use sagas for:

Use Redis rollback + tick retries for fast, fair, and consistent gameplay handling.


🔭 Future Enhancements