feat(scheduler): add per-level job limits based on load classification

Implements #34 - Job Limits Per Load Level

Jobs are now classified into HIGH, MEDIUM, or LOW load levels based on
gitignore-style whitelist files (.load files). This allows concurrent
execution of different types of jobs (e.g., downloading while transcoding).

Changes:
- Add LoadLevel enum with default limits (HIGH=2, MEDIUM=8, LOW=32)
- Add LoadLevelConfig record for per-level max jobs configuration
- Add CommandMatcher sealed interface for matching commands by name/path/dir
- Add LoadFileParser for parsing .load whitelist files
- Add LoadLevelClassifier for auto-classifying commands
- Add ConfigInstallCommand (barn config install) for default config files
- Update JobScheduler to use per-level limits with EnumMap
- Add --load-level/-l option to barn run for manual override
- Add load level display to barn status and barn describe output
- Remove --user flag from service install/uninstall (system-wide only)
- Update documentation for load levels and whitelist files

Default whitelists:
- high.load: ffmpeg, ffprobe, handbrake, x264, x265, etc.
- low.load: curl, wget, rclone, rsync, aria2c, etc.
- medium.load: empty (unmatched commands default to MEDIUM)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Daniel SamsonandClaude Opus 4.5 committed 2026-01-24 14:33:06 +00:00
1 parent 5a213788c7
commit f233547ce8
52 files changed
+2444 -193

No files matched your search

+67
View File
@@ -0,0 +1,67 @@
# Barn Configuration
# Generated by: barn config install
[service]
# Logging verbosity: debug, info, warn, error
log_level = "info"
# DEPRECATED: Use [load_levels] section instead
# max_concurrent_jobs = 4
# How often running jobs update their heartbeat (seconds)
heartbeat_interval_seconds = 5
# Heartbeat age before a job is considered orphaned (seconds)
stale_heartbeat_threshold_seconds = 30
[load_levels]
# Maximum concurrent high load jobs (CPU/GPU intensive)
max_high_jobs = 2
# Maximum concurrent medium load jobs (general purpose)
max_medium_jobs = 8
# Maximum concurrent low load jobs (network/IO intensive)
max_low_jobs = 32
[jobs]
# Maximum time a job can run before being killed (seconds)
default_timeout_seconds = 3600
# Number of retry attempts for failed jobs
max_retries = 3
# Initial delay before first retry (seconds)
retry_delay_seconds = 30
# Multiplier applied to delay after each retry
retry_backoff_multiplier = 2.0
# Only retry on these exit codes (empty = retry all failures)
retry_on_exit_codes = []
[cleanup]
# Enable automatic cleanup of old jobs
enabled = true
# Remove jobs older than this (hours)
max_age_hours = 72
# How often the cleanup task runs (minutes)
cleanup_interval_minutes = 60
# Preserve failed jobs for debugging
keep_failed_jobs = true
# How long to keep failed jobs (hours)
keep_failed_jobs_hours = 168
[storage]
# Root directory for all Barn data
base_dir = "/tmp/barn"
# Maximum disk space Barn can use (GB)
max_disk_usage_gb = 50
# Keep work/input and work/output after job completion
preserve_work_dir = false