/** * Check-column polling gate: diffs the narrow row-check read against the * expected row-check strings derived from canonical SQLite state. * * The User_Input tab carries a system-written per-row token-join formula in * the check column (see contracts `sheets/rowCheck.ts`). The inbound * polling preflight reads ONLY the identity + anchor + check column bands, * and this module decides per table: * * - `escalate` — the table cannot be gated: no provisioned check column * (legacy tab: mixed mode keeps the historical whole-table metadata * observation), or any row whose identity is invalid, duplicated, or * unknown, or an active canonical entity that is no longer visible, or * any system row-id (anchor) anomaly (deleted, duplicated, or moved off * its binding). Anchors escalate because only the whole-table * observation produces the authoritative row-mapping/orphan evidence. * - `targeted` — only value-mismatched rows exist: the caller re-reads * ONLY those physical rows (multi-range band, metadata-preserving) and * feeds them through the historical inspector/evaluator unchanged. A row * with no visible check value (a legacy row created before the column * existed, or one whose formula a human removed or REPLACED WITH A * LITERAL — the provider reports check evidence only while the cell * still holds the exact generated formula) mismatches and is therefore * included — the per-row mixed mode. * - `clean` — every visible row's check equals the value derived from its * canonical state: NO data-column read happens this pass. * * Why the expectation is DERIVED from canonical state at read time instead * of stored per row at write time: the user_input effect payload always * carries the FULL user field set (reconcile semantics), and canonical * `entity_field_state` holds exactly the values the last planned write * shows once delivered — so an insert, an update-like write, and a * probe/redrive outcome all re-derive the expectation for free. A stored * copy (row_binding column or new table) would duplicate canonical state, * need v9 migration surgery, and REQUIRE correct bookkeeping on every * delivery outcome; the derivation cannot drift. * * The one case canonical derivation CANNOT see ahead of is a delivery that * has not landed yet: while an own write is in flight the Sheet still * (correctly) shows the PRE-write values, so a derived expectation would * mismatch, the targeted read would observe the stale projection, and the * inspector's forceConflict rule (advanced canonical revision) would * fabricate a conflict against our own write. The gate therefore consults * the durable outbox: a mismatched row whose binding still has an * in-flight effect (pending/processing/delivery-uncertain/retryable * failed) is a PENDING DELIVERY, not human input, and is skipped without * any read. Human input stays protected: the worker's field-level CAS * evidence refuses a delivery whose remote changed mid-flight (the * delivery pipeline, not this gate, arbitrates that race), and after * delivery the row's check simply mismatches again and escalates normally. */ import type { ReadSyncRowChecksRequest, SyncRowChecksResult } from "../../../../contracts/sheets/syncSheets.js"; import type { TypedSheetsEntityMapping } from "../../../../contracts/sync-orm/mapping/contracts.js"; import type { MappedPollingState } from "./MikroOrmUserInputPollingState.js"; /** Outcome kind of one gated table. */ export declare const CHECKS_POLLING_DECISION_KINDS: { /** Every visible row matches its expected check; skip the table. */ readonly CLEAN: "clean"; /** Only these physical rows mismatch; read them targeted. */ readonly TARGETED: "targeted"; /** The gate cannot prove the table; run the historical whole-table read. */ readonly ESCALATE: "escalate"; }; export type ChecksPollingDecisionKind = (typeof CHECKS_POLLING_DECISION_KINDS)[keyof typeof CHECKS_POLLING_DECISION_KINDS]; /** Result of one gated table comparison. */ export interface ChecksPollingDecision { readonly kind: ChecksPollingDecisionKind; /** 1-based physical rows to re-read (only non-empty when targeted). */ readonly rowNumbers: readonly number[]; /** Rows the narrow read saw (report accounting only). */ readonly rowsScanned: number; /** Rows whose check mismatched their expected value. */ readonly changedRows: number; } /** Builds the narrow row-check request for one mapped user_input route. */ export declare function toRowChecksRequest(mapping: TypedSheetsEntityMapping): ReadSyncRowChecksRequest; /** * Decides one table's polling read shape from its narrow check result. * Never mutates state; every escalation condition mirrors the historical * values-only preflight so conflict/observation outcomes are unchanged. */ export declare function inspectChecksPollingTable(mapping: TypedSheetsEntityMapping, result: SyncRowChecksResult, state: MappedPollingState): ChecksPollingDecision; //# sourceMappingURL=MikroOrmUserInputPollingChecks.d.ts.map