mirror of
https://github.com/coder/coder.git
synced 2026-11-23 04:01:58 +08:00
63e08e231eb4e073aee593e31921983d620fd5a4
789
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
16aa6fca84 |
chore: bump various dependencies (#31841)
Bumps pinned transitive dependency overrides across the pnpm workspaces. | Package | Scope | From | To | |---|---|---|---| | dompurify | `site` | 3.4.14 | 3.4.17 | | qs | `site` | 6.16.0 | 6.16.1 | | brace-expansion (1.x) | root, `site`, `offlinedocs` | 1.1.18 | 1.1.21 | | minimatch (>=10) | `site` | 10.2.6 | 11.0.1 | | markdown-it | root, `scripts/apidocgen` | 14.1.0 / 12.3.2 | 14.3.3 | minimatch 11 is applied only to the `>=10` range (used by `glob@13`). Older ranges are left on their current pins because minimatch 9+ changed its export shape and would break 3.x/5.x consumers. Some lockfiles also gain `(supports-color@x)` peer suffixes. This is pnpm 12 re-resolving optional peers on override changes; the committed `offlinedocs` lockfile predates that behavior. No new packages are added by it. <details> <summary>Verification</summary> - `site`: `pnpm lint`, `pnpm test` (all unit tests pass), `pnpm build`, `pnpm storybook:build` - `site`: `Response.stories.tsx` Storybook browser tests pass, including the Mermaid stories that go through DOMPurify - `offlinedocs`: `pnpm lint`, `pnpm build` - root: `pnpm run check-docs` (markdownlint on markdown-it 14.3.3) - `scripts/apidocgen`: widdershins output on `coderd/apidoc/swagger.json` is byte-identical between markdown-it 12.3.2 and 14.3.3 - `./scripts/develop.sh` smoke test: login and main pages load without JS errors; DOMPurify 3.4.17 sanitizes as expected in the browser </details> --- _This PR was generated by Coder Agents on behalf of @Lisa-Fiander._ |
||
|
|
bf47fc68d9 |
feat: add a --bind-address flag to scripts/develop (#31815)
`scripts/develop.sh` always binds the API server, its metrics listener, the Vite dev server and the Prometheus UI container to `0.0.0.0`. On a shared or reachable host, anyone on the network can then reach a dev instance whose admin uses the published default password, or race the first-user setup on a new database. This adds `--bind-address` (`CODER_DEV_BIND_ADDRESS`), which takes `0.0.0.0` (the default, unchanged behavior) or `127.0.0.1`. With `127.0.0.1`, all four listeners stay on loopback and the banner lists only `localhost`. Other addresses are refused, because develop's health check, the Vite proxy and the Prometheus scrape target reach the API on `127.0.0.1`. A running `coder-prometheus` container is reused only when it listens on the same address. Otherwise develop logs a warning and runs without the Prometheus UI, because that container usually belongs to another live run. Workspaces in Docker containers, such as the `docker` starter template's, cannot reach a loopback-bound server, because their agents connect through `host.docker.internal`. The flag description and `.claude/docs/DEV_ISOLATION.md` say so. The `verify-coder` skill in #31782 needs this. A review of that PR found the exposure, and this PR is its prerequisite. Verification: `go test ./scripts/develop/` passes, with tests for the flag and env binding, validation, every listen address, the Vite `--host` argument (bare by default), the banner and the Prometheus reuse check. Reverting each of those turns a test red. A live `--bind-address 127.0.0.1` run listened on `127.0.0.1` only and refused connections on the host's network IPs. golangci-lint (full and new-code) is clean. I did not run the repo git hooks locally. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_ |
||
|
|
c95b908705 |
ci: make docs redirects relative and block removed routes (#30805)
## Summary
Moves `docs/redirects.json` to relative routes and makes
`lint/docs-redirects` fail when a PR removes a live docs route without a
redirect.
coder.com and docs-engine build each version's redirects from that
branch's file, so this file becomes the only place contributors add docs
redirects.
Part of DOCS-1290; tracked in DOCS-1296.
## Changes
- New rule format: `{"source": "path/to/page", "destination":
"path/to/another-page"}`, relative to the docs root of the branch's
version.
Trailing `/*` is the only wildcard, `/` is the version's docs root, one
`#fragment` is allowed on exact destinations, and external destinations
are limited to `https://github.com/coder/` and `https://coder.com/`.
The old `/docs/...` form is rejected with the converted rule in the
message.
- Removed-route check now blocks.
Every route in the base manifest, the live page list for the target
branch (`coder.com/beta-docs/<version>/llms.txt`), and the base file's
sources must be a page or resolve through a rule.
The failure names the old file and prints a paste-ready rule, suggesting
a renamed sibling, a page with the same last segment, or `/`.
An unreadable live list exits 2 in CI; `-offline` skips it locally.
Links under `/docs` count as well, so the check keeps working if the
list URL redirects there after the move to `/docs`.
- `docs/redirects.json` on `main`: 304 rules.
It carries the coder.com docs rules that 404 under `/docs/@main` today,
plus the 144 `@main`-only rules coder.com holds, with three sibling sets
condensed into wildcards (`networking/*`, `admin/notifications/*`,
`guides/*`).
- README, content guidelines, and agent guidance describe the new
format.
## Testing
- `go test ./scripts/docsredirectscheck/...` (also `-race`),
`golangci-lint`, and the pre-commit hook.
- `go run ./scripts/docsredirectscheck -base origin/main -branch main`
online, after merging current `main`: 304 rules OK, 497 routes resolve.
- Renaming `admin/integrations/istio.md` without a rule fails with
`{"source": "admin/integrations/istio", "destination":
"admin/integrations/istio-mesh"}`; adding that rule passes.
- coder.com's `generateRedirects` with this file and `main`'s manifest:
0 dropped; 336 of 336 sampled old URLs resolve to the expected page with
Next's matcher.
- `curl` on every destination under `coder.com/docs/@main`: all 200.
- Live baseline before merge: 185 of 336 sampled `/docs/@main` URLs
return 404.
- The check runs on Linux in `ci.yaml`'s `lint` job; the package's unit
tests also run on macOS and Windows in `test-go-pg`.
## Merge order
Merge after the coder.com generator (coder/coder.com,
`vigilante/docs-redirects-relative`) is deployed, otherwise coder.com
drops these rules with warnings until it is.
The docs-engine change (coder/docs-engine,
`vigilante/version-redirects`) can land before or after.
Then merge the `release/2.38` backport.
<details>
<summary>Contract shared by coder/coder, coder.com, and
docs-engine</summary>
# Docs redirects contract (coder/coder owns the data; coder.com and
docs-engine consume it)
## Ownership
- Every redirect for a moved, renamed, or removed docs page lives in
`coder/coder` `docs/redirects.json`, one file per branch (`main`,
`release/X.Y`).
- A branch's file applies only to that branch's version of the docs.
`main`'s file applies to `@main`; `release/X.Y`'s file applies to vX.Y,
and to unversioned `/docs` while X.Y is mainline.
- URL-scheme rules (`/docs/v1`, `/docs/v2/...`, `/docs/coder-oss/...`,
`/docs/coder/...`, `/docs/code-server/...`, classic `/@v<line>` forms)
are not content moves. They stay in the consumer that owns the URL
scheme, as code or a static engine-owned file.
- Nobody adds content redirects in coder.com or docs-engine. Existing
ones there are removed only after the matching coder/coder rules are
verified live for that version (later phase, not this change).
## File format
`docs/redirects.json` is a JSON array. Each entry is an object with
exactly these fields:
| Field | Required | Meaning |
|---------------|----------|-------------------------------------------------------------------------|
| `source` | yes | A route relative to the docs root of this version |
| `destination` | yes | A route relative to the docs root, `/` for the
docs root, or an allowed `https://` URL |
| `permanent` | no | Boolean, default `true`. `true` answers 308,
`false` answers 307 |
Unknown fields are an error.
### Routes
- A route is the URL path below `/docs` with no version, no leading
slash, no trailing slash, and no `.md`:
`admin/templates/extending-templates`.
- A route is one or more segments joined by `/`. Each segment matches
`[A-Za-z0-9._-]+`. Nothing else is allowed (no `@`, `%`, `:`, `(`, `?`,
`#`, spaces, empty segments, `.` or `..` segments).
- Routes are derived from `docs/manifest.json` the way the sites do
today: strip a leading `./`, then strip `README.md`, `index.md`, `.md`
in that order as plain text, trim slashes. The empty result is the docs
root.
### Wildcards
- A `source` may end in `/*`: `ai-coder/ai-bridge/*`. It matches the
prefix itself and every route beneath it.
- A `destination` may end in `/*` only when the source does. The part
the source's `*` matched (possibly empty) replaces the destination's
`*`; an empty match means the destination prefix itself
(`ai-coder/ai-gateway/*` with an empty match is `ai-coder/ai-gateway`).
- A wildcard source with a non-wildcard destination sends everything
under the prefix to that one page.
- No other pattern syntax exists. Consumers translate `*` into their own
matcher. For Next.js that is `:path([A-Za-z0-9._-]+)*`, never `(.*)`,
`.+`, or a bare `:name*`.
### Destinations
- `/` is the docs root of the same version (`/docs`, `/docs/@main`,
`/beta-docs/v2.37`, and so on). Pages with no suitable home redirect to
`/`.
- An internal destination always stays in the same version as the
request.
- A non-wildcard internal destination may end in one `#fragment`, where
the fragment matches `[A-Za-z0-9._-]+`:
`user-guides/workspace-access#web-ides`. The route part must still be a
live route. A wildcard destination and `/` never carry a fragment.
- An external destination is an `https://` URL whose host and path start
with an allowed prefix: `https://github.com/coder/` or
`https://coder.com/`. It contains no `:` after the scheme and no
parameter. A `*` is not allowed in an external destination.
### Order and precedence
- Rules apply in file order; the first match wins.
- A page always wins over a redirect: a rule only fires for a request
that is not a live page of that version. The checker rejects any rule
whose source matches a live route, so consumers that check redirects
before pages (Next.js static redirects) behave the same as those that
check on a miss.
- Matching ignores one trailing slash on the request.
- Consumers follow at most 3 chained hops and refuse loops. The checker
rejects chains so a valid file never needs this.
### Legacy entries
- During migration, consumers also accept a `source` or `destination`
that starts with `/docs/` (or equals `/docs`) and treat it as the route
after `/docs/` (or `/` for `/docs`). A legacy `:name*` or `:name(.*)`
trailing parameter is treated as `/*`. The coder/coder checker accepts
only the new form.
- A missing file and an empty array both mean no rules. A file that is
not a JSON array is an error.
## CI check (coder/coder `scripts/docsredirectscheck`)
Structural checks as today, adapted to the new form, plus a blocking
removed-route check:
1. **Inventory.** The set of routes that must keep working is the union
of:
- the base branch's `docs/manifest.json` routes,
- every route in the live production page list for the PR's target
branch, read from `https://coder.com/beta-docs/<segment>/llms.txt` where
the segment is `@main` for `main` and `vX.Y` for `release/X.Y`, keeping
only links under that segment,
- every `source` in the base branch's `docs/redirects.json` (exact
sources as-is; wildcard sources contribute the prefix).
2. **Resolution.** Each inventory route must be a live route in the head
manifest, or be resolved by the head rules (with wildcard substitution)
to a live head route, `/`, or an allowed external URL.
3. **Failure message.** Name the route, the file it came from on the
base branch when known, and a ready-to-paste rule, for example
`{"source": "path/to/page", "destination": "path/to/another-page"}`,
pointing at `/` when no candidate is obvious.
4. **Live list failures.** A network error, non-200, or a list with no
routes is an infrastructure failure (exit 2) in CI, not a pass. Locally,
`-offline` skips the live list and says so.
5. **Known engine difference.** beta-docs currently serves dotted
segments with hyphens (`esr-2.24-2.29-upgrade` is served as
`esr-2-24-2-29-upgrade`). Until docs-engine fixes it, a live route that
equals a head route with `.` replaced by `-` in each segment counts as
present.
## Consumers
- **coder.com classic** (`scripts/generate-docs-redirects.ts`): reads
`main` (scoped to `/docs/@main/...`) and the mainline release branch
(unversioned `/docs/...`) as today, in the new format, and emits Next.js
redirects. Version coverage beyond those two is out of scope.
- **docs-engine beta**: each version's publish reads
`docs/redirects.json` from the commit it builds, validates it, and
stores the compiled rules with that version's archive. The router
applies a version's own rules on a miss inside that version. Versions
published before this change keep today's behavior.
</details>
---
🤖 Built with AI assistance.
|
||
|
|
e7706406f4 | feat: render nerd font icons in the web terminal (#30527) | ||
|
|
fb36a3d877 |
chore: bump mise to 2026.10.25 (#31640)
Bump mise from 2026.5.12 in every place scripts/check_mise_versions.sh checks. mise.lock is regenerated because 2026.10.19 records vercel's registry default options, and `mise install --locked` fails on the old lockfile without them. 2026.7.12 removed `mise oci push --tool`, so the dogfood workflow drops `--tool crane` and the mise-oci-wrapper no longer installs crane. min_version is a hard requirement: in this repo, an older mise fails for `mise exec`, every shim and `mise activate` until `mise self-update` or a restart on the new dogfood image, so the git hooks block commits. Branches not rebased onto this change get mise.lock rewritten whenever mise 2026.10.25 installs something there. |
||
|
|
63b5c4d64a | fix: drop the /docs/about live-route assertion from TestRepositoryManifest | ||
|
|
2cab0e8c37 |
ci: remove PR deployments (#31757)
PR deployments have been dead since February, but `pr-cleanup.yaml` still runs on every closed PR with the deployment secrets in scope. |
||
|
|
b5c1b02f55 | chore: upgrade to pnpm 12 (#31589) | ||
|
|
11aaca1d85 |
fix: bump bundled terraform to 1.17.1 (#31438)
Bumps the bundled Terraform from 1.16.7 to [1.17.1](https://github.com/hashicorp/terraform/releases/tag/v1.17.1) (released 2026-10-28). 1.17.1 is built with `go-jose/v4` v4.1.6, which fixes [GHSA-mgcc-cww5-fp2q](https://github.com/go-jose/go-jose/security/advisories/GHSA-mgcc-cww5-fp2q) (CPU DoS through crafted RSA JWKs). Terraform 1.16.7, 1.17.0 and the current `v1.16` branch all still pin go-jose v4.1.4, so there's no 1.16.x release with the fix to move to yet. The IronBank VAT scan of `coder-service-2:2.38.3` flags `/opt/terraform/terraform` (High) for this. The 2.38 backport is #31441. This is a minor bump, so `maxTerraformVersion` moves from 1.16.9 to 1.17.9. Same file set as #31301: - `provisioner/terraform/install.go`: `TerraformVersion` and `maxTerraformVersion` - `install.sh`, `scripts/Dockerfile.base`, `docs/install/prepare/airgap.md` - `mise.toml`, `mise.lock`, `flake.nix`: checksums from `terraform_1.17.1_SHA256SUMS`, GPG-verified against HashiCorp's signing key (C874 011F 0AB4 0511 0D02 1055 3436 5D94 72D7 468F). The flake SRI hashes come from the same file. - `provisioner/terraform/testdata/generation.sha1`: regenerated with `generate.sh` under Terraform 1.17.1. No fixture outputs changed. Verified: `go test ./provisioner/terraform/` passes with Terraform 1.17.1 on `PATH`. Local git hooks were skipped; CI is the gate. Part of [ENT-228](https://linear.app/codercom/issue/ENT-228) (parent [ENT-230](https://linear.app/codercom/issue/ENT-230)). 2.38 backport: #31441. Opened by Superblink on behalf of @droopy4096. Co-authored-by: coder[bot] <137810501+coder[bot]@users.noreply.github.com> |
||
|
|
c0f7663e95 |
feat: support editing queued chat messages (#29215)
The owner of a chat can edit a queued message through
`PATCH /api/v2/chats/{chat}/queue/{queuedMessage}`. chatd never sends
a row under edit (`editing_since`): rows ahead of it still send in
order, and a turn that ends at it puts the chat in the new `paused`
status. Ending the head's edit, deleting it, or promoting a queued row
continues the chat. Interrupting sends still run ahead of the queue.
The chat state machine classifies a queue whose head is under edit as
its own sub-state (R1P, I1P, A1P, E1P, XE1P, P), so every path to
`paused` is in the transition matrix. A chat whose family has a paused
member cannot be archived, and auto-archive skips that family. Queue
edit and delete are owner-only, because both can send the next message
with the owner's credentials.
`ChatQueuedMessage` gains `editing_since` and `reasoning_effort`, and
`ChatStatus` gains `paused`.
Closes CODAGT-1028
Refs CODAGT-971
|
||
|
|
1acacc9c30 | feat: graduate MCP tool search from experiments (#31327) | ||
|
|
2255794d65 | feat: add response_size_bytes metric to chatd (#29816) | ||
|
|
dbd7db6877 | feat: add Harbor-based A/B eval for Coder Agents against main (#30686) | ||
|
|
28192213ab |
feat!: label the VS Code family and report built-in app usage per app (#29906)
The session banner now labels the VS Code family "VS Code Family", so it isn't confused with the VS Code editor. coderd_insights_applications_usage_seconds now reports built-in apps per app instead of per family. - Generate the frontend's family labels from the Go table in codersdk. - Add the connection_method label: workspace_app for template apps, and ssh, reconnecting_pty, or port_forwarding for built-in apps. - Rename the application_name label to display_name. For built-in apps it holds the registry name, "Unknown" for unknown, and "Other apps" for overflow. - Built-in apps get one series per app name, only for apps used in the window. The series limit and the fold rule are shared with the template insights API. - Breaking: selectors with a value for application_name, or with slug="", match nothing. The Prometheus docs map each old series to its new one. Closes #29940 Closes CLIENT-1034 Closes CLIENT-1036 |
||
|
|
1aff810443 |
chore: sync fantasy with upstream v0.45.5 (#31288)
Moves the fantasy pin to the tip of `coder_2_33` (`85ffbbe`). That commit is coder/fantasy#72, which merges 87 upstream charmbracelet/fantasy commits, v0.40.0 to v0.45.5. Between the two pins 117 files change. Upstream's own v0.40.0 to v0.45.5 change, without tests, testdata, examples, `go.sum` and the kronk provider, is 43 files, +2271/−928. ## What reaches chatd chatd builds only the `anthropic`, `openai` and `openaicompat` fantasy clients (`chatprovider.ModelFromConfig`); other vendors reach it through the AI Gateway on one of those. So the upstream changes to the Google, Vercel, OpenRouter, Bedrock, Azure and kronk providers, and to the `fantasy.Agent` loop and its retries, do not run in chatd. These do: - **Chat Completions and openaicompat streams** keep reasoning on batched and DeepSeek-shaped chunks, keep `finish_reason: length` when tool calls are truncated, and stop sending empty reasoning fields. openaicompat drops assistant turns that hold only reasoning. - **Token usage.** When an OpenAI-shaped backend reports reasoning tokens apart from completion tokens (reasoning larger than output), output tokens now include them, so that backend's reported output tokens and cost rise. OpenAI's own shape, where reasoning is a subset, is unchanged. - **Responses.** A content-filtered turn no longer reads as a tool-call turn. - **Context overflow.** Baseten, Fireworks and Parasail prompt-length errors set `ContextTooLargeErr`, which compaction acts on. - **Anthropic.** Tool calls whose content block never closes are reported. For Claude 5 models, thinking defaults to `display: "summarized"` when the chat config sets none; a configured display still wins. `TestThinkingDropBlockModel_RetriesWithEffort` now expects the field in the retry body. - **Anthropic keepalives.** Fantasy forwards `message_start`, `message_delta` and unknown events as content-free `keepalive` parts. The first one arrives before any model output, so this PR makes `ttft_seconds` and the `time_to_first_token` stage skip them, as they skip warnings. They still reset the stream silence guard. `processStepStream` ignores them, and the debug recorder counts them in its part count but records no content. - **Tool-result media** now goes through upstream's shared `ToolRunBuffer`, which replaces coder/fantasy#64 and does the same thing. #72 keeps coder's anthropic-sdk-go and openai-go forks, Go 1.26 and kronk v1.31.5, so upstream's SDK and Go moves do not come along. `go mod tidy` raises the modules fantasy v0.45.5 requires, among them otel exporters v1.47, the AWS SDK, `google.golang.org/api` v0.307 and go-openapi v1. All are upgrades. The `go.mod` comment now names #72 as the upstream sync. coder/coder#29861 stacks on this PR to pin coder/fantasy#62. <details> <summary>Verification</summary> - `go build ./...`. - `go test` passes on every package that imports fantasy (`coderd/x/chatd/...`), and `go test ./coderd -run 'TestChat|TestExpChat|TestMCP|TestAIBridge'` passes. - `TestGuardedStreamTTFTStage/WarningsAndKeepalivesThenContentObservesOnce` fails without the TTFT change (TTFT observed 0s instead of 1s) and passes with it. - `make pre-commit` passes. The generated Prometheus docs pick up the metric help change. Not verified against live backends in this PR: the stream fixes, the token usage change and the context-overflow patterns have no coder test against a real provider. coder/fantasy#72 reports a local chatd run against the AI Gateway on Anthropic, Responses, OpenAI Chat and openaicompat. </details> > 🤖 This PR was created with the help of Coder Agents, and _will be_ reviewed by a human. 🏂🏻 |
||
|
|
688c4a390c |
fix: bump Go to 1.26.10, terraform to 1.16.7, alpine to 3.24.3 (CVE-2026-111943) (#31301)
Mitigates CVE-2026-111943 (compromised eMudhra intermediate CAs). - **Go 1.26.9 to 1.26.10** (`go.mod`, `mise.toml`, `mise.lock`). Go 1.26.10 no longer trusts certificates issued through the compromised intermediates. - **Bundled Terraform 1.16.6 to 1.16.7** (`install.go`, `install.sh`, `scripts/Dockerfile.base`, `mise.toml`, `mise.lock`, `flake.nix`, airgap docs, `testdata/generation.sha1`). [1.16.7](https://github.com/hashicorp/terraform/releases/tag/v1.16.7) is built with Go 1.26.10. Checksums come from the GPG-verified `terraform_1.16.7_SHA256SUMS`. `maxTerraformVersion` stays at 1.16.9. - **Base image `alpine:3.24.2` to `alpine:3.24.3`**. 3.24.2 ships `ca-certificates-bundle-20260909-r0`; 3.24.3 ships `20261020-r0`. Verification: - Rebuilt `scripts/Dockerfile.base` for linux/amd64 and linux/arm64. Both contain `ca-certificates-bundle-20261020-r0` and `Terraform v1.16.7`. - `go test ./provisioner/terraform/...` passes with Terraform 1.16.7. - `scripts/check_go_versions.sh` passes. - Local git hooks were skipped at the author's request because the dogfood host was overloaded. CI is the gate. Backports to `release/2.34` through `release/2.38` follow as separate PRs. Older Terraform minor lines did not get the Go 1.26.10 rebuild (1.15.9 is built with Go 1.25.10, 1.14.9 with Go 1.25.8), so release/2.35 also moves to 1.16.7. <details> <summary>Decision log</summary> - The request named Go 1.26.1. Main and every release branch were already on 1.26.9, so @sreya confirmed the target is 1.26.10. - release/2.34 stays on the Alpine 3.23 line (`alpine:3.23.7`, which also ships `ca-certificates-bundle-20261020-r0`) instead of jumping to 3.24. - release/2.35 had drifted: `install.go` pinned 1.14.5 (max 1.14.9) while the image and `mise.toml` used 1.15.5. Its backport sets both to 1.16.7 and raises max to 1.16.9. </details> > Generated by Coder Agents on behalf of @sreya. |
||
|
|
9edb2e388d |
feat: enable Coder.USSpelling Vale rule (#30790)
Depends on #30782. Adds `Coder.USSpelling` at `warning` severity. The rule flags an `-ise` family (`organise`, `initialise`, `authorisation`) and a list of British spellings (`behaviour`, `labelled`, `cancelled`, `analogue`, `whilst`, and others) and suggests the US form. It covers `docs/**` except `docs/.style/style-guide/**` and the generated `docs/reference/{api,cli}/*.md` pages. Baseline: 13 findings before cleanup, 0 after. The first commit fixes 11 of them: 10 in hand-written pages and 1 in the Prometheus metrics table, which comes from metric help text. Two findings sit in generated reference pages, which `.vale.ini` excludes for this rule: the CLI alias `favourite` and `amongst` in a Go comment from a vendored dependency (the DERP map schema). The metric help text comes from `querymetrics.go`, so the fix lands there and in `generated_metrics` and `prometheus.md`. Known false positive: Vale doesn't skip bold text, so a UI label in bold that keeps British spelling is flagged. The rule comment and the guide footer say to use a code span for such a label. Linear: DOCS-1280 <details> <summary>Decision log</summary> - **Rule type**: `substitution`, so each message names the US form. The `-ise` family can't name a specific replacement, so it suggests "the -ize form". - **`cancelled`**: the guide's "Use US spelling" section lists `canceled` and `canceling`. The rule flags the double-l verb forms and leaves `cancellation` alone, which Merriam-Webster spells with one `l`. - **Exceptions**: Vale applies an exception to the matched word, so each is anchored with `^` and `$` and case-insensitive. The list covers `-wise` words and stems for `advise`, `advertise`, `exercise`, `promise`, `premise`, `compromise`, `surprise`, `comprise`, `concise`, `precise`, `revise`, `supervise`, `televise`, `devise`, `improvise`, `franchise`, `merchandise`, `disguise`, `despise`, `paradise`, `cruise`, `noise`, `raise`, `rise`, `wise`, and others, each with the endings `e`, `es`, `ed`, `ing`, `er`, and `ers`. The `mise` tool is excepted by name. - **Extra British spellings** beyond the guide table: other doubled-`l` verbs (`signalled`, `levelled`), `metre`, `litre`, `fibre`, `theatre`, `calibre`, `offence`, `pretence`, `analyse`, `judgement`, `acknowledgement`, `ageing`, `artefact`, `sceptic`, `aluminium`, `practise`, `enrol`, `fulfil`, `instil`, `skilful`. None appears in the corpus today. - **Generated pages**: excluded for `docs/reference/{api,cli}/*.md`, as `Coder.UnitSpacing` does. Changing the `favourite` alias would change CLI behavior, and the `amongst` comment isn't ours to edit. - **Prometheus doc**: edited by hand with matching table padding because `go run ./scripts/metricsdocgen` already rewrites the whole table on the base branch, independent of this change. Test cases, run with `vale --config` against fixtures that are not committed, in LF and CRLF: - Positive: `organise`, `initialise`, `authorise`, `customisation`, `authorisation`, `organisations`, `Organised`, `initialising`, `recogniser`, `customisable`, every explicit list entry, and capitalized forms. - Negative: `advise`, `exercise`, `otherwise`, `Enterprise`, `premise`, `compromise`, `promise`, `surprise`, `precise`, `concise`, `expertise`, `revising`, `supervising`, `improvising`, `raise`, `noise`, `cruise`, `franchise`, `merchandise`, `disguise`, `despise`, `paradise`, `appraise`, `sunrise`, `arise`, `liaise`, `clockwise`, `cancellation`, `canceled`, `mise`. - Skipped: words in code spans and fenced code blocks, such as `cancelled`. - LF and CRLF results are identical. Checks: `vale --output=line docs/` reports 0 `Coder.USSpelling` findings, `make lint/style-claims` passes, and the pre-commit hooks pass on both commits. </details> *Generated by [Coder Agents](https://coder.com/docs/ai-coder/agents) on behalf of @nickvigilante.* |
||
|
|
6e51c66a97 |
docs: give every table header cell text and fail lint on empty ones (#30879)
## Summary axe reports `empty-table-header` on 116 generated CLI reference pages and several hand-written pages: a header cell with no text is announced by screen readers as an unnamed column. This PR gives every table header cell in `docs/` text, and adds a lint check so empty header cells can't come back. ## How to review this PR - `docs/reference/cli/`: 116 files, these all generate identically, so I would only spot check 2-3 of them and skip the rest - `docs/*` outside of `docs/reference/cli/`: 6 files, normal review of these - `scripts`: 5 files, code review of the Bash and Go files to make sure we're properly inserting headers into each table ## What changed **Generator.** `scripts/clidocgen` wrote an empty header row (`| | |`) over each option's metadata table (Type, Environment, YAML, Default). It now writes `| Property | Value |`. Subcommand tables already had `Name | Purpose` and are unchanged. Regenerated with `make docs/reference/cli/index.md`: 116 files under `docs/reference/cli/` change. The header rows change, and the body rows of each option table are re-padded to the wider first column; the content is otherwise identical. Every option on those 116 pages now shows a visible `Property | Value` header row above Type, Environment, YAML, and Default, so this is a visual change on the docs site as well as a screen reader one. The CLI's own `--help` output doesn't use this template, so it's unchanged. **Audit logs.** `docs/admin/security/audit-logs.md` already has `Field | Tracked` headers on `main` (the generator writes them), so there was nothing to change there; the live-site finding predates that. **Hand-written tables.** - `docs/admin/networking/port-forwarding.md`: the CORS matrix had three empty spanning corner cells. The corner now reads `From user` and `From workspace` (spanning the three row-header columns, beside the Alice/Bob and Workspace rows) and `To user`, `To workspace`, `To app` (over the three row-header columns). The grid is still 3 header rows by 7 columns. The From cells have `scope="row"` and the other header-row cells `scope="col"`, so the From labels don't become column headers for the body's label columns; the body's user, workspace, and app labels are `<th scope="row">`; and a `<caption>` says columns are the origin and rows the destination. - `groups-roles.md`, `airgap.md`, `scale-testing.md`, `workspace-tags.md`: these four corner cells are already filled by #30873. The new check would fail CI without them, so this PR carries the same four lines, byte-identical to #30873 (`Permission`, `Component`, `Scenario`, `Input`), so whichever PR merges second rebases without conflict. If #30873 merges first, these hunks drop out. **New check.** `scripts/docshtmlcheck` (`make lint/docs-html`, part of `make lint`) now also reports `empty-table-header`. I put it there because that checker already parses every Markdown file under `docs/`, generated pages included, with goldmark and tokenizes raw HTML with `golang.org/x/net/html`, and it already runs in CI. A markdownlint custom rule would have needed a new JS rule and HTML parsing there. - Markdown pipe tables: the header row, via goldmark's GFM table extension. - Raw HTML tables: every `<th>`, tracked across HTML blocks, with entities decoded and whitespace trimmed, so `<th></th>`, `<th> </th>`, and `<th><br></th>` are all reported. Markdown between the HTML blocks of an open `<th>` counts as its text. Tables in code blocks are ignored. - Output: `docs/x.md:29: empty-table-header: header cell 1 has no text (table's first header "Auditor")`, plus a summary footer. - The tokenizer loop moved out of `scanNode` into a shared `tokenizeSegments` helper so both checks use it; `scanNode`'s behavior is unchanged. - The style guide's checks table gets one row; the README for the checker describes the rule. ## Testing - Tests first: `TestCheckTables` (now 22 cases) and `TestRunEmptyTableHeader` failed against a stub, then pass. The existing `docshtmlcheck` tests pass unchanged. - `go run ./scripts/docshtmlcheck` on `main` reports 1,561 empty header cells (116 CLI pages, port-forwarding, and the four #30873 tables); on this branch it reports none. - `go test ./scripts/docshtmlcheck/ ./scripts/clidocgen/ ./scripts/docgenenv/`, golangci-lint on the changed packages, `make lint/docs-html lint/docs-manifest lint/docs-gen-filter lint/emdash`, `pnpm run check-docs`, and Vale on the changed hand-written pages all pass. - `make gen` couldn't run to completion locally (no `protoc-gen-go`); CI's gen check covers it. The CLI pages were regenerated with the repo's own target. Review feedback applied in |
||
|
|
d187dea338 |
docs: end every page description with a period and lint for it (#30863)
## Summary Page descriptions in the docs were inconsistent about ending with a period. This makes every page description end with one and adds a lint so it stays that way. A page description can come from three places, and the docs site reads front matter first and falls back to the manifest: - the hand-written YAML sidebar sources under `docs/manifest/` (including `children_from` overlays), - the generated fragments (`docs/manifest/generated/cli.json`, `rest-api.json`), compiled into `docs/manifest.json`, - a page's own front matter (today only the generated CLI and API reference pages carry one). The check covers all three. For the CLI, the description comes from each command's `Short`, which stays unpunctuated by CLI-help convention, so `clidocgen` adds the period when it writes the docs description instead of changing 120 `Short` strings and the CLI golden files. ## What the lint checks `make lint/docs-manifest` (`docsmanifestgen check`, already part of `make lint` in CI) now fails when a non-empty description doesn't end with `.`. No description in the tree ends with `?` or `!`, so the rule allows only a period. Errors name the source file, the sidebar breadcrumb, and the description, for example: ``` install/plan/sizing.yml: Install > Plan your deployment > Coder Validated Architecture > Up to 1,000 users: description must end with a period: "Hardware specifications and architecture guidance for Coder deployments that support up to 1,000 users" generated/api.json: General: description must end with a period: "General endpoints" reference/cli/ping.md: Reference > Command Line > `ping`: front matter description must end with a period: "Ping a workspace" ``` The style guide's page-description rule now lists the requirement and cites the checker, and `styleclaims` recognises `scripts/docsmanifestgen` so the coverage table counts it as tool-checked. ## Count of descriptions fixed 147 descriptions in `docs/manifest.json`: - 27 hand-written descriptions in 15 sidebar source files, - 120 generated CLI descriptions, which also update the front matter of 120 CLI reference pages. The REST API descriptions already ended with a period. No description is otherwise reworded. ## Testing - New table cases in `scripts/docgenenv` (section route, child route, overlay, generated fragment, front matter, and a `?` ending) and `scripts/clidocgen`, written first and failing before the change. - `docsmanifestgen check` on the unfixed tree reported the 27 source descriptions; after the fixes and regeneration it passes. - `go test ./scripts/docgenenv/ ./scripts/clidocgen/ ./scripts/docsmanifestgen/ ./scripts/styleclaims/ ./scripts/apidocgen/...` - `golangci-lint run` on the changed packages, `pnpm run check-docs`, `go run ./scripts/styleclaims`, `scripts/check_emdash.sh`, and `docsmanifestgen fmt` (no changes). Linear: [DOCS-1304](https://linear.app/codercom/issue/DOCS-1304) --- 🤖 Built with AI assistance. |
||
|
|
7b8d480ae8 |
fix(scripts/releaser): use the v-prefixed image tag in release notes (#31032)
## Problem The release wizard writes this into every release's notes: ``` docker pull ghcr.io/coder/coder:2.37.5 ``` but the workflow tags images with `scripts/image_tag.sh`, which always emits `v<version>`. `ghcr.io/coder/coder:2.37.5` returns 404; `ghcr.io/coder/coder:v2.37.5` is the real tag. Checked against v2.37.5, v2.37.4, v2.38.0 and v2.29.19 on ghcr.io: only the `v`-prefixed manifests exist. `release.go` strips the `v` before formatting the tag (`strings.TrimPrefix(newVersion.String(), "v")`). The old bash generator used `image_tag.sh` directly and got it right. ## Change Format the tag with `newVersion.String()` (keeps the `v`), with a comment pointing at `image_tag.sh` as the source of truth. Affected published notes (36 releases back to v2.29.19) can be fixed with `gh release edit --notes-file`; this PR only fixes future ones. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Part of ENT-224 Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
86ea5d4c4e |
ci: bump paralleltestctx to detect timeout contexts used through closures (#31039)
#31011 fixed a flake where a closure in `TestProjectSkillQueries` used the parent test's `testutil.Context` from parallel subtests. Once that deadline passed, the closure's `require.NoError` called `FailNow` on the parent `t`, which panics and takes down the whole `coderd/database` package. `paralleltestctx` only checked direct references to the context, so it missed this. coder/paralleltestctx#6 now follows calls to local closures too. This pins `paralleltestctx` to the current `main` commit, as there's no tag yet. That commit also brings in the outer variable reassignment check from coder/paralleltestctx#4 and the `x/tools` bump from coder/paralleltestctx#5. The closure check flagged the `loadPrompt` helper in `TestMediaToolResultRoundTrip`, so it now makes its own context from the subtest's `t`. The `TestGraph` and `TestRuntimeAudit` fixes for the outer variable check are the same as in #30288, so that PR only needs to repin. |
||
|
|
116660193e |
chore: bump bundled terraform to 1.16.6 (#30516)
Bump the bundled Terraform binary from 1.16.2 to 1.16.6 (latest stable, [released 2026-10-14](https://github.com/hashicorp/terraform/releases/tag/v1.16.6)), following the same file set as #29331: - `provisioner/terraform/install.go`: `TerraformVersion` (`maxTerraformVersion` stays at 1.16.9 since this is a patch bump) - `install.sh`, `scripts/Dockerfile.base` - `mise.toml`, `mise.lock` (checksums from HashiCorp's `terraform_1.16.6_SHA256SUMS`) - `flake.nix` (fetchurl SRI hashes derived from the same SHA256SUMS) - `docs/install/prepare/airgap.md`: the example Dockerfile `ARG TERRAFORM_VERSION` had drifted back to 1.11.0 after the docs move; updated to 1.16.6 Verified locally with `go test ./provisioner/terraform/ -run 'TestInstall|Version'`. Opened by Superblink on behalf of @droopy4096. _Updated from 1.16.5 to 1.16.6 (adds an HTTP/2 resource-exhaustion fix). Branch name still says 1.16.5. Fixture fingerprint (`generation.sha1`) regenerated; `go test ./provisioner/terraform/ -run 'TestInstall|Version|Golden'` passes._ --------- Co-authored-by: coder[bot] <137810501+coder[bot]@users.noreply.github.com> Co-authored-by: Dmitry Makovey <dmakovey@yahoo.com> |
||
|
|
17ec9459c0 |
fix(scripts/dogfood): pass GO_LINT_NEW_CODE_BASE to the image lint run (#30851)
Fixes the `build_image (26.04)` failure in the `dogfood` workflow on PRs into `main` (seen on #30807). Tracked in [ENT-213](https://linear.app/codercom/issue/ENT-213). ## Problem `lint/go/new-code` (added in #30622) runs `.golangci.new-code.yaml` with `--new-from-merge-base=$(GO_LINT_NEW_CODE_BASE)`, which defaults to `origin/main`. `ci.yaml` sets `GO_LINT_NEW_CODE_BASE` to `HEAD^1` for PRs and `HEAD` otherwise. `scripts/dogfood/test_image.sh` doesn't pass it into the container, and the dogfood checkout (depth 2) has no `origin/main`. So `make lint` inside the image reports the whole tree (1263 issues: errcheck 437, forbidigo 42, nolintlint 784) and fails "Test image tooling". Pushes to `main` run the same validation before pushing the image, so the next dogfood-triggering merge to `main` would also fail and skip the Docker Hub push. ## Change `scripts/dogfood/test_image.sh` only: - Under GitHub Actions, and when `GO_LINT_NEW_CODE_BASE` isn't already set, default it to `HEAD^1` for `pull_request` and `HEAD` otherwise, mirroring `ci.yaml`. - Forward it into the container with `--env GO_LINT_NEW_CODE_BASE`. - Local runs are unchanged: the variable stays unset unless you set it, so the Makefile default (`origin/main`) applies. This PR touches `scripts/dogfood/**`, which triggers the `dogfood` workflow, so its own `build_image (26.04)` run is the end-to-end test. Opened by Superblink on behalf of @droopy4096. Co-authored-by: coder[bot] <137810501+coder[bot]@users.noreply.github.com> Co-authored-by: Dmitry Makovey <dmakovey@yahoo.com> |
||
|
|
603dd420d1 |
feat: add ServerTailnet logs and metrics for unreachable agents (#30133)
Add default-level metrics and warn-level diagnostics to investigate ServerTailnet reachability failures causing agent-specific 502s, without restarting coderd or enabling debug logging. - Enrich request logs and PTY/chatd warnings with agent ID, failure reason, wait duration, coordinator state, WireGuard handshake and byte counts, and DERP regions. - Add metrics for unreachable attempts by reason, reachability latency, embedded DERP connections, and offline app/terminal requests. - Distinguish reachability failures from subsequent TCP dial failures, cap reverse proxy dials at one minute, and exclude expected chatd readiness polls and superseded-agent dials from unreachable counts. - Report missing handshakes as zero time instead of 1970, also fixing `coder ping`. Part of PLAT-680, a sub-issue of PLAT-360. |
||
|
|
e7c2fd5d2e |
feat: add Gemini 4 Argon to Agents and AI Gateway (#30780)
Add Gemini 4 Argon to the Agents known models catalog, so it appears as a suggestion when an admin adds a chat model, and regenerate the AI Gateway price book from models.dev. | Provider | Model ID | Placed before | |---|---|---| | google | `gemini-4-argon` | `gemini-3.1-pro-preview` | | openrouter, vercel | `google/gemini-4-argon` | `google/gemini-3.8-flash` | **Pricing.** The price book carries Google's launch rates on google, openrouter, vercel, and copilot: $2 per 1M input tokens, $10 per 1M output tokens, and $0.10 per 1M cached input tokens. Google doubles them on 2026-12-01 ($4, $20, $0.20); the weekly refresh picks that up once models.dev changes. The google entry keeps models.dev's 32,768 max output tokens, the cap Google enforces on non-streaming `generateContent` calls (larger values return HTTP 400 there). **Thinking levels.** `googleSupportedThinkingLevels` did not recognize the `argon` name token and failed closed, so chatd sent Argon no `thinking_level` and no `include_thoughts`: the native Google path dropped the reasoning effort, and neither path showed thought summaries. Argon accepts LOW, MEDIUM, and HIGH like Gemini 3.1 Pro and rejects MINIMAL, so the map now treats it like the Pro family. **Upstream drift.** `prices.json` covers every model of its 8 providers, so the regeneration also brings the changes since the last weekly refresh, all on OpenRouter and Vercel: 14 other new entries, 26 entries models.dev delisted, and 51 price changes. The catalog picks up the same changes for 8 curated OpenRouter entries (DeepSeek, Kimi, Qwen, and GLM). ## Testing - Live requests to `gemini-4-argon` through the AI Gateway's Google provider (Google's OpenAI-compatible endpoint): `reasoning_effort` and `thinking_level` values `low`, `medium`, and `high` return 200 and `minimal` returns 400; `include_thoughts` returns thought text in streaming and non-streaming responses. - Red-green: removing the `argon` token fails `TestGoogleSupportedThinkingLevels/gemini-4-argon` (expected LOW, MEDIUM, HIGH; got nil). - Regenerating from the saved models.dev snapshot reproduces both generated files byte for byte. - `go test ./scripts/aibridgepricesgen/... ./coderd/aibridge/prices/... ./coderd/x/chatd/chatprovider/...` and `pnpm exec vitest run --project=unit src/modules/aiModels/` pass. The pre-commit hook passed; local pre-push checks were skipped, so CI is the first full run. ## Review record - Frontend review: the only `site/` change is the generated `knownModelsGenerated.json`, so the FE1 to FE10 checklist does not apply; no hand-written frontend code changed. > Xum opened this PR on behalf of @ibetitsmike. |
||
|
|
200cffcfd8 |
fix(scripts/release): promote stable on immutable releases (#30745)
## Problem `./scripts/release_promote_stable.sh v2.37.4` failed today with: ``` edit release failed: PATCH https://api.github.com/repos/coder/coder/releases/403906567: 404 Not Found ``` Releases on this repo are immutable (`gh release view v2.37.4 --json isImmutable` → `true`). `promoteVersionToStable` cloned the entire `RepositoryRelease` into `EditRelease`, so the PATCH carried `tag_name`, `target_commitish` and the assets. GitHub rejects that on an immutable release even when the values are unchanged, and answers 404 rather than 422. The same edit with only `body`, `prerelease` and `make_latest` succeeds (that's how v2.37.4 was promoted by hand). ## Change - Build a minimal `RepositoryRelease{Body, Prerelease, MakeLatest}` for the edit. - Drop the `Draft: false` assignment (published releases are never drafts, and `draft` is not an editable field on immutable releases). - Dry-run now logs the body diff instead of a diff of the whole object. - Remove the now-unused `cloneRelease` helper. Verified with `go test ./scripts/release/` and a `promote --dry-run` against v2.36.7. Every release published since immutable releases were enabled is affected, so without this the command cannot promote anything. Related: the release-process review notes that this step is also missing from the runbook and should become a workflow job on every `.0` mainline release. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
7517301ffa |
chore: add golangci new-code quality gates (#30622)
Stack context: second layer of the Go lint gate stack, built on the exclusion fix below. Why: adds commented-out code detection and a `log/slog` ban to the main config, plus a new-code-only pass requiring reasons on lint suppressions, flagging ignored errors (including `_, _ = w.Write(...)`), and banning `time.Sleep` in tests. Fixing the hits surfaced a real bug: GitLab warnings went to the wrong logger. The new-code pass resolves symlinked checkout paths so it does not silently report nothing. Validation: both configs report 0 issues; each seeded violation is caught; `make pre-commit` passed. > Xum acted for Mike to open this PR. |
||
|
|
e8dcf9a3f1 |
fix: anchor golangci .git exclusion and fix hidden findings (#30621)
Stack context: two-layer stack tightening Go lint gates. This bottom layer fixes the lint exclusion; the layer above adds new rules. Why: a `.git` path exclusion in the golangci config was hiding Go files, masking 70 findings. This fixes the exclusion, fixes the findings (`agent/agentgit` now runs git through `agentexec.Execer`), and adds a `make lint/go` check that fails when an exclusion hides Go files. `make lint/go` now waits for a concurrent golangci-lint run instead of failing. The exhaustruct exclusion rule for `scripts/*` had the same problem: as a regex it also matched `agent/agentscripts` and `coderd/agentapi/scripts.go`, so it is now `^scripts/`. Validation: full-tree lint reports 0 issues; the new check fails on the old entry and passes on the new one. > Xum acted for Mike to open and update this PR. |
||
|
|
2f2169ed19 |
fix: deduplicate template insights family metrics (#30497)
coderd_insights_applications_usage_seconds summed each family's per-app minutes, so a user with VS Code and Cursor open in the same minute was counted as two VS Code minutes. GetTemplateInsightsByTemplate now takes the registry's app-to-family mapping as jsonb, groups the raw agent stats by family, and counts each minute once per user and family. - Keep the metric's four built-in series (Visual Studio Code, JetBrains, Web Terminal, SSH) and their labels; only their values change. The HELP text now says built-in apps are grouped by family. - Add AppFamilyName.DisplayName() and remove the duplicate TemplateBuiltinAppDisplayName* constants from codersdk. The template insights handler returns the same display names. - Pin how the migration 000596 rollback approximates family minutes from per-app rows. Family values can drop wherever the old per-app sum double-counted overlapping apps. No migration or storage changes. |
||
|
|
5b060beeb1 |
feat: separate connection log methods from app names (#30466)
Connection logs now record how a connection was made (`connection_method`) separately from which app made it (`app_name`). Storage, the HTTP API, search filters, and the UI move to the new fields. Legacy agent reports and the deprecated `type` field keep working. - Add `connection_method` (`ssh`, `reconnecting_pty`, `workspace_app`, `port_forwarding`, `tunnel`) and optional `app_name` and `app_display_name` to `GET /api/v2/connectionlog`. Deprecate `type` and make it a plain string in the API and the Go SDK. - Add `method:` and repeatable `app:` search filters. `type:` keeps its old results but can't be combined with the new filters. - Replace the Type menu with a Method menu, show the app next to the method in each row, and warn when a filter uses `type:`. - Change the Active SSH connections preset to `method:ssh`, so it also includes SSH sessions from VS Code and JetBrains apps. - Generate `codersdk.ConnectionLogMethod` from the database enum with `typegen dbenums`. - Migration 000617 rewrites `connection_logs` under an ACCESS EXCLUSIVE lock, which takes about 50 seconds for 10 million rows. `vscode` and `jetbrains` rows become `ssh` rows with that app. Rolling back folds apps into the old types and loses per-app names. - Document the new filters and how to replace each `type:` value. Closes #27412 |
||
|
|
f923f4a525 |
chore!: remove the chat automations experiment (#30412)
Removes the experimental Chat Automations feature (`chat-automations` experiment) from main. This reverts the 16-PR stack that added it and adds two forward migrations that undo its schema and credential changes.
> [!WARNING]
> **Upgrade consequences**
>
> - **Automation data is deleted.** Migration 000615 drops the `chat_automations` table and deletes every queued message an automation delivered. Chats, their messages and ordinary queued messages stay. Messages lose their automation provenance (`automation_id`, `input_id`).
> - **Automation-only credentials are revoked.** Migration 000616 deletes API keys, OAuth2 codes and OAuth2 tokens whose only scopes (or allow-list entries) were `chat_automation:*`. Mixed credentials keep their other scopes. Custom roles lose their `chat_automation` permissions. OAuth2 apps that allowed only `chat_automation` scopes get the whitespace allowlist that grants nothing, as in 000595.
> - **A coordinated restart is required.** Stop all old replicas before the new version runs the migrations. Old replicas read the dropped table and columns, so a rolling deploy is not supported.
> - **Remove `--chat-max-automations-per-owner` before upgrading.** The flag, the YAML key `chat.maxAutomationsPerOwner` and the env var `CODER_CHAT_MAX_AUTOMATIONS_PER_OWNER` are removed. A deployment that still sets the flag or the YAML key will not start (`unknown flag` / `unknown option`). The env var is ignored. This includes dogfood. No release or tag contains the flag.
> - **Down migrations restore the schema only.** 000616 down and 000615 down recreate the 000611 schema with empty tables. They do not restore deleted automations, webhook secrets, provenance, queued deliveries, revoked credentials, stripped permissions or the deleted experiment rule.
## What is removed
- The `chat-automations` experiment and its stored runtime rule (`experiment_rule:chat-automations`).
- The `--chat-max-automations-per-owner` deployment option.
- The `chat_automation` RBAC resource, its member and chatd grants, and the `chat_automation:*` API key scopes.
- The automation sqlc queries, dbauthz wrappers and audit table entries.
- The management routes under `/api/experimental/organizations/{organization}/chat-automations`, and the webhook route `POST /api/experimental/chat-automations/{automation}/events` with its rate limiter.
- The chatd management service, webhook publish, schedule loop, the `manage_automations` tool, and the chatstate admission seam and queue promotion guard that only automations used.
- The Agents Automations page, editor, nav entry, chat labels, the Manage automations toggle and the API client.
- The `archived:any` chat search value that the automations "View chats" dialog added.
- `docs/ai-coder/agents/automations.md`, its manifest entry, the glossary entry and the related rows.
Reverted PRs: #30085, #30096, #30112, #30117, #30127, #30134, #30160, #30166, #30167, #30171, #30187, #30207, #30214, #30217, #30219, #30220.
## What stays, and why
- Migrations 000609, 000610 and 000611, their fixture, and the #30297 lock fix with `migration000609_test.go` stay unchanged. Deployments such as dogfood already ran them.
- New migration **000615** reverses the schema changes of 000609 and 000611 against the current schema. It uses the same short-wait lock-and-retry block as 000609, and it rebuilds `chats_expanded` from main's current definition minus the two automation columns. New migration **000616** follows the 000595 Tasks removal for credentials and recreates `api_key_scope` without the five `chat_automation:*` values. It keeps the `chat_project_memory:*` values from 000612.
- The `chat_automation` value stays in the `resource_type` enum, and `codersdk.ResourceTypeChatAutomation` stays. Old audit log rows stay readable, as with `task` after the Tasks removal.
- The 000615 delete fires the existing queue-version trigger, so `queue_version` moves to `snapshot_version` for each affected chat. `snapshot_version` is not bumped: the coordinated restart restarts every stream loop from an empty state, and the site does not read the version fields.
- `coderd/x/chatd/ARCHITECTURE.md` drops the sections the stack added and gets back its pre-stack wording, merged with the later main edits to the same file.
## Notes for reviewers
- #30379 (chat project page) merged while this PR was in progress. It passed `manageAutomationsEnabled` in `AgentCreatePage.test.tsx` and listed an `automations` route in `AgentsPageLayout.test.tsx`. Later main commits also added automation props in `ConversationTimeline.test.tsx` and `ConversationTimelineWorkingBlocks.stories.tsx`. This PR removes all of them.
- Remaining `automation` matches under `coderd`, `codersdk`, `enterprise`, `site/src` and `docs` are intended:
- migrations 000609 to 000611, their fixture and `migration000609_test.go`;
- the new 000615 and 000616 migrations and `migration000615_test.go`;
- the `chat_automation` resource type in `dump.sql`, `models.go`, `codersdk/audit.go`, the generated API docs, `swagger.json` and `typesGenerated.ts`;
- unrelated uses of the word "automation" (docs, `chatlabels_test.go`, `ratelimit.go`, `autostop.go`, `subagent_catalog.go`, `WorkspaceSharingSection.tsx`, `AgentChatPage.stories.tsx`).
Remote UAT on an isolated dev deployment passed. It upgraded a populated pre-removal database, then checked chats, queued messages, tokens, the 404 routes, the removed page and nav entry, and the experiments list.
---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_

|
||
|
|
35b3052ea8 |
ci(scripts/docsredirectscheck): reject redirects an earlier rule swallows (#30383)
## Summary
Redirects apply in file order and the first match wins, so rules have to
run from most specific to least.
Nothing enforced that, so a wildcard placed above a narrower rule inside
its subtree silently swallowed it.
## Problem
Given these two rules in that order, the second never applies:
```json
[
{ "source": "/docs/retired/:section(.*)", "destination": "/docs/reference/:section" },
{ "source": "/docs/retired/foo", "destination": "/docs/about" }
]
```
A reader asking for `/docs/retired/foo` is sent to `/docs/reference/foo`
instead of `/docs/about`.
If `/docs/reference/foo` happens to exist, every existing check passes:
the destination resolves, there is no duplicate source, no chain, and no
loop.
The rule is simply dead, and the only symptom is readers landing on the
wrong page.
`docs/redirects.json` is empty today, so this adds the guard before the
file gets its first wildcard rather than after.
## Fix
Compare each rule against the ones before it and fail when an earlier
source matches every URL a later source would.
Coverage is decided on path boundaries, not string prefixes, so
`/docs/retired/:path*` does not cover `/docs/retired-too/page`.
Two cases stay legal on purpose:
- An exact rule above a wildcard on the same prefix, which claims the
bare prefix and leaves the subtree to the wildcard.
- A regex wildcard above an exact rule on its bare prefix, since
`/:name(.*)` never matches the prefix itself.
Rules that share a source are still reported as duplicates, not as
unreachable, so one mistake produces one message.
## Changes
- `rules.go`: add `pattern.covers` and `checkOrder`, called from
`checkAcrossRules`.
- `README.md`: document the ordering requirement and the new failure.
- `main_test.go`: 11 cases covering each pattern pairing, both
orderings, the path-boundary case, reporting once against the first
coverer, and the duplicate interaction.
## Testing
- `go test ./scripts/docsredirectscheck/` passes;
`TestCheckRedirectsOrder` runs all 11 subtests.
- `make lint/docs-redirects` passes against the committed
`docs/redirects.json`.
- `gofmt -l` and `go vet` are clean on the package.
- Ran the binary against the example above: it fails with
`unreachable: rule [0] (source "/docs/retired/:section(.*)") comes first
and matches every URL this rule would; order rules from most specific to
least`,
exits 1, and passes with exit 0 once the two rules are swapped.
<details>
<summary>Why this check, and what it is a prerequisite for</summary>
`docs/redirects.json` is validated in CI and triggers a docs rebuild,
but no site reads it yet.
The redirects actually served live in two other hand-maintained files:
`coder.com/redirects.json` (297 rules, 173 under `/docs`) and
`docs-engine`'s `apps/router/redirects.json` (221 rules).
The plan is to make `docs/redirects.json` the single authored source and
have docs-engine compile it per version, so `apps/router/redirects.json`
becomes generated output.
Classifying the router's 221 rules showed all of them are same-version
moves once the version prefix is stripped, and that expanding them into
this file's narrow grammar yields 279 authored rules.
That expansion is what makes this check necessary now.
Collapsing many exact rules into wildcards is an engine optimization,
and the authored file will carry both wildcards and exact rules in the
same subtree, which is exactly the shape that can silently swallow a
rule.
Adding the guard while the file is still empty means the migration
cannot introduce an unreachable rule without CI saying so.
</details>
---
Resolves DOCS-1188.
Opened by Coder Agents on behalf of @nickvigilante.
<details>
<summary>CI note: one unrelated flake</summary>
`test-go-pg (ubuntu-latest)` failed on `coderd/x/chatd
TestChatTurnStopsAtStepLimit/Default`.
This PR changes three files under `scripts/docsredirectscheck` and
nothing in `coderd/`, so the failure is unrelated to the diff.
`lint`, `gen`, `fmt`, `check-build`, `test-go-race-pg`, `test-go-pg-17`,
`test-e2e`, and `test-go-pg` on macOS and Windows all pass.
The first run of this PR also had `changes`, `cla`, and `release-labels`
cancelled rather than failed, all three at exactly 15m03s, which skipped
the Go jobs entirely. A `--failed` rerun produced the results above.
</details>
|
||
|
|
bcedc5d47e |
fix(scripts/docsgenfiltercheck): accept CRLF line endings in banner check (#30476)
`bodyOpensWithContentBanner` split pages on `\n` and compared lines exactly. On a Windows checkout with CRLF endings, the first line of `docs/reference/cli/index.md` is `---\r`, so the front matter was never recognized and `TestBodyOpensWithContentBanner` failed deterministically on `test-go-pg (windows-2022)`. Normalize CRLF to LF before parsing, and add CRLF table cases so the bug reproduces on Linux too. Fixes CLI-55. Failing run: https://github.com/coder/coder/actions/runs/37570448753 ## Testing - The new CRLF cases failed before the fix and pass after it. - `go test ./scripts/docsgenfiltercheck`, `GOOS=windows go vet`, `golangci-lint`, and the full pre-commit hook pass. <details> <summary>CI flake note</summary> The first `fmt` run failed while downloading Go modules (`proxy.golang.org` returned `stream error: ... INTERNAL_ERROR` for `testcontainers-go@v0.40.0`), which also failed `required`. This is a network error unrelated to the change. I re-ran the failed jobs. </details> --- _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
d031680ff2 |
fix(scripts/metricsdocgen/scanner): normalize package keys to slash paths (#30360)
Fixes the Windows failures in `TestBuildPrefixIndex` and `TestExcluded` (ENG-3443). The scanner keyed package directories with `filepath.Dir`, which uses `\` on Windows, but compared them against keys derived from Go import paths and against `excludeDirs`, which always use `/`. Prefixes never reached imported packages, and excluded subtrees weren't skipped. Each parsed file now records its directory once in slash form (`packageDir`), and the `prefixIndex` doc states the key rule. `excluded` normalizes its input because `scanDirectory` passes it native `filepath.WalkDir` paths. Generated output on Linux is unchanged. PR CI only runs `./cli/... ./enterprise/cli/... ./agent/...` on Windows, so I dispatched [`nightly-gauntlet` on this branch](https://github.com/coder/coder/actions/runs/37316261411). On `windows-2022`, both `scripts/metricsdocgen` and `scripts/metricsdocgen/scanner` pass. That run tested `c5462169cd`. The only later commit drops an unused field and rewords comments, so the result still applies. <details> <summary>Unrelated failures in the gauntlet run</summary> The Windows job still fails on `TestWorkspaceToolsGolden`, `TestEditMessageCancelsToolCallsOnAgent`, and `TestTools/WorkspaceExecute`. These fail the same way in [main's 2026-10-05 nightly](https://github.com/coder/coder/actions/runs/37262889155), together with the scanner failures this PR fixes. `TestAcquirer_MatchTags` also failed once, in provisioner code that this PR doesn't touch. </details> --- 🤖 Generated by Coder Agents on behalf of @nickvigilante. |
||
|
|
28cf704f27 |
chore: update references to the relocated install docs paths (#30380)
The Install docs moved into the five-phase spine in #29304, but several references outside `docs/` still point at the pre-move URLs. `docs/redirects.json` is empty, so those URLs 404 rather than forwarding. The release note generators are the user-visible ones: every generated release note links `coder.com/docs/install/releases` and `coder.com/docs/install/upgrade`. | Reference | Was | Now | |---|---|---| | Release schedule links in release notes | `/docs/install/releases` | `/docs/reference/releases` | | Upgrade link in release notes | `/docs/install/upgrade` | `/docs/install/operate/upgrade` | | README sizing link | `/docs/admin/infrastructure/validated-architectures` | `/docs/install/plan/sizing` | | Provisioner tag table comments | `docs/admin/provisioners/index.md` | `docs/install/operate/provisioners/index.md` | | FAQ provenance comment | `docs/admin/licensing/index.md` | `docs/install/prepare/licensing.md` | | ESR 2.24-2.29 upgrade table | `/docs/admin/provisioners` | `/docs/install/operate/provisioners` | | Helm provisioner README, `NOTES.txt`, and `values.yaml` | `/docs/admin/provisioners` | `/docs/install/operate/provisioners` | | Helm Coder chart README | `/docs/install/kubernetes` | `/docs/install/server/kubernetes` | | `workspace-tags` example README | `/docs/admin/provisioners#external-provisioners` | `/docs/install/operate/provisioners#types-of-provisioners` | | `kubernetes-envbox` example README | `/docs/admin/infrastructure/architecture#agents` | `/docs/install/plan/architecture#agents` | `scripts/releaser/docs.go` was already updated in #29304; this covers what that pass missed. Two notes on anchors: - The `#external-provisioners` anchor was already dead before #29304, so it now points at `#types-of-provisioners`, the section covering external, organization-scoped, and user-scoped provisioners. - Every other anchor was verified to still exist on its new page. One link left alone: `provisionerd/provisionerd.go` references `docs/admin/provisioners.md` through a pinned-commit GitHub permalink, which still resolves and shouldn't be rewritten. ## Verification - `go test ./scripts/release/...` passes, including the release note golden strings. - `go build ./scripts/releaser/` succeeds. - `make pre-commit` passes. - Markdown table padding reflowed with `markdown-table-formatter`; `markdownlint` reports no new findings. <sub>Opened by Coder Agents on behalf of @nickvigilante.</sub> |
||
|
|
b9c0853473 |
ci: skip the gen job for docs-only PRs that cannot change its output (#30164)
The CI `gen` job ran `make -j -B gen` on every PR, so a docs-only PR
spent about 160 seconds of an 8-core runner (12 recent runs: 154 to 170
seconds) confirming that nothing changed.
This PR skips the job for docs-only PRs that touch none of the docs
paths `make gen` reads or rewrites.
Replaying every commit on `main` since 2026-08-01 through the new
filter, 96 of 116 docs-only commits (83%) would skip.
- A new `docs-gen` paths filter lists `docs/manifest.json`,
`docs/reference/api/**`, `docs/reference/cli/**`, and the three
generated admin pages.
`gen` now needs `changes` and runs unless the PR is docs-only with no
`docs-gen` or workflow match.
Push, release-branch `create`, and `workflow_dispatch` runs always
regenerate. Non-release `create` events now skip `gen`, like every other
job that needs `changes`.
- `lint/docs-gen-filter` (`scripts/docsgenfiltercheck`, run by `make
lint`) treats as generated every file in `GEN_FILES`, plus every tracked
Markdown page whose body opens with the shared
`docgenenv.GeneratedContentBanner`. It fails when a generated file
matches the `docs` filter but not `docs-gen`, or when a `docs-gen`
pattern matches no tracked file.
This keeps the filter from drifting when someone adds a generator.
## Why skipping is safe
- No generator reads docs prose. Makefile rules and generators only
touch `docs/manifest.json` and the generated pages under `docs/`;
`examplegen` embeds only `examples/templates`, and no golden-file test
reads `docs/`.
- `dorny/paths-filter` matches a renamed file on both its old and new
paths (`src/main.ts` at the pinned SHA), so moving a generated page out
of `docs/reference/cli/` still runs `gen`.
- If `changes` fails, `gen` is skipped and `required` fails on the
`changes` result, so a failed classification never counts as an
exemption.
Docs-only PRs that edit `docs/manifest.json` (usually a new page) or a
generated page still run the full job, because the generators rewrite
those files.
DOCS-1142 tracks a lighter path for those PRs and for fresh-worktree
rebuilds: render the docs from the committed `swagger.json` and sidebar
fragments instead of running swag or building the CLI.
That work depends on DOCS-1131, which rewrites the same Makefile rules.
Refs DOCS-1141
<details>
<summary>Measurements, options considered, and validation</summary>
**Local profile (not changed by this PR).**
In a warm worktree, editing a docs page or `manifest.json` and running
`make -j gen` rebuilds nothing (0.9 seconds).
In a fresh worktree with a warm Go cache on 12 cores, `make -j
docs/manifest.json` took 40 seconds and `make -j gen` took 46 seconds.
The time went to `_gen/bin/clidocgen` (26 seconds), swag in
`coderd/apidoc/.gen` (18 seconds), and the database codegen chain, which
needs PostgreSQL.
Checkout mtimes are arbitrary and `coderd/apidoc/.gen` is untracked, so
all of that reruns once.
`clidocgen` runs twice per `make gen`, but each run takes about 1
second, so merging the runs isn't worth it.
**Options considered.**
1. Skip `gen` by path for docs-only PRs (this PR). Low risk, independent
of DOCS-1131.
2. A light CI job that runs only the docs generators, skipping heavy
prerequisites with `make -o`. Rejected: CI would keep a second
dependency list that can drift from the Makefile.
3. Content-hash stamps for swag. A committed stamp would conflict on
nearly every backend PR, and an untracked one doesn't help fresh
worktrees. Deferred to DOCS-1142.
4. Split swag from the API Markdown rendering now. It conflicts with
DOCS-1131. Deferred to DOCS-1142.
**Filter validation** (the workflow's own filters with `picomatch@2`,
`dot: true`, the matcher `paths-filter` uses):
| Change | `gen` |
| --- | --- |
| Prose page, image, root `README.md`, style guide, `.claude/docs` |
skips |
| New page plus `docs/manifest.json` | runs |
| Edit, delete, or rename out of `docs/reference/cli/**` or
`docs/reference/api/**` | runs |
| Audit log, Prometheus, or configuration reference page | runs |
| Mixed code and docs, `Makefile`, generator script, `offlinedocs` |
runs |
| Workflow change | runs |
| Docs-only `push`, release `create`, `workflow_dispatch` | runs |
Running `make lint/docs-gen-filter` against edited copies of the
workflow fails, as it should, in each of these cases:
`docs/reference/cli/**` narrowed to `docs/reference/cli/*.md` (137
nested pages), `docs/reference/api/**` narrowed to `*.json` (31 pages
plus the stale pattern), the configuration reference entry removed, a
mistyped admin page path, and the unsupported patterns
`docs/reference/**.md` and `docs/reference/*/**`.
</details>
<details>
<summary>CI flake unrelated to this PR</summary>
`test-js` failed once, on the second push, in
`src/pages/AISettingsPage/SpendPage/SpendPage.test.tsx` ("applies and
clears the 'provider_name' filter and resets pagination"). The same test
failed on `main` in run 36649227804. This PR changes nothing under
`site/`, and `test-js` passed on every later push.
</details>
---
_Generated by Coder Agents on behalf of @nickvigilante._
<details>
<summary>CI flake note</summary>
`test-go-pg (ubuntu-latest)` failed once on `ff25eba` because the runner
ran out of disk (`No space left on device`) before the tests reported
results.
This PR doesn't change Go code under test. The rerun passed.
</details>
|
||
|
|
fcbf45c571 |
docs: render audit log resources as one table per resource (#29797)
## Summary The audit logs page now lists each tracked resource in its own section with a simple two-column table, replacing the nested HTML tables that rendered poorly and overflowed on phones. ## Before and after Before, the generated block was a single Markdown table with a malformed `|<b>Resource</b>||` header. Each row held the resource name and its actions in one cell, then split a raw HTML `<table>` of fields across the remaining cells. The result rendered unevenly across renderers, was far wider than the page on mobile, and was hard to navigate with a screen reader. After, each resource gets an `###` heading under **Tracked Events**, which also gives it a linkable anchor. Below the heading, an `Actions:` line lists the audited actions as inline code, followed by a two-column Field and Tracked table with `Yes` or `No` values. Every table uses the same fixed column widths (Field 75%, Tracked 25%), so the Tracked column lines up across all resources. Two narrow columns fit at phone width without horizontal scrolling. Resources with no mapped actions skip the `Actions:` line instead of rendering an empty one. Resource ordering is unchanged. ## Changes - `scripts/auditdocgen/main.go` writes one section per resource. Each fields table is a small HTML table with `width` attributes, because Markdown tables size columns to their content and cannot align across tables. GitHub and the docs site sanitizer both keep `width` but strip inline `style` and `<colgroup>`. - The generator no longer panics when its start marker is the last thing in the file. - New `scripts/auditdocgen/main_test.go` covers section output, marker handling, and idempotent regeneration. - `docs/admin/security/audit-logs.md` is regenerated, and the intro sentence above the block now explains the actions line and the Tracked column. ## How it was regenerated `make docs/admin/security/audit-logs.md`, which builds the generator and runs `markdownlint-cli2 --fix` and `markdown-table-formatter` over the output. Running it a second time produces no diff. ## Testing - `go test ./scripts/auditdocgen/...` passes. - `pnpm exec markdownlint-cli2 docs/admin/security/audit-logs.md` reports 0 errors. Linear: https://linear.app/codercom/issue/DOCS-894 --- 🤖 Built with AI assistance. |
||
|
|
12caf883fc |
test(scripts/docgenenv): match missing include by fs.ErrNotExist (#30285)
## Summary `TestBuildManifestErrors/IncludeMissingFile` fails deterministically on Windows because it matches the POSIX error text `no such file or directory`. Windows reports the same condition as `The system cannot find the file specified.` This asserts `fs.ErrNotExist` in the error chain instead, plus the included file name. Fixes [ENG-3439](https://linear.app/codercom/issue/ENG-3439). ## Changes - Add an optional `wantErrIs` field to the `TestBuildManifestErrors` table, checked with `require.ErrorIs`. - `IncludeMissingFile` now expects `fs.ErrNotExist` and the text `nope.yml` (not `ref/nope.yml`, since Windows renders the path with escaped backslashes). No production code changes: `DecodeSourceFile` already wraps the `os.ReadFile` error with `%w`, and `errors.Join` preserves it. ## Testing - `go test ./scripts/docgenenv/... -count=1` passes on Linux. - `GOOS=windows go test -c ./scripts/docgenenv` compiles. - `golangci-lint run ./scripts/docgenenv/...` reports 0 issues; pre-commit hook passed. - Not run on Windows locally; the `test-go-pg (windows-2022)` job is the real check. --- _Generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
bb58916e6c |
ci: validate docs/redirects.json (#30209)
Adds `docsredirectscheck`, a lint for `docs/redirects.json`, the list of
redirects the documentation website applies for pages that have moved or
been removed. It runs as `make lint/docs-redirects`, part of `make lint`
and `make lint-light`, so a bad redirect is caught in the pull request
that adds it. The file does not exist yet, and the check passes while it
is absent, so this can merge before or after the file does.
## What it checks
It fails on:
- a file that is not a JSON array of well-formed rules (`source`,
`destination`, optional boolean `permanent`, no unknown fields);
- syntax outside the supported subset: a source under `/docs/`, written
as an exact path, a trailing `/:name*`, or a trailing `/:name(.*)`, with
no version segment such as `/@main`;
- an internal destination that is not a page in `docs/manifest.json`, or
a pattern destination that points into a section with no pages or uses a
parameter the source does not define;
- a source that matches a live page, which would hide it;
- duplicate sources, chains (a destination that is another rule's
source), and loops.
It warns, and never fails, when a pull request removes routes from
`docs/manifest.json` while `docs/redirects.json` is unchanged and does
not already cover them. Pages are sometimes removed on purpose. The
comparison is by route rather than by file, so a rename that keeps its
URL (for example `admin/foo/index.md` to `admin/foo.md`) does not warn.
In GitHub Actions the warning is an annotation on the manifest. The base
is the first parent of the PR merge commit, the same approach
`scripts/check_emdash.sh` uses, and the warning is skipped with a note
when it is not available.
Routes are derived from `docs/manifest.json` the way the docs website
derives them, including its plain-suffix stripping of `README.md`,
`index.md`, and `.md`, so the check and the site agree about which pages
exist. `scripts/docsredirectscheck/README.md` documents the rule format
and the limits.
## Testing
- 128 Go tests pass under Go 1.26.5: route derivation, every failing and
passing rule shape, the absent-file pass, exit codes, and the warning
logic through a fake git reader.
- I checked that the tests can fail by breaking the code 16 ways (for
example dropping the `index.md` suffix, disabling the shadow check,
reporting loops twice). All 16 were caught. That run found one gap, a
missing test for "redirects file changed", which is now covered.
- Ran against the repository's real `docs/manifest.json`: passes with no
redirects file, and a file with one of each failure class reports every
problem with the rule index, the source, and how to fix it.
- Ran the warning against real git history: it warns for an older base,
stays silent at `HEAD`, and skips with a note for an unknown revision.
- Lint: `golangci-lint` v2.0.2 built with Go 1.26.5 against the
repository config reports 0 issues. `paralleltestctx`, `intxcheck`,
`typos` 1.46.1, `gofumpt` and `gci` (through `make fmt/go`), and `go
vet` pass.
CI: `lint` (which runs this check), `fmt`, `title`, and the Go and
end-to-end test jobs pass. The `gen` job, and so `required`, fails on
this branch for a reason this PR does not touch: `main` is failing it
too. `docs/manifest/generated/cli.json` has not been regenerated for the
`coder sharing` commands that landed in the latest commit on `main`. It
should clear once `main` is fixed and merged into this branch.
Not run locally: the full `make lint` and `make pre-commit`. The local
hooks are opt-in and were off. The annotation output has been exercised
by unit tests and a local run with `GITHUB_ACTIONS=true`, but not yet on
a real pull request merge commit; this PR does not change the manifest,
so it will not exercise it either. No workflow change is needed, because
the `lint` job already runs `make lint` for any change that is not
offlinedocs-only.
---
🤖 Built with AI assistance.
|
||
|
|
9316d67440 |
feat: add chat automations management API behind chat-automations (#30112)
Adds the management API for chat automations under
`/api/experimental/organizations/{organization}/chat-automations`,
behind the new user-scoped `chat-automations` experiment. This is the
first of two PRs for RFC step 3; nothing publishes automation messages
yet.
- **Experiment:** `chat-automations` is in `ExperimentsKnown`,
`ExperimentsUserScoped`, and the ruleguard list in `scripts/rules.go`.
Every route asks `chatd.AutomationsEnabled(ctx, api.ExperimentEvaluator,
callerID)`, which fails closed on a missing subject or evaluator; the
routes stay mounted and return 404 when the experiment is off for the
caller, so a runtime rule for one user applies on the next request
without a restart. There is no `/api/v2` alias.
- **Routes:** list, create (201), get, `PATCH`, delete (204), with
Swagger annotations and audit entries. List returns the automations in
the organization the caller can read (members see their own,
organization admins see all).
- **Service** (`coderd/x/chatd/automations.go`): create validates kind
and target shape, a non-empty prompt, a five-field cron and IANA time
zone, model access, and that an `existing_chat` target is a root chat of
the owner in the same organization. It defaults `when_busy` to `skip`
for schedules and `queue` for webhooks and computes the first schedule
cursor. `PATCH` runs the same per-field validation on each changed
field, rejects `kind` and `target_mode`, bumps `schedule_revision` on
prompt, cron, or time zone changes, and recomputes the cursor on cron or
time zone changes.
- **Owner-only:** only the owner can `PATCH` an automation, even with
organization-admin or site-owner roles (403); admins can list, read, and
delete.
- **Secrets:** a webhook's secret (`coder_automation_` prefix) is
returned once in the create response. Only its SHA-256 is stored, and it
appears in no list, get, audit, or log output.
- **Cap:** new option `--chat-max-automations-per-owner` (default 50)
caps automations per owner across all organizations; creating one more
returns 409. Creates serialize on a per-owner advisory lock.
- **Cron:** `cron.Standard(spec, timeZone)` accepts any standard
five-field expression (the existing `Weekly` rejects day-of-month and
month restrictions). Responses include the next five run times of an
enabled schedule.
PR 3b (stacked on this one) adds disable and re-enable with the queue
cutoff, makes delete run disable first, and adds secret rotation and the
schedule preview route. Until then, the queue promotion guard from
#30096 discards queued rows whose automation was deleted.
Dogfood UAT ran on a real dev instance and passed:
create/list/get/patch/delete via curl, owner-only 403s for an
organization admin and the site owner, the cap (including concurrent
creates and cross-organization counting), a runtime rule turning the
experiment off for one user without a restart, and `/api/v2` 404s.
Part of CODAGT-1209 (PR 3b closes it)
Part of CODAGT-1135
Refs CODAGT-1217
Stack: PR 3 of the Automations for Coder Agents stack, on top of #30096
(which is on top of #30085).
> This PR was written by an AI agent (xum) and reviewed by the agent's
own test audit and UAT. A human has not reviewed it yet.
---
_Generated with [`xum`](https://github.com/coder/xum) • Model:
`anthropic:claude-opus-5-5` • Thinking: `high`_
---------
Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
||
|
|
2e0f97e5de |
feat: add type and secret status to the configuration reference (DOCS-896) (#29310)
## Summary The generated configuration reference told a reader how to set each deployment option but not what the option accepts. Every entry carried the environment variable, CLI flag, YAML key, and default, while serpent's value type stayed in the source. A reader could not tell a `duration` from an `int`, or discover an enum's accepted values, without following the flag link into the CLI reference. - **Type** is now rendered for all 200 options from the serpent value. Enums expand into their choices (`- Type: `enum`, one of `password`, `awsiamrds``) rather than printing serpent's escaped `enum[a\|b]` spelling, which is meant for its own table output. - **Secrets** are now marked. The nine options carrying the `secret` annotation that `codersdk.IsSecretDeploymentOption` reads are deliberately excluded from YAML, so the page now says where to set them instead of leaving the omission unexplained. ## Correction to the issue DOCS-896 claimed the page showed a YAML key for secret options. It does not: all nine secret options have an empty `YAML` field, so the generator already omitted that bullet. The real gap was that nothing explained *why* the YAML key is missing. The page header and the per-option marker now cover it. ## Verification - `go test ./scripts/configdocgen` passes, with new cases for the enum-choice parsing, plain and nil value types, and the secret marker rendering exactly once for the annotated option. - Regenerated page has 200 `- Type:` lines for 200 rendered options and 9 secret markers. - `make lint/emdash`, markdownlint, `markdown-table-formatter`, and Vale are clean on the regenerated page. `golangci-lint` clean on the package. Full `make pre-commit` passed. <details> <summary>Local pre-push note</summary> The repository pre-push hook runs the full Go suite locally. In this workspace it segfaults the `make` process outright, and an isolated `make test` run produces ~1,000 failures unrelated to this change (embedded NATS servers failing to start within 10s, chatd state-machine tests), which reproduce independently of this diff. I verified the change with `go build ./...`, the package tests above, and the full pre-commit suite instead, and disabled the hook for this worktree only using its documented `git config coder.pre-push` knob, restoring the setting immediately after the push. No `--no-verify`. CI is the authority on the full suite here. </details> --- Generated with Coder Agents on behalf of @nickvigilante. Linear: [DOCS-896](https://linear.app/codercom/issue/DOCS-896/configdocgen-render-option-type-and-secret-status) |
||
|
|
4a184ca54a |
feat: add generated API key scopes reference (DOCS-135) (#29307)
## Summary Coder validates every requested API key scope against a curated public catalog in `coderd/rbac`, but the docs never listed it. Readers had to infer the requestable set from the `codersdk.APIKeyScope` enum, which is a superset that includes internal scopes a token cannot carry. This adds `scripts/scopesdocgen`, which renders `docs/reference/api-key-scopes.md` from `rbac.ExternalScopeNames` and the policy definitions behind it: - built-in scopes (`coder:all`, `coder:application_connect`) - composite `coder:*` scopes, each with the permissions it expands to - low-level `resource:action` scopes, with the action descriptions the policy declares - the deprecated `all` / `application_connect` aliases and their canonical spellings The generator is wired into `make gen`, so CI fails when the scope catalog and the page drift apart. ## Also in this change - `coderd/apikey.go`: the unrequestable-scope `400` detail pointed at `admin/users/sessions-tokens#api-key-scopes`, which only ever held a partial list. It now points at the generated reference. - `docs/admin/users/sessions-tokens.md`: the partial enumeration and the "read the schema, but not all of it applies" caveat are replaced with a link to the reference. The how-to content stays. ## Verification - `go test ./scripts/scopesdocgen` covers the sentence formatting, the scope partitioning, and a guard that every name in `rbac.ExternalScopeNames()` appears on the rendered page. - `go test ./coderd -run 'TestTokenScoped|TestCreateTokenScopes|TestExternalScopesAreStorable|TestTokenLegacySingularScopeCompat'` passes, confirming the page's claims about the default scope and the rejection of internal scopes. - `make lint/emdash`, `make lint/docs-html`, `make lint/check-scopes`, `pnpm run check-docs`, and Vale on the changed pages are clean. Full `make pre-commit` passed. <details> <summary>Context and scope decisions</summary> Part of the DOCS Automated reference documentation project, which tracks generating reference pages from product source of truth instead of maintaining them by hand. DOCS-135 is the first item: it was filed as "wire up the existing generator," but `scripts/apikeyscopesgen` emits Go (`codersdk/apikey_scopes_gen.go`), not documentation, so there was no generator output to surface and this adds one. Decisions made while implementing: - **Placement.** `docs/reference/api-key-scopes.md`, as a direct child of Reference rather than inside `docs/reference/api/`, because that directory is owned by the swagger generator. - **Page shape.** Follows the `scripts/docgenenv` convention for generated reference pages: the generated marker and page metadata in front matter, the generated-content banner in the body, and sections starting at level two because the front-matter title renders as the page heading. - **Public scopes only.** The page lists what `rbac.IsExternalScope` accepts. Internal `resource:action` pairs are deliberately excluded, which is the distinction the old schema link failed to make. - **Acronym handling.** Policy action descriptions are lowercase source strings (`"ssh into a given workspace"`). The generator restores the casing of a small set of leading acronyms rather than editing the RBAC package, so the change stays inside the docs pipeline. Sibling backlog items turned out to be already delivered and are being rescoped separately: `metricsdocgen` and `auditdocgen` already write into their docs pages, and `scripts/configdocgen` already generates the configuration reference. </details> --- Generated with Coder Agents on behalf of @nickvigilante. Linear: [DOCS-135](https://linear.app/codercom/issue/DOCS-135/wave-1-wire-up-api-key-scopes-reference-to-docs) ## Product UI impact, please read This PR corrects three RBAC action description strings in `coderd/rbac/policy/policy.go`: | Action | Before | After | |---|---|---| | `workspace:start` | allows starting a workspace | start a workspace | | `workspace:stop` | allows stopping a workspace | stop a workspace | | `api_key:update` | update an api key, eg expires | update an api key, for example its expiry | These were internal-facing until this PR, which is what made them worth fixing: the new reference page renders them verbatim to operators, and "eg expires" is not decodable by a reader without codebase context. **They are not docs-only.** `make gen` propagates them to `coderd/rbac/object_gen.go` and `site/src/api/rbacresourcesGenerated.ts`, and `CreateEditRolePageView.tsx` renders the description next to each action in the custom roles editor. So this changes admin UI copy, and `CreateEditRolePageView.stories.tsx` means Pixel may now report a genuine snapshot diff on that component rather than the pre-existing failure noted below. The new wording matches the convention the rest of the table already follows (`ssh into a given workspace`, `create an AI Gateway key`), so this makes the UI more internally consistent, not less. Flagging it explicitly because a docs PR changing product copy deserves an owner's eyes rather than a silent merge. Happy to split it out if RBAC or frontend would rather own it, with the caveat that the reference page would then publish `eg expires` in the meantime. <details> <summary>CI note: Storybook / Pixel failure</summary> The `Storybook` check fails at its `Snapshot` step, and `Pixel / Review` reports `build failed` with no snapshots processed. **Updated:** this note originally said the branch touched no files under `site/`. That is no longer true. Correcting the RBAC policy description strings (CRF-24) required `make gen`, which regenerated `site/src/api/rbacresourcesGenerated.ts` alongside `coderd/rbac/object_gen.go`. That file is a generated string table with no rendered component behind it, so it still cannot account for a Storybook snapshot or Pixel build failure, but the original justification no longer holds and is replaced by this one. The failure predates that change: it was present when the branch genuinely had no `site/` diff. Every other check passes. </details> |
||
|
|
149366a459 |
feat: validate documented experiment keys (DOCS-139) (#29316)
## Summary
The docs name specific experiment keys wherever an individual
experimental feature is documented, and nothing verifies those keys
still exist in the code.
When an experiment is renamed or graduated, the enablement example keeps
telling operators to set a key the server no longer accepts.
This adds `scripts/checkexperimentkeys`, which fails when a key named in
`docs/**` is absent from `codersdk.ExperimentsKnown`, and wires it into
`make lint` as `lint/check-experiment-keys`.
**The data flows one way.**
The check reads keys the docs already name and validates them against
code.
It does not generate a page, add a manifest route, or write any key into
`docs/`.
That is deliberate: #29113 retired the generated feature-stage lists
because the team decided not to advertise which features are currently
experimental or beta.
A guard against stale keys is compatible with that decision; an index is
not.
The five key references the check currently guards are the per-feature
ones that decision left in place: `chat-advisor`,
`chat-virtual-desktop`, `auto-fill-parameters`, `agent-lifecycle-hooks`,
and `mcp-server-http`.
### Recognition rules
Only explicit enablement forms are matched: `--experiments=<key-list>`
and `CODER_EXPERIMENTS=<key-list>`, including every key in a
comma-separated list.
Values may be single- or double-quoted.
Explicit shell line continuations are joined before matching, preserving
the first physical line for a finding.
Bare identifiers in prose are ignored on purpose.
A check that guesses at prose produces false positives, and a check with
false positives gets deleted by the first person it blocks.
`*`, `feature1`, `feature2`, and angle-bracketed values are recognized
placeholders.
The recognized forms are documented in the script's README.
Known gap: the space-separated `--experiments <key>` form is not
matched.
No prose uses it today, so this is latent rather than broken, and
closing it is a small follow-up if the form reappears.
### Also fixed
`ExperimentMCPToolSearch` had no case in `DisplayName()`, so it rendered
as a title-cased guess in the product UI as well as anywhere else
display names surface.
`TestExperimentDisplayNames` now pins the display name of every known
experiment against an expected map, with a length assertion, so a new
experiment cannot silently fall back to the title-cased key.
## Verification
- `go test ./scripts/checkexperimentkeys ./codersdk` passes.
Coverage includes known and unknown keys, quoted values, shell
continuations, placeholders, multi-key lists, bare-prose exclusion, and
failure-output formatting.
- `golangci-lint run ./scripts/checkexperimentkeys/... ./codersdk/...`
reports 0 issues.
- `make lint/check-experiment-keys` is clean against current `docs/`.
- Negative control: a fixture containing
`CODER_EXPERIMENTS=not-a-real-key` exits 1 with the expected finding.
- The full `pre-commit` hook passes, including
`lint/check-experiment-keys` inside aggregate `make lint`.
<details>
<summary>History: the deferred lint wiring, now resolved</summary>
This PR previously landed the tool and a standalone `make` target while
leaving the one-line addition to aggregate `make lint` for a follow-up,
and stayed draft, because three documented `oauth2` keys were stale and
owned by another PR:
- `docs/admin/integrations/oauth2-provider.md:34`
- `docs/ai-coder/mcp-server.md:108`
- `docs/ai-coder/mcp-server.md:114`
#29268 merged on 2026-09-15 and removed all three in favor of
`CODER_OAUTH2_PROVIDER_ENABLE`.
The branch is rebased onto that, the check is green against `main`, the
wiring is folded into this PR, and the merge-order constraint recorded
as CRF-5 no longer applies.
The rebase also collided with `DisplayName()`, which gained new cases on
`main`.
Resolved in favor of `main`'s switch rather than this branch's earlier
map refactor, keeping the production diff to the one missing case and
moving the exhaustiveness expectations into the test.
</details>
<details>
<summary>Why this replaced a generated reference page</summary>
DOCS-139 originally asked for a generated
`docs/reference/experiments.md` listing every key in `ExperimentsKnown`.
That was built and opened as #29311, then closed without merging.
Commit
|
||
|
|
72e31ffb4c |
fix: prevent Prometheus metrics reference drift (#29314)
## Summary The Prometheus metrics reference merged scanner output with a hand-maintained file, and changes to the hand-maintained half could not fail CI. 66 of the 76 static families had no scanner coverage: four files sat in a skip list pending `WrapRegistererWithPrefix` support, and the `aibridge/` tree was outside the scan roots entirely. Rename or add a metric in any of them and `make gen` regenerated the page unchanged, so `check_unstaged.sh` passed while the published table quietly went wrong. The scanner now resolves the prefixes a registerer applies: - Indexes `WrapRegistererWithPrefix` and `NewMetricAliasRegisterer` call sites, resolving the prefix from a string literal or an imported constant. - Maps that prefix to the package whose constructor receives the wrapped registerer, covering the two shapes the codebase uses: a constructor that **forwards** its registerer to another package (`aibridge.NewMetrics` to `aibridge/metrics.NewMetrics`), and a collector **registered directly** against the wrapped registerer (`gatewayRegisterer.MustRegister(keypool.NewStateCollector(...))`). - Indexes only the canonical prefix of an alias registerer. The legacy `coder_aibridged_` and `coder_aibridgeproxyd_` aliases are deprecated per AIGOV-447 and should not be taught in the reference. With prefixes resolved: skip list deleted, `aibridge` added to the scan roots, and all 29 `coder_ai_gateway_*` families removed from the static file, which now holds only genuine externals (`go_*`, `process_*`, and metrics built dynamically). `enterprise/scaletest/agentfake` is excluded deliberately: its fake-agent metrics are not part of a deployment's surface, so documenting them would send operators looking for series they will never see. **Also fixes two extraction and merge gaps.** Label lists written as `append(baseLabels, "status", "route")` now resolve, and any unresolvable element returns no labels rather than a partial list. Static runtime-label overrides now replace generated labels only: generated name, type, and HELP remain authoritative. ## Verification The prefix-scanning refactor itself preserves the existing AI Gateway rows. However, the page is **not byte-identical** to `main` because this round fixes two already-published stale HELP strings. Its SHA-256 changes from `7ced1e7e9f2d4caf5e3b5e484ef4af14f955b8b4cd1a14fe81360bbdd49bb150` to `a68774275a3b21d5bae65024cc8ee65b52c51e52786c9aea45e3981e4e7f1643`. | Metric | Before | After | | --- | --- | --- | | `coderd_agentstats_connection_median_latency_seconds` | The median agent connection latency | The median agent connection latency in seconds | | `coderd_agentstats_startup_script_seconds` | The number of seconds the startup script took to execute. | Amount of time taken to run the startup script in seconds. | - `go test ./scripts/metricsdocgen/...` covers prefix resolution from a literal and imported constant, alias-registerer argument selection, collector registration, forwarder propagation, scan-to-emit prefix application, all-or-nothing label extraction, static-label merging, and the exclusion predicate. - `golangci-lint run ./scripts/metricsdocgen/...` and full `make pre-commit` pass. ## What this does not fix Ten metrics are still skipped for having no `HELP` text, with a warning to stderr rather than an error. Making that fatal means writing accurate descriptions for ten metrics in the agent and SSH server packages, which is a behavioral claim I would rather not guess at. Follow-up filed as DOCS-906. The scanner still uses package-level syntactic prefix inference. Broader validation of prefix scan roots, mixed registration within a package, and parameter-passed registerers belongs in DOCS-908 rather than this focused drift fix. <details> <summary>Local pre-push note</summary> The pre-push hook cannot run in this workspace: GNU Make 4.4.1 segfaults on the repo's `.SHELLFLAGS = $@ -ceu` configuration for a target named `test`, tracked in DOCS-903 with a minimal reproduction. I verified with the package tests, `golangci-lint`, and full pre-commit, and disabled the hook for this worktree only through its documented `git config coder.pre-push` knob, restoring it right after the push. No `--no-verify`. </details> --- Generated with Coder Agents on behalf of @nickvigilante. Linear: [DOCS-897](https://linear.app/codercom/issue/DOCS-897/metricsdocgen-static-metrics-file-can-go-stale-without-failing-ci) |
||
|
|
35abc22fa9 |
fix(scripts/aibridgepricesgen): drop claude-sonnet-5-5 bare ID injection (#30229)
The scheduled `aigateway-prices-refresh` workflow fails ([run](https://github.com/coder/coder/actions/runs/36840685231)) with `anthropic.claude-sonnet-5-5 now present upstream; drop the injection`. #30159 added an `overrides.jq` injection for the Bedrock ID `anthropic.claude-sonnet-5-5`, copied from `global.anthropic.claude-sonnet-5-5`, because models.dev only listed the global profile at the time. A few hours later, models.dev added the bare ID itself ([sst/models.dev#8417](https://github.com/sst/models.dev/pull/8417)) with the same pricing and limits, so the guard now fails the refresh. This removes the injection. `prices.json` is unchanged: the existing `anthropic.claude-sonnet-5-5` row now comes from upstream with the same values. Other upstream data drift is left to the workflow's own refresh PR. After merge, `aigateway-prices-refresh` will be rerun manually on `main` to open the refresh PR. > [!NOTE] > Created by Coder Agents on behalf of @ssncferreira. |
||
|
|
f1ed84ffab |
docs: author the sidebar in per-section YAML compiled to manifest.json (#30165)
## Summary The docs sidebar is now written as YAML files under `docs/manifest/`, one route and its direct children per file, and a new tool, `scripts/docsmanifestgen`, compiles them into `docs/manifest.json`. Moving two top-level sections is now a 2-line change in `docs/manifest/index.yml` instead of a diff of hundreds of lines in a 2,600-line JSON file. The compiled `docs/manifest.json` is byte-identical to `main`, so coder.com, docs-preview, deploy-docs, and offlinedocs need no changes. Refs [DOCS-1131](https://linear.app/codercom/issue/DOCS-1131/author-the-docs-sidebar-in-per-section-yaml-compiled-to) ## Changes - **Sources:** `docs/manifest/index.yml` holds `versions` and the section files in sidebar order. Each section file (`about.yml`, `admin.yml`, and so on) holds one top-level route. - **One level per file:** a file holds one route and its direct children. A child with children of its own, or with `children_from`, lives in its own file in a directory named after the parent file, and the parent lists it as `- include: admin/users.yml`. For example, `get-started.yml` includes `get-started/customize-your-template.yml`, which lists that page's children. The 8 section files split into 53 source files. - **`scripts/docsmanifestgen`:** `build` compiles the sources into `docs/manifest.json`, `fmt` formats them, and `check` validates them. - Keys must be known (a typo like `titel:` fails with a line number) and appear in a fixed order in both the YAML and the JSON. - Every `path` must exist, and every file under `docs/manifest/` must be referenced from `index.yml`, an `include`, or a `children_from`. - A grandchild in the same file fails with a message to move the child into its own file, and an `include` entry can't set other keys or name a file that is already used. - A comment on the same line as a `title` or `description` is rejected, because an unquoted ` #` would silently cut off the value. - **Generated fragments:** `clidocgen` and `apidocgen` no longer rewrite the manifest. They write the Command Line and REST API children to `docs/manifest/generated/*.json`, which the sources pull in with `children_from`. The tool accepts fragments as YAML or JSON. - The hand-written REST API descriptions and states moved into the YAML, attached to generated routes by title. A YAML entry that matches no generated route, or disagrees with one, fails the build instead of being dropped silently. - **Shared code:** loading, validation, and fragment merging live in `scripts/docgenenv/sources.go`, so the generators and the tool share one loader. `docgenenv.Route` gains YAML tags and the source-only `ChildrenFrom` and `Include` fields (`json:"-"`). `LoadManifest` is removed because nothing reads the compiled JSON anymore. - **Makefile:** - `docs/manifest.json` is built from the sources and fragments, which replaces the `_gen/manifest-staging.json` handoff. - Each fragment has its own rule, and the fragments are added to the `.PRECIOUS`, `GEN_FILES`, and `gen/mark-fresh` lists. - `DOCS_MANIFEST_SOURCES` finds the source files recursively. - New targets: `fmt/docs-manifest` (part of `fmt`), `lint/docs-manifest` (part of `lint`), and `gen/docs-manifest`, the quick path after a sidebar-only edit that skips regenerating the CLI and API fragments. - **`.gitattributes`:** marks `docs/manifest.json` and `docs/manifest/generated/*` as generated so GitHub collapses them in diffs. - **Guidance:** the content guidelines, the style guide, `DOCS_STYLE_GUIDE.md`, the `write-docs` and `doc-check` skills, `docs/README.md`, and `docs/tutorials/example-guide.md` now point to the YAML sources instead of `docs/manifest.json`. ## Testing - Split today's `docs/manifest.json` into the sources, rebuilt it, and confirmed the output is byte-identical to `main`. After splitting the sources to one level per file, the rebuilt `docs/manifest.json` and a fresh `clidocgen` CLI fragment were still byte-identical, and `LoadManifestSources` still finds the REST API and Command Line routes through their includes. After rebasing onto `main`, both commits rebuild `main`'s `docs/manifest.json` byte for byte. - Hand-edited `docs/manifest.json` and a YAML source, then rebuilt: the YAML change persisted and the JSON edit was overwritten. CI's `make -B gen` plus `check_unstaged.sh` fails on a committed hand edit to the JSON. - Deleted both fragments and ran `make docs/manifest.json` in a fresh worktree, which regenerated them through swag and `clidocgen`. `docs/manifest.json`, the fragments, and every generated CLI and API page had no diff. - Swapped User Guides and Administration in `index.yml`: 2 changed lines in the source, 166 generated lines in `docs/manifest.json`. Swapping back restored the file exactly. - `go test` for `scripts/docgenenv`, `scripts/docsmanifestgen`, `scripts/clidocgen`, and `scripts/apidocgen/postprocess`. The new tests cover merging, includes, every validation error, idempotent formatting that keeps comments, and a check that the key order matches the struct field order. - `golangci-lint` on the changed packages, and the full `make pre-commit` hook (gen, fmt, lint including `lint/docs-manifest`, and the slim build). ## Notes - Open PRs that edit `docs/manifest.json` will need to redo their sidebar changes in the YAML sources after this merges. - #30161 (merged) stopped escaping `&`, `<`, and `>` in `docs/manifest.json`. This PR carries that over: all manifest JSON escaping is in `docgenenv.MarshalJSON`, which sets `enc.SetEscapeHTML(false)`, and `Manifest.Marshal` from #30161 is gone because the generators no longer write the manifest. - #30129 (merged) flattened `admin/external-auth/index.md` and `ai-coder/agents/tools/index.md` to single files, and the YAML sources use the new paths. - The CLI index and REST API page front matter still update only on a full `make gen` when their sidebar metadata changes, as it did before. That gap and the overall cost of `make gen` are tracked in [DOCS-1141](https://linear.app/codercom/issue/DOCS-1141/reduce-the-compute-cost-of-make-gen). <details> <summary>Decision log</summary> ### Goal Make the sidebar easy to reorder and hard to break, with strict key order and YAML sources, while keeping `docs/manifest.json` as the file downstream systems read. ### Jsonnet vs. a custom tool Jsonnet was evaluated first and rejected, based on tests against go-jsonnet v0.22.0: - Jsonnet always sorts object keys alphabetically, and there's no option to keep them in order (`preserve_order` isn't a parameter of `manifestJsonEx` or `objectFieldsEx`). Passing today's manifest through Jsonnet and then biome changed 2,114 of 2,478 lines. - Unknown keys pass through silently, so a `titel:` typo ends up in the output. - The sources would be `.jsonnet` files, not YAML. Reading YAML takes `std.parseYaml(importstr ...)`, and the keys still come out sorted. - Restoring key order would need a Go step after Jsonnet anyway, and that step is most of this tool. Decoding YAML into Go structs with yaml.v3 (already a dependency) gives key order from the struct, rejects unknown keys, keeps comments, and reproduced the current manifest byte for byte. ### Design choices - **Ordered by `index.yml`:** reordering sections touches only the index. - **One route and its direct children per file:** every file stays short and flat, so a subsection can be found, reviewed, and moved as one file. Files nest by parent file name rather than by docs path, so the directory tree matches the sidebar tree. Include paths are relative to `docs/manifest/`, like `children_from`, so every reference to a file is spelled the same way. A child with `children_from` also gets its own file, so the rule has no exceptions. - **Generated subtrees in their own fragments:** the generators can't safely rewrite hand-edited YAML, so they own separate files. Hand-written metadata for generated routes lives in the YAML, attached by title, so descriptions never live in a generated file. - **Key order enforced in both sources and output:** `fmt` rewrites the sources, `check` fails on unformatted sources, and the output order comes from the `docgenenv.Route` field order. - **`&` left unescaped:** the output matches `main` after #30161, which stopped escaping `&` downstream. - **`gen/docs-manifest` separate from `fmt`:** keeping manifest assembly out of `fmt` means `make -j gen fmt` never has two jobs writing `docs/manifest.json` at once. - **YAML pitfalls:** unquoted `no` and `123` stay strings because the fields are typed as strings, an unquoted `: ` is a parse error, and the silent ` #` truncation is rejected by the comment check. ### Out of scope - Replacing `&` with "and" in titles (a style question). - Reducing the cost of `make gen` (DOCS-1141). </details> --- _This PR was generated by Coder Agents on behalf of @nickvigilante._ |
||
|
|
0ce91ffc18 |
fix: stop escaping ampersands in docs manifest titles (#30161)
Closes DOCS-1139.
Go's `json.MarshalIndent` escapes `&`, `<` and `>` for HTML safety, so
both docs generators wrote titles like "Licensing & usage" into
`docs/manifest.json` as `Licensing & usage`. The two forms decode
identically (the offline docs site reads the file with `JSON.parse`),
but the escaped form reads like a bug in review, and a hand-typed `&`
flipped back on the next `make gen`.
Add `Manifest.Marshal` in `scripts/docgenenv`, which disables HTML
escaping, and use it from `clidocgen` and `apidocgen/postprocess`. The
two titles in `docs/manifest.json` that still carried the escape are
updated to match. A unit test covers the unescaped output and the round
trip through `LoadManifest`.
Testing: `go test ./scripts/docgenenv ./scripts/clidocgen
./scripts/apidocgen/...` passes. I ran `clidocgen -manifest-only`
against a copy of the manifest and confirmed the output has no escapes
and parses to the same content as the committed file. I did not run the
full `make docs/manifest.json` (it needs the site dependencies and
Biome), so the committed file keeps its existing Biome formatting.
cc @ianjevans for awareness.
---
🤖 Built with AI assistance.
|
||
|
|
fc0af7fbd8 |
feat: open a chat_turn span per prompt (#29771)
**TL;DR:** Wraps each prompt in a `chat_turn` root span with every lifecycle stage parented under it. The span records one outcome per turn (`completed`, `interrupted`, `error`, `abandoned`), and the new `coderd_chatd_turn_outcomes_total` counter counts those outcomes. Turns stay correct when tasks are canceled, replaced, or retried. Each prompt runs inside a `chat_turn` root span owned by the runner (`runnerTurnSpan`). The generation step, prepare, MCP connect, stream, TTFT, provider attempt, commit, thinking, tool call, compaction, and retry backoff stages are parented under it, activating the stages from #29770. `chat_turn` spans are standalone roots: the turn runs on a worker, often on another replica, and no trace context is persisted. **Lifecycle** - **Start.** Each generation loop iteration calls `Ensure`, which opens the turn if none is open and returns a `turnToken`. The span is backdated to the trigger: the latest of the last user prompt, a dynamic tool's result message after it, and a pending compaction request. An `acquisition` stage covers trigger to pickup. - **Stale trigger / takeover.** A trigger at or before the previous anchor opens the turn at now with no `acquisition` and counts `stale_anchor`. A runner that took the chat over from an owner with a stale heartbeat (`TakenOver`, from acquisition) opens its first turn at now with no `acquisition`, so the dead owner's run is not reported as pickup delay. - **Newer prompt.** `Ensure` on the current turn with a newer trigger closes it and opens a new one. The closed turn is `abandoned` unless the task that ran it records an outcome before releasing it. - **Finish.** After `FinishTurn` or `EnterRequiresAction` commits, the step calls `Complete`; `Settle` closes the span after the step's own stage ends, so the finishing step is inside the turn. A chat waiting in `requires_action` is outside any turn; the generation resumed by its tool results opens a new one. - **Emission.** Closing a turn fixes its end time; its span is emitted once every task that joined it (`Ensure` takes the task ID) has called `Release`, which `runTask` does after the task returns. A finishing task whose `FinishTurn` promoted a queued prompt therefore still counts its turn as `completed` even when the promoted task's `Ensure` runs before its `Complete`. `End` at runner exit emits whatever is left. - **Failure.** A step that commits `FinishError`, or fails closed, invalidates the turn as `error` after the commit. Errors the task runner retries, including task timeouts, keep the same turn open; an expected, non-retryable exit records no outcome and leaves the turn open until the interrupt task, a newer prompt, or runner exit closes it. A canceled generation task records no outcome and cannot obtain a turn token, so a replaced task never touches its successor's turn. - **Interrupt.** The interrupt task marks the open turn `interrupted` before `FinishInterruption` commits and closes it after. Only a stop (by the user or a parent agent) is `interrupted`; it ends with unset span status, since error status is reserved for `error` turns. runner shutdown, loss of ownership, and message edits close the turn as `abandoned` with unset status. - **Promotion.** Every promoting transition (`FinishTurn`, `FinishInterruption`, a send to an errored chat, `PromoteQueued`) returns the promoted message's queued time in its result, and one `recordQueueWait` helper records a standalone `queue_wait` to the promotion. The promoted turn opens at the promotion time. `chat_turn` is observed on `coderd_chatd_stage_duration_seconds` only for completed turns, so the histogram is completed-turn latency; every turn still emits its span. `coderd_chatd_turn_outcomes_total{outcome, chat_kind}` counts every closed turn exactly once (`completed`, `interrupted`, `error`, `abandoned`), matching the span's `turn_outcome`, under the `chat-stage-metrics` experiment. Turn time accounting is in draft #29772. **Stages and identity** - `tool_call` is a live stage around each local tool call in `chatloop`; the tool runs on its context, and it ends errored only when the tool fails to execute. Calls that never run (inactive, unknown, or rejected by policy) record no stage. - `mcp_connect` carries connected and failed server counts and ends errored only when servers were configured and none connected. - The compaction stage carries the model that runs the summary. - `withStageIdentity` puts scope and chat kind on the turn context. Detached background work runs in `background` scope as its own trace roots. - The `advisor` tool's nested model call appears only as its enclosing `tool_call`. ARCHITECTURE.md gains a "Lifecycle tracing" section. <details> <summary>Review decisions</summary> - Turn identity stays timestamp-based with targeted fixes (clamped acquisition, rotation on a newer trigger, invalidate after commit, fail-closed invalidation, settle closing invalidated turns) plus a takeover flag; keying turns on message IDs would not detect takeover and cannot express interrupted/abandoned outcomes. - Outcome classification: the interrupt task owns `interrupted`, and cancellation or a fence mismatch alone never records an outcome, so shutdown, ownership loss, and edits are `abandoned`. Only `error` turns set error span status. Remaining ordering races between a step and an interrupt are documented as known limitations in ARCHITECTURE.md. - Turns are emitted after the tasks that ran them return, not when they close, so an outcome a replaced task records while unwinding reaches its own turn; the successor task is not delayed. Chosen over an after-commit, pre-publish hook on `ChatMachine.Update`, which would fix only the `FinishTurn` ordering. - `requires_action` ends the turn rather than pausing it, so `chat_turn` measures chatd time; a prompt with client tools counts as several turns. - Promoted turns anchor at promotion time and `queue_wait` is always standalone, so `chat_turn` never includes time spent queued behind another turn. - The former `capacity_wait` stage (#29805) was dropped: it was a per-worker lower bound, excluded from accounting, and needed its own SQL and bookkeeping. #29805's remaining helpers are folded into this PR. </details> Supersedes #28972, #28973, and #29805. 🤖 This PR was generated by Coder Agents on behalf of @jscottmiller. |
||
|
|
e988ddb11d |
feat: trace chatd provider stages and count only output parts as first token (#29770)
**TL;DR:** Traces the model provider call: a `stream` stage, a nested `time_to_first_token` stage, and one `provider_attempt` per HTTP round trip, labelled with provider type and model. Behavior change: `coderd_chatd_ttft_seconds` now counts only a real output part as the first token, so error, warning, and finish parts no longer count. Instruments the provider call. **Stream and time to first token.** `GenerateAssistant` records a `stream` stage from stream open to close and a nested `time_to_first_token` stage. The TTFT window closes once, on the first streamed output part: any part other than warnings, finish, or error, including start markers such as `text_start`. A closed window observes the stage and the pre-existing `coderd_chatd_ttft_seconds` with the same elapsed time. A failed open, an error part, or a release without an output part ends the TTFT span with the error (a silence timeout is classified as such) and observes nothing. The `stream` span ends once, with the error `GenerateAssistant` returns, so content-filter and no-output attempts end errored. Failed `stream` windows are observed like successful ones. The attempt is released before the stream span ends, so the TTFT window always falls inside its stream. The compaction summary stream passes a nil tracer, so it records neither. Without #29771, production emits only `provider_attempt`; #29771 passes the tracer to `GenerateAssistant`. **Provider attempts.** The provider HTTP transport is wrapped in `stageSpanRoundTripper`, which emits one `provider_attempt` stage per round trip, so retries each get a span. The span closes on response headers; a status >= 400 marks it errored without changing what the client sees. `resolveModelCall` resolves the `StageModel` (wire provider, configured `provider_type`, model, effective reasoning effort) and threads it to the transport, so span attributes and labels match the call. `provider_type` is read from `ai_providers.type`, so types outside the fantasy set (copilot) keep their configured name. `chatd.New` builds the tracer with the server clock. **Behavior change to `coderd_chatd_ttft_seconds`:** only an output part counts as a first token. Error parts no longer close the window as a success, and warnings and finish parts are skipped; the help text says so. `StageSpan.End` returns the span's elapsed window, which `ttft_seconds` observes. Callers pass `Stages` and `StageModel` through `GenerateAssistantOptions`; a nil tracer discards (TTFT still records `ttft_seconds`). `Server` gains the `stages` tracer and a `TracerProvider` option, wired from `coderd`. <details> <summary>Review decisions</summary> - Start markers close the TTFT window: they are the first sign the model is producing output, and waiting for a delta would fold hidden reasoning time into TTFT. - Failed `stream` and `provider_attempt` windows are observed: that time was spent. TTFT is the exception because a first token that never arrived has no duration. - `http_host` was dropped from `provider_attempt`; every request goes through the local AI Gateway transport, so it was constant. - The advisor tool's nested model call is intentionally not instrumented as `stream`/TTFT. </details> Supersedes #28970 and #28971. 🤖 This PR was generated by Coder Agents on behalf of @jscottmiller. |
||
|
|
7a9442014e |
feat: add chatd lifecycle stage tracer (#29769)
**TL;DR:** Adds a stage tracer that turns each chat lifecycle stage into
both an OpenTelemetry span and a Prometheus histogram observation, so
traces and metrics always agree. The metrics are only registered with
the `chat-stage-metrics` experiment. Nothing calls the tracer until the
next PRs.
Adds `chatloop.StageTracer`, which emits each chat lifecycle stage as an
OpenTelemetry span and a `coderd_chatd_stage_duration_seconds{stage,
scope, chat_kind}` observation from one `End` call, so trace and metric
durations cannot disagree. The provider-bound stages (`stream`,
`provider_attempt`) are also observed on
`coderd_chatd_model_stage_duration_seconds{stage, provider_type,
chat_kind, model}`, the only family carrying `provider_type` and
`model`, and only for turn-scoped stages. Time to first token per model
stays on the existing `coderd_chatd_ttft_seconds`. Nothing calls the
tracer yet; the next PRs instrument the provider call and the runner.
- The families are registered only when the `chat-stage-metrics`
experiment is enabled (safe and known, so
`--experiments=chat-stage-metrics` or `--experiments=*` turns it on).
Spans are emitted regardless. `NewMetrics` leaves the families off;
`chatd.New` opts in from the experiment, and a test asserts the
experiment decides whether they reach the server's registry.
- `Stage`, `Scope`, `ChatKind`, and `StageAnomaly` are typed string
constants. `scope` separates latency attributable to a prompt (`turn`)
from detached `background` work; `chat_kind` is `root` or `subagent`,
empty without a known chat.
- `StageModel` carries the wire `provider`, `provider_type`, `model`,
and `reasoning_effort`. All are span attributes; only `provider_type`
and `model` are metric labels, on the model family. No family carries an
organization label.
- Observed stages: `chat_turn`, `queue_wait`, `acquisition`,
`mcp_connect`, `stream`, `time_to_first_token`, `provider_attempt`,
`tool_call`, `commit`, `retry_backoff`. `generation_step`, `prepare`,
`thinking`, and `compaction` are span-only. A test keeps the stage sets
and help text consistent.
- API: `Start` / `StartRootAt` for live spans (span timestamps come from
the tracer clock), `Record` for stages reconstructed from timestamps
(the scope comes from the context). `End` is idempotent;
`EndWithoutObservation` ends the span without a sample. A nil tracer,
provider, or metrics discards.
- `coderd_chatd_stage_anomalies_total{reason}` counts observations
dropped, adjusted, or inconsistent (`negative_elapsed`,
`inverted_window`, `missing_timestamp`, `future_start`, `stale_anchor`).
Span-only stages never feed it.
- Buckets are 12 round edges (`0.1 0.25 0.5 1 2.5 5 10 30 60 300 1800
3600`).
- Moves the body of the `for` loop in `StartGeneration` into
`runGenerationStep` so the step has a function boundary for a deferred
stage end. Control flow and error wrapping are unchanged.
<details>
<summary>Series cost (approximate, whole stack)</summary>
A histogram label set is 12 edges + `+Inf` + `_sum` + `_count`: 15
series. Per replica, each `chat_kind` costs about 150 stage series and 4
turn outcome counters; each `(chat_kind, model)` costs 30 (2 stages x
15). Both chat kinds on `M` models: about `308 + 60*M` per replica, plus
background-scope stage series.
Dogfood `main`, 3 replicas: ~3.4k `coderd_*` series per replica (~10.1k
total).
| Models used per replica | Added series (3 replicas) | vs. baseline |
|---:|---:|---:|
| 1 | ~1.1k | +11% |
| 5 | ~1.8k | +18% |
| 10 | ~2.7k | +27% |
| 35 | ~7.2k | +72% |
Most deployments run four or fewer models, so a typical replica adds
roughly 370 to 550 series. The experimental turn accounting in #29772
would add 88 more per replica (11 categories x 4 outcomes x 2 chat
kinds). Series appear lazily and do not grow with organizations.
</details>
<details>
<summary>Review decisions</summary>
- Experiment gate only; no deployment flag or metric levels. If the
experiment graduates, the families become always on like the other chatd
families; a flag is added then only if dogfood shows a cardinality
problem.
- Organization is on neither metrics nor spans, and `effort` is
span-only; `provider_type` (configured type), not the wire `provider`,
is the model-family label.
- `time_to_first_token` is not on the model family; per-model TTFT is
`ttft_seconds`, which observes the same measured window.
- The model family records only turn-scoped stages.
- Nil guards are kept so a nil or zero tracer is always safe to call.
- HTTP attribute keys stay snake_case like the rest of the chatd span
attributes.
</details>
Supersedes #28968 and #28969.
🤖 This PR was generated by Coder Agents on behalf of @jscottmiller.
|