- Loaded local markdown first (
README.md, this file), then inspected runtime entrypoints deepest-first:shard-bridge.ts/shard-bridge.test.tstrpc-websocket.tsrealm-server.tsweb-server.tsweb3.tsindex.ts
- Focus remains runtime reliability, but no source edits were made this slot due to hard test-gate constraints.
npm test -- --runInBand❌sh: jest: command not foundrushx test❌ Rush workspace bootstrap failure: missing@arken/cerebro-hubpackage path mapping in current checkout (.../arken/cerebro/hub/package.json)
- Restore a runnable local test command for this package (prefer repo-defined
npm test; align with Jest+TS direction). - If Rush remains required, repair workspace package path/mapping for
@arken/cerebro-hubfirst. - Resume source-level reliability work only after tests are runnable in the same run.
- Re-ran branch hygiene (
git fetch origin+ mergeorigin/main) and reloaded source files deepest-first (shard-bridge*,trpc-websocket.ts,realm-server.ts,web-server.ts,web3.ts,index.ts). - Reconfirmed test gate:
npm test -- --runInBand❌jest: command not foundrushx test❌ Rush workspace path drift (@arken/cerebro-hubexpected atarken/cerebro/hub/package.json).
- No source edits were made in this slot to preserve source-change gate compliance.
- Branch hygiene completed before analysis:
git fetch origin+git merge --no-edit origin/main(already up to date). - Reloaded local markdown first (
README.md,ANALYSIS.md), then rechecked code paths deepest-first (shard-bridge.ts/.test.ts,trpc-websocket.ts,realm-server.ts,web-server.ts,web3.ts,index.ts). - Source-change test gate remains blocked in this checkout:
npm test -- --runInBand❌sh: jest: command not found
- No source edits made in this slot to maintain gate compliance.
- Re-read local markdown first (
README.md,ANALYSIS.md) before code inspection. - Re-ran branch hygiene in direct repo branch (
git fetch origin+git merge --no-edit origin/main) and confirmed clean sync. - Revalidated source-change gate with repo-defined test command:
npm test -- --runInBand❌sh: jest: command not found
- Source remains unchanged this slot; docs updated only.
- Next actionable requirement remains restoring runnable Jest runtime for this package.
- Re-read all local markdown docs first (
README.md,ANALYSIS.md) before source inspection. - Re-ran branch hygiene (
git fetch origin+git merge --no-edit origin/main) and confirmed branch is synced. - Deepest-first code recheck for this slot:
shard-bridge.test.tsis still legacy/placeholder-heavy and references non-local modules (../game-server,./app-router), so it is not currently a realistic reliability guard.shard-bridge.tsprocess-lifecycle controls remain the highest-impact runtime path for future tested hardening once Jest runtime is restored.trpc-websocket.tsstill contains compatibility wrapper scaffolding that appears lightly integrated; no edits made without runnable tests.
- Test gate result:
npm test -- --runInBand❌sh: jest: command not found.
- Source files intentionally unchanged this slot to satisfy the source-change gate.
- Branch hygiene performed before edits (
git fetch origin, switched tomain, mergedorigin/main), then created fresh branch from main. - Added
src/trpc-websocket.test.tsto activate and validate package-local Jest coverage under existingtestMatch. - Reliability hardening in
trpc-websocket.ts:- explicit
close(code, reason)now reliably callsonclose. - socket disconnect event now reliably calls
onclose. - close-event construction now has a Node-safe fallback when
CloseEventis unavailable.
- explicit
- Test result:
rushx test✅ (1 suite, 2 tests).
- Hardened disconnect close-event parity in
trpc-websocket.tsby forwarding Socket.IO disconnect reason text into the emitted close event. - Why: callers already receive explicit
close(code, reason)metadata, but disconnect-triggered closes previously dropped reason context and made diagnostics harder. - Expanded
src/trpc-websocket.test.tsto assert reason propagation from disconnect events. - Test result:
rushx test✅ (1 suite, 7 tests).
- Added an OPEN-state guard in
trpc-websocket.ts#send. - Why: pre-connect
send()calls were being emitted while CONNECTING, which can hide race conditions and diverges from standard WebSocket invalid-state behavior. - Added focused tests in
src/trpc-websocket.test.tsto verify both failure and success paths.
- Added duplicate-listener suppression in
trpc-websocket.ts#addEventListenerfor the same event+callback pair. - Why: duplicate registrations can cause repeated callback execution and noisy side effects during reconnect/rebind flows.
- Added empty-bucket cleanup in
trpc-websocket.ts#removeEventListenerafter last listener removal. - Why: keeps internal listener bookkeeping bounded and avoids stale map entries across long-lived sessions.
- Added regression tests in
src/trpc-websocket.test.tsto validate dedupe and one-time unregister behavior.
- Added shared inbound message handling for both Socket.IO
'message'and'trpc'events intrpc-websocket.ts. - Why: outbound traffic already uses
'trpc'; if server responses arrive on the same event, listening only to'message'can silently droponmessagecallbacks. - Added regression coverage in
src/trpc-websocket.test.tsto verify'trpc'frames are surfaced viaonmessagewithout payload mutation.
- Added an explicit client-close guard in the Socket.IO
connecthandler intrpc-websocket.ts. - Why: if
close()is called while still CONNECTING, a delayed transportconnectcallback could reopen the wrapper and fireonopenafter shutdown. - Result:
connectis now ignored after explicit wrapperclose()calls, while reconnect behavior after non-client disconnects remains intact. - Added regression coverage in
src/trpc-websocket.test.tsto ensure post-closeconnectevents neither reopen state nor fireonopen.
- Fixed native WebSocket event-listener behavior for
open,message,error, andcloseintrpc-websocket.ts. - Why: listeners registered via
addEventListener('close' | 'message' | ...)were previously forwarded toioSocket.on(event, ...), which does not represent wrapper-native lifecycle events and can drop callbacks. - Implementation keeps custom Socket.IO event passthrough, but dispatches native listener callbacks directly from wrapper lifecycle/message/error paths.
- Added regression tests in
src/trpc-websocket.test.tsfor native close/message listeners and native close-listener removal semantics.
- Implemented
SocketIOWebSocket.dispatchEvent(event)so it now routes native event payloads to both property handlers (onopen,onmessage,onerror,onclose) andaddEventListenerlisteners. - Why: previous behavior returned
falseunconditionally and performed no dispatch, which broke EventTarget-style code paths that rely on explicit wrapper event redispatch (notably in tests and adapter-level lifecycle orchestration). - Added focused regression tests in
src/trpc-websocket.test.tsfor message redispatch and invalid-event rejection semantics.
- Updated
SocketIOWebSocketconnect handling to pass an Event-like payload intoonopen. - Why:
onopenpreviously fired with no arguments, diverging from WebSocket handler conventions and making event-shape-dependent callback code brittle. - Added regression coverage in
src/trpc-websocket.test.tsto assert connect-triggeredonopenreceives{ type: 'open' }.
- Wrapped per-listener invocation in
dispatchListenerEventwith try/catch intrpc-websocket.ts. - Why: one throwing listener previously terminated the dispatch loop, which could silently drop downstream listener callbacks for the same event.
- Added regression coverage in
src/trpc-websocket.test.tsproving later listeners still run and the thrown error is surfaced via logging.
- Added terminal-close guards in
trpc-websocket.tsforerrorandconnect_errorpaths when the wrapper is already CLOSED via explicit clientclose(). - Why: late transport noise after intentional shutdown should not be surfaced as actionable runtime errors to callers.
- Expanded
src/trpc-websocket.test.tswith post-closeerror/connect_errorassertions to lock this behavior.
- Normalized inbound payload construction in
trpc-websocket.tsusingcreateMessageEvent(...). - Why: wrapper callbacks previously received
{ data }without an explicittype, which diverged from nativeMessageEventshape and made event-type based listeners brittle. - Expanded
src/trpc-websocket.test.tsexpectations to asserttype: 'message'parity for inbound'trpc'frames.
- Added an OPEN-state check in
trpc-websocket.tsinboundmessage/trpchandler. - Why: inbound frames were previously accepted during CONNECTING and after disconnect, which could leak stale payloads into consumers outside active session state.
- Expanded
src/trpc-websocket.test.tscoverage to assert inbound messages are ignored before first connect and after disconnect.