Plugin Architecture (Removed)
Status: Current Last updated: 2026-03-26 14:05 EDT
Status: Removed (March 2026). The plugin system (
batchalign.plugins,PluginDescriptor,InferenceProvider,discover_plugins()) was deleted. The only plugin that existed (batchalign-hk-plugin) was folded into the core repository as built-in engines.The original detailed design history is preserved in maintainer archives; the public docs keep only the migration outcome and the current extension pattern.
Why It Was Removed
- Single consumer:
batchalign-hk-pluginwas the only plugin. The discovery machinery existed for one package. - Entry-point fragility:
importlib.metadata.entry_points()failed silently on broken packages, loaded wrong versions across environments, and was difficult to debug. - Enum dispatch is safer:
AsrEngineandFaEngineenums provide compile-time exhaustiveness checking and clear error messages for missing engines. - Built-in providers are simpler: we keep provider dependencies in the base package rather than recreating plugin-style install tiers.
Current Engine Extension Pattern
To add a new inference engine, use the built-in engine pattern documented in Adding Inference Providers. The pattern is:
- Create a
(load_*, infer_*)function pair inbatchalign/inference/ - Add an enum variant to
AsrEngine,FaEngine, or the relevant engine enum - Wire the loader into
worker/_model_loading/ - Register the runtime handler during bootstrap in
worker/_model_loading/and keepworker/_infer.pythin - Add provider/runtime dependencies to the base package if the engine is part of the supported built-in surface
If you are adding a new command, do not reach for a plugin system. Put the
released command in crates/batchalign/src/commands/ and keep any
algorithmic or orchestration logic in the owning Rust module (compare.rs,
benchmark.rs, transcribe/, fa/, morphosyntax/, etc.). Engines remain
providers for Rust-owned command flows; command composition does not happen
through late-bound plugin discovery.
For a real-world example of this pattern, see the Cantonese ASR engines in
batchalign/inference/languages/cantonese/ and the
Cantonese and CJK, Architecture.
Migration Guide for Existing Plugins
If you have an existing batchalign.plugins plugin, migrate it to a built-in
engine:
- Move your
load_*andinfer_*functions intobatchalign/inference/ - Add an enum variant for your engine in
worker/_types.py - Remove
pyproject.tomlentry points andPluginDescriptor - Add your dependencies to batchalign’s base package if the engine is a supported built-in provider
- Update tests to use
monkeypatchinstead of mock-based plugin patching
This page last changed: 2026-06-19 (commit c82a6d03). The whole book last changed: 2026-09-16 (commit 34d249d8).