# `Jidoka.Context`
[🔗](https://github.com/agentjido/jidoka/blob/v0.9.0/lib/jidoka/context.ex#L1)

Canonical runtime context passed to Jidoka policy code.

`Jidoka.Context` is the public, data-only shape for controls and approval
predicates. It keeps application context in `data` and exposes the current
request, operation, and result metadata without requiring callers to reach
into turn internals.

# `boundary`

```elixir
@type boundary() :: :input | :operation | :output
```

# `t`

```elixir
@type t() :: %Jidoka.Context{
  agent_id: nil | nil | binary(),
  agent_state: nil | nil | any(),
  arguments: map(),
  boundary: (:input | :operation) | :output,
  control: nil | nil | atom(),
  control_name: nil | nil | binary(),
  data: map(),
  idempotency: (((:pure | :idempotent) | :dedupe) | :reconcile) | :unsafe_once,
  idempotency_key: nil | nil | binary(),
  input: nil | nil | binary(),
  loop_index: nil | nil | integer(),
  metadata: map(),
  operation: nil | nil | binary(),
  operation_kind:
    (((((((((:action | :operation) | :tool) | :ash_resource) | :browser)
         | :skill)
        | :mcp)
       | :catalog)
      | :workflow)
     | :subagent)
    | :handoff,
  operation_metadata: map(),
  operation_source: nil | nil | binary(),
  plan: nil | nil | any(),
  request: nil | nil | any(),
  request_id: nil | nil | binary(),
  request_metadata: map(),
  result: nil | nil | any(),
  result_value: nil | nil | any(),
  runtime: map(),
  session_id: nil | nil | binary(),
  spec: nil | nil | any()
}
```

# `data`

```elixir
@spec data(t()) :: map()
```

Returns caller-provided application context data.

# `fetch`

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

Fetches an application context value by atom or string key without creating atoms.

# `fetch_runtime`

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

Fetches a runtime-only value by atom or string key without creating atoms.

# `from_data`

```elixir
@spec from_data(t() | keyword() | map() | nil, keyword() | map()) ::
  {:ok, t()} | {:error, term()}
```

Builds a request context from caller-provided application data.

Passing an existing `Jidoka.Context` uses only its public data. Use
`from_input/1` when trusted code needs to preserve runtime fields.

# `from_data!`

```elixir
@spec from_data!(t() | keyword() | map() | nil, keyword() | map()) :: t()
```

Builds a request context from caller-provided application data or raises.

# `from_input`

```elixir
@spec from_input(t() | keyword() | map()) :: {:ok, t()} | {:error, term()}
```

Normalizes trusted runtime context input and preserves runtime-only fields.

# `get`

```elixir
@spec get(t() | map(), atom() | String.t(), term()) :: term()
```

Returns an application context value by atom or string key without creating atoms.

# `get_runtime`

```elixir
@spec get_runtime(t() | map(), atom() | String.t(), term()) :: term()
```

Returns a runtime-only value by atom or string key without creating atoms.

# `new`

```elixir
@spec new(keyword() | map()) :: {:ok, t()} | {:error, term()}
```

Builds a runtime context from keyword or map attributes.

# `new!`

```elixir
@spec new!(keyword() | map()) :: t()
```

Builds a runtime context and raises if the attributes are invalid.

# `runtime`

```elixir
@spec runtime(t()) :: map()
```

Returns trusted runtime-only context values.

# `sanitize`

```elixir
@spec sanitize(t()) :: t()
```

Drops runtime-only values before persisting or projecting context.

# `schema`

```elixir
@spec schema() :: Zoi.schema()
```

Returns the Zoi schema for runtime context data.

# `to_action_context`

```elixir
@spec to_action_context(t()) :: map()
```

Projects caller data into the context map expected by Jido actions.

---

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