Repository navigation
Explicit websocket handshake buffering and safer transport request queue - #4
Open
jasonLaster wants to merge 3 commits into
Open
jasonLaster wants to merge 3 commits into
jasonLaster wants to merge 3 commits into
Conversation
Add typed websocket push envelopes with ordered sequence numbers,
structured decode diagnostics, and a client transport state machine.
On the server, route pushes through a shared push bus, gate welcome
delivery on explicit readiness barriers, and make keybindings startup
an explicit runtime with start/ready lifecycle.
Fix the flaky keybindings watcher test on Linux CI:
- Subscribe eagerly via PubSub.subscribe instead of lazy
Stream.fromPubSub to avoid missing events before the fiber
is scheduled.
- Replace the hand-rolled Effect.sleep polling loop with
fs.watchFile (Node's built-in stat-based poller on libuv
timers) so file change detection is reliable regardless of
Effect fiber scheduling pressure.
Add orchestration runtime receipts for checkpoint baseline capture,
checkpoint diff finalization, and turn quiescence, then update the
integration harness/tests to wait on those receipts instead of
timing-sensitive polling.
Use DrainableWorker for queue-based reactors so unit tests can
deterministically drain() instead of sleeping.
Adopt idiomatic Effect patterns: Effect.ignoreCause({ log: true })
for log-and-ignore error handling, Effect.tapCause for side-effecting
on errors before ignoring.
jasonLaster
force-pushed
the
statemachine
branch
6 times, most recently
from
March 10, 2026 05:53
332973c to
0711302
Compare
juliusmarminge
force-pushed
the
statemachine
branch
from
March 10, 2026 07:28
0711302 to
7a34680
Compare
jasonLaster
force-pushed
the
statemachine
branch
5 times, most recently
from
March 10, 2026 18:59
47a82c8 to
52410bd
Compare
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.
Motivation
server.welcomeis always first for a new socket while still queuing and delivering request-triggered pushes that happen during the handshake.latestPushByChannelfor late in-page subscribers but add explicit reconnect/replay semantics for orchestration event gaps.Description
apps/server/src/wsServer/pushBus.tsto allocate globalsequencenumbers, register clients inpre_welcomephase, bufferpublishAllpushes per-client with a bounded backlog, and exposeregisterClient,activateClient, andunregisterClientAPIs that atomically flip a client toactiveand flush the backlog in sequence order.apps/server/src/wsServer.tsto callpushBus.registerClient(ws), sendserver.welcomeviapushBus.publishClient(...), thenpushBus.activateClient(ws)and to usepushBus.unregisterClient(ws)on close/error; also replaced the previousRef-based broadcast set with the push-bus registration model.apps/web/src/wsTransport.tsby converting the outbound queue fromstring[]to an array of entries keyed by request id ({id, encoded}), removing queued entries when requests time out or the transport is disposed, and skipping queued entries whose pending request no longer exists when flushing.apps/web/src/routes/__root.tsxthat detects asequencegap and callsapi.orchestration.replayEvents(...)(falling back to snapshot sync) instead of relying onlatestPushByChannelfor log-like event recovery.apps/server/src/wsServer.ts(keeps existingissuesbehavior intact).apps/server/src/wsServer/pushBus.test.ts(handshake buffering),apps/web/src/wsTransport.test.ts(timeout/dispose/queue semantics), andapps/server/src/wsServer.test.ts(request-triggered pushes during handshake and non-fatal keybindings).Testing
mise exec -- bun lintsucceeded with no errors.mise exec -- bun typecheckfailed in this environment because pinned Effect platform packages could not be fetched (HTTP 403 from the privatepkg.pr.newregistry), so workspace type dependencies are missing and full typecheck could not complete.mise exec -- bunx vitest run ...could not run the modified suites due to the same missingeffect/platform packages (import errors), so the new tests exist but could not be executed end-to-end in this environment.Codex Task