urbit/pkg/arvo/sys/arvo.hoon

1969 lines
53 KiB
Plaintext
Raw Normal View History

2020-12-08 09:50:00 +03:00
=> ..ride =>
2022-04-08 03:15:59 +03:00
!:
|%
+| %global
::
2020-12-08 09:56:01 +03:00
++ arvo %240
::
:: $arch: node identity
:: $axal: fundamental node, recursive (trie)
:: $axil: fundamental node
:: $beak: global context
:: $beam: global name
:: $bone: opaque duct handle
:: $case: global version
2020-02-27 22:15:46 +03:00
:: $cage: marked vase
:: +cask: marked data builder
:: $desk: local workspace
:: $dock: message target
2020-11-24 00:06:50 +03:00
:: $gang: infinite set of peers
:: $mark: symbolic content type
:: $mien: orientation
2022-03-03 02:59:56 +03:00
:: $page: untyped cage
2020-11-24 00:06:50 +03:00
:: +omen: namespace path and data
:: $ship: network identity
:: $sink: subscription
::
+$ arch (axil @uvI)
++ axal
|$ [item]
2022-04-08 03:15:59 +03:00
[fil=(unit item) dir=(map @ta $)]
++ axil
|$ [item]
[fil=(unit item) dir=(map @ta ~)]
::
+$ beak (trel ship desk case)
2020-11-24 00:06:50 +03:00
+$ beam [beak s=path]
+$ bone @ud
+$ case
$% :: %da: date
:: %tas: label
:: %ud: sequence
::
[%da p=@da]
[%tas p=@tas]
[%ud p=@ud]
==
+$ cage (cask vase)
++ cask |$ [a] (pair mark a)
+$ desk @tas
+$ dock (pair @p term)
2020-11-24 00:06:50 +03:00
+$ gang (unit (set ship))
+$ mark @tas
2021-12-16 20:15:48 +03:00
+$ mien [our=ship now=@da eny=@uvJ]
2022-03-03 02:59:56 +03:00
+$ page (cask)
2020-11-24 00:06:50 +03:00
++ omen |$ [a] (pair path (cask a))
+$ ship @p
2020-02-27 22:15:46 +03:00
+$ sink (trel bone ship path)
::
+| %meta
::
:: +hypo: type-associated builder
:: $meta: meta-vase
:: $maze: vase, or meta-vase
::
++ hypo
|$ [a]
(pair type a)
+$ meta (pair)
+$ maze (each vase meta)
::
+| %interface
::
:: $ball: dynamic kernel action
:: $card: tagged, untyped event
:: $duct: causal history
:: +hobo: %soft task builder
:: $goof: crash label and trace XX fail/ruin/crud/flaw/lack/miss
2020-02-27 22:15:46 +03:00
:: $mass: memory usage
:: $move: cause and action
:: $ovum: card with cause
2020-11-24 00:06:50 +03:00
:: $roof: namespace
2020-12-06 13:55:19 +03:00
:: $rook: meta-namespace (super advanced)
2020-11-24 00:06:50 +03:00
:: +room: generic namespace
2020-12-08 00:52:12 +03:00
:: +roon: partial namespace
2020-12-06 13:55:19 +03:00
:: $root: raw namespace
2020-12-08 00:52:12 +03:00
:: $view: namespace perspective
:: +wind: kernel action builder
:: $wire: event pretext
:: +wite: kernel action/error builder
::
+$ ball (wite [vane=term task=maze] maze)
2022-03-26 16:59:43 +03:00
+$ card (cask)
+$ duct (list wire)
++ hobo
|$ [a]
$? $% [%soft p=*]
==
a
==
+$ goof [mote=term =tang]
2020-02-27 22:15:46 +03:00
+$ mass $~ $+|+~
(pair cord (each * (list mass)))
+$ move [=duct =ball]
+$ ovum [=wire =card]
::
2020-11-24 00:06:50 +03:00
+$ roof (room vase) :: namespace
+$ rook (room meta) :: meta-namespace
++ room :: either namespace
|$ [a]
$~ =>(~ |~(* ~))
$- $: lyc=gang :: leakset
2020-12-08 00:52:12 +03:00
vis=view :: perspective
2020-11-24 00:06:50 +03:00
bem=beam :: path
== ::
%- unit :: ~: unknown
%- unit :: ~ ~: invalid
(cask a)
2020-12-08 00:52:12 +03:00
+$ roon :: partial namespace
$~ =>(~ |~(* ~))
$- [lyc=gang car=term bem=beam]
(unit (unit cage))
2020-12-06 13:55:19 +03:00
+$ root $-(^ (unit (unit)))
2020-12-08 00:52:12 +03:00
+$ view $@(term [way=term car=term])
::
++ wind
|$ :: a: forward
:: b: reverse
::
[a b]
$% :: %pass: advance
:: %slip: lateral
:: %give: retreat
::
[%pass p=path q=a]
[%slip p=a]
[%give p=b]
==
+$ wire path
++ wite
|$ :: note: a routed $task
:: gift: a reverse action
::
:: NB: task: a forward action
:: sign: a sourced $gift
::
[note gift]
2020-02-27 02:57:59 +03:00
$% :: %hurl: action failed
:: %pass: advance
:: %slip: lateral
:: %give: retreat
::
2020-02-27 02:57:59 +03:00
[%hurl =goof wite=$;($>(?(%pass %give) $))]
[%pass =wire =note]
[%slip =note]
[%give =gift]
==
::
+| %implementation
::
:: $debt: ephemeral state
:: $grub: persistent state, larval stage
:: $germ: worklist source and bar stack
:: $heir: upgradeable state
:: $plan: worklist
:: $soul: persistent state
:: $vane: kernel module
2020-11-18 02:04:26 +03:00
:: $vere: runtime version
:: $vile: reflexive constants
:: $waif: arvo task, from anywhere
:: $wasp: arvo task, from Outside
2021-07-03 00:40:55 +03:00
:: $weft: kelvin version, tag and number
2020-12-05 13:32:54 +03:00
:: $worm: compiler cache
:: $wisp: arvo task, larval stage
2020-11-18 02:04:26 +03:00
:: $wynn: kelvin stack
::
+$ debt
$: :: run: list of worklists
:: out: pending output
2020-11-19 10:44:28 +03:00
:: kel: kernel files
:: fil: pending files
::
run=(list plan)
out=(list ovum)
2020-11-19 10:44:28 +03:00
kel=(list (pair path (cask)))
fil=(list (pair path (cask)))
==
+$ germ [vane=term bars=(list duct)]
+$ grub
$: :: who: identity once we know it
:: eny: entropy once we learn it
2020-12-03 03:16:59 +03:00
:: lac: laconicity as we want it
:: ver: the Outside as we see it
:: fat: source when we attain it
:: lul: %lull when we acquire it
:: zus: %zuse once we receive it
:: van: vanes while we desire it
::
who=(unit ship)
eny=(unit @)
lac=?
ver=(unit vere)
fat=(unit (axal (cask)))
2020-12-03 03:16:59 +03:00
lul=(unit (trap vase))
zus=(unit (trap vase))
van=(map term (trap vase))
==
+$ heir
2020-12-08 09:50:00 +03:00
$% $: %grub
$% [_arvo =grub]
== ==
[_arvo =debt =soul]
==
+$ plan (pair germ (list move))
+$ soul
$: :: identity, time, entropy
:: fad: configuration
:: zen: Outside knowledge
:: mod: internal modules
::
2021-12-16 20:15:48 +03:00
mien
$= fad
$: :: lac: not verbose
::
lac=?
==
$= zen
$: :: ver: runtime version
:: lag: upgrade blocked
::
ver=vere
lag=_|
==
$= mod
$: :: fat: filesystem
2020-12-03 03:16:59 +03:00
:: lul: %lull
:: zus: %zuse
:: van: vanes
::
fat=(axal (cask))
2020-12-03 03:16:59 +03:00
lul=vase
zus=vase
van=(map term vane)
==
==
+$ vane [=vase =worm]
+$ vere [[non=@ta rev=path] kel=wynn]
+$ vile
$: typ=type :: -:!>(*type)
duc=type :: -:!>(*duct)
wir=type :: -:!>(*wire)
dud=type :: -:!>(*(unit goof))
==
::
+$ waif
:: %trim: trim state, spam to all
:: %what: update from files
:: %whey: produce $mass :: XX remove, scry
:: %verb: toggle laconicity
:: %whiz: prime vane caches
::
2020-12-02 22:35:29 +03:00
$% [%trim p=@ud]
[%what p=(list (pair path (cask)))]
[%whey ~]
[%verb p=(unit ?)]
[%whiz ~]
==
+$ wasp
:: %crud: reroute $ovum with $goof
:: %wack: iterate entropy
:: %wyrd: check/record runtime kelvin stack
::
$% [%crud =goof =ovum]
[%wack p=@uvJ]
[%wyrd p=vere]
==
2021-07-03 00:40:55 +03:00
+$ weft [lal=@tas num=@ud]
2020-12-05 13:32:54 +03:00
+$ worm
$: :: +nest, +play, and +mint
::
nes=(set ^)
pay=(map (pair type hoon) type)
mit=(map (pair type hoon) (pair type nock))
==
+$ wisp
2020-12-02 22:35:29 +03:00
$% $>(?(%verb %what) waif)
$>(?(%wack %wyrd) wasp)
[%whom p=ship]
==
2021-07-03 00:40:55 +03:00
+$ wynn (list weft)
-- =>
::
2020-05-06 19:33:42 +03:00
~% %hex ..ut ~
2018-02-01 02:36:48 +03:00
|%
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: section 3bE, Arvo core ::
::
2020-11-24 00:06:50 +03:00
++ en-beam
|=(b=beam =*(s scot `path`[(s %p p.b) q.b (s r.b) s.b]))
::
++ de-beam
~/ %de-beam
2020-11-24 00:06:50 +03:00
|= p=path
^- (unit beam)
?. ?=([@ @ @ *] p) ~
?~ who=(slaw %p i.p) ~
?~ des=?~(i.t.p (some %$) (slaw %tas i.t.p)) ~ :: XX +sym ;~(pose low (easy %$))
?~ ved=(de-case i.t.t.p) ~
`[[`ship`u.who `desk`u.des u.ved] t.t.t.p]
2021-05-26 23:45:39 +03:00
::
++ de-case
~/ %de-case
2021-05-26 23:45:39 +03:00
|= =knot
^- (unit case)
?^ num=(slaw %ud knot) `[%ud u.num]
?^ wen=(slaw %da knot) `[%da u.wen]
?~ lab=(slaw %tas knot) ~
`[%tas u.lab]
2020-11-24 00:06:50 +03:00
::
2020-12-08 00:52:12 +03:00
++ en-omen
|= [vis=view bem=beam]
^- path
:_ (en-beam bem)
?@ vis vis
~(rent co [%many $/tas/way.vis $/tas/car.vis ~])
::
++ de-omen
~/ %de-omen
2020-12-08 00:52:12 +03:00
|= pax=path
^- (unit [vis=view bem=beam])
?~ pax ~
?~ bem=(de-beam t.pax) ~
?: ((sane %tas) i.pax)
`[i.pax u.bem]
=/ lot=(unit coin) (rush i.pax ;~(pfix dot perd:so))
?. ?& ?=(^ lot)
?=([%many [%$ %tas @] [%$ %tas @] ~] u.lot)
==
~
`[[q.p.i q.p.i.t]:p.u.lot u.bem]
::
2020-12-06 13:55:19 +03:00
++ look
~/ %look
|= [rof=roof lyc=gang]
^- root
~/ %in
|= [ref=* raw=*]
2020-12-06 13:55:19 +03:00
?~ pax=((soft path) raw) ~
2020-12-08 00:52:12 +03:00
?~ mon=(de-omen u.pax) ~
?~ dat=(rof lyc u.mon) ~
2020-12-06 13:55:19 +03:00
?~ u.dat [~ ~]
=* vax q.u.u.dat
?. ?& ?=(^ ref)
=(hoon-version -.ref)
-:(~(nets wa *worm) +.ref p.vax)
==
~>(%slog.[0 leaf+"arvo: scry-lost"] ~)
2020-12-06 13:55:19 +03:00
[~ ~ q.vax]
:: |wyrd: kelvin negotiation
2020-11-18 02:04:26 +03:00
::
:: specified but unimplemented:
:: arvo should produce a [wend/wynn] effect
:: to signal downgrade
::
++ wyrd
|%
:: +sane: kelvin stack for validity
2020-11-18 02:04:26 +03:00
::
++ sane
|= kel=wynn
^- ?
?: =(~ kel) &
2021-07-03 00:40:55 +03:00
=^ las=weft kel kel
|- ^- ?
?~ kel &
2021-07-03 00:40:55 +03:00
?& (gte num.las num.i.kel)
$(las i.kel, kel t.kel)
==
:: +need: require kelvins
2020-11-18 02:04:26 +03:00
::
++ need
|= [run=wynn hav=wynn]
:: wyr: ~: runtime supports all required kelvins
:: ^: runtime support is missing or lagging
::
=; wyr !.
?~ wyr
same
~& wyrd=wyr
~_ :+ %rose
[" " ~ ~]
:~ =+ p.u.wyr
2021-07-03 00:40:55 +03:00
leaf/"%{(trip lal)} %{(scow %ud num)} required;"
?~ q.u.wyr
leaf/"runtime missing support"
leaf/"runtime only supports %{(scow %ud u.q.u.wyr)}"
==
~> %mean.'arvo: upgrade blocked'
~> %mean.'wyrd'
!!
::
2021-07-03 00:40:55 +03:00
|- ^- (unit (pair weft (unit @ud)))
?~ hav ~
::
:: fel: %&: runtime kelvin for [i.hav]
:: %|: no specified runtime support
::
=/ fel
2021-07-03 00:40:55 +03:00
|- ^- (each @ud weft)
?~ run |/i.hav
2021-07-03 00:40:55 +03:00
?:(=(lal.i.hav lal.i.run) &/num.i.run $(run t.run))
::
?- -.fel
%| `[p.fel ~]
2021-07-03 00:40:55 +03:00
%& ?.((lte p.fel num.i.hav) `[i.hav `p.fel] $(hav t.hav))
==
--
::
2022-11-28 22:34:58 +03:00
:: |of: axal engine
::
2022-04-23 03:55:42 +03:00
++ of
=| fat=(axal)
|@
++ del
|= pax=path
2022-04-06 22:16:22 +03:00
^+ fat
?~ pax [~ dir.fat]
=/ kid (~(get by dir.fat) i.pax)
?~ kid fat
2022-04-06 22:16:22 +03:00
fat(dir (~(put by dir.fat) i.pax $(fat u.kid, pax t.pax)))
:: Descend to the axal at this path
::
++ dip
|= pax=path
^+ fat
?~ pax fat
=/ kid (~(get by dir.fat) i.pax)
?~ kid [~ ~]
$(fat u.kid, pax t.pax)
::
++ gas
|= lit=(list (pair path _?>(?=(^ fil.fat) u.fil.fat)))
^+ fat
?~ lit fat
$(fat (put p.i.lit q.i.lit), lit t.lit)
::
++ get
2022-04-06 22:16:22 +03:00
|= pax=path
fil:(dip pax)
:: Fetch file at longest existing prefix of the path
::
++ fit
|= pax=path
^+ [pax fil.fat]
?~ pax [~ fil.fat]
=/ kid (~(get by dir.fat) i.pax)
?~ kid [pax fil.fat]
=/ low $(fat u.kid, pax t.pax)
?~ +.low
[pax fil.fat]
low
::
++ has
|= pax=path
2022-04-08 02:31:12 +03:00
!=(~ (get pax))
:: Delete subtree
::
++ lop
|= pax=path
^+ fat
?~ pax fat
|-
?~ t.pax fat(dir (~(del by dir.fat) i.pax))
=/ kid (~(get by dir.fat) i.pax)
?~ kid fat
fat(dir (~(put by dir.fat) i.pax $(fat u.kid, pax t.pax)))
::
++ put
|* [pax=path dat=*]
2022-04-06 22:16:22 +03:00
=> .(dat `_?>(?=(^ fil.fat) u.fil.fat)`dat, pax `path`pax)
|- ^+ fat
?~ pax fat(fil `dat)
=/ kid (~(gut by dir.fat) i.pax ^+(fat [~ ~]))
fat(dir (~(put by dir.fat) i.pax $(fat kid, pax t.pax)))
::
++ tap
=| pax=path
=| out=(list (pair path _?>(?=(^ fil.fat) u.fil.fat)))
|- ^+ out
=? out ?=(^ fil.fat) :_(out [pax u.fil.fat])
=/ dir ~(tap by dir.fat)
|- ^+ out
?~ dir out
%= $
dir t.dir
out ^$(pax (weld pax /[p.i.dir]), fat q.i.dir)
==
2022-04-08 02:31:12 +03:00
:: Serialize to map
::
++ tar
(~(gas by *(map path _?>(?=(^ fil.fat) u.fil.fat))) tap)
--
::
2020-12-05 13:32:54 +03:00
++ wa :: cached compile
|_ worm
++ nell |=(ref=type (nest [%cell %noun %noun] ref)) :: nest in cell
++ nest :: nest:ut, cached
|= [sut=type ref=type]
^- [? worm]
?: (~(has in nes) [sut ref]) [& +>+<]
?. (~(nest ut sut) | ref)
~& %nest-failed
=+ foo=(skol ref)
=+ bar=(skol sut)
~& %nest-need
~> %slog.[0 bar]
~& %nest-have
~> %slog.[0 foo]
[| +>+<.$]
[& +>+<(nes (~(put in nes) [sut ref]))]
::
++ call :: call gate
|= [vax=vase nam=term som=(each vase ^)]
^- [vase worm]
=^ duf +>+<.$ (open vax nam som)
(slap duf [%limb %$])
::
++ open :: assemble door
|= [vax=vase nam=term som=(each vase ^)]
^- [vase worm]
=* key [%cncb [[%& 2] ~] [[[%& 6] ~] [%$ 3]] ~]
=^ dor +>+<.$ (slap vax [%limb nam])
=^ mes +>+<.$ (slot 6 dor)
=^ hip +>+<.$
?- -.som
%& (nest p.mes p.p.som)
%| (nets p.mes -.p.som)
==
?> hip
[[p.dor q.dor(+6 +7.som)] +>+<.$]
::
++ neat :: type compliance
|= [typ=type som=(each vase ^)]
^- worm
=^ hip +>+<.$
?- -.som
%& (nest typ p.p.som)
%| (nets typ -.p.som)
==
?> hip
+>+<.$
::
++ nets :: typeless nest
|= [sut=* ref=*]
^- [? worm]
?: (~(has in nes) [sut ref]) [& +>+<]
=+ gat=|=([a=type b=type] (~(nest ut a) | b))
?. (? (slum gat [sut ref]))
~& %nets-failed
=+ tag=`*`skol
=+ foo=(tank (slum tag ref))
=+ bar=(tank (slum tag sut))
~& %nets-need
~> %slog.[0 bar]
~& %nets-have
~> %slog.[0 foo]
[| +>+<.$]
[& +>+<.$(nes (~(put in nes) [sut ref]))]
:: +play: +play:ut, cached
::
++ play
|= [sut=type gen=hoon]
^- [type worm]
=+ old=(~(get by pay) [sut gen])
?^ old [u.old +>+<.$]
=+ new=(~(play ut sut) gen)
[new +>+<.$(pay (~(put by pay) [sut gen] new))]
:: +mint: +mint:ut to noun, cached
::
++ mint
|= [sut=type gen=hoon]
^- [(pair type nock) worm]
=+ old=(~(get by mit) [sut gen])
?^ old [u.old +>+<.$]
=+ new=(~(mint ut sut) %noun gen)
[new +>+<.$(mit (~(put by mit) [sut gen] new))]
:: +slam: +slam:ut, cached
::
++ slam
|= [gat=vase sam=vase]
=/ sut=type [%cell p.gat p.sam]
=/ gen=hoon [%cnsg [%$ ~] [%$ 2] [%$ 3] ~]
=^ new=type +>+<.$ (play sut gen)
[[new (slum q.gat q.sam)] +>+<.$]
:: +slap: +slap:ut, cached
::
++ slap
|= [vax=vase gen=hoon]
^- [vase worm]
=^ gun +>+< (mint p.vax gen)
[[p.gun .*(q.vax q.gun)] +>+<.$]
:: +slot: +slot:ut, cached
::
++ slot
|= [axe=@ vax=vase]
^- [vase worm]
=^ gun +>+< (mint p.vax [%$ axe])
[[p.gun .*(q.vax [0 axe])] +>+<.$]
::
:: +slur: slam a vase with a maze
::
++ slur
|= [gat=vase sam=maze]
^- [vase worm]
=^ cur +>+<.$ (slot 6 gat)
=. +>+<.$ (neat p.cur sam)
(slym gat q.p.sam)
2020-12-05 13:32:54 +03:00
:: +slym: +slym:ut, cached
::
++ slym
|= [gat=vase sam=*]
^- [vase worm]
(slap gat(+<.q sam) [%limb %$])
::
++ sped :: specialize vase
|= vax=vase
^- [vase worm]
=+ ^= gen ^- hoon
?@ q.vax [%wtts [%base [%atom %$]] [%& 1]~]
?@ -.q.vax [%wtts [%leaf %tas -.q.vax] [%& 2]~]
[%wtts [%base %cell] [%& 1]~]
=^ typ +>+<.$ (play p.vax [%wtgr gen [%$ 1]])
[[typ q.vax] +>+<.$]
::
++ spot :: slot then sped
|= [axe=@ vax=vase]
^- [vase worm]
=^ xav +>+< (slot axe vax)
(sped xav)
::
++ stop :: sped then slot
|= [axe=@ vax=vase]
^- [vase worm]
=^ xav +>+< (sped vax)
(slot axe xav)
--
::
:: |part: arvo structures and engines
::
++ part
=> |%
:: $card: tagged, untyped event
:: $ovum: card with cause
2020-11-19 10:44:28 +03:00
:: $news: collated updates
:: $oped: module updates
:: $seed: next kernel source
::
2020-11-19 10:44:28 +03:00
+$ news
$: :: sys: installs + replacements
:: use: non-system files
::
sys=(map path (cask))
use=(map path (cask))
==
+$ oped
2020-12-07 04:11:38 +03:00
$: lul=(unit cord)
zus=(unit cord)
van=(list (cask cord))
2020-11-19 10:44:28 +03:00
==
2020-12-07 04:11:38 +03:00
+$ seed [hun=(unit cord) arv=cord]
--
::
2020-05-06 19:33:42 +03:00
~% %part ..part ~
|%
::
+| %engines
::
2020-12-07 05:35:24 +03:00
:: |eden: lifecycle and bootstrap formula generators
::
:: while unused by arvo itself, these nock formulas
:: bootstrap arvo and define its lifecycle.
::
:: we're creating an event series E whose lifecycle can be computed
:: with the urbit lifecycle formula L, `[2 [0 3] [0 2]]`. that is:
:: if E is the list of events processed by a computer in its life,
:: its final state is S, where S is nock(E L).
::
:: in practice, the first five nouns in E are: two boot formulas,
:: a hoon compiler as a nock formula, the same compiler as source,
:: and the arvo kernel as source.
::
:: after the first five special events, we enter an iterative
:: sequence of regular events which continues for the rest of the
:: computer's life. during this sequence, each state is a function
:: that, passed the next event, produces the next state.
::
:: a regular event is an $ovum, or `[date wire type data]` tuple, where
:: `date` is a 128-bit Urbit date; `wire` is an opaque path which
:: output can match to track causality; `type` is a symbol describing
:: the type of input; and `data` is input data specific to `type`.
::
:: in real life we don't actually run the lifecycle loop,
:: since real life is updated incrementally and also cares
:: about things like output. we couple to the internal
:: structure of the state machine and work directly with
:: the underlying arvo engine.
::
:: this arvo core, which is at `+7` (Lisp `cddr`) of the state
:: function (see its public interface in `sys/arvo`), gives us
:: extra features, like output, which are relevant to running
:: a real-life urbit vm, but don't affect the formal definition.
::
:: so a real-life urbit interpreter is coupled to the shape of
:: the arvo core. it becomes very hard to change this shape.
:: fortunately, it is not a very complex interface.
::
++ eden
|%
:: +aeon: arvo lifecycle loop
::
:: the first event in a ship's log,
:: computing the final state from the rest of log
:: when invoked via the lifecycle formula: [%2 [%0 3] %0 2]
::
:: the formal urbit state is always just a gate (function)
:: which, passed the next event, produces the next state.
::
++ aeon
^- *
=> :: boot: kernel bootstrap, event 2
:: tale: events 3-n
::
*log=[boot=* tale=*]
!= :: arvo: bootstrapped kernel
:: epic: remainder of the log
::
=+ [arvo epic]=.*(tale.log boot.log)
|- ^- *
?@ epic arvo
%= $
epic +.epic
arvo .*([arvo -.epic] [%9 2 %10 [6 %0 3] %0 2])
2020-12-07 05:35:24 +03:00
==
::
:: +boot: event 2: bootstrap a kernel from source
::
++ boot
^- *
::
:: event 2 is the startup formula, which verifies the compiler
:: and starts the main lifecycle.
::
=> :: fate: event 3: a nock formula producing the hoon bootstrap compiler
:: hoon: event 4: compiler source
:: arvo: event 5: kernel source
:: epic: event 6-n
::
*log=[fate=* hoon=@ arvo=@ epic=*]
!=
::
:: activate the compiler gate. the product of this formula
:: is smaller than the formula. so you might think we should
:: save the gate itself rather than the formula producing it.
:: but we have to run the formula at runtime, to register jets.
::
:: as always, we have to use raw nock as we have no type.
:: the gate is in fact ++ride.
::
~> %slog.[0 leaf+"1-b"]
=/ compiler-gate .*(0 fate.log)
::
:: compile the compiler source, producing (pair span nock).
:: the compiler ignores its input so we use a trivial span.
::
~> %slog.[0 leaf+"1-c (compiling compiler, wait a few minutes)"]
=/ compiler-tool
.*([compiler-gate noun/hoon.log] [%9 2 %10 [6 %0 3] %0 2])
2020-12-07 05:35:24 +03:00
::
:: switch to the second-generation compiler. we want to be
:: able to generate matching reflection nouns even if the
:: language changes -- the first-generation formula will
:: generate last-generation spans for `!>`, etc.
::
~> %slog.[0 leaf+"1-d"]
=. compiler-gate .*(0 +.compiler-tool)
2020-12-07 05:35:24 +03:00
::
:: get the span (type) of the kernel core, which is the context
:: of the compiler gate. we just compiled the compiler,
:: so we know the span (type) of the compiler gate. its
:: context is at tree address `+>` (ie, `+7` or Lisp `cddr`).
:: we use the compiler again to infer this trivial program.
::
~> %slog.[0 leaf+"1-e"]
=/ kernel-span
-:.*([compiler-gate -.compiler-tool '+>'] [%9 2 %10 [6 %0 3] %0 2])
2020-12-07 05:35:24 +03:00
::
:: compile the arvo source against the kernel core.
::
~> %slog.[0 leaf+"1-f"]
=/ kernel-tool
.*([compiler-gate kernel-span arvo.log] [%9 2 %10 [6 %0 3] %0 2])
2020-12-07 05:35:24 +03:00
::
:: create the arvo kernel, whose subject is the kernel core.
::
~> %slog.[0 leaf+"1-g"]
[.*(+>.compiler-gate +.kernel-tool) epic.log]
2020-12-07 05:35:24 +03:00
--
::
2020-11-19 10:44:28 +03:00
:: |adapt
::
++ adapt
=> |%
:: deep file as source
::
2020-12-07 04:11:38 +03:00
++ sole |=(a=(cask) `cord`?>(?=([%hoon @t] a) q.a))
2020-11-19 10:44:28 +03:00
--
|_ fat=(axal (cask))
2020-11-19 10:44:28 +03:00
::
:: +group: collate changes
::
++ group
|= fal=(list (pair path (cask)))
=| del=news
|- ^+ del
?~ fal del
:: classify files, ignoring unchanged
::
=* pax p.i.fal
=* dat q.i.fal
2022-04-23 03:55:42 +03:00
=/ hav (~(get of fat) pax)
2022-04-06 22:16:22 +03:00
=? del |(?=(~ hav) !=(u.hav dat))
2020-11-19 10:44:28 +03:00
?: ?=([%sys *] pax)
del(sys (~(put by sys.del) pax dat))
del(use (~(put by use.del) pax dat))
$(fal t.fal)
:: +usurp: consider self-replacement
::
++ usurp
|= del=news
^- (unit (pair seed (list (pair path (cask)))))
=/ hun (~(get by sys.del) /sys/hoon)
=/ arv (~(get by sys.del) /sys/arvo)
?~ hun
?~ arv ~
`[`(sole u.arv) [/sys/arvo u.arv] ~]
=/ rav
~| %usurp-hoon-no-arvo
2022-04-23 03:55:42 +03:00
((bond |.((need (~(get of fat) /sys/arvo)))) arv)
2020-11-19 10:44:28 +03:00
~! rav
:+ ~
[`(sole u.hun) (sole rav)]
[[/sys/arvo rav] [/sys/hoon u.hun] ~]
:: +adorn: augment capabilities
::
++ adorn
|= [del=news all=?]
^- (pair oped _fat)
2020-12-03 03:16:59 +03:00
:: lull: shared structures
::
=^ lul fat
?^ hav=(~(get by sys.del) /sys/lull)
:- `(sole u.hav)
2022-04-23 03:55:42 +03:00
(~(put of fat) /sys/lull u.hav)
2020-12-03 03:16:59 +03:00
:_ fat
~| %adorn-no-lull
2022-04-23 03:55:42 +03:00
?.(all ~ `(sole (need (~(get of fat) /sys/lull))))
2020-11-19 10:44:28 +03:00
:: zuse: shared library
::
2020-12-03 03:16:59 +03:00
:: %lull is the subject of %zuse; force all if we have a new %lull
::
=. all |(all ?=(^ lul))
2020-11-19 10:44:28 +03:00
=^ zus fat
?^ hav=(~(get by sys.del) /sys/zuse)
:- `(sole u.hav)
2022-04-23 03:55:42 +03:00
(~(put of fat) /sys/zuse u.hav)
2020-11-19 10:44:28 +03:00
:_ fat
~| %adorn-no-zuse
2022-04-23 03:55:42 +03:00
?.(all ~ `(sole (need (~(get of fat) /sys/zuse))))
2020-11-19 10:44:28 +03:00
:: kernel modules
::
:: %zuse is the subject of the vanes; force all if we have a new %zuse
::
2020-12-03 03:16:59 +03:00
=. all |(all ?=(^ zus))
2020-12-07 04:11:38 +03:00
=| nav=(map term cord)
2020-12-03 03:16:59 +03:00
=? nav all
2020-11-19 10:44:28 +03:00
%- ~(gas by nav)
%+ turn
2022-04-23 03:55:42 +03:00
~(tap by dir:(~(dip of fat) /sys/vane))
2020-11-19 10:44:28 +03:00
|=([name=@ta _fat] [`@tas`name (sole (need fil))])
::
=^ new fat
%^ spin
%+ skim ~(tap by sys.del)
|=([p=path *] ?=([%sys %vane @tas ~] p))
fat
|= [[p=path q=(cask)] taf=_fat]
2020-12-07 04:11:38 +03:00
^- (pair (cask cord) _fat)
2020-11-19 10:44:28 +03:00
?> ?=([%sys %vane @tas ~] p)
=* nam i.t.t.p
?> ((sane %tas) nam)
2022-04-23 03:55:42 +03:00
[[`@tas`nam (sole q)] (~(put of taf) p q)]
2020-11-19 10:44:28 +03:00
::
=; van
2020-12-03 03:16:59 +03:00
[[lul zus van] fat]
2020-11-19 10:44:28 +03:00
%+ sort ~(tap by (~(gas by nav) new))
|=([[a=@tas *] [b=@tas *]] (aor a b))
-- :: adapt
::
:: |me: dynamic analysis
::
++ me
~/ %me
|_ :: sac: compiler cache
:: pyt: cached types
::
[sac=worm vil=vile]
2020-02-27 04:49:42 +03:00
:: +refine-moves: move list from vase
2020-01-24 06:45:03 +03:00
::
++ refine-moves
|= vax=vase
^- (pair (list move) worm)
?: =(~ q.vax) [~ sac]
=^ hed sac (~(slot wa sac) 2 vax)
=^ tal sac (~(slot wa sac) 3 vax)
=^ mov sac (refine-move hed)
=^ moz sac $(vax tal)
[[mov moz] sac]
2020-02-27 04:49:42 +03:00
:: +refine-move: move from vase
2020-01-24 06:45:03 +03:00
::
++ refine-move
|= vax=vase
^- (pair move worm)
~> %mean.'bad-move'
=^ hip sac (~(nell wa sac) p.vax)
?. hip
2020-03-04 00:20:34 +03:00
~>(%mean.'not-cell' !!)
=/ duc
~> %mean.'bad-duct'
;;(duct -.q.vax)
::
:: yat: specialized ball vase
::
=^ yat sac (~(spot wa sac) 3 vax)
=^ del sac (refine-ball yat)
[[duc del] sac]
2020-02-27 04:49:42 +03:00
:: +refine-ball: ball from vase
2020-01-24 06:45:03 +03:00
::
++ refine-ball
|= vax=vase
^- (pair ball worm)
?+ q.vax
~> %mean.'bad-ball'
~_ (sell vax)
!!
::
[%give card]
:: yed: vase containing card
2020-02-27 04:35:12 +03:00
:: hil: card as maze
::
=^ yed sac (~(spot wa sac) 3 vax)
=^ hil sac (refine-card yed)
[[%give hil] sac]
2020-01-24 06:45:03 +03:00
::
[%pass wire=* vane=term card]
=/ =wire
~> %mean.'bad-wire'
;;(wire wire.q.vax)
=/ vane
~> %mean.'bad-vane-label'
?> ((sane %tas) vane.q.vax)
vane.q.vax
::
:: yed: vase containing card
2020-02-27 04:35:12 +03:00
:: hil: card as maze
::
=^ xav sac (~(spot wa sac) 7 vax)
=^ yed sac (~(spot wa sac) 3 xav)
=^ hil sac (refine-card yed)
[[%pass wire vane hil] sac]
2020-01-24 06:45:03 +03:00
::
[%slip vane=term card]
=/ vane
~> %mean.'bad-vane-label'
?> ((sane %tas) vane.q.vax)
vane.q.vax
::
:: yed: vase containing card
2020-02-27 04:35:12 +03:00
:: hil: card as maze
::
=^ xav sac (~(spot wa sac) 3 vax)
=^ yed sac (~(spot wa sac) 3 xav)
=^ hil sac (refine-card yed)
[[%slip vane hil] sac]
2020-02-10 07:07:37 +03:00
::
2020-02-27 02:57:59 +03:00
[%hurl goof=^ ball=*]
2020-02-10 07:07:37 +03:00
=/ =goof
=/ mote -.goof.q.vax
?> ?& ?=(@ mote)
((sane %tas) mote)
==
[mote ;;(tang +.goof.q.vax)]
::
2020-02-27 02:57:59 +03:00
=^ bal sac
=^ lab sac (~(spot wa sac) 7 vax)
$(vax lab)
2020-02-10 07:07:37 +03:00
::
2020-02-27 02:57:59 +03:00
?> ?=(?(%pass %give) -.p.bal)
[[%hurl goof p.bal] sac]
==
2020-02-27 04:49:42 +03:00
:: +refine-card: card from vase
2020-01-24 06:45:03 +03:00
::
++ refine-card
|= vax=vase
2020-02-27 04:35:12 +03:00
^- (pair maze worm)
~> %mean.'bad-card'
=^ hip sac (~(nell wa sac) p.vax)
?> hip
?. ?=(%meta -.q.vax)
::
2020-02-27 04:35:12 +03:00
:: for a non-meta card, the maze is the vase
::
[[%& vax] sac]
~> %mean.'bad-meta'
::
:: tiv: vase of vase of card
:: typ: vase of span
2020-01-24 06:45:03 +03:00
::
=^ tiv sac (~(slot wa sac) 3 vax)
=^ hip sac (~(nell wa sac) p.tiv)
?> hip
=^ typ sac (~(slot wa sac) 2 tiv)
=. sac (~(neat wa sac) typ.vil [%& typ])
2020-01-24 06:45:03 +03:00
::
:: support for meta-meta-cards has been removed
::
?> ?=(meta q.tiv)
[[%| q.tiv] sac]
--
::
:: |va: vane engine
::
++ va
=> |%
2020-12-06 11:38:37 +03:00
+$ vane-sample [now=@da eny=@uvJ rof=rook]
::
++ smit
|= [cap=tape sub=vase pax=path txt=@t]
^- vase
2020-12-08 03:22:26 +03:00
~> %slog.[0 leaf/"{cap}: {(scow p+(mug txt))}"]
%- road |.
2020-12-08 03:22:26 +03:00
~_ leaf/"{cap}: build failed"
(slap sub (rain pax txt))
::
++ create
2020-12-06 11:38:37 +03:00
|= [our=ship zus=vase lal=term pax=path txt=@t]
^- vase
=/ cap "vane: %{(trip lal)}"
2020-12-06 11:38:37 +03:00
(slym (smit cap zus pax txt) our)
::
++ settle
|= van=vase
^- (pair vase worm)
=| sac=worm
=^ rig=vase sac (~(slym wa sac) van *vane-sample)
=^ gat=vase sac (~(slap wa sac) rig [%limb %scry])
=^ pro=vase sac (~(slap wa sac) gat [%limb %$])
[van +:(~(mint wa sac) p.pro [%$ 7])]
::
:: XX pass identity to preserve behavior?
::
++ update
|= [las=vase nex=vase]
^- vase
=/ sam=vase (slap (slym las *vane-sample) [%limb %stay])
=/ gat=vase (slap (slym nex *vane-sample) [%limb %load])
(slam gat sam)
--
::
~% %va ..va ~
2020-12-06 11:38:37 +03:00
|_ [vil=vile vax=vase sac=worm]
::
:: |plow:va: operate in time and space
::
++ plow
2020-11-24 00:06:50 +03:00
|= [now=@da rok=rook]
|%
:: +peek:plow:va: read from a local namespace
::
++ peek
2020-11-24 00:06:50 +03:00
^- rook
2020-12-08 00:52:12 +03:00
|= [lyc=gang vis=view bem=beam]
^- (unit (unit (cask meta)))
:: namespace reads receive no entropy
::
2020-12-06 11:38:37 +03:00
=/ sam=vane-sample [now *@uvJ rok]
=^ rig sac
~> %mean.'peek: activation failed'
(~(slym wa sac) vax sam)
=^ gat sac
~> %mean.'peek: pull failed'
(~(slap wa sac) rig [%limb %scry])
::
2020-12-08 00:52:12 +03:00
=/ mas=[gang view beam] [lyc vis bem]
2020-11-24 00:06:50 +03:00
::
=^ pro sac
~> %mean.'peek: call failed'
(~(slym wa sac) gat mas)
2020-11-24 00:06:50 +03:00
?~ q.pro ~
?~ +.q.pro [~ ~]
=^ dat sac (~(slot wa sac) 7 pro)
``[(,mark -.q.dat) (,^ +.q.dat)]
::
:: |spin:plow:va: move statefully
::
++ spin
2020-02-10 07:01:03 +03:00
|= [hen=duct eny=@uvJ dud=(unit goof)]
=* duc [duc.vil hen]
=* err [dud.vil dud]
2020-12-06 11:38:37 +03:00
=/ sam=vane-sample [now eny rok]
=^ rig sac
~> %mean.'spin: activation failed'
(~(slym wa sac) vax sam)
::
=> |%
:: +slid: cons a vase onto a maze
::
++ slid
|= [hed=vase tal=maze]
^- maze
?- -.tal
%& [%& (slop hed p.tal)]
%| [%| [%cell p.hed p.p.tal] [q.hed q.p.tal]]
==
--
|%
:: +peel:spin:plow:va: extract products, finalize vane
::
++ peel
|= pro=vase
^- (pair [vase vase] worm)
=^ moz sac (~(slot wa sac) 2 pro)
=^ vem sac (~(slot wa sac) 3 pro)
:: replace vane sample with default to plug leak
::
=. +<.q.vem *vane-sample
[[moz vem] sac]
:: +call:spin:plow:va: advance statefully
::
++ call
2020-02-27 04:35:12 +03:00
|= task=maze
^- (pair [vase vase] worm)
~> %mean.'call: failed'
=^ gat sac
(~(slap wa sac) rig [%limb %call])
::
2020-12-06 11:38:37 +03:00
:: sample is [duct (unit goof) (hobo task)]
::
2020-02-27 04:35:12 +03:00
=/ sam=maze
2020-12-06 11:38:37 +03:00
(slid duc (slid err task))
=^ pro sac (~(slur wa sac) gat sam)
(peel pro)
:: +take:spin:plow:va: retreat statefully
::
++ take
2020-02-27 04:35:12 +03:00
|= [=wire from=term gift=maze]
^- (pair [vase vase] worm)
~> %mean.'take: failed'
=^ gat sac
(~(slap wa sac) rig [%limb %take])
=/ src=vase
[[%atom %tas `from] from]
::
2020-12-06 11:38:37 +03:00
:: sample is [wire duct (unit goof) sign=[term gift]]
::
2020-02-27 04:35:12 +03:00
=/ sam=maze
=* tea [wir.vil wire]
2020-12-06 11:38:37 +03:00
(slid tea (slid duc (slid err (slid src gift))))
=^ pro sac (~(slur wa sac) gat sam)
(peel pro)
--
--
--
::
:: |le: arvo event-loop engine
::
++ le
~% %le ..le ~
2020-11-19 10:44:28 +03:00
=| $: :: run: list of worklists
:: out: pending output
:: gem: worklist metadata
:: dud: propagate error
2020-11-19 10:44:28 +03:00
:: but: reboot signal
::
2020-11-19 10:44:28 +03:00
::
run=(list plan)
out=(list ovum)
gem=germ
dud=(unit goof)
2020-11-19 10:44:28 +03:00
$= but %- unit
$: gat=$-(heir (trap ^))
kel=(list (pair path (cask)))
fil=(list (pair path (cask)))
==
==
::
2020-11-24 00:06:50 +03:00
|_ [[pit=vase vil=vile] soul]
+* this .
2020-11-24 00:06:50 +03:00
sol +<+
::
:: +abet: finalize loop
::
++ abet
^- (each (pair (list ovum) soul) (trap ^))
?~ but
2020-11-24 00:06:50 +03:00
^- [%& (pair (list ovum) soul)]
&/[(flop out) sol]
2020-11-24 00:06:50 +03:00
|/(gat.u.but [arvo [run out [kel fil]:u.but] sol])
:: +poke: prepare a worklist-of-one from outside
::
++ poke
|= =ovum
^+ this
2020-03-04 00:20:34 +03:00
~> %mean.'arvo: poke crashed'
~? !lac.fad ["" %unix p.card.ovum wire.ovum now]
(poke:pith ovum)
::
++ jump
|= =debt
^+ this
=: run run.debt
out out.debt
==
2020-11-19 10:44:28 +03:00
:: apply remaining update
::
2020-12-08 09:50:00 +03:00
=. ..this (~(lod what:pith fil.debt) kel.debt)
:: send upgrade notifications
::
=+ [wir car]=[/arvo vega/~]
=. ..this (xeno:pith $/wir car)
(emit $/~ (spam:pith wir !>(car)))
:: +emit: enqueue a worklist with source
::
++ emit
|= pan=plan
this(run [pan run])
:: +loop: until done
::
++ loop
^+ abet
?: ?| ?=(~ run)
?=(^ but)
==
abet
?: =(~ q.i.run) :: XX TMI
loop(run t.run)
=. dud ~
=. gem p.i.run
=^ mov=move q.i.run q.i.run
loop:(step mov)
:: +step: advance the loop one step by routing a move
::
++ step
|= =move
^+ this
2020-02-10 07:01:03 +03:00
::
~? &(!lac.fad ?=(^ dud)) %goof
2020-02-10 07:01:03 +03:00
::
?- -.ball.move
::
:: %pass: forward move
::
%pass
=* wire wire.ball.move
=* duct duct.move
=* vane vane.note.ball.move
=* task task.note.ball.move
::
~? &(!lac.fad !=(%$ vane.gem))
:- (runt [(lent bars.gem) '|'] "")
:^ %pass [vane.gem vane]
?: ?=(?(%deal %deal-gall) +>-.task)
:- :- +>-.task
;;([[ship ship] term term] [+>+< +>+>- +>+>+<]:task)
wire
[(symp +>-.task) wire]
duct
::
:: cons source onto wire, and wire onto duct
::
(call [[vane.gem wire] duct] vane task)
2020-01-24 06:45:03 +03:00
::
:: %slip: lateral move
2020-01-24 06:45:03 +03:00
::
%slip
=* duct duct.move
=* vane vane.note.ball.move
=* task task.note.ball.move
::
~? !lac.fad
:- (runt [(lent bars.gem) '|'] "")
2020-12-08 03:22:26 +03:00
[%slip [vane.gem vane] (symp +>-.task) duct]
::
(call duct vane task)
::
:: %give: return move
::
%give
?. ?=(^ duct.move)
~>(%mean.'give-no-duct' !!)
::
=/ wire i.duct.move
=/ duct t.duct.move
=* gift gift.ball.move
::
=^ way=term wire
2020-02-07 01:34:01 +03:00
~| [%give duct.move (symp -.q.p.gift)]
?>(?=(^ wire) wire)
::
~? &(!lac.fad !=(%$ way) |(!=(%blit +>-.gift) !=(%d vane.gem)))
:- (runt [(lent bars.gem) '|'] "")
:^ %give vane.gem
?: ?=(%unto +>-.gift)
[+>-.gift (symp +>+<.gift)]
(symp +>-.gift)
duct.move
::
(take duct wire way gift)
2020-02-10 07:01:03 +03:00
::
2020-02-27 02:57:59 +03:00
:: %hurl: action with error
2020-02-10 07:01:03 +03:00
::
%hurl
%= $
2020-02-27 02:57:59 +03:00
dud `goof.ball.move
ball.move wite.ball.move
2020-02-10 07:01:03 +03:00
==
==
2020-05-07 11:51:08 +03:00
:: +whey: measure memory usage
::
++ whey
^- mass
=; sam=(list mass)
:+ %arvo %|
:~ :+ %hoon %|
:~ one+&+..bloq
two+&+..turn
tri+&+..year
qua+&+..sane
pen+&+..ride
==
hex+&+..part
pit+&+pit
lull+|+[dot+&+q typ+&+p ~]:lul.mod
zuse+|+[dot+&+q typ+&+p ~]:zus.mod
vane+|+sam
==
::
%+ turn
2020-12-08 00:52:12 +03:00
(sort ~(tap by van.mod) |=([[a=@tas *] [b=@tas *]] (aor a b)))
=/ bem=beam [[our %base da+now] /whey] ::TODO %base?
|= [nam=term =vane]
=; mas=(list mass)
nam^|+(welp mas [dot+&+q.vase typ+&+p.vase sac+&+worm ~]:vane)
?~ met=(peek [~ ~] nam bem) ~
?~ u.met ~
~| mass+nam
;;((list mass) q.q.u.u.met)
:: +peek: read from the entire namespace
::
++ peek
2020-11-24 00:06:50 +03:00
^- rook
2020-12-08 00:52:12 +03:00
|= [lyc=gang vis=view bem=beam]
^- (unit (unit (cask meta)))
2020-12-08 00:52:12 +03:00
:: vane and care may be concatenated
::
2020-12-08 00:52:12 +03:00
=/ [way=term car=term]
?^ vis vis
?. =(2 (met 3 vis))
[vis %$]
[(end 3 vis) (rsh 3 vis)]
::
2020-12-08 00:52:12 +03:00
?: ?=(%$ way)
(peek:pith lyc car bem)
2020-12-08 03:22:26 +03:00
::
=. way (grow way)
?~ van=(~(get by van.mod) way)
~
2020-12-08 03:22:26 +03:00
%. [lyc car bem]
peek:spin:(~(plow va [vil u.van]) now peek)
:: +call: advance to target
::
++ call
2020-02-27 04:35:12 +03:00
|= [=duct way=term task=maze]
^+ this
?: ?=(%$ way)
2020-12-08 00:52:12 +03:00
~> %mean.'arvo: call:pith failed'
%- call:pith
~> %mean.'call: bad waif'
2020-12-08 00:52:12 +03:00
;;(waif q.p.task)
::
2020-12-08 03:22:26 +03:00
=. way (grow way)
%+ push [way duct bars.gem]
~| bar-stack=`(list ^duct)`[duct bars.gem]
2020-02-10 07:01:03 +03:00
%. task
2020-12-08 03:22:26 +03:00
call:(spin:(plow way) duct eny dud)
:: +take: retreat along call-stack
::
++ take
2020-02-27 04:35:12 +03:00
|= [=duct =wire way=term gift=maze]
^+ this
?: ?=(%$ way)
::
:: the caller was Outside
::
?> ?=(~ duct)
(xeno:pith wire ;;(card q.p.gift))
:: the caller was a vane
::
2020-12-08 03:22:26 +03:00
=. way (grow way)
%+ push [way duct bars.gem]
::
:: cons source onto .gift to make a $sign
::
~| wire=wire
~| bar-stack=`(list ^duct)`[duct bars.gem]
2020-02-10 07:01:03 +03:00
%. [wire [vane.gem gift]]
2020-12-08 03:22:26 +03:00
take:(spin:(plow way) duct eny dud)
:: +push: finalize an individual step
::
++ push
|= [gum=germ [zom=vase vax=vase] sac=worm]
^+ this
=^ moz sac
(~(refine-moves me sac vil) zom)
2020-12-08 03:22:26 +03:00
=. van.mod (~(put by van.mod) vane.gum [vax sac])
(emit `plan`[`germ`gum `(list move)`moz])
:: +plow: operate on a vane, in time and space
::
++ plow
|= way=term
~| [%plow-failed way]
=/ =vane
2020-02-07 01:34:01 +03:00
~| [%missing-vane way]
(~(got by van.mod) way)
2020-12-06 11:38:37 +03:00
(~(plow va [vil vane]) now peek)
::
:: |pith: operate on arvo internals
::
++ pith
|%
++ gest
|= =ovum
^- $>(%pass ball)
=^ way=term wire.ovum wire.ovum
::
:: %$: default, routed to arvo-proper as trivial vase
:: @: route to vane as $hobo
::
=/ =vase
?- way
%$ noun/card.ovum
@ [cell/[atom/tas/`%soft %noun] soft/card.ovum]
==
[%pass wire.ovum way &/vase]
::
2020-11-19 10:44:28 +03:00
:: |what: update engine
::
:: +kel: (maybe) initiate a kernel update
:: +lod: continue with update after kernel +load
:: +mod: update the modules of the kernel
::
++ what
|_ fil=(list (pair path (cask)))
::
++ kel
^+ ..pith
=/ del (~(group adapt fat.mod.sol) fil)
=/ tub (~(usurp adapt fat.mod.sol) del)
2020-11-19 10:44:28 +03:00
?~ tub
(mod del |)
=/ gat (boot kel.ver.zen [hun arv]:p.u.tub)
2020-12-08 09:50:00 +03:00
..pith(but `[gat q.u.tub fil])
2020-11-19 10:44:28 +03:00
::
++ lod
|= kel=(list (pair path (cask)))
^+ ..pith
2022-04-23 03:55:42 +03:00
=. fat.mod.sol (~(gas of fat.mod.sol) kel)
2020-11-19 10:44:28 +03:00
%+ mod
(~(group adapt fat.mod.sol) fil)
2020-11-19 10:44:28 +03:00
%+ lien kel
|= [p=path *]
?=([%sys ?(%arvo %hoon) *] p)
::
++ mod
|= [del=news all=?]
^+ ..pith
=^ job=oped fat.mod.sol (~(adorn adapt fat.mod.sol) del all)
2020-12-03 03:16:59 +03:00
=? lul.mod.sol ?=(^ lul.job)
(smit:va "lull" pit /sys/lull/hoon u.lul.job)
=? zus.mod.sol ?=(^ zus.job)
(smit:va "zuse" lul.mod.sol /sys/zuse/hoon u.zus.job)
%- %+ need:wyrd kel.ver.zen
2020-12-03 03:16:59 +03:00
:~ lull/;;(@ud q:(slap lul.mod.sol limb/%lull))
zuse/;;(@ud q:(slap zus.mod.sol limb/%zuse))
==
2020-11-19 10:44:28 +03:00
%= ..pith
van.mod
2020-11-19 10:44:28 +03:00
%+ roll van.job
2020-12-07 04:11:38 +03:00
|= [[nam=term txt=cord] van=_van.mod.sol]
2020-11-19 10:44:28 +03:00
^+ van
2020-12-06 11:38:37 +03:00
=/ nex (create:va our zus.mod.sol nam /sys/vane/[nam]/hoon txt)
=/ nav (~(get by van) nam)
2020-11-19 10:44:28 +03:00
=? nex ?=(^ nav) (update:va vase.u.nav nex)
(~(put by van) nam (settle:va nex))
2020-11-19 10:44:28 +03:00
==
--
::
++ call
|= =waif
^+ ..pith
?^ dud ~>(%mean.'pith: goof' !!)
?- -.waif
::
:: %trim: clear state
::
:: clears compiler caches if high-priority
:: XX add separate $wasp if this should happen last
::
%trim =? van.mod =(0 p.waif)
(~(run by van.mod) |=(=vane vane(worm *worm)))
(emit $/~ (spam /arvo !>(waif)))
::
%verb ..pith(lac.fad ?~(p.waif !lac.fad u.p.waif))
2020-11-19 10:44:28 +03:00
%what ~(kel what p.waif)
%whey ..pith(out [[//arvo mass/whey] out])
::
%whiz
..pith(van.mod (~(run by van.mod) |=(vane (settle:va:part vase))))
==
::
2020-11-24 00:06:50 +03:00
++ peek
2020-12-08 00:52:12 +03:00
^- roon
2020-11-24 00:06:50 +03:00
|= [lyc=gang car=term bem=beam]
^- (unit (unit cage))
?. ?| =(our p.bem)
?=(%$ q.bem)
=([%da now] p.r.bem)
==
~
?+ s.bem ~
2020-12-04 00:56:25 +03:00
[%whey ~] ``mass/!>(whey)
[%fad %lac ~] ``noun/!>(lac.fad)
[%zen %lag ~] ``noun/!>(lag.zen)
[%zen %ver ~] ``noun/!>(ver.zen)
2022-04-23 03:55:42 +03:00
[%mod %fat *] ``noun/!>((~(dip of fat.mod) t.t.s.bem))
2020-11-24 00:06:50 +03:00
==
::
++ poke
|= =ovum
^+ ..pith
?~ wire.ovum
~>(%mean.'pith: bad wire' !!)
::
?. ?=(?(%crud %wack %wyrd) p.card.ovum)
(emit $/~ [*duct (gest ovum)] ~)
::
=/ buz ~> %mean.'pith: bad wasp'
;;(wasp card.ovum)
?- -.buz
::
:: %crud: forward error notification
::
%crud =? lag.zen ?& ?=(%exit mote.goof.buz)
?=(^ tang.goof.buz)
?=([%leaf *] i.tang.goof.buz)
?=(%wyrd (crip p.i.tang.goof.buz))
==
~&(%lagging &)
(emit $/~ [*duct hurl/[goof.buz (gest ovum.buz)]] ~)
::
:: XX review
::
%wack ..pith(eny (shaz (cat 3 eny p.buz)))
2020-11-18 02:04:26 +03:00
::
:: %wyrd: check for runtime kelvin compatibility
::
%wyrd ?. (sane:wyrd kel.p.buz)
~>(%mean.'wyrd: insane' !!)
%- %+ need:wyrd kel.p.buz
2021-07-03 00:40:55 +03:00
^- wynn
:~ hoon/hoon-version
arvo/arvo
2020-12-03 03:16:59 +03:00
lull/;;(@ud q:(slap lul.mod limb/%lull))
zuse/;;(@ud q:(slap zus.mod limb/%zuse))
==
=? lag.zen !=(rev.ver.zen rev.p.buz) ~&(%unlagging |)
..pith(ver.zen p.buz)
==
::
++ spam
|= [=wire =vase]
^- (list move)
%+ turn
%+ sort ~(tap by van.mod)
|=([[a=@tas *] [b=@tas *]] (aor a b))
|=([way=term *] `move`[*duct %pass wire way `maze`&/vase])
::
++ xeno
|= =ovum
2020-12-08 09:50:00 +03:00
^+ ..pith
..pith(out [ovum out])
--
--
--
::
++ symp :: symbol or empty
|= a=* ^- @tas
?.(&(?=(@ a) ((sane %tas) a)) %$ a)
::
++ boot
2020-11-18 02:04:26 +03:00
|= [kel=wynn hun=(unit @t) van=@t]
^- $-(heir (trap ^))
2020-12-08 09:50:00 +03:00
~> %mean.'arvo: upgrade failed'
~> %slog.[0 'arvo: beginning upgrade']
?~ hun
=/ gat
2020-12-08 09:50:00 +03:00
~> %slog.[0 'arvo: compiling next arvo']
%- road |.
(slap !>(..ride) (rain /sys/arvo/hoon van))
=/ lod
(slap (slot 7 gat) [%limb %load])
|= =heir
|. ~> %slog.[0 'arvo: +load next']
;;(^ q:(slam lod !>(heir)))
::
:: hyp: hoon core type
:: hoc: hoon core
:: cop: compiler gate
::
=/ [hyp=* hoc=* cop=*]
:: compile new hoon.hoon source with the current compiler
::
=/ raw
2020-12-08 09:50:00 +03:00
~> %slog.[0 'arvo: compiling hoon']
(road |.((ride %noun u.hun)))
:: activate the new compiler gate, producing +ride
::
=/ cop .*(0 +.raw)
:: find the kelvin version number of the new compiler
::
=/ nex
;;(@ .*(cop q:(~(mint ut p.raw) %noun [%limb %hoon-version])))
:: require single-step upgrade
::
?. |(=(nex hoon-version) =(+(nex) hoon-version))
2020-12-08 09:50:00 +03:00
=* ud |=(a=@ (scow %ud a))
~_ leaf/"cannot upgrade to hoon %{(ud nex)} from %{(ud hoon-version)}"
!!
2020-11-18 02:04:26 +03:00
:: require runtime compatibility
::
%- (need:wyrd kel [hoon/nex ~])
::
:: if we're upgrading language versions, recompile the compiler
::
=^ hot=* cop
?: =(nex hoon-version)
[raw cop]
=/ hot
2020-12-08 09:50:00 +03:00
~> %slog.[0 leaf/"arvo: recompiling hoon %{(scow %ud nex)}"]
(road |.((slum cop [%noun u.hun])))
[hot .*(0 +.hot)]
:: extract the hoon core from the outer gate (+ride)
::
=/ hoc .*(cop [%0 7])
:: compute the type of the hoon.hoon core
::
=/ hyp -:(slum cop [-.hot '+>'])
::
[hyp hoc cop]
::
:: compile arvo
::
=/ rav
2020-12-08 09:50:00 +03:00
~> %slog.[0 'arvo: compiling next arvo']
(road |.((slum cop [hyp van])))
:: activate arvo and extract the arvo core from the outer gate
::
=/ voc .*(hoc [%7 +.rav %0 7])
::
:: extract the upgrade gate +load
::
=/ lod
:: vip: type of the arvo.hoon core
:: fol: formula for the +load gate
::
=/ vip -:(slum cop [-.rav '+>'])
=/ fol +:(slum cop [vip 'load'])
:: produce the upgrade gate
::
.*(voc fol)
::
|= =heir
|. ~> %slog.[1 'arvo: +load next']
;;(^ (slum lod heir))
::
++ viol :: vane tools
|= but=type
^- vile
=+ pal=|=(a=@t ^-(type (~(play ut but) (vice a))))
2018-02-13 06:25:46 +03:00
:* typ=(pal '$:type')
duc=(pal '$:duct')
wir=(pal '$:wire')
dud=(pal '=<($ (unit goof))') :: XX misparse
==
::
2020-11-19 10:44:28 +03:00
++ grow
|= way=term
?+ way way
%a %ames
%b %behn
%c %clay
%d %dill
%e %eyre
%f %ford
%g %gall
%i %iris
%j %jael
2022-01-21 21:48:05 +03:00
%k %khan
2020-11-19 10:44:28 +03:00
==
-- =>
::
:: cached reflexives
::
=/ pit=vase !>(..part)
=/ vil=vile (viol p.pit)
::
:: arvo state, as a discriminable sample
::
=| [_arvo soul]
=* sol ->
|%
2020-12-07 10:06:20 +03:00
:: +load: upgrade from previous state
::
2020-12-07 10:06:20 +03:00
++ load :: +4
|= hir=$<(%grub heir)
^- ^
2020-05-07 11:51:08 +03:00
~| %load
:: store persistent state
::
=. sol
?- -.hir
_arvo soul.hir
==
:: clear compiler caches
::
=. van.mod (~(run by van.mod) |=(=vane vane(worm *worm)))
2020-11-18 02:04:26 +03:00
::
%- %+ need:wyrd kel.ver.zen
2021-07-03 00:40:55 +03:00
^- wynn
2020-11-18 02:04:26 +03:00
:~ hoon/hoon-version
arvo/arvo
2020-12-03 03:16:59 +03:00
lull/;;(@ud q:(slap lul.mod limb/%lull))
zuse/;;(@ud q:(slap zus.mod limb/%zuse))
2020-11-18 02:04:26 +03:00
==
:: restore working state and resume
::
=/ zef=(each (pair (list ovum) soul) (trap ^))
2020-11-24 00:06:50 +03:00
loop:(~(jump le:part [pit vil] sol) debt.hir)
?- -.zef
%& [p.p.zef ..load(sol q.p.zef)]
%| $:p.zef
==
::
:: +peek: external inspect
::
2020-12-07 10:06:20 +03:00
++ peek :: +22
2020-11-24 00:06:50 +03:00
|= $: lyc=gang
$= nom
%+ each path
2020-12-08 00:52:12 +03:00
$% [%once vis=view syd=desk tyl=spur]
[%beam vis=view bem=beam]
2020-11-24 00:06:50 +03:00
==
==
^- (unit (cask))
2020-12-08 00:52:12 +03:00
=/ hap=(unit [pat=? vis=view bem=beam])
2020-11-24 00:06:50 +03:00
?- nom
2020-12-08 00:52:12 +03:00
[%& *] ?~(mon=(de-omen p.nom) ~ `[| u.mon])
[%| %beam *] `[| vis bem]:p.nom
[%| %once *] `[& vis.p.nom [our syd.p.nom da/now] tyl.p.nom]
2020-11-24 00:06:50 +03:00
==
::
2020-11-24 00:06:50 +03:00
?~ hap ~
2020-12-08 00:52:12 +03:00
=/ pro (~(peek le:part [pit vil] sol) lyc [vis bem]:u.hap)
2020-11-24 00:06:50 +03:00
?: |(?=(~ pro) ?=(~ u.pro)) ~
=/ dat=(cask) [p q.q]:u.u.pro
?. pat.u.hap `dat
2020-12-08 00:52:12 +03:00
`[%omen (en-omen [vis bem]:u.hap) dat]
::
:: +poke: external apply
::
2020-12-07 10:06:20 +03:00
++ poke :: +23
|= [now=@da ovo=ovum]
^- ^
2020-12-09 01:49:28 +03:00
:: this assertion is not yet viable, as vere's timestamps
:: are too unreliable. sad!
::
:: ?. (gth now now.sol)
:: ~| poke/[now=now last=now.sol wire.ovo p.card.ovo]
:: ~>(%mean.'time-marches-on' !!)
::
2020-11-24 00:06:50 +03:00
=: eny.sol (shaz (cat 3 eny now)) :: XX review
now.sol now
==
::
~| poke/p.card.ovo
=/ zef=(each (pair (list ovum) soul) (trap ^))
2020-11-24 00:06:50 +03:00
loop:(~(poke le:part [pit vil] sol) ovo)
?- -.zef
%& [p.p.zef ..poke(sol q.p.zef)]
%| $:p.zef
==
::
:: +wish: external compute
::
2020-12-07 10:06:20 +03:00
++ wish :: +10
|= txt=@
q:(slap zus.mod (ream txt))
-- =>
2020-05-07 11:51:08 +03:00
::
:: larval stage
::
:: The true Arvo kernel knows who it is. It should not *maybe*
:: have an identity, nor should it contain multitudes. This outer
:: kernel exists to accumulate identity, entropy, and the
:: standard library. Upon having done so, it upgrades itself into
:: the true Arvo kernel. Subsequent upgrades will fall through
:: the larval stage directly into the actual kernel.
2019-01-18 08:37:34 +03:00
::
:: For convenience, this larval stage also supports hoon compilation
:: with +wish and vane installation with the %veer event.
::
=> |%
++ molt
|= [now=@da grub]
2020-12-08 09:50:00 +03:00
^- (unit $>(_arvo heir))
2020-12-03 03:16:59 +03:00
?. &(?=(^ who) ?=(^ eny) ?=(^ ver) ?=(^ fat) ?=(^ lul) ?=(^ zus))
2020-11-18 02:04:26 +03:00
~
2020-12-03 03:16:59 +03:00
=/ lul $:u.lul
=/ zus $:u.zus
%- %+ need:wyrd kel.u.ver
2021-07-03 00:40:55 +03:00
^- wynn
2020-11-18 02:04:26 +03:00
:~ hoon/hoon-version
arvo/arvo
2020-12-03 03:16:59 +03:00
lull/;;(@ud q:(slap lul limb/%lull))
2020-11-18 02:04:26 +03:00
zuse/;;(@ud q:(slap zus limb/%zuse))
==
=/ nav %- ~(run by van)
2020-12-06 11:38:37 +03:00
|=(a=(trap vase) (settle:va:part (slym $:a u.who)))
2020-11-24 00:06:50 +03:00
:^ ~ arvo *debt
2020-12-03 03:16:59 +03:00
[[u.who now u.eny] [lac] [u.ver |] u.fat lul zus nav]
::
++ what
=> |%
++ smit
|= [cap=tape sub=(trap vase) pax=path txt=@t]
^- (trap vase)
2020-12-08 03:22:26 +03:00
~> %slog.[0 leaf/"{cap}: {(scow p+(mug txt))}"]
%- road |.
2020-12-08 03:22:26 +03:00
~_ leaf/"{cap}: build failed"
(swat sub (rain pax txt))
--
::
2020-12-03 03:16:59 +03:00
|= [grub fil=(list (pair path (cask)))]
^- grub
=* gub +<-
=/ taf (fall fat *(axal (cask)))
=/ del (~(group adapt:part taf) fil)
=/ tub (~(usurp adapt:part taf) del)
?: &(?=(^ dir.taf) ?=(^ tub))
~>(%mean.'arvo: larval reboot' !!) :: XX support
::
:: require, and unconditionally adopt, initial kernel source
::
=? taf =(~ dir.taf) :: XX TMI
~| %larval-need-kernel
?> &(?=(^ tub) ?=(^ hun.p.u.tub))
2022-04-23 03:55:42 +03:00
(~(gas of taf) q.u.tub)
2020-12-03 03:16:59 +03:00
::
=^ job=oped:part taf (~(adorn adapt:part taf) del |)
=? lul ?=(^ lul.job)
`(smit "lull" |.(pit) /sys/lull/hoon u.lul.job)
2020-12-03 03:16:59 +03:00
=? zus ?=(^ zus.job)
?. ?=(^ lul)
~|(%larval-need-lull !!)
`(smit "zuse" u.lul /sys/zuse/hoon u.zus.job)
2020-12-03 03:16:59 +03:00
=? van !=(~ van.job) :: XX TMI
?. ?=(^ zus)
~|(%larval-need-zuse !!)
%+ roll van.job
2020-12-07 04:11:38 +03:00
|= [[nam=term txt=cord] =_van]
2020-12-03 03:16:59 +03:00
^+ van
%+ ~(put by van) nam
(smit "vane: %{(trip nam)}" u.zus /sys/vane/[nam]/hoon txt)
2020-12-03 03:16:59 +03:00
gub(fat `taf)
--
::
:: larval state, as a discriminable sample
::
=| [%grub _arvo grub]
=* gub ->+
::
|%
2020-12-07 10:06:20 +03:00
++ load :: +4
|= hir=heir
?: ?=(%grub -.hir)
~>(%mean.'arvo: larval reboot' !!) :: XX support
(^load hir)
::
2020-12-07 10:06:20 +03:00
++ peek _~ :: +22
++ poke :: +23
|= [now=@da ovo=ovum]
^- ^
2020-12-03 03:16:59 +03:00
~| poke/p.card.ovo
=/ wip
~> %mean.'arvo: bad wisp'
;;(wisp card.ovo)
::
=. ..poke
?- -.wip
%verb ..poke(lac ?~(p.wip !lac u.p.wip))
%wack ..poke(eny `p.wip)
2020-12-03 03:16:59 +03:00
%what ..poke(gub (what gub p.wip))
%whom ..poke(who ~|(%whom-once ?>(?=(~ who) `p.wip)))
2020-11-19 10:44:28 +03:00
::
%wyrd ?. (sane:wyrd kel.p.wip)
~>(%mean.'wyrd: insane' !!)
%- %+ need:wyrd kel.p.wip
2021-07-03 00:40:55 +03:00
^- wynn
:* hoon/hoon-version
arvo/arvo
2020-12-03 03:16:59 +03:00
?~ lul ~
:- lull/;;(@ud q:(slap $:u.lul limb/%lull))
?~ zus ~
[zuse/;;(@ud q:(slap $:u.zus limb/%zuse)) ~]
==
..poke(ver `p.wip)
==
::
2020-11-18 02:04:26 +03:00
:: upgrade once we've accumulated necessary state
::
2020-12-03 03:16:59 +03:00
?~ hir=(molt now gub)
[~ ..poke]
~> %slog.[0 leaf+"arvo: metamorphosis"]
2020-11-18 02:04:26 +03:00
(load u.hir)
::
2020-12-07 10:06:20 +03:00
++ wish :: +10
|= txt=*
2020-12-03 03:16:59 +03:00
q:(slap ?~(zus pit $:u.zus) (ream ;;(@t txt)))
--
::
:: Arvo formal interface
::
:: this lifecycle wrapper makes the arvo door (multi-armed core)
:: look like a gate (function or single-armed core), to fit
:: urbit's formal lifecycle function (see aeon:eden:part).
:: a practical interpreter can and will ignore it.
::
|= [now=@da ovo=ovum]
^- *
.(+> +:(poke now ovo))