model.bend checks
raw source on the hub · import bend-kit-runner@0.19.0.0/model.bend as Model
Pure runner state transitions, retry decisions, and journal codecs.
12 imports
import Base import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes import bend-kit-encoding@0.5.0.0/encoding.bend as Encoding import bend-kit-scheduler@0.4.3.0/queue.bend as Q import bend-kit-resources@0.1.0.0/resources.bend as Res import bend-kit-retry@0.3.0.0/retry.bend as Retry import bend-kit-collections@0.1.5.0/heap.bend as H import bend-kit-collections@0.1.5.0/omap.bend as O import bend-kit-collections@0.1.5.0/hmap.bend as M import bend-kit-collections@0.1.5.0/LAWS.bend as CL import bend-kit-collections@0.1.5.0/PROOF.bend as CP import bend-kit-collections@0.1.5.0/order.bend as Order
Types
type Why source · line 17 · raw
Data
Why retry gave up on a ticket: its budget was spent, its deadline passed, its failure must not repeat, or another try would repeat its failure.
WhySpentWhy
WhyLateWhy
WhyUnsafeWhy
WhyFailedWhy
type Dead source · line 25 · raw
@-A:Data -> Data
A ticket that retry gave up on, with its payload, and when it gave up (wall-clock ms). It stays until Revive, Cancel, or Purge takes it.
Dead@-A:Data -> @ticket:0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A> -> @why:Why -> @at:Nat -> Dead<A>
type Op source · line 34 · raw
@-A:Data -> Data
One durable transition. Each one is one journal record, appended before the state changes. Select: the queue's select at now. Replay runs it at the same now, so it takes the same ticket. Requeue: the attempt failed; it counts one failure. Defer: the breaker held the ticket back; no attempt ran. Abandon: retry gave up at at; the running ticket becomes dead. Revive: a dead ticket is pending again at deadline, with a new budget. Purge: the dead tickets abandoned before before are dropped. PurgeAll: every dead ticket is dropped. Break: the breaker of target changed to state.
Enqueue@-A:Data -> @deadline:Nat -> @payload:A -> Op<A>
Select@-A:Data -> @now:Nat -> Op<A>
Complete@-A:Data -> @id:Nat -> Op<A>
Cancel@-A:Data -> @id:Nat -> Op<A>
Requeue@-A:Data -> @id:Nat -> @deadline:Nat -> Op<A>
Defer@-A:Data -> @id:Nat -> @deadline:Nat -> Op<A>
Abandon@-A:Data -> @id:Nat -> @why:Why -> @at:Nat -> Op<A>
Revive@-A:Data -> @id:Nat -> @deadline:Nat -> Op<A>
Purge@-A:Data -> @before:Nat -> Op<A>
PurgeAll@-A:Data -> Op<A>
Break@-A:Data -> @target:String -> @state:0x14e48621ef66156b0eb652524b8594d4/retry.State -> Op<A>
type Try source · line 48 · raw
Data
The failed attempts of a ticket, and its first deadline, from which the policy deadline counts.
Try@fails:Nat -> @start:Nat -> Try
type State source · line 67 · raw
@-A:Data -> Data
The durable state: the queue, the tries, the dead tickets, and the breakers.
State@-A:Data -> @queue:0x77b88a2c45e79ff162b14cf8d6ee4112/queue.State<A> -> @tries:Tries -> @dead:Graves(A) -> @breakers:Breakers -> State<A>
type Rec source · line 333 · raw
@-A:Data -> Data
A journal record. Compaction writes one Snap of the whole state; every other record is one op.
Snap@-A:Data -> @state:State<A> -> Rec<A>
Do@-A:Data -> @op:Op<A> -> Rec<A>
type Pick source · line 358 · raw
@-A:Data -> Type
Picked: a due ticket and one unit of the pool for it. Idle: no due ticket, or no free unit; the pool is unchanged.
Picked@-A:Data -> @pool:0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Pool -> @ticket:0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A> -> @grant:0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Grant -> Pick<A>
Idle@-A:Data -> @pool:0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Pool -> Pick<A>
type Loop source · line 386 · raw
@-A:Data -> Data
A flight holds one unit; its affine grant is retained by the runtime.
Loop@-A:Data -> @pool:0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Pool -> @state:State<A> -> @flights:List<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> Loop<A>
type LoopEvent source · line 389 · raw
Data
Claim@now:Nat -> LoopEvent
Finish@id:Nat -> LoopEvent
type Rd source · line 718 · raw
Type
A snapshot reader: the record, and the offset of the next field.
Rd@b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @at:U32 -> Rd
Definitions
def Tries source · line 52 · raw
Data
A Try for each ticket that is not yet complete, cancelled, or dead, by ticket id.
def Breakers source · line 56 · raw
Data
The breaker state of each target that has one, by target. An absent target is closed with no failures.
def dead.hash source · line 59 · raw
@i:Nat -> U32
def Graves source · line 63 · raw
@-A:Data -> Data
The dead tickets, by ticket id.
def new source · line 70 · raw
@-A:Data -> State<A>
def queue source · line 73 · raw
@-A:Data -> @s:State<A> -> 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.State<A>
def tries source · line 77 · raw
@-A:Data -> @s:State<A> -> Tries
def dead source · line 82 · raw
@-A:Data -> @s:State<A> -> Graves(A)
The dead tickets, by id. A Revive of one makes it pending again; a Cancel or a Purge drops it.
def breakers source · line 86 · raw
@-A:Data -> @s:State<A> -> Breakers
def dead.list.entries source · line 105 · raw
@-A:Data -> @es:List<&2, 0x55289dd95dde91bbc62b3e414066cf83/hmap.Entry<Nat, Dead<A>>> -> @acc:List<&2, Dead<A>> -> List<&2, Dead<A>>
def dead.list.go source · line 112 · raw
@-A:Data -> @ds:Graves(A) -> @acc:List<&2, Dead<A>> -> List<&2, Dead<A>>
def dead.list source · line 122 · raw
@-A:Data -> @ds:Graves(A) -> List<&2, Dead<A>>
The dead tickets, in no set order.
def dead.old.keep source · line 125 · raw
@-A:Data -> @old:Bool -> @+i:Nat -> @rest:List<&2, Nat> -> List<&2, Nat>
def dead.old source · line 133 · raw
@-A:Data -> @ds:List<&2, Dead<A>> -> @+t:Nat -> List<&2, Nat>
The ids of the dead tickets abandoned before t.
def tries.drop source · line 153 · raw
@ts:Tries -> @+i:Nat -> Tries
def tries.get source · line 156 · raw
@ts:Tries -> @+i:Nat -> Maybe<&2, Try>
def tries.bump.got source · line 159 · raw
@m:Maybe<&2, Try> -> @ts:Tries -> @+i:Nat -> Tries
def tries.bump source · line 166 · raw
@+ts:Tries -> @+i:Nat -> Tries
def brk.hash.go source · line 171 · raw
@key:String -> @acc:U32 -> U32
def brk.hash source · line 178 · raw
@key:String -> U32
def brk.eq source · line 181 · raw
@a:String -> @b:String -> Bool
def brk.got source · line 184 · raw
@m:Maybe<&2, 0x14e48621ef66156b0eb652524b8594d4/retry.State> -> 0x14e48621ef66156b0eb652524b8594d4/retry.State
def brk.get source · line 191 · raw
@-A:Data -> @s:State<A> -> @key:String -> 0x14e48621ef66156b0eb652524b8594d4/retry.State
def brk.state source · line 194 · raw
@br:0x14e48621ef66156b0eb652524b8594d4/retry.Breaker -> @old:0x14e48621ef66156b0eb652524b8594d4/retry.State -> 0x14e48621ef66156b0eb652524b8594d4/retry.State
def brk.nats source · line 201 · raw
@a:List<&2, Nat> -> @b:List<&2, Nat> -> Bool
def brk.same source · line 210 · raw
@a:0x14e48621ef66156b0eb652524b8594d4/retry.State -> @b:0x14e48621ef66156b0eb652524b8594d4/retry.State -> Bool
def calm.state source · line 221 · raw
@b:0x14e48621ef66156b0eb652524b8594d4/retry.State -> 0x14e48621ef66156b0eb652524b8594d4/retry.State
def calm.entries source · line 230 · raw
@es:List<&2, 0x55289dd95dde91bbc62b3e414066cf83/hmap.Entry<String, 0x14e48621ef66156b0eb652524b8594d4/retry.State>> -> List<&2, 0x55289dd95dde91bbc62b3e414066cf83/hmap.Entry<String, 0x14e48621ef66156b0eb652524b8594d4/retry.State>>
def calm.map source · line 237 · raw
@m:Breakers -> Breakers
def calm source · line 247 · raw
@-A:Data -> @s:State<A> -> State<A>
The probes of a half-open breaker died with the process that ran them, so open counts none in flight.
def step.enqueued source · line 253 · raw
@-A:Data -> @r:Pair(0x77b88a2c45e79ff162b14cf8d6ee4112/queue.State<A>, Nat) -> @ts:Tries -> @ds:Graves(A) -> @bs:Breakers -> @d:Nat -> State<A>
def step.selected source · line 257 · raw
@-A:Data -> @r:Pair(0x77b88a2c45e79ff162b14cf8d6ee4112/queue.State<A>, Maybe<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>>) -> @ts:Tries -> @ds:Graves(A) -> @bs:Breakers -> State<A>
def step.requeued source · line 261 · raw
@-A:Data -> @r:Pair(0x77b88a2c45e79ff162b14cf8d6ee4112/queue.State<A>, Bool) -> @ts:Tries -> @ds:Graves(A) -> @bs:Breakers -> State<A>
def step.completed source · line 266 · raw
@-A:Data -> @r:Pair(0x77b88a2c45e79ff162b14cf8d6ee4112/queue.State<A>, Maybe<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>>) -> @ts:Tries -> @ds:Graves(A) -> @bs:Breakers -> State<A>
Complete takes the ticket from the running list only: O(running), not O(pending).
def step.broke source · line 284 · raw
@bs:Breakers -> @k:String -> @b:0x14e48621ef66156b0eb652524b8594d4/retry.State -> Breakers
A closed breaker with no failures reads the same as an absent one, so it leaves the map.
def pick.took source · line 362 · raw
@-A:Data -> @r:0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Reserve -> @t:0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A> -> Pick<A>
def pick.due source · line 369 · raw
@-A:Data -> @m:Maybe<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> @p:0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Pool -> Pick<A>
def pick.sel source · line 376 · raw
@-A:Data -> @r:Pair(0x77b88a2c45e79ff162b14cf8d6ee4112/queue.State<A>, Maybe<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>>) -> @p:0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Pool -> Pick<A>
def loop.pool source · line 393 · raw
@-A:Data -> @s:Loop<A> -> 0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Pool
def loop.state source · line 397 · raw
@-A:Data -> @s:Loop<A> -> State<A>
def loop.flights source · line 401 · raw
@-A:Data -> @s:Loop<A> -> List<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>>
def loop.release source · line 405 · raw
@r:0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Release -> 0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Pool
def budget.of source · line 443 · raw
@+attempts:Nat -> @t:Maybe<&2, Try> -> @d:Maybe<&2, Nat> -> 0x14e48621ef66156b0eb652524b8594d4/retry.Budget
The budget left for ticket i: the policy's attempts less its failures, until its start plus the policy deadline.
def budget source · line 452 · raw
@p:0x14e48621ef66156b0eb652524b8594d4/retry.Policy -> @t:Maybe<&2, Try> -> 0x14e48621ef66156b0eb652524b8594d4/retry.Budget
def fails source · line 457 · raw
@t:Maybe<&2, Try> -> Nat
The failures so far: the index of the next retry.
def gave source · line 465 · raw
@b:0x14e48621ef66156b0eb652524b8594d4/retry.Budget -> Why
Why retry stopped a transient failure: no attempt is left, or the next wait would reach the deadline.
def stopped source · line 474 · raw
@-A:Data -> @o:0x14e48621ef66156b0eb652524b8594d4/retry.Outcome -> @b:0x14e48621ef66156b0eb652524b8594d4/retry.Budget -> @+id:Nat -> @+now:Nat -> Op<A>
A settled attempt completes its ticket; retry gave up at now on any other.
def after.plan source · line 487 · raw
@-A:Data -> @pl:0x14e48621ef66156b0eb652524b8594d4/retry.Plan -> @o:0x14e48621ef66156b0eb652524b8594d4/retry.Outcome -> @b:0x14e48621ef66156b0eb652524b8594d4/retry.Budget -> @+id:Nat -> @+now:Nat -> Op<A>
def after source · line 496 · raw
@-A:Data -> @+o:0x14e48621ef66156b0eb652524b8594d4/retry.Outcome -> @p:0x14e48621ef66156b0eb652524b8594d4/retry.Policy -> @+b:0x14e48621ef66156b0eb652524b8594d4/retry.Budget -> @+id:Nat -> @+n:Nat -> @+now:Nat -> @+r:Nat -> Op<A>
The record after an attempt of ticket id ends at now with o: requeue at now plus retry's wait, complete when o is settled, or abandon when retry gave up.
def brk.after source · line 500 · raw
@+circ:0x14e48621ef66156b0eb652524b8594d4/retry.Circuit -> @old:0x14e48621ef66156b0eb652524b8594d4/retry.State -> @+now:Nat -> @o:0x14e48621ef66156b0eb652524b8594d4/retry.Outcome -> 0x14e48621ef66156b0eb652524b8594d4/retry.Breaker
A target's breaker after an attempt ends at now with o.
def until source · line 504 · raw
@br:0x14e48621ef66156b0eb652524b8594d4/retry.Breaker -> @+now:Nat -> Nat
When an open breaker lets attempts start again.
def held source · line 516 · raw
@-A:Data -> @why:0x14e48621ef66156b0eb652524b8594d4/retry.Deny -> @br:0x14e48621ef66156b0eb652524b8594d4/retry.Breaker -> @+id:Nat -> @+now:Nat -> Op<A>
The record for a ticket that admit refused: Defer to when the breaker may admit, or Abandon when its budget is spent or late.
def why.code source · line 529 · raw
@w:Why -> Nat
def W source · line 540 · raw
Nat
def put.u64 source · line 544 · raw
@b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+at:U32 -> @+n:Nat -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
Nat fields hold values under 2^64.
def head source · line 547 · raw
@+tag:U32 -> @+a:Nat -> @+c:Nat -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
def snap.u32 source · line 550 · raw
@out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+v:U32 -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
def snap.u64 source · line 553 · raw
@out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+n:Nat -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
def snap.key.bytes source · line 556 · raw
@out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
def snap.key source · line 561 · raw
@out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @k:String -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
A target is a u32 octet length, then UTF-8 octets.
def snap.nats source · line 564 · raw
@xs:List<&2, Nat> -> @out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
def snap.brk source · line 572 · raw
@out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @b:0x14e48621ef66156b0eb652524b8594d4/retry.State -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
A breaker state is a u32 kind. 0 is closed: a u32 count, then each failure as a u64. 1 is open: until. 2 is half-open: busy.
def get.field source · line 606 · raw
@m:Maybe<&2, U32> -> U32
def get.u32 source · line 613 · raw
@r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, U32)
def get.hi source · line 617 · raw
@+lo:U32 -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Nat)
def get.lo source · line 621 · raw
@+at:U32 -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Nat)
def get.u64 source · line 626 · raw
@b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+at:U32 -> Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Nat)
def snap.payload source · line 636 · raw
@out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @p:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
def snap.tries source · line 658 · raw
@ts:Tries -> @out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
def brk.entries.leaf source · line 681 · raw
@es:List<&2, 0x55289dd95dde91bbc62b3e414066cf83/hmap.Entry<String, 0x14e48621ef66156b0eb652524b8594d4/retry.State>> -> @acc:List<&2, Sigma<&2, &2, String, _ => 0x14e48621ef66156b0eb652524b8594d4/retry.State>> -> List<&2, Sigma<&2, &2, String, _ => 0x14e48621ef66156b0eb652524b8594d4/retry.State>>
def brk.entries source · line 688 · raw
@bs:Breakers -> @acc:List<&2, Sigma<&2, &2, String, _ => 0x14e48621ef66156b0eb652524b8594d4/retry.State>> -> List<&2, Sigma<&2, &2, String, _ => 0x14e48621ef66156b0eb652524b8594d4/retry.State>>
def snap.brks source · line 697 · raw
@xs:List<&2, Sigma<&2, &2, String, _ => 0x14e48621ef66156b0eb652524b8594d4/retry.State>> -> @out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
def Dec source · line 722 · raw
@-T:Type -> Type
One step of the snapshot decoder. None: a field runs past the record or does not decode.
def Dec.next source · line 725 · raw
@-A:Type -> @-B:Type -> @m:Maybe<&1, Pair(Rd, A)> -> @f:(@_:A -> Dec(B)) -> Maybe<&1, Pair(Rd, B)>
def Dec.bind source · line 732 · raw
@-A:Type -> @-B:Type -> @m:Dec(A) -> @f:(@_:A -> Dec(B)) -> Dec(B)
def Dec.pure source · line 735 · raw
@-A:Type -> @x:A -> Dec(A)
def Dec.fail source · line 738 · raw
@-A:Type -> Dec(A)
def rd.u32.of source · line 741 · raw
@m:Maybe<&2, U32> -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+at:U32 -> Maybe<&1, Pair(Rd, U32)>
def rd.u32.got source · line 748 · raw
@+at:U32 -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Maybe<&2, U32>) -> Maybe<&1, Pair(Rd, U32)>
def rd.u32.at source · line 752 · raw
@r:Rd -> Maybe<&1, Pair(Rd, U32)>
def rd.u32 source · line 756 · raw
Dec(U32)
def rd.u64.of source · line 759 · raw
@+lo:U32 -> @+hi:U32 -> Nat
def rd.u64 source · line 762 · raw
Dec(Nat)
def rd.cut.got source · line 768 · raw
@+at:U32 -> @+n:U32 -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> Maybe<&1, Pair(Rd, 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes)>
def rd.cut.if source · line 772 · raw
@ok:Bool -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @+at:U32 -> @+n:U32 -> Maybe<&1, Pair(Rd, 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes)>
def rd.cut.at source · line 779 · raw
@+n:U32 -> @r:Rd -> Maybe<&1, Pair(Rd, 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes)>
def rd.cut source · line 784 · raw
@+n:U32 -> Dec(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes)
The next n octets.
def rd.flag.of source · line 787 · raw
@+m:U32 -> Dec(Bool)
def rd.flag source · line 791 · raw
Dec(Bool)
A u32 flag: 1 is True, 0 is False, and any other value fails.
def rd.payload source · line 794 · raw
@-A:Data -> @+i:Nat -> @+d:Nat -> @m:Maybe<&2, A> -> Dec(0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>)
def rd.tries source · line 839 · raw
@+fuel:Nat -> @node:Bool -> Dec(0x55289dd95dde91bbc62b3e414066cf83/omap.OMap<Nat, Try>)
def rd.why source · line 857 · raw
@+c:U32 -> Dec(Why)
def rd.wf source · line 945 · raw
@-A:Data -> @ok:Bool -> @ds:Graves(A) -> Dec(Graves(A))
The trie, when it is well formed as the never-selected laws assume.
def rd.key source · line 952 · raw
Dec(String)
def rd.nats source · line 960 · raw
@+fuel:Nat -> @end:Bool -> @+n:U32 -> Dec(List<&2, Nat>)
def rd.closed source · line 973 · raw
@+fuel:Nat -> Dec(0x14e48621ef66156b0eb652524b8594d4/retry.State)
def rd.brk.of source · line 979 · raw
@+fuel:Nat -> @+kind:U32 -> Dec(0x14e48621ef66156b0eb652524b8594d4/retry.State)
def rd.brk source · line 984 · raw
@+fuel:Nat -> Dec(0x14e48621ef66156b0eb652524b8594d4/retry.State)
def rd.break source · line 987 · raw
@-A:Data -> @+fuel:Nat -> Dec(Op<A>)
def rd.brks source · line 993 · raw
@+fuel:Nat -> @more:Bool -> @acc:Breakers -> Dec(Breakers)
def rd.done source · line 1023 · raw
@-T:Data -> @+len:U32 -> @m:Maybe<&1, Pair(Rd, T)> -> Maybe<&2, T>
The value read, when the reader ended at len, the record's end.
def decode.abandon source · line 1031 · raw
@-A:Data -> @+a:Nat -> @+c:Nat -> @+e:Nat -> Maybe<&2, Op<A>>
The Abandon of ticket a at e whose why.code is c, or None for any other code.
def decode.small source · line 1037 · raw
@-A:Data -> @ok:Bool -> @+tag:U32 -> @+a:Nat -> @+c:Nat -> Maybe<&2, Op<A>>
def decode.long source · line 1051 · raw
@-A:Data -> @ok:Bool -> @+a:Nat -> @+c:Nat -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Nat) -> Maybe<&2, Op<A>>
def decode.payload source · line 1059 · raw
@-A:Data -> @m:Maybe<&2, A> -> @+d:Nat -> Maybe<&2, Op<A>>
def decode.c.if source · line 1066 · raw
@-A:Data -> @abandon:Bool -> @+tag:U32 -> @+len:U32 -> @+a:Nat -> @+c:Nat -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, Op<A>>
def decode.snapped source · line 1117 · raw
@-A:Data -> @m:Maybe<&2, State<A>> -> Maybe<&2, Rec<A>>
def decode.did source · line 1124 · raw
@-A:Data -> @m:Maybe<&2, Op<A>> -> Maybe<&2, Rec<A>>
def empty.heap source · line 1146 · raw
@-A:Data -> @h:0x55289dd95dde91bbc62b3e414066cf83/heap.Heap<0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> Bool
def empty.list source · line 1153 · raw
@-A:Data -> @xs:List<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> Bool
def idle source · line 1161 · raw
@-A:Data -> @s:State<A> -> Bool
No ticket is pending or running. Dead tickets wait for a Revive, so they do not count.
def pending source · line 1165 · raw
@-A:Data -> @s:State<A> -> Nat
def drain.ms source · line 1170 · raw
@-A:Data -> @idle:U32 -> @now:Nat -> @m:Maybe<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> U32
ms to wait: idle, or less when the earliest pending ticket falls due sooner.
def soonest source · line 1177 · raw
@-A:Data -> @s:State<A> -> Maybe<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>>
Templates
template dead.get source · line 92 · raw
@-A:Data -> @ds:Graves(A) -> @+i:Nat -> Maybe<&2, Dead<A>>
template dead.drop source · line 95 · raw
@-A:Data -> @ds:Graves(A) -> @+i:Nat -> Graves(A)
template dead.bury source · line 98 · raw
@-A:Data -> @m:Maybe<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> @ds:Graves(A) -> @w:Why -> @+at:Nat -> Graves(A)
template dead.drops source · line 140 · raw
@-A:Data -> @ks:List<&2, Nat> -> @ds:Graves(A) -> Graves(A)
template dead.purge source · line 148 · raw
@-A:Data -> @+ds:Graves(A) -> @+t:Nat -> Graves(A)
The dead tickets without those abandoned before t. It walks every dead ticket once.
template step.abandoned source · line 271 · raw
@-A:Data -> @r:Pair(0x77b88a2c45e79ff162b14cf8d6ee4112/queue.State<A>, Maybe<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>>) -> @ts:Tries -> @ds:Graves(A) -> @bs:Breakers -> @w:Why -> @+at:Nat -> State<A>
Abandon takes the ticket from the running list, as Complete does, and keeps it with its payload.
template step.revived source · line 276 · raw
@-A:Data -> @m:Maybe<&2, Dead<A>> -> @+i:Nat -> @n:Nat -> @h:0x55289dd95dde91bbc62b3e414066cf83/heap.Heap<0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> @r:List<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> @ts:Tries -> @ds:Graves(A) -> @bs:Breakers -> @+d:Nat -> State<A>
The revived ticket keeps its payload and takes id i, the key it was dead under.
template step source · line 292 · raw
@-A:Data -> @s:State<A> -> @op:Op<A> -> State<A>
The state after op. Live and replay both run it, so they agree.
template apply.op source · line 317 · raw
@-A:Data -> @m:Maybe<&2, Op<A>> -> @s:State<A> -> Maybe<&2, State<A>>
template apply source · line 325 · raw
@-A:Data -> @-R:Type -> @-dec:(@_:R -> Maybe<&2, Op<A>>) -> @acc:Maybe<&2, State<A>> -> @r:R -> Maybe<&2, State<A>>
Folds one record into the replayed state. A record that does not decode ends the replay with None.
template load.rec source · line 337 · raw
@-A:Data -> @m:Maybe<&2, Rec<A>> -> @s:State<A> -> Maybe<&2, State<A>>
template load source · line 348 · raw
@-A:Data -> @-R:Type -> @-dec:(@_:R -> Maybe<&2, Rec<A>>) -> @acc:Maybe<&2, State<A>> -> @r:R -> Maybe<&2, State<A>>
Folds one record into the replayed state: a Snap replaces it, and an op steps it, as apply does. A record that does not decode ends the replay with None.
template pick source · line 381 · raw
@-A:Data -> @p:0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Pool -> @s:State<A> -> @now:Nat -> Pick<A>
The ticket that Select{now} takes, with one unit of p, when there is a ticket due and a unit free.
template loop.claim source · line 412 · raw
@-A:Data -> @k:Pick<A> -> @s:State<A> -> @fs:List<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> @now:Nat -> Loop<A>
template loop.finished source · line 419 · raw
@-A:Data -> @tk:0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Taken<A> -> @p:0x8ef64648a1ae4481382be5e5ce2a9fc8/resources.Pool -> @s:State<A> -> @+i:Nat -> Loop<A>
template loop.step source · line 426 · raw
@-A:Data -> @e:LoopEvent -> @s:Loop<A> -> Loop<A>
template loop.fold source · line 433 · raw
@-A:Data -> @es:List<&2, LoopEvent> -> @s:Loop<A> -> Loop<A>
template encode source · line 581 · raw
@-A:Data -> @-penc:(@_:A -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> @op:Op<A> -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
template snap.ticket source · line 640 · raw
@-A:Data -> @-penc:(@_:A -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> @out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> @t:0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A> -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
template snap.heap source · line 644 · raw
@-A:Data -> @-penc:(@_:A -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> @h:0x55289dd95dde91bbc62b3e414066cf83/heap.Heap<0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> @out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
template snap.run source · line 651 · raw
@-A:Data -> @-penc:(@_:A -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> @xs:List<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>> -> @out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
template snap.entries source · line 665 · raw
@-A:Data -> @-penc:(@_:A -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> @es:List<&2, 0x55289dd95dde91bbc62b3e414066cf83/hmap.Entry<Nat, Dead<A>>> -> @out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
template snap.graves source · line 672 · raw
@-A:Data -> @-penc:(@_:A -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> @ds:Graves(A) -> @out:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
template encode.snap source · line 705 · raw
@-A:Data -> @-penc:(@_:A -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> @s:State<A> -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
The Snap record of s.
template encode.rec source · line 710 · raw
@-A:Data -> @-penc:(@_:A -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes) -> @r:Rec<A> -> 0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes
template rd.ticket source · line 801 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> Dec(0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>)
template rd.heap source · line 810 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @+fuel:Nat -> @node:Bool -> Dec(0x55289dd95dde91bbc62b3e414066cf83/heap.Heap<0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>>)
Each rd.* tree reader takes the flag already read. fuel bounds the depth: every node holds at least one 4-octet flag.
template rd.run source · line 826 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @+fuel:Nat -> @more:Bool -> Dec(List<&2, 0x77b88a2c45e79ff162b14cf8d6ee4112/queue.Ticket<A>>)
template rd.entries source · line 863 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @+fuel:Nat -> @more:Bool -> Dec(List<&2, 0x55289dd95dde91bbc62b3e414066cf83/hmap.Entry<Nat, Dead<A>>>)
template rd.entry.le source · line 880 · raw
@-A:Data -> @a:0x55289dd95dde91bbc62b3e414066cf83/hmap.Entry<Nat, Dead<A>> -> @b:0x55289dd95dde91bbc62b3e414066cf83/hmap.Entry<Nat, Dead<A>> -> Bool
template rd.ascending source · line 885 · raw
@-A:Data -> @xs:List<&2, 0x55289dd95dde91bbc62b3e414066cf83/hmap.Entry<Nat, Dead<A>>> -> @+previous:Nat -> Bool
template rd.distinct source · line 892 · raw
@-A:Data -> @xs:List<&2, 0x55289dd95dde91bbc62b3e414066cf83/hmap.Entry<Nat, Dead<A>>> -> Bool
template rd.valid.go source · line 899 · raw
@-A:Data -> @+n:Nat -> @ds:Graves(A) -> Bool
template rd.valid source · line 918 · raw
@-A:Data -> @ds:Graves(A) -> Bool
template rd.graves source · line 922 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @+fuel:Nat -> @nil:Bool -> @leaf:Bool -> @branch:Bool -> Dec(Graves(A))
A trie node whose kind is already read: nil is kind 0, leaf kind 1, and branch kind 2. Any other kind fails.
template rd.state source · line 1006 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @+fuel:Nat -> Dec(State<A>)
template decode.c source · line 1074 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @+tag:U32 -> @+len:U32 -> @+a:Nat -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Nat) -> Maybe<&2, Op<A>>
An Abandon is 28 octets; every other op without a payload is 20.
template decode.kind source · line 1078 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @enq:Bool -> @+tag:U32 -> @+len:U32 -> @+a:Nat -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, Op<A>>
template decode.a source · line 1085 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @+tag:U32 -> @+len:U32 -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, Nat) -> Maybe<&2, Op<A>>
template decode.tag.if source · line 1089 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @brk:Bool -> @+tag:U32 -> @+len:U32 -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, Op<A>>
template decode.tag source · line 1096 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @+len:U32 -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, U32) -> Maybe<&2, Op<A>>
template decode.len source · line 1100 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @ok:Bool -> @+len:U32 -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, Op<A>>
template decode source · line 1108 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, Op<A>>
The op of a record, or None when it is not one that encode writes.
template decode.snap source · line 1113 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, State<A>>
The state of a Snap record whose tag is already checked. The decoder must end at the record's end.
template decode.rec.if source · line 1131 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @snap:Bool -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, Rec<A>>
template decode.rec.tag source · line 1138 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @r:Pair(0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes, U32) -> Maybe<&2, Rec<A>>
template decode.rec source · line 1143 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, Rec<A>>
The Rec of a journal record, or None when it is neither a Snap nor an op that encode.rec writes.
template replay.step source · line 1181 · raw
@-A:Data -> @-pdec:(@_:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, A>) -> @acc:Maybe<&2, State<A>> -> @b:0x632652e3c1c0183f12728faf3870bb68/bytes.Bytes -> Maybe<&2, State<A>>