perf(whatsapp): add doctor contract fast path

This commit is contained in:
Vincent Koc
2026-04-14 17:27:01 +01:00
parent 87eac5377c
commit 8d3bd4859e
2 changed files with 27 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
import type { ChannelDoctorLegacyConfigRule } from "openclaw/plugin-sdk/channel-contract";
export { normalizeCompatibilityConfig } from "./src/doctor-contract.js";
// WhatsApp currently exposes doctor compatibility fixes without extra legacy
// rule scans. Keep that empty answer on a lightweight contract surface so
// config validation stays off the broad contract-api import path.
export const legacyConfigRules: ChannelDoctorLegacyConfigRule[] = [];

View File

@@ -13,6 +13,11 @@ const { loadBundledPluginPublicArtifactModuleSyncMock } = vi.hoisted(() => ({
],
};
}
if (dirName === "whatsapp" && artifactBasename === "doctor-contract-api.js") {
return {
legacyConfigRules: [],
};
}
if (dirName === "telegram" && artifactBasename === "contract-api.js") {
return {
legacyConfigRules: [
@@ -52,6 +57,20 @@ describe("channel doctor contract api fast path", () => {
});
});
it("treats empty explicit doctor contract rules as authoritative", () => {
const api = loadBundledChannelDoctorContractApi("whatsapp");
expect(api?.legacyConfigRules).toEqual([]);
expect(loadBundledPluginPublicArtifactModuleSyncMock).toHaveBeenCalledWith({
dirName: "whatsapp",
artifactBasename: "doctor-contract-api.js",
});
expect(loadBundledPluginPublicArtifactModuleSyncMock).not.toHaveBeenCalledWith({
dirName: "whatsapp",
artifactBasename: "contract-api.js",
});
});
it("falls back to the generic contract artifact when the doctor artifact is absent", () => {
const api = loadBundledChannelDoctorContractApi("telegram");