focusreactive / focusreactive/payload-plugins
translator: pass run context into lifecycle callbacks
- Dominant language
- TypeScript
- Stars
- 19
- Forks
- 0
- Avg merge
- 16h 54m
- Merged PRs (30d)
- 19
Description
Read against **0.10.1**.
## Problem
Lifecycle callbacks carry no reference to the run that caused them. `onQueued` / `onCompleted` /
`onFailed` receive the document and target locale, but nothing identifying the enqueue that produced
the job.
A host that layers editorial process on top of translation needs to know *why* a run happened, not
just that it did. We let editors choose a per-run mode (AI with review, AI without review, manual, …)
and the callback is where that choice has to be applied — so the mode has to survive the round trip.
## What we do instead
We write an intent record before enqueue and have the callback join on `(collection, documentId,
targetLocale)` plus "is a run open". To make that join unambiguous we enforce **one open run per
document × target locale**, which is a real constraint we would rather not need: it means a host
cannot run two translations of the same pair concurrently even where that would be harmless.
It also makes retries unusable. `onFailed` fires per attempt and carries no attempt counter, so a host
cannot tell attempt 1 from attempt 3 and must run with `retries: { attempts: 0 }`.
## Suggested shape
Let `enqueue` accept an opaque `context` (or `metadata`) value per call and hand it back verbatim to
every callback for jobs from that enqueue. A run id generated by the plugin and passed to callbacks
would also solve it. Either removes the need for the single-open-run constraint and makes per-attempt
callbacks distinguishable if an attempt number rides along too.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.