feat: finish postgres-storage change

- 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>
This commit is contained in:
2026-10-01 16:20:49 +03:00
co-authored by Claude Opus 5.5
parent 90394ecdfb
commit 2d0a7c83e9
26 changed files with 947 additions and 357 deletions
+22 -2
View File
@@ -1,11 +1,12 @@
"""Спек `data-storage`.
Гонки — в `test_race.py`, рестарт — исключение в `spec_coverage.py`.
Гонки — в `test_race.py`; рестарт, отказы БД и пул — исключения в
`spec_coverage.py`.
"""
import pytest
from api_client import API, Api
from api_client import API, Actor, Api
from contract import assert_ok
@@ -15,3 +16,22 @@ def test_created_user_visible_at_once(api: Api) -> None:
actor = api.register()
resp = api.request("GET", f"{API}/users/me", actor=actor)
assert assert_ok(resp, 200, "User") == actor.user
@pytest.mark.spec("data-storage", "Порядок участников")
def test_member_order_kept(api: Api, alice: Actor, bob: Actor) -> None:
# порядок [bob, alice] из запроса не совпадает с порядком регистрации;
# «в том числе после рестарта» — evidence/storage/restart.md
created = api.create_chat(bob, alice, title="Порядок участников")
expected = [bob.id, alice.id]
assert created["member_ids"] == expected
resp = api.request("GET", f"{API}/chats/{created['id']}", actor=alice)
assert assert_ok(resp, 200, "Chat")["member_ids"] == expected
listed = {
chat["id"]: chat["member_ids"]
for page in api.chat_pages(alice)
for chat in page["items"]
}
assert listed[created["id"]] == expected