fix(regression): auto-enable gateway bootstrap snapshots

This commit is contained in:
Tak Hoffman
2026-03-27 23:40:30 -05:00
parent 0c729b6d30
commit 363038828f
2 changed files with 41 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
import { primeConfiguredBindingRegistry } from "../channels/plugins/binding-registry.js";
import type { loadConfig } from "../config/config.js";
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
import type { PluginRegistry } from "../plugins/registry.js";
import { pinActivePluginChannelRegistry } from "../plugins/runtime.js";
import { setGatewaySubagentRuntime } from "../plugins/runtime/index.js";
@@ -56,9 +57,13 @@ function logGatewayPluginDiagnostics(params: {
}
export function prepareGatewayPluginLoad(params: GatewayPluginBootstrapParams) {
installGatewayPluginRuntimeEnvironment(params.cfg);
const resolvedConfig = applyPluginAutoEnable({
config: params.cfg,
env: process.env,
}).config;
installGatewayPluginRuntimeEnvironment(resolvedConfig);
const loaded = loadGatewayPlugins({
cfg: params.cfg,
cfg: resolvedConfig,
workspaceDir: params.workspaceDir,
log: params.log,
coreGatewayHandlers: params.coreGatewayHandlers,
@@ -66,7 +71,7 @@ export function prepareGatewayPluginLoad(params: GatewayPluginBootstrapParams) {
preferSetupRuntimeForChannelPlugins: params.preferSetupRuntimeForChannelPlugins,
});
params.beforePrimeRegistry?.(loaded.pluginRegistry);
primeConfiguredBindingRegistry({ cfg: params.cfg });
primeConfiguredBindingRegistry({ cfg: resolvedConfig });
if ((params.logDiagnostics ?? true) && loaded.pluginRegistry.diagnostics.length > 0) {
logGatewayPluginDiagnostics({
diagnostics: loaded.pluginRegistry.diagnostics,

View File

@@ -571,9 +571,41 @@ describe("loadGatewayPlugins", () => {
test("primes configured bindings during gateway startup", async () => {
loadOpenClawPlugins.mockReturnValue(createRegistry([]));
const cfg = {};
const autoEnabledConfig = { channels: { slack: { enabled: true } }, autoEnabled: true };
applyPluginAutoEnable.mockReturnValue({ config: autoEnabledConfig, changes: [] });
loadGatewayStartupPluginsForTest({ cfg });
expect(primeConfiguredBindingRegistry).toHaveBeenCalledWith({ cfg });
expect(primeConfiguredBindingRegistry).toHaveBeenCalledWith({ cfg: autoEnabledConfig });
});
test("uses the auto-enabled config snapshot for gateway bootstrap policies", async () => {
const serverPlugins = serverPluginsModule;
const autoEnabledConfig = {
plugins: {
entries: {
demo: {
subagent: { allowModelOverride: true, allowedModels: ["openai/gpt-5.4"] },
},
},
},
};
applyPluginAutoEnable.mockReturnValue({ config: autoEnabledConfig, changes: [] });
const runtime = await createSubagentRuntime(serverPlugins, {});
serverPlugins.setFallbackGatewayContext(createTestContext("auto-enabled-bootstrap-policy"));
await gatewayRequestScopeModule.withPluginRuntimePluginIdScope("demo", () =>
runtime.run({
sessionKey: "s-auto-enabled-bootstrap-policy",
message: "use trusted override",
model: "openai/gpt-5.4",
deliver: false,
}),
);
expect(getLastDispatchedParams()).toMatchObject({
sessionKey: "s-auto-enabled-bootstrap-policy",
model: "openai/gpt-5.4",
});
});
test("can suppress duplicate diagnostics when reloading full runtime plugins", async () => {