/**
 * Audit Chain Service
 *
 * Provides immutable, hash-chained audit records for compliance.
 * Supports cryptographic signing and tamper detection.
 *
 * @packageDocumentation
 */
export type AuditEntityType = 'agent' | 'attestation' | 'trust' | 'a2a' | 'sandbox' | 'config';
export type AuditAction = 'create' | 'update' | 'delete' | 'activate' | 'suspend' | 'revoke' | 'tier_change' | 'approval' | 'invoke' | 'complete' | 'violation';
export interface AuditRecord {
    /** Unique record ID */
    id: string;
    /** Tenant ID for multi-tenancy */
    tenantId: string;
    /** Entity type being audited */
    entityType: AuditEntityType;
    /** Entity identifier */
    entityId: string;
    /** Action performed */
    action: AuditAction;
    /** Actor (user or agent ACI) */
    actor: string;
    /** Previous record hash (chain link) */
    previousHash: string;
    /** SHA-256 hash of payload */
    dataHash: string;
    /** Audit payload */
    payload: Record<string, unknown>;
    /** Record timestamp */
    timestamp: string;
    /** Ed25519 signature (optional) */
    signature?: string;
    /** Sequence number for ordering */
    sequence: number;
}
export interface AuditQuery {
    /** Filter by tenant */
    tenantId?: string;
    /** Filter by entity type */
    entityType?: AuditEntityType;
    /** Filter by entity ID */
    entityId?: string;
    /** Filter by action */
    action?: AuditAction;
    /** Filter by actor */
    actor?: string;
    /** Start timestamp */
    startTime?: string;
    /** End timestamp */
    endTime?: string;
    /** Limit results */
    limit?: number;
    /** Offset for pagination */
    offset?: number;
}
export interface ChainVerificationResult {
    /** Chain is valid */
    valid: boolean;
    /** Number of records verified */
    recordCount: number;
    /** First broken link (if any) */
    brokenAt?: number;
    /** Error message */
    error?: string;
}
export interface AuditStats {
    /** Total records */
    totalRecords: number;
    /** Records by entity type */
    byEntityType: Record<AuditEntityType, number>;
    /** Records by action */
    byAction: Record<AuditAction, number>;
    /** Chain head hash */
    headHash: string;
    /** Chain head sequence */
    headSequence: number;
}
export interface AuditStorage {
    append(record: AuditRecord): Promise<void>;
    getLatest(tenantId: string): Promise<AuditRecord | null>;
    query(query: AuditQuery): Promise<AuditRecord[]>;
    getBySequenceRange(tenantId: string, start: number, end: number): Promise<AuditRecord[]>;
    getStats(tenantId: string): Promise<AuditStats>;
}
export interface AuditChainConfig {
    /** Storage backend */
    storage: AuditStorage;
    /** Private key for signing (PEM format) */
    privateKey?: string;
    /** Public key for verification (PEM format) */
    publicKey?: string;
    /** Enable signing */
    signRecords?: boolean;
}
export declare class AuditChainService {
    private storage;
    private privateKey?;
    private publicKey?;
    private signRecords;
    private sequenceCache;
    constructor(config: AuditChainConfig);
    /**
     * Append a new audit record to the chain
     */
    append(tenantId: string, entityType: AuditEntityType, entityId: string, action: AuditAction, actor: string, payload: Record<string, unknown>): Promise<AuditRecord>;
    /**
     * Append multiple records atomically
     */
    appendBatch(records: Array<{
        tenantId: string;
        entityType: AuditEntityType;
        entityId: string;
        action: AuditAction;
        actor: string;
        payload: Record<string, unknown>;
    }>): Promise<AuditRecord[]>;
    /**
     * Verify the integrity of the audit chain
     */
    verifyChain(tenantId: string, startSequence?: number, endSequence?: number): Promise<ChainVerificationResult>;
    /**
     * Verify a single record's integrity
     */
    verifyRecord(record: AuditRecord): boolean;
    /**
     * Query audit records
     */
    query(query: AuditQuery): Promise<AuditRecord[]>;
    /**
     * Get audit history for an entity
     */
    getEntityHistory(tenantId: string, entityType: AuditEntityType, entityId: string, limit?: number): Promise<AuditRecord[]>;
    /**
     * Get recent activity for a tenant
     */
    getRecentActivity(tenantId: string, limit?: number): Promise<AuditRecord[]>;
    /**
     * Get chain statistics
     */
    getStats(tenantId: string): Promise<AuditStats>;
    /**
     * Compute SHA-256 hash of payload
     */
    private computeHash;
    /**
     * Sign a record using Ed25519
     */
    private signRecord;
    /**
     * Verify record signature
     */
    private verifySignature;
    /**
     * Get data to sign (deterministic ordering)
     */
    private getSignableData;
}
export declare class InMemoryAuditStorage implements AuditStorage {
    private records;
    append(record: AuditRecord): Promise<void>;
    getLatest(tenantId: string): Promise<AuditRecord | null>;
    query(query: AuditQuery): Promise<AuditRecord[]>;
    getBySequenceRange(tenantId: string, start: number, end: number): Promise<AuditRecord[]>;
    getStats(tenantId: string): Promise<AuditStats>;
}
export declare function createAuditChainService(config: AuditChainConfig): AuditChainService;
export declare function getAuditChainService(): AuditChainService;
//# sourceMappingURL=audit.d.ts.map