docs(realtime): state that composition code owns hidden, logout and kill-switch closing (04-04)

The registry validates hiddenPolicy, killSwitchId and fallback, but the
reference runtime reads none of them, and isCurrent is checked only at loop
boundaries. The comments and design 5.4-5.6 now say close() is the caller's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-26 00:19:52 +09:00
co-authored by Claude Opus 5.5
parent 7e37660ba6
commit 1fe9bfdc2d
3 changed files with 36 additions and 2 deletions
@@ -102,6 +102,10 @@ export type RealtimeReconnectSession<
close(): void;
}>;
/**
* Online is the only environment signal the coordinator follows. Visibility,
* pagehide and the registry's `hiddenPolicy` are composition code's job.
*/
export type RealtimeReconnectEnvironment = Readonly<{
online(): boolean;
subscribeOnline(listener: (online: boolean) => void): () => void;
@@ -141,6 +145,12 @@ export type RealtimeReconnectCoordinatorDependencies<
): RealtimeResult<void>;
clock?: ClockPort;
random?: () => number;
/**
* Checked only at loop boundaries (around attempt, sleep and waitClosed),
* never while a session stays open. On logout or account switch call
* `close()`; otherwise a quiet open session stays open until its next
* event or server close.
*/
isCurrent?: () => boolean;
}>;
+6
View File
@@ -71,6 +71,12 @@ export type RealtimeRecoveryProfile =
rebuildInputId: string;
}>;
/**
* `fallback`, `hiddenPolicy` and `killSwitchId` are validated declarations.
* The reference runtime in `src/adapters/realtime/` does not read or enforce
* them: closing on hidden, pagehide and logout, the kill switch and the
* fallback are composition code's responsibility (design 5.4-5.6).
*/
export type RealtimeStreamRegistration = Readonly<{
id: StreamRegistrationId;
protocol: typeof REALTIME_EVENT_PROTOCOL;