Skip to content

Instantly share code, notes, and snippets.

@belisarius222
Last active March 13, 2018 00:01
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/0274e88da36c2408151492c5e2995d4b to your computer and use it in GitHub Desktop.
Save belisarius222/0274e88da36c2408151492c5e2995d4b to your computer and use it in GitHub Desktop.
ford data structures
::
:: sys/ford/hoon
::
|%
::
:: +axle: overall ford state
::
+= axle
$: :: date: date at which ford's state was updated to this data structure
::
date=%~2018.3.8
:: state-by-ship: storage for all the @p's this ford has been
::
:: 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 and then
:: becoming its adult identity.
::
state-by-ship=(map ship ford-state)
==
:: +ford-state: all state that ford maintains for a @p ship identity
::
+= ford-state
$: :: results: all stored build results
::
:: Ford generally stores the result for all the most recently
:: completed live builds, unless it's been asked to wipe its cache.
::
results=(map build cache-line)
:: builds-by-schematic: all attempted builds, sorted by time
::
:: For each schematic we've attempted to build at any time,
:: list the formal dates of all build attempts, sorted newest first.
::
builds-by-schematic=(map schematic (list @da))
:: builds-by-date: all attempted builds, grouped by time
::
builds-by-date=(map @da (set schematic))
:: components: bidirectional linkages between sub-builds and clients
::
:: The first of the two jugs links from a build to its sub-builds.
:: The second of the two jugs links from a build to its client builds.
::
components=(bi-jug sub-build=build client=build)
:: blocks: map from +dependency to all builds waiting for its retrieval
::
blocks=(jug dependency build)
::
:: build request tracking
::
:: listeners: external requests for a build, both live (:live=&) and once
::
listeners=(jug build [listener=duct live=?])
:: builds-by-listener: reverse lookup for :listeners; find build by duct
::
builds-by-listener=(map duct build)
::
:: update tracking
::
:: live-leaf-builds: which live builds depend on a live +dependency
::
live-leaf-builds=(jug dependency build)
:: live-root-builds: which live builds depend on any files in a +disc
::
live-root-builds=(jug disc build)
:: dependencies: dependencies of a live build
::
dependencies=(map build (jug disc dependency))
:: dependency-updates: all clay updates we need to know about
::
:: dependency-updates stores all Clay changes at dates that
:: Ford needs to track because Ford is tracking attempted builds with
:: that formal date. The changed dependencies are grouped first by
:: date, then within a single date, they're grouped by +disc.
::
dependency-updates=(map @da (jug disc dependency))
==
:: +build: a referentially transparent request for a build.
::
:: Each unique +build will always produce the same +build-result
:: when run (if it completes). A live build consists of a sequence of
:: instances of +build with the same :plan and increasing :date.
::
+= build
$: :: date: the formal date of this build; unrelated to time of execution
::
date=@da
:: plan: the schematic that determines how to run this build
::
plan=schematic
==
:: +cache-line: a record of our result of running a +build
::
:: Proof that a build has been run. Might include the result if Ford is
:: caching it. If Ford wiped the result from its cache, the result will
:: be replaced with a tombstone so Ford still knows the build has been
:: run before. Otherwise, contains the last accessed time of the result,
:: for use in cache reclamation.
::
+= cache-line
$% :: %result: the result of running a +build, and its last access time
::
$: %result
:: last-accessed: the last time this result was accessed
::
:: Updated every time this result is used in another build or
:: requested in a build request.
last-accessed=@da
:: result: the referentially transparent result of a +build
::
result=build-result
==
:: %tombstone: marker that this build has been run and its result wiped
::
[%tombstone ~]
==
:: +build-result: the referentially transparent result of a +build
::
:: If the input +schematic was an auto-cons pair, then its result will be an
:: auto-cons +build-result. Otherwise, the result is either an error or a
:: tagged union of the various kinds of datatypes a build can produce.
::
+= build-result
:: ^: the result is an auto-cons pair of build-result's
::
$^ [head=build-result tail=build-result]
$% :: %error: the build produced an error whose description is :message
::
[%error message=tang]
:: %result: the build succeeded; its result is a tagged union
::
$: %result
$% [%alts build-result]
[%bake cage]
[%bunt cage]
[%call vase]
[%cast cage]
[%core vase]
[%dude build-result]
[%file cage]
[%hood hood]
[%path (pair disc spur)]
[%plan vase]
[%reef vase]
[%ride vase]
[%slit type]
[%slim (pair type nock)]
[%scry cage]
[%vale cage]
[%volt cage]
[%diff cage]
[%join cage]
[%mash cage]
[%mute cage]
[%pact cage]
== == ==
:: +bi-jug: bi-directional jug
::
:: A pair of jugs. The first jug maps from :a to :b; the second maps
:: backward from :b to :a. Both jugs must be kept in sync with each other to
:: be a valid bi-jug. If :a and :b are the same, it can be used to represent
:: arbitrary DAGs traversable in approximately log time in either direction.
::
++ bi-jug
|* $: :: a: key type for forward mapping; value type for backward mapping
::
a=mold
:: b: value type for forward mapping: key type for backward mapping
::
b=mold
==
(pair (jug a b) (jug b a)))
:: +dependency: dependency on a value from the urbit namespace
::
+= dependency
$% :: live dependency on a clay path; varies with time
::
[%clay-live ren=care:clay bel=(pair disc spur)]
:: once dependency on a clay path; pinned time
::
[%clay-once ren=care:clay bem=beam]
:: live dependency on a gall path; varies with time
::
[%gall-live ren=care:clay bel=(pair disc spur)]
:: once dependency on a gall path; pinned time
::
[%gall-once ren=care:clay bem=beam]
==
--
::
:: sys/zuse/hoon
::
:: |ford: build system vane interface
::
++ ford ^?
|%
:: |able:ford: ford's public +move interface
::
++ able ^?
|%
:: +task:able:ford: requests to ford
::
+= task
$% :: %make: perform a build, either live or once
::
$: %make
:: plan: the schematic to build
::
plan=schematic
:: date: the formal date of the build, or ~ for live
::
date=(unit @da)
==
:: %kill: stop a build; send on same duct as original %make request
::
[%kill ~]
:: %wegh: produce memory usage information
::
[%wegh ~]
:: %wipe: clear cache
::
[%wipe ~]
==
:: +gift:able:ford: responses from ford
::
+= gift
$% :: %mass: memory usage; response to %wegh +task
::
[%mass p=mass]
:: %made: build result; response to %make +task
::
$: %made
:: date: formal date of the build
::
date=@da
:: result: result of the build; either complete build, or error
::
$= result
$% :: %complete: contains the result of the completed build
::
[%complete build-result]
:: %incomplete: couldn't finish build; contains error message
::
[%incomplete tang]
== == ==
--
:: +disc: a desk on a ship; can be used as a beak that varies with time
::
+= disc (pair ship desk)
:: +view: a possibly time-varying view of a +disc
::
:: Either it contains a +case, which means it's pinned to a time,
:: or the (unit case) is ~, meaning the time can vary.
::
+= view (trel ship desk (unit case))
:: +rail: a possibly time-varying full path
::
:: Either its +view contains a +case, which means it's pinned to a time
:: (in which case it's equivalent to a +beam), or the (unit case) is ~,
:: meaning the time can vary.
::
+= rail (pair view spur)
::
:: +schematic: plan for building
::
++ schematic
:: If the head of the +schematic is a pair, it's an auto-cons
:: schematic. Its result will be the pair of results of its
:: sub-schematics.
::
$^ [head=schematic tail=schematic]
::
$% :: %$: literal value. Produces its input unchanged.
::
$: %$
:: literal: the value to be produced by the build
::
literal=cage
==
:: %alts: alternative build choices
::
:: Try each choice in :choices, in order; accept the first one that
:: succeeds. Note that the result inherits the dependencies of all
:: failed schematics, as well as the successful one.
::
$: %alts
:: choices: list of build options to try
::
choices=(list schematic)
==
:: %bake: run a file through a renderer
::
$: %bake
:: renderer: name of renderer; also its file path in ren/
::
renderer=term
:: query-string: the query string of the renderer's http path
::
query-string=coin
:: path-to-render: full path of file to render
::
path-to-render=rail
==
:: %bunt: produce the default value for a mark
::
$: %bunt
:: location: where in clay to load the mark from
::
location=view
:: mark: name of mark; also its file path in mar/
::
mark=term
==
:: %call: call a gate on a sample
::
$: %call
:: gate: schematic whose result is a gate
::
gate=schematic
:: sample: schematic whose result will be the gate's sample
::
sample=schematic
==
:: %cast: cast the result of a schematic through a mark
::
$: %cast
:: location: where in clay to load the mark from
::
location=view
:: mark: name of mark; also its file path in ren/
::
mark=term
:: input: schematic whose result will be run through the mark
::
input=schematic
==
:: %core: build a hoon program from a source file
::
$: %core
:: source-path: clay path from which to load hoon source
::
source-path=rail
==
:: %dude: wrap a failure's error message with an extra message
::
$: %dude
:: error: a trap producing an error message to wrap the original
::
error=(trap tank)
:: attempt: the schematic to try, whose error we wrap, if any
::
attempt=schematic
==
:: %file: load a file from clay
::
$: %file
:: location: the file's clay path
::
location=rail
==
:: %hood: create a +hood from a hoon source file
::
$: %hood
:: source-path: clay path from which to load hoon source
::
source-path=rail
==
:: %path: resolve a path with `-`s to a path with `/`s
::
:: Resolve +file-path to a path containing a file, replacing
:: any `-`s in the path with `/`s if no file exists at the
:: original path. Produces an error if multiple files match,
:: e.g. a/b/c and a/b-c, or a/b/c and a-b/c.
::
:: TODO verify current implementation
::
$: %path
:: location: the +disc within which to resolve :file-path
::
location=disc
:: file-path: the path to resolve
::
file-path=@tas
==
:: %plan: build a hoon program from a preprocessed source file
::
$: %plan
:: source-path: the clay path of the hoon source file
::
source-path=rail
:: query-string: the query string of the http request
::
query-string=coin
:: assembly: preprocessed hoon source and imports
::
assembly=hood
==
:: %reef: produce a hoon+zuse kernel. used internally for caching
::
[%reef ~]
:: %ride: eval hoon as formula with result of a schematic as subject
::
$: %ride
:: formula: a hoon to be evaluated against a subject
::
formula=hoon
:: subject: a schematic whose result will be used as subject
::
subject=schematic
==
:: %scry: lookup a value from the urbit namespace
::
$: %scry
:: request: the request to be made against the namespace
::
request=dependency
==
:: %slim: compile a hoon against a subject type
::
$: %slim
:: compile-time subject type for the :formula
::
subject-type=type
:: formula: a +hoon to be compiled to (pair type nock)
::
formula=hoon
==
:: %slit: get type of gate product
::
$: %slit
:: gate: a vase containing a gate
::
gate=vase
:: sample: a vase containing the :gate's sample
::
sample=vase
==
:: %vale: coerce a noun to a mark, validated
::
$: %vale
:: location: where in clay to load the mark from
::
location=view
:: mark: name of mark to use; also file path in mar/
::
mark=term
:: input: the noun to be converted using the mark
::
input=*
==
:: %volt: coerce a noun to a mark, unsafe
::
$: %volt
:: location: where in clay to load the mark from
::
location=view
:: mark: name of mark to use; also file path in mar/
::
mark=term
:: input: the noun to be converted using the mark
::
input=*
==
:: %diff: produce marked diff from :first to :second
::
$: %diff
:: location: where in clay to load the mark from
::
location=view
:: old: schematic producing data to be used as diff starting point
::
start=schematic
:: new: schematic producing data to be used as diff ending point
::
end=schematic
==
:: %join: merge two diffs into one diff; produces `~` if conflicts
::
$: %join
:: location: where in clay to load the mark from
::
location=view
:: mark: name of the mark to use for diffs; also file path in mar/
::
mark=term
:: first: schematic producing first diff
::
first=schematic
:: second: schematic producing second diff
::
second=schematic
==
:: %mash: force a merge, annotating any conflicts
::
$: %mash
:: location: where in clay to load the mark from
::
location=view
:: mark: name of mark used in diffs; also file path in mar/
::
mark=term
:: first: schematic producing first diff
::
first=schematic
:: second: schematic producing second diff
::
second=schematic
==
:: %mute: mutate a noun by replacing its wings with new values
::
$: %mute
:: subject: schematic producing the noun to mutate
::
subject=schematic
:: mutations: axes and schematics to produce their new contents
::
mutations=(list (pair wing schematic))
==
:: %pact: patch a marked noun by applying a diff
::
$: %pact
:: location: where in clay to load the mark from
::
location=view
:: mark: name of mark to use in diff; also file path in mar/
::
mark=term
:: start: schematic producing a noun to be patched
::
start=schematic
:: diff: schematic producing the diff to apply to :start
::
diff=schematic
==
==
--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment