

























@@ -260,6 +260,53 @@ describe("gateway startup config recovery", () => {
260260expect(recoveryNotice.enqueueConfigRecoveryNotice).not.toHaveBeenCalled();
261261});
262262263+it("rejects legacy config entries in Nix mode before recovery", async () => {
264+const legacySnapshot = buildTestConfigSnapshot({
265+path: configPath,
266+exists: true,
267+raw: `${JSON.stringify({
268+ heartbeat: { model: "anthropic/claude-3-5-haiku-20241022", every: "30m" },
269+ })}\n`,
270+parsed: {
271+heartbeat: { model: "anthropic/claude-3-5-haiku-20241022", every: "30m" },
272+},
273+valid: false,
274+config: {} as OpenClawConfig,
275+issues: [
276+{
277+path: "heartbeat",
278+message:
279+"top-level heartbeat is not a valid config path; use agents.defaults.heartbeat (cadence/target/model settings) or channels.defaults.heartbeat (showOk/showAlerts/useIndicator).",
280+},
281+],
282+legacyIssues: [
283+{
284+path: "heartbeat",
285+message:
286+"top-level heartbeat is not a valid config path; use agents.defaults.heartbeat (cadence/target/model settings) or channels.defaults.heartbeat (showOk/showAlerts/useIndicator).",
287+},
288+],
289+});
290+vi.mocked(configIo.readConfigFileSnapshotWithPluginMetadata).mockResolvedValueOnce({
291+snapshot: legacySnapshot,
292+ pluginMetadataSnapshot,
293+});
294+vi.mocked(configIo, true).isNixMode = true;
295+296+await expect(
297+loadGatewayStartupConfigSnapshot({
298+minimalTestGateway: true,
299+log: { info: vi.fn(), warn: vi.fn() },
300+}),
301+).rejects.toThrow(
302+"Legacy config entries detected while running in Nix mode. Update your Nix config to the latest schema and restart.",
303+);
304+305+expect(configIo.recoverConfigFromLastKnownGood).not.toHaveBeenCalled();
306+expect(configIo.recoverConfigFromJsonRootSuffix).not.toHaveBeenCalled();
307+expect(recoveryNotice.enqueueConfigRecoveryNotice).not.toHaveBeenCalled();
308+});
309+263310it("continues startup in degraded mode for plugin-local startup invalidity", async () => {
264311const invalidSnapshot = buildTestConfigSnapshot({
265312path: configPath,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。