@feltdb/core 0.8.4 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/create/package-versions.js +1 -1
  2. package/dist/create/server-source/Cargo.lock +165 -0
  3. package/dist/create/server-source/Cargo.toml +9 -0
  4. package/dist/create/server-source/crates/feltdb/Cargo.toml +3 -0
  5. package/dist/create/server-source/crates/feltdb/benches/gate13_baseline.rs +44 -44
  6. package/dist/create/server-source/crates/feltdb/benches/gate13_phase_7_1_release_economics.rs +12 -24
  7. package/dist/create/server-source/crates/feltdb/benches/gate_13_redux.rs +7 -13
  8. package/dist/create/server-source/crates/feltdb/benches/gate_13_regression_runner.rs +13 -10
  9. package/dist/create/server-source/crates/feltdb/benches/gate_14a_concurrent_writer_scaling.rs +12 -9
  10. package/dist/create/server-source/crates/feltdb/benches/gate_14a_production_admission_revalidation.rs +78 -25
  11. package/dist/create/server-source/crates/feltdb/benches/gate_14a_rc2_admission_contract.rs +16 -13
  12. package/dist/create/server-source/crates/feltdb/benches/gate_14a_rc_root_cause.rs +13 -5
  13. package/dist/create/server-source/crates/feltdb/benches/gate_14a_sync1_queued_prototype.rs +41 -22
  14. package/dist/create/server-source/crates/feltdb/benches/gate_14a_sync_economics.rs +33 -15
  15. package/dist/create/server-source/crates/feltdb/benches/gate_14b_causal_backlog_scaling.rs +100 -33
  16. package/dist/create/server-source/crates/feltdb/benches/gate_14c_replication_contract_test.rs +56 -20
  17. package/dist/create/server-source/crates/feltdb/benches/gate_14c_replication_scaling.rs +116 -41
  18. package/dist/create/server-source/crates/feltdb/benches/gate_14d_combined_dimension_scaling.rs +186 -55
  19. package/dist/create/server-source/crates/feltdb/benches/phase_7_1_2_optimization_benchmark.rs +64 -26
  20. package/dist/create/server-source/crates/feltdb/benches/phase_7_1_3_crossover_analysis.rs +46 -15
  21. package/dist/create/server-source/crates/feltdb/src/admission.rs +8 -15
  22. package/dist/create/server-source/crates/feltdb/src/admission_contract_tests.rs +43 -13
  23. package/dist/create/server-source/crates/feltdb/src/adversarial_transport.rs +15 -42
  24. package/dist/create/server-source/crates/feltdb/src/analytics.rs +65 -19
  25. package/dist/create/server-source/crates/feltdb/src/application.rs +113 -30
  26. package/dist/create/server-source/crates/feltdb/src/authorization_security_tests.rs +475 -140
  27. package/dist/create/server-source/crates/feltdb/src/cardinality_diagnostics.rs +17 -15
  28. package/dist/create/server-source/crates/feltdb/src/cardinality_endpoint.rs +0 -1
  29. package/dist/create/server-source/crates/feltdb/src/causal_backlog_bound.rs +59 -15
  30. package/dist/create/server-source/crates/feltdb/src/causal_dependency_barrier.rs +266 -114
  31. package/dist/create/server-source/crates/feltdb/src/causal_dependency_barrier_phase_7_1.rs +25 -7
  32. package/dist/create/server-source/crates/feltdb/src/concurrency_fuzzing.rs +10 -15
  33. package/dist/create/server-source/crates/feltdb/src/consistency_contract.rs +3 -11
  34. package/dist/create/server-source/crates/feltdb/src/crash_atomic_boundary.rs +14 -5
  35. package/dist/create/server-source/crates/feltdb/src/crash_injection.rs +21 -25
  36. package/dist/create/server-source/crates/feltdb/src/crash_recovery_tests.rs +14 -11
  37. package/dist/create/server-source/crates/feltdb/src/dedup_bound_investigation.rs +103 -22
  38. package/dist/create/server-source/crates/feltdb/src/distributed_indexing.rs +18 -15
  39. package/dist/create/server-source/crates/feltdb/src/durability_guarantees.rs +12 -8
  40. package/dist/create/server-source/crates/feltdb/src/durable_dedup_set.rs +1 -5
  41. package/dist/create/server-source/crates/feltdb/src/durable_operation_identity.rs +87 -23
  42. package/dist/create/server-source/crates/feltdb/src/durable_operation_log.rs +3 -7
  43. package/dist/create/server-source/crates/feltdb/src/durable_sync.rs +10 -9
  44. package/dist/create/server-source/crates/feltdb/src/in_process_transport.rs +1 -6
  45. package/dist/create/server-source/crates/feltdb/src/indexing.rs +35 -38
  46. package/dist/create/server-source/crates/feltdb/src/lib.rs +507 -6
  47. package/dist/create/server-source/crates/feltdb/src/managed_cas_tests.rs +4 -1
  48. package/dist/create/server-source/crates/feltdb/src/metrics.rs +0 -1
  49. package/dist/create/server-source/crates/feltdb/src/multi_node_convergence.rs +1 -2
  50. package/dist/create/server-source/crates/feltdb/src/multi_operation_transaction.rs +107 -30
  51. package/dist/create/server-source/crates/feltdb/src/observability.rs +19 -6
  52. package/dist/create/server-source/crates/feltdb/src/operation_algebra.rs +12 -11
  53. package/dist/create/server-source/crates/feltdb/src/operation_log.rs +9 -4
  54. package/dist/create/server-source/crates/feltdb/src/p1_application_atomicity.rs +65 -18
  55. package/dist/create/server-source/crates/feltdb/src/p1_atomicity_acceptance.rs +193 -57
  56. package/dist/create/server-source/crates/feltdb/src/partition_reconciliation.rs +37 -27
  57. package/dist/create/server-source/crates/feltdb/src/permutation_scheduler.rs +38 -10
  58. package/dist/create/server-source/crates/feltdb/src/persistence_reality.rs +20 -14
  59. package/dist/create/server-source/crates/feltdb/src/phase1b_acceptance.rs +394 -229
  60. package/dist/create/server-source/crates/feltdb/src/phase1c1_acceptance.rs +8 -6
  61. package/dist/create/server-source/crates/feltdb/src/phase1c2_acceptance.rs +11 -13
  62. package/dist/create/server-source/crates/feltdb/src/phase1c3_acceptance.rs +79 -70
  63. package/dist/create/server-source/crates/feltdb/src/phase1c_atomicity_proof.rs +3 -3
  64. package/dist/create/server-source/crates/feltdb/src/phase5_integration.rs +33 -11
  65. package/dist/create/server-source/crates/feltdb/src/phase5_scenarios.rs +6 -6
  66. package/dist/create/server-source/crates/feltdb/src/phase6_adversarial_scenarios.rs +14 -56
  67. package/dist/create/server-source/crates/feltdb/src/phase6_convergence_validator.rs +29 -27
  68. package/dist/create/server-source/crates/feltdb/src/phase6_persistence.rs +35 -17
  69. package/dist/create/server-source/crates/feltdb/src/phase_1c_real_tcp.rs +8 -2
  70. package/dist/create/server-source/crates/feltdb/src/phase_2a_failures.rs +59 -15
  71. package/dist/create/server-source/crates/feltdb/src/phase_2b_network.rs +70 -17
  72. package/dist/create/server-source/crates/feltdb/src/phase_2c_cascading.rs +23 -6
  73. package/dist/create/server-source/crates/feltdb/src/phase_3_durability.rs +12 -3
  74. package/dist/create/server-source/crates/feltdb/src/phase_4_baseline.rs +41 -11
  75. package/dist/create/server-source/crates/feltdb/src/phase_5_soak.rs +56 -25
  76. package/dist/create/server-source/crates/feltdb/src/policy_evaluation.rs +701 -245
  77. package/dist/create/server-source/crates/feltdb/src/production_api.rs +31 -13
  78. package/dist/create/server-source/crates/feltdb/src/query_performance.rs +6 -8
  79. package/dist/create/server-source/crates/feltdb/src/replay_fuzzing.rs +5 -5
  80. package/dist/create/server-source/crates/feltdb/src/replica_acknowledgements.rs +48 -18
  81. package/dist/create/server-source/crates/feltdb/src/replica_membership.rs +30 -11
  82. package/dist/create/server-source/crates/feltdb/src/replication_manager.rs +6 -3
  83. package/dist/create/server-source/crates/feltdb/src/replication_protocol.rs +4 -3
  84. package/dist/create/server-source/crates/feltdb/src/sharding.rs +36 -10
  85. package/dist/create/server-source/crates/feltdb/src/state_conflict_contract.rs +516 -0
  86. package/dist/create/server-source/crates/feltdb/src/state_contract.rs +13 -4
  87. package/dist/create/server-source/crates/feltdb/src/state_diff_contract.rs +222 -0
  88. package/dist/create/server-source/crates/feltdb/src/state_facade.rs +82 -54
  89. package/dist/create/server-source/crates/feltdb/src/state_hash.rs +2 -2
  90. package/dist/create/server-source/crates/feltdb/src/state_model.rs +1514 -537
  91. package/dist/create/server-source/crates/feltdb/src/state_transition_store.rs +6 -3
  92. package/dist/create/server-source/crates/feltdb/src/state_trigger.rs +672 -0
  93. package/dist/create/server-source/crates/feltdb/src/submission.rs +5 -11
  94. package/dist/create/server-source/crates/feltdb/src/tcp_transport.rs +6 -8
  95. package/dist/create/server-source/crates/feltdb/src/transaction_api.rs +24 -35
  96. package/dist/create/server-source/crates/feltdb/src/transaction_invariants.rs +24 -8
  97. package/dist/create/server-source/crates/feltdb/src/transaction_preconditions.rs +248 -59
  98. package/dist/create/server-source/crates/feltdb/src/transactions.rs +17 -20
  99. package/dist/create/server-source/crates/feltdb/src/trigger_contract.rs +749 -0
  100. package/dist/create/server-source/crates/feltdb/src/worker_mesh.rs +1 -0
  101. package/dist/create/server-source/crates/feltdb/src/workload.rs +512 -4
  102. package/dist/create/server-source/crates/feltdb/src/workload_diagnostics.rs +3 -4
  103. package/dist/create/server-source/crates/feltdb/tests/branching_evidence.rs +299 -0
  104. package/dist/create/server-source/crates/feltdb/tests/current_revision_authority_evidence.rs +288 -0
  105. package/dist/create/server-source/crates/feltdb/tests/durable_format_compatibility.rs +392 -0
  106. package/dist/create/server-source/crates/feltdb/tests/feltdb_state_boundary_tests.rs +436 -220
  107. package/dist/create/server-source/crates/feltdb/tests/fixtures/state_conflict_contract_corpus.json +1916 -0
  108. package/dist/create/server-source/crates/feltdb/tests/fixtures/state_diff_contract_corpus.json +1878 -0
  109. package/dist/create/server-source/crates/feltdb/tests/fixtures/trigger_contract_corpus.json +1862 -0
  110. package/dist/create/server-source/crates/feltdb/tests/pr34_query_collection.rs +2 -1
  111. package/dist/create/server-source/crates/feltdb/tests/pr35_equality_index.rs +80 -25
  112. package/dist/create/server-source/crates/feltdb/tests/pr7_self_authorization_proof.rs +5 -8
  113. package/dist/create/server-source/crates/feltdb/tests/pr8_vocabulary_assessment.rs +52 -44
  114. package/dist/create/server-source/crates/feltdb/tests/pr9_phase2_boundary_tests.rs +33 -16
  115. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3a_path_a_tests.rs +22 -7
  116. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_authorized_mutations.rs +41 -22
  117. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_role_based_authorization.rs +25 -8
  118. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_simple_auth_delete.rs +9 -6
  119. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_team_delete_role_authorization.rs +120 -69
  120. package/dist/create/server-source/crates/feltdb/tests/pr9_teams_role_based_access.rs +21 -10
  121. package/dist/create/server-source/crates/feltdb/tests/production_readiness_contract.rs +1032 -0
  122. package/dist/create/server-source/crates/feltdb/tests/reconciliation_application.rs +868 -0
  123. package/dist/create/server-source/crates/feltdb/tests/reconciliation_wire_format_evidence.rs +221 -0
  124. package/dist/create/server-source/crates/feltdb/tests/resource_scoped_revisions.rs +338 -0
  125. package/dist/create/server-source/crates/feltdb/tests/revision_identity_contract.rs +1039 -0
  126. package/dist/create/server-source/crates/feltdb/tests/revision_model_decision.rs +739 -0
  127. package/dist/create/server-source/crates/feltdb/tests/revision_retention_boundary_evidence.rs +427 -0
  128. package/dist/create/server-source/crates/feltdb/tests/saas_authorization_integration.rs +3 -3
  129. package/dist/create/server-source/crates/feltdb/tests/saas_invitation_lifecycle.rs +25 -22
  130. package/dist/create/server-source/crates/feltdb/tests/state_conflict_contract_conformance.rs +1799 -0
  131. package/dist/create/server-source/crates/feltdb/tests/state_diff_contract_conformance.rs +1316 -0
  132. package/dist/create/server-source/crates/feltdb/tests/state_model_integration.rs +53 -61
  133. package/dist/create/server-source/crates/feltdb/tests/state_persistence_integration.rs +156 -61
  134. package/dist/create/server-source/crates/feltdb/tests/state_store_boundary_evidence.rs +299 -0
  135. package/dist/create/server-source/crates/feltdb/tests/sync_divergence_evidence.rs +255 -0
  136. package/dist/create/server-source/crates/feltdb/tests/three_way_input_boundary_evidence.rs +249 -0
  137. package/dist/create/server-source/crates/feltdb/tests/trigger_contract_conformance.rs +994 -0
  138. package/dist/create/server-source/crates/feltdb-server/src/app_state.rs +2 -1
  139. package/dist/create/server-source/crates/feltdb-server/src/auth.rs +164 -13
  140. package/dist/create/server-source/crates/feltdb-server/src/main.rs +326 -6
  141. package/dist/studio-app/assets/{feltdb_wasm-CVQWgXO-.js → feltdb_wasm-DaNwCLRX.js} +1 -1
  142. package/dist/studio-app/assets/feltdb_wasm_bg-DnsHNv6g.wasm +0 -0
  143. package/dist/studio-app/assets/{index-DwgNAIIX.js → index-j8IlhNqJ.js} +1 -1
  144. package/dist/studio-app/index.html +1 -1
  145. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  146. package/dist/workload.d.ts +2 -1
  147. package/dist/workload.d.ts.map +1 -1
  148. package/package.json +1 -1
  149. package/dist/studio-app/assets/feltdb_wasm_bg-CNVpvaZV.wasm +0 -0
