@indigoai-us/hq-cloud 6.15.40 → 6.15.41
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.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +59 -26
- package/dist/bin/sync-runner-watch-loop.js.map +1 -1
- package/dist/bin/sync-runner.d.ts +10 -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 +90 -1
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/watcher.d.ts +2 -0
- package/dist/watcher.d.ts.map +1 -1
- package/dist/watcher.js +4 -0
- package/dist/watcher.js.map +1 -1
- package/package.json +1 -1
|
@@ -13,7 +13,7 @@ import * as path from "path";
|
|
|
13
13
|
import { runRunner, runRunnerWithLoop, resolveDeletePolicy, resolveSkipPersonal, resolveSkipCompanies, selectObjectIOFactory, routeChangeToTarget, buildTargetedPushArgv, resolvePullScope, readPinnedPrefixes, SESSIONS_SCOPE_PREFIX, defaultCollectTelemetry, AUTH_REQUIRED_PASS_EXIT, } from "./sync-runner.js";
|
|
14
14
|
import { PresignObjectIO, S3SdkObjectIO } from "../object-io.js";
|
|
15
15
|
import { setBandwidthGovernorForTesting } from "../bandwidth.js";
|
|
16
|
-
import { FakeClock, } from "../watcher.js";
|
|
16
|
+
import { FakeClock, TreeWatcher, } from "../watcher.js";
|
|
17
17
|
import { adaptivePollMs, advanceMonotonicDeadline, journalEntriesForWatcherDelete, shouldQuarantineWatcherDeleteIntents, } from "./sync-runner-watch-loop.js";
|
|
18
18
|
import { PERSONAL_VAULT_JOURNAL_SLUG, readJournal, writeJournal, } from "../journal.js";
|
|
19
19
|
import { HQ_CLOUD_VERSION } from "../version.js";
|
|
@@ -3809,6 +3809,95 @@ describe("runRunnerWithLoop — adaptive poll interval (no --poll-remote-ms)", (
|
|
|
3809
3809
|
});
|
|
3810
3810
|
});
|
|
3811
3811
|
describe("runRunnerWithLoop — event-push wiring", () => {
|
|
3812
|
+
it("activates the watcher after a successful numeric --companies pass", async () => {
|
|
3813
|
+
const watcher = makeWatcherStub();
|
|
3814
|
+
let triggerShutdown = () => { };
|
|
3815
|
+
const loop = runRunnerWithLoop(["--companies", "--watch", "--event-push", "--hq-root", "/tmp/hq"], {
|
|
3816
|
+
// The watch-loop seam may report a completed pass as a bare status.
|
|
3817
|
+
// A successful status must not permanently suppress local watching.
|
|
3818
|
+
runPass: vi.fn().mockResolvedValue(0),
|
|
3819
|
+
createWatcher: () => watcher,
|
|
3820
|
+
sleep: () => new Promise(() => { }),
|
|
3821
|
+
onShutdownSignal: (handler) => {
|
|
3822
|
+
triggerShutdown = handler;
|
|
3823
|
+
return () => { };
|
|
3824
|
+
},
|
|
3825
|
+
});
|
|
3826
|
+
await flushLoopMicrotasks();
|
|
3827
|
+
expect(watcher.started).toBe(true);
|
|
3828
|
+
triggerShutdown();
|
|
3829
|
+
await loop;
|
|
3830
|
+
});
|
|
3831
|
+
it("keeps both personal and company roots in a --companies watcher", async () => {
|
|
3832
|
+
const hqRoot = fs.mkdtempSync(path.join(os.tmpdir(), "hq-combined-watch-"));
|
|
3833
|
+
fs.mkdirSync(path.join(hqRoot, "personal"), { recursive: true });
|
|
3834
|
+
fs.mkdirSync(path.join(hqRoot, "companies", "indigo", "knowledge"), {
|
|
3835
|
+
recursive: true,
|
|
3836
|
+
});
|
|
3837
|
+
fs.writeFileSync(path.join(hqRoot, "personal", "profile.md"), "personal");
|
|
3838
|
+
fs.writeFileSync(path.join(hqRoot, "companies", "indigo", "knowledge", "guide.md"), "company");
|
|
3839
|
+
let triggerShutdown = () => { };
|
|
3840
|
+
let watchedRootCount = 0;
|
|
3841
|
+
const loop = runRunnerWithLoop(["--companies", "--watch", "--event-push", "--hq-root", hqRoot], {
|
|
3842
|
+
runPass: vi.fn().mockResolvedValue(completedPassOutcome()),
|
|
3843
|
+
createWatcher: (options) => new TreeWatcher({
|
|
3844
|
+
...options,
|
|
3845
|
+
backendFactory: ({ hqRoot, shouldEmit }) => {
|
|
3846
|
+
const roots = [
|
|
3847
|
+
path.join(hqRoot, "personal"),
|
|
3848
|
+
path.join(hqRoot, "companies"),
|
|
3849
|
+
path.join(hqRoot, "companies", "indigo"),
|
|
3850
|
+
].filter((candidate) => shouldEmit(candidate, true));
|
|
3851
|
+
watchedRootCount = roots.length;
|
|
3852
|
+
return {
|
|
3853
|
+
close: () => { },
|
|
3854
|
+
needsKnownKinds: false,
|
|
3855
|
+
watchedPathCount: () => watchedRootCount,
|
|
3856
|
+
};
|
|
3857
|
+
},
|
|
3858
|
+
}),
|
|
3859
|
+
sleep: () => new Promise(() => { }),
|
|
3860
|
+
onShutdownSignal: (handler) => {
|
|
3861
|
+
triggerShutdown = handler;
|
|
3862
|
+
return () => { };
|
|
3863
|
+
},
|
|
3864
|
+
});
|
|
3865
|
+
try {
|
|
3866
|
+
await flushLoopMicrotasks();
|
|
3867
|
+
expect(watchedRootCount).toBe(3);
|
|
3868
|
+
}
|
|
3869
|
+
finally {
|
|
3870
|
+
triggerShutdown();
|
|
3871
|
+
await loop;
|
|
3872
|
+
fs.rmSync(hqRoot, { recursive: true, force: true });
|
|
3873
|
+
}
|
|
3874
|
+
});
|
|
3875
|
+
it("warns once and continues poll-only when watcher startup fails", async () => {
|
|
3876
|
+
const stderrWrite = vi
|
|
3877
|
+
.spyOn(process.stderr, "write")
|
|
3878
|
+
.mockImplementation(() => true);
|
|
3879
|
+
let triggerShutdown = () => { };
|
|
3880
|
+
const loop = runRunnerWithLoop(["--companies", "--watch", "--event-push", "--hq-root", "/tmp/hq"], {
|
|
3881
|
+
runPass: vi.fn().mockResolvedValue(completedPassOutcome()),
|
|
3882
|
+
createWatcher: () => {
|
|
3883
|
+
throw new Error("simulated watcher startup failure");
|
|
3884
|
+
},
|
|
3885
|
+
sleep: () => new Promise(() => { }),
|
|
3886
|
+
onShutdownSignal: (handler) => {
|
|
3887
|
+
triggerShutdown = handler;
|
|
3888
|
+
return () => { };
|
|
3889
|
+
},
|
|
3890
|
+
});
|
|
3891
|
+
try {
|
|
3892
|
+
await flushLoopMicrotasks();
|
|
3893
|
+
expect(stderrWrite.mock.calls.map(([chunk]) => String(chunk)).join("")).toContain("hq-sync-runner: event-push watcher unavailable; continuing poll-only: simulated watcher startup failure");
|
|
3894
|
+
}
|
|
3895
|
+
finally {
|
|
3896
|
+
triggerShutdown();
|
|
3897
|
+
await loop;
|
|
3898
|
+
stderrWrite.mockRestore();
|
|
3899
|
+
}
|
|
3900
|
+
});
|
|
3812
3901
|
it("does not start journal-reading watcher callbacks before the initial pass finishes", async () => {
|
|
3813
3902
|
const watcher = makeWatcherStub();
|
|
3814
3903
|
let maintenanceComplete = false;
|