diff --git a/pkg/arvo/age/first.hoon b/pkg/arvo/age/first.hoon index 6a4cd51fe1..5c3d405e09 100644 --- a/pkg/arvo/age/first.hoon +++ b/pkg/arvo/age/first.hoon @@ -1,50 +1,22 @@ +/+ default-agent ^- agent:mall =| state=@ -|_ bowl:mall -++ handle-init - `..handle-init -:: -++ handle-prep - |= =old-state=vase - =/ old-state !<(@ old-state-vase) - ?~ old-state - ~& %prep-lost - `..handle-init - ~& %prep-found - `..handle-init(state u.old-state) -:: +|_ =bowl:mall ++* this . +++ handle-init ~(handle-init default-agent bowl this) +++ handle-extract-state ~(handle-extract-state default-agent bowl this) +++ handle-upgrade-state ~(handle-upgrade-state default-agent bowl this) ++ handle-poke |= in-poke-data=cage - ~& >> 'ouchies!' - ~& >>> in-poke-data ~& > state=state + ~& > in-poke-data =. state +(state) - `..handle-init + `this :: -++ handle-peer - |= path - `..handle-init -:: -++ handle-pull - |= path - `..handle-init -:: -++ handle-peek - |= path - *(unit (unit cage)) -:: -++ handle-mall - |= [wire internal-gift:mall] - `..handle-init -:: -++ handle-take - |= [wire vase] - `..handle-init -:: -++ handle-lame - |= [term tang] - `..handle-init -:: -++ handle-stay - !>(state) +++ handle-subscribe ~(handle-subscribe default-agent bowl this) +++ handle-unsubscribe ~(handle-unsubscribe default-agent bowl this) +++ handle-peek ~(handle-peek default-agent bowl this) +++ handle-agent-response ~(handle-agent-response default-agent bowl this) +++ handle-arvo-response ~(handle-arvo-response default-agent bowl this) +++ handle-error ~(handle-error default-agent bowl this) -- diff --git a/pkg/arvo/lib/default-agent.hoon b/pkg/arvo/lib/default-agent.hoon new file mode 100644 index 0000000000..06d505e17e --- /dev/null +++ b/pkg/arvo/lib/default-agent.hoon @@ -0,0 +1,63 @@ +|_ [=bowl:mall =agent:mall] +++ handle-init + `agent +:: +++ handle-prep + |= old-state=vase + ~& "updating agent {} by throwing away old state" + `agent +:: +++ handle-poke + |= =cage + ~& "unexpected poke to {} with mark {}" + ~| "unexpected poke to {} with mark {}" + !! +:: +++ handle-peer + |= =path + ~& "unexpected subscription to {} on path {}" + ~| "unexpected subscription to {} on path {}" + !! +:: +++ handle-pull + |= path + `agent +:: +++ handle-peek + |= path + ~| "unexpected scry into {} on path {}" + !! +:: +++ handle-mall + |= [=wire =internal-gift:mall] + ?- -.internal-gift + %coup `agent + %reap `agent + %quit + ~| "unexpected subscription closure to {} on wire {}" + !! + :: + %diff + ~| "unexpected subscription update to {} on wire {}" + ~| "with mark {}" + !! + :: + %http-response + ~| "unexpected http-response to {} on wire {}" + !! + == +:: +++ handle-take + |= [=wire =vase] + ~| "unexpected system response {} to {} on wire {}" + !! +:: +++ handle-lame + |= [=term =tang] + %- (slog leaf+"error in {}" >term< tang) + `agent +:: +++ handle-stay + ~& "extracting empty state for {}" + !>(~) +-- diff --git a/pkg/arvo/sys/zuse.hoon b/pkg/arvo/sys/zuse.hoon index cefcb1611d..4e934edfa4 100644 --- a/pkg/arvo/sys/zuse.hoon +++ b/pkg/arvo/sys/zuse.hoon @@ -1862,7 +1862,7 @@ $% {$mass p/mass} :: memory usage {$onto p/(each suss tang)} :: about agent {$rend p/path q/*} :: network request - {$unto p/internal-gift} :: + {$unto p/gift:agent} :: {$mack p/(unit tang)} :: message ack == :: ++ task :: incoming request @@ -1901,19 +1901,12 @@ {$peer p/path} :: subscribe {$poke p/cage} :: apply {$puff p/mark q/noun} :: unchecked poke - {$pull ~} :: unsubscribe + {$pull ~} :: unsubscribe {$punk p/mark q/cage} :: translated poke - {$pump ~} :: pump yes+no + {$pump ~} :: pump yes+no {$peer-not p/tang} :: poison pill peer == :: - ++ internal-gift :: - $% {$coup p/(unit tang)} :: poke result - {$diff p/cage} :: subscription output - {$quit ~} :: close subscription - {$reap p/(unit tang)} :: peer result - [%http-response =http-event:http] :: serve http result - == :: - ++ internal-task (pair term agent-action) :: internal task + ++ internal-task task:agent :: internal task ++ dude term :: server identity ++ gill (pair ship term) :: general contact ++ scar :: opaque duct @@ -1924,36 +1917,43 @@ ++ suss (trel dude @tas @da) :: config report ++ well (pair desk term) :: :: - :: +internal-note: +ap note - :: - ++ internal-note - $% [%meta =term =vase] - [%send =ship =internal-task] - == - :: +internal-move: agent-level move - :: - :: Analogous to an Arvo move, except these are routed by bone, instead of - :: duct. - :: - ++ internal-move - $: =bone - move=(wind internal-note internal-gift) - == :: +agent: app core :: ++ agent =< form |% - +$ move [=bone move=card] - +$ card (wind internal-note internal-gift) - +$ step (quip move form) + +$ step (quip card form) + +$ card (wind note gift) + +$ note + $% [%arvo note-arvo] + [%agent =ship name=term =task] + == + +$ task + $% [%subscribe-translated =mark =path] + [%subscribe =path] + [%unsubscribe ~] + [%poke =cage] + [%raw-poke =mark =noun] + [%poke-translated =mark =cage] + [%pump ~] + == + +$ gift + $% [%poke-ack p=(unit tang)] + [%subscription-update p=cage] + [%subscription-closed ~] + [%subscription-ack p=(unit tang)] + [%http-response =http-event:http] + == ++ form $_ ^| |_ bowl ++ handle-init *(quip move _^|(..handle-init)) :: - ++ handle-prep + ++ handle-extract-state + *vase + :: + ++ handle-upgrade-state |~ old-state=vase *(quip move _^|(..handle-init)) :: @@ -1961,11 +1961,11 @@ |~ in-poke-data=cage *(quip move _^|(..handle-init)) :: - ++ handle-peer + ++ handle-subscribe |~ path *(quip move _^|(..handle-init)) :: - ++ handle-pull + ++ handle-unsubscribe |~ path *(quip move _^|(..handle-init)) :: @@ -1973,20 +1973,17 @@ |~ path *(unit (unit cage)) :: - ++ handle-mall + ++ handle-agent-response |~ [wire internal-gift] *(quip move _^|(..handle-init)) :: - ++ handle-take - |~ [wire sign=vase] + ++ handle-arvo-response + |~ [wire =sign-arvo] *(quip move _^|(..handle-init)) :: - ++ handle-lame + ++ handle-error |~ [term tang] *(quip move _^|(..handle-init)) - :: - ++ handle-stay - *vase -- -- -- ::mall