@coool/opencode-adaptive 1.4.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/adapters/opencode/index.d.ts +2 -0
- package/dist/adapters/opencode/index.js +2 -0
- package/dist/adapters/opencode/index.js.map +1 -1
- package/dist/adapters/opencode/process-ledger.d.ts +56 -0
- package/dist/adapters/opencode/process-ledger.js +143 -0
- package/dist/adapters/opencode/process-ledger.js.map +1 -0
- package/dist/adapters/opencode/session-ops.d.ts +2 -0
- package/dist/adapters/opencode/session-ops.js +15 -9
- package/dist/adapters/opencode/session-ops.js.map +1 -1
- package/dist/adapters/opencode/timer.d.ts +5 -0
- package/dist/adapters/opencode/timer.js +12 -0
- package/dist/adapters/opencode/timer.js.map +1 -0
- package/dist/execution/parking/index.d.ts +2 -1
- package/dist/execution/parking/index.js +2 -1
- package/dist/execution/parking/index.js.map +1 -1
- package/dist/execution/parking/wake.d.ts +52 -0
- package/dist/execution/parking/wake.js +95 -0
- package/dist/execution/parking/wake.js.map +1 -0
- package/dist/gui-experimental.cjs +3 -3
- package/dist/gui.d.ts +2 -2
- package/dist/gui.js +37 -3
- package/dist/gui.js.map +1 -1
- package/dist/index.js +33 -20
- package/dist/index.js.map +1 -1
- package/dist/rpc/status.d.ts +9 -0
- package/dist/rpc/status.js +1 -0
- package/dist/rpc/status.js.map +1 -1
- package/dist/state/parked-work/store.d.ts +5 -0
- package/dist/state/parked-work/store.js +24 -0
- package/dist/state/parked-work/store.js.map +1 -1
- package/dist/supervisor/supervisor.d.ts +2 -0
- package/dist/supervisor/supervisor.js +475 -106
- package/dist/supervisor/supervisor.js.map +1 -1
- package/dist/supervisor/types.d.ts +5 -0
- package/dist/supervisor/types.js.map +1 -1
- package/dist/tui.d.ts +13 -0
- package/dist/tui.js +62 -16
- package/dist/tui.js.map +1 -1
- package/dist/ui/flow/waiting.d.ts +11 -0
- package/dist/ui/flow/waiting.js +40 -0
- package/dist/ui/flow/waiting.js.map +1 -0
- package/dist/ui/gui/api.d.ts +2 -0
- package/dist/ui/gui/api.js +6 -2
- package/dist/ui/gui/api.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor.js","sourceRoot":"","sources":["../../src/supervisor/supervisor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EACL,YAAY,GAIb,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAEnE,OAAO,EACL,KAAK,EACL,OAAO,IAAI,gBAAgB,EAC3B,cAAc,EACd,kBAAkB,GACnB,MAAM,4BAA4B,CAAA;AAOnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAEtE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACxE,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAE/E,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAA;AAY/E,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAGxE,OAAO,EAAE,gBAAgB,EAAE,iBAAi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C,CAAC,EAAE,YAAY,EAAE,cAAc,CAAC,KAAK,CAAC,YAAY,EAAE;YACrD,CAAC,CAAC,EAAE,CAAC;KACR,CAAA;AACH,CAAC","sourcesContent":["/**\n * The supervisor (ADP-025..ADP-032): owns all state stores and glues the pure\n * core to the host reports. It contains no policy of its own — every decision\n * comes from the pure scheduler/retry/tier modules — and it applies the two\n * wiring contracts: fail-open (ADP-031, internal failures log and defer) and\n * Observe ≡ Control (the same admission path, only the mode wrapper differs).\n *\n * Wiring decisions recorded here (see docs/ARCHITECTURE.md):\n * - admission runs only on `execution-started` (a safe boundary); auxiliary\n * per-request routing is not applied in v1 because switching the model for\n * an auxiliary request would also move the primary model.\n * - park records arise only from owned-recovery failures and resume\n * boundaries; admission cannot hold an already-started episode, so an\n * admission `park` decision is recorded as a receipt without a parked\n * record (the episode proceeds on OpenCode's own model).\n * - retry-hook veto decisions are not receipts (they are not scheduler\n * decisions); admission receipts plus outcome attachment cover ADP-030.\n * - interruption reasons outside the known vocabulary leave the unit open\n * (a later episode supersedes it); no outcome is ever fabricated.\n * - escalation (ADP-015..017) triggers only on capability-classified unit\n * failures (context overflow, content policy); infrastructure failures\n * never escalate, and the per-task budget is finite.\n */\nimport { WorkUnitTracker } from \"../core/work-unit/tracker.js\"\nimport {\n sameModelRef,\n type ActiveUnit,\n type ApplyResult,\n type ModelRef,\n} from \"../core/work-unit/types.js\"\nimport { INTERRUPT_REASONS } from \"../core/work-unit/interruption.js\"\nimport type { InterruptReason } from \"../core/work-unit/interruption.js\"\nimport { resolveRouting } from \"../core/tier-policy/resolve.js\"\nimport { isTierName, nextTier } from \"../core/tier-policy/types.js\"\nimport type { RoutingDecision, TierName, TierRequest } from \"../core/tier-policy/types.js\"\nimport {\n admit,\n forMode as schedulerForMode,\n planEscalation,\n schedulerHealthKey,\n} from \"../core/scheduler/index.js\"\nimport type {\n ApplyDecision,\n EscalationEvidence,\n OperatingMode,\n SchedulerInput,\n} from \"../core/scheduler/types.js\"\nimport { MAX_ESCALATION_EVIDENCE } from \"../core/scheduler/types.js\"\nimport type { CandidateModel, Demand } from \"../core/compatibility/types.js\"\nimport { checkCompatibility } from \"../core/compatibility/gate.js\"\nimport { classifyFailure, CapacityRegistry, ResourceHealthRegistry } from \"../health/index.js\"\nimport { sweepRecord } from \"../health/resource-health/transitions.js\"\nimport type { ResourceRecord } from \"../health/resource-health/types.js\"\nimport { HealthRecordStore, HEALTH_KEY } from \"../state/health/index.js\"\nimport { CapacityReadingStore, CAPACITY_KEY } from \"../state/capacity/index.js\"\nimport type { PersistedCapacityReading } from \"../state/capacity/index.js\"\nimport { mergeReadings } from \"../health/capacity/merge.js\"\nimport { resourceChain, resourceKeyID } from \"../health/resource-health/key.js\"\nimport type {\n Assessment,\n CapacityReading,\n CapacitySignals,\n FailureCategory,\n FailureClassification,\n HealthEvent,\n ProbeOutcome,\n ProbeTicket,\n ResourceKey,\n} from \"../health/index.js\"\nimport { SettingsStore, SETTINGS_KEY } from \"../state/settings/index.js\"\nimport type { SettingsV1 } from \"../state/settings/index.js\"\nimport type { PatchResult, SettingsPatch } from \"../state/settings/types.js\"\nimport { SessionModeStore, SESSION_MODES_KEY } from \"../state/session-modes/index.js\"\nimport { TierRequestStore, TIER_REQUESTS_KEY } from \"../state/tier-requests/index.js\"\nimport { ReceiptStore, RECEIPTS_KEY } from \"../state/receipts/index.js\"\nimport type { Receipt, ReceiptInput, ReceiptOutcome } from \"../state/receipts/types.js\"\nimport { buildStatus } from \"../rpc/status.js\"\nimport type { StatusSnapshot } from \"../rpc/status.js\"\nimport { RECEIPTS_VIEW_LIMIT } from \"./view.js\"\nimport { ParkedWorkStore, PARKED_KEY } from \"../state/parked-work/index.js\"\nimport type { ParkedRecord } from \"../state/parked-work/types.js\"\nimport {\n decideRetry,\n executeContinuation,\n forMode as retryForMode,\n planContinuation,\n selectResumable,\n} from \"../execution/index.js\"\nimport { escalationDetail } from \"../execution/escalation/index.js\"\nimport type { RecoveryOption } from \"../execution/index.js\"\nimport { listCandidates, sessionOps, storageSeam } from \"../adapters/opencode/index.js\"\nimport type { EventReport } from \"../adapters/opencode/index.js\"\nimport { CodexCapacitySensor } from \"../adapters/codex-capacity/index.js\"\nimport { logFailOpen } from \"./log.js\"\nimport type { RetryHookInput, SupervisorOptions } from \"./types.js\"\nimport { CODEX_PROVIDER_ID } from \"./types.js\"\n\nimport { TIERS } from \"../core/tier-policy/types.js\"\n\n/** Which tiers currently have configured resources (ADP-005). */\nfunction configuredTiers(settings: SettingsV1): TierName[] {\n return TIERS.filter((tier) => settings.tiers[tier].length > 0)\n}\n\n/** Narrow a wire interrupt reason to the known vocabulary. */\nfunction interruptReason(reason: string): InterruptReason | undefined {\n return (INTERRUPT_REASONS as readonly string[]).includes(reason)\n ? (reason as InterruptReason)\n : undefined\n}\n\n/**\n * Failure categories that count as structured capability evidence (ADP-015).\n * The remaining evidence kinds (agent request, reviewer rejection) have no\n * structured host source in v2 and are never inferred from free text.\n */\nconst CAPABILITY_EVIDENCE_CATEGORIES: readonly FailureCategory[] = [\n \"context_overflow\",\n \"content_policy\",\n]\n\n/** Finite per-task escalation budget (ADP-017). */\nconst MAX_ESCALATIONS_PER_TASK = 2\n\n/**\n * The recovery's post-settle guard aborted it (the session went OFF or the\n * user interrupted while the host settle was in flight). Callers use it to\n * skip the ordinary ops-failure degradation (parking) — an aborted recovery\n * is a steering change, not an infrastructure failure.\n */\nexport class RecoveryAbortedError extends Error {\n constructor(sessionID: string) {\n super(`recovery aborted for session ${sessionID}`)\n this.name = \"RecoveryAbortedError\"\n }\n}\n\nexport class Supervisor {\n readonly #options: SupervisorOptions\n readonly #settings: SettingsStore\n readonly #receipts: ReceiptStore\n readonly #parked: ParkedWorkStore\n readonly #tracker = new WorkUnitTracker()\n readonly #health: ResourceHealthRegistry\n readonly #healthRecords: HealthRecordStore\n readonly #capacityStore: CapacityReadingStore\n readonly #sessionModes: SessionModeStore\n readonly #capacity: CapacityRegistry\n readonly #codex: CodexCapacitySensor\n readonly #vetoes = new Map<string, number>()\n /**\n * Escalations spent per session on the current task (one user prompt and\n * the owned continuations it spawns). Keyed by session, not unit: every\n * escalation continues on a NEW unit, so a per-unit count would restart\n * the budget at each step. A fresh user prompt starts a new task.\n */\n readonly #escalations = new Map<string, number>()\n readonly #admissionTiers = new Map<string, TierName>()\n /** Recorded escalation-tool requests per unit (ADP-015 agent self-reports). */\n readonly #escalationEvidence = new Map<string, EscalationEvidence[]>()\n /** Last agent observed per session (role-hint routing evidence, ADP-002). */\n // Bounded like every other per-session map: long-lived hosts meet many\n // short-lived subagent sessions, and agent hints for long-gone sessions\n // are worthless. Insertion order gives the eviction (oldest hint first).\n static readonly MAX_AGENT_HINTS = 1024\n readonly #agents = new Map<string, string>()\n /**\n * Per-session tier requests (agent-declared via the adaptive_tier tool):\n * the request is STICKY — it steers the session's next and following\n * admissions until cleared or the session dies — because an agent works\n * across many units in one task. Persisted like the session-mode\n * overrides: the host's double plugin instance (hooks vs RPC) must not\n * strand a request on the instance that never routes.\n */\n readonly #tierRequests: TierRequestStore\n /**\n * Sessions whose last model change was the user's own pick\n * (`selected-external`): prompt admission does not re-route them —\n * switching would undo the user's `/model` choice (ADP-028). Cleared by an\n * adaptive switch, a tier request, or a mode change; a standing settings\n * pin overrides the suppression (the pin is manual intent too).\n */\n static readonly MAX_MANUAL_SELECTIONS = 1024\n readonly #manualSelections = new Map<string, true>()\n /**\n * Sessions with an owned continuation prompt in flight: the prompt hook\n * will fire for it, but that prompt belongs to the active unit — it must\n * not re-admit (prevents an admission ping-pong).\n */\n readonly #continuationPending = new Set<string>()\n /**\n * Depth of continuation prompts whose prompt hook has not run yet (or whose\n * host call is still in flight). While a session is inside this window, a\n * unit close must not clear the ownership mark: the close event of the\n * failed unit is pumped concurrently with the continuation's own\n * beforePrompt → prompt-hook sequence, and clearing the mark there would\n * make the continuation re-admit (admission ping-pong).\n */\n readonly #continuationsInFlight = new Map<string, number>()\n /**\n * Sessions with an owned recovery in flight (between veto/resume and the\n * delivered continuation prompt). The host settle inside it can take\n * unbounded time; an interruption arriving during that window must abort\n * the stale decision instead of acting after it.\n */\n readonly #recoveryPending = new Set<string>()\n /** Snapshot-sized budget shared by a task's terminal quota continuations. */\n readonly #quotaRecoveriesRemaining = new Map<string, number>()\n /** Interruptions observed while a recovery was pending on the session. */\n readonly #recoveryInterrupted = new Set<string>()\n /**\n * Half-open probe tickets by session: a probe admitted while computing the\n * recovery for a veto belongs to the continuation episode that follows, so\n * the ticket is parked here until that unit opens and takes it.\n */\n readonly #sessionProbeTickets = new Map<string, ProbeTicket>()\n /**\n * Half-open probe tickets by unit: the unit admitted as (or carrying) the\n * breaker's single probe. Its termination reports the probe outcome — a\n * success closes the breaker, a failure reopens it, an interruption re-arms\n * it — otherwise a lost probe would wedge the resource in half_open.\n */\n readonly #probeTickets = new Map<string, ProbeTicket>()\n /**\n * Per-unit dedup for breaker failure evidence (ADP-019). One failed attempt\n * surfaces through up to three host signals — the pumped `http.response`\n * event, the `retry` hook (the same request), and the terminal\n * `execution-failed` (the last attempt) — and counting each would trip the\n * breaker after ~2 real failures instead of `failureThreshold`. The exact\n * arrival order of a pair is not guaranteed (the retry hook runs in the\n * request lifecycle, the event pump lags), so the dedup is order-symmetric:\n * the first signal of a pair counts and arms, the matching counterpart\n * consumes it, a completed pair closes the attempt, and the terminal\n * repeats only when the last attempt left no live evidence. A same-category\n * observation with nothing armed is a NEW attempt (consecutive http-only\n * failures each count). Cleared at unit close.\n */\n readonly #attemptFailures = new Map<\n string,\n {\n http?: FailureCategory | undefined\n retry?: FailureCategory | undefined\n closed?: FailureCategory | undefined\n }\n >()\n /**\n * Session → tier admitted by the prompt hook for the unit that is about to\n * open. Consumed by execution-started, which then skips re-routing (the\n * model is already applied to the very turn that triggered admission).\n */\n readonly #promptAdmission = new Map<string, { tier?: TierName }>()\n /**\n * Tier intent for an owned continuation (retry recovery, escalation,\n * parked resume) set before its prompt is delivered. The continuation's\n * prompt hook re-arms the prompt-admission marker from this so the\n * continuation's execution-started skips re-routing — a fresh admission\n * would flip an escalated episode back to the preferred model mid-unit\n * (a switch only lands on the next turn). Cleared when the continuation\n * unit opens, its prompt is rejected, or the session dies.\n */\n readonly #continuationTiers = new Map<string, TierName>()\n readonly #ready: Promise<SettingsV1>\n readonly #ops: ReturnType<typeof sessionOps>\n\n constructor(options: SupervisorOptions) {\n this.#options = options\n this.#health = new ResourceHealthRegistry(options.clock)\n this.#capacity = new CapacityRegistry(options.clock)\n this.#codex = new CodexCapacitySensor({ providerID: CODEX_PROVIDER_ID })\n this.#capacity.register(this.#codex)\n this.#settings = new SettingsStore(storageSeam(SETTINGS_KEY, options.storage))\n this.#receipts = new ReceiptStore(storageSeam(RECEIPTS_KEY, options.storage))\n this.#parked = new ParkedWorkStore(storageSeam(PARKED_KEY, options.storage))\n this.#healthRecords = new HealthRecordStore(storageSeam(HEALTH_KEY, options.storage))\n this.#capacityStore = new CapacityReadingStore(storageSeam(CAPACITY_KEY, options.storage))\n this.#sessionModes = new SessionModeStore(\n storageSeam(SESSION_MODES_KEY, options.storage),\n options.clock,\n )\n this.#tierRequests = new TierRequestStore(\n storageSeam(TIER_REQUESTS_KEY, options.storage),\n options.clock,\n )\n this.#ops = sessionOps(options.session, {\n beforeSwitch: (sessionID, model) => {\n this.#tracker.noteOwnSwitch(sessionID, model)\n },\n beforePrompt: (sessionID) => {\n this.#continuationPending.add(sessionID)\n this.#continuationsInFlight.set(\n sessionID,\n (this.#continuationsInFlight.get(sessionID) ?? 0) + 1,\n )\n },\n afterPrompt: (sessionID, delivered) => {\n // sessionOps.prompt calls this only after its own beforePrompt, so\n // the entry is always present; the assertion avoids a default branch\n // no caller can reach.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const depth = this.#continuationsInFlight.get(sessionID)!\n if (depth <= 1) {\n this.#continuationsInFlight.delete(sessionID)\n if (!delivered) {\n // The last in-flight owned prompt never reached the host's hook:\n // its ownership mark would swallow the next user prompt's\n // admission, so it is dropped here (the hook can no longer fire).\n // The continuation's tier intent dies with it — no episode will\n // open to carry it.\n this.#continuationPending.delete(sessionID)\n this.#continuationTiers.delete(sessionID)\n }\n } else {\n this.#continuationsInFlight.set(sessionID, depth - 1)\n }\n },\n })\n // Durable state loads before the first report is handled: a later load\n // must never clobber decisions recorded in the meantime.\n const loadState = async (): Promise<SettingsV1> => {\n await this.#receipts.load()\n await this.#parked.load()\n // Unit ids are durable keys (`${sessionID}#${episode}`) persisted in\n // receipts and parked work. Seed the tracker's per-session episode\n // counters above every persisted id: after a restart the counters\n // must never re-mint a colliding id, which would replace a parked\n // record (the store parks one record per id) and misattribute\n // receipt outcomes.\n const floors = new Map<string, number>()\n const bump = (unitID: string | undefined): void => {\n if (unitID === undefined) return\n const cut = unitID.lastIndexOf(\"#\")\n if (cut <= 0) return\n const sessionID = unitID.slice(0, cut)\n const episode = Number(unitID.slice(cut + 1))\n if (!Number.isInteger(episode) || episode <= 0) return\n if (episode > (floors.get(sessionID) ?? 0)) floors.set(sessionID, episode)\n }\n for (const receipt of this.#receipts.snapshot()) bump(receipt.unitID)\n for (const record of this.#parked.list()) bump(record.id)\n this.#tracker.seedEpisodes(floors)\n // Health records hydrate the registry: the host's TUI-mode plugin\n // reconciliation can serve RPC from an instance whose hooks (event\n // pump) live on another instance — persisted failures are the only\n // health that instance can see, and a fresh instance must also assess\n // persisted failures before routing instead of starting from empty.\n await this.#healthRecords.load()\n this.#health.hydrate(this.#healthRecords.snapshot())\n // Session-mode overrides hydrate the same way: a restart (or the\n // host's double-instance reconciliation) must keep steering sessions\n // under the modes the user set for them.\n await this.#sessionModes.load()\n // Tier requests hydrate the same way: a tier request recorded through\n // the host's other plugin instance (or before a restart) must still\n // steer this instance's admissions.\n await this.#tierRequests.load()\n await this.#capacityStore.load()\n return this.#settings.load()\n }\n this.#ready = loadState()\n }\n\n /** Settings as of the latest load/patch (awaits the constructor load). */\n async #ensureSettings(): Promise<SettingsV1> {\n await this.#ready\n return this.#settings.get()\n }\n\n /**\n * The session's effective operating mode (ADP-054): its per-session\n * override when one is set, else the global mode. Every session-scoped\n * supervision decision consults this instead of `settings.mode` directly.\n */\n #modeFor(sessionID: string, settings: SettingsV1): OperatingMode {\n return this.#sessionModes.get(sessionID) ?? settings.mode\n }\n\n // ---------- public entry points (never throw — fail-open, ADP-031) ----------\n\n /** Handle one host report (event pump or session hook). */\n async handleReport(report: EventReport): Promise<void> {\n try {\n const settings = await this.#ensureSettings()\n // An OFF session is fully inert — no supervision, no receipts, no\n // health evidence. Idle is the exception: it is the bookkeeping\n // boundary (parked-work sweep, dead-session override pruning) and runs\n // for every report so other sessions' overrides are maintained; the\n // sweep itself gates per parked session below.\n if (report.kind !== \"idle\" && this.#modeFor(report.sessionID, settings) === \"off\") return\n await this.#dispatch(report, settings)\n } catch (error) {\n logFailOpen(\"report\", error)\n }\n }\n\n /** Marks the session's manual-selection state from an external selection event. */\n #noteManualSelection(sessionID: string): void {\n if (\n !this.#manualSelections.has(sessionID) &&\n this.#manualSelections.size >= Supervisor.MAX_MANUAL_SELECTIONS\n ) {\n // The guard above ensures the map is at its cap (>= 1 entries), so the\n // first key always exists; the assertion avoids a branch the coverage\n // gate would reject as unreachable.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const oldest = this.#manualSelections.keys().next().value!\n this.#manualSelections.delete(oldest)\n }\n this.#manualSelections.set(sessionID, true)\n }\n\n /**\n * True while the session's last model change was the user's own pick.\n * A standing settings pin is explicit manual intent as well (ADP-002):\n * honoring it does not fight the pick, so suppression is skipped there.\n */\n #manuallySelected(sessionID: string, settings: SettingsV1): boolean {\n return settings.pin === null && this.#manualSelections.has(sessionID)\n }\n\n /**\n * The manual-pick suppression actually applied at an admission. It yields\n * when the picked model is health-blocked: keeping the session on a\n * quarantined resource does not honor the pick — the configured fallback\n * takes over instead (the pick is re-honored only if the user picks again).\n * Uses the non-mutating evaluation, never a probe admission.\n */\n #manualSuppressionHolds(sessionID: string, settings: SettingsV1): boolean {\n if (!this.#manuallySelected(sessionID, settings)) return false\n const current = this.#tracker.lastModel(sessionID)?.model\n if (current === undefined) return true\n if (this.#health.evaluate(refKey(current)).kind !== \"blocked\") return true\n this.#manualSelections.delete(sessionID)\n return false\n }\n\n /**\n * Handle one `retry` hook invocation. On a veto this mutates\n * `input.decision` to `{ retry: false }`; otherwise the decision is left\n * untouched and OpenCode's native retry policy stands.\n */\n async handleRetry(input: RetryHookInput): Promise<void> {\n try {\n const settings = await this.#ensureSettings()\n if (this.#modeFor(input.sessionID, settings) === \"off\") return\n await this.#handleRetry(input, settings)\n } catch (error) {\n logFailOpen(\"retry\", error)\n }\n }\n\n /**\n * Record an escalation-tool request (ADP-015 agent self-report) against the\n * session's current work unit. Returns false when no unit is active — the\n * request is then discarded (escalation is a per-unit signal).\n */\n noteEscalationRequest(sessionID: string, reason: string, evidence: string): boolean {\n const unit = this.#tracker.active(sessionID)\n if (unit === undefined) return false\n const recorded = this.#escalationEvidence.get(unit.id) ?? []\n recorded.push({\n kind: \"agent-request\",\n detail: escalationDetail({ reason, evidence }),\n })\n this.#escalationEvidence.set(unit.id, recorded.slice(-MAX_ESCALATION_EVIDENCE))\n return true\n }\n\n /**\n * Record an agent-declared tier request for the session (the adaptive_tier\n * tool). STICKY: it steers the session's next and following admissions\n * until cleared — an agent works across many units in one task. Returns\n * false on an unknown tier (the tool re-validates before calling).\n *\n * Fire-and-forget persistence: the recorder signature is sync on both the\n * tool and the RPC source interfaces, so the write is enqueued without\n * awaiting it. Readers (routing, getTierRequest, the idle sweep) flush the\n * store's queue before reading, which makes the record visible\n * deterministically; a write failure drops the record fail-open (the tool\n * told the agent \"recorded\", the persisted mirror simply never sees it —\n * the same degradation the in-memory map had on restart).\n */\n noteTierRequest(sessionID: string, tier: string): boolean {\n if (!isTierName(tier)) return false\n void this.#tierRequests.set(sessionID, tier).catch(() => undefined)\n // The user/agent explicitly asked Adaptive to route again (ADP-028).\n this.#manualSelections.delete(sessionID)\n return true\n }\n\n /** The session's tier request, or `null` when it follows the routing ladder. */\n async getTierRequest(sessionID: string): Promise<TierName | null> {\n await this.#ready\n // A fire-and-forget note may still be in the queue: flush before reading.\n await this.#tierRequests.flush()\n return this.#tierRequests.get(sessionID)\n }\n\n /** Clear one session's tier request (`null` is the only valid input). */\n async setTierRequest(sessionID: string, tier: TierName | null): Promise<void> {\n await this.#ready\n if (tier !== null) throw new Error(\"only null clears a tier request\")\n await this.#tierRequests.set(sessionID, null)\n // Clearing through the control surface is the user asking Adaptive back.\n this.#manualSelections.delete(sessionID)\n }\n\n // ---------- state API for the control surfaces (ADP-033/034/036) ----------\n\n /** Current settings (awaits the constructor load). */\n async settings(): Promise<SettingsV1> {\n return this.#ensureSettings()\n }\n\n /** Validate and persist a settings patch; returns per-field errors. */\n async updateSettings(patch: SettingsPatch): Promise<PatchResult> {\n await this.#ready\n const result = await this.#settings.update(patch)\n if (result.ok && patch.mode !== undefined) {\n // A global mode change is the user steering Adaptive explicitly\n // (ADP-028): manual-selection suppression lifts for every session.\n this.#manualSelections.clear()\n }\n return result\n }\n\n /** The session's mode override, or `null` when it follows the global mode. */\n async getSessionMode(sessionID: string): Promise<OperatingMode | null> {\n await this.#ready\n return this.#sessionModes.get(sessionID)\n }\n\n /**\n * Persist one session's mode override (`null` clears it). Throws on write\n * failure — the RPC handler degrades that to an error patch result\n * (fail-open, ADP-031), while the routing path never calls this.\n */\n async setSessionMode(sessionID: string, mode: OperatingMode | null): Promise<void> {\n await this.#ready\n await this.#sessionModes.set(sessionID, mode)\n // A mode change is the user steering Adaptive explicitly (ADP-028).\n this.#manualSelections.delete(sessionID)\n }\n\n /**\n * Bounded status snapshot for the status view (ADP-033). Health is read\n * from the persisted record set (not the in-memory registry): the serving\n * instance's registry can be empty when the host's plugin reconciliation\n * placed the event-pump hooks on another instance, while the persisted\n * mirror is shared by every instance.\n */\n async status(): Promise<StatusSnapshot> {\n const settings = await this.#ensureSettings()\n await this.#healthRecords.load()\n // The persisted mirror serves the status surface: a serving instance\n // without the event-pump hooks must still report sensed capacity.\n await this.#capacityStore.load()\n const now = this.#options.clock()\n const records = this.#healthRecords.snapshot().map((record) => sweepRecord(record, now))\n // Capacity readings are gathered per configured ref (mirroring the health\n // input shape) so buildStatus stays a pure function of its inputs.\n const capacity: Record<string, CapacityReading | null> = {}\n for (const tier of TIERS) {\n for (const ref of settings.tiers[tier]) {\n const chainIDs = new Set(resourceChain(refKey(ref)).map(resourceKeyID))\n const candidates = this.#capacityStore\n .snapshot()\n .filter((entry) => chainIDs.has(resourceKeyID(entry.key)))\n .map((entry) => entry.reading)\n capacity[schedulerHealthKey(ref)] = mergeReadings(candidates, now)\n }\n }\n return buildStatus({\n settings,\n health: records,\n capacity,\n parked: this.#parked.count(),\n receipts: this.#receipts.snapshot().length,\n })\n }\n\n /** Newest-first bounded receipt view (ADP-030). */\n async receipts(): Promise<Receipt[]> {\n await this.#ready\n return this.#receipts.snapshot().slice(-RECEIPTS_VIEW_LIMIT).reverse()\n }\n\n // ---------- dispatch ----------\n\n async #dispatch(report: EventReport, settings: SettingsV1): Promise<void> {\n switch (report.kind) {\n case \"execution-started\":\n await this.#onExecutionStarted(report, settings)\n return\n case \"execution-succeeded\":\n await this.#onExecutionSucceeded(report)\n return\n case \"execution-failed\":\n await this.#onExecutionFailed(report, settings)\n return\n case \"execution-interrupted\":\n await this.#onExecutionInterrupted(report)\n return\n case \"model-selected\": {\n const result = this.#tracker.apply({\n kind: \"model-selected\",\n sessionID: report.sessionID,\n at: report.at,\n model: report.model,\n })\n // Whether the change was the user's pick or Adaptive's own switch\n // decides who controls the session's model (ADP-028); the result\n // carries the attribution the tracker resolved. Only the two\n // selection sources reach this event kind.\n const { source } = result.transition\n if (source === \"selected-adaptive\") this.#manualSelections.delete(report.sessionID)\n else this.#noteManualSelection(report.sessionID)\n return\n }\n case \"model-request\":\n if (report.agent !== undefined) {\n if (\n !this.#agents.has(report.sessionID) &&\n this.#agents.size >= Supervisor.MAX_AGENT_HINTS\n ) {\n // The guard above ensures the map is at its cap (>= 1 entries),\n // so the first key always exists; the assertion avoids a branch\n // the coverage gate would reject as unreachable.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const oldest = this.#agents.keys().next().value!\n this.#agents.delete(oldest)\n }\n this.#agents.set(report.sessionID, report.agent)\n }\n // Only the agent loop's own request reports the model actually\n // executing the unit's work. An auxiliary request (title, compaction,\n // generate — ADP-027) carries the host's own cheap pick for that side\n // request; adopting it as the session's model would misattribute the\n // primary unit's health evidence and leave the next admission\n // believing the unit runs on the wrong resource.\n if (report.requestKind === \"primary\") {\n this.#tracker.apply({\n kind: \"model-request\",\n sessionID: report.sessionID,\n at: this.#options.clock(),\n model: report.model,\n })\n }\n return\n case \"http-response\":\n await this.#onHttpResponse(report)\n return\n case \"idle\":\n await this.#onIdle(settings)\n return\n case \"prompt\":\n await this.#onPrompt(report.sessionID, settings)\n return\n }\n }\n\n // ---------- admission ----------\n\n /**\n * CONTROL-mode admission in the awaited prompt hook. The hook runs before\n * the turn's model resolution, so the applied model governs the very turn\n * that triggered admission (the event-pump execution-started report is\n * asynchronous and would only affect the next turn — verified on host\n * 2.2.5). OBSERVE never switches, so it needs no prompt-time decision and\n * stays on the pump entirely.\n */\n async #onPrompt(sessionID: string, settings: SettingsV1): Promise<void> {\n const mode = this.#modeFor(sessionID, settings)\n if (mode !== \"active\") return\n if (this.#continuationPending.delete(sessionID)) {\n // An owned continuation (retry recovery, escalation, parked resume)\n // already owns this unit's routing: re-arm the admission marker from\n // the continuation's tier intent so execution-started skips a fresh\n // (continuation-unaware) admission.\n const tier = this.#continuationTiers.get(sessionID)\n this.#promptAdmission.set(sessionID, tier !== undefined ? { tier } : {})\n return\n }\n // Prompt hooks also admit steering messages into an active episode. They\n // are not routing boundaries: switching here interrupts productive work\n // and resets its recovery budget before the host consumes the steering.\n if (this.#tracker.active(sessionID) !== undefined) return\n // A fresh user prompt cancels any stale continuation intent and marker:\n // this admission re-routes from scratch.\n this.#continuationTiers.delete(sessionID)\n this.#promptAdmission.delete(sessionID)\n this.#escalations.delete(sessionID)\n this.#quotaRecoveriesRemaining.delete(sessionID)\n // A pending probe ticket from an earlier prompt admission (or a failed\n // recovery) can only be carried by the unit the ORIGINAL prompt opens;\n // a fresh admission means that episode never ran, so the ticket is\n // released here instead of being adopted by whichever unit opens next.\n const stale = this.#sessionProbeTickets.get(sessionID)\n if (stale !== undefined) {\n this.#sessionProbeTickets.delete(sessionID)\n this.#health.releaseProbe(stale)\n }\n if (this.#manualSuppressionHolds(sessionID, settings)) {\n // ADP-028: the user's own model pick stands (yielded to health if the\n // picked resource is quarantined). Recording the defer (no switch, no\n // marker) leaves OpenCode's choice — the picked model — in place;\n // execution-started will skip routing the same way.\n await this.#recordReceipt({\n sessionID,\n decision: { kind: \"defer\", reason: \"routing-defer\", detail: \"manual-selection\" },\n })\n return\n }\n let probeTicket: ProbeTicket | undefined\n try {\n const admission = await this.#admit(settings, sessionID)\n probeTicket = admission.probeTicket\n const wrapped = schedulerForMode(admission.decision, mode)\n if (wrapped.kind === \"apply\") {\n await this.#ops.switchModel(sessionID, wrapped.model)\n }\n // A pin is not a tier — receipts only carry a tier for tiered routing.\n const tier = routingTier(admission.routing)\n await this.#recordReceipt({\n sessionID,\n ...(tier !== undefined ? { tier } : {}),\n decision: wrapped,\n })\n this.#promptAdmission.set(sessionID, { ...(tier !== undefined ? { tier } : {}) })\n // The prompt-admitted probe episode is the turn that follows.\n if (wrapped.kind === \"apply\" && probeTicket !== undefined) {\n this.#sessionProbeTickets.set(sessionID, probeTicket)\n }\n } catch (error) {\n // A probe admitted for this turn is lost when the admission fails (the\n // switch threw): no unit will ever carry the ticket, so release it.\n if (probeTicket !== undefined) {\n this.#health.releaseProbe(probeTicket)\n }\n // Fail-open: no marker → execution-started re-routes the unit itself.\n logFailOpen(\"admission\", error)\n await this.#recordReceipt({\n sessionID,\n decision: { kind: \"defer\", reason: \"routing-defer\", detail: \"internal error\" },\n })\n }\n }\n\n async #onExecutionStarted(\n report: EventReport & { kind: \"execution-started\" },\n settings: SettingsV1,\n ): Promise<void> {\n const opened = this.#tracker.apply({\n kind: \"execution-started\",\n sessionID: report.sessionID,\n at: report.at,\n })\n const unit = opened.unit\n // The prompt-hook marker belongs to the unit this report OPENS, so read\n // it before the close cleanup: a superseding start would otherwise\n // discard it and re-route an already-admitted turn.\n const admitted = this.#promptAdmission.get(report.sessionID)\n // A superseding start closes the previous episode — release its\n // per-unit bookkeeping (veto budget) too.\n this.#afterUnitClose(opened)\n // The prompt hook already admitted and applied for this unit — carry the\n // tier into escalation context and skip re-routing.\n if (admitted !== undefined) {\n this.#promptAdmission.delete(report.sessionID)\n this.#continuationTiers.delete(report.sessionID)\n if (admitted.tier !== undefined) this.#admissionTiers.set(unit.id, admitted.tier)\n // The prompt-time admission receipt was recorded before this unit\n // existed; adopt it so outcomes attach to it like any unit receipt.\n try {\n await this.#receipts.adoptUnit(report.sessionID, unit.id)\n } catch (error) {\n logFailOpen(\"receipts\", error)\n }\n const sessionTicket = this.#sessionProbeTickets.get(report.sessionID)\n if (sessionTicket !== undefined) {\n this.#sessionProbeTickets.delete(report.sessionID)\n this.#probeTickets.set(unit.id, sessionTicket)\n }\n return\n }\n // A probe admitted while computing a veto's recovery belongs to the\n // continuation episode that follows — the first start on the session\n // after the veto.\n const carriedTicket = this.#sessionProbeTickets.get(report.sessionID)\n if (carriedTicket !== undefined) {\n this.#sessionProbeTickets.delete(report.sessionID)\n this.#probeTickets.set(unit.id, carriedTicket)\n }\n try {\n await this.#routeAdmission(unit, settings, this.#modeFor(unit.sessionID, settings))\n } catch (error) {\n logFailOpen(\"admission\", error)\n await this.#recordReceipt({\n sessionID: unit.sessionID,\n unitID: unit.id,\n decision: { kind: \"defer\", reason: \"routing-defer\", detail: \"internal error\" },\n })\n }\n }\n\n /** Fresh admission: routing ladder → scheduler, raw (unwrapped). */\n async #admit(\n settings: SettingsV1,\n sessionID: string,\n requiredTier?: TierName,\n ): Promise<{\n routing: RoutingDecision\n decision: ReturnType<typeof admit>\n probeTicket?: ProbeTicket\n }> {\n // The agent-declared tier request (adaptive_tier tool) outranks the\n // role hints but stays below the pin (ADP-002 ladder). The note is\n // recorded fire-and-forget, so flush the store's queue before reading.\n await this.#tierRequests.flush()\n const tierRequest = this.#tierRequests.get(sessionID)\n let routedTier: TierRequest | undefined\n if (requiredTier !== undefined) {\n routedTier = { tier: requiredTier, via: \"manual-command\" as const }\n } else if (tierRequest !== null) {\n routedTier = { tier: tierRequest, via: \"manual-command\" as const }\n }\n const routing = resolveRouting({\n ...(settings.pin !== null ? { pin: settings.pin } : {}),\n ...(routedTier !== undefined ? { tierRequest: routedTier } : {}),\n // The agent-role hint is the session's last observed agent — the host\n // reports it on every model request (ADP-002 level 3).\n ...(this.#agents.has(sessionID) ? { agent: this.#agents.get(sessionID) } : {}),\n agentTiers: settings.agentTiers,\n configuredTiers: configuredTiers(settings),\n })\n const tierCandidates = routing.kind === \"tier\" ? settings.tiers[routing.tier] : []\n const inventory = await listCandidates(this.#options.model)\n // Capacity sensors are pull-based: refresh before assessing so the\n // admission decision sees current readings.\n await this.#capacity.refresh()\n const health: Record<string, Assessment> = {}\n const capacity: Record<string, CapacitySignals> = {}\n // Tickets issued by this assessment sweep (see the release below).\n const issued: ProbeTicket[] = []\n // Only the routed candidates are assessed: assess flips a due breaker to\n // half_open, and admitting a quick unit has no business touching an\n // advanced-tier resource's breaker.\n const routed = routing.kind === \"pin\" ? [routing.model] : tierCandidates\n for (const ref of routed) {\n const mapKey = schedulerHealthKey(ref)\n const assessment = this.#health.assess(refKey(ref))\n health[mapKey] = assessment\n if (assessment.kind === \"probe\") issued.push(assessment.ticket)\n const capacityAssessment = this.#capacity.assessment(refKey(ref))\n if (capacityAssessment.kind === \"estimate\") capacity[mapKey] = capacityAssessment.signals\n }\n const input: SchedulerInput = {\n routing,\n // The host exposes no per-episode demand source in the v2 wiring\n // (no tool/modality/context requirement reaches the plugin), so the\n // compatibility gate runs on availability metadata only. Documented\n // limitation — see TEST_STRATEGY \"Compatibility gate demand\".\n demand: {} satisfies Demand,\n inventory,\n tierCandidates,\n health,\n capacity,\n }\n const decision = admit(input)\n // Assess admits a half-open probe for every due breaker it touches —\n // including candidates this decision passed over (an earlier ready\n // candidate wins) or dispatched nothing for (defer/park). An\n // issued-but-undispatched probe would wedge its resource in half_open:\n // no unit ever carries the ticket. Release each unselected ticket — it\n // stays due, because a probe that never ran is no health evidence and\n // restarting its backoff would push it back on every admission.\n const selectedId = decision.kind === \"apply\" ? decision.evidence.probeId : undefined\n let probeTicket: ProbeTicket | undefined\n for (const ticket of issued) {\n if (selectedId !== undefined && ticket.id === selectedId) {\n probeTicket = ticket\n } else {\n this.#health.releaseProbe(ticket)\n }\n }\n return { routing, decision, ...(probeTicket !== undefined ? { probeTicket } : {}) }\n }\n\n async #routeAdmission(\n unit: ActiveUnit,\n settings: SettingsV1,\n mode: OperatingMode,\n ): Promise<void> {\n if (this.#manualSuppressionHolds(unit.sessionID, settings)) {\n // ADP-028: the session runs on the user's own pick (yielded to health\n // if the picked resource is quarantined) — no re-route.\n await this.#recordReceipt({\n sessionID: unit.sessionID,\n unitID: unit.id,\n decision: { kind: \"defer\", reason: \"routing-defer\", detail: \"manual-selection\" },\n })\n return\n }\n const { routing, decision, probeTicket } = await this.#admit(settings, unit.sessionID)\n // The tier the unit was admitted under is escalation context (ADP-015);\n // recorded for every tiered routing outcome (including a defer, which\n // still names the tier it could not honor).\n if (routing.kind !== \"pin\") {\n this.#admissionTiers.set(unit.id, routing.tier)\n }\n const wrapped = schedulerForMode(decision, mode)\n if (wrapped.kind === \"apply\") {\n try {\n await this.#applyModel(unit, wrapped)\n } catch (error) {\n // The episode cannot carry the probe when the switch itself failed —\n // release the ticket instead of wedging the resource half-open.\n if (probeTicket !== undefined) {\n this.#health.releaseProbe(probeTicket)\n }\n throw error\n }\n if (probeTicket !== undefined) this.#probeTickets.set(unit.id, probeTicket)\n return\n }\n if (probeTicket !== undefined) {\n // OBSERVE wraps an apply — including a probe admission — without\n // running it: no episode will ever report the ticket, so release it.\n this.#health.releaseProbe(probeTicket)\n }\n // Observe-only records the identical decision; defer and park leave the\n // episode on OpenCode's own model (admission cannot hold an episode).\n const tier = routingTier(routing)\n await this.#recordReceipt({\n sessionID: unit.sessionID,\n unitID: unit.id,\n ...(tier !== undefined ? { tier } : {}),\n decision: wrapped,\n })\n }\n\n /** CONTROL-mode application at the admission boundary; OBSERVE never reaches here. */\n async #applyModel(unit: ActiveUnit, decision: ApplyDecision): Promise<void> {\n await this.#ops.switchModel(unit.sessionID, decision.model)\n await this.#recordReceipt({\n sessionID: unit.sessionID,\n unitID: unit.id,\n ...(decision.tier !== undefined ? { tier: decision.tier } : {}),\n decision,\n })\n }\n\n // ---------- unit termination ----------\n\n async #onExecutionSucceeded(\n report: EventReport & { kind: \"execution-succeeded\" },\n ): Promise<void> {\n const unit = this.#tracker.active(report.sessionID)\n const model = unit?.model ?? this.#tracker.lastModel(report.sessionID)?.model\n const probeTicket = this.#takeProbeTicket(unit?.id)\n const closed = this.#tracker.apply({\n kind: \"execution-succeeded\",\n sessionID: report.sessionID,\n at: report.at,\n })\n this.#afterUnitClose(closed)\n if (model !== undefined) {\n this.#observeHealth({ kind: \"success\", key: refKey(model) })\n }\n if (unit !== undefined) {\n if (probeTicket !== undefined) {\n this.#reportProbeOutcome(probeTicket, { success: true })\n }\n await this.#attachOutcome(unit, { status: \"succeeded\" })\n }\n }\n\n async #onExecutionFailed(\n report: EventReport & { kind: \"execution-failed\" },\n settings: SettingsV1,\n ): Promise<void> {\n const unit = this.#tracker.active(report.sessionID)\n const model = unit?.model ?? this.#tracker.lastModel(report.sessionID)?.model\n const unitID = unit?.id\n // The tier is read before the close clears the per-unit maps.\n const admissionTier = unitID !== undefined ? this.#admissionTiers.get(unitID) : undefined\n const escalationUsed = this.#escalations.get(report.sessionID) ?? 0\n // Tool evidence is captured pre-close like the other per-unit maps.\n const toolEvidence = unitID !== undefined ? (this.#escalationEvidence.get(unitID) ?? []) : []\n const probeTicket = this.#takeProbeTicket(unitID)\n // The terminal classifies and dedups BEFORE the close: the close clears\n // the unit's attempt-failure entry, and the terminal must consult it —\n // it repeats the episode's last attempt, which an attempt signal\n // (http-response or retry hook) already counted.\n const classification = classifyFailure({\n structured: {\n type: report.error.type,\n ...(report.error.retryAfterMs !== undefined\n ? { retryAfterMs: report.error.retryAfterMs }\n : {}),\n },\n status: report.error.status,\n // Terminal classification may use the bounded textual last resort\n // (content-policy rejections arrive as free text, not error types).\n // The retry hook passes text only to refine a 429's window.\n text: report.error.message,\n })\n const countTerminal = this.#countTerminalFailure(unitID, classification.category)\n const closed = this.#tracker.apply({\n kind: \"execution-failed\",\n sessionID: report.sessionID,\n at: report.at,\n error: report.error,\n })\n this.#afterUnitClose(closed)\n if (model !== undefined && countTerminal) {\n this.#observeHealth(failureEvent(refKey(model), classification))\n }\n if (unit !== undefined) {\n await this.#attachOutcome(unit, { status: \"failed\", category: classification.category })\n if (probeTicket !== undefined) {\n this.#reportProbeOutcome(probeTicket, { success: false, category: classification.category })\n }\n }\n if (\n unit !== undefined &&\n model !== undefined &&\n classification.category === \"quota_exhausted\"\n ) {\n await this.#recoverTerminalQuota(unit, admissionTier, settings)\n return\n }\n await this.#escalateOnFailure(\n report,\n unitID,\n model,\n classification,\n admissionTier,\n escalationUsed,\n toolEvidence,\n settings,\n )\n }\n\n async #recoverTerminalQuota(\n unit: ActiveUnit,\n requiredTier: TierName | undefined,\n settings: SettingsV1,\n ): Promise<void> {\n const sessionID = unit.sessionID\n // A retry veto already owns the continuation; its terminal echo must not\n // start another. OBSERVE computes the same admission without applying it.\n const mode = this.#modeFor(sessionID, settings)\n if (\n mode === \"off\" ||\n this.#recoveryPending.has(sessionID) ||\n this.#continuationTiers.has(sessionID) ||\n this.#continuationPending.has(sessionID)\n )\n return\n if (mode === \"active\") this.#manualSuppressionHolds(sessionID, settings)\n const { routing, decision, probeTicket } = await this.#admit(settings, sessionID, requiredTier)\n const tier = routingTier(routing)\n if (mode === \"observe\") {\n if (probeTicket !== undefined) this.#health.releaseProbe(probeTicket)\n await this.#recordReceipt({ sessionID, tier, decision: schedulerForMode(decision, mode) })\n return\n }\n // Quota windows can expire while session.wait is pending. Snapshot the\n // configured ladder length once so even those recoveries cannot loop.\n const remaining =\n this.#quotaRecoveriesRemaining.get(sessionID) ??\n (tier === undefined ? 0 : settings.tiers[tier].length)\n if (decision.kind === \"apply\" && remaining === 0) {\n if (probeTicket !== undefined) this.#health.releaseProbe(probeTicket)\n return\n }\n await this.#recordReceipt({ sessionID, tier, decision })\n if (decision.kind !== \"apply\") {\n if (decision.kind === \"park\" && tier !== undefined) {\n await this.#parked.park({\n id: unit.id,\n sessionID,\n tier,\n reason: \"all-blocked\",\n detail: \"quota exhausted\",\n parkedAt: this.#options.clock(),\n })\n }\n return\n }\n this.#quotaRecoveriesRemaining.set(sessionID, remaining - 1)\n if (probeTicket !== undefined) this.#sessionProbeTickets.set(sessionID, probeTicket)\n // The host rejected this attempt without invoking its retry hook. Continue\n // from durable session state rather than waiting for another user message.\n void this.#ownRecovery(\n sessionID,\n decision.model,\n tier,\n () => this.#modeFor(sessionID, this.#settings.get()) === \"active\",\n ).catch((error: unknown) => {\n if (probeTicket !== undefined && this.#sessionProbeTickets.get(sessionID) === probeTicket) {\n this.#sessionProbeTickets.delete(sessionID)\n this.#health.releaseProbe(probeTicket)\n }\n if (!(error instanceof RecoveryAbortedError)) logFailOpen(\"quota-recovery\", error)\n })\n }\n\n /**\n * Escalation targets must be usable: the scheduler contract hands\n * planEscalation \"already gated\" resources, so the wiring filters the next\n * tier's configured refs to candidates that exist in the inventory, pass\n * the compatibility gate, are not health-blocked, and differ from the\n * model that just failed. Evaluated WITHOUT probe admission (evaluate,\n * not assess) — gating an escalation must never flip a breaker or strand\n * an unowned ticket.\n */\n async #eligibleEscalationTargets(\n refs: readonly ModelRef[],\n failed: ModelRef,\n ): Promise<ModelRef[]> {\n let inventory: readonly CandidateModel[]\n try {\n inventory = await listCandidates(this.#options.model)\n } catch (error) {\n // No inventory means no verifiable target: escalating would switch\n // blind, so the budget is kept instead of burned.\n logFailOpen(\"escalation\", error)\n return []\n }\n const eligible: ModelRef[] = []\n // Compared by resource key: the host reports base-model calls as variant\n // \"default\", which is the same resource as the bare tier entry.\n const failedID = resourceKeyID(refKey(failed))\n for (const ref of refs) {\n if (resourceKeyID(refKey(ref)) === failedID) continue\n const candidate = inventory.find((entry) => sameModelRef(candidateRef(entry), ref))\n if (candidate === undefined) continue\n if (!checkCompatibility(candidate, {} satisfies Demand).compatible) continue\n if (this.#health.evaluate(refKey(ref)).kind !== \"available\") continue\n eligible.push(ref)\n }\n return eligible\n }\n\n /**\n * Escalation on a terminally failed unit (ADP-015..017): structured\n * capability evidence only, same-model variant first then next tier,\n * finite budget. Control continues the interrupted work on the escalated\n * resource; Observe records the identical decision; defer receipts stand.\n */\n async #escalateOnFailure(\n report: EventReport & { kind: \"execution-failed\" },\n unitID: string | undefined,\n model: ModelRef | undefined,\n classification: FailureClassification,\n admissionTier: TierName | undefined,\n escalationUsed: number,\n toolEvidence: readonly EscalationEvidence[],\n settings: SettingsV1,\n ): Promise<void> {\n if (\n unitID === undefined ||\n model === undefined ||\n admissionTier === undefined ||\n !CAPABILITY_EVIDENCE_CATEGORIES.includes(classification.category)\n ) {\n return\n }\n const next = nextTier(admissionTier)\n const evidence: EscalationEvidence[] = [\n ...toolEvidence,\n { kind: \"repeated-failure\", detail: classification.category },\n ]\n const nextResources = next !== undefined ? settings.tiers[next] : []\n const eligible = await this.#eligibleEscalationTargets(nextResources, model)\n const plan = planEscalation({\n currentModel: model,\n currentTier: admissionTier,\n nextTierResources: eligible,\n evidence,\n budget: { used: escalationUsed, max: MAX_ESCALATIONS_PER_TASK },\n })\n const wrapped = schedulerForMode(plan, this.#modeFor(report.sessionID, settings))\n if (wrapped.kind === \"escalate\") {\n this.#escalations.set(report.sessionID, escalationUsed + 1)\n // Recorded unit-less on purpose: the receipt describes the CONTINUATION\n // decision, so the continuation unit adopts it and its outcome attaches\n // here (the failed unit's own outcome attaches to its apply receipt).\n await this.#recordReceipt({\n sessionID: report.sessionID,\n tier: wrapped.tier,\n decision: wrapped,\n })\n // Continue the interrupted work on the escalated resource; the unit is\n // terminally failed, so an ops failure is only logged (never parked).\n try {\n await this.#ownRecovery(\n report.sessionID,\n wrapped.target,\n wrapped.tier,\n () => this.#modeFor(report.sessionID, settings) !== \"off\",\n )\n } catch (error) {\n if (!(error instanceof RecoveryAbortedError)) logFailOpen(\"escalation-ops\", error)\n }\n return\n }\n await this.#recordReceipt({\n sessionID: report.sessionID,\n tier: plan.kind === \"escalate\" ? plan.tier : admissionTier,\n decision: wrapped,\n })\n }\n\n async #onExecutionInterrupted(\n report: EventReport & { kind: \"execution-interrupted\" },\n ): Promise<void> {\n const reason = interruptReason(report.reason)\n if (reason === undefined) {\n logFailOpen(\n \"interrupt\",\n new Error(`unknown interruption reason: ${report.reason.slice(0, 32)}`),\n )\n return\n }\n const unit = this.#tracker.active(report.sessionID)\n const probeTicket = this.#takeProbeTicket(unit?.id)\n // An interruption while a recovery is pending on this session aborts it\n // at its post-settle guard (the pending recovery's decision predates the\n // interruption and must not act after it).\n if (this.#recoveryPending.has(report.sessionID)) {\n this.#recoveryInterrupted.add(report.sessionID)\n }\n const closed = this.#tracker.apply({\n kind: \"execution-interrupted\",\n sessionID: report.sessionID,\n at: report.at,\n reason,\n })\n this.#afterUnitClose(closed)\n // User and host interruptions never produce health evidence (the\n // classifier maps them outside the infrastructure vocabulary).\n if (unit !== undefined) {\n // An interrupted probe is no evidence about resource health: re-arm the\n // breaker's same window rather than doubling it.\n if (probeTicket !== undefined) {\n this.#reportProbeOutcome(probeTicket, { success: false, category: \"user_cancelled\" })\n }\n await this.#attachOutcome(unit, { status: \"interrupted\", reason })\n }\n }\n\n /**\n * One probe ticket's resolution at its episode's termination. A probe that\n * ends without a reported outcome (superseded, lost) would wedge the\n * resource in half_open, so the close cleanup reports those as\n * interruptions — re-arming the same backoff window, never doubling it.\n */\n #reportProbeOutcome(ticket: ProbeTicket, outcome: ProbeOutcome): void {\n // reportProbe is total and synchronous; validation failures (stale or\n // unknown ticket) are reported by its boolean return, not by throwing.\n this.#health.reportProbe(ticket, outcome)\n }\n\n /**\n * One attempt's failure evidence (http-response event or retry hook):\n * returns whether THIS observation is the attempt's first count.\n */\n #countAttemptFailure(\n unitID: string | undefined,\n source: \"http\" | \"retry\",\n category: FailureCategory,\n ): boolean {\n if (unitID === undefined) return true\n const ev = this.#attemptFailures.get(unitID) ?? {}\n if (source === \"http\" ? ev.retry === category : ev.http === category) {\n // The other host signal already counted this attempt: consume it.\n const closed = { ...ev, http: undefined, retry: undefined, closed: category }\n this.#attemptFailures.set(unitID, closed)\n return false\n }\n this.#attemptFailures.set(\n unitID,\n source === \"http\" ? { ...ev, http: category } : { ...ev, retry: category },\n )\n return true\n }\n\n /**\n * The terminal `execution-failed` repeats the episode's last attempt: it\n * counts only when the last attempt left no live evidence (e.g. a\n * capability failure that never produced an HTTP response or retry hook).\n */\n #countTerminalFailure(unitID: string | undefined, category: FailureCategory): boolean {\n if (unitID === undefined) return true\n const ev = this.#attemptFailures.get(unitID) ?? {}\n if (ev.http === category) {\n this.#attemptFailures.set(unitID, { ...ev, http: undefined })\n return false\n }\n if (ev.retry === category) {\n this.#attemptFailures.set(unitID, { ...ev, retry: undefined })\n return false\n }\n if (ev.closed === category) {\n this.#attemptFailures.set(unitID, { ...ev, closed: undefined })\n return false\n }\n this.#attemptFailures.set(unitID, { ...ev, closed: category })\n return true\n }\n\n /**\n * Hands a closing unit's probe ticket to its explicit outcome reporter.\n * Taken BEFORE the close: #afterUnitClose treats any ticket still held as\n * lost and re-opens the breaker, which would turn a probe's real outcome\n * into a stale report.\n */\n #takeProbeTicket(unitID: string | undefined): ProbeTicket | undefined {\n if (unitID === undefined) return undefined\n const ticket = this.#probeTickets.get(unitID)\n this.#probeTickets.delete(unitID)\n return ticket\n }\n\n /** Bounded per-unit bookkeeping once the tracker closed the unit. */\n #afterUnitClose(closed: ApplyResult): void {\n const unitID = closedUnitID(closed)\n if (unitID !== undefined) {\n this.#vetoes.delete(unitID)\n this.#admissionTiers.delete(unitID)\n this.#escalationEvidence.delete(unitID)\n const leftover = this.#probeTickets.get(unitID)\n if (leftover !== undefined) {\n // The explicit outcome reporters take their ticket before this\n // cleanup; reaching here means the unit ended without one\n // (superseded or lost).\n this.#reportProbeOutcome(leftover, { success: false, category: \"user_cancelled\" })\n this.#probeTickets.delete(unitID)\n }\n }\n if (closed.kind === \"opened\" || closed.kind === \"closed\") {\n const unitID = closedUnitID(closed)\n if (unitID !== undefined) {\n this.#attemptFailures.delete(unitID)\n }\n // Per-session flags for a unit that will never open again must not\n // leak: a stale continuation mark would swallow a real user prompt's\n // admission; a stale admission marker would skip routing. The guard\n // keeps the wipe out of an in-flight continuation's mark window (its\n // own close events are pumped concurrently with the mark).\n const sid = closed.unit.sessionID\n // A continuation tier intent pins the marker: the failed unit's close\n // event can arrive after the continuation's prompt hook set it, and\n // wiping then would re-route the continuation unit.\n if ((this.#continuationsInFlight.get(sid) ?? 0) === 0 && !this.#continuationTiers.has(sid)) {\n this.#continuationPending.delete(sid)\n this.#promptAdmission.delete(sid)\n }\n }\n }\n\n // ---------- http evidence ----------\n\n async #onHttpResponse(report: EventReport & { kind: \"http-response\" }): Promise<void> {\n if (report.capturedHeaders !== undefined) {\n this.#codex.observe(report.capturedHeaders, this.#options.clock())\n await this.#syncCapacityMirror()\n }\n if (report.status < 400) return\n const unit = this.#tracker.active(report.sessionID)\n const model = unit?.model ?? this.#tracker.lastModel(report.sessionID)?.model\n if (model === undefined) return\n const classification = classifyFailure({\n status: report.status,\n ...(report.retryAfterHeader !== undefined\n ? { headers: { \"retry-after\": report.retryAfterHeader } }\n : {}),\n })\n // The retry hook classifies the same request for the host's retry\n // decision; counting both would double every attempt (ADP-019).\n if (this.#countAttemptFailure(unit?.id, \"http\", classification.category)) {\n this.#observeHealth(failureEvent(refKey(model), classification))\n }\n }\n\n // ---------- retry hook ----------\n\n async #handleRetry(input: RetryHookInput, settings: SettingsV1): Promise<void> {\n const classification = classifyFailure({\n structured: {\n type: input.error.type,\n ...(input.error.retryAfterMs !== undefined\n ? { retryAfterMs: input.error.retryAfterMs }\n : {}),\n },\n status: input.error.status,\n // Text only refines a definitive 429's window (rate limit vs spent\n // quota); every other retry classification stays structural.\n ...(input.error.status === 429 ? { text: input.error.message } : {}),\n })\n const unitID = this.#tracker.active(input.sessionID)?.id\n // The pumped http-response event describes the same failed request;\n // counting both would double every attempt (ADP-019).\n if (this.#countAttemptFailure(unitID, \"retry\", classification.category)) {\n this.#observeHealth(failureEvent(refKey(input.model), classification))\n }\n\n // Recovery = fresh admission; the failed resource is already health-blocked.\n let recovery: RecoveryOption = { kind: \"none\" }\n let routingTier: TierName | undefined\n let probeTicket: ProbeTicket | undefined\n let admission: ReturnType<typeof admit> | undefined\n try {\n const {\n routing,\n decision,\n probeTicket: ticket,\n } = await this.#admit(settings, input.sessionID)\n routingTier = routing.kind === \"pin\" ? undefined : routing.tier\n if (decision.kind === \"apply\") {\n admission = decision\n recovery = {\n kind: \"switch\",\n model: decision.model,\n ...(decision.evidence.probeId !== undefined\n ? { probeId: decision.evidence.probeId }\n : {}),\n }\n probeTicket = ticket\n }\n } catch (error) {\n logFailOpen(\"recovery\", error)\n }\n\n const vetoesUsed = unitID !== undefined ? (this.#vetoes.get(unitID) ?? 0) : 0\n const core = decideRetry({\n classification,\n failingModel: input.model,\n native: input.decision,\n recovery,\n vetoesUsed,\n })\n const wrapped = retryForMode(core, this.#modeFor(input.sessionID, settings))\n if (wrapped.kind !== \"veto\") {\n // OBSERVE (and a declined veto) never runs the recovery episode, so an\n // admitted probe has no continuation to report it — release it here or\n // the resource wedges half-open.\n if (probeTicket !== undefined) {\n this.#health.releaseProbe(probeTicket)\n }\n return\n }\n input.decision = { retry: false }\n if (unitID !== undefined) {\n this.#vetoes.set(unitID, vetoesUsed + 1)\n }\n // A probe admitted by this recovery belongs to the continuation episode\n // that ownRecovery is about to start; its termination reports the probe.\n if (probeTicket !== undefined) {\n // The session holds one pending probe slot. A still-pending older\n // ticket belongs to a recovery whose continuation has not started (its\n // episode can no longer claim this slot) — release it before replacing.\n const stale = this.#sessionProbeTickets.get(input.sessionID)\n if (stale !== undefined && stale !== probeTicket) {\n this.#health.releaseProbe(stale)\n }\n this.#sessionProbeTickets.set(input.sessionID, probeTicket)\n }\n // The continuation episode is not re-admitted — its prompt hook is\n // consumed as an owned continuation — so the recovery admission is\n // recorded here, unit-less; the unit that opens next adopts this receipt\n // and carries the outcome.\n // A veto implies the admission was an apply: the recovery option exists\n // only when the fresh admission selected a resource, so the assertion\n // cannot be undefined on this path.\n await this.#recordReceipt({\n sessionID: input.sessionID,\n tier: routingTier,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- a veto implies the admission was an apply (the recovery exists only then)\n decision: admission!,\n })\n void this.#ownRecovery(\n input.sessionID,\n wrapped.model,\n routingTier,\n () => this.#modeFor(input.sessionID, settings) !== \"off\",\n )\n .then(() => undefined)\n .catch(async (error: unknown) => {\n if (error instanceof RecoveryAbortedError) {\n // The user steered away (interruption / OFF) during the settle: the\n // veto stands, but no continuation episode will ever carry the\n // probe it admitted — release it instead of wedging half-open.\n if (\n probeTicket !== undefined &&\n this.#sessionProbeTickets.get(input.sessionID) === probeTicket\n ) {\n this.#sessionProbeTickets.delete(input.sessionID)\n this.#health.releaseProbe(probeTicket)\n }\n return\n }\n logFailOpen(\"recovery-ops\", error)\n // The recovery rejected before (or while) delivering its continuation\n // prompt, so no unit will ever carry the probe it admitted — release\n // it instead of wedging the resource half-open.\n if (\n probeTicket !== undefined &&\n this.#sessionProbeTickets.get(input.sessionID) === probeTicket\n ) {\n this.#sessionProbeTickets.delete(input.sessionID)\n this.#health.releaseProbe(probeTicket)\n }\n if (unitID === undefined || routingTier === undefined) return\n try {\n await this.#parked.park({\n id: unitID,\n sessionID: input.sessionID,\n tier: routingTier,\n reason: \"all-blocked\",\n detail: \"continuation failed\",\n parkedAt: this.#options.clock(),\n })\n } catch (parkError) {\n logFailOpen(\"parked\", parkError)\n }\n })\n }\n\n /**\n * Owned horizontal recovery: settle → switch → continue from session\n * state. `tier` is the continuation unit's routing tier — recorded so the\n * continuation's prompt hook re-arms the admission marker (the unit must\n * not be re-routed: that would discard the recovery/escalation decision).\n */\n async #ownRecovery(\n sessionID: string,\n model: ModelRef,\n tier: TierName | undefined,\n stillValid: () => boolean,\n ): Promise<void> {\n if (tier !== undefined) this.#continuationTiers.set(sessionID, tier)\n // The guard window opens before the first await so an interrupt pumped\n // during the admission race is still seen.\n this.#recoveryPending.add(sessionID)\n try {\n const alive = await this.#isSessionAlive(sessionID)\n const recovery: RecoveryOption = { kind: \"switch\", model }\n const action = planContinuation({\n recovery,\n continuationPossible: alive,\n })\n // executeContinuation settles first; the supervisor settles here so the\n // post-settle guard (mode OFF, user interruption) can abort before any\n // switch or prompt — the settle is the only step that can take\n // unbounded time, and a decision made before it may be stale after it.\n await this.#ops.settle(sessionID)\n if (!stillValid() || this.#recoveryInterrupted.delete(sessionID)) {\n throw new RecoveryAbortedError(sessionID)\n }\n // Already settled above; the action's own settle is a no-op.\n await executeContinuation({\n sessionID,\n action,\n ops: { ...this.#ops, settle: () => Promise.resolve() },\n })\n } catch (error) {\n // The continuation prompt never reached the host, so no unit will open\n // to consume the tier intent — drop it or it would pin the marker\n // wipes and mislabel a later user prompt's admission.\n if (tier !== undefined) this.#continuationTiers.delete(sessionID)\n throw error\n } finally {\n this.#recoveryPending.delete(sessionID)\n }\n }\n\n // ---------- parked-work resume (safe boundary: idle) ----------\n\n async #onIdle(settings: SettingsV1): Promise<void> {\n const records = this.#parked.list()\n // Override holders join the alive sweep: a dead session's override is\n // pruned here (its per-session steering is worthless once the session is\n // gone), in the same sweep that clears the other per-session maps.\n const overrideIDs = this.#sessionModes.snapshot().map((record) => record.sessionID)\n const tierRequestIDs = this.#tierRequests.snapshot().map((record) => record.sessionID)\n if (records.length === 0 && overrideIDs.length === 0 && tierRequestIDs.length === 0) return\n // OFF sessions are not supervised: their parked records are neither\n // dropped nor resumed, and no alive probe runs for them.\n const supervised = new Set(\n records\n .map((record) => record.sessionID)\n .filter((sessionID) => this.#modeFor(sessionID, settings) !== \"off\"),\n )\n const alive = new Map<string, boolean>()\n for (const sessionID of new Set([...supervised, ...overrideIDs])) {\n alive.set(sessionID, await this.#isSessionAlive(sessionID))\n }\n // Tier-request holders join the alive sweep too: a dead session's sticky\n // tier request dies with its session, like the other per-session maps.\n for (const sessionID of tierRequestIDs) {\n if (!alive.has(sessionID)) alive.set(sessionID, await this.#isSessionAlive(sessionID))\n }\n const plan = selectResumable(records, {\n tierConfigured: (tier) => configuredTiers(settings).includes(tier),\n sessionAlive: (sessionID) => alive.get(sessionID) === true,\n })\n for (const dropped of plan.drop) {\n if (this.#modeFor(dropped.sessionID, settings) === \"off\") continue\n await this.#dropParked(dropped)\n }\n // Tier requests die with their session, like the other per-session maps.\n // The fire-and-forget note means the queue may still hold writes; the\n // serialized set applies after them. A write failure just leaves the\n // record (fail-open — it will die with the session on the next sweep).\n for (const sessionID of tierRequestIDs) {\n if (alive.get(sessionID) === false) {\n try {\n await this.#tierRequests.set(sessionID, null)\n } catch (error) {\n logFailOpen(\"tier-requests\", error)\n }\n }\n }\n // At most ONE continuation per session per sweep: prompting a session\n // with an active unit would supersede the user's in-flight episode (not\n // a safe boundary), and several back-to-back continuation prompts could\n // redo work an earlier one already completed (ADP-023).\n const attempted = new Set<string>()\n for (const record of plan.attempt) {\n if (this.#modeFor(record.sessionID, settings) === \"off\") continue\n if (this.#tracker.active(record.sessionID) !== undefined) continue\n if (attempted.has(record.sessionID)) continue\n attempted.add(record.sessionID)\n await this.#resumeAttempt(record, settings)\n }\n for (const [sessionID, isAlive] of alive) {\n if (!isAlive) {\n this.#continuationTiers.delete(sessionID)\n this.#promptAdmission.delete(sessionID)\n this.#continuationPending.delete(sessionID)\n this.#escalations.delete(sessionID)\n this.#quotaRecoveriesRemaining.delete(sessionID)\n if (this.#sessionModes.get(sessionID) !== null) {\n try {\n await this.#sessionModes.set(sessionID, null)\n } catch (error) {\n logFailOpen(\"session-modes\", error)\n }\n }\n }\n }\n }\n\n async #dropParked(record: ParkedRecord): Promise<void> {\n try {\n await this.#parked.resume(record.id)\n } catch (error) {\n logFailOpen(\"parked\", error)\n }\n }\n\n /** One parked record's fresh routing attempt at the idle boundary. */\n async #resumeAttempt(record: ParkedRecord, settings: SettingsV1): Promise<void> {\n // The parked session resumes under ITS effective mode, not the idle\n // report's session's mode.\n const mode = this.#modeFor(record.sessionID, settings)\n let decision: ReturnType<typeof admit>\n let probeTicket: ProbeTicket | undefined\n try {\n const admission = await this.#admit(settings, record.sessionID, record.tier)\n decision = admission.decision\n probeTicket = admission.probeTicket\n } catch (error) {\n logFailOpen(\"resume\", error)\n return\n }\n if (mode === \"observe\") {\n if (probeTicket !== undefined) this.#health.releaseProbe(probeTicket)\n await this.#recordReceipt({\n sessionID: record.sessionID,\n unitID: record.id,\n tier: record.tier,\n decision: { kind: \"observe-only\", would: decision },\n })\n return\n }\n if (decision.kind !== \"apply\") {\n // Still no usable resource (or the routing deferred) — stay parked. The\n // admission held no probe ticket: #admit keeps a ticket only for apply\n // decisions and releases every other one itself.\n await this.#recordReceipt({\n sessionID: record.sessionID,\n unitID: record.id,\n tier: record.tier,\n decision,\n })\n return\n }\n const popped = await this.#popParked(record)\n if (popped === undefined) {\n if (probeTicket !== undefined) this.#health.releaseProbe(probeTicket)\n return\n }\n // The resume continuation is not re-admitted (owned continuation), so\n // the freshly routed admission is recorded here, unit-less; the unit\n // that opens next adopts it and carries the outcome.\n await this.#recordReceipt({\n sessionID: record.sessionID,\n tier: record.tier,\n decision,\n })\n // The resume continuation is an owned recovery: settle first, apply the\n // freshly routed model, then prompt — the episode's first LLM call must\n // not hit the model the work was parked away from.\n try {\n if (probeTicket !== undefined) this.#sessionProbeTickets.set(record.sessionID, probeTicket)\n await this.#ownRecovery(\n record.sessionID,\n decision.model,\n record.tier,\n // The parked session's own effective mode and its still-open unit\n // window are re-checked after the settle; a session that gained an\n // active unit must not be prompted (not a safe boundary).\n () =>\n this.#modeFor(record.sessionID, settings) !== \"off\" &&\n this.#tracker.active(record.sessionID) === undefined,\n )\n } catch (error) {\n if (\n probeTicket !== undefined &&\n this.#sessionProbeTickets.get(record.sessionID) === probeTicket\n ) {\n this.#sessionProbeTickets.delete(record.sessionID)\n this.#health.releaseProbe(probeTicket)\n }\n if (!(error instanceof RecoveryAbortedError)) logFailOpen(\"resume\", error)\n await this.#rePark(record)\n }\n }\n\n async #popParked(record: ParkedRecord): Promise<ParkedRecord | undefined> {\n try {\n return await this.#parked.resume(record.id)\n } catch (error) {\n logFailOpen(\"parked\", error)\n return undefined\n }\n }\n\n async #rePark(record: ParkedRecord): Promise<void> {\n try {\n await this.#parked.park({\n ...record,\n attempts: (record.attempts ?? 0) + 1,\n parkedAt: this.#options.clock(),\n })\n } catch (error) {\n logFailOpen(\"parked\", error)\n }\n }\n\n // ---------- shared helpers ----------\n\n async #isSessionAlive(sessionID: string): Promise<boolean> {\n try {\n await this.#options.session.get({ sessionID })\n return true\n } catch (error) {\n // The host rejects `session.get` for a missing session with a plain\n // error and exposes no typed status; only a definitive not-found\n // counts as dead. Anything else is treated as alive (fail open toward\n // keeping durable user state, ADP-031): a transient storage or host\n // error must never prune parked work, mode overrides, or tier\n // requests — the next sweep re-probes instead.\n return !/not found/i.test(String(error))\n }\n }\n\n async #recordReceipt(input: Omit<ReceiptInput, \"at\">): Promise<void> {\n try {\n await this.#receipts.record({ at: this.#options.clock(), ...input })\n } catch (error) {\n logFailOpen(\"receipts\", error)\n }\n }\n\n async #attachOutcome(unit: ActiveUnit, outcome: ReceiptOutcome): Promise<void> {\n try {\n await this.#receipts.attachOutcome({ sessionID: unit.sessionID, unitID: unit.id }, outcome)\n } catch (error) {\n logFailOpen(\"receipts\", error)\n }\n }\n\n #observeHealth(event: HealthEvent): void {\n this.#health.observe(event)\n // Persist the record mirror fire-and-forget: the status surface reads\n // persisted records so a serving instance without the event-pump hooks\n // still reports true health. Failures are fail-open (ADP-031).\n const records: readonly ResourceRecord[] = this.#health.snapshot()\n void this.#healthRecords.replace(records).catch((error: unknown) => {\n logFailOpen(\"health\", error)\n })\n }\n\n /**\n * Persist the capacity mirror after a passive observation (same instance\n * split rationale as the health mirror): the status surface reads persisted\n * readings so a serving instance without the event-pump hooks still reports\n * sensed capacity. Failures are fail-open (ADP-031).\n */\n async #syncCapacityMirror(): Promise<void> {\n try {\n await this.#capacity.refresh()\n const entries: PersistedCapacityReading[] = []\n for (const sensor of this.#capacity.snapshot()) {\n if (sensor.latest !== null) {\n entries.push({ key: sensor.resource, reading: sensor.latest })\n }\n }\n await this.#capacityStore.replace(entries)\n } catch (error) {\n logFailOpen(\"capacity\", error)\n }\n }\n}\n\n/** A pin is not a tier — receipts only carry a tier for tiered routing. */\nfunction routingTier(routing: RoutingDecision): TierName | undefined {\n return routing.kind === \"pin\" ? undefined : routing.tier\n}\n\n/** The unit a tracker result closed or superseded, if any. */\nfunction closedUnitID(result: ApplyResult): string | undefined {\n switch (result.kind) {\n case \"closed\":\n return result.unit.id\n case \"opened\":\n return result.superseded?.id\n default:\n return undefined\n }\n}\n\n/** ModelRef for a normalized candidate. */\nfunction candidateRef(candidate: {\n providerID: string\n modelID: string\n variant?: string | undefined\n}): ModelRef {\n return {\n providerID: candidate.providerID,\n id: candidate.modelID,\n ...(candidate.variant !== undefined ? { variant: candidate.variant } : {}),\n }\n}\n\n/** ResourceKey for a model ref (no account level is observable in v1). */\nfunction refKey(ref: ModelRef): ResourceKey {\n // The host reports base-model calls with variant \"default\" (verified on\n // 2.2.5), while the inventory enumerates the bare model plus its named\n // variants. Taken literally, a \"default\" key would orphan every\n // unvarianted failure record on a key no admission ever assesses — health\n // and breaker state would be invisible to routing.\n const variant = ref.variant === \"default\" ? undefined : ref.variant\n return {\n providerID: ref.providerID,\n modelID: ref.id,\n ...(variant !== undefined ? { variantID: variant } : {}),\n }\n}\n\n/** Quota survives variantless host resolution; only shared-limit evidence blocks siblings. */\nfunction failureKey(key: ResourceKey, classification: FailureClassification): ResourceKey {\n if (classification.quotaScope === \"provider\") {\n // Host model refs expose the configured provider, not a credential/account id.\n return { providerID: key.providerID }\n }\n if (classification.category === \"quota_exhausted\" && key.variantID !== undefined) {\n return { providerID: key.providerID, modelID: key.modelID }\n }\n return key\n}\n\n/** Health failure event from a classification (bounded structured evidence). */\nfunction failureEvent(key: ResourceKey, classification: FailureClassification): HealthEvent {\n return {\n kind: \"failure\",\n key: failureKey(key, classification),\n category: classification.category,\n definitive: classification.definitive,\n ...(classification.retry.retryAfterMs !== undefined\n ? { retryAfterMs: classification.retry.retryAfterMs }\n : {}),\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"supervisor.js","sourceRoot":"","sources":["../../src/supervisor/supervisor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EACL,YAAY,GAIb,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAA;AAErE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAEnE,OAAO,EACL,KAAK,EACL,OAAO,IAAI,gBAAgB,EAC3B,cAAc,EACd,kBAAkB,GACnB,MAAM,4BAA4B,CAAA;AAOnC,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAClE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAA;AAEtE,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAA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SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAA;IACnE,OAAO;QACL,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,OAAO,EAAE,GAAG,CAAC,EAAE;QACf,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzD,CAAA;AACH,CAAC;AAED,8FAA8F;AAC9F,SAAS,UAAU,CAAC,GAAgB,EAAE,cAAqC;IACzE,IAAI,cAAc,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;QAC7C,+EAA+E;QAC/E,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,CAAA;IACvC,CAAC;IACD,IAAI,cAAc,CAAC,QAAQ,KAAK,iBAAiB,IAAI,GAAG,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;QACjF,OAAO,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,CAAA;IAC7D,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,gFAAgF;AAChF,SAAS,YAAY,CAAC,GAAgB,EAAE,cAAqC;IAC3E,OAAO;QACL,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,UAAU,CAAC,GAAG,EAAE,cAAc,CAAC;QACpC,QAAQ,EAAE,cAAc,CAAC,QAAQ;QACjC,UAAU,EAAE,cAAc,CAAC,UAAU;QACrC,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,YAAY,KAAK,SAAS;YACjD,CAAC,CAAC,EAAE,YAAY,EAAE,cAAc,CAAC,KAAK,CAAC,YAAY,EAAE;YACrD,CAAC,CAAC,EAAE,CAAC;KACR,CAAA;AACH,CAAC","sourcesContent":["/**\n * The supervisor (ADP-025..ADP-032): owns all state stores and glues the pure\n * core to the host reports. It contains no policy of its own — every decision\n * comes from the pure scheduler/retry/tier modules — and it applies the two\n * wiring contracts: fail-open (ADP-031, internal failures log and defer) and\n * Observe ≡ Control (the same admission path, only the mode wrapper differs).\n *\n * Wiring decisions recorded here (see docs/ARCHITECTURE.md):\n * - admission runs only on `execution-started` (a safe boundary); auxiliary\n * per-request routing is not applied in v1 because switching the model for\n * an auxiliary request would also move the primary model.\n * - park records arise only from owned-recovery failures and resume\n * boundaries; admission cannot hold an already-started episode, so an\n * admission `park` decision is recorded as a receipt without a parked\n * record (the episode proceeds on OpenCode's own model).\n * - retry-hook veto decisions are not receipts (they are not scheduler\n * decisions); admission receipts plus outcome attachment cover ADP-030.\n * - interruption reasons outside the known vocabulary leave the unit open\n * (a later episode supersedes it); no outcome is ever fabricated.\n * - escalation (ADP-015..017) triggers only on capability-classified unit\n * failures (context overflow, content policy); infrastructure failures\n * never escalate, and the per-task budget is finite.\n */\nimport { WorkUnitTracker } from \"../core/work-unit/tracker.js\"\nimport {\n sameModelRef,\n type ActiveUnit,\n type ApplyResult,\n type ModelRef,\n} from \"../core/work-unit/types.js\"\nimport { INTERRUPT_REASONS } from \"../core/work-unit/interruption.js\"\nimport type { InterruptReason } from \"../core/work-unit/interruption.js\"\nimport { resolveRouting } from \"../core/tier-policy/resolve.js\"\nimport { isTierName, nextTier } from \"../core/tier-policy/types.js\"\nimport type { RoutingDecision, TierName, TierRequest } from \"../core/tier-policy/types.js\"\nimport {\n admit,\n forMode as schedulerForMode,\n planEscalation,\n schedulerHealthKey,\n} from \"../core/scheduler/index.js\"\nimport type {\n ApplyDecision,\n EscalationEvidence,\n OperatingMode,\n SchedulerInput,\n} from \"../core/scheduler/types.js\"\nimport { MAX_ESCALATION_EVIDENCE } from \"../core/scheduler/types.js\"\nimport type { CandidateModel, Demand } from \"../core/compatibility/types.js\"\nimport { checkCompatibility } from \"../core/compatibility/gate.js\"\nimport { classifyFailure, CapacityRegistry, ResourceHealthRegistry } from \"../health/index.js\"\nimport { sweepRecord } from \"../health/resource-health/transitions.js\"\nimport type { ResourceRecord } from \"../health/resource-health/types.js\"\nimport { HealthRecordStore, HEALTH_KEY } from \"../state/health/index.js\"\nimport { CapacityReadingStore, CAPACITY_KEY } from \"../state/capacity/index.js\"\nimport type { PersistedCapacityReading } from \"../state/capacity/index.js\"\nimport { mergeReadings } from \"../health/capacity/merge.js\"\nimport { resourceChain, resourceKeyID } from \"../health/resource-health/key.js\"\nimport type {\n Assessment,\n CapacityReading,\n CapacitySignals,\n FailureCategory,\n FailureClassification,\n HealthEvent,\n ProbeOutcome,\n ProbeTicket,\n ResourceKey,\n} from \"../health/index.js\"\nimport { SettingsStore, SETTINGS_KEY } from \"../state/settings/index.js\"\nimport type { SettingsV1 } from \"../state/settings/index.js\"\nimport type { PatchResult, SettingsPatch } from \"../state/settings/types.js\"\nimport { SessionModeStore, SESSION_MODES_KEY } from \"../state/session-modes/index.js\"\nimport { TierRequestStore, TIER_REQUESTS_KEY } from \"../state/tier-requests/index.js\"\nimport { ReceiptStore, RECEIPTS_KEY } from \"../state/receipts/index.js\"\nimport type { Receipt, ReceiptInput, ReceiptOutcome } from \"../state/receipts/types.js\"\nimport { buildStatus } from \"../rpc/status.js\"\nimport type { StatusSnapshot } from \"../rpc/status.js\"\nimport { RECEIPTS_VIEW_LIMIT } from \"./view.js\"\nimport { ParkedWorkStore, PARKED_KEY } from \"../state/parked-work/index.js\"\nimport type { ParkedRecord } from \"../state/parked-work/types.js\"\nimport {\n decideRetry,\n earliestUsable,\n executeContinuation,\n forMode as retryForMode,\n MAX_PARKED_ATTEMPTS,\n planContinuation,\n planWake,\n resourceUsableAt,\n selectResumable,\n} from \"../execution/index.js\"\nimport { escalationDetail } from \"../execution/escalation/index.js\"\nimport type { RecoveryOption } from \"../execution/index.js\"\nimport { listCandidates, sessionOps, storageSeam } from \"../adapters/opencode/index.js\"\nimport type { EventReport } from \"../adapters/opencode/index.js\"\nimport { CodexCapacitySensor } from \"../adapters/codex-capacity/index.js\"\nimport { logFailOpen } from \"./log.js\"\nimport type { RetryHookInput, SupervisorOptions } from \"./types.js\"\nimport { CODEX_PROVIDER_ID } from \"./types.js\"\n\nimport { TIERS } from \"../core/tier-policy/types.js\"\n\n/** Which tiers currently have configured resources (ADP-005). */\nfunction configuredTiers(settings: SettingsV1): TierName[] {\n return TIERS.filter((tier) => settings.tiers[tier].length > 0)\n}\n\n/** Narrow a wire interrupt reason to the known vocabulary. */\nfunction interruptReason(reason: string): InterruptReason | undefined {\n return (INTERRUPT_REASONS as readonly string[]).includes(reason)\n ? (reason as InterruptReason)\n : undefined\n}\n\n/**\n * Failure categories that count as structured capability evidence (ADP-015).\n * The remaining evidence kinds (agent request, reviewer rejection) have no\n * structured host source in v2 and are never inferred from free text.\n */\nconst CAPABILITY_EVIDENCE_CATEGORIES: readonly FailureCategory[] = [\n \"context_overflow\",\n \"content_policy\",\n]\n\n/** Finite per-task escalation budget (ADP-017). */\nconst MAX_ESCALATIONS_PER_TASK = 2\n\n/**\n * The recovery's post-settle guard aborted it (the session went OFF or the\n * user interrupted while the host settle was in flight). Callers use it to\n * skip the ordinary ops-failure degradation (parking) — an aborted recovery\n * is a steering change, not an infrastructure failure.\n */\nexport class RecoveryAbortedError extends Error {\n constructor(sessionID: string) {\n super(`recovery aborted for session ${sessionID}`)\n this.name = \"RecoveryAbortedError\"\n }\n}\n\nexport class Supervisor {\n readonly #options: SupervisorOptions\n readonly #settings: SettingsStore\n readonly #receipts: ReceiptStore\n readonly #parked: ParkedWorkStore\n readonly #tracker = new WorkUnitTracker()\n readonly #health: ResourceHealthRegistry\n readonly #healthRecords: HealthRecordStore\n readonly #capacityStore: CapacityReadingStore\n readonly #sessionModes: SessionModeStore\n readonly #capacity: CapacityRegistry\n readonly #codex: CodexCapacitySensor\n readonly #vetoes = new Map<string, number>()\n /**\n * Escalations spent per session on the current task (one user prompt and\n * the owned continuations it spawns). Keyed by session, not unit: every\n * escalation continues on a NEW unit, so a per-unit count would restart\n * the budget at each step. A fresh user prompt starts a new task.\n */\n readonly #escalations = new Map<string, number>()\n readonly #admissionTiers = new Map<string, TierName>()\n /** Recorded escalation-tool requests per unit (ADP-015 agent self-reports). */\n readonly #escalationEvidence = new Map<string, EscalationEvidence[]>()\n /** Last agent observed per session (role-hint routing evidence, ADP-002). */\n // Bounded like every other per-session map: long-lived hosts meet many\n // short-lived subagent sessions, and agent hints for long-gone sessions\n // are worthless. Insertion order gives the eviction (oldest hint first).\n static readonly MAX_AGENT_HINTS = 1024\n readonly #agents = new Map<string, string>()\n /**\n * Per-session tier requests (agent-declared via the adaptive_tier tool):\n * the request is STICKY — it steers the session's next and following\n * admissions until cleared or the session dies — because an agent works\n * across many units in one task. Persisted like the session-mode\n * overrides: the host's double plugin instance (hooks vs RPC) must not\n * strand a request on the instance that never routes.\n */\n readonly #tierRequests: TierRequestStore\n /**\n * Sessions whose last model change was the user's own pick\n * (`selected-external`): prompt admission does not re-route them —\n * switching would undo the user's `/model` choice (ADP-028). Cleared by an\n * adaptive switch, a tier request, or a mode change; a standing settings\n * pin overrides the suppression (the pin is manual intent too).\n */\n static readonly MAX_MANUAL_SELECTIONS = 1024\n readonly #manualSelections = new Map<string, true>()\n /**\n * Sessions with an owned continuation prompt in flight: the prompt hook\n * will fire for it, but that prompt belongs to the active unit — it must\n * not re-admit (prevents an admission ping-pong).\n */\n readonly #continuationPending = new Set<string>()\n /**\n * Depth of continuation prompts whose prompt hook has not run yet (or whose\n * host call is still in flight). While a session is inside this window, a\n * unit close must not clear the ownership mark: the close event of the\n * failed unit is pumped concurrently with the continuation's own\n * beforePrompt → prompt-hook sequence, and clearing the mark there would\n * make the continuation re-admit (admission ping-pong).\n */\n readonly #continuationsInFlight = new Map<string, number>()\n /**\n * Sessions with an owned recovery in flight (between veto/resume and the\n * delivered continuation prompt). The host settle inside it can take\n * unbounded time; an interruption arriving during that window must abort\n * the stale decision instead of acting after it. The value settles when\n * the recovery does (it never rejects).\n */\n readonly #recoveryPending = new Map<string, Promise<void>>()\n /**\n * Units opened by an owned continuation's prompt. Such a unit can fail\n * before the recovery that started it returns from its prompt call; its\n * terminal failure is its own, not an echo of the superseded unit.\n * Cleared at unit close.\n */\n readonly #continuationUnits = new Set<string>()\n /** Snapshot-sized budget shared by a task's terminal quota continuations. */\n readonly #quotaRecoveriesRemaining = new Map<string, number>()\n /** Interruptions observed while a recovery was pending on the session. */\n readonly #recoveryInterrupted = new Set<string>()\n /**\n * Half-open probe tickets by session: a probe admitted while computing the\n * recovery for a veto belongs to the continuation episode that follows, so\n * the ticket is parked here until that unit opens and takes it.\n */\n readonly #sessionProbeTickets = new Map<string, ProbeTicket>()\n /**\n * Half-open probe tickets by unit: the unit admitted as (or carrying) the\n * breaker's single probe. Its termination reports the probe outcome — a\n * success closes the breaker, a failure reopens it, an interruption re-arms\n * it — otherwise a lost probe would wedge the resource in half_open.\n */\n readonly #probeTickets = new Map<string, ProbeTicket>()\n /**\n * Per-unit dedup for breaker failure evidence (ADP-019). One failed attempt\n * surfaces through up to three host signals — the pumped `http.response`\n * event, the `retry` hook (the same request), and the terminal\n * `execution-failed` (the last attempt) — and counting each would trip the\n * breaker after ~2 real failures instead of `failureThreshold`. The exact\n * arrival order of a pair is not guaranteed (the retry hook runs in the\n * request lifecycle, the event pump lags), so the dedup is order-symmetric:\n * the first signal of a pair counts and arms, the matching counterpart\n * consumes it, a completed pair closes the attempt, and the terminal\n * repeats only when the last attempt left no live evidence. A same-category\n * observation with nothing armed is a NEW attempt (consecutive http-only\n * failures each count). Cleared at unit close.\n */\n readonly #attemptFailures = new Map<\n string,\n {\n http?: FailureCategory | undefined\n retry?: FailureCategory | undefined\n closed?: FailureCategory | undefined\n }\n >()\n /**\n * Session → tier admitted by the prompt hook for the unit that is about to\n * open. Consumed by execution-started, which then skips re-routing (the\n * model is already applied to the very turn that triggered admission).\n */\n readonly #promptAdmission = new Map<string, { tier?: TierName; continuation?: true }>()\n /**\n * Tier intent for an owned continuation (retry recovery, escalation,\n * parked resume) set before its prompt is delivered. The continuation's\n * prompt hook re-arms the prompt-admission marker from this so the\n * continuation's execution-started skips re-routing — a fresh admission\n * would flip an escalated episode back to the preferred model mid-unit\n * (a switch only lands on the next turn). Cleared when the continuation\n * unit opens, its prompt is rejected, or the session dies.\n */\n readonly #continuationTiers = new Map<string, TierName>()\n /**\n * Parked-work wake (ADP-024): idle only follows successful work, so when a\n * whole tier is blocked one timer stands in for the safe boundary at the\n * earliest moment a candidate resource recovers. `dueAt` may lie past the\n * timer when the delay was capped — an early fire only re-arms.\n */\n #wake: { readonly cancel: () => void; readonly dueAt: number } | undefined\n /** Consecutive wake sweeps that resumed nothing (backs the timer off). */\n #fruitless = 0\n #disposed = false\n /**\n * Whether this instance receives host reports. The host's other plugin\n * instance (ADP-056) never does: its in-memory health is only what it\n * hydrated, so it re-reads persisted health before a wake sweep.\n */\n #live = false\n /**\n * Session → resume cycles spent on its current task: a resumed unit that\n * parks again carries the count, so park → wake → fail loops stay bounded\n * by MAX_PARKED_ATTEMPTS. Cleared on success or a fresh user prompt.\n */\n readonly #resumeCycles = new Map<string, number>()\n readonly #ready: Promise<SettingsV1>\n readonly #ops: ReturnType<typeof sessionOps>\n\n constructor(options: SupervisorOptions) {\n this.#options = options\n this.#health = new ResourceHealthRegistry(options.clock)\n this.#capacity = new CapacityRegistry(options.clock)\n this.#codex = new CodexCapacitySensor({ providerID: CODEX_PROVIDER_ID })\n this.#capacity.register(this.#codex)\n this.#settings = new SettingsStore(storageSeam(SETTINGS_KEY, options.storage))\n this.#receipts = new ReceiptStore(storageSeam(RECEIPTS_KEY, options.storage))\n this.#parked = new ParkedWorkStore(storageSeam(PARKED_KEY, options.storage))\n this.#healthRecords = new HealthRecordStore(storageSeam(HEALTH_KEY, options.storage))\n this.#capacityStore = new CapacityReadingStore(storageSeam(CAPACITY_KEY, options.storage))\n this.#sessionModes = new SessionModeStore(\n storageSeam(SESSION_MODES_KEY, options.storage),\n options.clock,\n )\n this.#tierRequests = new TierRequestStore(\n storageSeam(TIER_REQUESTS_KEY, options.storage),\n options.clock,\n )\n this.#ops = sessionOps(options.session, {\n beforeSwitch: (sessionID, model) => {\n this.#tracker.noteOwnSwitch(sessionID, model)\n options.ledger.noteSwitch(sessionID, model, options.clock())\n },\n switchFailed: (sessionID) => {\n options.ledger.withdrawSwitch(sessionID)\n },\n beforePrompt: (sessionID) => {\n // The other plugin instance may be the one that hears this prompt:\n // the ledger lets it recognize the continuation as Adaptive's.\n const tier = this.#continuationTiers.get(sessionID)\n const cycles = this.#resumeCycles.get(sessionID)\n options.ledger.noteContinuation(\n sessionID,\n { ...(tier === undefined ? {} : { tier }), ...(cycles === undefined ? {} : { cycles }) },\n options.clock(),\n )\n this.#continuationPending.add(sessionID)\n this.#continuationsInFlight.set(\n sessionID,\n (this.#continuationsInFlight.get(sessionID) ?? 0) + 1,\n )\n },\n afterPrompt: (sessionID, delivered) => {\n // sessionOps.prompt calls this only after its own beforePrompt, so\n // the entry is always present; the assertion avoids a default branch\n // no caller can reach.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const depth = this.#continuationsInFlight.get(sessionID)!\n if (depth <= 1) {\n this.#continuationsInFlight.delete(sessionID)\n if (!delivered) {\n // The last in-flight owned prompt never reached the host's hook:\n // its ownership mark would swallow the next user prompt's\n // admission, so it is dropped here (the hook can no longer fire).\n // The continuation's tier intent dies with it — no episode will\n // open to carry it. The other instance's view of it goes too.\n this.#continuationPending.delete(sessionID)\n this.#continuationTiers.delete(sessionID)\n options.ledger.withdrawContinuation(sessionID)\n }\n } else {\n this.#continuationsInFlight.set(sessionID, depth - 1)\n }\n },\n })\n // Durable state loads before the first report is handled: a later load\n // must never clobber decisions recorded in the meantime.\n const loadState = async (): Promise<SettingsV1> => {\n await this.#receipts.load()\n await this.#parked.load()\n // Unit ids are durable keys (`${sessionID}#${episode}`) persisted in\n // receipts and parked work. Seed the tracker's per-session episode\n // counters above every persisted id: after a restart the counters\n // must never re-mint a colliding id, which would replace a parked\n // record (the store parks one record per id) and misattribute\n // receipt outcomes.\n const floors = new Map<string, number>()\n const bump = (unitID: string | undefined): void => {\n if (unitID === undefined) return\n const cut = unitID.lastIndexOf(\"#\")\n if (cut <= 0) return\n const sessionID = unitID.slice(0, cut)\n const episode = Number(unitID.slice(cut + 1))\n if (!Number.isInteger(episode) || episode <= 0) return\n if (episode > (floors.get(sessionID) ?? 0)) floors.set(sessionID, episode)\n }\n for (const receipt of this.#receipts.snapshot()) bump(receipt.unitID)\n for (const record of this.#parked.list()) {\n bump(record.id)\n options.ledger.noteParked(record.sessionID)\n }\n this.#tracker.seedEpisodes(floors)\n // Health records hydrate the registry: the host's TUI-mode plugin\n // reconciliation can serve RPC from an instance whose hooks (event\n // pump) live on another instance — persisted failures are the only\n // health that instance can see, and a fresh instance must also assess\n // persisted failures before routing instead of starting from empty.\n await this.#healthRecords.load()\n this.#health.hydrate(this.#healthRecords.snapshot())\n // Session-mode overrides hydrate the same way: a restart (or the\n // host's double-instance reconciliation) must keep steering sessions\n // under the modes the user set for them.\n await this.#sessionModes.load()\n // Tier requests hydrate the same way: a tier request recorded through\n // the host's other plugin instance (or before a restart) must still\n // steer this instance's admissions.\n await this.#tierRequests.load()\n await this.#capacityStore.load()\n return this.#settings.load()\n }\n this.#ready = loadState()\n // Parked work survives restarts; its wake must too.\n void this.#armWake()\n }\n\n /** Stop the wake timer; a disposed supervisor never re-arms it. */\n dispose(): void {\n this.#disposed = true\n this.#options.ledger.leave()\n this.#wake?.cancel()\n this.#wake = undefined\n }\n\n /**\n * This instance hears the host. The ledger ignores it from a disposed\n * instance (a late report during teardown), so the survivor still sweeps.\n */\n #markLive(): void {\n this.#live = true\n this.#options.ledger.markLive()\n }\n\n /** Settings as of the latest load/patch (awaits the constructor load). */\n async #ensureSettings(): Promise<SettingsV1> {\n await this.#ready\n return this.#settings.get()\n }\n\n /**\n * The session's effective operating mode (ADP-054): its per-session\n * override when one is set, else the global mode. Every session-scoped\n * supervision decision consults this instead of `settings.mode` directly.\n */\n #modeFor(sessionID: string, settings: SettingsV1): OperatingMode {\n return this.#sessionModes.get(sessionID) ?? settings.mode\n }\n\n // ---------- public entry points (never throw — fail-open, ADP-031) ----------\n\n /** Handle one host report (event pump or session hook). */\n async handleReport(report: EventReport): Promise<void> {\n this.#markLive()\n try {\n const settings = await this.#ensureSettings()\n // An OFF session is fully inert — no supervision, no receipts, no\n // health evidence. Idle is the exception: it is the bookkeeping\n // boundary (parked-work sweep, dead-session override pruning) and runs\n // for every report so other sessions' overrides are maintained; the\n // sweep itself gates per parked session below. A prompt still marks\n // the user taking the session over (its parked work is dropped).\n if (\n report.kind !== \"idle\" &&\n report.kind !== \"prompt\" &&\n this.#modeFor(report.sessionID, settings) === \"off\"\n )\n return\n await this.#dispatch(report, settings)\n } catch (error) {\n logFailOpen(\"report\", error)\n }\n }\n\n /** Marks the session's manual-selection state from an external selection event. */\n #noteManualSelection(sessionID: string): void {\n if (\n !this.#manualSelections.has(sessionID) &&\n this.#manualSelections.size >= Supervisor.MAX_MANUAL_SELECTIONS\n ) {\n // The guard above ensures the map is at its cap (>= 1 entries), so the\n // first key always exists; the assertion avoids a branch the coverage\n // gate would reject as unreachable.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const oldest = this.#manualSelections.keys().next().value!\n this.#manualSelections.delete(oldest)\n }\n this.#manualSelections.set(sessionID, true)\n }\n\n /**\n * True while the session's last model change was the user's own pick.\n * A standing settings pin is explicit manual intent as well (ADP-002):\n * honoring it does not fight the pick, so suppression is skipped there.\n */\n #manuallySelected(sessionID: string, settings: SettingsV1): boolean {\n return settings.pin === null && this.#manualSelections.has(sessionID)\n }\n\n /**\n * The manual-pick suppression actually applied at an admission. It yields\n * when the picked model is health-blocked: keeping the session on a\n * quarantined resource does not honor the pick — the configured fallback\n * takes over instead (the pick is re-honored only if the user picks again).\n * Uses the non-mutating evaluation, never a probe admission.\n */\n #manualSuppressionHolds(sessionID: string, settings: SettingsV1): boolean {\n if (!this.#manuallySelected(sessionID, settings)) return false\n const current = this.#tracker.lastModel(sessionID)?.model\n if (current === undefined) return true\n if (this.#health.evaluate(refKey(current)).kind !== \"blocked\") return true\n this.#manualSelections.delete(sessionID)\n return false\n }\n\n /**\n * Handle one `retry` hook invocation. On a veto this mutates\n * `input.decision` to `{ retry: false }`; otherwise the decision is left\n * untouched and OpenCode's native retry policy stands.\n */\n async handleRetry(input: RetryHookInput): Promise<void> {\n this.#markLive()\n try {\n const settings = await this.#ensureSettings()\n if (this.#modeFor(input.sessionID, settings) === \"off\") return\n await this.#handleRetry(input, settings)\n } catch (error) {\n logFailOpen(\"retry\", error)\n }\n }\n\n /**\n * Record an escalation-tool request (ADP-015 agent self-report) against the\n * session's current work unit. Returns false when no unit is active — the\n * request is then discarded (escalation is a per-unit signal).\n */\n noteEscalationRequest(sessionID: string, reason: string, evidence: string): boolean {\n const unit = this.#tracker.active(sessionID)\n if (unit === undefined) return false\n const recorded = this.#escalationEvidence.get(unit.id) ?? []\n recorded.push({\n kind: \"agent-request\",\n detail: escalationDetail({ reason, evidence }),\n })\n this.#escalationEvidence.set(unit.id, recorded.slice(-MAX_ESCALATION_EVIDENCE))\n return true\n }\n\n /**\n * Record an agent-declared tier request for the session (the adaptive_tier\n * tool). STICKY: it steers the session's next and following admissions\n * until cleared — an agent works across many units in one task. Returns\n * false on an unknown tier (the tool re-validates before calling).\n *\n * Fire-and-forget persistence: the recorder signature is sync on both the\n * tool and the RPC source interfaces, so the write is enqueued without\n * awaiting it. Readers (routing, getTierRequest, the idle sweep) flush the\n * store's queue before reading, which makes the record visible\n * deterministically; a write failure drops the record fail-open (the tool\n * told the agent \"recorded\", the persisted mirror simply never sees it —\n * the same degradation the in-memory map had on restart).\n */\n noteTierRequest(sessionID: string, tier: string): boolean {\n if (!isTierName(tier)) return false\n void this.#tierRequests.set(sessionID, tier).catch(() => undefined)\n // The user/agent explicitly asked Adaptive to route again (ADP-028).\n this.#manualSelections.delete(sessionID)\n return true\n }\n\n /** The session's tier request, or `null` when it follows the routing ladder. */\n async getTierRequest(sessionID: string): Promise<TierName | null> {\n await this.#ready\n // A fire-and-forget note may still be in the queue: flush before reading.\n await this.#tierRequests.flush()\n return this.#tierRequests.get(sessionID)\n }\n\n /** Clear one session's tier request (`null` is the only valid input). */\n async setTierRequest(sessionID: string, tier: TierName | null): Promise<void> {\n await this.#ready\n if (tier !== null) throw new Error(\"only null clears a tier request\")\n await this.#tierRequests.set(sessionID, null)\n // Clearing through the control surface is the user asking Adaptive back.\n this.#manualSelections.delete(sessionID)\n }\n\n // ---------- state API for the control surfaces (ADP-033/034/036) ----------\n\n /** Current settings (awaits the constructor load). */\n async settings(): Promise<SettingsV1> {\n return this.#ensureSettings()\n }\n\n /** Validate and persist a settings patch; returns per-field errors. */\n async updateSettings(patch: SettingsPatch): Promise<PatchResult> {\n await this.#ready\n const result = await this.#settings.update(patch)\n if (result.ok && patch.mode !== undefined) {\n // A global mode change is the user steering Adaptive explicitly\n // (ADP-028): manual-selection suppression lifts for every session.\n this.#manualSelections.clear()\n }\n // Mode and tier changes move which parked work is due and when.\n if (result.ok) await this.#rearmWake()\n return result\n }\n\n /** The session's mode override, or `null` when it follows the global mode. */\n async getSessionMode(sessionID: string): Promise<OperatingMode | null> {\n await this.#ready\n return this.#sessionModes.get(sessionID)\n }\n\n /**\n * Persist one session's mode override (`null` clears it). Throws on write\n * failure — the RPC handler degrades that to an error patch result\n * (fail-open, ADP-031), while the routing path never calls this.\n */\n async setSessionMode(sessionID: string, mode: OperatingMode | null): Promise<void> {\n await this.#ready\n await this.#sessionModes.set(sessionID, mode)\n // A mode change is the user steering Adaptive explicitly (ADP-028).\n this.#manualSelections.delete(sessionID)\n await this.#rearmWake()\n }\n\n /**\n * Bounded status snapshot for the status view (ADP-033). Health is read\n * from the persisted record set (not the in-memory registry): the serving\n * instance's registry can be empty when the host's plugin reconciliation\n * placed the event-pump hooks on another instance, while the persisted\n * mirror is shared by every instance.\n */\n async status(): Promise<StatusSnapshot> {\n const settings = await this.#ensureSettings()\n // Parked work too: the other instance may have parked or resumed it.\n await this.#parked.refresh()\n const now = this.#options.clock()\n const { records, capacity, usableAt } = await this.#persistedView(settings, now)\n // The wake that will actually resume the session may come later than the\n // reset (backoff after fruitless wakes). It is this instance's own when\n // it sweeps, else the one the live instance published.\n const { ledger } = this.#options\n const wakeAt = this.#live || !ledger.liveElsewhere() ? this.#wake?.dueAt : ledger.liveWake()\n const waiting = this.#parked\n .list()\n .filter((record) => this.#wakeable(record, settings))\n .map((record) => {\n const usable = parkedResumeAt(record, settings, usableAt)\n return {\n sessionID: record.sessionID,\n tier: record.tier,\n resumeAt: usable === undefined ? null : Math.max(usable, wakeAt ?? usable),\n }\n })\n return buildStatus({\n settings,\n health: records,\n capacity,\n parked: this.#parked.count(),\n waiting,\n receipts: this.#receipts.snapshot().length,\n })\n }\n\n /**\n * Health and capacity as persisted by every instance, with when each ref\n * becomes usable. The status surface reads this (its instance's registry\n * can be empty when the host placed the event pump on another instance),\n * and so does the wake of an instance that hears no host reports.\n */\n async #persistedView(\n settings: SettingsV1,\n now: number,\n ): Promise<{\n records: ResourceRecord[]\n capacity: Record<string, CapacityReading | null>\n usableAt: (ref: ModelRef) => number | undefined\n }> {\n await this.#healthRecords.load()\n await this.#capacityStore.load()\n const records = this.#healthRecords.snapshot().map((record) => sweepRecord(record, now))\n const recordsByID = new Map(records.map((record) => [resourceKeyID(record.key), record]))\n // Capacity readings are gathered per configured ref (mirroring the health\n // input shape) so buildStatus stays a pure function of its inputs.\n const capacity: Record<string, CapacityReading | null> = {}\n for (const tier of TIERS) {\n for (const ref of settings.tiers[tier]) {\n const chainIDs = new Set(resourceChain(refKey(ref)).map(resourceKeyID))\n const candidates = this.#capacityStore\n .snapshot()\n .filter((entry) => chainIDs.has(resourceKeyID(entry.key)))\n .map((entry) => entry.reading)\n capacity[schedulerHealthKey(ref)] = mergeReadings(candidates, now)\n }\n }\n const usableAt = (ref: ModelRef): number | undefined =>\n resourceUsableAt(\n resourceChain(refKey(ref)).map((key) => recordsByID.get(resourceKeyID(key))),\n capacity[schedulerHealthKey(ref)] ?? null,\n now,\n )\n return { records, capacity, usableAt }\n }\n\n /** Newest-first bounded receipt view (ADP-030). */\n async receipts(): Promise<Receipt[]> {\n await this.#ready\n return this.#receipts.snapshot().slice(-RECEIPTS_VIEW_LIMIT).reverse()\n }\n\n // ---------- dispatch ----------\n\n async #dispatch(report: EventReport, settings: SettingsV1): Promise<void> {\n switch (report.kind) {\n case \"execution-started\":\n await this.#onExecutionStarted(report, settings)\n return\n case \"execution-succeeded\":\n await this.#onExecutionSucceeded(report)\n return\n case \"execution-failed\":\n await this.#onExecutionFailed(report, settings)\n return\n case \"execution-interrupted\":\n await this.#onExecutionInterrupted(report)\n return\n case \"model-selected\": {\n const result = this.#tracker.apply({\n kind: \"model-selected\",\n sessionID: report.sessionID,\n at: report.at,\n model: report.model,\n })\n // Whether the change was the user's pick or Adaptive's own switch\n // decides who controls the session's model (ADP-028); the result\n // carries the attribution the tracker resolved. Only the two\n // selection sources reach this event kind.\n const { source } = result.transition\n if (\n source === \"selected-adaptive\" ||\n // The host's other plugin instance (ADP-056) may have switched it.\n this.#options.ledger.takeSwitch(report.sessionID, report.model, this.#options.clock())\n ) {\n this.#manualSelections.delete(report.sessionID)\n return\n }\n this.#noteManualSelection(report.sessionID)\n await this.#takeOver(report.sessionID)\n return\n }\n case \"model-request\":\n if (report.agent !== undefined) {\n if (\n !this.#agents.has(report.sessionID) &&\n this.#agents.size >= Supervisor.MAX_AGENT_HINTS\n ) {\n // The guard above ensures the map is at its cap (>= 1 entries),\n // so the first key always exists; the assertion avoids a branch\n // the coverage gate would reject as unreachable.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const oldest = this.#agents.keys().next().value!\n this.#agents.delete(oldest)\n }\n this.#agents.set(report.sessionID, report.agent)\n }\n // Only the agent loop's own request reports the model actually\n // executing the unit's work. An auxiliary request (title, compaction,\n // generate — ADP-027) carries the host's own cheap pick for that side\n // request; adopting it as the session's model would misattribute the\n // primary unit's health evidence and leave the next admission\n // believing the unit runs on the wrong resource.\n if (report.requestKind === \"primary\") {\n this.#tracker.apply({\n kind: \"model-request\",\n sessionID: report.sessionID,\n at: this.#options.clock(),\n model: report.model,\n })\n }\n return\n case \"http-response\":\n await this.#onHttpResponse(report)\n return\n case \"idle\":\n await this.#onIdle(settings)\n return\n case \"prompt\":\n await this.#onPrompt(report.sessionID, settings)\n return\n }\n }\n\n // ---------- admission ----------\n\n /**\n * CONTROL-mode admission in the awaited prompt hook. The hook runs before\n * the turn's model resolution, so the applied model governs the very turn\n * that triggered admission (the event-pump execution-started report is\n * asynchronous and would only affect the next turn — verified on host\n * 2.2.5). OBSERVE never switches, so it needs no prompt-time decision and\n * stays on the pump entirely.\n */\n async #onPrompt(sessionID: string, settings: SettingsV1): Promise<void> {\n const mode = this.#modeFor(sessionID, settings)\n const own = this.#continuationPending.delete(sessionID)\n // The host's other plugin instance (ADP-056) may have sent it.\n const foreign = own\n ? undefined\n : this.#options.ledger.takeContinuation(sessionID, this.#options.clock())\n if (mode !== \"active\") {\n // An OFF or OBSERVE session is not routed, but the user's own turn\n // there still supersedes its parked work: turning Adaptive back on\n // must not replay a continuation the user has moved past.\n if (!own && foreign === undefined) await this.#takeOver(sessionID)\n return\n }\n if (own || foreign !== undefined) {\n // An owned continuation (retry recovery, escalation, parked resume)\n // already owns this unit's routing: re-arm the admission marker from\n // the continuation's tier intent so execution-started skips a fresh\n // (continuation-unaware) admission.\n const tier = own ? this.#continuationTiers.get(sessionID) : foreign?.tier\n if (foreign?.cycles !== undefined) this.#resumeCycles.set(sessionID, foreign.cycles)\n this.#promptAdmission.set(sessionID, {\n ...(tier !== undefined ? { tier } : {}),\n continuation: true,\n })\n return\n }\n // Prompt hooks also admit steering messages into an active episode. They\n // are not routing boundaries: switching here interrupts productive work\n // and resets its recovery budget before the host consumes the steering.\n if (this.#tracker.active(sessionID) !== undefined) return\n // A fresh user prompt cancels any stale continuation intent and marker:\n // this admission re-routes from scratch.\n this.#continuationTiers.delete(sessionID)\n this.#promptAdmission.delete(sessionID)\n this.#escalations.delete(sessionID)\n this.#quotaRecoveriesRemaining.delete(sessionID)\n await this.#takeOver(sessionID)\n // A pending probe ticket from an earlier prompt admission (or a failed\n // recovery) can only be carried by the unit the ORIGINAL prompt opens;\n // a fresh admission means that episode never ran, so the ticket is\n // released here instead of being adopted by whichever unit opens next.\n const stale = this.#sessionProbeTickets.get(sessionID)\n if (stale !== undefined) {\n this.#sessionProbeTickets.delete(sessionID)\n this.#health.releaseProbe(stale)\n }\n if (this.#manualSuppressionHolds(sessionID, settings)) {\n // ADP-028: the user's own model pick stands (yielded to health if the\n // picked resource is quarantined). Recording the defer (no switch, no\n // marker) leaves OpenCode's choice — the picked model — in place;\n // execution-started will skip routing the same way.\n await this.#recordReceipt({\n sessionID,\n decision: { kind: \"defer\", reason: \"routing-defer\", detail: \"manual-selection\" },\n })\n return\n }\n let probeTicket: ProbeTicket | undefined\n try {\n const admission = await this.#admit(settings, sessionID)\n probeTicket = admission.probeTicket\n const wrapped = schedulerForMode(admission.decision, mode)\n if (wrapped.kind === \"apply\") {\n await this.#ops.switchModel(sessionID, wrapped.model)\n }\n // A pin is not a tier — receipts only carry a tier for tiered routing.\n const tier = routingTier(admission.routing)\n await this.#recordReceipt({\n sessionID,\n ...(tier !== undefined ? { tier } : {}),\n decision: wrapped,\n })\n this.#promptAdmission.set(sessionID, { ...(tier !== undefined ? { tier } : {}) })\n // The prompt-admitted probe episode is the turn that follows.\n if (wrapped.kind === \"apply\" && probeTicket !== undefined) {\n this.#sessionProbeTickets.set(sessionID, probeTicket)\n }\n } catch (error) {\n // A probe admitted for this turn is lost when the admission fails (the\n // switch threw): no unit will ever carry the ticket, so release it.\n if (probeTicket !== undefined) {\n this.#health.releaseProbe(probeTicket)\n }\n // Fail-open: no marker → execution-started re-routes the unit itself.\n logFailOpen(\"admission\", error)\n await this.#recordReceipt({\n sessionID,\n decision: { kind: \"defer\", reason: \"routing-defer\", detail: \"internal error\" },\n })\n }\n }\n\n async #onExecutionStarted(\n report: EventReport & { kind: \"execution-started\" },\n settings: SettingsV1,\n ): Promise<void> {\n const opened = this.#tracker.apply({\n kind: \"execution-started\",\n sessionID: report.sessionID,\n at: report.at,\n })\n const unit = opened.unit\n // The prompt-hook marker belongs to the unit this report OPENS, so read\n // it before the close cleanup: a superseding start would otherwise\n // discard it and re-route an already-admitted turn.\n const admitted = this.#promptAdmission.get(report.sessionID)\n // A run Adaptive did not continue — the user's shell or slash command\n // skips the prompt hook — moves the session past any resume waiting to\n // settle on it.\n if (admitted?.continuation !== true) this.#options.ledger.noteTakeover(report.sessionID)\n // A superseding start closes the previous episode — release its\n // per-unit bookkeeping (veto budget) too.\n this.#afterUnitClose(opened)\n // The prompt hook already admitted and applied for this unit — carry the\n // tier into escalation context and skip re-routing.\n if (admitted !== undefined) {\n this.#promptAdmission.delete(report.sessionID)\n this.#continuationTiers.delete(report.sessionID)\n if (admitted.tier !== undefined) this.#admissionTiers.set(unit.id, admitted.tier)\n if (admitted.continuation === true) this.#continuationUnits.add(unit.id)\n // The prompt-time admission receipt was recorded before this unit\n // existed; adopt it so outcomes attach to it like any unit receipt.\n try {\n await this.#receipts.adoptUnit(report.sessionID, unit.id)\n } catch (error) {\n logFailOpen(\"receipts\", error)\n }\n const sessionTicket = this.#sessionProbeTickets.get(report.sessionID)\n if (sessionTicket !== undefined) {\n this.#sessionProbeTickets.delete(report.sessionID)\n this.#probeTickets.set(unit.id, sessionTicket)\n }\n return\n }\n // A probe admitted while computing a veto's recovery belongs to the\n // continuation episode that follows — the first start on the session\n // after the veto.\n const carriedTicket = this.#sessionProbeTickets.get(report.sessionID)\n if (carriedTicket !== undefined) {\n this.#sessionProbeTickets.delete(report.sessionID)\n this.#probeTickets.set(unit.id, carriedTicket)\n }\n try {\n await this.#routeAdmission(unit, settings, this.#modeFor(unit.sessionID, settings))\n } catch (error) {\n logFailOpen(\"admission\", error)\n await this.#recordReceipt({\n sessionID: unit.sessionID,\n unitID: unit.id,\n decision: { kind: \"defer\", reason: \"routing-defer\", detail: \"internal error\" },\n })\n }\n }\n\n /** Fresh admission: routing ladder → scheduler, raw (unwrapped). */\n async #admit(\n settings: SettingsV1,\n sessionID: string,\n requiredTier?: TierName,\n ): Promise<{\n routing: RoutingDecision\n decision: ReturnType<typeof admit>\n probeTicket?: ProbeTicket\n }> {\n // The agent-declared tier request (adaptive_tier tool) outranks the\n // role hints but stays below the pin (ADP-002 ladder). The note is\n // recorded fire-and-forget, so flush the store's queue before reading.\n await this.#tierRequests.flush()\n const tierRequest = this.#tierRequests.get(sessionID)\n let routedTier: TierRequest | undefined\n if (requiredTier !== undefined) {\n routedTier = { tier: requiredTier, via: \"manual-command\" as const }\n } else if (tierRequest !== null) {\n routedTier = { tier: tierRequest, via: \"manual-command\" as const }\n }\n const routing = resolveRouting({\n ...(settings.pin !== null ? { pin: settings.pin } : {}),\n ...(routedTier !== undefined ? { tierRequest: routedTier } : {}),\n // The agent-role hint is the session's last observed agent — the host\n // reports it on every model request (ADP-002 level 3).\n ...(this.#agents.has(sessionID) ? { agent: this.#agents.get(sessionID) } : {}),\n agentTiers: settings.agentTiers,\n configuredTiers: configuredTiers(settings),\n })\n const tierCandidates = routing.kind === \"tier\" ? settings.tiers[routing.tier] : []\n const inventory = await listCandidates(this.#options.model)\n // Capacity sensors are pull-based: refresh before assessing so the\n // admission decision sees current readings.\n await this.#capacity.refresh()\n const health: Record<string, Assessment> = {}\n const capacity: Record<string, CapacitySignals> = {}\n // Tickets issued by this assessment sweep (see the release below).\n const issued: ProbeTicket[] = []\n // Only the routed candidates are assessed: assess flips a due breaker to\n // half_open, and admitting a quick unit has no business touching an\n // advanced-tier resource's breaker.\n const routed = routing.kind === \"pin\" ? [routing.model] : tierCandidates\n for (const ref of routed) {\n const mapKey = schedulerHealthKey(ref)\n const assessment = this.#health.assess(refKey(ref))\n health[mapKey] = assessment\n if (assessment.kind === \"probe\") issued.push(assessment.ticket)\n const capacityAssessment = this.#capacity.assessment(refKey(ref))\n if (capacityAssessment.kind === \"estimate\") capacity[mapKey] = capacityAssessment.signals\n }\n const input: SchedulerInput = {\n routing,\n // The host exposes no per-episode demand source in the v2 wiring\n // (no tool/modality/context requirement reaches the plugin), so the\n // compatibility gate runs on availability metadata only. Documented\n // limitation — see TEST_STRATEGY \"Compatibility gate demand\".\n demand: {} satisfies Demand,\n inventory,\n tierCandidates,\n health,\n capacity,\n }\n const decision = admit(input)\n // Assess admits a half-open probe for every due breaker it touches —\n // including candidates this decision passed over (an earlier ready\n // candidate wins) or dispatched nothing for (defer/park). An\n // issued-but-undispatched probe would wedge its resource in half_open:\n // no unit ever carries the ticket. Release each unselected ticket — it\n // stays due, because a probe that never ran is no health evidence and\n // restarting its backoff would push it back on every admission.\n const selectedId = decision.kind === \"apply\" ? decision.evidence.probeId : undefined\n let probeTicket: ProbeTicket | undefined\n for (const ticket of issued) {\n if (selectedId !== undefined && ticket.id === selectedId) {\n probeTicket = ticket\n } else {\n this.#health.releaseProbe(ticket)\n }\n }\n return { routing, decision, ...(probeTicket !== undefined ? { probeTicket } : {}) }\n }\n\n async #routeAdmission(\n unit: ActiveUnit,\n settings: SettingsV1,\n mode: OperatingMode,\n ): Promise<void> {\n if (this.#manualSuppressionHolds(unit.sessionID, settings)) {\n // ADP-028: the session runs on the user's own pick (yielded to health\n // if the picked resource is quarantined) — no re-route.\n await this.#recordReceipt({\n sessionID: unit.sessionID,\n unitID: unit.id,\n decision: { kind: \"defer\", reason: \"routing-defer\", detail: \"manual-selection\" },\n })\n return\n }\n const { routing, decision, probeTicket } = await this.#admit(settings, unit.sessionID)\n // The tier the unit was admitted under is escalation context (ADP-015);\n // recorded for every tiered routing outcome (including a defer, which\n // still names the tier it could not honor).\n if (routing.kind !== \"pin\") {\n this.#admissionTiers.set(unit.id, routing.tier)\n }\n const wrapped = schedulerForMode(decision, mode)\n if (wrapped.kind === \"apply\") {\n try {\n await this.#applyModel(unit, wrapped)\n } catch (error) {\n // The episode cannot carry the probe when the switch itself failed —\n // release the ticket instead of wedging the resource half-open.\n if (probeTicket !== undefined) {\n this.#health.releaseProbe(probeTicket)\n }\n throw error\n }\n if (probeTicket !== undefined) this.#probeTickets.set(unit.id, probeTicket)\n return\n }\n if (probeTicket !== undefined) {\n // OBSERVE wraps an apply — including a probe admission — without\n // running it: no episode will ever report the ticket, so release it.\n this.#health.releaseProbe(probeTicket)\n }\n // Observe-only records the identical decision; defer and park leave the\n // episode on OpenCode's own model (admission cannot hold an episode).\n const tier = routingTier(routing)\n await this.#recordReceipt({\n sessionID: unit.sessionID,\n unitID: unit.id,\n ...(tier !== undefined ? { tier } : {}),\n decision: wrapped,\n })\n }\n\n /** CONTROL-mode application at the admission boundary; OBSERVE never reaches here. */\n async #applyModel(unit: ActiveUnit, decision: ApplyDecision): Promise<void> {\n await this.#ops.switchModel(unit.sessionID, decision.model)\n await this.#recordReceipt({\n sessionID: unit.sessionID,\n unitID: unit.id,\n ...(decision.tier !== undefined ? { tier: decision.tier } : {}),\n decision,\n })\n }\n\n // ---------- unit termination ----------\n\n async #onExecutionSucceeded(\n report: EventReport & { kind: \"execution-succeeded\" },\n ): Promise<void> {\n const unit = this.#tracker.active(report.sessionID)\n const model = unit?.model ?? this.#tracker.lastModel(report.sessionID)?.model\n const probeTicket = this.#takeProbeTicket(unit?.id)\n const closed = this.#tracker.apply({\n kind: \"execution-succeeded\",\n sessionID: report.sessionID,\n at: report.at,\n })\n this.#afterUnitClose(closed)\n this.#resumeCycles.delete(report.sessionID)\n if (model !== undefined) {\n this.#observeHealth({ kind: \"success\", key: refKey(model) })\n }\n if (unit !== undefined) {\n if (probeTicket !== undefined) {\n this.#reportProbeOutcome(probeTicket, { success: true })\n }\n await this.#attachOutcome(unit, { status: \"succeeded\" })\n }\n }\n\n async #onExecutionFailed(\n report: EventReport & { kind: \"execution-failed\" },\n settings: SettingsV1,\n ): Promise<void> {\n const unit = this.#tracker.active(report.sessionID)\n const model = unit?.model ?? this.#tracker.lastModel(report.sessionID)?.model\n const unitID = unit?.id\n // The tier is read before the close clears the per-unit maps.\n const admissionTier = unitID !== undefined ? this.#admissionTiers.get(unitID) : undefined\n const escalationUsed = this.#escalations.get(report.sessionID) ?? 0\n // Tool evidence is captured pre-close like the other per-unit maps.\n const toolEvidence = unitID !== undefined ? (this.#escalationEvidence.get(unitID) ?? []) : []\n const probeTicket = this.#takeProbeTicket(unitID)\n // A vetoed continuation unit's failure is an echo: its own veto owns the\n // next continuation.\n const continuation =\n unitID !== undefined && this.#continuationUnits.has(unitID) && !this.#vetoes.has(unitID)\n // The terminal classifies and dedups BEFORE the close: the close clears\n // the unit's attempt-failure entry, and the terminal must consult it —\n // it repeats the episode's last attempt, which an attempt signal\n // (http-response or retry hook) already counted.\n const classification = classifyFailure({\n structured: {\n type: report.error.type,\n ...(report.error.retryAfterMs !== undefined\n ? { retryAfterMs: report.error.retryAfterMs }\n : {}),\n },\n status: report.error.status,\n // Terminal classification may use the bounded textual last resort\n // (content-policy rejections arrive as free text, not error types).\n // The retry hook passes text only to refine a 429's window.\n text: report.error.message,\n })\n const countTerminal = this.#countTerminalFailure(unitID, classification.category)\n const closed = this.#tracker.apply({\n kind: \"execution-failed\",\n sessionID: report.sessionID,\n at: report.at,\n error: report.error,\n })\n this.#afterUnitClose(closed)\n if (model !== undefined && countTerminal) {\n this.#observeHealth(failureEvent(refKey(model), classification))\n }\n if (unit !== undefined) {\n await this.#attachOutcome(unit, { status: \"failed\", category: classification.category })\n if (probeTicket !== undefined) {\n this.#reportProbeOutcome(probeTicket, { success: false, category: classification.category })\n }\n }\n if (\n unit !== undefined &&\n model !== undefined &&\n classification.category === \"quota_exhausted\"\n ) {\n await this.#recoverTerminalQuota(unit, admissionTier, continuation, settings)\n return\n }\n await this.#escalateOnFailure(\n report,\n unitID,\n model,\n classification,\n admissionTier,\n escalationUsed,\n toolEvidence,\n settings,\n )\n }\n\n async #recoverTerminalQuota(\n unit: ActiveUnit,\n requiredTier: TierName | undefined,\n continuation: boolean,\n settings: SettingsV1,\n ): Promise<void> {\n const sessionID = unit.sessionID\n // The continuation unit itself can run out of quota before the recovery\n // that started it returns from its prompt call. Its failure is its own:\n // wait for that recovery to settle, then recover (or park) like any unit.\n if (continuation) await this.#recoveryPending.get(sessionID)\n // Otherwise a pending continuation owns the session (a retry veto's\n // terminal echo must not start another). OBSERVE computes the same\n // admission without applying it.\n const mode = this.#modeFor(sessionID, settings)\n if (\n mode === \"off\" ||\n this.#recoveryPending.has(sessionID) ||\n this.#continuationTiers.has(sessionID) ||\n this.#continuationPending.has(sessionID)\n )\n return\n if (mode === \"active\") this.#manualSuppressionHolds(sessionID, settings)\n const { routing, decision, probeTicket } = await this.#admit(settings, sessionID, requiredTier)\n const tier = routingTier(routing)\n if (mode === \"observe\") {\n if (probeTicket !== undefined) this.#health.releaseProbe(probeTicket)\n await this.#recordReceipt({ sessionID, tier, decision: schedulerForMode(decision, mode) })\n return\n }\n // Quota windows can expire while session.wait is pending. Snapshot the\n // configured ladder length once so even those recoveries cannot loop.\n const remaining =\n this.#quotaRecoveriesRemaining.get(sessionID) ??\n (tier === undefined ? 0 : settings.tiers[tier].length)\n if (decision.kind === \"apply\" && remaining === 0) {\n if (probeTicket !== undefined) this.#health.releaseProbe(probeTicket)\n // The ladder is spent but the work is not done: park it so the wake\n // resumes it with a fresh budget instead of leaving the session stuck.\n if (tier !== undefined) {\n await this.#recordReceipt({\n sessionID,\n tier,\n decision: { kind: \"park\", reason: \"all-blocked\", detail: \"quota recovery budget spent\" },\n })\n await this.#parkUnit(unit.id, sessionID, tier, \"quota exhausted\")\n }\n return\n }\n await this.#recordReceipt({ sessionID, tier, decision })\n if (decision.kind !== \"apply\") {\n if (decision.kind === \"park\" && tier !== undefined) {\n await this.#parkUnit(unit.id, sessionID, tier, \"quota exhausted\")\n }\n return\n }\n this.#quotaRecoveriesRemaining.set(sessionID, remaining - 1)\n if (probeTicket !== undefined) this.#sessionProbeTickets.set(sessionID, probeTicket)\n // The host rejected this attempt without invoking its retry hook. Continue\n // from durable session state rather than waiting for another user message.\n void this.#ownRecovery(\n sessionID,\n decision.model,\n tier,\n () => this.#modeFor(sessionID, this.#settings.get()) === \"active\",\n ).catch((error: unknown) => {\n if (probeTicket !== undefined && this.#sessionProbeTickets.get(sessionID) === probeTicket) {\n this.#sessionProbeTickets.delete(sessionID)\n this.#health.releaseProbe(probeTicket)\n }\n if (!(error instanceof RecoveryAbortedError)) logFailOpen(\"quota-recovery\", error)\n })\n }\n\n /**\n * Escalation targets must be usable: the scheduler contract hands\n * planEscalation \"already gated\" resources, so the wiring filters the next\n * tier's configured refs to candidates that exist in the inventory, pass\n * the compatibility gate, are not health-blocked, and differ from the\n * model that just failed. Evaluated WITHOUT probe admission (evaluate,\n * not assess) — gating an escalation must never flip a breaker or strand\n * an unowned ticket.\n */\n async #eligibleEscalationTargets(\n refs: readonly ModelRef[],\n failed: ModelRef,\n ): Promise<ModelRef[]> {\n let inventory: readonly CandidateModel[]\n try {\n inventory = await listCandidates(this.#options.model)\n } catch (error) {\n // No inventory means no verifiable target: escalating would switch\n // blind, so the budget is kept instead of burned.\n logFailOpen(\"escalation\", error)\n return []\n }\n const eligible: ModelRef[] = []\n // Compared by resource key: the host reports base-model calls as variant\n // \"default\", which is the same resource as the bare tier entry.\n const failedID = resourceKeyID(refKey(failed))\n for (const ref of refs) {\n if (resourceKeyID(refKey(ref)) === failedID) continue\n const candidate = inventory.find((entry) => sameModelRef(candidateRef(entry), ref))\n if (candidate === undefined) continue\n if (!checkCompatibility(candidate, {} satisfies Demand).compatible) continue\n if (this.#health.evaluate(refKey(ref)).kind !== \"available\") continue\n eligible.push(ref)\n }\n return eligible\n }\n\n /**\n * Escalation on a terminally failed unit (ADP-015..017): structured\n * capability evidence only, same-model variant first then next tier,\n * finite budget. Control continues the interrupted work on the escalated\n * resource; Observe records the identical decision; defer receipts stand.\n */\n async #escalateOnFailure(\n report: EventReport & { kind: \"execution-failed\" },\n unitID: string | undefined,\n model: ModelRef | undefined,\n classification: FailureClassification,\n admissionTier: TierName | undefined,\n escalationUsed: number,\n toolEvidence: readonly EscalationEvidence[],\n settings: SettingsV1,\n ): Promise<void> {\n if (\n unitID === undefined ||\n model === undefined ||\n admissionTier === undefined ||\n !CAPABILITY_EVIDENCE_CATEGORIES.includes(classification.category)\n ) {\n return\n }\n const next = nextTier(admissionTier)\n const evidence: EscalationEvidence[] = [\n ...toolEvidence,\n { kind: \"repeated-failure\", detail: classification.category },\n ]\n const nextResources = next !== undefined ? settings.tiers[next] : []\n const eligible = await this.#eligibleEscalationTargets(nextResources, model)\n const plan = planEscalation({\n currentModel: model,\n currentTier: admissionTier,\n nextTierResources: eligible,\n evidence,\n budget: { used: escalationUsed, max: MAX_ESCALATIONS_PER_TASK },\n })\n const wrapped = schedulerForMode(plan, this.#modeFor(report.sessionID, settings))\n if (wrapped.kind === \"escalate\") {\n this.#escalations.set(report.sessionID, escalationUsed + 1)\n // Recorded unit-less on purpose: the receipt describes the CONTINUATION\n // decision, so the continuation unit adopts it and its outcome attaches\n // here (the failed unit's own outcome attaches to its apply receipt).\n await this.#recordReceipt({\n sessionID: report.sessionID,\n tier: wrapped.tier,\n decision: wrapped,\n })\n // Continue the interrupted work on the escalated resource; the unit is\n // terminally failed, so an ops failure is only logged (never parked).\n try {\n await this.#ownRecovery(\n report.sessionID,\n wrapped.target,\n wrapped.tier,\n () => this.#modeFor(report.sessionID, settings) !== \"off\",\n )\n } catch (error) {\n if (!(error instanceof RecoveryAbortedError)) logFailOpen(\"escalation-ops\", error)\n }\n return\n }\n await this.#recordReceipt({\n sessionID: report.sessionID,\n tier: plan.kind === \"escalate\" ? plan.tier : admissionTier,\n decision: wrapped,\n })\n }\n\n async #onExecutionInterrupted(\n report: EventReport & { kind: \"execution-interrupted\" },\n ): Promise<void> {\n const reason = interruptReason(report.reason)\n if (reason === undefined) {\n logFailOpen(\n \"interrupt\",\n new Error(`unknown interruption reason: ${report.reason.slice(0, 32)}`),\n )\n return\n }\n const unit = this.#tracker.active(report.sessionID)\n const probeTicket = this.#takeProbeTicket(unit?.id)\n // The user cancelling is the user steering: a resume waiting on this\n // session (on either instance) drops its work instead of re-parking it.\n if (reason === \"user\") this.#options.ledger.noteTakeover(report.sessionID)\n // An interruption while a recovery is pending on this session aborts it\n // at its post-settle guard (the pending recovery's decision predates the\n // interruption and must not act after it).\n if (this.#recoveryPending.has(report.sessionID)) {\n this.#recoveryInterrupted.add(report.sessionID)\n }\n const closed = this.#tracker.apply({\n kind: \"execution-interrupted\",\n sessionID: report.sessionID,\n at: report.at,\n reason,\n })\n this.#afterUnitClose(closed)\n // User and host interruptions never produce health evidence (the\n // classifier maps them outside the infrastructure vocabulary).\n if (unit !== undefined) {\n // An interrupted probe is no evidence about resource health: re-arm the\n // breaker's same window rather than doubling it.\n if (probeTicket !== undefined) {\n this.#reportProbeOutcome(probeTicket, { success: false, category: \"user_cancelled\" })\n }\n await this.#attachOutcome(unit, { status: \"interrupted\", reason })\n }\n }\n\n /**\n * One probe ticket's resolution at its episode's termination. A probe that\n * ends without a reported outcome (superseded, lost) would wedge the\n * resource in half_open, so the close cleanup reports those as\n * interruptions — re-arming the same backoff window, never doubling it.\n */\n #reportProbeOutcome(ticket: ProbeTicket, outcome: ProbeOutcome): void {\n // reportProbe is total and synchronous; validation failures (stale or\n // unknown ticket) are reported by its boolean return, not by throwing.\n this.#health.reportProbe(ticket, outcome)\n }\n\n /**\n * One attempt's failure evidence (http-response event or retry hook):\n * returns whether THIS observation is the attempt's first count.\n */\n #countAttemptFailure(\n unitID: string | undefined,\n source: \"http\" | \"retry\",\n category: FailureCategory,\n ): boolean {\n if (unitID === undefined) return true\n const ev = this.#attemptFailures.get(unitID) ?? {}\n if (source === \"http\" ? ev.retry === category : ev.http === category) {\n // The other host signal already counted this attempt: consume it.\n const closed = { ...ev, http: undefined, retry: undefined, closed: category }\n this.#attemptFailures.set(unitID, closed)\n return false\n }\n this.#attemptFailures.set(\n unitID,\n source === \"http\" ? { ...ev, http: category } : { ...ev, retry: category },\n )\n return true\n }\n\n /**\n * The terminal `execution-failed` repeats the episode's last attempt: it\n * counts only when the last attempt left no live evidence (e.g. a\n * capability failure that never produced an HTTP response or retry hook).\n */\n #countTerminalFailure(unitID: string | undefined, category: FailureCategory): boolean {\n if (unitID === undefined) return true\n const ev = this.#attemptFailures.get(unitID) ?? {}\n if (ev.http === category) {\n this.#attemptFailures.set(unitID, { ...ev, http: undefined })\n return false\n }\n if (ev.retry === category) {\n this.#attemptFailures.set(unitID, { ...ev, retry: undefined })\n return false\n }\n if (ev.closed === category) {\n this.#attemptFailures.set(unitID, { ...ev, closed: undefined })\n return false\n }\n this.#attemptFailures.set(unitID, { ...ev, closed: category })\n return true\n }\n\n /**\n * Hands a closing unit's probe ticket to its explicit outcome reporter.\n * Taken BEFORE the close: #afterUnitClose treats any ticket still held as\n * lost and re-opens the breaker, which would turn a probe's real outcome\n * into a stale report.\n */\n #takeProbeTicket(unitID: string | undefined): ProbeTicket | undefined {\n if (unitID === undefined) return undefined\n const ticket = this.#probeTickets.get(unitID)\n this.#probeTickets.delete(unitID)\n return ticket\n }\n\n /** Bounded per-unit bookkeeping once the tracker closed the unit. */\n #afterUnitClose(closed: ApplyResult): void {\n const unitID = closedUnitID(closed)\n if (unitID !== undefined) {\n this.#vetoes.delete(unitID)\n this.#continuationUnits.delete(unitID)\n this.#admissionTiers.delete(unitID)\n this.#escalationEvidence.delete(unitID)\n const leftover = this.#probeTickets.get(unitID)\n if (leftover !== undefined) {\n // The explicit outcome reporters take their ticket before this\n // cleanup; reaching here means the unit ended without one\n // (superseded or lost).\n this.#reportProbeOutcome(leftover, { success: false, category: \"user_cancelled\" })\n this.#probeTickets.delete(unitID)\n }\n }\n if (closed.kind === \"opened\" || closed.kind === \"closed\") {\n const unitID = closedUnitID(closed)\n if (unitID !== undefined) {\n this.#attemptFailures.delete(unitID)\n }\n // Per-session flags for a unit that will never open again must not\n // leak: a stale continuation mark would swallow a real user prompt's\n // admission; a stale admission marker would skip routing. The guard\n // keeps the wipe out of an in-flight continuation's mark window (its\n // own close events are pumped concurrently with the mark).\n const sid = closed.unit.sessionID\n // A continuation tier intent pins the marker: the failed unit's close\n // event can arrive after the continuation's prompt hook set it, and\n // wiping then would re-route the continuation unit.\n if ((this.#continuationsInFlight.get(sid) ?? 0) === 0 && !this.#continuationTiers.has(sid)) {\n this.#continuationPending.delete(sid)\n this.#promptAdmission.delete(sid)\n }\n }\n }\n\n // ---------- http evidence ----------\n\n async #onHttpResponse(report: EventReport & { kind: \"http-response\" }): Promise<void> {\n if (report.capturedHeaders !== undefined) {\n this.#codex.observe(report.capturedHeaders, this.#options.clock())\n await this.#syncCapacityMirror()\n }\n if (report.status < 400) return\n const unit = this.#tracker.active(report.sessionID)\n const model = unit?.model ?? this.#tracker.lastModel(report.sessionID)?.model\n if (model === undefined) return\n const classification = classifyFailure({\n status: report.status,\n ...(report.retryAfterHeader !== undefined\n ? { headers: { \"retry-after\": report.retryAfterHeader } }\n : {}),\n })\n // The retry hook classifies the same request for the host's retry\n // decision; counting both would double every attempt (ADP-019).\n if (this.#countAttemptFailure(unit?.id, \"http\", classification.category)) {\n this.#observeHealth(failureEvent(refKey(model), classification))\n }\n }\n\n // ---------- retry hook ----------\n\n async #handleRetry(input: RetryHookInput, settings: SettingsV1): Promise<void> {\n const classification = classifyFailure({\n structured: {\n type: input.error.type,\n ...(input.error.retryAfterMs !== undefined\n ? { retryAfterMs: input.error.retryAfterMs }\n : {}),\n },\n status: input.error.status,\n // Text only refines a definitive 429's window (rate limit vs spent\n // quota); every other retry classification stays structural.\n ...(input.error.status === 429 ? { text: input.error.message } : {}),\n })\n const unitID = this.#tracker.active(input.sessionID)?.id\n // The pumped http-response event describes the same failed request;\n // counting both would double every attempt (ADP-019).\n if (this.#countAttemptFailure(unitID, \"retry\", classification.category)) {\n this.#observeHealth(failureEvent(refKey(input.model), classification))\n }\n\n // Recovery = fresh admission; the failed resource is already health-blocked.\n let recovery: RecoveryOption = { kind: \"none\" }\n let routingTier: TierName | undefined\n let probeTicket: ProbeTicket | undefined\n let admission: ReturnType<typeof admit> | undefined\n try {\n const {\n routing,\n decision,\n probeTicket: ticket,\n } = await this.#admit(settings, input.sessionID)\n routingTier = routing.kind === \"pin\" ? undefined : routing.tier\n if (decision.kind === \"apply\") {\n admission = decision\n recovery = {\n kind: \"switch\",\n model: decision.model,\n ...(decision.evidence.probeId !== undefined\n ? { probeId: decision.evidence.probeId }\n : {}),\n }\n probeTicket = ticket\n }\n } catch (error) {\n logFailOpen(\"recovery\", error)\n }\n\n const vetoesUsed = unitID !== undefined ? (this.#vetoes.get(unitID) ?? 0) : 0\n const core = decideRetry({\n classification,\n failingModel: input.model,\n native: input.decision,\n recovery,\n vetoesUsed,\n })\n const wrapped = retryForMode(core, this.#modeFor(input.sessionID, settings))\n if (wrapped.kind !== \"veto\") {\n // OBSERVE (and a declined veto) never runs the recovery episode, so an\n // admitted probe has no continuation to report it — release it here or\n // the resource wedges half-open.\n if (probeTicket !== undefined) {\n this.#health.releaseProbe(probeTicket)\n }\n return\n }\n input.decision = { retry: false }\n if (unitID !== undefined) {\n this.#vetoes.set(unitID, vetoesUsed + 1)\n }\n // A probe admitted by this recovery belongs to the continuation episode\n // that ownRecovery is about to start; its termination reports the probe.\n if (probeTicket !== undefined) {\n // The session holds one pending probe slot. A still-pending older\n // ticket belongs to a recovery whose continuation has not started (its\n // episode can no longer claim this slot) — release it before replacing.\n const stale = this.#sessionProbeTickets.get(input.sessionID)\n if (stale !== undefined && stale !== probeTicket) {\n this.#health.releaseProbe(stale)\n }\n this.#sessionProbeTickets.set(input.sessionID, probeTicket)\n }\n // The continuation episode is not re-admitted — its prompt hook is\n // consumed as an owned continuation — so the recovery admission is\n // recorded here, unit-less; the unit that opens next adopts this receipt\n // and carries the outcome.\n // A veto implies the admission was an apply: the recovery option exists\n // only when the fresh admission selected a resource, so the assertion\n // cannot be undefined on this path.\n await this.#recordReceipt({\n sessionID: input.sessionID,\n tier: routingTier,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- a veto implies the admission was an apply (the recovery exists only then)\n decision: admission!,\n })\n void this.#ownRecovery(\n input.sessionID,\n wrapped.model,\n routingTier,\n () => this.#modeFor(input.sessionID, settings) !== \"off\",\n )\n .then(() => undefined)\n .catch(async (error: unknown) => {\n if (error instanceof RecoveryAbortedError) {\n // The user steered away (interruption / OFF) during the settle: the\n // veto stands, but no continuation episode will ever carry the\n // probe it admitted — release it instead of wedging half-open.\n if (\n probeTicket !== undefined &&\n this.#sessionProbeTickets.get(input.sessionID) === probeTicket\n ) {\n this.#sessionProbeTickets.delete(input.sessionID)\n this.#health.releaseProbe(probeTicket)\n }\n return\n }\n logFailOpen(\"recovery-ops\", error)\n // The recovery rejected before (or while) delivering its continuation\n // prompt, so no unit will ever carry the probe it admitted — release\n // it instead of wedging the resource half-open.\n if (\n probeTicket !== undefined &&\n this.#sessionProbeTickets.get(input.sessionID) === probeTicket\n ) {\n this.#sessionProbeTickets.delete(input.sessionID)\n this.#health.releaseProbe(probeTicket)\n }\n if (unitID === undefined || routingTier === undefined) return\n await this.#parkUnit(unitID, input.sessionID, routingTier, \"continuation failed\")\n })\n }\n\n /**\n * Owned horizontal recovery: settle → switch → continue from session\n * state. `tier` is the continuation unit's routing tier — recorded so the\n * continuation's prompt hook re-arms the admission marker (the unit must\n * not be re-routed: that would discard the recovery/escalation decision).\n */\n #ownRecovery(\n sessionID: string,\n model: ModelRef,\n tier: TierName | undefined,\n stillValid: () => boolean,\n ): Promise<void> {\n const run = this.#continueSession(sessionID, model, tier, stillValid)\n // The guard window opens in the same tick the recovery starts (before\n // its first await completes) so an interrupt pumped during the admission\n // race is still seen.\n const pending = run.catch(() => undefined)\n this.#recoveryPending.set(sessionID, pending)\n return run.finally(() => {\n // A later recovery on the session owns the entry now.\n if (this.#recoveryPending.get(sessionID) === pending) this.#recoveryPending.delete(sessionID)\n })\n }\n\n async #continueSession(\n sessionID: string,\n model: ModelRef,\n tier: TierName | undefined,\n stillValid: () => boolean,\n ): Promise<void> {\n if (tier !== undefined) this.#continuationTiers.set(sessionID, tier)\n try {\n const alive = await this.#isSessionAlive(sessionID)\n const recovery: RecoveryOption = { kind: \"switch\", model }\n const action = planContinuation({\n recovery,\n continuationPossible: alive,\n })\n // executeContinuation settles first; the supervisor settles here so the\n // post-settle guard (mode OFF, user interruption) can abort before any\n // switch or prompt — the settle is the only step that can take\n // unbounded time, and a decision made before it may be stale after it.\n await this.#ops.settle(sessionID)\n if (!stillValid() || this.#recoveryInterrupted.delete(sessionID)) {\n throw new RecoveryAbortedError(sessionID)\n }\n // Already settled above; the action's own settle is a no-op.\n await executeContinuation({\n sessionID,\n action,\n ops: { ...this.#ops, settle: () => Promise.resolve() },\n })\n } catch (error) {\n // The continuation prompt never reached the host, so no unit will open\n // to consume the tier intent — drop it or it would pin the marker\n // wipes and mislabel a later user prompt's admission.\n if (tier !== undefined) this.#continuationTiers.delete(sessionID)\n throw error\n }\n }\n\n // ---------- parked-work resume (safe boundaries: idle, wake) ----------\n\n async #onIdle(settings: SettingsV1): Promise<void> {\n await this.#sweepParked(settings)\n await this.#armWake()\n }\n\n /**\n * The wake timer's safe boundary. Fires only when no unit of a parked\n * session can reach idle on its own; it runs the same sweep (same\n * safeguards) as idle, then re-plans. An early fire (capped delay) only\n * re-plans: no sweep, no receipts while a long window is still open.\n */\n async #onWake(dueAt: number, capped: boolean): Promise<void> {\n this.#setWake(undefined)\n try {\n const settings = await this.#ensureSettings()\n if (!this.#disposed && (!capped || this.#options.clock() >= dueAt)) {\n if (!this.#live && this.#options.ledger.liveElsewhere()) {\n // The instance that hears the host has current health and sees\n // the resumed unit's reports: it resumes, this one backs off.\n this.#fruitless += 1\n } else {\n if (!this.#live) {\n // No instance hears the host yet (fresh start): persisted health\n // is the only current evidence.\n await this.#healthRecords.load()\n this.#health.hydrate(this.#healthRecords.snapshot())\n }\n // A taken record's delivery settles the backoff itself.\n if (!(await this.#sweepParked(settings))) this.#fruitless += 1\n }\n }\n } catch (error) {\n logFailOpen(\"wake\", error)\n }\n await this.#armWake()\n }\n\n /**\n * Plans the one wake timer from the parked work due for resume (ADP-024).\n * Never throws: a failed plan leaves parked work to the idle boundary.\n */\n async #armWake(): Promise<void> {\n try {\n const settings = await this.#ensureSettings()\n const now = this.#options.clock()\n // An instance that hears no host has no current health or capacity of\n // its own: it plans from what the live one persisted, as status does.\n const usableAt = this.#live\n ? (ref: ModelRef): number | undefined =>\n resourceUsableAt(\n resourceChain(refKey(ref)).map((key) => this.#health.recordFor(key)),\n this.#capacity.reading(refKey(ref)),\n now,\n )\n : (await this.#persistedView(settings, now)).usableAt\n // Disposal may land during either read above.\n if (this.#disposed) return\n const targets = this.#parked\n .list()\n .filter((record) => this.#wakeable(record, settings))\n .map((record) => parkedResumeAt(record, settings, usableAt))\n const plan = planWake(targets, now, this.#fruitless)\n if (plan !== undefined && plan.dueAt === this.#wake?.dueAt) return\n this.#wake?.cancel()\n this.#setWake(undefined)\n if (plan === undefined) return\n const { dueAt, capped } = plan\n this.#setWake({\n dueAt,\n cancel: this.#options.schedule(() => void this.#onWake(dueAt, capped), plan.delayMs),\n })\n } catch (error) {\n logFailOpen(\"wake\", error)\n }\n }\n\n /** Keeps the published wake (what status shows elsewhere) in step. */\n #setWake(wake: { readonly cancel: () => void; readonly dueAt: number } | undefined): void {\n this.#wake = wake\n this.#options.ledger.noteWake(wake?.dueAt)\n }\n\n /** A change the user or a new park made: re-plan without backoff. */\n async #rearmWake(): Promise<void> {\n this.#fruitless = 0\n await this.#armWake()\n }\n\n /**\n * Parked work the wake serves: an ACTIVE session (observe never resumes,\n * off is inert), a configured tier (else it is held), attempts left.\n */\n #wakeable(record: ParkedRecord, settings: SettingsV1): boolean {\n return (\n this.#modeFor(record.sessionID, settings) === \"active\" &&\n configuredTiers(settings).includes(record.tier) &&\n (record.attempts ?? 0) < MAX_PARKED_ATTEMPTS\n )\n }\n\n /**\n * Resumes due parked work once per session; true when any record was\n * taken for resume. Reloads parked work first: the host's other plugin\n * instance may have parked or resumed records since this one last looked.\n */\n async #sweepParked(settings: SettingsV1): Promise<boolean> {\n await this.#parked.refresh()\n const records = this.#parked.list()\n for (const record of records) this.#options.ledger.noteParked(record.sessionID)\n // Override holders join the alive sweep: a dead session's override is\n // pruned here (its per-session steering is worthless once the session is\n // gone), in the same sweep that clears the other per-session maps.\n const overrideIDs = this.#sessionModes.snapshot().map((record) => record.sessionID)\n const tierRequestIDs = this.#tierRequests.snapshot().map((record) => record.sessionID)\n if (records.length === 0 && overrideIDs.length === 0 && tierRequestIDs.length === 0) {\n return false\n }\n // OFF sessions are not supervised: their parked records are neither\n // dropped nor resumed, and no alive probe runs for them.\n const supervised = new Set(\n records\n .map((record) => record.sessionID)\n .filter((sessionID) => this.#modeFor(sessionID, settings) !== \"off\"),\n )\n const alive = new Map<string, boolean>()\n for (const sessionID of new Set([...supervised, ...overrideIDs])) {\n alive.set(sessionID, await this.#isSessionAlive(sessionID))\n }\n // Tier-request holders join the alive sweep too: a dead session's sticky\n // tier request dies with its session, like the other per-session maps.\n for (const sessionID of tierRequestIDs) {\n if (!alive.has(sessionID)) alive.set(sessionID, await this.#isSessionAlive(sessionID))\n }\n const plan = selectResumable(records, {\n tierConfigured: (tier) => configuredTiers(settings).includes(tier),\n sessionAlive: (sessionID) => alive.get(sessionID) === true,\n })\n for (const dropped of plan.drop) {\n if (this.#modeFor(dropped.sessionID, settings) === \"off\") continue\n await this.#dropParked(dropped)\n }\n // Tier requests die with their session, like the other per-session maps.\n // The fire-and-forget note means the queue may still hold writes; the\n // serialized set applies after them. A write failure just leaves the\n // record (fail-open — it will die with the session on the next sweep).\n for (const sessionID of tierRequestIDs) {\n if (alive.get(sessionID) === false) {\n try {\n await this.#tierRequests.set(sessionID, null)\n } catch (error) {\n logFailOpen(\"tier-requests\", error)\n }\n }\n }\n // At most ONE continuation per session per sweep: prompting a session\n // with an active unit would supersede the user's in-flight episode (not\n // a safe boundary), and several back-to-back continuation prompts could\n // redo work an earlier one already completed (ADP-023).\n const attempted = new Set<string>()\n let resumed = false\n for (const record of plan.attempt) {\n if (this.#disposed) break\n if (this.#modeFor(record.sessionID, settings) === \"off\") continue\n if (this.#tracker.active(record.sessionID) !== undefined) continue\n if (attempted.has(record.sessionID)) continue\n attempted.add(record.sessionID)\n if (await this.#resumeAttempt(record, settings)) resumed = true\n }\n for (const [sessionID, isAlive] of alive) {\n if (!isAlive) {\n this.#continuationTiers.delete(sessionID)\n this.#promptAdmission.delete(sessionID)\n this.#continuationPending.delete(sessionID)\n this.#escalations.delete(sessionID)\n this.#quotaRecoveriesRemaining.delete(sessionID)\n this.#resumeCycles.delete(sessionID)\n this.#options.ledger.clearParked(sessionID)\n if (this.#sessionModes.get(sessionID) !== null) {\n try {\n await this.#sessionModes.set(sessionID, null)\n } catch (error) {\n logFailOpen(\"session-modes\", error)\n }\n }\n }\n }\n return resumed\n }\n\n async #dropParked(record: ParkedRecord): Promise<void> {\n try {\n await this.#parked.resume(record.id)\n } catch (error) {\n logFailOpen(\"parked\", error)\n }\n }\n\n /**\n * The user took the session over (own prompt or model pick): a resume in\n * flight on either plugin instance aborts after its settle, and parked\n * work is dropped — resuming it would replay a continuation the user has\n * already moved past.\n */\n async #takeOver(sessionID: string): Promise<void> {\n const { ledger } = this.#options\n ledger.noteTakeover(sessionID)\n this.#resumeCycles.delete(sessionID)\n const parkedHere = (): ParkedRecord[] =>\n this.#parked.list().filter((record) => record.sessionID === sessionID)\n // A session that never parked costs no storage read (OFF stays free).\n if (parkedHere().length === 0 && !ledger.mayBeParked(sessionID)) return\n await this.#parked.refresh()\n const records = parkedHere()\n ledger.clearParked(sessionID)\n if (records.length === 0) return\n for (const record of records) await this.#dropParked(record)\n await this.#rearmWake()\n }\n\n /**\n * Parks a unit whose tier has no usable resource. A unit that was itself\n * a resume carries the session's resume cycles, so repeated park → wake →\n * fail rounds exhaust MAX_PARKED_ATTEMPTS instead of looping.\n */\n async #parkUnit(id: string, sessionID: string, tier: TierName, detail: string): Promise<void> {\n const attempts = this.#resumeCycles.get(sessionID)\n if (\n await this.#storeParked({\n id,\n sessionID,\n tier,\n reason: \"all-blocked\",\n detail,\n parkedAt: this.#options.clock(),\n ...(attempts !== undefined ? { attempts } : {}),\n })\n ) {\n await this.#rearmWake()\n }\n }\n\n /**\n * Persists parked work; false when nothing waits. Work out of resume\n * attempts is not kept: it gets a receipt saying so instead of lingering\n * unresumable behind a waiting chip.\n */\n async #storeParked(record: ParkedRecord): Promise<boolean> {\n if ((record.attempts ?? 0) >= MAX_PARKED_ATTEMPTS) {\n await this.#recordReceipt({\n sessionID: record.sessionID,\n unitID: record.id,\n tier: record.tier,\n decision: {\n kind: \"park\",\n reason: \"all-blocked\",\n detail: `gave up after ${String(MAX_PARKED_ATTEMPTS)} resume attempts`,\n },\n })\n return false\n }\n this.#options.ledger.noteParked(record.sessionID)\n try {\n await this.#parked.park(record)\n } catch (error) {\n logFailOpen(\"parked\", error)\n return false\n }\n return true\n }\n\n /**\n * One parked record's fresh routing attempt at a safe boundary; true when\n * the record was taken for resume. Its continuation is delivered in the\n * background: the prompt call stays open while the continued unit runs,\n * and the sweep must not hold every other due session behind it.\n */\n async #resumeAttempt(record: ParkedRecord, settings: SettingsV1): Promise<boolean> {\n // The parked session resumes under ITS effective mode, not the idle\n // report's session's mode.\n const mode = this.#modeFor(record.sessionID, settings)\n let decision: ReturnType<typeof admit>\n let probeTicket: ProbeTicket | undefined\n try {\n const admission = await this.#admit(settings, record.sessionID, record.tier)\n decision = admission.decision\n probeTicket = admission.probeTicket\n } catch (error) {\n logFailOpen(\"resume\", error)\n return false\n }\n if (mode === \"observe\" || decision.kind !== \"apply\") {\n // Observed, or still no usable resource (or the routing deferred) —\n // stay parked. A non-apply admission held no probe ticket: #admit keeps\n // a ticket only for apply decisions and releases every other one.\n if (probeTicket !== undefined) this.#health.releaseProbe(probeTicket)\n await this.#noteStillParked(\n record,\n mode === \"observe\" ? { kind: \"observe-only\", would: decision } : decision,\n )\n return false\n }\n // The takeover baseline is read before the claim, synchronously with it:\n // a user prompt landing while the record is popped still counts. The\n // claim spans the pop and the continuation's delivery: the host's other\n // plugin instance sweeping the same record backs off, then finds it gone\n // once it re-reads the parked store.\n const { ledger } = this.#options\n const takeovers = ledger.takeovers(record.sessionID)\n if (!ledger.claim(record.sessionID)) {\n if (probeTicket !== undefined) this.#health.releaseProbe(probeTicket)\n return false\n }\n let delivering = false\n try {\n const popped = await this.#popParked(record)\n if (popped === undefined) {\n if (probeTicket !== undefined) this.#health.releaseProbe(probeTicket)\n return false\n }\n // The resumed unit is a new round of the same task: a fresh quota\n // ladder, and one more spent resume cycle should it park again.\n this.#resumeCycles.set(record.sessionID, (record.attempts ?? 0) + 1)\n this.#quotaRecoveriesRemaining.delete(record.sessionID)\n if (probeTicket !== undefined) this.#sessionProbeTickets.set(record.sessionID, probeTicket)\n // The resume continuation is not re-admitted (owned continuation), so\n // the freshly routed admission is recorded here, unit-less; the unit\n // that opens next adopts it and carries the outcome.\n await this.#recordReceipt({ sessionID: record.sessionID, tier: record.tier, decision })\n delivering = true\n const takenOver = (): boolean => ledger.takeovers(record.sessionID) !== takeovers\n void this.#deliverResume(record, decision.model, settings, probeTicket, takenOver).finally(\n () => {\n ledger.release(record.sessionID)\n },\n )\n return true\n } finally {\n if (!delivering) ledger.release(record.sessionID)\n }\n }\n\n /**\n * Records why parked work stays parked. A wake that finds nothing changed\n * adds no receipt: a tier with no stated recovery would otherwise log the\n * same decision every few minutes.\n */\n async #noteStillParked(record: ParkedRecord, decision: Receipt[\"decision\"]): Promise<void> {\n const last = this.#receipts.snapshot().findLast((receipt) => receipt.unitID === record.id)\n if (last !== undefined && JSON.stringify(last.decision) === JSON.stringify(decision)) return\n await this.#recordReceipt({\n sessionID: record.sessionID,\n unitID: record.id,\n tier: record.tier,\n decision,\n })\n }\n\n /**\n * The resume continuation is an owned recovery: settle first, apply the\n * freshly routed model, then prompt — the episode's first LLM call must\n * not hit the model the work was parked away from. Never rejects.\n */\n async #deliverResume(\n record: ParkedRecord,\n model: ModelRef,\n settings: SettingsV1,\n probeTicket: ProbeTicket | undefined,\n takenOver: () => boolean,\n ): Promise<void> {\n try {\n await this.#ownRecovery(\n record.sessionID,\n model,\n record.tier,\n // The parked session's own effective mode and its still-open unit\n // window are re-checked after the settle; a session that gained an\n // active unit must not be prompted (not a safe boundary), and one the\n // user took over (on either instance) has moved past the work.\n () =>\n !(takenOver() || this.#disposed) &&\n this.#modeFor(record.sessionID, settings) !== \"off\" &&\n this.#tracker.active(record.sessionID) === undefined,\n )\n this.#fruitless = 0\n } catch (error) {\n if (\n probeTicket !== undefined &&\n this.#sessionProbeTickets.get(record.sessionID) === probeTicket\n ) {\n this.#sessionProbeTickets.delete(record.sessionID)\n this.#health.releaseProbe(probeTicket)\n }\n if (!(error instanceof RecoveryAbortedError)) logFailOpen(\"resume\", error)\n this.#resumeCycles.delete(record.sessionID)\n // Work the user took over is gone for good; anything else waits again,\n // and a failed resume backs off like a fruitless wake rather than\n // retrying a second later.\n if (takenOver()) return\n this.#fruitless += 1\n await this.#rePark(record)\n await this.#armWake()\n }\n }\n\n async #popParked(record: ParkedRecord): Promise<ParkedRecord | undefined> {\n try {\n return await this.#parked.resume(record.id)\n } catch (error) {\n logFailOpen(\"parked\", error)\n return undefined\n }\n }\n\n async #rePark(record: ParkedRecord): Promise<void> {\n await this.#storeParked({\n ...record,\n attempts: (record.attempts ?? 0) + 1,\n parkedAt: this.#options.clock(),\n })\n }\n\n // ---------- shared helpers ----------\n\n async #isSessionAlive(sessionID: string): Promise<boolean> {\n try {\n await this.#options.session.get({ sessionID })\n return true\n } catch (error) {\n // The host rejects `session.get` for a missing session with a plain\n // error and exposes no typed status; only a definitive not-found\n // counts as dead. Anything else is treated as alive (fail open toward\n // keeping durable user state, ADP-031): a transient storage or host\n // error must never prune parked work, mode overrides, or tier\n // requests — the next sweep re-probes instead.\n return !/not found/i.test(String(error))\n }\n }\n\n async #recordReceipt(input: Omit<ReceiptInput, \"at\">): Promise<void> {\n try {\n await this.#receipts.record({ at: this.#options.clock(), ...input })\n } catch (error) {\n logFailOpen(\"receipts\", error)\n }\n }\n\n async #attachOutcome(unit: ActiveUnit, outcome: ReceiptOutcome): Promise<void> {\n try {\n await this.#receipts.attachOutcome({ sessionID: unit.sessionID, unitID: unit.id }, outcome)\n } catch (error) {\n logFailOpen(\"receipts\", error)\n }\n }\n\n #observeHealth(event: HealthEvent): void {\n this.#health.observe(event)\n // Persist the record mirror fire-and-forget: the status surface reads\n // persisted records so a serving instance without the event-pump hooks\n // still reports true health. Failures are fail-open (ADP-031).\n const records: readonly ResourceRecord[] = this.#health.snapshot()\n void this.#healthRecords.replace(records).catch((error: unknown) => {\n logFailOpen(\"health\", error)\n })\n }\n\n /**\n * Persist the capacity mirror after a passive observation (same instance\n * split rationale as the health mirror): the status surface reads persisted\n * readings so a serving instance without the event-pump hooks still reports\n * sensed capacity. Failures are fail-open (ADP-031).\n */\n async #syncCapacityMirror(): Promise<void> {\n try {\n await this.#capacity.refresh()\n const entries: PersistedCapacityReading[] = []\n for (const sensor of this.#capacity.snapshot()) {\n if (sensor.latest !== null) {\n entries.push({ key: sensor.resource, reading: sensor.latest })\n }\n }\n await this.#capacityStore.replace(entries)\n } catch (error) {\n logFailOpen(\"capacity\", error)\n }\n }\n}\n\n/** A pin is not a tier — receipts only carry a tier for tiered routing. */\nfunction routingTier(routing: RoutingDecision): TierName | undefined {\n return routing.kind === \"pin\" ? undefined : routing.tier\n}\n\n/** The unit a tracker result closed or superseded, if any. */\nfunction closedUnitID(result: ApplyResult): string | undefined {\n switch (result.kind) {\n case \"closed\":\n return result.unit.id\n case \"opened\":\n return result.superseded?.id\n default:\n return undefined\n }\n}\n\n/** ModelRef for a normalized candidate. */\nfunction candidateRef(candidate: {\n providerID: string\n modelID: string\n variant?: string | undefined\n}): ModelRef {\n return {\n providerID: candidate.providerID,\n id: candidate.modelID,\n ...(candidate.variant !== undefined ? { variant: candidate.variant } : {}),\n }\n}\n\n/**\n * When a parked record can resume: the earliest usable candidate its\n * resume admission would route to (a standing pin wins over the tier).\n */\nfunction parkedResumeAt(\n record: ParkedRecord,\n settings: SettingsV1,\n usableAt: (ref: ModelRef) => number | undefined,\n): number | undefined {\n const candidates = settings.pin !== null ? [settings.pin] : settings.tiers[record.tier]\n return earliestUsable(candidates.map(usableAt))\n}\n\n/** ResourceKey for a model ref (no account level is observable in v1). */\nfunction refKey(ref: ModelRef): ResourceKey {\n // The host reports base-model calls with variant \"default\" (verified on\n // 2.2.5), while the inventory enumerates the bare model plus its named\n // variants. Taken literally, a \"default\" key would orphan every\n // unvarianted failure record on a key no admission ever assesses — health\n // and breaker state would be invisible to routing.\n const variant = ref.variant === \"default\" ? undefined : ref.variant\n return {\n providerID: ref.providerID,\n modelID: ref.id,\n ...(variant !== undefined ? { variantID: variant } : {}),\n }\n}\n\n/** Quota survives variantless host resolution; only shared-limit evidence blocks siblings. */\nfunction failureKey(key: ResourceKey, classification: FailureClassification): ResourceKey {\n if (classification.quotaScope === \"provider\") {\n // Host model refs expose the configured provider, not a credential/account id.\n return { providerID: key.providerID }\n }\n if (classification.category === \"quota_exhausted\" && key.variantID !== undefined) {\n return { providerID: key.providerID, modelID: key.modelID }\n }\n return key\n}\n\n/** Health failure event from a classification (bounded structured evidence). */\nfunction failureEvent(key: ResourceKey, classification: FailureClassification): HealthEvent {\n return {\n kind: \"failure\",\n key: failureKey(key, classification),\n category: classification.category,\n definitive: classification.definitive,\n ...(classification.retry.retryAfterMs !== undefined\n ? { retryAfterMs: classification.retry.retryAfterMs }\n : {}),\n }\n}\n"]}
|