Add tee builtin #623
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 442 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
Diff Size
diff_size
0.365
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #623"
general
weight: 0.35
san-jos
Summary
Adds
teeas a remediation-only builtin, alongsidetruncate/logrotate/rm/systemctl, since it mutates file content.Supported flags:
-a/--append,-h/--help.-i/--ignore-interruptsand-p/--output-errorare intentionally out of scope (rshell builtins don't receive process signals, and every FIFO write target is already rejected by the sandbox) and are rejected as unknown flags.Design notes
FILEoperand in fixed 32 KiB chunks — no buffering proportional to input size.FILEwrite routes throughcallCtx.OpenFile, inheriting theAllowedPaths:rwsandbox gate, hard-link write-target rejection, and theRemediationOnlydispatch gate thattruncate/logrotatealready rely on.Sandbox.Truncate/Sandbox.TruncateToZeroIfAtLeast,Sandbox.Open(the primitive behindcallCtx.OpenFile) does not addO_NONBLOCKto a caller-supplied write flag. AnO_WRONLYopen of a readerless FIFO throughcallCtx.OpenFiletherefore blocks the shell indefinitely — I hit this early on withtee pipehanging.teeworks around it with a pre-openStatFilecheck (rejectNonRegularTarget), mirroring the interpreter's ownrejectNonRegularRedirectTargetused by>/>>. Documented inAGENTS.mdfor future write-capable builtins, sinceteeis the first builtin to callcallCtx.OpenFilewith a write flag directly.-as aFILEoperand writes to standard output again (matching GNUtee), not a literal file named-.FILE, matching GNUtee's continue-on-failure semantics.Testing
builtins/tests/tee: unit/integration tests covering append/overwrite, multi-file,-/passthrough, remediation-mode gating, sandbox containment, hard-link rejection, FIFO rejection.interp/builtin_tee_pentest__test.go: pentest suite — remediation-mode gating (including the "no FILE operands" edge case), sandbox escape (path traversal, symlink, absolute path), hard-link and FIFO write-target rejection with and without an attached reader (mirroring the existingtruncateFIFO pentest's determinism check), resource limits (200 file operands, duplicate operand, streamed large input, broken downstream pipe), flag/argument injection.builtins/tests/tee/tee_fuzz_test.go:FuzzTeeStdinContent,FuzzTeeFlags.tests/scenarios/cmd/tee/: YAML scenarios, compared against real bash/GNUteevia the existing Docker-based harness where behavior is expected to match;skip_assert_against_bashonly on the two flags we intentionally reject that GNUteeaccepts (-i,-p).go build ./...,gofmt -l .,go vet ./...,go test ./...) is green, including theanalysis/symbol-allowlist and structural (OpenFile-must-close) checks.Note:
RSHELL_BASH_TEST=1 go test ./tests/... -run TestShellScenariosAgainstBashfails locally on this machine with a pre-existing Docker-Desktop-on-macOS bind-mount issue (bash: /work/runner.sh: No such file or directory) — reproduces identically on unmodifiedmain, unrelated to this change.Docs
SHELL_FEATURES.md: newteeentry,RemediationModebuiltin list updated.AGENTS.md: new note on theO_NONBLOCKwrite-open gap this surfaced..github/workflows/fuzz.yml: new matrix entry forbuiltins/tests/tee.