kiln: wip

This commit is contained in:
Philip Monk 2022-08-25 21:57:20 -08:00
parent 9a4d754429
commit fa569cf7f3
5 changed files with 201 additions and 209 deletions

View File

@ -278,7 +278,7 @@
:: restart %eth-watcher
::
~& >> %starting-eth-watcher
=/ rein=[desk rein] [%base %.y [%eth-watcher ~ ~] ~]
=/ rein=[desk rein] [%base [%eth-watcher %&] ~ ~]
:_ cards
[%pass /rein %agent [our.bowl %hood] %poke kiln-rein+!>(rein)]
=? cards !installed

View File

@ -18,7 +18,8 @@
+$ state-0 [%0 pith-0]
+$ any-state
$~ *state
$% state-9
$% state-10
state-9
state-8
state-7
state-6
@ -32,7 +33,7 @@
::
+$ pith-10
$: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) ::
syn=(map kiln-sync [let=@ud nex=(unit desk)]) ::
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
@ -60,12 +61,24 @@
hxs=(map desk @ud)
==
::
:: $rein-9: diff from desk manifest
::
:: .liv: suspended? if suspended, no agents should run
:: .add: agents not in manifest that should be running
:: .sub: agents in manifest that should not be running
::
+$ rein-9
$: liv=_&
add=(set dude)
sub=(set dude)
==
::
+$ pith-7
$: wef=(unit weft)
rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) ::
ark=(map desk arak-7) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
rem=(map desk per-desk)
syn=(map kiln-sync 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
:: and the latest version numbers for beaks to
fus=(map desk per-fuse)
@ -74,16 +87,25 @@
:: ensure they're unique even when the same
:: request is made multiple times.
hxs=(map desk @ud)
== ::
==
::
+$ arak-9
$: rail=(unit rail-9)
=rein
rein=rein-9
==
::
++ rail-9
$: publisher=(unit ship)
paused=?
=ship
=desk
=aeon
next=(list rung)
==
::
+$ arak-7
$: rail=(unit rail-7)
=rein
rein=rein-9
==
::
+$ rail-7
@ -110,7 +132,7 @@
hxs=(map desk @ud)
== ::
::
+$ arak-6 [rail=rail-6 next=(list rung) =rein]
+$ arak-6 [rail=rail-6 next=(list rung) rein=rein-9]
+$ rail-6 [paused=? =ship =desk =aeon]
::
+$ pith-5
@ -147,7 +169,7 @@
=desk
=aeon
next=(list rung)
=rein
rein=rein-9
==
+$ pith-3 ::
$: rem=(map desk per-desk) ::
@ -287,6 +309,15 @@
:^ %palm [" " ~ ~ ~] leaf+(weld "kiln: " mez)
~[leaf+"from {<sud>}" leaf+"on {<who>}" leaf+"to {<syd>}"]
::
++ sources
=/ syns=(list [[syd=desk her=ship sud=desk] let=@ud]) ~(tap by syn)
=| sources=(map desk [ship desk])
|- ^+ sources
?~ syns
sources
=. sources (~(put by sources) desk.i.syns [her sud])
$(syns t.syns)
::
++ on-init
=< abet
~> %slog.(fmt "boot")
@ -296,26 +327,24 @@
=. desks (~(del in desks) %kids)
::
=/ sop=ship (sein:title our now our)
:: XX sync desks
:: set up base desk
::
=. ..on-init abet:(install-local:vats %base)
=? ..on-init ?=(?(%earl %duke %king) (clan:title our))
abet:(install:vats %base sop %kids)
abet:start-sync:(set-next:(auto %base sop %kids) `%kids)
:: install other desks and make them public
::
=/ dez=(list desk) ~(tap in desks)
|- ^+ ..on-init
?~ dez ..on-init
=. ..on-init
abet:(install-local:vats i.dez)
(emit %pass /kiln-init-zest %arvo %c %zest i.dez %next)
=. ..on-init
%- emit
:^ %pass /kiln/permission %arvo
[%c %perm i.dez / %r `[%black ~]]
=/ src (get-publisher our i.dez now)
=? ..on-init &(?=(^ src) !=(our u.src))
abet:(install:vats i.dez u.src i.dez)
abet:start-sync:(auto i.dez u.src i.dez)
$(dez t.dez)
::
++ on-load
@ -423,6 +452,9 @@
[%x %kiln %base-hash ~]
=/ ver (mergebase-hashes our %base now (~(got by ark) %base))
``noun+!>(?~(ver 0v0 i.ver))
::
[%x %kiln %syncs ~] ``noun+!>(syn)
[%x %kiln %sources ~] ``noun+!>(sources)
==
::
:: +get-germ: select merge strategy into local desk
@ -457,7 +489,6 @@
%kiln-nuke =;(f (f !<(_+<.f vase)) poke-nuke)
%kiln-pause =;(f (f !<(_+<.f vase)) poke-pause)
%kiln-permission =;(f (f !<(_+<.f vase)) poke-permission)
%kiln-resume =;(f (f !<(_+<.f vase)) poke-resume)
%kiln-revive =;(f (f !<(_+<.f vase)) poke-revive)
%kiln-rein =;(f (f !<(_+<.f vase)) poke-rein)
%kiln-rm =;(f (f !<(_+<.f vase)) poke-rm)
@ -577,7 +608,9 @@
::
++ poke-install
|= [loc=desk her=ship rem=desk]
abet:abet:(install:vats +<)
:: XX should check if already installed before changing zest?
=. ..on-init (emit %pass /kiln-install %arvo %c %zest loc %next)
(poke-sync loc her rem)
::
++ poke-label
|= [syd=desk lab=@tas aey=(unit aeon)]
@ -603,12 +636,15 @@
?. desk
(emit %pass /nuke %arvo %g [%nuke term])
%- emil
%+ turn (get-apps-have our term now)
:: XX
%+ turn *(list [dude ?]) :: (get-apps-have our term now)
|=([=dude ?] [%pass /nuke %arvo %g [%nuke dude]])
::
++ poke-pause
|= =desk
abet:abet:(pause:vats desk)
?~ got=(~(get by sources) desk)
abet:(spam leaf+"desk not installed: {<desk>}" ~)
(poke-unsync desk u.got)
::
++ poke-permission
|= [syd=desk pax=path pub=?]
@ -619,15 +655,11 @@
::
++ poke-rein
|= [=desk =rein]
abet:abet:(set-rein:vats +<)
::
++ poke-resume
|= =desk
abet:abet:(resume:vats desk)
abet:(emit %pass /kiln-rein %arvo %c %rein desk rein)
::
++ poke-revive
|= =desk
abet:abet:(revive:vats desk)
abet:(emit %pass /kiln-revive %arvo %c %zest desk %live)
::
++ poke-rm
|= a=path
@ -646,13 +678,14 @@
::
++ poke-suspend
|= =desk
abet:abet:(suspend:vats desk)
abet:(emit %pass /kiln-suspend %arvo %c %zest desk %dead)
::
++ poke-sync
|= hos=kiln-sync
?: (~(has by syn) hos)
|= [hos=kiln-sync nex=(unit desk)]
?^ got=(~(get by syn) hos)
=. syn (~(put by syn) hos u.got(nex nex))
abet:(spam (render "already syncing" [sud her syd]:hos) ~)
abet:abet:start-sync:(auto hos)
abet:abet:start-sync:(set-next:(auto hos) nex)
::
++ poke-syncs :: print sync config
|= ~
@ -670,7 +703,10 @@
::
++ poke-uninstall
|= loc=desk
abet:(uninstall:vats +<)
?~ got=(~(get by sources) loc)
abet:(spam leaf+"desk not installed: {<loc>}" ~)
=. ..on-init (emit %pass /kiln-uninstall %arvo %c %zest loc %dead)
(poke-unsync loc u.got)
::
++ poke-unmount
|= mon=kiln-unmount
@ -696,7 +732,7 @@
?> (team:title our src)
?+ path ~|(kiln-path/path !!)
[%vats ~]
abet(moz :_(moz [%give %fact ~ %kiln-vats-snap-0 !>(ark)]))
(mean leaf+"kiln: old subscription to /kiln/vats failed" ~)
==
::
++ take-agent
@ -727,7 +763,7 @@
?>(?=(%writ +<.sign-arvo) +>.sign-arvo)
[%autocommit *] %+ take-wake-autocommit t.wire
?>(?=(%wake +<.sign-arvo) +>.sign-arvo)
[%vats *] abet:(take:vats t.wire sign-arvo)
[%vats *] ..abet
[%fuse-request @tas *]
=/ f (fuzz i.t.wire now)
?~ f
@ -945,7 +981,7 @@
::
++ auto
|= kiln-sync
=+ (~(gut by syn) [syd her sud] let=*@ud)
=+ (~(gut by syn) [syd her sud] let=*@ud nex=~)
|%
++ abet
..auto(syn (~(put by syn) [syd her sud] let))
@ -964,6 +1000,10 @@
=> (spam (render "ended autosync" sud her syd) ~)
=/ =wire /kiln/sync/[syd]/(scot %p her)/[sud]
(warp wire her sud ~)
::
++ set-next
|= nex=(unit desk)
..abet(nex nex)
:: duplicate of start-sync? see |track
::
++ start-track
@ -1028,6 +1068,7 @@
leaf+"note: blank desk {<sud>} on {<her>}"
==
==
:: XX fire merge to nex
=/ =wire /kiln/sync/[syd]/(scot %p her)/[sud]
(warp wire her sud `[%sing %y ud+let /])
--

View File

@ -777,7 +777,7 @@
[%park des=desk yok=yoki ran=rang] :: synchronous commit
[%perm des=desk pax=path rit=rite] :: change permissions
[%pork ~] :: resume commit
[%rein des=desk liv=zest ren=(map dude:gall ?)] :: live
[%rein des=desk ren=rein] :: extra apps
[%stir arg=*] :: debug
[%tire p=(unit ~)] :: app state subscribe
[%tomb =clue] :: tombstone specific
@ -785,6 +785,7 @@
$>(%vega vane-task) :: report upgrade
[%warp wer=ship rif=riff] :: internal file req
[%werp who=ship wer=ship rif=riff-any] :: external file req
[%zest des=desk liv=zest] :: live
$>(%plea vane-task) :: ames request
== ::
:: ::
@ -894,6 +895,7 @@
who=(pair (set ship) (map @ta crew)) ::
== ::
+$ regs (map path rule) :: rules for paths
+$ rein (map dude:gall ?) :: extra apps
+$ riff [p=desk q=(unit rave)] :: request+desist
+$ riff-any ::
$% [%1 =riff] ::

View File

@ -324,17 +324,6 @@
== ::
::
+$ bill (list dude:gall)
:: diff from desk.bill
::
:: -- `.liv`: suspended? if suspended, no agents should run
:: -- `.add`: agents not in manifest that should be running
:: -- `.sub`: agents in manifest that should not be running
::
+$ rein
$: liv=zest
add=(set dude:gall)
sub=(set dude:gall)
==
::
:: Active downloads
::
@ -3060,11 +3049,15 @@
|= r=rule
r(who (~(del in who.r) |+nom))
::
++ rein
|= [liv=zest ren=(map dude:gall ?)]
++ set-rein
|= [ren=(map dude:gall ?)]
^+ ..park
..park(ren.dom ren)
::
++ set-zest
|= liv=zest
=? liv =(%base syd) %live
..park(liv.dom liv, ren.dom ren)
..park(liv.dom liv)
::
++ rise
|= [=dude:gall on=(unit ?)]
@ -4711,7 +4704,7 @@
%rein
=^ m1 ruf
=/ den ((de now rof hen ruf) our des.req)
abet:(rein:den liv.req ren.req)
abet:(set-rein:den ren.req)
=^ m2 ruf abet:goad:(lu now rof hen ruf)
[(weld m1 m2) ..^$]
::
@ -4801,6 +4794,13 @@
cancel-request:den
(start-request:den for u.q.rif)
[mos ..^$]
::
%zest
=^ m1 ruf
=/ den ((de now rof hen ruf) our des.req)
abet:(set-zest:den liv.req)
=^ m2 ruf abet:goad:(lu now rof hen ruf)
[(weld m1 m2) ..^$]
::
%plea
=* her ship.req
@ -5414,6 +5414,7 @@
%rang ``[%rang !>(ran.ruf)]
%tomb ``[%flag !>((tomb t.path))]
%domes domes
%tire ``[%tire !>(tore:(lu now rof *duct ruf))]
==
::
++ domes

View File

@ -1,83 +1,59 @@
=, clay
=* dude dude:gall
|%
:: $snap: kiln snapshot
::
+$ snap (map desk arak)
:: $diff: subscription update
::
+$ diff
$% [%block =desk =arak =weft blockers=(set desk)]
[%reset =desk =arak]
[%commit =desk =arak]
[%merge-sunk =desk =arak =tang]
[%merge-fail =desk =arak =tang]
[%suspend =desk =arak]
[%revive =desk =arak]
==
:: $rung: reference to upstream commit
::
+$ rung [=aeon =weft]
:: $rein: diff from desk manifest
::
:: .liv: suspended? if suspended, no agents should run
:: .add: agents not in manifest that should be running
:: .sub: agents in manifest that should not be running
::
+$ rein
$: liv=_&
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
==
:- (report-kids our now)
(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
?: =(ud.cass 0)
leaf+"desk does not yet exist: {<desk>}"
=/ kel-path
/(scot %p our)/[desk]/(scot %da now)/sys/kelvin
?. .^(? %cu kel-path)
leaf+"bad desk: {<desk>}"
=+ .^(=weft %cx kel-path)
:+ %rose ["" "{<desk>}" "::"]
^- tang
=/ meb (mergebase-hashes our desk now arak)
=/ poz
?~ rail.arak "local"
?:(paused.u.rail.arak "paused" "tracking")
=/ sat ?:(liv.rein.arak "running" "suspended")
=/ pen
?~ rail.arak "~"
<(turn next.u.rail.arak |=([@ lal=@tas num=@] [lal num]))>
:~ leaf/"/sys/kelvin: {<[lal num]:weft>}"
leaf/"base hash: {?.(=(1 (lent meb)) <meb> <(head meb)>)}"
leaf/"%cz hash: {<hash>}"
::
leaf/"app status: {sat}"
leaf/"force on: {?:(=(~ add.rein.arak) "~" <add.rein.arak>)}"
leaf/"force off: {?:(=(~ sub.rein.arak) "~" <sub.rein.arak>)}"
::
leaf/"publishing ship: {?~(rail.arak <~> <publisher.u.rail.arak>)}"
leaf/"updates: {poz}"
leaf/"source ship: {?~(rail.arak <~> <ship.u.rail.arak>)}"
leaf/"source desk: {?~(rail.arak <~> <desk.u.rail.arak>)}"
leaf/"source aeon: {?~(rail.arak <~> <aeon.u.rail.arak>)}"
leaf/"pending updates: {pen}"
==
:: XX
:: +$ 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
:: ==
:: :- (report-kids our now)
:: (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
:: ?: =(ud.cass 0)
:: leaf+"desk does not yet exist: {<desk>}"
:: =/ kel-path
:: /(scot %p our)/[desk]/(scot %da now)/sys/kelvin
:: ?. .^(? %cu kel-path)
:: leaf+"bad desk: {<desk>}"
:: =+ .^(=weft %cx kel-path)
:: :+ %rose ["" "{<desk>}" "::"]
:: ^- tang
:: =/ meb (mergebase-hashes our desk now arak)
:: =/ poz
:: ?~ rail.arak "local"
:: ?:(paused.u.rail.arak "paused" "tracking")
:: =/ sat ?:(liv.rein.arak "running" "suspended")
:: =/ pen
:: ?~ rail.arak "~"
:: <(turn next.u.rail.arak |=([@ lal=@tas num=@] [lal num]))>
:: :~ leaf/"/sys/kelvin: {<[lal num]:weft>}"
:: leaf/"base hash: {?.(=(1 (lent meb)) <meb> <(head meb)>)}"
:: leaf/"%cz hash: {<hash>}"
:: ::
:: leaf/"app status: {sat}"
:: leaf/"force on: {?:(=(~ add.rein.arak) "~" <add.rein.arak>)}"
:: leaf/"force off: {?:(=(~ sub.rein.arak) "~" <sub.rein.arak>)}"
:: ::
:: leaf/"publishing ship: {?~(rail.arak <~> <publisher.u.rail.arak>)}"
:: leaf/"updates: {poz}"
:: leaf/"source ship: {?~(rail.arak <~> <ship.u.rail.arak>)}"
:: leaf/"source desk: {?~(rail.arak <~> <desk.u.rail.arak>)}"
:: leaf/"source aeon: {?~(rail.arak <~> <aeon.u.rail.arak>)}"
:: leaf/"pending updates: {pen}"
:: ==
:: +report-kids: non-vat cz hash report for kids desk
::
++ report-kids
@ -143,21 +119,6 @@
?. .^(? cu/pax)
*(list dude)
.^((list dude) cx/pax)
:: +adjust-dudes: which agents should be started and stopped
::
:: Will ask Gall to start agents that it's already running
:: but that should be ok, and might be safer in case other
:: unprocessed moves would have turned them off.
::
++ adjust-dudes
|= $: local=[our=ship =desk now=@da]
=rein
==
^- [jolt=(list dude) idle=(list dude)]
=/ all=(list dude) (read-bill local)
=/ want (get-apps-want local all rein)
=/ have (get-apps-live local)
[want (skip have ~(has in (sy want)))]
::
++ get-remote-diff
|= [our=ship here=desk now=@da her=ship there=desk when=aeon]
@ -172,49 +133,51 @@
?. .^(? %cu pax) ~
`.^(ship %cx pax)
::
++ 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
|= [local=[our=ship =desk now=@da] duz=(list dude) =rein]
^- (list dude)
?. liv.rein ~
?. |(=(`zuse+zuse (read-kelvin-local local)) =(%base desk.local)) ~
=. duz (skip duz ~(has in sub.rein))
=. duz (weld duz (skip ~(tap in add.rein) ~(has in (sy duz))))
duz
::
++ mergebase-hashes
|= [our=@p =desk now=@da =arak]
?~ rail.arak
~
=/ her (scot %p ship.u.rail.arak)
=/ ego (scot %p our)
=/ wen (scot %da now)
%+ turn .^((list tako) %cs ~[ego desk wen %base her desk.u.rail.arak])
|=(=tako .^(@uv %cs ~[ego desk wen %hash (scot %uv tako)]))
:: XX
:: ++ 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
:: |= [local=[our=ship =desk now=@da] duz=(list dude) =rein]
:: ^- (list dude)
:: ?. liv.rein ~
:: ?. |(=(`zuse+zuse (read-kelvin-local local)) =(%base desk.local)) ~
:: =. duz (skip duz ~(has in sub.rein))
:: =. duz (weld duz (skip ~(tap in add.rein) ~(has in (sy duz))))
:: duz
:: ::
:: ++ mergebase-hashes
:: |= [our=@p =desk now=@da =arak]
:: ?~ rail.arak
:: ~
:: =/ her (scot %p ship.u.rail.arak)
:: =/ ego (scot %p our)
:: =/ wen (scot %da now)
:: %+ turn .^((list tako) %cs ~[ego desk wen %base her desk.u.rail.arak])
:: |=(=tako .^(@uv %cs ~[ego desk wen %hash (scot %uv tako)]))
::
++ enjs
=, enjs:format
|%
++ vats
|= v=(list ^vat)
^- json
%- pairs
%+ turn v
|= va=^vat
[desk.va (vat va)]
:: XX
:: ++ vats
:: |= v=(list ^vat)
:: ^- json
:: %- pairs
:: %+ turn v
:: |= va=^vat
:: [desk.va (vat va)]
::
++ tim
|= t=@
@ -228,14 +191,15 @@
da+(tim da.c)
==
::
++ vat
|= v=^vat
%- pairs
:~ desk+s+desk.v
hash+s+(scot %uv hash.v)
cass+(cass cass.v)
arak+(arak arak.v)
==
:: XX
:: ++ vat
:: |= v=^vat
:: %- pairs
:: :~ desk+s+desk.v
:: hash+s+(scot %uv hash.v)
:: cass+(cass cass.v)
:: arak+(arak arak.v)
:: ==
::
++ weft
|= w=^weft
@ -251,29 +215,13 @@
weft+(weft weft.r)
==
::
++ rein
|= r=^rein
%- pairs
:~ add+a+(turn ~(tap in add.r) (lead %s))
sub+a+(turn ~(tap in sub.r) (lead %s))
==
:: XX
:: ++ rein
:: |= r=^rein
:: %- pairs
:: :~ add+a+(turn ~(tap in add.r) (lead %s))
:: sub+a+(turn ~(tap in sub.r) (lead %s))
:: ==
::
++ arak
|= a=^arak
%- pairs
:~ rail+?~(rail.a ~ (rail u.rail.a))
rein+(rein rein.a)
==
::
++ rail
|= r=^rail
%- pairs
:~ ship+s+(scot %p ship.r)
publisher+?~(publisher.r ~ s+(scot %p u.publisher.r))
desk+s+desk.r
paused+b+paused.r
aeon+(numb aeon.r)
next+a+(turn next.r rung)
==
--
--