Reality Slider
The Reality Slider is a unified control mechanism that adjusts the realism of your mock environment from simple static stubs to full production-level chaos. It coordinates three key subsystems: Chaos Engineering, Latency Simulation, and MockAI.
Overview
By adjusting a single slider from 1 to 5, you can instantly transform your mock environment to match different testing scenarios without manually configuring each subsystem.
Reality Levels
Level 1: Static Stubs
Use Case: Fast, predictable responses for basic functionality testing
- Chaos: Disabled
- Latency: 0ms (instant responses)
- MockAI: Disabled
- Best For: Unit tests, rapid prototyping, simple integration checks
Level 2: Light Simulation
Use Case: Minimal realism with basic intelligence
- Chaos: Disabled
- Latency: 10-50ms (minimal network delay)
- MockAI: Basic AI (simple response generation)
- Best For: Frontend development, basic API testing, quick demos
Level 3: Moderate Realism (Default)
Use Case: Balanced realism for most development scenarios
- Chaos: 5% error rate, 10% delay probability
- Latency: 50-200ms (moderate network conditions)
- MockAI: Full AI enabled (intelligent responses, relationship awareness)
- Best For: Integration testing, development environments, staging-like behavior
Level 4: High Realism
Use Case: Production-like conditions with increased complexity
- Chaos: 10% error rate, 20% delay probability
- Latency: 100-500ms (realistic network conditions)
- MockAI: Full AI + session state management
- Best For: Pre-production testing, realistic user flows, stress testing preparation
Level 5: Production Chaos
Use Case: Maximum realism for resilience testing
- Chaos: 15% error rate, 30% delay probability
- Latency: 200-2000ms (production-like network conditions)
- MockAI: Full AI + mutations + advanced features
- Best For: Chaos engineering, resilience testing, production simulation
Usage
UI Usage
Dashboard
The Reality Slider is available on the Dashboard page:
- Navigate to Dashboard in the admin UI
- Find the Environment Control section
- Use the slider to adjust the reality level (1-5)
- Click level indicators for quick selection
- View current configuration in the details panel
Configuration Page
For advanced control and preset management:
- Navigate to Configuration → Reality Slider
- Use the full-featured slider with visual feedback
- Manage presets (export/import configurations)
- View keyboard shortcuts reference
CLI Usage
Command Line Flag
# Set reality level at startup
mockforge serve --reality-level 5
# With OpenAPI spec
mockforge serve --spec api.yaml --reality-level 3
Environment Variable
# Set via environment variable
export MOCKFORGE_REALITY_LEVEL=4
mockforge serve
# Or inline
MOCKFORGE_REALITY_LEVEL=2 mockforge serve --spec api.yaml
Precedence: CLI flag > Environment variable > Config file > Default (Level 3)
Configuration File
Add to your mockforge.yaml:
reality:
enabled: true
level: 3 # 1-5
Or use per-profile configuration:
profiles:
development:
reality:
level: 2
staging:
reality:
level: 4
production:
reality:
level: 5
Keyboard Shortcuts
Quick reality level changes from anywhere in the UI:
| Shortcut | Action |
|---|---|
Ctrl+Shift+1 | Set to Level 1 (Static Stubs) |
Ctrl+Shift+2 | Set to Level 2 (Light Simulation) |
Ctrl+Shift+3 | Set to Level 3 (Moderate Realism) |
Ctrl+Shift+4 | Set to Level 4 (High Realism) |
Ctrl+Shift+5 | Set to Level 5 (Production Chaos) |
Ctrl+Shift+R | Reset to default (Level 3) |
Ctrl+Shift+P | Open preset manager (Config page) |
Note: Shortcuts are disabled when typing in input fields to avoid conflicts.
Presets
Exporting Presets
Save your current reality configuration for reuse:
- Navigate to Configuration → Reality Slider
- Click Export Current
- Enter a preset name (e.g., “production-chaos”, “staging-realistic”)
- Optionally add a description
- Click Export Preset
Presets are saved as JSON or YAML files in the workspace presets directory.
Importing Presets
- Navigate to Configuration → Reality Slider
- Click Import Preset
- Select a preset from the list
- Click Load to apply
Preset File Format
Presets are stored as JSON or YAML:
{
"metadata": {
"name": "production-chaos",
"description": "Maximum realism for resilience testing",
"created_at": "2025-01-15T10:30:00Z",
"version": "1.0"
},
"config": {
"chaos": {
"enabled": true,
"error_rate": 0.15,
"delay_rate": 0.30
},
"latency": {
"base_ms": 200,
"jitter_ms": 1800
},
"mockai": {
"enabled": true
}
}
}
CI/CD Integration
GitHub Actions
env:
MOCKFORGE_REALITY_LEVEL: 3 # Moderate Realism for tests
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Run tests with mock
run: |
mockforge serve --reality-level ${{ env.MOCKFORGE_REALITY_LEVEL }} &
# Run your tests
Docker Compose
services:
mockforge:
environment:
- MOCKFORGE_REALITY_LEVEL=${MOCKFORGE_REALITY_LEVEL:-3}
API Reference
Get Current Reality Level
GET /__mockforge/reality/level
Response:
{
"level": 3,
"level_name": "Moderate Realism",
"description": "Some chaos, moderate latency, full intelligence",
"chaos": {
"enabled": true,
"error_rate": 0.05,
"delay_rate": 0.10
},
"latency": {
"base_ms": 50,
"jitter_ms": 150
},
"mockai": {
"enabled": true
}
}
Set Reality Level
PUT /__mockforge/reality/level
Content-Type: application/json
{
"level": 5
}
Use Cases
Development Workflow
-
Start Development: Level 2 (Light Simulation)
- Fast responses for rapid iteration
- Basic AI for realistic data
-
Integration Testing: Level 3 (Moderate Realism)
- Some chaos to catch error handling
- Realistic latency for network-aware code
-
Pre-Production: Level 4 (High Realism)
- Production-like conditions
- Full feature set enabled
-
Resilience Testing: Level 5 (Production Chaos)
- Maximum chaos for stress testing
- Simulate worst-case scenarios
Testing Scenarios
Unit Tests
# Fast, predictable responses
MOCKFORGE_REALITY_LEVEL=1 npm test
Integration Tests
# Moderate realism
MOCKFORGE_REALITY_LEVEL=3 npm test
E2E Tests
# High realism for production-like testing
MOCKFORGE_REALITY_LEVEL=4 npm test
Chaos Engineering
# Maximum chaos for resilience testing
MOCKFORGE_REALITY_LEVEL=5 npm test
Best Practices
- Start Low, Increase Gradually: Begin with Level 1-2 for development, increase as you approach production
- Use Presets: Save common configurations for different environments
- CI/CD Integration: Set appropriate levels for different test stages
- Monitor Impact: Watch metrics as you change levels to understand the impact
- Document Your Levels: Use preset descriptions to document when to use each configuration
Troubleshooting
Level Changes Not Applying
- Check that the reality slider is enabled in configuration
- Verify API endpoint is accessible:
curl http://localhost:9080/__mockforge/reality/level - Check server logs for errors
Shortcuts Not Working
- Ensure you’re not typing in an input field
- Check browser console for JavaScript errors
- Verify shortcuts are enabled (disabled in compact mode)
Presets Not Loading
- Verify preset file format (JSON or YAML)
- Check file permissions
- Ensure preset path is correct
- Review server logs for import errors
Related Documentation
- Chaos Lab - Detailed chaos engineering features
- MockAI - Intelligent mocking system
- Configuration Guide - Complete configuration reference