logs.gokuls.in

9 pull requests merged across 3 repos

Offline-Protocol/offline-protocol-sdk

The first two-device run of the browser lobby (laptop Chrome and an Android phone, docs/bridges/web-devices.md) found a player page that kept reading "Joined the game" over a frozen court after the phone went to the background or locked its screen. That is the case the checklist says must not happen. This PR fixes it and the holes the run found on the way back.

  • The carrier reports each connection's state. WebRtcCarrier is now an EventTarget and dispatches a connection event for "connected", "disconnected" and, once, "closed", naming the object offer() or answer() resolved to. A connection still closes only on "failed": "disconnected" may recover, and closing there would turn a Wi-Fi blip into two new codes typed by hand. Chrome reaches "failed", and the engine reports the peer lost, 10 s after "disconnected", so a page can now warn that much earlier.
  • Both sides of the lobby show the loss. The page only handled neighbor_lost while hosting. Both roles now track live links, show "connection unstable" from the carrier, then say the other device disconnected and what to press to carry on.
  • A device with a durable session is invited. A restored session fires no secure_session_established, so a device that already had a session with the host (a returning guest, or a host and player that swapped roles) was never invited or listed. The host now invites on a proved link as well, and lets a member back in on its link with no invite. Found by running the phone-hosts direction.
  • A reloaded host resumes its game. It used to make a new group the other player was not in. The host's game is remembered per profile; End this game forgets it.
  • Game state is ephemeral. The host kept sending reliable states while the other player was gone, so about 30 stale states landed in the first second of the next link. State and paddle are now ephemeral sends (ADR 0032), the host sends only while a member has a link, and the paddle is resent once a second so a reloaded host learns where it is. Host store flushes drop from about 40 a second to about 22.

No Rust, UDL or wire change.

Testing

  • bash bindings/web/scripts/test-browser.sh: 15 of 15 pages pass in Chromium, Firefox and WebKit. webrtc.html now asserts that "connected" and "closed" arrive and name the connection offer() returned. Negative control: with the "closed" report removed, webrtc.html fails at its loss step.
  • Device run on a MacBook (Chrome 155) and a Samsung Galaxy M36 (Android 16, Chrome 152), in both directions, recorded in docs/bridges/web-devices.md:
  • link 40 to 110 ms after Connect, 10 states a second each way, touch and arrow-key paddles cross;
  • the player and then the host reloaded, each the same address, the host still hosting, play resumed with no second invite;
  • background and screen lock, with either device hosting: both pages showed "connection unstable" 11 to 13 s after the phone left the screen and the disconnect 10 s later; the host sent nothing while apart; two new codes resumed play at 10 states a second with no backlog;
  • a second tab on the same account is still refused.

Not covered

  • Unlocking the phone by hand after the lock: it has a secure lock screen. The relink after the lock was driven behind it.
  • iPhone Safari, and the "disconnected" timing on Firefox and Safari, which were not measured on devices.

What

  • Three engines. bindings/web/scripts/test-browser.sh now runs every page in bindings/web/test in Chromium, Firefox and WebKit through Playwright 1.64.0 (pinned, with a lockfile). This replaces the Chrome-only DevTools runner. BROWSERS narrows the run.
  • Storage conformance in a real browser (C11). New crates/offline-protocol-web/tests/browser_conformance.rs runs both conformance suites against the log store over real OPFS sync access handles, in a dedicated worker (wasm-bindgen-test, run_in_dedicated_worker). It also reopens the store after enough writes to compact several times. bindings/web/scripts/test-conformance.sh runs it in Chrome and Firefox via WebDriver.
  • MLS suite on targets with no threads. On wasm without atomics, concurrent_writes_land_whole runs its writers in turns on one thread instead of failing with "could not start a writer thread". Hosts are unchanged.
  • Two-device checklist. New docs/bridges/web-devices.md covers examples/web-lobby on laptop ↔ Android Chrome and laptop ↔ iPhone Safari: serving over HTTPS or adb reverse, the steps, and a results table.
  • CI. The web-binding job installs Playwright and the three engines, runs the pages, then runs the conformance test with the runner image's ChromeDriver and geckodriver. the_browser_tests_run_in_ci pins both new steps. Dependabot now watches bindings/web.

Bug found by the new coverage

OfflineNode.start awaited navigator.storage.persist(). Firefox answers that call with a permission prompt, and the promise stays pending until the user responds. As a result, every durable start in Firefox waited on the doorhanger, and a headless Firefox never started at all. I confirmed the promise is still pending after 5 s. The request is now made without waiting for the answer (bindings/web/src/index.js).

Verification (local, macOS arm64)

  • test-browser.sh: 15/15 (5 pages × 3 engines) on three consecutive runs. Before the persist() fix, Firefox timed out on the 4 durable-storage pages.
  • On the very first three-engine run, WebKit failed webrtc.html and nostr-signal.html at "secure_session_established". That has not reproduced in 6 runs since (3 WebKit-only, 3 all-engine). A bare negotiated data channel connects in Playwright WebKit. WebKit on the Linux runner is the open question: WebKit has no switch to turn off mDNS .local host candidates.
  • test-conformance.sh: 3/3 in Chrome 155 (ChromeDriver 155) and 3/3 in Firefox 158 (geckodriver 0.36.0).
  • Negative controls on the conformance test:
  • Writing every OPFS write at offset 0 fails the reopen test, which is expected; the suites alone stay green, which is why the reopen exists.
  • Mutating the read offset is an equivalent mutant, because the store reads whole files at offset 0.
  • cargo clippy --workspace -D warnings, cargo fmt --check, cargo deny check, shellcheck: clean. Tests for offline-protocol-mls, offline-protocol and offline-protocol-web: all pass.

Not covered

  • Conformance in WebKit or Safari: safaridriver needs a one-time sudo safaridriver --enable, and there is none on Linux.
  • The two-device checklist has not been run yet; its results table is empty.

Docs, plus one lockfile bump to clear a new advisory. Brings the browser documentation in line with what #608 to #611 built, and corrects two claims in ADR 0032 that the code does not support.

  • ADR 0032 cadence. The ADR said a rung goes out about every 25 seconds at 10 Hz. note_group_generation resets the count on every send that reaches every member, so a rung goes out only after 256 sends in a row that missed somebody, plus the first send in a process.
  • ADR 0032 hold. The ADR said a linked member whose carrier refused the rung is "then unlinked and held". record_ephemeral_rungs skips every member linked before the send, so that member is never held, and nothing holds it on relink.
  • ADR 0032 dead rung. New consequence: a rung that arrives behind more than 32 newer frames is too far in the past to decrypt, is never acknowledged, is retried until MessageFailed, and holds that member out of ephemeral frames meanwhile.
  • docs/bridges/web.md. "What is not built yet" gains the dead-rung item and the unpublished package (npm package private, crate never released).
  • README. The bindings line and install table list the experimental browser build, marked unpublished.
  • bindings/web/src/index.js. The signalEvent doc comment now names the freshUntilMs field the worker returns.

Also: tokio 1.52.3 to 1.54.1

