Rolebook vs SpiceDB: authorize and update in one transaction
Rolebook fits when your application updates a row in PostgreSQL and the permission check should commit or roll back with that update.
SpiceDB's schema documentation shows permissions computed from relations, including read access to a document through its parent folder.
The check and the update share one transaction
createPostgresProtectedWriteAdapter() runs one resource-wide action check and your SQL callback in a single SERIALIZABLE PostgreSQL transaction, and records a receipt and an outbox event with your change. It needs the PostgreSQL sharing adapter, versioned sharing and a local identity projection in the same database. Your SQL remains trusted application code.
Renaming a document
user_123 renames document_1 in workspace_1. If the initial action check refuses, your callback never runs. If it allows, your UPDATE must advance the row's version and keep its owner, ancestry and sharing state. The rename, its receipt and its outbox event commit atomically only if the final authority checks succeed.
While that receipt is retained, an exact retry with the same idempotency key returns it without running the callback again.