← Back to Pull requests

fix(interp): report write errors on builtin stdout instead of exiting 0 #708

Open
unknown opened this pull request with 248 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 31, 2026 21:47 UTC
Author

What

CallContext.Out/Outf drop the error from the underlying write, and the dispatcher only looked at the builtin's own return code. So echo, printf, sed, awk, sort, grep, cut, wc, ls, find, strings and sha256sum exited 0 on ENOSPC/EIO/EFBIG and left a truncated redirect target.

The dispatcher now wraps the builtin's stdout in a builtins.WriteGuard, which remembers the first write error and fails every later write with it:

  • Builtins that check their writes stop early.

  • When the builtin otherwise succeeded, the dispatcher prints one <cmd>: write error: <reason> line and sets the status to 1, as bash does (e.g. echo: write error: no space left on device; lowercase like rshell's other messages and tr's existing write error).

  • Builtins that already failed and said why (cat, head, uniq) aren't reported twice.

  • A broken pipe stays silent, as bash builtins die quietly from SIGPIPE.

  • The find -exec / xargs child dispatch gets the same treatment.
  • Credit

    Found by Jacob Hayes with his deterministic-simulation tool patina (finding #1: SILENT oracle, random EIO leg, about 25k runs; reproduces natively with RLIMIT_FSIZE). Findings thread: https://dd.slack.com/archives/D0AC8RLB21J/p1793475631273749

    Tests

    interp/builtin_write_error_test.go gives the runner a stdout that fails with ENOSPC:

  • TestBuiltinWriteErrorReported: echo, printf, sed, sort, grep, wc, cut, cat, head and uniq each exit 1 with exactly one stderr line.

  • TestBuiltinWriteErrorFormat: the exact echo message.

  • TestBuiltinWriteErrorBrokenPipeSilent: EPIPE prints nothing.
  • The first two fail on main for the Out-based builtins. go test ./... passes except TestPSPentestLargePIDListDoesNotHang in builtins/ps, which fails the same way on clean main on this host (it has real processes with the PIDs the test assumes are missing).

    🤖 Generated with Claude Code

    Diff: 248 lines (+186 / -62) across 3 files Reviewer: louis-cqrl Review duration: 43319m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.39) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.39 · 248 lines diff across 3 files
    0.39
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.330
    Real PR Conversation Timeline
    1 comments
    "Review active on #708"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 38.9% (MEDIUM) · Higher = larger blast radius
    38.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.8% · Safe to merge
    20.8%
    Repository