From 6f1a80cafdc26ff4603b261f3ebef95bf924fa45 Mon Sep 17 00:00:00 2001 From: YokiiroBW Date: Mon, 27 Jul 2026 13:19:40 +0800 Subject: [PATCH] fix: sync nested detail enhancement config --- docs/错题本.md | 2 +- ops/deploy-plugin.sh | 5 +++++ tests/test_deploy_script_windows.py | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/错题本.md b/docs/错题本.md index 1695455..838f539 100644 --- a/docs/错题本.md +++ b/docs/错题本.md @@ -174,7 +174,7 @@ - Phase: D1 implementation and VM deployment tooling. - Type: feature behavior / deployment / testing. - Symptom: schema, runtime fallback, and VM persisted config could independently retain `enable_detail_enhancement=False`; the Bash deploy script depended on an SSH alias and `pytest`. -- Root cause: new-install defaults and existing persistent overrides are separate paths; the script assumed a Unix developer environment. +- Root cause: new-install defaults, the flat persisted value, and the nested `schedule_detail_config` persisted value are separate paths; startup migration can copy the nested value back over the flat one; the script also assumed a Unix developer environment. - Fix or workaround: set all three defaults to `true`; after stopping AstrBot, deploy writes the VM JSON config before startup; Bash accepts `VM`, `SSH_KEY`, `SSH_PORT`, `PYTHON_BIN`, `SKIP_LOCAL_TESTS`, and `DETAIL_ENHANCEMENT_ENABLED`; add `ops/deploy-plugin.ps1`. - Prevention rule: configuration switches must be checked at schema, runtime fallback, and production persistence layers; cross-machine deploy commands must make SSH and test-runtime dependencies explicit. - Validation evidence: `tests/test_d1_default_enabled.py` and `tests/test_deploy_script_windows.py`; deployment verifies service state, logs, and persisted config. \ No newline at end of file diff --git a/ops/deploy-plugin.sh b/ops/deploy-plugin.sh index e19e6bf..4a18064 100644 --- a/ops/deploy-plugin.sh +++ b/ops/deploy-plugin.sh @@ -147,6 +147,11 @@ value = sys.argv[1].strip().lower() in ("1", "true", "yes", "on") with codecs.open(path, "r", "utf-8-sig") as handle: config = json.load(handle) config["enable_detail_enhancement"] = value +schedule_detail = config.get("schedule_detail_config") +if not isinstance(schedule_detail, dict): + schedule_detail = {} + config["schedule_detail_config"] = schedule_detail +schedule_detail["enable_detail_enhancement"] = value with codecs.open(path, "w", "utf-8-sig") as handle: json.dump(config, handle, ensure_ascii=False, indent=2) handle.write("\n") diff --git a/tests/test_deploy_script_windows.py b/tests/test_deploy_script_windows.py index e8519b3..b96a9cb 100644 --- a/tests/test_deploy_script_windows.py +++ b/tests/test_deploy_script_windows.py @@ -15,6 +15,7 @@ class WindowsDeployEntrypointTests(unittest.TestCase): self.assertIn(token, script) self.assertIn('"$PYTHON_BIN" -m unittest discover -s tests -q', script) self.assertIn("shutdown persistence", script) + self.assertIn("schedule_detail_config", script) def test_powershell_wrapper_supplies_vm_key_and_python(self): wrapper = (ROOT / "ops" / "deploy-plugin.ps1").read_text(encoding="utf-8")