import { sessions, sessionToolPayload } from './schema/sessions.js'; import type { StoredSession, StoredSessionHostMetrics } from '@opensip-cli/contracts'; import type { DrizzleDataStore, DrizzleHandle } from '@opensip-cli/datastore/internal'; /** Package-private validated projection shared by legacy and bundle writes. */ export interface PreparedSessionWrite { readonly sessionId: string; readonly tool: string; readonly hasPayload: boolean; readonly sessionRow: typeof sessions.$inferInsert; readonly payloadRow?: typeof sessionToolPayload.$inferInsert; readonly payloadMissingInnerVersion: boolean; } /** * Validate and project one fully host-stamped Session without writing it. * * This function is intentionally not exported from the package barrel. The * evidence-bundle writer uses it to prevalidate every row before entering its * transaction; `SessionWriteRepo` uses the same projection for legacy writes. */ export declare function prepareSessionWrite(session: StoredSession): PreparedSessionWrite; /** Write a prepared Session and optional opaque payload through the active tx. */ export declare function writePreparedSession(tx: DrizzleHandle, prepared: PreparedSessionWrite): void; /** Emit the existing bounded diagnostics only after the transaction committed. */ export declare function reportPreparedSessionWrite(prepared: PreparedSessionWrite): void; export declare class SessionWriteRepo { private readonly datastore; constructor(datastore: DrizzleDataStore); /** * Persist a completed session row and its tool payload. Writes the generic * columns including host-owned `startedAt` / `completedAt` (mapped to the * physical `timestamp*` / `completed_at*` columns); `session.hostMetrics` is * IGNORED here — metrics arrive later and attach via {@link SessionWriteRepo.upsertHostMetrics}. * * @throws {ValidationError} When the mapped row shape or lifecycle timing is * invalid — guarded eagerly so malformed values never reach the write lock. */ save(session: StoredSession): void; /** Best-effort upsert of host-side overhead metrics (host-owned-run-timing §5.3). */ upsertHostMetrics(sessionId: string, metrics: StoredSessionHostMetrics): void; } //# sourceMappingURL=session-write-repo.d.ts.map