shrub/sys/parv.hoon

609 lines
22 KiB
Plaintext
Raw Normal View History

2017-02-08 05:28:12 +03:00
!: :: /sys/arvo
:: :: !%reference/2
:: %arvo: arvo microkernel.
::
=< :: 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. a practical interpreter
:: can ignore it.
::
|= {now/@da ovo/ovum}
^+ .
~> %slog.[0 leaf+"arvo-event"]
.(+> +:(poke now ovo))
=>
:: :: ::
2017-02-09 05:19:39 +03:00
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (1) public molds
2017-02-08 05:28:12 +03:00
:: :: ::
|%
2017-02-09 05:19:39 +03:00
++ arms (map chip dope) :: stated identity
2017-02-08 05:28:12 +03:00
++ card {p/@tas q/*} :: tagged event
++ chip :: standard identity
$? $giv :: given name
2017-02-09 05:19:39 +03:00
$fam :: surname
2017-02-08 05:28:12 +03:00
$had :: fictitious name
$mid :: middle name
2017-02-09 05:19:39 +03:00
$gen :: generational suffix
2017-02-08 05:28:12 +03:00
== ::
2017-02-09 05:19:39 +03:00
++ dope (pair @tas @t) :: term/unicode pair
2017-02-08 05:28:12 +03:00
++ duct (list wire) :: causal history
++ ovum (pair wire card) :: input or output
2017-02-15 07:49:48 +03:00
++ plum (pair term noun) :: deep file
2017-02-08 05:28:12 +03:00
++ ruby @pG :: 64-bit passcode
++ wire path :: cause
-- =>
2017-02-09 05:19:39 +03:00
:: :: ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (2) state molds
:: :: ::
2017-02-08 05:28:12 +03:00
|%
2017-02-13 09:48:33 +03:00
++ evil :: evolvable state
|* {span/_span twig/_twig vase/_vase} :: injected molds
2017-02-09 05:19:39 +03:00
|% ::
2017-02-15 07:49:48 +03:00
++ boot (pair (unit hoof) hoof) :: hoon/arvo boot src
2017-02-13 09:48:33 +03:00
++ hoof @t :: hoon source file
2017-02-08 05:28:12 +03:00
++ mall :: any arvo version
2017-02-11 05:03:33 +03:00
$? {$293 mast} :: kelvin 293, current
2017-02-08 05:28:12 +03:00
== ::
++ mast :: system state
2017-02-11 05:03:33 +03:00
$: $= gut :: abdomen
$: run/(list move) :: worklist
2017-02-13 09:48:33 +03:00
out/(list ovum) :: unix output
but/(unit boot) :: reboot
== ::
$= hax :: thorax
$: sac/worm :: compiler cache
kit/toys :: common nouns
2017-02-08 05:28:12 +03:00
== ::
2017-02-11 05:03:33 +03:00
$= bug :: insect brain
$: noc/@ta :: process nonce
ver/(qual @tas @ud @ud @ud) :: vendor/version
== ::
2017-02-08 05:28:12 +03:00
$= mal :: mammal brain
2017-02-12 05:44:56 +03:00
$: off/? :: not yet booted
lac/? :: not verbose
2017-02-17 04:37:36 +03:00
eny/@uvJ :: 512-bit entropy
2017-02-13 09:48:33 +03:00
yor/vase :: %york, vane models
zus/vase :: %zuse, user lib
2017-02-15 07:49:48 +03:00
van/(map term (pair term vase)) :: vanes
2017-02-08 05:28:12 +03:00
== ::
$= rep :: reptile brain
$: orb/@p :: ship
nym/arms :: name information
roy/(map @ud ruby) :: start secrets
fat/(map path (pair term noun)) :: boot filesystem
== == ::
2017-02-09 05:19:39 +03:00
++ mill (each vase milo) :: vase or metavase
2017-02-08 05:28:12 +03:00
++ milo {p/* q/*} :: untyped metavase
2017-02-11 05:03:33 +03:00
++ move (pair duct part) :: vane move
2017-02-08 05:28:12 +03:00
++ part :: arvo vane move
$% {$give p/mill} :: vane "return"
2017-02-11 05:03:33 +03:00
{$pass p/wire q/(pair term mill)} :: vane "call"
2017-02-08 05:28:12 +03:00
== ::
2017-02-13 09:48:33 +03:00
++ toys :: reflexive constants
$: typ/span :: -:!>(*span)
duc/span :: -:!>(*duct)
pah/span :: -:!>(*path)
mev/span :: -:!>([%meta *vase])
== ::
2017-02-09 05:19:39 +03:00
++ worm :: compiler cache
$: nes/(set ^) :: ++nest
pay/(map (pair span twig) span) :: ++play
mit/(map (pair span twig) (pair span nock)) :: ++mint
== ::
-- ::
++ live (evil) :: modern molds
++ vile (evil typo twit vise) :: old molds
2017-02-11 05:03:33 +03:00
++ wasp :: arvo effect
2017-02-12 05:44:56 +03:00
$% {$walk ~} :: finish mammal brain
2017-02-11 05:03:33 +03:00
{$what p/(list (pair path (pair term noun)))} :: put reptile files
{$whom p/@p q/arms r/(map @ud ruby)} :: put reptile identity
2017-02-12 05:44:56 +03:00
{$woke ~} :: finish booting
2017-02-11 05:03:33 +03:00
== ::
2017-02-08 05:28:12 +03:00
-- =>
2017-02-09 05:19:39 +03:00
|%
2017-02-08 05:28:12 +03:00
:: :: ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (2) engines
:: :: ::
|%
2017-02-09 05:19:39 +03:00
:: :: ++le
++ le :: deep engine
2017-02-13 09:48:33 +03:00
=+ [now=*@da mast:live]
2017-02-12 05:44:56 +03:00
=* ::
:: sys: system state
::
2017-02-13 09:48:33 +03:00
sys ->
2017-02-09 05:19:39 +03:00
|%
2017-02-12 05:44:56 +03:00
:: :: ++abet:le
2017-02-13 09:48:33 +03:00
++ abet :: complete cycle
^- {(pair (unit (pair @t @t)) (list move)) _sys}
:- [but.gut flop
[[but.gut (flop out.gut) sys(out.gut ~)]
2017-02-12 05:44:56 +03:00
:: :: ++emit:le
2017-02-13 09:48:33 +03:00
++ emit :: emit move
|= mov/move
+>(run.gut [mov run.gut])
2017-02-11 05:03:33 +03:00
:: :: ++pike:le
2017-02-12 05:44:56 +03:00
++ pike :: event to %pass
2017-02-09 05:19:39 +03:00
|= $: :: lay: event route
:: now: date
2017-02-13 09:48:33 +03:00
:: ovo: input ovum
2017-02-09 05:19:39 +03:00
::
lay/@tas
now/@da
2017-02-13 09:48:33 +03:00
ovo/ovum
2017-02-09 05:19:39 +03:00
==
2017-02-12 05:44:56 +03:00
^+ +>
:: print event if in verbose mode
2017-02-11 05:03:33 +03:00
::
~? &(!lac.mal !=(%belt -.q.ovo)) [%unix -.q.ovo p.ovo]
::
2017-02-13 09:48:33 +03:00
:: vax: card as vase
::
=^ vax +> (open q.ovo)
::
:: hen: fundamental cause (unix input channel)
:: tea: local cause (unix i/o)
:: mov: action (pass into event route)
2017-02-11 05:03:33 +03:00
::
2017-02-13 09:48:33 +03:00
=* hen `duct`[p.ovo ~]
=* tea `wire`[%$ %unix ~]
=* mov `move`[%pass tea lay %& vax]
2017-02-12 05:44:56 +03:00
::
2017-02-13 09:48:33 +03:00
:: push move on stack
2017-02-12 05:44:56 +03:00
::
2017-02-13 09:48:33 +03:00
(emit mov)
2017-02-12 05:44:56 +03:00
:: :: ++open:le
++ open :: input card to move
2017-02-13 09:48:33 +03:00
|= fav/card
2017-02-12 05:44:56 +03:00
^- {vase _+>}
?< off.mal
2017-02-13 09:48:33 +03:00
::
:: gat: mold for correct unix task
:: vax: molded card
::
=^ gat sac.gut (~(slap wa sac.gut) bud.mal [%limb %unix-task])
=/ vax (slam gat [%noun fav])
~| [%le-open -.fav]
?> =(fav q.vax)
2017-02-12 05:44:56 +03:00
[vax +>.$]
2017-02-09 05:19:39 +03:00
:: :: ++poke:le
++ poke :: event from unix
|= $: :: now: event date
:: ovo: event
::
now/@da
ovo/ovum
==
^+ sys
2017-02-12 05:44:56 +03:00
~| [%poke -.ovo]
2017-02-09 21:39:36 +03:00
::
2017-02-12 05:44:56 +03:00
:: the event is either vane input or an arvo action (wasp).
:: we default to treating it as a wasp.
2017-02-11 05:03:33 +03:00
::
2017-02-13 09:48:33 +03:00
:: XX: this logic will be directed in the event structure itself.
::
2017-02-12 05:44:56 +03:00
?+ -.ovo
2017-02-13 09:48:33 +03:00
=/ wap ((hard wasp) ovo)
=* tea `wire`[%$ %init ~]
=* hen `duct`[tea [p.ovo ~]]
=* mov `move`[hen %give %& !>(wap)]
(emit mov)
2017-02-11 05:03:33 +03:00
::
2017-02-12 05:44:56 +03:00
$belt (pike %d now ovo)
$blew (pike %d now ovo)
$born (pike %e now ovo)
$hail (pike %d now ovo)
$hear (pike %a now ovo)
$hook (pike %d now ovo)
$into (pike %c now ovo)
$they (pike %e now ovo)
$this (pike %e now ovo)
$thus (pike %e now ovo)
2017-02-09 05:19:39 +03:00
==
2017-02-17 04:37:36 +03:00
:: :: ++va:le
++ va :: vane engine
|_ $: :: lay: short name, eg %a
:: way: long name, eg %ames
:: vax: vane or vane builder
::
lay/term
way/term
vax/vase
==
:: :: ++va-abet:va:le
++ va-abet :: resolve
^+ ..va
..va(van.mal (~(put by van.mal) lay [way vax]))
:: :: ++va-abut:va:le
++ va-abut :: deploy
^+ +>
+>(+< [lay (~(got by van.mal) lay))
:: :: ++va-apex:va:le
++ va-apex :: boot/reboot
|= src/hoof
^+ +>
=+ bun=(~(get by van.mal) lay)
?~ bun
(va-create src)
(va-update(vax u.bun) src)
2017-02-18 05:10:32 +03:00
:: :: ++va-active:va:le
++ va-active :: make activated vane
|= {ski
2017-02-17 04:37:36 +03:00
:: :: ++va-create:va:le
++ va-create :: compile new vase
|= src/hoof
2017-02-18 05:10:32 +03:00
^+ +>
2017-02-17 04:37:36 +03:00
:: no existing vase; compile new vase
::
~& [%vase-compile lay way `@p`(mug src)]
=. vax (slam zus.mal (ream src))
2017-02-18 05:10:32 +03:00
?: off
:: not booted yet, wait to activate
+>
:: already booted; activate now
::
+>(vax (slam vax !>(orb.rep)))
:: :: ++va-settle:va:le
++ va-settle :: initialize ship
^+ +>
.(vax (slap vax !>(orb.rep)))
:: :: ++va-update
++ va-update :: replace existing
|= src/hoof
?: off
:: replacing unbooted, weird
::
(va-create src)
=+ nex=(slap (slam zus.mal (ream src)) !>(orb.rep))
2017-02-17 04:37:36 +03:00
--
:: :: ++vale:le
++ vale :: load existing vane
|= lay/term
~(. va lay (~(got by van.mal lay)))
2017-02-15 07:49:48 +03:00
:: :: ++warp:le
++ warp :: arvo effect
|= {hen/duct wap/wasp}
^+ +>
?+ -.wap !!
$what (what hen p.wap)
$whom (whom hen p.wap q.wap r.wap)
==
:: :: ++wilt:le
++ wilt :: deep file as source
|= pet/plum
^- hoof
?>(?=({$hoon @tas} pet) +.pet)
:: :: ++wise:le
++ wise :: load/reload vane
2017-02-17 04:37:36 +03:00
|= {lay/term way/term src/hoof}
2017-02-15 07:49:48 +03:00
^+ +>
2017-02-17 04:37:36 +03:00
=+ bun=(~(get by van) lay)
?~ bun
::
:: no existing vase; compile new vase
::
~& [%vase-compile lay way `@p`(mug src)]
=+ vax=(slam zus.mal (ream src))
::
:: if we are already live, activate new vase
::
2017-02-15 07:49:48 +03:00
:: :: ++what:le
++ what :: write deep storage
|= {hen/duct fal/(list (pair path plum))}
^+ +>
:: dev: collated `fal`
::
=+ =| dev
$: :: use: non-system files
:: new: system installs
:: rep: system replacements
::
use/(map path plum)
new/(map path plum)
rez/(map path plum)
==
|- ^+ dev
?~ fal dev
::
:: pax: path of this file
:: pet: value of this file
::
=+ [pax pet]=[p q]:i.fal
=. fal t.fal
::
:: old: current value in deep storage
::
=+ old=(~(get by fat.rep) pax)
::
:: ignore unchanged data
::
?: =(old `pet) $
::
:: classify as user, system install or replacement
::
?. ?=({$sys *} pax)
$(use (~(put by use.dev) pax pet)
?~ old
$(new (~(put by new.dev) pax pet))
$(rez (~(put by rez.dev) pax pet))
::
:: adopt user changes, which have no systems impact
::
=. fat.rep (~(uni by fat.rep) use.rez)
::
:: but: kernel reboot operation, if any
::
=/ but
^- (unit boot)
=/ hun=(~(get by rez.dev) /sys/hoon)
=/ arv=(~(get by rez.dev) /sys/arvo)
?~ hun
?~ arv ~
::
:: light reboot, arvo only
::
`[~ (wilt u.arv)]
::
:: heavy reboot, hoon and arvo
::
`[`(wilt hun) (wilt q:?^(arv u.arv (~(got by fat.rep) /sys/arvo)))]
?^ but
:: stop working and set up reboot
::
%= +>.$
:: set boot hook for termination
::
but.gut ?>(=(~ but.gut) but)
::
2017-02-17 04:37:36 +03:00
:: execute write after reboot
2017-02-15 07:49:48 +03:00
::
2017-02-17 04:37:36 +03:00
run.rep :: syt: all systems changes
::
=* syt (~(tap by (~(uni by rez.dev) new.dev)))
:_ run.rep
`move`[hen %give %& !>([%what syt])]
2017-02-15 07:49:48 +03:00
::
:: delete reboot source files from deep
:: storage, so install causes vane upgrade,
:: and *does not* cause repeat kernel upgrade.
::
fat.rep ?~ p.but fat.rep
(~(del by (~(del by fat.rep) /sys/hoon) /sys/arvo))
==
2017-02-17 04:37:36 +03:00
:: keep working after vane upgrades
2017-02-15 07:49:48 +03:00
::
=< work
::
:: job: plan for upgrading
::
=/ job
^- $: yor/(unit hoof)
zus/(unit hoof)
van/(list (trel @tas @tas hoof))
==
=- [yor zus van]
:: yor: reload shared structures
:: zus: reload shared library
::
=/ yor (bind (~(get by rez.dev) /sys/york) wilt)
=/ zus (bind (~(get by rez.dev) /sys/zuse) wilt)
::
:: %york is the subject of %zuse
::
=. zus ?^(zus zus ?~(yor ~ `(wilt (~(get by fat.rep) /sys/zuse))))
::
:: van: all vane upgrades, as [initial name source]
::
=/ van
:: zyr: all system file replacements
::
2017-02-17 04:37:36 +03:00
=/ rad
2017-02-15 07:49:48 +03:00
=/ zyr (~(tap by rez.dev))
|- ^- (list (pair @tas hoof))
?^ zyr
:: mor: process rest of `zyr`
::
=/ mor $(zyr t.zyr)
?. ?=({$sys $van @tas $~} p.i.zyr)
mor
::
:: replaced vane in `/sys/vane/*/[nam]`
::
=* nam `term`i.t.t.p.i.zyr
:_(mor [(end 3 1 nam) nam (wilt q.i.zyr)])
::
2017-02-17 04:37:36 +03:00
:: reload compiled vanes if needed
2017-02-15 07:49:48 +03:00
::
2017-02-17 04:37:36 +03:00
?. |((~(has by new.dev) /sys/hoon) ?=(^ zus))
::
:: we didn't replace compiler, %york or %zuse
~
2017-02-15 07:49:48 +03:00
::
2017-02-17 04:37:36 +03:00
:: get source code for current running vanes
2017-02-15 07:49:48 +03:00
::
2017-02-17 04:37:36 +03:00
%+ turn (~(tap by van.mal))
|= {lay/term way/term vax/vase}
[lay way (wilt (~(got by fat.rep) [%sys %van way ~]))
2017-02-15 07:49:48 +03:00
::
:: upgrade %york, vane shared structures
::
=> ?~ yor .
%= .
2017-02-17 04:37:36 +03:00
yor.mal ~& [%york-boot `@p`(mug u.yor.job)]
2017-02-15 07:49:48 +03:00
(slap !>(..arms) (ream u.yor.job))
==
::
:: upgrade %zuse, vane shared libraries
::
=> ?~ zus .
%= .
2017-02-17 04:37:36 +03:00
zus.mal ~& [%zuse-boot `@p`(mug u.zus.job)]
2017-02-15 07:49:48 +03:00
(slap yor.mal (ream u.zus.job))
==
::
:: upgrade all indicated vanes
::
|- ^+ +>.^$
?~ van.job +>.^$
2017-02-17 04:37:36 +03:00
~& [%vane-boot p.i.van.job `@p`(mug q.i.van.job)]
2017-02-15 07:49:48 +03:00
$(van.job t.van.job, +>.^$ (wise i.van.job))
2017-02-13 09:48:33 +03:00
:: :: ++work:le
++ work :: main loop
=* ken +
^+ ken
::
:: terminate when stack is empty
::
?~ run.gut ken
::
:: mov: top move on stack
:: hen: cause of move
:: act: action in move
::
=* mov `move`i.run.gut
=* hen `duct`p.mov
=* egg `part`q.mov
::
:: pop top move off stack
::
=. run.gut t.run.gut
::
:: interpret top move
::
?- -.egg
::
:: %give: event return
::
$give
::
:: the duct can't be empty
::
?> ?=(^ p.mov)
::
:: tea: top wire on duct
:: hen: rest of duct
::
=/ tea i.p.mov
=* hen t.p.mov
::
:: route gift by wire
::
?: ?=({%$ *} tea)
::
:: gift returned on arvo wire
::
?: ?=({%unix $~} t.tea)
::
:: gift returned to unix i/o
::
(unix hen XXp.egg)
?> ?=({%arvo $~} t.tea)
::
:: gift returned to arvo control
::
(wasp hen XXp.egg)
::
:: gift returned to calling vane
::
?> ?=({@tas *} tea)
(read hen i.tea t.tea p.egg)
::
:: %pass: event call
::
$pass
(send [p.egg hen] p.q.egg q.egg)
==
2017-02-11 05:03:33 +03:00
2017-02-13 09:48:33 +03:00
::
:: $whom: install identity information and complete boot process
::
$whom
=* mol $: orb/@p
nym/arms
roy/(map @ud ruby)
==
=+ dat=((hard mol) +.ovo)
=: orb.rep orb.dat
nym.rep nym.dat
roy.rep (~(uni by roy.rep) roy.rep roy.dat)
==
!!
==
:: :: ++we-gift:work:le
++ we-gift
|= $: :: hen: cause
:: lay: vane to return to
:: hil:
::
hen/duct
lay/term
hil/mill
==
^+ ken
!!
++ we-wasp
|= $: :: hen: cause
::
^_
++ we-
--
2017-02-09 05:19:39 +03:00
--
2017-02-08 05:28:12 +03:00
--
:: :: ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: (3) surface
:: :: ::
|_
:: :: ++come
++ come :: upgrade from old
|=
^- {(list ovum) _+>}
~& %hoon-come
=^ rey +>+ (^come +<)
[rey +>.$]
::
++ keep |=(* (^keep ((hard {@da path}) +<))) :: 4
++ load |= {@ (list ovum) pane} :: 86
^- {(list ovum) _+>}
~& %hoon-load
=^ rey +>+ (^load +<)
[rey +>.$]
++ peek |=(* (^peek ((hard {@da path}) +<))) :: 87
++ poke |= * :: 42
^- {(list ovum) *}
=> .(+< ((hard {now/@da ovo/ovum}) +<))
=^ ova +>+ (^poke now ovo)
|- ^- {(list ovum) *}
?~ ova
[~ +>.^$]
?: ?=($verb -.q.i.ova)
$(ova t.ova, lac !lac)
?: ?=($veer -.q.i.ova)
$(ova t.ova, +>+.^$ (veer now q.i.ova))
?: ?=($velo -.q.i.ova)
(fall (velo now t.ova ({@ @} +.q.i.ova)) [~ +>.^$])
?: ?=(?($init $veal) -.q.i.ova)
=+ avo=$(ova t.ova, +>+.^$ (boot (@ +.q.i.ova)))
[[i.ova -.avo] +.avo]
?: ?=($mass -.q.i.ova)
=+ avo=$(ova t.ova)
:_ +.avo
:_ -.avo
%= i.ova
q.q
:- %userspace
:- %|
:~ hoon+`pit
zuse+`mast
hoon-cache+`p.niz
q.q.i.ova
dot+`.
==
==
=+(avo=$(ova t.ova) [[i.ova -.avo] +.avo])
++ wish |=(* (^wish ((hard @ta) +<))) :: 20
--