flowchart LR accTitle: Recovering a job after admission accDescr: These four worker failure cases are proposed design tests. Follow a duplicate delivery, a stale claim, an orphaned artifact or an unknown provider charge to its own recovery condition. %% journal-worker-recovery (en) %% https://www.thebsq.com/blog/prototype-to-production-checklist/ subgraph g1 ["Delivery and ownership"] %% n_dispatch — Admission already committed a job and outbox row. A relay may publish the same job twice if it stops before marking the first send as complete. n_dispatch["Dispatch intent"] %% n_inspect — Look up the authoritative job ID before rendering. A completed job can be acknowledged immediately. New work requires an eligible claim. n_inspect["Inspect the durable job"] %% n_claim — Each new claimant acquires a bounded lease and increments the generation. A slow worker can still compute after expiry, so the permission to publish is checked separately. n_claim["Lease and generation"] end subgraph g2 ["Artifact outcome"] %% n_write — Save the generation-specific output before publishing it. A process stop between storage and completion can leave a real object with no visible job pointer. n_write["Immutable attempt object"] %% n_guard — Update the visible pointer only when the generation still owns the job. The test checks that a late worker cannot replace the current result. n_guard["Guarded publication"] %% n_orphan — An unreferenced attempt object may be superseded during recovery. Inspect job pointers and remove orphaned objects later while preserving the visible winner. n_orphan["Sweep orphan outputs"] %% n_done — Inspect the published job ID and artifact pointer. Duplicate delivery may repeat work but only the winning completion should be visible. n_done["Acknowledge completion"] end subgraph g3 ["External effect"] %% n_provider — A paid provider may have accepted the work before timing out. Worker lease state says nothing about the provider’s charge. n_provider["Provider response missing"] %% n_lookup — Where supported, query the operation or retry with the same provider identity. Record the resolved external outcome against the original job. n_lookup["Reuse provider identity"] %% n_reconcile — Without deduplication or lookup, mark the job for reconciliation and assign an owner before any replay. A timeout alone cannot establish absence of a charge. n_reconcile["Park the unknown outcome"] end n_dispatch -->|"Receive a possibly repeated job ID"| n_inspect n_inspect -->|"A completed pointer already exists"| n_done n_inspect -->|"Unfinished job is eligible"| n_claim n_claim -->|"Render under the current generation"| n_write n_write -->|"Attempt to make output visible"| n_guard n_guard -->|"Generation matches"| n_done n_guard -->|"Generation is stale"| n_orphan n_write -->|"Process stops before publication"| n_orphan n_claim -->|"A paid external request times out"| n_provider n_provider -->|"Provider supports lookup or deduplication"| n_lookup n_provider -->|"Provider cannot confirm the outcome"| n_reconcile %% Duplicate delivery — n_dispatch → n_inspect → n_done %% Late worker completion — n_dispatch → n_inspect → n_claim → n_write → n_guard → n_orphan %% Unknown provider charge — n_dispatch → n_inspect → n_claim → n_provider → n_reconcile