Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve usability of machine-runner API #5

Closed
rkuhn opened this issue Mar 3, 2023 · 1 comment
Closed

improve usability of machine-runner API #5

rkuhn opened this issue Mar 3, 2023 · 1 comment

Comments

@rkuhn
Copy link
Member

rkuhn commented Mar 3, 2023

The purpose of the machine-runner library is twofold: it should provide a safe and intuitive API for writing, running, and inspecting state machines, and it should allow static analysis of a set of such state machines plus a swarm protocol to ensure protocol correctness and adherence.

For the first aspect we need the following:

  • type-safe construction of the initial state (for production code) as well as all other states (for unit tests)
  • type-safe inspection of an unknown runtime state (“downcasting” and access to properties), e.g. in a UI or a node.js application
  • type-safe invocation of commands if the runtime state is of a particular name
  • type-safe formulation of events emitted from commands and events consumed in handlers as per the overall protocol
  • a generic handler function to be invoked upon reception of an unexpected event

For the second aspect we need the following:

  • identification of initial state
  • enumerate all commands including their name, argument type list, and resulting event list
  • enumerate all event handlers including argument type list and name of the resulting state

These can be captured during unit tests (i.e. by reifying states, events, handler, and commands as objects) or analysed using TypeScript as a library; in either case, the captured machine specification needs to be formatted in JSON and passed to an external type-checking program for swarm protocols (currently implemented in Haskell).

@rkuhn
Copy link
Member Author

rkuhn commented Apr 5, 2023

moved discarded event handler to #25

The rest is fixed by #7.

@rkuhn rkuhn closed this as completed Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant