@feltdb/core 0.13.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 (300) hide show
  1. package/dist/agent-runtime.d.ts +64 -2
  2. package/dist/agent-runtime.d.ts.map +1 -1
  3. package/dist/agent-runtime.js +121 -11
  4. package/dist/agent-state.d.ts +68 -0
  5. package/dist/agent-state.d.ts.map +1 -1
  6. package/dist/agent-state.js +210 -12
  7. package/dist/agent.d.ts +10 -1
  8. package/dist/agent.d.ts.map +1 -1
  9. package/dist/agent.js +10 -1
  10. package/dist/build-identity.json +12 -4
  11. package/dist/cli/commands.js +214 -10
  12. package/dist/cli/publish-engine.js +116 -16
  13. package/dist/collection.d.ts +3 -1
  14. package/dist/collection.d.ts.map +1 -1
  15. package/dist/collection.js +33 -8
  16. package/dist/create/build-identity.json +12 -4
  17. package/dist/create/cli.js +1 -1
  18. package/dist/create/create.js +4 -6
  19. package/dist/create/managed-account.js +93 -35
  20. package/dist/create/package-versions.js +1 -1
  21. package/dist/create/server-source/Cargo.lock +8 -511
  22. package/dist/create/server-source/Cargo.toml +2 -13
  23. package/dist/create/server-source/crates/feltdb-client/Cargo.toml +1 -1
  24. package/dist/create/server-source/crates/feltdb-server/Cargo.toml +1 -1
  25. package/dist/create/server-source/crates/feltdb-server/README.md +6 -1
  26. package/dist/create/server-source/crates/feltdb-server/src/app_state.rs +9 -1
  27. package/dist/create/server-source/crates/feltdb-server/src/auth.rs +85 -25
  28. package/dist/create/server-source/crates/feltdb-server/src/backup.rs +4 -0
  29. package/dist/create/server-source/crates/feltdb-server/src/console_accounts.rs +1009 -0
  30. package/dist/create/server-source/crates/feltdb-server/src/control_authorization.rs +441 -0
  31. package/dist/create/server-source/crates/feltdb-server/src/identity.rs +68 -6
  32. package/dist/create/server-source/crates/feltdb-server/src/key_management.rs +355 -23
  33. package/dist/create/server-source/crates/feltdb-server/src/lib.rs +3 -0
  34. package/dist/create/server-source/crates/feltdb-server/src/main.rs +1134 -96
  35. package/dist/create/server-source/crates/feltdb-server/src/redaction.rs +208 -0
  36. package/dist/create/server-source/crates/feltdb-server/src/tenancy.rs +198 -19
  37. package/dist/create/server-source/crates/feltdb-server/tests/transaction_precondition_contract.rs +403 -0
  38. package/dist/create/server-source/crates/feltdb-wasm/Cargo.toml +1 -1
  39. package/dist/db.d.ts +75 -10
  40. package/dist/db.d.ts.map +1 -1
  41. package/dist/db.js +168 -29
  42. package/dist/deployment.d.ts +19 -0
  43. package/dist/deployment.d.ts.map +1 -1
  44. package/dist/deployment.js +38 -2
  45. package/dist/embedded-query.d.ts.map +1 -1
  46. package/dist/embedded-query.js +5 -4
  47. package/dist/embedded-transaction.d.ts +8 -4
  48. package/dist/embedded-transaction.d.ts.map +1 -1
  49. package/dist/embedded-transaction.js +55 -19
  50. package/dist/error-codes.d.ts +36 -2
  51. package/dist/error-codes.d.ts.map +1 -1
  52. package/dist/error-codes.js +50 -3
  53. package/dist/feltdb.d.ts +7 -0
  54. package/dist/feltdb.d.ts.map +1 -1
  55. package/dist/file-db.d.ts +27 -0
  56. package/dist/file-db.d.ts.map +1 -1
  57. package/dist/file-db.js +145 -7
  58. package/dist/http-client.d.ts +11 -3
  59. package/dist/http-client.d.ts.map +1 -1
  60. package/dist/http-client.js +27 -14
  61. package/dist/http-db.d.ts +43 -1
  62. package/dist/http-db.d.ts.map +1 -1
  63. package/dist/http-db.js +287 -59
  64. package/dist/index.js +1 -1
  65. package/dist/local-state-lock.d.ts +34 -0
  66. package/dist/local-state-lock.d.ts.map +1 -0
  67. package/dist/local-state-lock.js +225 -0
  68. package/dist/managed-recovery.d.ts +6 -0
  69. package/dist/managed-recovery.d.ts.map +1 -1
  70. package/dist/managed-recovery.js +9 -0
  71. package/dist/reactive-graph.d.ts +0 -3
  72. package/dist/reactive-graph.d.ts.map +1 -1
  73. package/dist/reactive-graph.js +11 -1
  74. package/dist/runtime-registry.d.ts +7 -2
  75. package/dist/runtime-registry.d.ts.map +1 -1
  76. package/dist/runtime-registry.js +2 -2
  77. package/dist/studio/components/index.js +1 -1
  78. package/dist/studio/{components-BSGmHfif.js → components-CJmzntBi.js} +2 -1
  79. package/dist/studio/index.js +1 -1
  80. package/dist/studio-app/assets/{feltdb_wasm-3hDngl1h.js → feltdb_wasm-DtybUY0q.js} +1 -1
  81. package/dist/studio-app/assets/feltdb_wasm_bg-DsgIUwaB.wasm +0 -0
  82. package/dist/studio-app/assets/index-C4OffsZl.js +37 -0
  83. package/dist/studio-app/index.html +1 -1
  84. package/dist/transaction.d.ts +27 -11
  85. package/dist/transaction.d.ts.map +1 -1
  86. package/dist/transaction.js +20 -14
  87. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  88. package/dist/wasm/package.json +1 -1
  89. package/dist/workload.d.ts +86 -6
  90. package/dist/workload.d.ts.map +1 -1
  91. package/dist/workload.js +51 -3
  92. package/dist/workspace/workspace-connection.d.ts.map +1 -1
  93. package/dist/workspace/workspace-connection.js +14 -3
  94. package/package.json +1 -1
  95. package/dist/create/server-source/crates/feltdb/Cargo.lock +0 -175
  96. package/dist/create/server-source/crates/feltdb/Cargo.toml +0 -102
  97. package/dist/create/server-source/crates/feltdb/LICENSE +0 -21
  98. package/dist/create/server-source/crates/feltdb/README.md +0 -75
  99. package/dist/create/server-source/crates/feltdb/benches/baselines/gate-13-redux.json +0 -370
  100. package/dist/create/server-source/crates/feltdb/benches/gate13_baseline.rs +0 -589
  101. package/dist/create/server-source/crates/feltdb/benches/gate13_phase_7_1_release_economics.rs +0 -247
  102. package/dist/create/server-source/crates/feltdb/benches/gate_13_redux.rs +0 -440
  103. package/dist/create/server-source/crates/feltdb/benches/gate_13_regression_runner.rs +0 -275
  104. package/dist/create/server-source/crates/feltdb/benches/gate_14a_concurrent_writer_scaling.rs +0 -381
  105. package/dist/create/server-source/crates/feltdb/benches/gate_14a_production_admission_revalidation.rs +0 -467
  106. package/dist/create/server-source/crates/feltdb/benches/gate_14a_rc2_admission_contract.rs +0 -489
  107. package/dist/create/server-source/crates/feltdb/benches/gate_14a_rc_root_cause.rs +0 -281
  108. package/dist/create/server-source/crates/feltdb/benches/gate_14a_sync1_queued_prototype.rs +0 -606
  109. package/dist/create/server-source/crates/feltdb/benches/gate_14a_sync_economics.rs +0 -531
  110. package/dist/create/server-source/crates/feltdb/benches/gate_14b_causal_backlog_scaling.rs +0 -462
  111. package/dist/create/server-source/crates/feltdb/benches/gate_14c_replication_contract_test.rs +0 -505
  112. package/dist/create/server-source/crates/feltdb/benches/gate_14c_replication_scaling.rs +0 -484
  113. package/dist/create/server-source/crates/feltdb/benches/gate_14d_combined_dimension_scaling.rs +0 -758
  114. package/dist/create/server-source/crates/feltdb/benches/phase_7_1_2_optimization_benchmark.rs +0 -421
  115. package/dist/create/server-source/crates/feltdb/benches/phase_7_1_3_crossover_analysis.rs +0 -329
  116. package/dist/create/server-source/crates/feltdb/src/acceptance_tests.rs +0 -1705
  117. package/dist/create/server-source/crates/feltdb/src/acquisition.rs +0 -286
  118. package/dist/create/server-source/crates/feltdb/src/admission.rs +0 -185
  119. package/dist/create/server-source/crates/feltdb/src/admission_contract_tests.rs +0 -507
  120. package/dist/create/server-source/crates/feltdb/src/adversarial_transport.rs +0 -539
  121. package/dist/create/server-source/crates/feltdb/src/agent_state.rs +0 -320
  122. package/dist/create/server-source/crates/feltdb/src/agent_transition_contract.rs +0 -1545
  123. package/dist/create/server-source/crates/feltdb/src/analytics.rs +0 -521
  124. package/dist/create/server-source/crates/feltdb/src/application.rs +0 -2674
  125. package/dist/create/server-source/crates/feltdb/src/application_runtime.rs +0 -1070
  126. package/dist/create/server-source/crates/feltdb/src/authority.rs +0 -479
  127. package/dist/create/server-source/crates/feltdb/src/authority_failover.rs +0 -847
  128. package/dist/create/server-source/crates/feltdb/src/authorization.rs +0 -1030
  129. package/dist/create/server-source/crates/feltdb/src/authorization_security_tests.rs +0 -1122
  130. package/dist/create/server-source/crates/feltdb/src/bin/feltdb-authority-client.rs +0 -32
  131. package/dist/create/server-source/crates/feltdb/src/bin/feltdb-authority.rs +0 -19
  132. package/dist/create/server-source/crates/feltdb/src/bin/feltdb_node.rs +0 -1474
  133. package/dist/create/server-source/crates/feltdb/src/capabilities/mod.rs +0 -8
  134. package/dist/create/server-source/crates/feltdb/src/capabilities/search.rs +0 -418
  135. package/dist/create/server-source/crates/feltdb/src/capabilities/vector.rs +0 -482
  136. package/dist/create/server-source/crates/feltdb/src/capability.rs +0 -903
  137. package/dist/create/server-source/crates/feltdb/src/cardinality_diagnostics.rs +0 -263
  138. package/dist/create/server-source/crates/feltdb/src/cardinality_endpoint.rs +0 -77
  139. package/dist/create/server-source/crates/feltdb/src/causal_backlog_bound.rs +0 -496
  140. package/dist/create/server-source/crates/feltdb/src/causal_dependency_barrier.rs +0 -2574
  141. package/dist/create/server-source/crates/feltdb/src/causal_dependency_barrier_phase_7_1.rs +0 -212
  142. package/dist/create/server-source/crates/feltdb/src/concurrency_fuzzing.rs +0 -422
  143. package/dist/create/server-source/crates/feltdb/src/consistency_contract.rs +0 -445
  144. package/dist/create/server-source/crates/feltdb/src/content_distribution.rs +0 -465
  145. package/dist/create/server-source/crates/feltdb/src/convergence.rs +0 -634
  146. package/dist/create/server-source/crates/feltdb/src/crash_atomic_boundary.rs +0 -427
  147. package/dist/create/server-source/crates/feltdb/src/crash_injection.rs +0 -376
  148. package/dist/create/server-source/crates/feltdb/src/crash_recovery_tests.rs +0 -365
  149. package/dist/create/server-source/crates/feltdb/src/cron.rs +0 -294
  150. package/dist/create/server-source/crates/feltdb/src/dedup_bound_investigation.rs +0 -483
  151. package/dist/create/server-source/crates/feltdb/src/distributed_indexing.rs +0 -477
  152. package/dist/create/server-source/crates/feltdb/src/distributed_tests.rs +0 -1003
  153. package/dist/create/server-source/crates/feltdb/src/distributed_transactions.rs +0 -1334
  154. package/dist/create/server-source/crates/feltdb/src/durability_guarantees.rs +0 -368
  155. package/dist/create/server-source/crates/feltdb/src/durable_dedup_set.rs +0 -231
  156. package/dist/create/server-source/crates/feltdb/src/durable_operation_identity.rs +0 -482
  157. package/dist/create/server-source/crates/feltdb/src/durable_operation_log.rs +0 -203
  158. package/dist/create/server-source/crates/feltdb/src/durable_sync.rs +0 -317
  159. package/dist/create/server-source/crates/feltdb/src/equality_index.rs +0 -595
  160. package/dist/create/server-source/crates/feltdb/src/execution.rs +0 -426
  161. package/dist/create/server-source/crates/feltdb/src/in_process_transport.rs +0 -214
  162. package/dist/create/server-source/crates/feltdb/src/indexing.rs +0 -776
  163. package/dist/create/server-source/crates/feltdb/src/lib.rs +0 -7274
  164. package/dist/create/server-source/crates/feltdb/src/managed_cas_tests.rs +0 -234
  165. package/dist/create/server-source/crates/feltdb/src/materialization.rs +0 -184
  166. package/dist/create/server-source/crates/feltdb/src/metrics.rs +0 -266
  167. package/dist/create/server-source/crates/feltdb/src/multi_node_convergence.rs +0 -310
  168. package/dist/create/server-source/crates/feltdb/src/multi_operation_transaction.rs +0 -736
  169. package/dist/create/server-source/crates/feltdb/src/observability.rs +0 -379
  170. package/dist/create/server-source/crates/feltdb/src/operation.rs +0 -290
  171. package/dist/create/server-source/crates/feltdb/src/operation_algebra.rs +0 -439
  172. package/dist/create/server-source/crates/feltdb/src/operation_log.rs +0 -349
  173. package/dist/create/server-source/crates/feltdb/src/p1_application_atomicity.rs +0 -332
  174. package/dist/create/server-source/crates/feltdb/src/p1_atomicity_acceptance.rs +0 -718
  175. package/dist/create/server-source/crates/feltdb/src/partition_reconciliation.rs +0 -487
  176. package/dist/create/server-source/crates/feltdb/src/peer_registry.rs +0 -166
  177. package/dist/create/server-source/crates/feltdb/src/permutation_scheduler.rs +0 -289
  178. package/dist/create/server-source/crates/feltdb/src/persistence_reality.rs +0 -566
  179. package/dist/create/server-source/crates/feltdb/src/phase1b_acceptance.rs +0 -3391
  180. package/dist/create/server-source/crates/feltdb/src/phase1c1_acceptance.rs +0 -203
  181. package/dist/create/server-source/crates/feltdb/src/phase1c2_acceptance.rs +0 -261
  182. package/dist/create/server-source/crates/feltdb/src/phase1c3_acceptance.rs +0 -502
  183. package/dist/create/server-source/crates/feltdb/src/phase1c_atomicity_proof.rs +0 -216
  184. package/dist/create/server-source/crates/feltdb/src/phase5_integration.rs +0 -303
  185. package/dist/create/server-source/crates/feltdb/src/phase5_scenarios.rs +0 -323
  186. package/dist/create/server-source/crates/feltdb/src/phase6_adversarial_scenarios.rs +0 -531
  187. package/dist/create/server-source/crates/feltdb/src/phase6_convergence_validator.rs +0 -406
  188. package/dist/create/server-source/crates/feltdb/src/phase6_persistence.rs +0 -436
  189. package/dist/create/server-source/crates/feltdb/src/phase_1c_real_tcp.rs +0 -387
  190. package/dist/create/server-source/crates/feltdb/src/phase_2a_failures.rs +0 -378
  191. package/dist/create/server-source/crates/feltdb/src/phase_2b_network.rs +0 -359
  192. package/dist/create/server-source/crates/feltdb/src/phase_2c_cascading.rs +0 -372
  193. package/dist/create/server-source/crates/feltdb/src/phase_3_durability.rs +0 -404
  194. package/dist/create/server-source/crates/feltdb/src/phase_4_baseline.rs +0 -376
  195. package/dist/create/server-source/crates/feltdb/src/phase_5_soak.rs +0 -461
  196. package/dist/create/server-source/crates/feltdb/src/policy_evaluation.rs +0 -2125
  197. package/dist/create/server-source/crates/feltdb/src/production_api.rs +0 -418
  198. package/dist/create/server-source/crates/feltdb/src/provenance.rs +0 -207
  199. package/dist/create/server-source/crates/feltdb/src/query_execution_diagnostics.rs +0 -126
  200. package/dist/create/server-source/crates/feltdb/src/query_performance.rs +0 -218
  201. package/dist/create/server-source/crates/feltdb/src/read_basis.rs +0 -257
  202. package/dist/create/server-source/crates/feltdb/src/references.rs +0 -404
  203. package/dist/create/server-source/crates/feltdb/src/replay_fuzzing.rs +0 -401
  204. package/dist/create/server-source/crates/feltdb/src/replica_acknowledgements.rs +0 -501
  205. package/dist/create/server-source/crates/feltdb/src/replica_membership.rs +0 -680
  206. package/dist/create/server-source/crates/feltdb/src/replication_manager.rs +0 -163
  207. package/dist/create/server-source/crates/feltdb/src/replication_protocol.rs +0 -133
  208. package/dist/create/server-source/crates/feltdb/src/routing.rs +0 -409
  209. package/dist/create/server-source/crates/feltdb/src/semantic_decision.rs +0 -2029
  210. package/dist/create/server-source/crates/feltdb/src/semantic_query.rs +0 -599
  211. package/dist/create/server-source/crates/feltdb/src/sharding.rs +0 -549
  212. package/dist/create/server-source/crates/feltdb/src/state_conflict_contract.rs +0 -516
  213. package/dist/create/server-source/crates/feltdb/src/state_contract.rs +0 -5894
  214. package/dist/create/server-source/crates/feltdb/src/state_diff_contract.rs +0 -222
  215. package/dist/create/server-source/crates/feltdb/src/state_facade.rs +0 -320
  216. package/dist/create/server-source/crates/feltdb/src/state_hash.rs +0 -291
  217. package/dist/create/server-source/crates/feltdb/src/state_model.rs +0 -4158
  218. package/dist/create/server-source/crates/feltdb/src/state_transition_store.rs +0 -379
  219. package/dist/create/server-source/crates/feltdb/src/state_trigger.rs +0 -673
  220. package/dist/create/server-source/crates/feltdb/src/storage.rs +0 -273
  221. package/dist/create/server-source/crates/feltdb/src/submission.rs +0 -471
  222. package/dist/create/server-source/crates/feltdb/src/sync.rs +0 -495
  223. package/dist/create/server-source/crates/feltdb/src/sync_contract.rs +0 -822
  224. package/dist/create/server-source/crates/feltdb/src/tcp_transport.rs +0 -433
  225. package/dist/create/server-source/crates/feltdb/src/transaction_api.rs +0 -462
  226. package/dist/create/server-source/crates/feltdb/src/transaction_invariants.rs +0 -965
  227. package/dist/create/server-source/crates/feltdb/src/transaction_preconditions.rs +0 -1120
  228. package/dist/create/server-source/crates/feltdb/src/transactions.rs +0 -643
  229. package/dist/create/server-source/crates/feltdb/src/trigger.rs +0 -390
  230. package/dist/create/server-source/crates/feltdb/src/trigger_contract.rs +0 -749
  231. package/dist/create/server-source/crates/feltdb/src/versioned_object_substrate.rs +0 -708
  232. package/dist/create/server-source/crates/feltdb/src/worker_mesh.rs +0 -1133
  233. package/dist/create/server-source/crates/feltdb/src/workflow.rs +0 -713
  234. package/dist/create/server-source/crates/feltdb/src/workflow_acceptance_tests.rs +0 -510
  235. package/dist/create/server-source/crates/feltdb/src/workflow_integration.rs +0 -354
  236. package/dist/create/server-source/crates/feltdb/src/workflow_runtime.rs +0 -594
  237. package/dist/create/server-source/crates/feltdb/src/workload.rs +0 -2886
  238. package/dist/create/server-source/crates/feltdb/src/workload_diagnostics.rs +0 -456
  239. package/dist/create/server-source/crates/feltdb/tests/agent_state_native.rs +0 -1188
  240. package/dist/create/server-source/crates/feltdb/tests/agent_transition_contract_conformance.rs +0 -2884
  241. package/dist/create/server-source/crates/feltdb/tests/authority_process.rs +0 -297
  242. package/dist/create/server-source/crates/feltdb/tests/authority_transaction_identity.rs +0 -534
  243. package/dist/create/server-source/crates/feltdb/tests/bounded_read_contract.rs +0 -132
  244. package/dist/create/server-source/crates/feltdb/tests/branching_evidence.rs +0 -299
  245. package/dist/create/server-source/crates/feltdb/tests/common/mod.rs +0 -96
  246. package/dist/create/server-source/crates/feltdb/tests/compaction_stall_contract.rs +0 -272
  247. package/dist/create/server-source/crates/feltdb/tests/crash_durability_contract.rs +0 -467
  248. package/dist/create/server-source/crates/feltdb/tests/current_revision_authority_evidence.rs +0 -309
  249. package/dist/create/server-source/crates/feltdb/tests/durable_backup_contract.rs +0 -445
  250. package/dist/create/server-source/crates/feltdb/tests/durable_corruption_contract.rs +0 -518
  251. package/dist/create/server-source/crates/feltdb/tests/durable_format_compatibility.rs +0 -392
  252. package/dist/create/server-source/crates/feltdb/tests/feltdb_state_boundary_tests.rs +0 -850
  253. package/dist/create/server-source/crates/feltdb/tests/fixtures/agent_transition_corpus.json +0 -23340
  254. package/dist/create/server-source/crates/feltdb/tests/fixtures/state_conflict_contract_corpus.json +0 -1916
  255. package/dist/create/server-source/crates/feltdb/tests/fixtures/state_diff_contract_corpus.json +0 -1878
  256. package/dist/create/server-source/crates/feltdb/tests/fixtures/trigger_contract_corpus.json +0 -1862
  257. package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_evidence.rs +0 -123
  258. package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_substrate_completion.rs +0 -299
  259. package/dist/create/server-source/crates/feltdb/tests/local_process_ownership.rs +0 -69
  260. package/dist/create/server-source/crates/feltdb/tests/managed_incident_regression.rs +0 -191
  261. package/dist/create/server-source/crates/feltdb/tests/operational_health_contract.rs +0 -278
  262. package/dist/create/server-source/crates/feltdb/tests/pr34_query_collection.rs +0 -234
  263. package/dist/create/server-source/crates/feltdb/tests/pr35_equality_index.rs +0 -947
  264. package/dist/create/server-source/crates/feltdb/tests/pr7_self_authorization_proof.rs +0 -404
  265. package/dist/create/server-source/crates/feltdb/tests/pr8_vocabulary_assessment.rs +0 -916
  266. package/dist/create/server-source/crates/feltdb/tests/pr9_phase2_boundary_tests.rs +0 -1045
  267. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3a_path_a_tests.rs +0 -347
  268. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_authorized_mutations.rs +0 -361
  269. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_role_based_authorization.rs +0 -330
  270. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_simple_auth_delete.rs +0 -93
  271. package/dist/create/server-source/crates/feltdb/tests/pr9_phase3c_team_delete_role_authorization.rs +0 -622
  272. package/dist/create/server-source/crates/feltdb/tests/pr9_teams_role_based_access.rs +0 -517
  273. package/dist/create/server-source/crates/feltdb/tests/production_certification.rs +0 -1153
  274. package/dist/create/server-source/crates/feltdb/tests/production_contract.rs +0 -771
  275. package/dist/create/server-source/crates/feltdb/tests/production_readiness_contract.rs +0 -1383
  276. package/dist/create/server-source/crates/feltdb/tests/reconciliation_application.rs +0 -868
  277. package/dist/create/server-source/crates/feltdb/tests/reconciliation_wire_format_evidence.rs +0 -221
  278. package/dist/create/server-source/crates/feltdb/tests/replicated_history_contract.rs +0 -417
  279. package/dist/create/server-source/crates/feltdb/tests/resource_scoped_revisions.rs +0 -338
  280. package/dist/create/server-source/crates/feltdb/tests/revision_identity_contract.rs +0 -1039
  281. package/dist/create/server-source/crates/feltdb/tests/revision_model_decision.rs +0 -739
  282. package/dist/create/server-source/crates/feltdb/tests/revision_retention_boundary_evidence.rs +0 -452
  283. package/dist/create/server-source/crates/feltdb/tests/saas_authorization_integration.rs +0 -81
  284. package/dist/create/server-source/crates/feltdb/tests/saas_invitation_lifecycle.rs +0 -438
  285. package/dist/create/server-source/crates/feltdb/tests/semantic_decision.rs +0 -1165
  286. package/dist/create/server-source/crates/feltdb/tests/semantic_query.rs +0 -767
  287. package/dist/create/server-source/crates/feltdb/tests/semantic_query_contract.rs +0 -363
  288. package/dist/create/server-source/crates/feltdb/tests/state_conflict_contract_conformance.rs +0 -1799
  289. package/dist/create/server-source/crates/feltdb/tests/state_diff_contract_conformance.rs +0 -1316
  290. package/dist/create/server-source/crates/feltdb/tests/state_model_integration.rs +0 -358
  291. package/dist/create/server-source/crates/feltdb/tests/state_persistence_integration.rs +0 -365
  292. package/dist/create/server-source/crates/feltdb/tests/state_ref_authority.rs +0 -918
  293. package/dist/create/server-source/crates/feltdb/tests/state_store_boundary_evidence.rs +0 -299
  294. package/dist/create/server-source/crates/feltdb/tests/storage_independent_versioned_object_substrate.rs +0 -328
  295. package/dist/create/server-source/crates/feltdb/tests/sync_divergence_evidence.rs +0 -255
  296. package/dist/create/server-source/crates/feltdb/tests/three_way_input_boundary_evidence.rs +0 -249
  297. package/dist/create/server-source/crates/feltdb/tests/trigger_contract_conformance.rs +0 -994
  298. package/dist/create/server-source/crates/feltdb/tests/workload_envelope_contract.rs +0 -484
  299. package/dist/studio-app/assets/feltdb_wasm_bg-CFQT4gCy.wasm +0 -0
  300. package/dist/studio-app/assets/index-Dql1hS5m.js +0 -30
