deepline 0.3.550 → 0.3.551
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/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +22 -0
- package/dist/bundling-sources/shared_libs/integration-contracts/tool-connection.ts +42 -0
- package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +31 -0
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +19 -0
- package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +187 -16
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +70 -19
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +854 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +15 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +6 -2
- package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +43 -0
- package/dist/bundling-sources/shared_libs/product-notifications/billing-sales.ts +1 -0
- package/dist/bundling-sources/shared_libs/product-notifications/catalog.ts +38 -5
- package/dist/bundling-sources/shared_libs/product-notifications/default-policy.ts +1 -1
- package/dist/bundling-sources/shared_libs/product-notifications/events.ts +16 -0
- package/dist/cli/auth-B4PI7GVY.js +43 -0
- package/dist/cli/{auth-UJCAHGZG.mjs → auth-E7BH4GMJ.mjs} +5 -5
- package/dist/cli/{billing-VO2O5O5O.js → billing-DNQAZGX7.js} +99 -99
- package/dist/cli/{billing-RYWMI7JJ.mjs → billing-OXKU462W.mjs} +10 -10
- package/dist/cli/chunk-2RIKOPIM.mjs +9 -0
- package/dist/cli/{chunk-IZCPOX7X.mjs → chunk-2UXDHFSF.mjs} +1 -1
- package/dist/cli/{chunk-XYIECA7M.js → chunk-2WFPHBR4.js} +30 -8
- package/dist/cli/{chunk-JYUIIDZO.js → chunk-2ZYRBMQM.js} +23 -22
- package/dist/cli/{chunk-TB3WT76F.js → chunk-3G6QZACZ.js} +23 -20
- package/dist/cli/{chunk-LWHWMU4V.js → chunk-3KYBDAR3.js} +7 -7
- package/dist/cli/{chunk-CIBQVA6V.mjs → chunk-3T65J5RG.mjs} +2 -2
- package/dist/cli/{chunk-KSUTNW3X.js → chunk-44I675YK.js} +42 -41
- package/dist/cli/{chunk-4NQWUUOH.mjs → chunk-44KSACJW.mjs} +2 -2
- package/dist/cli/{chunk-GVW5V562.mjs → chunk-4D3WIZST.mjs} +1 -1
- package/dist/cli/{chunk-RS6ZSKX6.js → chunk-4OMAGJ6U.js} +2 -2
- package/dist/cli/{chunk-SZNX3XU3.js → chunk-54EEYLTF.js} +3 -3
- package/dist/cli/{chunk-QD2KT7II.mjs → chunk-5IL7SC45.mjs} +2 -2
- package/dist/cli/{chunk-COHCKZQK.mjs → chunk-5S6PHKRV.mjs} +2 -1
- package/dist/cli/{chunk-SBNNK73L.js → chunk-5VVSEU67.js} +6 -6
- package/dist/cli/{chunk-ZQZOYGDC.mjs → chunk-6PWJKMFQ.mjs} +5 -4
- package/dist/cli/{chunk-MAE3AKDR.mjs → chunk-7DOQ3OEX.mjs} +17 -8
- package/dist/cli/{chunk-3W44AJOE.js → chunk-7RSIFA72.js} +18 -16
- package/dist/cli/{chunk-F2RXBNT5.mjs → chunk-7WQNWJQW.mjs} +7 -5
- package/dist/cli/{chunk-6P7TGCHQ.mjs → chunk-BGBJV26E.mjs} +10 -3
- package/dist/cli/{chunk-UL7HWZO7.mjs → chunk-BIIJATTX.mjs} +2 -2
- package/dist/cli/{chunk-ADWMIZCB.js → chunk-C4CUZH57.js} +20 -11
- package/dist/cli/{chunk-S6XOKGBF.mjs → chunk-CLRAANWH.mjs} +1 -1
- package/dist/cli/{chunk-YSYOQYZE.js → chunk-COGREZAO.js} +48 -44
- package/dist/cli/{chunk-SMLWC7PM.js → chunk-CQ6JYQSW.js} +10 -10
- package/dist/cli/{chunk-7BWMCVYU.mjs → chunk-D6M5HFBB.mjs} +1 -1
- package/dist/cli/{chunk-FMXLQHM2.mjs → chunk-E64HFB4L.mjs} +13 -13
- package/dist/cli/{chunk-E2QVWDDW.mjs → chunk-FOTGUFVK.mjs} +3 -3
- package/dist/cli/{chunk-HCFH2V27.mjs → chunk-GGB3JYCW.mjs} +3 -2
- package/dist/cli/{chunk-7AOFSZJM.mjs → chunk-GGGAEVCX.mjs} +23 -1
- package/dist/cli/{chunk-N2Y2IGNB.mjs → chunk-GVYLCCKN.mjs} +1 -1
- package/dist/cli/{chunk-UV4RU2TE.js → chunk-H4ALLC2X.js} +2 -0
- package/dist/cli/{chunk-LUULRAQB.mjs → chunk-HEHVGEZV.mjs} +10 -7
- package/dist/cli/{chunk-HEVUFICQ.mjs → chunk-I4VKGNAQ.mjs} +9 -5
- package/dist/cli/{chunk-RKF263LR.js → chunk-KWSH5T7K.js} +25 -18
- package/dist/cli/{chunk-XKE2PGZ2.js → chunk-LPJPCGT3.js} +8 -8
- package/dist/cli/{chunk-E4S7OE7B.mjs → chunk-MNSTCJMX.mjs} +3 -3
- package/dist/cli/{chunk-QNWNR6DG.js → chunk-MR5LTVHD.js} +53 -53
- package/dist/cli/{chunk-K7JZV4QW.mjs → chunk-MXGA6JFI.mjs} +2 -2
- package/dist/cli/{chunk-EU23QOJ6.js → chunk-NMWGZD6Y.js} +26 -26
- package/dist/cli/{chunk-MJDQZYKO.js → chunk-PACD5DGC.js} +4 -4
- package/dist/cli/{chunk-EMPXPEIQ.mjs → chunk-PM7MO62Y.mjs} +3 -3
- package/dist/cli/{chunk-JKLDCFY5.js → chunk-POLUE7D5.js} +11 -11
- package/dist/cli/{chunk-DGUTBLXF.js → chunk-PPSDCN6C.js} +3 -2
- package/dist/cli/{chunk-NM3AYEDI.js → chunk-QM6Y6S4E.js} +5 -5
- package/dist/cli/{chunk-2AKS64KJ.mjs → chunk-RE5MJBEV.mjs} +2 -2
- package/dist/cli/{chunk-KLQILE2I.mjs → chunk-S7IZWGUA.mjs} +2 -2
- package/dist/cli/{chunk-2IW5GKB4.js → chunk-T2B5BVZE.js} +13 -13
- package/dist/cli/{chunk-OKNOQRQ3.js → chunk-UDXULACQ.js} +3 -3
- package/dist/cli/{chunk-ECWOIXAV.js → chunk-UPMRIVZB.js} +14 -12
- package/dist/cli/{chunk-72NXIFOT.mjs → chunk-V6SCP4B7.mjs} +1 -1
- package/dist/cli/{chunk-5J3TRWTB.js → chunk-VTGG2RT3.js} +1 -1
- package/dist/cli/{chunk-DJWM5OOY.mjs → chunk-VWLHRZFG.mjs} +4 -4
- package/dist/cli/{chunk-I62PCYU6.js → chunk-W2ZWQUHT.js} +2 -2
- package/dist/cli/{chunk-MXEYNRTZ.mjs → chunk-W425ERWN.mjs} +6 -5
- package/dist/cli/{chunk-GWNYLIF7.mjs → chunk-WEHCBH5R.mjs} +4 -2
- package/dist/cli/{chunk-JLFOQRWM.js → chunk-WKBHUB6R.js} +270 -270
- package/dist/cli/{chunk-3WG2GURT.js → chunk-XYE5XPGF.js} +9 -9
- package/dist/cli/{chunk-R5CYKRA2.js → chunk-Z2FIOG3V.js} +12 -12
- package/dist/cli/{chunk-BJO7ZXAK.js → chunk-ZCDKE4UH.js} +5 -5
- package/dist/cli/{chunk-RINUMR6C.js → chunk-ZDQFBJPO.js} +20 -19
- package/dist/cli/{chunk-TL3WIXDH.mjs → chunk-ZMNGZ6XS.mjs} +1 -1
- package/dist/cli/command-docs.js +3 -3
- package/dist/cli/command-docs.mjs +2 -2
- package/dist/cli/{concurrent-runs-help-766HVJR3.mjs → concurrent-runs-help-C6L6I5OR.mjs} +7 -7
- package/dist/cli/concurrent-runs-help-JEFQZTJI.js +21 -0
- package/dist/cli/{csv-4DZKGYCU.js → csv-QMF4FWE7.js} +19 -14
- package/dist/cli/{csv-VU52KZOX.mjs → csv-SYSDXFEM.mjs} +10 -5
- package/dist/cli/{db-UBGW373S.mjs → db-Q7HURWRZ.mjs} +6 -6
- package/dist/cli/{db-KPIH4HPW.js → db-YSHPPA4H.js} +27 -27
- package/dist/cli/describe-PXTSBJTL.js +50 -0
- package/dist/cli/{describe-NGITP6RA.mjs → describe-YGMQBV44.mjs} +21 -21
- package/dist/cli/describe-core.d.mts +4 -2
- package/dist/cli/describe-core.d.ts +4 -2
- package/dist/cli/describe-core.js +4 -4
- package/dist/cli/describe-core.mjs +3 -3
- package/dist/cli/{executions-CO5UF3CV.mjs → executions-G7U3VUXN.mjs} +6 -6
- package/dist/cli/{executions-G3X25U3V.js → executions-MWBC5TAW.js} +8 -8
- package/dist/cli/{feedback-M2L5DVN2.mjs → feedback-GMHIFLBJ.mjs} +6 -6
- package/dist/cli/{feedback-ZYF65WPH.js → feedback-SD55OY6H.js} +14 -14
- package/dist/cli/{git-AYJD5CLS.mjs → git-HPE45OPD.mjs} +5 -5
- package/dist/cli/git-I3JV7IGH.js +25 -0
- package/dist/cli/index.js +147 -147
- package/dist/cli/index.mjs +46 -46
- package/dist/cli/{integrations-LKEGGTZO.mjs → integrations-2W4MGIQR.mjs} +7 -7
- package/dist/cli/{integrations-GSXXJ4CF.js → integrations-HFKVBY6G.js} +15 -15
- package/dist/cli/{legacy-noops-UF4GKMD4.mjs → legacy-noops-GZYKNU2Z.mjs} +6 -6
- package/dist/cli/{legacy-noops-MZDLLEKN.js → legacy-noops-SXVNDEXN.js} +9 -9
- package/dist/cli/{mcp-NHQ6RMBP.mjs → mcp-BWA6KULG.mjs} +4 -4
- package/dist/cli/{mcp-RTNC6LP3.js → mcp-PJRHQHHU.js} +24 -24
- package/dist/cli/{monitors-WMWB6EKQ.js → monitors-K2WSI6CR.js} +100 -100
- package/dist/cli/{monitors-NC4ZR5DH.mjs → monitors-SYQKCATO.mjs} +7 -7
- package/dist/cli/{org-ZXUSYREQ.mjs → org-5KD7X7IA.mjs} +6 -6
- package/dist/cli/{org-33Q7CXJB.js → org-YQ2CR32B.js} +88 -88
- package/dist/cli/{play-N24XV6TI.js → play-SZXY2F2S.js} +330 -330
- package/dist/cli/{play-IPWFGNRE.mjs → play-TTMABJEI.mjs} +18 -18
- package/dist/cli/{providers-MSVE7UZS.mjs → providers-GQIOMRQO.mjs} +6 -6
- package/dist/cli/{providers-AUI7MMQS.js → providers-YDHCTZAF.js} +9 -9
- package/dist/cli/{quickstart-PSC6VTRI.js → quickstart-BNYOXQXG.js} +6 -6
- package/dist/cli/{quickstart-OME5XMW5.mjs → quickstart-PHSSMKCA.mjs} +4 -4
- package/dist/cli/{run-EYTT2DHO.mjs → run-74C3C75C.mjs} +26 -26
- package/dist/cli/{run-UTIX7CJY.js → run-GFIAZXVL.js} +47 -47
- package/dist/cli/search-2RRRF4LW.js +32 -0
- package/dist/cli/{search-FVE7PM72.mjs → search-3SWUB7KX.mjs} +7 -7
- package/dist/cli/{search-output-O463JNLR.js → search-output-6JF3S4TP.js} +43 -13
- package/dist/cli/{search-output-TQMY6BDG.mjs → search-output-K2SWHVHQ.mjs} +40 -10
- package/dist/cli/{secrets-KCJJAHQB.mjs → secrets-2M4XWEKE.mjs} +6 -6
- package/dist/cli/{secrets-TWZ2GO73.js → secrets-2SAKLH2H.js} +15 -15
- package/dist/cli/{sessions-ZCWAA7QL.mjs → sessions-A64BCXTO.mjs} +6 -6
- package/dist/cli/sessions-SBH27JNW.js +22 -0
- package/dist/cli/{settings-SCR654U7.js → settings-HV64WIJF.js} +85 -85
- package/dist/cli/{settings-4JFKCKII.mjs → settings-SVGEC3FI.mjs} +12 -12
- package/dist/cli/{setup-Q2YOPGOI.mjs → setup-EDC3NEJ3.mjs} +15 -10
- package/dist/cli/{setup-O6GH3UWT.js → setup-FHXOLQGQ.js} +55 -50
- package/dist/cli/{skills-QHPZ6H2G.mjs → skills-3HGHZMXB.mjs} +7 -7
- package/dist/cli/skills-Y3SRLOYD.js +36 -0
- package/dist/cli/tools-OFYPUPUV.js +57 -0
- package/dist/cli/{tools-YO22H46E.mjs → tools-P2QS6A6Q.mjs} +19 -19
- package/dist/cli/{update-WHBC5IHE.mjs → update-552BYQM4.mjs} +9 -9
- package/dist/cli/update-SOUSCLB7.js +34 -0
- package/dist/cli/{views-XNLXV2BT.mjs → views-LD5HXJYY.mjs} +6 -6
- package/dist/cli/{views-4CZJ5BLG.js → views-PA25NAE3.js} +21 -21
- package/dist/cli/{workflow-C4VBARIE.js → workflow-FIDBUQV6.js} +17 -17
- package/dist/cli/{workflow-QUWP2CG2.mjs → workflow-LDYFGBYP.mjs} +7 -7
- package/dist/{client-BEJqhQAj.d.mts → client-DuDFiJDU.d.mts} +1 -1
- package/dist/{client-core-BPYuWfBC.d.ts → client-core-CJRzLanv.d.ts} +93 -4
- package/dist/{client-core-BqetRxx-.d.mts → client-core-DydMQOft.d.mts} +93 -4
- package/dist/{client-Ceo295L2.d.ts → client-t9HZAkFD.d.ts} +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +124 -124
- package/dist/plays/play-description.d.mts +1 -1
- package/dist/plays/play-description.d.ts +1 -1
- package/dist/plays/run-request.d.mts +1 -1
- package/dist/plays/run-request.d.ts +1 -1
- 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 +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-J4OW5RNJ.js +0 -43
- package/dist/cli/chunk-NIPLY25A.mjs +0 -7
- package/dist/cli/concurrent-runs-help-3XZIHVRP.js +0 -21
- package/dist/cli/describe-4BI6E2CM.js +0 -50
- package/dist/cli/git-QRZP4DNA.js +0 -25
- package/dist/cli/search-CQ6JG2EN.js +0 -32
- package/dist/cli/sessions-LMPXUPUH.js +0 -22
- package/dist/cli/skills-M4CFE65Z.js +0 -36
- package/dist/cli/tools-CV7XA2V6.js +0 -57
- package/dist/cli/update-PUWBKPWJ.js +0 -34
|
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
|
|
|
205
205
|
// getters keep their established compatibility behavior.
|
|
206
206
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
207
207
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
208
|
-
version: '0.3.
|
|
208
|
+
version: '0.3.551',
|
|
209
209
|
updateSummary: {
|
|
210
210
|
introducedIn: '0.3.90',
|
|
211
211
|
summary:
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ToolDiscoveryAuth,
|
|
3
|
+
ToolDiscoveryUsage,
|
|
4
|
+
} from '../../shared_libs/integration-contracts/tool-connection';
|
|
1
5
|
import type {
|
|
2
6
|
TerminalRuntimePerformance,
|
|
3
7
|
TerminalRuntimePerformanceUnavailableReason,
|
|
@@ -252,6 +256,9 @@ export interface ToolCategoryListing {
|
|
|
252
256
|
* schema, examples, pricing, extraction guidance, and execution metadata.
|
|
253
257
|
*/
|
|
254
258
|
export interface ToolDefinition extends ToolExecutionMetadataFields {
|
|
259
|
+
auth?: ToolDiscoveryAuth;
|
|
260
|
+
toolUsage?: ToolDiscoveryUsage;
|
|
261
|
+
describeCommand?: string;
|
|
255
262
|
/** Unique tool identifier used in API calls (e.g. `"dropleads_search_people"`). */
|
|
256
263
|
toolId: string;
|
|
257
264
|
/** Provider that backs this tool (e.g. `"hunter"`, `"dropleads"`, `"test"`). */
|
|
@@ -587,6 +594,9 @@ export interface SearchOptions extends ToolSearchOptions {
|
|
|
587
594
|
|
|
588
595
|
/** One ranked search result; `kind` says which fields accompany it. */
|
|
589
596
|
export interface SearchResultItem {
|
|
597
|
+
auth?: ToolDiscoveryAuth;
|
|
598
|
+
toolUsage?: ToolDiscoveryUsage;
|
|
599
|
+
describeCommand?: string;
|
|
590
600
|
/** Tool id for tools and monitor types, play reference, or `docs/<path>`. */
|
|
591
601
|
id: string;
|
|
592
602
|
kind:
|
|
@@ -645,6 +655,18 @@ export interface ToolSearchResult {
|
|
|
645
655
|
search_terms?: string[];
|
|
646
656
|
/** Search mode used. */
|
|
647
657
|
search_mode?: 'v1' | 'v2';
|
|
658
|
+
/** Scoped result for an exact tool ID, independent of ranked alternatives. */
|
|
659
|
+
exactLookup?: {
|
|
660
|
+
id: string;
|
|
661
|
+
status:
|
|
662
|
+
| 'found'
|
|
663
|
+
| 'catalog_miss'
|
|
664
|
+
| 'outside_search_scope'
|
|
665
|
+
| 'unavailable_in_workspace'
|
|
666
|
+
| 'lookup_unavailable';
|
|
667
|
+
toolId?: string;
|
|
668
|
+
message?: string;
|
|
669
|
+
};
|
|
648
670
|
/** Whether search fell back to category matching. */
|
|
649
671
|
search_fallback_to_category?: boolean;
|
|
650
672
|
/** Query-writing advice when phrasing is unclear, matches are weak, or the search is empty. */
|
|
@@ -11,3 +11,45 @@ export function isToolConnectionName(value: unknown): value is string {
|
|
|
11
11
|
GOOGLE_WORKSPACE_DOMAIN_PATTERN.test(value))
|
|
12
12
|
);
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
export type ToolAuthMode = {
|
|
16
|
+
kind:
|
|
17
|
+
| 'managed'
|
|
18
|
+
| 'oauth'
|
|
19
|
+
| 'personal_oauth'
|
|
20
|
+
| 'user_credentials'
|
|
21
|
+
| 'workspace_oauth'
|
|
22
|
+
| 'workspace_credentials'
|
|
23
|
+
| 'workspace_delegation';
|
|
24
|
+
status:
|
|
25
|
+
| 'available'
|
|
26
|
+
| 'requires_connection'
|
|
27
|
+
| 'requires_permission'
|
|
28
|
+
| 'unavailable'
|
|
29
|
+
| 'unknown';
|
|
30
|
+
setupPath?: string;
|
|
31
|
+
requiredScopes?: string[];
|
|
32
|
+
/** Names and scopes the authenticated caller has permission to use. */
|
|
33
|
+
connections?: Array<{ name: string; verifiedScopes?: string[] }>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type ToolDiscoveryAuth = {
|
|
37
|
+
modes: ToolAuthMode[];
|
|
38
|
+
connectionRequired?: true;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type ToolDiscoveryUsage = {
|
|
42
|
+
effect?: 'read' | 'write' | 'destructive';
|
|
43
|
+
requiredInputs: Array<{ name: string; meaning?: string }>;
|
|
44
|
+
/** Provider-authored example. Replace the sample inputs before executing. */
|
|
45
|
+
example?: {
|
|
46
|
+
cli: string;
|
|
47
|
+
mcp: {
|
|
48
|
+
tool_id: string;
|
|
49
|
+
input: Record<string, unknown>;
|
|
50
|
+
connection?: string;
|
|
51
|
+
confirm_mutation?: true;
|
|
52
|
+
};
|
|
53
|
+
play: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
@@ -61,6 +61,24 @@ function readRecord(value: unknown): Record<string, unknown> | null {
|
|
|
61
61
|
: null;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* The documented 404 bodies: `{ "error": "not found" }`, or a record for the
|
|
66
|
+
* looked-up IP with a network `type` and no company. Any other 404 body, such
|
|
67
|
+
* as a structured route error, is not an answer about this IP.
|
|
68
|
+
*/
|
|
69
|
+
function isSnitcherNoCompanyBody(
|
|
70
|
+
record: Record<string, unknown> | null,
|
|
71
|
+
ip: string,
|
|
72
|
+
) {
|
|
73
|
+
if (!record) return false;
|
|
74
|
+
if (record.error === 'not found') return true;
|
|
75
|
+
return (
|
|
76
|
+
record.ip === ip &&
|
|
77
|
+
typeof record.type === 'string' &&
|
|
78
|
+
readRecord(record.company) === null
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
64
82
|
function readString(value: unknown) {
|
|
65
83
|
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
66
84
|
}
|
|
@@ -241,6 +259,19 @@ export async function findSnitcherIp2Company(
|
|
|
241
259
|
if (response.status === 403)
|
|
242
260
|
return { status: 'quota_exceeded', ip: candidate };
|
|
243
261
|
if (response.status === 429) return { status: 'rate_limited', ip: candidate };
|
|
262
|
+
// Snitcher answers 404 when the IP has no company: an ISP or residential
|
|
263
|
+
// network (`type: "isp"`, `domain: null`) or `{ "error": "not found" }`.
|
|
264
|
+
// That is a definitive answer, so it is cached and never retried. A 404
|
|
265
|
+
// without that JSON body (a gateway or moved path) stays a retryable failure.
|
|
266
|
+
if (response.status === 404 && isSnitcherNoCompanyBody(record, candidate)) {
|
|
267
|
+
return {
|
|
268
|
+
status: 'no_company',
|
|
269
|
+
ip: candidate,
|
|
270
|
+
networkType: readString(record?.type),
|
|
271
|
+
company: null,
|
|
272
|
+
geoIp: readRecord(record?.geoIP),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
244
275
|
if (!response.ok) {
|
|
245
276
|
return {
|
|
246
277
|
status: 'failed',
|
|
@@ -7,6 +7,7 @@ export const VECTOR_POST_DEPLOY_GUIDANCE = {
|
|
|
7
7
|
steps: [
|
|
8
8
|
'In Vector, open the segment named in this monitor setup.',
|
|
9
9
|
'Add a webhook endpoint using {{callback_url}}, then select contact.visited.',
|
|
10
|
+
'Other event types the endpoint subscribes to (company.visited, contact.intent, visitor.identified, contact) are stored too; each row names its event_type.',
|
|
10
11
|
'Enable the webhook action on the segment and send a Vector test event.',
|
|
11
12
|
],
|
|
12
13
|
event_type: 'contact.visited',
|
|
@@ -1971,5 +1971,24 @@
|
|
|
1971
1971
|
"runTimeoutMs": 120000,
|
|
1972
1972
|
"failureAlert": "convex_native_scheduled_function",
|
|
1973
1973
|
"domainReportRequired": true
|
|
1974
|
+
},
|
|
1975
|
+
{
|
|
1976
|
+
"id": "github.warehouse-tool-rollups",
|
|
1977
|
+
"name": "Warehouse Tool Rollups",
|
|
1978
|
+
"workflowEvents": ["workflow_dispatch"],
|
|
1979
|
+
"scheduler": "github_actions",
|
|
1980
|
+
"cadence": "runAfter(successful mirror materialization)",
|
|
1981
|
+
"timezone": "UTC",
|
|
1982
|
+
"source": ".github/workflows/warehouse-tool-rollups.yml",
|
|
1983
|
+
"locator": "workflow_dispatch:",
|
|
1984
|
+
"owner": "data-platform",
|
|
1985
|
+
"criticality": "reporting",
|
|
1986
|
+
"purpose": "Recompute historical tool analytics from raw mirrored usage and atomically publish Search serving snapshots once per UTC cutoff.",
|
|
1987
|
+
"successDefinition": "A source-certified snapshot reconciles and publishes, or the same cutoff already has a complete snapshot. Historical runs retain each daily build without rewinding current serving data.",
|
|
1988
|
+
"failureDefinition": "Source is stale or changes during the read, SQL fails, or a bounded publication fails; the previous serving snapshot remains active.",
|
|
1989
|
+
"startGraceMs": 600000,
|
|
1990
|
+
"runTimeoutMs": 5400000,
|
|
1991
|
+
"failureAlert": "github_workflow_run",
|
|
1992
|
+
"domainReportRequired": true
|
|
1974
1993
|
}
|
|
1975
1994
|
]
|
|
@@ -54,6 +54,8 @@ export type PlayActivityTarget =
|
|
|
54
54
|
limit?: number;
|
|
55
55
|
/** Whether this limit was pinned at launch or read from workspace policy. */
|
|
56
56
|
limitSource?: 'admission' | 'workspace';
|
|
57
|
+
/** Completed capacity wait duration; absent on older observations. */
|
|
58
|
+
waitedMs?: number;
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
export type PlayActivityProgress = {
|
|
@@ -150,7 +150,7 @@ export const DURABLE_RUNS_ROLLOUT = {
|
|
|
150
150
|
* not a scalar, or a placeholder reused without an explicit cast, keeps the
|
|
151
151
|
* multi-trip path. Off: unchanged.
|
|
152
152
|
*/
|
|
153
|
-
rateStateSingleTripTransactions:
|
|
153
|
+
rateStateSingleTripTransactions: true,
|
|
154
154
|
/**
|
|
155
155
|
* Collapse a warm rate-state acquire to as few requests as its transactions
|
|
156
156
|
* allow (needs `rateStateSingleTripTransactions`). The concurrency grant
|
|
@@ -166,7 +166,7 @@ export const DURABLE_RUNS_ROLLOUT = {
|
|
|
166
166
|
* row locks and errors; any statement that cannot be rendered keeps the
|
|
167
167
|
* previous path. Off: unchanged.
|
|
168
168
|
*/
|
|
169
|
-
rateStateCollapsedAcquire:
|
|
169
|
+
rateStateCollapsedAcquire: true,
|
|
170
170
|
/**
|
|
171
171
|
* While a detached runner waits for the park acknowledgement, it issues the
|
|
172
172
|
* read-only startup lookups its static plan names (tool metadata and
|
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts
CHANGED
|
@@ -186,6 +186,9 @@ import {
|
|
|
186
186
|
completePostgresSchedulerComputeBillingSessionBootstrap,
|
|
187
187
|
claimPostgresSchedulerWaitingDetachedAttemptForTerminal,
|
|
188
188
|
deferPostgresSchedulerAttemptForCapacity,
|
|
189
|
+
gatePostgresSchedulerSandboxCapacity,
|
|
190
|
+
sandboxCapacityWaitFallbackSeconds,
|
|
191
|
+
sandboxCapacityWakeEventName,
|
|
189
192
|
deferPostgresSchedulerAttemptForExecutorTokenOutage,
|
|
190
193
|
detachedRunnerCeilingDeadlineMsFromSuspension,
|
|
191
194
|
enqueuePostgresSchedulerSandboxCleanupForAttempt,
|
|
@@ -367,7 +370,10 @@ import {
|
|
|
367
370
|
import { DIRECT_COMPLETED_TERMINAL_CONTRACT } from './terminal-contract';
|
|
368
371
|
import { runnerReadiness } from './runner-push';
|
|
369
372
|
import { runtimeApiBaseUrlFromLaunch } from './runtime-api-origin';
|
|
370
|
-
import {
|
|
373
|
+
import {
|
|
374
|
+
resolvePlayLaunchQueuePolicy,
|
|
375
|
+
shouldTerminalizeSandboxCapacityRejection,
|
|
376
|
+
} from '../launch-source-policy';
|
|
371
377
|
import {
|
|
372
378
|
ABSURD_CANCELLED_DEADLINE_RECONCILE_LIMIT,
|
|
373
379
|
reconcileAbsurdRuntimeCancellations,
|
|
@@ -377,6 +383,7 @@ import {
|
|
|
377
383
|
abandonRuntimeSandboxOperationReservation,
|
|
378
384
|
bindRuntimeSandboxCapacityLease,
|
|
379
385
|
createRuntimeSandboxOperationReservation,
|
|
386
|
+
DEFAULT_PLAY_SANDBOX_CONCURRENCY,
|
|
380
387
|
precheckRuntimeSandboxCapacity,
|
|
381
388
|
readReservedDaytonaCancellationOperation,
|
|
382
389
|
recordDaytonaSandboxCleanupIntent,
|
|
@@ -778,6 +785,15 @@ function isTransientHeartbeatTimeout(error: unknown): boolean {
|
|
|
778
785
|
);
|
|
779
786
|
}
|
|
780
787
|
|
|
788
|
+
function runIdSpreadSeconds(runId: string, spreadSeconds: number): number {
|
|
789
|
+
let hash = 2166136261;
|
|
790
|
+
for (let index = 0; index < runId.length; index += 1) {
|
|
791
|
+
hash ^= runId.charCodeAt(index);
|
|
792
|
+
hash = Math.imul(hash, 16777619);
|
|
793
|
+
}
|
|
794
|
+
return Math.abs(hash) % Math.max(1, Math.floor(spreadSeconds));
|
|
795
|
+
}
|
|
796
|
+
|
|
781
797
|
/**
|
|
782
798
|
* A workspace sandbox-capacity refusal, whether it arrives as the typed class,
|
|
783
799
|
* by name across the provider-backend boundary, or as a generic scheduler
|
|
@@ -825,12 +841,7 @@ export function capacityDeferralSeconds(
|
|
|
825
841
|
Math.ceil(runtimeSchedulerCapacityRetryAfterMs(error) / 1_000),
|
|
826
842
|
);
|
|
827
843
|
// Keep a saturated fleet from waking every parked run in the same second.
|
|
828
|
-
|
|
829
|
-
for (let index = 0; index < runId.length; index += 1) {
|
|
830
|
-
hash ^= runId.charCodeAt(index);
|
|
831
|
-
hash = Math.imul(hash, 16777619);
|
|
832
|
-
}
|
|
833
|
-
return baseSeconds + (Math.abs(hash) % 3);
|
|
844
|
+
return baseSeconds + runIdSpreadSeconds(runId, 3);
|
|
834
845
|
}
|
|
835
846
|
|
|
836
847
|
export async function runWithAbsurdExecutionLeaseHeartbeat<T>(input: {
|
|
@@ -3388,6 +3399,8 @@ async function prepareAbsurdAttempt(input: {
|
|
|
3388
3399
|
options: Pick<PostgresSchedulerOptions, 'schema'>;
|
|
3389
3400
|
runId: string;
|
|
3390
3401
|
queueName: string;
|
|
3402
|
+
/** This task's wait on that sandbox-capacity `seq` timed out. */
|
|
3403
|
+
retireSandboxCapacityWaitSeq?: number;
|
|
3391
3404
|
}) {
|
|
3392
3405
|
return input.deps.runWithClient(
|
|
3393
3406
|
async (client) => {
|
|
@@ -3581,6 +3594,77 @@ async function prepareAbsurdAttempt(input: {
|
|
|
3581
3594
|
);
|
|
3582
3595
|
}
|
|
3583
3596
|
|
|
3597
|
+
if (shouldGateSandboxCapacityBeforeClaim(launch, laneState.status)) {
|
|
3598
|
+
// Like the projection gate above, this runs before an attempt exists:
|
|
3599
|
+
// a full org parks the task on a wake event instead of allocating an
|
|
3600
|
+
// attempt that the in-attempt reservation would refuse.
|
|
3601
|
+
let gate: Awaited<
|
|
3602
|
+
ReturnType<typeof gatePostgresSchedulerSandboxCapacity>
|
|
3603
|
+
> | null = null;
|
|
3604
|
+
try {
|
|
3605
|
+
gate = await gatePostgresSchedulerSandboxCapacity(
|
|
3606
|
+
client,
|
|
3607
|
+
{
|
|
3608
|
+
runId: input.runId,
|
|
3609
|
+
orgId: launch.orgId,
|
|
3610
|
+
entitlementLimit: launch.concurrentRunsLimit ?? null,
|
|
3611
|
+
defaultLimit: DEFAULT_PLAY_SANDBOX_CONCURRENCY,
|
|
3612
|
+
queueName: input.queueName,
|
|
3613
|
+
nowMs: Date.now(),
|
|
3614
|
+
...(input.retireSandboxCapacityWaitSeq !== undefined
|
|
3615
|
+
? { retireSeq: input.retireSandboxCapacityWaitSeq }
|
|
3616
|
+
: {}),
|
|
3617
|
+
},
|
|
3618
|
+
input.options,
|
|
3619
|
+
);
|
|
3620
|
+
} catch (error) {
|
|
3621
|
+
if (isRetryableAttemptPreparationError(error)) throw error;
|
|
3622
|
+
// The gate is advisory. A defect in it must not spend engine
|
|
3623
|
+
// attempts or settle the run; the in-attempt reservation still
|
|
3624
|
+
// enforces the cap.
|
|
3625
|
+
console.error('[runtime.scheduler.sandbox_capacity_gate_failed]', {
|
|
3626
|
+
runId: input.runId,
|
|
3627
|
+
orgId: launch.orgId,
|
|
3628
|
+
error: error instanceof Error ? error.message : String(error),
|
|
3629
|
+
});
|
|
3630
|
+
}
|
|
3631
|
+
if (gate?.kind === 'waiting') {
|
|
3632
|
+
// A burst that started waiting together re-checks spread out.
|
|
3633
|
+
const fallbackSeconds = sandboxCapacityWaitFallbackSeconds(
|
|
3634
|
+
Date.now() - gate.sinceMs,
|
|
3635
|
+
);
|
|
3636
|
+
const delaySeconds =
|
|
3637
|
+
fallbackSeconds +
|
|
3638
|
+
runIdSpreadSeconds(input.runId, fallbackSeconds / 10);
|
|
3639
|
+
console.info('[runtime.scheduler.sandbox_capacity_wait]', {
|
|
3640
|
+
runId: input.runId,
|
|
3641
|
+
orgId: launch.orgId,
|
|
3642
|
+
limit: gate.limit,
|
|
3643
|
+
activeLeases: gate.activeLeases,
|
|
3644
|
+
ahead: gate.ahead,
|
|
3645
|
+
seq: gate.seq,
|
|
3646
|
+
waitedMs: Date.now() - gate.sinceMs,
|
|
3647
|
+
fallbackSeconds: delaySeconds,
|
|
3648
|
+
attemptAllocated: false,
|
|
3649
|
+
});
|
|
3650
|
+
return {
|
|
3651
|
+
kind: 'sandbox_capacity_wait' as const,
|
|
3652
|
+
launch,
|
|
3653
|
+
seq: gate.seq,
|
|
3654
|
+
delaySeconds,
|
|
3655
|
+
};
|
|
3656
|
+
}
|
|
3657
|
+
if (gate?.kind === 'admitted' && gate.waitedMs !== null) {
|
|
3658
|
+
console.info('[runtime.scheduler.sandbox_capacity_admitted]', {
|
|
3659
|
+
runId: input.runId,
|
|
3660
|
+
orgId: launch.orgId,
|
|
3661
|
+
limit: gate.limit,
|
|
3662
|
+
activeLeases: gate.activeLeases,
|
|
3663
|
+
waitedMs: gate.waitedMs,
|
|
3664
|
+
});
|
|
3665
|
+
}
|
|
3666
|
+
}
|
|
3667
|
+
|
|
3584
3668
|
const generation = preparation.nextAttempt;
|
|
3585
3669
|
const leaseToken = randomUUID();
|
|
3586
3670
|
const initialRuntimeResource = isManagedSandboxRuntimeBackend(
|
|
@@ -3618,6 +3702,29 @@ async function prepareAbsurdAttempt(input: {
|
|
|
3618
3702
|
);
|
|
3619
3703
|
}
|
|
3620
3704
|
|
|
3705
|
+
/**
|
|
3706
|
+
* Whether a fresh attempt for this run should first pass the pre-claim
|
|
3707
|
+
* sandbox-capacity gate. Only a queued run on a managed sandbox backend under
|
|
3708
|
+
* enforced capacity takes it. A trigger with a finite capacity wait keeps the
|
|
3709
|
+
* in-attempt rejection that terminalizes it.
|
|
3710
|
+
*/
|
|
3711
|
+
export function shouldGateSandboxCapacityBeforeClaim(
|
|
3712
|
+
launch: Pick<
|
|
3713
|
+
PlaySchedulerSubmitInput,
|
|
3714
|
+
'orgId' | 'runtimeBackend' | 'triggerSource'
|
|
3715
|
+
>,
|
|
3716
|
+
runStatus: string | null | undefined,
|
|
3717
|
+
): boolean {
|
|
3718
|
+
return (
|
|
3719
|
+
runStatus === 'queued' &&
|
|
3720
|
+
Boolean(launch.orgId?.trim()) &&
|
|
3721
|
+
isManagedSandboxRuntimeBackend(launch.runtimeBackend) &&
|
|
3722
|
+
runtimeSandboxCapacityAdmissionMode() === 'enforce' &&
|
|
3723
|
+
resolvePlayLaunchQueuePolicy(launch.triggerSource)
|
|
3724
|
+
.sandboxCapacityMaxWaitSeconds === null
|
|
3725
|
+
);
|
|
3726
|
+
}
|
|
3727
|
+
|
|
3621
3728
|
function isRetryableAttemptPreparationError(error: unknown): boolean {
|
|
3622
3729
|
return (
|
|
3623
3730
|
isConnectionCategoryError(error) ||
|
|
@@ -3641,6 +3748,7 @@ async function prepareAbsurdAttemptForTask(input: {
|
|
|
3641
3748
|
options: Pick<PostgresSchedulerOptions, 'schema'>;
|
|
3642
3749
|
runId: string;
|
|
3643
3750
|
queueName: string;
|
|
3751
|
+
retireSandboxCapacityWaitSeq?: number;
|
|
3644
3752
|
}) {
|
|
3645
3753
|
try {
|
|
3646
3754
|
return await prepareAbsurdAttempt(input);
|
|
@@ -3767,6 +3875,62 @@ async function executeAbsurdAttemptAdapter(
|
|
|
3767
3875
|
throw error;
|
|
3768
3876
|
}
|
|
3769
3877
|
}
|
|
3878
|
+
// The org's sandbox slots are full. No attempt exists and none is
|
|
3879
|
+
// allocated: park on this wait's own event, which a lease release (or an
|
|
3880
|
+
// admitted waiter seeing spare slots) emits, with a long fallback timer.
|
|
3881
|
+
const awaitedSandboxCapacityWaits = new Set<number>();
|
|
3882
|
+
while (prepared.kind === 'sandbox_capacity_wait') {
|
|
3883
|
+
const { seq, delaySeconds } = prepared;
|
|
3884
|
+
if (seq === null || awaitedSandboxCapacityWaits.has(seq)) {
|
|
3885
|
+
// A raced wait start, or a wake that did not advance the wait. Neither
|
|
3886
|
+
// can suspend on a fresh event, so retry through the engine's timer.
|
|
3887
|
+
throw new DeferTask(
|
|
3888
|
+
`Run ${runId} is waiting for a sandbox slot in its workspace.`,
|
|
3889
|
+
seq === null ? 5 : delaySeconds,
|
|
3890
|
+
);
|
|
3891
|
+
}
|
|
3892
|
+
awaitedSandboxCapacityWaits.add(seq);
|
|
3893
|
+
let retireSandboxCapacityWaitSeq: number | undefined;
|
|
3894
|
+
try {
|
|
3895
|
+
await ctx.awaitEvent(sandboxCapacityWakeEventName(runId, seq), {
|
|
3896
|
+
stepName: `sandbox-capacity-wait:${seq}`,
|
|
3897
|
+
timeout: delaySeconds,
|
|
3898
|
+
});
|
|
3899
|
+
} catch (error) {
|
|
3900
|
+
// Absurd's own timeout first: the retryable check below also matches
|
|
3901
|
+
// any error named TimeoutError.
|
|
3902
|
+
if (error instanceof TimeoutError) {
|
|
3903
|
+
retireSandboxCapacityWaitSeq = seq;
|
|
3904
|
+
} else if (isRetryableAttemptPreparationError(error)) {
|
|
3905
|
+
// No attempt exists yet: a database blip must not spend an engine
|
|
3906
|
+
// attempt (the last one settles the run).
|
|
3907
|
+
throw new DeferTask(
|
|
3908
|
+
`Run ${runId} sandbox-capacity wait deferred: ${error instanceof Error ? error.message : String(error)}`,
|
|
3909
|
+
30,
|
|
3910
|
+
);
|
|
3911
|
+
} else {
|
|
3912
|
+
throw error;
|
|
3913
|
+
}
|
|
3914
|
+
}
|
|
3915
|
+
prepared = await prepareAbsurdAttemptForTask({
|
|
3916
|
+
ctx,
|
|
3917
|
+
deps,
|
|
3918
|
+
options,
|
|
3919
|
+
runId,
|
|
3920
|
+
queueName,
|
|
3921
|
+
...(retireSandboxCapacityWaitSeq !== undefined
|
|
3922
|
+
? { retireSandboxCapacityWaitSeq }
|
|
3923
|
+
: {}),
|
|
3924
|
+
});
|
|
3925
|
+
}
|
|
3926
|
+
if (prepared.kind === 'created_projection_pending') {
|
|
3927
|
+
// Preparation checks the projection before capacity, so this is a
|
|
3928
|
+
// projection lost after it was delivered; retry through the engine.
|
|
3929
|
+
throw new DeferTask(
|
|
3930
|
+
`Run ${runId} lost its run-created projection while waiting for a sandbox slot.`,
|
|
3931
|
+
prepared.delaySeconds,
|
|
3932
|
+
);
|
|
3933
|
+
}
|
|
3770
3934
|
if (prepared.kind === 'missing') {
|
|
3771
3935
|
throw new Error(
|
|
3772
3936
|
`absurd runtime worker: no launch row for run ${runId} (schema=${
|
|
@@ -3872,10 +4036,7 @@ async function executeAbsurdAttemptAdapter(
|
|
|
3872
4036
|
// only spares a doomed attempt that work, and throws the same capacity
|
|
3873
4037
|
// error, so deferral and terminalization are unchanged. A failed read
|
|
3874
4038
|
// falls through to the ordinary path.
|
|
3875
|
-
if (
|
|
3876
|
-
isManagedSandboxRuntimeBackend(launch.runtimeBackend) &&
|
|
3877
|
-
launch.orgId
|
|
3878
|
-
) {
|
|
4039
|
+
if (isManagedSandboxRuntimeBackend(launch.runtimeBackend) && launch.orgId) {
|
|
3879
4040
|
const capacityMode = runtimeSandboxCapacityAdmissionMode();
|
|
3880
4041
|
let precheck: Awaited<
|
|
3881
4042
|
ReturnType<typeof precheckRuntimeSandboxCapacity>
|
|
@@ -3897,11 +4058,14 @@ async function executeAbsurdAttemptAdapter(
|
|
|
3897
4058
|
{ runId, phase: 'sandbox_capacity_precheck' },
|
|
3898
4059
|
);
|
|
3899
4060
|
} catch (error) {
|
|
3900
|
-
console.warn(
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
4061
|
+
console.warn(
|
|
4062
|
+
'[absurd-runtime.worker] sandbox_capacity_precheck_failed',
|
|
4063
|
+
{
|
|
4064
|
+
runId,
|
|
4065
|
+
attempt: generation,
|
|
4066
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4067
|
+
},
|
|
4068
|
+
);
|
|
3905
4069
|
}
|
|
3906
4070
|
}
|
|
3907
4071
|
if (precheck?.full) {
|
|
@@ -4203,6 +4367,13 @@ async function executeAbsurdAttemptAdapter(
|
|
|
4203
4367
|
sandboxCapacity: {
|
|
4204
4368
|
limit: error.limit,
|
|
4205
4369
|
nowMs: Date.now(),
|
|
4370
|
+
// The next execution parks at the pre-claim gate.
|
|
4371
|
+
...(shouldGateSandboxCapacityBeforeClaim(
|
|
4372
|
+
executionLaunch,
|
|
4373
|
+
'queued',
|
|
4374
|
+
)
|
|
4375
|
+
? { waitQueueName: queueName }
|
|
4376
|
+
: {}),
|
|
4206
4377
|
},
|
|
4207
4378
|
}
|
|
4208
4379
|
: {}),
|
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts
CHANGED
|
@@ -2014,6 +2014,7 @@ async function collapsedGrantWithConcurrency(
|
|
|
2014
2014
|
const opening = `BEGIN ISOLATION LEVEL READ COMMITTED;\n${RATE_STATE_BOUNDS_SQL}\n${lock};`;
|
|
2015
2015
|
let open = false;
|
|
2016
2016
|
let committed = false;
|
|
2017
|
+
const committedLeaseIds: string[] = [];
|
|
2017
2018
|
const grantClient: PostgresSchedulerQueryClient = {
|
|
2018
2019
|
query: async <Row extends Record<string, unknown>>(
|
|
2019
2020
|
sql: string,
|
|
@@ -2030,13 +2031,23 @@ async function collapsedGrantWithConcurrency(
|
|
|
2030
2031
|
return await client.query<Row>(sql, parameters);
|
|
2031
2032
|
}
|
|
2032
2033
|
open = true;
|
|
2033
|
-
const result =
|
|
2034
|
+
const result = oneRequestRows<Row>(
|
|
2035
|
+
await client.query<Row>(`${opening}\n${grant};\nCOMMIT;`),
|
|
2036
|
+
);
|
|
2034
2037
|
committed = true;
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2038
|
+
const rows = result.rows.filter(
|
|
2039
|
+
(row) => !Object.hasOwn(row, RATE_STATE_SCOPE_LOCK_MARKER),
|
|
2040
|
+
);
|
|
2041
|
+
for (const row of rows) {
|
|
2042
|
+
const leaseIds = (row as { lease_ids?: unknown }).lease_ids;
|
|
2043
|
+
if (!Array.isArray(leaseIds)) continue;
|
|
2044
|
+
for (const leaseId of leaseIds) {
|
|
2045
|
+
if (typeof leaseId === 'string' && leaseId.length > 0) {
|
|
2046
|
+
committedLeaseIds.push(leaseId);
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
return { rows };
|
|
2040
2051
|
},
|
|
2041
2052
|
} as PostgresSchedulerQueryClient;
|
|
2042
2053
|
try {
|
|
@@ -2052,10 +2063,32 @@ async function collapsedGrantWithConcurrency(
|
|
|
2052
2063
|
return outcome;
|
|
2053
2064
|
} catch (error) {
|
|
2054
2065
|
// Same as the multi-trip path. After a committed request this only fails
|
|
2055
|
-
// a post-statement invariant check (lease drift, grant shape)
|
|
2056
|
-
//
|
|
2057
|
-
//
|
|
2058
|
-
if (
|
|
2066
|
+
// a post-statement invariant check (lease drift, grant shape): that grant
|
|
2067
|
+
// has already committed, so give its leases back instead of letting them
|
|
2068
|
+
// hold concurrency slots until their TTL, then fail as before.
|
|
2069
|
+
if (committed) {
|
|
2070
|
+
if (committedLeaseIds.length > 0) {
|
|
2071
|
+
try {
|
|
2072
|
+
await client.query(
|
|
2073
|
+
`DELETE FROM ${concurrencyLeaseTableName(input)}
|
|
2074
|
+
WHERE bucket_id = $1 AND lease_id = ANY($2::text[])`,
|
|
2075
|
+
[input.bucketId, committedLeaseIds],
|
|
2076
|
+
);
|
|
2077
|
+
} catch (releaseError) {
|
|
2078
|
+
console.error(
|
|
2079
|
+
'[rate-state] committed_grant_lease_release_failed',
|
|
2080
|
+
{
|
|
2081
|
+
bucketId: input.bucketId,
|
|
2082
|
+
leases: committedLeaseIds.length,
|
|
2083
|
+
error:
|
|
2084
|
+
releaseError instanceof Error
|
|
2085
|
+
? releaseError.message
|
|
2086
|
+
: String(releaseError),
|
|
2087
|
+
},
|
|
2088
|
+
);
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
} else if (open) {
|
|
2059
2092
|
try {
|
|
2060
2093
|
await client.query('ROLLBACK');
|
|
2061
2094
|
} catch {
|
|
@@ -2082,9 +2115,18 @@ async function boundRateStateTransaction(
|
|
|
2082
2115
|
);
|
|
2083
2116
|
}
|
|
2084
2117
|
|
|
2085
|
-
/**
|
|
2118
|
+
/**
|
|
2119
|
+
* The same transaction-local bounds as {@link boundRateStateTransaction}, plus
|
|
2120
|
+
* a closed-socket check. A one-request transaction is already on the server
|
|
2121
|
+
* when it starts waiting for the scope lock, so a caller that aborts or drops
|
|
2122
|
+
* its connection would otherwise have its grant and COMMIT run anyway and
|
|
2123
|
+
* leave leases nobody holds. Checking the socket makes PostgreSQL abort the
|
|
2124
|
+
* transaction instead, as the multi-trip path does when it reads end-of-file.
|
|
2125
|
+
*/
|
|
2126
|
+
const RATE_STATE_CLIENT_CONNECTION_CHECK_INTERVAL_MS = 100;
|
|
2086
2127
|
const RATE_STATE_BOUNDS_SQL = `SET LOCAL lock_timeout = ${escapeLiteral(`${RATE_STATE_LOCK_TIMEOUT_MS}ms`)};
|
|
2087
|
-
SET LOCAL statement_timeout = ${escapeLiteral(`${RATE_STATE_STATEMENT_TIMEOUT_MS}ms`)}
|
|
2128
|
+
SET LOCAL statement_timeout = ${escapeLiteral(`${RATE_STATE_STATEMENT_TIMEOUT_MS}ms`)};
|
|
2129
|
+
SET LOCAL client_connection_check_interval = ${escapeLiteral(`${RATE_STATE_CLIENT_CONNECTION_CHECK_INTERVAL_MS}ms`)};`;
|
|
2088
2130
|
|
|
2089
2131
|
/**
|
|
2090
2132
|
* The one request a bounded single-statement transaction becomes. If any
|
|
@@ -2227,14 +2269,21 @@ function rateStateSingleTripEnabled(): boolean {
|
|
|
2227
2269
|
return enabled;
|
|
2228
2270
|
}
|
|
2229
2271
|
|
|
2230
|
-
/**
|
|
2231
|
-
|
|
2272
|
+
/**
|
|
2273
|
+
* The rows of a one-request transaction. The scheduler pool flattens a
|
|
2274
|
+
* multi-statement result; a bare node-postgres client returns one result per
|
|
2275
|
+
* statement. BEGIN, SET LOCAL and COMMIT return no rows, so flattening yields
|
|
2276
|
+
* exactly the rows of the request's real statements whichever client ran it,
|
|
2277
|
+
* without depending on how many bound statements precede them.
|
|
2278
|
+
*/
|
|
2279
|
+
function oneRequestRows<Row extends Record<string, unknown>>(
|
|
2232
2280
|
result: unknown,
|
|
2233
|
-
statementIndex: number,
|
|
2234
2281
|
): { rows: Row[] } {
|
|
2235
2282
|
if (Array.isArray(result)) {
|
|
2236
2283
|
return {
|
|
2237
|
-
rows: (
|
|
2284
|
+
rows: result.flatMap(
|
|
2285
|
+
(entry) => ((entry as { rows?: Row[] } | null)?.rows ?? []) as Row[],
|
|
2286
|
+
),
|
|
2238
2287
|
};
|
|
2239
2288
|
}
|
|
2240
2289
|
return { rows: ((result as { rows?: Row[] }).rows ?? []) as Row[] };
|
|
@@ -2256,7 +2305,7 @@ async function queryBoundedRateState<
|
|
|
2256
2305
|
// One request, still four commands in one transaction: BEGIN, the same
|
|
2257
2306
|
// transaction-local bounds, the statement (its own snapshot), COMMIT.
|
|
2258
2307
|
const result = await client.query(rateStateSingleTripRequest(singleTrip));
|
|
2259
|
-
return
|
|
2308
|
+
return oneRequestRows<Row>(result) as Awaited<
|
|
2260
2309
|
ReturnType<typeof client.query<Row>>
|
|
2261
2310
|
>;
|
|
2262
2311
|
} catch (error) {
|
|
@@ -3830,12 +3879,14 @@ async function collapsedApplyConcurrencyObservations(
|
|
|
3830
3879
|
};
|
|
3831
3880
|
let committed = false;
|
|
3832
3881
|
try {
|
|
3833
|
-
const result =
|
|
3882
|
+
const result = oneRequestRows<{
|
|
3834
3883
|
accepted_rows: number;
|
|
3835
3884
|
counted_rows: number;
|
|
3836
3885
|
rule_rows: ConcurrencyCheckpointRow[] | string | null;
|
|
3837
3886
|
}>(
|
|
3838
|
-
|
|
3887
|
+
await client.query(
|
|
3888
|
+
`BEGIN;\n${RATE_STATE_BOUNDS_SQL}\n${fold};${checkpoint ? '' : '\nCOMMIT;'}`,
|
|
3889
|
+
),
|
|
3839
3890
|
);
|
|
3840
3891
|
committed = !checkpoint;
|
|
3841
3892
|
const row = result.rows[0];
|