/**
 * EntityStore - Session-scoped Entity Cache
 *
 * Provides a deterministic cache for Frame and Session entities discovered
 * during analysis. This enables:
 * - Cache-first resolution for drill-down queries (no re-running discovery)
 * - Incremental analysis (track analyzed vs candidate entities)
 * - Stable entity data across turns (not dependent on findings.details)
 *
 * Design principles:
 * - Use string IDs to avoid >2^53 precision loss (frame tokens can be 64-bit)
 * - Snake_case canonical field names for consistency
 * - Track provenance (source: table/interval/finding/enrichment)
 * - Support serialization for session persistence
 */
/** String ID to avoid BigInt precision loss */
export type EntityId = string;
/** Supported entity types */
export type EntityType = 'frame' | 'session' | 'cpu_slice' | 'binder' | 'gc' | 'memory' | 'generic';
/**
 * Base entity interface - all entities share these fields
 */
export interface BaseEntity {
    /** Provenance tracking */
    source?: 'table' | 'interval' | 'finding' | 'enrichment';
    updated_at?: number;
}
/**
 * Frame entity - represents a single frame from scrolling/rendering analysis
 */
export interface FrameEntity extends BaseEntity {
    frame_id: EntityId;
    start_ts?: string;
    end_ts?: string;
    process_name?: string;
    session_id?: EntityId;
    jank_type?: string;
    dur_ms?: number | string;
    main_start_ts?: string;
    main_end_ts?: string;
    render_start_ts?: string;
    render_end_ts?: string;
    pid?: number | string;
    layer_name?: string;
    vsync_missed?: number | string;
    token_gap?: number | string;
    jank_responsibility?: string;
    frame_index?: number | string;
}
/**
 * Session entity - represents a scroll session
 */
export interface SessionEntity extends BaseEntity {
    session_id: EntityId;
    start_ts?: string;
    end_ts?: string;
    process_name?: string;
    frame_count?: number | string;
    jank_count?: number | string;
    max_vsync_missed?: number | string;
    jank_types?: string;
}
/**
 * CPU slice entity - represents a CPU scheduling slice
 */
export interface CpuSliceEntity extends BaseEntity {
    slice_id: EntityId;
    start_ts?: string;
    end_ts?: string;
    dur_ns?: number | string;
    cpu?: number | string;
    tid?: number | string;
    pid?: number | string;
    process_name?: string;
    thread_name?: string;
    state?: string;
    priority?: number | string;
    utid?: number | string;
}
/**
 * Binder entity - represents a Binder/IPC transaction
 */
export interface BinderEntity extends BaseEntity {
    transaction_id: EntityId;
    start_ts?: string;
    end_ts?: string;
    dur_ns?: number | string;
    client_pid?: number | string;
    client_tid?: number | string;
    client_process?: string;
    client_thread?: string;
    server_pid?: number | string;
    server_tid?: number | string;
    server_process?: string;
    server_thread?: string;
    reply_ts?: string;
    code?: number | string;
    flags?: number | string;
    is_oneway?: boolean;
    is_reply?: boolean;
}
/**
 * GC entity - represents a garbage collection event
 */
export interface GcEntity extends BaseEntity {
    gc_id: EntityId;
    start_ts?: string;
    end_ts?: string;
    dur_ns?: number | string;
    pid?: number | string;
    process_name?: string;
    gc_type?: string;
    gc_reason?: string;
    freed_bytes?: number | string;
    freed_objects?: number | string;
    pause_time_ns?: number | string;
    is_blocking?: boolean;
}
/**
 * Memory entity - represents a memory allocation or event
 */
export interface MemoryEntity extends BaseEntity {
    memory_id: EntityId;
    ts?: string;
    pid?: number | string;
    process_name?: string;
    event_type?: string;
    size_bytes?: number | string;
    address?: string;
    heap_name?: string;
    oom_score?: number | string;
    rss_bytes?: number | string;
    anon_bytes?: number | string;
    swap_bytes?: number | string;
}
/**
 * Generic entity - extensible type for any other entity kind
 */
