dwctl-0.5.1 is not a library.
Control Layer API Server (dwctl)
Rust-based API server for user, group, and model management with PostgreSQL database.
Local Development Setup
Prerequisites
- Rust (latest stable)
- PostgreSQL running locally
- sqlx-cli:
cargo install sqlx-cli
1. Database Setup
# Start PostgreSQL (macOS with Homebrew)
# Create database
# Or connect to existing PostgreSQL instance
2. Environment Configuration
Create .env file in the dwctl directory:
# dwctl/.env
DATABASE_URL=postgres://your-username@localhost:5432/control_layer
Replace your-username with your PostgreSQL username.
3. Run Database Migrations
4. Generate Query Cache (for builds without database)
# Generate offline query cache
# This creates .sqlx/ directory with cached query metadata
Running the Service
# Run with live database connection
# Run tests (requires database)
Configuration
The service uses config.yaml (or DWCTL_* environment variables):
DWCTL_HOST: Server host (default: 0.0.0.0)DWCTL_PORT: Server port (default: 3001)DATABASE_URL: PostgreSQL connection string
User Roles and Permissions
Control Layer uses an additive role-based access control system where users can have multiple roles that combine to provide different levels of access.
Role Types
StandardUser (Base Role)
- Required for all users - Cannot be removed
- Enables basic authentication and login functionality
- Provides access to user's own profile and data
- Allows model access, API key creation, and playground usage
- Foundation role that all other roles build upon
PlatformManager
- Administrative access to most platform functionality
- Can create, update, and delete users
- Can manage groups and group memberships
- Can control access to models and manage inference endpoints
- Can configure system settings
- Cannot view private request data (requires RequestViewer)
RequestViewer
- Read-only access to request logs and analytics
- Can view all requests that have transited the gateway
- Useful for auditing, monitoring, and analytics purposes
- Often combined with other roles for full administrative access
Role Combinations
Roles are additive, meaning users gain the combined permissions of all their assigned roles:
- StandardUser only: Basic user with profile access and model usage
- StandardUser + PlatformManager: Full administrative access except request viewing
- StandardUser + RequestViewer: Basic user who can also view request logs
- StandardUser + PlatformManager + RequestViewer: Full system administrator with all permissions
Role Management
- All users automatically receive and retain the
StandardUserrole - Additional roles can be assigned/removed via the admin interface
- The system automatically ensures
StandardUseris preserved during role updates - Role changes take effect immediately without requiring user re-authentication, unless using native auth with jwts, whereby a user needs to logout and back for API access effects to take place
Troubleshooting
Database connection errors
- Ensure PostgreSQL is running:
brew services start postgresql - Check DATABASE_URL in
.envfile - Verify database exists:
psql -l | grep control_layer
Migration errors
# Reset database
# 'other user are connected' error (usually your IDE is also connected)
Database Schema
Migrations are stored in the migrations/ directory, and run automatically on startup.
001_initial.sql- Users, groups, models tables002_listen_notify.sql- PostgreSQL notify triggers003_make_hosted_on_not_null.sql- Schema updates
API Endpoints
- See OpenAPI docs at
/admin/docswhen running