# Class LittleGhost::CodeMode::Engine

Documentation version: Edge

Canonical HTML: https://littleghostai.org/docs/LittleGhost/CodeMode/Engine.html

Adapter contract for a code-mode language.

An Engine describes the language shown to the model and opens one Session.
Model-authored code must run behind the supplied `sandbox_factory`. The Broker
must remain in the trusted parent process; do not expose it or its application
objects inside the child interpreter.

LittleGhost may call one registered Engine instance concurrently for different
Agents and RunContexts. Keep mutable program state in the Session returned by
#open_session, not on the Engine.

## Inheritance

`LittleGhost::CodeMode::Engine < Object`

## Instance methods

<a id="method-i-instructions"></a>
### `#instructions`

```ruby
#instructions(catalog:)
```

Returns model-facing instructions for the supplied Tool Catalog. This method
may be called concurrently. Instructions must describe only names and behavior
the Session actually implements.

<a id="method-i-language"></a>
### `#language`

```ruby
#language()
```

Returns the engine's language identifier as a Symbol.

<a id="method-i-open_session"></a>
### `#open_session`

```ruby
#open_session(broker:, sandbox_factory:, limits:)
```

Opens and returns a CodeMode::Session.

`broker` is called only from trusted parent code. `sandbox_factory` creates
the Sandbox that contains model-authored execution. `limits` is the
application's mapping, passed through unchanged. A custom Engine must
normalize keys and values, validate supported settings, and merge its own safe
defaults. The Session owns every Workspace, Sandbox, process, thread, and
channel it creates. This method may be called concurrently; each call must
return an independent Session.
