# @manifesto-ai/host

> Effect execution runtime. Implements Mailbox + Runner + Job architecture.

## Role

Host executes effects, applies patches, orchestrates the compute loop, and fulfills requirements. It must not compute semantic meaning or make governance decisions.

## Public API

### `createHost(schema, options?): ManifestoHost`

```typescript
const host = createHost(schema, effectHandlers, {
  maxIterations: 100,
  initialData: {},
  runtime: defaultRuntime,
  env: {},
  onTrace: (event) => {},
  disableAutoEffect: false,
});
```

### `ManifestoHost`

```typescript
class ManifestoHost {
  dispatch(intent: Intent): Promise<HostResult>;
  registerEffect(type, handler, options?): void;
  unregisterEffect(type): boolean;
  hasEffect(type): boolean;
  getEffectTypes(): string[];
  getSnapshot(): Snapshot | null;
  getSchema(): DomainSchema;
  getCore(): ManifestoCore;
  validateSchema(): ValidateResult;
  reset(initialData): void;
}
```

## Effect handler contract

```typescript
type EffectHandler = (
  type: string,
  params: Record<string, unknown>,
  context: EffectContext,
) => Promise<Patch[]>;
```

SDK wraps this Host-level contract into the simpler `(params, ctx)` developer-facing signature.

## Execution Model

- **Mailbox**: FIFO queue of jobs per execution key
- **Runner**: single-writer execution loop
- **Jobs**: `StartIntent`, `ContinueCompute`, `FulfillEffect`, `ApplyPatches`

## Common exports

- mailbox helpers
- runner helpers
- context provider helpers
- job handlers
- effect registry and executor
- Host error helpers

## Notes

- Host is the execution seam between Core and external systems.
- Host-facing Snapshot references follow the current Core v5 shape: domain state is `snapshot.state`, platform/runtime diagnostics live under `snapshot.namespaces`, and accumulated `system.errors` is not part of the current surface.
- Host-owned execution diagnostics belong under canonical `namespaces.host.*`; `namespaces.host.lastError` is a deep-debug diagnostic, not a semantic replacement for `system.lastError`.
- Host stays aligned to the current Core typing and dispatchability contract, but does not own legality policy or query APIs itself.
- SDK, Lineage, and Governance decorate around Host. Host itself does not own continuity or legitimacy semantics.
