Files
open-code-review/internal
Qiaochu Hu 9f0f63d5ab fix(llmloop): drain per-file comment work without racing pool submissions (#449)
executeSubtask called the pool-wide CommentWorkerPool.Await() from each
per-file goroutine before running the review filter, while other files'
tool-use loops were still calling Submit(). The pool's own contract
forbids Await concurrent with Submit: both use the same sync.WaitGroup,
so an Add landing while Wait is blocked panics with "Add called
concurrently with Wait" or "WaitGroup is reused before previous Wait
has returned". The panic is recovered by the subtask wrapper, so the
symptom is a spurious per-file failure (or, depending on the
interleaving, a corrupted counter that hangs the final Await).

Add SubmitFor/AwaitKey so a caller can drain only the units submitted
under one key. The review path keys submissions by the reviewed file's
path: a file's loop submits all its async comment work before its
AwaitKey runs, so the per-key WaitGroup Add/Wait pairing is race-free,
and draining no longer waits for (or crashes into) other files'
in-flight submissions. The pool-wide Await remains for the end-of-run
call sites, where all submissions have finished.
2026-07-22 20:39:45 +08:00
..
…