---
url: 'https://adk.nht.io/api/@nhtio/adk/common/classes/Registry.md'
description: >-
  A controlled-mutation key-value store with dot-path access and deep-clone
  isolation.
---

# Class: Registry

Defined in: [lib/classes/registry.ts:18](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/registry.ts#L18)

A controlled-mutation key-value store with dot-path access and deep-clone isolation.

## Remarks

The registry enforces a safe read/write contract: callers never hold a live reference into
the internal store. Every value that enters (`set`) or leaves (`get`, `all`) is deep-cloned
via `klona`, so mutations to a retrieved value cannot affect stored state and vice versa.

Keys are dot-delimited paths (e.g. `"user.profile.name"`), resolved via `dlv` for reads and
`dset` for writes; intermediate objects are created automatically on write.

## Constructors

### Constructor

```ts
new Registry(initial?: Record<string, unknown>): Registry;
```

Defined in: [lib/classes/registry.ts:25](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/registry.ts#L25)

#### Parameters

| Parameter  | Type                                                                                                               | Description                                                              |
| ---------- | ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------ |
| `initial?` | [`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `unknown`> | Optional plain object to seed the registry. Deep-cloned on construction. |

#### Returns

`Registry`

#### Throws

[@nhtio/adk!E\_INVALID\_INITIAL\_REGISTRY\_VALUE](../../exceptions/variables/E_INVALID_INITIAL_REGISTRY_VALUE.md) when `initial` is defined but not a plain object.

## Methods

### all()

```ts
all(): Record<string, unknown>;
```

Defined in: [lib/classes/registry.ts:129](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/registry.ts#L129)

Returns a deep clone of the entire store contents.

#### Returns

[`Record`](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<`string`, `unknown`>

A plain object snapshot of all stored key-value pairs.

***

### get()

```ts
get<T>(key: string, defaultValue?: T): T;
```

Defined in: [lib/classes/registry.ts:56](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/registry.ts#L56)

Retrieves the value at `key`, returning `defaultValue` if the path is absent.

#### Type Parameters

| Type Parameter | Default type | Description                          |
| -------------- | ------------ | ------------------------------------ |
| `T`            | `unknown`    | Expected type of the value at `key`. |

#### Parameters

| Parameter       | Type     | Description                                              |
| --------------- | -------- | -------------------------------------------------------- |
| `key`           | `string` | Dot-delimited path into the store (e.g. `"user.name"`).  |
| `defaultValue?` | `T`      | Fallback returned when the path resolves to `undefined`. |

#### Returns

`T`

A deep clone of the stored value cast to `T`, or `defaultValue` when the path is absent.

#### Remarks

The returned value is a deep clone — mutating it will not affect the stored state.

***

### has()

```ts
has(key: string): boolean;
```

Defined in: [lib/classes/registry.ts:86](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/registry.ts#L86)

Returns `true` if the registry has a value at `key`, `false` otherwise.

#### Parameters

| Parameter | Type     | Description                                             |
| --------- | -------- | ------------------------------------------------------- |
| `key`     | `string` | Dot-delimited path into the store (e.g. `"user.name"`). |

#### Returns

`boolean`

`true` when the path resolves to a value other than `undefined`.

#### Remarks

A key resolving to `undefined` is treated as absent — same convention as [Registry.get](#get)'s
`defaultValue` fallback. No clone is performed; this is a pure existence check.

***

### keys()

```ts
keys(): string[];
```

Defined in: [lib/classes/registry.ts:99](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/registry.ts#L99)

Returns all leaf dot-paths present in the registry.

#### Returns

`string`\[]

A string array of dot-delimited paths to leaf values in the store.

#### Remarks

The store is deep-cloned before traversal. Plain objects are walked recursively with path
segments joined by dots; arrays, primitives, `null`, and class instances are treated as leaves.

***

### set()

```ts
set(key: string, value: unknown): void;
```

Defined in: [lib/classes/registry.ts:72](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/registry.ts#L72)

Sets the value at `key`, creating intermediate objects as needed.

#### Parameters

| Parameter | Type      | Description                                             |
| --------- | --------- | ------------------------------------------------------- |
| `key`     | `string`  | Dot-delimited path into the store (e.g. `"user.name"`). |
| `value`   | `unknown` | Value to store at the path.                             |

#### Returns

`void`

#### Remarks

The stored value is isolated from the caller — mutating `value` after this call will not
affect what is held in the registry.

***

### isRegistry()

```ts
static isRegistry(value: unknown): value is Registry;
```

Defined in: [lib/classes/registry.ts:41](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/classes/registry.ts#L41)

Returns `true` if `value` is a Registry instance.

#### Parameters

| Parameter | Type      | Description        |
| --------- | --------- | ------------------ |
| `value`   | `unknown` | The value to test. |

#### Returns

`value is Registry`

`true` when `value` is a Registry instance.

#### Remarks

Uses [@nhtio/adk!isInstanceOf](../../guards/functions/isInstanceOf.md) for cross-realm safety.
