shrub/arvo/jael.hoon

1972 lines
73 KiB
Plaintext
Raw Normal View History

2016-09-13 03:24:21 +03:00
!: :: /van/jael
:: :: %reference/0
2016-09-13 03:24:21 +03:00
!? 150
2016-10-26 02:20:08 +03:00
::
::
:: %jael: secrets and promises.
::
:: todo:
::
:: - communication with other vanes:
:: - actually use %behn for expiring secrets
:: - report %ames propagation errors to user
::
:: - nice features:
:: - scry namespace
:: - task for converting invites to tickets
::
2016-09-15 20:38:47 +03:00
|= pit/vase
2016-10-30 05:02:08 +03:00
=, pki:^jael
=, rights:^jael
=, moves:^jael
2016-11-01 03:12:56 +03:00
=, crypto:ames
=, jael
2016-10-04 03:36:11 +03:00
:: ::::
2016-10-26 02:20:08 +03:00
:::: # models :: data structures
2016-10-04 03:36:11 +03:00
:: ::::
2016-10-26 02:20:08 +03:00
:: the %jael state comes in two parts: absolute
:: and relative.
::
:: ++state-absolute is objective -- defined without
:: reference to our ship. if you steal someone else's
:: private keys, we have a place to put them. when
:: others make promises to us, we store them in the
:: same structures we use to make promises to others.
::
:: ++state-relative is subjective, denormalized and
:: derived. it consists of all the state we need to
:: manage subscriptions efficiently.
::
2016-10-04 03:36:11 +03:00
=> |%
++ state :: all vane state
$: ver/$0 :: vane version
yen/(set duct) :: raw observers
urb/state-absolute :: all absolute state
sub/state-relative :: all relative state
2016-09-06 20:56:36 +03:00
== ::
2016-10-04 03:36:11 +03:00
++ state-relative :: urbit metadata
$: $= car :: secure channels
%+ map ship :: partner
$: yen/(set duct) :: trackers
det/channel :: channel state
== ::
$= rel :: neighborhood
$: dad/_our :: parent
cod/farm :: dependencies
pyr/(set ship) :: peers
kyz/(set ship) :: children
== ::
$= bal :: balance sheet
$: yen/(set duct) :: trackers
== ::
$= own :: vault
$: yen/(set duct) :: trackers
lyf/life :: version
jaw/(map life ring) :: private keys
== ::
== ::
++ state-absolute :: absolute urbit
$: pug/farm :: keys
pry/(map ship (map ship safe)) :: promises
2016-09-12 04:07:23 +03:00
== ::
2016-10-04 03:36:11 +03:00
:: ::
++ message :: p2p message
$% {$hail p/safe} :: reset rights
2016-09-28 04:39:03 +03:00
{$meet p/farm} :: propagate pki
2016-08-31 01:23:00 +03:00
== ::
2016-10-04 03:36:11 +03:00
++ card :: i/o action
(wind note gift) ::
2016-09-28 04:39:03 +03:00
:: ::
2016-10-04 03:36:11 +03:00
++ move :: output
{p/duct q/card} ::
2016-10-30 05:02:08 +03:00
-- ::
2016-09-13 03:24:21 +03:00
:: ::::
2016-10-26 02:20:08 +03:00
:::: # data :: static data
2016-09-13 03:24:21 +03:00
:: ::::
=> |%
2016-10-04 18:04:38 +03:00
:: :: ++zeno
2016-09-28 04:39:03 +03:00
++ zeno :: boot fingerprints
2016-10-26 02:20:08 +03:00
::
:: in ++zeno we hardcode the fingerprints of galaxies
:: and the identities of their owners. if the
:: fingerprint is 0, the galaxy can't be created.
::
:: we'll probably move at least the identity data
:: into urbit as it becomes more stable, but keeping
:: it in the source makes it very resilient.
::
2016-10-04 18:04:38 +03:00
|= who/ship
2016-10-02 13:52:17 +03:00
^- @
%+ snag who
^- (list @uw)
:~ 0w0 :: 0, ~zod, urbit.org
0w0 :: 1, ~nec, Curtis Yarvin
0w0 :: 2, ~bud, Tlon Investor 1
0w0 :: 3, ~wes, Tlon Investor 2
0w0 :: 4, ~sev, Tlon Investor 2
0w0 :: 5, ~per, Tlon Investor 3
0w0 :: 6, ~sut, Tlon Investor 4
0w0 :: 7, ~let, Tlon Investor 4
0w0 :: 8, ~ful, Tlon Investor 4
0w0 :: 9, ~pen, Tlon Investor 4
0w0 :: 10, ~syt, Tlon Investor 4
0w0 :: 11, ~dur, Tlon Investor 4
0w0 :: 12, ~wep, Sam Putman
0w0 :: 13, ~ser, Tlon Investor 5
0w0 :: 14, ~wyl, Zimran Ahmed
0w0 :: 15, ~sun, Colin Smith
0w0 :: 16, ~ryp, Tlon Investor 6
0w0 :: 17, ~syx, Tlon Investor 6
0w0 :: 18, ~dyr, Tlon Investor 6
0w0 :: 19, ~nup, Tlon Investor 6
0w0 :: 20, ~heb, Tlon Investor 6
0w0 :: 21, ~peg, Tlon Investor 6
0w0 :: 22, ~lup, Tlon Investor 6
0w0 :: 23, ~dep, Tlon Investor 6
0w0 :: 24, ~dys, Mike Gogulski
0w0 :: 25, ~put, Tlon Investor 7
0w0 :: 26, ~lug, Tlon Investor 8
0w0 :: 27, ~hec, Tlon Investor 8
0w0 :: 28, ~ryt, Tlon Investor 8
0w0 :: 29, ~tyv, Tlon Investor 8
0w0 :: 30, ~syd, Jennifer Kollmer
0w0 :: 31, ~nex, Prakhar Goel
0w0 :: 32, ~lun, Tlon Investor 9
0w0 :: 33, ~mep, Tlon Investor 9
0w0 :: 34, ~lut, Tlon Investor 9
0w0 :: 35, ~sep, Tlon Investor 9
0w0 :: 36, ~pes, Jennifer Kollmer
0w0 :: 37, ~del, Kingdon Barrett
0w0 :: 38, ~sul, John Burnham
0w0 :: 39, ~ped, Jeremy Wall
0w0 :: 40, ~tem, Tlon Investor 10
0w0 :: 41, ~led, Nick Caruso
0w0 :: 42, ~tul, Susan Yarvin
0w0 :: 43, ~met, Susan Yarvin
0w0 :: 44, ~wen, Susan Yarvin
0w0 :: 45, ~byn, Susan Yarvin
0w0 :: 46, ~hex, James Torre
0w0 :: 47, ~feb, urbit.org
0w0 :: 48, ~pyl, Michael Hartl
0w0 :: 49, ~dul, Jennifer Kollmer
0w0 :: 50, ~het, Jennifer Kollmer
0w0 :: 51, ~mev, Herbert Yarvin
0w0 :: 52, ~rut, Herbert Yarvin
0w0 :: 53, ~tyl, Tlon Investor 11
0w0 :: 54, ~wyd, Curtis Yarvin
0w0 :: 55, ~tep, Sibyl Kollmer
0w0 :: 56, ~bes, Sibyl Kollmer
0w0 :: 57, ~dex, Jared Hance
0w0 :: 58, ~sef, Owen Rescher
0w0 :: 59, ~wyc, Galen Wolfe-Pauly
0w0 :: 60, ~bur, Galen Wolfe-Pauly
0w0 :: 61, ~der, Galen Wolfe-Pauly
0w0 :: 62, ~nep, Galen Wolfe-Pauly
0w0 :: 63, ~pur, Herbert Yarvin
0w0 :: 64, ~rys, Charlie Cummings
0w0 :: 65, ~reb, Herbert Yarvin
0w0 :: 66, ~den, Michael Hartl
0w0 :: 67, ~nut, Henry Yarvin
0w0 :: 68, ~sub, Henry Yarvin
0w0 :: 69, ~pet, Henry Yarvin
0w0 :: 70, ~rul, Henry Yarvin
0w0 :: 71, ~syn, Henry Ault
0w0 :: 72, ~reg, Henry Ault
0w0 :: 73, ~tyd, Henry Ault
0w0 :: 74, ~sup, Henry Ault
0w0 :: 75, ~sem, Michael Livshin
0w0 :: 76, ~wyn, Anton Dyudin
0w0 :: 77, ~rec, Anton Dyudin
0w0 :: 78, ~meg, Anton Dyudin
0w0 :: 79, ~net, Anthony Martinez
0w0 :: 80, ~sec, Curtis Yarvin
0w0 :: 81, ~mul, Curtis Yarvin
0w0 :: 82, ~nym, Max Greer
0w0 :: 83, ~tev, Sibyl Kollmer
0w0 :: 84, ~web, Ar Vicco
0w0 :: 85, ~sum, Philip Monk
0w0 :: 86, ~mut, Philip Monk
0w0 :: 87, ~nyx, Philip Monk
0w0 :: 88, ~rex, Tlon Investor 12
0w0 :: 89, ~teb, Sibyl Kollmer
0w0 :: 90, ~fus, Tlon Corporation
0w0 :: 91, ~hep, urbit.org
0w0 :: 92, ~ben, urbit.org
0w0 :: 93, ~mus, urbit.org
0w0 :: 94, ~wyx, urbit.org
0w0 :: 95, ~sym, urbit.org
0w0 :: 96, ~sel, urbit.org
0w0 :: 97, ~ruc, urbit.org
0w0 :: 98, ~dec, urbit.org
0w0 :: 99, ~wex, Pax Dickinson
0w0 :: 100, ~syr, urbit.org
0w0 :: 101, ~wet, urbit.org
0w0 :: 102, ~dyl, urbit.org
0w0 :: 103, ~myn, urbit.org
0w0 :: 104, ~mes, urbit.org
0w0 :: 105, ~det, urbit.org
0w0 :: 106, ~bet, urbit.org
0w0 :: 107, ~bel, urbit.org
0w0 :: 108, ~tux, Tlon Investor 13
0w0 :: 109, ~tug, Philip Monk
0w0 :: 110, ~myr, urbit.org
0w0 :: 111, ~pel, urbit.org
0w0 :: 112, ~syp, urbit.org
0w0 :: 113, ~ter, urbit.org
0w0 :: 114, ~meb, urbit.org
0w0 :: 115, ~set, urbit.org
0w0 :: 116, ~dut, urbit.org
0w0 :: 117, ~deg, urbit.org
0w0 :: 118, ~tex, urbit.org
0w0 :: 119, ~sur, urbit.org
0w0 :: 120, ~fel, urbit.org
0w0 :: 121, ~tud, urbit.org
0w0 :: 122, ~nux, urbit.org
0w0 :: 123, ~rux, urbit.org
0w0 :: 124, ~ren, urbit.org
0w0 :: 125, ~wyt, urbit.org
0w0 :: 126, ~nub, urbit.org
0w0 :: 127, ~med, urbit.org
0w0 :: 128, ~lyt, Arthur Breitman
0w0 :: 129, ~dus, urbit.org
0w0 :: 130, ~neb, urbit.org
0w0 :: 131, ~rum, urbit.org
0w0 :: 132, ~tyn, urbit.org
0w0 :: 133, ~seg, urbit.org
0w0 :: 134, ~lyx, urbit.org
0w0 :: 135, ~pun, urbit.org
0w0 :: 136, ~res, urbit.org
0w0 :: 137, ~red, Alex Kravets
0w0 :: 138, ~fun, Aaron Beckerman
0w0 :: 139, ~rev, urbit.org
0w0 :: 140, ~ref, Matt Brubeck
0w0 :: 141, ~mec, urbit.org
0w0 :: 142, ~ted, urbit.org
0w0 :: 143, ~rus, Stephen Burnham
0w0 :: 144, ~bex, urbit.org
0w0 :: 145, ~leb, Justin LeBlanc
0w0 :: 146, ~dux, urbit.org
0w0 :: 147, ~ryn, urbit.org
0w0 :: 148, ~num, Tlon
0w0 :: 149, ~pyx, Katherine McFall
0w0 :: 150, ~ryg, Dan Haffey
0w0 :: 151, ~ryx, Tlon
0w0 :: 152, ~fep, Tlon
0w0 :: 153, ~tyr, Steve Dee
0w0 :: 154, ~tus, Tlon
0w0 :: 155, ~tyc, Tlon
0w0 :: 156, ~leg, Tlon
0w0 :: 157, ~nem, Tlon
0w0 :: 158, ~fer, Tlon
0w0 :: 159, ~mer, Tlon
0w0 :: 160, ~ten, Tlon
0w0 :: 161, ~lus, Tlon
0w0 :: 162, ~nus, Tlon
0w0 :: 163, ~syl, Tlon
0w0 :: 164, ~tec, Tlon
0w0 :: 165, ~mex, Tlon
0w0 :: 166, ~pub, Tlon
0w0 :: 167, ~rym, Tlon
0w0 :: 168, ~tuc, Tlon
0w0 :: 169, ~fyl, Tlon
0w0 :: 170, ~lep, Tlon
0w0 :: 171, ~deb, Tlon
0w0 :: 172, ~ber, Tlon
0w0 :: 173, ~mug, Tlon
0w0 :: 174, ~hut, Tlon
0w0 :: 175, ~tun, Tlon
0w0 :: 176, ~byl, Tlon
0w0 :: 177, ~sud, Tlon
0w0 :: 178, ~pem, Tlon
0w0 :: 179, ~dev, Tlon
0w0 :: 180, ~lur, Tlon
0w0 :: 181, ~def, Tlon
0w0 :: 182, ~bus, Tlon
0w0 :: 183, ~bep, Tlon
0w0 :: 184, ~run, Tlon
0w0 :: 185, ~mel, Tlon
0w0 :: 186, ~pex, Tlon
0w0 :: 187, ~dyt, Tlon
0w0 :: 188, ~byt, Tlon
0w0 :: 189, ~typ, Tlon
0w0 :: 190, ~lev, Tlon
0w0 :: 191, ~myl, Tlon
0w0 :: 192, ~wed, Tlon
0w0 :: 193, ~duc, Tlon
0w0 :: 194, ~fur, Tlon
0w0 :: 195, ~fex, Tlon
0w0 :: 196, ~nul, Tlon
0w0 :: 197, ~luc, Tlon
0w0 :: 198, ~len, Tlon
0w0 :: 199, ~ner, Tlon
0w0 :: 200, ~lex, Michael Hartl
0w0 :: 201, ~rup, Owen Rescher
0w0 :: 202, ~ned, Tlon
0w0 :: 203, ~lec, Tlon
0w0 :: 204, ~ryd, Tlon
0w0 :: 205, ~lyd, Adam Bliss
0w0 :: 206, ~fen, Tlon
0w0 :: 207, ~wel, Tlon
0w0 :: 208, ~nyd, Tlon
0w0 :: 209, ~hus, Tlon
0w0 :: 210, ~rel, Tlon
0w0 :: 211, ~rud, Tlon
0w0 :: 212, ~nes, Tlon
0w0 :: 213, ~hes, Tlon Investor 14
0w0 :: 214, ~fet, Tlon
0w0 :: 215, ~des, Tlon
0w0 :: 216, ~ret, Tlon
0w0 :: 217, ~dun, Tlon
0w0 :: 218, ~ler, Tlon
0w0 :: 219, ~nyr, Ivan Matosevic
0w0 :: 220, ~seb, Tlon
0w0 :: 221, ~hul, Tlon
0w0 :: 222, ~ryl, Tlon
0w0 :: 223, ~lud, Tlon
0w0 :: 224, ~rem, Tlon
0w0 :: 225, ~lys, Tlon
0w0 :: 226, ~fyn, Stephen Burnham
0w0 :: 227, ~wer, Tlon
0w0 :: 228, ~ryc, Tlon
0w0 :: 229, ~sug, Tlon
0w0 :: 230, ~nys, Tlon
0w0 :: 231, ~nyl, Tlon
0w0 :: 232, ~lyn, Tlon
0w0 :: 233, ~dyn, Tlon
0w0 :: 234, ~dem, Tlon
0w0 :: 235, ~lux, Tlon Investor 15
0w0 :: 236, ~fed, Tlon
0w0 :: 237, ~sed, Tlon
0w0 :: 238, ~bec, Tlon
0w0 :: 239, ~mun, Tlon
0w0 :: 240, ~lyr, Tlon
0w0 :: 241, ~tes, Tlon
0w0 :: 242, ~mud, Ian Rowan
0w0 :: 243, ~nyt, Byrne Hobart
0w0 :: 244, ~byr, Tlon
0w0 :: 245, ~sen, Tlon
0w0 :: 246, ~weg, Tlon
0w0 :: 247, ~fyr, Anton Dyudin
0w0 :: 248, ~mur, Tlon
0w0 :: 249, ~tel, Tlon
0w0 :: 250, ~rep, Raymond Pasco
0w0 :: 251, ~teg, Tlon
0w0 :: 252, ~pec, Tlon
0w0 :: 253, ~nel, Tlon
0w0 :: 254, ~nev, Tlon
0w0 :: 255, ~fes, John Burnham
==
2016-10-30 05:02:08 +03:00
-- ::
2016-09-13 03:24:21 +03:00
:: ::::
2016-10-26 02:20:08 +03:00
:::: # light :: light cores
2016-09-15 20:38:47 +03:00
:: ::::
2016-09-28 04:39:03 +03:00
=> |%
2016-09-30 18:42:08 +03:00
:: :: ++py
2016-10-30 05:02:08 +03:00
:::: ## sparse/light :: sparse range
2016-10-04 18:04:38 +03:00
:: ::::
++ py
2016-10-26 02:20:08 +03:00
:: because when you're a star with 2^16 unissued
:: planets, a (set) is kind of lame...
::
2016-10-06 03:37:51 +03:00
|_ a/pile
2016-10-07 01:52:13 +03:00
:: :: ++dif:py
++ dif :: add/remove a->b
|= b/pile
^- (pair pile pile)
[(sub(a b) a) (sub b)]
2016-10-06 03:37:51 +03:00
:: :: ++div:py
++ div :: allocate
|= b/@ud
^- (unit (pair pile pile))
=< ?-(- $& [~ p], $| ~)
|- ^- (each (pair pile pile) @u)
?: =(0 b)
[%& ~ a]
?~ a [%| 0]
=/ al $(a l.a)
?- -.al
$& [%& p.p.al a(l q.p.al)]
$|
=. b (^sub b p.al)
=/ top +((^sub q.n.a p.n.a))
?: =(b top)
[%& a(r ~) r.a]
?: (lth b top)
:+ %& a(r ~, q.n (add p.n.a (dec b)))
=. p.n.a (add p.n.a b)
(uni(a r.a) [n.a ~ ~])
=/ ar $(a r.a, b (^sub b top))
?- -.ar
$& [%& a(r p.p.ar) q.p.ar]
$| [%| :(add top p.al p.ar)]
==
==
2016-10-07 01:52:13 +03:00
::
++ gas :: ++gas:py
|= b/(list ship) ^- pile :: insert list
2016-10-06 03:37:51 +03:00
?~ b a
2016-10-07 01:52:13 +03:00
$(b t.b, a (put i.b))
:: :: ++gud:py
++ gud :: validate
=| {bot/(unit ship) top/(unit ship)}
|- ^- ?
?~ a &
?& (lte p.n.a q.n.a)
?~(top & (lth +(q.n.a) u.top))
?~(bot & (gth p.n.a +(u.bot)))
::
?~(l.a & (vor p.n.a p.n.l.a))
$(a l.a, top `p.n.a)
::
?~(l.a & (vor p.n.a p.n.l.a))
$(a r.a, bot `q.n.a)
==
2016-10-06 03:37:51 +03:00
:: :: ++int:py
++ int :: intersection
|= b/pile ^- pile
?~ a ~
?~ b ~
?. (vor p.n.a p.n.b) $(a b, b a)
?: (gth p.n.a q.n.b)
(uni(a $(b r.b)) $(a l.a, r.b ~))
?: (lth q.n.a p.n.b)
(uni(a $(b l.b)) $(a r.a, l.b ~))
?: (gte p.n.a p.n.b)
?: (lte q.n.a q.n.b)
[n.a $(a l.a, r.b ~) $(a r.a, l.b ~)]
[n.a(q q.n.b) $(a l.a, r.b ~) $(l.a ~, b r.b)]
%- uni(a $(r.a ~, b l.b))
?: (lte q.n.a q.n.b)
%- uni(a $(l.b ~, a r.a))
[n.b(q q.n.a) ~ ~]
%- uni(a $(l.a ~, b r.b))
[n.b ~ ~]
2016-10-07 01:52:13 +03:00
:: :: ++put:py
++ put :: insert
2016-10-06 03:37:51 +03:00
|= b/ship ^- pile
(uni [b b] ~ ~)
2016-10-07 01:52:13 +03:00
:: :: ++sub:py
++ sub :: subtract
|= b/pile ^- pile
2016-10-06 03:37:51 +03:00
?~ b a
2016-10-07 01:52:13 +03:00
?~ a a
?: (gth p.n.a q.n.b)
$(b r.b, l.a $(a l.a, r.b ~))
?: (lth q.n.a p.n.b)
$(b l.b, r.a $(a r.a, l.b ~))
%- uni(a $(a l.a, r.b ~))
%- uni(a $(a r.a, l.b ~))
?: (gte p.n.a p.n.b)
?: (lte q.n.a q.n.b)
~
$(b r.b, a [[+(q.n.b) q.n.a] ~ ~])
?: (lte q.n.a q.n.b)
$(b l.b, a [[n.a(q (min q.n.a (dec p.n.b)))] ~ ~])
%- uni(a $(b r.b, a [[+(q.n.b) q.n.a] ~ ~]))
$(b l.b, a [[n.a(q (min q.n.a (dec p.n.b)))] ~ ~])
2016-10-06 03:37:51 +03:00
::
++ tap
=| out/(list (pair ship ship))
|- ^+ out
?~ a out
$(a l.a, out [n.a $(a r.a)])
2016-10-07 01:52:13 +03:00
:: :: ++uni:py
++ uni :: merge two piles
|= b/pile
^- pile
?~ b a
?~ a b
?. (vor p.n.a p.n.b) $(a b, b a)
?: (lth +(q.n.b) p.n.a)
$(b r.b, l.a $(a l.a, r.b ~))
?: (lth +(q.n.a) p.n.b)
$(b l.b, r.a $(a r.a, l.b ~))
?: =(n.a n.b) [n.a $(a l.a, b l.b) $(a r.a, b r.b)]
?: (lth p.n.a p.n.b)
?: (gth q.n.a q.n.b)
$(b l.b, a $(b r.b))
$(b l.b, a $(b r.b, a $(b r.a, r.a ~, q.n.a q.n.b)))
?: (gth q.n.a q.n.b)
$(a l.a, b $(a r.a, b $(a r.b, r.b ~, q.n.b q.n.a)))
$(a l.a, b $(a r.a))
2016-10-30 05:02:08 +03:00
-- ::py
2016-09-29 10:07:40 +03:00
:: :: ++ry
2016-10-30 05:02:08 +03:00
:::: ## rights/light :: rights algebra
2016-10-04 18:04:38 +03:00
:: ::::
++ ry
2016-10-26 02:20:08 +03:00
::
:: we need to be able to combine rights, and
:: track changes by taking differences between them.
::
:: ++ry must always crash when you try to make it
:: do something that makes no sense.
::
:: language compromises: the type system can't enforce
:: that lef and ryt match, hence the asserts.
::
2016-10-04 18:04:38 +03:00
|_ $: :: lef: old right
:: ryt: new right
::
lef/rite
ryt/rite
==
2016-09-30 18:42:08 +03:00
:: :: ++dif:ry
2016-10-01 03:17:33 +03:00
++ dif :: r->l: {add remove}
2016-10-04 03:36:11 +03:00
^- (pair (unit rite) (unit rite))
2016-10-01 05:45:53 +03:00
|^ ?- -.lef
$apple ?>(?=($apple -.ryt) (table %apple p.lef p.ryt))
$block ?>(?=($block -.ryt) [~ ~])
$email ?>(?=($email -.ryt) (sable %email p.lef p.ryt))
$final ?>(?=($final -.ryt) (table %final p.lef p.ryt))
$fungi ?>(?=($fungi -.ryt) (noble %fungi p.lef p.ryt))
$guest ?>(?=($guest -.ryt) [~ ~])
$hotel ?>(?=($hotel -.ryt) (bible %hotel p.lef p.ryt))
$jewel ?>(?=($jewel -.ryt) (table %jewel p.lef p.ryt))
$login ?>(?=($login -.ryt) (sable %login p.lef p.ryt))
$pword ?>(?=($pword -.ryt) (ruble %pword p.lef p.ryt))
$token ?>(?=($token -.ryt) (ruble %token p.lef p.ryt))
$urban ?>(?=($urban -.ryt) (table %urban p.lef p.ryt))
==
:: :: ++bible:dif:ry
++ bible :: diff pile
2016-10-07 01:03:19 +03:00
|* {nut/@tas new/(map dorm pile) old/(map dorm pile)}
=/ mor/_old
%- ~(rep by old)
|= {{cur/dorm fid/pile} acc/_^+(old ~)}
=. fid
(~(sub py fid) (fall (~(get by new) cur) ~))
?~ fid acc
(~(put by acc) cur fid)
::
=/ les/_new
%- ~(rep by new)
|= {{cur/dorm fid/pile} acc/_^+(new ~)}
=. fid
(~(sub py fid) (fall (~(get by old) cur) ~))
?~ fid acc
(~(put by acc) cur fid)
::
:- ?~(mor ~ `[nut mor])
?~(les ~ `[nut les])
2016-10-01 05:45:53 +03:00
:: :: ++noble:dif:ry
++ noble :: diff map of @ud
|* {nut/@tas new/(map * @ud) old/(map * @ud)}
2016-10-04 03:36:11 +03:00
^- (pair (unit rite) (unit rite))
2016-10-07 00:56:24 +03:00
=/ mor/_old
%- ~(rep by old)
|* {{cur/* fid/@ud} acc/_^+(old ~)}
=> .(+< `_[[cur fid]=-.new acc=old]`+<)
=. fid
(^sub fid (max fid (fall (~(get by new) cur) 0)))
?~ fid acc
(~(put by acc) cur fid)
::
=/ les/_new
%- ~(rep by new)
|* {{cur/* fid/@ud} acc/_^+(new ~)}
=> .(+< `_[[cur fid]=-.old acc=new]`+<)
=. fid
(^sub fid (max fid (fall (~(get by old) cur) 0)))
?~ fid acc
(~(put by acc) cur fid)
2016-10-01 05:45:53 +03:00
::
:- ?~(mor ~ `[nut mor])
?~(les ~ `[nut les])
:: :: ++ruble:dif:ry
++ ruble :: diff map of maps
|* {nut/@tas new/(map * (map)) old/(map * (map))}
2016-10-07 00:56:24 +03:00
=/ mor/_old
%- ~(rep by old)
|* {{cur/* fid/(map)} acc/_^+(old ~)}
=> .(+< `_[[cur fid]=n.-.new acc=old]`+<)
=. fid
(~(dif by ,.fid) (fall (~(get by new) cur) ~))
?~ fid acc
(~(put by acc) cur fid)
::
=/ les/_new
%- ~(rep by new)
|* {{cur/* fid/(map)} acc/_^+(new ~)}
=> .(+< `_[[cur fid]=n.-.old acc=new]`+<)
=. fid
(~(dif by ,.fid) (fall (~(get by old) cur) ~))
?~ fid acc
(~(put by acc) cur fid)
2016-10-01 05:45:53 +03:00
::
:- ?~(mor ~ `[nut mor])
?~(les ~ `[nut les])
:: :: ++sable:dif:ry
++ sable :: diff set
|* {nut/@tas new/(set) old/(set)}
=/ mor (~(dif in new) old)
=/ les (~(dif in old) new)
:- ?~(mor ~ `[nut mor])
?~(les ~ `[nut les])
:: :: ++table:dif:ry
++ table :: diff map
|* {nut/@tas new/(map) old/(map)}
2016-10-04 03:36:11 +03:00
^- (pair (unit rite) (unit rite))
2016-10-01 05:45:53 +03:00
=/ ped (~(dep by old) new)
:- ?~(p.ped ~ `[nut p.ped])
?~(q.ped ~ `[nut q.ped])
2016-10-30 05:02:08 +03:00
-- ::dif
2016-10-01 05:45:53 +03:00
:: :: ++sub:ry
++ sub :: l - r
2016-10-04 03:36:11 +03:00
^- (unit rite)
2016-10-01 05:45:53 +03:00
=/ vid dif
?>(?=($~ q.vid) p.vid)
:: :: ++add:ry
++ uni :: lef new, ryt old
2016-10-04 03:36:11 +03:00
^- rite
|^ ?- -.lef
$apple ?>(?=($apple -.ryt) [%apple (table p.lef p.ryt)])
$block ?>(?=($block -.ryt) [%block ~])
$email ?>(?=($email -.ryt) [%email (sable p.lef p.ryt)])
$final ?>(?=($final -.ryt) [%final (table p.lef p.ryt)])
$fungi ?>(?=($fungi -.ryt) [%fungi (noble p.lef p.ryt)])
$guest ?>(?=($guest -.ryt) [%guest ~])
$hotel ?>(?=($hotel -.ryt) [%hotel (bible p.lef p.ryt)])
$jewel ?>(?=($jewel -.ryt) [%jewel (table p.lef p.ryt)])
$login ?>(?=($login -.ryt) [%login (sable p.lef p.ryt)])
$pword ?>(?=($pword -.ryt) [%pword (ruble p.lef p.ryt)])
$token ?>(?=($token -.ryt) [%token (ruble p.lef p.ryt)])
$urban ?>(?=($urban -.ryt) [%urban (table p.lef p.ryt)])
==
:: :: ++bible:uni:ry
++ bible :: union pile
2016-10-07 01:03:19 +03:00
|= {new/(map dorm pile) old/(map dorm pile)}
^+ new
2016-10-07 01:03:19 +03:00
%- (~(uno by old) new)
|= (trel dorm pile pile)
(~(uni py q) r)
:: :: ++noble:uni:ry
++ noble :: union map of @ud
|= {new/(map term @ud) old/(map term @ud)}
^+ new
%- (~(uno by old) new)
|= (trel term @ud @ud)
(add q r)
:: :: ++ruble:uni:ry
++ ruble :: union map of maps
|= {new/(map site (map @t @t)) old/(map site (map @t @t))}
^+ new
%- (~(uno by old) new)
|= (trel site (map @t @t) (map @t @t))
%- (~(uno by q) r)
|= (trel @t @t @t)
?>(=(q r) r)
:: :: ++sable:uni:ry
++ sable :: union set
|* {new/(set) old/(set)}
^+ new
(~(uni in old) new)
:: :: ++table:uni:ry
++ table :: union map
|* {new/(map) old/(map)}
^+ new
%- (~(uno by old) new)
|= (trel _p.-<.new _q.->.new _q.->.new)
?>(=(q r) r)
2016-10-30 05:02:08 +03:00
-- ::uni
-- ::ry
2016-09-28 04:39:03 +03:00
:: :: ++up
2016-10-26 02:20:08 +03:00
:::: ## wallet^light :: wallet algebra
2016-10-04 18:04:38 +03:00
:: ::::
++ up
2016-10-26 02:20:08 +03:00
:: a set of rites is stored as a tree (++safe), sorted
:: by ++gor on the stem, balanced by ++vor on the stem.
:: (this is essentially a ++map with stem as key, but
:: ++map doesn't know how to link stem and bulb types.)
:: the goal of the design is to make it easy to add new
:: kinds of rite without a state adapter.
::
:: wallet operations always crash if impossible;
:: %jael has no concept of negative rights.
::
:: performance issues: ++differ and ++splice, naive.
::
:: external issues: much copy and paste from ++by. it
:: would be nice to resolve this somehow, but not urgent.
::
:: language issues: if hoon had an equality test
:: that informed inference, ++expose could be
:: properly inferred, eliminating the ?>.
::
2016-10-04 03:36:11 +03:00
|_ pig/safe
:: :: ++delete:up
++ delete :: delete right
2016-10-04 03:36:11 +03:00
|= ryt/rite
^- safe
?~ pig
~
?. =(-.ryt -.n.pig)
?: (gor -.ryt -.n.pig)
[n.pig $(pig l.pig) r.pig]
[n.pig l.pig $(pig r.pig)]
=/ dub ~(sub ry n.pig ryt)
?^ dub [u.dub l.pig r.pig]
2016-10-04 03:36:11 +03:00
|- ^- safe
?~ l.pig r.pig
?~ r.pig l.pig
?: (vor -.n.l.pig -.n.r.pig)
[n.l.pig l.l.pig $(l.pig r.l.pig)]
[n.r.pig $(r.pig l.r.pig) r.r.pig]
2016-09-28 04:39:03 +03:00
:: :: ++differ:up
2016-09-20 19:21:56 +03:00
++ differ :: delta pig->gob
2016-10-04 03:36:11 +03:00
|= gob/safe
^- bump
|^ [way way(pig gob, gob pig)]
++ way
%- intern(pig ~)
%+ skip linear(pig gob)
2016-10-04 03:36:11 +03:00
|=(rite (~(has in pig) +<))
--
2016-09-28 04:39:03 +03:00
:: :: ++exists:up
++ exists :: test presence
|= tag/@tas
!=(~ (expose tag))
:: :: ++expose:up
2016-09-20 19:21:56 +03:00
++ expose :: typed extract
|= tag/@tas
2016-10-04 03:36:11 +03:00
^- (unit rite)
2016-09-20 19:21:56 +03:00
?~ pig ~
?: =(tag -.n.pig)
[~ u=n.pig]
?:((gor tag -.n.pig) $(pig l.pig) $(pig r.pig))
2016-09-28 04:39:03 +03:00
:: :: ++insert:up
2016-09-29 10:07:40 +03:00
++ insert :: insert item
2016-10-04 03:36:11 +03:00
|= ryt/rite
^- safe
?~ pig
[ryt ~ ~]
?: =(-.ryt -.n.pig)
?: =(+.ryt +.n.pig)
pig
[~(uni ry ryt n.pig) l.pig r.pig]
?: (gor -.ryt -.n.pig)
=+ nex=$(pig l.pig)
2016-10-07 01:03:14 +03:00
=. l.pig nex
?> ?=(^ l.pig)
?: (vor -.n.pig -.n.l.pig)
[n.pig l.pig r.pig]
[n.l.pig l.l.pig [n.pig r.l.pig r.pig]]
=+ nex=$(pig r.pig)
2016-10-07 01:03:14 +03:00
=. r.pig nex
?> ?=(^ r.pig)
?: (vor -.n.pig -.n.r.pig)
[n.pig l.pig r.pig]
[n.r.pig [n.pig l.pig l.r.pig] r.r.pig]
2016-09-29 10:07:40 +03:00
:: :: ++intern:up
++ intern :: insert list
2016-10-04 03:36:11 +03:00
|= lin/(list rite)
^- safe
2016-09-29 10:07:40 +03:00
?~ lin pig
=. pig $(lin t.lin)
(insert i.lin)
:: :: ++linear:up
++ linear :: convert to list
2016-10-04 03:36:11 +03:00
=| lin/(list rite)
2016-09-29 10:07:40 +03:00
|- ^+ lin
?~ pig ~
$(pig r.pig, lin [n.pig $(pig l.pig)])
2016-09-28 04:39:03 +03:00
:: :: ++redact:up
++ redact :: conceal secrets
2016-10-04 03:36:11 +03:00
|- ^- safe
2016-09-28 04:39:03 +03:00
?~ pig ~
:_ [$(pig l.pig) $(pig r.pig)]
=* rys n.pig
2016-10-04 03:36:11 +03:00
^- rite
2016-09-28 04:39:03 +03:00
?+ -.rys rys
$apple
[%apple (~(run by p.rys) |=(@ (mug +<)))]
::
$final
[%final (~(run by p.rys) |=(@ (mug +<)))]
2016-09-29 10:07:40 +03:00
::
$login
2016-10-01 03:17:33 +03:00
[%login ~]
2016-09-28 04:39:03 +03:00
::
$pword
:- %pword
%- ~(run by p.rys)
|= (map @ta @t)
2016-10-07 01:03:14 +03:00
(~(run by +<) |=(@t (fil 3 (met 3 +<) '*')))
2016-09-28 04:39:03 +03:00
::
$jewel
[%jewel (~(run by p.rys) |=(@ (mug +<)))]
::
$token
:- %token
%- ~(run by p.rys)
|=((map @ta @) (~(run by +<) |=(@ (mug +<))))
::
$urban
[%urban (~(run by p.rys) |=({@da code} [+<- (mug +<+)]))]
==
:: :: ++remove:up
2016-09-20 19:21:56 +03:00
++ remove :: pig minus gob
2016-10-04 03:36:11 +03:00
|= gob/safe
^- safe
=/ buv (~(tap by gob))
|- ?~ buv pig
$(buv t.buv, pig (delete i.buv))
2016-09-29 10:07:40 +03:00
:: :: ++splice:up
++ splice :: pig plus gob
2016-10-04 03:36:11 +03:00
|= gob/safe
^- safe
=/ buv (~(tap by gob))
|- ?~ buv pig
$(buv t.buv, pig (insert i.buv))
2016-09-28 04:39:03 +03:00
:: :: ++update:up
2016-09-20 19:21:56 +03:00
++ update :: arbitrary change
2016-10-04 03:36:11 +03:00
|= del/bump
^- safe
(splice(pig (remove les.del)) mor.del)
2016-09-20 19:21:56 +03:00
--
2016-09-28 04:39:03 +03:00
:: :: ++we
2016-10-28 08:19:01 +03:00
:::: ## will^light :: will functions
2016-10-04 18:04:38 +03:00
:: ::::
++ we
2016-10-28 08:19:01 +03:00
|_ pub/will
2016-09-28 04:39:03 +03:00
:: :: ++collate:we
++ collate :: sort by version
|= com/$-({{life cert} {life cert}} ?)
^- (list (pair life cert))
(sort (~(tap by pub)) com)
:: :: ++current:we
++ current :: current number
^- (unit life)
(bind instant |=((pair life cert) p))
:: :: ++forward:we
++ forward :: sort oldest first
(collate |=({a/{life *} b/{life *}} (lth -.a -.b)))
:: :: ++instant:we
++ instant :: current cert
^- (unit (pair life cert))
=+ reverse
?~(- ~ `i)
:: :: ++reverse:we
++ reverse :: sort latest first
(collate |=({a/{life *} b/{life *}} (gth -.a -.b)))
--
2016-09-20 19:21:56 +03:00
--
2016-09-15 20:38:47 +03:00
:: ::::
2016-10-26 02:20:08 +03:00
:::: # heavy :: heavy engines
2016-09-13 03:24:21 +03:00
:: ::::
=> |%
2016-10-04 18:04:38 +03:00
:: :: ++of
2016-10-26 02:20:08 +03:00
:::: ## main^heavy :: main engine
2016-10-04 18:04:38 +03:00
:: ::::
++ of
2016-10-26 02:20:08 +03:00
:: this core handles all top-level %jael semantics,
:: changing state and recording moves.
::
:: logically we could nest the ++su and ++ur cores
:: within it, but we keep them separated for clarity.
:: the ++curd and ++cure arms complete relative and
:: absolute effects, respectively, at the top level.
::
:: a general pattern here is that we use the ++ur core
:: to generate absolute effects (++change), then invoke
:: ++su to calculate the derived effect of these changes.
::
:: arvo issues: should be merged with the top-level
:: vane interface when that gets cleaned up a bit.
::
2016-10-04 18:04:38 +03:00
=| moz/(list move)
2016-09-20 19:21:56 +03:00
=| $: :: sys: system context
2016-09-14 20:03:06 +03:00
::
2016-09-20 19:21:56 +03:00
$= sys
2016-09-14 20:03:06 +03:00
$: :: now: current time
2016-09-13 03:24:21 +03:00
:: eny: unique entropy
2016-09-12 04:07:23 +03:00
::
2016-09-13 03:24:21 +03:00
now/@da
eny/@e
2016-09-12 04:07:23 +03:00
==
2016-09-13 03:24:21 +03:00
:: all vane state
2016-09-12 04:07:23 +03:00
::
2016-10-04 03:36:11 +03:00
state
2016-09-12 04:07:23 +03:00
==
2016-09-13 03:24:21 +03:00
:: lex: all durable state
2016-09-14 20:03:06 +03:00
:: moz: pending actions
::
2016-09-20 19:21:56 +03:00
=* lex ->
2016-09-12 04:07:23 +03:00
|%
2016-10-04 18:04:38 +03:00
:: :: ++abet:of
2016-09-12 04:07:23 +03:00
++ abet :: resolve
2016-09-13 03:24:21 +03:00
[(flop moz) lex]
2016-10-04 18:04:38 +03:00
:: :: ++burb:of
2016-09-29 10:07:40 +03:00
++ burb :: per ship
|= who/ship
~(able ~(ex ur urb) who)
2016-10-04 18:04:38 +03:00
:: :: ++call:of
2016-09-13 03:24:21 +03:00
++ call :: invoke
|= $: :: hen: event cause
:: tac: event data
2016-09-12 04:07:23 +03:00
::
2016-09-13 03:24:21 +03:00
hen/duct
2016-10-04 03:36:11 +03:00
tac/task
2016-09-12 04:07:23 +03:00
==
2016-09-13 03:24:21 +03:00
^+ +>
?- -.tac
::
2016-09-28 04:39:03 +03:00
:: destroy promises
2016-10-07 00:56:24 +03:00
:: {$burn p/ship q/safe}
::
2016-09-28 04:39:03 +03:00
$burn
2016-09-29 10:07:40 +03:00
(cure abet:abet:(deal:(burb our) p.tac [~ q.tac]))
2016-09-12 04:07:23 +03:00
::
2016-09-28 04:39:03 +03:00
:: remote update
2016-10-04 03:36:11 +03:00
:: {$hail p/ship q/remote}
2016-09-12 04:07:23 +03:00
::
2016-09-28 04:39:03 +03:00
$hail
2016-09-29 10:07:40 +03:00
(cure abet:abet:(hail:(burb p.tac) our q.tac))
2016-09-08 19:29:38 +03:00
::
2016-09-28 04:39:03 +03:00
:: initialize vane
2016-09-29 10:07:40 +03:00
:: {$init p/code q/arms}
2016-09-08 19:29:38 +03:00
::
2016-09-28 04:39:03 +03:00
$init
2016-09-29 10:07:40 +03:00
(cure abet:(~(make ur urb) now.sys eny.sys p.tac q.tac))
2016-09-14 20:03:06 +03:00
::
2016-09-28 04:39:03 +03:00
:: create promises
2016-10-04 03:36:11 +03:00
:: {$mint p/ship q/safe}
2016-09-08 19:29:38 +03:00
::
2016-09-28 04:39:03 +03:00
$mint
2016-09-29 10:07:40 +03:00
(cure abet:abet:(deal:(burb our) p.tac [q.tac ~]))
2016-09-20 19:21:56 +03:00
::
2016-09-28 04:39:03 +03:00
:: move promises
2016-10-04 03:36:11 +03:00
:: {$move p/ship q/ship r/safe}
2016-09-20 19:21:56 +03:00
::
2016-09-28 04:39:03 +03:00
$move
2016-09-29 10:07:40 +03:00
=. +> (cure abet:abet:(deal:(burb our) p.tac [~ r.tac]))
=. +> (cure abet:abet:(deal:(burb our) q.tac [r.tac ~]))
2016-09-28 04:39:03 +03:00
+>
::
2016-09-28 04:39:03 +03:00
:: public-key update
2016-09-29 10:07:40 +03:00
:: {$meet p/(unit (unit ship)) q/farm}
::
2016-09-28 04:39:03 +03:00
$meet
(cure abet:(~(meet ur urb) p.tac q.tac))
::
2016-09-28 04:39:03 +03:00
:: cancel all trackers from duct
:: {$nuke $~}
::
2016-09-28 04:39:03 +03:00
$nuke
2016-09-29 10:07:40 +03:00
%_ +>
yen (~(del in yen) hen)
yen.bal.sub (~(del in yen.bal.sub) hen)
yen.own.sub (~(del in yen.own.sub) hen)
car.sub %- ~(run by car.sub)
2016-10-04 03:36:11 +03:00
|= {yen/(set duct) det/channel}
2016-09-29 10:07:40 +03:00
[(~(del in yen) hen) det]
==
2016-09-08 19:29:38 +03:00
::
2016-09-13 03:24:21 +03:00
:: extend our certificate with a new private key
2016-09-29 10:07:40 +03:00
:: {$next p/bull}
2016-09-08 19:29:38 +03:00
::
2016-09-29 10:07:40 +03:00
$next
(cure abet:abet:(next:(burb our) eny.sys p.tac))
::
2016-09-28 04:39:03 +03:00
:: open secure channel
:: {$veil p/ship}
::
$veil
(curd abet:(~(veil ~(feed su urb sub) hen) p.tac))
::
2016-09-20 19:21:56 +03:00
:: watch private keys
:: {$vein $~}
::
2016-09-20 19:21:56 +03:00
$vein
2016-09-28 04:39:03 +03:00
(curd abet:~(vein ~(feed su urb sub) hen))
::
2016-09-13 03:24:21 +03:00
:: monitor assets
:: {$vest $~}
2016-09-07 20:36:06 +03:00
::
2016-09-13 03:24:21 +03:00
$vest
2016-09-28 04:39:03 +03:00
(curd abet:~(vest ~(feed su urb sub) hen))
2016-09-08 19:29:38 +03:00
::
2016-09-20 19:21:56 +03:00
:: monitor all
:: {$vine $~}
::
$vine
2016-09-28 04:39:03 +03:00
+>(yen (~(put in yen) hen))
2016-09-20 19:21:56 +03:00
::
2016-09-29 10:07:40 +03:00
:: authenticated remote request
2016-09-13 03:24:21 +03:00
:: {$west p/ship q/path r/*}
2016-09-08 19:29:38 +03:00
::
2016-09-13 03:24:21 +03:00
$west
2016-09-14 20:03:06 +03:00
?> =(~ q.tac)
2016-10-04 03:36:11 +03:00
=+ mes=((hard message) r.tac)
2016-09-14 20:03:06 +03:00
?- -.mes
::
:: reset remote rights
2016-10-04 03:36:11 +03:00
:: {$hail p/safe}
2016-09-14 20:03:06 +03:00
::
$hail
2016-09-29 10:07:40 +03:00
(cure abet:abet:(hail:(burb p.tac) our [%| p.mes]))
2016-09-14 20:03:06 +03:00
::
:: share certificates
2016-09-28 04:39:03 +03:00
:: {$meet p/farm}
2016-09-14 20:03:06 +03:00
::
2016-09-28 04:39:03 +03:00
$meet
2016-09-29 10:07:40 +03:00
(cure abet:(~(meet ur urb) ``p.tac p.mes))
2016-09-14 20:03:06 +03:00
==
2016-09-13 03:24:21 +03:00
==
2016-09-29 10:07:40 +03:00
:: :: ++curd:of
2016-10-04 03:36:11 +03:00
++ curd :: relative moves
|= {moz/(list move) sub/state-relative}
2016-09-28 04:39:03 +03:00
+>(sub sub, moz (weld (flop moz) ^moz))
2016-09-29 10:07:40 +03:00
:: :: ++cure:of
2016-10-04 03:36:11 +03:00
++ cure :: absolute edits
|= {hab/(list change) urb/state-absolute}
2016-09-14 20:03:06 +03:00
^+ +>
2016-09-28 04:39:03 +03:00
(curd(urb urb) abet:(~(apex su urb sub) hab))
2016-09-14 20:03:06 +03:00
--
2016-10-05 03:29:25 +03:00
:: :: ++su
2016-10-26 02:20:08 +03:00
:::: ## relative^heavy :: subjective engine
2016-10-05 03:29:25 +03:00
:: ::::
++ su
:: the ++su core handles all derived state,
:: subscriptions, and actions.
::
:: ++feed:su registers subscriptions, and also
:: drives certificate propagation when a %veil
:: (secure channel) subscription is created.
::
:: ++feel:su checks if a ++change should notify
:: any subscribers.
::
:: ++fire:su generates outgoing network messages.
::
:: ++form:su generates the actual report data.
::
=| moz/(list move)
2016-10-04 03:36:11 +03:00
=| $: state-absolute
state-relative
2016-09-15 20:38:47 +03:00
==
2016-09-20 19:21:56 +03:00
:: moz: moves in reverse order
2016-10-04 03:36:11 +03:00
:: urb: absolute urbit state
:: sub: relative urbit state
2016-09-16 20:10:15 +03:00
::
2016-09-20 19:21:56 +03:00
=* urb -<
=* sub ->
2016-09-15 20:38:47 +03:00
|%
2016-09-29 10:07:40 +03:00
:: :: ++abet:su
2016-09-15 20:38:47 +03:00
++ abet :: resolve
2016-09-20 19:21:56 +03:00
[(flop moz) sub]
2016-09-29 10:07:40 +03:00
:: :: ++apex:su
2016-09-15 20:38:47 +03:00
++ apex :: apply changes
2016-10-04 03:36:11 +03:00
|= hab/(list change)
2016-09-15 20:38:47 +03:00
^+ +>
2016-09-28 04:39:03 +03:00
?~ hab +>
%= $
hab t.hab
+>
?- -.i.hab
$rite (paid +.i.hab)
$fact (said +.i.hab)
==
==
:: :: ++exec:su
++ exec :: mass gift
2016-10-04 03:36:11 +03:00
|= {yen/(set duct) cad/card}
2016-09-28 04:39:03 +03:00
=/ noy (~(tap in yen))
|- ^+ ..exec
?~ noy ..exec
$(noy t.noy, moz [[i.noy cad] moz])
:: :: ++feed:su
++ feed :: subscribe to view
|_ :: hen: subscription source
::
hen/duct
:: :: ++veil:feed:su
++ veil :: secure channel
|= who/ship
2016-09-28 04:39:03 +03:00
^+ ..feed
::
:: send initial pki sync as needed
::
=. ..feed (open hen who)
2016-09-28 04:39:03 +03:00
=/ ruc (~(get by car) who)
=/ rec
?~ ruc
[`yen/(set duct)`[hen ~ ~] det=(veil:form who)]
u.ruc(yen (~(put in yen.u.ruc) hen))
2016-09-28 04:39:03 +03:00
%_ ..feed
moz [[hen %give %veil det.rec] moz]
2016-09-28 04:39:03 +03:00
car (~(put by car) who rec)
==
:: :: ++vein:feed:su
++ vein :: private keys
%_ ..feed
moz [[hen %give %vein [lyf jaw]:own] moz]
yen.own (~(put in yen.own) hen)
==
:: :: ++vest:feed:su
++ vest :: balance
%_ ..feed
moz [[hen %give %vest %& vest:form] moz]
yen.bal (~(put in yen.bal) hen)
==
--
:: :: ++feel:su
++ feel :: update tracker
|%
:: :: ++veal:feel:su
++ veal :: kick subfarm
^+ ..feel
=/ cod veal:form
?:(=(cod.rel cod) ..feel ..feel(cod.rel cod))
2016-09-28 04:39:03 +03:00
:: :: ++veil:feel:su
++ veil :: kick secure channel
|= who/ship
^+ ..feel
=/ ruc (~(get by car) who)
?~ ruc ..feel
=/ det (veil:form who)
?: =(det det.u.ruc) ..feel
=. car (~(put by car) who [yen.u.ruc det])
(exec yen.u.ruc [%give %veil det])
2016-09-28 04:39:03 +03:00
:: :: ++vein:feel:su
++ vein :: kick private keys
^+ ..feel
=/ yam vein:form
?: =(yam +.own) ..feel
(exec(+.own yam) yen.own [%give %vein +.own])
:: :: ++vest:feel:su
++ vest :: kick balance
2016-10-04 03:36:11 +03:00
|= hug/action
2016-09-28 04:39:03 +03:00
^+ ..feel
?: =([~ ~] +.q.hug) ..feel
2016-09-16 20:10:15 +03:00
::
2016-09-28 04:39:03 +03:00
:: notify all local listeners
2016-09-16 20:10:15 +03:00
::
2016-09-28 04:39:03 +03:00
=. ..feel (exec yen.bal [%give %vest %| p.hug q.hug])
2016-09-16 20:10:15 +03:00
::
2016-09-28 04:39:03 +03:00
:: pig: purse report for partner
2016-09-16 20:10:15 +03:00
::
2016-09-28 04:39:03 +03:00
?. ?=($| -.q.hug) ..feel
=* pig (~(lawn ur urb) our p.hug)
%_ ..feel
moz :_ moz
[*duct %pass /vest/(scot %p p.hug) %x %mess p.hug /j %hail pig]
==
--
:: :: ++fire:su
++ fire :: propagate keys
|_ hec/farm
++ home :: ++home:su
|= who/ship :: to ship
%_ ..fire
moz
:_ moz
[*duct %pass /meet/(scot %p who) %x %mess who /j [%meet hec]]
==
:: :: ++flow:su
++ flow :: to set of ships
|= tar/(set ship)
=+ rot=(~(tap in (~(del in tar) our)))
|- ^+ ..fire
?~ rot ..fire
$(rot t.rot, ..fire (home i.rot))
:: :: ++spam:su
++ spam :: to list of sets
|= {via/(unit ship) jax/(list (set ship))}
^+ ..fire
=- (flow ?~(via - (~(del in -) u.via)))
|- ^- (set ship)
?~(jax ~ (~(uni in i.jax) $(jax t.jax)))
--
:: :: ++form:su
++ form :: generate reports
|%
:: :: ++veal:form:su
++ veal :: public dependencies
2016-10-02 13:52:17 +03:00
=| sea/(set ship)
=| out/farm
=/ mor `(set ship)`[our ~ ~]
|- ^- farm
?: =(~ mor) out
::
2016-10-28 08:19:01 +03:00
:: nex: all wills to add
2016-10-02 13:52:17 +03:00
::
=/ nex
=/ rom (~(tap in mor))
|- ^- farm
?~ rom ~
%+ ~(put by $(rom t.rom))
i.rom
(~(got by pug.urb) i.rom)
::
2016-10-28 08:19:01 +03:00
:: wit: all new ships in these wills
2016-10-02 13:52:17 +03:00
::
=. sea (~(uni in sea) mor)
=/ wit
=| wit/(set ship)
=/ fem (~(tap by nex))
|- ^+ wit
?~ fem wit
=. wit $(fem t.fem)
=/ naw (~(tap by q.i.fem))
|- ^+ wit
?~ naw wit
=. wit $(naw t.naw)
=* dad dad.doc.dat.q.i.naw
?: (~(has in sea) dad) wit
(~(put in wit) dad)
::
:: repeat, flushing output
::
$(mor wit, out (~(uni by out) nex))
2016-09-28 04:39:03 +03:00
:: :: ++veil:form:su
++ veil :: channel report
|= who/ship
2016-10-04 03:36:11 +03:00
^- channel
2016-09-16 20:10:15 +03:00
::
2016-10-28 08:19:01 +03:00
:: pub: will of who
2016-09-28 04:39:03 +03:00
:: exp: promises from our to who
:: imp: promises from who to our
:: out: symmetric key from our to who
:: inn: symmetric keys from who to our
2016-09-16 20:10:15 +03:00
::
2016-09-28 04:39:03 +03:00
=/ pub
2016-10-28 08:19:01 +03:00
^- will
2016-09-28 04:39:03 +03:00
=- ?~(- ~ u.-)
(~(get by pug.urb) who)
2016-09-16 20:10:15 +03:00
::
2016-09-28 04:39:03 +03:00
=/ exp
2016-10-04 03:36:11 +03:00
^- safe
2016-09-28 04:39:03 +03:00
=- ?~(- ~ u.-)
(~(get by (~(got by pry.urb) our)) who)
::
=/ imp
2016-10-04 03:36:11 +03:00
^- safe
2016-09-28 04:39:03 +03:00
=- ?~(- ~ u.-)
%. our
2016-10-04 03:36:11 +03:00
~(get by (fall (~(get by pry.urb) who) *(map ship safe)))
2016-09-28 04:39:03 +03:00
::
=* out
^- (unit (pair hand bill))
=+ (~(expose up exp) %urban)
?~ - ~
?> ?=($urban -.u.-)
=* pam p.u.-
?~ pam ~
:: arbitrarily select root node of the map
::
`n.pam
::
=* inn
=+ (~(expose up imp) %urban)
^- (map hand bill)
?~ - ~
?> ?=($urban -.u.-)
p.u.-
::
2016-10-04 03:36:11 +03:00
^- channel
2016-09-28 04:39:03 +03:00
[out inn ~(current we pub) (~(dads ur urb) who) pub]
:: :: ++vein:form:su
++ vein :: private key report
^- (pair life (map life ring))
(~(lean ur urb) our)
:: :: ++vest:form:su
++ vest :: balance report
2016-10-04 03:36:11 +03:00
^- balance
2016-09-28 04:39:03 +03:00
:- ::
:: raw: all our liabilities by ship
:: dud: delete liabilities to self
:: cul: mask secrets
::
=* raw =-(?~(- ~ u.-) (~(get by pry.urb) our))
=* dud (~(del by raw) our)
2016-10-04 03:36:11 +03:00
=* cul (~(run by dud) |=(safe ~(redact up +<)))
2016-09-28 04:39:03 +03:00
cul
::
:: fub: all assets by ship
:: veg: all nontrivial assets, secrets masked
::
=/ fub
2016-10-04 03:36:11 +03:00
^- (list (pair ship (unit safe)))
2016-09-28 04:39:03 +03:00
%+ turn
(~(tap by pry.urb))
2016-10-04 03:36:11 +03:00
|= (pair ship (map ship safe))
2016-09-28 04:39:03 +03:00
[p (~(get by q) our)]
=* veg
2016-10-04 03:36:11 +03:00
|- ^- (list (pair ship safe))
2016-09-28 04:39:03 +03:00
?~ fub ~
=+ $(fub t.fub)
?~(q.i.fub - [[p.i.fub ~(redact up u.q.i.fub)] -])
::
2016-10-04 03:36:11 +03:00
(~(gas by *(map ship safe)) veg)
2016-09-28 04:39:03 +03:00
--
:: :: ++open:su
++ open :: make secure channel
|= $: hen/duct
2016-09-28 04:39:03 +03:00
who/ship
==
2016-09-16 20:10:15 +03:00
^+ +>
::
:: a one-time operation to create a secure channel
::
?: (~(has by car) who) +>
::
:: initial propagation: ourself and dependencies, plus
:: all capital ships if meeting a child.
::
=* hec ^- farm
?. (~(has in kyz.rel) who) cod.rel
=- (~(uni by cod.rel) -)
%- ~(gas by *farm)
%+ skim (~(tap by pug.urb))
|=({who/ship *} (lth who 65.536))
::
(~(home fire hec) who)
:: :: ++paid:su
2016-09-28 04:39:03 +03:00
++ paid :: track asset change
|= $: :: rex: promise from
:: pal: promise to
:: del: change to existing
:: bur: changes to symmetric keys
::
rex/ship
pal/ship
2016-10-04 03:36:11 +03:00
del/bump
2016-09-28 04:39:03 +03:00
==
2016-09-16 20:10:15 +03:00
^+ +>
2016-09-28 04:39:03 +03:00
=* bur ?| (~(exists up mor.del) %urban)
(~(exists up les.del) %urban)
==
:: ignore empty delta; keep secrets out of metadata
2016-09-16 20:10:15 +03:00
::
2016-09-28 04:39:03 +03:00
?: =([~ ~] del) +>
=. del [~(redact up mor.del) ~(redact up les.del)]
?. =(our pal)
::
:: track promises we made to others
::
?. =(our rex) +>
::
:: track liabilities
::
=. +> (vest:feel pal %& del)
::
:: track secure channels
::
?. bur +>
(veil:feel pal)
2016-09-16 20:10:15 +03:00
::
2016-09-28 04:39:03 +03:00
:: track private keys
2016-09-16 20:10:15 +03:00
::
2016-09-28 04:39:03 +03:00
=. +> ?. (~(exists up mor.del) %jewel)
+>
vein:feel
2016-09-16 20:10:15 +03:00
::
2016-09-28 04:39:03 +03:00
:: track changes in secure channels
::
?. bur +>
(veil:feel rex)
:: :: ++said:su
2016-10-05 03:29:25 +03:00
++ said :: track cert change
2016-10-28 08:19:01 +03:00
|= $: :: rex: ship whose will has changed
2016-09-28 04:39:03 +03:00
:: vie: change authorized by
:: lyf: modified/created version
:: gan: modification
::
rex/ship
vie/(unit (unit ship))
lyf/life
2016-10-04 03:36:11 +03:00
gan/growth
2016-09-28 04:39:03 +03:00
==
:: lip: this change as its own farm
::
=/ lip ^- farm
=- [[rex -] ~ ~]
2016-10-28 08:19:01 +03:00
^- will
2016-09-28 04:39:03 +03:00
=- [[lyf -] ~ ~]
^- cert
?- -.gan
::
2016-10-28 08:19:01 +03:00
:: add a new certificate to this will
2016-09-28 04:39:03 +03:00
:: {$step p/cert}
::
$step p.gan
::
:: add a new signature to this certificate
:: {$sign p/mind q/@}
::
$sign
:- dat:(~(got by (~(got by pug.urb) rex)) lyf)
=- [- ~ ~]
[who.p.gan lyf.p.gan q.gan]
==
::
:: if our subfarm may have changed, reset it
::
=. +>.$ ?. |(=(our rex) (~(has by cod.rel) rex)) +>.$
veal:feel
::
2016-10-28 08:19:01 +03:00
:: if a new deed, reset parent
2016-09-28 04:39:03 +03:00
::
=. dad.rel ?. &(=(our rex) ?=($step -.gan))
dad.rel
dad.doc.dat.p.gan
2016-09-28 04:39:03 +03:00
::
:: kick secure channels
::
=. +>.$ (veil:feel rex)
::
2016-10-28 08:19:01 +03:00
:: if we signed a will for someone else, send it home
2016-09-28 04:39:03 +03:00
::
?: &(=([~ ~] vie) !=(our rex))
(~(home fire lip) rex)
::
:: if first certificate, add to neighbor lists
::
=. +>.$ ?. &(?=($step -.gan) =(1 lyf)) +>.$
=. kyz.rel ?. =(our dad.doc.dat.p.gan) kyz.rel
(~(put in kyz.rel) rex)
=. pyr.rel ?. =((clan rex) (clan our)) pyr.rel
(~(put in pyr.rel) rex)
+>.$
::
2016-09-28 04:39:03 +03:00
:: propagate new data as appropriate
::
%+ ~(spam fire lip)
?~(vie ~ ?~(u.vie ~ `u.u.vie))
^- (list (set ship))
::
2016-10-28 08:19:01 +03:00
:: if our will has changed, send to parents and kids;
:: if a new deed has been added, also to pals
2016-09-28 04:39:03 +03:00
::
?: =(our rex)
:* [dad.rel ~ ~]
kyz.rel
?.(=(%step -.gan) ~ [pyr.rel ~])
2016-09-28 04:39:03 +03:00
==
::
:: forward star and galaxy updates to parents and kids
::
?. (lth rex 65.536)
~
:* [dad.rel ~ ~]
kyz.rel
2016-09-28 04:39:03 +03:00
~
2016-09-16 20:10:15 +03:00
==
2016-09-20 19:21:56 +03:00
--
2016-10-05 03:29:25 +03:00
:: :: ++ur
2016-10-26 02:20:08 +03:00
:::: ## absolute^heavy :: objective engine
2016-10-05 03:29:25 +03:00
:: ::::
++ ur
:: the ++ur core handles primary, absolute state.
:: it is the best reference for the semantics of
:: the urbit pki.
::
:: it is absolutely verboten to use [our] in ++ur.
::
=| hab/(list change)
2016-10-04 03:36:11 +03:00
=| state-absolute
2016-09-28 04:39:03 +03:00
::
2016-09-20 19:21:56 +03:00
:: hab: side effects, reversed
2016-09-28 04:39:03 +03:00
:: urb: all urbit state
2016-09-14 20:03:06 +03:00
::
2016-09-28 04:39:03 +03:00
=* urb -
2016-09-14 20:03:06 +03:00
|%
2016-09-28 04:39:03 +03:00
:: :: ++abet:ur
++ abet :: resolve
2016-10-04 03:36:11 +03:00
[(flop hab) `state-absolute`urb]
:: :: ++boss:ur
++ boss :: parent
|= who/ship
^- ship
-:(dads who)
2016-09-28 04:39:03 +03:00
::
++ dads :: ++dads:ur
|= who/ship :: lineage
^- (list ship)
=/ ryg (~(get by pug) who)
?~ ryg (saxo who)
=/ dad dad.doc.dat.q:(need ~(instant we u.ryg))
[who ?:(=(who dad) ~ $(who dad))]
::
++ lawn :: ++lawn:ur
|= {rex/ship pal/ship} :: debts, rex to pal
2016-10-04 03:36:11 +03:00
^- safe
2016-09-28 04:39:03 +03:00
(lawn:~(able ex rex) pal)
:: :: ++leak:ur
++ leak :: private key
|= rex/ship
^- (pair life ring)
=/ lyn lean:~(able ex rex)
[p.lyn (~(got by q.lyn) p.lyn)]
:: :: ++lean:ur
++ lean :: private keys
|= rex/ship
^- (pair life (map life ring))
lean:~(able ex rex)
2016-09-29 10:07:40 +03:00
:: :: ++make:ur
++ make :: initialize urbit
|= $: :: now: date
:: eny: entropy
:: gen: bootstrap ticket
:: nym: self-description
::
now/@da
eny/@e
gen/@pG
nym/arms
==
^+ +>
:: key: generated key
:: bul: initial bull
::
=/ key (ypt:scr:crypto (mix our %jael-make) gen)
2016-09-29 10:07:40 +03:00
=* doc `bull`[(sein our) & nym]
::
:: register generator as login secret
::
2016-10-01 03:17:33 +03:00
=. +>.$ abet:(deal:~(able ex our) our [[[%login [gen ~ ~]] ~ ~] ~])
2016-09-29 10:07:40 +03:00
::
:: initialize hierarchical property
::
=. +>.$
=- abet:(deal:~(able ex our) our - ~)
2016-10-04 03:36:11 +03:00
^- safe
%- intern:up
2016-10-04 03:36:11 +03:00
^- (list rite)
=/ mir (clan our)
?+ mir ~
$czar
:~ [%fungi [%usr 255] ~ ~]
2016-10-07 01:03:19 +03:00
[%hotel [[our 3] [1 255] ~ ~] ~ ~]
==
$king
:~ [%fungi [%upl 65.535] ~ ~]
2016-10-07 01:03:19 +03:00
[%hotel [[our 4] [1 65.535] ~ ~] ~ ~]
==
$duke
2016-10-07 01:03:19 +03:00
:~ [%hotel [[our 5] [1 0xffff.ffff] ~ ~] ~ ~]
==
==
::
:: create initial communication secrets
2016-09-29 10:07:40 +03:00
::
?: (lth our 256)
::
:: create galaxy with generator as seed
::
2016-09-29 10:07:40 +03:00
abet:(next:~(able ex our) key doc)
::
:: had: key handle
:: ryt: initial right
::
=/ key (ypt:scr:crypto (mix our %jael-make) gen)
2016-09-29 10:07:40 +03:00
=* had (shaf %hand key)
2016-10-04 03:36:11 +03:00
=* ryt `rite`[%urban [had (add ~m1 now) key] ~ ~]
2016-09-29 10:07:40 +03:00
::
:: register initial symmetric key from ticket
::
=. +>.$ abet:(hail:~(able ex (sein our)) our %& [ryt ~ ~])
::
:: create initial private key and certificate
::
abet:(next:~(able ex our) (mix eny key) doc)
2016-09-28 04:39:03 +03:00
:: :: ++meet:ur
++ meet :: calculate merge
|= $: :: vie: authenticated source
2016-09-14 20:03:06 +03:00
:: cod: transmitted certificates
::
2016-09-28 04:39:03 +03:00
vie/(unit (unit ship))
cod/farm
2016-09-14 20:03:06 +03:00
==
^+ +>
=+ lec=(~(tap by cod))
2016-09-20 19:21:56 +03:00
|- ^+ ..meet
?~ lec ..meet
%= $
lec t.lec
2016-09-28 04:39:03 +03:00
..meet abet:(grow:~(able ex p.i.lec) vie cod q.i.lec)
2016-09-20 19:21:56 +03:00
==
2016-09-28 04:39:03 +03:00
:: :: ++ex:ur
++ ex :: server engine
2016-09-20 19:21:56 +03:00
:: shy: private state
2016-10-28 08:19:01 +03:00
:: rug: domestic will
2016-09-13 03:24:21 +03:00
::
2016-10-04 03:36:11 +03:00
=| $: shy/(map ship safe)
2016-10-28 08:19:01 +03:00
rug/will
2016-09-20 19:21:56 +03:00
==
=| :: rex: server ship
2016-09-14 20:03:06 +03:00
::
rex/ship
2016-09-13 03:24:21 +03:00
|%
2016-09-28 04:39:03 +03:00
:: :: ++abet:ex:ur
2016-09-20 19:21:56 +03:00
++ abet :: resolve
%_ ..ex
pry (~(put by pry) rex shy)
pug (~(put by pug) rex rug)
==
2016-09-28 04:39:03 +03:00
:: :: ++able:ex:ur
2016-09-20 19:21:56 +03:00
++ able :: initialize
%_ .
2016-10-04 03:36:11 +03:00
shy (fall (~(get by pry) rex) *(map ship safe))
2016-10-28 08:19:01 +03:00
rug (fall (~(get by pug) rex) *will)
2016-09-20 19:21:56 +03:00
==
2016-09-28 04:39:03 +03:00
:: :: ++deal:ex:ur
++ deal :: alter rights
2016-10-04 03:36:11 +03:00
|= {pal/ship del/bump}
2016-09-28 04:39:03 +03:00
^+ +>
2016-10-04 03:36:11 +03:00
=/ gob (fall (~(get by shy) pal) *safe)
2016-09-28 04:39:03 +03:00
=* hep (~(update up gob) del)
2016-09-29 10:07:40 +03:00
%_ +>.$
shy (~(put by shy) pal hep)
hab [[%rite rex pal del] hab]
==
::
++ hail :: ++hail:ex:ur
2016-10-04 03:36:11 +03:00
|= {pal/ship rem/remote} :: report rights
2016-09-29 10:07:40 +03:00
^+ +>
2016-10-04 03:36:11 +03:00
=/ gob (fall (~(get by shy) pal) *safe)
=/ yer ^- (pair bump safe)
2016-09-29 10:07:40 +03:00
?- -.rem
$& [[p.rem ~] (~(splice up gob) p.rem)]
$| [(~(differ up gob) p.rem) p.rem]
==
%_ +>.$
shy (~(put by shy) pal q.yer)
hab [[%rite rex pal p.yer] hab]
==
2016-09-28 04:39:03 +03:00
:: :: ++lean:ex:ur
++ lean :: private keys
^- (pair life (map life ring))
::
:: lyf: latest life of
:: lab: promises by rex
:: par: promises by rex, to rex
:: jel: %jewel rights
::
=/ lyf `life`(need ~(current we (~(got by pug) rex)))
=* lab (~(got by pry) rex)
=* par (~(got by lab) rex)
2016-10-04 03:36:11 +03:00
=/ jel `rite`(need (~(expose up par) %jewel))
2016-09-28 04:39:03 +03:00
?> ?=($jewel -.jel)
[lyf p.jel]
:: :: ++lawn:ex:ur
++ lawn :: liabilities to pal
|= pal/ship
2016-10-04 03:36:11 +03:00
^- safe
2016-09-28 04:39:03 +03:00
=-(?~(- ~ u.-) (~(get by shy) pal))
2016-09-29 10:07:40 +03:00
:: :: ++next:ex:ur
++ next :: advance private key
|= {eny/@e doc/bull}
^+ +>
:: loy: live keypair
:: rig: private key
:: ryt: private key as right
:: pub: public key
:: cet: unsigned certificate
2016-10-28 08:19:01 +03:00
:: wyl: initial will
:: hec: initial will as farm
2016-09-29 10:07:40 +03:00
::
=/ loy (pit:nu:crub 512 eny)
=* rig sec:ex:loy
2016-10-04 03:36:11 +03:00
=* ryt `rite`[%jewel [1 rig] ~ ~]
2016-09-29 10:07:40 +03:00
=* pub pub:ex:loy
=* cet `cert`[[doc pub] ~]
2016-10-28 08:19:01 +03:00
=* wyl `will`[[1 cet] ~ ~]
2016-09-29 10:07:40 +03:00
=* hec `farm`[[rex wyl] ~ ~]
=. +>.$ (deal rex [[ryt ~ ~] ~])
=. ..ex (meet [~ ~] hec)
+>.$
2016-09-20 19:21:56 +03:00
:: :: grow:ex:ur
2016-10-28 08:19:01 +03:00
++ grow :: merge wills
2016-09-29 10:07:40 +03:00
|= $: :: vie: data source
2016-09-20 19:21:56 +03:00
:: cod: merge context
2016-10-28 08:19:01 +03:00
:: gur: input will
2016-09-20 19:21:56 +03:00
::
2016-09-28 04:39:03 +03:00
vie/(unit (unit ship))
cod/farm
2016-10-28 08:19:01 +03:00
gur/will
2016-09-20 19:21:56 +03:00
==
2016-09-28 04:39:03 +03:00
?: |(=(~ gur) =(gur rug)) ..grow
2016-09-20 19:21:56 +03:00
|^ ^+ ..grow
2016-09-21 05:56:32 +03:00
::
:: wap: ascending list of new certs
2016-10-28 08:19:01 +03:00
:: pre: previous deed
2016-09-21 05:56:32 +03:00
::
2016-10-07 00:56:24 +03:00
=/ wap ~(forward we gur)
?~ wap ..grow
2016-09-21 05:56:32 +03:00
=/ pre
2016-10-28 08:19:01 +03:00
^- (unit deed)
2016-10-07 00:56:24 +03:00
?~ (dec p.i.wap) ~
`dat:(~(got by rug) (dec p.i.wap))
2016-09-21 05:56:32 +03:00
::
:: merge each life
::
2016-09-20 19:21:56 +03:00
|- ^+ ..grow
2016-09-13 03:24:21 +03:00
::
2016-10-07 00:56:24 +03:00
:: hub: changes
2016-10-28 08:19:01 +03:00
:: lub: merged deed
2016-09-20 19:21:56 +03:00
::
2016-10-07 00:56:24 +03:00
=+ [hub lub]=[p q]:(grow-mate p.i.wap q.i.wap pre)
?~ t.wap ..grow
?> =(p.i.t.wap +(p.i.wap))
2016-09-20 19:21:56 +03:00
%= $
2016-09-28 04:39:03 +03:00
wap t.wap
2016-10-07 00:56:24 +03:00
pre `dat.lub
rug (~(put by rug) p.i.wap lub)
hab (weld (flop hub) hab)
2016-09-20 19:21:56 +03:00
==
:: :: grow-lick/ex:ur
++ grow-lick :: check signature
|= {pub/pass ash/@ val/@}
^- ?
=+ ver=(sure:as:(com:nu:crub pub) *code val)
?~ ver |
=(ash u.ver)
:: :: grow-like/ex:ur
++ grow-like :: verify signature
|= {myn/mind ash/@ val/@}
^- ?
=: ..able able(rex who.myn)
2016-10-28 08:19:01 +03:00
gur (fall (~(get by cod) who.myn) *will)
2016-09-20 19:21:56 +03:00
==
(grow-lick (grow-look lyf.myn) ash val)
:: :: grow-look/ex:ur
++ grow-look :: load public key
|= lyf/life
^- @
2016-09-13 03:24:21 +03:00
::
2016-09-20 19:21:56 +03:00
:: cascade search over old and new, new first
2016-09-13 03:24:21 +03:00
::
2016-09-20 19:21:56 +03:00
|^ %- (bond |.((need grow-look-find)))
grow-look-find(rug gur)
:: :: grow-look-find:ex:ur
++ grow-look-find ::
^- (unit @)
::
:: crash if this life is revoked
::
2016-09-28 04:39:03 +03:00
?< (~(has by rug) +(lyf))
%+ biff (~(get by rug) lyf)
|=(cert `pub.dat)
2016-09-20 19:21:56 +03:00
--
:: :: grow-mate/ex:ur
++ grow-mate :: merge lives
|= $: :: num: life we're merging
2016-10-28 08:19:01 +03:00
:: new: new deed
:: pre: previous deed
:: eld: old deed
2016-09-13 03:24:21 +03:00
::
num/@ud
2016-09-28 04:39:03 +03:00
new/cert
2016-10-28 08:19:01 +03:00
pre/(unit deed)
2016-09-13 03:24:21 +03:00
==
2016-09-28 04:39:03 +03:00
=+ :* eld=`(unit cert)`(~(get by rug) num)
2016-09-13 03:24:21 +03:00
==
2016-10-04 03:36:11 +03:00
^- (pair (list change) cert)
2016-09-13 03:24:21 +03:00
::
2016-09-21 05:56:32 +03:00
:: enforce artificial scarcity in lives
::
?> (lte num 9)
::
2016-09-13 03:24:21 +03:00
:: if no new information, do nothing
::
2016-09-21 05:56:32 +03:00
?: |(=(eld `new))
?> ?=(^ eld)
[~ u.eld]
2016-09-13 03:24:21 +03:00
::
2016-10-28 08:19:01 +03:00
:: ash: hash of deed content
2016-09-13 03:24:21 +03:00
:: def: our default parent
:: dad: our declared parent
:: mir: our rank
::
2016-09-21 05:56:32 +03:00
=/ ash (sham %urbit rex num dat.new)
2016-09-14 20:03:06 +03:00
=/ def (sein rex)
2016-09-21 05:56:32 +03:00
=* dad dad.doc.dat.new
2016-09-14 20:03:06 +03:00
=/ mir (clan rex)
2016-09-13 03:24:21 +03:00
?> ?: |(=(num 1) =(%earl mir) =(%pawn mir))
::
2016-09-20 19:21:56 +03:00
:: first parent must be default;
:: comets and moons may not migrate
2016-09-13 03:24:21 +03:00
::
=(def dad)
::
2016-09-20 19:21:56 +03:00
:: all others may migrate to parent of same rank
2016-09-13 03:24:21 +03:00
::
=((clan def) (clan dad))
::
2016-10-28 08:19:01 +03:00
:: if we have an old deed at this life, merge new signatures
2016-09-13 03:24:21 +03:00
::
2016-09-21 05:56:32 +03:00
?: ?=(^ eld)
2016-09-13 03:24:21 +03:00
::
2016-10-28 08:19:01 +03:00
:: deed data must be identical
2016-09-13 03:24:21 +03:00
::
2016-09-21 05:56:32 +03:00
?> =(dat.new dat.u.eld)
2016-09-13 03:24:21 +03:00
::
:: sow: all new signatures
::
2016-09-21 05:56:32 +03:00
=+ sow=`(list (trel ship life @))`(~(tap by syg.new))
2016-10-04 03:36:11 +03:00
|- ^- (pair (list change) cert)
2016-09-21 05:56:32 +03:00
?~ sow [~ u.eld]
2016-09-13 03:24:21 +03:00
::
:: mor: all further edits
:: och: old signature for this signer
::
=+ mor=$(sow t.sow)
2016-09-20 19:21:56 +03:00
=+ och=(~(get by syg.q.mor) p.i.sow)
2016-09-13 03:24:21 +03:00
::
2016-09-21 05:56:32 +03:00
:: ignore obsolete/equivalent signature
2016-09-13 03:24:21 +03:00
::
?. |(?=($~ och) (gth q.i.sow p.u.och))
mor
::
2016-09-20 19:21:56 +03:00
:: verify and merge added signature
2016-09-13 03:24:21 +03:00
::
2016-09-20 19:21:56 +03:00
?> (grow-like [p q]:i.sow ash r.i.sow)
:_ q.mor(syg (~(put by syg.q.mor) p.i.sow [q r]:i.sow))
:_ p.mor
2016-10-04 03:36:11 +03:00
`change`[%fact rex vie num `growth`[%sign [[p q] r]:i.sow]]
2016-09-13 03:24:21 +03:00
::
2016-10-28 08:19:01 +03:00
:: non-initial deeds must be signed by previous
2016-09-13 03:24:21 +03:00
::
?> ?| ?=($~ pre)
2016-09-21 05:56:32 +03:00
=+ laz=(~(got by syg.new) rex)
2016-09-13 03:24:21 +03:00
?> =(p.laz (dec num))
2016-09-20 19:21:56 +03:00
(grow-lick pub.u.pre ash q.laz)
2016-09-13 03:24:21 +03:00
==
::
2016-10-02 13:52:17 +03:00
:: initial fingerprint for galaxy is hardcoded
::
?> ?| !=(%czar mir)
!=(~ pre)
~| [%czar (shaf %zeno pub.dat.new) (zeno rex)]
=((shaf %zeno pub.dat.new) (zeno rex))
==
::
2016-09-13 03:24:21 +03:00
:: check the parent has signed, if necessary
::
?> ?| ::
:: no parent signature for existing, non-moon urbits
::
?& ?=(^ pre)
=(dad.doc.u.pre dad)
!=(%earl mir)
==
::
2016-10-02 13:52:17 +03:00
:: no parent signature for initial galaxy
2016-09-13 03:24:21 +03:00
::
?& =(%czar mir)
2016-10-02 13:52:17 +03:00
=(~ pre)
2016-09-13 03:24:21 +03:00
==
::
2016-10-28 08:19:01 +03:00
:: the deed is homemade or sent by owner
2016-09-13 03:24:21 +03:00
::
2016-09-28 04:39:03 +03:00
&(?=(^ vie) |(?=($~ u.vie) =(u.u.vie rex)))
2016-09-13 03:24:21 +03:00
::
:: check valid parent signature
::
2016-09-21 05:56:32 +03:00
=+ par=(~(got by syg.new) dad)
2016-09-20 19:21:56 +03:00
(grow-like [dad p.par] ash q.par)
2016-09-13 03:24:21 +03:00
==
2016-09-20 19:21:56 +03:00
=- [[%fact rex p.- num %step q.-]~ q.-]
2016-09-28 04:39:03 +03:00
^- (pair (unit (unit ship)) cert)
2016-09-13 03:24:21 +03:00
::
2016-10-28 08:19:01 +03:00
:: the new deed is complete; report it
2016-09-13 03:24:21 +03:00
::
2016-09-21 05:56:32 +03:00
?: (~(has by syg.new) dad)
2016-09-28 04:39:03 +03:00
[vie new]
2016-09-20 19:21:56 +03:00
::
2016-10-28 08:19:01 +03:00
:: the new deed needs a parent signature; try to add it
2016-09-20 19:21:56 +03:00
::
2016-09-28 04:39:03 +03:00
:- [~ ~]
2016-09-13 03:24:21 +03:00
::
2016-09-28 04:39:03 +03:00
:: pev: life and ring of parent
2016-09-13 03:24:21 +03:00
:: val: new signature
::
2016-09-28 04:39:03 +03:00
=/ pev (leak dad)
=* val (sign:as:(nol:nu:crub q.pev) *@ ash)
new(syg (~(put by syg.new) dad [p.pev val]))
-- --
-- --
2016-09-13 03:24:21 +03:00
:: ::::
2016-10-26 02:20:08 +03:00
:::: # vane :: interface
2016-09-13 03:24:21 +03:00
:: ::::
::
:: lex: all durable %jael state
::
2016-10-04 03:36:11 +03:00
=| lex/state
2016-09-13 03:24:21 +03:00
|= $: ::
:: now: current time
:: eny: unique entropy
:: ski: namespace resolver
::
now/@da
eny/@e
ski/sley
==
|%
2016-09-28 04:39:03 +03:00
:: :: ++call
2016-09-13 03:24:21 +03:00
++ call :: request
|= $: :: hen: cause of this event
:: hic: event data
::
hen/duct
2016-10-04 03:36:11 +03:00
hic/(hypo (hobo task))
2016-09-13 03:24:21 +03:00
==
2016-10-04 03:36:11 +03:00
=> .(q.hic ?.(?=($soft -.q.hic) q.hic ((hard task) p.q.hic)))
^- {p/(list move) q/_..^$}
2016-09-20 19:21:56 +03:00
=^ did lex abet:~(call of [now eny] lex)
2016-09-13 03:24:21 +03:00
[did ..^$]
2016-09-28 04:39:03 +03:00
:: :: ++doze
2016-09-13 03:24:21 +03:00
++ doze :: await
|= $: :: now: current time
:: hen: cause (XX why we need this?)
::
now/@da
hen/duct
==
^- (unit @da)
~
2016-09-28 04:39:03 +03:00
:: :: ++load
2016-09-13 03:24:21 +03:00
++ load :: upgrade
|= $: :: old: previous state
::
2016-10-04 03:36:11 +03:00
old/state
2016-09-13 03:24:21 +03:00
==
^+ ..^$
..^$(lex old)
2016-09-28 04:39:03 +03:00
:: :: ++scry
2016-09-13 03:24:21 +03:00
++ scry :: inspect
|= $: :: fur: event security
:: ren: access mode
:: why: owner
:: syd: desk (branch)
:: lot: case (version)
:: tyl: rest of path
::
fur/(unit (set monk))
ren/@tas
why/shop
syd/desk
lot/coin
tyl/spur
==
^- (unit (unit cage))
2016-09-29 10:07:40 +03:00
~
2016-09-28 04:39:03 +03:00
:: :: ++stay
2016-09-13 03:24:21 +03:00
++ stay :: preserve
lex
2016-09-28 04:39:03 +03:00
:: :: ++take
2016-09-13 03:24:21 +03:00
++ take :: accept
|= $: :: tea: order
:: hen: cause
:: hin: result
::
tea/wire
hen/duct
hin/(hypo sign-arvo)
==
2016-10-04 03:36:11 +03:00
^- {p/(list move) q/_..^$}
2016-09-13 03:24:21 +03:00
[~ ..^$]
2016-04-08 20:08:05 +03:00
--