feat: generate the RPC shape for a protocol (surface 4.2) - #2
Merged
Conversation
`code` mode now emits, per FrozenUnit::Protocol, everything the runtime's surface-4 contract needs -- turning the hand-written stand-ins in comline-runtime's dispatch_roundtrip / client_roundtrip tests into real generator output: - one params struct per function that takes args (<Proto><Fn>Params) - one schema-only error enum per function from its `throws` ordinals (<Proto><Fn>Error; empty when it throws nothing), resolved against the FrozenUnit::Error units' `ordinal` -- local or a re-exported import - a per-protocol union <Proto>Error + From<<Fn>Error> impls - the provider trait `pub trait <Proto>` (sync, schema errors only) plus `pub const <PROTO>_CALLS: &[&str]` - <Proto>Dispatcher<S> impl comline_runtime::contract::Dispatch -- an index jump table, decode params, run the handler, frame the ok/err Envelope - <Proto>Client<T, W> wrapping comline_runtime::client::Client -- one method per function returning Result<R, CallError<<Fn>Error>> FrozenUnit::Error also gets struct codegen now (it was skipped entirely). KindValue::Unit and a no-return function both render `-> ()` for now (true one-way / fire-and-forget is a runtime feature, not built yet). Params are owned (String / Vec<T>); borrowed `<'de>` generated types are a follow-up. `Function.parameters` (per-call settings) not consumed yet. lib mode's generated Cargo.toml git-deps comline-runtime when any schema has a protocol. tests/compiles.rs generates a lib crate for a protocol (throwing call, list return, zero-arg call, unit return) and `cargo build`s it against comline-runtime -- string assertions can't prove it compiles. Plus expanded string-match coverage in tests/generate.rs.
This was referenced Sep 1, 2026
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.
codemode now emits, perFrozenUnit::Protocol, everythingcomline-runtime's surface-4 contract needs — turning the hand-written stand-ins in the runtime'sdispatch_roundtrip/client_roundtriptests into real generator output.What's emitted
pub struct <Proto><Fn>Paramsper function that takes args (owned fields)pub enum <Proto><Fn>Errorfrom the function'sthrowsordinals — resolved against theFrozenUnit::Errorunits'ordinal(local or a re-exported import, core#47); empty enum when it throws nothingpub enum <Proto>Error∪ every!in the protocol +From<<Fn>Error>implspub trait <Proto>— sync,&self,Result<R, <Fn>Error>(schema errors only) +pub const <PROTO>_CALLS: &[&str]<Proto>Dispatcher<S>implcomline_runtime::contract::Dispatch— index jump table → decode params → run handler → frame the ok/errEnvelope<Proto>Client<T, W>wrappingcomline_runtime::client::Client— one method per fn →Result<R, CallError<<Fn>Error>>FrozenUnit::Errorgets struct codegen too now (it was skipped entirely before).libmode's generatedCargo.tomlgit-depscomline-runtimewhen any schema has a protocol.Deferred (noted in code)
<'de>) — params are owned (String/Vec<T>) for now._return: NoneandKindValue::Unitboth render-> ()(request/response with an empty ack); fire-and-forget is an unbuilt runtime feature.Function.parameters(per-call settings) — not consumed yet.Tests
tests/compiles.rs— generates alibcrate for a protocol (throwing call, list return, zero-arg call, unit return) and actuallycargo builds it againstcomline-runtime(string assertions can't prove it compiles). Plus expanded string-match coverage intests/generate.rs.cargo test --workspacegreen (1 + 5 + doctests).Follow-up
The
generationconformance corpus'sprotocolgolden will need a re-bless once this lands (separate PR — bump itscomline-codegen-rustrev,CONFORMANCE_BLESS=1).