From 1b621b6b13495b1bfc41ab821d64f3fc46d974e6 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 10 Sep 2026 18:21:13 -0700 Subject: [PATCH] docs(runtime): the two guards on the park-time binding are not redundant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recording a reconciliation result that existed only in a review thread, and correcting it in the process — measuring the claim changed it. The claim under review was that the `?? ''` fallback in `recordExpiredWait` is unreachable by two independent guards, either sufficient alone: the caller's generation gate (a missing waiter fails `undefined === number`) and the record-before-release ordering. That is not what the code does. Measured, by removing each in turn: - ordering removed, generation gate kept: the gate does NOT carry it. With the waiter already deleted, the gate is false on every expiry, so nothing is ever recorded — five failures, and the door is shut by breaking the mechanism rather than by refusing ''. - generation gate removed, ordering kept: 736 files green, one failure, and it is `does not let a wait armed on the previous connection decide the new one` in host-mirror-handle-gap-resume.test.ts — a different property entirely. So the ordering alone makes `''` unreachable, and the generation gate is not a second guard on it at all: it pins reconnect-void. Both are load-bearing, for different reasons, which is a stronger argument against removing either than redundancy would have been — redundancy invites deleting one. Worth writing in the file because the two sit three lines apart and read as belt and braces on the same thing. The `''` comment next to them already exists because an unexplained guard on an unreachable value gets deleted as dead code in a year; a guard that looks redundant is deleted sooner. No behaviour change. One comment, corrected against measurement rather than against the thread it came from. --- src/renderer/src/lib/host-mirror-handle-gap-wait.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/renderer/src/lib/host-mirror-handle-gap-wait.ts b/src/renderer/src/lib/host-mirror-handle-gap-wait.ts index c3cd4af0d4d..7b2cb27d4e8 100644 --- a/src/renderer/src/lib/host-mirror-handle-gap-wait.ts +++ b/src/renderer/src/lib/host-mirror-handle-gap-wait.ts @@ -159,6 +159,11 @@ function recordExpiredWait(environmentId: string, key: string): void { // wait just ran out. Re-reading here would attribute it to whatever holds the id NOW, handing a // pane that replaced it mid-wait a verdict it never served. The caller must therefore record // BEFORE `releaseWaiter` deletes the entry; the union suite pins that ordering. + // The `?? ''` is unreachable solely because of the record-before-release ordering above it. The + // caller's generation gate LOOKS like a second guard on it and is not: drop the ordering and that + // gate stops recording anything at all rather than admitting ''. It pins a different property + // (reconnect-void, host-mirror-handle-gap-resume.test.ts). Both are load-bearing, for different + // reasons — do not collapse them as redundant. expiredGenerationByPane.set(key, { generation, paneBinding: waitersByPane.get(key)?.paneBinding ?? ''