Repository Public
1/**2 * Database access of the engine (always inside a journaled step). A failing query is an infrastructure3 * problem, not a verdict on the run: it is raised as `KernelStorageError`, which the kernel never4 * journals as a step failure — the run is released and resumed later instead of ending `failed`.5 */6import { KernelStorageError, type Kernel } from '@aos/kernel';78export async function dbQuery<T = Record<string, unknown>>(k: Kernel, sql: string, params: unknown[] = []): Promise<T[]> {9 try {10 return (await k.pool.query(sql, params)).rows as T[];11 } catch (err) {12 throw new KernelStorageError(`engine storage error: ${(err as Error).message}`, { cause: err });13 }14}15