@feltdb/core 0.6.13 → 0.7.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 (83) hide show
  1. package/README.md +32 -0
  2. package/dist/agent-registry.js +1 -3
  3. package/dist/agent-runtime.js +8 -7
  4. package/dist/analytics-backend.js +3 -1
  5. package/dist/application-contract.js +1 -0
  6. package/dist/application-manifest.js +1 -0
  7. package/dist/artifact.js +2 -0
  8. package/dist/authorization.js +2 -0
  9. package/dist/bundle.js +2 -0
  10. package/dist/capability.js +1 -3
  11. package/dist/cell.js +9 -4
  12. package/dist/cli/commands.js +26 -2
  13. package/dist/cli/index.js +1 -1
  14. package/dist/collection.js +39 -31
  15. package/dist/create/package-versions.js +1 -1
  16. package/dist/create/server-source/crates/feltdb/src/bin/feltdb_node.rs +613 -27
  17. package/dist/create/server-source/crates/feltdb/src/causal_backlog_bound.rs +452 -0
  18. package/dist/create/server-source/crates/feltdb/src/causal_dependency_barrier.rs +208 -0
  19. package/dist/create/server-source/crates/feltdb/src/convergence.rs +16 -0
  20. package/dist/create/server-source/crates/feltdb/src/dedup_bound_investigation.rs +402 -0
  21. package/dist/create/server-source/crates/feltdb/src/distributed_transactions.rs +784 -24
  22. package/dist/create/server-source/crates/feltdb/src/durable_operation_identity.rs +418 -0
  23. package/dist/create/server-source/crates/feltdb/src/lib.rs +284 -0
  24. package/dist/create/server-source/crates/feltdb/src/replica_acknowledgements.rs +471 -0
  25. package/dist/create/server-source/crates/feltdb/src/replica_membership.rs +661 -0
  26. package/dist/create/server-source/crates/feltdb/src/tcp_transport.rs +72 -3
  27. package/dist/create/server-source/crates/feltdb/src/transaction_preconditions.rs +899 -0
  28. package/dist/create/server-source/crates/feltdb-server/src/main.rs +116 -4
  29. package/dist/db.d.ts +2 -2
  30. package/dist/db.d.ts.map +1 -1
  31. package/dist/db.js +48 -15
  32. package/dist/development-runtime-bridge.js +1 -1
  33. package/dist/distributed-indexing.js +7 -5
  34. package/dist/embedded-transaction.d.ts +9 -0
  35. package/dist/embedded-transaction.d.ts.map +1 -1
  36. package/dist/embedded-transaction.js +95 -3
  37. package/dist/feltdb.d.ts +16 -0
  38. package/dist/feltdb.d.ts.map +1 -1
  39. package/dist/file-db.d.ts.map +1 -1
  40. package/dist/file-db.js +9 -3
  41. package/dist/flowspec.js +2 -1
  42. package/dist/http-client.js +2 -0
  43. package/dist/http-db.d.ts +11 -0
  44. package/dist/http-db.d.ts.map +1 -1
  45. package/dist/http-db.js +32 -3
  46. package/dist/identity.js +1 -0
  47. package/dist/index-analytics.js +6 -7
  48. package/dist/index-backend.js +3 -3
  49. package/dist/index-dashboard.js +10 -13
  50. package/dist/index-manager.js +12 -11
  51. package/dist/index-monitoring.js +9 -4
  52. package/dist/index-store.js +2 -0
  53. package/dist/indexeddb-db.d.ts.map +1 -1
  54. package/dist/indexeddb-db.js +32 -23
  55. package/dist/memory-db.d.ts.map +1 -1
  56. package/dist/memory-db.js +8 -4
  57. package/dist/observe.js +2 -0
  58. package/dist/provider.js +2 -0
  59. package/dist/query-planner.js +2 -4
  60. package/dist/reactive-graph.js +6 -8
  61. package/dist/release.js +2 -0
  62. package/dist/sharding.js +11 -6
  63. package/dist/state-contract.js +3 -3
  64. package/dist/studio-app/assets/{feltdb_wasm-CJv3wHzi.js → feltdb_wasm-CD744e5D.js} +1 -1
  65. package/dist/studio-app/assets/feltdb_wasm_bg-CiIXhOLi.wasm +0 -0
  66. package/dist/studio-app/assets/index-DoROs8yx.js +28 -0
  67. package/dist/studio-app/index.html +1 -1
  68. package/dist/sync-contract.js +9 -2
  69. package/dist/telemetry.d.ts.map +1 -1
  70. package/dist/telemetry.js +32 -12
  71. package/dist/transaction.d.ts +127 -9
  72. package/dist/transaction.d.ts.map +1 -1
  73. package/dist/transaction.js +91 -5
  74. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  75. package/dist/worker.js +2 -0
  76. package/dist/workload.js +2 -0
  77. package/dist/workspace/development-node.js +11 -10
  78. package/dist/workspace/investigation-lifecycle-manager.js +2 -0
  79. package/dist/workspace/investigation-supervisor.js +5 -3
  80. package/dist/workspace/workspace-connection.js +14 -5
  81. package/package.json +1 -1
  82. package/dist/studio-app/assets/feltdb_wasm_bg-C8TG8r2n.wasm +0 -0
  83. package/dist/studio-app/assets/index-DospFFYE.js +0 -28
@@ -19,6 +19,21 @@
19
19
  /// Deduplication/idempotency/retry logic is the protocol's responsibility via DistributedTransactionExecutor.
20
20
 
21
21
  use crate::distributed_transactions::ReplicationMessage;
