| Crates.io | systemprompt-scheduler |
| lib.rs | systemprompt-scheduler |
| version | 0.0.11 |
| created_at | 2026-01-21 20:05:54.331897+00 |
| updated_at | 2026-01-25 21:43:27.468035+00 |
| description | Core scheduler module for systemprompt.io OS - background jobs and cron tasks |
| homepage | https://systemprompt.io |
| repository | https://github.com/systempromptio/systemprompt-core |
| max_upload_size | |
| id | 2060014 |
| size | 243,961 |
Core scheduler module for systemprompt.io OS - background jobs and cron tasks.
Part of the App layer in the systemprompt.io architecture.
Background job scheduling and execution module. Discovers jobs via the inventory crate and executes them on configurable cron schedules.
src/
├── lib.rs # Public exports
├── jobs/
│ ├── mod.rs # Job exports
│ ├── behavioral_analysis.rs # Analyzes fingerprint behavior patterns
│ ├── cleanup_empty_contexts.rs # Removes empty conversation contexts
│ ├── cleanup_inactive_sessions.rs # Closes inactive sessions
│ ├── database_cleanup.rs # Orphaned logs, MCP, OAuth cleanup
│ └── malicious_ip_blacklist.rs # Detects and blacklists malicious IPs
├── models/
│ └── mod.rs # JobStatus, SchedulerError, ScheduledJob
├── repository/
│ ├── mod.rs # SchedulerRepository facade
│ ├── analytics/
│ │ └── mod.rs # Analytics cleanup queries
│ ├── jobs/
│ │ └── mod.rs # Scheduled job CRUD operations
│ └── security/
│ └── mod.rs # IP session queries for malicious detection
└── services/
├── mod.rs # Service exports
├── service_management.rs # Service lifecycle management
├── scheduling/
│ └── mod.rs # SchedulerService - job discovery and execution
└── orchestration/
├── mod.rs # Orchestration exports
├── process_cleanup.rs # Process management utilities
├── reconciler.rs # Service state reconciliation
├── state_manager.rs # Service state verification
├── state_types.rs # DesiredStatus, RuntimeStatus, ServiceAction
└── verified_state.rs # VerifiedServiceState with builder pattern
Background jobs that implement the Job trait from systemprompt-traits. Each job is registered via inventory::submit! for automatic discovery.
| Job | Schedule | Description |
|---|---|---|
CleanupInactiveSessionsJob |
Every 10 min | Closes sessions inactive for 1 hour |
CleanupEmptyContextsJob |
Every 2 hours | Removes conversation contexts with no messages |
DatabaseCleanupJob |
Daily at 3 AM | Deletes orphaned logs, MCP executions, expired OAuth tokens |
BehavioralAnalysisJob |
Hourly | Analyzes fingerprint patterns, flags suspicious activity, bans repeat offenders |
MaliciousIpBlacklistJob |
Every 6 hours | Detects high-volume, scanner, datacenter, and high-risk country IPs |
Domain types for the scheduler:
Success, Failed, Runningthiserror deriveData access layer for scheduler operations:
scheduled_jobs tableuser_contextsSchedulerService - Core scheduler that:
inventory cratetokio-cron-schedulerSystemSpan for structured loggingServiceManagementService - Service lifecycle operations:
State machine for service reconciliation:
State types:
Enabled | DisabledRunning | Starting | Stopped | Crashed | OrphanedNone | Start | Stop | Restart | CleanupDb | CleanupProcessJobs are discovered via the inventory crate. Any crate can register jobs:
inventory::submit! { &MyCustomJob }
The scheduler discovers all registered jobs at startup and schedules them based on configuration.
| Crate | Purpose |
|---|---|
systemprompt-runtime |
AppContext |
systemprompt-database |
Database pool and repositories |
systemprompt-logging |
SystemSpan for tracing |
systemprompt-analytics |
SessionRepository, FingerprintRepository |
systemprompt-users |
BannedIpRepository |
systemprompt-traits |
Job trait definition |
systemprompt-identifiers |
ScheduledJobId |
systemprompt-models |
Config types |
use systemprompt_scheduler::{SchedulerService, SchedulerConfig};
let config = SchedulerConfig::from_context(&app_context);
let service = SchedulerService::new(config, db_pool, app_context)?;
service.start().await?;
Add to your Cargo.toml:
[dependencies]
systemprompt-scheduler = "0.0.1"
FSL-1.1-ALv2 - See LICENSE for details.