chore: remove legacy chat template allowlist by ethanndickson · Pull Request #27515 · coder/coder · GitHub
Skip to content

chore: remove legacy chat template allowlist - #27515

Merged
ethanndickson merged 2 commits into
mainfrom
feat-remove-chat-template-allowlist
Aug 6, 2026
Merged

chore: remove legacy chat template allowlist#27515
ethanndickson merged 2 commits into
mainfrom
feat-remove-chat-template-allowlist

Conversation

@ethanndickson

@ethanndickson ethanndickson commented Jul 27, 2026

Copy link
Copy Markdown
Member

Relates to CODAGT-713

Depends on #27514

Removes the legacy deployment-wide allowlist now that the API and frontend use per-template agents_allowed: the experimental /template-allowlist routes, SDK methods and generated types, site config queries, frontend bindings, and the now-unused xjson utility.

Migration 000563 deletes the obsolete agents_template_allowlist value. It's irreversible for deployments that configured an allowlist, which I think is fine, since 000562 already drops agents_allowed on the way down, and this release ships 000548 and 000555 with the same property.

Two side effects of the model change worth writing down, both from #27514 rather than here. The value used to need ActionRead on ResourceDeploymentConfig to read and deployment config update to write. AgentsAllowed is now a plain field on the template response, readable by anyone who can read the template, and it's set with a template update, so org admins manage it themselves. That's the delegation we wanted, and it's tracked in the audit log.

The rest of the stack adds --agents-allowed to the CLI and updates the platform controls docs.

@linear-code

linear-code Bot commented Jul 27, 2026

Copy link
Copy Markdown

CODAGT-713

@ethanndickson
ethanndickson force-pushed the feat-remove-chat-template-allowlist branch from 7590a7a to f90d237 Compare July 27, 2026 10:47
@ethanndickson
ethanndickson force-pushed the feat-site-template-agents-allowed branch from ca6e762 to 35387b5 Compare July 27, 2026 10:47
@ethanndickson
ethanndickson force-pushed the feat-remove-chat-template-allowlist branch from f90d237 to d1cdd80 Compare August 3, 2026 05:12
@ethanndickson
ethanndickson force-pushed the feat-site-template-agents-allowed branch from 35387b5 to 616f118 Compare August 3, 2026 05:12
@ethanndickson
ethanndickson force-pushed the feat-remove-chat-template-allowlist branch 2 times, most recently from 0e1a0b6 to 8acb538 Compare August 3, 2026 08:41
@ethanndickson
ethanndickson force-pushed the feat-site-template-agents-allowed branch from 4dcfdf6 to 33c31a7 Compare August 4, 2026 04:28
@ethanndickson
ethanndickson force-pushed the feat-remove-chat-template-allowlist branch from 8acb538 to 0e64d11 Compare August 4, 2026 04:28
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

@ethanndickson

Copy link
Copy Markdown
Member Author

/coder-agents-review

@coder-agents-review

coder-agents-review Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Chat: Review posted | View chat
Requested: 2026-08-04 04:49 UTC by @ethanndickson
Spend: $36.52 / $100.00

Review history
  • R1 (2026-08-04): 20 reviewers, 1 Nit, 1 Note, 1 P1, 8 P3, 1 P4, REQUEST_CHANGES. Review

deep-review v0.9.0 | Round 1 | 33c31a7..0e64d11

Last posted: Round 1, 12 findings (1 P1, 8 P3, 1 P4, 1 Nit, 1 Note), REQUEST_CHANGES. Review

Finding inventory

Finding inventory, PR #27515

Findings

# Sev Status Location Summary Round Reviewer Posted
CRF-1 P3 Open docs/ai-coder/agents/platform-controls/template-optimization.md:15 "Restrict available templates" documents the deleted deployment-wide allowlist; rewrite is authored in upstack #27518 R1 Netero P2, orchestrator downgraded to P3 Yes
CRF-2 P3 Open docs/ai-coder/agents/platform-controls/index.md:82 Template routing section repeats removed allowlist semantics; rewrite is authored in upstack #27518 R1 Netero P2, orchestrator downgraded to P3 Yes
CRF-3 P3 Open docs/ai-coder/agents/tools/index.md:217 Bullet names "the administrator's allowlist"; enforcement now reads templates.agents_allowed. Not fixed in #27518 R1 Netero Yes
CRF-4 P1 Merged into CRF-6 (same location, same fix) coderd/database/migrations/000563_delete_agents_template_allowlist.up.sql:1 Rollback below 000562 leaves neither the column nor the row, so an older binary fails open R1 Netero P3 No
CRF-5 Nit Raised in review body (process observation) coderd/database/migrations/000563_delete_agents_template_allowlist.up.sql:1 PR body says migration 000553; the added file is 000563 R1 Netero No
CRF-6 P1 Open coderd/database/migrations/000563_delete_agents_template_allowlist.up.sql:1 The DELETE disarms allowlist enforcement in every pre-#27514 binary, silently, on a normal rolling upgrade R1 Knuckle P2, Meruem P2, Kite P2, Knov P2, Komugi P2, Kurapika P2, Hisoka P3, Netero P3; orchestrator raised to P1 Yes
CRF-7 P3 Open docs/ai-coder/agents/tools/index.md:48 Second stale "template allowlist" sentence in the same file; not covered by CRF-3 and not fixed by #27518 R1 Kite, Zoro, Mafuuu, Leorio, Mafu-san Yes
CRF-8 P2 Raised in review body (process observation) n/a (PR-level) All 20 CI jobs red on the head commit with no explanation; no merge signal R1 Mafu-san P1, orchestrator downgraded to P2 No
CRF-9 P3 Open coderd/database/queries/siteconfig.sql:316 No deployment-level default survives, so every template created after the migration is agent-usable and the restriction decays R1 Knov Yes
CRF-10 P3 Open coderd/coderd.go:1403 Authority to grant agents template access drops from deployment-config update to template update, with no ceiling left R1 Knov P3, Kurapika P4 Yes
CRF-11 P4 Open coderd/database/queries/siteconfig.sql:224 Two sibling orphaned chat site_configs settings survive the same cleanup premise R1 Pariston Yes
CRF-12 P3 Open coderd/database/migrations/000563_delete_agents_template_allowlist.up.sql:1 migrate_test.go:2016 still asserts 000562 preserves the row, so the guard is vacuous once 000563 destroys it R1 Meruem Yes
CRF-13 P3 Open coderd/database/migrations/000563_delete_agents_template_allowlist.down.sql:1 The no-op comment explains 000562's conversion, not that the up migration destroyed the only copy R1 Leorio Yes
CRF-14 Nit Open coderd/database/migrations/000563_delete_agents_template_allowlist.up.sql:1 The destructive statement carries no comment while the no-op down carries two lines of rationale R1 Gon, Leorio Yes
CRF-15 Nit Raised in review body (process observation) n/a (PR-level) refactor: for a change that deletes released endpoints and production data; repo precedent is chore: R1 Mafu-san No
CRF-16 Note Open coderd/database/dbauthz/dbauthz.go:3618 The deleted wrapper comment recorded an admin-only-read invariant the replacement does not hold; nothing records the visibility change R1 Hisoka, Kite, Meruem, Zoro Yes

Contested and acknowledged

None.

Round log

Round 1

Netero first pass, then a 20-reviewer panel (Bisky, Hisoka, Mafu-san, Mafuuu, Pariston, Komugi, Gon, Leorio, Knuckle, Kurapika, Kite, Ryosuke, Knov, Ging-Go, Ging-TS, Nami, Chopper, Melody, plus wildcards Zoro and Meruem). Law not spawned: effective additions are 4.

Netero reported 2 P2 (docs), 2 P3, 1 Nit, 1 Note.

Orchestrator verification of Netero's two P2s (docs drift):

  • Keep-at-P2 argument: a stacked PR can merge on its own once its downstack lands, so chore: remove legacy chat template allowlist #27515 could reach main while the docs PR stalls, leaving docs/ describing a deleted API and, per Netero, a nonexistent settings page. No-follow-up assumption says the docs fix may never land.
  • Evidence against: I fetched pull/27518/head (commit 0d9baa4863) into the orchestrator worktree and read its diff. It rewrites both flagged sections to the per-template Allow Coder Agents model. Netero's claim that no settings page exists is also wrong: site/src/pages/AISettingsPage/TemplatesPage/ toggles agents_allowed (his grep searched for the literal label "Manage Agents", which is absence of a string, not absence of a page).
  • Disposition: downgraded to P3, kept open. CRF-3 stays P3 because docs: document per-template agents_allowed #27518 does not touch docs/ai-coder/agents/tools/index.md.

