diff --git a/.travis/pin-vere-commit.txt b/.travis/pin-vere-commit.txt index 8a2bb70ed..cf724bb3a 100644 --- a/.travis/pin-vere-commit.txt +++ b/.travis/pin-vere-commit.txt @@ -1 +1 @@ -051f31b31e45c57aee5542522c5c38e146f3e012 +315634d99b0a0d7760267eacc0b32465e03ea981 diff --git a/.travis/test.js b/.travis/test.js index 8b0c14ea5..0e9324826 100644 --- a/.travis/test.js +++ b/.travis/test.js @@ -9,7 +9,7 @@ var actions = runner.actions var args = ['-B', 'urbit.pill', '-A', '..', '-cSF', 'zod', 'zod']; var urbit = new Urbit(args); -// XX upstream the following into runner-js +// XX upstream this into runner-js // function rePill(urb) { return new Promise(function(resolve,reject){ @@ -59,6 +59,11 @@ function rePill(urb) { return read.pipe(write) }) + // XX find a better way to add this to the promise chain + // + .then(function(){ + return barMass(urb); + }) .catch(function(err){ return reject(err) }); @@ -67,6 +72,16 @@ function rePill(urb) { }) } +// XX upstream this into runner-js +// +function barMass(urb) { + return urb.line("|mass") + .then(function(){ + return urb.expectEcho("%ran-mass") + .then(function(){ return urb.resetListeners(); }) + }) +} + Promise.resolve(urbit) // XX temporary // send ctrl-x to select dojo @@ -79,15 +94,14 @@ Promise.resolve(urbit) .then(function() { return urbit }) }) .then(actions.safeBoot) +.then(function(){ + return barMass(urbit); +}) .then(actions.test) .then(actions.testCores) .then(actions.testRenderers) .then(function(){ - return urbit.line("|mass") - .then(function(){ - return urbit.expectEcho("%ran-mass") - .then(function(){ return urbit.resetListeners(); }) - }) + return barMass(urbit); }) .then(function(){ return rePill(urbit); diff --git a/app/dojo.hoon b/app/dojo.hoon index 0f1b89be9..e85e9be2d 100644 --- a/app/dojo.hoon +++ b/app/dojo.hoon @@ -54,7 +54,6 @@ {$poke p/goal} :: poke app {$show p/?($0 $1 $2 $3 $4 $5)} :: val/type/hoon/xray {$verb p/term} :: store variable - {$help p/(list term)} :: look up help == :: ++ dojo-source :: construction node $: p/@ud :: assembly index @@ -137,221 +136,217 @@ :: [%incomplete =tang] == == - {$unto p/cuft:gall} :: - == :: - -- :: -:: :: -:::: :: - :: :: -=, gall -=+ foo=*monkey -|_ $: hid/bowl :: system state - house :: program state - == :: -++ he :: per session - |_ {moz/(list move) session} :: - ++ dp :: dojo parser - |% - ++ dp-default-app %hood - ++ dp-message :: %poke - |= {gol/goal mod/dojo-model} ^- dojo-command - [[%poke gol] [0 [%ge mod(q.p [q.gol q.p.mod])]]] - :: - ++ dp-command-line ;~(sfix dp-command (star ace) (just '\0a')) - ++ dp-variable :: %verb or %brev - |* {sym/rule src/rule} - %+ cook - |= {a/term b/(unit dojo-source)} - ^- dojo-command - ?~(b [%brev a] [[%verb a] u.b]) - ;~(plug sym (punt src)) + {$unto p/cuft:gall} + == + -- +=> +|% +:: |parser-at: parsers for dojo expressions using :dir as working directory +:: +++ parser-at + |= [our=ship dir=beam] + |% + ++ default-app %hood + ++ hoon-parser (vang | (en-beam:format dir)) + ++ our p.dir + :: + ++ parse-command-line ;~(sfix parse-command (star ace) (just '\0a')) + :: + ++ to-command + |= [gol=goal mod=dojo-model] + ^- dojo-command + [[%poke gol] [0 [%ge mod(q.p [q.gol q.p.mod])]]] + :: + ++ parse-variable + |* [sym=rule src=rule] + %+ cook + |= {a/term b/(unit dojo-source)} + ^- dojo-command + ?~(b [%brev a] [[%verb a] u.b]) + ;~(plug sym (punt src)) + :: + ++ parse-command + :: =< ;~(less |-(;~(pose (jest '|*') ;~(pfix next (knee ** |.(^$))))) .) + %+ knee *dojo-command |. ~+ + ;~ pose + ;~ pfix bar + %+ cook to-command + (stag `goal`[our default-app] parse-model) + == :: - ++ dp-command :: ++dojo-command - :: =< ;~(less |-(;~(pose (jest '|*') ;~(pfix next (knee ** |.(^$))))) .) - %+ knee *dojo-command |. ~+ - ;~ pose - ;~ pfix bar - %+ cook dp-message - (stag [our.hid dp-default-app] dp-model) - == - :: - ;~ pfix col - %+ cook - |= {a/goal b/$^(dojo-model dojo-source)} - ?@ -.b [[%poke a] b] - (dp-message a b) - ;~ plug - dp-goal - ;~ pose - ;~(pfix bar dp-model) - ;~(pfix ace dp-source) - == - == - == - :: - ;~ pfix tis - ;~ pose - (dp-variable (jest %dir) ;~(pfix ace :(stag 0 %ex dp-rood))) - (dp-variable sym ;~(pfix ace dp-source)) - == - == - :: - ;~ pfix net - ;~ pose - (dp-variable (cold %sur hep) ;~(pfix gap parse-cables)) - (dp-variable (cold %lib lus) ;~(pfix gap parse-cables)) - == - == - :: - ;~ pfix hax + ;~ pfix col + %+ cook + |= {a/goal b/$^(dojo-model dojo-source)} + ?@ -.b [[%poke a] b] + (to-command a b) + ;~ plug + parse-goal ;~ pose - ;~ pfix ace - %+ cook - |= a/(list term) - [[%help a] 0 %ex [%cnts p=~[[%.y p=1]] q=~]] - (most col sym) - == - (easy [[%help ~] 0 %ex [%cnts p=~[[%.y p=1]] q=~]]) + ;~(pfix bar parse-model) + ;~(pfix ace parse-source) == == - :: - ;~((glue ace) dp-sink dp-source) - (stag [%show %0] dp-source) == - ++ dp-sink - ;~ pose - ;~(plug (cold %file tar) dp-beam) - ;~(plug (cold %flat vat) (most net sym)) - ;~(plug (cold %pill dot) (most net sym)) - ;~(plug (cold %http lus) (stag %post dp-iden-url)) - ;~(plug (cold %http hep) (stag %put dp-iden-url)) - (stag %show (cook $?($1 $2 $3 $4 $5) (cook lent (stun [1 5] wut)))) - == - :: - ++ parse-cables - %+ cook - |= cables=(list cable:ford) - :+ 0 %ex - ^- hoon - :: - :- %clsg - %+ turn cables - |= cable=cable:ford - ^- hoon - :: - :+ %clhp - ?~ face.cable - [%rock %n ~] - [%clhp [%rock %n ~] [%sand %tas u.face.cable]] - [%sand %tas file-path.cable] - (most ;~(plug com gaw) parse-cable) - :: +cable: parses a +^cable, a reference to something on the filesystem - :: - :: This parses: - :: - :: `library` -> wraps `library` around the library `library` - :: `face=library` -> wraps `face` around the library `library` - :: `*library` -> exposes `library` directly to the subject :: - :: NOTE: This is a verbatim duplicate of Ford's cable parsing - :: - ++ parse-cable - %+ cook |=(a=cable:ford a) - ;~ pose - (stag ~ ;~(pfix tar sym)) - (cook |=([face=term tis=@ file=term] [`face file]) ;~(plug sym tis sym)) - (cook |=(a=term [`a a]) sym) + ;~ pfix tis + ;~ pose + (parse-variable (jest %dir) ;~(pfix ace :(stag 0 %ex parse-rood))) + (parse-variable sym ;~(pfix ace parse-source)) + == == :: - ++ dp-hoon-punt :: hoon of unit - |*(a/rule ;~(pose (stag [%bust %null] a) (easy [%bust %null]))) - :: - ++ dp-case-hoon - |= a/coin ^- (unit hoon) - ?. ?=({~ case} a) ~ - %+ some - [%rock %tas p.p.a] - [%sand p.a] + ;~ pfix net + ;~ pose + (parse-variable (cold %sur hep) ;~(pfix gap parse-cables)) + (parse-variable (cold %lib lus) ;~(pfix gap parse-cables)) + == + == :: - ++ dp-source (stag 0 dp-build) :: ++dojo-source - ++ dp-build :: ++dojo-build + ;~((glue ace) parse-sink parse-source) + (stag [%show %0] parse-source) + == + :: + ++ parse-sink + ;~ pose + ;~(plug (cold %file tar) parse-beam) + ;~(plug (cold %flat vat) (most net sym)) + ;~(plug (cold %pill dot) (most net sym)) + ;~(plug (cold %http lus) (stag %post parse-iden-url)) + ;~(plug (cold %http hep) (stag %put parse-iden-url)) + (stag %show (cook $?($1 $2 $3 $4 $5) (cook lent (stun [1 5] wut)))) + == + :: + ++ parse-cables + %+ cook + |= cables=(list cable:ford) + :+ 0 %ex + ^- hoon + :: + :- %clsg + %+ turn cables + |= cable=cable:ford + ^- hoon + :: + :+ %clhp + ?~ face.cable + [%rock %n ~] + [%clhp [%rock %n ~] [%sand %tas u.face.cable]] + [%sand %tas file-path.cable] + (most ;~(plug com gaw) parse-cable) + :: + ++ parse-cable + %+ cook |=(a=cable:ford a) + ;~ pose + (stag ~ ;~(pfix tar sym)) + (cook |=([face=term tis=@ file=term] [`face file]) ;~(plug sym tis sym)) + (cook |=(a=term [`a a]) sym) + == + ++ parse-source (stag 0 parse-build) + ++ parse-build %+ knee *dojo-build |. ~+ ;~ pose - ;~(plug (cold %ur lus) dp-iden-url) - ;~(plug (cold %ge lus) dp-model) - ;~(plug (cold %as pad) sym ;~(pfix ace dp-source)) - ;~(plug (cold %do cab) dp-hoon ;~(pfix ace dp-source)) - dp-value + ;~(plug (cold %ur lus) parse-iden-url) + ;~(plug (cold %ge lus) parse-model) + ;~(plug (cold %as pad) sym ;~(pfix ace parse-source)) + ;~(plug (cold %do cab) parse-hoon ;~(pfix ace parse-source)) + parse-value == - :: - ++ dp-goal :: ++goal - %+ cook |=(a/goal a) - ;~ pose - ;~ plug - ;~(pfix sig fed:ag) - ;~(pose ;~(pfix net sym) (easy dp-default-app)) - == - %+ stag our.hid - ;~(pose sym (easy dp-default-app)) + :: + ++ parse-goal + %+ cook |=(a/goal a) + ;~ pose + ;~ plug + ;~(pfix sig fed:ag) + ;~(pose ;~(pfix net sym) (easy default-app)) == - ++ dp-beam :: ++beam - %+ cook - |= a/path - :: hack: fixup paths that come out of the hoon parser - :: - :: We currently invoke the hoon parser to read relative paths from - :: the command line, and this parser will produce leading ~ path - :: components with paths that start with a `/`. - :: - :: This entire path is nuts and we shouldn't be representing paths - :: as arbitrary hoons. - :: - =? a &(?=(^ a) =('' i.a)) - t.a - =+((de-beam:format a) ?^(- u [he-beak (flop a)])) - =+ vez=(vang | dp-path) - (sear plex:vez (stag %clsg poor:vez)) + %+ stag our + ;~(pose sym (easy default-app)) + == + :: + ++ parse-beam + %+ cook + |= a=path + :: hack: fixup paths that come out of the hoon parser + :: + :: We currently invoke the hoon parser to read relative paths from + :: the command line, and this parser will produce leading ~ path + :: components with paths that start with a `/`. + :: + :: This entire path is nuts and we shouldn't be representing paths + :: as arbitrary hoons. + :: + =? a &(?=(^ a) =('' i.a)) + t.a + (fall (de-beam:format a) [`beak`[p q r]:dir (flop a)]) + =+ vez=hoon-parser + (sear plex:vez (stag %clsg poor:vez)) + :: + ++ parse-iden-url + %+ cook + |=([a=(unit knot) b=purl:eyre] [`(fall a *knot) b]) + auru:de-purl:html + :: + ++ parse-model ;~(plug parse-server parse-config) + ++ parse-server (stag 0 (most net sym)) + ++ parse-hoon tall:hoon-parser + :: + ++ parse-rood + :: XX should this use +hoon-parser instead to normalize the case? :: - ++ dp-iden-url - %+ cook - |=({a/(unit knot) b/purl:eyre} [`(fall a *knot) b]) - auru:de-purl:html + => (vang | (en-beam:format dir)) + ;~ pose + rood :: - ++ dp-model ;~(plug dp-server dp-config) :: ++dojo-model - ++ dp-path (en-beam:format he-beam) :: ++path - ++ dp-server (stag 0 (most net sym)) :: ++dojo-server - ++ dp-hoon tall:(vang | dp-path) :: ++hoon - ++ dp-rood :: 'dir' hoon - => (vang | (en-beam:format dir)) - ;~ pose - rood + :: XX refactor ++scat :: - =- ;~(pfix cen (stag %clsg -)) :: XX refactor ++scat - %+ sear |=({a/@ud b/tyke} (posh ~ ~ a b)) - ;~ pose - porc - (cook |=(a/(list) [(lent a) ~]) (star cen)) - == - == - ++ dp-value :: ++dojo-source + =- ;~(pfix cen (stag %clsg -)) + %+ sear |=([a=@ud b=tyke] (posh ~ ~ a b)) ;~ pose - (stag %sa ;~(pfix tar pad sym)) - (stag %ex dp-hoon) - (stag %tu (ifix [lac rac] (most ace dp-source))) + porc + (cook |=(a=(list) [(lent a) ~]) (star cen)) == - :: - ++ dp-config :: ++dojo-config + == + ++ parse-value + ;~ pose + (stag %sa ;~(pfix tar pad sym)) + (stag %ex parse-hoon) + (stag %tu (ifix [lac rac] (most ace parse-source))) + == + :: + ++ parse-config + ;~ plug + (star ;~(pfix ace (stag 0 parse-value))) + %+ cook + ~(gas by *(map term (unit dojo-source))) + %- star ;~ plug - (star ;~(pfix ace (stag 0 dp-value))) - %+ cook - ~(gas by *(map term (unit dojo-source))) - %- star - ;~ plug - ;~(pfix com ace tis sym) - (punt ;~(pfix ace (stag 0 dp-value))) - == + ;~(pfix com ace tis sym) + (punt ;~(pfix ace (stag 0 parse-value))) == - -- + == + -- +-- +:: :: +:::: :: + :: :: +=, gall +=+ foo=*monkey +|_ $: hid/bowl :: system state + house :: program state + == :: +++ he :: per session + |_ {moz/(list move) session} :: + :: + ++ he-beam + ^- beam + ?. =([%ud 0] r.dir) + dir + dir(r [%da now.hid]) + :: + ++ he-disc `disc:ford`[p q]:he-beam + ++ he-beak `beak`[p q r]:he-beam + ++ he-rail `rail:ford`[[p q] s]:he-beam + ++ he-parser (parser-at our.hid he-beam) :: ++ dy :: project work |_ dojo-project :: @@ -568,9 +563,6 @@ =- +>(..dy (he-diff %tan - ~)) rose+[" " `~]^~[leaf+"=%" (smyt (en-beam:format he-beak s.dir))] == - :: - $help - (dy-inspect +.p.mad p.q.cay) :: $poke %- he-card(poy ~) @@ -612,7 +604,9 @@ ?- p.p.mad %0 ~ %1 [[%rose [~ " " ~] (skol p.q.cay) ~] maar] - %2 [[%rose [~ " " ~] (dy-show-type-noun p.q.cay) ~] maar] + :: XX actually print something meaningful here + :: + %2 [[%rose [~ " " ~] *tank ~] maar] %3 ~ %4 ~ %5 [[%rose [~ " " ~] (xskol p.q.cay) ~] maar] @@ -660,638 +654,6 @@ t=(turn `wain`?~(r.hit ~ (to-wain:format q.u.r.hit)) trip) == :: - ++ dy-inspect - |= {topic/(list term) sut/type} - %+ dy-rash %tan - |^ ^- tang - =+ to-display=(find-item-in-type (flop topic) sut) - ?~ to-display - [%leaf "Could not find help"]~ - (flop (print-item u.to-display)) - :: # %models - +| %models - :: - :: an overview of all named things in the type. - :: - :: each item in the overview list is either a documentation for a sublist - :: or an association between a term and documentation for it. - ++ overview (list overview-item) - :: - :: in instance in the ++overview list. - ++ overview-item - $% :: a header {doc} which will indent its {children}. - {$header doc/what children/overview} - :: an item in a list with {name} and {docs}. - {$item name/tape doc/what} - == - :: - :: the part of a {type} being inspected. - ++ item - $~ [%view ~] - $% :: overview of type - {$view items/overview} - :: inspecting a full core. - $: $core - name/tape - docs/what - sut/type - con/coil - children/(unit item) - == - :: inspecting a single arm on a core. - $: $arm - name/tape - docs/what - f/foot - sut/type - == - :: inspecting a single chapter on a core. - $: $chapter - name/tape - docs/what - sut/type - con/coil - chapter-id/@ - == - :: inspecting a face and what's behind it. - $: $face - name/tape - docs/what - children/(unit item) - == - == - :: # - :: # %searching - :: # - :: functions which find what to print - +| %searching - :: returns the item to print while searching through {topic}. - :: - :: this gate is called recursively to find the path {topic} in the type - :: {sut}. once it finds the correct part of the type, it switches to - :: ++build-inspectable-recursively to describe that part of the type. - ++ find-item-in-type - |= {topics/(list term) sut/type} - ^- (unit item) - ~ -:: ?~ topics -:: :: we have no more search path. return the rest as an overview -:: (build-inspectable-recursively sut) -:: ?- sut -:: {$atom *} ~ -:: :: -:: {$cell *} -:: =+ lhs=$(sut p.sut) -:: ?~ lhs -:: $(sut q.sut) -:: lhs -:: :: -:: {$core *} -:: =+ core-docs=r.q.sut -:: ?~ p.core-docs -:: :: todo: this core has no toplevel documentation. it might have -:: :: an arm though. check that next. -:: $(sut p.sut) -:: ?: !=(i.topics u.p.core-docs) -:: :: the current topic isn't the toplevel core topic. -:: =+ arm=(find-arm-in-coil i.topics q.sut) -:: ?~ arm -:: :: the current topic is neither the name of the core or an arm -:: :: on the core. -:: $(sut p.sut) -:: `[%arm (trip i.topics) p.u.arm q.u.arm p.sut] -:: ?~ t.topics -:: :: we matched the core name and have no further search terms. -:: =* compiled-against (build-inspectable-recursively p.sut) -:: `[%core (trip i.topics) q.core-docs p.sut q.sut compiled-against] -:: :: search the core for chapters. -:: =/ tombs/(list (pair @ tomb)) ~(tap by q.s.q.sut) -:: |- -:: ^- (unit item) -:: ?~ tombs -:: ~ -:: ?~ p.p.q.i.tombs -:: :: this has no chapter name. -:: $(tombs t.tombs) -:: ?: !=(i.t.topics u.p.p.q.i.tombs) -:: :: this isn't the topic. -:: $(tombs t.tombs) -:: `[%chapter (trip i.t.topics) q.p.q.i.tombs sut q.sut p.i.tombs] -:: :: -:: {$face *} -:: ?. ?=(term q.p.sut) -:: :: todo: is there something we could do if we have a tune? -:: ~ -:: ?. =(i.topics q.p.sut) -:: :: this face has a name, but it's not the name we're looking for. -:: ~ -:: ?~ t.topics -:: `[%face (trip q.p.sut) p.p.sut (build-inspectable-recursively q.sut)] -:: (find-item-in-type t.topics q.sut) -:: :: -:: {$fork *} -:: =/ types/(list type) ~(tap in p.sut) -:: |- -:: ?~ types -:: ~ -:: =+ res=(find-item-in-type topics i.types) -:: ?~ res -:: $(types t.types) -:: res -:: :: -:: :: {$help *} -:: :: while we found a raw help, it's associated on the wrong side of a -:: :: set of topics. Walk through it instead of showing it. -:: :: (find-item-in-type t.topics q.sut) -:: :: -:: {$hint *} -:: $(sut q.sut) -:: :: -:: {$hold *} $(sut (~(play ut p.sut) q.sut)) -:: $noun ~ -:: $void ~ -:: == - :: - :: changes a {type} into an {item}. - ++ build-inspectable-recursively - |= sut/type - ^- (unit item) - ~ -:: ?- sut -:: :: -:: {$atom *} ~ -:: :: -:: {$cell *} -:: %+ join-items -:: (build-inspectable-recursively p.sut) -:: (build-inspectable-recursively q.sut) -:: :: -:: {$core *} -:: =* name (fall p.r.q.sut '') -:: =* compiled-against (build-inspectable-recursively p.sut) -:: `[%core (trip name) q.r.q.sut p.sut q.sut compiled-against] -:: :: -:: {$face *} -:: ?. ?=(term q.p.sut) -:: :: todo: can we do anything here if this face doesn't have a term? -:: ~ -:: =* compiled-against (build-inspectable-recursively q.sut) -:: `[%face (trip q.p.sut) p.p.sut compiled-against] -:: :: -:: {$fork *} -:: =* types ~(tap in p.sut) -:: =* items (turn types build-inspectable-recursively) -:: (roll items join-items) -:: :: -:: :: {$help *} -:: :: =* rest-type (build-inspectable-recursively q.sut) -:: :: ?> ?=($docs -.p.sut) -:: :: `[%view [%header `+.p.sut (item-as-overview rest-type)]~] -:: :: -:: {$hint *} $(sut q.sut) -:: {$hold *} $(sut (~(play ut p.sut) q.sut)) -:: $noun ~ -:: $void ~ -:: == - :: - :: combines two {(unit item)} together - ++ join-items - |= {lhs/(unit item) rhs/(unit item)} - ^- (unit item) - ?~ lhs rhs - ?~ rhs lhs - `[%view (weld (item-as-overview lhs) (item-as-overview rhs))] - :: - :: changes an item into an overview. - ++ item-as-overview - |= uit/(unit item) - ^- overview - ?~ uit ~ - =+ itm=u.uit - ?- itm - :: - {$view *} - items.itm - :: - {$core *} - ?~ name.itm - (item-as-overview children.itm) - :- [%item name.itm docs.itm] - (item-as-overview children.itm) - :: - {$arm *} - [%item name.itm docs.itm]~ - :: - {$chapter *} - [%item name.itm docs.itm]~ - :: - {$face *} - ?~ name.itm - ~ - [%item name.itm docs.itm]~ - == - :: - :: translate the internals of a core's {tomb} into an {overview}. - ++ arms-as-overview - |= {a/(map term (pair what foot)) sut/type} - ^- overview - %+ turn ~(tap by a) - |= (pair term (pair what foot)) - =* doc (select-arm-docs p.q q.q sut) - [%item (weld "++" (trip p)) -.doc] - :: - :: if {arm-name} is an arm in {c}, returns its documentation. - ++ find-arm-in-coil - |= {arm-name/term con/coil} - ^- (unit (pair what foot)) - ~ -:: =/ tombs ~(tap by q.s.con) -:: |- -:: ?~ tombs -:: ~ -:: =+ item=(~(get by q.q.i.tombs) arm-name) -:: ?~ item -:: $(tombs t.tombs) -:: [~ u.item] - :: - :: returns an overview for a core's arms and chapters. - :: - :: returns an overview for arms which are part of unnamed chapters, - :: and an overview of the named chapters. - ++ arm-and-chapter-overviews - |= {sut/type con/coil core-name/tape} - ^- {overview overview} - [*overview *overview] -:: =| arm-docs/overview :: documented arms -:: =| chapter-docs/overview :: documented chapters -:: =/ tombs ~(tap by q.s.con) -:: |- -:: ?~ tombs -:: [(sort-overview arm-docs) (sort-overview chapter-docs)] -:: =* current q.i.tombs -:: ?~ p.p.current -:: :: this chapter has no name. add all the foot documentation -:: :: to arm-docs. -:: =. arm-docs (weld arm-docs (arms-as-overview q.current sut)) -:: $(tombs t.tombs) -:: :: this chapter has a name. add it to the list of chapters -:: =. chapter-docs -:: %+ weld chapter-docs -:: ^- overview -:: [%item :(weld (trip u.p.p.current) ":" core-name) q.p.current]~ -:: $(tombs t.tombs) -:: :: -:: :: returns an overview of the arms in a spedific chapter. - ++ arms-in-chapter - |= {sut/type con/coil chapter-id/@} - ^- overview - *overview - :: =* chapter-tomb (~(got by q.s.con) chapter-id) - :: (sort-overview (arms-as-overview q.chapter-tomb sut)) - :: - :: sort the items. - ++ sort-overview - |: ovr=$:overview - ^- overview - %+ sort ovr - |: $:{lhs/overview-item rhs/overview-item} - (aor (get-overview-name lhs) (get-overview-name rhs)) - :: - ++ get-overview-name - |: ovr=$:overview-item - ?- ovr - {$header *} "" - {$item *} name.ovr - == - :: - ++ what-from-type - |= sut/type - ?+ sut ~ - {$core *} q.r.q.sut - :: {$help *} ?>(?=($docs -.p.sut) `+.p.sut) - {$hint *} $(sut q.sut) - {$hold *} $(sut (~(play ut p.sut) q.sut)) - == - :: - :: # - :: # %printing - :: # - :: functions which display output of various types. - +| %printing - ++ print-item - |: itm=$:item - ^- tang - ?- itm - {$view *} (print-overview items.itm) - {$core *} (print-core +.itm) - {$arm *} (print-arm +.itm) - {$chapter *} (print-chapter +.itm) - {$face *} (print-face +.itm) - == - :: - :: renders the documentation for a full core. - ++ print-core - |: $:{core-name/tape docs/what sut/type con/coil uit/(unit item)} - ^- tang - *tang -:: =+ [arms chapters]=(arm-and-chapter-overviews sut con core-name) -:: ;: weld -:: (print-header (trip (fall p.r.con '')) q.r.con) -:: :: -:: :: todo: figure out how to display the default arm, which should -:: :: be rendered separately. -:: :: -:: ?~ arms -:: ~ -:: (print-overview [%header `['arms:' ~] arms]~) -:: :: -:: ?~ chapters -:: ~ -:: (print-overview [%header `['chapters:' ~] chapters]~) -:: :: -:: =+ compiled=(item-as-overview uit) -:: ?~ compiled -:: ~ -:: (print-overview [%header `['compiled against:' ~] compiled]~) -:: == - :: - :: figures out which {what}s to use. - :: - :: there are three places with a relevant {what}: the {arm-doc} on the - :: arm, the {what} in the computed type of the foot, and the {what} on - :: the product of the default arm when the computed type is a core. - ++ select-arm-docs - |= {arm-doc/what f/foot sut/type} - :: the computed arm documentation and the product documentation. - ^- {what what} - [*what *what] -:: =+ foot-type=(~(play ut sut) p.f) -:: =/ raw-product/what (what-from-type foot-type) -:: =/ product-product/what -:: ?. ?=({$core *} foot-type) -:: ~ -:: =* inner-type (~(play ut foot-type) [%limb %$]) -:: (what-from-type inner-type) -:: :- -:: ?~ arm-doc -:: ?~ raw-product -:: product-product -:: raw-product -:: arm-doc -:: ?~ arm-doc -:: product-product -:: raw-product - :: - :: renders the documentation for a single arm in a core. - ++ print-arm - |= {arm-name/tape arm-doc/what f/foot sut/type} - :: todo: need to get the sample here. also hoist this to the general - :: core printing machinery, too. - =+ [main-doc product-doc]=(select-arm-docs arm-doc f sut) - %+ weld - (print-header arm-name main-doc) - ?~ product-doc - ~ - %+ weld - `tang`[[%leaf ""] [%leaf "product:"] ~] - (print-header "" product-doc) - :: - :: renders the documentation for a chapter in a core. - ++ print-chapter - |= {name/tape doc/what sut/type con/coil chapter-id/@} - ;: weld - (print-header name doc) - :: - ?~ doc - ~ - (print-sections q.u.doc) - :: - =+ arms=(arms-in-chapter sut con chapter-id) - ?~ arms - ~ - (print-overview [%header `['arms:' ~] arms]~) - == - :: - :: renders the documentation for a face. - ++ print-face - |= {name/tape doc/what children/(unit item)} - %+ weld - (print-header name doc) - ?~ children - ~ - (print-item u.children) - :: - :: returns a set of lines from a {chap} - ++ print-header - |= {name/tape doc/what} - ^- tang - ?~ name - ?~ doc - [%leaf "(Undocumented)"]~ - %+ weld - `tang`[%leaf "{(trip p.u.doc)}"]~ - (print-sections q.u.doc) - ?~ doc - [%leaf name]~ - %+ weld - `tang`[%leaf "{name}: {(trip p.u.doc)}"]~ - (print-sections q.u.doc) - :: - :: renders an overview as {tang} - ++ print-overview - |: ovr=$:overview - ^- tang - |^ (print-level ovr 0) - ++ print-level - :: indentation: multiply by 2 to get number of spaces. - |: $:{ovr/overview indentation/@u} - ^- tang - :: max-key-length: length of the longest {item} term. - =/ max-key-length (calculate-max-key-length ovr) - :: output: what we return - =| output/tang - |- - ?~ ovr - output - ?- i.ovr - :: - {$header *} - %= $ - output ;: weld - output - ?~ doc.i.ovr - ~ - `tang`[[%leaf ""] [%leaf "{(trip p.u.doc.i.ovr)}"] ~] - ?~ doc.i.ovr - ~ - (print-sections q.u.doc.i.ovr) - (print-level children.i.ovr (add 1 indentation)) - == - ovr t.ovr - == - :: - {$item *} - =* rendered (render-item indentation max-key-length +.i.ovr) - %= $ - output (weld output rendered) - ovr t.ovr - == - == - :: - :: - ++ calculate-max-key-length - |: ovr=$:overview - ^- @u - %- dy-longest-tape - (turn ovr get-overview-name) - :: - :: renders a single item line with the given indentation level. - ++ render-item - |= {indentation/@u max-key-length/@u name/tape doc/what} - ^- tang - =+ spaces=(mul indentation 2) - =+ line=(weld (dy-build-space spaces) name) - =* line-len (lent line) - =* name-len (lent name) - =+ diff=(sub max-key-length name-len) - =? line (gth diff 0) - (weld line (dy-build-space diff)) - =/ slogan/tape - ?~ doc - ~ - (trip p.u.doc) - =? line !=(0 (lent slogan)) - ;: weld - line - " : " - (dy-truncate (sub 80 :(add 1 spaces line-len)) slogan) - == - [%leaf line]~ - -- - :: - :: renders a list of sections as {tang} - :: - :: prints the longform documentation. - ++ print-sections - |= sections/(list sect) - ^- tang - =| output/tang - |- - ?~ sections - output - =. output ;: weld - output - `tang`[%leaf ""]~ - (print-section i.sections) - == - $(sections t.sections) - :: - :: renders an individual {sect} to a {tang} - ++ print-section - |= section/sect - ^- tang - %+ turn section - |= pica - ^- tank - ?: p - [%leaf (trip q)] - [%leaf " {(trip q)}"] - -- - :: - :: truncates `t` down to `i` characters, adding an ellipsis. - ++ dy-truncate - :: todo: when ~palfun's string library is landed, switch to his - :: implementation. - |= {i/@u t/tape} - ^- tape - =+ t-len=(lent t) - ?: (lth t-len i) - t - :(weld (scag (sub i 4) t) "...") - :: - :: creates a tape of i spaces, used for padding. - ++ dy-build-space - :: todo: when ~palfun's string library is landed, switch to his - :: implementation. - |= i/@u - ^- tape - =| t/tape - |- - ?: =(0 i) - t - $(t (weld " " t), i (sub i 1)) - :: - :: returns the length of the longest tape in c. - ++ dy-longest-tape - |= c/(list tape) - =| ret/@ud - |- - ?~ c - ret - =+ l=(lent i.c) - ?: (gth l ret) - $(ret l, c t.c) - $(c t.c) - :: - ++ dy-show-type-noun - |= a/type ^- tank - *tank -:: =- >[-]< -:: |- ^- $? $% {$atom @tas (unit @)} -:: {$cell _$ _$} -:: {$cube * _$} -:: {$face {what $@(term tune)} _$} -:: {$fork (set _$)} -:: {$hold _$ hoon} -:: == -:: wain :: "<|core|>" -:: $?($noun $void) -:: == -:: ?+ a a -:: :: {?($cube $face) ^} a(q $(a q.a)) -:: {$cell ^} a(p $(a p.a), q $(a q.a)) -:: {$fork *} a(p (silt (turn ~(tap in p.a) |=(b/type ^$(a b))))) -:: {$hint *} !! -:: {$core ^} `wain`/core -:: {$hold *} a(p $(a p.a)) -:: == - :: - :: XX needs filter - :: -:: ++ dy-shown -:: $? hoon -:: $^ {dy-shown dy-shown} -:: $% {$ur (unit knot) purl:eyre} -:: {$sa mark} -:: {$as mark dy-shown} -:: {$do hoon dy-shown} -:: {$ge path (list dy-shown) (map term (unit dy-shown))} -:: {$dv path} -:: == -:: == -:: :: -:: ++ dy-show-source -:: |= a/dojo-source ^- tank -:: =- >[-]< -:: =+ `{@ bil/dojo-build}`a -:: |- ^- dy-shown -:: ?- -.bil -:: $?($ur $dv $sa) bil -:: $ex ?. ?=({$cltr *} p.bil) p.bil -:: |- ^- hoon -:: ?~ p.p.bil !! -:: ?~ t.p.p.bil i.p.p.bil -:: [i.p.p.bil $(p.p.bil t.p.p.bil)] -:: $tu ?~ p.bil !! -:: |- -:: ?~ t.p.bil ^$(bil q.i.p.bil) -:: [^$(bil q.i.p.bil) $(p.bil t.p.bil)] -:: $as bil(q $(bil q.q.bil)) -:: $do bil(q $(bil q.q.bil)) -:: $ge :+ %ge q.p.p.bil -:: [(turn p.q.p.bil ..$) (~(run by q.q.p.bil) (lift ..$))] -:: == - :: ++ dy-edit :: handle edit |= cal/sole-change ^+ +>+> @@ -1489,12 +851,12 @@ dy-make(cud `[nex (~(got by job) nex)]) -- :: - ++ he-dope :: sole user of ++dp + ++ he-dope |= txt/tape :: ^- (each (unit (each dojo-command tape)) hair) :: prefix+result =+ len=+((lent txt)) :: line length =. txt (weld buf `tape`(weld txt "\0a")) :: - =+ vex=((full dp-command-line):dp [1 1] txt) :: + =+ vex=((full parse-command-line:he-parser) [1 1] txt) ?: =(q.p.vex len) :: matched to line end [%& ~] :: ?: =(p.p.vex +((lent (skim txt |=(a/@ =(10 a)))))) :: parsed all lines @@ -1517,14 +879,6 @@ => he-stop [(flop moz) %_(+> hoc (~(del by hoc) ost.hid))] :: - ++ he-disc [p q]:he-beam - ++ he-beak [p q r]:he-beam - ++ he-rail [[p q] s]:he-beam - ++ he-beam :: logical beam - ^- beam - ?. =(ud+0 r.dir) dir - dir(r [%da now.hid]) - :: ++ he-card :: emit gift |= cad/card ^+ +> @@ -1662,7 +1016,7 @@ $data [%ex %sand %t data.source.com] $dojo %+ rash command.source.com - (ifix [(punt gap) (punt gap)] dp-build:dp) + (ifix [(punt gap) (punt gap)] parse-build:he-parser) :: $clay :- %ex @@ -1719,7 +1073,7 @@ $url [%http %post `~. url.sink.com] $to-api !! $send-api [%poke our.hid api.sink.com] - $command (rash command.sink.com dp-sink:dp) + $command (rash command.sink.com parse-sink:he-parser) $app [%poke our.hid app.sink.com] == (he-plan sink source) @@ -1833,10 +1187,27 @@ (wrap he-lens):arm :: ++ poke-json - |= jon/json - ^- {(list move) _+>.$} + |= jon=json + ^- [(list move) _+>.$] ~& jon=jon [~ +>.$] +:: +poke-wipe: clear all dojo sessions +:: +++ poke-wipe + |= * + ^- [(list move) _+>.$] + ~& %dojo-wipe + =. hoc + %- ~(run by hoc) + |= =session + %_ session + sur ~ + lib ~ + var ~ + old ~ + == + :: + [~ +>.$] :: ++ made (wrap he-made):arm ++ sigh-httr (wrap he-sigh):arm diff --git a/app/hall.hoon b/app/hall.hoon index c6f731db6..ca5a663f0 100644 --- a/app/hall.hoon +++ b/app/hall.hoon @@ -498,7 +498,7 @@ ~/ %hall-action-create |= {nom/name des/cord typ/security} ^+ ..ta-action - ?. (~(has in stories) nom) + ?. (~(has by stories) nom) %^ impact nom %new :* [[[our.bol nom] ~] ~ ~] des @@ -516,7 +516,7 @@ :: ~/ %hall-action-design |= {nom/name cof/config} - ?. (~(has in stories) nom) + ?. (~(has by stories) nom) (impact nom %new cof) (ta-evil (crip "{(trip nom)}: already exists")) :: @@ -2654,15 +2654,16 @@ == :: ?: =(wat ~) & - %- ~(has in wat) - ?+ -.det %hasnot - $gram %grams - $new %config-l - $remove %config-l + ?+ -.det | + $gram (~(has in wat) %grams) + $new (~(has in wat) %config-l) + $remove (~(has in wat) %config-l) $config ?: =(cir.det [our.bol nom]) - %config-l %config-r + (~(has in wat) %config-l) + (~(has in wat) %config-r) $status ?: =(cir.det [our.bol nom]) - %group-l %group-r + (~(has in wat) %group-l) + (~(has in wat) %group-r) == == :: diff --git a/gen/dojo/wipe.hoon b/gen/dojo/wipe.hoon new file mode 100644 index 000000000..732178fb1 --- /dev/null +++ b/gen/dojo/wipe.hoon @@ -0,0 +1,9 @@ +:: wipe: poke dojo to wipe its state +:: +/? 310 +:: +:- %say +|= $: [now=@da eny=@uvJ bec=beak] + [~ ~] + == +[%wipe ~] diff --git a/lib/hood/helm.hoon b/lib/hood/helm.hoon index b251fc339..462361511 100644 --- a/lib/hood/helm.hoon +++ b/lib/hood/helm.hoon @@ -176,9 +176,9 @@ =+ way=?:(zus (welp top /sys/[nam]) (welp top /sys/vane/[nam])) =+ fil=.^(@ %cx (welp way /hoon)) [%flog /reload [%veer ?:(=('z' tip) %$ tip) way fil]] -:: +poke-reset: send %vega to reboot kernel +:: +poke-reset: send %lyra to initiate kernel upgrade :: -:: And reinstall %zuse and the vanes. +:: And reinstall %zuse and the vanes with %veer. :: Trigger with |reset. :: ++ poke-reset @@ -189,7 +189,7 @@ =/ top=path /(scot %p our)/home/(scot %da now)/sys =/ hun .^(@ %cx (welp top /hoon/hoon)) =/ arv .^(@ %cx (welp top /arvo/hoon)) - :- [%flog /reset [%vega `@t`hun `@t`arv]] + :- [%flog /reset [%lyra `@t`hun `@t`arv]] %+ turn (module-ova:pill top) |=(a=[wire flog:dill] [%flog a]) diff --git a/lib/test/ford.hoon b/lib/test/ford.hoon index ff253a267..304dfa69f 100644 --- a/lib/test/ford.hoon +++ b/lib/test/ford.hoon @@ -105,7 +105,7 @@ [%leaf "expected %dude, but got {<-.actual>}"]~ :: %+ weld - (expect-eq !>((error.expected)) !>((error.actual))) + (expect-eq !>(error.expected) !>(error.actual)) $(expected attempt.expected, actual attempt.actual) :: %hood diff --git a/mar/json/rpc/response.hoon b/mar/json/rpc/response.hoon index 900c34108..6e26f119f 100644 --- a/mar/json/rpc/response.hoon +++ b/mar/json/rpc/response.hoon @@ -1,6 +1,5 @@ :: -/- json-rpc -=, json-rpc +=, rpc:jstd :: |_ res=response :: diff --git a/sur/json/rpc.hoon b/sur/json/rpc.hoon deleted file mode 100644 index 19aeaadbd..000000000 --- a/sur/json/rpc.hoon +++ /dev/null @@ -1,8 +0,0 @@ -|% -++ response ::TODO id should be optional - $% [%result id=@t res=json] - [%error id=@t code=@t message=@t] ::TODO data? - [%fail hit=httr:eyre] - [%batch bas=(list response)] - == --- diff --git a/sys/arvo.hoon b/sys/arvo.hoon index 11d42c98c..2ff98aba9 100644 --- a/sys/arvo.hoon +++ b/sys/arvo.hoon @@ -540,6 +540,18 @@ :: we emit ova to unix in fifo order, but emit internal moves depth-first :: $(ova (weld ova p.nyx), mor (weld q.nyx t.mor)) + :: +spam: kick every vane with :ovum + :: + ++ spam + |= [lac=? ovo=ovum] + ^- [(list ovum) (list [label=@tas =vane])] + =/ card + :+ %& + [%cell [%atom %tas `%soft] %noun] + [%soft q.ovo] + %+ kick lac + %+ turn vanes + |=([label=@tas *] [label ~ [%pass p.ovo label card]]) -- -- =< :: Arvo larval stage @@ -651,12 +663,13 @@ ^- [(list ovum) *] => .(+< ((hard ,[now=@da ovo=ovum]) +<)) =^ ova +>+.$ (^poke now ovo) + =| out=(list ovum) |- ^- [(list ovum) *] ?~ ova - [~ +>.^$] + [(flop out) +>.^$] :: upgrade the kernel :: - ?: ?=(%vega -.q.i.ova) + ?: ?=(%lyra -.q.i.ova) %+ fall (vega now t.ova ({@ @} +.q.i.ova)) [~ +>.^$] @@ -664,10 +677,8 @@ :: and passing the rest through as output :: =^ vov +>+.^$ (feck now i.ova) - ?~ vov - $(ova t.ova) - =/ avo $(ova t.ova) - [[+.vov -.avo] +.avo] + =? out ?=(^ vov) [+.vov out] + $(ova t.ova) :: ++ wish |=(* (^wish ((hard @ta) +<))) :: 22 -- @@ -688,20 +699,28 @@ bud dub vanes (turn nyf |=({a/@tas b/vise} [a [b *worm]])) == + =| out=(list ovum) |- ^- [(list ovum) _+>.^$] ?~ ova - [~ +>.^$] + [(flop out) +>.^$] :: iterate over effects, handling those on arvo proper :: and passing the rest through as output :: :: In practice, the pending effects after an upgrade - :: are the %veer moves to install %zuse and the vanes. + :: are the %veer moves to install %zuse and the vanes, + :: plus a %vega notification that the upgrade is complete. + :: + :: N.B. this implementation assumes that %vega will be + :: at the end of :ova. + :: + ?: ?=(%vega -.q.i.ova) + =^ zef vanes + (~(spam (is our vil eny bud vanes) now) lac i.ova) + $(out [i.ova out], ova (weld t.ova zef)) :: =^ vov +>.^$ (feck now i.ova) - ?~ vov - $(ova t.ova) - =/ avo $(ova t.ova) - [[+.vov -.avo] +.avo] + =? out ?=(^ vov) [+.vov out] + $(ova t.ova) :: ++ peek :: external inspect |= {now/@da hap/path} @@ -840,16 +859,18 @@ :* our now eny - ova + :: tack a notification onto the pending effects + :: + (weld ova [`ovum`[/ %vega ~] ~]) bud (turn vanes |=([label=@tas =vane] [label vase.vane])) == :: call into the new kernel :: =/ out (slum gat sam) - :: tack a reset notification onto the product + :: add types to the product :: - [[[/ %vega ~] ((list ovum) -.out)] +.out] + [((list ovum) -.out) +.out] :: +veer: install %zuse or a vane :: :: Identity is in the sample so the larval stage diff --git a/sys/hoon.hoon b/sys/hoon.hoon index 3c726a9b5..8d87bc20d 100644 --- a/sys/hoon.hoon +++ b/sys/hoon.hoon @@ -1335,10 +1335,26 @@ ?~ b a $(b t.b, a (put i.b)) + :: +has: does :b exist in :a? :: - ++ has :: b exists in a check + ++ has ~/ %has - |* b/* + |* b=* + ^- ? + :: wrap extracted item type in a unit because bunting fails + :: + :: If we used the real item type of _?^(a n.a !!) as the sample type, + :: then hoon would bunt it to create the default sample for the gate. + :: + :: However, bunting that expression fails if :a is ~. If we wrap it + :: in a unit, the bunted unit doesn't include the bunted item type. + :: + :: This way we can ensure type safety of :b without needing to perform + :: this failing bunt. It's a hack. + :: + %. [~ b] + |= b=(unit _?>(?=(^ a) n.a)) + => .(b ?>(?=(^ b) u.b)) |- ^- ? ?~ a | @@ -7830,7 +7846,7 @@ :: [%tsld [%$ 6] p.mod] {$bspd *} $(mod p.mod) - {$bssg *} p.mod + {$bssg *} [%kthp q.mod p.mod] {$bsts *} [%ktts p.mod $(mod q.mod)] {$bsvt *} $(mod p.mod) {$bswt *} :: use last entry @@ -7891,7 +7907,7 @@ :: process annotations outside construct, to catch default :: ?: ?=($dbug -.mod) factory(mod q.mod, bug [p.mod bug]) - ?: ?=($bssg -.mod) factory(mod q.mod, def `p.mod) + ?: ?=($bssg -.mod) factory(mod q.mod, def `[%kthp q.mod p.mod]) ^- hoon :: if we recognize an indirection :: @@ -8212,7 +8228,7 @@ :: default :: {$bssg *} - relative(mod q.mod, def `p.mod) + relative(mod q.mod, def `[%kthp q.mod p.mod]) :: :: choice, $? :: @@ -12114,7 +12130,7 @@ |= [acc=_map [ty=type k=xkey]] =/ dest (~(get by refs.tbl) k) ?^ dest (~(put by acc) ty u.dest) - ?. (~(has in live.tbl)) acc + ?. (~(has in live.tbl) k) acc (~(put in acc) ty k) :: :: Rebuild the `xrays` table. @@ -17007,7 +17023,7 @@ :: :::: 5e: caching compiler :: -++ wa !: :: cached compile +++ wa :: cached compile |_ worm ++ nell |=(ref/type (nest [%cell %noun %noun] ref)) :: nest in cell ++ nest :: nest:ut, cached diff --git a/sys/vane/ames.hoon b/sys/vane/ames.hoon index fc7466688..2c470e8bd 100644 --- a/sys/vane/ames.hoon +++ b/sys/vane/ames.hoon @@ -1,4 +1,4 @@ -:: :: ames (4a), networking +!: :: ames (4a), networking :: |= pit=vase => =~ @@ -6,7 +6,7 @@ =, ames :: this number needs to be below 8 :: -=+ protocol-version=7 +=+ protocol-version=0 |% += move [p=duct q=(wind note:able gift:able)] :: local move :: |pact: internal packet structures @@ -1506,6 +1506,9 @@ wab.zac.fox (~(del by wab.zac.fox) who) == [[%wine who " has sunk"]~ fox] + :: + %vega + [~ fox] :: %wake (~(wake am [our now fox ski]) hen) diff --git a/sys/vane/behn.hoon b/sys/vane/behn.hoon index 618e8caf6..30aa9cf35 100644 --- a/sys/vane/behn.hoon +++ b/sys/vane/behn.hoon @@ -1,5 +1,5 @@ :: %behn, just a timer -:: +!: !? 164 :: =, behn @@ -17,122 +17,94 @@ +$ timer [date=@da =duct] -- :: -=| behn-state -=* state - -|= [our=ship now=@da eny=@uvJ ski=sley] :: current invocation -^? -|% :: poke+peek pattern -++ call :: handle request - |= $: hen=duct - type=* - wrapped-task=(hobo task:able) - == - ^- [(list move) _..^$] +=> |% +++ per-event + =| moves=(list move) + |= [[our=ship now=@da =duct] state=behn-state] :: - =/ =task:able - ?. ?=(%soft -.wrapped-task) - wrapped-task - ((hard task:able) p.wrapped-task) + |% + :: %entry-points :: - |^ =^ moves state - :: - ?- -.task - :: %crud: error report; hand off to %dill to be printed - :: - %crud - [[hen %slip %d %flog task]~ state] - :: - :: %born: handle urbit restart - :: - %born - :: store this duct for setting unix wakeup timers - :: - =. unix-duct hen - :: process any elapsed timers and clear and reset :next-wake - :: - =^ moves timers notify-clients - (set-wake(next-wake ~) moves) - :: - :: %rest: cancel a timer, resetting :next-wake if needed - :: - %rest - =. timers (unset-timer [p.task hen]) - (set-wake ~) - :: - :: %wait: set a new timer - :: - %wait - :: process elapsed timers first to maintain sort order - :: - =^ moves timers notify-clients - :: set the timer, then adjust :next-wake if needed - :: - =. timers (set-timer [p.task hen]) - (set-wake moves) - :: - :: %wake: unix says wake up; notify clients and set next wakeup - :: - %wake - =^ moves timers notify-clients - (set-wake(next-wake ~) moves) - :: - :: %wegh: produce memory usage report for |mass - :: - %wegh - :_ state :_ ~ - :^ hen %give %mass - :+ %behn %| - :~ timers+&+timers - dot+&+state - == - == - :: - [moves ..^^$] - :: +set-timer: set a timer, maintaining the sort order of the :timers list + :: +born: handle urbit restart :: - ++ set-timer - |= t=timer - ^+ timers - :: - ?~ timers - ~[t] - :: timers at the same date form a fifo queue + ++ born + ^+ [moves state] + :: store this duct for setting unix wakeup timers :: - ?: (lth date.t date.i.timers) - [t timers] + =. unix-duct.state duct + :: process any elapsed timers and clear and reset :next-wake :: - [i.timers $(timers t.timers)] - :: +unset-timer: cancel a timer; if it already expired, no-op + => notify-clients + set-wake(next-wake.state ~) + :: +crud: error report; hand off to %dill to be printed :: - ++ unset-timer - |= [t=timer] - ^+ timers - :: if we don't have this timer, no-op; for debugging, add a printf here + ++ crud + |= [p=@tas q=tang] + ^+ [moves state] + [[duct %slip %d %flog %crud p q]~ state] + :: +rest: cancel the timer at :date, resetting :next-wake if needed + :: + ++ rest + |= date=@da + ^+ [moves state] :: - ?~ timers - ~ - ?: =(i.timers t) - t.timers + =. timers.state (unset-timer [date duct]) + set-wake + :: +vega: learn of a kernel upgrade + :: + ++ vega + [moves state] + :: +wait: set a new timer at :date, resetting :next-wake if needed + :: + ++ wait + |= date=@da + ^+ [moves state] + :: process elapsed timers first to maintain sort order :: - [i.timers $(timers t.timers)] + =. event-core notify-clients + =. timers.state (set-timer [date duct]) + set-wake + :: +wake: unix says we should wake up; notify clients and set :next-wake + :: + ++ wake + ^+ [moves state] + => notify-clients + set-wake(next-wake.state ~) + :: +wegh: produce memory usage report for |mass + :: + ++ wegh + ^+ [moves state] + :_ state :_ ~ + :^ duct %give %mass + :+ %behn %| + :~ timers+&+timers.state + dot+&+state + == + :: %utilities + :: + ::+| + :: + ++ event-core . :: +notify-clients: wake up vanes whose timers have expired :: :: When we return the list moves to clients, we flop them so they're in :: the same order as they were in :timers. :: ++ notify-clients - =| moves=(list move) - |- ^+ [moves timers] + =* timers timers.state + |- ^+ event-core :: ?~ timers - [(flop moves) timers] + =. moves (flop moves) + event-core :: ?: (gth date.i.timers now) - [(flop moves) timers] + =. moves (flop moves) + event-core :: %_ $ timers t.timers - moves [[duct.i.timers %give %wake ~] moves] + moves [[duct.i.timers %give %wake ~] moves] == :: +set-wake: set or unset a unix timer to wake us when next timer expires :: @@ -145,8 +117,11 @@ :: handled by unix first which is incorrect. :: ++ set-wake - |= moves=(list move) ^+ [moves state] + :: + =* next-wake next-wake.state + =* timers timers.state + =* unix-duct unix-duct.state :: if no timers, cancel existing wakeup timer or no-op :: ?~ timers @@ -165,16 +140,83 @@ :: :_ state(next-wake `date.i.timers) [[unix-duct %give %doze `date.i.timers] moves] + :: +set-timer: set a timer, maintaining the sort order of the :timers list + :: + ++ set-timer + =* timers timers.state + |= t=timer + ^+ timers + :: + ?~ timers + ~[t] + :: ignore duplicates + :: + ?: =(t i.timers) + timers + :: timers at the same date form a fifo queue + :: + ?: (lth date.t date.i.timers) + [t timers] + :: + [i.timers $(timers t.timers)] + :: +unset-timer: cancel a timer; if it already expired, no-op + :: + ++ unset-timer + =* timers timers.state + |= [t=timer] + ^+ timers + :: if we don't have this timer, no-op; for debugging, add a printf here + :: + ?~ timers + ~ + ?: =(i.timers t) + t.timers + :: + [i.timers $(timers t.timers)] -- +-- +:: +=| behn-state +=* state - +|= [our=ship now=@da eny=@uvJ ski=sley] +=* behn-gate . +^? +|% +:: +call: handle a +task:able:behn request +:: +++ call + |= $: hen=duct + type=* + wrapped-task=(hobo task:able) + == + ^- [(list move) _behn-gate] + :: + =/ =task:able + ?. ?=(%soft -.wrapped-task) + wrapped-task + ((hard task:able) p.wrapped-task) + :: + =/ event-core (per-event [our now hen] state) + :: + =^ moves state + ?- -.task + %born born:event-core + %crud (crud:event-core [p q]:task) + %rest (rest:event-core date=p.task) + %vega vega:event-core + %wait (wait:event-core date=p.task) + %wake wake:event-core + %wegh wegh:event-core + == + [moves behn-gate] +:: +load: migrate an old state to a new behn version :: ++ load |= old=* - ^+ ..^$ - ?^ new=((soft behn-state) old) - ~& %behn-load-new - ..^$(state u.new) - ~& %behn-load-wipe - ..^$(state *behn-state) + ^+ behn-gate + :: + ~| %behn-load-fail + behn-gate(state (behn-state old)) :: +scry: view timer state :: :: TODO: not referentially transparent w.r.t. elapsed timers, @@ -189,9 +231,10 @@ [~ ~ %tank !>(>timers<)] :: ++ stay state -++ take :: process move +++ take |= [tea=wire hen=duct hin=(hypo sign)] - ^+ [*(list move) ..^$] + ^- [(list move) _behn-gate] ~| %behn-take-not-implemented !! -- + diff --git a/sys/vane/clay.hoon b/sys/vane/clay.hoon index c299beb2b..fcd665a62 100644 --- a/sys/vane/clay.hoon +++ b/sys/vane/clay.hoon @@ -1,5 +1,5 @@ :: clay (4c), revision control -:: +!: :: This is split in three top-level sections: structure definitions, main :: logic, and arvo interface. :: @@ -1770,7 +1770,7 @@ |= [disc=disc:ford a=page] ^- schematic:ford ?. ?=($hoon p.a) [%vale [our %home] a] - ?. ?=(@t q.a) [%dude |.(>%weird-hoon<) %ride [%zpzp ~] %$ *cage] + ?. ?=(@t q.a) [%dude >%weird-hoon< %ride [%zpzp ~] %$ *cage] [%$ p.a [%atom %t ~] q.a] :: :: Verify the foreign data is of the the mark it claims to be. @@ -3885,6 +3885,8 @@ [mos ..^$] :: $sunk [~ ..^$] + :: + $vega [~ ..^$] :: ?($warp $werp) :: capture whether this read is on behalf of another ship diff --git a/sys/vane/dill.hoon b/sys/vane/dill.hoon index 537cc5a6b..82113fd1a 100644 --- a/sys/vane/dill.hoon +++ b/sys/vane/dill.hoon @@ -1,4 +1,4 @@ -:: +!: :: dill (4d), terminal handling :: |= pit/vase @@ -51,9 +51,9 @@ $% {$crud p/@tas q/(list tank)} :: {$heft $~} :: {$init p/ship} :: + {$lyra p/@t q/@t} :: upgrade kernel {$text p/tape} :: {$veer p/@ta q/path r/@t} :: install vane - {$vega p/@t q/@t} :: reboot by path {$verb $~} :: verbose mode == :: ++ note-eyre :: @@ -158,8 +158,8 @@ (crud p.kyz q.kyz) $blew (send %rez p.p.kyz q.p.kyz) $heft heft + $lyra (dump kyz) $veer (dump kyz) - $vega (dump kyz) $verb (dump kyz) == :: @@ -531,6 +531,10 @@ :: ?: ?=(%sunk -.task) [~ ..^$] + :: a %vega notification on kernel upgrade comes in on an unfamiliar duct + :: + ?: ?=(%vega -.task) + [~ ..^$] :: =/ nus (ax hen) ?~ nus diff --git a/sys/vane/eyre.hoon b/sys/vane/eyre.hoon index a3a4a6d2f..61aa6d4ca 100644 --- a/sys/vane/eyre.hoon +++ b/sys/vane/eyre.hoon @@ -1,4 +1,4 @@ -:: :: %eyre, http servant +!: :: %eyre, http servant !? 164 :::: |= pit/vase @@ -728,6 +728,8 @@ == :: $sunk +> + :: + $vega +> :: ?($chis $this) :: inbound request %- emule |. ^+ ..apex @@ -1160,7 +1162,7 @@ |= [tea=whir live=? request=schematic:ford] %+ pass-note tea :* %f %build live - [%dude |.([%leaf "eyre: execute {}"]) request] + [%dude [%leaf "eyre: execute {(spud tea)}"] request] == :: ++ add-links :: x-urbit:// urls @@ -2075,7 +2077,6 @@ ++ has-arm ~(has in (silt (sloe cor-type))) ++ build %^ execute-turbo %core live=%.y - :::+ %dude [|.(+)]:>%mod-samp< ^- schematic:ford :+ %mute ^- schematic:ford diff --git a/sys/vane/ford.hoon b/sys/vane/ford.hoon index cd02592f9..cde22f241 100644 --- a/sys/vane/ford.hoon +++ b/sys/vane/ford.hoon @@ -1,5 +1,5 @@ :: ford: build system vane -:: +!: :: Ford is a functional reactive build system. :: :: A Ford build is a function of the Urbit namespace and a date that @@ -1771,7 +1771,7 @@ :: to wake us up immediately. This has the advantage that Ford stops hard :: blocking the main Urbit event loop, letting other work be done. :: - ++ execute-loop + ++ execute-loop !. ~/ %execute-loop |= builds=(set build) ^+ ..execute @@ -1808,7 +1808,7 @@ :: should run the candidate build this cycle through the +execute loop, we :: place it in :next-builds. +gather runs until it has no more candidates. :: - ++ gather + ++ gather !. ~/ %gather |= [builds=(set build) force=?] ^+ ..execute @@ -2080,7 +2080,7 @@ :: +build-receipts. It is in +reduce where we take these +build-receipts :: and apply them to ..execute. :: - ++ reduce + ++ reduce !. ~/ %reduce |= build-receipts=(list build-receipt) ^+ ..execute @@ -3131,7 +3131,7 @@ :: ++ make-dude ~% %make-dude ..^^$ ~ - |= [error=(trap tank) attempt=schematic] + |= [error=tank attempt=schematic] ^- build-receipt :: =/ attempt-build=^build [date.build attempt] @@ -3143,7 +3143,7 @@ ?. ?=([%error *] u.attempt-result) (return-result u.attempt-result) :: - (return-error [$:error message.u.attempt-result]) + (return-error [error message.u.attempt-result]) :: ++ make-hood ~% %make-hood ..^^$ ~ @@ -6182,6 +6182,14 @@ %sunk :: [~ ford-gate] + :: + :: %vega: learn of kernel upgrade + :: + :: XX clear cache, rebuild live builds + :: + %vega + :: + [~ ford-gate] :: :: %wipe: wipe stored builds, clearing :percent-to-remove of the entries :: diff --git a/sys/vane/gall.hoon b/sys/vane/gall.hoon index 747c7f84f..ee6aeb743 100644 --- a/sys/vane/gall.hoon +++ b/sys/vane/gall.hoon @@ -1,4 +1,4 @@ -:: :: %gall, agent execution +!: :: %gall, agent execution !? 163 :::: |= pit/vase @@ -1316,6 +1316,8 @@ [~ ..^$(sys.mast.all hen)] :: $sunk [~ ..^$] + :: + $vega [~ ..^$] :: $west ?> ?=({?($ge $gh) @ ~} q.q.hic) diff --git a/sys/vane/jael.hoon b/sys/vane/jael.hoon index 3da51094c..f1d93eea3 100644 --- a/sys/vane/jael.hoon +++ b/sys/vane/jael.hoon @@ -1,4 +1,4 @@ -:: :: /van/jael +!: :: /van/jael :: :: %reference/0 !? 150 :: @@ -865,6 +865,12 @@ ?< =(fak.own.sub ?=(^ tuf.own.sub)) +>.$(moz [[hen %give %turf tuf.own.sub] moz]) :: + :: learn of kernel upgrade + :: [%vega ~] + :: + %vega + +>.$ + :: :: watch private keys :: {$vein $~} :: diff --git a/sys/zuse.hoon b/sys/zuse.hoon index a16a77957..20f258fac 100644 --- a/sys/zuse.hoon +++ b/sys/zuse.hoon @@ -95,7 +95,17 @@ |% ++ rpc |% - ++ response ::TODO id should be optional + +$ request + $: id=@t + method=@t + params=request-params + == + :: + +$ request-params + $% [%list (list json)] + [%object (list (pair @t json))] + == + +$ response $~ [%fail *httr:eyre] $% [%result id=@t res=json] [%error id=@t code=@t message=@t] ::TODO data? @@ -242,6 +252,7 @@ {$kick p/@da} :: wake up {$nuke p/@p} :: toggle auto-block {$sunk p=ship q=life} :: report death + {$vega ~} :: report upgrade {$wake ~} :: timer activate {$wegh ~} :: report memory {$west p/ship q/path r/*} :: network request @@ -423,6 +434,7 @@ $% {$born ~} :: new unix process {$crud p/@tas q/(list tank)} :: error with trace {$rest p/@da} :: cancel alarm + {$vega ~} :: report upgrade {$wait p/@da} :: set alarm {$wake ~} :: timer activate {$wegh ~} :: report memory @@ -475,6 +487,7 @@ {$ogre pot/$@(desk beam)} :: delete mount point {$perm des/desk pax/path rit/rite} :: change permissions {$sunk p=ship q=life} :: report death + {$vega ~} :: report upgrade {$warp wer/ship rif/riff} :: internal file req {$werp who/ship wer/ship rif/riff} :: external file req {$wegh ~} :: report memory @@ -614,16 +627,16 @@ ++ able ^? |% ++ gift :: out result <-$ - $% {$bbye ~} :: reset prompt + $% {$bbye ~} :: reset prompt {$blit p/(list blit)} :: terminal output {$burl p/@t} :: activate url {$init p/@p} :: set owner - {$logo ~} :: logout + {$logo ~} :: logout + {$lyra p/@t q/@t} :: upgrade kernel {$mass p/mass} :: memory usage {$send p/lane:ames q/@} :: transmit packet {$veer p/@ta q/path r/@t} :: install vane - {$vega p/@t q/@t} :: reboot - {$verb ~} :: verbose mode + {$verb ~} :: verbose mode == :: ++ task :: in request ->$ $% {$belt p/belt} :: terminal input @@ -632,18 +645,19 @@ {$crud p/@tas q/(list tank)} :: error with trace {$flog p/flog} :: wrapped error {$flow p/@tas q/(list gill:gall)} :: terminal config - {$hail ~} :: terminal refresh - {$heft ~} :: memory report - {$hook ~} :: this term hung up - {$harm ~} :: all terms hung up + {$hail ~} :: terminal refresh + {$heft ~} :: memory report + {$hook ~} :: this term hung up + {$harm ~} :: all terms hung up {$init p/ship} :: after gall ready - {$noop ~} :: no operation + {$lyra p/@t q/@t} :: upgrade kernel + {$noop ~} :: no operation {$sunk p=ship q=life} :: report death {$talk p/tank} :: {$text p/tape} :: {$veer p/@ta q/path r/@t} :: install vane - {$vega p/@t q/@t} :: reboot - {$verb ~} :: verbose mode + {$vega ~} :: report upgrade + {$verb ~} :: verbose mode == :: -- ::able :: @@ -652,46 +666,46 @@ ++ blew {p/@ud q/@ud} :: columns rows ++ belt :: old belt $% {$aro p/?($d $l $r $u)} :: arrow key - {$bac ~} :: true backspace + {$bac ~} :: true backspace {$ctl p/@c} :: control-key - {$del ~} :: true delete + {$del ~} :: true delete {$met p/@c} :: meta-key - {$ret ~} :: return + {$ret ~} :: return {$txt p/(list @c)} :: utf32 text == :: ++ blit :: old blit - $% {$bel ~} :: make a noise - {$clr ~} :: clear the screen + $% {$bel ~} :: make a noise + {$clr ~} :: clear the screen {$hop p/@ud} :: set cursor position {$lin p/(list @c)} :: set current line - {$mor ~} :: newline + {$mor ~} :: newline {$sag p/path q/*} :: save to jamfile {$sav p/path q/@} :: save to file {$url p/@t} :: activate url == :: - ++ deco ?(~ $bl $br $un) :: text decoration + ++ deco ?(~ $bl $br $un) :: text decoration ++ dill-belt :: new belt $% {$aro p/?($d $l $r $u)} :: arrow key - {$bac ~} :: true backspace + {$bac ~} :: true backspace {$cru p/@tas q/(list tank)} :: echo error {$ctl p/@} :: control-key - {$del ~} :: true delete - {$hey ~} :: refresh + {$del ~} :: true delete + {$hey ~} :: refresh {$met p/@} :: meta-key - {$ret ~} :: return + {$ret ~} :: return {$rez p/@ud q/@ud} :: resize, cols, rows {$txt p/(list @c)} :: utf32 text {$yow p/gill:gall} :: connect to app == :: ++ dill-blit :: new blit - $% {$bel ~} :: make a noise - {$clr ~} :: clear the screen + $% {$bel ~} :: make a noise + {$clr ~} :: clear the screen {$hop p/@ud} :: set cursor position {$klr p/stub} :: styled text {$mor p/(list dill-blit)} :: multiple blits {$pom p/stub} :: styled prompt {$pro p/(list @c)} :: show as cursor+line - {$qit ~} :: close console + {$qit ~} :: close console {$out p/(list @c)} :: send output line {$sag p/path q/*} :: save to jamfile {$sav p/path q/@} :: save to file @@ -699,11 +713,11 @@ == :: ++ flog :: sent to %dill $% {$crud p/@tas q/(list tank)} :: - {$heft ~} :: + {$heft ~} :: + {$lyra p/@t q/@t} :: upgrade kernel {$text p/tape} :: {$veer p/@ta q/path r/@t} :: install vane - {$vega p/@t q/@t} :: reboot - {$verb ~} :: verbose mode + {$verb ~} :: verbose mode == :: -- ::dill :: :::: @@ -741,6 +755,7 @@ [%chis p=? q=clip r=httq] :: IPC inbound request [%this p=? q=clip r=httq] :: inbound request [%thud ~] :: inbound cancel + [%vega ~] :: report upgrade [%wegh ~] :: report memory [%well p=path q=(unit mime)] :: put/del .well-known [%west p=ship q=[path *]] :: network request @@ -977,6 +992,9 @@ :: %sunk: receive a report that a foreign ship has lost continuity :: [%sunk =ship =life] + :: %vega: report kernel upgrade + :: + [%vega ~] :: %wegh: produce memory usage information :: [%wegh ~] @@ -1204,7 +1222,7 @@ $: %dude :: error: a trap producing an error message to wrap the original :: - error=(trap tank) + error=tank :: attempt: the schematic to try, whose error we wrap, if any :: attempt=schematic @@ -1668,6 +1686,7 @@ {$init p/ship} :: set owner {$deal p/sock q/cush} :: full transmission {$sunk p=ship q/life} :: report death + {$vega ~} :: report upgrade {$west p/ship q/path r/*} :: network request {$wegh ~} :: report memory == :: @@ -1859,6 +1878,7 @@ [%meet =ship =life =pass] :: met after breach [%snap snap=snapshot kick=?] :: load snapshot [%turf ~] :: view domains + [%vega ~] :: report upgrade [%vein ~] :: view signing keys [%vent ~] :: view ethereum events [%vest ~] :: view public balance @@ -5934,7 +5954,7 @@ %+ welp tam =- ?~(att rez [' ' (attr att rez)]) ^- rez/tape - ?: &(?=(~ c.mex) |(cot (clot man))) + ?: &(?=(~ c.mex) |(cot ?^(man | (clot man)))) [' ' '/' '>' rez] :- '>' (many c.mex :(weld "" rez)) @@ -7971,6 +7991,8 @@ ^- json %- pairs =; r=[met=@t pas=(list json)] + ::TODO should use request-to-json:rpc:jstd, + :: and probably (fall riq -.req) :* jsonrpc+s+'2.0' method+s+met.r params+a+pas.r @@ -8167,6 +8189,43 @@ (rash (rsh 3 2 a) hex) -- :: +:: |jstd: json standard library +:: +++ jstd + =, ^jstd + |% + ++ rpc + =, ^rpc + |% + ++ request-to-hiss + |= [url=purl:eyre req=request] + ^- hiss:eyre + :- url + :+ %post + %- ~(gas in *math:eyre) + ~['Content-Type'^['application/json']~] + %- some + %- as-octt:mimes:html + (en-json:html (request-to-json req)) + :: + ++ request-to-json + |= request + ^- json + %- pairs:enjs:format + :~ jsonrpc+s+'0.2' + id+s+id + method+s+method + :: + :- %params + ^- json + ?- -.params + %list [%a +.params] + %object [%o (~(gas by *(map @t json)) +.params)] + == + == + -- + -- +:: :: |dawn: pre-boot request/response de/serialization and validation :: ++ dawn diff --git a/tests/sys/vane/ford.hoon b/tests/sys/vane/ford.hoon index 15c8663be..a9de88d8a 100644 --- a/tests/sys/vane/ford.hoon +++ b/tests/sys/vane/ford.hoon @@ -1980,7 +1980,7 @@ ++ test-dude ^- tang :: =/ schematic=schematic:ford-gate - :* %dude |.(>%test-no-error<) + :* %dude >%test-no-error< [%scry [%c care=%x bel=[[~nul %desk] /bar/foo]]] == :: @@ -2007,7 +2007,7 @@ ++ test-dude-error ^- tang :: =/ schematic=schematic:ford-gate - :* %dude |.(>%in-the-error-message<) + :* %dude >%in-the-error-message< [%scry [%c care=%x bel=[[~nul %desk] /bar/foo]]] == ::