Function: parseStructuredPredicate()
function parseStructuredPredicate(
value: unknown,
depth?: number,
): ParsePredicateResult;Defined in: src/batteries/orchestration/predicates.ts:205
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. 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
A discriminated result: {ok: true, predicate} on success, or {ok: false, reason} naming the fix on failure.