feat(e7): live-сессии пилота — реальные LLM, run-процесс, Docker-образы, фиксы лимитов речи и баланса (TASK-53…TASK-56) #8

Merged
geekiot merged 16 commits from feat/pilot-e7 into main 2026-08-12 22:52:26 +05:00
Owner

Контекст

Эпик E7 (пилот на реальных LLM): цель — прогнать live-сессии на GigaChat, собрать метрики NFR-010 и подготовить продакшен-развёртывание через Docker Compose.

Что входит

  • Live-процесс game-core (TASK-53): session runner, python -m game_core, активация сессии, wakeup/start-now, восстановление запланированных сессий из журнала (D-81), управление жизненным циклом соединения с БД.
  • LLM-агент (TASK-53): живой игрок на GigaChat/Kimi через LangChain, промпты знакомства и голосований; KIMI_BASE_URL из env; GIGACHAT_VERIFY_SSL_CERTS для проверки TLS.
  • Контент: каталог темпераментов — 20 записей (D-94, D-95).
  • Docker (TASK-56): Dockerfile и wiring в compose для game-core, api и frontend (замена заглушек); frontend — standalone-сборка NextJS, api — uv-образ; healthcheck'и и depends_on у всех сервисов.
  • Фиксы по пилотам:
  • RULE-094/D-111: реплики длиннее 6 предложений обрезаются без ретрая (D-23-промпты ≤ 4 для greeting/farewell), клэмп всех реплик — знакомство/обсуждение/прощание;
  • D-112: баланс ролей — дон входит в лимит чёрной команды, MAFIA = лимит − 1 при игре с доном;
  • example.env — полный набор runtime-переменных.
  • Документация: чек-лист пилота и запросы метрик (NFR-010), обновления спеки (RULE-133, D-111, D-112), contracts.

Проверка

  • ruff check, ruff format --check, ty check, uv run pytest -q — 547 passed;
  • frontend npm test (vitest) — 165 passed;
  • docker compose config валиден; все 4 сервиса поднимаются и отвечают: api health 200, прокси /api/v1 через frontend 200, страницы /, /sessions, /players, /stats, /test — 200;
  • 3 пилотные сессии на реальном GigaChat (журналы в volume journals).
