/** * Registry compareAndSwap CAS adapter — opaque registry/version token discipline over host-injected I/O. * * Uses executeIfUnchanged (conditional-write.ts). Does not invent a parallel outcome shape. * Token format is opaque to the guard (string equality only). * * Token encoding (this adapter only; not interpreted by the core): * registry:v1: * Missing / empty token → REGISTRY_ABSENT_TOKEN. * * HONESTY: this adapter never talks to a registry client. The host callback performs * compareAndSwap(expected, newValue) (or equivalent) and reports {swapped|conflict}. * The adapter only normalizes tokens and maps the report onto ExecuteIfUnchangedOutcome. * * No registry SDKs — all I/O is host-injected. */ import { tokensEqual, type ExecuteIfUnchangedOutcome, type VersionToken } from '../conditional-write.js'; /** Prefix for this adapter's opaque tokens (equality-only outside this module). */ export declare const REGISTRY_VERSION_TOKEN_PREFIX = "registry:v1:"; /** * Token used when the registry key is absent / unversioned. * Hosts that measured absence should pass this as expected_token for first put. */ export declare const REGISTRY_ABSENT_TOKEN: VersionToken; /** * Build a VersionToken from a host registry revision / generation / etag-like value. * null / undefined / empty → REGISTRY_ABSENT_TOKEN. */ export declare function createRegistryVersionToken(token: string | number | bigint | null | undefined): VersionToken; /** Raw value embedded in a registry:v1: token (for host CAS APIs). Absent → null. */ export declare function registryTokenRaw(token: VersionToken | null | undefined): string | null; /** * Host report after compareAndSwap (or equivalent). */ export type RegistryHostCasReport = { swapped: true; /** New registry token after successful swap; null/omit when unknown. */ new_token?: string | number | bigint | null; result?: T; } | { swapped: false; /** Current token if observed on conflict; omit → null (no invented token). */ current_token?: string | number | bigint | null; } | { status: 'committed'; new_token?: string | number | bigint | null; result?: T; } | { status: 'conflict'; current_token?: string | number | bigint | null; }; export type WriteRegistryIfUnchangedArgs = { /** Token measured before the host decided to write (from createRegistryVersionToken). */ expected_token: VersionToken; /** Re-read the registry key's current token. Pre-write and post-write when detect is on. */ current_token: () => string | number | bigint | null | Promise; /** * Host compareAndSwap. Receives the raw expected token for the CAS call. * Adapter does not invoke any registry client. */ compareAndSwap: (ctx: { expected: string | null; expected_token: VersionToken; }) => RegistryHostCasReport | Promise>; /** * Opt-in post-commit detection (default false). * When host omits new_token on success, detection is a no-op. */ detect_stale_during_commit?: boolean; }; export type RegistryWriteResult = { new_token: string | null; result: T | undefined; }; /** * Conditional registry write: re-read token; if matches → host compareAndSwap. * * Mapping (host report → ExecuteIfUnchangedOutcome): * swapped:true / status:committed → committed * swapped:false / status:conflict → refused / stale_version_token * current_token from host when supplied, else null * * Wired through executeIfUnchanged — not a parallel path. */ export declare function writeRegistryIfUnchanged(args: WriteRegistryIfUnchangedArgs): Promise>>; /** Re-export equality helper for hosts comparing tokens without importing core module. */ export { tokensEqual }; //# sourceMappingURL=registry.d.ts.map