---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/orchestration/functions/parseStructuredPredicate.md
---

# Function: parseStructuredPredicate()

```ts
function parseStructuredPredicate(
  value: unknown,
  depth?: number,
): ParsePredicateResult;
```

Defined in: [src/batteries/orchestration/predicates.ts:205](https://github.com/NHTIO/ADK/blob/v1.20260906.0/src/src/batteries/orchestration/predicates.ts#L205)

Validates an untrusted `EncodableValue` into the structured predicate IR.

This is the single authority that turns a branch/select node's `predicate` field (typed
`EncodableValue` in the IR) into a [StructuredPredicate](../type-aliases/StructuredPredicate.md). It never throws: every failure
returns `{ok: false, reason}` where `reason` is MODEL-ADDRESSED — it names the offending field
and the fix (for example, which operator is unknown and what the legal set is), so an authoring
model can correct the plan in one pass.

The value is validated structurally, not by type alone: a leaf requires a string `path` and a
closed-set `op`; `truthy`/`exists` must not carry a `value` while every other operator must;
combinators require arrays of already-valid predicates (`all`/`any`) or a single one (`not`).
A value that is none of the four shapes is refused with a reason naming the shape it most
resembles, so the author knows what to change.

## Parameters

| Parameter | Type      | Default value | Description                                                               |
| --------- | --------- | ------------- | ------------------------------------------------------------------------- |
| `value`   | `unknown` | `undefined`   | The untrusted value to validate, as read from a plan's `predicate` field. |
| `depth`   | `number`  | `0`           | -                                                                         |

## Returns

[`ParsePredicateResult`](../type-aliases/ParsePredicateResult.md)

A discriminated result: `{ok: true, predicate}` on success, or `{ok: false, reason}`
naming the fix on failure.
