/** * Conflict lifecycle transitions. * * Per design: conflict status is OPEN, NEEDS_REBASE, RESOLVED only. * SUPERSEDED is not a conflict status. * * - OPEN: initial state when a stale field is detected * - NEEDS_REBASE: same field's canonical value advanced while conflict is open * - RESOLVED: user submitted acknowledge_system with matching revision/hash CAS */ import type { NormalizedCell } from "../../encoding/types.js"; import type { ConflictResolutionError } from "./errors.js"; import type { ResolutionCommand, SyncConflict } from "../model/types.js"; import type { LookupResult } from "../../state/types.js"; /** Runtime values for the discriminated conflict transition result. */ export declare const CONFLICT_TRANSITION_KINDS: { readonly RESOLVED: "resolved"; readonly STALE: "stale"; readonly REJECTED: "rejected"; }; /** Closed set of outcomes produced by a conflict transition. */ export type ConflictTransitionKind = (typeof CONFLICT_TRANSITION_KINDS)[keyof typeof CONFLICT_TRANSITION_KINDS]; /** Result of attempting to transition a conflict via a resolution command. */ export type ConflictTransitionResult = { readonly kind: typeof CONFLICT_TRANSITION_KINDS.RESOLVED; readonly conflict: SyncConflict; } | { readonly kind: typeof CONFLICT_TRANSITION_KINDS.STALE; readonly conflict: SyncConflict; } | { readonly kind: typeof CONFLICT_TRANSITION_KINDS.REJECTED; readonly error: ConflictResolutionError; }; /** * Determines whether a canonical commit should trigger NEEDS_REBASE. * * Called within the same SQLite transaction that commits the canonical change. * If the same field has an OPEN or NEEDS_REBASE conflict, the conflict's * current canonical projection is updated and status set to NEEDS_REBASE. */ export declare function shouldRebaseConflict(conflict: SyncConflict, changedFieldName: string, newCanonicalRevision: number, newCanonicalValue: NormalizedCell): LookupResult; /** * Applies a resolution command to a conflict via compare-and-set. * * The command's expected revision, active candidate hash, and candidate epoch * must match the conflict's current state. The epoch prevents an old request * from resolving an ABA retry that returned to the same candidate value. If * any CAS input does not match, the conflict stays at its current status * (NEEDS_REBASE if canonical has advanced) and the checkbox is reset. */ export declare function applyResolution(conflict: SyncConflict, command: ResolutionCommand): ConflictTransitionResult; /** Computes the active candidate hash for CAS comparison. */ /** Computes the compare-and-set hash for the currently active user candidate. */ export declare function candidateHash(conflict: SyncConflict): string; //# sourceMappingURL=transitions.d.ts.map