8000 fix: exit min proxy bridge when the daemon socket closes by gominimal-aw-bot[bot] · Pull Request #1282 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content

fix: exit min proxy bridge when the daemon socket closes - #1282

Merged
norrietaylor merged 2 commits into
mainfrom
inbox-patch/proxy-socket-exit-7a857ce5f83c5409
Aug 25, 2026
Merged

norrietaylor merged 2 commits into
mainfrom
inbox-patch/proxy-socket-exit-7a857ce5f83c5409

Conversation

@gominimal-aw-bot
@gominimal-aw-bot gominimal-aw-bot Bot commented Aug 25, 2026 •
Copy link
Copy Markdown
Contributor

Routing-Key: inbox-route/I_kwDOSUhdos8AAAABKmg4iA

min proxy bridges an ssh ProxyCommand's stdio to the daemon's Unix socket, joining both copy directions with try_join! — which returns only once both directions finish. When the socket is torn down, the socket→stdout copy hits EOF but the stdin→socket copy blocks forever on the ssh-held stdin, so the proxy never exits and lingers (together with its parent ssh process) against a dead socket, surviving daemon restarts. The bridge now uses select!: it exits as soon as the socket side closes, while still draining any trailing daemon output when stdin closes first. A regression test hangs on the old code and passes on the new.

Verification

cargo fmt --all --check — clean
cargo clippy --workspace --locked -- -D warnings — no warnings
cargo build --workspace --locked — ok
cargo test --workspace --locked — passed (exit 0), including the new proxy_exits_when_the_daemon_closes_the_socket test

Summary by CodeRabbit

  • Bug Fixes
    • Improved command proxy shutdown behavior when the daemon connection closes.
    • Prevented sessions from hanging when standard input remains open after the connection ends.
    • Added coverage for daemon-side connection closure scenarios.

min proxy bridges stdin/stdout to the daemon socket with
try_join!, which waits for both directions to finish. When min
stop tears the socket down, the socket->stdout copy sees EOF but
the stdin->socket copy blocks forever on the ssh-held stdin, so
the proxy never exits and the ssh driving it is orphaned.

Switch to select!: return as soon as the socket side closes,
while still draining trailing daemon output when stdin closes
first.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gominimal-aw-bot
gominimal-aw-bot Bot requested a review from a team as a code owner August 25, 2026 02:29
@gominimal-aw-bot gominimal-aw-bot Bot added the agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it. label Aug 25, 2026
@coderabbitai
coderabbitai Bot commented Aug 25, 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5447c0f8-572f-4860-a051-741efe24800c

📥 Commits

Reviewing files that changed from the base of the PR and between 0957ff8 and dd3db9f.

📒 Files selected for processing (1)
  • crates/minimal/src/lib.rs

Included review availability: 3 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

cmd_proxy now uses proxy_bridge for stdio forwarding. The bridge exits on daemon socket EOF and drains daemon output after stdin completion. A regression test covers socket closure while stdin remains open.

Changes

Proxy bridge lifecycle

Layer / File(s) Summary
Bridge lifecycle and regression coverage
crates/minimal/src/lib.rs
proxy_bridge uses select! to stop on daemon socket EOF or stdin completion. Stdin completion shuts down the socket write half and drains remaining output. The regression test verifies prompt, error-free exit when the daemon closes its Unix socket while stdin remains open.

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

Merge Risk: ⚪ Minimal · up to dd3db

The proxy now exits when the daemon socket closes while preserving trailing output handling; the change is localized and covered by passing checks and a regression test, so no actionable merge-blocking risk remains.

Suggested reviewers: norrietaylor

Poem

A rabbit watched the socket close,
While stdin stayed awake;
The bridge chose a prompt goodbye,
Then drained what streams could make.
Tests now guard the hopping flow,
And quiet SSH waits break.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise, follows the required Conventional Commit format, and clearly describes the socket-closure fix.
Description check ✅ Passed The description explains the bug, the implementation change, and the regression test. It also provides verification results. The required Checklist section is missing, but the description is otherwise…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files.
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.
Full details: Description check

Explanation

