Commit Graph
802 Commits
Author SHA1 Message Date
Ethan feea5ab959 feat: add GPT-6.2 Astra and GPT-6.2 Sol to Agents and AI Gateway (#32370)
Closes CODAGT-1608

This adds `gpt-6.2-astra` and `gpt-6.2-sol` to the Agents known models
catalog, so they're suggested when an admin adds a chat model, and
regenerates the AI Gateway price book from models.dev so the gateway can
price them.

| Model | Input | Output | Cache read | Cache write |
|---|---|---|---|---|
| GPT-6.2 Astra | $8 | $40 | $0.40 | $10 |
| GPT-6.2 Sol | $2 | $10 | $0.10 | $2.50 |

Prices are per 1M tokens, and both models have a 1,050,000 token context
window and 128,000 max output tokens. They're in the catalog for OpenAI
(with a suggested effort of `medium`, same as `gpt-6-astra` and
`gpt-6.1-sol`), OpenRouter and Vercel. models.dev doesn't list them on
Azure or Bedrock yet, so I've left those out for now.

Both models also reject the `none` and `minimal` reasoning efforts. A
model config only sets a default and a maximum effort, so the picker
always offers both, and picking either one fails the turn:

```
Unsupported value: 'none' is not supported with the 'gpt-6.2-astra' model. Supported values are: 'low', 'medium', 'high', 'xhigh', and 'max'.
```

We already send `low` instead for `gpt-6-astra` and `gpt-6.1-sol`, so to
fix, we'll just do the same for the two new models. All four now live in
one list of model ID prefixes, rather than a helper each. I checked this
against the real models: all four return a 400 like the one above for
`none` and `minimal`, and accept `low`. `gpt-6-sol` and `gpt-6.1-terra`
still accept `none`, so they're left alone.

Regenerating the price book also brings in everything else models.dev
changed since the last weekly refresh, mostly on OpenRouter and Vercel:
22 other new entries (4 of them `-pro` and `-fast` variants of these
two), 29 it dropped and 51 price changes. 6 existing catalog entries get
new prices or limits the same way.
2026-11-19 00:33:46 +11:00
Dean Sheather d974fefc08 chore: sign with github.com/coder/gpgkms instead of scripts/gpgkms (#32308)
Replaces `scripts/gpgkms` with
[`github.com/coder/gpgkms`](https://github.com/coder/gpgkms) v0.2.0, the
same code extracted into a shared module (terraform-provider-coder
already signs its releases with it). v0.2.0 also rejects keys that
aren't HSM-backed (`gpg-release` is `HSM`, and the check reads
`protectionLevel` from the existing `GetPublicKey` call, so no new IAM
is needed), limits each KMS request to a minute, and writes `-out`
atomically.

- `go.mod`: gpgkms is a `tool` dependency, so the version is pinned in
`go.mod`/`go.sum` and Dependabot keeps it current. This bumps go-crypto
1.4.1 → 1.5.2, google.golang.org/api 0.308.0 → 0.311.0 and circl 1.6.3 →
1.6.5, plus a few indirect dependencies. go-crypto is now only indirect:
nothing else in coder/coder imports it.
- `scripts/gpgkms.sh` (new): runs it with `go tool` (like
`scripts/format_go_file.sh` does for gofumpt and gci), passing the
release key's OpenPGP identity (name, email, creation time, 4-year
lifetime). The library takes these as flags instead of hardcoding them,
so they now live in one place.
- It also pins `-fingerprint 0F685EFE0AE5A8182A473DD86E3A8E5613707520`,
so signing and `public-key` fail if the KMS key or creation time ever
change. That's the fingerprint every current main build prints (e.g. run
44031030839), and I recomputed it from the KMS public key and the
creation time alone, without signing anything. The fingerprint doesn't
cover the user ID or lifetime; the equivalence check below does.
- `scripts/sign_with_gpg.sh` and the "Print GPG KMS public key" step in
`build.yaml` call the wrapper instead of `./scripts/gpgkms`. Signatures
stay armored `.v2.asc` files, as before.
- `scripts/gpgkms/` is deleted.

## Same key, same signatures

The OpenPGP key's fingerprint depends on these exact inputs, so I
checked that nothing changed. With a local RSA-4096 key standing in for
KMS, the deleted `newEntity`/`writePublicKey`/`sign` produce the same
output as the gpgkms CLI with the flags read out of `scripts/gpgkms.sh`:

