1 agents

pvm-adaptive-scheduler

pvm-adaptive-scheduler

Overview

The pvm-adaptive-scheduler operates as an L3 Strategic Command authority within the Prismatic Platform's execution infrastructure, providing intelligent workload scheduling for the Prismatic Virtual Machine (PVM) execution environment. This agent dynamically allocates computational resources across competing agent workflows, pipeline stages, and background operations based on real-time system load, task priority, deadline constraints, and resource availability. The adaptive scheduler ensures that the platform's finite computational resources are distributed optimally across its 400+ autonomous agents, preventing resource starvation for critical operations while maintaining fair allocation for routine workloads.

The scheduler's adaptive behavior is grounded in five core Lean4 theorems that formally verify safety properties of scheduling decisions. These theorems guarantee that no scheduling decision can cause resource deadlock, that priority inversion is bounded and resolved within configurable time limits, that critical-path operations receive guaranteed minimum resource allocations, that the scheduler's own resource consumption is bounded and predictable, and that schedule transitions between steady states are smooth rather than oscillatory. These formal guarantees distinguish the PVM scheduler from heuristic-based approaches that may perform well empirically but lack provable safety properties.

Adaptive Scheduling Architecture

The scheduler operates as a continuously running OTP GenServer process that receives scheduling requests, evaluates resource availability, and produces scheduling decisions at configurable intervals (default: 100ms scheduling cycles).

Workload Classification categorizes incoming tasks into scheduling classes based on their resource requirements, latency sensitivity, and priority level. Interactive tasks (LiveView page renders, API responses) receive the highest scheduling priority with strict latency bounds. Pipeline stages (quality gates, evolution cycles) receive medium priority with throughput optimization. Background operations (telemetry aggregation, cache maintenance) receive lowest priority with best-effort scheduling. Classification is automatic based on task metadata, with override capability for escalated operations.

Resource Modeling maintains a real-time model of available computational resources across the platform's execution environment. The model tracks CPU capacity (BEAM scheduler utilization across all cores), memory availability (process heap allocation headroom), I/O bandwidth (disk and network throughput capacity), and database connection pool utilization. Resource measurements are sampled at high frequency and smoothed to prevent scheduling oscillation from momentary spikes.

Decision Engine produces scheduling decisions by solving a constrained optimization problem: maximize aggregate task throughput subject to priority ordering constraints, deadline constraints, resource capacity limits, and fairness requirements. The decision engine uses a priority-aware variant of the Completely Fair Scheduler (CFS) algorithm adapted for the BEAM's preemptive reduction-counting scheduler, ensuring that scheduling decisions complement rather than conflict with the BEAM's native scheduling behavior.

Adaptive Feedback Mechanisms

The scheduler continuously adapts its behavior based on observed system performance, implementing a closed-loop control system that responds to changing conditions.

Load Prediction uses exponentially weighted moving averages of recent resource utilization to predict near-future load. When predicted load exceeds capacity thresholds, the scheduler proactively adjusts admission rates and task scheduling to prevent overload before it occurs. Load prediction accuracy is continuously evaluated and the prediction parameters are auto-tuned based on prediction error history.

Deadline Monitoring tracks the progress of deadline-constrained tasks against their time budgets. Tasks that are falling behind schedule receive priority boosts proportional to their urgency. Tasks that have already missed their deadlines are flagged for post-mortem analysis and the scheduler adjusts future predictions to account for the observed execution time variance.

Throughput Optimization adjusts batch sizes and concurrency levels for throughput-oriented workloads based on observed processing rates. When a pipeline stage processes tasks faster than predicted, the scheduler increases its concurrency allocation to exploit the available performance headroom. When processing slows, concurrency is reduced to prevent memory pressure from excessive parallel work.

Starvation Prevention ensures that low-priority tasks eventually execute despite sustained high-priority load. The scheduler implements aging-based priority promotion: tasks that have waited beyond a configurable threshold receive incremental priority increases until they reach a level sufficient for scheduling. This prevents indefinite starvation while maintaining priority ordering for normal operation.

Formal Safety Guarantees

The five Lean4 theorems provide mathematical guarantees for scheduling correctness.

Deadlock Freedom proves that the scheduler cannot produce a circular wait condition where tasks are mutually blocked waiting for resources held by each other. The proof establishes a total ordering on resource acquisition that the scheduler enforces in all scheduling decisions.

Bounded Priority Inversion proves that no high-priority task can be blocked by a lower-priority task for more than a configurable time bound. The proof establishes the priority inheritance protocol used when resource contention occurs between tasks of different priority levels.

Critical Path Guarantee proves that operations on the platform's critical path (user-facing requests, deployment gates) receive guaranteed minimum resource allocations regardless of background load. The proof establishes resource reservation bounds that the scheduler enforces even under overload conditions.

Self-Resource Bounding proves that the scheduler's own computational overhead is bounded by a fixed fraction of total system capacity. The proof establishes that the scheduling algorithm's time complexity is linear in the number of active tasks with a small constant factor.

Transition Smoothness proves that the scheduler does not exhibit oscillatory behavior when transitioning between load regimes. The proof establishes convergence properties of the adaptive feedback mechanisms, ensuring that scheduling decisions approach steady-state allocations monotonically.

Command Interface

CommandDescriptionAuthority
/pvm schedule-statusDisplay current scheduling state with resource utilizationL3+
/pvm priorityAdjust scheduling priority for a specific workflow or agentL3+
/pvm capacityReport available resource capacity across scheduling classesL3+
/pvm tuneAdjust scheduling parameters (cycle time, thresholds, aging rates)L3+

Coordination

AgentRelationship
pvm-executorReceives scheduling decisions for task execution dispatch
pvm-compilerCompilation task scheduling with resource-aware batching
pvm-tracerExecution tracing data for scheduling decision evaluation
performance-profiling-agentPerformance data informing resource model calibration

Integration Architecture

ComponentRelationship
Prismatic AgentsRuntime execution and lifecycle management
Prismatic TelemetryScheduling metrics, resource utilization, and decision latency tracking
AIAD RegistryAgent priority and resource requirement specifications
SEADF PipelineEvolution cycle scheduling with quality gate integration

Enforcement

Scheduling decisions are governed by the NO MERCY doctrine -- resource overcommitment, deadline violations for critical-path operations, and scheduling decisions that violate formal safety theorems are rejected. The NO DOUBTS principle requires that all scheduling decisions are based on measured resource availability and task requirements, not on assumptions about system capacity. The Trinity Gate validates scheduling configuration changes through structural consistency (scheduling graph is valid), logical consistency (priority ordering is maintained), and formal necessity (Lean4 safety theorem satisfaction is preserved).


Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL