/** * Centralised Access-Halt Gate * * Provides the gate helper that every invalid-value access site routes * through. When a RillValue carries a non-`#ok` status sidecar * (`isInvalid(value) === true`), any of the following access sites must * call this gate to convert the implicit halt into an explicit runtime * halt signal: * * - pipe (`$invalid -> ...`) * - field projection (`$invalid.field`) * - index access (`$invalid[0]`) * - arithmetic / comparison * - spread (`...$invalid`) * - function argument (`fn($invalid)`) * * The gate appends an `access`-kind TraceFrame to the value's status * sidecar and throws a catchable `RuntimeHaltSignal`. Guard / retry * blocks catch the signal and recover the invalid value; any other * frame lets the signal propagate. * * Interface requirements: * - Access on invalid value halts (catchable by guard / retry). * - Status-probe sites (`.!`, `.!field`) bypass the gate entirely. * * Wiring into the evaluator base (pipe / field / index / spread / arg / * arith call sites) is owned by task 2.2; this task only exports the * gate helper and the halt-signal type. * * @internal */ import type { SourceLocation } from '../../../../types.js'; import { RuntimeHaltSignal } from '../../types/halt.js'; import type { RillValue } from '../../types/structures.js'; /** * `RuntimeHaltSignal` is re-exported so existing imports from this * module continue to compile. The canonical definition lives in * `types/halt.ts` (the type-layer primitive shared with the type-halt * builder used by evaluator handlers and standalone type helpers). */ export { RuntimeHaltSignal }; /** * Describes the access site for trace-frame population. * * `fn` is free-form: operator symbol (`"->"`, `"."`, `"[]"`, `"..."`, * `"+"`), host fn name, or method name. Empty string when not * applicable; matches the TraceFrame.fn contract. */ interface AccessSite { readonly location?: SourceLocation | undefined; readonly sourceId?: string | undefined; readonly fn: string; } /** * Formats a source location into `file:line:col` form, matching the * TraceFrame.site contract. Used by the access gate to populate * `access` frames. * * Falls back to `""` when no location is available (e.g., * synthesized nodes). `sourceId` defaults to `"