import { RegistryKey } from "./keys.mjs";
//#region src/services/registry/confirm.d.ts
/**
 * The publish-confirmation state machine: a registry write is verified, not
 * assumed. Every leg the publish wrote — the runtime config always, the
 * manifest tag and its version record on release trains — must read back
 * byte-equal before the publish counts, because FastKV writes are
 * action-indexed: the on-chain transaction's execution is irrelevant
 * (CodeDoesNotExist is the designed success path), the read-back is the
 * only authority.
 *
 * States: Pending → Indexed (the tx is visible in the registry's history;
 * the cheap probe) → Verified (every leg reads back deep-equal) | TimedOut
 * (deadline; the unverified legs are named). Two provisions carry over from
 * the polling loop this replaces: the history probe is informative only —
 * after two informative-but-absent probes, or any history failure, the
 * machine falls back permanently to plain content polling, so a registry
 * whose history never carries the tx still verifies; and a leg read failure
 * never skips the leg — it retries until the deadline. The transaction probe
 * is consultative: it runs only after a content miss and may terminate a
 * wait content has already failed to satisfy, never preempt a verify — the
 * read-back outranks it (a landed publish executes with CodeDoesNotExist on
 * the codeless namespace and that is success).
 */
type ConfirmLegKind = "runtimeConfig" | "manifest" | "version";
/** The submit's transaction as the chain sees it, from the `txStatus` seam.
 * `invalid` is explicit rejection (stale nonce, expired); `unknown` means no
 * node has the transaction; `unreachable` is a failed status probe — always
 * treated as informative-only, never proof of anything. */
type TxStatus = "included" | "invalid" | "unknown" | "unreachable";
interface ConfigConfirmLeg {
  readonly kind: ConfirmLegKind;
  readonly key: RegistryKey;
  /** The expected value — the exact publish payload (deep-equality via
   * JSON compare; the registry serves the written value verbatim). */
  readonly expected: unknown;
  /** Overrides the default keyed read — the manifest/version legs read
   * through pointer.ts's transports (the train binds account/gateway and
   * the registry override); the config leg reads through the injected
   * `read` seam. */
  readonly read?: () => Promise<unknown>;
}
type ConfirmLeg = ConfigConfirmLeg;
type ConfirmVerdict = {
  readonly ok: true;
  readonly verified: readonly ConfirmLegKind[];
} | {
  readonly ok: false;
  readonly unverified: readonly ConfirmLegKind[];
  readonly lastError?: string;
  /** The transaction reached a terminal-unapplied outcome — rejected on-chain
   * or dropped at broadcast (most often a stale nonce). The registry was
   * never written; content polling is pointless. The caller may resubmit
   * identical bytes. */
  readonly terminalTx?: true;
};
interface ConfirmOptions {
  readonly legs: readonly ConfirmLeg[];
  /** The submit's tx hash (#430) — enables the indexed-probe fast path. */
  readonly txHash?: string;
  readonly timeoutMs?: number;
  readonly intervalMs?: number;
  /** Seams — tests substitute fakes; production defaults to the client. */
  readonly read?: (key: RegistryKey) => Promise<unknown>;
  readonly history?: (key: RegistryKey, limit: number) => Promise<Array<{
    txHash?: string;
  }>>;
  /** The submit's transaction status as the chain sees it. `invalid` and an
   * `unknown` state persisting past {@link TX_UNKNOWN_GRACE_MS} end the wait
   * early with a terminal verdict; everything else keeps content polling. */
  readonly txStatus?: (txHash: string) => Promise<TxStatus>;
  readonly now?: () => number;
  readonly sleep?: (ms: number) => Promise<void>;
}
/** How long a transaction may stay unknown to the chain before the wait is
 * declared terminal: a broadcast that landed is visible within seconds; one
 * still unknown past this grace was dropped (most often a stale nonce from a
 * lagging RPC at broadcast) and will never apply. */
declare const TX_UNKNOWN_GRACE_MS = 30000;
declare function confirmPublish(opts: ConfirmOptions): Promise<ConfirmVerdict>;
/** The train-facing failure message — the wire form of `TimedOut` (#422's
 * confirm channel): the legs' actual wire keys, named. */
declare function describeConfirmTimeout(legs: readonly ConfirmLeg[], verdict: Extract<ConfirmVerdict, {
  ok: false;
}>): string;
//#endregion
export { ConfigConfirmLeg, ConfirmLeg, ConfirmLegKind, ConfirmOptions, ConfirmVerdict, TX_UNKNOWN_GRACE_MS, TxStatus, confirmPublish, describeConfirmTimeout };
//# sourceMappingURL=confirm.d.mts.map