conflict

package
v0.1.0-dev3 Latest Latest
Warning

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

Go to latest
Published: May 27, 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) ([]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 Conflict

type Conflict struct {
	// BatchID is the ID of the in-flight batch that conflicts with the
	// analyzed batch.
	BatchID string
	// Type classifies the conflict. A single (analyzed, in-flight) pair may
	// be reported with multiple Conflict entries when different conflict
	// types apply.
	Type ConflictType
}

Conflict reports a single conflict between the analyzed batch and one of the in-flight batches.

type ConflictType

type ConflictType string

ConflictType classifies why two batches are considered to conflict. New values may be added as more sophisticated analyzers are introduced.

const (
	// ConflictTypeUnknown is the unreachable zero value, set by default when
	// the structure is initialized. It should never be seen in the system.
	ConflictTypeUnknown ConflictType = ""
	// ConflictTypeConservative means the analyzer treated the batches as
	// conflicting because it could not prove otherwise, without identifying a
	// specific reason. Used by conservative analyzers that serialize
	// everything by default.
	ConflictTypeConservative ConflictType = "conservative"
	// ConflictTypeTargetOverlap means the two batches modify one or more of
	// the same build targets and may therefore interfere with each other.
	ConflictTypeTargetOverlap ConflictType = "target_overlap"
)

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 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