/** * Predicate matcher engine — vendored verbatim from pi's frontmatter-rules * extension. * * Source: src/builtin-pi-packages/pi-crtr-extensions/extensions/frontmatter-rules/index.ts * (the "Condition language" block, functions `asArray` … `evalCondition`). * * The unified document substrate uses this to evaluate a document's `gate` * predicate against a node-config subject (e.g. `orchestration.depth: { gte: 2 }`). * * This is intentionally a COPY, not an import: the bundled pi package is * excluded from crouter's tsc compile unit (tsconfig `exclude`) — it is loaded * by pi's own TS loader at runtime — so compiled core cannot import from it; * cross-boundary imports go extension→core only. The functions are pure * TS over `unknown` / `Record` with zero external imports, so * vendoring them keeps this module standalone and dependency-free. Keep it in * sync with the source by hand if the matcher language ever changes. * * Condition language (evaluated against the subject object): * A condition is a map of -> , AND-ed across fields. * `field` may be dotted to reach nested values (e.g. `orchestration.depth`). * * Matcher forms: * scalar (string/number/bool/null) * field === value, OR (if the field is an array) the array includes value * array [a, b, c] * membership/intersection: field is one of these, OR the field array * shares any element with these * object { : , ... } (multiple ops AND together) * eq equals (scalar or array-includes) * ne not eq * in [..] — field (or any of its array elements) is in the list * nin not in * exists true|false — field is present / absent * contains field array includes this value * containsAll [..] — field array includes all of these * containsAny [..] — field array includes any of these * matches regex string, case-sensitive (tests String(field); arrays: any) * imatches regex string, case-insensitive * gt gte lt lte numeric comparison * * Combinators (reserved keys at any condition level): * all: [ {..}, {..} ] every sub-condition true (AND) * any: [ {..}, {..} ] at least one true (OR) * not: { .. } sub-condition false * Sibling field matchers next to combinators are AND-ed in. * * Two load-bearing edge cases preserved from the source: * - An empty condition (`{}`) is INERT: it returns false, NOT match-all. * - An unknown op never matches. */ export declare function asArray(v: unknown): unknown[]; export declare function scalarEq(a: unknown, b: unknown): boolean; export declare function getField(subject: unknown, key: string): unknown; export declare function toRegExp(arg: unknown, flags: string): RegExp | null; export declare function applyOp(op: string, value: unknown, arg: unknown): boolean; export declare function matchField(value: unknown, matcher: unknown): boolean; /** * Evaluate a `gate` predicate against a subject object. * * This is the one function consumers call. Returns true iff `condition` * matches `subject`. A null/non-object condition and an empty object both * return false (inert), never match-all. */ export declare function evalCondition(condition: unknown, subject: Record): boolean;