Fencing stale task attempts
Status: Ready
Article ID: 052
Truth label: Current
Audience: Backend builder
Reader outcome: Explain how an incrementing fence prevents an old result from replacing a newer task attempt.
Related articles: 004, 051, 054
Target week: 21
Last verified: 2026-09-13
Technical reviewer: Codex source audit
Editorial reviewer: Codex editorial audit
Give every attempt an order
The task's run attempt increments on claim and serves as its fence. Logs, leases, run tokens, and results carry that number. A higher fence represents a newer ownership generation.
Reject state replacement
When a result arrives, Central compares its fence with current task state. A matching current attempt can transition the task. An older attempt is recorded as superseded and cannot overwrite the newer result.
Preserve late evidence
Historical run-token rows let Central authenticate a late report from a real old claim. The ledger keeps its cost, files, and outcome as superseded evidence while terminal task state remains with the current fence.
Test the race
In a scratch data root, expire attempt one, claim attempt two, then deliver the old result. Verify the response says superseded, the task still names attempt two, and history contains both records.
Current limits
Fences protect task state, not external side effects or filesystem edits. A stale process can still have changed files before its result was refused.
Next lesson
Continue with Deliver results through an outbox.
Derivative map
- Weekly package: WEEK-21
- Long video: VIDEO-W21-LONG
- Shorts: SHORT-W21-PROBLEM, SHORT-W21-MECHANISM, SHORT-W21-WARNING
- Email: EMAIL-W21
- LinkedIn: LI-W21-A, LI-W21-B
- X: X-W21-A, X-W21-B
- Visual: VISUAL-W21
Review record
- Fence generation, authentication, superseded handling, and history checked against current source.
- Filesystem and external-effect limits reviewed.
- Race exercise uses a scratch data root.
- Internal links and repository voice reviewed.
Review completed: 2026-08-27
Re-audited against the running product: 2026-09-13