Формальная спецификация (IEEE 29148)
Стиль формулировок: shall (обязательно), should (желательно), may (опционально).
1. Системные требования
SYS-001. The TableTime platform shall allow multiple participants to join a single session via web client or Telegram bot.
SYS-002. The platform shall support at least one game plugin (dice_board) with server-authoritative game state.
SYS-003. The platform shall synchronize game state to all connected clients of all participants in a session.
SYS-004. The platform should persist game history for registered users.
2. Операции с пред/постусловиями
OP-001: createSession
| Actor | Host (guest or registered) |
| Pre | Actor authenticated (guest token or JWT) |
| Input | display_name, optional max_players |
| Post | Session exists in Lobby; unique invite_code; actor is host |
| Inv | invite_code unique among status != Closed sessions |
OP-002: joinSession
| Actor | Player |
| Pre | Session exists; status in {Lobby, GameSelection}; not full |
| Input | invite_code, channel ∈ |
| Post | Participant created or existing linked; presence updated |
| Inv | One Participant per (session, identity) |
OP-003: startGame
| Actor | Host |
| Pre | Session in GameSelection; plugin_id valid; players ≥ min |
| Input | plugin_id |
| Post | New GameInstance active; Session InGame |
| Inv | At most one active GameInstance per session |
OP-004: submitAction
| Actor | Current player |
| Pre | GameInstance active; phase allows action; action_id unique |
| Input | action_type, payload, action_id |
| Post | State updated or rejected; event published |
| Inv | Audit log append-only entry created on success |
OP-005: switchGame
| Actor | Host |
| Pre | Session GameSelection; previous game finished or aborted |
| Input | plugin_id |
| Post | New GameInstance; same session id and invite_code |
3. Инварианты домена
| ID | Инвариант |
|---|---|
| INV-001 | Session.status = InGame ⟹ exactly one GameInstance.status = active |
| INV-002 | Participant.session_id immutable after create |
| INV-003 | action_id unique per GameInstance |
| INV-004 | Dice values in dice_board only from server CSPRNG |
| INV-005 | choose_cell target ∈ {(d1,d2), (d2,d1)} from last roll |
4. Матрица трассировки
| FR | UC | Component | Test |
|---|---|---|---|
| FR-001 | UC-01 CreateSession | session-service | TC-001 |
| FR-002 | UC-02 JoinSession | session-service, bot, web | TC-002 |
| FR-003 | UC-03 DualPresence | session-service, realtime | TC-003 |
| FR-004 | UC-04 SelectGame | session-service | TC-004 |
| FR-005 | UC-05 SwitchGame | session-service, game-runtime | TC-005 |
| FR-006 | UC-06 ViewBoard | media-service, web, bot | TC-006 |
| FR-011 | UC-10 RollDice | game-runtime, dice_board | TC-010 |
| FR-012 | UC-11 ChooseCell | game-runtime, dice_board | TC-011 |
| FR-014 | UC-12 Capture | game-runtime, dice_board | TC-012 |
| FR-015 | UC-13 CenterReroll | game-runtime, dice_board | TC-013 |
| FR-017 | UC-14 WinThreeInRow | game-runtime, dice_board | TC-014 |
| FR-025 | UC-07 RealtimeWeb | realtime-service | TC-007 |
| FR-026 | UC-08 RealtimeTG | telegram-bot, realtime | TC-008 |
| FR-027 | UC-09 IdempotentAction | game-runtime | TC-009 |
| FR-021 | UC-15 Register | auth-service | TC-015 |
| FR-009 | UC-02 JoinSession | auth-service | TC-002 |
5. Use Cases (краткий каталог)
| UC | Название | Актор |
|---|---|---|
| UC-01 | CreateSession | Host |
| UC-02 | JoinSession | Player, Guest |
| UC-03 | DualPresence | Registered |
| UC-04 | SelectGame | Host |
| UC-05 | SwitchGame | Host |
| UC-06 | ViewBoard | All |
| UC-07 | RealtimeWeb | Web client |
| UC-08 | RealtimeTG | Bot |
| UC-09 | IdempotentAction | Player |
| UC-10 | RollDice | Active player |
| UC-11 | ChooseCell | Active player |
| UC-12 | CaptureToken | Active player |
| UC-13 | CenterReroll | Active player |
| UC-14 | WinThreeInRow | System |
| UC-15 | Register | User |
| UC-16 | LinkTelegram | User |
| UC-17 | KickParticipant | Host |
| UC-18 | CloseSession | Host |
| UC-19 | ViewHistory | Registered |
| UC-20 | RenderBoardImage | media-service |
6. Формальные NFR
NFR-F01. The game-runtime service shall complete action validation and apply within 300 ms for p95 under 500 concurrent sessions.
NFR-F02. The realtime service shall deliver GameStateChanged to subscribed clients within 1 s for p95.
NFR-F03. The system shall rate-limit session join to 10 attempts per 5 minutes per source IP.