shrub/pkg/arvo/sys/vane/gall.hoon

2639 lines
71 KiB
Plaintext
Raw Normal View History

!: :: %gall, agent execution
2016-11-24 07:25:07 +03:00
!? 163
!:
2016-11-24 07:25:07 +03:00
::::
|= pit=vase
=, gall
2015-05-10 01:55:05 +03:00
=> =~
2019-05-05 03:23:22 +03:00
|%
:: +coke: cook
2019-05-05 03:23:22 +03:00
::
++ coke
$? %inn
%out
%cay
==
:: +reverse-ames: reverse ames message
2019-05-05 03:23:22 +03:00
::
++ reverse-ames
2019-08-14 14:57:51 +03:00
$% :: diff
2019-05-05 03:23:22 +03:00
::
2019-08-15 20:51:50 +03:00
[%d p=mark q=*]
:: etc.
::
2019-08-15 20:51:50 +03:00
[%x ~]
2019-05-05 03:23:22 +03:00
==
:: +forward-ames: forward ames message
2019-05-05 03:23:22 +03:00
::
++ forward-ames
2019-08-14 14:57:51 +03:00
$% :: message
2019-05-05 03:23:22 +03:00
::
2019-08-15 20:51:50 +03:00
[%m =mark noun=*]
2019-05-05 03:23:22 +03:00
:: "peel" subscribe
::
2019-08-15 20:51:50 +03:00
[%l =mark =path]
2019-05-05 03:23:22 +03:00
:: subscribe
::
2019-08-15 20:51:50 +03:00
[%s =path]
2019-05-05 03:23:22 +03:00
:: cancel+unsubscribe
::
2019-08-15 20:51:50 +03:00
[%u ~]
2019-05-05 03:23:22 +03:00
==
:: +foreign-response: foreign response
2019-05-05 03:23:22 +03:00
::
++ foreign-response
2019-05-05 03:23:22 +03:00
$? %peer
%peel
%poke
%pull
==
--
|%
:: +internal-note: +ap note
2019-05-05 03:23:22 +03:00
::
++ internal-note
2019-08-15 20:51:50 +03:00
$% [%meta =term =vase]
[%send =ship =internal-task]
2019-05-05 03:23:22 +03:00
==
:: +internal-move: agent-level move
2019-06-27 07:08:07 +03:00
::
:: Analogous to an Arvo move, except these are routed by bone, instead of
:: duct.
2019-05-05 03:23:22 +03:00
::
++ internal-move
2019-08-14 14:57:51 +03:00
$: =bone
move=(wind internal-note internal-gift)
==
:: +move: Arvo-level move
2019-05-05 03:23:22 +03:00
::
2019-08-15 23:12:53 +03:00
++ move
$: =duct
move=(wind note-arvo gift-arvo)
==
2019-05-05 03:23:22 +03:00
--
|%
:: +state: all state
2019-05-05 03:23:22 +03:00
::
++ state
2019-08-14 14:57:51 +03:00
$: :: state version
2019-05-05 03:23:22 +03:00
::
%1
:: agents by ship
2019-05-05 03:23:22 +03:00
::
=agents
2019-05-05 03:23:22 +03:00
==
:: +subscribers: subscriber data
2019-05-05 03:23:22 +03:00
::
2019-05-30 05:24:24 +03:00
++ subscribers
2019-08-14 14:57:51 +03:00
$: :: incoming subscribers
2019-05-05 03:23:22 +03:00
::
incoming=bitt
2019-05-05 03:23:22 +03:00
:: outgoing subscribers
::
outgoing=boat
2019-05-05 03:23:22 +03:00
:: queue meter
::
meter=(map bone @ud)
2019-05-05 03:23:22 +03:00
==
:: +agents: ship state
2019-05-05 03:23:22 +03:00
::
++ agents
$: :: system duct
2019-05-05 03:23:22 +03:00
::
system-duct=duct
2019-05-05 03:23:22 +03:00
:: foreign contacts
::
contacts=(map ship foreign)
2019-05-05 03:23:22 +03:00
:: running agents
::
running=(map term agent)
2019-05-05 03:23:22 +03:00
:: waiting queue
::
2019-06-26 00:25:03 +03:00
blocked=(map term blocked)
2019-05-05 03:23:22 +03:00
==
:: +routes: new cuff
2019-05-05 03:23:22 +03:00
::
++ routes
2019-08-14 14:57:51 +03:00
$: :: disclosing to
::
disclosing=(unit (set ship))
:: attributed to
::
attributing=ship
==
:: +foreign: foreign connections
2019-05-05 03:23:22 +03:00
::
++ foreign
2019-08-14 14:57:51 +03:00
$: :: index
2019-05-05 03:23:22 +03:00
::
index=@ud
2019-05-05 03:23:22 +03:00
:: by duct
::
index-map=(map duct @ud)
2019-05-05 03:23:22 +03:00
:: by index
::
duct-map=(map @ud duct)
2019-05-05 03:23:22 +03:00
==
:: +ducts: opaque input
2019-05-05 03:23:22 +03:00
::
2019-05-29 10:46:55 +03:00
++ ducts
2019-08-14 14:57:51 +03:00
$: :: bone sequence
2019-05-05 03:23:22 +03:00
::
bone=@ud
2019-05-05 03:23:22 +03:00
:: by duct
::
bone-map=(map duct bone)
2019-05-05 03:23:22 +03:00
:: by bone
::
duct-map=(map bone duct)
2019-05-05 03:23:22 +03:00
==
:: +misvale-data: subscribers with bad marks
2019-05-05 03:23:22 +03:00
::
:: XX a hack, required to break a subscription loop
:: which arises when an invalid mark crashes a diff.
:: See usage in ap-misvale.
::
++ misvale-data (set wire)
:: +agent: agent state
2019-05-05 03:23:22 +03:00
::
++ agent
2019-08-14 14:57:51 +03:00
$: :: bad reqs
2019-05-05 03:23:22 +03:00
::
misvale=misvale-data
:: cache
::
cache=worm
2019-05-13 10:40:50 +03:00
:: ap-find-arm cache
2019-05-05 03:23:22 +03:00
::
2019-05-13 10:40:50 +03:00
arm-cache=(map [term path] (unit (pair @ud term)))
2019-05-05 03:23:22 +03:00
:: control duct
::
control-duct=duct
2019-05-05 03:23:22 +03:00
:: unstopped
::
live=?
2019-05-05 03:23:22 +03:00
:: statistics
::
2019-08-14 14:57:51 +03:00
=stats
2019-05-05 03:23:22 +03:00
:: subscribers
::
2019-08-14 14:57:51 +03:00
=subscribers
2019-05-05 03:23:22 +03:00
:: running state
::
running-state=vase
2019-05-05 03:23:22 +03:00
:: update control
::
2019-08-14 14:57:51 +03:00
=beak
2019-05-05 03:23:22 +03:00
:: req'd translations
::
2019-07-03 05:36:54 +03:00
marks=(map bone mark)
2019-05-05 03:23:22 +03:00
:: opaque ducts
::
2019-08-14 14:57:51 +03:00
=ducts
2019-05-05 03:23:22 +03:00
==
:: +blocked: blocked tasks
2019-05-05 03:23:22 +03:00
::
++ blocked (qeu (trel duct routes agent-action))
:: +stats: statistics
2019-05-05 03:23:22 +03:00
::
++ stats
2019-08-14 14:57:51 +03:00
$: :: change number
2019-05-05 03:23:22 +03:00
::
change=@ud
2019-05-05 03:23:22 +03:00
:: entropy
::
eny=@uvJ
:: time
::
time=@da
2019-05-05 03:23:22 +03:00
==
--
2016-11-24 07:25:07 +03:00
. ==
=| =state
2019-08-14 14:57:51 +03:00
|= $: :: identity
2019-05-05 03:23:22 +03:00
::
our=ship
:: urban time
::
now=@da
:: entropy
::
eny=@uvJ
:: activate
::
ska=sley
==
2016-11-24 07:25:07 +03:00
~% %gall-top ..is ~
2019-04-27 09:08:29 +03:00
|%
:: +gall-payload: gall payload
2019-05-03 01:53:27 +03:00
::
++ gall-payload +
:: +mo: Arvo-level move handling
2019-06-12 14:25:49 +03:00
::
:: An outer core responsible for routing moves to and from Arvo; it calls
:: an inner core, +ap, to route internal moves to and from agents.
::
2016-11-24 07:25:07 +03:00
++ mo
2018-12-13 04:34:25 +03:00
~% %gall-mo +> ~
2019-05-05 03:23:22 +03:00
|_
2019-08-14 14:57:51 +03:00
$: hen=duct
moves=(list move)
2019-05-05 03:23:22 +03:00
==
++ mo-core .
2019-06-12 14:25:49 +03:00
:: +mo-abed: initialise state with the provided duct.
2019-04-11 23:13:17 +03:00
::
++ mo-abed
2018-12-13 04:34:25 +03:00
|= =duct
^+ mo-core
2019-04-11 23:16:24 +03:00
::
mo-core(hen duct)
2019-04-11 23:16:24 +03:00
:: +mo-abet: resolve moves.
::
++ mo-abet
2019-05-03 01:53:27 +03:00
^- [(list move) _gall-payload]
2019-04-11 23:16:24 +03:00
::
2019-04-25 20:39:32 +03:00
=/ resolved (flop moves)
2019-05-03 01:53:27 +03:00
[resolved gall-payload]
2016-11-24 07:25:07 +03:00
::
2019-06-27 07:08:07 +03:00
:: +mo-boot: ask %ford to build us a core for the specified agent.
2019-05-13 10:40:50 +03:00
::
++ mo-boot
|= [=term =ship =desk]
^+ mo-core
::
=/ =case [%da now]
=/ =path
=/ ship (scot %p ship)
=/ case (scot case)
/sys/core/[term]/[ship]/[desk]/[case]
::
=/ =note-arvo
2019-06-12 14:25:49 +03:00
=/ =schematic:ford [%core [ship desk] /hoon/[term]/app]
[%f %build live=%.y schematic]
::
=/ pass [path note-arvo]
(mo-pass pass)
::
:: +mo-reboot: ask %ford to rebuild the specified agent
::
++ mo-reboot
|= [force=? =term =ship]
^+ mo-core
=/ gent (~(got by running.agents.state) term)
=. hen control-duct.gent
=* desk q.beak.gent
:: if we're forcing a reboot, we don't try to %kill the old build
::
?: force
(mo-boot term ship desk)
::
=/ =wire
=/ ship (scot %p ship)
=/ case (scot r.beak.gent)
/sys/core/[term]/[ship]/[desk]/[case]
%. [term ship desk]
=< mo-boot
=/ =note-arvo [%f %kill ~]
(mo-pass wire note-arvo)
::
::
:: +mo-goad: rebuild agent(s)
::
++ mo-goad
|= [force=? agent=(unit dude)]
^+ mo-core
?^ agent
~| goad-gone+u.agent
(mo-reboot force u.agent our)
::
=/ agents=(list term)
~(tap in ~(key by running.agents.state))
|- ^+ mo-core
?~ agents
mo-core
%= $
agents t.agents
..mo-core (mo-reboot force i.agents our)
==
::
2019-08-14 14:57:51 +03:00
:: +mo-pass: prepend a standard %pass to the current list of moves.
::
++ mo-pass
|= pass=(pair path note-arvo)
^+ mo-core
::
=/ =move [hen [%pass pass]]
mo-core(moves [move moves])
2019-08-14 14:57:51 +03:00
:: +mo-give: prepend a standard %give to the current list of moves.
2016-11-24 07:25:07 +03:00
::
++ mo-give
2019-04-25 20:39:32 +03:00
|= =gift:able
^+ mo-core
::
=/ =move [hen [%give gift]]
mo-core(moves [move moves])
2019-06-12 14:25:49 +03:00
:: +mo-contains-valid-bowl: check that a vase contains a valid bowl.
::
2019-05-13 10:40:50 +03:00
++ mo-contains-valid-bowl
~/ %mo-contains-valid-bowl
|= =vase
2016-11-24 07:25:07 +03:00
^- ?
::
=/ maybe-vase (slew 12 vase)
?~ maybe-vase
%.n
=/ =type p.u.maybe-vase
2019-08-15 19:22:32 +03:00
(~(nest ut type) %.n -:!>(*bowl))
2019-06-26 00:25:03 +03:00
:: +mo-receive-core: receives an app core built by %ford.
2019-06-12 14:25:49 +03:00
::
:: Presuming we receive a good core, we first check to see if the agent
:: is already running. If so, we update its beak in %gall's state,
:: initialise an +ap core for the agent, install the core we got from
:: %ford, and then resolve any moves associated with it.
2019-06-12 14:25:49 +03:00
::
:: If we're dealing with a new agent, we create one using the result we
:: got from %ford, add it to the collection of agents %gall is keeping
:: track of, and then do more or less the same procedure as we did for the
:: running agent case.
::
2019-06-26 00:25:03 +03:00
++ mo-receive-core
~/ %mo-receive-core
|= [=term =beak =made-result:ford]
^+ mo-core
::
?: ?=([%incomplete *] made-result)
(mo-give %onto %.n tang.made-result)
::
=/ build-result build-result.made-result
::
?: ?=([%error *] build-result)
(mo-give %onto %.n message.build-result)
::
=/ =cage (result-to-cage:ford build-result)
=/ result-vase q.cage
2019-06-12 14:25:49 +03:00
=/ maybe-agent=(unit agent)
(~(get by running.agents.state) term)
::
2019-06-12 14:25:49 +03:00
?^ maybe-agent
=/ agent u.maybe-agent(beak beak)
=. running.agents.state
(~(put by running.agents.state) term agent)
=/ =routes [disclosing=~ attributing=our]
=/ app (ap-abed:ap term routes)
=. app (ap-reinstall:app result-vase)
ap-abet:app
::
2019-05-13 10:40:50 +03:00
?. (mo-contains-valid-bowl result-vase)
=/ err [[%leaf "{<term>}: bogus core"] ~]
2019-04-27 07:54:35 +03:00
(mo-give %onto %.n err)
::
=. mo-core (mo-new-agent term beak result-vase)
=/ old mo-core
2019-04-27 07:54:35 +03:00
=/ wag
=/ =routes [disclosing=~ attributing=our]
=/ app (ap-abed:ap term routes)
(ap-prep:app ~)
::
=/ maybe-tang -.wag
=/ app +.wag
?^ maybe-tang
=. mo-core old
(mo-give %onto %.n u.maybe-tang)
2019-04-27 07:54:35 +03:00
::
=. mo-core ap-abet:app
=. mo-core (mo-clear-queue term)
2019-05-29 10:46:55 +03:00
=/ =suss [term %boot now]
(mo-give %onto [%.y suss])
2019-06-12 14:25:49 +03:00
:: +mo-new-agent: create a new agent and add it to %gall's state.
::
:: %gall maintains a collection of running agents. This arm creates a
:: new one with the provided name, beak, and state (held in a vase).
::
2019-05-13 10:40:50 +03:00
++ mo-new-agent
|= [=term =beak =vase]
^+ mo-core
::
2019-05-29 10:46:55 +03:00
=/ =ducts
:+ bone=1
bone-map=[[[~ ~] 0] ~ ~]
duct-map=[[0 [~ ~]] ~ ~]
::
=/ agent
=/ default-agent *agent
%_ default-agent
control-duct hen
beak beak
running-state vase
2019-05-29 10:46:55 +03:00
ducts ducts
2016-11-24 07:25:07 +03:00
==
::
%_ mo-core
running.agents.state (~(put by running.agents.state) term agent)
2019-06-12 14:25:49 +03:00
==
:: +mo-handle-foreign-request: handle a foreign request.
::
:: Handles tasks received on a +call that have come from another ship.
2016-11-24 07:25:07 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-handle-foreign-request
~/ %mo-handle-foreign-request
|= [=ship =internal-task]
^+ mo-core
::
=/ =term p.internal-task
=/ =agent-action q.internal-task
?: ?=(%pump -.agent-action)
2016-11-24 07:25:07 +03:00
::
:: you'd think this would send an ack for the diff
:: that caused this pump. it would, but we already
2019-10-22 01:41:28 +03:00
:: sent it when we got the diff in +mo-handle-sys-rep.
:: then we'd have to save the network duct and connect
:: it to this returning pump.
2016-11-24 07:25:07 +03:00
::
mo-core
::
?: ?=(%peer-not -.agent-action)
=/ =tang p.agent-action
(mo-give %unto %reap (some tang))
::
=^ bone mo-core (mo-assign-bone ship)
=/ =forward-ames
?- -.agent-action
%poke [%m p.p.agent-action q.q.p.agent-action]
%pull [%u ~]
%puff !!
%punk !!
%peel [%l agent-action]
%peer [%s p.agent-action]
==
::
=/ sys-path
=/ action -.agent-action
/sys/way/[action]
::
=/ =note-arvo
=/ =path /g/ge/[term]
2019-05-13 10:40:50 +03:00
=/ =noun [bone forward-ames]
[%a %want ship path noun]
::
(mo-pass sys-path note-arvo)
2019-05-13 10:40:50 +03:00
:: +mo-handle-foreign-response: handle foreign response.
2016-11-24 07:25:07 +03:00
::
:: Handle a received %woot from %ames.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-handle-foreign-response
|= [=foreign-response art=(unit ares)]
^+ mo-core
::
=/ to-tang
2019-08-27 02:46:56 +03:00
|= =ares
^- tang
2019-08-27 02:46:56 +03:00
?~ ares
~
=/ tape (trip p.u.ares)
[[%leaf tape] q.u.ares]
::
2019-08-27 02:46:56 +03:00
=/ result (bind art to-tang)
?- foreign-response
%peel (mo-give %unto %reap result)
%peer (mo-give %unto %reap result)
%poke (mo-give %unto %coup result)
%pull mo-core
2016-11-24 07:25:07 +03:00
==
2019-08-14 14:57:51 +03:00
:: +mo-assign-bone: assign an outbone to a ship.
2019-06-12 14:25:49 +03:00
::
:: If we know about the ship, we simply use its existing bone. Otherwise
:: we register a new entry for the ship, and use a default bone for it.
::
2019-05-13 10:40:50 +03:00
++ mo-assign-bone
|= =ship
^- [bone _mo-core]
::
=? mo-core !(~(has by contacts.agents.state) ship)
=/ =note-arvo [%j %public-keys (silt ship ~)]
=. moves [[system-duct.agents.state %pass /sys/jael note-arvo] moves]
=/ =foreign [1 ~ ~]
=. contacts.agents.state
(~(put by contacts.agents.state) ship foreign)
mo-core
::
=/ =foreign (~(got by contacts.agents.state) ship)
=/ existing (~(get by index-map.foreign) hen)
?^ existing
[u.existing mo-core]
::
=/ index index.foreign
2019-05-13 10:40:50 +03:00
=/ contacts
=/ new-foreign
%_ foreign
index +(index)
index-map (~(put by index-map.foreign) hen index)
duct-map (~(put by duct-map.foreign) index hen)
==
(~(put by contacts.agents.state) ship new-foreign)
::
=/ next mo-core(contacts.agents.state contacts)
2019-04-27 07:54:35 +03:00
[index next]
2019-06-12 14:25:49 +03:00
:: +mo-retrieve-duct: retrieve a duct by index.
::
2019-06-12 14:25:49 +03:00
++ mo-retrieve-duct
|= [=ship index=@ud]
^- (unit duct)
::
=/ contact=(unit foreign) (~(get by contacts.agents.state) ship)
?~ contact
~
`(~(got by duct-map.u.contact) index)
:: +mo-cancel-jael: cancel jael subscription
::
++ mo-cancel-jael
|= =ship
^+ mo-core
=/ =note-arvo [%j %nuke (silt ship ~)]
=. moves
[[system-duct.agents.state %pass /sys/jael note-arvo] moves]
mo-core
:: +mo-breach: ship breached, so forget about them
::
++ mo-breach
|= =ship
^+ mo-core
=/ agents=(list [name=term =agent]) ~(tap by running.agents.state)
|- ^+ mo-core
?~ agents
mo-core
=. mo-core
=/ =routes [disclosing=~ attributing=ship]
=/ app (ap-abed:ap name.i.agents routes)
ap-abet:(ap-breach:app ship)
=. mo-core (mo-cancel-jael ship)
=. contacts.agents.state (~(del by contacts.agents.state) ship)
$(agents t.agents)
2019-06-26 00:25:03 +03:00
:: +mo-handle-sys: handle a +sign incoming over /sys.
::
:: (Note that /sys implies the +sign should be routed to a vane.)
2019-06-27 07:08:07 +03:00
::
2019-06-26 00:25:03 +03:00
++ mo-handle-sys
~/ %mo-handle-sys
|= [=path =sign-arvo]
^+ mo-core
2019-06-26 00:25:03 +03:00
::
?+ -.path !!
%jael (mo-handle-sys-jael path sign-arvo)
2019-06-26 00:25:03 +03:00
%core (mo-handle-sys-core path sign-arvo)
%pel (mo-handle-sys-pel path sign-arvo)
%red (mo-handle-sys-red path sign-arvo)
%rep (mo-handle-sys-rep path sign-arvo)
%req (mo-handle-sys-req path sign-arvo)
%val (mo-handle-sys-val path sign-arvo)
%way (mo-handle-sys-way path sign-arvo)
==
:: +mo-handle-sys-jael: receive update about contact
::
++ mo-handle-sys-jael
|= [=path =sign-arvo]
^+ mo-core
?> ?=([%j %public-keys *] sign-arvo)
?> ?=([%jael ~] path)
?. ?=(%breach -.public-keys-result.sign-arvo)
mo-core
(mo-breach who.public-keys-result.sign-arvo)
2019-06-12 14:25:49 +03:00
:: +mo-handle-sys-core: receive a core from %ford.
::
2019-05-13 10:40:50 +03:00
++ mo-handle-sys-core
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([%f %made *] sign-arvo)
?> ?=([@ @ @ @ @ ~] path)
2019-04-24 21:49:51 +03:00
=/ beak-path t.t.path
=/ =beak
=/ =ship (slav %p i.beak-path)
=/ =desk i.t.beak-path
=/ =case [%da (slav %da i.t.t.beak-path)]
2019-05-13 10:40:50 +03:00
[ship desk case]
2019-06-26 00:25:03 +03:00
(mo-receive-core i.t.path beak result.sign-arvo)
2019-05-13 10:40:50 +03:00
:: +mo-handle-sys-pel: translated peer.
::
:: Validates a received %ford result and %gives an internal %diff.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-handle-sys-pel
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([%f %made *] sign-arvo)
?> ?=([@ @ ~] path)
::
?: ?=([%incomplete *] result.sign-arvo)
=/ err (some tang.result.sign-arvo)
(mo-give %unto %coup err)
::
=/ build-result build-result.result.sign-arvo
::
?: ?=([%error *] build-result)
=/ err (some message.build-result)
(mo-give %unto %coup err)
::
=/ =cage (result-to-cage:ford build-result)
(mo-give %unto %diff cage)
2019-05-13 10:40:50 +03:00
:: +mo-handle-sys-red: diff ack.
::
:: On receipt of a valid +sign from %ames, we simply pass a %pump
:: acknowledgement internally; otherwise we pass both an internal
:: unsubscribing %pull, plus a %want to %ames, before complaining about a
:: bad message acknowledgment.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-handle-sys-red
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([@ @ @ @ ~] path)
?. ?=([%a %woot *] sign-arvo)
~& [%red-want path]
mo-core
::
=/ him (slav %p i.t.path)
=/ dap i.t.t.path
=/ num (slav %ud i.t.t.t.path)
2019-04-27 07:54:35 +03:00
=/ =coop q.+>.sign-arvo
=/ sys-path
=/ pax [%req t.path]
[%sys pax]
::
2019-04-27 07:54:35 +03:00
?~ coop
2019-05-13 10:40:50 +03:00
=/ =note-arvo
=/ =sock [him our]
2019-06-12 14:25:49 +03:00
=/ =internal-task [dap %pump ~]
=/ =task:able [%deal sock internal-task]
2019-05-13 10:40:50 +03:00
[%g task]
(mo-pass sys-path note-arvo)
::
2019-05-13 10:40:50 +03:00
=/ gall-move=note-arvo
=/ =sock [him our]
2019-06-12 14:25:49 +03:00
=/ =internal-task [dap %pull ~]
=/ =task:able [%deal sock internal-task]
2019-05-13 10:40:50 +03:00
[%g task]
::
=/ ames-move=note-arvo
=/ path [%g %gh dap ~]
=/ =noun [num %x ~]
=/ =task:able:ames [%want him path noun]
[%a task]
::
=. mo-core (mo-pass sys-path gall-move)
=. mo-core (mo-pass sys-path ames-move)
::
2019-04-27 07:54:35 +03:00
?. ?=([~ ~ %mack *] coop)
~& [%diff-bad-ack coop]
mo-core
2019-05-13 10:40:50 +03:00
::
~& [%diff-bad-ack %mack]
=/ print (slog (flop q.,.+>.coop))
(print mo-core)
2019-05-13 10:40:50 +03:00
:: +mo-handle-sys-rep: reverse request.
::
:: On receipt of a valid +sign from %ford, sets state to the appropriate
:: duct and gives an internal %diff containing the +sign payload.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-handle-sys-rep
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([@ @ @ @ ~] path)
?> ?=([%f %made *] sign-arvo)
=/ him (slav %p i.t.path)
=/ dap i.t.t.path
=/ num (slav %ud i.t.t.t.path)
::
?: ?=([%incomplete *] result.sign-arvo)
=/ err (some tang.result.sign-arvo)
(mo-give %mack err)
::
=/ build-result build-result.result.sign-arvo
?: ?=([%error *] build-result)
:: XX should crash
=/ err (some message.build-result)
(mo-give %mack err)
:: XX pump should ack
=. mo-core (mo-give %mack ~)
2019-06-12 14:25:49 +03:00
=/ duct (mo-retrieve-duct him num)
?~ duct
%- (slog leaf/"gall: sys-rep no index" ~)
mo-core
=. mo-core (mo-abed u.duct)
=/ =cage (result-to-cage:ford build-result)
=/ move [%unto [%diff cage]]
(mo-give move)
2019-06-27 07:08:07 +03:00
:: +mo-handle-sys-req: process an inbound request.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-handle-sys-req
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([@ @ @ @ ~] path)
=/ him (slav %p i.t.path)
=/ dap i.t.t.path
=/ num (slav %ud i.t.t.t.path)
::
?: ?=([%f %made *] sign-arvo)
?: ?=([%incomplete *] result.sign-arvo)
=/ err (some tang.result.sign-arvo)
(mo-give %mack err)
::
=/ build-result build-result.result.sign-arvo
?: ?=([%error *] build-result)
=/ err (some message.build-result)
(mo-give %mack err)
::
=/ sys-path [%sys path]
2019-06-27 07:08:07 +03:00
=/ =note-arvo
=/ =cage (result-to-cage:ford build-result)
[%g %deal [him our] i.t.t.path %poke cage]
(mo-pass sys-path note-arvo)
::
?: ?=([%a %woot *] sign-arvo)
mo-core
::
?> ?=([%g %unto *] sign-arvo)
=/ =internal-gift +>.sign-arvo
::
?- -.internal-gift
%coup
(mo-give %mack p.internal-gift)
::
%diff
=/ sys-path [%sys %red t.path]
=/ =note-arvo
=/ path [%g %gh dap ~]
=/ noun [num %d p.p.internal-gift q.q.p.internal-gift]
[%a %want him path noun]
(mo-pass sys-path note-arvo)
::
%quit
=/ sys-path [%sys path]
=/ =note-arvo
=/ path [%g %gh dap ~]
=/ noun [num %x ~]
[%a %want him path noun]
(mo-pass sys-path note-arvo)
::
%reap
(mo-give %mack p.internal-gift)
::
%http-response
!!
==
2019-05-13 10:40:50 +03:00
:: +mo-handle-sys-val: inbound validate.
::
:: Validates an incoming +sign from %ford and applies it to the specified
:: agent.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-handle-sys-val
|= [=path =sign-arvo]
^+ mo-core
2016-11-24 07:25:07 +03:00
::
?> ?=([%f %made *] sign-arvo)
?> ?=([@ @ @ ~] path)
=/ =ship (slav %p i.t.path)
=/ =term i.t.t.path
?: ?=([%incomplete *] result.sign-arvo)
=/ err (some tang.result.sign-arvo)
(mo-give %unto %coup err)
::
=/ build-result build-result.result.sign-arvo
?: ?=([%error *] build-result)
=/ err (some message.build-result)
(mo-give %unto %coup err)
::
=/ =routes [disclosing=~ attributing=ship]
=/ =cage (result-to-cage:ford build-result)
=/ =agent-action [%poke cage]
(mo-apply term routes agent-action)
2019-05-13 10:40:50 +03:00
:: +mo-handle-sys-way: outbound request.
::
2019-05-13 10:40:50 +03:00
++ mo-handle-sys-way
|= [=path =sign-arvo]
^+ mo-core
::
?> ?=([%a %woot *] sign-arvo)
?> ?=([@ @ ~] path)
=/ =foreign-response (foreign-response i.t.path)
2019-06-12 14:25:49 +03:00
=/ maybe-ares +>+.sign-arvo
(mo-handle-foreign-response foreign-response maybe-ares)
:: +mo-handle-use: handle a typed +sign incoming on /use.
::
:: (Note that /use implies the +sign should be routed to an agent.)
2019-06-27 07:08:07 +03:00
::
:: Initialises the specified agent and then performs an agent-level +take
:: on the supplied +sign.
2019-04-11 23:29:43 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-handle-use
~/ %mo-handle-use
2019-04-11 23:29:43 +03:00
|= [=path hin=(hypo sign-arvo)]
^+ mo-core
2019-04-11 23:29:43 +03:00
::
?. ?=([@ @ coke *] path)
2019-05-13 10:40:50 +03:00
~& [%mo-handle-use-bad-path path]
2016-11-24 07:25:07 +03:00
!!
2019-04-11 23:29:43 +03:00
::
=/ app
2019-04-11 23:29:43 +03:00
=/ =term i.path
=/ =ship (slav %p i.t.path)
=/ =routes [disclosing=~ attributing=ship]
(ap-abed:ap term routes)
2019-04-11 23:29:43 +03:00
::
=/ =sign-arvo q.hin
2019-04-11 23:29:43 +03:00
?- i.t.t.path
%inn
2019-05-29 10:46:55 +03:00
=/ =vase (slot 3 hin)
=. app (ap-generic-take:app t.t.t.path vase)
ap-abet:app
::
2019-04-11 23:29:43 +03:00
%cay
~& [%mo-handle-use-weird sign-arvo]
~& [%mo-handle-use-weird-path path]
mo-core
::
2019-04-11 23:29:43 +03:00
%out
?. ?=([%g %unto *] sign-arvo)
2019-05-13 10:40:50 +03:00
~& [%mo-handle-use-weird sign-arvo]
~& [%mo-handle-use-weird-path path]
mo-core
=. app
=/ =internal-gift +>.sign-arvo
(ap-specific-take:app t.t.t.path internal-gift)
ap-abet:app
2016-11-24 07:25:07 +03:00
==
2019-06-27 07:08:07 +03:00
:: +mo-clear-queue: clear blocked tasks from the specified running agent.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-clear-queue
|= =term
^+ mo-core
2019-04-11 23:30:44 +03:00
::
?. (~(has by running.agents.state) term)
mo-core
=/ maybe-blocked (~(get by blocked.agents.state) term)
?~ maybe-blocked
mo-core
2019-04-11 23:30:44 +03:00
::
=/ =blocked u.maybe-blocked
2019-04-27 07:54:35 +03:00
::
|- ^+ mo-core
?: =(~ blocked)
=/ blocked (~(del by blocked.agents.state) term)
%_ mo-core
blocked.agents.state blocked
2019-04-11 23:30:44 +03:00
==
2019-05-29 10:46:55 +03:00
=^ task blocked [p q]:~(get to blocked)
=/ =duct p.task
=/ =routes q.task
2019-05-29 10:46:55 +03:00
=/ =agent-action r.task
::
=/ move
=/ =sock [attributing.routes our]
=/ =internal-task [term agent-action]
=/ card [%slip %g %deal sock internal-task]
[duct card]
2019-04-11 23:30:44 +03:00
$(moves [move moves])
2019-06-12 14:25:49 +03:00
:: +mo-beak: assemble a beak for the specified agent.
2016-11-24 07:25:07 +03:00
::
2019-04-11 23:30:44 +03:00
++ mo-beak
|= =term
2016-11-24 07:25:07 +03:00
^- beak
2019-06-12 14:25:49 +03:00
::
?~ running=(~(get by running.agents.state) term)
:: XX this fallback is necessary, as .term could be either the source
:: or the destination app. ie, it might not exist locally ...
::
[our %home %da now]
2019-08-14 14:57:51 +03:00
beak.u.running
:: +mo-peek: call to +ap-peek (which is not accessible outside of +mo).
2019-05-13 10:40:50 +03:00
::
2016-11-24 07:25:07 +03:00
++ mo-peek
~/ %mo-peek
|= [agent=term =routes =term =path]
2016-11-24 07:25:07 +03:00
^- (unit (unit cage))
::
=/ app (ap-abed:ap agent routes)
(ap-peek:app term path)
2019-06-12 14:25:49 +03:00
:: +mo-apply: apply the supplied action to the specified agent.
::
2019-05-13 10:40:50 +03:00
++ mo-apply
|= [=term =routes =agent-action]
^+ mo-core
::
=/ =path
=/ ship (scot %p attributing.routes)
/sys/val/[ship]/[term]
::
=/ ship-desk
=/ =beak (mo-beak term)
[p q]:beak
::
?: ?=(%puff -.agent-action)
=/ =schematic:ford [%vale ship-desk +.agent-action]
2019-04-27 07:54:35 +03:00
=/ =note-arvo [%f %build live=%.n schematic]
(mo-pass path note-arvo)
::
?: ?=(%punk -.agent-action)
=/ =schematic:ford [%cast ship-desk p.agent-action [%$ q.agent-action]]
2019-04-27 07:54:35 +03:00
=/ =note-arvo [%f %build live=%.n schematic]
(mo-pass path note-arvo)
::
?: ?=(%peer-not -.agent-action)
=/ err (some p.agent-action)
(mo-give %unto %reap err)
::
=/ app (ap-abed:ap term routes)
=. app (ap-apply:app agent-action)
ap-abet:app
2019-05-13 10:40:50 +03:00
:: +mo-handle-local: handle locally.
::
:: If the agent is running or blocked, assign it the supplied +task.
:: Otherwise simply apply the action to the agent.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-handle-local
|= [=ship =internal-task]
^+ mo-core
::
=/ =routes [disclosing=~ attributing=ship]
=/ =term p.internal-task
=/ =agent-action q.internal-task
=/ is-running (~(has by running.agents.state) term)
=/ is-blocked (~(has by blocked.agents.state) term)
2019-04-26 08:16:46 +03:00
::
2019-06-26 00:25:03 +03:00
?: |(!is-running is-blocked)
=/ =blocked
=/ waiting (~(get by blocked.agents.state) term)
2019-05-29 10:46:55 +03:00
=/ tasks (fall waiting *blocked)
=/ task [hen routes agent-action]
2019-05-29 10:46:55 +03:00
(~(put to tasks) task)
::
2019-11-05 10:36:50 +03:00
~& >> [%gall-not-running term -.agent-action]
%_ mo-core
blocked.agents.state (~(put by blocked.agents.state) term blocked)
==
(mo-apply term routes agent-action)
2019-06-27 07:08:07 +03:00
:: +mo-handle-forward: handle forward %ames message.
2016-11-24 07:25:07 +03:00
::
2019-05-13 10:40:50 +03:00
++ mo-handle-forward
|= [=ship =term =bone =forward-ames]
^+ mo-core
::
=. mo-core
2019-08-15 20:51:50 +03:00
?. ?=(%u -.forward-ames)
mo-core
(mo-give %mack ~)
::
=/ =path
2019-04-27 07:54:35 +03:00
=/ him (scot %p ship)
=/ num (scot %ud bone)
/sys/req/[him]/[term]/[num]
::
=/ =sock [ship our]
=/ =note-arvo
2019-08-15 20:51:50 +03:00
?- -.forward-ames
%m
=/ =task:able
=/ =internal-task [term %puff [mark noun]:forward-ames]
[%deal sock internal-task]
[%g task]
::
%l
=/ =task:able
=/ =internal-task [term %peel [mark path]:forward-ames]
[%deal sock internal-task]
[%g task]
::
%s
=/ =task:able
=/ =internal-task [term %peer path.forward-ames]
[%deal sock internal-task]
[%g task]
::
%u
=/ =task:able
=/ =internal-task [term %pull ~]
[%deal sock internal-task]
[%g task]
==
(mo-pass path note-arvo)
2019-06-27 07:08:07 +03:00
:: +mo-handle-backward: handle reverse %ames message.
::
2019-05-13 10:40:50 +03:00
++ mo-handle-backward
|= [=ship =term =bone =reverse-ames]
^+ mo-core
::
2019-08-15 20:51:50 +03:00
?- -.reverse-ames
%d
=/ =path
2019-04-27 07:54:35 +03:00
=/ him (scot %p ship)
=/ num (scot %ud bone)
/sys/rep/[him]/[term]/[num]
::
=/ =note-arvo
=/ beak (mo-beak term)
=/ info [p q]:beak
=/ =schematic:ford [%vale info p.reverse-ames q.reverse-ames]
2019-04-27 07:54:35 +03:00
[%f %build live=%.n schematic]
::
(mo-pass path note-arvo)
::
%x
2019-05-03 01:53:27 +03:00
:: XX should crash
=. mo-core (mo-give %mack ~)
=/ out (mo-retrieve-duct ship bone)
?~ out
%- (slog leaf/"gall: x no index" ~)
mo-core
2019-05-03 01:53:27 +03:00
=/ initialised
(mo-abed u.out)
2019-05-03 01:53:27 +03:00
(mo-give:initialised %unto %quit ~)
2015-05-10 01:55:05 +03:00
==
2019-04-27 08:05:43 +03:00
:: +ap: agent engine
::
:: An inner, agent-level core. The sample refers to the agent we're
:: currently focused on.
2019-08-14 14:57:51 +03:00
::
2019-04-27 08:05:43 +03:00
++ ap
2016-11-24 07:25:07 +03:00
~% %gall-ap +> ~
|_ $: agent-name=term
agent-routes=routes
agent-bone=bone
agent-moves=(list internal-move)
agent-config=(list (each suss tang))
2019-07-03 05:36:54 +03:00
current-agent=agent
2016-11-24 07:25:07 +03:00
==
++ ap-core .
:: +ap-abed: initialise state for an agent, with the supplied routes.
2019-06-12 14:25:49 +03:00
::
:: The agent must already be running in +gall -- here we simply update
:: +ap's state to focus on it.
2019-04-27 08:05:43 +03:00
::
++ ap-abed
~/ %ap-abed
|= [=term =routes]
^+ ap-core
2019-04-27 08:05:43 +03:00
::
=/ =agent
=/ running (~(got by running.agents.state) term)
=/ =stats
:+ +(change.stats.running)
(shaz (mix (add term change.stats.running) eny))
now
running(stats stats)
2019-04-27 09:08:29 +03:00
::
=. agent-name term
=. agent-routes routes
2019-07-03 05:36:54 +03:00
=. current-agent agent
2019-06-12 14:25:49 +03:00
=/ maybe-bone (~(get by bone-map.ducts.agent) hen)
?^ maybe-bone
ap-core(agent-bone u.maybe-bone)
2019-04-27 09:08:29 +03:00
::
2019-05-29 10:46:55 +03:00
=/ =ducts
:+ +(bone.ducts.agent)
(~(put by bone-map.ducts.agent) hen bone.ducts.agent)
(~(put by duct-map.ducts.agent) bone.ducts.agent hen)
::
%_ ap-core
2019-07-03 05:36:54 +03:00
agent-bone bone.ducts.agent
ducts.current-agent ducts
2016-11-24 07:25:07 +03:00
==
2019-04-27 08:05:43 +03:00
:: +ap-abet: resolve moves.
::
++ ap-abet
^+ mo-core
2019-04-27 08:05:43 +03:00
::
2019-05-13 10:40:50 +03:00
=> ap-track-queue
=/ running (~(put by running.agents.state) agent-name current-agent)
=/ moves
2019-05-13 10:40:50 +03:00
=/ giver |=(report=(each suss tang) [hen %give %onto report])
=/ from-internal (turn agent-moves ap-from-internal)
=/ from-suss (turn agent-config giver)
:(weld from-internal from-suss moves)
::
%_ mo-core
running.agents.state running
2019-08-15 23:13:05 +03:00
moves moves
2016-11-24 07:25:07 +03:00
==
2019-05-13 10:40:50 +03:00
:: +ap-track-queue: track queue.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-track-queue
^+ ap-core
2019-04-27 08:42:04 +03:00
::
=/ internal-moves agent-moves
=/ bones *(set bone)
|- ^+ ap-core
?^ internal-moves
=/ =internal-move i.internal-moves
2019-07-03 05:36:54 +03:00
?. ?=([%give %diff *] move.internal-move)
$(internal-moves t.internal-moves)
::
=^ filled ap-core ap-enqueue(agent-bone bone.internal-move)
=/ new-bones
?: filled
bones
(~(put in bones) bone.internal-move)
$(internal-moves t.internal-moves, bones new-bones)
::
2019-06-12 14:25:49 +03:00
=/ bones ~(tap in bones)
2019-04-27 09:08:29 +03:00
::
|- ^+ ap-core
2019-06-12 14:25:49 +03:00
?~ bones
ap-core
2019-04-27 09:08:29 +03:00
::
2019-06-12 14:25:49 +03:00
=> $(bones t.bones, agent-bone i.bones)
2019-07-03 05:36:54 +03:00
=/ incoming
(~(get by incoming.subscribers.current-agent) agent-bone)
2019-06-12 14:25:49 +03:00
?~ incoming
~& [%ap-track-queue-bad-bone agent-name agent-bone]
ap-core
::
2019-06-12 14:25:49 +03:00
=/ =ship p.u.incoming
ap-kill(attributing.agent-routes ship)
2019-05-13 10:40:50 +03:00
:: +ap-from-internal: internal move to move.
2019-04-27 08:42:04 +03:00
::
:: We convert from bone-indexed moves to duct-indexed moves when
:: resolving them in Arvo.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-from-internal
~/ %ap-from-internal
|= =internal-move
2019-01-18 08:37:34 +03:00
^- move
2019-04-27 08:42:04 +03:00
::
2019-07-03 05:36:54 +03:00
~| [%gall-move-conversion-failed internal-move]
=/ =duct
(~(got by duct-map.ducts.current-agent) bone.internal-move)
2019-05-13 10:40:50 +03:00
::
=/ card
?- -.move.internal-move
%slip !!
::
%give
?< =(0 bone.internal-move)
::
=/ =internal-gift p.move.internal-move
?. ?=(%diff -.internal-gift)
[%give %unto internal-gift]
::
=/ =cage p.internal-gift
=/ =mark
2019-07-03 05:36:54 +03:00
=/ mark (~(get by marks.current-agent) bone.internal-move)
(fall mark p.cage)
::
?: =(mark p.cage)
[%give %unto internal-gift]
=/ =path /sys/pel/[agent-name]
=/ =note-arvo
=/ =schematic:ford
=/ =beak (mo-beak agent-name)
[%cast [p q]:beak mark [%$ cage]]
[%f %build live=%.n schematic]
::
[%pass path note-arvo]
::
%pass
=/ =path p.move.internal-move
=/ =internal-note q.move.internal-move
=/ use-path [%use agent-name path]
=/ =note-arvo
2019-08-15 20:51:50 +03:00
?- -.internal-note
%send
2019-05-13 10:40:50 +03:00
=/ =task:able
=/ =sock [our ship.internal-note]
=/ =internal-task internal-task.internal-note
[%deal sock internal-task]
[%g task]
::
%meta
=/ =term term.internal-note
=/ =vase vase.internal-note
[term %meta vase]
==
[%pass use-path note-arvo]
==
[duct card]
:: +ap-breach: ship breached, so forget about them
::
++ ap-breach
|= =ship
^+ ap-core
=/ in=(list [=bone =^ship =path])
~(tap by incoming.subscribers.current-agent)
|- ^+ ap-core
?^ in
=? ap-core =(ship ship.i.in)
=/ core ap-load-delete(agent-bone bone.i.in)
core(agent-bone agent-bone)
$(in t.in)
::
=/ out=(list [[=bone =wire] =bean =^ship =path])
~(tap by outgoing.subscribers.current-agent)
|- ^+ ap-core
?~ out
ap-core
=? ap-core =(ship ship.i.out)
=/ core (ap-specific-take(agent-bone bone.i.out) wire.i.out %quit ~)
core(agent-bone agent-bone)
$(out t.out)
2019-04-27 08:42:04 +03:00
:: +ap-call: call into server.
::
++ ap-call
2016-11-24 07:25:07 +03:00
~/ %ap-call
2019-05-03 01:53:27 +03:00
|= [=term =vase]
^- [(unit tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=. ap-core ap-construct-bowl
=^ arm ap-core (ap-produce-arm term)
?: ?=(%.n -.arm)
[(some p.arm) ap-core]
2019-05-03 01:53:27 +03:00
::
=^ arm ap-core (ap-slam term p.arm vase)
?: ?=(%.n -.arm)
[(some p.arm) ap-core]
2019-05-13 10:40:50 +03:00
(ap-handle-result p.arm)
2019-04-27 08:42:04 +03:00
:: +ap-peek: peek.
::
2016-11-24 07:25:07 +03:00
++ ap-peek
~/ %ap-peek
|= [=term tyl=path]
2016-11-24 07:25:07 +03:00
^- (unit (unit cage))
2019-04-27 08:42:04 +03:00
::
=/ marked
?. ?=(%x term)
2019-05-03 01:53:27 +03:00
[mark=%$ tyl=tyl]
::
2019-05-03 01:53:27 +03:00
=/ =path (flop tyl)
?> ?=(^ path)
[mark=i.path tyl=(flop t.path)]
::
=/ =mark mark.marked
=/ tyl tyl.marked
=^ maybe-arm ap-core (ap-find-arm %peek term tyl)
::
?~ maybe-arm
2019-05-03 01:53:27 +03:00
=/ =tank [%leaf "peek find fail"]
=/ print (slog tank >tyl< >mark< ~)
(print [~ ~])
2019-05-03 01:53:27 +03:00
::
=^ arm ap-core (ap-produce-arm q.u.maybe-arm)
2019-05-03 01:53:27 +03:00
::
?: ?=(%.n -.arm)
2019-05-03 01:53:27 +03:00
=/ =tank [%leaf "peek farm fail"]
=/ print (slog tank p.arm)
(print [~ ~])
2019-05-03 01:53:27 +03:00
::
=/ slammed
=/ index p.u.maybe-arm
=/ name q.u.maybe-arm
=/ =vase
=/ =path [term tyl]
!> (slag index path)
(ap-slam name p.arm vase)
2019-05-03 01:53:27 +03:00
::
=^ possibly-vase ap-core slammed
?: ?=(%.n -.possibly-vase)
2019-05-03 01:53:27 +03:00
=/ =tank [%leaf "peek slam fail"]
=/ print (slog tank p.possibly-vase)
(print [~ ~])
::
=/ slammed-vase p.possibly-vase
=/ vase-value q.slammed-vase
2019-05-03 01:53:27 +03:00
=/ err
|.
2019-05-03 01:53:27 +03:00
=/ =tank [%leaf "peek bad result"]
=/ print (slog tank ~)
(print [~ ~])
2019-05-03 01:53:27 +03:00
::
?+ vase-value $:err
~
~
::
[~ ~]
[~ ~]
::
2019-05-03 01:53:27 +03:00
[~ ~ ^]
=/ =vase (sped (slot 7 slammed-vase))
2019-05-03 01:53:27 +03:00
::
?. ?=([p=@ *] q.vase)
=/ =tank [%leaf "scry: malformed cage"]
=/ print (slog tank ~)
(print [~ ~])
2019-05-03 01:53:27 +03:00
::
?. ((sane %tas) p.q.vase)
2019-05-03 01:53:27 +03:00
=/ =tank [%leaf "scry: malformed cage"]
=/ print (slog tank ~)
(print [~ ~])
2019-05-03 01:53:27 +03:00
::
?. =(mark p.q.vase)
[~ ~]
::
=/ =cage [p.q.vase (slot 3 vase)]
(some (some cage))
2016-11-24 07:25:07 +03:00
==
2019-05-13 10:40:50 +03:00
:: +ap-apply: apply effect.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-apply
|= =agent-action
^+ ap-core
2019-04-27 08:42:04 +03:00
::
?- -.agent-action
%peel (ap-peel +.agent-action)
%poke (ap-poke +.agent-action)
%peer (ap-peer +.agent-action)
2019-05-03 01:53:27 +03:00
%puff !!
%punk !!
%peer-not !!
2019-05-13 10:40:50 +03:00
%pull ap-load-delete
%pump ap-dequeue
2016-11-24 07:25:07 +03:00
==
2019-04-27 08:42:04 +03:00
:: +ap-diff: pour a diff.
::
++ ap-diff
~/ %ap-diff
|= [=ship =path =cage]
^+ ap-core
2019-04-27 08:42:04 +03:00
::
=/ rest +.path
2019-05-29 10:46:55 +03:00
=/ pax [p.cage rest]
=^ maybe-arm ap-core (ap-find-arm %diff pax)
2019-05-03 01:53:27 +03:00
::
?~ maybe-arm
=/ target [%.n ship rest]
2019-05-03 01:53:27 +03:00
=/ =tang
=/ why "diff: no {<[p.cage rest]>}"
2019-05-13 10:40:50 +03:00
(ap-tang why)
2019-05-03 01:53:27 +03:00
::
=. ap-core (ap-lame %diff tang)
(ap-update-subscription target)
2019-05-03 01:53:27 +03:00
::
=/ arm u.maybe-arm
2019-05-03 01:53:27 +03:00
=/ =vase
=/ target
?: =(0 p.arm)
=/ =vase (ap-cage cage)
[!>(rest) vase]
[!>((slag (dec p.arm) rest)) q.cage]
2019-05-03 01:53:27 +03:00
(slop target)
::
=^ called ap-core (ap-call q.arm vase)
?^ called
=. ap-core (ap-lame q.arm u.called)
(ap-update-subscription %.n ship path)
2019-05-13 10:40:50 +03:00
(ap-update-subscription %.y ship path)
2019-04-27 08:42:04 +03:00
:: +ap-cage: cage to tagged vase.
::
++ ap-cage
2019-05-13 10:40:50 +03:00
|= =cage
2019-05-29 01:37:42 +03:00
^- vase
2019-05-13 10:40:50 +03:00
::
=/ =type [%atom %tas (some p.cage)]
=/ =vase [type p.cage]
(slop vase q.cage)
:: +ap-update-subscription: update subscription.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-update-subscription
~/ %ap-update-subscription
2019-05-03 01:53:27 +03:00
|= [is-ok=? =ship =path]
^+ ap-core
2019-04-27 08:42:04 +03:00
::
2019-05-03 01:53:27 +03:00
=/ way [(scot %p ship) %out path]
::
?: is-ok
=/ =internal-note [%send ship -.path %pump ~]
(ap-pass way internal-note)
=. ap-core (ap-give %quit ~)
=/ =internal-note [%send ship -.path %pull ~]
(ap-pass way internal-note)
2019-05-13 10:40:50 +03:00
:: +ap-dequeue: drop from queue.
2019-04-27 08:42:04 +03:00
::
:: Dequeues along the current bone, deleting the queue entirely if it
:: drops to zero.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-dequeue
^+ ap-core
2019-04-27 08:42:04 +03:00
::
2019-07-03 05:36:54 +03:00
?. (~(has by incoming.subscribers.current-agent) agent-bone)
ap-core
2019-07-03 05:36:54 +03:00
=/ level (~(get by meter.subscribers.current-agent) agent-bone)
?: |(?=(~ level) =(0 u.level))
ap-core
2019-05-03 01:53:27 +03:00
::
=. u.level (dec u.level)
?: =(0 u.level)
2019-07-03 05:36:54 +03:00
=/ deleted (~(del by meter.subscribers.current-agent) agent-bone)
ap-core(meter.subscribers.current-agent deleted)
2019-05-03 01:53:27 +03:00
::
2019-08-14 14:57:51 +03:00
=/ dequeued
(~(put by meter.subscribers.current-agent) agent-bone u.level)
ap-core(meter.subscribers.current-agent dequeued)
2019-05-13 10:40:50 +03:00
:: +ap-produce-arm: produce arm.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-produce-arm
~/ %ap-produce-arm
2019-05-03 01:53:27 +03:00
|= =term
^- [(each vase tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=/ virtual
2019-07-03 05:36:54 +03:00
=/ =type p.running-state.current-agent
=/ =hoon [%limb term]
%- mule
|. (~(mint wa cache.current-agent) type hoon)
2019-05-03 01:53:27 +03:00
::
?: ?=(%.n -.virtual)
=/ =tang p.virtual
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ possibly-vase=(each vase tang)
2019-07-03 05:36:54 +03:00
=/ value q.running-state.current-agent
2019-05-13 10:40:50 +03:00
=/ ton (mock [value q.+<.virtual] ap-namespace-view)
2019-05-03 01:53:27 +03:00
?- -.ton
%0 [%.y p.+<.virtual p.ton]
%1 [%.n (turn p.ton |=(a=* (smyt (path a))))]
2019-05-03 01:53:27 +03:00
%2 [%.n p.ton]
==
::
=/ next
=/ =worm +>.virtual
ap-core(cache.current-agent worm)
::
[possibly-vase next]
2019-05-13 10:40:50 +03:00
:: +ap-enqueue: add to queue.
2019-04-27 08:42:04 +03:00
::
:: Every agent has a 'meter', that tracks the number of incoming
:: subscribers by bone. We get both the meter and ship associated with
:: the current bone; if the meter has hit twenty for another ship, we
:: don't enqueue the subscriber. Otherwise we increment the meter for
:: the current bone and update the agent's state with it.
2019-06-12 14:25:49 +03:00
::
:: Returns a yes if the meter has been incremented, and no otherwise.
2019-06-12 14:25:49 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-enqueue
^- [? _ap-core]
::
2019-07-03 05:36:54 +03:00
=/ meter (~(gut by meter.subscribers.current-agent) agent-bone 0)
2019-06-04 01:23:29 +03:00
=/ subscriber=(unit (pair ship path))
2019-07-03 05:36:54 +03:00
(~(get by incoming.subscribers.current-agent) agent-bone)
2019-05-03 01:53:27 +03:00
::
?: ?& =(20 meter)
2019-06-04 01:23:29 +03:00
?| ?=(~ subscriber)
!=(our p.u.subscriber)
==
==
2019-07-03 05:36:54 +03:00
=/ incoming (~(get by incoming.subscribers.current-agent) agent-bone)
=/ duct (~(get by duct-map.ducts.current-agent) agent-bone)
~& [%gall-pulling-20 agent-bone incoming duct]
[%.n ap-core]
::
=/ next
2019-08-14 14:57:51 +03:00
=/ meter
(~(put by meter.subscribers.current-agent) agent-bone +(meter))
ap-core(meter.subscribers.current-agent meter)
::
[%.y next]
2019-05-13 10:40:50 +03:00
:: +ap-find-arm: general arm.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-find-arm
~/ %ap-find-arm
2019-05-03 01:53:27 +03:00
|= [=term =path]
^- [(unit (pair @ud @tas)) _ap-core]
2019-05-03 01:53:27 +03:00
::
2019-07-03 05:36:54 +03:00
=/ maybe-cached (~(get by arm-cache.current-agent) [term path])
?^ maybe-cached
[u.maybe-cached ap-core]
::
2019-05-03 01:53:27 +03:00
=/ result
=/ dep 0
|- ^- (unit (pair @ud @tas))
=/ spu
?~ path
~
=/ hyped (cat 3 term (cat 3 '-' i.path))
$(path t.path, dep +(dep), term hyped)
::
?^ spu
spu
::
2019-05-13 10:40:50 +03:00
?. (ap-exists-arm term)
2019-05-03 01:53:27 +03:00
~
(some [dep term])
::
2019-08-14 14:57:51 +03:00
=. arm-cache.current-agent
(~(put by arm-cache.current-agent) [term path] result)
[result ap-core]
2019-06-12 14:25:49 +03:00
:: +ap-exists-arm: check for an arm in the running agent state.
2016-11-24 07:25:07 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-exists-arm
~/ %ap-exists-arm
2019-05-03 01:53:27 +03:00
|= =term
2016-11-24 07:25:07 +03:00
^- ?
2019-04-27 08:42:04 +03:00
::
2019-07-03 05:36:54 +03:00
=/ =type p.running-state.current-agent
(slob term type)
2019-04-27 08:42:04 +03:00
:: +ap-give: return result.
2016-11-24 07:25:07 +03:00
::
2019-04-27 08:42:04 +03:00
++ ap-give
|= =internal-gift
^+ ap-core
2019-04-27 08:42:04 +03:00
::
=/ internal-moves
=/ move [%give internal-gift]
=/ =internal-move [agent-bone move]
[internal-move agent-moves]
ap-core(agent-moves internal-moves)
2019-05-13 10:40:50 +03:00
:: +ap-construct-bowl: set up bowl.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-construct-bowl
^+ ap-core
::
%_ ap-core
2019-07-03 05:36:54 +03:00
+12.q.running-state.current-agent
2016-11-24 07:25:07 +03:00
^- bowl
2019-08-14 14:57:51 +03:00
:* :* our :: host
attributing.agent-routes :: guest
2019-08-14 14:57:51 +03:00
agent-name :: agent
== ::
:* :: NB (jtobin): see urbit/urbit#1466
2019-08-15 23:22:45 +03:00
wex=~ :: outgoing
2019-08-14 14:57:51 +03:00
sup=incoming.subscribers.current-agent :: incoming
== ::
:* agent-bone=agent-bone :: cause
act=change.stats.current-agent :: tick
eny=eny.stats.current-agent :: nonce
now=time.stats.current-agent :: time
byk=beak.current-agent :: source
== ==
2016-11-24 07:25:07 +03:00
==
2019-04-27 08:42:04 +03:00
:: +ap-move: process each move.
::
++ ap-move
2016-11-24 07:25:07 +03:00
~/ %ap-move
2019-05-03 01:53:27 +03:00
|= =vase
^- [(each internal-move tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=/ noun q.vase
?@ noun
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "move: invalid move (atom)")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
?^ -.noun
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "move: invalid move (bone)")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
?@ +.noun
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "move: invalid move (card)")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ =bone -.noun
2019-07-03 05:36:54 +03:00
=/ has-duct (~(has by duct-map.ducts.current-agent) bone)
?. &(has-duct !=(0 bone))
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "move: invalid card (bone {<bone>})")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
2019-07-03 05:36:54 +03:00
=^ vase cache.current-agent (~(spot wa cache.current-agent) 3 vase)
=^ vase cache.current-agent (~(slot wa cache.current-agent) 3 vase)
?+ +<.noun (ap-move-pass bone +<.noun vase)
%diff (ap-move-diff bone vase)
%peel (ap-move-peel bone vase)
%peer (ap-move-peer bone vase)
%pull (ap-move-pull bone vase)
%poke (ap-move-poke bone vase)
%send (ap-move-send bone vase)
%quit (ap-move-quit bone vase)
%http-response (ap-move-http-response bone vase)
2016-11-24 07:25:07 +03:00
==
2019-04-27 08:42:04 +03:00
:: +ap-move-quit: give quit move.
::
++ ap-move-quit
~/ %quit
2019-05-03 01:53:27 +03:00
|= [=bone =vase]
^- [(each internal-move tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=/ possibly-internal-move=(each internal-move tang)
2019-05-03 01:53:27 +03:00
?^ q.vase
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "quit: improper give")
2019-05-03 01:53:27 +03:00
[%.n tang]
::
=/ =internal-move
=/ =internal-gift [%quit ~]
=/ move [%give internal-gift]
[bone move]
::
[%.y internal-move]
2019-05-03 01:53:27 +03:00
::
=/ next
2019-07-03 05:36:54 +03:00
=/ incoming (~(del by incoming.subscribers.current-agent) bone)
%_ ap-core
2019-07-03 05:36:54 +03:00
incoming.subscribers.current-agent incoming
==
[possibly-internal-move next]
2019-04-27 08:42:04 +03:00
:: +ap-move-diff: give diff move.
::
++ ap-move-diff
~/ %diff
2019-05-03 01:53:27 +03:00
|= [=bone =vase]
^- [(each internal-move tang) _ap-core]
::
2019-07-03 05:36:54 +03:00
=^ vase cache.current-agent (~(sped wa cache.current-agent) vase)
=/ value q.vase
?. ?& ?=(^ value)
?=(@ -.value)
((sane %tas) -.value)
==
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "diff: improper give")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
2019-07-03 05:36:54 +03:00
=^ vase cache.current-agent (~(slot wa cache.current-agent) 3 vase)
=/ =internal-move
=/ =cage [-.value vase]
=/ move [%give %diff cage]
[bone move]
[[%.y internal-move] ap-core]
:: +ap-move-http-response
::
++ ap-move-http-response
|= [sto=bone vax=vase]
^- [(each internal-move tang) _ap-core]
:: TODO: Magic vase validation. I have no idea how malformed checking
:: works.
::
:_ ap-core
[%& sto %give %http-response ;;(http-event:http q.vax)]
2019-04-27 08:42:04 +03:00
:: +ap-move-mess: extract path, target.
::
++ ap-move-mess
~/ %mess
2019-05-03 01:53:27 +03:00
|= =vase
^- [(each (trel path ship term) tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=/ possibly-trel=(each (trel path ship term) tang)
2019-05-03 01:53:27 +03:00
?. ?& ?=([p=* [q=@ r=@] s=*] q.vase)
(gte 1 (met 7 q.q.vase))
==
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "mess: malformed target")
2019-05-03 01:53:27 +03:00
[%.n tang]
::
=/ pax ((soft path) p.q.vase)
2019-05-03 01:53:27 +03:00
::
?. ?& ?=(^ pax)
(levy u.pax (sane %ta))
==
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "mess: malformed path")
2019-05-03 01:53:27 +03:00
[%.n tang]
::
=/ =path [(scot %p q.q.vase) %out r.q.vase u.pax]
2019-05-03 01:53:27 +03:00
=/ =ship q.q.vase
=/ =term r.q.vase
[%.y path ship term]
::
[possibly-trel ap-core]
2019-04-27 08:42:04 +03:00
:: +ap-move-pass: pass general move.
::
++ ap-move-pass
~/ %pass
2019-05-03 01:53:27 +03:00
|= [=bone =noun =vase]
^- [(each internal-move tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
?. ?& ?=(@ noun)
((sane %tas) noun)
==
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "pass: malformed card")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ pax ((soft path) -.q.vase)
?. ?& ?=(^ pax)
(levy u.pax (sane %ta))
==
=/ =tang (ap-tang "pass: malformed path")
~& [%bad-path pax]
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ maybe-vane (ap-vain noun)
?~ maybe-vane
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "move: unknown note {(trip noun)}")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ vane u.maybe-vane
2019-08-14 14:57:51 +03:00
=^ at-slot cache.current-agent
(~(slot wa cache.current-agent) 3 vase)
=/ =internal-move
=/ =path [(scot %p attributing.agent-routes) %inn u.pax]
2019-05-13 10:40:50 +03:00
=/ vase (ap-atomic-vase %tas noun)
=/ combined (slop vase at-slot)
=/ =internal-note [%meta vane combined]
=/ card [%pass path internal-note]
[bone card]
[[%.y internal-move] ap-core]
2019-04-27 08:42:04 +03:00
:: +ap-move-poke: pass %poke.
::
++ ap-move-poke
~/ %poke
|= [=bone =vase]
^- [(each internal-move tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=^ possibly-target ap-core (ap-move-mess vase)
2019-05-03 01:53:27 +03:00
::
?: ?=(%.n -.possibly-target)
[possibly-target ap-core]
2019-05-03 01:53:27 +03:00
::
2019-08-14 14:57:51 +03:00
=^ at-slot cache.current-agent
(~(slot wa cache.current-agent) 7 vase)
2019-05-03 01:53:27 +03:00
::
?. ?& ?=([p=@ q=*] q.at-slot)
((sane %tas) p.q.at-slot)
==
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "poke: malformed cage")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
2019-08-14 14:57:51 +03:00
=^ specialised cache.current-agent
(~(stop wa cache.current-agent) 3 at-slot)
=/ target p.possibly-target
=/ =path p.target
=/ =ship q.target
=/ =term r.target
::
=/ =internal-move
=/ =internal-task [term %poke p.q.at-slot specialised]
=/ =internal-note [%send ship internal-task]
=/ card [%pass path internal-note]
[bone card]
::
[[%.y internal-move] ap-core]
2019-04-27 08:42:04 +03:00
:: +ap-move-peel: pass %peel.
::
++ ap-move-peel
~/ %peel
2019-05-03 01:53:27 +03:00
|= [=bone =vase]
^- [(each internal-move tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=^ possibly-target ap-core (ap-move-mess vase)
?: ?=(%.n -.possibly-target)
[possibly-target ap-core]
::
=/ target p.possibly-target
=/ =ship q.target
=/ =term r.target
=/ mark ((soft mark) +>-.q.vase)
?~ mark
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "peel: malformed mark")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ pax ((soft path) +>+.q.vase)
2019-05-03 01:53:27 +03:00
::
?. ?& ?=(^ pax)
(levy u.pax (sane %ta))
==
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "peel: malformed path")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ move
2019-07-03 05:36:54 +03:00
?: (~(has in misvale.current-agent) p.target)
=/ =internal-task
=/ =tang [[%leaf "peel: misvalidation encountered"] ~]
=/ =agent-action [%peer-not tang]
[term agent-action]
=/ =internal-note [%send ship internal-task]
=/ card [%pass p.target internal-note]
[bone card]
::
=/ =agent-action [%peel u.mark u.pax]
=/ =internal-task [term agent-action]
=/ =internal-note [%send ship internal-task]
=/ card [%pass p.target internal-note]
[bone card]
[[%.y move] ap-core]
2019-04-27 08:42:04 +03:00
:: +ap-move-peer: pass %peer.
::
++ ap-move-peer
~/ %peer
2019-05-03 01:53:27 +03:00
|= [=bone =vase]
^- [(each internal-move tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=^ possibly-target ap-core (ap-move-mess vase)
?: ?=(%.n -.possibly-target)
[possibly-target ap-core]
::
=/ target p.possibly-target
=/ =ship q.target
=/ =term r.target
=/ pax ((soft path) +>.q.vase)
?. ?& ?=(^ pax)
(levy u.pax (sane %ta))
==
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "peer: malformed path")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ move
2019-07-03 05:36:54 +03:00
?: (~(has in misvale.current-agent) p.target)
=/ err [[%leaf "peer: misvalidation encountered"] ~]
=/ =agent-action [%peer-not err]
=/ =internal-note [%send ship term agent-action]
=/ card [%pass p.target internal-note]
[bone card]
::
=/ =agent-action [%peer u.pax]
=/ =internal-note [%send ship term agent-action]
=/ card [%pass p.target internal-note]
[bone card]
[[%.y move] ap-core]
2019-04-27 08:42:04 +03:00
:: +ap-move-pull: pass %pull.
::
++ ap-move-pull
~/ %pull
2019-05-03 01:53:27 +03:00
|= [=bone =vase]
^- [(each internal-move tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=^ possibly-target ap-core (ap-move-mess vase)
?: ?=(%.n -.possibly-target)
[possibly-target ap-core]
::
=/ target p.possibly-target
=/ =ship q.target
=/ =term r.target
2019-05-03 01:53:27 +03:00
?. =(~ +>.q.vase)
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "pull: malformed card")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ move
=/ =agent-action [%pull ~]
=/ =internal-note [%send ship term agent-action]
=/ card [%pass p.target internal-note]
[bone card]
::
[[%.y move] ap-core]
2019-04-27 08:42:04 +03:00
:: +ap-move-send: pass gall action.
::
++ ap-move-send
~/ %send
2019-05-03 01:53:27 +03:00
|= [=bone =vase]
^- [(each internal-move tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
2019-05-03 01:53:27 +03:00
?. ?& ?=([p=* [q=@ r=@] [s=@ t=*]] q.vase)
(gte 1 (met 7 q.q.vase))
((sane %tas) r.q.vase)
2016-11-24 07:25:07 +03:00
==
2019-08-14 14:57:51 +03:00
=/ =tang
(ap-tang "send: improper ask.[%send wire gill agent-action]")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ pax ((soft path) p.q.vase)
?. ?& ?=(^ pax)
(levy u.pax (sane %ta))
==
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "send: malformed path")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
?: ?=($poke s.q.vase)
2019-08-14 14:57:51 +03:00
=^ specialised cache.current-agent
(~(spot wa cache.current-agent) 7 vase)
::
?> =(%poke -.q.specialised)
2019-05-03 01:53:27 +03:00
::
?. ?& ?=([p=@ q=*] t.q.vase)
((sane %tas) p.t.q.vase)
2016-11-24 07:25:07 +03:00
==
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "send: malformed poke")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
2019-08-14 14:57:51 +03:00
=^ specialised cache.current-agent
(~(spot wa cache.current-agent) 3 specialised)
=^ at-slot cache.current-agent
(~(slot wa cache.current-agent) 3 specialised)
::
=/ move
=/ =agent-action [%poke p.t.q.vase at-slot]
=/ =internal-note [%send q.q.vase r.q.vase agent-action]
=/ =path [(scot %p q.q.vase) %out r.q.vase u.pax]
=/ card [%pass path internal-note]
[bone card]
2019-05-03 01:53:27 +03:00
::
[[%.y move] ap-core]
2019-05-03 01:53:27 +03:00
::
=/ maybe-action ((soft agent-action) [s t]:q.vase)
?~ maybe-action
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "send: malformed agent-action")
[[%.n tang] ap-core]
::
=/ move
=/ =agent-action u.maybe-action
=/ =internal-note [%send q.q.vase r.q.vase agent-action]
=/ =path [(scot %p q.q.vase) %out r.q.vase u.pax]
=/ card [%pass path internal-note]
[bone card]
::
[[%.y move] ap-core]
2019-04-27 08:42:04 +03:00
:: +ap-pass: request action.
::
++ ap-pass
|= [=path =internal-note]
^+ ap-core
2019-04-27 08:42:04 +03:00
::
=/ =internal-move
=/ move [%pass path internal-note]
[agent-bone move]
=/ internal-moves [internal-move agent-moves]
ap-core(agent-moves internal-moves)
2019-05-13 10:40:50 +03:00
:: +ap-reinstall: reinstall.
2016-11-24 07:25:07 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-reinstall
~/ %ap-reinstall
2019-05-03 01:53:27 +03:00
|= =vase
^+ ap-core
2019-04-27 08:42:04 +03:00
::
=/ prep
2019-07-03 05:36:54 +03:00
=/ installed ap-install(running-state.current-agent vase)
=/ running (some running-state.current-agent)
(installed running)
::
=^ maybe-tang ap-core prep
?~ maybe-tang
ap-core
(ap-lame %prep-failed u.maybe-tang)
2019-04-27 08:42:04 +03:00
:: +ap-peel: apply %peel.
::
2016-11-24 07:25:07 +03:00
++ ap-peel
2019-05-03 01:53:27 +03:00
|= [=mark =path]
^+ ap-core
2019-04-27 08:42:04 +03:00
::
2019-07-03 05:36:54 +03:00
=. marks.current-agent (~(put by marks.current-agent) agent-bone mark)
2019-05-03 01:53:27 +03:00
(ap-peer path)
2019-04-27 08:42:04 +03:00
:: +ap-peer: apply %peer.
::
++ ap-peer
~/ %ap-peer
2019-04-27 08:42:04 +03:00
|= pax=path
^+ ap-core
2019-04-27 08:42:04 +03:00
::
=/ incoming [attributing.agent-routes pax]
2019-07-03 05:36:54 +03:00
=. incoming.subscribers.current-agent
(~(put by incoming.subscribers.current-agent) agent-bone incoming)
2019-05-03 01:53:27 +03:00
::
=^ maybe-arm ap-core (ap-find-arm %peer pax)
?~ maybe-arm
ap-core
2019-05-03 01:53:27 +03:00
::
=/ arm u.maybe-arm
=/ =vase !>((slag p.arm pax))
=/ old agent-moves
=. agent-moves ~
=^ maybe-tang ap-core (ap-call q.arm vase)
=/ internal-moves=(list internal-move)
=/ move [agent-bone %give %reap maybe-tang]
[move old]
2019-05-03 01:53:27 +03:00
::
=. agent-moves (weld agent-moves internal-moves)
?^ maybe-tang
2019-05-13 10:40:50 +03:00
ap-silent-delete
ap-core
2019-04-27 08:42:04 +03:00
:: +ap-poke: apply %poke.
2016-11-24 07:25:07 +03:00
::
2019-04-27 08:42:04 +03:00
++ ap-poke
~/ %ap-poke
2019-05-03 01:53:27 +03:00
|= =cage
^+ ap-core
2019-04-27 08:42:04 +03:00
::
=^ maybe-arm ap-core (ap-find-arm %poke p.cage ~)
?~ maybe-arm
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "no poke arm for {(trip p.cage)}")
2019-05-03 01:53:27 +03:00
(ap-give %coup (some tang))
::
=/ arm u.maybe-arm
=/ =vase
2019-05-13 10:40:50 +03:00
=/ vas (ap-atomic-vase %tas p.cage)
?. =(0 p.arm)
q.cage
(slop vas q.cage)
::
=^ tur ap-core (ap-call q.arm vase)
2016-11-24 07:25:07 +03:00
(ap-give %coup tur)
2019-04-27 08:42:04 +03:00
:: +ap-lame: pour error.
::
++ ap-lame
2019-05-03 01:53:27 +03:00
|= [=term =tang]
^+ ap-core
2019-04-27 08:42:04 +03:00
::
=^ maybe-arm ap-core (ap-find-arm /lame)
=/ form |=(=tank [%rose [~ "! " ~] tank ~])
?~ maybe-arm
=/ tang [>%ap-lame agent-name term< (turn tang form)]
2019-05-03 01:53:27 +03:00
~> %slog.`rose+[" " "[" "]"]^(flop tang)
ap-core
2019-05-03 01:53:27 +03:00
::
=/ arm u.maybe-arm
=/ =vase !>([term tang])
=^ maybe-tang ap-core (ap-call q.arm vase)
?^ maybe-tang
=/ tang u.maybe-tang
=/ etc (flop [>%ap-lame-lame< (turn tang form)])
~> %slog.`rose+[" " "[" "]"]^(welp etc [%leaf "." (flop tang)])
ap-core
2019-05-03 01:53:27 +03:00
::
ap-core
2019-04-27 08:42:04 +03:00
:: +ap-misvale: broken vale.
::
++ ap-misvale
2019-05-03 01:53:27 +03:00
|= =wire
^+ ap-core
2019-04-27 08:42:04 +03:00
::
2019-05-03 01:53:27 +03:00
~& [%ap-blocking-misvale wire]
2019-07-03 05:36:54 +03:00
=/ misvaled (~(put in misvale.current-agent) wire)
ap-core(misvale.current-agent misvaled)
2019-05-13 10:40:50 +03:00
:: +ap-generic-take: generic take.
2016-11-04 04:35:47 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-generic-take
~/ %ap-generic-take
|= [=path =vase]
^+ ap-core
2019-04-27 08:42:04 +03:00
::
2019-05-03 01:53:27 +03:00
?. &(?=([@ *] q.vase) ((sane %tas) -.q.vase))
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "pour: malformed card")
2019-05-03 01:53:27 +03:00
(ap-lame %pour tang)
::
=/ =term -.q.vase
=^ maybe-arm ap-core (ap-find-arm [term path])
?~ maybe-arm
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "pour: no {(trip -.q.vase)}: {<path>}")
(ap-lame term tang)
::
=/ arm u.maybe-arm
2019-08-14 14:57:51 +03:00
=^ at-slot cache.current-agent
(~(slot wa cache.current-agent) 3 vase)
=/ vase (slop !>((slag p.arm path)) at-slot)
2019-05-03 01:53:27 +03:00
::
=^ maybe-tang ap-core (ap-call q.arm vase)
?^ maybe-tang
(ap-lame term u.maybe-tang)
ap-core
2019-05-13 10:40:50 +03:00
:: +ap-unwrap-take: unwrap take.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-unwrap-take
~/ %ap-unwrap-take
2019-05-03 01:53:27 +03:00
|= [=term pax=path =cage]
^+ ap-core
2019-04-27 08:42:04 +03:00
::
=^ maybe-arm ap-core (ap-find-arm [term p.cage pax])
::
?~ maybe-arm
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "{(trip term)}: no {<`path`[p.cage pax]>}")
2019-05-03 01:53:27 +03:00
(ap-lame term tang)
::
=/ arm u.maybe-arm
2019-05-03 01:53:27 +03:00
=/ =vase
%- slop
?: =(0 p.arm)
=/ =vase (ap-cage cage)
[!>(`path`pax) vase]
[!>((slag (dec p.arm) `path`pax)) q.cage]
2019-05-03 01:53:27 +03:00
::
=^ maybe-tang ap-core (ap-call q.arm vase)
?^ maybe-tang
(ap-lame q.arm u.maybe-tang)
ap-core
2019-05-13 10:40:50 +03:00
:: +ap-specific-take: specific take.
2016-11-24 07:25:07 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-specific-take
|= [=path =internal-gift]
^+ ap-core
2019-04-27 08:42:04 +03:00
::
2019-08-14 14:57:51 +03:00
=/ pax +.path
?- -.internal-gift
2019-08-14 14:57:51 +03:00
%coup
=/ maybe-vase (some !>(p.internal-gift))
(ap-non-diff-take %coup pax maybe-vase)
::
2019-08-14 14:57:51 +03:00
%diff
=/ =ship attributing.agent-routes
2019-08-14 14:57:51 +03:00
=/ =cage p.internal-gift
(ap-diff ship path cage)
::
2019-08-14 14:57:51 +03:00
%quit
(ap-non-diff-take %quit pax ~)
::
2019-08-14 14:57:51 +03:00
%reap
=/ maybe-vase (some !>(p.internal-gift))
(ap-non-diff-take %reap pax maybe-vase)
::
2019-08-14 14:57:51 +03:00
%http-response
!!
2016-11-24 07:25:07 +03:00
==
2019-05-13 10:40:50 +03:00
:: +ap-install: install wrapper.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-install
|= maybe-vase=(unit vase)
^- [(unit tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=^ maybe-tang ap-core (ap-prep maybe-vase)
=/ new-misvale-data
2019-07-03 05:36:54 +03:00
~? !=(misvale.current-agent *misvale-data)
[%misvale-drop misvale.current-agent]
:: new app might mean new marks
*misvale-data
::
=/ new-agent-config
=/ =term ?~(maybe-vase %boot %bump)
=/ possibly-suss
?~ maybe-tang
=/ =suss [agent-name term now]
[%.y suss]
[%.n u.maybe-tang]
[possibly-suss agent-config]
::
=/ next
%= ap-core
2019-08-14 14:57:51 +03:00
misvale.current-agent new-misvale-data
agent-config new-agent-config
arm-cache.current-agent ~
==
::
[maybe-tang next]
2019-05-13 10:40:50 +03:00
:: +ap-prep: low-level install.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-prep
~/ %ap-prep
|= maybe-vase=(unit vase)
^- [(unit tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
?. (ap-exists-arm %prep)
?~ maybe-vase
[~ ap-core]
2019-05-03 01:53:27 +03:00
::
2019-05-13 10:40:50 +03:00
=/ new-type
2019-07-03 05:36:54 +03:00
=/ new (slot 13 running-state.current-agent)
2019-05-13 10:40:50 +03:00
p.new
2019-05-03 01:53:27 +03:00
::
2019-05-13 10:40:50 +03:00
=/ old-type
=/ old (slot 13 u.maybe-vase)
p.old
::
?. (~(nest ut new-type) %.n old-type)
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "prep mismatch")
[(some tang) ap-core]
::
2019-08-14 14:57:51 +03:00
=/ next
ap-core(+13.q.running-state.current-agent +13.q.u.maybe-vase)
[~ next]
2019-05-03 01:53:27 +03:00
::
=/ =vase
?~ maybe-vase
!>(~)
(slop !>(~) (slot 13 u.maybe-vase))
2019-05-03 01:53:27 +03:00
::
(ap-call %prep vase)
2019-05-13 10:40:50 +03:00
:: +ap-silent-delete: silent delete.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-silent-delete
^+ ap-core
2019-04-27 08:42:04 +03:00
::
2019-08-21 19:46:26 +03:00
?~ (~(get by incoming.subscribers.current-agent) agent-bone)
ap-core
2019-05-03 01:53:27 +03:00
::
2019-08-21 19:46:26 +03:00
=/ incoming (~(del by incoming.subscribers.current-agent) agent-bone)
2019-08-14 14:57:51 +03:00
=/ meter (~(del by meter.subscribers.current-agent) agent-bone)
%_ ap-core
2019-08-14 14:57:51 +03:00
incoming.subscribers.current-agent incoming
meter.subscribers.current-agent meter
2016-11-24 07:25:07 +03:00
==
2019-05-13 10:40:50 +03:00
:: +ap-load-delete: load delete.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-load-delete
^+ ap-core
2019-04-27 08:42:04 +03:00
::
2019-08-14 14:57:51 +03:00
=/ maybe-incoming
(~(get by incoming.subscribers.current-agent) agent-bone)
?~ maybe-incoming
ap-core
2019-05-03 01:53:27 +03:00
::
=/ incoming u.maybe-incoming
2019-08-14 14:57:51 +03:00
=. incoming.subscribers.current-agent
(~(del by incoming.subscribers.current-agent) agent-bone)
=. meter.subscribers.current-agent
(~(del by meter.subscribers.current-agent) agent-bone)
2019-05-03 01:53:27 +03:00
::
=^ maybe-arm ap-core (ap-find-arm %pull q.incoming)
?~ maybe-arm
ap-core
2019-05-03 01:53:27 +03:00
::
=/ arm u.maybe-arm
=/ =vase !>((slag p.arm q.incoming))
=^ maybe-tang ap-core (ap-call q.arm vase)
?^ maybe-tang
(ap-lame q.arm u.maybe-tang)
ap-core
2019-04-27 08:42:04 +03:00
:: +ap-kill: queue kill.
::
++ ap-kill
^+ ap-core
2019-05-13 10:40:50 +03:00
::
=> ap-load-delete
(ap-give %quit ~)
2019-05-13 10:40:50 +03:00
:: +ap-non-diff-take: non-diff gall take.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-non-diff-take
~/ %ap-non-diff-take
|= [=term =path maybe-vase=(unit vase)]
^+ ap-core
2019-04-27 08:42:04 +03:00
::
=^ maybe-arm ap-core (ap-find-arm term path)
?~ maybe-arm
ap-core
2019-05-03 01:53:27 +03:00
::
=/ arm u.maybe-arm
=/ =vase
=/ vax !>((slag p.arm path))
?~ maybe-vase
vax
(slop vax u.maybe-vase)
::
=^ maybe-tang ap-core (ap-call q.arm vase)
?^ maybe-tang
(ap-lame q.arm u.maybe-tang)
ap-core
2019-04-27 08:42:04 +03:00
:: +ap-safe: process move list.
2016-11-24 07:25:07 +03:00
::
2019-04-27 08:42:04 +03:00
++ ap-safe
~/ %ap-safe
2019-05-03 01:53:27 +03:00
|= =vase
^- [(each (list internal-move) tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
2019-05-03 01:53:27 +03:00
?~ q.vase
[[%.y ~] ap-core]
2019-05-03 01:53:27 +03:00
::
?@ q.vase
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "move: malformed list")
[[%.n tang] ap-core]
2019-05-03 01:53:27 +03:00
::
2019-07-03 05:36:54 +03:00
=^ hed cache.current-agent (~(slot wa cache.current-agent) 2 vase)
=^ possibly-internal-move ap-core (ap-move hed)
?: ?=(%.n -.possibly-internal-move)
[possibly-internal-move ap-core]
2019-05-03 01:53:27 +03:00
::
=/ =internal-move p.possibly-internal-move
2019-07-03 05:36:54 +03:00
=^ tel cache.current-agent (~(slot wa cache.current-agent) 3 vase)
=^ res ap-core $(vase tel)
=/ possibly-internal-moves
2019-05-03 01:53:27 +03:00
?: ?=(%.n -.res)
res
[%.y [internal-move p.res]]
2019-05-03 01:53:27 +03:00
::
[possibly-internal-moves ap-core]
2019-05-13 10:40:50 +03:00
:: +ap-handle-result: handle result.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-handle-result
~/ %ap-handle-result
2019-05-03 01:53:27 +03:00
|= =vase
^- [(unit tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
2019-05-03 01:53:27 +03:00
?: ?=(@ q.vase)
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "ap-handle-result: invalid product (atom)")
[(some tang) ap-core]
2019-05-03 01:53:27 +03:00
::
2019-07-03 05:36:54 +03:00
=^ hed cache.current-agent (~(slot wa cache.current-agent) 2 vase)
=^ possibly-internal-moves ap-core (ap-safe hed)
?: ?=(%.n -.possibly-internal-moves)
=/ =tang p.possibly-internal-moves
[(some tang) ap-core]
2019-05-03 01:53:27 +03:00
::
=/ internal-moves p.possibly-internal-moves
2019-07-03 05:36:54 +03:00
=^ tel cache.current-agent (~(slot wa cache.current-agent) 3 vase)
=^ possibly-vase ap-core (ap-verify-core tel)
2019-05-03 01:53:27 +03:00
::
?: ?=(%.n -.possibly-vase)
=/ =tang p.possibly-vase
[(some tang) ap-core]
::
=/ next
%_ ap-core
2019-08-14 14:57:51 +03:00
agent-moves (weld (flop internal-moves) agent-moves)
2019-07-03 05:36:54 +03:00
running-state.current-agent p.possibly-vase
==
::
[~ next]
2019-05-13 10:40:50 +03:00
:: +ap-verify-core: verify core.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-verify-core
~/ %ap-verify-core
2019-04-27 08:42:04 +03:00
|= vax=vase
^- [(each vase tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=/ received-type p.vax
2019-07-03 05:36:54 +03:00
=/ running-type p.running-state.current-agent
2019-08-14 14:57:51 +03:00
=^ nests cache.current-agent
(~(nest wa cache.current-agent) running-type received-type)
::
=/ possibly-vase
?. nests
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "invalid core")
[%.n tang]
[%.y vax]
::
[possibly-vase ap-core]
2019-04-27 08:42:04 +03:00
:: +ap-slam: virtual slam.
::
++ ap-slam
2016-11-24 07:25:07 +03:00
~/ %ap-slam
|= [=term gat=vase arg=vase]
^- [(each vase tang) _ap-core]
2019-04-27 08:42:04 +03:00
::
=/ virtual
=/ =type [%cell p.gat p.arg]
=/ =hoon [%cnsg [%$ ~] [%$ 2] [%$ 3] ~]
%- mule
|. (~(mint wa cache.current-agent) type hoon)
::
?: ?=(%.n -.virtual)
2019-05-13 10:40:50 +03:00
=/ =tang (ap-tang "call: {<term>}: type mismatch")
=/ sam (~(peek ut p.gat) %free 6)
=/ print
(slog >%ap-slam-mismatch< ~(duck ut p.arg) ~(duck ut sam) ~)
(print [[%.n tang] ap-core])
::
=/ =worm +>.virtual
=/ =vase +<.virtual
=/ =type p.vase
=/ nock q.vase
2019-05-13 10:40:50 +03:00
=/ ton (mock [[q.gat q.arg] nock] ap-namespace-view)
=/ possibly-vase
?- -.ton
%0 [%.y type p.ton]
%1 [%.n (turn p.ton |=(a=* (smyt (path a))))]
%2 [%.n p.ton]
==
2019-05-03 01:53:27 +03:00
::
=/ next ap-core(cache.current-agent worm)
[possibly-vase next]
2019-05-13 10:40:50 +03:00
:: +ap-namespace-view: namespace view.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-namespace-view (sloy ska)
:: +ap-tang: standard tang.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-tang
2019-05-03 01:53:27 +03:00
|= =tape
2016-11-24 07:25:07 +03:00
^- tang
2019-04-27 08:42:04 +03:00
::
=/ =tank [%leaf (weld "gall: {<agent-name>}: " tape)]
2019-05-03 01:53:27 +03:00
[tank ~]
2019-05-13 10:40:50 +03:00
:: +ap-atomic-vase: atomic vase.
2019-04-27 08:42:04 +03:00
::
2019-05-13 10:40:50 +03:00
++ ap-atomic-vase
2019-05-03 01:53:27 +03:00
|= [=term =atom]
2016-11-24 07:25:07 +03:00
^- vase
2019-04-27 08:42:04 +03:00
::
2019-05-03 01:53:27 +03:00
=/ =type [%atom term (some atom)]
2019-05-13 10:40:50 +03:00
[type atom]
2019-04-27 08:42:04 +03:00
:: +ap-vain: card to vane.
::
++ ap-vain
2019-05-03 01:53:27 +03:00
|= =term
2016-11-24 07:25:07 +03:00
^- (unit @tas)
2019-04-27 08:42:04 +03:00
::
2019-05-03 01:53:27 +03:00
?+ term ~& [%ap-vain term]
~
%bonk `%a
%build `%f
%cash `%a
%conf `%g
%conf-mall `%m
%cred `%c
%crew `%c
%crow `%c
%deal `%g
%deal-mall `%m
%dirk `%c
%drop `%c
%flog `%d
%goad `%g
%info `%c
%init `%m
%keep `%f
%kill `%f
2019-09-27 20:55:14 +03:00
%knob `%d
%look `%j
%listen `%j
%merg `%c
%mont `%c
%moon `%j
%nuke `%a
%ogre `%c
%perm `%c
%rest `%b
%rekey `%j
%wait `%b
%want `%a
%warp `%c
%wash `%g
%wipe `%f
2019-07-04 03:08:23 +03:00
%request `%i
%cancel-request `%i
2019-08-14 14:57:51 +03:00
%serve `%e
%connect `%e
%disconnect `%e
%rule `%e
2016-11-24 07:25:07 +03:00
==
--
--
:: +call: request
2019-05-03 01:53:27 +03:00
::
++ call
2016-11-24 07:25:07 +03:00
~% %gall-call +> ~
2019-05-03 01:53:27 +03:00
|= [=duct hic=(hypo (hobo task:able))]
^- [(list move) _gall-payload]
2019-04-11 23:34:30 +03:00
::
2019-05-13 10:40:50 +03:00
~| [%gall-call-failed duct q.hic]
:: make sure our task is hard
::
2019-05-13 10:40:50 +03:00
=/ =task:able
?. ?=(%soft -.q.hic)
q.hic
;; task:able p.q.hic
2019-04-11 23:34:30 +03:00
::
2019-05-03 01:53:27 +03:00
=/ initialised (mo-abed:mo duct)
2019-05-13 10:40:50 +03:00
?- -.task
2019-04-11 23:34:30 +03:00
%conf
2019-05-13 10:40:50 +03:00
=/ =dock p.task
2019-05-03 01:53:27 +03:00
=/ =ship p.dock
?. =(our ship)
~& [%gall-not-ours ship]
[~ gall-payload]
2019-04-11 23:34:30 +03:00
::
2019-05-13 10:40:50 +03:00
=> (mo-boot:initialised q.dock q.task)
mo-abet
::
2019-04-11 23:34:30 +03:00
%deal
2019-05-13 10:40:50 +03:00
=/ =sock p.task
=/ =internal-task q.task
?. =(q.sock our)
?> =(p.sock our)
=> (mo-handle-foreign-request:initialised q.sock internal-task)
mo-abet
::
=> (mo-handle-local:initialised p.sock internal-task)
mo-abet
::
%goad
mo-abet:(mo-goad:initialised force.task agent.task)
::
2019-04-11 23:34:30 +03:00
%init
=/ payload gall-payload(system-duct.agents.state duct)
2019-05-05 03:23:22 +03:00
[~ payload]
::
%trim
:: reuse %wash task to clear caches on memory-pressure
::
:: XX cancel subscriptions if =(0 trim-priority) ?
::
~> %slog.[0 leaf+"gall: trim: clearing caches"]
=/ =move [duct %pass / %g [%wash ~]]
[[move ~] gall-payload]
::
2019-05-03 01:53:27 +03:00
%vega
[~ gall-payload]
::
2019-04-11 23:34:30 +03:00
%west
2019-05-13 10:40:50 +03:00
=/ =ship p.task
=/ =path q.task
=/ =noun r.task
::
?> ?=([?(%ge %gh) @ ~] path)
=/ agent-name i.t.path
2019-05-03 01:53:27 +03:00
::
2019-05-13 10:40:50 +03:00
?: ?=(%ge i.path)
=/ mes ;;((pair @ud forward-ames) noun)
=> (mo-handle-forward:initialised ship agent-name mes)
2019-05-13 10:40:50 +03:00
mo-abet
2019-05-03 01:53:27 +03:00
::
2019-05-13 10:40:50 +03:00
=/ mes ;;((pair @ud reverse-ames) noun)
=> (mo-handle-backward:initialised ship agent-name mes)
2019-05-13 10:40:50 +03:00
mo-abet
::
2019-08-11 00:24:31 +03:00
%wash
=. running.agents.state
(~(run by running.agents.state) |=(=agent agent(cache *worm)))
[~ gall-payload]
::
%wegh
2019-06-26 00:25:03 +03:00
=/ blocked
=/ queued (~(run by blocked.agents.state) |=(blocked [%.y +<]))
(sort ~(tap by queued) aor)
::
=/ running
=/ active (~(run by running.agents.state) |=(agent [%.y +<]))
(sort ~(tap by active) aor)
::
2018-12-13 04:34:25 +03:00
=/ =mass
2019-05-03 01:53:27 +03:00
:+ %gall %.n
:~ [%foreign %.y contacts.agents.state]
2019-06-26 00:25:03 +03:00
[%blocked %.n blocked]
[%active %.n running]
[%dot %.y state]
2018-12-13 04:34:25 +03:00
==
::
=/ moves
=/ =move [duct %give %mass mass]
[move ~]
::
[moves gall-payload]
2016-11-24 07:25:07 +03:00
==
:: +load: recreate vane
2019-05-03 01:53:27 +03:00
::
++ load
=> |%
+$ all-states
$% state-0
state-1
==
::
+$ state-0
$: %0
=agents-0
==
::
+$ agents-0
$: system-duct=duct
contacts=(map ship foreign-0)
running=(map term agent)
blocked=(map term blocked)
==
::
+$ foreign-0
$: =rift
index=@ud
index-map=(map duct @ud)
duct-map=(map @ud duct)
==
::
++ upgrade-0
|= s=state-0
^- state-1
:- %1
%= +.s
contacts.agents-0
%- ~(run by contacts.agents-0.s)
|= foreign-0
^- foreign
[index index-map duct-map]
==
::
++ state-1 ^state
--
|= old=all-states
2019-05-03 01:53:27 +03:00
^+ gall-payload
::
=? old ?=(%0 -.old)
(upgrade-0 old)
?> ?=(%1 -.old)
gall-payload(state old)
:: +scry: standard scry
2019-05-03 01:53:27 +03:00
::
2016-11-24 07:25:07 +03:00
++ scry
~/ %gall-scry
2019-05-05 03:23:22 +03:00
|= [fur=(unit (set monk)) =term =shop =desk =coin =path]
2016-11-24 07:25:07 +03:00
^- (unit (unit cage))
2019-05-05 03:23:22 +03:00
?. ?=(%.y -.shop)
2019-05-03 01:53:27 +03:00
~
::
2019-05-05 03:23:22 +03:00
=/ =ship p.shop
?: ?& =(%u term)
=(~ path)
=([%$ %da now] coin)
=(our ship)
2016-11-24 07:25:07 +03:00
==
=/ =vase !>((~(has by running.agents.state) desk))
2019-05-05 03:23:22 +03:00
=/ =cage [%noun vase]
(some (some cage))
2019-05-03 01:53:27 +03:00
::
2019-05-05 03:23:22 +03:00
?. =(our ship)
2016-11-24 07:25:07 +03:00
~
2019-05-03 01:53:27 +03:00
::
2019-05-05 03:23:22 +03:00
?. =([%$ %da now] coin)
2016-11-24 07:25:07 +03:00
~
2019-05-03 01:53:27 +03:00
::
?. (~(has by running.agents.state) desk)
2019-05-05 03:23:22 +03:00
(some ~)
2019-05-03 01:53:27 +03:00
::
2019-05-05 03:23:22 +03:00
?. ?=(^ path)
2016-11-24 07:25:07 +03:00
~
2019-05-03 01:53:27 +03:00
::
2019-05-05 03:23:22 +03:00
=/ initialised mo-abed:mo
=/ =routes [~ ship]
(mo-peek:initialised desk routes term path)
:: +stay: save without cache
2019-05-03 01:53:27 +03:00
::
++ stay state
:: +take: response
2016-11-24 07:25:07 +03:00
::
2019-05-03 01:53:27 +03:00
++ take
~/ %gall-take
2019-05-05 03:23:22 +03:00
|= [=wire =duct hin=(hypo sign-arvo)]
^- [(list move) _gall-payload]
::
2019-05-13 10:40:50 +03:00
~| [%gall-take-failed wire]
2019-05-05 03:23:22 +03:00
?> ?=([?(%sys %use) *] wire)
=/ initialised (mo-abed:mo duct)
2019-05-29 10:46:55 +03:00
=/ =sign-arvo q.hin
=>
2019-05-05 03:23:22 +03:00
?- i.wire
2019-05-29 10:46:55 +03:00
%sys (mo-handle-sys:initialised t.wire sign-arvo)
2019-05-13 10:40:50 +03:00
%use (mo-handle-use:initialised t.wire hin)
==
mo-abet
2016-11-24 07:25:07 +03:00
--