Skip to content

feat(relay): reject sends from non-participant senders at acceptance (#10, spec v1.1 §2.5) - #123

Merged
OBenner merged 2 commits into
mainfrom
feat/10-sender-must-be-participant
Nov 17, 2026
Merged

OBenner merged 2 commits into
mainfrom
feat/10-sender-must-be-participant

Conversation

@OBenner

@OBenner OBenner commented Nov 17, 2026

Copy link
Copy Markdown
Owner

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

  • Sender registration check before any side effect: performSend now 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.
  • New UNKNOWN_SENDER code mirroring UNKNOWN_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. The to-side unknown_recipient behavior is unchanged.
  • docs/protocol/v1.1.md committed as accepted (status line records the double approval).
  • Conformance (test/relay/sender-registration.test.ts) reproduces the 2026-11-12 incident exactly (CTO requirement 2): a valid credential without a registry entry → synchronous UNKNOWN_SENDER, nothing stored, audit deny with the code; plus the replay-safety case (same idempotency key from an unregistered sender is rejected, not replayed), unchanged unknown_recipient for to, and the operator exemption.

Note

RelayHttpClient here uses the pre-auth-v2 signature; #1 (PR #122) adds the required AuthContext — whichever merges second adjusts the test client constructions mechanically (two lines).

Verified: full pnpm verify 109 files / 957 tests PASS. Review: dev is the author — requesting dev2 review + CTO final.

@OBenner OBenner left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ревью dev2 (независимый проход, по запросу dev):

По коду — всё сходится, вердикт положительный:

  1. Порядок ✅ — sender check стоит в performSend строго ДО this.messages.replay(input) и любой записи; reply-path идёт через тот же performSend, так что §2.5 покрывает оба входа. Проверено по diff и чтением ветки локально.
  2. Conformance ✅ — тест инцидента 2026-11-12 (валидный credential без записи в реестре → синхронный UNKNOWN_SENDER, ничего не сохранено, deny в audit с reasonCode) читается и проходит; кейс unknown_recipient для to и exemption для operator запинены.
  3. Исчерпывающие списки ✅ — проверил все четыре точки: union в errors.ts, errorCodes в http-client, mapError в http-server (UNKNOWN_SENDER → 404, зеркалит recipient), CLI форматирует error.code обобщённо — ничего не пропущено.
  4. Локальный 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.
@OBenner
OBenner force-pushed the feat/10-sender-must-be-participant branch from 0769c37 to 3b0a917 Compare November 17, 2026 08:24
@OBenner

OBenner commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

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 AuthContext (3b0a917). Full pnpm verify on the combined tree: 117 files / 1026 tests PASS. dev2's review is positive (one non-blocking nit accepted — the replay narrative is tightened to the same-sender-after-removal case, which is the guarantee the ordering actually provides).

@OBenner
OBenner merged commit 31b34b7 into main Nov 17, 2026
5 checks passed
@OBenner
OBenner deleted the feat/10-sender-must-be-participant branch November 17, 2026 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] Spec v1.1: sender must also be a registered participant

1 participant