transaction.bend checks
raw source on the hub · import 0x67fd5084c1da4adc13317822045bb11f/transaction.bend as Transaction
3 imports
import Base import ./deferred_command.bend as Deferred import ./trace_facts.bend as TraceFacts
Types
type Tx source · line 11 · raw
@W:Type -> @E:Data -> Type
Engine-owned transaction state; gameplay receives abstract providers instead. The journal owns replacement values inside affine inverse closures. Lower-level affine transaction owner with inverse journal, staged commands and Data events. Raw fields/inverses are trusted engine setup; normal gameplay uses declared opaque capabilities. Does not automatically journal arbitrary mutations or make host IO reversible.
Tx@W:Type -> @E:Data -> @world:W -> @undo:List<&1, @_:W -> W> -> @commands:List<&1, 0x67fd5084c1da4adc13317822045bb11f/deferred_command.Command<W>> -> @events:List<&2, E> -> @trace:0x67fd5084c1da4adc13317822045bb11f/trace_facts.State -> Tx<W, E>
type Outcome source · line 16 · raw
@Error:Data -> Data
System transaction decision: Success makes finish commit recorded effects; Failure makes it run recorded inverses. Does not own a World itself.
Success@Error:Data -> Outcome<Error>
Failure@Error:Data -> @error:Error -> Outcome<Error>
type Returned source · line 22 · raw
@W:Type -> @Error:Data -> Type
Finished transaction returns its World and decision on either path. Contains no body output or automatic recovery receipt for rejected payloads.
Returned@W:Type -> @Error:Data -> @world:W -> @outcome:Outcome<Error> -> Returned<W, Error>
Templates
template begin source · line 27 · raw
@-W:Type -> @-E:Data -> @world:W -> Tx<W, E>
Consume World into a transaction with empty journal/queues and tracing off. Does not clone World; return it through finish, including on system failure.
template add_undo source · line 33 · raw
@-W:Type -> @-E:Data -> @tx:Tx<W, E> -> @inverse:(@_:W -> W) -> Tx<W, E>
Trusted lower-level operation: push an affine inverse onto the journal. Caller must ensure it restores the matching change and preserves other owners. Inverses execute newest first on failure, not on successful commit.
template stage_command source · line 42 · raw
@-W:Type -> @-E:Data -> @tx:Tx<W, E> -> @command:0x67fd5084c1da4adc13317822045bb11f/deferred_command.Command<W> -> Tx<W, E>
Commands and events are accumulated in reverse and reversed once at commit. Stage an owned deferred command without executing it. Commit enqueues commands in authored order; failure discards them. Visibility follows the command queue's explicit barrier, not transaction completion itself.
template stage source · line 48 · raw
@-W:Type -> @-E:Data -> @tx:Tx<W, E> -> @command:(@_:W -> W) -> Tx<W, E>
Trusted adapter staging a raw World-transforming callback as a command. It is not executed here; callbacks must obey their own authority/ownership contracts. Prefer declared commands for ordinary gameplay.
template emit source · line 56 · raw
@-W:Type -> @-E:Data -> @tx:Tx<W, E> -> @event:E -> Tx<W, E>
Stage one Data event, retaining publication order for successful commit. Failure publishes none of this transaction's staged events. For affine Type payload ownership/recovery use the separate owned-event APIs.
template rollback source · line 64 · raw
@-W:Type -> @undo:List<&1, @_:W -> W> -> @world:W -> W
Trusted lower-level journal execution: apply inverse closures head first and return World. Only recorded changes are undone; no general mutation or external-effect rollback is inferred from calling this function.
template finish_world source · line 71 · raw
@-W:Type -> @-E:Data -> @-Error:Data -> @-enqueue:(@_:W -> @_:List<&1, 0x67fd5084c1da4adc13317822045bb11f/deferred_command.Command<W>> -> W) -> @-publish:(@_:W -> @_:List<&2, E> -> W) -> @world:W -> @undo:List<&1, @_:W -> W> -> @commands:List<&1, 0x67fd5084c1da4adc13317822045bb11f/deferred_command.Command<W>> -> @events:List<&2, E> -> @outcome:Outcome<Error> -> Returned<W, Error>
template finish source · line 88 · raw
@-W:Type -> @-E:Data -> @-Error:Data -> @-enqueue:(@_:W -> @_:List<&1, 0x67fd5084c1da4adc13317822045bb11f/deferred_command.Command<W>> -> W) -> @-publish:(@_:W -> @_:List<&2, E> -> W) -> @tx:Tx<W, E> -> @outcome:Outcome<Error> -> Returned<W, Error>
Consume the transaction and return World with its decision. Success enqueues commands then publishes Data events in authored order; failure runs the inverse journal newest first and publishes/enqueues neither. enqueue/publish are trusted callbacks; arbitrary external effects are outside this guarantee. This function does not execute the deferred command barrier.
template begin_observed source · line 99 · raw
@-W:Type -> @-E:Data -> @world:W -> Tx<W, E>
Begin a transaction with operation tracing enabled and an empty fact list. Tracing observes operations; it does not strengthen rollback guarantees.
template trace_enabled source · line 103 · raw
@-W:Type -> @-E:Data -> @tx:Tx<W, E> -> Pair(Tx<W, E>, Bool)
Return the transaction owner and its trace-enabled flag without emitting a fact, invoking gameplay or changing journal/queue contents.
template record source · line 108 · raw
@-W:Type -> @-E:Data -> @tx:Tx<W, E> -> @fact:0x67fd5084c1da4adc13317822045bb11f/trace_facts.Fact -> Tx<W, E>
Append an operation observation through the current tracing state. Disabled tracing retains its disabled state; facts confer no write authority.
template committed source · line 111 · raw
@-Error:Data -> @outcome:Outcome<Error> -> Bool
template finish_observed source · line 118 · raw
@-W:Type -> @-E:Data -> @-Error:Data -> @-enqueue:(@_:W -> @_:List<&1, 0x67fd5084c1da4adc13317822045bb11f/deferred_command.Command<W>> -> W) -> @-publish:(@_:W -> @_:List<&2, E> -> W) -> @tx:Tx<W, E> -> @+outcome:Outcome<Error> -> Pair(Returned<W, Error>, 0x67fd5084c1da4adc13317822045bb11f/trace_facts.State)
Finish with the same commit/rollback behavior as finish, also returning trace facts settled with the actual transaction decision. Returned facts are observations, not additional changes to apply or undo.
template begin_with_trace source · line 125 · raw
@-W:Type -> @-E:Data -> @world:W -> @trace:0x67fd5084c1da4adc13317822045bb11f/trace_facts.State -> Tx<W, E>
Trusted integration entry beginning an empty transaction with supplied tracing state. Consumes World once; no previous journal or command state is imported or inferred from trace facts.
template annotate_newest source · line 129 · raw
@-W:Type -> @-E:Data -> @tx:Tx<W, E> -> @before:0x67fd5084c1da4adc13317822045bb11f/trace_facts.Value -> @after:0x67fd5084c1da4adc13317822045bb11f/trace_facts.Value -> Tx<W, E>
Advanced trace adapter adding detached before/after values to the newest operation fact. Does not modify World, journal semantics or publication order.