M6.1.3-R2 非五类兼容(阻断修复):DTO date 缺失时从 occurred_at 派生, 刻意不做时区换算以与 _infer_window 同一时钟;calendar_event 取 start_at、 creative_progress 取 project.updated_at;未知 kind 不再默认 bot_observed_activity; capture_hard_fact L4→L3;TYPE_CONTRACTS 覆盖全部 12 类,修复非五类 source_kind 兜底成 observed 污染本地记录;proactive_message 的 image_path 改为 has_image+ image_name(原样透传会被自身隐私校验整条静默丢弃);snapshot/daily_plan 透传 version。 M6.1.4 创作/媒体/主观分域:creative_progress 补 chunk 形参(生产调用点一直 TypeError 导致创作推进整步被阻断)并只留里程碑摘要;photo_generation 改为媒体索引 (原 payload 带 prompt 键与绝对路径,100% 静默丢弃);幂等键纳入隐私校验; 禁用键清单收窄,放行媒体标识键;两条 Bridge 路径统一送 body payload。 M6.1.5 Bot 专用检索 Profiles:按 Profile 分槽注入,固定槽位与条数、跨槽去重、 声明当前以本地运行态为准;旧版记忆插件回退通用检索。 M6.1.6 分层只读 API:新增 build_agenda_runtime_view 与 GET /agenda/runtime, 记忆插件停用时仍完整返回并标降级。 M6.1.7 隐私与残余收口:DTO 新增 contexts 禁用键;已删除娱乐功能(qzone/news/ web_exploration)的残余配置入口从展示面隐藏,旧值保留不删。 测试:174 项通过(pytest 与 unittest 双口径)。联合 E2E 135 项全部通过。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
53 行
2.3 KiB
Python
53 行
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import ast
|
|
import asyncio
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
|
|
class R1MaintenanceTests(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls):
|
|
source_path = Path(__file__).resolve().parents[1] / "daily_state.py"
|
|
tree = ast.parse(source_path.read_text(encoding="utf-8"))
|
|
function = next(node for node in tree.body if isinstance(node, ast.ClassDef) and node.name == "DailyStateMixin" for node in node.body if isinstance(node, ast.AsyncFunctionDef) and node.name == "_run_proactive_maintenance_tasks")
|
|
namespace = {"logger": type("Logger", (), {"warning": staticmethod(lambda *args, **kwargs: None)})(), "_single_line": lambda value, limit=160: str(value or "")[:limit]}
|
|
module = ast.Module(body=[function], type_ignores=[])
|
|
ast.fix_missing_locations(module)
|
|
exec(compile(module, str(source_path), "exec"), namespace)
|
|
cls._maintenance = namespace["_run_proactive_maintenance_tasks"]
|
|
|
|
def test_core_schedule_maintenance_runs_when_proactive_generation_disabled(self):
|
|
calls = []
|
|
|
|
class Harness:
|
|
def _proactive_generation_disabled(self):
|
|
return True
|
|
|
|
async def _agenda_maintenance_tick(self):
|
|
calls.append("agenda")
|
|
|
|
async def _maybe_settle_skill_growth(self):
|
|
calls.append("skill")
|
|
|
|
async def _maybe_trigger_jm_cosmos_boredom_read(self):
|
|
calls.append("reading")
|
|
|
|
async def _maybe_schedule_private_reading_recommendation_request(self):
|
|
calls.append("recommendation")
|
|
|
|
asyncio.run(R1MaintenanceTests._maintenance(Harness()))
|
|
self.assertEqual(calls, ["agenda"])
|
|
|
|
def test_tick_source_runs_disabled_maintenance_before_lock(self):
|
|
source = (Path(__file__).resolve().parents[1] / "daily_state.py").read_text(encoding="utf-8")
|
|
disabled_call = "if self._proactive_generation_disabled():\n await self._run_proactive_maintenance_tasks()"
|
|
self.assertIn(disabled_call, source)
|
|
tick_start = source.index(" async def _tick(self):")
|
|
self.assertLess(source.index(disabled_call, tick_start), source.index("async with self._data_lock:", tick_start))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|