Repository navigation
serve: d opens a live view of slots, placement, requests, records and the connect lines - #939
Conversation
There was a problem hiding this comment.
Verdict: MUST_FIX: two mechanical duplication fixes (a second window-size ioctl, and one repeated unsafe sequence that R2 asks to be one wrapper); no behavior bug found.
Must fix
1. term::size is a second copy of the window-size query
crates/serve/src/live/term.rs:137 repeats the TIOCGWINSZ ioctl that screen.rs:212 already does in paint (same zeroed winsize, same unsafe block). The PR body says "Duplication: none". One owner removes one unsafe block and one winsize literal.
Fix: add the owner in screen.rs; paint calls winsize(std::io::stderr().as_raw_fd()) and keeps its two messages; term::size becomes TTY.get().and_then(|t| crate::screen::winsize(t.as_raw_fd()).ok()) mapped to usize.
pub(crate) fn winsize(fd: std::os::fd::RawFd) -> std::io::Result<(u16, u16)> {
let mut size = libc::winsize { ws_row: 0, ws_col: 0, ws_xpixel: 0, ws_ypixel: 0 };
// SAFETY: fd is a live descriptor and size a writable winsize for this ioctl.
if unsafe { libc::ioctl(fd, libc::TIOCGWINSZ, &mut size) } != 0 {
return Err(std::io::Error::last_os_error());
}
Ok((size.ws_col, size.ws_row))
}2. One signal-set sequence is written three times as separate unsafe blocks (R2)
Zeroed sigset_t, sigemptyset, sigaddset appear at crates/serve/src/live/term.rs:315 (SIGTTOU), term.rs:339 and mod.rs:346 (SIGTSTP). R2: an invariant repeated in three places becomes one safe wrapper. It removes 6 of the 57 serve blocks the tools/unsafe-ratchet.txt PIN sets (14 before), so lower the pin with it.
Fix: add to term.rs; use only(libc::SIGTTOU) and only(libc::SIGTSTP) at the three places (pub(super) for the test).
pub(super) fn only(sig: libc::c_int) -> libc::sigset_t {
// SAFETY: an all-zero sigset_t is a valid value for sigemptyset to clear.
let mut set: libc::sigset_t = unsafe { std::mem::zeroed() };
// SAFETY: set is a writable sigset_t.
unsafe { libc::sigemptyset(&mut set) };
// SAFETY: set is an initialized set.
unsafe { libc::sigaddset(&mut set, sig) };
set
}Non-blocking
⚠ The view skips a frame without a word: mod.rs:301 returns when term::size() fails or the width is under MIN_COLUMNS. The user sees the last frame frozen, with no line saying why. Direction: draw one short "terminal too small" line.
⚠ The panic hook ends the view for a panic the server catches: live/mod.rs:108 runs restore_on_panic, which sets GONE, for every panic; embeddings.rs:661, video.rs:778 and worker.rs:455 catch panics and keep serving. After a caught embed_batch panic the view closes for good and d does nothing. Direction: say so in the module doc, or restore only outside catch_unwind.
⚠ Test misses a mutant: term.rs:393 || self.partial.len() == SPILL_LINE_BYTES bounds a line at 64 KiB. Dropping that clause turns no assertion red: the_spill_keeps_order_and_names_what_it_dropped feeds only short lines. Add one take of SPILL_LINE_BYTES + 1 bytes without a newline and assert two lines.
⚠ where_rows (complexity 16 → 28) builds the same facts in rows, sections and sizes, with gib(paged) formatted twice per arm (screen.rs:720-743). Later work: keep the numbers in Sizes once and let each screen format them.
Checked
- Duplicates: about 40 new items Grepped; hits are items 1 and 2; dryer 0 pairs.
- Complexity:
tiles,panels,tableare new and flat;Live::pressis key arms;Server::runadds two guarded calls. - Silent failure: 9 sites followed; all named or bounded except the frame skip. Tests: the PTY test and
keys_need_every_conditionturn red on their mutants. - Gates: the
PIN(2026-10-29)lines move only the unsafe ratchet. Performance: no hot-path term. Escape catalog: none.
Notes
- No
nvidia-smiline, commit hashes orjust gate-*output in the PR body; no GPU evidence counted. No kernel touched. - Tested on a Mac only; the Linux PTY test is not shown to pass on Linux CI.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
2124530 to
31c5f25
Compare
There was a problem hiding this comment.
Verdict: CLEAN: both earlier must-fix items are fixed, and the new commits add no behavior bug or duplicate.
Since the last review:
- Must fix 1 (second window-size ioctl): fixed.
screen::winsizeis the one owner;paintandterm::sizecall it. - Must fix 2 (signal-set sequence three times): fixed.
term::onlyreplaces all three. The ratchet moves 57 to 54; I counted 54unsafe {lines incrates/serve, so the pin is exact. - ⚠ frame skipped without a word: fixed.
view::framedraws "terminal too small", andLive::drawdraws "terminal size unavailable". - ⚠ panic hook closes the view for a caught panic: answered in the module doc (
live/mod.rs:17). - ⚠ spill test misses the line-bound mutant: fixed. Without the
== SPILL_LINE_BYTESclause, a take ofSPILL_LINE_BYTES + 1bytes gives 2 lines, not 3, so the new assertion turns red. - ⚠
where_rowsrepeats the fact in three outputs (complexity 16 to 28): still open as later work; the doublegib()per arm is gone.
Non-blocking
⚠ The PIN line at unsafe-ratchet.txt:1022 says "remove seven blocks … add three". The net is minus three, but the diff removes seven and adds four (the pipe's second block, sigismember, two TIOCSWINSZ). Say "add four" so the next reader can redo the count.
Checked
- Duplicates: 6 new items checked (
winsize,only,Reapedmove, theframeguard, the two draw messages), none duplicated. dryer: 0 pairs. - Complexity: the new commits add no function crapper flags.
- Silent failure: 3 sites followed (the size read, the new draw error, the
spawn_helpererror). Each is named on stderr or restores the terminal. - Tests: the
onlytest turns red if the set holds another signal. The resize test turns red if the guard is dropped. - Threads:
spawn_helperwithPlacement::Floatmatches the check-arch axis 5 contract. - Gates: the only pin moved is the unsafe ratchet, with a dated
PIN. Performance: no hot-path term. Escape catalog: none matched.
Notes
- The PR body has no
nvidia-smiline and nojust gate-*output. No GPU evidence counted. No kernel is touched.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
31c5f25 to
cca13cb
Compare
There was a problem hiding this comment.
Verdict: CLEAN: the only change since the last review rewrites two test lines, and it adds no behavior bug, duplicate or unsafe block.
Since the last review:
- ⚠ PIN line says "add three" (should be four): still open at unsafe-ratchet.txt:1023. Not blocking. Say "add four" (the pipe's second block,
sigismember, twoTIOCSWINSZ) so the next reader can redo the count. - ⚠
where_rowsrepeats one fact in three outputs (complexity 16 to 28): still open as later work. - All other earlier items were fixed or answered in the last review. Their commits are unchanged.
Checked
- Duplicates: 0 new items in the changed commit. dryer: 0 pairs.
- Complexity: the changed commit adds no function crapper flags.
- Silent failure: 2 sites followed, the two
TIOCSWINSZcalls in live/mod.rs:501 and :506. Each return code is bound torcand asserted to be 0, so the check is kept. - unsafe: each of the two blocks still has its
// SAFETY:line directly above. Theunsafe {line count is unchanged, so the ratchet pin of 54 stays exact. - Tests: the resize test keeps its assertions. It turns red if the "terminal too small" guard is dropped.
- Gates: no pin moved by this commit. Performance: no hot-path term. Escape catalog: none matched.
Notes
- The PR body has no
nvidia-smiline and nojust gate-*output. No GPU evidence counted. No kernel is touched.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
… the connect lines The start screen stays as it is and gains one key on its key row when the server takes keys: BLOOMERY_SCREEN on, stdin and stderr terminals, the process in the foreground and TERM not dumb. A seat that draws no start screen (bloomery-serve-metal) names the key on a line of its own. d opens the view on the alternate screen with the terminal in cbreak (ISIG kept), q or Esc closes it, Ctrl+C stops the server through the existing path. Its header names the model, the time served, the status, the seat, the address and the load time. Tabs: - Overview: the seat's states, tiles for decode, prefill, the card's memory, the host's experts, the prompt cache and the NVMe tier, bars for the context and the experts, and the last requests that ended. - Placement: the experts bar with each part's count, then the card, tier card, host, NVMe and context sections, one labelled value a line. - Requests: the last 64 that ended, and the newest one's time split. - Records: the start screen's tape. - Connect: the routes, who can reach them, a curl command and the client settings. A tab, tile, bar or section line whose numbers the seat does not have is left out, and the tiles left fill their rows: four, two or one to a row by width. Text cut to fit ends with an ellipsis. The view copies the server's counters in-process every 0.5 s while open and does nothing while closed. While the view is open stderr goes through a pipe into a bounded buffer and comes back below a rule when it closes, with a line naming what was dropped. The terminal settings come back on q, on the orderly stop, on a second interrupt, on a server error, on a panic and around SIGTSTP and SIGCONT. /metrics and the view share one owner for the rates, the decoded positions and the context room; the route paths are named once. The start screen's record reader also hands the view the byte counts behind its rows and the same values as labelled sections.
cca13cb to
af64375
Compare
There was a problem hiding this comment.
Verdict: CLEAN: the changes since the last review are a macOS stub for sibling_of, a recount of the unsafe pins and a qdot recipe move. I found no behavior bug, duplicate or unneeded element in them.
Since the last review:
- ⚠ PIN line says "add three" (should be four): still open at unsafe-ratchet.txt:1023. Not blocking.
- ⚠
where_rowsrepeats one fact in three outputs (complexity 16 to 28): still open as later work. - All other earlier items were fixed or answered. Their commits are unchanged.
Non-blocking
⚠ Three PIN lines each read "serve 14 -> 54": unsafe-ratchet.txt:1015, 1020 and 1022. The rebase recount made each line claim the whole step, so they no longer read as a chain. Say "serve 14 -> 54 blocks in total" once, and give the other two lines their own part (for example "of which 4: the PTY test's signal set").
Checked
- Duplicates:
sibling_offor macOS is the same function under the othercfg, not a copy. The othersibling_ofhit is a test helper incrates/hf. dryer: 0 pairs. - Complexity: the new commits add no function that crapper flags.
- Silent failure: the macOS
sibling_ofreturnsNone.Placement::Siblingthen floats the helper, andHelper.pinnedreportsNone, the same as a core without SMT.cpu_listis used only by the Linuxsibling_of, so no dead code on macOS. - unsafe: 54 sites in
crates/serve, equal to the ratchet. The new commit adds none. - Tests: the recipe check
expect(not real.get("bloomery-qdot"), ...)turns red if qdot is rejected again, and thepure_nowlist turns red if qdot leaves the set. - Gates: the qdot move in
tools/recipes.pyhas a datedPIN(2026-10-29)with the reason. No other pin moved. - Performance: no hot-path term. Escape catalog: none matched.
Notes
- The PR body has no
nvidia-smiline and nojust gate-*output. No GPU evidence counted. The commit in "What I ran" (31c5f250) is not the current head.
🔨 Shingler, bloomery's review bot: approves a clean pull request and requests changes on a must-fix (how it works)
|
The review is done and the contribution check passed, so I'm merging this. |
bloomery-serve 시작 화면은 그대로 두고, 서빙 중 d 키를 누르면 서버 상태를 보여 주는 라이브 화면을 엽니다.
Part of #565.
What and why
The start screen is drawn once when the server listens. After that a person at the terminal sees only request lines, and to learn how the seat is doing they have to read
/metricsor/slotsby hand. This PR adds a live view they can open from the same terminal.The start screen does not change, except for one key on its key row:
d opens the live view. The key shows only when the server takes keys:BLOOMERY_SCREENis on, stdin and stderr are terminals, the process is in the terminal's foreground group, andTERMis notdumb. Piped or redirected output, a server started with&, andTERM=dumbget no key and no change at all.A seat that draws no start screen (
bloomery-serve-metal) prints the key on a line of its own after itslisteningline.dopens the view on the alternate screen.qorEsccloses it and the server keeps serving.Ctrl+Cstops the server through the existing orderly stop. The terminal is in cbreak only (canonical mode and echo off, signals and output processing kept), soCtrl+Cstays a signal.Every tab shares one header: the wordmark, the model and uptime, the state badge, seat name, address and load time, and the tab row. The number keys pick a tab:
card,tier card,host,nvmeandcontextsections of key and value rows.trycommand and the settings for an OpenAI-compatible client.Only facts the server already has are drawn. A tile, row or tab whose facts the seat did not record is left out, and the remaining tiles widen to fill their row. Tiles go four to a row, then two, then one as the terminal narrows. Outside UTF-8 the boxes and bars use ASCII. A terminal too small to draw in, or one whose size cannot be read, gets a message on screen.
The view copies the server's counters in-process every 0.5 s while it is open. While it is closed the key thread waits in
polland touches nothing else.While the view is open, anything the process writes to stderr goes through a pipe into a bounded buffer. When the view closes it is printed below one rule, in order, with a line naming how many lines were dropped if the buffer filled.
The terminal settings and the main screen come back on
q, on the orderly stop, on a second interrupt, on a server error, on a panic, when the key thread cannot start or its read fails, and aroundSIGTSTPandSIGCONT. A view stopped withCtrl+Zand continued withbgstays closed until the server is in the foreground again.Release notes: Added: the
bloomery-servescreen now has a live view for advanced users. Pressdon the start screen to see the seat's state, rates, placement, recent requests, start records and connect lines;qreturns to the log.Code shape
facts(), the stats and board owners/metricsreads, and the route pathsroute()matches./metricsnow goes through the same rate, position and room functions. The start screen and the view read the window size in one function,screen::winsize, and build their signal sets in one function,term::only.servemoves with aPINline, and each block has itsSAFETYline.cargo fmt --all -- --checkis clean.Duplication found or removed (
path:line): none beyond the shared window size and signal set functions above.No new environment variable:
BLOOMERY_SCREEN's registry row now says it also turns the live view on.What I ran
Commit
31c5f250e559f91ab52f2088cabc2ca2e48c9a35on top offdc0ccad2f7d45b59f1f7b017f34df2660db6240, run on a Linux machine and on a Mac:live::tests printtest result: ok. 8 passedand thescreen::tests printtest result: ok. 17 passed.test result: ok. 8 passedandtest result: ok. 17 passed.cargo fmt --all -- --checkprints nothing,check-arch: ok, andcheck-unsafe: ok.a_failed_startup_reaps_its_childprintstest result: ok. 1 passed.A pseudo-terminal test starts the server, checks the key on the start screen and cbreak, presses
d,q,dandCtrl+C, and compares the terminal settings at exit with those at start. A second case stops the view withCtrl+Zin a session where the stop is discarded and checks thatdstill opens the view without Enter.On a DGX Spark serving Qwen3.8-Flash-Next-FP4-Local in Ghostty, I sent three requests, pressed
dduring a 1,500-token stream, went through every tab and closed the view withq. The start screen came back with the lines written meanwhile below one rule. Screenshots from that run:The start screen with the new key
Overview
Placement
Requests
Records
Connect
After
q: the start screen and the lines written while the view was openAI help
AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.