Add PostgreSQL role and grant management specification #437
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.
Add PostgreSQL role and grant management specification
Summary
Adds a SPEC.md document that specifies patterns and requirements for creating, granting, and managing PostgreSQL roles and users. This specification addresses race conditions, idempotency, and SQL safety concerns identified in the current implementation (related to PR #325).
The document covers:
This is a documentation-only PR with no code changes. The spec is intended to guide future implementation work to fix the identified issues.
Review & Testing Checklist for Human
pg_advisory_xact_lock(42, hashtext(...))and the dual exception handling (duplicate_object OR unique_violation)CREATE ROLE,CREATE USER,GRANT,REVOKE,DROP ROLEstatements that may have been missedremoveDbRoles()(lines 139-141 of client.ts) - verify that${username}interpolation withoutformat('%I', ...)is actually a risk given the upstream sanitizationNotes
42was chosen arbitrarily since no other advisory locks currently exist in the codebase. Consider if a different convention is preferred.Link to Devin run: https://app.devin.ai/sessions/94c39fc3c7184ff6b799f00bb5d17782
Requested by: Dan Lynch ([email protected]) / @pyramation