Skip to content

refactor(coderd): move chat model ACL handlers onto the shared ACL helpers - #31015

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

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

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Moves the chat model ACL handlers onto the organization ACL helpers in coderd/mcp_acl.go, which MCP server configs and organization skills already share. It deletes the model copies of the user and group resolvers, the member count query, the list of available principals, the organization and duplicate ID checks, and the role update loop: 30 lines added, 321 removed.

Two shared helpers change:

  • resolveACLUsers and resolveACLGroups pass each stored ACL entry to the callback, so the model ACL reads each role from it.
  • resolveACLGroups takes an organization ID. The model ACL passes its organization, so groups from other organizations stay hidden. MCP server configs and organization skills pass uuid.Nil, which keeps every organization, as today.

What changes: successful responses stay the same. On error paths, a stored key that is not a UUID is skipped without a warning log (PATCH validation rejects such keys), 500 details use the shared texts (get ACL users instead of hydrate chat model ACL users), duplicate ID errors come back in the same 400 as the other validation errors because the check now runs inside the write transaction, and a failed membership lookup skips the group check.

Why it is safe: TestChatModelACL checks that groups from other organizations stay hidden, and TestChatModelACLValidationIsAtomic covers the duplicate check. I ran 9 mutants of the changed lines with go test -overlay: ignore the organization in resolveACLGroups or pass uuid.Nil from each handler, drop the stored entry given to either callback, report zero members, and apply group roles to users or user roles to groups. The tests fail on each.

Review focus: uuid.Nil means every organization in resolveACLGroups, as it does in GetGroups.

Validation: on main and on this branch, go test ./coderd -run '(?i)acl|mcp|skill' -count=1 passes (24 tests, 62 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 (make gen, formatting, golangci-lint, slim build).

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.

…lpers

The chat model ACL read, available, and update handlers kept their own
copies of the user and group resolvers, the member count query, the
organization checks, and the key canonicalization that coderd/mcp_acl.go
already shares between MCP servers and organization skills. Use the
shared helpers and delete the copies.

resolveACLUsers and resolveACLGroups now pass each stored ACL entry to
the callback so chat roles can be read from it, and resolveACLGroups
takes an organization ID (uuid.Nil keeps every organization) so the
model ACL still hides groups from other organizations.
@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:51:31.874120Z 65c242b 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. Keep it up!

Reviewed commit: 65c242b762

ℹ️ 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

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 65c242b762

ℹ️ 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".

Comment thread coderd/mcp_acl.go

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