Merge pull request #5571 from urbit/jo/khan

khan: thread runner vane
This commit is contained in:
Jōshin 2022-03-02 19:00:58 -08:00 committed by GitHub
commit fdd29804d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 745 additions and 17 deletions

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:ae4a7a69fe81c5f2114d7b7360c05602f614fe66b96d1db4c3dc0c2a2a5d856e oid sha256:c4247c64a7d9fc0c0f1d2f017c21dd3464ddfe56529c7d6eef0e64554bd453e8
size 7536000 size 7611162

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:f59ec4eaf907227a1fd64e1d54810b769b5d39f6811c6bb254b2e89de528ca04 oid sha256:dc76fbf64ab20512842c5c87e5302cd8a70141fe4b5a1e4ba086221f36e406a0
size 1209494 size 1894727

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:e660fba934c5b80eeda64037a1f28c71eff4b2ea0bd28809b91432ca3d5ef08a oid sha256:204056f6c140a8d5329f78e149a318bc85190d2aaab73204249d39a12d0353e0
size 23052691 size 9296839

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:c27cdb47bccda98ba68556181cae6cd845c6daf8d7426d82adf67c1e8f532be9 oid sha256:187ea751a274dba7ed69df3a5b8f6f7ac620e3f9787abd75b18cf494d0c41f05
size 7454265 size 11174099

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:bcab0698de6efda1bbac54b0833da5e853bca058919110aa5668aa63fb40626e oid sha256:b187510f9f6ab95c9dd53889121e92db349633c113049e9ef5bdb0b879390e89
size 9392699 size 9489162

View File

@ -648,7 +648,6 @@
:: ::
++ yarn-to-byk ++ yarn-to-byk
|= [=yarn =bowl:gall] |= [=yarn =bowl:gall]
=/ [* * =desk] =/ [* * =desk]
~| "no desk associated with {<tid>}" ~| "no desk associated with {<tid>}"
%- ~(got by serving.state) (yarn-to-tid yarn) %- ~(got by serving.state) (yarn-to-tid yarn)
@ -666,5 +665,4 @@
%cc %cc
/(scot %p our.bowl)/[desk]/(scot %da now.bowl)/[from]/[to] /(scot %p our.bowl)/[desk]/(scot %da now.bowl)/[from]/[to]
== ==
-- --

View File

@ -18,6 +18,7 @@
:: $gang: infinite set of peers :: $gang: infinite set of peers
:: $mark: symbolic content type :: $mark: symbolic content type
:: $mien: orientation :: $mien: orientation
:: $page: untyped cage
:: +omen: namespace path and data :: +omen: namespace path and data
:: $ship: network identity :: $ship: network identity
:: $sink: subscription :: $sink: subscription
@ -49,6 +50,7 @@
+$ gang (unit (set ship)) +$ gang (unit (set ship))
+$ mark @tas +$ mark @tas
+$ mien [our=ship now=@da eny=@uvJ] +$ mien [our=ship now=@da eny=@uvJ]
+$ page (cask)
++ omen |$ [a] (pair path (cask a)) ++ omen |$ [a] (pair path (cask a))
+$ ship @p +$ ship @p
+$ sink (trel bone ship path) +$ sink (trel bone ship path)
@ -86,7 +88,7 @@
:: +wite: kernel action/error builder :: +wite: kernel action/error builder
:: ::
+$ ball (wite [vane=term task=maze] maze) +$ ball (wite [vane=term task=maze] maze)
+$ card (cask) +$ card (pair @tas *)
+$ duct (list wire) +$ duct (list wire)
++ hobo ++ hobo
|$ [a] |$ [a]
@ -1678,6 +1680,7 @@
%g %gall %g %gall
%i %iris %i %iris
%j %jael %j %jael
%k %khan
== ==
-- => -- =>
:: ::

View File

