khan: %fard/%arow use $cage, not $vase

Threads should eventually take and produce $cage instead of $vase. Since
%khan is likely to be used by third parties, we write to the eventual
intended API. We ignore the mark on the input $cage (it is safe to
always specify %noun), and we always use %noun as the output mark.

%fyrd now makes more sense. It was previously discarding the type of the
output %arow and re-encoding the raw noun as a vase of the output mark;
it is now performing mark conversion from the mark of the output $cage
to the originally requested output mark.
This commit is contained in:
Jōshin 2022-03-02 13:07:52 -06:00
parent f5fb214939
commit 340f4d5b6c
No known key found for this signature in database
GPG Key ID: A8BE5A9A521639D0
3 changed files with 38 additions and 17 deletions

View File

@ -2098,14 +2098,16 @@
++ khan ^?
|%
+$ gift :: out result <-$
$% [%arow p=(avow vase)] :: in-arvo result
$% [%arow p=(avow cage)] :: in-arvo result
[%avow p=(avow crag)] :: external result
== ::
+$ task :: in request ->$
$~ [%vega ~] ::
$% $>(%born vane-task) :: new unix process
[%done ~] :: socket closed
[%fard p=(fyrd vase)] :: in-arvo thread
:: 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
@ -2113,7 +2115,7 @@
:: ::
++ avow |$ [a] (each a goof) :: $fyrd result
+$ bear $@(desk beak) :: partial $beak
+$ cast (pair mark crag) :: mark-converted input
+$ cast (pair mark crag) :: output mark + input
++ fyrd |$ [a] [=bear name=term args=a] :: thread run request
-- ::khan
::

View File

@ -62,11 +62,20 @@
|= [=beak =mark rof=roof]
^- dais:clay
?~ ret=(rof ~ %cb beak /[mark])
~|(%mark-unknown !!)
~|(mark-unknown+mark !!)
?~ u.ret
~|(%mark-invalid !!)
~|(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
@ -134,7 +143,7 @@
(cat 3 'khan-fyrd--' (scot %uv (sham eny)))
=* fyd p.task
=/ =beak (get-beak bear.fyd now)
=/ args [~ `tid beak name.fyd args.fyd]
=/ args [~ `tid beak name.fyd q.args.fyd]
:_ khan-gate
%+ turn
:~ (watch-spider our /thread-result/[tid])
@ -150,8 +159,8 @@
(get-dais beak p.q.args.fyd rof)
=/ =vase
(slap (vale.dais q.q.args.fyd) !,(*hoon [~ u=.]))
:_ khan-gate
[hen %pass wire %k %fard bear.fyd name.fyd vase]~
=- [[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
::
@ -192,7 +201,7 @@
[hen %give %arow %| p.cag tang]~
::
%thread-done
[hen %give %arow %& q.cag]~
[hen %give %arow %& %noun q.cag]~
==
==
::
@ -205,8 +214,10 @@
[hen %give %avow row]~
=/ [=beak =mark]
(read-wire tea)
=/ =dais:clay (get-dais beak mark rof)
=/ =vase (vale:dais q.p.row)
=/ =tube:clay
(get-tube beak p.p.row mark rof)
=/ =vase
(tube q.p.row)
[hen %give %avow %& mark q.vase]~
==
--

View File

@ -46,7 +46,8 @@
results-3 results-4
(expect-eq !>(%base) !>(bear.fad))
(expect-eq !>(%nonexistent) !>(name.fad))
(expect-eq !>(`~) args.fad)
(expect-eq !>(%noun) !>(p.args.fad))
(expect-eq !>(`~) q.args.fad)
==
++ test-khan-fard-start-args
=^ born-moves khan-gate
@ -56,7 +57,7 @@
scry=scry-provides-mark
call-args=[duct=~[/initial-born-duct] ~ [%born ~]]
==
=/ fard=(fyrd:khan vase) [%base %nonexistent !>(~)]
=/ fard=(fyrd:khan cage) [%base %nonexistent %noun !>(~)]
=/ now=@da (add ~1111.1.1 ~s1)
=^ start-moves khan-gate
%- khan-call :*
@ -117,7 +118,7 @@
call-args=[duct=~[/a] ~ [%born ~]]
==
=/ results-0 (expect-eq !>(~) !>(born-moves))
=/ fard=(fyrd:khan vase) [%base %fake !>(~)]
=/ fard=(fyrd:khan cage) [%base %fake %noun !>(~)]
=^ start-moves khan-gate
%- khan-call :*
khan-gate
@ -140,7 +141,7 @@
%- expect !>(=(1 (lent take-moves)))
=/ results-2
%+ expect-eq
!>([~[//khan/2/0v0] %give %arow %& !>(%res)])
!>([~[//khan/2/0v0] %give %arow %& %noun !>(%res)])
!>((head take-moves))
:(weld results-0 results-1 results-2)
++ test-khan-take-full-run-fyrd
@ -177,7 +178,7 @@
wire=wir
duct=~[//khan/0v0/1/0v2]
dud=~
[%khan %arow %& !>(%res)]
[%khan %arow %& %noun !>(%res)]
==
=/ results-1 (expect !>(=(1 (lent arow-moves))))
=/ row (head arow-moves)
@ -325,7 +326,7 @@
scry-provides-mark
/fyrd/~nul/base/da/~1111.1.1..00.00.01/bad-mark
~[//khan/0v0/1/0v0] ~
[%khan %arow %& !>(~)]
[%khan %arow %& %noun !>(~)]
==
++ khan-call
|= $: khan-gate=_khan-gate
@ -403,6 +404,9 @@
++ pact !!
++ vale |=(=noun !>(;;(^noun noun)))
--
++ tube-noun-noun ^- tube:clay
|= =vase
!>(!<(noun vase))
++ scry-provides-mark ^- roof
|= [gang =view =beam]
^- (unit (unit cage))
@ -410,5 +414,9 @@
:^ ~ ~ %dais
!> ^- dais:clay
dais-noun
?: &(=(%cc view) =(/noun/noun s.beam))
:^ ~ ~ %tube
!> ^- tube:clay
tube-noun-noun
~
--