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
|
@@ -25,8 +25,93 @@ export type CompletedCall = {
|
|
|
25
25
|
/** Reuse a result already stored by its canonical receipt without copying it. */
|
|
26
26
|
valueReceiptKey?: string;
|
|
27
27
|
undefinedValue?: true;
|
|
28
|
+
/**
|
|
29
|
+
* Optional, reader-first: `sha256(semanticKey)` of the call that recorded
|
|
30
|
+
* this operation, i.e. the org, authored request (tool id and normalized
|
|
31
|
+
* input, or fetch method, URL and body), credential scope and action
|
|
32
|
+
* revision. Operation recovery returns a recorded result only to a call
|
|
33
|
+
* with the same fingerprint. Receipts written before it existed lack it;
|
|
34
|
+
* older readers ignore it.
|
|
35
|
+
*/
|
|
36
|
+
requestFingerprint?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional, reader-first: digest of the authored request alone (tool id and
|
|
39
|
+
* normalized input, or fetch method, URL and body), without credential
|
|
40
|
+
* scope or action revision. Distinguishes a changed input from a changed
|
|
41
|
+
* credential or action revision when `requestFingerprint` differs.
|
|
42
|
+
*/
|
|
43
|
+
inputFingerprint?: string;
|
|
28
44
|
};
|
|
29
45
|
|
|
46
|
+
/**
|
|
47
|
+
* A call's view of the other call-order slots of its authored id and scope,
|
|
48
|
+
* used only for receipts recorded before bindings. See
|
|
49
|
+
* `executeWithFreshnessReceipt`'s `legacySlotSearch`.
|
|
50
|
+
*/
|
|
51
|
+
export type LegacySlotSearch = {
|
|
52
|
+
ownIndex: number;
|
|
53
|
+
/** Must be called once, as soon as this call's own slot was read. */
|
|
54
|
+
reportOwnSlot: (unbound: boolean) => void;
|
|
55
|
+
/** Whether an earlier slot of this scope, read in this attempt, is unbound. */
|
|
56
|
+
priorSlotsUnbound: () => Promise<boolean>;
|
|
57
|
+
candidates: () => Array<{ index: number; invocationId: string }>;
|
|
58
|
+
/** Takes a slot for this call; false when another call already took it. */
|
|
59
|
+
consume: (index: number) => boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* What a replayed call does when its recorded slot holds a different request
|
|
64
|
+
* and no exact-request slot holds its own: a read executes (it never
|
|
65
|
+
* completed in this run); anything that may write fails loudly.
|
|
66
|
+
*/
|
|
67
|
+
export type ReplayMismatchPolicy = 'execute' | 'fail';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A recorded operation without an input binding (written before bindings, or
|
|
71
|
+
* by a lane still running such a build) that nothing proves belongs to this
|
|
72
|
+
* call. It is neither returned nor re-executed: zero dispatch, zero charge.
|
|
73
|
+
* Not retryable.
|
|
74
|
+
*/
|
|
75
|
+
export class DurableReplayUnverifiableLegacySlotError extends Error {
|
|
76
|
+
readonly code = 'DURABLE_REPLAY_UNVERIFIABLE_LEGACY_SLOT';
|
|
77
|
+
readonly retryable = false;
|
|
78
|
+
readonly reason = 'no_recorded_request_identity_match';
|
|
79
|
+
|
|
80
|
+
constructor(
|
|
81
|
+
readonly operation: string,
|
|
82
|
+
readonly callId: string,
|
|
83
|
+
) {
|
|
84
|
+
super(
|
|
85
|
+
`DURABLE_REPLAY_UNVERIFIABLE_LEGACY_SLOT: ctx.${operation}("${callId}") reached a result recorded before input binding, and no request identity recorded with it matches this call, so Deepline cannot prove it belongs to this input. It was neither returned nor repeated. Start a new run to execute it; giving each distinct call its own id avoids this.`,
|
|
86
|
+
);
|
|
87
|
+
this.name = 'DurableReplayUnverifiableLegacySlotError';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A replay reached a recorded operation of a different request and the call
|
|
93
|
+
* may write. Returning the recorded result would hand back another request's
|
|
94
|
+
* output; executing could repeat a write. Not retryable: the Play's input
|
|
95
|
+
* must be made deterministic, or each distinct call given its own id.
|
|
96
|
+
*/
|
|
97
|
+
export class DurableReplayInputMismatchError extends Error {
|
|
98
|
+
readonly code = 'DURABLE_REPLAY_INPUT_MISMATCH';
|
|
99
|
+
readonly retryable = false;
|
|
100
|
+
|
|
101
|
+
constructor(
|
|
102
|
+
readonly operation: string,
|
|
103
|
+
readonly callId: string,
|
|
104
|
+
readonly reason: 'input_changed' | 'credential_or_action_changed',
|
|
105
|
+
) {
|
|
106
|
+
super(
|
|
107
|
+
reason === 'input_changed'
|
|
108
|
+
? `DURABLE_REPLAY_INPUT_MISMATCH: ctx.${operation}("${callId}") was replayed with a different input than the call recorded in this run. Deepline did not return the recorded result or repeat the call, because it may write. Make the input deterministic (no current time or random values), or give each distinct call its own id.`
|
|
109
|
+
: `DURABLE_REPLAY_INPUT_MISMATCH: ctx.${operation}("${callId}") was replayed with the same input but a different credential or action revision than the call recorded in this run. Deepline did not return the recorded result or repeat the call, because it may write.`,
|
|
110
|
+
);
|
|
111
|
+
this.name = 'DurableReplayInputMismatchError';
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
30
115
|
/**
|
|
31
116
|
* An immutable completed-cache receipt a call hands to the freshness layer
|
|
32
117
|
* instead of writing it, so the call's finishing writes share one request.
|
|
@@ -187,7 +272,13 @@ function isCancellationError(error: unknown): boolean {
|
|
|
187
272
|
export function latestCacheResultOutput(
|
|
188
273
|
call: CompletedCall,
|
|
189
274
|
): PublishLatestCacheResultInput['output'] {
|
|
190
|
-
|
|
275
|
+
// The shared entry is keyed by the request itself; keep its shape unchanged.
|
|
276
|
+
const {
|
|
277
|
+
completedAt: _completedAt,
|
|
278
|
+
requestFingerprint: _requestFingerprint,
|
|
279
|
+
inputFingerprint: _inputFingerprint,
|
|
280
|
+
...result
|
|
281
|
+
} = call;
|
|
191
282
|
return { kind: LATEST_CACHE_RESULT_KIND, ...result };
|
|
192
283
|
}
|
|
193
284
|
|
|
@@ -200,6 +291,31 @@ function sharesLatestResult<T>(
|
|
|
200
291
|
return sharesResult ? sharesResult(value) : true;
|
|
201
292
|
}
|
|
202
293
|
|
|
294
|
+
/**
|
|
295
|
+
* Request-derived identities recorded with a completed tool result: its
|
|
296
|
+
* canonical result receipt and the cache/receipt keys in its execution
|
|
297
|
+
* metadata. Each hashes the request it was recorded for.
|
|
298
|
+
*/
|
|
299
|
+
function recordedRequestIdentities(call: CompletedCall): string[] {
|
|
300
|
+
const keys = new Set<string>();
|
|
301
|
+
if (call.valueReceiptKey) keys.add(call.valueReceiptKey);
|
|
302
|
+
const value = call.value;
|
|
303
|
+
const result = isSerializedToolExecuteResult(value)
|
|
304
|
+
? deserializeToolExecuteResult(value)
|
|
305
|
+
: isToolExecuteResult(value)
|
|
306
|
+
? value
|
|
307
|
+
: null;
|
|
308
|
+
const execution = result?._metadata?.execution;
|
|
309
|
+
for (const key of [
|
|
310
|
+
execution?.cacheKey,
|
|
311
|
+
execution?.receiptKey,
|
|
312
|
+
execution?.resultReceiptKey,
|
|
313
|
+
]) {
|
|
314
|
+
if (typeof key === 'string' && key.trim()) keys.add(key.trim());
|
|
315
|
+
}
|
|
316
|
+
return [...keys];
|
|
317
|
+
}
|
|
318
|
+
|
|
203
319
|
function completedCall(
|
|
204
320
|
receipt: RuntimeStepReceipt | null,
|
|
205
321
|
): CompletedCall | null {
|
|
@@ -223,7 +339,13 @@ function completedCall(
|
|
|
223
339
|
(candidate.undefinedValue !== undefined &&
|
|
224
340
|
candidate.undefinedValue !== true) ||
|
|
225
341
|
(candidate.undefinedValue === true &&
|
|
226
|
-
(hasReceiptReference || candidate.value !== null))
|
|
342
|
+
(hasReceiptReference || candidate.value !== null)) ||
|
|
343
|
+
(candidate.requestFingerprint !== undefined &&
|
|
344
|
+
(typeof candidate.requestFingerprint !== 'string' ||
|
|
345
|
+
!candidate.requestFingerprint)) ||
|
|
346
|
+
(candidate.inputFingerprint !== undefined &&
|
|
347
|
+
(typeof candidate.inputFingerprint !== 'string' ||
|
|
348
|
+
!candidate.inputFingerprint))
|
|
227
349
|
) {
|
|
228
350
|
throw new Error('Invalid completed freshness receipt.');
|
|
229
351
|
}
|
|
@@ -241,6 +363,54 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
241
363
|
semanticKey: string;
|
|
242
364
|
orgId: string;
|
|
243
365
|
invocationId: string;
|
|
366
|
+
/**
|
|
367
|
+
* Call-order artifacts: the operation slot numbered among identical
|
|
368
|
+
* requests only. Recorded beside the call-order slot and recovered first,
|
|
369
|
+
* so a call whose call-order slot holds a sibling's result still finds its
|
|
370
|
+
* own. Omitted where `invocationId` is already request-scoped.
|
|
371
|
+
*/
|
|
372
|
+
exactRequestInvocationId?: string;
|
|
373
|
+
/**
|
|
374
|
+
* A call-order slot was recovered from a receipt written before request
|
|
375
|
+
* fingerprints existed, so its request could not be verified. Recovery keeps
|
|
376
|
+
* the historical behavior for it; the caller reports it (rate-limited).
|
|
377
|
+
*/
|
|
378
|
+
/**
|
|
379
|
+
* A recorded operation without a binding was proven to be this call's by a
|
|
380
|
+
* request identity recorded with it. Reported (rate-limited) by the caller.
|
|
381
|
+
*/
|
|
382
|
+
onLegacyRecoveryProven?: () => void;
|
|
383
|
+
/**
|
|
384
|
+
* Request-derived identities of this call, as builds before bindings
|
|
385
|
+
* recorded them with a result (for tools: the durable result-cache keys,
|
|
386
|
+
* which hash the request input, credential scope, action version and run
|
|
387
|
+
* cache epoch). An unbound recorded operation is this call's only when one
|
|
388
|
+
* of its recorded identities is in this set. Omitted: no proof exists.
|
|
389
|
+
*/
|
|
390
|
+
legacyRequestIdentities?: () => Promise<readonly string[]>;
|
|
391
|
+
/**
|
|
392
|
+
* The operation key itself already encodes the authored request (a
|
|
393
|
+
* `ctx.step` with a `semanticKey`): an unbound receipt under it can only be
|
|
394
|
+
* this request's or an identical declared request's.
|
|
395
|
+
*/
|
|
396
|
+
operationKeyEncodesRequest?: true;
|
|
397
|
+
/**
|
|
398
|
+
* Call-order artifacts: a sibling started in another order on replay may
|
|
399
|
+
* hold this call's pre-binding result in another slot of the same scope.
|
|
400
|
+
* Searched only when this call's slot holds an unbound receipt that is not
|
|
401
|
+
* its own, or is empty while an earlier slot of the scope is unbound.
|
|
402
|
+
*/
|
|
403
|
+
legacySlotSearch?: LegacySlotSearch;
|
|
404
|
+
/** Digest of the authored request alone; see `CompletedCall`. */
|
|
405
|
+
inputFingerprint?: string;
|
|
406
|
+
/**
|
|
407
|
+
* Decided only when a recorded slot holds a different request. Omitted
|
|
408
|
+
* means `fail`: a call is a read only when its caller proves it.
|
|
409
|
+
*/
|
|
410
|
+
replayMismatchPolicy?: () => Promise<ReplayMismatchPolicy>;
|
|
411
|
+
/** Names the call in a mismatch error. */
|
|
412
|
+
operation?: string;
|
|
413
|
+
callId?: string;
|
|
244
414
|
runId: string;
|
|
245
415
|
requestedStaleAfterSeconds: number | null;
|
|
246
416
|
effectiveStaleAfterSeconds: number | null;
|
|
@@ -307,6 +477,24 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
307
477
|
) => Promise<Result>;
|
|
308
478
|
now?: () => number;
|
|
309
479
|
}): Promise<T> {
|
|
480
|
+
let ownSlotReported = false;
|
|
481
|
+
const reportOwnSlot = (unbound: boolean) => {
|
|
482
|
+
if (ownSlotReported) return;
|
|
483
|
+
ownSlotReported = true;
|
|
484
|
+
input.legacySlotSearch?.reportOwnSlot(unbound);
|
|
485
|
+
};
|
|
486
|
+
try {
|
|
487
|
+
return await executeWithFreshnessReceiptOnce(input, reportOwnSlot);
|
|
488
|
+
} finally {
|
|
489
|
+
// A sibling may be waiting on this slot's verdict; never leave it hanging.
|
|
490
|
+
reportOwnSlot(false);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
async function executeWithFreshnessReceiptOnce<T>(
|
|
495
|
+
input: Parameters<typeof executeWithFreshnessReceipt<T>>[0],
|
|
496
|
+
reportOwnSlot: (unbound: boolean) => void,
|
|
497
|
+
): Promise<T> {
|
|
310
498
|
if (!input.store.enabled) {
|
|
311
499
|
throw new Error(
|
|
312
500
|
'Durable operation recovery is unavailable in this runtime.',
|
|
@@ -325,11 +513,45 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
325
513
|
const semanticHash = sha256Hex(input.semanticKey);
|
|
326
514
|
const cachePrefix = `ctx:${input.orgId}:freshness:${semanticHash}`;
|
|
327
515
|
const latestCacheKey = latestCacheResultKey(input.orgId, input.semanticKey);
|
|
328
|
-
const operationKeyFor = (
|
|
516
|
+
const operationKeyFor = (
|
|
517
|
+
runId: string,
|
|
518
|
+
invocationId: string = input.invocationId,
|
|
519
|
+
) =>
|
|
329
520
|
`ctx:${input.orgId}:freshness:operation:${sha256Hex(
|
|
330
|
-
stableStringify({ runId, invocationId
|
|
521
|
+
stableStringify({ runId, invocationId }),
|
|
331
522
|
)}`;
|
|
332
523
|
const operationKey = operationKeyFor(input.runId);
|
|
524
|
+
const exactRequestOperationKey =
|
|
525
|
+
input.exactRequestInvocationId !== undefined
|
|
526
|
+
? // Its own namespace, so per-run history counts (post-code recovery's
|
|
527
|
+
// saved calls) still count each call once.
|
|
528
|
+
`ctx:${input.orgId}:freshness:operation-exact:${sha256Hex(
|
|
529
|
+
stableStringify({
|
|
530
|
+
runId: input.runId,
|
|
531
|
+
invocationId: input.exactRequestInvocationId,
|
|
532
|
+
}),
|
|
533
|
+
)}`
|
|
534
|
+
: null;
|
|
535
|
+
/** The slot this call's own result is recorded and recovered under. */
|
|
536
|
+
const ownOperationKey = exactRequestOperationKey ?? operationKey;
|
|
537
|
+
const requestFingerprint = semanticHash;
|
|
538
|
+
const fingerprints = {
|
|
539
|
+
requestFingerprint,
|
|
540
|
+
...(input.inputFingerprint
|
|
541
|
+
? { inputFingerprint: input.inputFingerprint }
|
|
542
|
+
: {}),
|
|
543
|
+
};
|
|
544
|
+
/**
|
|
545
|
+
* Whether a recorded operation belongs to this call. A binding must match
|
|
546
|
+
* exactly. A receipt without one predates bindings; see
|
|
547
|
+
* `refuseAmbiguousUnbound` for when it may still be recovered.
|
|
548
|
+
*/
|
|
549
|
+
const ownsOperation = (call: CompletedCall): 'yes' | 'no' | 'unverified' =>
|
|
550
|
+
call.requestFingerprint === undefined
|
|
551
|
+
? 'unverified'
|
|
552
|
+
: call.requestFingerprint === requestFingerprint
|
|
553
|
+
? 'yes'
|
|
554
|
+
: 'no';
|
|
333
555
|
const legacyOperationKey =
|
|
334
556
|
input.legacyOperationRunId !== undefined &&
|
|
335
557
|
input.legacyOperationRunId !== input.runId
|
|
@@ -508,7 +730,9 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
508
730
|
const stored = await input.store.get(key);
|
|
509
731
|
if (stored?.status !== 'completed' && stored?.status !== 'skipped') {
|
|
510
732
|
throw new Error(
|
|
511
|
-
key === operationKey ||
|
|
733
|
+
key === operationKey ||
|
|
734
|
+
key === exactRequestOperationKey ||
|
|
735
|
+
key.startsWith(`${cachePrefix}:reusable:`)
|
|
512
736
|
? 'Completed freshness receipt publication failed.'
|
|
513
737
|
: `Tool Result Receipt ${key} could not publish a completed result.`,
|
|
514
738
|
);
|
|
@@ -564,7 +788,18 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
564
788
|
// second read) beside the candidates' manifests. Own-run recovery still
|
|
565
789
|
// wins whenever it exists.
|
|
566
790
|
const [operation, candidateManifests] = await Promise.allSettled([
|
|
567
|
-
|
|
791
|
+
exactRequestOperationKey
|
|
792
|
+
? // One batch: the exact-request slot and the call-order slot.
|
|
793
|
+
readMany([exactRequestOperationKey, operationKey]).then(
|
|
794
|
+
([exact, callOrder]) => ({
|
|
795
|
+
exact: completedCall(exact ?? null),
|
|
796
|
+
callOrder: completedCall(callOrder ?? null),
|
|
797
|
+
}),
|
|
798
|
+
)
|
|
799
|
+
: read(operationKey).then((callOrder) => ({
|
|
800
|
+
exact: null,
|
|
801
|
+
callOrder,
|
|
802
|
+
})),
|
|
568
803
|
candidateKeys.length > 0 && input.store.getMany
|
|
569
804
|
? input.store
|
|
570
805
|
.getMany([...candidateKeys], { hydrateOutput: false })
|
|
@@ -572,11 +807,126 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
572
807
|
: Promise.resolve(null),
|
|
573
808
|
]);
|
|
574
809
|
if (operation.status === 'rejected') throw operation.reason;
|
|
575
|
-
|
|
576
|
-
|
|
810
|
+
const { exact, callOrder } = operation.value;
|
|
811
|
+
reportOwnSlot(callOrder !== null && ownsOperation(callOrder) === 'unverified');
|
|
812
|
+
// Same-run recovery returns only this call's own recorded result.
|
|
813
|
+
if (exact && ownsOperation(exact) === 'yes') {
|
|
814
|
+
return outcome(exact, 'operation_recovery');
|
|
815
|
+
}
|
|
816
|
+
if (callOrder && ownsOperation(callOrder) === 'yes') {
|
|
817
|
+
return outcome(callOrder, 'operation_recovery');
|
|
818
|
+
}
|
|
819
|
+
/**
|
|
820
|
+
* A recorded operation without a binding is returned only with proof that
|
|
821
|
+
* it is this call's: its operation key encodes the request, or a request
|
|
822
|
+
* identity recorded with it matches this call's. Otherwise the call refuses
|
|
823
|
+
* with zero dispatch, read or write: an unverifiable slot may be another
|
|
824
|
+
* request's result, and executing could repeat a paid call.
|
|
825
|
+
*/
|
|
826
|
+
const recoverUnbound = async (recorded: CompletedCall) => {
|
|
827
|
+
const search = input.legacySlotSearch;
|
|
828
|
+
const owned =
|
|
829
|
+
(input.operationKeyEncodesRequest === true ||
|
|
830
|
+
(await recordedIdentityMatches(recorded))) &&
|
|
831
|
+
(!search || search.consume(search.ownIndex));
|
|
832
|
+
if (!owned) {
|
|
833
|
+
const found = await searchLegacySlots();
|
|
834
|
+
if (found) return found;
|
|
835
|
+
throw new DurableReplayUnverifiableLegacySlotError(
|
|
836
|
+
input.operation ?? 'call',
|
|
837
|
+
input.callId ?? 'unknown',
|
|
838
|
+
);
|
|
839
|
+
}
|
|
840
|
+
input.onLegacyRecoveryProven?.();
|
|
841
|
+
return outcome(recorded, 'operation_recovery');
|
|
842
|
+
};
|
|
843
|
+
/**
|
|
844
|
+
* Another slot of this scope holding this call's pre-binding result,
|
|
845
|
+
* proven by a recorded request identity and not yet taken by another call.
|
|
846
|
+
*/
|
|
847
|
+
const searchLegacySlots = async (): Promise<T | null> => {
|
|
848
|
+
const search = input.legacySlotSearch;
|
|
849
|
+
if (!search || !input.legacyRequestIdentities) return null;
|
|
850
|
+
const candidates = search.candidates();
|
|
851
|
+
if (candidates.length === 0) return null;
|
|
852
|
+
const receipts = await readMany(
|
|
853
|
+
candidates.map(({ invocationId }) =>
|
|
854
|
+
operationKeyFor(input.runId, invocationId),
|
|
855
|
+
),
|
|
856
|
+
);
|
|
857
|
+
const current = new Set(await input.legacyRequestIdentities());
|
|
858
|
+
for (const [position, candidate] of candidates.entries()) {
|
|
859
|
+
const call = completedCall(receipts[position] ?? null);
|
|
860
|
+
if (!call || ownsOperation(call) !== 'unverified') continue;
|
|
861
|
+
if (
|
|
862
|
+
recordedRequestIdentities(call).some((identity) =>
|
|
863
|
+
current.has(identity),
|
|
864
|
+
) &&
|
|
865
|
+
search.consume(candidate.index)
|
|
866
|
+
) {
|
|
867
|
+
input.onLegacyRecoveryProven?.();
|
|
868
|
+
return outcome(call, 'operation_recovery');
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
return null;
|
|
872
|
+
};
|
|
873
|
+
const recordedIdentityMatches = async (
|
|
874
|
+
recorded: CompletedCall,
|
|
875
|
+
): Promise<boolean> => {
|
|
876
|
+
if (!input.legacyRequestIdentities) return false;
|
|
877
|
+
const recordedIdentities = recordedRequestIdentities(recorded);
|
|
878
|
+
if (recordedIdentities.length === 0) return false;
|
|
879
|
+
const current = new Set(await input.legacyRequestIdentities());
|
|
880
|
+
return recordedIdentities.some((identity) => current.has(identity));
|
|
881
|
+
};
|
|
882
|
+
/**
|
|
883
|
+
* A recorded slot holds another request. A read never completed in this
|
|
884
|
+
* run and executes; a call that may write fails loudly instead of returning
|
|
885
|
+
* another request's output or repeating a write.
|
|
886
|
+
*/
|
|
887
|
+
const refuseOrExecute = async (recorded: CompletedCall) => {
|
|
888
|
+
const policy = input.replayMismatchPolicy
|
|
889
|
+
? await input.replayMismatchPolicy()
|
|
890
|
+
: 'fail';
|
|
891
|
+
if (policy === 'execute') return;
|
|
892
|
+
const sameInput =
|
|
893
|
+
recorded.inputFingerprint !== undefined
|
|
894
|
+
? recorded.inputFingerprint === input.inputFingerprint
|
|
895
|
+
: recorded === exact;
|
|
896
|
+
throw new DurableReplayInputMismatchError(
|
|
897
|
+
input.operation ?? 'call',
|
|
898
|
+
input.callId ?? 'unknown',
|
|
899
|
+
sameInput ? 'credential_or_action_changed' : 'input_changed',
|
|
900
|
+
);
|
|
901
|
+
};
|
|
902
|
+
if (exact && ownsOperation(exact) === 'no') {
|
|
903
|
+
// The exact-request slot is keyed by the input itself: only the
|
|
904
|
+
// credential scope or action revision differs.
|
|
905
|
+
await refuseOrExecute(exact);
|
|
906
|
+
} else if (callOrder) {
|
|
907
|
+
if (ownsOperation(callOrder) === 'unverified') {
|
|
908
|
+
return recoverUnbound(callOrder);
|
|
909
|
+
}
|
|
910
|
+
await refuseOrExecute(callOrder);
|
|
911
|
+
} else if (
|
|
912
|
+
!exact &&
|
|
913
|
+
input.legacySlotSearch &&
|
|
914
|
+
(await input.legacySlotSearch.priorSlotsUnbound())
|
|
915
|
+
) {
|
|
916
|
+
// An empty slot in a scope holding pre-binding receipts: a sibling that
|
|
917
|
+
// started first may have taken this call's original slot.
|
|
918
|
+
const found = await searchLegacySlots();
|
|
919
|
+
if (found) return found;
|
|
920
|
+
}
|
|
921
|
+
if (legacyOperationKey && !exact && !callOrder) {
|
|
577
922
|
const legacy =
|
|
578
923
|
await readLegacyOperationWrittenByThisRun(legacyOperationKey);
|
|
579
|
-
if (legacy)
|
|
924
|
+
if (legacy) {
|
|
925
|
+
const owner = ownsOperation(legacy);
|
|
926
|
+
if (owner === 'unverified') return recoverUnbound(legacy);
|
|
927
|
+
if (owner === 'yes') return outcome(legacy, 'operation_recovery');
|
|
928
|
+
await refuseOrExecute(legacy);
|
|
929
|
+
}
|
|
580
930
|
}
|
|
581
931
|
if (candidateManifests.status === 'rejected') {
|
|
582
932
|
throw candidateManifests.reason;
|
|
@@ -594,6 +944,13 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
594
944
|
for (const parse of reusable) {
|
|
595
945
|
const cached = parse();
|
|
596
946
|
if (!cached) continue;
|
|
947
|
+
// Buckets are keyed by the request; a present binding must agree.
|
|
948
|
+
if (
|
|
949
|
+
cached.requestFingerprint !== undefined &&
|
|
950
|
+
cached.requestFingerprint !== requestFingerprint
|
|
951
|
+
) {
|
|
952
|
+
continue;
|
|
953
|
+
}
|
|
597
954
|
const age = now() - cached.completedAt;
|
|
598
955
|
if (age < 0 || (ttl !== null && age >= ttl * 1000)) continue;
|
|
599
956
|
// Read applies the same eligibility as publish, so an entry an older
|
|
@@ -602,8 +959,19 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
602
959
|
? await servedAnswer(cached)
|
|
603
960
|
: undefined;
|
|
604
961
|
if (served === null) continue;
|
|
605
|
-
const
|
|
606
|
-
|
|
962
|
+
const hit: CompletedCall = { ...cached, ...fingerprints };
|
|
963
|
+
if (!exactRequestOperationKey) {
|
|
964
|
+
const own = await publish(operationKey, hit);
|
|
965
|
+
return outcome(own, 'reusable_result', served);
|
|
966
|
+
}
|
|
967
|
+
// Both slots in one request: the exact-request slot for this build, the
|
|
968
|
+
// call-order slot for older readers. A sibling may already hold the
|
|
969
|
+
// call-order slot; the insert then keeps the sibling's.
|
|
970
|
+
await publishFinishingWrites([
|
|
971
|
+
{ key: exactRequestOperationKey, output: hit },
|
|
972
|
+
{ key: operationKey, output: hit },
|
|
973
|
+
]);
|
|
974
|
+
return outcome(hit, 'reusable_result', served);
|
|
607
975
|
}
|
|
608
976
|
}
|
|
609
977
|
|
|
@@ -636,10 +1004,17 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
636
1004
|
throw new Error('Freshness call returned an invalid completion time.');
|
|
637
1005
|
}
|
|
638
1006
|
const completed = completedCallForResult(value, completedAt);
|
|
1007
|
+
const recorded: CompletedCall = { ...completed, ...fingerprints };
|
|
639
1008
|
|
|
640
1009
|
// Recover this exact operation even if reusable publication fails afterwards.
|
|
1010
|
+
// A call-order artifact records both slots: its exact-request slot for this
|
|
1011
|
+
// and later builds, its call-order slot for older readers. A sibling may
|
|
1012
|
+
// already hold the call-order slot; the insert then keeps the sibling's.
|
|
641
1013
|
const pointers: DeferredReceiptWrite[] = [
|
|
642
|
-
|
|
1014
|
+
...(exactRequestOperationKey
|
|
1015
|
+
? [{ key: exactRequestOperationKey, output: recorded }]
|
|
1016
|
+
: []),
|
|
1017
|
+
{ key: operationKey, output: recorded },
|
|
643
1018
|
];
|
|
644
1019
|
// The same eligibility gates the policy bucket and the newest shared
|
|
645
1020
|
// result: a failed, empty or non-final answer recovers within this run but
|
|
@@ -657,7 +1032,7 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
657
1032
|
ttl === null
|
|
658
1033
|
? `${cachePrefix}:reusable:indefinite`
|
|
659
1034
|
: `${cachePrefix}:reusable:${ttl}:${completionPartition}`,
|
|
660
|
-
output:
|
|
1035
|
+
output: recorded,
|
|
661
1036
|
});
|
|
662
1037
|
}
|
|
663
1038
|
// One request carries the call's result receipt, its replay pointer and its
|
|
@@ -245,3 +245,31 @@ export function withPlayLaunchIdentityDigest<
|
|
|
245
245
|
launchIdentityDigest: buildPlayLaunchIdentityDigest(launch),
|
|
246
246
|
};
|
|
247
247
|
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The launch identity a keyed rerun request controls: the owning org, the
|
|
251
|
+
* source run's pinned revision, and the exact input (the source run's
|
|
252
|
+
* retained input with the request's overrides applied). The run id already
|
|
253
|
+
* binds the source run, whose artifact and files are immutable.
|
|
254
|
+
*
|
|
255
|
+
* Read through `buildPlayLaunchIdentity`, the same normalizer the admission
|
|
256
|
+
* fence digests, so transport, authority and release details never count and
|
|
257
|
+
* an admitted launch from any build (it always stores `input`) is provable.
|
|
258
|
+
*/
|
|
259
|
+
export const PLAY_RERUN_INTENT_IDENTITY_FIELDS = Object.freeze([
|
|
260
|
+
'orgId',
|
|
261
|
+
'revisionId',
|
|
262
|
+
'inputDigest',
|
|
263
|
+
] as const);
|
|
264
|
+
|
|
265
|
+
/** Rerun intent fields where an admitted launch differs from a request. */
|
|
266
|
+
export function playRerunIntentDifferences(
|
|
267
|
+
admitted: PlayLaunchIdentitySource,
|
|
268
|
+
requested: PlayLaunchIdentitySource,
|
|
269
|
+
): string[] {
|
|
270
|
+
const stored = buildPlayLaunchIdentity(admitted);
|
|
271
|
+
const incoming = buildPlayLaunchIdentity(requested);
|
|
272
|
+
return PLAY_RERUN_INTENT_IDENTITY_FIELDS.filter(
|
|
273
|
+
(field) => stored[field] !== incoming[field],
|
|
274
|
+
);
|
|
275
|
+
}
|
|
@@ -6,6 +6,7 @@ import type { ToolResultMetadataInput } from '../tool-result';
|
|
|
6
6
|
|
|
7
7
|
/** The app's runtime tool metadata as the runner receives it over HTTP. */
|
|
8
8
|
export type RuntimeToolMetadata = {
|
|
9
|
+
/** The pre-edition-11 shared-cache gate; only the legacy latest-cache path reads it. */
|
|
9
10
|
reusableResult?: { supported: boolean; unavailableReason: string | null };
|
|
10
11
|
provider?: string | null;
|
|
11
12
|
operation?: string | null;
|
|
@@ -17,6 +18,7 @@ export type RuntimeToolMetadata = {
|
|
|
17
18
|
idempotencyScope?: 'invocation';
|
|
18
19
|
retrySafeTransientHttp?: boolean;
|
|
19
20
|
requiresExecutionFence?: boolean;
|
|
21
|
+
providerServerErrorReplay?: 'idempotent_key' | 'read_safe' | 'never';
|
|
20
22
|
};
|
|
21
23
|
targetGetters?: Record<string, string[]>;
|
|
22
24
|
listExtractorPaths?: string[];
|
|
@@ -102,6 +104,9 @@ export function createRuntimeToolHooks(input: {
|
|
|
102
104
|
return {
|
|
103
105
|
retrySafeTransientHttp: metadata.retry?.retrySafeTransientHttp === true,
|
|
104
106
|
requiresExecutionFence: metadata.retry?.requiresExecutionFence === true,
|
|
107
|
+
// Absent (an older metadata reader or an unclassified action) is `never`.
|
|
108
|
+
providerServerErrorReplay:
|
|
109
|
+
metadata.retry?.providerServerErrorReplay ?? 'never',
|
|
105
110
|
};
|
|
106
111
|
},
|
|
107
112
|
getToolActionCacheVersion: async (toolId) => {
|
|
@@ -1328,6 +1328,8 @@ function emitDaytonaStage(
|
|
|
1328
1328
|
playName: context.playName ?? null,
|
|
1329
1329
|
stage,
|
|
1330
1330
|
...extra,
|
|
1331
|
+
// This worker's clock at the stage; log rows carry the shipper's.
|
|
1332
|
+
atMs: Date.now(),
|
|
1331
1333
|
};
|
|
1332
1334
|
try {
|
|
1333
1335
|
console.info('[play-runner.daytona.stage]', JSON.stringify(payload));
|
|
@@ -1531,6 +1533,24 @@ function isFailedDaytonaRunnerStart(error: unknown): boolean {
|
|
|
1531
1533
|
);
|
|
1532
1534
|
}
|
|
1533
1535
|
|
|
1536
|
+
/**
|
|
1537
|
+
* The last sandbox of an attempt breached the upload deadline, but an earlier
|
|
1538
|
+
* sandbox of the same attempt failed for another, Daytona-side reason (for
|
|
1539
|
+
* example a control-request timeout). The upload never finished, so no command
|
|
1540
|
+
* was sent and no customer code ran. One breach is not evidence of an input
|
|
1541
|
+
* too large for any sandbox, so it defers like any other failed start. When
|
|
1542
|
+
* every sandbox of the attempt breached, the upload stays loud.
|
|
1543
|
+
*/
|
|
1544
|
+
function isUploadDeadlineAfterOtherStartFailure(
|
|
1545
|
+
error: unknown,
|
|
1546
|
+
executionAttempt: number,
|
|
1547
|
+
): boolean {
|
|
1548
|
+
return (
|
|
1549
|
+
error instanceof DaytonaUploadDeadlineBreachError &&
|
|
1550
|
+
error.attemptTimings.length < executionAttempt
|
|
1551
|
+
);
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1534
1554
|
/** Which failure ended a start, for the stage log: the run error has less. */
|
|
1535
1555
|
function startFailureForLog(error: unknown) {
|
|
1536
1556
|
const diagnostic =
|
|
@@ -1590,19 +1610,28 @@ function isRetryableUnstartedDaytonaRunner(
|
|
|
1590
1610
|
// that waiting state. Defer a runner with no exit evidence, or the observed
|
|
1591
1611
|
// pre-start 127 shape (no Node process or startup marker). A fresh attempt
|
|
1592
1612
|
// fences the old sandbox; persistent failures exhaust the existing budget.
|
|
1613
|
+
// A sandbox Daytona could not answer for at all (command and session both
|
|
1614
|
+
// unreadable) also has no exit evidence: it is the same unstarted runner,
|
|
1615
|
+
// only on a sandbox that vanished, so it defers too.
|
|
1593
1616
|
const noExit =
|
|
1594
1617
|
diagnostic.exitCode === null && diagnostic.exitCodeFile === null;
|
|
1595
1618
|
const exitedBeforeStartup =
|
|
1619
|
+
diagnostic.commandFound &&
|
|
1620
|
+
diagnostic.sessionFound &&
|
|
1596
1621
|
(diagnostic.exitCode === null || diagnostic.exitCode === 127) &&
|
|
1597
1622
|
diagnostic.exitCodeFile === 127 &&
|
|
1598
1623
|
diagnostic.processSummary?.node === 0 &&
|
|
1599
1624
|
diagnostic.runnerStartup === null &&
|
|
1600
1625
|
diagnostic.errors.includes('startup_diagnostic_unavailable');
|
|
1626
|
+
const sandboxUnreadable =
|
|
1627
|
+
!diagnostic.commandFound &&
|
|
1628
|
+
!diagnostic.sessionFound &&
|
|
1629
|
+
diagnostic.errors.includes('get_session_command_failed') &&
|
|
1630
|
+
diagnostic.errors.includes('get_session_failed');
|
|
1631
|
+
const runnerReadable = diagnostic.commandFound && diagnostic.sessionFound;
|
|
1601
1632
|
return (
|
|
1602
|
-
diagnostic.
|
|
1603
|
-
|
|
1604
|
-
(noExit || exitedBeforeStartup) &&
|
|
1605
|
-
!diagnostic.schedulerReadinessObserved
|
|
1633
|
+
!diagnostic.schedulerReadinessObserved &&
|
|
1634
|
+
((noExit && (runnerReadable || sandboxUnreadable)) || exitedBeforeStartup)
|
|
1606
1635
|
);
|
|
1607
1636
|
}
|
|
1608
1637
|
|
|
@@ -2239,7 +2268,11 @@ export const daytonaPlayRunnerBackend: PlayRunnerBackend = {
|
|
|
2239
2268
|
? 'runner_startup_not_live'
|
|
2240
2269
|
: sandboxForAttempt &&
|
|
2241
2270
|
!parkStarted &&
|
|
2242
|
-
isFailedDaytonaRunnerStart(error)
|
|
2271
|
+
(isFailedDaytonaRunnerStart(error) ||
|
|
2272
|
+
isUploadDeadlineAfterOtherStartFailure(
|
|
2273
|
+
error,
|
|
2274
|
+
executionAttempt,
|
|
2275
|
+
))
|
|
2243
2276
|
? 'runner_start_failed'
|
|
2244
2277
|
: isRetryableDaytonaInfrastructureFailure(error)
|
|
2245
2278
|
? 'daytona_infrastructure'
|