Skip to content

feat(speculation): add selector + selection-limit extensions#317

Open
behinddwalls wants to merge 1 commit into
preetam/ext/speculation-scorerfrom
preetam/ext/speculation-selector
Open

feat(speculation): add selector + selection-limit extensions#317
behinddwalls wants to merge 1 commit into
preetam/ext/speculation-scorerfrom
preetam/ext/speculation-selector

Conversation

@behinddwalls

@behinddwalls behinddwalls commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add the selector seam and its limit counterpart from the speculation RFC, as vendor-agnostic extension interfaces under submitqueue/extension/speculation/.

selector: the controller hands it the batch's speculation tree; it returns a per-path decision (Promote/Cancel) for the paths it chooses to act on. It is the policy seam — it reads the tree it is given and emits decisions only, never writing status, and does not decide merging. The controller maps each decision to a guarded status transition (Promote → Selected, Cancel → Cancelling/Cancelled) and persists it, staying the single writer of tree state.

selectionlimit: the "how much" policy bounding how many paths a batch may build in parallel. It is the selector's companion — the selector decides which paths, the limit decides how many. Injected into the selector at construction and called by it, keeping the selector interface limit-free; the value is dynamic, not a fixed constant.

Each follows the repo extension contract: Factory.For(Config) (T, error) with Config carrying only QueueName. Includes READMEs, gomock packages, and programmable fakes. Interfaces only; concrete impls and controller wiring are deferred.

Test Plan

Issues

Stack

  1. feat(entity,storage): rework speculation tree model and store #231
  2. feat(speculation): add enumerator + dependency-limit extensions #315
  3. feat(speculation): add path scorer extension #316
  4. @ feat(speculation): add selector + selection-limit extensions #317
  5. feat(speculation): add prioritizer + prioritization-limit extensions #320

@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-scorer branch from e954c66 to 4e8b0ba Compare July 8, 2026 21:50
@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-selector branch from a091730 to 5e6a56f Compare July 8, 2026 21:51
@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-scorer branch from 4e8b0ba to 86f877f Compare July 8, 2026 21:56
@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-selector branch from 5e6a56f to e89bb7c Compare July 8, 2026 21:56
@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-scorer branch from 86f877f to 9dc7023 Compare July 8, 2026 23:14
@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-selector branch from e89bb7c to 0ab1871 Compare July 8, 2026 23:14
@behinddwalls behinddwalls marked this pull request as ready for review July 8, 2026 23:20
@behinddwalls behinddwalls requested review from a team and sbalabanov as code owners July 8, 2026 23:20
@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-scorer branch from 9dc7023 to 0209c43 Compare July 9, 2026 17:02
@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-selector branch from 0ab1871 to d9084c2 Compare July 9, 2026 17:02
@behinddwalls behinddwalls marked this pull request as draft July 9, 2026 17:03
Add the selector seam and its limit counterpart from the speculation RFC, as vendor-agnostic extension interfaces under submitqueue/extension/speculation/.

selector: the controller hands it the batch's speculation tree; it returns a per-path decision (Promote/Cancel) for the paths it chooses to act on. It is the policy seam — it reads the tree it is given and emits decisions only, never writing status, and does not decide merging. The controller maps each decision to a guarded status transition (Promote → Selected, Cancel → Cancelling/Cancelled) and persists it, staying the single writer of tree state.

selectionlimit: the "how much" policy bounding how many paths a batch may build in parallel. It is the selector's companion — the selector decides which paths, the limit decides how many. Injected into the selector at construction and called by it, keeping the selector interface limit-free; the value is dynamic, not a fixed constant.

Each follows the repo extension contract: Factory.For(Config) (T, error) with Config carrying only QueueName. Includes READMEs, gomock packages, and programmable fakes. Interfaces only; concrete impls and controller wiring are deferred.
@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-scorer branch from 0209c43 to 5b2d34f Compare July 9, 2026 17:42
@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-selector branch from d9084c2 to 0ae2849 Compare July 9, 2026 17:42
behinddwalls added a commit that referenced this pull request Jul 9, 2026
## Summary
Reshape the speculation tree data model around the Base/Head path that
the build stage actually consumes, and align its store with the
speculation design.

entity: SpeculationPath{Base, Head} becomes the unit;
SpeculationPathInfo carries the path plus its Score, controller-owned
Status
(candidate/selected/prioritized/building/passed/failed/cancelling/cancelled),
and BuildID — Path is immutable once persisted, Score/Status/BuildID are
updateable by the controller. Score is scorer-computed and
controller-persisted dynamic state — recomputed on every respeculate,
not set at enumeration. Selected/Prioritized and Cancelling/Cancelled
split desire vs budget-cleared and cancel-intent vs terminal, so the
persisted status carries the cross-stage contract. Adds
SpeculationPathAction (Promote/Cancel) and SpeculationPathDecision for
the selector and prioritizer seams. SpeculationTree.Speculations becomes
Paths, and the tree gains a Version for optimistic locking (starts at 1,
incremented per change). The Build entity uses the shared
SpeculationPath (Head = the batch under verification) and drops its own
Score, which was never populated or read.

storage: SpeculationTreeStore.UpdateSpeculations(batchID,
[]SpeculationInfo) becomes a pure conditional write — Update(ctx,
batchID, oldVersion, newVersion, paths) — returning ErrVersionMismatch
when the persisted version does not match, per the repo's
optimistic-locking pattern (version arithmetic owned by the controller).
The MySQL impl treats rowsAffected == 1 as success, 0 as version
mismatch, and anything else as a generic error. The MySQL column
speculations is renamed paths and the schema gains a version column.
MySQL impl, mock, and storage integration coverage (create/get
round-trip, duplicate, versioned whole-tree overwrite, stale-write
rejection, not-found) added/updated.

## Test Plan


## Issues


## Stack
1. @ #231
1. #315
1. #316
1. #317
1. #320
@behinddwalls behinddwalls marked this pull request as ready for review July 9, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant