Skip to content
Closed
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,11 @@ runs:
if [[ -n "${MINT_URL}" ]]; then
MINT_FLAGS+=(--mint-url "${MINT_URL}")
fi
fullsend run "${AGENT}" \
# exec replaces the shell so signals (SIGINT/SIGTERM from GHA

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] scope-creep

The PR title/body frame this change as cost estimation ('estimate USD cost on cancelled runs via historical rate cache'), but this revision also (1) replaces fullsend run with exec fullsend run so GHA signals reach the process directly, affecting every agent invocation through this action, not just cancelled Review runs, and (2) changes ExecStreamReader's default cancellation signal from SIGKILL to SIGINT + a 5s WaitDelay for all sandboxed CLI invocations (Claude, pi, Codex). GoReleaser builds release notes from PR titles (COMMITS.md), so a signal-handling behavior change hidden inside a cost-estimation title won't surface there, and the risk/moderate label similarly understates the process-lifecycle blast radius since ExecStreamReader is shared across all sandbox executions.

Suggested fix: Update the PR title/body to explicitly claim both scopes (cost estimation and graceful cancellation / signal delivery) so release notes and reviewers aren't misled, and re-evaluate the risk label given the shared blast radius. Splitting into two PRs is optional; retitling to reflect the actual scope is the minimum.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] scope-authorization-partial

Issue #6936's acceptance criteria explicitly ask to "verify the signal/cancellation lifecycle across the Review workflow, the fullsend action, ClaudeRuntime.Run, and the run finalization/telemetry writer" — this authorizes the substance of the changes to action.yml (exec fullsend run, cited inline as referencing #6936), internal/sandbox/sandbox.go (the SIGINT-relay rewrite), and internal/runtime/claude.go (exec claude). This resolves the prior medium-severity "unauthorized scope" concern for the code itself. What remains is a release-note/PR-metadata accuracy gap: the PR title ("feat(#6936): estimate USD cost on cancelled runs via historical rate cache") and the PR body's own "Files changed" list omit any mention of the signal/cancellation-lifecycle rewrite, even though that rewrite grew more extensive since the prior review (a full SIGINT-relay architecture, not just a signal-choice tweak). GoReleaser builds release notes from PR titles per this repo's COMMITS.md, so this process-signal-handling change would not surface there. (Downgraded from the prior medium-severity scope-creep finding now that the issue's authorization is established; the residual concern is narrower.)

Suggested fix: Update the PR title/body to explicitly claim both the cost-estimation and signal/cancellation-lifecycle scopes, and update the body's "Files changed" list to include action.yml, internal/runtime/claude.go, and internal/sandbox/sandbox.go.

# cancellation) go directly to fullsend, preventing it from being
# orphaned and killed before its cleanup path can flush telemetry
# and metrics (#6936).
exec fullsend run "${AGENT}" \
--fullsend-dir "${FULLSEND_DIR}" \
--output-dir "${GITHUB_WORKSPACE}/output" \
--target-repo "${TARGET_REPO}" \
Expand Down
10 changes: 5 additions & 5 deletions internal/cli/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3711,11 +3711,11 @@ func transcriptErrorMessage(te agentruntime.TranscriptError) string {
// artifact upload step (if: always()) captures the partial usage data
// (#6936).
//
// NOTE: TotalCostUSD will be zero in the persisted metrics because dollar
// cost is only available from the terminal ResultEvent, which a cancelled
// run never emits. Token counts (input, output, cache_read, cache_creation)
// are captured via the deferred TokensEvent and will be non-zero. See #6936
// for background.
// NOTE: TotalCostUSD is now reported by the SIGINT-into-sandbox
// mechanism (#6936): on cancellation, SIGINT is sent to the in-sandbox
// claude process, which flushes its ResultEvent (with cost data) before
// exiting. If the SIGINT delivery fails, TotalCostUSD falls back to
// zero — token counts are still captured via the deferred TokensEvent.
//
// cancelled is false when ctx is still live, in which case the caller's
// normal control flow continues unchanged; the other return values are
Expand Down
9 changes: 7 additions & 2 deletions internal/runtime/claude.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ func (ClaudeRuntime) Run(ctx context.Context, params RunParams, printer *ui.Prin
innerHandler(evt)
}

if parseErr := parseClaudeStream(r, handler); parseErr != nil {
parseErr := parseClaudeStream(r, handler)
fmt.Fprintf(os.Stderr, " stream ended: parseErr=%v ctxErr=%v cost=%.4f\n", parseErr, ctx.Err(), metrics.TotalCostUSD)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] leftover-debug-code

Two new unconditional fmt.Fprintf(os.Stderr, ...) debug lines (" stream ended: parseErr=%v ctxErr=%v cost=%.4f" at line 181 and " wait done: exitCode=%d waitErr=%v" at line 193) execute on every agent run, including normal successful runs, writing unstructured trace messages to stderr. These read as developer debug output left over from the signal-lifecycle debugging work rather than intentional, permanent diagnostics, and they are not mentioned in the PR's stated design decisions.

Suggested fix: Remove the leftover fmt.Fprintf(os.Stderr, ...) statements at lines 181 and 193, or gate them behind an explicit debug/verbose flag if they are meant to persist.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] logging-conventions

