From 88b834107cf89905d658c9cc704f77a269370f4a Mon Sep 17 00:00:00 2001 From: Ted Blackman Date: Thu, 14 May 2020 07:24:44 -0400 Subject: [PATCH] gall: pupal phase --- bin/solid.pill | 4 +- pkg/arvo/sys/vane/gall.hoon | 1545 ++++++++++++++++++++--------------- 2 files changed, 871 insertions(+), 678 deletions(-) diff --git a/bin/solid.pill b/bin/solid.pill index 6610aa14f..a1a73d72d 100644 --- a/bin/solid.pill +++ b/bin/solid.pill @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:600d74621bc74756d0488dc38dce8cc7a56c560ca0aa276f0cde81eadac35832 -size 13077251 +oid sha256:9c37d3bca1ecd239b23a4f3f6c8a046dbbcf6e1c1f48b7a89ae14eea2d9a5255 +size 13122161 diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index a220fa080..b89347402 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -6,13 +6,15 @@ =, gall => |% -:: +move: Arvo-level move ++| %main +:: +:: $move: Arvo-level move :: +$ move [=duct move=(wind note-arvo gift-arvo)] -:: +state-5: overall gall state, versioned +:: $state-6: overall gall state, versioned :: -+$ state-5 [%5 state] -:: +state: overall gall state ++$ state-6 [%6 state] +:: $state: overall gall state :: :: system-duct: TODO document :: outstanding: outstanding request queue @@ -27,19 +29,19 @@ yokes=(map term yoke) blocked=(map term (qeu blocked-move)) == -:: +watches: subscribers and publications +:: $watches: subscribers and publications :: :: TODO: rename this, to $ties? :: TODO: rename $boat and $bitt and document :: +$ watches [inbound=bitt outbound=boat] -:: +routes: new cuff; TODO: document +:: $routes: new cuff; TODO: document :: +$ routes $: disclosing=(unit (set ship)) attributing=ship == -:: +yoke: agent runner state +:: $yoke: agent runner state :: :: control-duct: TODO document :: live: is this agent running? TODO document better @@ -58,17 +60,17 @@ =beak marks=(map duct mark) == -:: +blocked-move: enqueued move to an agent +:: $blocked-move: enqueued move to an agent :: +$ blocked-move [=duct =routes =deal] -:: +stats: statistics +:: $stats: statistics :: -:: change: how many moves this agent has processed -:: eny: entropy -:: time: date of current event processing +:: change: how many moves this agent has processed +:: eny: entropy +:: time: date of current event processing :: +$ stats [change=@ud eny=@uvJ time=@da] -:: +ames-response: network response message (%boon) +:: $ames-response: network response message (%boon) :: :: %d: fact :: %x: quit @@ -77,7 +79,7 @@ $% [%d =mark noun=*] [%x ~] == -:: +ames-request: network request (%plea) +:: $ames-request: network request (%plea) :: :: %m: poke :: %l: watch-as @@ -90,7 +92,7 @@ [%s =path] [%u ~] == -:: +remote-request: kinds of agent actions that can cross the network +:: $remote-request: kinds of agent actions that can cross the network :: :: Used in wires to identify the kind of remote request we made. :: Bijective with the tags of $ames-request. @@ -102,14 +104,800 @@ %leave %missing == +:: |migrate: data structures for upgrades +:: ++| %migrate +:: +:: $chrysalis: pupal gall state, until agents have reloaded +:: ++$ chrysalis + $: queue=(qeu bolus) + =spore + == +:: $bolus: incoming move to a pupa, enqueued in a $chrysalis +:: ++$ bolus + $% [%call =duct =task:able] + [%take =wire =duct sign=sign-arvo] + == +:: $spore: structures for update, produced by +stay +:: ++$ spore + $: %6 + system-duct=duct + outstanding=(map [wire duct] (qeu remote-request)) + contacts=(set ship) + eggs=(map term egg) + blocked=(map term (qeu blocked-move)) + == +:: $egg: migratory agent state; $yoke with .old-state instead of .agent +:: ++$ egg + $: control-duct=duct + live=? + =stats + =watches + old-state=vase + =beak + marks=(map duct mark) + == -- -=| state=state-5 +:: pupal gall core, on upgrade +:: +=< =* adult-gate . + =| sac=chrysalis + |= [our=ship now=@da eny=@uvJ ski=sley] + =* pupal-gate . + =* adult-core (adult-gate +<) + |% + ++ call + |= [=duct dud=(unit goof) typ=type wrapped-task=(hobo task:able)] + =* call-args +< + ?: =(~ eggs.spore.sac) + ~> %slog.[0 leaf+"gall: direct morphogenesis"] + =. state.adult-gate spore.sac(eggs *(map term yoke)) + (call:adult-core call-args) + ?^ dud + (mean >mote.u.dud< tang.u.dud) + :: + =/ task ((harden task:able:gall) wrapped-task) + ~> %slog.[0 leaf+"gall: pupa call {<-.task>}"] + =. queue.sac (~(put to queue.sac) [%call duct task]) + [*(list move) pupal-gate] + ++ scry scry:adult-core + ++ stay ~|(%gall-subinvolution !!) + ++ take + |= [=wire =duct dud=(unit goof) typ=type sign=sign-arvo] + =* take-args +< + ?: =(~ eggs.spore.sac) + ~> %slog.[0 leaf+"gall: direct morphogenesis"] + =. state.adult-gate spore.sac(eggs *(map term yoke)) + (take:adult-core take-args) + ?^ dud + ~> %slog.[0 leaf+"gall: pupa take dud"] + (mean >mote.u.dud< tang.u.dud) + ?. =(/sys/lyv wire) + ~> %slog.[0 leaf+"gall: pupa take {(spud wire)} {<[- +<]:sign>}"] + =. queue.sac (~(put to queue.sac) [%take wire duct sign]) + [*(list move) pupal-gate] + ~> %slog.[0 leaf+"gall: pupa exiting chrysalis"] + =/ adult adult-core + =. state.adult + [%6 system-duct outstanding contacts yokes=~ blocked]:spore.sac + =/ mo-core (mo-abed:mo:adult duct) + =. mo-core + =/ apps=(list [dap=term =egg]) ~(tap by eggs.spore.sac) + |- ^+ mo-core + ?~ apps mo-core + ~> %slog.[0 leaf+"gall: pupa upgrading {}"] + =/ ap-core (ap-abut:ap:mo-core i.apps) + =^ tan ap-core (ap-install:ap-core `old-state.egg.i.apps) + ?^ tan + (mean u.tan) + $(apps t.apps, mo-core ap-abet:ap-core) + =. mo-core (mo-subscribe-to-agent-builds:mo-core now) + =^ moves adult-gate mo-abet:mo-core + =. moves + %+ weld moves + %+ turn ~(tap to queue.sac) + |= mov=bolus + ^- move + ~& gall-dequeue+-.mov + ?- -.mov + %call [duct.mov %slip %g task.mov] + %take [duct.mov %pass wire.mov %b %huck !>(sign.mov)] + == + ~> %slog.[0 leaf+"gall: metamorphosis"] + [moves adult-gate] + :: + ++ load + |^ + |= old=all-state + =. spore.sac (upgrade old) + ?. =(~ eggs.spore.sac) + pupal-gate + ~> %slog.[0 leaf+"gall: direct morphogenesis"] + adult-gate(state spore.sac(eggs *(map term yoke))) + :: + ++ upgrade + |= =all-state + ^- spore + :: + =? all-state ?=(%0 -.all-state) + (state-0-to-1 all-state) + :: + =? all-state ?=(%1 -.all-state) + (state-1-to-2 all-state) + :: + =? all-state ?=(%2 -.all-state) + (state-2-to-3 all-state) + :: + =? all-state ?=(%3 -.all-state) + (state-3-to-4 all-state) + :: + =? all-state ?=(%4 -.all-state) + (state-4-to-5 all-state) + :: + =? all-state ?=(%5 -.all-state) + (state-5-to-spore-6 all-state) + :: + ?> ?=(%6 -.all-state) + all-state + :: +all-state: upgrade path + :: + ++ all-state $%(state-0 state-1 state-2 state-3 state-4 state-5 spore) + :: + ++ state-5-to-spore-6 + |= =state-5 + ^- spore + =; eggs=(map term egg) state-5(- %6, yokes.agents-5 eggs) + %- ~(run by yokes.agents-5.state-5) + |=(=yoke `egg`yoke(agent on-save:agent.yoke)) + :: + ++ state-5 + $: %5 + =agents-5 + == + :: + ++ agents-5 + $: system-duct=duct + outstanding=(map [wire duct] (qeu remote-request)) + contacts=(set ship) + yokes=(map term yoke-5) + blocked=(map term (qeu blocked-move)) + == + :: + ++ yoke-5 + $: control-duct=duct + live=? + =stats + =watches + =agent + =beak + marks=(map duct mark) + == + :: + ++ state-4-to-5 + |= =state-4 + ^- state-5 + %= state-4 + - %5 + running.agents-4 + (~(run by running.agents-4.state-4) |=(yoke-3 +<+)) + == + :: + ++ state-4 + $: %4 + agents-4=agents-3 :: agents-3 is unchanged in state-4 + == + :: + ++ state-3-to-4 + |= =state-3 + ^- state-4 + %= state-3 + - %4 + outstanding.agents-3 ~ + == + :: + ++ state-3 + $: %3 + =agents-3 + == + :: + ++ agents-3 + $: system-duct=duct + outstanding=(map [wire duct] (qeu remote-request)) + contacts=(set ship) + running=(map term yoke-3) + blocked=(map term (qeu blocked-move)) + == + :: + ++ yoke-3 + $: cache=worm + control-duct=duct + live=? + =stats + =watches + =agent + =beak + marks=(map duct mark) + == + :: + ++ state-2-to-3 + |= =state-2 + ^- state-3 + %= state-2 + - %3 + running.agents-2 + %- ~(run by running.agents-2.state-2) + |= =yoke-2 + ^- yoke-3 + %= yoke-2 + agent-2 (agent-2-to-3 agent-2.yoke-2) + == + == + :: + ++ agent-2-to-3 + |= =agent-2 + ^- agent + => |% + ++ cards-2-to-3 + |= cards=(list card:^agent-2) + ^- (list card:agent) + %+ turn cards + |= =card:^agent-2 + ^- card:agent + ?. ?=([%give ?(%fact %kick) *] card) card + %=(card path.p (drop path.p.card)) + -- + |_ =bowl:gall + +* this . + pass ~(. agent-2 bowl) + ++ on-init + =^ cards agent-2 on-init:pass + [(cards-2-to-3 cards) this] + :: + ++ on-save + on-save:pass + :: + ++ on-load + |= old-state=vase + =^ cards agent-2 (on-load:pass old-state) + [(cards-2-to-3 cards) this] + :: + ++ on-poke + |= [=mark =vase] + =^ cards agent-2 (on-poke:pass mark vase) + [(cards-2-to-3 cards) this] + :: + ++ on-watch + |= =path + =^ cards agent-2 (on-watch:pass path) + [(cards-2-to-3 cards) this] + :: + ++ on-leave + |= =path + =^ cards agent-2 (on-leave:pass path) + [(cards-2-to-3 cards) this] + :: + ++ on-peek + |= =path + (on-peek:pass path) + :: + ++ on-agent + |= [=wire =sign:agent:gall] + =^ cards agent-2 (on-agent:pass wire sign) + [(cards-2-to-3 cards) this] + :: + ++ on-arvo + |= [=wire =sign-arvo] + =^ cards agent-2 (on-arvo:pass wire sign-arvo) + [(cards-2-to-3 cards) this] + :: + ++ on-fail + |= [=term =tang] + =^ cards agent-2 (on-fail:pass term tang) + [(cards-2-to-3 cards) this] + -- + :: + ++ state-2 + $: %2 + =agents-2 + == + :: + ++ agents-2 + $: system-duct=duct + outstanding=(map [wire duct] (qeu remote-request)) + contacts=(set ship) + running=(map term yoke-2) + blocked=(map term (qeu blocked-move)) + == + :: + ++ yoke-2 + $: cache=worm + control-duct=duct + live=? + =stats + =watches + =agent-2 + =beak + marks=(map duct mark) + == + :: + ++ agent-2 + =< form + |% + +$ step (quip card form) + +$ card (wind note gift) + +$ note note:agent + +$ task task:agent + +$ sign sign:agent + +$ gift + $% [%fact path=(unit path) =cage] + [%kick path=(unit path) ship=(unit ship)] + [%watch-ack p=(unit tang)] + [%poke-ack p=(unit tang)] + == + ++ form + $_ ^| + |_ bowl + ++ on-init + *(quip card _^|(..on-init)) + :: + ++ on-save + *vase + :: + ++ on-load + |~ old-state=vase + *(quip card _^|(..on-init)) + :: + ++ on-poke + |~ [mark vase] + *(quip card _^|(..on-init)) + :: + ++ on-watch + |~ path + *(quip card _^|(..on-init)) + :: + ++ on-leave + |~ path + *(quip card _^|(..on-init)) + :: + ++ on-peek + |~ path + *(unit (unit cage)) + :: + ++ on-agent + |~ [wire sign] + *(quip card _^|(..on-init)) + :: + ++ on-arvo + |~ [wire sign-arvo] + *(quip card _^|(..on-init)) + :: + ++ on-fail + |~ [term tang] + *(quip card _^|(..on-init)) + -- + -- + :: + ++ state-1-to-2 + |= =state-1 + ^- state-2 + %= state-1 + - %2 + +.agents-1 [~ +.agents-1.state-1] + == + :: + ++ state-1 + $: %1 + =agents-1 + == + :: + ++ agents-1 + $: system-duct=duct + contacts=(set ship) + running=(map term yoke-2) + blocked=(map term (qeu blocked-move)) + == + :: + ++ state-0-to-1 + |= =state-0 + ^- state-1 + %= state-0 + - %1 + running.agents-0 + %- ~(run by running.agents-0.state-0) + |= =yoke-0 + ^- yoke-2 + %= yoke-0 + agent-0 (agent-0-to-1 agent-0.yoke-0) + == + == + :: + ++ agent-0-to-1 + |= =agent-0 + ^- agent-2 + |_ =bowl:gall + +* this . + pass ~(. agent-0 bowl) + ++ on-init + =^ cards agent-0 on-init:pass + [cards this] + :: + ++ on-save + on-save:pass + :: + ++ on-load + |= old-state=vase + =^ cards agent-0 (on-load:pass old-state) + [cards this] + :: + ++ on-poke + |= [=mark =vase] + =^ cards agent-0 (on-poke:pass mark vase) + [cards this] + :: + ++ on-watch + |= =path + =^ cards agent-0 (on-watch:pass path) + [cards this] + :: + ++ on-leave + |= =path + =^ cards agent-0 (on-leave:pass path) + [cards this] + :: + ++ on-peek + |= =path + (on-peek:pass path) + :: + ++ on-agent + |= [=wire =sign:agent:gall] + =^ cards agent-0 (on-agent:pass wire sign) + [cards this] + :: + ++ on-arvo + |= [=wire =sign-arvo] + ?< ?=([%d %pack *] sign-arvo) + =^ cards agent-0 (on-arvo:pass wire `sign-arvo-0`sign-arvo) + [cards this] + :: + ++ on-fail + |= [=term =tang] + =^ cards agent-0 (on-fail:pass term tang) + [cards this] + -- + :: + ++ state-0 + $: %0 + =agents-0 + == + :: + ++ agents-0 + $: system-duct=duct + contacts=(set ship) + running=(map term yoke-0) + blocked=(map term (qeu blocked-move)) + == + :: + ++ yoke-0 + $: cache=worm + control-duct=duct + live=? + =stats + =watches + =agent-0 + =beak + marks=(map duct mark) + == + :: + ++ agent-0 + =< form + |% + +$ step (quip card form) + +$ card (wind note gift) + +$ note note:agent + +$ task task:agent + +$ gift gift:agent-2 + +$ sign sign:agent + ++ form + $_ ^| + |_ bowl + ++ on-init + *(quip card _^|(..on-init)) + :: + ++ on-save + *vase + :: + ++ on-load + |~ old-state=vase + *(quip card _^|(..on-init)) + :: + ++ on-poke + |~ [mark vase] + *(quip card _^|(..on-init)) + :: + ++ on-watch + |~ path + *(quip card _^|(..on-init)) + :: + ++ on-leave + |~ path + *(quip card _^|(..on-init)) + :: + ++ on-peek + |~ path + *(unit (unit cage)) + :: + ++ on-agent + |~ [wire sign] + *(quip card _^|(..on-init)) + :: + ++ on-arvo + |~ [wire sign-arvo-0] + *(quip card _^|(..on-init)) + :: + ++ on-fail + |~ [term tang] + *(quip card _^|(..on-init)) + -- + -- + :: + ++ sign-arvo-0 + $% {$a gift:able:ames} + $: $b + $% gift:able:behn + $>(%wris gift:able:clay) + $>(%writ gift:able:clay) + $>(%mere gift:able:clay) + $>(%unto gift:able:gall) + == + == + {$c gift:able:clay} + {$d $<(%pack gift:able:dill)} + {$f gift:ford} + [%e gift:able:eyre] + {$g gift:able:gall} + [%i gift:able:iris] + {$j gift:able:jael} + == + :: + ++ ford + |% + += gift + $% :: %made: build result; response to %build +task + :: + $: %made + :: date: formal date of the build + :: + date=@da + :: result: result of the build; either complete build, or error + :: + result=made-result + == == + += made-result + $% :: %complete: contains the result of the completed build + :: + [%complete =build-result] + :: %incomplete: couldn't finish build; contains error message + :: + [%incomplete =tang] + == + += build-result + $% :: %error: the build produced an error whose description is :message + :: + [%error message=tang] + :: %success: result of successful +build, tagged by +schematic sub-type + :: + $: %success + $^ [head=build-result tail=build-result] + $% [%$ =cage] + [%alts =build-result] + [%bake =cage] + [%bunt =cage] + [%call =vase] + [%cast =cage] + [%core =vase] + [%diff =cage] + [%hood =scaffold] + [%join =cage] + [%list results=(list build-result)] + [%mash =cage] + [%mute =cage] + [%pact =cage] + [%path =rail] + [%plan =vase] + [%reef =vase] + [%ride =vase] + [%scry =cage] + [%slim [=type =nock]] + [%slit =type] + [%vale =cage] + [%volt =cage] + [%walk results=(list mark-action)] + == == == + += scaffold + $: :: source-rail: the file this scaffold was parsed from + :: + source-rail=rail + :: zuse-version: the kelvin version of the standard library + :: + zuse-version=@ud + :: structures: files from %/sur which are included + :: + structures=(list cable) + :: libraries: files from %/lib which are included + :: + libraries=(list cable) + :: cranes: a list of resources to transform and include + :: + cranes=(list crane) + :: sources: hoon sources, either parsed or on the filesystem + :: + sources=(list hoon) + == + += mark-action [type=?(%grow %grab) source=term target=term] + += rail [=disc =spur] + +$ cable + $: face=(unit term) + file-path=term + == + += crane + $% $: :: %fssg: `/~` hoon literal + :: + :: `/~ ` produces a crane that evaluates arbitrary hoon. + :: + %fssg + =hoon + == + $: :: %fsbc: `/$` process query string + :: + :: `/$` will call a gate with the query string supplied to this + :: build. If no query string, this errors. + :: + %fsbc + =hoon + == + $: :: %fsbr: `/|` first of many options that succeeds + :: + :: `/|` takes a series of cranes and produces the first one + :: (left-to-right) that succeeds. If none succeed, it produces + :: stack traces from all of its arguments. + :: + %fsbr + :: choices: cranes to try + :: + choices=(list crane) + == + $: :: %fsts: `/=` wrap a face around a crane + :: + :: /= runs a crane (usually produced by another ford rune), takes + :: the result of that crane, and wraps a face around it. + :: + %fsts + :: face: face to apply + :: + face=term + :: crane: internal build step + :: + =crane + == + $: :: %fsdt: `/.` null-terminated list + :: + :: Produce a null-terminated list from a sequence of cranes, + :: terminated by a `==`. + :: + %fsdt + :: items: cranes to evaluate + :: + items=(list crane) + == + $: :: %fscm: `/,` switch by path + :: + :: `/,` is a switch statement, which picks a branch to evaluate + :: based on whether the current path matches the path in the + :: switch statement. Takes a sequence of pairs of (path, crane) + :: terminated by a `==`. + :: + %fscm + :: cases: produces evaluated crane of first +spur match + :: + cases=(list (pair spur crane)) + == + $: :: %fspm: `/&` pass through a series of marks + :: + :: `/&` passes a crane through multiple marks, right-to-left. + :: + %fspm + :: marks: marks to apply to :crane, in reverse order + :: + marks=(list mark) + =crane + == + $: :: %fscb: `/_` run a crane on each file in the current directory + :: + :: `/_` takes a crane as an argument. It produces a new crane + :: representing the result of mapping the supplied crane over the + :: list of files in the current directory. The keys in the + :: resulting map are the basenames of the files in the directory, + :: and each value is the result of running that crane on the + :: contents of the file. + :: + %fscb + =crane + == + $: :: %fssm: `/;` operate on + :: + :: `/;` takes a hoon and a crane. The hoon should evaluate to a + :: gate, which is then called with the result of the crane as its + :: sample. + :: + %fssm + =hoon + =crane + == + $: :: %fscl: `/:` evaluate at path + :: + :: `/:` takes a path and a +crane, and evaluates the crane with + :: the current path set to the supplied path. + :: + %fscl + :: path: late bound path to be resolved relative to current beak + :: + :: This becomes current path of :crane + :: + path=truss + =crane + == + $: :: %fskt: `/^` cast + :: + :: `/^` takes a +mold and a +crane, and casts the result of the + :: crane to the mold. + :: + %fskt + :: mold: evaluates to a mold to be applied to :crane + :: + =spec + =crane + == + $: :: %fstr: `/*` run :crane on all files with current path as prefix + :: + %fstr + =crane + == + $: :: %fszp: `/!mark/` evaluate as hoon, then pass through mark + :: + %fszp + =mark + == + $: :: %fszy: `/mark/` passes current path through :mark + :: + %fszy + =mark + == == + += truss + $: pre=(unit tyke) + pof=(unit [p=@ud q=tyke]) + == + -- + -- + -- +:: adult gall vane interface, for type compatibility with pupa +:: +=| state=state-6 |= [our=ship now=@da eny=@uvJ ski=sley] +=* gall-payload . +=< ~% %gall-wrap ..mo ~ + |% + ++ call ^call + ++ load ^load + ++ scry ^scry + ++ stay ^stay + ++ take ^take + -- ~% %gall-top ..is ~ |% -:: +gall-payload: gall payload -:: -++ gall-payload + :: +mo: Arvo-level move handling :: :: An outer core responsible for routing moves to and from Arvo; it calls @@ -170,20 +958,12 @@ :: ++ mo-receive-core ~/ %mo-receive-core - |= [dap=term bek=beak =cage] + |= [dap=term bek=beak =agent] ^+ mo-core :: =/ existing (~(get by yokes.state) dap) =/ re ?~(existing "" "re") ~> %slog.[0 leaf+"gall: {re}loading {}"] - ?. =(%vase p.cage) - (mo-give %onto |+[leaf+"gall: bad mark {} for agent {}"]~) - :: - =/ maybe-new-agent (mule |.(!<(agent !<(vase q.cage)))) - ?: ?=(%| -.maybe-new-agent) - =/ err [[%leaf "{}: not valid agent"] p.maybe-new-agent] - (mo-give %onto %.n err) - =/ =agent p.maybe-new-agent :: ?^ existing =. yokes.state @@ -216,20 +996,41 @@ (mo-give %onto [%.y suss]) :: +mo-subscribe-to-agent-builds: request agent update notices :: + :: Also subscribe to our own source path, in case we get reloaded + :: but none of the agents do. This way, Clay will still notify us, + :: and we'll be able to exit the chrysalis. + :: ++ mo-subscribe-to-agent-builds |= date=@da ^+ mo-core =. mo-core (mo-abed system-duct.state) - =/ =wire /sys/lyv :: TODO: add $aeon to wire as sanity check + =/ =wire /sys/lyv =. mo-core (mo-pass /sys/lyv %c %warp our %home ~) =/ =mool:clay :- da+date %- ~(gas in *(set [care:clay path])) + :- [%z /sys/vane/gall/hoon] %+ turn ~(tap in ~(key by yokes.state)) |= dap=term ^- [care:clay path] [%a /app/[dap]/hoon] (mo-pass wire %c %warp our %home ~ %mult mool) + :: +mo-scry-agent-cage: read $agent core from clay + :: + ++ mo-scry-agent-cage + |= [dap=term =case:clay] + ^- (each agent tang) + =/ bek=beak [our %home case] + =/ sky (ski [%141 %noun] ~ %ca bek /hoon/[dap]/app) + ?~ sky |+[leaf+"gall: {} scry blocked"]~ + ?~ u.sky |+[leaf+"gall: {} scry failed"]~ + =/ =cage u.u.sky + ?. =(%vase p.cage) + |+[leaf+"gall: bad mark {} for agent {}"]~ + =/ res (mule |.(!<(agent !<(vase q.cage)))) + ?: ?=(%& -.res) + &+p.res + |+[[leaf+"gall: {} not valid agent"] p.res] :: +mo-send-foreign-request: handle local request to .ship :: ++ mo-send-foreign-request @@ -354,7 +1155,13 @@ =/ =beak [(slav %p her) desk da+tim] ?> ?=([?(%b %c) %writ *] sign-arvo) ?^ p.sign-arvo - =. mo-core (mo-receive-core dap beak r.u.p.sign-arvo) + =/ cag=cage r.u.p.sign-arvo + ?. =(%vase p.cag) + (mo-give %onto |+[leaf+"gall: invalid %writ {} for {}"]~) + =/ res (mule |.(!<(agent !<(vase q.cag)))) + ?: ?=(%| -.res) + (mo-give %onto |+[leaf+"gall: {}" p.res]) + =. mo-core (mo-receive-core dap beak p.res) (mo-subscribe-to-agent-builds tim) (mo-give %onto |+[leaf+"gall: failed to build agent {}"]~) :: +mo-handle-sys-lyv: handle notice that agents have been rebuilt @@ -374,8 +1181,10 @@ ^+ cor ?> =(%a care) =/ dap dap:;;([%app dap=@tas %hoon ~] path) - =/ cage (need (need (ski [%141 %noun] ~ %ca bek (flop path)))) - (mo-receive-core:cor dap bek cage) + =/ rag (mo-scry-agent-cage dap p.sign-arvo) + ?: ?=(%| -.rag) + (mean p.rag) + (mo-receive-core:cor dap bek p.rag) :: +mo-handle-sys-lag: handle an ames %clog notification :: ++ mo-handle-sys-lag @@ -747,17 +1556,28 @@ ~/ %ap-abed |= [dap=term =routes] ^+ ap-core - :: - =/ =yoke - =/ running (~(got by yokes.state) dap) - =/ =stats - :+ +(change.stats.running) - (shaz (mix (add dap change.stats.running) eny)) - now - running(stats stats) - :: + (ap-yoke dap (~(got by yokes.state) dap)) + :: +ap-hatch: initialize agent state from $egg, after upgrade + :: + ++ ap-abut + |= [dap=term =egg] + ^+ ap-core + =/ res (mo-scry-agent-cage dap da+now) + ?: ?=(%| -.res) + (mean p.res) + =/ =yoke egg(old-state `agent`p.res) + (ap-yoke dap yoke) + :: +ap-yoke: initialize agent state, starting from a $yoke + :: + ++ ap-yoke + |= [dap=term =yoke] + ^+ ap-core + =. stats.yoke + :+ +(change.stats.yoke) + (shaz (mix (add dap change.stats.yoke) eny)) + now =. agent-name dap - =. agent-routes routes + =. agent-routes [disclosing=~ attributing=our] =. current-agent yoke =. agent-duct hen ap-core @@ -1388,640 +2208,9 @@ %trim [~ gall-payload] %vega [~ gall-payload] == -:: +load: recreate vane +:: +load: recreate vane; note, only valid if called from pupa :: -++ load - |^ - |= =all-state - ^+ gall-payload - :: - =? all-state ?=(%0 -.all-state) - (state-0-to-1 all-state) - :: - =? all-state ?=(%1 -.all-state) - (state-1-to-2 all-state) - :: - =? all-state ?=(%2 -.all-state) - (state-2-to-3 all-state) - :: - =? all-state ?=(%3 -.all-state) - (state-3-to-4 all-state) - :: - =? all-state ?=(%4 -.all-state) - (state-4-to-5 all-state) - :: - ?> ?=(%5 -.all-state) - gall-payload(state all-state) - :: - :: +all-state: upgrade path - :: - ++ all-state $%(state-0 state-1 state-2 state-3 state-4 state-5) - :: - ++ state-4-to-5 - |= =state-4 - ^- state-5 - %= state-4 - - %5 - running.agents-4 - (~(run by running.agents-4.state-4) |=(yoke-3 +<+)) - == - :: - ++ state-4 - $: %4 - agents-4=agents-3 :: agents-3 is unchanged in state-4 - == - :: - ++ state-3-to-4 - |= =state-3 - ^- state-4 - %= state-3 - - %4 - outstanding.agents-3 ~ - == - :: - ++ state-3 - $: %3 - =agents-3 - == - :: - ++ agents-3 - $: system-duct=duct - outstanding=(map [wire duct] (qeu remote-request)) - contacts=(set ship) - running=(map term yoke-3) - blocked=(map term (qeu blocked-move)) - == - :: - ++ yoke-3 - $: cache=worm - control-duct=duct - live=? - =stats - =watches - =agent - =beak - marks=(map duct mark) - == - :: - ++ state-2-to-3 - |= =state-2 - ^- state-3 - %= state-2 - - %3 - running.agents-2 - %- ~(run by running.agents-2.state-2) - |= =yoke-2 - ^- yoke-3 - %= yoke-2 - agent-2 (agent-2-to-3 agent-2.yoke-2) - == - == - :: - ++ agent-2-to-3 - |= =agent-2 - ^- agent - => |% - ++ cards-2-to-3 - |= cards=(list card:^agent-2) - ^- (list card:agent) - %+ turn cards - |= =card:^agent-2 - ^- card:agent - ?. ?=([%give ?(%fact %kick) *] card) card - %=(card path.p (drop path.p.card)) - -- - |_ =bowl:gall - +* this . - pass ~(. agent-2 bowl) - ++ on-init - =^ cards agent-2 on-init:pass - [(cards-2-to-3 cards) this] - :: - ++ on-save - on-save:pass - :: - ++ on-load - |= old-state=vase - =^ cards agent-2 (on-load:pass old-state) - [(cards-2-to-3 cards) this] - :: - ++ on-poke - |= [=mark =vase] - =^ cards agent-2 (on-poke:pass mark vase) - [(cards-2-to-3 cards) this] - :: - ++ on-watch - |= =path - =^ cards agent-2 (on-watch:pass path) - [(cards-2-to-3 cards) this] - :: - ++ on-leave - |= =path - =^ cards agent-2 (on-leave:pass path) - [(cards-2-to-3 cards) this] - :: - ++ on-peek - |= =path - (on-peek:pass path) - :: - ++ on-agent - |= [=wire =sign:agent:gall] - =^ cards agent-2 (on-agent:pass wire sign) - [(cards-2-to-3 cards) this] - :: - ++ on-arvo - |= [=wire =sign-arvo] - =^ cards agent-2 (on-arvo:pass wire sign-arvo) - [(cards-2-to-3 cards) this] - :: - ++ on-fail - |= [=term =tang] - =^ cards agent-2 (on-fail:pass term tang) - [(cards-2-to-3 cards) this] - -- - :: - ++ state-2 - $: %2 - =agents-2 - == - :: - ++ agents-2 - $: system-duct=duct - outstanding=(map [wire duct] (qeu remote-request)) - contacts=(set ship) - running=(map term yoke-2) - blocked=(map term (qeu blocked-move)) - == - :: - ++ yoke-2 - $: cache=worm - control-duct=duct - live=? - =stats - =watches - =agent-2 - =beak - marks=(map duct mark) - == - :: - ++ agent-2 - =< form - |% - +$ step (quip card form) - +$ card (wind note gift) - +$ note note:agent - +$ task task:agent - +$ sign sign:agent - +$ gift - $% [%fact path=(unit path) =cage] - [%kick path=(unit path) ship=(unit ship)] - [%watch-ack p=(unit tang)] - [%poke-ack p=(unit tang)] - == - ++ form - $_ ^| - |_ bowl - ++ on-init - *(quip card _^|(..on-init)) - :: - ++ on-save - *vase - :: - ++ on-load - |~ old-state=vase - *(quip card _^|(..on-init)) - :: - ++ on-poke - |~ [mark vase] - *(quip card _^|(..on-init)) - :: - ++ on-watch - |~ path - *(quip card _^|(..on-init)) - :: - ++ on-leave - |~ path - *(quip card _^|(..on-init)) - :: - ++ on-peek - |~ path - *(unit (unit cage)) - :: - ++ on-agent - |~ [wire sign] - *(quip card _^|(..on-init)) - :: - ++ on-arvo - |~ [wire sign-arvo] - *(quip card _^|(..on-init)) - :: - ++ on-fail - |~ [term tang] - *(quip card _^|(..on-init)) - -- - -- - :: - ++ state-1-to-2 - |= =state-1 - ^- state-2 - %= state-1 - - %2 - +.agents-1 [~ +.agents-1.state-1] - == - :: - ++ state-1 - $: %1 - =agents-1 - == - :: - ++ agents-1 - $: system-duct=duct - contacts=(set ship) - running=(map term yoke-2) - blocked=(map term (qeu blocked-move)) - == - :: - ++ state-0-to-1 - |= =state-0 - ^- state-1 - %= state-0 - - %1 - running.agents-0 - %- ~(run by running.agents-0.state-0) - |= =yoke-0 - ^- yoke-2 - %= yoke-0 - agent-0 (agent-0-to-1 agent-0.yoke-0) - == - == - :: - ++ agent-0-to-1 - |= =agent-0 - ^- agent-2 - |_ =bowl:gall - +* this . - pass ~(. agent-0 bowl) - ++ on-init - =^ cards agent-0 on-init:pass - [cards this] - :: - ++ on-save - on-save:pass - :: - ++ on-load - |= old-state=vase - =^ cards agent-0 (on-load:pass old-state) - [cards this] - :: - ++ on-poke - |= [=mark =vase] - =^ cards agent-0 (on-poke:pass mark vase) - [cards this] - :: - ++ on-watch - |= =path - =^ cards agent-0 (on-watch:pass path) - [cards this] - :: - ++ on-leave - |= =path - =^ cards agent-0 (on-leave:pass path) - [cards this] - :: - ++ on-peek - |= =path - (on-peek:pass path) - :: - ++ on-agent - |= [=wire =sign:agent:gall] - =^ cards agent-0 (on-agent:pass wire sign) - [cards this] - :: - ++ on-arvo - |= [=wire =sign-arvo] - ?< ?=([%d %pack *] sign-arvo) - =^ cards agent-0 (on-arvo:pass wire `sign-arvo-0`sign-arvo) - [cards this] - :: - ++ on-fail - |= [=term =tang] - =^ cards agent-0 (on-fail:pass term tang) - [cards this] - -- - :: - ++ state-0 - $: %0 - =agents-0 - == - :: - ++ agents-0 - $: system-duct=duct - contacts=(set ship) - running=(map term yoke-0) - blocked=(map term (qeu blocked-move)) - == - :: - ++ yoke-0 - $: cache=worm - control-duct=duct - live=? - =stats - =watches - =agent-0 - =beak - marks=(map duct mark) - == - :: - ++ agent-0 - =< form - |% - +$ step (quip card form) - +$ card (wind note gift) - +$ note note:agent - +$ task task:agent - +$ gift gift:agent-2 - +$ sign sign:agent - ++ form - $_ ^| - |_ bowl - ++ on-init - *(quip card _^|(..on-init)) - :: - ++ on-save - *vase - :: - ++ on-load - |~ old-state=vase - *(quip card _^|(..on-init)) - :: - ++ on-poke - |~ [mark vase] - *(quip card _^|(..on-init)) - :: - ++ on-watch - |~ path - *(quip card _^|(..on-init)) - :: - ++ on-leave - |~ path - *(quip card _^|(..on-init)) - :: - ++ on-peek - |~ path - *(unit (unit cage)) - :: - ++ on-agent - |~ [wire sign] - *(quip card _^|(..on-init)) - :: - ++ on-arvo - |~ [wire sign-arvo-0] - *(quip card _^|(..on-init)) - :: - ++ on-fail - |~ [term tang] - *(quip card _^|(..on-init)) - -- - -- - :: - ++ sign-arvo-0 - $% {$a gift:able:ames} - $: $b - $% gift:able:behn - $>(%wris gift:able:clay) - $>(%writ gift:able:clay) - $>(%mere gift:able:clay) - $>(%unto gift:able:gall) - == - == - {$c gift:able:clay} - {$d $<(%pack gift:able:dill)} - {$f gift:ford} - [%e gift:able:eyre] - {$g gift:able:gall} - [%i gift:able:iris] - {$j gift:able:jael} - == - :: - ++ ford - |% - += gift - $% :: %made: build result; response to %build +task - :: - $: %made - :: date: formal date of the build - :: - date=@da - :: result: result of the build; either complete build, or error - :: - result=made-result - == == - += made-result - $% :: %complete: contains the result of the completed build - :: - [%complete =build-result] - :: %incomplete: couldn't finish build; contains error message - :: - [%incomplete =tang] - == - += build-result - $% :: %error: the build produced an error whose description is :message - :: - [%error message=tang] - :: %success: result of successful +build, tagged by +schematic sub-type - :: - $: %success - $^ [head=build-result tail=build-result] - $% [%$ =cage] - [%alts =build-result] - [%bake =cage] - [%bunt =cage] - [%call =vase] - [%cast =cage] - [%core =vase] - [%diff =cage] - [%hood =scaffold] - [%join =cage] - [%list results=(list build-result)] - [%mash =cage] - [%mute =cage] - [%pact =cage] - [%path =rail] - [%plan =vase] - [%reef =vase] - [%ride =vase] - [%scry =cage] - [%slim [=type =nock]] - [%slit =type] - [%vale =cage] - [%volt =cage] - [%walk results=(list mark-action)] - == == == - += scaffold - $: :: source-rail: the file this scaffold was parsed from - :: - source-rail=rail - :: zuse-version: the kelvin version of the standard library - :: - zuse-version=@ud - :: structures: files from %/sur which are included - :: - structures=(list cable) - :: libraries: files from %/lib which are included - :: - libraries=(list cable) - :: cranes: a list of resources to transform and include - :: - cranes=(list crane) - :: sources: hoon sources, either parsed or on the filesystem - :: - sources=(list hoon) - == - += mark-action [type=?(%grow %grab) source=term target=term] - += rail [=disc =spur] - +$ cable - $: face=(unit term) - file-path=term - == - += crane - $% $: :: %fssg: `/~` hoon literal - :: - :: `/~ ` produces a crane that evaluates arbitrary hoon. - :: - %fssg - =hoon - == - $: :: %fsbc: `/$` process query string - :: - :: `/$` will call a gate with the query string supplied to this - :: build. If no query string, this errors. - :: - %fsbc - =hoon - == - $: :: %fsbr: `/|` first of many options that succeeds - :: - :: `/|` takes a series of cranes and produces the first one - :: (left-to-right) that succeeds. If none succeed, it produces - :: stack traces from all of its arguments. - :: - %fsbr - :: choices: cranes to try - :: - choices=(list crane) - == - $: :: %fsts: `/=` wrap a face around a crane - :: - :: /= runs a crane (usually produced by another ford rune), takes - :: the result of that crane, and wraps a face around it. - :: - %fsts - :: face: face to apply - :: - face=term - :: crane: internal build step - :: - =crane - == - $: :: %fsdt: `/.` null-terminated list - :: - :: Produce a null-terminated list from a sequence of cranes, - :: terminated by a `==`. - :: - %fsdt - :: items: cranes to evaluate - :: - items=(list crane) - == - $: :: %fscm: `/,` switch by path - :: - :: `/,` is a switch statement, which picks a branch to evaluate - :: based on whether the current path matches the path in the - :: switch statement. Takes a sequence of pairs of (path, crane) - :: terminated by a `==`. - :: - %fscm - :: cases: produces evaluated crane of first +spur match - :: - cases=(list (pair spur crane)) - == - $: :: %fspm: `/&` pass through a series of marks - :: - :: `/&` passes a crane through multiple marks, right-to-left. - :: - %fspm - :: marks: marks to apply to :crane, in reverse order - :: - marks=(list mark) - =crane - == - $: :: %fscb: `/_` run a crane on each file in the current directory - :: - :: `/_` takes a crane as an argument. It produces a new crane - :: representing the result of mapping the supplied crane over the - :: list of files in the current directory. The keys in the - :: resulting map are the basenames of the files in the directory, - :: and each value is the result of running that crane on the - :: contents of the file. - :: - %fscb - =crane - == - $: :: %fssm: `/;` operate on - :: - :: `/;` takes a hoon and a crane. The hoon should evaluate to a - :: gate, which is then called with the result of the crane as its - :: sample. - :: - %fssm - =hoon - =crane - == - $: :: %fscl: `/:` evaluate at path - :: - :: `/:` takes a path and a +crane, and evaluates the crane with - :: the current path set to the supplied path. - :: - %fscl - :: path: late bound path to be resolved relative to current beak - :: - :: This becomes current path of :crane - :: - path=truss - =crane - == - $: :: %fskt: `/^` cast - :: - :: `/^` takes a +mold and a +crane, and casts the result of the - :: crane to the mold. - :: - %fskt - :: mold: evaluates to a mold to be applied to :crane - :: - =spec - =crane - == - $: :: %fstr: `/*` run :crane on all files with current path as prefix - :: - %fstr - =crane - == - $: :: %fszp: `/!mark/` evaluate as hoon, then pass through mark - :: - %fszp - =mark - == - $: :: %fszy: `/mark/` passes current path through :mark - :: - %fszy - =mark - == == - += truss - $: pre=(unit tyke) - pof=(unit [p=@ud q=tyke]) - == - -- - -- +++ load !! :: +scry: standard scry :: ++ scry @@ -2066,7 +2255,11 @@ (mo-peek:mo dap routes care path) :: +stay: save without cache :: -++ stay state +++ stay + ^- spore + =; eggs=(map term egg) state(yokes eggs) + %- ~(run by yokes.state) + |=(=yoke `egg`yoke(agent on-save:agent.yoke)) :: +take: response :: ++ take