/** * PgObservationStore — PostgreSQL parity for the observation store. * * Mirrors PgScheduledJobStore / PgSynapseSessionStore's discipline: the * ObservationStore interface is SYNCHRONOUS (the hook-service and * CompactionSnapshotService call store.insert / listBySession / listRecent * with no await, matching the PostgreSQL store and legacy local database API). PG is * inherently async, so this store: * - Writes fire-and-forget (best-effort, logged on failure — matching the * PostgreSQL store's try/catch best-effort semantics). * - Reads are served from an in-memory mirror hydrated from PG on first use * (async) and kept in sync by every insert. The mirror is the hot read * path within a process; PG is the durability + cross-process recovery * layer (a new process hydrates its mirror from the persisted rows, so * observations captured before a restart are visible after it once * hydration settles). This is what makes compaction snapshots round-trip * across a process restart under PG. * * Uses raw SQL ($executeRaw / $queryRaw) via the shared prisma client — the * same pattern as PgScheduledJobStore and MemoryRepositoryPg — to avoid the * Prisma 7.7.0 + adapter-pg isObjectEnumValue incompatibility. Reuses * getPrismaClient() (no second pool). * * Schema parity: observations table (see Prisma model Observation and PG * migration 20260710123800_add_observations_pg). The `created_at` column is * BIGINT ms-epoch to match the store's `createdAt: number` contract (NOT the * Prisma model's DateTime — see the migration note). */ import type { Observation, ObservationStore } from "./observation-contract.js"; export declare class PgObservationStore implements ObservationStore { private prisma; /** * In-memory mirror: the sync read path. Hydrated from PG on first use and * kept in sync by every insert(). Keyed by id for dedupe on upsert. */ private mirror; private hydrated; private hydrating; /** * Epoch (ms) of the last failed hydration attempt. Used to rate-limit * retries so a persistent PG error does not turn every op into a full * `SELECT *` retry storm. We retry at most once per HYDRATE_RETRY_MS. */ private hydrateFailedAt; private static readonly HYDRATE_RETRY_MS; private getClient; /** * Best-effort hydrate the mirror from PG. Resolves (never rejects) — * failures log a warn and leave the mirror as-is; inserts made before * hydration lands are preserved (re-applied over the DB snapshot, matching * PgScheduledJobStore's inflight-merge). */ private ensureHydrated; insert(obs: Observation): void; listRecent(projectId: string, limit: number): Observation[]; listBySession(sessionId: string, limit: number): Observation[]; countByProject(projectId: string): number; journalMode(): string; /** Test helper: force hydration to complete before reading the mirror. */ __hydrate(): Promise; /** Test helper: await in-flight writes. Not for production use. */ __drain(): Promise; } //# sourceMappingURL=observation-repository-pg.d.ts.map