/** * Hourly count of orchestrator turns, by why it was woken * (specs/2026-10-01-orc-status-wakes.md). * * Every orchestrator turn re-reads its whole context (~70k tokens on * 2026-09-29), so the number of turns IS the cost. Once an hour the counter * logs one line: * * orc wakes: 14 (owner 3, delegated-done 2, escalations 1, digest 2, other 6) * * - `N` and `owner` are counted when the queue processor starts an * orchestrator turn (`owner` = any non-system source: Slack, web chat, …). * - `delegated-done`, `escalations`, `digest` are counted when the status * router decides to wake the orchestrator (several queued system events * can coalesce into one turn, so these may add up to more than the turns * they caused). * - `other` = turns that are neither owner messages nor status-router wakes * (cron, wiki, triggers, enforcer reminders, …). * * @module services/orc/orc-wake-counter */ import type { OrcWakeCategory } from './orc-status-routing.js'; /** One hour's numbers. */ export interface OrcWakeCounts { /** Orchestrator turns started */ turns: number; /** Turns for an owner message */ owner: number; /** Status-router wakes: [DONE] on orchestrator-delegated work (incl. owed deliveries) */ delegatedDone: number; /** Status-router wakes: [BLOCKED]/[FAILED] with no lead to take it */ escalations: number; /** Status digests sent */ digest: number; /** Status-router wakes for an answer that was not a status line */ statusOther: number; } /** * The log line for one period. * * @param c - Counts * @returns `orc wakes: N (owner X, delegated-done Y, escalations Z, digest W, other V)` */ export declare function formatOrcWakeLine(c: OrcWakeCounts): string; /** Counts orchestrator wakes and logs them once per period. */ export declare class OrcWakeCounter { private readonly now; private static instance; private counts; private periodStart; private timer; private readonly logger; /** * @param now - Clock (tests) */ constructor(now?: () => number); /** The process-wide counter. */ static getInstance(): OrcWakeCounter; /** Drop the singleton (tests). */ static resetInstance(): void; /** Log every {@link ORC_WAKE_CONSTANTS.COUNTER_LOG_INTERVAL_MS}. Idempotent. */ start(): void; /** Stop the periodic log. */ stop(): void; /** * An orchestrator turn started (queue processor). * * @param source - Message source of the turn */ noteTurn(source: string): void; /** * The status router decided to wake the orchestrator. * * @param category - Why */ noteRouted(category: OrcWakeCategory): void; /** The current period's numbers (copy). */ snapshot(): OrcWakeCounts; /** * Log the period's line and start a new period. * * @returns The logged line */ flush(): string; } //# sourceMappingURL=orc-wake-counter.d.ts.map