import type { Capability, VocabDocument } from "../protocol/index.ts"; import { type RequiresPredicate } from "./requires.ts"; /** A role flattened out of the vocab tree, with its derived routing token. */ export interface ResolvedRole { /** The leaf routing token (`network[.subnetwork…].role`, or a bare role). */ readonly token: string; /** The network segment, absent for a bare role. */ readonly network?: string; /** The subnetwork segments between network and role (possibly empty). */ readonly subnetworks: readonly string[]; /** The role segment. */ readonly role: string; /** Cognition weight for the role, if declared. */ readonly weight?: number; /** Normalised seats: a non-negative count, or the explicit named-seat list. */ readonly seats: number | readonly string[]; /** Diversity SLO opt-in: when true, seats must be filled by distinct families. */ readonly seatsDistinctFamily: boolean; /** The parsed enrolment gate for the role. */ readonly requires: readonly RequiresPredicate[]; } /** The result of resolving one capability against the vocab. */ export interface Resolution { /** The SERVE token set — sorted, de-duplicated leaf tokens. */ readonly tokens: readonly string[]; /** The matched roles (sorted by token) the tokens came from. */ readonly roles: readonly ResolvedRole[]; } /** Raised when the document handed to the resolver is not a valid vocab artifact. */ export declare class VocabDocumentError extends Error { readonly errors: readonly { path: string; message: string; }[]; constructor(errors: readonly { path: string; message: string; }[]); } export declare class VocabResolver { #private; /** * Build a resolver over a vocab document. The document is re-validated against * the S0 schema and every role's `requires` gate is parsed up front, so a * malformed gate fails loudly at construction rather than silently at match. */ constructor(doc: VocabDocument); /** The vocab artifact version this resolver was built from. */ get version(): number; /** Every role in the vocab, sorted by token. */ roles(): readonly ResolvedRole[]; /** Every leaf token in the vocab, sorted. */ tokens(): readonly string[]; /** Look up a role by its routing token. */ roleForToken(token: string): ResolvedRole | undefined; /** * Resolve a declared enrolment capability to its SERVE token set: every role * whose `requires` gate the capability satisfies. The token list is sorted and * de-duplicated, so the same capability always yields the same SERVE. */ resolve(capability: Capability): Resolution; }