C.W.K.
Stream
Lesson 04 of 05 · published

Reconcile Before You Re-Pay

~10 min · reconcile, recovery, no-auto-repay

Level 0Silent
0 XP0/36 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete
"An ambiguous job is a question, not a dead end. Reconcile asks every source you already have before anyone even mentions paying again."

Turning Ambiguous Into Answered

Track 1 gave you the ambiguous state; this is how it gets resolved. Reconciling a failed or ambiguous job is a search, in order, through everything you might already own. First the cache: maybe the job actually finished and the audio is right there. Then the durable chunk lineage: maybe every paid chunk is saved and only the local concat failed, so the file rebuilds for free. Then provider history: the provider may have a record, tied to your request ID, of the audio it produced and the charge it made. Each of these recovers the result at zero new cost.

The Line Reconcile Never Crosses

Here's the invariant that keeps recovery safe: reconcile reuses, it never re-buys. It can read the cache, rebuild from chunks, and query provider history — but it will not issue a new paid request on its own. If none of those sources holds the audio, reconcile stops and reports that a decision is needed. A second paid attempt is a deliberate act, never a silent step hidden inside a recovery routine.

Why Automatic Re-Pay Would Undo Everything

If reconcile could quietly pay again to "just fix it," every ambiguous timeout would risk a double charge — exactly the outcome the whole track exists to prevent. By making reconcile strictly non-spending, an ambiguous job can be retried, resumed, and repaired as many times as needed with no fear, because none of those paths can cost money. The spend decision is lifted out of the automatic layer entirely.

Code

Check everything you own; stop before spending·python
def reconcile(job: Job) -> Resolution:
    # 1. Did we already finish? The cache may hold the audio.
    if audio := cache.get(job.identity):
        return Resolution.recovered(audio, cost=0)

    # 2. Are the paid chunks durable? Rebuild the file locally, no new call.
    if chunks := lineage.chunks_for(job.id):
        return Resolution.recovered(ffmpeg_concat(chunks), cost=0)

    # 3. Ask the provider what it has on record for OUR request id.
    if hist := provider.history(job.request_id):
        return Resolution.recovered(lineage.adopt(hist.audio), cost=0)

    # Nothing recovered. Reconcile STOPS here -- it never pays on its own.
    return Resolution.needs_decision(job)

External links

Exercise

Design a reconcile routine for an ambiguous payment or side effect in a system you know. List, in order, every source you'd check to recover the result for free before considering a second attempt — local record, saved intermediate, remote history. Then state the hard rule: at what point does your routine stop and hand the spend decision to a human?
Hint
The ordering goes cheapest-and-closest first: your own cache, then your saved pieces, then the remote's memory. The routine's job is to recover for free or stop — never to decide, by itself, to pay again.

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.