feat: implement input event system with durable command handling

- Introduced InputEvent model with status tracking (PENDING, PROCESSING, SUCCEEDED, FAILED) and unique request IDs.
- Added DatabaseTurnDaemonTransport for sending commands and handling idempotency.
- Implemented executeInputEvent function to manage input event lifecycle and error handling.
- Created DatabaseTurnDaemonCommandQueue for managing command processing and lease recovery.
- Enhanced turn daemon lifecycle to support atomic command execution and error recovery.
- Added tests for input event atomicity, command queuing, and error handling scenarios.
This commit is contained in:
2026-07-25 05:36:34 +00:00
parent c5da507df9
commit 5040691d7c
34 changed files with 1587 additions and 448 deletions
+10 -3
View File
@@ -43,13 +43,14 @@ export interface TurnDaemonStatus {
export type TurnDaemonCommand =
| {
type: 'run';
requestId?: string;
reason: RunReason;
targetTime?: string;
budget?: TurnRunBudget;
}
| { type: 'pause'; reason?: string }
| { type: 'resume'; reason?: string }
| { type: 'shutdown'; reason?: string }
| { type: 'pause'; requestId?: string; reason?: string }
| { type: 'resume'; requestId?: string; reason?: string }
| { type: 'shutdown'; requestId?: string; reason?: string }
| { type: 'getStatus'; requestId?: string }
| { type: 'troopJoin'; requestId?: string; generalId: number; troopId: number }
| { type: 'troopExit'; requestId?: string; generalId: number }
@@ -186,6 +187,12 @@ export type TurnDaemonCommand =
};
export type TurnDaemonCommandResult =
| {
type: 'commandRejected';
ok: false;
commandType: TurnDaemonCommand['type'];
reason: string;
}
| {
type: 'auctionFinalize';
ok: true;