Repository navigation
feat: project-scope all id-based message-store lookups (#51) - #57
Merged
Merged
Conversation
OBenner
commented
Nov 15, 2026
OBenner
left a comment
Owner
Author
There was a problem hiding this comment.
Ревью dev (скоуп: всё, кроме wire — wire здесь не затронут).
Вердикт: принять по коду, но до мержа нужен rebase + зелёный CI.
Проверено по ветке локально (4a5fb14):
- Call-site'ы: все вызовы
getMessage/setDeliveryState/countThreadSince/resetSubmittedForRetryв src обновлены на project-scoped сигнатуры, ни одного одноаргументного вызова не осталось (проверено grep по дереву + typecheck). Снятые caller-side проверкиrow.project !== projectне теряют семантику —findById(id, project)теперь делает их по построению. - Смена контракта UNAUTHORIZED → NOT_FOUND для кросс-проектных read/ack: согласен. Fail-closed, no-existence-leak, консистентно с политикой reply (чужой тред уже NOT_FOUND). Обновлённые ожидания в relay-service.test.ts и message-store.test.ts помечены комментариями — честно.
- Conformance-тест доказывает именно project-фильтр: одинаковый threadId в двух проектах,
countThreadSinceвозвращает по 1 на проект (не 2),getMessageкросс-проект → undefined, кросс-проектные write'ы бросают и не трогают исходное сообщение. Это ровно то, что требовалось. - Края проверены:
completeDeliveryReceipt—!beforeв evidence-ветке учтён;reportDeliveryFailure—!row→ UNAUTHORIZED до любого разыменования.
Неблокирующие ниты:
- http-server.ts: проверки
existing.project !== project(строки ~367/~397) теперь недостижимы — scoped-запрос гарантирует. Оставить как defense-in-depth допустимо, но это мёртвый код; можно пометить комментарием или снять при следующем касании. quarantineDelivery: кросс-проектный вызов раньше давал INVALID_INPUT, теперь NOT_FOUND — та же fail-closed логика, ок, но в PR body явно названы только UNAUTHORIZED→NOT_FOUND; упомянуть бы и этот класс.
Два блокера до мержа:
- CI «Format, typecheck, test, build» — failure. Локальный
pnpm verifyна 4a5fb14 полностью зелёный (83 файла / 733 теста). Похоже на окружение/flaky, не на код. Нужен повторный прогон — самый простой способ заодно решает пункт 2. - Конфликт с main (0c1812c) в
src/relay/relay-service.ts— пересечение со смерженным #60 (single-writer, requireWriter рядом с твоими хунками send/reply/getMessage). Ребейз/merge main в ветку, резолв тривиальный по смыслу (оба набора правок сохраняются), пуш перезапустит CI.
Defense in depth: 'an id is unique within the database file' held by discipline; now it holds structurally. Every id-based lookup carries the project in the query (WHERE id = ? AND project = ?): - findById(id, project), getMessage(id, project), countThreadSince(threadId, project, since); - the filter-less helpers setDeliveryState and resetSubmittedForRetry gain a project parameter too, so no id-based path remains unscoped; - redundant caller-side project comparisons dropped where the scoped query already guarantees them. Observable change, fail-closed and consistent with the existing no-existence-leak policy: cross-project reads/acks that used to answer UNAUTHORIZED now answer NOT_FOUND. Tests: store-level conformance case pins that an id from project A is invisible from project B across getMessage/countThreadSince/acknowledge/ setDeliveryState/resetSubmittedForRetry, with a same-thread-id message in the other project to prove the filter is the project column; existing call-site expectations updated to the new signatures. pnpm verify: 83 files / 733 tests, format/typecheck/build green.
… routes (#51) Review nit from dev: getMessage(messageId, project) is project-scoped in the query since the previous commit, so the existing.project comparison can never fire.
OBenner
force-pushed
the
feat/51-message-store-project-filter
branch
from
November 15, 2026 16:49
4a5fb14 to
20f38f8
Compare
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.
What
Closes #51 — the P3 defense-in-depth gap from the Claude Desktop live run triage: id-based message-store lookups had no
projectfilter, so the invariant "an id is unique within the database file" held by discipline only.findById(id, project)→WHERE id = ? AND project = ?; same for the publicgetMessage(id, project)andcountThreadSince(threadId, project, since).setDeliveryStateandresetSubmittedForRetry(no wire-input production callers) gain aprojectparameter too, so no id-based path remains unscoped.row.project !== projectcomparisons dropped where the scoped query already guarantees them (authorizeDelivery,completionClaim,reportDeliveryFailure,quarantineDelivery,acknowledge,relay-service.getMessage, HTTP receipt/failure routes — the latter also as a review-nit follow-up commit).Observable behavior changes (fail-closed)
UNAUTHORIZEDnow answerNOT_FOUND— consistent with the existing no-existence-leak policy (reply to a foreign thread is already NOT_FOUND). Conformance expectations intest/relay/relay-service.test.tsandtest/storage/message-store.test.tsupdated with comments.quarantineDeliveryfor a cross-project id now throwsNOT_FOUND("message not found") instead ofINVALID_INPUT("quarantine recipient does not match") — same no-existence-leak rationale; recipient-mismatch within the same project still throwsINVALID_INPUT.Tests
test/storage/message-store.test.ts, "cross-project isolation"): an id from project A is invisible from project B acrossgetMessage/countThreadSince/acknowledge/setDeliveryState/resetSubmittedForRetry; a message with the same thread id exists in project B to prove the filter is the project column, not the thread.pnpm verifyafter rebase on main761c1af(includes the merged #60requireWriter): 86 files / 761 tests, format/typecheck/build green. The rebase conflict inrelay-service.tswas resolved keeping both change sets (requireWriter+ project-scoped lookups).Docs
Threat-model acceptance item:
docs/security/threat-model-2026-11-12.mdis a dated historical record and is never edited retroactively (CONTRIBUTING), so the "project isolation is structural at the store layer" note landed as a bullet in the README security/operations notes instead. If a refreshed threat-model document is wanted, that is a separate docs task.Out of scope
projectcolumn already exists.RelayService.getMessage(identity, id)signature unchanged.