feat(speculation): generator contract and bestfirst impl - #446
Open
behinddwalls wants to merge 1 commit into
Open
feat(speculation): generator contract and bestfirst impl#446behinddwalls wants to merge 1 commit into
behinddwalls wants to merge 1 commit into
Conversation
This was referenced Jul 27, 2026
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
3 times, most recently
from
July 27, 2026 23:14
c8ec6b1 to
3fb7e2b
Compare
behinddwalls
marked this pull request as ready for review
July 27, 2026 23:17
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
2 times, most recently
from
July 28, 2026 19:13
5e0bdbd to
3fb7e2b
Compare
This was referenced Jul 28, 2026
sbalabanov
requested changes
Jul 28, 2026
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
from
July 29, 2026 18:12
3fb7e2b to
5e2ad89
Compare
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
from
July 29, 2026 18:24
5e2ad89 to
4c727b2
Compare
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
from
July 29, 2026 22:31
4c727b2 to
ccb1aa4
Compare
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
3 times, most recently
from
July 29, 2026 23:18
e9e54ca to
ee4ab40
Compare
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
from
July 29, 2026 23:18
ee4ab40 to
d5dd68b
Compare
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
from
July 30, 2026 01:19
d5dd68b to
e3d56b0
Compare
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
from
July 30, 2026 07:31
e3d56b0 to
4eddce6
Compare
behinddwalls
changed the base branch from
main
to
preetam/speculation-assumptions
July 30, 2026 07:42
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
4 times, most recently
from
August 4, 2026 01:58
d98d5a4 to
688c44f
Compare
This was referenced Aug 4, 2026
## Summary ### Why? The standard Speculator needs a ranked stream of candidate speculation paths to fund. Nothing enumerates or ranks the path space today. ### What? Adds `submitqueue/extension/speculation/generator` — the Generator/PathIterator contract — plus the `bestfirst` implementation and mocks. The generator is a pure enumerator: `Open` takes only the queue's batches and offers every coherent path, including ones whose builds already ran. Suppressing those belongs to the Allocator, which already reconciles candidates against the stored path sets by ID. `bestfirst` ranks each path by how likely all its assumptions are to hold and generates lazily: one heap holds the frontier of every head's path tree, so pulling k paths does O(k) work however large the space behind them — which is also why the old depth bound is gone. Scores are summed log probabilities so wide heads cannot underflow into ties, and a canonical subset expansion emits each path exactly once, in non-increasing score order. The full design — tie-breaks, per-dependency derivation, the floating-point pitfalls — is documented in `generator/bestfirst/README.md` and next to the code. Also sharpens `scorer.Scorer`'s contract: it returns the probability that a batch's build succeeds — the quantity bestfirst consumes — not "the likelihood of a successful land". ## Test Plan ✅ `bazel test //submitqueue/extension/...` — ordering, uniqueness, canonical score sums, wide-head underflow (7100-dependency heads), score validation, context cancellation, and the no-copy `Open` contract. ✅ `make fmt`, `make gazelle`, `make mocks`
behinddwalls
force-pushed
the
preetam/speculation-generator
branch
from
August 4, 2026 05:11
688c44f to
4871c73
Compare
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.
Summary
Why?
The standard Speculator needs a ranked stream of candidate speculation paths to fund. Nothing enumerates or ranks the path space today.
What?
Adds
submitqueue/extension/speculation/generator— the Generator/PathIterator contract — plus thebestfirstimplementation and mocks.The generator is a pure enumerator:
Opentakes only the queue's batches and offers every coherent path, including ones whose builds already ran. Suppressing those belongs to the Allocator, which already reconciles candidates against the stored path sets by ID.bestfirstranks each path by how likely all its assumptions are to hold and generates lazily: one heap holds the frontier of every head's path tree, so pulling k paths does O(k) work however large the space behind them — which is also why the old depth bound is gone. Scores are summed log probabilities so wide heads cannot underflow into ties, and a canonical subset expansion emits each path exactly once, in non-increasing score order. The full design — tie-breaks, per-dependency derivation, the floating-point pitfalls — is documented ingenerator/bestfirst/README.mdand next to the code.Also sharpens
scorer.Scorer's contract: it returns the probability that a batch's build succeeds — the quantity bestfirst consumes — not "the likelihood of a successful land".Test Plan
✅
bazel test //submitqueue/extension/...— ordering, uniqueness, canonical score sums, wide-head underflow (7100-dependency heads), score validation, context cancellation, and the no-copyOpencontract.✅
make fmt,make gazelle,make mocksIssues
Stack