Skip to content

refactor(coderd): move chat and chat project ACL reads onto the shared helpers - #31016

Open
ibetitsmike wants to merge 1 commit into
mike/chat-acl-shared-helpersfrom
mike/chat-acl-shared-helpers-chats
Open

ibetitsmike wants to merge 1 commit into
mike/chat-acl-shared-helpersfrom
mike/chat-acl-shared-helpers-chats

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Moves the chat ACL and chat project ACL reads onto resolveACLUsers and resolveACLGroups, and the chat ACL update onto applyACLReadRoles. It deletes chatACLUsers, chatACLGroups, chatProjectACLGroups, and the user lookup in chatProjectACLUsers: 26 lines added, 174 removed. Both reads counted group members with one query per group; the shared resolver counts every group in one query.

Both reads still list groups from every organization (uuid.Nil), and the project read still drops users outside the project's organization before it resolves them. The resolvers' doc comments and nolint reasons now say that callers authorized reading the ACL, because these two reads check read access, not share.

What changes: successful responses stay the same. A stored key that is not a UUID is skipped without a warning log, 500 details use the shared texts, and an empty project ACL runs its lookups with empty ID lists instead of returning early.

Why it is safe: #31014 pins the member counts and user fields of both reads. I ran 5 mutants of the changed lines with go test -overlay: apply group roles to users or user roles to groups in the chat ACL update, keep project users from other organizations, filter project groups by organization, and drop the stored entry of project users. The tests fail on each.

Review focus: chatProjectACLUsers, which filters by membership and then resolves users through the shared helper.

#29663 batches the same per-group count query in coderd/exp_chats_acl.go, so the two conflict. The chat ACL update still writes request keys as sent, as on main; #31037 canonicalizes them. It merges with this PR without conflicts, and whichever merges second will merge main first.

Validation: on main and on this branch, go test ./coderd -count=1 passes with -run '(?i)acl|mcp|skill' (24 tests, 62 with subtests) and with -run '^(TestChatProjectSharing|TestChatSharingDisabled|TestListChatsSharedScope|TestSharedReaderStreamChat|TestChatFileDownloadURL)$' (5 tests, 22 with subtests), and go test ./enterprise/coderd -run '(?i)acl|mcp|skill|TestEnterpriseAuditLogs' -count=1 passes (9 tests, 46 with subtests). The pre-commit hook passed.

Stack

This stack moves the chat, chat project, and chat model ACL handlers onto the organization ACL helpers that MCP server configs and organization skills share, and deletes their copies. Successful ACL responses do not change.

  1. test(coderd): pin member counts and user details in chat and project ACL reads #31014 Pin member counts and user details in chat and project ACL reads
  2. refactor(coderd): move chat model ACL handlers onto the shared ACL helpers #31015 Move chat model ACL handlers onto the shared ACL helpers
  3. refactor(coderd): move chat and chat project ACL reads onto the shared helpers #31016 Move chat and chat project ACL reads onto the shared helpers

Xum, an AI agent, opened this PR for @ibetitsmike and wrote this description.

…d helpers

getChatACL and getChatProjectACL resolved users and groups with their
own loops and counted group members with one query per group. Use
resolveACLUsers and resolveACLGroups, which count every group in one
query, and apply chat ACL updates with applyACLReadRoles.
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

Xum, an AI agent, requested this review for @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T22:50:11.327047Z e8b68d6 Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: e8b68d6a87

ℹ️ 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 marked this pull request as ready for review October 19, 2026 22:48

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant