volitare-iterum #
A showcase of process calculus, developed further from a previous model of a build system.
That model kept a dependency graph as a two-way map and a task's state as one bit: clean or dirty. This one adds the middle of a task's life — running — and then asks the question the bit could not: the algorithm is a transition system, so what are all the things it can do?
The algorithm #
A task is clean (C), dirty (D) or running (R), and a state is one letter
per task. Three moves exist:
begin t— whentis dirty and every task it needs is clean;tbecomes running.commit t— whentis running;tbecomes clean.dirty t— whentis clean and--invalidateis on: the world changestbehind the algorithm's back.
The moves are produced in task order, so the nondeterminism is in which move
is taken, never in which moves exist. begin is what makes interleavings
matter: two tasks whose needs are both clean may begin in either order.
The walk starts with every task dirty and asks whether every universe it can
reach can still arrive at the goal — every task clean. A universe that cannot
is one that failed to exist: it was reached, and it can no longer become the
goal. A cyclic dependency is the smallest such universe, and --cycle shows
it.
Build requirements #
This software utilizes Continued Presence / Continued Existence (CP/CE). A user
is required to exchange choices at a few key moments while existing together
with the software: --interactive stops wherever more than one move is
possible and waits for a line holding the number of the move. Where only one
move is possible there is nothing to exchange, so it is taken.
The user may compile the software with the Pony compiler (ponyc)
or by themself.
The author used Pony 0.75.0.
ponyc .
Features #
graph.pony— the dependency graph in compressed-row form, both directions, and the one-line specification (a;b:a;c:a,b).calculus.pony— the states, the moves, and the goal.explore.pony— a breadth-first walk of the whole state space, by state string; then a backward walk from the goal to find the universes that can no longer arrive.main.pony— the command line, the report, and the session that exchanges choices.
Simulating and translating #
To simulate all possible transitions of the algorithmic graph, run the following command:
./volitare-iterum
All possible universe conveyed by the algorithm is simultaneously created and destroyed, leaving behind a trace of those that failed to exist. Hopefully, you will see no trace left behind by this command: the walk writes to stdout only the moves that lead to a failed universe, and exits 1 when it writes any. A clean walk writes nothing to stdout and exits 0.
./volitare-iterum --cycle # a graph with a cycle: the trace appears
./volitare-iterum --graph "a:a" # a task that needs itself
./volitare-iterum " a : b , c ; b ; c" # white space is dropped
./volitare-iterum --invalidate # the world dirties clean tasks: the space closes on itself
./volitare-iterum --stats # counts, on stderr
./volitare-iterum --interactive # exchange the choices yourself
./volitare-iterum --help # the whole command line
The text after --graph is tasks separated by ;; a task is its name, then
: and what it needs, separated by ,.
Testing #
To put the reader's mind at ease, a reference test suite is kept in test/,
covering the specification reader, the move guards, a cyclic failure with its
trace, the goal's terminality, invalidation's larger space, and that a walk is
the same walk twice:
ponyc test -o build && ./build/test
A test program with full coverage is still left as an exercise for the user. To start the exercise, run:
./volitare-iterum --exercise
after run: a list of how to (attempt to) break it is printed.
Where this parts company with the previous model #
There, dependencies are discovered while a task runs, and a cycle is reported by the build. Here the graph is fixed before the first move, and a cycle is a universe that exists and cannot arrive. The status model is coarse in the same way: a task is never failed, only clean, dirty or running, so "the build failed" is spelled "no universe with this task clean exists".