Repository navigation
Description
Xum created this issue on behalf of @ibetitsmike.
Part of #4.
Workspace brief from the pstack parity plan (local plan page "Running pstack on the Coder Agents Fork"; the PRD is local to Mike's Mac and not reproduced here). Claim numbers such as 1.3 or shared.2 refer to the plan page.
This issue is W0b: item 5 of the W0 brief below (the chatdmig version guard, the question-stack merge and the queue-stack merge), on mike/fork-upstream-stacks. Items 1 to 4 are W0a.
W0 · Foundation (runs as W0a and W0b)
W0a builds items 1 to 4 on mike/fork-foundation. W0b brings the upstream stacks (item 5) on mike/fork-upstream-stacks. They run in parallel.
Task. Build the fork base that every feature workspace uses, then stop.
Background. The fork keeps Coder Agents tables in a chatd schema with graph-ordered nodes (coderd/database/migrations/chatdmig/README.md). The README reserves coderd/database/forkdb for fork queries; fork main does not have the package yet (README.md:192-195).
- Draft fork PR feat: add chat plugins backed by a chatd fork node #2 (
mike/chat-plugins, Xum workspaceca58893a63, "Port chat plugins to the fork") already has it:forkdb.From,InTxandWrapper(coderd/database/forkdb/forkdb.go),fork_forkdb.gofiles incoderd/database,dbauthz,dbmetricsanddbgen,forkdb/generate.sh,sqlc.yaml, a fork-ci job and README text. W0a takes that infrastructure from PR feat: add chat plugins backed by a chatd fork node #2 as it is, with the same file names and APIs and none of the plugin tables, queries, RBAC or routes, so PR feat: add chat plugins backed by a chatd fork node #2 can rebase by dropping its copy. Messageca58893a63before the first PR and keep it informed.
Scope (W0a, stack of about 5 PRs).
forkdbpackage, taken from PR feat: add chat plugins backed by a chatd fork node #2:sqlc.yamlthat reads../dump.sqland then the nodes in graph order, a generate target, aStoreinterface, and an authz wrapper that loads the owning chat through dbauthz first. A test fails when a forkdb method has no authz check.- Transaction accessor: fork files in
coderd/database,dbauthzanddbmetricsthat unwrap adatabase.Store(also the oneInTxpasses) to itsDBTX, soforkdb.New(tx)joins the upstream transaction. Callers: child creation (chatstate.CreateChatWithID,subagent_operations.go:465),Admit(agentadmission.go:28), wake-up claims, archive cleanup.
- Transaction accessor: fork files in
- First node
chat_subagents(plan shared.1):chat_id,agent_type,depth,isolation,worktree_path,branch,workspace_id. No backfill: a chat with no row is a legacysharedchild of its built-in type. - Hooks:
p.appendForkTools(...)afterturn_environment.go:737;registerForkChatRoutesincoderd/chat_routes.go:17; a fork renderer spread intoolRenderers(Tool.tsx:1178); one composer slot;codersdk/fork_experiments.gowithinit()that appends toExperimentsKnown(deployment.go:5562). - fork-ci jobs: forkdb generate drift,
go test ./agent/agentcontext/... ./agent/agentgit/..., sitetscandvitestforsrc/pages/AgentsPage. Current jobs are onlygraph,schema,chat-tests,build.
Scope (W0b, 3 PRs).
- Upstream stacks (plan shared.5, decision
upstream= merge): one PR per stack that merges the stack's top branch fromcoder/coderinto forkmain, as upstream wrote it. The PR description lists the upstream PRs and head SHAs it contains.- Question stack, now:
mike/codagt-1460-question-dock(feat: pin the open async question above the chat input coder/coder#31312, which contains feat: let web UI chats ask questions without ending the turn coder/coder#31310, feat(site/src/pages/AgentsPage): show ask_user_question options as numbered one-line answers coder/coder#31555, feat(site/src/pages/AgentsPage): show async question answers without their call line coder/coder#31315 and feat(site/src): answer async agent questions in the timeline while the agent works coder/coder#31294). No migrations. - Queue stack, now (decision
queuestack):ethanndickson/chat-send-now-steer(feat(coderd)!: steer queued messages on Send now coder/coder#31156, which contains chore(coderd): store a delivery mode on queued chat messages coder/coder#30073, refactor(coderd): deliver queued chat messages through one helper coder/coder#31153, feat(coderd): add a steer lane to queued chat messages coder/coder#31154, feat(coderd/x/chatd): deliver steer messages before each model call coder/coder#30074 and feat: store interrupt sends in the steer lane coder/coder#31155). Not feat!: steer chat messages by default and remove the interrupt busy behavior coder/coder#31174: it makes sends steer by default and returns 400 forbusy_behavior: interrupt, and W5 does not need it. - chore(coderd): store a delivery mode on queued chat messages coder/coder#30073 adds
000640_chat_queued_message_busy_behavioronchat_queued_messages.chatdmig routeplaces it in the chatd schema (write the override if it ismixed). The daily server runs it before upstream numbers it for good. Mike defers the sync issues, so add only one guard: golang-migrate keeps one version per database, sochatdmig routefails, and fork-sync stops, when upstream brings a migration whose version is at or below one the fork took from an open branch. Without it, the daily server would skip that migration silently. Ship the guard as its own PR before the queue-stack merge. - Before READY on the queue-stack PR, rehearse its migrations on a copy of the live database (
local-coder-forkmemory, "Rehearse a risky migration") and put the result in the PR description. implement-flow's workflow moves commits asgit format-patchpatches, which drop merge commits. Make each merge commit in the workspace checkout, then run the remainingimplement-flowstages in the chat (validation, dogfood UAT, PR, Codex). The guard PR runs the full workflow.
- Question stack, now:
Starting points. chatdmig/README.md, chatdmig/graph.go, coderd/database/migrations/fork_chatd.go, coderd/database/dbauthz/dbauthz.go:6513, coderd/coderd.go:2656 (ReadExperiments), .github/workflows/fork-ci.yaml.
Acceptance.
chatdmig checkpasses and lists the new node after the adopt node.- sqlc parses the node files (
-- requires:headers are comments) andforkdbgeneration is clean in CI. - With every fork experiment off, a test shows
appendForkToolsreturns the tool list unchanged and fork routes return 404. git diff main -- coderd/database/dump.sql coderd/database/queries.sql.go coderd/database/querier.go coderd/database/dbmockis empty.- A test rolls back a transaction that wrote both a chat and its
chat_subagentsrow and finds neither. - Each stack merge PR passes fork-ci and is merged with a merge commit, like sync PRs (
chatdmig/README.md:208), so later merges of the same branch bring only new commits.chatdmig checklists the routed000640node.
Deliverables. Merged PR stack; a short "how to add a fork table and query" section appended to chatdmig/README.md.
Constraints. No fork feature behavior; item 5 brings upstream code as upstream wrote it. Keep every hook to one line or one call in the upstream file.
Rules for every workspace
| Topic | Rule |
|---|---|
| Runner | One Xum workspace per brief (W0 runs as W0a and W0b), started from fork main at its wave start. Every implementation runs implement-flow with the workstream issue as its input and the brief as the plan. |
| Branches | mike/<topic> for the workspace; stacked PR branches mike/<topic>-<n>-<slug>. Local name equals remote name. Never push to main. |
| PR size | 500 changed lines at most per PR, generated code excepted (reviewer-friendly-pr). Stack with gh stack; the extension is not installed on the Mac today (gh extension install github/gh-stack), else use explicit-base PRs. |
| Schema | Fork tables are chatd graph nodes: go run ./coderd/database/migrations/chatdmig/cmd/chatdmig new <name> -requires <node or upstream:name>. Never edit a node that ran. No edits to dump.sql, queries.sql.go, querier.go, dbmock or numbered migrations. |
| Queries | coderd/database/forkdb only (created by W0). Every method goes through the forkdb authz wrapper. A forkdb write that belongs with an upstream write runs in the same transaction, through the W0 accessor (database.Store exposes only InTx, coderd/database/db.go:22-31). |
| Authorization | Chat-owned rows authorize through the owning chat (dbauthz.go:6513-6522 pattern). Agent and plugin rows reuse the skill RBAC objects. No new RBAC resources, no new API key scopes. Tools run as the chatd subject, which can read and update every chat (dbauthz.go:807-817): a tool that touches a chat other than its own runs as the owner (asOwner, chattool/listtemplates.go:437-443). |
| Upstream files | One hook line per hot file (plan shared.2). Logic lives in new fork files. Hot files: turn_environment.go, chatd.go, subagent*.go, codersdk/chats.go, deployment.go, dbauthz.go, chat_routes.go, AgentChatInput, AgentChatPageView. |
| Open upstream PRs | If a workspace needs an open coder/coder PR, W0 or W7 merges its branch into the fork with a merge commit. Its migrations go through chatdmig route into the chatd schema. Sync conflicts are solved later (Mike, 2026-11-08). |
| Flags | Each feature is behind its fork-* experiment in codersdk/fork_experiments.go. With the flag off, tool lists, routes and UI match upstream. |
| API | Swagger annotations on new public endpoints. Audited types update enterprise/audit/table.go. |
| chatd docs | coderd/x/chatd/ARCHITECTURE.md gets TODO lines only. Mike writes the text. |
| Validation | Go suites run in Colima: a postgres:17 container, plus golang:<go.mod version>-bookworm --network container:<pg> with volumes coder-gen-gomod and coder-gen-gocache and postgresql-client-17 from PGDG. chatdmig tests use CHATDMIG_TEST_DATABASE_URL='postgres://[email protected]:5432/postgres?sslmode=disable'. Never create a postgres role on the live Postgres. Frontend: site/AGENTS.md commands plus frontend-deep-review for any site/ diff. |
| Review | implement-flow ends with codex-review-loop; Codex is installed (2026-11-08). If @codex review gets no reply within 30 minutes, tell the lead and run code-quality-review with Opus until Codex answers. Mike (2026-11-09): fix real defects in the PR's own change; drop scope creep and defensive bikeshedding with a one-line reply and a resolved thread, no follow-up issue. Upstream is only a sync source: never report or file anything upstream. |
| UAT | coder-agents-uat through Coder MCP on the local deployment (http://127.0.0.1:3000, templates devcontainer or docker, RUNBOOK "Running a branch in a dev container workspace"). The remote agent runs scripts/develop.sh for the branch inside its workspace (plan decision uat). Never coder-local use a branch build: that replaces Mike's daily server. |
| Ready | When a PR meets the merge bar, send the lead (task_send_message to 8ac7791132) READY #<pr> <head sha> with the CI, Codex, UAT and open-thread evidence, then wait. Never merge yourself. |
| Merge | The lead merges (Mike, 2026-11-08). Merge bar: green fork-ci on the exact head, a clean Codex verdict, or Codex findings that were all fixed or dropped under the scope rule (the lead confirms each drop), no unresolved threads, UAT PASS on the head or on a SHA whose later commits only answer review, and a lead review of the diff against the brief. Squash, except sync and upstream stack PRs, which take a merge commit. A merge to fork main deploys Mike's daily server through autodeploy within about 5 minutes plus a drain of up to 30 minutes, so the lead merges one PR at a time and waits until Fork ops reports the deploy healthy. Experiments stay off on that server until Mike enables them. |
| Follow-ups | A defect in merged code or on the daily server becomes an issue in ibetitsmike/coder with label followup. Fork ops triages it; an accepted one gets its own workspace running implement-flow. |
Activity
ibetitsmike commentedon Nov 8, 2026
Opened #16 (PR 1 of 3: chatdmig guard for upstream migrations taken early).
ibetitsmike commentedon Nov 8, 2026
Opened #17 (PR 2 of 3: question stack merge, coder#31312 at 3ffaffd).
ibetitsmike commentedon Nov 9, 2026
W0b status: #16 (chatdmig early-version guard) sent READY to the lead at head e62cbe2: fork-ci green, Codex clean, UAT round 2 PASS on 5623042 (later commits answer review). Follow-ups #20, #21. #17 (question stack) waits on UAT round 2; its Codex threads are upstream-identical code, relayed in #22.
ibetitsmike commentedon Nov 9, 2026
W0b status: #16 merged (33b0bb6). Queue stack PR opened: #23 (merge of coder#31156 at 7b15d15, 000640 routed to chatd and listed in early.txt, rehearsal on a live-DB copy passes). Its merge is held until the #21 fix lands. #17 waits on UAT round 2.
ibetitsmike commentedon Nov 9, 2026
W0b status: #17 merged (7e37c9b). #23 (queue stack) sent READY to the lead at head 3f29af1. fork-ci is green and Codex is clean. UAT round 5 passed on 57fd473, and the later commits only merge main. The 000640 rehearsal on a live-DB copy passed on the head. All my UAT workspaces are deleted.
ibetitsmike commentedon Nov 9, 2026
W0b complete. All three PRs are merged into fork main:
Each PR had green fork-ci, a clean Codex review, no unresolved threads and a UAT PASS recorded on the PR. The 000640 rehearsal on a copy of the live database passed. All my UAT workspaces are deleted. Open follow-up: #20, which Fork ops triages.
ibetitsmike commentedon Nov 15, 2026
Closing as done, per Mike's decision on #219 (2026-11-15). Every PR this issue lists is merged; evidence: #4 (comment)