feat: stabilize multi-region runtime sync and worker orchestration

This commit is contained in:
root
2026-04-27 15:48:12 +08:00
parent 7cbde2aa78
commit 215a364891
137 changed files with 31931 additions and 1943 deletions

103
docs/审核顺序.md Normal file
View File

@@ -0,0 +1,103 @@
# 第一轮审核清单
第一轮目标:先查控制面、运行态聚合、同步链、节点控制和配置分发。
建议模型与强度:
- `gpt-5.4`
- `xhigh`
建议额度:
- `300万 ~ 450万 tokens`
本轮不看:
- `release/`
- `.venv/`
- `node_modules/`
- 运行时日志、快照、night runs
- 大型静态资源和锁文件
## 审核顺序
### P0运行态与页面口径
1. [domain-api/app/services/detect_job_service.py](/www/wwwroot/getDomain/domain-api/app/services/detect_job_service.py)
重点看:`active_job``runtime_snapshot``runtime_ingest``distributed_node_stats``display_*` 字段是否会互相覆盖。
2. [domain-api/app/services/detect_service.py](/www/wwwroot/getDomain/domain-api/app/services/detect_service.py)
重点看:检测控制页口径、聚合线程数、参与节点/参与进程统计、零值回退逻辑。
3. [domain-api/app/services/runtime_status_service.py](/www/wwwroot/getDomain/domain-api/app/services/runtime_status_service.py)
重点看:运行中心聚合、`queue_health` 与 backlog 对齐、活跃任务判定。
4. [domain-api/app/services/dashboard.py](/www/wwwroot/getDomain/domain-api/app/services/dashboard.py)
重点看:首页总览是否复用旧快照、`queue_display_*``active_job` 是否一致。
5. [domain-api/app/api/routes/detect.py](/www/wwwroot/getDomain/domain-api/app/api/routes/detect.py)
重点看:检测控制接口有没有直接透传脏口径。
6. [domain-api/app/api/routes/runtime.py](/www/wwwroot/getDomain/domain-api/app/api/routes/runtime.py)
重点看:运行中心接口是否二次加工错误。
7. [domain-api/app/api/routes/dashboard.py](/www/wwwroot/getDomain/domain-api/app/api/routes/dashboard.py)
重点看:首页口径是否和服务层一致。
### P0同步链与投影链
8. [domain-api/app/services/sync_record_service.py](/www/wwwroot/getDomain/domain-api/app/services/sync_record_service.py)
重点看:`runtime_projection``runtime_ingest`、未来时间记录、重复投影、自愈逻辑。
9. [domain-api/app/services/sync_push_service.py](/www/wwwroot/getDomain/domain-api/app/services/sync_push_service.py)
重点看:同步触发、推送条件、失败重试、是否会把旧状态推成新状态。
10. [domain-api/app/services/cluster_runtime_service.py](/www/wwwroot/getDomain/domain-api/app/services/cluster_runtime_service.py)
重点看集群节点汇总、心跳、stale/offline 判定。
11. [domain-api/app/services/debug_event_service.py](/www/wwwroot/getDomain/domain-api/app/services/debug_event_service.py)
重点看:调试事件是否参与运行态推断,是否会误导当前任务。
### P0节点控制与配置分发
12. [domain-api/app/services/worker_control_service.py](/www/wwwroot/getDomain/domain-api/app/services/worker_control_service.py)
重点看worker 进程探测、当前状态读取、systemd 口径和实际进程口径是否一致。
13. [domain-api/app/services/settings_service.py](/www/wwwroot/getDomain/domain-api/app/services/settings_service.py)
重点看:`process_count``thread_count`、节点级覆盖、多实例父子节点映射。
14. [domain-api/app/services/runtime_settings_service.py](/www/wwwroot/getDomain/domain-api/app/services/runtime_settings_service.py)
重点看:运行态配置来源、热配置优先级、页面修改后是否真生效。
15. [domain-api/app/services/runtime_control_service.py](/www/wwwroot/getDomain/domain-api/app/services/runtime_control_service.py)
重点看:启动/停止/恢复对多实例 worker 是否安全。
### P1检测任务主链
16. [domain-api/app/services/detect_run_service.py](/www/wwwroot/getDomain/domain-api/app/services/detect_run_service.py)
重点看运行记录、cycle 事件、页面日志来源。
17. [domain-api/app/services/domains_service.py](/www/wwwroot/getDomain/domain-api/app/services/domains_service.py)
重点看:域名主数据是否和检测任务状态有交叉写入风险。
18. [domain-api/app/services/import_task_service.py](/www/wwwroot/getDomain/domain-api/app/services/import_task_service.py)
重点看:导入任务是否影响 backlog、是否能造成页面统计失真。
## 必看测试
### 直接对应运行态/聚合
1. [domain-api/tests/test_detect_job_service.py](/www/wwwroot/getDomain/domain-api/tests/test_detect_job_service.py)
2. [domain-api/tests/test_detect_service_status_fallback.py](/www/wwwroot/getDomain/domain-api/tests/test_detect_service_status_fallback.py)
3. [domain-api/tests/test_runtime_status_service.py](/www/wwwroot/getDomain/domain-api/tests/test_runtime_status_service.py)
4. [domain-api/tests/test_dashboard_service.py](/www/wwwroot/getDomain/domain-api/tests/test_dashboard_service.py)
### 直接对应同步链
5. [domain-api/tests/test_sync_record_service.py](/www/wwwroot/getDomain/domain-api/tests/test_sync_record_service.py)
6. [domain-api/tests/test_sync_push_service.py](/www/wwwroot/getDomain/domain-api/tests/test_sync_push_service.py)
7. [domain-api/tests/test_cluster_runtime_service.py](/www/wwwroot/getDomain/domain-api/tests/test_cluster_runtime_service.py)
### 直接对应节点控制与配置
8. [domain-api/tests/test_worker_control_service.py](/www/wwwroot/getDomain/domain-api/tests/test_worker_control_service.py)
9. [domain-api/tests/test_settings_service.py](/www/wwwroot/getDomain/domain-api/tests/test_settings_service.py)
10. [domain-api/tests/test_detect_api_routes.py](/www/wwwroot/getDomain/domain-api/tests/test_detect_api_routes.py)
11. [domain-api/tests/test_ops_api_routes.py](/www/wwwroot/getDomain/domain-api/tests/test_ops_api_routes.py)
## 本轮输出要求
只输出这 3 类内容,避免烧额度:
- `P0 / P1` 真实问题,带文件和行号
- 影响范围
- 修复建议
不要在第一轮做这些:
- 大篇架构说明
- 文件逐段复述
- UI 细节优化建议
- 发布脚本和迁移功能深挖
## 第一轮完成标准
满足以下条件就可以结束第一轮,转第二轮:
- 能回答“为什么页面显示会和现场不一致”
- 能回答“为什么 sync 会把旧运行态覆盖成新页面口径”
- 能回答“进程/线程配置、页面显示、节点实际执行三者有没有断层”
- 能列出前 `10` 个最值得先修的 `P0/P1` 问题