fix(comfyui): make the task instance own its runtime with a job object #894
No reviewers
Labels
No labels
burndown-2026-06
burndown-2026-08
autonomy
async-consult
autonomy
epic
autonomy
headless
autonomy
live-collab
coherence-core
priority
P0
priority
P1
priority
P2
priority
P3
priority
P4
qa-fixture
role/advocate
role/director
role/exec
role/frontend
role/gamedev
role/human
role/platform
role/qa
role/science
role/sysadmin
state
ambient
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
coilyco-flight-deck/infrastructure!894
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/comfyui-supervisor-job-object"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes the third #888 option from #883: drive the runtime entirely through the task surface, so session and elevation stop mattering.
Why not the other two options
Return the task to Interactive. That re-introduces exactly what #888 fixed. A session disconnect kills the task with
0xC000013A, andGpuHeartbeathad been up 5.5 days before a disconnect took it down. It trades a supervision problem for a liveness problem on a host whose job is unattended uptime.Give the converger an elevated path. The converger runs unelevated today, which is what lets ansible and an agent run it with nobody at the keyboard. Elevation puts a UAC prompt in the middle of unattended convergence, and it elevates the whole script (downloads, 7z extraction, writes into
$HOME) to buy oneStop-Processcall.The actual defect
The converger reaches past the task surface to
Stop-ProcessbecauseStop-ScheduledTaskdoes not free the port. That is a process-tree problem, not a permissions problem. Reaching for the process is what put the converger on the wrong side of the S4U session boundary.cmd.exeruns python synchronously, so the instance stays attached andRunning. But stopping the instance kills onlycmd.exe. The python child survives holding127.0.0.1:8188, no task owns it, andRestartCount=5has no instance to act on.The change
The task action is now a generated supervisor. It puts itself in a job object limited to
KILL_ON_JOB_CLOSEand launchesserve.cmdas a child. Job membership is inherited, socmd.exeand python join it. When the instance stops, the supervisor dies, its last job handle closes, and the tree goes with it.serve.cmdis unchanged. The wrapper exists for the>> comfyui.log 2>&1redirect, and ComfyUI 0.29.0 has no--log-file(only--verboseand--log-stdoutincomfy/cli_args.py), so dropping it would cost the log this whole investigation ran on.Stop-ScheduledTaskis then sufficient. It is unprivileged and session-agnostic, so the converger manages an S4U runtime without ever signalling it. The restart path no longer callsStop-Process.Migration safety
Replacing a pre-supervisor task still stops an instance that does not own its runtime, and
Unregister-ScheduledTaskdoes that before the restart path is reached. So a pre-flight now refuses the whole converge when a legacy task is being replaced and the port is held and cannot be freed. That preserves what #892 bought: never detach a runtime without a proven way back.On kai-tower-3026 this pre-flight will fire, because the runtime there is already an orphan from before either fix. That is correct. The tower needs the elevated cleanup first either way.
Verification
Done on kai-tower-3026 without touching the live runtime:
Stop-ScheduledTaskdoes.cmd.exe,conhost.exe, and the grandchild were all reaped, no orphans.cmd.exeshape. The child survived, reproducing the orphan.The script itself parses clean (3387 tokens). PSScriptAnalyzer is not installed on this host.
Not exercised end to end against the live ComfyUI. Running the converger against the live runtime is the destructive act at the centre of #883, and the tower's runtime is currently an orphan that this branch's pre-flight will correctly refuse to touch. The first real run wants an operator present.