Repository navigation
Conversation
…() and the other lambda-free stages (#1172) A lambda followed to the pool workers only while every stage between it and the terminal operation was woven. sorted, distinct, limit, skip, parallel(), sequential() and the as*Stream conversions were not, so list.stream().map(...).parallel().sorted().toList(), a common shape, ran its map lambda unattributed, and a race in it was seen on the caller's own elements alone. flatMap, takeWhile, dropWhile and the primitive-to-primitive maps left their own lambdas unattributed too. The lambda-free stages now carry the slots behind them to the stream they return (a Stream's parallel, sequential and unordered return BaseStream, which is what their call sites expect). flatMap, takeWhile, dropWhile and the remaining mapTo* lambdas wait in slots like map's, and a sorted comparator runs as a combine, since a parallel sort compares what other subtasks produced. 47 additive hooks, @SInCE 1.14.2. Tests first: four new cases in AgentParallelStreamHooksTest failed to compile on the missing hooks; all 23 pass. Dropping the sorted() carry, or running the comparator as a plain element, each turns its own case red. Corpus: parallelMapThenSorted with and without a lock; idiom lane 88/88, every lane green. Library 3967 and agent 118 tests green, static gate chain green. The javadoc restatement gate caught one "@PARAM comparator the comparator" on the way; reworded. Still not followed: mapMulti, a pipeline ended by iterator(), and a Collector's own functions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Stacked on #1225 and #1226: review the last commit (
d65a6d8c0). The first two commits are theirs and drop out of this diff as they merge. All three changedocs/CHANGELOG.md, which is why they are chained.Partly addresses #1172. What is still not followed stays there (listed below).
Why
A lambda reached the common pool's workers only while every stage between it and the terminal operation was woven.
sorted,distinct,limit,skip,parallel(),sequential()and theas*Streamconversions were not. Solist.stream().map(...).parallel().sorted().toList(), a common shape, ran itsmaplambda unattributed, and a race in it was seen only on the caller's own elements. The lambdas offlatMap,takeWhile,dropWhileand the primitive-to-primitive maps (IntStream.mapToLongand the rest) ran unattributed too.What changed
sorted(),distinct,limit,skip,parallel(),sequential()on all four stream kinds, aStream'sunordered(), andasLongStream/asDoubleStream. AStream'sparallel,sequentialandunorderedare declared byBaseStream, so their call sites expect aBaseStreamback, and those hooks return exactly that.map's:flatMap,takeWhileanddropWhileon all four kinds, and the six primitive-to-primitivemapTo*.sorted(Comparator)comparator runs as a combine: a parallel sort compares elements other subtasks produced, after a join the agent does not see, so it is ordered after the elements that built them, like areduceoperator.@since 1.14.2, and 47 weaver rows.How it was verified
AgentParallelStreamHooksTestfailed to compile on the missing hooks. All 23 cases in the class pass now.sorted()carry turnsaLambdaStaysLentBehindTheCarryingStagesred. Running the comparator as a plain element instead of a combine turnsaSortedComparatorIsOrderedAfterTheElementsItComparesred: a correct parallel sort was then reported as a race.idiom_parallelMapThenSorted_plainCounter(MUST_FIRE) and its locked twin (MUST_STAY_SILENT). The idiom lane passed 88/88 and every other lane is green.JavadocDescribesRatherThanRestatesTest, on a new@param comparator the comparator; I reworded it and that class and the stream class pass. The agent suite was skipped in that first run because the reactor stopped, so I ran it on its own afterwards (118 green).Docs
The
docs/CHANGELOG.md#1172 entry,docs/agent/limitations.mdanddocs/analysis/corpus-eval-future-improvements.mdnow list what is followed and what is not. No VibeTags guardrail was added: the hooks class's contract-frozen rule covers the new hooks, and no external contract changed.Checklist
VIBETAGS-START/VIBETAGS-ENDmarkers@since 1.14.2Co-Authored-BytrailerStill not followed (tracked in #1172)
A
mapMultilambda, a stage behind a primitive stream'sunordered()oronClose, a pipeline ended byiterator(), and aCollector's own functions.🤖 Generated with Claude Code