@indigoai-us/hq-cloud 6.3.0 → 6.3.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/sync-runner.d.ts +22 -2
- package/dist/bin/sync-runner.d.ts.map +1 -1
- package/dist/bin/sync-runner.js +85 -2
- package/dist/bin/sync-runner.js.map +1 -1
- package/dist/bin/sync-runner.test.js +201 -0
- package/dist/bin/sync-runner.test.js.map +1 -1
- package/dist/cli/rescue-core.js +14 -2
- package/dist/cli/rescue-core.js.map +1 -1
- package/dist/cli/rescue-hq-root-guard.test.d.ts +2 -0
- package/dist/cli/rescue-hq-root-guard.test.d.ts.map +1 -0
- package/dist/cli/rescue-hq-root-guard.test.js +176 -0
- package/dist/cli/rescue-hq-root-guard.test.js.map +1 -0
- package/dist/skill-telemetry.d.ts +42 -6
- package/dist/skill-telemetry.d.ts.map +1 -1
- package/dist/skill-telemetry.js +253 -10
- package/dist/skill-telemetry.js.map +1 -1
- package/dist/skill-telemetry.test.js +287 -1
- package/dist/skill-telemetry.test.js.map +1 -1
- package/dist/sync/event-sync.d.ts +181 -0
- package/dist/sync/event-sync.d.ts.map +1 -0
- package/dist/sync/event-sync.js +316 -0
- package/dist/sync/event-sync.js.map +1 -0
- package/dist/sync/event-sync.test.d.ts +14 -0
- package/dist/sync/event-sync.test.d.ts.map +1 -0
- package/dist/sync/event-sync.test.js +440 -0
- package/dist/sync/event-sync.test.js.map +1 -0
- package/package.json +1 -1
- package/src/bin/sync-runner.test.ts +246 -0
- package/src/bin/sync-runner.ts +117 -3
- package/src/cli/rescue-core.ts +15 -2
- package/src/cli/rescue-hq-root-guard.test.ts +193 -0
- package/src/skill-telemetry.test.ts +433 -0
- package/src/skill-telemetry.ts +260 -10
- package/src/sync/event-sync.test.ts +533 -0
- package/src/sync/event-sync.ts +481 -0
- package/test/e2e/sync/cross-tenant-isolation.test.ts +126 -0
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event-driven sync wiring — Phase 3 of event-driven-sync-menubar
|
|
3
|
+
* (US-017 publish / US-018 receive / US-019 rollout gate).
|
|
4
|
+
*
|
|
5
|
+
* Phases 1–2 built every piece but left them unconnected: the watcher runs
|
|
6
|
+
* targeted *push passes* (S3 upload) but never publishes a PushEvent, and the
|
|
7
|
+
* runner's receiver seam defaults to {@link NoopPushReceiver}. This module is
|
|
8
|
+
* the connective tissue that turns both on for enrolled accounts:
|
|
9
|
+
*
|
|
10
|
+
* - {@link resolveEventSync} — the rollout gate. EXACT-email allowlist
|
|
11
|
+
* (mirrors `resolvePresignTransport`'s shape in sync-runner.ts, but full
|
|
12
|
+
* address, not domain suffix) + `HQ_SYNC_EVENT_SYNC` env override in both
|
|
13
|
+
* directions. ONE gate governs publish AND receive so a device is never
|
|
14
|
+
* publish-only or receive-only in a half-rolled state.
|
|
15
|
+
* - {@link subscribeSyncReceive} — `POST /v1/sync/subscribe` (US-015/US-016):
|
|
16
|
+
* mints the per-device queue and returns `{queueUrl, region, credentials}`,
|
|
17
|
+
* where `credentials` are short-lived STS creds scoped to receive/delete on
|
|
18
|
+
* exactly that queue.
|
|
19
|
+
* - {@link sqsClientFromAwsSdk} — the doc-promised thin adapter from the AWS
|
|
20
|
+
* SDK `SQSClient` to the receiver's narrow {@link SqsClientLike} seam.
|
|
21
|
+
* - {@link createRefreshingSqsClient} — wraps the adapter with credential
|
|
22
|
+
* lifecycle: proactive re-vend before expiry (skew window) + one reactive
|
|
23
|
+
* retry on an expiry-class error. The queue URL is stable across re-vends
|
|
24
|
+
* (same device → same queue, idempotent endpoint); only creds rotate.
|
|
25
|
+
* - {@link startEventSync} — the wiring entry the runner calls from the
|
|
26
|
+
* `--event-push` watch block when the gate is ON. Resolves tenant + device
|
|
27
|
+
* identity, builds the {@link HttpPushTransport} + {@link PushEventEmitter}
|
|
28
|
+
* (publish leg) and the {@link SqsPushReceiver} (receive leg, self-echo
|
|
29
|
+
* filtered), and returns handles. Any startup failure degrades to
|
|
30
|
+
* poll-only — it NEVER takes the daemon down.
|
|
31
|
+
*
|
|
32
|
+
* The 10-minute `--poll-remote-ms` pass remains the correctness backstop for
|
|
33
|
+
* every path here; event delivery is best-effort by design.
|
|
34
|
+
*/
|
|
35
|
+
import { SQSClient, ReceiveMessageCommand, DeleteMessageCommand, } from "@aws-sdk/client-sqs";
|
|
36
|
+
import { HttpPushTransport } from "./push-transport.js";
|
|
37
|
+
import { SqsPushReceiver, } from "./push-receiver.js";
|
|
38
|
+
import { PushEventEmitter } from "../watcher.js";
|
|
39
|
+
// ─── US-019: rollout gate ───────────────────────────────────────────────────
|
|
40
|
+
/**
|
|
41
|
+
* Accounts enrolled in event-driven sync (publish + receive).
|
|
42
|
+
*
|
|
43
|
+
* EXACT full-address matching, case-insensitive — NOT a domain suffix. The
|
|
44
|
+
* single-account Phase 3 rollout (2026-06-10) targets the operator's own
|
|
45
|
+
* devices; `xhassaan@getindigo.ai` and `hassaan@getindigo.ai.evil.com` must
|
|
46
|
+
* never match. Broadening later is an entry here (or a domain-set like
|
|
47
|
+
* `PRESIGN_ROLLOUT_DOMAINS` once GA'd).
|
|
48
|
+
*/
|
|
49
|
+
export const EVENT_SYNC_ROLLOUT_EMAILS = new Set([
|
|
50
|
+
"hassaan@getindigo.ai",
|
|
51
|
+
]);
|
|
52
|
+
/**
|
|
53
|
+
* Decide whether this session runs event-driven sync (publish + receive).
|
|
54
|
+
*
|
|
55
|
+
* Mirrors `resolvePresignTransport` precedence: `HQ_SYNC_EVENT_SYNC`
|
|
56
|
+
* overrides in both directions (`1`/`true`/`yes`/`on` → force on,
|
|
57
|
+
* `0`/`false`/`no`/`off` → force off) so unenrolled testers can exercise it
|
|
58
|
+
* and enrolled accounts can be rolled back without a release. An unset/blank
|
|
59
|
+
* override falls through to the exact-email check; an unrecognized override
|
|
60
|
+
* value is ignored (email check wins).
|
|
61
|
+
*/
|
|
62
|
+
export function resolveEventSync(email, override) {
|
|
63
|
+
const o = (override ?? "").trim().toLowerCase();
|
|
64
|
+
if (o === "1" || o === "true" || o === "yes" || o === "on")
|
|
65
|
+
return true;
|
|
66
|
+
if (o === "0" || o === "false" || o === "no" || o === "off")
|
|
67
|
+
return false;
|
|
68
|
+
if (typeof email !== "string")
|
|
69
|
+
return false;
|
|
70
|
+
return EVENT_SYNC_ROLLOUT_EMAILS.has(email.trim().toLowerCase());
|
|
71
|
+
}
|
|
72
|
+
function asNonEmptyString(v, field) {
|
|
73
|
+
if (typeof v !== "string" || v.length === 0) {
|
|
74
|
+
throw new Error(`subscribeSyncReceive: response missing ${field}`);
|
|
75
|
+
}
|
|
76
|
+
return v;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* `POST /v1/sync/subscribe` — provision (idempotently) this device's queue
|
|
80
|
+
* and vend fresh receive credentials. Auth mirrors HttpPushTransport: Bearer
|
|
81
|
+
* token resolved per-call via the supplied source.
|
|
82
|
+
*/
|
|
83
|
+
export async function subscribeSyncReceive(opts) {
|
|
84
|
+
const apiUrl = opts.apiUrl.replace(/\/+$/, "");
|
|
85
|
+
const tok = opts.authToken;
|
|
86
|
+
const token = typeof tok === "function" ? await tok() : tok;
|
|
87
|
+
const fetchImpl = opts.fetchImpl ??
|
|
88
|
+
((input, init) => globalThis.fetch(input, init));
|
|
89
|
+
const controller = new AbortController();
|
|
90
|
+
const timeout = setTimeout(() => controller.abort(), opts.timeoutMs ?? 15_000);
|
|
91
|
+
let res;
|
|
92
|
+
try {
|
|
93
|
+
res = await fetchImpl(`${apiUrl}/v1/sync/subscribe`, {
|
|
94
|
+
method: "POST",
|
|
95
|
+
headers: {
|
|
96
|
+
Authorization: `Bearer ${token}`,
|
|
97
|
+
"Content-Type": "application/json",
|
|
98
|
+
},
|
|
99
|
+
body: JSON.stringify({ deviceId: opts.deviceId }),
|
|
100
|
+
signal: controller.signal,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
clearTimeout(timeout);
|
|
105
|
+
}
|
|
106
|
+
if (!res.ok) {
|
|
107
|
+
const text = await res.text().catch(() => "");
|
|
108
|
+
throw new Error(`subscribeSyncReceive: POST /v1/sync/subscribe failed (${res.status}): ${text.slice(0, 300)}`);
|
|
109
|
+
}
|
|
110
|
+
const parsed = JSON.parse(await res.text());
|
|
111
|
+
const obj = parsed;
|
|
112
|
+
const creds = (obj.credentials ?? {});
|
|
113
|
+
return {
|
|
114
|
+
queueUrl: asNonEmptyString(obj.queueUrl, "queueUrl"),
|
|
115
|
+
region: asNonEmptyString(obj.region, "region"),
|
|
116
|
+
credentials: {
|
|
117
|
+
accessKeyId: asNonEmptyString(creds.accessKeyId, "credentials.accessKeyId"),
|
|
118
|
+
secretAccessKey: asNonEmptyString(creds.secretAccessKey, "credentials.secretAccessKey"),
|
|
119
|
+
sessionToken: asNonEmptyString(creds.sessionToken, "credentials.sessionToken"),
|
|
120
|
+
expiration: asNonEmptyString(creds.expiration, "credentials.expiration"),
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
// ─── SQS SDK adapter ────────────────────────────────────────────────────────
|
|
125
|
+
/**
|
|
126
|
+
* Adapt the AWS SDK `SQSClient` to the receiver's narrow {@link SqsClientLike}
|
|
127
|
+
* seam (the doc-promised `sqsClientFromAwsSdk` from push-receiver.ts). The
|
|
128
|
+
* abort signal is forwarded so `dispose()` can cut a 20s long-poll short.
|
|
129
|
+
*/
|
|
130
|
+
export function sqsClientFromAwsSdk(client) {
|
|
131
|
+
return {
|
|
132
|
+
async receiveMessage({ queueUrl, maxMessages, waitTimeSeconds, signal }) {
|
|
133
|
+
const out = await client.send(new ReceiveMessageCommand({
|
|
134
|
+
QueueUrl: queueUrl,
|
|
135
|
+
MaxNumberOfMessages: maxMessages,
|
|
136
|
+
WaitTimeSeconds: waitTimeSeconds,
|
|
137
|
+
}), { abortSignal: signal });
|
|
138
|
+
return {
|
|
139
|
+
messages: (out.Messages ?? []).map((m) => ({
|
|
140
|
+
Body: m.Body,
|
|
141
|
+
ReceiptHandle: m.ReceiptHandle,
|
|
142
|
+
MessageId: m.MessageId,
|
|
143
|
+
})),
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
async deleteMessage({ queueUrl, receiptHandle }) {
|
|
147
|
+
await client.send(new DeleteMessageCommand({
|
|
148
|
+
QueueUrl: queueUrl,
|
|
149
|
+
ReceiptHandle: receiptHandle,
|
|
150
|
+
}));
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// ─── Refreshing SQS client (credential lifecycle) ───────────────────────────
|
|
155
|
+
/**
|
|
156
|
+
* Error names the SQS SDK surfaces when STS session creds have expired or
|
|
157
|
+
* become invalid. Used for the reactive retry-once path; the proactive
|
|
158
|
+
* skew-window refresh below should make these rare.
|
|
159
|
+
*/
|
|
160
|
+
const EXPIRY_ERROR_NAMES = new Set([
|
|
161
|
+
"ExpiredToken",
|
|
162
|
+
"ExpiredTokenException",
|
|
163
|
+
"InvalidSecurityToken",
|
|
164
|
+
"InvalidClientTokenId",
|
|
165
|
+
"UnrecognizedClientException",
|
|
166
|
+
]);
|
|
167
|
+
function isExpiryError(err) {
|
|
168
|
+
return err instanceof Error && EXPIRY_ERROR_NAMES.has(err.name);
|
|
169
|
+
}
|
|
170
|
+
/** Re-vend this long before the recorded expiry (proactive refresh window). */
|
|
171
|
+
const REFRESH_SKEW_MS = 120_000;
|
|
172
|
+
function defaultBuildSqs(resp) {
|
|
173
|
+
return sqsClientFromAwsSdk(new SQSClient({
|
|
174
|
+
region: resp.region,
|
|
175
|
+
credentials: {
|
|
176
|
+
accessKeyId: resp.credentials.accessKeyId,
|
|
177
|
+
secretAccessKey: resp.credentials.secretAccessKey,
|
|
178
|
+
sessionToken: resp.credentials.sessionToken,
|
|
179
|
+
expiration: new Date(resp.credentials.expiration),
|
|
180
|
+
},
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* An {@link SqsClientLike} that owns the vended-credential lifecycle:
|
|
185
|
+
*
|
|
186
|
+
* - PROACTIVE: before each call, if the recorded expiry is within the skew
|
|
187
|
+
* window, re-subscribe (re-vend) and rebuild the inner client first.
|
|
188
|
+
* - REACTIVE: if a call still fails with an expiry-class error (clock skew,
|
|
189
|
+
* revocation), re-vend once and retry the call once. Anything else — or a
|
|
190
|
+
* second failure — propagates to the receiver's own backoff/reconnect
|
|
191
|
+
* loop, whose retention-backed redelivery makes the miss recoverable.
|
|
192
|
+
*
|
|
193
|
+
* Concurrent refreshes collapse onto one in-flight subscribe promise.
|
|
194
|
+
*/
|
|
195
|
+
export function createRefreshingSqsClient(opts) {
|
|
196
|
+
const now = opts.now ?? (() => Date.now());
|
|
197
|
+
const buildSqs = opts.buildSqs ?? defaultBuildSqs;
|
|
198
|
+
let inner = buildSqs(opts.initial);
|
|
199
|
+
let expiresAtMs = Date.parse(opts.initial.credentials.expiration);
|
|
200
|
+
let refreshing = null;
|
|
201
|
+
const refresh = () => {
|
|
202
|
+
refreshing ??= (async () => {
|
|
203
|
+
try {
|
|
204
|
+
const resp = await opts.subscribe();
|
|
205
|
+
inner = buildSqs(resp);
|
|
206
|
+
expiresAtMs = Date.parse(resp.credentials.expiration);
|
|
207
|
+
}
|
|
208
|
+
finally {
|
|
209
|
+
refreshing = null;
|
|
210
|
+
}
|
|
211
|
+
})();
|
|
212
|
+
return refreshing;
|
|
213
|
+
};
|
|
214
|
+
const ensureFresh = async () => {
|
|
215
|
+
if (Number.isFinite(expiresAtMs) && now() >= expiresAtMs - REFRESH_SKEW_MS) {
|
|
216
|
+
await refresh();
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
const withRetry = async (call) => {
|
|
220
|
+
await ensureFresh();
|
|
221
|
+
try {
|
|
222
|
+
return await call();
|
|
223
|
+
}
|
|
224
|
+
catch (err) {
|
|
225
|
+
if (!isExpiryError(err))
|
|
226
|
+
throw err;
|
|
227
|
+
await refresh();
|
|
228
|
+
return await call();
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
return {
|
|
232
|
+
receiveMessage: (args) => withRetry(() => inner.receiveMessage(args)),
|
|
233
|
+
deleteMessage: (args) => withRetry(() => inner.deleteMessage(args)),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Bring up the publish + receive legs. Returns `null` (poll-only degradation)
|
|
238
|
+
* on ANY startup failure — subscribe 5xx, tenant resolution failure, etc. —
|
|
239
|
+
* after logging the reason. The caller treats `null` as "today's behavior".
|
|
240
|
+
*/
|
|
241
|
+
export async function startEventSync(opts) {
|
|
242
|
+
const log = opts.log ?? ((m) => console.error(m));
|
|
243
|
+
try {
|
|
244
|
+
const tenantId = await opts.resolveTenantId();
|
|
245
|
+
const deviceId = opts.deviceId;
|
|
246
|
+
// ── publish leg (US-017) ──
|
|
247
|
+
const transport = opts.transport ??
|
|
248
|
+
new HttpPushTransport({
|
|
249
|
+
apiUrl: opts.apiUrl,
|
|
250
|
+
pushPath: "/v1/sync/push",
|
|
251
|
+
authToken: opts.authToken,
|
|
252
|
+
});
|
|
253
|
+
await transport.start();
|
|
254
|
+
const emitter = new PushEventEmitter({
|
|
255
|
+
originTenantId: tenantId,
|
|
256
|
+
originDeviceId: deviceId,
|
|
257
|
+
transport,
|
|
258
|
+
// The rollout gate (resolveEventSync) already said yes — the emitter's
|
|
259
|
+
// per-tenant env flag is a server-side convention, not the client gate.
|
|
260
|
+
flagProvider: { isEnabled: () => true },
|
|
261
|
+
// Wall-clock sequence numbers: monotonic per device ACROSS daemon
|
|
262
|
+
// restarts (the emitter's default in-process counter restarts at 0,
|
|
263
|
+
// which would make peers' highest-seq dedupe drop every post-restart
|
|
264
|
+
// event). Receiver dedupe is per-path highest-seq, so ms-epoch values
|
|
265
|
+
// also stay comparable when two devices touch the same path.
|
|
266
|
+
getSequenceNumber: () => (opts.now ?? Date.now)(),
|
|
267
|
+
onError: (err, ctx) => log(`event-sync: publish failed for ${ctx.relativePath ?? "?"}: ${err.message}`),
|
|
268
|
+
});
|
|
269
|
+
// ── receive leg (US-018) ──
|
|
270
|
+
const subscribe = opts.subscribe ??
|
|
271
|
+
((dev) => subscribeSyncReceive({
|
|
272
|
+
apiUrl: opts.apiUrl,
|
|
273
|
+
authToken: opts.authToken,
|
|
274
|
+
deviceId: dev,
|
|
275
|
+
}));
|
|
276
|
+
const initial = await subscribe(deviceId);
|
|
277
|
+
const sqs = createRefreshingSqsClient({
|
|
278
|
+
initial,
|
|
279
|
+
subscribe: () => subscribe(deviceId),
|
|
280
|
+
buildSqs: opts.buildSqs,
|
|
281
|
+
now: opts.now,
|
|
282
|
+
});
|
|
283
|
+
const receiver = new SqsPushReceiver({
|
|
284
|
+
tenantId,
|
|
285
|
+
queueUrl: initial.queueUrl,
|
|
286
|
+
sqs,
|
|
287
|
+
// Self-echo filter: this device's own publishes fan out to its own
|
|
288
|
+
// queue too — pulling them back is wasted work at best and a conflict
|
|
289
|
+
// source at worst. Skip before bridging into the sync engine.
|
|
290
|
+
syncFn: async (ctx) => {
|
|
291
|
+
if (ctx.event.originDeviceId === deviceId)
|
|
292
|
+
return;
|
|
293
|
+
await opts.syncFn(ctx);
|
|
294
|
+
},
|
|
295
|
+
// The client rollout gate is the authority; the env-driven per-tenant
|
|
296
|
+
// flag provider is a server-side convention not set on user machines.
|
|
297
|
+
enabled: true,
|
|
298
|
+
});
|
|
299
|
+
await receiver.start();
|
|
300
|
+
log(`event-sync: live (tenant=${tenantId} device=${deviceId} queue=${initial.queueUrl})`);
|
|
301
|
+
return {
|
|
302
|
+
publishBatch: (batch) => void emitter.emitForBatch(batch),
|
|
303
|
+
receiver,
|
|
304
|
+
ownDeviceId: deviceId,
|
|
305
|
+
dispose: async () => {
|
|
306
|
+
await receiver.dispose().catch(() => undefined);
|
|
307
|
+
await transport.dispose().catch(() => undefined);
|
|
308
|
+
},
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
catch (err) {
|
|
312
|
+
log(`event-sync: startup failed, continuing poll-only: ${err instanceof Error ? err.message : String(err)}`);
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
//# sourceMappingURL=event-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-sync.js","sourceRoot":"","sources":["../../src/sync/event-sync.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAwB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EACL,eAAe,GAIhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGjD,+EAA+E;AAE/E;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC;IACpE,sBAAsB;CACvB,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAyB,EACzB,QAA4B;IAE5B,MAAM,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAChD,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACxE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,OAAO,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC;IAC1E,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,OAAO,yBAAyB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;AACnE,CAAC;AAgCD,SAAS,gB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AE,KAAK,EAAE,GAAG,EAAE,EAAE;gBACpB,IAAI,GAAG,CAAC,KAAK,CAAC,cAAc,KAAK,QAAQ;oBAAE,OAAO;gBAClD,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACzB,CAAC;YACD,sEAAsE;YACtE,sEAAsE;YACtE,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;QACH,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;QAEvB,GAAG,CACD,4BAA4B,QAAQ,WAAW,QAAQ,UAAU,OAAO,CAAC,QAAQ,GAAG,CACrF,CAAC;QAEF,OAAO;YACL,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,KAAK,CAAC;YACzD,QAAQ;YACR,WAAW,EAAE,QAAQ;YACrB,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;gBAChD,MAAM,SAAS,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACnD,CAAC;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,GAAG,CACD,qDAAqD,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACxG,CAAC;QACF,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 3 event-sync tests (US-017/US-018/US-019).
|
|
3
|
+
*
|
|
4
|
+
* - resolveEventSync: exact-email gate semantics + env-override precedence.
|
|
5
|
+
* - subscribeSyncReceive: request shape, response validation, failure surface.
|
|
6
|
+
* - sqsClientFromAwsSdk: command mapping + abort-signal forwarding.
|
|
7
|
+
* - createRefreshingSqsClient: proactive skew refresh, reactive retry-once on
|
|
8
|
+
* expiry-class errors, non-expiry errors propagate, concurrent refresh
|
|
9
|
+
* collapse.
|
|
10
|
+
* - startEventSync: happy-path handle wiring (self-echo filter, publish leg),
|
|
11
|
+
* poll-only degradation on subscribe/tenant failure.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=event-sync.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-sync.test.d.ts","sourceRoot":"","sources":["../../src/sync/event-sync.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|