Feature/a memorix disabled by default#1624
Conversation
|
Caution Review failedPull request was closed or merged during review Walkthrough该PR将A_Memorix的配置管理从直接读取TOML文件改为通过全局配置管理器,涉及新增配置数据模型、主机服务重构、运行时优化和相关测试更新,以支持统一的配置生命周期管理和动态重载机制。 ChangesA_Memorix 配置系统全局管理集成
Sequence DiagramsequenceDiagram
participant Old as 旧流程
participant New as 新流程
participant HostService as 主机服务
participant ConfigMgr as 全局配置管理器
participant File as 文件系统
participant Callback as 回调机制
rect rgb(200, 150, 100, 0.5)
Note over Old,New: 旧配置读取方式
Old->>HostService: get_raw_config()
HostService->>File: 直接读取 a_memorix.toml
File-->>HostService: TOML内容
HostService-->>Old: 原始TOML字符串
end
rect rgb(100, 150, 200, 0.5)
Note over New,Callback: 新配置读取方式
New->>HostService: get_raw_config_with_meta()
HostService->>ConfigMgr: get_global_config().a_memorix
ConfigMgr->>ConfigMgr: 从全局状态读取
ConfigMgr-->>HostService: AMemorixConfig 模型
HostService->>HostService: 转换为运行时dict→tomlkit文档
HostService-->>New: TOML字符串 + exists/using_default元数据
end
rect rgb(150, 200, 100, 0.5)
Note over New,Callback: 配置更新与重载
New->>HostService: update_config(新值)
HostService->>HostService: _write_config_to_bot_config()
HostService->>File: 写入 bot_config.toml
File-->>HostService: 成功
HostService->>ConfigMgr: 重新加载bot作用域配置
ConfigMgr-->>HostService: 更新完成
HostService->>Callback: 触发 on_config_reload('bot')
Callback-->>HostService: 重载确认
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.Comment |
There was a problem hiding this comment.
Pull request overview
This PR migrates A_Memorix (长期记忆) configuration into the main bot_config.toml, makes the subsystem disabled by default via config, and wires A_Memorix runtime to follow config hot-reloads (plus corresponding WebUI + test updates).
Changes:
- Add
AMemorixConfigto the official config model andConfig, including legacyconfig/a_memorix.tomlmigration intobot_config.toml. - Update A_Memorix host service to read/write config from
bot_config.tomland reload on config hot-reload events. - Adjust WebUI config schema routing and update/extend tests to reflect the new config location and runtime behavior.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/webui/routers/config.py | Exposes a_memorix as a configurable section in the generic config schema endpoint. |
| src/main.py | Registers A_Memorix config hot-reload callback during initialization. |
| src/config/official_configs.py | Introduces AMemorixConfig and all nested config classes; defaults to disabled. |
| src/config/config.py | Adds a_memorix into global config, bumps config version, and migrates legacy a_memorix.toml. |
| src/A_memorix/host_service.py | Switches A_Memorix to use bot_config.toml, supports writing into [a_memorix], and reacts to hot reload. |
| src/A_memorix/core/runtime/init.py | Avoids eager imports via lazy __getattr__ for kernel types. |
| pytests/webui/test_memory_routes_integration.py | Updates integration setup to mock config via host service + patches embedding adapter. |
| pytests/webui/test_memory_routes.py | Updates expected config path responses to bot_config.toml. |
| pytests/test_maisaka_builtin_query_memory.py | Fixes test config patching to align with global_config.memory.*. |
| pytests/A_memorix_test/test_feedback_correction_chat_flow.py | Updates monkeypatch signatures and disables visual planner in test flow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| current = doc.get("a_memorix") | ||
| if isinstance(current, dict): | ||
| _update_toml_doc(current, bot_config_payload) | ||
| else: | ||
| doc["a_memorix"] = bot_config_payload |
| async def _write_config_to_bot_config(self, config: Dict[str, Any]) -> tuple[Path, Optional[Path]]: | ||
| path = self.get_config_path() | ||
| path.parent.mkdir(parents=True, exist_ok=True) | ||
| backup_path = _backup_config_file(path) | ||
| if path.exists(): | ||
| with path.open("r", encoding="utf-8") as handle: | ||
| doc = tomlkit.load(handle) | ||
| else: | ||
| doc = tomlkit.document() | ||
|
|
||
| bot_config_payload = self._runtime_dict_to_bot_config_dict(config) | ||
| current = doc.get("a_memorix") | ||
| if isinstance(current, dict): | ||
| _update_toml_doc(current, bot_config_payload) | ||
| else: | ||
| doc["a_memorix"] = bot_config_payload | ||
|
|
||
| with path.open("w", encoding="utf-8") as handle: | ||
| tomlkit.dump(doc, handle) | ||
|
|
||
| await _get_config_manager().reload_config(changed_scopes=("bot",)) | ||
| if not self._reload_callback_registered: | ||
| await self.reload() |
| "telemetry": TelemetryConfig, | ||
| "maim_message": MaimMessageConfig, | ||
| "memory": MemoryConfig, | ||
| "a_memorix": AMemorixConfig, |
zh-CN目标翻译作为常规 GitHub 编辑面;常规翻译以 Crowdin ->l10n_*PR 回流为准,详见docs/i18n.md请填写以下内容
(删除掉中括号内的空格,并替换为小写的x)
main分支 禁止修改,请确认本次提交的分支 不是main分支src/A_memorix,我确认已阅读src/A_memorix/MODIFICATION_POLICY.md,不涉及则无需勾选其他信息
Summary by CodeRabbit
New Features
Bug Fixes & Improvements