Skip to content

chore: merge upstream coder/coder f610e9ab19 - #271

Merged
ibetitsmike merged 9 commits into
mainfrom
mike/sync-upstream-f610e9ab19
Nov 13, 2026
Merged

ibetitsmike merged 9 commits into
mainfrom
mike/sync-upstream-f610e9ab19

Conversation

@ibetitsmike

Copy link
Copy Markdown
Owner

Closes #268

Merge upstream coder/coder f610e9ab191a22555d1abc78cda7ca8ed644169f (fix(site): drop deep link params from new chat URLs (coder#32068)) into fork main 0d8bea4783 as a merge commit. Two conflicting files, resolutions below.

Conflict resolutions

  • codersdk/deployment_test.go (ExperimentChatAutomations expected-map entries): union of both sides' entries. Upstream adds ExperimentChatAutomations: "Chat Automations"; the fork's ExperimentPlugins: "Plugins" entry stays. Both are upstream experiments in ExperimentsKnown, so the expected map (which is asserted 1:1 against ExperimentsKnown minus ForkExperiments) needs both. gofmt clean.
  • docs/reference/api/schemas.md (Experiment enum table): regenerated-content table, alphabetical by enum value; union of both lists with upstream's chat-automations inserted in sorted position (26 values). Re-ran the repo's own formatters in a clean node container: markdownlint-cli2 0 errors and markdown-table-formatter report no changes against the merged file, so the hand-merge matches generated output. Upstream's other hunks in this file auto-merged.

No fork hook lines were touched; no migration files changed.

Validation

  • go test ./codersdk/... green in the ops lane container (codersdk core incl. deployment_test.go ok; first attempt's toolsdk/tunneler failures were environmental, docker.sock not mounted for dbtestutil's self-launched postgres; green with the pre-authorized pg sidecar).
  • chatdmig route check: exit 0, routes.txt unchanged.
  • .github/fork/check-apidoc.sh: exit 0 (no apidoc drift).
  • Docs formatters on schemas.md: markdownlint + table-formatter clean, no diff.

Xum (AI agent) opened this on behalf of @ibetitsmike.

EhabY and others added 9 commits November 11, 2026 15:02
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
…NotNarrowed (coder#32065)

## Why

The `test-go-race-pg` job fails intermittently with `WARNING: DATA RACE`
in `swag.(*Spec).ReadDoc`, on pull requests whose changes do not cause
it. It failed CI runs 43102680650 and 43103681536 on two unrelated pull
requests. A green rerun of the same commit passes, so it hides as a
flake.

## Cause

swag's `Spec.ReadDoc` writes shared state, so parallel tests that each
call it race. coder#31829 addressed this by reading the spec once through
`swaggerDoc`, a `sync.OnceValue`. coder#30122 then added
`TestSwaggerEnumsNotNarrowed` with a direct
`apidoc.SwaggerInfo.ReadDoc()` call, which races with the tests that
still read the shared value.

## What changed

`TestSwaggerEnumsNotNarrowed` calls `swaggerDoc()`, like the other
tests. It was the only direct call outside the generated
`coderd/apidoc/docs.go`.

## Reproduction

- On `main` (412d998), `go test -race -count=20 -run
'TestSwagger|TestChatModelPathParametersFormatted' ./coderd/coderdtest/`
fails with 2 data race reports. `TestChatModelPathParametersFormatted`,
`TestSwaggerParametersValid` and `TestSwaggerEnumsNotNarrowed` fail.
- With this change, the same command passes with no data race report.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model:
`anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
## 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 coder#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 coder#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`_
…hooks verifiers (coder#32062)

## Why

An automation webhook must prove that a request comes from the holder of
the automation's secret before Coder parses the JSON body. The approved
RFC ([Automations for Coder
Agents](https://app.notion.com/p/3ded579be59281e39950e686df02fa3d),
Webhooks section) puts that check behind one `WebhookVerifier` interface
with three schemes. This PR adds those verifiers as a pure Go package.
The webhook route that calls them comes in a later PR.

Part of CODAGT-1135.

## What changed

New leaf package `coderd/x/chatd/chatwebhook`:

- `WebhookVerifier`, with the three methods exactly as the RFC writes
them, and three verifiers: `bearer` (constant-time token compare, one or
more spaces after `Bearer` as in RFC 6750 section 2.1), `github`
(HMAC-SHA256 of the raw body in `X-Hub-Signature-256`) and
`standard_webhooks` (HMAC-SHA256 of `webhook-id.webhook-timestamp.body`,
`v1,` entries in `webhook-signature`, five-minute timestamp window,
`whsec_` secret).
- `Scheme` with the three RFC enum strings, and `NewVerifier(Scheme)`.
The package does not import `coderd/database`.
- Every `Verify` failure wraps `ErrRejected`, so the route can answer
`401`. Every `Verify` and `ValidateSecret` error is built from a fixed
string: it never holds the secret, the received token or a signature.
The package does not log. Only the `NewVerifier` error names the unknown
scheme.
- `GenerateSecret` reads 32 bytes from `crypto/rand` for `bearer` and
`github`. For `standard_webhooks` it returns `ok=false`, and
`ValidateSecret` checks the pasted `whsec_` secret.

## Scope

- No database, no HTTP route, no wiring, no new Go module. Nothing
imports the package yet, so `main` behaves as before with the
`chat-automations` experiment off.
- The map from the database enum to a verifier, and its "every enum
value has a verifier" test, belong to the route PR. It can call
`NewVerifier(chatwebhook.Scheme(automation.WebhookAuth))`. A
`NewVerifier` error is a server error, not a `401`.
- No deduplication by `webhook-id`, as in the RFC. The same valid
request verifies every time.

## Tradeoffs

- A pasted `whsec_` secret has no length bound. The spec describes
sender secrets of 24 to 64 bytes, but it does not tell a receiver to
reject others. A bound would lock out a sender that deviates, and it
protects only the owner from the sender's own key.
- The bearer verifier accepts one or more spaces between `Bearer` and
the token, as RFC 6750 section 2.1 and the API key middleware do. It
rejects a tab and an empty token. It also rejects trailing whitespace
after the token when it receives it, but an HTTP request cannot deliver
that: `net/http` strips trailing whitespace from the header value before
the verifier runs, so such a request is accepted with the right token.
- The signed Standard Webhooks content uses the `webhook-timestamp` text
as received. The reference Go library signs the reformatted number
instead. The two differ only for a timestamp with leading zeros, which a
conforming sender does not send.
- A `webhook-id` that contains `.` is rejected. The spec asks senders to
avoid it, because it makes `id.timestamp.body` ambiguous. A repeated
`Authorization`, `X-Hub-Signature-256`, `webhook-id` or
`webhook-timestamp` line is rejected for the same reason. Several
`webhook-signature` lines are read as one list.
- `TestSecretComparisonsAreConstantTime` reads the package source and
fails on `==`, `bytes.Equal` and similar on secrets. A correct
early-exit compare gives the same answers as a constant-time one, so a
request-level test cannot tell them apart. The scan is a guard against
the likely mistake, not a proof.

## Verification
- Test vectors come from the [GitHub
docs](https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries)
and from `TestWebhookSign` in the [Standard Webhooks Go
library](https://github.com/standard-webhooks/standard-webhooks/blob/main/libraries/go/webhook_test.go).
The tests cite the URL beside each vector.
- Live lane: none. No route, CLI or UI reaches this code yet, so there
is no surface to exercise.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model:
`anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
coder#31688)

Relates to coder#14726
Relates to https://linear.app/codercom/issue/CORE-807

coder#15078 added a `CRITICAL` log, with a
stack trace from `terraform-provider-coder`, for when `terraform init`
fails with `text file busy`. It's been dead since
coder#20503 started running `init` with
`-json`. In JSON mode, terraform writes the error as a diagnostic on
stdout and leaves stderr empty, and we only ever checked stderr:

```
{"@Level":"error","@message":"Error: Failed to install provider","@module":"terraform.ui","diagnostic":{"severity":"error","summary":"Failed to install provider","detail":"Error while installing coder/coder v2.13.1: open .../terraform-provider-coder_v2.13.1: text file busy"},"type":"diagnostic"}
```

To fix, we'll just check stdout as well, and include it in the log. The
existing test missed this because its fake terraform always wrote the
error to stderr. It now writes the JSON diagnostic to stdout when it's
passed `-json`, and the test also runs against a pre-1.9 version, which
still reports the error on stderr.
…32052)

Replaces the JetBrains AI Assistant setup with JetBrains Air, the
recommended agent workspace bundled in JetBrains IDEs 2026.3+. JetBrains
moved AI Chat into Air and supports AI Assistant only [until early
2027](https://blog.jetbrains.com/ai/2026/11/air-in-jetbrains-ides-ga/).

- `clients/jetbrains.md`: rewritten for Air only. Covers prerequisites,
how Air runs Claude Agent and Codex in the workspace, template setup,
starting a session, and the **Agent login** / "Claude subscription
(OAuth token)" label.
- `clients/index.md`: JetBrains row marks Anthropic as supported and
drops the AI Assistant note.
- Manifest description updated; the two unused AI Assistant screenshots
are removed.

Naming follows JetBrains docs: [Agents in IntelliJ
IDEA](https://www.jetbrains.com/help/idea/agents-in-ide.html),
[Configure agent
authorization](https://www.jetbrains.com/help/air-ides/air-configure-authorization.html).

Verified on dogfood with IntelliJ IDEA 2026.3 over remote development:
Air runs the ACP-registry Claude Agent and the workspace's Codex CLI
inside the workspace, both inherit the AI Gateway env/config, and
sessions land in AI Gateway.

_Opened via Superblink._
Closes CODAGT-1559

`AgentCreatePage debug deep link > prefills the prompt and the build
logs, and sends them on Send` flaked in
[CI](https://github.com/coder/coder/actions/runs/43137145430) with the
new chat's URL still carrying `?debug_workspace_build=...`.

It turns out react-router 7 applies router state inside
`React.startTransition`, so `router.state` updates straight away but
`useLocation()` lags until the transition commits. The query data that
enables Send arrives as a sync update, so under load Send can commit
first, and it forwarded the stale `location.search`. Waiting on
`router.state` in the test wouldn't help, as it's already clean by the
time Send is clicked.

To fix, we'll just strip the link params from the search once in render
and use that for both the URL cleanup and the navigation on Send, so
neither depends on when the transition commits.
@ibetitsmike ibetitsmike added the sync Upstream sync label Nov 13, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T10:25:48.450685Z 8bd156f Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 8bd156f87b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike
ibetitsmike merged commit 57c991b into main Nov 13, 2026
11 checks passed
@ibetitsmike
ibetitsmike deleted the mike/sync-upstream-f610e9ab19 branch November 13, 2026 11:02
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Merged as 57c991b171 with a merge commit, like earlier syncs (#244), so upstream f610e9ab19 stays in main's history. These checks passed on head 8bd156f87b:

  • fork-ci run 43408321485, plus all 11 other check runs
  • Codex: no major issues on 8bd156f87b
  • 0 unresolved threads, branch up to date with main
  • Paired pre-merge UAT by Fork ops on a full local build. Against 0d8b on :3100, the schema, migration nodes, API probes, experiments and log counts all matched, and both smoke runs passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sync Upstream sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sync: upstream f610e9ab19 conflicts

6 participants