Skip to content

fix(coding-agent): refuse sync dequeue/edit of a durable queued input (#4087) - #6410

Open
surlymochan wants to merge 2 commits into
code-yeongyu:mainfrom
surlymochan:fix/4087-held-durable-sync-change
Open

surlymochan wants to merge 2 commits into
code-yeongyu:mainfrom
surlymochan:fix/4087-held-durable-sync-change

Conversation

@surlymochan

@surlymochan surlymochan commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4087.

What changed

  • dequeueQueuedInput / editQueuedInput no longer change an input the pending-input store owns: when the copy is still queued they answer conflict and leave the queue, the record and the native queue untouched; a drained durable copy still answers already_delivered. Change a durable copy through the store-backed changeQueuedInput instead.
  • The guard runs before the still-queued probe on purpose: the probe itself removes/replaces the native message, so a refused change checked after it would still lose or rewrite the copy. The guard reads the native queue non-destructively (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 UncertainJournal fixture are gone, the L-c2 recovery-callback loop no longer exists, and the L-c1 edit-after-landed-reservation case is already refused by reduceMutation (covered by pending-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 stayed queued, and a reopen re-queued the input (restoreQueuedInput re-enqueues anything the record did not retire).

Evidence (RED -> GREEN)

  • New test/suite/regressions/4087-sync-change-durable-held-copy.test.ts: RED on unmodified code (sync dequeue answered removed, sync edit answered edited), 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.
  • Neighbouring suites after the fix: 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 in rpc-pending-inputs.test.ts and are environmental: the tests spawn the built CLI host and this checkout's dist/ is a stale partial build (dist/valid-cwd.js missing, 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

  • The change fragment (changes/unreleased/<this PR>.md) follows in a second commit once this PR has its number.
  • CLA: to be signed by the user (Chao Chen) if required for this repo.

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 conflict and leave the queue untouched; change durable inputs through changeQueuedInput.

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.

View guided diff

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-up to #4056: sync dequeue/edit can change a held durable copy without a store record; two recovery paths lack tests

1 participant