The Dependency Audit job went red on this PR from an advisory published today, RUSTSEC-2026-0386 (tokio AsyncFd safe constructors accept any raw descriptor). It would fail on main too. cargo update -p tokio moves the lockfile to 1.54.1 (MSRV 1.85, under the workspace's 1.87). Nothing in the workspace constructs an AsyncFd, and tokio reaches the graph as a dev dependency of offline-protocol-mls. No tool lockfile contains tokio.

Not in this PR

  • The three Unreleased CHANGELOG Fixed entries describe unreleased code; they fold into Added at the 0.31.0 cut.
  • The non-finite freshUntilMs guard in hold() and wider margins in the session-hold page step are code changes.
  • Reserving offline-protocol-web on crates.io (still 404) before the next tag.

Validation

  • No guard test reads any edited file.
  • No em dashes in added lines.

Fixes the three non-blocking items left after the #610 review.

What changes

  • The host holds a signalling session while its offer is fresh. The host forgot a session 120 s after its first offer. But the worker accepts an offer until its created_at plus 120 s, and two cases outlast that hold:
  • a republished offer, sent up to 30 s later;
  • an offer from a joiner whose clock runs ahead, which can stay fresh for up to 240 s after the host first sees it.

In both cases a relay's late repeat looked like a new joiner and opened a second connection. Now:

  • signal::open returns Opened { signal, fresh_until }, and the page receives the bound as freshUntilMs;
  • host() holds each session until its newest offer goes stale;
  • the fixed SESSION_HOLD_MS is gone. Its guard is replaced by one that checks host() holds by the worker's bound, on both the first offer and a repeat.
  • A room that fails to open closes its sockets. RoomChannel.open() closes every socket it opened when it rejects. Before, a relay that accepted the connection and never sent EOSE kept its socket open after host() timed out. join() already closed in finally.
  • ADR 0032 names the remaining rung gap. The hold is decided by who was linked when the rung was sent, not by what each carrier accepted. So a member whose live link refused the rung is not held. The ADR explains why that member is not held (it would cost one round trip of PeerNotReachable at every rung) and what the fix would need.

Verification

  • cargo clippy --workspace -- -D warnings, cargo fmt --all -- --check and rustdoc with -D warnings (web crate) are clean.
  • cargo test -p offline-protocol-web --lib: 42/42 pass. The new an_opened_signal_says_how_long_a_relay_can_repeat_it checks three things:
  • the bound is exact: the event opens at fresh_until and is refused one second later;
  • a fast joiner clock gives 240 s from first sight;
  • the JSON carries the bound in milliseconds.
  • Five browser pages pass in headless Chrome. nostr-signal.html has two new steps:
  • a room that never opens: host() against a new /silent mode of the local relay, which accepts the socket and never answers. Every socket must be closed after the rejection.
  • session hold: host() driven with offers whose freshUntilMs the page sets. A repeat inside the newest offer's bound must not open a second connection, and an offer after every bound has passed must open one.
  • Negative controls, each failing at its own step:
  • with no close on failure: FAIL: a room that never opens: 1 socket(s) left open;
  • with no hold extension on a repeat: FAIL: session hold: a repeat inside the newest offer's freshness opened 2 connections.

Not done

  • The linked-member rung gap is documented, not changed.

Finishes the browser work left after #608 and #609: the unacknowledged send for game state, signalling without hand-carried codes, configurable ICE servers, and the review residuals.

What changes

  • Ephemeral sends (ADR 0032, W10). SendMessageOptions::ephemeral and GroupSendOptions::ephemeral send once over a live direct link with requires_ack = false. Nothing is kept to retry, park, hand to the mesh or give to the relay, so a game update never arrives late.
  • No link, or no confirmed session, fails at once and before encrypting. Plaintext still needs an explicit require_encryption = false.
  • A group member who keeps missing them is counted against the existing 256-generation ratchet-gap budget. A spent budget makes that one send reliable, so the member's ratchet never falls past OpenMLS's 8192 limit.
  • Telemetry counts only acknowledged sends as sent, so games do not lower the delivery ratio.
  • Exposed on the browser only. The UDL record is unchanged, so no binding regeneration.
  • Nostr room signalling (W11, R28). NostrSignaller moves the two WebRTC codes through relays the application names, by a short room code. The worker derives topic and key, seals, signs with single-use keys, and checks freshness. The page only moves text.
  • WebRtcCarrier({ iceServers }) for the application's own STUN and TURN. The default is still none.
  • Residuals from the #609 review.
  • A failed compaction backs off instead of retrying on every append.
  • A corrupted length prefix is refused rather than cut.
  • Replay reads the log in one call.
  • A WebRTC peer with 8 MiB waiting is closed, and the W9 memory claim is corrected.
  • Calls after stop() reject instead of hanging.
  • The tab carrier no longer posts on a closed channel.
  • The LogStats doc now says four flushes per compaction.

Measured

Sender store flushes per group messageHost testHeadless Chrome
Reliable4.04.3
Ephemeral2.02.0

Verification

  • cargo clippy --workspace -- -D warnings, cargo fmt --check and rustdoc with -D warnings are clean.
  • cargo test --workspace --lib passes with 0 failures, including 10 new engine tests, 7 signalling tests and 2 new log store tests.
  • Five browser pages pass in headless Chrome. The new one is nostr-signal.html, run over a local NIP-01 relay that the script starts.
  • Negative controls fail as expected for each fix: the compaction backoff, the length-prefix scan, the role binding in the seal, the fail-closed plaintext rule, and stop-then-call, which hangs without the fix.

Not done

  • Reserving offline-protocol-web on crates.io. That needs a maintainer's crates.io credentials.
  • No TURN server is run or tested. No Safari, Firefox or two-device run.
  • Ephemeral sends on the native bindings.

Milestones B and C of the browser plan, on top of #608.

B: a browser node is durable

  • LogStore (crates/offline-protocol-web/src/log_store.rs): each storage category (MLS material, protocol state) is a sealed append log over two OPFS files. Ok means flushed. Every record is ChaCha20-Poly1305 under a key derived per category and per generation from a 32-byte store key, with the category, the file's generation and the record's sequence number as associated data, so a record moved to another category, generation or position does not authenticate. A wrong key is refused at open with nothing truncated. Once the header authenticates, only a torn tail is dropped; a damaged record with intact records after it is refused untouched, because cutting there would roll back acknowledged ratchet state. A file shorter than a header is a crash during the first header write and starts a fresh log. Compaction commits by writing the spare file's header last. If an I/O error comes once that write has begun, the spare is emptied again, and if that fails too, the log refuses every later write. It passes both storage conformance suites on the host.
  • OPFS adapter (opfs.rs): five sync-access-handle calls. The handles live in a table on the worker's one thread, so the store stays Send + Sync with no unsafe code. Dropping a file frees its slot.
  • Worker boot (bindings/web/src/store.js): a Web Lock per account, so a second node for the same account is refused before it opens a file. The lock request waits up to 2 s before refusing, and a file handle still being released is retried, so a restart right after terminate() does not race the browser's cleanup. All four log handles are opened before the engine starts. The store key is sealed under a non-extractable AES-GCM key in IndexedDB. If the logs hold data and their key is missing or does not unseal (site data partly cleared), the node refuses to start and changes nothing rather than minting a new identity. While every log is empty, a new key is minted.
  • Lifecycle: OfflineNode.terminate() ends the worker the way a crash would. The page chooses the worker's tab-carrier address, so it can say bye for a worker it ended, and the other tabs drop the link at once. A failed start keeps no engine, lock or handle, and the client terminates its worker; this fixes the #608 residual where start left engine set after a failure. The client stops the worker on pagehide, and a page restored from the back-forward cache afterwards gets one fatal event. storage: "memory" keeps the old behaviour, and the two-tabs example now asks for it.
  • account_storage_namespace moves out from behind the file-store feature. It is still re-exported from file_store.

C: WebRTC between devices, no server

  • WebRtcCarrier (bindings/web/src/webrtc.js) runs on the page, because RTCPeerConnection exists only there. It uses one negotiated, reliable, ordered data channel per peer. Outbound bytes are cut into 16 KiB chunks, which every browser accepts, and the engine's stream reader joins them again. Sends wait while more than 1 MiB is buffered on the channel, and a close releases them. The page opens links through new OfflineNode.openLink / linkReceived / closeLink calls. The worker answers openLink before it sends that link's preamble.
  • Signalling is offline: each side waits for ICE gathering to finish, then encodes its description as one compressed code (about 570 characters) for a QR code or a paste. No ICE server is configured.
  • examples/web-lobby: two-player Pong with durable nodes. The host's state goes to an MLS group at 10 Hz, and the other player's paddle comes back as a direct message. The lobby lists every address it admits, and a player sees the host's, as R27 requires.

Docs

docs/bridges/web.md gains W8 (storage) and W9 (WebRTC) and updates W1, W3 and W5. The threat model gains R26 (a browser store key is reachable from its origin) and R27 (connection codes are unauthenticated and name local addresses). stream-framing.md no longer says every implementation keeps the lower-address stream: the browser keeps the link that verified first (a #608 residual). The changelog's [Unreleased] section and CLAUDE.md are updated.

Measured (headless Chrome, one Mac)

webrtc.html, group at 10 Hz for 3 s to one member: 30/30 delivered, p50 5.4 ms, p95 9.7 ms. The sender's store did 128 flushes, about 4.3 per group message (42.7/s). This is the number milestone D (ephemeral sends) needs. Module size is unchanged: 6.4 MB, 2.2 MB gzipped.

Checks

  • cargo test -p offline-protocol-web: 15 new log-store tests (both conformance suites, reopen, torn tail, torn first header, wrong key refused with the file byte-identical, damaged record refused untouched, cross-category, reordered records, compaction, uncommitted compaction, a compaction header flush that fails and is undone, one that cannot be undone and refuses later writes, a key per generation, size ceilings). Plus a host test that drops a durable member mid-session, reboots it over the same files, and checks it keeps its address and reads the group's next message.
  • bash bindings/web/scripts/test-browser.sh: all 4 pages PASS (two-nodes, refusal, the new restart and webrtc). restart.html also deletes the wrapping key and checks that the node refuses to start with its files byte-identical, then puts the key back and checks it starts as the same device. Negative control: restarting the player in memory makes restart.html fail with "restarted as off1…, a new device".
  • Lobby smoke test in two headless tabs: the second tab joined the host's group and received states.
  • cargo fmt --check, cargo clippy --workspace -D warnings (and the web crate for wasm32), cargo test --workspace --lib (3,363 pass), RUSTDOCFLAGS="-D warnings" cargo doc, cargo deny check: all green.

Not done

  • Not tested across two physical devices, or on Safari/Firefox. Every WebRTC run here is in one Chrome. CI turns off WebRtcHideLocalIpsWithMdns so the runner can reach its own candidates; a real deployment keeps Chrome's default.
  • The conformance suites run on the host, not in the browser: the MLS suite's concurrent-writes check spawns threads, which a worker does not have.
  • Still owed from #608: reserving offline-protocol-web on crates.io before the next tag.

What this does

Makes a browser a full mesh node. crates/offline-protocol-web compiles the whole engine, MLS included, for wasm32-unknown-unknown, and bindings/web runs it in a dedicated Web Worker. Tabs of one origin find each other over a BroadcastChannel, prove their identities with the peer-stream preamble, and exchange end-to-end encrypted direct and group messages with no server.

This is milestone A of an experiment aimed at local multiplayer for browser games. Storage is in memory, so a reload is a new device.

Changes

  • Clock seam (6 crates). On the browser target, std::time::Instant::now() and SystemTime::now() compile and panic on first use. Every crate the browser build compiles now reads the clock through offline_protocol_core::time: std::time on every other target (the types are the standard library's own, so nothing changes there) and web-time in the browser. clocks_are_read_through_core_time_only refuses a direct import.
  • offline-protocol-web. A host-testable Node with a thin #[wasm_bindgen] WebEngine over it. Rust owns every peer-stream rule (identity preamble, length prefix, one link per address) through the existing PeerStreamReader; the JavaScript carriers only move bytes. Nothing calls back into JavaScript, so a page can never re-enter the engine's lock.
  • bindings/web. The worker (100 ms tick, as the mobile bridges run), a BroadcastChannel tab carrier, the OfflineNode client and its .d.ts. The npm package is private for now.
  • Release set. The crate is publishable (README, LICENSE). Its engine dependency is declared locally, because cargo ignores default-features = false on an inherited dependency and would otherwise put the telemetry thread and TLS stack into the browser build. The crates.io no-op probe in release.yml now checks both top-level crates (-uniffi and -web), since either can be published last.
  • CI. A new web-binding job builds the module and runs the browser test in headless Chrome. the_wasm_bindgen_pins_agree holds the lockfile, the crate's = pin, the build script and the CI install to one version; the_browser_tests_run_in_ci keeps the job wired.
  • Advisory waiver. RUSTSEC-2024-0384 (instant, unmaintained, not a vulnerability), in both deny.toml and .cargo/audit.toml. It arrives only on wasm32: OpenMLS refuses to build for wasm without its js feature, which adds fluvio-wasm-timer, then parking_lot 0.11, then instant.
  • Docs. docs/bridges/web.md (rules W1 to W7), rows in the bridges README, CLAUDE.md, an [Unreleased] changelog section, and examples/web-two-tabs.

Verification

  • cargo test -p offline-protocol-web: 8 host tests (two engines over links: proved-address announcement, encrypted DM, group message, duplicate-link refusal, a bad first frame closing the link, loss on close) plus both storage conformance suites. Removing the duplicate-link check fails its test.
  • bash bindings/web/scripts/test-browser.sh: PASS in headless Chrome, with two workers in one page establishing an MLS session both ways and exchanging an encrypted DM and a group message, plus a loss on stop. With the carrier's send disabled it fails at the session step.
  • The two-tab demo was checked in two headless tabs: each lists the other with an encrypted session, and a sent message arrives.
  • Workspace: cargo fmt --check, clippy --workspace -D warnings, RUSTDOCFLAGS=-D warnings cargo doc, cargo test --workspace --lib (3,342 passed), cargo deny check, the license and README scripts, the bare-metal core/sealed/leaf clippy on Cortex-M33, Cortex-M0 and RISC-V, and the WASI leaf build all pass.
  • Not run locally: the Rust 1.87 MSRV check (the toolchain isn't installed here) and the new CI job itself. This PR is the first run of both.

Not in this PR

Durable storage (OPFS in the worker), WebRTC between devices, and an unacknowledged send for game state. The module is 6.4 MB, or 2.2 MB gzipped, with no wasm-opt pass yet.

bahdotsh/hopchat

Follow-ups from the review of #2, needed before the first tag.

Installer

  • A 5xx or 429 from github.com while resolving the latest release is now fatal. Before, it looked like "no release yet" and started a cargo install, contradicting the script's own guarantee. Fixed for both curl and wget.
  • Only a redirect to /releases counts as "no release"; any other redirect is an error.
  • The staged binary uses a mktemp name, is checked with --version, and the glibc hint only prints on Linux.

CLI

  • --version / -V prints hopchat <version>. The man page documents it.

Release pipeline

  • New vendored-openssl feature. Linux tarballs and the AppImage bundle OpenSSL, so they only need glibc 2.35. CI fails if the portable binary links libssl/libcrypto.
  • The .deb and .rpm use a second x86_64 build that links the system OpenSSL, so distro security updates still apply.
  • CI now asserts the .deb depends on libssl3, and the .rpm requires libssl.so.3 and ships LICENSE. Before, both install tests ran on hosts that already had OpenSSL, so they couldn't catch a missing dependency.
  • Every artifact and the post-release install check assert --version matches the tag.
  • Fixed the tarball comment that described a ./hopchat member the installer would not find.

Verification

  • cargo clippy --all-targets --locked -- -D warnings clean, cargo test --locked 153 passed.
  • shellcheck and actionlint clean.
  • Installer tested against live GitHub (no release yet, falls back to cargo), and with simulated curl 503 and wget 429 (both fatal), and a wget redirect to /releases (no release).
  • The vendored Linux build and package assertions run in this PR's release workflow.

ratatui/awesome-ratatui

<!-- Thanks for making Ratatui awesome! 🐭 -->

  • Link to your project (GitHub/crates.io): https://github.com/bahdotsh/hopchat · https://crates.io/crates/hopchat
  • Description (optional): Offline, end-to-end encrypted terminal chat for your local network. Peers find each other over UDP multicast and DNS-SD, and every conversation (direct messages, groups, the lobby, file transfers) is encrypted with MLS (RFC 9420). No server, internet or accounts. Added under Networking and Internet › Communications and Social.
  • Screenshot or gif (strongly recommended):

!alice and bob find each other on the same network and start a private, end-to-end encrypted chat