> ## Documentation Index
> Fetch the complete documentation index at: https://usefused.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Runtime storage

> Choose storage authorities for committed sessions, in-progress checkpoints, media, and application data.

Harnest keeps committed session state separate from private in-progress execution state. It discovers storage factories across root and Harnest Extension extension files, then assembles one typed registry. Every application resolves exactly one session store and one checkpointer, even when both roles share the same backend object.

| Role                 | Holds                                                                      | Agent access                    | Guide                                                                                             |
| -------------------- | -------------------------------------------------------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------- |
| Sessions             | Committed conversation history and application session data                | `context.session`               | [Sessions and application storage](/docs/harnest/runtime/session-storage)                              |
| Checkpoints          | Active run state, framework snapshots, pending writes, and resumable waits | Framework-owned                 | [Checkpoints](/docs/harnest/runtime/checkpoints)                                                       |
| Tasks and cron       | Queued work, results, leases, and recurring schedules                      | `harnest.task` / `harnest.cron` | [Task and cron storage](/docs/harnest/runtime/task-storage)                                            |
| Named assets         | Session-owned media bytes                                                  | `context.assets("name")`        | [Store and retrieve media](/docs/harnest/build/models-and-libraries/store-and-retrieve-media)          |
| Named custom storage | Domain repositories                                                        | `context.storage("name")`       | [Sessions and application storage](/docs/harnest/runtime/session-storage#register-a-domain-repository) |

## Reuse a backend without merging roles

Put a shared connection in `lib/`, then declare each responsibility in its own extension file:

<Tabs>
  <Tab title="lib/state.py">
    ```python theme={null}
    import os

    from harnest.store import PostgresStore

    state = PostgresStore(os.environ["DATABASE_URL"])
    ```
  </Tab>

  <Tab title="lifecycle/sessions.py">
    ```python theme={null}
    from harnest.lib.state import state
    from harnest import lifecycle


    @lifecycle.storage.sessions
    def sessions():
        """Provide committed session and conversation storage."""

        return state
    ```
  </Tab>

  <Tab title="lifecycle/checkpoints.py">
    ```python theme={null}
    from harnest.lib.state import state
    from harnest import lifecycle


    @lifecycle.storage.checkpoints
    def checkpoints():
        """Provide private in-progress execution storage."""

        return state
    ```
  </Tab>
</Tabs>

Harnest starts the shared object once and closes it once. Separate factories make ownership visible even when the physical backend is the same. If one small factory intentionally owns both roles, you can stack the two decorators.

## Choose a backend

| Store           | Best for                                         | Limitation                                |
| --------------- | ------------------------------------------------ | ----------------------------------------- |
| `MemoryStore`   | Local development and tests                      | Process-local and lost on restart         |
| `PostgresStore` | Durable sessions, checkpoints, and continuations | Requires PostgreSQL                       |
| `RedisStore`    | Distributed sessions and expiring checkpoints    | Durability depends on Redis configuration |
| Custom store    | Existing infrastructure                          | You own schema, migration, and durability |

<CardGroup cols={2}>
  <Card title="Sessions and application storage" icon="messages" href="/docs/harnest/runtime/session-storage">
    Configure conversation state, `context.session`, assets, and domain repositories.
  </Card>

  <Card title="Checkpoints" icon="clock-rotate-left" href="/docs/harnest/runtime/checkpoints">
    Configure active-run recovery, framework adapters, and replica safety.
  </Card>
</CardGroup>
