cryochamber
CLAUDE.md34 starsChanged 7 months agoMITView on GitHub
Developer guidance for Claude Code (claude.ai/code) when working on this repository. For project overview and usage, see README.md. Scope note: Most of this document's normative content is duplicated where its real audiences can see it: templates/protocol.md (for in-chamber agents — injected into every wake prompt) and docs/src/explanation/ (for end users). What lives only here is maintainer-facing design rationale — why a rule exists, not how to follow it. When changing an operational contract, land the change in those user-visible surfaces…
- Reads credentials
- Installs packages
In this repository7 other files it gives its agents.
- AGENTS.mdAGENTS.md
- chat-bridgeSkill
- daemon-state-diagramSkill
- fix-prSkill
- make-planSkill
- releaseSkill
- review-implementationSkill
The file
We split this CLAUDE.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 59
Verify with codex login status.
- Very specific: line 135
Every TODO is honoured, and every failure is reported: When a TODO's at time arrives the daemon claims it and runs a session.
- Very specific: line 170
Chamber-authored messages: All daemon-originated outbox messages use a single from: cryochamber sender for fallback replies when the agent …
- Distinctive: line 267
Do not commit implementation plans.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
Developer guidance for Claude Code (claude.ai/code) when working on this repository.
For project overview and usage, see README.md.
Scope note: Most of this document's normative content is duplicated where its real audiences can see it:
templates/protocol.md(for in-chamber agents — injected into every wake prompt) anddocs/src/explanation/(for end users). What lives only here is maintainer-facing design rationale — why a rule exists, not how to follow it. When changing an operational contract, land the change in those user-visible surfaces first, then mirror it here.
Build & Test
cargo build # build
cargo test # run all tests
cargo test daemon::tests # run a single test module
cargo test test_event_logger # run a single test by name
cargo fmt --all # format
cargo clippy --all-targets -- -D warnings # lint (warnings are errors)Make Targets
make check # fmt-check + clippy + test + console-check + bridge-check
make build # cargo build
make test # cargo test
make fmt # cargo fmt
make clippy # cargo clippy (warnings are errors)
make console-check # type-check and unit-test the Agent Console (npm ci, tsc, vitest)
make bridge-check # Python chat-bridge tests, no external accounts required
make coverage # generate coverage report (auto-installs cargo-llvm-cov)
make cli # cargo install --path .
make console-build # build the Agent Console (embedded into cryohub on the next cargo build)
make app-dev # run the native shell against the Vite dev server (requires tauri-cli)
make app-macos # build the macOS app bundle + dmg from the production console build
make app-android # build the arm64 Android APK
make app-check # fmt-check + clippy + test the native shell crate (app/src-tauri)
make logo # compile logo with typst
make example # run an example (DIR=examples/chambers/mr-lazy or .../chess-by-mail)
make example-start-all # start all example chambers (AGENT=pi|opencode|claude)
make example-cancel # stop a running example (DIR=examples/chambers/...)
make example-hub # start global cryohub in foreground (PORT=8765)
make example-clean # remove auto-generated files from all examples
make run-plan # execute a plan with Codex by default (RUNNER=claude for Claude)
make check-agent # quick agent smoke test (AGENT=pi|opencode|claude)
make check-round-trip # full round-trip test with mr-lazy
make check-service # verify OS service install/uninstall lifecycle (launchd/systemd)
make check-mock # run mock agent integration tests (no external agent required)
make book # build mdbook documentation (English + Chinese)
make book-serve # serve the built book (both languages) at :3000
make book-serve-live # mdbook serve with live reload (English only)
make book-deploy # deploy mdbook to GitHub Pages (gh-pages branch)
make copilot-review # request Copilot code review on current PR
make release V=x.y.z # tag and push a release (triggers CI publish to crates.io)Codex CLI (for make run-plan)
make run-plan invokes codex exec on the latest plan in docs/plans/ (default RUNNER=codex).
Auth: codex login (ChatGPT) or printenv OPENAI_API_KEY | codex login --with-api-key.
Verify with codex login status. Override model via CODEX_MODEL=gpt-5.5 make run-plan,
switch runner via AGENT_TYPE=claude make run-plan. Output goes to run-plan-output.log.
Architecture
Core Loop
cmd_start() → spawn cryo daemon → event loop: spawn agent → listen on socket server for IPC commands → sleep until wake time or inbox event → run session → ...
Binaries
| Binary | Purpose |
cryo | Operator CLI — init, start, status, cancel, clean, log, watch, send, receive, ps, restart, daemon |
cryo-agent | Agent-side IPC/utility CLI — hibernate, send, receive, dialog, time, todo (used by the spawned agent, not by operators; most commands send requests to the daemon via socket, while time is local) |
cryo-zulip | Zulip sync CLI — init, pull, push, sync, unsync, status (manages Zulip stream messaging via OS service) |
cryohub | Global web dashboard — start [--host --port --foreground --public|--no-public], stop, restart, status, token {owner,create,list,revoke}, daemon (daemon is internal — start installs a launchd/systemd service that serves the Agent Console and /api over HTTP; token manages the bearer-auth store). |
Modules
| Module | Purpose |
socket | Unix domain socket IPC — message types (Request/Response), client (send_request), server (SocketServer). |
config | TOML persistence for project config (cryo.toml). CryoConfig struct, load/save, apply_overrides merges CLI overrides from state. |
state | JSON persistence to timer.json — runtime-only state (session number, PID lock, CLI overrides). PID-based locking via libc::kill(pid, 0). |
log | Session log manager. Sessions delimited by --- CRYO SESSION N --- / --- CRYO END ---. EventLogger writes timestamped events (agent start, hibernate, exit), and hub status derives daily digests from the same log. |
protocol | Loads templates from templates/ via include_str! (protocol, plan, cryo.toml). Written by init/start. |
agent | Builds lightweight prompt with task + session context, spawns agent subprocess (stdout/stderr redirected to cryo-agent.log). |
process | Process management utilities: send_signal, terminate_pid, spawn_daemon. |
session | Legacy utility module (should_copy_plan). Currently unused — plan.md must exist in the working directory. |
daemon | Persistent event loop: socket server for agent IPC, watches messages/inbox/ via notify, enforces session timeout, EventLogger for structured logs, consumes past-due TODOs before each session, re-injects them with a (attempt k) suffix and 2^k-minute delay (capped at 1 day) on crash, detects delayed wakes (e.g. after machine suspend), and coordinates the active-session inbox claim/send/fallback lifecycle. It notices when inbox messages exist but never previews bodies in the wake prompt. |
message | File-based inbox/outbox message system. Agent-side cryo-agent receive goes through daemon IPC and claims one conversation, grouped by the first pending message's thread_id or the unthreaded main stream. It archives that group into messages/inbox/archive/ immediately via MessageStore. The current session tracks the conversation; a durable obligation backs restart notification. Operator cryo receive is separate: it reads messages from messages/outbox/. |
channel | Channel abstraction. Submodules: store (local inbox/outbox), zulip (Zulip REST API). Attachments cross the boundary symmetrically. On pull, localize_upload_links downloads /user_uploads/ files (authenticated, 25 MB cap) into messages/attachments/ and rewrites inbox links to those local paths, so vision agents can read uploaded images. On push, externalize_local_links uploads chamber-local files an agent linked to and rewrites the link to the returned /user_uploads/ path. Both directions are best-effort: a failure leaves the link untouched and never fails the sync cycle. |
registry | User chamber registry for Cryohub discovery. Uses $XDG_STATE_HOME/cryo/chambers/ (fallback ~/.cryo/chambers/), keeps stopped chambers, clears stale PIDs, and prunes entries whose chamber disappeared. |
service | OS service management: install/uninstall launchd (macOS) or systemd (Linux) user services. Used by cryo start and cryo-zulip sync for reboot-persistent daemons. CRYO_NO_SERVICE=1 disables (falls back to direct spawn). |
todo | Per-project TODO list persistence (todo.json). TodoItem/TodoFile structs plus retry rescheduling logic for crashed sessions. Mutated through daemon IPC so scheduling changes are serialized with the session lifecycle. |
zulip_sync | Zulip sync state persistence (zulip-sync.json). |
hub | Global web dashboard: Axum router (serve, build_router_with_state), registry-backed chamber discovery, SSE events, start/stop/restart handlers. Served by the cryohub binary. |
Chamber Invariants
Four guarantees the daemon must preserve. Every change to the session lifecycle, inbox handling, or TODO scheduling must be checked against them. If a proposed change would violate one, it is wrong by default and needs an explicit justification.
- Every wake produces at least one visible message to the user. If
the agent exits without calling
cryo-agent send, the daemon writes afrom: cryochamberfallback so the operator always has something to look at for that wake (daemon_missing_outbound_textinsrc/daemon.rs). Retryable agent-runner failures before any outbound message or inbox claim may defer this fallback across the bounded in-daemon retry loop; after retries are exhausted the fallback is mandatory. Silent finalized wakes are a bug. Scope: a "wake" here is a wake that starts a session. A scheduled fire that claims no due TODO and finds a verified-empty inbox starts no session (demand-driven wakes) — there is no work to report and no claimed TODO to honour; the skip itself is logged tocryo.log. Bootstrap and inbox wakes always start a session. - Every inbox message is answered — by the agent or by the
chamber. An agent crash mid-processing is acceptable; leaving
the sender with no reply is not. If a session ends with a received
conversation still unanswered, the daemon writes the fallback reply from
daemon_unanswered_reply_textfor that conversation (finalize_human_replies). Filesystem effects persist a reply obligation in.cryo/reply-obligation.jsonbefore archiving. After a hard daemon stop, startup finishes any partial archive. If no durable reply receipt exists in outbox or its archive, startup writes an interruption notice in the claimed thread when applicable. The sender decides whether to resend; external work is never automatically replayed. Corrupt journals fail startup without discarding evidence. The hibernate quietness gate enforces the front half of this: a session cannot end in a clean hibernate while unread mail exists, so mail present at hibernate time is answered by the live agent when the agent behaves — a crash, failure report (--exit N), timeout, or shutdown still ends the session and leaves that mail unread for a future session. - Every TODO is honoured, and every failure is reported. When a
TODO's
attime arrives the daemon claims it and runs a session. The claimed item stays visible as[~]in## TODO Listwhile the session is active, but the scheduler ignores it so the same wake does not loop. If the session succeeds, the daemon marks the claimed item done. If that session crashes,reschedule_claimed_after_crashmarks the original done and creates a new TODO with an(attempt k)suffix and a2^k-minute delay capped at 1 day, so the task keeps being retried and the operator can see how many attempts have been made. A manually-completed TODO (cryo-agent todo done) is the only way to stop the retry cycle short of a successful session. - Claim/consumption is terminal — a picked-up message or TODO
never returns to pending, regardless of whether processing
succeeded. An
inbox conversation read by
cryo-agent receiveorcryo-agent dialogis archived intomessages/inbox/archive/immediately and is never re-delivered or restored to the inbox. A TODO claimed for a session is never moved back to plain pending: successful sessions mark it done, and failed sessions mark it done plus add a fresh retry item. Retries are always implemented as new items with fresh IDs, not by reopening the original. This prevents the same trigger from re-spawning the agent on every subsequent wake tick and keeps the retry count honest. If a human still wants action on an unanswered message, they resend.
Key Design Decisions
- Daemon mode:
cryo startinstalls an OS service (launchd on macOS, systemd on Linux) that survives reboots. The daemon sleeps until the scheduled wake time, watchesmessages/inbox/for reactive wake, and enforces session timeout. SetCRYO_NO_SERVICE=1to fall back to direct background process spawn. - Socket-based IPC: The agent communicates with the daemon via
cryo-agentCLI subcommands (hibernate,send,receive,todo), which send JSON messages over a Unix domain socket. Onlytimeis purely local. - Fire-and-forget agent: The daemon spawns the agent and redirects its stdout/stderr to
cryo-agent.log. Stdout/stderr are diagnostic logs, not a human communication channel. All structured communication flows throughcryo-agent. - No forced-wake command: there is no
cryo wakeand no SIGUSR1 wake path. A chamber wakes for its schedule (todo.json), for mail (thewatch_dirsinbox watcher), or at daemon start.cryo sendis how an operator reaches the agent — it carries intent and is guaranteed a reply (invariant 2);cryo restartcovers the message-less "kick it now" case via the bootstrap session. Do not reintroduce a bare wake signal. - Reactive wake via
watch_dirs:cryo.tomlcarries a listwatch_dirs(default["messages/inbox"]) of directories the daemon attaches a notify watcher to. New files in any watched directory wake the agent, equivalent to inbox-triggered wake. Empty list disables reactive wake. Do not reintroducewatch_inboxcompatibility. - Config/state split:
cryo.tomlis the project config (agent, session timeout, watch_dirs, provider env) created bycryo init.timer.jsonis runtime-only state (session number, PID, CLI overrides). CLI flags tocryo startare stored as optional overrides intimer.json. - Provider config: Cryochamber supports a single active provider profile. The canonical TOML shape is
[provider]with anenv = { ... }map, injected into every spawned agent session. Legacy[[providers]]arrays are accepted only for backward compatibility: loading them emits a deprecation warning, the first entry is used, and saving canonicalizes back to[provider]. Provider rotation has been removed; do not reintroduceprovider_index,rotate_on, or multi-provider retry behavior. - Chamber-authored messages: All daemon-originated outbox messages use a single
from: cryochambersender for fallback replies when the agent never sends a human-visible message after claiming inbox, or crashes after retry exhaustion. Agent-authored human-visible messages usefrom: agent. - Preflight validation:
cryo start, Hub lifecycle starts, Console settings updates, and an explicitcryohub start --default-agentcheck that the agent command exists on PATH before spawning or saving. The Console's create-and-start route performs this check before scaffolding so a missing executable cannot leave a partial chamber. Every hub-side check goes through the singlehub::lifecycle::validate_agent_command, which searches the PATH a session actually gets — thecryobinary's directory prepended, asagent.rsdoes it — so a runner installed next tocryois never refused at save time and then accepted at start time. An unresolvablecryonarrows that search back to the plain PATH rather than failing the command: the lifecycle action that needs the binary reports its absence in its own words. - Chamber resolution via
CRYO_CHAMBER_DIR: all binaries resolve the chamber fromCRYO_CHAMBER_DIRwhen set, else cwd (work_dir()insrc/lib.rs). The daemon injects the variable into every spawned agent session, socryo-agentreaches the right chamber no matter what cwd the agent's shell tool uses (a wrong cwd used to route IPC to another chamber's socket).cryo-agentadditionally preflightsensure_chamber_dirfor every command except the local-onlytime, so a non-chamber directory fails with the real reason instead of a "Daemon instance mismatch" red herring. - Crash handling via retry and TODO re-injection: Retryable agent-runner exits before any outbound message or inbox claim get an in-daemon retry loop: up to 10 retries after the first attempt, with exponentially increasing gaps. If the final attempt still fails, or if the agent exits without calling
cryo-agent hibernateafter consuming work, the daemon records the crash and re-injects any TODOs it claimed for that wake with a(attempt k)suffix and an exponential delay (2^kmin, capped at 1 day). TODO rescheduling lives intodo.json, surviving daemon restarts and visible to both agent and operator. EventLogger is always finalized for each attempt. - Attachments are a channel concern, not an agent concern: the agent only ever deals in chamber-local file paths — it reads pulled attachments from
messages/attachments/and links to local files when sending. Uploading, downloading, and per-server markdown quirks live in the sync binary. The Console composer stages at most 10 attachments of at most 25 MB each, supports picker/drop/paste, previews, removal, progress, retry, and file-only sends, and uploads them serially through the existing authenticated route. It persists ready upload references with the text draft, but never browserFilebytes for queued or in-flight uploads. Notablyexternalize_local_linksrewrites upload links to absolute URLs and strips the!from; both are required for an inline preview (verified on Zulip 11.4): the preview pass only matches absolute upload URLs, and CommonMark image syntax renders literally before server 12.0 (feature level 437). Do not push channel-specific syntax intocryo-agent sendor the protocol; do not let either sync implementation upload anything outside the chamber, under.cryo/, or namedcryo.toml(these hold bot or provider API keys). - Inbox and thread contract: There is no
cryo-agent reply. Wake prompts do not include inbox contents; the daemon only checks whether inbox files exist so it can surface a notice in the session prompt. During an agent session,cryo-agent receiveandcryo-agent dialogask the daemon to claim one conversation: all currently pending messages whosethread_idmatches the first pending message, or all unthreaded messages when the first message has none. The daemon archives that group immediately. A durable pending obligation fixes the active conversation, so later claims can extend it with new messages from the same thread but cannot claim a different thread or the main stream before a reply. A new thread claim includes the root and full thread history even when adialog --lastor--sincefilter would omit part of it; subsequent dialog reads filter to the active thread and apply the requested limit normally. Bodies returned byreceiveanddialog, including thread context, rewrite/api/chambers/.../files/...links to chamber-localmessages/attachments/...paths. The next successfulcryo-agent sendis the reply by definition and automatically inherits the activethread_id; daemon fallback and interruption replies do the same. Archive-on-claim is terminal and inbox messages are never replayed. Only TODOs have retry semantics. If the human still wants action, they resend. - Default agent and host override: Pi is the built-in default.
HubConfig.default_agentin host-levelcryohub.tomlis the scaffold default for both plaincryo initand the Console's New Chamber flow. Owners can update it through/api/config, the Console Settings sheet, orcryohub start --default-agent;cryo init --agentis the explicit per-scaffold override, and every created chamber still records its selected command incryo.tomlso later host changes never rewrite existing chambers. A chamber's own runner is changed through owner-onlyPOST /api/chambers/{id}/agent(the Console's chamber Settings sheet), which writesagentinto that chamber'scryo.tomland reportsrestart_required— the daemon readscryo.tomlonce at start, so a live chamber keeps its runner until restarted, and the hub never restarts a session to apply a setting. Both Console settings surfaces validate that the parsed command's executable exists on the Hub host before saving, through the samehub::lifecycle::validate_agent_commanda lifecycle start uses. The Console's dropdown list (console/src/api/agents.ts) mirrors the runnersresolve_agentknows, minusmock, and always keeps the saved value as an option so a hand-written command is never silently rewritten. - Agent notes via
NOTES.md: The agent's persistent memory across sessions is a plain markdown file (NOTES.md) the agent reads and writes directly — no IPC roundtrip. Seeded bycryo init, surfaced in the hub's Notes drawer tab, and updated by the agent on its own. The removedcryo-agent notesubcommand andRequest::NoteIPC variant are historical. cryo-agent timeinput grammar: Accepts three forms only — empty (current time),+N minutes|hours|days|weeks(relative offset), and ISO8601 (2026-04-25T10:00or date-only) as validated pass-through. Natural-language parsing is deliberately not supported: the agent is an LLM that can reason about "tomorrow 9am" itself, so the tool stays small and documentable. Unknown input prints the accepted forms.cryohubis global and registry-backed: Thecryohubbinary (notcryo) runs one global web dashboard per user and can start, stop, and report status from any directory. Product discovery reads the user chamber registry only; it does not scan the current working directory. Host, port, and the dashboard-created chamber root live inhub::config::HubConfigat$XDG_CONFIG_HOME/cryo/cryohub.toml(fallback~/.config/cryo/cryohub.toml); default host/port are127.0.0.1:8765, and the default chamber root is~/.cryo/chambers.cryohub start --host/--portupdates the saved hub config. The service label is"hub"anchored tohub::paths::hub_service_dir()socryohub stopworks from arbitrary directories. The log file lives under the user-level Cryo state/log directory viahub::paths::hub_log_path().cryohub statusalso lists legacy cwd-scopedcom.cryo.hub.*services from older versions. Per-chamberweb_host/web_portfields are not part ofCryoConfig.- The Agent Console is the hub's only web surface: the bundled
web_shell.htmldashboard,templates/web.cssandtemplates/vendor/*(KaTeX, marked, DOMPurify, the woff2 fonts) are gone, along withhub::routes::pagesandhub::routes::fonts. The hub registers no page routes at all;hub::routes::console::serveis the router's unconditional fallback and owns everything outside/api. The console ships inside the binary:rust-embedoverconsole/dist/(whichbuild.rscreates empty when absent, so a git build without Node compiles), packaged via theCargo.tomlincludewhitelist and built by the release workflow beforecargo publish.console_dirincryohub.tomlis the single override (must be absolute; refused atcryohub startotherwise) — there is no~/.cryo/consoleand nomake console-install;make console-buildjust runs the Vite build. Resolution isConsoleSource::Dirifconsole_diris set, elseConsoleSource::Embedded, decided per request. A source with noindex.htmlanswers pages with a self-contained 503 setup page; a missing hashed asset stays a 404, because answering it with HTML would break the module loader. Serving contract:/assets/*immutable for a year, everything elseno-cache, ETag/304, 405 for non-GET/HEAD, CSP on HTML,nosniff+no-referreron every hub response./api/whoamicarrieshub_version(== console version by construction) and the owner'sname. Message bodies retain Markdown plus inline and display LaTeX rendering. Thread reads derive their focused view by scanning mailbox history; this has no performance SLO, and an index should be added only if large histories make the scan slow. Share to stream copies a thread reply to the outbox withshared_frommetadata for display. It must never write the local inbox, wake the agent, or create a reply obligation. Do not reintroduce a server-rendered dashboard, and do not vendor client-side libraries intotemplates/— the console bundles its own through npm. - Bearer auth ("public mode") is the hub's default:
HubConfig.publicdefaults totrue; every/apiroute requiresAuthorization: Bearer <token>, and the console signs in with a token (owner or invite link#invite=<token>). The store is~/.config/cryo/cryohub-tokens.json(mode 0600,hub::tokens): one owner token plus named invites scoped to chamber ids, revoked by tombstone (revoked_at) so the audit trail survives; roles areOwner/Invite { name, chambers }(hub::auth), and a guest gets403on anything outside their chambers, including/api/tokens.cryohub startmints a missing owner token before binding or installing the service (ensure_owner_token) and prints it only at the terminal (announce_owner_token, called fromcmd_startalone);serve()and the service path never print a secret, because a service's stdout is a world-readable log —cryohub token ownerreprints it, and invite tokens are printed exactly once attoken create.--no-publicis an explicit, saved opt-out (open mode: loopback only, no sharing); a plaincryohub startkeeps whatever mode is saved, and thedaemonsubcommand only overlays flags in memory — a boot is not a configuration act. Guards live inhub::security(host allowlist = loopback + bind host +public_hostsfor a reverse proxy, CSRF header on writes,nosniff+no-referreron every response) andhub::ratelimit(per-credential GCRA on sends/uploads in public mode only →429with a whole-secondRetry-After; open mode has no bucket).cryohub.tomlisdeny_unknown_fieldsand saved atomically. Do not add cookie/session auth, and do not print tokens anywhere a log can catch them. - Editable chamber files are the operator's, not the agent's: the console writes
plan.md(owner-onlyPOST /api/chambers/{id}/plan,MAX_PLAN_BYTES= 1 MiB, CRLF normalised, trailing newline added, empty accepted as empty) because the plan is the operator's brief;NOTES.mdstays read-only because it is the agent's own memory. No restart and no daemon involvement: the agent is told to readplan.mdat the top of every session, so the next wake sees it. Last write wins — there is no revision token, because the other writer is an agent instructed to keep its state inNOTES.md. The rawplan_contentships in the status payload (a plan holds no credentials);cryo.tomlstill never does. - The console never lets the browser fetch hub files unauthenticated:
/api/chambers/{id}/files/{name}needs the bearer, soMessageBodyparks a hub image'ssrcindata-upload-src(deferHubImages) and only the authenticated blob swap setssrc; a resolved blob lands on every<img>wanting that file, whatever happened to the effect that started the fetch (React re-setsinnerHTMLon re-render, and the old observer can claim the fresh node first). Downloads and the lightbox go through the same fetcher. The console has no message-sync surface —/api/chambers/{id}/sync*stay on the server for other clients — and the chamber controls sheet is state + actions + detail sheets (Todos · Plan · Notes · Settings · Log; session number, last-session summary and daily digests head the Log sheet). - Hub chamber creation: The console's New Chamber sheet scaffolds and starts chambers with the host-level default agent in one action.
POST /api/chambers/newkeepsstartoptional and false by default for older API clients. A preflight failure creates nothing; a failure after successful scaffolding returns the chamber id plusstart_error, keeps the chamber, and lets the Console surface the warning. The optional API key provider section is folded and writes onlycryo.toml; do not create runner-specific sidecar config. Provider and model are free-text inputs so custom providers/models keep working; server-side code should validate provider ids and map them to API-key environment variable names, but must not carry a hardcoded model catalog. Runner-specific selection belongs in the command/environment written tocryo.tomland must not replace the host-selected runner. Cryohub knows how to wire a model intoopencode(env) andpi(flags) only; an API key is universal, so a model chosen for any other host runner is refused with a400before the chamber directory is created rather than written nowhere and silently ignored. - The reply window is the only waiting mechanism: there is no agent-chosen wait (
cryo-agent receive --waitandRequest::ReceiveWaitare gone). The agent never blocks on the operator; it finishes, asks to sleep, and the daemon decides when the sleep happens. (hibernate --lingerdoes not contradict this: the agent passes a duration hint on the call that ends its session; it is still the daemon that parks, releases, and decides.) A conversation is carried by the loop hibernate refused/rejected →receive→send→hibernate, which re-arms the window each round. Long-gap conversations legitimately span sessions and are reconstructed from the dialog archive (cryo-agent dialog), not held open by a blocked process. - Hibernate quietness gate & reply window: hibernate is granted only when the chamber is quiet — unconditionally refused while unread inbox mail exists (
--completeadditionally while a TODO is due;--exit Nfailure reports are never gated) — and, when the window is nonzero, the daemon parks the accepted hibernate (holding the operator-facing socket responder; hibernate is the only call that parks). The window duration is agent-chosen per hibernate:cryo-agent hibernate --linger <secs>(min(requested, 86400); flag absent = 300;0= sleep immediately;--lingerconflicts with--complete/--exit, which never park). There is no config knob — the agent has the context (question asked vs. routine status) that a chamber-wide constant cannot capture, and an operator steers lingering throughplan.mdinstructions instead. Constants live insrc/daemon/request.rs(DEFAULT_LINGER_SECS,MAX_LINGER_SECS). Mail arrival rejects the parked call back into the same agent process (notice only — the agent still claims viareceive; delivery clearshibernate_outcomeso a later crash is a real crash); a due TODO or window expiry grants the sleep (TODOs always run in fresh sessions — never delivered into a linger, keeping invariant 3's one-session-one-attempt accounting). Every failure mode (runner shell-timeout kills the parked client, daemon restart, crash mid-window) degrades to today's fresh-session behavior. See issue #71. - Scheduled wakes are demand-driven: the daemon's cached
next_wakeonly decides when to re-checktodo.json; whether a session runs is decided by what the wake actually claims. A scheduled wake that claims no due TODO and finds an empty inbox runs nothing — the daemon resyncsnext_wakefrom disk and sleeps (pacing retries viaTODO_CLAIM_RETRY_DELAYif disk still shows past-due work thatclaim_duefailed to persist). Bootstrap and inbox wakes are explicit demand and always run. This makes a stale wake-time cache cost a file read instead of an agent session; the 2026-04-21 incident (a pre-fix binary spun ~678 spurious sessions in 9 hours) is the motivating failure shape, reproduced intest_stale_scheduled_wake_with_no_due_work_skips_session_and_resyncs. - Bounded TODO list in the wake prompt: the per-session prompt renders TODOs via
TodoFile::display_for_prompt, which always shows pending/claimed items but folds all except the last 3 completed items (in list order ≈ creation order; completion times are not tracked) behind a count — done items are never deleted, so the full list grows with chamber age and would be re-injected on every wake.cryo-agent todo liststill returns the full list.
Primary APIs and Ownership
- API to invoke the external agent process:
src/agent.rs.agent_programis the preflight executable resolver.AgentConfig+build_promptdefine the session prompt contract.build_commandandspawn_agentare the execution APIs.- The daemon invokes these from
ProcessSessionLauncher::run_sessioninsrc/daemon/session.rs. cryo-agentis not the external model runner; it is the agent-side IPC/utility CLI the spawned agent uses to talk back to the daemon.
- API to manipulate TODOs:
src/todo.rs::TodoFile.TodoFileis the single file-backed API fortodo.json:add,done,remove,items,display,next_wake_time,next_valid_wake,claim_due,complete_claimed,reschedule_claimed_after_crash.cryo-agent todo ...does not touchtodo.jsondirectly; it sendssocket::Request::{TodoAdd, TodoDone, TodoRemove, TodoList}throughdaemon_client::send_checked_request.- Daemon request handling goes through
SessionEffects/FsSessionEffects, which delegate toTodoFile. - Scheduler-side daemon logic also uses
TodoFiledirectly for wake computation and crash retry requeue.
- API to manipulate local message files:
src/channel/store.rs::MessageStore.MessageStoreis the local mailbox API for directory setup, archive-stable message lookup, inbox/outbox reads, thread context, and archiving. Explicit thread reads currently scan all mailbox files. Keep that simple until measured history size requires an index; do not claim a thread-read latency SLO.- Agent-side
cryo-agent receivesendssocket::Request::Receivethroughdaemon_client::send_checked_request; during an active session, the daemon selects and archives one inbox conversation throughMessageStoreand records the reply obligation in session memory and a durable journal.cryo-agent dialoguses the same claim path. cryo-agent sendmust not write outbox files directly; it sendssocket::Request::Sendthroughdaemon_client::send_checked_requestso the daemon can both write the outbox message and resolve any claimed inbox batch correctly.- Archive-on-receive remains terminal.
daemon::inboxjournals only the reply obligation for restart notification; never restore claimed messages to pending or replay their external work. - Daemon, operator CLI, sync daemons, hub routes, and status/read-model code should all use
MessageStorefor local mailbox file access. - Low-level markdown parsing / rendering / archiving primitives still live in
src/message.rs;MessageStorecomposes them instead of reimplementing them.
- How the daemon manipulates TODOs and messages:
- Request-time side effects go through
src/daemon/effects.rs:SessionEffectsis the boundary;FsSessionEffectsis the filesystem-backed implementation. - Daemon TODO mutation goes through
FsSessionEffects→TodoFile. - Daemon message-file mutation goes through
FsSessionEffects→MessageStore. - Session startup only lists unread inbox filenames; the daemon does not preview inbox bodies.
DaemonRequest::Sendwrites the agent-authored outbox message and, if a claimed inbox batch exists, also finalizes that batch.- Session finalization may write a fallback
from: cryochamberreply or status update if the agent did not send a human-visible response. Fallback reply obligation applies only to the batch this session already received; unread inbox files stay unread for a future session. - Past-due TODOs are claimed when a session starts; on success the daemon marks them done, and on crash it marks them done while creating fresh retry TODOs rather than "un-claiming" the originals.
- Request-time side effects go through
Files Created by cryo init
cryo.toml— project configuration (agent, max_session_duration, watch_dirs)plan.md— template plan fileNOTES.md— agent's persistent memory across sessions (seeded fromtemplates/notes.md; agent reads/writes directly)README.md— quickstart guide for the project (service commands, messaging channels)
Files Created at Runtime (per project directory)
timer.json— runtime state only (session number, PID lock, CLI overrides)cryo.log— append-only structured event logcryo-agent.log— agent stdout/stderr (raw tool-call output)todo.json— per-project TODO items for agent task trackingmessages/inbox/— incoming messages for the agentmessages/outbox/— outgoing messages (agent replies, daemon stand-in replies)messages/inbox/archive/— processed inbox messagesmessages/attachments/— files downloaded from remote uploads (e.g. Zulip images); inbox message links are rewritten to point here.cryo/cryo.sock— Unix domain socket for agent-daemon IPCzulip-sync.json— Zulip sync state (if configured).cryo/zuliprc— Zulip credentials copied from user's zuliprc (if configured). Never sync, commit, or push this file — it holds API credentials. Already gitignored; thecryo-zulipsync channel must never include it in any payload.cryo-zulip-sync.log— Zulip sync daemon log output (if configured)~/Library/LaunchAgents/com.cryo.*.plist— macOS launchd service files (auto-managed)~/.config/systemd/user/com.cryo.*.service— Linux systemd service files (auto-managed)
Documentation
Main documentation lives in the mdbook at docs/src/ (published to giggleliu.github.io/cryochamber). Keep README.md lean — detailed guides belong in the mdbook.
README.md— Project overview and quickstart onlydocs/src/— mdbook source: introduction (pitch + quickstart), CLI reference, configurationMakefile— Dev targets (check,build,test,run-plan,check-round-trip, etc.)templates/— Single source of truth for agent protocol, template plan, and cryo.toml config templatedocs/plans/— Design documents (key design decisions only)docs/reports/— Code review reportsexamples/— Showcase examples.chambers/holds runnable chambers (e.g.mr-lazy,chess-by-mail,personal-assistant).
Skills
.claude/skills/make-plan/SKILL.md— Claude Code skill that guides users through creating a new cryochamber application (plan.md + cryo.toml) via conversational Q&A. Install withclaude skill install --path .claude/skills/make-plan, invoke with/make-plan. Additional repo-local skills (fix-pr,review-implementation) live alongside it..claude/skills/chat-bridge/SKILL.md— Claude Code skill for bridging a chamber to a chat platform (Zulip / Feishu-Lark) with one unified backbone:scripts/chat-bridgeCLI +chat_bridge/package (backbone.pyshared engine,channel.pyprotocol,zulip.py/lark.pyadapters). Mention-gated by default, multi-channel, attachments, realtime Zulip events queue, systemd + linger. Invoke with/chat-bridge.
Commit Convention
Conventional commits: feat:, test:, docs:, chore:, fix:
Do not commit implementation plans. Design documents should only be committed when they contain a key design decision.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

