One message through ZenClaw

    architecture node:

    Representation at this boundary

    Source modules

      Message map

      One thread, two channels — a single agent thread (main.rs) drains the HTTP chat mpsc channel non-blockingly and long-polls Telegram (10 s) in the same loop, so turns are strictly serial across channels. Recognized slash commands are answered locally by the gateway with no LLM call; everything else runs the full ReAct loop. A new message on a chat cancels the turn already running on that chat.
      The storage tiers — in cloud mode the working set lives in a PSRAM cache (core/cloud/cache.rs): session appends update the cached log segment and enqueue it to the replicator, which coalesces by key and PUTs to the S3-compatible bucket with backoff and a dead-letter list; memory, cron, and config writes take the strict path and block on a confirmed PUT. Flash (LittleFS) receives a whole-cache snapshot every 900 s, written to a temp file and renamed into place.
      Idle and offline — with nothing to do, the agent thread sits in its Telegram long poll and the snapshot timer sleeps: always-on, no sleep modes in the ESP32 build. If the bucket is unreachable, eager writes queue and strict writes fail visibly; the next boot restores from the bucket, falls back to the on-flash snapshot, and quarantines any chat it cannot repair. If Wi-Fi is down, no turn can run at all — the model, the channels, and the bucket are all network services.