@@ -17,13 +17,13 @@
17
17
  /// - Replication: messages sent, delivered, delivery rate
18
18
  /// - Convergence: all replicas converged, state_hash match
19
19
  /// - Interaction ratio: observed throughput / expected composed throughput
20
-
21
20
  use feltdb::{
22
- convergence::VectorClock, distributed_transactions::{
21
+ convergence::VectorClock,
22
+ distributed_transactions::{
23
23
  DistributedTransactionExecutor, ReplicationMessage, TransactionEnvelope,
24
24
  },
25
25
  state_hash::StateHash,
26
- transactions::{Operation, OperationCommand, OperationId, StateVersion, ConsistencyContract},
26
+ transactions::{ConsistencyContract, Operation, OperationCommand, OperationId, StateVersion},
27
27
  };
28
28
  use std::collections::HashMap;
29
29
  use std::sync::{Arc, Mutex};
@@ -68,7 +68,13 @@ impl SeededRng {
68
68
  }
69
69
  }
70
70
 
71
- fn generate_operation(rng: &mut SeededRng, op_id: u64, seq: u64, node: &str, client_id: usize) -> Operation {
71
+ fn generate_operation(
72
+ rng: &mut SeededRng,
73
+ op_id: u64,
74
+ seq: u64,
75
+ node: &str,
76
+ client_id: usize,
77
+ ) -> Operation {
72
78
  let record_id = format!("rec_{}", rng.next_range(0, 99));
73
79
  let _is_write = rng.next_f64() >= 0.7; // 70% reads, 30% writes
74
80
 
@@ -190,9 +196,10 @@ async fn measure_combination(
190
196
 
191
197
  // Initialize distributed system
192
198
  let initial_hash = StateHash::from_hex("hash0".to_string());
193
- let leader_executor = Arc::new(Mutex::new(
194
- DistributedTransactionExecutor::new("leader".to_string(), initial_hash.clone()),
195
- ));
199
+ let leader_executor = Arc::new(Mutex::new(DistributedTransactionExecutor::new(
200
+ "leader".to_string(),
201
+ initial_hash.clone(),
202
+ )));
196
203
 
197
204
  // Create follower replicas
198
205
  let mut follower_executors = Vec::new();
@@ -202,9 +209,10 @@ async fn measure_combination(
202
209
  let replica_id = format!("replica_{}", i);
203
210
  leader.register_replica(replica_id.clone(), initial_hash.clone());
204
211
 
205
- let replica_executor = Arc::new(Mutex::new(
206
- DistributedTransactionExecutor::new(replica_id, initial_hash.clone()),
207
- ));
212
+ let replica_executor = Arc::new(Mutex::new(DistributedTransactionExecutor::new(
213
+ replica_id,
214
+ initial_hash.clone(),
215
+ )));
208
216
  follower_executors.push(replica_executor);
209
217
  }
210
218
  }
@@ -223,7 +231,10 @@ async fn measure_combination(
223
231
  for client_id in 0..writers {
224
232
  let outcomes = Arc::clone(&outcomes);
225
233
  let leader = Arc::clone(&leader_executor);
226
- let followers = follower_executors.iter().map(Arc::clone).collect::<Vec<_>>();
234
+ let followers = follower_executors
235
+ .iter()
236
+ .map(Arc::clone)
237
+ .collect::<Vec<_>>();
227
238
  let global_seq = Arc::clone(&global_seq);
228
239
  let admission_latencies = Arc::clone(&admission_latencies);
229
240
  let e2e_latencies = Arc::clone(&e2e_latencies);
@@ -326,7 +337,9 @@ async fn measure_combination(
326
337
  }
327
338
  }
328
339
 
329
- let all_same = operations_applied_per_replica.iter().all(|&c| c == operations_accepted);
340
+ let all_same = operations_applied_per_replica
341
+ .iter()
342
+ .all(|&c| c == operations_accepted);
330
343
  let converged = all_same && operations_applied_per_replica.len() == replica_count;
331
344
 
332
345
  // Latency percentiles
@@ -401,7 +414,8 @@ async fn measure_combination(
401
414
  _ => 1.0,
402
415
  };
403
416
 
404
- let expected_throughput = BASELINE_14C_SINGLE_WRITER_2_REPLICA * replica_factor * backlog_factor * writer_factor;
417
+ let expected_throughput =
418
+ BASELINE_14C_SINGLE_WRITER_2_REPLICA * replica_factor * backlog_factor * writer_factor;
405
419
 
406
420
  let interaction_ratio = if expected_throughput > 0.0 {
407
421
  throughput_ops_sec / expected_throughput
@@ -421,7 +435,10 @@ async fn measure_combination(
421
435
  "compositional".to_string()
422
436
  };
423
437
 
424
- let correctness_check = converged && operations_applied_per_replica.iter().all(|&c| c == operations_accepted);
438
+ let correctness_check = converged
439
+ && operations_applied_per_replica
440
+ .iter()
441
+ .all(|&c| c == operations_accepted);
425
442
  let correctness_status = if correctness_check { "PASS" } else { "FAIL" };
426
443
 
427
444
  CombinationMetrics {
@@ -442,13 +459,15 @@ async fn measure_combination(
442
459
  end_to_end_latency_p99_us: p99_e2e,
443
460
  target_backlog_depth: backlog_depth,
444
461
  actual_max_pending_depth: backlog_depth.min(operations_accepted),
445
- backlog_drain_rate_ops_sec: if backlog_depth > 0 && submission_duration.as_secs_f64() > 0.0 {
462
+ backlog_drain_rate_ops_sec: if backlog_depth > 0 && submission_duration.as_secs_f64() > 0.0
463
+ {
446
464
  backlog_depth as f64 / submission_duration.as_secs_f64()
447
465
  } else {
448
466
  0.0
449
467
  },
450
468
  operations_waiting_on_causal_barrier: backlog_depth.min(operations_accepted),
451
- operations_ready_to_apply: (operations_accepted as isize - backlog_depth as isize).max(0) as usize,
469
+ operations_ready_to_apply: (operations_accepted as isize - backlog_depth as isize).max(0)
470
+ as usize,
452
471
  median_wait_time_for_barrier_us: if backlog_depth > 0 { 100 } else { 0 },
453
472
  p99_wait_time_for_barrier_us: if backlog_depth > 0 { 500 } else { 0 },
454
473
  replication_messages_sent: operations_accepted * (replica_count - 1),
@@ -492,7 +511,10 @@ fn main() {
492
511
  println!(" Writers: {:?}", WRITERS);
493
512
  println!(" Causal backlog depths: {:?}", BACKLOG_DEPTHS);
494
513
  println!(" Replica counts: {:?}", REPLICA_COUNTS);
495
- println!(" Total combinations: {}\n", WRITERS.len() * BACKLOG_DEPTHS.len() * REPLICA_COUNTS.len());
514
+ println!(
515
+ " Total combinations: {}\n",
516
+ WRITERS.len() * BACKLOG_DEPTHS.len() * REPLICA_COUNTS.len()
517
+ );
496
518
 
497
519
  let mut all_results = Vec::new();
498
520
  let mut combination_count = 0;
@@ -501,52 +523,108 @@ fn main() {
501
523
  for &backlog_depth in BACKLOG_DEPTHS {
502
524
  for &replica_count in REPLICA_COUNTS {
503
525
  combination_count += 1;
504
- print!("\n[{}/75] Writers={} Backlog={} Replicas={}... ",
505
- combination_count, writer_count, backlog_depth, replica_count);
526
+ print!(
527
+ "\n[{}/75] Writers={} Backlog={} Replicas={}... ",
528
+ combination_count, writer_count, backlog_depth, replica_count
529
+ );
506
530
  std::io::Write::flush(&mut std::io::stdout()).unwrap();
507
531
 
508
- let result = rt.block_on(measure_combination(writer_count, backlog_depth, replica_count));
532
+ let result = rt.block_on(measure_combination(
533
+ writer_count,
534
+ backlog_depth,
535
+ replica_count,
536
+ ));
509
537
 
510
538
  if result.correctness_status != "PASS" {
511
539
  println!("❌ FAILED");
512
540
  println!("\n⚠️ CORRECTNESS VIOLATION DETECTED");
513
541
  println!(" Expected state_hash to match across all replicas");
514
- println!(" Configuration: writers={} backlog={} replicas={}",
515
- writer_count, backlog_depth, replica_count);
542
+ println!(
543
+ " Configuration: writers={} backlog={} replicas={}",
544
+ writer_count, backlog_depth, replica_count
545
+ );
516
546
  std::process::exit(1);
517
547
  }
518
548
 
519
549
  println!("✓");
520
550
 
521
551
  // Detailed output
522
- println!("\n{:-^60}", format!("Writers={} Backlog={} Replicas={}", writer_count, backlog_depth, replica_count));
552
+ println!(
553
+ "\n{:-^60}",
554
+ format!(
555
+ "Writers={} Backlog={} Replicas={}",
556
+ writer_count, backlog_depth, replica_count
557
+ )
558
+ );
523
559
 
524
560
  println!("\nADMISSION:");
525
561
  println!(" operations_attempted: {}", result.operations_attempted);
526
- println!(" operations_accepted: {}", result.operations_first_attempt_accepted);
527
- println!(" operations_rejected: {}", result.operations_permanent_reject);
528
- println!(" acceptance_rate_percent: {:.1}%", result.acceptance_rate_percent);
562
+ println!(
563
+ " operations_accepted: {}",
564
+ result.operations_first_attempt_accepted
565
+ );
566
+ println!(
567
+ " operations_rejected: {}",
568
+ result.operations_permanent_reject
569
+ );
570
+ println!(
571
+ " acceptance_rate_percent: {:.1}%",
572
+ result.acceptance_rate_percent
573
+ );
529
574
 
530
575
  println!("\nPERFORMANCE:");
531
576
  println!(" throughput_ops_sec: {:.3}", result.throughput_ops_sec);
532
- println!(" admission_latency_p50_us: {}", result.admission_latency_p50_us);
533
- println!(" admission_latency_p95_us: {}", result.admission_latency_p95_us);
534
- println!(" admission_latency_p99_us: {}", result.admission_latency_p99_us);
535
- println!(" end_to_end_latency_p50_us: {}", result.end_to_end_latency_p50_us);
536
- println!(" end_to_end_latency_p95_us: {}", result.end_to_end_latency_p95_us);
537
- println!(" end_to_end_latency_p99_us: {}", result.end_to_end_latency_p99_us);
577
+ println!(
578
+ " admission_latency_p50_us: {}",
579
+ result.admission_latency_p50_us
580
+ );
581
+ println!(
582
+ " admission_latency_p95_us: {}",
583
+ result.admission_latency_p95_us
584
+ );
585
+ println!(
586
+ " admission_latency_p99_us: {}",
587
+ result.admission_latency_p99_us
588
+ );
589
+ println!(
590
+ " end_to_end_latency_p50_us: {}",
591
+ result.end_to_end_latency_p50_us
592
+ );
593
+ println!(
594
+ " end_to_end_latency_p95_us: {}",
595
+ result.end_to_end_latency_p95_us
596
+ );
597
+ println!(
598
+ " end_to_end_latency_p99_us: {}",
599
+ result.end_to_end_latency_p99_us
600
+ );
538
601
 
539
602
  println!("\nCAUSAL BACKLOG:");
540
603
  println!(" target_backlog: {}", result.target_backlog_depth);
541
604
  println!(" actual_max_pending: {}", result.actual_max_pending_depth);
542
- println!(" drain_rate_ops_sec: {:.3}", result.backlog_drain_rate_ops_sec);
543
- println!(" operations_waiting_on_barrier: {}", result.operations_waiting_on_causal_barrier);
544
- println!(" operations_ready_to_apply: {}", result.operations_ready_to_apply);
605
+ println!(
606
+ " drain_rate_ops_sec: {:.3}",
607
+ result.backlog_drain_rate_ops_sec
608
+ );
609
+ println!(
610
+ " operations_waiting_on_barrier: {}",
611
+ result.operations_waiting_on_causal_barrier
612
+ );
613
+ println!(
614
+ " operations_ready_to_apply: {}",
615
+ result.operations_ready_to_apply
616
+ );
545
617
 
546
618
  println!("\nREPLICATION:");
547
619
  println!(" messages_sent: {}", result.replication_messages_sent);
548
- println!(" messages_delivered: {}", result.replication_messages_delivered);
549
- println!(" delivery_rate_percent: {:.1}%", result.replication_delivery_success_rate_percent);
620
+ println!(
621
+ " messages_delivered: {}",
622
+ result.replication_messages_delivered
623
+ );
624
+ println!(
625
+ " delivery_rate_percent: {:.1}%",
626
+ result.replication_delivery_success_rate_percent
627
+ );
550
628
  for (i, &applied) in result.per_replica_operations_applied.iter().enumerate() {
551
629
  if i == 0 {
552
630
  println!(" operations_applied_leader: {}", applied);
@@ -556,13 +634,33 @@ fn main() {
556
634
  }
557
635
 
558
636
  println!("\nCORRECTNESS:");
559
- println!(" replicas_converged: {}", if result.all_replicas_converged { "YES" } else { "NO" });
560
- println!(" state_hashes_match: {}", if result.state_hashes_match { "YES" } else { "NO" });
637
+ println!(
638
+ " replicas_converged: {}",
639
+ if result.all_replicas_converged {
640
+ "YES"
641
+ } else {
642
+ "NO"
643
+ }
644
+ );
645
+ println!(
646
+ " state_hashes_match: {}",
647
+ if result.state_hashes_match {
648
+ "YES"
649
+ } else {
650
+ "NO"
651
+ }
652
+ );
561
653
  println!(" status: {}", result.correctness_status);
562
654
 
563
655
  println!("\nINTERACTION:");
564
- println!(" observed_throughput: {:.3} ops/sec", result.throughput_ops_sec);
565
- println!(" expected_throughput: {:.3} ops/sec (composed)", result.expected_throughput_ops_sec);
656
+ println!(
657
+ " observed_throughput: {:.3} ops/sec",
658
+ result.throughput_ops_sec
659
+ );
660
+ println!(
661
+ " expected_throughput: {:.3} ops/sec (composed)",
662
+ result.expected_throughput_ops_sec
663
+ );
566
664
  println!(" interaction_ratio: {:.3}", result.interaction_ratio);
567
665
  println!(" classification: {}", result.interaction_classification);
568
666
 
@@ -576,52 +674,85 @@ fn main() {
576
674
  println!("INTERACTION ANALYSIS");
577
675
  println!("═════════════════════════════════════════════════════════════");
578
676
 
579
- let compositional: Vec<_> = all_results.iter()
677
+ let compositional: Vec<_> = all_results
678
+ .iter()
580
679
  .filter(|r| r.interaction_classification == "compositional")
581
680
  .collect();
582
- let overhead: Vec<_> = all_results.iter()
681
+ let overhead: Vec<_> = all_results
682
+ .iter()
583
683
  .filter(|r| r.interaction_classification == "overhead")
584
684
  .collect();
585
- let nonlinear: Vec<_> = all_results.iter()
685
+ let nonlinear: Vec<_> = all_results
686
+ .iter()
586
687
  .filter(|r| r.interaction_classification == "nonlinear")
587
688
  .collect();
588
- let beneficial: Vec<_> = all_results.iter()
689
+ let beneficial: Vec<_> = all_results
690
+ .iter()
589
691
  .filter(|r| r.interaction_classification == "beneficial")
590
692
  .collect();
591
693
 
592
694
  println!("\nComposition Summary:");
593
- println!(" Compositional (ratio ~1.0): {} combinations", compositional.len());
695
+ println!(
696
+ " Compositional (ratio ~1.0): {} combinations",
697
+ compositional.len()
698
+ );
594
699
  if let Some(first) = compositional.first() {
595
- println!(" Example: writers={} backlog={} replicas={}", first.writers, first.backlog_depth, first.replica_count);
700
+ println!(
701
+ " Example: writers={} backlog={} replicas={}",
702
+ first.writers, first.backlog_depth, first.replica_count
703
+ );
596
704
  }
597
705
 
598
- println!(" Overhead (ratio 1.0-2.0): {} combinations", overhead.len());
706
+ println!(
707
+ " Overhead (ratio 1.0-2.0): {} combinations",
708
+ overhead.len()
709
+ );
599
710
  if let Some(first) = overhead.first() {
600
- println!(" Example: writers={} backlog={} replicas={}", first.writers, first.backlog_depth, first.replica_count);
711
+ println!(
712
+ " Example: writers={} backlog={} replicas={}",
713
+ first.writers, first.backlog_depth, first.replica_count
714
+ );
601
715
  }
602
716
 
603
717
  println!(" Nonlinear (ratio >2.0): {} combinations", nonlinear.len());
604
718
  if let Some(first) = nonlinear.first() {
605
- println!(" Example: writers={} backlog={} replicas={}", first.writers, first.backlog_depth, first.replica_count);
719
+ println!(
720
+ " Example: writers={} backlog={} replicas={}",
721
+ first.writers, first.backlog_depth, first.replica_count
722
+ );
606
723
  }
607
724
 
608
- println!(" Beneficial (ratio <1.0): {} combinations", beneficial.len());
725
+ println!(
726
+ " Beneficial (ratio <1.0): {} combinations",
727
+ beneficial.len()
728
+ );
609
729
 
610
730
  println!("\n\nOVERALL FINDING:");
611
731
  if nonlinear.is_empty() {
612
732
  println!("\n✅ Gate 14D finding: The three dimensions compose approximately independently");
613
- println!(" through the tested configuration space, with typical interaction ratio < 2.0.");
733
+ println!(
734
+ " through the tested configuration space, with typical interaction ratio < 2.0."
735
+ );
614
736
  println!(" No architectural bottlenecks identified.");
615
737
  } else {
616
738
  println!("\n⚠️ Gate 14D finding: A nonlinear interaction appears between dimensions");
617
739
  println!(" at certain configurations:");
618
740
  for (i, result) in nonlinear.iter().take(3).enumerate() {
619
- println!(" {}. writers={} backlog={} replicas={} (ratio: {:.2})",
620
- i + 1, result.writers, result.backlog_depth, result.replica_count, result.interaction_ratio);
741
+ println!(
742
+ " {}. writers={} backlog={} replicas={} (ratio: {:.2})",
743
+ i + 1,
744
+ result.writers,
745
+ result.backlog_depth,
746
+ result.replica_count,
747
+ result.interaction_ratio
748
+ );
621
749
  }
622
750
  }
623
751
 
624
752
  println!("\n═════════════════════════════════════════════════════════════");
625
- println!("Gate 14D measurement complete: {} combinations verified.", all_results.len());
753
+ println!(
754
+ "Gate 14D measurement complete: {} combinations verified.",
755
+ all_results.len()
756
+ );
626
757
  println!("═════════════════════════════════════════════════════════════\n");
627
758
  }
@@ -7,17 +7,16 @@
7
7
  ///
8
8
  /// Key principle: Don't declare victory from a microbenchmark.
9
9
  /// Systematically measure: latency, examination counts, memory, concurrency.
10
-
11
- use criterion::{black_box, criterion_group, criterion_main, Criterion, BenchmarkId};
10
+ use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
12
11
  use feltdb::causal_dependency_barrier::CausalDependencyBarrier;
13
12
  use feltdb::convergence::VectorClock;
14
13
 
15
14
  /// Benchmark workload configuration
16
15
  #[derive(Clone, Debug)]
17
16
  struct BenchmarkWorkload {
18
- pending_size: usize, // 10, 100, 1K, 10K, 100K
19
- frontier_advances: usize, // 1, 10
20
- release_selectivity: f64, // Fraction of operations that will be released
17
+ pending_size: usize, // 10, 100, 1K, 10K, 100K
18
+ frontier_advances: usize, // 1, 10
19
+ release_selectivity: f64, // Fraction of operations that will be released
21
20
  }
22
21
 
23
22
  /// Metrics collected during a benchmark run
@@ -46,8 +45,7 @@ impl ReleaseMetrics {
46
45
  if self.ref_pending_examined == 0 {
47
46
  0.0
48
47
  } else {
49
- (1.0 - (self.opt_candidates_examined as f64 / self.ref_pending_examined as f64))
50
- * 100.0
48
+ (1.0 - (self.opt_candidates_examined as f64 / self.ref_pending_examined as f64)) * 100.0
51
49
  }
52
50
  }
53
51
 
@@ -62,7 +60,10 @@ impl ReleaseMetrics {
62
60
  }
63
61
 
64
62
  /// Generate a benchmark workload with reproducible randomness
65
- fn generate_workload(workload: &BenchmarkWorkload, seed: u64) -> (Vec<(String, VectorClock)>, Vec<VectorClock>) {
63
+ fn generate_workload(
64
+ workload: &BenchmarkWorkload,
65
+ seed: u64,
66
+ ) -> (Vec<(String, VectorClock)>, Vec<VectorClock>) {
66
67
  use std::collections::hash_map::DefaultHasher;
67
68
  use std::hash::{Hash, Hasher};
68
69
 
@@ -71,7 +72,9 @@ fn generate_workload(workload: &BenchmarkWorkload, seed: u64) -> (Vec<(String, V
71
72
  let mut rng_seed = hasher.finish();
72
73
 
73
74
  fn next_rng(seed: &mut u64) -> u64 {
74
- *seed = seed.wrapping_mul(6364136223846793005).wrapping_add(1442695040888963407);
75
+ *seed = seed
76
+ .wrapping_mul(6364136223846793005)
77
+ .wrapping_add(1442695040888963407);
75
78
  *seed
76
79
  }
77
80
 
@@ -82,7 +85,8 @@ fn generate_workload(workload: &BenchmarkWorkload, seed: u64) -> (Vec<(String, V
82
85
  for i in 0..workload.pending_size {
83
86
  let mut required = VectorClock::new();
84
87
  // Create dependency that will be satisfied based on selectivity
85
- let release_threshold = (workload.pending_size as f64 * workload.release_selectivity) as usize;
88
+ let release_threshold =
89
+ (workload.pending_size as f64 * workload.release_selectivity) as usize;
86
90
  let ts = if i < release_threshold {
87
91
  10 // Will be released when frontier advances to 10
88
92
  } else {
@@ -188,8 +192,10 @@ fn benchmark_optimization_matrix(c: &mut Criterion) {
188
192
  let selectivities = vec![0.10]; // Start with 10% release
189
193
 
190
194
  println!("\n=== Phase 7.1.2: Optimization Matrix Metrics ===");
191
- println!("{:<8} {:<10} {:<10} {:<15} {:<15} {:<12} {:<12}",
192
- "Pending", "Advances", "Selectivity", "Ref (µs)", "Opt (µs)", "Speedup", "Candidate %");
195
+ println!(
196
+ "{:<8} {:<10} {:<10} {:<15} {:<15} {:<12} {:<12}",
197
+ "Pending", "Advances", "Selectivity", "Ref (µs)", "Opt (µs)", "Speedup", "Candidate %"
198
+ );
193
199
 
194
200
  for pending in &pending_sizes {
195
201
  for advances in &advance_counts {
@@ -209,11 +215,23 @@ fn benchmark_optimization_matrix(c: &mut Criterion) {
209
215
  let speedup = ref_metrics.ref_latency_ns as f64 / opt_metrics.opt_latency_ns as f64;
210
216
  let candidate_reduction = opt_metrics.candidate_reduction_pct();
211
217
 
212
- println!("{:<8} {:<10} {:<10.0}% {:<15.1} {:<15.1} {:<12.2}x {:<12.1}%",
213
- pending, advances, selectivity * 100.0, ref_us, opt_us, speedup, candidate_reduction);
218
+ println!(
219
+ "{:<8} {:<10} {:<10.0}% {:<15.1} {:<15.1} {:<12.2}x {:<12.1}%",
220
+ pending,
221
+ advances,
222
+ selectivity * 100.0,
223
+ ref_us,
224
+ opt_us,
225
+ speedup,
226
+ candidate_reduction
227
+ );
214
228
 
215
- let bench_name = format!("pending_{}_advances_{}_sel_{:.0}pct",
216
- pending, advances, selectivity * 100.0);
229
+ let bench_name = format!(
230
+ "pending_{}_advances_{}_sel_{:.0}pct",
231
+ pending,
232
+ advances,
233
+ selectivity * 100.0
234
+ );
217
235
 
218
236
  group.bench_with_input(
219
237
  BenchmarkId::new("reference", &bench_name),
@@ -221,7 +239,11 @@ fn benchmark_optimization_matrix(c: &mut Criterion) {
221
239
  |b, w| {
222
240
  let (ops, advs) = generate_workload(w, 42);
223
241
  b.iter(|| {
224
- benchmark_reference_release(black_box(w), black_box(&ops), black_box(&advs))
242
+ benchmark_reference_release(
243
+ black_box(w),
244
+ black_box(&ops),
245
+ black_box(&advs),
246
+ )
225
247
  });
226
248
  },
227
249
  );
@@ -232,7 +254,11 @@ fn benchmark_optimization_matrix(c: &mut Criterion) {
232
254
  |b, w| {
233
255
  let (ops, advs) = generate_workload(w, 42);
234
256
  b.iter(|| {
235
- benchmark_optimized_release(black_box(w), black_box(&ops), black_box(&advs))
257
+ benchmark_optimized_release(
258
+ black_box(w),
259
+ black_box(&ops),
260
+ black_box(&advs),
261
+ )
236
262
  });
237
263
  },
238
264
  );
@@ -253,8 +279,10 @@ fn benchmark_selectivity_variation(c: &mut Criterion) {
253
279
  let selectivities = vec![0.0, 0.01, 0.10, 0.25, 0.50, 0.75, 1.0];
254
280
 
255
281
  println!("\n=== Phase 7.1.2: Selectivity Variation Metrics ===");
256
- println!("{:<12} {:<15} {:<15} {:<12} {:<12}",
257
- "Selectivity", "Ref (µs)", "Opt (µs)", "Speedup", "Candidate %");
282
+ println!(
283
+ "{:<12} {:<15} {:<15} {:<12} {:<12}",
284
+ "Selectivity", "Ref (µs)", "Opt (µs)", "Speedup", "Candidate %"
285
+ );
258
286
 
259
287
  for selectivity in selectivities {
260
288
  let workload = BenchmarkWorkload {
@@ -276,8 +304,14 @@ fn benchmark_selectivity_variation(c: &mut Criterion) {
276
304
  };
277
305
  let candidate_reduction = opt_metrics.candidate_reduction_pct();
278
306
 
279
- println!("{:<12.0}% {:<15.1} {:<15.1} {:<12.2}x {:<12.1}%",
280
- selectivity * 100.0, ref_us, opt_us, speedup, candidate_reduction);
307
+ println!(
308
+ "{:<12.0}% {:<15.1} {:<15.1} {:<12.2}x {:<12.1}%",
309
+ selectivity * 100.0,
310
+ ref_us,
311
+ opt_us,
312
+ speedup,
313
+ candidate_reduction
314
+ );
281
315
 
282
316
  let bench_name = format!("pending_1000_sel_{:.0}pct", selectivity * 100.0);
283
317
 
@@ -319,8 +353,10 @@ fn benchmark_pathological_scaling(c: &mut Criterion) {
319
353
  let selectivity = 0.10; // 10% of pending operations become ready each advance
320
354
 
321
355
  println!("\n=== Phase 7.1.2: Pathological Scaling (10 advances) ===");
322
- println!("{:<10} {:<15} {:<15} {:<12} {:<12}",
323
- "Pending", "Ref (µs)", "Opt (µs)", "Speedup", "Candidate %");
356
+ println!(
357
+ "{:<10} {:<15} {:<15} {:<12} {:<12}",
358
+ "Pending", "Ref (µs)", "Opt (µs)", "Speedup", "Candidate %"
359
+ );
324
360
 
325
361
  for pending in &pending_sizes {
326
362
  let workload = BenchmarkWorkload {
@@ -342,8 +378,10 @@ fn benchmark_pathological_scaling(c: &mut Criterion) {
342
378
  };
343
379
  let candidate_reduction = opt_metrics.candidate_reduction_pct();
344
380
 
345
- println!("{:<10} {:<15.1} {:<15.1} {:<12.2}x {:<12.1}%",
346
- pending, ref_us, opt_us, speedup, candidate_reduction);
381
+ println!(
382
+ "{:<10} {:<15.1} {:<15.1} {:<12.2}x {:<12.1}%",
383
+ pending, ref_us, opt_us, speedup, candidate_reduction
384
+ );
347
385
 
348
386
  let bench_name = format!("pending_{}_advances_{}", pending, advance_count);
349
387