selectionlimit

package
v0.3.0-20260714201009-... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

README

Speculation Selection Limit

Vendor-agnostic "how much" policy that bounds how many paths a batch may build in parallel.

See the Speculation RFC for the end-to-end design and how limits fit into the two-layer speculation model.

Selection Limit

The selection limit is the selector's companion. The selector decides which of a batch's paths are worth building — its ranking over the tree; the selection limit decides how many of them may run at once. Keeping "which" and "how much" separate keeps selector logic free of resource accounting and lets the bound scale with build resources without touching that logic.

The value is signal-driven, not a fixed constant. Its primary input is the build system's available capacity, but a policy may also weigh historical pass rates, cost budgets, time of day, or an experiment toggle.

Unlike the dependency limit — which the controller holds and applies as an eligibility gate — the selection limit is injected into the seam that uses it: the selector is constructed with it and calls it itself, never receiving it as a method parameter. This follows the repo's extension-contract pattern (dependencies injected at the Factory), keeps the selector interface limit-free and stable, and lets the limit be swapped independently of selector logic.

Factory

A per-queue factory returns the limit policy for a queue, following the repo's extension contract. It is handed only the queue identity; the signals a policy weighs — a capacity feed, historical metrics, config — are injected at construction by the integrator in the wiring layer, which is also where the limit is handed to the selector. Computing the limit itself takes no further inputs.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// QueueName identifies the queue this SelectionLimit serves.
	QueueName string
}

Config carries the per-queue identity handed to a Factory. The system knows only the queue name; everything a policy needs to compute the limit (a capacity feed, historical metrics, config) is injected at construction by the integrator.

type Factory

type Factory interface {
	// For returns the SelectionLimit for the given queue.
	For(cfg Config) (SelectionLimit, error)
}

Factory builds the SelectionLimit for a queue. Implementations are provided by integrators (and tests) and inject whatever signals they need at construction.

type SelectionLimit

type SelectionLimit interface {
	// Limit returns the current maximum number of paths a batch may build in
	// parallel. The selector caps its Promote decisions at this. It takes no
	// parameters; anything an implementation needs is injected at construction.
	Limit(ctx context.Context) (int, error)
}

SelectionLimit is the "how much" policy that bounds how many paths a batch may build in parallel.

It is the selector's companion: the selector decides *which* of a batch's paths are worth building (its ranking); the selection limit decides *how many* of them may run at once. Separating the two keeps selector logic free of resource accounting and lets the bound scale with build resources without touching that logic.

The value is dynamic: it may change between calls, so the selector reads it each pass rather than caching it.

Unlike the dependency limit, this limit is injected into the seam that uses it — the selector is constructed with it and calls it itself — never passed as a method parameter, keeping the selector interface limit-free and stable.

Directories

Path Synopsis
Package fake provides a programmable selectionlimit.SelectionLimit for tests and examples.
Package fake provides a programmable selectionlimit.SelectionLimit for tests and examples.
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL