Skip to content

Instantly share code, notes, and snippets.

@belisarius222
Last active February 18, 2018 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save belisarius222/ec7637180b29589cf50079298ab288db to your computer and use it in GitHub Desktop.
Save belisarius222/ec7637180b29589cf50079298ab288db to your computer and use it in GitHub Desktop.
future Ford design

Ford rebuild algorithm

Steps

  1. Ford receives a ++sign from Clay containing the ++care of new revisions of some files we subscribed to on a ++path.
  2. Ford does a bi-jug lookup of the changed dependencies in its state's deps, which will return a set of ++build-indices whose builds they refer to may need to get rebuilt.
  3. For each of those build indices, Ford calls ++build-up.
  4. For each root build that comlpleted during this event, grab the keys of its jug from disk to dependency in dependencies.live, and unify those into one set of disks representing the set of disks that we'll need to make Clay requests on. For each disk, look up all of the root builds that depend on that disk in root-builds.live, and unify those into one set of root builds that depend on any of the disks. Then, create one Clay request for each disk. To do this, for each disk, for each root build, look up the dependecies of the root build that are on this disk in dependencies.live. From those dependencies, we can create a set of [care path]s, which forms part of the
    Clay request. The beak in the Clay request is built from the disk and the time of the Clay file change, which we obtain from the time of any of the root builds that completed during this event (they should all be the same time).

++build-up

  1. Ford looks up the ++silk of the old build (looked up by ++build-index) and runs the new build against the updated beak (the new revision that Clay gave us).
  2. In the case that the build blocks, store the build in builds-in-progress.live in Ford's state, then return.
  3. If the build completes, add its build index to the set of completed builds, which we will produce at the end of this function.
  4. Once we have the new build result, we check that build result (some actual noun) against the old build result. If they're the same, return.
  5. Add this build index to the builds-done.live in Ford's state.
  6. For each listener for live updates of the old build, enqueue a %made response on that duct to be sent out at the end of this event.
  7. For each external dependency of this new build, add the mapping from the dependency to the new build index in the dependencies.live of Ford's state. For each sub-build of the new build, add that sub-build's external dependencies to the new build's dependencies in dependencies.live.
  8. For each build that depended on the old build, recurse and run Step 4 on that build, then take the new parent build and link it with its child in the build graph. Unify the sets of completed builds from each parent with our set of completed builds.
  9. Remove the old build. This means removing it from every piece of the state. Notably, this removes the old build from the dependencies.live field, which
    is necessary for making the next Clay request.

++build-down

  1. ++build-down starts with a ++bilk. First we look up if there's already a build for the silk of the given beak. If so, we try to run that build as far as we can. Otherwise, we create a new ++build.
  2. Now we actually have a build that we're running. If the build's status is %done, produce the result, and we're done.
  3. If the build's status is %blocked,
  4. If the build's status is %not-started, ^ TODO Finish this.
|%
+= axle
$: %~2018.2.15
(map ship ford-state) :: can we remove keying on ship yet?
==
+= ford-state
$: next-build-id=build-id
builds-by-id=(map build-id (each build [@da build-id]))
builds-by-schematic=(map schematic (list (pair @da build-id))) :: newest first
components=(bi-jug build-id build-id) :: sub-builds, client builds
promotions=(jug build-id build-id) :: (jug old new)
blocks=(jug dependency build-id)
listeners=(jug build-id [duct liv=?])
leaf-builds=(jug dependency build-id)
root-builds=(jug disk build-id)
dependencies=(map build-id (jug disk dependency))
dependency-updates=(jug @da dependency)
==
+= build-id @ud
++ bi-jug |*([a=mold b=mold] (pair (jug a b) (jug b a)))
+= build
$: plan=schematic
time=@da
result=(unit build-result)
==
+= build-result
%+ each :: XX also gage?
$% [%hood hood]
[%boil vase]
[%load vase]
[%path path] :: XX beam?
[%slit type]
[%slim (pair type nock)]
[%slap (pair vase vase)]
[%scry vase]
==
tang
+= dependency
$% [%clay-dynamic ren=care:clay bel=beal]
[%clay-static ren=care:clay bem=beam]
[%gall-dynamic ren=care:clay bel=beal] :: not yet supported
[%gall-static ren=care:clay bem=beam] :: needed for +twit and others
==
::
:: in zuse
::
+= task:able:ford
$% [%exec plan=schematic time=(unit @da)] :: r=~ for live
[%kill ~]
[%wegh ~]
[%wipe ~]
==
+= gift:able:ford
$% [%made p=@da q=gage] :: p is date at which build was evaluated
[%mass p=mass]
==
+= gage
$^ [p=gage q=gage]
$% [%& p=cage]
[%| p=tang]
::
+= disk (pair ship desk)
+= beal (pair disk path) :: beam with no case
+= bead (each beam beal) :: possibly pinned beal
+= bisk (each beak disk) :: possibly pinned disk
+= bark (pair bisk mark)
+= dilk (pair disk schematic)
++ schematic :: construction layer
$^ {p/schematic q/schematic} :: cons
$% {$$ p/cage} :: literal
{$alts p/(list schematic)} :: options
{$bake p/mark q/coin r/bead} :: local synthesis
{$bunt p/bark} :: example of mark
{$call p/schematic q/schematic} :: slam
{$cast p/bark q/schematic} :: translate
{$core p/bead} :: build program
{$diff p/bisk q/schematic r/schematic} :: diff
{$dude p/(trap tank) q/schematic} :: error wrap
{$file p/bead} :: from clay
{$flag p/(set $@(@uvH bead)) q/schematic} :: add dependencies
{$join p/bark q/schematic r/schematic} :: merge
{$mash p/bark q/dilk r/dilk} :: annotate
{$mute p/schematic q/(list (pair wing schematic))} :: mutant
{$pact p/bisk q/schematic r/schematic} :: patch
{$plan p/bead q/coin r/hood} :: structured assembly
{$reef $~} :: kernel reef
{$ride p/hoon q/schematic} :: schematic thru hoon
{$tabl p/(list (pair schematic schematic))} :: list
{$vale p/bisk q/mark r/*} :: validate
{$volt p/bisk q/(cask *)} :: unsafe add type
==
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment