Skip to content

feat(schemas): encode the wire protocol as Zod single-source-of-truth - #6

Merged
Mearman merged 3 commits into
mainfrom
feat/protocol-schemas
Sep 12, 2026
Merged

Mearman merged 3 commits into
mainfrom
feat/protocol-schemas

Conversation

@Mearman

@Mearman Mearman commented Sep 12, 2026

Copy link
Copy Markdown
Member

Summary

  • All verified protocol shapes become Zod schemas with attached .is() guards: key files, registry entries, envelope grammar, auth lines, user frames, and every control frame (receipts with the drop taxonomy, idle subscriptions, the yield family).
  • Domain layer: canonical-order envelope builder/parser with the receiver's round-trip invariant, hop-chain guards (runaway > 28, loop >= 10 own tokens), id generation.
  • JSON Schema draft 2020-12 artifacts generated from the same schemas, published as ./schemas/*.schema.json.
  • docs/PROTOCOL.md: the full implement-it-yourself reference.
  • Envelope round-trip tested against a frame captured verbatim from live Claude Code 2.1.269 traffic.

Test plan

  • vitest: 14 tests green (envelope round-trip, canonical order, escaping idempotence, hop-chain edges)
  • eslint + tsc green; attw clean
  • CI verify passes

pnpm's strict node_modules layout does not expose semantic-release's
built-in plugin subpaths (semantic-release/commit-analyzer and
semantic-release/release-notes-generator), so the release job failed
with MODULE_NOT_FOUND. Install both plugins as devDependencies and
reference them by package name instead.
Every verified protocol shape becomes a schema with an attached .is()
guard (defineSchema): key files, registry entries, the envelope attribute
grammar with its canonical order and charsets, auth lines, user frames
with file attachments, and all control frames (peer_message_status
receipts with the drop taxonomy, notify_when_idle / peer_idle_notice,
the yield_artifact_replies family). Protocol limits live in limits.ts as
named constants derived from the receiver's own grammar.

Domain layer: envelope builder/parser mirroring the receiver's regex
including the rebuild-and-compare round-trip invariant (bodies stay in
escaped form; escaping is idempotent), hop-chain utilities replicating
the admission guards (runaway > 28, loop at >= 10 own-token hits), and
id generation. The envelope round-trip test fixture is a frame captured
verbatim from live Claude Code 2.1.269 traffic.

The JSON-Schema generator now emits draft-2020-12 documents for all
eleven schemas, published as ./schemas/*.schema.json subpath exports.
docs/PROTOCOL.md carries the full verified wire reference: transport and
identity, key-file auth classes, user and control frames, envelope grammar,
the consent model, peer registration and roster admission, the receipt
status table with the drop taxonomy, idle subscriptions, guard rails with
hop-token derivation, artifact_yield, file transfer up to its upstream
flag, cloud/bridge routing, and the daemon - with verification status
separating live-confirmed behaviour from evidenced boundaries.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 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-12T19:38:18.289232Z 3b5f7d3 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.

@Mearman
Mearman merged commit 250cbd2 into main Sep 12, 2026
2 checks passed
@exaclaude

exaclaude Bot commented Sep 12, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@exaclaude exaclaude Bot added the released label Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant