Lab2 grade 4: PostgreSQL, Redis sessions, Compose, student tests and evidence.
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-10-30 12:37:18 +03:00
parent 65003b6119
commit 950ff93573
34 changed files with 2252 additions and 41 deletions
+1
View File
@@ -0,0 +1 @@
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+10
View File
@@ -0,0 +1,10 @@
-- Seed ≥10k messages then EXPLAIN the keyset history query.
-- Run: docker compose exec -T postgres psql -U messenger -d messenger -f - < evidence/explain.sql
EXPLAIN (ANALYZE, BUFFERS)
SELECT id, chat_id, sender_id, text, created_at
FROM messages
WHERE chat_id = (SELECT id FROM chats LIMIT 1)
AND (created_at, id) > ('1970-01-01'::timestamptz, '00000000-0000-0000-0000-000000000000'::uuid)
ORDER BY created_at ASC, id ASC
LIMIT 50;
Binary file not shown.
+9
View File
@@ -0,0 +1,9 @@
Docker Desktop / Engine (compose lab2 stack)
Images: python:3.12.8-slim-bookworm, postgres:16.6-bookworm, redis:7.4.2-bookworm
API image: mtusi-messenger:lab2
Target grade: 4
Branch: solution/bvt2303-bolotov
Tests: check PASS, smoke PASS, persistence PASS
Student-tests: RUN_DEPS_TEST=1 (18 OK) + expiry at SESSION_TTL_SECONDS=2 PASS
EXPLAIN: Index Scan on idx_messages_chat_created_id, SEEDED 10000 (evidence/explain.txt)
Postgres for IDE: 127.0.0.1:5432 (compose.yaml, loopback only)
+2
View File
@@ -0,0 +1,2 @@
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
+45
View File
@@ -0,0 +1,45 @@
CREATE EXTENSION IF NOT EXISTS pgcrypto;
INSERT INTO users (id, username, display_name, password_hash, created_at)
VALUES (
'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa',
'explain_seed_user',
'Explain',
'$argon2id$v=19$m=65536,t=3,p=4$YWFhYWFhYWFhYWFhYWFhYQ$YWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWE',
now()
)
ON CONFLICT (username) DO NOTHING;
INSERT INTO chats (id, title, created_at)
VALUES ('bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb', 'explain-chat', now())
ON CONFLICT (id) DO NOTHING;
INSERT INTO chat_members (chat_id, user_id)
VALUES ('bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb', 'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa')
ON CONFLICT DO NOTHING;
INSERT INTO messages (id, chat_id, sender_id, text, created_at)
SELECT gen_random_uuid(),
'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb',
'aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa',
'msg-' || g,
timestamptz '2026-01-01 00:00:00Z' + (g * interval '1 millisecond')
FROM generate_series(1::integer, 12000::integer) AS g
WHERE NOT EXISTS (
SELECT 1 FROM messages WHERE chat_id = 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb' LIMIT 1
);
SELECT count(*) AS message_count
FROM messages
WHERE chat_id = 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb';
EXPLAIN (ANALYZE, BUFFERS)
SELECT id, chat_id, sender_id, text, created_at
FROM messages
WHERE chat_id = 'bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb'
AND (created_at, id) > (
'1970-01-01'::timestamptz,
'00000000-0000-0000-0000-000000000000'::uuid
)
ORDER BY created_at ASC, id ASC
LIMIT 50;
+1
View File
@@ -0,0 +1 @@
PASS: lab2 public API scenario; infrastructure and grading evidence remain separate.
Binary file not shown.