# `PtcRunner.Schema`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/ptc_runner/schema.ex#L1)

Declarative schema module that defines all DSL operations.

This module serves as the single source of truth for operation definitions,
supporting validation, JSON Schema generation, and documentation.

# `get_operation`

```elixir
@spec get_operation(String.t()) :: {:ok, map()} | :error
```

Get operation definition by name.

## Arguments
  - operation_name: The name of the operation

## Returns
  - `{:ok, definition}` if the operation exists
  - `:error` if the operation is unknown

# `operations`

```elixir
@spec operations() :: map()
```

Returns all operation definitions.

## Returns
  A map where keys are operation names and values are operation definitions.

# `to_json_schema`

```elixir
@spec to_json_schema() :: map()
```

Generate a JSON Schema (draft-07) for the PTC DSL.

## Returns
  A map representing the JSON Schema that can be encoded to JSON.

# `to_llm_schema`

```elixir
@spec to_llm_schema() :: map()
```

Generate a flattened JSON Schema optimized for LLM structured output.

This schema uses `anyOf` to list all operations at the top level, avoiding
the recursive `$ref` patterns that LLMs struggle with. The schema is designed
to work with ReqLLM.generate_object! for structured output mode.

## Returns
  A map representing the flattened JSON Schema for the PTC DSL.

# `to_prompt`

```elixir
@spec to_prompt(keyword()) :: String.t()
```

Generate a concise prompt describing PTC operations for LLM text mode.

This produces a human-readable description of operations suitable for system
prompts. Includes operation reference, memory contract, key rules, and examples.

## Options
  - `:examples` - number of full JSON examples to include (default: 3)

## Returns
  A string containing operation descriptions and examples.

# `valid_operation_names`

```elixir
@spec valid_operation_names() :: [String.t()]
```

Returns a sorted list of valid operation names.

## Returns
  A list of operation names in sorted order.

---

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