# bookclerk_library::entities::jobs

SeaORM entity for the durable daemon `jobs` table.

| Item | Kind | Summary |
| --- | --- | --- |
| [`Model`](#model) | struct | Row shape for this table (`DeriveEntityModel`). |
| [`ColumnIter`](#columniter) | struct | An iterator over the variants of [Column] |
| [`Entity`](#entity) | struct | Generated by sea-orm-macros |
| [`PrimaryKeyIter`](#primarykeyiter) | struct | An iterator over the variants of [PrimaryKey] |
| [`ActiveModel`](#activemodel) | struct | Generated by sea-orm-macros |
| [`RelationIter`](#relationiter) | struct | An iterator over the variants of [Relation] |
| [`Column`](#column) | enum | Generated by sea-orm-macros |
| [`PrimaryKey`](#primarykey) | enum | Generated by sea-orm-macros |
| [`Relation`](#relation) | enum | Declared SeaORM relations (temp paths are queried by `job_id`, not modeled). |

## Structs

### Model

```rust
pub struct Model {
    pub id: String,
    pub kind: String,
    pub state: String,
    pub priority: i64,
    pub resource_class: String,
    pub payload: String,
    pub progress: Option<String>,
    pub attempt_count: i64,
    pub max_attempts: i64,
    pub run_after: String,
    pub lease_owner: Option<String>,
    pub lease_expires_at: Option<String>,
    pub dedup_key: String,
    pub error_kind: Option<String>,
    pub error_message: Option<String>,
    pub cancel_requested: i64,
    pub created_at: String,
    pub updated_at: String,
    pub started_at: Option<String>,
    pub finished_at: Option<String>,
    pub lease_generation: i64,
}
```

Row shape for this table (`DeriveEntityModel`).

**Fields**

- `id`: Stable job id (`scan-{uuid}`, `acquire-{uuid}`, `listen_sync-{uuid}`).
- `kind`: Job kind (`scan`, `acquire`, `listen_sync`).
- `state`: Lifecycle state (`pending`, `running`, `succeeded`, `failed`, `cancelled`).
- `priority`: Higher values are claimed first when several jobs are ready.
- `resource_class`: Concurrency class (`network`, `media`, `transcription`, `indexing`).
- `payload`: JSON payload (`account`, `title`, `trigger`).
- `progress`: Human-readable progress string shown in the API and UI.
- `attempt_count`: Number of times a worker has claimed this row.
- `max_attempts`: Maximum claims before a failure becomes terminal.
- `run_after`: RFC 3339 time after which a pending job may be claimed (backoff / delay).
- `lease_owner`: Worker id that currently holds the lease, when `state = running`.
- `lease_expires_at`: RFC 3339 lease expiry; stale running rows are reclaimed after this.
- `dedup_key`: Idempotency key unique among pending/running rows of the same work.
- `error_kind`: Structured error kind (`queue_full` is admission-only; execution uses
  `handler`, `cancelled`, `orphaned_after_restart`, `max_attempts`, and
  `unroutable` from the requirements sweep).
- `error_message`: Operator-facing error text when the job failed or was cancelled.
- `cancel_requested`: Cooperative cancel flag (`0` / `1`); running workers check between steps.
- `created_at`: RFC 3339 timestamp when the row was inserted.
- `updated_at`: RFC 3339 timestamp when the row was last modified.
- `started_at`: RFC 3339 timestamp when a worker first claimed the row.
- `finished_at`: RFC 3339 timestamp when the row reached a terminal state.
- `lease_generation`: Per-claim generation used to fence heartbeat and finalization.

#### Model::into_ex

```rust
pub fn into_ex(self) -> Self
```

Generated by sea-orm-macros

Implements: `Clone`, `Debug`, `Eq`, `From<Model>`, `FromQueryResult`, `IntoActiveModel<ActiveModel>`, `ModelTrait`, `PartialEq`, `TryFrom<ActiveModel>`, `TryIntoModel<Model>`

### ColumnIter

```rust
pub struct ColumnIter {
    /* private fields */
}
```

An iterator over the variants of [Column](#column)

Implements: `Clone`, `Debug`, `DoubleEndedIterator`, `ExactSizeIterator`, `FusedIterator`, `Iterator`

### Entity

```rust
pub struct Entity;
```

Generated by sea-orm-macros

Implements: `Clone`, `Copy`, `Debug`, `Default`, `EntityName`, `EntityTrait`, `Iden`, `IdenStatic`

### PrimaryKeyIter

```rust
pub struct PrimaryKeyIter {
    /* private fields */
}
```

An iterator over the variants of [PrimaryKey](#primarykey)

Implements: `Clone`, `Debug`, `DoubleEndedIterator`, `ExactSizeIterator`, `FusedIterator`, `Iterator`

### ActiveModel

```rust
pub struct ActiveModel {
    pub id: ActiveValue<String>,
    pub kind: ActiveValue<String>,
    pub state: ActiveValue<String>,
    pub priority: ActiveValue<i64>,
    pub resource_class: ActiveValue<String>,
    pub payload: ActiveValue<String>,
    pub progress: ActiveValue<Option<String>>,
    pub attempt_count: ActiveValue<i64>,
    pub max_attempts: ActiveValue<i64>,
    pub run_after: ActiveValue<String>,
    pub lease_owner: ActiveValue<Option<String>>,
    pub lease_expires_at: ActiveValue<Option<String>>,
    pub dedup_key: ActiveValue<String>,
    pub error_kind: ActiveValue<Option<String>>,
    pub error_message: ActiveValue<Option<String>>,
    pub cancel_requested: ActiveValue<i64>,
    pub created_at: ActiveValue<String>,
    pub updated_at: ActiveValue<String>,
    pub started_at: ActiveValue<Option<String>>,
    pub finished_at: ActiveValue<Option<String>>,
    pub lease_generation: ActiveValue<i64>,
}
```

Generated by sea-orm-macros

**Fields**

- `id`: Generated by sea-orm-macros
- `kind`: Generated by sea-orm-macros
- `state`: Generated by sea-orm-macros
- `priority`: Generated by sea-orm-macros
- `resource_class`: Generated by sea-orm-macros
- `payload`: Generated by sea-orm-macros
- `progress`: Generated by sea-orm-macros
- `attempt_count`: Generated by sea-orm-macros
- `max_attempts`: Generated by sea-orm-macros
- `run_after`: Generated by sea-orm-macros
- `lease_owner`: Generated by sea-orm-macros
- `lease_expires_at`: Generated by sea-orm-macros
- `dedup_key`: Generated by sea-orm-macros
- `error_kind`: Generated by sea-orm-macros
- `error_message`: Generated by sea-orm-macros
- `cancel_requested`: Generated by sea-orm-macros
- `created_at`: Generated by sea-orm-macros
- `updated_at`: Generated by sea-orm-macros
- `started_at`: Generated by sea-orm-macros
- `finished_at`: Generated by sea-orm-macros
- `lease_generation`: Generated by sea-orm-macros

Implements: `ActiveModelBehavior`, `ActiveModelTrait`, `Clone`, `Debug`, `Default`, `From<Model>`, `IntoActiveModel<ActiveModel>`, `PartialEq`, `TryFrom<ActiveModel>`, `TryIntoModel<Model>`

### RelationIter

```rust
pub struct RelationIter {
    /* private fields */
}
```

An iterator over the variants of [Relation](#relation)

Implements: `Clone`, `Debug`, `DoubleEndedIterator`, `ExactSizeIterator`, `FusedIterator`, `Iterator`

## Enums

### Column

```rust
pub enum Column {
    Id,
    Kind,
    State,
    Priority,
    ResourceClass,
    Payload,
    Progress,
    AttemptCount,
    MaxAttempts,
    RunAfter,
    LeaseOwner,
    LeaseExpiresAt,
    DedupKey,
    ErrorKind,
    ErrorMessage,
    CancelRequested,
    CreatedAt,
    UpdatedAt,
    StartedAt,
    FinishedAt,
    LeaseGeneration,
}
```

Generated by sea-orm-macros

**Variants**

- `Id`: Generated by sea-orm-macros
- `Kind`: Generated by sea-orm-macros
- `State`: Generated by sea-orm-macros
- `Priority`: Generated by sea-orm-macros
- `ResourceClass`: Generated by sea-orm-macros
- `Payload`: Generated by sea-orm-macros
- `Progress`: Generated by sea-orm-macros
- `AttemptCount`: Generated by sea-orm-macros
- `MaxAttempts`: Generated by sea-orm-macros
- `RunAfter`: Generated by sea-orm-macros
- `LeaseOwner`: Generated by sea-orm-macros
- `LeaseExpiresAt`: Generated by sea-orm-macros
- `DedupKey`: Generated by sea-orm-macros
- `ErrorKind`: Generated by sea-orm-macros
- `ErrorMessage`: Generated by sea-orm-macros
- `CancelRequested`: Generated by sea-orm-macros
- `CreatedAt`: Generated by sea-orm-macros
- `UpdatedAt`: Generated by sea-orm-macros
- `StartedAt`: Generated by sea-orm-macros
- `FinishedAt`: Generated by sea-orm-macros
- `LeaseGeneration`: Generated by sea-orm-macros

Implements: `Clone`, `ColumnTrait`, `Copy`, `Debug`, `FromStr`, `Iden`, `IdenStatic`, `IntoEnumIterator`

### PrimaryKey

```rust
pub enum PrimaryKey {
    Id,
}
```

Generated by sea-orm-macros

**Variants**

- `Id`: Generated by sea-orm-macros

Implements: `Clone`, `Copy`, `Debug`, `Iden`, `IdenStatic`, `IntoEnumIterator`, `PrimaryKeyToColumn`, `PrimaryKeyTrait`

### Relation

```rust
pub enum Relation {}
```

Declared SeaORM relations (temp paths are queried by `job_id`, not modeled).

Implements: `Clone`, `Copy`, `Debug`, `IntoEnumIterator`, `RelationTrait`