Convergence, CRF-4 raised to P1 as CRF-6. Seven reviewers independently reached the same location from different triggers:

  • Rollback path (Netero, CRF-4): migrate below 000562 and neither the column nor the row survives.
  • Forward path (Knuckle, Meruem, Kite, Knov, Komugi): the DELETE lands in the same release as the last reader, so still-running pre-feat(site): add per-template Coder Agents controls #27514 replicas fail open for the length of the rollout, and permanently if the operator rolls the binary back without touching migrations.
  • Corrupt-value path (Hisoka, empirically reproduced; Kurapika; Mafuuu): 000562 declines to consume a corrupt value and leaves every template allowed; 000563 then destroys the only record of what the admin intended, in the same transaction.

Consequence chain: an access control on agent workspace creation fails open, silently (missing row and unconfigured are the same value in the old reader), across three independent triggers, with no recovery, and the DELETE buys nothing at head because no code reads the row after this diff. Orchestrator raised to P1 and merged CRF-4 into CRF-6, since one fix (drop 000563) closes all three.

Independent orchestrator verification of the claim driving the P1: origin/main at 1f946bb50b wires p.chatTemplateAllowlist into all three chat tools (coderd/x/chatd/chatd.go:3943,3947,3957), and chatTemplateAllowlist() (chatd.go:217) reads GetChatTemplateAllowlist per call with no cache and returns nil on empty or error, which the tools read as all-allowed. git tag --contains 7713788aab is empty, so no released tag contains the enforcement move. Chopper separately confirmed the routes ship in v2.34.7, v2.35.0, and v2.35.3.

Downgrade gate on Mafu-san's P1 for red CI (CRF-8):

  • Keep-at-P1 argument: 20 of 20 jobs are red, nobody can read the logs, and a review cannot substitute for CI. Merging with no signal risks shipping a break.
  • Evidence against: five worktrees independently ran go build ./..., go vet, gofmt -l, coderd/database/generate.sh (clean git status after), go run ./scripts/apitypings, tsc --noEmit -p site, TestMethodTestSuite, TestMigrate (Once, Twice, Parallel, UpDownUp) and TestMigrateUpWithFixtures against real Postgres, all green. The failure set includes changes, lint-actions, offlinedocs, and notify-slack-on-failure, which this diff cannot affect.
  • Disposition: P2, raised in the review body as a process observation. It blocks merge but is not evidence of a defect in the diff.

No findings from Bisky, Ryosuke, Chopper, Melody, Nami, Ging-Go, or Ging-TS. All seven verified the deletion's completeness independently and agreed: no dangling reference, no orphaned test helper, no lost coverage, no swagger or apidoc regeneration owed.

Reviewed against 33c31a7..0e64d11.

About deep-review

CRF = Coder Review Finding (P0-P4, Nit, Note)

Reviewer Focus
Bisky tests
Chopper ops/errors
Churn-guard change verification
Ging language modernization
Gon naming
Hisoka edge cases
Killua perf
Kite change integrity
Knov contracts
Knuckle SQL
Komugi flake/determinism
Kurapika security
Law decomposition
Leorio docs
Luffy product
Mafu-san process
Mafuuu contracts
Melody dispatch/pairing
Meruem structural
Nami frontend
Netero mechanical checks
Pariston premise testing
Pen-botter product gaps
Razor verification
Robin duplication
Ryosuke Go arch
Takumi concurrency
Zoro shape

🤖 Managed by Coder Agents.

@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: 0e64d11799

ℹ️ 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/database/migrations/000563_delete_agents_template_allowlist.down.sql Outdated
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review:

re: P1 Badge Preserve the legacy allowlist for rollback

