/** * Resource lifecycle engine — executeResource(). * * Drives the check-then-apply lifecycle for all resources with policy-driven * timeout and retry support. Enforces the idempotence contract. * * Supports an optional non-authoritative check result cache. Cache is * advisory for check mode only — apply mode always performs a live check. * * **Idempotence contract enforcement**: * - check() is called first (read-only, side-effect free). * - If inDesiredState === true, apply() is skipped → status "ok". * - If inDesiredState === false and mode is "apply", apply() is called → status "changed". * - Resources that cannot safely prove desired state during check() should * conservatively return inDesiredState === false and decide in apply(). * - A convergent resource: after apply(), a subsequent check() returns inDesiredState: true. */ import type { ExecOptions, ExecutionContext, ResourceCallMeta, ResourceDefinition, ResourcePolicy, ResourceResult, Transport, TransportCapability } from "./types.ts"; /** * Short-circuit apply() after a conservative check(). * * Resources use this when `check()` must remain read-only but the final apply * decision depends on an apply-time precondition. The executor reports the * resource as `ok` and does not run post-check. */ export declare function skipApply(output?: TOutput): never; /** * Assert that the transport on `ctx` supports the given capability. * * Throws a typed `CapabilityError` if the capability is not available. * Resources should call this before performing operations that depend * on optional transport capabilities (e.g. 'transfer', 'fetch'). * */ export declare function requireCapability(ctx: ExecutionContext, capability: TransportCapability, resourceType: string): void; /** Resolve effective policy from per-resource override and global default. */ export declare function resolvePolicy(override?: Partial): ResourcePolicy; /** * Wrap a transport to merge default ExecOptions into every exec() call. * * Returns a new Transport that delegates all methods to the original, * merging `defaults` into the opts argument of `exec()`. Caller-provided * opts take precedence over defaults. */ export declare function wrapTransport(transport: Transport, defaults: Partial, defaultSignal?: AbortSignal): Transport; /** * Execute a single resource through the check-then-apply lifecycle. * * 1. Reports resource start to the context reporter. * 2. In check mode with cache: tries cache first, returns cached result on hit. * 3. Runs `check()` to compare current vs desired state (with timeout/retry). * 4. If already in desired state → status "ok", skip apply. * 5. If not in desired state and mode is "check" → status "changed", skip apply. * 6. If not in desired state and mode is "apply" → runs `apply()` (with timeout/retry), status "changed". * 7. On error → status "failed", error captured in result. * 8. Records timing and attempt metadata, pushes result to `ctx.results`, reports to `ctx.reporter`. * 9. In check mode with cache: stores the check result for future lookups. * 10. In "fail-fast" error mode, re-throws after recording the failure. */ export declare function executeResource(ctx: ExecutionContext, def: ResourceDefinition, input: TInput, policy?: Partial, meta?: ResourceCallMeta): Promise>; //# sourceMappingURL=resource.d.ts.map