Skip to content

feat(prioritization): add prioritizer + prioritization-limit extensions#318

Closed
behinddwalls wants to merge 5 commits into
preetam/ext/speculation-selectorfrom
preetam/ext/prioritization
Closed

feat(prioritization): add prioritizer + prioritization-limit extensions#318
behinddwalls wants to merge 5 commits into
preetam/ext/speculation-selectorfrom
preetam/ext/prioritization

Conversation

@behinddwalls

@behinddwalls behinddwalls commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

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

Prioritization is queue-wide and lives at the build stage, not per batch inside speculate, so it sits in its own prioritization/ family rather than under speculation/.

prioritizer: the queue-wide policy that rations a shared build budget across every in-flight batch. Bound to its queue at construction, it takes no arguments — the store is the source of truth, so it reads the queue's pending builds and each build's path score from storage (read access injected at its Factory), ranks them by score plus any fairness policy, and returns the admitted subset that fits the queue's concurrent-build budget. It never writes; dispatching the admitted builds is the controller's job.

limit: the "how much" policy bounding how many builds the queue runs at once — the queue's concurrent-build budget and the ultimate cap on speculation's demand on CI. Injected into the prioritizer at construction and called by it; 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.

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(prioritization): add prioritizer + prioritization-limit extensions #318

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/building/passed/failed/cancelled), and BuildID. Score is scorer-computed and controller-persisted dynamic state — recomputed on every respeculate, not set at enumeration. Adds SpeculationPathAction and SpeculationPathDecision for the selector seam. SpeculationTree.Speculations becomes Paths. The Build entity uses the shared SpeculationPath (Head = the batch under verification) and drops its own Score, which was never populated or read; the prioritizer seam re-adds a build priority when it lands.

storage: SpeculationTreeStore.UpdateSpeculations(batchID, []SpeculationInfo) becomes Update(ctx, SpeculationTree) — symmetric with Create, keyed by tree.BatchID. The MySQL column speculations is renamed paths to match the entity field. MySQL impl, mock, and storage integration coverage (create/get round-trip, duplicate, whole-tree overwrite, not-found) added/updated.
Add the first speculation seam and its limit counterpart from the speculation RFC, as vendor-agnostic extension interfaces under submitqueue/extension/speculation/.

enumerator: given a batch and its ordered active dependencies, mechanically lists the candidate Base/Head paths — pure, deterministic, and purely structural. It sets no score and no status; the controller stamps status on persist and the scorer fills score. (Its earlier scoring responsibility is dropped here, per the RFC, and moves to the scorer seam.)

dependencylimit: the "how much" policy bounding how many active (in-flight) dependencies a batch may speculate over. It is the eligibility gate before enumeration; unlike the other speculation limits it is controller-held rather than injected into a seam, keeping the enumerator pure. The value is signal-driven, not a fixed constant.

Each follows the repo extension contract (conflict.Analyzer reference shape): Factory.For(Config) (T, error) with Config carrying only QueueName; behavioral knobs and limit signals are integrator-injected at construction. Includes READMEs, gomock packages, and Makefile mock-gen wiring. Interfaces only; concrete impls and controller wiring are deferred.
Add the scorer seam from the speculation RFC, as a vendor-agnostic extension interface under submitqueue/extension/speculation/scorer/.

The scorer computes each speculation path's predicted-success score from the current state: the per-batch scores of the path's base batches (entity.Batch.Score) and which of those dependencies have resolved (landed or build-passed), plus optionally other signals. It is a prediction over live state, so the controller re-runs it on every respeculate right after reconciling status, and persists the result; the scorer owns only the formula.

The store is the source of truth: the scorer takes only the batch identity and loads what it needs — the batch's speculation tree (with controller-reconciled statuses) and its dependency batches — through read access injected at its Factory. It returns the scored tree; the controller persists the scores, staying the single writer of tree state.

This is the per-path scorer, distinct from the existing per-batch score stage (extension/scorer) that sets entity.Batch.Score — the path scorer consumes those to score whole paths.

Follows the repo extension contract: Factory.For(Config) (Scorer, error) with Config carrying only QueueName. Includes README, gomock package, and a programmable fake. Interface only; concrete impls and controller wiring are deferred.
Add the selector seam and its limit counterpart from the speculation RFC, as vendor-agnostic extension interfaces under submitqueue/extension/speculation/.

selector: given a batch, loads its speculation tree (with controller-stamped status and score) from storage and returns a per-path action (Build/Cancel) for the paths it chooses to act on. It is the policy seam — it reads stored state and emits actions only, never writes status, and does not decide merging. The store is the source of truth: it takes only the batch identity and reads the tree through read access injected at its Factory, so the controller stays the single writer.

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.
Add the prioritizer seam and its limit counterpart from the speculation RFC, as vendor-agnostic extension interfaces under submitqueue/extension/prioritization/.

Prioritization is queue-wide and lives at the build stage, not per batch inside speculate, so it sits in its own prioritization/ family rather than under speculation/.

prioritizer: the queue-wide policy that rations a shared build budget across every in-flight batch. Bound to its queue at construction, it takes no arguments — the store is the source of truth, so it reads the queue's pending builds and each build's path score from storage (read access injected at its Factory), ranks them by score plus any fairness policy, and returns the admitted subset that fits the queue's concurrent-build budget. It never writes; dispatching the admitted builds is the controller's job.

limit: the "how much" policy bounding how many builds the queue runs at once — the queue's concurrent-build budget and the ultimate cap on speculation's demand on CI. Injected into the prioritizer at construction and called by it; 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-selector branch from 5e6a56f to e89bb7c Compare July 8, 2026 21:56
@behinddwalls behinddwalls force-pushed the preetam/ext/prioritization branch from e36260b to 65c01c4 Compare July 8, 2026 21:57
@behinddwalls behinddwalls force-pushed the preetam/ext/speculation-selector branch from e89bb7c to 0ab1871 Compare July 8, 2026 23:14
@behinddwalls

Copy link
Copy Markdown
Collaborator Author

Superseded by #320 — the prioritizer moved under submitqueue/extension/speculation/ (branch renamed to preetam/ext/speculation-prioritizer).

@behinddwalls behinddwalls deleted the preetam/ext/prioritization branch July 8, 2026 23:16
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