- main.py: 4360 → 146 lines (96.6% reduction), entry layer only - services/: rate_limiter, autostart, persona, connection, profile, hotspot, content, engagement, scheduler, queue_ops (10 business modules) - ui/app.py: all Gradio UI code extracted into build_app(cfg, analytics) - Fix: with gr.Blocks() indented inside build_app function - Fix: cfg.all property (not get_all method) - Fix: STATUS_LABELS, get_persona_keywords, fetch_proactive_notes imports - Fix: queue_ops module-level set_publish_callback moved into configure() - Fix: pub_queue.format_*() wrapped as queue_format_table/calendar helpers - All 14 files syntax-verified, build_app() runtime-verified - 58/58 tasks complete"
1.1 KiB
1.1 KiB
ADDED Requirements
Requirement: 自动调度器函数迁移至独立模块
系统 SHALL 将调度器相关的状态变量和函数从 main.py 提取至 services/scheduler.py,包括:_scheduler_next_times、_auto_log(列表)、_auto_log_append、_scheduler_loop、start_scheduler、stop_scheduler、get_auto_log、get_scheduler_status、_learn_running、_learn_scheduler_loop、start_learn_scheduler、stop_learn_scheduler。
Scenario: 调度器启停正常工作
- WHEN
start_scheduler(...)被调用并传入合法参数 - THEN 调度器线程 SHALL 正常启动,
get_scheduler_status()返回运行中状态
Scenario: 日志追加线程安全
- WHEN 多个自动化任务并发调用
_auto_log_append(msg) - THEN 日志条目 SHALL 正确追加,不丢失和乱序
Scenario: engagement 通过回调写日志
- WHEN
services/engagement.py中的函数需要写日志时 - THEN SHALL 通过
log_fn参数(由scheduler.py传入_auto_log_append)写入,不直接导入scheduler.py