22
+ use crate::replica_acknowledgements::ReplicaAcknowledgement;
23
+
24
+ /// What actually goes on the wire.
25
+ ///
26
+ /// Tagged, so a connection can carry envelopes and acknowledgements without
27
+ /// either being able to masquerade as the other. The alternative -- an
28
+ /// acknowledgement riding inside a `ReplicationMessage` with a placeholder
29
+ /// envelope -- would put a value on the receive path that only a flag
30
+ /// distinguishes from a real operation, and the receive path's whole job is
31
+ /// deciding what to apply.
32
+ #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
33
+ pub enum Frame {
34
+ Replication(Box<ReplicationMessage>),
35
+ Acknowledgement(Box<ReplicaAcknowledgement>),
36
+ }
22
37
  use crate::replication_protocol::{ProtocolError, ProtocolMetrics, ProtocolTransport};
23
38
  use std::sync::atomic::{AtomicBool, Ordering};
24
39
  use std::sync::Arc;
@@ -37,6 +52,12 @@ pub struct TcpTransport {
37
52
  metrics: Arc<ProtocolMetrics>,
38
53
  is_connected: Arc<AtomicBool>,
39
54
  receive_buffer: Arc<Mutex<Vec<ReplicationMessage>>>,
55
+ /// Acknowledgements read off the socket, waiting to be drained.
56
+ ///
57
+ /// They arrive interleaved with envelopes on the same connection, so
58
+ /// `receive` parks them here rather than changing its return type and the
59
+ /// trait every caller implements against.
60
+ ack_buffer: Arc<Mutex<Vec<ReplicaAcknowledgement>>>,
40
61
  }
41
62
 
42
63
  impl TcpTransport {
@@ -49,6 +70,7 @@ impl TcpTransport {
49
70
  metrics: Arc::new(ProtocolMetrics::new()),
50
71
  is_connected: Arc::new(AtomicBool::new(false)),
51
72
  receive_buffer: Arc::new(Mutex::new(Vec::with_capacity(MESSAGE_BUFFER_SIZE))),
73
+ ack_buffer: Arc::new(Mutex::new(Vec::new())),
52
74
  }
53
75
  }
54
76
 
@@ -76,6 +98,44 @@ impl TcpTransport {
76
98
  }
77
99
  }
78
100
 
101
+ impl TcpTransport {
102
+ /// Send an acknowledgement over the same connection envelopes use.
103
+ ///
104
+ /// Not part of `ProtocolTransport`: that trait is the replication protocol,
105
+ /// and an acknowledgement is a statement about what has been applied rather
106
+ /// than something to apply.
107
+ pub async fn send_acknowledgement(
108
+ &self,
109
+ ack: ReplicaAcknowledgement,
110
+ ) -> Result<(), ProtocolError> {
111
+ let mut stream_guard = self.stream.lock().await;
112
+ let stream = stream_guard
113
+ .as_mut()
114
+ .ok_or(ProtocolError::ConnectionError("not connected".to_string()))?;
115
+ let payload = serde_json::to_vec(&Frame::Acknowledgement(Box::new(ack)))
116
+ .map_err(|e| ProtocolError::SerializationError(e.to_string()))?;
117
+ stream
118
+ .write_all(&(payload.len() as u32).to_be_bytes())
119
+ .await
120
+ .map_err(|e| ProtocolError::TransportError(e.to_string()))?;
121
+ stream
122
+ .write_all(&payload)
123
+ .await
124
+ .map_err(|e| ProtocolError::TransportError(e.to_string()))?;
125
+ stream
126
+ .flush()
127
+ .await
128
+ .map_err(|e| ProtocolError::TransportError(e.to_string()))?;
129
+ self.metrics.record_send(4 + payload.len());
130
+ Ok(())
131
+ }
132
+
133
+ /// Take the acknowledgements read off the socket since the last drain.
134
+ pub async fn take_acknowledgements(&self) -> Vec<ReplicaAcknowledgement> {
135
+ std::mem::take(&mut *self.ack_buffer.lock().await)
136
+ }
137
+ }
138
+
79
139
  #[async_trait::async_trait]
80
140
  impl ProtocolTransport for TcpTransport {
81
141
  async fn send(&self, message: ReplicationMessage) -> Result<(), ProtocolError> {
@@ -85,7 +145,7 @@ impl ProtocolTransport for TcpTransport {
85
145
  .ok_or(ProtocolError::ConnectionError("not connected".to_string()))?;
86
146
 
87
147
  // Serialize message using serde_json (bincode has issues with serde_json::Value)
88
- let payload = serde_json::to_vec(&message)
148
+ let payload = serde_json::to_vec(&Frame::Replication(Box::new(message)))
89
149
  .map_err(|e| ProtocolError::SerializationError(e.to_string()))?;
90
150
 
91
151
  let payload_len = payload.len() as u32;
@@ -152,12 +212,21 @@ impl ProtocolTransport for TcpTransport {
152
212
  .await
153
213
  .map_err(|e| ProtocolError::TransportError(e.to_string()))?;
154
214
 
155
- let message: ReplicationMessage = serde_json::from_slice(&payload)
215
+ let frame: Frame = serde_json::from_slice(&payload)
156
216
  .map_err(|e| ProtocolError::SerializationError(e.to_string()))?;
157
217
 
158
218
  self.metrics.record_receive(4 + payload_len);
159
219
 
160
- Ok(vec![message])
220
+ match frame {
221
+ Frame::Replication(message) => Ok(vec![*message]),
222
+ Frame::Acknowledgement(ack) => {
223
+ // Read off the socket and parked. The bytes crossed the
224
+ // network exactly as an envelope's do, and the counters
225
+ // above record them.
226
+ self.ack_buffer.lock().await.push(*ack);
227
+ Ok(Vec::new())
228
+ }
229
+ }
161
230
  }
162
231
  Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
163
232
  // No data available right now