Feature · Reliability
A book takes hours. A worker restart should not.
Translation runs in its own process, claiming jobs from the database with leases and heartbeats. If it dies mid-book, the job returns to the queue and picks up where it left off — without duplicating work or charging twice.
The lifecycle is explicit.
Every transition is recorded, so state is never guessed.
-
01
Job states
queued → preparing → parsing → segmenting → translating → finalizing → completed, withfailed,cancellingandcancelled— logged in the job-events trail.
-
02
Claim and lease
A worker claims a job, sets a lease and heartbeats while it runs. If the lease expires,
recover_stale()requeues the job.
-
03
Translate segments
Each segment has its own state — pending, translating, failed, skipped, validated. A batch returning never assumes every segment succeeded.
-
04
Retry and repair
Transient provider errors are retried with backoff and jitter; permanent ones are not. Context-too-large shrinks the batch instead of repeating the identical request.
Why it holds up under failure.
Idempotent by construction
The source is stored once, segments are created once per job, completed segments are skipped, and output lands on a deterministic key with a checksum.
No double-charge
The managed order is snapshotted on the job, and a failed or cancelled job is not charged — so a crash cannot charge twice.
No Redis required
The queue, leases and job store all live in PocketBase. Concurrency is bounded by configuration, not a broker cluster.
Retry only what failed.
When a job ends failed, the job page offers Retry failed. Book Fork preserves the original plan snapshot, skips every validated segment, and retranslates only the segments that did not make it — then reuses translation memory for the rest.
- Stable segment ids across retries
- Append-only attempt history
- Original plan snapshot preserved
- Progress computed from segment state, never a timer
uv run python -m worker.main # continuous
uv run python -m worker.main --once # process one job
uv run python -m worker.main --job-id <id> # run a specific job
uv run python -m worker.main --concurrency 4 # bounded parallelism
The worker refuses to start without a PocketBase service credential, and can be restarted or scaled without touching the web tier.
Start a long job and walk away.
Progress is durable. Your book finishes whether or not the tab stays open.