Repository navigation
feat(core): gossip directory, self-advert and extension rules in the Rust session - #438
Merged
Merged
Conversation
…e fails to start `serving()` started the hub, spawned the Rust node and awaited its output before the caller's try, so a rejection there left the child running and the hub listening. It now stops the node, closes the peer and the hub itself and rethrows, and a case that forces a failure after the node has announced asserts that no process and no listener is left. The build call also sets `maxBuffer`, since it prints a JSON line per artefact and the default limit is easily passed.
…lf-advert `domain::gossip_extensions` refuses an extension key that would shadow a mandatory advert field, the session-managed topology or the reserved version key, or that is not `<domain>/<field>` in lowercase kebab-case. `domain::gossip_directory` verifies each advert of a gossip frame alone and keeps the newest advert per device by its signed snapshot time, in first-heard order. It is bounded in devices and in the size of an advert, and refuses beyond either without evicting. `domain::self_advert` builds and signs this node's own advert with its version and its topology.
`SessionOptions` carries a relay client, gossip, or both into `Session::accept_with`. A session that gossips sends its own signed advert after its handshake, verifies each advert it receives and keeps the newest per device in a directory (`Session::directory`), and reports `DirectoryChanged` and `AdvertRefused` events. `send_gossip_update` sends a fresh advert with extensions the caller's validated keys. A peer that sends no handshake within the timeout is reported as `HandshakeUnanswered`, which is what a relay-only hub produces, and every session answers `version.get` without a handler.
…ementations `gossip-directory.v1.json` holds the extension rules, the directory scenarios and the self-advert structure, with adverts really signed under fixed keys. Both runners read it, and the interop test gains a case where the Rust node learns a TypeScript peer from the hub's gossip and its own advert verifies there.
…refusals once per frame The directory checks size, snapshot range, an older advert for a known device and a full directory before it verifies a signature, so replayed or flooding adverts cost no signature check. A frame yields one `AdvertsRefused` event with the count and the first refusal, and one `DirectoryChanged` per distinct device, so its size no longer sets the number of events. A self-advert is refused for a clock before 2001, which is not a wall clock. The example reads the system clock, and the docs say what a full directory and a replayed first advert do.
Mearman
force-pushed
the
feat/rust-gossip-directory
branch
from
November 26, 2026 10:52
3026b45 to
c30daff
Compare
Mearman
marked this pull request as ready for review
November 26, 2026 11:00
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.
Merging publishes a patch of
wire-mesh-corewith no change to its content (a test file underts/packages/core/testchanges), plus the range rewrites of the packages that depend on it; nothing fromrust/is published.Gives a Rust session the gossip role: it sends its own signed advert after its handshake, verifies each advert it receives and keeps the newest per device in a peer directory, and answers
version.getwithout a handler. Fixes #376. Refs #432.The rules the TypeScript session applies are ported as three modules, each with a test that fails by name when its rule is broken:
gossip_extensionsrefuses an extension key that would shadow a mandatory advert field, the session-managed topology or the reserved version key, or that is not<domain>/<field>in lowercase kebab-case, and names the first key refused.gossip_directoryverifies every advert on its own, so one that does not verify is dropped alone. The newest advert per device wins by its signed snapshot time, never by arrival, and a re-advert replaces in place, so the directory keeps first-heard order. Unlike the TypeScript it is bounded, since adverts come from a hub that is not trusted to bound them: a device count and an encoded size per advert, refused and not evicted beyond either (a full directory stays full until the session ends). The decisions that need no signature (size, snapshot range, an older advert, a full directory) come before the signature check, so replayed or flooding adverts cost no verification. A frame yields oneAdvertsRefusedevent with the count and the first refusal, however many adverts it carries.self_advertbuilds and signs the node's own advert with its version and its topology, recomputed on every call, and refuses a clock before 2001, which is not a wall clock. The first advertised peer is taken as the direct peer only on an accepted connection; the connection port has no authenticated peer, so a peer that first sends a genuine advert of another device makes the node's adverts name that device as direct, a misstated edge and nothing more, which an authenticating transport removes.Session::accept_withtakesSessionOptionsfor a relay client, gossip, or both. A peer that sends no handshake within the timeout is reported asHandshakeUnanswered, which is what a relay-only hub produces and not an error.conformance/gossip-directory.v1.jsonis new and both implementations run it: the extension rules, the directory scenarios and the self-advert structure, with really signed adverts under fixed keys. The size cap is a scenario only the Rust runner applies. The interop test gains a case where the Rust example joins the TypeScript hub, learns a TypeScript peer from the hub's gossip, and its own advert verifies there and names its version.The first commit is the cleanup the interop review asked for: a case that fails to start no longer leaves the relay peer process or the hub listener behind, and the build output limit is a named constant.
Not in this change: the per-request refusal (#428), and the unbounded events queue and the task per manage-request (#431, whose scope now includes the gossip events).