---
url: 'https://adk.nht.io/api/@nhtio/adk/common/interfaces/TurnGate.md'
description: >-
  A cooperative suspension gate that blocks a turn's middleware pipeline until
  resolved, rejected, aborted, or timed out.
---

# Interface: TurnGate\<T>

Defined in: [lib/classes/turn\_gate.ts:114](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L114)

A cooperative suspension gate that blocks a turn's middleware pipeline until resolved, rejected,
aborted, or timed out.

## Remarks

Created exclusively via `ctx.waitFor()` — middleware never constructs a gate directly.
The gate emits `turnGateOpen` on the runner's observability bus at creation time and
`turnGateClosed` when it settles.

Resolution is validated against an optional schema before the internal promise is settled.
A validation failure throws [@nhtio/adk!E\_INVALID\_TURN\_GATE\_RESOLUTION](../../exceptions/variables/E_INVALID_TURN_GATE_RESOLUTION.md) **synchronously in the
caller's context** — the promise is NOT settled and the gate remains open.

## Type Parameters

| Type Parameter | Default type | Description                                |
| -------------- | ------------ | ------------------------------------------ |
| `T`            | `unknown`    | The expected type of the resolution value. |

## Properties

| Property                                    | Modifier   | Type       | Defined in                                                                                                        |
| ------------------------------------------- | ---------- | ---------- | ----------------------------------------------------------------------------------------------------------------- |
|  `createdAt` | `readonly` | `DateTime` | [lib/classes/turn\_gate.ts:140](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L140) |
|  `id`               | `readonly` | `string`   | [lib/classes/turn\_gate.ts:136](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L136) |
|  `isSettled` | `readonly` | `boolean`  | [lib/classes/turn\_gate.ts:141](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L141) |
|  `payload`     | `readonly` | `unknown`  | [lib/classes/turn\_gate.ts:139](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L139) |
|  `reason`       | `readonly` | `string`   | [lib/classes/turn\_gate.ts:138](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L138) |
|  `turnId`       | `readonly` | `string`   | [lib/classes/turn\_gate.ts:137](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L137) |

## Methods

### \_promise()

```ts
_promise(): Promise<T>;
```

Defined in: [lib/classes/turn\_gate.ts:315](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L315)

**`Internal`**

Returns the internal promise. Called by `ctx.waitFor()` to block the middleware pipeline.

#### Returns

`Promise`<`T`>

***

### abort()

```ts
abort(): void;
```

Defined in: [lib/classes/turn\_gate.ts:305](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L305)

Aborts the gate by firing the internal `AbortController`, which rejects the promise with
[@nhtio/adk!E\_TURN\_GATE\_ABORTED](../../exceptions/variables/E_TURN_GATE_ABORTED.md).

#### Returns

`void`

#### Remarks

No-ops if the gate is already settled. Distinct from the turn-level abort signal — this
allows callers to cancel a specific gate without aborting the whole turn.

***

### reject()

```ts
reject(error: Error): void;
```

Defined in: [lib/classes/turn\_gate.ts:291](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L291)

Rejects the gate with `error`, unblocking the awaiting middleware with a rejection.

#### Parameters

| Parameter | Type    | Description           |
| --------- | ------- | --------------------- |
| `error`   | `Error` | The rejection reason. |

#### Returns

`void`

#### Remarks

No-ops if the gate is already settled.

***

### resolve()

```ts
resolve(value: unknown): void;
```

Defined in: [lib/classes/turn\_gate.ts:268](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/turn_gate.ts#L268)

Resolves the gate with `value`, unblocking the awaiting middleware.

#### Parameters

| Parameter | Type      | Description                                                                 |
| --------- | --------- | --------------------------------------------------------------------------- |
| `value`   | `unknown` | The resolution value. Must satisfy the gate's schema when one was provided. |

#### Returns

`void`

#### Remarks

If a schema was provided at construction, `value` is validated synchronously before the
promise is settled. A validation failure throws [@nhtio/adk!E\_INVALID\_TURN\_GATE\_RESOLUTION](../../exceptions/variables/E_INVALID_TURN_GATE_RESOLUTION.md)
in the caller's context — the promise is NOT settled and the gate remains open.

No-ops if the gate is already settled.

#### Throws

[@nhtio/adk!E\_INVALID\_TURN\_GATE\_RESOLUTION](../../exceptions/variables/E_INVALID_TURN_GATE_RESOLUTION.md) when `value` fails schema validation.
