sptos-sched
Coherence-aware scheduler for the SPTOS Cognition Kernel
Overview
sptos-sched implements the SPTOS scheduler from ADR-087 Section 5. It combines three signals to determine task priority: deadline pressure (EDF scheduling), novelty signal (priority boost for genuinely new information), and structural risk (deprioritization when mutations would lower coherence). This is no_std compatible.
Key Features
- Three-signal priority — Deadline pressure, novelty boost, and coherence risk are combined into a single scheduling score
- Partition scheduling — Tasks grouped by SPF mount origin, each partition receives a guaranteed time slice
- Novelty tracking — Embedding-based novelty detection using cosine similarity against recent inputs
- No priority inversion — Capability-based access prevents tasks from blocking on unheld resources
- Bounded preemption — Preemption occurs only at queue boundaries (after send/recv completes)
Dependencies
Key internal dependencies:
sptos-types— Scheduler types (TaskHandle, TaskPriority, SchedulerPartition)sptos-cap— Capability rights for partition access controlspt-coherence(optional) — Spectral coherence scoring integration
Usage
rust
use sptos_sched::{Scheduler, SchedulerConfig, TaskControlBlock};
use sptos_types::{TaskHandle, TaskPriority, SchedulerPartition};
let mut scheduler: Scheduler<64, 8> = Scheduler::new(
SchedulerConfig::default()
);
let tcb = TaskControlBlock::new(
TaskHandle::new(1, 0),
CapRights::READ | CapRights::WRITE,
TaskPriority::Normal,
0, // partition_id
);
scheduler.add_task(tcb).unwrap();API Reference
Core Types
| Type | Description |
|---|---|
Scheduler<N, P> | Core scheduler with N max tasks and P max partitions |
SchedulerConfig | Configuration (time quantum, decay factor, risk weight) |
TaskControlBlock | Per-task state including priority, partition, and novelty score |
TaskState | Task lifecycle state (Ready, Running, Blocked, etc.) |
PartitionManager | Manages time-slice allocation across partitions |
NoveltyTracker | Tracks input novelty via embedding cosine similarity |
PriorityConfig | Weights for combining the three priority signals |
SchedulerStats | Runtime statistics for the scheduler |