Sync jobs

The server-side engine behind CLI syncs — phases, strategies, statuses, resumability, and failure handling.

Not verified yet

A sync job is a server-side, resumable job that reconciles a submitted set of translation strings against a namespace — diffing, pushing the changes, and optionally AI-translating whatever is still missing. It's the engine behind nrc langsync sync; you'll rarely create one by hand, but understanding how it behaves explains everything the CLI reports.

The four phases

Every job runs the same pipeline:

  1. Planning. Compare the submitted marks and values against the namespace's current state, and write an ordered list of operations: create (mark doesn't exist), update (value changed), delete (only when pruning).
  2. Pushing. Apply each operation. Progress counters (created / updated / deleted) tick as it goes. In a namespace whose message syntax is icu, each pushed value is checked first; a refused one fails its operation with a code. After the operations, the job stores the key descriptions the request sent.
  3. Autotranslating. Run the AI engine over every term × language cell that's still empty, with each term's key and description, glossary included. A translation that fails the checks is not stored and becomes a failure entry with a code.
  4. Finalizing. Assemble the resulting per-language state — the complete mark → value map for every attached language — which is what the CLI writes back to your local files.

Statuses

pending → planning → planned                        (terminal for dry-run)
                   └→ pushing → autotranslating → finalizing → completed

failed and cancelled are the other terminal states. A dry-run stops at planned with the plan attached — nothing is applied.

Poll the job over the API (GET /namespaces/{name}/sync/{jobId}) to watch it move; that's exactly what the CLI's live dashboard does. The response carries the status, per-phase progress counters, the plan (for dry-runs and in-flight pushes), the resulting per-language state, a count of cells that remained untranslated, unreviewedPerLanguage, and a list of failures if any occurred.

unreviewedPerLanguage is set once the job is completed: per language code, how many translations have text that nobody has marked reviewed. The job's source language is not in it.

Options

OptionDefaultWhat it does
strategylocallocal = push the submitted strings, then autotranslate. server = don't push anything; just autotranslate what's missing and return the server state. Use server for a read-only refresh.
pruneoffDelete server-side marks that are missing from the submitted set. Without it, marks you didn't submit are left alone.
dryRunoffStop after planning; return the plan without applying anything.
waitForAutotranslateonWhether the job should be polled through the autotranslate phase before the client reports completion.
waitTimeoutSeconds120Server-side cap on that wait.
contextsnoneKey descriptions, {key: description}, stored with the terms and given to the model. See below.
retranslateOnSourceChangeoffWhen an update changes a term's source-language value, clear its other-language translations so the AI regenerates them from the new source. Off means stale translations stay until you deal with them.
source languagenamespace defaultThe submitted strings' language. When it differs from the namespace default, autotranslate uses your language as the translation source — see source-of-truth language.

Key descriptions (contexts)

A short key such as close or changes can mean several things. A description says where the text is used ("button that closes the dialog"), and the model gets it with the key whenever it translates the term. The CLI sends descriptions from the namespace's context_file.

contexts maps keys of the request's source language to descriptions:

  • every key must be one of the source-language keys in the same request, and there can't be more entries than those keys;
  • a description is at most 1,000 characters of valid text;
  • an empty description clears the term's description, and a key left out keeps the one it has.

The job stores them in each term's context (the Context field of the dashboard) after its push operations, so new terms get theirs too, and before autotranslate, so the model reads them. A server strategy or a dry-run pushes nothing and stores no descriptions.

A request that breaks a rule is refused before a job is created with 400 SYNC_CONTEXTS_INVALID. data.reason says which rule:

reasonMeaningOther data
too_manyMore entries than the request has source-language keys.max
unknown_keyAn entry names a key the request's source language does not have.key
too_longA description is longer than 1,000 characters.key, maxChars
not_textA key or a description is not valid text (invalid UTF-8 or a NUL character).key

Failure entries

Each entry of failures has the phase it happened in (push or autotranslate), the operation's opIdx and the term's mark where there is one, and error, an English sentence for logs.

An entry about a translation that was not stored because of its text also has:

FieldMeaning
codeWhy: placeholders_changed, icu_invalid, plural_forms, tags_changed, glossary_term_missing, too_many_variants, untranslated or model_failed. See the codes.
languageCodeThe language of the translation.
offset, argument, missing, unexpectedThe code's facts, when it has them.
  • Phase autotranslate: one entry per key and language the engine refused. The cell stays empty; other keys and languages are stored. A job lists at most 500 of these and then one more entry whose dropped counts the rest.
  • Phase push: a pushed value an icu namespace refused. The operation fails and the job goes on; a refused source value creates no term.

Reliability guarantees

Sync jobs are built to survive crashes and never double-charge AI work:

  • One worker at a time. Workers claim jobs with a short exclusive lease that they keep refreshing; a competing worker can't pick up a live job.
  • Resumable, idempotent operations. Every planned operation records whether it has been applied. If a worker dies mid-push, the next one resumes from the first unapplied operation; re-running an applied operation is a no-op.
  • Autotranslate fires at most once. The job records the moment autotranslate is triggered before dispatching it; resumption sees the marker and never re-triggers the AI batch.
  • Failures are captured, not fatal. If individual operations fail, the job continues, completes, and reports the failures list — three bad rows out of a hundred don't waste the other ninety-seven. The CLI surfaces these in its Issues block along with diagnostic hints (a common one: source values that are empty, which autotranslate skips).

Retention

Job records — the plan, progress counters, results, and failures — are kept for 7 days after completion, then deleted automatically. Pull anything you need for audits before that; the job's creation, completion, or failure is also permanently recorded in the audit log (sync_job.created / sync_job.completed / sync_job.failed).

Edge cases worth knowing

  • Pruning deletes are permanent. A local + prune job removes server marks missing from your submission — terms and all their translations. Run --dry-run first when in doubt.
  • server strategy never writes your submitted values. It's safe to run against a namespace someone else is editing — you'll get their edits, they won't get yours.
  • The wait is client-side convenience, not job control. If the wait times out, the job keeps running server-side; the CLI writes whatever is finished and tells you translations are still draining. Re-run nrc langsync pull later to pick up the rest.
  • CLI project sync — the tool that creates these jobs and everything about its flags.
  • Auto-translate — how the AI phase translates and what it costs.

On this page