|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| use automated_operator::{AutomatedOperator, Ed25519PublicKey, ScoreWeights, ENTROPY_BOUND};
|
|
|
| #[test]
|
| fn execute_10k_operator_simulation() {
|
| let anchor = Ed25519PublicKey([0xFF; 32]);
|
| let seed = [42u8; 32];
|
|
|
| let mut operator = AutomatedOperator::new(seed, anchor, ScoreWeights::DEFAULT);
|
|
|
| let total_iterations = 10_000;
|
| let mut entropy_violations = 0;
|
| let mut null_generations = 0;
|
| let mut novelties = Vec::with_capacity(total_iterations);
|
|
|
| for epoch in 0..total_iterations {
|
|
|
| if let Some(obj) = operator.next_objective() {
|
|
|
|
|
| if operator.state().entropy_budget < 0.0 || operator.state().entropy_budget > ENTROPY_BOUND {
|
| entropy_violations += 1;
|
| }
|
|
|
|
|
| assert_eq!(
|
| obj.target_space_hash[0],
|
| anchor.0[0],
|
| "Sovereign compliance violation at epoch {}", epoch
|
| );
|
|
|
|
|
| let novelty = operator.novelty_estimate(&obj);
|
| novelties.push(novelty);
|
|
|
|
|
| let mock_result_hash = [epoch as u8; 32];
|
| let mock_proof_hash = [0xAA; 32];
|
| operator.receive_result(mock_result_hash, mock_proof_hash);
|
|
|
| } else {
|
|
|
| null_generations += 1;
|
| }
|
| }
|
|
|
|
|
| let avg_novelty: f32 = novelties.iter().sum::<f32>() / novelties.len() as f32;
|
| let min_novelty = novelties.iter().fold(f32::INFINITY, |a, &b| a.min(b));
|
| let max_novelty = novelties.iter().fold(f32::NEG_INFINITY, |a, &b| a.max(b));
|
|
|
| println!("========================================");
|
| println!("AUTOMATED OPERATOR: 10K SIMULATION RUN");
|
| println!("========================================");
|
| println!("Total Epochs: {}", total_iterations);
|
| println!("Valid Objectives: {}", novelties.len());
|
| println!("Null Generations: {} (Budget Relaxations)", null_generations);
|
| println!("Entropy Violations: {}", entropy_violations);
|
| println!("----------------------------------------");
|
| println!("Novelty Distribution:");
|
| println!(" Average: {:.4}", avg_novelty);
|
| println!(" Minimum: {:.4}", min_novelty);
|
| println!(" Maximum: {:.4}", max_novelty);
|
| println!("========================================");
|
|
|
|
|
| assert_eq!(entropy_violations, 0, "FATAL: Entropy budget was breached.");
|
| assert!(avg_novelty > 0.30, "FATAL: Mode collapse detected. Novelty too low: {}", avg_novelty);
|
| assert!(novelties.len() > 9000, "FATAL: Too many null generations, operator stalled.");
|
| }
|
|
|
| #[test]
|
| fn test_determinism_same_seed_same_sequence() {
|
| let seed = [42u8; 32];
|
| let anchor = Ed25519PublicKey([1u8; 32]);
|
|
|
| let mut op1 = AutomatedOperator::new(seed, anchor, ScoreWeights::DEFAULT);
|
| let mut op2 = AutomatedOperator::new(seed, anchor, ScoreWeights::DEFAULT);
|
|
|
| for epoch in 0..100 {
|
| let o1 = op1.next_objective();
|
| let o2 = op2.next_objective();
|
| assert_eq!(o1, o2, "Determinism violated at epoch {}", epoch);
|
|
|
| if o1.is_some() {
|
| op1.receive_result([1u8; 32], [2u8; 32]);
|
| op2.receive_result([1u8; 32], [2u8; 32]);
|
| }
|
| }
|
| }
|
|
|
| #[test]
|
| fn test_sovereign_compliance_enforced() {
|
| let anchor = Ed25519PublicKey([0xFFu8; 32]);
|
| let mut op = AutomatedOperator::new([0u8; 32], anchor, ScoreWeights::DEFAULT);
|
|
|
| for epoch in 0..1000 {
|
| if let Some(obj) = op.next_objective() {
|
| assert_eq!(obj.target_space_hash[0], 0xFF, "Sovereign compliance violation at epoch {}", epoch);
|
| op.receive_result([1u8; 32], [2u8; 32]);
|
| }
|
| }
|
| }
|
|
|
| #[test]
|
| fn test_novelty_increases_over_time() {
|
| let mut op = AutomatedOperator::new([0u8; 32], Ed25519PublicKey([0xFF; 32]), ScoreWeights::DEFAULT);
|
| let mut novelties = Vec::new();
|
|
|
| for _ in 0..50 {
|
| if let Some(obj) = op.next_objective() {
|
| let novelty = op.novelty_estimate(&obj);
|
| novelties.push(novelty);
|
| op.receive_result([1u8; 32], [2u8; 32]);
|
| }
|
| }
|
|
|
| let avg_novelty: f32 = novelties.iter().sum::<f32>() / novelties.len() as f32;
|
| println!("Average novelty over 50 epochs: {:.4}", avg_novelty);
|
| assert!(avg_novelty > 0.30, "Average novelty too low: {}", avg_novelty);
|
| } |