conflict

package
v0.3.0-20260803204450-... Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

README

Conflict

Vendor-agnostic interface for detecting conflicts between a candidate batch and the batches already in flight.

Interface

Analyzer exposes a single Analyze method that takes the candidate batch and the list of in-flight batches it might conflict with. It returns the subset of in-flight batches that conflict with the candidate, each paired with a ConflictType describing the kind of conflict. An empty result means the candidate is free to advance independently.

Callers are responsible for filtering out the candidate itself and any terminal batches from the in-flight list before invoking the analyzer. The analyzer itself stays free of lifecycle knowledge. A non-nil error reports an infrastructure failure of the analysis and should be treated as retryable by the caller.

The analyzer is intentionally pure with respect to batch state: it does not mutate inputs, does not read storage, and may be called concurrently. Real implementations are expected to resolve the batch contents (e.g. changed build targets, modified files) via whichever upstream system they depend on, and to return as much classification detail as that system supports.

Implementations

  • all/ — pessimistic stub: reports every in-flight batch as a ConflictTypeConservative conflict. Useful as a worst-case baseline and for wiring tests where speculation must serialize.
  • none/ — optimistic stub: reports no conflicts. Useful as a best-case baseline and for wiring tests where speculation should run all batches in parallel.

Adding a new backend

  1. Create extension/conflict/{backend}/ with an Analyzer implementation.
  2. Resolve each entity.Batch into whatever signal the backend needs (e.g. changed build targets, files touched, dependency graphs).
  3. Emit one Conflict per (in-flight batch, detected conflict type). Pick the most specific ConflictType your backend can determine; use ConflictTypeConservative only when the backend cannot prove the absence of a conflict and falls back to a pessimistic default. Introduce a new ConflictType constant when you can classify the conflict more precisely.
  4. Return a plain error for transient infrastructure failures so callers can classify and retry.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

type Analyzer interface {
	// Analyze returns the subset of inFlight batches that conflict with
	// batch, each paired with the type of conflict detected. An empty
	// result means batch does not conflict with any in-flight batch.
	//
	// Callers should not include batch itself in inFlight; terminal batches
	// should be filtered out before calling. A non-nil error indicates the
	// analysis itself failed (infrastructure issue) and should be treated as
	// retryable by the caller.
	Analyze(ctx context.Context, batch entity.Batch, inFlight []entity.Batch) ([]entity.Conflict, error)
}

Analyzer detects conflicts between a candidate batch and the batches already in flight, so the speculation layer can decide which batches can safely advance in parallel.

type Config

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

Config carries the per-queue identity handed to a Factory. The system knows only the queue name; everything an implementation needs is injected at construction by the integrator.

type Factory

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

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

Directories

Path Synopsis
Package all provides a conflict.Analyzer that pessimistically reports a conflict against every in-flight batch.
Package all provides a conflict.Analyzer that pessimistically reports a conflict against every in-flight batch.
Package fake provides a conflict.Analyzer that decorates an existing analyzer: it delegates to the wrapped implementation for the happy path, but injects an error when a caller-supplied predicate matches.
Package fake provides a conflict.Analyzer that decorates an existing analyzer: it delegates to the wrapped implementation for the happy path, but injects an error when a caller-supplied predicate matches.
Package fileoverlap provides a conflict.Analyzer that reports a conflict between two batches when they change one or more of the same files.
Package fileoverlap provides a conflict.Analyzer that reports a conflict between two batches when they change one or more of the same files.
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
Package none provides a conflict.Analyzer that never reports a conflict.
Package none provides a conflict.Analyzer that never reports a conflict.

Jump to

Keyboard shortcuts

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