deepline 0.3.505 → 0.3.507
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/bundling-sources/sdk/src/client-core.ts +148 -11
- package/dist/bundling-sources/sdk/src/index.ts +3 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +2 -0
- package/dist/bundling-sources/shared_libs/monitors/deactivation-reasons.ts +38 -1
- package/dist/bundling-sources/shared_libs/monitors/fleets/issues.ts +176 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +17 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/overview.ts +118 -0
- package/dist/bundling-sources/shared_libs/monitors/fleets/plan.ts +29 -1
- package/dist/bundling-sources/shared_libs/monitors/fleets/verdict.ts +4 -2
- package/dist/bundling-sources/shared_libs/monitors/legacy-radar-retirement.ts +29 -10
- package/dist/bundling-sources/shared_libs/monitors/package.json +6 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-errors.ts +15 -0
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-state.ts +24 -4
- package/dist/bundling-sources/shared_libs/monitors/provider-resource-failure.ts +405 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +8 -8
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +52 -5
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +6 -1
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +48 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +13 -40
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +36 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-egress.ts +55 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +66 -0
- package/dist/cli/auth-6PJ4G5PC.js +43 -0
- package/dist/cli/{auth-AHE2EDQA.mjs → auth-BNP3M27C.mjs} +5 -5
- package/dist/cli/{billing-JOIZPHON.js → billing-7HIVX4YJ.js} +101 -91
- package/dist/cli/{billing-7CPWTGGI.mjs → billing-JKJ2AEZ6.mjs} +27 -17
- package/dist/cli/{chunk-PDLOPF5L.mjs → chunk-2OKEMB5A.mjs} +1 -1
- package/dist/cli/{chunk-HASFFOSU.js → chunk-2ZINJVWW.js} +16 -16
- package/dist/cli/{chunk-MHZAG2ZQ.js → chunk-3D5ZNYYI.js} +93 -60
- package/dist/cli/{chunk-7DDACLMX.js → chunk-56SRWY5F.js} +16 -16
- package/dist/cli/{chunk-QGNNAZ5M.mjs → chunk-5A66OJZD.mjs} +1 -1
- package/dist/cli/{chunk-UZ24SF7N.mjs → chunk-5I2XKXLS.mjs} +5 -5
- package/dist/cli/{chunk-SPN7U3MV.js → chunk-5PXGAA2M.js} +4 -4
- package/dist/cli/{chunk-EMUFF6EU.js → chunk-6AQO5OJ5.js} +7 -7
- package/dist/cli/{chunk-WTQLUULB.js → chunk-76R5I7HR.js} +6 -6
- package/dist/cli/{chunk-OMEDQ77C.mjs → chunk-7TZA6LJI.mjs} +5 -5
- package/dist/cli/{chunk-JVKEZT7L.mjs → chunk-AFSYNOG4.mjs} +22 -1
- package/dist/cli/{chunk-OORPAQVC.js → chunk-AXYLMDU3.js} +8 -8
- package/dist/cli/{chunk-FIQ5UEIF.mjs → chunk-D2T4W5LR.mjs} +2 -2
- package/dist/cli/{chunk-Y52XY56V.js → chunk-E5HGDYU3.js} +41 -41
- package/dist/cli/{chunk-3YEOOXD4.js → chunk-E7YIIEZU.js} +11 -11
- package/dist/cli/{chunk-NARJWXBR.mjs → chunk-EEJLV77L.mjs} +2 -2
- package/dist/cli/{chunk-7DDKLFOY.mjs → chunk-EYZJDHXA.mjs} +3 -3
- package/dist/cli/{chunk-K26YOPDO.js → chunk-GDHLL5EQ.js} +22 -1
- package/dist/cli/{chunk-WTUC5VKB.mjs → chunk-GMRWVXU2.mjs} +2 -2
- package/dist/cli/{chunk-PZN24YQQ.mjs → chunk-H334EFON.mjs} +2 -2
- package/dist/cli/{chunk-RT3HJBIH.mjs → chunk-H6PABDS4.mjs} +10 -10
- package/dist/cli/{chunk-7QLK2GHL.js → chunk-HPZONIDF.js} +5 -5
- package/dist/cli/{chunk-5XT4DZQL.mjs → chunk-IBKWVFWP.mjs} +2 -2
- package/dist/cli/{chunk-45XYW477.js → chunk-ILUZ7IHP.js} +21 -21
- package/dist/cli/{chunk-SHKRL7CW.mjs → chunk-IWZRQ6YW.mjs} +1 -1
- package/dist/cli/{chunk-ACI6CUDX.mjs → chunk-JCE2JNGD.mjs} +78 -45
- package/dist/cli/{chunk-XHPB6RGY.js → chunk-JPN6OBPW.js} +1 -1
- package/dist/cli/{chunk-W6I4N4JN.mjs → chunk-LSONU2E2.mjs} +6 -6
- package/dist/cli/{chunk-VXKWF3AD.js → chunk-MN5HO2PN.js} +9 -9
- package/dist/cli/{chunk-6FEN6VWZ.js → chunk-MQRT5NYP.js} +26 -26
- package/dist/cli/{chunk-52FPW2RD.mjs → chunk-NJRJGXVF.mjs} +2 -2
- package/dist/cli/{chunk-BWAYMJ23.js → chunk-OBATCFZO.js} +91 -48
- package/dist/cli/{chunk-YBIVVAL7.mjs → chunk-OPEJASMJ.mjs} +3 -3
- package/dist/cli/{chunk-GXMNOUHP.js → chunk-QWRSWQ7Z.js} +7 -7
- package/dist/cli/{chunk-GAUNJCXQ.js → chunk-REFT4DMJ.js} +96 -96
- package/dist/cli/{chunk-QYGYVCRI.js → chunk-RFJANXCC.js} +14 -14
- package/dist/cli/{chunk-4OFSAZN6.mjs → chunk-RTLWYERT.mjs} +46 -3
- package/dist/cli/{chunk-CSLLQWAB.mjs → chunk-T6FUNWXX.mjs} +1 -1
- package/dist/cli/{chunk-JA7YBRP4.mjs → chunk-TVR4R2E6.mjs} +1 -1
- package/dist/cli/{chunk-ZLN2B5YA.js → chunk-TZ7APOBM.js} +3 -3
- package/dist/cli/{chunk-JSTKLYYD.js → chunk-V2K34NAO.js} +2 -2
- package/dist/cli/{chunk-WPCF7C6B.js → chunk-V4GGTOCX.js} +3 -3
- package/dist/cli/{chunk-IZYOYXG7.mjs → chunk-VGEBRTHF.mjs} +4 -4
- package/dist/cli/{chunk-OA6U5NVB.mjs → chunk-VQLD5M43.mjs} +5 -5
- package/dist/cli/{chunk-LC4FG34E.js → chunk-WOPWSAGS.js} +53 -53
- package/dist/cli/{chunk-MAFZ64RN.mjs → chunk-WQAHMVBT.mjs} +2 -2
- package/dist/cli/{chunk-IDAE5VDH.js → chunk-WTY2R4R3.js} +5 -5
- package/dist/cli/{chunk-6U3AGJWI.mjs → chunk-XKGNEN4P.mjs} +1 -1
- package/dist/cli/{chunk-7AD565DO.mjs → chunk-YAAJHS6W.mjs} +1 -1
- package/dist/cli/{chunk-CA3SYXCS.js → chunk-ZCNGMQVD.js} +2 -2
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-WTPI6ZON.mjs → csv-LZTQOPP2.mjs} +4 -4
- package/dist/cli/{csv-DZHVIW3G.js → csv-WYJVU5HV.js} +13 -13
- package/dist/cli/{db-NR4PJ6AF.mjs → db-D6XFOQP3.mjs} +6 -6
- package/dist/cli/{db-D7LPPNCC.js → db-UCUXPY7S.js} +27 -27
- package/dist/cli/{describe-NCKAJPUG.mjs → describe-HKL2XK67.mjs} +18 -18
- package/dist/cli/describe-XS4OIASD.js +50 -0
- package/dist/cli/describe-core.d.mts +3 -3
- package/dist/cli/describe-core.d.ts +3 -3
- package/dist/cli/{executions-UQG6LWEN.js → executions-5CF5NM7V.js} +8 -8
- package/dist/cli/{executions-RQVJ4LAB.mjs → executions-AFHYXH73.mjs} +6 -6
- package/dist/cli/{feedback-TCHA67IA.js → feedback-GJAX3JZE.js} +8 -8
- package/dist/cli/{feedback-RD4Y3YQR.mjs → feedback-MLKQ572F.mjs} +4 -4
- package/dist/cli/{git-Z7434B7Y.mjs → git-BMLROZOU.mjs} +5 -5
- package/dist/cli/git-RIXUHRDL.js +25 -0
- package/dist/cli/index.js +145 -149
- package/dist/cli/index.mjs +46 -50
- package/dist/cli/{legacy-noops-23WRA7DH.js → legacy-noops-FHRDF7MC.js} +8 -8
- package/dist/cli/{legacy-noops-LQJU4UIV.mjs → legacy-noops-Y7JSQVLQ.mjs} +5 -5
- package/dist/cli/{monitors-KOWN7M3V.js → monitors-Z6RPIQIH.js} +450 -138
- package/dist/cli/{monitors-Z6VYUZ2W.mjs → monitors-ZEVK3UD7.mjs} +332 -20
- package/dist/cli/{org-UBNRO5XO.mjs → org-PFLVANIN.mjs} +6 -6
- package/dist/cli/{org-2T5K2VP5.js → org-TXJ3RES5.js} +72 -72
- package/dist/cli/{pages-GHPJBVV3.mjs → pages-BKEMQ2J7.mjs} +6 -6
- package/dist/cli/{pages-SRXTU7XO.js → pages-ESKKBK5Y.js} +18 -18
- package/dist/cli/{play-HRQKGTXA.mjs → play-4Z6Z7KVY.mjs} +18 -18
- package/dist/cli/{play-2HMZ57EZ.js → play-AAFOZJKQ.js} +317 -317
- package/dist/cli/{providers-JWJRFRR5.mjs → providers-KYP2UWDV.mjs} +6 -6
- package/dist/cli/{providers-P5O676MZ.js → providers-WEU4UNKY.js} +9 -9
- package/dist/cli/{quickstart-S7NZUQRO.mjs → quickstart-7EUDF4IL.mjs} +4 -4
- package/dist/cli/{quickstart-YCY72TAO.js → quickstart-DXYZCOJY.js} +6 -6
- package/dist/cli/{run-MHLLGF4G.js → run-3YN6P26W.js} +41 -41
- package/dist/cli/{run-QWMRIUIU.mjs → run-MB2R5PQ7.mjs} +23 -23
- package/dist/cli/{search-4BFTQUEP.mjs → search-MIFBESRE.mjs} +8 -8
- package/dist/cli/search-Z7GUKVFE.js +33 -0
- package/dist/cli/{search-output-LIYHDTBP.mjs → search-output-2IR3UA4W.mjs} +4 -4
- package/dist/cli/{search-output-62LBVZHN.js → search-output-NUWL47SR.js} +6 -6
- package/dist/cli/{secrets-KKKHVSOO.js → secrets-6UT6BIDJ.js} +15 -15
- package/dist/cli/{secrets-GW27V77E.mjs → secrets-E6WIYONW.mjs} +6 -6
- package/dist/cli/{sessions-R75LBGIL.mjs → sessions-AP7L6YCL.mjs} +5 -5
- package/dist/cli/{sessions-R3OEINAR.js → sessions-NF2RBXMJ.js} +6 -6
- package/dist/cli/{settings-MQIHAEZN.js → settings-FZWXYP4W.js} +106 -79
- package/dist/cli/{settings-I3AQZSYG.mjs → settings-MMLHJ5E5.mjs} +39 -12
- package/dist/cli/{setup-2YA5MYMS.mjs → setup-WJNN2CZZ.mjs} +10 -10
- package/dist/cli/{setup-X3QRJERP.js → setup-YHXAAJNZ.js} +50 -50
- package/dist/cli/skills-4YYUFNMS.js +37 -0
- package/dist/cli/{skills-7252FOOI.mjs → skills-KXZ5PJU2.mjs} +8 -8
- package/dist/cli/{tools-SKQTSVGE.mjs → tools-K6S7RX7B.mjs} +17 -17
- package/dist/cli/tools-OCYEMMUP.js +57 -0
- package/dist/cli/{update-GNBBSKTB.mjs → update-2SFWEVM6.mjs} +10 -10
- package/dist/cli/update-WQIPUQ4K.js +35 -0
- package/dist/cli/{workflow-OJSAL5FO.mjs → workflow-IR3RCVHZ.mjs} +7 -7
- package/dist/cli/{workflow-QB7YYWPP.js → workflow-SM3Q45X5.js} +17 -17
- package/dist/{client-B3GSaSFn.d.ts → client-BlwD-G4v.d.ts} +1 -1
- package/dist/{client-DEJg0CZn.d.mts → client-DMpsMNH9.d.mts} +1 -1
- package/dist/{client-core-C404E33V.d.mts → client-core-CITtRTbB.d.mts} +77 -11
- package/dist/{client-core-GQmy3N8y.d.ts → client-core-DwBLuEkm.d.ts} +77 -11
- package/dist/{compiler-manifest-DaJrA2KV.d.mts → compiler-manifest-BeURaD5Y.d.mts} +2 -0
- package/dist/{compiler-manifest-DaJrA2KV.d.ts → compiler-manifest-BeURaD5Y.d.ts} +2 -0
- package/dist/{errors-KLga4bLr.d.ts → errors-BoPXPrSy.d.ts} +1 -1
- package/dist/{errors-BKnSYueU.d.mts → errors-kBuT4kGK.d.mts} +1 -1
- package/dist/{index-C5nAZ-VS.d.ts → index-D0crdGM1.d.ts} +1 -1
- package/dist/{index-C-8AFpWy.d.mts → index-DC7oRAAC.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +116 -112
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/play-description.d.mts +2 -2
- package/dist/plays/play-description.d.ts +2 -2
- package/dist/plays/run-request.d.mts +2 -2
- package/dist/plays/run-request.d.ts +2 -2
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.d.mts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-SEPKNRHV.js +0 -43
- package/dist/cli/describe-HVQBTKFM.js +0 -50
- package/dist/cli/git-TUB2ZUEH.js +0 -25
- package/dist/cli/search-QPUHOEIL.js +0 -33
- package/dist/cli/skills-BPZWMZSL.js +0 -37
- package/dist/cli/tools-F7RVQ3IK.js +0 -57
- package/dist/cli/update-TLSY6LC2.js +0 -35
|
@@ -77,6 +77,15 @@ export type FleetPlan = {
|
|
|
77
77
|
removes: number;
|
|
78
78
|
/** Refusals by the limit that caused them, e.g. `{'monitor.watched_entities': 3}`. */
|
|
79
79
|
blocked: Record<string, number>;
|
|
80
|
+
/**
|
|
81
|
+
* Creates, updates and removes for members whose last attempt failed. Each
|
|
82
|
+
* is also counted in `creates`, `updates` or `removes`.
|
|
83
|
+
*/
|
|
84
|
+
retries: number;
|
|
85
|
+
/** Creates for members a limit had blocked and now admits. Included in `creates`. */
|
|
86
|
+
unblocked: number;
|
|
87
|
+
/** Creates for rows the fleet did not own a monitor for. Included in `creates`. */
|
|
88
|
+
newRows: number;
|
|
80
89
|
};
|
|
81
90
|
|
|
82
91
|
export type FleetMembershipMember = {
|
|
@@ -234,6 +243,9 @@ export function planFleetMembers(input: {
|
|
|
234
243
|
let creates = 0;
|
|
235
244
|
let updates = 0;
|
|
236
245
|
let removes = 0;
|
|
246
|
+
let retries = 0;
|
|
247
|
+
let unblocked = 0;
|
|
248
|
+
let newRows = 0;
|
|
237
249
|
|
|
238
250
|
const refuse = (member: PlannedFleetMember, blockedBy: string) => {
|
|
239
251
|
blocked[blockedBy] = (blocked[blockedBy] ?? 0) + 1;
|
|
@@ -270,6 +282,8 @@ export function planFleetMembers(input: {
|
|
|
270
282
|
// rather than needing a second write path that could disagree with it.
|
|
271
283
|
members.push({ ...base, action: 'update', needsSeed: false });
|
|
272
284
|
updates += 1;
|
|
285
|
+
// A failed update keeps its applied hash, so it is retried as an update.
|
|
286
|
+
if (owned?.convergence === 'failed') retries += 1;
|
|
273
287
|
continue;
|
|
274
288
|
}
|
|
275
289
|
|
|
@@ -292,6 +306,10 @@ export function planFleetMembers(input: {
|
|
|
292
306
|
entityCounts.set(entityKey, onEntity + 1);
|
|
293
307
|
members.push(base);
|
|
294
308
|
creates += 1;
|
|
309
|
+
// A failed member never reached the provider, so this create is its retry.
|
|
310
|
+
if (owned?.convergence === 'failed') retries += 1;
|
|
311
|
+
if (owned?.convergence === 'blocked') unblocked += 1;
|
|
312
|
+
if (!owned) newRows += 1;
|
|
295
313
|
}
|
|
296
314
|
|
|
297
315
|
const plannedKeys = new Set(members.map((member) => member.monitorKey));
|
|
@@ -319,7 +337,17 @@ export function planFleetMembers(input: {
|
|
|
319
337
|
});
|
|
320
338
|
plannedKeys.add(owned.monitorKey);
|
|
321
339
|
removes += 1;
|
|
340
|
+
if (owned.convergence === 'failed') retries += 1;
|
|
322
341
|
}
|
|
323
342
|
|
|
324
|
-
return {
|
|
343
|
+
return {
|
|
344
|
+
members,
|
|
345
|
+
creates,
|
|
346
|
+
updates,
|
|
347
|
+
removes,
|
|
348
|
+
blocked,
|
|
349
|
+
retries,
|
|
350
|
+
unblocked,
|
|
351
|
+
newRows,
|
|
352
|
+
};
|
|
325
353
|
}
|
|
@@ -65,11 +65,13 @@ export const FLEET_SETTLED_VERDICTS = [
|
|
|
65
65
|
/**
|
|
66
66
|
* A Fleet's customer state. A Fleet has no `provisioning` state: its first
|
|
67
67
|
* convergence is reported by the durable Fleet operation, while each member
|
|
68
|
-
* monitor still pending its create reports `provisioning` itself.
|
|
68
|
+
* monitor still pending its create reports `provisioning` itself. Nor is a
|
|
69
|
+
* Fleet `errored`: the provider fails one member's resource, and that member
|
|
70
|
+
* reports `errored` itself.
|
|
69
71
|
*/
|
|
70
72
|
export type FleetCustomerState = Exclude<
|
|
71
73
|
ProviderMonitorCustomerState,
|
|
72
|
-
'provisioning'
|
|
74
|
+
'provisioning' | 'errored'
|
|
73
75
|
>;
|
|
74
76
|
|
|
75
77
|
/**
|
|
@@ -63,7 +63,10 @@ export function legacyRadarMonitorTool(radarType: string): string | null {
|
|
|
63
63
|
|
|
64
64
|
export type LegacyExpectedConfig = {
|
|
65
65
|
radar_type: string;
|
|
66
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Contact types only: lowercased LinkedIn `/in/<slug>`, as written. It may
|
|
68
|
+
* still be percent-encoded; the match decodes it like the live URL.
|
|
69
|
+
*/
|
|
67
70
|
profile_slug?: string;
|
|
68
71
|
/** Company types and `contact_job_changes`; optional on social posts. */
|
|
69
72
|
domain?: string;
|
|
@@ -143,13 +146,13 @@ export function parseLegacyExpectedConfig(text: string): LegacyExpectedConfig {
|
|
|
143
146
|
};
|
|
144
147
|
}
|
|
145
148
|
|
|
146
|
-
/**
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
let slug =
|
|
149
|
+
/**
|
|
150
|
+
* A LinkedIn `/in/<slug>` segment percent-decoded, trimmed and lowercased:
|
|
151
|
+
* `Gustav-Witth%C3%B6ft` -> `gustav-witthöft`. Both sides of the match go
|
|
152
|
+
* through it, so an encoded and a decoded spelling of one slug compare equal.
|
|
153
|
+
*/
|
|
154
|
+
export function normalizeLinkedinProfileSlug(raw: string): string | null {
|
|
155
|
+
let slug = raw;
|
|
153
156
|
try {
|
|
154
157
|
slug = decodeURIComponent(slug);
|
|
155
158
|
} catch {
|
|
@@ -159,6 +162,15 @@ export function linkedinProfileSlug(url: unknown): string | null {
|
|
|
159
162
|
return slug || null;
|
|
160
163
|
}
|
|
161
164
|
|
|
165
|
+
/** Normalized `/in/<slug>` of a LinkedIn profile URL, or null. */
|
|
166
|
+
export function linkedinProfileSlug(url: unknown): string | null {
|
|
167
|
+
const text = nonEmptyText(url);
|
|
168
|
+
if (!text) return null;
|
|
169
|
+
const match = /\/in\/([^/?#]+)/i.exec(text);
|
|
170
|
+
if (!match?.[1]) return null;
|
|
171
|
+
return normalizeLinkedinProfileSlug(match[1]);
|
|
172
|
+
}
|
|
173
|
+
|
|
162
174
|
/** Scheme, `www.`, port, path and case removed: `https://WWW.Acme.com/x` -> `acme.com`. */
|
|
163
175
|
export function normalizeRadarDomain(value: unknown): string | null {
|
|
164
176
|
let text = nonEmptyText(value)?.toLowerCase();
|
|
@@ -213,7 +225,8 @@ function stableJson(value: unknown): string {
|
|
|
213
225
|
* Returns null on a match, otherwise the refusal reason.
|
|
214
226
|
*
|
|
215
227
|
* - same `radar_type`;
|
|
216
|
-
* - contact types: the same LinkedIn `/in/<slug
|
|
228
|
+
* - contact types: the same LinkedIn `/in/<slug>`, each side percent-decoded
|
|
229
|
+
* once (`normalizeLinkedinProfileSlug`);
|
|
217
230
|
* - company types and `contact_job_changes`: the same normalized domain;
|
|
218
231
|
* - contact social types: a domain, when expected, may be missing (the one
|
|
219
232
|
* allowed broadening) but never different; an unexpected domain refuses;
|
|
@@ -232,7 +245,13 @@ export function legacyMonitorConfigMismatch(input: {
|
|
|
232
245
|
}
|
|
233
246
|
const contact = isLegacyContactRadarType(expected.radar_type);
|
|
234
247
|
if (contact) {
|
|
235
|
-
|
|
248
|
+
// Decoded here rather than when parsed: sealed approvals store the slug
|
|
249
|
+
// as written, and decoding exactly once keeps `%25` meaning `%`.
|
|
250
|
+
const expectedSlug = expected.profile_slug
|
|
251
|
+
? normalizeLinkedinProfileSlug(expected.profile_slug)
|
|
252
|
+
: null;
|
|
253
|
+
const liveSlug = linkedinProfileSlug(payload.profile_url);
|
|
254
|
+
if (!expectedSlug || liveSlug !== expectedSlug) {
|
|
236
255
|
return 'required_monitor_profile_changed';
|
|
237
256
|
}
|
|
238
257
|
}
|
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
"./deactivation-reasons": "./deactivation-reasons.ts",
|
|
35
35
|
"./deactivation-reasons.js": "./deactivation-reasons.ts",
|
|
36
36
|
"./fleets/errors": "./fleets/errors.ts",
|
|
37
|
+
"./fleets/issues": "./fleets/issues.ts",
|
|
38
|
+
"./fleets/overview": "./fleets/overview.ts",
|
|
39
|
+
"./fleets/overview.js": "./fleets/overview.ts",
|
|
40
|
+
"./fleets/issues.js": "./fleets/issues.ts",
|
|
37
41
|
"./fleets/errors.js": "./fleets/errors.ts",
|
|
38
42
|
"./fleets/plan": "./fleets/plan.ts",
|
|
39
43
|
"./fleets/plan.js": "./fleets/plan.ts",
|
|
@@ -89,6 +93,8 @@
|
|
|
89
93
|
"./provider-monitor-status.js": "./provider-monitor-status.ts",
|
|
90
94
|
"./provider-monitor-upstream-identity": "./provider-monitor-upstream-identity.ts",
|
|
91
95
|
"./provider-monitor-upstream-identity.js": "./provider-monitor-upstream-identity.ts",
|
|
96
|
+
"./provider-resource-failure": "./provider-resource-failure.ts",
|
|
97
|
+
"./provider-resource-failure.js": "./provider-resource-failure.ts",
|
|
92
98
|
"./provider-webhook-monitor-runtime": "./provider-webhook-monitor-runtime.ts",
|
|
93
99
|
"./provider-webhook-monitor-runtime.js": "./provider-webhook-monitor-runtime.ts",
|
|
94
100
|
"./quickstart-prompts": "./quickstart-prompts.ts",
|
|
@@ -130,3 +130,18 @@ export class ProviderMonitorStoppedAfterSubmitError extends Error {
|
|
|
130
130
|
this.name = 'ProviderMonitorStoppedAfterSubmitError';
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The provider failed this monitor's resource and only a payload change fixes
|
|
136
|
+
* it (`errored`, KAR-193). Nothing else may recreate it from the same payload:
|
|
137
|
+
* not a repair (a forced replacement), including one whose batch selected the
|
|
138
|
+
* monitor before the failure webhook landed, and not a priority-only update.
|
|
139
|
+
*/
|
|
140
|
+
export class ProviderMonitorErroredRepairRefusedError extends Error {
|
|
141
|
+
constructor(readonly monitorKey: string) {
|
|
142
|
+
super(
|
|
143
|
+
`Monitor "${monitorKey}" is errored: the provider failed its resource. Change its payload or delete it; only a payload change recreates it.`,
|
|
144
|
+
);
|
|
145
|
+
this.name = 'ProviderMonitorErroredRepairRefusedError';
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isProviderErroredDeactivationReason } from './provider-resource-failure';
|
|
2
|
+
|
|
1
3
|
/** Provider evidence carried only by an exact, fenced terminal deletion. */
|
|
2
4
|
export type ProviderMonitorDeletionObservation = {
|
|
3
5
|
providerResourceId: string;
|
|
@@ -11,6 +13,11 @@ export type ProviderMonitorDeletionObservation = {
|
|
|
11
13
|
* has not yet confirmed that it exists: it does not deliver events or bill
|
|
12
14
|
* until the create commits and the monitor becomes `active`.
|
|
13
15
|
*
|
|
16
|
+
* `errored` means the provider failed the monitor's resource after it was
|
|
17
|
+
* created, in a way recreating the same payload cannot fix (KAR-193). It is a
|
|
18
|
+
* customer state, not operation progress: it lasts until the customer changes
|
|
19
|
+
* the payload or removes the monitor, and the fix is theirs to make.
|
|
20
|
+
*
|
|
14
21
|
* Provider work, retries, and audit evidence intentionally live on separate
|
|
15
22
|
* axes. They must never become additional values in this union.
|
|
16
23
|
*/
|
|
@@ -18,6 +25,7 @@ export type ProviderMonitorCustomerState =
|
|
|
18
25
|
| 'active'
|
|
19
26
|
| 'provisioning'
|
|
20
27
|
| 'billing_suspended'
|
|
28
|
+
| 'errored'
|
|
21
29
|
| 'disabled';
|
|
22
30
|
|
|
23
31
|
/**
|
|
@@ -159,21 +167,32 @@ export function providerMonitorCustomerStateForBillingState(
|
|
|
159
167
|
/**
|
|
160
168
|
* The single public monitor-state projection. A billing suspension owns the
|
|
161
169
|
* off state. A `pending_create` lifecycle is `provisioning`: the create was
|
|
162
|
-
* recorded but the provider has not confirmed the resource.
|
|
163
|
-
*
|
|
170
|
+
* recorded but the provider has not confirmed the resource. A provider-owned
|
|
171
|
+
* deactivation on a live lifecycle is `errored`. Otherwise `active` is
|
|
172
|
+
* operational proof: a committed active lifecycle and a non-empty provider
|
|
164
173
|
* resource binding. Internal billing bookkeeping such as an unresolved usage
|
|
165
174
|
* charge must not make a usable provider resource look disabled.
|
|
175
|
+
*
|
|
176
|
+
* Callers that omit `deactivationReason` never see `errored`; every public
|
|
177
|
+
* list/get projection passes it.
|
|
166
178
|
*/
|
|
167
179
|
export function providerMonitorCustomerState(input: {
|
|
168
180
|
lifecycleStatus?: string | null;
|
|
169
181
|
billingState?: unknown;
|
|
170
182
|
providerResourceId?: string | null | undefined;
|
|
183
|
+
deactivationReason?: string | null | undefined;
|
|
171
184
|
}): ProviderMonitorCustomerState {
|
|
172
185
|
const billingState = providerMonitorCustomerStateForBillingState(
|
|
173
186
|
input.billingState,
|
|
174
187
|
);
|
|
175
188
|
if (billingState === 'billing_suspended') return billingState;
|
|
176
189
|
if (input.lifecycleStatus === 'pending_create') return 'provisioning';
|
|
190
|
+
if (
|
|
191
|
+
input.lifecycleStatus === 'active' &&
|
|
192
|
+
isProviderErroredDeactivationReason(input.deactivationReason)
|
|
193
|
+
) {
|
|
194
|
+
return 'errored';
|
|
195
|
+
}
|
|
177
196
|
|
|
178
197
|
const providerResourceId = providerMonitorResourceId(
|
|
179
198
|
input.providerResourceId,
|
|
@@ -186,8 +205,9 @@ export function providerMonitorCustomerState(input: {
|
|
|
186
205
|
|
|
187
206
|
/**
|
|
188
207
|
* Deprecated compatibility projection for the old `status`/`active` keys. The
|
|
189
|
-
* alias stays two-valued: every non-active state, including `provisioning
|
|
190
|
-
* is `inactive`.
|
|
208
|
+
* alias stays two-valued: every non-active state, including `provisioning`
|
|
209
|
+
* and `errored`, is `inactive`. An installed CLI that predates `errored`
|
|
210
|
+
* falls back to this alias and shows such a monitor as `disabled`.
|
|
191
211
|
*/
|
|
192
212
|
export function providerMonitorStatusAlias(
|
|
193
213
|
state: ProviderMonitorCustomerState,
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider resource failures: the `errored` monitor state (KAR-193).
|
|
3
|
+
*
|
|
4
|
+
* TamRadar can fail a radar hours or days after its create returned success,
|
|
5
|
+
* with a `radar_failure` webhook naming the radar and a reason. Before this
|
|
6
|
+
* module Deepline only refunded the create: the monitor stayed desired-active,
|
|
7
|
+
* the daily global audit saw "active vs inactive" and recreated the radar,
|
|
8
|
+
* TamRadar failed it again, and the loop repeated every day.
|
|
9
|
+
*
|
|
10
|
+
* The rule, decided by Karl on 2026-11-11:
|
|
11
|
+
*
|
|
12
|
+
* - `source_inaccessible` (the profile URL is dead or renamed) errors the
|
|
13
|
+
* monitor at once. Recreating the same URL cannot succeed.
|
|
14
|
+
* - Any other reason gets one automatic recreate. A second failure on the same
|
|
15
|
+
* payload errors the monitor.
|
|
16
|
+
* - An errored monitor stays errored until its payload changes. Changing the
|
|
17
|
+
* payload creates a fresh resource and clears it; resubmitting the same
|
|
18
|
+
* payload does not. Delete removes it. Nothing automatic revives it.
|
|
19
|
+
*
|
|
20
|
+
* The decision is pure so every direction can be driven without Convex. The
|
|
21
|
+
* Convex owner (`providerMonitorRegistry.recordProviderResourceFailure`)
|
|
22
|
+
* applies it, and the inbound processor raises the alerts.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export const TAMRADAR_SOURCE_INACCESSIBLE_REASON = 'source_inaccessible';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Stored when a failure webhook names no reason. Never a known reason, so it
|
|
29
|
+
* always raises the unknown-reason alert.
|
|
30
|
+
*/
|
|
31
|
+
export const UNSPECIFIED_PROVIDER_FAILURE_REASON = 'unspecified';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Every `radar_failure` reason Deepline has seen in Production.
|
|
35
|
+
*
|
|
36
|
+
* A reason outside this set raises a Slack alert each time it arrives, so a
|
|
37
|
+
* new provider failure mode cannot slip through as one more refund. When the
|
|
38
|
+
* alert fires, decide how the reason should be treated and add it here.
|
|
39
|
+
*
|
|
40
|
+
* Evidence (KAR-193 fleet-wide journal scan, 2026-11-11): Prove's 72
|
|
41
|
+
* `contact_social_posts` failures and three August company radars were
|
|
42
|
+
* `source_inaccessible`; one September `company_new_hires` failure was
|
|
43
|
+
* `missing_prerequisites`.
|
|
44
|
+
*/
|
|
45
|
+
export const KNOWN_TAMRADAR_RADAR_FAILURE_REASONS: ReadonlySet<string> =
|
|
46
|
+
new Set([TAMRADAR_SOURCE_INACCESSIBLE_REASON, 'missing_prerequisites']);
|
|
47
|
+
|
|
48
|
+
export function isKnownTamradarRadarFailureReason(reason: string): boolean {
|
|
49
|
+
return KNOWN_TAMRADAR_RADAR_FAILURE_REASONS.has(reason);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The `provider`-owned deactivation reasons that mean `errored`. Declared in
|
|
54
|
+
* `deactivation-reasons.ts`; repeated here, import-free, so the customer state
|
|
55
|
+
* projection can read them without a module cycle. A unit test keeps the two
|
|
56
|
+
* in step.
|
|
57
|
+
*/
|
|
58
|
+
export const PROVIDER_ERRORED_DEACTIVATION_REASON_IDS: ReadonlySet<string> =
|
|
59
|
+
new Set(['provider_source_inaccessible', 'provider_resource_failed']);
|
|
60
|
+
|
|
61
|
+
export function isProviderErroredDeactivationReason(
|
|
62
|
+
id: string | null | undefined,
|
|
63
|
+
): boolean {
|
|
64
|
+
return (
|
|
65
|
+
typeof id === 'string' && PROVIDER_ERRORED_DEACTIVATION_REASON_IDS.has(id)
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Failures on one payload before a non-`source_inaccessible` reason errors. */
|
|
70
|
+
export const PROVIDER_RESOURCE_FAILURES_BEFORE_ERRORED = 2;
|
|
71
|
+
|
|
72
|
+
/** The stored failure record on a monitor definition. */
|
|
73
|
+
export type ProviderResourceFailureRecord = {
|
|
74
|
+
/** The provider's reason code, e.g. `source_inaccessible`. */
|
|
75
|
+
reason: string;
|
|
76
|
+
/** The resource the provider failed. */
|
|
77
|
+
providerResourceId: string;
|
|
78
|
+
/** The provider's id for this failure event (TamRadar `update_id`). */
|
|
79
|
+
providerEventId: string;
|
|
80
|
+
/** The provider's error id, kept for support conversations. */
|
|
81
|
+
errorId?: string;
|
|
82
|
+
failedAt: number;
|
|
83
|
+
/**
|
|
84
|
+
* Failures of resources created from the same payload. A changed payload
|
|
85
|
+
* starts again at 1.
|
|
86
|
+
*/
|
|
87
|
+
failureCount: number;
|
|
88
|
+
/** Fingerprint of the payload the failed resource was created from. */
|
|
89
|
+
payloadFingerprint: string;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type ProviderResourceFailureEvent = {
|
|
93
|
+
reason: string;
|
|
94
|
+
providerResourceId: string;
|
|
95
|
+
providerEventId: string;
|
|
96
|
+
errorId?: string;
|
|
97
|
+
failedAt: number;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type ProviderResourceFailureDecision =
|
|
101
|
+
/** This exact failure event was already recorded. */
|
|
102
|
+
| { kind: 'duplicate' }
|
|
103
|
+
/** Record the failure and let one automatic recreate run. */
|
|
104
|
+
| { kind: 'retry'; failure: ProviderResourceFailureRecord }
|
|
105
|
+
/** Record the failure and move the monitor to `errored`. */
|
|
106
|
+
| {
|
|
107
|
+
kind: 'errored';
|
|
108
|
+
failure: ProviderResourceFailureRecord;
|
|
109
|
+
deactivationReason:
|
|
110
|
+
| 'provider_source_inaccessible'
|
|
111
|
+
| 'provider_resource_failed';
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export function decideProviderResourceFailure(input: {
|
|
115
|
+
previous: ProviderResourceFailureRecord | undefined | null;
|
|
116
|
+
event: ProviderResourceFailureEvent;
|
|
117
|
+
payloadFingerprint: string;
|
|
118
|
+
}): ProviderResourceFailureDecision {
|
|
119
|
+
const { previous, event } = input;
|
|
120
|
+
if (previous && previous.providerEventId === event.providerEventId) {
|
|
121
|
+
return { kind: 'duplicate' };
|
|
122
|
+
}
|
|
123
|
+
const samePayload =
|
|
124
|
+
previous !== null &&
|
|
125
|
+
previous !== undefined &&
|
|
126
|
+
previous.payloadFingerprint === input.payloadFingerprint;
|
|
127
|
+
// A second webhook about a resource already counted is the same failure,
|
|
128
|
+
// not a new one: only a recreate earns another count.
|
|
129
|
+
const failureCount = !samePayload
|
|
130
|
+
? 1
|
|
131
|
+
: previous.providerResourceId === event.providerResourceId
|
|
132
|
+
? previous.failureCount
|
|
133
|
+
: previous.failureCount + 1;
|
|
134
|
+
const failure: ProviderResourceFailureRecord = {
|
|
135
|
+
reason: event.reason,
|
|
136
|
+
providerResourceId: event.providerResourceId,
|
|
137
|
+
providerEventId: event.providerEventId,
|
|
138
|
+
...(event.errorId ? { errorId: event.errorId } : {}),
|
|
139
|
+
failedAt: event.failedAt,
|
|
140
|
+
failureCount,
|
|
141
|
+
payloadFingerprint: input.payloadFingerprint,
|
|
142
|
+
};
|
|
143
|
+
if (event.reason === TAMRADAR_SOURCE_INACCESSIBLE_REASON) {
|
|
144
|
+
return {
|
|
145
|
+
kind: 'errored',
|
|
146
|
+
failure,
|
|
147
|
+
deactivationReason: 'provider_source_inaccessible',
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (failureCount >= PROVIDER_RESOURCE_FAILURES_BEFORE_ERRORED) {
|
|
151
|
+
return {
|
|
152
|
+
kind: 'errored',
|
|
153
|
+
failure,
|
|
154
|
+
deactivationReason: 'provider_resource_failed',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return { kind: 'retry', failure };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* True when a payload being committed with a fresh resource differs from the
|
|
162
|
+
* one the recorded failure was created from. That is the customer's fix: it
|
|
163
|
+
* clears `errored` and the failure count.
|
|
164
|
+
*/
|
|
165
|
+
export function providerResourceFailureClearedByPayload(input: {
|
|
166
|
+
failure: Pick<ProviderResourceFailureRecord, 'payloadFingerprint'>;
|
|
167
|
+
payloadFingerprint: string;
|
|
168
|
+
}): boolean {
|
|
169
|
+
return input.failure.payloadFingerprint !== input.payloadFingerprint;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function stableJson(value: unknown): string {
|
|
173
|
+
if (value === null || typeof value !== 'object') {
|
|
174
|
+
return JSON.stringify(value ?? null);
|
|
175
|
+
}
|
|
176
|
+
if (Array.isArray(value)) {
|
|
177
|
+
return `[${value.map((entry) => stableJson(entry)).join(',')}]`;
|
|
178
|
+
}
|
|
179
|
+
return `{${Object.keys(value as Record<string, unknown>)
|
|
180
|
+
.filter((key) => (value as Record<string, unknown>)[key] !== undefined)
|
|
181
|
+
.sort()
|
|
182
|
+
.map(
|
|
183
|
+
(key) =>
|
|
184
|
+
`${JSON.stringify(key)}:${stableJson((value as Record<string, unknown>)[key])}`,
|
|
185
|
+
)
|
|
186
|
+
.join(',')}}`;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* SHA-256 of the payload's stable JSON. Runs in Convex and in Node, both of
|
|
191
|
+
* which provide Web Crypto.
|
|
192
|
+
*/
|
|
193
|
+
export async function providerMonitorPayloadFingerprint(
|
|
194
|
+
payload: unknown,
|
|
195
|
+
): Promise<string> {
|
|
196
|
+
const digest = await crypto.subtle.digest(
|
|
197
|
+
'SHA-256',
|
|
198
|
+
new TextEncoder().encode(stableJson(payload ?? {})),
|
|
199
|
+
);
|
|
200
|
+
return Array.from(new Uint8Array(digest), (byte) =>
|
|
201
|
+
byte.toString(16).padStart(2, '0'),
|
|
202
|
+
).join('');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The customer-facing fix prompt for an errored monitor. The wording is
|
|
207
|
+
* Karl's (KAR-193), with "the provider" where he wrote the upstream's name:
|
|
208
|
+
* customers and agents only ever see `deepline_native`
|
|
209
|
+
* (`scripts/check-deepline-native-no-tamradar-leak.ts` scans these strings).
|
|
210
|
+
* A contact radar watches a LinkedIn profile URL, which is what
|
|
211
|
+
* `source_inaccessible` means for it; a company radar's source is not a
|
|
212
|
+
* LinkedIn URL, so it gets the same instruction without that claim.
|
|
213
|
+
*/
|
|
214
|
+
export function providerResourceFailureMessage(input: {
|
|
215
|
+
reason: string;
|
|
216
|
+
sourceCapability?: string | null;
|
|
217
|
+
}): string {
|
|
218
|
+
if (input.reason === TAMRADAR_SOURCE_INACCESSIBLE_REASON) {
|
|
219
|
+
return input.sourceCapability?.startsWith('contact_')
|
|
220
|
+
? "This LinkedIn URL no longer resolves (the provider could not reach it). Update the monitor with the person's current URL, or remove it."
|
|
221
|
+
: 'The provider could not reach the source this monitor watches (reason: source_inaccessible). Update the monitor with a source that resolves, or remove it.';
|
|
222
|
+
}
|
|
223
|
+
return `The provider could not run this monitor (reason: ${input.reason}). Update or remove the monitor.`;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* The public shape of a failure on `monitors list/get` (snake_case API). It
|
|
228
|
+
* never names the provider resource id: the customer API exposes Deepline's
|
|
229
|
+
* own identities, not upstream ones.
|
|
230
|
+
*/
|
|
231
|
+
export type ProviderMonitorFailureSummary = {
|
|
232
|
+
reason: string;
|
|
233
|
+
message: string;
|
|
234
|
+
failed_at: string;
|
|
235
|
+
failure_count: number;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export function providerMonitorFailureSummary(input: {
|
|
239
|
+
failure: ProviderResourceFailureRecord;
|
|
240
|
+
sourceCapability?: string | null;
|
|
241
|
+
}): ProviderMonitorFailureSummary {
|
|
242
|
+
return {
|
|
243
|
+
reason: input.failure.reason,
|
|
244
|
+
message: providerResourceFailureMessage({
|
|
245
|
+
reason: input.failure.reason,
|
|
246
|
+
sourceCapability: input.sourceCapability,
|
|
247
|
+
}),
|
|
248
|
+
failed_at: new Date(input.failure.failedAt).toISOString(),
|
|
249
|
+
failure_count: input.failure.failureCount,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Read a stored record defensively; null when absent or malformed. */
|
|
254
|
+
export function parseProviderResourceFailureRecord(
|
|
255
|
+
value: unknown,
|
|
256
|
+
): ProviderResourceFailureRecord | null {
|
|
257
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) return null;
|
|
258
|
+
const row = value as Record<string, unknown>;
|
|
259
|
+
const text = (key: string) =>
|
|
260
|
+
typeof row[key] === 'string' && (row[key] as string).trim()
|
|
261
|
+
? (row[key] as string)
|
|
262
|
+
: null;
|
|
263
|
+
const reason = text('reason');
|
|
264
|
+
const providerResourceId = text('providerResourceId');
|
|
265
|
+
const providerEventId = text('providerEventId');
|
|
266
|
+
const payloadFingerprint = text('payloadFingerprint');
|
|
267
|
+
const failedAt = row.failedAt;
|
|
268
|
+
const failureCount = row.failureCount;
|
|
269
|
+
if (
|
|
270
|
+
!reason ||
|
|
271
|
+
!providerResourceId ||
|
|
272
|
+
!providerEventId ||
|
|
273
|
+
!payloadFingerprint ||
|
|
274
|
+
typeof failedAt !== 'number' ||
|
|
275
|
+
!Number.isFinite(failedAt) ||
|
|
276
|
+
typeof failureCount !== 'number' ||
|
|
277
|
+
!Number.isInteger(failureCount) ||
|
|
278
|
+
failureCount < 1
|
|
279
|
+
) {
|
|
280
|
+
return null;
|
|
281
|
+
}
|
|
282
|
+
const errorId = text('errorId');
|
|
283
|
+
return {
|
|
284
|
+
reason,
|
|
285
|
+
providerResourceId,
|
|
286
|
+
providerEventId,
|
|
287
|
+
...(errorId ? { errorId } : {}),
|
|
288
|
+
failedAt,
|
|
289
|
+
failureCount,
|
|
290
|
+
payloadFingerprint,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* The Slack alert a recorded failure raises, or null for none.
|
|
296
|
+
*
|
|
297
|
+
* Two things must never pass silently (KAR-193): a monitor going `errored`,
|
|
298
|
+
* and a failure reason Deepline has not classified. A first failure with a
|
|
299
|
+
* known, retryable reason is the automatic recreate working as designed and
|
|
300
|
+
* raises nothing; its second failure errors the monitor and alerts then.
|
|
301
|
+
* A redelivered event alerts nothing the first delivery did not.
|
|
302
|
+
*/
|
|
303
|
+
export function providerResourceFailureAlert(input: {
|
|
304
|
+
outcome: string;
|
|
305
|
+
reason: string;
|
|
306
|
+
providerResourceId: string;
|
|
307
|
+
failureCount?: number | null;
|
|
308
|
+
errorId?: string | null;
|
|
309
|
+
sourceCapability?: string | null;
|
|
310
|
+
}): { reason: string; detail: string } | null {
|
|
311
|
+
if (input.outcome === 'duplicate') return null;
|
|
312
|
+
const unknownReason = !isKnownTamradarRadarFailureReason(input.reason);
|
|
313
|
+
const errored = input.outcome === 'errored';
|
|
314
|
+
if (!errored && !unknownReason) return null;
|
|
315
|
+
const parts = [
|
|
316
|
+
`radar_failure reason=${input.reason} on radar ${input.providerResourceId}`,
|
|
317
|
+
`outcome=${input.outcome}`,
|
|
318
|
+
...(input.failureCount ? [`failure ${input.failureCount}`] : []),
|
|
319
|
+
...(input.errorId ? [`error_id=${input.errorId}`] : []),
|
|
320
|
+
];
|
|
321
|
+
if (unknownReason) {
|
|
322
|
+
parts.push(
|
|
323
|
+
`Deepline has never classified reason '${input.reason}': decide how it should be treated and add it to the known radar failure reasons in packages/monitors/provider-resource-failure.ts`,
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
if (errored) {
|
|
327
|
+
parts.push(
|
|
328
|
+
`Customer sees: ${providerResourceFailureMessage({
|
|
329
|
+
reason: input.reason,
|
|
330
|
+
sourceCapability: input.sourceCapability,
|
|
331
|
+
})}`,
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
reason: errored
|
|
336
|
+
? unknownReason
|
|
337
|
+
? 'monitor_errored_unknown_provider_failure_reason'
|
|
338
|
+
: 'monitor_errored'
|
|
339
|
+
: 'unknown_provider_failure_reason',
|
|
340
|
+
detail: parts.join(' | '),
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Read the failure facts from an unwrapped TamRadar `radar_failure` payload.
|
|
346
|
+
*
|
|
347
|
+
* Real shape (Prove, 2026-11-11): `{code: 400, status: 'error', message,
|
|
348
|
+
* errors: [{field: 'radar', reason: 'source_inaccessible'}], error_id,
|
|
349
|
+
* update_id, update_type: 'radar_failure', refund_amount_usd,
|
|
350
|
+
* data: {radar_id, radar_type, ...}}`. A payload without `errors[].reason`
|
|
351
|
+
* reads as `unspecified`, which is never a known reason and so alerts.
|
|
352
|
+
*/
|
|
353
|
+
export function readTamradarRadarFailure(payload: Record<string, unknown>): {
|
|
354
|
+
reason: string;
|
|
355
|
+
providerEventId: string | null;
|
|
356
|
+
errorId: string | null;
|
|
357
|
+
radarId: string | null;
|
|
358
|
+
} | null {
|
|
359
|
+
if (payload.update_type !== 'radar_failure') return null;
|
|
360
|
+
const text = (value: unknown) =>
|
|
361
|
+
typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
362
|
+
const errors = Array.isArray(payload.errors) ? payload.errors : [];
|
|
363
|
+
const firstReason = errors
|
|
364
|
+
.map((entry) =>
|
|
365
|
+
entry && typeof entry === 'object'
|
|
366
|
+
? text((entry as Record<string, unknown>).reason)
|
|
367
|
+
: null,
|
|
368
|
+
)
|
|
369
|
+
.find((reason): reason is string => reason !== null);
|
|
370
|
+
const data =
|
|
371
|
+
payload.data && typeof payload.data === 'object'
|
|
372
|
+
? (payload.data as Record<string, unknown>)
|
|
373
|
+
: {};
|
|
374
|
+
return {
|
|
375
|
+
reason: firstReason ?? UNSPECIFIED_PROVIDER_FAILURE_REASON,
|
|
376
|
+
providerEventId: text(payload.update_id) ?? text(payload.event_id),
|
|
377
|
+
errorId: text(payload.error_id),
|
|
378
|
+
radarId: text(data.radar_id),
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* True when Deepline wants a monitor running, the provider holds its resource
|
|
384
|
+
* inactive or missing, and no recorded failure of THAT resource explains it.
|
|
385
|
+
*
|
|
386
|
+
* Repair recreates such a monitor. Before KAR-193 that happened silently;
|
|
387
|
+
* this drift has no webhook behind it, so its cause is unknown and a person
|
|
388
|
+
* should hear about it. A recorded failure of the current resource is the
|
|
389
|
+
* one automatic retry working as designed and is not reported again.
|
|
390
|
+
*/
|
|
391
|
+
export function isUnexplainedProviderDrift(row: {
|
|
392
|
+
desired: 'active' | 'inactive';
|
|
393
|
+
observed?: 'active' | 'inactive' | 'missing' | 'unknown' | null;
|
|
394
|
+
providerResourceId?: string | null;
|
|
395
|
+
providerFailure?: unknown;
|
|
396
|
+
}): boolean {
|
|
397
|
+
if (row.desired !== 'active') return false;
|
|
398
|
+
if (row.observed !== 'inactive' && row.observed !== 'missing') return false;
|
|
399
|
+
const failure = parseProviderResourceFailureRecord(row.providerFailure);
|
|
400
|
+
return (
|
|
401
|
+
failure === null ||
|
|
402
|
+
!row.providerResourceId ||
|
|
403
|
+
failure.providerResourceId !== row.providerResourceId
|
|
404
|
+
);
|
|
405
|
+
}
|