Skip to content

fix(controller): seed config writer cache from disk on cold start#349

Merged
lefarcen merged 1 commit intomainfrom
fix/config-writer-cold-start-cache
Mar 22, 2026
Merged

fix(controller): seed config writer cache from disk on cold start#349
lefarcen merged 1 commit intomainfrom
fix/config-writer-cold-start-cache

Conversation

@alchemistklk
Copy link
Copy Markdown
Contributor

Summary

  • Follows up on fix(controller): skip redundant config writes to break Feishu restart loop #347 — on process restart, lastWrittenContent is null, so the first write() always writes to disk even if the file already has identical content
  • Fix: read the existing config file to seed the in-memory cache on the first write() call
  • This eliminates the unnecessary OpenClaw reload that happened on every controller cold start

Test plan

  • New test: new writer instance seeds cache from existing file (skips write)
  • New test: new writer instance writes when content differs from existing file
  • New test: cold start with no existing file writes normally
  • Existing tests still pass (8/8)
  • Manual: restart controller and verify no unnecessary OpenClaw reload in logs (openclaw_config_write_skipped_unchanged should appear)

🤖 Generated with Claude Code

On process restart, lastWrittenContent is null, causing the first write()
to always hit disk even if the config file already has identical content.
This triggers an unnecessary OpenClaw reload on every controller restart.

Read the existing file to seed the in-memory cache on the first write()
call, so cold starts skip the write when content matches.
@alchemistklk
Copy link
Copy Markdown
Contributor Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Reviewed: empty catch block scope, sentinel reset behavior, documentation maintenance obligations, test coverage changes, mtime-based test assertions, and watchTrigger interaction. All issues scored below confidence threshold (highest was 75/100 for the bare catch block and docs — both borderline and unlikely to cause real problems in practice).

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@alchemistklk
Copy link
Copy Markdown
Contributor Author

/cr

@slack-code-review-channel
Copy link
Copy Markdown

✅ CR topic created in Feishu topic group Refly CR.

@lefarcen lefarcen merged commit 4b24ce9 into main Mar 22, 2026
4 checks passed
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.

2 participants