urbit/pkg/arvo/lib/hood/kiln.hoon

1392 lines
41 KiB
Plaintext
Raw Normal View History

/- *hood
2022-09-02 06:47:28 +03:00
/+ strandio
=, clay
2016-12-02 02:59:17 +03:00
=, space:userlib
=, format
=* dude dude:gall
|%
2022-08-17 07:33:25 +03:00
+$ state state-10
2022-09-02 06:47:28 +03:00
+$ state-10 [%10 pith-10]
2022-08-17 07:33:25 +03:00
+$ state-9 [%9 pith-9]
+$ state-8 [%8 pith-9]
+$ state-7 [%7 pith-7]
+$ state-6 [%6 pith-6]
+$ state-5 [%5 pith-5]
+$ state-4 [%4 pith-4]
+$ state-3 [%3 pith-3]
+$ state-2 [%2 pith-2]
+$ state-1 [%1 pith-1]
+$ state-0 [%0 pith-0]
+$ any-state
2021-08-11 19:23:36 +03:00
$~ *state
2022-08-26 08:57:20 +03:00
$% state-10
state-9
state-8
state-7
state-6
state-5
2021-09-06 17:27:17 +03:00
state-4
2021-08-20 01:57:31 +03:00
state-3
state-2
state-1
state-0
==
::
2022-08-17 07:33:25 +03:00
+$ pith-10
2022-08-31 05:32:31 +03:00
$: rem=(map desk per-desk)
2022-09-07 09:52:59 +03:00
nyz=@ud
2022-09-02 06:47:28 +03:00
zyn=(map kiln-sync sync-state)
2022-08-31 05:32:31 +03:00
commit-timer=[way=wire nex=@da tim=@dr mon=term]
2022-08-17 07:33:25 +03:00
:: 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-9
$: wef=(unit weft)
2022-08-31 05:32:31 +03:00
rem=(map desk per-desk)
syn=(map kiln-sync 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
:: 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)
==
::
2022-08-26 08:57:20 +03:00
:: $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)
2022-08-26 08:57:20 +03:00
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)
:: 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)
2022-08-26 08:57:20 +03:00
==
2022-08-17 07:33:25 +03:00
::
+$ arak-9
$: rail=(unit rail-9)
2022-08-26 08:57:20 +03:00
rein=rein-9
==
::
++ rail-9
$: publisher=(unit ship)
paused=?
=ship
=desk
=aeon
next=(list rung)
2022-08-17 07:33:25 +03:00
==
::
+$ arak-7
$: rail=(unit rail-7)
2022-08-26 08:57:20 +03:00
rein=rein-9
==
::
+$ rail-7
$: paused=?
=ship
=desk
=aeon
next=(list rung)
==
::
+$ pith-6
$: wef=(unit weft)
rem=(map desk per-desk) ::
syn=(map kiln-sync 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
:: 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)
== ::
::
2022-08-26 08:57:20 +03:00
+$ arak-6 [rail=rail-6 next=(list rung) rein=rein-9]
+$ rail-6 [paused=? =ship =desk =aeon]
::
2021-09-06 17:27:17 +03:00
+$ pith-5
$: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) ::
ark=(map desk arak-6) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
2021-05-24 01:43:41 +03:00
:: 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)
== ::
2021-09-06 17:27:17 +03:00
::
+$ pith-4 ::
$: rem=(map desk per-desk) ::
syn=(map kiln-sync 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
:: 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)
== ::
+$ arak-4
$: =ship
=desk
=aeon
next=(list rung)
2022-08-26 08:57:20 +03:00
rein=rein-9
2021-09-06 17:27:17 +03:00
==
2021-08-20 01:57:31 +03:00
+$ pith-3 ::
$: rem=(map desk per-desk) ::
syn=(map kiln-sync 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
:: 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)
==
+$ arak-3
$: =ship
=desk
=aeon
2021-09-06 17:27:17 +03:00
next=(list rung)
2021-08-20 01:57:31 +03:00
rein=rein-3
==
+$ rein-3
$: add=(set dude)
sub=(set dude)
==
::
+$ pith-2 ::
$: rem=(map desk per-desk) ::
syn=(map kiln-sync let=@ud) ::
ota=(unit [=ship =desk =aeon]) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
2021-08-11 19:23:36 +03:00
fus=(map desk per-fuse)
hxs=(map desk @ud)
== ::
+$ pith-1 ::
$: rem=(map desk per-desk) ::
syn=(map kiln-sync 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) ::
autoload-on=? ::
cur-hoon=@uvI ::
cur-arvo=@uvI ::
cur-zuse=@uvI ::
cur-vanes=(map @tas @uvI) ::
commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
==
+$ per-desk :: per-desk state
$: auto=? :: escalate on failure
gem=?(%this %that germ) :: strategy
her=@p :: from ship
sud=@tas :: from desk
cas=case :: at case
==
2021-05-24 01:43:41 +03:00
+$ per-fuse :: per fuse state
:: map [ship desk] to latest version number we
:: have for them. used for things we're %trak-ing
:: our invariant here is to store the latest version
:: number we've heard of.
$: mox=(map [ship desk] let=@ud)
:: relevant parts of originating request
kf=kiln-fuse-data
==
+$ kiln-commit term ::
+$ kiln-mount ::
$: pax=path ::
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 ::
ali=ship ::
sud=desk ::
cas=case ::
gim=?(%auto germ) ::
==
2021-05-24 01:43:41 +03:00
+$ fuse-source [who=ship des=desk ver=$@(%trak case)]
:: actual poke
2021-04-20 06:46:46 +03:00
+$ kiln-fuse
2021-05-02 06:04:19 +03:00
$@ ~
2021-04-20 06:46:46 +03:00
$: syd=desk
2021-05-24 01:43:41 +03:00
$@ ~ :: signifies clearing the fuse
$: overwrite=flag :: force overwrite previous fuse
bas=fuse-source
con=(list [fuse-source germ])
==
2021-04-20 06:46:46 +03:00
==
2021-05-24 01:43:41 +03:00
:: state tracked by kiln
+$ kiln-fuse-data
$: syd=desk
bas=fuse-source
con=(list [fuse-source germ])
==
:: Request to list current fuses. ~ means "list all"
::
+$ kiln-fuse-list (unit desk)
--
2021-08-18 01:16:48 +03:00
|= [bowl:gall state]
2015-09-02 01:20:17 +03:00
?> =(src our)
=| moz=(list card:agent:gall)
|%
++ kiln .
2015-12-09 04:54:26 +03:00
++ abet :: resolve
[(flop moz) `state`+<+.$]
2015-09-02 01:20:17 +03:00
::
2019-11-14 21:39:50 +03:00
++ emit
2019-11-19 07:36:21 +03:00
|= card:agent:gall
2019-11-14 21:39:50 +03:00
%_(+> moz [+< moz])
::
++ emil :: return cards
2019-11-19 07:36:21 +03:00
|= (list card:agent:gall)
2015-09-02 01:20:17 +03:00
^+ +>
?~(+< +> $(+< t.+<, +> (emit i.+<)))
2021-09-26 08:07:23 +03:00
:: +fmt: format string for slogging
::
++ fmt
|= mes=tape
[%0 %leaf (weld "kiln: " mes)]
2015-09-02 01:20:17 +03:00
::
++ render
2022-09-07 09:52:59 +03:00
|= [mez=tape sud=desk who=ship syd=desk kid=(unit desk)]
:^ %palm [" " ~ ~ ~] leaf+(weld "kiln: " mez)
2022-09-07 09:52:59 +03:00
:^ leaf+"from {<sud>}" leaf+"on {<who>}" leaf+"to {<syd>}"
?~ kid ~
2022-09-08 08:56:12 +03:00
[leaf+"then {<u.kid>}" ~]
2015-09-02 01:20:17 +03:00
::
2022-08-26 08:57:20 +03:00
++ sources
2022-09-02 06:47:28 +03:00
=/ zyns=(list [[syd=desk her=ship sud=desk] *]) ~(tap by zyn)
2022-08-26 08:57:20 +03:00
=| sources=(map desk [ship desk])
|- ^+ sources
2022-09-02 06:47:28 +03:00
?~ zyns
2022-08-26 08:57:20 +03:00
sources
2022-09-02 06:47:28 +03:00
=. sources (~(put by sources) -.i.zyns)
$(zyns t.zyns)
2015-09-02 01:20:17 +03:00
::
++ on-init
=< abet
2021-09-26 08:07:23 +03:00
~> %slog.(fmt "boot")
::
=+ .^(desks=(set desk) %cd /(scot %p our)//(scot %da now))
=. desks (~(del in desks) %base)
=. desks (~(del in desks) %kids)
::
=/ sop=ship (sein:title our now our)
:: set up base desk
::
=? ..on-init ?=(?(%earl %duke %king) (clan:title our))
2022-09-02 06:47:28 +03:00
abet:init:(apex:(sync %base sop %kids) `%kids)
:: install other desks and make them public
::
=/ dez=(list desk) ~(tap in desks)
|- ^+ ..on-init
?~ dez ..on-init
=. ..on-init
2022-09-08 09:38:35 +03:00
(emit %pass /kiln/init-zest %arvo %c %zest i.dez %live)
=. ..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))
2022-09-02 06:47:28 +03:00
abet:init:(sync i.dez u.src i.dez)
$(dez t.dez)
::
2020-06-10 02:21:30 +03:00
++ on-load
2021-08-11 19:23:36 +03:00
=> |%
+$ ota [syd=desk her=ship sud=desk]
--
=| old-ota=(unit ota)
2020-07-18 02:58:28 +03:00
|= [hood-version=@ud old=any-state]
2021-09-22 23:34:20 +03:00
=/ old-version -.old
=* state +<+.$.abet
::
2021-08-11 19:23:36 +03:00
=? old-ota ?=(%0 -.old)
=/ syncs=(list [ota =aeon]) ~(tap by syn.old)
|- ^- (unit ota)
?~ syncs
~
?: &(=([%base %kids] [syd sud]:i.syncs) !=(our her.i.syncs))
`[syd her sud]:i.syncs
$(syncs t.syncs)
::
=? old ?=(%0 -.old)
=? syn.old ?=(^ old-ota) (~(del by syn.old) u.old-ota)
[%3 [rem syn ark=~ commit-timer fus=~ hxs=~]:old]
2020-06-10 02:21:30 +03:00
::
=? old ?=(%1 -.old)
:* %2
rem.old
syn.old
ota.old
commit-timer.old
2021-08-11 19:23:36 +03:00
fus=~
hxs=~
==
2021-08-11 19:23:36 +03:00
::
=? old-ota ?=(%2 -.old)
?~ ota.old ~
`[%base ship desk]:u.ota.old
2020-06-10 02:21:30 +03:00
::
=? old ?=(%2 -.old)
:* %3
rem.old
syn.old
ark=~
commit-timer.old
2021-08-11 19:23:36 +03:00
fus.old
hxs.old
==
::
2021-09-06 17:27:17 +03:00
=? old ?=(%3 -.old)
:- %4
+.old(ark (~(run by ark.old) |=(a=arak-3 a(rein [liv=& rein.a]))))
::
=? old ?=(%4 -.old)
:- %5
=- +.old(ark -)
%- ~(run by ark.old)
|= a=arak-4
^- arak-6
2021-09-06 17:27:17 +03:00
[[paused=| ship desk aeon] next rein]:a
::
=? old ?=(%5 -.old)
[%6 ~ +.old]
2021-09-06 17:27:17 +03:00
::
=? old ?=(%6 -.old)
:- %7
=- +.old(ark -)
%- ~(run by ark.old)
|= a=arak-6
^- arak-7
:_ rein.a
^- (unit rail-7)
`[paused.rail ship.rail desk.rail aeon.rail next]:a
::
=? old ?=(%7 -.old)
:- %8
=- +.old(ark -)
2022-09-02 06:47:28 +03:00
%- ~(gas by *(map desk arak-9))
%+ turn ~(tap by ark.old)
|= [d=desk a=arak-7]
2022-09-02 06:47:28 +03:00
^- [desk arak-9]
:- d
:_ rein.a
?~ rail.a ~
`[(get-publisher our d now) u.rail.a]
::
=? old ?=(%8 -.old)
[%9 +.old]
::
2022-09-08 08:56:12 +03:00
=^ cards-9=(list card:agent:gall) old
?. ?=(%9 -.old)
`old
=/ syn=(set kiln-sync)
%- ~(gas in ~(key by syn.old))
%+ murn ~(tap by ark.old)
|= [=desk =arak-9]
?~ rail.arak-9
~
?: paused.u.rail.arak-9
~
`u=[desk ship.u.rail.arak-9 desk.u.rail.arak-9]
=/ zet=(list [desk zest])
%+ murn ~(tap by ark.old)
|= [=desk =arak-9]
^- (unit [^desk zest])
?: liv.rein.arak-9
2022-10-14 05:27:50 +03:00
`[desk %held]
2022-09-08 08:56:12 +03:00
?~ rail.arak-9
~
?: paused.u.rail.arak-9
~
2022-10-14 05:27:50 +03:00
`[desk %held]
2022-09-08 08:56:12 +03:00
::
:_ [%10 |1.+.old(syn 0, ark ~)]
;: weld
%+ turn zet
|= [=desk =zest]
[%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)]
::
=/ ks ~(tap in syn)
|- ^- (list card:agent:gall)
?~ ks
~
?: =(%base syd.i.ks)
:_ ~
:* %pass /kiln/load-kids %agent [our %hood]
%poke %kiln-kids !>([i.ks `%kids])
==
$(ks t.ks)
==
::
2022-08-17 07:33:25 +03:00
?> ?=(%10 -.old)
=. state old
2022-09-08 08:56:12 +03:00
abet:(emil cards-9)
2020-06-10 02:21:30 +03:00
::
++ on-peek
|= =path
^- (unit (unit cage))
2020-12-04 11:37:28 +03:00
?+ path [~ ~]
2022-08-17 07:33:25 +03:00
[%x %kiln %our ~] ``noun+!>(our)
[%x %kiln %lag ~]
``loob+!>(.^(? //(scot %p our)//(scot %da now)/zen/lag))
2021-08-24 07:09:12 +03:00
::
2020-12-04 11:37:28 +03:00
[%x %kiln %base-hash ~]
2022-09-02 06:47:28 +03:00
=/ ver (mergebase-hashes our %base now (~(got by sources) %base))
2020-12-04 11:37:28 +03:00
``noun+!>(?~(ver 0v0 i.ver))
2022-08-26 08:57:20 +03:00
::
2022-09-07 09:52:59 +03:00
[%x %kiln %syncs ~] ``noun+!>(zyn)
2022-08-26 08:57:20 +03:00
[%x %kiln %sources ~] ``noun+!>(sources)
2022-10-07 01:46:45 +03:00
[%x %kiln %pikes ~]
=+ .^(=rock:tire %cx /(scot %p our)//(scot %da now)/tire)
2022-11-03 20:04:36 +03:00
:^ ~ ~ %kiln-pikes
!> ^- pikes
2022-10-07 01:46:45 +03:00
%- ~(rut by rock)
|= [=desk =zest wic=(set weft)]
^- pike
=+ .^(hash=@uv %cz /(scot %p our)/[desk]/(scot %da now))
=/ sync (~(get by sources) desk)
[sync hash zest wic]
2020-12-02 09:27:52 +03:00
==
::
:: +get-germ: select merge strategy into local desk
::
2022-08-17 07:33:25 +03:00
:: If destination desk doesn't exist, need a %init merge. Otherwise,
:: we just want what the remote has, so we use %only-that.
::
++ get-germ
|= =desk
=+ .^(=cass:clay %cw /(scot %p our)/[desk]/(scot %da now))
?- ud.cass
%0 %init
2022-05-11 06:38:57 +03:00
* %only-that
==
2021-07-10 15:56:08 +03:00
::
++ poke
|= [=mark =vase]
?+ mark ~|([%poke-kiln-bad-mark mark] !!)
%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-fuse =;(f (f !<(_+<.f vase)) poke-fuse)
2021-08-11 19:23:36 +03:00
%kiln-fuse-list =;(f (f !<(_+<.f vase)) poke-fuse-list)
%kiln-gall-sear =;(f (f !<(_+<.f vase)) poke-gall-sear)
%kiln-info =;(f (f !<(_+<.f vase)) poke-info)
%kiln-install =;(f (f !<(_+<.f vase)) poke-install)
2022-09-08 08:56:12 +03:00
%kiln-kids =;(f (f !<(_+<.f vase)) poke-kids)
%kiln-label =;(f (f !<(_+<.f vase)) poke-label)
%kiln-merge =;(f (f !<(_+<.f vase)) poke-merge)
%kiln-mount =;(f (f !<(_+<.f vase)) poke-mount)
2021-07-21 12:00:11 +03:00
%kiln-nuke =;(f (f !<(_+<.f vase)) poke-nuke)
2021-09-06 17:27:17 +03:00
%kiln-pause =;(f (f !<(_+<.f vase)) poke-pause)
%kiln-permission =;(f (f !<(_+<.f vase)) poke-permission)
2021-08-20 01:57:31 +03:00
%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-schedule =;(f (f !<(_+<.f vase)) poke-schedule)
2021-09-06 17:27:17 +03:00
%kiln-suspend =;(f (f !<(_+<.f vase)) poke-suspend)
%kiln-sync =;(f (f !<(_+<.f vase)) poke-sync)
%kiln-syncs =;(f (f !<(_+<.f vase)) poke-syncs)
%kiln-uninstall =;(f (f !<(_+<.f vase)) poke-uninstall)
%kiln-unmount =;(f (f !<(_+<.f vase)) poke-unmount)
%kiln-unsync =;(f (f !<(_+<.f vase)) poke-unsync)
==
2016-02-26 02:19:44 +03:00
::
++ poke-autocommit
|= [mon=kiln-commit auto=?]
=< abet
=. +>.$ (emit %pass /commit %arvo %c [%dirk mon])
?. auto
+>.$
=/ recur ~s1
=. commit-timer
[/kiln/autocommit (add now recur) recur mon]
(emit %pass way.commit-timer %arvo %b [%wait nex.commit-timer])
::
++ poke-bump
|= ~
=< abet
=+ .^(=rock:tire %cx /(scot %p our)//(scot %da now)/tire)
=/ wic
%+ sort ~(tap by wic:(~(got by rock) %base))
|= [[* a=@ud] [* b=@ud]]
(gth a b)
=. wic (skip wic |=([* a=@ud] (gte a zuse)))
?~ wic
%- (slog 'kiln: %base already up-to-date' ~)
..abet
=/ kel i.wic
%- emil
=/ cards
%+ murn ~(tap by rock)
|= [=desk =zest wic=(set weft)]
?: |(=(%base desk) !?=(%live zest) (~(has in wic) kel))
~
2022-10-14 05:27:50 +03:00
`u=[%pass /kiln/bump/[desk] %arvo %c %zest desk %held]
?~ cards
[%pass /kiln/bump/wick %arvo %c %wick ~]~
cards
::
++ poke-cancel
|= a=@tas
abet:(emit %pass /cancel %arvo %c [%drop a])
::
++ poke-cancel-autocommit
2018-03-19 07:18:20 +03:00
|= ~
abet:(emit %pass way.commit-timer %arvo %b [%rest nex.commit-timer])
2015-09-02 01:20:17 +03:00
::
++ poke-commit
|= [mon=kiln-commit auto=?]
=< abet
=. +>.$ (emit %pass /commit %arvo %c [%dirk mon])
?. auto
+>.$
=/ recur ~s1
=. commit-timer
[/kiln/autocommit (add now recur) recur mon]
(emit %pass way.commit-timer %arvo %b [%wait nex.commit-timer])
2015-09-02 01:20:17 +03:00
::
++ poke-fuse-list
=>
|%
++ format-fuse
2021-06-08 03:23:00 +03:00
|= [into=desk pf=per-fuse]
^- tank
=/ sources=tape
%+ reel
con.kf.pf
|= [[fs=fuse-source g=germ] acc=tape]
^- tape
2021-08-11 19:23:36 +03:00
:(weld " [" (format-fuse-source fs) " " <g> "]" acc)
2021-06-08 03:23:00 +03:00
:- %leaf
;: weld
"|fuse {<into>} "
(format-fuse-source bas.kf.pf)
sources
==
:: +format-fuse-source: fuse source -> beak -> path
::
++ format-fuse-source
|= fs=fuse-source
^- tape
=/ bec=beak [who.fs des.fs ?:(?=([%trak] ver.fs) [%tas %track] ver.fs)]
<(en-beam [bec /])>
--
|= k=kiln-fuse-list
^+ abet
%. abet
?~ k
?~ fus
(slog [leaf+"no ongoing fuses" ~])
%- slog
%+ roll
~(tap by `(map desk per-fuse)`fus)
|= [[syd=desk pf=per-fuse] acc=tang]
^- tang
2021-06-08 03:23:00 +03:00
[(format-fuse syd pf) acc]
=/ pfu=(unit per-fuse) (~(get by fus) u.k)
?~ pfu
(slog [leaf+"no ongoing fuse for {<u.k>}" ~])
2021-06-08 03:23:00 +03:00
(slog [(format-fuse u.k u.pfu) ~])
::
2021-04-20 06:46:46 +03:00
++ poke-fuse
|= k=kiln-fuse
2021-05-02 06:04:19 +03:00
?~ k abet
2021-05-24 01:43:41 +03:00
=/ payload +.k
?~ payload
:: cancelling an ongoing fuse
%- (slog [leaf+"cancelling fuse into {<syd.k>}" ~])
=/ f (fuzz syd.k now)
?~ f
abet
abet:abet:delete:u.f
2021-05-24 01:43:41 +03:00
?: &(!overwrite.payload (~(has by fus) syd.k))
((slog [leaf+"existing fuse into {<syd.k>} - need =overwrite &" ~]) abet)
=. fus (~(put by fus) syd.k [~ [syd.k bas.payload con.payload]])
=/ old-cnt=@ud (~(gut by hxs) syd.k 0)
=. hxs (~(put by hxs) syd.k +(old-cnt))
=/ f (fuzz syd.k now)
?~ f
abet
abet:abet:fuse:u.f
2021-04-20 06:46:46 +03:00
::
++ poke-gall-sear
|= =ship
abet:(emit %pass /kiln %arvo %g %sear ship)
::
2016-05-07 02:21:29 +03:00
++ poke-info
|= [mez=tape tor=(unit toro)]
?~ tor
abet:(spam leaf+mez ~)
2019-11-14 21:39:50 +03:00
abet:(emit:(spam leaf+mez ~) %pass /kiln %arvo %c [%info u.tor])
2015-09-02 01:20:17 +03:00
::
++ poke-install
|= [loc=desk her=ship rem=desk]
2022-09-07 09:52:59 +03:00
=+ .^(=rock:tire %cx /(scot %p our)//(scot %da now)/tire)
=/ =zest
?~ got=(~(get by rock) loc)
%dead
zest.u.got
2022-09-08 09:38:35 +03:00
=. zyn
?~ got=(~(get by sources) loc)
zyn
(~(del by zyn) loc u.got)
=? ..abet ?=(%dead zest)
(emit %pass /kiln/install %arvo %c %zest loc ?:(=(our her) %live %held))
2022-09-08 09:45:11 +03:00
?: (~(has by zyn) loc her rem)
abet:(spam (render "already syncing" loc her rem ~) ~)
?: =([our loc] [her rem])
abet
2022-10-18 07:38:45 +03:00
=/ sun (sync loc her rem)
~> %slog.(fmt "beginning install into {here:sun}")
=< abet:abet:init
2022-09-08 09:45:11 +03:00
?: =(%base loc)
2022-10-18 07:38:45 +03:00
(apex:sun `%kids)
sun
::
2022-09-08 08:56:12 +03:00
++ poke-kids
|= [hos=kiln-sync nex=(unit desk)]
abet:abet:(apex:(sync hos) nex)
::
++ poke-label
|= [syd=desk lab=@tas aey=(unit aeon)]
=+ pax=/(scot %p our)/[syd]/[lab]
(poke-info "labeled {(spud pax)}" `[syd %| lab aey])
::
++ poke-merge
|= kiln-merge
?~ +< abet
abet:abet:(merge:(work syd) ali sud cas gim)
::
++ poke-mount
|= kiln-mount
=+ bem=(de-beam pax)
?~ bem
=+ "can't mount bad path: {<pax>}"
abet:(spam leaf+- ~)
abet:(emit %pass /mount %arvo %c [%mont pot u.bem])
::
2021-07-21 12:00:11 +03:00
++ poke-nuke
|= [=term desk=?]
=< abet
?. desk
(emit %pass /nuke %arvo %g [%nuke term])
%- emil
2021-07-23 14:07:58 +03:00
%+ turn (get-apps-have our term now)
2021-07-21 12:00:11 +03:00
|=([=dude ?] [%pass /nuke %arvo %g [%nuke dude]])
::
2021-09-06 17:27:17 +03:00
++ poke-pause
|= =desk
2022-08-26 08:57:20 +03:00
?~ got=(~(get by sources) desk)
abet:(spam leaf+"desk not installed: {<desk>}" ~)
(poke-unsync desk u.got)
2021-09-06 17:27:17 +03:00
::
++ poke-permission
|= [syd=desk pax=path pub=?]
=< abet
%- emit
=/ =rite [%r ~ ?:(pub %black %white) ~]
[%pass /kiln/permission %arvo %c [%perm syd pax rite]]
::
++ poke-rein
|= [=desk =rein]
2022-09-08 08:56:12 +03:00
abet:(emit %pass /kiln/rein %arvo %c %rein desk rein)
2021-09-06 17:27:17 +03:00
::
2021-08-20 01:57:31 +03:00
++ poke-revive
|= =desk
2022-09-08 08:56:12 +03:00
abet:(emit %pass /kiln/revive %arvo %c %zest desk %live)
2021-08-20 01:57:31 +03:00
::
++ poke-rm
|= a=path
=| c=(list (unit toro))
2022-11-06 09:18:40 +03:00
%+ poke-info "removed: {<a>}"
=- %+ roll -
2022-11-09 07:56:54 +03:00
|= [a=(unit toro) b=(unit toro)]
(clap a b furl)
|- ^- (list (unit toro))
=+ b=.^(arch %cy a)
2022-11-10 10:03:18 +03:00
?: ?=([^ ~] b) (snoc c `(fray a))
=? c ?=(^ fil.b) (snoc c `(fray a))
%- zing
%+ turn ~(tap by dir.b)
|= [kid=@ta ~]
^$(a (weld a /[kid]))
::
2015-09-02 01:20:17 +03:00
++ poke-schedule
|= [where=path tym=@da eve=@t]
2015-09-02 01:20:17 +03:00
=. where (welp where /sched)
2016-05-07 02:21:29 +03:00
%+ poke-info "scheduled"
2015-12-09 04:54:26 +03:00
=+ old=;;((map @da cord) (fall (file where) ~))
`(foal where %sched !>((~(put by old) tym eve)))
2015-09-02 01:20:17 +03:00
::
2021-08-20 01:57:31 +03:00
++ poke-suspend
|= =desk
2022-09-08 08:56:12 +03:00
abet:(emit %pass /kiln/suspend %arvo %c %zest desk %dead)
2021-08-20 01:57:31 +03:00
::
++ poke-sync
|= hos=kiln-sync
2022-09-02 06:47:28 +03:00
?: (~(has by zyn) hos)
2022-09-07 09:52:59 +03:00
abet:(spam (render "already syncing" [sud her syd ~]:hos) ~)
2022-10-18 07:38:45 +03:00
~> %slog.(fmt "beginning sync into {<syd.hos>} from {<her.hos>}/{<sud.hos>}")
2022-09-02 06:47:28 +03:00
abet:abet:init:(sync hos)
::
++ poke-syncs :: print sync config
|= ~
=< abet %- spam
2022-09-07 09:52:59 +03:00
?: =(0 ~(wyt by zyn))
[%leaf "no syncs configured"]~
2022-09-07 09:52:59 +03:00
%+ turn ~(tap by zyn)
|= [kiln-sync sync-state]
(render "sync configured" sud her syd kid)
2019-11-05 10:37:58 +03:00
::
++ poke-uninstall
|= loc=desk
2023-03-10 20:22:09 +03:00
=+ .^(=rock:tire %cx /(scot %p our)//(scot %da now)/tire)
?~ got=(~(get by rock) loc)
abet:(spam leaf+"desk does not exist: {<loc>}" ~)
?: =(+<:got %dead)
2022-08-26 08:57:20 +03:00
abet:(spam leaf+"desk not installed: {<loc>}" ~)
2023-03-10 20:22:09 +03:00
~> %slog.(fmt "uninstalling {<loc>}")
2022-09-08 08:56:12 +03:00
=. ..on-init (emit %pass /kiln/uninstall %arvo %c %zest loc %dead)
2023-03-10 20:22:09 +03:00
?~ sync=(~(get by sources) loc)
abet
(poke-unsync loc u.sync)
::
++ poke-unmount
|= mon=kiln-unmount
?^ mon
=+ bem=(de-beam mon)
?~ bem
=+ "can't unmount bad path: {<mon>}"
abet:(spam leaf+- ~)
abet:(emit %pass /unmount-beam %arvo %c [%ogre [[p q r] s]:u.bem])
abet:(emit %pass /unmount-point %arvo %c [%ogre mon])
::
2022-09-07 09:52:59 +03:00
:: Don't need to cancel anything because new syncs will get a new nonce
::
++ poke-unsync
|= hus=kiln-unsync
2022-09-07 09:52:59 +03:00
?~ got=(~(get by zyn) hus)
abet:(spam (render "not syncing" [sud her syd ~]:hus) ~)
=. zyn (~(del by zyn) hus)
abet:(spam (render "cancelling sync" sud.hus her.hus syd.hus kid.u.got) ~)
:: +peer: handle %watch
::
++ peer
|= =path
?> (team:title our src)
2022-09-02 06:47:28 +03:00
?: =(0 1) abet :: avoid mint-vain
?+ path ~|(kiln-path/path !!)
2021-09-28 22:33:16 +03:00
[%vats ~]
2022-08-26 08:57:20 +03:00
(mean leaf+"kiln: old subscription to /kiln/vats failed" ~)
==
::
2019-11-14 21:39:50 +03:00
++ take-agent
2019-11-19 07:36:21 +03:00
|= [=wire =sign:agent:gall]
2022-09-08 08:56:12 +03:00
?+ wire
?: ?=(%poke-ack -.sign)
~? ?=(^ p.sign) [%kiln-poke-nack u.p.sign]
abet
~|([%kiln-bad-take-agent wire -.sign] !!)
::
2021-07-17 02:54:20 +03:00
[%fancy *]
?> ?=(%poke-ack -.sign)
(take-coup-fancy t.wire p.sign)
::
[%spam *]
?> ?=(%poke-ack -.sign)
(take-coup-spam t.wire p.sign)
::
[%link @ ~]
?> ?=(%poke-ack -.sign)
2021-09-26 08:07:23 +03:00
~> %slog.(fmt "linked {<`@tas`i.t.wire>} to console")
abet
2019-11-14 21:39:50 +03:00
==
::
2020-06-16 10:29:17 +03:00
++ take-arvo
2019-11-14 21:39:50 +03:00
|= [=wire =sign-arvo]
2022-09-02 06:47:28 +03:00
^+ abet
2021-07-17 02:54:20 +03:00
?- wire
2022-09-07 09:52:59 +03:00
[%sync %merg *] abet
[%find-ship *] abet
[%sync *] abet
2022-08-31 05:32:31 +03:00
[%zinc *] (take-sync t.wire sign-arvo)
2019-11-14 21:39:50 +03:00
[%autocommit *] %+ take-wake-autocommit t.wire
?>(?=(%wake +<.sign-arvo) +>.sign-arvo)
2022-09-02 06:47:28 +03:00
[%vats *] abet
2021-05-24 01:43:41 +03:00
[%fuse-request @tas *]
=/ f (fuzz i.t.wire now)
?~ f
abet
abet:abet:(take:u.f t.t.wire sign-arvo)
2021-05-24 01:43:41 +03:00
[%fuse @tas *] ?> ?=(%mere +<.sign-arvo)
=/ syd=desk i.t.wire
?. ?=([%| *] +>.sign-arvo)
?~ p.p.sign-arvo
abet
2021-06-06 01:48:55 +03:00
=/ msg=tape "fuse merge conflict for {<syd>}"
%- (slog [leaf+msg >p.p.sign-arvo< ~])
abet
%- (slog leaf+"failed fuse for {<syd>}" p.p.sign-arvo)
abet
2019-11-14 21:39:50 +03:00
*
?+ +<.sign-arvo
((slog leaf+"kiln: strange card {<+<.sign-arvo wire>}" ~) abet)
2022-09-08 08:56:12 +03:00
%done (done wire +>.sign-arvo)
%mere (take-mere wire +>.sign-arvo)
2019-11-14 21:39:50 +03:00
==
==
++ take |=(way=wire ?>(?=([@ ~] way) (work i.way))) :: general handler
++ done
|= [way=wire saw=(unit error:ames)]
~? ?=(^ saw) [%kiln-nack u.saw]
abet
::
2015-09-02 01:20:17 +03:00
++ take-mere ::
|= [way=wire are=(each (set path) (pair term tang))]
2021-05-18 22:09:22 +03:00
?. ?=([@ ~] way)
abet
2015-09-02 01:20:17 +03:00
abet:abet:(mere:(take way) are)
::
++ take-coup-fancy ::
|= [way=wire saw=(unit tang)]
2015-09-02 01:20:17 +03:00
abet:abet:(coup-fancy:(take way) saw)
::
2017-11-30 07:31:13 +03:00
++ take-coup-spam ::
|= [way=wire saw=(unit tang)]
2017-11-30 07:31:13 +03:00
~? ?=(^ saw) [%kiln-spam-lame u.saw]
abet
::
2019-08-25 12:00:26 +03:00
++ take-wake-autocommit
|= [way=wire error=(unit tang)]
?^ error
%- (slog u.error)
~& %kiln-wake-autocommit-fail
abet
=. nex.commit-timer (add now tim.commit-timer)
=< abet
%- emil
2019-11-14 21:39:50 +03:00
:~ [%pass /commit %arvo %c [%dirk mon.commit-timer]]
[%pass way.commit-timer %arvo %b [%wait nex.commit-timer]]
2019-08-25 12:00:26 +03:00
==
::
::
2015-09-02 01:20:17 +03:00
++ spam
|= mes=(list tank)
2015-09-02 01:20:17 +03:00
((slog mes) ..spam)
2021-05-24 01:43:41 +03:00
:: state machine for fuses
::
++ fuzz
|= [syd=desk now=@da]
=/ pfu=(unit per-fuse) (~(get by fus) syd)
?~ pfu
~
=* kf kf.u.pfu
=* mox mox.u.pfu
2021-05-24 01:43:41 +03:00
=/ should-delete=flag |
%- some
2021-05-24 01:43:41 +03:00
|%
:: finalize
::
++ abet
?: should-delete
2021-05-24 01:43:41 +03:00
..fuzz(fus (~(del by fus) syd))
..fuzz(fus (~(put by fus) syd [mox kf]))
::
++ delete
^+ ..delete
=. should-delete &
..delete
:: queue moves
::
++ blab
|= new=(list card:agent:gall)
^+ +>
+>.$(moz (welp new moz))
:: +make-requests: send requests for each %trak source.
2021-05-24 01:43:41 +03:00
::
++ make-requests
^+ ..abet
=/ movs=(list card:agent:gall)
%+ murn
[[bas.kf *germ] con.kf]
|= [fs=fuse-source germ]
^- (unit card:agent:gall)
?^ ver.fs
:: static source, don't need to track
~
2021-06-22 03:44:29 +03:00
=/ bec=beak (realize-fuse-source fs &)
2021-05-24 01:43:41 +03:00
?> =(who.fs p.bec)
?> =(des.fs q.bec)
=/ hax=@ud (mug [kf (~(got by hxs) syd)])
2021-06-06 01:48:55 +03:00
=/ wir=wire
/kiln/fuse-request/[syd]/(scot %p p.bec)/[q.bec]/(scot %ud hax)
2021-06-22 03:44:29 +03:00
=/ rav=rave [%sing %w r.bec /]
2021-05-24 01:43:41 +03:00
=/ rif=riff [q.bec `rav]
`[%pass wir %arvo %c [%warp who.fs rif]]
:: No need to keep state if all the sources are static
?~ movs
delete
(blab movs)
::
++ send-fuse
^+ ..abet
2021-06-22 03:44:29 +03:00
=/ bas=beak (realize-fuse-source bas.kf |)
2021-05-24 01:43:41 +03:00
=/ con=(list [beak germ])
%+ turn
con.kf
|= [fs=fuse-source g=germ]
2021-06-22 03:44:29 +03:00
[(realize-fuse-source fs |) g]
2021-05-24 01:43:41 +03:00
%- blab
[%pass /kiln/fuse/[syd] %arvo %c [%fuse syd bas con]]~
::
++ fuse
^+ ..abet
send-fuse:make-requests
::
++ take
|= [wir=wire =sign-arvo]
^+ ..fuse
?> =((lent wir) 3)
=/ who=ship (slav %p (snag 0 wir))
=/ src=desk (snag 1 wir)
=/ hax=@ud (slav %ud (snag 2 wir))
?. =(hax (mug [kf (~(got by hxs) syd)]))
:: If the hash in the wire doesn't match the current request
:: this is a response for a previous fuse that we can ignore.
..take
2021-06-17 00:45:45 +03:00
?> ?=([?(%clay %behn) %writ *] sign-arvo)
=/ gif +.sign-arvo
2021-05-24 01:43:41 +03:00
?~ p.gif
%- (slog leaf+"|fuse request failed for {<src>} on <who> - cancelling")
delete
=/ cas=cass:clay !<(cass:clay +.r.u.p.gif)
=. mox (~(put by mox) [who src] ud.cas)
2021-05-24 01:43:41 +03:00
fuse
::
:: utility functions below
::
:: +realize-fuse-source: convert a fuse-source to a
:: fully realized beak.
::
++ realize-fuse-source
2021-06-22 03:44:29 +03:00
|= [fs=fuse-source incr=flag]
2021-05-24 01:43:41 +03:00
^- beak
:+ who.fs
des.fs
?@ ver.fs
2021-06-22 03:44:29 +03:00
(realize-case [who.fs des.fs incr])
2021-05-24 01:43:41 +03:00
`case`ver.fs
::
++ realize-case
2021-06-22 03:44:29 +03:00
|= [who=ship des=desk incr=flag]
2021-05-24 01:43:41 +03:00
^- case
=/ let=(unit @ud) (~(get by mox) [who des])
^- case
?~ let
da+now
2021-06-22 03:44:29 +03:00
:- %ud
?: incr
+(u.let)
u.let
2021-05-24 01:43:41 +03:00
--
2015-09-02 01:20:17 +03:00
::
2022-08-31 05:32:31 +03:00
++ take-sync
|= [=wire =sign-arvo]
?> ?=([@ @ @ *] wire)
=* syd i.wire
=/ her (slav %p i.t.wire)
=* sud i.t.t.wire
2022-09-07 09:52:59 +03:00
?. (~(has by zyn) syd her sud)
abet
2022-08-31 05:32:31 +03:00
abet:abet:(take:(sync syd her sud) t.t.t.wire sign-arvo)
::
++ sync
2015-09-02 01:20:17 +03:00
|= kiln-sync
2022-09-07 09:52:59 +03:00
=/ got (~(get by zyn) syd her sud)
=+ `sync-state`(fall got [(scot %uv nyz) ~ *@ud])
=? nyz ?=(~ got) +(nyz)
2015-09-02 01:20:17 +03:00
|%
2022-09-07 09:52:59 +03:00
++ abet ..sync(zyn (~(put by zyn) [syd her sud] nun kid let))
2022-09-02 06:47:28 +03:00
++ apex |=(nex=(unit desk) ..abet(kid nex))
++ emit |=(card:agent:gall ..abet(kiln (^emit +<)))
++ emil |=((list card:agent:gall) ..abet(kiln (^emil +<)))
2022-09-08 09:38:35 +03:00
++ here "{<syd>} from {<her>}/{<sud>}"
2022-08-31 05:32:31 +03:00
++ ware
|= =wire
2022-09-07 09:52:59 +03:00
[%kiln %zinc syd (scot %p her) sud nun wire]
2022-08-31 05:32:31 +03:00
++ lard
|= [=wire =shed:khan]
(emit %pass (ware wire) %arvo %k %lard %base shed)
++ merg
|= [=wire =desk]
2022-09-02 06:47:28 +03:00
%: emit
%pass (ware wire) %arvo %c
%merg desk her sud
ud+(dec let) (get-germ desk)
==
2015-06-18 02:44:00 +03:00
::
2022-08-31 05:32:31 +03:00
:: (re)Start a sync from scratch by finding what version the source
:: desk is at
2015-05-12 03:31:37 +03:00
::
2022-08-31 05:32:31 +03:00
++ init
^+ ..abet
2022-09-02 06:47:28 +03:00
=. let 0
2022-08-31 05:32:31 +03:00
%+ lard /init
2022-09-02 06:47:28 +03:00
=/ m (strand:rand ,vase)
;< =riot:clay bind:m (warp:strandio her sud ~ %sing %y ud+1 /)
?> ?=(^ riot)
2022-08-31 05:32:31 +03:00
~> %slog.(fmt "activated install into {here}")
2022-09-02 06:47:28 +03:00
;< now=@da bind:m get-time:strandio
;< =riot:clay bind:m (warp:strandio her sud ~ %sing %w da+now /)
2022-08-31 05:32:31 +03:00
?> ?=(^ riot)
=+ !<(=cass:clay q.r.u.riot)
(pure:m !>(ud.cass))
2019-11-14 21:39:50 +03:00
::
2022-08-31 05:32:31 +03:00
:: Listen for the next revision, and download it
2015-06-04 00:18:13 +03:00
::
2022-08-31 05:32:31 +03:00
++ next
^+ ..abet
%+ lard /next
2022-09-02 06:47:28 +03:00
=/ m (strand:rand ,vase)
;< =riot:clay bind:m (warp:strandio her sud ~ %sing %w ud+let /)
?> ?=(^ riot)
2022-08-31 05:32:31 +03:00
~> %slog.(fmt "downloading update for {here}")
2022-09-02 06:47:28 +03:00
;< =riot:clay bind:m (warp:strandio her sud ~ %sing %v ud+let /)
2022-08-31 05:32:31 +03:00
?> ?=(^ riot)
(pure:m !>(%done))
2016-01-07 01:08:46 +03:00
::
2022-08-31 05:32:31 +03:00
:: Main control router
2019-04-30 20:40:38 +03:00
::
2022-08-31 05:32:31 +03:00
:: NB: %next, %main, and %kids are conceptually a single state with a
:: single error handling mechanism (move on to the next version). We
:: cannot combine them into a single lard because when you update
:: main you may update spider, and in that case all active threads
:: are killed, which would stop us from continuing that thread.
:: Instead, we do the merges to syd and kid explicitly.
2015-05-12 03:31:37 +03:00
::
2022-08-31 05:32:31 +03:00
++ take
|= [=wire =sign-arvo]
^+ ..abet
2022-09-07 09:52:59 +03:00
?> ?=([@ @ *] wire)
?. =(nun i.wire)
..abet
?+ i.t.wire
2022-08-31 05:32:31 +03:00
~> %slog.(fmt "sync-bad-take {<wire>}")
..abet
%init
?. =(0 let)
~> %slog.(fmt "sync-bad-stage {<let>} {<wire>}")
..abet
?> ?=(%arow +<.sign-arvo)
?: ?=(%| -.p.sign-arvo)
~> %slog.(fmt "activation failed into {here}; retrying sync")
%- (slog p.p.sign-arvo)
init
:: Now that we know the revision, start main download loop
::
=. let !<(@ud q.p.p.sign-arvo)
next
::
2022-08-31 05:32:31 +03:00
%next
?> ?=(%arow +<.sign-arvo)
?: ?=(%| -.p.sign-arvo)
:: ~> %slog.(fmt "download failed into {here}; retrying sync")
:: %- (slog p.p.sign-arvo)
2022-08-31 05:32:31 +03:00
init
::
~> %slog.(fmt "finished downloading update for {here}")
=. let +(let)
2023-01-27 00:55:15 +03:00
:: If nothing changed, just ensure %kids is up-to-date and advance
2022-08-31 05:32:31 +03:00
::
2022-09-02 06:47:28 +03:00
?. (get-remote-diff our syd now [her sud (dec let)])
=< next
?~ kid
~> %slog.(fmt "remote is identical to {here}, skipping")
..abet
?. (get-remote-diff our u.kid now [her sud (dec let)])
~> %slog.(fmt "remote is identical to {here}, skipping")
..abet
~> %slog.(fmt "remote is identical to {here}, merging into {<u.kid>}")
(merg /kids u.kid)
2022-08-31 05:32:31 +03:00
:: 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.
::
=. ..abet (merg /main syd)
next
::
2022-08-31 05:32:31 +03:00
%main
?> ?=(%mere +<.sign-arvo)
?: ?=(%| -.p.sign-arvo)
=+ "kiln: merge into {here} failed, waiting for next revision"
%- (slog leaf/- p.p.sign-arvo)
..abet
2022-09-02 06:47:28 +03:00
~> %slog.(fmt "merge into {<syd>} succeeded")
2022-08-31 05:32:31 +03:00
:: If we have a kids desk parameter, merge into that
::
?~ kid
..abet
~> %slog.(fmt "kids merge into {<u.kid>}")
2022-08-31 05:32:31 +03:00
(merg /kids u.kid)
::
2022-08-31 05:32:31 +03:00
%kids
2022-09-02 06:47:28 +03:00
?> ?=(%mere +<.sign-arvo)
2022-10-18 07:38:45 +03:00
?~ kid
..abet
2022-08-31 05:32:31 +03:00
:: Just notify; we've already started listening for the next
:: version
::
2022-09-02 06:47:28 +03:00
?- -.p.sign-arvo
2022-10-18 07:38:45 +03:00
%& ~> %slog.(fmt "kids merge to {<u.kid>} succeeded")
2022-08-31 05:32:31 +03:00
..abet
2022-10-18 07:38:45 +03:00
%| ~> %slog.(fmt "kids merge to {<u.kid>} failed")
2022-08-31 05:32:31 +03:00
%- (slog p.p.sign-arvo)
..abet
2015-09-02 01:20:17 +03:00
==
2022-08-31 05:32:31 +03:00
==
2015-09-02 01:20:17 +03:00
--
::
++ work :: state machine
|= syd=desk
=/ ,per-desk
%+ ~(gut by rem) syd
2017-11-30 00:29:35 +03:00
=+ *per-desk
2015-09-02 01:20:17 +03:00
%_(- cas [%da now])
|%
++ abet :: resolve
..work(rem (~(put by rem) syd auto gem her sud cas))
2015-05-28 05:46:58 +03:00
::
2015-09-02 01:20:17 +03:00
++ blab
|= new=(list card:agent:gall)
2015-09-02 01:20:17 +03:00
^+ +>
+>.$(moz (welp new moz))
2015-05-28 05:46:58 +03:00
::
2015-09-02 01:20:17 +03:00
++ win . :: successful poke
++ lose
^+ .
~| %kiln-work-fail
.
::
++ perform ::
2015-09-02 01:20:17 +03:00
^+ .
?< ?=(%this gem)
?< ?=(%that gem)
2019-11-14 21:39:50 +03:00
(blab [%pass /kiln/[syd] %arvo %c [%merg syd her sud cas gem]] ~)
2015-05-26 04:20:45 +03:00
::
2015-09-02 01:20:17 +03:00
++ fancy-merge :: send to self
|= [syd=desk her=@p sud=desk gem=?(%auto germ)]
2015-09-02 01:20:17 +03:00
^+ +>
2019-11-14 21:39:50 +03:00
=/ =cage [%kiln-merge !>([syd her sud cas gem])]
2015-09-02 01:20:17 +03:00
%- blab :_ ~
2019-11-14 21:39:50 +03:00
[%pass /kiln/fancy/[^syd] %agent [our %hood] %poke cage]
2015-05-26 04:20:45 +03:00
::
2015-09-02 01:20:17 +03:00
++ spam ::|=(tang ((slog +<) ..spam))
|*(* +>(..work (^spam +<)))
++ merge
|= [her=@p sud=@tas cas=case gim=?(%auto germ)]
2015-09-02 01:20:17 +03:00
^+ +>
?. ?=(%auto gim)
2016-01-07 01:08:46 +03:00
perform(auto |, gem gim, her her, cas cas, sud sud)
?: =(0 ud:.^(cass:clay %cw /(scot %p our)/[syd]/(scot %da now)))
2015-09-02 01:20:17 +03:00
=> $(gim %init)
.(auto &)
=> $(gim %fine)
.(auto &)
2015-05-26 04:20:45 +03:00
::
2015-09-02 01:20:17 +03:00
++ coup-fancy
|= saw=(unit tang)
2015-09-02 01:20:17 +03:00
?~ saw
2020-05-14 05:28:04 +03:00
+>
2015-09-02 01:20:17 +03:00
=+ :- "failed to set up conflict resolution scratch space"
"I'm out of ideas"
2015-12-21 00:16:39 +03:00
lose:(spam leaf+-< leaf+-> u.saw)
2015-05-26 04:20:45 +03:00
::
2015-09-02 01:20:17 +03:00
++ mere
|= are=(each (set path) (pair term tang))
2015-09-02 01:20:17 +03:00
^+ +>
?: =(%meld gem)
2018-03-19 06:54:47 +03:00
?: ?=(%& -.are)
2015-09-02 01:20:17 +03:00
?. auto
=+ "merged with strategy {<gem>}"
2015-12-21 00:16:39 +03:00
win:(spam leaf+- ?~(p.are ~ [>`(set path)`p.are< ~]))
2015-09-02 01:20:17 +03:00
:: ~? > =(~ p.are) [%mere-no-conflict syd]
2020-05-14 05:28:04 +03:00
=> .(+>.$ (spam leaf+"mashing conflicts" ~))
2015-09-02 01:20:17 +03:00
=+ tic=(cat 3 syd '-scratch')
2020-05-14 05:28:04 +03:00
=/ notations=(list [path (unit [mark vase])])
%+ turn ~(tap in p.are)
|= =path
=/ =mark -:(flop path)
=/ =dais .^(dais %cb /(scot %p our)/[syd]/(scot cas)/[mark])
=/ base .^(vase %cr (weld /(scot %p our)/[tic]/(scot cas) path))
=/ ali .^(vase %cr (weld /(scot %p her)/[sud]/(scot cas) path))
=/ bob .^(vase %cr (weld /(scot %p our)/[syd]/(scot cas) path))
=/ ali-dif (~(diff dais base) ali)
=/ bob-dif (~(diff dais base) bob)
=/ mash (~(mash dais base) [her sud ali-dif] [our syd bob-dif])
:- path
?~ mash
~
`[mark (~(pact dais base) u.mash)]
=/ [annotated=(list [path *]) unnotated=(list [path *])]
(skid notations |=([* v=*] ?=(^ v)))
=/ tic=desk (cat 3 syd '-scratch')
=/ tan=(list tank)
%- zing
^- (list (list tank))
:~ %- tape-to-tanks
"""
done setting up scratch space in {<[tic]>}
please resolve the following conflicts and run
|merge {<syd>} our {<[tic]>}
"""
%^ tanks-if-any
"annotated conflicts in:" (turn annotated head)
""
%^ tanks-if-any
"unannotated conflicts in:" (turn unnotated head)
"""
some conflicts could not be annotated.
for these, the scratch space contains
the most recent common ancestor of the
conflicting content.
"""
==
=< win
%- blab:(spam tan)
:_ ~
:* %pass /kiln/[syd] %arvo %c
%info
tic %&
%+ murn notations
|= [=path dif=(unit [=mark =vase])]
^- (unit [^path miso])
?~ dif
~
`[path %mut mark.u.dif vase.u.dif]
==
2015-09-02 01:20:17 +03:00
=+ "failed to merge with strategy meld"
2015-12-21 00:16:39 +03:00
lose:(spam leaf+- >p.p.are< q.p.are)
2018-03-19 06:54:47 +03:00
?: ?=(%& -.are)
2015-09-02 01:20:17 +03:00
=+ "merged with strategy {<gem>}"
2015-12-21 00:16:39 +03:00
win:(spam leaf+- ?~(p.are ~ [>`(set path)`p.are< ~]))
2015-09-02 01:20:17 +03:00
?. auto
=+ "failed to merge with strategy {<gem>}"
2015-12-21 00:16:39 +03:00
lose:(spam leaf+- >p.p.are< q.p.are)
2015-09-02 01:20:17 +03:00
?+ gem
2015-12-21 00:16:39 +03:00
(spam leaf+"strange auto" >gem< ~)
2015-09-02 01:20:17 +03:00
::
%init
2015-09-02 01:20:17 +03:00
=+ :- "auto merge failed on strategy %init"
2015-05-12 03:31:37 +03:00
"I'm out of ideas"
2015-12-21 00:16:39 +03:00
lose:(spam leaf+-< leaf+-> [>p.p.are< q.p.are])
2015-05-12 03:31:37 +03:00
::
%fine
?. ?=(%bad-fine-merge p.p.are)
2015-09-02 01:20:17 +03:00
=+ "auto merge failed on strategy %fine"
2015-12-21 00:16:39 +03:00
lose:(spam leaf+- >p.p.are< q.p.are)
=> (spam leaf+"%fine merge failed, trying %meet" ~)
2015-09-02 01:20:17 +03:00
perform(gem %meet)
2015-07-28 01:39:36 +03:00
::
%meet
?. ?=(%meet-conflict p.p.are)
2015-09-02 01:20:17 +03:00
=+ "auto merge failed on strategy %meet"
2015-12-21 00:16:39 +03:00
lose:(spam leaf+- >p.p.are< q.p.are)
=> (spam leaf+"%meet merge failed, trying %mate" ~)
2015-09-02 01:20:17 +03:00
perform(gem %mate)
2015-07-28 01:39:36 +03:00
::
%mate
?. ?=(%mate-conflict p.p.are)
2015-09-02 01:20:17 +03:00
=+ "auto merge failed on strategy %mate"
2015-12-21 00:16:39 +03:00
lose:(spam leaf+- >p.p.are< q.p.are)
2015-09-02 01:20:17 +03:00
=> .(gem %meld)
=+ tic=(cat 3 syd '-scratch')
=> =+ :- "%mate merge failed with conflicts,"
"setting up scratch space at %{(trip tic)}"
2015-12-21 00:16:39 +03:00
[tic=tic (spam leaf+-< leaf+-> q.p.are)]
2020-05-14 05:28:04 +03:00
=. ..mere (fancy-merge tic our syd %init)
=> (spam leaf+"%melding %{(trip sud)} into scratch space" ~)
%- blab :_ ~
?< ?=(%this gem)
?< ?=(%that gem)
2020-05-14 05:28:04 +03:00
=/ note [%merg (cat 3 syd '-scratch') her sud cas gem]
[%pass /kiln/[syd] %arvo %c note]
2015-09-02 01:20:17 +03:00
==
::
++ tape-to-tanks
|= a=tape ^- (list tank)
(scan a (more (just '\0a') (cook |=(a=tape leaf+a) (star prn))))
2015-09-02 01:20:17 +03:00
::
++ tanks-if-any
|= [a=tape b=(list path) c=tape] ^- (list tank)
2015-09-02 01:20:17 +03:00
?: =(~ b) ~
(welp (tape-to-tanks "\0a{c}{a}") >b< ~)
2015-05-12 03:31:37 +03:00
--
--