@@ -1,713 +0,0 @@
1
- use crate::FlowRef;
2
- /// Workflow module for durable, reactive distributed workflows
3
- ///
4
- /// A workflow is a durable graph of intents and references that can execute
5
- /// wherever the required capabilities exist, without the workflow owning execution location.
6
- use serde::{Deserialize, Serialize};
7
- use std::collections::{HashMap, HashSet};
8
- use std::fmt::{Display, Formatter};
9
-
10
- /// Reference to a workflow - addressable object in the fabric
11
- ///
12
- /// WorkflowRef {
13
- /// namespace: "workflows",
14
- /// workflow_id: "order-processing",
15
- /// version: 1,
16
- /// }
17
- ///
18
- /// For example:
19
- /// - flow://workflow/order-processing@1
20
- /// - flow://workflow/document-ingestion@2
21
- /// - flow://workflow/research@1
22
- #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash)]
23
- pub struct WorkflowRef {
24
- /// Namespace for workflows (typically "workflow")
25
- pub namespace: String,
26
- /// Unique identifier for the workflow
27
- pub workflow_id: String,
28
- /// Version of the workflow
29
- pub version: u64,
30
- }
31
-
32
- impl WorkflowRef {
33
- /// Create a new WorkflowRef
34
- pub fn new(namespace: impl Into<String>, workflow_id: impl Into<String>, version: u64) -> Self {
35
- Self {
36
- namespace: namespace.into(),
37
- workflow_id: workflow_id.into(),
38
- version,
39
- }
40
- }
41
-
42
- /// Get canonical string representation
43
- pub fn canonical(&self) -> String {
44
- format!(
45
- "flow://{}/{}@{}",
46
- self.namespace, self.workflow_id, self.version
47
- )
48
- }
49
-
50
- /// Parse from canonical form
51
- pub fn from_canonical(s: &str) -> Option<Self> {
52
- if !s.starts_with("flow://") {
53
- return None;
54
- }
55
- let s = &s[7..]; // Remove "flow://"
56
-
57
- let (namespace, rest) = s.split_once('/')?;
58
- let (workflow_id, version_str) = rest.split_once('@')?;
59
- let version = version_str.parse().ok()?;
60
-
61
- Some(Self {
62
- namespace: namespace.to_string(),
63
- workflow_id: workflow_id.to_string(),
64
- version,
65
- })
66
- }
67
- }
68
-
69
- impl Display for WorkflowRef {
70
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
71
- write!(f, "{}", self.canonical())
72
- }
73
- }
74
-
75
- /// Reference to a step within a workflow
76
- ///
77
- /// Provides stable identity for workflow steps across peer failures and migrations.
78
- #[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash)]
79
- pub struct WorkflowStepRef {
80
- /// Reference to the parent workflow
81
- pub workflow_ref: WorkflowRef,
82
- /// Step identifier within the workflow (e.g., "step-1", "extract", "join-results")
83
- pub step_id: String,
84
- }
85
-
86
- impl WorkflowStepRef {
87
- /// Create a new WorkflowStepRef
88
- pub fn new(workflow_ref: WorkflowRef, step_id: impl Into<String>) -> Self {
89
- Self {
90
- workflow_ref,
91
- step_id: step_id.into(),
92
- }
93
- }
94
-
95
- /// Get canonical string representation
96
- pub fn canonical(&self) -> String {
97
- format!("{}/{}", self.workflow_ref.canonical(), self.step_id)
98
- }
99
-
100
- /// Parse from canonical form
101
- pub fn from_canonical(s: &str) -> Option<Self> {
102
- // Expected format: flow://workflow/workflow-id@version/step-id
103
- if !s.starts_with("flow://") {
104
- return None;
105
- }
106
-
107
- let s = &s[7..]; // Remove "flow://"
108
-
109
- // Find the last '/' to separate workflow part from step-id
110
- let last_slash_idx = s.rfind('/')?;
111
- let workflow_str = &s[..last_slash_idx];
112
- let step_id = &s[last_slash_idx + 1..];
113
-
114
- // Parse the workflow part
115
- let (namespace, rest) = workflow_str.split_once('/')?;
116
- let (workflow_id, version_str) = rest.split_once('@')?;
117
- let version = version_str.parse().ok()?;
118
-
119
- Some(Self {
120
- workflow_ref: WorkflowRef {
121
- namespace: namespace.to_string(),
122
- workflow_id: workflow_id.to_string(),
123
- version,
124
- },
125
- step_id: step_id.to_string(),
126
- })
127
- }
128
- }
129
-
130
- impl Display for WorkflowStepRef {
131
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
132
- write!(f, "{}", self.canonical())
133
- }
134
- }
135
-
136
- /// State of a workflow step in the durable execution model
137
- #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
138
- pub enum WorkflowStepState {
139
- /// Waiting for dependencies to be satisfied
140
- Pending,
141
- /// Dependencies satisfied, ready to execute
142
- Ready,
143
- /// Step has been claimed by a peer for execution
144
- Claimed,
145
- /// Step is currently executing
146
- Running,
147
- /// Step completed successfully
148
- Completed,
149
- /// Step failed during execution
150
- Failed,
151
- /// Step scheduled for retry after failure
152
- Retrying,
153
- /// Step is blocked, waiting for external input
154
- Blocked,
155
- }
156
-
157
- impl Display for WorkflowStepState {
158
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
159
- match self {
160
- Self::Pending => write!(f, "Pending"),
161
- Self::Ready => write!(f, "Ready"),
162
- Self::Claimed => write!(f, "Claimed"),
163
- Self::Running => write!(f, "Running"),
164
- Self::Completed => write!(f, "Completed"),
165
- Self::Failed => write!(f, "Failed"),
166
- Self::Retrying => write!(f, "Retrying"),
167
- Self::Blocked => write!(f, "Blocked"),
168
- }
169
- }
170
- }
171
-
172
- /// Reason a workflow step is blocked
173
- #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
174
- pub enum BlockedReason {
175
- /// Awaiting human approval
176
- AwaitingApproval(String),
177
- /// Awaiting human input
178
- AwaitingInput(String),
179
- /// Required capability not available
180
- AwaitingCapability(String),
181
- /// Insufficient resources
182
- AwaitingResource(String),
183
- /// Custom blocking reason
184
- Custom(String),
185
- }
186
-
187
- impl Display for BlockedReason {
188
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
189
- match self {
190
- Self::AwaitingApproval(msg) => write!(f, "AwaitingApproval: {}", msg),
191
- Self::AwaitingInput(msg) => write!(f, "AwaitingInput: {}", msg),
192
- Self::AwaitingCapability(cap) => write!(f, "AwaitingCapability: {}", cap),
193
- Self::AwaitingResource(res) => write!(f, "AwaitingResource: {}", res),
194
- Self::Custom(msg) => write!(f, "Custom: {}", msg),
195
- }
196
- }
197
- }
198
-
199
- /// State of a workflow
200
- #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
201
- pub enum WorkflowState {
202
- /// Workflow has been created but not started
203
- Created,
204
- /// Workflow is currently executing
205
- Running,
206
- /// Workflow completed successfully
207
- Completed,
208
- /// Workflow failed
209
- Failed,
210
- }
211
-
212
- impl Display for WorkflowState {
213
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
214
- match self {
215
- Self::Created => write!(f, "Created"),
216
- Self::Running => write!(f, "Running"),
217
- Self::Completed => write!(f, "Completed"),
218
- Self::Failed => write!(f, "Failed"),
219
- }
220
- }
221
- }
222
-
223
- /// Workflow lifecycle event - becomes a durable operation
224
- #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
225
- pub enum WorkflowOperation {
226
- /// Workflow was created
227
- Created { workflow_ref: WorkflowRef },
228
- /// Workflow started execution
229
- Started { workflow_ref: WorkflowRef },
230
- /// A step became ready to execute
231
- StepReady { step_ref: WorkflowStepRef },
232
- /// A step was claimed by a peer
233
- StepClaimed {
234
- step_ref: WorkflowStepRef,
235
- claimed_by: String,
236
- },
237
- /// A step started executing
238
- StepExecuting {
239
- step_ref: WorkflowStepRef,
240
- claimed_by: String,
241
- },
242
- /// A step completed successfully
243
- StepCompleted {
244
- step_ref: WorkflowStepRef,
245
- result_ref: Option<FlowRef>,
246
- },
247
- /// A step failed
248
- StepFailed {
249
- step_ref: WorkflowStepRef,
250
- error: String,
251
- attempt: u32,
252
- },
253
- /// A step is blocked pending external input
254
- StepBlocked {
255
- step_ref: WorkflowStepRef,
256
- reason: BlockedReason,
257
- },
258
- /// A step retry was scheduled
259
- StepRetrying {
260
- step_ref: WorkflowStepRef,
261
- attempt: u32,
262
- },
263
- /// Workflow completed
264
- Completed { workflow_ref: WorkflowRef },
265
- /// Workflow failed
266
- Failed {
267
- workflow_ref: WorkflowRef,
268
- error: String,
269
- },
270
- }
271
-
272
- impl WorkflowOperation {
273
- /// Get the affected workflow reference
274
- pub fn workflow_ref(&self) -> Option<&WorkflowRef> {
275
- match self {
276
- Self::Created { workflow_ref } => Some(workflow_ref),
277
- Self::Started { workflow_ref } => Some(workflow_ref),
278
- Self::Completed { workflow_ref } => Some(workflow_ref),
279
- Self::Failed { workflow_ref, .. } => Some(workflow_ref),
280
- _ => None,
281
- }
282
- }
283
-
284
- /// Get the affected step reference
285
- pub fn step_ref(&self) -> Option<&WorkflowStepRef> {
286
- match self {
287
- Self::StepReady { step_ref } => Some(step_ref),
288
- Self::StepClaimed { step_ref, .. } => Some(step_ref),
289
- Self::StepExecuting { step_ref, .. } => Some(step_ref),
290
- Self::StepCompleted { step_ref, .. } => Some(step_ref),
291
- Self::StepFailed { step_ref, .. } => Some(step_ref),
292
- Self::StepBlocked { step_ref, .. } => Some(step_ref),
293
- Self::StepRetrying { step_ref, .. } => Some(step_ref),
294
- _ => None,
295
- }
296
- }
297
- }
298
-
299
- /// Workflow graph node - represents a capability to execute
300
- #[derive(Debug, Clone, Serialize, Deserialize)]
301
- pub struct WorkflowNode {
302
- /// Step identifier (e.g., "extract", "embed", "classify")
303
- pub step_id: String,
304
- /// Capability to execute (reference to a CapabilityRef)
305
- pub capability: String,
306
- /// Input references required for this step
307
- pub inputs: Vec<String>, // Step IDs or input slot names
308
- /// Output slot names produced by this step
309
- pub outputs: Vec<String>,
310
- /// State requirements for this step
311
- pub state_requirements: HashMap<String, String>,
312
- /// Metadata about this node
313
- pub metadata: HashMap<String, serde_json::Value>,
314
- }
315
-
316
- impl WorkflowNode {
317
- /// Create a new workflow node
318
- pub fn new(step_id: impl Into<String>, capability: impl Into<String>) -> Self {
319
- Self {
320
- step_id: step_id.into(),
321
- capability: capability.into(),
322
- inputs: Vec::new(),
323
- outputs: Vec::new(),
324
- state_requirements: HashMap::new(),
325
- metadata: HashMap::new(),
326
- }
327
- }
328
-
329
- /// Add an input dependency
330
- pub fn with_input(mut self, input: impl Into<String>) -> Self {
331
- self.inputs.push(input.into());
332
- self
333
- }
334
-
335
- /// Add an output slot
336
- pub fn with_output(mut self, output: impl Into<String>) -> Self {
337
- self.outputs.push(output.into());
338
- self
339
- }
340
-
341
- /// Add a state requirement
342
- pub fn with_state_requirement(
343
- mut self,
344
- key: impl Into<String>,
345
- value: impl Into<String>,
346
- ) -> Self {
347
- self.state_requirements.insert(key.into(), value.into());
348
- self
349
- }
350
- }
351
-
352
- /// Workflow graph definition - durable DAG structure
353
- #[derive(Debug, Clone, Serialize, Deserialize)]
354
- pub struct WorkflowGraph {
355
- /// Workflow reference
356
- pub workflow_ref: WorkflowRef,
357
- /// Nodes in the workflow
358
- pub nodes: HashMap<String, WorkflowNode>,
359
- /// Edges: from_step_id -> to_step_id
360
- pub edges: HashMap<String, Vec<String>>,
361
- /// Input references for the entire workflow
362
- pub inputs: Vec<FlowRef>,
363
- /// Output slot definitions
364
- pub outputs: Vec<String>,
365
- /// Metadata
366
- pub metadata: HashMap<String, serde_json::Value>,
367
- }
368
-
369
- impl WorkflowGraph {
370
- /// Create a new workflow graph
371
- pub fn new(workflow_ref: WorkflowRef) -> Self {
372
- Self {
373
- workflow_ref,
374
- nodes: HashMap::new(),
375
- edges: HashMap::new(),
376
- inputs: Vec::new(),
377
- outputs: Vec::new(),
378
- metadata: HashMap::new(),
379
- }
380
- }
381
-
382
- /// Add a node to the graph
383
- pub fn add_node(mut self, node: WorkflowNode) -> Self {
384
- self.nodes.insert(node.step_id.clone(), node);
385
- self
386
- }
387
-
388
- /// Add an edge from one step to another
389
- pub fn add_edge(mut self, from_step: impl Into<String>, to_step: impl Into<String>) -> Self {
390
- let from = from_step.into();
391
- let to = to_step.into();
392
- self.edges.entry(from).or_insert_with(Vec::new).push(to);
393
- self
394
- }
395
-
396
- /// Add an input reference
397
- pub fn with_input(mut self, input: FlowRef) -> Self {
398
- self.inputs.push(input);
399
- self
400
- }
401
-
402
- /// Validate the graph structure (basic DAG check)
403
- pub fn validate(&self) -> Result<(), String> {
404
- // Check all edges reference existing nodes
405
- for (from, tos) in &self.edges {
406
- if !self.nodes.contains_key(from) {
407
- return Err(format!("Edge source '{}' does not exist", from));
408
- }
409
- for to in tos {
410
- if !self.nodes.contains_key(to) {
411
- return Err(format!("Edge target '{}' does not exist", to));
412
- }
413
- }
414
- }
415
-
416
- // Check input dependencies reference existing nodes or inputs
417
- for node in self.nodes.values() {
418
- for input in &node.inputs {
419
- if !self.nodes.contains_key(input) && !input.starts_with("input:") {
420
- return Err(format!(
421
- "Node '{}' has input dependency '{}' that doesn't exist",
422
- node.step_id, input
423
- ));
424
- }
425
- }
426
- }
427
-
428
- // Simple cycle detection using DFS
429
- self.detect_cycles()?;
430
-
431
- Ok(())
432
- }
433
-
434
- /// Detect cycles in the graph using DFS
435
- fn detect_cycles(&self) -> Result<(), String> {
436
- let mut visited: HashSet<String> = HashSet::new();
437
- let mut rec_stack: HashSet<String> = HashSet::new();
438
-
439
- for node_id in self.nodes.keys() {
440
- if !visited.contains(node_id) {
441
- self.dfs(node_id, &mut visited, &mut rec_stack)?;
442
- }
443
- }
444
-
445
- Ok(())
446
- }
447
-
448
- /// DFS helper for cycle detection
449
- fn dfs(
450
- &self,
451
- node_id: &str,
452
- visited: &mut HashSet<String>,
453
- rec_stack: &mut HashSet<String>,
454
- ) -> Result<(), String> {
455
- visited.insert(node_id.to_string());
456
- rec_stack.insert(node_id.to_string());
457
-
458
- if let Some(neighbors) = self.edges.get(node_id) {
459
- for neighbor in neighbors {
460
- if !visited.contains(neighbor) {
461
- self.dfs(neighbor, visited, rec_stack)?;
462
- } else if rec_stack.contains(neighbor) {
463
- return Err(format!("Cycle detected: {} -> {}", node_id, neighbor));
464
- }
465
- }
466
- }
467
-
468
- rec_stack.remove(node_id);
469
- Ok(())
470
- }
471
-
472
- /// Get nodes with no dependencies (entry points)
473
- pub fn entry_nodes(&self) -> Vec<String> {
474
- self.nodes
475
- .keys()
476
- .filter(|node_id| {
477
- if let Some(node) = self.nodes.get(*node_id) {
478
- // A node is an entry point if all its inputs come from workflow inputs
479
- node.inputs.is_empty()
480
- || node.inputs.iter().all(|inp| inp.starts_with("input:"))
481
- } else {
482
- false
483
- }
484
- })
485
- .cloned()
486
- .collect()
487
- }
488
-
489
- /// Get nodes that depend on a given step
490
- pub fn dependents(&self, step_id: &str) -> Vec<String> {
491
- self.edges
492
- .get(step_id)
493
- .map(|deps| deps.clone())
494
- .unwrap_or_default()
495
- }
496
-
497
- /// Get nodes that a given step depends on
498
- pub fn dependencies(&self, step_id: &str) -> Vec<String> {
499
- if let Some(node) = self.nodes.get(step_id) {
500
- node.inputs
501
- .iter()
502
- .filter(|inp| !inp.starts_with("input:"))
503
- .cloned()
504
- .collect()
505
- } else {
506
- Vec::new()
507
- }
508
- }
509
- }
510
-
511
- /// Runtime state for a workflow instance
512
- #[derive(Debug, Clone, Serialize, Deserialize)]
513
- pub struct WorkflowInstance {
514
- /// Reference to the workflow definition
515
- pub workflow_ref: WorkflowRef,
516
- /// Unique instance ID for this execution
517
- pub instance_id: String,
518
- /// Overall workflow state
519
- pub state: WorkflowState,
520
- /// Current state of each step
521
- pub step_states: HashMap<String, WorkflowStepState>,
522
- /// Which peer claimed each step
523
- pub step_claims: HashMap<String, String>,
524
- /// Results produced by each step
525
- pub step_results: HashMap<String, FlowRef>,
526
- /// Failed attempts for each step
527
- pub step_failures: HashMap<String, Vec<String>>,
528
- /// Blocked reason for each step
529
- pub step_blocked_reasons: HashMap<String, BlockedReason>,
530
- /// Timestamp created (ms since UNIX epoch)
531
- pub created_ms: u128,
532
- /// Timestamp started (ms since UNIX epoch)
533
- pub started_ms: Option<u128>,
534
- /// Timestamp completed (ms since UNIX epoch)
535
- pub completed_ms: Option<u128>,
536
- }
537
-
538
- impl WorkflowInstance {
539
- /// Create a new workflow instance
540
- pub fn new(workflow_ref: WorkflowRef, instance_id: impl Into<String>) -> Self {
541
- Self {
542
- workflow_ref,
543
- instance_id: instance_id.into(),
544
- state: WorkflowState::Created,
545
- step_states: HashMap::new(),
546
- step_claims: HashMap::new(),
547
- step_results: HashMap::new(),
548
- step_failures: HashMap::new(),
549
- step_blocked_reasons: HashMap::new(),
550
- created_ms: crate::now_ms(),
551
- started_ms: None,
552
- completed_ms: None,
553
- }
554
- }
555
-
556
- /// Get the state of a step
557
- pub fn get_step_state(&self, step_id: &str) -> Option<WorkflowStepState> {
558
- self.step_states.get(step_id).copied()
559
- }
560
-
561
- /// Set the state of a step
562
- pub fn set_step_state(&mut self, step_id: impl Into<String>, state: WorkflowStepState) {
563
- self.step_states.insert(step_id.into(), state);
564
- }
565
-
566
- /// Mark a step as claimed
567
- pub fn claim_step(
568
- &mut self,
569
- step_id: impl Into<String>,
570
- claimed_by: impl Into<String>,
571
- ) -> Result<(), String> {
572
- let step_id = step_id.into();
573
- let claimed_by = claimed_by.into();
574
-
575
- match self.get_step_state(&step_id) {
576
- Some(WorkflowStepState::Ready) => {
577
- self.set_step_state(step_id.clone(), WorkflowStepState::Claimed);
578
- self.step_claims.insert(step_id, claimed_by);
579
- Ok(())
580
- }
581
- Some(state) => Err(format!("Cannot claim step in state {}", state)),
582
- None => Err(format!("Step not found: {}", step_id)),
583
- }
584
- }
585
-
586
- /// Record a step completion
587
- pub fn complete_step(
588
- &mut self,
589
- step_id: impl Into<String>,
590
- result_ref: FlowRef,
591
- ) -> Result<(), String> {
592
- let step_id = step_id.into();
593
- self.set_step_state(step_id.clone(), WorkflowStepState::Completed);
594
- self.step_results.insert(step_id, result_ref);
595
- Ok(())
596
- }
597
-
598
- /// Record a step failure
599
- pub fn fail_step(&mut self, step_id: impl Into<String>, error: String) -> Result<(), String> {
600
- let step_id = step_id.into();
601
- self.set_step_state(step_id.clone(), WorkflowStepState::Failed);
602
- self.step_failures
603
- .entry(step_id)
604
- .or_insert_with(Vec::new)
605
- .push(error);
606
- Ok(())
607
- }
608
-
609
- /// Check if workflow is terminal (won't change state)
610
- pub fn is_terminal(&self) -> bool {
611
- matches!(self.state, WorkflowState::Completed | WorkflowState::Failed)
612
- }
613
- }
614
-
615
- #[cfg(test)]
616
- mod tests {
617
- use super::*;
618
-
619
- #[test]
620
- fn test_workflow_ref_canonical() {
621
- let r = WorkflowRef::new("workflow", "order-processing", 1);
622
- assert_eq!(r.canonical(), "flow://workflow/order-processing@1");
623
- }
624
-
625
- #[test]
626
- fn test_workflow_ref_parse() {
627
- let s = "flow://workflow/order-processing@1";
628
- let r = WorkflowRef::from_canonical(s).unwrap();
629
- assert_eq!(r.namespace, "workflow");
630
- assert_eq!(r.workflow_id, "order-processing");
631
- assert_eq!(r.version, 1);
632
- }
633
-
634
- #[test]
635
- fn test_workflow_step_ref_canonical() {
636
- let wf = WorkflowRef::new("workflow", "test", 1);
637
- let step = WorkflowStepRef::new(wf, "step-1");
638
- assert_eq!(step.canonical(), "flow://workflow/test@1/step-1");
639
- }
640
-
641
- #[test]
642
- fn test_workflow_step_ref_parse() {
643
- let s = "flow://workflow/test@1/step-1";
644
- let step = WorkflowStepRef::from_canonical(s).unwrap();
645
- assert_eq!(step.step_id, "step-1");
646
- assert_eq!(step.workflow_ref.workflow_id, "test");
647
- }
648
-
649
- #[test]
650
- fn test_workflow_graph_validation() {
651
- let wf = WorkflowRef::new("workflow", "test", 1);
652
- let graph = WorkflowGraph::new(wf)
653
- .add_node(WorkflowNode::new("step-1", "capability-a"))
654
- .add_node(WorkflowNode::new("step-2", "capability-b").with_input("step-1"))
655
- .add_edge("step-1", "step-2");
656
-
657
- assert!(graph.validate().is_ok());
658
- }
659
-
660
- #[test]
661
- fn test_workflow_graph_cycle_detection() {
662
- let wf = WorkflowRef::new("workflow", "test", 1);
663
- let graph = WorkflowGraph::new(wf)
664
- .add_node(WorkflowNode::new("step-1", "capability-a"))
665
- .add_node(WorkflowNode::new("step-2", "capability-b"))
666
- .add_edge("step-1", "step-2")
667
- .add_edge("step-2", "step-1");
668
-
669
- assert!(graph.validate().is_err());
670
- }
671
-
672
- #[test]
673
- fn test_workflow_graph_entry_nodes() {
674
- let wf = WorkflowRef::new("workflow", "test", 1);
675
- let graph = WorkflowGraph::new(wf)
676
- .add_node(WorkflowNode::new("step-1", "capability-a"))
677
- .add_node(WorkflowNode::new("step-2", "capability-b").with_input("step-1"))
678
- .add_edge("step-1", "step-2");
679
-
680
- let entries = graph.entry_nodes();
681
- assert_eq!(entries.len(), 1);
682
- assert!(entries.contains(&"step-1".to_string()));
683
- }
684
-
685
- #[test]
686
- fn test_workflow_instance_lifecycle() {
687
- let wf = WorkflowRef::new("workflow", "test", 1);
688
- let mut instance = WorkflowInstance::new(wf, "instance-1");
689
-
690
- instance.set_step_state("step-1", WorkflowStepState::Pending);
691
- assert_eq!(
692
- instance.get_step_state("step-1"),
693
- Some(WorkflowStepState::Pending)
694
- );
695
-
696
- instance.set_step_state("step-1", WorkflowStepState::Ready);
697
- let claim_result = instance.claim_step("step-1", "peer-a");
698
- assert!(claim_result.is_ok());
699
- assert_eq!(
700
- instance.get_step_state("step-1"),
701
- Some(WorkflowStepState::Claimed)
702
- );
703
- }
704
-
705
- #[test]
706
- fn test_workflow_blocked_reason() {
707
- let reason = BlockedReason::AwaitingApproval("Needs manager approval".to_string());
708
- assert_eq!(
709
- reason.to_string(),
710
- "AwaitingApproval: Needs manager approval"
711
- );
712
- }
713
- }