[**@sebasoft/neuron-js**](../../README.md)

***

Defined in: [Synapse.ts:13](https://github.com/SebaSOFT/neuron-js/blob/aff482a5bc89c6f9dff62f832acdd1bd10d3a175/src/Synapse.ts#L13)

The Synapse class is the core execution engine of the rules system.
It processes logic defined in scripts by coordinating between the Registry (Neuron) and the state (ExecutionContext).

## Constructors

### Constructor

> **new Synapse**(`_neuron`, `_hookEmitter?`): `Synapse`

Defined in: [Synapse.ts:20](https://github.com/SebaSOFT/neuron-js/blob/aff482a5bc89c6f9dff62f832acdd1bd10d3a175/src/Synapse.ts#L20)

Initializes a new execution engine.

#### Parameters

##### \_neuron

[`Neuron`](../../index/classes/Neuron.md)

The registry containing all element definitions.

##### \_hookEmitter?

[`HookEmitter`](../../types/HookEmitter/type-aliases/HookEmitter.md)

Optional global lifecycle hook emitter.

#### Returns

`Synapse`

## Methods

### execute()

> **execute**(`script`, `context`, `runtimeHookEmitter?`): [`ExecutionResult`](../../types/ExecutionResult/classes/ExecutionResult.md)\<`number`\>

Defined in: [Synapse.ts:33](https://github.com/SebaSOFT/neuron-js/blob/aff482a5bc89c6f9dff62f832acdd1bd10d3a175/src/Synapse.ts#L33)

Executes a script logic against a provided context.

#### Parameters

##### script

[`ScriptInterface`](../../interfaces/Script/interfaces/ScriptInterface.md)

The serializable script defining the logic rules.

##### context

[`ExecutionContext`](../../types/ExecutionContext/interfaces/ExecutionContext.md)

The shared state object to pass through the execution.

##### runtimeHookEmitter?

[`HookEmitter`](../../types/HookEmitter/type-aliases/HookEmitter.md)

Optional one-time hook emitter for this specific execution.

#### Returns

[`ExecutionResult`](../../types/ExecutionResult/classes/ExecutionResult.md)\<`number`\>

An ExecutionResult containing the final context and the number of successfully executed rules.
