deepline 0.3.522 → 0.3.524
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 +178 -60
- 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/monitors/signal-radars/inbound-dead-letter.ts +60 -14
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-queue-delivery.ts +9 -3
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +406 -40
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/db-session-renewal.ts +209 -0
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +16 -6
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +388 -13
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +28 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-tool-hooks.ts +5 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-modal-fallback.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +38 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +92 -10
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +96 -25
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +29 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +139 -17
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-sql.ts +26 -3
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +145 -5
- package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +190 -10
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +85 -5
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +21 -11
- package/dist/cli/auth-OKPHHMMP.js +43 -0
- package/dist/cli/{auth-YIBY5IKT.mjs → auth-QXJMVLPN.mjs} +5 -5
- package/dist/cli/{billing-UDKL53GI.js → billing-N5R4HTHT.js} +82 -82
- package/dist/cli/{billing-G3IX3SNY.mjs → billing-SNSIFM4B.mjs} +7 -7
- package/dist/cli/{chunk-EJBW7Y6Z.js → chunk-2ZWNIS54.js} +108 -96
- package/dist/cli/{chunk-3KMGVOBM.mjs → chunk-2ZX7XSAQ.mjs} +4 -4
- package/dist/cli/{chunk-4TUMKJZX.mjs → chunk-3WWTBQHC.mjs} +2 -2
- package/dist/cli/{chunk-MD524MRB.mjs → chunk-536TGWR6.mjs} +1 -1
- package/dist/cli/{chunk-37SXIFIU.js → chunk-66N76YZG.js} +44 -44
- package/dist/cli/{chunk-BZY335JP.js → chunk-7E6B7VMS.js} +5 -5
- package/dist/cli/{chunk-HYR34KFA.js → chunk-7OQGZBDG.js} +109 -24
- package/dist/cli/{chunk-GVKW3LCA.js → chunk-7QM6DNR4.js} +11 -11
- package/dist/cli/{chunk-DNJJ3ULJ.js → chunk-ANKD3AIR.js} +2 -2
- package/dist/cli/{chunk-4DFWDA2Q.js → chunk-ATATJNJ6.js} +9 -9
- package/dist/cli/{chunk-ZZ7U4YJS.mjs → chunk-BXIQD2IY.mjs} +1 -1
- package/dist/cli/{chunk-XT25FX6T.js → chunk-BXVYVIMB.js} +3 -3
- package/dist/cli/{chunk-XR6TN5DT.mjs → chunk-CH7JVSA7.mjs} +6 -6
- package/dist/cli/{chunk-RKE5YTHY.mjs → chunk-EO55Y4QW.mjs} +5 -5
- package/dist/cli/{chunk-RI672VNY.js → chunk-EQNAQENZ.js} +2 -2
- package/dist/cli/{chunk-LFSOBW7E.mjs → chunk-FXTV5B3D.mjs} +22 -10
- package/dist/cli/{chunk-C6WGMODR.mjs → chunk-GMO3JDZA.mjs} +2 -2
- package/dist/cli/{chunk-DRDZBRXV.js → chunk-GTGJBZVH.js} +7 -7
- package/dist/cli/{chunk-SFMCKB57.mjs → chunk-HLAFGQPV.mjs} +76 -34
- package/dist/cli/{chunk-534YYHIF.js → chunk-HTYT2OHB.js} +6 -6
- package/dist/cli/{chunk-ZZLZCO6Y.js → chunk-I75VRGQG.js} +22 -22
- package/dist/cli/{chunk-Y3LDRCMB.mjs → chunk-II3BJKCH.mjs} +2 -2
- package/dist/cli/{chunk-5BQPEHEP.js → chunk-JDIQBZ6O.js} +14 -14
- package/dist/cli/{chunk-ENWJFUWK.mjs → chunk-KKPBCB6D.mjs} +2 -2
- package/dist/cli/{chunk-BONXEWYF.mjs → chunk-KSQXBLRW.mjs} +3 -3
- package/dist/cli/{chunk-7JEN3FX4.js → chunk-LRWDZDBS.js} +5 -5
- package/dist/cli/{chunk-5477PEHL.mjs → chunk-MW3YMPD2.mjs} +1 -1
- package/dist/cli/{chunk-VFCVH2LV.mjs → chunk-NUC7ZVDG.mjs} +5 -5
- package/dist/cli/{chunk-DLDWAPA5.js → chunk-OCT4SUJA.js} +4 -4
- package/dist/cli/{chunk-FQQAAR3Q.mjs → chunk-OQ5G7RFQ.mjs} +1 -1
- package/dist/cli/{chunk-VIM6I7RC.js → chunk-PFKKZVFK.js} +41 -41
- package/dist/cli/{chunk-OAQIVJFY.mjs → chunk-PFKWKWUJ.mjs} +2 -2
- package/dist/cli/{chunk-52MHE7B4.mjs → chunk-R457IMHJ.mjs} +1 -1
- package/dist/cli/{chunk-UV6XCHOZ.mjs → chunk-RIX26ZJD.mjs} +1 -1
- package/dist/cli/{chunk-RDJTCW3I.mjs → chunk-RTDX5NNN.mjs} +3 -3
- package/dist/cli/{chunk-FNHUDCJE.js → chunk-RUULUCBP.js} +10 -10
- package/dist/cli/{chunk-GMYDVW7Z.js → chunk-SF4QJVBE.js} +3 -3
- package/dist/cli/{chunk-DARD7TJ7.js → chunk-SMWFOGUT.js} +53 -53
- package/dist/cli/{chunk-XXY4E57R.mjs → chunk-T43FF5PF.mjs} +2 -2
- package/dist/cli/{chunk-ZUAKRBZB.js → chunk-TZTWH53O.js} +1 -1
- package/dist/cli/{chunk-7J5PLHII.mjs → chunk-V2YIBBVT.mjs} +1 -1
- package/dist/cli/{chunk-6SJPZV5E.js → chunk-V4RJ57MA.js} +2 -2
- package/dist/cli/{chunk-4MF44THR.js → chunk-V7KUBDEB.js} +82 -40
- package/dist/cli/{chunk-ISUUSSS4.js → chunk-VHTVXS5A.js} +16 -16
- package/dist/cli/{chunk-NDNG3MAT.mjs → chunk-WCVIPZWX.mjs} +5 -5
- package/dist/cli/{chunk-F5D623KO.js → chunk-WOEPDSO3.js} +26 -26
- package/dist/cli/{chunk-VE6FHVXZ.mjs → chunk-XURWFEXM.mjs} +109 -24
- package/dist/cli/{chunk-G65FJ5JX.mjs → chunk-YCIXY66B.mjs} +2 -2
- package/dist/cli/{chunk-CFXERH7F.mjs → chunk-YGOI5ZE5.mjs} +1 -1
- package/dist/cli/{chunk-PDLRUZ42.mjs → chunk-YKFW3NNA.mjs} +5 -5
- package/dist/cli/{chunk-5H22VJPE.js → chunk-YXVYPYIP.js} +6 -6
- package/dist/cli/{chunk-KMBF3N2Z.js → chunk-Z4MOEQSY.js} +16 -16
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-PE35WGRO.mjs → csv-HT2JBCW2.mjs} +4 -4
- package/dist/cli/{csv-3HIE4VCO.js → csv-Q2LWKXAV.js} +13 -13
- package/dist/cli/{db-L7ZMMQKW.mjs → db-CS3XQ2LX.mjs} +6 -6
- package/dist/cli/{db-O2YRTTDO.js → db-XEV4WEE4.js} +27 -27
- package/dist/cli/describe-5G5NXO5E.js +50 -0
- package/dist/cli/{describe-NI324Y2M.mjs → describe-OUTXLDGZ.mjs} +18 -18
- package/dist/cli/describe-core.d.mts +3 -3
- package/dist/cli/describe-core.d.ts +3 -3
- package/dist/cli/{executions-VH4DKLFI.js → executions-JCC34WAD.js} +8 -8
- package/dist/cli/{executions-T6KU2OKK.mjs → executions-L6XFG5MP.mjs} +6 -6
- package/dist/cli/{feedback-SCSJC3FX.mjs → feedback-AWBDO5I6.mjs} +5 -5
- package/dist/cli/{feedback-ZLC6G5OK.js → feedback-HV2M2G7N.js} +10 -10
- package/dist/cli/git-GDPTG52F.js +25 -0
- package/dist/cli/{git-I4LVQCID.mjs → git-S4LRXTRX.mjs} +5 -5
- package/dist/cli/index.js +146 -146
- package/dist/cli/index.mjs +45 -45
- package/dist/cli/{legacy-noops-44FQ2256.mjs → legacy-noops-7MOKBL4O.mjs} +6 -6
- package/dist/cli/{legacy-noops-UPFWEHPG.js → legacy-noops-RGSZUD6V.js} +9 -9
- package/dist/cli/{monitors-JN6IQGK6.js → monitors-JEFM2C5W.js} +100 -100
- package/dist/cli/{monitors-LMSASWXE.mjs → monitors-XQNXDZPQ.mjs} +7 -7
- package/dist/cli/{org-F7O3ZU5O.js → org-GYLA5V32.js} +235 -72
- package/dist/cli/{org-QYLVEE7A.mjs → org-KTMJZGTN.mjs} +169 -6
- package/dist/cli/{pages-KEL3Y4L4.js → pages-RY4U7OCL.js} +18 -18
- package/dist/cli/{pages-5XE4LBZN.mjs → pages-WOMU2T2O.mjs} +6 -6
- package/dist/cli/{play-OURHH6KV.js → play-2Q6MWJ3D.js} +363 -323
- package/dist/cli/{play-MWQG3G32.mjs → play-KOYGGNYS.mjs} +64 -24
- package/dist/cli/{providers-IQY7LUBB.mjs → providers-7YKDITJC.mjs} +6 -6
- package/dist/cli/{providers-ZCBWPE3C.js → providers-HOIRHMN2.js} +9 -9
- package/dist/cli/{quickstart-O53OXTN6.js → quickstart-OWCJOSQA.js} +6 -6
- package/dist/cli/{quickstart-L45NGRMI.mjs → quickstart-RDXHSMVX.mjs} +4 -4
- package/dist/cli/{run-W745Z3Z5.js → run-MT2ABKO5.js} +41 -41
- package/dist/cli/{run-VCSIWLEU.mjs → run-RT73NDP5.mjs} +23 -23
- package/dist/cli/search-7VBA6IGS.js +33 -0
- package/dist/cli/{search-THELKULN.mjs → search-CJPKIGSA.mjs} +8 -8
- package/dist/cli/{search-output-N7MJLYYD.mjs → search-output-AREMA544.mjs} +4 -4
- package/dist/cli/{search-output-SJW7LEOM.js → search-output-OSBZ7WK6.js} +6 -6
- package/dist/cli/{secrets-44ST3FJH.mjs → secrets-BTIY2FEJ.mjs} +6 -6
- package/dist/cli/{secrets-GDXPX3KB.js → secrets-OV6KH633.js} +15 -15
- package/dist/cli/{sessions-LYCBI77S.mjs → sessions-3CO3ZFOD.mjs} +6 -6
- package/dist/cli/sessions-B3WNEWRW.js +18 -0
- package/dist/cli/{settings-GXPDMJFG.mjs → settings-7BQIC7QN.mjs} +13 -13
- package/dist/cli/{settings-3WOFF642.js → settings-LBIECYDB.js} +86 -86
- package/dist/cli/{setup-YHLMBJP4.js → setup-QZE7QR3F.js} +50 -50
- package/dist/cli/{setup-YM6JEB64.mjs → setup-XPTSNNES.mjs} +10 -10
- package/dist/cli/{skills-WX4XWEAT.mjs → skills-TGGKIQLT.mjs} +8 -8
- package/dist/cli/skills-TXBRTWEV.js +37 -0
- package/dist/cli/{tools-K24VSQ7S.mjs → tools-MKIFX2TQ.mjs} +17 -17
- package/dist/cli/tools-RZJV4X3J.js +57 -0
- package/dist/cli/{update-PSSCF5AT.mjs → update-5R3D3WNH.mjs} +10 -10
- package/dist/cli/update-YWGGPWUA.js +35 -0
- package/dist/cli/{artifacts-RY2MK74N.mjs → views-VHKDHHUP.mjs} +76 -76
- package/dist/cli/views-VPWEINIA.js +270 -0
- package/dist/cli/{workflow-FPVI3NIA.js → workflow-7K2VEQ4V.js} +17 -17
- package/dist/cli/{workflow-DGOPYATO.mjs → workflow-D5DF65N6.mjs} +7 -7
- package/dist/{client-DA71-2_u.d.mts → client-C5_6W8yd.d.mts} +1 -1
- package/dist/{client-core-C0IzDKMJ.d.ts → client-core-B-GPfmaC.d.ts} +121 -44
- package/dist/{client-core-BXbds1cb.d.mts → client-core-Dob428Z4.d.mts} +121 -44
- package/dist/{client-B-2Am2y6.d.ts → client-iXW4TOat.d.ts} +1 -1
- package/dist/{compiler-manifest-B4mIIbw7.d.mts → compiler-manifest-DsxsQP-T.d.mts} +14 -7
- package/dist/{compiler-manifest-B4mIIbw7.d.ts → compiler-manifest-DsxsQP-T.d.ts} +14 -7
- package/dist/{errors-Gj9i5Rkd.d.ts → errors-Bk5h1D-C.d.ts} +1 -1
- package/dist/{errors-C2F4qzAq.d.mts → errors-qdJUVQ3g.d.mts} +1 -1
- package/dist/{index-5JZBufdF.d.mts → index-PaupwX1B.d.mts} +1 -1
- package/dist/{index-BXtSj8bv.d.ts → index-bL66eHYz.d.ts} +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 +117 -116
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/bundle-play-file.mjs +7 -5
- 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/artifacts-GIZZH5VA.js +0 -270
- package/dist/cli/auth-JSES2JOQ.js +0 -43
- package/dist/cli/describe-EB336DAO.js +0 -50
- package/dist/cli/git-23T7TXAH.js +0 -25
- package/dist/cli/search-R6K7ZAMU.js +0 -33
- package/dist/cli/sessions-2V5ZFOWL.js +0 -18
- package/dist/cli/skills-XNGADDO6.js +0 -37
- package/dist/cli/tools-ROUMCB7B.js +0 -57
- package/dist/cli/update-RXURGIRW.js +0 -35
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DB_LOGICAL_TABLES,
|
|
5
|
+
DB_SESSION_OPERATIONS,
|
|
6
|
+
PRELOADED_RUNTIME_DB_SESSION_TTL_SECONDS,
|
|
7
|
+
createDbSessionResponseSchema,
|
|
8
|
+
type CreateDbSessionResponse,
|
|
9
|
+
type PreloadedRuntimeDbSession,
|
|
10
|
+
} from './db-session';
|
|
11
|
+
import {
|
|
12
|
+
dbSessionPostgresUrlAad,
|
|
13
|
+
decryptDbSessionPostgresUrl,
|
|
14
|
+
encryptDbSessionPostgresUrl,
|
|
15
|
+
} from './db-session-crypto';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Admission seals a run's Runtime DB sessions once, for the executor-token
|
|
19
|
+
* lifetime. A run that sleeps or waits past that lifetime would otherwise wake
|
|
20
|
+
* with sessions that every reader rejects as expired. Each attempt's
|
|
21
|
+
* executor-token issuance therefore renews them, under the attempt lease,
|
|
22
|
+
* whenever they would expire before the attempt's own token does. This slack
|
|
23
|
+
* keeps the first attempt of a promptly claimed run on its admission sessions:
|
|
24
|
+
* it is smaller than the runner's post-runtime headroom, so user code can never
|
|
25
|
+
* outlive a session it reused.
|
|
26
|
+
*/
|
|
27
|
+
export const PRELOADED_RUNTIME_DB_SESSION_ATTEMPT_RENEWAL_SLACK_MS = 5 * 60_000;
|
|
28
|
+
|
|
29
|
+
/** The lifetime a renewed session receives, from the renewing attempt's start. */
|
|
30
|
+
export const PRELOADED_RUNTIME_DB_SESSION_RENEWAL_TTL_MS =
|
|
31
|
+
PRELOADED_RUNTIME_DB_SESSION_TTL_SECONDS * 1000;
|
|
32
|
+
|
|
33
|
+
function sessionExpiresAtMs(preloaded: unknown): number | null {
|
|
34
|
+
if (!preloaded || typeof preloaded !== 'object') return null;
|
|
35
|
+
const session = (preloaded as { session?: unknown }).session;
|
|
36
|
+
if (!session || typeof session !== 'object') return null;
|
|
37
|
+
const expiresAt = (session as { expiresAt?: unknown }).expiresAt;
|
|
38
|
+
if (typeof expiresAt !== 'string') return null;
|
|
39
|
+
const parsed = Date.parse(expiresAt);
|
|
40
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Whether a new attempt starting at `nowMs` needs renewed sessions: some
|
|
45
|
+
* stored session would expire before a token minted now. An entry without a
|
|
46
|
+
* readable expiry is never matched by a reader, so renewal leaves it alone and
|
|
47
|
+
* it cannot make renewal due.
|
|
48
|
+
*/
|
|
49
|
+
export function preloadedRuntimeDbSessionsRenewalDue(
|
|
50
|
+
sessions: readonly unknown[],
|
|
51
|
+
nowMs: number,
|
|
52
|
+
): boolean {
|
|
53
|
+
return sessions.some((preloaded) => sessionRenewalDue(preloaded, nowMs));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function sessionRenewalDue(preloaded: unknown, nowMs: number): boolean {
|
|
57
|
+
const expiresAtMs = sessionExpiresAtMs(preloaded);
|
|
58
|
+
return (
|
|
59
|
+
expiresAtMs !== null &&
|
|
60
|
+
expiresAtMs <
|
|
61
|
+
nowMs +
|
|
62
|
+
PRELOADED_RUNTIME_DB_SESSION_RENEWAL_TTL_MS -
|
|
63
|
+
PRELOADED_RUNTIME_DB_SESSION_ATTEMPT_RENEWAL_SLACK_MS
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Re-seal each stored session that is due (it would expire before a token
|
|
69
|
+
* minted now) with a fresh id and expiry and nothing else
|
|
70
|
+
* changed: the same org, Play, table namespace, logical table, operations,
|
|
71
|
+
* limits, relations, execution role, and database location. The database URL
|
|
72
|
+
* is the one admission sealed, decrypted with the run's own unwrap key (which
|
|
73
|
+
* also authenticates the stored metadata) and sealed again under that key, so
|
|
74
|
+
* a renewal can never widen scope or move a run to another location.
|
|
75
|
+
*
|
|
76
|
+
* Entries that are not due, and entries that a reader could never use for
|
|
77
|
+
* this run (malformed, another org or Play, a public-key envelope that was
|
|
78
|
+
* never a preload, or a bundle that does not authenticate under the run's
|
|
79
|
+
* key), are returned unchanged (the same object), so their readers keep
|
|
80
|
+
* failing exactly as before. An unrenewable expired entry therefore leaves
|
|
81
|
+
* the array identical and cannot make every later attempt renew again.
|
|
82
|
+
*/
|
|
83
|
+
export async function renewPreloadedRuntimeDbSessions(input: {
|
|
84
|
+
sessions: readonly PreloadedRuntimeDbSession[];
|
|
85
|
+
unwrapKey: string;
|
|
86
|
+
orgId: string;
|
|
87
|
+
playName: string;
|
|
88
|
+
nowMs: number;
|
|
89
|
+
}): Promise<PreloadedRuntimeDbSession[]> {
|
|
90
|
+
const unwrapKey = input.unwrapKey.trim();
|
|
91
|
+
if (!unwrapKey) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
'Renewing preloaded Runtime DB sessions requires the run unwrap key.',
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
const expiresAt = new Date(
|
|
97
|
+
input.nowMs + PRELOADED_RUNTIME_DB_SESSION_RENEWAL_TTL_MS,
|
|
98
|
+
).toISOString();
|
|
99
|
+
return await Promise.all(
|
|
100
|
+
input.sessions.map(async (preloaded) => {
|
|
101
|
+
if (!sessionRenewalDue(preloaded, input.nowMs)) return preloaded;
|
|
102
|
+
const parsed = createDbSessionResponseSchema.safeParse(
|
|
103
|
+
preloaded?.session,
|
|
104
|
+
);
|
|
105
|
+
if (!parsed.success) return preloaded;
|
|
106
|
+
const session = parsed.data;
|
|
107
|
+
if (
|
|
108
|
+
session.target.orgId !== input.orgId ||
|
|
109
|
+
session.playName !== input.playName
|
|
110
|
+
) {
|
|
111
|
+
return preloaded;
|
|
112
|
+
}
|
|
113
|
+
// Spread the stored object so fields this build does not know survive;
|
|
114
|
+
// the AAD is computed from the parsed view every reader also uses.
|
|
115
|
+
const stored = preloaded.session as unknown as Record<string, unknown>;
|
|
116
|
+
const {
|
|
117
|
+
postgresUrl,
|
|
118
|
+
encryptedPostgresUrl,
|
|
119
|
+
...sessionWithoutUrl
|
|
120
|
+
}: CreateDbSessionResponse = session;
|
|
121
|
+
const renewedIdentity = { sessionId: randomUUID(), expiresAt };
|
|
122
|
+
if (!encryptedPostgresUrl) {
|
|
123
|
+
// Harness-only plain sessions carry no sealed URL to re-key.
|
|
124
|
+
return {
|
|
125
|
+
...preloaded,
|
|
126
|
+
session: {
|
|
127
|
+
...stored,
|
|
128
|
+
...renewedIdentity,
|
|
129
|
+
} as unknown as CreateDbSessionResponse,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (encryptedPostgresUrl.alg !== 'A256GCM') return preloaded;
|
|
133
|
+
void postgresUrl;
|
|
134
|
+
let sealedUrl: string;
|
|
135
|
+
try {
|
|
136
|
+
sealedUrl = await decryptDbSessionPostgresUrl({
|
|
137
|
+
encrypted: encryptedPostgresUrl,
|
|
138
|
+
secret: unwrapKey,
|
|
139
|
+
aad: dbSessionPostgresUrlAad(sessionWithoutUrl),
|
|
140
|
+
});
|
|
141
|
+
} catch {
|
|
142
|
+
// Every reader fails this same unwrap loudly when it uses the entry.
|
|
143
|
+
// Renewal never re-seals a bundle it could not authenticate.
|
|
144
|
+
return preloaded;
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
...preloaded,
|
|
148
|
+
session: {
|
|
149
|
+
...stored,
|
|
150
|
+
...renewedIdentity,
|
|
151
|
+
encryptedPostgresUrl: await encryptDbSessionPostgresUrl({
|
|
152
|
+
postgresUrl: sealedUrl,
|
|
153
|
+
secret: unwrapKey,
|
|
154
|
+
aad: dbSessionPostgresUrlAad({
|
|
155
|
+
...sessionWithoutUrl,
|
|
156
|
+
...renewedIdentity,
|
|
157
|
+
}),
|
|
158
|
+
}),
|
|
159
|
+
} as unknown as CreateDbSessionResponse,
|
|
160
|
+
};
|
|
161
|
+
}),
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Read an executor-token response's optional `preloadedDbSessions`. Returns
|
|
167
|
+
* the array only when every entry is a well-formed preloaded session whose
|
|
168
|
+
* envelope agrees with its session target; otherwise null, so the caller keeps
|
|
169
|
+
* the launch's stored sessions. Absence, an empty array, or any malformed entry
|
|
170
|
+
* all mean "nothing renewed".
|
|
171
|
+
*/
|
|
172
|
+
export function parseRenewedPreloadedRuntimeDbSessions(
|
|
173
|
+
value: unknown,
|
|
174
|
+
): PreloadedRuntimeDbSession[] | null {
|
|
175
|
+
if (!Array.isArray(value) || value.length === 0) return null;
|
|
176
|
+
const parsed: PreloadedRuntimeDbSession[] = [];
|
|
177
|
+
for (const entry of value) {
|
|
178
|
+
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const candidate = entry as Record<string, unknown>;
|
|
182
|
+
const { tableNamespace, logicalTable, operations } = candidate;
|
|
183
|
+
if (
|
|
184
|
+
typeof tableNamespace !== 'string' ||
|
|
185
|
+
!tableNamespace.trim() ||
|
|
186
|
+
typeof logicalTable !== 'string' ||
|
|
187
|
+
!(DB_LOGICAL_TABLES as readonly string[]).includes(logicalTable) ||
|
|
188
|
+
!Array.isArray(operations) ||
|
|
189
|
+
operations.length === 0 ||
|
|
190
|
+
!operations.every(
|
|
191
|
+
(operation) =>
|
|
192
|
+
typeof operation === 'string' &&
|
|
193
|
+
(DB_SESSION_OPERATIONS as readonly string[]).includes(operation),
|
|
194
|
+
)
|
|
195
|
+
) {
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
const session = createDbSessionResponseSchema.safeParse(candidate.session);
|
|
199
|
+
if (
|
|
200
|
+
!session.success ||
|
|
201
|
+
session.data.target.tableNamespace !== tableNamespace ||
|
|
202
|
+
session.data.target.logicalTable !== logicalTable
|
|
203
|
+
) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
parsed.push(entry as PreloadedRuntimeDbSession);
|
|
207
|
+
}
|
|
208
|
+
return parsed;
|
|
209
|
+
}
|
|
@@ -47,13 +47,23 @@ export const DURABLE_RUNS_ROLLOUT = {
|
|
|
47
47
|
sharedReadCacheWrites: true,
|
|
48
48
|
/**
|
|
49
49
|
* A provider's 5xx is retried inside the attempt with exponential backoff
|
|
50
|
-
* and jitter, sending the same provider idempotency key,
|
|
51
|
-
* action
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
50
|
+
* and jitter, sending the same provider idempotency key, but only for an
|
|
51
|
+
* action that is classified for it (`retry.providerServerErrorReplay` of
|
|
52
|
+
* `idempotent_key` or `read_safe`, or `retrySafeTransientHttp`). A write,
|
|
53
|
+
* upsert, create or send, a paid call whose 5xx is ambiguous after
|
|
54
|
+
* dispatch, and any unclassified action is never resent. Only successes are
|
|
55
|
+
* final for the classified actions. The runner decides; the gateway
|
|
56
|
+
* previous-outcome check only validates the recorded outcome.
|
|
57
|
+
*
|
|
58
|
+
* Known limit: a provider that ignores idempotency keys may still apply a
|
|
59
|
+
* classified write twice if its classification is wrong, so a new replaying
|
|
60
|
+
* action needs review (`tests/fixtures/provider-server-error-replay.json`).
|
|
61
|
+
* Each call is retried at most twice (3 sends), a provider Retry-After wait
|
|
62
|
+
* is capped at 30 s, and the retries never charge the run-wide retry
|
|
63
|
+
* budget. Off again stops new retries; a call already retried keeps its
|
|
64
|
+
* recorded attempts.
|
|
55
65
|
*/
|
|
56
|
-
retryProviderServerErrors:
|
|
66
|
+
retryProviderServerErrors: true,
|
|
57
67
|
/**
|
|
58
68
|
* `runs resume` continues a stopped run. Off, the API refuses with
|
|
59
69
|
* `resume_unavailable`; readers for resumed runs ship regardless.
|