PR #178 (subtraction review) — Keep the default Windows Ctrl-C termination while loading
Key findings
- Blocking — every line of the diff lands in a file that no longer exists on
main(all 14 diff lines: +8/−6).flare/src/main.rswas moved toflare-cli/src/main.rsin fa158284 (2026-11-09, "Add a native Windows desktop backed by the shared Flare library"), six days after this PR branched at 902c88e. The live file already holds the exact registration the PR deletes. 100% of the change must be redone; the smaller version is a 13-line relocation inflare-cli/src/main.rs. - Should fix — delete the second added comment line (1 line). "A registration failure must return before replay starts." restates the
return Errfour lines below and claims a drain benefit that is backwards. - Nit —
docs/windows.md:141-142is left claiming a drain that stops being true while loading (0 lines saved, same-length rewrite).
Nothing else in the PR is a candidate for subtraction: it adds no flag, helper, type, constant, test or dependency. The intent is already minimal; only its address is wrong.
The change, measured
1 file changed, +8/−6 (14 diff lines), all in flare/src/main.rs, head 85fb08c on base 902c88e.
- The +8: two comment lines,
#[cfg(windows)],unsafe {, the three-lineSetConsoleCtrlHandler(...) == 0failure check, and two closing braces. - The −6: the same six-line registration deleted from the old
flare/src/main.rs:147-152. stop_console(oldflare/src/main.rs:643-652) is untouched; its surviving twin isflare-cli/src/main.rs:736-745.
No flags, options, parameters, fallbacks, abstractions or tests are added. The change is a relocation.
Findings, ranked by lines saved
1. Blocking — the whole diff targets a deleted file: ~14 lines (all of it)
Where: flare/src/main.rs (both hunks; deletion at 147-152, insertion at 574-580 in the old tree).
What goes: all of it. Nothing can replace it in that file.
Why nothing is lost by redoing it elsewhere: the file is not on main.
read_file flare/src/main.rsatmain→ "not a file at that commit";list_files flare/src/*atmainshowsapplication.rs,windows.rs, … but nomain.rs; atpr/178the old tree still has it.search_history path=flare-cli/src/main.rs ref=mainnewest 50 stops at fa158284, the move.- Reviewer yatesdr reached the same conclusion on 2026-11-18: "flare/src/main.rs moved to flare-cli/src/main.rs in fa158284".
The live code already has the registration the PR deletes — flare-cli/src/main.rs:187-192:
#[cfg(windows)]
unsafe {
if windows_sys::Win32::System::Console::SetConsoleCtrlHandler(Some(stop_console), 1) == 0 {
return Err(std::io::Error::last_os_error().into());
}
}
stop_console is at flare-cli/src/main.rs:736-745; SetConsoleCtrlHandler appears at only two sites on main (flare-cli/src/main.rs:189, heliopause/src/processes_windows.rs:38), so there is exactly one registration to move.
Where the insertion belongs on main: flare-cli/src/main.rs:178-186 rejects --rank, --rendezvous, --hosts, --roce-ring, --roce-chain on Windows, so serve() (592) always takes the cluster.is_none() branch into serve_local (602-604). serve_local starts the server at 702 (loaded.start()), after the "Start server" phase opens at 701 — register immediately before that. Every Windows serving run goes through serve_local, so one site covers all of them.
Smaller version to land (13 lines of diff: −6, +6 code, +1 comment): delete 187-192, insert before line 702:
// Loading keeps the default Ctrl-C termination: nothing observes STOP before serving.
#[cfg(windows)]
unsafe {
if windows_sys::Win32::System::Console::SetConsoleCtrlHandler(Some(stop_console), 1) == 0 {
return Err(std::io::Error::last_os_error().into());
}
}
Not a subtraction I endorse: dropping the == 0 failure branch (3 of the 8 added lines) would suppress an OS error; AGENTS.md forbids that, so the check stays.
2. Should fix — drop the second added comment line: 1 line
Where: flare/src/main.rs:574-575 (old tree); in the ported version it is the second line of the two-line comment before loaded.start().
// Loading keeps the default Ctrl-C termination because nothing observes STOP before serving.
// A registration failure must return before replay starts.
What goes: the second sentence.
Why nothing is lost: it restates the return Err(...) that now sits four lines above Server::start, and the ordering it describes is visible from the code. Worse, the benefit it implies does not exist:
- On
mainthe deleted registration (flare-cli/src/main.rs:187-192) runs beforeload_core(220), so a failure there has no loaded owner at all — nothing is dropped. The moved-down placement is the one that returns with a live owner, and it drops it rather than confirming a drain (loaded.start().map_err(|failure| failure.message)?at:702). The comment therefore advertises the opposite of what the placement does. - The PR description repeats the claim ("instead of dropping the package owner without a confirmed drain"), and the file elsewhere goes out of its way to avoid exactly that:
std::mem::forget(owner)atflare-cli/src/main.rs:565, 580, 669,DrainGuardinhelios/src/server/session.rs:110-133.
The first sentence is the genuinely non-obvious constraint and should stay: nothing reads STOP before the serving loop, whose other reader (distribution's rendezvous wait) is #[cfg(unix)] — flare-cli/src/main.rs:209-260 on main.
Smaller version: keep one line, delete the other.
3. Nit — docs/windows.md:141-142 still promises a drain during loading: ~0 lines
Where: docs/windows.md:141-142 (main): "Ctrl-C and Ctrl-Break drain native work before releasing CUDA resources."
What goes: the unconditional claim, rewritten in place at the same length — do not add a paragraph to a 6-line fix (AGENTS.md: "Scale detail to the change"; "State the substantive fact directly"). After the change, only serving-time Ctrl-C drains; during download and loading Windows keeps the default console termination, which ends the process with no drain. Reviewer yatesdr raised the same gap (2026-11-18, point 3).
Replacement, same length: "Ctrl-C and Ctrl-Break end loading immediately, and drain native work once serving has started."
Checked and left alone: docs/model-preparation.md:470 (not opened) ("Stop Flare with Ctrl-C or SIGTERM so native replay drains") and AGENTS.md:134 describe the serving loop, which is unchanged. No other doc or test asserts the loading-time behavior, so nothing else is made dead.
Verified as not subtraction candidates
- No new option, flag, parameter, setting, fallback, abstraction or dependency; nothing with one value in practice.
- No new test that proves nothing or duplicates another (the PR adds no tests at all — a gap in coverage, but adding tests is outside this lens).
- No existing helper duplicated: the registration reuses
stop_consolerather than introducing a second handler. - The PR description satisfies the four-part scheme in
AGENTS.md:72-113; no prose to trim there. - The
--rank-rejection block atflare-cli/src/main.rs:178-186is not made redundant by moving the handler — it independently invalidates incompatible flags.
Open questions / not verified
- No build, no run. No Windows toolchain or GPU was available to me either; CI on the head commit reports no checks, although
.github/workflows/native-serving.yml:6(not opened) would build and testflare-clionwindows-2022for a pull request. The "STOP is not read before the serving loop" premise is verified by reading the code (flare-cli/src/main.rs:209-260is#[cfg(unix)];STOPis loaded at:714), not by execution. - Whether the exact insertion point before
:702is the tightest choice versus beforeLoadedSession::newat:698: I chose 702 because 698 is whereownerbegins to be live and 701 is the "Start server" phase boundary the PR targets. Either works; the difference is which failures keep the default termination. - Signed-off-by / authorship raised by the reviewer is outside the subtraction lens and not assessed here.
Tally
- Diff under review: +8/−6 = 14 lines, all obsolete (finding 1).
- Portable equivalent: −6 +7 = 13 lines in
flare-cli/src/main.rs. - Removable from that smaller version: 1 line (finding 2); 0 lines of doc churn if finding 3 is a rewrite in place.
- Net: this is not a change that needs shrinking — it needs rebasing. Once ported it is minimal, and the only cut left is one redundant comment sentence.