fix(acp): serialize stdin writes through a single actor - #6675
Open
moneypartners wants to merge 1 commit into
Open
fix(acp): serialize stdin writes through a single actor#6675moneypartners wants to merge 1 commit into
moneypartners wants to merge 1 commit into
Conversation
Route complete NDJSON frames through one writer task so cancelling a prompt future cannot leave partial bytes for session/cancel to append to. Add a duplex-based regression test for the cancellation race. Refs block#6671 Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Money Partners <moneypartners.tools@gmail.com>
Author
|
Full repository gate verified on commit dc2492c: |
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.
Fixes #6671.
What changed
tokio::io::duplexandLinesCodecthat cancels a >256 KiB prompt write before sendingsession/cancel.Why
write_ndjsonpreviously performedwrite_all(line), newline, andflushinside caller futures. The prompt path is cancellable throughtokio::select!; dropping it after a partial pipe write left those bytes behind. The cleanup path then appendedsession/cancel, creating one invalid NDJSON line.The production capture behind #6671 was a 65,773-byte malformed frame ending in a partial prompt immediately followed by a complete cancel notification. The raw capture includes channel payloads, so the issue records its checksum and sanitized boundary instead of publishing the payload.
With the actor, cancelling a caller can only leave a complete frame enqueued or no frame enqueued. The actual
write_all+flushis never owned by the cancellable caller.Verification
Ported onto upstream
mainat0720f5380ce8rather than pushing the originaldesktop-v0.5.4-based branch.The new regression test passes against the production
StdinWriterand reads two independently valid JSON lines through the same codec used byAcpClient.