urbit/arvo/jael.hoon

979 lines
33 KiB
Plaintext
Raw Normal View History

2016-09-13 03:24:21 +03:00
!: :: /van/jael
2016-09-14 20:03:06 +03:00
:: :: %orthodox
2016-09-13 03:24:21 +03:00
!? 150
:: ::::
2016-09-15 01:57:32 +03:00
:::: # 1 :: structures
2016-09-13 03:24:21 +03:00
:: ::::
2016-09-15 20:38:47 +03:00
|= pit/vase
2016-09-13 03:24:21 +03:00
=> |%
2016-08-08 00:47:51 +03:00
++ jael-state :: all crypto state
$: ver/$0 :: %jael version
2016-09-15 20:38:47 +03:00
nav/jael-objective :: all objective state
nix/jael-subjective :: all subjective state
2016-04-08 20:08:05 +03:00
== ::
2016-09-15 20:38:47 +03:00
++ jael-subjective :: indexes / observers
$: sub/jael-subjective-urbit :: urbit subjective
2016-09-16 20:10:15 +03:00
sew/jael-subjective-web :: web subjective
2016-09-15 20:38:47 +03:00
== ::
2016-09-16 20:10:15 +03:00
++ jael-subjective-urbit :: urbit metadata
2016-09-15 20:38:47 +03:00
$: $= dev :: indexes
$: dad/ship :: our parent
2016-09-17 01:52:23 +03:00
pyr/(set ship) :: peers
2016-09-16 20:10:15 +03:00
kid/(set ship) :: children
2016-09-15 20:38:47 +03:00
ast/(map ship jael-purse) :: assets from
== ::
$= vew :: all trackers
$: lat/(set duct) :: rights
hin/(set duct) :: channel, all
yon/(map ship (set duct)) :: channel by ship
== == ::
2016-09-16 20:10:15 +03:00
++ jael-subjective-web :: web metadata
$~ ::
2016-08-31 01:23:00 +03:00
++ jael-objective :: all universal state
$: urb/jael-urbit :: all urbit state
2016-09-13 03:24:21 +03:00
web/(map site jael-web-domain) :: all web state
2016-04-08 20:08:05 +03:00
== ::
2016-09-06 20:56:36 +03:00
++ jael-web-domain :: per foreign app
$: sec/(map @t jael-web-app) :: client per api key
2016-09-15 20:38:47 +03:00
usr/(map @ta (unit @t)) :: user/password
2016-04-08 20:08:05 +03:00
== ::
2016-09-06 20:56:36 +03:00
++ jael-web-app :: local app
2016-08-31 01:23:00 +03:00
$: key/(unit (pair @da @)) :: API key
2016-09-06 20:56:36 +03:00
tok/(map @t (pair @da @)) :: token by username
2016-04-08 20:08:05 +03:00
== ::
2016-09-06 20:56:36 +03:00
++ jael-web-user :: per-user secrets
2016-08-31 01:23:00 +03:00
$: pas/(unit @t) :: password
2016-09-06 20:56:36 +03:00
dey/(unit @t) :: display name
2016-08-25 08:05:26 +03:00
== ::
2016-08-31 01:23:00 +03:00
++ jael-urbit :: objective urbit
2016-09-12 04:07:23 +03:00
$: pug/gree :: all public state
2016-09-15 20:38:47 +03:00
pry/(map ship (map ship jael-purse)) :: all private state
2016-09-06 20:56:36 +03:00
== ::
++ jael-friend :: relationship
2016-09-07 20:33:42 +03:00
$: luf/(unit life) :: life as known to
2016-09-15 01:57:32 +03:00
lab/jael-purse :: promises to
2016-08-08 00:47:51 +03:00
== ::
2016-09-13 03:24:21 +03:00
++ jael-gift :: output
2016-09-15 20:38:47 +03:00
$? {$cash jael-report-cash} :: account report
{$clue jael-report-clue} :: channel dump
2016-09-13 03:24:21 +03:00
{$paid jael-report-paid} :: asset update
{$self jael-report-self} :: self dump
== ::
2016-08-31 01:23:00 +03:00
++ jael-right :: urbit commitment
2016-09-15 20:38:47 +03:00
$% {$email p/(set @ta)} :: email addresses
2016-09-12 04:07:23 +03:00
{$final p/(map ship @uvG)} :: ticketed ships
2016-08-31 01:23:00 +03:00
{$fungi p/(map term @ud)} :: fungibles
2016-09-12 04:07:23 +03:00
{$guest $~} :: refugee visa
2016-09-15 20:38:47 +03:00
{$hotel p/pile} :: reserved block
{$jewel p/(map life ring)} :: private keyring
2016-09-16 20:10:15 +03:00
{$lived p/life} :: PKI knowledge
{$noble p/(map hand (pair @da code))} :: symmetric keys
2016-08-31 01:23:00 +03:00
== ::
2016-09-15 01:57:32 +03:00
++ jael-purse :: rights set
(nap jael-right) ::
:: ::
++ jael-delta :: rights change
$: mor/jael-purse :: gain rights
les/jael-purse :: lose rights
== ::
2016-08-31 01:23:00 +03:00
++ jael-task :: operations on
2016-09-15 01:57:32 +03:00
$% {$give p/ship q/jael-purse} :: add rights
2016-08-31 01:23:00 +03:00
{$line p/ship q/@da r/code} :: outbound symkey
{$link p/ship q/@da r/code} :: inbound symkey
2016-09-12 04:07:23 +03:00
{$meet p/ship q/gree} :: integrate pki from
2016-09-16 20:10:15 +03:00
{$nuke ~} :: cancel as tracker
2016-08-31 01:23:00 +03:00
{$over p/ship q/jael-task} :: mirror operation
2016-09-06 20:56:36 +03:00
{$pall p/ship q/life} :: our life acked
2016-09-14 20:03:06 +03:00
{$ping p/ship} :: empty contact
{$step p/lamp q/ring} :: update private key
2016-09-15 01:57:32 +03:00
{$take p/ship q/jael-purse} :: subtract rights
2016-09-15 20:38:47 +03:00
{$vest $~} :: watch accounts
{$view p/ship} :: watch channel
2016-09-13 03:24:21 +03:00
{$vile p/site} :: watch website
2016-09-15 20:38:47 +03:00
{$vine $~} :: watch all changes
2016-08-31 01:23:00 +03:00
{$west p/ship q/path r/*} :: remote request
2016-09-13 03:24:21 +03:00
{$wink p/site q/@t r/(unit bill)} :: set web API key
{$wish p/site q/@t r/(unit @t)} :: set web login
{$wonk p/site q/@t r/@t s/(unit bill)} :: set web API token
2016-09-06 20:56:36 +03:00
== ::
++ jael-report-them :: report on neighbor
$: gur/grue :: certificate
2016-09-15 01:57:32 +03:00
lab/jael-purse :: our promises to
own/jael-purse :: our promises from
2016-09-06 20:56:36 +03:00
== ::
++ jael-report-self :: report on self
$: gur/grue :: certificate
war/(map life ring) :: private keys
== ::
++ jael-report-cash :: neighbors/assets
2016-09-15 01:57:32 +03:00
$: has/(map ship jael-purse) ::
2016-08-31 01:23:00 +03:00
== ::
2016-09-06 20:56:36 +03:00
++ jael-report-paid :: asset diff
2016-09-15 01:57:32 +03:00
$: dif/(list (trel ship ? jael-purse)) :: who, +/-, what
2016-09-06 20:56:36 +03:00
== ::
2016-09-12 04:07:23 +03:00
++ jael-note :: out request $->
$% {$x $mess p/ship q/path r/*} :: send message
== ::
2016-08-31 01:23:00 +03:00
++ jael-message :: p2p message
2016-09-15 01:57:32 +03:00
$% {$hail p/jael-purse} :: reset rights
2016-09-12 04:07:23 +03:00
{$ping p/gree} :: propagate
2016-08-31 01:23:00 +03:00
== ::
2016-09-16 20:10:15 +03:00
++ jael-edit-fact :: certificate change
$: rex/ship :: owner
via/ship :: propagated from
lyf/life :: deed modified
way/?($new $old) :: new/existing deed
gur/gree :: pedigree
== ::
++ jael-edit-rite :: rights change
$: rex/ship :: server
pal/ship :: client
del/jael-delta :: change
== ::
++ jael-edit :: urbit change
2016-09-17 01:52:23 +03:00
$% $: $fact :: certificate change
rex/ship :: owner
via/ship :: propagated from
lyf/life :: deed modified
way/?($new $old) :: extend/improve
gur/gree :: pedigree
== ::
$: $rite :: rights change
rex/ship :: issuer
pal/ship :: issued to
del/jael-delta :: change
== ::
2016-09-16 20:10:15 +03:00
== ::
2016-09-13 03:24:21 +03:00
++ jael-edit :: pki change
2016-09-15 20:38:47 +03:00
$: $= why :: cause of change
$? $hear :: external source
$make :: internal source
== ::
gut/jael-change :: new information
== ::
2016-09-15 01:57:32 +03:00
++ jael-change :: pki change
2016-09-15 20:38:47 +03:00
$% {$sent p/ship q/ship r/jael-delta)} :: rights from/to
2016-09-16 20:10:15 +03:00
{$step p/ship q/life r/gree} :: new deed
{$sure p/ship q/life r/gree} :: new signature
== ::
2016-09-13 03:24:21 +03:00
++ jael-move :: output
{p/duct q/(wind jael-note jael-gift)}
--
:: ::::
2016-09-15 01:57:32 +03:00
:::: # 2 :: static data
2016-09-13 03:24:21 +03:00
:: ::::
=> |%
2016-09-15 20:38:47 +03:00
:: :: zeno
2016-09-13 03:24:21 +03:00
++ zeno :: boot signatures
|= :: who: galaxy (0-255)
::
who/ship
^- pass
!!
--
:: ::::
2016-09-15 20:38:47 +03:00
:::: # 3 :: stateless functions
:: ::::
=> |%
:: :: chop:of
++ chop :: subtract rights
|= {les/jael-purse lab/jael-purse}
^- jael-purse
!!
:: :: clip:of
++ clip :: construct diff
|= {nex/jael-purse lab/jael-purse}
^- jael-delta
!!
:: :: comb:of
++ comb :: combine
|= {mor/jael-purse lab/jael-purse}
!!
:: :: come:of
++ come :: apply rights delta
|= {del/jal-delta lab/jael-purse}
^- jael-purse
(chop les.del (comb mor.del lab))
:: ::::
:::: # 4 :: reactors
2016-09-13 03:24:21 +03:00
:: ::::
=> |%
2016-09-15 20:38:47 +03:00
:: ## 4.a :: of
2016-09-14 20:03:06 +03:00
++ of :: general reactor
2016-09-15 01:57:32 +03:00
=| $: :: sys: system context ::::
2016-09-14 20:03:06 +03:00
::
^= sys
$: :: 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-09-13 03:24:21 +03:00
jael-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-13 03:24:21 +03:00
=* lex ->+
=| moz/(list jael-move)
2016-09-12 04:07:23 +03:00
|%
2016-09-14 20:03:06 +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-09-14 20:03:06 +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
tac/jael-task
2016-09-12 04:07:23 +03:00
==
2016-09-13 03:24:21 +03:00
^+ +>
?- -.tac
::
2016-09-13 03:24:21 +03:00
:: add rights
2016-09-15 01:57:32 +03:00
:: {$give p/ship q/jael-purse)}
::
2016-09-13 19:41:54 +03:00
$give
2016-09-15 20:38:47 +03:00
(cure abet:(~(give ur urb.nav) our [p q]:tac))
2016-09-12 04:07:23 +03:00
::
2016-09-13 03:24:21 +03:00
:: outbound symmetric key
:: {$link p/ship q/@da r/code}
2016-09-12 04:07:23 +03:00
::
2016-09-13 03:24:21 +03:00
$link
=* ryt [%entry [[(shaf %hand r.tac) q.tac r.tac] ~ ~]]
2016-09-14 20:03:06 +03:00
%- curd
abet:(~(give ur urb.nav) our p.tac ryt)
2016-09-08 19:29:38 +03:00
::
2016-09-13 03:24:21 +03:00
:: inbound symmetric key
:: {$line p/ship q/@da r/code}
2016-09-08 19:29:38 +03:00
::
2016-09-13 03:24:21 +03:00
$line
2016-09-13 19:41:54 +03:00
=* ryt [%entry [[(shaf %hand r.tac) q.tac r.tac] ~ ~]]
2016-09-14 20:03:06 +03:00
%- curd
abet:(~(give ur sys urb.nav) p.tac our ryt)
::
2016-09-13 03:24:21 +03:00
:: public-key update
:: {$meet p/ship q/gree}
2016-09-08 19:29:38 +03:00
::
2016-09-13 03:24:21 +03:00
$meet
2016-09-15 20:38:47 +03:00
(cure abet:(~(meet ur sys urb.nav) p.tac q.tac))
::
2016-09-13 19:41:54 +03:00
:: learn as other ship
2016-09-13 03:24:21 +03:00
:: {$over p/ship q/jael-task}
::
2016-09-13 03:24:21 +03:00
$over
$(our p.tac, tac q.tac)
::
2016-09-13 19:41:54 +03:00
:: remote version acknowledgment
2016-09-13 03:24:21 +03:00
:: {$pall p/ship q/life}
::
2016-09-13 03:24:21 +03:00
$pall
2016-09-15 20:38:47 +03:00
(cure abet:(~(pall ur sys urb.nav) our p.tac q.tac))
2016-09-08 19:29:38 +03:00
::
2016-09-14 20:03:06 +03:00
:: request incidental contact
:: {$ping p/ship}
::
$ping
2016-09-15 20:38:47 +03:00
!!
:: (cure [%ping p.tac ~]~)
2016-09-14 20:03:06 +03:00
::
2016-09-13 03:24:21 +03:00
:: extend our certificate with a new private key
:: {$step p/lamp}
2016-09-08 19:29:38 +03:00
::
2016-09-13 03:24:21 +03:00
$step
2016-09-15 20:38:47 +03:00
(cure abet:(~(step ur sys urb.nav) our p.tac))
::
2016-09-13 03:24:21 +03:00
:: remove rights
2016-09-15 01:57:32 +03:00
:: {$take p/ship q/jael-purse}
2016-09-13 03:24:21 +03:00
::
$take
2016-09-15 20:38:47 +03:00
(cure abet:(~(give ur sys urb.nav) our [p q]:tac))
::
2016-09-13 03:24:21 +03:00
:: monitor self
:: {$vain $~}
::
2016-09-13 03:24:21 +03:00
$vain
2016-09-15 20:38:47 +03:00
=/
::
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-07 20:36:06 +03:00
::
2016-09-13 03:24:21 +03:00
:: monitor website
:: {$vile p/site}
2016-09-08 19:29:38 +03:00
::
2016-09-13 03:24:21 +03:00
$vile
!!
2016-09-08 19:29:38 +03:00
::
2016-09-13 03:24:21 +03:00
:: execute remote request
:: {$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)
=+ mes=((hard jael-message) r.tac)
?- -.mes
::
:: reset remote rights
2016-09-15 01:57:32 +03:00
:: {$hail p/jael-purse}
2016-09-14 20:03:06 +03:00
::
$hail
2016-09-15 20:38:47 +03:00
(cure (~(hail ur urb.nav) p.tac our p.mes))
2016-09-14 20:03:06 +03:00
::
:: share certificates
:: {$ping p/gree}
::
$ping
2016-09-15 20:38:47 +03:00
(cure (~(meet ur urb.nav) p.tac p.mes))
2016-09-14 20:03:06 +03:00
==
2016-09-08 19:29:38 +03:00
::
2016-09-13 03:24:21 +03:00
:: set/clear web API key
:: {$wink p/site q/@t r/(unit bill)}
2016-09-08 19:29:38 +03:00
::
2016-09-13 03:24:21 +03:00
$wink
!!
2016-09-06 20:56:36 +03:00
::
2016-09-13 03:24:21 +03:00
:: set/clear web password
:: {$wish p/site q/@t r/(unit @t)}
::
$wish
2016-09-06 20:56:36 +03:00
!!
2016-09-07 20:33:42 +03:00
::
2016-09-13 03:24:21 +03:00
:: set/clear web API token
:: {$wonk p/site q/@t r/@t s/(unit bill)}
::
$wonk
!!
2016-09-13 03:24:21 +03:00
==
2016-09-14 20:03:06 +03:00
:: :: curd:of
2016-09-15 20:38:47 +03:00
++ curd :: subjective moves
|= {moz/(list move) urb/jael-subjective-urbit}
+>(urb.nix urb, moz (weld (flop moz) ^moz))
2016-09-14 20:03:06 +03:00
:: :: cure:of
2016-09-15 20:38:47 +03:00
++ cure :: objective edits
|= {hab/(list jael-edit) urb/jael-urbit}
2016-09-14 20:03:06 +03:00
^+ +>
2016-09-16 20:10:15 +03:00
(curd(urb urb.nav) abet:(~(apex su sys urb.nav urb.nix) hab))
2016-09-14 20:03:06 +03:00
--
2016-09-15 20:38:47 +03:00
:: ## 4.b :: su
++ su :: subjective reactor
2016-09-16 20:10:15 +03:00
=| $: :: sys: system context ::::
::
^= sys
$: :: now: current time
:: eny: unique entropy
::
now/@da
eny/@e
==
2016-09-15 20:38:47 +03:00
urb/jael-urbit
jael-subjective-urbit
==
2016-09-16 20:10:15 +03:00
:: urb: objective urbit state
:: sub: subjective urbit state
:: moz: moves in reverse order
::
=* sub ->+
=| moz/(list move)
2016-09-15 20:38:47 +03:00
|%
:: :: abet:su
++ abet :: resolve
[(flop moz) urb]
:: :: apex:su
++ apex :: apply changes
|= hab/(list jael-edit)
?~ hab +>
$(hab t.hab, +> (repo:(echo i.hab) i.hab))
:: :: cart:su
++ cart :: ping ship
|= {her/ship gur/gree}
^+ +>
+>(moz :_(moz [%pass %x ~ %mess /x %ping gur]))
:: :: carp:su
2016-09-16 20:10:15 +03:00
++ carp :: ping all in set
2016-09-15 20:38:47 +03:00
|= {all/(set ship) gur/gree}
=+ lal/(~(tap by all))
|- ^+ +>.^$
?~ lal +>.^$
$(lal t.lal, +>.^$ (cart i.lal gur))
2016-09-16 20:10:15 +03:00
:: :: echo:su
++ echo ::
|= led/jael-edit
2016-09-15 20:38:47 +03:00
^+ +>
2016-09-16 20:10:15 +03:00
?- -.led
2016-09-15 20:38:47 +03:00
::
2016-09-16 20:10:15 +03:00
:: new certificate state
:: {$fact rex/ship via/ship lyf/life way/?($new $old) gur/gree}
2016-09-15 20:38:47 +03:00
::
2016-09-17 01:52:23 +03:00
$fact
2016-09-16 20:10:15 +03:00
::
:: ignore changes to existing deeds
::
2016-09-17 01:52:23 +03:00
?. =(%new way.led) +>
=+ dad=dad.doc.dat:(~(got by q:(~(got by gur.led) rex.led)) lyf.led)
2016-09-16 20:10:15 +03:00
::
:: if self update, update cached parent state
::
2016-09-17 01:52:23 +03:00
?: =(our rex.led)
2016-09-16 20:10:15 +03:00
+>.$(dad dad)
::
:: if first meeting, add to child/peer sets
::
2016-09-17 01:52:23 +03:00
?: =(1 lyf.led) +>
2016-09-16 20:10:15 +03:00
?: =(our dad)
2016-09-17 01:52:23 +03:00
+>.$(kid (~(put in kid) rex.led))
?. =((clan rex.led) (clan our))
2016-09-16 20:10:15 +03:00
+>.$
2016-09-17 01:52:23 +03:00
+>.$(pyr (~(put in pyr) rex.led))
2016-09-16 20:10:15 +03:00
::
:: new rights
2016-09-17 01:52:23 +03:00
:: {$rite rex/ship pal/ship del/jael-delta}
2016-09-16 20:10:15 +03:00
::
$send
::
:: record promises made to us
::
2016-09-17 01:52:23 +03:00
?. =(our pal.led) +>.$
=* haz (fall (~(get by ast) rex.led) *jael-purse)
+>.$(ast (~(put by ast) (come del.led haz)))
2016-09-16 20:10:15 +03:00
==
:: :: repo:su
++ repo :: report change
|= led/jael-edit
^+ +>
?- -.led
::
:: new certificate state
:: {$fact rex/ship via/ship lyf/life way/?($new $old) gur/gree}
::
$fact
2016-09-15 20:38:47 +03:00
!!
::
2016-09-16 20:10:15 +03:00
:: new rights
:: {$paid p/ship q/jael-delta}
::
$paid
+>
2016-09-15 20:38:47 +03:00
==
2016-09-16 20:10:15 +03:00
:: :: prop:su
++ prop :: propagate pki change
|= led/jael-edit
^+ +>
2016-09-17 01:52:23 +03:00
?. ?=($fact -.led) +>
2016-09-16 20:10:15 +03:00
::
2016-09-17 01:52:23 +03:00
:: if we made a cert for someone else, send it back
2016-09-16 20:10:15 +03:00
::
2016-09-17 01:52:23 +03:00
?: &(=(our via.led) !=(our rex.led))
(cart rex.led gur.led)
+>
2016-09-16 20:10:15 +03:00
::
:: new rights
:: {$paid p/ship q/jael-delta}
::
$paid
+>
==
2016-09-17 01:52:23 +03:00
--
2016-09-15 20:38:47 +03:00
:: ## 4.c :: ur
2016-09-14 20:03:06 +03:00
++ ur :: urbit reactor
2016-09-15 20:38:47 +03:00
=| $: :: sys: system context ::::
2016-09-14 20:03:06 +03:00
::
^= sys
$: :: now: current time
:: eny: unique entropy
::
now/@da
eny/@e
==
:: all vane state
::
jael-urbit
==
:: urb: all urbit state
:: mer: merge state
:: via: authenticated source
:: cod: propagating certificates
:: hab: side effects
::
=* urb ->+
=| $: mer/(unit {via/@p cod/gree})
hab/(list jael-effect)
==
|%
:: :: abet:ur
++ abet :: resolve
[(flop hab) urb]
:: :: like:ur
++ like :: verify signature
|= {myn/mind ash/@ val/@}
^- ?
::
:: XX crypto api needs some adjusting
::
?> .= ash
%- need
=< sure:as
%. [*code val]
(com:nu:crub (look myn))
&
:: :: look:ur
++ look :: get public key
|= myn/mind
(look:(from who.myn) lyf.myn)
:: :: mean:ur
++ mean :: apply merge
|= {why/?($hear $make) gut/jael-change}
2016-09-13 03:24:21 +03:00
^+ +>
2016-09-15 01:57:32 +03:00
=. +> (
2016-09-14 20:03:06 +03:00
?- -.gut
::
:: learn new signature on existing deed
:: {$sure p/ship q/life r/mind s/@}
::
$sure
2016-09-15 01:57:32 +03:00
?: =($hear why)
(emit %kick p.gut)
(emil [%kick p.gut] [%kids p.gut] ~)
2016-09-14 20:03:06 +03:00
::
:: learn new deed
:: {$step p/ship q/life r/lace}
::
$step
?: =($hear why)
2016-09-15 01:57:32 +03:00
(emit %kick p.gut)
(emil [%kick p.gut]
2016-09-14 20:03:06 +03:00
==
== ::
$sure
?: =($make
==
$hear
::
:: map from edits to
::
2016-09-13 03:24:21 +03:00
!!
2016-09-14 20:03:06 +03:00
:: :: meet:ur
++ meet :: calculate merge
|= $: :: via: authenticated source
:: cod: transmitted certificates
::
via/@p
cod/gree
==
^+ +>
=- :: map edits to effects
::
|- ^+ +>.^$
=. mer `[via cod]
=+ lec=(~(tap by cod))
2016-09-13 03:24:21 +03:00
::
2016-09-14 20:03:06 +03:00
:: check new certs ship by ship
2016-09-13 03:24:21 +03:00
::
2016-09-14 20:03:06 +03:00
|- ^- fex/(list jael-edit)
?~ lec ~
(weld (boat:(from p.i.lec) q.i.lec) $(lec t.lec))
:: :: from:ur
++ from :: server reactor
|= :: rex: server ship
::
rex/ship
::
:: shy: private state
:: rug: public state
::
=+ :+ shy/(fall (~(get by pry) rex) *jael-ship)
rug/(fall (~(get by pug) rex) *grue)
gur/(fall ?~(mer ~ (~(get by cod.u.mer) rex) *grue))
2016-09-13 03:24:21 +03:00
|%
2016-09-14 20:03:06 +03:00
:: :: abet:from:ur
++ abet :: resolve
%_(..from pry (~(put by pry) rex shy))
:: ::
++ look :: get public key
|= lyf/life
^- @
2016-09-13 03:24:21 +03:00
::
2016-09-14 20:03:06 +03:00
:: first galaxy key is hardcoded
2016-09-13 03:24:21 +03:00
::
2016-09-14 20:03:06 +03:00
?: &((lth rex 256) =(1 lyf))
(zeno rex)
::
:: cascade search over old and new, new first
::
?~ mer (need find)
|^ ((bond |.((need find))) find(rug gur))
++ find
^- (unit @)
2016-09-13 03:24:21 +03:00
::
2016-09-14 20:03:06 +03:00
:: crash if this life is revoked
2016-09-13 03:24:21 +03:00
::
2016-09-14 20:03:06 +03:00
?> =(p.rug lyf)
%+ biff (~(get by q.rug) lyf)
|=(lace `pub.dat)
2016-09-13 03:24:21 +03:00
--
2016-09-14 20:03:06 +03:00
::
++ boat
?> mer
=+ gur=((~(get by cod.u.mer) *grue)
2016-09-15 01:57:32 +03:00
::
2016-09-14 20:03:06 +03:00
++ bonk
--
:: :: unto:from:ur:of
++ unto :: client reactor
|= :: pal: client ship
2016-09-13 03:24:21 +03:00
::
2016-09-14 20:03:06 +03:00
pal/ship
::
:: cly: client state
::
=+ (fall (~(get by rel) pal) *jael-friend)
=* cly -
|%
:: :: abet:unto:from:ur:
++ abet :: resolve
^+ ..unto
..unto(rel (~(put by rel) pal cly))
:: :: give:unto:from:ur:
++ give :: credit
2016-09-15 01:57:32 +03:00
|= lab/jael-purse
2016-09-14 20:03:06 +03:00
^+ +>
!!
--
--
2016-09-13 03:24:21 +03:00
:: ::
++ boat :: merge ships
|= $: :: who: this ship
:: gur: new will for this ship
::
2016-09-14 20:03:06 +03:00
rex/ship
2016-09-13 03:24:21 +03:00
gur/grue
==
^- (list jael-edit)
::
:: rug: old will for this ship
::
2016-09-14 20:03:06 +03:00
=+ rug=(fall (~(get by pug) rex) *grue)
2016-09-13 03:24:21 +03:00
?: =(gur rug) ~
=+ :* ::
:: num: life counter
:: end: last life in old or new ship
::
num=`life`1
end=(max p.gur p.rug)
==
=| $: :: pre: previous deed
:: fex: edits in reverse order
::
pre/(unit lama)
fex/(list jael-edit)
==
|- ^+ fex
::
:: merge all lives in :%
::
?: (gth num end)
(flop fex)
::
:: lub: deed merge for this life
::
=+ ^= lub
%- bonk
2016-09-14 20:03:06 +03:00
:* rex
2016-09-13 03:24:21 +03:00
num
pre
(~(get by q.rug) num)
(~(get by q.gur) num)
==
%= $
num +(num)
pre `p.lub
fex (weld (flop q.lub) fex)
==
:: ::
++ bonk :: merge lives
2016-09-14 20:03:06 +03:00
|= $: :: rex: ship we're merging
2016-09-13 03:24:21 +03:00
:: num: life we're merging
:: pre: previous deed
:: lod: old deed
:: wan: new deed
::
2016-09-14 20:03:06 +03:00
rex/ship
2016-09-13 03:24:21 +03:00
num/@ud
pre/(unit lama)
lod/(unit lace)
wan/(unit lace)
==
^- $: :: p: next previous deed
:: q: edits in order
::
p/lama
q/(list jael-edit)
==
::
:: if no new information, do nothing
::
?: |(?=($~ wan) =(wan lod))
?> ?=(^ lod)
[dat.u.lod ~]
::
:: ash: hash of deed content
:: def: our default parent
:: dad: our declared parent
:: mir: our rank
::
=/ ash (sham dat.u.wan)
2016-09-14 20:03:06 +03:00
=/ def (sein rex)
2016-09-13 03:24:21 +03:00
=* dad dad.doc.dat.u.wan
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))
::
:: comets and moons must stay with default parent
::
=(def dad)
::
:: other ships may migrate to parent of same rank
::
=((clan def) (clan dad))
::
:: if we have an old deed at this life, merge them
::
?: ?=(^ lod)
::
:: use the old deed as the next previous
::
:- dat.u.lod
::
:: deed data must be identical
::
?> =(dat.u.wan dat.u.lod)
::
:: sow: all new signatures
::
=+ sow=`(list (trel ship life @))`(~(tap by syg.u.wan))
|- ^- (list jael-edit)
?~ sow ~
::
:: mor: all further edits
:: och: old signature for this signer
::
=+ mor=$(sow t.sow)
=+ och=(~(get by syg.u.lod) p.i.sow)
::
:: ignore obsolete or equal signature
::
?. |(?=($~ och) (gth q.i.sow p.u.och))
mor
::
:: check and merge new, or newer, signature
::
2016-09-14 20:03:06 +03:00
?> (like [p q]:i.sow ash r.i.sow)
:_(mor [%make %sure rex num [p q]:i.sow r.i.sow])
2016-09-13 03:24:21 +03:00
::
:: use the new deed as the next previous
::
:- dat.u.wan
::
:: non-initial deeds must be signed by previous
::
?> ?| ?=($~ pre)
2016-09-14 20:03:06 +03:00
=+ laz=(~(got by syg.u.wan) rex)
2016-09-13 03:24:21 +03:00
?> =(p.laz (dec num))
=(ash (need (sure:as:(com:nu:crub pub.u.pre) *code q.laz)))
==
::
:: check the parent has signed, if necessary
::
?> ?| ::
:: no parent signature for existing, non-moon urbits
::
?& ?=(^ pre)
=(dad.doc.u.pre dad)
!=(%earl mir)
==
::
:: public keys for galaxies are hardcoded
::
?& =(%czar mir)
?=($~ pre)
2016-09-14 20:03:06 +03:00
=(pub.dat.u.wan (zeno rex))
2016-09-13 03:24:21 +03:00
==
::
:: the deed's secure channel authenticates it
::
2016-09-14 20:03:06 +03:00
=(via rex)
2016-09-13 03:24:21 +03:00
::
:: check valid parent signature
::
=+ par=(~(got by syg.u.wan) dad)
2016-09-14 20:03:06 +03:00
(like [dad p.par] ash q.par)
2016-09-13 03:24:21 +03:00
==
:: tep: deed update
::
2016-09-14 20:03:06 +03:00
=/ tep [%hear %step rex num u.wan]
2016-09-13 03:24:21 +03:00
::
:: if we don't need to add a signature, report the new deed
::
?: (~(has by syg.u.wan) dad)
[tep ~]
::
:: lyf: life of parent
:: rig: secret key of parent
:: val: new signature
::
=* lyf p:(~(got by pug) dad)
=* rig (~(got by own:(~(got by pry) dad)) lyf)
=* val (sign:as:(nol:nu:crub rig) *@ ash)
2016-09-14 20:03:06 +03:00
[tep [%make %sure rex num [dad lyf] val] ~]
--
++ ur :: urbit reactor
=| jael-urbit
::
:: hab: effects in reverse order
:: urb: all urbit state
::
=| hab/(list jael-effect)
=* urb ->
|%
:: :: mean:ur:of
++ mean :: apply merge
|= ved/(list jael-edit)
^+ +>
!!
:: :: meet:ur:of
2016-09-13 03:24:21 +03:00
:: ::
2016-09-06 20:56:36 +03:00
--
2016-09-13 03:24:21 +03:00
:: :: we
++ we :: web reactor
!! ::::
--
--
:: ::::
:::: :: preamble
:: ::::
::
:: lex: all durable %jael state
::
=| lex/jael-state
|= $: ::
:: now: current time
:: eny: unique entropy
:: ski: namespace resolver
::
now/@da
eny/@e
ski/sley
==
:: ::
2016-09-13 03:24:21 +03:00
:::: :: interface
:: ::::
|%
:: :: call
++ call :: request
|= $: :: hen: cause of this event
:: hic: event data
::
hen/duct
hic/(hypo (hobo jael-task))
==
=> .(q.hic ?.(?=($soft -.q.hic) q.hic ((hard jael-task) p.q.hic)))
^- {p/(list jael-move) q/_..^$}
2016-09-14 20:03:06 +03:00
=^ did lex abet:~(call of [now eny] ~ lex)
2016-09-13 03:24:21 +03:00
[did ..^$]
:: :: doze
++ doze :: await
|= $: :: now: current time
:: hen: cause (XX why we need this?)
::
now/@da
hen/duct
==
^- (unit @da)
~
:: :: load
++ load :: upgrade
|= $: :: old: previous state
::
old/jael-state
==
^+ ..^$
..^$(lex old)
:: :: scry
++ 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-13 03:24:21 +03:00
:: :: stay
++ stay :: preserve
lex
:: :: take
++ take :: accept
|= $: :: tea: order
:: hen: cause
:: hin: result
::
tea/wire
hen/duct
hin/(hypo sign-arvo)
==
^- {p/(list jael-move) q/_..^$}
[~ ..^$]
2016-04-08 20:08:05 +03:00
--