# Toon — Options & Presets

`AcToonSerializerOptions` controls every Toon output behavior. Definition: `Serializers/Toons/AcToonSerializerOptions.cs`.

## Toon-specific options

| Option | Type | Default | Purpose |
|---|---|---|---|
| `Mode` | `ToonSerializationMode` | `Full` | Which sections to emit. |
| `UseMeta` | `bool` | `true` | Include `@meta`/`@types` sections. Ignored when `Mode = DataOnly`. |
| `UseIndentation` | `bool` | `true` | Pretty-print with indentation. When `false`, `=` has no surrounding spaces. |
| `IndentString` | `string` | `"  "` (2 spaces) | Indent unit when `UseIndentation = true`. |
| `UseInlineTypeHints` | `bool` | `false` | Emit `value <type>` hints in `@data` (schema already has type info). |
| `UseInlineComments` | `bool` | `false` | Emit property descriptions as inline comments. |
| `ShowCollectionCount` | `bool` | `true` | Emit `<Type[]> (count: N) ` header on arrays/dictionaries. |
| `UseMultiLineStrings` | `bool` | `true` | Triple-quote format for long strings. |
| `MultiLineStringThreshold` | `int` | `80` | Character count above which a string becomes multi-line. |
| `UseEnhancedMetadata` | `bool` | `true` | Full per-property metadata (description + purpose + constraints + examples + navigation) vs compact single-line form. |
| `OmitDefaultValues` | `bool` | `true` | Skip properties whose value equals `default(T)` / `null` / `0` / `false`. |
| `WriteTypeNames` | `bool` | `true` | Emit the type name before `{` on `@data` objects. |
| `MaxExampleStringLength` | `int` | `50` | Truncate example values in `@types` beyond this length. |

## Inherited from `AcSerializerOptions`

| Option | Type | Notes |
|---|---|---|
| `MaxDepth` | `byte` | Recursion depth limit. Toon currently truncates to `null` when exceeded (silent shallow-cut). The action at the limit is conceptually dispatched on `MaxDepthBehavior`, but **Toon does not yet honor that option** — see `TOON_ISSUES.md#accore-toon-i-s4q9`. |
| `MaxDepthBehavior` | `MaxDepthBehavior` | `Truncate` / `Throw` / `Disable`. Default `Throw` at the base. **Not honored by Toon today**: Toon's depth handling is always silent-null truncation regardless of this setting. Tracked at `TOON_TODO.md#accore-toon-t-w8b5`. |
| `ReferenceHandling` | `ReferenceHandlingMode` | `None` / `OnlyId` / `All`. ⚠️ Reference-identity only: `OnlyId` == `All`, same-`Id` distinct instances not deduped — `TOON_ISSUES.md#accore-toon-b-r8k3`. |
| `SerializerType` | `AcSerializerType` | Fixed to `Toon`. |

## `ToonSerializationMode` enum

```csharp
public enum ToonSerializationMode : byte
{
    Full     = 0,  // @meta + @types + @data (default)
    MetaOnly = 1,  // @meta + @types only
    DataOnly = 2,  // @data only
}
```

## Presets

Each preset is a fresh instance (static property with `new` expression; no shared state).

### `Default`

```
Mode = Full, UseMeta = true, UseIndentation = true,
OmitDefaultValues = true, WriteTypeNames = true
```

First-time serialization with full context for the LLM.

### `MetaOnly`

```
Mode = MetaOnly, UseMeta = true, UseIndentation = true,
UseInlineComments = true
```

Send schema once at conversation start. `UseInlineComments = true` adds clarity since no `@data` follows.

### `DataOnly`

```
Mode = DataOnly, UseMeta = false, UseIndentation = true,
OmitDefaultValues = true, WriteTypeNames = true
```

Subsequent sends once the LLM already has the schema.

### `Compact`

```
Mode = DataOnly, UseMeta = false, UseIndentation = true,
OmitDefaultValues = true, WriteTypeNames = false,
ReferenceHandling = None
```

Data-only, no type names, no reference tracking. Note: `UseIndentation = true` here — truly token-minimal output requires `UseIndentation = false` on a custom options instance.

### `Verbose`

```
Mode = Full, UseMeta = true, UseIndentation = true,
UseInlineTypeHints = true, UseInlineComments = true,
OmitDefaultValues = false, WriteTypeNames = true
```

Debugging / documentation — every hint turned on, defaults included. Bloats tokens; avoid for production LLM contexts.

## Factory helpers

```csharp
AcToonSerializerOptions.WithMaxDepth(10)
AcToonSerializerOptions.WithoutReferenceHandling()
```

Short-hand for common one-off customizations.

## Custom options

All properties are `init;` — assemble once per serialization call:

```csharp
var opts = new AcToonSerializerOptions
{
    Mode = ToonSerializationMode.Full,
    UseIndentation = false,         // tight token-minimal output
    ShowCollectionCount = true,
    UseMultiLineStrings = false,    // keep long strings inline
    OmitDefaultValues = true,
    MaxDepth = 20
};
string toon = AcToonSerializer.Serialize(value, opts);
```

## Public API overloads

| Method | Purpose |
|---|---|
| `Serialize<T>(T value)` | Default options. |
| `Serialize<T>(T value, AcToonSerializerOptions)` | Custom options. |
| `Serialize<T>(T value, string domainDescription, AcToonSerializerOptions)` | Adds `context = "..."` line to `@meta`. |
| `SerializeTypeMetadata<T>()` / `SerializeTypeMetadata(Type)` | Schema only — uses `MetaOnly` internally. |
| `SerializeMetadata(IEnumerable<Type>)` | Schema for multiple types (no instance required). |
| `SerializeMetadata(params Type[])` | Schema for multiple types (params syntax). |
| `SerializeMetadata(string domainDescription, params Type[])` | Multi-type schema with domain context in `@meta`. |

## Picking a preset / customization

| Scenario | Choice |
|---|---|
| First prompt to an LLM in a new conversation | `Default` |
| Send schema once, many data round-trips | `MetaOnly` then `DataOnly` |
| Token-minimal streaming after schema is established | Custom: `Mode = DataOnly` + `UseIndentation = false` + `WriteTypeNames = false` |
| Debugging, local inspection | `Verbose` |
| Cyclic object graph (entity with backrefs) | `ReferenceHandling = OnlyId`/`All`; shared **instances** only (`ACCORE-TOON-B-R8K3`) |
