Skip to content

docs(coderd/x/chatd): describe fork features in ARCHITECTURE.md - #272

Merged
ibetitsmike merged 5 commits into
mainfrom
mike/chatd-architecture-fork-docs
Nov 13, 2026
Merged

ibetitsmike merged 5 commits into
mainfrom
mike/chatd-architecture-fork-docs

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Summary

Replaces every fork TODO in coderd/x/chatd/ARCHITECTURE.md with prose describing what the fork code actually does today: 53 TODO(ibetitsmike) and TODO(fork-chat-todos) comments gone, each replaced in place with concise prose matched to the surrounding section. No upstream line is reworded or reflowed; the five upstream TODOs (TODO(f0ssel), TODO (#29808)) and all upstream prose are untouched. Docs only; no code changes.

Coverage: fork data classification (chat todos, descendant questions, secret answers, pinned skills, wake-ups, excluded plugin packs, organization wake-up caps, PR/process/output polling), the steer lane for async ask_user_question answers, nested subagents (depth tracking, organization limits, concurrency and live caps, queued_for_capacity), agent definitions (custom types, tiers, tool policy, root resolution, depth 0 rows), subagent isolation (worktree, binding, wait report, workspace, definition default), workflows (step chats, runs, journal resume), family archive (lock order, isolation cleanup, wake-up cancellation), the /loop command, the interrupt cascade, the wake-up delivery loop and controls, acquisition candidate order, fork chat routes, and the fork tools.

Premises that no longer matched the code

These TODOs described a state the code had moved past; the prose describes what the code does now:

  • Line 171 said "the durable journal is later work". It is implemented: fork_workflow_journal.go writes workflow_runs and workflow_steps (chatdmig 01a1d041), a startup sweep marks open runs of a dead process interrupted, and resume replays the journaled script and steps. The prose drops the "later work" clause. The same TODO's "the first awaiter consumes the result" is reworded to what the code does: every awaiter gets the result snapshot; the queued end notice is only sent when no awaiter was waiting, and the next await_workflow deletes it.
  • Line 631's "(issue 79)" reference exists nowhere in the repository; the prose keeps the deadlock rationale (root FOR NO KEY UPDATE does not conflict with the FOR KEY SHARE foreign-key checks) and drops the reference.
  • Line 157 implied queued_for_capacity is stored state. It is derived on read (forkChatQueuedForCapacity); the prose reflects that.
  • Line 159 named two stored tiers. The code offers four (pinned workspace plus personal, organization, and project); the prose reflects that, including that only the personal and organization reads run as the owner.

Evidence

One row per replaced TODO, verified against the current code. Line numbers refer to the TODO's position on origin/main before this PR.

Main line Replaced TODO Evidence (file:line)
50 chat todos classification coderd/x/chatd/fork_chat_todos.go:51-85,130-160; coderd/database/forkdb/queries/chat_todos.sql:5-8
51 descendant questions classification coderd/x/chatd/fork_descendant_questions.go:227-263; coderd/database/forkdb/queries/chat_descendant_questions.sql:10-45
52 secret answers classification, TTL, dbpurge coderd/fork_chat_questions.go:188-193,354-379; coderd/x/chatd/fork_secret_answers.go:40-97; coderd/database/forkdb/queries/chat_secret_answers.sql:6-11,16-26; coderd/database/dbpurge/fork_dbpurge.go:16-36
53 pinned skills classification coderd/fork_chat_pinned_skills.go:54-125; coderd/x/chatd/fork_pinned_skills.go:56-96
54 wake-ups classification and delivery coderd/x/chatd/fork_wakeups.go:129-166,246-308; coderd/database/forkdb/queries/chat_wakeups.sql:98-126
55 excluded plugin packs coderd/x/chatd/fork_plugin_gate.go:282-335; coderd/database/migrations/chatdmig/nodes/01a1cf83-*chat_excluded_plugin_packs*
56 organization wake-up caps coderd/x/chatd/fork_wakeup_caps.go:26-91; coderd/database/forkdb/queries/chat_organization_wakeup_caps.sql
57 PR polling coderd/x/chatd/fork_pull_request_events.go:29-42,134-167,225-252; coderd/x/chatd/fork_wait_for_events.go:425-439,566-575
58 process polling coderd/x/chatd/fork_process_events.go:170-174,194-199,295-337,490-534,298-307
59 process_output_pattern coderd/x/chatd/fork_process_events.go:30-34,347-377,371-373,419-464; coderd/x/chatd/fork_wait_for_events.go:453-491,558-564
147 steer lane for async answers site/src/pages/AgentsPage/components/ForkDescendantQuestionDock.tsx:73-75; site/src/api/queries/forkChatQuestions.ts:66-68; coderd/exp_chats.go:3310-3313; coderd/x/chatd/generation.go:1486-1524
153 spawn depth tracking coderd/x/chatd/fork_subagents.go:355,366,389-400
154 organization subagent limits coderd/database/migrations/chatdmig/nodes/01a1bfc4-*chat_organization_subagent_limits*; coderd/x/chatd/fork_limits.go:49-72; codersdk/fork_chat_config.go:42-92
155 concurrency caps, ancestor exclusion coderd/x/chatd/fork_capacity.go:75-140; coderd/database/forkdb/queries/chat_capacity.sql:1-28
156 live cap, advisory lock coderd/x/chatd/fork_subagents.go:161-252,373-388,254-259; coderd/database/queries/lock.sql:1-6
157 queued_for_capacity reporting coderd/x/chatd/fork_capacity.go:150-192; coderd/x/chatd/chatd.go:1599-1616; coderd/x/chatd/fork_list_agents.go:29
158 custom agent types from pins coderd/x/chatd/fork_agent_definitions.go:41-63,114-196; coderd/x/chatd/fork_subagents.go:393-400
159 stored agent definition tiers coderd/x/chatd/fork_agent_definitions.go:207-311; coderd/x/skills/skills.go:161-230
160 stored type in tool results coderd/x/chatd/fork_subagent_types.go:25-49,86-154
161 tool policy storage and filtering coderd/x/chatd/fork_agent_tool_policy.go:32-45,189-258; coderd/database/forkdb/queries/chat_subagents.sql:4-8
162 ResolveRootAgent tiers, workspace refusal coderd/x/chatd/fork_root_agent.go:23-26,84-114
163 depth 0 row for roots coderd/x/chatd/fork_root_agent.go:155-231; coderd/database/forkdb/queries/chat_subagents.sql:10-14
164 root tool policy, guidance drops coderd/x/chatd/fork_agent_tool_policy.go:123-129,151-162; coderd/x/chatd/fork_root_agent.go:131,175-182; coderd/x/chatd/turn_environment.go:750-769
165 worktree spawn coderd/x/chatd/fork_isolation.go:182-255,273-298; coderd/x/chatd/fork_subagents.go:335-343,389-403
166 worktree binding coderd/x/chatd/fork_isolation_binding.go:39-131,147-152,184-223
167 isolation wait report coderd/x/chatd/fork_isolation_report.go:28,86-154
168 workspace isolation coderd/x/chatd/fork_isolation_workspace.go:47-163,177-227
169 definition isolation default coderd/x/chatd/fork_isolation.go:59-76,117-121; codersdk/workspacesdk/fork_agentdefinition.go:85,191-195
170 workflow step chats coderd/x/chatd/fork_workflow_step.go:35-61,74-78,101-110,145-154,187-201
171 workflow runs, journal resume coderd/x/chatd/fork_workflow.go:426-448,528-650,820-842; coderd/x/chatd/fork_workflow_journal.go:124-362
598 fork chat routes coderd/fork_chat_routes.go:17-28,33-93,161-167
631 family archive lock order coderd/x/chatd/fork_family_lock.go:28-117; coderd/database/forkdb/queries/chat_family_lock.sql:1-5; coderd/database/forkdb/queries/chat_subtree.sql:1-19
632 archive worktree cleanup coderd/x/chatd/fork_isolation_cleanup.go:48-133,180-225; coderd/x/chatd/chatstate/fork_notice.go:12-21
633 archive workspace stops coderd/x/chatd/fork_isolation_cleanup.go:124-140; coderd/x/chatd/fork_isolation_workspace.go:207-227; coderd/x/chatd/chattool/stopworkspace.go:37-141
635 archive cancels wake-ups coderd/x/chatd/fork_family_lock.go:68-91; coderd/x/chatd/fork_wakeups.go:32,392-406; coderd/database/forkdb/queries/chat_wakeups.sql:80-90
668 /loop command coderd/x/chatd/fork_loop_command.go:55-146; coderd/x/chatd/fork_schedule_wakeup.go:26-33,162-179,204-273; coderd/fork_chat_loop_errors.go:17-26
817 interrupt cascade, active family archive coderd/x/chatd/fork_cascade.go:32-142; coderd/x/chatd/chat_mutations.go:540-552,902-920
901 wake-up delivery loop coderd/x/chatd/fork_wakeups.go:27-58,129-176,222-308; coderd/x/chatd/fork_wakeup_caps.go:117-166; coderd/database/forkdb/queries/chat_wakeups.sql:98-126
902 wake-up owner controls coderd/x/chatd/fork_wakeup_controls.go:40-114; coderd/fork_chat_wakeups.go:121-150; coderd/database/forkdb/queries/chat_wakeups.sql:51-78,131-143
924 acquisition candidate order coderd/database/queries/chats.sql:2559-2672; coderd/x/chatd/worker.go:169-215
1228 plugin pack MCP servers coderd/x/chatd/chatd.go:379-388; coderd/x/chatd/fork_plugin_gate.go:39-84,201-226; agent/agentcontext/fork_pack_mcp.go:257-274
1232 search_chats, include_tool_calls coderd/x/chatd/fork_search_chats.go:22-58; coderd/x/chatd/fork_wait_agent.go:37-39,59-113
1233 appendForkTools additions coderd/x/chatd/fork_tools.go:37-90; tool names in fork_schedule_wakeup.go:26, fork_wait_for_events.go:29, fork_notify_user.go:24
1234 workflow_report tool handling coderd/x/chatd/fork_workflow_report.go:584-659; coderd/x/chatd/stream_loop.go:272-276; coderd/x/chatd/tasks.go:717-726
1235 nested subagent tools coderd/x/chatd/fork_subagents.go:425-501
1236 descendant ask_user_question coderd/x/chatd/fork_descendant_questions.go:44-92,235-265,290-372; coderd/x/chatd/fork_tools.go:65-80
1237 secret answer wrapping coderd/x/chatd/fork_secret_answers.go:31-97,110-187
1238 todo tools, snapshot coderd/x/chatd/fork_chat_todos.go:26-85,132-164; coderd/x/chatd/fork_chat_transcript.go:64-120; coderd/x/chatd/fork_list_agents.go:26-80; coderd/x/chatd/fork_context.go:41-161
1239 plugin pack gating coderd/x/chatd/fork_plugin_gate.go:51-106,276-335; coderd/x/chatd/fork_plugin_drift.go:35-72
1240 plugin pack materialization coderd/x/chatd/fork_pack_materializer.go:40-51,104-183,185-232; coderd/x/chatd/turn_environment.go:465-466
1241 glob-scoped Cursor rules agent/agentcontext/fork_rules.go:238-254; coderd/x/chatd/context_prompt.go:262-300; coderd/x/chatd/fork_scoped_rules.go:32-125; coderd/x/chatd/turn_environment.go:470
1242 plugin pack cleanup coderd/x/chatd/fork_pack_cleanup.go:45-152; agent/agentcontext/fork_pack_mcp.go:207-210
1243 pinned skills coderd/x/chatd/fork_pinned_skills.go:36-96,147-161; coderd/x/chatd/fork_context.go:58-66; coderd/fork_chat_routes.go:130-135

Replace the 53 fork TODO comments in chatd ARCHITECTURE.md with prose
verified against the fork code: fork data classification, nested
subagents (depth, caps, agent definitions, isolation), workflows,
wake-ups (loop, caps, polling, controls), the /loop command, the
interrupt cascade and family archive cleanup, fork chat routes, and
the fork tools. Upstream TODOs and prose are untouched.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 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-13T11:54:54.359469Z a6b2a70 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.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum commented on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81bca11f1d

ℹ️ 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".

Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum commented on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9b15e3a85

ℹ️ 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".

Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Nine accuracy corrections against the code: events polls read process
entries until one produces a message; live-cap admission also covers
wake-up resumes; the worktree diff summary is skipped for timed-out
waits; the acquisition fallback orders status then age; /loop requires
a single text part; the family archive settle deadline is family-wide;
the workflow startup sweep has no ownership tracking; an idle parent
receives the workflow end notice directly; and the plugin pack restart
sweep runs only when a pass has packs to write or stale packs.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum commented on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b826e3cd1d

ℹ️ 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".

Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Comment thread coderd/x/chatd/ARCHITECTURE.md Resolved
Five accuracy corrections: awaiters that time out get a snapshot as of
their timeout, not the final result; a due events wake-up with nothing
ready just reschedules; the process output cursor advances only when a
matching batch is delivered; re-setting a finished wake-up's status is
a no-op and only a status change answers 409; and the fork also adds an
async root ask_user_question.
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum commented on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 02e8811cd8

ℹ️ 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".

…cture-fork-docs

# Conflicts:
#	coderd/x/chatd/ARCHITECTURE.md
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum commented on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: a6b2a70fd3

ℹ️ 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
ibetitsmike merged commit 0449955 into main Nov 13, 2026
9 checks passed
@ibetitsmike
ibetitsmike deleted the mike/chatd-architecture-fork-docs branch November 13, 2026 12:05
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Merged as 044995538c with a squash. Mike decided on 2026-11-13 that agents write and merge the ARCHITECTURE.md text, which overrides the AGENTS.md rule for this file. These checks passed on head a6b2a70fd3:

  • fork-ci run 43420342095 green
  • Codex: no major issues on a6b2a70fd3 (two earlier rounds of factual corrections landed in b826e3cd1d and 02e8811cd8)
  • 14 of 14 review threads answered and resolved
  • branch up to date with main

No TODO(ibetitsmike) or TODO(fork-chat-todos) remains in coderd/x/chatd/ARCHITECTURE.md. The 5 upstream TODOs are untouched. The PR body maps each passage to the code it was checked against.

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.

1 participant