Skip to content
C.W.K.
Stream
Lesson 04 of 05 · published

Late Results Ask Permission

~11 min · compare-and-set, late-results, cancellation, integrity

Level 0Dry Nib
0 XP0/36 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete
"Late work may finish; only current work may land."

Name the protected result

Background work finishes in a world it cannot assume still exists. The entry may be deleted, the source edited, or the job cancelled while a model is thinking. Completion is therefore a proposal to land, not a command.

Put the promise in state

Load the entry after the model returns, require it to remain live, and compare its exact original text with the worker's birth snapshot. Re-read the job too and require its status to remain running. Only after the entry, job, and exact source snapshot pass their guards should the worker call the translation write method.

The quiet failure

Checking freshness before the model call leaves a race after the check. Checking only after writing exposes stale output briefly. The pipeline performs the final entry and job guards immediately before the write; set_translation_text itself is a write method, not a boolean guard.

Invariant. Late work may finish; only current work may land.

Trace five moments

To test “Late Results Ask Permission,” inspect the moment before creation, after commit, when a worker claims the job, when output returns, and on the next-day reload. At each point record entry state, job state, captured source text, and visible copy. A promise that survives only the successful request is conditional sovereignty.

Do the work

Write the guarded completion path and enumerate every reason it may refuse to land. Add source editing, entry deletion, worker restart, and external-service failure to the same table. Mark when dropping an output is integrity preservation rather than data loss.

The final question

Does the screen keep the original visible while telling the truth about work around it? Then adornment serves. If a spinner hides failure or a late result overwrites current text, the adornment has stolen the throne.

Landing condition

The freshly loaded entry must still be live, its original text must equal the worker snapshot, and the freshly loaded job must still be running. Deletion, source editing, cancellation, or supersession all turn completion into a clean drop instead of a forced write.

A generated result can be valuable and still have no permission to alter the current entry.

Code

Land only in the birth world·python
def land_translation(store, snapshot, translated_text):
    fresh = store.get_entry(snapshot["entry_id"])
    if fresh is None or fresh["status"] != "live":
        return "dropped: entry unavailable"

    job = store.get_job(snapshot["job_id"])
    if job is None or job["status"] != "running":
        return "dropped: job superseded"

    if fresh["original_text"] != snapshot["original_text"]:
        return "dropped: source changed"

    store.set_translation_text(
        snapshot["entry_id"], snapshot["lang"], translated_text
    )
    return "landed"

External links

Exercise

Write the guarded completion path and enumerate every reason it may refuse to land.
Hint
Distrust any completion path that never re-reads current state.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.