Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #178

Raw Markdown for agents: https://autobot.eidonix.com/p/3af84738-ff1d-434a-8148-f531d58858b3.md

#1 [high] Verified diff state at head 20d2c655 (correctness lens)

PR #178 at head 20d2c655 = pure rebase; pr_diff content identical to 43c6ea78.

flare-cli/src/main.rs:

docs/windows.md:138-142 now reads: "...--trust-store selects another path. Ctrl-C and Ctrl-Break end loading immediately and drain native work before releasing CUDA resources once serving has started." (verbatim verified).

Server::start blocks at helios/src/server.rs:417 ready_rx.recv() and pumps tuning graphs; Server::close at :524-... joins HTTP thread (5 s graceful timeout at :396-405) then model.close() (runtime.rs:1007-1039 joins model thread). No STOP read anywhere in helios.

#2 [high] Findings: handler boundary, second Ctrl-C, tests/evidence

F1 (Minor) — Ctrl-C during loaded.start() is abrupt, undocumented, and the inline comment misplaces the boundary. flare-cli/src/main.rs:704-710 comment ":706 // Loading keeps the default Ctrl-C termination; nothing reads STOP before serving." but the registration is after loaded.start() (:696), which IS the "Start server" phase started at :695 and which blocks at helios/src/server.rs:417 while pumping tuning graphs / graph capture. Ctrl-C there now hard-terminates mid-GPU-init with no drain (same class as main, but docs/windows.md:141-142 only names "loading" and the in-code comment gives a wrong reason: nothing reads STOP before serving, yet the handler is deliberately NOT installed before serving begins). Impact: user pressing Ctrl-C on the spinner labelled "Start server" gets a silent kill with no message; reviewer's regression target is exactly this window, so making the boundary explicit matters. Fix: comment should say "loaded.start() must keep the default termination: it captures graphs and no STOP reader exists until the serve loop"; optionally have the "Start server" phase print a line that Ctrl-C aborts at once.

F2 (Minor) — a single Ctrl-C after readiness is unrecoverable while close() drains; stop_console returns 1 unconditionally. flare-cli/src/main.rs:738-746: if matches!(event, CTRL_C_EVENT | CTRL_BREAK_EVENT) { STOP.store(true, Relaxed); 1 } else { 0 }. After the first Ctrl-C, serve_local runs session.close() (:719) -> Server::close (helios/src/server.rs:524) -> 5 s HTTP grace (:396-405) then model.close() join (helios/src/server/runtime.rs:1007-1039) then Drop -> close() (:732/104-108). Further Ctrl-C is swallowed -> only force-kill or closing the console (CTRL_CLOSE_EVENT returns 0) exits. Fix (2 lines): let already = STOP.swap(true, Ordering::Relaxed); if already { 0 } else { 1 } so the second Ctrl-C falls through to the default handler. Needs no Windows run to be worth doing; Unix has the same structure (main.rs:53-55) but shell escalation gives users an out.

F3 (Minor) — no test anywhere exercises the new block, and the CI that would is known-red. search_code stop_console -> only main.rs:707/738; the sole Windows CLI test is flare-cli/tests/cli.rs:56-75 windows_rejects_multi_host_options_before_loading, unrelated. .github/workflows/native-serving.yml:20-21/43-45/69-73 builds+tests flare-cli on windows-2022 but no check exists on the PR, and #177 documents that job failing on every main commit (eos 0xc0000135, 8 flare test failures), so a red check would be ambiguous. Only the author-reported cargo xwin check ... --target x86_64-pc-windows-msvc exit 0 (2026-11-30) covers it. Fix: a GPU-free Windows unit test (stop_console(CTRL_C_EVENT)==1 and sets STOP; stop_console(CTRL_CLOSE_EVENT)==0) — the function is a plain fn of u32 returning i32; and/or the live flare run CORE Ctrl-C session across loading and "Start server".

Verified SOUND / no finding:

#3 [high] Research summary

Correctness/contracts/system-consequences review of PR #178 at head 20d2c655 (pure rebase; diff = flare-cli/src/main.rs +7/−6, docs/windows.md +2/−2) is complete. Scratchpad entries 1 and 2 hold the verified anchors, the three findings with citations/quotes, and the list of areas verified sound.

Verdict: the change is correct and safe in the areas this lens owns. The diagnosis holds and the deletion is complete — flare-cli/src/main.rs:707 is now the only SetConsoleCtrlHandler site in the whole repo (search_code stop_console → main.rs:707,738 only; CliSignals lives in heliopause, which flare-cli does not depend on, and helios installs no handler). The sibling serve() (:586-683) keeps its Unix-only registration at :647-651 and is unreachable on Windows (run() rejects multi-host at :178-186, serve() dispatches to serve_local() at :596-597), so no second policy is introduced. No behavior changes outside the Windows loading window: serve_local was unreachable before readiness anyway, so the docs contract stays true — docs/cli-design.md:1569 ("Shutdown restores the terminal after draining active execution"), AGENTS.md:278-280, and the rewritten docs/windows.md:141-142. Abrupt termination during download/verify is crash-safe (leases are kernel-released file locks, helios/src/core/cache.rs:7,21; artifact writes are ok/WouldBlock-guarded, :3142-3187; publish precedes return, hub.rs:91). No locks, queues, coalescing, memory, metrics or admission-cost spans are touched, so the system-level and metric-span checks are N/A; no wire/captured-graph contract or design sign-off is involved; the change is #[cfg(windows)]-confined with no new dependency.

Three Minor findings, none blocking the code: (F1) the new inline comment at main.rs:706 misplaces the boundary — the registration at :704-710 sits after loaded.start() (:696), which is the "Start server" phase and blocks at helios/src/server.rs:417 while capturing graphs, so Ctrl-C there is still an abrupt, undocumented kill and the comment's reason is wrong; (F2) stop_console (:738-746) returns 1 unconditionally, so after the first Ctrl-C a second one can no longer terminate during the session.close() drain (:719 → server.rs:524), leaving force-kill or CTRL_CLOSE as the only exits — a 2-line STOP.swap fallback fixes it; (F3) no test exercises the new block (the only Windows CLI test is unrelated multi-host rejection, flare-cli/tests/cli.rs:56-75), no CI check exists on the PR, and native-serving.yml:20-21/43-45/69-73 is known-red per #177, so only the author's cargo xwin check exit 0 covers it.

Also noted for the record: the Discovery Dossier's §D ("description contradicts the head") is stale at this head — the live PR body is accurate (removal from run(), addition after loaded.start(), lld-link limitation, live run unrun, Discord: myong_acct present).

#4 [high] Report skeleton: verdict + evidence trail for #178 correctness lens

VERDICT: no Blocker/Major under the correctness, contracts & system-consequences lens. Diff correct; 3 Minor findings (F1 comment boundary, F2 second Ctrl-C during drain, F3 untested + unobservable CI). Do NOT report the code as "cannot land".

SOUNDNESS EVIDENCE (each directly verified this run):

FINDINGS with quotes already in entry 2; final report must carry: exact file:line, severity, verbatim quote, impact, concrete fix for each of F1/F2/F3.

STALE DOSSIER NOTE: §D must be overridden — live PR body at 2026-11-30 08:57 is accurate (removal from run(), addition after loaded.start(), lld-link limitation, live run unrun, Discord: myong_acct present). Do not repeat the dossier's "description contradiction persists" as a finding.