@ -857,7 +857,6 @@
[%| p=@tas] :: label [%| p=@tas] :: label
== :: == ::
+$ open $-(path vase) :: get prelude +$ open $-(path vase) :: get prelude
+$ page (cask *) :: untyped cage
+$ plop blob :: unvalidated blob +$ plop blob :: unvalidated blob
+$ rang :: repository +$ rang :: repository
$: hut=(map tako yaki) :: changes $: hut=(map tako yaki) :: changes
@ -2092,6 +2091,32 @@
+$ oath @ :: signature +$ oath @ :: signature
-- :: pki -- :: pki
-- :: jael -- :: jael
:: ::::
:::: ++khan :: (1i) threads
:: ::::
++ khan ^?
|%
+$ gift :: out result <-$
$% [%arow p=(avow cage)] :: in-arvo result
[%avow p=(avow page)] :: external result
== ::
+$ task :: in request ->$
$~ [%vega ~] ::
$% $>(%born vane-task) :: new unix process
[%done ~] :: socket closed
:: XX mark ignored
::
[%fard p=(fyrd cage)] :: in-arvo thread
[%fyrd p=(fyrd cast)] :: external thread
$>(%trim vane-task) :: trim state
$>(%vega vane-task) :: report upgrade
== ::
:: ::
++ avow |$ [a] (each a goof) :: $fyrd result
+$ bear $@(desk beak) :: partial $beak
+$ cast (pair mark page) :: output mark + input
++ fyrd |$ [a] [=bear name=term args=a] :: thread run request
-- ::khan
:: ::
+$ gift-arvo :: out result <-$ +$ gift-arvo :: out result <-$
$~ [%doze ~] $~ [%doze ~]
@ -2103,6 +2128,7 @@
gift:gall gift:gall
gift:iris gift:iris
gift:jael gift:jael
gift:khan
== ==
+$ task-arvo :: in request ->$ +$ task-arvo :: in request ->$
$% task:ames $% task:ames
@ -2113,6 +2139,7 @@
task:gall task:gall
task:iris task:iris
task:jael task:jael
task:khan
== ==
+$ note-arvo :: out request $-> +$ note-arvo :: out request $->
$~ [%b %wake ~] $~ [%b %wake ~]
@ -2124,6 +2151,7 @@
[%g task:gall] [%g task:gall]
[%i task:iris] [%i task:iris]
[%j task:jael] [%j task:jael]
[%k task:khan]
[%$ %whiz ~] [%$ %whiz ~]
[@tas %meta vase] [@tas %meta vase]
== ==
@ -2145,6 +2173,7 @@
[%gall gift:gall] [%gall gift:gall]
[%iris gift:iris] [%iris gift:iris]
[%jael gift:jael] [%jael gift:jael]
[%khan gift:khan]
== ==
:: $unix-task: input from unix :: $unix-task: input from unix
:: ::

222
pkg/arvo/sys/vane/khan.hoon Normal file
View File

