4.6 KiB
4.6 KiB
S-SCHEDULER-01..04 — Scheduler Subsystem (Timers, Calendar, Durable Storage Store, Operator Controls)
Scope
Implement the P1–P3 native Void::Scheduler subsystem and Void::SchedulerStorage durable adapter per docs/roadmap/subsystems/Scheduler.md and docs/roadmap/DEPENDENCIES.md:
S-SCHEDULER-01— In-Memory Heap, Recurrence, Overlap, Cancellation & Shutdown:- Module
src/Scheduler/module.cmake(INTERNAL_DEPS Core Functional Time Async) with zeroStoragedependency. - Error domain
kSchedulerErrorDomain = 31(SchedulerErrorCode). - Monotonic min-heap ordered by
(due_time, sequence)using injectedMonotonicClockandCivilClock, pure construction (no hidden background threads), andAsync::OperationOptionsfor deadlines/cancellation. - One-shot, fixed-delay (advances from durable completion), and fixed-rate (advances from intended schedule time) schedules;
OverlapPolicy(Forbid,QueueOne,AllowBounded);RetryPolicy(default 5 attempts, exponential backoff 1s..5m, x2, injectable full-jitter RNG); callbacks run outside scheduler/store locks. close_and_join()stops materialization/dispatch, signals active handlers, joins within deadline, and returnsShutdownReportpreserving running records on timeout.
- Module
S-SCHEDULER-02— Calendar Grammar, Explicit Timezones/DST, and Bounded Misfire:- 5-field cron-like grammar (
minute hour day month weekdaywith*, lists, ranges, steps; both day-of-month and weekday constraints apply). - Explicit
TimezoneRegistrysupporting"UTC", fixed offsets (+HH:MM/-HH:MM), and explicit DST transition rules (DstGapPolicy::Skip/NextValid,DstFoldPolicy::First/Second/Twicewith persistedfold_index). Unknown timezone fails withUnsupportedTimezone(never silent UTC fallback). MisfirePolicy(Skip,CoalesceLatest,CatchUpBoundedcapped at100slots/job/pass while preserving remaining cursor state even across millions of missed slots).
- 5-field cron-like grammar (
S-SCHEDULER-03— Durable Persistence Port andSchedulerStorageAdapter:JobStoreport +InMemoryJobStore(inScheduler) andStorageJobStore(insrc/SchedulerStorage/module.cmake,INTERNAL_DEPS Scheduler Storage) backed byVoid::Storage::Engineconditional batches (Durability::Sync, 1 MiB batch cap).- Exclusive ownership lock rejecting second concurrent scheduler owner (
OwnershipLocked). - Atomic occurrence materialization + cursor advance with unique
(job, revision, civil_slot, fold)dedup key preventing duplicate materialization on wall-clock rollback. - Atomic
Pending -> Runningclaim checking job tombstone and revision invalidation watermark in the same conditional batch;Running -> Completed/Pending/Deadtransitions;UnknownOutcomesurfaced faithfully on unknown storage write outcome. - Startup crash recovery returning
Runningoccurrences toPendingwith the exact sameOccurrenceId(explicit at-least-once semantics).
S-SCHEDULER-04— Revision Updates, Tombstone Removal, Retention Caps, and Operator Inspection:update_job()bumps revision and atomically writes old-revision invalidation watermark so unstarted old occurrences are cancelled without racing active claims; failed updates leave prior policy intact.remove_job()writes tombstone, stops admission, and requests stop for active handlers.- Retention count cap pauses materialization without advancing cursors or deleting unacknowledged work; dead occurrences require explicit
acknowledge_dead()before pruning; boundedprune_completed()/reclaim_invalidated()and inspection APIs.
File Ownership
include/Void/Scheduler/{Types,Calendar,Store,Scheduler}.hppsrc/Scheduler/{module.cmake,Calendar.cpp,Scheduler.cpp}include/Void/SchedulerStorage/StorageJobStore.hppsrc/SchedulerStorage/{module.cmake,StorageJobStore.cpp}tests/standalone/Scheduler/Scheduler.cpptests/standalone/SchedulerStorage/StorageJobStore.cpptests/package/SchedulerOnly/{CMakeLists.txt,main.cpp}tests/package/InstalledComponents.cmake
Acceptance & Verification
- Standalone
Scheduler;SchedulerStorage;Testing(-DVOID_WARNINGS_AS_ERRORS=ON) +SchedulerOnlyconsumer with_no_external_deps. - Deterministic fake-clock ordering, overlap, retry/dead-letter, DST gap/fold/unknown-tz, millions-of-missed-slots coalesce/catch-up cap, crash/reopen recovery preserving
OccurrenceId, revision watermark race, unknown outcome, and retention-cap cursor preservation tests. - Full
RelWithDebInfo,DebugASan+UBSan, andDebugTSanwith 0 leaks, 0 UB, 0 races.