fmt.Fprintf(os.Stderr, " stream ended: parseErr=%v ctxErr=%v cost=%.4f\n", ...) (line 181) and fmt.Fprintf(os.Stderr, " wait done: exitCode=%d waitErr=%v\n", ...) (line 193) execute unconditionally on every ClaudeRuntime.Run, including normal successful runs, adding stderr noise beyond the existing error-only " progress parser: %v\n" pattern. parseErr is also printed with a raw %v here (unsanitized) before being sanitized again on the error-handling path a few lines later.

Suggested fix: Remove the unconditional diagnostic prints, or gate them behind an explicit debug/verbose flag if they are meant to persist as permanent diagnostics.

if parseErr != nil {
fmt.Fprintf(os.Stderr, " progress parser: %v\n", sanitizeOutput(parseErr.Error()))
cancel()
io.Copy(io.Discard, r)
Expand All @@ -188,6 +190,7 @@ func (ClaudeRuntime) Run(ctx context.Context, params RunParams, printer *ui.Prin
if execCmd.ProcessState != nil {
exitCode = execCmd.ProcessState.ExitCode()
}
fmt.Fprintf(os.Stderr, " wait done: exitCode=%d waitErr=%v\n", exitCode, waitErr)

if waitErr != nil && execCmd.ProcessState == nil {
return exitCode, fmt.Errorf("openshell exec failed: %w", waitErr)
Expand Down Expand Up @@ -349,8 +352,10 @@ func buildRunCommand(params RunParams) string {
envFile := sandbox.SandboxWorkspace + "/.env"
safe := strings.ReplaceAll(params.AgentBaseName, "'", "'\\''")

// exec replaces the shell so ExecStreamReader's PID file points to
// claude, not sh — required for the SIGINT-into-sandbox cancel mechanism.
parts := []string{
fmt.Sprintf("cd %s && . %s && claude", params.RepoDir, envFile),
fmt.Sprintf("cd %s && . %s && exec claude", params.RepoDir, envFile),
Comment on lines +355 to +358

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

3. Signal routing can regress untested 📘 Rule violation ▣ Testability

buildRunCommand now relies on exec claude for correct signal delivery, but no modified Claude
runtime test asserts that the generated command includes the shell replacement. If a later command
refactor removes exec, existing tests still pass while the PID file targets the intermediate shell
instead of the process that must flush final telemetry.
Agent Prompt
## Issue description
The new signal-delivery mechanism depends on `buildRunCommand` producing `exec claude`, but the corresponding runtime tests do not assert this behavior.

## Fix Focus Areas
- internal/runtime/claude_test.go[217-223]

## Recommended Fix
Update `TestBuildRunCommand_Basic` to assert that the generated command contains `exec claude`, ensuring removal of the required shell replacement causes a test failure.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +355 to +358

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

4. Runtime change skips guide review 📘 Rule violation ⛨ Security

ClaudeRuntime.Run and buildRunCommand change an existing runtime backend's execution behavior,
but the PR description does not state that docs/contributing/runtime-implementation.md was
consulted. Because direct process execution participates in the documented egress-binary contract,
reviewers cannot verify from the change record that the runtime checklist was evaluated.
Agent Prompt
## Issue description
The Claude runtime backend now directly replaces its shell process, but the PR does not record consultation of the runtime implementation guide as required for backend behavior changes.

## Fix Focus Areas
- internal/runtime/claude.go[355-358]

## Recommended Fix
Update the PR description to explicitly state that `docs/contributing/runtime-implementation.md` was consulted and that the existing Claude egress-binary mapping, wire protocol, and workspace layout remain unchanged.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

"--print",
"--verbose",
"--output-format stream-json",
Expand Down
68 changes: 64 additions & 4 deletions internal/sandbox/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -1360,24 +1360,84 @@ func ExecContext(ctx context.Context, sandboxName, command string, timeout time.
return stdoutBuf.String(), stderrBuf.String(), exitCode, nil
}

// execPIDFile is the path inside the sandbox where the exec'd process PID
// is recorded so the cancel function can send SIGINT to it.
const execPIDFile = "/tmp/.fullsend_exec.pid"

// ExecStreamReader runs a command inside a sandbox, returning an io.ReadCloser for
// stdout so the caller can parse structured output. Stderr is forwarded to the
// given writer. The caller must read stdout to completion, then call cmd.Wait().
//
// The parent context is used as the base for the timeout context, so
// cancelling the parent (e.g. on SIGTERM) terminates the subprocess. This
// allows CLI-level signal handling to propagate into long-running sandbox
// commands.
// cancelling the parent (e.g. on SIGTERM) terminates the subprocess. On
// context cancellation, a separate openshell exec call sends SIGINT to the
// in-sandbox process (identified by a PID file written at startup). This is
// necessary because SIGINT to the openshell CLI does not propagate through
// gRPC to in-sandbox processes. The openshell relay process is left running
// so it continues piping stdout (e.g. Claude Code's terminal result event
// with cost data). An 8-second WaitDelay allows the graceful shutdown to
// complete; after that Go kills the openshell process.
//
// stderrW must be safe for concurrent use: the cancel goroutine and the
// openshell subprocess both write to it simultaneously.
//
// The PID file path is a fixed singleton inside the sandbox. This function
// must not be called concurrently for the same sandbox.
func ExecStreamReader(ctx context.Context, sandboxName, command string, timeout time.Duration, stderrW io.Writer) (io.ReadCloser, *exec.Cmd, context.CancelFunc, error) {
ctx, cancel := context.WithTimeout(ctx, timeout)
timeoutSecs := fmt.Sprintf("%d", int(timeout.Seconds()))

// Prepend a PID-file write so the cancel function can target the
// in-sandbox process. Callers that use "exec" in their command (e.g.
// buildRunCommand) replace the shell, so the PID file points to the
// final process.
wrapped := fmt.Sprintf("echo $$ > %s; %s", execPIDFile, command)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Three agents miss cancellation signals 🔗 Cross-repo conflict ☼ Reliability

ExecStreamReader records the wrapper shell's $$ and later sends SIGINT only to that PID, but
buildPiRunCommand launches Pi as a child without exec and the Codex builder uses a pipeline
rather than replacing the shell as Claude does. Cancellation of Codex or the agents repository's
Pi-based code, prioritize, and review agents can therefore leave the real agent running without
flushing terminal output until the relay fallback timeout, WaitDelay, or sandbox teardown.
Agent Prompt
## Issue description
`ExecStreamReader` assumes the PID written from `$$` becomes the agent PID, but that is only true when the supplied command replaces the wrapper shell. Codex uses a pipeline and Pi launches without `exec`, so cancellation targets `sh` rather than the actual agent process.

## Fix Focus Areas
- internal/sandbox/sandbox.go[1390-1440]
- internal/runtime/codex_run.go[365-370]
- internal/runtime/pi_run.go[497-505]
- internal/sandbox/sandbox_test.go[306-363]

## Recommended Fix
Change the launch protocol so the PID file reliably identifies the actual agent process or its dedicated process group for every `ExecStreamReader` caller. Launch Pi with `exec` after completing its setup and guard commands, update Codex command construction as needed, and add cancellation tests covering all three runtime command shapes to verify that each agent receives SIGINT, exits gracefully, and flushes its final output rather than relying on `WaitDelay`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


cmd := exec.CommandContext(ctx, "openshell", "sandbox", "exec",
"--name", sandboxName,
"--no-tty",
"--timeout", timeoutSecs,
"--", "sh", "-c", command,
"--", "sh", "-c", wrapped,
)
// Put openshell in its own session so process-group-wide signals
// (SIGINT from GHA cancellation) don't kill it before cmd.Cancel
// has a chance to send SIGINT into the sandbox and relay the
// result event through stdout.
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] permission-expansion

Setsid: true moves the openshell relay process into a new session, and cmd.Cancel returns nil without ever signaling that process directly — the 8s WaitDelay is the only host-side mechanism that can still kill it. This detaches openshell from the GHA step's process group, so a group-wide SIGINT/SIGTERM/SIGKILL no longer reaches it directly the way it did before this PR. There is no Pdeathsig; if the parent fullsend process is SIGKILLed before WaitDelay fires, the relay is reparented to init and can keep running. An 8s WaitDelay also sits at or past GitHub Actions' own ~7.5s SIGINT-to-SIGKILL grace window, so the intended force-kill of the relay may never run on a cancelled GHA job.

Suggested fix: If Setsid is required to protect the relay from a premature group-wide SIGINT before the in-sandbox result event is flushed, also set SysProcAttr.Pdeathsig = syscall.SIGKILL (Linux) so a killed parent cannot leave the relay orphaned. Shrink WaitDelay (or the internal kill-exec timeout) so cleanup still fits inside GitHub Actions' cancellation budget.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] permission-expansion

Setsid: true moves the openshell relay into a new session, and cmd.Cancel returns nil without ever signaling that host process directly — the only host-side kill is cmd.WaitDelay = 8s, with no Pdeathsig. If the parent fullsend process is SIGKILLed before WaitDelay fires, the relay can be reparented to init and keep running. An 8s WaitDelay also sits at or past GitHub Actions' own ~7.5s SIGINT-to-SIGKILL step window, so the intended force-kill of the relay may never run on a cancelled GHA job. Blast radius is limited to an already-sandboxed relay process (bounded by the existing --timeout, and torn down with the GHA VM), so this is a lifecycle-hardening gap rather than a genuine privilege expansion.

Suggested fix: If Setsid is required, also set SysProcAttr.Pdeathsig = syscall.SIGKILL (Linux) so a killed parent cannot leave the relay orphaned. Shrink WaitDelay (or the internal 5s kill-exec timeout) so cleanup still fits inside GitHub Actions' cancellation budget.

cmd.Cancel = func() error {
fmt.Fprintf(stderrW, " sandbox cancel: sending SIGINT into %s\n", sandboxName)
// Send SIGINT to the in-sandbox process so it can flush final
// output (e.g. Claude Code's result event with total_cost_usd).
// A background context is required because the parent is already
// cancelled. The goroutine runs concurrently so Cancel returns
// immediately and WaitDelay starts without blocking.
killCtx, killCancel := context.WithTimeout(context.Background(), 5*time.Second)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] leftover-debug-code

The killScript constructed in ExecStreamReader's Cancel function contains debug echo statements (echo "sandbox-cancel: pid=$PID" >&2 and echo "sandbox-cancel: kill=$?" >&2) that look like leftover troubleshooting output from developing the in-sandbox signal-handling mechanism. See also: [fail-open] finding on this file — the raw $PID echoed here is the same value flagged there for lacking validation.

Suggested fix: Remove the debug echo commands from killScript, or route their content through existing output sanitization if they are meant to persist as operator-facing diagnostics.

go func() {
defer killCancel()
killScript := fmt.Sprintf(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] fail-open

ExecStreamReader's cancel path treats the in-sandbox PID file (/tmp/.fullsend_exec.pid) as the sole SIGINT target and is fail-open when that file is absent, empty, or malformed: PID=$(cat ... 2>/dev/null); kill -INT $PID with $PID unquoted. An empty/missing PID makes kill -INT run with no operand, so SIGINT is silently never delivered (WaitDelay is the fallback). Unquoted expansion could pass multiple operands, or a value like -1, if the well-known path were ever overwritten with malformed content. The blast radius is confined to the sandbox (the kill runs via a second openshell sandbox exec call), not the GHA host, and the missing-PID case already degrades to the existing WaitDelay fallback rather than granting broader access.

Suggested fix: Validate that the PID file's content is a bare positive integer before using it (e.g. case "$PID" in ''|*[!0-9]*) exit 1;; esac) and quote kill -INT "$PID".

"PID=$(cat %s 2>/dev/null); "+
"if [ -z \"$PID\" ]; then echo \"sandbox-cancel: pid-file missing or empty\" >&2; exit 1; fi; "+
"echo \"sandbox-cancel: pid=$PID\" >&2; "+
"kill -INT $PID 2>&1; echo \"sandbox-cancel: kill=$?\" >&2",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] runtime-mechanism

ExecStreamReader records echo $$ > /tmp/.fullsend_exec.pid and on cancel sends SIGINT only to that PID (kill -INT $PID). Claude's exec claude replaces the wrapping shell, so $$ is the runtime and SIGINT is delivered correctly. Codex still ends in a pipeline (printf ... | "$codex" exec in internal/runtime/codex_run.go) — a shell cannot last-exec a pipeline, so $$ is the wrapper shell and kill -INT $PID never reaches the Codex process. Pi launches "$FULLSEND_PI_BIN" --print without exec (internal/runtime/pi_run.go); it may happen to inherit $$ via shell last-command-exec, but that is implicit and untested. Both non-Claude callers also now pay the new 8s WaitDelay on every cancel/timeout before the openshell relay is SIGKILLed. TestExecStreamReader_SendsSIGINTOnCancel only covers a cooperative same-PID child, so this gap is untested. This mechanism is squarely this PR's stated purpose, and as implemented it verifiably works for Claude but not for two of the three supported runtimes.

Suggested fix: Either exec the payload in every ExecStreamReader caller (so $$ is always the runtime process, matching the Claude pattern) or deliver SIGINT to the recorded PID's process group (kill -INT -- -$PID) so wrapper-shell children receive it. Extend the cancellation test to a wrapping shell with a non-exec'd child and a pipeline child.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] fail-open

ExecStreamReader's cancel script still treats the in-sandbox PID file as the sole SIGINT target. The new [ -z "$PID" ] check (added since the prior review) closes the absent/empty-file case, but the script still doesn't validate the content is a bare positive integer, and kill -INT $PID remains unquoted — a malformed PID file could still pass multiple IFS-split operands or a negative value. Blast radius stays inside the sandbox, and a bad PID still degrades to the WaitDelay fallback rather than granting host access, so this is a partial fix of the prior finding rather than a new issue.

Suggested fix: Reject non-numeric PID file contents (e.g. case "$PID" in ''|[!0-9]) exit 1;; esac) before signaling, and use kill -INT -- "$PID".

execPIDFile)
killCmd := exec.CommandContext(killCtx, "openshell", "sandbox", "exec", //nolint:gosec // sandboxName is not user input
"--name", sandboxName,
"--no-tty",
"--timeout", "5",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] runtime-mechanism

ExecStreamReader records echo $$ > /tmp/.fullsend_exec.pid and on cancel sends SIGINT to only that PID. buildRunCommand's exec claude makes $$ the Claude process, so Claude receives SIGINT correctly. But pi launches "$pi" --print ... as a child of the wrapping shell (no exec), and Codex's last step is a pipeline printf | "$codex" exec, so in both cases $$ is the wrapping shell, not the runtime process. SIGINT is delivered to the shell, which the runtime child never sees — pi and Codex runs get no graceful-cancellation opportunity and rely entirely on the 8s WaitDelay force-kill, defeating this PR's own stated purpose (flushing the terminal cost-bearing result event) for two of the three supported runtimes. TestExecStreamReader_SendsSIGINTOnCancel only covers a cooperative same-PID child, so this gap is untested.

Suggested fix: Either exec the payload in every ExecStreamReader caller (so $$ is always the runtime process, matching the Claude pattern), or deliver SIGINT to the recorded PID's process group instead of the single PID. Extend the cancellation test to a wrapping shell with a non-exec'd child.

"--", "sh", "-c", killScript,
)
killCmd.Stdout = stderrW
killCmd.Stderr = stderrW
if err := killCmd.Run(); err != nil {
fmt.Fprintf(stderrW, " sandbox cancel: kill-exec failed: %v\n", err)
}
}()
// Do NOT signal the openshell relay process here. Openshell must
// stay alive to pipe claude's result event (with cost data) back
// through stdout. WaitDelay is the fallback if claude doesn't exit.
return nil
}
cmd.WaitDelay = 8 * time.Second
cmd.Stderr = stderrW

