docs(remote): document the wake-on-LAN invariants; drop wake state on bulk delete

Self-review pass: the input-ladder's two 'buffer' branches were the same three
lines, and bulk delete left a session's (bounded, per-random-uuid) wake state
behind. Documents the design where the code refers to it - remote-sessions.md
section, the architecture invariant, and the CLAUDE.md key pattern.
This commit is contained in:
Randalix
2026-09-15 10:45:01 +02:00
parent 0f3eea2fb5
commit 3f0bfde54a
5 changed files with 109 additions and 52 deletions
+4 -8
View File
@@ -214,15 +214,11 @@ export class RemoteWakeRegistry {
if (action === 'deliver') return 'deliver';
if (action === 'buffer') {
// A buffered decision with no wake in flight (the wake failed and the state
// was reset, or the very first input of a session in the throttle window)
// must still drive a wake, or the bytes would sit in the buffer forever.
if (state.waking == null && remote?.wakeCommand) {
this._enqueue(session.id, data);
void this.wake(session);
return 'buffered';
}
this._enqueue(session.id, data);
// A buffered verdict with no wake in flight still has to DRIVE a wake (the
// previous one failed and reset the probe state, or the ladder landed here
// directly) — otherwise the bytes would sit in the buffer forever.
if (state.waking == null && remote?.wakeCommand) void this.wake(session);
return 'buffered';
}
+1
View File
@@ -1322,6 +1322,7 @@ export function registerSessionRoutes(
for (const id of sessionIds) {
if (ctx.sessions.has(id)) {
remoteWake.drop(id);
await ctx.cleanupSession(id, true, 'user_bulk_delete');
killed++;
}