export interface GenericEntity extends BaseEntity {
    entity_id: EntityId;
    entity_type: string;
    start_ts?: string;
    end_ts?: string;
    process_name?: string;
    pid?: number | string;
    tid?: number | string;
    /** Arbitrary additional data */
    data?: Record<string, any>;
}
/**
 * Union type for all entity types
 */
export type AnyEntity = FrameEntity | SessionEntity | CpuSliceEntity | BinderEntity | GcEntity | MemoryEntity | GenericEntity;
/**
 * Serializable snapshot for persistence
 */
export interface EntityStoreSnapshot {
    version: number;
    framesById: Array<[EntityId, FrameEntity]>;
    sessionsById: Array<[EntityId, SessionEntity]>;
    cpuSlicesById?: Array<[EntityId, CpuSliceEntity]>;
    bindersById?: Array<[EntityId, BinderEntity]>;
    gcsById?: Array<[EntityId, GcEntity]>;
    memoriesById?: Array<[EntityId, MemoryEntity]>;
    genericsById?: Array<[EntityId, GenericEntity]>;
    analyzedFrameIds: EntityId[];
    analyzedSessionIds: EntityId[];
    lastCandidateFrameIds: EntityId[];
    lastCandidateSessionIds: EntityId[];
    analyzedEntityIds?: Record<string, EntityId[]>;
}
export declare class EntityStore {
    private framesById;
    private sessionsById;
    private cpuSlicesById;
    private bindersById;
    private gcsById;
    private memoriesById;
    private genericsById;
    private static readonly ANALYZED_SET_CAP;
    private analyzedFrameIds;
    private analyzedSessionIds;
    private lastCandidateFrameIds;
    private lastCandidateSessionIds;
    private analyzedEntityIds;
    private enforceCapLRU;
    /**
     * Upsert a frame entity. Merges with existing if present.
     * Newer data (by updated_at) wins for non-null fields.
     */
    upsertFrame(entity: FrameEntity): void;
    /**
     * Get a frame entity by ID.
     * Tries both original ID and normalized string version.
     */
    getFrame(id: EntityId | number): FrameEntity | undefined;
    /**
     * Get all frame entities.
     */
    getAllFrames(): FrameEntity[];
    /**
     * Mark a frame as analyzed (for extend support).
     */
    markFrameAnalyzed(id: EntityId | number): void;
    /**
     * Check if a frame was already analyzed in a previous drill-down.
     */
    wasFrameAnalyzed(id: EntityId | number): boolean;
    /**
     * Get all analyzed frame IDs.
     * Used by IncrementalAnalyzer to build PreviousAnalysisState.
     */
    getAnalyzedFrameIds(): EntityId[];
    /**
     * Set the candidate frame list from last discovery stage.
     * Used by extend to know which frames can be analyzed next.
     */
    setLastCandidateFrames(ids: Array<EntityId | number>): void;
    /**
     * Get candidate frames that haven't been analyzed yet.
     */
    getUnanalyzedCandidateFrames(): EntityId[];
    /**
     * Get all candidate frame IDs from last discovery.
     */
    getLastCandidateFrames(): EntityId[];
    /**
     * Upsert a session entity. Merges with existing if present.
     */
    upsertSession(entity: SessionEntity): void;
    /**
     * Get a session entity by ID.
     */
    getSession(id: EntityId | number): SessionEntity | undefined;
    /**
     * Get all session entities.
     */
    getAllSessions(): SessionEntity[];
    /**
     * Mark a session as analyzed.
     */
    markSessionAnalyzed(id: EntityId | number): void;
    /**
     * Check if a session was already analyzed.
     */
    wasSessionAnalyzed(id: EntityId | number): boolean;
    /**
     * Get all analyzed session IDs.
     * Used by IncrementalAnalyzer to build PreviousAnalysisState.
     */
    getAnalyzedSessionIds(): EntityId[];
    /**
     * Set the candidate session list from last discovery stage.
     */
    setLastCandidateSessions(ids: Array<EntityId | number>): void;
    /**
     * Get candidate sessions that haven't been analyzed yet.
     */
    getUnanalyzedCandidateSessions(): EntityId[];
    /**
     * Get all candidate session IDs from last discovery.
     */
    getLastCandidateSessions(): EntityId[];
    /**
     * Upsert a CPU slice entity.
     */
    upsertCpuSlice(entity: CpuSliceEntity): void;
    getCpuSlice(id: EntityId | number): CpuSliceEntity | undefined;
    getAllCpuSlices(): CpuSliceEntity[];
    /**
     * Upsert a Binder transaction entity.
     */
    upsertBinder(entity: BinderEntity): void;
    getBinder(id: EntityId | number): BinderEntity | undefined;
    getAllBinders(): BinderEntity[];
    /**
     * Upsert a GC event entity.
     */
    upsertGc(entity: GcEntity): void;
    getGc(id: EntityId | number): GcEntity | undefined;
    getAllGcs(): GcEntity[];
    /**
     * Upsert a memory event entity.
     */
    upsertMemory(entity: MemoryEntity): void;
    getMemory(id: EntityId | number): MemoryEntity | undefined;
    getAllMemories(): MemoryEntity[];
    /**
     * Upsert a generic entity (extensible for any entity type).
     */
    upsertGeneric(entity: GenericEntity): void;
    getGeneric(id: EntityId | number): GenericEntity | undefined;
    getAllGenerics(): GenericEntity[];
    /**
     * Get all generic entities of a specific type.
     */
    getGenericsByType(entityType: string): GenericEntity[];
    /**
     * Mark any entity type as analyzed.
     * @param entityType - The type of entity (e.g., 'cpu_slice', 'binder')
     * @param id - The entity ID
     */
    markEntityAnalyzed(entityType: string, id: EntityId | number): void;
    /**
     * Check if any entity type was analyzed.
     */
    wasEntityAnalyzed(entityType: string, id: EntityId | number): boolean;
    /**
     * Get all analyzed entity IDs for a type.
     */
    getAnalyzedEntityIds(entityType: string): EntityId[];
    /**
     * Upsert multiple frames at once.
     */
    upsertFrames(entities: FrameEntity[]): void;
    /**
     * Upsert multiple sessions at once.
     */
    upsertSessions(entities: SessionEntity[]): void;
    /**
     * Upsert multiple CPU slices at once.
     */
    upsertCpuSlices(entities: CpuSliceEntity[]): void;
    /**
     * Upsert multiple Binder transactions at once.
     */
    upsertBinders(entities: BinderEntity[]): void;
    /**
     * Upsert multiple GC events at once.
     */
    upsertGcs(entities: GcEntity[]): void;
    /**
     * Upsert multiple memory events at once.
     */
    upsertMemories(entities: MemoryEntity[]): void;
    /**
     * Upsert multiple generic entities at once.
     */
    upsertGenerics(entities: GenericEntity[]): void;
    /**
     * Get store statistics for debugging/logging.
     */
    getStats(): {
        frameCount: number;
        sessionCount: number;
        cpuSliceCount: number;
        binderCount: number;
        gcCount: number;
        memoryCount: number;
        genericCount: number;
        analyzedFrameCount: number;
        analyzedSessionCount: number;
        candidateFrameCount: number;
        candidateSessionCount: number;
        totalEntityCount: number;
    };
    /**
     * Serialize to a JSON-safe snapshot for persistence.
     */
    serialize(): EntityStoreSnapshot;
    /**
     * Deserialize from a snapshot.
     */
    static deserialize(snapshot: EntityStoreSnapshot): EntityStore;
    /**
     * Clear all data (for testing or reset).
     */
    clear(): void;
}
/**
 * Create a new EntityStore instance.
 */
export declare function createEntityStore(): EntityStore;
//# sourceMappingURL=entityStore.d.ts.map