TOML Configuration Files
TOML Configuration Files
Section titled “TOML Configuration Files”Mantis uses TOML (Tom’s Obvious Minimal Language) for configuration files.
TOML Basics
Section titled “TOML Basics”Syntax Overview
Section titled “Syntax Overview”TOML is designed to be easy to read and write:
# This is a comment
# Basic key-value pairskey = "value"number = 42boolean = true
# Sections (tables)[section]key = "value in section"
# Nested sections[section.subsection]key = "nested value"
# Arraysitems = ["one", "two", "three"]
# Inline tablespoint = { x = 1, y = 2 }Data Types
Section titled “Data Types”| Type | Example | Description |
|---|---|---|
| String | "hello" | Text in quotes |
| Integer | 42 | Whole numbers |
| Float | 3.14 | Decimal numbers |
| Boolean | true, false | True/false values |
| DateTime | 2024-01-15T10:30:00Z | ISO 8601 format |
| Array | [1, 2, 3] | List of values |
| Table | [section] | Nested structure |
Configuration Structure
Section titled “Configuration Structure”Mandible Configuration
Section titled “Mandible Configuration”# Server section[server]host = "0.0.0.0"port = 3000
# Nested TLS section[server.tls]cert_path = "/etc/mantis/certs/server.crt"key_path = "/etc/mantis/certs/server.key"
# Database section[database]url = "postgres://mantis:password@localhost:5432/mantis"max_connections = 10
# JWT section[jwt]algorithm = "HS256"secret = "your-secret-key"access_token_expiry_secs = 3600
# Auth section[auth]lens_base_url = "https://lens.example.com/login"Thorax Configuration
Section titled “Thorax Configuration”[tls]auth_mode = "thumbprint"cert_path = "/etc/mantis/certs/thorax.crt"key_path = "/etc/mantis/certs/thorax.key"
[grpc]address = "0.0.0.0"port = 50051
[mandible]endpoint = "https://mandible.example.com:50052"tls_cert_path = "/etc/mantis/certs/client.crt"tls_key_path = "/etc/mantis/certs/client.key"tls_ca_cert_path = "/etc/mantis/certs/ca.crt"
[queue]enabled = truehost = "localhost"port = 5671
[cluster]enabled = trueredis_url = "redis://localhost:6379"Tarsus Configuration
Section titled “Tarsus Configuration”name = "web-prod-01"mode = "listen"
# Tarsus registers with Mandible (not Thorax); env: TARSUS__MANDIBLE__ENDPOINT[mandible]endpoint = "mandible.example.com:50052"
[tls]cert_path = "/etc/tarsus/cert.pem"key_path = "/etc/tarsus/key.pem"ca_cert_path = "/etc/tarsus/ca.crt"String Formats
Section titled “String Formats”Basic Strings
Section titled “Basic Strings”# Double quotes - escape sequences supportedpath = "/etc/mantis/config"message = "Line 1\nLine 2"
# Literal strings - no escapingregex = 'C:\Users\name'Multi-line Strings
Section titled “Multi-line Strings”# Multi-line basic stringdescription = """This is a longer descriptionthat spans multiple lines.Newlines are preserved."""
# Multi-line literal stringscript = '''#!/bin/bashecho "Hello, World!"exit 0'''String Escapes
Section titled “String Escapes”| Escape | Meaning |
|---|---|
\n | Newline |
\t | Tab |
\\ | Backslash |
\" | Double quote |
Arrays
Section titled “Arrays”Simple Arrays
Section titled “Simple Arrays”# Array of stringsorigins = ["https://app.example.com", "https://admin.example.com"]
# Array of integersports = [80, 443, 8080]
# Mixed types (not recommended)mixed = ["string", 42, true]Multi-line Arrays
Section titled “Multi-line Arrays”allowed_origins = [ "https://app.example.com", "https://admin.example.com", "https://api.example.com",]Array of Tables
Section titled “Array of Tables”# Array of inline tables[[storage.backends]]name = "local"type = "filesystem"path = "/var/lib/mantis/storage"
[[storage.backends]]name = "s3"type = "s3"bucket = "mantis-artifacts"region = "us-east-1"Tables (Sections)
Section titled “Tables (Sections)”Standard Tables
Section titled “Standard Tables”[server]host = "0.0.0.0"port = 3000
[database]url = "postgres://localhost/mantis"Nested Tables
Section titled “Nested Tables”# Dotted keys[server.tls]cert_path = "/path/to/cert"
# Equivalent to:[server][server.tls]cert_path = "/path/to/cert"Inline Tables
Section titled “Inline Tables”# Inline table (one line)point = { x = 1, y = 2 }
# Useful for small, related valuesdatabase = { host = "localhost", port = 5432 }Comments
Section titled “Comments”Line Comments
Section titled “Line Comments”# This is a comment on its own linekey = "value" # This is an end-of-line comment
# Comments can explain configuration# Maximum number of database connectionsmax_connections = 10Section Comments
Section titled “Section Comments”# ============================================# Server Configuration# ============================================[server]host = "0.0.0.0"port = 3000
# ============================================# Database Configuration# ============================================[database]url = "postgres://localhost/mantis"Variable Substitution
Section titled “Variable Substitution”TOML doesn’t support variable substitution natively. Use these approaches:
Environment Variables
Section titled “Environment Variables”# Reference in TOML (processed by application)[database]url = "${DATABASE_URL}"
# Or use environment variable directly# export DATABASE_URL=postgres://localhost/mantisShell Preprocessing
Section titled “Shell Preprocessing”# Using envsubstenvsubst < config.toml.template > config.toml
# config.toml.template:# [database]# url = "${DATABASE_URL}"Validation
Section titled “Validation”Syntax Validation
Section titled “Syntax Validation”# Using Pythonpython -c "import tomllib; tomllib.load(open('config.toml', 'rb'))"
# Using taplo (TOML toolkit)taplo check config.tomlCommon Syntax Errors
Section titled “Common Syntax Errors”| Error | Cause | Fix |
|---|---|---|
| Unexpected character | Missing quotes | Add quotes around strings |
| Invalid key | Special characters | Quote the key or rename |
| Duplicate key | Key defined twice | Remove duplicate |
| Type mismatch | Wrong value type | Use correct type |
Best Practices
Section titled “Best Practices”1. Organize by Section
Section titled “1. Organize by Section”# Good: Logical grouping[server]host = "0.0.0.0"port = 3000
[server.tls]cert_path = "/path/to/cert"
[database]url = "..."
# Bad: Mixed order[server.tls]cert_path = "/path/to/cert"
[database]url = "..."
[server]host = "0.0.0.0"2. Use Comments Wisely
Section titled “2. Use Comments Wisely”# Good: Explain non-obvious settings[server]# Higher timeout for slow network environmentsrequest_timeout_secs = 120
# Bad: State the obvious[server]# Server portport = 30003. Keep Secrets Out
Section titled “3. Keep Secrets Out”# Bad: Secrets in config[jwt]secret = "super-secret-key"
# Good: Reference environment variable[jwt]# Set via MANDIBLE__JWT__SECRET environment variablealgorithm = "HS256"4. Use Sensible Defaults
Section titled “4. Use Sensible Defaults”# Only override when needed[server]# port = 3000 # Using defaultrequest_timeout_secs = 120 # Non-default value
[database]url = "postgres://localhost/mantis"# max_connections = 10 # Using default5. Document Custom Settings
Section titled “5. Document Custom Settings”# Custom timeout for high-latency network# Ticket: INFRA-1234request_timeout_secs = 300File Organization
Section titled “File Organization”Development vs Production
Section titled “Development vs Production”config/├── development.toml # Local development├── staging.toml # Staging environment├── production.toml # Production settings└── base.toml # Shared settings (if using includes)Per-Component Configuration
Section titled “Per-Component Configuration”/etc/mantis/├── mandible.toml # API configuration├── thorax.toml # Orchestration configuration└── shared/ # Shared files └── ca.crt
/etc/tarsus/├── tarsus.toml # Agent configuration├── cert.pem└── key.pemComplete Examples
Section titled “Complete Examples”Minimal Production Mandible
Section titled “Minimal Production Mandible”# Minimal production configuration
[server]port = 3000
[server.tls]cert_path = "/etc/mantis/certs/server.crt"key_path = "/etc/mantis/certs/server.key"
[database]url = "postgres://mantis@db.internal/mantis?sslmode=require"
[jwt]algorithm = "RS256"private_key_path = "/etc/mantis/jwt/private.pem"public_key_path = "/etc/mantis/jwt/public.pem"
[grpc]orchestration_url = "https://thorax.internal:50051"Full Development Mandible
Section titled “Full Development Mandible”# Development configuration with all options
[server]host = "127.0.0.1"port = 3000request_timeout_secs = 60
[database]# Prefer the DATABASE_URL environment variable in real deploymentsurl = "postgres://mantis:mantis@localhost:5432/mantis_dev"max_connections = 5min_idle = 1connection_timeout_secs = 10
[jwt]algorithm = "HS256"# Set via MANDIBLE__JWT__SECRET in real deploymentssecret = "development-only-secret-not-for-production"access_token_expiry_secs = 86400refresh_token_expiry_secs = 604800issuer = "mantis-dev"
[cors]allowed_origins = ["https://localhost:5173"]allowed_methods = ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"]allowed_headers = ["Content-Type", "Authorization", "Accept", "X-Request-ID"]allow_credentials = truemax_age_secs = 3600
[cookie]secure = falsesame_site = "Lax"
[grpc]orchestration_url = "https://localhost:50051"connect_timeout_secs = 5request_timeout_secs = 30Log level is controlled by the
RUST_LOGenvironment variable (the standard tracingEnvFilter), not a[logging]section.
Troubleshooting
Section titled “Troubleshooting”Parse Errors
Section titled “Parse Errors”Error: TOML parse error at line 15, column 8 |15 | key = value without quotes | ^^^^^invalid stringFix: Add quotes around string values.
Key Not Found
Section titled “Key Not Found”Error: missing field `url` in section `database`Fix: Add the required field or check spelling.
Type Mismatch
Section titled “Type Mismatch”Error: expected integer for `port`, found stringFix: Remove quotes from numeric values.
# Wrongport = "3000"
# Correctport = 3000Next Steps
Section titled “Next Steps”- Configuration Overview - Configuration concepts
- Environment Variables - Variable reference
- Mandible Configuration - API configuration
