Skip to content

feat(rls): Phase 1 #6 — AgentPermissionGrant RLS + callsite fixes (#133)#134

Merged
webdevcom01-cell merged 1 commit into
mainfrom
feat/rls-phase1-agentpermissiongrant
May 24, 2026
Merged

feat(rls): Phase 1 #6 — AgentPermissionGrant RLS + callsite fixes (#133)#134
webdevcom01-cell merged 1 commit into
mainfrom
feat/rls-phase1-agentpermissiongrant

Conversation

@webdevcom01-cell
Copy link
Copy Markdown
Owner

Summary

  • Enable RLS + FORCE RLS on AgentPermissionGrant (TENANT_DIRECT, position chore(deps): bump actions/upload-artifact from 4.6.2 to 7.0.0 #6 in runbook §2.3)
  • Add composite (organizationId, id) index for RLS scan performance
  • permissions/route.ts GET: wrap findMany in withOrgContext (fetches agent's org first)
  • hierarchy.ts grantPermission: wrap create in withOrgContext with explicit organizationId
  • hierarchy.ts checkA2APermission: wrap findFirst in withAdminBypass (system-level A2A check, no org at call site; not currently called from production — defensive prep for when enforcement goes live)

Security Audit

checkA2APermission is not called from production — the call-agent-handler.ts uses ownership-based guard ({ id: targetAgentId, userId: callerUserId }) rather than permission grants. CLAUDE.md docs are outdated on this point. The grantPermission ancestral guard remains intact (grantor must be ancestor of grantee).

Test plan

  • pnpm precheck — TS ✅, vitest 4117/4119 ✅, ESLint ✅
  • CI: "Run Prisma migrations" step (critical gate)
  • CI: src/lib/org-chart/__tests__/hierarchy.test.ts passes (mocks are fn(prisma) compatible with withAdminBypass)

🤖 Generated with Claude Code

- 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)
@webdevcom01-cell webdevcom01-cell added the e2e Run E2E tests on this PR label May 24, 2026
@webdevcom01-cell webdevcom01-cell merged commit e2c5c78 into main May 24, 2026
6 of 12 checks passed
@webdevcom01-cell webdevcom01-cell deleted the feat/rls-phase1-agentpermissiongrant branch May 24, 2026 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e2e Run E2E tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant