feat: scope chat model runtime to orgs#27357
Closed
mafredri wants to merge 1 commit into
Closed
Conversation
Docs preview📖 View docs preview for |
This was referenced Jul 20, 2026
mafredri
force-pushed
the
mathias/codagt-709-api
branch
from
July 21, 2026 10:15
fd93e80 to
2000f7b
Compare
mafredri
force-pushed
the
mathias/codagt-709-runtime
branch
from
July 21, 2026 10:15
79c6005 to
bb70ac3
Compare
mafredri
force-pushed
the
mathias/codagt-709-api
branch
from
July 21, 2026 10:27
2000f7b to
c40bbe9
Compare
mafredri
force-pushed
the
mathias/codagt-709-runtime
branch
from
July 21, 2026 10:27
bb70ac3 to
ee3177e
Compare
Resolve runtime settings and model caches within each chat organization, propagate scoped invalidations, and update backend operational callers.
mafredri
force-pushed
the
mathias/codagt-709-api
branch
from
July 21, 2026 19:20
c40bbe9 to
546eb44
Compare
mafredri
force-pushed
the
mathias/codagt-709-runtime
branch
from
July 21, 2026 19:20
ee3177e to
39e7f51
Compare
Member
Author
|
Closing because the implementation approach was rejected by the operator. Do not reuse or merge this stack.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Review boundary
Review slice 4 of CODAGT-709. Do not merge this PR separately. The full dependent stack will be reviewed, squashed into one commit, reverified, and merged atomically to
main.This slice owns organization-aware chat runtime selection, cache and singleflight isolation, pubsub invalidation, telemetry, CLI, scaletest, and non-site caller migrations.
Depends on: #27356
The final site review slice is preserved separately and will be based on this PR. It is blocked because seven CODAGT-714-owned settings and model-management pages still need organization context, and repository hooks typecheck the complete site. No fallback or compatibility behavior was added.
Verification
make gen,make fmt,make lint,make build, andgit diff --checkComplete CODAGT-709 stack plan
CODAGT-709: review-only hard-cut stack for organization-scoped chat model configs
Direction for approval
Implement CODAGT-709 as one atomic hard cut, decomposed into stacked PRs only to make review manageable. The PRs are not independently deployable or mergeable to
main. Each PR depends on the complete behavior introduced by later layers. After all layers are reviewed and the stack head passes verification, squash the full stack into one commit and merge it atomically tomain.The atomic change adds organization ownership, clones and remaps existing data, activates RBAC and ACLs, replaces global APIs and settings with organization-qualified contracts, scopes chat runtime and caches, migrates every supported caller, and removes the legacy contracts. There is no compatibility period and no intermediate production state.
CODAGT-714 remains separate. CODAGT-709 supplies the organization-scoped model CRUD, settings, and ACL APIs that CODAGT-714 will consume, but does not implement the organization picker, model-management UI migration, settings UI migration, empty-state UI, or sharing UI.
Observable end state
chat_model_configsis organization-owned andorganization_idis non-null.ResourceChatModelConfigsupports create, read, update, delete, and share. There is noActionUse.readonly.readand have an empty user ACL.Settled decisions
Stack and merge model
main; every later PR is based on the previous PR branch.main.main.Migration
The up migration performs the original hard cut in one transaction:
organization_id,user_acl, andgroup_acltochat_model_configs.readfor the organization's Everyone group, keyed by organization ID.chats.last_model_config_idthrough the chat's organization.organization_idtochat_messages, backfill it from the parent chat, and remapmodel_config_idthrough that organization.organization_idtochat_queued_messages, backfill it from the parent chat, and remapmodel_config_idthrough that organization.chat_debug_runs.model_config_idthrough the debug run's chat organization.(id, organization_id)keys for model configs and chats.organization_idwhereis_default = true AND deleted = false.No compatibility, coexistence, inheritance metadata, synchronization, fallback, or shadow rows are added.
Downgrade
The down migration preserves the original deterministic collapse behavior:
The downgrade is intentionally lossy with respect to organization-specific settings and defaults, but it preserves model rows and references.
RBAC and ACLs
ResourceChatModelConfigas an organization-scoped resource.ActionUse.ChatModelConfig.RBACObject()with organization, identifier, user ACL, and group ACL.ChatModelConfigConverterfor RegoSQL.ResourceDeploymentConfigchecks on model CRUD with the new resource.ActionReadauthorization filtering.read. Reject other ACL actions.readgrants make migrated configs available to organization members.Defaults and writes
readACL.API
Replace the legacy model routes with the hard-cut organization contract:
GET /api/experimental/organizations/{organization}/chats/modelsGET /api/experimental/organizations/{organization}/chat-model-configsPOST /api/experimental/organizations/{organization}/chat-model-configsGET /api/experimental/chat-model-configs/{modelConfig}PATCH /api/experimental/chat-model-configs/{modelConfig}DELETE /api/experimental/chat-model-configs/{modelConfig}GET /api/experimental/chat-model-configs/{modelConfig}/aclPATCH /api/experimental/chat-model-configs/{modelConfig}/aclReplace model-bearing settings routes with organization-qualified routes under:
The scoped settings are:
The deployment-wide personal-model-overrides enablement flag remains deployment-scoped because it is not model-bearing.
All legacy global model discovery, model CRUD, ACL, and model-bearing settings routes are removed. Do not retain gone handlers, redirects, default-organization adapters, or fallback routes.
Settings storage
Chat model selection and runtime
organization_idand resolves every model choice in that organization.model_config_idmust identify an enabled, readable config in the requested organization.Cache and pubsub
SDK, frontend, CLI, scaletest, and telemetry
chat.organization_id.selectedOrginAgentCreateForm.CODAGT-714 exclusion
CODAGT-709 does not implement:
CODAGT-714 consumes the final organization CRUD, ACL, and settings APIs after CODAGT-709 merges atomically.
Ruled-out directions
main.Review-only PR stack
The active stack begins at #27354. Closed PRs #27337, #27338, and #27340 are not stack layers and provide no merge dependency.
PR 1, #27354: database hard cut
Branch:
mathias/codagt-709-databaseBase:
main.Review focus: Schema, migration correctness, organization-qualified storage, same-organization constraints, defaults, and generated database interfaces.
Boundary:
PR 2, #27355: RBAC and dbauthz
Branch:
mathias/codagt-709-rbacBase: #27354.
Review focus: Resource policy, ACL-backed authorization, authorized SQL filtering, role behavior, and database authorization coverage.
Boundary:
ResourceChatModelConfigwith create, read, update, delete, and share.ChatModelConfig.RBACObject()and generated RBAC objects and SDK resources.PR 3, #27356: API, SDK, and organization settings
Branch:
mathias/codagt-709-apiBase: #27355.
Review focus: Hard-cut HTTP contracts, SDK contracts, model CRUD, ACL validation, defaults, organization-scoped settings, and item concealment.
Boundary:
PR 4, #27357: runtime and backend callers
Branch:
mathias/codagt-709-runtimeBase: #27356.
Review focus: End-to-end backend organization isolation and migration of every non-site caller.
Boundary:
Pending site slice: frontend callers and final stack-head verification
Base: #27357.
Status: Preserved but not opened as an active PR. It is blocked until separately owned CODAGT-714 supplies organization context to all seven settings and model-management pages listed below. Repository hooks typecheck the complete site, so the site slice cannot pass required hooks while those pages still call the hard-cut organization-required API without an organization.
The seven blocking pages are:
site/src/pages/AISettingsPage/CoderAgentsPage/CoderAgentsPage.tsxsite/src/pages/AISettingsPage/ModelsPage/AddModelPage/AddModelPage.tsxsite/src/pages/AISettingsPage/ModelsPage/ModelsPage.tsxsite/src/pages/AISettingsPage/ModelsPage/UpdateModelPage/UpdateModelPage.tsxsite/src/pages/AgentsPage/AgentSettingsAPIKeysPage.tsxsite/src/pages/AgentsPage/AgentSettingsCompactionPage.tsxsite/src/pages/AgentsPage/AgentSettingsUserAgentsPage.tsxCODAGT-714 owns adding organization context, picker behavior, model-management UI migration, settings UI migration, sharing UI, empty-organization UI, and its Storybook coverage. CODAGT-709 does not implement those behaviors.
After CODAGT-714 supplies organization context, the pending site slice contains only CODAGT-709 caller migration and verification work:
chat.organization_id.AgentCreateForm.selectedOrg.id.Stack dependencies and atomic merge procedure
mainfor review context.main.maincontains the complete hard cut.main...stack-headdiff into one commit on a final integration branch.main.Full-stack invariants
main.Verification at the stack head and squash commit
Run all checks on both the reviewed PR 7 head and the exact final squash commit:
make gen.make fmt.make lint.make buildor the repository's required final build entry point.git diff --check.A failure in any layer is a failure of the complete stack. Do not merge a partial layer or add compatibility behavior to make an intermediate PR independently deployable.
References
/home/coder/.coder/plans/CODAGT-709-full-implementation.patch.