Repository navigation
[SEL-391] Keep approval and small fields in --timeout errors - #155
Merged
Merged
Conversation
…it (SEL-391)
With an explicit --timeout a hard exit fires if the command is stuck. If
stdout is stalled and an error object is larger than the pipe's atomic
write size, the kernel takes part of it, the write blocks, and the hard
exit leaves an unterminated line on stdout. Any error object can be that
large, not only timeout errors: a network_error with a long hostname was
cut 5 of 5.
When --timeout is given explicitly, an error object on stdout is now at
most 512 bytes including its newline, measured after JSON encoding, and
written in one Write. v, error and message are kept, message shortened
on a UTF-8 boundary if needed. Other fields are kept only while the
object still fits, never partially. sel doctor's object carries
failed_check (the first failing check's name) in place of the doctor
field, and the full document goes to stderr as one {"v":1,"doctor":{...}}
line after the stdout object.
Choices the decision did not cover: a server-supplied error code that
alone cannot fit is shortened to fit, with an empty message; extra
fields are tried in key order and a field that does not fit is skipped,
later smaller ones are still kept. Pending-approval documents are not
error objects and are unchanged.
Without an explicit --timeout, and with --watch (no hard exit), output
is unchanged.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
They need no pipe stall, only a child process and a server, so they use runBinaryIn instead of the Linux-only runCapped. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
…under --timeout (SEL-391) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
…or objects (SEL-391) Under an explicit --timeout the 512-byte error object lost three things the contract says an agent can rely on, and doctor's stderr document could change the exit code. - approval was dropped from every exit 6 and 7 error, including the second 202's new approval. It is now compacted to id, url, status and expires_at (the write object's shape, CONTRACT 5.5) before it is sized. Compaction round-trips through JSON because the field is a *api.Approval from the wait path and a json.RawMessage from the re-send path. - message was sized before the other fields, so a long server message evicted retry_after_s, attempts, scope and failed_check. Fields are now placed first, keeping room for the first 128 written bytes of the message (rounded up to a rune boundary), and the message takes what remains. A field that does not fit is still dropped whole. The 512-byte cap wins over the 128-byte floor when the error code or control-character escapes leave no room. - doctor ... 2>&1: the stderr document is skipped when stderr is the file stdout is written to, so the last JSON line is the error object. - doctor with a stalled stderr: the document write is bounded by backstopExit/2 and, when it lapses, the Error: line (which would block behind the partial document) is skipped so the real exit code is returned instead of 8. Not fixed: a 422 whose fields value alone exceeds 512 bytes is still dropped. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp
This was referenced Nov 22, 2026
natevick
marked this pull request as ready for review
November 22, 2026 20:51
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.
SEL-391 follow-up: under
--timeout, #149 dropped fields agents act on and could change doctor's exit code. This keeps them and returns the real code.Stacked on #149 (
badd67a). Merge the two together.What changed
approval:id,url,status,expires_at.retry_after_s,attempts,scopeandfailed_checkno longer lose to a longmessage. The message keeps at least its first 128 written bytes unless the line cap leaves less. The line stays at most 512 bytes.doctor ... 2>&1: the error stays the last JSON line. The full document is skipped when stderr is the file stdout writes to.Error:line is skipped.Checks on
1fe02ec-race, and 5/5 with 8 busy loops running.clock.fire, keepingBoundedErrorwith&& !ctrlC. Vet, lint andgo test -racepass (21 packages). The new tests and SEL-389 stalled-pipe rows pass 3/3.Not established
fieldsalone exceeds 512 bytes still losesfields.🤖 Generated with Claude Code
https://claude.ai/code/session_0186m4FrY9RHAiNN1uxztLCp