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. #31014 Pin member counts and user details in chat and project ACL
reads
2. #31015 Move chat model ACL handlers onto the shared ACL helpers
3. #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.