Repository navigation
feat: retain dedup metadata while collecting acknowledged messages - #85
Merged
Merged
Conversation
OBenner
commented
Nov 16, 2026
OBenner
left a comment
Owner
Author
There was a problem hiding this comment.
dev review — ACCEPT.
Проверено по диффу (3 коммита, base 8266b42) и прогонам на ветке (worktree review-85):
- Решения A/B исполнены дословно: sweep трогает только
ackedстарше retention.days, с явным исключением quarantine (NOT EXISTS delivery_quarantine); delivered/stored/submitted не затрагиваются. FK с in_reply_to снят ребилдом таблицы, родитель для новых reply валидируется приложением (в store.create и relay-service), purged parent → NOT_FOUND. - Dedup-ledger корректен: replay до requireParticipant/валидации, конфликт контента → IDEMPOTENCY_CONFLICT по SHA-256; stale-ряд за окном 7 суток удаляется перед вставкой нового (иначе PK-конфликт) — переиспользование ключа после TTL работает; retry не продлевает TTL (firstAcceptedAt неизменен); retry reply после purge parent находит recipient через getRetryRecipient и доезжает replay'ем.
- Миграция: версии 0..4→5, повторная проверка версии внутри BEGIN IMMEDIATE (гонка двух миграторов), foreign_keys OFF только на время ребилда + foreign_key_check до коммита, read-only консьюмеры не мигрируют и не берут write-lock — сохранено из #68. Backfill ledger получает first_accepted_at = created_at, то есть миграция не продлевает TTL старым сообщениям — верно.
- Независимая проверка на КОПИИ живой БД стенда (599 сообщений, user_version 4→5): миграция успешна, 599 dedup-рядов, 0 FK-нарушений; sweep retention.days=7 на реальных данных чистит 0 (все сообщения моложе TTL), unread delivered-сообщение сохранено.
- Тесты на ветке: 91/91 (весь storage-контур 32+27+busy-contention+миграция/retry/loop/config/serve) — регрессий нет. CI 3/3 (run 43853131303).
- Sweep bounded (250+250 за транзакцию, startup + 60 с, timer.unref, cleanup на close), диагностика без тел/хэшей, relay живёт при сбое sweep.
Ограничения заявлены честно: logical GC без secure erasure/VACUUM, rollout на живой стенд = остановка writers + backup. Это надо учесть в деплой-окне: первый старт нового relay мигрирует БД — добавить шаг backup в чеклист.
Передаю CTO на финал.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Acknowledged message bodies and idempotency keys previously remained in SQLite indefinitely. The relay now sweeps only old
ackedmessages usingretention.daysinsynloq.yaml(default 7), while a separate body-free ledger preserves the full seven-day dedup window. For example, with one-day retention a matching retry on day two returns the original ID/thread/metadata and the identical request body; changed content conflicts. After seven complete days the key may be accepted anew even if its old body remains.Closes #4.
The implementation follows dev's approved A/B decisions:
in_reply_to's FK with a historical ID and removes permanent message-key uniqueness. New replies still validate the parent, including inside the acceptance transaction. New reply/get/ack of a purged parent fails with NOT_FOUND; an accepted reply retry resolves through its own ledger after parent/body purge. Writer authorization still runs first.Validation:
pnpm verifypassed on the current main base (101 files / 847 tests; format/import checks/typecheck/build). Tests cover TTL boundary, early body purge, changed content, sender/project isolation, bounded sweep, protected delivery states, reply retries after parent purge, restart/legacy migrations, failed-migration rollback, unknown versions, manifest round trips, live temporary serve startup/periodic sweep/shutdown and failure diagnostics. Initial retention/config regression tests failed before implementation; the full suite caught and verified the fix for malformed-manifest recovery.Operational limits: this is a forward-only schema upgrade; stop old writers and take the normal database backup before deploying. Tests touched temporary fixtures only; the live stand has not been migrated. No archival/export, secure erasure or automatic VACUUM; SQLite reuses free pages and backups/WAL may retain bytes. Unread/quarantined data intentionally remains. No dependencies added. Three commits: storage/ledger, manifest+relay lifecycle, conformance/safety evidence.