@indigoai-us/hq-cloud 6.16.85-alpha.0 → 6.16.86-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-company.js +2 -2
- package/dist/bin/sync-runner-company.js.map +1 -1
- package/dist/bin/sync-runner-watch-loop.d.ts +21 -0
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +41 -19
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner.d.ts +0 -2
- 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 +286 -148
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/cli/share.d.ts.map +1 -1
- package/dist/cli/share.js +7 -14
- package/dist/cli/share.js.map +1 -1
- package/dist/cli/share.test.js +22 -72
- package/dist/cli/share.test.js.map +1 -1
- package/dist/cli/sync-scope.test.js +34 -0
- package/dist/cli/sync-scope.test.js.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -2
- package/dist/cli/sync.js.map +1 -1
- package/dist/prefix-coalesce.d.ts +37 -30
- package/dist/prefix-coalesce.d.ts.map +1 -1
- package/dist/prefix-coalesce.js +104 -16
- package/dist/prefix-coalesce.js.map +1 -1
- package/dist/prefix-coalesce.test.js +34 -3
- package/dist/prefix-coalesce.test.js.map +1 -1
- package/dist/remote-pull.d.ts.map +1 -1
- package/dist/remote-pull.js +15 -8
- package/dist/remote-pull.js.map +1 -1
- package/dist/remote-pull.test.js +44 -4
- package/dist/remote-pull.test.js.map +1 -1
- package/dist/scope-shrink.d.ts.map +1 -1
- package/dist/scope-shrink.js +7 -1
- package/dist/scope-shrink.js.map +1 -1
- package/dist/sync/event-sync.d.ts.map +1 -1
- package/dist/sync/event-sync.js +1 -4
- package/dist/sync/event-sync.js.map +1 -1
- package/dist/sync/event-sync.test.js +2 -2
- package/dist/sync/event-sync.test.js.map +1 -1
- package/dist/sync/pull-scope.d.ts.map +1 -1
- package/dist/sync/pull-scope.js +5 -5
- package/dist/sync/pull-scope.js.map +1 -1
- package/package.json +1 -1
- package/dist/sync/full-pass-interval.d.ts +0 -25
- package/dist/sync/full-pass-interval.d.ts.map +0 -1
- package/dist/sync/full-pass-interval.js +0 -53
- package/dist/sync/full-pass-interval.js.map +0 -1
- package/dist/sync/full-pass-interval.test.d.ts +0 -2
- package/dist/sync/full-pass-interval.test.d.ts.map +0 -1
- package/dist/sync/full-pass-interval.test.js +0 -21
- package/dist/sync/full-pass-interval.test.js.map +0 -1
|
@@ -20,8 +20,7 @@ import { ObjectLockChecksumRequiredError, PresignObjectIO, S3SdkObjectIO, } from
|
|
|
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, 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";
|
|
23
|
+
import { adaptivePollMs, advanceMonotonicDeadline, DEFAULT_EVENT_BATCH_LIMIT, DEFAULT_FAST_LANE_MAX_BYTES, DEFAULT_FAST_LANE_MAX_FILE_BYTES, DEFAULT_FAST_LANE_MAX_FILES, DEFAULT_FULL_RECONCILE_MS, EVENT_BATCH_LIMIT_ENV, FAST_LANE_MAX_BYTES_ENV, FAST_LANE_MAX_FILES_ENV, FULL_RECONCILE_MS_ENV, isFastLocalBatch, isFastReceiverBatch, partitionLocalBatch, journalEntriesForWatcherDelete, resolveEventBatchLimit, resolveFullReconcileMs, 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";
|
|
25
24
|
import { FullPassCapController, resetFullPassCapLogForTest, } from "../sync/full-pass-caps.js";
|
|
26
25
|
import { AreaLedgerMigration, JournalStore, openJournalStateStoreForMigration, PERSONAL_VAULT_JOURNAL_SLUG, readJournal, readJournalScoped, writeJournal, } from "../journal.js";
|
|
27
26
|
import { AreaLedger } from "../sync/area-ledger.js";
|
|
@@ -33,7 +32,7 @@ import { lockPathFor, OPERATION_LOCKED_EXIT } from "../operation-lock.js";
|
|
|
33
32
|
import { TRANSIENT_NETWORK_EXIT } from "../lib/net-errors.js";
|
|
34
33
|
import { getStateStoreSnapshotRecoveryCountForTest, resetStateStoreSnapshotRecoveryCountForTest, StateStoreLockError, } from "../sync/state-store.js";
|
|
35
34
|
import { PARTIAL_SYNC_EXIT, UNRESOLVED_COMPANY_EXIT, } from "../lib/exit-codes.js";
|
|
36
|
-
import { isCoveredByAny } from "../prefix-coalesce.js";
|
|
35
|
+
import { isCoveredByAny, toScopePrefixEntries } from "../prefix-coalesce.js";
|
|
37
36
|
import { VaultAuthError, VaultNotFoundError } from "../vault-client.js";
|
|
38
37
|
import { buildRoutePullArgv } from "./sync-runner-watch-routes.js";
|
|
39
38
|
import { CognitoAuthError, CognitoRefreshError } from "../cognito-auth.js";
|
|
@@ -3728,8 +3727,8 @@ describe("--direction", () => {
|
|
|
3728
3727
|
isDefault: false,
|
|
3729
3728
|
}),
|
|
3730
3729
|
listMyExplicitGrants: async () => [
|
|
3731
|
-
{ companyUid: "cmp_a", path: "knowledge
|
|
3732
|
-
{ companyUid: "cmp_a", path: "policies
|
|
3730
|
+
{ companyUid: "cmp_a", path: "knowledge/*", permission: "read", source: "person" },
|
|
3731
|
+
{ companyUid: "cmp_a", path: "policies/*", permission: "read", source: "group" },
|
|
3733
3732
|
],
|
|
3734
3733
|
};
|
|
3735
3734
|
const deps = makeDeps({
|
|
@@ -3754,7 +3753,7 @@ describe("--direction", () => {
|
|
|
3754
3753
|
isDefault: false,
|
|
3755
3754
|
}),
|
|
3756
3755
|
listMyExplicitGrants: async () => [
|
|
3757
|
-
{ companyUid: "cmp_a", path: "knowledge
|
|
3756
|
+
{ companyUid: "cmp_a", path: "knowledge/*", permission: "read", source: "person" },
|
|
3758
3757
|
],
|
|
3759
3758
|
};
|
|
3760
3759
|
const deps = makeDeps({
|
|
@@ -3790,7 +3789,7 @@ describe("--direction", () => {
|
|
|
3790
3789
|
isDefault: false,
|
|
3791
3790
|
}),
|
|
3792
3791
|
listMyExplicitGrants: async () => [
|
|
3793
|
-
{ companyUid: "cmp_a", path: "policies
|
|
3792
|
+
{ companyUid: "cmp_a", path: "policies/*", permission: "read", source: "person" },
|
|
3794
3793
|
],
|
|
3795
3794
|
};
|
|
3796
3795
|
const deps = makeDeps({
|
|
@@ -4710,13 +4709,28 @@ describe("advanceMonotonicDeadline", () => {
|
|
|
4710
4709
|
});
|
|
4711
4710
|
});
|
|
4712
4711
|
});
|
|
4713
|
-
describe("watch-loop reconcile
|
|
4712
|
+
describe("watch-loop reconcile environment resolvers", () => {
|
|
4714
4713
|
it("uses the shipped 10,000 event-batch default while allowing smaller and larger overrides", () => {
|
|
4715
4714
|
expect(DEFAULT_EVENT_BATCH_LIMIT).toBe(10_000);
|
|
4716
4715
|
expect(resolveEventBatchLimit({})).toBe(10_000);
|
|
4717
4716
|
expect(resolveEventBatchLimit({ [EVENT_BATCH_LIMIT_ENV]: "5" })).toBe(5);
|
|
4718
4717
|
expect(resolveEventBatchLimit({ [EVENT_BATCH_LIMIT_ENV]: "50000" })).toBe(50_000);
|
|
4719
4718
|
});
|
|
4719
|
+
it("defaults the full-reconcile cadence to one elapsed hour for an unset or invalid interval", () => {
|
|
4720
|
+
// The legacy default was "every tenth tick" with no elapsed-time floor.
|
|
4721
|
+
// Ticks fire on every watcher batch, not just polls, so on an active
|
|
4722
|
+
// vault that meant a full pass every 4-8 minutes — and each pass on a
|
|
4723
|
+
// real install lasts ~10 minutes. Full reconcile is the correctness
|
|
4724
|
+
// backstop behind event-push, so elapsed time is the right clock.
|
|
4725
|
+
expect(DEFAULT_FULL_RECONCILE_MS).toBe(3_600_000);
|
|
4726
|
+
expect(resolveFullReconcileMs({})).toBe(DEFAULT_FULL_RECONCILE_MS);
|
|
4727
|
+
for (const raw of ["", "0", "0.5", "-1", "NaN", "not-a-number", "Infinity"]) {
|
|
4728
|
+
expect(resolveFullReconcileMs({ [FULL_RECONCILE_MS_ENV]: raw })).toBe(DEFAULT_FULL_RECONCILE_MS);
|
|
4729
|
+
}
|
|
4730
|
+
});
|
|
4731
|
+
it("accepts a positive millisecond full-reconcile interval", () => {
|
|
4732
|
+
expect(resolveFullReconcileMs({ [FULL_RECONCILE_MS_ENV]: "10800000" })).toBe(10_800_000);
|
|
4733
|
+
});
|
|
4720
4734
|
});
|
|
4721
4735
|
describe("runRunnerWithLoop — adaptive poll interval (no --poll-remote-ms)", () => {
|
|
4722
4736
|
// Capture the ms handed to sleep on the FIRST poll, then hang so the loop
|
|
@@ -4932,8 +4946,10 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
4932
4946
|
it("parallel coordinator activates every event surface after a partial completed full reconcile", async () => {
|
|
4933
4947
|
const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
4934
4948
|
const previousEventSync = process.env.HQ_SYNC_EVENT_SYNC;
|
|
4949
|
+
const previousFullReconcileMs = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
4935
4950
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
|
|
4936
4951
|
process.env.HQ_SYNC_EVENT_SYNC = "1";
|
|
4952
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "60000";
|
|
4937
4953
|
const watcher = makeWatcherStub();
|
|
4938
4954
|
const receiver = {
|
|
4939
4955
|
connected: false,
|
|
@@ -4993,13 +5009,19 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
4993
5009
|
delete process.env.HQ_SYNC_EVENT_SYNC;
|
|
4994
5010
|
else
|
|
4995
5011
|
process.env.HQ_SYNC_EVENT_SYNC = previousEventSync;
|
|
5012
|
+
if (previousFullReconcileMs === undefined)
|
|
5013
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
5014
|
+
else
|
|
5015
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = previousFullReconcileMs;
|
|
4996
5016
|
}
|
|
4997
5017
|
});
|
|
4998
5018
|
it("parallel coordinator activates event surfaces and advances cadence after a numeric-zero full reconcile", async () => {
|
|
4999
5019
|
const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
5000
5020
|
const previousEventSync = process.env.HQ_SYNC_EVENT_SYNC;
|
|
5021
|
+
const previousFullReconcileMs = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
5001
5022
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
|
|
5002
5023
|
process.env.HQ_SYNC_EVENT_SYNC = "1";
|
|
5024
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "60000";
|
|
5003
5025
|
const watcher = makeWatcherStub();
|
|
5004
5026
|
const receiver = {
|
|
5005
5027
|
connected: false,
|
|
@@ -5059,11 +5081,17 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
5059
5081
|
delete process.env.HQ_SYNC_EVENT_SYNC;
|
|
5060
5082
|
else
|
|
5061
5083
|
process.env.HQ_SYNC_EVENT_SYNC = previousEventSync;
|
|
5084
|
+
if (previousFullReconcileMs === undefined)
|
|
5085
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
5086
|
+
else
|
|
5087
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = previousFullReconcileMs;
|
|
5062
5088
|
}
|
|
5063
5089
|
});
|
|
5064
5090
|
it("backs off failed parallel full-reconcile completions before another chore is admitted", async () => {
|
|
5065
5091
|
const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
5092
|
+
const previousFullReconcileMs = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
5066
5093
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
|
|
5094
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "1";
|
|
5067
5095
|
const runPass = vi.fn().mockResolvedValue(1);
|
|
5068
5096
|
const delays = [];
|
|
5069
5097
|
const waiters = [];
|
|
@@ -5080,7 +5108,6 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
5080
5108
|
clock: new FakeClock(),
|
|
5081
5109
|
monotonicNow: () => now,
|
|
5082
5110
|
sleep,
|
|
5083
|
-
fullPassIntervalSource: { read: () => 1 },
|
|
5084
5111
|
onShutdownSignal: (handler) => {
|
|
5085
5112
|
shutdown = handler;
|
|
5086
5113
|
return () => { };
|
|
@@ -5108,6 +5135,10 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
5108
5135
|
delete process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
5109
5136
|
else
|
|
5110
5137
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = previousCoordinator;
|
|
5138
|
+
if (previousFullReconcileMs === undefined)
|
|
5139
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
5140
|
+
else
|
|
5141
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = previousFullReconcileMs;
|
|
5111
5142
|
}
|
|
5112
5143
|
});
|
|
5113
5144
|
it("parallel coordinator keeps event surfaces off for an auth-required full reconcile", async () => {
|
|
@@ -5240,7 +5271,7 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
5240
5271
|
sleep.tick();
|
|
5241
5272
|
await flushLoopMicrotasks();
|
|
5242
5273
|
}
|
|
5243
|
-
clockState.now =
|
|
5274
|
+
clockState.now = DEFAULT_FULL_RECONCILE_MS;
|
|
5244
5275
|
sleep.tick();
|
|
5245
5276
|
await flushLoopMicrotasks();
|
|
5246
5277
|
// Tick 1 and the first tick after an hour has elapsed are full
|
|
@@ -5308,7 +5339,7 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
5308
5339
|
}
|
|
5309
5340
|
expect(runPass).toHaveBeenCalledTimes(1);
|
|
5310
5341
|
// The hourly cadence, not a tick count, schedules the next full pass.
|
|
5311
|
-
clockState.now =
|
|
5342
|
+
clockState.now = DEFAULT_FULL_RECONCILE_MS;
|
|
5312
5343
|
sleep.tick();
|
|
5313
5344
|
await flushLoopMicrotasks(30);
|
|
5314
5345
|
expect(runPass).toHaveBeenCalledTimes(2);
|
|
@@ -9365,7 +9396,7 @@ describe("runRunnerWithLoop — event-push wiring", () => {
|
|
|
9365
9396
|
runPass,
|
|
9366
9397
|
clock: new FakeClock(),
|
|
9367
9398
|
createWatcher: () => watcher,
|
|
9368
|
-
monotonicNow: () => (monotonic +=
|
|
9399
|
+
monotonicNow: () => (monotonic += DEFAULT_FULL_RECONCILE_MS),
|
|
9369
9400
|
sleep: sleep.sleep,
|
|
9370
9401
|
onShutdownSignal: (handler) => {
|
|
9371
9402
|
triggerShutdown = handler;
|
|
@@ -10347,7 +10378,9 @@ describe("CooperativePassScheduler", () => {
|
|
|
10347
10378
|
describe("first-tick realtime yield", () => {
|
|
10348
10379
|
it("commits a watcher push at the first chore checkpoint without a wall-clock wait", async () => {
|
|
10349
10380
|
const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
10381
|
+
const previousInterval = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10350
10382
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
|
|
10383
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
10351
10384
|
const timings = [];
|
|
10352
10385
|
const spy = vi.spyOn(process.stderr, "write").mockImplementation((chunk) => {
|
|
10353
10386
|
const text = String(chunk);
|
|
@@ -10446,6 +10479,10 @@ describe("first-tick realtime yield", () => {
|
|
|
10446
10479
|
delete process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
10447
10480
|
else
|
|
10448
10481
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = previousCoordinator;
|
|
10482
|
+
if (previousInterval === undefined)
|
|
10483
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10484
|
+
else
|
|
10485
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = previousInterval;
|
|
10449
10486
|
}
|
|
10450
10487
|
});
|
|
10451
10488
|
});
|
|
@@ -10740,6 +10777,8 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10740
10777
|
capture.restore();
|
|
10741
10778
|
});
|
|
10742
10779
|
it("logs event-push-surfaces-inactive without silently attributing the first tick", async () => {
|
|
10780
|
+
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10781
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
10743
10782
|
const capture = captureFullReconcileDecisions();
|
|
10744
10783
|
try {
|
|
10745
10784
|
const sleep = makeSteppableSleep();
|
|
@@ -10768,6 +10807,10 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10768
10807
|
}
|
|
10769
10808
|
finally {
|
|
10770
10809
|
capture.restore();
|
|
10810
|
+
if (saved === undefined)
|
|
10811
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10812
|
+
else
|
|
10813
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
10771
10814
|
}
|
|
10772
10815
|
});
|
|
10773
10816
|
it("reports every matching trigger instead of short-circuiting at the first", async () => {
|
|
@@ -10822,7 +10865,9 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10822
10865
|
});
|
|
10823
10866
|
it("skips a 404 company route in a mixed drain and records a completed full reconcile", async () => {
|
|
10824
10867
|
const previousCoordinator = process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
10868
|
+
const previousInterval = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10825
10869
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = "1";
|
|
10870
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
10826
10871
|
const failedLines = [];
|
|
10827
10872
|
const decisions = [];
|
|
10828
10873
|
const timingRecords = [];
|
|
@@ -10922,11 +10967,17 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10922
10967
|
delete process.env.HQ_SYNC_PARALLEL_COORDINATOR;
|
|
10923
10968
|
else
|
|
10924
10969
|
process.env.HQ_SYNC_PARALLEL_COORDINATOR = previousCoordinator;
|
|
10970
|
+
if (previousInterval === undefined)
|
|
10971
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10972
|
+
else
|
|
10973
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = previousInterval;
|
|
10925
10974
|
}
|
|
10926
10975
|
});
|
|
10927
10976
|
it("does not escalate a fully-enumerated over-limit batch to a full reconcile", async () => {
|
|
10928
10977
|
const savedLimit = process.env.HQ_SYNC_EVENT_BATCH_LIMIT;
|
|
10978
|
+
const savedInterval = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10929
10979
|
process.env.HQ_SYNC_EVENT_BATCH_LIMIT = "2";
|
|
10980
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
10930
10981
|
const journal = captureWatchLoopJournal();
|
|
10931
10982
|
try {
|
|
10932
10983
|
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
@@ -10966,11 +11017,17 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
10966
11017
|
delete process.env.HQ_SYNC_EVENT_BATCH_LIMIT;
|
|
10967
11018
|
else
|
|
10968
11019
|
process.env.HQ_SYNC_EVENT_BATCH_LIMIT = savedLimit;
|
|
11020
|
+
if (savedInterval === undefined)
|
|
11021
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11022
|
+
else
|
|
11023
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = savedInterval;
|
|
10969
11024
|
}
|
|
10970
11025
|
});
|
|
10971
11026
|
it("still escalates an overflowed batch with unknown routes to a full reconcile", async () => {
|
|
10972
11027
|
const savedLimit = process.env.HQ_SYNC_EVENT_BATCH_LIMIT;
|
|
11028
|
+
const savedInterval = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
10973
11029
|
process.env.HQ_SYNC_EVENT_BATCH_LIMIT = "2";
|
|
11030
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
10974
11031
|
const journal = captureWatchLoopJournal();
|
|
10975
11032
|
try {
|
|
10976
11033
|
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
@@ -11002,9 +11059,15 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11002
11059
|
delete process.env.HQ_SYNC_EVENT_BATCH_LIMIT;
|
|
11003
11060
|
else
|
|
11004
11061
|
process.env.HQ_SYNC_EVENT_BATCH_LIMIT = savedLimit;
|
|
11062
|
+
if (savedInterval === undefined)
|
|
11063
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11064
|
+
else
|
|
11065
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = savedInterval;
|
|
11005
11066
|
}
|
|
11006
11067
|
});
|
|
11007
|
-
it("logs scheduled-interval as the sole full-reconcile trigger on the
|
|
11068
|
+
it("logs scheduled-interval as the sole full-reconcile trigger on the default hourly cadence", async () => {
|
|
11069
|
+
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11070
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11008
11071
|
const capture = captureFullReconcileDecisions();
|
|
11009
11072
|
try {
|
|
11010
11073
|
const clockState = { now: 0 };
|
|
@@ -11030,11 +11093,11 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11030
11093
|
sleep.tick();
|
|
11031
11094
|
await flushLoopMicrotasks();
|
|
11032
11095
|
}
|
|
11033
|
-
// A dozen ticks inside the
|
|
11096
|
+
// A dozen ticks inside the hour: never a scheduled full pass.
|
|
11034
11097
|
expect(runPass).not.toHaveBeenCalled();
|
|
11035
11098
|
capture.clear();
|
|
11036
11099
|
runPass.mockClear();
|
|
11037
|
-
clockState.now =
|
|
11100
|
+
clockState.now = DEFAULT_FULL_RECONCILE_MS;
|
|
11038
11101
|
sleep.tick();
|
|
11039
11102
|
await flushLoopMicrotasks();
|
|
11040
11103
|
expectFullReconcileDecision(capture.records[0], "full", [
|
|
@@ -11046,6 +11109,10 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11046
11109
|
}
|
|
11047
11110
|
finally {
|
|
11048
11111
|
capture.restore();
|
|
11112
|
+
if (saved === undefined)
|
|
11113
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11114
|
+
else
|
|
11115
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11049
11116
|
}
|
|
11050
11117
|
});
|
|
11051
11118
|
it("logs scoped passes with their batch path count and preserves the scoped route", async () => {
|
|
@@ -11066,6 +11133,8 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11066
11133
|
capture.restore();
|
|
11067
11134
|
});
|
|
11068
11135
|
it("reports interval diagnostics while the configured interval has not elapsed", async () => {
|
|
11136
|
+
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11137
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "1000";
|
|
11069
11138
|
const capture = captureFullReconcileDecisions();
|
|
11070
11139
|
try {
|
|
11071
11140
|
const clockState = { now: 0 };
|
|
@@ -11074,7 +11143,6 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11074
11143
|
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
11075
11144
|
const loop = runRunnerWithLoop(watchArgv, {
|
|
11076
11145
|
runPass,
|
|
11077
|
-
fullPassIntervalSource: { read: () => 1_000 },
|
|
11078
11146
|
monotonicNow: () => clockState.now,
|
|
11079
11147
|
createWatcher: () => makeBatchWatcherStub(),
|
|
11080
11148
|
sleep: sleep.sleep,
|
|
@@ -11110,6 +11178,10 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11110
11178
|
}
|
|
11111
11179
|
finally {
|
|
11112
11180
|
capture.restore();
|
|
11181
|
+
if (saved === undefined)
|
|
11182
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11183
|
+
else
|
|
11184
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11113
11185
|
}
|
|
11114
11186
|
});
|
|
11115
11187
|
it("startup runs one full reconcile, then watcher edits interrupt the pending wait", async () => {
|
|
@@ -11415,6 +11487,8 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11415
11487
|
await loop;
|
|
11416
11488
|
});
|
|
11417
11489
|
it("drops an unroutable batch and leaves the next unexpired poll idle", async () => {
|
|
11490
|
+
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11491
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "1000";
|
|
11418
11492
|
const capture = captureFullReconcileDecisions();
|
|
11419
11493
|
try {
|
|
11420
11494
|
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
@@ -11440,6 +11514,10 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11440
11514
|
}
|
|
11441
11515
|
finally {
|
|
11442
11516
|
capture.restore();
|
|
11517
|
+
if (saved === undefined)
|
|
11518
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11519
|
+
else
|
|
11520
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11443
11521
|
}
|
|
11444
11522
|
});
|
|
11445
11523
|
it("personal scoped ticks preserve personal mode for the pull leg", async () => {
|
|
@@ -11598,7 +11676,7 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11598
11676
|
}
|
|
11599
11677
|
expect(runPass).not.toHaveBeenCalled();
|
|
11600
11678
|
runPass.mockClear();
|
|
11601
|
-
clockState.now =
|
|
11679
|
+
clockState.now = DEFAULT_FULL_RECONCILE_MS;
|
|
11602
11680
|
sleep.tick();
|
|
11603
11681
|
await flushLoopMicrotasks();
|
|
11604
11682
|
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
@@ -11606,105 +11684,134 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11606
11684
|
sleep.tick();
|
|
11607
11685
|
await loop;
|
|
11608
11686
|
});
|
|
11609
|
-
it("schedules the full reconcile by elapsed time, not tick count,
|
|
11687
|
+
it("schedules the full reconcile by elapsed time, not tick count, when the interval env is unset", async () => {
|
|
11610
11688
|
// Pre-fix the unset default was every tenth tick. Ticks fire on every
|
|
11611
11689
|
// watcher batch, so an active vault ran a ~10-minute full pass every
|
|
11612
11690
|
// 4-8 minutes — nearly continuous, and the runner's dominant CPU cost
|
|
11613
11691
|
// once per-pass hashing was fixed.
|
|
11614
|
-
const
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11692
|
+
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11693
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11694
|
+
try {
|
|
11695
|
+
const clockState = { now: 0 };
|
|
11696
|
+
const watcher = makeBatchWatcherStub();
|
|
11697
|
+
const sleep = makeSteppableSleep();
|
|
11698
|
+
let triggerShutdown = () => { };
|
|
11699
|
+
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
11700
|
+
const loop = runRunnerWithLoop(watchArgv, {
|
|
11701
|
+
runPass,
|
|
11702
|
+
clock: new FakeClock(),
|
|
11703
|
+
monotonicNow: () => clockState.now,
|
|
11704
|
+
createWatcher: () => watcher,
|
|
11705
|
+
sleep: sleep.sleep,
|
|
11706
|
+
onShutdownSignal: (handler) => {
|
|
11707
|
+
triggerShutdown = handler;
|
|
11708
|
+
return () => { };
|
|
11709
|
+
},
|
|
11710
|
+
});
|
|
11711
|
+
await flushLoopMicrotasks();
|
|
11712
|
+
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11713
|
+
runPass.mockClear();
|
|
11714
|
+
// Twenty ticks in fifty-nine minutes: the old cadence would have run
|
|
11715
|
+
// two full passes here.
|
|
11716
|
+
for (let tick = 0; tick < 20; tick++) {
|
|
11717
|
+
clockState.now += 177_000;
|
|
11718
|
+
sleep.tick();
|
|
11719
|
+
await flushLoopMicrotasks();
|
|
11720
|
+
}
|
|
11721
|
+
expect(runPass).not.toHaveBeenCalled();
|
|
11722
|
+
runPass.mockClear();
|
|
11723
|
+
clockState.now = DEFAULT_FULL_RECONCILE_MS;
|
|
11637
11724
|
sleep.tick();
|
|
11638
11725
|
await flushLoopMicrotasks();
|
|
11726
|
+
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11727
|
+
triggerShutdown();
|
|
11728
|
+
await loop;
|
|
11729
|
+
}
|
|
11730
|
+
finally {
|
|
11731
|
+
if (saved === undefined)
|
|
11732
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11733
|
+
else
|
|
11734
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11639
11735
|
}
|
|
11640
|
-
expect(runPass).not.toHaveBeenCalled();
|
|
11641
|
-
runPass.mockClear();
|
|
11642
|
-
clockState.now = DEFAULT_FULL_PASS_INTERVAL_MS;
|
|
11643
|
-
sleep.tick();
|
|
11644
|
-
await flushLoopMicrotasks();
|
|
11645
|
-
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11646
|
-
triggerShutdown();
|
|
11647
|
-
await loop;
|
|
11648
11736
|
});
|
|
11649
|
-
it("uses the
|
|
11650
|
-
const
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11737
|
+
it("uses the configured elapsed-time interval instead of the tick count", async () => {
|
|
11738
|
+
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11739
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "1000";
|
|
11740
|
+
try {
|
|
11741
|
+
const clockState = { now: 0 };
|
|
11742
|
+
const watcher = makeBatchWatcherStub();
|
|
11743
|
+
const sleep = makeSteppableSleep();
|
|
11744
|
+
let triggerShutdown = () => { };
|
|
11745
|
+
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
11746
|
+
const loop = runRunnerWithLoop(watchArgv, {
|
|
11747
|
+
runPass,
|
|
11748
|
+
clock: new FakeClock(),
|
|
11749
|
+
monotonicNow: () => clockState.now,
|
|
11750
|
+
createWatcher: () => watcher,
|
|
11751
|
+
sleep: sleep.sleep,
|
|
11752
|
+
onShutdownSignal: (handler) => {
|
|
11753
|
+
triggerShutdown = handler;
|
|
11754
|
+
return () => { };
|
|
11755
|
+
},
|
|
11756
|
+
});
|
|
11757
|
+
await flushLoopMicrotasks();
|
|
11758
|
+
// Startup always forces the first full reconcile, and starts the interval.
|
|
11759
|
+
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11760
|
+
runPass.mockClear();
|
|
11761
|
+
clockState.now = 999;
|
|
11762
|
+
sleep.tick();
|
|
11763
|
+
await flushLoopMicrotasks();
|
|
11764
|
+
expect(runPass).not.toHaveBeenCalled();
|
|
11765
|
+
runPass.mockClear();
|
|
11766
|
+
clockState.now = 1_000;
|
|
11767
|
+
sleep.tick();
|
|
11768
|
+
await flushLoopMicrotasks();
|
|
11769
|
+
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11770
|
+
triggerShutdown();
|
|
11771
|
+
await loop;
|
|
11772
|
+
}
|
|
11773
|
+
finally {
|
|
11774
|
+
if (saved === undefined)
|
|
11775
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11776
|
+
else
|
|
11777
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11778
|
+
}
|
|
11682
11779
|
});
|
|
11683
11780
|
it("does not let a full-reconcile interval suppress event-push activation", async () => {
|
|
11684
|
-
const
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
|
|
11781
|
+
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11782
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
11783
|
+
try {
|
|
11784
|
+
const watcher = makeBatchWatcherStub();
|
|
11785
|
+
const sleep = makeSteppableSleep();
|
|
11786
|
+
let triggerShutdown = () => { };
|
|
11787
|
+
// A numeric partial result does not activate event-push surfaces, so the
|
|
11788
|
+
// next tick must force another full pass even though three hours have not elapsed.
|
|
11789
|
+
const runPass = vi.fn().mockResolvedValue(PARTIAL_SYNC_EXIT);
|
|
11790
|
+
const loop = runRunnerWithLoop(watchArgv, {
|
|
11791
|
+
runPass,
|
|
11792
|
+
clock: new FakeClock(),
|
|
11793
|
+
monotonicNow: () => 0,
|
|
11794
|
+
createWatcher: () => watcher,
|
|
11795
|
+
sleep: sleep.sleep,
|
|
11796
|
+
onShutdownSignal: (handler) => {
|
|
11797
|
+
triggerShutdown = handler;
|
|
11798
|
+
return () => { };
|
|
11799
|
+
},
|
|
11800
|
+
});
|
|
11801
|
+
await flushLoopMicrotasks();
|
|
11802
|
+
runPass.mockClear();
|
|
11803
|
+
sleep.tick();
|
|
11804
|
+
await flushLoopMicrotasks();
|
|
11805
|
+
expect(runPass.mock.calls.map((call) => call[0])).toEqual([fullArgv]);
|
|
11806
|
+
triggerShutdown();
|
|
11807
|
+
await loop;
|
|
11808
|
+
}
|
|
11809
|
+
finally {
|
|
11810
|
+
if (saved === undefined)
|
|
11811
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11812
|
+
else
|
|
11813
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11814
|
+
}
|
|
11708
11815
|
});
|
|
11709
11816
|
it("overflow with known dropped-route hints fans out per touched route instead of a full reconcile", async () => {
|
|
11710
11817
|
const capture = captureFullReconcileDecisions();
|
|
@@ -11839,40 +11946,50 @@ describe("runRunnerWithLoop — accumulate-and-drain scoped push", () => {
|
|
|
11839
11946
|
await loop;
|
|
11840
11947
|
});
|
|
11841
11948
|
it("a batch above the shipped 10,000-path default stays on chunked targeted passes before the interval", async () => {
|
|
11842
|
-
const
|
|
11843
|
-
|
|
11844
|
-
|
|
11845
|
-
|
|
11846
|
-
|
|
11847
|
-
|
|
11848
|
-
|
|
11849
|
-
|
|
11850
|
-
|
|
11851
|
-
|
|
11852
|
-
|
|
11853
|
-
|
|
11854
|
-
|
|
11855
|
-
|
|
11856
|
-
|
|
11857
|
-
|
|
11858
|
-
|
|
11859
|
-
|
|
11860
|
-
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
11864
|
-
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
.
|
|
11871
|
-
|
|
11872
|
-
|
|
11873
|
-
|
|
11874
|
-
|
|
11875
|
-
|
|
11949
|
+
const saved = process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11950
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = "10800000";
|
|
11951
|
+
try {
|
|
11952
|
+
const watcher = makeBatchWatcherStub();
|
|
11953
|
+
const sleep = makeSteppableSleep();
|
|
11954
|
+
let triggerShutdown = () => { };
|
|
11955
|
+
const runPass = vi.fn().mockResolvedValue(completedPassOutcome());
|
|
11956
|
+
const loop = runRunnerWithLoop(watchArgv, {
|
|
11957
|
+
runPass,
|
|
11958
|
+
clock: new FakeClock(),
|
|
11959
|
+
monotonicNow: () => 0,
|
|
11960
|
+
createWatcher: () => watcher,
|
|
11961
|
+
sleep: sleep.sleep,
|
|
11962
|
+
onShutdownSignal: (handler) => {
|
|
11963
|
+
triggerShutdown = handler;
|
|
11964
|
+
return () => { };
|
|
11965
|
+
},
|
|
11966
|
+
});
|
|
11967
|
+
await flushLoopMicrotasks();
|
|
11968
|
+
runPass.mockClear();
|
|
11969
|
+
watcher.emit("companies/indigo/a.md", {
|
|
11970
|
+
paths: new Map(Array.from({ length: 10_001 }, (_, index) => [
|
|
11971
|
+
`/tmp/hq/companies/indigo/${index}.md`,
|
|
11972
|
+
`companies/indigo/${index}.md`,
|
|
11973
|
+
])),
|
|
11974
|
+
});
|
|
11975
|
+
sleep.tick();
|
|
11976
|
+
await flushLoopMicrotasks(40);
|
|
11977
|
+
const calls = runPass.mock.calls.map((call) => call[0]);
|
|
11978
|
+
expect(calls).not.toContainEqual(fullArgv);
|
|
11979
|
+
const pushScopeCounts = calls
|
|
11980
|
+
.filter((argv) => argv.includes("push"))
|
|
11981
|
+
.map((argv) => scopePathsFromArgv(argv).length);
|
|
11982
|
+
expect(Math.max(0, ...pushScopeCounts)).toBeLessThanOrEqual(10_000);
|
|
11983
|
+
expect(pushScopeCounts.reduce((sum, count) => sum + count, 0)).toBe(10_001);
|
|
11984
|
+
triggerShutdown();
|
|
11985
|
+
await loop;
|
|
11986
|
+
}
|
|
11987
|
+
finally {
|
|
11988
|
+
if (saved === undefined)
|
|
11989
|
+
delete process.env.HQ_SYNC_FULL_RECONCILE_MS;
|
|
11990
|
+
else
|
|
11991
|
+
process.env.HQ_SYNC_FULL_RECONCILE_MS = saved;
|
|
11992
|
+
}
|
|
11876
11993
|
});
|
|
11877
11994
|
it("a throwing targeted pass falls back to one full reconcile instead of dropping the change", async () => {
|
|
11878
11995
|
const capture = captureFullReconcileDecisions();
|
|
@@ -12223,7 +12340,7 @@ describe("resolvePullScope", () => {
|
|
|
12223
12340
|
isDefault: false,
|
|
12224
12341
|
}),
|
|
12225
12342
|
listMyExplicitGrants: async () => [
|
|
12226
|
-
{ companyUid: "cmp_a", path: "knowledge
|
|
12343
|
+
{ companyUid: "cmp_a", path: "knowledge/*", permission: "read", source: "person" },
|
|
12227
12344
|
],
|
|
12228
12345
|
}), "cmp_a", "acme"),
|
|
12229
12346
|
// custom
|
|
@@ -12297,7 +12414,7 @@ describe("resolvePullScope", () => {
|
|
|
12297
12414
|
isDefault: false,
|
|
12298
12415
|
}),
|
|
12299
12416
|
listMyExplicitGrants: async () => [
|
|
12300
|
-
{ companyUid: "cmp_a", path: "knowledge
|
|
12417
|
+
{ companyUid: "cmp_a", path: "knowledge/*", permission: "read", source: "person" },
|
|
12301
12418
|
],
|
|
12302
12419
|
}), "cmp_a", "acme");
|
|
12303
12420
|
expect(scope).toEqual({ syncMode: "shared", prefixSet: ["knowledge/"], excludePrefixes: [SESSIONS_SCOPE_PREFIX] });
|
|
@@ -12341,15 +12458,36 @@ describe("resolvePullScope", () => {
|
|
|
12341
12458
|
isDefault: false,
|
|
12342
12459
|
}),
|
|
12343
12460
|
listMyExplicitGrants: async () => [
|
|
12344
|
-
{ companyUid: "cmp_a", path: "knowledge
|
|
12345
|
-
{ companyUid: "cmp_a", path: "knowledge/sub
|
|
12346
|
-
{ companyUid: "cmp_a", path: "shared
|
|
12461
|
+
{ companyUid: "cmp_a", path: "knowledge/*", permission: "read", source: "person" },
|
|
12462
|
+
{ companyUid: "cmp_a", path: "knowledge/sub/*", permission: "read", source: "group" },
|
|
12463
|
+
{ companyUid: "cmp_a", path: "shared/*", permission: "read", source: "open" },
|
|
12347
12464
|
],
|
|
12348
12465
|
}), "cmp_a", "acme");
|
|
12349
12466
|
// knowledge/sub/ is covered by knowledge/ → coalesced away.
|
|
12350
12467
|
expect(scope.syncMode).toBe("shared");
|
|
12351
12468
|
expect(scope.prefixSet).toEqual(["knowledge/", "shared/"]);
|
|
12352
12469
|
});
|
|
12470
|
+
it.each(["read", "write"])("keeps a private foo/ %s grant distinct while retaining its minted child rows", async (permission) => {
|
|
12471
|
+
const scope = await resolvePullScope(stubClient({
|
|
12472
|
+
listMyMemberships: async () => [membership("cmp_a", "mk_a")],
|
|
12473
|
+
getMembershipSyncConfig: async () => ({
|
|
12474
|
+
membershipId: "mk_a",
|
|
12475
|
+
syncMode: "shared",
|
|
12476
|
+
isDefault: false,
|
|
12477
|
+
}),
|
|
12478
|
+
listMyExplicitGrants: async () => [
|
|
12479
|
+
{ companyUid: "cmp_a", path: "foo/", permission, source: "open" },
|
|
12480
|
+
{ companyUid: "cmp_a", path: "foo/new-folder/*", permission: "admin", source: "creator" },
|
|
12481
|
+
{ companyUid: "cmp_a", path: "foo/brief.md", permission: "admin", source: "creator" },
|
|
12482
|
+
],
|
|
12483
|
+
}), "cmp_a", "acme");
|
|
12484
|
+
expect(scope.syncMode).toBe("shared");
|
|
12485
|
+
expect(toScopePrefixEntries(scope.prefixSet ?? [])).toEqual([
|
|
12486
|
+
{ prefix: "foo/", match: "private" },
|
|
12487
|
+
{ prefix: "foo/brief.md", match: "exact" },
|
|
12488
|
+
{ prefix: "foo/new-folder/", match: "prefix" },
|
|
12489
|
+
]);
|
|
12490
|
+
});
|
|
12353
12491
|
// Regression lock-in (Michal / ridge report): a non-owner member whose
|
|
12354
12492
|
// ONLY grant is a COMPANY-WIDE write grant (surfaced by the server as
|
|
12355
12493
|
// `source: "open"`) on a projects prefix — and who has NO direct
|
|
@@ -12372,7 +12510,7 @@ describe("resolvePullScope", () => {
|
|
|
12372
12510
|
listMyExplicitGrants: async () => [
|
|
12373
12511
|
{
|
|
12374
12512
|
companyUid: "cmp_a",
|
|
12375
|
-
path: "projects/alpha
|
|
12513
|
+
path: "projects/alpha/*",
|
|
12376
12514
|
permission: "write",
|
|
12377
12515
|
source: "open",
|
|
12378
12516
|
},
|
|
@@ -12497,7 +12635,7 @@ describe("resolvePullScope", () => {
|
|
|
12497
12635
|
syncMode: "shared",
|
|
12498
12636
|
isDefault: false,
|
|
12499
12637
|
}),
|
|
12500
|
-
listMyExplicitGrants: async () => [{ companyUid: "cmp_a", path: "knowledge
|
|
12638
|
+
listMyExplicitGrants: async () => [{ companyUid: "cmp_a", path: "knowledge/*", permission: "read", source: "person" }],
|
|
12501
12639
|
}), "cmp_a", "acme", root);
|
|
12502
12640
|
expect(scope.syncMode).toBe("shared");
|
|
12503
12641
|
// Grant prefix + pinned prefix, coalesced + sorted.
|
|
@@ -12540,7 +12678,7 @@ describe("resolvePullScope", () => {
|
|
|
12540
12678
|
syncMode: "shared",
|
|
12541
12679
|
isDefault: false,
|
|
12542
12680
|
}),
|
|
12543
|
-
listMyExplicitGrants: async () => [{ companyUid: "cmp_a", path: "knowledge
|
|
12681
|
+
listMyExplicitGrants: async () => [{ companyUid: "cmp_a", path: "knowledge/*", permission: "read", source: "person" }],
|
|
12544
12682
|
}), "cmp_a", "acme", root);
|
|
12545
12683
|
// beta's pin must not leak into acme's scope.
|
|
12546
12684
|
expect(scope.prefixSet).toEqual(["knowledge/"]);
|