/** * Session Hook Handlers - Phase 2D of T5237 * * Handlers that capture session lifecycle events. * Auto-registers on module load. * * T138: Triggers memory bridge refresh on session start and end. * T139: Regenerates bridge with session scope on start. * T144: Extracts transcript observations on session end. * T5158: Auto-snapshots SQLite databases (tasks.db + brain.db) via * VACUUM INTO on SessionEnd to preserve a recovery point now that * the databases are no longer tracked in project git (ADR-013). * T527: Removed duplicate session observeBrain writes — session data already * lives in the sessions table; writing it again to brain_observations * was pure noise. * T549 Wave 3-E: Fire-and-forget sleep-time consolidation on session end. * Runs after backup (priority 5) so brain.db snapshot is captured first. * T554: Fire-and-forget LLM reflector on session end. Runs at priority 4 * (after consolidation at priority 5) to synthesize final session knowledge. * T732: Write `transcript_pending_extraction` tombstone on session end (priority 3). * Runs after reflector so it is the last scheduled operation. Records the * session JSONL path so `cleo transcript scan --pending` can list queued work. * T1263: Append session journal entry at priority 2 (last in pipeline). * Absorbs T1262 session-end hook: calls scanBrainNoise and embeds * doctorSummary in each session_end journal entry. * MUST use `await` (not setImmediate) — process exits after this hook. */ import type { SessionEndPayload, SessionStartPayload } from '../types.js'; /** * Handle SessionStart - refresh memory bridge on session start. * * T138: Refresh memory bridge on session start. * T139: Regenerate bridge with session scope context. * T527: Removed duplicate observeBrain write — session data is already * persisted in the sessions table. */ export declare function handleSessionStart(projectRoot: string, _payload: SessionStartPayload): Promise; /** * Handle SessionEnd - run post-session tasks and refresh memory bridge. * * T138: Refresh memory bridge after session ends. * T144: Extract transcript observations via cross-provider adapter. * T527: Removed duplicate observeBrain write — session data is already * persisted in the sessions table. */ export declare function handleSessionEnd(projectRoot: string, payload: SessionEndPayload): Promise; /** * Handle SessionEnd - snapshot SQLite databases to `.cleo/backups/sqlite/`. * * ADR-013 / T5158: `.cleo/tasks.db` and `.cleo/brain.db` are NOT tracked in * project git, so we need an out-of-band recovery mechanism. This handler * calls `vacuumIntoBackupAll` with `force: true` at every session end to * guarantee a fresh point-in-time snapshot of both databases. * * Rotation (MAX_SNAPSHOTS = 10 per database) is handled inside * `sqlite-backup.ts`. Failures here are non-fatal: a backup error must * never block session end. * * The `vacuumIntoBackupAll` import is deferred to call time so tests that * auto-load session-hooks (e.g. via `handlers/index.ts`) do not have to * mock every transitive dependency of `sqlite-backup.ts` at hoisted * `vi.mock` time. */ export declare function handleSessionEndBackup(projectRoot: string, _payload: SessionEndPayload): Promise; /** * Handle SessionEnd — fire-and-forget sleep-time memory consolidation. * * T549 Wave 3-E: Runs the full consolidation pipeline (dedup, quality recompute, * tier promotion, contradiction detection, soft eviction, graph strengthening, * summary generation) in the background after the session backup has completed. * * Uses setImmediate to yield control so the session end flow completes before * consolidation begins. Consolidation errors are caught and logged to console.warn * — they MUST NOT block session end or throw to callers. * * Priority 5 ensures this runs last (after backup at priority 10). */ export declare function handleSessionEndConsolidation(projectRoot: string, _payload: SessionEndPayload): Promise; /** * Handle SessionEnd — fire-and-forget LLM Observer compression. * * T740: GAP-6 fix — Observer was only triggered on task completion when * observation count >= threshold (default 10). Sessions with < 10 observations * never got compression. This hook runs Observer unconditionally at session end * with a threshold override of 1, ensuring even short sessions get compressed. * * Priority 4.5 (between consolidation at 5 and reflector at 4) so Observer * compresses the raw observations before Reflector synthesizes patterns/learnings * from them. This matches the intended pipeline order. * * Uses setImmediate to yield control before the LLM call. Errors are caught * and logged — they MUST NOT block session end or throw to callers. */ export declare function handleSessionEndObserver(projectRoot: string, payload: SessionEndPayload): Promise; /** * Handle SessionEnd — fire-and-forget LLM reflector synthesis. * * T554: Runs the Reflector after the consolidation pass (priority 5) to * synthesize session observations into durable patterns and learnings. * * Uses setImmediate to yield control before the LLM call. Errors are caught * and logged — they MUST NOT block session end or throw to callers. * * Priority 4 ensures this runs after consolidation (priority 5). */ export declare function handleSessionEndReflector(projectRoot: string, payload: SessionEndPayload): Promise; /** * Handle SessionEnd — write a `transcript_pending_extraction` record to brain_observations. * * T732: Records the session JSONL path so the warm-tier extractor and * `cleo transcript scan --pending` can locate queued sessions. * * The record is idempotent: re-running session end for the same session_id * updates the timestamp but does not create a duplicate (content-hash dedup * in observeBrain handles this automatically). * * Priority 3 — runs after reflector (priority 4) so it is the last step in * the session-end pipeline. * * Uses setImmediate to yield so the session-end response reaches the CLI * before the brain write occurs. */ export declare function handleSessionEndTranscriptSchedule(projectRoot: string, payload: SessionEndPayload): Promise; /** * Handle SessionEnd — append a session journal entry to `.cleo/session-journals/`. * * T1263 PSYCHE E6: Writes a `session_end` JSONL entry capturing session metadata * and the compact result of `scanBrainNoise` (T1262 absorption). * * **MUST use synchronous `await`** — this hook runs at priority 2, immediately * before process.exit. Using `setImmediate` here would silently drop the write. * * Runs at priority 2 — the last synchronous hook in the session-end pipeline, * ensuring all prior work (backup, consolidation, observer, reflector, transcript) * has been scheduled before the journal entry is written. */ export declare function handleSessionEndJournal(projectRoot: string, payload: SessionEndPayload): Promise; //# sourceMappingURL=session-hooks.d.ts.map