Skip to main content

Module attempt

Module attempt 

Source
Expand description

SQLite dialect-forked queries for the attempt hot path.

Populated in Phase 2a.2 per RFC-023 §4.1. The SQL strings are module-level consts so backend.rs call sites reference them by name and cross-dialect review lines them up against the PG reference at ff-backend-postgres/src/attempt.rs statement-by- statement.

§Dialect translation summary

PG patternSQLite fork
FOR UPDATE SKIP LOCKEDBEGIN IMMEDIATE txn + plain SELECT (§4.1 A3)
text[] @> ARRAY[...]junction-table SELECT + Rust subset match (A4)
jsonb_build_object(...)json_set(raw_fields, '$.field', ?)
BIGSERIAL RETURNINGINTEGER PRIMARY KEY AUTOINCREMENT + RETURNING
BYTEA bindsBLOB binds (sqlx auto-encodes &[u8])

§Fence-triple contract

BEGIN IMMEDIATE on SQLite escalates the txn to RESERVED, so the single-writer invariant (§3.2) holds for the full read-modify-write window. Fence CAS is expressed as a plain SELECT of the attempt row’s lease_epoch under the txn lock; a mismatch against the caller’s handle surfaces as ff_core::engine_error::ContentionKind::LeaseConflict without retrying (it is a semantic conflict, not transient busy).