feat(rls): Phase 1 #6 — AgentPermissionGrant RLS + callsite fixes (#133)#134
Merged
Merged
Conversation
- Enable RLS + FORCE RLS on AgentPermissionGrant (TENANT_DIRECT) - Add composite index (organizationId, id) for RLS performance - permissions/route.ts GET: wrap findMany in withOrgContext - hierarchy.ts grantPermission: wrap create in withOrgContext - hierarchy.ts checkA2APermission: wrap findFirst in withAdminBypass (system-level A2A permission lookup; orgId not available at call site)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AgentPermissionGrant(TENANT_DIRECT, position chore(deps): bump actions/upload-artifact from 4.6.2 to 7.0.0 #6 in runbook §2.3)(organizationId, id)index for RLS scan performancefindManyinwithOrgContext(fetches agent's org first)grantPermission: wrapcreateinwithOrgContextwith explicitorganizationIdcheckA2APermission: wrapfindFirstinwithAdminBypass(system-level A2A check, no org at call site; not currently called from production — defensive prep for when enforcement goes live)Security Audit
checkA2APermissionis not called from production — thecall-agent-handler.tsuses ownership-based guard ({ id: targetAgentId, userId: callerUserId }) rather than permission grants. CLAUDE.md docs are outdated on this point. ThegrantPermissionancestral guard remains intact (grantor must be ancestor of grantee).Test plan
pnpm precheck— TS ✅, vitest 4117/4119 ✅, ESLint ✅src/lib/org-chart/__tests__/hierarchy.test.tspasses (mocks arefn(prisma)compatible withwithAdminBypass)🤖 Generated with Claude Code