deepline 0.3.528 → 0.3.530
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +60 -0
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +22 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-capacity-policy.ts +3 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-telemetry.ts +123 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +302 -48
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-pool.ts +29 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +43 -16
- package/dist/cli/{auth-PPOTNK4T.mjs → auth-LRWNDQFT.mjs} +5 -5
- package/dist/cli/auth-QFIXECQV.js +43 -0
- package/dist/cli/{billing-3C7T7CUQ.js → billing-5FDPWGCG.js} +79 -79
- package/dist/cli/{billing-OEZUQ2K6.mjs → billing-7T73MRYF.mjs} +6 -6
- package/dist/cli/{chunk-4SBUXDKZ.js → chunk-2FLODRM2.js} +13 -13
- package/dist/cli/{chunk-AFIAVG5T.mjs → chunk-2FLRKNME.mjs} +2 -2
- package/dist/cli/{chunk-B6YWCGVC.mjs → chunk-2LKVNWRA.mjs} +10 -10
- package/dist/cli/{chunk-7WZXUAQW.js → chunk-32NTC5UD.js} +7 -7
- package/dist/cli/{chunk-KLGYBOGZ.mjs → chunk-3MAHDV5C.mjs} +1 -1
- package/dist/cli/{chunk-IYCRX34W.mjs → chunk-4VQ63Y6S.mjs} +5 -5
- package/dist/cli/{chunk-WXHBD6H7.js → chunk-4WPIORJX.js} +1 -1
- package/dist/cli/{chunk-IJAEYEJM.js → chunk-5B37ER3C.js} +3 -3
- package/dist/cli/{chunk-IM5XQ4DG.mjs → chunk-5DJUNUHN.mjs} +5 -5
- package/dist/cli/{chunk-GFGFAAY2.mjs → chunk-5KX3TWBK.mjs} +1 -1
- package/dist/cli/{chunk-FPHAUP55.mjs → chunk-6NG3FRJB.mjs} +5 -5
- package/dist/cli/{chunk-FXYWEKUK.js → chunk-7E7CP5KA.js} +4 -4
- package/dist/cli/{chunk-RFTBMEWL.js → chunk-7WGMCOM6.js} +2 -2
- package/dist/cli/{chunk-GP7E4TE4.mjs → chunk-A5MYJM4K.mjs} +2 -2
- package/dist/cli/{chunk-T4QPRL3P.mjs → chunk-BVY4QRVT.mjs} +3 -3
- package/dist/cli/{chunk-R5ZQVQ3K.js → chunk-C44RZGM5.js} +26 -26
- package/dist/cli/{chunk-G7RTPKRJ.js → chunk-D7Y7I4EE.js} +2 -2
- package/dist/cli/{chunk-36UD7H7Y.js → chunk-E6L3NEFV.js} +41 -41
- package/dist/cli/{chunk-XD2DRBPH.js → chunk-EADHDZW2.js} +6 -6
- package/dist/cli/{chunk-Z25KC5V2.mjs → chunk-ERMDXXP5.mjs} +1 -1
- package/dist/cli/{chunk-MLNH4DK2.js → chunk-GW76IDID.js} +22 -22
- package/dist/cli/{chunk-Z44S7VWO.mjs → chunk-HCWPX2UP.mjs} +2 -2
- package/dist/cli/{chunk-6OLQWQU5.mjs → chunk-I2YXEHDO.mjs} +3 -3
- package/dist/cli/{chunk-HJVNCRXY.mjs → chunk-J6XSBTEX.mjs} +1 -1
- package/dist/cli/{chunk-DCVNL5XN.mjs → chunk-K4Y6CNFV.mjs} +1 -1
- package/dist/cli/{chunk-GCBFSFLA.js → chunk-KEXGBXUG.js} +5 -5
- package/dist/cli/{chunk-CMTY6SVY.mjs → chunk-KI63L5H3.mjs} +2 -2
- package/dist/cli/{chunk-5MJ4CDAQ.js → chunk-KUHH7RW4.js} +44 -44
- package/dist/cli/{chunk-237PKFIQ.js → chunk-L4QR7CYL.js} +14 -14
- package/dist/cli/{chunk-RC5CG5SE.mjs → chunk-LNZILMVK.mjs} +4 -4
- package/dist/cli/{chunk-LU4EA3ET.js → chunk-M4Q4LEMM.js} +2 -2
- package/dist/cli/{chunk-ZFD5FJCZ.js → chunk-MHR3XVJD.js} +5 -5
- package/dist/cli/{chunk-RML3VSTN.mjs → chunk-MVF7ZBJX.mjs} +1 -1
- package/dist/cli/{chunk-OEI7YUEF.js → chunk-MVFKZQ7E.js} +3 -3
- package/dist/cli/{chunk-PS2UYVAE.mjs → chunk-OUM2V7R6.mjs} +6 -6
- package/dist/cli/{chunk-NCOTOGTK.mjs → chunk-QI2LKPW5.mjs} +2 -2
- package/dist/cli/{chunk-ULUI2FEM.mjs → chunk-QQ4LNSY5.mjs} +1 -1
- package/dist/cli/{chunk-GSBKODMU.mjs → chunk-QWEPCX6L.mjs} +2 -2
- package/dist/cli/{chunk-OVZSNBDJ.js → chunk-SJQ7Z3NI.js} +53 -53
- package/dist/cli/{chunk-ADZGTMLU.js → chunk-V4EK7ZZX.js} +98 -98
- package/dist/cli/{chunk-IXEEXYE2.js → chunk-VKVLJTW5.js} +9 -9
- package/dist/cli/{chunk-NZM4KWWV.mjs → chunk-VQMGCNX2.mjs} +5 -5
- package/dist/cli/{chunk-OGVUT2KM.js → chunk-VYSQ76RP.js} +7 -7
- package/dist/cli/{chunk-42ZSDTOC.mjs → chunk-WAWOMHWO.mjs} +2 -2
- package/dist/cli/{chunk-B3HQF2CA.js → chunk-WWLIDAVT.js} +11 -11
- package/dist/cli/{chunk-7X3NLHI7.js → chunk-WYI3VMTO.js} +6 -6
- package/dist/cli/{chunk-LT4IEJ6V.js → chunk-X547OW3I.js} +16 -16
- package/dist/cli/{chunk-KWIKFR7Y.mjs → chunk-XNWS2WJG.mjs} +1 -1
- package/dist/cli/{chunk-KHVCHFE3.js → chunk-YI7QOP6L.js} +16 -16
- package/dist/cli/{chunk-SP2KZ7SH.mjs → chunk-YVLPGYRS.mjs} +1 -1
- package/dist/cli/{csv-OTRVTHD2.js → csv-EFIEDJA2.js} +13 -13
- package/dist/cli/{csv-K7TRWOFJ.mjs → csv-VY2S7KKV.mjs} +4 -4
- package/dist/cli/{db-UO2ZFLFN.js → db-3DLI5TYW.js} +27 -27
- package/dist/cli/{db-C7GQU3TZ.mjs → db-D32CBDTN.mjs} +6 -6
- package/dist/cli/{describe-LG4CPTIV.mjs → describe-6MYKK2P3.mjs} +18 -18
- package/dist/cli/describe-U6HM52X6.js +50 -0
- package/dist/cli/{executions-LHFVPO7E.js → executions-QG3DEEY3.js} +8 -8
- package/dist/cli/{executions-P3INNVZE.mjs → executions-U6TPX4RX.mjs} +6 -6
- package/dist/cli/{feedback-H22FWG63.mjs → feedback-YZ6H4VMQ.mjs} +6 -6
- package/dist/cli/{feedback-M3HZQAWX.js → feedback-ZSPW6NXL.js} +14 -14
- package/dist/cli/{git-G2N7PVFI.mjs → git-ENN72IK4.mjs} +5 -5
- package/dist/cli/git-OBV73OVY.js +25 -0
- package/dist/cli/index.js +141 -141
- package/dist/cli/index.mjs +43 -43
- package/dist/cli/{legacy-noops-LDYSWTL2.mjs → legacy-noops-MNA6LWJU.mjs} +6 -6
- package/dist/cli/{legacy-noops-2RVROWBY.js → legacy-noops-Q6EVYIGN.js} +9 -9
- package/dist/cli/{monitors-U4RE6KN5.js → monitors-BUH54HXJ.js} +100 -100
- package/dist/cli/{monitors-IYT3VON7.mjs → monitors-KENWEEWC.mjs} +7 -7
- package/dist/cli/{org-SO52ZGRP.js → org-AHWQJMV7.js} +86 -86
- package/dist/cli/{org-R3JE22GS.mjs → org-HWOHKYP3.mjs} +6 -6
- package/dist/cli/{pages-5RLT5YTF.mjs → pages-I7DYTCW6.mjs} +6 -6
- package/dist/cli/{pages-SWXJQJXH.js → pages-Z5R7NYEF.js} +18 -18
- package/dist/cli/{play-J4UXOQOJ.js → play-3LXZB4ED.js} +317 -317
- package/dist/cli/{play-2ELYCSXZ.mjs → play-ET7CRVWJ.mjs} +18 -18
- package/dist/cli/{providers-IXITXHTS.mjs → providers-GZSAZVHZ.mjs} +6 -6
- package/dist/cli/{providers-VVUDGV2D.js → providers-ZV2E7NGX.js} +9 -9
- package/dist/cli/{quickstart-HQCGDPPL.mjs → quickstart-5746NBS2.mjs} +4 -4
- package/dist/cli/{quickstart-XPH6MT47.js → quickstart-VJZAT4RY.js} +6 -6
- package/dist/cli/{run-OR646AC6.js → run-WGUAVYZC.js} +41 -41
- package/dist/cli/{run-H2HQPWC4.mjs → run-WOQ6XMTT.mjs} +23 -23
- package/dist/cli/search-IGHNMXI4.js +33 -0
- package/dist/cli/{search-MBPI5SBW.mjs → search-NNPFJYEW.mjs} +8 -8
- package/dist/cli/{search-output-CYOMJNRV.mjs → search-output-65HDEEFS.mjs} +4 -4
- package/dist/cli/{search-output-YGNSHBXX.js → search-output-K4ISMPKD.js} +6 -6
- package/dist/cli/{secrets-HVZKNNLZ.js → secrets-NBKGWMF4.js} +15 -15
- package/dist/cli/{secrets-NK2CN7WI.mjs → secrets-RK44OV3X.mjs} +6 -6
- package/dist/cli/{sessions-NY4G427U.mjs → sessions-ULQJJN3J.mjs} +6 -6
- package/dist/cli/sessions-ZJNV4SEL.js +22 -0
- package/dist/cli/{settings-PVJRDEN2.js → settings-IHNA7X3Y.js} +86 -86
- package/dist/cli/{settings-RC4FGYY2.mjs → settings-V5ZRL2EF.mjs} +13 -13
- package/dist/cli/{setup-YT3XSY6X.mjs → setup-54VZPJGM.mjs} +10 -10
- package/dist/cli/{setup-B7QB4YV2.js → setup-HTEBFMOQ.js} +50 -50
- package/dist/cli/{skills-5ILFNAHR.mjs → skills-3FCPWMHX.mjs} +8 -8
- package/dist/cli/skills-ZCJ6FOOK.js +37 -0
- package/dist/cli/{tools-7PAY32OZ.mjs → tools-2NTDNUQT.mjs} +17 -17
- package/dist/cli/tools-Q75XC2BS.js +57 -0
- package/dist/cli/{update-Z27QYB6O.mjs → update-25MTBTGU.mjs} +10 -10
- package/dist/cli/update-3G3GO7IE.js +35 -0
- package/dist/cli/{views-NP2SCMOV.js → views-37K4JNNS.js} +18 -18
- package/dist/cli/{views-2IANF6KR.mjs → views-OBE5LUSW.mjs} +6 -6
- package/dist/cli/{workflow-2GNQL646.js → workflow-6YTIHHJH.js} +17 -17
- package/dist/cli/{workflow-CAMEZLLY.mjs → workflow-HAPCL4K6.mjs} +7 -7
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +104 -104
- 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.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-CWJZYLTB.js +0 -43
- package/dist/cli/describe-IK4UYJ5M.js +0 -50
- package/dist/cli/git-72ADWRUQ.js +0 -25
- package/dist/cli/search-D27DZH2D.js +0 -33
- package/dist/cli/sessions-MTISSOZ4.js +0 -22
- package/dist/cli/skills-BHF35NLX.js +0 -37
- package/dist/cli/tools-W5BZ37L6.js +0 -57
- package/dist/cli/update-M65CGK42.js +0 -35
|
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
|
|
|
205
205
|
// getters keep their established compatibility behavior.
|
|
206
206
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
207
207
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
208
|
-
version: '0.3.
|
|
208
|
+
version: '0.3.530',
|
|
209
209
|
updateSummary: {
|
|
210
210
|
introducedIn: '0.3.90',
|
|
211
211
|
summary:
|
|
@@ -4423,6 +4423,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4423
4423
|
replayMismatchPolicy?: () => Promise<ReplayMismatchPolicy>;
|
|
4424
4424
|
/** See `executeWithFreshnessReceipt`. */
|
|
4425
4425
|
legacyRequestIdentities?: () => Promise<readonly string[] | null>;
|
|
4426
|
+
/** See `executeWithFreshnessReceipt`. */
|
|
4427
|
+
legacyOwnOccurrenceIdentities?: () => Promise<readonly string[]>;
|
|
4426
4428
|
operationKeyEncodesRequest?: true;
|
|
4427
4429
|
}): Promise<T> {
|
|
4428
4430
|
const orgId = this.#options.orgId?.trim();
|
|
@@ -4447,6 +4449,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
4447
4449
|
...(input.legacyRequestIdentities
|
|
4448
4450
|
? { legacyRequestIdentities: input.legacyRequestIdentities }
|
|
4449
4451
|
: {}),
|
|
4452
|
+
...(input.legacyOwnOccurrenceIdentities
|
|
4453
|
+
? {
|
|
4454
|
+
legacyOwnOccurrenceIdentities: input.legacyOwnOccurrenceIdentities,
|
|
4455
|
+
}
|
|
4456
|
+
: {}),
|
|
4450
4457
|
...(input.replayMismatchPolicy
|
|
4451
4458
|
? { replayMismatchPolicy: input.replayMismatchPolicy }
|
|
4452
4459
|
: {}),
|
|
@@ -15010,6 +15017,55 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15010
15017
|
// operation key.
|
|
15011
15018
|
return cacheKeys;
|
|
15012
15019
|
};
|
|
15020
|
+
/**
|
|
15021
|
+
* An invocation-scoped tool scoped its recorded result keys by the run
|
|
15022
|
+
* and its logical call id: the digest of its tool-layer occurrence key
|
|
15023
|
+
* (authored id, row/workflow scope and request identity) and its
|
|
15024
|
+
* occurrence index among identical requests. Recomputed for this call's
|
|
15025
|
+
* own reserved index, an exact match names the same (id, scope, request,
|
|
15026
|
+
* index) occurrence. A miss proves nothing: an older build numbered
|
|
15027
|
+
* occurrences at the tool layer, so a recovered sibling may have shifted
|
|
15028
|
+
* the index. Those calls execute as before.
|
|
15029
|
+
*/
|
|
15030
|
+
const ownOccurrenceIdentities =
|
|
15031
|
+
(staleAfterSeconds: number | null | undefined) => async () => {
|
|
15032
|
+
if (
|
|
15033
|
+
reservedCallIndexKey === undefined ||
|
|
15034
|
+
reservedCallIndex === undefined
|
|
15035
|
+
) {
|
|
15036
|
+
return [];
|
|
15037
|
+
}
|
|
15038
|
+
const [idempotencyScope, eventWait] = await Promise.all([
|
|
15039
|
+
this.#options.getToolIdempotencyScope?.(toolId),
|
|
15040
|
+
this.#options.getIntegrationEventWaitHandler?.(toolId),
|
|
15041
|
+
]);
|
|
15042
|
+
if (eventWait || idempotencyScope !== 'invocation') return [];
|
|
15043
|
+
const identity = {
|
|
15044
|
+
toolId,
|
|
15045
|
+
requestInput,
|
|
15046
|
+
executionAuthScopeDigest: authScope?.trim() || null,
|
|
15047
|
+
staleAfterSeconds: this.effectiveToolCallCachePolicy({
|
|
15048
|
+
...options,
|
|
15049
|
+
force: true,
|
|
15050
|
+
staleAfterSeconds,
|
|
15051
|
+
}).staleAfterSeconds,
|
|
15052
|
+
};
|
|
15053
|
+
const [keys, legacy] = await Promise.all([
|
|
15054
|
+
this.compatibleDurableToolCallCacheKeys(identity),
|
|
15055
|
+
this.legacyDurableToolCallCacheKey(identity),
|
|
15056
|
+
]);
|
|
15057
|
+
const invocationIdentity = `${this.historyRunId}:${stableDigest(
|
|
15058
|
+
`${reservedCallIndexKey}:${reservedCallIndex}`,
|
|
15059
|
+
)}`;
|
|
15060
|
+
return (legacy ? [...keys, legacy] : keys).map((receiptKey) =>
|
|
15061
|
+
scopeToolReceiptToInvocation({
|
|
15062
|
+
orgId: this.#options.orgId,
|
|
15063
|
+
toolId,
|
|
15064
|
+
receiptKey,
|
|
15065
|
+
invocationIdentity,
|
|
15066
|
+
}),
|
|
15067
|
+
);
|
|
15068
|
+
};
|
|
15013
15069
|
|
|
15014
15070
|
if (
|
|
15015
15071
|
isAlwaysFreshIntegrationWriteTool(toolId) &&
|
|
@@ -15027,6 +15083,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15027
15083
|
invocationId,
|
|
15028
15084
|
policy: { requested: policy.requested, effective: 0 },
|
|
15029
15085
|
legacyRequestIdentities: once(legacyIdentities(0)),
|
|
15086
|
+
legacyOwnOccurrenceIdentities: once(ownOccurrenceIdentities(0)),
|
|
15030
15087
|
execute: async (_publication, replay) =>
|
|
15031
15088
|
await this.executeToolLegacyInternal(
|
|
15032
15089
|
key,
|
|
@@ -15082,6 +15139,9 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
15082
15139
|
legacyRequestIdentities: once(
|
|
15083
15140
|
legacyIdentities(options?.staleAfterSeconds),
|
|
15084
15141
|
),
|
|
15142
|
+
legacyOwnOccurrenceIdentities: once(
|
|
15143
|
+
ownOccurrenceIdentities(options?.staleAfterSeconds),
|
|
15144
|
+
),
|
|
15085
15145
|
...(publishLatestOnRefresh
|
|
15086
15146
|
? { publishLatestOnRefresh: true as const }
|
|
15087
15147
|
: {}),
|
|
@@ -408,6 +408,14 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
408
408
|
* of its recorded identities is in this set. Omitted: no proof exists.
|
|
409
409
|
*/
|
|
410
410
|
legacyRequestIdentities?: () => Promise<readonly string[] | null>;
|
|
411
|
+
/**
|
|
412
|
+
* Identities that can only PROVE an unbound recorded operation is this
|
|
413
|
+
* occurrence's, never disprove it: an invocation-scoped tool's result keys
|
|
414
|
+
* recomputed for this call's own occurrence index. A match reuses the
|
|
415
|
+
* record; a miss proves nothing, so the call is decided as if this were
|
|
416
|
+
* absent.
|
|
417
|
+
*/
|
|
418
|
+
legacyOwnOccurrenceIdentities?: () => Promise<readonly string[]>;
|
|
411
419
|
/**
|
|
412
420
|
* The operation key itself already encodes the authored request (a
|
|
413
421
|
* `ctx.step` with a `semanticKey`): an unbound receipt under it can only be
|
|
@@ -854,7 +862,8 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
854
862
|
: await recordedIdentitiesOf(recorded);
|
|
855
863
|
if (
|
|
856
864
|
input.operationKeyEncodesRequest === true ||
|
|
857
|
-
(await recordedIdentityMatches(recordedIdentities))
|
|
865
|
+
(await recordedIdentityMatches(recordedIdentities)) ||
|
|
866
|
+
(await recordedOwnOccurrenceMatches(recordedIdentities))
|
|
858
867
|
) {
|
|
859
868
|
input.onLegacyRecoveryProven?.();
|
|
860
869
|
return outcome(recorded, 'operation_recovery');
|
|
@@ -911,6 +920,18 @@ export async function executeWithFreshnessReceipt<T>(input: {
|
|
|
911
920
|
}
|
|
912
921
|
return resultRequestIdentities(referent.output);
|
|
913
922
|
};
|
|
923
|
+
const recordedOwnOccurrenceMatches = async (
|
|
924
|
+
recordedIdentities: readonly string[],
|
|
925
|
+
): Promise<boolean> => {
|
|
926
|
+
if (
|
|
927
|
+
!input.legacyOwnOccurrenceIdentities ||
|
|
928
|
+
recordedIdentities.length === 0
|
|
929
|
+
) {
|
|
930
|
+
return false;
|
|
931
|
+
}
|
|
932
|
+
const current = new Set(await input.legacyOwnOccurrenceIdentities());
|
|
933
|
+
return recordedIdentities.some((identity) => current.has(identity));
|
|
934
|
+
};
|
|
914
935
|
const recordedIdentityMatches = async (
|
|
915
936
|
recordedIdentities: readonly string[],
|
|
916
937
|
): Promise<boolean> => {
|
|
@@ -93,8 +93,9 @@ export const RUNTIME_CAPACITY_POLICY = {
|
|
|
93
93
|
* an Absurd execution slot. The fleet-wide limiter paces lifecycle
|
|
94
94
|
* admissions; this semaphore bounds concurrent create/retry ladders in one
|
|
95
95
|
* worker process. A run lends its execution slot from taking a permit
|
|
96
|
-
* until it gets a slot back after its create,
|
|
97
|
-
* 8 slots + twice this many
|
|
96
|
+
* until it gets a slot back after its create, and during its pre-park
|
|
97
|
+
* lifecycle flush, so a worker holds at most 8 slots + twice this many
|
|
98
|
+
* runs + 10 flush loans (`ABSURD_RUNTIME_WORKER_MAX_LENT_SLOTS`).
|
|
98
99
|
*
|
|
99
100
|
* Ten lets the two warm workers reach the limiter's 10 starts a second on
|
|
100
101
|
* their own: a create took 1.5-2.2 s mean in the 2026-11-12 bursts, so
|
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
createTelemetry,
|
|
3
3
|
TELEMETRY_TRIAGE_SCHEMA_VERSION,
|
|
4
4
|
} from '../observability/telemetry';
|
|
5
|
+
import { sha256Hex } from '../plays/row-identity';
|
|
6
|
+
import { readProvenanceTag } from './log-provenance';
|
|
5
7
|
|
|
6
8
|
type PlayRuntimeTelemetryInput = {
|
|
7
9
|
phase: string;
|
|
@@ -353,3 +355,124 @@ export function emitPlayRunResumeDecision(input: PlayRunResumeDecision): void {
|
|
|
353
355
|
},
|
|
354
356
|
});
|
|
355
357
|
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* A runner-decided durable replay refusal, read back from the structured
|
|
361
|
+
* `durable_replay_refused` run-log record the runner writes where it refuses
|
|
362
|
+
* (`reportReplayRefusal` in `context.ts`). Runner stderr is not shipped from
|
|
363
|
+
* Modal or Daytona sandboxes, so the server that ingests the run's log lines
|
|
364
|
+
* re-emits each record as one fleet-visible line.
|
|
365
|
+
*/
|
|
366
|
+
export type DurableReplayRefusalRecord = {
|
|
367
|
+
code: string;
|
|
368
|
+
operation: string;
|
|
369
|
+
rung: string;
|
|
370
|
+
reason: string;
|
|
371
|
+
slot: string | null;
|
|
372
|
+
ordinal: number | null;
|
|
373
|
+
/** The runner's running count for this code, operation and authored id. */
|
|
374
|
+
refusalCount: number;
|
|
375
|
+
/** Fingerprint of the authored call id: a dedupe key, never the id itself. */
|
|
376
|
+
callKeyHash: string;
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const RUN_LOG_RECORD_FRAME =
|
|
380
|
+
/^\[[^\]\s]+\] (?:\[(?:debug|info|warn|error)\] )?(\{[\s\S]*\})$/u;
|
|
381
|
+
const DURABLE_REPLAY_REFUSAL_CODE = /^DURABLE_REPLAY_[A-Z_]{1,64}$/;
|
|
382
|
+
|
|
383
|
+
function shortFingerprint(value: string): string {
|
|
384
|
+
return sha256Hex(value).slice(0, 16);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* The refusal carried by one ingested run-log line, or null. Only the
|
|
389
|
+
* runtime's own structured record counts: a customer-authored line
|
|
390
|
+
* (`ctx.log` and captured console output are always tagged `user`) never
|
|
391
|
+
* does, whatever its text, and the record must be the line's whole JSON
|
|
392
|
+
* object with `event: 'durable_replay_refused'`. The runner already
|
|
393
|
+
* rate-limits each refusal key to counts 1, 2, 4, 8 and so on; a record off
|
|
394
|
+
* that sequence is not forwarded, so the server line keeps the same limit.
|
|
395
|
+
*/
|
|
396
|
+
export function durableReplayRefusalFromRunLogLine(
|
|
397
|
+
line: unknown,
|
|
398
|
+
): DurableReplayRefusalRecord | null {
|
|
399
|
+
if (typeof line !== 'string' || line.length === 0) return null;
|
|
400
|
+
const tagged = readProvenanceTag(line.trim());
|
|
401
|
+
if (tagged.provenance !== null && tagged.provenance !== 'diagnostic') {
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
const json = tagged.line.match(RUN_LOG_RECORD_FRAME)?.[1];
|
|
405
|
+
if (!json) return null;
|
|
406
|
+
let record: unknown;
|
|
407
|
+
try {
|
|
408
|
+
record = JSON.parse(json);
|
|
409
|
+
} catch {
|
|
410
|
+
return null;
|
|
411
|
+
}
|
|
412
|
+
if (!record || typeof record !== 'object' || Array.isArray(record)) {
|
|
413
|
+
return null;
|
|
414
|
+
}
|
|
415
|
+
const fields = record as Record<string, unknown>;
|
|
416
|
+
if (fields.event !== 'durable_replay_refused') return null;
|
|
417
|
+
const code = fields.code;
|
|
418
|
+
if (typeof code !== 'string' || !DURABLE_REPLAY_REFUSAL_CODE.test(code)) {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
const refusalCount = durabilityDecisionCount(fields.refusal_count);
|
|
422
|
+
if (
|
|
423
|
+
refusalCount === null ||
|
|
424
|
+
refusalCount < 1 ||
|
|
425
|
+
(refusalCount & (refusalCount - 1)) !== 0
|
|
426
|
+
) {
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
return {
|
|
430
|
+
code,
|
|
431
|
+
operation: durabilityDecisionReason(fields.operation),
|
|
432
|
+
rung: durabilityDecisionReason(fields.rung),
|
|
433
|
+
reason: durabilityDecisionReason(fields.reason),
|
|
434
|
+
slot:
|
|
435
|
+
fields.slot === undefined || fields.slot === null
|
|
436
|
+
? null
|
|
437
|
+
: durabilityDecisionReason(fields.slot),
|
|
438
|
+
ordinal: durabilityDecisionCount(fields.ordinal),
|
|
439
|
+
refusalCount,
|
|
440
|
+
callKeyHash: shortFingerprint(
|
|
441
|
+
typeof fields.call_key === 'string' ? fields.call_key : '',
|
|
442
|
+
),
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* One line per forwarded runner refusal: `play.run.replay_refused`. Identities
|
|
448
|
+
* come from the ingesting server's authenticated launch, not from the record.
|
|
449
|
+
* Distinct refusals are `dcount(runId, attempt, callKeyHash, code,
|
|
450
|
+
* operation, refusalCount)`: live ingest and terminal replay can both carry one record.
|
|
451
|
+
*/
|
|
452
|
+
export function emitPlayRunReplayRefusal(input: {
|
|
453
|
+
orgId: string | null;
|
|
454
|
+
runId: string;
|
|
455
|
+
playName: string | null;
|
|
456
|
+
attempt: number | null;
|
|
457
|
+
refusal: DurableReplayRefusalRecord;
|
|
458
|
+
}): void {
|
|
459
|
+
emitPlayTelemetry({
|
|
460
|
+
level: 'warn',
|
|
461
|
+
event: 'play.run.replay_refused',
|
|
462
|
+
tag: '[play.run.replay_refused]',
|
|
463
|
+
fields: {
|
|
464
|
+
orgId: input.orgId,
|
|
465
|
+
runId: input.runId,
|
|
466
|
+
playName: input.playName,
|
|
467
|
+
attempt: durabilityDecisionCount(input.attempt),
|
|
468
|
+
code: input.refusal.code,
|
|
469
|
+
operation: input.refusal.operation,
|
|
470
|
+
rung: input.refusal.rung,
|
|
471
|
+
reason: input.refusal.reason,
|
|
472
|
+
slot: input.refusal.slot,
|
|
473
|
+
ordinal: input.refusal.ordinal,
|
|
474
|
+
refusalCount: input.refusal.refusalCount,
|
|
475
|
+
callKeyHash: input.refusal.callKeyHash,
|
|
476
|
+
},
|
|
477
|
+
});
|
|
478
|
+
}
|