From 1b60ee96bb181f4f31dfe5cf5b708de018c15a2c Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 11 Aug 2021 14:27:45 +1000 Subject: [PATCH] grid: remove workarounds for multiple desks --- pkg/grid/app/docket.hoon | 10 +-- pkg/grid/desk.bill | 4 +- pkg/grid/lib/kiln.hoon | 18 ++++ pkg/grid/mar/docket-uninstall.hoon | 13 +++ pkg/grid/mar/docket-update.hoon | 13 +++ pkg/grid/sur/hood.hoon | 134 +++++++++++++++++++++++++++++ pkg/grid/ted/glob.hoon | 17 ++++ 7 files changed, 197 insertions(+), 12 deletions(-) create mode 100644 pkg/grid/lib/kiln.hoon create mode 100644 pkg/grid/mar/docket-uninstall.hoon create mode 100644 pkg/grid/mar/docket-update.hoon create mode 100644 pkg/grid/sur/hood.hoon create mode 100644 pkg/grid/ted/glob.hoon diff --git a/pkg/grid/app/docket.hoon b/pkg/grid/app/docket.hoon index 3423aec98..d33f57e55 100644 --- a/pkg/grid/app/docket.hoon +++ b/pkg/grid/app/docket.hoon @@ -64,13 +64,7 @@ =^ cards state ?+ mark (on-poke:def:cc mark vase) %docket-uninstall dc-abet:dc-uninstall:(dc-abed !<(desk vase)) - :: - %init :: must delay poke until after commit - =^ g-cards state :: TODO: break into own desk, remove special casing - dc-abet:dc-install:(dc-abed %grid) - =^ l-cards state - dc-abet:dc-install:(dc-abed %landscape) - [(weld g-cards l-cards) state] + %init dc-abet:dc-install:(dc-abed %grid) :: %noun =+ ;;([%kick =desk] q.vase) @@ -253,8 +247,6 @@ ++ dc-install =. dc-core (dc-log "installing {}") =/ =path - ?: =(%grid desk) :: XX remove - /(scot %p our.bowl)/landscape/(scot %da now.bowl)/grid/docket /(scot %p our.bowl)/[desk]/(scot %da now.bowl)/desk/docket =+ .^(exists=? %cu path) ?. exists :: no docket diff --git a/pkg/grid/desk.bill b/pkg/grid/desk.bill index fd785ab54..fea481bb1 100644 --- a/pkg/grid/desk.bill +++ b/pkg/grid/desk.bill @@ -1,7 +1,5 @@ :~ :- %apes :~ %docket == - :- %fish - :~ %chat-cli - == + :- %fish ~ == diff --git a/pkg/grid/lib/kiln.hoon b/pkg/grid/lib/kiln.hoon new file mode 100644 index 000000000..feb77d33f --- /dev/null +++ b/pkg/grid/lib/kiln.hoon @@ -0,0 +1,18 @@ +/- *hood +/* base-bill %bill /desk/bill +=, clay +=, space:userlib +=, format +=* dude dude:gall +|% +:: $diff: subscription update +:: ++$ diff + $% [%block =desk =arak =weft blockers=(set desk)] + [%reset =desk =arak] + [%merge =desk =arak] + [%merge-sunk =desk =arak =tang] + [%merge-fail =desk =arak =tang] + == +-- + diff --git a/pkg/grid/mar/docket-uninstall.hoon b/pkg/grid/mar/docket-uninstall.hoon new file mode 100644 index 000000000..335cd9580 --- /dev/null +++ b/pkg/grid/mar/docket-uninstall.hoon @@ -0,0 +1,13 @@ +|_ =desk +++ grad %noun +++ grow + |% + ++ noun desk + ++ json s+desk + -- +++ grab + |% + ++ noun ^desk + ++ json so:dejs:format + -- +-- diff --git a/pkg/grid/mar/docket-update.hoon b/pkg/grid/mar/docket-update.hoon new file mode 100644 index 000000000..e624fa6f0 --- /dev/null +++ b/pkg/grid/mar/docket-update.hoon @@ -0,0 +1,13 @@ +/+ dock=docket +|_ =update:dock +++ grad %noun +++ grow + |% + ++ noun update + ++ json (update:enjs:dock update) + -- +++ grab + |% + ++ noun update:dock + -- +-- diff --git a/pkg/grid/sur/hood.hoon b/pkg/grid/sur/hood.hoon new file mode 100644 index 000000000..6130b0324 --- /dev/null +++ b/pkg/grid/sur/hood.hoon @@ -0,0 +1,134 @@ +/- *bill +=, clay +=* dude dude:gall +|% +:: $arak: foreign vat tracker +:: +:: .next is a list of pending commits with future kelvins +:: ++$ arak + $: =ship + =desk + =aeon + next=(list [=aeon =weft]) + =rein + == +:: $rein: diff from desk manifest +:: +:: .add: agents not in manifest that should be running +:: .sub: agents in manifest that should not be running +:: ++$ rein + $: add=(set dude) + sub=(set dude) + == +:: ++$ vat [=desk hash=@uv =cass =arak] +:: +report-vats: report on all desk installations +:: +++ report-vats + |= [our=@p now=@da] + ^- tang + =+ .^ raz=(list vat) + %gx /(scot %p our)/hood/(scot %da now)/kiln/vats/noun + == + (turn raz |=(v=vat (report-vat our now v))) +:: +report-vat: report on a single desk installation +:: +++ report-vat + |= [our=ship now=@da vat] + ^- tank + =+ .^(=weft %cx /(scot %p our)/[desk]/(scot %da now)/sys/kelvin) + :+ %rose ["" "{}" "::"] + ^- tang + =- ?: =(~ next.arak) - + (snoc - leaf/"pending: {}") + ^- tang + =/ meb (mergebase-hashes our desk now arak) + :~ leaf/"/sys/kelvin: {<[lal num]:weft>}" + leaf/"base hash: {?.(=(1 (lent meb)) <(head meb)>)}" + leaf/"%cz hash: {}" + leaf/"remote aeon: {}" + leaf/"force on: {?:(=(~ add.rein.arak) "~" )}" + leaf/"force off: {?:(=(~ sub.rein.arak) "~" )}" + == +:: +ankh-to-kelvin: read /sys.kelvin from an $ankh +:: +++ ankh-to-kelvin + |= =ankh + !< weft + q:(need (~(get an:cloy ankh) /sys/kelvin)) +:: +++ read-kelvin-local + |= [our=ship =desk =aeon] + .^(weft cx+/(scot %p our)/[desk]/(scot %ud aeon)/sys/kelvin) +:: +++ read-kelvin-foreign + |= [=ship =desk =aeon] + ^- weft + =/ her (scot %p ship) + =/ syd (scot %tas desk) + =/ yon (scot %ud aeon) + :: + =/ dom .^(dome cv/~[her syd yon]) + =/ tak (scot %uv (~(got by hit.dom) let.dom)) + =/ yak .^(yaki cs/~[her syd yon %yaki tak]) + =/ lob (scot %uv (~(got by q.yak) /sys/kelvin)) + =/ bob .^(blob cs/~[her syd yon %blob lob]) + :: + ;; weft + ?- -.bob + %direct q.q.bob + %delta q.r.bob + == +:: +read-bill: read contents of /desk/bill manifest +:: +++ read-bill + |= [our=ship =desk now=@da] + .^(bill cx+/(scot %p our)/[desk]/(scot %da now)/desk/bill) +:: +is-fish: should dill link .dude? +:: +++ is-fish |=([=dude =bill] .?((find ~[dude] (read-fish bill)))) +:: +get-apps-diff: which agents should be started and stopped +:: +++ get-apps-diff + |= [our=ship =desk now=@da =rein] + ^- [liv=(list dude) ded=(list dude)] + =/ =bill (read-bill our desk now) + =/ wan (sy (get-apps-want bill rein)) + =/ hav (sy (get-apps-live our desk now)) + =/ liv ~(tap in (~(dif in wan) hav)) + =/ ded ~(tap in (~(dif in hav) wan)) + [liv ded] +:: +++ get-apps-live + |= [our=ship =desk now=@da] + ^- (list dude) + %+ murn (get-apps-have our desk now) + |=([=dude live=?] ?.(live ~ `dude)) +:: +get-apps-have: find which apps Gall is running on a desk +:: +++ get-apps-have + |= [our=ship =desk now=@da] + ^- (list [=dude live=?]) + %~ tap in + .^((set [=dude live=?]) ge+/(scot %p our)/[desk]/(scot %da now)) +:: +get-apps-want: find which apps should be running on a desk +:: +++ get-apps-want + |= [=bill =rein] + ^- (list dude) + =/ duz (read-apes bill) + =. duz (skip duz ~(has in sub.rein)) + =. duz (weld duz ~(tap in add.rein)) + duz +:: +++ mergebase-hashes + |= [our=@p =desk now=@da =arak] + =/ her (scot %p ship.arak) + =/ ego (scot %p our) + =/ wen (scot %da now) + %+ turn .^((list tako) %cs ~[ego desk wen %base her desk.arak]) + |=(=tako .^(@uv %cs ~[ego desk wen %hash (scot %uv tako)])) +-- + diff --git a/pkg/grid/ted/glob.hoon b/pkg/grid/ted/glob.hoon new file mode 100644 index 000000000..aa03a6868 --- /dev/null +++ b/pkg/grid/ted/glob.hoon @@ -0,0 +1,17 @@ +/- spider, docket +/+ strandio +=, strand=strand:spider +^- thread:spider +|= arg=vase +=/ m (strand ,vase) +^- form:m +=+ !<([~ url=cord] arg) +;< =glob:docket bind:m + %+ (retry:strandio ,glob:docket) `5 + =/ n (strand ,(unit glob:docket)) + ;< =cord bind:n (fetch-cord:strandio (trip url)) + %- pure:n + %- mole + |. + ;;(=glob:docket (cue cord)) +(pure:m !>(glob))