BB.Inference.ModelController (bb_inference v0.1.0)

Copy Markdown View Source

The controller each model is lowered into.

init/1 returns at once and the model loads in handle_continue/2, so the rest of the robot starts while a large artefact is still loading. A call made while it loads waits for it.

When loading fails

If the artefact is missing, the runtime can't load it, or the codec doesn't fit what the runtime describes, the controller reports the error through BB.Safety.report_error/3, logs one line saying why, and stops. Its supervisor restarts it, and each restart tries the load again. A model that keeps failing exhausts the restart budget, the topology supervisor stops, and the robot latches in :error with its infrastructure still running. BB.Safety.force_disarm/1 acknowledges the fault and tries again.

There is no back-off between attempts: they happen as fast as the supervisors restart the controller, so the artefact is loaded once per attempt before the robot reaches :error.

It stops with a {:shutdown, error} reason. The supervisor restarts it all the same and counts it against the budget, but GenServer doesn't write a crash report for it, so the log isn't filled with the controller's state.

Unloading

The controller traps exits so that BB.Inference.Runtime.unload/1, where the runtime defines it, runs when the controller's supervisor shuts it down as well as when it stops of its own accord.