Help us shape the future of Go! Take the 2026 Go Developer Survey

pathoverlap

package
v0.3.0-20261028150941-... Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

README

pathoverlap

pathoverlap is a conflict.Analyzer that reports a conflict between two batches when the paths they change share a key.

Behavior

The files a batch changes are drawn from each change's provider-supplied details, and each path is projected onto a key by the PathKey chosen at construction. The candidate batch conflicts with an in-flight batch when their key sets intersect; each such in-flight batch is reported once, preserving the in-flight order. A shared path key is the concrete notion of target overlap, so conflicts are classified as ConflictTypeTargetOverlap. A batch that changes no files conflicts with nothing, and an empty in-flight list yields no conflicts. A failure to resolve a batch's changes is returned as a (retryable) error.

Granularity

Two projections ship with the package, selected per queue in the wiring layer:

  • ByFile keys on the whole path, so only batches touching the same file conflict.
  • ByDirectory keys on the path's immediate parent directory, so batches touching sibling files conflict too. Paths at the repository root share the key ., which serializes batches that touch any two root-level files.

ByDirectory is strictly coarser: every file overlap is also a directory overlap. It trades parallelism for protection against semantic conflicts between neighbouring files — edits that break each other without touching the same file. Which trade is right is a per-queue judgement about how tightly coupled a directory's contents are, so the choice is a construction parameter rather than a property of the analyzer.

Path-key intersection is a deliberately simple notion of overlap. A richer one that needs inputs beyond the changed paths — build targets, ownership boundaries — would be a separate analyzer rather than another PathKey.

Documentation

Overview

Package pathoverlap provides a conflict.Analyzer that reports a conflict between two batches when the paths they change share a key. The key is a projection of the path chosen at construction: ByFile compares whole paths, so only batches touching the same file conflict; ByDirectory compares parent directories, so batches touching sibling files conflict too. It is the first analyzer to use the capability the extension contract unblocks: it takes only batch identity and resolves each batch's changed files itself through an injected changeset resolver, rather than depending on the controller to pre-compute them. A shared path key is the concrete notion of target overlap, so it reports entity.ConflictTypeTargetOverlap.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByDirectory

func ByDirectory(p string) string

ByDirectory keys on the path's immediate parent directory: batches conflict when they change any files in the same directory, whether or not the files themselves are the same. Overlap by directory is strictly coarser than overlap by file — every file overlap is also a directory overlap. Paths at the repository root share the key ".".

func ByFile

func ByFile(p string) string

ByFile keys on the whole path: batches conflict only when they change the same file.

func New

func New(cfg conflict.Config, resolver changeset.Resolver, key PathKey) conflict.Analyzer

New returns a conflict.Analyzer that flags an in-flight batch as conflicting when it changes a path whose key matches one the candidate batch changes, bound to the queue named in cfg. The resolver resolves each batch's changed files, and key selects the granularity of overlap. Panics if key is nil.

Types

type PathKey

type PathKey func(path string) string

PathKey projects a changed file path onto the key overlap is measured on. Two batches conflict when any of their changed paths yield the same key, so a coarser projection serializes more batches.

Jump to

Keyboard shortcuts

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