- The public key is **byte for byte identical**.
- A signature with `-prepend` is armored the same way and has the same
length (only the timestamp differs). Both the prepended signature and
the KMS signature verify in both outputs.
- Changing the lifetime in the wrapper by one hour makes the comparison
fail, so the check is sensitive.

```
$ git -C gpgkms describe --tags
v0.2.0
$ WRAPPER_ARGS_FILE=wrapper-args.txt go test ./cmd/gpgkms -run TestCoderWrapperMatchesOldCoderCode -count=3 -v
=== RUN   TestCoderWrapperMatchesOldCoderCode
    equiv_coder_test.go:40: wrapper args: ["-name" "Coder Release Signing Key" "-email" "security@coder.com" "-created" "2026-11-16T00:00:00Z" "-lifetime" "35040h"]
--- PASS: TestCoderWrapperMatchesOldCoderCode (0.33s)
--- PASS: TestCoderWrapperMatchesOldCoderCode (0.11s)
--- PASS: TestCoderWrapperMatchesOldCoderCode (0.20s)
ok  	github.com/coder/gpgkms/cmd/gpgkms	0.634s

# with -lifetime 35041h
    equiv_coder_test.go:56: public keys differ:
FAIL

# with the wrapper's -fingerprint pin and a random test key
    derived key has fingerprint 9794B34B5E098DE61DD6CE247E0DFD4BF203C917, want 0F685EFE0AE5A8182A473DD86E3A8E5613707520 (wrong -key, -created or KMS key?)
```

(The byte-for-byte comparison runs without `-fingerprint`, since the
test key is random.)

gpgkms also has its own compatibility test against this identity
(`compat_test.go`).

Other checks:

```
$ ./scripts/gpgkms.sh public-key                 # from the repo root (build.yaml)
gpgkms: -key is required
$ cd scripts && ./gpgkms.sh public-key           # from scripts/ (build_go.sh -> execrelative)
gpgkms: -key is required
$ ./gpgkms.sh sign -key x -prepend ../no-such-file -out o.asc ../go.mod   # relative paths resolve from the caller
gpgkms: read prepend signature: open ../no-such-file: no such file or directory
$ shellcheck -x scripts/gpgkms.sh scripts/sign_with_gpg.sh   # clean
$ shfmt -d scripts/gpgkms.sh scripts/sign_with_gpg.sh        # clean
$ actionlint .github/workflows/build.yaml                    # clean
$ go build ./... && go mod tidy -diff                        # clean
```

Not run here: real signing through Cloud KMS. The first main build after
merging prints the public key in the job summary; it should be identical
to the one printed by current main builds.

---

