mirror of
https://github.com/urbit/shrub.git
synced 2024-12-01 14:42:02 +03:00
13. single-home %ford state
This commit is contained in:
parent
979122a9da
commit
c4c5fe5a79
@ -190,17 +190,12 @@
|
||||
+= axle
|
||||
$: :: date: date at which ford's state was updated to this data structure
|
||||
::
|
||||
date=%~2018.6.28
|
||||
:: state-by-ship: storage for all the @p's this ford has been
|
||||
date=%~2018.12.13
|
||||
:: state: all persistent state
|
||||
::
|
||||
:: Once the cc-release boot sequence lands, we can remove this
|
||||
:: mapping, since an arvo will not change @p identities. until
|
||||
:: then, we need to support a ship booting as a comet before
|
||||
:: becoming its adult identity.
|
||||
::
|
||||
state-by-ship=(map ship ford-state)
|
||||
state=ford-state
|
||||
==
|
||||
:: +ford-state: all state that ford maintains for a @p ship identity
|
||||
:: +ford-state: all state that ford maintains
|
||||
::
|
||||
+= ford-state
|
||||
$: :: builds: per-build state machine for all builds
|
||||
@ -6093,12 +6088,8 @@
|
||||
:: %kill: cancel a build
|
||||
:: %wipe: clear memory
|
||||
::
|
||||
:: The general procedure is for Ford to determine the `our` identity
|
||||
:: for this +task and operate on the :ship-state for that identity.
|
||||
::
|
||||
:: Most requests get converted into operations to be performed inside
|
||||
:: the +per-event core, which is Ford's main build engine. The %keep
|
||||
:: and %wipe requests work across all identities stored in Ford, though.
|
||||
:: the +per-event core, which is Ford's main build engine.
|
||||
::
|
||||
++ call
|
||||
|= [=duct type=* wrapped-task=(hobo task:able)]
|
||||
@ -6109,6 +6100,9 @@
|
||||
?. ?=(%soft -.wrapped-task)
|
||||
wrapped-task
|
||||
((hard task:able) p.wrapped-task)
|
||||
:: we wrap +per-event with a call that binds our event args
|
||||
::
|
||||
=* this-event (per-event [our duct now scry-gate] state.ax)
|
||||
::
|
||||
?- -.task
|
||||
:: %build: request to perform a build
|
||||
@ -6116,19 +6110,13 @@
|
||||
%build
|
||||
:: perform the build indicated by :task
|
||||
::
|
||||
:: First, we find or create the :ship-state for :our.task,
|
||||
:: modifying :state-by-ship as necessary. Then we dispatch to the |ev
|
||||
:: by constructing :event-args and using them to create :start-build,
|
||||
:: which performs the build. The result of :start-build is a pair of
|
||||
:: :moves and a mutant :ship-state. We update our :state-by-ship map
|
||||
:: with the new :ship-state and produce it along with :moves.
|
||||
:: First, we dispatch to the |ev by constructing :event-args and
|
||||
:: using them to create :start-build, which performs the build.
|
||||
:: The result of :start-build is a pair of :moves and a mutant :state.
|
||||
:: We update our :state and produce it along with :moves.
|
||||
::
|
||||
=^ ship-state state-by-ship.ax (find-or-create-ship-state our.task)
|
||||
=/ =build [now schematic.task]
|
||||
=* event-args [[our.task duct now scry-gate] ship-state]
|
||||
=* start-build start-build:(per-event event-args)
|
||||
=^ moves ship-state (start-build build live.task)
|
||||
=. state-by-ship.ax (~(put by state-by-ship.ax) our.task ship-state)
|
||||
=^ moves state.ax (start-build:this-event build live.task)
|
||||
::
|
||||
[moves ford-gate]
|
||||
::
|
||||
@ -6136,21 +6124,7 @@
|
||||
::
|
||||
%keep
|
||||
::
|
||||
=/ ship-states=(list [ship=@p state=ford-state])
|
||||
~(tap by state-by-ship.ax)
|
||||
::
|
||||
=. state-by-ship.ax
|
||||
|- ^+ state-by-ship.ax
|
||||
?~ ship-states state-by-ship.ax
|
||||
::
|
||||
=, i.ship-states
|
||||
=* event-args [[ship duct now scry-gate] state]
|
||||
::
|
||||
=. state-by-ship.ax
|
||||
%+ ~(put by state-by-ship.ax) ship
|
||||
(keep:(per-event event-args) [compiler-cache build-cache]:task)
|
||||
::
|
||||
$(ship-states t.ship-states)
|
||||
=. state.ax (keep:this-event [compiler-cache build-cache]:task)
|
||||
::
|
||||
[~ ford-gate]
|
||||
::
|
||||
@ -6158,10 +6132,7 @@
|
||||
::
|
||||
%kill
|
||||
::
|
||||
=/ ship-state ~|(our+our.task (~(got by state-by-ship.ax) our.task))
|
||||
=* event-args [[our.task duct now scry-gate] ship-state]
|
||||
=^ moves ship-state cancel:(per-event event-args)
|
||||
=. state-by-ship.ax (~(put by state-by-ship.ax) our.task ship-state)
|
||||
=^ moves state.ax cancel:this-event
|
||||
::
|
||||
[moves ford-gate]
|
||||
::
|
||||
@ -6175,21 +6146,7 @@
|
||||
::
|
||||
%wipe
|
||||
::
|
||||
=/ ship-states=(list [ship=@p state=ford-state])
|
||||
~(tap by state-by-ship.ax)
|
||||
::
|
||||
=. state-by-ship.ax
|
||||
|- ^+ state-by-ship.ax
|
||||
?~ ship-states state-by-ship.ax
|
||||
::
|
||||
=, i.ship-states
|
||||
=* event-args [[ship duct now scry-gate] state]
|
||||
::
|
||||
=. state-by-ship.ax
|
||||
%+ ~(put by state-by-ship.ax) ship
|
||||
(wipe:(per-event event-args) percent-to-remove.task)
|
||||
::
|
||||
$(ship-states t.ship-states)
|
||||
=. state.ax (wipe:this-event percent-to-remove.task)
|
||||
::
|
||||
[~ ford-gate]
|
||||
::
|
||||
@ -6200,13 +6157,12 @@
|
||||
^- mass
|
||||
:- %ford
|
||||
:- %|
|
||||
%+ turn ~(tap by state-by-ship.ax) :: XX single-home
|
||||
|= [our=@ ford-state] ^- mass
|
||||
:+ (scot %p our) %|
|
||||
::
|
||||
:~ [%builds [%& builds]]
|
||||
[%compiler-cache [%& compiler-cache]]
|
||||
==
|
||||
:~ ^- mass
|
||||
:+ (scot %p our) %|
|
||||
::
|
||||
:~ [%builds [%& builds.state.ax]]
|
||||
[%compiler-cache [%& compiler-cache.state.ax]]
|
||||
== ==
|
||||
==
|
||||
:: +take: receive a response from another vane
|
||||
::
|
||||
@ -6225,9 +6181,6 @@
|
||||
:: If Ford receives this, it will continue building one or more builds
|
||||
:: that were blocked on this resource.
|
||||
::
|
||||
:: The general procedure is for Ford to determine the `our` identity
|
||||
:: for this +task and operate on the :ship-state for that identity.
|
||||
::
|
||||
:: The +sign gets converted into operations to be performed inside
|
||||
:: the +per-event core, which is Ford's main build engine.
|
||||
::
|
||||
@ -6240,27 +6193,15 @@
|
||||
:: :wire must at least contain :our and a tag for dispatching
|
||||
::
|
||||
?> ?=([@ @ *] wire)
|
||||
:: :parse our from the head of :wire
|
||||
::
|
||||
=/ our=@p (slav %p i.wire)
|
||||
::
|
||||
::
|
||||
=/ ship-state
|
||||
:: we know :our is already in :state-by-ship because we sent this request
|
||||
::
|
||||
~| [%take-our our]
|
||||
(~(got by state-by-ship.ax) our)
|
||||
::
|
||||
|^ ^- [(list move) _ford-gate]
|
||||
::
|
||||
=^ moves ship-state
|
||||
=^ moves state.ax
|
||||
?+ i.t.wire ~|([%bad-take-wire wire] !!)
|
||||
%clay-sub take-rebuilds
|
||||
%scry-request take-unblocks
|
||||
==
|
||||
::
|
||||
=. state-by-ship.ax (~(put by state-by-ship.ax) our ship-state)
|
||||
::
|
||||
[moves ford-gate]
|
||||
:: +take-rebuilds: rebuild all live builds affected by the Clay changes
|
||||
::
|
||||
@ -6273,7 +6214,7 @@
|
||||
::
|
||||
=/ =subscription
|
||||
~| [%ford-take-bad-clay-sub wire=wire duct=duct]
|
||||
=/ =duct-status (~(got by ducts.ship-state) duct)
|
||||
=/ =duct-status (~(got by ducts.state.ax) duct)
|
||||
?> ?=(%live -.live.duct-status)
|
||||
?> ?=(^ last-sent.live.duct-status)
|
||||
?> ?=(^ subscription.u.last-sent.live.duct-status)
|
||||
@ -6281,15 +6222,15 @@
|
||||
::
|
||||
=/ ducts=(list ^duct)
|
||||
~| [%ford-take-missing-subscription subscription]
|
||||
(get-request-ducts pending-subscriptions.ship-state subscription)
|
||||
(get-request-ducts pending-subscriptions.state.ax subscription)
|
||||
::
|
||||
=| moves=(list move)
|
||||
|- ^+ [moves ship-state]
|
||||
?~ ducts [moves ship-state]
|
||||
|- ^+ [moves state.ax]
|
||||
?~ ducts [moves state.ax]
|
||||
::
|
||||
=* event-args [[our i.ducts now scry-gate] ship-state]
|
||||
=* event-args [[our i.ducts now scry-gate] state.ax]
|
||||
=* rebuild rebuild:(per-event event-args)
|
||||
=^ duct-moves ship-state
|
||||
=^ duct-moves state.ax
|
||||
(rebuild subscription p.case.sign disc care-paths.sign)
|
||||
::
|
||||
$(ducts t.ducts, moves (weld moves duct-moves))
|
||||
@ -6315,17 +6256,17 @@
|
||||
::
|
||||
=/ ducts=(list ^duct)
|
||||
~| [%ford-take-missing-scry-request scry-request]
|
||||
(get-request-ducts pending-scrys.ship-state scry-request)
|
||||
(get-request-ducts pending-scrys.state.ax scry-request)
|
||||
::
|
||||
=| moves=(list move)
|
||||
|- ^+ [moves ship-state]
|
||||
?~ ducts [moves ship-state]
|
||||
|- ^+ [moves state.ax]
|
||||
?~ ducts [moves state.ax]
|
||||
::
|
||||
=* event-args [[our i.ducts now scry-gate] ship-state]
|
||||
=* event-args [[our i.ducts now scry-gate] state.ax]
|
||||
:: unblock the builds that had blocked on :resource
|
||||
::
|
||||
=* unblock unblock:(per-event event-args)
|
||||
=^ duct-moves ship-state (unblock scry-request scry-result)
|
||||
=^ duct-moves state.ax (unblock scry-request scry-result)
|
||||
::
|
||||
$(ducts t.ducts, moves (weld moves duct-moves))
|
||||
--
|
||||
@ -6350,18 +6291,4 @@
|
||||
::+|
|
||||
::
|
||||
++ ford-gate ..$
|
||||
:: +find-or-create-ship-state: find or create a ford-state for a @p
|
||||
::
|
||||
:: Accesses and modifies :state-by-ship.
|
||||
::
|
||||
++ find-or-create-ship-state
|
||||
|= our=@p
|
||||
^- [ford-state _state-by-ship.ax]
|
||||
::
|
||||
=/ existing (~(get by state-by-ship.ax) our)
|
||||
?^ existing
|
||||
[u.existing state-by-ship.ax]
|
||||
::
|
||||
=| new-state=ford-state
|
||||
[new-state (~(put by state-by-ship.ax) our new-state)]
|
||||
--
|
||||
|
@ -7261,7 +7261,7 @@
|
||||
==
|
||||
^- [tang _ford-gate]
|
||||
::
|
||||
=/ ford (ford-gate our=~zod now=now eny=`@`0xdead.beef scry=scry)
|
||||
=/ ford (ford-gate our=~nul now=now eny=`@`0xdead.beef scry=scry)
|
||||
::
|
||||
=^ moves ford-gate
|
||||
%- call:ford call-args
|
||||
@ -7282,7 +7282,7 @@
|
||||
==
|
||||
^- [tang _ford-gate]
|
||||
::
|
||||
=/ ford (ford-gate our=~zod now=now eny=`@`0xdead.beef scry=scry)
|
||||
=/ ford (ford-gate our=~nul now=now eny=`@`0xdead.beef scry=scry)
|
||||
::
|
||||
=^ moves ford-gate
|
||||
%- take:ford take-args
|
||||
@ -7307,7 +7307,7 @@
|
||||
==
|
||||
^- [tang _ford-gate]
|
||||
::
|
||||
=/ ford (ford-gate our=~zod now=now eny=`@`0xdead.beef scry=scry)
|
||||
=/ ford (ford-gate our=~nul now=now eny=`@`0xdead.beef scry=scry)
|
||||
::
|
||||
=^ moves ford-gate
|
||||
%- call:ford call-args
|
||||
@ -7326,7 +7326,7 @@
|
||||
==
|
||||
^- [tang _ford-gate]
|
||||
::
|
||||
=/ ford (ford-gate our=~zod now=now eny=`@`0xdead.beef scry=scry)
|
||||
=/ ford (ford-gate our=~nul now=now eny=`@`0xdead.beef scry=scry)
|
||||
::
|
||||
=^ moves ford-gate
|
||||
%- take:ford take-args
|
||||
@ -7363,7 +7363,7 @@
|
||||
==
|
||||
::
|
||||
=/ ford *ford-gate
|
||||
=/ state (~(got by state-by-ship.ax.+>+<.ford) ship)
|
||||
=/ state state.ax.+>+<.ford
|
||||
::
|
||||
=/ default-state *ford-state:ford
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user