create-feltdb 0.8.3 → 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 (147) hide show
  1. package/dist/create.js +25 -21
  2. package/dist/managed-account.js +11 -0
  3. package/dist/package-versions.js +1 -1
  4. package/dist/server-source/Cargo.lock +165 -0
  5. package/dist/server-source/Cargo.toml +9 -0
  6. package/dist/server-source/crates/feltdb/Cargo.toml +3 -0
  7. package/dist/server-source/crates/feltdb/benches/gate13_baseline.rs +44 -44
  8. package/dist/server-source/crates/feltdb/benches/gate13_phase_7_1_release_economics.rs +12 -24
  9. package/dist/server-source/crates/feltdb/benches/gate_13_redux.rs +7 -13
  10. package/dist/server-source/crates/feltdb/benches/gate_13_regression_runner.rs +13 -10
  11. package/dist/server-source/crates/feltdb/benches/gate_14a_concurrent_writer_scaling.rs +12 -9
  12. package/dist/server-source/crates/feltdb/benches/gate_14a_production_admission_revalidation.rs +78 -25
  13. package/dist/server-source/crates/feltdb/benches/gate_14a_rc2_admission_contract.rs +16 -13
  14. package/dist/server-source/crates/feltdb/benches/gate_14a_rc_root_cause.rs +13 -5
  15. package/dist/server-source/crates/feltdb/benches/gate_14a_sync1_queued_prototype.rs +41 -22
  16. package/dist/server-source/crates/feltdb/benches/gate_14a_sync_economics.rs +33 -15
  17. package/dist/server-source/crates/feltdb/benches/gate_14b_causal_backlog_scaling.rs +100 -33
  18. package/dist/server-source/crates/feltdb/benches/gate_14c_replication_contract_test.rs +56 -20
  19. package/dist/server-source/crates/feltdb/benches/gate_14c_replication_scaling.rs +116 -41
  20. package/dist/server-source/crates/feltdb/benches/gate_14d_combined_dimension_scaling.rs +186 -55
  21. package/dist/server-source/crates/feltdb/benches/phase_7_1_2_optimization_benchmark.rs +64 -26
  22. package/dist/server-source/crates/feltdb/benches/phase_7_1_3_crossover_analysis.rs +46 -15
  23. package/dist/server-source/crates/feltdb/src/admission.rs +8 -15
  24. package/dist/server-source/crates/feltdb/src/admission_contract_tests.rs +43 -13
  25. package/dist/server-source/crates/feltdb/src/adversarial_transport.rs +15 -42
  26. package/dist/server-source/crates/feltdb/src/analytics.rs +65 -19
  27. package/dist/server-source/crates/feltdb/src/application.rs +113 -30
  28. package/dist/server-source/crates/feltdb/src/authorization_security_tests.rs +475 -140
  29. package/dist/server-source/crates/feltdb/src/cardinality_diagnostics.rs +17 -15
  30. package/dist/server-source/crates/feltdb/src/cardinality_endpoint.rs +0 -1
  31. package/dist/server-source/crates/feltdb/src/causal_backlog_bound.rs +59 -15
  32. package/dist/server-source/crates/feltdb/src/causal_dependency_barrier.rs +266 -114
  33. package/dist/server-source/crates/feltdb/src/causal_dependency_barrier_phase_7_1.rs +25 -7
  34. package/dist/server-source/crates/feltdb/src/concurrency_fuzzing.rs +10 -15
  35. package/dist/server-source/crates/feltdb/src/consistency_contract.rs +3 -11
  36. package/dist/server-source/crates/feltdb/src/crash_atomic_boundary.rs +14 -5
  37. package/dist/server-source/crates/feltdb/src/crash_injection.rs +21 -25
  38. package/dist/server-source/crates/feltdb/src/crash_recovery_tests.rs +14 -11
  39. package/dist/server-source/crates/feltdb/src/dedup_bound_investigation.rs +103 -22
  40. package/dist/server-source/crates/feltdb/src/distributed_indexing.rs +18 -15
  41. package/dist/server-source/crates/feltdb/src/durability_guarantees.rs +12 -8
  42. package/dist/server-source/crates/feltdb/src/durable_dedup_set.rs +1 -5
  43. package/dist/server-source/crates/feltdb/src/durable_operation_identity.rs +87 -23
  44. package/dist/server-source/crates/feltdb/src/durable_operation_log.rs +3 -7
  45. package/dist/server-source/crates/feltdb/src/durable_sync.rs +10 -9
  46. package/dist/server-source/crates/feltdb/src/equality_index.rs +595 -0
  47. package/dist/server-source/crates/feltdb/src/in_process_transport.rs +1 -6
  48. package/dist/server-source/crates/feltdb/src/indexing.rs +35 -38
  49. package/dist/server-source/crates/feltdb/src/lib.rs +1050 -117
  50. package/dist/server-source/crates/feltdb/src/managed_cas_tests.rs +4 -1
  51. package/dist/server-source/crates/feltdb/src/metrics.rs +0 -1
  52. package/dist/server-source/crates/feltdb/src/multi_node_convergence.rs +1 -2
  53. package/dist/server-source/crates/feltdb/src/multi_operation_transaction.rs +107 -30
  54. package/dist/server-source/crates/feltdb/src/observability.rs +19 -6
  55. package/dist/server-source/crates/feltdb/src/operation_algebra.rs +12 -11
  56. package/dist/server-source/crates/feltdb/src/operation_log.rs +9 -4
  57. package/dist/server-source/crates/feltdb/src/p1_application_atomicity.rs +65 -18
  58. package/dist/server-source/crates/feltdb/src/p1_atomicity_acceptance.rs +193 -57
  59. package/dist/server-source/crates/feltdb/src/partition_reconciliation.rs +37 -27
  60. package/dist/server-source/crates/feltdb/src/permutation_scheduler.rs +38 -10
  61. package/dist/server-source/crates/feltdb/src/persistence_reality.rs +20 -14
  62. package/dist/server-source/crates/feltdb/src/phase1b_acceptance.rs +394 -229
  63. package/dist/server-source/crates/feltdb/src/phase1c1_acceptance.rs +8 -6
  64. package/dist/server-source/crates/feltdb/src/phase1c2_acceptance.rs +11 -13
  65. package/dist/server-source/crates/feltdb/src/phase1c3_acceptance.rs +90 -72
  66. package/dist/server-source/crates/feltdb/src/phase1c_atomicity_proof.rs +3 -3
  67. package/dist/server-source/crates/feltdb/src/phase5_integration.rs +33 -11
  68. package/dist/server-source/crates/feltdb/src/phase5_scenarios.rs +6 -6
  69. package/dist/server-source/crates/feltdb/src/phase6_adversarial_scenarios.rs +14 -56
  70. package/dist/server-source/crates/feltdb/src/phase6_convergence_validator.rs +29 -27
  71. package/dist/server-source/crates/feltdb/src/phase6_persistence.rs +35 -17
  72. package/dist/server-source/crates/feltdb/src/phase_1c_real_tcp.rs +8 -2
  73. package/dist/server-source/crates/feltdb/src/phase_2a_failures.rs +59 -15
  74. package/dist/server-source/crates/feltdb/src/phase_2b_network.rs +70 -17
  75. package/dist/server-source/crates/feltdb/src/phase_2c_cascading.rs +23 -6
  76. package/dist/server-source/crates/feltdb/src/phase_3_durability.rs +12 -3
  77. package/dist/server-source/crates/feltdb/src/phase_4_baseline.rs +41 -11
  78. package/dist/server-source/crates/feltdb/src/phase_5_soak.rs +56 -25
  79. package/dist/server-source/crates/feltdb/src/policy_evaluation.rs +701 -245
  80. package/dist/server-source/crates/feltdb/src/production_api.rs +31 -13
  81. package/dist/server-source/crates/feltdb/src/query_execution_diagnostics.rs +126 -0
  82. package/dist/server-source/crates/feltdb/src/query_performance.rs +6 -8
  83. package/dist/server-source/crates/feltdb/src/replay_fuzzing.rs +5 -5
  84. package/dist/server-source/crates/feltdb/src/replica_acknowledgements.rs +48 -18
  85. package/dist/server-source/crates/feltdb/src/replica_membership.rs +30 -11
  86. package/dist/server-source/crates/feltdb/src/replication_manager.rs +6 -3
  87. package/dist/server-source/crates/feltdb/src/replication_protocol.rs +4 -3
  88. package/dist/server-source/crates/feltdb/src/sharding.rs +36 -10
  89. package/dist/server-source/crates/feltdb/src/state_conflict_contract.rs +516 -0
  90. package/dist/server-source/crates/feltdb/src/state_contract.rs +305 -6
  91. package/dist/server-source/crates/feltdb/src/state_diff_contract.rs +222 -0
  92. package/dist/server-source/crates/feltdb/src/state_facade.rs +82 -54
  93. package/dist/server-source/crates/feltdb/src/state_hash.rs +2 -2
  94. package/dist/server-source/crates/feltdb/src/state_model.rs +1514 -537
  95. package/dist/server-source/crates/feltdb/src/state_transition_store.rs +6 -3
  96. package/dist/server-source/crates/feltdb/src/state_trigger.rs +672 -0
  97. package/dist/server-source/crates/feltdb/src/submission.rs +5 -11
  98. package/dist/server-source/crates/feltdb/src/sync.rs +12 -0
  99. package/dist/server-source/crates/feltdb/src/tcp_transport.rs +6 -8
  100. package/dist/server-source/crates/feltdb/src/transaction_api.rs +24 -35
  101. package/dist/server-source/crates/feltdb/src/transaction_invariants.rs +24 -8
  102. package/dist/server-source/crates/feltdb/src/transaction_preconditions.rs +248 -59
  103. package/dist/server-source/crates/feltdb/src/transactions.rs +17 -20
  104. package/dist/server-source/crates/feltdb/src/trigger_contract.rs +749 -0
  105. package/dist/server-source/crates/feltdb/src/worker_mesh.rs +1 -0
  106. package/dist/server-source/crates/feltdb/src/workload.rs +512 -4
  107. package/dist/server-source/crates/feltdb/src/workload_diagnostics.rs +442 -0
  108. package/dist/server-source/crates/feltdb/tests/branching_evidence.rs +299 -0
  109. package/dist/server-source/crates/feltdb/tests/current_revision_authority_evidence.rs +288 -0
  110. package/dist/server-source/crates/feltdb/tests/durable_format_compatibility.rs +392 -0
  111. package/dist/server-source/crates/feltdb/tests/feltdb_state_boundary_tests.rs +436 -220
  112. package/dist/server-source/crates/feltdb/tests/fixtures/state_conflict_contract_corpus.json +1916 -0
  113. package/dist/server-source/crates/feltdb/tests/fixtures/state_diff_contract_corpus.json +1878 -0
  114. package/dist/server-source/crates/feltdb/tests/fixtures/trigger_contract_corpus.json +1862 -0
  115. package/dist/server-source/crates/feltdb/tests/pr34_query_collection.rs +234 -0
  116. package/dist/server-source/crates/feltdb/tests/pr35_equality_index.rs +947 -0
  117. package/dist/server-source/crates/feltdb/tests/pr7_self_authorization_proof.rs +5 -8
  118. package/dist/server-source/crates/feltdb/tests/pr8_vocabulary_assessment.rs +52 -44
  119. package/dist/server-source/crates/feltdb/tests/pr9_phase2_boundary_tests.rs +33 -16
  120. package/dist/server-source/crates/feltdb/tests/pr9_phase3a_path_a_tests.rs +22 -7
  121. package/dist/server-source/crates/feltdb/tests/pr9_phase3c_authorized_mutations.rs +41 -22
  122. package/dist/server-source/crates/feltdb/tests/pr9_phase3c_role_based_authorization.rs +25 -8
  123. package/dist/server-source/crates/feltdb/tests/pr9_phase3c_simple_auth_delete.rs +9 -6
  124. package/dist/server-source/crates/feltdb/tests/pr9_phase3c_team_delete_role_authorization.rs +120 -69
  125. package/dist/server-source/crates/feltdb/tests/pr9_teams_role_based_access.rs +21 -10
  126. package/dist/server-source/crates/feltdb/tests/production_readiness_contract.rs +1032 -0
  127. package/dist/server-source/crates/feltdb/tests/reconciliation_application.rs +868 -0
  128. package/dist/server-source/crates/feltdb/tests/reconciliation_wire_format_evidence.rs +221 -0
  129. package/dist/server-source/crates/feltdb/tests/resource_scoped_revisions.rs +338 -0
  130. package/dist/server-source/crates/feltdb/tests/revision_identity_contract.rs +1039 -0
  131. package/dist/server-source/crates/feltdb/tests/revision_model_decision.rs +739 -0
  132. package/dist/server-source/crates/feltdb/tests/revision_retention_boundary_evidence.rs +427 -0
  133. package/dist/server-source/crates/feltdb/tests/saas_authorization_integration.rs +3 -3
  134. package/dist/server-source/crates/feltdb/tests/saas_invitation_lifecycle.rs +25 -22
  135. package/dist/server-source/crates/feltdb/tests/state_conflict_contract_conformance.rs +1799 -0
  136. package/dist/server-source/crates/feltdb/tests/state_diff_contract_conformance.rs +1316 -0
  137. package/dist/server-source/crates/feltdb/tests/state_model_integration.rs +53 -61
  138. package/dist/server-source/crates/feltdb/tests/state_persistence_integration.rs +156 -61
  139. package/dist/server-source/crates/feltdb/tests/state_store_boundary_evidence.rs +299 -0
  140. package/dist/server-source/crates/feltdb/tests/sync_divergence_evidence.rs +255 -0
  141. package/dist/server-source/crates/feltdb/tests/three_way_input_boundary_evidence.rs +249 -0
  142. package/dist/server-source/crates/feltdb/tests/trigger_contract_conformance.rs +994 -0
  143. package/dist/server-source/crates/feltdb-server/src/app_state.rs +2 -1
  144. package/dist/server-source/crates/feltdb-server/src/audit.rs +1137 -29
  145. package/dist/server-source/crates/feltdb-server/src/auth.rs +164 -13
  146. package/dist/server-source/crates/feltdb-server/src/main.rs +800 -34
  147. package/package.json +1 -1
