|
1 | 1 | # Conflict |
2 | 2 |
|
3 | | -Vendor-agnostic interface for detecting conflicts between a candidate batch |
4 | | -and the batches already in flight. |
| 3 | +Vendor-agnostic interface for detecting conflicts between a candidate batch and the batches already in flight. |
5 | 4 |
|
6 | 5 | ## Interface |
7 | 6 |
|
8 | | -`Analyzer` exposes a single `Analyze` method that takes the candidate batch |
9 | | -and the list of in-flight batches it might conflict with. It returns the |
10 | | -subset of in-flight batches that conflict with the candidate, each paired |
11 | | -with a `ConflictType` describing the kind of conflict. An empty result means |
12 | | -the candidate is free to advance independently. |
| 7 | +`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. |
13 | 8 |
|
14 | | -Callers are responsible for filtering out the candidate itself and any |
15 | | -terminal batches from the in-flight list before invoking the analyzer. The |
16 | | -analyzer itself stays free of lifecycle knowledge. A non-nil error reports |
17 | | -an infrastructure failure of the analysis and should be treated as |
18 | | -retryable by the caller. |
| 9 | +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-transition knowledge. A non-nil error reports that analysis could not be completed; implementations return plain errors and the configured error classifiers decide retryability. |
19 | 10 |
|
20 | | -The analyzer is intentionally pure with respect to batch state: it does not |
21 | | -mutate inputs, does not read storage, and may be called concurrently. Real |
22 | | -implementations are expected to resolve the batch contents (e.g. changed |
23 | | -build targets, modified files) via whichever upstream system they depend |
24 | | -on, and to return as much classification detail as that system supports. |
| 11 | +The analyzer does not mutate batch inputs and may be called concurrently. Implementations resolve the batch contents they need through injected dependencies. For example, `pathoverlap` uses a `changeset.Resolver`, whose store-backed implementation reads queue-scoped request and change records. |
25 | 12 |
|
26 | 13 | ## Implementations |
27 | 14 |
|
28 | | -- [`all/`](all/) — pessimistic stub: reports every in-flight batch as a |
29 | | - `ConflictTypeConservative` conflict. Useful as a worst-case baseline and |
30 | | - for wiring tests where speculation must serialize. |
31 | | -- [`none/`](none/) — optimistic stub: reports no conflicts. Useful as a |
32 | | - best-case baseline and for wiring tests where speculation should run all |
33 | | - batches in parallel. |
| 15 | +- [`all/`](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. |
| 16 | +- [`fake/`](fake/) — wraps another analyzer and optionally injects configured failures for tests and example wiring. |
| 17 | +- [`none/`](none/) — optimistic stub: reports no conflicts. Useful as a best-case baseline and for wiring tests where speculation should run all batches in parallel. |
| 18 | +- [`pathoverlap/`](pathoverlap/) — resolves changed files and reports overlap conflicts by whole file or parent directory. |
34 | 19 |
|
35 | 20 | ## Adding a new backend |
36 | 21 |
|
37 | 22 | 1. Create `extension/conflict/{backend}/` with an `Analyzer` implementation. |
38 | | -2. Resolve each `entity.Batch` into whatever signal the backend needs |
39 | | - (e.g. changed build targets, files touched, dependency graphs). |
40 | | -3. Emit one `Conflict` per (in-flight batch, detected conflict type). Pick |
41 | | - the most specific `ConflictType` your backend can determine; use |
42 | | - `ConflictTypeConservative` only when the backend cannot prove the absence |
43 | | - of a conflict and falls back to a pessimistic default. Introduce a new |
44 | | - `ConflictType` constant when you can classify the conflict more precisely. |
45 | | -4. Return a plain error for transient infrastructure failures so callers |
46 | | - can classify and retry. |
| 23 | +2. Resolve each `entity.Batch` into whatever signal the backend needs (e.g. changed build targets, files touched, dependency graphs). |
| 24 | +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. |
| 25 | +4. Return plain errors and let the consumer's configured classifiers determine retry behavior. |
0 commit comments