Skip to content

Add protocol v1.1.0 schema validation and tooling#4

Merged
GsCommand merged 1 commit into
mainfrom
claude/audit-protocol-infrastructure-vF6oo
May 12, 2026
Merged

Add protocol v1.1.0 schema validation and tooling#4
GsCommand merged 1 commit into
mainfrom
claude/audit-protocol-infrastructure-vF6oo

Conversation

@GsCommand
Copy link
Copy Markdown
Contributor

Summary

This PR introduces protocol v1.1.0 support with structured receipt schema validation, two new diagnostic tools, and comprehensive test coverage. The server now validates receipt structure at the MCP layer before proxying to the runtime, and provides tools for clients to discover protocol capabilities and validate receipts without cryptographic verification.

Key Changes

  • New receipt schema (src/lib/receiptSchema.js) — Zod-based validation for the v1.1.0 receipt format with strict proof field validation (canonical, alg, signature, kid, signer_id). Reused by both verify_receipt input validation and the new validate_receipt_schema tool.

  • New tools:

    • get_protocol_version — returns protocol version (1.1.0), signing spec, canonicalization method, proof field names, and schema host URL
    • validate_receipt_schema — validates receipt structure without cryptographic verification; returns structured field-level errors for development/debugging
  • Tool registration refactored — tool definitions now declared at module level (TOOL_DEFS) so Zod schemas and handler references are evaluated once at startup rather than per-request. New McpServer instance still created per request to avoid transport collision under concurrent load.

  • Breaking change: Default verify path corrected from /api/verify to /verify to match the runtime server's actual endpoint. Configurable via COMMANDLAYER_VERIFY_PATH.

  • Dead code removed:

    • src/lib/receiptVerifier.js — implemented a 4th incompatible receipt format (payload/signer/hash/signature) never called by any tool
    • src/lib/canonicalize.js — duplicate implementation only imported by receiptVerifier; canonical implementation lives in @commandlayer/runtime-core
  • Test suite (test/tools.test.js) — 11 unit tests covering all tool handlers (no network required). Tests validate schema acceptance/rejection, capability filtering, and error handling.

  • Documentation:

    • CHANGELOG.md — detailed v1.1.0 release notes with breaking changes
    • SECURITY.md — security model, rate limiting guidance, and known limitations
    • .env.example — environment variable reference
  • CI/CD — GitHub Actions workflow (.github/workflows/ci.yml) runs tests on every push and PR.

  • Version bump — package.json and health endpoint updated to 1.1.0.

Implementation Details

  • Receipt validation uses Zod's safeParse() to return structured errors with field paths and codes, enabling clients to provide precise feedback.
  • Proof schema enforces canonical: 'json.sorted_keys.v1' and alg: 'ed25519' as literals to reject pre-v1.1.0 field names at the MCP boundary.
  • validate_receipt_schema is intentionally non-cryptographic — it validates structure only and must not be used as a security gate.

https://claude.ai/code/session_0112Taq5ne2BieC3hfqjjf3r

…I/tests/docs

Critical fixes:
- Fix COMMANDLAYER_VERIFY_PATH default: /api/verify → /verify (matches runtime)
- Remove dead receiptVerifier.js (4th incompatible receipt format, never called)
- Remove unused canonicalize.js (only imported by the now-dead receiptVerifier)
- Add shared receiptSchema.js with Zod v1.1.0 receipt schema (new field names)
- verify_receipt tool now validates receipt structure before proxying (was z.any())

Architecture improvement:
- Tool definitions moved to module level; server still created per-request to
  avoid concurrent-request transport collision, but schemas/handlers defined once

New tools:
- get_protocol_version: returns signing spec, canonicalization, schema host
- validate_receipt_schema: validates receipt structure without crypto (dev tool)

Infrastructure:
- Add test/tools.test.js with unit tests for all tool handlers
- Add .github/workflows/ci.yml
- Add .env.example documenting all env vars
- Add SECURITY.md, CHANGELOG.md
- Bump version to 1.1.0
- Health endpoint now returns version
@GsCommand GsCommand merged commit 3fd8e4c into main May 12, 2026
1 check passed
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.

1 participant