fix(plugins): tighten register rollback

This commit is contained in:
Ayaan Zaidi
2026-04-17 09:56:54 +05:30
parent 59d07f0ab4
commit c95507978f
4 changed files with 99 additions and 9 deletions

View File

@@ -1795,6 +1795,18 @@ module.exports = { id: "throws-after-import", register() {} };`,
description: "Fail me",
handler: async () => ({ text: "nope" }),
});
api.registerReload({
onConfigReload: async () => {},
});
api.registerNodeHostCommand({
command: "failme",
description: "failme",
run: async () => ({ ok: true }),
});
api.registerSecurityAuditCollector({
id: "failme",
collect: async () => [],
});
api.registerInteractiveHandler({
channel: "slack",
namespace: "failme",
@@ -1831,6 +1843,9 @@ module.exports = { id: "throws-after-import", register() {} };`,
);
expect(getRegisteredEventKeys()).toEqual([]);
expect(getPluginCommandSpecs()).toEqual([]);
expect(registry.reloads).toEqual([]);
expect(registry.nodeHostCommands).toEqual([]);
expect(registry.securityAuditCollectors).toEqual([]);
expect(resolvePluginInteractiveNamespaceMatch("slack", "failme:payload")).toBeNull();
expect(getContextEngineFactory("failme-context")).toBeUndefined();
expect(listContextEngineIds()).not.toContain("failme-context");

View File

@@ -2209,6 +2209,7 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
hookPolicy: entry?.hooks,
registrationMode,
});
const registrySnapshot = snapshotPluginRegistry(registry);
const previousAgentHarnesses = listRegisteredAgentHarnesses();
const previousCompactionProviders = listRegisteredCompactionProviders();
const previousMemoryEmbeddingProviders = listRegisteredMemoryEmbeddingProviders();
@@ -2217,7 +2218,6 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
const previousMemoryCorpusSupplements = listMemoryCorpusSupplements();
const previousMemoryPromptSupplements = listMemoryPromptSupplements();
const previousMemoryRuntime = getMemoryRuntime();
const registrySnapshot = snapshotPluginRegistry(registry);
try {
runPluginRegisterSync(register, api);