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 W0a: items 1 to 4 of the W0 brief below, on mike/fork-foundation. Item 5 is W0b.
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
Notes from the PR #2 author (head
7bff5a104a, forkdb landed in commit35a62a01e7), to verify while splitting forkdb out:forkdb/apikeyscopes.go(plugin API key scopes andValidAPIKeyScope, used bycoderd/apikey/apikey.go),forkdb/queries/plugins.sqlandplugins.sql.go,forkdb/modelmethods.go(plugin RBAC objects), the chatdmigpluginsnode, andenterprise/dbcrypt/fork_forkdb.go(it overrides 6 plugin config queries; a generic version would only embedforkdb.Store).dbauthz/fork_forkdb.go(theforkQuerierchecks are per query),dbauthz/fork_forkdb_test.goplus a 4-line skip ofForkUnwrap/ForkWrapin upstreamTestDBAuthzRecursive,scripts/check-scopes/fork.go(readsALTER TYPE api_key_scope ADD VALUEfrom chatdmig nodes), andforkdb_test.go(TestSQLCSchemaOrder,TestFromandTestInTxare generic,TestAPIKeyScopeValuesis not).chat_subagentsnode) or a placeholder.main.ibetitsmike commentedon Nov 9, 2026
W0a status: opened #25 (PR 1 of the foundation stack: forkdb package,
chat_subagentsnode,GetChatSubagentByChatID, fork-ci drift job) at99317f60ee. Remote UAT PASS onc4802d3262; later commits change tests only. Codex review requested.ibetitsmike commentedon Nov 9, 2026
W0a status: #25 is READY at
99317f60ee: fork-ci green on the head, Codex reviewed (3 findings dropped under the scope rule, threads resolved), UAT PASS onc4802d3262with test-only commits after it. Waiting for the lead to merge.ibetitsmike commentedon Nov 9, 2026
W0a status: PR 2 of the stack is open as #26 (
InsertChatSubagent, head12b4d48cfd), rebased ontomainafter #2 merged. Codex review requested; PR 3 (Go hooks) is committed locally and follows once #26 is READY.ibetitsmike commentedon Nov 9, 2026
W0a status: PR 3 of the stack is open as #27 (fork hooks for chat tools, chat routes and experiments, head
40a073c935). It is based onmainand independent of #26. Codex review requested.ibetitsmike commentedon Nov 9, 2026
W0a status: #26 is READY for the lead at
1356ff9633(fork-ci green, Codex clean). #27 has a clean Codex verdict atbc6508af5band is in UAT. #28 (fork-ci jobs and the README how-to) is open and merges after #27. The frontend hooks PR is in implementation.ibetitsmike commentedon Nov 9, 2026
W0a status: opened #30 (frontend hooks:
forkToolRenderersspread inTool.tsx,ForkComposerSlotinAgentChatInput.tsx). #26 is merged. In #27, UAT found that anonymous/chats/fork/*returned 404 instead of 401; that is fixed in fc9fb28 and UAT round 2 is running. #28 is Codex clean and waits on #27.ibetitsmike commentedon Nov 9, 2026
W0a status: #25, #26, #27 and #28 are merged. #30 (frontend hooks) is READY at 133bfc6: fork-ci green including the new site job, Codex clean, UAT passed with the UI identical to main. Open item for @ibetitsmike: two
TODO(ibetitsmike)comments incoderd/x/chatd/ARCHITECTURE.md(the/chats/forkmount andappendForkTools).ibetitsmike commentedon Nov 9, 2026
W0a final status: the foundation stack is merged.
InsertChatSubagentfork query with the chat pluschat_subagentsrollback testappendForkTools), chat routes (registerForkChatRoutes, authenticated, 404 under/chats/fork) and experiments (ForkExperiments)agent-sdkandsitejobs, and the "Add a fork table and query" section inchatdmig/README.mdforkToolRenderers,ForkComposerSlot)Every PR merged with green fork-ci on its exact head, a clean Codex review, no unresolved threads, and UAT (N/A for the CI-only #28). Open item for @ibetitsmike: two
TODO(ibetitsmike)comments incoderd/x/chatd/ARCHITECTURE.md(the/chats/forkmount andappendForkTools).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)