guard: say which road the stopped run hole came by - #91
Merged
Conversation
The hole this guard is about had two roads to it and the guard could not tell them apart. drain asks about cancellation AFTER taking an index, so the writer holding index zero can lose the processor in between, come back to a cancelled context and return without ever reaching its generator. Same hole, same manifest, weaker proof - a file that never started is not a file cut off half way. Measured with tools/probes/stoprace -held before changing anything: never entered 0 times in 50 idle runs and 0 in 25 starved ones. So the second road is one the construction allows and the machine does not take, and that number decided the shape of this change. The cancellation condition is therefore NOT rebuilt. Requiring the generator to have started before cancelling would be a change with no measured effect that carries its own risk, since a generator that never started would end the run in success. What is added instead is a net: the generator records that it was reached and the guard asserts it, as a fourth assertion beside the three it already makes about its own reach. This turns "measured once, did not happen" into "cannot happen unnoticed", which matters because the sizes and the cancellation condition above it are both things a later change can move. Measured after: 50 runs including 30 under CPU starvation, zero failures, the prefix mutation still reddens it, race detector clean. The assertion has no mutation of its own and that is deliberate - no mutation of product code reddens it alone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Follow-up to #90, found by analysing the merged change rather than by a failure.
The gap
The hole that
TestARunStoppedPartWayNamesEveryFileThatFinishedis about had two roads to it, and the guard could not tell them apart.drainasks about cancellation after taking an index, so the writer holding index zero can lose the processor in between, come back to a cancelled context and return without ever reaching its generator. Same hole, same manifest, weaker proof - a file that never started is not a file cut off half way.The measurement decided the shape of the fix
Measured with
tools/probes/stoprace -heldbefore changing anything:So the second road is one the construction allows and the machine does not take.
That is why the cancellation condition is not rebuilt. Requiring the generator to have started before cancelling would be a change with no measured effect that carries its own risk - a generator that never started would end the run in success. What is added instead is a net: the generator records that it was reached, and the guard asserts it as a fourth assertion beside the three it already makes about its own reach.
It turns "measured once, did not happen" into "cannot happen unnoticed", which matters because the sizes and the cancellation condition above it are both things a later change can move.
Verified
-raceclean over 5 runs,staticcheckv0.8.1,gofmt,vetcleanstaleness.py(912 patterns, each occurring exactly once)Deliberately absent: a mutation for the new assertion. No mutation of product code reddens it alone, so it stands in the same category as the three assertions beside it.
Not run: the full suite and preflight - this goes to CI.
🤖 Generated with Claude Code