/**
 * Unified Audit Chain Emitter.
 *
 * Many cluster surfaces emit their own event types (OverrideEvent from W1.9,
 * PackVersionEvent from W1.4, SelfRegistrationEvent from W2.2, etc). This
 * helper normalises them into a single AuditChainEntry shape and hash-chains
 * the entries so downstream verifiers can detect tampering.
 *
 * Chain invariant:
 *   - Each entry carries `prevHash` (SHA-256 of the prior canonical entry).
 *   - Each entry carries `selfHash` (SHA-256 of the current canonical entry
 *     WITHOUT the selfHash field).
 *   - Verifier walks the chain head-to-tail and checks both fields.
 *
 * Pure helper — no IO. Storage / fan-out is the caller's job (Postgres
 * append, OTLP emit, S3 archive, etc.). This keeps the audit-chain logic
 * unit-testable and free of side effects.
 *
 * @connexum/ai-governance  Audit chain unification (tamper-evident integrity)
 */
import type { OverrideEvent } from './pack-inheritance.js';
import type { PackVersionEvent } from './pack-versioning.js';
import type { SelfRegistrationEvent } from './self-registration-hook.js';
/**
 * Canonical AuditChainEntry. Every source event maps to this shape before
 * being appended.
 */
export interface AuditChainEntry {
    /** Monotonic chain index (0 for genesis, +1 per append). */
    seq: number;
    /** ISO 8601 entry timestamp. */
    at: string;
    /** Source event class. */
    source: 'OVERRIDE' | 'PACK_VERSION' | 'AGENT_REGISTERED' | 'AGENT_TOOL_OBSERVED' | 'APPROVAL_NOTIFICATION' | 'COMPLIANCE_AGENT_SPAWNED' | 'COMPLIANCE_AGENT_REGISTERED' | 'COMPLIANCE_AGENT_HEARTBEAT' | 'DATA_MANIFEST_CREATED' | 'DATA_MANIFEST_ACTIVATED' | 'DATA_MANIFEST_REVOKED' | 'AGENT_DATA_READ' | 'COMPLIANCE_AGENT_REPORT_EMITTED' | 'CIRCUIT_BREAKER_TRIPPED' | 'CIRCUIT_BREAKER_ADVISORY' | 'GENERIC';
    /** Stable id of the source event when known. */
    sourceId?: string;
    /** Tenant scope. */
    orgId: string;
    /** Agent scope when applicable. */
    agentId?: string;
    /** Actor (employee / system) that produced the event. */
    actor?: string;
    /** Verbatim source-event payload. */
    data: Record<string, unknown>;
    /** SHA-256 base64url of the previous entry's selfHash (or 'GENESIS'). */
    prevHash: string;
    /** SHA-256 base64url of this entry's canonical bytes (computed at append time). */
    selfHash: string;
}
/** Adapters that normalise source events into the chain-entry shape. */
export declare function fromOverrideEvent(ev: OverrideEvent): Omit<AuditChainEntry, 'seq' | 'prevHash' | 'selfHash'>;
export declare function fromPackVersionEvent(ev: PackVersionEvent, orgId: string): Omit<AuditChainEntry, 'seq' | 'prevHash' | 'selfHash'>;
export declare function fromSelfRegistrationEvent(ev: SelfRegistrationEvent): Omit<AuditChainEntry, 'seq' | 'prevHash' | 'selfHash'>;
export interface ApprovalNotificationAuditInput {
    ticketId: string;
    orgId: string;
    agentId?: string;
    recipientId: string;
    channel: 'dashboard' | 'email' | 'sms';
    delivered: boolean;
    providerMessageId?: string;
    error?: string;
    at: string;
}
export declare function fromApprovalNotification(ev: ApprovalNotificationAuditInput): Omit<AuditChainEntry, 'seq' | 'prevHash' | 'selfHash'>;
export interface CircuitBreakerTripEvent {
    agentId: string;
    orgId: string;
    /** 'tripped' = breaker OPEN blocked a tool call; 'advisory' = infra fail-open. */
    kind: 'tripped' | 'advisory';
    reason: string;
    at: string;
}
export declare function fromCircuitBreakerEvent(ev: CircuitBreakerTripEvent): Omit<AuditChainEntry, 'seq' | 'prevHash' | 'selfHash'>;
/**
 * Append-only in-process audit chain. Persistence is the caller's job —
 * subscribe to onAppend and forward to Postgres / OTLP / S3 / etc.
 */
export declare class AuditChainEmitter {
    private readonly entries;
    private readonly onAppend;
    constructor(options?: {
        onAppend?: (entry: AuditChainEntry) => void;
    });
    append(prepared: Omit<AuditChainEntry, 'seq' | 'prevHash' | 'selfHash'>): AuditChainEntry;
    /** Read-only view of the chain. */
    list(): AuditChainEntry[];
    /** Look up by sequence number. */
    get(seq: number): AuditChainEntry | undefined;
    /** Length of the chain. */
    size(): number;
}
export type ChainVerifyError = {
    code: 'OK';
} | {
    code: 'PREV_HASH_MISMATCH';
    seq: number;
} | {
    code: 'SELF_HASH_MISMATCH';
    seq: number;
} | {
    code: 'OUT_OF_ORDER_SEQ';
    seq: number;
    expected: number;
};
/**
 * Verify chain integrity head-to-tail. Returns OK or the first failure.
 * Safe to call against an externally-supplied list (e.g. after persistence
 * round-trip).
 */
export declare function verifyAuditChain(entries: ReadonlyArray<AuditChainEntry>): ChainVerifyError;
//# sourceMappingURL=audit-chain-emitter.d.ts.map