This is intentionally destructive, same as 000387 and 000555. We don't support rollbacks, and the only thing lost is a list of template IDs an admin can set again from the AI Settings page, so I'd rather accept the loss than restore it.

Restoring would be worse in the common case: a deployment that never configured an allowlist has every template at agents_allowed = true, so we'd write out exactly the templates that existed at rollback time and old chatd would deny anything created after that. Fail-closed for everyone, to avoid a fail-open for the few deployments that set a list.

000562 already drops agents_allowed on the way down, so the rollback loses data regardless of what 000563 does.

@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: 0e64d11799

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

@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review

re: Preserve the legacy allowlist for rollback

This is intentionally destructive, same as 000387 and 000555. We don't support rollbacks, and the only thing lost is a list of template IDs an admin can set again from the AI Settings page, so I'd rather accept the loss than restore it.

Restoring would be worse in the common case: a deployment that never configured an allowlist has every template at agents_allowed = true, so we'd write out exactly the templates that existed at rollback time and old chatd would deny anything created after that. Fail-closed for everyone, to avoid a fail-open for the few deployments that set a list.

000562 already drops agents_allowed on the way down, so the rollback loses data regardless of what 000563 does.

re: Retain the allowlist through mixed-version rollouts

Deliberately not deferring this. agents_allowed is ANDed with normal template RBAC, so during the window an agent can only reach templates the requesting user could already create a workspace from by hand. It's an agent-specific gate lapsing for the length of a rolling update, not an escalation.
We also don't defer destructive changes across releases anywhere else. 000371 drops api_keys.scope in the same migration that backfills scopes, 000505 drops the legacy chat provider tables outright, and 000555 rewrites login_type in place. Old replicas hitting 000371 break far harder than this.
Happy to revisit if this ever becomes a pattern we handle properly, but I don't want to invent an expand/contract convention in this PR.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 0e64d11799

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

@ethanndickson
ethanndickson marked this pull request as ready for review August 4, 2026 05:35
coder-agents-review[bot]

This comment was marked as resolved.

@coderagents

coderagents Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Documentation Check

This PR removes the legacy deployment-wide chat template allowlist (the /template-allowlist routes, SDK methods, and agents_template_allowlist site config) in favor of the per-template agents_allowed model. The current docs still describe the deployment-wide allowlist workflow and UI path, so they will be inaccurate once this stack lands.

The PR description defers the platform controls docs to the rest of the stack. This PR's diff contains no docs changes, so the items below remain open.

Updates Needed

  • docs/ai-coder/agents/platform-controls/template-optimization.md - The "Restrict available templates" section documents the deployment-wide allowlist (Agents > Settings > Manage Agents > Templates, "select templates", "Save"). Update to the per-template agents_allowed model.
  • docs/ai-coder/agents/platform-controls/index.md - The "Template routing" section describes restricting templates "using the template allowlist at Agents > Settings > Manage Agents > Templates". Update to reflect per-template controls.
  • docs/ai-coder/agents/tools/index.md - Stale deployment-wide allowlist references remain at HEAD: line 48 links to template-optimization.md#restrict-available-templates, and line 217 states "Templates outside the administrator's allowlist are rejected." Update once the per-template model is documented.

Automated review via Coder Agents

@ethanndickson ethanndickson changed the title refactor: remove legacy chat template allowlist chore: remove legacy chat template allowlist Aug 4, 2026
@ethanndickson
ethanndickson force-pushed the feat-remove-chat-template-allowlist branch from 0e64d11 to f5a8248 Compare August 4, 2026 06:20
@ethanndickson

Copy link
Copy Markdown
Member Author

@codex review:

re: P1 Retain the allowlist through mixed-version rollouts

Keeping the DELETE. The window is real but it's bounded by the rollout, and agents_allowed is ANDed with normal template RBAC, so an agent can only reach templates the requesting user could already create a workspace from by hand. It's an agent-specific gate lapsing for the length of a rolling update, not an escalation.

The rollback half of this doesn't hold up either. helm rollback against a migrated schema is already broken in this release: 000548 drops chat_messages.api_key_id, which v2.35.3 reads, and 000543 swaps the chat_status enum out from under chats. Anyone in that state has a broken chat subsystem, not a slightly wider allowlist.

