fix(zalouser): migrate legacy group allow aliases (#60702)

* fix(channels): prefer source contract surfaces in source checkouts

* fix(zalouser): migrate legacy group allow aliases
This commit is contained in:
Vincent Koc
2026-04-04 14:50:15 +09:00
committed by GitHub
parent ae7942bf5e
commit 73115b5480
16 changed files with 281 additions and 62 deletions

View File

@@ -0,0 +1,16 @@
import { describe, expect, it } from "vitest";
import { getBundledChannelContractSurfaceModule } from "./contract-surfaces.js";
describe("bundled channel contract surfaces", () => {
it("resolves Telegram contract surfaces from a source checkout", () => {
const surface = getBundledChannelContractSurfaceModule<{
normalizeTelegramCommandName?: (value: string) => string;
}>({
pluginId: "telegram",
preferredBasename: "contract-surfaces.ts",
});
expect(surface).not.toBeNull();
expect(surface?.normalizeTelegramCommandName?.("/Hello-World")).toBe("hello_world");
});
});

View File

@@ -61,6 +61,16 @@ function createModuleLoader() {
const loadModule = createModuleLoader();
function getContractSurfaceDiscoveryEnv(): NodeJS.ProcessEnv {
if (RUNNING_FROM_BUILT_ARTIFACT) {
return process.env;
}
return {
...process.env,
VITEST: process.env.VITEST || "1",
};
}
function matchesPreferredBasename(
basename: ContractSurfaceBasename,
preferredBasename: ContractSurfaceBasename | undefined,
@@ -153,9 +163,11 @@ function loadBundledChannelContractSurfaceEntries(): Array<{
pluginId: string;
surface: unknown;
}> {
const discovery = discoverOpenClawPlugins({ cache: false });
const env = getContractSurfaceDiscoveryEnv();
const discovery = discoverOpenClawPlugins({ cache: false, env });
const manifestRegistry = loadPluginManifestRegistry({
cache: false,
env,
config: {},
candidates: discovery.candidates,
diagnostics: discovery.diagnostics,
@@ -204,9 +216,11 @@ export function getBundledChannelContractSurfaceModule<T = unknown>(params: {
if (cachedPreferredSurfaceModules.has(cacheKey)) {
return (cachedPreferredSurfaceModules.get(cacheKey) ?? null) as T | null;
}
const discovery = discoverOpenClawPlugins({ cache: false });
const env = getContractSurfaceDiscoveryEnv();
const discovery = discoverOpenClawPlugins({ cache: false, env });
const manifestRegistry = loadPluginManifestRegistry({
cache: false,
env,
config: {},
candidates: discovery.candidates,
diagnostics: discovery.diagnostics,

View File

@@ -15318,9 +15318,6 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
additionalProperties: {
type: "object",
properties: {
allow: {
type: "boolean",
},
enabled: {
type: "boolean",
},
@@ -15435,9 +15432,6 @@ export const GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA = [
additionalProperties: {
type: "object",
properties: {
allow: {
type: "boolean",
},
enabled: {
type: "boolean",
},

View File

@@ -558,7 +558,7 @@ describe("legacy migrate nested channel enabled aliases", () => {
});
});
it("moves legacy allow toggles into enabled for slack, googlechat, discord, and matrix", () => {
it("moves legacy allow toggles into enabled for slack, googlechat, discord, matrix, and zalouser", () => {
const res = migrateLegacyConfig({
channels: {
slack: {
@@ -633,6 +633,22 @@ describe("legacy migrate nested channel enabled aliases", () => {
},
},
},
zalouser: {
groups: {
"group:trusted": {
allow: false,
},
},
accounts: {
work: {
groups: {
"group:legacy": {
allow: true,
},
},
},
},
},
},
});
@@ -660,6 +676,12 @@ describe("legacy migrate nested channel enabled aliases", () => {
expect(res.changes).toContain(
"Moved channels.matrix.accounts.work.rooms.!legacy:example.org.allow → channels.matrix.accounts.work.rooms.!legacy:example.org.enabled (true).",
);
expect(res.changes).toContain(
"Moved channels.zalouser.groups.group:trusted.allow → channels.zalouser.groups.group:trusted.enabled (false).",
);
expect(res.changes).toContain(
"Moved channels.zalouser.accounts.work.groups.group:legacy.allow → channels.zalouser.accounts.work.groups.group:legacy.enabled (true).",
);
expect(res.config?.channels?.slack?.channels?.ops).toEqual({
enabled: false,
});
@@ -675,6 +697,12 @@ describe("legacy migrate nested channel enabled aliases", () => {
expect(res.config?.channels?.matrix?.accounts?.work?.rooms?.["!legacy:example.org"]).toEqual({
enabled: true,
});
expect(res.config?.channels?.zalouser?.groups?.["group:trusted"]).toEqual({
enabled: false,
});
expect(res.config?.channels?.zalouser?.accounts?.work?.groups?.["group:legacy"]).toEqual({
enabled: true,
});
});
it("drops legacy allow when enabled is already set", () => {