/**
 * Cognigate Redis Resource State Provider
 *
 * Implements distributed resource tracking using Redis.
 * Uses atomic Lua scripts for consistency under concurrent access.
 *
 * @packageDocumentation
 * @module @vorionsys/cognigate/resource-state-provider
 */
import type { Redis } from 'ioredis';
import type { ID } from '../common/types.js';
import type { ResourceLimits, ResourceUsage, ResourceStateProvider } from './types.js';
/**
 * Dependencies for RedisResourceStateProvider
 */
export interface RedisResourceStateProviderDependencies {
    /** Redis client instance */
    redis?: Redis;
}
/**
 * Redis-based resource state provider for distributed execution tracking.
 *
 * Uses Redis HASH structures for efficient storage and Lua scripts
 * for atomic operations that prevent race conditions.
 */
export declare class RedisResourceStateProvider implements ResourceStateProvider {
    private readonly redis;
    private readonly keyPrefix;
    constructor(deps?: RedisResourceStateProviderDependencies);
    /**
     * Build the Redis key for an execution
     */
    private buildKey;
    /**
     * Initialize execution tracking with limits and TTL
     */
    initExecution(executionId: ID, limits: ResourceLimits, ttlMs: number): Promise<void>;
    /**
     * Record memory usage sample, updating peak if higher
     */
    recordMemoryUsage(executionId: ID, memoryMb: number): Promise<void>;
    /**
     * Get peak memory usage for an execution
     */
    getPeakMemory(executionId: ID): Promise<number>;
    /**
     * Atomically increment CPU time and return new total
     */
    incrementCpuTime(executionId: ID, deltaMs: number): Promise<number>;
    /**
     * Get total CPU time for an execution
     */
    getCpuTimeMs(executionId: ID): Promise<number>;
    /**
     * Atomically increment network request count and check limit
     */
    incrementNetworkRequests(executionId: ID, limit: number): Promise<{
        allowed: boolean;
        current: number;
    }>;
    /**
     * Get current network request count
     */
    getNetworkRequestCount(executionId: ID): Promise<number>;
    /**
     * Atomically increment file system operation count and check limit
     */
    incrementFileSystemOps(executionId: ID, limit: number): Promise<{
        allowed: boolean;
        current: number;
    }>;
    /**
     * Get current file system operation count
     */
    getFileSystemOpCount(executionId: ID): Promise<number>;
    /**
     * Check if execution should be terminated based on resource limits
     */
    shouldTerminate(executionId: ID, limits: ResourceLimits): Promise<{
        terminate: boolean;
        reason?: string;
        violation?: string;
    }>;
    /**
     * Clean up execution tracking and return final usage metrics
     */
    cleanupExecution(executionId: ID): Promise<ResourceUsage>;
    /**
     * Get a snapshot of all resource metrics
     */
    getResourceSnapshot(executionId: ID): Promise<{
        memoryPeakMb: number;
        cpuTimeMs: number;
        networkRequests: number;
        fileSystemOps: number;
        wallTimeMs: number;
    }>;
}
/**
 * Create a Redis resource state provider instance
 */
export declare function createResourceStateProvider(deps?: RedisResourceStateProviderDependencies): ResourceStateProvider;
//# sourceMappingURL=resource-state-provider.d.ts.map