Bracket one bridge transaction with `atomic-bridge` enter/leave. The watcher enters the `atomic-bridge` state before `body` runs. On success or failure the state is left exactly once, and because the bracket closes with a cancel (not a change query), every filesystem write performed inside the span is discarded rather than surfaced — self-event suppression without a reconciliation loop. If the e
(
watcher: &mut dyn FileWatcher,
operation_id: &str,
body: impl Future<Output = Result<T, E>>,
)
| 40 | /// If the enter call itself fails, `body` still runs: watching is optional and |
| 41 | /// must never weaken safety. If the body fails, the state is still released. |
| 42 | pub async fn with_bridge_state<T, E>( |
| 43 | watcher: &mut dyn FileWatcher, |
| 44 | operation_id: &str, |
| 45 | body: impl Future<Output = Result<T, E>>, |
| 46 | ) -> Result<T, E> { |
| 47 | if let Err(error) = watcher |
| 48 | .begin_turn(&bridge_state_session(operation_id)) |
| 49 | .await |
| 50 | { |
| 51 | log::warn!( |
| 52 | "atomic-bridge state-enter failed for operation {operation_id}: {error}; \ |
| 53 | continuing without the optional accelerator" |
| 54 | ); |
| 55 | } |
| 56 | |
| 57 | let outcome = body.await; |
| 58 | |
| 59 | // Failure cleanup and success exit both leave the state. Cancel instead of |
| 60 | // end_turn: bridge-originated writes inside the span are suppressed rather |
| 61 | // than reported as turn changes. |
| 62 | if watcher.is_active() { |
| 63 | if let Err(error) = watcher.cancel_turn().await { |
| 64 | log::warn!("atomic-bridge state-leave failed for operation {operation_id}: {error}"); |
| 65 | } |
| 66 | } |
| 67 | outcome |
| 68 | } |
| 69 | |
| 70 | /// Synchronous bracket for CLI bridge commands. |
| 71 | /// |
no test coverage detected