Skip to content

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 control
  • spt-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

TypeDescription
Scheduler<N, P>Core scheduler with N max tasks and P max partitions
SchedulerConfigConfiguration (time quantum, decay factor, risk weight)
TaskControlBlockPer-task state including priority, partition, and novelty score
TaskStateTask lifecycle state (Ready, Running, Blocked, etc.)
PartitionManagerManages time-slice allocation across partitions
NoveltyTrackerTracks input novelty via embedding cosine similarity
PriorityConfigWeights for combining the three priority signals
SchedulerStatsRuntime statistics for the scheduler

Released under the MIT License.