Skip to content

feat: enable plugin packs for chat projects and chats - #203

Merged
ibetitsmike merged 8 commits into
mainfrom
mike/plugin-packs-4-enablement-api
Nov 11, 2026
Merged

ibetitsmike merged 8 commits into
mainfrom
mike/plugin-packs-4-enablement-api

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

First part of PR3 of plugin packs (R7.3): an installed pack can now be enabled for a chat project or for one chat. A later PR filters a chat's pack skills by this set, and another writes the enabled packs into the workspace.

What changes

  • Schema: chatdmig node plugin_pack_enablement adds plugin_pack_projects (organization_id, project_id, pack_id) and chat_plugin_packs (organization_id, chat_id, pack_id). Both are fork tables, so upstream's chats table and the upstream create-chat paths don't change. The schema keeps a pack inside its organization: a foreign key on (pack_id, organization_id) points at plugin_packs, and a trigger checks that the project or chat is in the same organization. chat_projects and chats are upstream tables, so that side is a trigger, like agent_definition_project_organization.
  • Routes under /api/v2/chats/fork, behind the fork-plugin-packs experiment and hidden from the API docs like the other fork routes:
    • GET organizations/{organization}/projects/{project}/plugin-packs, plus PUT and DELETE on .../plugin-packs/{pluginPack}.
    • GET {chat}/plugin-packs, plus PUT and DELETE on {chat}/plugin-packs/{pluginPack}.
    • PUT and DELETE return 204 and can be repeated safely. GET returns only id, name and commit_sha.
  • Access: enabling a pack follows how skills are enabled and disabled (R7.3), so it needs update access to the project or chat, not read access to the pack. Org members can't read packs: admins choose which packs are installed, and enabling one exposes only its name and commit. The insert matches the pack to the project's or the chat's organization, so a pack ID from another organization gets the same 404 as an unknown ID. Pack names are unique within an organization, so a project or chat can't end up with two packs of the same name.

Validation

  • In a container: forkdb/generate.sh, chatdmig check, go build ./coderd/... ./enterprise/... ./codersdk/..., vet, and swag and apitypings regen (only the new entries are kept in coderd/apidoc and typesGenerated.ts).
  • Tests passed: forkdb TestPluginPackEnablementOrganization (raw inserts across organizations hit the trigger or the foreign key, and the queries match no row), dbauthz TestForkQuerier (new cases for all six queries), coderd TestForkPluginPackEnablement (a member enables a pack on their own project and chat; a pack from another organization and an unknown pack get 404; another member gets 404; disabling empties the list), TestForkPluginPacks, TestForkChatRoutes, the swagger tests, and ./coderd/database/migrations/chatdmig/ against Postgres 17.

Adds the plugin_packs and plugin_pack_resources tables (chatdmig node),
their forkdb queries with dbauthz and dbmetrics wrappers, and
coderd/x/pluginpacks, which fetches one commit of a pack directory over
smart HTTP with a host allowlist and fixed size caps.

Packs reuse the organization skill RBAC object, so only organization
admins and auditors read or manage them.
The 64 MiB transfer cap does not bound memory, because go-git inflates
every fetched object into memory storage before the per-file limits run.
Read the pack first and reject it when its object headers, and the target
sizes of its deltas, add up to more than 256 MiB.
Organization admins can allowlist Git hosts and install, update, list and
delete plugin packs through /api/v2/chats/fork/organizations/{organization}
behind the fork-plugin-packs experiment. An install or update fetches the
pack, pins the resolved commit and stores its files. Members cannot see
packs and auditors can only read them.
…nstall-api

# Conflicts:
#	coderd/database/dbauthz/fork_forkdb.go
#	coderd/database/dbauthz/fork_forkdb_test.go
#	coderd/database/dbmetrics/fork_forkdb.go
#	coderd/database/forkdb/forkdbmock/forkdbmock.go
#	coderd/database/forkdb/models.go
#	coderd/database/forkdb/plugin_packs.sql.go
#	coderd/database/forkdb/querier.go
#	coderd/database/forkdb/queries/plugin_packs.sql
#	coderd/database/forkdb/sqlc.yaml
#	coderd/x/pluginpacks/fetch_test.go
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T17:01:00.346339Z 4261106 Manual request
ℹ️ 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.

Base automatically changed from mike/plugin-packs-3-install-api to main November 11, 2026 16:34
…nablement-api

# Conflicts:
#	coderd/database/dbauthz/fork_forkdb.go
#	coderd/database/forkdb/forkdbmock/forkdbmock.go
#	coderd/database/forkdb/querier.go
#	coderd/database/forkdb/sqlc.yaml
#	coderd/fork_chat_routes.go

@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: a67f2451e7

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

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 4261106983

ℹ️ 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 merged commit e7de95c into main Nov 11, 2026
10 checks passed
@ibetitsmike
ibetitsmike deleted the mike/plugin-packs-4-enablement-api branch November 11, 2026 17:11
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Merged as a squash of head 4261106983, on top of main 0c32663607 (#201).

  • CI: fork-ci run 43063439672 passed on the exact head, which is based on current main.
  • Codex: the first review's P1 (no organization_id on the enablement tables) was fixed in 4261106983 with an org column, a composite FK and per-table triggers. Clean receipt 6802049927 on 4261106983. 0 unresolved threads.
  • Validation: container runs covered the migration, raw-SQL trigger tests and handler tests, including a member enabling a pack on their own project and a 404 for a cross-org pack ID.
  • UAT: these routes sit behind fork-plugin-packs, which the daily deployment does not enable. The end-to-end UAT on feat(coderd/x/chatd): write enabled plugin packs into chat workspaces #205, whose head contains this change, covers enablement together with chatd gating and materialization.
  • Size: about 450 hand-written non-test lines; the rest is generated (apidoc, sqlc, mocks, typesGenerated).

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