Key findings
Verdict: clean — no blocking or should-fix correctness defects at head 43c6ea78. The rebase fixed the two blockers my earlier review raised (the diff edited flare/src/main.rs (not opened), a file main no longer has; and the argued placement inside serve() is unreachable on Windows). The change now does what it claims in the only code path Windows serving uses, and it matches the Unix ordering.
- Nit —
flare-cli/src/main.rs:738-746:stop_consolereturns "handled" afterSTOPis already set, so a second Ctrl-C cannot force exit during the shutdown drain. Not a regression (Unixstopat 53-55 has the same gap). - Nit — PR description vs. code: the description says the handler is registered "immediately before
Server::start" and that "a Ctrl-C duringServer::startsetsSTOP, so the serving loop exits at once". The head registers it afterloaded.start()(flare-cli/src/main.rs:696-710), so the startup-tuning window keeps the default console termination. Intentional and safer, but the description describes the pre-rebase design. - Nit — no terminal/ANSI restore on the newly reachable abrupt-exit paths (cosmetic; precedent at
heliopause/src/processes_windows.rs:16-27(not opened)). - Evidence gap (not a code defect) — the head has no Windows compile or live run; the Windows compile is obtainable from existing PR CI, only the live Ctrl-C session stays unrun.
What the diff does, in context
flare-cli/src/main.rs (+7/−6), docs/windows.md (+2/−2).
- The early registration inside
run()is deleted (it sat where the old branch had it, immediately after the Windows multi-host rejection):
#[cfg(windows)]
if args.rank.is_some() || args.rendezvous.is_some() || !args.hosts.is_empty()
|| args.roce_ring || args.roce_chain
{
return Err("multi-host serving is not supported on Windows".into());
}
// deleted: SetConsoleCtrlHandler(Some(stop_console), 1)
(flare-cli/src/main.rs:178-186; the deleted block was the #[cfg(windows)] unsafe { … } that followed it.)
- A new registration is added in
serve_local, afterloaded.start()and beside the Unix signal block:
695 let phase = progress.phase("Start server", None);
696 let session = loaded.start().map_err(|failure| failure.message)?;
...
699 #[cfg(unix)] unsafe {
700 libc::signal(libc::SIGINT, stop as *const () as libc::sighandler_t);
701 libc::signal(libc::SIGTERM, stop as *const () as libc::sighandler_t);
702 }
704 #[cfg(windows)] unsafe {
706 // Loading keeps the default Ctrl-C termination; nothing reads STOP before serving.
707 if windows_sys::Win32::System::Console::SetConsoleCtrlHandler(Some(stop_console), 1) == 0 {
708 return Err(std::io::Error::last_os_error().into());
709 }
710 }
711 progress.finish_animation();
712 if let Err(error) = server.start_dashboard() { ... }
715 while !STOP.load(Ordering::Relaxed) && server.wait(Duration::from_millis(250)) {}
(flare-cli/src/main.rs:695-715)
Does Windows always reach this site?
Yes, and I traced each branch rather than assuming it:
- Multi-host flags are rejected on Windows before anything else (
flare-cli/src/main.rs:178-186), so no rank/rendezvous path exists. - The
#[cfg(windows)]load branch never builds aMembership: it destructures(_, authorized, _, lease)and the binding after it islet mut membership: Option<cluster::Membership> = None;(:255-268). - With
membership == None, the cluster match can only reach(None, None, None) => Noneor the mismatch error, never a peer/zero branch (:315-323). - Belt and braces,
LoadedSession::newitself refuses a clustered owner:if owner.cluster().is_some() { return Err("an owned local session requires every model rank in this process") }(helios/src/server/session.rs:26-29).
So on Windows the process that serves is serve_local via flare-cli/src/main.rs:597 (return serve_local(owner, config, progress);), and the registration at 704-710 always executes before the serving loop.
Is the ordering right?
Download and model load now run with no handler and therefore the default console termination — exactly the Unix situation before SIGINT/SIGTERM are installed at 699-702. That is the fix: previously stop_console returned 1 ("handled") for CTRL_C_EVENT | CTRL_BREAK_EVENT (flare-cli/src/main.rs:737-746) and suppressed the default termination, while on Windows nothing read STOP before the serving loop.
Server::start is also inside the default-termination window now. Note this is deliberate and is the safer direction: Server::start blocks on worker readiness (helios/src/server.rs:417) while startup tuning graphs run under a 120 s-per-graph completion deadline and a 120 s drain deadline, with no STOP check (helios/src/execution/transport.rs:739-784). Registering before the start would have re-created the reported symptom for minutes at a time.
Error handling and lifetimes at the new site
If SetConsoleCtrlHandler returns 0 (:707), the function returns Err(last_os_error()) while session: ServingSession is still owned. ServingSession::drop calls close() (helios/src/server/session.rs:104-108), which sets owner.drained = shutdown.drained (:96-100); DrainGuard::drop releases the model only on confirmed drain and otherwise mem::forgets it (:125-133). So the failure path neither leaks badly nor frees CUDA storage under live work. The description's claim that a registration failure "returns before replay begins, instead of dropping the package owner without a confirmed drain" holds for the new site: startup replay is driven by the serving loop that starts after this point.
Minor ordering consequence: on that error return, progress.finish_animation() (:711) and start_dashboard() (:712) are skipped, so a spinner may be left on screen. Cosmetic only.
Docs
docs/windows.md:141-142 now reads: "Ctrl-C and Ctrl-Break end loading immediately and drain native work before releasing CUDA resources once serving has started." That is accurate for 704-710: default termination before registration, handler-driven drain after. It also correctly narrows the old unconditional promise.
Findings
Nit 1 — a second Ctrl-C cannot force exit during the drain (flare-cli/src/main.rs:738-746)
737 #[cfg(windows)]
738 unsafe extern "system" fn stop_console(event: u32) -> i32 {
739 use windows_sys::Win32::System::Console::{CTRL_BREAK_EVENT, CTRL_C_EVENT};
740 if matches!(event, CTRL_C_EVENT | CTRL_BREAK_EVENT) {
741 STOP.store(true, Ordering::Relaxed);
742 1
743 } else { 0 }
746 }
Once the loop at :715 exits, the process runs session.close() (:719), which joins HTTP and model workers and waits for native replay to drain (helios/src/server.rs:524-560). Every subsequent Ctrl-C still returns 1, so the default handler never runs and the user cannot terminate a slow or stuck drain except by force. This is pre-existing (Unix stop, flare-cli/src/main.rs:52-55, also only sets STOP), so it is not a regression introduced here; I record it because this PR is the one that changes Ctrl-C semantics on Windows. One-line fix, and it is exactly the fallback the earlier review suggested:
if STOP.swap(true, Ordering::Relaxed) { 0 } else { 1 }
Returning 0 lets the next handler — the default one — terminate the process.
Nit 2 — the PR description describes the pre-rebase design
The description states "Register the handler immediately before Server::start" and "A Ctrl-C during Server::start sets STOP, so the serving loop exits at once and native replay drains before CUDA resources are released." At this head both statements are false: the registration is at :704-710, after loaded.start() at :696. In practice a Ctrl-C during Server::start (startup tuning, up to 120 s per graph, helios/src/execution/transport.rs:739-784) now terminates the process without the graceful path. That is the right choice — it restores default termination instead of swallowing the key — but the consequence worth stating is that an abrupt Ctrl-C during tuning bypasses GraphExecutor's record-and-drain-or-abort protocol (helios/src/execution/transport.rs:767-783) and lets process exit tear down the CUDA context. Unix behaves identically today, so this is parity rather than a defect; the description should be rewritten to say loading (including Server::start) keeps the default termination and only the serving loop drains.
(Author's comment of 2026-11-28 states the description was updated; the text I was given still carries the old wording, so at minimum it needs re-checking before merge.)
Nit 3 — no terminal restore on the new abrupt-exit paths
Ctrl-C during download or load now terminates without running any epilogue, so progress's ANSI/cursor state (progress.finish_animation() at :711 never runs) can be left on the console. Cosmetic; the same file already accepts this for its other early errors. Precedent for restoring it on a signal path is heliopause/src/processes_windows.rs:16-27 (not opened).
Evidence gap (should be stated in the PR, not a code defect)
At 43c6ea78 there is no Windows compile and no Windows run. Both are resolvable and one is already partly covered:
.github/workflows/native-serving.yml:6(not opened) triggers on everypull_request,:20-21includeswindows-2022/x86_64-pc-windows-msvcin the matrix, and:45runscargo build --locked --release --manifest-path flare-cli/Cargo.toml, withcargo testfor the same manifest at:73. So the Windows compile of this exact code is obtainable from CI and should be posted.- Only the live
flare run COREsession — Ctrl-C during download, Ctrl-C during load, Ctrl-C after "Start server" followed by a confirmed drain — must remain explicitly labelled unrun.AGENTS.md:103-112requires each material claim to be tied to the check that supports it and untested items to be stated.
Verified non-issues (checked, no finding)
- No new dependency or feature gap.
windows-syswithWin32_System_Consoleis already enabled for the CLI:flare-cli/Cargo.toml:49. - Handler lifetime. The handler is installed once and never removed, but
serve_localreturning is followed by process exit (main,flare-cli/src/main.rs:60-68); no second handler in this binary, and Windows permits multiple handlers per process. - Dashboard does not steal Ctrl-C.
InputMode::opensetsENABLE_PROCESSED_INPUTand clears line/echo input (helios/src/server/dashboard.rs:1067-1068), so Ctrl-C stays a console control event rather than becoming a keystroke, andDroprestores the original console mode (:1076-1083). Registration (:704-710) precedesstart_dashboard()(:712). - Interrupted download/load is safe. Package acquisition in
flare/src/hub.rsis resumable and digest-verified (check_cancelused throughout, with resume/verify tests), and nothing durable is written duringNativeModel::load, so default termination mid-download or mid-load cannot corrupt the cache. This is what makes the behavioural change acceptable. - No regression on Unix. The unix block is untouched (
:699-702), and the deleted block was#[cfg(windows)]. - Non-CLI front ends unaffected. The Windows desktop app drives the
flarelibrary controller (flare/src/controller.rs:2566-2590) and never entersserve_local, so its Ctrl-C behaviour is unchanged; no new API surface (area:apilabel notwithstanding). serve()needs no second registration. Windows cannot reach it (flare-cli/src/main.rs:178-186,:255-268,:315-323), and adding one would duplicate the policy.
Open questions
- Whether a second Ctrl-C should be allowed to force exit during the drain (Nit 1) — needs a maintainer decision on policy, since Unix has the same gap and fixing only Windows would diverge the platforms further.
- Whether the 120 s-per-graph tuning window inside
Server::startis acceptable to leave uninterruptible on Windows (Nit 2). The alternative — a handler that setsSTOPand also aborts tuning — would requireSTOPchecks inhelios/src/execution/transport.rs, i.e. a helios change outside this PR's scope. - The Windows compile result and one live Ctrl-C session: only CI and a Windows machine can settle these; nothing in the code blocks on them.