ex_monty_plugin
What a plugin tells a Monty Studio cluster about itself, and the registry that carries the answer between nodes.
A run is assembled from modules — the experiment that drives it, the learning modules it steps, the motor policies that decide where to sense next — and they do not all live in the same node. A policy that reads a part's B-rep has to run where the part was opened, because a B-rep handle cannot leave its node. So a cluster has to be able to ask a module what it is before it decides where to call it. That question, and its answer, are this package.
defmodule FollowChamfers do
@behaviour MontyPlugin
@impl true
def describe do
%{
"name" => "follow_chamfers",
"kind" => :motor_policy,
"version" => "0.1.0",
# It reads a part's geometry, and a B-rep handle cannot leave its node.
"placement" => :owner_only,
"needs" => [:quiddity]
}
end
end
MontyPlugin.conforms?(FollowChamfers.describe())
#=> :ok
| Module | What it answers |
|---|---|
MontyPlugin |
the contract: describe/0 — name, kind, version, placement, needs — and conforms?/1, which names the field that is wrong |
MontyPlugin.Registry |
which plugins the cluster offers, by name and kind, over :pg, and the same answer on every node; lookup/3 asks for a name on a named node, which is what an :owner_only plugin needs |
The three kinds are :experiment, :learning_module and :motor_policy;
placement is :anywhere or :owner_only. A learning module is advertised rather
than routed — it runs thousands of operations a step, so it is compiled where it
runs — while an experiment and a policy are called once per step, which is what
makes a remote call free.
Install
def deps do
[
{:ex_monty_plugin, "~> 0.1"}
]
end
Elixir only: no NIF, no geometry, no Monty. Adding the dependency is the whole of
the setup — MontyPlugin.Application starts the one process this package needs,
OTP's :pg, under the scope PLUGIN_SCOPE names, before anything that could ask
it a question.
What a provider is
A plugin is a process that answers one call:
def handle_call(:describe, _from, state), do: {:reply, MyPlugin.describe(), state}
The answer is held to MontyPlugin.conforms?/1. A plugin that answers unusably is
still listed, with the reason — hiding it would make "nothing there" and "there
but unusable" look the same to whoever is choosing.
Two variables, both read at boot
| variable | what it does |
|---|---|
PLUGIN_SCOPE |
the :pg scope name (default monty_plugins). Two systems sharing a cluster that must not see each other's plugins differ here, exactly as they differ in node name |
PLUGIN_DISCOVERY |
pg (default) or none. none is a deployment that runs its own built-in work and takes no part in a cluster: registration does nothing and a lookup says so, rather than looking like an empty cluster |
A node that is not distributed is a cluster of one, which is a supported deployment — the registry answers with what that node offers and nothing else.
Where to find what
| Question | Where |
|---|---|
| The contract a plugin implements | MontyPlugin |
| Which plugins the cluster offers, and how to ask | MontyPlugin.Registry |
| What a plugin can require of its host | MontyPlugin.Capabilities |
| The process this package starts | MontyPlugin.Application |
| What changed, release by release | CHANGELOG |
| Working on the package: tests, CI, releasing | development |
The API by module — and the same content as llms.txt
for a model with no browser — is generated by mix docs and published at
d-led.github.io/ex.monty.plugin from
main; the released version is on HexDocs.
What this is not
- It does not carry a call.
MontyPlugin.Registryanswers where a plugin is; making the call is the caller's, with whatever:erpcorGenServer.call/3it already uses. - It does not supervise plugins. A provider registers and unregisters itself, and
:pgforgets a node's names when the node goes down, which is the whole of the liveness story here. - It does not choose. Nothing ranks plugins, scores their capabilities or falls back to a second one — that belongs to whoever is assembling a run.
Licence
MPL-2.0 (LICENSE).