# Turnover Buffer Rule

`D03-F06-A07` · Index and Benchmark Engineering → Governance and Maintenance · archetype `record-transform` · difficulty 3/5 · verification **verified**

Full page: https://docs.thefintechbuilder.com/index-and-benchmark-engineering/governance-and-maintenance/turnover-buffer-rule/
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 { calculate } from "fintech-algorithms/index-and-benchmark-engineering/governance-and-maintenance/turnover-buffer-rule";
```

## Signature

```ts
calculate(data)
```

The buffer in isolation: a band around the cutoff inside which incumbents keep their place. Widening it cuts turnover and lets the membership drift further from the pure ranking — that trade-off is the whole design decision.

## Parameters

| Name | Type | Required | Notes |
| --- | --- | --- | --- |
| `data` | `{ candidates: Candidate[]; targetCount: number; buffer: number }` | yes | `buffer` is expressed in ranks or in weight, depending on the index's own rulebook. |

## Returns

`{ selectedIds, additions, deletions, targetCount }`

The membership after the buffer is applied, with the changes it permitted.

## Errors

- When buffer is negative — throws

## Complexity

Time `O(n log 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
{
  "candidates": [
    {
      "id": "A",
      "rank": 1,
      "incumbent": true
    },
    {
      "id": "B",
      "rank": 2,
      "incumbent": false
    },
    {
      "id": "C",
      "rank": 3,
      "incumbent": true
    }
  ],
  "targetCount": 5,
  "buffer": 1
}
```

### Call

```ts
calculate(data)
```

### Returns

object with 4 fields: selectedIds, additions, deletions, targetCount

```json
{
  "selectedIds": ["A", "B", "C", "E", "F"],
  "additions": ["B"],
  "deletions": [],
  "targetCount": 5
}
```

## 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.13.1.
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/index-and-benchmark-engineering/governance-and-maintenance/turnover-buffer-rule/
- Implementation source: https://github.com/IslamBaraka90/Fintech-Algorithms-Library/blob/main/src/index-and-benchmark-engineering/governance-and-maintenance/turnover-buffer-rule/impl.ts
- Package on npm: https://www.npmjs.com/package/fintech-algorithms
- Domain index for agents: https://docs.thefintechbuilder.com/index-and-benchmark-engineering/llms.txt
