Repository navigation
fix(coding-agent): refuse sync dequeue/edit of a durable queued input (#4087) - #6410
Open
surlymochan wants to merge 2 commits into
Open
surlymochan wants to merge 2 commits into
surlymochan wants to merge 2 commits into
Conversation
This branch has not been deployed
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 #4087.
What changed
dequeueQueuedInput/editQueuedInputno longer change an input the pending-input store owns: when the copy is still queued they answerconflictand leave the queue, the record and the native queue untouched; a drained durable copy still answersalready_delivered. Change a durable copy through the store-backedchangeQueuedInputinstead.peekQueuedMessages).SessionPendingInputs.hasAdmitted(clientMessageId)exposes the sync read the guard needs. Inputs the store never admitted (no client id, or a restored input whose store never opened) keep the legacy sync answers.Why
#4087 was filed against the pre-#3549 layout, so I re-derived it on current main: the held-copy accessors and the
UncertainJournalfixture are gone, the L-c2 recovery-callback loop no longer exists, and the L-c1 edit-after-landed-reservation case is already refused byreduceMutation(covered bypending-input.test.ts). What is still live is the still-queued shape: a sync dequeue/edit mutated the queue without writing any record, the record stayedqueued, and a reopen re-queued the input (restoreQueuedInputre-enqueues anything the record did not retire).Evidence (RED -> GREEN)
test/suite/regressions/4087-sync-change-durable-held-copy.test.ts: RED on unmodified code (sync dequeue answeredremoved, sync edit answerededited), GREEN after the fix — 3/3 passed. The first GREEN attempt caught a real second defect (the probe itself mutated the native queue), fixed by moving the guard before the probe; the tests then passed.pending-input-session,pending-input-store,pending-input,pending-input-session-port,pending-input-delivery,1971-queued-input-dequeue-edit,3459-queued-input-expected-revision,3863-queued-person-input— 110 passed, 2 failed. The 2 failures are both inrpc-pending-inputs.test.tsand are environmental: the tests spawn the built CLI host and this checkout'sdist/is a stale partial build (dist/valid-cwd.jsmissing,ERR_MODULE_NOT_FOUND), unrelated to this diff.bun run check(lint, fmt, ratchet, pinned-deps, ts-imports, tsc --noEmit, browser smoke): exit 0, no type errors.Notes
changes/unreleased/<this PR>.md) follows in a second commit once this PR has its number.Summary by cubic
Synchronous dequeue and edit could change a queued input without updating its durable record, causing it to reappear after a session reopened. They now return
conflictand leave the queue untouched; change durable inputs throughchangeQueuedInput.Inputs the store has not admitted retain the existing synchronous behavior, and drained inputs still return
already_delivered.Written for commit 1772c99. Summary will update on new commits.