The client passed the sync redis.retry.Retry to async connections, so no
retry could ever run. Use redis.asyncio.retry.Retry with one immediate
retry on ConnectionError only: after a Valkey restart the stale pooled
connection is reopened instead of switching the cache off for 5 s.
Timeouts are not retried, and asyncio.timeout bounds each cache command
(pool wait, connect, retry, reply) by [cache] timeout_seconds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Valkey 9.1 in compose caches the immutable chat card (title, members,
created_at) used by GET /chats/{id} and by the membership check of the
message endpoints. Cache-aside with a write after commit, keys per
database, TTL plus allkeys-lru, persistence off. redis-py runs without
retries; on failure the cache is skipped for a few seconds and requests
go to PostgreSQL. Readiness does not depend on Valkey.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- lifespan computes the dummy Argon2id hash: first unknown-user login
takes as long as a wrong password
- evidence for session TTL from config.toml, default and environment
- REPORT.md: manual /docs check, TTL configuration row
- tasks.md: why checks ran on a separate dev database
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Argon2id password hashes, KDF in a thread with its own limit
- POST /auth/sessions with Basic, DELETE /auth/sessions/current
- Bearer sessions in PostgreSQL, X-User-Id ignored
- migration drops lab 1 data without passwords
- student-tests on tokens, sessions spec and synced specs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- hide_parameters=True in the engine, rule in infra.md
- design: 79 of 80 tests, $(PYTHON) for test_isolated
- AGENTS.md: hand off deferred scenarios
- REPORT.md: unknown outcome of a timed-out commit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- keep engine and session factory in src/infra/db/session.py
- sync delta specs into openspec/specs, add db-migrations spec
- update rules, AGENTS.md and run skill for lab 2 storage
- fill REPORT.md for the storage part
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the in-memory store with PostgreSQL 18.6: SQLAlchemy 2.1 async
engine on asyncpg, alembic migrations with an async env.py, repos on
AsyncSession and services that own the transaction. Username
uniqueness is enforced by the database (ON CONFLICT), a chat and its
members are created in one transaction, member order is kept in
chat_members.position, and a composite foreign key makes the sender a
member of the chat. History and chat lists use keyset pagination on
(chat_id, created_at, id) and (user_id, created_at, chat_id).
The compose stand runs postgres, a one-shot migrate service on the
API image and the API. All Postgres addresses come from .env without
literals; only the 127.0.0.1 publish address stays literal. make
run_dev starts Postgres and applies migrations before the server, and
make env_setup generates a random Postgres password.
Unavailable PostgreSQL yields 503: get_db_session bounds the request
with asyncio and classifies driver errors. BoundedCloseConnection
limits asyncpg's graceful close, which otherwise waited without limit
on a frozen server and held the request until it was resumed.
Add scripts/restart.sh for make test-persistence and make
test_isolated, which runs the image on a throwaway test database.
Remove make run_no_compose. X-User-Id identification is unchanged
until the session-auth change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy the committed lab 1 sources as-is: src/, student-tests/, bench/,
Dockerfile, docker-compose.yml, pyproject.toml, uv.lock,
.python-version, config_example.toml, AGENTS.md, CLAUDE.md, .claude/,
openspec/, .graphifyignore and KNOWN_ISSUES.md. Lab 1 evidence stays
in the lab 1 repository.
Merge the new skeleton files with own sections: Makefile (lab 2
targets plus own run, docker, bench and common targets), .gitignore,
.dockerignore and .env.example. Rename the image to
mtusi-messenger:lab2 and point AGENTS.md at lab 2.
The application is still the in-memory lab 1 implementation.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>