Persist each lane's answer as it lands, not after the last one (#58) - #59
Open
CryptoJones wants to merge 1 commit into
Open
Persist each lane's answer as it lands, not after the last one (#58)#59CryptoJones wants to merge 1 commit into
CryptoJones wants to merge 1 commit into
Conversation
A run interrupted anywhere in the fan-out discarded every answer it had already collected. `list(pool.map(...))` blocks until the last lane returns, and the transcript was written only after that, so all answers lived in memory for the whole run. A SIGKILL, a closed terminal, a harness timeout or a Ctrl-C threw the lot away — including paid http lanes that had already billed for tokens nobody would ever read. It presents as a run that "randomly dies" with zero output and no transcript, and it is worst exactly when it costs most: a long brief with many lanes, where the slowest lane decides whether the rest survive. The transcript path is now claimed before the fan-out and rewritten after every lane completes, driven by as_completed. Each result is written into the slot its lane was dispatched from, so ordering is preserved and a partial transcript reads like a complete one with null for the lanes still out. Writes go to a .tmp and are replaced into place, so a kill mid-write leaves the previous good transcript rather than a truncated one. Partial transcripts carry "partial": true and a note; the final write clears it and attaches the synthesis. Verified: kill -9 mid-run now leaves a transcript holding the two lanes that had answered, third slot null. A completed run is unchanged — no partial marker, synthesis and collisions attached, no stray .tmp. Suite green (119 passed, 29 subtests). Verification set items 1 and 2 re-run by hand. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VmauK5UCYGRYyXoQ36FQ3S
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #58 — the "roundtable randomly dies" bug.
The problem
main()collected the fan-out withresults = list(pool.map(...))and wrote the transcript only afterwards. Every answer was held in memory until the last lane returned, so any interruption during the fan-out discarded all completed lanes — including paidhttplanes that had already billed for tokens nobody would ever read.It presents as a run that dies with zero output and no transcript, and it bites hardest when it costs most: a long brief with many lanes, where the slowest lane decides whether the other eleven survive. Observed tonight on a 7-lane, 92 KB brief — stopped mid-flight, 0 bytes out, no transcript, after every lane had been dispatched.
The change
as_completedand rewrite the transcript after every lanenullfor lanes still out.tmpthenreplace), so a kill during the write leaves the previous good transcript instead of a truncated one"partial": trueplus a note; the final write clears the marker and attaches the synthesisBehaviour on a successful run is unchanged.
Verification
kill -9mid-run now leaves a transcript holding the two lanes that had answered, third slotnull,partial: true. Before the change that kill left nothing.synthesisandcollisionsattached, no stray.tmp.--listshows the correct route per lane with zero network calls; a full run has every lane answer with exit0.Proudly Made in Nebraska. Go Big Red! 🌽 https://xkcd.com/2347/