khan: cleanup

This commit is contained in:
Jōshin 2022-01-25 21:28:45 -08:00
parent 12b4c80cf1
commit 8ad57d8bd2
No known key found for this signature in database
GPG Key ID: A8BE5A9A521639D0
2 changed files with 36 additions and 22 deletions

View File

@ -2098,13 +2098,13 @@
++ khan ^? ++ khan ^?
|% |%
+$ gift :: out result <-$ +$ gift :: out result <-$
$% [%avow p=(each cage [term tang])] :: thread result $% [%avow p=(each [mark noun] [term tang])] :: thread 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
[%fyrd =beak name=term data=*] :: run thread v0 [%fyrd =desk name=term data=*] :: run thread v0
$>(%trim vane-task) :: trim state $>(%trim vane-task) :: trim state
$>(%vega vane-task) :: report upgrade $>(%vega vane-task) :: report upgrade
== ==

View File

@ -49,27 +49,33 @@
^- [(list move) _khan-gate] ^- [(list move) _khan-gate]
:: ::
=/ =task:khan ((harden task:khan) wrapped-task) =/ =task:khan ((harden task:khan) wrapped-task)
?- -.task ?+ -.task [~ khan-gate]
%vega
[~ khan-gate]
%trim
[~ khan-gate]
%done
[~ khan-gate]
%born %born
[~ khan-gate(unix-duct hen)] [~ khan-gate(unix-duct hen)]
%fyrd %fyrd
=/ rid=@ta (rear (head hen)) :: start the thread on %spider.
::
=/ wir=wire (head hen)
=/ rid=@ta (rear wir)
:: XX what if the client sends a duplicate rid?
:: is this fine? should we inject some randomness?
::
=/ tid=@ta =/ tid=@ta
(cat 3 'khan-fyrd--' rid) (cat 3 'khan-fyrd--' rid)
=/ args =/ args
:* ~ `tid [our q.beak.task %da now] name.task :* ~ `tid [our desk.task %da now] name.task
!>([~ ~zod]) :: XX can't do this:
::
:: !>(data.task)
::
:: special case for -hi:
::
!>(;;([~ arg=$@(who=ship [who=ship mez=tape])] data.task))
== ==
=/ start-moves=(list move) =/ start-moves=(list move)
%+ turn %+ turn
:~ (watch-spider p.beak.task /thread-result/[tid]) :~ (watch-spider our /thread-result/[tid])
(start-spider p.beak.task %spider-start !>(args)) (start-spider our %spider-start !>(args))
== ==
|=(=note ^-(move [hen %pass //g note])) |=(=note ^-(move [hen %pass //g note]))
[start-moves khan-gate] [start-moves khan-gate]
@ -80,7 +86,7 @@
|= old=khan-state |= old=khan-state
^+ khan-gate ^+ khan-gate
khan-gate(state old) khan-gate(state old)
:: +scry: view khan state :: +scry: nothing to see as yet
:: ::
++ scry ++ scry
^- roon ^- roon
@ -88,6 +94,8 @@
^- (unit (unit cage)) ^- (unit (unit cage))
~ ~
++ stay state ++ stay state
:: +take: handle responses.
::
++ take ++ take
|= [tea=wire hen=duct dud=(unit goof) hin=sign] |= [tea=wire hen=duct dud=(unit goof) hin=sign]
^- [(list move) _khan-gate] ^- [(list move) _khan-gate]
@ -100,24 +108,30 @@
?(%poke-ack %watch-ack) ?(%poke-ack %watch-ack)
?~ p.p.hin [~ khan-gate] ?~ p.p.hin [~ khan-gate]
%- (slog u.p.p.hin) %- (slog u.p.p.hin)
[~ khan-gate] :_ khan-gate
[hen %give %avow %| -.p.hin u.p.p.hin]~
:: ::
%fact %fact
=* cag cage.p.hin =* cag cage.p.hin
?+ p.cag !! ?+ p.cag ~&(bad-fact+p.cag !!)
%thread-fail %thread-fail
%- (slog !<(tang q.cag)) =/ =tang !<(tang q.cag)
[~ khan-gate] %- (slog tang)
:_ khan-gate
[hen %give %avow %| p.cag tang]~
:: ::
%thread-done %thread-done
:_ khan-gate :_ khan-gate
=/ mov=move :: XX mark conversion
[hen %give %avow %& %tape !>(~)] ::
~[mov] =/ res=* !<(* q.cag)
[hen %give %avow %& %noun res]~
== ==
== ==
:: ::
%khan %khan
:: XX unreachable?
::
!! !!
== ==
-- --