Repository navigation
feat: share organization agent definitions behind fork-agent-definitions - #71
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. More of your lovely PRs please. 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". |
|
@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". |
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2eef33ad7b
ℹ️ 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".
…write Lock the granted users' organization memberships before the definition row, like the organization skill ACL route, so a concurrent member removal cannot miss the new grant. Limit the member-removal cleanup to organization-tier rows, the only ones with ACLs.
|
@codex review
|
|
Codex Review: Didn't find any major issues. Hooray! 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". |
Closing and reopening only to make GitHub recompute the merge ref against current main ( |
The merge ref now points at current main ( |
Merge evidence for head
|
Part of #7
Stacked on #66 (organization-tier routes). Adds the ACL routes for organization agent definitions behind
fork-agent-definitions, and a regression test for read-time organization membership. PR9 adds the project tier.Routes
GET and PATCH on
/api/v2/chats/fork/organizations/{organization}/agent-definitions/{agentDefinition}/acl, in the sameregisterForkChatRoutesmount as #66.codersdk.OrganizationSkillACL,UpdateOrganizationSkillACLRequest) and helpers (validateOrganizationACLUpdate,applyACLReadRoles,resolveACLUsers,resolveACLGroups), so the request shape and validation match/organizations/{organization}/skills/{skillName}/acl.ExtractOrganizationSkillParam(..., policy.ActionShare), both routes admit only callers who can share the definition. Readers and everyone else get 404, so readers cannot list the grants. A share-only API key scope works.GetOrganizationAgentDefinitionByNameForUpdate), validates the grants against the organization in the same transaction, and writes throughUpdateOrganizationAgentDefinitionACLByName, which dbauthz authorizes forActionShare.Read-time membership
acl_allowinpolicy.regoalready requiresis_org_member, so RBAC drops a direct grant as soon as its user leaves the organization. No extra dbauthz check is needed.TestOrganizationAgentDefinitionOrganizationMembershipruns the get and list queries against the real authorizer and locks this in: before removal the grantee reads the row, after removal get is not authorized and the list is empty.Leaving the organization also drops the user's direct grants, so rejoining does not restore them, the same as skills (
000621) and chat projects (000629). A new chatd node,01a1c242-…_agent_definition_acl_org_member_delete, mirrors000629: aBEFORE DELETE ON organization_memberstrigger that removes the user from theuser_aclof the definitions in that organization, and a one-time cleanup for users who already left. Nodes have no down migrations.The trigger sits on a core table but runs a chatd function, like upstream's skill trigger after the adopt node.
TestForkNodesOnlyAddToChatdnow admits that one shape (CREATE TRIGGER ... EXECUTE FUNCTION chatd.), and the chatdmig README says so.Tests
TestForkOrganizationAgentDefinitions/ACL: an org admin replaces the Everyone grant with a direct read grant. The ACL lists only the grantee. The grantee reads the definition, another member gets 404 and an empty list. The grantee gets 404 on GET and PATCH of the ACL. An invalid user ID gives 400. After the grantee leaves the organization, reading gives 404 and the storeduser_aclno longer has the grantee. After the grantee rejoins, reading still gives 404.TestForkOrganizationAgentDefinitions/ScopedAPIKeys: a key scoped toorganization_skill:sharereads the ACL.TestForkQuerier: the new queries, withActionSharefor the ACL update.chatdObjectchange failsTestForkNodesOnlyAddToChatdon the new trigger. Authorizing the ACL routes for read instead of share, dropping the user grant from the PATCH, and authorizing the dbauthz ACL update for update instead of share each make a test fail.chatdmigpackage withCHATDMIG_TEST_DATABASE_URLset (includingTestForkNodesOnlyAddToChatd),chatdmig check,TestSQLCSchemaOrder,TestForkOrganizationAgentDefinitions,TestForkUserAgentDefinitions,TestForkQuerier,TestOrganizationAgentDefinitionOrganizationMembership,TestForkChatRoutes,TestEndpointsDocumented,TestEnterpriseEndpointsDocumented,TestSwaggerParametersValid,TestSDKFieldsFormatted, and golangci-lint (no findings in the changed files).Size
395 non-generated lines added: 146 handlers, 76 dbauthz tests, 72 API tests, 36 migration node, 39 queries and wrappers, 12 SDK, 11 chatdmig test and README, 1 sqlc config and 2 routes. The rest is sqlc, mock and Swagger output. The routes are skipped from the published API reference with
@x-apidocgen {"skip": true}.