# `JsonRemedy.Layer2.StructuralRepair`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L1)

Layer 2: Structural Repair - Fixes missing, extra, and mismatched delimiters using a state machine.

This layer handles:
- Missing closing delimiters ({ [
- Extra closing delimiters } ]
- Mismatched delimiters (closing with wrong type)
- Complex nested structure issues

Uses a state machine approach to track parsing context and handle structural repairs.

# `context_frame`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L26)

```elixir
@type context_frame() :: %{type: delimiter_type(), position: non_neg_integer()}
```

# `delimiter_type`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L25)

```elixir
@type delimiter_type() :: :brace | :bracket
```

# `layer_result`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L21)

```elixir
@type layer_result() :: JsonRemedy.LayerBehaviour.layer_result()
```

# `parser_state`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L24)

```elixir
@type parser_state() :: :root | :object | :array
```

# `repair_action`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L19)

```elixir
@type repair_action() :: JsonRemedy.LayerBehaviour.repair_action()
```

# `repair_context`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L20)

```elixir
@type repair_context() :: JsonRemedy.LayerBehaviour.repair_context()
```

# `state_map`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L30)

```elixir
@type state_map() :: %{
  position: non_neg_integer(),
  current_state: parser_state(),
  context_stack: list(),
  repairs: [repair_action()],
  in_string: boolean(),
  escape_next: boolean(),
  result_chars: [String.t()],
  input: String.t(),
  remaining: binary()
}
```

# `name`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L572)

```elixir
@spec name() :: String.t()
```

Return a human-readable name for this layer.

# `priority`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L566)

```elixir
@spec priority() :: 2
```

Return the priority order for this layer.
Layer 2 (Structural Repair) should run after Layer 1 (Content Cleaning).

# `process`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L51)

```elixir
@spec process(input :: String.t(), context :: repair_context()) :: layer_result()
```

Process input string and apply Layer 2 structural repairs using state machine.

Returns:
- `{:ok, processed_input, updated_context}` - Layer completed successfully
- `{:continue, input, context}` - Layer doesn't apply, pass to next layer
- `{:error, reason}` - Layer failed, stop pipeline

# `supports?`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L514)

```elixir
@spec supports?(input :: String.t()) :: boolean()
```

Check if this layer can handle the given input.
Layer 2 detects structural issues with delimiters.

# `validate_options`
[🔗](https://github.com/nshkrdotcom/json_remedy/blob/v0.2.1/lib/json_remedy/layer2/structural_repair.ex#L579)

```elixir
@spec validate_options(options :: keyword()) :: :ok | {:error, String.t()}
```

Validate layer configuration and options.
Layer 2 accepts options for controlling structural repair behavior.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