# Контекст Эпик E7 (пилот на реальных LLM): цель — прогнать live-сессии на GigaChat, собрать метрики NFR-010 и подготовить продакшен-развёртывание через Docker Compose. # Что входит - Live-процесс game-core (TASK-53): session runner, python -m game_core, активация сессии, wakeup/start-now, восстановление запланированных сессий из журнала (D-81), управление жизненным циклом соединения с БД. - LLM-агент (TASK-53): живой игрок на GigaChat/Kimi через LangChain, промпты знакомства и голосований; KIMI_BASE_URL из env; GIGACHAT_VERIFY_SSL_CERTS для проверки TLS. - Контент: каталог темпераментов — 20 записей (D-94, D-95). - Docker (TASK-56): Dockerfile и wiring в compose для game-core, api и frontend (замена заглушек); frontend — standalone-сборка NextJS, api — uv-образ; healthcheck'и и depends_on у всех сервисов. - Фиксы по пилотам: - RULE-094/D-111: реплики длиннее 6 предложений обрезаются без ретрая (D-23-промпты ≤ 4 для greeting/farewell), клэмп всех реплик — знакомство/обсуждение/прощание; - D-112: баланс ролей — дон входит в лимит чёрной команды, MAFIA = лимит − 1 при игре с доном; - example.env — полный набор runtime-переменных. - Документация: чек-лист пилота и запросы метрик (NFR-010), обновления спеки (RULE-133, D-111, D-112), contracts. # Проверка - ruff check, ruff format --check, ty check, uv run pytest -q — 547 passed; - frontend npm test (vitest) — 165 passed; - docker compose config валиден; все 4 сервиса поднимаются и отвечают: api health 200, прокси /api/v1 через frontend 200, страницы /, /sessions, /players, /stats, /test — 200; - 3 пилотные сессии на реальном GigaChat (журналы в volume journals).
runner.py composes phase automata around PlayerAgent (live providers, LangGraph
Postgres memory, stats materialization); __main__.py hosts the admin API and
the scheduler loop with NFR-003 startup recovery. Activation moves from
tick/start-now to open_session: tick/start-now mark_active broke open_session
(active->active) and the scheduled->skipped path (FR-003); per the state
machine the session becomes active after a successful selection.
- Dockerfile: uv workspace sync --no-editable (editable .pth pointed to
  builder-stage paths, import game_core failed in the runtime image);
  prompts/*.md packaged via hatchling package data; migrations, alembic.ini,
  data copied; healthcheck on /admin/settings.
- docker-compose.yml: game-core service replaced the stub with the built
  image (DATABASE_URL to postgres, JOURNAL_DIR named volume, loopback-only
  port 8001 per D-77).
- admin_api: ADMIN_HOST overridable via env for containers (default stays
  127.0.0.1 per D-77); test reloads the module for both cases.
- WakeupScheduler moved into scheduler.py with consume_forced(); start_now
  creates a planned_at=now session; the main loop drains forced wakeups first.
- SessionStore.status_of() added; __main__ recovers scheduled journals on
  restart so their seq/pos reload correctly (NFR-001) instead of crashing.
- _postgres_memory uses an explicit psycopg connection (autocommit) held for
  the session lifetime and closed after the run; PlayerMemoryStore.close().

Tests: TestWakeupScheduler (forced consumed before tick, skipped when already
opened, none by default, rejected while active), scheduled journal reopen and
corrupt-tail failure in test_sessions.py. Test isolation: LangGraph store
tables are dropped after the postgres roundtrip and admin settings are
restored, so the shared session-scoped DB stays migration-clean.
GigaChat ignores the prompt limit and produced 4-5+ sentence speeches, which
counted as invalid answers and ran the D-99 backoff until technical_dropout
(observed in pilot E7). The prompt still asks for at most 4 sentences
(PROMPT_SPEECH_SENTENCES), the game-core hard limit is 6 and longer speeches
are truncated via truncate_sentences() instead of raising.

Spec: RULE-094/D-23 updated, new D-111 in registry, NFR-010, llm-cost,
PlayerSpeech schema description, ASSUMPTIONS A-5, CHANGELOG; historical plan
note in e3-game-core.md. Tests: truncation instead of re-pick, unit tests for
truncate_sentences (incl. trailing fragment without a terminator).
The "Мафия" column in game-rules §7 means the whole black team including
the don (RULE-133, D-112): at 8–9 players the black team stays at 2
(1 mafia + don), and the 10-player fork is 2–3 black including the don.
Pilot 2 showed 4 black at 10 players gave black an instant win.

Updates role_composition, the game-core fixture (don now used for the
reflection failure), tests (incl. fixture event counts 249 → 315), and the
spec docs (RULE-133, D-112).
Greeting, discussion, and farewell speeches now enforce the D-111
hard limit of 6 sentences via _clamp_speech. Previously only the
discussion phase clamped in DiscussionPhase, so GigaChat introduction
and farewell replies could reach up to 21 sentences (pilot 3).

Prompts for greeting/farewell also carry the prompt-side <= 4
sentences instruction (D-23) via max_sentences template var
(PROMPT_VERSION 2 -> 3); spec RULE-094 updated accordingly.
geekiot changed title from feat/pilot-e7 to feat(e7): live-сессии пилота — реальные LLM, run-процесс, Docker-образы, фиксы лимитов речи и баланса (TASK-53…TASK-56) 2026-08-12 22:49:32 +05:00
geekiot deleted branch feat/pilot-e7 2026-08-12 22:52:26 +05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
geekiot/mafia-agents!8
No description provided.