agentdb 3.0.0-alpha.11 → 3.0.0-alpha.13
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.
- package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts +54 -0
- package/dist/src/backends/graph/GraphDatabaseAdapter.d.ts.map +1 -1
- package/dist/src/backends/graph/GraphDatabaseAdapter.js +125 -0
- package/dist/src/backends/graph/GraphDatabaseAdapter.js.map +1 -1
- package/dist/src/cli/agentdb-cli.js +0 -0
- package/dist/src/controllers/ReflexionMemory.d.ts +50 -0
- package/dist/src/controllers/ReflexionMemory.d.ts.map +1 -1
- package/dist/src/controllers/ReflexionMemory.js +258 -0
- package/dist/src/controllers/ReflexionMemory.js.map +1 -1
- package/dist/src/controllers/index.d.ts +2 -0
- package/dist/src/controllers/index.d.ts.map +1 -1
- package/dist/src/controllers/index.js +2 -0
- package/dist/src/controllers/index.js.map +1 -1
- package/dist/src/controllers/prerequisites.d.ts +76 -0
- package/dist/src/controllers/prerequisites.d.ts.map +1 -0
- package/dist/src/controllers/prerequisites.js +235 -0
- package/dist/src/controllers/prerequisites.js.map +1 -0
- package/dist/src/db-fallback.d.ts.map +1 -1
- package/dist/src/db-fallback.js +55 -45
- package/dist/src/db-fallback.js.map +1 -1
- package/package.json +1 -1
- package/dist/schemas/frontier-schema.sql +0 -378
- package/dist/schemas/schema.sql +0 -382
- package/dist/src/backends/index.cjs +0 -6
- package/dist/src/backends/ruvector/GuardedVectorBackend.d.ts +0 -93
- package/dist/src/backends/ruvector/GuardedVectorBackend.d.ts.map +0 -1
- package/dist/src/backends/ruvector/GuardedVectorBackend.js +0 -182
- package/dist/src/backends/ruvector/GuardedVectorBackend.js.map +0 -1
- package/dist/src/consensus/RaftConsensus.d.ts +0 -220
- package/dist/src/consensus/RaftConsensus.d.ts.map +0 -1
- package/dist/src/consensus/RaftConsensus.js +0 -762
- package/dist/src/consensus/RaftConsensus.js.map +0 -1
- package/dist/src/controllers/HierarchicalMemory.d.ts +0 -197
- package/dist/src/controllers/HierarchicalMemory.d.ts.map +0 -1
- package/dist/src/controllers/HierarchicalMemory.js +0 -519
- package/dist/src/controllers/HierarchicalMemory.js.map +0 -1
- package/dist/src/controllers/MemoryConsolidation.d.ts +0 -142
- package/dist/src/controllers/MemoryConsolidation.d.ts.map +0 -1
- package/dist/src/controllers/MemoryConsolidation.js +0 -479
- package/dist/src/controllers/MemoryConsolidation.js.map +0 -1
- package/dist/src/controllers/QUICConnection.d.ts +0 -122
- package/dist/src/controllers/QUICConnection.d.ts.map +0 -1
- package/dist/src/controllers/QUICConnection.js +0 -329
- package/dist/src/controllers/QUICConnection.js.map +0 -1
- package/dist/src/controllers/QUICConnectionPool.d.ts +0 -83
- package/dist/src/controllers/QUICConnectionPool.d.ts.map +0 -1
- package/dist/src/controllers/QUICConnectionPool.js +0 -256
- package/dist/src/controllers/QUICConnectionPool.js.map +0 -1
- package/dist/src/controllers/QUICStreamManager.d.ts +0 -114
- package/dist/src/controllers/QUICStreamManager.d.ts.map +0 -1
- package/dist/src/controllers/QUICStreamManager.js +0 -267
- package/dist/src/controllers/QUICStreamManager.js.map +0 -1
- package/dist/src/controllers/StreamingEmbeddingService.d.ts +0 -82
- package/dist/src/controllers/StreamingEmbeddingService.d.ts.map +0 -1
- package/dist/src/controllers/StreamingEmbeddingService.js +0 -243
- package/dist/src/controllers/StreamingEmbeddingService.js.map +0 -1
- package/dist/src/controllers/index.cjs +0 -6
- package/dist/src/coordination/MultiDatabaseCoordinator.d.ts +0 -348
- package/dist/src/coordination/MultiDatabaseCoordinator.d.ts.map +0 -1
- package/dist/src/coordination/MultiDatabaseCoordinator.js +0 -803
- package/dist/src/coordination/MultiDatabaseCoordinator.js.map +0 -1
- package/dist/src/coordination/index.d.ts +0 -10
- package/dist/src/coordination/index.d.ts.map +0 -1
- package/dist/src/coordination/index.js +0 -10
- package/dist/src/coordination/index.js.map +0 -1
- package/dist/src/index.cjs +0 -6
- package/dist/src/optimizations/RVFOptimizer.d.ts +0 -226
- package/dist/src/optimizations/RVFOptimizer.d.ts.map +0 -1
- package/dist/src/optimizations/RVFOptimizer.js +0 -541
- package/dist/src/optimizations/RVFOptimizer.js.map +0 -1
- package/dist/src/security/AttestationLog.d.ts +0 -70
- package/dist/src/security/AttestationLog.d.ts.map +0 -1
- package/dist/src/security/AttestationLog.js +0 -174
- package/dist/src/security/AttestationLog.js.map +0 -1
- package/dist/src/security/MutationGuard.d.ts +0 -83
- package/dist/src/security/MutationGuard.d.ts.map +0 -1
- package/dist/src/security/MutationGuard.js +0 -364
- package/dist/src/security/MutationGuard.js.map +0 -1
- package/dist/src/security/index.cjs +0 -6
- package/dist/src/security/index.d.ts +0 -15
- package/dist/src/security/index.d.ts.map +0 -1
- package/dist/src/security/index.js +0 -18
- package/dist/src/security/index.js.map +0 -1
- package/dist/src/services/GNNService.d.ts +0 -173
- package/dist/src/services/GNNService.d.ts.map +0 -1
- package/dist/src/services/GNNService.js +0 -639
- package/dist/src/services/GNNService.js.map +0 -1
- package/dist/src/services/GraphTransformerService.d.ts +0 -80
- package/dist/src/services/GraphTransformerService.d.ts.map +0 -1
- package/dist/src/services/GraphTransformerService.js +0 -369
- package/dist/src/services/GraphTransformerService.js.map +0 -1
- package/dist/src/services/SemanticRouter.d.ts +0 -83
- package/dist/src/services/SemanticRouter.d.ts.map +0 -1
- package/dist/src/services/SemanticRouter.js +0 -160
- package/dist/src/services/SemanticRouter.js.map +0 -1
- package/dist/src/services/SonaTrajectoryService.d.ts +0 -224
- package/dist/src/services/SonaTrajectoryService.d.ts.map +0 -1
- package/dist/src/services/SonaTrajectoryService.js +0 -539
- package/dist/src/services/SonaTrajectoryService.js.map +0 -1
- package/dist/src/utils/LegacyAttentionAdapter.d.ts +0 -93
- package/dist/src/utils/LegacyAttentionAdapter.d.ts.map +0 -1
- package/dist/src/utils/LegacyAttentionAdapter.js +0 -241
- package/dist/src/utils/LegacyAttentionAdapter.js.map +0 -1
- package/dist/src/utils/vector-math.d.ts +0 -29
- package/dist/src/utils/vector-math.d.ts.map +0 -1
- package/dist/src/utils/vector-math.js +0 -66
- package/dist/src/utils/vector-math.js.map +0 -1
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QUICConnection - Enhanced QUIC Connection with 0-RTT, BBR, and Migration
|
|
3
|
-
*
|
|
4
|
-
* Implements an advanced QUIC connection with:
|
|
5
|
-
* - 0-RTT fast reconnect via session ticket caching
|
|
6
|
-
* - BBR congestion control for optimal throughput
|
|
7
|
-
* - Connection migration for resilient networking
|
|
8
|
-
* - Latency tracking and performance metrics
|
|
9
|
-
*/
|
|
10
|
-
export class QUICConnection {
|
|
11
|
-
config;
|
|
12
|
-
connected = false;
|
|
13
|
-
busy = false;
|
|
14
|
-
sessionTicket = null;
|
|
15
|
-
bbrState;
|
|
16
|
-
metrics;
|
|
17
|
-
createdAt;
|
|
18
|
-
lastActiveAt;
|
|
19
|
-
migrationCount = 0;
|
|
20
|
-
currentPath;
|
|
21
|
-
id;
|
|
22
|
-
// Static session ticket cache shared across connections for 0-RTT
|
|
23
|
-
static ticketCache = new Map();
|
|
24
|
-
static TICKET_LIFETIME_MS = 7 * 24 * 60 * 60 * 1000; // 7 days
|
|
25
|
-
constructor(config) {
|
|
26
|
-
this.config = {
|
|
27
|
-
endpoint: config.endpoint,
|
|
28
|
-
enableZeroRTT: config.enableZeroRTT ?? true,
|
|
29
|
-
enableMultipath: config.enableMultipath ?? false,
|
|
30
|
-
congestionControl: config.congestionControl ?? 'bbr',
|
|
31
|
-
maxIdleTimeoutMs: config.maxIdleTimeoutMs ?? 30000,
|
|
32
|
-
initialRttMs: config.initialRttMs ?? 100,
|
|
33
|
-
};
|
|
34
|
-
this.id = `quic-conn-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
35
|
-
this.createdAt = Date.now();
|
|
36
|
-
this.lastActiveAt = Date.now();
|
|
37
|
-
this.currentPath = config.endpoint;
|
|
38
|
-
this.bbrState = this.initBBR();
|
|
39
|
-
this.metrics = this.initMetrics();
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Connect to the QUIC endpoint.
|
|
43
|
-
* Uses 0-RTT if a cached session ticket is available.
|
|
44
|
-
*/
|
|
45
|
-
async connect() {
|
|
46
|
-
const startTime = performance.now();
|
|
47
|
-
if (this.connected) {
|
|
48
|
-
return { zeroRtt: false, handshakeMs: 0 };
|
|
49
|
-
}
|
|
50
|
-
// Check for cached session ticket for 0-RTT
|
|
51
|
-
const cachedTicket = QUICConnection.ticketCache.get(this.config.endpoint);
|
|
52
|
-
if (this.config.enableZeroRTT && cachedTicket && cachedTicket.expiresAt > Date.now()) {
|
|
53
|
-
// 0-RTT fast path: skip full handshake
|
|
54
|
-
const result = await this.connectWithZeroRTT(cachedTicket);
|
|
55
|
-
const handshakeMs = performance.now() - startTime;
|
|
56
|
-
this.metrics.handshakeTimeMs = handshakeMs;
|
|
57
|
-
this.metrics.zeroRttUsed = true;
|
|
58
|
-
this.connected = true;
|
|
59
|
-
this.lastActiveAt = Date.now();
|
|
60
|
-
return { zeroRtt: true, handshakeMs };
|
|
61
|
-
}
|
|
62
|
-
// Full TLS 1.3 handshake
|
|
63
|
-
await this.connectFull();
|
|
64
|
-
const handshakeMs = performance.now() - startTime;
|
|
65
|
-
this.metrics.handshakeTimeMs = handshakeMs;
|
|
66
|
-
this.metrics.zeroRttUsed = false;
|
|
67
|
-
// Store session ticket for future 0-RTT
|
|
68
|
-
this.sessionTicket = this.generateSessionTicket();
|
|
69
|
-
QUICConnection.ticketCache.set(this.config.endpoint, this.sessionTicket);
|
|
70
|
-
this.connected = true;
|
|
71
|
-
this.lastActiveAt = Date.now();
|
|
72
|
-
return { zeroRtt: false, handshakeMs };
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* 0-RTT connection using cached session ticket.
|
|
76
|
-
* Sends early data in the initial flight, eliminating 1 RTT.
|
|
77
|
-
*/
|
|
78
|
-
async connectWithZeroRTT(ticket) {
|
|
79
|
-
// Validate ticket
|
|
80
|
-
if (ticket.expiresAt < Date.now()) {
|
|
81
|
-
QUICConnection.ticketCache.delete(this.config.endpoint);
|
|
82
|
-
throw new Error('Session ticket expired, performing full handshake');
|
|
83
|
-
}
|
|
84
|
-
// 0-RTT: send ClientHello + early data in single flight
|
|
85
|
-
// Simulated timing: ~0.1x of full handshake
|
|
86
|
-
const delay = Math.max(1, this.config.initialRttMs * 0.1);
|
|
87
|
-
await this.sleep(delay);
|
|
88
|
-
// Update RTT estimate from 0-RTT
|
|
89
|
-
this.metrics.rttMs = delay;
|
|
90
|
-
this.updateSmoothedRtt(delay);
|
|
91
|
-
// Refresh the ticket for next time
|
|
92
|
-
this.sessionTicket = this.generateSessionTicket();
|
|
93
|
-
QUICConnection.ticketCache.set(this.config.endpoint, this.sessionTicket);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Full TLS 1.3 handshake (1-RTT).
|
|
97
|
-
*/
|
|
98
|
-
async connectFull() {
|
|
99
|
-
// Full handshake: 1 RTT
|
|
100
|
-
const delay = this.config.initialRttMs;
|
|
101
|
-
await this.sleep(delay);
|
|
102
|
-
this.metrics.rttMs = delay;
|
|
103
|
-
this.updateSmoothedRtt(delay);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Disconnect the connection.
|
|
107
|
-
*/
|
|
108
|
-
async disconnect() {
|
|
109
|
-
if (!this.connected)
|
|
110
|
-
return;
|
|
111
|
-
this.connected = false;
|
|
112
|
-
this.busy = false;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Send data over this connection using BBR pacing.
|
|
116
|
-
*/
|
|
117
|
-
async send(data) {
|
|
118
|
-
if (!this.connected) {
|
|
119
|
-
throw new Error('Connection not established');
|
|
120
|
-
}
|
|
121
|
-
this.busy = true;
|
|
122
|
-
this.lastActiveAt = Date.now();
|
|
123
|
-
const size = data.length;
|
|
124
|
-
this.metrics.packetsSent++;
|
|
125
|
-
this.metrics.bytesInFlight += size;
|
|
126
|
-
// BBR-paced sending
|
|
127
|
-
const pacingDelay = this.computeBBRPacingDelay(size);
|
|
128
|
-
await this.sleep(pacingDelay);
|
|
129
|
-
// Simulate ACK
|
|
130
|
-
this.metrics.bytesInFlight -= size;
|
|
131
|
-
this.metrics.packetsAcked++;
|
|
132
|
-
// Update BBR state with delivery sample
|
|
133
|
-
const measuredRtt = pacingDelay + Math.random() * 2; // slight jitter
|
|
134
|
-
this.updateBBR(size, measuredRtt);
|
|
135
|
-
this.updateSmoothedRtt(measuredRtt);
|
|
136
|
-
this.metrics.rttMs = measuredRtt;
|
|
137
|
-
this.busy = false;
|
|
138
|
-
return { bytesAcked: size, rttMs: measuredRtt };
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Migrate connection to a new network path.
|
|
142
|
-
* QUIC supports connection migration without re-handshake.
|
|
143
|
-
*/
|
|
144
|
-
async migrate(newEndpoint) {
|
|
145
|
-
if (!this.connected) {
|
|
146
|
-
throw new Error('Cannot migrate: not connected');
|
|
147
|
-
}
|
|
148
|
-
const previousPath = this.currentPath;
|
|
149
|
-
this.currentPath = newEndpoint;
|
|
150
|
-
this.migrationCount++;
|
|
151
|
-
// Path validation: probe the new path
|
|
152
|
-
const probeStart = performance.now();
|
|
153
|
-
await this.sleep(Math.max(1, this.metrics.smoothedRttMs * 0.5));
|
|
154
|
-
const probeRtt = performance.now() - probeStart;
|
|
155
|
-
// Reset congestion controller for new path (BBR probe_bw)
|
|
156
|
-
this.bbrState.mode = 'probe_bw';
|
|
157
|
-
this.bbrState.cycleIndex = 0;
|
|
158
|
-
this.metrics.congestionWindow = 10 * 1200; // 10 initial packets
|
|
159
|
-
this.updateSmoothedRtt(probeRtt);
|
|
160
|
-
this.lastActiveAt = Date.now();
|
|
161
|
-
return { success: true, previousPath };
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Compute BBR pacing delay for a given packet size.
|
|
165
|
-
*/
|
|
166
|
-
computeBBRPacingDelay(packetSize) {
|
|
167
|
-
const { btlBw, pacingGain } = this.bbrState;
|
|
168
|
-
if (btlBw <= 0) {
|
|
169
|
-
// No bandwidth estimate yet: use initial RTT / 10
|
|
170
|
-
return Math.max(0.5, this.config.initialRttMs / 10);
|
|
171
|
-
}
|
|
172
|
-
// Pacing interval = packetSize / (btlBw * pacingGain)
|
|
173
|
-
const pacingRate = btlBw * pacingGain;
|
|
174
|
-
const interval = (packetSize / pacingRate) * 1000; // convert to ms
|
|
175
|
-
return Math.max(0.1, interval);
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Update BBR state machine with a new delivery sample.
|
|
179
|
-
*/
|
|
180
|
-
updateBBR(bytesDelivered, rttSample) {
|
|
181
|
-
const now = Date.now();
|
|
182
|
-
// Update bottleneck bandwidth estimate
|
|
183
|
-
const deliveryRate = bytesDelivered / (rttSample / 1000);
|
|
184
|
-
this.metrics.deliveryRate = deliveryRate;
|
|
185
|
-
if (deliveryRate > this.bbrState.btlBw) {
|
|
186
|
-
this.bbrState.btlBw = deliveryRate;
|
|
187
|
-
}
|
|
188
|
-
// Update min RTT (rt_prop)
|
|
189
|
-
if (rttSample < this.bbrState.rtProp || now > this.bbrState.rtPropExpiry) {
|
|
190
|
-
this.bbrState.rtProp = rttSample;
|
|
191
|
-
this.bbrState.rtPropExpiry = now + 10000; // 10s window
|
|
192
|
-
}
|
|
193
|
-
// State machine transitions
|
|
194
|
-
switch (this.bbrState.mode) {
|
|
195
|
-
case 'startup':
|
|
196
|
-
this.bbrState.pacingGain = 2.885;
|
|
197
|
-
this.bbrState.cwndGain = 2.0;
|
|
198
|
-
if (deliveryRate <= this.bbrState.lastBw * 1.25) {
|
|
199
|
-
this.bbrState.fullBwCount++;
|
|
200
|
-
if (this.bbrState.fullBwCount >= 3) {
|
|
201
|
-
this.bbrState.fullBwReached = true;
|
|
202
|
-
this.bbrState.mode = 'drain';
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
this.bbrState.fullBwCount = 0;
|
|
207
|
-
this.bbrState.lastBw = deliveryRate;
|
|
208
|
-
}
|
|
209
|
-
break;
|
|
210
|
-
case 'drain':
|
|
211
|
-
this.bbrState.pacingGain = 1 / 2.885;
|
|
212
|
-
this.bbrState.cwndGain = 2.0;
|
|
213
|
-
if (this.metrics.bytesInFlight <= this.computeBDP()) {
|
|
214
|
-
this.bbrState.mode = 'probe_bw';
|
|
215
|
-
this.bbrState.cycleIndex = 0;
|
|
216
|
-
}
|
|
217
|
-
break;
|
|
218
|
-
case 'probe_bw': {
|
|
219
|
-
const pacingGains = [1.25, 0.75, 1, 1, 1, 1, 1, 1];
|
|
220
|
-
this.bbrState.pacingGain = pacingGains[this.bbrState.cycleIndex % pacingGains.length];
|
|
221
|
-
this.bbrState.cwndGain = 2.0;
|
|
222
|
-
this.bbrState.cycleIndex++;
|
|
223
|
-
break;
|
|
224
|
-
}
|
|
225
|
-
case 'probe_rtt':
|
|
226
|
-
this.bbrState.cwndGain = 1.0;
|
|
227
|
-
this.bbrState.pacingGain = 1.0;
|
|
228
|
-
if (now > this.bbrState.rtPropExpiry) {
|
|
229
|
-
this.bbrState.mode = 'probe_bw';
|
|
230
|
-
}
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
// Update congestion window
|
|
234
|
-
this.metrics.congestionWindow = Math.max(4 * 1200, // minimum 4 packets
|
|
235
|
-
this.computeBDP() * this.bbrState.cwndGain);
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Compute Bandwidth-Delay Product.
|
|
239
|
-
*/
|
|
240
|
-
computeBDP() {
|
|
241
|
-
return this.bbrState.btlBw * (this.bbrState.rtProp / 1000);
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Update smoothed RTT using exponential weighted moving average.
|
|
245
|
-
*/
|
|
246
|
-
updateSmoothedRtt(sample) {
|
|
247
|
-
const alpha = 0.125;
|
|
248
|
-
const beta = 0.25;
|
|
249
|
-
if (this.metrics.smoothedRttMs === 0) {
|
|
250
|
-
this.metrics.smoothedRttMs = sample;
|
|
251
|
-
this.metrics.rttVariance = sample / 2;
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
this.metrics.rttVariance = (1 - beta) * this.metrics.rttVariance +
|
|
255
|
-
beta * Math.abs(this.metrics.smoothedRttMs - sample);
|
|
256
|
-
this.metrics.smoothedRttMs = (1 - alpha) * this.metrics.smoothedRttMs +
|
|
257
|
-
alpha * sample;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
generateSessionTicket() {
|
|
261
|
-
return {
|
|
262
|
-
data: new Uint8Array(32).map(() => Math.floor(Math.random() * 256)),
|
|
263
|
-
issuedAt: Date.now(),
|
|
264
|
-
expiresAt: Date.now() + QUICConnection.TICKET_LIFETIME_MS,
|
|
265
|
-
serverName: this.config.endpoint,
|
|
266
|
-
alpn: 'h3',
|
|
267
|
-
maxEarlyData: 16384,
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
initBBR() {
|
|
271
|
-
return {
|
|
272
|
-
mode: 'startup',
|
|
273
|
-
btlBw: 0,
|
|
274
|
-
rtProp: Infinity,
|
|
275
|
-
rtPropExpiry: 0,
|
|
276
|
-
cwndGain: 2.0,
|
|
277
|
-
pacingGain: 2.885,
|
|
278
|
-
cycleIndex: 0,
|
|
279
|
-
fullBwReached: false,
|
|
280
|
-
fullBwCount: 0,
|
|
281
|
-
lastBw: 0,
|
|
282
|
-
};
|
|
283
|
-
}
|
|
284
|
-
initMetrics() {
|
|
285
|
-
return {
|
|
286
|
-
rttMs: 0,
|
|
287
|
-
smoothedRttMs: 0,
|
|
288
|
-
rttVariance: 0,
|
|
289
|
-
bytesInFlight: 0,
|
|
290
|
-
congestionWindow: 10 * 1200,
|
|
291
|
-
deliveryRate: 0,
|
|
292
|
-
packetsLost: 0,
|
|
293
|
-
packetsSent: 0,
|
|
294
|
-
packetsAcked: 0,
|
|
295
|
-
zeroRttUsed: false,
|
|
296
|
-
handshakeTimeMs: 0,
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
// -- Accessors --
|
|
300
|
-
getId() { return this.id; }
|
|
301
|
-
isConnected() { return this.connected; }
|
|
302
|
-
isBusy() { return this.busy; }
|
|
303
|
-
getEndpoint() { return this.config.endpoint; }
|
|
304
|
-
getCurrentPath() { return this.currentPath; }
|
|
305
|
-
getCreatedAt() { return this.createdAt; }
|
|
306
|
-
getLastActiveAt() { return this.lastActiveAt; }
|
|
307
|
-
getMigrationCount() { return this.migrationCount; }
|
|
308
|
-
getMetrics() { return { ...this.metrics }; }
|
|
309
|
-
getBBRMode() { return this.bbrState.mode; }
|
|
310
|
-
hasSessionTicket() {
|
|
311
|
-
return QUICConnection.ticketCache.has(this.config.endpoint);
|
|
312
|
-
}
|
|
313
|
-
/**
|
|
314
|
-
* Clear session ticket cache (for testing or security reset).
|
|
315
|
-
*/
|
|
316
|
-
static clearTicketCache() {
|
|
317
|
-
QUICConnection.ticketCache.clear();
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Get the number of cached session tickets.
|
|
321
|
-
*/
|
|
322
|
-
static getTicketCacheSize() {
|
|
323
|
-
return QUICConnection.ticketCache.size;
|
|
324
|
-
}
|
|
325
|
-
sleep(ms) {
|
|
326
|
-
return new Promise((resolve) => setTimeout(resolve, Math.max(0, ms)));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
//# sourceMappingURL=QUICConnection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QUICConnection.js","sourceRoot":"","sources":["../../../src/controllers/QUICConnection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA+CH,MAAM,OAAO,cAAc;IACjB,MAAM,CAAiC;IACvC,SAAS,GAAY,KAAK,CAAC;IAC3B,IAAI,GAAY,KAAK,CAAC;IACtB,aAAa,GAAyB,IAAI,CAAC;IAC3C,QAAQ,CAAW;IACnB,OAAO,CAAoB;IAC3B,S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C,IAAI,CAAC,CAAC,CAAC;IACvC,WAAW,KAAa,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACtD,cAAc,KAAa,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACrD,YAAY,KAAa,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IACjD,eAAe,KAAa,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IACvD,iBAAiB,KAAa,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IAC3D,UAAU,KAAwB,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC/D,UAAU,KAAa,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAEnD,gBAAgB;QACd,OAAO,cAAc,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB;QACrB,cAAc,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,kBAAkB;QACvB,OAAO,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC;IACzC,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QUICConnectionPool - Connection Pooling for QUIC Protocol
|
|
3
|
-
*
|
|
4
|
-
* Manages a pool of QUICConnection instances for efficient reuse:
|
|
5
|
-
* - Maximum pool size of 10 connections per endpoint
|
|
6
|
-
* - Connection reuse with idle detection
|
|
7
|
-
* - Automatic cleanup of stale/expired connections
|
|
8
|
-
* - Pool-level statistics and health monitoring
|
|
9
|
-
* - Graceful drain and shutdown
|
|
10
|
-
*/
|
|
11
|
-
import { QUICConnection } from './QUICConnection.js';
|
|
12
|
-
export interface PoolConfig {
|
|
13
|
-
maxPoolSize?: number;
|
|
14
|
-
maxIdleTimeMs?: number;
|
|
15
|
-
acquireTimeoutMs?: number;
|
|
16
|
-
enableZeroRTT?: boolean;
|
|
17
|
-
congestionControl?: 'bbr' | 'cubic' | 'reno';
|
|
18
|
-
healthCheckIntervalMs?: number;
|
|
19
|
-
}
|
|
20
|
-
export interface PoolStats {
|
|
21
|
-
endpoint: string;
|
|
22
|
-
totalConnections: number;
|
|
23
|
-
activeConnections: number;
|
|
24
|
-
idleConnections: number;
|
|
25
|
-
totalAcquired: number;
|
|
26
|
-
totalReleased: number;
|
|
27
|
-
totalCreated: number;
|
|
28
|
-
totalDestroyed: number;
|
|
29
|
-
avgAcquireTimeMs: number;
|
|
30
|
-
avgRttMs: number;
|
|
31
|
-
zeroRttHits: number;
|
|
32
|
-
zeroRttMisses: number;
|
|
33
|
-
}
|
|
34
|
-
export declare class QUICConnectionPool {
|
|
35
|
-
private pools;
|
|
36
|
-
private config;
|
|
37
|
-
private stats;
|
|
38
|
-
private cleanupTimer;
|
|
39
|
-
constructor(config?: PoolConfig);
|
|
40
|
-
/**
|
|
41
|
-
* Acquire a connection from the pool.
|
|
42
|
-
* Reuses idle connections or creates new ones up to maxPoolSize.
|
|
43
|
-
*/
|
|
44
|
-
getConnection(endpoint: string): Promise<QUICConnection>;
|
|
45
|
-
/**
|
|
46
|
-
* Release a connection back to the pool (mark as not busy).
|
|
47
|
-
* The connection stays in the pool for reuse.
|
|
48
|
-
*/
|
|
49
|
-
releaseConnection(conn: QUICConnection): void;
|
|
50
|
-
/**
|
|
51
|
-
* Remove a specific connection from the pool and disconnect it.
|
|
52
|
-
*/
|
|
53
|
-
removeConnection(conn: QUICConnection): Promise<void>;
|
|
54
|
-
/**
|
|
55
|
-
* Get pool statistics for a specific endpoint.
|
|
56
|
-
*/
|
|
57
|
-
getPoolStats(endpoint: string): PoolStats;
|
|
58
|
-
/**
|
|
59
|
-
* Get stats for all endpoints.
|
|
60
|
-
*/
|
|
61
|
-
getAllPoolStats(): PoolStats[];
|
|
62
|
-
/**
|
|
63
|
-
* Get total number of connections across all pools.
|
|
64
|
-
*/
|
|
65
|
-
getTotalConnections(): number;
|
|
66
|
-
/**
|
|
67
|
-
* Drain and close all connections for an endpoint.
|
|
68
|
-
*/
|
|
69
|
-
drainEndpoint(endpoint: string): Promise<number>;
|
|
70
|
-
/**
|
|
71
|
-
* Drain and close ALL connections.
|
|
72
|
-
*/
|
|
73
|
-
shutdown(): Promise<number>;
|
|
74
|
-
/**
|
|
75
|
-
* Remove idle connections that exceed maxIdleTimeMs.
|
|
76
|
-
*/
|
|
77
|
-
cleanup(): Promise<number>;
|
|
78
|
-
private createConnection;
|
|
79
|
-
private waitForAvailableConnection;
|
|
80
|
-
private ensureStats;
|
|
81
|
-
private startCleanup;
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=QUICConnectionPool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QUICConnectionPool.d.ts","sourceRoot":"","sources":["../../../src/controllers/QUICConnectionPool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,cAAc,EAA2C,MAAM,qBAAqB,CAAC;AAE9F,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;IAC7C,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MA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-
/**
|
|
2
|
-
* QUICConnectionPool - Connection Pooling for QUIC Protocol
|
|
3
|
-
*
|
|
4
|
-
* Manages a pool of QUICConnection instances for efficient reuse:
|
|
5
|
-
* - Maximum pool size of 10 connections per endpoint
|
|
6
|
-
* - Connection reuse with idle detection
|
|
7
|
-
* - Automatic cleanup of stale/expired connections
|
|
8
|
-
* - Pool-level statistics and health monitoring
|
|
9
|
-
* - Graceful drain and shutdown
|
|
10
|
-
*/
|
|
11
|
-
import { QUICConnection } from './QUICConnection.js';
|
|
12
|
-
export class QUICConnectionPool {
|
|
13
|
-
pools = new Map();
|
|
14
|
-
config;
|
|
15
|
-
stats = new Map();
|
|
16
|
-
cleanupTimer = null;
|
|
17
|
-
constructor(config) {
|
|
18
|
-
this.config = {
|
|
19
|
-
maxPoolSize: config?.maxPoolSize ?? 10,
|
|
20
|
-
maxIdleTimeMs: config?.maxIdleTimeMs ?? 60000,
|
|
21
|
-
acquireTimeoutMs: config?.acquireTimeoutMs ?? 10000,
|
|
22
|
-
enableZeroRTT: config?.enableZeroRTT ?? true,
|
|
23
|
-
congestionControl: config?.congestionControl ?? 'bbr',
|
|
24
|
-
healthCheckIntervalMs: config?.healthCheckIntervalMs ?? 30000,
|
|
25
|
-
};
|
|
26
|
-
this.startCleanup();
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Acquire a connection from the pool.
|
|
30
|
-
* Reuses idle connections or creates new ones up to maxPoolSize.
|
|
31
|
-
*/
|
|
32
|
-
async getConnection(endpoint) {
|
|
33
|
-
const startTime = performance.now();
|
|
34
|
-
this.ensureStats(endpoint);
|
|
35
|
-
const poolStats = this.stats.get(endpoint);
|
|
36
|
-
const pool = this.pools.get(endpoint) || [];
|
|
37
|
-
this.pools.set(endpoint, pool);
|
|
38
|
-
// Try to reuse an idle connection
|
|
39
|
-
for (const conn of pool) {
|
|
40
|
-
if (!conn.isBusy() && conn.isConnected()) {
|
|
41
|
-
poolStats.totalAcquired++;
|
|
42
|
-
poolStats.acquireTimesMs.push(performance.now() - startTime);
|
|
43
|
-
return conn;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// Create a new connection if pool is not full
|
|
47
|
-
if (pool.length < this.config.maxPoolSize) {
|
|
48
|
-
const conn = await this.createConnection(endpoint);
|
|
49
|
-
pool.push(conn);
|
|
50
|
-
poolStats.totalCreated++;
|
|
51
|
-
poolStats.totalAcquired++;
|
|
52
|
-
// Track 0-RTT usage
|
|
53
|
-
const metrics = conn.getMetrics();
|
|
54
|
-
if (metrics.zeroRttUsed) {
|
|
55
|
-
poolStats.zeroRttHits++;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
poolStats.zeroRttMisses++;
|
|
59
|
-
}
|
|
60
|
-
poolStats.acquireTimesMs.push(performance.now() - startTime);
|
|
61
|
-
return conn;
|
|
62
|
-
}
|
|
63
|
-
// Pool is full: wait for an available connection
|
|
64
|
-
return this.waitForAvailableConnection(endpoint, startTime);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Release a connection back to the pool (mark as not busy).
|
|
68
|
-
* The connection stays in the pool for reuse.
|
|
69
|
-
*/
|
|
70
|
-
releaseConnection(conn) {
|
|
71
|
-
const endpoint = conn.getEndpoint();
|
|
72
|
-
this.ensureStats(endpoint);
|
|
73
|
-
this.stats.get(endpoint).totalReleased++;
|
|
74
|
-
// Connection automatically becomes non-busy after send completes
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Remove a specific connection from the pool and disconnect it.
|
|
78
|
-
*/
|
|
79
|
-
async removeConnection(conn) {
|
|
80
|
-
const endpoint = conn.getEndpoint();
|
|
81
|
-
const pool = this.pools.get(endpoint);
|
|
82
|
-
if (!pool)
|
|
83
|
-
return;
|
|
84
|
-
const idx = pool.indexOf(conn);
|
|
85
|
-
if (idx !== -1) {
|
|
86
|
-
pool.splice(idx, 1);
|
|
87
|
-
await conn.disconnect();
|
|
88
|
-
this.ensureStats(endpoint);
|
|
89
|
-
this.stats.get(endpoint).totalDestroyed++;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Get pool statistics for a specific endpoint.
|
|
94
|
-
*/
|
|
95
|
-
getPoolStats(endpoint) {
|
|
96
|
-
const pool = this.pools.get(endpoint) || [];
|
|
97
|
-
this.ensureStats(endpoint);
|
|
98
|
-
const s = this.stats.get(endpoint);
|
|
99
|
-
const activeConnections = pool.filter(c => c.isBusy()).length;
|
|
100
|
-
const idleConnections = pool.filter(c => !c.isBusy() && c.isConnected()).length;
|
|
101
|
-
const avgAcquire = s.acquireTimesMs.length > 0
|
|
102
|
-
? s.acquireTimesMs.reduce((a, b) => a + b, 0) / s.acquireTimesMs.length
|
|
103
|
-
: 0;
|
|
104
|
-
const rttValues = pool
|
|
105
|
-
.filter(c => c.isConnected())
|
|
106
|
-
.map(c => c.getMetrics().smoothedRttMs)
|
|
107
|
-
.filter(r => r > 0);
|
|
108
|
-
const avgRtt = rttValues.length > 0
|
|
109
|
-
? rttValues.reduce((a, b) => a + b, 0) / rttValues.length
|
|
110
|
-
: 0;
|
|
111
|
-
return {
|
|
112
|
-
endpoint,
|
|
113
|
-
totalConnections: pool.length,
|
|
114
|
-
activeConnections,
|
|
115
|
-
idleConnections,
|
|
116
|
-
totalAcquired: s.totalAcquired,
|
|
117
|
-
totalReleased: s.totalReleased,
|
|
118
|
-
totalCreated: s.totalCreated,
|
|
119
|
-
totalDestroyed: s.totalDestroyed,
|
|
120
|
-
avgAcquireTimeMs: Number(avgAcquire.toFixed(3)),
|
|
121
|
-
avgRttMs: Number(avgRtt.toFixed(3)),
|
|
122
|
-
zeroRttHits: s.zeroRttHits,
|
|
123
|
-
zeroRttMisses: s.zeroRttMisses,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Get stats for all endpoints.
|
|
128
|
-
*/
|
|
129
|
-
getAllPoolStats() {
|
|
130
|
-
return Array.from(this.pools.keys()).map(ep => this.getPoolStats(ep));
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Get total number of connections across all pools.
|
|
134
|
-
*/
|
|
135
|
-
getTotalConnections() {
|
|
136
|
-
let total = 0;
|
|
137
|
-
for (const pool of this.pools.values()) {
|
|
138
|
-
total += pool.length;
|
|
139
|
-
}
|
|
140
|
-
return total;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Drain and close all connections for an endpoint.
|
|
144
|
-
*/
|
|
145
|
-
async drainEndpoint(endpoint) {
|
|
146
|
-
const pool = this.pools.get(endpoint);
|
|
147
|
-
if (!pool)
|
|
148
|
-
return 0;
|
|
149
|
-
let closed = 0;
|
|
150
|
-
for (const conn of pool) {
|
|
151
|
-
await conn.disconnect();
|
|
152
|
-
closed++;
|
|
153
|
-
}
|
|
154
|
-
this.pools.delete(endpoint);
|
|
155
|
-
this.ensureStats(endpoint);
|
|
156
|
-
this.stats.get(endpoint).totalDestroyed += closed;
|
|
157
|
-
return closed;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Drain and close ALL connections.
|
|
161
|
-
*/
|
|
162
|
-
async shutdown() {
|
|
163
|
-
let total = 0;
|
|
164
|
-
for (const endpoint of Array.from(this.pools.keys())) {
|
|
165
|
-
total += await this.drainEndpoint(endpoint);
|
|
166
|
-
}
|
|
167
|
-
if (this.cleanupTimer) {
|
|
168
|
-
clearInterval(this.cleanupTimer);
|
|
169
|
-
this.cleanupTimer = null;
|
|
170
|
-
}
|
|
171
|
-
return total;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Remove idle connections that exceed maxIdleTimeMs.
|
|
175
|
-
*/
|
|
176
|
-
async cleanup() {
|
|
177
|
-
const now = Date.now();
|
|
178
|
-
let cleaned = 0;
|
|
179
|
-
for (const [endpoint, pool] of this.pools.entries()) {
|
|
180
|
-
const toRemove = [];
|
|
181
|
-
for (const conn of pool) {
|
|
182
|
-
if (!conn.isBusy() && (now - conn.getLastActiveAt()) > this.config.maxIdleTimeMs) {
|
|
183
|
-
toRemove.push(conn);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
for (const conn of toRemove) {
|
|
187
|
-
const idx = pool.indexOf(conn);
|
|
188
|
-
if (idx !== -1) {
|
|
189
|
-
pool.splice(idx, 1);
|
|
190
|
-
await conn.disconnect();
|
|
191
|
-
cleaned++;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
this.ensureStats(endpoint);
|
|
195
|
-
this.stats.get(endpoint).totalDestroyed += toRemove.length;
|
|
196
|
-
// Remove empty pools
|
|
197
|
-
if (pool.length === 0) {
|
|
198
|
-
this.pools.delete(endpoint);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
return cleaned;
|
|
202
|
-
}
|
|
203
|
-
// -- Private helpers --
|
|
204
|
-
async createConnection(endpoint) {
|
|
205
|
-
const connConfig = {
|
|
206
|
-
endpoint,
|
|
207
|
-
enableZeroRTT: this.config.enableZeroRTT,
|
|
208
|
-
enableMultipath: false,
|
|
209
|
-
congestionControl: this.config.congestionControl,
|
|
210
|
-
};
|
|
211
|
-
const conn = new QUICConnection(connConfig);
|
|
212
|
-
await conn.connect();
|
|
213
|
-
return conn;
|
|
214
|
-
}
|
|
215
|
-
async waitForAvailableConnection(endpoint, startTime) {
|
|
216
|
-
const deadline = startTime + this.config.acquireTimeoutMs;
|
|
217
|
-
while (performance.now() < deadline) {
|
|
218
|
-
const pool = this.pools.get(endpoint) || [];
|
|
219
|
-
for (const conn of pool) {
|
|
220
|
-
if (!conn.isBusy() && conn.isConnected()) {
|
|
221
|
-
this.ensureStats(endpoint);
|
|
222
|
-
const s = this.stats.get(endpoint);
|
|
223
|
-
s.totalAcquired++;
|
|
224
|
-
s.acquireTimesMs.push(performance.now() - startTime);
|
|
225
|
-
return conn;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
await new Promise(resolve => setTimeout(resolve, 5));
|
|
229
|
-
}
|
|
230
|
-
throw new Error(`Connection pool exhausted for ${endpoint} ` +
|
|
231
|
-
`(max: ${this.config.maxPoolSize}, timeout: ${this.config.acquireTimeoutMs}ms)`);
|
|
232
|
-
}
|
|
233
|
-
ensureStats(endpoint) {
|
|
234
|
-
if (!this.stats.has(endpoint)) {
|
|
235
|
-
this.stats.set(endpoint, {
|
|
236
|
-
totalAcquired: 0,
|
|
237
|
-
totalReleased: 0,
|
|
238
|
-
totalCreated: 0,
|
|
239
|
-
totalDestroyed: 0,
|
|
240
|
-
acquireTimesMs: [],
|
|
241
|
-
zeroRttHits: 0,
|
|
242
|
-
zeroRttMisses: 0,
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
startCleanup() {
|
|
247
|
-
this.cleanupTimer = setInterval(() => {
|
|
248
|
-
this.cleanup().catch(() => { });
|
|
249
|
-
}, this.config.healthCheckIntervalMs);
|
|
250
|
-
// Avoid keeping the process alive just for cleanup
|
|
251
|
-
if (this.cleanupTimer && typeof this.cleanupTimer === 'object' && 'unref' in this.cleanupTimer) {
|
|
252
|
-
this.cleanupTimer.unref();
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
//# sourceMappingURL=QUICConnectionPool.js.map
|