Michael Suchacz 9cfe27063d test(coderd): reduce chat test fixture and timer waits (#29523)
Reduce repeated database/server fixtures and fixed timer waits in chat
tests without changing production code or assertions.

`TestTransitionMatrix_AllCombinations` shares one database and seeded
dependencies across 272 leaves, with a unique chat and recording
publisher per leaf. `TestPostChatFile` shares one authenticated client
across 20 upload leaves. `TestResolveFallbackModelConfigID` shares one
database with independently seeded model configurations. The
requires-action test closes its server after the expected state
persists; the stopped-workspace test advances a trapped Quartz
validation timer; two tool-filtering tests no longer start unused
workspace agents.

| Test | Before | After |
|---|---|---|
| `chatstate/TestTransitionMatrix_AllCombinations` (272 leaves) | 94.06s
| 16.86s |
| `coderd/TestPostChatFile` (20 leaves) | 31.23s | 0.95s |
| `chatd/TestRequiresActionChatPersistsWaitingStatusLabel` | 11.21s |
1.25s |
| `chatd/TestSubagentChatExcludesWorkspaceProvisioningTools` | 7.90s |
2.84s |
| `chatd/TestPlanModeSubagentChatExcludesAskUserQuestion` | 8.25s |
3.00s |
| `chatd/TestStoppedWorkspaceWithPersistedAgentBindingDoesNotBlockChat`
| 6.91s | 1.91s |
| `chatd/TestResolveFallbackModelConfigID` (12 leaves) | 7.58s | 0.34s |

Independent review measurements on September 18, 2026: median summed
leaf time from two runs per side in A/B/B/A order, comparing base
`0ea777a341` with head `e378f9e936`. Every run used
`-tags=testsmallbatch -count=1 -v -p 1 -parallel 8`, PostgreSQL 17, and
the same test selection per package. Other agents shared the host, so
absolute times varied. The speedups reproduced, but not the original
ratios: the matrix improved 5.58x and uploads 32.87x. Summed leaf time
excludes shared parent fixture setup and cleanup; it is not package wall
time. Median package elapsed was 19.26s to 9.76s for the full
`chatstate` package, 4.47s to 1.28s for `coderd` with only
`TestPostChatFile`, and 11.43s to 3.36s for the five targeted `chatd`
tests. Compilation time is excluded.

<details>
<summary>Investigation notes</summary>

- Transition matrix: the shared user, organization, membership,
provider, and model are not mutated by any leaf. Each leaf seeds its own
chat, messages, and queue, and copies the fixture with a new recording
publisher (`transitions_matrix_test.go:617,728,762`).
`ChatMachine.Update` still opens real transactions on the shared
database store; no outer transaction masks rollback assertions
(`chatstate/machine.go:161`, `transitions_helpers_test.go:891`). Parent
cleanup runs after every leaf.
- Requires-action: the old idle hook reached its 10s timeout because the
runner remains active while awaiting dynamic-tool results
(`testhooks.go:14`, `worker.go:114`). The test now waits for the
persisted status and label, closes and drains the server, and retains
the no-web-push assertion (`chatd_test.go:3072`).
- Stale binding: the test injects a new Quartz mock, traps the 5s
validation timer, waits for `MustRelease` to finish timer registration
and for the dial to start, then advances the clock
(`chatd_test.go:4907`). The one-dial, model-call, and
unavailable-workspace tool-result assertions remain intact.
- Tool filtering: both tests create templates but no workspace, and
their mocked model only invokes `spawn_agent` before returning text. The
removed workspace agents could not authenticate and were never used by
the tested flow; their shutdown added about 5s
(`chatd_test.go:229,384`).
- Fallback models: configurations and providers are independently
inserted. Most leaves use unique organizations; the two
default-organization cases insert distinct models, and only one inserts
a default. No leaf mutates another leaf's model or provider
(`chatd_internal_test.go:3512`).

Validation: all changed tests passed with `-count=5` and `-race
-count=2`; the full `chatstate` package passed both checks (2,350 and
940 test executions, including parents). All 272 matrix, 20 upload, and
12 fallback leaves remain present. `gofmt -l`, `git diff --check`, and
`golangci-lint run` on the three changed packages were clean. The full
`coderd` package was not run. No correctness changes were needed during
review. `ARCHITECTURE.md` was read; this test-only PR does not affect
the documented architecture, so no TODO or architecture edit is needed.

</details>

_Investigated, implemented, and validated by Coder Agents on behalf of
@ibetitsmike._
2026-10-07 13:42:42 +02:00
…
…
…
…

Coder Logo Light Coder Logo Dark

Self-Hosted Cloud Development Environments and AI Agents

Coder Banner Light Coder Banner Dark

Quickstart | Docs | Why Coder | Premium

discord release godoc OpenSSF Best Practices OpenSSF Scorecard license Ask DeepWiki

Coder is a self-hosted platform for cloud development environments and AI coding agents. Workspaces are defined with Terraform, connected through a secure Wireguard® tunnel, and automatically shut down when not used. Coder Agents runs a native AI coding agent whose loop executes in the control plane on your infrastructure, with no API keys in workspaces.

  • Define cloud development environments in Terraform
    • EC2 VMs, Kubernetes Pods, Docker Containers, etc.
  • Automatically shutdown idle resources to save on costs
  • Onboard developers in seconds instead of days
  • Delegate coding work to AI agents on your infrastructure
    • Bring any model (Anthropic, OpenAI, Google, Bedrock, self-hosted)
    • No LLM credentials in workspaces, user identity on every action
    • Centralized model governance, cost tracking, and audit logging

Coder platform showing templates and a running workspace

Quickstart

Check out our install guides for other methods and a complete tutorial.

Try Coder with the install script on Linux and macOS, or grab the latest binary or installer from GitHub Releases on Windows:

curl -fsSL https://coder.com/install.sh | sh

Start the server and open http://localhost:3000 to create your initial user, create a Docker template, and provision your first workspace:

coder server

For a production deployment, add a PostgreSQL database (version 13 or later) and an external access URL, and see our validated architectures for sizing and infrastructure guidance:

coder server --postgres-url <url> --access-url <url>

Without these flags, Coder uses a built-in database and sets up a *.try.coder.app access URL for evaluation. Use coder --help for the full list of flags and environment variables.

Documentation

Browse the documentation or visit a specific section below:

  • Workspaces: Workspaces contain the IDEs, dependencies, and configuration information needed for software development
  • Templates: Templates are written in Terraform and describe the infrastructure for workspaces
  • Coder Agents: Delegate coding work to AI agents running on your self-hosted infrastructure
  • AI Gateway: Centralize authentication, auditing, and cost controls for AI tooling
  • Administration: Learn how to operate Coder
  • Premium: Learn about paid features built for large teams
  • IDEs: Connect your existing editor to a workspace

Support

Open an issue for bugs and feature requests.

For community support, showcasing what you built, and feedback on in-progress features, join our Discord or GitHub Discussions.

Dedicated support is included in Coder Premium. For more information, visit coder.com/pricing.

Integrations

New integrations are always in progress. Open an issue to request one. Contributions are welcome in any official or community repository.

Official

Community

Contributing

New contributors are always welcome. If you are new to the Coder codebase, see the contribution guide to get started.

Hiring

Apply on the careers page if you are interested in joining the team.

S
Description
No description provided
Readme AGPL-3.0
1.4 GiB
0 Stars 1 Watchers 0 Forks
Languages
Go 73.6%
TypeScript 24.3%
Shell 0.8%
PLpgSQL 0.3%
Go Template 0.2%
Other 0.5%