Repository navigation
An agent that stops reading its input is a closed connection, not a crash - #270
Merged
Merged
Conversation
…rash heed, the heed CLI and the test process now ignore SIGPIPE at startup, so a write to a pipe or socket whose reader has gone fails with EPIPE instead of ending the process. That was the 1-in-16 "unexpected signal code 13" in full test runs: ACPProcessTransport checked the agent was running, then wrote to its stdin, and an agent that exited in between killed the test run (or the app). - ACPProcessTransport.send throws ACPError.closed when the write fails. - The CLI sets SO_NOSIGPIPE on its hook socket, and writes stdout and stderr with write(contentsOf:), so `heed watch | head` ends quietly rather than raising. - The other writers already set SO_NOSIGPIPE (Control, ClaudeInbox, TelemetryServer), write to a file (HookSpool) or give their child no stdin pipe (ProcessRunner, HostEventStream). The test process ignores SIGPIPE from a C constructor in a small test-only target, HeedTestProcess: Swift Testing has no hook that runs before every test, and a trait or shared helper covers only the tests that opt in. The constructor runs when the bundle loads, before any test; theTestProcessIgnoresBrokenPipes checks it did. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Full test runs crashed about 1 in 16 with
swiftpm-testing-helper ... exited with unexpected signal code 13. ACPProcessTransport checked the agent was running, then wrote to its stdin. If the agent exited in between, SIGPIPE ended the whole process. The running app had the same crash.heedCLI and the test process ignore SIGPIPE at startup (BrokenPipe.ignore(), and a C constructor in a test-onlyHeedTestProcesstarget for the test bundle, because Swift Testing has no hook that runs before every test).ACPProcessTransport.sendthrowsACPError.closedwhen the write fails.SO_NOSIGPIPEon its hook socket and writes stdout/stderr withwrite(contentsOf:), soheed watch | headends quietly.SO_NOSIGPIPE, HookSpool writes to a file, and ProcessRunner and HostEventStream give their child no stdin pipe.Tests: one agent closes its stdin and keeps running, so the write after the running check is always the one that fails. Another agent exits without reading. A third test checks that the test process ignores SIGPIPE.
Testing the tests:
signalcall removed, the closed-stdin test kills the run withunexpected signal code 13, the same failure CI showed.NSCocoaErrorDomain 512 / POSIX 32 Broken pipe.16 full-suite runs in a row: no signal 13. The only failures were the known
theHookStaysFast, plus wall-clock checks under a loaded machine (removalWaitsForTheSummaryButNotForever3/16,manyAsksAtOnceAreEachAnswered…1/16). This change does not touch the code those two test.🤖 Generated with Claude Code