import { type RequestArtifactState } from './request-artifact-state-helpers.js'; import type { RequestArtifactRole } from './artifact-templates.js'; export type StateOrderBreach = { /** `jump` — the move skips past an intermediate state. `unreadable` — the * current state could not be read, so the move cannot be shown to be legal. */ kind: 'jump' | 'unreadable'; /** The states this move skips over. Empty for `unreadable`. */ skipped: ReadonlyArray; /** The one legal next state from a READABLE current one, else `null`. */ next: RequestArtifactState | null; }; /** * `null` when the move is allowed, or the breach when it is not. * * FAIL-CLOSED on an unreadable current state. A carrier with no `- state:` line * reads as the literal `'unknown'` (the `readArtifactState(...) ?? 'unknown'` * fallback in the transition service), and this gate runs before every other * one. Reading "I could not read it" as "no jump" would therefore hand the gate * an off-switch that is one deleted line — re-opening the `rd → handed-off` jump * this module exists to stop — so an unreadable state is refused, not allowed. */ export declare function stateOrderViolation(role: RequestArtifactRole, from: string, to: RequestArtifactState): StateOrderBreach | null; /** The breach kinds get their own codes: a refusal that cannot be named is a * refusal a consumer cannot act on, and "jumped" is not "could not be read". */ export declare const STATE_ORDER_JUMP_CODE = "STATE_ORDER_JUMP"; export declare const STATE_ORDER_UNREADABLE_CODE = "STATE_ORDER_UNREADABLE"; export declare class StateOrderViolationError extends Error { readonly code: string; readonly role: RequestArtifactRole; readonly from: string; readonly to: RequestArtifactState; readonly skipped: ReadonlyArray; readonly kind: StateOrderBreach['kind']; constructor(role: RequestArtifactRole, from: string, to: RequestArtifactState, breach: StateOrderBreach); } /** Throws when `to` skips an intermediate state or the current state is * unreadable. `bypass` is the caller's `--allow-incomplete` escape hatch. */ export declare function assertLegalStateStep(role: RequestArtifactRole, from: string, to: RequestArtifactState, bypass: boolean): void;