🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
🔖 Checkpoint: Edit /workspaces/claude-code-flow/src/verification/types.ts
rUv24334b8a7338
diff --git a/.claude/checkpoints/1754966591.json b/.claude/checkpoints/1754966591.jsonnew file mode 100644index 0000000000..0787b90013--- /dev/null+++ b/.claude/checkpoints/1754966591.json@@ -0,0 +1 @@+{"branch": "checkpoint/pre-edit-20250812-024311", "file": "/workspaces/claude-code-flow/jest.config.js", "timestamp": "2025-08-12T02:43:11Z", "type": "pre-edit", "original_branch": "alpha-89"}diff --git a/.claude/checkpoints/1754966593.json b/.claude/checkpoints/1754966593.jsonnew file mode 100644index 0000000000..31bec20982--- /dev/null+++ b/.claude/checkpoints/1754966593.json@@ -0,0 +1 @@+{"tag": "checkpoint-20250812-024313", "file": "/workspaces/claude-code-flow/jest.config.js", "timestamp": "2025-08-12T02:43:13Z", "type": "post-edit", "branch": "alpha-89", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/system-metrics.json | 208 ++++++++++++++++++++++++++++--- .claude-flow/metrics/task-metrics.json | 6 +- .claude/checkpoints/1754966588.json | 1 + .claude/checkpoints/1754966589.json | 1 + jest.config.js | 6 + 6 files changed, 206 insertions(+), 18 deletions(-) "}diff --git a/src/verification/types.ts b/src/verification/types.tsindex dbf23123e8..e413f46d2b 100644--- a/src/verification/types.ts+++ b/src/verification/types.ts@@ -1,349 +1,1099 @@/**- * Type definitions for Security Enforcement System+ * Verification Engine Types and Interfaces+ * Comprehensive type definitions for the verification system*/-export interface SecurityConfig {- totalNodes: number;+import type { AgentId, TaskId, SwarmId, TaskResult, AgentState } from '../swarm/types.js';++// ===== CORE VERIFICATION TYPES =====++export type VerificationLevel = 'basic' | 'standard' | 'strict' | 'critical';+export type VerificationStatus = 'pending' | 'running' | 'passed' | 'failed' | 'error' | 'cancelled';+export type CheckpointType = 'pre_execution' | 'mid_execution' | 'post_execution' | 'rollback_point';+export type ClaimType = 'task_completion' | 'quality_metric' | 'performance_benchmark' | 'system_state' | 'agent_capability';++// ===== TRUTH SCORING =====++export interface TruthScoreConfig {+ /** Minimum threshold for truth score (0-1, default: 0.95) */threshold: number;- rateLimits: {- perSecond: number;- perMinute: number;- perHour: number;- perDay: number;- };- byzantineTolerance: {- suspicionThreshold: number;- consensusThreshold: number;- heartbeatInterval: number;- };- cryptography: {- keySize: number;- algorithm: string;- hashAlgorithm: string;- };-}--export interface ThreatLevel {- level: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';+ /** Weighted factors for scoring */+ weights: TruthScoringWeights;+ /** Enable/disable specific validation checks */+ checks: TruthValidationChecks;+ /** Confidence intervals for statistical validation */+ confidence: ConfidenceConfig;+}++export interface TruthScoringWeights {+ /** Weight for agent reliability history (0-1) */+ agentReliability: number;+ /** Weight for cross-validation results (0-1) */+ crossValidation: number;+ /** Weight for external verification (0-1) */+ externalVerification: number;+ /** Weight for consistency with known facts (0-1) */+ factualConsistency: number;+ /** Weight for logical coherence (0-1) */+ logicalCoherence: number;+}++export interface TruthValidationChecks {+ /** Validate against agent performance history */+ historicalValidation: boolean;+ /** Cross-check with multiple agents */+ crossAgentValidation: boolean;+ /** Verify against external sources */+ externalValidation: boolean;+ /** Check for logical consistency */+ logicalValidation: boolean;+ /** Validate statistical claims */+ statisticalValidation: boolean;+}++export interface ConfidenceConfig {+ /** Confidence level for statistical tests (e.g., 0.95 for 95%) */+ level: number;+ /** Sample size requirements */+ minSampleSize: number;+ /** Maximum acceptable error margin */+ maxErrorMargin: number;+}++export interface TruthScore {+ /** Overall truth score (0-1) */score: number;- indicators: string[];- mitigationActions: string[];+ /** Individual component scores */+ components: TruthScoreComponents;+ /** Confidence intervals */+ confidence: ConfidenceInterval;+ /** Evidence supporting the score */+ evidence: TruthEvidence[];+ /** Computed timestamp */+ timestamp: Date;+ /** Validation metadata */+ metadata: Record<string, unknown>;}-export interface SecurityEvent {- eventId: string;+export interface TruthScoreComponents {+ agentReliability: number;+ crossValidation: number;+ externalVerification: number;+ factualConsistency: number;+ logicalCoherence: number;+ overall: number;+}++export interface ConfidenceInterval {+ lower: number;+ upper: number;+ level: number;+}++export interface TruthEvidence {+ type: 'agent_history' | 'cross_validation' | 'external_source' | 'logical_proof' | 'statistical_test';+ source: string;+ weight: number;+ score: number;+ details: Record<string, unknown>;timestamp: Date;- type: 'AUTHENTICATION' | 'AUTHORIZATION' | 'BYZANTINE' | 'RATE_LIMIT' | 'CRYPTOGRAPHIC';- severity: 'INFO' | 'WARNING' | 'ERROR' | 'CRITICAL';- agentId: string;- details: any;- resolved: boolean;-}--export interface ComplianceReport {- reportId: string;- generatedAt: Date;- period: { from: Date; to: Date };- totalTransactions: number;- securityEvents: SecurityEvent[];- auditTrailIntegrity: boolean;- complianceScore: number;- recommendations: string[];}-export interface AttackPattern {- patternId: string;+// ===== VERIFICATION PIPELINE =====++export interface VerificationPipelineConfig {+ /** Pipeline identification */+ id: string;name: string;description: string;- indicators: string[];- severity: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';- mitigation: string[];- frequency: number;++ /** Pipeline configuration */+ level: VerificationLevel;+ checkpoints: VerificationCheckpoint[];+ truthScoreConfig: TruthScoreConfig;++ /** Execution settings */+ parallel: boolean;+ timeout: number;+ retryAttempts: number;++ /** Rollback settings */+ enableRollback: boolean;+ snapshotInterval: number;+ maxSnapshots: number;++ /** Reporting settings */+ reportLevel: 'minimal' | 'standard' | 'detailed' | 'comprehensive';+ notifications: NotificationConfig[];}-export interface AgentBehaviorProfile {- agentId: string;- profileCreated: Date;- lastUpdated: Date;- requestPatterns: {- averageRequestsPerMinute: number;- peakRequestTimes: Date[];- requestTypes: Map<string, number>;- };- behaviorScore: number;- anomalies: string[];- trustLevel: number;-}--export interface ConsensusState {- roundId: string;- proposalId: string;- participants: string[];- votes: Map<string, boolean>;- consensusReached: boolean;- result: boolean | null;- byzantineNodes: string[];- timestamp: Date;+export interface VerificationCheckpoint {+ /** Checkpoint identification */+ id: string;+ name: string;+ type: CheckpointType;++ /** Execution configuration */+ mandatory: boolean;+ order: number;+ dependencies: string[];++ /** Validation rules */+ validators: CheckpointValidator[];+ conditions: CheckpointCondition[];++ /** Execution settings */+ timeout: number;+ retryAttempts: number;++ /** Rollback configuration */+ createSnapshot: boolean;+ rollbackOnFailure: boolean;+}++export interface CheckpointValidator {+ id: string;+ type: 'truth_score' | 'agent_claim' | 'integration_test' | 'state_validation' | 'custom';+ config: Record<string, unknown>;+ weight: number;+ required: boolean;+}++export interface CheckpointCondition {+ field: string;+ operator: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin' | 'regex' | 'custom';+ value: unknown;+ description: string;+}++export interface NotificationConfig {+ type: 'email' | 'webhook' | 'slack' | 'teams' | 'custom';+ endpoint: string;+ conditions: string[];+ template: string;}-export interface ZKProofChallenge {- challengeId: string;- challenger: string;- challenged: string;- proofType: 'KNOWLEDGE' | 'RANGE' | 'MEMBERSHIP' | 'STATEMENT';- challenge: string;+export interface VerificationResult {+ /** Result identification */+ id: string;+ pipelineId: string;timestamp: Date;- expiresAt: Date;++ /** Overall result */+ status: VerificationStatus;+ score: number;+ passed: boolean;++ /** Detailed results */+ checkpointResults: CheckpointResult[];+ truthScore: TruthScore;++ /** Performance metrics */+ duration: number;+ resourceUsage: ResourceUsage;++ /** Evidence and artifacts */+ evidence: VerificationEvidence[];+ artifacts: Record<string, unknown>;++ /** Error information */+ errors: VerificationError[];+ warnings: VerificationWarning[];++ /** Recommendations */+ recommendations: string[];+ nextSteps: string[];+}++export interface CheckpointResult {+ checkpointId: string;+ status: VerificationStatus;+ score: number;+ passed: boolean;+ duration: number;+ validatorResults: ValidatorResult[];+ evidence: VerificationEvidence[];+ errors: VerificationError[];+ warnings: VerificationWarning[];+}++export interface ValidatorResult {+ validatorId: string;+ status: VerificationStatus;+ score: number;+ passed: boolean;+ details: Record<string, unknown>;+ evidence: VerificationEvidence[];+}++export interface ResourceUsage {+ cpu: number;+ memory: number;+ disk: number;+ network: number;+ tokens?: number;+ apiCalls?: number;}-export interface ThresholdSignatureState {- signatureId: string;- message: any;- requiredSignatures: number;- currentSignatures: number;- signatories: string[];- partialSignatures: Map<string, string>;- completed: boolean;- finalSignature?: string;+export interface VerificationEvidence {+ type: string;+ source: string;+ timestamp: Date;+ data: Record<string, unknown>;+ reliability: number;+ weight: number;}-export interface RateLimitWindow {- windowStart: Date;- windowEnd: Date;- requestCount: number;- limit: number;- violations: number;+export interface VerificationError {+ code: string;+ message: string;+ severity: 'low' | 'medium' | 'high' | 'critical';+ context: Record<string, unknown>;+ recoverable: boolean;+ timestamp: Date;}-export interface SecurityAlert {- alertId: string;+export interface VerificationWarning {+ code: string;+ message: string;+ severity: 'low' | 'medium' | 'high';+ context: Record<string, unknown>;+ recommendation: string;timestamp: Date;- type: 'BREACH_ATTEMPT' | 'BYZANTINE_BEHAVIOR' | 'RATE_LIMIT_EXCEEDED' | 'AUTH_FAILURE' | 'SIGNATURE_INVALID';- agentId: string;- severity: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';+}++// ===== AGENT CLAIM VALIDATION =====++export interface AgentClaim {+ /** Claim identification */+ id: string;+ agentId: AgentId;+ taskId?: TaskId;+ swarmId?: SwarmId;++ /** Claim details */+ type: ClaimType;+ title: string;description: string;- evidence: any;- automaticResponse: string[];- requiresManualIntervention: boolean;-}--export interface VerificationChain {- chainId: string;- startedBy: string;- truthClaim: any;- verificationSteps: Array<{- stepId: string;- verifiedBy: string;- timestamp: Date;- result: boolean;- evidence: any[];- signature: string;- }>;- finalResult: boolean;++ /** Claim data */+ data: Record<string, unknown>;+ metrics: ClaimMetrics;++ /** Supporting evidence */+ evidence: ClaimEvidence[];+ references: string[];++ /** Validation status */+ status: VerificationStatus;confidence: number;- chainIntegrity: boolean;++ /** Timestamps */+ submittedAt: Date;+ validatedAt?: Date;++ /** Validation metadata */+ metadata: Record<string, unknown>;}-export interface CryptographicEvidence {- evidenceId: string;- type: 'SIGNATURE' | 'HASH' | 'PROOF' | 'CERTIFICATE';- data: string;- algorithm: string;+export interface ClaimMetrics {+ /** Performance metrics */+ executionTime?: number;+ resourceUsage?: ResourceUsage;+ throughput?: number;+ errorRate?: number;++ /** Quality metrics */+ accuracy?: number;+ precision?: number;+ recall?: number;+ f1Score?: number;++ /** Custom metrics */+ custom: Record<string, number>;+}++export interface ClaimEvidence {+ type: 'log_entry' | 'test_result' | 'measurement' | 'artifact' | 'witness_testimony' | 'external_verification';+ source: string;timestamp: Date;+ data: Record<string, unknown>;+ reliability: number;verifiable: boolean;- relatedAgents: string[];}-export interface SecureCommunicationChannel {- channelId: string;- participants: string[];- encryptionKey: string;- established: Date;- lastActivity: Date;- messageCount: number;- integrityVerified: boolean;+export interface ClaimValidationConfig {+ /** Validation rules */+ requiredEvidence: string[];+ minimumConfidence: number;+ crossValidationRequired: boolean;++ /** Verification methods */+ methods: ClaimValidationMethod[];++ /** Timeout and retry settings */+ timeout: number;+ retryAttempts: number;++ /** Quality thresholds */+ qualityThresholds: Record<string, number>;+}++export interface ClaimValidationMethod {+ name: string;+ type: 'historical_comparison' | 'cross_agent_verification' | 'external_validation' | 'statistical_test' | 'custom';+ config: Record<string, unknown>;+ weight: number;+ required: boolean;+}++export interface ClaimValidationResult {+ claimId: string;+ status: VerificationStatus;+ confidence: number;+ score: number;+ passed: boolean;++ methodResults: MethodValidationResult[];+ evidence: VerificationEvidence[];++ duration: number;+ timestamp: Date;++ errors: VerificationError[];+ warnings: VerificationWarning[];+ recommendations: string[];+}++export interface MethodValidationResult {+ methodName: string;+ status: VerificationStatus;+ score: number;+ confidence: number;+ details: Record<string, unknown>;+ evidence: VerificationEvidence[];+}++// ===== INTEGRATION TESTING =====++export interface IntegrationTestConfig {+ /** Test identification */+ id: string;+ name: string;+ description: string;++ /** Test scope */+ agents: AgentId[];+ tasks: TaskId[];+ swarms: SwarmId[];++ /** Test scenarios */+ scenarios: TestScenario[];++ /** Execution settings */+ parallel: boolean;+ timeout: number;+ retryAttempts: number;++ /** Environment settings */+ environment: TestEnvironment;++ /** Validation criteria */+ validationCriteria: ValidationCriteria;+}++export interface TestScenario {+ id: string;+ name: string;+ description: string;++ /** Test steps */+ steps: TestStep[];++ /** Setup and teardown */+ setup?: TestStep[];+ teardown?: TestStep[];++ /** Dependencies */+ dependencies: string[];++ /** Expected outcomes */+ expectedResults: ExpectedResult[];++ /** Resource requirements */+ resources: ResourceRequirements;+}++export interface TestStep {+ id: string;+ name: string;+ type: 'agent_action' | 'system_action' | 'validation' | 'wait' | 'custom';++ /** Step configuration */+ config: Record<string, unknown>;+ params: Record<string, unknown>;++ /** Execution settings */+ timeout: number;+ retryAttempts: number;+ continueOnError: boolean;++ /** Validation */+ validators: TestValidator[];+ assertions: TestAssertion[];+}++export interface TestValidator {+ type: string;+ config: Record<string, unknown>;+ weight: number;+ required: boolean;+}++export interface TestAssertion {+ field: string;+ operator: string;+ expected: unknown;+ actual?: unknown;+ passed?: boolean;+ message?: string;+}++export interface ExpectedResult {+ type: 'agent_state' | 'task_result' | 'system_metric' | 'custom';+ criteria: Record<string, unknown>;+ tolerance: number;+ required: boolean;}-export interface FraudDetectionResult {- scanId: string;+export interface ResourceRequirements {+ cpu: number;+ memory: number;+ disk: number;+ network: number;+ agents: number;+ duration: number;+}++export interface TestEnvironment {+ name: string;+ variables: Record<string, string>;+ services: ServiceConfig[];+ constraints: EnvironmentConstraint[];+}++export interface ServiceConfig {+ name: string;+ type: string;+ config: Record<string, unknown>;+ healthCheck: HealthCheck;+}++export interface HealthCheck {+ type: 'http' | 'tcp' | 'exec' | 'custom';+ config: Record<string, unknown>;+ interval: number;+ timeout: number;+ retries: number;+}++export interface EnvironmentConstraint {+ type: string;+ value: unknown;+ description: string;+}++export interface ValidationCriteria {+ /** Performance criteria */+ maxExecutionTime: number;+ minThroughput: number;+ maxErrorRate: number;++ /** Quality criteria */+ minAccuracy: number;+ minReliability: number;+ minConsistency: number;++ /** Resource criteria */+ maxResourceUsage: ResourceUsage;++ /** Custom criteria */+ custom: Record<string, unknown>;+}++export interface IntegrationTestResult {+ /** Test identification */+ testId: string;timestamp: Date;- agentId: string;- suspiciousActivities: Array<{- activity: string;- riskScore: number;- indicators: string[];- }>;- overallRiskScore: number;- recommendedActions: string[];- escalationRequired: boolean;-}--export interface BackupSecurityState {- backupId: string;++ /** Overall result */+ status: VerificationStatus;+ passed: boolean;+ score: number;++ /** Scenario results */+ scenarioResults: ScenarioResult[];++ /** Performance metrics */+ duration: number;+ resourceUsage: ResourceUsage;++ /** Quality metrics */+ coverage: TestCoverage;+ reliability: number;++ /** Evidence and artifacts */+ evidence: VerificationEvidence[];+ artifacts: Record<string, unknown>;+ logs: TestLog[];++ /** Error information */+ errors: VerificationError[];+ warnings: VerificationWarning[];++ /** Analysis and recommendations */+ analysis: TestAnalysis;+ recommendations: string[];+}++export interface ScenarioResult {+ scenarioId: string;+ status: VerificationStatus;+ passed: boolean;+ score: number;+ duration: number;++ stepResults: StepResult[];+ validationResults: ValidationResult[];++ evidence: VerificationEvidence[];+ artifacts: Record<string, unknown>;++ errors: VerificationError[];+ warnings: VerificationWarning[];+}++export interface StepResult {+ stepId: string;+ status: VerificationStatus;+ passed: boolean;+ duration: number;++ validatorResults: ValidatorResult[];+ assertionResults: AssertionResult[];++ output: Record<string, unknown>;+ evidence: VerificationEvidence[];+}++export interface AssertionResult {+ field: string;+ operator: string;+ expected: unknown;+ actual: unknown;+ passed: boolean;+ message: string;+ timestamp: Date;+}++export interface ValidationResult {+ type: string;+ passed: boolean;+ score: number;+ details: Record<string, unknown>;+ evidence: VerificationEvidence[];+}++export interface TestCoverage {+ agents: number;+ tasks: number;+ scenarios: number;+ steps: number;+ assertions: number;+ percentage: number;+}++export interface TestLog {+ level: 'debug' | 'info' | 'warn' | 'error';+ message: string;timestamp: Date;- securityHash: string;- agentStates: Map<string, any>;- auditTrail: any[];- cryptographicKeys: Map<string, string>;- configurationSnapshot: any;- integrityProof: string;+ source: string;+ context: Record<string, unknown>;+}++export interface TestAnalysis {+ bottlenecks: PerformanceBottleneck[];+ patterns: TestPattern[];+ insights: TestInsight[];+ trends: TestTrend[];+}++export interface PerformanceBottleneck {+ type: string;+ location: string;+ impact: number;+ description: string;+ recommendations: string[];+}++export interface TestPattern {+ type: string;+ pattern: string;+ frequency: number;+ significance: number;+ examples: string[];+}++export interface TestInsight {+ category: string;+ insight: string;+ confidence: number;+ evidence: string[];+ implications: string[];+}++export interface TestTrend {+ metric: string;+ direction: 'increasing' | 'decreasing' | 'stable' | 'volatile';+ magnitude: number;+ significance: number;+ period: string;}-export interface SecurityPolicy {- policyId: string;+// ===== STATE SNAPSHOT SYSTEM =====++export interface StateSnapshotConfig {+ /** Snapshot identification */+ id: string;name: string;description: string;- enforcementLevel: 'ADVISORY' | 'MANDATORY' | 'CRITICAL';- rules: Array<{- ruleId: string;- condition: string;- action: string;- parameters: any;- }>;- applicableAgents: string[];- createdAt: Date;- lastModified: Date;- active: boolean;-}--// Utility types for enhanced type safety-export type SecurityOperation =- | 'REGISTER_AGENT'- | 'AUTHENTICATE_AGENT'- | 'VERIFY_TRUTH_CLAIM'- | 'SIGN_RESULT'- | 'AUDIT_TRAIL'- | 'RATE_LIMIT_CHECK'- | 'BYZANTINE_DETECTION'- | 'CONSENSUS_PARTICIPATION'- | 'EMERGENCY_SHUTDOWN'- | 'BACKUP_CREATION'- | 'RESTORE_STATE';--export type ThreatVector =- | 'SYBIL_ATTACK'- | 'BYZANTINE_ATTACK'- | 'ECLIPSE_ATTACK'- | 'DOS_ATTACK'- | 'REPLAY_ATTACK'- | 'MAN_IN_MIDDLE'- | 'SIGNATURE_FORGERY'- | 'COLLUSION_ATTACK'- | 'TIMING_ATTACK'- | 'SOCIAL_ENGINEERING';--export type CryptographicPrimitive =- | 'RSA_SIGNATURE'- | 'ECDSA_SIGNATURE'- | 'THRESHOLD_SIGNATURE'- | 'ZERO_KNOWLEDGE_PROOF'- | 'HASH_FUNCTION'- | 'SYMMETRIC_ENCRYPTION'- | 'ASYMMETRIC_ENCRYPTION'- | 'MERKLE_TREE'- | 'COMMITMENT_SCHEME'- | 'SECRET_SHARING';--export type AuditEventType =- | 'SYSTEM_START'- | 'SYSTEM_SHUTDOWN'- | 'AGENT_REGISTRATION'- | 'AGENT_DEREGISTRATION'- | 'VERIFICATION_REQUEST'- | 'VERIFICATION_RESULT'- | 'SIGNATURE_CREATION'- | 'SIGNATURE_VERIFICATION'- | 'CONSENSUS_ROUND'- | 'THREAT_DETECTED'- | 'POLICY_VIOLATION'- | 'EMERGENCY_ACTION';--// Generic interfaces for extensibility-export interface SecurityExtension<T = any> {++ /** Snapshot scope */+ scope: SnapshotScope;++ /** Storage settings */+ storage: SnapshotStorageConfig;++ /** Retention settings */+ retention: SnapshotRetentionConfig;++ /** Compression settings */+ compression: SnapshotCompressionConfig;++ /** Encryption settings */+ encryption?: SnapshotEncryptionConfig;+}++export interface SnapshotScope {+ /** Include agent states */+ includeAgents: boolean;+ agentFilter?: AgentFilter;++ /** Include task states */+ includeTasks: boolean;+ taskFilter?: TaskFilter;++ /** Include swarm states */+ includeSwarms: boolean;+ swarmFilter?: SwarmFilter;++ /** Include system state */+ includeSystem: boolean;+ systemComponents: string[];++ /** Include memory state */+ includeMemory: boolean;+ memoryPartitions: string[];++ /** Custom inclusions */+ custom: Record<string, boolean>;+}++export interface AgentFilter {+ types: string[];+ statuses: string[];+ tags: string[];+ exclude: AgentId[];+}++export interface TaskFilter {+ types: string[];+ statuses: string[];+ priorities: string[];+ exclude: TaskId[];+}++export interface SwarmFilter {+ modes: string[];+ strategies: string[];+ statuses: string[];+ exclude: SwarmId[];+}++export interface SnapshotStorageConfig {+ type: 'local' | 'remote' | 'distributed' | 'cloud';+ location: string;+ redundancy: number;+ checksum: boolean;+ versioning: boolean;+}++export interface SnapshotRetentionConfig {+ maxSnapshots: number;+ maxAge: number;+ strategy: 'fifo' | 'lru' | 'importance' | 'custom';+ archiveOld: boolean;+ archiveLocation?: string;+}++export interface SnapshotCompressionConfig {+ enabled: boolean;+ algorithm: 'gzip' | 'brotli' | 'lz4' | 'zstd';+ level: number;+ threshold: number;+}++export interface SnapshotEncryptionConfig {+ enabled: boolean;+ algorithm: 'aes-256-gcm' | 'chacha20-poly1305' | 'custom';+ keyDerivation: 'pbkdf2' | 'scrypt' | 'argon2';+ saltLength: number;+}++export interface StateSnapshot {+ /** Snapshot identification */+ id: string;name: string;+ description: string;++ /** Snapshot metadata */+ timestamp: Date;version: string;- initialize(): Promise<void>;- process(input: T): Promise<any>;- cleanup(): Promise<void>;+ checksum: string;++ /** Snapshot scope */+ scope: SnapshotScope;++ /** Snapshot data */+ agentStates: Record<string, AgentState>;+ taskStates: Record<string, TaskResult>;+ swarmStates: Record<string, SwarmState>;+ systemState: SystemState;+ memoryState: MemoryState;+ customState: Record<string, unknown>;++ /** Snapshot statistics */+ statistics: SnapshotStatistics;++ /** Storage information */+ storage: SnapshotStorageInfo;++ /** Validation information */+ validation: SnapshotValidation;+}++export interface SwarmState {+ id: SwarmId;+ status: string;+ progress: Record<string, unknown>;+ metrics: Record<string, unknown>;+ configuration: Record<string, unknown>;+ timestamp: Date;+}++export interface SystemState {+ timestamp: Date;+ version: string;+ uptime: number;+ resources: ResourceUsage;+ services: ServiceState[];+ configuration: Record<string, unknown>;+ health: HealthState;+}++export interface ServiceState {+ name: string;+ status: string;+ health: string;+ metrics: Record<string, unknown>;+ configuration: Record<string, unknown>;+ timestamp: Date;}-export interface SecurityMiddleware {+export interface HealthState {+ overall: string;+ components: Record<string, string>;+ checks: HealthCheckResult[];+ timestamp: Date;+}++export interface HealthCheckResult {name: string;- priority: number;- beforeVerification?(request: any): Promise<void>;- afterVerification?(result: any): Promise<void>;- onError?(error: Error): Promise<void>;-}--export interface SecurityMetricsCollector {- collect(): Promise<Map<string, number>>;- reset(): Promise<void>;- export(format: 'json' | 'csv' | 'prometheus'): Promise<string>;-}--// Constants for security configuration-export const SECURITY_CONSTANTS = {- DEFAULT_KEY_SIZE: 4096,- DEFAULT_HASH_ALGORITHM: 'sha256',- DEFAULT_SIGNATURE_ALGORITHM: 'rsa',- DEFAULT_ENCRYPTION_ALGORITHM: 'aes-256-gcm',- MINIMUM_CONSENSUS_THRESHOLD: 0.67,- MAXIMUM_BYZANTINE_TOLERANCE: 0.33,- DEFAULT_RATE_LIMITS: {- perSecond: 10,- perMinute: 100,- perHour: 1000,- perDay: 10000- },- REPUTATION_THRESHOLDS: {- MINIMUM_FOR_VERIFICATION: 50,- MINIMUM_FOR_CONSENSUS: 70,- MAXIMUM_REPUTATION: 100,- MINIMUM_REPUTATION: 0- },- AUDIT_RETENTION: {- DAYS: 365,- MAX_ENTRIES: 1000000- }+ status: string;+ message: string;+ duration: number;+ timestamp: Date;+}++export interface MemoryState {+ timestamp: Date;+ partitions: Record<string, MemoryPartitionState>;+ statistics: MemoryStatistics;+ integrity: MemoryIntegrity;+}++export interface MemoryPartitionState {+ id: string;+ type: string;+ entries: number;+ size: number;+ lastModified: Date;+ checksum: string;+}++export interface MemoryStatistics {+ totalEntries: number;+ totalSize: number;+ utilizationRate: number;+ accessPatterns: Record<string, number>;+ performance: Record<string, number>;+}++export interface MemoryIntegrity {+ checksumValid: boolean;+ corruptedEntries: string[];+ missingReferences: string[];+ inconsistencies: string[];+}++export interface SnapshotStatistics {+ totalSize: number;+ compressedSize: number;+ compressionRatio: number;+ entryCount: Record<string, number>;+ captureTime: number;+ validationTime: number;+}++export interface SnapshotStorageInfo {+ type: string;+ location: string;+ size: number;+ checksum: string;+ encrypted: boolean;+ redundancy: number;+ accessibility: string;+}++export interface SnapshotValidation {+ checksumValid: boolean;+ structureValid: boolean;+ dataIntegrity: boolean;+ versionCompatible: boolean;+ errors: string[];+ warnings: string[];+ timestamp: Date;+}++export interface RollbackConfig {+ /** Rollback identification */+ id: string;+ snapshotId: string;+ reason: string;++ /** Rollback scope */+ scope: RollbackScope;++ /** Rollback strategy */+ strategy: RollbackStrategy;++ /** Safety settings */+ safety: RollbackSafetyConfig;++ /** Notification settings */+ notifications: NotificationConfig[];+}++export interface RollbackScope {+ includeAgents: boolean;+ includeTasks: boolean;+ includeSwarms: boolean;+ includeSystem: boolean;+ includeMemory: boolean;++ /** Partial rollback filters */+ agentFilter?: AgentFilter;+ taskFilter?: TaskFilter;+ swarmFilter?: SwarmFilter;++ /** Exclude from rollback */+ preserveData: string[];+}++export interface RollbackStrategy {+ type: 'immediate' | 'gradual' | 'selective' | 'custom';+ stopRunningTasks: boolean;+ backupCurrent: boolean;+ validateBefore: boolean;+ validateAfter: boolean;+ rollbackTimeout: number;+}++export interface RollbackSafetyConfig {+ requireConfirmation: boolean;+ maxRollbackTime: number;+ emergencyStop: boolean;+ backupRequired: boolean;+ validationRequired: boolean;+ approvalRequired: boolean;+}++export interface RollbackResult {+ /** Rollback identification */+ id: string;+ snapshotId: string;+ timestamp: Date;++ /** Result status */+ status: 'completed' | 'partial' | 'failed' | 'cancelled';+ success: boolean;++ /** Rollback details */+ scope: RollbackScope;+ duration: number;++ /** Component results */+ componentResults: ComponentRollbackResult[];++ /** Validation results */+ validation: RollbackValidation;++ /** Data preservation */+ preservedData: string[];+ lostData: string[];++ /** Backup information */+ backupSnapshot?: string;++ /** Error information */+ errors: VerificationError[];+ warnings: VerificationWarning[];++ /** Recovery information */+ recoveryActions: string[];+ nextSteps: string[];+}++export interface ComponentRollbackResult {+ component: string;+ status: 'completed' | 'failed' | 'skipped';+ duration: number;+ itemsRolledBack: number;+ itemsFailed: number;+ errors: string[];+}++export interface RollbackValidation {+ preValidation: ValidationResult;+ postValidation: ValidationResult;+ dataIntegrity: boolean;+ systemHealth: boolean;+ functionalityPreserved: boolean;+}++// ===== UTILITY TYPES =====++export type VerificationCallback = (result: VerificationResult) => void | Promise<void>;+export type CheckpointCallback = (result: CheckpointResult) => void | Promise<void>;+export type ClaimValidationCallback = (result: ClaimValidationResult) => void | Promise<void>;+export type TestCompletionCallback = (result: IntegrationTestResult) => void | Promise<void>;+export type SnapshotCallback = (snapshot: StateSnapshot) => void | Promise<void>;+export type RollbackCallback = (result: RollbackResult) => void | Promise<void>;++// ===== TYPE GUARDS =====++export function isTruthScore(obj: unknown): obj is TruthScore {+ return (+ typeof obj === 'object' &&+ obj !== null &&+ typeof (obj as TruthScore).score === 'number' &&+ typeof (obj as TruthScore).components === 'object' &&+ (obj as TruthScore).timestamp instanceof Date+ );+}++export function isVerificationResult(obj: unknown): obj is VerificationResult {+ return (+ typeof obj === 'object' &&+ obj !== null &&+ typeof (obj as VerificationResult).id === 'string' &&+ typeof (obj as VerificationResult).status === 'string' &&+ typeof (obj as VerificationResult).passed === 'boolean'+ );+}++export function isAgentClaim(obj: unknown): obj is AgentClaim {+ return (+ typeof obj === 'object' &&+ obj !== null &&+ typeof (obj as AgentClaim).id === 'string' &&+ typeof (obj as AgentClaim).type === 'string' &&+ (obj as AgentClaim).submittedAt instanceof Date+ );+}++export function isStateSnapshot(obj: unknown): obj is StateSnapshot {+ return (+ typeof obj === 'object' &&+ obj !== null &&+ typeof (obj as StateSnapshot).id === 'string' &&+ (obj as StateSnapshot).timestamp instanceof Date &&+ typeof (obj as StateSnapshot).checksum === 'string'+ );+}++// ===== CONSTANTS =====++export const VERIFICATION_CONSTANTS = {+ // Default thresholds+ DEFAULT_TRUTH_THRESHOLD: 0.95,+ DEFAULT_CONFIDENCE_LEVEL: 0.95,+ DEFAULT_MIN_SAMPLE_SIZE: 30,+ DEFAULT_MAX_ERROR_MARGIN: 0.05,++ // Timeouts+ DEFAULT_VERIFICATION_TIMEOUT: 5 * 60 * 1000, // 5 minutes+ DEFAULT_CHECKPOINT_TIMEOUT: 2 * 60 * 1000, // 2 minutes+ DEFAULT_CLAIM_VALIDATION_TIMEOUT: 1 * 60 * 1000, // 1 minute+ DEFAULT_TEST_TIMEOUT: 10 * 60 * 1000, // 10 minutes+ DEFAULT_ROLLBACK_TIMEOUT: 3 * 60 * 1000, // 3 minutes++ // Retry limits+ DEFAULT_RETRY_ATTEMPTS: 3,+ MAX_RETRY_ATTEMPTS: 10,++ // Snapshot limits+ DEFAULT_MAX_SNAPSHOTS: 100,+ DEFAULT_SNAPSHOT_RETENTION_DAYS: 30,+ DEFAULT_COMPRESSION_THRESHOLD: 1024 * 1024, // 1MB++ // Quality thresholds+ MIN_TRUTH_SCORE: 0.0,+ MAX_TRUTH_SCORE: 1.0,+ HIGH_CONFIDENCE_THRESHOLD: 0.9,+ MEDIUM_CONFIDENCE_THRESHOLD: 0.7,+ LOW_CONFIDENCE_THRESHOLD: 0.5,++ // Resource limits+ MAX_VERIFICATION_MEMORY: 512 * 1024 * 1024, // 512MB+ MAX_SNAPSHOT_SIZE: 1024 * 1024 * 1024, // 1GB+ MAX_TEST_DURATION: 60 * 60 * 1000, // 1 hour} as const;-// Error types for better error handling-export class SecurityError extends Error {- constructor(- message: string,- public code: string,- public agentId?: string,- public details?: any- ) {- super(message);- this.name = 'SecurityError';- }-}--export class AuthenticationError extends SecurityError {- constructor(message: string, agentId?: string, details?: any) {- super(message, 'AUTH_ERROR', agentId, details);- this.name = 'AuthenticationError';- }-}--export class ByzantineError extends SecurityError {- constructor(message: string, agentId: string, details?: any) {- super(message, 'BYZANTINE_ERROR', agentId, details);- this.name = 'ByzantineError';- }-}--export class CryptographicError extends SecurityError {- constructor(message: string, details?: any) {- super(message, 'CRYPTO_ERROR', undefined, details);- this.name = 'CryptographicError';- }-}--export class RateLimitError extends SecurityError {- constructor(message: string, agentId: string, retryAfter?: number) {- super(message, 'RATE_LIMIT_ERROR', agentId, { retryAfter });- this.name = 'RateLimitError';- }-}\ No newline at end of file+export default {+ VERIFICATION_CONSTANTS,+ isTruthScore,+ isVerificationResult,+ isAgentClaim,+ isStateSnapshot,+};\ No newline at end of file