> ## 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.

# harnest_redis

> Public Python signatures, fields, and methods.

[All Python modules](https://usefused.com/docs/harnest/reference/api/overview.md) · [Import and compatibility guidance](https://usefused.com/docs/harnest/build/python-imports.md)

## Exports

| Name | Kind |
| - | - |
| [`RedisMemoryStore`](#redismemorystore) | Class |
| [`RedisStore`](#redisstore) | Class |

## RedisMemoryStore

Store explicit memories in Redis; durability requires persistent Redis.

```python theme={null}
RedisMemoryStore(url: str, *, prefix: str = 'harnest-memory') -> None
```

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `url` | `str` | Required |
> | `prefix` | `str` | `'harnest-memory'` |
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store = RedisMemoryStore(url=...)
> ```

### RedisMemoryStore.delete\_all

```python theme={null}
async RedisMemoryStore.delete_all(scope: harnest.memory.MemoryScope) -> int
```

Erase one explicit namespace through trusted application code only.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `harnest.memory.MemoryScope` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store: RedisMemoryStore
> result = await store.delete_all(scope=...)
> ```

### RedisMemoryStore.delete\_user

```python theme={null}
async RedisMemoryStore.delete_user(application_id: str, user_id: str) -> int
```

Erase an explicitly authorized owner without registering any endpoint.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store: RedisMemoryStore
> result = await store.delete_user(application_id=..., user_id=...)
> ```

### RedisMemoryStore.purge\_expired

```python theme={null}
async RedisMemoryStore.purge_expired(
    scope: harnest.memory.MemoryScope,
    *,
    limit: int = 100,
    after: str | None = None,
) -> harnest.memory.MemoryCleanupPage
```

Sweep a bounded key page without exposing another user's collection.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `harnest.memory.MemoryScope` | Required |
> | `limit` | `int` | `100` |
> | `after` | `str \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store: RedisMemoryStore
> page = await store.purge_expired(scope=...)
> ```

### RedisMemoryStore.put

```python theme={null}
async RedisMemoryStore.put(record: harnest.memory.MemoryRecord, *, expected_revision: str | None = None) -> harnest.memory.MemoryRecord
```

Validate before atomically persisting a deliberate memory write.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `record` | `harnest.memory.MemoryRecord` | Required |
> | `expected_revision` | `str \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store: RedisMemoryStore
> record = await store.put(record=...)
> ```

### RedisMemoryStore.get

```python theme={null}
async RedisMemoryStore.get(scope: harnest.memory.MemoryScope, key: str) -> harnest.memory.MemoryRecord | None
```

Read only an explicitly scoped live record.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `harnest.memory.MemoryScope` | Required |
> | `key` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store: RedisMemoryStore
> record = await store.get(scope=..., key=...)
> ```

### RedisMemoryStore.list

```python theme={null}
async RedisMemoryStore.list(
    scope: harnest.memory.MemoryScope,
    *,
    limit: int = 20,
    after: str | None = None,
) -> harnest.memory.MemoryPage
```

Page records without loading an unbounded provider collection.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `harnest.memory.MemoryScope` | Required |
> | `limit` | `int` | `20` |
> | `after` | `str \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store: RedisMemoryStore
> page = await store.list(scope=...)
> ```

### RedisMemoryStore.search

```python theme={null}
async RedisMemoryStore.search(
    scope: harnest.memory.MemoryScope,
    query: str,
    *,
    limit: int = 20,
    after: str | None = None,
) -> harnest.memory.MemoryPage
```

Retrieve explicit literal text matches without model or embedding calls.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `harnest.memory.MemoryScope` | Required |
> | `query` | `str` | Required |
> | `limit` | `int` | `20` |
> | `after` | `str \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store: RedisMemoryStore
> page = await store.search(scope=..., query=...)
> ```

### RedisMemoryStore.delete

```python theme={null}
async RedisMemoryStore.delete(
    scope: harnest.memory.MemoryScope,
    key: str,
    *,
    expected_revision: str | None = None,
) -> bool
```

Remove memory and its indexes with an optional atomic revision fence.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `harnest.memory.MemoryScope` | Required |
> | `key` | `str` | Required |
> | `expected_revision` | `str \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store: RedisMemoryStore
> result = await store.delete(scope=..., key=...)
> ```

### RedisMemoryStore.start

```python theme={null}
async RedisMemoryStore.start() -> None
```

Open an owned async client only when the selected provider starts.

> [accordion] Example
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store: RedisMemoryStore
> await store.start()
> ```

### RedisMemoryStore.close

```python theme={null}
async RedisMemoryStore.close() -> None
```

Release only this provider's Redis client.

> [accordion] Example
>
> ```python theme={null}
> from harnest_redis import RedisMemoryStore
>
> store: RedisMemoryStore
> await store.close()
> ```

## RedisStore

Combined storage with atomic task leases and cron occurrence handoff.

Tasks have no expiration: durable retention follows explicit lifecycle
operations, independent of the session/checkpoint TTL configuration.
Configure Redis persistence and replication for the required durability.

```python theme={null}
RedisStore(
    url: str,
    *,
    prefix: str = 'harnest',
    session_ttl_seconds: int | None = None,
    checkpoint_ttl_seconds: int = 604800,
    lease_seconds: int = 60,
    lease_wait_seconds: float = 30,
    client_options: Mapping[str, Any] | None = None,
) -> None
```

Fields (`—` means no declared default):

| Field | Type | Default |
| - | - | - |
| `owner` | `CheckpointOwner` | `'harnest'` |
| `framework` | `str \| None` | `None` |
| `schema_id` | `str` | `'harnest-checkpoint/v1'` |

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `url` | `str` | Required |
> | `prefix` | `str` | `'harnest'` |
> | `session_ttl_seconds` | `int \| None` | `None` |
> | `checkpoint_ttl_seconds` | `int` | `604800` |
> | `lease_seconds` | `int` | `60` |
> | `lease_wait_seconds` | `float` | `30` |
> | `client_options` | `Mapping[str, Any] \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store = RedisStore(url=...)
> ```

### RedisStore.start

```python theme={null}
async RedisStore.start() -> None
```

Open the client and establish the compatible schema marker.

> [accordion] Example
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> await store.start()
> ```

### RedisStore.close

```python theme={null}
async RedisStore.close() -> None
```

Close only clients created and owned by this store.

> [accordion] Example
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> await store.close()
> ```

### RedisStore.create\_cron

```python theme={null}
async RedisStore.create_cron(record: CronRecord) -> CronRecord
```

Atomically persist schedule identity, owner index, and due index.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `record` | `CronRecord` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.create_cron(record=...)
> ```

### RedisStore.get\_cron

```python theme={null}
async RedisStore.get_cron(*, application_id: str, user_id: str, schedule_id: str) -> CronRecord | None
```

Read one schedule using an owner predicate evaluated by Redis.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `schedule_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.get_cron(application_id=..., user_id=..., schedule_id=...)
> ```

### RedisStore.list\_crons

```python theme={null}
async RedisStore.list_crons(
    *,
    application_id: str,
    user_id: str,
    after: str | None = None,
    limit: int = 100,
) -> tuple[CronRecord, ...]
```

Return a bounded lexicographic owner-index page in one Redis call.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `after` | `str \| None` | `None` |
> | `limit` | `int` | `100` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.list_crons(application_id=..., user_id=...)
> ```

### RedisStore.update\_cron

```python theme={null}
async RedisStore.update_cron(record: CronRecord, *, expected_revision: int) -> CronRecord
```

Replace mutable schedule fields with revision and terminal fencing.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `record` | `CronRecord` | Required |
> | `expected_revision` | `int` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.update_cron(record=..., expected_revision=...)
> ```

### RedisStore.delete\_cron

```python theme={null}
async RedisStore.delete_cron(*, application_id: str, user_id: str, schedule_id: str) -> bool
```

Remove one owner's record and its identity/query indexes atomically.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `schedule_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.delete_cron(application_id=..., user_id=..., schedule_id=...)
> ```

### RedisStore.list\_due\_crons

```python theme={null}
async RedisStore.list_due_crons(
    *,
    application_id: str,
    now: float,
    after: tuple[float, str] | None = None,
    limit: int = 100,
) -> tuple[CronRecord, ...]
```

Read due schedules from a time/ID index with stable keyset bounds.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `now` | `float` | Required |
> | `after` | `tuple[float, str] \| None` | `None` |
> | `limit` | `int` | `100` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.list_due_crons(application_id=..., now=...)
> ```

### RedisStore.commit\_cron\_occurrence

```python theme={null}
async RedisStore.commit_cron_occurrence(
    *,
    application_id: str,
    user_id: str,
    schedule_id: str,
    expected_revision: int,
    due_at: float,
    next_run_at: float,
    task: TaskRecord,
) -> TaskRecord | None
```

Enqueue and advance a fenced occurrence within one Lua transaction.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `schedule_id` | `str` | Required |
> | `expected_revision` | `int` | Required |
> | `due_at` | `float` | Required |
> | `next_run_at` | `float` | Required |
> | `task` | `TaskRecord` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.commit_cron_occurrence(
>     application_id=...,
>     user_id=...,
>     schedule_id=...,
>     expected_revision=...,
>     due_at=...,
>     next_run_at=...,
>     task=...,
> )
> ```

### RedisStore.enqueue\_task

```python theme={null}
async RedisStore.enqueue_task(record: TaskRecord) -> TaskRecord
```

Persist a job once per scoped key, retaining immutable fingerprints.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `record` | `TaskRecord` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.enqueue_task(record=...)
> ```

### RedisStore.get\_task

```python theme={null}
async RedisStore.get_task(*, application_id: str, job_id: str, user_id: str | None = None) -> TaskRecord | None
```

Apply owner scope inside Redis before returning a single record.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `job_id` | `str` | Required |
> | `user_id` | `str \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.get_task(application_id=..., job_id=...)
> ```

### RedisStore.claim\_tasks

```python theme={null}
async RedisStore.claim_tasks(
    *,
    application_id: str,
    queues: tuple[str, ...],
    now: float,
    lease_seconds: float,
    limit: int = 1,
) -> tuple[TaskRecord, ...]
```

Claim bounded indexed work and recover expired attempts atomically.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `queues` | `tuple[str, ...]` | Required |
> | `now` | `float` | Required |
> | `lease_seconds` | `float` | Required |
> | `limit` | `int` | `1` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.claim_tasks(
>     application_id=...,
>     queues=...,
>     now=...,
>     lease_seconds=...,
> )
> ```

### RedisStore.renew\_task\_lease

```python theme={null}
async RedisStore.renew_task_lease(
    *,
    application_id: str,
    job_id: str,
    lease_token: str,
    now: float,
    lease_seconds: float,
) -> bool
```

Renew only the matching unexpired attempt's fenced queue lease.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `job_id` | `str` | Required |
> | `lease_token` | `str` | Required |
> | `now` | `float` | Required |
> | `lease_seconds` | `float` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.renew_task_lease(
>     application_id=...,
>     job_id=...,
>     lease_token=...,
>     now=...,
>     lease_seconds=...,
> )
> ```

### RedisStore.finish\_task

```python theme={null}
async RedisStore.finish_task(
    *,
    application_id: str,
    job_id: str,
    lease_token: str,
    now: float,
    status: str,
    result: Any = None,
    failure_code: str | None = None,
    retry_at: float | None = None,
) -> bool
```

Commit a fenced result or delayed retry and scrub terminal payloads.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `job_id` | `str` | Required |
> | `lease_token` | `str` | Required |
> | `now` | `float` | Required |
> | `status` | `str` | Required |
> | `result` | `Any` | `None` |
> | `failure_code` | `str \| None` | `None` |
> | `retry_at` | `float \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.finish_task(
>     application_id=...,
>     job_id=...,
>     lease_token=...,
>     now=...,
>     status=...,
> )
> ```

### RedisStore.cancel\_task

```python theme={null}
async RedisStore.cancel_task(*, application_id: str, user_id: str, job_id: str, now: float) -> bool
```

Cancel scoped work and invalidate running claims in one mutation.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `job_id` | `str` | Required |
> | `now` | `float` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.cancel_task(application_id=..., user_id=..., job_id=..., now=...)
> ```

### RedisStore.as\_langgraph\_checkpointer

```python theme={null}
RedisStore.as_langgraph_checkpointer() -> Any
```

Return one stable native saver for advanced LangGraph construction.

> [accordion] Example
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = store.as_langgraph_checkpointer()
> ```

### RedisStore.create

```python theme={null}
async RedisStore.create(*, session_id: str, user_id: str, state: Mapping[str, Any]) -> SessionRecord
```

Create one tenant-scoped session with an atomic Lua mutation.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `session_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `state` | `Mapping[str, Any]` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.create(session_id=..., user_id=..., state=...)
> ```

### RedisStore.get

```python theme={null}
async RedisStore.get(*, session_id: str, user_id: str) -> SessionRecord | None
```

Read one tenant-scoped session from Redis.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `session_id` | `str` | Required |
> | `user_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.get(session_id=..., user_id=...)
> ```

### RedisStore.list

```python theme={null}
async RedisStore.list(*, user_id: str, after: str | None = None, limit: int | None = None) -> Sequence[SessionRecord]
```

Read one lexicographically ordered keyset page with one MGET.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `user_id` | `str` | Required |
> | `after` | `str \| None` | `None` |
> | `limit` | `int \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.list(user_id=...)
> ```

### RedisStore.put\_a2a\_task

```python theme={null}
async RedisStore.put_a2a_task(record: A2ATaskRecord) -> A2ATaskRecord
```

Atomically update one A2A record and all of its query indexes.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `record` | `A2ATaskRecord` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.put_a2a_task(record=...)
> ```

### RedisStore.get\_a2a\_task

```python theme={null}
async RedisStore.get_a2a_task(*, application_id: str, user_id: str, task_id: str) -> A2ATaskRecord | None
```

Read one task through its digested application and owner key.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `task_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.get_a2a_task(application_id=..., user_id=..., task_id=...)
> ```

### RedisStore.list\_a2a\_tasks

```python theme={null}
async RedisStore.list_a2a_tasks(
    *,
    application_id: str,
    user_id: str,
    context_id: str | None = None,
    status: int | None = None,
    status_timestamp_after: str | None = None,
    cursor_task_id: str | None = None,
    limit: int = 51,
) -> A2ATaskPage
```

Use one prefiltered sorted index and one batched record read.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `context_id` | `str \| None` | `None` |
> | `status` | `int \| None` | `None` |
> | `status_timestamp_after` | `str \| None` | `None` |
> | `cursor_task_id` | `str \| None` | `None` |
> | `limit` | `int` | `51` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> page = await store.list_a2a_tasks(application_id=..., user_id=...)
> ```

### RedisStore.delete\_a2a\_task

```python theme={null}
async RedisStore.delete_a2a_task(*, application_id: str, user_id: str, task_id: str) -> bool
```

Delete a record and every selected-list index with optimistic CAS.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `task_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.delete_a2a_task(application_id=..., user_id=..., task_id=...)
> ```

### RedisStore.update

```python theme={null}
async RedisStore.update(*, session_id: str, user_id: str, state_delta: Mapping[str, Any]) -> SessionRecord | None
```

Atomically merge state while preserving session expiry policy.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `session_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `state_delta` | `Mapping[str, Any]` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.update(session_id=..., user_id=..., state_delta=...)
> ```

### RedisStore.delete

```python theme={null}
async RedisStore.delete(*, session_id: str, user_id: str) -> bool
```

Delete a session and its user index entry atomically.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `session_id` | `str` | Required |
> | `user_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.delete(session_id=..., user_id=...)
> ```

### RedisStore.acquire

```python theme={null}
RedisStore.acquire(*, session_id: str, user_id: str) -> AsyncIterator[SessionLease]
```

Hold and renew a token-bound distributed lease for one execution.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `session_id` | `str` | Required |
> | `user_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> async with store.acquire(session_id=..., user_id=...):
>     ...
> ```

### RedisStore.begin\_run

```python theme={null}
async RedisStore.begin_run(
    *,
    application_id: str,
    user_id: str,
    session_id: str,
    run_id: str,
    framework: Literal['adk', 'langgraph'],
) -> RunRecord
```

Create an idempotent run while allowing one active run per session.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `session_id` | `str` | Required |
> | `run_id` | `str` | Required |
> | `framework` | `Literal['adk', 'langgraph']` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.begin_run(
>     application_id=...,
>     user_id=...,
>     session_id=...,
>     run_id=...,
>     framework=...,
> )
> ```

### RedisStore.get\_run

```python theme={null}
async RedisStore.get_run(*, scope: RunScope) -> RunRecord | None
```

Read one Redis checkpoint run through its ownership scope.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.get_run(scope=...)
> ```

### RedisStore.get\_checkpoint

```python theme={null}
async RedisStore.get_checkpoint(*, scope: RunScope, checkpoint_id: str | None = None, namespace: str = '') -> CheckpointRecord | None
```

Resolve an exact or newest checkpoint through its Redis index.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `checkpoint_id` | `str \| None` | `None` |
> | `namespace` | `str` | `''` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.get_checkpoint(scope=...)
> ```

### RedisStore.list\_checkpoints

```python theme={null}
RedisStore.list_checkpoints(
    *,
    scope: RunScope,
    namespace: str | None = None,
    before: str | None = None,
    limit: int = 20,
) -> AsyncIterator[CheckpointRecord]
```

Read bounded checkpoint history from sorted-set indexes.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `namespace` | `str \| None` | `None` |
> | `before` | `str \| None` | `None` |
> | `limit` | `int` | `20` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> async for item in store.list_checkpoints(scope=...):
>     ...
> ```

### RedisStore.put

```python theme={null}
async RedisStore.put(checkpoint: CheckpointRecord, *, scope: RunScope, expected_revision: int | None) -> CheckpointRecord
```

Persist checkpoint data and revision indexes with one Lua CAS.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `checkpoint` | `CheckpointRecord` | Required |
> | `scope` | `RunScope` | Required |
> | `expected_revision` | `int \| None` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.put(checkpoint=..., scope=..., expected_revision=...)
> ```

### RedisStore.put\_writes

```python theme={null}
async RedisStore.put_writes(*, scope: RunScope, checkpoint_id: str, writes: Sequence[CheckpointWrite]) -> None
```

Add pending writes idempotently with one Lua operation.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `checkpoint_id` | `str` | Required |
> | `writes` | `Sequence[CheckpointWrite]` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> await store.put_writes(scope=..., checkpoint_id=..., writes=...)
> ```

### RedisStore.get\_writes

```python theme={null}
async RedisStore.get_writes(*, scope: RunScope, checkpoint_id: str) -> Sequence[CheckpointWrite]
```

Read pending writes for one owned Redis checkpoint.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `checkpoint_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.get_writes(scope=..., checkpoint_id=...)
> ```

### RedisStore.get\_writes\_batch

```python theme={null}
async RedisStore.get_writes_batch(*, scope: RunScope, checkpoint_ids: Sequence[str]) -> Mapping[str, Sequence[CheckpointWrite]]
```

Fetch several pending-write hashes in one Redis round trip.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `checkpoint_ids` | `Sequence[str]` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.get_writes_batch(scope=..., checkpoint_ids=...)
> ```

### RedisStore.suspend\_continuation

```python theme={null}
async RedisStore.suspend_continuation(*, record: ContinuationRecord, external_id: str) -> ContinuationRecord
```

Atomically persist a provider wait and move its run to waiting.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `record` | `ContinuationRecord` | Required |
> | `external_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.suspend_continuation(record=..., external_id=...)
> ```

### RedisStore.get\_continuation

```python theme={null}
async RedisStore.get_continuation(*, scope: RunScope, continuation_id: str) -> ContinuationRecord | None
```

Read one private record only when all ownership fields match.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `continuation_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.get_continuation(scope=..., continuation_id=...)
> ```

### RedisStore.get\_provider\_continuation

```python theme={null}
async RedisStore.get_provider_continuation(*, scope: RunScope, provider: str, continuation_id: str) -> ProviderPendingContinuation | None
```

Load an exact provider envelope only while its owned run exists.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `provider` | `str` | Required |
> | `continuation_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> continuation = await store.get_provider_continuation(
>     scope=...,
>     provider=...,
>     continuation_id=...,
> )
> ```

### RedisStore.get\_continuation\_by\_external\_id

```python theme={null}
async RedisStore.get_continuation_by_external_id(*, application_id: str, provider: str, external_id: str) -> ProviderPendingContinuation | None
```

Resolve a callback through its provider-owned Redis index.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `provider` | `str` | Required |
> | `external_id` | `str` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> continuation = await store.get_continuation_by_external_id(
>     application_id=...,
>     provider=...,
>     external_id=...,
> )
> ```

### RedisStore.list\_pending\_continuations

```python theme={null}
async RedisStore.list_pending_continuations(
    *,
    application_id: str,
    provider: str,
    after: str | None = None,
    limit: int = 100,
) -> Sequence[ProviderPendingContinuation]
```

Load one indexed provider page with a single batched value read.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `provider` | `str` | Required |
> | `after` | `str \| None` | `None` |
> | `limit` | `int` | `100` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.list_pending_continuations(application_id=..., provider=...)
> ```

### RedisStore.resolve\_continuation

```python theme={null}
async RedisStore.resolve_continuation(
    *,
    scope: RunScope,
    provider: str,
    external_id: str,
    schema_id: str,
    result: Any = None,
    failure: ContinuationFailure | None = None,
) -> ContinuationRecord
```

Resolve an indexed provider callback with an atomic status CAS.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `provider` | `str` | Required |
> | `external_id` | `str` | Required |
> | `schema_id` | `str` | Required |
> | `result` | `Any` | `None` |
> | `failure` | `ContinuationFailure \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.resolve_continuation(
>     scope=...,
>     provider=...,
>     external_id=...,
>     schema_id=...,
> )
> ```

### RedisStore.claim\_continuation

```python theme={null}
async RedisStore.claim_continuation(
    *,
    scope: RunScope,
    provider: str,
    continuation_id: str,
    expected_revision: int,
) -> ContinuationRecord
```

Claim a provider outcome and resume its run with one Lua CAS.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `provider` | `str` | Required |
> | `continuation_id` | `str` | Required |
> | `expected_revision` | `int` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.claim_continuation(
>     scope=...,
>     provider=...,
>     continuation_id=...,
>     expected_revision=...,
> )
> ```

### RedisStore.cancel\_continuation

```python theme={null}
async RedisStore.cancel_continuation(
    *,
    scope: RunScope,
    provider: str,
    continuation_id: str,
    expected_revision: int,
    failure: ContinuationFailure,
) -> ContinuationRecord
```

Cancel one exact waiting run and fail its continuation in one script.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `provider` | `str` | Required |
> | `continuation_id` | `str` | Required |
> | `expected_revision` | `int` | Required |
> | `failure` | `ContinuationFailure` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.cancel_continuation(
>     scope=...,
>     provider=...,
>     continuation_id=...,
>     expected_revision=...,
>     failure=...,
> )
> ```

### RedisStore.arm\_continuation

```python theme={null}
async RedisStore.arm_continuation(
    *,
    scope: RunScope,
    provider: str,
    continuation_id: str,
    expected_revision: int,
) -> ContinuationRecord
```

Arm one persisted wait after the framework commits its checkpoint.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `provider` | `str` | Required |
> | `continuation_id` | `str` | Required |
> | `expected_revision` | `int` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.arm_continuation(
>     scope=...,
>     provider=...,
>     continuation_id=...,
>     expected_revision=...,
> )
> ```

### RedisStore.transition

```python theme={null}
async RedisStore.transition(
    *,
    scope: RunScope,
    expected_status: RunStatus,
    status: RunStatus,
    pending_action: PendingAction | None = None,
) -> RunRecord
```

Apply one status compare-and-swap and release terminal ownership.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
> | `expected_status` | `RunStatus` | Required |
> | `status` | `RunStatus` | Required |
> | `pending_action` | `PendingAction \| None` | `None` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> record = await store.transition(scope=..., expected_status=..., status=...)
> ```

### RedisStore.delete\_run

```python theme={null}
async RedisStore.delete_run(*, scope: RunScope) -> None
```

Make run data unreachable immediately and let private blobs expire.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `scope` | `RunScope` | Required |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> await store.delete_run(scope=...)
> ```

### RedisStore.list\_task\_metadata

```python theme={null}
async RedisStore.list_task_metadata(
    *,
    application_id: str,
    user_id: str,
    after: str | None = None,
    limit: int = 100,
) -> dict[str, Any]
```

Index legacy jobs incrementally and project one owner page inside Redis.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `after` | `str \| None` | `None` |
> | `limit` | `int` | `100` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.list_task_metadata(application_id=..., user_id=...)
> ```

### RedisStore.list\_cron\_metadata

```python theme={null}
async RedisStore.list_cron_metadata(
    *,
    application_id: str,
    user_id: str,
    after: str | None = None,
    limit: int = 100,
) -> dict[str, Any]
```

Project one indexed owner page in Redis without transferring private arguments.

> [accordion] Parameters and example
>
> | Parameter | Type | Default |
> | - | - | - |
> | `application_id` | `str` | Required |
> | `user_id` | `str` | Required |
> | `after` | `str \| None` | `None` |
> | `limit` | `int` | `100` |
>
> ```python theme={null}
> from harnest_redis import RedisStore
>
> store: RedisStore
> result = await store.list_cron_metadata(application_id=..., user_id=...)
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.