/**
 * Permission override + audit persistence helpers for CLI.4.
 *
 * Split out of `permissions.ts` (file-size budget). Four concerns:
 *
 *   1. `readOverridesFile` / `writeOverridesFile` — load + atomically rewrite
 *      `~/.opensquid/permission_overrides.yaml`. Schema:
 *
 *        overrides:
 *          - pack: ci
 *            capability: shell_exec
 *            target: "pnpm test"
 *            granted_at: "2026-05-20T12:00:00.000Z"
 *
 *      Atomic write via `tmp + rename` matches the webhooks.yaml +
 *      schedules.yaml + trigger_state.yaml pattern.
 *
 *   2. `appendAuditEntry` / `readAuditEntries` — `~/.opensquid/
 *      permission_audit.jsonl`. CLI.4 ships the FILE-based audit-log
 *      surface; CLI.5 replaces this with the libsql `audit_log` table
 *      under the unified `category: capability_gate` row. The on-disk
 *      shape here is deliberately a subset of the CLI.5 column set so
 *      the migration is `INSERT INTO audit_log SELECT ...` and not a
 *      schema change.
 *
 *   3. `enumerateManifests` — walk `~/.opensquid/packs/<id>/manifest.yaml`
 *      and parse each through the `Manifest` schema (NOT through
 *      `loadPack`, which discards `manifest.permissions`). Returns the
 *      validated manifests so `permissions list` can render per-pack
 *      declared capabilities + their user overrides side-by-side.
 *
 *   4. `denylistRejectionFor` — central guard used by `grant`. Returns
 *      the human-readable rejection message if a `(capability, target)`
 *      pair would be blocked by the sealed built-in denylist; null if
 *      safe to persist. Honors `OPENSQUID_TRUST_BUILTIN_DENY=0` escape
 *      flag for parity with the gate.
 *
 * The override file is read by the daemon at gate-construction time
 * (wired via `CapabilityGateOpts.overrides`); the CLI is the
 * authoritative writer. We intentionally do NOT mutate pack manifests
 * — overrides are user-side state, separate from pack identity.
 *
 * Imports from: node:fs/promises, yaml, ../../packs/schemas/index,
 *   ../../packs/yaml, ../../runtime/builtin_denylist,
 *   ../../runtime/capability_gate, ../../runtime/paths.
 * Imported by: src/setup/cli/permissions.ts +
 *   src/setup/cli/permissions_actions.ts.
 */
import { type Capability, type ManifestType } from '../../packs/schemas/index.js';
import type { UserOverride } from '../../runtime/capability_gate.js';
/** One row in `permission_overrides.yaml`. */
export interface OverrideRecord {
    pack: string;
    capability: Capability;
    target: string;
    granted_at: string;
}
/** One row in `permission_audit.jsonl`. Mirrors the CLI.5 audit_log columns. */
export interface AuditEntry {
    occurred_at_ms: number;
    category: 'capability_gate';
    decision: 'allowed' | 'denied' | 'prompted';
    pack: string;
    capability: Capability;
    target: string;
    source: 'declared' | 'user_approved' | 'user_override' | 'denied' | 'denylist';
    message?: string;
}
export declare const defaultOverridesPath: () => string;
export declare const defaultAuditPath: () => string;
export declare const defaultPacksDir: () => string;
export declare function readOverridesFile(path: string): Promise<OverrideRecord[]>;
/**
 * Atomic write — delegates to `writeKeyedYamlList` (T-SIC L9 byte-preserves
 * the `overrides: []\n` empty form). Callers MUST pass the FULL desired
 * override set; we never merge here to avoid dropping unrelated overrides
 * on concurrent CLI invocations.
 */
export declare function writeOverridesFile(path: string, overrides: readonly OverrideRecord[]): Promise<void>;
/** Convert persisted `OverrideRecord[]` into the runtime `UserOverride[]`
 *  shape consumed by `CapabilityGateOpts.overrides`. The `granted_at`
 *  stamp is for human audit; the gate doesn't need it. */
export declare function toRuntimeOverrides(records: readonly OverrideRecord[]): UserOverride[];
export declare function appendAuditEntry(path: string, entry: AuditEntry): Promise<void>;
export declare function readAuditEntries(path: string): Promise<AuditEntry[]>;
export interface ManifestRow {
    packId: string;
    manifest: ManifestType;
}
export declare function enumerateManifests(packsDir: string): Promise<ManifestRow[]>;
export interface DenylistRejection {
    message: string;
}
export declare function denylistRejectionFor(capability: Capability, target: string, opts?: {
    homeDir?: string;
    env?: NodeJS.ProcessEnv;
}): DenylistRejection | null;
//# sourceMappingURL=permissions_state.d.ts.map