fix: 降低 worker 健康检查与前端轮询的空闲开销 - #1086
Merged
Merged
Conversation
xerrors
marked this pull request as ready for review
September 28, 2026 07:39
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更说明
修复 #1078 中周期性 worker 健康检查反复导入完整业务运行时、开发环境 Vite 高频文件轮询导致的空闲开销。
bug-fix工程主张与 Owner
worker_health.py拥有 ARQ 心跳键、间隔、TTL 上界与轻量检查入口;worker 和 API readiness 读取同一契约。python -m yuxi.services.worker_health。探针通过 Redis transaction 读取 GET/PTTL;空值、缺失、过期、永久、超长租约或连接异常均失败。日志不输出 DSN/异常内容中的凭据。web/vite.config.js拥有轮询频率;保留 polling 以兼容 Docker/Windows 文件挂载。验证情况
探针不加载业务执行依赖且保留租约失败语义
/repo,在/repo/backend设置PYTHONPATH=/repo/backend/package后执行:python -m pytest -p no:cacheprovider test/unit/services/test_worker_health.py test/unit/services/test_readiness_service.py test/unit/config/test_docker_compose_checkpointer.py -q:33 passed。python -m pytest -p no:cacheprovider --confcutdir=test/integration/services test/integration/services/test_worker_health_redis.py -q:6 passed,连接独占临时 Redis。该 selector 排除无关全局 API/沙盒清理 fixture,保留随机测试键的创建与清理。python -m pytest -p no:cacheprovider test/unit -m 'not slow':2428 passed、7 subtests passed;设置YUXI_SKILL_PROJECTION_DIR=/tmp/1078-skill-projections供容器写入。健康检查进程开销下降
arq --check server.worker_main.WorkerSettings与python -m yuxi.services.worker_health各 3 次;每次预置有效 6 秒心跳,使用perf_counter与getrusage(RUSAGE_CHILDREN)读取 wall/CPU 时间。Vite 轮询仍发送更新
npm run lint:check、npm run test:unit(380 passed)、npm run build;Vite createServer 加载当前配置,对临时模块 transformRequest 后修改文件,等待 ws.send 的 update 消息。工程与文档门禁
python3 scripts/verify_engineering_contracts.py、python3 -m unittest scripts.test_verify_engineering_contracts(62 passed)、uvx ruff check(本次修改的 Python 文件)、uvx ruff format --check(新增 Python 文件)、cd docs && npm run build、git diff --check。简化 / 删除验收
不涉及。
独立语义 Review
已调用全新、无历史会话的 pi,只启用 read/grep/find/ls 工具。覆盖完整需求、根与子树规范、完整 diff(含新增文件)、相关源码、实际测试日志和未验证范围。结论:没有探针逻辑、Compose 接线、Vite polling 或共享心跳语义问题;唯一 P3 是清理 Vite 验证生成的临时文件。该文件已删除,最终提交范围已复核,没有未解决 findings。
未验证范围与风险
.env和运行中的 Compose 服务,要求的docker compose exec api uv run --group test pytest test/unit -m 'not slow'在配置插值阶段失败;上述后端检查改用已有 API 镜像的临时容器挂载本工作树执行。首次全量测试因容器 skill-projections 目录不可写失败,设置独立可写目录后全部通过。事故反馈
未达到高影响事故复盘门槛;已补充针对性回归与决策记录。
界面变更
不涉及产品界面或交互;开发服务器文件轮询频率调整。
关联事项
Closes #1078
补充说明
以 xerrors 身份提交 Draft PR;不合并。运行环境需重建生产镜像或重建相关开发容器,以应用新的 Compose 健康检查和 Vite 配置。