Repository navigation
A Hello built from what an end provides and calls, and provide refusing what the handshake didn't accept - #126
Merged
Merged
Conversation
added 2 commits
November 17, 2026 01:20
Vendors ComlineProject/specification at 3254e0e (#19). It adds seven `handshake-comline2` cases for a Hello that lists some of the package's protocols: `hello-subset`, `offer-subset-offered`, `offer-subset-local`, `conclude-subset`, `conclude-answer-beyond-offer`, `symmetric-subset-local` and `finish-refused-unlisted`. No existing case changes. The vectors are written by the reference (`conformance/src/comline2.rs`), which gains the cases; the re-vendored file is byte-identical to what it blessed, and the report lists them.
…shake didn't accept A Hello can list some of the package's protocols (named connections, core#288): what an end provides plus the ones it calls. - `Hello::build(header, provided, called)` puts a Hello together from a `HelloHeader` (exchange, package id, version, encodings) and the `ProtocolEntry`s of what the end provides and calls, in `canonical()` order, each protocol once. A generator emits the header and the entries as constants and passes the ones it wants. With every protocol among them the bytes are the whole Hello's. - `Negotiated::accepts` / `check_provide`: whether the handshake accepted a protocol, that is its result holds it and it isn't refused. The protocols whose calls already fail locally (`check_call`). - `Handshake` / `AsyncHandshake` gain `agreed()`, `None` unless the handshake negotiates per protocol (`comline@2`). `connect_with` / `accept_with` keep it on the connection. - `Connection::provide` and `AsyncConnection::provide` return `Result` and refuse, with `RuntimeError::Unavailable`, a protocol the handshake didn't accept: one the Hello didn't list, or one the peer refused. Without a Hello (`comline@1`, `none`, `new_unverified`) there is nothing to check against and they take any protocol. Direction isn't checked: an entry carries none, so the generated code checks it. Tests: the Hello built whole is the specification's `hello` bytes however the protocols are split, and a subset is `hello-subset`; both refusals on blocking and async connections in both exchanges; no check without a Hello; and calls to a protocol outside the result fail locally with nothing written.
Kinflou
marked this pull request as ready for review
November 16, 2026 18:47
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.
Closes #124. Part of the epic ComlineProject/core#288 (connections with a subset of the package's protocols), on the decisions in docs#186 and the review settled in docs#188.
Two commits. The first re-vendors the specification; the second is the runtime.
Re-vendors the specification at
3254e0e(specification#19, spec 0.12). It adds sevenhandshake-comline2cases:hello-subset,offer-subset-offered,offer-subset-local,conclude-subset,conclude-answer-beyond-offer,symmetric-subset-localandfinish-refused-unlisted. The reference (conformance/src/comline2.rs) writes them; the vendored file is byte-identical to what it blessed, sovectors_are_currentholds. No existing case changes (checked by id: seven added, none removed or changed).A Hello for a subset.
HelloHeader(exchange, package id, version, pre-release, encodings) andProtocolEntry(number, line, shape hash, function numbers) are the structured pieces a generator emits as constants.Hello::build(&header, provided, called)lists the union of the two sets, each protocol once (the first entry for a number), incanonical()order. The header's encodings and each entry's functions are sorted and deduplicated.hellovector's bytes from every split of its two protocols, in either order, listed twice, with the functions scrambled, andhello-subset's from protocol 1 alone.providerefuses what the handshake didn't accept.Negotiated::accepts(protocol): this end's result holds it and it isn't refused. That is the set whose calls already fail locally.check_providereturnsRuntimeError::Unavailablefor the rest.HandshakeandAsyncHandshakegainagreed(),Noneby default;Comline2Handshakereturns itsnegotiated().connect_with/accept_withkeep it on the connection. Nothing to change for a custom handshake.Connection::provideandAsyncConnection::providenow returnResult<(), RuntimeError>and check it. Without acomline@2Hello (comline@1,none,new_unverified) nothing is checked and they take any protocol, as today.Unavailable, which is already what a protocol outside the result gives a call. A caller that wants the reason reads theNegotiatedit holds (the generatedNegotiationhas it).@provider.Breaking, on purpose.
providereturned(); it returns aResultnow, so a generatedprovide_onthat ends inconn.provide(..)stops compiling at the next bump until it returns theResult. That belongs to the generators (comline-rust#133); the call sites in this repository's tests are updated. JSON-RPC (comline@1) is untouched.Senders. Confirmed in comline-rust's generator: sync and async senders both call the generated
check_callbefore writing a request, which isNegotiated::check_call, and a protocol the result doesn't hold isUnavailable. The runtime-side test below holds the contract (the specification's ops can't ask about it; specification#20 may make these cases).Tests (
core/tests/comline2_subset.rs):hellovector's bytes however the protocols are split, a subset ishello-subset, encodings reach the wire in order, and the header's version and exchange are the Hello's;unknown_protocol, one refused for a line mismatch, and accepts the rest, on a blocking and an async connection, in both exchanges;new_unverifiedorcomline@1, blocking and async;Unavailableand writes nothing to a counting transport; one the Hello listed is written.Not run locally; CI is the check.