Have you thought about integrating with Wazuh or similar?
You run queries against real PostgreSQL 18 compiled to WASM (PGlite). Building up from early broad grants directly on users in the first section through to abstractions around owners, login roles and roles that scope access.