Skip to content

test(coderd/x/chatd): prove a busy chat family survives a chatd restart - #279

Merged
ibetitsmike merged 6 commits into
mainfrom
mike/issue-252-family-restart
Nov 13, 2026
Merged

ibetitsmike merged 6 commits into
mainfrom
mike/issue-252-family-restart

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Coder Agents opened this PR on behalf of @ibetitsmike.

Part of #252

What

Adds TestChatFamilySurvivesRestart in coderd/x/chatd/fork_family_restart_test.go. It stops one chatd server under a busy family and starts a new server on the same database.

The family at the moment of the stop:

  • The root has spawned a coordinator and is parked on a wait_for_events watch of it.
  • The coordinator is blocked in a parallel batch of three wait_agent calls, one per worker. The test checks that each call runs: a pubsub wrapper on the first server counts the state subscription that each wait takes on its worker.
  • Two workers are in a model call. The third waits for capacity (per-family limit 2).
  • Each running worker has sent message_family_chat to the busy coordinator after the coordinator committed its wait batch, so exactly two messages are queued and none is in its history yet.
  • The cut batch is replayed by the new server with the same tool-call IDs.

After the restart the test checks:

  • every chat finishes without an error and holds no queued message,
  • the root gets one wake-up and one wait_agent result from the coordinator,
  • the coordinator gets each worker result once and each family message once,
  • no chat is spawned twice (3 workers, no grandchildren of workers).

Experiments: fork-nested-subagents, fork-family-messages, fork-chat-wakeups. The test uses the fake OpenAI model and the existing chatd test helpers. It runs in the fork-ci chat-tests job (./coderd/x/..., name matches (?i)chat).

Cases found that duplicate work (follow-up PRs)

These are not in this test because they fail today. Each gets its own fix PR with a test that fails without the fix.

  • A spawn_agent call in a batch that the restart cuts runs again on replay and spawns a second child.
  • A message_agent call in a batch that the restart cuts runs again on replay and delivers the message twice.

Tests

  • flock ~/.fork-go.lock go test ./coderd/x/chatd -run 'TestChatFamilySurvivesRestart$' -count=3: ok (47s).
  • Same with -race -count=3: ok (49s).
  • A logged run showed the subscription counts before the stop: 1 on the capacity waiter (its wait), 2 on each running worker (its runner and its wait).
  • golangci-lint run ./coderd/x/chatd/...: no finding in the new file.

Not covered

  • A crash without a graceful close. The new server then waits InFlightChatStaleAfter before it takes the chats.
  • A spawn cut after the child row is created but before its post-create steps.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@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-13T22:53:24.702653Z 4e9afdb 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.

@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: 93fe63fca9

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

Copy link
Copy Markdown
Owner Author

Coder Agents acted 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: dd0bb101ef

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

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged main (#278) into the branch. @codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: a1738e13f0

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

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Added a per-worker result count in 8ef754e. @codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: 8ef754ec96

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

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged main (#281) into the branch. @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: 9178fab5de

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

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 4e9afdb894

ℹ️ 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 607a95b into main Nov 13, 2026
10 checks passed
@ibetitsmike
ibetitsmike deleted the mike/issue-252-family-restart branch November 13, 2026 23:25
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Coder Agents acted on behalf of @ibetitsmike.

Merged as 607a95b (squash, --match-head-commit 4e9afdb894).

Gates on head 4e9afdb:

  1. Head SHA matched the verified SHA at merge time. Main was db48523 and the server ran it.
  2. Every check run on the head passed. fork-ci run 43522337062 on this head passed.
  3. Codex receipt on this head: test(coderd/x/chatd): prove a busy chat family survives a chatd restart #279 (comment)
  4. Unresolved review threads: 0.
  5. Behind main: 0.
  6. Test evidence run by the maintainer on the exact head: go test -count=1 -v -run TestChatFamilySurvivesRestart ./coderd/x/chatd/ passed (15.8 s).

Not exercised: this PR adds a test only. No runtime code changed.

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