pub fn derive_inverse_command(
forward: &Command,
step: &UnresolvedStep,
) -> Option<Command>Expand description
Map a forward Command to its compensating inverse, given the
recorded step row (which carries the forward command’s emitted
events in output_json, useful for Create* → extract-new-id →
Delete*).
Returns None for commands whose inverse cannot be derived from
the saga log alone (caller logs + skips). Documented limitations:
MoveTabandMoveBlock: we don’t know the source’sdst_indexthe tab/block was originally at, so we can’t perfectly restore the prior order. We construct a swap that at least returns the tab/block to its source — index 0. This is incorrect for re-ordering inverses but acceptable for the common tear-off case (where the source workspace’s order is not the saga’s concern; the saga only cares the tab is back insrc).- Any
Delete*: not invertible — un-deleting requires reconstructing the deleted entity’s full state, which is gone from the saga log by definition. Update*Meta,Rename*,SetActiveTab, etc: pure-state patches whose inverse needs the prior value. The saga log doesn’t capture pre-state today (deferred to a future spec bump).