@feltdb/core 0.15.0 → 0.16.0

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 (247) hide show
  1. package/dist/agent-state.d.ts +20 -0
  2. package/dist/agent-state.d.ts.map +1 -1
  3. package/dist/agent-state.js +36 -0
  4. package/dist/build-identity.json +12 -4
  5. package/dist/cli/commands.js +187 -4
  6. package/dist/cli/publish-engine.js +116 -16
  7. package/dist/collection.d.ts.map +1 -1
  8. package/dist/collection.js +3 -0
  9. package/dist/create/build-identity.json +12 -4
  10. package/dist/create/managed-account.js +93 -35
  11. package/dist/create/package-versions.js +1 -1
  12. package/dist/create/server-source/Cargo.lock +6 -509
  13. package/dist/create/server-source/Cargo.toml +2 -13
  14. package/dist/create/server-source/crates/feltdb-client/Cargo.toml +1 -1
  15. package/dist/create/server-source/crates/feltdb-server/Cargo.toml +1 -1
  16. package/dist/create/server-source/crates/feltdb-server/src/main.rs +255 -12
  17. package/dist/create/server-source/crates/feltdb-wasm/Cargo.toml +1 -1
  18. package/dist/db.d.ts +11 -1
  19. package/dist/db.d.ts.map +1 -1
  20. package/dist/db.js +15 -2
  21. package/dist/error-codes.d.ts +5 -0
  22. package/dist/error-codes.d.ts.map +1 -1
  23. package/dist/error-codes.js +9 -1
  24. package/dist/http-db.d.ts +16 -0
  25. package/dist/http-db.d.ts.map +1 -1
  26. package/dist/http-db.js +36 -6
  27. package/dist/managed-recovery.d.ts +6 -0
  28. package/dist/managed-recovery.d.ts.map +1 -1
  29. package/dist/managed-recovery.js +9 -0
  30. package/dist/studio-app/assets/{feltdb_wasm-BjM1ylL3.js → feltdb_wasm-DtybUY0q.js} +1 -1
  31. package/dist/studio-app/assets/feltdb_wasm_bg-DsgIUwaB.wasm +0 -0
  32. package/dist/studio-app/assets/index-C4OffsZl.js +37 -0
  33. package/dist/studio-app/index.html +1 -1
  34. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  35. package/dist/wasm/package.json +1 -1
  36. package/dist/workload.d.ts +55 -3
  37. package/dist/workload.d.ts.map +1 -1
  38. package/dist/workload.js +23 -0
  39. package/dist/workspace/workspace-connection.d.ts.map +1 -1
  40. package/dist/workspace/workspace-connection.js +14 -3
  41. package/package.json +1 -1
  42. package/dist/create/server-source/crates/feltdb/Cargo.lock +0 -175
  43. package/dist/create/server-source/crates/feltdb/Cargo.toml +0 -102
  44. package/dist/create/server-source/crates/feltdb/LICENSE +0 -21
  45. package/dist/create/server-source/crates/feltdb/README.md +0 -75
  46. package/dist/create/server-source/crates/feltdb/benches/baselines/gate-13-redux.json +0 -370
  47. package/dist/create/server-source/crates/feltdb/benches/gate13_baseline.rs +0 -589
  48. package/dist/create/server-source/crates/feltdb/benches/gate13_phase_7_1_release_economics.rs +0 -247
  49. package/dist/create/server-source/crates/feltdb/benches/gate_13_redux.rs +0 -440
  50. package/dist/create/server-source/crates/feltdb/benches/gate_13_regression_runner.rs +0 -275
  51. package/dist/create/server-source/crates/feltdb/benches/gate_14a_concurrent_writer_scaling.rs +0 -381
  52. package/dist/create/server-source/crates/feltdb/benches/gate_14a_production_admission_revalidation.rs +0 -467
  53. package/dist/create/server-source/crates/feltdb/benches/gate_14a_rc2_admission_contract.rs +0 -489
  54. package/dist/create/server-source/crates/feltdb/benches/gate_14a_rc_root_cause.rs +0 -281
  55. package/dist/create/server-source/crates/feltdb/benches/gate_14a_sync1_queued_prototype.rs +0 -606
  56. package/dist/create/server-source/crates/feltdb/benches/gate_14a_sync_economics.rs +0 -531
  57. package/dist/create/server-source/crates/feltdb/benches/gate_14b_causal_backlog_scaling.rs +0 -462
  58. package/dist/create/server-source/crates/feltdb/benches/gate_14c_replication_contract_test.rs +0 -505
  59. package/dist/create/server-source/crates/feltdb/benches/gate_14c_replication_scaling.rs +0 -484
  60. package/dist/create/server-source/crates/feltdb/benches/gate_14d_combined_dimension_scaling.rs +0 -758
  61. package/dist/create/server-source/crates/feltdb/benches/phase_7_1_2_optimization_benchmark.rs +0 -421
  62. package/dist/create/server-source/crates/feltdb/benches/phase_7_1_3_crossover_analysis.rs +0 -329
  63. package/dist/create/server-source/crates/feltdb/src/acceptance_tests.rs +0 -1705
  64. package/dist/create/server-source/crates/feltdb/src/acquisition.rs +0 -286
  65. package/dist/create/server-source/crates/feltdb/src/admission.rs +0 -185
  66. package/dist/create/server-source/crates/feltdb/src/admission_contract_tests.rs +0 -507
  67. package/dist/create/server-source/crates/feltdb/src/adversarial_transport.rs +0 -539
  68. package/dist/create/server-source/crates/feltdb/src/agent_state.rs +0 -320
  69. package/dist/create/server-source/crates/feltdb/src/agent_transition_contract.rs +0 -1545
  70. package/dist/create/server-source/crates/feltdb/src/analytics.rs +0 -521
  71. package/dist/create/server-source/crates/feltdb/src/application.rs +0 -2674
  72. package/dist/create/server-source/crates/feltdb/src/application_runtime.rs +0 -1070
  73. package/dist/create/server-source/crates/feltdb/src/authority.rs +0 -479
  74. package/dist/create/server-source/crates/feltdb/src/authority_failover.rs +0 -847
  75. package/dist/create/server-source/crates/feltdb/src/authorization.rs +0 -1030
  76. package/dist/create/server-source/crates/feltdb/src/authorization_security_tests.rs +0 -1122
  77. package/dist/create/server-source/crates/feltdb/src/bin/feltdb-authority-client.rs +0 -32
  78. package/dist/create/server-source/crates/feltdb/src/bin/feltdb-authority.rs +0 -19
  79. package/dist/create/server-source/crates/feltdb/src/bin/feltdb_node.rs +0 -1474
  80. package/dist/create/server-source/crates/feltdb/src/capabilities/mod.rs +0 -8
  81. package/dist/create/server-source/crates/feltdb/src/capabilities/search.rs +0 -418
  82. package/dist/create/server-source/crates/feltdb/src/capabilities/vector.rs +0 -482
  83. package/dist/create/server-source/crates/feltdb/src/capability.rs +0 -903
  84. package/dist/create/server-source/crates/feltdb/src/cardinality_diagnostics.rs +0 -263
  85. package/dist/create/server-source/crates/feltdb/src/cardinality_endpoint.rs +0 -77
  86. package/dist/create/server-source/crates/feltdb/src/causal_backlog_bound.rs +0 -496
  87. package/dist/create/server-source/crates/feltdb/src/causal_dependency_barrier.rs +0 -2574
  88. package/dist/create/server-source/crates/feltdb/src/causal_dependency_barrier_phase_7_1.rs +0 -212
  89. package/dist/create/server-source/crates/feltdb/src/concurrency_fuzzing.rs +0 -422
  90. package/dist/create/server-source/crates/feltdb/src/consistency_contract.rs +0 -445
  91. package/dist/create/server-source/crates/feltdb/src/content_distribution.rs +0 -465
  92. package/dist/create/server-source/crates/feltdb/src/convergence.rs +0 -634
  93. package/dist/create/server-source/crates/feltdb/src/crash_atomic_boundary.rs +0 -427
  94. package/dist/create/server-source/crates/feltdb/src/crash_injection.rs +0 -376
  95. package/dist/create/server-source/crates/feltdb/src/crash_recovery_tests.rs +0 -365
  96. package/dist/create/server-source/crates/feltdb/src/cron.rs +0 -294
  97. package/dist/create/server-source/crates/feltdb/src/dedup_bound_investigation.rs +0 -483
  98. package/dist/create/server-source/crates/feltdb/src/distributed_indexing.rs +0 -477
  99. package/dist/create/server-source/crates/feltdb/src/distributed_tests.rs +0 -1003
  100. package/dist/create/server-source/crates/feltdb/src/distributed_transactions.rs +0 -1334
  101. package/dist/create/server-source/crates/feltdb/src/durability_guarantees.rs +0 -368
  102. package/dist/create/server-source/crates/feltdb/src/durable_dedup_set.rs +0 -231
  103. package/dist/create/server-source/crates/feltdb/src/durable_operation_identity.rs +0 -482
  104. package/dist/create/server-source/crates/feltdb/src/durable_operation_log.rs +0 -203
  105. package/dist/create/server-source/crates/feltdb/src/durable_sync.rs +0 -317
  106. package/dist/create/server-source/crates/feltdb/src/equality_index.rs +0 -595
  107. package/dist/create/server-source/crates/feltdb/src/execution.rs +0 -426
  108. package/dist/create/server-source/crates/feltdb/src/in_process_transport.rs +0 -214
  109. package/dist/create/server-source/crates/feltdb/src/indexing.rs +0 -776
  110. package/dist/create/server-source/crates/feltdb/src/lib.rs +0 -7365
  111. package/dist/create/server-source/crates/feltdb/src/managed_cas_tests.rs +0 -234
  112. package/dist/create/server-source/crates/feltdb/src/materialization.rs +0 -184
  113. package/dist/create/server-source/crates/feltdb/src/metrics.rs +0 -266
  114. package/dist/create/server-source/crates/feltdb/src/multi_node_convergence.rs +0 -310
  115. package/dist/create/server-source/crates/feltdb/src/multi_operation_transaction.rs +0 -736
  116. package/dist/create/server-source/crates/feltdb/src/observability.rs +0 -379
  117. package/dist/create/server-source/crates/feltdb/src/operation.rs +0 -290
  118. package/dist/create/server-source/crates/feltdb/src/operation_algebra.rs +0 -439
  119. package/dist/create/server-source/crates/feltdb/src/operation_log.rs +0 -349
  120. package/dist/create/server-source/crates/feltdb/src/p1_application_atomicity.rs +0 -332
  121. package/dist/create/server-source/crates/feltdb/src/p1_atomicity_acceptance.rs +0 -718
  122. package/dist/create/server-source/crates/feltdb/src/partition_reconciliation.rs +0 -487
  123. package/dist/create/server-source/crates/feltdb/src/peer_registry.rs +0 -166
  124. package/dist/create/server-source/crates/feltdb/src/permutation_scheduler.rs +0 -289
  125. package/dist/create/server-source/crates/feltdb/src/persistence_reality.rs +0 -566
  126. package/dist/create/server-source/crates/feltdb/src/phase1b_acceptance.rs +0 -3391
  127. package/dist/create/server-source/crates/feltdb/src/phase1c1_acceptance.rs +0 -203
  128. package/dist/create/server-source/crates/feltdb/src/phase1c2_acceptance.rs +0 -261
  129. package/dist/create/server-source/crates/feltdb/src/phase1c3_acceptance.rs +0 -502
  130. package/dist/create/server-source/crates/feltdb/src/phase1c_atomicity_proof.rs +0 -216
  131. package/dist/create/server-source/crates/feltdb/src/phase5_integration.rs +0 -303
  132. package/dist/create/server-source/crates/feltdb/src/phase5_scenarios.rs +0 -323
  133. package/dist/create/server-source/crates/feltdb/src/phase6_adversarial_scenarios.rs +0 -531
  134. package/dist/create/server-source/crates/feltdb/src/phase6_convergence_validator.rs +0 -406
  135. package/dist/create/server-source/crates/feltdb/src/phase6_persistence.rs +0 -436
  136. package/dist/create/server-source/crates/feltdb/src/phase_1c_real_tcp.rs +0 -387
  137. package/dist/create/server-source/crates/feltdb/src/phase_2a_failures.rs +0 -378
  138. package/dist/create/server-source/crates/feltdb/src/phase_2b_network.rs +0 -359
  139. package/dist/create/server-source/crates/feltdb/src/phase_2c_cascading.rs +0 -372
  140. package/dist/create/server-source/crates/feltdb/src/phase_3_durability.rs +0 -404
  141. package/dist/create/server-source/crates/feltdb/src/phase_4_baseline.rs +0 -376
  142. package/dist/create/server-source/crates/feltdb/src/phase_5_soak.rs +0 -461
  143. package/dist/create/server-source/crates/feltdb/src/policy_evaluation.rs +0 -2125
  144. package/dist/create/server-source/crates/feltdb/src/production_api.rs +0 -418
  145. package/dist/create/server-source/crates/feltdb/src/provenance.rs +0 -207
  146. package/dist/create/server-source/crates/feltdb/src/query_execution_diagnostics.rs +0 -126
  147. package/dist/create/server-source/crates/feltdb/src/query_performance.rs +0 -218
  148. package/dist/create/server-source/crates/feltdb/src/read_basis.rs +0 -257
  149. package/dist/create/server-source/crates/feltdb/src/references.rs +0 -404
  150. package/dist/create/server-source/crates/feltdb/src/replay_fuzzing.rs +0 -401
  151. package/dist/create/server-source/crates/feltdb/src/replica_acknowledgements.rs +0 -501
  152. package/dist/create/server-source/crates/feltdb/src/replica_membership.rs +0 -680
  153. package/dist/create/server-source/crates/feltdb/src/replication_manager.rs +0 -163
  154. package/dist/create/server-source/crates/feltdb/src/replication_protocol.rs +0 -133
  155. package/dist/create/server-source/crates/feltdb/src/routing.rs +0 -409
  156. package/dist/create/server-source/crates/feltdb/src/semantic_decision.rs +0 -2029
  157. package/dist/create/server-source/crates/feltdb/src/semantic_query.rs +0 -599
  158. package/dist/create/server-source/crates/feltdb/src/sharding.rs +0 -549
  159. package/dist/create/server-source/crates/feltdb/src/state_conflict_contract.rs +0 -516
  160. package/dist/create/server-source/crates/feltdb/src/state_contract.rs +0 -6003
  161. package/dist/create/server-source/crates/feltdb/src/state_diff_contract.rs +0 -222
  162. package/dist/create/server-source/crates/feltdb/src/state_facade.rs +0 -320
  163. package/dist/create/server-source/crates/feltdb/src/state_hash.rs +0 -291
  164. package/dist/create/server-source/crates/feltdb/src/state_model.rs +0 -4158
  165. package/dist/create/server-source/crates/feltdb/src/state_transition_store.rs +0 -379
  166. package/dist/create/server-source/crates/feltdb/src/state_trigger.rs +0 -673
  167. package/dist/create/server-source/crates/feltdb/src/storage.rs +0 -273
  168. package/dist/create/server-source/crates/feltdb/src/submission.rs +0 -471
  169. package/dist/create/server-source/crates/feltdb/src/sync.rs +0 -495
  170. package/dist/create/server-source/crates/feltdb/src/sync_contract.rs +0 -822
  171. package/dist/create/server-source/crates/feltdb/src/tcp_transport.rs +0 -433
  172. package/dist/create/server-source/crates/feltdb/src/transaction_api.rs +0 -462
  173. package/dist/create/server-source/crates/feltdb/src/transaction_invariants.rs +0 -965
  174. package/dist/create/server-source/crates/feltdb/src/transaction_preconditions.rs +0 -1120
  175. package/dist/create/server-source/crates/feltdb/src/transactions.rs +0 -643
  176. package/dist/create/server-source/crates/feltdb/src/trigger.rs +0 -390
  177. package/dist/create/server-source/crates/feltdb/src/trigger_contract.rs +0 -749
  178. package/dist/create/server-source/crates/feltdb/src/versioned_object_substrate.rs +0 -708
  179. package/dist/create/server-source/crates/feltdb/src/worker_mesh.rs +0 -1269
  180. package/dist/create/server-source/crates/feltdb/src/workflow.rs +0 -713
  181. package/dist/create/server-source/crates/feltdb/src/workflow_acceptance_tests.rs +0 -510
  182. package/dist/create/server-source/crates/feltdb/src/workflow_integration.rs +0 -354
  183. package/dist/create/server-source/crates/feltdb/src/workflow_runtime.rs +0 -594
  184. package/dist/create/server-source/crates/feltdb/src/workload.rs +0 -4222
  185. package/dist/create/server-source/crates/feltdb/src/workload_diagnostics.rs +0 -456
  186. package/dist/create/server-source/crates/feltdb/tests/agent_state_native.rs +0 -1188
  187. package/dist/create/server-source/crates/feltdb/tests/agent_transition_contract_conformance.rs +0 -2884
  188. package/dist/create/server-source/crates/feltdb/tests/authority_process.rs +0 -297
  189. package/dist/create/server-source/crates/feltdb/tests/authority_transaction_identity.rs +0 -534
  190. package/dist/create/server-source/crates/feltdb/tests/bounded_read_contract.rs +0 -132
  191. package/dist/create/server-source/crates/feltdb/tests/branching_evidence.rs +0 -299
  192. package/dist/create/server-source/crates/feltdb/tests/common/mod.rs +0 -96
  193. package/dist/create/server-source/crates/feltdb/tests/compaction_stall_contract.rs +0 -272
  194. package/dist/create/server-source/crates/feltdb/tests/crash_durability_contract.rs +0 -467
  195. package/dist/create/server-source/crates/feltdb/tests/current_revision_authority_evidence.rs +0 -309
  196. package/dist/create/server-source/crates/feltdb/tests/durable_backup_contract.rs +0 -445
  197. package/dist/create/server-source/crates/feltdb/tests/durable_corruption_contract.rs +0 -518
  198. package/dist/create/server-source/crates/feltdb/tests/durable_format_compatibility.rs +0 -392
  199. package/dist/create/server-source/crates/feltdb/tests/feltdb_state_boundary_tests.rs +0 -850
  200. package/dist/create/server-source/crates/feltdb/tests/fixtures/agent_transition_corpus.json +0 -23340
  201. package/dist/create/server-source/crates/feltdb/tests/fixtures/state_conflict_contract_corpus.json +0 -1916
  202. package/dist/create/server-source/crates/feltdb/tests/fixtures/state_diff_contract_corpus.json +0 -1878
  203. package/dist/create/server-source/crates/feltdb/tests/fixtures/trigger_contract_corpus.json +0 -1862
  204. package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_evidence.rs +0 -123
  205. package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_substrate_completion.rs +0 -299
  206. package/dist/create/server-source/crates/feltdb/tests/local_process_ownership.rs +0 -69
  207. package/dist/create/server-source/crates/feltdb/tests/managed_incident_regression.rs +0 -191
  208. package/dist/create/server-source/crates/feltdb/tests/operational_health_contract.rs +0 -278
  209. package/dist/create/server-source/crates/feltdb/tests/pr34_query_collection.rs +0 -234
  210. package/dist/create/server-source/crates/feltdb/tests/pr35_equality_index.rs +0 -947
  211. package/dist/create/server-source/crates/feltdb/tests/pr7_self_authorization_proof.rs +0 -404
  212. package/dist/create/server-source/crates/feltdb/tests/pr8_vocabulary_assessment.rs +0 -916
  213. package/dist/create/server-source/crates/feltdb/tests/pr9_phase2_boundary_tests.rs +0 -1045
  214. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3a_path_a_tests.rs +0 -347
  215. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_authorized_mutations.rs +0 -361
  216. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_role_based_authorization.rs +0 -330
  217. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_simple_auth_delete.rs +0 -93
  218. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_team_delete_role_authorization.rs +0 -622
  219. package/dist/create/server-source/crates/feltdb/tests/pr9_teams_role_based_access.rs +0 -517
  220. package/dist/create/server-source/crates/feltdb/tests/production_certification.rs +0 -1153
  221. package/dist/create/server-source/crates/feltdb/tests/production_contract.rs +0 -771
  222. package/dist/create/server-source/crates/feltdb/tests/production_readiness_contract.rs +0 -1383
  223. package/dist/create/server-source/crates/feltdb/tests/reconciliation_application.rs +0 -868
  224. package/dist/create/server-source/crates/feltdb/tests/reconciliation_wire_format_evidence.rs +0 -221
  225. package/dist/create/server-source/crates/feltdb/tests/replicated_history_contract.rs +0 -417
  226. package/dist/create/server-source/crates/feltdb/tests/resource_scoped_revisions.rs +0 -338
  227. package/dist/create/server-source/crates/feltdb/tests/revision_identity_contract.rs +0 -1039
  228. package/dist/create/server-source/crates/feltdb/tests/revision_model_decision.rs +0 -739
  229. package/dist/create/server-source/crates/feltdb/tests/revision_retention_boundary_evidence.rs +0 -452
  230. package/dist/create/server-source/crates/feltdb/tests/saas_authorization_integration.rs +0 -81
  231. package/dist/create/server-source/crates/feltdb/tests/saas_invitation_lifecycle.rs +0 -438
  232. package/dist/create/server-source/crates/feltdb/tests/semantic_decision.rs +0 -1165
  233. package/dist/create/server-source/crates/feltdb/tests/semantic_query.rs +0 -767
  234. package/dist/create/server-source/crates/feltdb/tests/semantic_query_contract.rs +0 -363
  235. package/dist/create/server-source/crates/feltdb/tests/state_conflict_contract_conformance.rs +0 -1799
  236. package/dist/create/server-source/crates/feltdb/tests/state_diff_contract_conformance.rs +0 -1316
  237. package/dist/create/server-source/crates/feltdb/tests/state_model_integration.rs +0 -358
  238. package/dist/create/server-source/crates/feltdb/tests/state_persistence_integration.rs +0 -365
  239. package/dist/create/server-source/crates/feltdb/tests/state_ref_authority.rs +0 -918
  240. package/dist/create/server-source/crates/feltdb/tests/state_store_boundary_evidence.rs +0 -299
  241. package/dist/create/server-source/crates/feltdb/tests/storage_independent_versioned_object_substrate.rs +0 -328
  242. package/dist/create/server-source/crates/feltdb/tests/sync_divergence_evidence.rs +0 -255
  243. package/dist/create/server-source/crates/feltdb/tests/three_way_input_boundary_evidence.rs +0 -249
  244. package/dist/create/server-source/crates/feltdb/tests/trigger_contract_conformance.rs +0 -994
  245. package/dist/create/server-source/crates/feltdb/tests/workload_envelope_contract.rs +0 -484
  246. package/dist/studio-app/assets/feltdb_wasm_bg-TseJn2Ax.wasm +0 -0
  247. package/dist/studio-app/assets/index-1wd0uKua.js +0 -30
