Skip to main content
ChameleonDB uses Integrity Modes to control schema modifications through a Unix-style protection ring system.

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)
Example:
This is the recommended mode for production environments. Schema changes should go through proper change management processes.

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
Example:
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
Example:
Use sparingly. Only for experienced DBAs who need direct database access. All operations are logged for audit.

emergency (R0) - Incident Recovery

Purpose: Unrestricted access for emergency situations. Permissions:
  • ✅ Skip integrity checks
  • ✅ Force migrations
  • ✅ Bypass all safety guards
  • ✅ Complete audit trail
Example:
Use ONLY during incidents. This mode bypasses all safety mechanisms. Every action is fully audited.

Mode Upgrades & Downgrades

Password Protection

Mode upgrades (lower ring → higher privilege) require password authentication:
Password is stored:
Set file permissions: chmod 600 .chameleon/vault/auth/mode.key

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 to integrity.log:
Log fields:
  • from - Previous mode
  • to - New mode
  • type - upgrade or downgrade
  • user - Who made the change (from OS username)

Password Management

Set Password

Change Password

Use Environment Variable (CI/CD)

Never commit passwords to version control. Use environment variables or secret management tools.

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 changes
Time-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