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.
W3 · Per-subagent isolation · mike/subagent-isolation
Task. Add isolation: shared | worktree | workspace to spawn_agent (PRD 6.2).
Background. A child copies the parent's WorkspaceID, BuildID and AgentID (subagent_operations.go:468-470). The agent git API has only GET /watch (agent/agentgit/api.go:40). Context scan roots are per agent, not per chat (agent/agentcontext/manager.go:591-617), so a worktree child reads the parent checkout's skills and instructions in v1. execute already takes workdir (chattool/execute.go:54).
Scope.
- Agent:
POSTandDELETE /api/v0/git/worktrees; create atbase_branch(default parentHEAD) on a new branch named from the child chat; location~/.coder/worktrees/<repo>/<chat>(decisionwtloc); allowed-roots path checks; delete refuses dirty or unpushed trees and says why. - chatd: isolation argument and definition default;
chat_subagentsrow; child defaultworkdirand file-tool root are the worktree; the child's system prompt names the path and branch. - Cleanup (R2.4): archive removes clean worktrees and reports kept ones to the parent.
workspace: create through thecreate_workspacepath (turn_environment.go:2573), so quotas and prebuilds apply; bind the child inCreateChatWithID(subagent_operations.go:465-470); child workspaces follow the root's archive and autostop; the parent can stop them.wait_agentadds branch, worktree path or workspace name, and the diff summary (R2.5).
R2.7 (fork from uncommitted state) waits for a later plan.
Acceptance (PRD 6.2).
- Two
worktreechildren edit the same file on different branches, both commit, and the parent checkout is unchanged. - A
workspacechild runs commands in a different workspace than its parent, visible in the UI. - Archiving the root cleans clean worktrees and reports kept ones.
Constraints. Experiment fork-subagent-isolation. Starts after W2's spawn PRs merge. The definition default for isolation needs W1's frontmatter parser; if W1 has not merged, ship the spawn argument first. Record the per-agent context limit in the adapter (W7).
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 9, 2026
W3 status: opened #81 (PR1, agent git worktree API).
ibetitsmike commentedon Nov 10, 2026
PR2 (spawn_agent worktree creation) opened: #108 at a79e3e5.
ibetitsmike commentedon Nov 10, 2026
PR2 #108 READY at ab14e15: Codex clean on the head, fork-ci green (https://github.com/ibetitsmike/coder/actions/runs/42759837414).
ibetitsmike commentedon Nov 10, 2026
PR2 #108 READY again at 47ff189 after merging main (with #95): Codex clean on the head, fork-ci green (https://github.com/ibetitsmike/coder/actions/runs/42790347791).
ibetitsmike commentedon Nov 10, 2026
PR3 (child binding) opened: #135 at 609e4bd.
ibetitsmike commentedon Nov 10, 2026
PR3 #135 (worktree child binding) is READY at b33147a: Codex is clean, fork-ci is green, and the UAT rerun passed all 5 cases.
ibetitsmike commentedon Nov 10, 2026
PR4 (archive cleanup of subagent worktrees) opened as #138 at e03161c.
ibetitsmike commentedon Nov 10, 2026
PR4 #138 is READY at 93463b5: Codex clean (issuecomment-6767369875), fork-ci green (run 42815000190), 0 open threads, UAT passed.
ibetitsmike commentedon Nov 10, 2026
PR5 (wait_agent worktree report) opened: #141 at 61c288e.
ibetitsmike commentedon Nov 10, 2026
PR5 #141 READY at a6235c5 (Codex clean, fork-ci green, UAT pass).
ibetitsmike commentedon Nov 10, 2026
PR4 #138 merged as 77b2073 (subagent worktrees removed on family archive).
ibetitsmike commentedon Nov 10, 2026
W3 PR6a opened: #144 (spawn_agent
isolation: workspace, stacked on #141), head bb356f7. UAT on :3200 is pending.ibetitsmike commentedon Nov 10, 2026
PR5 #141 (wait_agent report for worktree children) merged as 64965c9. #144 now targets main and shows only its own diff, at 01aa038.
ibetitsmike commentedon Nov 10, 2026
PR6b #147 is open on top of #144: archiving a family stops the workspaces of its workspace subagents.
ibetitsmike commentedon Nov 10, 2026
W3 READY for the lead: #144 at 01aa038 and #147 at 0989048. Both have a clean Codex review on their head and passing fork-ci. The :3200 UAT at 0989048 covered the isolated spawn happy path and confirmed that archiving the family stops the child workspace.
ibetitsmike commentedon Nov 10, 2026
PR6a #144 (spawn_agent
isolation: workspace) merged as 9705e5a. I merged main into #147, now at ca6e91a. Its diff is unchanged, and CI is running.ibetitsmike commentedon Nov 10, 2026
PR8 opened: #151, agent definitions can set the default subagent isolation.
ibetitsmike commentedon Nov 10, 2026
PR7 opened: #152, the spawn and wait tool cards show the subagent's branch, worktree or workspace, and the worktree diff summary.
ibetitsmike commentedon Nov 10, 2026
READY: #152 (tool cards show worktree isolation) at c20eecb, Codex clean, fork-ci green, UAT done.
ibetitsmike commentedon Nov 10, 2026
READY: #151 (agent definitions set the default subagent isolation) at 08a2dcb, Codex drop-only round, fork-ci green, UAT done.
ibetitsmike commentedon Nov 10, 2026
MERGED: #147 as bef9c59. Remaining in this issue: #152 and #151, both READY.
ibetitsmike commentedon Nov 10, 2026
MERGED: #152 as 73169c3. Remaining in this issue: #151, READY.
ibetitsmike commentedon Nov 10, 2026
MERGED: #151 as 14d31fa. All W3 PRs are merged; W3 is done.
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)