stdout, err := cmd.StdoutPipe()
Expand Down
58 changes: 58 additions & 0 deletions internal/sandbox/sandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,64 @@ func TestExecStreamReader_OpenshellNotInPath(t *testing.T) {
assert.Error(t, err)
}

func TestExecStreamReader_SendsSIGINTOnCancel(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skip("SIGINT not supported on Windows")
}

bin := t.TempDir()
script := filepath.Join(bin, "openshell")
// Fake openshell: pass-through that runs whatever comes after "--".
// This lets the cancel function's separate "openshell sandbox exec"
// call also go through the fake and execute the kill command.
require.NoError(t, os.WriteFile(script, []byte(`#!/bin/sh
while [ $# -gt 0 ]; do
if [ "$1" = "--" ]; then
shift
exec "$@"
fi
shift
done
echo "no -- found" >&2; exit 1
`), 0o755))
t.Setenv("PATH", bin+":/bin:/usr/bin")
defer os.Remove(execPIDFile)

ctx, cancel := context.WithCancel(context.Background())
// The command traps SIGINT and flushes output, simulating Claude Code's
// graceful shutdown that emits the result event with cost data.
testCmd := "trap 'echo flushed-after-sigint; exit 0' INT; echo ready; while true; do :; done"
stdout, cmd, cleanup, err := ExecStreamReader(ctx, "test-sandbox", testCmd, 30*time.Second, os.Stderr)
require.NoError(t, err)
defer cleanup()

buf := make([]byte, 256)
n, err := stdout.Read(buf)
require.NoError(t, err)
assert.Contains(t, string(buf[:n]), "ready")

cancel()

var all []byte
for {
n, err = stdout.Read(buf)
if n > 0 {
all = append(all, buf[:n]...)
}
if err != nil {
break
}
}
assert.Contains(t, string(all), "flushed-after-sigint",
"in-sandbox process should receive SIGINT via the kill-exec mechanism and flush output")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] test-idioms

In TestExecStreamReader_SendsSIGINTOnCancel, waitErr := cmd.Wait() assigns the error to a named variable that is immediately discarded via _ = waitErr — dead code / unnecessary indirection that also misses an opportunity to assert the wait outcome.

Suggested fix: Replace with _ = cmd.Wait() // wait for subprocess cleanup after cancellation, or assert the expected outcome.

waitErr := cmd.Wait()
_ = waitErr

assert.Equal(t, 8*time.Second, cmd.WaitDelay,
"WaitDelay should give the subprocess time to flush before force-kill")
}

func TestOsRootContainment(t *testing.T) {
dir := t.TempDir()

Expand Down
Loading