/** * Correction effect generation for the reconciliation scanner. * * Plans a normal system_projection effect per drift against the latest outbox * and visible-state evidence, so the correction is applied by the same * CAS-guarded slow path as regular writes. The expected visible hash/revision * in each effect comes from the most recent outbox item (an in-flight or * uncertain write) or from the confirmed visible state, never from the stale * snapshot that triggered the drift. */ import type { NewEffect } from "@hikoutei/ikisaki"; import type { SqlExecutor } from "../../../../contracts/storage/sql.js"; import type { SyncSnapshotRow } from "../../../../contracts/sheets/syncSheets.js"; import { type DesiredRow, type LatestVisibleSqlShape, type ScanContext } from "./shared.js"; import type { DriftTarget } from "./diff.js"; export declare function buildCorrectionEffects(context: ScanContext, sheet: { readonly tabName: string; readonly registeredRange: string; }, drifts: readonly DriftTarget[]): Promise; /** * One desired row awaiting a failed-head repair plus its observed snapshot * evidence (a clean row whose Sheet state already matches canonical). */ export interface FailedHeadRepairTarget { readonly desired: DesiredRow; /** * The observed snapshot row for a clean (already matching) row, so the * repair plan can guard on the row's current visible hash even when no * confirmed visible evidence exists. `undefined` when the row was not * observable in the snapshot. */ readonly observed: SyncSnapshotRow | undefined; } /** * Plans the stream repair for one desired row whose Sheet state already * matches canonical but whose stream is wedged behind a terminal failed head. * * The failed head blocks every follower through the durable predecessor * guard while the drift path never plans a repair for a row that already * matches, so this replans the same correction contract without a drift: an * equivalent correction already in flight behind the head produces a * supersede-only plan; otherwise a fresh correction effect is returned that * supersedes the head when it is appended. Returns null when a concurrent * pass already superseded the head. */ export declare function buildFailedHeadRepairPlan(context: ScanContext, sheet: { readonly tabName: string; readonly registeredRange: string; }, target: FailedHeadRepairTarget, commitId: string): Promise; /** * One reconciliation correction and the durable transition it requires. * * `supersedeFailedEffectId` is set only when a terminal (non-recoverable) * failed effect blocks the target stream and must be superseded so the * repair can become (or unblock) the stream head. Recoverable failed heads * stay on the worker retry path and are never superseded. */ export interface CorrectionPlan { /** * The correction effect to append, or null for a supersede-only plan * (the in-flight correction that already covers this drift is unblocked * by superseding the terminal failed head with its effect id). */ readonly effect: NewEffect | null; readonly supersedeFailedEffectId: string | null; readonly supersedeByEffectId: string | null; } export interface CorrectionBaseline { readonly skip: boolean; readonly expectedVisibleRevision: number; readonly expectedVisibleHash: string; readonly createIfMissing: boolean; readonly streamSequence: number; /** * Terminal failed stream head to supersede when appending this correction. * * `null` means append normally. Set only when an active `failed` effect with * a non-recoverable error code blocks the target stream, so the correction * can supersede that head and become the new stream head instead of being * blocked behind the terminal failed predecessor forever. */ readonly supersedeFailedEffectId: string | null; /** * Existing effect that owns the stream after the failed head is superseded. * * Set only when the baseline skips appending (an equivalent correction is * already in flight behind the failed head). The failed head is superseded * with this effect id so the blocked correction becomes claimable. */ readonly supersedeByEffectId: string | null; } export declare function resolveCorrectionBaseline(context: ScanContext, desired: DesiredRow, observed: SyncSnapshotRow | undefined): Promise; export declare function resolveCorrectionBaselineWithSql(sql: SqlExecutor, context: ScanContext, desired: DesiredRow, observed: SyncSnapshotRow | undefined): Promise; export declare function baselineFromVisible(visible: LatestVisibleSqlShape | undefined, streamSequence: number, observed: SyncSnapshotRow | undefined, systemFields: readonly string[] | undefined): CorrectionBaseline; export declare function extractTargetVisibleHash(payloadJson: string): string; //# sourceMappingURL=repair.d.ts.map