deepline 0.3.523 → 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 +60 -60
- 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 +359 -22
- 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/cli/auth-OKPHHMMP.js +43 -0
- package/dist/cli/{auth-ENQUQS56.mjs → auth-QXJMVLPN.mjs} +5 -5
- package/dist/cli/{billing-6HONTJOY.js → billing-N5R4HTHT.js} +82 -82
- package/dist/cli/{billing-6A27ULCX.mjs → billing-SNSIFM4B.mjs} +7 -7
- package/dist/cli/{chunk-326WVSWS.js → chunk-2ZWNIS54.js} +98 -98
- package/dist/cli/{chunk-JGZQBDYG.mjs → chunk-2ZX7XSAQ.mjs} +4 -4
- package/dist/cli/{chunk-6DBRBWHC.mjs → chunk-3WWTBQHC.mjs} +2 -2
- package/dist/cli/{chunk-KILRUAXF.mjs → chunk-536TGWR6.mjs} +1 -1
- package/dist/cli/{chunk-MZROKQV3.js → chunk-66N76YZG.js} +44 -44
- package/dist/cli/{chunk-IEVXYHGJ.js → chunk-7E6B7VMS.js} +5 -5
- package/dist/cli/{chunk-QYXIODWH.js → chunk-7OQGZBDG.js} +31 -23
- package/dist/cli/{chunk-4NWY7JBB.js → chunk-7QM6DNR4.js} +11 -11
- package/dist/cli/{chunk-HUC5SGJQ.js → chunk-ANKD3AIR.js} +2 -2
- package/dist/cli/{chunk-2BRDHM4S.js → chunk-ATATJNJ6.js} +9 -9
- package/dist/cli/{chunk-QSAC3IVI.mjs → chunk-BXIQD2IY.mjs} +1 -1
- package/dist/cli/{chunk-S4YKRH3W.js → chunk-BXVYVIMB.js} +3 -3
- package/dist/cli/{chunk-NWTMQGPP.mjs → chunk-CH7JVSA7.mjs} +6 -6
- package/dist/cli/{chunk-4V63IJCL.mjs → chunk-EO55Y4QW.mjs} +5 -5
- package/dist/cli/{chunk-FBMOBNJY.js → chunk-EQNAQENZ.js} +2 -2
- package/dist/cli/{chunk-QOO5W5XS.mjs → chunk-FXTV5B3D.mjs} +10 -10
- package/dist/cli/{chunk-HSVGP4CI.mjs → chunk-GMO3JDZA.mjs} +2 -2
- package/dist/cli/{chunk-V46J3UTM.js → chunk-GTGJBZVH.js} +7 -7
- package/dist/cli/{chunk-WVQOXYTQ.mjs → chunk-HLAFGQPV.mjs} +33 -33
- package/dist/cli/{chunk-PESMXAUG.js → chunk-HTYT2OHB.js} +6 -6
- package/dist/cli/{chunk-ZWN4RXC2.js → chunk-I75VRGQG.js} +22 -22
- package/dist/cli/{chunk-PCORO245.mjs → chunk-II3BJKCH.mjs} +2 -2
- package/dist/cli/{chunk-WGVJA4I5.js → chunk-JDIQBZ6O.js} +14 -14
- package/dist/cli/{chunk-UH3EAFFN.mjs → chunk-KKPBCB6D.mjs} +2 -2
- package/dist/cli/{chunk-RKREB7MU.mjs → chunk-KSQXBLRW.mjs} +3 -3
- package/dist/cli/{chunk-36LQQL5C.js → chunk-LRWDZDBS.js} +5 -5
- package/dist/cli/{chunk-SXTVJIGB.mjs → chunk-MW3YMPD2.mjs} +1 -1
- package/dist/cli/{chunk-5WFQXAD4.mjs → chunk-NUC7ZVDG.mjs} +5 -5
- package/dist/cli/{chunk-UQN4VTZL.js → chunk-OCT4SUJA.js} +4 -4
- package/dist/cli/{chunk-JCTTXLAZ.mjs → chunk-OQ5G7RFQ.mjs} +1 -1
- package/dist/cli/{chunk-XVXEARHC.js → chunk-PFKKZVFK.js} +41 -41
- package/dist/cli/{chunk-F3WRLFFM.mjs → chunk-PFKWKWUJ.mjs} +2 -2
- package/dist/cli/{chunk-I62LJ7NU.mjs → chunk-R457IMHJ.mjs} +1 -1
- package/dist/cli/{chunk-JVEFMOY2.mjs → chunk-RIX26ZJD.mjs} +1 -1
- package/dist/cli/{chunk-QMBL5ZIQ.mjs → chunk-RTDX5NNN.mjs} +3 -3
- package/dist/cli/{chunk-K326BEVR.js → chunk-RUULUCBP.js} +10 -10
- package/dist/cli/{chunk-MCXPJYBN.js → chunk-SF4QJVBE.js} +3 -3
- package/dist/cli/{chunk-HUIFUE4L.js → chunk-SMWFOGUT.js} +53 -53
- package/dist/cli/{chunk-LZL6V5M5.mjs → chunk-T43FF5PF.mjs} +2 -2
- package/dist/cli/{chunk-JMMNCJ7Z.js → chunk-TZTWH53O.js} +1 -1
- package/dist/cli/{chunk-U6DLLV3S.mjs → chunk-V2YIBBVT.mjs} +1 -1
- package/dist/cli/{chunk-XYL26236.js → chunk-V4RJ57MA.js} +2 -2
- package/dist/cli/{chunk-N5MLEXZ7.js → chunk-V7KUBDEB.js} +39 -39
- package/dist/cli/{chunk-MT3WG3KR.js → chunk-VHTVXS5A.js} +16 -16
- package/dist/cli/{chunk-H7275EZU.mjs → chunk-WCVIPZWX.mjs} +5 -5
- package/dist/cli/{chunk-SBGKKOCC.js → chunk-WOEPDSO3.js} +26 -26
- package/dist/cli/{chunk-MHTRYBXY.mjs → chunk-XURWFEXM.mjs} +31 -23
- package/dist/cli/{chunk-7M5FRSFP.mjs → chunk-YCIXY66B.mjs} +2 -2
- package/dist/cli/{chunk-6OZ2WSHD.mjs → chunk-YGOI5ZE5.mjs} +1 -1
- package/dist/cli/{chunk-DNXP3D5H.mjs → chunk-YKFW3NNA.mjs} +5 -5
- package/dist/cli/{chunk-7GNKAACY.js → chunk-YXVYPYIP.js} +6 -6
- package/dist/cli/{chunk-RQN4PHRE.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-YFJ2JLUP.mjs → csv-HT2JBCW2.mjs} +4 -4
- package/dist/cli/{csv-UBACJK75.js → csv-Q2LWKXAV.js} +13 -13
- package/dist/cli/{db-NKGYTAQO.mjs → db-CS3XQ2LX.mjs} +6 -6
- package/dist/cli/{db-2ZPA2LZ7.js → db-XEV4WEE4.js} +27 -27
- package/dist/cli/describe-5G5NXO5E.js +50 -0
- package/dist/cli/{describe-GX7DRKWZ.mjs → describe-OUTXLDGZ.mjs} +18 -18
- package/dist/cli/describe-core.d.mts +2 -2
- package/dist/cli/describe-core.d.ts +2 -2
- package/dist/cli/{executions-NXMRGPIL.js → executions-JCC34WAD.js} +8 -8
- package/dist/cli/{executions-HTHQ7KKD.mjs → executions-L6XFG5MP.mjs} +6 -6
- package/dist/cli/{feedback-USP4T34P.mjs → feedback-AWBDO5I6.mjs} +5 -5
- package/dist/cli/{feedback-TGVQACRO.js → feedback-HV2M2G7N.js} +10 -10
- package/dist/cli/git-GDPTG52F.js +25 -0
- package/dist/cli/{git-KUONEHCD.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-B2GMHU42.mjs → legacy-noops-7MOKBL4O.mjs} +6 -6
- package/dist/cli/{legacy-noops-2JY3CQ24.js → legacy-noops-RGSZUD6V.js} +9 -9
- package/dist/cli/{monitors-XI6I52AX.js → monitors-JEFM2C5W.js} +100 -100
- package/dist/cli/{monitors-2OVBZJ6Z.mjs → monitors-XQNXDZPQ.mjs} +7 -7
- package/dist/cli/{org-5TUQ2H6Y.js → org-GYLA5V32.js} +86 -86
- package/dist/cli/{org-BNJW764Y.mjs → org-KTMJZGTN.mjs} +6 -6
- package/dist/cli/{pages-UXCLX53Y.js → pages-RY4U7OCL.js} +18 -18
- package/dist/cli/{pages-QC3TQIPW.mjs → pages-WOMU2T2O.mjs} +6 -6
- package/dist/cli/{play-KRWMZ7FG.js → play-2Q6MWJ3D.js} +363 -323
- package/dist/cli/{play-45PPG5SZ.mjs → play-KOYGGNYS.mjs} +64 -24
- package/dist/cli/{providers-JDT35MRL.mjs → providers-7YKDITJC.mjs} +6 -6
- package/dist/cli/{providers-RBUJ72Y3.js → providers-HOIRHMN2.js} +9 -9
- package/dist/cli/{quickstart-JZ4Q3HFT.js → quickstart-OWCJOSQA.js} +6 -6
- package/dist/cli/{quickstart-GD2SWGAC.mjs → quickstart-RDXHSMVX.mjs} +4 -4
- package/dist/cli/{run-JEAHA367.js → run-MT2ABKO5.js} +41 -41
- package/dist/cli/{run-KIZ3HBI2.mjs → run-RT73NDP5.mjs} +23 -23
- package/dist/cli/search-7VBA6IGS.js +33 -0
- package/dist/cli/{search-5UFNXHFK.mjs → search-CJPKIGSA.mjs} +8 -8
- package/dist/cli/{search-output-HAXPKQO6.mjs → search-output-AREMA544.mjs} +4 -4
- package/dist/cli/{search-output-W3RDSVLE.js → search-output-OSBZ7WK6.js} +6 -6
- package/dist/cli/{secrets-JAWT66B2.mjs → secrets-BTIY2FEJ.mjs} +6 -6
- package/dist/cli/{secrets-PC7C2Q32.js → secrets-OV6KH633.js} +15 -15
- package/dist/cli/{sessions-325V7G35.mjs → sessions-3CO3ZFOD.mjs} +6 -6
- package/dist/cli/sessions-B3WNEWRW.js +18 -0
- package/dist/cli/{settings-FKHTA65P.mjs → settings-7BQIC7QN.mjs} +13 -13
- package/dist/cli/{settings-RGU6Y2QR.js → settings-LBIECYDB.js} +86 -86
- package/dist/cli/{setup-ZMZ7HU2I.js → setup-QZE7QR3F.js} +50 -50
- package/dist/cli/{setup-43GOYTFC.mjs → setup-XPTSNNES.mjs} +10 -10
- package/dist/cli/{skills-Q2VAHSXM.mjs → skills-TGGKIQLT.mjs} +8 -8
- package/dist/cli/skills-TXBRTWEV.js +37 -0
- package/dist/cli/{tools-BUH7ZWDS.mjs → tools-MKIFX2TQ.mjs} +17 -17
- package/dist/cli/tools-RZJV4X3J.js +57 -0
- package/dist/cli/{update-JFALWOHD.mjs → update-5R3D3WNH.mjs} +10 -10
- package/dist/cli/update-YWGGPWUA.js +35 -0
- package/dist/cli/{artifacts-RBHR2DG4.mjs → views-VHKDHHUP.mjs} +76 -76
- package/dist/cli/views-VPWEINIA.js +270 -0
- package/dist/cli/{workflow-YELST32A.js → workflow-7K2VEQ4V.js} +17 -17
- package/dist/cli/{workflow-ISJKLY6X.mjs → workflow-D5DF65N6.mjs} +7 -7
- package/dist/{client-C2N7MofG.d.mts → client-C5_6W8yd.d.mts} +1 -1
- package/dist/{client-core-hmhBi7Ib.d.ts → client-core-B-GPfmaC.d.ts} +43 -43
- package/dist/{client-core-BTkDSKGn.d.mts → client-core-Dob428Z4.d.mts} +43 -43
- package/dist/{client-C7lTRJjw.d.ts → client-iXW4TOat.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 +110 -110
- 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/artifacts-RZTS2JHZ.js +0 -270
- package/dist/cli/auth-DPWYFQR5.js +0 -43
- package/dist/cli/describe-WQZF7MEG.js +0 -50
- package/dist/cli/git-X3SCQREB.js +0 -25
- package/dist/cli/search-6JULJMD7.js +0 -33
- package/dist/cli/sessions-WFUCOJHZ.js +0 -18
- package/dist/cli/skills-3XTQ6FFM.js +0 -37
- package/dist/cli/tools-UK2R4YXQ.js +0 -57
- package/dist/cli/update-LNKPHS54.js +0 -35
|
@@ -295,7 +295,9 @@ import {
|
|
|
295
295
|
executeWithFreshnessReceipt,
|
|
296
296
|
latestCacheResultKey,
|
|
297
297
|
latestCacheResultOutput,
|
|
298
|
+
type LegacySlotSearch,
|
|
298
299
|
parseLatestCacheResult,
|
|
300
|
+
type ReplayMismatchPolicy,
|
|
299
301
|
toolReadSemanticKey,
|
|
300
302
|
} from './freshness-receipt-execution';
|
|
301
303
|
import {
|
|
@@ -654,6 +656,13 @@ function recordReplayCallAdvance(key: string, advance: number): void {
|
|
|
654
656
|
}
|
|
655
657
|
}
|
|
656
658
|
|
|
659
|
+
/**
|
|
660
|
+
* Call-order slots past the highest one allocated in this attempt that the
|
|
661
|
+
* pre-binding slot search also inspects: siblings that started earlier in
|
|
662
|
+
* the original attempt but have not started yet in this one.
|
|
663
|
+
*/
|
|
664
|
+
const LEGACY_SLOT_SEARCH_LOOKAHEAD = 16;
|
|
665
|
+
|
|
657
666
|
function nextReplayableCallIndex(key: string, freshIndex: number): number {
|
|
658
667
|
const indexes = rowContext.getStore()?.replayCallIndexes;
|
|
659
668
|
if (!indexes) return freshIndex;
|
|
@@ -3163,6 +3172,49 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
3163
3172
|
private readonly stepCallIndexByKey = new Map<string, number>();
|
|
3164
3173
|
private readonly toolCallIndexByKey = new Map<string, number>();
|
|
3165
3174
|
private readonly freshnessCallIndexByKey = new Map<string, number>();
|
|
3175
|
+
/**
|
|
3176
|
+
* Call-order artifacts only: the exact-request operation slot of each
|
|
3177
|
+
* call-order invocation id, consumed when the call reaches the freshness
|
|
3178
|
+
* layer. See `freshnessInvocationId`.
|
|
3179
|
+
*/
|
|
3180
|
+
private readonly exactRequestInvocationIds = new Map<
|
|
3181
|
+
string,
|
|
3182
|
+
{
|
|
3183
|
+
exactRequestInvocationId?: string;
|
|
3184
|
+
inputFingerprint: string;
|
|
3185
|
+
/** The invocation id itself is numbered among identical requests. */
|
|
3186
|
+
keyEncodesRequest?: true;
|
|
3187
|
+
/** This call's call-order slot, for the pre-binding slot search. */
|
|
3188
|
+
legacySlot?: { scope: string; index: number };
|
|
3189
|
+
}
|
|
3190
|
+
>();
|
|
3191
|
+
/**
|
|
3192
|
+
* Per call-order scope, for receipts recorded before bindings: whether each
|
|
3193
|
+
* slot read in this attempt held an unbound receipt, and which slots a call
|
|
3194
|
+
* has already proven and taken.
|
|
3195
|
+
*/
|
|
3196
|
+
private readonly legacySlotVerdicts = new Map<
|
|
3197
|
+
string,
|
|
3198
|
+
(unbound: boolean) => void
|
|
3199
|
+
>();
|
|
3200
|
+
private readonly legacySlotScopes = new Map<
|
|
3201
|
+
string,
|
|
3202
|
+
{
|
|
3203
|
+
/** Verdicts of slots allocated but not yet read, by index. */
|
|
3204
|
+
pending: Map<number, Promise<boolean>>;
|
|
3205
|
+
/** A slot of this scope held an unbound receipt in this attempt. */
|
|
3206
|
+
anyUnbound: boolean;
|
|
3207
|
+
/**
|
|
3208
|
+
* Slots taken by a proven pre-binding recovery, with the invocation
|
|
3209
|
+
* that took them. The same invocation may take its slot again (a row
|
|
3210
|
+
* re-entered after provider backpressure restores its call index);
|
|
3211
|
+
* a sibling may not.
|
|
3212
|
+
*/
|
|
3213
|
+
consumed: Map<number, string>;
|
|
3214
|
+
}
|
|
3215
|
+
>();
|
|
3216
|
+
/** Authored calls whose unverified recovery was already reported. */
|
|
3217
|
+
private readonly unverifiedRecoveryReported = new Set<string>();
|
|
3166
3218
|
/**
|
|
3167
3219
|
* Parent-level inline-child aggregates. Maintained only by the single-writer
|
|
3168
3220
|
* progress path (never per child) so concurrent fan-out cannot contend. See
|
|
@@ -4185,10 +4237,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4185
4237
|
* slots. Callers pass the authored request without credentials, auth scope,
|
|
4186
4238
|
* or runtime-assigned keys, so the slot follows the authored effect.
|
|
4187
4239
|
*/
|
|
4188
|
-
private callSlotRequestDigest(request: unknown): string
|
|
4189
|
-
if (this.currentRuntimeSemantics.callSlotIdentity !== 'request_digest') {
|
|
4190
|
-
return undefined;
|
|
4191
|
-
}
|
|
4240
|
+
private callSlotRequestDigest(request: unknown): string {
|
|
4192
4241
|
return sha256Hex(stableStringify(request));
|
|
4193
4242
|
}
|
|
4194
4243
|
|
|
@@ -4196,10 +4245,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4196
4245
|
private fetchCallSlotRequestDigest(
|
|
4197
4246
|
input: string | URL,
|
|
4198
4247
|
init: PlaySecretAwareRequestInit | SecretAwareRequestInit,
|
|
4199
|
-
): string
|
|
4200
|
-
if (this.currentRuntimeSemantics.callSlotIdentity !== 'request_digest') {
|
|
4201
|
-
return undefined;
|
|
4202
|
-
}
|
|
4248
|
+
): string {
|
|
4203
4249
|
const body = typeof init.body === 'string' ? init.body : null;
|
|
4204
4250
|
return this.callSlotRequestDigest({
|
|
4205
4251
|
method: (init.method ?? 'GET').toUpperCase(),
|
|
@@ -4237,23 +4283,215 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4237
4283
|
// Edition 12 numbers same-id calls only among identical requests, so
|
|
4238
4284
|
// parallel calls started in another order on resume keep their own slot.
|
|
4239
4285
|
// Call-order artifacts keep their exact historical scope string.
|
|
4240
|
-
const
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4286
|
+
const exactRequestScope = stableStringify({
|
|
4287
|
+
...slotScope,
|
|
4288
|
+
request: requestDigest ?? null,
|
|
4289
|
+
});
|
|
4290
|
+
const slot = (scope: string) => {
|
|
4291
|
+
const freshIndex = this.freshnessCallIndexByKey.get(scope) ?? 0;
|
|
4292
|
+
this.freshnessCallIndexByKey.set(scope, freshIndex + 1);
|
|
4293
|
+
// Invocation identity follows authored scope and call order. Keep it
|
|
4294
|
+
// separate from the request/auth/action fingerprint used by reusable
|
|
4295
|
+
// result caching, so credential or response-contract changes cannot
|
|
4296
|
+
// mint a second provider operation key for the same authored effect.
|
|
4297
|
+
// A mapped row can be re-entered after provider backpressure; its
|
|
4298
|
+
// replay cursor restores the original call position.
|
|
4299
|
+
const index = nextReplayableCallIndex(`freshness:${scope}`, freshIndex);
|
|
4300
|
+
return { id: sha256Hex(`${scope}:${index}`), index };
|
|
4301
|
+
};
|
|
4302
|
+
if (this.currentRuntimeSemantics.callSlotIdentity === 'request_digest') {
|
|
4303
|
+
const invocationId = slot(exactRequestScope).id;
|
|
4304
|
+
if (requestDigest !== undefined) {
|
|
4305
|
+
this.exactRequestInvocationIds.set(invocationId, {
|
|
4306
|
+
inputFingerprint: requestDigest,
|
|
4307
|
+
keyEncodesRequest: true,
|
|
4308
|
+
});
|
|
4309
|
+
}
|
|
4310
|
+
return invocationId;
|
|
4311
|
+
}
|
|
4312
|
+
// A call-order slot is only a candidate: same-id calls started in another
|
|
4313
|
+
// order on replay take each other's slots. The call also records and
|
|
4314
|
+
// recovers its exact-request slot (numbered among identical requests, as
|
|
4315
|
+
// in edition 12), and the freshness layer verifies the request
|
|
4316
|
+
// fingerprint before returning a call-order slot's result.
|
|
4317
|
+
const callOrderScope = stableStringify(slotScope);
|
|
4318
|
+
const callOrder = slot(callOrderScope);
|
|
4319
|
+
if (requestDigest !== undefined) {
|
|
4320
|
+
this.exactRequestInvocationIds.set(callOrder.id, {
|
|
4321
|
+
exactRequestInvocationId: slot(exactRequestScope).id,
|
|
4322
|
+
inputFingerprint: requestDigest,
|
|
4323
|
+
// Only tools record request identities a slot search can prove.
|
|
4324
|
+
...(operation === 'tool'
|
|
4325
|
+
? { legacySlot: { scope: callOrderScope, index: callOrder.index } }
|
|
4326
|
+
: {}),
|
|
4327
|
+
});
|
|
4328
|
+
if (operation === 'tool') {
|
|
4329
|
+
this.registerLegacySlot(callOrder.id, callOrderScope, callOrder.index);
|
|
4330
|
+
}
|
|
4331
|
+
}
|
|
4332
|
+
return callOrder.id;
|
|
4333
|
+
}
|
|
4334
|
+
|
|
4335
|
+
/**
|
|
4336
|
+
* A tool is a read on replay mismatch only when its metadata proves it: no
|
|
4337
|
+
* invocation-scoped idempotency, no execution fence, not SQL, and either a
|
|
4338
|
+
* provider-declared reusable read (`legacySharedCacheReuseSupport`, which
|
|
4339
|
+
* refuses write/persist tags) or a `read_safe` server-error replay class.
|
|
4340
|
+
* Anything unproven, including a metadata lookup failure, fails loudly.
|
|
4341
|
+
*/
|
|
4342
|
+
private async toolReplayMismatchPolicy(
|
|
4343
|
+
toolId: string,
|
|
4344
|
+
input: Record<string, unknown>,
|
|
4345
|
+
): Promise<ReplayMismatchPolicy> {
|
|
4346
|
+
if (
|
|
4347
|
+
isCustomerDbDatasetTool(toolId) ||
|
|
4348
|
+
isAlwaysFreshIntegrationWriteTool(toolId)
|
|
4349
|
+
) {
|
|
4350
|
+
return 'fail';
|
|
4351
|
+
}
|
|
4352
|
+
try {
|
|
4353
|
+
const [scope, retry, reusable] = await Promise.all([
|
|
4354
|
+
this.#options.getToolIdempotencyScope?.(toolId),
|
|
4355
|
+
this.#options.getToolRetryPolicy?.(toolId, input),
|
|
4356
|
+
this.#options.getToolReusableResultSupport?.(toolId),
|
|
4357
|
+
]);
|
|
4358
|
+
if (scope === 'invocation' || retry?.requiresExecutionFence === true) {
|
|
4359
|
+
return 'fail';
|
|
4360
|
+
}
|
|
4361
|
+
return reusable?.supported === true ||
|
|
4362
|
+
retry?.providerServerErrorReplay === 'read_safe'
|
|
4363
|
+
? 'execute'
|
|
4364
|
+
: 'fail';
|
|
4365
|
+
} catch {
|
|
4366
|
+
return 'fail';
|
|
4367
|
+
}
|
|
4368
|
+
}
|
|
4369
|
+
|
|
4370
|
+
/**
|
|
4371
|
+
* Pre-binding slot search for one call: other call-order slots of its
|
|
4372
|
+
* scope, which a sibling started in another order may hold its own result
|
|
4373
|
+
* in. Only receipts proven by a recorded request identity are taken, each
|
|
4374
|
+
* at most once per attempt.
|
|
4375
|
+
*/
|
|
4376
|
+
/**
|
|
4377
|
+
* Registered when the slot is allocated, in allocation order, so a later
|
|
4378
|
+
* sibling can wait for this slot's verdict. Settled by the freshness layer
|
|
4379
|
+
* once the slot is read, or by `settleLegacySlot` when the call ends first.
|
|
4380
|
+
* A scope without unbound receipts is dropped once its slots settle, so
|
|
4381
|
+
* runs without pre-binding receipts keep no state here.
|
|
4382
|
+
*/
|
|
4383
|
+
private registerLegacySlot(
|
|
4384
|
+
invocationId: string,
|
|
4385
|
+
scopeKey: string,
|
|
4386
|
+
index: number,
|
|
4387
|
+
): void {
|
|
4388
|
+
// A re-entered row reuses its slot; release the earlier registration.
|
|
4389
|
+
this.settleLegacySlot(invocationId, { keepSlotEntry: true });
|
|
4390
|
+
let scope = this.legacySlotScopes.get(scopeKey);
|
|
4391
|
+
if (!scope) {
|
|
4392
|
+
scope = { pending: new Map(), anyUnbound: false, consumed: new Map() };
|
|
4393
|
+
this.legacySlotScopes.set(scopeKey, scope);
|
|
4394
|
+
}
|
|
4395
|
+
const state = scope;
|
|
4396
|
+
let resolve!: (unbound: boolean) => void;
|
|
4397
|
+
const verdict: Promise<boolean> = new Promise<boolean>(
|
|
4398
|
+
(settle) => (resolve = settle),
|
|
4399
|
+
).then((unbound) => {
|
|
4400
|
+
if (unbound) state.anyUnbound = true;
|
|
4401
|
+
if (state.pending.get(index) === verdict) state.pending.delete(index);
|
|
4402
|
+
if (
|
|
4403
|
+
state.pending.size === 0 &&
|
|
4404
|
+
!state.anyUnbound &&
|
|
4405
|
+
state.consumed.size === 0 &&
|
|
4406
|
+
this.legacySlotScopes.get(scopeKey) === state
|
|
4407
|
+
) {
|
|
4408
|
+
this.legacySlotScopes.delete(scopeKey);
|
|
4409
|
+
}
|
|
4410
|
+
return unbound;
|
|
4411
|
+
});
|
|
4412
|
+
state.pending.set(index, verdict);
|
|
4413
|
+
this.legacySlotVerdicts.set(invocationId, resolve);
|
|
4414
|
+
}
|
|
4415
|
+
|
|
4416
|
+
/** The call ended (or never reached the freshness layer): release waiters. */
|
|
4417
|
+
private settleLegacySlot(
|
|
4418
|
+
invocationId: string,
|
|
4419
|
+
options?: { keepSlotEntry: true },
|
|
4420
|
+
): void {
|
|
4421
|
+
this.legacySlotVerdicts.get(invocationId)?.(false);
|
|
4422
|
+
this.legacySlotVerdicts.delete(invocationId);
|
|
4423
|
+
if (!options?.keepSlotEntry) {
|
|
4424
|
+
this.exactRequestInvocationIds.delete(invocationId);
|
|
4425
|
+
}
|
|
4426
|
+
}
|
|
4427
|
+
|
|
4428
|
+
private legacySlotSearch(
|
|
4429
|
+
invocationId: string,
|
|
4430
|
+
slot: { scope: string; index: number },
|
|
4431
|
+
): LegacySlotSearch {
|
|
4432
|
+
const scope = this.legacySlotScopes.get(slot.scope)!;
|
|
4433
|
+
const verdict = this.legacySlotVerdicts.get(invocationId);
|
|
4434
|
+
return {
|
|
4435
|
+
ownIndex: slot.index,
|
|
4436
|
+
reportOwnSlot: (unbound) => verdict?.(unbound),
|
|
4437
|
+
priorSlotsUnbound: async () => {
|
|
4438
|
+
await Promise.all(
|
|
4439
|
+
[...scope.pending]
|
|
4440
|
+
.filter(([index]) => index < slot.index)
|
|
4441
|
+
.map(([, observed]) => observed),
|
|
4442
|
+
);
|
|
4443
|
+
return scope.anyUnbound;
|
|
4444
|
+
},
|
|
4445
|
+
candidates: () => {
|
|
4446
|
+
const candidates: Array<{ index: number; invocationId: string }> = [];
|
|
4447
|
+
const allocated = Math.max(
|
|
4448
|
+
this.freshnessCallIndexByKey.get(slot.scope) ?? 0,
|
|
4449
|
+
slot.index + 1,
|
|
4450
|
+
);
|
|
4451
|
+
const end = allocated + LEGACY_SLOT_SEARCH_LOOKAHEAD;
|
|
4452
|
+
for (let index = 0; index < end; index += 1) {
|
|
4453
|
+
const claimant = scope.consumed.get(index);
|
|
4454
|
+
if (
|
|
4455
|
+
index === slot.index ||
|
|
4456
|
+
(claimant !== undefined && claimant !== invocationId)
|
|
4457
|
+
) {
|
|
4458
|
+
continue;
|
|
4459
|
+
}
|
|
4460
|
+
candidates.push({
|
|
4461
|
+
index,
|
|
4462
|
+
invocationId: sha256Hex(`${slot.scope}:${index}`),
|
|
4463
|
+
});
|
|
4464
|
+
}
|
|
4465
|
+
return candidates;
|
|
4466
|
+
},
|
|
4467
|
+
consume: (index) => {
|
|
4468
|
+
const claimant = scope.consumed.get(index);
|
|
4469
|
+
if (claimant !== undefined && claimant !== invocationId) return false;
|
|
4470
|
+
scope.consumed.set(index, invocationId);
|
|
4471
|
+
return true;
|
|
4472
|
+
},
|
|
4473
|
+
};
|
|
4474
|
+
}
|
|
4475
|
+
|
|
4476
|
+
/** Rate-limited: once per authored call per run context. */
|
|
4477
|
+
private reportLegacyOperationRecovery(
|
|
4478
|
+
operation: DurableCtxOperation,
|
|
4479
|
+
id: string,
|
|
4480
|
+
): void {
|
|
4481
|
+
const reportKey = `${operation}:${id}`;
|
|
4482
|
+
if (this.unverifiedRecoveryReported.has(reportKey)) return;
|
|
4483
|
+
this.unverifiedRecoveryReported.add(reportKey);
|
|
4484
|
+
this.runtimeLog(
|
|
4485
|
+
JSON.stringify({
|
|
4486
|
+
event: 'durable_operation_recovery_legacy_proven',
|
|
4487
|
+
operation,
|
|
4488
|
+
call_key: id,
|
|
4489
|
+
proof: 'recorded_request_identity',
|
|
4490
|
+
}),
|
|
4244
4491
|
);
|
|
4245
|
-
const freshIndex = this.freshnessCallIndexByKey.get(scope) ?? 0;
|
|
4246
|
-
this.freshnessCallIndexByKey.set(scope, freshIndex + 1);
|
|
4247
|
-
// Invocation identity follows authored scope and call order. Keep it
|
|
4248
|
-
// separate from the request/auth/action fingerprint used by reusable
|
|
4249
|
-
// result caching, so credential or response-contract changes cannot mint
|
|
4250
|
-
// a second provider operation key for the same authored effect.
|
|
4251
|
-
// A mapped row can be re-entered after provider backpressure; its replay
|
|
4252
|
-
// cursor restores the original call position.
|
|
4253
|
-
const index = nextReplayableCallIndex(`freshness:${scope}`, freshIndex);
|
|
4254
|
-
return sha256Hex(`${scope}:${index}`);
|
|
4255
4492
|
}
|
|
4256
4493
|
|
|
4494
|
+
|
|
4257
4495
|
private async executeFreshnessControlledCall<T>(input: {
|
|
4258
4496
|
operation: DurableCtxOperation;
|
|
4259
4497
|
id: string;
|
|
@@ -4268,6 +4506,14 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4268
4506
|
/** Names the tool in the shared-cache skip log. */
|
|
4269
4507
|
toolId?: string;
|
|
4270
4508
|
onOutcome?: (value: T, metadata: CallFreshnessMetadata) => T;
|
|
4509
|
+
/**
|
|
4510
|
+
* Whether this call is a read that may execute when its recorded slot
|
|
4511
|
+
* holds a different request. Omitted: it fails loudly instead.
|
|
4512
|
+
*/
|
|
4513
|
+
replayMismatchPolicy?: () => Promise<ReplayMismatchPolicy>;
|
|
4514
|
+
/** See `executeWithFreshnessReceipt`. */
|
|
4515
|
+
legacyRequestIdentities?: () => Promise<readonly string[]>;
|
|
4516
|
+
operationKeyEncodesRequest?: true;
|
|
4271
4517
|
}): Promise<T> {
|
|
4272
4518
|
const orgId = this.#options.orgId?.trim();
|
|
4273
4519
|
if (!orgId) {
|
|
@@ -4275,10 +4521,38 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4275
4521
|
'Freshness-controlled calls require a resolved organization identity.',
|
|
4276
4522
|
);
|
|
4277
4523
|
}
|
|
4524
|
+
const slots = this.exactRequestInvocationIds.get(input.invocationId);
|
|
4525
|
+
this.exactRequestInvocationIds.delete(input.invocationId);
|
|
4278
4526
|
return executeWithFreshnessReceipt({
|
|
4279
4527
|
orgId,
|
|
4280
4528
|
semanticKey: input.semanticKey,
|
|
4281
4529
|
invocationId: input.invocationId,
|
|
4530
|
+
...(slots?.exactRequestInvocationId
|
|
4531
|
+
? { exactRequestInvocationId: slots.exactRequestInvocationId }
|
|
4532
|
+
: {}),
|
|
4533
|
+
...(slots ? { inputFingerprint: slots.inputFingerprint } : {}),
|
|
4534
|
+
...(slots?.keyEncodesRequest || input.operationKeyEncodesRequest
|
|
4535
|
+
? { operationKeyEncodesRequest: true as const }
|
|
4536
|
+
: {}),
|
|
4537
|
+
...(input.legacyRequestIdentities
|
|
4538
|
+
? { legacyRequestIdentities: input.legacyRequestIdentities }
|
|
4539
|
+
: {}),
|
|
4540
|
+
...(slots?.legacySlot &&
|
|
4541
|
+
this.legacySlotScopes.has(slots.legacySlot.scope)
|
|
4542
|
+
? {
|
|
4543
|
+
legacySlotSearch: this.legacySlotSearch(
|
|
4544
|
+
input.invocationId,
|
|
4545
|
+
slots.legacySlot,
|
|
4546
|
+
),
|
|
4547
|
+
}
|
|
4548
|
+
: {}),
|
|
4549
|
+
...(input.replayMismatchPolicy
|
|
4550
|
+
? { replayMismatchPolicy: input.replayMismatchPolicy }
|
|
4551
|
+
: {}),
|
|
4552
|
+
operation: input.operation,
|
|
4553
|
+
callId: input.id,
|
|
4554
|
+
onLegacyRecoveryProven: () =>
|
|
4555
|
+
this.reportLegacyOperationRecovery(input.operation, input.id),
|
|
4282
4556
|
runId: this.currentReceiptOwnerRunId,
|
|
4283
4557
|
receiptOwnerRunId: this.currentReceiptOwnerRunId,
|
|
4284
4558
|
// Launches admitted without run-scoped keys wrote this operation under
|
|
@@ -7192,6 +7466,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
7192
7466
|
onClaimedResult?: (output: T, receiptKey: string) => T;
|
|
7193
7467
|
shouldPersistFailure?: (error: unknown) => boolean;
|
|
7194
7468
|
transient?: boolean;
|
|
7469
|
+
/** A read-only request: executes when its replayed slot holds another. */
|
|
7470
|
+
replayReadSafe?: boolean;
|
|
7195
7471
|
markRunningBeforeExecute?: boolean;
|
|
7196
7472
|
requiresExecutionLock?: boolean;
|
|
7197
7473
|
executionLockTtlMs?: number;
|
|
@@ -7257,6 +7533,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
7257
7533
|
}),
|
|
7258
7534
|
),
|
|
7259
7535
|
policy,
|
|
7536
|
+
replayMismatchPolicy: async () =>
|
|
7537
|
+
opts.replayReadSafe === true ? 'execute' : 'fail',
|
|
7260
7538
|
execute: () => execute(null),
|
|
7261
7539
|
sharesResult: (value) =>
|
|
7262
7540
|
!(
|
|
@@ -14667,6 +14945,27 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
14667
14945
|
toolId: string,
|
|
14668
14946
|
input: Record<string, unknown>,
|
|
14669
14947
|
options?: ToolCallOptions,
|
|
14948
|
+
): Promise<unknown> {
|
|
14949
|
+
let invocationId: string | null = null;
|
|
14950
|
+
try {
|
|
14951
|
+
return await this.executeToolInternalWithSlot(
|
|
14952
|
+
key,
|
|
14953
|
+
toolId,
|
|
14954
|
+
input,
|
|
14955
|
+
options,
|
|
14956
|
+
(allocated) => (invocationId = allocated),
|
|
14957
|
+
);
|
|
14958
|
+
} finally {
|
|
14959
|
+
if (invocationId) this.settleLegacySlot(invocationId);
|
|
14960
|
+
}
|
|
14961
|
+
}
|
|
14962
|
+
|
|
14963
|
+
private async executeToolInternalWithSlot(
|
|
14964
|
+
key: string,
|
|
14965
|
+
toolId: string,
|
|
14966
|
+
input: Record<string, unknown>,
|
|
14967
|
+
options: ToolCallOptions | undefined,
|
|
14968
|
+
onSlotAllocated: (invocationId: string) => void,
|
|
14670
14969
|
): Promise<unknown> {
|
|
14671
14970
|
if (!this.usesExplicitFreshness) {
|
|
14672
14971
|
return this.executeToolLegacyInternal(key, toolId, input, options);
|
|
@@ -14694,6 +14993,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
14694
14993
|
normalizedKey,
|
|
14695
14994
|
this.callSlotRequestDigest({ toolId, input }),
|
|
14696
14995
|
);
|
|
14996
|
+
onSlotAllocated(invocationId);
|
|
14697
14997
|
const sqlTool = isCustomerDbDatasetTool(toolId);
|
|
14698
14998
|
const scalarCustomerDbQuery = sqlTool && input.result_mode === 'rows';
|
|
14699
14999
|
const liveDataset =
|
|
@@ -14767,6 +15067,30 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
14767
15067
|
sqlTool && (sqlMutation || scalarCustomerDbQuery)
|
|
14768
15068
|
? { ...input, operation_key: `${this.historyRunId}:${invocationId}` }
|
|
14769
15069
|
: input;
|
|
15070
|
+
/**
|
|
15071
|
+
* The result-cache keys this call's execution records with its result
|
|
15072
|
+
* (`executeToolLegacyInternal`): each hashes the request input, credential
|
|
15073
|
+
* scope, action version and the run's cache epoch. They prove an unbound
|
|
15074
|
+
* recorded operation is this call's.
|
|
15075
|
+
*/
|
|
15076
|
+
const legacyRequestIdentities =
|
|
15077
|
+
(staleAfterSeconds: number | null | undefined) => async () => {
|
|
15078
|
+
const identity = {
|
|
15079
|
+
toolId,
|
|
15080
|
+
requestInput,
|
|
15081
|
+
executionAuthScopeDigest: authScope?.trim() || null,
|
|
15082
|
+
staleAfterSeconds: this.effectiveToolCallCachePolicy({
|
|
15083
|
+
...options,
|
|
15084
|
+
force: true,
|
|
15085
|
+
staleAfterSeconds,
|
|
15086
|
+
}).staleAfterSeconds,
|
|
15087
|
+
};
|
|
15088
|
+
const [keys, legacy] = await Promise.all([
|
|
15089
|
+
this.compatibleDurableToolCallCacheKeys(identity),
|
|
15090
|
+
this.legacyDurableToolCallCacheKey(identity),
|
|
15091
|
+
]);
|
|
15092
|
+
return legacy ? [...keys, legacy] : keys;
|
|
15093
|
+
};
|
|
14770
15094
|
|
|
14771
15095
|
if (
|
|
14772
15096
|
isAlwaysFreshIntegrationWriteTool(toolId) &&
|
|
@@ -14783,6 +15107,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
14783
15107
|
semanticKey,
|
|
14784
15108
|
invocationId,
|
|
14785
15109
|
policy: { requested: policy.requested, effective: 0 },
|
|
15110
|
+
legacyRequestIdentities: legacyRequestIdentities(0),
|
|
14786
15111
|
execute: async () =>
|
|
14787
15112
|
await this.executeToolLegacyInternal(key, toolId, requestInput, {
|
|
14788
15113
|
...options,
|
|
@@ -14793,6 +15118,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
14793
15118
|
}
|
|
14794
15119
|
|
|
14795
15120
|
if (liveDataset || isAlwaysFreshIntegrationTool(toolId)) {
|
|
15121
|
+
// Never recovered: release the exact-request slot it reserved.
|
|
15122
|
+
this.exactRequestInvocationIds.delete(invocationId);
|
|
14796
15123
|
const value = await this.executeToolLegacyInternal(
|
|
14797
15124
|
key,
|
|
14798
15125
|
toolId,
|
|
@@ -14824,6 +15151,10 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
14824
15151
|
invocationId,
|
|
14825
15152
|
policy,
|
|
14826
15153
|
toolId,
|
|
15154
|
+
replayMismatchPolicy: () => this.toolReplayMismatchPolicy(toolId, input),
|
|
15155
|
+
legacyRequestIdentities: legacyRequestIdentities(
|
|
15156
|
+
options?.staleAfterSeconds,
|
|
15157
|
+
),
|
|
14827
15158
|
...(publishLatestOnRefresh
|
|
14828
15159
|
? { publishLatestOnRefresh: true as const }
|
|
14829
15160
|
: {}),
|
|
@@ -17397,6 +17728,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
17397
17728
|
invocationId,
|
|
17398
17729
|
staleAfterSeconds: options?.staleAfterSeconds,
|
|
17399
17730
|
transient: options?.transient === true,
|
|
17731
|
+
replayReadSafe: reusableReadMethod,
|
|
17400
17732
|
onRecovered: (output) => {
|
|
17401
17733
|
if (!output.ok) {
|
|
17402
17734
|
this.logCtxFetchHttpFailure({
|
|
@@ -17763,6 +18095,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
17763
18095
|
id: normalizedKey,
|
|
17764
18096
|
semanticKey,
|
|
17765
18097
|
invocationId: boundaryId,
|
|
18098
|
+
// The boundary is scoped by the authored semanticKey: an
|
|
18099
|
+
// unbound receipt under it is this declared request's.
|
|
18100
|
+
...(options?.semanticKey?.trim()
|
|
18101
|
+
? { operationKeyEncodesRequest: true as const }
|
|
18102
|
+
: {}),
|
|
17766
18103
|
policy: freshnessPolicy,
|
|
17767
18104
|
completedAt: (value) => value.completedAt,
|
|
17768
18105
|
sharesResult: (value) =>
|