# Scheduler Queue — Sprint 16 Coordination Notes Queue work now has concrete contracts from `StellaOps.Scheduler.Models`: * Planner inputs reference `Schedule` and `ImpactSet` samples (`samples/api/scheduler/`). * Runner segment payloads should carry `runId`, `scheduleId?`, `tenantId`, and the impacted digest list (mirrors `Run.Deltas`). * Notify fanout relies on the `DeltaSummary` shape already emitted by the model layer. ## Action items for SCHED-QUEUE-16-401..403 1. Reference `StellaOps.Scheduler.Models` so adapters can serialise `Run`/`DeltaSummary` without bespoke DTOs. 2. Use the canonical serializer for queue messages to keep ordering consistent with API payloads. 3. Coverage: add fixture-driven tests that enqueue the sample payloads, then dequeue and re-serialise to verify byte-for-byte stability. 4. Expose queue depth/lease metrics with the identifiers provided by the models (`Run.Id`, `Schedule.Id`). ## JetStream failover notes - `SchedulerQueueOptions.Kind = "nats"` will spin up `NatsSchedulerPlannerQueue` / `NatsSchedulerRunnerQueue` instances backed by JetStream. - `SchedulerQueueHealthCheck` pings both planner and runner transports; register via `AddSchedulerQueueHealthCheck()` to surface in `/healthz`. - Planner defaults: ```yaml scheduler: queue: kind: nats deadLetterEnabled: true nats: url: "nats://nats:4222" planner: stream: SCHEDULER_PLANNER subject: scheduler.planner durableConsumer: scheduler-planners deadLetterStream: SCHEDULER_PLANNER_DEAD deadLetterSubject: scheduler.planner.dead runner: stream: SCHEDULER_RUNNER subject: scheduler.runner durableConsumer: scheduler-runners redis: deadLetterStream: scheduler:planner:dead idempotencyKeyPrefix: scheduler:planner:idemp: ``` - Retry / dead-letter semantics mirror the Redis adapter: attempts beyond `MaxDeliveryAttempts` are shipped to the configured dead-letter stream with headers describing `runId`, `scheduleId`, and failure reasons. Set `deadLetterEnabled: false` to drop exhausted messages instead. - Depth metrics surface through `scheduler_queue_depth{transport,queue}`; both transports publish lightweight counters to drive alerting dashboards. These notes unblock the queue guild now that SCHED-MODELS-16-102 is complete.