Skip to content

[codex] Add shared protocol package#201

Closed
TheCardGoat-BOT wants to merge 1 commit into
mainfrom
codex/extract-protocol-contracts
Closed

[codex] Add shared protocol package#201
TheCardGoat-BOT wants to merge 1 commit into
mainfrom
codex/extract-protocol-contracts

Conversation

@TheCardGoat-BOT

Copy link
Copy Markdown
Member

Summary

  • add @tcg/protocol to the shared tcg-engines repository
  • carry over the gateway, inbox, envelope, event, payload, and schema contracts from the-card-goat-online
  • make the package self-contained by moving chat constants, chat message types, and playable game slug helpers into the protocol package

Validation

  • bun test packages/protocol/src
  • bun run check-types from packages/protocol

@blocksorg

blocksorg Bot commented May 12, 2026

Copy link
Copy Markdown

Mention Blocks like a regular teammate with your question or request:

@blocks review this pull request
@blocks make the following changes ...
@blocks create an issue from what was mentioned in the following comment ...
@blocks explain the following code ...
@blocks are there any security or performance concerns?

Run @blocks /help for more information.

Workspace settings | Disable this message

@claude

claude Bot commented May 12, 2026

Copy link
Copy Markdown
Contributor

Claude finished @TheCardGoat-BOT's task in 1m 56s —— View job


📋 Review Summary

This PR adds a new @tcg/protocol package to the shared tcg-engines repository, extracting WebSocket protocol contracts from the-card-goat-online. The package provides typed Socket.io event maps, Zod schemas for runtime validation, and envelope handling for Redis Streams communication between ws-gateway and game-server.

The implementation is well-structured, well-documented, and follows TypeScript best practices. The code makes excellent use of discriminated unions, type guards, and Zod for runtime type safety.

🔍 General Feedback

Positive aspects:

  • Comprehensive JSDoc comments throughout explaining the architecture
  • Strong type safety with discriminated unions and branded types via isPlayableGameSlug type guard
  • Good test coverage for envelope serialization/parsing and schema validation
  • Consistent with monorepo pattern (TypeScript source distribution)
  • Clean separation of concerns: schemas, payloads, events, envelopes, inbox

Areas to consider:

  • The package.json "build": "tsc --noEmit && mkdir -p dist" script creates an empty dist folder - this seems intentional but unclear why mkdir -p dist is needed when noEmit prevents output
  • The Zod version ^4.4.2 in protocol is newer than ^4.3.5 used in core - may want to align versions

📝 Inline Comments

  1. Minor formatting issue in envelope.ts:103 - missing space before opening brace (low severity)

✅ Validation Status

The PR author validated:

  • bun test packages/protocol/src - Tests cover key functionality
  • bun run check-types from packages/protocol - TypeScript compilation

Recommendation: ✅ Approve with minor nit

The code is production-ready. The inline comment is optional formatting fix.


return null;
}
const ts = Number(tsRaw);
if (!Number.isFinite(ts)) {return null;}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Formatting: Add space before opening brace for consistency with project style guide.

Suggested change
if (!Number.isFinite(ts)) {return null;}
if (!Number.isFinite(ts)) { return null; }

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.

2 participants