everything-dev
Version:
A consolidated product package for building Module Federation apps with oRPC APIs.
73 lines • 3.54 kB
text/typescript
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.
*/
type ConfirmLegKind = "runtimeConfig" | "manifest" | "version" | "platformPointer";
interface ConfigConfirmLeg {
readonly kind: "runtimeConfig" | "manifest" | "version";
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;
}
interface PlatformPointerConfirmLeg {
readonly kind: "platformPointer";
/** The pre-cutover wire key (`apps/<a>/<g>/platform.json`) — named
* verbatim in the timeout message. The pointer lives outside the key
* model's union until ticket 10's cutover, so it carries its wire key
* explicitly instead of a RegistryKey. */
readonly wireKey: string;
/** The pre-cutover transport, injected — `readPlatformPointer` bound to
* the runtime; never baked into keys.ts. */
readonly read: () => Promise<unknown>;
/** The expected value — the composed release manifest the leg wrote. */
readonly expected: unknown;
}
type ConfirmLeg = ConfigConfirmLeg | PlatformPointerConfirmLeg;
type ConfirmVerdict = {
readonly ok: true;
readonly verified: readonly ConfirmLegKind[];
} | {
readonly ok: false;
readonly unverified: readonly ConfirmLegKind[];
readonly lastError?: string;
};
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;
}>>;
readonly now?: () => number;
readonly sleep?: (ms: number) => Promise<void>;
}
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, PlatformPointerConfirmLeg, confirmPublish, describeConfirmTimeout };
//# sourceMappingURL=confirm.d.mts.map