fix(comfyui): keep the pre-supervisor pre-flight out of -WhatIf's way #895

Merged
coilysiren merged 1 commit from fix/comfyui-preflight-whatif into main 2026-08-20 07:16:46 +00:00
Owner

Follow-up to #894. Both defects came out of the first live -WhatIf preview on kai-tower-3026, which #894 could not run because its own pre-flight aborted it.

1. The pre-flight aborted a pure preview

#894's legacy pre-flight called Stop-LoopbackListener outside any ShouldProcess guard. Stop-Process honours -WhatIf through $WhatIfPreference scope inheritance, verified directly on this host, so nothing was ever killed. But that is exactly why the port never freed, so Wait-LoopbackPortFree timed out and the pre-flight threw. A read-only preview aborted instead of previewing, which is the failure #882 already fixed once elsewhere.

Under -WhatIf it now reports the wall and lets the rest of the preview run.

2. CRLF sources produced CR CR LF

$launcher and $supervisor were converted to CRLF without normalising first. A checkout carrying CRLF hands the here-string CRLF already, so converting again yields CR CR LF. That never matches the installed file, so every run rewrote serve.cmd and reported changed, and it would have written serve.ps1 malformed.

Reproduced from the real source on this host: the generated launcher contained 0D 0D 0A, while the installed serve.cmd has clean 0D 0A. .gitattributes mandates eol=lf, so a correct checkout would not hit this, but the converger should not depend on the line endings of its own source.

Worth noting separately: this checkout has CRLF working files despite * text=auto eol=lf, with core.autocrlf=true set globally. That is host config drift, not something this PR fixes.

Verification, live on kai-tower-3026

Ran the real converge with -WhatIf against the live host, before and after.

Before:

launcher: converged                 <- every run, from the CR CR LF mismatch
supervisor: converged
(threw on the pre-flight in #894 as merged)

After:

supervisor: converged               <- correct, serve.ps1 does not exist yet
scheduled task 'ComfyUI': replacing the pre-supervisor task needs loopback port 8188 freed first
What if: Performing the operation "replace" on target "ScheduledTask ComfyUI".
What if: Performing the operation "restart under scheduled-task ownership" ...
RESULT=CHANGED
exit code 0

launcher: converged is gone, so serve.cmd now matches byte for byte and the converger is idempotent for it again.

Both preview runs left the host untouched: listener still pid 39132, /system_stats still 200, and serve.ps1 still absent.

Follow-up to #894. Both defects came out of the first live `-WhatIf` preview on kai-tower-3026, which #894 could not run because its own pre-flight aborted it. ## 1. The pre-flight aborted a pure preview #894's legacy pre-flight called `Stop-LoopbackListener` outside any `ShouldProcess` guard. `Stop-Process` honours `-WhatIf` through `$WhatIfPreference` scope inheritance, verified directly on this host, so nothing was ever killed. But that is exactly why the port never freed, so `Wait-LoopbackPortFree` timed out and the pre-flight threw. A read-only preview aborted instead of previewing, which is the failure #882 already fixed once elsewhere. Under `-WhatIf` it now reports the wall and lets the rest of the preview run. ## 2. CRLF sources produced CR CR LF `$launcher` and `$supervisor` were converted to CRLF without normalising first. A checkout carrying CRLF hands the here-string CRLF already, so converting again yields `CR CR LF`. That never matches the installed file, so every run rewrote `serve.cmd` and reported changed, and it would have written `serve.ps1` malformed. Reproduced from the real source on this host: the generated launcher contained `0D 0D 0A`, while the installed `serve.cmd` has clean `0D 0A`. `.gitattributes` mandates `eol=lf`, so a correct checkout would not hit this, but the converger should not depend on the line endings of its own source. Worth noting separately: this checkout has CRLF working files despite `* text=auto eol=lf`, with `core.autocrlf=true` set globally. That is host config drift, not something this PR fixes. ## Verification, live on kai-tower-3026 Ran the real converge with `-WhatIf` against the live host, before and after. Before: ``` launcher: converged <- every run, from the CR CR LF mismatch supervisor: converged (threw on the pre-flight in #894 as merged) ``` After: ``` supervisor: converged <- correct, serve.ps1 does not exist yet scheduled task 'ComfyUI': replacing the pre-supervisor task needs loopback port 8188 freed first What if: Performing the operation "replace" on target "ScheduledTask ComfyUI". What if: Performing the operation "restart under scheduled-task ownership" ... RESULT=CHANGED exit code 0 ``` `launcher: converged` is gone, so `serve.cmd` now matches byte for byte and the converger is idempotent for it again. Both preview runs left the host untouched: listener still pid 39132, `/system_stats` still 200, and `serve.ps1` still absent.
fix(comfyui): keep the pre-supervisor pre-flight out of -WhatIf's way
All checks were successful
TruffleHog / Scan for secrets (pull_request) Successful in 5s
CI / lint (pull_request) Successful in 41s
02b0a044ba
Two defects the first live preview of #894 surfaced.

The legacy pre-flight called Stop-LoopbackListener outside any
ShouldProcess guard. Stop-Process honours -WhatIf, verified on this host,
so nothing was ever killed, but the port therefore never freed and the
pre-flight threw. A pure preview aborted instead of previewing, which is
the failure #882 already fixed once elsewhere. Under -WhatIf it now
reports the wall and lets the rest of the preview run.

The launcher and supervisor were converted to CRLF without normalising
first. A checkout carrying CRLF hands the here-string CRLF already, so
converting again yields CR CR LF. That never matches the installed file,
so every run rewrote serve.cmd and reported changed, and it would have
written serve.ps1 malformed. Reproduced from the real source on
kai-tower-3026: generated content contained 0D 0D 0A.

Verified by running the converge with -WhatIf against the live host.
Before: "launcher: converged" every run. After: gone, because serve.cmd
now matches byte for byte. "supervisor: converged" correctly remains,
serve.ps1 does not exist yet. The pre-flight prints that port 8188 needs
freeing rather than throwing, exit code 0, and both runs left the runtime
and its listener untouched.

Refs: #883

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
coilyco-flight-deck/infrastructure!895
No description provided.