Repository navigation
T36 — Follow a box's logs and list exited tasks - #3184
Conversation
Add `min session logs`, `min task logs` and `min box logs`, one verb with `-f`, which read the box's output log over ReadLog and follow it until the box is removed (BCLI-012). Add `min task list [--all]`, which lists the task boxes in any state. An exited task shows as `exited (<code>)` until `min box prune` removes it (BCLI-015).
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Approved: every review thread resolved at @agent-137 resolved the last thread, which releases the approval this review had withheld. Nothing to do. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 2 conditions · the full ruling
The logs handler and its owner conform to the design. Two type-noun verbs do not act as aliases of the min box verb filtered to their type (architecture.md line 338). min session logs and min task logs resolve a box of any type, and the test follows a session box with min task logs. C1 adds the type filter. min task list is a second listing with its own table and the label exited (3). For the same record, min box list prints exited (exit 3). C2 routes min task list through the min box list path, filtered to task boxes.
Ruled at 5afb0d3 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
The line carries box output, which can hold secrets.
There was a problem hiding this comment.
arch-review: CONDITIONS · 2 conditions · the full ruling
min box logs conforms to line 473 of the design. Two deviations from the baseline ruling stay open, and the compare does not touch them. min session logs and min task logs read a box of any type. Line 338 says each type-noun verb is the min box verb filtered to that type. C1 adds that filter. min task list is a second listing with its own columns and its own state label. Line 332 says list means the same thing under every noun. C2 makes it min box list filtered to tasks.
Ruled at 957f0b9 against gominimal/arch@7a86ec7bb3c0 by claude-opus-5-5.
There was a problem hiding this comment.
APPROVE withheld: 12 unresolved threads — minimal-foundry[bot] crates/minimal/src/cmd/boxes.rs, minimal-arch[bot] crates/minimal/src/cmd/boxes.rs:74, minimal-arch[bot] crates/minimal/src/cmd/mod.rs:391, minimal-arch[bot] crates/minimal/src/tests.rs:11373, minimal-arch[bot] crates/minimal/src/task.rs:799, ….
minimal-review — advisory review
Verdict COMMENT — No findings.
Panel: 1 of 3 personas ran (supply-chain); did not complete: correctness, security.
|
Round 1 of 10 on the runtime's review findings, pushed as
Verify Converted to a draft: something above needs a person before review. Review threads the coder judged:
A person follows a box's output with Notes from the agent: cargo-nextest is not installed on this box, so I ran each test line with cargo test and the same package and test name. This round changed only the decode warning in copy_log: it records line_len in place of the raw line. |
…ox-s-logs-and-list-exited-tasks
min task logs and min session logs now resolve the box only among boxes of their own type, so a type noun refuses a box of another type. min task list now prints the min box list table, state label and empty lines, filtered to task boxes, in place of a second listing.
|
Round 2 of 10 on a failed check suite, pushed as
Verify Converted to a draft: something above needs a person before review. Review threads the coder judged:
A person runs Notes from the agent: The failed checks were infrastructure faults. The unit job got repeated |
There was a problem hiding this comment.
APPROVE withheld: 12 unresolved threads — minimal-foundry[bot] crates/minimal/src/cmd/boxes.rs, minimal-arch[bot] crates/minimal/src/cmd/boxes.rs, minimal-arch[bot] crates/minimal/src/cmd/mod.rs, minimal-arch[bot] crates/minimal/src/tests.rs, minimal-arch[bot] crates/minimal/src/task.rs:799, ….
minimal-review — advisory review
Verdict COMMENT — No findings.
Panel: 2 of 3 personas ran (correctness, security); did not complete: supply-chain.
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The change now conforms to the design. min session logs and min task logs read only boxes of their own type, as design principle 8 (line 338) requires. min task list prints the min box list table and state labels, filtered to tasks, so list means one thing under every noun (line 332). One note is outside the design: under min task list, the empty-project line says the project has no boxes. That is not true when the project has sessions. Change the plan's exited (3) to exited (exit 3) in the issue.
Ruled at 8738059 against gominimal/arch@949521619eea by claude-opus-5-5.
There was a problem hiding this comment.
minimal-review — approved
Verdict APPROVE — every review thread is resolved; @agent-137 closed the last one. The review of 873805989c10 withheld this approval on the threads open then. Posted as a comment, as the review itself was; the check and the label carry it.
There was a problem hiding this comment.
Babysitter review at 87380598. No blocking findings. The approval is left to the owner, because agent-137 would be approving its own walk's PR.
min box logs/min session logs/min task logsshare one path. Each type noun resolves the address only among boxes of its own Box Type (resolve_typed_box_on_hosts), somin task logs <session-box>is refused and writes nothing.min task listrenders throughrender_box_listfiltered to tasks, with themin box listwording (exited (exit 3)). An exited task stays listed until a prune.- A log line that fails to decode is logged by length only (
line_len), so box output never reaches the log. - Arch passes this head, minimal-review has no findings, and all 12 threads are resolved after I checked the code.
One leftover for the plan: T36's diagnostics line still says exited (3). The code now prints exited (exit 3).
There was a problem hiding this comment.
Thank you for this change. It adds min session logs, min task logs and min box logs with -f, and min task list. The arch rounds left it in good shape: the type nouns now resolve only among boxes of their own type, the task list reuses the min box list table and labels, and the decode warning no longer logs box output. I reviewed head 8738059. The client side is careful about bytes, ordering and the daemon's log cap. My main concern is how a follow ends. A follow of a task ends only when the box is removed, not when the task exits, and a follow does not notice when its reader goes away. Together those can leave min task logs <id> -f running forever in a script.
Findings
1. Medium. A follow of a task never ends when the task exits. crates/minimal/src/cmd/boxes.rs:88 sends follow: args.follow to ReadLog, and the daemon ends a followed read only at reap. That matches the ReadLog contract and the help text at crates/minimal/src/cli.rs:993. But a task box keeps its record after it exits (BOX-038), until a prune or min box rm. So the common script id=$(min task run --detach build); min task logs "$id" -f prints the task's output and then hangs after the task exits, until someone prunes the box. docker logs -f and kubectl logs -f end when the container ends, so people will expect the same. I suggest ending the follow when the box leaves running. After the stream catches up, poll the box's state or watch its exited event, then drain the log once more without following and return. If BCLI-012 really means "until reaped" for tasks too, please raise it with the spec owner and file a follow-up, so this is a decision rather than a surprise.
2. Medium. A follow does not notice a closed reader, and a closed pipe prints an error. copy_log writes with out.write_all(&data)? at crates/minimal/src/cmd/boxes.rs:196. When the reader closes, as in min box logs web | head -1, the command prints error: Broken pipe (os error 32) and exits 1, because crates/minimal/src/main.rs:221 quiets a broken pipe only for min version. With -f, the command writes only when new output arrives. So min task logs job -f | head -1 on an exited task, or on a quiet one, never learns that head left and runs until the box is removed. crates/minimal/src/cmd/box_audit.rs:492 already solves this for min box audit --follow with a reader_gone poll. I would treat a BrokenPipe from the write as a clean end, and in follow mode check reader_gone on stdout between updates, for example on a timer next to next_line.
3. Low. The early-end hint can point at a different box. crates/minimal/src/cmd/boxes.rs:172-173 always suggests min box logs {address}, as your notes say. Under a type noun the address was resolved among boxes of one type, while min box logs resolves it among all types. BOX-004 lets an exited task named job and a running session named job coexist, and name resolution prefers the running box. In that case the hint reads the session's output, not the task's. Passing verb into the message and printing min {verb} {address}, or printing the resolved box id, fixes it. The same message will run again under -f after a daemon restart, which is the main way a follow ends early.
4. Low. A truncated last line reads as a version mismatch. SubsystemLines::next_line returns an unterminated tail as a line once the channel closes (crates/minimal-client/src/lib.rs:1375-1380). A ReadLog line can be up to about 128 KiB of hex, more than one SSH packet. If the daemon stops while it writes such a line, copy_log fails to decode it and says "The output of box … is in a form this version of min cannot read" at crates/minimal/src/cmd/boxes.rs:191. That misleads the person after a daemon restart. I would report a decode failure on the last line before the end as the early-end error from finding 3, or word the decode error so it covers both causes.
5. Low. The empty task list talks about boxes. crates/minimal/src/task.rs:862 reuses render_box_list, so a project with sessions but no tasks prints "This project has no boxes. Run min box list --all…". The first sentence is false there, and the hint names the box verb. I know the arch review asked for the min box list lines. A noun parameter for the empty line, giving "This project has no tasks. Run min task list --all…", keeps one renderer and stays true. I would leave this to you and the arch reviewer.
6. Low. The tests leave three claims unpinned.
- In
type_noun_logs_follow, the drive stops and removes each box in one step (crates/minimal/src/tests.rs:11435-11440). A follow that wrongly ended at stop would pass too. Asserting that the follows are still pending after the stop, with a short timeout that must elapse, pins "until removed". It will also pin whatever you decide for finding 1. - In
task_list_shows_exited_until_pruned, the scoped listing is asserted only for another project (crates/minimal/src/tests.rs:11585). Please addlist(Some(project))and assert that it shows the task. That is the defaultmin task listpath. - "The exited task stays until a prune removes it" (
crates/minimal/src/tests.rs:11589-11590) repeats the listing right after the first one, so it adds nothing. The forged record at line 11551 is a fair stand-in, as your notes explain.
7. Nits.
- The
min box logshelp atcrates/minimal/src/cli.rs:497says the output stays "untilmin box rmremoves it".min box pruneremoves it too. min box listtakes-o jsonandmin task listdoes not. Iflistmeans the same under every noun, the task list would take it as well. This could be a follow-up.- This is outside this diff, but it bears on BCLI-015. An interactive task, one with no spec, runs through the owns-box exec at
crates/minimal/src/task.rs:1355, and the daemon destroys its box at exit. Such a task never appears as exited inmin task list. If that is intended under NET-131, a sentence in the help would avoid the question.
Checked and fine
- Type filtering.
resolve_typed_box_on_hostsdrops other types before resolution and narrows a qualified address to its host, the same wayresolve_box_on_hostsdoes. The refusal tests cover both directions. - Bytes. Output is written as raw bytes and flushed per chunk, so partial UTF-8 and partial terminal lines pass through unchanged.
- Bounded buffers and back-pressure. The daemon sends at most 64 KiB of log per line, and the SSH window holds the daemon back when the client is slow. The daemon-error buffer is bounded.
- Log cap and drops. One
LogReaderper stream on the daemon side means no byte is sent twice across a drop, and the drop line marks the gap. - Client interrupt. Ctrl-C drops the channel, and the daemon's follow loop ends on the channel's close.
- Daemon restart. The channel closes without a terminal update, which is reported as an early end with a non-zero exit.
- RPC compatibility. The change is client-only. ReadLog shipped in #2852, and the selected host is gated by
ensure_version_match, so an older daemon is refused before any read. The request uses fields with serde defaults. - Task list. The project filter is the same equality the daemon's
list_boxesuses. Rows come in box-id order per host, which is creation order for UUIDv7 ids. A spec'd task's record is retained after exit, and a prune removes it. An unreachable non-selected host is named on stderr, and the selected host's failure ends the command, as inmin box list. - Observability. Each path records the verb, the resolved box id and the outcome, and the decode warning logs only the line length.
- CI. CI is green on this head, except
unitandartifacts, which were still pending when I looked.
Verdict
Approve with nits. Findings 1 and 2 together can hang a script, so I would like them fixed here or tracked in an issue against BCLI-012 before merge. Findings 3 to 7 can land here or in a follow-up, whichever you prefer.
Reviewed with lab tooling on the branch head; the lab round, where one ran, is cited in the text. Questions welcome.
There was a problem hiding this comment.
Approving with nits (in the review above). Before merge I'd track the two mediums: -f ends only at reap, so following a detached task hangs after it exits; and a closed reader is never noticed (box audit --follow has the in-crate pattern).
* feat(minimal): add min box start and min session start Both verbs create a box from an entry of the project. With no entry, min box start picks the default entry of any type, else the only one, and min session start picks the default session entry, else the only one. The implicit default entry counts. A session box attaches this terminal unless --detach is given. Off a terminal, without --detach, the start exits 2 before it creates anything. A task entry starts detached, with its stdin closed, and one hint names min box run, min box logs and min box wait. --name sets the box's [box] name, and --new asks for a fresh instance. A held name exits 2, names the holder and names --new and --name. * test(minimal): list the start name test's requests in the create inventory * fix(minimal): refuse --name for a task entry in min box start The run path names a task box itself and takes no name, so the start dropped --name without a word. It now refuses the flag with exit 2 before it creates anything. --new already holds for a task box: its generated name is never held. * docs(minimal): link the start interims to gominimal#3196 and gominimal#3197 Name the issues that track the task-entry --name refusal and the unsupported-type refusal, and correct the run-path comment: a task-entry start is always a fresh instance named <entry>-<n>. * fix(minimal): read the typed session entry's egress on start min session start <entry> reads the egress of that entry, not of default. A typed entry needs no default to start. Link the entry body residual of stamp_session_spec_as to gominimal#3204. * fix(minimal): print a port in use the same on min box start Both start verbs share start_refusal, so the port-in-use rewrite moves there. min box start now names the port and its holder, as min session start does. * docs(minimal): name the --name run gap and the logs/wait merge order BCLI-069 gives --name to min box run and min task run too. Say where that waits: RunEntry takes no box name yet. The unattached start hint names min box logs and min box wait, which gominimal#3184 and gominimal#3195 add, so this change merges after both. * fix(minimal): refuse unresolved types and [boxes] tasks on start start_candidates refuses an entry whose type has no built-in root (gominimal#3140) before the session filter, so a project Box Type never gets the implicit default. plan_start refuses a [boxes] task entry (gominimal#3213). StartEntryRefusal::exit_code gives 4 for an entry the start does not find. run_entry returns the box id, so the detached start names it in its hint and records it on the span. * docs(minimal): document min session start Give its arguments, how it picks the entry, and its refusals with their exit codes: 4 for an entry it does not find, 2 for the others. * fix(minimal): refuse unresolved types only when start counts entries Move the TypeUnresolved refusal after the explicit-entry lookups in pick_box_start_entry and pick_session_start_entry, in the order that pick_session_entry uses. A typed project entry or an explicit default entry now starts beside an entry of a project Box Type. * fix(minimal): escape entry names in every start refusal NotSession, UnsupportedType, StartNeedsTerminal and the entry lists in Several and Unknown printed names from minimal.toml raw. Pass each name through printable, as the sibling arms do, and pin it in a test. * fix(minimal): refuse a typed session entry other than default The box of a typed session entry gets the entry's name in its spec, but its body still comes from the [session] table. Until gominimal#3204 applies the entry's own body, both start verbs refuse such a start with exit 2, before anything is created. A typed default and a bare start of the only session entry still start. The tests now plan the two starts that 43b4a42 broke: a bare start beside an unresolved project type, and min box start build. * test(minimal): start the only session entry bare in the off-tty test A typed dev is now refused until gominimal#3204, so the off-terminal test reaches the terminal refusal through a bare start of the sole entry. * fix(minimal): escape the names in the held-name start refusal StartNameHeld printed the entry, the held name and the holder's name raw. A name with control characters can no longer move the cursor. * chore(minimal): drop the start hint's merge-order comment min box wait is on main now, so the comment's claim that this branch lacks it is false. * fix(minimal): set run network fields in box start of a task The merge of main added network and egress to RunEntry. The task start of min box start takes no network flags, so it passes none. --------- Co-authored-by: minimal-foundry[bot] <327719912+minimal-foundry[bot]@users.noreply.github.com>
T36 — Follow a box's logs and list exited tasks
slice: S2
kind: task
covers: BCLI-012, BCLI-015
size: M
est: 160 code, 120 tests
executor: agent
difficulty: routine
model: standard
diagnostics:
min task listshows an exited task with its exit code, as "exited (3)", untilmin box pruneremoves it, pinned by task_list_shows_exited_until_prunedobservability: the command's existing tracing span records the verb, the box id it resolved and the outcome
layers:
- client:
- crates/minimal/src/cli.rs: the verb's arguments and help in the one command model
- crates/minimal/src/cmd/mod.rs: dispatches the verb
- crates/minimal/src/cmd/boxes.rs: the logs verb for every box and its
-ffollow- crates/minimal/src/task.rs:
min task listkeeps exited tasks until a prune- crates/minimal/src/tests.rs: the in-process minimald test harness gains this layer's tests
test: cargo nextest run -p minimal type_noun_logs_follow
test: cargo nextest run -p minimal task_list_shows_exited_until_pruned
produces: none
consumes: none
proof: A person follows a box's output with
logs -f, and sees exited tasks inmin task listuntil a prune.depends on:
- blocked by #2892
Proof
A person runs
min session logs <box> -f,min task logs <box> -formin box logs <box> -f. Each command prints the box's output from its start, then each new output as the box writes it, and ends when the box is removed. Without-f, the command prints the output so far and ends.min task listshows each task box with its state. A task that exited shows asexited (3)untilmin box pruneremoves it.--alllists the tasks of every project.Notes from the agent: The binary cargo-nextest is not on this box, so the two test: lines ran as
cargo test -p minimal --lib <name>. The two commands use the same test filter. The verb did not exist before this change. All three nouns parse to oneBoxLogsArgsand one handler,box_logs_on_hostsin cmd/boxes.rs. That handler calls the daemon's ReadLog stream through the publicClient::stream_box_subsystem, so this change did not touch minimal-client.min task listdid not exist before this change either, and the task's dependency #2892 is not in the tree. This change adds it in task.rs, with--alland a scope to the current project asmin box listhas. It shows the columns ID, NAME, STATE and HOST. The plan pinsexited (3)as the task state.min box listprints the same box asexited (exit 3), so the two lists name the same state in two different ways. A reviewer can make one of them the same as the other. In the test, the task box is a stopped session box whose record.json the test changes to type task, status exited, exit code 3. The in-process harness has no direct way to create an exited task box. Two new messages: when the selected host does not answer,min task listprintsCould not reach host <host>, so no task is listed. Runmin doctorto check the daemon.When a log read ends early, the error tells the person to runmin box logs <box>, also when the person typedmin task logsormin session logs. Observability: the tracing info record has the verb, the resolved box id…[truncated]Tests
cargo nextest run -p minimal type_noun_logs_followcargo nextest run -p minimal task_list_shows_exited_until_prunedVerify
min task run agent-verifyexited 101 under rustc 1.99.0, which the repository does not pin (1.99.1 in rust-toolchain.toml); the PR is not a draft on that alone — CI, which honours the pin, is the gate.Closes #2897