Skip to content

pstack W0b: upstream stack merges #6

Closed

Description

@ibetitsmike

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).

Scope (W0a, stack of about 5 PRs).

  1. forkdb package, taken from PR feat: add chat plugins backed by a chatd fork node #2: sqlc.yaml that reads ../dump.sql and then the nodes in graph order, a generate target, a Store interface, 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, dbauthz and dbmetrics that unwrap a database.Store (also the one InTx passes) to its DBTX, so forkdb.New(tx) joins the upstream transaction. Callers: child creation (chatstate.CreateChatWithID, subagent_operations.go:465), Admit (agentadmission.go:28), wake-up claims, archive cleanup.
  2. 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 legacy shared child of its built-in type.
  3. Hooks: p.appendForkTools(...) after turn_environment.go:737; registerForkChatRoutes in coderd/chat_routes.go:17; a fork renderer spread in toolRenderers (Tool.tsx:1178); one composer slot; codersdk/fork_experiments.go with init() that appends to ExperimentsKnown (deployment.go:5562).
  4. fork-ci jobs: forkdb generate drift, go test ./agent/agentcontext/... ./agent/agentgit/..., site tsc and vitest for src/pages/AgentsPage. Current jobs are only graph, schema, chat-tests, build.

Scope (W0b, 3 PRs).

  1. Upstream stacks (plan shared.5, decision upstream = merge): one PR per stack that merges the stack's top branch from coder/coder into fork main, as upstream wrote it. The PR description lists the upstream PRs and head SHAs it contains.

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 check passes and lists the new node after the adopt node.
  • sqlc parses the node files (-- requires: headers are comments) and forkdb generation is clean in CI.
  • With every fork experiment off, a test shows appendForkTools returns 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/dbmock is empty.
  • A test rolls back a transaction that wrote both a chat and its chat_subagents row 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 check lists the routed 000640 node.

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

  1. added
    pstack-parity
    on Nov 8, 2026
  2. ibetitsmike commented on Nov 8, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    Opened #16 (PR 1 of 3: chatdmig guard for upstream migrations taken early).

  3. ibetitsmike commented on Nov 8, 2026

    @ibetitsmike
    OwnerAuthor

    Xum posted this on behalf of @ibetitsmike.

    Opened #17 (PR 2 of 3: question stack merge, coder#31312 at 3ffaffd).

  4. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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.

    Xum acted for Mike.

  5. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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.

    Xum acted for Mike.

  6. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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.

    Xum acted for Mike.

  7. ibetitsmike commented on Nov 9, 2026

    @ibetitsmike
    OwnerAuthor

    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.

    Xum acted for Mike.

  8. ibetitsmike commented on Nov 15, 2026

    @ibetitsmike
    OwnerAuthor

    Coder Agents acted on behalf of @ibetitsmike.

    Closing as done, per Mike's decision on #219 (2026-11-15). Every PR this issue lists is merged; evidence: #4 (comment)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    pstack-parity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions