Batched, resumable, self-correcting distillation pipeline
The initial build is slow, expensive, and likely to fail somewhere. A single model call over a whole repository hits the output limit, loses everything if it fails, and spreads the model's attention too thin. So the pipeline splits the work into small batches, and a failure halfway through only costs the batch that failed.
Implementation details
- File-aware packing groups a file's units together up to a token budget and sub-splits a single oversized unit, so the model always distils a symbol alongside its local context
- Each batch commits in its own transaction, so partial progress survives a later failure and re-running init skips batches already done; a failed batch is isolated, recorded with its failure kind, and the run finishes the rest
- Retry depends on why the batch failed: a truncated reply is re-planned into smaller sub-batches with the budget halved per attempt, a transient error backs off, invalid JSON retries once and then stays visibly failed, capped at three attempts
- A batch is identified by its packing ordinal, not by the set of coordinates it covers, because sub-split pieces share one parent coordinate and keying by coordinate re-distilled a whole oversized file once per piece