fix(copaw-worker): restore model preflight + startup health writes (#1077 regression) - #1130
Open
LUOSENGWA wants to merge 2 commits into
Open
fix(copaw-worker): restore model preflight + startup health writes (#1077 regression)#1130LUOSENGWA wants to merge 2 commits into
LUOSENGWA wants to merge 2 commits into
Conversation
…gentscope-ai#1077 regression) Restore the health-state mechanism that upstream agentscope-ai#1077 dropped when it rewrote worker.py. The 15 test_worker_health.py failures all stemmed from that rewrite: tests patch 'copaw_worker.worker.check_model_service' but the worker no longer imported it, and start() no longer wrote component health (sync/matrix/model/bridge) to health.json. Production gap fixed: readiness previously hard-coded 'model: validated at startup' (readiness false-positive when the model provider is down). Now startup runs a real model preflight (records health + Matrix notify on failure, without blocking boot) and readiness re-checks model/ copaw/ matrix live on every poll. Changes: - worker.py: re-add check_model_service + HealthState wiring; start() creates self._health, records sync/matrix/model/bridge health, passes health into sync_loop/push_loop, and starts the Worker API server (build_worker_liveness/build_worker_readiness methods) - worker.py: restore _notify_matrix/_wait_for_matrix_rooms/ _accept_matrix_invites used by the model preflight failure path - worker.py: _run_copaw_with_console marks copaw unhealthy when the app exits unexpectedly; _mark_copaw_startup_health probes the app endpoint - tests: test_worker_health.py collapse the 12x5s mirror-retry wait; test_sync.py monkeypatch _get_worker_info where agt CLI is unavailable and make fake_mc write openclaw.json so the post-mirror check passes Baseline comparison (copaw/tests full run): 84 failed before -> 66 failed after, delta == exactly the 18 fixed (15 worker_health + 3 sync), zero new failures. All 46 tests in worker_health/sync/health now pass.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
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.
Fixes the 18 baseline
copaw/testsfailures left behind by the #1077 Worker rewrite.Problem A: test_worker_health.py — 15 failures
The tests patch
copaw_worker.worker.check_model_service, but #1077's rewriteof
worker.pydropped the model-preflight import and the whole startuphealth-state mechanism (e2fce4a had it; upstream did not preserve it).
Production gap fixed
Readiness previously hard-coded
model: "validated at startup"— the modelcomponent was never actually checked, so a Worker stayed "ready" while the
model provider was down (readiness false-positive). Now:
start()runs a real model preflight (records health + Matrix notify onfailure, without blocking boot)
build_worker_readiness()re-checks model / copaw / matrix live on every pollstart()records sync / matrix / bridge health inhealth.json(
build_worker_liveness/build_worker_readinessmethods)Problem B: test_sync.py — 3 failures
_get_worker_info()requires theagtCLI, which is not available in abare test container (real worker images copy it) — tests now monkeypatch it
fake_mcdid not write local files, so the post-mirroropenclaw.jsonexistence check failed — fake_mc now writes the file
Baseline comparison (full copaw/tests run)
Delta == exactly the 18 fixed (15 worker_health + 3 sync), zero new
failures. All 46 tests in worker_health/sync/health now pass (0.34s).
Note
The remaining 66 failures (test_taskflow_tool / test_worker_matrix_channel /
test_worker_sync) are pre-existing upstream baseline failures unrelated to
this change; they are tracked separately.
问题 A:
test_worker_health.py— 15 个失败测试 patch 了
copaw_worker.worker.check_model_service,但 #1077 重写worker.py时丢掉了 model preflight 的 import 和整套启动期 health-state 机制(e2fce4a中曾存在,上游未保留)——功能回归。修复的生产缺口
修复前 readiness 硬编码
model: "validated at startup"——model 组件从不真正检查,model 服务挂了 Worker 仍显示 ready(readiness 假阳性)。现在:start()执行真实 model preflight(写入 health + 失败时 Matrix 通知,但不阻塞启动)build_worker_readiness()每次轮询时对 model / copaw / matrix 做实时检查start()将 sync / matrix / bridge 组件健康状态写入health.jsonbuild_worker_liveness/build_worker_readiness方法)问题 B:
test_sync.py— 3 个失败_get_worker_info()依赖agtCLI,裸测试容器里没有(真实 Worker 镜像有)——测试改为 monkeypatchfake_mc不写本地文件,导致 mirror 后openclaw.json存在性检查失败——fake_mc 补上文件写入基线对比(copaw/tests 全量)
差值 = 恰好修复 18 个(15 worker_health + 3 sync),零新增失败。worker_health/sync/health 三个文件共 46 个测试全部通过(0.34s)。
说明
剩余 66 个失败(test_taskflow_tool / test_worker_matrix_channel / test_worker_sync)是修复前就存在的上游基线失败,与本改动无关,另行跟踪。