diff --git a/pkg/arvo/app/spider.hoon b/pkg/arvo/app/spider.hoon index 0bc957b200..b2be418b49 100644 --- a/pkg/arvo/app/spider.hoon +++ b/pkg/arvo/app/spider.hoon @@ -1,5 +1,5 @@ /- spider -/+ libstrand=strand, default-agent, verb, server +/+ libstrand=strand, default-agent, verb, server, dbug =, strand=strand:libstrand ~% %spider-top ..part ~ |% @@ -18,7 +18,7 @@ $: starting=(map yarn [=trying =vase]) running=trie tid=(map tid yarn) - serving=(map tid [@ta =mark =desk]) + serving=(map tid [(unit @ta) =mark =desk]) == :: +$ clean-slate-any @@ -26,10 +26,19 @@ $% clean-slate-sig clean-slate-1 clean-slate-2 + clean-slate-3 clean-slate == :: +$ clean-slate + $: %4 + starting=(map yarn [=trying =vase]) + running=(list yarn) + tid=(map tid yarn) + serving=(map tid [(unit @ta) =mark =desk]) + == +:: ++$ clean-slate-3 $: %3 starting=(map yarn [=trying =vase]) running=(list yarn) @@ -144,6 +153,7 @@ (welp next-1 next-2) -- :: +%- agent:dbug ^- agent:gall =| =state =< @@ -156,7 +166,7 @@ def ~(. (default-agent this %|) bowl) bec byk.bowl(r da+now.bowl) :: - ++ on-init + ++ on-init ^- (quip card _this) :_ this ~[bind-eyre:sc] @@ -167,10 +177,11 @@ =+ !<(any=clean-slate-any old-state) =? any ?=(^ -.any) (old-to-1 any) =? any ?=(~ -.any) (old-to-1 any) - =^ upgrade-cards any + =^ upgrade-cards any (old-to-2 any) =. any (old-to-3 any) - ?> ?=(%3 -.any) + =. any (old-to-4 any) + ?> ?=(%4 -.any) :: =. tid.state tid.any =/ yarns=(list yarn) @@ -193,8 +204,8 @@ ++ old-to-2 |= old=clean-slate-any ^- (quip card clean-slate-any) - ?> ?=(?(%1 %2 %3) -.old) - ?: ?=(?(%2 %3) -.old) + ?> ?=(?(%1 %2 %3 %4) -.old) + ?: ?=(?(%2 %3 %4) -.old) `old :- ~[bind-eyre:sc] :* %2 @@ -206,9 +217,9 @@ :: ++ old-to-3 |= old=clean-slate-any - ^- clean-slate - ?> ?=(?(%2 %3) -.old) - ?: ?=(%3 -.old) + ^- clean-slate-any + ?> ?=(?(%2 %3 %4) -.old) + ?: ?=(?(%3 %4) -.old) old :* %3 starting.old @@ -216,6 +227,18 @@ tid.old (~(run by serving.old) |=([id=@ta =mark] [id mark q.byk.bowl])) == + ++ old-to-4 + |= old=clean-slate-any + ^- clean-slate + ?> ?=(?(%3 %4) -.old) + ?: ?=(%4 -.old) + old + :* %4 + starting.old + running.old + tid.old + (~(run by serving.old) |=([id=@ta =mark =desk] [`id mark q.byk.bowl])) + == -- :: ++ on-poke @@ -230,7 +253,7 @@ %spider-start (handle-start-thread:sc !<(start-args vase)) %spider-stop (handle-stop-thread:sc !<([tid ?] vase)) :: - %handle-http-request + %handle-http-request (handle-http-request:sc !<([@ta =inbound-request:eyre] vase)) == [cards this] @@ -309,7 +332,7 @@ |= [eyre-id=@ta =inbound-request:eyre] ^- (quip card _state) ::?> authenticated.inbound-request - =/ url + =/ url (parse-request-line:server url.request.inbound-request) ?> ?=([%spider @t @t @t @t ~] site.url) =* desk i.t.site.url @@ -318,14 +341,10 @@ =* output-mark i.t.t.t.t.site.url =/ =tid (new-thread-id thread) =. serving.state - (~(put by serving.state) tid [eyre-id output-mark desk]) + (~(put by serving.state) tid [`eyre-id output-mark desk]) :: TODO: speed this up somehow. we spend about 15ms in this arm alone :: - =+ .^ - =tube:clay - %cc - /(scot %p our.bowl)/[desk]/(scot %da now.bowl)/json/[input-mark] - == + =/ tube (convert-tube %json input-mark desk bowl) ?> ?=(^ body.request.inbound-request) =/ body=json (need (de-json:html q.u.body.request.inbound-request)) =/ input=vase (slop !>(~) (tube !>(body))) @@ -384,7 +403,8 @@ :: =: starting.state (~(put by starting.state) yarn [%build vase]) tid.state (~(put by tid.state) new-tid yarn) - == + serving.state (~(put by serving.state) new-tid [~ %noun q.beak]) + == =/ pax=path ~| no-file-for-thread+file (need (get-fit:clay beak %ted file)) @@ -453,7 +473,7 @@ ^- (quip card ^state) =/ m (strand ,vase) ?. (has-yarn running.state yarn) - %- (slog leaf+"spider got input for non-existent {} 2" ~) + %- (slog leaf+"spider got input for non-existent {}" ~) `state =/ =eval-form:eval:m thread-form:(need (get-yarn running.state yarn)) @@ -511,11 +531,13 @@ |= [=tid =term =tang] ^- (quip card ^state) =- (fall - `state) - %+ bind + %+ bind (~(get by serving.state) tid) - |= [eyre-id=@ta output=mark =desk] + |= [eyre-id=(unit @ta) output=mark =desk] :_ state(serving (~(del by serving.state) tid)) - %+ give-simple-payload:app:server eyre-id + ?~ eyre-id + ~ + %+ give-simple-payload:app:server u.eyre-id ^- simple-payload:http :_ ~ :_ ~ ?. ?=(http-error:spider term) @@ -541,16 +563,14 @@ |= [=tid =vase] ^- (quip card ^state) =- (fall - `state) - %+ bind + %+ bind (~(get by serving.state) tid) - |= [eyre-id=@ta output=mark =desk] - =+ .^ - =tube:clay - %cc - /(scot %p our.bowl)/[desk]/(scot %da now.bowl)/[output]/json - == + |= [eyre-id=(unit @ta) output=mark =desk] + ?~ eyre-id + `state + =/ tube (convert-tube output %json desk bowl) :_ state(serving (~(del by serving.state) tid)) - %+ give-simple-payload:app:server eyre-id + %+ give-simple-payload:app:server u.eyre-id (json-response:gen:server !<(json (tube vase))) :: ++ thread-done @@ -581,6 +601,7 @@ =/ =tid (yarn-to-tid yarn) =: running.state (del-yarn running.state yarn) tid.state (~(del by tid.state) tid) + serving.state (~(del by serving.state) (yarn-to-tid yarn)) == :_ state %+ murn ~(tap by wex.bowl) @@ -597,14 +618,14 @@ |= [=yarn =bowl:gall] ^- bowl:spider :* our.bowl - src.bowl + src.bowl (yarn-to-tid yarn) (yarn-to-parent yarn) wex.bowl sup.bowl eny.bowl now.bowl - byk.bowl + (yarn-to-byk yarn bowl) == :: ++ yarn-to-tid @@ -623,7 +644,25 @@ ~ `i.t.nary :: +++ yarn-to-byk + |= [=yarn =bowl:gall] + + =/ [* * =desk] + ~| "no desk associated with {}" + %- ~(got by serving.state) (yarn-to-tid yarn) + =/ boc bec + boc(q desk) +:: ++ clean-state !> ^- clean-slate - 3+state(running (turn (tap-yarn running.state) head)) + 4+state(running (turn (tap-yarn running.state) head)) +:: +++ convert-tube + |= [from=mark to=mark =desk =bowl:gall] + .^ + tube:clay + %cc + /(scot %p our.bowl)/[desk]/(scot %da now.bowl)/[from]/[to] + == + -- diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index 0d133de855..7189749a89 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -1590,9 +1590,7 @@ =. mim.dom (apply-changes-to-mim mim.dom mim) =. fod.dom ford-cache.args =. ..park (emil (print q.old-yaki data)) - :: =? ..park &(updated !dist-upgraded.ruf) migrate-dist - :: wake:(ergo mim) :: ++ migrate-dist diff --git a/pkg/arvo/sys/vane/gall.hoon b/pkg/arvo/sys/vane/gall.hoon index 41a94bc1ae..25086045d6 100644 --- a/pkg/arvo/sys/vane/gall.hoon +++ b/pkg/arvo/sys/vane/gall.hoon @@ -1408,6 +1408,9 @@ ?. ?=(%raw-fact -.unto) [unto ap-core] =/ =case:clay da+now + ?: ?=(%spider agent-name) + :- [%fact mark.unto !>(noun.unto)] + ap-core =/ sky (rof ~ %cb [our q.beak.yoke case] /[mark.unto]) ?. ?=([~ ~ *] sky) (mean leaf+"gall: ames mark fail {}" ~) diff --git a/pkg/base-dev/lib/strand.hoon b/pkg/base-dev/lib/strand.hoon index b618f2d4e3..a955daec8d 100644 --- a/pkg/base-dev/lib/strand.hoon +++ b/pkg/base-dev/lib/strand.hoon @@ -128,6 +128,17 @@ [%done value=a] == :: + ++ validate-mark + |= [in=* =mark =bowl] + ^- cage + =+ .^ =dais:clay %cb + /(scot %p our.bowl)/[q.byk.bowl]/(scot %da now.bowl)/[mark] + == + =/ res (mule |.((vale.dais in))) + ?: ?=(%| -.res) + ~|(%spider-mark-fail (mean leaf+"spider: ames vale fail {}" p.res)) + [mark p.res] + :: :: Take a new sign and run the strand against it :: ++ take @@ -137,6 +148,15 @@ |= [=eval-form =strand-input] ^- [[(list card) =eval-result] _eval-form] =* take-loop $ + =. in.strand-input + ?~ in.strand-input ~ + =/ in u.in.strand-input + ?. ?=(%agent -.in) `in + ?. ?=(%fact -.sign.in) `in + :: + :- ~ + :+ %agent wire.in + [%fact (validate-mark q.cage.sign.in p.cage.sign.in bowl.strand-input)] :: run the strand callback :: =/ =output (form.eval-form strand-input) @@ -165,3 +185,4 @@ -- -- -- +:: diff --git a/pkg/base-dev/mar/glob.hoon b/pkg/base-dev/mar/glob.hoon deleted file mode 100644 index 5c23a80cfd..0000000000 --- a/pkg/base-dev/mar/glob.hoon +++ /dev/null @@ -1,11 +0,0 @@ -|_ gob=(map path mime) -++ grow - |% - ++ noun gob - -- -++ grab - |% - ++ noun (map path mime) - -- -++ grad ~&(%grid-mar %noun) --- diff --git a/pkg/garden/app/docket.hoon b/pkg/garden/app/docket.hoon index d7f293bbca..53a02ceff7 100644 --- a/pkg/garden/app/docket.hoon +++ b/pkg/garden/app/docket.hoon @@ -274,54 +274,18 @@ ?~ p.sign `state ((slog leaf+"Failed to uninstall %{(trip desk)}" u.p.sign) `state) :: - [%glob @ %ames @ ~] - ?- -.sign - %kick `state - %poke-ack ~&([dap.bowl %unexpected-poke-ack] `state) - :: - %watch-ack - ?~ p.sign `state - %- %- slog - leaf+"docket: failed to fetch glob over ames for {(trip desk)}" - =. charges (new-chad:cha hung+'failed to fetch glob via ames') - [~[add-fact:cha] state] - :: - %fact - ?. =(%glob p.cage.sign) - ~& [dap.bowl %unexpected-fact from=src.bowl p.cage.sign] - `state - =+ !<(=glob q.cage.sign) - =/ =docket docket:(~(got by charges) desk) - ?. ?=([%glob @ @ %ames *] href.docket) - `state - =* want=@uv hash.glob-reference.href.docket - =/ plea=@uv (slav %uv i.t.wire) - ?. =(want plea) - :: we requested this at some point but no longer want it - :: - `state - =/ have=@uv (hash-glob glob) - ?. =(want have) - %. `state - %- slog - :~ leaf+"docket: glob hash mismatch on {} from {}" - leaf+"expected: {}" - leaf+"received: {}" - == - =. charges (new-chad:cha glob+glob) - =. by-base (~(put by by-base) base.href.docket desk) - [~[add-fact:cha] state] - == - :: - [%glob @ %http @ ~] + ?([%glob @ %http @ ~] [%glob @ %ames @ ~]) ?- -.sign %kick `state :: ?(%poke-ack %watch-ack) ?~ p.sign `state =/ act=tape ?:(?=(%poke-ack -.sign) "start" "listen") - =. charges (new-chad:cha hung+'glob-failed') - :- ~[add-fact:cha] + =. charges + %- new-chad:cha + ?: ?=(i.t.t.wire %http) + hung+'failed to fetch glob via http' + hung+'failed to fetch glob via ames' ((slog leaf+"docket: couldn't {act} thread; will retry" u.p.sign) state) :: %fact @@ -671,12 +635,7 @@ ?: =(our.bowl ship.location.ref) ~> %slog.0^leaf/"docket: awaiting manual glob for {} desk" ~ - ~> %slog.0^leaf/"docket: fetching ames glob for {} desk" - :_ ~ - %+ watch:(pass (glob-wire ref)) - [ship.location.ref %docket] - /glob/[base.href.docket.charge]/(scot %uv hash.ref) - ~> %slog.0^leaf/"docket: fetching http glob for {} desk" + ~> %slog.0^leaf/"docket: fetching {<-.location.ref>} glob for {} desk" =/ =cage spider-start+!>([~ `tid byk.bowl(r da+now.bowl) %glob !>(`[ref desk])]) :~ (watch-our:(pass (glob-wire ref)) %spider /thread-result/[tid]) (poke-our:(pass (glob-wire ref)) %spider cage) diff --git a/pkg/garden/mar/glob.hoon b/pkg/garden/mar/glob.hoon deleted file mode 120000 index 15b77e5a37..0000000000 --- a/pkg/garden/mar/glob.hoon +++ /dev/null @@ -1 +0,0 @@ -../../base-dev/mar/glob.hoon \ No newline at end of file diff --git a/pkg/garden/mar/glob.hoon b/pkg/garden/mar/glob.hoon new file mode 100644 index 0000000000..5c23a80cfd --- /dev/null +++ b/pkg/garden/mar/glob.hoon @@ -0,0 +1,11 @@ +|_ gob=(map path mime) +++ grow + |% + ++ noun gob + -- +++ grab + |% + ++ noun (map path mime) + -- +++ grad ~&(%grid-mar %noun) +-- diff --git a/pkg/garden/ted/glob.hoon b/pkg/garden/ted/glob.hoon index 15d9301c81..7774704a58 100644 --- a/pkg/garden/ted/glob.hoon +++ b/pkg/garden/ted/glob.hoon @@ -9,7 +9,7 @@ |^ ?- -.location.ref %http (fetch-http [url.location hash]:ref) - %ames !! ::NOTE done within docket itself + %ames (fetch-ames [ship.location hash]:ref base) == :: ++ fetch-http @@ -22,7 +22,16 @@ %- pure:n %- mole |. - =- ?>(=(hash (sham -)) -) ;;(=glob:docket (cue cord)) (pure:m !>(glob)) +:: +:: download from ship's docket state +++ fetch-ames + |= [[=ship hash=@uvH] base=term] + ^- form:m + ;< =bowl:spider bind:m get-bowl:strandio + ;< =cage bind:m + (watch-one:strandio /glob/(scot %da now.bowl) [ship %docket] /glob/[base]/(scot %uv hash)) + ?> ?=(%glob p.cage) + (pure:m q.cage) --