C.W.K.
Lesson 02 of 05 · published

Heartbeat Loop — `_tick()` + LLM Judgment

~11 min · heartbeat, loop

Level 0Curious
0 XP0/52 lessons0/16 achievements
0/100 XP to next level100 XP to go0% complete

The tick

backend/services/heartbeat.py has an async _tick() that runs on a schedule. Each tick:

  1. Skip if Dad is currently chatting (streaming guard, lesson 4).
  2. Run vault auto-indexing (incremental ChromaDB update for changed files).
  3. Read all task files in vault/todos/.
  4. Pass them to an LLM with the current time and recent context.
  5. If the LLM decides to act, execute (could be: send a Telegram message, post to cwk-site, fetch market data, anything).
  6. Update task files based on what was done.

Why an LLM is the right scheduler here

'Every Monday morning unless it's a holiday' is hard to express in cron. 'When the market closes red 3 days in a row' is hard to express in any DSL. An LLM reads the todo + the world state + the recent context and decides. The scheduler isn't the cron — it's the judgment.

Progress

Progress is local-only — sign in to sync across devices.