Files
mtusi2026lab6/openspec/specs/lab2-history-index/spec.md
T
ArtyomandClaude Opus 5.5 a0d3947710 Carry over the agent context and openspec history from lab 5
Bring the Claude Code settings, the lint hook, the opsx commands and
skills, the architecture notes, the lab 1 to lab 5 specs and the
archived lab 1 to lab 5 changes into the lab 6 skeleton, so lab 6
continues the same spec history instead of starting from scratch. The
files come from the lab 5 solution commit 64d5c67.

Rewrite AGENTS.md and the openspec context and rules for lab 6: the
business API stays at contract 1.6.0, API, relay and worker start the
OpenTelemetry SDK in every process after fork and export OTLP over HTTP
to a separate Collector, Prometheus, Loki and Tempo store metrics, logs
and traces on volumes, Grafana only reads them through provisioning
kept in Git, telemetry never blocks a request and never feeds
/health/ready, metric labels stay low-cardinality and message bodies
and secrets never leave the process. Out of scope moves to lab 7,
track 2 and clustered telemetry backends.

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

25 lines
2.1 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.
# lab2-history-index Specification
## Purpose
Определяет, чем обоснован индекс истории сообщений: планом запроса страницы на наборе не меньше 10 000 сообщений и отсутствием полного прохода по истории на каждой странице.
## Requirements
### Requirement: Индекс истории обоснован планом
Чтение страницы истории SHALL обслуживаться индексом по `(chat_id, created_at, id)` так, что число прочитанных строк и буферов пропорционально `limit`, а не размеру истории чата. Обоснование SHALL быть получено `EXPLAIN (ANALYZE, BUFFERS)` на чате не меньше чем из 10 000 сообщений для первой и для глубокой страницы и сохранено в доказательствах.
#### Scenario: Первая страница
- **WHEN** выполняется запрос первой страницы истории с `limit=50` на чате из ≥10 000 сообщений
- **THEN** план — `Index Scan` по индексу истории без узла `Sort`, прочитана 51 строка
#### Scenario: Глубокая страница keyset-курсором
- **WHEN** выполняется запрос страницы после курсора, указывающего на 10 000-е сообщение
- **THEN** план — `Index Scan` с условием по `(created_at, id)`, прочитана 51 строка, без прохода по предыдущим 10 000
#### Scenario: Сравнение с OFFSET
- **WHEN** та же глубокая страница запрашивается через `OFFSET 10000`
- **THEN** план читает и отбрасывает ≥10 000 строк, что фиксируется рядом с keyset-планом как обоснование выбора курсора