import type { OrgDaemon, RunningOrg } from './daemon.js'; import type { PolicyEngine } from './policy.js'; import type { OrgTask } from './task-dag.js'; import type { BusEvent } from './types.js'; /** Share of a budget at which the coordinator is warned: once per role per * run for budget_usd and budget_tokens, once per run for run_config.budget_tokens. */ export declare const BUDGET_WARN_FRACTION = 0.8; /** Which of the role's own caps it has spent, or undefined when neither. A * role whose runner won't start an exec below the budget floor (#550) has * spent its token cap once it is under that floor. */ export declare function exhaustedDetail(policy: PolicyEngine): string | undefined; /** The run's spend against run_config.budget_tokens: every live session on * the budgeted basis (ADR-O001 D1), plus what replaced incarnations retired * into their slot (role-slot.ts / respawnRole) — a replacement must not reset * the org's spend. */ export declare function orgBudgetedUsage(running: RunningOrg): number; declare const orgDetail: (running: RunningOrg) => string; export { orgDetail as orgCeilingDetail }; /** Why `roleId`'s session is closed for budget, or undefined when it is not. * A role closed by the org-wide run_config.budget_tokens ceiling carries the * same close reason without being over its own caps. */ export declare function budgetClosureDetail(running: RunningOrg, roleId: string): string | undefined; /** #552: why `roleId` must not be spawned (or its replacement published) now * — the org-wide ceiling is spent, or the role's own session is closed for * budget (its own caps, including #550's turn floor) — or undefined when it * may. The own-closure half can only fire for a role that has a runtime: a * role that never started has spent nothing of its own, so for a deferred * lazy spawn it matters only when another path started (and closed) the * role meanwhile — spawnRole would no-op then anyway; this makes the skip * explicit and audited. */ export declare function spawnClosedDetail(running: RunningOrg, roleId: string): string | undefined; /** Hold `roleId`'s open tasks with a budget-closure reason (#557 review: a * deferral registered while the org-wide ceiling is spent). */ export declare function holdTasksForBudget(running: RunningOrg, roleId: string, detail: string): void; /** #557 review: a replacement incarnation found the budget closed before it * was published (role-respawn.ts). The old incarnation stays in `agents`; * under the org-wide ceiling it is closed and recorded like the roles the * ceiling closed, so a reload that raises it reopens it. Its open tasks are * held with the reason. */ export declare function holdReplacedRoleForBudget(running: RunningOrg, roleId: string, detail: string): void; /** Re-word `roleId`'s budget-held tasks with the current numbers. */ export declare function refreshHolds(running: RunningOrg, roleId: string): void; /** Bus hook (daemon.ts's org subscriber): enforce the org-wide ceiling, note * a per-role budget closure and warn on the approach to a budget. */ export declare function onBudgetBusEvent(running: RunningOrg, e: BusEvent): void; /** dispatchReadyTasks, for a task whose assignee's mailbox is closed: when it * was closed for budget, hold the task with the reason, warn, tell the task's * creator (or the coordinator) and return true. The task leaves 'ready', so * this happens once per task. */ export declare function holdForBudgetClosedAssignee(running: RunningOrg, task: OrgTask): boolean; /** Put every budget-held task whose assignee is no longer budget-closed back * to 'ready' — after a reload reopened it, a respawn replaced it, or a resume * left its recoverable close open. Called at the top of dispatchReadyTasks. */ export declare function releaseBudgetHolds(running: RunningOrg): void; /** Before a reload changes the def: the live roles whose token cap is the one * the def gives them (their own budget_tokens, policy.maxTokens or their even * split of run_config.budget_tokens) — not a replacement's explicit budget. */ export declare function rolesOnDefTokenCaps(running: RunningOrg): Set; /** Resume `roleId` the way a checkpoint resume does (a budget close is * recoverable, so the new mailbox opens), one generation on, with its spend * kept. False when it could not be spawned; the closed runtime stays. */ export declare function respawnFromCheckpoint(running: RunningOrg, roleId: string): boolean; /** After a hot reload applied new caps: re-derive the token caps of `onDef`'s * roles (rolesOnDefTokenCaps, taken before the def changed), reopen the roles * the org-wide ceiling closed if it now allows, then reopen each role closed * for its own budget that is no longer over it, keeping its spend (the new * cap applies to the total), and re-dispatch their tasks. A role still over * its cap stays closed; its held tasks get the new numbers in their reason. */ export declare function reopenBudgetClosedRoles(daemon: OrgDaemon, org: string, running: RunningOrg, onDef?: Set): string[]; //# sourceMappingURL=budget-closure.d.ts.map