package/dist/create.js CHANGED
@@ -79,8 +79,10 @@ export async function createProject(options) {
79
79
  }
80
80
  fs.writeFileSync(path.join(projectDir, 'package.json'), JSON.stringify(packageJson, null, 2));
81
81
  // Create feltdb.config.json
82
+ const deploymentMode = runtime === 'browser' ? 'browser' : runtime === 'node' ? 'local' : 'remote';
82
83
  const feltdbConfig = {
83
84
  namespace: applicationName,
85
+ mode: deploymentMode,
84
86
  runtime,
85
87
  storage: runtime === 'browser' ? 'indexeddb' : runtime === 'managed' ? 'managed' : 'durable',
86
88
  distributed,
@@ -195,13 +197,6 @@ ${hasAgents ? ` agent WorkspaceAssistant {
195
197
  }
196
198
  fs.writeFileSync(path.join(projectDir, 'tsconfig.json'), JSON.stringify(tsconfig, null, 2));
197
199
  // Create main application files
198
- const runtimeOptions = runtime === 'browser'
199
- ? "{ namespace: import.meta.env.VITE_FELTDB_NAMESPACE || '" + applicationName + "', browser: true }"
200
- : runtime === 'managed'
201
- ? "{ namespace: '" + applicationName + "', server: { url: import.meta.env.VITE_FELTDB_MANAGED_URL || '', applicationId: import.meta.env.VITE_FELTDB_MANAGED_APPLICATION_ID, environment: 'production' } }"
202
- : runtime === 'self-hosted'
203
- ? "{ namespace: import.meta.env.VITE_FELTDB_NAMESPACE || '" + applicationName + "', server: { url: import.meta.env.VITE_FELTDB_URL || 'http://localhost:7700', token: import.meta.env.VITE_FELTDB_API_KEY || '' } }"
204
- : "{ namespace: import.meta.env.VITE_FELTDB_NAMESPACE || '" + applicationName + "', memory: true }";
205
200
  const feltdbTs = `import { configureDevelopmentRuntimeBridge, createFeltDB } from '@feltdb/core';
206
201
 
207
202
  configureDevelopmentRuntimeBridge({
@@ -214,7 +209,7 @@ configureDevelopmentRuntimeBridge({
214
209
  applicationUrl: import.meta.env.VITE_FELTDB_APPLICATION_URL,
215
210
  });
216
211
 
217
- export const db = createFeltDB(${runtimeOptions});
212
+ export const db = createFeltDB();
218
213
 
219
214
  // Collections
220
215
  export const projects = db.collection('Project');
@@ -1198,7 +1193,7 @@ root.render(
1198
1193
  }
1199
1194
  fs.writeFileSync(path.join(projectDir, 'feltdb.flow'), fs.readFileSync(path.join(canonicalTemplate, 'feltdb.flow'), 'utf8').replace('app FeltDBStarter', `app ${appName}`));
1200
1195
  const databasePath = path.join(srcDir, 'feltdb.ts');
1201
- fs.writeFileSync(databasePath, fs.readFileSync(databasePath, 'utf8').replace(/export const managedRuntime[\s\S]*?\n\} : \{ namespace: import\.meta\.env\.VITE_FELTDB_NAMESPACE \|\| 'feltdb-starter', browser: true \}\);/, `export const managedRuntime = ${runtime === 'managed'};\nexport const db = createFeltDB(${runtimeOptions});`));
1196
+ fs.writeFileSync(databasePath, fs.readFileSync(databasePath, 'utf8').replace(/export const managedRuntime[\s\S]*?\n\} : \{ namespace: import\.meta\.env\.VITE_FELTDB_NAMESPACE \|\| 'feltdb-starter', browser: true \}\);/, `export const managedRuntime = ${runtime === 'managed'};\nexport const db = createFeltDB();`));
1202
1197
  }
