Skip to content

test(core): direct unit tests for RoomMessaging's optional-field spreads and DM key derivation - #125

Merged
Mearman merged 3 commits into
mainfrom
test/room-messaging-mutation-coverage
Sep 15, 2026
Merged

Mearman merged 3 commits into
mainfrom
test/room-messaging-mutation-coverage

Conversation

@Mearman

@Mearman Mearman commented Sep 15, 2026

Copy link
Copy Markdown
Member

Summary

  • RoomMessaging was only exercised indirectly through end-to-end room-send integration tests, leaving many individual branches (optional replyTo/streamingBehavior spreads, error message text, since-filtering boundaries, self-DM vs cross-DM key derivation) unobserved.
  • Adds a direct DI-based unit test file; loadRoomTokens is mocked since RoomMessaging only ever forwards its return value opaquely, never inspecting or verifying it.
  • Covers sendRoomMessage's not-found/not-a-member/no-token error messages, replyTo/streaming-behavior optional inclusion, federated-room forwarding, and per-member fan-out; readRoomMessages' since-filtering boundaries; and sendDm's self-DM shortcut versus cross-agent validation, sorted dmRoomPath key, and error messages.
  • Raises src/core/room-messaging.ts's mutation score from a freshly-measured 37.33% (28 killed, 47 survived) toward the repo's 80% threshold.

Closes #110

Test plan

  • pnpm typecheck
  • pnpm lint
  • pnpm test (64 files, 491 tests, full suite green)

…derivation directly

RoomMessaging was previously exercised only indirectly through end-to-end
room-send integration tests, leaving many individual branches (optional
replyTo/streamingBehavior spreads, error message text, since-filtering
boundaries, self-DM vs cross-DM key derivation) unobserved.

RoomMessagingDeps is a narrow, injectable surface built exactly for direct
testing; loadRoomTokens is mocked since RoomMessaging only ever forwards
its return value opaquely, never inspecting or verifying it. A fake deps
object with vi.fn() collaborators asserts on sendRoomMessage's not-found/
not-a-member/no-token error messages, replyTo/streaming-behavior optional
inclusion in both the stored message and the wire params, federated-room
forwarding, and per-member fan-out excluding the sender; readRoomMessages'
since-omitted/since-empty/since-set filtering boundaries; and sendDm's
self-DM shortcut (no recipient validation, no wire round trip, self:<id>
key) versus cross-agent validation, sorted dmRoomPath key, and error
messages.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-15T09:32:15.275110Z 673f550 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…' equivalent

Verified against a fresh mutation run: sendRoomMessage's own
streamingBehavior inclusion on the stored message (distinct from the
already-tested wire-params version) had no assertion; readRoomMessages
never distinguished the real since='' shortcut from a mutant comparing
against a different literal; and sendDm's cross-agent wire params never
asserted streaming-behavior's absence when omitted (only presence was
checked). The remaining since==='' ConditionalExpression mutant is a
practical equivalent given every RoomMessage's timestamp is always a
real ISO string, documented in the file header rather than forced.
Verified against a fresh mutation run: the StringLiteral mutant survives
for the identical reason the ConditionalExpression mutant does (filtering
with since="" reproduces the early-return's output for any real, non-empty
timestamp), not a separate gap the earlier test closed. Corrected the file
header to document both, and fixed an inline comment on an unrelated test
that had wrongly claimed to distinguish this specific mutant.
@Mearman
Mearman merged commit d68d991 into main Sep 15, 2026
6 checks passed
@Mearman
Mearman deleted the test/room-messaging-mutation-coverage branch September 15, 2026 09:57
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.

Raise src/core/room-messaging.ts mutation score to 80%

1 participant