Repository navigation
Conversation
…chedules Automations store a five-field cron expression and an IANA time zone. Standard parses both and gives a repeated local time one run and a nonexistent local time one run after the clock change, which the robfig/cron Next used by Weekly and Daily does not do. MinInterval returns the shortest gap between runs for the API check, because Min only samples one week from 1970-01-01.
… MinInterval Next searches again when robfig/cron gives up after five years, so a leap day schedule keeps running across 2100. The zone period walk starts 26 hours before the reading, so historic offsets above 14 hours still find the first instance of a repeated time. MinInterval scans 28 years, which holds every calendar a year can have, so schedules that set both day fields get their true shortest gap. It stops once it sees two days in a row, and searches from midnight, so common schedules take microseconds.
Go reports wrong zone period bounds after the last transition in a zone's data, so the walk over zone periods never ended on December 31 of a leap year. A reading is now resolved from the offsets of the zone around it, with fixed bounds on every loop, and Next returns the zero time instead of spinning when a step does not move forward. MinInterval drops the calendar scan and returns the shortest distance between two times of day around the clock. Standard rejects the zone data files localtime, posixrules and Factory.
…a through 2100 The differential test runs over every clock change of five zones and December 31 in years up to 2100, with the zone data of the host and the data that Go embeds. Every Next call in the termination test has a deadline. The model of cron comes from robfig/cron, not from the code under test.
…limits No two runs are closer than MinInterval while the UTC offset of the zone does not change. An offset change can shorten a gap that spans it, and a pair across midnight counts without days in a row. Tests pin both.
A zone name with an empty, dot or dot-dot segment is rejected, because time.LoadLocation cleans the path and ./localtime reached the host file. Tests start Next inside repeated periods of up to a whole day, so the bound on the readings that Next walks is pinned, and a test from a zone with a local mean time offset above 15 hours pins the range of offsets that Next reads. The comment on the search for later runs now states 16 years, which is what robfig's year limit gives.
…the zone once A zone name is rejected when its first segment is posix or right, because right counts leap seconds and gives wrong runs on hosts that have it. The files that are not zones are rejected in any directory. The error for an unknown zone holds the name once. A test starts Next in Juneau, where the walk visits 1,441 readings, one more than the repeated day of Sitka.
…to tk/automations-api-read
Mark database.ChatAutomation as an Auditable, with the target name and ID, the organization requirement, and the audit table. webhook_secret and prompt are ActionSecret, so an entry shows that they changed and never their value.
…n needs GetChatsByIDs reads the chats whose titles a response shows. GetChatIDsWithQueuedMessagesByAutomationID and DeleteChatQueuedMessagesByAutomationID let a delete lock the chats that hold queued messages of the automation before it removes them.
The routes sit under /api/experimental/organizations/{organization}/chats/automations
behind the chat-automations experiment, which is evaluated for the caller and
answers 404 when off. The response type has no webhook secret field. Delete
locks the automation, then each chat that holds a queued message of it in chat
ID order like a chat transition, then removes the queued messages and the row.
ARCHITECTURE.md prose was drafted by an agent at the user's request; the user will review it.
The request logger logs the response body of a 5xx, so the handlers write the message only and log the error.
Cut test rows, phases and helpers that no product mutant separates, merge the two lock-order subtests into one test, and replace the expected-value builder of the response test with targeted assertions. Add TestChatAutomationsInternalError: a 500 from list, get or delete carries a message and no detail, and the response body never holds the cause.
This PR audits only the delete. A later PR adds the action that it audits, so that the audit log page never lists an action that nothing emits.
A role that can read a chat automation and cannot delete it got 404. The chat project routes answer 403 in that case. Also correct the comments that the review found false or unclear, and the ARCHITECTURE.md bullet.
…ssage names the automation Delete no longer removes queued messages. Nothing writes automation_id on a queued row before the run path exists, and how a delete leaves a chat's queue is a chat state decision that belongs with that path. Delete takes the automation lock, re-reads the automation and refuses with ErrQueuedMessages when a queued message names it. The handler answers a generic 500.
|
@codex review |
|
@codex security review |
Docs previewLinks open this pull request's preview at https://pr-32079.docs.cdr-preview.dev, which updates with each push. Check off each page once it's been reviewed. If a page changes in a later push, its checkbox clears automatically so it gets a fresh look. Pages not yet wired into the docs navigation aren't listed here. Preview sites for each built commit (2)Every built commit keeps its own preview, newest first. Previews aren't indexed by search engines and are deleted when this pull request is merged or closed. |
💡 Codex ReviewWhen a parameter changes, this pending flag is not set until When a dynamic-parameter response is pending, the view now disables the submit button and replaces its normal state with a spinner, but every story inherits AGENTS.md reference: site/AGENTS.md:L74-L75 ℹ️ 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". |
🛡️ Codex Security Reviewcoder/enterprise/cli/provisionerkeys.go Line 92 in 1b9dbec When a lower-privileged actor can read coderd or proxy logs, this metadata lookup exposes the newly created provisioner credential. SECURITY.md reference: SECURITY.md:L13-L15 ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. Only the user who started this review can view the report in Codex. |
|
@codex review |
|
@codex security review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. 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". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
|
Two Codex findings on this head (comments 6847923172 and 6847932144) name |
…tk/automations-tool-read Conflict in coderd/chatautomations.go: the sync of #32079 edited the doc of loadChatAutomationRefs, which this PR moved to chatautomation.LoadRefs. The deletion stays. The create handler of #32096 now calls chatautomation.LoadRefs, and LoadRefs reads the chats through GetReadableChatsByIDs, the filtering read that #32079 renamed so that main's all-or-nothing GetChatsByIDs stays.
- coderd: drop TestChatAutomationsDeleteQueuedMessage. chatautomation TestDelete/QueuedMessageOfTheAutomation owns the refusal and TestChatAutomationsInternalError/Delete owns the 500 without detail. - coderd: drop the MemberNoAgents, Auditor and ScopedToken rows of TestChatAutomationsAuthorization and their fixtures. The dbauthz TestChatAutomationAuthorization matrix owns those role and scope outcomes. - coderd: drop the UnreadableUsername row of TestChatAutomationsOwnerFilter. UnreadableUsernameWithReadableRows kills the same mutants. The Me row now owns an automation, so that reading me as a username fails it. - coderd: drop the allow-list token half of TestChatAutomationsResponse/Unreadable. TestChatAutomationsReadOnlyRole owns the owner fallback, and Webhook now asserts OwnerID. - coderd: assert the audit resource type and target in TestChatAutomationsOwnerLifecycle and drop TestChatAutomationResource, whose ResourceRequiresOrgID check restated a flag that nothing observes. - chatautomation: drop TestDeleteForbidden (TestChatAutomationsReadOnlyRole owns the 403) and TestDeleteOtherOrganization (TestChatAutomationsAuthorization/WrongOrganizationPath owns the 404). - codersdk: drop TestChatAutomationResponseTypesHaveNoSecret, a field name grep. TestChatAutomationsResponse/Webhook reads the response body for the secret. - database: drop TestGetReadableChatsByIDs. TestChatAutomationsResponse/Webhook resolves the target and creator chats through the query. - enterprise/audit: drop the created-direction block and the JSON loop of Test_chatAutomationSecretsMasked. The exact map of the rotated diff covers the masking.
…rst uses it Nothing writes a chat_queued_messages row with automation_id yet, so the refusal in chatautomation.Delete never fires. Move it, with its tests, to the PR that adds the first writer. - Move ErrQueuedMessages and the queued-message refusal of chatautomation.Delete. - Move the advisory lock in Delete and the exported LockID. - Move the query GetChatIDsWithQueuedMessagesByAutomationID: SQL, dbauthz method and MethodTestSuite row, generated code, dbmetrics wrapper. - Move TestDeleteLock, the TestDelete rows QueuedMessageOfTheAutomation and OtherQueuedMessages, and the queue and queued test helpers. - Keep the 403 for a caller that can read an automation and cannot delete it: map the dbauthz NotAuthorized error of DeleteChatAutomationByID to ErrDeleteForbidden. The removed probe query did this. _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-sonnet-5-5` • Thinking: `xhigh`_
…automations-api-read
|
@codex review |
|
@codex security review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f12982c2f3
ℹ️ 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".
|
|
||
| // This row holds the decrypted webhook secret. The converter never | ||
| // copies it. | ||
| automation, err := api.Database.GetChatAutomationByID(ctx, id) |
There was a problem hiding this comment.
Read automations without decrypting webhook secrets
In a multi-replica deployment where an already-running keyless replica shares the database with a newly keyed replica, requesting an automation created by the keyed replica returns 500 even though this response never uses the secret. GetChatAutomationByID always decrypts webhook_secret; the supported failure mode is demonstrated in enterprise/dbcrypt/dbcrypt_internal_test.go:2480-2505, while the list query avoids it by omitting secret columns. Use an authorized secret-free single-row query here so ordinary reads remain available during encryption-key rollout.
Useful? React with 👍 / 👎.
Chat automations send a saved prompt to a chat from a webhook or a schedule (RFC: Automations for Coder Agents). This PR adds the routes that read and delete them, behind the
chat-automationsexperiment, so that create, the scheduler and the webhook endpoint can follow in small PRs. Part of CODAGT-1135.Stacked on #32076. Review only this diff. It merges after #32076.
Size of the diff: 706 lines of hand-written product code, 697 lines of tests, and 1,287 lines of generated code and docs.
What changed
Three routes under
/api/experimental/organizations/{organization}/chats/automations: list (with?owner=), get and delete. They answer 404 when the experiment is off for the caller. Access follows the RFC role table through RBAC and dbauthz: members read and delete their own automations, and organization administrators and deployment owners read and delete every automation in the organization. The response typecodersdk.ChatAutomationhas no secret field, and an owner or a chat title appears only when the caller can read that user or chat.chatautomation.Deletere-reads the row as the caller and deletes it in one transaction, and the delete is audited withpromptandwebhook_secretmasked.Suggested reading order:
coderd/chatautomations.go,coderd/x/chatd/chatautomation/delete.go,coderd/database/db2sdk/chatautomation.go,codersdk/chatautomations.go, then the tests. The rest is generated code and docs.Scope
--experiments=chat-automationsflag exists only on dev or dogfood deployments, and those turn these routes on.Tradeoffs
MaxPromptBytes.new_chat_model_config_id,project_idandreasoning_effort, named as in the create request. The RFC says PATCH "takes the same fields as create", so an editor must be able to read them.paused_reasonsis always[]until the run path exists, and there is no field for the count of skipped and refused runs: that field arrives with its writer.ChatAutomationlists onlydelete. The generated audit log page lists every action in the map, and nothing emits create or write yet. Later PRs add the actions they emit.chat_automationaction." The custom role API lets an actor grant only the permissions that the actor holds (customRoleEscalationCheck), and no built-in role holds create. This PR adds no create route and keeps the role table: a custom role with read and delete deletes, one with read only gets 403, and one with delete and without read gets 404 and deletes nothing, because the delete re-reads the row with read.Live check
On a local enterprise build with its own PostgreSQL and the experiment on for one of two users, the three routes behaved as described, and a canary secret appeared 0 times in every response, the audit log, the server log and the PostgreSQL log.
Generated with
xum• Model:anthropic:claude-sonnet-5-5• Thinking:xhigh