문서 추가: 턴 다이아몬드 생명주기 및 제어 계약 문서화

This commit is contained in:
2025-12-27 02:44:44 +00:00
parent d9c14ddec9
commit 4a9c14fd98
4 changed files with 243 additions and 0 deletions
+24
View File
@@ -23,6 +23,9 @@ deployments predictable.
- Communication channel: Redis Stream or Redis pub/sub
- Client updates: SSE between API server and frontend where appropriate
Detailed lifecycle and control flow are defined in
`docs/architecture/turn-daemon-lifecycle.md`.
## Engine Runtime Flow (Draft)
### Turn Daemon Loop
@@ -38,6 +41,27 @@ deployments predictable.
immediately even if requests remain queued.
- While the daemon is resolving a turn, the API server queues incoming requests.
### Daemon Control Contract (Draft)
API server commands are delivered to the daemon over the control channel
(Redis Stream or in-process). The daemon replies with status and run events.
```ts
export type RunReason = 'schedule' | 'manual' | 'poke';
export type DaemonCommand =
| { type: 'run'; reason: RunReason; targetTime?: string; budget?: TurnRunBudget }
| { type: 'pause'; reason?: string }
| { type: 'resume'; reason?: string }
| { type: 'getStatus'; requestId: string };
export type DaemonEvent =
| { type: 'status'; requestId?: string; status: TurnDaemonStatus }
| { type: 'runStarted'; at: string; reason: RunReason }
| { type: 'runCompleted'; at: string; result: TurnRunResult }
| { type: 'runFailed'; at: string; error: string };
```
### API Server Flow
- The API server validates queries/commands and writes them to Redis Streams