feat(plugins): enforce apiVersion; launcher plugins default ON with "none" opt-out
Two gaps from the MossTank shipment review. **apiVersion was declared in every manifest and checked by nothing.** The loader now refuses an unsupported contract BEFORE loading any code from the plugin — checking after the fact is not equivalent, because by then the assembly is in a collectible context and the mismatch surfaces as a type-load or missing-member failure from inside the plugin, which reads like the plugin is broken rather than built for a different host. PluginApi (Current / MinimumSupported) lives in Plugin.Abstractions beside the contract it versions, and the refusal is a distinct PluginApiVersionException so callers can tell "update the client or the plugin" from "this plugin is broken". The tests pin the ordering too: a manifest with a future apiVersion AND a missing dll must fail on the version, a supported one on the dll. **A launcher-launched client loaded no plugins until the user typed ids.** LA5 distinguishes an omitted allow-list (load all) from an explicit empty one (load none); a fresh character profile's list is empty, so it composed to load-none. Direct launches pass null and load everything -- which is why the gap never showed in development: the two launch paths disagreed and the launcher was the one users get. This REVERSES the LA5 default deliberately: "nothing configured" now composes to the omitted list, so plugins are on by default, including ones installed later. The opt-out is kept -- losing it would be a real regression for stripped sessions -- respelled as the literal id "none", and the launcher's plugin box says so. The cross-host shared fixture composes its explicit-load-none case through the new spelling, keeping the reader-side contract tests (App and Headless both preserve an explicit empty list) exactly as they were. Complete Release suite: 14,469 tests pass on the standard hermetic lane filter, 0 failures. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
7e75be23d1
commit
cd6eefd0ba
8 changed files with 194 additions and 7 deletions
|
|
@ -1,6 +1,39 @@
|
|||
// src/AcDream.Plugin.Abstractions/IAcDreamPlugin.cs
|
||||
namespace AcDream.Plugin.Abstractions;
|
||||
|
||||
/// <summary>The plugin contract's version.</summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// A plugin declares the version it was built against in its
|
||||
/// <c>plugin.json</c> (<c>apiVersion</c>), and the host refuses to load one
|
||||
/// it cannot honour. Without that check a plugin built against a different
|
||||
/// contract loads anyway and fails later as a MissingMethodException or a
|
||||
/// type-load error from inside the plugin's own code — an error that reads
|
||||
/// like the plugin is broken rather than mismatched.
|
||||
/// </para>
|
||||
/// <para>
|
||||
/// Bump <see cref="Current"/> only for a BREAKING change to the interfaces in
|
||||
/// this assembly (a removed or re-shaped member). Purely additive changes keep
|
||||
/// the number, since a plugin built against the older shape still runs.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static class PluginApi
|
||||
{
|
||||
/// <summary>The contract version this build implements.</summary>
|
||||
public const int Current = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The oldest contract version this build can still load. Equal to
|
||||
/// <see cref="Current"/> until a breaking change ships with a
|
||||
/// compatibility path.
|
||||
/// </summary>
|
||||
public const int MinimumSupported = 1;
|
||||
|
||||
/// <summary>Whether a plugin declaring <paramref name="apiVersion"/> can load here.</summary>
|
||||
public static bool IsSupported(int apiVersion)
|
||||
=> apiVersion >= MinimumSupported && apiVersion <= Current;
|
||||
}
|
||||
|
||||
public interface IAcDreamPlugin
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue