phase 3: wire protocol foundation (ARCP + TLS 1.2 + HMAC + real-VM round-trip) - #1
Conversation
…und-trip) docs/PROTOCOL.md spells out the framing, envelope shape, HMAC canonicalization, and TLS configuration. Go (internal/arcp, internal/transport) and Python (agent/arcp.py) implementations produce byte-identical canonical/sig/framed bytes for every envelope in the shared corpus (tests/protocol_corpus.json). Real-VM round-trip against the live XP VM (Windows XP SP3, Python 3.4.10, OpenSSL 1.0.2k) succeeds for ping, session.open, tool.invoke, stream.chunk, and log message types using ECDHE-RSA-AES256-GCM-SHA384. R1/R8 (TLS-on- Python-3.4) risk in docs/ARCHITECTURE.md is closed. What landed: * docs/PROTOCOL.md (v0 spec) and docs/sessions/phase-3-roundtrip.md (session log). * internal/arcp: typed Envelope, sorted-key canonical JSON, HMAC-SHA256 sign/verify, length-prefixed framing (4-byte BE length, max 50 MiB), Crockford-base32 IDs, RFC 3339 microsecond timestamps, full v0 message- type constant table. 47 unit + corpus tests. * internal/transport: TLS 1.2 dial with self-signed cert fingerprint pinning via VerifyConnection; RSA cipher suites confirmed working on the VM. * agent/arcp.py: Python-3.4-compatible mirror; corpus parity verified. * agent/scripts/echo_server.py + cmd/xpc-roundtrip: Phase 3 verification client/server. * cmd/gen-corpus: regeneratable golden corpus (six representative envelopes). * TASKS.md and CHANGELOG.md updated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (27)
📝 WalkthroughWalkthroughThis PR completes Phase 3 by implementing the xpc v0 wire protocol specification with byte-identical Go and Python libraries, TLS 1.2 transport with certificate fingerprint pinning, canonical JSON signing with HMAC-SHA256, and comprehensive corpus parity testing validated on a real Windows XP VM. ChangesPhase 3 Wire Protocol Foundation
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6dc1ebf8f5
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return json.dumps( | ||
| value, | ||
| sort_keys=True, | ||
| separators=(",", ":"), | ||
| ensure_ascii=False, |
There was a problem hiding this comment.
Reject non-finite floats in canonical JSON
canonical_marshal calls json.dumps without allow_nan=False, so payloads containing NaN/Infinity are serialized as non-standard JSON tokens. That violates the protocol’s RFC 8259 requirement and breaks Go/Python interoperability because Go’s encoder rejects non-finite floats; a Python sender can emit frames that the Go side cannot marshal/verify consistently.
Useful? React with 👍 / 👎.
| body = read_raw(stream) | ||
| if body is None: | ||
| return None | ||
| return json.loads(body.decode("utf-8")) |
There was a problem hiding this comment.
Validate decoded envelopes before returning them
read_frame returns json.loads(...) directly and never calls validate, so malformed envelopes (for example, missing id or timestamp) are treated as successfully decoded frames. In this commit’s server flow, such messages can still pass verify_sig and reach business logic, which diverges from the Go path (ReadFrame -> Unmarshal -> Validate) and allows protocol-invalid inputs to be processed.
Useful? React with 👍 / 👎.
Summary
Closes Phase 3 per
MASTER.md§7. Real-VM round-trip succeeds against thelive XP VM (Windows XP SP3, Python 3.4.10, OpenSSL 1.0.2k); see
docs/sessions/phase-3-roundtrip.mdfor the captured log.docs/PROTOCOL.md— v0 wire spec (framing, envelope shape, HMACcanonicalization, TLS configuration, all v0 message types).
internal/arcp— Go side: typedEnvelope, sorted-key canonical JSON,HMAC-SHA256 sign/verify with constant-time compare, length-prefixed
framing (4-byte BE length, 50 MiB cap), Crockford-base32 IDs, RFC 3339
µs timestamps. 47 unit + corpus tests.
internal/transport— TLS 1.2 dial with self-signed cert fingerprintpinning via
VerifyConnection. RSA cipher suites confirmed working onthe VM's Python 3.4 OpenSSL 1.0.2k build.
agent/arcp.py— Python-3.4-compatible mirror. Byte-for-byte paritywith Go enforced by
tests/protocol_corpus.json.cmd/gen-corpus,cmd/xpc-roundtrip,agent/scripts/echo_server.py—generator + Phase 3 verification client/server.
R1/R8 (TLS-on-Python-3.4) risk in
docs/ARCHITECTURE.mdis now closed.Test plan
go test -race ./...green (47 tests acrosscmd/xpc,internal/{arcp,transport,version}).golangci-lint runclean (0 issues).pytest agent/tests/green (34 passed, 2 skipped).bytes in Go and Python.
xp-truvoice-w02:9579(5/5 casesOK: ping, session.open, tool.invoke, stream.chunk, log).
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests
Documentation