/** * Session ID utilities for the Trap Ledger A.3.a schema extension. * * The SessionStart hook mints a UUID and persists it to `.totem/ledger/.session-id`. * Subsequent MCP calls and ledger writes within the same session correlate via this * UUID. Per ADR-029 § Session Heuristic, the explicit UUID supersedes the rolling-2h * activity-based heuristic when present; the TTL fallback handles long-running * sessions exceeding 24h or sessions that bypass the SessionStart hook. */ /** Mint a fresh session UUID. */ export declare function mintSessionId(): string; /** * Persist a session ID to `/ledger/.session-id`. * Creates the ledger directory if it doesn't exist. Fire-and-forget on I/O failure. */ export declare function writeSessionId(totemDir: string, sessionId: string, onWarn?: (msg: string) => void): void; /** * Read the current session ID from `/ledger/.session-id`. * * Returns the persisted UUID when present AND within the TTL window. Returns * undefined when the file is missing, malformed, or expired (file older than * `ttlHours` per Q-9 — fallback for long sessions or hookless agents). * * The TTL fallback uses file mtime; sessions exceeding the window are treated * as "missing" so callers can defensively decide whether to rotate. * * Race-condition note (strategy-Claude T0345Z): if a ledger writer reads this * file mid-SessionStart-hook rotation, it will stamp the event with the prior * session UUID. This is intentional and NOT a bug — the event's timestamp * reflects when it actually fired, and the ADR-029 compliance metric considers * it part of the prior session (correctly, per its temporal semantics). Future * readers tempted to "fix" this race by guarding rotation with a lockfile * should re-read this doc-comment and the metric semantics before changing. */ export declare function readSessionId(totemDir: string, ttlHours?: number): string | undefined; //# sourceMappingURL=session-id.d.ts.map