/**
 * Anti-drift state primitives (0.8 unified-evaluator track).
 *
 * Per loop/docs/opensquid-anti-drift-unified-evaluator-design.md C-section
 * "state primitives": one filesystem-backed source of truth for the
 * active-task signal + violations log + drift catalog.
 *
 * This module is the foundation of the unified evaluator. Today it
 * lives alongside src/hooks/ (no cutover yet). Subsequent patches
 * port rules from src/hooks/* into src/anti-drift/rules.ts which
 * reads from this state module, replacing per-rule transcript
 * parsing.
 *
 * Three state primitives:
 *   1. active-task.json — current in_progress task id + subject + started_at
 *   2. violations.log   — append-only ring buffer (last N violations)
 *   3. drift-catalog.jsonl — append-only audit trail
 *
 * Layout (sessions are short-lived; project scope is durable):
 *   ~/.opensquid/sessions/<session-id>/active-task.json
 *   ~/.opensquid/sessions/<session-id>/violations.log
 *   ~/.opensquid/projects/<project-uuid>/drift-catalog.jsonl
 *
 * Design choice: writes are best-effort. State corruption is recoverable
 * (worst case: rule fails-open, which is what the existing hooks already
 * do). The new architecture's win is making "no active task" a positive
 * signal (file absent) rather than a parse failure (transcript
 * unreadable) — different shape, easier to reason about.
 */
export interface ActiveTaskState {
    /** Numeric task id from Claude Code's TodoWrite / TaskCreate. */
    id: string;
    /** Human-readable subject (helps with grep + debugging). */
    subject?: string;
    /** ISO 8601 timestamp when this task was marked in_progress. */
    started_at: string;
}
/**
 * Write the active-task state. Idempotent — overwrites any existing
 * file. Caller is responsible for choosing the right semantic (e.g.
 * a fresh TaskCreate vs. a TaskUpdate(in_progress) on an existing
 * task id).
 *
 * Exported for direct testing + use by the PreToolUse sync helper.
 */
export declare function writeActiveTask(sessionId: string, state: ActiveTaskState, options?: {
    dataRoot?: string;
}): Promise<void>;
/**
 * Read the active-task state. Returns null when the file is absent
 * (the canonical "no in_progress task" signal) OR when the file is
 * malformed (fail-safe: treat corruption as "no task" rather than
 * crashing the gate).
 */
export declare function readActiveTask(sessionId: string, options?: {
    dataRoot?: string;
}): Promise<ActiveTaskState | null>;
/**
 * Delete the active-task state. Idempotent — silent no-op when the
 * file is already absent. Called on TaskUpdate(completed).
 */
export declare function clearActiveTask(sessionId: string, options?: {
    dataRoot?: string;
}): Promise<void>;
export interface ViolationEntry {
    /** ISO 8601 timestamp the rule fired. */
    ts: string;
    /** Rule id from rules.ts. */
    rule_id: string;
    /** "block" | "warn" | "surface" | "auto". */
    verdict: string;
    /** Free-text reason (becomes the agent-facing surface text). */
    reason: string;
    /** Optional matched-text snippet (≤200 chars). */
    evidence?: string;
}
/**
 * Append a violation entry. Each call writes exactly one JSON line.
 * Best-effort: silent on write failure (the rule has already fired
 * in-process — losing the log entry is non-load-bearing).
 */
export declare function appendViolation(sessionId: string, entry: ViolationEntry, options?: {
    dataRoot?: string;
}): Promise<void>;
/**
 * Atomically claim all pending violations for surfacing at next UPS.
 * Returns the parsed entries; the on-disk file is renamed-then-deleted
 * so concurrent writers land in a fresh file the next consumer picks up.
 */
export declare function consumeViolations(sessionId: string, options?: {
    dataRoot?: string;
}): Promise<ViolationEntry[]>;
/**
 * Path helper for the per-project drift catalog. The catalog is
 * project-scoped (not session-scoped) so a project's drift history
 * accumulates across sessions.
 *
 * Falls back to a session-scoped path when projectUuid is null —
 * matches the existing drift-catalog.ts fallback shape.
 */
export declare function driftCatalogPath(projectUuid: string | null, sessionId: string, dataRoot?: string): string;
/**
 * Per-session file paths that SessionEnd should clean up. Project-scoped
 * files (drift-catalog.jsonl) are durable across sessions and excluded.
 */
export declare function sessionStateFiles(sessionId: string, dataRoot?: string): string[];
//# sourceMappingURL=state.d.ts.map