/** * Implicit system-wins conflict resolution for the mapped sync path. * * A detected User_Input conflict is never resolved by polling alone. The first * observation persists an OPEN conflict, its active candidate, the * candidate-time full-row visible evidence, and a durable OPEN Sync_Conflicts * audit effect; no resolution command is created. Only a later canonical field * revision increase on the SAME conflicted field (planned by the mapped flush * hook inside the flush transaction) is an implicit system-wins trigger: the * conflict is rebased to NEEDS_REBASE and a revision-identified * acknowledge_system command is planned from the stored candidate evidence. * * Pending commands are durable retry records: a processing or * delivery_uncertain predecessor defers the exact command, and later polling * passes reconstruct the identical command from the stored conflict row. * Legacy `sync:auto-system-wins` pending commands and obsolete revision * generations are staled idempotently without resolving the conflict. */ import type { NormalizedCell } from "../../contracts/encoding/types.js"; import type { ResolutionCommand, SyncConflict } from "../../contracts/domain/model/types.js"; import { type TypedSheetsEntityMapping } from "../../orm/mapping/entityMapping.js"; import type { ResolvedWriterOptions } from "../../orm/persistence/support/contracts.js"; import { type FencingContext } from "@hikoutei/ikisaki"; import type { SqlExecutor, SqlStorageAdapter } from "../../contracts/storage/sql.js"; /** Actor identity recorded on every implicit system-wins resolution command. */ export declare const SYSTEM_WINS_ACTOR_ID = "sync:system-wins"; /** Actor identity recorded by the retired creation-time auto resolver. */ export declare const LEGACY_AUTO_SYSTEM_WINS_ACTOR_ID = "sync:auto-system-wins"; /** Command identity prefix of the retired creation-time auto resolver. */ export declare const LEGACY_AUTO_SYSTEM_WINS_COMMAND_PREFIX = "auto-system-wins:"; /** Command identity prefix of the revision-identified implicit resolver. */ export declare const SYSTEM_WINS_COMMAND_PREFIX = "sync:system-wins:"; /** Renews the startup resolver fence without accepting a silent epoch takeover. */ export declare function renewAutomaticConflictResolutionLeaseWithSql(sql: SqlExecutor, fence: FencingContext, writer: ResolvedWriterOptions): Promise; /** * Plans the durable OPEN Sync_Conflicts audit effect for newly detected * conflicts inside the caller's SQLite transaction. * * This is the only audit work a detection performs: zero resolution commands * are created, so polling and restart alone can never resolve a conflict. */ export declare function planOpenConflictAuditEffectsWithSql(sql: SqlExecutor, fence: FencingContext, writer: ResolvedWriterOptions, mapping: TypedSheetsEntityMapping, conflictIds: readonly string[]): Promise; /** * Decides whether a committed canonical field change is an implicit * system-wins trigger for an unresolved conflict. * * Only a REAL field revision increase on the SAME conflicted field counts: * the new revision must strictly exceed the conflict's current canonical * revision and the committed value must differ from the current canonical * value. Unrelated fields and same-value/no-revision updates never trigger. */ export declare function shouldTriggerImplicitSystemWins(conflict: SyncConflict, nextFieldRevision: number, nextFieldValue: NormalizedCell): boolean; /** * Returns the durable command identity for one implicit system-wins attempt. * * The identity embeds the conflict ID, the active candidate epoch, and the * current canonical revision, so a newer same-field commit plans a strictly * newer command that supersedes any older pending generation. */ export declare function systemWinsCommandId(conflict: SyncConflict): string; /** Returns the deterministic commit ID shared by one system-wins command and its effects. */ export declare function systemWinsCommitId(conflict: SyncConflict): string; /** * Builds the exact implicit system-wins command for one conflict row. * * The command is fully derived from durable conflict state (candidate hash, * epoch, current canonical revision), so a deferred command can be * reconstructed byte-for-byte on later retries. */ export declare function systemWinsCommandFor(conflict: SyncConflict): ResolutionCommand; /** * Plans rebase, audit, and implicit system-wins work after one mapped flush. * * Runs inside the same SQLite transaction that committed the entity change. * For every changed field with an OPEN/NEEDS_REBASE active candidate, a real * revision increase rebases the conflict to NEEDS_REBASE (with the committed * value, revision, and commit ID), appends the durable NEEDS_REBASE audit * effect, and plans the revision-identified system-wins command. Conflicts * without stored candidate evidence are never guessed: they stay rebased for * human resolution. */ export declare function planMappedFlushConflictSyncWithSql(sql: SqlExecutor, fence: FencingContext, writer: ResolvedWriterOptions, mapping: TypedSheetsEntityMapping, input: { readonly entityId: string; readonly rowBindingId: string; readonly commitId: string; readonly changedFieldNames: readonly string[]; readonly suppressedUserProjection: boolean; }): Promise; /** * Retries durable pending system-wins commands after later polling passes. * * Legacy `sync:auto-system-wins` pending commands are staled idempotently * without resolving their conflicts. New-style pending commands are * reconstructed exactly from the stored conflict row and re-issued; an * obsolete revision generation is staled. A still-in-flight predecessor keeps * the exact command pending for the next pass. Manual or unknown pending * commands are never touched by polling. */ export declare function retryOpenMappedConflictsWithAdapter(storage: SqlStorageAdapter, mappings: readonly TypedSheetsEntityMapping[], writer: ResolvedWriterOptions): Promise; //# sourceMappingURL=autoSystemConflictResolution.d.ts.map