1203
1198
  }
1204
1199
  else {
@@ -1234,18 +1229,27 @@ main().catch(console.error);
1234
1229
  const envExample = `# FeltDB Configuration
1235
1230
  # Copy this file to .env.local and update the values
1236
1231
 
1237
- # API key for authenticated self-hosted browser access
1238
- VITE_FELTDB_API_KEY=
1239
-
1240
- # FeltDB Server URL (self-hosted or managed runtime)
1241
- VITE_FELTDB_URL=http://localhost:7700
1242
-
1243
- # Managed example: https://runtime.your-app.feltdb.com
1244
- VITE_FELTDB_MANAGED_URL=
1245
- VITE_FELTDB_MANAGED_APPLICATION_ID=
1246
- # Server/control-plane only. Never rename with a VITE_ prefix.
1247
- FELTDB_MANAGED_CONTROL_API_KEY=
1248
- FELTDB_TOKEN=
1232
+ # Canonical application-plane deployment configuration consumed by createFeltDB()
1233
+ # Supported public modes: browser, local, remote
1234
+ VITE_FELTDB_MODE=${deploymentMode}
1235
+ VITE_FELTDB_NAMESPACE=${applicationName}
1236
+ VITE_FELTDB_ENVIRONMENT=development
1237
+
1238
+ # FeltDB Server URL (self-hosted or managed runtime)
1239
+ VITE_FELTDB_URL=http://localhost:7700
1240
+
1241
+ # Optional credential for authenticated remote browser access
1242
+ VITE_FELTDB_TOKEN=
1243
+ # Legacy alias accepted by older tooling
1244
+ VITE_FELTDB_API_KEY=
1245
+
1246
+ # Managed example: https://runtime.your-app.feltdb.com
1247
+ VITE_FELTDB_MANAGED_URL=
1248
+ VITE_FELTDB_MANAGED_APPLICATION_ID=
1249
+ VITE_FELTDB_APPLICATION_ID=
1250
+ # Server/control-plane only. Never rename with a VITE_ prefix.
1251
+ FELTDB_MANAGED_CONTROL_API_KEY=
1252
+ FELTDB_TOKEN=
1249
1253
 
1250
1254
  # Override the default self-hosted container image
1251
1255
  # By default the server image is built locally from the bundled source.
@@ -100,6 +100,17 @@ export async function configureManagedAccount(options) {
100
100
  }
101
101
  const environment = [
102
102
  '# Generated by create-feltdb managed setup. Do not commit this file.',
103
+ 'FELTDB_MODE=remote',
104
+ `FELTDB_URL=${apiUrl}`,
105
+ `FELTDB_APPLICATION_ID=${application.id}`,
106
+ `FELTDB_NAMESPACE=${application.namespace || options.namespace}`,
107
+ 'FELTDB_ENVIRONMENT=production',
108
+ '# Browser-safe deployment identity aliases.',
109
+ 'VITE_FELTDB_MODE=remote',
110
+ `VITE_FELTDB_URL=${apiUrl}`,
111
+ `VITE_FELTDB_APPLICATION_ID=${application.id}`,
112
+ `VITE_FELTDB_NAMESPACE=${application.namespace || options.namespace}`,
113
+ 'VITE_FELTDB_ENVIRONMENT=production',
103
114
  `VITE_FELTDB_MANAGED_URL=${apiUrl}`,
104
115
  `VITE_FELTDB_MANAGED_APPLICATION_ID=${application.id}`,
105
116
  '# Control-plane credential. Never prefix this with VITE_ or expose it to browser code.',
@@ -1,4 +1,4 @@
1
1
  // One release train keeps generated applications installable. The repository
2
2
  // validation script checks these values against every workspace manifest.
3
- export const FELTDB_PACKAGE_VERSION = '0.8.3';
3
+ export const FELTDB_PACKAGE_VERSION = '0.8.5';
4
4
  export const feltdbPackageRange = `^${FELTDB_PACKAGE_VERSION}`;
@@ -470,6 +470,12 @@ version = "1.17.0"
470
470
  source = "registry+https://github.com/rust-lang/crates.io-index"
471
471
  checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d"
472
472
 
473
+ [[package]]
474
+ name = "equivalent"
475
+ version = "1.0.2"
476
+ source = "registry+https://github.com/rust-lang/crates.io-index"
477
+ checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
478
+
473
479
  [[package]]
474
480
  name = "errno"
475
481
  version = "0.3.14"
@@ -501,6 +507,7 @@ dependencies = [
501
507
  "sha2",
502
508
  "tempfile",
503
509
  "tokio",
510
+ "wasmi",
504
511
  ]
505
512
 
506
513
  [[package]]
@@ -557,6 +564,12 @@ version = "0.1.10"
557
564
  source = "registry+https://github.com/rust-lang/crates.io-index"
558
565
  checksum = "26b73573e6edcd2af0cdf47bd6cb58f0b3839491263c314eaad1ccf24430e1de"
559
566
 
567
+ [[package]]
568
+ name = "foldhash"
569
+ version = "0.1.5"
570
+ source = "registry+https://github.com/rust-lang/crates.io-index"
571
+ checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
572
+
560
573
  [[package]]
561
574
  name = "form_urlencoded"
562
575
  version = "1.2.2"
@@ -663,6 +676,21 @@ dependencies = [
663
676
  "zerocopy",
664
677
  ]
665
678
 
679
+ [[package]]
680
+ name = "hashbrown"
681
+ version = "0.15.5"
682
+ source = "registry+https://github.com/rust-lang/crates.io-index"
683
+ checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
684
+ dependencies = [
685
+ "foldhash",
686
+ ]
687
+
688
+ [[package]]
689
+ name = "hashbrown"
690
+ version = "0.17.1"
691
+ source = "registry+https://github.com/rust-lang/crates.io-index"
692
+ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
693
+
666
694
  [[package]]
667
695
  name = "hermit-abi"
668
696
  version = "0.5.2"
@@ -886,6 +914,16 @@ dependencies = [
886
914
  "icu_properties",
887
915
  ]
888
916
 
917
+ [[package]]
918
+ name = "indexmap"
919
+ version = "2.14.2"
920
+ source = "registry+https://github.com/rust-lang/crates.io-index"
921
+ checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
922
+ dependencies = [
923
+ "equivalent",
924
+ "hashbrown 0.17.1",
925
+ ]
926
+
889
927
  [[package]]
890
928
  name = "ipnet"
891
929
  version = "2.12.1"
@@ -935,12 +973,24 @@ version = "1.5.0"
935
973
  source = "registry+https://github.com/rust-lang/crates.io-index"
936
974
  checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
937
975
 
976
+ [[package]]
977
+ name = "leb128fmt"
978
+ version = "0.1.0"
979
+ source = "registry+https://github.com/rust-lang/crates.io-index"
980
+ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
981
+
938
982
  [[package]]
939
983
  name = "libc"
940
984
  version = "0.2.189"
941
985
  source = "registry+https://github.com/rust-lang/crates.io-index"
942
986
  checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
943
987
 
988
+ [[package]]
989
+ name = "libm"
990
+ version = "0.2.16"
991
+ source = "registry+https://github.com/rust-lang/crates.io-index"
992
+ checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
993
+
944
994
  [[package]]
945
995
  name = "linux-raw-sys"
946
996
  version = "0.12.1"
@@ -1585,6 +1635,12 @@ dependencies = [
1585
1635
  "windows-sys 0.61.2",
1586
1636
  ]
1587
1637
 
1638
+ [[package]]
1639
+ name = "spin"
1640
+ version = "0.9.9"
1641
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1642
+ checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e"
1643
+
1588
1644
  [[package]]
1589
1645
  name = "spki"
1590
1646
  version = "0.7.3"
@@ -1601,6 +1657,16 @@ version = "1.2.1"
1601
1657
  source = "registry+https://github.com/rust-lang/crates.io-index"
1602
1658
  checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
1603
1659
 
1660
+ [[package]]
1661
+ name = "string-interner"
1662
+ version = "0.19.0"
1663
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1664
+ checksum = "23de088478b31c349c9ba67816fa55d9355232d63c3afea8bf513e31f0f1d2c0"
1665
+ dependencies = [
1666
+ "hashbrown 0.15.5",
1667
+ "serde",
1668
+ ]
1669
+
1604
1670
  [[package]]
1605
1671
  name = "subtle"
1606
1672
  version = "2.6.1"
@@ -1891,6 +1957,12 @@ version = "1.0.24"
1891
1957
  source = "registry+https://github.com/rust-lang/crates.io-index"
1892
1958
  checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
1893
1959
 
1960
+ [[package]]
1961
+ name = "unicode-width"
1962
+ version = "0.2.2"
1963
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1964
+ checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
1965
+
1894
1966
  [[package]]
1895
1967
  name = "untrusted"
1896
1968
  version = "0.9.0"
@@ -2018,6 +2090,99 @@ dependencies = [
2018
2090
  "unicode-ident",
2019
2091
  ]
2020
2092
 
2093
+ [[package]]
2094
+ name = "wasm-encoder"
2095
+ version = "0.258.0"
2096
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2097
+ checksum = "e974fe6821a8cf64575d51ea2194e2c8f77e7b66e9afe7419ce8a97f9ee0d251"
2098
+ dependencies = [
2099
+ "leb128fmt",
2100
+ "wasmparser 0.258.0",
2101
+ ]
2102
+
2103
+ [[package]]
2104
+ name = "wasmi"
2105
+ version = "2.0.0"
2106
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2107
+ checksum = "78693fcdd618e0fc34af59c6b8efa9ac5d58c68df940beff4bedddb6acfe7c27"
2108
+ dependencies = [
2109
+ "spin",
2110
+ "wasmi_collections",
2111
+ "wasmi_core",
2112
+ "wasmi_ir",
2113
+ "wasmparser 0.228.0",
2114
+ "wat",
2115
+ ]
2116
+
2117
+ [[package]]
2118
+ name = "wasmi_collections"
2119
+ version = "2.0.0"
2120
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2121
+ checksum = "8a8be2aa467cf2d29e96ff759472c36eeb44a3c81c67fc9cb76c9a24c519c557"
2122
+ dependencies = [
2123
+ "string-interner",
2124
+ ]
2125
+
2126
+ [[package]]
2127
+ name = "wasmi_core"
2128
+ version = "2.0.0"
2129
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2130
+ checksum = "69372d5fda3ea3d1e0aa6603c7888110e0187e88ea17cd8fc2e2df0a0e1f37fa"
2131
+ dependencies = [
2132
+ "libm",
2133
+ ]
2134
+
2135
+ [[package]]
2136
+ name = "wasmi_ir"
2137
+ version = "2.0.0"
2138
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2139
+ checksum = "8f17b774caa13c618c7244f1ee51fe23c5e7b8538a471fa46d9949779758aed6"
2140
+ dependencies = [
2141
+ "wasmi_core",
2142
+ ]
2143
+
2144
+ [[package]]
2145
+ name = "wasmparser"
2146
+ version = "0.228.0"
2147
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2148
+ checksum = "4abf1132c1fdf747d56bbc1bb52152400c70f336870f968b85e89ea422198ae3"
2149
+ dependencies = [
2150
+ "bitflags",
2151
+ "indexmap",
2152
+ ]
2153
+
2154
+ [[package]]
2155
+ name = "wasmparser"
2156
+ version = "0.258.0"
2157
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2158
+ checksum = "d9a61719f93a87b16d325921e251800c4833f8fab50fa21c7de73aed50086313"
2159
+ dependencies = [
2160
+ "bitflags",
2161
+ "indexmap",
2162
+ ]
2163
+
2164
+ [[package]]
2165
+ name = "wast"
2166
+ version = "258.0.0"
2167
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2168
+ checksum = "97f7defc7ecca8b19ac7f824598eadd0c53985ee00c74060d65051e9da5b58a1"
2169
+ dependencies = [
2170
+ "bumpalo",
2171
+ "leb128fmt",
2172
+ "memchr",
2173
+ "unicode-width",
2174
+ "wasm-encoder",
2175
+ ]
2176
+
2177
+ [[package]]
2178
+ name = "wat"
2179
+ version = "1.258.0"
2180
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2181
+ checksum = "7555c008cca87f2ac58d9f83ccda7e7b44611093ce28eb28f052e7c78024b9bf"
2182
+ dependencies = [
2183
+ "wast",
2184
+ ]
2185
+
2021
2186
  [[package]]
2022
2187
  name = "web-sys"
2023
2188
  version = "0.3.104"
@@ -1,5 +1,14 @@
1
1
  [workspace]
2
2
  members = ["crates/feltdb", "crates/feltdb-server", "crates/feltdb-wasm"]
3
+ # The deterministic contracts' WASM implementations are their own
4
+ # dependency-free workspaces: they are only ever built for
5
+ # wasm32-unknown-unknown, and a second implementation that inherited this
6
+ # workspace's dependencies would stop being an independent one.
7
+ exclude = [
8
+ "crates/feltdb-trigger-contract-wasm",
9
+ "crates/feltdb-state-diff-contract-wasm",
10
+ "crates/feltdb-state-conflict-contract-wasm",
11
+ ]
3
12
  resolver = "2"
4
13
 
5
14
  [workspace.package]
@@ -21,6 +21,9 @@ tokio = { version = "1", features = ["net", "io-util", "rt-multi-thread"] }
21
21
  criterion = { version = "0.5", features = ["html_reports"] }
22
22
  sha2 = "0.10"
23
23
  tempfile = "3"
24
+ # Host runtime for the deterministic-contract conformance suite only. It is a
25
+ # test dependency: FeltDB does not execute WASM in production.
26
+ wasmi = "2"
24
27
 
25
28
  [[bench]]
26
29
  name = "gate13_baseline"
@@ -11,11 +11,9 @@
11
11
  /// 4. Separate primitives from transaction benchmarks
12
12
  /// 5. 2D matrix: causal barrier vs buffer size × node count
13
13
  /// 6. Black box protection on all critical results
14
-
15
14
  use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
16
15
  use feltdb::{
17
- CausalDependencyBarrier, ConsistencyContractEnforcer, CrashAtomicExecutor,
18
- VectorClock,
16
+ CausalDependencyBarrier, ConsistencyContractEnforcer, CrashAtomicExecutor, VectorClock,
19
17
  };
20
18
 
21
19
  /// Helper: Create a vector clock with N nodes
@@ -179,10 +177,8 @@ fn benchmark_causal_barrier_buffer_scaling(c: &mut Criterion) {
179
177
  let _ = barrier.receive_operation(format!("op_{}", i), vc);
180
178
  }
181
179
 
182
- let result = barrier.receive_operation(
183
- format!("op_test"),
184
- black_box(required.clone()),
185
- );
180
+ let result = barrier
181
+ .receive_operation(format!("op_test"), black_box(required.clone()));
186
182
  black_box(result)
187
183
  });
188
184
  },
@@ -282,8 +278,7 @@ fn benchmark_cost_of_correctness(c: &mut Criterion) {
282
278
  let mut barrier = CausalDependencyBarrier::new();
283
279
  let required = VectorClock::new();
284
280
  b.iter(|| {
285
- let result =
286
- barrier.receive_operation("op".to_string(), black_box(required.clone()));
281
+ let result = barrier.receive_operation("op".to_string(), black_box(required.clone()));
287
282
  black_box(result)
288
283
  });
289
284
  });
@@ -360,7 +355,10 @@ fn benchmark_readiness_frontier_satisfied(c: &mut Criterion) {
360
355
  for node_count in [2, 4, 8].iter() {
361
356
  group.throughput(Throughput::Elements(1));
362
357
  group.bench_function(
363
- format!("frontier_satisfied_nodes{}_buffer{}", node_count, buffer_size),
358
+ format!(
359
+ "frontier_satisfied_nodes{}_buffer{}",
360
+ node_count, buffer_size
361
+ ),
364
362
  |b| {
365
363
  let required = make_vector_clock(*node_count);
366
364
  validate_vector_clock(&required, *node_count);
@@ -375,14 +373,13 @@ fn benchmark_readiness_frontier_satisfied(c: &mut Criterion) {
375
373
  for i in 0..*buffer_size {
376
374
  let mut unrelated = VectorClock::new();
377
375
  unrelated.increment(&format!("other_node_{}", i));
378
- let _ = barrier.receive_operation(format!("op_buffer_{}", i), unrelated);
376
+ let _ =
377
+ barrier.receive_operation(format!("op_buffer_{}", i), unrelated);
379
378
  }
380
379
 
381
380
  // Now test readiness check on satisfied requirement
382
- let result = barrier.receive_operation(
383
- "op_test".to_string(),
384
- black_box(required.clone()),
385
- );
381
+ let result = barrier
382
+ .receive_operation("op_test".to_string(), black_box(required.clone()));
386
383
  black_box(result)
387
384
  });
388
385
  },
@@ -403,7 +400,10 @@ fn benchmark_readiness_frontier_satisfied_corrected(c: &mut Criterion) {
403
400
  for node_count in [2, 4, 8].iter() {
404
401
  group.throughput(Throughput::Elements(1));
405
402
  group.bench_function(
406
- format!("frontier_satisfied_corrected_nodes{}_buffer{}", node_count, buffer_size),
403
+ format!(
404
+ "frontier_satisfied_corrected_nodes{}_buffer{}",
405
+ node_count, buffer_size
406
+ ),
407
407
  |b| {
408
408
  let required = make_vector_clock(*node_count);
409
409
  validate_vector_clock(&required, *node_count);
@@ -418,7 +418,8 @@ fn benchmark_readiness_frontier_satisfied_corrected(c: &mut Criterion) {
418
418
  for i in 0..*buffer_size {
419
419
  let mut unrelated = VectorClock::new();
420
420
  unrelated.increment(&format!("other_node_{}", i));
421
- let _ = barrier.receive_operation(format!("op_buffer_{}", i), unrelated);
421
+ let _ = barrier
422
+ .receive_operation(format!("op_buffer_{}", i), unrelated);
422
423
  }
423
424
 
424
425
  barrier
@@ -473,10 +474,8 @@ fn benchmark_readiness_frontier_missing(c: &mut Criterion) {
473
474
  }
474
475
 
475
476
  // Test readiness check on unsatisfied requirement
476
- let result = barrier.receive_operation(
477
- "op_test".to_string(),
478
- black_box(required.clone()),
479
- );
477
+ let result = barrier
478
+ .receive_operation("op_test".to_string(), black_box(required.clone()));
480
479
  black_box(result)
481
480
  });
482
481
  },
@@ -495,29 +494,32 @@ fn benchmark_frontier_advancement_release(c: &mut Criterion) {
495
494
 
496
495
  for pending_count in [10, 100].iter() {
497
496
  group.throughput(Throughput::Elements(*pending_count as u64));
498
- group.bench_function(format!("frontier_advancement_release_{}_pending", pending_count), |b| {
499
- let mut required = VectorClock::new();
500
- required.increment("node_a");
501
- required.increment("node_a"); // {node_a: 2}
502
- validate_vector_clock(&required, 1);
497
+ group.bench_function(
498
+ format!("frontier_advancement_release_{}_pending", pending_count),
499
+ |b| {
500
+ let mut required = VectorClock::new();
501
+ required.increment("node_a");
502
+ required.increment("node_a"); // {node_a: 2}
503
+ validate_vector_clock(&required, 1);
503
504
 
504
- b.iter(|| {
505
- let mut barrier = CausalDependencyBarrier::new();
505
+ b.iter(|| {
506
+ let mut barrier = CausalDependencyBarrier::new();
506
507
 
507
- // Pre-buffer N operations waiting for {node_a: 2}
508
- for i in 0..*pending_count {
509
- let _ = barrier.receive_operation(format!("op_{}", i), required.clone());
510
- }
508
+ // Pre-buffer N operations waiting for {node_a: 2}
509
+ for i in 0..*pending_count {
510
+ let _ = barrier.receive_operation(format!("op_{}", i), required.clone());
511
+ }
511
512
 
512
- // Advance frontier to {node_a: 2}, which releases all pending
513
- let mut satisfying = VectorClock::new();
514
- satisfying.increment("node_a");
515
- satisfying.increment("node_a");
513
+ // Advance frontier to {node_a: 2}, which releases all pending
514
+ let mut satisfying = VectorClock::new();
515
+ satisfying.increment("node_a");
516
+ satisfying.increment("node_a");
516
517
 
517
- barrier.advance_frontier(black_box(&satisfying));
518
- black_box(barrier.get_pending_operations())
519
- });
520
- });
518
+ barrier.advance_frontier(black_box(&satisfying));
519
+ black_box(barrier.get_pending_operations())
520
+ });
521
+ },
522
+ );
521
523
  }
522
524
 
523
525
  group.finish();
@@ -556,10 +558,8 @@ fn benchmark_causal_pathological_workload(c: &mut Criterion) {
556
558
 
557
559
  // Now test: incoming operation with already-satisfied requirement
558
560
  // This should be fast if frontier check is sufficient
559
- let result = barrier.receive_operation(
560
- "test_op".to_string(),
561
- black_box(required.clone()),
562
- );
561
+ let result =
562
+ barrier.receive_operation("test_op".to_string(), black_box(required.clone()));
563
563
  black_box(result)
564
564
  });
565
565
  });
@@ -9,7 +9,6 @@
9
9
  /// - Outcome C: Repeated advances cause O(m²) pathological rescanning
10
10
  ///
11
11
  /// Only Outcome C justifies architectural changes to release mechanism.
12
-
13
12
  use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
14
13
  use feltdb::{CausalDependencyBarrier, VectorClock};
15
14
 
@@ -44,11 +43,10 @@ fn benchmark_release_single_scan(c: &mut Criterion) {
44
43
  for i in 0..*pending_size {
45
44
  let mut required = VectorClock::new();
46
45
  // Each requires increasing timestamp: A:1000, A:1001, etc.
47
- required.clocks.insert("node_a".to_string(), (1000 + i) as u64);
48
- let _ = barrier.receive_operation(
49
- format!("pending_{}", i),
50
- required,
51
- );
46
+ required
47
+ .clocks
48
+ .insert("node_a".to_string(), (1000 + i) as u64);
49
+ let _ = barrier.receive_operation(format!("pending_{}", i), required);
52
50
  }
53
51
  barrier
54
52
  },
@@ -97,10 +95,7 @@ fn benchmark_release_selectivity(c: &mut Criterion) {
97
95
  let mut required = VectorClock::new();
98
96
  // Frontier will be at A:2000, these require A:100
99
97
  required.clocks.insert("node_a".to_string(), 100);
100
- let _ = barrier.receive_operation(
101
- format!("ready_{}", i),
102
- required,
103
- );
98
+ let _ = barrier.receive_operation(format!("ready_{}", i), required);
104
99
  }
105
100
 
106
101
  // Add blocked operations (frontier won't satisfy them yet)
@@ -108,10 +103,7 @@ fn benchmark_release_selectivity(c: &mut Criterion) {
108
103
  let mut required = VectorClock::new();
109
104
  // These require A:5000, frontier will only be at A:2000
110
105
  required.clocks.insert("node_a".to_string(), 5000);
111
- let _ = barrier.receive_operation(
112
- format!("blocked_{}", i),
113
- required,
114
- );
106
+ let _ = barrier.receive_operation(format!("blocked_{}", i), required);
115
107
  }
116
108
  barrier
117
109
  },
@@ -146,7 +138,7 @@ fn benchmark_release_selectivity(c: &mut Criterion) {
146
138
  /// - Bad: entries_examined ≈ 50,000,000 (each advance scans remaining operations)
147
139
  fn benchmark_release_pathological_repeated(c: &mut Criterion) {
148
140
  let mut group = c.benchmark_group("gate13_release_pathological_repeated");
149
- group.sample_size(5); // Fewer samples for large workload
141
+ group.sample_size(5); // Fewer samples for large workload
150
142
  group.measurement_time(std::time::Duration::from_secs(30));
151
143
 
152
144
  // Note: Using 1000 instead of 10000 to keep benchmark runtime reasonable
@@ -166,10 +158,7 @@ fn benchmark_release_pathological_repeated(c: &mut Criterion) {
166
158
  let mut required = VectorClock::new();
167
159
  // Each requires A:(i+1)
168
160
  required.clocks.insert("node_a".to_string(), (i + 1) as u64);
169
- let _ = barrier.receive_operation(
170
- format!("seq_{}", i),
171
- required,
172
- );
161
+ let _ = barrier.receive_operation(format!("seq_{}", i), required);
173
162
  }
174
163
  barrier
175
164
  },
@@ -221,12 +210,11 @@ fn benchmark_release_mixed_advances(c: &mut Criterion) {
221
210
 
222
211
  // Distribute dependencies: some low, some high
223
212
  let dependency_level = ((i * 997) % 1000) as u64 + 1;
224
- required.clocks.insert("node_a".to_string(), dependency_level);
213
+ required
214
+ .clocks
215
+ .insert("node_a".to_string(), dependency_level);
225
216
 
226
- let _ = barrier.receive_operation(
227
- format!("mixed_{}", i),
228
- required,
229
- );
217
+ let _ = barrier.receive_operation(format!("mixed_{}", i), required);
230
218
  }
231
219
  barrier
232
220
  },
@@ -24,8 +24,7 @@
24
24
  ///
25
25
  /// This is a FROZEN baseline. No further causal barrier optimization until Gate 14
26
26
  /// demonstrates that the causal release path has become a system bottleneck.
27
-
28
- use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput, BenchmarkId};
27
+ use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
29
28
  use feltdb::{CausalDependencyBarrier, VectorClock};
30
29
  use std::time::Instant;
31
30
 
@@ -51,10 +50,9 @@ fn populate_pending_operations(
51
50
  for i in 0..count {
52
51
  let mut required = create_vector_clock_with_nodes(node_count);
53
52
  // Make each operation depend on a node that hasn't been reached yet
54
- required.clocks.insert(
55
- format!("node_{}", node_count % 2),
56
- (node_count * 10) as u64,
57
- );
53
+ required
54
+ .clocks
55
+ .insert(format!("node_{}", node_count % 2), (node_count * 10) as u64);
58
56
  let _ = barrier.receive_operation(format!("op_{}", i), required);
59
57
  }
60
58
  }
@@ -246,10 +244,8 @@ fn benchmark_index_maintenance_cost(c: &mut Criterion) {
246
244
  let required = create_vector_clock_with_nodes(nodes);
247
245
  b.iter(|| {
248
246
  let mut barrier = CausalDependencyBarrier::new();
249
- let _ = barrier.receive_operation(
250
- "op_test".to_string(),
251
- black_box(required.clone()),
252
- );
247
+ let _ = barrier
248
+ .receive_operation("op_test".to_string(), black_box(required.clone()));
253
249
  black_box(barrier.get_dependency_index().entry_count())
254
250
  });
255
251
  },
@@ -291,9 +287,7 @@ fn benchmark_vector_clock_cost(c: &mut Criterion) {
291
287
  |b, &nodes| {
292
288
  let clock1 = create_vector_clock_with_nodes(nodes);
293
289
  let clock2 = create_vector_clock_with_nodes(nodes);
294
- b.iter(|| {
295
- black_box(black_box(&clock1).happens_before(black_box(&clock2)))
296
- });
290
+ b.iter(|| black_box(black_box(&clock1).happens_before(black_box(&clock2))));
297
291
  },
298
292
  );
299
293
  }