Repository navigation
feat: restore agents-access as a default organization role - #30004
Conversation
Re-introduce the built-in organization role `agents-access` ("Coder Agents
User") and add it to every organization's default member roles, so all
members keep Coder Agents access after upgrading. Admins can remove it from
the organization defaults and grant it selectively through member role
edits or IdP role sync. Service accounts do not inherit it from the
defaults.
Replace the RoleSelectorDialog prop capture with a request-body assertion and keep fixture changes to MockOrganization.
Members without agents-access cannot read chats they created earlier; only chats shared with them stay readable.
Renumber the agents-access default role migration to 000602 because main added migrations 000600 and 000601.
…ries The organization PATCH endpoint stored duplicate default role names verbatim, which made the Roles page render a role twice. The CLI already de-duplicates the flag values.
Tell restricted members that their existing chats are kept and reappear when access is restored, and stop the forbidden composer from claiming that no models are configured when the user simply has no permitted organization.
…RBAC roles Organization defaults now include agents-access, so the workspace owner's roles gain it. Sort the acquired job's roles before comparing, because the server returns them in database order.
Docs previewCheck 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. |
|
@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: a6fef66b3f
ℹ️ 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".
Custom role names are stored lowercase, so a custom role named Agents-Access became an agents-access role that the built-in role shadowed and that could not be deleted.
|
@codex review |
|
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". |
mafredri
left a comment
There was a problem hiding this comment.
Reviewed only the PR text: description, docs, CLI help, UI strings, and comments. I didn't review the design or the tests. One check, one suggestion, two minor corrections, three nits, and a suggested description.
Check: migration 000602 deletes custom roles named agents-access but leaves agents-access entries in organization_members.roles. Before this PR, rolesByNames skipped those as retired. Now they resolve to the built-in role, so those members keep Coder Agents after an admin removes the default. If that's intended, I think the NOTE should say so. The diff below adds a sentence.
Suggested PR description, 566 words down to 451:
- Removes the "Delivery record" section and the round-by-round history. Reviewers can't act on either.
- Drops the known issues about
scripts/testidpand user admins blocked by defaults they can't assign. This PR doesn't touch that code. - Credits the upgrade test to a6fef66, the round where it ran.
Description diff
@@ -1,38 +1,29 @@
-Restores `agents-access` (**Coder Agents User**) as a built-in organization role and ships it in every organization's `default_org_member_roles`. Every member keeps Coder Agents by default, and admins can now restrict it per organization by removing the role from the defaults and granting it through IdP organization role sync or direct assignment.
+Restores `agents-access` (**Coder Agents User**) as a built-in organization role and adds it to every organization's `default_org_member_roles`. Members keep Coder Agents by default, and admins can now restrict it per organization by removing the role from the defaults and granting it through IdP role sync or direct assignment.
Since #28186, chat permissions lived in the organization-member floor, so the only way to limit Coder Agents was narrowing per-model access lists, which did not hide the feature.
- Migration 000602 appends `agents-access` to every organization's defaults, so upgrading keeps every member's access. New organizations get it from `rbac.DefaultOrgMemberRoles()`.
-- Service accounts do not inherit the role from the defaults (`GetAuthorizationUserRoles`) and need an explicit grant, matching today's service-account floor without chat.
+- Service accounts do not inherit the role from the defaults (`GetAuthorizationUserRoles`), so they still need an explicit grant for chat.
- Owners and Organization Admins keep chat access regardless of defaults. Chats shared with a user stay readable without the role.
-- Role sync is unchanged: default roles are implicit, so after the default is removed a mapped user gets `agents-access` at their next sign-in (documented).
+- Role sync is unchanged. It does not store default roles, so after the default is removed a mapped user gets `agents-access` at their next sign-in.
- The retired-role mechanism (`IsRetiredRoleName`) is removed.
- `PATCH /api/v2/organizations/{organization}` rejects duplicate `default_org_member_roles` entries (the CLI already de-duplicated them).
- Custom organization role requests treat built-in role names case-insensitively, since custom role names are stored lowercase and `Agents-Access` would otherwise become an undeletable shadow of the built-in role.
-- The Agents permission alert tells restricted members their chats are kept, and the forbidden composer no longer claims that no models are configured.
+- The Agents permission alert tells restricted members their chats are kept, and the model selector for users without chat permission no longer claims that no models are configured.
Docs add "Control who can use Coder Agents" to the Agents getting-started guide.
-**NOTE**: Migration 000602 deletes custom roles named `agents-access`, which the built-in role would shadow. The down migration does not restore them.
+**NOTE**: Migration 000602 deletes custom roles named `agents-access`, which the built-in role would shadow. The down migration does not restore them. Stored member grants of `agents-access` from the earlier built-in role or a deleted custom role stay and now grant chat access.
## Validation
-- Remote dogfood UAT: **PASS on fb441dfae58** (round 3: case variants of built-in names rejected on create, update, delete, default roles, and member grants, plus a regression smoke on the round-2 database). Round 2 PASS on a6fef66b3fe covered the upgrade from main 5dde49dffbd on a fresh database. Screenshots and logs are attached to the [UAT chat](https://dogfood.cdr.dev/agents/e1c18dc6-f6f0-49a1-b6cd-6ce014b51a86).
-- Local: rbac, dbauthz, idpsync, migrations (chain incl. 000602 down/up), querier, httpmw, provisionerdserver, coderd and enterprise chat/role/organization tests, chatd, toolsdk, CLI; frontend vitest, story tests, biome, oxlint, tsc. Red-green on the duplicate-roles test and the forbidden placeholder.
+- Remote dogfood [UAT](https://dogfood.cdr.dev/agents/e1c18dc6-f6f0-49a1-b6cd-6ce014b51a86) passed on fb441dfae58, covering case variants of built-in role names on create, update, delete, default roles, and member grants. The previous round, on a6fef66b3fe, passed the upgrade from main 5dde49dffbd on a fresh database.
+- Local: rbac, dbauthz, idpsync, migrations (chain including 000602 down and up), querier, httpmw, provisionerdserver, coderd and enterprise chat, role, and organization tests, chatd, toolsdk, CLI; frontend vitest, story tests, biome, oxlint, tsc.
## Known issues (not changed here)
- Sending from a chat page that was already open when access was removed shows a generic 404 panel until reload.
- The members page role editor is not locked for OIDC users under org role sync; the API rejects the change with 400.
-- User admins cannot change member roles in an org whose defaults include a role they cannot assign (for example `organization-auditor`).
- Creating a custom role named after a system role (`organization-member`, `organization-service-account`) returns 400 with a raw database unique-constraint error.
-- `scripts/testidp` advertises JWKS `alg: RSA`, which go-oidc v3.21 rejects.
-
-## Delivery record
-
-- Remote UAT (UAT Critic sub-agent `6636c855ec`): round 1 on 8bec029d353 PASS with issues, fixed in d7ba937a108 and e0f16e1a45f; round 2 on a6fef66b3fe PASS; round 3 on fb441dfae58 (current head) PASS, remaining issues listed above.
-- Frontend: FE1 to FE10 and coder-frontend-review checkpoints self-audited in the main thread.
-- Codex round 1 on a6fef66b3fe: one P2 (case variants of built-in role names), confirmed by a probe, fixed in fb441dfae58 with a red-green test, thread resolved. Round 2 on fb441dfae58: no major issues.
> 🤖 This PR was opened by [Xum](https://mux.coder.com) on behalf of @ibetitsmike.
-I verified these claims against the code at fb441df:
- Role sync treats default roles as implicit (
coderd/idpsync/role.go:183-198). - The CLI de-duplicates the role list (
parseDefaultOrgMemberRoles). - Custom role names are stored lowercase (
queries/roles.sql). - Owner and Organization Admin roles include chat.
- Chat ACLs keep shared chats readable.
I couldn't verify "did not hide the feature" or the UAT results.
🤖 This review was automatically generated with Coder Agents.
Move the access-gap explanation ahead of the restriction steps, exclude service accounts from "every member" claims, align the CLI example with the docs wording, and trim comments that restated code.
|
Thanks for the review. All nine suggestions are applied in 6b7f107.
|
Documentation CheckUpdates Needed
Automated review via Coder Agents |
Restores
agents-access(Coder Agents User) as a built-in organization role and adds it to every organization'sdefault_org_member_roles. Members keep Coder Agents by default, and admins can now restrict it per organization by removing the role from the defaults and granting it through IdP role sync or direct assignment.Since #28186, chat permissions lived in the organization-member floor, so the only way to limit Coder Agents was narrowing per-model access lists, which did not hide the feature.
agents-accessto every organization's defaults, so upgrading keeps every member's access. New organizations get it fromrbac.DefaultOrgMemberRoles().GetAuthorizationUserRoles), so they still need an explicit grant for chat.agents-accessat their next sign-in.IsRetiredRoleName) is removed.PATCH /api/v2/organizations/{organization}rejects duplicatedefault_org_member_rolesentries (the CLI already de-duplicated them).Agents-Accesswould otherwise become an undeletable shadow of the built-in role.Docs add "Control who can use Coder Agents" to the Agents getting-started guide.
NOTE: Migration 000602 deletes custom roles named
agents-access, which the built-in role would shadow. The down migration does not restore them. Stored member grants ofagents-accessfrom the earlier built-in role or a deleted custom role stay and now grant chat access.Validation
Known issues (not changed here)
organization-member,organization-service-account) returns 400 with a raw database unique-constraint error.Review record
6636c855ec): round 1 on 8bec029 passed with issues, fixed in d7ba937 and e0f16e1; round 2 on a6fef66 passed; round 3 on fb441df passed.