Skip to content

[fm-sim] add the basic simulator skeleton: a clock and a bunch of plumbing. - #11720

Open
mergeconflict wants to merge 1 commit into
mainfrom
mergeconflict/fm-sim-skeleton
Open

mergeconflict wants to merge 1 commit into
mainfrom
mergeconflict/fm-sim-skeleton

Conversation

@mergeconflict

@mergeconflict mergeconflict commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

This PR is the first of many, inshallah, implementing a simulated environment for fault management. It doesn't really do much on its own, but it establishes a whole bunch of scaffolding across two crates that the rest of the sim's functionality will eventually fit into.

nexus-fm-simulation: the "core" functionality, which currently includes:

  • struct SimState: the state of the simulated environment, which currently only contains a time field. Instances are immutable snapshots.
  • struct SimStateBuilder: allows basic functional mutation of states.
  • mod time: operations on the simulated clock in SimState.

fm-sim: the simulator CLI lib/bin crates, which is mostly the clap command vocabulary and REPL logic. The main things here:

  • struct Simulator: contains a current state, and a run function that parses and dispatches clap commands to do stuff with that state.
  • trait Query, trait Mutate, enum Verb<Q: Query, M: Mutate>: a bit of plumbing that lets us bind groups of related clap subcommands to their respective behaviors. I'm pretty happy with this bit of design, I hope you like it.
  • enum TimeQuery, enum TimeMutate: the only implementations of Query and Mutate so far, which are the clap subcommands for time show and time advance.
  • ... and various other bits that glue clap and repl-utils together to make a thing.

The idea is that users should eventually be able to use the core crate on its own for writing unit tests, and the CLI for both scripted tests and ad hoc manual tests. The advantage of the former style is that the core crate exposes a strongly typed interface: for example, time::advance returns a DateTime<Utc>, whereas the commands in the CLI crate just return string output. The advantage of the latter style is that often you just want scripts and golden files.

Subsequent PRs will add history / op log (similar to what @sunshowers implemented for reconfigurator-cli), and all the rest of the command vocabulary in RFD 726. There are a handful of // TODO(#10209) comments throughout, indicating where those additions should land.

Context: #10209.

nexus-fm-simulation holds the simulated world (so far a clock) and typed
operations on it, with no command-line types. fm-sim holds the clap
vocabulary, a parser for one line, and a simulator that runs lines against
a single current state; a history of states comes next. The fm-sim binary
reads a script or runs interactively and is tested against golden output.
@mergeconflict mergeconflict self-assigned this Nov 6, 2026
@mergeconflict mergeconflict added the fault-management Everything related to the fault-management initiative (RFD480 and others) label Nov 6, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fault-management Everything related to the fault-management initiative (RFD480 and others)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant