feat: handshake codegen — IR_HASH + connect / serve helpers - #6
Merged
Conversation
For a schema with a `protocol`, the generated `.rs` now carries: - `pub const IR_HASH: u64` — a deterministic fingerprint of the schema's frozen units (FNV-1a over their Debug form). Stable per generator version; a generator bump changes it, which is correct. A canonical cross-language hash from core's CAS (threaded through GenRequest) is the eventual form — noted in the code. - `<Proto>Client::connect(transport, format) -> Result<Self, RuntimeError>` — wraps `Client::connect` with `Handshake::new(IR_HASH, format.name(), FRAMING_DATAGRAM, 0)`. - `<Proto>Dispatcher::serve(self, transport, format)` — builds a `Server` and calls `serve_handshaked` with the same handshake. `<Proto>Client::new` / a bare `Server::serve` still work for "misaligned mode". Bumps the generated crate's comline-runtime pin to the rev with the handshake (runtime#8). tests/generate.rs: the IR_HASH const + both helpers are emitted for a protocol, and neither IR_HASH nor any comline_runtime reference appears for a protocol-less schema. tests/compiles.rs already builds a protocol crate against comline-runtime, so it now covers the helpers too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The codegen half of runtime#8. A schema with a
protocolnow also emits:ChatClient::new/ a bareServer::servestill work for "misaligned mode".IR_HASHis FNV-1a over the frozen units'Debugform — deterministic per generator version; a generator bump changes it, which is correct (different codegen ⇒ different handshake identity). A canonical cross-language hash fromcore's CAS, threaded throughGenRequest, is the eventual form (noted in the code). Only emitted when the schema has a protocol.Bumps the generated crate's
comline-runtimepin to the handshake rev.Tests
tests/generate.rs—IR_HASH+ both helpers for a protocol; noIR_HASH/comline_runtimefor a protocol-less schema (8 string tests).tests/compiles.rsbuilds a protocol crate againstcomline-runtime, so the helpers compile too. Clippy clean.Follow-up
A
cliPR: switch the end-to-end test's driver toChatClient::connect/ChatDispatcher::serveso the handshake runs through the real pipeline.