Repository navigation
feat(coderd/database): add project-tier agent definition queries - #72
Conversation
…initions
Add CRUD routes for a member's stored agent definitions under
/api/v2/chats/fork/organizations/{organization}/members/{user}/agent-definitions,
the SDK types and client methods, and the generated API docs. Content is
parsed with workspacesdk.ParseAgentDefinition and the front-matter names the
definition. Writes are not audited.
Part of #7.
Add CRUD routes for organization-tier stored agent definitions under
/api/v2/chats/fork/organizations/{organization}/agent-definitions and the
SDK methods. A new definition grants read to the Everyone group, like a new
organization skill, and the list is filtered by each row's ACL.
Part of #7.
…erence The routes are gated by an experiment, so mark them with @x-apidocgen skip like the fork chat todo routes.
…es-6-agent-definition-routes
… mike/custom-agent-types-6b-org-agent-definition-routes
|
@codex review
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…es-9-project-queries # Conflicts: # coderd/database/forkdb/agent_definitions.sql.go # coderd/database/forkdb/sqlc.yaml # coderd/database/migrations/chatdmig/nodes/01a1c242-decb-7db2-b52e-38c2843c434c_agent_definition_acl_org_member_delete.up.sql # coderd/fork_agent_definitions_test.go # coderd/fork_organization_agent_definitions_acl.go
|
@codex review
|
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Merge evidence for head
|
Part of #7
Based on main now that #71 has merged. First of three project-tier PRs: this one adds the schema guard and the queries. The next adds the fork routes under
/api/v2/chats/fork/organizations/{organization}/projects/{project}/agent-definitions, and the last resolves project-tier rows into the spawn catalog behind the usable-project check. #69 has landed. Splitting keeps each under 500 lines.Schema guard
A project-tier row stores both
organization_idandproject_id, unlike a project skill, whoseorganization_idis NULL. The new chatd node01a1c246-…_agent_definition_project_organizationadds aBEFORE INSERT OR UPDATE OF organization_id, project_idtrigger onagent_definitionsthat raisesagent_definitions_project_organization(check violation) when the project is not in the row's organization. Without it, a row could be read through an organization that does not own its project.chat_projects.organization_idnever changes, so no trigger onchat_projectsis needed.Queries
InsertProjectAgentDefinition,GetProjectAgentDefinitionByName,ListProjectAgentDefinitionMetadata,UpdateProjectAgentDefinitionByNameandDeleteProjectAgentDefinitionByName, keyed byproject_idand name.dbauthz authorizes them like upstream's project skill queries, through
authorizeChatProjectConfigon the project: read for get and list, update for insert, update and delete. The row's own RBAC object stays unauthorizable, as before.Tests
TestAgentDefinitions/ProjectTier: inserting into another organization and moving a row to another organization both fail withagent_definitions_project_organization. Names are unique per project. Update, get and list stay in the project, and an organization-tier row in the same organization is not listed. Delete removes the row.TestForkQuerier: the five queries assert the project object with the right action.ProjectTier. Authorizing insert for read instead of update failsTestForkQuerier.TestAgentDefinitions,TestSQLCSchemaOrder,TestForkQuerier, thechatdmigpackage withCHATDMIG_TEST_DATABASE_URLset (includingTestForkNodesOnlyAddToChatd),chatdmig check, and golangci-lint (no findings in the changed files).Size
221 non-generated lines added: 25 migration node, 32 queries, 60 dbauthz and dbmetrics, 103 tests and 1 sqlc config. The rest is sqlc and mock output.