AI disclosure: this PR was written by an AI coding agent (Xum) at my
direction, and the agent ran the verification above. It stays a draft
until I've reviewed it.
2026-11-18 15:36:57 +11:00
Dean Sheather 368fddf1d6 feat: deploy dogfood by pulled digest instead of CI push (#32253)
Switches dogfood from push-based deploys to pull-based, digest-pinned
deploys with Flux image automation (SEC-863):

- **Remove the push deploy.** Deletes `deploy.yaml` and
`scripts/should_deploy.sh`, and drops the `deploy` job from
`build.yaml`. CI no longer assumes the AWS deploy role, fetches EKS
credentials, runs `flux reconcile` or `kubectl rollout restart`, or
retags `:dogfood`, which nothing consumes. `build.yaml` now has no
cluster access, and only the signing job's existing `id-token: write`
remains.
- **`coder.image.digest`** in the `coder`, `provisioner` and
`ai-gateway` charts. When set, the image renders as `repo:tag@digest`.
Empty (the default) keeps today's output, and existing golden files are
unchanged.
- **Sortable main tag.** `build.yaml` pushes an extra `main-<commit unix
time>-<12 char sha>` tag for every main build, which the Flux
`ImagePolicy` orders on. The `prune` job already prunes `^main-` tags
older than 30 days.

Companion PR: coder/dogfood#857, which installs the image controllers
and pins dogfood-cdr by digest. **Merge this one first**: the ai-gateway
chart's schema rejects unknown keys, so dogfood's new `digest` value
would fail on the current chart.

Merging this before dogfood#857 doesn't regress anything. The
`dogfood-coder-repo-ci` role's trust was disabled during containment, so
the deploy job currently fails at OIDC role assumption on every main
build and only sends a failure alert to Slack. Until dogfood#857 is
live, dogfood stays on its current image.

<details>
<summary>Design notes and decision log</summary>

- **Delete the deploy instead of keeping a Flux webhook ping.** A ping
would only cut latency. Flux scans the registry every 2m, so any trigger
can be added later as a notification-controller `Receiver` without
giving CI cluster credentials.
- **Separate digest value instead of `tag: x@sha256:...`.** Flux's
`:tag` and `:digest` setters write separate fields, and no setter writes
`tag@digest` into a single field. A dedicated chart value is the
documented Flux pattern for HelmReleases and is useful to customers who
pin by digest.
- **Commit timestamp in the tag.** `git log -1 --format=%ct` makes the
tag sort by commit time, which Flux's `numerical` policy selects on. The
sha suffix keeps tags unique and traceable.
- **Not done here:**
- Making the cosign and GitHub attestation steps required. They're still
`continue-on-error`. Admission-time signature verification is a separate
SEC-863 step.
- Removing the AWS role itself and the `AWS_DOGFOOD_*` repo variables.
Those are settings outside the repo, and they become unused once this
merges.

</details>

Verified: `go test ./helm/...`, `make lint/helm`, `make lint/actions`. I
also rendered the dogfood-cdr values against this branch's charts, and
the server, provisioner and ai-gateway images all come out as
`ghcr.io/coder/coder-preview:<tag>@sha256:<digest>`.

Refs SEC-863

> Generated by Coder Agents on behalf of @deansheather.
2026-11-16 21:38:23 +11:00
Dean Sheather b0a66bd878 ci: build and sign main and releases with a shared build-coder action (#32229)
> [!NOTE]
> Generated by Coder Agents on behalf of @deansheather.

Main builds and releases now build and sign through one shared composite
action, so they can't drift apart. PR builds use the same action
unsigned, in a job with no environment, so they can't reach signing
secrets or identities.

Depends on coder/gcp#343, which must merge first. The `release-signer`
identity provider only accepts tag-dispatched releases and `ci.yaml`.
Since #32211 made that login unconditional, releases and non-push main
runs already fail today.

## Changes

- **`.github/actions/build-coder` (new):** tool setup, then `make` for
the given targets. With `sign: true` it signs darwin binaries with the
Apple key in Cloud KMS, Windows binaries with EV, and everything with
GPG (the legacy key plus the optional KMS key). With `notarize: true` it
also notarizes. Composite actions can't read secrets, so callers pass
them in.
- Signing material goes in a `$RUNNER_TEMP/coder-signing` directory with
mode 700 and is removed with `if: always()`.
  - Signing builds disable the mise, pnpm and rcodesign caches.
- KMS signing no longer checks the event or ref. If the provider rejects
a run, the build fails loudly.
- **`.github/workflows/build.yaml` (new):** the signed main and
`release/*` build, moved out of `ci.yaml`.
- Triggers: `push` to `main` and `release/*` (ignoring the same
docs-only paths as `ci.yaml`'s `changes` filter), plus `create` for
`release/*`. No `pull_request` or `workflow_dispatch`. Top-level
`permissions: {}`.
- The `build` job runs in `ci-signing`. It builds and signs, pushes
`coder-preview` tags, then runs SBOM, image attestations and binary
attestations (new), and uploads artifacts.
- `prune` runs `action-ghcr-prune` in its own job, away from the signing
credentials.
- `deploy` calls `deploy.yaml`. `notify-slack-on-failure` covers build,
prune and deploy failures on main.
- **`ci.yaml`:**
  - The `build` and `deploy` jobs are removed.
- `check-build` now runs `make build-slim` through the action, unsigned.
That compile-checks all 7 OS/arch targets without the frontend and fat
builds.
  - `check-build` also runs when CI files change.
- **`release.yaml`:**
- Builds and signs through the action with `notarize: true`. Tagging,
base image, images, attestations and publishing are unchanged.
  - The `refs/tags/*` KMS gate is removed.
- The publish step now reads the `release-signer` credentials from the
action's output.
- **Hardening on top of #32211:**
- `install-rcodesign` gains a `use-cache` input, which signing jobs set
to `false`. Depot caches are shared across branches, so a PR could
otherwise plant a binary under the cache key that a signing job would
run with signing credentials.
- `cargo install --locked` pins rcodesign's dependency tree. I verified
the lockfile resolves with the patch at the pinned revision.
- `sign_darwin.sh` takes `AC_PKCS11_CREDENTIALS_FILE` and sets
`GOOGLE_APPLICATION_CREDENTIALS` only for `rcodesign`. The
`release-signer` credentials no longer reach the whole `make` step.
  - The jsign jar is now verified against a pinned sha256.

## Validation

- `make lint/actions/actionlint` passes. zizmor (offline, strict
collection) reports no findings. shellcheck passes on every `run` block
in the composite actions.
- I dry-ran the signing-material and target-parsing logic locally. The
kmsp11 config renders correctly and files are mode 600. Multi-line
targets parse correctly.
- Not run: a real signed build. The first main run after merge should
show `.asc` and `.v2.asc` files, rcodesign and jsign output,
`coder-preview:main` pushed and dogfood deployed. A release dry run from
`main` covers `release.yaml` once #56 lets the `release` environment run
on `main`; release branches still carry the old `release.yaml`.

## Follow-ups (manual)

- After the first successful signed main build and release, delete
`AC_CERTIFICATE_P12_BASE64` and `AC_CERTIFICATE_PASSWORD`.
- The Rust toolchain is still whatever `stable` the runner has.
Rebuilding rcodesign without the cache adds a few minutes to each signed
build.

The `release` environment changes and the release-branch `ci.yaml`
signing are handled in coder/github-org-terraform#56 and coder/gcp#343.

## Merge order (all 8 PRs)

coder/gcp applies on merge, so the order matters.

1. coder/github-org-terraform#56: the `code-signing` environments, tag
rulesets, and coder/coder `release` and `release-publish` allowing
`main`. This must be applied before an RC can be dispatched from `main`.
2. coder/gcp#343, then coder/coder#32229 right after. Signed `ci.yaml`
builds on `main` fail between those two. `release/2.37` to `2.39` keep
signing through `ci.yaml` under #343's temporary rule until 2027-02-16.
3. coder/coder-desktop-windows#192, coder/mutagen#19, coder/pr-buddy#69
and coder/xum#8170.
4. coder/gcp#347. Windows signing in those 4 repos breaks if this lands
before step 3.

<details>
<summary>Plan and decision log</summary>

**Goal:** main and `release/*` pushes build coderd fully, sign
everything (EV, Apple, GPG and KMS GPG) the same way releases do, push
`coder-preview`, and deploy dogfood. PRs get a compile check with no
signing access.

**Verified constraints:**

- Signing secrets exist only in the `ci-signing` and `release`
environments. There are none at the repo or org level.
- `ci-signing` allows `main` and `release/*`. `release` requires
`release-managers` with self-review prevented, and admins can't bypass.
- `ev-code-signing` (coder-ci) and `release-signer`
(coder-release-signing) are bound only to the `environment:ci-signing`
and `environment:release` subjects.
- The `release-signer` provider condition checks `job_workflow_ref`. A
reusable workflow would change that claim, so the shared code is a
composite action that runs inside the caller's job. This also keeps the
release job as a single job, with no artifact handoff between build and
publish.

**Decisions:**

- The new workflow is named `build.yaml`.
- There is no cutover period, so the provider names only `build.yaml`.
- Main builds are signed identically to releases. Only notarization and
publishing differ, because main doesn't build darwin archives.
- `release/*` still gets `coder-preview:release-X.Y` images.
- PR `check-build` builds slim binaries only, which keeps the
cross-compile coverage at a fraction of the cost.

</details>
2026-11-16 20:11:05 +11:00
Jon Ayers 74a4a98bba fix(scripts/releaser): render calendar separator at full column width (#32236) 2026-11-16 00:07:17 -06:00
Jon Ayers a8ed5a1b65 ci: sign darwin binaries with an Apple signing key in Google Cloud KMS (#32211) 2026-11-15 20:19:24 -06:00
coder[bot] b83a339e03 chore: add optional Cloud KMS dual signing for release GPG signatures (#32209) 2026-11-15 19:58:21 -06:00
Kyle CarberryandClaude Opus 5.5 12766eca93 ci: create release tags and branches with the release App after approval (#32212)
## Summary

**Unblocks releases after the `coder/coder` lockdown.** Only the
`coder-release-publisher` App can now create tags and release branches
(rulesets "Release tags (App only)" and "Release branch creation",
managed in `coder/github-org-terraform`). Its key is only available in
environments that need a **second release manager's approval**
(`release-managers`, no self-review, no admin bypass). People can't push
release tags anymore, so the tag is now created **inside the approved
release run**.

### Releasing (`./scripts/release.sh` works as before, minus one step)

1. Run `./scripts/release.sh` on `release/X.Y` (or `main` for an RC), as
today. It still picks the version, checks open PRs and breaking changes,
and writes the release notes.
2. Instead of creating and pushing the tag, it checks the commit is
already on `origin/<branch>` and dispatches `release.yaml` **on the
branch** with `version`, `commit`, `release_channel` and
`release_notes`.
3. The releaser prints the run's URL. GitHub also notifies the
`release-managers` reviewers. **Another release manager approves** the
run's `release` environment (Review deployments).
4. The approved job creates the annotated tag `version` at `commit` with
the App, then builds, signs and publishes that commit as before.

`release.yaml` can also be run by hand from the Actions UI with the same
inputs.

### `release.yaml`

- New `version` and `commit` inputs (required unless `dry_run`).
- The `release` job checks out `commit`. Before anything else, it:
  - refuses a malformed version;
- refuses a version that doesn't match the branch (`release/X.Y`, or
`main`/`release/X.Y` for `-rc.N`);
  - refuses a commit that isn't already on the dispatched branch;
  - refuses an existing tag that points elsewhere;
- otherwise creates the annotated tag with the App. A re-run reuses a
tag already at that commit.

  `version.sh` and the rest of the job are unchanged.
- **Homebrew and the `coder/packages` dispatch use the new
`coder-package-publisher` App** (`release-publish` environment) instead
of `CDRCI_GITHUB_TOKEN`. The dispatch moves to its own
`publish-packages` job in `release-publish`, where that key lives; it's
approved together with Homebrew and winget. Winget still uses the
`cdrci` machine user, since an App can't open PRs on
`microsoft/winget-pkgs`.
- Every App token is scoped to one repository and the permissions it
needs (`zizmor`'s `github-app` audit: 5 high findings to 0, one of which
predates this PR).

### `create-release-branch.yaml` (new)

Dispatched on `main` with `version` (e.g. `2.40`) and `commit`. After
approval in the `release-refs` environment, it creates `release/X.Y` at
that commit, refusing one that isn't on `main` or a branch that already
exists.

### `scripts/releaser`

- `ReleaseExecutor` drops `CreateTag`/`PushTag`.
- `TriggerWorkflow` dispatches on the branch with `version` and
`commit`.
- An existing tag must already point at HEAD.
- After dispatching, it looks up the run (`gh run list`, polling
briefly) and prints its URL and the approval steps.

## Before merging

- [ ] `RELEASE_APP_ID` and `RELEASE_APP_PRIVATE_KEY` set in the
**`release-refs`** environment (currently empty), and the rotated
release App key in `release`.
- [x] `CODER_PACKAGE_PUBLISHER_APP_ID` /
`CODER_PACKAGE_PUBLISHER_APP_PRIVATE_KEY` in `release-publish`; App
installed on `homebrew-coder` and `packages`.

## After merging: backport to every branch you release from

`release.yaml` runs from the dispatched branch's own copy, and
`./scripts/release.sh` runs the branch's releaser. So **each
`release/X.Y` needs this change before it can release**. Active lines by
recent tags: `release/2.39`, `2.38`, `2.37`, `2.36`, `2.35`, `2.34`,
`2.29`.

## Relation to #31321

#31321 (`Tag release`) runs the releaser non-interactively in CI. This
PR is the smaller change that unblocks releases now. #31321 can build on
it: its tagging job would need `environment: release-refs` (where the
App key lives) plus the extra App permissions it asks for, which are a
manifest change in `coder/github-org-terraform` `apps/`.

## Testing

- `go build`, `go vet`, `go test ./scripts/releaser` pass.
- `actionlint` and `zizmor` are clean on both workflows.
- Not exercised end to end. Suggest the first use be an RC
(`v2.40.0-rc.N` from `main`), watching the tag step.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 19:54:29 -05:00
Dmitry Makovey 872105c4bb fix: bump bundled terraform to 1.17.2 (#32110)
Bumps the bundled Terraform from 1.17.1 to
[1.17.2](https://github.com/hashicorp/terraform/releases/tag/v1.17.2)
(released 2026-11-11). 1.17.2 pins `klauspost/compress` v1.20.2, which
contains the fix for
[GHSA-fpmh-frq8-7rj8](https://github.com/klauspost/compress/security/advisories/GHSA-fpmh-frq8-7rj8)
/ [GO-2026-6865](https://pkg.go.dev/vuln/GO-2026-6865) (panic in the
zstd decoder on a crafted frame). 1.17.1 pins v1.19.1.

Iron Bank reports GO-2026-6865 against `/opt/terraform/terraform` in
`coder/coder-enterprise/coder-service-2:2.38.7` (High). The Iron Bank
image takes its Terraform from the version coder bundles, so this bump
is how that finding goes away.

This is a patch bump, so `maxTerraformVersion` stays at 1.17.9. It does
not change the Go toolchain Terraform is built with (still go1.26.10) or
its `go-getter` pin (still v1.8.6).

## Changes

Same file set as #30516:

- `provisioner/terraform/install.go`: `TerraformVersion`
- `install.sh`, `scripts/Dockerfile.base`
- `mise.toml`, `mise.lock` (checksums from HashiCorp's
`terraform_1.17.2_SHA256SUMS`)
- `flake.nix` (fetchurl SRI hashes derived from the same SHA256SUMS)
- `docs/install/prepare/airgap.md`
- `provisioner/terraform/testdata/generation.sha1`: fixture fingerprint,
regenerated with `generate.sh --if-needed`. No plan or state fixture
changed.

I checked the checksum conversion first by deriving the 1.17.1 values
from `terraform_1.17.1_SHA256SUMS`; it reproduces every value currently
in `flake.nix` and `mise.lock`.

## Verification

```
$ mise install terraform        # mise.lock checksums verified against the download
$ mise exec -- terraform version
Terraform v1.17.2 on linux_amd64
$ ./provisioner/terraform/testdata/generate.sh --if-needed
only generation.sha1 changed
$ go test ./provisioner/terraform/ -run 'TestInstall|Version|Golden' -count=1
ok  github.com/coder/coder/v2/provisioner/terraform  (75 tests passed, 0 failed)
```

`flake.nix` was not evaluated with Nix; its hashes come from the same
SHA256SUMS as `mise.lock`.

## AI disclosure

Prepared with an AI coding agent on behalf of @droopy4096. The agent ran
the verification above; a human review is still needed before merge.
2026-11-13 09:39:18 -07:00
Spike Curtis 33a7633494 chore: add cluster-host to develop.sh to use NATS (#32088)
Adds `--cluster-host` to develop.sh, so that coder server uses NATS in
the development run.

---

<sub>Stack created with <a
href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a
href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
2026-11-13 17:20:32 +01:00
Nick Vigilanteanddefault 1271dcb570 docs: inherit feature states from ancestor routes in the docs sidebar (#31975)
## Summary

A feature `state` in `docs/manifest/` now applies to a route and all its
descendants, so each state is set once on the highest route it applies
to.
`docsmanifestgen check` rejects a route that repeats an ancestor's
state, and the repeated states on `main` are removed.

## State model

- Put a state on the highest route it applies to.
- Add a state to a descendant only when it is new, such as an early
access page inside a Premium section.
- The sidebar shows a pill on the route that sets the state and on
descendants whose state differs.
- Every page shows its full state, own plus inherited, under the title.

## Changes

- `docsmanifestgen check` (`make lint/docs-manifest`) fails when a route
repeats an ancestor's state, following include files and overlays, or
lists a state twice.
  It runs only after the manifest builds cleanly.
  Table-driven tests in `scripts/docsmanifestgen/state_test.go`.
- Keep `state: [premium]` on AI Governance and External provisioners
only.
Remove the 27 states their descendants repeat in
`docs/manifest/ai-governance/**` and
`docs/manifest/install/operate/provisioners.yml`, and regenerate
`docs/manifest.json`.
- Document the model in `contributing/documentation.md` (new "Feature
states" section with a YAML example),
`docs/.style/content-guidelines.md`, and the doc-check skill.

> [!IMPORTANT]
> Inherited pills under the page title and the new sidebar behavior need
the matching docs-engine change
([DOCS-1440](https://linear.app/codercom/issue/DOCS-1440)).
> Merge this after that ships, or child pages show no state pill until
it does.

## Testing

- `go test ./scripts/docsmanifestgen/... ./scripts/docgenenv/...`
- `golangci-lint run ./scripts/docsmanifestgen/...`
- `GOOS=windows` and `GOOS=darwin` `go vet ./scripts/docsmanifestgen/`
- `make lint/docs-manifest`, `make lint/markdown`, `make
lint/docs-redirects`
- `make gen/docs-manifest` leaves the tree clean.

<details>
<summary>Decision log: rebase onto main after #31645</summary>

- #31645 (merged 2026-11-04) moved AI Governance to a top-level section
with Agent Firewall and AI Gateway nested under it, and added the
`ai-coder/...` redirects.
That covered this PR's move commits, link and URL updates, and
redirects, which caused the conflicts.
- The branch was rebuilt on `main`: the two move commits were dropped,
and the four state-tooling and guidance commits were cherry-picked.
The manifest cleanup was redone as a new commit against `main`'s layout,
using the new lint's output as the list of repeated states.
- Agent Relay is now top-level with `state: [premium, beta]` and no
child states, so it needs no change.
- Conflicts in `content-guidelines.md` and the doc-check skill were
resolved to keep `main`'s newer text (Vale word-choice updates and
relative redirect syntax) and apply only the feature-states lines.
- The pre-rebase head was `a797f59737`.

</details>

> Generated by Coder Agents on behalf of @nickvigilante.


Supersedes #31481, reopened under a human author for attribution.

---------

Co-authored-by: default <default@example.com>
2026-11-12 13:19:38 -05:00
Thomas Kosiewski e307f1d5cf feat: add the user-scoped chat-automations experiment (#32064)
## Why

The Automations RFC controls availability with one user-scoped
experiment. Its text: "The user-scoped `chat-automations` experiment
controls availability. Operators configure defaults with `--experiments`
and can change per-user rules while Coder is running. Each surface
checks the relevant caller or automation's owner, and experiment
evaluation fails closed." The later backend PRs (management routes, the
`manage_automations` tool, `Publish`) need that check first. This PR
registers the experiment and proves the per-user, fail-closed check.
Nothing consumes it yet.

Part of CODAGT-1135

## What changed

- Registers `chat-automations` in `ExperimentsKnown` and
`ExperimentsUserScoped`. An earlier experiment with this name was
removed in #30412, and this PR restores none of its consumers.
- Keeps it out of `ExperimentsSafe`, so `--experiments=*` does not turn
it on. Automations act with their owner's authority, and a test pins the
choice.
- Adds the name to the `userScopedExperimentStaticCheck` ruleguard rule,
so server code cannot decide it from the static list.
`TestExperimentsUserScopedRuleguard` keeps the rule in step with
`ExperimentsUserScoped`.
- Regenerates the swagger files, `docs/reference/api/schemas.md` and
`typesGenerated.ts`.
- Adds tests for the real experiment name. The evaluator tests cover the
startup default, stored `on`, `off` and condition rules for two users,
and an off decision on a rules read error, a malformed rule, an unknown
mode, an attribute read error, a condition error and a nil subject. A
coderd test with a real database checks the same per-user behavior
through `api.ExperimentEvaluator` and `GET /api/v2/experiments`.

## Scope

No routes, tool, UI or chatd change. I added no helper:
`Evaluator.Enabled(ctx, userID, ex)` already decides per user and fails
closed, and API handlers reach it through `api.ExperimentEvaluator`.
chatd has no evaluator handle on main, because #31327 removed the unused
field. The first chatd consumer adds it together with its read.

## Blast radius

With the experiment off, which is the default, behavior on main does not
change. Two things become visible. `GET
/api/experimental/experiments/rules` and `coder exp experiment-rules
list` show a `chat-automations` row, and an administrator can store a
rule for it. A deployment that already passes
`--experiments=chat-automations` sees three small differences: the
startup log reports an opted-in hidden experiment where it reported an
unknown one, the deployment Overview page stops flagging the name as
invalid, and the rules row shows the static default as on. Nothing reads
the experiment yet, so no feature turns on.

## Live check

A local `./scripts/develop.sh` deployment built from this head ran with
no flag, with `--experiments=*` and with
`--experiments=chat-automations`. `GET /api/v2/experiments` lists
`chat-automations` for the owner and for a member only when the startup
list or a rule turns it on, and `--experiments=*` does not turn it on. A
condition rule `user.username == "member"` turned it on for the member
and off for the owner without a restart, and `reset` restored the
startup default.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model:
`anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
2026-11-11 23:54:05 +01:00
Ehab Younes 1126533c31 feat: export workspace last used time to Prometheus (#31346)
Add an opt-in coderd_workspace_last_used_timestamp_seconds gauge that
reports workspaces.last_used_at, the value the dormancy threshold
measures inactivity from. To enable it, set
--prometheus-collect-workspace-stats or
CODER_PROMETHEUS_COLLECT_WORKSPACE_STATS.

A separate WorkspaceStats collector refreshes the gauge once a minute
in the background from a new GetWorkspaceLastUsedForMetrics query. Each
series has a workspace_id label, so a workspace that reuses a deleted
workspace's name starts a new series. Workspaces owned by deleted users
are excluded.

Closes CLIENT-1065
2026-11-11 15:02:18 +00:00
Lisa Fiander 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._
2026-11-06 15:55:44 +00:00
Thomas Kosiewski 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`_
2026-11-06 04:26:44 +01:00
Nick Vigilante 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.
2026-11-05 14:04:17 -05:00
McKayla はな e7706406f4 feat: render nerd font icons in the web terminal (#30527) 2026-11-05 10:14:42 -07:00
Mathias Fredriksson 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.
2026-11-05 11:49:42 +02:00
Jon Ayers 63b5c4d64a fix: drop the /docs/about live-route assertion from TestRepositoryManifest 2026-11-04 21:37:07 -06:00
Jon Ayers 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.
2026-11-04 15:47:27 -06:00
McKayla はな b5c1b02f55 chore: upgrade to pnpm 12 (#31589) 2026-11-03 10:55:51 -07:00
coder[bot] 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>
2026-11-02 18:30:55 +00:00
Mathias Fredriksson 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
2026-10-30 15:52:22 +02:00
Michael Suchacz 1acacc9c30 feat: graduate MCP tool search from experiments (#31327) 2026-10-29 20:32:56 +01:00
Callum Styan 2255794d65 feat: add response_size_bytes metric to chatd (#29816) 2026-10-28 18:35:20 -07:00
Garrett Delfosse dbd7db6877 feat: add Harbor-based A/B eval for Coder Agents against main (#30686) 2026-10-28 08:21:44 -04:00
Ehab Younes 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
2026-10-27 09:58:36 +00:00
Mathias Fredriksson 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. 🏂🏻
2026-10-27 11:29:10 +11:00
Jon Ayers 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.
2026-10-26 16:47:25 -07:00
Nick Vigilante 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.*
2026-10-23 22:18:30 -07:00
Nick Vigilante 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>&nbsp;</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 cfd29a2160 (entities decoded in Markdown
text, image alt text and autolinks count as text), 709a58f603 (per-kind
counts, finding order, CLI generator note), 8e61ff3afa (CORS matrix
scopes and caption), and b807bcbbc7 and 2871f89bdf (style guide rule
section, `make lint/docs-html` in the checks table, coverage counts).

Linear: DOCS-1308

---

🤖 Built with AI assistance.
2026-10-21 10:58:04 -07:00
Nick Vigilante 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.
2026-10-20 18:51:44 -04:00
Denis AfonsoandClaude 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>
2026-10-20 22:02:53 +01:00
Ethan 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.
2026-10-20 15:41:25 +11:00
coder[bot]andDmitry Makovey 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>
2026-10-15 12:33:45 -07:00
coder[bot]andDmitry Makovey 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>
2026-10-15 11:11:10 -07:00
Bobby Ho 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.
2026-10-14 14:55:29 -07:00
Michael Suchacz 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.
2026-10-14 22:39:00 +02:00
Denis AfonsoandClaude 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>
2026-10-14 16:42:56 +01:00
Michael Suchacz 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.
2026-10-13 07:57:56 +00:00
Michael Suchacz 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.
2026-10-13 07:57:56 +00:00
Ehab Younes 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.
2026-10-12 23:58:35 +03:00
Ehab Younes 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
2026-10-12 15:56:40 +03:00
Thomas Kosiewski 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`_

![Agents sidebar after the upgrade, with no Automations entry](https://github.com/user-attachments/assets/bd446035-7fc8-4ca4-a735-3a4f36380738)
2026-10-11 19:57:49 +02:00
Nick Vigilante 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>
2026-10-08 12:26:20 -04:00
Nick Vigilante 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._
2026-10-08 12:24:42 -04:00
Nick Vigilante 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.
2026-10-06 14:53:20 -04:00
Nick Vigilante 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>
2026-10-05 22:28:54 +00:00
Nick Vigilante 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>
2026-10-05 09:27:46 -04:00
Nick Vigilante 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.
2026-10-02 15:05:10 -04:00