Skip to content

feat(coderd/x/chatd): gate plugin packs by project and chat enablement - #204

Merged
ibetitsmike merged 16 commits into
mainfrom
mike/plugin-packs-5-chatd-gating
Nov 11, 2026
Merged

ibetitsmike merged 16 commits into
mainfrom
mike/plugin-packs-5-chatd-gating

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Xum opened this PR on behalf of @ibetitsmike.

Second part of PR3 of plugin packs (R7.3), stacked on #203. A chat now uses an installed pack only when the pack is enabled for the chat's project or for the chat. The next PR writes the enabled packs into the workspace.

What changes

  • filterPackResources in coderd/x/chatd/fork_plugin_gate.go now takes the chat. With fork-plugin-packs off it still drops every pack row. With it on, it drops rows of installed packs that are not enabled for the chat.
  • An installed pack is one under ~/.coder/plugins/<name>/, the directory the next PR writes packs into. The gate reads <name> from the row's manifest path. Packs the user placed elsewhere, such as ~/.claude/plugins/cache, are not gated.
  • The enabled set is the packs of the chat's project, when the owner can use the project (resolveUsableChatProjectID), plus the packs enabled on the chat itself and on each of its ancestors (the root and, with fork-nested-subagents, the chats in between, via AncestorChatIDs). Subagents inherit the project's packs and their ancestors' packs. The lookups run as chatd, like project skills, and only when a chat has installed pack rows. A failed lookup enables nothing.
  • All four callers pass the chat: the prompt builder, the context resource listing, the custom agent types for spawn_agent, and the agent type catalog. The catalog passes a chat that doesn't exist yet, so it sees only the project's packs.
  • DriftHash is unchanged. A workspace holds the packs of all its chats, so filtering happens per chat after pinning.
  • coderd/x/chatd/ARCHITECTURE.md gets a TODO for the pack gate, for the human author.

Known limitations

  • The gate detects an installed pack by the /.coder/plugins/<name>/ segment of its manifest path. If ~/.coder or ~/.coder/plugins is a symlink, the agent stores the resolved path, so the pack is not gated and reaches every chat on the workspace. A user's own pack under some other .coder/plugins/ directory is gated.
  • When an enabled and a disabled pack define an agent with the same name, the agent can keep only the disabled pack's definition, and the gate then drops it.
  • DriftHash covers every pack on the workspace, so a pack file change marks all chats on that workspace context-dirty, including chats that do not have the pack enabled. Their refresh changes nothing.
  • Disabled packs count toward the agent's resource and byte caps, so on very large installs they can push enabled pack resources out of the snapshot.

Validation

  • In a container: go build ./coderd/... ./enterprise/... and go vet ./coderd/x/chatd/.
  • Tests passed: TestManagedPackName, TestFilterPackResources (against Postgres: project packs, chat packs, a subagent inheriting its root chat's packs and adding its own, a nested subagent inheriting every ancestor's packs, a chat with nothing enabled, and the catalog's new chat), TestAgentRowDefinitionsGatesPackAgents, TestIsPackContribution, TestDriftHash, TestPinnedWorkspaceContext, TestContextResources, TestForkAgentDefinition*, and coderd TestForkAgentTypes.

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
…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
@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:19:00.105116Z f049a85 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.

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

ℹ️ 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/x/chatd/fork_plugin_gate.go Resolved
Comment thread coderd/x/chatd/fork_plugin_gate.go Resolved
Comment thread coderd/x/chatd/fork_plugin_gate.go Resolved
Comment thread coderd/x/chatd/fork_plugin_gate.go Resolved
Comment thread coderd/x/chatd/fork_plugin_gate.go Resolved
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

@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: 8c914e1f38

ℹ️ 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/x/chatd/fork_plugin_gate.go Resolved
Comment thread coderd/x/chatd/fork_plugin_gate.go Resolved
Comment thread coderd/x/chatd/fork_plugin_gate.go Resolved
Base automatically changed from mike/plugin-packs-4-enablement-api to main November 11, 2026 17:11
@ibetitsmike

Copy link
Copy Markdown
Owner Author

@codex review

Xum posted this on behalf of @ibetitsmike.

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

ℹ️ 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/x/chatd/ARCHITECTURE.md Resolved
@ibetitsmike
ibetitsmike merged commit 6862ebc into main Nov 11, 2026
10 checks passed
@ibetitsmike
ibetitsmike deleted the mike/plugin-packs-5-chatd-gating branch November 11, 2026 18:48
@ibetitsmike

Copy link
Copy Markdown
Owner Author

Xum merged this PR on behalf of @ibetitsmike.

Merged as a squash of head f049a85e9c, on top of main e7de95c8f9 (#203).

  • CI: fork-ci run 43066188749 passed on the exact head, which is based on current main.
  • Codex: review 5862675880 on f049a85e9c had one P1 asking to remove the architecture TODO. It was replied and resolved, because repository rules have the author leave chatd architecture TODOs for the owner. 0 unresolved threads.
  • UAT: covered by UAT205 run 2 on feat(coderd/x/chatd): write enabled plugin packs into chat workspaces #205 at acc1354693, which contains this head unchanged. A pack enabled on a project showed its skills and agents in the chat by turn 2 with no manual context refresh. A second chat in the project saw them, a chat outside the project saw none, chat-level enable and disable took effect at once, members got 404 on other members' packs, and with fork-plugin-packs off the routes returned 403. Teardown and leak audit were clean.
  • Follow-up for the owner: the TODO this PR adds in "#### Generation goroutine" of coderd/x/chatd/ARCHITECTURE.md.

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