# composeThreeWay

**Kind:** Function

**Source:** [`atloria-monorepo/apps/api/src/change-request/merge-compose.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/apps/api/src/change-request/merge-compose.ts#L19)

Compose the auto-merged document from aligned three-way sections (S2.3 merge).

PURE — no I/O. The caller (CrWorker's merge gate) has already classified every section via
DiffService.threeWaySections and verified NONE are 'conflict'; this walks the aligned slots
in order and takes:
  - 'keep-mine'   → mine   (main moved this section; the proposal left it alone)
  - 'take-theirs' → theirs (the proposal changed this section; main left it alone)
  - 'unchanged'   → mine   (mine === theirs by definition — either side works)

A section DELETED on the winning side compares as '' and is dropped from the composition
(this also covers the deleted-on-both-sides slots threeWaySections appends as 'unchanged').
Section texts carry no trailing newline (they are joined line runs), so the composition
re-joins with '\n' and ends with a single trailing newline — matching the normalised form
every committed page already has.

## Signature

```ts
function composeThreeWay(sections: ThreeWaySection[]): string
```

## Parameters

| Name | Type |
|---|---|
| `sections` | `ThreeWaySection[]` |

**Returns:** `string`
