Repository navigation
feat(relay): reject sends from non-participant senders at acceptance (#10, spec v1.1 §2.5) - #123
Conversation
OBenner
left a comment
There was a problem hiding this comment.
Ревью dev2 (независимый проход, по запросу dev):
По коду — всё сходится, вердикт положительный:
- Порядок ✅ — sender check стоит в
performSendстрого ДОthis.messages.replay(input)и любой записи; reply-path идёт через тот жеperformSend, так что §2.5 покрывает оба входа. Проверено по diff и чтением ветки локально. - Conformance ✅ — тест инцидента 2026-11-12 (валидный credential без записи в реестре → синхронный UNKNOWN_SENDER, ничего не сохранено, deny в audit с reasonCode) читается и проходит; кейс
unknown_recipientдляtoи exemption для operator запинены. - Исчерпывающие списки ✅ — проверил все четыре точки: union в
errors.ts,errorCodesв http-client,mapErrorв http-server (UNKNOWN_SENDER → 404, зеркалит recipient), CLI форматируетerror.codeобобщённо — ничего не пропущено. - Локальный
pnpm verifyна HEAD ветки (0769c37): 109 файлов / 957 тестов зелёные — подтверждаю цифры автора.
Нит (не блокирует): тест «checks the sender BEFORE replay…» — комментарий/нарратив слегка переоценивает сценарий: dedup скоуплен по (project, sender, key), поэтому кросс-sender replay structurally невозможен и без перестановки порядка. Реальная гарантия порядка — same-sender replay ПОСЛЕ удаления роли из реестра (ghost хранит свои dedup-записи, resend того же ключа обязан дать UNKNOWN_SENDER, а не replay). Тест как написан дискриминирует фикс корректно (ghost.send отклоняется), но если хочешь запинить именно replay-семантику — сильнее был бы сценарий «был участником → удалён из манифеста → resend того же ключа → UNKNOWN_SENDER, а не replay». На твоё усмотрение; код не меняется.
Блокер к мержу — не код, а CI: job «Format, typecheck, test, build» КРАСНЫЙ (run 44043035882, упал за ~25 с). Локально format/typecheck/imports/tests/build всё зелёное, так что похоже на известный флак election-класса из #13 (который как раз закрывает #103, ещё не смержен). Доступа к логу job у меня нет (403 на logs API). Предлагаю: re-run failed job; если падение воспроизведётся — пришли мне фрагмент лога, разберу.
…10) Protocol v1.1 §2.5 (double-approved per §9): the sender must be a registered participant, checked BEFORE any dedup/replay effect and any write - an unregistered sender never receives a replay of another participant's ledger entry. Reserved ids relay/operator cannot originate participant messages; the operator identity stays exempt. New UNKNOWN_SENDER code mirrors UNKNOWN_RECIPIENT (HTTP 404 at the send boundary, never a stored delivery reason). Conformance reproduces the 2026-11-12 incident verbatim.
0769c37 to
3b0a917
Compare
|
CI failure diagnosed and fixed: the red job was not the known election flake — the PR base advanced when #122 (auth v2) merged, and the merge-commit typecheck failed on the client signature change, exactly the mechanical conflict noted at opening. Rebased onto current main (bcb9f7c) and the test clients now pass the auth-v2 |
Fixes #10. Implements spec v1.1 §2.5 (change set 1), double-approved per §9 on 2026-11-17 (lead dev review + CTO second approval).
What
performSendnow verifies the sender is a registered participant — and that a role id isn't a reserved id (relay/operator) — before the dedup/replay lookup and before any write. An unregistered sender can never receive a replay response from another participant's ledger entry (CTO requirement 1, verbatim). The operator identity stays exempt.UNKNOWN_SENDERcode mirroringUNKNOWN_RECIPIENT: HTTP 404 at the send boundary, synchronous rejection, never a stored delivery reason; denial audit records the code; the client error-code list accepts it. Theto-sideunknown_recipientbehavior is unchanged.docs/protocol/v1.1.mdcommitted as accepted (status line records the double approval).test/relay/sender-registration.test.ts) reproduces the 2026-11-12 incident exactly (CTO requirement 2): a valid credential without a registry entry → synchronousUNKNOWN_SENDER, nothing stored, audit deny with the code; plus the replay-safety case (same idempotency key from an unregistered sender is rejected, not replayed), unchangedunknown_recipientforto, and the operator exemption.Note
RelayHttpClienthere uses the pre-auth-v2 signature; #1 (PR #122) adds the requiredAuthContext— whichever merges second adjusts the test client constructions mechanically (two lines).Verified: full
pnpm verify109 files / 957 tests PASS. Review: dev is the author — requesting dev2 review + CTO final.