Repository navigation
Conversation
Delete no longer runs the disable update first, which required update permission. It deletes the row and then removes every queued message of the automation; the promotion guard discards any message whose automation no longer exists, so deleting the row is the cutoff.
Add POST /api/experimental/chat-automations/{automation}/events. The
caller authenticates with the automation's webhook secret, compared in
constant time; unknown ids, other kinds, and wrong secrets get the same
401. After the secret matches, the chat-automations experiment is
checked for the automation owner and the body (at most 256 KiB of JSON)
is read.
chatd's PublishAutomationWebhook sends the saved prompt and a separate,
labeled untrusted event-data part to the target chat as the owner,
always with the queue busy behavior. Its AdmitInTx callback locks the
automation and rechecks enabled, secret version, single-use state,
target, and owner permissions, applies When busy (skip refuses a busy
chat; queue caps automation messages at half the chat queue), consumes
single-use webhooks, and returns the provenance. new_chat targets answer
501 until a follow-up change.
Part of CODAGT-1210 (1 of 2).
…agt-1210-automations-webhooks
…agt-1210-automations-webhooks
- A chat with no enabled model now gets the same 400 as a person's message instead of a 500 that senders retry. - The 429 for a full automation queue share names the share instead of repeating the internal error chain. - The 400 for a body that fails to parse names the parser's cause, such as nesting deeper than the parser accepts. - The event data part starts with a blank line so clients that join text parts verbatim do not run it into the prompt.
The Unauthorized case sent a wrong secret and an unknown id twice to compare their bodies. Compare each case's body with the first inside the loop instead, which also covers missing secrets and session tokens.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b56dc29b95
ℹ️ 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".
- Limit webhook event requests per caller across all automation ids, in addition to the per-path limiter, so cycling random ids no longer gets a fresh bucket per request (new httpmw.RateLimitByEndpointKey). - Refuse an already-used single-use webhook before SendMessage, so a repeated request never reaches the user_prompt_submit hooks. The locked recheck in admitAutomation still handles races. - Report a target chat deleted between the pre-send check and the send as ErrAutomationTargetUnavailable instead of an internal error. - Drop the body @PARAM that declared the event as an object; the body can be any JSON value. Regenerated the swagger docs. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3e7f99c549
ℹ️ 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".
…tions - Refuse a webhook request whose secret was rotated before SendMessage, so its payload never reaches the user_prompt_submit hooks. The check under lock still catches a rotation during the send. - In the admission callback, read the chat's queued rows first and lock this automation together with the queued rows' automations in one ascending-id call, the order promotion uses, to avoid deadlocks between deliveries to chats that queue each other's rows. - Count only queued automation rows that promotion would still deliver (automation present, enabled, same queue generation) toward the automations' queue share, so stale rows no longer refuse deliveries. - Remove the now unused CountChatQueuedAutomationMessagesByChatID query. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1375b8c7e
ℹ️ 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".
- Admission is decided by one checkAdmission function, called on unlocked reads before SendMessage and again on the locked rows in the admission callback. It covers enabled, webhook kind and secret version, single-use consumption, the target, when-busy skip and the queue share, so no refusal that the callback can make reaches the prompt hooks first. - A chat is busy, and the automations' share is counted, only from queued rows promotion would keep, so a chat whose queue holds only stale automation rows counts as idle. - Register the webhook events route outside the /api/experimental group so only its per-caller limiter applies; the group's limiter keys unauthenticated callers by path. - Document the event body as an unconstrained JSON schema. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 23e76e9d4a
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
The events section now says that the route sits outside the /api/experimental group with a fixed-key limiter, that the admission checks run before the send so refused events never reach hooks, that the callback locks the automation together with the chat's queued automations in one call, and that only promotable queued rows count toward busy and the queue share. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…ble-rotate' into HEAD
…tk/codagt-1210-automations-webhooks coderd/x/chatd/chatd.go conflicted in the Config struct, where main added TracerProvider next to the automation Authorizer field. Both fields are kept. Webhook publishing goes through Server.SendMessage, so it picks up main's chat_turn span and queue-wait recording without further changes. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main d9c13dc: hand-resolved coderd/x/chatd/chatd.go Config (kept main's TracerProvider and the automation Authorizer); make gen produced no diff
Generated with |
|
@codex review Scope: only the conflict resolution in merge commit effdb6b (sync with main d9c13dc). Please do not re-review main's code or the unchanged stack code.
Generated with |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…tk/codagt-1210-automations-webhooks No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main 35abc22: no content conflicts; make gen produced no diff
Generated with |
ibetitsmike
left a comment
There was a problem hiding this comment.
Xum (an AI coding agent) prepared and posted this review on behalf of Mike. Each finding came from automated review passes and was re-verified against the code; please push back on anything that looks wrong.
This layer adds POST /api/experimental/chat-automations/{automation}/events and chatd.PublishAutomationWebhook for existing_chat targets. The reviewer passes and an independent re-read of the handler, the rate limiter routing, and the admission path (unlocked precheck, then the locked recheck in AdmitInTx) found no issues worth fixing beyond what the earlier Codex rounds already covered. TestChatAutomationEvents and TestPublishAutomationWebhook pass locally at this head.
Verdict: no blocking issues
Severity: P0 0, P1 0, P2 0, P3 0
Review coverage
- code-review Standards: 0 findings (Swagger annotations, error wrapping, doc comments, body limit, ARCHITECTURE.md adds no TODOs)
- code-review Spec: 0 findings (matches the RFC Webhooks, Acceptance transaction, and Failure outcomes sections;
new_chat501 is deferred to the next layer as described) - frontend-review: FE2 PASS, FE1 and FE3 to FE10 N/A (only generated
typesGenerated.tschanged) - coder-frontend-review: types and naming PASS, other roles N/A
- Existing threads: 13 Codex threads, all resolved (11 fixed, 1 declined with a reason, 1 deferred to CODAGT-1233); none reopened
…tk/codagt-1210-automations-webhooks No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main d11809f: merged #30117
Generated with |
ibetitsmike
left a comment
There was a problem hiding this comment.
Xum re-reviewed this PR on behalf of @ibetitsmike using GPT-6.1 Sol (high) Exec subagents.
Verified the 11 prior fixes on the fresh head and checked the unchanged webhook layer against its changed admission, archive, capacity and retry dependencies. New findings: Standards 0, Spec 0, Frontend 0. The existing physical stale-queue cap remains deferred to CODAGT-1233, and the custom-role consumption policy remains accepted and closed. Fresh publisher, HTTP, escaping, authorization and selected dependency tests passed, including ten additional single-use repetitions; Storybook is externally blocked by Pixel report HTTP 500s, and full suites, frontend runtime checks and dogfood were not rerun.
…tk/codagt-1210-automations-webhooks Resolved conflicts in coderd/apidoc/docs.go coderd/apidoc/swagger.json coderd/database/dbauthz/dbauthz_test.go : hand-written files keep both sides, generated files come from make gen. make gen regenerated coderd/apidoc/docs.go coderd/apidoc/swagger.json --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
sync with main a328bee: merged #30117
Generated with |
ibetitsmike
left a comment
There was a problem hiding this comment.
Xum validated this PR and approved it on behalf of @ibetitsmike.
Validated head 258afe9afc14. The 11 resolved webhook findings remain fixed; accepted custom-role and physical stale-queue policies remain unchanged. Fresh publisher/concurrency/refusal, event-escaping, HTTP and consumption-authorization tests passed on this head. Current required CI passed. This approval covers existing-chat acceptance, not eventual execution or the rest of the stack.
…tk/codagt-1210-automations-webhooks No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
merged #30117
Generated with |
…tk/codagt-1210-automations-webhooks No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
|
merged #30117
Generated with |
…tk/codagt-1210-automations-webhooks No conflicts. make gen produced no diff. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Generated with |
…automations-webhooks Brings main ff158c0 into this layer. No conflicts. --- _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Part of CODAGT-1210 (1 of 2). Part of CODAGT-1135.
What this adds
POST /api/experimental/chat-automations/{automation}/events. External systems send the automation's webhook secret asAuthorization: Bearer <secret>and a JSON body of at most 256 KiB. The route has no API key middleware and sits outside the/api/experimentalgroup, behind its own rate limiter keyed by caller and a fixed endpoint key (IP address for unauthenticated callers), so varying the automation id does not reset the budget.401. Thechat-automationsexperiment is checked for the automation owner only after the secret matches (404when off). The body is then read: over the limit413, not JSON400.chatd.PublishAutomationWebhooksends as the owner (dbauthz.Aswith the owner's subject) throughSendMessagewith thequeuebusy behavior set explicitly, so automations never interrupt or steer.user_prompt_submithooks run first: a denial is403, an unreachable hook service502.AdmitInTxcallback, which locks the automation together with the chat's queued automations in one ascending-order call. Under the lock it rechecks: enabled, secret version (a request verified before a rotation but committed after it gets401), single-use state, target chat (root chat of the owner, same org, not archived), owner status, and the owner'schat:updatepermission. It then applies When busy:skiprefuses a busy chat (409),queuerefuses input beyond the automations' share, half the chat queue cap rounded down and at least 1 (429); busy and the share count only queued rows that promotion would still deliver. It marks a single-use webhook consumed and returns the provenance.<automation_event_data>tags.json.HTMLEscapeescapes<,>, and&in the body, which keeps the JSON value and makes the closing tag impossible to forge.chatd.Config.Authorizer(wired fromoptions.Authorizer) for the explicit owner checks; publishing fails closed without one.ConsumeChatAutomationWebhookByIDwith a dbauthz wrapper.Status codes follow the RFC's failure outcomes table; the chat-without-a-model case returns the same
400as a person's message.Notes for reviewers
chat_automation. No lower-layer RBAC change.coderd/apidoc,dbmock,dbmetrics,querier.go,queries.sql.go,docs/reference/api/schemas.md,typesGenerated.ts).SendMessagepath).Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:high