Skip to content

test(core): direct unit tests for RoomProtocol's wire-verb handlers and token verification - #127

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

Mearman merged 2 commits into
mainfrom
test/room-protocol-mutation-coverage

Conversation

@Mearman

@Mearman Mearman commented Sep 15, 2026

Copy link
Copy Markdown
Member

Summary

  • RoomProtocol was only exercised through real two-peer TCP/TLS integration tests, which cover the happy path end-to-end but not most individual error codes, optional-field spreads, and edge branches.
  • Token verification here is genuinely cryptographic (verifyRoomToken), so tests use real identities (generateIdentity/toIdentityPort) and real minted tokens (mintCapabilityToken) rather than opaque placeholders.
  • Split across two files to stay under the max-lines cap: room-protocol.test.ts covers handleRoomSend/handleRoomRead/handleRoomMembers/sendRoomMessageDirected; room-protocol-admission.test.ts covers sendRoomRequestToMember/flushPendingRoomRequests, handleRoomJoin/admitRoomJoin, acceptRoomJoin/rejectRoomJoin, handleRoomInvite, and handleRoomLeave.
  • Raises src/core/room-protocol.ts's mutation score from a freshly-measured 56.52% (103 killed, 80 survived) toward the repo's 80% threshold.

Closes #111

Test plan

  • pnpm typecheck
  • pnpm lint
  • pnpm test (67 files, 578 tests, full suite green)

…cation directly

RoomProtocol was previously exercised only through real two-peer TCP/TLS
integration tests, which cover the happy path end-to-end but not most
individual error codes, optional-field spreads, and edge branches.
RoomProtocolDeps is a narrow, injectable surface built exactly for
direct testing, but token verification here is genuinely cryptographic
(verifyRoomToken), so tests use real identities (generateIdentity/
toIdentityPort) and real minted tokens (mintCapabilityToken) rather
than opaque placeholders, unlike room-messaging.ts's sending side.

Split across two files to stay under this repo's max-lines cap.
room-protocol.test.ts covers handleRoomSend, handleRoomRead,
handleRoomMembers, and sendRoomMessageDirected: every error code
(missing_scope_path, unauthorized, malformed_params), the replyTo/
streaming-behavior optional spreads on both room and dm-path sends,
the dm-vs-room history branch, room.read's readBy dedup and dm/room
event-shape distinction, and room.members' dm-participant-vs-Room-
member mapping. room-protocol-admission.test.ts covers
sendRoomRequestToMember/flushPendingRoomRequests (including the
MAX_QUEUED_DELIVERIES_PER_AGENT oldest-first bound), handleRoomJoin/
admitRoomJoin (not_owner/not_participant/dm-auto-approve branches, the
held-open accept/reject continuation, minting and persisting the
granted token), handleRoomInvite (the deliberately-ungated verb, its
embedded-token verification, and the room-state/inviter-agent
extension fallbacks), and handleRoomLeave (member-vs-invited-decline
branches, revocation, and the member_left/invite_declined event
distinction).
@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-15T14:05:00.668104Z 166c085 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.

…rage

Verified against a fresh mutation run: streamingBehavior's optional
inclusion was only tested for owner-named room sends, not the dm-path
branch that constructs a separate DmMessage object; handleRoomMembers'
token-verification-failure branch had no test at all, only the
no-token-presented case.
@Mearman
Mearman merged commit 0a6e69a into main Sep 15, 2026
6 checks passed
@Mearman
Mearman deleted the test/room-protocol-mutation-coverage branch September 15, 2026 15:19
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-protocol.ts mutation score to 80%

1 participant