def stage_command
import bendvy-ecs-core@0.1.0.4/transaction.bend as Transactionimport Base
import bendvy-ecs-core@0.1.0.4/deferred_command.bend as Deferred
38# Commands and events are accumulated in reverse and reversed once at commit.
39# Stage an owned deferred command without executing it. Commit enqueues
40# commands in authored order; failure discards them. Visibility follows the
41# command queue's explicit barrier, not transaction completion itself.
42def stage_command(~W:Type,~E:Data,tx:Tx<W,E>,command:Deferred.Command<W>) -> Tx<W,E>:
43 match tx:
44 case Tx{world,undo,commands,events,trace}:Tx{world,undo,command <> commands,events,trace}