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

Save Every Paid Chunk Before You Stitch

~9 min · chunk-lineage, durability, concatenation

Level 0Silent
0 XP0/36 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete
"Each chunk was paid for separately. Save each one durably before you try to combine them, or a stitching failure burns real money."

Long Text Is Many Paid Calls

A long passage doesn't go to the provider as one request — it's split into chunks, each synthesized on its own (you'll see exactly how the splitting works in Track 7). Every chunk is a separate paid call producing its own audio. Only at the end are those pieces concatenated into a single file. That final concatenation is a local muxing step, and local steps fail: a bad container flag, a full disk, a crash mid-write.

The Rule: Durable Before Combine

Bellows copies each returned chunk into durable lineage before concatenation. So when the concat step fails, you've lost only the concat — a cheap, local, repeatable operation — and not the paid provider audio, which is already safe on disk. Without this, chunks held only in memory would vanish on a muxing failure, and rebuilding the file would mean paying for every chunk again. The lineage turns an expensive failure into a trivial one.

Lineage Outlives the Final File

Keeping the chunks around isn't just crash insurance — it's what makes later repair and Studio rerolls possible without new spend. The final concatenated file is derived; the chunks are the paid originals. When something downstream needs to be rebuilt, it's rebuilt from the durable chunks, and the provider is never asked to do work it already did.

Code

Paid chunks land durably before the fragile combine·python
def synthesize_long(chunks: list[str], binding, settings, job_id: str) -> Audio:
    chunk_paths = []
    for i, chunk_text in enumerate(chunks):
        raw = provider.synthesize(chunk_text, binding, settings)  # PAID, per chunk
        # Save EACH paid chunk durably BEFORE trying to stitch anything.
        path = lineage.save_chunk(job_id, i, raw)
        chunk_paths.append(path)

    # Concatenation is a LOCAL muxing step. If it fails now, it's CHEAP:
    # re-run the concat from the durable chunks -- no chunk is re-synthesized.
    return ffmpeg_concat(chunk_paths)

External links

Exercise

Find a batch operation you know that makes several expensive sub-calls and then combines their results — a multi-part upload, a map-reduce, a document assembled from generated sections. Identify the moment each expensive piece becomes durable. If it's only after the final combine succeeds, describe what a failure at the combine step costs, and move the durability earlier.
Hint
Draw the line between 'expensive and remote' and 'cheap and local.' Everything expensive should be on disk before anything cheap-and-fragile runs. A crash should never be able to throw away work you paid for.

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.