




















@@ -714,6 +714,70 @@ describe("config io write", () => {
714714});
715715});
716716717+it("does not print benign missing-meta write anomalies by default", async () => {
718+await withSuiteHome(async (home) => {
719+const configPath = path.join(home, ".openclaw", "openclaw.json");
720+await fs.mkdir(path.dirname(configPath), { recursive: true });
721+await fs.writeFile(
722+configPath,
723+`${JSON.stringify({ gateway: { mode: "local", port: 18789 } }, null, 2)}\n`,
724+"utf-8",
725+);
726+const warn = vi.fn();
727+const io = createConfigIO({
728+env: {} as NodeJS.ProcessEnv,
729+homedir: () => home,
730+logger: {
731+ warn,
732+error: vi.fn(),
733+},
734+});
735+736+await io.writeConfigFile({
737+gateway: { mode: "local", port: 18790 },
738+});
739+740+const anomalyLogs = warn.mock.calls.filter(
741+(call) => typeof call[0] === "string" && call[0].startsWith("Config write anomaly:"),
742+);
743+expect(anomalyLogs).toHaveLength(0);
744+});
745+});
746+747+it("prints missing-meta write anomalies when anomaly logging is requested", async () => {
748+await withSuiteHome(async (home) => {
749+const configPath = path.join(home, ".openclaw", "openclaw.json");
750+await fs.mkdir(path.dirname(configPath), { recursive: true });
751+await fs.writeFile(
752+configPath,
753+`${JSON.stringify({ gateway: { mode: "local", port: 18789 } }, null, 2)}\n`,
754+"utf-8",
755+);
756+const warn = vi.fn();
757+const io = createConfigIO({
758+env: {
759+OPENCLAW_CONFIG_WRITE_ANOMALY_LOG: "1",
760+} as NodeJS.ProcessEnv,
761+homedir: () => home,
762+logger: {
763+ warn,
764+error: vi.fn(),
765+},
766+});
767+768+await io.writeConfigFile({
769+gateway: { mode: "local", port: 18790 },
770+});
771+772+expect(warn.mock.calls).toContainEqual([
773+expect.stringContaining("Config write anomaly:"),
774+]);
775+expect(warn.mock.calls).toContainEqual([
776+expect.stringContaining("missing-meta-before-write"),
777+]);
778+});
779+});
780+717781it("suppresses overwrite audit output when skipOutputLogs is set", async () => {
718782await withSuiteHome(async (home) => {
719783const configPath = path.join(home, ".openclaw", "openclaw.json");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。