deepline 0.3.501 → 0.3.503
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 +26 -0
- package/dist/bundling-sources/sdk/src/index.ts +1 -0
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +9 -0
- package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +0 -8
- package/dist/bundling-sources/shared_libs/observability/dlq.ts +174 -0
- package/dist/bundling-sources/shared_libs/observability/queue-health.ts +9 -0
- package/dist/bundling-sources/shared_libs/observability/queue-item-connectors.ts +1 -0
- package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +20 -2
- package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +20 -0
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +62 -2
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +667 -62
- package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +55 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/vercel-fly-rollback-alignment.ts +29 -14
- package/dist/bundling-sources/shared_libs/play-runtime/durable-receipt-execution.ts +20 -2
- package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +46 -0
- package/dist/bundling-sources/shared_libs/play-runtime/execution-gateway-invocation-fence.ts +80 -4
- package/dist/bundling-sources/shared_libs/play-runtime/fixture-egress-fetch.ts +95 -0
- package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +292 -45
- package/dist/bundling-sources/shared_libs/play-runtime/internal-bootstrap-token.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-http-request.ts +7 -3
- package/dist/bundling-sources/shared_libs/play-runtime/play-runtime-semantics.ts +31 -1
- package/dist/bundling-sources/shared_libs/play-runtime/post-code-recovery-policy.ts +231 -0
- package/dist/bundling-sources/shared_libs/play-runtime/prebuilt-result-quality.ts +264 -0
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ending-event.ts +55 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +126 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +70 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +2 -9
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +51 -19
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/local-process.ts +9 -4
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/runtime-sandbox-reconciliation.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-actions.ts +12 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-authority.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-gateway-oidc.ts +30 -8
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +42 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +7 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +26 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +13 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-deadline-reconciliation.ts +53 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +631 -19
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-inventory.ts +719 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/durable-run-sql.ts +206 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/latest-cache-result.ts +83 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +1453 -160
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/receipt-gateway.ts +61 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +29 -8
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-queue-health.ts +27 -2
- package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +45 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-cache-policy.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +129 -14
- package/dist/bundling-sources/shared_libs/play-runtime/workflow-executor-auth.ts +2 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +10 -1
- package/dist/bundling-sources/shared_libs/product-notifications/slack-delivery.ts +2 -0
- package/dist/cli/{auth-6ECHXOI4.mjs → auth-IC4WLSE3.mjs} +5 -5
- package/dist/cli/auth-ZCMSXZO4.js +43 -0
- package/dist/cli/{billing-75NZYRXA.mjs → billing-2VOV64SD.mjs} +6 -6
- package/dist/cli/{billing-QRR7O6BD.js → billing-LWQOII22.js} +79 -79
- package/dist/cli/{chunk-N2TJJNCW.js → chunk-2626LTU3.js} +291 -273
- package/dist/cli/{chunk-VL72UKNW.js → chunk-26RSSTCF.js} +26 -26
- package/dist/cli/{chunk-HDKXSHGA.js → chunk-2K2QBLYO.js} +53 -53
- package/dist/cli/{chunk-463ZOO2L.js → chunk-33JUK73X.js} +7 -7
- package/dist/cli/{chunk-KTOAJP4N.js → chunk-3CXHK4TW.js} +10 -10
- package/dist/cli/{chunk-YPTZJ7LO.js → chunk-4IIYSBEP.js} +70 -13
- package/dist/cli/{chunk-VTDAJZIJ.mjs → chunk-5GI6NKOE.mjs} +20 -1
- package/dist/cli/{chunk-TFFJ2PRN.mjs → chunk-5M5WSFRZ.mjs} +70 -13
- package/dist/cli/{chunk-5S7MLAI7.mjs → chunk-6XTE6C3W.mjs} +41 -23
- package/dist/cli/{chunk-7L6QNHUL.mjs → chunk-7HEDCIR3.mjs} +1 -1
- package/dist/cli/{chunk-C5R3UH5V.mjs → chunk-7MJYZ33I.mjs} +2 -6
- package/dist/cli/{chunk-TOE7LHEA.js → chunk-A2C6ONWA.js} +6 -6
- package/dist/cli/{chunk-QQ3JJYE2.js → chunk-AARF4SOW.js} +17 -13
- package/dist/cli/{chunk-APAHMCGR.js → chunk-B3X4YWQ6.js} +53 -53
- package/dist/cli/{chunk-J74N375S.mjs → chunk-BI2Q45SY.mjs} +4 -4
- package/dist/cli/{chunk-GBICEYUA.js → chunk-BN5VKY4X.js} +141 -20
- package/dist/cli/{chunk-UR7JOSLT.js → chunk-C5RQTTLP.js} +26 -7
- package/dist/cli/{chunk-ZUOKIBLJ.mjs → chunk-D27HP3HS.mjs} +2 -2
- package/dist/cli/{chunk-UJRN6YP6.mjs → chunk-DPI5OYVU.mjs} +10 -6
- package/dist/cli/{chunk-MSLXAVVK.mjs → chunk-EDMV4JT5.mjs} +2 -2
- package/dist/cli/{chunk-ZUQHQGC5.mjs → chunk-EQ3WMKFY.mjs} +5 -5
- package/dist/cli/{chunk-5X4AUFYW.js → chunk-F73PD2XD.js} +7 -7
- package/dist/cli/{chunk-O3DDVP7Z.mjs → chunk-FHJ54BHH.mjs} +2 -2
- package/dist/cli/{chunk-SV2TEZ2M.js → chunk-FIUTDSJX.js} +5 -4
- package/dist/cli/{chunk-W6JTHVPF.js → chunk-FVDTERO2.js} +21 -21
- package/dist/cli/{chunk-CJJ7JBM2.js → chunk-FZHOWPSN.js} +23 -21
- package/dist/cli/{chunk-WJUDAHIQ.mjs → chunk-GIHNEYBG.mjs} +1 -1
- package/dist/cli/{chunk-V5NHEYU7.mjs → chunk-GLZBFBJS.mjs} +5 -5
- package/dist/cli/{chunk-VVEMPC2I.js → chunk-HRTDCXHI.js} +2 -2
- package/dist/cli/{chunk-BOFCF4L7.js → chunk-HS63YBT5.js} +3 -3
- package/dist/cli/{chunk-4OXHLTCP.js → chunk-IIP46RVC.js} +1 -1
- package/dist/cli/{chunk-SAW3FBCA.mjs → chunk-ITJ7NB2D.mjs} +6 -0
- package/dist/cli/{chunk-NA3J3F2Z.mjs → chunk-J6RBOLK7.mjs} +1 -1
- package/dist/cli/{chunk-PXIF74UJ.mjs → chunk-JJVN7OIX.mjs} +4 -4
- package/dist/cli/{chunk-T7E3XEPG.mjs → chunk-JPDD4Y53.mjs} +10 -8
- package/dist/cli/{chunk-OKOXB3LY.mjs → chunk-K7NFFQFU.mjs} +2 -2
- package/dist/cli/{chunk-66XDYH5T.mjs → chunk-KGLVATEB.mjs} +2 -2
- package/dist/cli/{chunk-EHVFBD36.mjs → chunk-KPBBT6OS.mjs} +2 -1
- package/dist/cli/{chunk-MADTHS56.mjs → chunk-L3TZV625.mjs} +1 -1
- package/dist/cli/{chunk-FS7XYDOF.js → chunk-MJQOG4TZ.js} +16 -16
- package/dist/cli/{chunk-JO5FFSR7.js → chunk-NTLBZUHD.js} +6 -0
- package/dist/cli/{chunk-EKZQ5LQO.js → chunk-PVA3MWCO.js} +3 -3
- package/dist/cli/{chunk-PNF2ZU4R.js → chunk-QIEYEY6Z.js} +8 -8
- package/dist/cli/{chunk-KSHAFYYG.mjs → chunk-R2VZVHJP.mjs} +127 -6
- package/dist/cli/{chunk-XEBFJ2PH.js → chunk-RVOBFO7C.js} +41 -41
- package/dist/cli/{chunk-RU5ROUFO.js → chunk-TCQYWZFS.js} +5 -5
- package/dist/cli/{chunk-I42EOZKQ.js → chunk-TMQUMILM.js} +19 -23
- package/dist/cli/{chunk-EOO7OSS4.mjs → chunk-URZNSJE2.mjs} +4 -4
- package/dist/cli/{chunk-Z6AUOV7D.mjs → chunk-VC5B462T.mjs} +2 -2
- package/dist/cli/{chunk-EKF4DKUA.js → chunk-WHP3FJ7T.js} +5 -5
- package/dist/cli/{chunk-VD2374K7.mjs → chunk-WS274KID.mjs} +1 -1
- package/dist/cli/{chunk-T4U245E4.mjs → chunk-XYZZZLN6.mjs} +2 -2
- package/dist/cli/{chunk-J6SVNKRP.js → chunk-YXGPMTAK.js} +2 -2
- package/dist/cli/{chunk-RFV7PPLS.mjs → chunk-ZEQPCEV4.mjs} +3 -3
- package/dist/cli/command-docs.js +2 -2
- package/dist/cli/command-docs.mjs +1 -1
- package/dist/cli/{csv-RZJ4SOIL.mjs → csv-2TXOI3UE.mjs} +4 -4
- package/dist/cli/{csv-JXX2LXK5.js → csv-NEWCNOSZ.js} +13 -13
- package/dist/cli/{db-T2KJNONM.js → db-J3IJS4OG.js} +27 -27
- package/dist/cli/{db-MUTT2NWI.mjs → db-PX7EQEIG.mjs} +6 -6
- package/dist/cli/{describe-K3UMAAVO.mjs → describe-GQHGTZSL.mjs} +20 -21
- package/dist/cli/describe-LE7EZCL4.js +49 -0
- package/dist/cli/describe-core.d.mts +8 -4
- package/dist/cli/describe-core.d.ts +8 -4
- package/dist/cli/describe-core.js +4 -5
- package/dist/cli/describe-core.mjs +3 -4
- package/dist/cli/{executions-PHS4R2OX.mjs → executions-FFKK24RY.mjs} +6 -6
- package/dist/cli/{executions-7HSLDRHR.js → executions-RO3TJUXL.js} +8 -8
- package/dist/cli/{feedback-BJZRM637.js → feedback-XRR4HIS6.js} +8 -8
- package/dist/cli/{feedback-RWMDCIDF.mjs → feedback-ZTO56SRL.mjs} +4 -4
- package/dist/cli/git-26AH4XIO.js +25 -0
- package/dist/cli/{git-YW6VHYZG.mjs → git-FIPBVFYZ.mjs} +5 -5
- package/dist/cli/index.js +142 -142
- package/dist/cli/index.mjs +42 -42
- package/dist/cli/{legacy-noops-5UBSUPGG.mjs → legacy-noops-AMD2NWHF.mjs} +5 -5
- package/dist/cli/{legacy-noops-2WUV2XD7.js → legacy-noops-MTBBGM27.js} +8 -8
- package/dist/cli/{monitors-HWOQO3OK.mjs → monitors-24LDKDJX.mjs} +7 -7
- package/dist/cli/{monitors-YZZRKSTG.js → monitors-42PIGLBF.js} +95 -95
- package/dist/cli/{org-NCXT6RB4.mjs → org-4B7SCFRL.mjs} +6 -6
- package/dist/cli/{org-JY7HLHBA.js → org-GQMCA3MN.js} +72 -72
- package/dist/cli/{pages-QJO53QAT.mjs → pages-PD5EGL2R.mjs} +6 -6
- package/dist/cli/{pages-6ZOHXL6X.js → pages-RL2M62GJ.js} +18 -18
- package/dist/cli/{play-SQRS7JN3.mjs → play-5V54VTUR.mjs} +132 -26
- package/dist/cli/{play-TAYGSR35.js → play-FST6ZAHW.js} +447 -341
- package/dist/cli/{providers-4Q5LOIQ5.js → providers-HBUUPN7J.js} +9 -9
- package/dist/cli/{providers-3IR3N5DT.mjs → providers-N5YVCKPL.mjs} +6 -6
- package/dist/cli/{quickstart-ITNUZENY.js → quickstart-4QIQNSHG.js} +6 -6
- package/dist/cli/{quickstart-KCZCYO6B.mjs → quickstart-NJDDVTQR.mjs} +4 -4
- package/dist/cli/{run-YQ57LMKN.js → run-FGOKCG4J.js} +44 -45
- package/dist/cli/{run-JCWRWDSK.mjs → run-JHI5MTHD.mjs} +25 -26
- package/dist/cli/search-CTKSEVSO.js +32 -0
- package/dist/cli/{search-FUM27HQP.mjs → search-EWIZBIY2.mjs} +7 -7
- package/dist/cli/{search-output-EWEYT34M.mjs → search-output-NAK3MWBH.mjs} +53 -75
- package/dist/cli/{search-output-XAMWKRJH.js → search-output-TMQTRC2W.js} +58 -80
- package/dist/cli/{secrets-2IRRRZBL.js → secrets-5TSUEOJB.js} +15 -15
- package/dist/cli/{secrets-YTI4IAKR.mjs → secrets-ONQVW5SR.mjs} +6 -6
- package/dist/cli/{sessions-EFS4KUPF.mjs → sessions-B7F5O3ZR.mjs} +5 -5
- package/dist/cli/{sessions-HWTRDXBQ.js → sessions-BSGE5EET.js} +6 -6
- package/dist/cli/{settings-FRVEIOKR.js → settings-47LARBRU.js} +78 -78
- package/dist/cli/{settings-NTOO42DY.mjs → settings-SGGFQV5R.mjs} +11 -11
- package/dist/cli/{setup-PAVQPALX.mjs → setup-ATGNXQUK.mjs} +9 -9
- package/dist/cli/{setup-6ZIOAE2V.js → setup-BNFZFXO6.js} +49 -49
- package/dist/cli/skills-6RD25MVM.js +36 -0
- package/dist/cli/{skills-3O3XTPUM.mjs → skills-CIMBRM5R.mjs} +7 -7
- package/dist/cli/{tools-7QSB65UL.mjs → tools-DTDXAULX.mjs} +18 -19
- package/dist/cli/tools-TDZH4XHS.js +56 -0
- package/dist/cli/{update-T6CYS5ZT.mjs → update-EOIJBJCO.mjs} +9 -9
- package/dist/cli/update-Y32VT4VL.js +34 -0
- package/dist/cli/{workflow-OMSXZ73T.mjs → workflow-IWXUJPWY.mjs} +7 -7
- package/dist/cli/{workflow-4KMJBMGX.js → workflow-V5VKPICQ.js} +17 -17
- package/dist/{client-Bn8FwKGO.d.ts → client-CIwenMFS.d.ts} +1 -1
- package/dist/{client-CfNRmjLK.d.mts → client-DYAfJpaN.d.mts} +1 -1
- package/dist/{client-core-B91EV0WS.d.ts → client-core-CRjtyMAI.d.ts} +25 -2
- package/dist/{client-core-BG8Cgrmk.d.mts → client-core-DlzP8vEs.d.mts} +25 -2
- package/dist/{compiler-manifest-DlXDyndN.d.ts → compiler-manifest-DaJrA2KV.d.mts} +1 -1
- package/dist/{compiler-manifest-DlXDyndN.d.mts → compiler-manifest-DaJrA2KV.d.ts} +1 -1
- package/dist/{errors-BtriA2ld.d.mts → errors-BKnSYueU.d.mts} +1 -1
- package/dist/{errors-DmcLykM7.d.ts → errors-KLga4bLr.d.ts} +1 -1
- package/dist/{index-DI0sR_fX.d.mts → index-C-8AFpWy.d.mts} +1 -1
- package/dist/{index--Jw-slHY.d.ts → index-C5nAZ-VS.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 +124 -118
- 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 +8 -1
- 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/auth-VP7PMXKQ.js +0 -43
- package/dist/cli/chunk-XK5DMLZE.js +0 -111
- package/dist/cli/chunk-XRDXNAAY.mjs +0 -111
- package/dist/cli/describe-SEXUJLE4.js +0 -50
- package/dist/cli/git-VNS7UQWN.js +0 -25
- package/dist/cli/search-I425FRTK.js +0 -32
- package/dist/cli/skills-6ZNMO2PR.js +0 -36
- package/dist/cli/tools-DPV2JES6.js +0 -57
- package/dist/cli/update-Q5GUDEAW.js +0 -34
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type { PlayRunnerResult } from './protocol';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Automatic recovery after customer code has started.
|
|
5
|
+
*
|
|
6
|
+
* A platform failure retries the same run: its next attempt replays the Play
|
|
7
|
+
* from its checkpoint, and every call recorded in the run's history returns
|
|
8
|
+
* its result instead of executing again. Only evidence gathered outside the
|
|
9
|
+
* sandbox can classify a failure as the platform's, because customer code
|
|
10
|
+
* shares the runner's process and could otherwise fake one.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Ladder for post-code platform failures; pre-code keeps its own policy. */
|
|
14
|
+
export const POST_CODE_RECOVERY_BUDGET = {
|
|
15
|
+
baseMs: 60_000,
|
|
16
|
+
maxMs: 5 * 60 * 60_000,
|
|
17
|
+
horizonMs: 24 * 60 * 60_000,
|
|
18
|
+
/** Spread wakes after a shared outage by ±20%. */
|
|
19
|
+
jitterRatio: 0.2,
|
|
20
|
+
/** Hard cap independent of the horizon. */
|
|
21
|
+
maxDefers: 20,
|
|
22
|
+
/**
|
|
23
|
+
* Attempts in a row that may record no new history before the run fails.
|
|
24
|
+
* The first unproductive attempt still earns a retry, because a crash can
|
|
25
|
+
* land before the attempt's first call completes; the second ends the run.
|
|
26
|
+
*/
|
|
27
|
+
maxUnproductiveAttempts: 2,
|
|
28
|
+
} as const;
|
|
29
|
+
|
|
30
|
+
export type PostCodeRecoveryReason =
|
|
31
|
+
/** The provider has no sandbox for the attempt any more. */
|
|
32
|
+
| 'runner_lost_sandbox_missing'
|
|
33
|
+
/** The sandbox stopped without an exit, or on a signal (128 or above). */
|
|
34
|
+
| 'runner_lost_sandbox_stopped'
|
|
35
|
+
/** The runner gave up on the gateway while the worker saw it go silent. */
|
|
36
|
+
| 'control_plane_unreachable'
|
|
37
|
+
/**
|
|
38
|
+
* The retry was held back because an earlier attempt's sandbox deletion is
|
|
39
|
+
* not confirmed yet. Never an attempt outcome; only the start gate records it.
|
|
40
|
+
*/
|
|
41
|
+
| 'earlier_sandbox_deletion_unconfirmed';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Reasons for which the provider has NOT confirmed the lost attempt's sandbox
|
|
45
|
+
* gone. The next attempt (and any release of the lost attempt's receipt
|
|
46
|
+
* claims) waits for its cleanup to be confirmed deleted.
|
|
47
|
+
*/
|
|
48
|
+
export function postCodeRecoveryRequiresSandboxDeletion(
|
|
49
|
+
reason: PostCodeRecoveryReason,
|
|
50
|
+
): boolean {
|
|
51
|
+
return (
|
|
52
|
+
reason === 'runner_lost_sandbox_stopped' ||
|
|
53
|
+
reason === 'control_plane_unreachable'
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Stable machine-detectable prefix of an exhausted post-code recovery. */
|
|
58
|
+
export const PLATFORM_RECOVERY_EXHAUSTED_PREFIX =
|
|
59
|
+
'PLATFORM_RECOVERY_EXHAUSTED:';
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The customer-facing failure once automatic recovery is spent. It stands
|
|
63
|
+
* alone: it never embeds the first attempt's "not retried" explanation, which
|
|
64
|
+
* would contradict the retries that happened.
|
|
65
|
+
*/
|
|
66
|
+
export function platformRecoveryExhaustedMessage(input: {
|
|
67
|
+
retries: number | null;
|
|
68
|
+
savedCalls: number | null;
|
|
69
|
+
}): string {
|
|
70
|
+
const tries =
|
|
71
|
+
input.retries === null
|
|
72
|
+
? 'Deepline retried this run automatically'
|
|
73
|
+
: `Deepline retried this run automatically ${input.retries} ${input.retries === 1 ? 'time' : 'times'}`;
|
|
74
|
+
const saved =
|
|
75
|
+
input.savedCalls === null
|
|
76
|
+
? ''
|
|
77
|
+
: ` ${input.savedCalls} completed ${input.savedCalls === 1 ? 'call was' : 'calls were'} saved, so they are not repeated.`;
|
|
78
|
+
return `${PLATFORM_RECOVERY_EXHAUSTED_PREFIX} Deepline's infrastructure interrupted this run before it finished. ${tries}, but it did not recover.${saved} Start the run again to continue. If this keeps happening, contact support.`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type PostCodeAttemptOutcome =
|
|
82
|
+
| { kind: 'play' }
|
|
83
|
+
| {
|
|
84
|
+
kind: 'platform';
|
|
85
|
+
reason: PostCodeRecoveryReason;
|
|
86
|
+
/**
|
|
87
|
+
* Whether an attempt that recorded nothing counts against the run. An
|
|
88
|
+
* outage stops progress through no fault of the Play.
|
|
89
|
+
*/
|
|
90
|
+
countsTowardProgress: boolean;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* What the worker itself observed about an attempt that ended after customer
|
|
95
|
+
* code started. Only the worker's detached-runner resolver writes it, and
|
|
96
|
+
* {@link withoutWorkerEvidence} removes it from anything the sandbox
|
|
97
|
+
* produced, so it never carries the sandbox's own claims.
|
|
98
|
+
*/
|
|
99
|
+
export type WorkerAttemptEvidence = {
|
|
100
|
+
source: 'runner_lost' | 'salvaged_after_heartbeat_lapse';
|
|
101
|
+
heartbeatAgeMs: number;
|
|
102
|
+
heartbeatTimeoutMs: number;
|
|
103
|
+
inspectionStage: string | null;
|
|
104
|
+
/** The runner's exit code as the sandbox provider reported it. */
|
|
105
|
+
exitCode: number | null;
|
|
106
|
+
/** The sandbox's own return code (Modal reports it for a stopped sandbox). */
|
|
107
|
+
providerReturnCode: number | null;
|
|
108
|
+
reachedRuntimeCeiling: boolean;
|
|
109
|
+
/** Independent worker probe, never inferred from sandbox output or silence. */
|
|
110
|
+
controlPlaneOutageObserved?: boolean;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Stats keys only the worker may write. */
|
|
114
|
+
const WORKER_ONLY_STATS_KEYS = ['workerEvidence', 'runnerLiveness'] as const;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Remove worker-only evidence from a result the sandbox produced: a pushed
|
|
118
|
+
* terminal, or one salvaged from the sandbox's captured output.
|
|
119
|
+
*/
|
|
120
|
+
export function withoutWorkerEvidence<T extends { stats?: unknown }>(
|
|
121
|
+
result: T,
|
|
122
|
+
): T {
|
|
123
|
+
const stats = result.stats;
|
|
124
|
+
if (!stats || typeof stats !== 'object' || Array.isArray(stats)) {
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
if (!WORKER_ONLY_STATS_KEYS.some((key) => Object.hasOwn(stats, key))) {
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
const kept = { ...(stats as Record<string, unknown>) };
|
|
131
|
+
for (const key of WORKER_ONLY_STATS_KEYS) delete kept[key];
|
|
132
|
+
return { ...result, stats: kept };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function workerEvidence(
|
|
136
|
+
result: PlayRunnerResult,
|
|
137
|
+
): WorkerAttemptEvidence | null {
|
|
138
|
+
const evidence = (result.stats as { workerEvidence?: unknown } | undefined)
|
|
139
|
+
?.workerEvidence;
|
|
140
|
+
if (!evidence || typeof evidence !== 'object') return null;
|
|
141
|
+
const value = evidence as Partial<WorkerAttemptEvidence>;
|
|
142
|
+
return value.source === 'runner_lost' ||
|
|
143
|
+
value.source === 'salvaged_after_heartbeat_lapse'
|
|
144
|
+
? (value as WorkerAttemptEvidence)
|
|
145
|
+
: null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Decide whether an attempt that ended after customer code started failed
|
|
150
|
+
* because of the platform. Everything that is not proven to be the
|
|
151
|
+
* platform's is the Play's: a Play that exits, crashes or throws fails.
|
|
152
|
+
*
|
|
153
|
+
* - The provider has no sandbox: platform.
|
|
154
|
+
* - The sandbox stopped with no exit code, or on a signal (128 or above):
|
|
155
|
+
* platform. Out-of-memory exits look the same; the no-progress rule bounds
|
|
156
|
+
* them.
|
|
157
|
+
* - The runner reported the gateway unreachable after its heartbeat lapsed,
|
|
158
|
+
* and an independent worker probe observed an outage: platform, and the
|
|
159
|
+
* attempt is not held against the run's progress.
|
|
160
|
+
* - Reaching the runtime ceiling is always the Play's.
|
|
161
|
+
*/
|
|
162
|
+
export function classifyPostCodeAttemptOutcome(
|
|
163
|
+
result: PlayRunnerResult,
|
|
164
|
+
): PostCodeAttemptOutcome {
|
|
165
|
+
if (result.status !== 'failed') return { kind: 'play' };
|
|
166
|
+
const evidence = workerEvidence(result);
|
|
167
|
+
if (!evidence || evidence.reachedRuntimeCeiling) return { kind: 'play' };
|
|
168
|
+
if (evidence.source === 'runner_lost') {
|
|
169
|
+
if (evidence.inspectionStage === 'sandbox_missing') {
|
|
170
|
+
return {
|
|
171
|
+
kind: 'platform',
|
|
172
|
+
reason: 'runner_lost_sandbox_missing',
|
|
173
|
+
countsTowardProgress: true,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (evidence.inspectionStage === 'sandbox_stopped') {
|
|
177
|
+
const code = evidence.exitCode ?? evidence.providerReturnCode;
|
|
178
|
+
return code === null || code >= 128
|
|
179
|
+
? {
|
|
180
|
+
kind: 'platform',
|
|
181
|
+
reason: 'runner_lost_sandbox_stopped',
|
|
182
|
+
countsTowardProgress: true,
|
|
183
|
+
}
|
|
184
|
+
: { kind: 'play' };
|
|
185
|
+
}
|
|
186
|
+
return { kind: 'play' };
|
|
187
|
+
}
|
|
188
|
+
return result.error.startsWith('RUNTIME_CONTROL_PLANE_UNAVAILABLE:') &&
|
|
189
|
+
evidence.controlPlaneOutageObserved === true &&
|
|
190
|
+
evidence.heartbeatAgeMs >= evidence.heartbeatTimeoutMs
|
|
191
|
+
? {
|
|
192
|
+
kind: 'platform',
|
|
193
|
+
reason: 'control_plane_unreachable',
|
|
194
|
+
countsTowardProgress: false,
|
|
195
|
+
}
|
|
196
|
+
: { kind: 'play' };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Delay before the next attempt, in milliseconds, with jitter applied. */
|
|
200
|
+
export function postCodeRecoveryDelayMs(
|
|
201
|
+
deferCount: number,
|
|
202
|
+
random: () => number = Math.random,
|
|
203
|
+
): number {
|
|
204
|
+
const exponent = Math.max(0, Math.floor(deferCount) - 1);
|
|
205
|
+
const base = Math.min(
|
|
206
|
+
POST_CODE_RECOVERY_BUDGET.maxMs,
|
|
207
|
+
POST_CODE_RECOVERY_BUDGET.baseMs * 2 ** exponent,
|
|
208
|
+
);
|
|
209
|
+
const spread = 1 + (random() * 2 - 1) * POST_CODE_RECOVERY_BUDGET.jitterRatio;
|
|
210
|
+
return Math.max(1_000, Math.round(base * spread));
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Receipt key that marks a run as not replay-safe: some call ran without a
|
|
215
|
+
* history row (an inline child authored before call history existed). The
|
|
216
|
+
* runtime writes it, awaited, before that call goes out, and the worker never
|
|
217
|
+
* replays a run that has it.
|
|
218
|
+
*/
|
|
219
|
+
export function replayTrackedMarkerReceiptKey(
|
|
220
|
+
orgId: string,
|
|
221
|
+
runId: string,
|
|
222
|
+
): string {
|
|
223
|
+
return `ctx:${orgId}:run-replay-tracked:${runId}`;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export function replayUnsafeMarkerReceiptKey(
|
|
227
|
+
orgId: string,
|
|
228
|
+
runId: string,
|
|
229
|
+
): string {
|
|
230
|
+
return `ctx:${orgId}:run-replay-unsafe:${runId}`;
|
|
231
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isPlayDataset,
|
|
3
|
+
residentPlayDatasetRows,
|
|
4
|
+
} from '../plays/dataset';
|
|
5
|
+
|
|
6
|
+
const RESULT_COLUMNS = {
|
|
7
|
+
'company-to-contact': 'contacts',
|
|
8
|
+
'company-to-domain': 'company_domain',
|
|
9
|
+
'company-to-info': 'company_domain',
|
|
10
|
+
'company-to-job-postings': 'job_postings',
|
|
11
|
+
'company-to-news': 'news_events',
|
|
12
|
+
'company-to-tech-stack': 'technologies',
|
|
13
|
+
'name-and-domain-to-email-waterfall': 'email',
|
|
14
|
+
'person-linkedin-to-company': 'company_domain',
|
|
15
|
+
'person-linkedin-to-email': 'email',
|
|
16
|
+
'person-to-email': 'email',
|
|
17
|
+
'person-to-linkedin': 'linkedin_url',
|
|
18
|
+
'person-to-linkedin-harvestapi': 'linkedin_url',
|
|
19
|
+
'person-to-phone': 'phone',
|
|
20
|
+
'personal-email': 'personal_email',
|
|
21
|
+
'personal-email-to-linkedin': 'linkedin_url',
|
|
22
|
+
'professional-to-email': 'email',
|
|
23
|
+
'smb-business-email': 'email',
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
26
|
+
export const PREBUILT_RESULT_QUALITY_COLUMNS: Readonly<Record<string, string>> =
|
|
27
|
+
{
|
|
28
|
+
...Object.fromEntries(
|
|
29
|
+
Object.entries(RESULT_COLUMNS).flatMap(([name, column]) => [
|
|
30
|
+
[name, column],
|
|
31
|
+
[`${name}-batch`, column],
|
|
32
|
+
]),
|
|
33
|
+
),
|
|
34
|
+
'company-to-employees-batch': 'employees',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const LIST_COLUMNS = new Set([
|
|
38
|
+
'contacts',
|
|
39
|
+
'employees',
|
|
40
|
+
'job_postings',
|
|
41
|
+
'news_events',
|
|
42
|
+
'technologies',
|
|
43
|
+
]);
|
|
44
|
+
|
|
45
|
+
const SOURCE_COLUMNS: Readonly<Record<string, string>> = {
|
|
46
|
+
email: 'email_source',
|
|
47
|
+
personal_email: 'email_source',
|
|
48
|
+
phone: 'phone_source',
|
|
49
|
+
linkedin_url: 'linkedin_source',
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const DOMAIN_SOURCE_PLAYS = new Set([
|
|
53
|
+
'company-to-domain',
|
|
54
|
+
'company-to-domain-batch',
|
|
55
|
+
'person-linkedin-to-company',
|
|
56
|
+
'person-linkedin-to-company-batch',
|
|
57
|
+
]);
|
|
58
|
+
const DOMAIN_SOURCES = new Set([
|
|
59
|
+
'company_identify',
|
|
60
|
+
'linkedin_company_page',
|
|
61
|
+
'company_database',
|
|
62
|
+
'google_maps',
|
|
63
|
+
'web_search',
|
|
64
|
+
'linkedin_profile',
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
// Stable attribution buckets. Never put an arbitrary output value into the ledger.
|
|
68
|
+
const SOURCES = new Map([
|
|
69
|
+
...[
|
|
70
|
+
'aviato',
|
|
71
|
+
'contactout',
|
|
72
|
+
'datagma',
|
|
73
|
+
'exa',
|
|
74
|
+
'findymail',
|
|
75
|
+
'forager',
|
|
76
|
+
'fullenrich',
|
|
77
|
+
'hunter',
|
|
78
|
+
'harvestapi',
|
|
79
|
+
'icypeas',
|
|
80
|
+
'leadmagic',
|
|
81
|
+
'limadata',
|
|
82
|
+
'openmart',
|
|
83
|
+
'prospeo',
|
|
84
|
+
'quickenrich',
|
|
85
|
+
'serper',
|
|
86
|
+
'upcell',
|
|
87
|
+
'wiza',
|
|
88
|
+
].map((provider) => [provider, provider] as const),
|
|
89
|
+
['ai_ark', 'ai_ark'],
|
|
90
|
+
['native', 'deepline_native'],
|
|
91
|
+
['pdl', 'peopledatalabs'],
|
|
92
|
+
['trykitt', 'kitt'],
|
|
93
|
+
['pattern', 'email_pattern'],
|
|
94
|
+
]);
|
|
95
|
+
const SOURCE_BUCKETS = new Set([
|
|
96
|
+
...SOURCES.values(),
|
|
97
|
+
...DOMAIN_SOURCES,
|
|
98
|
+
'unknown',
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
export type PrebuiltResultQuality = {
|
|
102
|
+
rows: number;
|
|
103
|
+
hits: number;
|
|
104
|
+
sources: Record<string, number>;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
function record(value: unknown): Record<string, unknown> | null {
|
|
108
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
109
|
+
? (value as Record<string, unknown>)
|
|
110
|
+
: null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function resultShape(reference: string | undefined) {
|
|
114
|
+
if (!reference?.startsWith('prebuilt/')) return undefined;
|
|
115
|
+
const name = reference.slice('prebuilt/'.length);
|
|
116
|
+
if (!Object.hasOwn(PREBUILT_RESULT_QUALITY_COLUMNS, name)) return undefined;
|
|
117
|
+
const column = PREBUILT_RESULT_QUALITY_COLUMNS[name];
|
|
118
|
+
return {
|
|
119
|
+
column,
|
|
120
|
+
sourceColumn: DOMAIN_SOURCE_PLAYS.has(name)
|
|
121
|
+
? 'company_domain_source'
|
|
122
|
+
: SOURCE_COLUMNS[column],
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function measureRows(
|
|
127
|
+
{ column, sourceColumn }: NonNullable<ReturnType<typeof resultShape>>,
|
|
128
|
+
rows: Iterable<unknown>,
|
|
129
|
+
): PrebuiltResultQuality | null {
|
|
130
|
+
const quality: PrebuiltResultQuality = { rows: 0, hits: 0, sources: {} };
|
|
131
|
+
for (const item of rows) {
|
|
132
|
+
const row = record(item);
|
|
133
|
+
if (!row || !Object.hasOwn(row, column)) return null;
|
|
134
|
+
quality.rows++;
|
|
135
|
+
const value = row[column];
|
|
136
|
+
if (value === null) continue;
|
|
137
|
+
if (LIST_COLUMNS.has(column)) {
|
|
138
|
+
if (!Array.isArray(value)) return null;
|
|
139
|
+
if (!value.length) continue;
|
|
140
|
+
} else {
|
|
141
|
+
if (typeof value !== 'string') return null;
|
|
142
|
+
if (!value.trim()) continue;
|
|
143
|
+
}
|
|
144
|
+
const source = sourceColumn ? row[sourceColumn] : undefined;
|
|
145
|
+
const prefix =
|
|
146
|
+
typeof source === 'string'
|
|
147
|
+
? /^(ai_ark|[a-z0-9]+)(?:_|$)/.exec(
|
|
148
|
+
source.replace(/^waterfall:/, ''),
|
|
149
|
+
)?.[1]
|
|
150
|
+
: undefined;
|
|
151
|
+
const bucket =
|
|
152
|
+
sourceColumn === 'company_domain_source'
|
|
153
|
+
? typeof source === 'string' && DOMAIN_SOURCES.has(source)
|
|
154
|
+
? source
|
|
155
|
+
: 'unknown'
|
|
156
|
+
: (SOURCES.get(prefix ?? '') ?? 'unknown');
|
|
157
|
+
quality.sources[bucket] = (quality.sources[bucket] ?? 0) + 1;
|
|
158
|
+
quality.hits++;
|
|
159
|
+
}
|
|
160
|
+
return quality;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Tally only first-attempt writes proved committed by the sheet owner. */
|
|
164
|
+
export function createPrebuiltBatchQualityCollector(
|
|
165
|
+
reference: string | undefined,
|
|
166
|
+
) {
|
|
167
|
+
const shape = reference?.endsWith('-batch') && resultShape(reference);
|
|
168
|
+
if (!shape) return null;
|
|
169
|
+
const datasets = new Map<string, PrebuiltResultQuality | null>();
|
|
170
|
+
return {
|
|
171
|
+
record(input: {
|
|
172
|
+
datasetId: string;
|
|
173
|
+
rows: ReadonlyArray<{ key: string; status?: string; data: unknown }>;
|
|
174
|
+
committedKeys: readonly string[];
|
|
175
|
+
updated: number;
|
|
176
|
+
recoveredStaleKeys: readonly string[];
|
|
177
|
+
}) {
|
|
178
|
+
if (datasets.get(input.datasetId) === null) return;
|
|
179
|
+
// A reconciled stale write proves ownership but may have been written by
|
|
180
|
+
// another invocation. Its candidate values cannot establish attribution.
|
|
181
|
+
if (
|
|
182
|
+
input.updated !== input.committedKeys.length ||
|
|
183
|
+
input.recoveredStaleKeys.length
|
|
184
|
+
) {
|
|
185
|
+
datasets.set(input.datasetId, null);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const committed = new Set(input.committedKeys);
|
|
189
|
+
const accepted = new Map(
|
|
190
|
+
input.rows
|
|
191
|
+
.filter((row) => committed.has(row.key))
|
|
192
|
+
.map((row) => [row.key, row]),
|
|
193
|
+
);
|
|
194
|
+
const batch =
|
|
195
|
+
accepted.size === committed.size
|
|
196
|
+
? measureRows(
|
|
197
|
+
shape,
|
|
198
|
+
[...accepted.values()]
|
|
199
|
+
.filter((row) => row.status !== 'failed')
|
|
200
|
+
.map((row) => row.data),
|
|
201
|
+
)
|
|
202
|
+
: null;
|
|
203
|
+
const previous = datasets.get(input.datasetId);
|
|
204
|
+
if (batch && previous) {
|
|
205
|
+
batch.rows += previous.rows;
|
|
206
|
+
batch.hits += previous.hits;
|
|
207
|
+
for (const [source, count] of Object.entries(previous.sources)) {
|
|
208
|
+
batch.sources[source] = (batch.sources[source] ?? 0) + count;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
datasets.set(input.datasetId, batch);
|
|
212
|
+
},
|
|
213
|
+
complete(datasetId: string, rows: number): PrebuiltResultQuality | null {
|
|
214
|
+
const quality = datasets.get(datasetId);
|
|
215
|
+
return quality?.rows === rows ? quality : null;
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export function measurePrebuiltResultQuality(
|
|
221
|
+
reference: string | undefined,
|
|
222
|
+
result: unknown,
|
|
223
|
+
collector?: ReturnType<typeof createPrebuiltBatchQualityCollector>,
|
|
224
|
+
): PrebuiltResultQuality | null {
|
|
225
|
+
const shape = resultShape(reference);
|
|
226
|
+
const output = record(result);
|
|
227
|
+
if (!shape || !output) return null;
|
|
228
|
+
if (!reference?.endsWith('-batch')) return measureRows(shape, [output]);
|
|
229
|
+
const [dataset, ...others] = Object.values(output).filter(isPlayDataset);
|
|
230
|
+
if (!dataset || others.length) return null;
|
|
231
|
+
const rows = residentPlayDatasetRows(dataset);
|
|
232
|
+
if (rows) return measureRows(shape, rows);
|
|
233
|
+
// The retained preview is incomplete. Only accept counts proved to cover
|
|
234
|
+
// the entire returned handle. This path never reads the sheet again.
|
|
235
|
+
return collector?.complete(dataset.datasetId, dataset.toJSON().count) ?? null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Scheduler boundary. Accept only counts and the fixed attribution vocabulary. */
|
|
239
|
+
export function readPrebuiltResultQuality(
|
|
240
|
+
value: unknown,
|
|
241
|
+
): PrebuiltResultQuality | null {
|
|
242
|
+
const quality = record(value);
|
|
243
|
+
const sources = record(quality?.sources);
|
|
244
|
+
const count = (n: unknown): n is number =>
|
|
245
|
+
typeof n === 'number' && Number.isSafeInteger(n) && n >= 0;
|
|
246
|
+
if (
|
|
247
|
+
!quality ||
|
|
248
|
+
!sources ||
|
|
249
|
+
!count(quality.rows) ||
|
|
250
|
+
!count(quality.hits) ||
|
|
251
|
+
quality.hits > quality.rows
|
|
252
|
+
)
|
|
253
|
+
return null;
|
|
254
|
+
const cleanSources: Record<string, number> = {};
|
|
255
|
+
let hits = 0;
|
|
256
|
+
for (const [source, n] of Object.entries(sources)) {
|
|
257
|
+
if (!SOURCE_BUCKETS.has(source) || !count(n) || n === 0) return null;
|
|
258
|
+
cleanSources[source] = n;
|
|
259
|
+
hits += n;
|
|
260
|
+
}
|
|
261
|
+
return hits === quality.hits
|
|
262
|
+
? { rows: quality.rows, hits, sources: cleanSources }
|
|
263
|
+
: null;
|
|
264
|
+
}
|
|
@@ -26,6 +26,8 @@ import type { ToolResponseContract } from '../plays/tool-response-contract';
|
|
|
26
26
|
import type { FixtureBehavior } from './fixture-behavior';
|
|
27
27
|
import type { CtxFetchHttpFailureDiagnostic } from './log-provenance';
|
|
28
28
|
|
|
29
|
+
import type { PrebuiltResultQuality } from './prebuilt-result-quality';
|
|
30
|
+
|
|
29
31
|
export type PlayRunnerRateStateBackendConfig =
|
|
30
32
|
| {
|
|
31
33
|
kind: 'in_memory';
|
|
@@ -301,10 +303,16 @@ export interface PlayRunnerContextConfig extends RetainedPipelineCarrier {
|
|
|
301
303
|
runId?: string;
|
|
302
304
|
/** Original run for an explicit user-requested replay. */
|
|
303
305
|
replayedFromRunId?: string | null;
|
|
306
|
+
/** Launch fact; see `PlaySchedulerSubmitInput.runScopedKeys`. */
|
|
307
|
+
runScopedKeys?: boolean;
|
|
308
|
+
/** How many times `runs resume` continued this run (absent means 0). */
|
|
309
|
+
resumeEpoch?: number;
|
|
304
310
|
/** Shared governance/billing root. Differs from runId for async children. */
|
|
305
311
|
rootRunId?: string;
|
|
306
312
|
runAttempt?: number | null;
|
|
307
313
|
playName?: string;
|
|
314
|
+
/** Canonical system prebuilt reference for internal result coverage. */
|
|
315
|
+
prebuiltQualityReference?: string;
|
|
308
316
|
userEmail?: string;
|
|
309
317
|
/** Authenticated account snapshot projected from durable runtime authority. */
|
|
310
318
|
runActor?:
|
|
@@ -486,6 +494,7 @@ export type PlayRunnerResult =
|
|
|
486
494
|
/** Customer-safe runtime observations that must survive bounded log tails. */
|
|
487
495
|
runtimeDiagnostics?: CtxFetchHttpFailureDiagnostic[];
|
|
488
496
|
outputRowCount?: number;
|
|
497
|
+
prebuiltResultQuality?: PrebuiltResultQuality;
|
|
489
498
|
rowOutcomes?: PlayRunnerRowOutcomeSummary;
|
|
490
499
|
logs: string[];
|
|
491
500
|
logIds?: string[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbox event IDs for a run's endings.
|
|
3
|
+
*
|
|
4
|
+
* A run that was never resumed has one ending, `run-terminal:{runId}`, as it
|
|
5
|
+
* always has. Each `runs resume` bumps the run's epoch, and the ending of that
|
|
6
|
+
* epoch is `run-ended:{runId}:{epoch}`: a new event, ordered after the earlier
|
|
7
|
+
* one, rather than a duplicate the outbox would drop. The SQL writer is
|
|
8
|
+
* `runEndingEventIdSql` in `scheduler-backends/postgres.ts`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** The ending event ID for a run at its current resume epoch. */
|
|
12
|
+
export function runEndingEventId(
|
|
13
|
+
runId: string,
|
|
14
|
+
resumeEpoch?: number | null,
|
|
15
|
+
): string {
|
|
16
|
+
const epoch = normalizeResumeEpoch(resumeEpoch);
|
|
17
|
+
return epoch === 0 ? `run-terminal:${runId}` : `run-ended:${runId}:${epoch}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Whether `eventId` is an ending of `runId`, from any epoch. */
|
|
21
|
+
export function isRunEndingEventId(eventId: string, runId: string): boolean {
|
|
22
|
+
return runEndingEventEpoch(eventId, runId) !== null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The epoch of an ending event of `runId`, or null if it is not one. */
|
|
26
|
+
export function runEndingEventEpoch(
|
|
27
|
+
eventId: string,
|
|
28
|
+
runId: string,
|
|
29
|
+
): number | null {
|
|
30
|
+
if (eventId === `run-terminal:${runId}`) return 0;
|
|
31
|
+
const prefix = `run-ended:${runId}:`;
|
|
32
|
+
if (!eventId.startsWith(prefix)) return null;
|
|
33
|
+
const epoch = Number(eventId.slice(prefix.length));
|
|
34
|
+
return Number.isSafeInteger(epoch) && epoch > 0 ? epoch : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A missing or malformed epoch is 0: the run was never resumed. */
|
|
38
|
+
/**
|
|
39
|
+
* Compute billing session for one epoch of a run. Each resumed epoch is
|
|
40
|
+
* billed as its own session over its own attempts, since the earlier
|
|
41
|
+
* epoch's session is already finalized.
|
|
42
|
+
*/
|
|
43
|
+
export function computeBillingSessionId(
|
|
44
|
+
runId: string,
|
|
45
|
+
resumeEpoch: unknown,
|
|
46
|
+
): string {
|
|
47
|
+
const epoch = normalizeResumeEpoch(resumeEpoch);
|
|
48
|
+
return epoch > 0 ? `${runId}:resume:${epoch}` : runId;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function normalizeResumeEpoch(value: unknown): number {
|
|
52
|
+
return typeof value === 'number' && Number.isSafeInteger(value) && value > 0
|
|
53
|
+
? value
|
|
54
|
+
: 0;
|
|
55
|
+
}
|