ADR-0021: Plugin API (0, 2)¶
Architecture: Section 5, Engine and catalog contracts
Context¶
0.2 is the first release that runs models. The 0.1 engine contract had no way to check what a Python model returned, to share one result between units, to create a view, to say which materializations an engine offers, or to tell whether a state store is visible to other processes. The model runner needs all of them, and the engine plugins (polars, pandas) are built against the same API.
Options¶
- Keep the 0.1 contract and let the runner work around it. The runner would guess at native types and could not reject a foreign return value with a useful error.
- Add the missing pieces to the protocols. One additive change, and core, plugins and the memory engine move together.
Decision¶
The plugin API version becomes (0, 2). While the major version is 0 a plugin must match it exactly (ADR-0017), so every plugin is rebuilt for it. The change is additive:
Engine.versionnames the engine library's version and goes intorun_results.json.Engine.session(ctx, *, catalog)receives the catalog. A session is created once per invocation and must be thread-safe, because the thread executor shares it.EngineSession.relation(native)checks a model's return value and wraps it in aRelation. It raisesTypeErrorfor a foreign type, which the runner reports as PLX101 with a hint.EngineSession.persist(rel)returns an in-memory copy that later reads reuse. The runner calls it for an ephemeral model that more than one unit inlines.EngineSession.create_view(target, query, inputs)creates or replaces a catalog view.inputsmaps the aliases used inquerytoReadSpecs; a persisted model is read as formattable.EngineCapabilities.materializationslists what the engine can store:table,viewandephemeralin 0.2. A model whose materialization is missing is PLC509, soincrementalandintermediateare rejected until an engine declares them. Views keep PLC507 for engines without view support.StateStoreCapabilities.sharedsays whether every process and task of a run sees the store.PluginSpec.capabilitiesholds either kind of capabilities.ReadSpec.formatmay betable, a table of the catalog named byReadSpec.table.- The state store records runs and unit attempts (
record_run,list_units) next to watermarks and locks. - A view must be a SQL model that inlines no ephemeral model, because the query is stored as written (PLP409).
The runner does not call EngineSession.filter_since, max_value or cancel; they stay for 0.3.
Consequences¶
- Plugins built for (0, 1) fail with PLU001 until they are updated.
- The memory engine implements the whole contract, including views, so the contract suites can run against it.
- The runner has one place (
_to_frame_api) where Narwhals frames will be wired in, for engines that declareportable.
Status¶
Accepted
Date¶
2026-11-04