test(plugins): enforce behavior compatibility contract

This commit is contained in:
Teknium
2026-08-08 12:45:32 -07:00
parent f6aaff4646
commit 729b8a7169
7 changed files with 214 additions and 3 deletions

View File

@@ -797,6 +797,31 @@ as a side effect of importing `model_tools.py`. Code paths that read plugin
state without importing `model_tools.py` first must call `discover_plugins()`
explicitly (it's idempotent).
#### Native plugin compatibility policy
The canonical contract and deprecation policy live in
`website/docs/developer-guide/plugins/index.md#native-plugin-compatibility-contract`.
Compatibility is enforced as a behavior contract, not through a monolithic
`PLUGIN_API_VERSION`, a manifest-wide native `api:` match, or version literals
on unrelated payloads. Keep documented plugin surfaces additive:
- add hook payload data as keyword fields; signature-inspect callbacks so old
narrow signatures receive only fields they declare, while `**kwargs`
callbacks receive the complete payload;
- do not remove or rename `PluginContext` methods; make new parameters optional
with defaults and keyword-only where possible;
- ignore unknown native manifest fields;
- give new provider methods default implementations, and signature-inspect
optional callback kwargs rather than forwarding them unconditionally;
- use a local schema version only for a capability with a wire or persisted
contract, and preserve old state/config/session replay or ship a migration.
Deprecations require a once-per-process warning, a documented replacement and
migration note, and at least two subsequent minor releases before removal.
Compatibility tests must load frozen plugins through the real discovery path
and assert outcomes. Do not replace these with exact registry/catalog counts,
source-reading tests, or assertions that a global version literal changed.
### Memory-provider plugins (`plugins/memory/<name>/`)
Separate discovery system for pluggable memory backends. Current built-in