@@ -1,531 +0,0 @@
1
- /// Gate 14A-SYNC: Synchronization Economics Measurement
2
- ///
3
- /// Objective: Characterize the cost of the current mutex-based write path.
4
- /// Measure whether lock contention or critical-section work dominates.
5
- ///
6
- /// FROZEN WORKLOAD (identical to Gate 14A/RC/RC2):
7
- /// - 1000 operations per client
8
- /// - 10,000 record dataset
9
- /// - 70% reads, 30% writes (seed: 42)
10
- /// - Consensus: Causal
11
- ///
12
- /// MEASUREMENTS (across concurrency 1 → 2 → 4 → 8 → 16 → 32 → 64):
13
- /// - Lock acquisition attempts (try_lock calls)
14
- /// - Successful acquisitions (first try + retries)
15
- /// - Failed acquisitions (retry exhaustion)
16
- /// - Lock hold duration (critical section time)
17
- /// - Lock wait duration (retry loops, backoff time)
18
- /// - Operations per successful lock acquisition
19
- /// - Retry distribution (0, 1, 2, 3+ attempts)
20
- /// - Rejection rate (%)
21
- /// - Throughput (ops/sec)
22
- /// - p50/p95/p99 latencies
23
- ///
24
- /// KEY ANALYSIS:
25
- /// Ratio = lock_wait_time / total_operation_time
26
- /// If ratio is high (lock dominates) → admission architecture is bottleneck
27
- /// If ratio is low (lock is cheap) → other subsystem is constrained
28
- use criterion::{criterion_group, criterion_main, Criterion};
29
- use feltdb::Operation;
30
- use serde_json::json;
31
- use std::sync::Arc;
32
- use std::time::{Duration, Instant};
33
-
34
- // ============================================================================
35
- // FROZEN WORKLOAD DEFINITION
36
- // ============================================================================
37
-
38
- const OPERATIONS_PER_CLIENT: usize = 1000;
39
- const RECORD_COUNT: usize = 10_000;
40
- const READ_WRITE_RATIO: f64 = 0.7;
41
- const RANDOM_SEED: u64 = 42;
42
- const CONCURRENCY_LEVELS: &[usize] = &[1, 2, 4, 8, 16, 32, 64];
43
- const TRIALS_PER_LEVEL: usize = 3;
44
-
45
- /// Seeded random number generator
46
- struct SeededRng {
47
- state: u64,
48
- }
49
-
50
- impl SeededRng {
51
- fn new(seed: u64) -> Self {
52
- SeededRng { state: seed }
53
- }
54
-
55
- fn next_u64(&mut self) -> u64 {
56
- self.state ^= self.state << 13;
57
- self.state ^= self.state >> 7;
58
- self.state ^= self.state << 17;
59
- self.state
60
- }
61
-
62
- fn next_f64(&mut self) -> f64 {
63
- ((self.next_u64() >> 11) as f64) / (1u64 << 53) as f64
64
- }
65
-
66
- fn next_range(&mut self, min: usize, max: usize) -> usize {
67
- min + ((self.next_u64() as usize) % (max - min + 1))
68
- }
69
- }
70
-
71
- // ============================================================================
72
- // WORKLOAD GENERATION
73
- // ============================================================================
74
-
75
- fn generate_operation(
76
- rng: &mut SeededRng,
77
- op_id: u64,
78
- sequence: u64,
79
- instance_id: &str,
80
- ) -> Operation {
81
- let record_key = format!("record_{}", rng.next_range(0, RECORD_COUNT - 1));
82
- let is_write = rng.next_f64() >= READ_WRITE_RATIO;
83
-
84
- let value = if is_write {
85
- json!({ "timestamp": rng.next_u64(), "data": format!("write_{}", op_id) })
86
- } else {
87
- json!({ "read": true })
88
- };
89
-
90
- Operation::insert(
91
- op_id,
92
- instance_id.to_string(),
93
- sequence,
94
- record_key,
95
- value,
96
- "json".to_string(),
97
- "default".to_string(),
98
- )
99
- }
100
-
101
- fn generate_frozen_workload(instance_id: &str, client_id: usize) -> Vec<Operation> {
102
- let mut rng = SeededRng::new(RANDOM_SEED.wrapping_add(client_id as u64));
103
- let mut operations = Vec::with_capacity(OPERATIONS_PER_CLIENT);
104
-
105
- for seq in 0..OPERATIONS_PER_CLIENT as u64 {
106
- let op_id = (client_id as u64 * OPERATIONS_PER_CLIENT as u64) + seq;
107
- operations.push(generate_operation(&mut rng, op_id, seq, instance_id));
108
- }
109
-
110
- operations
111
- }
112
-
113
- // ============================================================================
114
- // LOCK ECONOMICS TRACKING
115
- // ============================================================================
116
-
117
- #[derive(Clone)]
118
- struct LockOperation {
119
- op_id: u64,
120
- operation_latency_us: u64,
121
- lock_wait_us: u64,
122
- lock_hold_us: u64,
123
- acquisition_attempts: usize,
124
- retry_count: usize,
125
- success: bool,
126
- }
127
-
128
- #[derive(Clone, Default)]
129
- struct LockStatistics {
130
- total_operations: usize,
131
- successful_operations: usize,
132
- rejected_operations: usize,
133
- total_acquisition_attempts: usize,
134
- total_lock_wait_us: u64,
135
- total_lock_hold_us: u64,
136
- ops_per_acquisition: f64,
137
- retry_distribution: [usize; 5], // [0 retries, 1, 2, 3, 4+]
138
- throughput_ops_per_sec: f64,
139
- p50_operation_latency_us: u64,
140
- p95_operation_latency_us: u64,
141
- p99_operation_latency_us: u64,
142
- lock_wait_ratio: f64, // lock_wait_time / total_operation_time
143
- critical_section_ratio: f64, // lock_hold_time / total_operation_time
144
- }
145
-
146
- impl LockStatistics {
147
- fn from_operations(ops: &[LockOperation], wall_clock_ms: f64) -> Self {
148
- let total = ops.len();
149
- let successful = ops.iter().filter(|o| o.success).count();
150
- let rejected = total - successful;
151
-
152
- let total_attempts: usize = ops.iter().map(|o| o.acquisition_attempts).sum();
153
- let total_wait: u64 = ops.iter().map(|o| o.lock_wait_us).sum();
154
- let total_hold: u64 = ops.iter().map(|o| o.lock_hold_us).sum();
155
-
156
- let ops_per_acq = if total_attempts > 0 {
157
- successful as f64 / total_attempts as f64
158
- } else {
159
- 0.0
160
- };
161
-
162
- // Retry distribution
163
- let mut retry_dist = [0; 5];
164
- for op in ops {
165
- if op.success {
166
- let idx = op.retry_count.min(4);
167
- retry_dist[idx] += 1;
168
- }
169
- }
170
-
171
- // Latency percentiles
172
- let mut latencies: Vec<u64> = ops.iter().map(|o| o.operation_latency_us).collect();
173
- latencies.sort_unstable();
174
-
175
- let p50 = if !latencies.is_empty() {
176
- latencies[latencies.len() / 2]
177
- } else {
178
- 0
179
- };
180
- let p95 = if !latencies.is_empty() {
181
- latencies[(latencies.len() * 95) / 100]
182
- } else {
183
- 0
184
- };
185
- let p99 = if !latencies.is_empty() {
186
- latencies[(latencies.len() * 99) / 100]
187
- } else {
188
- 0
189
- };
190
-
191
- let total_operation_time_us: u64 = ops.iter().map(|o| o.operation_latency_us).sum();
192
- let throughput = if wall_clock_ms > 0.0 {
193
- (successful as f64 / wall_clock_ms) * 1000.0
194
- } else {
195
- 0.0
196
- };
197
-
198
- let wait_ratio = if total_operation_time_us > 0 {
199
- total_wait as f64 / total_operation_time_us as f64
200
- } else {
201
- 0.0
202
- };
203
-
204
- let hold_ratio = if total_operation_time_us > 0 {
205
- total_hold as f64 / total_operation_time_us as f64
206
- } else {
207
- 0.0
208
- };
209
-
210
- LockStatistics {
211
- total_operations: total,
212
- successful_operations: successful,
213
- rejected_operations: rejected,
214
- total_acquisition_attempts: total_attempts,
215
- total_lock_wait_us: total_wait,
216
- total_lock_hold_us: total_hold,
217
- ops_per_acquisition: ops_per_acq,
218
- retry_distribution: retry_dist,
219
- throughput_ops_per_sec: throughput,
220
- p50_operation_latency_us: p50,
221
- p95_operation_latency_us: p95,
222
- p99_operation_latency_us: p99,
223
- lock_wait_ratio: wait_ratio,
224
- critical_section_ratio: hold_ratio,
225
- }
226
- }
227
- }
228
-
229
- // ============================================================================
230
- // MEASUREMENT WITH LOCK INSTRUMENTATION
231
- // ============================================================================
232
-
233
- async fn measure_synchronization_economics(concurrency: usize) -> (LockStatistics, usize) {
234
- let operation_log = Arc::new(tokio::sync::Mutex::new(Vec::new()));
235
- let measurements = Arc::new(tokio::sync::Mutex::new(Vec::new()));
236
- let start_time = Instant::now();
237
- let mut handles = vec![];
238
-
239
- for client_id in 0..concurrency {
240
- let log = Arc::clone(&operation_log);
241
- let meas = Arc::clone(&measurements);
242
- let instance_id = format!("node_{}", client_id);
243
-
244
- let handle = tokio::spawn(async move {
245
- let operations = generate_frozen_workload(&instance_id, client_id);
246
-
247
- for op in operations.iter() {
248
- let op_id = op.op_id;
249
- let op_start = Instant::now();
250
- let mut total_wait_us = 0u64;
251
- let mut total_hold_us = 0u64;
252
- let mut acquisition_attempts = 0;
253
- let mut retry_count = 0;
254
- let mut success = false;
255
-
256
- // Try once without waiting
257
- let try_start = Instant::now();
258
- if let Ok(mut log_guard) = log.try_lock() {
259
- let hold_start = Instant::now();
260
- log_guard.push(op.clone());
261
- total_hold_us = hold_start.elapsed().as_micros() as u64;
262
- acquisition_attempts = 1;
263
- success = true;
264
- } else {
265
- // Record initial attempt failure
266
- total_wait_us += try_start.elapsed().as_micros() as u64;
267
- acquisition_attempts = 1;
268
-
269
- // Retry with exponential backoff (matching Gate 14A: 3 retries)
270
- for attempt in 1..=3 {
271
- let backoff_us = 100_u64 * (2_u64).saturating_pow(attempt as u32);
272
- let sleep_start = Instant::now();
273
- tokio::time::sleep(Duration::from_micros(backoff_us)).await;
274
- total_wait_us += sleep_start.elapsed().as_micros() as u64;
275
-
276
- let try_start = Instant::now();
277
- if let Ok(mut log_guard) = log.try_lock() {
278
- let hold_start = Instant::now();
279
- log_guard.push(op.clone());
280
- total_hold_us = hold_start.elapsed().as_micros() as u64;
281
- acquisition_attempts += 1;
282
- retry_count = attempt;
283
- success = true;
284
- break;
285
- } else {
286
- total_wait_us += try_start.elapsed().as_micros() as u64;
287
- acquisition_attempts += 1;
288
- }
289
- }
290
- }
291
-
292
- let operation_latency_us = op_start.elapsed().as_micros() as u64;
293
-
294
- let lock_op = LockOperation {
295
- op_id,
296
- operation_latency_us,
297
- lock_wait_us: total_wait_us,
298
- lock_hold_us: total_hold_us,
299
- acquisition_attempts,
300
- retry_count,
301
- success,
302
- };
303
-
304
- {
305
- let mut m = meas.lock().await;
306
- m.push(lock_op);
307
- }
308
- }
309
- });
310
-
311
- handles.push(handle);
312
- }
313
-
314
- for handle in handles {
315
- let _ = handle.await;
316
- }
317
-
318
- let wall_clock_ms = start_time.elapsed().as_secs_f64() * 1000.0;
319
- let final_log = operation_log.lock().await;
320
- let ingested_count = final_log.len();
321
-
322
- let measurements_guard = measurements.lock().await;
323
- let stats = LockStatistics::from_operations(&measurements_guard, wall_clock_ms);
324
-
325
- (stats, ingested_count)
326
- }
327
-
328
- // ============================================================================
329
- // BENCHMARK HARNESS
330
- // ============================================================================
331
-
332
- fn gate_14a_sync_economics(c: &mut Criterion) {
333
- let mut group = c.benchmark_group("gate14a_sync_economics");
334
- group.sample_size(10);
335
- group.measurement_time(Duration::from_secs(5));
336
-
337
- let rt = tokio::runtime::Runtime::new().unwrap();
338
-
339
- println!("\n═══════════════════════════════════════════════════════════════════");
340
- println!("Gate 14A-SYNC: Synchronization Economics Measurement");
341
- println!("═══════════════════════════════════════════════════════════════════");
342
- println!("\nFROZEN WORKLOAD:");
343
- println!(" Operations per client: {}", OPERATIONS_PER_CLIENT);
344
- println!(" Record count: {}", RECORD_COUNT);
345
- println!(" Read/write ratio: 70% / 30%");
346
- println!(" Random seed: {}", RANDOM_SEED);
347
- println!("\nKEY MEASUREMENTS:");
348
- println!(" • Lock acquisition attempts (try_lock calls)");
349
- println!(" • Successful vs rejected acquisitions");
350
- println!(" • Lock hold duration (critical section time)");
351
- println!(" • Lock wait duration (retry + backoff)");
352
- println!(" • Critical ratio = lock_hold_time / total_operation_time");
353
- println!(" • Wait ratio = lock_wait_time / total_operation_time");
354
- println!("\nINTERPRETATION:");
355
- println!(" High wait ratio → admission contention is bottleneck");
356
- println!(" High hold ratio → critical section work is bottleneck");
357
- println!("\n───────────────────────────────────────────────────────────────────");
358
-
359
- let mut all_results: Vec<(usize, LockStatistics)> = Vec::new();
360
-
361
- println!("\nCONCURRENCY SCALING:");
362
- println!(
363
- "{:8} │ {:8} │ {:8} │ {:8} │ {:6} │ {:6} │ {:6} │ {:8}",
364
- "Writers", "Success", "Rejected", "Attempts", "Wait%", "Hold%", "Ops/acq", "Ops/sec"
365
- );
366
- println!("{}", "─".repeat(87));
367
-
368
- for &concurrency in CONCURRENCY_LEVELS {
369
- let mut trial_stats = Vec::new();
370
-
371
- for _trial in 0..TRIALS_PER_LEVEL {
372
- let (stats, _) = rt.block_on(measure_synchronization_economics(concurrency));
373
- trial_stats.push(stats);
374
- }
375
-
376
- // Average across trials
377
- let avg_success: usize = trial_stats
378
- .iter()
379
- .map(|s| s.successful_operations)
380
- .sum::<usize>()
381
- / trial_stats.len();
382
- let avg_rejected: usize = trial_stats
383
- .iter()
384
- .map(|s| s.rejected_operations)
385
- .sum::<usize>()
386
- / trial_stats.len();
387
- let avg_attempts: usize = trial_stats
388
- .iter()
389
- .map(|s| s.total_acquisition_attempts)
390
- .sum::<usize>()
391
- / trial_stats.len();
392
- let avg_wait_ratio: f64 =
393
- trial_stats.iter().map(|s| s.lock_wait_ratio).sum::<f64>() / trial_stats.len() as f64;
394
- let avg_hold_ratio: f64 = trial_stats
395
- .iter()
396
- .map(|s| s.critical_section_ratio)
397
- .sum::<f64>()
398
- / trial_stats.len() as f64;
399
- let avg_ops_per_acq: f64 = trial_stats
400
- .iter()
401
- .map(|s| s.ops_per_acquisition)
402
- .sum::<f64>()
403
- / trial_stats.len() as f64;
404
- let avg_throughput: f64 = trial_stats
405
- .iter()
406
- .map(|s| s.throughput_ops_per_sec)
407
- .sum::<f64>()
408
- / trial_stats.len() as f64;
409
-
410
- println!(
411
- "{:8} │ {:8} │ {:8} │ {:8} │ {:5.1}% │ {:5.1}% │ {:6.2} │ {:8.0}",
412
- concurrency,
413
- avg_success,
414
- avg_rejected,
415
- avg_attempts,
416
- avg_wait_ratio * 100.0,
417
- avg_hold_ratio * 100.0,
418
- avg_ops_per_acq,
419
- avg_throughput
420
- );
421
-
422
- // Store first trial for detailed analysis
423
- all_results.push((concurrency, trial_stats[0].clone()));
424
- }
425
-
426
- println!("─────────────────────────────────────────────────────────────────");
427
-
428
- // =========================================================================
429
- // DETAILED ANALYSIS AT KEY CONCURRENCY POINTS
430
- // =========================================================================
431
-
432
- println!("\nDETAILED ANALYSIS:");
433
- println!("\n┌─ Concurrency Boundary Analysis ─────────────────────────────────┐");
434
-
435
- if let Some((_, stats_1)) = all_results.iter().find(|(c, _)| *c == 1) {
436
- if let Some((_, stats_8)) = all_results.iter().find(|(c, _)| *c == 8) {
437
- println!("│ Single writer (baseline):");
438
- println!(
439
- "│ Wait ratio: {:.2}% | Hold ratio: {:.2}% | Throughput: {:.0} ops/sec",
440
- stats_1.lock_wait_ratio * 100.0,
441
- stats_1.critical_section_ratio * 100.0,
442
- stats_1.throughput_ops_per_sec
443
- );
444
- println!("│");
445
- println!("│ Eight writers (scaling challenge):");
446
- println!(
447
- "│ Wait ratio: {:.2}% | Hold ratio: {:.2}% | Throughput: {:.0} ops/sec",
448
- stats_8.lock_wait_ratio * 100.0,
449
- stats_8.critical_section_ratio * 100.0,
450
- stats_8.throughput_ops_per_sec
451
- );
452
- println!("│");
453
-
454
- let wait_increase = stats_8.lock_wait_ratio / stats_1.lock_wait_ratio;
455
- let hold_increase = stats_8.critical_section_ratio / stats_1.critical_section_ratio;
456
-
457
- println!("│ Ratio increase from 1→8 writers:");
458
- println!("│ Lock wait contention: {:.1}x", wait_increase);
459
- println!("│ Critical section: {:.1}x", hold_increase);
460
-
461
- if wait_increase > hold_increase * 2.0 {
462
- println!("│");
463
- println!("│ ⚠ BOTTLENECK IDENTIFIED:");
464
- println!("│ Lock acquisition contention dominates");
465
- println!("│ (wait ratio increase >> hold ratio increase)");
466
- } else if hold_increase > wait_increase * 2.0 {
467
- println!("│");
468
- println!("│ ⚠ BOTTLENECK IDENTIFIED:");
469
- println!("│ Critical section work dominates");
470
- println!("│ (hold ratio increase >> wait ratio increase)");
471
- } else {
472
- println!("│");
473
- println!("│ ✓ BALANCED CONTENTION:");
474
- println!("│ Both lock wait and hold scale proportionally");
475
- }
476
- }
477
- }
478
-
479
- println!("└──────────────────────────────────────────────────────────────┘");
480
-
481
- // =========================================================================
482
- // RETRY DISTRIBUTION AT HIGH CONCURRENCY
483
- // =========================================================================
484
-
485
- println!("\nRETRY DISTRIBUTION (at 64 writers):");
486
- if let Some((_, stats_64)) = all_results.iter().find(|(c, _)| *c == 64) {
487
- let total_successful = stats_64.retry_distribution.iter().sum::<usize>();
488
- if total_successful > 0 {
489
- println!(
490
- " 0 retries: {} ({:.1}%)",
491
- stats_64.retry_distribution[0],
492
- (stats_64.retry_distribution[0] as f64 / total_successful as f64) * 100.0
493
- );
494
- for i in 1..4 {
495
- if stats_64.retry_distribution[i] > 0 {
496
- println!(
497
- " {} retries: {} ({:.1}%)",
498
- i,
499
- stats_64.retry_distribution[i],
500
- (stats_64.retry_distribution[i] as f64 / total_successful as f64) * 100.0
501
- );
502
- }
503
- }
504
- }
505
- }
506
-
507
- println!("\n───────────────────────────────────────────────────────────────────");
508
- println!("SYNCHRONIZATION ECONOMICS SUMMARY:");
509
- println!("───────────────────────────────────────────────────────────────────");
510
- println!("\nBottleneck Analysis:");
511
- println!(" If lock_wait_ratio grows faster than critical_section_ratio");
512
- println!(" → Admission architecture is the bottleneck");
513
- println!(" → Consider: bounded queue, batching, or actor model");
514
- println!(" → Current mutex may not be appropriate for this concurrency");
515
- println!(" ");
516
- println!(" If critical_section_ratio grows faster than lock_wait_ratio");
517
- println!(" → Critical section work is the bottleneck");
518
- println!(" → Consider: reduce operations per transaction, lazy evaluation");
519
- println!(" → Mutex is not the primary constraint");
520
- println!(" ");
521
- println!(" If both grow proportionally");
522
- println!(" → Contention is unavoidable; consider load reduction");
523
- println!(" → Or verify that behavior matches concurrency theory");
524
-
525
- println!("\n═══════════════════════════════════════════════════════════════════\n");
526
-
527
- group.finish();
528
- }
529
-
530
- criterion_group!(benches, gate_14a_sync_economics);
531
- criterion_main!(benches);