Skip to main content
PackageRegistry is an in-memory catalog for b01t algorithm packages. You publish a compiled program as a PackageMeta entry, then retrieve it by name or tag, resolve its dependencies in topological order, and save or load the entire registry to a JSON file. A global DEFAULT_REGISTRY instance is available for convenience.

PackageMeta

PackageMeta is a dataclass that describes a published algorithm package.
str
required
Unique name for this package. Used as the registry key.
str
required
Effect string: "coherent" or "adaptive". Matches Effect.value.
bool
required
Whether the program carries Certification.SAFE or is_safe = True.
list[str]
Free-form tags for discovery. Default: [].
str
Human-readable description of the algorithm. Default: "".
list[tuple[str, int]]
Register specifications as (name, size) tuples, in order. Default: [].
str
Semantic version string. Default: "0.1.0".
list[str]
Names of other packages this package depends on. Used for topological resolution. Default: [].
IRProgram | None
Attached broad IR program, if any. Not persisted in JSON (save stores its text dump; load does not restore it). Default: None.
ExactProgram | None
Attached exact program. Persisted to JSON using exact-oracle-v1 format when save is called. Restored on load. Default: None.

PackageRegistry

publish

Adds or replaces the package entry for meta.name.
PackageMeta
required
The package metadata to store. If a package with the same name already exists, it is overwritten.

get

Retrieves the package with the given name, or None if not found.
str
required
The exact package name to look up.

find_by_tag

Returns all packages whose tags list includes tag.
str
required
The tag to search for.

all

Returns all published packages as a list. Order is insertion order.

save

Serializes the registry to a JSON file at path. Each entry includes all scalar fields. If a package has an exact_program, it is serialized using exact-oracle-v1 format. Broad IRProgram objects are saved as their text dump but are not restored on load.
str | Path
required
File path to write. The file is created or overwritten.

load

Deserializes packages from a JSON file previously written by save and merges them into this registry.
str | Path
required
File path to read.

resolve

Returns the transitive dependencies of name in topological order (dependencies first, then name itself). Raises DSLValidationError if a circular dependency is detected or a required package is missing.
str
required
The package name to resolve.

dependency_graph_dot

Returns a string in DOT format describing the dependency graph of all published packages. You can pipe this to Graphviz to visualise the graph.

DEFAULT_REGISTRY

DEFAULT_REGISTRY is a module-level PackageRegistry instance. Use it to publish packages without managing your own registry object.

Full example