@ -0,0 +1,222 @@
:: %khan, thread runner
::
:: this vane presents a command/response interface for running
:: threads. two modes are supported: %fard for intra-arvo
:: requests (i.e. within the same kernel space) and %fyrd for
:: external requests (e.g. from the unix control plane.)
::
:: both modes take a thread start request consisting of a
:: namespace, thread name, and input data; they respond over the
:: same duct with either success or failure. %fard takes its
:: input arguments as a cage and produces %arow, which contains
:: a cage on success (or tang on failure). %fyrd takes an output
:: mark and input page; it produces %avow, which contains a page
:: on success.
::
:: threads currently expect input and produce output as vase,
:: not cage. %fard/%arow use cage instead since this is the
:: eventual desired thread API; however, the input mark is
:: currently ignored, and the output mark is always %noun. (for
:: forward compatibility, it is safe to specify %noun as the
:: input mark.)
::
:: %fyrd does mark conversion on both ends, and additionally
:: lifts its input into a $unit. this second step is done
:: because threads conventionally take their input as a unit,
:: with ~ for the case of "no arguments".
::
:: n.b. the current convention for threads is to use !< to
:: unpack their input vase. !< imposes the requirement that the
:: input type nests within the specified type. this limits %fyrd
:: to threads with inputs for which a named mark exists; it is
:: impossible to use %noun in general since it does not nest.
:: threads written against the current vase-based API could use
:: ;; instead of !< to unpack their input, thus allowing the
:: use of %fyrd with %noun. however the eventual solution is
:: probably to make threads consume and produce cages, and do
:: mark conversion where appropriate.
!:
!? 164
::
=, khan
|= our=ship
=> |% :: %khan types
+$ move [p=duct q=(wite note gift)] ::
+$ note :: out request $->
$~ [%g %deal *sock *term *deal:gall] ::
$% $: %g :: to %gall
$>(%deal task:gall) :: full transmission
== ::
$: %k :: to self
$>(%fard task) :: internal thread
== == ::
+$ sign :: in response $<-
$% $: %gall :: from %gall
$>(%unto gift:gall) :: update
== ::
$: %khan :: from self
$>(?(%arow %avow) gift) :: thread result
== == ::
+$ khan-state ::
$: %0 :: state v0
hey=duct :: unix duct
tic=@ud :: tid counter
== ::
-- ::
=>
|%
++ get-beak
|= [=bear now=@da]
?@(bear [our bear %da now] bear)
::
++ get-dais
|= [=beak =mark rof=roof]
^- dais:clay
?~ ret=(rof ~ %cb beak /[mark])
~|(mark-unknown+mark !!)
?~ u.ret
~|(mark-invalid+mark !!)
?> =(%dais p.u.u.ret)
!<(dais:clay q.u.u.ret)
::
++ get-tube
|= [=beak =mark =out=mark rof=roof]
^- tube:clay
?~ ret=(rof ~ %cc beak /[mark]/[out-mark])
~|(tube-unknown+[mark out-mark] !!)
?~ u.ret
~|(tube-invalid+[mark out-mark] !!)
?> =(%tube p.u.u.ret)
!<(tube:clay q.u.u.ret)
::
++ make-wire
|= [=beak =mark]
^- wire
[%fyrd (en-beam beak mark ~)]
::
++ read-wire
|= =wire
^- (pair beak mark)
~| khan-read-wire+wire
?> ?=([%fyrd ^] wire)
=/ =beam (need (de-beam t.wire))
?>(?=([@ ~] s.beam) beam(s i.s.beam))
::
++ start-spider
|= =vase
^- note
[%g %deal [our our] %spider %poke %spider-start vase]
::
++ watch-spider
|= =path
^- note
[%g %deal [our our] %spider %watch path]
--
=| khan-state
=* state -
|= [now=@da eny=@uvJ rof=roof]
=* khan-gate .
^?
|%
:: +call: handle a +task request
::
++ call
|= $: hen=duct
dud=(unit goof)
wrapped-task=(hobo task)
==
^- [(list move) _khan-gate]
::
=/ =task ((harden task) wrapped-task)
?^ dud
~|(%khan-call-dud (mean tang.u.dud))
?+ -.task [~ khan-gate]
%born
[~ khan-gate(hey hen, tic 0)]
::
%fard
=/ tid=@ta
%^ cat 3
'khan-fyrd--'
(scot %uv (sham (mix tic eny)))
=. tic +(tic)
=* fyd p.task
=/ =beak (get-beak bear.fyd now)
=/ args [~ `tid beak name.fyd q.args.fyd]
:_ khan-gate
%+ turn
:~ (watch-spider /thread-result/[tid])
(start-spider !>(args))
==
|=(=note ^-(move [hen %pass //g note]))
::
%fyrd
=* fyd p.task
=/ =beak (get-beak bear.fyd now)
=/ =wire (make-wire beak p.args.fyd)
=/ =dais:clay
(get-dais beak p.q.args.fyd rof)
=/ =vase
(slap (vale.dais q.q.args.fyd) !,(*hoon [~ u=.]))
=- [[hen %pass wire -]~ khan-gate]
[%k %fard bear.fyd name.fyd p.q.args.fyd vase]
==
:: +load: migrate an old state to a new khan version
::
++ load
|= old=khan-state
^+ khan-gate
khan-gate(state old)
:: +scry: nothing to see as yet
::
++ scry
^- roon
|= [lyc=gang car=term bem=beam]
^- (unit (unit cage))
~
++ stay state
:: +take: handle responses.
::
++ take
|= [tea=wire hen=duct dud=(unit goof) hin=sign]
^- [(list move) _khan-gate]
?^ dud
~|(%khan-take-dud (mean tang.u.dud))
:_ khan-gate
?- -.hin
%gall
?+ -.p.hin ~
?(%poke-ack %watch-ack)
?~ p.p.hin ~
%- (slog 'khan-ack' u.p.p.hin)
[hen %give %arow %| -.p.hin u.p.p.hin]~
::
%fact
=* cag cage.p.hin
?+ p.cag ~&(bad-fact+p.cag !!)
%thread-fail
=/ =tang !<(tang q.cag)
%- (slog 'khan-fact' tang)
[hen %give %arow %| p.cag tang]~
::
%thread-done
[hen %give %arow %& %noun q.cag]~
==
==
::
%khan
?. ?=(%arow +<.hin) ~
?~ tea ~
?. ?=(%fyrd -.tea) ~
=* row p.hin
?. ?=(%& -.row)
[hen %give %avow row]~
=/ [=beak =mark]
(read-wire tea)
=/ =tube:clay
(get-tube beak p.p.row mark rof)
=/ =vase
(tube q.p.row)
[hen %give %avow %& mark q.vase]~
==
--

View File

@ -0,0 +1,476 @@
:: remaining cases to test:
:: call dud
:: take dud
:: TODO when can dud happen?
::
/+ *test
/= khan-raw /sys/vane/khan
=/ khan-gate (khan-raw ~nul)
|%
++ test-khan-fyrd-start-args
=^ born-moves khan-gate
%- khan-call :*
khan-gate
now=~1162.1.1
scry=scry-provides-mark
call-args=[duct=~[/initial-born-duct] ~ [%born ~]]
==
=/ results-0 (expect-eq !>(~) !>(born-moves))
=/ fyrd=(fyrd:khan cast:khan) [%base %nonexistent %noun %noun ~]
=/ now=@da (add ~1162.1.1 ~s1)
=^ start-moves khan-gate
%- khan-call :*
khan-gate
now
scry=scry-provides-mark
^= call-args
:* duct=~[//khan/1/0vsome.ductt] ~
%fyrd fyrd
== ==
=/ results-1 (expect !>(=(1 (lent start-moves))))
=/ mev (head start-moves)
=/ results-2
%+ expect-eq
!> ~[//khan/1/0vsome.ductt]
!> p.mev
?> ?=(%pass -.q.mev)
=/ results-3
%+ expect-eq
!> /fyrd/~nul/base/~1162.1.1..00.00.01/noun
!> wire.q.mev
=/ results-4 (expect-eq !>(%k) !>(-.note.q.mev))
?> ?=(%fard +<.note.q.mev)
=/ fad p.note.q.mev
;: weld
results-0 results-1 results-2
results-3 results-4
(expect-eq !>(%base) !>(bear.fad))
(expect-eq !>(%nonexistent) !>(name.fad))
(expect-eq !>(%noun) !>(p.args.fad))
(expect-eq !>(`~) q.args.fad)
==
++ test-khan-fard-start-args
=^ born-moves khan-gate
%- khan-call :*
khan-gate
now=~1162.1.1
scry=scry-provides-mark
call-args=[duct=~[/initial-born-duct] ~ [%born ~]]
==
=/ fard=(fyrd:khan cage) [%base %nonexistent %noun !>(~)]
=/ now=@da (add ~1162.1.1 ~s1)
=^ start-moves khan-gate
%- khan-call :*
khan-gate
now
scry=scry-provides-mark
^= call-args
:* duct=~[//khan/1/0vthat.ductt] ~
%fard fard
== ==
=/ results-0 (expect !>(=(2 (lent start-moves))))
:: XX overspecified
::
=/ expected-tid (cat 3 'khan-fyrd--' (scot %uv (sham 0xdead.beef)))
=/ results-1
%+ expect-eq
!> :* ~[//khan/1/0vthat.ductt]
%pass //g %g %deal
[~nul ~nul] %spider %watch
/thread-result/[expected-tid]
==
!> (head start-moves)
=/ mev (rear start-moves)
=/ results-2 (expect-eq !>(~[//khan/1/0vthat.ductt]) !>(p.mev))
?> ?=(%pass -.q.mev)
=/ results-3 (expect-eq !>(//g) !>(wire.q.mev))
=* not note.q.mev
=/ results-4 (expect-eq !>(%g) !>(-.not))
?> ?=(%deal +<.not)
=/ results-5 (expect-eq !>([~nul ~nul]) !>(p.not))
=/ results-6 (expect-eq !>(%spider) !>(q.not))
?> ?=(%poke -.r.not)
=* cag cage.r.not
?> ?=(%spider-start p.cag)
=/ rag
:: XX $start-args in %/app/spider/hoon
::
!< [p=(unit @ta) q=(unit @ta) r=beak s=term t=vase]
q.cag
=/ results-7
%+ expect-eq
!> :* ~ `expected-tid
[~nul %base %da now] %nonexistent ~
==
!>(rag(t ~))
=/ results-8 (expect-eq !>(~) t.rag)
;: weld
results-0 results-1 results-2
results-3 results-4 results-5
results-6 results-7 results-8
==
++ test-khan-take-full-run-fard
=^ born-moves khan-gate
%- khan-call :*
khan-gate
now=~1162.1.1
scry=scry-provides-mark
call-args=[duct=~[/a] ~ [%born ~]]
==
=/ results-0 (expect-eq !>(~) !>(born-moves))
=/ fard=(fyrd:khan cage) [%base %fake %noun !>(~)]
=^ start-moves khan-gate
%- khan-call :*
khan-gate
now=(add ~1162.1.1 ~s1)
scry=scry-provides-mark
^= call-args
:* duct=~[//khan/2/0v0] ~
%fard fard
== ==
=^ take-moves khan-gate
%- khan-take-all :*
khan-gate now=~1162.1.2 sep=~s1 scry=scry-provides-mark
:~ [//g ~[//khan/2/0v0] ~ %gall %unto %watch-ack ~]
[//g ~[//khan/2/0v0] ~ %gall %unto %poke-ack ~]
[//g ~[//khan/2/0v0] ~ %gall %unto %fact %thread-done !>(%res)]
[//g ~[//khan/2/0v0] ~ %gall %unto %kick ~]
==
==
=/ results-1
%- expect !>(=(1 (lent take-moves)))
=/ results-2
%+ expect-eq
!>([~[//khan/2/0v0] %give %arow %& %noun !>(%res)])
!>((head take-moves))
:(weld results-0 results-1 results-2)
++ test-khan-multi-fard
=^ born-moves khan-gate
%- khan-call :*
khan-gate
now=~1162.1.1
scry=scry-provides-mark
call-args=[duct=~[/a] ~ [%born ~]]
==
=/ fard=(fyrd:khan cage) [%base %fake %noun !>(~)]
=/ khan-call-args :*
now=(add ~1162.1.1 ~s1)
scry=scry-provides-mark
^= call-args :*
duct=~[//khan/2/0va] ~ %fard fard
==
==
=^ start-1-moves khan-gate
%- khan-call :*
khan-gate
khan-call-args
==
=^ start-2-moves khan-gate
%- khan-call :*
khan-gate
khan-call-args
==
=/ results-1
%+ expect-spider-start-tid
'khan-fyrd--0vir6kv.ci3nm.a8rcs.kua3e.9sp7o'
start-1-moves
=/ results-2
%+ expect-spider-start-tid
'khan-fyrd--0v4.la9d1.uc5cu.ngv3f.pbo8a.mlc5f'
start-2-moves
(weld results-1 results-2)
++ test-khan-take-full-run-fyrd
=^ born-moves khan-gate
%- khan-call :*
khan-gate
now=~1162.1.1
scry=scry-provides-mark
call-args=[duct=~[/a] ~ [%born ~]]
==
=^ fyrd-moves khan-gate
%- khan-call :*
khan-gate
now=(add ~1162.1.1 ~s1)
scry=scry-provides-mark
^= call-args
duct=~[//khan/0v0/1/0v2] ~
%fyrd [%base %fake %noun %noun ~]
==
=/ results-0 (expect !>(=(1 (lent fyrd-moves))))
=/ fard-move (head fyrd-moves)
?> ?=(%pass -.q.fard-move)
?> ?=(%k -.note.q.fard-move)
=* wir wire.q.fard-move
:: XX may erroneously break if %khan keeps state dependent on
:: its inner %fard.
::
=^ arow-moves khan-gate
%- khan-take :*
khan-gate
now=(add ~1162.1.1 ~s3)
scry=scry-provides-mark
^= take-args
wire=wir
duct=~[//khan/0v0/1/0v2]
dud=~
[%khan %arow %& %noun !>(%res)]
==
=/ results-1 (expect !>(=(1 (lent arow-moves))))
=/ row (head arow-moves)
=/ results-2
%+ expect-eq
!>(~[//khan/0v0/1/0v2])
!>(p.row)
=/ results-3
%+ expect-eq
!>([%give %avow %& %noun %res])
!>(q.row)
:(weld results-0 results-1 results-2 results-3)
++ test-khan-fard-watch-ack-fail
=^ born-moves khan-gate
%- khan-call-all :*
khan-gate now=~1162.1.1 sep=~s1 scry=scry-provides-mark
:~ [~[/a] ~ %born ~]
[~[//khan/0v0/1/0v0] ~ %fard %base %hi %noun %noun ~]
==
==
=^ watch-ack-moves khan-gate
%- khan-take :*
khan-gate now=~1162.1.2 scry=scry-provides-mark
^= take-args
//g ~[//khan/0v0/1/0v0] ~
%gall %unto %watch-ack `~['fail']
==
=/ results-0 (expect !>(=(1 (lent watch-ack-moves))))
=/ mev (head watch-ack-moves)
=/ results-1
%+ expect-eq
!>([~[//khan/0v0/1/0v0] %give %arow %| %watch-ack ~['fail']])
!>(mev)
(weld results-0 results-1)
++ test-khan-fard-poke-ack-fail
=^ call-moves khan-gate
%- khan-call-all :*
khan-gate now=~1162.1.1 sep=~s1 scry=scry-provides-mark
:~ [~[/a] ~ %born ~]
[~[//khan/0v0/1/0v0] ~ %fard %base %hi %noun %noun ~]
==
==
=^ take-moves khan-gate
%- khan-take-all :*
khan-gate now=~1162.1.2 sep=~s1 scry=scry-provides-mark
:~ [//g ~[//khan/0v0/1/0v0] ~ %gall %unto %watch-ack ~]
:* //g ~[//khan/0v0/1/0v0] ~
%gall %unto %poke-ack `~['fail']
==
[//g ~[//khan/0v0/1/0v0] ~ %gall %unto %kick ~]
==
==
=/ results-0 (expect !>(=(1 (lent take-moves))))
=/ mev (head take-moves)
=/ results-1
%+ expect-eq
!>([~[//khan/0v0/1/0v0] %give %arow %| %poke-ack ~['fail']])
!>(mev)
(weld results-0 results-1)
++ test-khan-fard-thread-fail
=^ call-moves khan-gate
%- khan-call-all :*
khan-gate now=~1162.1.1 sep=~s1 scry=scry-provides-mark
:~ [~[/a] ~ %born ~]
[~[//khan/0v0/1/0v0] ~ %fard %base %hi %noun %noun ~]
==
==
=^ take-moves khan-gate
%- khan-take-all :*
khan-gate now=~1162.1.2 sep=~s1 scry=scry-provides-mark
:~ [//g ~[//khan/0v0/1/0v0] ~ %gall %unto %watch-ack ~]
[//g ~[//khan/0v0/1/0v0] ~ %gall %unto %poke-ack ~]
:* //g ~[//khan/0v0/1/0v0] ~
%gall %unto %fact %thread-fail
!>([%woops ~['fail']])
==
[//g ~[//khan/0v0/1/0v0] ~ %gall %unto %kick ~]
==
==
=/ results-0 (expect !>(=(1 (lent take-moves))))
=/ mev (head take-moves)
=/ results-1
%+ expect-eq
!> :* ~[//khan/0v0/1/0v0] %give
%arow %| %thread-fail ~['woops' 'fail']
==
!>(mev)
(weld results-0 results-1)
++ test-khan-fyrd-arow-fail
=^ call-moves khan-gate
%- khan-call-all :*
khan-gate now=~1162.1.1 sep=~s1 scry=scry-provides-mark
:~ [~[/a] ~ %born ~]
[~[//khan/0v0/1/0v0] ~ %fyrd %base %a %noun %noun ~]
==
==
=/ results-0 (expect !>(=(1 (lent call-moves))))
=/ fard-move (head call-moves)
?> ?=(%pass -.q.fard-move)
=* wir wire.q.fard-move
=^ arow-moves khan-gate
%- khan-take :*
khan-gate now=~1162.1.2 scry=scry-provides-mark
^= take-args
wir ~[//khan/0v0/1/0v0] ~
%khan %arow %| %watch-ack ~['fail']
==
=/ results-1 (expect !>(=(1 (lent arow-moves))))
=/ mev (head arow-moves)
=/ results-2
%+ expect-eq
!>([~[//khan/0v0/1/0v0] %give %avow %| %watch-ack ~['fail']])
!>(mev)
:(weld results-0 results-1 results-2)
++ test-khan-fyrd-no-input-mark
=^ born-moves khan-gate
%- khan-call :*
khan-gate
~1162.1.1
scry-provides-mark
~[/a] ~ %born ~
==
%- expect-fail
|.
%- khan-call :*
khan-gate
(add ~1162.1.1 ~s1)
scry-provides-mark
~[//khan/0v0/1/0v0] ~
%fyrd %base %a %noun %bad-mark ~
==
++ test-khan-fyrd-no-output-mark
=^ call-moves khan-gate
%- khan-call-all :*
khan-gate ~1162.1.1 ~s1 scry-provides-mark
:~ [~[/a] ~ %born ~]
[~[//khan/0v0/1/0v0] ~ %fyrd %base %a %bad-mark %noun ~]
==
==
%- expect-fail
|.
%- khan-take :*
khan-gate
~1162.1.2
scry-provides-mark
/fyrd/~nul/base/da/~1162.1.1..00.00.01/bad-mark
~[//khan/0v0/1/0v0] ~
[%khan %arow %& %noun !>(~)]
==
++ expect-spider-start-tid
|= [tid=@ta mev=(list move:khan-gate)]
?> ?=([^ ^ ~] mev)
=* watch-move i.mev
=* start-move i.t.mev
?> ?=([* %pass * %g %deal * %spider %watch *] watch-move)
=/ results-1
%+ expect-eq
!>(/thread-result/[tid])
!>(path.r.note.q.watch-move)
?> ?=([* %pass * %g %deal * %spider %poke %spider-start *] start-move)
=/ start-args
!< [p=(unit @ta) q=(unit @ta) r=beak s=term t=vase]
q.cage.r.note.q.start-move
=/ results-2
%+ expect-eq
!> `tid
!> q.start-args
(weld results-1 results-2)
++ khan-call
|= $: khan-gate=_khan-gate
now=@da
scry=roof
$= call-args
$: =duct
dud=(unit goof)
wrapped-task=(hobo task:khan)
== ==
^- [(list move:khan-gate) _khan-gate]
=/ khan-core
(khan-gate now eny=`@uvJ`0xdead.beef scry=scry)
(call:khan-core [duct dud wrapped-task]:call-args)
++ khan-call-all
|= $: khan-gate=_khan-gate
now=@da
sep=@dr
scry=roof
call-list=(list [p=duct q=(unit goof) r=(hobo task:khan)])
==
^- [(list move:khan-gate) _khan-gate]
=+ i=0
=/ mev=(list move:khan-gate) ~
|-
?~ call-list [mev khan-gate]
=^ mov khan-gate
%- khan-call :*
khan-gate
now=(add now (mul sep i))
scry=scry
call-args=i.call-list
==
$(i +(i), call-list t.call-list, mev (weld mev mov))
++ khan-take
|= $: khan-gate=_khan-gate
now=@da
scry=roof
$= take-args
$: =wire
=duct
dud=(unit goof)
=sign:khan-gate
== ==
^- [(list move:khan-gate) _khan-gate]
=/ khan-core
(khan-gate now eny=`@uvJ`0xdead.beef scry=scry)
(take:khan-core [wire duct dud sign]:take-args)
++ khan-take-all
|= $: khan-gate=_khan-gate
now=@da
sep=@dr
scry=roof
take-list=(list [p=wire q=duct r=(unit goof) s=sign:khan-gate])
==
^- [(list move:khan-gate) _khan-gate]
=+ i=0
=/ mev=(list move:khan-gate) ~
|-
?~ take-list [mev khan-gate]
=^ mov khan-gate
%- khan-take :*
khan-gate
now=(add now (mul sep i))
scry=scry
take-args=i.take-list
==
$(i +(i), take-list t.take-list, mev (weld mev mov))
++ dais-noun ^- dais:clay
|_ sam=vase
++ diff !!
++ form !!
++ join !!
++ mash !!
++ pact !!
++ vale |=(=noun !>(;;(^noun noun)))
--
++ tube-noun-noun ^- tube:clay
|= =vase
!>(!<(noun vase))
++ scry-provides-mark ^- roof
|= [gang =view =beam]
^- (unit (unit cage))
?: &(=(%cb view) =(/noun s.beam))
:^ ~ ~ %dais
!> ^- dais:clay
dais-noun
?: &(=(%cc view) =(/noun/noun s.beam))
:^ ~ ~ %tube
!> ^- tube:clay
tube-noun-noun
~
--

View File

@ -61,10 +61,10 @@
=; hav ~& user-files+(lent hav) =; hav ~& user-files+(lent hav)
=/ =yuki:clay =/ =yuki:clay
:- *(list tako:clay) :- *(list tako:clay)
%- ~(gas by *(map path (each page:clay lobe:clay))) %- ~(gas by *(map path (each page lobe:clay)))
(turn hav |=([=path =page:clay] [path &+page])) (turn hav |=([=path =page] [path &+page]))
[/c/sync [%park des &+yuki *rang:clay]] [/c/sync [%park des &+yuki *rang:clay]]
=| hav=(list [path page:clay]) =| hav=(list [path page])
|- ^+ hav |- ^+ hav
?~ sal ~ ?~ sal ~
=. hav $(sal t.sal) =. hav $(sal t.sal)