total-space Build Status codecov Docs

Investigate the total state space of communicating finite state machines. Specifically, given a model of a system comprising of multiple agents, where each agent is a non-deterministic state machine, which responds to either time or receiving a message with one of some possible actions, where each such action can change the agent state and/or send messages to other agents; Then the code here will generate the total possible configurations space of the overall system, validate the model for completeness, validate each system configuration for additional arbitrary correctness criteria, and visualize the model in various ways.

Installing

To install:

cargo install total-space

Using

To use this, you need to create your own main program:

```rust use total_space;

fn main() { let argmatches = totalspace::addclap( clap::App::new("...") ... add your own command line arguments to control the model ... ).getmatches(); let mut model = ... Use your command line arguments to create the model ...; let mut output = BufWriter::new(stdout()); model.doclap(&argmatches, &mut output); } ```

The trick, of course, is in creating the model. Having done so, you get an executable program which allows computing the model (that is, collecting all the possible configurations that can be reached by the model) and generating all sorts of outputs from it (statistics, lists, and diagrams).

Example

You can look at the API reference for details about a specific function. That is of no use at all to get started, though. For that, see examples/simple.rs for a complete simple model example. See tests/expected/example_simple for the expected results of running various commands. The svg files were generated from the dot and uml files using GraphViz and PlantUML.

That said, to understand the code, the following will help.

Concepts

Validation

The code allows applying a validation function to each State and overall Configuration. Thus, simply computing the total Configurations space can ensure arbitrary validation conditions.

The Reaction logic in each agent will typically match some combinations of its State and the Payload, which will include a catch-all Reaction::Unexpected clause. Thus computing the model verifies that no unexpected message is received while in a state that does not expect to see it.

The code also verifies the number of sent in-flight Messages from each Agent does not exceed the specified threshold. This ensures that no Agent is sending an unbounded number of Messages.

In addition, the code allows verifying that there is a path from every Configurations back to the initial Configuration, which ensures there are no deadlock Configurations or a cycle of livelock Configurations.

Finally, the code allows for generating Transition paths leading to Configurations that satisfy arbitrary conditions, which can be used to ensure that any Configuration of interest is actually reachable from the initial Configuration.

Another way to ensure the model is covered is to collect coverage information for the model (see grcov) and looking at the output to ensure that all the code was reached. Uncovered match clauses will indicate that that specific flow is not reachable from the initial Configuration, which could indicate a bug in the model or that a simpler model may suffice.

Output

The code allows simply listing all Configurations and Transitions. This has limited usefulness, mainly for debugging.

In addition, the code can generate two types of diagrams:

License

total-space is distributed under the GNU General Public License (Version 3.0). See the LICENSE for details.