Repository navigation
fix(platform): allow audit-log chain writes through RLS - #1726
Conversation
Adds an RLS rule for `auditLogChainGenesis` and relaxes `auditLogs.modify` from blanket-deny to org-membership gating so `createAuditLog` can perform its two required writes: 1. Upsert the per-org genesis sentinel row. 2. Patch the predecessor row's `chainSuccessor` to serialize concurrent writers via OCC and prevent chain forks. Both writes are part of the audit-chain anti-fork design but were blocked by `mutationWithRLS` (defaultPolicy: deny). Every audit-logged mutation in a user-facing context was failing — most visibly, `markConversationAsRead` throwing "insert access not allowed" / "write access not allowed" when navigating conversation items. Audit-log content immutability remains enforced by the chain hash and `verifyIntegrity` self-check, not by the RLS modify rule.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR adds a new RLS rule set for the Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Comment |
Summary
auditLogChainGenesis(org-membership gated read/insert/modify) so the per-org chain-genesis sentinel can be upserted.auditLogs.modifyfrom blanket-deny to org-membership gating socreateAuditLogcan patch the predecessor row'schainSuccessor(the OCC anti-fork mechanism).integrityHash+verifyIntegrityself-check — not by the RLS modify rule, which has no visibility into the patch diff.Why
mutationWithRLSruns withdefaultPolicy: 'deny'. After the audit-chain anti-fork landed (PR #1676 hardening series),createAuditLogstarted doing two writes that RLS blocked:auditLogChainGenesis— no RLS rule existed, default-denied.auditLogsrow'schainSuccessorfield — blocked by the previous `modify: () => false` rule.Every audit-logged mutation in a user-facing context was failing. User-visible symptom: navigating conversation items threw `Failed to mark conversation as read: [CONVEX M(conversations/mutations:markConversationAsRead)] [...] insert access not allowed`, then after fixing the first hop, `write access not allowed` from the predecessor patch.
Test plan
convex/audit_logs,convex/lib/rls,convex/conversationspass.unread_countclears, audit log row is written.verifyIntegrityagainst a newly created org's audit log and confirm the chain validates end-to-end withchainSuccessorpopulated.Summary by CodeRabbit
Release Notes