Skip to content

test(coderd/x/chatd): fold taskTestFixture into workerTestFixture - #30924

Draft
ibetitsmike wants to merge 2 commits into
mike/chatd-shared-recording-pubsubfrom
mike/chatd-task-test-fixture
Draft

ibetitsmike wants to merge 2 commits into
mike/chatd-shared-recording-pubsubfrom
mike/chatd-task-test-fixture

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

taskTestFixture in tasks_test.go repeated workerTestFixture field for field, with the same seed rows, and carried its own copies of five chat setup helpers, publishChatUpdate and two message builders. This PR deletes the fixture and the copies and moves the 39 task, hook and turn-trace tests that built it onto workerTestFixture and the shared helpers. It also drops the fixture's API key row and the apiKeyID parameter of userTextMessage, which nothing read.

Why it is safe

The copies differed from the shared helpers in two ways, and both are kept:

  • Clearing the recorder. The copies cleared the recording pubsub after setup, and interruptChat cleared it before interrupting, so assertions on published events see only what the code under test published. workerTestFixture.pubsub is now that recorder (from the layer below), and the shared helpers clear it at the same points. No worker test reads the fixture recorder's events, so the extra clears do not change them.
  • The deadline argument. The task copy of forceExecutionState took an explicit requires-action deadline. forceExecutionStateWithDeadline takes it as a pointer (nil keeps the current one) for setRequiresActionDeadline and the one call that cleared an expired deadline. The other three callers passed an empty deadline for chats that never had one, so they call forceExecutionState.

The rest of the move keeps the old behavior:

  • startRealTaskWorker now starts from testOptions, which holds the same values. It unsets the recording task starter so the worker builds its real one, as before.
  • No chatd code reads the fixture's API key. The synthetic gateway key is looked up by its own token name.

After the change, rg 'taskTestFixture|taskUserTextMessage|taskAssistantToolCallMessage|f\.apiKey' coderd/ enterprise/ finds nothing.

Review focus

The clear() placement in helpers_test.go. Setup helpers clear when they finish, and interruptChat clears before it runs.

Validation

Same commands as the layer below: the 142 top-level tests in the ten files listed there, run from go test -c ./coderd/x/chatd/ binaries (plain and -race) with -test.count=1 -test.parallel 4.

Head Plain -race
main (e289c6fe011) 142 passed 142 passed, no data races
this PR 142 passed 142 passed, no data races

The pre-commit hook passed.

Stack

The stack folds the task test fixture into the shared worker test fixture.

  1. test(coderd/x/chatd): reuse recordingPubsub in the task test fixture #30923 reuse recordingPubsub in the task test fixture
  2. test(coderd/x/chatd): fold taskTestFixture into workerTestFixture #30924 fold taskTestFixture into workerTestFixture (this PR)

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

taskTestFixture repeated workerTestFixture with the same seed rows, plus copies of the chat setup helpers, publishChatUpdate and two message builders. The task, hook and turn-trace tests now use workerTestFixture, whose helpers clear the recording pubsub at the same points the copies did. forceExecutionStateWithDeadline carries the explicit deadline the task copy took. The fixture's API key and the apiKeyID parameter of userTextMessage are dropped: nothing read them.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-18T17:26:10.682046Z 38b7be0 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

Copy link
Copy Markdown

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

Reviewed commit: d8708e9c7e

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

@codex review

Xum, an AI agent, posted this comment for @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 38b7be0978

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

This branch has not been deployed

No deployments
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