@indigoai-us/hq-cloud 6.16.83-alpha.0 → 6.16.85-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 +22 -19
- package/dist/bin/sync-runner-watch-loop.d.ts.map +1 -1
- package/dist/bin/sync-runner-watch-loop.js +127 -61
- 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 +641 -296
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/cli/share.d.ts.map +1 -1
- package/dist/cli/share.js +50 -9
- package/dist/cli/share.js.map +1 -1
- package/dist/cli/share.test.js +224 -1
- package/dist/cli/share.test.js.map +1 -1
- package/dist/lib/machine-id.d.ts +7 -0
- package/dist/lib/machine-id.d.ts.map +1 -1
- package/dist/lib/machine-id.js +54 -7
- package/dist/lib/machine-id.js.map +1 -1
- package/dist/lib/machine-id.test.js +20 -1
- package/dist/lib/machine-id.test.js.map +1 -1
- package/dist/object-io.d.ts +2 -0
- package/dist/object-io.d.ts.map +1 -1
- package/dist/object-io.js +78 -27
- package/dist/object-io.js.map +1 -1
- package/dist/object-io.test.js +107 -2
- package/dist/object-io.test.js.map +1 -1
- package/dist/sync/event-sync.d.ts +14 -4
- package/dist/sync/event-sync.d.ts.map +1 -1
- package/dist/sync/event-sync.js +148 -14
- package/dist/sync/event-sync.js.map +1 -1
- package/dist/sync/event-sync.test.js +321 -2
- package/dist/sync/event-sync.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/dist/sync/parallel-sync-coordinator.d.ts +1 -0
- package/dist/sync/parallel-sync-coordinator.d.ts.map +1 -1
- package/dist/sync/parallel-sync-coordinator.js +39 -8
- package/dist/sync/parallel-sync-coordinator.js.map +1 -1
- package/dist/sync/parallel-sync-coordinator.test.js +33 -1
- package/dist/sync/parallel-sync-coordinator.test.js.map +1 -1
- package/dist/sync/push-receiver.d.ts +3 -1
- package/dist/sync/push-receiver.d.ts.map +1 -1
- package/dist/sync/push-receiver.js +45 -9
- package/dist/sync/push-receiver.js.map +1 -1
- package/dist/sync/push-receiver.test.js +70 -0
- package/dist/sync/push-receiver.test.js.map +1 -1
- package/dist/sync/push-transport.d.ts +15 -0
- package/dist/sync/push-transport.d.ts.map +1 -1
- package/dist/sync/push-transport.js +27 -0
- package/dist/sync/push-transport.js.map +1 -1
- package/dist/sync/push-transport.test.js +14 -1
- package/dist/sync/push-transport.test.js.map +1 -1
- package/dist/sync/sync-work.d.ts +5 -0
- package/dist/sync/sync-work.d.ts.map +1 -1
- package/dist/sync/sync-work.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/share.test.js
CHANGED
|
@@ -68,7 +68,7 @@ import { share, ServerOwnedPushPathsError, UnreachablePushPathsError, Unregister
|
|
|
68
68
|
import { deleteRemoteFile, downloadFile, headRemoteFile, primeObjectTransport, primeUploads, uploadFile, uploadSymlink, WindowsSymlinkPrivilegeError, } from "../s3.js";
|
|
69
69
|
import { VaultAuthError, VaultClientError, VaultConflictError, VaultPermissionDeniedError, } from "../vault-client.js";
|
|
70
70
|
import { CognitoRefreshError } from "../cognito-auth.js";
|
|
71
|
-
import { RateLimitedError } from "../object-io.js";
|
|
71
|
+
import { ObjectLockChecksumRequiredError, RateLimitedError, } from "../object-io.js";
|
|
72
72
|
import { AreaLedgerMigration, closeCachedAreaJournalMigration, hashFile, openJournalStateStoreForMigration, readJournal, readJournalScoped, setAreaLedgerMigrationTestHooksForTest, writeJournal, } from "../journal.js";
|
|
73
73
|
import { ReconcileCursorStore } from "../sync/reconcile-cursor.js";
|
|
74
74
|
import { AreaResolver } from "../sync/area-resolver.js";
|
|
@@ -2019,6 +2019,109 @@ describe("share", () => {
|
|
|
2019
2019
|
vi.mocked(uploadFile).mockResolvedValue({ etag: '"upload-etag"' });
|
|
2020
2020
|
}
|
|
2021
2021
|
});
|
|
2022
|
+
it.each([
|
|
2023
|
+
[
|
|
2024
|
+
"429 throttle",
|
|
2025
|
+
() => new RateLimitedError("test.md", "put"),
|
|
2026
|
+
"RateLimited",
|
|
2027
|
+
true,
|
|
2028
|
+
],
|
|
2029
|
+
[
|
|
2030
|
+
"503 throttle",
|
|
2031
|
+
() => Object.assign(new Error("presign request failed (503)"), {
|
|
2032
|
+
statusCode: 503,
|
|
2033
|
+
}),
|
|
2034
|
+
"503",
|
|
2035
|
+
true,
|
|
2036
|
+
],
|
|
2037
|
+
[
|
|
2038
|
+
"Object Lock 400 checksum refusal",
|
|
2039
|
+
() => new ObjectLockChecksumRequiredError("test.md", "checksum required"),
|
|
2040
|
+
"ObjectLockChecksumRequired",
|
|
2041
|
+
false,
|
|
2042
|
+
],
|
|
2043
|
+
[
|
|
2044
|
+
"request timeout",
|
|
2045
|
+
() => Object.assign(new Error("request timed out"), { name: "TimeoutError" }),
|
|
2046
|
+
"TimeoutError",
|
|
2047
|
+
true,
|
|
2048
|
+
],
|
|
2049
|
+
[
|
|
2050
|
+
"caller abort",
|
|
2051
|
+
() => Object.assign(new Error("request aborted"), { name: "AbortError" }),
|
|
2052
|
+
"AbortError",
|
|
2053
|
+
true,
|
|
2054
|
+
],
|
|
2055
|
+
[
|
|
2056
|
+
"nested transport failure",
|
|
2057
|
+
() => Object.assign(new TypeError("fetch failed"), {
|
|
2058
|
+
cause: Object.assign(new Error("socket reset"), { code: "ECONNRESET" }),
|
|
2059
|
+
}),
|
|
2060
|
+
"fetch failed",
|
|
2061
|
+
true,
|
|
2062
|
+
],
|
|
2063
|
+
])("remote failure contract classifies %s, preserves its journal row, and emits its reason", async (_description, makeFailure, telemetryReason, deferred) => {
|
|
2064
|
+
const companyRoot = path.join(tmpDir, "companies", "acme");
|
|
2065
|
+
fs.mkdirSync(companyRoot, { recursive: true });
|
|
2066
|
+
const testFile = path.join(companyRoot, "test.md");
|
|
2067
|
+
fs.writeFileSync(testFile, "# Hello World");
|
|
2068
|
+
const journalPath = path.join(stateDir, "sync-journal.acme.json");
|
|
2069
|
+
const staleHash = "stale-hash-for-old-content";
|
|
2070
|
+
seedJournalAt(journalPath, {
|
|
2071
|
+
version: "1",
|
|
2072
|
+
lastSync: new Date(Date.now() - 60_000).toISOString(),
|
|
2073
|
+
files: {
|
|
2074
|
+
"test.md": {
|
|
2075
|
+
hash: staleHash,
|
|
2076
|
+
size: 5,
|
|
2077
|
+
syncedAt: new Date(Date.now() - 60_000).toISOString(),
|
|
2078
|
+
direction: "up",
|
|
2079
|
+
remoteEtag: "old-etag",
|
|
2080
|
+
},
|
|
2081
|
+
},
|
|
2082
|
+
});
|
|
2083
|
+
vi.mocked(uploadFile).mockReset();
|
|
2084
|
+
vi.mocked(uploadFile).mockRejectedValueOnce(makeFailure());
|
|
2085
|
+
try {
|
|
2086
|
+
const events = [];
|
|
2087
|
+
const result = await share({
|
|
2088
|
+
paths: [testFile],
|
|
2089
|
+
company: "acme",
|
|
2090
|
+
vaultConfig: mockConfig,
|
|
2091
|
+
hqRoot: tmpDir,
|
|
2092
|
+
onEvent: (event) => events.push(event),
|
|
2093
|
+
});
|
|
2094
|
+
expect(result.filesUploaded).toBe(0);
|
|
2095
|
+
expect(journalAt(journalPath).files["test.md"]).toMatchObject({
|
|
2096
|
+
hash: staleHash,
|
|
2097
|
+
remoteEtag: "old-etag",
|
|
2098
|
+
});
|
|
2099
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
2100
|
+
type: "error",
|
|
2101
|
+
path: "test.md",
|
|
2102
|
+
message: expect.stringContaining(telemetryReason),
|
|
2103
|
+
}));
|
|
2104
|
+
if (deferred) {
|
|
2105
|
+
expect(result.filesSkipped).toBeGreaterThanOrEqual(1);
|
|
2106
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
2107
|
+
type: "error",
|
|
2108
|
+
diagnostic: true,
|
|
2109
|
+
path: "test.md",
|
|
2110
|
+
}));
|
|
2111
|
+
expect(events.some((event) => event.type === "error" && event.diagnostic !== true)).toBe(false);
|
|
2112
|
+
}
|
|
2113
|
+
else {
|
|
2114
|
+
expect(result.filesSkipped).toBe(0);
|
|
2115
|
+
const errorEvent = events.find((event) => event.type === "error");
|
|
2116
|
+
expect(errorEvent).toMatchObject({ type: "error", path: "test.md" });
|
|
2117
|
+
expect(errorEvent).not.toHaveProperty("diagnostic");
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
finally {
|
|
2121
|
+
vi.mocked(uploadFile).mockReset();
|
|
2122
|
+
vi.mocked(uploadFile).mockResolvedValue({ etag: '"upload-etag"' });
|
|
2123
|
+
}
|
|
2124
|
+
});
|
|
2022
2125
|
it("still emits a hard error when upload throws a generic Error", async () => {
|
|
2023
2126
|
const companyRoot = path.join(tmpDir, "companies", "acme");
|
|
2024
2127
|
fs.mkdirSync(companyRoot, { recursive: true });
|
|
@@ -3908,6 +4011,126 @@ describe("share", () => {
|
|
|
3908
4011
|
expect(calls[0][4]).toEqual({ ifNoneMatch: "*" });
|
|
3909
4012
|
expect(calls[1][4]).toBeUndefined();
|
|
3910
4013
|
});
|
|
4014
|
+
it("defers a retryable upload failure after overwrite conflict resolution", async () => {
|
|
4015
|
+
const companyRoot = path.join(tmpDir, "companies", "acme");
|
|
4016
|
+
fs.mkdirSync(companyRoot, { recursive: true });
|
|
4017
|
+
const testFile = path.join(companyRoot, "retry-later.md");
|
|
4018
|
+
fs.writeFileSync(testFile, "keep journaled until the next pass");
|
|
4019
|
+
const journalPath = path.join(stateDir, "sync-journal.acme.json");
|
|
4020
|
+
const staleHash = "old-retry-later-hash";
|
|
4021
|
+
seedJournalAt(journalPath, {
|
|
4022
|
+
version: "1",
|
|
4023
|
+
lastSync: new Date(Date.now() - 60_000).toISOString(),
|
|
4024
|
+
files: {
|
|
4025
|
+
"retry-later.md": {
|
|
4026
|
+
hash: staleHash,
|
|
4027
|
+
size: 5,
|
|
4028
|
+
syncedAt: new Date(Date.now() - 60_000).toISOString(),
|
|
4029
|
+
direction: "up",
|
|
4030
|
+
remoteEtag: "old-etag",
|
|
4031
|
+
},
|
|
4032
|
+
},
|
|
4033
|
+
});
|
|
4034
|
+
vi.mocked(headRemoteFile).mockResolvedValueOnce(null);
|
|
4035
|
+
vi.mocked(uploadFile)
|
|
4036
|
+
.mockRejectedValueOnce(fence412())
|
|
4037
|
+
.mockRejectedValueOnce(Object.assign(new Error("retry PUT timed out"), { name: "TimeoutError" }));
|
|
4038
|
+
const store = ReconcileCursorStore.open({
|
|
4039
|
+
rootDir: stateDir,
|
|
4040
|
+
journalSlug: "acme",
|
|
4041
|
+
layoutEpoch: 1,
|
|
4042
|
+
areaId: "root:notes",
|
|
4043
|
+
});
|
|
4044
|
+
const events = [];
|
|
4045
|
+
const result = await share({
|
|
4046
|
+
paths: [testFile],
|
|
4047
|
+
company: "acme",
|
|
4048
|
+
vaultConfig: mockConfig,
|
|
4049
|
+
hqRoot: tmpDir,
|
|
4050
|
+
onConflict: "overwrite",
|
|
4051
|
+
onEvent: (event) => events.push(event),
|
|
4052
|
+
reconcileApply: {
|
|
4053
|
+
store,
|
|
4054
|
+
cursor: {
|
|
4055
|
+
routerVersion: 1,
|
|
4056
|
+
epoch: "epoch-overwrite",
|
|
4057
|
+
areaId: "root:notes",
|
|
4058
|
+
phase: "apply",
|
|
4059
|
+
journalAfterKey: "retry-later.md",
|
|
4060
|
+
},
|
|
4061
|
+
},
|
|
4062
|
+
});
|
|
4063
|
+
expect(vi.mocked(uploadFile)).toHaveBeenCalledTimes(2);
|
|
4064
|
+
expect(result.filesUploaded).toBe(0);
|
|
4065
|
+
expect(result.filesSkipped).toBe(1);
|
|
4066
|
+
expect(journalAt(journalPath).files["retry-later.md"]).toMatchObject({
|
|
4067
|
+
hash: staleHash,
|
|
4068
|
+
remoteEtag: "old-etag",
|
|
4069
|
+
});
|
|
4070
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
4071
|
+
type: "error",
|
|
4072
|
+
diagnostic: true,
|
|
4073
|
+
path: "retry-later.md",
|
|
4074
|
+
message: expect.stringContaining("TimeoutError"),
|
|
4075
|
+
}));
|
|
4076
|
+
expect(events.some((event) => event.type === "error" && event.diagnostic !== true)).toBe(false);
|
|
4077
|
+
expect(store.read().cursor).toBeUndefined();
|
|
4078
|
+
});
|
|
4079
|
+
it("withholds an apply checkpoint when a version-aware local retry is deferred", async () => {
|
|
4080
|
+
const companyRoot = path.join(tmpDir, "companies", "acme");
|
|
4081
|
+
fs.mkdirSync(companyRoot, { recursive: true });
|
|
4082
|
+
const testFile = path.join(companyRoot, "retry-local-winner.md");
|
|
4083
|
+
fs.writeFileSync(testFile, "---\nversion: 10\n---\nlocal body\n");
|
|
4084
|
+
vi.mocked(headRemoteFile)
|
|
4085
|
+
.mockResolvedValueOnce(null)
|
|
4086
|
+
.mockResolvedValueOnce({
|
|
4087
|
+
lastModified: new Date(),
|
|
4088
|
+
etag: '"peer-etag"',
|
|
4089
|
+
size: 31,
|
|
4090
|
+
});
|
|
4091
|
+
vi.mocked(downloadFile).mockImplementationOnce(async (_ctx, _key, destination) => {
|
|
4092
|
+
fs.writeFileSync(destination, "---\nversion: 8\n---\nremote body\n");
|
|
4093
|
+
return undefined;
|
|
4094
|
+
});
|
|
4095
|
+
vi.mocked(uploadFile)
|
|
4096
|
+
.mockRejectedValueOnce(fence412())
|
|
4097
|
+
.mockRejectedValueOnce(Object.assign(new Error("retry PUT timed out"), { name: "TimeoutError" }));
|
|
4098
|
+
const store = ReconcileCursorStore.open({
|
|
4099
|
+
rootDir: stateDir,
|
|
4100
|
+
journalSlug: "acme",
|
|
4101
|
+
layoutEpoch: 1,
|
|
4102
|
+
areaId: "root:notes",
|
|
4103
|
+
});
|
|
4104
|
+
const events = [];
|
|
4105
|
+
const result = await share({
|
|
4106
|
+
paths: [testFile],
|
|
4107
|
+
company: "acme",
|
|
4108
|
+
vaultConfig: mockConfig,
|
|
4109
|
+
hqRoot: tmpDir,
|
|
4110
|
+
onConflict: "keep",
|
|
4111
|
+
onEvent: (event) => events.push(event),
|
|
4112
|
+
reconcileApply: {
|
|
4113
|
+
store,
|
|
4114
|
+
cursor: {
|
|
4115
|
+
routerVersion: 1,
|
|
4116
|
+
epoch: "epoch-local-winner",
|
|
4117
|
+
areaId: "root:notes",
|
|
4118
|
+
phase: "apply",
|
|
4119
|
+
journalAfterKey: "retry-local-winner.md",
|
|
4120
|
+
},
|
|
4121
|
+
},
|
|
4122
|
+
});
|
|
4123
|
+
expect(vi.mocked(uploadFile)).toHaveBeenCalledTimes(2);
|
|
4124
|
+
expect(result.filesUploaded).toBe(0);
|
|
4125
|
+
expect(result.filesSkipped).toBe(1);
|
|
4126
|
+
expect(store.read().cursor).toBeUndefined();
|
|
4127
|
+
expect(events).toContainEqual(expect.objectContaining({
|
|
4128
|
+
type: "error",
|
|
4129
|
+
diagnostic: true,
|
|
4130
|
+
path: "retry-local-winner.md",
|
|
4131
|
+
message: expect.stringContaining("TimeoutError"),
|
|
4132
|
+
}));
|
|
4133
|
+
});
|
|
3911
4134
|
it("412 under abort: halts the pass", async () => {
|
|
3912
4135
|
const companyRoot = path.join(tmpDir, "companies", "acme");
|
|
3913
4136
|
fs.mkdirSync(companyRoot, { recursive: true });
|