feat(rls): Phase 1 #7 — HeartbeatConfig RLS + callsite fixes#135
Merged
Conversation
Migration 20260601000000: TENANT_DIRECT RLS on HeartbeatConfig. BullMQ worker uses explicit organizationId from job.data (ALS empty in workers). Scheduler functions gain organizationId param; route and template engine wrapped.
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
20260601000000_rls_phase1_heartbeatconfig: TENANT_DIRECT RLS onHeartbeatConfig(SELECT/INSERT/UPDATE/DELETE policies + compositeorganizationId, idindex)heartbeat-worker.ts): wrapsheartbeatConfig.findUniqueinwithOrgContext(prisma, organizationId, …)using explicitorganizationIdfromjob.data— ALS is empty in BullMQ workers (confirmed in Migration chore(deps): bump node from 20-alpine to 25-alpine #3 audit)heartbeat-scheduler.ts):scheduleHeartbeatandunscheduleHeartbeatgainorganizationId: string | nullparam; allheartbeatConfigreads/writes wrapped withwithOrgContext/api/agents/[agentId]/heartbeat): GET and DELETE fetchorganizationIdvia separate agent lookup (same pattern as permissions route); POST usesorganizationIdfrom validated bodyexportTemplatewraps agent+include query inwithOrgContextto prevent silent null onheartbeatConfiginclude under RLS;importTemplatewrapsheartbeatConfig.createTest plan
pnpm precheck— 4/4 pass (TypeScript, vitest 4119 tests, lucide mocks, placeholder strings) ✅RLS_ENFORCEMENT_ENABLED=truein test org — POST heartbeat config, confirm no 42501RLS state after this PR
Phase 1: 7/14 live — OrganizationMember, Invitation, CompanyMission, Department, Goal, AgentPermissionGrant, HeartbeatConfig
🤖 Generated with Claude Code