# Overlapping-Pattern Conflict Resolver

`D06-F05-A07` · Price Action and Candlesticks → Candlestick Scanning and Context · archetype `row-classify` · difficulty 3/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/price-action-and-candlesticks/candlestick-scanning-and-context/overlapping-pattern-conflict-resolver/
Agent skill: `npx skills add IslamBaraka90/Fintech-Algorithms-Library` — https://docs.thefintechbuilder.com/guides/agent-skill/

## Install and import

```bash
npm install fintech-algorithms
```

```ts
import { resolveConflicts } from "fintech-algorithms/price-action-and-candlesticks/candlestick-scanning-and-context/overlapping-pattern-conflict-resolver";
```

## Signature

```ts
resolveConflicts(data)
```

form connected overlap components and choose one reproducible winner using declared precedence and stable tie-breaks.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ occurrences: { occurrence_id: string; instrument_id: string; interval: string; pattern_id: string; direction: string; start_index: number; end_index: number; priority: number; confidence: number; geometry_score: number }[] }` | yes | Topic input record; the required fields are fixed by this topic data-contract. |

## Returns

`{ state, winner_count, suppressed_count, winners, suppressed }`

One `ready` conflict-resolution record containing the deterministic winners and reason-coded suppressed occurrences with aggregate counts.

## Complexity

Time `O(n log n) worst case; see README for topic-specific n`, space `O(n)`.

## Worked example

This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

### Input

`data`:

```json
{
  "occurrences": [
    {
      "occurrence_id": "A",
      "instrument_id": "SYNTH:AAA",
      "interval": "5m",
      "pattern_id": "D06-F02-A01",
      "direction": "neutral",
      "start_index": 10,
      "end_index": 10,
      "priority": 1,
      "confidence": 90,
      "geometry_score": 0.95
    },
    {
      "occurrence_id": "B",
      "instrument_id": "SYNTH:AAA",
      "interval": "5m",
      "pattern_id": "D06-F03-A01",
      "direction": "bullish",
      "start_index": 10,
      "end_index": 11,
      "priority": 2,
      "confidence": 70,
      "geometry_score": 0.85
    },
    {
      "occurrence_id": "C",
      "instrument_id": "SYNTH:AAA",
      "interval": "5m",
      "pattern_id": "D06-F02-A04",
      "direction": "bullish",
      "start_index": 15,
      "end_index": 15,
      "priority": 1,
      "confidence": 80,
      "geometry_score": 0.9
    }
  ]
}
```

### Call

```ts
resolveConflicts(data)
```

### Returns

object with 3 fields: state, winner_count, suppressed_count

```json
{
  "state": "ready",
  "winner_count": 2,
  "suppressed_count": 1
}
```

## Verification and provenance

Tier: **verified** (via input-expected).

The worked example below is the figure published in this algorithm's article, replayed and asserted by the test suite on every build. The arithmetic cannot drift without the build failing.

Both tiers guarantee the signature. Full explanation: https://docs.thefintechbuilder.com/guides/verification/

Generated from the docs.json payload shipped inside fintech-algorithms@0.12.0.
The signature and parameter list are checked against the compiled implementation at build time,
so a description that contradicts the code fails the build rather than reaching this file.

## Links

- Article (how it works, step by step): https://thefintechbuilder.com/price-action-and-candlesticks/candlestick-scanning-and-context/overlapping-pattern-conflict-resolver/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/price-action-and-candlesticks/candlestick-scanning-and-context/overlapping-pattern-conflict-resolver/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/price-action-and-candlesticks/llms.txt
