{"version":3,"file":"predicates-CM27Z3TF.mjs","names":[],"sources":["../src/batteries/orchestration/exceptions.ts","../src/batteries/orchestration/predicates.ts"],"sourcesContent":["import { createException } from '../../factories'\n\n/** A required orchestration encoder is not configured. */\nexport const E_ORCH_ENCODER_REQUIRED = createException<[string]>(\n  'E_ORCH_ENCODER_REQUIRED',\n  '%s',\n  'E_ORCH_ENCODER_REQUIRED',\n  500,\n  true\n)\n/** An orchestration cell is unavailable. */\nexport const E_ORCH_CELL_UNAVAILABLE = createException<[string]>(\n  'E_ORCH_CELL_UNAVAILABLE',\n  '%s',\n  'E_ORCH_CELL_UNAVAILABLE',\n  422,\n  false\n)\n","import { E_ORCH_CELL_UNAVAILABLE } from './exceptions'\nimport { isInstanceOf, isObject } from '../../lib/utils/guards'\nimport type { EncodableValue } from './types'\n\n// ── the structured predicate IR ─────────────────────────────────────────────\n/**\n * The closed set of comparison operators a structured predicate leaf may name.\n *\n * `truthy` and `exists` take no `value`; every other operator requires one. The set is CLOSED —\n * `parseStructuredPredicate` refuses any other string with a model-addressed reason naming the\n * legal set, so a branch/select author cannot smuggle an operator no cell implements.\n */\nexport type PredicateOp =\n  | 'eq'\n  | 'ne'\n  | 'lt'\n  | 'lte'\n  | 'gt'\n  | 'gte'\n  | 'in'\n  | 'contains'\n  | 'truthy'\n  | 'exists'\n\n/**\n * A leaf predicate: read `path` from the readable context and compare it with `op`.\n *\n * `value` is optional because `truthy` and `exists` are unary — they need no right-hand side.\n * For every other operator `parseStructuredPredicate` requires `value` to be present.\n */\nexport interface PredicateLeaf {\n  /** The dot-path into the readable context to read and compare. */\n  path: string\n  /** The comparison operator. `truthy`/`exists` are unary and must not carry `value`. */\n  op: PredicateOp\n  /** The right-hand side to compare against. Required for every operator except `truthy`/`exists`. */\n  value?: EncodableValue\n}\n\n/** A predicate that is satisfied only when EVERY member is satisfied. */\nexport interface AllPredicate {\n  /** The member predicates; all must be satisfied. */\n  all: StructuredPredicate[]\n}\n\n/** A predicate that is satisfied when AT LEAST ONE member is satisfied. */\nexport interface AnyPredicate {\n  /** The member predicates; at least one must be satisfied. */\n  any: StructuredPredicate[]\n}\n\n/** A predicate that is satisfied exactly when its single member is NOT satisfied. */\nexport interface NotPredicate {\n  /** The member predicate; its negation is the result. */\n  not: StructuredPredicate\n}\n\n/**\n * The structured predicate IR — the value a branch/select node's `predicate` field holds when the\n * structured cell interprets it.\n *\n * A discriminated union of four shapes: a leaf (`{path, op, value?}`), and the three combinators\n * `{all}`, `{any}`, `{not}`. The combinator shapes are discriminated by their single key, and a\n * leaf by the presence of `path`/`op`. `parseStructuredPredicate` is the single authority that\n * turns an untrusted `EncodableValue` into this IR.\n */\nexport type StructuredPredicate = PredicateLeaf | AllPredicate | AnyPredicate | NotPredicate\n\n/**\n * Type guard for {@link PredicateLeaf}. A leaf is a plain object carrying a string `path` and a\n * string `op`; the `op` is narrowed to `PredicateOp` only when it is a member of the closed set.\n */\nexport const isPredicateLeaf = (v: unknown): v is PredicateLeaf => {\n  if (!isObject(v)) return false\n  if (!isSingleForm(v)) return false\n  if (typeof v.path !== 'string') return false\n  if (typeof v.op !== 'string') return false\n  return isPredicateOp(v.op)\n}\n\n/**\n * Type guard for {@link AllPredicate}. An `all` combinator is a plain object whose sole\n * discriminator key `all` holds an array of structured predicates.\n */\nexport const isAllPredicate = (v: unknown): v is AllPredicate => {\n  if (!isObject(v)) return false\n  if (!isSingleForm(v)) return false\n  if (!Array.isArray(v.all)) return false\n  return v.all.every(isStructuredPredicate)\n}\n\n/**\n * Type guard for {@link AnyPredicate}. An `any` combinator is a plain object whose sole\n * discriminator key `any` holds an array of structured predicates.\n */\nexport const isAnyPredicate = (v: unknown): v is AnyPredicate => {\n  if (!isObject(v)) return false\n  if (!isSingleForm(v)) return false\n  if (!Array.isArray(v.any)) return false\n  return v.any.every(isStructuredPredicate)\n}\n\n/**\n * Type guard for {@link NotPredicate}. A `not` combinator is a plain object whose sole\n * discriminator key `not` holds a single structured predicate.\n */\nexport const isNotPredicate = (v: unknown): v is NotPredicate => {\n  if (!isObject(v)) return false\n  if (!isSingleForm(v)) return false\n  return isStructuredPredicate(v.not)\n}\n\n/**\n * Type guard for the whole {@link StructuredPredicate} union. A value is a structured predicate\n * iff it is one of the four shapes. Because the combinator shapes are discriminated by their\n * single key and a leaf by `path`/`op`, the four guards are mutually exclusive.\n */\nexport const isStructuredPredicate = (v: unknown): v is StructuredPredicate => {\n  return isPredicateLeaf(v) || isAllPredicate(v) || isAnyPredicate(v) || isNotPredicate(v)\n}\n\n/**\n * Type guard for {@link PredicateOp}. `op` is a member of the closed set.\n */\nconst isPredicateOp = (v: unknown): v is PredicateOp => {\n  return (\n    v === 'eq' ||\n    v === 'ne' ||\n    v === 'lt' ||\n    v === 'lte' ||\n    v === 'gt' ||\n    v === 'gte' ||\n    v === 'in' ||\n    v === 'contains' ||\n    v === 'truthy' ||\n    v === 'exists'\n  )\n}\n\nconst LEGAL_OPS =\n  \"'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte' | 'in' | 'contains' | 'truthy' | 'exists'\"\n\n/**\n * The recognised structural keys of a structured predicate: the leaf markers `path`/`op` and the\n * three combinator keys `all`/`any`/`not`.\n */\nconst STRUCTURAL_KEYS = ['all', 'any', 'not', 'path', 'op'] as const\n\n/**\n * The structural keys an object actually carries, in a stable order.\n */\nconst presentStructuralKeys = (v: object): string[] => STRUCTURAL_KEYS.filter((k) => k in v)\n\n/**\n * True when an object carries exactly one predicate FORM: a leaf (`path`/`op` with no combinator\n * key), or exactly one of `all`/`any`/`not`. A value mixing a leaf with a combinator, or carrying\n * more than one combinator key, is ambiguous and is not a single form.\n */\nconst isSingleForm = (v: object): boolean => {\n  const present = presentStructuralKeys(v)\n  const hasLeaf = present.includes('path') || present.includes('op')\n  const combinators = present.filter((k) => k === 'all' || k === 'any' || k === 'not')\n  return !(combinators.length > 1 || (hasLeaf && combinators.length > 0))\n}\n\n/**\n * The result of {@link parseStructuredPredicate}: either a validated predicate, or a\n * model-addressed reason naming the fix.\n */\nexport type ParsePredicateResult =\n  | { ok: true; predicate: StructuredPredicate }\n  | { ok: false; reason: string }\n\n/**\n * The deepest combinator nesting a structured predicate may carry.\n *\n * @remarks\n * Chosen well below the measured failure point rather than at it: evaluation begins throwing\n * `RangeError` around 5,000 levels on Node 24, and a limit tuned to one engine's stack size would\n * be a limit that shifts under the reader. 256 is far past anything a human or a model writes —\n * `all`/`any` take LISTS, so real predicates are wide, not deep — while leaving a very large\n * margin against the actual overflow.\n */\nexport const MAX_PREDICATE_DEPTH = 256\n\n/**\n * Validates an untrusted `EncodableValue` into the structured predicate IR.\n *\n * This is the single authority that turns a branch/select node's `predicate` field (typed\n * `EncodableValue` in the IR) into a {@link StructuredPredicate}. It never throws: every failure\n * returns `{ok: false, reason}` where `reason` is MODEL-ADDRESSED — it names the offending field\n * and the fix (for example, which operator is unknown and what the legal set is), so an authoring\n * model can correct the plan in one pass.\n *\n * The value is validated structurally, not by type alone: a leaf requires a string `path` and a\n * closed-set `op`; `truthy`/`exists` must not carry a `value` while every other operator must;\n * combinators require arrays of already-valid predicates (`all`/`any`) or a single one (`not`).\n * A value that is none of the four shapes is refused with a reason naming the shape it most\n * resembles, so the author knows what to change.\n *\n * @param value - The untrusted value to validate, as read from a plan's `predicate` field.\n * @returns A discriminated result: `{ok: true, predicate}` on success, or `{ok: false, reason}`\n *   naming the fix on failure.\n */\nexport const parseStructuredPredicate = (\n  value: unknown,\n  depth: number = 0\n): ParsePredicateResult => {\n  // DEPTH IS BOUNDED, and the bound is here rather than at evaluation because this is the gate\n  // freeze runs. An over-deep tree overflows the JavaScript call stack — measured: evaluation\n  // throws `RangeError` around 5,000 nested combinators and parsing itself throws around 20,000\n  // — and a stack overflow escapes as an uncaught error, which breaks the cell's promise that a\n  // predicate never crashes a run.\n  //\n  // Plan bounds do not cover this: a crashing 20,000-deep predicate encodes to roughly 180KB\n  // against a 1 MiB `maxEncodedBytes`, so it passes freeze on size and detonates at run time.\n  // Refusing here means the plan is rejected BEFORE an operator can approve it.\n  if (depth > MAX_PREDICATE_DEPTH) {\n    return {\n      ok: false,\n      reason:\n        `predicate nests deeper than ${MAX_PREDICATE_DEPTH} combinators, which would overflow ` +\n        'the call stack during evaluation. Flatten it — `all`/`any` take a LIST, so sibling ' +\n        'conditions belong in one array rather than nested one per level.',\n    }\n  }\n  if (!isObject(value)) {\n    return {\n      ok: false,\n      reason:\n        'predicate must be a structured predicate object: a leaf {path, op, value?}, or a ' +\n        'combinator {all: [...]}, {any: [...]}, or {not: ...}. Got a non-object.',\n    }\n  }\n\n  // Refuse a value that mixes more than one predicate FORM: a leaf with a combinator, or more\n  // than one combinator key. Silently keeping whichever key the parser tests first would let an\n  // approved plan branch on a condition the author never wrote.\n  if (!isSingleForm(value)) {\n    const present = presentStructuralKeys(value)\n    return {\n      ok: false,\n      reason:\n        `predicate mixes more than one form: it carries ${present.map((k) => `'${k}'`).join(', ')}. ` +\n        'A predicate must be exactly one form: a leaf {path, op, value?}, or one of ' +\n        '{all: [...]}, {any: [...]}, {not: ...}.',\n    }\n  }\n\n  // A leaf: {path, op, value?}\n  if ('path' in value || 'op' in value) {\n    if (typeof value.path !== 'string') {\n      return {\n        ok: false,\n        reason: `predicate leaf 'path' must be a string (a dot-path into the readable context). Got ${describe(value.path)}.`,\n      }\n    }\n    if (typeof value.op !== 'string') {\n      return {\n        ok: false,\n        reason: `predicate leaf 'op' must be a string. Got ${describe(value.op)}.`,\n      }\n    }\n    if (!isPredicateOp(value.op)) {\n      return {\n        ok: false,\n        reason: `predicate leaf 'op' is unknown: '${value.op}'. The legal set is ${LEGAL_OPS}.`,\n      }\n    }\n    const unary = value.op === 'truthy' || value.op === 'exists'\n    if (unary && 'value' in value) {\n      return {\n        ok: false,\n        reason: `predicate leaf 'op' is '${value.op}', which is unary and must NOT carry a 'value'. Remove the 'value' field.`,\n      }\n    }\n    if (!unary && !('value' in value)) {\n      return {\n        ok: false,\n        reason: `predicate leaf 'op' is '${value.op}', which requires a 'value' to compare against. Add a 'value' field.`,\n      }\n    }\n    return {\n      ok: true,\n      predicate: {\n        path: value.path,\n        op: value.op,\n        value: value.value as EncodableValue | undefined,\n      },\n    }\n  }\n\n  // Combinators: {all}, {any}, {not}\n  if ('all' in value) {\n    if (!Array.isArray(value.all)) {\n      return {\n        ok: false,\n        reason: `predicate combinator 'all' must be an array of structured predicates. Got ${describe(value.all)}.`,\n      }\n    }\n    for (let i = 0; i < value.all.length; i++) {\n      const member = parseStructuredPredicate(value.all[i], depth + 1)\n      if (!member.ok) {\n        return {\n          ok: false,\n          reason: `predicate combinator 'all' member ${i} is invalid: ${member.reason}`,\n        }\n      }\n    }\n    return { ok: true, predicate: { all: value.all as StructuredPredicate[] } }\n  }\n  if ('any' in value) {\n    if (!Array.isArray(value.any)) {\n      return {\n        ok: false,\n        reason: `predicate combinator 'any' must be an array of structured predicates. Got ${describe(value.any)}.`,\n      }\n    }\n    for (let i = 0; i < value.any.length; i++) {\n      const member = parseStructuredPredicate(value.any[i], depth + 1)\n      if (!member.ok) {\n        return {\n          ok: false,\n          reason: `predicate combinator 'any' member ${i} is invalid: ${member.reason}`,\n        }\n      }\n    }\n    return { ok: true, predicate: { any: value.any as StructuredPredicate[] } }\n  }\n  if ('not' in value) {\n    const member = parseStructuredPredicate(value.not, depth + 1)\n    if (!member.ok) {\n      return {\n        ok: false,\n        reason: `predicate combinator 'not' is invalid: ${member.reason}`,\n      }\n    }\n    return { ok: true, predicate: { not: member.predicate } }\n  }\n\n  return {\n    ok: false,\n    reason:\n      'predicate must be a structured predicate object: a leaf {path, op, value?}, or a ' +\n      'combinator {all: [...]}, {any: [...]}, or {not: ...}. Got an object with none of the ' +\n      `discriminator keys 'path'/'op'/'all'/'any'/'not'.`,\n  }\n}\n\n/**\n * A short, safe description of a value for use in a model-addressed reason. Never throws and\n * never inspects live objects beyond their constructor name.\n */\nconst describe = (v: unknown): string => {\n  if (v === null) return 'null'\n  if (v === undefined) return 'undefined'\n  if (typeof v === 'string') return `a string`\n  if (typeof v === 'number') return `a number`\n  if (typeof v === 'boolean') return `a boolean`\n  if (Array.isArray(v)) return `an array`\n  if (isObject(v)) {\n    const name = (v as { constructor?: { name?: string } }).constructor?.name\n    return name ? `an object of type '${name}'` : 'an object'\n  }\n  return `a ${typeof v}`\n}\n\n// ── idempotent lazy loading ─────────────────────────────────────────────────\n/**\n * Wraps a cell's `load()` so it is idempotent and converts a failed lazy `await import()` into\n * `E_ORCH_CELL_UNAVAILABLE`.\n *\n * A cell's `load()` is expected to resolve an optional ESM peer through a lazy `await import()`.\n * That import can fail (the package is not installed), and the failure must surface as a named\n * `E_ORCH_CELL_UNAVAILABLE` whose message names the missing package and its install command —\n * not as a raw module-resolution error the author cannot act on. This helper also makes `load()`\n * idempotent: the wrapped loader runs at most once, and every subsequent call resolves with the\n * same outcome, so a cell can be loaded once and reused across many plans without re-importing.\n *\n * The helper is deliberately minimal — it is a single idempotence + error-mapping wrapper, not a\n * plugin registry. A cell that needs to register itself with a consumer's registry does so in its\n * own `load()` body, before or after calling the wrapped loader.\n *\n * @param id - The cell's id, used to name the missing package in the error.\n * @param loader - The cell's actual load body (typically a lazy `await import()`).\n * @returns A wrapped loader that is idempotent and maps import failure to\n *   `E_ORCH_CELL_UNAVAILABLE`.\n */\nexport const loadOnce = (id: string, loader: () => Promise<void>): (() => Promise<void>) => {\n  let state: 'idle' | 'loading' | 'loaded' | 'failed' = 'idle'\n  let pending: Promise<void> | undefined\n  let failure: unknown\n\n  return async () => {\n    if (state === 'loaded') return\n    if (state === 'failed') throw failure\n    if (state === 'loading' && pending) return pending\n\n    state = 'loading'\n    pending = (async () => {\n      try {\n        await loader()\n        state = 'loaded'\n      } catch (err) {\n        state = 'failed'\n        failure = toCellUnavailable(id, err)\n        throw failure\n      }\n    })()\n    return pending\n  }\n}\n\n/**\n * Maps a failed lazy import into an `E_ORCH_CELL_UNAVAILABLE` naming the missing package and its\n * install command. The package name is derived from the cell id (a cell id is expected to be the\n * package it loads, e.g. `'jexl'` or `'fengari'`); the install command is the standard\n * `npm install <id>`.\n */\nconst toCellUnavailable = (id: string, err: unknown): unknown => {\n  const message =\n    `orchestration cell '${id}' is unavailable: its optional peer could not be loaded. ` +\n    `Install it with: npm install ${id}. Underlying error: ${isInstanceOf(err, 'Error', Error) ? err.message : String(err)}`\n  return new E_ORCH_CELL_UNAVAILABLE([message])\n}\n"],"mappings":";;;;;AAGA,IAAa,0BAA0B,gBACrC,2BACA,MACA,2BACA,KACA,IACF;;AAEA,IAAa,0BAA0B,gBACrC,2BACA,MACA,2BACA,KACA,KACF;;;;;;;ACuDA,IAAa,mBAAmB,MAAmC;CACjE,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO;CACzB,IAAI,CAAC,aAAa,CAAC,GAAG,OAAO;CAC7B,IAAI,OAAO,EAAE,SAAS,UAAU,OAAO;CACvC,IAAI,OAAO,EAAE,OAAO,UAAU,OAAO;CACrC,OAAO,cAAc,EAAE,EAAE;AAC3B;;;;;AAMA,IAAa,kBAAkB,MAAkC;CAC/D,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO;CACzB,IAAI,CAAC,aAAa,CAAC,GAAG,OAAO;CAC7B,IAAI,CAAC,MAAM,QAAQ,EAAE,GAAG,GAAG,OAAO;CAClC,OAAO,EAAE,IAAI,MAAM,qBAAqB;AAC1C;;;;;AAMA,IAAa,kBAAkB,MAAkC;CAC/D,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO;CACzB,IAAI,CAAC,aAAa,CAAC,GAAG,OAAO;CAC7B,IAAI,CAAC,MAAM,QAAQ,EAAE,GAAG,GAAG,OAAO;CAClC,OAAO,EAAE,IAAI,MAAM,qBAAqB;AAC1C;;;;;AAMA,IAAa,kBAAkB,MAAkC;CAC/D,IAAI,CAAC,SAAS,CAAC,GAAG,OAAO;CACzB,IAAI,CAAC,aAAa,CAAC,GAAG,OAAO;CAC7B,OAAO,sBAAsB,EAAE,GAAG;AACpC;;;;;;AAOA,IAAa,yBAAyB,MAAyC;CAC7E,OAAO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