Skip to content

feat(speculation): generator contract and bestfirst impl - #446

Open
behinddwalls wants to merge 1 commit into
mainfrom
preetam/speculation-generator
Open

feat(speculation): generator contract and bestfirst impl#446
behinddwalls wants to merge 1 commit into
mainfrom
preetam/speculation-generator

Conversation

@behinddwalls

@behinddwalls behinddwalls commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

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

Issues

Stack

  1. @ feat(speculation): generator contract and bestfirst impl #446
  2. feat(speculation): allocator contract and sticky impl #450
  3. feat(speculation): standard composed speculator #451
  4. feat(storage): speculation path set store #501
  5. feat(storage): path-build link store for per-path builds #502
  6. feat(orchestrator): dispatch builds per speculation path #503
  7. feat(orchestrator): poll builds and stop the ones nothing wants #504
  8. fix(orchestrator): mint distinct message IDs for cancel re-publishes #505
  9. feat(orchestrator): re-plan the queue from the Speculator each run #506
  10. feat(orchestrator)!: finalize batches from their speculation paths #507
  11. feat(orchestrator): compose per-queue speculators and turn speculation on #508

@behinddwalls
behinddwalls force-pushed the preetam/speculation-generator branch 3 times, most recently from c8ec6b1 to 3fb7e2b Compare July 27, 2026 23:14
@behinddwalls
behinddwalls marked this pull request as ready for review July 27, 2026 23:17
@behinddwalls
behinddwalls requested review from a team and sbalabanov as code owners July 27, 2026 23:17
@behinddwalls
behinddwalls force-pushed the preetam/speculation-generator branch 2 times, most recently from 5e0bdbd to 3fb7e2b Compare July 28, 2026 19:13
Comment thread submitqueue/extension/speculation/generator/README.md Outdated
Comment thread submitqueue/extension/speculation/generator/generator.go Outdated
Comment thread submitqueue/extension/speculation/generator/generator.go Outdated
Comment thread submitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment thread submitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment thread submitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment thread submitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment thread submitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment thread submitqueue/extension/speculation/generator/bestfirst/bestfirst.go Outdated
Comment thread submitqueue/extension/speculation/generator/bestfirst/bestfirst_test.go Outdated
@behinddwalls
behinddwalls force-pushed the preetam/speculation-generator branch from 3fb7e2b to 5e2ad89 Compare July 29, 2026 18:12
@behinddwalls
behinddwalls force-pushed the preetam/speculation-generator branch from 5e2ad89 to 4c727b2 Compare July 29, 2026 18:24
@behinddwalls
behinddwalls requested a review from sbalabanov July 29, 2026 18:41
@behinddwalls
behinddwalls force-pushed the preetam/speculation-generator branch from 4c727b2 to ccb1aa4 Compare July 29, 2026 22:31
@behinddwalls
behinddwalls force-pushed the preetam/speculation-generator branch 3 times, most recently from e9e54ca to ee4ab40 Compare July 29, 2026 23:18
@behinddwalls
behinddwalls force-pushed the preetam/speculation-generator branch from ee4ab40 to d5dd68b Compare July 29, 2026 23:18
Base automatically changed from preetam/speculation-speculator to main July 30, 2026 01:19
@behinddwalls
behinddwalls force-pushed the preetam/speculation-generator branch from d5dd68b to e3d56b0 Compare July 30, 2026 01:19
## 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
behinddwalls force-pushed the preetam/speculation-generator branch from 688c44f to 4871c73 Compare August 4, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants