trellis
Version:
Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications
52 lines • 2.15 kB
TypeScript
/**
* Datalog Evaluator — Rule-based recursive queries.
*
* Provides transitive closure, reachability, and other recursive
* graph queries via Datalog-style rules evaluated over the EAV store.
*
* Built-in rules:
* - `reachable(?src, ?tgt)` via a named link attribute
* - `ancestor(?x, ?y)` (generic transitive closure over any link)
*
* Custom rules can be registered via `addRule()`.
*
* @module trellis/core/query
*/
import type { EAVStore } from '../store/eav-store.js';
import type { DatalogRule } from './types.js';
import { QueryEngine } from './engine.js';
/**
* Creates a transitive closure rule over a specific link attribute.
*
* `reachable(?x, ?y) :- (x attr y)`
* `reachable(?x, ?y) :- (x attr ?z), reachable(?z, ?y)`
*/
export declare function transitiveClosureRules(ruleName: string, linkAttribute: string): DatalogRule[];
/**
* Creates a reverse reachability rule (follows links backwards).
*/
export declare function reverseReachabilityRules(ruleName: string, linkAttribute: string): DatalogRule[];
/**
* Creates a "sibling" rule — entities that share a common parent via a link attribute.
*
* `sibling(?a, ?b) :- (?a attr ?parent), (?b attr ?parent)`
* FILTER ?a != ?b
*/
export declare function siblingRules(ruleName: string, linkAttribute: string): DatalogRule[];
export declare class DatalogRuntime {
private engine;
constructor(store: EAVStore);
/** Register a Datalog rule (or multiple). */
addRule(rule: DatalogRule): void;
addRules(rules: DatalogRule[]): void;
removeRule(name: string): void;
/** Register built-in transitive closure for a link attribute. */
registerTransitiveClosure(ruleName: string, linkAttribute: string): void;
/** Register built-in reverse reachability for a link attribute. */
registerReverseReachability(ruleName: string, linkAttribute: string): void;
/** Register built-in sibling rule for a link attribute. */
registerSiblings(ruleName: string, linkAttribute: string): void;
/** Get the underlying QueryEngine for direct query execution. */
getEngine(): QueryEngine;
}
//# sourceMappingURL=datalog.d.ts.map