/** * Escalation chooser (P5c) -- the READER of {@link PolicyNode}. * * P2 landed `PolicyNode` as written-data; this module is its reader: given a * policy and the runtime site a node will be admitted on, it chooses the * MINIMAL capability rung ({@link CapTier}, lowest `Cap.ordinal`) that * satisfies the policy's `requires`, fits its `budgets`, lies inside its * `grants`, and still admits the projection targets the rung gates. * * Determinism: minimal-rung by `Cap.ordinal` ascending; ties (which the total * `CapTier` order makes impossible, but we keep the rule explicit so the * contract survives future lattice changes) break by the Astro directive * escalation order `satellite < stream < llm < worker < gpu < wasm`. `@czap/core` * cannot import `@czap/astro`, so that order is encoded locally below. * * Cycle discipline: the CapTier-to-target admissibility table PROJECTS from the * shared {@link LADDER_TARGETS} datum (`cap-ladder.ts`). We deliberately do NOT * import `TIER_TARGETS` from `@czap/quantizer`: the quantizer depends on core, * so core importing the quantizer would close a dependency cycle. Instead both * `RUNG_TARGETS` here and the quantizer's `TIER_TARGETS` are projections of the * SAME index-keyed ladder — one source, no drift (see `cap-ladder.ts`). * * @module */ import type { PolicyNode, RuntimeSite } from './document-graph.js'; import type { CapTier } from './caps.js'; import type { LadderTarget } from './cap-ladder.js'; /** A projection target the escalation gate may admit (subset of `ProjectionNode.target`). */ type ProjectionTarget = LadderTarget; /** * Immutable view of a rung's admissible targets. The raw `RUNG_TARGETS` table is * module-PRIVATE on purpose: it holds mutable `Set`s, and `@czap/core` publishes * wildcard subpaths (`./*`), so exporting it would let any consumer reach * `@czap/core/escalation` and `.clear()`/`.add()` the escalation lattice * process-wide. This returns a fresh copy each call. */ export declare function rungTargets(rung: CapTier): ReadonlySet; /** The successful chooser verdict. */ export interface RungChoice { /** The minimal {@link CapTier} satisfying site, budget, grants, and admissibility. */ readonly rung: CapTier; /** The projection targets that rung admits, intersected with the rung's table. */ readonly admittedTargets: ReadonlySet; } /** The chooser result: a verdict or an unsatisfiability reason. */ export type EscalationResult = RungChoice | { readonly error: string; }; /** * Choose the minimal capability rung a {@link PolicyNode} admits on a runtime site. * * Returns `{ rung, admittedTargets }` on success, or `{ error }` if the site is * not in `policy.sites` or no rung at or below `policy.requires` clears the * budgets/grants. Memoized by `policy.id + runtimeSite` (a policy id is its * `fnv1a` content address, so equal inputs return a stable reference). * * @param policy - The capability/constraint gate to read. * @param runtimeSite - The site the gated node will be admitted on. */ export declare function chooseRung(policy: PolicyNode, runtimeSite: RuntimeSite): EscalationResult; /** Test-only: clear the chooser memo. Not part of the public `@czap/core` surface. */ export declare function _resetEscalationMemo(): void; export {}; //# sourceMappingURL=escalation.d.ts.map