@indigoai-us/hq-cloud 6.16.1 → 6.16.2
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/area-ledger-migration.test.js +3 -1
- package/dist/bin/area-ledger-migration.test.js.map +1 -1
- package/dist/bin/sync-runner-watch-loop.d.ts +11 -0
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +60 -24
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner-watch-loop.test.js +84 -2
- package/dist/bin/sync-runner-watch-loop.test.js.map +1 -1
- package/dist/cli/sync.d.ts +2 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +125 -75
- package/dist/cli/sync.js.map +1 -1
- package/dist/cli/sync.test.js +40 -1
- package/dist/cli/sync.test.js.map +1 -1
- package/dist/ignore.d.ts +26 -8
- package/dist/ignore.d.ts.map +1 -1
- package/dist/ignore.js +66 -18
- package/dist/ignore.js.map +1 -1
- package/dist/ignore.test.js +77 -5
- package/dist/ignore.test.js.map +1 -1
- package/dist/journal-store.test.js +17 -0
- package/dist/journal-store.test.js.map +1 -1
- package/dist/journal.d.ts +14 -2
- package/dist/journal.d.ts.map +1 -1
- package/dist/journal.js +42 -1
- package/dist/journal.js.map +1 -1
- package/dist/sync/area-ledger-migration.d.ts +8 -1
- package/dist/sync/area-ledger-migration.d.ts.map +1 -1
- package/dist/sync/area-ledger-migration.js +81 -50
- package/dist/sync/area-ledger-migration.js.map +1 -1
- package/dist/sync/area-ledger-migration.test.js +1 -0
- package/dist/sync/area-ledger-migration.test.js.map +1 -1
- package/dist/sync/event-sync.d.ts +3 -1
- package/dist/sync/event-sync.d.ts.map +1 -1
- package/dist/sync/event-sync.js +1 -0
- package/dist/sync/event-sync.js.map +1 -1
- package/dist/watcher.d.ts +13 -4
- package/dist/watcher.d.ts.map +1 -1
- package/dist/watcher.js +18 -3
- package/dist/watcher.js.map +1 -1
- package/dist/watcher.test.js +28 -0
- package/dist/watcher.test.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,11 +4,12 @@ import * as path from "node:path";
|
|
|
4
4
|
import { afterEach, describe, expect, it } from "vitest";
|
|
5
5
|
import { openJournalStateStoreForMigration, writeJournal } from "../journal.js";
|
|
6
6
|
import { acquireOperationLock } from "../operation-lock.js";
|
|
7
|
-
import { AreaLedgerMigration } from "../sync/area-ledger-migration.js";
|
|
7
|
+
import { AreaLedgerMigration, setAreaLedgerMigrationTestHooksForTest } from "../sync/area-ledger-migration.js";
|
|
8
8
|
import { AreaResolver } from "../sync/area-resolver.js";
|
|
9
9
|
import { runAreaLedgerMigrationCli } from "./area-ledger-migration.js";
|
|
10
10
|
let stateDir = "";
|
|
11
11
|
afterEach(() => {
|
|
12
|
+
setAreaLedgerMigrationTestHooksForTest(undefined);
|
|
12
13
|
delete process.env.HQ_STATE_DIR;
|
|
13
14
|
delete process.env.HQ_OP_LOCK_TIMEOUT;
|
|
14
15
|
if (stateDir)
|
|
@@ -49,6 +50,7 @@ describe("area-ledger migration CLI", () => {
|
|
|
49
50
|
finally {
|
|
50
51
|
held.release();
|
|
51
52
|
}
|
|
53
|
+
setAreaLedgerMigrationTestHooksForTest({ now: () => 0 });
|
|
52
54
|
expect(runAreaLedgerMigrationCli(["--journal", "personal-vault", "--layout", layoutPath, "--cutover"])).toBe(0);
|
|
53
55
|
});
|
|
54
56
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"area-ledger-migration.test.js","sourceRoot":"","sources":["../../src/bin/area-ledger-migration.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ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,CAAC,CAAC,cAAc,EAAE,CAAC;QAEpB,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC7E,OAAO,CAAC,GAAG,CAAC,kBAAkB,GAAG,GAAG,CAAC;QACrC,IAAI,CAAC;YACH,MAAM,CAAC,yBAAyB,CAAC,CAAC,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClH,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,OAAO,EAAE,CAAC;QACjB,CAAC;QACD,sCAAsC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACzD,MAAM,CAAC,yBAAyB,CAAC,CAAC,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { readJournal } from "../journal.js";
|
|
|
3
3
|
import { type FeatureSwitch } from "../sync/feature-flags.js";
|
|
4
4
|
import { HeapCensus } from "./sync-runner-heap-telemetry.js";
|
|
5
5
|
import type { TelemetryClaims } from "../telemetry-events.js";
|
|
6
|
+
import type { JournalEntry } from "../types.js";
|
|
6
7
|
import type { Direction, RunnerLoopDeps, RunnerPassOutcome } from "./sync-runner.js";
|
|
7
8
|
/**
|
|
8
9
|
* Area storage is AUTO by default and only applies after durable cutover.
|
|
@@ -166,6 +167,16 @@ type JournalFiles = ReturnType<typeof readJournal>["files"];
|
|
|
166
167
|
* deliberately avoid enumeration; only directory unlinks expand descendants.
|
|
167
168
|
*/
|
|
168
169
|
export declare function journalEntriesForWatcherDelete(files: JournalFiles, key: string, kind: "unlink" | "unlinkDir"): Array<[string, JournalFiles[string]]>;
|
|
170
|
+
/**
|
|
171
|
+
* Return a journal hash only when its row demonstrably predates this runner.
|
|
172
|
+
*
|
|
173
|
+
* A scoped push writes the completed upload's hash before the runner hands the
|
|
174
|
+
* path to PushEventEmitter. The lazy tier is a startup baseline, not a live
|
|
175
|
+
* "has this runner just pushed it?" lookup, so every row stamped at or after
|
|
176
|
+
* this session's start is deliberately a miss. Invalid timestamps are also a
|
|
177
|
+
* miss: publishing an extra realtime event is safer than suppressing one.
|
|
178
|
+
*/
|
|
179
|
+
export declare function publishedContentHashFromJournalEntryBeforeSession(entry: Readonly<JournalEntry> | undefined, sessionStartedAt: number): string | undefined;
|
|
169
180
|
/**
|
|
170
181
|
* Should a single `unlinkDir` expansion be quarantined instead of stamping a
|
|
171
182
|
* version-bound delete intent on every descendant journal entry?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-runner-watch-loop.d.ts","sourceRoot":"","sources":["../../src/bin/sync-runner-watch-loop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-runner-watch-loop.d.ts","sourceRoot":"","sources":["../../src/bin/sync-runner-watch-loop.ts"],"names":[],"mappings":"AAqBA,OAAO,EAKL,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAUL,WAAW,EAKZ,MAAM,eAAe,CAAC;AAYvB,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAC;AASlC,OAAO,EACL,UAAU,EAqBX,MAAM,iCAAiC,CAAC;AASzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYhD,OAAO,KAAK,EACV,SAAS,EAET,cAAc,EACd,iBAAiB,EAElB,MAAM,kBAAkB,CAAC;AAK1B;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,WAA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G,SAAS,CAOpB;AAWD;;;;;;;;;;;;GAYG;AACH,wBAAgB,oCAAoC,CAClD,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,MAAM,GACrB,OAAO,CAIT;AA6BD,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EAAE,EACd,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,cAAc,EACpB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,MAAM,CAAC,CAkxFjB"}
|
|
@@ -4,6 +4,7 @@ import * as fs from "fs";
|
|
|
4
4
|
import * as v8 from "node:v8";
|
|
5
5
|
import { performance } from "node:perf_hooks";
|
|
6
6
|
import { inventoryManagedSnapshots } from "../backup-prune.js";
|
|
7
|
+
import { targetedJournalSessionCensusSizes } from "../cli/sync.js";
|
|
7
8
|
import { VaultClient } from "../index.js";
|
|
8
9
|
import { pickCanonicalPersonEntity } from "../vault-client.js";
|
|
9
10
|
import { acquireOperationLock, withOperationLock, withOperationLockSync, OperationLockedError, OPERATION_LOCKED_EXIT, } from "../operation-lock.js";
|
|
@@ -13,7 +14,7 @@ import { PARTIAL_SYNC_EXIT } from "../lib/exit-codes.js";
|
|
|
13
14
|
import { getOrCreateMachineId } from "../lib/machine-id.js";
|
|
14
15
|
import { localPathForVaultKey } from "../local-path-codec.js";
|
|
15
16
|
import { TreeWatcher, resolveEventDebounceConfig, systemClock, } from "../watcher.js";
|
|
16
|
-
import { clearLocalDeleteIntent, getStateDir, markLocalDeleteIntent, PERSONAL_VAULT_JOURNAL_SLUG, openJournalStoreSession, openJournalStoreSessionAsync, listJournalSlugs, listJournals, maintainAreaJournalSlice, readJournal, writeJournal, } from "../journal.js";
|
|
17
|
+
import { clearLocalDeleteIntent, getStateDir, markLocalDeleteIntent, PERSONAL_VAULT_JOURNAL_SLUG, openJournalStoreSession, openJournalStoreSessionAsync, listJournalSlugs, listJournals, maintainAreaJournalSlice, readJournal, releaseCachedAreaJournalMigrations, journalCacheCensusSizes, readJournalScoped, writeJournal, } from "../journal.js";
|
|
17
18
|
import { NoopPushReceiver, } from "../sync/push-receiver.js";
|
|
18
19
|
import { resolveEventSync, startEventSync as defaultStartEventSync, } from "../sync/event-sync.js";
|
|
19
20
|
import { resolveAreaStorageEnabled, resolveEffectiveParallelSyncRollout, resolveParallelSyncRollout, } from "../sync/feature-flags.js";
|
|
@@ -117,9 +118,10 @@ const EVENT_SYNC_CENSUS_SITES = [
|
|
|
117
118
|
"publishedContentHashGenerations",
|
|
118
119
|
"deferredPublishes",
|
|
119
120
|
"durablePublishedHashRetries",
|
|
121
|
+
"initialPublishedContentHashes",
|
|
120
122
|
];
|
|
121
123
|
/** TreeWatcher-owned census sites, read via {@link WatcherSurface.censusSizes}. */
|
|
122
|
-
const WATCHER_CENSUS_SITES = ["knownKinds", "deleteSnapshotEpochs"];
|
|
124
|
+
const WATCHER_CENSUS_SITES = ["knownKinds", "deleteSnapshotEpochs", "ignoreFilterMemo"];
|
|
123
125
|
/**
|
|
124
126
|
* Assemble the heap census from every long-lived watch-session structure. Each
|
|
125
127
|
* site registers under a FIXED token; the emitter/watcher sites read the CURRENT
|
|
@@ -355,6 +357,24 @@ export function journalEntriesForWatcherDelete(files, key, kind) {
|
|
|
355
357
|
}
|
|
356
358
|
return Object.entries(files).filter(([candidate]) => key === "" || candidate === key || candidate.startsWith(`${key}/`));
|
|
357
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* Return a journal hash only when its row demonstrably predates this runner.
|
|
362
|
+
*
|
|
363
|
+
* A scoped push writes the completed upload's hash before the runner hands the
|
|
364
|
+
* path to PushEventEmitter. The lazy tier is a startup baseline, not a live
|
|
365
|
+
* "has this runner just pushed it?" lookup, so every row stamped at or after
|
|
366
|
+
* this session's start is deliberately a miss. Invalid timestamps are also a
|
|
367
|
+
* miss: publishing an extra realtime event is safer than suppressing one.
|
|
368
|
+
*/
|
|
369
|
+
export function publishedContentHashFromJournalEntryBeforeSession(entry, sessionStartedAt) {
|
|
370
|
+
if (entry === undefined || entry.removedAt !== undefined || entry.kind === "symlink" || entry.localDiverges) {
|
|
371
|
+
return undefined;
|
|
372
|
+
}
|
|
373
|
+
const syncedAt = Date.parse(entry.syncedAt);
|
|
374
|
+
if (!Number.isFinite(syncedAt) || syncedAt >= sessionStartedAt)
|
|
375
|
+
return undefined;
|
|
376
|
+
return `sha256:${entry.hash}`;
|
|
377
|
+
}
|
|
358
378
|
/**
|
|
359
379
|
* Bulk-intent quarantine thresholds. Deliberately the same shape and values as
|
|
360
380
|
* the engine's `BULK_ASYMMETRY_*` constants (`src/cli/share.ts`) so operators
|
|
@@ -1300,6 +1320,7 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
1300
1320
|
const quarantinedDeleteRoots = new Set();
|
|
1301
1321
|
const watcherJournalStores = new Map();
|
|
1302
1322
|
const watcherJournalStoreOpens = new Map();
|
|
1323
|
+
let watcherJournalStoreEpoch = 0;
|
|
1303
1324
|
const watcherJournalStore = (slug) => {
|
|
1304
1325
|
const existing = watcherJournalStores.get(slug);
|
|
1305
1326
|
if (existing)
|
|
@@ -1314,8 +1335,13 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
1314
1335
|
return existing;
|
|
1315
1336
|
let opening = watcherJournalStoreOpens.get(slug);
|
|
1316
1337
|
if (!opening) {
|
|
1338
|
+
const openingEpoch = watcherJournalStoreEpoch;
|
|
1317
1339
|
opening = openJournalStoreSessionAsync(slug).then((created) => {
|
|
1318
|
-
|
|
1340
|
+
// A completed pass may have released its cache while this yielding
|
|
1341
|
+
// open was pending. The caller still receives a correct local session,
|
|
1342
|
+
// but the stale completion must not repin a full journal indefinitely.
|
|
1343
|
+
if (openingEpoch === watcherJournalStoreEpoch)
|
|
1344
|
+
watcherJournalStores.set(slug, created);
|
|
1319
1345
|
return created;
|
|
1320
1346
|
});
|
|
1321
1347
|
watcherJournalStoreOpens.set(slug, opening);
|
|
@@ -1323,6 +1349,14 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
1323
1349
|
}
|
|
1324
1350
|
return opening;
|
|
1325
1351
|
};
|
|
1352
|
+
const releaseWatcherJournalStores = () => {
|
|
1353
|
+
watcherJournalStoreEpoch += 1;
|
|
1354
|
+
// Do not dispose here. A raw watcher callback can still hold a local
|
|
1355
|
+
// session while its asynchronous capture finishes for the next episode;
|
|
1356
|
+
// removing the cache reference lets that operation complete correctly and
|
|
1357
|
+
// makes the completed episode's full projection collectible afterwards.
|
|
1358
|
+
watcherJournalStores.clear();
|
|
1359
|
+
};
|
|
1326
1360
|
const QUARANTINE_KEY_SEPARATOR = "\u0000";
|
|
1327
1361
|
const quarantineRootKey = (slug, journalKey) => `${slug}${QUARANTINE_KEY_SEPARATOR}${journalKey}`;
|
|
1328
1362
|
const quarantineRootFor = (slug, journalKey) => {
|
|
@@ -1598,26 +1632,15 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
1598
1632
|
}
|
|
1599
1633
|
return paths;
|
|
1600
1634
|
};
|
|
1601
|
-
const
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
for (const [key, entry] of Object.entries(journal.files)) {
|
|
1611
|
-
// Tombstones and link records have no live regular-file body for the
|
|
1612
|
-
// PushEventEmitter's SHA-256 comparison, so they must not seed it.
|
|
1613
|
-
if (entry.removedAt !== undefined ||
|
|
1614
|
-
entry.kind === "symlink" ||
|
|
1615
|
-
entry.localDiverges)
|
|
1616
|
-
continue;
|
|
1617
|
-
hashes[isPersonal ? key : `companies/${slug}/${key}`] = `sha256:${entry.hash}`;
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
return hashes;
|
|
1635
|
+
const publishedContentHashLookup = (relativePath) => {
|
|
1636
|
+
const coordinates = journalCoordinates(relativePath);
|
|
1637
|
+
if (!coordinates)
|
|
1638
|
+
return undefined;
|
|
1639
|
+
// Do not capture a session-sized object in the emitter closure. A durable
|
|
1640
|
+
// cache miss reads precisely this journal key; only a valid row from
|
|
1641
|
+
// before this runner began can seed the historical baseline.
|
|
1642
|
+
const entry = readJournalScoped(coordinates.slug, [coordinates.key]).files[coordinates.key];
|
|
1643
|
+
return publishedContentHashFromJournalEntryBeforeSession(entry, serviceStartedAt);
|
|
1621
1644
|
};
|
|
1622
1645
|
const prepareWatcherChanges = (changes) => {
|
|
1623
1646
|
const journals = new Map();
|
|
@@ -2347,7 +2370,7 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
2347
2370
|
telemetryClient: eventSyncClient,
|
|
2348
2371
|
telemetryClaims: claims,
|
|
2349
2372
|
publishedContentHashStateDir: getStateDir(),
|
|
2350
|
-
|
|
2373
|
+
publishedContentHashLookup,
|
|
2351
2374
|
onReceiveActivity,
|
|
2352
2375
|
});
|
|
2353
2376
|
if (!handles)
|
|
@@ -2454,6 +2477,11 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
2454
2477
|
pendingWatcherDroppedRouteHints: () => pendingWatcherDroppedRouteHints.size,
|
|
2455
2478
|
quarantinedDeleteRoots: () => quarantinedDeleteRoots.size,
|
|
2456
2479
|
watcherJournalStores: () => watcherJournalStores.size,
|
|
2480
|
+
watcherJournalRows: () => Array.from(watcherJournalStores.values())
|
|
2481
|
+
.reduce((total, store) => total + store.rowCount(), 0),
|
|
2482
|
+
targetedJournalSessions: () => targetedJournalSessionCensusSizes().targetedJournalSessions,
|
|
2483
|
+
targetedJournalRows: () => targetedJournalSessionCensusSizes().targetedJournalRows,
|
|
2484
|
+
cachedAreaJournalMigrations: () => journalCacheCensusSizes().cachedAreaJournalMigrations,
|
|
2457
2485
|
pendingSlowPasses: () => pendingSlowPasses.length,
|
|
2458
2486
|
pendingFastPasses: () => pendingFastPasses.length,
|
|
2459
2487
|
},
|
|
@@ -2715,6 +2743,12 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
2715
2743
|
for (const root of drainedQuarantineRoots) {
|
|
2716
2744
|
quarantinedDeleteRoots.delete(root);
|
|
2717
2745
|
}
|
|
2746
|
+
// Delete snapshot capture needs a fresh keyed view while an episode is
|
|
2747
|
+
// being assembled, but completed watch cycles do not. Releasing it here
|
|
2748
|
+
// prevents the watcher from retaining another full-vault projection next
|
|
2749
|
+
// to the targeted-pull and area-ledger views.
|
|
2750
|
+
releaseWatcherJournalStores();
|
|
2751
|
+
releaseCachedAreaJournalMigrations();
|
|
2718
2752
|
const exitCode = passExitCode(result);
|
|
2719
2753
|
if (exitCode === runtime.authRequiredPassExit) {
|
|
2720
2754
|
// The pass already emitted auth-error. Hand the sentinel to the
|
|
@@ -2845,6 +2879,8 @@ export async function runWatchLoop(argv, parsed, deps, runtime) {
|
|
|
2845
2879
|
return 0;
|
|
2846
2880
|
}
|
|
2847
2881
|
finally {
|
|
2882
|
+
releaseWatcherJournalStores();
|
|
2883
|
+
releaseCachedAreaJournalMigrations();
|
|
2848
2884
|
await shutdown();
|
|
2849
2885
|
detachSignal?.();
|
|
2850
2886
|
}
|