fix(macos): stop writing legacy config-health.json to prevent migration conflict (fixes #98917)#98928
Conversation
…on conflict The macOS app wrote config-health state to ~/.openclaw/logs/config-health.json every ~3s, preventing migrateLegacyConfigHealth from completing and causing conflict warnings on every CLI/gateway bootstrap. Node core ≥2026.6.x owns config-health state in the shared SQLite config_health_entries table. Replace disk persistence with in-memory cache so anomaly detection still works within a session while the legacy JSON path is no longer written. Fixes openclaw#98917.
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close: the merged replacement at #99039 supersedes this PR with a stronger current-main fix that removes both macOS runtime read and write access to the retired config-health sidecar and adds regression coverage. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Keep the merged #99039 implementation on current main and close this narrower stale branch. So I’m closing this here and keeping the remaining discussion on #99039. Review detailsBest possible solution: Keep the merged #99039 implementation on current main and close this narrower stale branch. Do we have a high-confidence way to reproduce the issue? Yes for the original bug from source and the merged replacement's before/after proof; no current-main failing reproduction remains because current main now keeps macOS config-health state process-local and leaves the JSON sidecar to migration only. Is this the best way to solve the issue? No for this branch. The merged replacement is the better fix because it removes both runtime read and write paths for the retired sidecar and adds focused Swift regression coverage. Security review: Security review cleared: The diff only changes Swift macOS config-health persistence behavior and does not add dependencies, workflows, permissions, secret handling, or downloaded code. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 8229f62ac3be; fix evidence: commit 3ae5e98bf605, main fix timestamp 2026-07-02T12:22:21Z. |
Move nonisolated(unsafe) after private static to satisfy SwiftLint modifierOrder rule (line 10).
Reorder → to match SwiftFormat modifier order expected by the macos-swift CI lane.
e1daacf to
987356c
Compare
|
ClawSweeper applied the proposed close for this PR.
|
|
🦞👀 Reason: structured ClawSweeper close marker: close-required (sha=987356c78c84bae005d0ca9051e284a561fd123b) Usage: |
What Problem This Solves
The macOS app writes config-health state to
~/.openclaw/logs/config-health.jsonevery ~3s while running. Node core ≥2026.6.x owns config-health state in the shared SQLiteconfig_health_entriestable. The legacy JSON writer preventsmigrateLegacyConfigHealthfrom completing and causes a conflict warning on every CLI/gateway bootstrap:The warning appears on every
openclawCLI invocation and gateway start when the Mac app is running. The migration can never clear the file because the Mac app recreates it within ~3s.Why This Change Was Made
The
writeConfigHealthStatefunction inOpenClawConfigFile.swiftatomically writes the config-health JSON on every config read observation. Since Node core now manages this state in SQLite, the Mac app's JSON writer is a legacy holdover that conflicts with the migration.The fix replaces disk persistence with an in-memory cache so that:
lastKnownGoodfingerprintUser Impact
[state-migrations]conflict warning on every CLI/gateway bootstrap for Mac app usersopenclaw doctor --fixcan now complete the config-health migrationEvidence
~/.openclaw/logs/config-health.jsonswift buildswift build, deleted~/.openclaw/logs/config-health.json, ran the built binary for 10 seconds, verified the file was NOT recreatedls ~/.openclaw/logs/config-health.jsonreturns "No such file or directory" after running the app, confirming the legacy writer is disabledswift test)UNUserNotificationCenter); cross-session migration end-to-end with live gatewayReal behavior proof
swift buildinapps/macos/— build succeeds. (2)rm ~/.openclaw/logs/config-health.json— deleted existing file. (3) Ran.build/debug/OpenClawfor 10 seconds. (4) Checkedls ~/.openclaw/logs/config-health.json— file does NOT exist. (5)swift test— all 589 tests pass.Observed result after fix: The legacy JSON file is not created by the macOS app. The in-memory config health cache preserves anomaly detection within a session.
What was not tested: Full GUI app lifecycle with display server; end-to-end migration with live gateway and CLI running simultaneously
AI-assisted (Hermes Agent)