Skip to content

fix(copaw-worker): restore model preflight + startup health writes (#1077 regression) - #1130

Open
LUOSENGWA wants to merge 2 commits into
agentscope-ai:mainfrom
LUOSENGWA:fix/copaw-test-cleanup
Open

fix(copaw-worker): restore model preflight + startup health writes (#1077 regression)#1130
LUOSENGWA wants to merge 2 commits into
agentscope-ai:mainfrom
LUOSENGWA:fix/copaw-test-cleanup

Conversation

@LUOSENGWA

@LUOSENGWA LUOSENGWA commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Fixes the 18 baseline copaw/tests failures 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 rewrite
of worker.py dropped the model-preflight import and the whole startup
health-state mechanism (e2fce4a had it; upstream did not preserve it).

Production gap fixed

Readiness previously hard-coded model: "validated at startup" — the model
component 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 on
    failure, without blocking boot)
  • build_worker_readiness() re-checks model / copaw / matrix live on every poll
  • start() records sync / matrix / bridge health in health.json
  • Worker API liveness/readiness server starts during startup
    (build_worker_liveness / build_worker_readiness methods)

Problem B: test_sync.py — 3 failures

  • _get_worker_info() requires the agt CLI, which is not available in a
    bare test container (real worker images copy it) — tests now monkeypatch it
  • fake_mc did not write local files, so the post-mirror openclaw.json
    existence check failed — fake_mc now writes the file

Baseline comparison (full copaw/tests run)

failed passed
before (124f06d) 84 126
after 66 144

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.json
  • Worker API 的 liveness/readiness 服务改为启动期创建(build_worker_liveness / build_worker_readiness 方法)

问题 B:test_sync.py — 3 个失败

  • _get_worker_info() 依赖 agt CLI,裸测试容器里没有(真实 Worker 镜像有)——测试改为 monkeypatch
  • fake_mc 不写本地文件,导致 mirror 后 openclaw.json 存在性检查失败——fake_mc 补上文件写入

基线对比(copaw/tests 全量)

failed passed
修复前(124f06d1) 84 126
修复后 66 144

差值 = 恰好修复 18 个(15 worker_health + 3 sync),零新增失败。worker_health/sync/health 三个文件共 46 个测试全部通过(0.34s)。

说明

剩余 66 个失败(test_taskflow_tool / test_worker_matrix_channel / test_worker_sync)是修复前就存在的上游基线失败,与本改动无关,另行跟踪。

…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.
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant