Skip to content

serve and connect take a subset of the provided protocols - #179

Draft
Kinflou wants to merge 4 commits into
mainfrom
feat/serve-connect-subset
Draft

Kinflou wants to merge 4 commits into
mainfrom
feat/serve-connect-subset

Conversation

@Kinflou

@Kinflou Kinflou commented Nov 16, 2026

Copy link
Copy Markdown
Member

Closes #173

The TypeScript counterpart of comline-rust#133, the smaller step accepted in Named connections: a side provides a subset of its protocols, and the Hello is built from what it gives plus the protocols it calls.

API

  • Services and ClientServices take an optional field per protocol. serve(transport, { chat }) and connect(transport, { events }) are written as before; leaving a field out stops providing that protocol. connect's services default to {}.
  • Under comline@2 the Hello is built when a connection opens: the protocols given, plus the ones this side calls (every protocol the other side provides, so the peer refuses what it doesn't have). A protocol both provided and called is listed once.
  • @comline/runtime gains buildHello(header, provided, called) (mirrors Hello::build: union, each protocol once, ascending by wire number), ProtocolEntry, providedEntries, Negotiated.accepts / checkProvide, and an optional Handshake.agreed() that Connection.connect / accept keep.
  • Connection.provide refuses, with RuntimeError("unavailable") naming the protocol by wire number (#2), a protocol the comline@2 handshake didn't accept: one this end's Hello didn't list (unknown_protocol), or one the peer refused. A connection with no Hello (comline@1, none, Connection.unverified) takes any protocol. Direction isn't checked in the runtime; the generated code only provides what Services holds.
  • Generated connection.ts emits HELLO_HEADER and a SERVICES_HELLO / CLIENT_SERVICES_HELLO table of entries (from facts::hello_parts) instead of the one HELLO. JSON-RPC and none packages get optional fields and fewer dispatchers, nothing else.

Pins and vendored files

  • generation 37ed342 to 99187d7 (rev = lines only); core stays at 69039e7.
  • Specification 3254e0e (0.12) and the core at runtime e736221 (CORE_REV and SPEC_REV move together; vendor-core.sh --check rebuilds the same bytes). The TypeScript conformance harness marks handshake-comline2 unsupported (the cases run on the core), so nothing there runs them; test/hello-build.test.ts checks buildHello against the vendored hello and hello-subset cases instead.

Goldens

  • New: connections_subset (4 files), FEATURES.md / features.json list it as proof of protocols, connections, datagram@3, comline@2 and others.
  • Changed: only the connection.ts of the 14 fixtures with a package connection (and the same for the runtime's generated test fixtures): the Hello constants, optional fields and provide lines. No other golden moves.
  • test/wire-invariance.json only gains the new subset/ fixture: every existing fixture's whole-connection Hello, rebuilt from the header and entries, is the same bytes as before.

Not in this PR

Narrowing what a side calls (the decision lets a side list the protocols it calls; this builds the default, all of them). A failed provide in accept / connect rejects, and leaves the connection to be closed by its transport since the runtime has no close().

Kinflou added 3 commits November 17, 2026 03:05
facts::hello_parts: a Hello's pieces per protocol, to be put together at
runtime from what an end provides and calls. The core pin stays at 69039e7.
The specification's seven comline@2 cases for a Hello that lists a subset of
the package's protocols (3254e0e), and the core that proves them: SPEC_REV and
CORE_REV move together. scripts/vendor-core.sh --check rebuilds the same bytes.
Services and ClientServices take a field per protocol, each optional; connect's
services default to none. Under comline@2 the Hello is built when a connection
opens, from the protocols given plus the ones this side calls (every protocol
the other side provides), by the runtime's buildHello, from the header and the
per-protocol entries the generator emits from facts::hello_parts. With every
protocol provided the Hello is the bytes the package embedded before: the
wire-invariance record doesn't move.

The runtime's Connection.provide refuses, with RuntimeError("unavailable"), a
protocol the comline@2 handshake didn't accept (one this end's Hello didn't
list, or the peer refused); a connection with no Hello takes any protocol, as
in the Rust runtime (runtime#126).

Blesses connections_subset, and the connection.ts of every fixture that has a
package connection: the Hello constants, the optional fields and the provide
lines are the only changes to them.

Closes #173
@Kinflou Kinflou added codegen Code generation enhancement New feature or request labels Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen Code generation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

serve and connect that take a subset of the provided protocols

1 participant