import { type FairShareCounters } from './fair-share.ts'; import type { WorkerInfo } from './types.ts'; /** * Return `true` when `worker` is eligible for the given `activityName` and * optional `queue` constraint, and has spare capacity. * * This is the single canonical gate every routing policy relies on — it * extracts the capacity+queue+activity filter out of `findWorker` so the loop * body reads as a simple linear scan. */ export declare function matchesWorkerCapabilities(worker: WorkerInfo, activityName: string, queue: string | undefined): boolean; /** * Pick the worker with the lowest in-flight count. Ties broken by stable * worker id ordering so the choice is deterministic across runs. * * `eligible` must be non-empty — the caller is responsible for this precondition. */ export declare function pickLeastLoaded(eligible: WorkerInfo[]): WorkerInfo; /** * Round-robin selection with a per-(queue, activity) cursor so two activities * sharing a queue advance independently. Mutates `cursor` in place, advancing * the entry for this (queue, activity) pair. * * `eligible` must be non-empty — the caller is responsible for this precondition. */ export declare function pickRoundRobin(eligible: WorkerInfo[], cursor: Map, queue: string | undefined, activityName: string): WorkerInfo; /** * Fair-share selection: the worker carrying the fewest in-flight tasks for * `fairShareKey` wins, ties broken by overall in-flight count then stable id * order. The score snapshot is built synchronously so the ranking is consistent * across the full candidate set. * * `eligible` must be non-empty — the caller is responsible for this precondition. */ export declare function pickFairShare(eligible: WorkerInfo[], counters: FairShareCounters, fairShareKey: string): WorkerInfo;