/**
 * Unified audit log (CLI.5).
 *
 * Single libsql `audit_log` table consolidating every audit-emit point
 * in the daemon: AUTO.3 capability gate, SCHED.1 webhook server,
 * SCHED.x schedule fires, DURABLE.4 resumer, channel_send, and the
 * SEC.6 queued-shell-exec approval loop (`pending_shell` — the only
 * category whose rows mutate post-write via `transitionPending`).
 *
 * Discipline:
 *   - `detail_json` carries the category-specific payload — NEVER PII.
 *     Producers MUST pre-hash sensitive values via `hashDetailValue`
 *     (signing secrets, bearer tokens, URLs with creds). See per-
 *     category callsites for the hash boundary.
 *   - `(category, occurred_at_ms)` index covers every time-windowed
 *     query the CLI exposes (sub-100ms/1M rows acceptance criterion).
 *   - Pending approval: `transitionPending` is a single UPDATE WHERE
 *     decision='prompted' — SQLite-atomic, so two racing approvals
 *     yield exactly one `rowsAffected === 1`; the loser refuses to
 *     fire the queued shell_exec twice.
 *   - Tail: libsql has no CDC; polling cursor over `occurred_at_ms`,
 *     exits on `signal.aborted`. Same posture as TraceReader.tail.
 */
import type { Client } from '@libsql/client';
/** Locked category enum. `pending_shell` is the only mutable category.
 *  `channel_inbound` (Patch B) is the inbound-routing counterpart of
 *  `channel_send` — outbound stays `channel_send`. */
export type AuditCategory = 'capability_gate' | 'webhook' | 'schedule' | 'resume' | 'channel_send' | 'channel_inbound' | 'pending_shell';
/** Locked decision enum. `prompted` + `approved` + `rejected` are reserved
 *  for the `pending_shell` state machine. */
export type AuditDecision = 'allowed' | 'denied' | 'prompted' | 'success' | 'error' | 'approved' | 'rejected';
export interface AuditEntry {
    occurredAtMs: number;
    category: AuditCategory;
    decision: AuditDecision;
    packId?: string;
    skill?: string;
    ruleId?: string;
    /** Category-specific payload. Sensitive values MUST be pre-hashed. */
    detail: Record<string, unknown>;
}
/** Read-back row — carries `id` so `approve/reject <id>` have a handle. */
export interface AuditRow extends AuditEntry {
    id: number;
}
export interface QueryOpts {
    sinceMs?: number;
    category?: AuditCategory;
    decision?: AuditDecision;
    /** Cap result set; default 100. `Number.POSITIVE_INFINITY` → no cap. */
    limit?: number;
}
export interface TailOpts {
    /** Cursor — only rows with `occurred_at_ms > sinceMs` are emitted. */
    sinceMs?: number;
    intervalMs?: number;
    signal?: AbortSignal;
    category?: AuditCategory;
}
export declare class AuditLog {
    private readonly db;
    private initialized;
    constructor(db: Client);
    /** Idempotent DDL — same posture as CheckpointStore.init (DURABLE.1). */
    init(): Promise<void>;
    /** Append one entry. `detail` is JSON-encoded as-is — producers pre-hash
     *  sensitive fields via `hashDetailValue` (the log doesn't know which). */
    append(entry: AuditEntry): Promise<void>;
    /** Time-windowed query. `idx_audit_occurred_category` covers category +
     *  sinceMs; decision is a post-index filter. Returns newest-first. */
    query(opts?: QueryOpts): Promise<AuditRow[]>;
    /** Live tail. Polling cursor over `occurred_at_ms`. Exits on
     *  `signal.aborted` — caller owns the AbortController so SIGINT cleans
     *  up cleanly (see audit.ts tail action). */
    tail(opts?: TailOpts): Promise<AsyncIterable<AuditRow>>;
    /** Atomic `prompted → approved|rejected` transition. Returns `true` on
     *  the single winning row (`rowsAffected === 1`); `false` when the row
     *  is already resolved (race loser) or doesn't exist. */
    transitionPending(id: number, to: 'approved' | 'rejected'): Promise<boolean>;
}
/** Hash a sensitive raw value for `detail` (SHA-256, first 16 hex chars).
 *  Use for: signing secrets, bearer tokens, URLs with query-string creds,
 *  any value that could leak PII downstream. Not invertible. */
export declare function hashDetailValue(raw: string): string;
//# sourceMappingURL=audit_log.d.ts.map