/** * Guard / Retry Blocks, Status Probes, and Timeout Blocks * * Provides evaluator methods for the four recovery-related AST nodes: * - `GuardBlock` (`guard { body }` / `guard { body }`) * - `RetryBlock` (`retry { body }` / `retry { body }`) * - `StatusProbe` (`$x.!`, `$x.!code`, `$x.!message`, ...) * - `TimeoutBlock` (`timeout { body }` / `timeout { body }`) * * Interface requirements: * - Guard catches `RuntimeHaltSignal` at block boundary, appends a * `guard-caught` trace frame, returns the invalid value as block * result. * - Retry re-enters its body on caught halt up to N attempts; * appends one `guard-caught` frame per failed attempt. * - `` filter: non-matching halts propagate (NOT * caught). * - Status probes bypass the access-halt gate and read the sidecar * directly. * - `error "..."` and `assert` raise non-catchable halts: guard / * retry re-throw them unconditionally. * - TimeoutBlock creates a fresh AbortController, chains it to ctx.signal, * arms a wall-time (total) or idle-tick (idle) timer, and on expiry * aborts the controller and throws a catchable halt carrying * #TIMEOUT_TOTAL or #TIMEOUT_IDLE. * * @internal */ import type { GuardBlockNode, RetryBlockNode, StatusProbeNode, TimeoutBlockNode } from '../../../../types.js'; import type { RillValue } from '../../types/structures.js'; import type { EvalState } from '../state.js'; /** * Evaluate a guard block. * * Runs the body once. On a catchable halt whose code matches the * optional `onCodes` filter, appends a `guard-caught` trace frame * and returns the invalid value as the block result. Non-matching * halts and non-catchable halts (error / assert) propagate. */ export declare function evaluateGuardBlock(s: EvalState, node: GuardBlockNode): Promise; /** * Evaluate a retry block. * * Re-enters the body up to `node.attempts` times. Each caught halt * that matches the `onCodes` filter appends one `guard-caught` * frame to a running invalid value and advances to the next * attempt. On success, returns the body's result. If every attempt * halts, returns the final invalid value with all N frames. * * A `RetryBlock` node with `attempts <= 0` (only reachable via * host-synthesised AST; the parser rejects `limit: N` for N < 1) executes * zero times and returns an invalid `#R001` (programmer error). */ export declare function evaluateRetryBlock(s: EvalState, node: RetryBlockNode): Promise; /** * Evaluate a status probe (`.!`, `.!code`, `.!message`, `.!provider`, * `.!trace`, `.!`). * * Bypasses the access-halt gate: reading the sidecar of an invalid * value is the one access site that must NOT halt. Instead, the * probe materialises sidecar metadata as an ordinary RillValue. * * Projection semantics: * - bare `.!` -> bool: `false` when valid, `true` when invalid * (`$valid.!` is `false`). * - `.!code` -> `:atom` atom value. * - `.!message` -> string. * - `.!provider` -> string. * - `.!trace` -> list of trace-frame dicts. * - `.!` -> lookup in `status.raw`; missing key yields `""`. */ export declare function evaluateStatusProbe(s: EvalState, node: StatusProbeNode): Promise; /** * Evaluate a timeout block. * * Validates that `node.duration` evaluates to a `duration` value. * Creates a fresh `AbortController` for the timeout scope, chains it to * `ctx.signal` via `AbortSignal.any` so either side can cancel. Arms a * `setTimeout` (total) or idle-tick (idle) timer via `ctx.scheduler` when * injected, falling back to the global scheduler. * * On expiry: the chained controller is aborted and a catchable * `RuntimeHaltSignal` carrying `#TIMEOUT_TOTAL` or `#TIMEOUT_IDLE` is * thrown. The host body runs under the chained signal so * cooperative host functions observing `ctx.signal` halt naturally. * * Non-catchable halts (RILL_R010, error, assert) and ControlSignal * subclasses propagate through unchanged. */ export declare function evaluateTimeoutBlock(s: EvalState, node: TimeoutBlockNode): Promise;