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

View File

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

View File

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