@indigoai-us/hq-cloud 6.16.75-alpha.1 → 6.16.76-alpha.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.
- package/dist/bin/sync-runner-watch-loop.d.ts +0 -45
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +29 -129
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner.d.ts +2 -0
- package/dist/bin/sync-runner.d.ts.map +1 -1
- package/dist/bin/sync-runner.js.map +1 -1
- package/dist/bin/sync-runner.test.js +134 -431
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/sync/full-pass-interval.d.ts +25 -0
- package/dist/sync/full-pass-interval.d.ts.map +1 -0
- package/dist/sync/full-pass-interval.js +53 -0
- package/dist/sync/full-pass-interval.js.map +1 -0
- package/dist/sync/full-pass-interval.test.d.ts +2 -0
- package/dist/sync/full-pass-interval.test.d.ts.map +1 -0
- package/dist/sync/full-pass-interval.test.js +21 -0
- package/dist/sync/full-pass-interval.test.js.map +1 -0
- package/package.json +1 -1
|
@@ -20,7 +20,8 @@ import { PresignObjectIO, S3SdkObjectIO } from "../object-io.js";
|
|
|
20
20
|
import { setBandwidthGovernorForTesting } from "../bandwidth.js";
|
|
21
21
|
import { POST_SYNC_FLAG_KEYS, } from "./sync-runner-post-sync-flags.js";
|
|
22
22
|
import { FakeClock, TreeWatcher, } from "../watcher.js";
|
|
23
|
-
import { adaptivePollMs, advanceMonotonicDeadline, DEFAULT_EVENT_BATCH_LIMIT, DEFAULT_FAST_LANE_MAX_BYTES, DEFAULT_FAST_LANE_MAX_FILE_BYTES, DEFAULT_FAST_LANE_MAX_FILES,
|
|
23
|
+
import { adaptivePollMs, advanceMonotonicDeadline, DEFAULT_EVENT_BATCH_LIMIT, DEFAULT_FAST_LANE_MAX_BYTES, DEFAULT_FAST_LANE_MAX_FILE_BYTES, DEFAULT_FAST_LANE_MAX_FILES, EVENT_BATCH_LIMIT_ENV, FAST_LANE_MAX_BYTES_ENV, FAST_LANE_MAX_FILES_ENV, isFastLocalBatch, isFastReceiverBatch, partitionLocalBatch, journalEntriesForWatcherDelete, resolveEventBatchLimit, resolveWatchPollMs, CHORE_STARVATION_CAP_MS, CooperativePassScheduler, REALTIME_ADMISSION_DEADLINE_MS, REALTIME_DRAIN_BURST_MS, REALTIME_WORKER_OCCUPANCY_CAP, RealtimeAdmissionTimeoutError, setRealtimeAdmissionDeadlineMsForTesting, setRealtimeDrainBurstMsForTesting, normalizeCoordinatorPaths, shouldQuarantineWatcherDeleteIntents, shouldUseAreaStorage, WATCHER_REDISCOVERY_RETRY_MS, WATCHER_REDISCOVERY_RETRY_MAX_MS, } from "./sync-runner-watch-loop.js";
|
|
24
|
+
import { DEFAULT_FULL_PASS_INTERVAL_MS } from "../sync/full-pass-interval.js";
|
|
24
25
|
import { FullPassCapController, resetFullPassCapLogForTest, } from "../sync/full-pass-caps.js";
|
|
25
26
|
import { AreaLedgerMigration, JournalStore, openJournalStateStoreForMigration, PERSONAL_VAULT_JOURNAL_SLUG, readJournal, readJournalScoped, writeJournal, } from "../journal.js";
|
|
26
27
|
import { AreaLedger } from "../sync/area-ledger.js";
|
|
@@ -4636,28 +4637,13 @@ describe("advanceMonotonicDeadline", () => {
|
|
|
4636
4637
|
});
|
|
4637
4638
|
});
|
|
4638
4639
|
});
|
|
4639
|
-
describe("watch-loop reconcile
|
|
4640
|
+
describe("watch-loop reconcile configuration", () => {
|
|
4640
4641
|
it("uses the shipped 10,000 event-batch default while allowing smaller and larger overrides", () => {
|
|
4641
4642
|
expect(DEFAULT_EVENT_BATCH_LIMIT).toBe(10_000);
|
|
4642
4643
|
expect(resolveEventBatchLimit({})).toBe(10_000);
|
|
4643
4644
|
expect(resolveEventBatchLimit({ [EVENT_BATCH_LIMIT_ENV]: "5" })).toBe(5);
|
|
4644
4645
|
expect(resolveEventBatchLimit({ [EVENT_BATCH_LIMIT_ENV]: "50000" })).toBe(50_000);
|
|
4645
4646
|
});
|
|
4646
|
-
it("defaults the full-reconcile cadence to one elapsed hour for an unset or invalid interval", () => {
|
|
4647
|
-
// The legacy default was "every tenth tick" with no elapsed-time floor.
|
|
4648
|
-
// Ticks fire on every watcher batch, not just polls, so on an active
|
|
4649
|
-
// vault that meant a full pass every 4-8 minutes — and each pass on a
|
|
4650
|
-
// real install lasts ~10 minutes. Full reconcile is the correctness
|
|
4651
|
-
// backstop behind event-push, so elapsed time is the right clock.
|
|
4652
|
-
expect(DEFAULT_FULL_RECONCILE_MS).toBe(3_600_000);
|
|
4653
|
-
expect(resolveFullReconcileMs({})).toBe(DEFAULT_FULL_RECONCILE_MS);
|
|
4654
|
-
for (const raw of ["", "0", "0.5", "-1", "NaN", "not-a-number", "Infinity"]) {
|
|
4655
|
-
expect(resolveFullReconcileMs({ [FULL_RECONCILE_MS_ENV]: raw })).toBe(DEFAULT_FULL_RECONCILE_MS);
|
|
4656
|
-
}
|
|
4657
|
-
});
|
|
4658
|
-
it("accepts a positive millisecond full-reconcile interval", () => {
|
|
4659
|
-
expect(resolveFullReconcileMs({ [FULL_RECONCILE_MS_ENV]: "10800000" })).toBe(10_800_000);
|
|
4660
|
-
});
|
|
4661
4647
|
});
|
|
4662
4648
|
describe("runRunnerWithLoop — adaptive poll interval (no --poll-remote-ms)", () => {
|
|
4663
4649
|
// Capture the ms handed to sleep on the FIRST poll, then hang so the loop
|
|
@@ -4873,10 +4859,8 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
4873
4859
|
it("parallel coordinator activates every event surface after a partial completed full reconcile", async () => {
|
|
4874
4860
|
const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
4875
4861
|
const previousEventSync = process.env.HQ_SYNC_EVENT_SYNC;
|
|
4876
|
-
const previousFullReconcileMs = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
4877
4862
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
|
|
4878
4863
|
process.env.HQ_SYNC_EVENT_SYNC = "1";
|
|
4879
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = "60000";
|
|
4880
4864
|
const watcher = makeWatcherStub();
|
|
4881
4865
|
const receiver = {
|
|
4882
4866
|
connected: false,
|
|
@@ -4936,19 +4920,13 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
4936
4920
|
delete process.env.HQ_SYNC_EVENT_SYNC;
|
|
4937
4921
|
else
|
|
4938
4922
|
process.env.HQ_SYNC_EVENT_SYNC = previousEventSync;
|
|
4939
|
-
if (previousFullReconcileMs === undefined)
|
|
4940
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
4941
|
-
else
|
|
4942
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = previousFullReconcileMs;
|
|
4943
4923
|
}
|
|
4944
4924
|
});
|
|
4945
4925
|
it("parallel coordinator activates event surfaces and advances cadence after a numeric-zero full reconcile", async () => {
|
|
4946
4926
|
const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
4947
4927
|
const previousEventSync = process.env.HQ_SYNC_EVENT_SYNC;
|
|
4948
|
-
const previousFullReconcileMs = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
4949
4928
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
|
|
4950
4929
|
process.env.HQ_SYNC_EVENT_SYNC = "1";
|
|
4951
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = "60000";
|
|
4952
4930
|
const watcher = makeWatcherStub();
|
|
4953
4931
|
const receiver = {
|
|
4954
4932
|
connected: false,
|
|
@@ -5008,64 +4986,6 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
5008
4986
|
delete process.env.HQ_SYNC_EVENT_SYNC;
|
|
5009
4987
|
else
|
|
5010
4988
|
process.env.HQ_SYNC_EVENT_SYNC = previousEventSync;
|
|
5011
|
-
if (previousFullReconcileMs === undefined)
|
|
5012
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
5013
|
-
else
|
|
5014
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = previousFullReconcileMs;
|
|
5015
|
-
}
|
|
5016
|
-
});
|
|
5017
|
-
it("backs off failed parallel full-reconcile completions before another chore is admitted", async () => {
|
|
5018
|
-
const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
5019
|
-
const previousFullReconcileMs = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
5020
|
-
process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
|
|
5021
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = "1";
|
|
5022
|
-
const runPass = vi.fn().mockResolvedValue(1);
|
|
5023
|
-
const delays = [];
|
|
5024
|
-
const waiters = [];
|
|
5025
|
-
let now = 0;
|
|
5026
|
-
let shutdown = () => { };
|
|
5027
|
-
const sleep = (ms) => {
|
|
5028
|
-
delays.push(ms);
|
|
5029
|
-
return new Promise((resolve) => {
|
|
5030
|
-
waiters.push(resolve);
|
|
5031
|
-
});
|
|
5032
|
-
};
|
|
5033
|
-
const loop = runRunnerWithLoop(["--companies", "--watch", "--poll-remote-ms", "1", "--hq-root", "/tmp/hq"], {
|
|
5034
|
-
runPass,
|
|
5035
|
-
clock: new FakeClock(),
|
|
5036
|
-
monotonicNow: () => now,
|
|
5037
|
-
sleep,
|
|
5038
|
-
onShutdownSignal: (handler) => {
|
|
5039
|
-
shutdown = handler;
|
|
5040
|
-
return () => { };
|
|
5041
|
-
},
|
|
5042
|
-
});
|
|
5043
|
-
try {
|
|
5044
|
-
for (let attempt = 0; attempt < 50 && runPass.mock.calls.length < 3; attempt += 1) {
|
|
5045
|
-
const resolve = waiters.shift();
|
|
5046
|
-
if (resolve) {
|
|
5047
|
-
now += 1;
|
|
5048
|
-
resolve();
|
|
5049
|
-
await flushLoopMicrotasks(30);
|
|
5050
|
-
}
|
|
5051
|
-
else {
|
|
5052
|
-
await new Promise((resolveNext) => setImmediate(resolveNext));
|
|
5053
|
-
}
|
|
5054
|
-
}
|
|
5055
|
-
expect(runPass).toHaveBeenCalledTimes(3);
|
|
5056
|
-
expect(delays).toContain(60_000);
|
|
5057
|
-
}
|
|
5058
|
-
finally {
|
|
5059
|
-
shutdown();
|
|
5060
|
-
await expect(loop).resolves.toBe(0);
|
|
5061
|
-
if (previousCoordinator === undefined)
|
|
5062
|
-
delete process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
5063
|
-
else
|
|
5064
|
-
process.env.HQ_SYNC_PARALLEL_COORDINATOR = previousCoordinator;
|
|
5065
|
-
if (previousFullReconcileMs === undefined)
|
|
5066
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
5067
|
-
else
|
|
5068
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = previousFullReconcileMs;
|
|
5069
4989
|
}
|
|
5070
4990
|
});
|
|
5071
4991
|
it("parallel coordinator keeps event surfaces off for an auth-required full reconcile", async () => {
|
|
@@ -5198,7 +5118,7 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
5198
5118
|
sleep.tick();
|
|
5199
5119
|
await flushLoopMicrotasks();
|
|
5200
5120
|
}
|
|
5201
|
-
clockState.now =
|
|
5121
|
+
clockState.now = DEFAULT_FULL_PASS_INTERVAL_MS;
|
|
5202
5122
|
sleep.tick();
|
|
5203
5123
|
await flushLoopMicrotasks();
|
|
5204
5124
|
// Tick 1 and the first tick after an hour has elapsed are full
|
|
@@ -5266,7 +5186,7 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
5266
5186
|
}
|
|
5267
5187
|
expect(runPass).toHaveBeenCalledTimes(1);
|
|
5268
5188
|
// The hourly cadence, not a tick count, schedules the next full pass.
|
|
5269
|
-
clockState.now =
|
|
5189
|
+
clockState.now = DEFAULT_FULL_PASS_INTERVAL_MS;
|
|
5270
5190
|
sleep.tick();
|
|
5271
5191
|
await flushLoopMicrotasks(30);
|
|
5272
5192
|
expect(runPass).toHaveBeenCalledTimes(2);
|
|
@@ -8952,137 +8872,6 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
8952
8872
|
await expect(loop).resolves.toBe(0);
|
|
8953
8873
|
expect(watcher.disposed).toBe(false);
|
|
8954
8874
|
});
|
|
8955
|
-
it("bounds repeated watch-pass exits with a fake-clock retry budget while keeping the runner alive", async () => {
|
|
8956
|
-
const watcher = makeWatcherStub();
|
|
8957
|
-
const runPass = vi.fn().mockResolvedValue(1);
|
|
8958
|
-
const delays = [];
|
|
8959
|
-
const waiters = [];
|
|
8960
|
-
let now = 0;
|
|
8961
|
-
let shutdown = () => { };
|
|
8962
|
-
let settled;
|
|
8963
|
-
const sleep = (ms) => {
|
|
8964
|
-
delays.push(ms);
|
|
8965
|
-
return new Promise((resolve) => {
|
|
8966
|
-
waiters.push(resolve);
|
|
8967
|
-
});
|
|
8968
|
-
};
|
|
8969
|
-
const tick = async (advanceMs) => {
|
|
8970
|
-
now += advanceMs;
|
|
8971
|
-
const resolve = waiters.shift();
|
|
8972
|
-
if (!resolve)
|
|
8973
|
-
throw new Error("retry sleep was not pending");
|
|
8974
|
-
resolve();
|
|
8975
|
-
await flushLoopMicrotasks();
|
|
8976
|
-
};
|
|
8977
|
-
const waitForRetrySleep = async () => {
|
|
8978
|
-
for (let attempt = 0; attempt < 200; attempt += 1) {
|
|
8979
|
-
if (waiters.length > 0)
|
|
8980
|
-
return;
|
|
8981
|
-
await new Promise((resolve) => setImmediate(resolve));
|
|
8982
|
-
}
|
|
8983
|
-
throw new Error("timed out waiting for retry sleep");
|
|
8984
|
-
};
|
|
8985
|
-
const loop = runRunnerWithLoop(["--companies", "--watch", "--event-push", "--poll-remote-ms", "1", "--hq-root", "/tmp/hq"], {
|
|
8986
|
-
runPass,
|
|
8987
|
-
clock: new FakeClock(),
|
|
8988
|
-
createWatcher: () => watcher,
|
|
8989
|
-
monotonicNow: () => now,
|
|
8990
|
-
sleep,
|
|
8991
|
-
onShutdownSignal: (handler) => {
|
|
8992
|
-
shutdown = handler;
|
|
8993
|
-
return () => { };
|
|
8994
|
-
},
|
|
8995
|
-
}).then((code) => {
|
|
8996
|
-
settled = code;
|
|
8997
|
-
return code;
|
|
8998
|
-
});
|
|
8999
|
-
try {
|
|
9000
|
-
await waitForRetrySleep();
|
|
9001
|
-
expect(runPass).toHaveBeenCalledTimes(1);
|
|
9002
|
-
expect(delays).toEqual([1]);
|
|
9003
|
-
await tick(1_000);
|
|
9004
|
-
expect(runPass).toHaveBeenCalledTimes(2);
|
|
9005
|
-
expect(delays).toEqual([1, 1]);
|
|
9006
|
-
await tick(1_000);
|
|
9007
|
-
expect(runPass).toHaveBeenCalledTimes(3);
|
|
9008
|
-
expect(delays).toEqual([1, 1, 60_000]);
|
|
9009
|
-
await tick(60_000);
|
|
9010
|
-
await tick(120_000);
|
|
9011
|
-
await tick(240_000);
|
|
9012
|
-
await tick(480_000);
|
|
9013
|
-
expect(runPass).toHaveBeenCalledTimes(7);
|
|
9014
|
-
expect(delays).toEqual([
|
|
9015
|
-
1,
|
|
9016
|
-
1,
|
|
9017
|
-
60_000,
|
|
9018
|
-
120_000,
|
|
9019
|
-
240_000,
|
|
9020
|
-
480_000,
|
|
9021
|
-
600_000,
|
|
9022
|
-
]);
|
|
9023
|
-
// The retry window is quiet-time based, not anchored to the first
|
|
9024
|
-
// failure. Continuing failures after thirty minutes must remain capped.
|
|
9025
|
-
await tick(600_000);
|
|
9026
|
-
await tick(600_000);
|
|
9027
|
-
expect(runPass).toHaveBeenCalledTimes(9);
|
|
9028
|
-
expect(delays.slice(-2)).toEqual([600_000, 600_000]);
|
|
9029
|
-
expect(settled).toBeUndefined();
|
|
9030
|
-
expect(watcher.disposed).toBe(false);
|
|
9031
|
-
}
|
|
9032
|
-
finally {
|
|
9033
|
-
shutdown();
|
|
9034
|
-
await expect(loop).resolves.toBe(0);
|
|
9035
|
-
}
|
|
9036
|
-
});
|
|
9037
|
-
it("does not let a watcher interrupt bypass a failed-pass retry deadline", async () => {
|
|
9038
|
-
const watcher = makeWatcherStub();
|
|
9039
|
-
let passes = 0;
|
|
9040
|
-
const runPass = vi.fn().mockImplementation(async () => {
|
|
9041
|
-
passes += 1;
|
|
9042
|
-
return passes === 1 ? 0 : 1;
|
|
9043
|
-
});
|
|
9044
|
-
const waiters = [];
|
|
9045
|
-
const now = 0;
|
|
9046
|
-
let shutdown = () => { };
|
|
9047
|
-
const sleep = vi.fn(() => new Promise((resolve) => {
|
|
9048
|
-
waiters.push(resolve);
|
|
9049
|
-
}));
|
|
9050
|
-
const loop = runRunnerWithLoop(["--companies", "--watch", "--event-push", "--poll-remote-ms", "1", "--hq-root", "/tmp/hq"], {
|
|
9051
|
-
runPass,
|
|
9052
|
-
clock: new FakeClock(),
|
|
9053
|
-
createWatcher: () => watcher,
|
|
9054
|
-
monotonicNow: () => now,
|
|
9055
|
-
sleep,
|
|
9056
|
-
onShutdownSignal: (handler) => {
|
|
9057
|
-
shutdown = handler;
|
|
9058
|
-
return () => { };
|
|
9059
|
-
},
|
|
9060
|
-
});
|
|
9061
|
-
try {
|
|
9062
|
-
await waitForPollSleep({
|
|
9063
|
-
pendingCount: () => waiters.length,
|
|
9064
|
-
});
|
|
9065
|
-
expect(runPass).toHaveBeenCalledTimes(1);
|
|
9066
|
-
watcher.emit();
|
|
9067
|
-
await flushLoopMicrotasks(30);
|
|
9068
|
-
expect(runPass).toHaveBeenCalledTimes(2);
|
|
9069
|
-
watcher.emit();
|
|
9070
|
-
await flushLoopMicrotasks(30);
|
|
9071
|
-
expect(runPass).toHaveBeenCalledTimes(3);
|
|
9072
|
-
watcher.emit();
|
|
9073
|
-
await flushLoopMicrotasks(30);
|
|
9074
|
-
expect(runPass).toHaveBeenCalledTimes(4);
|
|
9075
|
-
expect(sleep).toHaveBeenLastCalledWith(60_000);
|
|
9076
|
-
watcher.emit();
|
|
9077
|
-
await flushLoopMicrotasks(30);
|
|
9078
|
-
expect(runPass).toHaveBeenCalledTimes(4);
|
|
9079
|
-
expect(sleep).toHaveBeenLastCalledWith(60_000);
|
|
9080
|
-
}
|
|
9081
|
-
finally {
|
|
9082
|
-
shutdown();
|
|
9083
|
-
await expect(loop).resolves.toBe(0);
|
|
9084
|
-
}
|
|
9085
|
-
});
|
|
9086
8875
|
it("alerts when a partial pass failed before a company's download leg", async () => {
|
|
9087
8876
|
const watcher = makeWatcherStub();
|
|
9088
8877
|
const stderrWrite = vi
|
|
@@ -9117,7 +8906,7 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
9117
8906
|
runPass,
|
|
9118
8907
|
clock: new FakeClock(),
|
|
9119
8908
|
createWatcher: () => watcher,
|
|
9120
|
-
monotonicNow: () => (monotonic +=
|
|
8909
|
+
monotonicNow: () => (monotonic += DEFAULT_FULL_PASS_INTERVAL_MS),
|
|
9121
8910
|
sleep: sleep.sleep,
|
|
9122
8911
|
onShutdownSignal: (handler) => {
|
|
9123
8912
|
triggerShutdown = handler;
|
|
@@ -10099,9 +9888,7 @@ describe("CooperativePassScheduler", () => {
|
|
|
10099
9888
|
describe("first-tick realtime yield", () => {
|
|
10100
9889
|
it("commits a watcher push at the first chore checkpoint within the admission deadline", async () => {
|
|
10101
9890
|
const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
10102
|
-
const previousInterval = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10103
9891
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
|
|
10104
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
10105
9892
|
const timings = [];
|
|
10106
9893
|
const spy = vi.spyOn(process.stderr, "write").mockImplementation((chunk) => {
|
|
10107
9894
|
const text = String(chunk);
|
|
@@ -10204,10 +9991,6 @@ describe("first-tick realtime yield", () => {
|
|
|
10204
9991
|
delete process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
10205
9992
|
else
|
|
10206
9993
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = previousCoordinator;
|
|
10207
|
-
if (previousInterval === undefined)
|
|
10208
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10209
|
-
else
|
|
10210
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = previousInterval;
|
|
10211
9994
|
}
|
|
10212
9995
|
});
|
|
10213
9996
|
});
|
|
@@ -10502,8 +10285,6 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10502
10285
|
capture.restore();
|
|
10503
10286
|
});
|
|
10504
10287
|
it("logs event-push-surfaces-inactive without silently attributing the first tick", async () => {
|
|
10505
|
-
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10506
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
10507
10288
|
const capture = captureFullReconcileDecisions();
|
|
10508
10289
|
try {
|
|
10509
10290
|
const sleep = makeSteppableSleep();
|
|
@@ -10532,10 +10313,6 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10532
10313
|
}
|
|
10533
10314
|
finally {
|
|
10534
10315
|
capture.restore();
|
|
10535
|
-
if (saved === undefined)
|
|
10536
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10537
|
-
else
|
|
10538
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
10539
10316
|
}
|
|
10540
10317
|
});
|
|
10541
10318
|
it("reports every matching trigger instead of short-circuiting at the first", async () => {
|
|
@@ -10590,9 +10367,7 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10590
10367
|
});
|
|
10591
10368
|
it("skips a 404 company route in a mixed drain and records a completed full reconcile", async () => {
|
|
10592
10369
|
const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
10593
|
-
const previousInterval = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10594
10370
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
|
|
10595
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
10596
10371
|
const failedLines = [];
|
|
10597
10372
|
const decisions = [];
|
|
10598
10373
|
const timingRecords = [];
|
|
@@ -10692,17 +10467,11 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10692
10467
|
delete process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
10693
10468
|
else
|
|
10694
10469
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = previousCoordinator;
|
|
10695
|
-
if (previousInterval === undefined)
|
|
10696
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10697
|
-
else
|
|
10698
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = previousInterval;
|
|
10699
10470
|
}
|
|
10700
10471
|
});
|
|
10701
10472
|
it("does not escalate a fully-enumerated over-limit batch to a full reconcile", async () => {
|
|
10702
10473
|
const savedLimit = process.env.HQ_SYNC_EVENT_BATCH_LIMIT;
|
|
10703
|
-
const savedInterval = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10704
10474
|
process.env.HQ_SYNC_EVENT_BATCH_LIMIT = "2";
|
|
10705
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
10706
10475
|
const journal = captureWatchLoopJournal();
|
|
10707
10476
|
try {
|
|
10708
10477
|
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
@@ -10742,17 +10511,11 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10742
10511
|
delete process.env.HQ_SYNC_EVENT_BATCH_LIMIT;
|
|
10743
10512
|
else
|
|
10744
10513
|
process.env.HQ_SYNC_EVENT_BATCH_LIMIT = savedLimit;
|
|
10745
|
-
if (savedInterval === undefined)
|
|
10746
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10747
|
-
else
|
|
10748
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = savedInterval;
|
|
10749
10514
|
}
|
|
10750
10515
|
});
|
|
10751
10516
|
it("still escalates an overflowed batch with unknown routes to a full reconcile", async () => {
|
|
10752
10517
|
const savedLimit = process.env.HQ_SYNC_EVENT_BATCH_LIMIT;
|
|
10753
|
-
const savedInterval = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10754
10518
|
process.env.HQ_SYNC_EVENT_BATCH_LIMIT = "2";
|
|
10755
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
10756
10519
|
const journal = captureWatchLoopJournal();
|
|
10757
10520
|
try {
|
|
10758
10521
|
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
@@ -10784,15 +10547,9 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10784
10547
|
delete process.env.HQ_SYNC_EVENT_BATCH_LIMIT;
|
|
10785
10548
|
else
|
|
10786
10549
|
process.env.HQ_SYNC_EVENT_BATCH_LIMIT = savedLimit;
|
|
10787
|
-
if (savedInterval === undefined)
|
|
10788
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10789
|
-
else
|
|
10790
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = savedInterval;
|
|
10791
10550
|
}
|
|
10792
10551
|
});
|
|
10793
|
-
it("logs scheduled-interval as the sole full-reconcile trigger on the default
|
|
10794
|
-
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10795
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10552
|
+
it("logs scheduled-interval as the sole full-reconcile trigger on the six-hour default", async () => {
|
|
10796
10553
|
const capture = captureFullReconcileDecisions();
|
|
10797
10554
|
try {
|
|
10798
10555
|
const clockState = { now: 0 };
|
|
@@ -10818,11 +10575,11 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10818
10575
|
sleep.tick();
|
|
10819
10576
|
await flushLoopMicrotasks();
|
|
10820
10577
|
}
|
|
10821
|
-
// A dozen ticks inside the
|
|
10578
|
+
// A dozen ticks inside the interval: never a scheduled full pass.
|
|
10822
10579
|
expect(runPass).not.toHaveBeenCalled();
|
|
10823
10580
|
capture.clear();
|
|
10824
10581
|
runPass.mockClear();
|
|
10825
|
-
clockState.now =
|
|
10582
|
+
clockState.now = DEFAULT_FULL_PASS_INTERVAL_MS;
|
|
10826
10583
|
sleep.tick();
|
|
10827
10584
|
await flushLoopMicrotasks();
|
|
10828
10585
|
expectFullReconcileDecision(capture.records[0], "full", [
|
|
@@ -10834,10 +10591,6 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10834
10591
|
}
|
|
10835
10592
|
finally {
|
|
10836
10593
|
capture.restore();
|
|
10837
|
-
if (saved === undefined)
|
|
10838
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10839
|
-
else
|
|
10840
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
10841
10594
|
}
|
|
10842
10595
|
});
|
|
10843
10596
|
it("logs scoped passes with their batch path count and preserves the scoped route", async () => {
|
|
@@ -10858,8 +10611,6 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10858
10611
|
capture.restore();
|
|
10859
10612
|
});
|
|
10860
10613
|
it("reports interval diagnostics while the configured interval has not elapsed", async () => {
|
|
10861
|
-
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10862
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = "1000";
|
|
10863
10614
|
const capture = captureFullReconcileDecisions();
|
|
10864
10615
|
try {
|
|
10865
10616
|
const clockState = { now: 0 };
|
|
@@ -10868,6 +10619,7 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10868
10619
|
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
10869
10620
|
const loop = runRunnerWithLoop(watchArgv, {
|
|
10870
10621
|
runPass,
|
|
10622
|
+
fullPassIntervalSource: { read: () => 1_000 },
|
|
10871
10623
|
monotonicNow: () => clockState.now,
|
|
10872
10624
|
createWatcher: () => makeBatchWatcherStub(),
|
|
10873
10625
|
sleep: sleep.sleep,
|
|
@@ -10903,10 +10655,6 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10903
10655
|
}
|
|
10904
10656
|
finally {
|
|
10905
10657
|
capture.restore();
|
|
10906
|
-
if (saved === undefined)
|
|
10907
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10908
|
-
else
|
|
10909
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
10910
10658
|
}
|
|
10911
10659
|
});
|
|
10912
10660
|
it("startup runs one full reconcile, then watcher edits interrupt the pending wait", async () => {
|
|
@@ -11212,8 +10960,6 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11212
10960
|
await loop;
|
|
11213
10961
|
});
|
|
11214
10962
|
it("drops an unroutable batch and leaves the next unexpired poll idle", async () => {
|
|
11215
|
-
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11216
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = "1000";
|
|
11217
10963
|
const capture = captureFullReconcileDecisions();
|
|
11218
10964
|
try {
|
|
11219
10965
|
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
@@ -11239,10 +10985,6 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11239
10985
|
}
|
|
11240
10986
|
finally {
|
|
11241
10987
|
capture.restore();
|
|
11242
|
-
if (saved === undefined)
|
|
11243
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11244
|
-
else
|
|
11245
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11246
10988
|
}
|
|
11247
10989
|
});
|
|
11248
10990
|
it("personal scoped ticks preserve personal mode for the pull leg", async () => {
|
|
@@ -11401,7 +11143,7 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11401
11143
|
}
|
|
11402
11144
|
expect(runPass).not.toHaveBeenCalled();
|
|
11403
11145
|
runPass.mockClear();
|
|
11404
|
-
clockState.now =
|
|
11146
|
+
clockState.now = DEFAULT_FULL_PASS_INTERVAL_MS;
|
|
11405
11147
|
sleep.tick();
|
|
11406
11148
|
await flushLoopMicrotasks();
|
|
11407
11149
|
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
@@ -11409,134 +11151,105 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11409
11151
|
sleep.tick();
|
|
11410
11152
|
await loop;
|
|
11411
11153
|
});
|
|
11412
|
-
it("schedules the full reconcile by elapsed time, not tick count,
|
|
11154
|
+
it("schedules the full reconcile by elapsed time, not tick count, at the flag fallback", async () => {
|
|
11413
11155
|
// Pre-fix the unset default was every tenth tick. Ticks fire on every
|
|
11414
11156
|
// watcher batch, so an active vault ran a ~10-minute full pass every
|
|
11415
11157
|
// 4-8 minutes — nearly continuous, and the runner's dominant CPU cost
|
|
11416
11158
|
// once per-pass hashing was fixed.
|
|
11417
|
-
const
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
11434
|
-
|
|
11435
|
-
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
// two full passes here.
|
|
11441
|
-
for (let tick = 0; tick < 20; tick++) {
|
|
11442
|
-
clockState.now += 177_000;
|
|
11443
|
-
sleep.tick();
|
|
11444
|
-
await flushLoopMicrotasks();
|
|
11445
|
-
}
|
|
11446
|
-
expect(runPass).not.toHaveBeenCalled();
|
|
11447
|
-
runPass.mockClear();
|
|
11448
|
-
clockState.now = DEFAULT_FULL_RECONCILE_MS;
|
|
11159
|
+
const clockState = { now: 0 };
|
|
11160
|
+
const watcher = makeBatchWatcherStub();
|
|
11161
|
+
const sleep = makeSteppableSleep();
|
|
11162
|
+
let triggerShutdown = () => { };
|
|
11163
|
+
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
11164
|
+
const loop = runRunnerWithLoop(watchArgv, {
|
|
11165
|
+
runPass,
|
|
11166
|
+
clock: new FakeClock(),
|
|
11167
|
+
monotonicNow: () => clockState.now,
|
|
11168
|
+
createWatcher: () => watcher,
|
|
11169
|
+
sleep: sleep.sleep,
|
|
11170
|
+
onShutdownSignal: (handler) => {
|
|
11171
|
+
triggerShutdown = handler;
|
|
11172
|
+
return () => { };
|
|
11173
|
+
},
|
|
11174
|
+
});
|
|
11175
|
+
await flushLoopMicrotasks();
|
|
11176
|
+
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11177
|
+
runPass.mockClear();
|
|
11178
|
+
// Twenty ticks in fifty-nine minutes: the old cadence would have run
|
|
11179
|
+
// two full passes here.
|
|
11180
|
+
for (let tick = 0; tick < 20; tick++) {
|
|
11181
|
+
clockState.now += 177_000;
|
|
11449
11182
|
sleep.tick();
|
|
11450
11183
|
await flushLoopMicrotasks();
|
|
11451
|
-
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11452
|
-
triggerShutdown();
|
|
11453
|
-
await loop;
|
|
11454
|
-
}
|
|
11455
|
-
finally {
|
|
11456
|
-
if (saved === undefined)
|
|
11457
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11458
|
-
else
|
|
11459
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11460
11184
|
}
|
|
11185
|
+
expect(runPass).not.toHaveBeenCalled();
|
|
11186
|
+
runPass.mockClear();
|
|
11187
|
+
clockState.now = DEFAULT_FULL_PASS_INTERVAL_MS;
|
|
11188
|
+
sleep.tick();
|
|
11189
|
+
await flushLoopMicrotasks();
|
|
11190
|
+
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11191
|
+
triggerShutdown();
|
|
11192
|
+
await loop;
|
|
11461
11193
|
});
|
|
11462
|
-
it("uses the
|
|
11463
|
-
const
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
triggerShutdown();
|
|
11496
|
-
await loop;
|
|
11497
|
-
}
|
|
11498
|
-
finally {
|
|
11499
|
-
if (saved === undefined)
|
|
11500
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11501
|
-
else
|
|
11502
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11503
|
-
}
|
|
11194
|
+
it("uses the hq-flag interval source instead of the tick count", async () => {
|
|
11195
|
+
const clockState = { now: 0 };
|
|
11196
|
+
const watcher = makeBatchWatcherStub();
|
|
11197
|
+
const sleep = makeSteppableSleep();
|
|
11198
|
+
let triggerShutdown = () => { };
|
|
11199
|
+
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
11200
|
+
const loop = runRunnerWithLoop(watchArgv, {
|
|
11201
|
+
runPass,
|
|
11202
|
+
fullPassIntervalSource: { read: () => 1_000 },
|
|
11203
|
+
clock: new FakeClock(),
|
|
11204
|
+
monotonicNow: () => clockState.now,
|
|
11205
|
+
createWatcher: () => watcher,
|
|
11206
|
+
sleep: sleep.sleep,
|
|
11207
|
+
onShutdownSignal: (handler) => {
|
|
11208
|
+
triggerShutdown = handler;
|
|
11209
|
+
return () => { };
|
|
11210
|
+
},
|
|
11211
|
+
});
|
|
11212
|
+
await flushLoopMicrotasks();
|
|
11213
|
+
// Startup always forces the first full reconcile, and starts the interval.
|
|
11214
|
+
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11215
|
+
runPass.mockClear();
|
|
11216
|
+
clockState.now = 999;
|
|
11217
|
+
sleep.tick();
|
|
11218
|
+
await flushLoopMicrotasks();
|
|
11219
|
+
expect(runPass).not.toHaveBeenCalled();
|
|
11220
|
+
runPass.mockClear();
|
|
11221
|
+
clockState.now = 1_000;
|
|
11222
|
+
sleep.tick();
|
|
11223
|
+
await flushLoopMicrotasks();
|
|
11224
|
+
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11225
|
+
triggerShutdown();
|
|
11226
|
+
await loop;
|
|
11504
11227
|
});
|
|
11505
11228
|
it("does not let a full-reconcile interval suppress event-push activation", async () => {
|
|
11506
|
-
const
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11531
|
-
triggerShutdown();
|
|
11532
|
-
await loop;
|
|
11533
|
-
}
|
|
11534
|
-
finally {
|
|
11535
|
-
if (saved === undefined)
|
|
11536
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11537
|
-
else
|
|
11538
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11539
|
-
}
|
|
11229
|
+
const watcher = makeBatchWatcherStub();
|
|
11230
|
+
const sleep = makeSteppableSleep();
|
|
11231
|
+
let triggerShutdown = () => { };
|
|
11232
|
+
// A numeric partial result does not activate event-push surfaces, so the
|
|
11233
|
+
// next tick must force another full pass even though three hours have not elapsed.
|
|
11234
|
+
const runPass = vi.fn().mockResolvedValue(PARTIAL_SYNC_EXIT);
|
|
11235
|
+
const loop = runRunnerWithLoop(watchArgv, {
|
|
11236
|
+
runPass,
|
|
11237
|
+
clock: new FakeClock(),
|
|
11238
|
+
monotonicNow: () => 0,
|
|
11239
|
+
createWatcher: () => watcher,
|
|
11240
|
+
sleep: sleep.sleep,
|
|
11241
|
+
onShutdownSignal: (handler) => {
|
|
11242
|
+
triggerShutdown = handler;
|
|
11243
|
+
return () => { };
|
|
11244
|
+
},
|
|
11245
|
+
});
|
|
11246
|
+
await flushLoopMicrotasks();
|
|
11247
|
+
runPass.mockClear();
|
|
11248
|
+
sleep.tick();
|
|
11249
|
+
await flushLoopMicrotasks();
|
|
11250
|
+
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11251
|
+
triggerShutdown();
|
|
11252
|
+
await loop;
|
|
11540
11253
|
});
|
|
11541
11254
|
it("overflow with known dropped-route hints fans out per touched route instead of a full reconcile", async () => {
|
|
11542
11255
|
const capture = captureFullReconcileDecisions();
|
|
@@ -11671,50 +11384,40 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11671
11384
|
await loop;
|
|
11672
11385
|
});
|
|
11673
11386
|
it("a batch above the shipped 10,000-path default stays on chunked targeted passes before the interval", async () => {
|
|
11674
|
-
const
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
expect(pushScopeCounts.reduce((sum, count) => sum + count, 0)).toBe(10_001);
|
|
11709
|
-
triggerShutdown();
|
|
11710
|
-
await loop;
|
|
11711
|
-
}
|
|
11712
|
-
finally {
|
|
11713
|
-
if (saved === undefined)
|
|
11714
|
-
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11715
|
-
else
|
|
11716
|
-
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11717
|
-
}
|
|
11387
|
+
const watcher = makeBatchWatcherStub();
|
|
11388
|
+
const sleep = makeSteppableSleep();
|
|
11389
|
+
let triggerShutdown = () => { };
|
|
11390
|
+
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
11391
|
+
const loop = runRunnerWithLoop(watchArgv, {
|
|
11392
|
+
runPass,
|
|
11393
|
+
clock: new FakeClock(),
|
|
11394
|
+
monotonicNow: () => 0,
|
|
11395
|
+
createWatcher: () => watcher,
|
|
11396
|
+
sleep: sleep.sleep,
|
|
11397
|
+
onShutdownSignal: (handler) => {
|
|
11398
|
+
triggerShutdown = handler;
|
|
11399
|
+
return () => { };
|
|
11400
|
+
},
|
|
11401
|
+
});
|
|
11402
|
+
await flushLoopMicrotasks();
|
|
11403
|
+
runPass.mockClear();
|
|
11404
|
+
watcher.emit("companies/indigo/a.md", {
|
|
11405
|
+
paths: new Map(Array.from({ length: 10_001 }, (_, index) => [
|
|
11406
|
+
`/tmp/hq/companies/indigo/${index}.md`,
|
|
11407
|
+
`companies/indigo/${index}.md`,
|
|
11408
|
+
])),
|
|
11409
|
+
});
|
|
11410
|
+
sleep.tick();
|
|
11411
|
+
await flushLoopMicrotasks(40);
|
|
11412
|
+
const calls = runPass.mock.calls.map((call) => call[0]);
|
|
11413
|
+
expect(calls).not.toContainEqual(fullArgv);
|
|
11414
|
+
const pushScopeCounts = calls
|
|
11415
|
+
.filter((argv) => argv.includes("push"))
|
|
11416
|
+
.map((argv) => scopePathsFromArgv(argv).length);
|
|
11417
|
+
expect(Math.max(0, ...pushScopeCounts)).toBeLessThanOrEqual(10_000);
|
|
11418
|
+
expect(pushScopeCounts.reduce((sum, count) => sum + count, 0)).toBe(10_001);
|
|
11419
|
+
triggerShutdown();
|
|
11420
|
+
await loop;
|
|
11718
11421
|
});
|
|
11719
11422
|
it("a throwing targeted pass falls back to one full reconcile instead of dropping the change", async () => {
|
|
11720
11423
|
const capture = captureFullReconcileDecisions();
|