Subtraction, Simplicity & Conventions review — PR #178 (flare-cli/src/main.rs, docs/windows.md)
Key findings
The diff is already lean; nothing should be removed. PR #178 is a verbatim move of one six-line #[cfg(windows)] block out of run() and into serve_local() (flare-cli/src/main.rs:704-710), plus a two-line docs sentence (docs/windows.md:141-142, verified verbatim at the head). It introduces no flag, knob, wrapper, fallback layer, dead code, or dependency. windows-sys's Win32_System_Console feature is already listed (flare-cli/Cargo.toml:49), exactly one registration site remains (SetConsoleCtrlHandler → flare-cli/src/main.rs:707), and stop_console (:737-746) keeps exactly one caller.
Three modest findings, none blocking:
- (Medium, optional dedup) The platform-install idiom now exists at three sites in this file —
serve()atmain.rs:647-651andserve_local()at:699-710duplicate the Unixlibc::signalpair verbatim.flare-cli/src/orbit/controller.rs:66-75already establishes acatch_interrupts()helper with a doc comment and aSAFETY:line, which is the pattern to follow. A singlefn catch_termination() -> io::Result<()>turns 12 lines into twocall()?;sites and gives the newunsafeblock theSAFETY:rationale every otherunsafeinmain.rscarries (:287,:551,:599). - (Low, prose)
docs/windows.md:141-142packs two behaviors and a trailing temporal clause into one conjunction; "drain native work once serving has started" can be misread as scoping the loading behavior. Split into two present-state sentences. - (Low,
AGENTS.mdconvention)AGENTS.md:57-58requires unrun checks to be recorded indocs/TODO.txt. The loading-termination behavior asserted atdocs/windows.md:141-142has never been run on Windows, anddocs/TODO.txthas no Ctrl-C/console/windows-live entry at all (search_codeforCtrl|console|Windows live|unrun, ignore case: no matches).
A. Subtraction — nothing removable was introduced or left behind
- Removed cleanly, no orphan. The deleted block sat before
let bind = args.bind_address();(nowmain.rs:187); the Windows multi-host rejection ends at:185.pr_diffshows exactly 6 removed / 7 added lines inmain.rsand 2/2 indocs/windows.md. No leftover early registration, and no second path to prune:run()rejects multi-host on Windows (main.rs:178-186) andserve()dispatches local runs at:597, soserve()'s Windows branch stays unreachable. - No dead code at either end of the flag.
STOPis read only atmain.rs:656,:674,:715,:729and set at:54(Unixstop) and:741(stop_console).stop_console(:737-746) has exactly one caller,:707. Nothing in the crate readsSTOPbefore serving — which is precisely what makes the new comment at:706true. - No new cargo surface.
flare-cli/Cargo.toml:49already gateswindows-syswithWin32_System_Console; the diff adds no feature, flag, or dependency line. - The new comment is an invariant, not change history — keep it.
main.rs:706:// Loading keeps the default Ctrl-C termination; nothing reads STOP before serving.It states a property of the placement, which is the only thing a later reader could get wrong. Under finding 1 it becomes the helper's doc comment, not a deletion.
B. Simplicity & duplication — finding 1, with the counterweight
Current shape, flare-cli/src/main.rs:699-710:
#[cfg(unix)]
unsafe {
libc::signal(libc::SIGINT, stop as *const () as libc::sighandler_t);
libc::signal(libc::SIGTERM, stop as *const () as libc::sighandler_t);
}
#[cfg(windows)]
unsafe {
// Loading keeps the default Ctrl-C termination; nothing reads STOP before serving.
if windows_sys::Win32::System::Console::SetConsoleCtrlHandler(Some(stop_console), 1) == 0 {
return Err(std::io::Error::last_os_error().into());
}
}
flare-cli/src/main.rs:647-651 in serve() is the same Unix half, byte for byte:
#[cfg(unix)]
unsafe {
libc::signal(libc::SIGINT, stop as *const () as libc::sighandler_t);
libc::signal(libc::SIGTERM, stop as *const () as libc::sighandler_t);
}
The repo already has the abstraction this wants, flare-cli/src/orbit/controller.rs:66-75:
/// Record SIGINT and SIGTERM in [`INTERRUPTED`] instead of terminating, so that waiting loops
/// can stop a group in order.
fn catch_interrupts() {
INTERRUPTED.store(false, Ordering::Relaxed);
// SAFETY: the handler only stores to an atomic, which is async-signal-safe.
unsafe {
libc::signal(libc::SIGINT, interrupt as *const () as libc::sighandler_t);
libc::signal(libc::SIGTERM, interrupt as *const () as libc::sighandler_t);
}
}
Concrete simplification: add one file-level helper next to stop (main.rs:51-55) / stop_console (:737-746):
/// Record Ctrl-C and Ctrl-Break in [`STOP`]. Loading keeps the platform default termination.
///
/// # Errors
/// Returns the console handler registration error on Windows.
fn catch_termination() -> std::io::Result<()> {
// SAFETY: the handler only stores to an atomic, which is async-signal-safe.
unsafe { /* cfg(unix) signals; cfg(windows) SetConsoleCtrlHandler, else last_os_error() */ }
Ok(())
}
Both call sites become catch_termination()?; — 12 lines become 2, and both unsafe blocks gain the SAFETY: rationale that main.rs:287, :551, :599 and parallax.rs:198 all carry and that the new block at :705 lacks.
Honest counterweight (why this stays optional): AGENTS.md:188-193 — "Reject unsupported abstractions and churn… Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost." Extracting the helper is adjacent churn to a two-file bug fix, and the file's own live convention is the inline per-call-site cfg block (flare-cli/src/parallax.rs:197-202 installs the same signals inline with a SAFETY: comment). I would not block on it; if the author wants the smaller diff, add the missing // SAFETY: line at main.rs:705 instead and leave the duplication.
C. Not removable (checked, and should stay)
- The
Err(last_os_error())return atmain.rs:707-709is not a removable fallback branch. It is pre-existing behaviour, and it is not an ad-hoc drain path:ServingSessionimplementsDrop→close()(helios/src/server/session.rs:104-108), so the early return still passes through the defined drain. Deleting it to "simplify" would remove the report-path the PR's own rationale relies on. - No repo helper was missed.
search_codeforSetConsoleCtrlHandlerfinds onlyflare-cli/src/main.rs:707andheliopause/src/processes_windows.rs:38,48— the latter is Ignition's own scopedExitProcess(130)handler for the preparation CLI, a different contract (flare runmust drain, notExitProcess), and not a reasonable dependency direction forflare-cli. Searches forctrl_c,ConsoleCtrl,GetConsoleCtrlHandler,fn (shutdown|stop|terminate)_(handlers?|signals?|hook), andinstall|record_?(signal|interrupt|stop)found no shared abstraction. So finding 1 is a new extraction, not a re-use — which is exactly why it is optional rather than a duplication defect. - Nothing to borrow from
eos/orflare/src/windows.rs: noconsole handlerhits ineos/;flare/src/windows.rsis trust store, known folders, locks, terminal columns and file identity only. The inlinewindows-syscall is the repo's existing idiom.
D. Conventions
- Finding 3 (
AGENTS.md:57-58). The docs sentence atdocs/windows.md:141-142asserts loading-termination behaviour; the PR states it was never run on Windows (only acargo xwin checkcross-compile, per the PR discussion).AGENTS.md:57-58: "Record unresolved defects, unrun checks, and pending measurements in [docs/TODO.txt]".docs/TODO.txtcurrently has no such entry (search_codeforCtrl|console|Windows live|unrun, ignore case → no matches). Concrete fix: one line indocs/TODO.txtnaming the unrun Windows liveflare run CORECtrl-C check across download/loading and after "Start server", plus its removal criterion. This is a smaller and more conventional change than annotating the doc sentence with a qualification, and it keepsdocs/windows.mdpresent-state asAGENTS.md:52-56asks. - No structural violation of module conventions was found: the block keeps its
#[cfg(windows)]gating, stays inside the function that owns the serving loop, and the handler type (unsafe extern "system" fn(u32) -> i32) matches thewindows-syssignature without a wrapper or shim.
Open questions
- Do the helpers in finding 1 fit the maintainers' reading of
AGENTS.md:188-193here, or is the inline idiom (parallax.rs:197-202) the intended one? Only a maintainer can settle a churn-boundary call; the diff is correct either way. - Is a
docs/TODO.txtline acceptable for a check the author cannot run (no Windows GPU host), or does the project prefer the unqualified doc sentence plus the PR-thread caveat?AGENTS.md:57-58is explicit, but the TODO file has no precedent entry for hardware-gated checks that I could locate. - Cosmetic, unrelated to this lens and still unanswered since 2026-11-26: the now-default-terminated loading exit restores no ANSI/cursor state (
\x1b[0m\x1b[?25h), unlikeheliopause/src/processes_windows.rs(not opened). Out of scope for this PR's subtraction review.
Could not find
- No CI result on the PR, so nothing confirms the moved block links or runs on Windows.
- No Windows user report of the swallowed-Ctrl-C symptom; issue #113 remains a Linux report closed as resolved by its reporter.
- No
docs/TODO.txtprecedent for recording a hardware-gated unrun Windows check, so finding 3's form (one line vs. a section) is inferred fromAGENTS.md:57-58alone.
Verdict for this lens: diff is already lean and idiomatic — 0 must-fix, 1 optional dedup (finding 1), 1 prose split (finding 2), 1 AGENTS.md TODO-convention note (finding 3). Nothing in the change should be deleted.