# Maintain state and recover from failures

Source: https://usecns.dev/cortex-topic-maintain-state-and-recover-from-failures/

[Start here](https://usecns.dev/manual-cortex/)
[CLI commands](https://usecns.dev/commands-cortex/)
[Configuration & integration](https://usecns.dev/cortex-topics/)

Use SQLite-safe backups before upgrading or renaming seats. Default sandbox storage is `<session-dir>/sandbox@local-durable.sqlite`; daemon `--seat` changes the preloaded sandbox ID. Durable entries, runtime configuration and workflow documents belong to the server. Do not share an independently opened SQLite file among writers. SIGINT/SIGTERM release the guard, remove discovery state and close the daemon cleanly.

Coordinate registry boundaries when running multiple daemons. `CORTEX_ROLE=unit`, `CORTEX_REGISTRY_ACTIVE=1` or `CORTEX_PARENT_REGISTRY_URL` forces a unit role; an already-held registry lock also yields unit role. The CLI passes `<session-dir>/registry.lock`, so different session directories do not enforce a host-wide singleton. Use separate credentials and stores for subordinate instances.

The inspected package is version 1.1.6. When migrating older installations, review sandbox naming/storage, protected-rig configuration, explicit model defaults, strict catalog keys, `classify_state` tool naming and `cortex.workflow` workflow documents. Old workflow-kind state is not read automatically; conversations remain distinct and durable. Review migration needs before renaming files or recreating workflow state. Package version, native-client protocol version (1), and daemon wire version (0.1.0) are different identifiers.

| Symptom | Next action |
| --- | --- |
| CLI reaches the wrong daemon | Check `--daemon-url`, URL/port environment and the intended session directory's `daemon.json`. The MCP proxy has different discovery rules. |
| Empty models or unrouted seat | Check catalog paths/unknown-key errors, explicit defaults and Thalamus startup status. Credentials do not select defaults. |
| Unexpected direct calls | Inspect catalog/per-call URLs and explicit/fallback environment overrides, then route classification. |
| System 1 succeeds offline | Read mock/fallback bands. Reject mode or the disabled backend intentionally fails classification. |
| Sender cannot prompt a seat | Check signature/allowlist, perimeter hold, principal role and seat/terminal access. Do not disable guards to make a webhook pass. |
| Fork succeeds but later work uses old history | Select the returned conversation ID explicitly. |
| Device repeatedly disconnects | Distinguish expired/reused pairing codes from revoked tokens (401/4001); re-pair only with owner authorization. |
| Bridge missing | Check the external harness/socket/configuration separately from daemon health. |