mixle.registry module¶
Registry – a local directory + index of fitted task models, queryable by capability and fingerprint.
The registry is the local library catalog that orchestrators, routers, capture
flows, and accumulation workflows can read from or write into. Deliberately a
directory plus a JSON index, not a server: every entry is a saved
TaskModel or CalibratedTaskModel artifact directory
(see mixle.task.artifact) plus a small index record naming its capabilities, task fingerprint
(task_fingerprint()), and capture profile. find_for answers “do I already have
something for this task”; tier_stack turns a matching capability into an ascending-cost tier list – the
shape Router consumes directly (Router(tiers=stack)), with the frontier
appended last as the router’s own fallback tier.
- class RegistryEntry(entry_id, path, kind, capabilities=<factory>, fingerprint=None, profile=<factory>, cost=0.0)[source]
Bases:
objectOne catalog record: where the artifact lives, what it’s registered under, and how much it costs to run.
- Parameters:
- to_dict()[source]
Serialize the registry entry into JSON-compatible fields.
- class Registry(dir)[source]
Bases:
objectA
dir-backed catalog of registered models:registerwrites an artifact + index entry;find_for/tier_stackquery it. Re-opening the samedirin a fresh process sees every entry.- Parameters:
dir (str)
- register(model, *, capabilities, fingerprint=None, profile=None, cost=0.0, entry_id=None)[source]
Save
model’s artifact underdirand add its index entry; return the entry.modelis a fittedTaskModelorCalibratedTaskModel– the two artifact-saveable task model kinds.capabilitiesnames what this model answers (matched byfind_for());fingerprintis typicallytask_fingerprint()’s vector for the training data;profileis free-form (e.g. acapture_profile()dict);costis the per-request cost used to ordertier_stack().
- load(entry_id)[source]
Reload a registered model by
entry_id(round-trips through the artifact on disk).- Parameters:
entry_id (str)
- Return type:
TaskModel | CalibratedTaskModel
- find_for(query, *, top_k=None)[source]
Entries matching
query: a capability name (str, containment match) or a task fingerprint vector (array-like of floats, nearest-neighbor match).top_kcaps how many are returned – every capability match by default, or the single nearest fingerprint match by default.
- tier_stack(task, *, frontier, costs=None, names=None)[source]
Ascending-cost
(name, model, cost)tiers for capabilitytask,frontierappended last.Matching entries are loaded (
load()) and ordered by their registeredcost. The result is exactly the shapeRoutertakes astiers=: each non-final tier exposesdecide(x), the final tier is the callablefrontierfallback.costs(one entry per matching solution plus one forfrontier, mirroringfrom_solutions()) overrides the registered per-entry costs when given.