gateway: close health monitor review threads
This commit is contained in:
parent
226c2e3aa0
commit
f1bc3d157c
@ -212,6 +212,37 @@ describe("gateway.channelHealthCheckMinutes", () => {
|
|||||||
expect(res.issues[0]?.path).toBe("gateway.channelHealthCheckMinutes");
|
expect(res.issues[0]?.path).toBe("gateway.channelHealthCheckMinutes");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("rejects stale thresholds shorter than the health check interval", () => {
|
||||||
|
const res = validateConfigObject({
|
||||||
|
gateway: {
|
||||||
|
channelHealthCheckMinutes: 5,
|
||||||
|
channelStaleEventThresholdMinutes: 4,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(res.ok).toBe(false);
|
||||||
|
if (!res.ok) {
|
||||||
|
expect(res.issues[0]?.path).toBe("gateway.channelStaleEventThresholdMinutes");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it("accepts stale thresholds that match or exceed the health check interval", () => {
|
||||||
|
const equal = validateConfigObject({
|
||||||
|
gateway: {
|
||||||
|
channelHealthCheckMinutes: 5,
|
||||||
|
channelStaleEventThresholdMinutes: 5,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(equal.ok).toBe(true);
|
||||||
|
|
||||||
|
const greater = validateConfigObject({
|
||||||
|
gateway: {
|
||||||
|
channelHealthCheckMinutes: 5,
|
||||||
|
channelStaleEventThresholdMinutes: 6,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(greater.ok).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("cron webhook schema", () => {
|
describe("cron webhook schema", () => {
|
||||||
|
|||||||
@ -835,6 +835,21 @@ export const OpenClawSchema = z
|
|||||||
.optional(),
|
.optional(),
|
||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
|
.superRefine((gateway, ctx) => {
|
||||||
|
if (
|
||||||
|
gateway.channelStaleEventThresholdMinutes != null &&
|
||||||
|
gateway.channelHealthCheckMinutes != null &&
|
||||||
|
gateway.channelHealthCheckMinutes !== 0 &&
|
||||||
|
gateway.channelStaleEventThresholdMinutes < gateway.channelHealthCheckMinutes
|
||||||
|
) {
|
||||||
|
ctx.addIssue({
|
||||||
|
code: z.ZodIssueCode.custom,
|
||||||
|
path: ["channelStaleEventThresholdMinutes"],
|
||||||
|
message:
|
||||||
|
"channelStaleEventThresholdMinutes should be >= channelHealthCheckMinutes to avoid delayed stale detection",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
memory: MemorySchema,
|
memory: MemorySchema,
|
||||||
skills: z
|
skills: z
|
||||||
|
|||||||
@ -235,4 +235,27 @@ describe("server-channels auto restart", () => {
|
|||||||
|
|
||||||
expect(manager.isHealthMonitorEnabled("discord", "router-d")).toBe(false);
|
expect(manager.isHealthMonitorEnabled("discord", "router-d")).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("falls back to channel-level health monitor overrides when account resolution omits them", () => {
|
||||||
|
installTestRegistry(
|
||||||
|
createTestPlugin({
|
||||||
|
resolveAccount: () => ({
|
||||||
|
enabled: true,
|
||||||
|
configured: true,
|
||||||
|
}),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const manager = createManager({
|
||||||
|
loadConfig: () => ({
|
||||||
|
channels: {
|
||||||
|
discord: {
|
||||||
|
healthMonitor: { enabled: false },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(manager.isHealthMonitorEnabled("discord", DEFAULT_ACCOUNT_ID)).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -131,11 +131,24 @@ export function createChannelManager(opts: ChannelManagerOptions): ChannelManage
|
|||||||
}
|
}
|
||||||
| undefined;
|
| undefined;
|
||||||
const accountOverride = resolvedAccount?.healthMonitor?.enabled;
|
const accountOverride = resolvedAccount?.healthMonitor?.enabled;
|
||||||
|
const channelOverride = (
|
||||||
|
cfg.channels?.[channelId] as
|
||||||
|
| {
|
||||||
|
healthMonitor?: {
|
||||||
|
enabled?: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
| undefined
|
||||||
|
)?.healthMonitor?.enabled;
|
||||||
|
|
||||||
if (typeof accountOverride === "boolean") {
|
if (typeof accountOverride === "boolean") {
|
||||||
return accountOverride;
|
return accountOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof channelOverride === "boolean") {
|
||||||
|
return channelOverride;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user