Skip to content

serve: d opens a live view of slots, placement, requests, records and the connect lines - #939

Merged
juliankang4 merged 5 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-serve-live
Oct 29, 2026
Merged

juliankang4 merged 5 commits into
midagedev:mainfrom
juliankang4:dgx-spark-q38-usab-serve-live

Conversation

@juliankang4

@juliankang4 juliankang4 commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

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 /metrics or /slots by 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_SCREEN is on, stdin and stderr are terminals, the process is in the terminal's foreground group, and TERM is not dumb. Piped or redirected output, a server started with &, and TERM=dumb get 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 its listening line.

  • d opens the view on the alternate screen. q or Esc closes it and the server keeps serving. Ctrl+C stops the server through the existing orderly stop. The terminal is in cbreak only (canonical mode and echo off, signals and output processing kept), so Ctrl+C stays 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:

    • Overview: state chips (idle, prefill, decode, queued, fault) with the slot count in each; tiles for decode rate, prefill rate, card memory, host and tier card experts, prompt cache reuse and the NVMe tier; bars for context use and where the routed experts went; and the recent requests.
    • Placement: the expert bar with a card, tier card, host and nvme legend, then card, tier card, host, nvme and context sections of key and value rows.
    • Requests: the last 64 that ended, with their prompt, cached and output counts, rates, engine time and how they ended, and a split of the latest one into cache lookup, prefill and decode.
    • Records: every record line the start printed.
    • Connect: the routes, the bind and key settings, the try command 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 poll and 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 around SIGTSTP and SIGCONT. A view stopped with Ctrl+Z and continued with bg stays closed until the server is in the foreground again.

Release notes: Added: the bloomery-serve screen now has a live view for advanced users. Press d on the start screen to see the seat's state, rates, placement, recent requests, start records and connect lines; q returns to the log.

Code shape

  • No second copy. The view reads the start screen's tape and facts(), the stats and board owners /metrics reads, and the route paths route() matches. /metrics now 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.
  • Model code holds only architecture facts. Nothing model-specific changed.
  • Dead code is gone.
  • No silent failure. A terminal call that fails is named on stderr, the view turns off and the server keeps serving. A full stderr buffer names the lines it dropped. A caught panic closes the view, and the module docs say so.
  • Comments state what is true now.
  • No relaxed gate. The four golden screens change only on their key row. The unsafe ratchet for serve moves with a PIN line, and each block has its SAFETY line.
  • cargo fmt --all -- --check is 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 31c5f250e559f91ab52f2088cabc2ca2e48c9a35 on top of fdc0ccad2f7d45b59f1f7b017f34df2660db6240, run on a Linux machine and on a Mac:

cargo test -p bloomery-serve --lib live:: -- --test-threads=1
cargo test -p bloomery-serve --lib screen:: -- --test-threads=1
cargo fmt --all -- --check
bash tools/check-arch.sh
bash tools/check-unsafe.sh
cargo test -p bloomery-serve --test serve a_failed_startup_reaps_its_child -- --exact --nocapture
  • Linux: the live:: tests print test result: ok. 8 passed and the screen:: tests print test result: ok. 17 passed.
  • Mac: the same two runs print test result: ok. 8 passed and test result: ok. 17 passed.
  • Linux: cargo fmt --all -- --check prints nothing, check-arch: ok, and check-unsafe: ok.
  • Linux: a_failed_startup_reaps_its_child prints test result: ok. 1 passed.

A pseudo-terminal test starts the server, checks the key on the start screen and cbreak, presses d, q, d and Ctrl+C, and compares the terminal settings at exit with those at start. A second case stops the view with Ctrl+Z in a session where the stop is discarded and checks that d still opens the view without Enter.

On a DGX Spark serving Qwen3.8-Flash-Next-FP4-Local in Ghostty, I sent three requests, pressed d during a 1,500-token stream, went through every tab and closed the view with q. The start screen came back with the lines written meanwhile below one rule. Screenshots from that run:

The start screen with the new key

The start screen with the new key

Overview

Overview

Placement

Placement

Requests

Requests

Records

Records

Connect

Connect

After q: the start screen and the lines written while the view was open

After q: the start screen and the lines written while the view was open

AI help

AI 코딩 에이전트가 코드를 작성한 후 설명을 썼고, 테스트를 마쳤습니다. diff 리뷰와 PR 초안 리뷰는 제가 직접 했습니다.

@github-actions github-actions Bot added host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset serve The HTTP server: crates/serve labels Oct 28, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, table are new and flat; Live::press is key arms; Server::run adds two guarded calls.
  • Silent failure: 9 sites followed; all named or bounded except the frame skip. Tests: the PTY test and keys_need_every_condition turn 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-smi line, commit hashes or just 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)

github-actions[bot]
github-actions Bot previously approved these changes Oct 29, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::winsize is the one owner; paint and term::size call it.
  • Must fix 2 (signal-set sequence three times): fixed. term::only replaces all three. The ratchet moves 57 to 54; I counted 54 unsafe { lines in crates/serve, so the pin is exact.
  • ⚠ frame skipped without a word: fixed. view::frame draws "terminal too small", and Live::draw draws "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_BYTES clause, a take of SPILL_LINE_BYTES + 1 bytes gives 2 lines, not 3, so the new assertion turns red.
  • ⚠ where_rows repeats the fact in three outputs (complexity 16 to 28): still open as later work; the double gib() 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, Reaped move, the frame guard, 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_helper error). Each is named on stderr or restores the terminal.
  • Tests: the only test turns red if the set holds another signal. The resize test turns red if the guard is dropped.
  • Threads: spawn_helper with Placement::Float matches 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-smi line and no just 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)

github-actions[bot]
github-actions Bot previously approved these changes Oct 29, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, two TIOCSWINSZ) so the next reader can redo the count.
  • ⚠ where_rows repeats 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 TIOCSWINSZ calls in live/mod.rs:501 and :506. Each return code is bound to rc and asserted to be 0, so the check is kept.
  • unsafe: each of the two blocks still has its // SAFETY: line directly above. The unsafe { 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-smi line and no just 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.
@juliankang4
juliankang4 force-pushed the dgx-spark-q38-usab-serve-live branch from cca13cb to af64375 Compare October 29, 2026 01:13
@github-actions github-actions Bot added the tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo label Oct 29, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_rows repeats 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_of for macOS is the same function under the other cfg, not a copy. The other sibling_of hit is a test helper in crates/hf. dryer: 0 pairs.
  • Complexity: the new commits add no function that crapper flags.
  • Silent failure: the macOS sibling_of returns None. Placement::Sibling then floats the helper, and Helper.pinned reports None, the same as a core without SMT. cpu_list is used only by the Linux sibling_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 the pure_now list turns red if qdot leaves the set.
  • Gates: the qdot move in tools/recipes.py has a dated PIN(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-smi line and no just 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)

@juliankang4

Copy link
Copy Markdown
Collaborator Author

The review is done and the contribution check passed, so I'm merging this.

@juliankang4
juliankang4 merged commit 75380f6 into midagedev:main Oct 29, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

host Host crates: qdot, threads, engram, engram-lab, runtime, sampler, levers, decision, vision, refset serve The HTTP server: crates/serve tools Tools, recipes, CI and the toolchain: tools/, justfile, .github/, Cargo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant