From f1c1205fe2e6351392d1a865de15c920c88cfd47 Mon Sep 17 00:00:00 2001 From: Tinnus Napbus Date: Thu, 27 Jul 2023 18:01:30 +1200 Subject: [PATCH 1/4] kiln: let publishers tell subs to switch source This adds a %kiln-change-source poke that changes the sync source for all syncs from the given remote ship/desk to a new ship/source. This poke works remotely iff it comes from the publisher, allowing publishers to migrate app distribution. A %kiln-change-publisher poke is also added to kiln which sends this out to all desk subscribers with the let+1 %w %sing that %kiln uses. --- pkg/arvo/lib/hood/kiln.hoon | 52 +++++++++++++++++++++++++++- pkg/arvo/mar/kiln/change-source.hoon | 16 +++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 pkg/arvo/mar/kiln/change-source.hoon diff --git a/pkg/arvo/lib/hood/kiln.hoon b/pkg/arvo/lib/hood/kiln.hoon index 6418acb415..82649c42f4 100644 --- a/pkg/arvo/lib/hood/kiln.hoon +++ b/pkg/arvo/lib/hood/kiln.hoon @@ -285,7 +285,6 @@ +$ kiln-fuse-list (unit desk) -- |= [bowl:gall state] -?> =(src our) =| moz=(list card:agent:gall) |% ++ kiln . @@ -528,6 +527,7 @@ :: ++ poke |= [=mark =vase] + ?> |(=(src our) =(%kiln-change-source mark)) ?+ mark ~|([%poke-kiln-bad-mark mark] !!) %kiln-autocommit =;(f (f !<(_+<.f vase)) poke-autocommit) %kiln-bump =;(f (f !<(_+<.f vase)) poke-bump) @@ -543,6 +543,8 @@ %kiln-label =;(f (f !<(_+<.f vase)) poke-label) %kiln-merge =;(f (f !<(_+<.f vase)) poke-merge) %kiln-mount =;(f (f !<(_+<.f vase)) poke-mount) + %kiln-change-source =;(f (f !<(_+<.f vase)) poke-change-source) + %kiln-change-publisher =;(f (f !<(_+<.f vase)) poke-change-publisher) %kiln-nuke =;(f (f !<(_+<.f vase)) poke-nuke) %kiln-pause =;(f (f !<(_+<.f vase)) poke-pause) %kiln-permission =;(f (f !<(_+<.f vase)) poke-permission) @@ -731,6 +733,52 @@ abet:(spam leaf+- ~) abet:(emit %pass /mount %arvo %c [%mont pot u.bem]) :: +++ poke-change-publisher + |= [syd=desk her=ship sud=desk] + ?: =([our syd] [her sud]) + abet + =/ let=@ud ud:.^(cass:clay %cw /(scot %p our)/[syd]/(scot %da now)) + =/ subs=(set [@p rave:clay]) + .^((set [@p rave:clay]) %cx /(scot %p our)//(scot %da now)/cult/[syd]) + =/ ships=(set @p) + %+ roll ~(tap in subs) + |= [[=ship =rave:clay] ships=(set @p)] + ?: =(our ship) ships + ?. ?=([%sing %w [%ud @] ~] rave) ships + ?. =(+(let) p.case.mood.rave) ships + (~(put in ships) ship) + =< abet + %- emil + %+ turn ~(tap in ships) + |= =ship + :* %pass /kiln/change-publisher %agent [ship %hood] + %poke %kiln-change-source !>([[our syd] [her sud]]) + == +:: +++ poke-change-source + |= [old=dock new=dock] + ?> |(=(src p.old) =(src our)) + ?: =(old new) abet + =/ old-sources=(list kiln-sync) + (skim ~(tap by sources) |=(kiln-sync =(old [her sud]))) + =/ new-sources=(list kiln-sync) + (turn old-sources |=(kiln-sync [syd new])) + =. zyn + |- + ?~ old-sources zyn + $(old-sources t.old-sources, zyn (~(del by zyn) i.old-sources)) + =< abet + |- ^+ ..abet + ?~ new-sources ..abet + %= $ + new-sources t.new-sources + ..abet =/ sun (sync i.new-sources) + =< abet:init + ?: =(%base syd.i.new-sources) + (apex:sun `%kids) + sun + == +:: ++ poke-nuke |= [=term desk=?] =< abet @@ -865,6 +913,8 @@ ~? ?=(^ p.sign) [%kiln-poke-nack u.p.sign] abet ~|([%kiln-bad-take-agent wire -.sign] !!) + :: + [%change-publisher ~] abet :: [%fancy *] ?> ?=(%poke-ack -.sign) diff --git a/pkg/arvo/mar/kiln/change-source.hoon b/pkg/arvo/mar/kiln/change-source.hoon new file mode 100644 index 0000000000..e8fda84477 --- /dev/null +++ b/pkg/arvo/mar/kiln/change-source.hoon @@ -0,0 +1,16 @@ +:: +:::: /hoon/change-source/kiln/mar + :: +/? 310 +|_ req=[old=dock new=dock] +:: +++ grow + |% + ++ noun req + -- +++ grab + |% + ++ noun ,[dock dock] + -- +++ grad %noun +-- From c4b612dac50cf13d68dea9912c47f8b8f3fd9ca3 Mon Sep 17 00:00:00 2001 From: Tinnus Napbus Date: Fri, 28 Jul 2023 23:43:17 +1200 Subject: [PATCH 2/4] gen/hood: add +change-publisher generator --- pkg/arvo/gen/hood/change-publisher.hoon | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pkg/arvo/gen/hood/change-publisher.hoon diff --git a/pkg/arvo/gen/hood/change-publisher.hoon b/pkg/arvo/gen/hood/change-publisher.hoon new file mode 100644 index 0000000000..729733f6db --- /dev/null +++ b/pkg/arvo/gen/hood/change-publisher.hoon @@ -0,0 +1,23 @@ +/+ *generators +:- %ask +|= $: [now=@da eny=@uvJ bec=beak] + [syd=desk her=ship sud=desk ~] + hard=_| + == +?: hard (produce %kiln-change-publisher syd her sud) +=/ m1 + 'This will tell desk subscribers to switch update source.' +=/ m2 + 'If you enter the wrong ship/desk, you will not be \ + /able to correct it.' +=/ m3 + leaf+"Are you sure you want to tell subscribers to get ". + "updates for {} from {}/{(trip sud)}?" +%+ print m3 +%+ print m2 +%+ print m1 +%+ prompt [%& %prompt "(y/N) "] +|= in=tape +?. |(=("y" in) =("Y" in) =("yes" in)) + no-product +(produce %kiln-change-publisher syd her sud) From 4440eaced6573ab2af6bf094c74ecb3765b034d6 Mon Sep 17 00:00:00 2001 From: Tinnus Napbus Date: Mon, 7 Aug 2023 21:24:52 +1200 Subject: [PATCH 3/4] kiln: make publisher change requests require approval --- pkg/arvo/app/hood.hoon | 5 +- pkg/arvo/gen/hood/jump/approve.hoon | 6 ++ .../propose.hoon} | 15 +--- pkg/arvo/gen/hood/jump/reject.hoon | 6 ++ pkg/arvo/gen/jumps.hoon | 16 ++++ pkg/arvo/lib/hood/kiln.hoon | 79 ++++++++++++++++--- .../{change-source.hoon => jump-ask.hoon} | 2 +- pkg/arvo/mar/kiln/jump-opt.hoon | 22 ++++++ pkg/arvo/mar/kiln/jump.hoon | 43 ++++++++++ pkg/base-dev/sur/hood.hoon | 9 ++- 10 files changed, 176 insertions(+), 27 deletions(-) create mode 100644 pkg/arvo/gen/hood/jump/approve.hoon rename pkg/arvo/gen/hood/{change-publisher.hoon => jump/propose.hoon} (52%) create mode 100644 pkg/arvo/gen/hood/jump/reject.hoon create mode 100644 pkg/arvo/gen/jumps.hoon rename pkg/arvo/mar/kiln/{change-source.hoon => jump-ask.hoon} (80%) create mode 100644 pkg/arvo/mar/kiln/jump-opt.hoon create mode 100644 pkg/arvo/mar/kiln/jump.hoon diff --git a/pkg/arvo/app/hood.hoon b/pkg/arvo/app/hood.hoon index 91b2ec4b82..57727514ca 100644 --- a/pkg/arvo/app/hood.hoon +++ b/pkg/arvo/app/hood.hoon @@ -2,8 +2,8 @@ /+ drum=hood-drum, helm=hood-helm, kiln=hood-kiln |% +$ state - $~ [%26 *state:drum *state:helm *state:kiln] - $>(%26 any-state) + $~ [%27 *state:drum *state:helm *state:kiln] + $>(%27 any-state) :: +$ any-state $% [ver=?(%1 %2 %3 %4 %5 %6) lac=(map @tas fin-any-state)] @@ -27,6 +27,7 @@ [%24 drum=state-4:drum helm=state-2:helm kiln=state-10:kiln] [%25 drum=state-5:drum helm=state-2:helm kiln=state-10:kiln] [%26 drum=state-6:drum helm=state-2:helm kiln=state-10:kiln] + [%27 drum=state-6:drum helm=state-2:helm kiln=state-11:kiln] == +$ any-state-tuple $: drum=any-state:drum diff --git a/pkg/arvo/gen/hood/jump/approve.hoon b/pkg/arvo/gen/hood/jump/approve.hoon new file mode 100644 index 0000000000..ce3a3b0182 --- /dev/null +++ b/pkg/arvo/gen/hood/jump/approve.hoon @@ -0,0 +1,6 @@ +:- %say +|= $: [now=@da eny=@uvJ bec=beak] + [old=dock new=dock ~] + ~ + == +kiln-jump-opt+[old new &] diff --git a/pkg/arvo/gen/hood/change-publisher.hoon b/pkg/arvo/gen/hood/jump/propose.hoon similarity index 52% rename from pkg/arvo/gen/hood/change-publisher.hoon rename to pkg/arvo/gen/hood/jump/propose.hoon index 729733f6db..75ba21a2db 100644 --- a/pkg/arvo/gen/hood/change-publisher.hoon +++ b/pkg/arvo/gen/hood/jump/propose.hoon @@ -4,20 +4,13 @@ [syd=desk her=ship sud=desk ~] hard=_| == -?: hard (produce %kiln-change-publisher syd her sud) -=/ m1 - 'This will tell desk subscribers to switch update source.' -=/ m2 - 'If you enter the wrong ship/desk, you will not be \ - /able to correct it.' -=/ m3 +?: hard (produce %kiln-jump-propose syd her sud) +=/ msg leaf+"Are you sure you want to tell subscribers to get ". "updates for {} from {}/{(trip sud)}?" -%+ print m3 -%+ print m2 -%+ print m1 +%+ print msg %+ prompt [%& %prompt "(y/N) "] |= in=tape ?. |(=("y" in) =("Y" in) =("yes" in)) no-product -(produce %kiln-change-publisher syd her sud) +(produce %kiln-jump-propose syd her sud) diff --git a/pkg/arvo/gen/hood/jump/reject.hoon b/pkg/arvo/gen/hood/jump/reject.hoon new file mode 100644 index 0000000000..b1a885c5f4 --- /dev/null +++ b/pkg/arvo/gen/hood/jump/reject.hoon @@ -0,0 +1,6 @@ +:- %say +|= $: [now=@da eny=@uvJ bec=beak] + [old=dock new=dock ~] + ~ + == +kiln-jump-opt+[old new |] diff --git a/pkg/arvo/gen/jumps.hoon b/pkg/arvo/gen/jumps.hoon new file mode 100644 index 0000000000..78c7ac5aad --- /dev/null +++ b/pkg/arvo/gen/jumps.hoon @@ -0,0 +1,16 @@ +/- h=hood +:- %say +|= [[now=@da eny=@uvJ bec=beak] ~ ~] +:- %tang +^- tang +=+ .^ hop=jump:h + %gx + (scot %p p.bec) + %hood + (scot %da now) + /kiln/jumps/noun + == +?> ?=(%all -.hop) +%+ turn ~(tap by all.hop) +|= [old=dock new=dock] +leaf+"{}/{(trip q.old)} -> {}/{(trip q.new)}" diff --git a/pkg/arvo/lib/hood/kiln.hoon b/pkg/arvo/lib/hood/kiln.hoon index 82649c42f4..d1d7a7f13b 100644 --- a/pkg/arvo/lib/hood/kiln.hoon +++ b/pkg/arvo/lib/hood/kiln.hoon @@ -5,7 +5,8 @@ =, format =* dude dude:gall |% -+$ state state-10 ++$ state state-11 ++$ state-11 [%11 pith-11] +$ state-10 [%10 pith-10] +$ state-9 [%9 pith-9] +$ state-8 [%8 pith-9] @@ -19,7 +20,8 @@ +$ state-0 [%0 pith-0] +$ any-state $~ *state - $% state-10 + $% state-11 + state-10 state-9 state-8 state-7 @@ -32,6 +34,24 @@ state-0 == :: ++$ pith-11 + $: rem=(map desk per-desk) + nyz=@ud + zyn=(map kiln-sync sync-state) + :: requests from publishers to switch sync source + hop=(map dock dock) + commit-timer=[way=wire nex=@da tim=@dr mon=term] + :: map desk to the currently ongoing fuse request + :: and the latest version numbers for beaks to + fus=(map desk per-fuse) + :: used for fuses - every time we get a fuse we + :: bump this. used when calculating hashes to + :: ensure they're unique even when the same + :: request is made multiple times. + hxs=(map desk @ud) + == +:: +:: +$ pith-10 $: rem=(map desk per-desk) nyz=@ud @@ -482,7 +502,10 @@ $(ks t.ks) == :: - ?> ?=(%10 -.old) + =? old ?=(%10 -.old) + old(- %11, |4 [hop=~ |4.old]) + :: + ?> ?=(%11 -.old) =. state old abet:(emil cards-9) :: @@ -498,6 +521,7 @@ =/ ver (mergebase-hashes our %base now (~(got by sources) %base)) ``noun+!>(?~(ver 0v0 i.ver)) :: + [%x %kiln %jumps ~] ``kiln-jump+!>([%all hop]) [%x %kiln %syncs ~] ``noun+!>(zyn) [%x %kiln %sources ~] ``noun+!>(sources) [%x %kiln %pikes ~] @@ -527,7 +551,7 @@ :: ++ poke |= [=mark =vase] - ?> |(=(src our) =(%kiln-change-source mark)) + ?> |(=(src our) =(%kiln-jump-ask mark)) ?+ mark ~|([%poke-kiln-bad-mark mark] !!) %kiln-autocommit =;(f (f !<(_+<.f vase)) poke-autocommit) %kiln-bump =;(f (f !<(_+<.f vase)) poke-bump) @@ -543,8 +567,9 @@ %kiln-label =;(f (f !<(_+<.f vase)) poke-label) %kiln-merge =;(f (f !<(_+<.f vase)) poke-merge) %kiln-mount =;(f (f !<(_+<.f vase)) poke-mount) - %kiln-change-source =;(f (f !<(_+<.f vase)) poke-change-source) - %kiln-change-publisher =;(f (f !<(_+<.f vase)) poke-change-publisher) + %kiln-jump-ask =;(f (f !<(_+<.f vase)) poke-jump-ask) + %kiln-jump-opt =;(f (f !<(_+<.f vase)) poke-jump-opt) + %kiln-jump-propose =;(f (f !<(_+<.f vase)) poke-jump-propose) %kiln-nuke =;(f (f !<(_+<.f vase)) poke-nuke) %kiln-pause =;(f (f !<(_+<.f vase)) poke-pause) %kiln-permission =;(f (f !<(_+<.f vase)) poke-permission) @@ -733,7 +758,7 @@ abet:(spam leaf+- ~) abet:(emit %pass /mount %arvo %c [%mont pot u.bem]) :: -++ poke-change-publisher +++ poke-jump-propose |= [syd=desk her=ship sud=desk] ?: =([our syd] [her sud]) abet @@ -751,14 +776,40 @@ %- emil %+ turn ~(tap in ships) |= =ship - :* %pass /kiln/change-publisher %agent [ship %hood] - %poke %kiln-change-source !>([[our syd] [her sud]]) + :* %pass /kiln/jump-propose %agent [ship %hood] + %poke %kiln-jump-ask !>([[our syd] [her sud]]) == :: -++ poke-change-source +++ poke-jump-ask |= [old=dock new=dock] ?> |(=(src p.old) =(src our)) - ?: =(old new) abet + ?: =(old new) + ?~ had=(~(get by hop) old) + abet + =. hop (~(del by hop) old) + abet:(emit %give %fact ~[/jumps] %kiln-jump !>([%nay old u.had])) + ?~ (skim ~(tap by sources) |=(kiln-sync =(old [her sud]))) + ~> %slog.(fmt "no syncs from {}/{(trip q.old)}") + abet + =. hop (~(put by hop) old new) + abet:(emit %give %fact ~[/jumps] %kiln-jump !>([%add old new])) +:: +++ poke-jump-opt + |= [old=dock new=dock yea=?] + ?~ got=(~(get by hop) old) + ~> %slog.(fmt "no jump request for {}/{(trip q.old)}") + abet + ?. =(new u.got) + =/ txt-old "{}/{(trip q.old)}" + =/ txt-new "{}/{(trip q.new)}" + ~> %slog.(fmt "no jump request from {txt-old} to {txt-new}") + abet + ?. yea + =/ txt-old "{}/{(trip q.old)}" + =/ txt-new "{}/{(trip q.new)}" + ~> %slog.(fmt "denied jump from {txt-old} to {txt-new}") + =. hop (~(del by hop) old) + abet:(emit %give %fact ~[/jumps] %kiln-jump !>([%nay old new])) =/ old-sources=(list kiln-sync) (skim ~(tap by sources) |=(kiln-sync =(old [her sud]))) =/ new-sources=(list kiln-sync) @@ -767,6 +818,8 @@ |- ?~ old-sources zyn $(old-sources t.old-sources, zyn (~(del by zyn) i.old-sources)) + =. hop (~(del by hop) old) + =. ..abet (emit %give %fact ~[/jumps] %kiln-jump !>([%yea old new])) =< abet |- ^+ ..abet ?~ new-sources ..abet @@ -900,10 +953,12 @@ ++ peer |= =path ?> (team:title our src) - ?: =(0 1) abet :: avoid mint-vain ?+ path ~|(kiln-path/path !!) [%vats ~] (mean leaf+"kiln: old subscription to /kiln/vats failed" ~) + :: + [%jumps ~] + abet:(emit %give %fact ~ %kiln-jump !>([%all hop])) == :: ++ take-agent diff --git a/pkg/arvo/mar/kiln/change-source.hoon b/pkg/arvo/mar/kiln/jump-ask.hoon similarity index 80% rename from pkg/arvo/mar/kiln/change-source.hoon rename to pkg/arvo/mar/kiln/jump-ask.hoon index e8fda84477..0e6ce52be7 100644 --- a/pkg/arvo/mar/kiln/change-source.hoon +++ b/pkg/arvo/mar/kiln/jump-ask.hoon @@ -1,5 +1,5 @@ :: -:::: /hoon/change-source/kiln/mar +:::: /hoon/jump-ask/kiln/mar :: /? 310 |_ req=[old=dock new=dock] diff --git a/pkg/arvo/mar/kiln/jump-opt.hoon b/pkg/arvo/mar/kiln/jump-opt.hoon new file mode 100644 index 0000000000..f03d2d2b03 --- /dev/null +++ b/pkg/arvo/mar/kiln/jump-opt.hoon @@ -0,0 +1,22 @@ +:: +:::: /hoon/jump-opt/kiln/mar + :: +|_ req=[old=dock new=dock yea=?] +:: +++ grow + |% + ++ noun req + -- +++ grab + |% + ++ noun ,[dock dock ?] + ++ json + =, dejs:format + %- ot + :~ [%old (ot ship+(se %p) desk+so ~)] + [%new (ot ship+(se %p) desk+so ~)] + [%yea bo] + == + -- +++ grad %noun +-- diff --git a/pkg/arvo/mar/kiln/jump.hoon b/pkg/arvo/mar/kiln/jump.hoon new file mode 100644 index 0000000000..540f35a893 --- /dev/null +++ b/pkg/arvo/mar/kiln/jump.hoon @@ -0,0 +1,43 @@ +:: +:::: /hoon/jump/kiln/mar + :: +/- h=hood +|_ jum=jump:h +:: +++ grow + |% + ++ noun jum + ++ json + =, enjs:format + |^ ^- ^json + ?- -.jum + %add + %+ frond 'add' + (pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~) + :: + %yea + %+ frond 'yea' + (pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~) + :: + %nay + %+ frond 'nay' + (pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~) + :: + %all + %+ frond 'all' + :- %a + %+ turn ~(tap by all.jum) + |= [old=dock new=dock] + (pairs ['old' (en-dock old)] ['new' (en-dock new)] ~) + == + ++ en-dock + |= =dock + (pairs ['ship' s+(scot %p p.dock)] ['desk' s+q.dock] ~) + -- + -- +++ grab + |% + ++ noun jump:h + -- +++ grad %noun +-- diff --git a/pkg/base-dev/sur/hood.hoon b/pkg/base-dev/sur/hood.hoon index 5c736f2714..3c0430f990 100644 --- a/pkg/base-dev/sur/hood.hoon +++ b/pkg/base-dev/sur/hood.hoon @@ -10,7 +10,14 @@ == :: +$ pikes (map desk pike) -:: +:: $jump: changes to update source change requests +:: ++$ jump + $% [%all all=(map dock dock)] :: pending requests + [%add old=dock new=dock] :: new request + [%yea old=dock new=dock] :: approved + [%nay old=dock new=dock] :: denied + == :: $rung: reference to upstream commit :: +$ rung [=aeon =weft] From b59525a203c24194aa2e7dd23e337c1abe58486d Mon Sep 17 00:00:00 2001 From: Tinnus Napbus Date: Fri, 8 Sep 2023 03:13:47 +1200 Subject: [PATCH 4/4] kiln: OTA merge control - let users disable automatic OTA merging for a sync or globally - a sync can be set to manual, automatic or global default - unapproved non-auto updates must be approved by the user --- pkg/arvo/gen/hood/approve-merge.hoon | 6 + pkg/arvo/gen/hood/global-automerge.hoon | 6 + pkg/arvo/gen/hood/sync-automerge.hoon | 6 + pkg/arvo/gen/updates.hoon | 16 ++ pkg/arvo/lib/hood/kiln.hoon | 221 +++++++++++++++++------ pkg/arvo/mar/kiln/approve-merge.hoon | 1 + pkg/arvo/mar/kiln/jump-ask.hoon | 17 +- pkg/arvo/mar/kiln/jump-opt.hoon | 23 +-- pkg/arvo/mar/kiln/jump.hoon | 44 +---- pkg/arvo/mar/kiln/sync-update.hoon | 1 + pkg/base-dev/mar/kiln/approve-merge.hoon | 22 +++ pkg/base-dev/mar/kiln/jump-ask.hoon | 16 ++ pkg/base-dev/mar/kiln/jump-opt.hoon | 22 +++ pkg/base-dev/mar/kiln/jump.hoon | 43 +++++ pkg/base-dev/mar/kiln/sync-update.hoon | 50 +++++ pkg/base-dev/sur/hood.hoon | 28 ++- 16 files changed, 381 insertions(+), 141 deletions(-) create mode 100644 pkg/arvo/gen/hood/approve-merge.hoon create mode 100644 pkg/arvo/gen/hood/global-automerge.hoon create mode 100644 pkg/arvo/gen/hood/sync-automerge.hoon create mode 100644 pkg/arvo/gen/updates.hoon create mode 120000 pkg/arvo/mar/kiln/approve-merge.hoon mode change 100644 => 120000 pkg/arvo/mar/kiln/jump-ask.hoon mode change 100644 => 120000 pkg/arvo/mar/kiln/jump-opt.hoon mode change 100644 => 120000 pkg/arvo/mar/kiln/jump.hoon create mode 120000 pkg/arvo/mar/kiln/sync-update.hoon create mode 100644 pkg/base-dev/mar/kiln/approve-merge.hoon create mode 100644 pkg/base-dev/mar/kiln/jump-ask.hoon create mode 100644 pkg/base-dev/mar/kiln/jump-opt.hoon create mode 100644 pkg/base-dev/mar/kiln/jump.hoon create mode 100644 pkg/base-dev/mar/kiln/sync-update.hoon diff --git a/pkg/arvo/gen/hood/approve-merge.hoon b/pkg/arvo/gen/hood/approve-merge.hoon new file mode 100644 index 0000000000..58a49cc5a2 --- /dev/null +++ b/pkg/arvo/gen/hood/approve-merge.hoon @@ -0,0 +1,6 @@ +:- %say +|= $: [now=@da eny=@uvJ bec=beak] + [syd=desk her=ship sud=desk approve=? ~] + ~ + == +kiln-approve-merge+[[syd her sud] approve] diff --git a/pkg/arvo/gen/hood/global-automerge.hoon b/pkg/arvo/gen/hood/global-automerge.hoon new file mode 100644 index 0000000000..d8992f54e2 --- /dev/null +++ b/pkg/arvo/gen/hood/global-automerge.hoon @@ -0,0 +1,6 @@ +:- %say +|= $: [now=@da eny=@uvJ bec=beak] + [auto=? ~] + ~ + == +kiln-global-automerge+auto diff --git a/pkg/arvo/gen/hood/sync-automerge.hoon b/pkg/arvo/gen/hood/sync-automerge.hoon new file mode 100644 index 0000000000..7daf36fcab --- /dev/null +++ b/pkg/arvo/gen/hood/sync-automerge.hoon @@ -0,0 +1,6 @@ +:- %say +|= $: [now=@da eny=@uvJ bec=beak] + [syd=desk her=ship sud=desk auto=(unit ?) ~] + ~ + == +kiln-sync-automerge+[[syd her sud] auto] diff --git a/pkg/arvo/gen/updates.hoon b/pkg/arvo/gen/updates.hoon new file mode 100644 index 0000000000..94bbe88c51 --- /dev/null +++ b/pkg/arvo/gen/updates.hoon @@ -0,0 +1,16 @@ +/- h=hood +:- %say +|= [[now=@da eny=@uvJ bec=beak] ~ ~] +:- %tang +^- tang +=+ .^ upd=sync-update:h + %gx + (scot %p p.bec) + %hood + (scot %da now) + /kiln/pending/noun + == +?> ?=(%pending -.upd) +%+ turn ~(tap in pending.upd) +|= [sync-record:h rev=@ud] +leaf+"{} <- {}/{(trip sud)}/{}" diff --git a/pkg/arvo/lib/hood/kiln.hoon b/pkg/arvo/lib/hood/kiln.hoon index a55c580ef6..28fcbda692 100644 --- a/pkg/arvo/lib/hood/kiln.hoon +++ b/pkg/arvo/lib/hood/kiln.hoon @@ -37,9 +37,12 @@ +$ pith-11 $: rem=(map desk per-desk) nyz=@ud - zyn=(map kiln-sync sync-state) + zyn=(map sync-record sync-state) :: requests from publishers to switch sync source hop=(map dock dock) + :: toggle global update auto-merge + mer=? + :: commit-timer=[way=wire nex=@da tim=@dr mon=term] :: map desk to the currently ongoing fuse request :: and the latest version numbers for beaks to @@ -51,11 +54,12 @@ hxs=(map desk @ud) == :: ++$ sync-state-10 [nun=@ta kid=(unit desk) let=@ud] :: +$ pith-10 $: rem=(map desk per-desk) nyz=@ud - zyn=(map kiln-sync sync-state) + zyn=(map sync-record sync-state-10) commit-timer=[way=wire nex=@da tim=@dr mon=term] :: map desk to the currently ongoing fuse request :: and the latest version numbers for beaks to @@ -70,7 +74,7 @@ +$ pith-9 $: wef=(unit weft) rem=(map desk per-desk) - syn=(map kiln-sync let=@ud) + syn=(map sync-record let=@ud) ark=(map desk arak-9) commit-timer=[way=wire nex=@da tim=@dr mon=term] :: map desk to the currently ongoing fuse request @@ -98,7 +102,7 @@ +$ pith-7 $: wef=(unit weft) rem=(map desk per-desk) - syn=(map kiln-sync let=@ud) + syn=(map sync-record let=@ud) ark=(map desk arak-7) commit-timer=[way=wire nex=@da tim=@dr mon=term] :: map desk to the currently ongoing fuse request @@ -141,7 +145,7 @@ +$ pith-6 $: wef=(unit weft) rem=(map desk per-desk) :: - syn=(map kiln-sync let=@ud) :: + syn=(map sync-record let=@ud) :: ark=(map desk arak-6) :: commit-timer=[way=wire nex=@da tim=@dr mon=term] :: :: map desk to the currently ongoing fuse request @@ -159,7 +163,7 @@ :: +$ pith-5 $: rem=(map desk per-desk) :: - syn=(map kiln-sync let=@ud) :: + syn=(map sync-record let=@ud) :: ark=(map desk arak-6) :: commit-timer=[way=wire nex=@da tim=@dr mon=term] :: :: map desk to the currently ongoing fuse request @@ -174,7 +178,7 @@ :: +$ pith-4 :: $: rem=(map desk per-desk) :: - syn=(map kiln-sync let=@ud) :: + syn=(map sync-record let=@ud) :: ark=(map desk arak-4) :: commit-timer=[way=wire nex=@da tim=@dr mon=term] :: :: map desk to the currently ongoing fuse request @@ -195,7 +199,7 @@ == +$ pith-3 :: $: rem=(map desk per-desk) :: - syn=(map kiln-sync let=@ud) :: + syn=(map sync-record let=@ud) :: ark=(map desk arak-3) :: commit-timer=[way=wire nex=@da tim=@dr mon=term] :: :: map desk to the currently ongoing fuse request @@ -221,7 +225,7 @@ :: +$ pith-2 :: $: rem=(map desk per-desk) :: - syn=(map kiln-sync let=@ud) :: + syn=(map sync-record let=@ud) :: ota=(unit [=ship =desk =aeon]) :: commit-timer=[way=wire nex=@da tim=@dr mon=term] :: fus=(map desk per-fuse) @@ -229,13 +233,13 @@ == :: +$ pith-1 :: $: rem=(map desk per-desk) :: - syn=(map kiln-sync let=@ud) :: + syn=(map sync-record let=@ud) :: ota=(unit [=ship =desk =aeon]) :: commit-timer=[way=wire nex=@da tim=@dr mon=term] :: == :: +$ pith-0 :: $: rem=(map desk per-desk) :: - syn=(map kiln-sync let=@ud) :: + syn=(map sync-record let=@ud) :: autoload-on=? :: cur-hoon=@uvI :: cur-arvo=@uvI :: @@ -265,16 +269,6 @@ pot=term :: == +$ kiln-unmount $@(term [knot path]) :: -+$ kiln-sync :: - $: syd=desk :: local desk - her=ship :: foreign ship - sud=desk :: foreign desk - == -+$ kiln-unsync :: - $: syd=desk :: local desk - her=ship :: foreign ship - sud=desk :: foreign desk - == +$ kiln-merge :: $@ ~ $: syd=desk :: @@ -459,7 +453,7 @@ =^ cards-9=(list card:agent:gall) old ?. ?=(%9 -.old) `old - =/ syn=(set kiln-sync) + =/ syn=(set sync-record) %- ~(gas in ~(key by syn.old)) %+ murn ~(tap by ark.old) |= [=desk =arak-9] @@ -487,8 +481,8 @@ [%pass /kiln/load-zest %arvo %c %zest desk zest] :: %+ turn ~(tap in syn) - |= k=kiln-sync - [%pass /kiln/load-sync %agent [our %hood] %poke %kiln-sync !>(k)] + |= r=sync-record + [%pass /kiln/load-sync %agent [our %hood] %poke %kiln-sync !>(r)] :: =/ ks ~(tap in syn) |- ^- (list card:agent:gall) @@ -503,7 +497,14 @@ == :: =? old ?=(%10 -.old) - old(- %11, |4 [hop=~ |4.old]) + %= old + - %11 + |4 [hop=~ mer=& |4.old] + zyn %- ~(run by zyn.old) + |= sync-state-10 + ^- sync-state + [nun kid let ~ ~ |] + == :: ?> ?=(%11 -.old) =. state old @@ -521,9 +522,10 @@ =/ ver (mergebase-hashes our %base now (~(got by sources) %base)) ``noun+!>(?~(ver 0v0 i.ver)) :: - [%x %kiln %jumps ~] ``kiln-jump+!>([%all hop]) - [%x %kiln %syncs ~] ``noun+!>(zyn) - [%x %kiln %sources ~] ``noun+!>(sources) + [%x %kiln %jumps ~] ``kiln-jump+!>([%all hop]) + [%x %kiln %syncs ~] ``noun+!>(zyn) + [%x %kiln %sources ~] ``noun+!>(sources) + [%x %kiln %automerge ~] ``loob+!>(mer) [%x %kiln %pikes ~] =+ .^(=rock:tire %cx /(scot %p our)//(scot %da now)/tire) :^ ~ ~ %kiln-pikes @@ -534,6 +536,17 @@ =+ .^(hash=@uv %cz /(scot %p our)/[desk]/(scot %da now)) =/ sync (~(get by sources) desk) [sync hash zest wic] + :: + [%x %kiln %pending ~] + :^ ~ ~ %kiln-sync-update + !> ^- sync-update + :- %pending + %- ~(gas by *(set [sync-record @ud])) + ^- (list [sync-record @ud]) + %+ murn ~(tap by zyn) + |= [sync-record sync-state] + ?~ hav ~ + (some [syd her sud] u.hav) == :: :: +get-germ: select merge strategy into local desk @@ -553,11 +566,13 @@ |= [=mark =vase] ?> |(=(src our) =(%kiln-jump-ask mark)) ?+ mark ~|([%poke-kiln-bad-mark mark] !!) + %kiln-approve-merge =;(f (f !<(_+<.f vase)) poke-approve-merge) %kiln-autocommit =;(f (f !<(_+<.f vase)) poke-autocommit) %kiln-bump =;(f (f !<(_+<.f vase)) poke-bump) %kiln-cancel =;(f (f !<(_+<.f vase)) poke-cancel) %kiln-cancel-autocommit =;(f (f !<(_+<.f vase)) poke-cancel-autocommit) %kiln-commit =;(f (f !<(_+<.f vase)) poke-commit) + %kiln-sync-automerge =;(f (f !<(_+<.f vase)) poke-sync-automerge) %kiln-fuse =;(f (f !<(_+<.f vase)) poke-fuse) %kiln-fuse-list =;(f (f !<(_+<.f vase)) poke-fuse-list) %kiln-gall-sear =;(f (f !<(_+<.f vase)) poke-gall-sear) @@ -576,6 +591,7 @@ %kiln-revive =;(f (f !<(_+<.f vase)) poke-revive) %kiln-rein =;(f (f !<(_+<.f vase)) poke-rein) %kiln-rm =;(f (f !<(_+<.f vase)) poke-rm) + %kiln-global-automerge =;(f (f !<(_+<.f vase)) poke-global-automerge) %kiln-schedule =;(f (f !<(_+<.f vase)) poke-schedule) %kiln-suspend =;(f (f !<(_+<.f vase)) poke-suspend) %kiln-suspend-many =;(f (f !<(_+<.f vase)) poke-suspend-many) @@ -586,6 +602,19 @@ %kiln-unsync =;(f (f !<(_+<.f vase)) poke-unsync) == :: +++ poke-approve-merge + |= [sync-record approve=?] + ?~ got=(~(get by zyn) syd her sud) + =+ msg="kiln: no syncs from {(scow %p her)}/{(trip sud)} to {}" + ((slog leaf+msg ~) abet) + ?~ hav.u.got + =+ msg="kiln: no updates from {(scow %p her)}/{(trip sud)} for {}" + ((slog leaf+msg ~) abet) + =< abet + ?. approve + abet:drop:(sync syd her sud) + abet:(merg /main syd):(sync syd her sud) +:: ++ poke-autocommit |= [mon=kiln-commit auto=?] =< abet @@ -706,6 +735,23 @@ |= =ship abet:(emit %pass /kiln %arvo %g %sear ship) :: +++ poke-global-automerge + |= auto=? + =. mer auto + ?. mer abet + =/ zyns=(list [sync-record sync-state]) ~(tap by zyn) + =< abet + |- + ?~ zyns ..abet + ?. ?& ?=(^ hav.i.zyns) + !?=([~ %.n] nit.i.zyns) + == + $(zyns t.zyns) + %= $ + zyns t.zyns + ..abet abet:(merg /main syd):(sync -.i.zyns) + == +:: ++ poke-info |= [mez=tape tor=(unit toro)] ?~ tor @@ -719,17 +765,20 @@ ?~ got=(~(get by rock) loc) %dead zest.u.got - =. zyn + =. ..abet ?~ got=(~(get by sources) loc) - zyn - (~(del by zyn) loc u.got) + ..abet + ?: =([her rem] u.got) + ..abet + =. ..abet abet:drop:(sync loc u.got) + ..abet(zyn (~(del by zyn) loc u.got)) =? ..abet ?=(%dead zest) (emit %pass /kiln/install %arvo %c %zest loc ?:(=(our her) %live %held)) ?: (~(has by zyn) loc her rem) abet:(spam (render "already syncing" loc her rem ~) ~) ?: =([our loc] [her rem]) abet - =/ sun (sync loc her rem) + =/ sun okay:(sync loc her rem) ~> %slog.(fmt "beginning install into {here:sun}") =< abet:abet:init ?: =(%base loc) @@ -737,7 +786,7 @@ sun :: ++ poke-kids - |= [hos=kiln-sync nex=(unit desk)] + |= [hos=sync-record nex=(unit desk)] abet:abet:(apex:(sync hos) nex) :: ++ poke-label @@ -788,7 +837,7 @@ abet =. hop (~(del by hop) old) abet:(emit %give %fact ~[/jumps] %kiln-jump !>([%nay old u.had])) - ?~ (skim ~(tap by sources) |=(kiln-sync =(old [her sud]))) + ?~ (skim ~(tap by sources) |=(sync-record =(old [her sud]))) ~> %slog.(fmt "no syncs from {}/{(trip q.old)}") abet =. hop (~(put by hop) old new) @@ -810,16 +859,20 @@ ~> %slog.(fmt "denied jump from {txt-old} to {txt-new}") =. hop (~(del by hop) old) abet:(emit %give %fact ~[/jumps] %kiln-jump !>([%nay old new])) - =/ old-sources=(list kiln-sync) - (skim ~(tap by sources) |=(kiln-sync =(old [her sud]))) - =/ new-sources=(list kiln-sync) - (turn old-sources |=(kiln-sync [syd new])) - =. zyn + =/ old-sources=(list sync-record) + (skim ~(tap by sources) |=(sync-record =(old [her sud]))) + =/ new-sources=(list sync-record) + (turn old-sources |=(sync-record [syd new])) + =. ..abet + (emit %give %fact ~[/jumps] %kiln-jump !>([%yea old new])) + =. ..abet |- - ?~ old-sources zyn - $(old-sources t.old-sources, zyn (~(del by zyn) i.old-sources)) + ?~ old-sources + ..abet + =. ..abet abet:drop:(sync i.old-sources) + =. zyn (~(del by zyn) i.old-sources) + $(old-sources t.old-sources, ..abet ..abet) =. hop (~(del by hop) old) - =. ..abet (emit %give %fact ~[/jumps] %kiln-jump !>([%yea old new])) =< abet |- ^+ ..abet ?~ new-sources ..abet @@ -902,11 +955,28 @@ |=(=desk [%pass /kiln/suspend %arvo %c %zest desk %dead]) :: ++ poke-sync - |= hos=kiln-sync - ?: (~(has by zyn) hos) - abet:(spam (render "already syncing" [sud her syd ~]:hos) ~) - ~> %slog.(fmt "beginning sync into {} from {}/{}") - abet:abet:init:(sync hos) + |= sync-record + ?: (~(has by zyn) sud her syd) + abet:(spam (render "already syncing" [sud her syd ~]) ~) + =. ..abet + ?~ got=(~(get by sources) syd) + ..abet + =. ..abet abet:drop:(sync syd u.got) + ..abet(zyn (~(del by zyn) syd u.got)) + ~> %slog.(fmt "beginning sync into {} from {}/{}") + abet:abet:init:(sync syd her sud) +:: +++ poke-sync-automerge + |= [sync-record auto=(unit ?)] + ?~ got=(~(get by zyn) syd her sud) + =+ msg="kiln: no syncs from {(scow %p her)}/{(trip sud)} to {}" + ((slog leaf+msg ~) abet) + =. zyn (~(put by zyn) [syd her sud] u.got(nit auto)) + ?~ hav.u.got + abet + ?. |(?=([~ %.y] auto) &(mer ?=(~ auto))) + abet + abet:abet:(merg /main syd):(sync [syd her sud]) :: ++ poke-syncs :: print sync config |= ~ @@ -914,7 +984,7 @@ ?: =(0 ~(wyt by zyn)) [%leaf "no syncs configured"]~ %+ turn ~(tap by zyn) - |= [kiln-sync sync-state] + |= [sync-record sync-state] (render "sync configured" sud her syd kid) :: ++ poke-uninstall @@ -942,9 +1012,10 @@ :: Don't need to cancel anything because new syncs will get a new nonce :: ++ poke-unsync - |= hus=kiln-unsync + |= hus=sync-record ?~ got=(~(get by zyn) hus) abet:(spam (render "not syncing" [sud her syd ~]:hus) ~) + =. ..abet abet:drop:(sync hus) =. zyn (~(del by zyn) hus) abet:(spam (render "cancelling sync" sud.hus her.hus syd.hus kid.u.got) ~) :: +peer: handle %watch @@ -958,6 +1029,20 @@ :: [%jumps ~] abet:(emit %give %fact ~ %kiln-jump !>([%all hop])) + :: + [%updates ~] + =< abet + %- emit + :^ %give %fact ~ + :- %kiln-sync-update + !> ^- sync-update + :- %pending + %- ~(gas by *(set [sync-record @ud])) + ^- (list [sync-record @ud]) + %+ murn ~(tap by zyn) + |= [sync-record sync-state] + ?~ hav ~ + (some [syd her sud] u.hav) == :: ++ take-agent @@ -1183,15 +1268,30 @@ abet:abet:(take:(sync syd her sud) t.t.t.wire sign-arvo) :: ++ sync - |= kiln-sync + |= sync-record =/ got (~(get by zyn) syd her sud) - =+ `sync-state`(fall got [(scot %uv nyz) ~ *@ud]) + =+ `sync-state`(fall got [(scot %uv nyz) ~ *@ud ~ ~ |]) =? nyz ?=(~ got) +(nyz) |% - ++ abet ..sync(zyn (~(put by zyn) [syd her sud] nun kid let)) + ++ abet ..sync(zyn (~(put by zyn) [syd her sud] nun kid let nit hav yea)) ++ apex |=(nex=(unit desk) ..abet(kid nex)) ++ emit |=(card:agent:gall ..abet(kiln (^emit +<))) ++ emil |=((list card:agent:gall) ..abet(kiln (^emil +<))) + ++ okay ..abet(yea &) + ++ gain + =. hav `(dec let) + =/ upd=sync-update [%new [syd her sud] (dec let)] + (emit %give %fact ~[/update] %kiln-sync-update !>(upd)) + ++ drop + =? ..abet ?=(^ hav) + =/ upd=sync-update [%drop [syd her sud] u.hav] + (emit %give %fact ~[/updates] %kiln-sync-update !>(upd)) + ..abet(hav ~, yea |) + ++ tada + =? ..abet ?=(^ hav) + =/ upd=sync-update [%done [syd her sud] u.hav] + (emit %give %fact ~[/updates] %kiln-sync-update !>(upd)) + ..abet(hav ~, yea |) ++ here "{} from {}/{}" ++ ware |= =wire @@ -1206,7 +1306,6 @@ %merg desk her sud ud+(dec let) (get-germ desk) == - :: :: (re)Start a sync from scratch by finding what version the source :: desk is at :: @@ -1234,8 +1333,8 @@ ?> ?=(^ riot) :: The syncs may have changed, so get the latest :: - ;< zyx=(map kiln-sync sync-state) bind:m - (scry:strandio (map kiln-sync sync-state) /gx/hood/kiln/syncs/noun) + ;< zyx=(map sync-record sync-state) bind:m + (scry:strandio (map sync-record sync-state) /gx/hood/kiln/syncs/noun) ?. (~(has by zyx) syd her sud) (pure:m !>(%done)) ~> %slog.(fmt "downloading update for {here}") @@ -1280,6 +1379,7 @@ ?: ?=(%| -.p.sign-arvo) :: ~> %slog.(fmt "download failed into {here}; retrying sync") :: %- (slog p.p.sign-arvo) + =. ..abet drop init :: ~> %slog.(fmt "finished downloading update for {here}") @@ -1287,7 +1387,7 @@ :: If nothing changed, just ensure %kids is up-to-date and advance :: ?. (get-remote-diff our syd now [her sud (dec let)]) - =< next + =< next:drop ?~ kid ~> %slog.(fmt "remote is identical to {here}, skipping") ..abet @@ -1296,15 +1396,22 @@ ..abet ~> %slog.(fmt "remote is identical to {here}, merging into {}") (merg /kids u.kid) + :: wait for approval if can't automerge & signal available update + :: + ?. |(=(our her) yea =([~ &] nit) &(=(~ nit) mer)) + =. ..abet gain + next :: Else start merging, but also immediately start listening to :: the next revision. Now, all errors should no-op -- we're :: already waiting for the next revision. :: + =. yea | =. ..abet (merg /main syd) next :: - %main + %main ?> ?=(%mere +<.sign-arvo) + =< tada ?: ?=(%| -.p.sign-arvo) =+ "kiln: merge into {here} failed, waiting for next revision" %- (slog leaf/- p.p.sign-arvo) diff --git a/pkg/arvo/mar/kiln/approve-merge.hoon b/pkg/arvo/mar/kiln/approve-merge.hoon new file mode 120000 index 0000000000..cceb68cc1b --- /dev/null +++ b/pkg/arvo/mar/kiln/approve-merge.hoon @@ -0,0 +1 @@ +../../../base-dev/mar/kiln/approve-merge.hoon \ No newline at end of file diff --git a/pkg/arvo/mar/kiln/jump-ask.hoon b/pkg/arvo/mar/kiln/jump-ask.hoon deleted file mode 100644 index 0e6ce52be7..0000000000 --- a/pkg/arvo/mar/kiln/jump-ask.hoon +++ /dev/null @@ -1,16 +0,0 @@ -:: -:::: /hoon/jump-ask/kiln/mar - :: -/? 310 -|_ req=[old=dock new=dock] -:: -++ grow - |% - ++ noun req - -- -++ grab - |% - ++ noun ,[dock dock] - -- -++ grad %noun --- diff --git a/pkg/arvo/mar/kiln/jump-ask.hoon b/pkg/arvo/mar/kiln/jump-ask.hoon new file mode 120000 index 0000000000..c13477815d --- /dev/null +++ b/pkg/arvo/mar/kiln/jump-ask.hoon @@ -0,0 +1 @@ +../../../base-dev/mar/kiln/jump-ask.hoon \ No newline at end of file diff --git a/pkg/arvo/mar/kiln/jump-opt.hoon b/pkg/arvo/mar/kiln/jump-opt.hoon deleted file mode 100644 index f03d2d2b03..0000000000 --- a/pkg/arvo/mar/kiln/jump-opt.hoon +++ /dev/null @@ -1,22 +0,0 @@ -:: -:::: /hoon/jump-opt/kiln/mar - :: -|_ req=[old=dock new=dock yea=?] -:: -++ grow - |% - ++ noun req - -- -++ grab - |% - ++ noun ,[dock dock ?] - ++ json - =, dejs:format - %- ot - :~ [%old (ot ship+(se %p) desk+so ~)] - [%new (ot ship+(se %p) desk+so ~)] - [%yea bo] - == - -- -++ grad %noun --- diff --git a/pkg/arvo/mar/kiln/jump-opt.hoon b/pkg/arvo/mar/kiln/jump-opt.hoon new file mode 120000 index 0000000000..2b49747d07 --- /dev/null +++ b/pkg/arvo/mar/kiln/jump-opt.hoon @@ -0,0 +1 @@ +../../../base-dev/mar/kiln/jump-opt.hoon \ No newline at end of file diff --git a/pkg/arvo/mar/kiln/jump.hoon b/pkg/arvo/mar/kiln/jump.hoon deleted file mode 100644 index 540f35a893..0000000000 --- a/pkg/arvo/mar/kiln/jump.hoon +++ /dev/null @@ -1,43 +0,0 @@ -:: -:::: /hoon/jump/kiln/mar - :: -/- h=hood -|_ jum=jump:h -:: -++ grow - |% - ++ noun jum - ++ json - =, enjs:format - |^ ^- ^json - ?- -.jum - %add - %+ frond 'add' - (pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~) - :: - %yea - %+ frond 'yea' - (pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~) - :: - %nay - %+ frond 'nay' - (pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~) - :: - %all - %+ frond 'all' - :- %a - %+ turn ~(tap by all.jum) - |= [old=dock new=dock] - (pairs ['old' (en-dock old)] ['new' (en-dock new)] ~) - == - ++ en-dock - |= =dock - (pairs ['ship' s+(scot %p p.dock)] ['desk' s+q.dock] ~) - -- - -- -++ grab - |% - ++ noun jump:h - -- -++ grad %noun --- diff --git a/pkg/arvo/mar/kiln/jump.hoon b/pkg/arvo/mar/kiln/jump.hoon new file mode 120000 index 0000000000..c8e8202368 --- /dev/null +++ b/pkg/arvo/mar/kiln/jump.hoon @@ -0,0 +1 @@ +../../../base-dev/mar/kiln/jump.hoon \ No newline at end of file diff --git a/pkg/arvo/mar/kiln/sync-update.hoon b/pkg/arvo/mar/kiln/sync-update.hoon new file mode 120000 index 0000000000..93eaa91d50 --- /dev/null +++ b/pkg/arvo/mar/kiln/sync-update.hoon @@ -0,0 +1 @@ +../../../base-dev/mar/kiln/sync-update.hoon \ No newline at end of file diff --git a/pkg/base-dev/mar/kiln/approve-merge.hoon b/pkg/base-dev/mar/kiln/approve-merge.hoon new file mode 100644 index 0000000000..b1b25fa64f --- /dev/null +++ b/pkg/base-dev/mar/kiln/approve-merge.hoon @@ -0,0 +1,22 @@ +:: +:::: /hoon/approve-merge/kiln/mar + :: +/- h=hood +|_ req=[sync-record:h approve=?] +:: +++ grow + |% + ++ noun req + -- +++ grab + |% + ++ noun ,[sync-record:h approve=?] + ++ json + =, dejs:format + %- ot + :~ [%sync (ot syd+so her+(se %p) sud+so ~)] + [%approve bo] + == + -- +++ grad %noun +-- diff --git a/pkg/base-dev/mar/kiln/jump-ask.hoon b/pkg/base-dev/mar/kiln/jump-ask.hoon new file mode 100644 index 0000000000..0e6ce52be7 --- /dev/null +++ b/pkg/base-dev/mar/kiln/jump-ask.hoon @@ -0,0 +1,16 @@ +:: +:::: /hoon/jump-ask/kiln/mar + :: +/? 310 +|_ req=[old=dock new=dock] +:: +++ grow + |% + ++ noun req + -- +++ grab + |% + ++ noun ,[dock dock] + -- +++ grad %noun +-- diff --git a/pkg/base-dev/mar/kiln/jump-opt.hoon b/pkg/base-dev/mar/kiln/jump-opt.hoon new file mode 100644 index 0000000000..f03d2d2b03 --- /dev/null +++ b/pkg/base-dev/mar/kiln/jump-opt.hoon @@ -0,0 +1,22 @@ +:: +:::: /hoon/jump-opt/kiln/mar + :: +|_ req=[old=dock new=dock yea=?] +:: +++ grow + |% + ++ noun req + -- +++ grab + |% + ++ noun ,[dock dock ?] + ++ json + =, dejs:format + %- ot + :~ [%old (ot ship+(se %p) desk+so ~)] + [%new (ot ship+(se %p) desk+so ~)] + [%yea bo] + == + -- +++ grad %noun +-- diff --git a/pkg/base-dev/mar/kiln/jump.hoon b/pkg/base-dev/mar/kiln/jump.hoon new file mode 100644 index 0000000000..540f35a893 --- /dev/null +++ b/pkg/base-dev/mar/kiln/jump.hoon @@ -0,0 +1,43 @@ +:: +:::: /hoon/jump/kiln/mar + :: +/- h=hood +|_ jum=jump:h +:: +++ grow + |% + ++ noun jum + ++ json + =, enjs:format + |^ ^- ^json + ?- -.jum + %add + %+ frond 'add' + (pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~) + :: + %yea + %+ frond 'yea' + (pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~) + :: + %nay + %+ frond 'nay' + (pairs ['old' (en-dock old.jum)] ['new' (en-dock new.jum)] ~) + :: + %all + %+ frond 'all' + :- %a + %+ turn ~(tap by all.jum) + |= [old=dock new=dock] + (pairs ['old' (en-dock old)] ['new' (en-dock new)] ~) + == + ++ en-dock + |= =dock + (pairs ['ship' s+(scot %p p.dock)] ['desk' s+q.dock] ~) + -- + -- +++ grab + |% + ++ noun jump:h + -- +++ grad %noun +-- diff --git a/pkg/base-dev/mar/kiln/sync-update.hoon b/pkg/base-dev/mar/kiln/sync-update.hoon new file mode 100644 index 0000000000..20a3166558 --- /dev/null +++ b/pkg/base-dev/mar/kiln/sync-update.hoon @@ -0,0 +1,50 @@ +:: +:::: /hoon/sync-update/kiln/mar + :: +/- h=hood +|_ upd=sync-update:h +:: +++ grow + |% + ++ noun upd + ++ json + =, enjs:format + |^ ^- ^json + ?- -.upd + %new + %+ frond 'new' + (pairs ['for' (en-sync-record for.upd)] ['rev' (numb rev.upd)] ~) + :: + %done + %+ frond 'done' + (pairs ['for' (en-sync-record for.upd)] ['rev' (numb rev.upd)] ~) + :: + %drop + %+ frond 'drop' + (pairs ['for' (en-sync-record for.upd)] ['rev' (numb rev.upd)] ~) + :: + %pending + %+ frond 'pending' + :- %a + %+ turn ~(tap by pending.upd) + |= [for=sync-record:h rev=@ud] + %- pairs + :~ ['for' (en-sync-record for)] + ['rev' (numb rev)] + == + == + ++ en-sync-record + |= sync-record:h + %- pairs + :~ ['syd' s+syd] + ['her' s+(scot %p her)] + ['sud' s+sud] + == + -- + -- +++ grab + |% + ++ noun sync-update:h + -- +++ grad %noun +-- diff --git a/pkg/base-dev/sur/hood.hoon b/pkg/base-dev/sur/hood.hoon index 3c0430f990..1b5e58ca44 100644 --- a/pkg/base-dev/sur/hood.hoon +++ b/pkg/base-dev/sur/hood.hoon @@ -21,8 +21,30 @@ :: $rung: reference to upstream commit :: +$ rung [=aeon =weft] +:: #sync-record: source and destination of a kiln sync +:: ++$ sync-record :: + $: syd=desk :: local desk + her=ship :: foreign ship + sud=desk :: foreign desk + == +:: ++$ sync-state :: + $: nun=@ta :: nonce + kid=(unit desk) :: has kids desk too? + let=@ud :: next revision + nit=(unit ?) :: automerge or default + hav=(unit @ud) :: update available + yea=? :: update approved + == +:: ++$ sync-update + $% [%new for=sync-record rev=@ud] + [%done for=sync-record rev=@ud] + [%drop for=sync-record rev=@ud] + [%pending pending=(set [for=sync-record rev=@ud])] + == :: -+$ sync-state [nun=@ta kid=(unit desk) let=@ud] +$ sink (unit [her=@p sud=desk kid=(unit desk) let=@ud]) :: +truncate-hash: get last 5 digits of hash and convert to tape :: @@ -108,7 +130,7 @@ :: +report-vat: report on a single desk installation :: ++ report-vat - |= $: $: tyr=rock:tire =cone sor=(map desk [ship desk]) + |= $: $: tyr=rock:tire =cone sor=(map desk (pair ship desk)) zyn=(map [desk ship desk] sync-state) == our=ship now=@da syd=desk verb=? @@ -144,7 +166,7 @@ ~ ?~ z=(~(get by zyn) syd u.s) ~ - `[-.u.s +.u.s +.u.z] + `[p.u.s q.u.s [kid let]:u.z] =/ meb=(list @uv) ?~ sink [hash]~ (mergebase-hashes our syd now her.u.sink sud.u.sink)