Skip to content

fix(task): bound buffered command output - #11922

Merged
jdx merged 1 commit into
jdx:mainfrom
Marukome0743:pr11922
Aug 13, 2026
Merged

jdx merged 1 commit into
jdx:mainfrom
Marukome0743:pr11922

Conversation

@Marukome0743

@Marukome0743 Marukome0743 commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • stop retaining all stdout and stderr for every non-raw command execution
  • retain only the last 64 KiB of hidden stdout for progress-mode failure diagnostics
  • preserve live output, redaction, artifact-cache capture, keep-order buffering, and process cleanup behavior

Root cause

CmdLineRunner appended every redacted stdout and stderr line to combined_output in both its synchronous and asynchronous execution paths. Most output modes never consumed that vector, including the default parallel prefix mode, so long-running services accumulated output for their entire lifetime. In a local reproduction with a continuously writing task and a second parallel task, mise RSS grew from about 374 MiB after one second to about 1.97 GiB after six seconds.

The runner now creates a failure-output buffer only when stdout is hidden behind a progress reporter and therefore needs to be replayed on failure. That buffer keeps a UTF-8-safe 64 KiB tail and emits a truncation notice when older output is discarded.

Verification

  • mise exec -- cargo test --all-features cmd::tests (21 passed)
  • mise run test:e2e e2e/tasks/test_task_output_buffering
  • mise run test:e2e e2e/tasks/test_task_parallel_replacing e2e/tasks/test_task_output_style_decoupling e2e/tasks/test_task_raw_output e2e/tasks/test_task_artifact_cache_output e2e/tasks/test_task_parallel_fail_fast
  • mise exec -- cargo check --all-features
  • mise exec -- cargo clippy --workspace --all-features --all-targets -- -D warnings
  • mise exec -- cargo fmt --all -- --check
  • mise exec -- shellcheck e2e/tasks/test_task_output_buffering
  • mise exec -- shfmt -d e2e/tasks/test_task_output_buffering

mise run lint could not run because its hk task requires a .git directory, while this checkout is managed by Sapling without one; the underlying Rust, shell, and format checks above passed directly.

Addresses #8786

AI-assisted — Tool: Codex; model: OpenAI/GPT-5; version: unavailable.

Summary by CodeRabbit

  • Bug Fixes

    • Improved failed-command output handling by retaining the most recent output when earlier content exceeds the buffer limit.
    • Added a truncation notice when older output is discarded.
    • Preserved safe handling of Unicode text and parallel task output streams.
  • Tests

    • Added regression coverage for buffered output, truncation behavior, and failed-command reporting.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: ac5b6dae-e5a1-4ada-9498-9ad57579f1f1

📥 Commits

Reviewing files that changed from the base of the PR and between 5cc4893 and f71c29a.

📒 Files selected for processing (2)
  • e2e/tasks/test_task_output_buffering
  • src/cmd.rs

📝 Walkthrough

Walkthrough

Changes

Failure output buffering

Layer / File(s) Summary
Bounded failure-output collector
src/cmd.rs
FailureOutputTail retains the final 64 KiB of stdout, truncates UTF-8 safely, reports truncation, and activates only for progress-hidden output without a stdout callback. Unit tests cover these rules.
Synchronous command handling
src/cmd.rs
Synchronous execution streams stdout and stderr directly and replays only the retained stdout tail when a command fails.
Asynchronous command handling and regression coverage
src/cmd.rs, e2e/tasks/test_task_output_buffering
Asynchronous execution applies the same bounded retention during output and pipe draining. End-to-end coverage verifies parallel streaming and truncated failure output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CmdLineRunner
  participant ChildCommand
  participant ProgressReport
  participant ErrorHandler
  CmdLineRunner->>ChildCommand: Execute command
  ChildCommand->>ProgressReport: Stream stdout
  ChildCommand->>CmdLineRunner: Stream stderr
  CmdLineRunner->>CmdLineRunner: Retain bounded stdout tail
  ChildCommand-->>CmdLineRunner: Return failure
  CmdLineRunner->>ErrorHandler: Replay retained tail and truncation notice
Loading

Possibly related PRs

Suggested reviewers: jdx, jambalaya56562, risu729

Poem

I’m a rabbit guarding the tail,
Sixty-four KiB in my leafy pail.
Streams run freely, lines stay bright,
Failed commands replay the final sight.
UTF-8 hops safely through the night.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: limiting buffered command output for task failures.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Marukome0743
Marukome0743 marked this pull request as ready for review August 13, 2026 17:35
@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR bounds hidden command-output retention while preserving live stream handling and failure diagnostics.

  • Adds a UTF-8-safe 64 KiB tail buffer for stdout hidden behind progress reporting.
  • Stops accumulating unused stdout and stderr in synchronous and asynchronous command execution.
  • Adds unit and end-to-end coverage for bounded retention, truncation notices, Unicode, and parallel output.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code defect identified.

The new buffer is enabled only for stdout hidden by progress reporting, bounds retained payload, truncates oversized UTF-8 lines safely, and leaves stderr visible through its existing live progress-report path.

Important Files Changed

Filename Overview
src/cmd.rs Replaces unbounded combined-output accumulation with a bounded hidden-stdout tail while retaining existing stream and error-routing behavior.
e2e/tasks/test_task_output_buffering Adds regression coverage for streamed parallel output and truncated failure diagnostics in replacing mode.

Reviews (1): Last reviewed commit: "fix(task): bound buffered command output" | Re-trigger Greptile

@jdx
jdx merged commit 5bb3513 into jdx:main Aug 13, 2026
30 checks passed
@Marukome0743
Marukome0743 deleted the pr11922 branch August 13, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants