trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
50 lines • 1.71 kB
TypeScript
/**
* EQL-S Query Engine — Pattern-matching evaluator over the EAV store.
*
* Evaluates queries by matching fact/link patterns against the store,
* binding variables, applying filters, and computing aggregates.
*
* @module trellis/core/query
*/
import type { EAVStore, Atom } from '../store/eav-store.js';
import type { Query, DatalogRule } from './types.js';
export interface QueryResult {
bindings: Record<string, Atom>[];
executionTime: number;
count: number;
}
export declare class QueryEngine {
private store;
private rules;
private maxRuleDepth;
constructor(store: EAVStore);
/** Register a Datalog rule. Multiple rules with the same name = union. */
addRule(rule: DatalogRule): void;
removeRule(name: string): void;
/** Execute a query against the store. */
execute(query: Query): QueryResult;
private _evaluatePatterns;
private _evaluatePattern;
private _evalFactPattern;
private _evalLinkPattern;
private _evalNotPattern;
private _evalOrPattern;
private _evalRuleApplication;
private _evalFilter;
private _aggregate;
private _computeAggregate;
/**
* Semantic rank for known enum values. EQL-S stores these as raw strings, so
* a plain `<`/`>` comparison would be lexicographic (medium > critical).
* Mapping values to ranks lets `ORDER BY ?priority` / `ORDER BY ?status`
* honor the workflow order. Keyed by value (not attribute) since the tokens
* are unambiguous across the two enums.
*/
private static readonly ENUM_RANKS;
private _order;
private _project;
private _resolve;
private _bind;
private _dedup;
}
//# sourceMappingURL=engine.d.ts.map