We also don't defer destructive changes across releases anywhere in this repo. 000371 drops api_keys.scope in the same migration that backfills scopes, and 000555 rewrites login_type in place. Deferring here would be inventing an expand/contract convention in a cleanup PR, which I don't want to do by accident.

I've made the down migration comment honest about what it deleted, since the old wording described 000562's backfill rather than this migration.

@ethanndickson
ethanndickson force-pushed the feat-remove-chat-template-allowlist branch 2 times, most recently from 86acdb5 to 9847266 Compare August 5, 2026 05:13
@ethanndickson
ethanndickson force-pushed the feat-site-template-agents-allowed branch 2 times, most recently from 2932f73 to c18baff Compare August 5, 2026 05:53
@ethanndickson
ethanndickson force-pushed the feat-remove-chat-template-allowlist branch 5 times, most recently from a5561c0 to e7f74e3 Compare August 5, 2026 08:35
@ethanndickson
ethanndickson requested a review from johnstcn August 5, 2026 09:26
@ethanndickson
ethanndickson force-pushed the feat-site-template-agents-allowed branch from 73e9ab6 to e1df7ab Compare August 5, 2026 09:50
@ethanndickson
ethanndickson force-pushed the feat-remove-chat-template-allowlist branch 3 times, most recently from 6d831b3 to c16f754 Compare August 6, 2026 03:31
@ethanndickson
ethanndickson force-pushed the feat-site-template-agents-allowed branch 2 times, most recently from 6cd0526 to ccd94e6 Compare August 6, 2026 03:51
@ethanndickson
ethanndickson force-pushed the feat-remove-chat-template-allowlist branch from c16f754 to ccc4841 Compare August 6, 2026 03:51

ethanndickson commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

ethanndickson added a commit that referenced this pull request Aug 6, 2026
Relates to CODAGT-713

Depends on #27284

This makes the per-template `agents_allowed` field authoritative in the API and chatd. It adds optional create and metadata update fields with the intended default and omission semantics, supports `agents-allowed:` template search, includes the value in telemetry, and makes `list_templates`, `read_template`, and `create_workspace` read the template row directly. Existing-workspace retries remain idempotent, and blocked same-organisation templates return an actionable message.

The experimental `/template-allowlist` routes remain temporarily because the shipped AI Settings page still calls them, but they no longer control chatd enforcement. #27514 moves that page to per-template metadata, #27515 removes the legacy storage, routes, SDK types, and utility, #27517 adds the CLI flags, and #27518 updates the platform controls documentation for the per-template model, directly addressing CRF-5 and CRF-6. The stack is intended to merge as a unit.
@ethanndickson
ethanndickson changed the base branch from feat-site-template-agents-allowed to graphite-base/27515 August 6, 2026 04:15
ethanndickson added a commit that referenced this pull request Aug 6, 2026
Relates to CODAGT-713

Depends on #27285

This replaces the deployment-wide template allowlist UI with per-template Coder Agents controls. Each template's General Settings page exposes `agents_allowed` to organisation and template administrators through the existing template-update permission, whilst AI Settings > Templates gives deployment administrators a bulk management page. The bulk page requires both deployment-config and template-update permissions, reuses the same URL-backed server-side filter as `/templates`, tracks pending updates independently for each template, and surfaces failures through template-specific toasts. The copy refers to new workspace creation because disabling a template does not revoke an existing Coder Agent workspace.

This completes the frontend migration away from the experimental `/template-allowlist` API. #27515 removes the now-unused legacy storage, routes, SDK methods, generated types, and JSON utility. Later PRs add CLI flags and update the platform controls documentation. The stack is intended to merge as a unit.
@ethanndickson
ethanndickson changed the base branch from graphite-base/27515 to main August 6, 2026 04:23
@ethanndickson
ethanndickson force-pushed the feat-remove-chat-template-allowlist branch from ccc4841 to a23ce3a Compare August 6, 2026 04:24
@ethanndickson
ethanndickson merged commit d2f9280 into main Aug 6, 2026
29 checks passed
@ethanndickson
ethanndickson deleted the feat-remove-chat-template-allowlist branch August 6, 2026 04:35
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants