managarten/services/mana-sync/internal
Till JS 88e3adb9d3 feat(spaces): multi-member RLS policy in mana-sync (forward-compat)
Adds the second RLS policy needed for shared spaces. Users can read
rows in any space they're a member of, in addition to their own rows.

Changes:
- New policy sync_changes_space_member_read (SELECT only) uses
  app.current_user_space_ids session config: rows with space_id in
  that comma-separated list pass RLS.
- WITH CHECK is not extended — writes still require user_id match, so
  only the author can write. Members read, owner/author writes.
- withUser() is now a thin wrapper around withUserAndMemberships(),
  which accepts the caller's Space membership list and sets the new
  session config alongside app.current_user_id.
- The comma-join is empty-filtered so stray blank entries can't match
  rows with literal empty space_id (defense in depth).

Forward-compatible: today every space has exactly one member (the
author), so the membership list is always empty and the new policy
is a no-op — user_id isolation remains the only active guard.

When shared spaces start being used (clubs/teams/brand spaces with
invites), the HTTP handlers will fetch the caller's membership from
mana-auth and pass it to withUserAndMemberships. No migration needed
at that point — the policy is already live.

Subscription fan-out (WS/SSE broadcast to all space members) is still
per-user; that's a follow-up tied to the membership lookup infra.

Go build + existing tests pass.

Plan: docs/plans/spaces-foundation.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 19:55:17 +02:00
..
auth feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00
backup test(sync): extract WriteBackup + 4 Go integration tests 2026-04-14 17:44:37 +02:00
billing feat(sync): Phase 2 — server-side billing gate, cron charging, email notifications 2026-04-10 22:28:57 +02:00
config feat(sync): Phase 2 — server-side billing gate, cron charging, email notifications 2026-04-10 22:28:57 +02:00
store feat(spaces): multi-member RLS policy in mana-sync (forward-compat) 2026-04-20 19:55:17 +02:00
sync feat(spaces): thread space_id through mana-sync protocol + storage 2026-04-20 16:53:14 +02:00
ws feat: rename ManaCore to Mana across entire codebase 2026-04-05 20:00:13 +02:00