@indigoai-us/hq-cloud 6.16.72-alpha.0 → 6.16.72-alpha.1
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/bin/sync-runner-watch-loop.d.ts +5 -35
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +32 -156
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner.test.js +12 -96
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/cli/rescue-breaker.test.js +94 -1
- package/dist/cli/rescue-breaker.test.js.map +1 -1
- package/dist/cli/rescue-classify-ordering.test.js +1 -1
- package/dist/cli/rescue-clone-network-retry.test.d.ts +2 -0
- package/dist/cli/rescue-clone-network-retry.test.d.ts.map +1 -0
- package/dist/cli/rescue-clone-network-retry.test.js +415 -0
- package/dist/cli/rescue-clone-network-retry.test.js.map +1 -0
- package/dist/cli/rescue-core.d.ts +12 -5
- package/dist/cli/rescue-core.d.ts.map +1 -1
- package/dist/cli/rescue-core.js +685 -93
- package/dist/cli/rescue-core.js.map +1 -1
- package/dist/cli/rescue-drift-reconcile.test.js +1 -1
- package/dist/cli/rescue-drop-dir-symlink.test.js +1 -1
- package/dist/cli/rescue-exec-bit-preserve.test.js +1 -1
- package/dist/cli/rescue-hq-root-guard.test.js +1 -1
- package/dist/cli/rescue-journal-reconcile.test.js +1 -1
- package/dist/cli/rescue-keep-local-ignore.test.js +2 -2
- package/dist/cli/rescue-move.test.d.ts +2 -0
- package/dist/cli/rescue-move.test.d.ts.map +1 -0
- package/dist/cli/rescue-move.test.js +162 -0
- package/dist/cli/rescue-move.test.js.map +1 -0
- package/dist/cli/rescue-mtime-preserve.test.js +1 -1
- package/dist/cli/rescue-preserve-copy-symlink.test.d.ts +2 -0
- package/dist/cli/rescue-preserve-copy-symlink.test.d.ts.map +1 -0
- package/dist/cli/rescue-preserve-copy-symlink.test.js +338 -0
- package/dist/cli/rescue-preserve-copy-symlink.test.js.map +1 -0
- package/dist/cli/rescue-rsync-preflight.test.js +108 -12
- package/dist/cli/rescue-rsync-preflight.test.js.map +1 -1
- package/dist/cli/rescue-rsync-status.test.d.ts +2 -0
- package/dist/cli/rescue-rsync-status.test.d.ts.map +1 -0
- package/dist/cli/rescue-rsync-status.test.js +199 -0
- package/dist/cli/rescue-rsync-status.test.js.map +1 -0
- package/dist/cli/rescue-settings-reconcile.test.js +2 -2
- package/dist/cli/rescue-snapshot-copy.test.js +1 -1
- package/dist/cli/rescue-snapshot-recovery.test.js +1 -1
- package/dist/cli/rescue-source-switch-floor.test.js +1 -1
- package/package.json +1 -1
|
@@ -24,14 +24,6 @@ export declare const REALTIME_ADMISSION_DEADLINE_MS: number;
|
|
|
24
24
|
* that value only promotes a deferred chore to the front of the queue.
|
|
25
25
|
*/
|
|
26
26
|
export declare const REALTIME_DRAIN_BURST_MS: number;
|
|
27
|
-
/**
|
|
28
|
-
* How many realtime executes may run during one chore hand-off.
|
|
29
|
-
* HQ_SYNC_MAX_CONCURRENCY caps simultaneous S3 object transfers, not these
|
|
30
|
-
* workers. One long transfer keeps its worker; a realtime item that arrives
|
|
31
|
-
* while that execute() is in flight starts on the other slot instead of
|
|
32
|
-
* waiting for the whole batch. In-flight work is never aborted.
|
|
33
|
-
*/
|
|
34
|
-
export declare const REALTIME_WORKER_OCCUPANCY_CAP = 2;
|
|
35
27
|
export declare function setRealtimeAdmissionDeadlineMsForTesting(ms: number | undefined): void;
|
|
36
28
|
export declare function setRealtimeDrainBurstMsForTesting(ms: number | undefined): void;
|
|
37
29
|
export declare class RealtimeAdmissionTimeoutError extends Error {
|
|
@@ -64,13 +56,11 @@ export interface GuardedPassContext {
|
|
|
64
56
|
signal: AbortSignal;
|
|
65
57
|
}
|
|
66
58
|
/**
|
|
67
|
-
* One durable-state owner at a time for a full chore. Realtime work runs
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* pre-existing scoped fast-over-slow exception, but never while a chore owns
|
|
73
|
-
* durable state.
|
|
59
|
+
* One durable-state owner at a time for a full chore. Realtime work never runs
|
|
60
|
+
* beside that chore: it explicitly awaits `checkpoint()` after a completed
|
|
61
|
+
* durable unit, then resumes once the hand-off is finished. A separately
|
|
62
|
+
* tracked, explicitly opted-in watcher fast pass may use the pre-existing
|
|
63
|
+
* scoped fast-over-slow exception, but never while a chore owns durable state.
|
|
74
64
|
*/
|
|
75
65
|
export declare class CooperativePassScheduler<T> {
|
|
76
66
|
private readonly now;
|
|
@@ -78,13 +68,6 @@ export declare class CooperativePassScheduler<T> {
|
|
|
78
68
|
private readonly options;
|
|
79
69
|
private readonly pending;
|
|
80
70
|
private active;
|
|
81
|
-
/** Realtime executes started by the current hand-off. Not the chore slot. */
|
|
82
|
-
private readonly realtimeOccupants;
|
|
83
|
-
private handoffBacklog;
|
|
84
|
-
private handoffDeferredAt;
|
|
85
|
-
private handoffAdmitted;
|
|
86
|
-
private occupantEpoch;
|
|
87
|
-
private occupantWaiters;
|
|
88
71
|
private activeFastRealtime;
|
|
89
72
|
private stopped;
|
|
90
73
|
private _handoffActive;
|
|
@@ -114,19 +97,6 @@ export declare class CooperativePassScheduler<T> {
|
|
|
114
97
|
private startFastRealtime;
|
|
115
98
|
private completeFastRealtime;
|
|
116
99
|
private execute;
|
|
117
|
-
private withinHandoffAdmission;
|
|
118
|
-
private waitOccupantChange;
|
|
119
|
-
private notifyOccupantChange;
|
|
120
|
-
/** Run one realtime execute without aborting it and without taking the chore slot. */
|
|
121
|
-
private startRealtimeOccupant;
|
|
122
|
-
/** Items that showed up while a transfer was already running take a free slot. */
|
|
123
|
-
private promoteOccupancyArrivals;
|
|
124
|
-
/**
|
|
125
|
-
* Pull at most one already-queued realtime item while the admission window
|
|
126
|
-
* is open and a worker slot is free. Further backlog waits for that
|
|
127
|
-
* execute() so pre-queued hand-offs stay one durable writer at a time.
|
|
128
|
-
*/
|
|
129
|
-
private admitHandoffBacklog;
|
|
130
100
|
private drainRealtime;
|
|
131
101
|
private checkpoint;
|
|
132
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-runner-watch-loop.d.ts","sourceRoot":"","sources":["../../src/bin/sync-runner-watch-loop.ts"],"names":[],"mappings":"AAwBA,OAAO,EAKL,KAAK,UAAU,EAEf,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAUL,WAAW,EASZ,MAAM,eAAe,CAAC;AAavB,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AASlC,OAAO,EACL,UAAU,EA0CX,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAEL,qBAAqB,EACtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAGL,KAAK,uBAAuB,EAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAEL,KAAK,eAAe,EAIrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYhD,OAAO,KAAK,EACV,yBAAyB,EACzB,SAAS,EAET,cAAc,EACd,iBAAiB,EAElB,MAAM,kBAAkB,CAAC;AAG1B,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,QAAiB,CAAC;AACtD;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,QACI,CAAC;AAChD;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,QAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-runner-watch-loop.d.ts","sourceRoot":"","sources":["../../src/bin/sync-runner-watch-loop.ts"],"names":[],"mappings":"AAwBA,OAAO,EAKL,KAAK,UAAU,EAEf,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAUL,WAAW,EASZ,MAAM,eAAe,CAAC;AAavB,OAAO,EAIL,KAAK,aAAa,EACnB,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49,14 +49,6 @@ export const REALTIME_ADMISSION_DEADLINE_MS = 2 * DEFAULT_REALTIME_AUTHORIZATION
|
|
|
49
49
|
* that value only promotes a deferred chore to the front of the queue.
|
|
50
50
|
*/
|
|
51
51
|
export const REALTIME_DRAIN_BURST_MS = REALTIME_ADMISSION_DEADLINE_MS;
|
|
52
|
-
/**
|
|
53
|
-
* How many realtime executes may run during one chore hand-off.
|
|
54
|
-
* HQ_SYNC_MAX_CONCURRENCY caps simultaneous S3 object transfers, not these
|
|
55
|
-
* workers. One long transfer keeps its worker; a realtime item that arrives
|
|
56
|
-
* while that execute() is in flight starts on the other slot instead of
|
|
57
|
-
* waiting for the whole batch. In-flight work is never aborted.
|
|
58
|
-
*/
|
|
59
|
-
export const REALTIME_WORKER_OCCUPANCY_CAP = 2;
|
|
60
52
|
let realtimeAdmissionDeadlineMsForTest;
|
|
61
53
|
let realtimeDrainBurstMsForTest;
|
|
62
54
|
export function setRealtimeAdmissionDeadlineMsForTesting(ms) {
|
|
@@ -126,13 +118,11 @@ export function realtimeTelemetryReason(paths) {
|
|
|
126
118
|
return undefined;
|
|
127
119
|
}
|
|
128
120
|
/**
|
|
129
|
-
* One durable-state owner at a time for a full chore. Realtime work runs
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* pre-existing scoped fast-over-slow exception, but never while a chore owns
|
|
135
|
-
* durable state.
|
|
121
|
+
* One durable-state owner at a time for a full chore. Realtime work never runs
|
|
122
|
+
* beside that chore: it explicitly awaits `checkpoint()` after a completed
|
|
123
|
+
* durable unit, then resumes once the hand-off is finished. A separately
|
|
124
|
+
* tracked, explicitly opted-in watcher fast pass may use the pre-existing
|
|
125
|
+
* scoped fast-over-slow exception, but never while a chore owns durable state.
|
|
136
126
|
*/
|
|
137
127
|
export class CooperativePassScheduler {
|
|
138
128
|
now;
|
|
@@ -140,13 +130,6 @@ export class CooperativePassScheduler {
|
|
|
140
130
|
options;
|
|
141
131
|
pending = [];
|
|
142
132
|
active = null;
|
|
143
|
-
/** Realtime executes started by the current hand-off. Not the chore slot. */
|
|
144
|
-
realtimeOccupants = new Set();
|
|
145
|
-
handoffBacklog = null;
|
|
146
|
-
handoffDeferredAt = null;
|
|
147
|
-
handoffAdmitted = false;
|
|
148
|
-
occupantEpoch = 0;
|
|
149
|
-
occupantWaiters = [];
|
|
150
133
|
// Scoped fast realtime work has the established in-process lock exception
|
|
151
134
|
// while a scoped slow realtime upload is in flight. Keep that slot separate
|
|
152
135
|
// from `active`: a chore still has exactly one durable-state owner.
|
|
@@ -197,20 +180,6 @@ export class CooperativePassScheduler {
|
|
|
197
180
|
if (this.canStartFastRealtime(directEntry)) {
|
|
198
181
|
return this.startFastRealtime(directEntry);
|
|
199
182
|
}
|
|
200
|
-
if (workClass === "realtime" &&
|
|
201
|
-
this._handoffActive &&
|
|
202
|
-
this.realtimeOccupants.size < REALTIME_WORKER_OCCUPANCY_CAP) {
|
|
203
|
-
return new Promise((resolve, reject) => {
|
|
204
|
-
const entry = {
|
|
205
|
-
...directEntry,
|
|
206
|
-
enqueuedAt: this.now(),
|
|
207
|
-
resolve,
|
|
208
|
-
reject,
|
|
209
|
-
occupancyArrival: true,
|
|
210
|
-
};
|
|
211
|
-
this.startRealtimeOccupant(entry);
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
183
|
if (this.active === null &&
|
|
215
184
|
this.activeFastRealtime === null &&
|
|
216
185
|
this.pending.length === 0) {
|
|
@@ -237,9 +206,6 @@ export class CooperativePassScheduler {
|
|
|
237
206
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
238
207
|
entry.abort = () => signal.removeEventListener("abort", onAbort);
|
|
239
208
|
}
|
|
240
|
-
if (workClass === "realtime" && this._handoffActive) {
|
|
241
|
-
entry.occupancyArrival = true;
|
|
242
|
-
}
|
|
243
209
|
this.enqueuePending(entry);
|
|
244
210
|
this.drain();
|
|
245
211
|
});
|
|
@@ -292,10 +258,6 @@ export class CooperativePassScheduler {
|
|
|
292
258
|
drain() {
|
|
293
259
|
if (this.stopped || this.pending.length === 0)
|
|
294
260
|
return;
|
|
295
|
-
if (this._handoffActive) {
|
|
296
|
-
this.promoteOccupancyArrivals();
|
|
297
|
-
return;
|
|
298
|
-
}
|
|
299
261
|
if (this.active !== null) {
|
|
300
262
|
const fastRealtime = this.nextFastRealtime();
|
|
301
263
|
if (fastRealtime && this.canStartFastRealtime(fastRealtime)) {
|
|
@@ -408,90 +370,6 @@ export class CooperativePassScheduler {
|
|
|
408
370
|
signal: entry.controller.signal,
|
|
409
371
|
});
|
|
410
372
|
}
|
|
411
|
-
withinHandoffAdmission() {
|
|
412
|
-
if (this.handoffDeferredAt === null)
|
|
413
|
-
return false;
|
|
414
|
-
return this.now() - this.handoffDeferredAt < realtimeDrainBurstMs();
|
|
415
|
-
}
|
|
416
|
-
waitOccupantChange(seenEpoch) {
|
|
417
|
-
if (this.occupantEpoch !== seenEpoch)
|
|
418
|
-
return Promise.resolve();
|
|
419
|
-
return new Promise((resolve) => {
|
|
420
|
-
this.occupantWaiters.push(resolve);
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
|
-
notifyOccupantChange() {
|
|
424
|
-
this.occupantEpoch += 1;
|
|
425
|
-
const waiters = this.occupantWaiters;
|
|
426
|
-
this.occupantWaiters = [];
|
|
427
|
-
for (const resolve of waiters)
|
|
428
|
-
resolve();
|
|
429
|
-
}
|
|
430
|
-
/** Run one realtime execute without aborting it and without taking the chore slot. */
|
|
431
|
-
startRealtimeOccupant(entry) {
|
|
432
|
-
this.clearAdmission(entry);
|
|
433
|
-
this.realtimeOccupants.add(entry);
|
|
434
|
-
this.handoffAdmitted = true;
|
|
435
|
-
let running;
|
|
436
|
-
try {
|
|
437
|
-
running = this.execute(entry);
|
|
438
|
-
}
|
|
439
|
-
catch (error) {
|
|
440
|
-
this.realtimeOccupants.delete(entry);
|
|
441
|
-
if (this.handoffBacklog === entry)
|
|
442
|
-
this.handoffBacklog = null;
|
|
443
|
-
entry.reject(error);
|
|
444
|
-
this.notifyOccupantChange();
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
void running.then((outcome) => {
|
|
448
|
-
this.realtimeOccupants.delete(entry);
|
|
449
|
-
if (this.handoffBacklog === entry)
|
|
450
|
-
this.handoffBacklog = null;
|
|
451
|
-
entry.resolve(outcome);
|
|
452
|
-
this.notifyOccupantChange();
|
|
453
|
-
}, (error) => {
|
|
454
|
-
this.realtimeOccupants.delete(entry);
|
|
455
|
-
if (this.handoffBacklog === entry)
|
|
456
|
-
this.handoffBacklog = null;
|
|
457
|
-
entry.reject(error);
|
|
458
|
-
this.notifyOccupantChange();
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
/** Items that showed up while a transfer was already running take a free slot. */
|
|
462
|
-
promoteOccupancyArrivals() {
|
|
463
|
-
if (!this._handoffActive)
|
|
464
|
-
return;
|
|
465
|
-
while (this.realtimeOccupants.size < REALTIME_WORKER_OCCUPANCY_CAP) {
|
|
466
|
-
const index = this.pending.findIndex((pending) => pending.workClass === "realtime" && pending.occupancyArrival === true);
|
|
467
|
-
if (index < 0)
|
|
468
|
-
return;
|
|
469
|
-
const arrival = this.pending.splice(index, 1)[0];
|
|
470
|
-
this.startRealtimeOccupant(arrival);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
/**
|
|
474
|
-
* Pull at most one already-queued realtime item while the admission window
|
|
475
|
-
* is open and a worker slot is free. Further backlog waits for that
|
|
476
|
-
* execute() so pre-queued hand-offs stay one durable writer at a time.
|
|
477
|
-
*/
|
|
478
|
-
admitHandoffBacklog() {
|
|
479
|
-
if (!this._handoffActive || this.handoffBacklog !== null)
|
|
480
|
-
return;
|
|
481
|
-
if (!this.withinHandoffAdmission())
|
|
482
|
-
return;
|
|
483
|
-
if (this.realtimeOccupants.size >= REALTIME_WORKER_OCCUPANCY_CAP)
|
|
484
|
-
return;
|
|
485
|
-
const realtimeIndex = this.nextRealtimeIndex();
|
|
486
|
-
if (realtimeIndex < 0)
|
|
487
|
-
return;
|
|
488
|
-
const pending = this.pending[realtimeIndex];
|
|
489
|
-
if (pending?.occupancyArrival)
|
|
490
|
-
return;
|
|
491
|
-
const realtime = this.pending.splice(realtimeIndex, 1)[0];
|
|
492
|
-
this.handoffBacklog = realtime;
|
|
493
|
-
this.startRealtimeOccupant(realtime);
|
|
494
|
-
}
|
|
495
373
|
async drainRealtime(entry) {
|
|
496
374
|
if (this.stopped ||
|
|
497
375
|
entry.workClass !== "chore" ||
|
|
@@ -499,48 +377,46 @@ export class CooperativePassScheduler {
|
|
|
499
377
|
!this.pending.some((pending) => pending.workClass === "realtime")) {
|
|
500
378
|
return false;
|
|
501
379
|
}
|
|
502
|
-
// `entry` is suspended at a caller-declared durable boundary.
|
|
503
|
-
//
|
|
504
|
-
//
|
|
505
|
-
//
|
|
380
|
+
// `entry` is suspended at a caller-declared durable boundary. It remains
|
|
381
|
+
// the sole full-pass continuation and will resume after this bounded burst.
|
|
382
|
+
// The burst cap only stops *admitting* further realtime items; an
|
|
383
|
+
// execute() that already started (presign + PUT + journal) runs to
|
|
384
|
+
// completion so a 45s upload is not retried every 30s.
|
|
385
|
+
const deferredAt = this.now();
|
|
386
|
+
const burstMs = realtimeDrainBurstMs();
|
|
506
387
|
this.active = null;
|
|
507
388
|
this._handoffActive = true;
|
|
508
|
-
this.handoffDeferredAt = this.now();
|
|
509
|
-
this.handoffAdmitted = false;
|
|
510
|
-
this.handoffBacklog = null;
|
|
511
389
|
this.options.caps?.suspendForHandoff();
|
|
390
|
+
let handedOff = false;
|
|
512
391
|
try {
|
|
513
|
-
this.
|
|
514
|
-
|
|
515
|
-
if (
|
|
516
|
-
this.admitHandoffBacklog();
|
|
517
|
-
if (this.realtimeOccupants.size === 0)
|
|
518
|
-
break;
|
|
519
|
-
}
|
|
520
|
-
const seen = this.occupantEpoch;
|
|
521
|
-
if (this.realtimeOccupants.size === 0)
|
|
392
|
+
while (!this.stopped && this.now() - deferredAt < burstMs) {
|
|
393
|
+
const realtimeIndex = this.nextRealtimeIndex();
|
|
394
|
+
if (realtimeIndex < 0)
|
|
522
395
|
break;
|
|
523
|
-
|
|
524
|
-
this.
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
396
|
+
const realtime = this.pending.splice(realtimeIndex, 1)[0];
|
|
397
|
+
this.clearAdmission(realtime);
|
|
398
|
+
handedOff = true;
|
|
399
|
+
this.active = realtime;
|
|
400
|
+
try {
|
|
401
|
+
const outcome = await this.execute(realtime);
|
|
402
|
+
realtime.resolve(outcome);
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
realtime.reject(error);
|
|
406
|
+
}
|
|
407
|
+
finally {
|
|
408
|
+
if (this.active === realtime)
|
|
409
|
+
this.active = null;
|
|
410
|
+
}
|
|
533
411
|
}
|
|
534
412
|
}
|
|
535
413
|
finally {
|
|
536
414
|
this._handoffActive = false;
|
|
537
|
-
this.handoffDeferredAt = null;
|
|
538
|
-
this.handoffBacklog = null;
|
|
539
415
|
if (!this.stopped)
|
|
540
416
|
this.active = entry;
|
|
541
417
|
this.options.caps?.resumeAfterHandoff();
|
|
542
418
|
}
|
|
543
|
-
return
|
|
419
|
+
return handedOff;
|
|
544
420
|
}
|
|
545
421
|
async checkpoint(entry) {
|
|
546
422
|
if (this.stopped || entry.workClass !== "chore" || this.active !== entry) {
|