Verify execution integrity, query the semantic behavior graph, replay session timelines, and run counterfactual experiments.
The query layer provides verification, graph queries, replay, and counterfactual analysis.
`verify()` validates hash chain integrity and signatures. `queryGraph()` interrogates the semantic behavior graph. `replayTimeline()` returns a chronological timeline of trace events. `counterfactual()` branches from a node with modified inputs for "what if" analysis.
const proof = await inv.verify('execution-id');
console.log(proof.valid);
const receipts = await inv.query({ sessionId: 'session-123', action: 'swap' });
const timeline = await inv.replayTimeline('session-123');
for (const entry of timeline) {
console.log(`${entry.actionType} at ${entry.timestamp} (${entry.durationMs}ms)`);
}
const cf = await inv.counterfactual({
branchFromNodeId: 'node-456',
modifiedInput: { query: 'different search' },
tag: 'experiment-1',
});interface VerificationProof {
valid: boolean;
executionId: string;
chain: Array<{ nodeId: string; hash: string; actionType: string; anomalyScore: number }>;
signedBy: string;
anchored: boolean;
tamperedNodes?: string[];
}interface ReceiptQuery {
sessionId?: string;
agent?: string;
action?: string;
fromTimestamp?: number;
toTimestamp?: number;
limit?: number;
offset?: number;
}interface EvalSuite {
add(name: string, fn: (query: TraceQuery) => void): this;
addJudge(name: string, config: {
prompt: string;
provider: (prompt: string) => Promise<string>;
}): this;
run(receipts: readonly Receipt[]): Promise<EvalResult[]>;
}interface EvalResult {
name: string;
passed: boolean;
error?: string;
durationMs: number;
type: 'assertion' | 'judge';
}interface TraceQuery {
ofType(actionType: string): TraceQuery;
byAgent(agent: string): TraceQuery;
withError(): TraceQuery;
where(predicate: (r: Receipt) => boolean): TraceQuery;
inTimeRange(from: number, to: number): TraceQuery;
all(): Receipt[];
count(): number;
first(): Receipt | undefined;
}