Files
mtusi2026lab5/openspec/changes/archive/2026-10-28-add-lab2-session-cache-and-resilience/tasks.md
T
ArtyomandClaude Opus 5.5 1210dd899c Carry over the agent context and openspec history from lab 4
Bring the Claude Code settings, the lint hook, the opsx commands and
skills, the architecture notes, the lab 1 to lab 4 specs and the
archived lab 1 to lab 4 changes into the lab 5 skeleton, so lab 5
continues the same spec history instead of starting from scratch. The
files come from the lab 4 solution commit d2744bc.

Rewrite AGENTS.md and the openspec context and rules for lab 5: upload
answers 202 queued after the original is in a private staging prefix
and the attachment, the job and the outbox row are committed in one
transaction, a separate relay publishes the outbox to RabbitMQ with
publisher confirms, a separate worker built from the same image
consumes the queue through FastStream with a manual ack after the
result commit, PostgreSQL stays the source of truth for job states,
Out of scope moves to labs 6-7, track 1 and broker HA, and the rules
add the failure windows between PostgreSQL and the broker, the effect
key and the lease to specs and designs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-29 00:32:37 +03:00

39 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 1. Кэш сессий (зона `identity`)
- [x] 1.1 Добавить зависимость `redis`; настройки `CACHE_URL`, `SESSION_CACHE_TTL_SECONDS`, `CACHE_TIMEOUT_SECONDS`, `CACHE_COOLDOWN_SECONDS` в `IdentitySettings`
- [x] 1.2 Адаптер `CachedSessionDirectory`: чтение с отметкой отзыва, заполнение `SET NX PXAT`, инвалидация отметкой с `503` при отказе, размыкатель
- [x] 1.3 Провайдер DI: кэш подключается при заданном `CACHE_URL`, клиент закрывается вместе с контейнером
- [x] 1.4 Проверка группы: in-process тесты против одноразового Valkey — попадание в кэш, срок ключа не позже `expires_at`, выход оставляет отметку, гонка заполнения после выхода, обход недоступного кэша, `503` выхода без кэша
## 2. Отказы PostgreSQL и пул
- [x] 2.1 In-process тест исчерпания пула: пул из одного занятого соединения → `503` за время ожидания
- [x] 2.2 Проверка группы: `make student-test` зелёный
## 3. Стенд
- [x] 3.1 `compose.yaml`: `valkey` по digest (uid 999, AOF `always`, volume `valkeydata`, healthcheck с паролем), `CACHE_URL_FILE` в API, `api-shortttl` в профиле `faults`
- [x] 3.2 `scripts/secrets.sh` дописывает `valkey.conf` и `cache_url`; `scripts/restart.sh` перезапускает и Valkey; `.env.example` — `SHORTTTL_PORT`
- [x] 3.3 Проверка группы: `make up`, `make test`, `make test-persistence ACTION_SCRIPT=scripts/restart.sh`
## 4. Тесты стенда
- [x] 4.1 `student-tests/stack/`: фикстуры `BASE_URL`/`SHORTTTL_URL`, вызовы `docker compose`, маркер `stack` вне набора по умолчанию
- [x] 4.2 Гонка 50 регистраций одного `username` (1×201 + 49×409, одна строка в БД) и rollback чата с неизвестным участником (строк нет)
- [x] 4.3 Expiry на `api-shortttl`, logout и повторный logout, неверный пароль и неизвестный пользователь
- [x] 4.4 Остановка и рестарт Valkey, `FLUSHALL`, кэш реально используется (`keyspace_hits`)
- [x] 4.5 Остановка PostgreSQL: `503` быстрее 2 с, `live` 200, восстановление без рестарта API
- [x] 4.6 Цель `make test-faults`; проверка группы: прогон зелёный, вывод сохранён в `evidence/faults.txt`
## 5. Индекс истории
- [x] 5.1 `scripts/sql/seed-history.sql` и `make seed`: 20 000 сообщений синтетического чата, повтор безопасен
- [x] 5.2 `scripts/sql/explain-history.sql` и `make explain`: первая и глубокая keyset-страница против `OFFSET` → `evidence/explain-history.txt`
- [x] 5.3 Проверка группы: в планах `Index Scan using messages_history_idx`, 51 строка у keyset, ≥10 000 у `OFFSET`
## 6. Отчёт
- [x] 6.1 Нагрузка `tests/load.py --concurrency 64`: без `500`, ошибки и задержки в `evidence/load.json`
- [x] 6.2 `REPORT.md`: роль Valkey, источник истины, expiry и инвалидация, persistence, пул и таймауты, строки уровня «4», таблица отказов
- [x] 6.3 Проверка группы: `make check`, `make lint`, `make student-test`, `make test`, `make test-persistence ACTION_SCRIPT=scripts/restart.sh`, `make test-faults` зелёные