Repository navigation
Keep a running shell's output across a daemon stop or kill - #1549
Merged
Merged
Conversation
A shell with an outputs folder that runs past its first second writes its streams to their files as it runs, at most a second behind and without a sync, as Pi keeps a running call's output; one that ends sooner never touches the disk, and a file that ends within a preview is removed. A clean stop ends running commands with their output as daemon_shutdown, and a background command a killed daemon lost answers at the next start with what its files kept. Within 1 MiB the kept bytes are handed to the writer once a second without a copy per read or a wait on the disk; writes are one writev per batch on blocking workers, with no buffer kept per file. bench.shell_streams measures it against main; results in docs/DAEMON_MEASUREMENTS.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013jkdGFB8684xSdg7nKsRqk
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dc13bbaa3f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…-rgzll6 # Conflicts: # docs/DAEMON_MEASUREMENTS.md # src/store.rs
A turn parked on a background command a killed daemon lost was restored, and its result read, before the start put the command's kept output in that result: the recovery now runs first. A lost command's file opens without waiting, so a pipe put in its place is rejected rather than holding the start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013jkdGFB8684xSdg7nKsRqk
This was referenced Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by George · project thread
Dec 2 feedback, item 23, built like Pi: a running shell's output survives a daemon stop or kill. Pi commits a running call's output within a second and, after a restart, answers the call with the output so far. Until now the daemon kept a command's output in memory until it passed 1 MiB, a clean stop dropped running background commands, and the next start marked them
process_lostwith no output.What changes
{outputs}/{turn}-{call}-{stream}), what it read before then first. After that it writes at most once a second, or per 256 KiB, without a sync. Theusableguard (the folder must not be writable by the bot's commands) is unchanged. A command that ends within its first second never touches the disk. A time-streamed file that ends within a 64 KiB preview is removed, so that answer is exactly main's. A larger one is kept and synced as a spilled file is, and the model is shown the same text main shows ("the full output is retained").stdout,stderrand"error":"daemon_shutdown", with the existingstopped_by_shutdowndetail. The stop waits up to 5 s for those ends to be recorded. A command the stop came before never starts. At start, only rows stillrunningbecomelost, as before.files/artifacts, as a finished command's are. No schema change and no migration.New model-facing text (needs George's per-diff OK)
Only one new string. It goes in the omitted-bytes marker of a lost command's stdout or stderr when its file holds more than a preview:
New result fields:
stdout/stderr, plusfiles/artifactswhen its files hold more than a preview. Before, it was just{"error":"process_lost"}.{"stdout","stderr","exit_code":null,"success":false,"error":"daemon_shutdown","detail":"the daemon stopped this command before it finished, so it may have had effects; nothing has run it again","wall_time_ms"}. The detail is the existing string.docs/RUST_PROTOTYPE.mdsaid a clean stop recordsprocess_lost. It now describes the new behavior.How the daemon stays fast and light
try_reserve, so a slow disk never makes a pipe wait. Past 1 MiB, the reader waits for the writer exactly as on main.writevper batch, with no buffer kept per file. The open goes with the first write and the last write goes with the close, so a 3 s command costs about three trips to a worker. On a slow disk, a batch takes everything already waiting.Bench (
bench.shell_streams, new; full tables in docs/DAEMON_MEASUREMENTS.md)These are medians of 3 alternated runs on a 4-CPU container, main 2f67e9b against this change, both built the same way.
These costs come from writing the output to disk, which is the durability this change adds. The rest is even or better.
Tests
tests/test_wait.py):cargo clippy -D warnings,cargo fmt, and the full lib suite (328) pass.Follow-up, not in this PR: an in-turn foreground call cut off by a stop or crash keeps today's answer.
Requested by George
Generated by Claude Code