/**
 * Chain of Trust Service
 *
 * Tracks and manages trust chains for nested A2A calls.
 * Implements trust inheritance policies and chain validation.
 *
 * @packageDocumentation
 */
import { type ChainContext, type ChainLink, type TrustInheritanceMode, type A2AAttestationData } from './types.js';
/**
 * Active chain tracking
 */
export interface ActiveChain {
    /** Root request ID */
    rootRequestId: string;
    /** Chain links */
    links: ChainLink[];
    /** Trust inheritance mode */
    inheritanceMode: TrustInheritanceMode;
    /** Current effective trust tier */
    effectiveTier: number;
    /** Current effective trust score */
    effectiveScore: number;
    /** Started timestamp */
    startedAt: Date;
    /** Last activity */
    lastActivityAt: Date;
    /** Chain state */
    state: 'active' | 'completed' | 'failed' | 'expired';
    /** Attestation data collected */
    attestations: A2AAttestationData[];
}
/**
 * Chain validation result
 */
export interface ChainValidationResult {
    valid: boolean;
    effectiveTier: number;
    effectiveScore: number;
    warnings: string[];
    violations: ChainViolation[];
}
/**
 * Chain violation
 */
export interface ChainViolation {
    type: 'depth_exceeded' | 'trust_drop' | 'loop_detected' | 'stale_chain' | 'invalid_link';
    message: string;
    linkIndex?: number;
}
/**
 * Chain statistics
 */
export interface ChainStats {
    totalChains: number;
    activeChains: number;
    completedChains: number;
    failedChains: number;
    avgChainDepth: number;
    avgChainDuration: number;
    loopDetections: number;
    depthViolations: number;
}
export declare class ChainOfTrustService {
    private activeChains;
    private stats;
    private defaultInheritanceMode;
    constructor(inheritanceMode?: TrustInheritanceMode);
    /**
     * Start a new chain
     */
    startChain(rootRequestId: string, initiator: ChainLink, inheritanceMode?: TrustInheritanceMode): ActiveChain;
    /**
     * Add a link to an existing chain
     */
    addLink(rootRequestId: string, link: ChainLink): ChainValidationResult;
    /**
     * Complete a chain
     */
    completeChain(rootRequestId: string, attestation: A2AAttestationData): void;
    /**
     * Fail a chain
     */
    failChain(rootRequestId: string, reason: string): void;
    /**
     * Get active chain
     */
    getChain(rootRequestId: string): ActiveChain | undefined;
    /**
     * Build chain context from active chain
     */
    buildContext(rootRequestId: string): ChainContext | null;
    /**
     * Validate a new link
     */
    private validateLink;
    /**
     * Validate a complete chain context
     */
    validateChainContext(context: ChainContext): ChainValidationResult;
    /**
     * Calculate effective trust from chain
     */
    calculateEffectiveTrust(links: ChainLink[], mode: TrustInheritanceMode): {
        tier: number;
        score: number;
    };
    /**
     * Get minimum tier required for an action given a chain
     */
    getMinimumTierForAction(chain: ChainLink[], actionMinTier: number, mode?: TrustInheritanceMode): number;
    /**
     * Generate chain visualization for debugging
     */
    visualizeChain(rootRequestId: string): string;
    /**
     * Export chain for analysis
     */
    exportChain(rootRequestId: string): {
        chain: ActiveChain | null;
        visualization: string;
        validation: ChainValidationResult | null;
    };
    /**
     * Update rolling averages
     */
    private updateAverages;
    /**
     * Get statistics
     */
    getStats(): ChainStats;
    /**
     * Get all active chains (for monitoring)
     */
    getActiveChains(): ActiveChain[];
    /**
     * Cleanup expired chains
     */
    cleanupExpiredChains(maxAgeMs?: number): number;
}
export declare function createChainOfTrustService(inheritanceMode?: TrustInheritanceMode): ChainOfTrustService;
export declare function getChainOfTrustService(): ChainOfTrustService;
//# sourceMappingURL=chain-of-trust.d.ts.map