Skip to content

chore: merge upstream queue stack (coder/coder#31156) - #23

Merged
ibetitsmike merged 19 commits into
mainfrom
mike/fork-upstream-stacks-3-queue-stack
Nov 9, 2026
Merged

ibetitsmike merged 19 commits into
mainfrom
mike/fork-upstream-stacks-3-queue-stack

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Part of #6.

Merges the upstream queue stack into fork main as upstream wrote it, so later workspaces can build on queued-message delivery modes, the steer lane and Send now. Merge with a merge commit (not squash), like sync PRs, so a later merge of the same upstream branch brings only new commits.

Merged head: ethanndickson/chat-send-now-steer at 7b15d1581a14230efdff8805bad0f78d274bde27 (fetched 2026-11-09 00:20 UTC). Not coder#31174, per the brief.

Upstream PR Branch Head merged Title
coder#30073 ethanndickson/chat-queue-delivery-mode 2c514df17e chore(coderd): store a delivery mode on queued chat messages
coder#31153 ethanndickson/chat-queue-batch-delivery 7a352a0ff5 refactor(coderd): deliver queued chat messages through one helper
coder#31154 ethanndickson/chat-steer-lane 464c55a501 feat(coderd): add a steer lane to queued chat messages
coder#30074 ethanndickson/chat-steer-next-step baf0487cc2 feat(coderd/x/chatd): deliver steer messages before each model call
coder#31155 ethanndickson/chat-interrupt-send-steer f5ab996dfd feat: store interrupt sends in the steer lane
coder#31156 ethanndickson/chat-send-now-steer 7b15d1581a feat(coderd): steer queued messages on Send now

Each listed head is an ancestor of the merged head. The branch forked from upstream main at bf47fc68d9, which fork main already contains, so the merge brings only the stack's 14 commits. Upstream main (80978fa5ef) still ends at 000639.

Rehearsal on a copy of the live database

This ran at 2026-11-09 03:18 UTC on head 3f29af10ae, which is this branch merged with main at 8c183ed4f8 (#16, #25, #17 and #2). The run reads the live coder database only through pg_dump and restores the dump into a scratch database.

  • Live state: schema_migrations is at 639 and not dirty. The live database has 3 chatd nodes: adopt, chat_subagents and plugins.
  • Migration: the copy goes from 639 to 640 in 25 ms. A second run is idempotent (19 ms) and leaves the copy at 640, not dirty.
  • Row counts: they are identical before and after across all public and chatd tables. The only change is chatd.migration_nodes, which goes from 3 to 4. The new node 000640_chat_queued_message_busy_behavior applies last.
  • Schema change: the migration creates the chatd.chat_busy_behavior type and adds chatd.chat_queued_messages.busy_behavior as NOT NULL DEFAULT 'queue'. On 8f577c996e, an earlier run filled the one existing queued row with queue.
  • Fresh database: a database migrated from scratch has the same schema as the migrated copy. Only the per-dump \restrict tokens differ.

Validation

3f29af10ae: chatdmig route is clean, and chatdmig check lists adopt, plugins, chat_subagents, then 000640. The chatdmig suites, go build ./..., and go test -count=1 ./coderd/x/chatd/... ./coderd/database/dbauthz/ ./coderd/database/ ./coderd/database/forkdb/... plus go test -run Chat ./coderd/ against Postgres 17 in Colima all pass. Earlier, on 8f577c996e:

  • chatdmig suite against Postgres (CHATDMIG_TEST_DATABASE_URL) and cmd/chatdmig tests: pass.
  • go build ./...: pass.
  • go test -count=1 ./coderd/x/chatd/... ./coderd/database/dbauthz/ ./coderd/database/ and go test -run Chat ./coderd/ against Postgres 17 in Colima: pass.

ethanndickson and others added 16 commits November 6, 2026 05:52
Add a chat_busy_behavior enum ('queue', 'steer') and a busy_behavior
column on chat_queued_messages. Every current insert stores 'queue', so
behavior does not change. A later change delivers 'steer' rows at the
next step boundary.
FinishTurn, FinishInterruption, SendMessage from E1, and
PromoteQueuedMessage now share deliverQueuedRows, which moves a list
of queued rows into history. The delivery still takes only the queue
head, and a head under edit still pauses the chat. FinishTurnResult
and FinishInterruptionResult return PromotedMessages as a slice.
chatstate now uses the busy_behavior of a queued message as its lane,
steer or queue. The queue lists the steer lane first, then the queue
lane.

FinishTurn, FinishInterruption, and a send from E1, E1P, or P deliver
the whole steer lane. If the steer lane is empty, they deliver the
queue head. Delivery stops at the first row under edit, so rows ahead
of an edited row still go out in order. chatstate accepts the steer
busy behavior, but no caller sends it yet. Interrupt sends still go
into the queue lane, and PromoteQueuedMessage reorders a message
inside its own lane.
Before each assistant model call, the generation task applies
DeliverSteerMessages. If steer messages are queued, it moves them into
history and returns without the call. The history change starts a new
generation task, which sends them to the model. Queue messages wait
until the turn ends. Compaction calls do not deliver steer messages.

chatd.SendMessage accepts the steer busy behavior.
An interrupt send now stores the message at the end of the steer lane.
Before, it went to the head of the queue lane from R0, R1, or R1P, and
to the tail of the queue lane from I1 or I1P. FinishInterruption
delivers the whole steer lane, so the message goes into history after
the steer messages that were queued before it. A steer message under
edit still stops the delivery, so the message waits behind it.
Send now ends any edit on the queued message and moves it to the end of
the steer lane. In the same transaction, it interrupts the chat if the
chat is running or requires action, or is interrupting and no worker
owns it. From E1, E1P, or P, it delivers the steer lane into history,
up to the first message under edit.

SteerQueuedMessage replaces PromoteQueuedMessage in chatstate, and the
SteerChatQueuedMessage query replaces ReorderChatQueuedMessageToHead.
When chatstate refuses a delete, edit, or Send now on a queued message, it now looks up the message. A missing message returns ErrQueuedMessageNotFound (404). An existing message keeps ErrTransitionNotAllowed, which the handlers map to 409, as on main.
The test enables the chat worker. The worker can take over the unowned requires_action chat, and without requires_action_deadline_at it cancels the pending tool call at once, so SubmitToolResults got a 409.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum acted for Mike: requested review of 8f577c9.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T03:21:58.807133Z 3f29af1 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 8f577c996e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum acted for Mike: requested review of 57fd473 (main 7e37c9b merged in; the PR diff is still the queue stack plus the 000640 route).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 57fd473760

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum acted for Mike: requested review of 3f29af1 (main 8c183ed merged in; the PR diff is still the queue stack plus the 000640 route).

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 3f29af10ae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike

Copy link
Copy Markdown
Owner Author

UAT

These rounds ran through Coder Agents on the local deployment. A dev server built from this branch ran inside the docker-template workspace uat-r2-envsetup, which is now deleted. The isolation proof and the leak audits were clean in every round.

  • Round 4: BLOCKED (partial) on 57fd4737606f36fa6e214858fbf99df4167bcd38, chat ac10403a-39a7-44fc-a782-022a5fdc0d67.
    • Upgrade path passed. The round-3 dev DB was at 639 with the chatd nodes. On restart at this head it applied node 000640_chat_queued_message_busy_behavior, and schema_migrations is 640, not dirty. chatd.chat_queued_messages.busy_behavior is NOT NULL DEFAULT 'queue'.
    • Queue scenarios passed. A send while the agent runs queues and is delivered after the turn. Through the API, queue returns 200, interrupt returns 200 (not 400, because feat!: steer chat messages by default and remove the interrupt busy behavior coder/coder#31174 is not included), and an invalid value returns 400.
    • Not run because of browser thrash: steer, Send now, the async question after the merge, and a plain chat.
  • Round 5: PASS on 57fd4737606f36fa6e214858fbf99df4167bcd38, chat ac10403a-39a7-44fc-a782-022a5fdc0d67. This round used the API and the database, and it asserted order by position and row id:
    • Async question after the merge: an answer given while the agent runs joins the end of the queue in the queue lane and is delivered FIFO after the queued marker.
    • Steer: an interrupt send is stored in the steer lane. It is delivered before the next model call in the same turn, and the model reacts to it.
    • Send now: POST .../queue/{id}/promote returns 202, the row moves from queue to steer, and the message is delivered mid-turn ahead of the turn-end marker.
    • Plain chat: works.

Non-blocking findings, all in upstream behavior as written:

  • The public enum is queue|interrupt, but the stored lane is queue|steer.
  • codersdk.ChatQueuedMessage omits busy_behavior.
  • A non-owner promote returns 404, not 403.
  • Promote moves position backwards. The lane, not the position, decides delivery.

Nothing in any round shows that the merge broke something.

The head moved from the tested SHA only through merges of main:

Neither merge changes 000640, routes.txt or early.txt, and chatdmig route stays clean.

Xum acted for Mike: posted the UAT record for this PR.

@ibetitsmike
ibetitsmike merged commit c479170 into main Nov 9, 2026
8 checks passed
@ibetitsmike
ibetitsmike deleted the mike/fork-upstream-stacks-3-queue-stack branch November 9, 2026 03:45
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum (AI agent) merged this on behalf of @ibetitsmike after verifying the exact head 3f29af1: fork-ci green (build, chat-tests, forkdb, graph, quiet, schema), Codex clean on this head, 0 unresolved threads, UAT PASS on 57fd473 with only a clean main merge after it, and the 000640 rehearsal on a live-database copy recorded above. Merged with a merge commit as c479170.

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.

2 participants