The 4 Integrity Modes
Modes are inspired by CPU protection rings (Ring 0-3), where higher numbers = more restrictions.
Mode Details
readonly (R3) - Production Default
Purpose: Lock schemas in production to prevent accidental changes. Permissions:- ❌ Schema migrations blocked
- ✅ Read-only operations allowed
- ✅ Query execution
- ✅ Data mutations (INSERT/UPDATE/DELETE)
standard (R2) - Development Teams
Purpose: Allow controlled schema changes during development. Permissions:- ✅ Schema migrations allowed (with validation)
- ✅ Migration preview (dry-run)
- ✅ Schema validation
- ✅ All operations logged
Recommended for development and staging environments where teams need to iterate on schemas.
privileged (R1) - Database Administrators
Purpose: Direct schema access for DBAs with full logging. Permissions:- ✅ Direct SQL execution
- ✅ Bypass certain safety checks
- ✅ Manual schema registration
- ✅ All operations audited
emergency (R0) - Incident Recovery
Purpose: Unrestricted access for emergency situations. Permissions:- ✅ Skip integrity checks
- ✅ Force migrations
- ✅ Bypass all safety guards
- ✅ Complete audit trail
Mode Upgrades & Downgrades
Password Protection
Mode upgrades (lower ring → higher privilege) require password authentication:Upgrade Mode (Requires Password)
Downgrade Mode (No Password)
Mode downgrades (higher privilege → lower ring) don’t require a password:Downgrades are unrestricted because they increase security, not decrease it.
Mode Enforcement Flow
Checking Current Mode
Quick Check
Detailed Status
Mode Change Logging
All mode changes are logged tointegrity.log:
from- Previous modeto- New modetype- upgrade or downgradeuser- Who made the change (from OS username)
Password Management
Set Password
Change Password
Use Environment Variable (CI/CD)
Mode Strategy by Environment
Development
Staging
Production
Maintenance Window
Best Practices
Start with readonly - Default to most restrictive mode
Require password - Always set a strong mode password
Log mode changes - Monitor
integrity.log for unexpected changesTime-limited upgrades - Downgrade after maintenance window
Rotate passwords - Change passwords regularly, especially after personnel changes
Document upgrades - Require change tickets for production mode changes
Alert on emergency - Immediately notify security team if emergency mode is used
Common Workflows
Development Workflow
Production Deployment
Incident Recovery
Next Steps
Vault Integrity
Learn about SHA256 hashing and tamper detection
Best Practices
Security recommendations for production