From 84c7b442e9b562ccb4ff61e7b1791ce383a39696 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Thu, 5 Sep 2019 18:18:31 -0700 Subject: [PATCH] mall: convert helm to mall --- pkg/arvo/age/hood.hoon | 79 ++++++++--- pkg/arvo/app/cop.hoon | 5 +- pkg/arvo/app/hood.hoon | 1 - pkg/arvo/lib/hood/helm-mall.hoon | 225 +++++++++++++++++++++++++++++++ pkg/arvo/lib/hood/helm.hoon | 14 +- pkg/arvo/sys/vane/mall.hoon | 57 +++----- 6 files changed, 313 insertions(+), 68 deletions(-) create mode 100644 pkg/arvo/lib/hood/helm-mall.hoon diff --git a/pkg/arvo/age/hood.hoon b/pkg/arvo/age/hood.hoon index cd9ef14c4..69a0c2527 100644 --- a/pkg/arvo/age/hood.hoon +++ b/pkg/arvo/age/hood.hoon @@ -11,7 +11,7 @@ :: they have been bundled into :hood :: :: |command handlers - hood-helm, hood-kiln, hood-drum, hood-write + hood-helm-mall, hood-kiln, hood-drum, hood-write :: :: :: :::: :: :: :: :: :: @@ -46,7 +46,7 @@ |: paw=$:hood-part ?- hed $drum ?>(?=($drum -.paw) `part:hood-drum`paw) - $helm ?>(?=($helm -.paw) `part:hood-helm`paw) + $helm ?>(?=($helm -.paw) `part:hood-helm-mall`paw) $kiln ?>(?=($kiln -.paw) `part:hood-kiln`paw) $write ?>(?=($write -.paw) `part:hood-write`paw) == @@ -57,7 +57,7 @@ |@ ++ $ ?- hed $drum (make:hood-drum our) - $helm *part:hood-helm + $helm *part:hood-helm-mall $kiln *part:hood-kiln $write *part:hood-write == @@ -69,7 +69,7 @@ :: :: ++ hood-part :: current module state $% {$drum $2 pith-2:hood-drum} :: - {$helm $0 pith:hood-helm} :: + {$helm $0 pith:hood-helm-mall} :: {$kiln $0 pith:hood-kiln} :: {$write $0 pith:hood-write} :: == :: @@ -79,7 +79,9 @@ :: :: :: ^- agent:mall =| hood-1 :: module states -=> |% +=/ help + |= hid/bowl:mall + |% ++ able :: find+make part |= hid=bowl:mall =+ hed=$:hood-head @@ -103,16 +105,15 @@ ?~ old +> +>(lac (~(run by lac.u.old) hood-port)) :: - :: ++ poke-hood-load :: recover lost brain - :: |= dat/hood-part - :: ?> =(our.hid src.hid) - :: ~& loaded+-.dat - :: [~ %_(+> lac (~(put by lac) -.dat dat))] + ++ poke-hood-load :: recover lost brain + |= dat/hood-part + ?> =(our.hid src.hid) + ~& loaded+-.dat + [~ (~(put by lac) -.dat dat)] :: :: ++ from-module :: create wrapper |* _[identity=%module start=..$ finish=_abet]:(hood-module) - |= hid=bowl:mall =- [wrap=- *start] :: usage (wrap handle-arm):from-foo |* handle/_finish |= a=_+<.handle @@ -120,7 +121,7 @@ (ably (handle a)) :: per-module interface wrappers ++ from-drum (from-module %drum [..$ _se-abet]:(hood-drum)) - ++ from-helm (from-module %helm [..$ _abet]:(hood-helm)) + ++ from-helm (from-module %helm [..$ _abet]:(hood-helm-mall)) ++ from-kiln (from-module %kiln [..$ _abet]:(hood-kiln)) ++ from-write (from-module %write [..$ _abet]:(hood-write)) -- @@ -140,9 +141,41 @@ ++ handle-poke |= [=mark =vase] ^- (quip move:agent:mall agent:mall) + =/ h (help hid) =^ moves lac ?+ mark ~|([%poke-hood-bad-mark mark] !!) - %atom ((wrap poke-atom):(from-helm hid) (need !<(@ vase))) + %hood-load %- poke-hood-load:h + (need !<(hood-part vase)) + %atom %- (wrap poke-atom):from-helm:h + (need !<(@ vase)) + %helm-hi %- (wrap poke-hi):from-helm:h + (need !<(@t vase)) + %helm-mass %- (wrap poke-mass):from-helm:h + (need !<(~ vase)) + %helm-reload %- (wrap poke-reload):from-helm:h + (need !<((list term) vase)) + %helm-reload-desk %- (wrap poke-reload-desk):from-helm:h + (need !<([@t (list term)] vase)) + %helm-reset %- (wrap poke-reset):from-helm:h + (need !<(~ vase)) + %helm-serve %- (wrap poke-serve):from-helm:h + (need !<([=binding:eyre =generator:eyre] vase)) + %helm-send-hi %- (wrap poke-send-hi):from-helm:h + (need !<([ship (unit tape)] vase)) + %helm-verb %- (wrap poke-verb):from-helm:h + (need !<(~ vase)) + %helm-rekey %- (wrap poke-rekey):from-helm:h + (need !<(@t vase)) + %helm-moon %- (wrap poke-moon):from-helm:h + (need !<((unit [ship udiff:point:able:jael]) vase)) + %helm-nuke %- (wrap poke-nuke):from-helm:h + (need !<(ship vase)) + %helm-automass %- (wrap poke-automass):from-helm:h + (need !<(@dr vase)) + %helm-cancel-automass %- (wrap poke-cancel-automass):from-helm:h + (need !<(~ vase)) + %helm-bonk %- (wrap poke-bonk):from-helm:h + (need !<(~ vase)) == [moves ..handle-init] :: @@ -159,12 +192,24 @@ *(unit (unit cage)) :: ++ handle-mall - |= [wire internal-gift:mall] - `..handle-init + |= [=wire =internal-gift:mall] + ~& [%handling-mall wire] + =/ h (help hid) + =^ moves lac + ?+ wire ~|([%hood-bad-wire wire] !!) + [%helm %hi *] %+ (wrap coup-hi):from-helm:h t.t.wire + ?>(?=(%coup -.internal-gift) p.internal-gift) + == + [moves ..handle-init] :: ++ handle-take - |= [wire vase] - `..handle-init + |= [=wire =vase] + =/ h (help hid) + =^ moves lac + ?+ wire ~|([%hood-bad-wire wire] !!) + [%helm *] ((wrap take):from-helm:h t.wire vase) + == + [moves ..handle-init] :: ++ handle-lame |= [term tang] diff --git a/pkg/arvo/app/cop.hoon b/pkg/arvo/app/cop.hoon index 1a46d5e63..d64bbfa69 100644 --- a/pkg/arvo/app/cop.hoon +++ b/pkg/arvo/app/cop.hoon @@ -12,8 +12,9 @@ ^- (quip move _this) :_ this :_ ~ ?+ arg ~|(%bad-arg !!) - %conf `move`[ost.bowl %conf-mall / [our.bowl %hood] [our.bowl %home]] - %poke `move`[ost.bowl %deal-mall / [our.bowl our.bowl] %hood %poke %atom !>(%hey)] + %conf [ost.bowl %conf-mall / [our.bowl %hood] [our.bowl %home]] + %poke [ost.bowl %deal-mall / [our.bowl our.bowl] %hood %poke %atom !>(%hey)] + %hi [ost.bowl %deal-mall / [our.bowl our.bowl] %hood %poke %helm-send-hi !>([our.bowl `"heyza"])] == :: ++ onto diff --git a/pkg/arvo/app/hood.hoon b/pkg/arvo/app/hood.hoon index 83648971a..356d20838 100644 --- a/pkg/arvo/app/hood.hoon +++ b/pkg/arvo/app/hood.hoon @@ -200,6 +200,5 @@ ++ writ-kiln-autoload (wrap take-writ-autoload):from-kiln ++ writ-kiln-find-ship (wrap take-writ-find-ship):from-kiln ++ writ-kiln-sync (wrap take-writ-sync):from-kiln - ++ bound (wrap take-bound):from-helm -- diff --git a/pkg/arvo/lib/hood/helm-mall.hoon b/pkg/arvo/lib/hood/helm-mall.hoon new file mode 100644 index 000000000..4dbe28137 --- /dev/null +++ b/pkg/arvo/lib/hood/helm-mall.hoon @@ -0,0 +1,225 @@ +:: :: :: +:::: /hoon/helm/hood/lib :: :: + :: :: :: +/? 310 :: version +/- sole, hall +/+ pill +:: :: :: +:::: :: :: + :: :: :: +|% :: :: +++ part {$helm $0 pith} :: helm state +++ pith :: helm content + $: hoc/(map bone session) :: consoles + == :: +++ session :: + $: say/sole-share:sole :: console state + mud/(unit (sole-dialog:sole @ud)) :: console dialog + mass-timer/{way/wire nex/@da tim/@dr} + == :: +:: :: :: +:::: :: :: + :: :: :: +++ hood-nuke :: block/unblock + $: him/ship :: + == :: +++ hood-reset :: reset command + $~ :: +++ helm-verb :: reset command + $~ :: +++ hood-reload :: reload command + (list term) :: +-- :: +:: :: :: +:::: :: :: + :: :: :: +|: $:{bowl:gall part} :: main helm work +=+ sez=(~(gut by hoc) ost $:session) +=> |% :: arvo structures + ++ card :: + $% [%bonk wire ~] :: + {$flog wire flog:dill} :: + {$nuke wire ship} :: + [%serve wire binding:eyre generator:eyre] :: + {$poke wire dock pear} :: + {$rest wire @da} :: + {$wait wire @da} :: + {$rekey wire life ring} :: + {$moon wire ship udiff:point:able:jael} :: + == :: + ++ move (pair bone card) :: user-level move + ++ pear :: poke fruit + $% {$hood-unsync desk ship desk} :: + {$helm-hi cord} :: + {$drum-start well:gall} :: + {$hall-action action:hall} :: + == :: + -- +=| moz=(list move:agent:mall) +|% +++ abet + [(flop moz) %_(+<+.$ hoc (~(put by hoc) ost sez))] +:: +++ emit + |= (wind internal-note:mall internal-gift:mall) + %_(+> moz [[ost +<] moz]) +:: +++ flog + |= =flog:dill + (emit %pass /di %meta %d !>([%flog flog])) +:: +++ emil :: return cards + |= (list (wind internal-note:mall internal-gift:mall)) + ^+ +> + ?~(+< +> $(+< t.+<, +> (emit i.+<))) +:: +++ poke-rekey :: rotate private keys + |= des=@t + =/ sed=(unit seed:able:jael) + %+ biff + (bind (slaw %uw des) cue) + (soft seed:able:jael) + =< abet + ?~ sed + ~& %invalid-private-key + +>.$ + ?. =(our who.u.sed) + ~& [%wrong-private-key-ship who.u.sed] + +>.$ + (emit %pass / %meta %j !>([%rekey lyf.u.sed key.u.sed])) +:: +++ poke-moon :: rotate moon keys + |= sed=(unit [=ship =udiff:point:able:jael]) + =< abet + ?~ sed + +>.$ + (emit %pass / %meta %j !>([%moon u.sed])) +:: +++ poke-nuke :: initialize + |= him/ship =< abet + (emit %pass /helm %meta %j !>([%nuke him])) +:: +++ poke-mass + |= ~ =< abet + (flog %crud %hax-heft ~) +:: +++ poke-automass + |= recur=@dr + =. mass-timer.sez + [/helm/automass (add now recur) recur] + abet:(emit %pass way.mass-timer.sez %meta %b !>([%wait nex.mass-timer.sez])) +:: +++ poke-cancel-automass + |= ~ + abet:(emit %pass way.mass-timer.sez %meta %b !>([%rest nex.mass-timer.sez])) +:: +++ poke-bonk + |= ~ + ~& .^((unit @da) %a /(scot %p our)/time/(scot %da now)/(scot %p our)) + %- %- slog :_ ~ .^(tank %b /(scot %p our)/timers/(scot %da now)) + abet:(emit %pass /bonk %meta %a !>([%bonk ~])) +:: +++ take-wake-automass + |= [way=wire error=(unit tang)] + ?^ error + %- (slog u.error) + ~& %helm-wake-automass-fail + abet + =. nex.mass-timer.sez (add now tim.mass-timer.sez) + =< abet + %- emil + :~ [%pass /heft %meta %d !>([%flog %crud %hax-heft ~])] + [%pass way.mass-timer.sez %meta %b !>([%wait nex.mass-timer.sez])] + == +:: +++ poke-send-hi + |= {her/ship mes/(unit tape)} =< abet + %- emit + :* %pass /helm/hi/(scot %p her) + %send her %hood %poke + %helm-hi !>(?~(mes '' (crip u.mes))) + == +:: +:: +++ poke-hi + |= mes/@t + ~| %poke-hi-fail + ?: =(%fail mes) + ~& %poke-hi-fail + !! + abet:(flog %text "< {}: {(trip mes)}") +:: +++ poke-atom + |= ato/@ + =+ len=(scow %ud (met 3 ato)) + =+ gum=(scow %p (mug ato)) + =< abet + (flog %text "< {}: atom: {len} bytes, mug {gum}") +:: +++ coup-hi + |= {pax/path cop/(unit tang)} =< abet + ?> ?=({@t ~} pax) + (flog %text "hi {(trip i.pax)} {?~(cop "" "un")}successful") +:: +++ poke-reload |=(all/(list term) (poke-reload-desk %home all)) +++ poke-reload-desk :: reload vanes + |: $:{syd/desk all/(list term)} =< abet + %- emil + %- flop + %+ turn all + =+ top=`path`/(scot %p our)/[syd]/(scot %da now) + =/ van/(list {term ~}) + :- zus=[%zuse ~] + ~(tap by dir:.^(arch %cy (welp top /sys/vane))) + |= nam/@tas + =. nam + ?. =(1 (met 3 nam)) + nam + =+ ^- zaz/(list {p/knot ~}) + (skim van |=({a/term ~} =(nam (end 3 1 a)))) + ?> ?=({{@ ~} ~} zaz) + `term`p.i.zaz + =+ tip=(end 3 1 nam) + =+ zus==('z' tip) + =+ way=?:(zus (welp top /sys/[nam]) (welp top /sys/vane/[nam])) + =+ fil=.^(@ %cx (welp way /hoon)) + [%pass /reload %meta %d !>([%flog %veer ?:(=('z' tip) %$ tip) way fil])] +:: +poke-reset: send %lyra to initiate kernel upgrade +:: +:: And reinstall %zuse and the vanes with %veer. +:: Trigger with |reset. +:: +++ poke-reset + |= hood-reset + =< abet + %- emil %- flop + ^- (list (wind internal-note:mall internal-gift:mall)) + =/ top=path /(scot %p our)/home/(scot %da now)/sys + =/ hun .^(@ %cx (welp top /hoon/hoon)) + =/ arv .^(@ %cx (welp top /arvo/hoon)) + :- [%pass /reset %meta %d !>([%flog %lyra `@t`hun `@t`arv])] + %+ turn + (module-ova:pill top) + |=([=wire =flog:dill] [%pass wire %meta %d !>([%flog flog])]) +:: +++ poke-verb :: toggle verbose + |= ~ =< abet + (flog %verb ~) +:: +++ poke-serve + |= [=binding:eyre =generator:eyre] =< abet + (emit %pass /helm/serv %meta %e !>([%serve binding generator])) +:: +++ take-bound + |= [wir=wire success=? binding=binding:eyre] =< abet + (flog %text "bound: {}") +:: +++ take + |= [=wire =vase] + ?+ wire ~|([%helm-bad-take-wire wire] !!) + [%automass *] %+ take-wake-automass t.wire + +:(need !<([%wake (unit tang)] vase)) + [%serv *] %+ take-bound t.wire + +:(need !<([%bound ? binding:eyre] vase)) + == +-- diff --git a/pkg/arvo/lib/hood/helm.hoon b/pkg/arvo/lib/hood/helm.hoon index 50ec68c8a..e02c3d9ff 100644 --- a/pkg/arvo/lib/hood/helm.hoon +++ b/pkg/arvo/lib/hood/helm.hoon @@ -57,19 +57,11 @@ == :: -- =+ moz=((list move)) -=| moi=(list move:agent:mall) |% ++ abet :: resolve [(flop moz) %_(+<+.$ hoc (~(put by hoc) ost sez))] :: -++ abei - [(flop moi) %_(+<+.$ hoc (~(put by hoc) ost sez))] -:: ++ emit |=(card %_(+> moz [[ost +<] moz])) :: return card -++ emii - |= (wind internal-note:mall internal-gift:mall) - %_(+> moi [[ost +<] moi]) -:: ++ emil :: return cards |= (list card) ^+ +> @@ -152,10 +144,8 @@ |= ato/@ =+ len=(scow %ud (met 3 ato)) =+ gum=(scow %p (mug ato)) - =< abei - %^ emii %pass /di - :+ %meta %d - !> [%flog %text "< {}: atom: {len} bytes, mug {gum}"] + =< abet + (emit %flog /di %text "< {}: atom: {len} bytes, mug {gum}") :: ++ coup-hi |= {pax/path cop/(unit tang)} =< abet diff --git a/pkg/arvo/sys/vane/mall.hoon b/pkg/arvo/sys/vane/mall.hoon index 84c69dba6..9bfc05c03 100644 --- a/pkg/arvo/sys/vane/mall.hoon +++ b/pkg/arvo/sys/vane/mall.hoon @@ -6,13 +6,6 @@ =, mall => =~ |% -:: +coke: cook -:: -++ coke - $? %inn - %out - %cay - == :: +reverse-ames: reverse ames message :: ++ reverse-ames @@ -706,7 +699,7 @@ |= [=path hin=(hypo sign-arvo)] ^+ mo-core :: - ?. ?=([@ @ coke *] path) + ?. ?=([@ @ *] path) ~& [%mo-handle-use-bad-path path] !! :: @@ -717,27 +710,16 @@ (ap-abed:ap term routes) :: =/ =sign-arvo q.hin - ?- i.t.t.path - %inn + ?. ?=([%m %unto *] sign-arvo) =/ =vase (slot 3 hin) - =. app (ap-generic-take:app t.t.t.path vase) + ~& [%handling-use path] + =. app (ap-generic-take:app t.t.path vase) ap-abet:app - :: - %cay - ~& [%mo-handle-use-weird sign-arvo] - ~& [%mo-handle-use-weird-path path] - mo-core - :: - %out - ?. ?=([%m %unto *] sign-arvo) - ~& [%mo-handle-use-weird sign-arvo] - ~& [%mo-handle-use-weird-path path] - mo-core - =. app - =/ =internal-gift +>.sign-arvo - (ap-specific-take:app t.t.t.path internal-gift) - ap-abet:app - == + =. app + =/ =internal-gift +>.sign-arvo + ~& [%handling-use path] + (ap-specific-take:app t.t.path internal-gift) + ap-abet:app :: +mo-clear-queue: clear blocked tasks from the specified running agent. :: ++ mo-clear-queue @@ -1065,7 +1047,8 @@ %pass =/ =path p.move.internal-move =/ =internal-note q.move.internal-move - =/ use-path [%use agent-name path] + =/ use-path + [%use agent-name (scot %p attributing.agent-routes) path] =/ =note-arvo ?- -.internal-note %send @@ -1316,9 +1299,9 @@ :: =^ maybe-tang ap-core %+ ap-ingest ~ |. - (handle-mall:ap-agent-core +.path internal-gift) + (handle-mall:ap-agent-core path internal-gift) ?: ?=(%diff -.internal-gift) - (ap-update-subscription =(~ maybe-tang) attributing.agent-routes +.path) + (ap-update-subscription =(~ maybe-tang) attributing.agent-routes path) ?^ maybe-tang (ap-lame -.internal-gift u.maybe-tang) ap-core @@ -1563,12 +1546,14 @@ :: +load: recreate vane :: ++ load - |= =state-old - ^+ mall-payload - :: - ?- -.state-old - %0 mall-payload(state state-old) - == + |= * + mall-payload + :: |= =state-old + :: ^+ mall-payload + :: :: + :: ?- -.state-old + :: %0 mall-payload(state state-old) + :: == :: +scry: standard scry :: ++ scry