Expand description
Phase E.2c.2 reducer-dispatch helpers shared by the service handlers and
(via crate::server::service::β¦) the sagas.
FunctionsΒ§
- compensate_
via_ πreducer - Compensation helper: dispatch a command into the reducer and apply its emitted events to mstore best-effort. Used when an earlier sync apply partially wrote SQLite and we need to undo the leaked rows. SQLite errors during compensation are logged but ignored β the caller is already returning an error to the client; throwing on the cleanup just hides the original cause. (codex P1 + reagent P2 #616 β partial-write cleanup.)
- dispatch_
to_ πreducer - Dispatch a command into the srv reducer and return the emitted events. Locks the reducer mutex briefly; the lock is released before any I/O (caller is responsible for publishing the events to the broadcast bus).
- mstore_
workspace_ πexists - Existence check used by
DeleteWorkspaceto decide whether to run the wcore delete path. PropagatesStoreErrorso the caller can surface real I/O / corruption failures instead of misclassifying them as βnot foundβ (codex P2 #615 carryover β the priorboolreturn collapsedErr(_)intofalse, which led to silent successes when SQLite was unhealthy: reducer would delete its own copy and report success while the disk row was never touched). - publish_
events π - Publish each event on the srv broadcast bus. Failures (no subscribers) are non-fatal.
- queue_
layout_ πactions_ via_ reducer - SPEC_864 Phase 4 β single-writer queue append. Dispatch a
LayoutQueueBackendActionsand persist the resultingLayoutBackendActionsQueuedinside ONE hold of the reducer mutex (same critical-section contract asseed_layout_via_reducer), so a concurrent frontend ACK slice (LayoutSetTreeREPLACE) canβt interleave between dispatch and persist. Replaces the five store-directpendingbackendactionswriters (layout_helpersβ insert/split/delete queuers + the two inline app_api sites). - seed_
layout_ πvia_ reducer - SPEC_864 Phase 3 β single-writer layout seeding. Dispatch a
LayoutSetTree(tree + focus + leaforder as client slices) and persist it inside ONE hold of the reducer mutex, so persist order equals dispatch order β the same contract asUpdateObjectβs Phase-2 route inobject.rs. Replaces the wcore-direct seeders (write_default_three_pane_layoutpost-bootstrap caller,setup_torn_off_block_layout): the reducerβsTabRecord.rootnodeis authoritative, and the persist subscriber is the soledb_layoutwriter on this path.