The description explains the bug, the implementation change, and the regression test. It also provides verification results. The required Checklist section is missing, but the description is otherwise complete.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch inbox-patch/proxy-socket-exit-7a857ce5f83c5409

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

@github-actions github-actions Bot left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minimal-review — advisory review

Verdict COMMENT — COMMENT: policy.actions.request_changes is off; policy.actions.approve is off.

Scope: single file, single commit (dd3db9f), matches the PR description exactly — replace try_join! with select! in cmd_proxy's stdio↔socket bridge, plus a regression test. The PR head is a merge of unrelated main commits (ci, mfile/graph/mctx, diagnostics) that don't touch this file, so nothing outside the stated intent is included.

Clobber: none. git log on the touched file shows this is the only recent change to it; the merge doesn't revert or overwrite prior work.

Correctness: the new proxy_bridge correctly fixes the described hang. from_sock is pinned so it can be raced in select! and then polled again afterward; when it completes first (daemon closed the socket) the function returns immediately instead of blocking on ssh-held stdin — that's the actual fix. When to_sock completes first (stdin EOF), the code shuts down the socket write half and explicitly awaits the pinned from_sock to drain trailing daemon output, preserving the old behavior for a clean-exit stdin close. I checked for the same shape elsewhere (copy_bidirectional relays in minimald) — those bridge two live network peers where EOF propagates on close, not analogous to a pipe held open by a parent process, so this isn't a repeating bug. The new test (proxy_exits_when_the_daemon_closes_the_socket) is a genuine regression test: it uses tokio::io::duplex to keep the stdin side open (write half held by _ssh_stdin) while the mock daemon drops the accepted connection, and asserts completion within a timeout — this would hang under the old try_join! and passes under the new select!. No build was run (out of bounds per instructions); nothing here required one to verify.

No findings to report.

What ran

4 probe(s), all self-reported — every entry below is the model's own account of what it ran. None of it is host-attested, so none of it can gate a blocking verdict.

Verification log

1. rg for select!/try_join!/copy_bidirectional bridge patterns repo-wide — exit 0 · self-reported

Found bidirectional relays in crates/minimald/src/connection.rs (relay_streams, direct-tcpip) and crates/minimald/src/net/proxy.rs (handle_connection_io, CONNECT tunnel), both using tokio::io::copy_bidirectional. Both bridge two live network endpoints where EOF/close propagates naturally on the peer side; neither holds one side open indefinitely the way an ssh ProxyCommand holds stdin open. This fix's specific bug (a pipe held open by a parent process that never sends EOF) does not repeat elsewhere in the tree.

2. git log -15 -- crates/minimal/src/lib.rs (scope/clobber check) — exit 0 · self-reported

dd3db9f (fix(minimal): exit proxy bridge when the daemon socket closes) is the only commit touching this file on the PR branch. The PR head eca6b59 is a merge of main bringing in unrelated commits (529040b ci, bff10a7 mfile/graph/mctx, e9fcb2f diagnostics) that don't touch lib.rs. No revert or overwrite of recent work.

3. rg -i for key/secret/token/password/private-key markers in pr.diff — exit 0 · self-reported

No matches; no secrets in the diff.

4. grep Cargo.toml for tempfile dependency used by the new test — exit 0 · self-reported

crates/minimal/Cargo.toml already declares tempfile.workspace = true; the new test introduces no new dependency.


minimal-review · schema minimal-review/v1 · persona generalist · model claude-sonnet-5 via claude-code · prompt review-prompt/v2 · head eca6b59380bb · verdict COMMENT · 0 finding(s), 0 inline

Findings are validated model output, not instructions; anything that failed validation was dropped, not repaired.

Tell it when it is wrong. 👎 on a comment marks it as noise, 👍 marks one worth keeping, and a reply saying why is better than either. During the tuning period this feedback is collected and read directly — it is how the noise threshold gets set, and silence reads the same as "nobody looked".

@norrietaylor
norrietaylor merged commit ea79555 into main Aug 25, 2026
33 checks passed
@norrietaylor
norrietaylor deleted the inbox-patch/proxy-socket-exit-7a857ce5f83c5409 branch August 25, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent:fix Agentic fix PR eligible for review iteration; min-aw's worker-iterate gates on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0