import { AihError } from "../errors.js"; import type { FrameworkCard } from "./card.js"; import type { BindingLock, BindingOwnershipEntry, BindingWrite } from "./lock.js"; import { type ResolvedSource, type ScanDisposition } from "./scan-gate.js"; import { type BindingDeclaration, type FrameworkId } from "./schema.js"; /** * The one narrow framework-adapter contract (D6): inspect, resolve, plan, * provision, verify, remove, report. There is no general-purpose arbitrary * installer — every adapter is one of the four D6 types, and `standalone-host` * is deferred (registering one throws). * * `provision` requires a {@link ScanDisposition} BY TYPE — it is not callable * without one — and revalidates it at runtime through the scan gate before any * upstream code could run. D8 (exactly one framework) is enforced independently * at each layer: the schema is structural, `plan` re-rejects a second framework * (layer 2), and `provision` re-rejects it again (layer 3). */ export type AdapterType = "host-plugin" | "project-skills" | "upstream-local-installer" | "standalone-host"; export declare const ADAPTER_TYPES: readonly AdapterType[]; /** Adapter types not yet implemented; registering one fails closed. */ export declare const DEFERRED_ADAPTER_TYPES: ReadonlySet; /** The world an adapter acts against: the declaration + any framework already bound. */ export interface BindingContext { declaration: BindingDeclaration; /** Framework already bound in this project (from the lock/declaration), if any. */ existingFramework?: FrameworkId; } export interface InspectRequest { treePath: string; } export interface InspectReport { framework: FrameworkId; treePath: string; notes: string[]; } export interface ResolveRequest { declaration: BindingDeclaration; } export interface BindingPlan { framework: FrameworkId; writes: BindingWrite[]; ownership: BindingOwnershipEntry[]; } export interface ProvisionRequest { context: BindingContext; resolved: ResolvedSource; } export interface ProvisionResult { lock: BindingLock; } export interface VerifyResult { ok: boolean; drift: string[]; } export interface RemoveResult { mode: "apply" | "drift-report-only"; } export interface BindingReport { framework: FrameworkId; /** * The typed, versioned Framework Card (W7 §A) — the derived, rebuildable * evidence record `lines` is rendered from. `report()` builds it; a `provision()` * persists it beside the lock (O8). See {@link FrameworkCard}. * * OPTIONAL: adapters may return lines-only while their card rendering is * being migrated, so consumers must treat `card` as possibly absent. */ card?: FrameworkCard; lines: string[]; } export interface FrameworkAdapter { readonly framework: FrameworkId; readonly adapterType: AdapterType; inspect(request: InspectRequest): InspectReport | Promise; resolve(request: ResolveRequest): Promise; plan(context: BindingContext): BindingPlan; provision(request: ProvisionRequest, disposition: ScanDisposition): Promise; verify(context: BindingContext): VerifyResult; remove(context: BindingContext): RemoveResult; report(context: BindingContext): BindingReport; } /** Adapter-registry violation (deferred type, unknown type, duplicate framework). */ export declare class BindingAdapterRegistryError extends AihError { constructor(message: string); } /** * D8 layer 2 — `plan` must call this so a plan for a second methodology framework * is rejected before any work is scheduled. */ export declare function assertPlanAllowed(context: BindingContext): void; /** * D8 layer 3 + the D12 scan-gate invariant — `provision` must call this before it * runs any upstream code: re-reject a second framework, then require the exact * source disposition to be genuine, allow, and digest-matched. */ export declare function assertProvisionAllowed(request: ProvisionRequest, disposition: ScanDisposition): void; /** * Registry of the five D6 adapter types, keyed by framework (exactly one adapter * per framework). A deferred type or an unknown type is refused at registration. * Registered adapters are dispatched through a provision guard (see * {@link guardProvision}). */ export declare class AdapterRegistry { private readonly byFramework; register(adapter: FrameworkAdapter): void; get(framework: FrameworkId): FrameworkAdapter | undefined; has(framework: FrameworkId): boolean; frameworks(): FrameworkId[]; }