Expand description
ADR-099 migration step 3 (sub-slice B2) — the atomic runner: the
synchronous commit-pass mechanism that applies a caller-supplied sequence
of prepared write plans (crate::atomic_plan) as ONE
SqlAccess::atomic_unit, under a per-op SAVEPOINT, committing every
plan or rolling back the whole unit.
ADR-099 B3 caller: kkernel exec --ops-file --atomic — async prepare,
then this runner’s one synchronous commit pass, then async post-commit
effects. Runtime callers also supply prepared plans directly (hard-delete
in operations.rs). See docs/api/atomic_runner.md for the full
three-phase shape (ADR-099 D1).
§Safety: suspend-free invariant
run_atomic_unit is the one place in this crate that builds an
AtomicUnitOp closure for SqlAccess::atomic_unit, whose contract
requires the closure’s future to resolve on its first poll — synchronous
DML against the provided &mut dyn SqlWriter only, never a suspending
.await. Every statement driven here comes from
AtomicOpPlan::plan_statements, which can only ever produce
PlanStatements (plain parameterized SQL), so no code path in this
module can hand atomic_unit a suspending future. The paired
suspend-trap tests at the bottom of this file check both the happy-path
(real commit pass resolves on first poll) and the misuse-is-caught case
(a hand-built suspending closure fails loudly through the same seam). See
docs/api/atomic_runner.md#suspend-free-invariant for the full argument.
Structs§
- Atomic
Runner Error - A failure of the
atomic_unitseam itself — the storage layer refused or could not complete the call at all (read-only backend, no async runtime for the writer-task lookup, or anAtomicUnitOpthat violated the suspend-free invariant and got caught byblock_on_sync). Never returned for an ordinary op-level guard or SQL failure inside the unit — those surface asAtomicRunOutcome::RolledBack, not this error.
Enums§
- Atomic
OpFailure - Why a single op’s plan failed inside the commit pass (ADR-099 acceptance criteria: “the failing op index is recorded”).
- Atomic
OpPlan - One admissible op’s prepared write plan (ADR-099 D3’s v1 admissible verb
groups), ready for the commit pass. This is the
Vec<AtomicOpPlan>shaperun_atomic_unitconsumes — the runner is agnostic to which verb produced a given plan; it only needs each plan’s ordered statements (plan_statements) and any deferred post-commit effect (post_commit_effect). - Atomic
RunOutcome - The whole-unit outcome of a completed
run_atomic_unitcall — the commit pass ran to a clean, distinguishable verdict (never returned for a seam-level failure; seeAtomicRunnerErrorfor that case).
Functions§
- run_
atomic_ unit - Run
plansas ONE atomic unit (ADR-099 D1 commit pass): open a singleSqlAccess::atomic_unit, apply every plan’s statements under a namedSAVEPOINT(adr099_atomic_op_<n>), and commit all or roll back all.