deepline 0.3.483 → 0.3.485
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 +91 -30
- package/dist/bundling-sources/sdk/src/compat.ts +13 -0
- package/dist/bundling-sources/sdk/src/plays/client-core.ts +4 -1
- package/dist/bundling-sources/sdk/src/plays/run-request.ts +143 -9
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +31 -4
- package/dist/bundling-sources/sdk/src/tool-calls.ts +1 -1
- package/dist/bundling-sources/sdk/src/types.ts +7 -1
- package/dist/bundling-sources/shared_libs/monitors/signal-radars/inbound-dead-letter.ts +100 -9
- package/dist/bundling-sources/shared_libs/play-data-plane/sheet-column-storage.ts +32 -3
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +126 -41
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +231 -25
- package/dist/bundling-sources/shared_libs/play-runtime/daytona-runtime-config.ts +9 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machines.ts +130 -19
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-registry.ts +105 -0
- package/dist/bundling-sources/shared_libs/play-runtime/execute-server-timing.ts +4 -2
- package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +194 -56
- package/dist/bundling-sources/shared_libs/play-runtime/log-provenance.ts +11 -6
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/job.ts +3 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/ports.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +30 -0
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +195 -2
- package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +20 -1
- package/dist/bundling-sources/shared_libs/play-runtime/run-ledger-projection-contract.ts +15 -0
- package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +102 -23
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/progress-sidecar.ts +9 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-control-transport.ts +25 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-launch-transport.ts +133 -82
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-lifecycle.ts +58 -16
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-sandbox-absence.ts +171 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-session-execution.ts +69 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona.ts +100 -40
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/types.ts +8 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api.ts +67 -9
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-incident-drills.ts +5 -5
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-store-adapter.ts +6 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-errors.ts +14 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-sheet-row-writer.ts +87 -31
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/contract.ts +18 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/index.ts +19 -0
- package/dist/bundling-sources/shared_libs/play-runtime/sandbox-runs/runner-backend-adapter.ts +14 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +204 -6
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd.ts +39 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/ambiguous-modal-create-state.ts +21 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/compute-billing-job-state.ts +23 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-retirement-state.ts +25 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/integration-operation-value-retirement.ts +15 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/outbox-repair-operation-state.ts +30 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +12 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +26 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +44 -15
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +60 -11
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +743 -70
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +6 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +34 -34
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/sandbox-cleanup-job-state.ts +23 -0
- package/dist/bundling-sources/shared_libs/play-runtime/suspension.ts +12 -0
- package/dist/bundling-sources/shared_libs/play-runtime/test-runtime-seams.ts +21 -0
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +1 -1
- package/dist/bundling-sources/shared_libs/plays/source-authoring-edition.ts +1 -1
- package/dist/bundling-sources/shared_libs/product-notifications/destination-state.ts +93 -0
- package/dist/cli/auth-ABZBH55L.js +43 -0
- package/dist/cli/{auth-2NXF6Q3Q.mjs → auth-OWMUENCU.mjs} +5 -5
- package/dist/cli/{billing-5PW4L5WD.js → billing-2FMNQGOX.js} +80 -80
- package/dist/cli/{billing-W2Y4EOZP.mjs → billing-JX4H3VFF.mjs} +7 -7
- package/dist/cli/{chunk-UGBZ6MCR.js → chunk-2ILND7XX.js} +2 -2
- package/dist/cli/{chunk-25IGCYJP.mjs → chunk-2ZEQ43B7.mjs} +3 -3
- package/dist/cli/{chunk-J7S3DJB4.mjs → chunk-3DBW6C7M.mjs} +13 -4
- package/dist/cli/{chunk-7APXZ3CX.mjs → chunk-3DYU3JQN.mjs} +2 -2
- package/dist/cli/{chunk-VFEW53L5.js → chunk-3OF7NSGR.js} +322 -294
- package/dist/cli/{chunk-UDF2CY4D.mjs → chunk-3Z24NKW7.mjs} +62 -34
- package/dist/cli/{chunk-62XGOB2D.js → chunk-5DCQWQCP.js} +26 -26
- package/dist/cli/{chunk-4X23YY2E.mjs → chunk-62PJ6PK7.mjs} +5 -5
- package/dist/cli/{chunk-YL64JIQ7.mjs → chunk-676NZ7K4.mjs} +1 -1
- package/dist/cli/{chunk-T5GZZJ7O.js → chunk-775AZTO7.js} +323 -247
- package/dist/cli/{chunk-C3LJSOQ6.mjs → chunk-ACTUAZYP.mjs} +5 -5
- package/dist/cli/{chunk-R2OR4RHV.js → chunk-AFADYKFE.js} +8 -8
- package/dist/cli/{chunk-GVAENVIG.js → chunk-AUQQVDAB.js} +110 -21
- package/dist/cli/{chunk-GONUMUBM.js → chunk-BSKPQB2P.js} +7 -7
- package/dist/cli/chunk-C6QWRSMQ.js +42 -0
- package/dist/cli/{chunk-AK7UKQ5R.js → chunk-CSBMKHTV.js} +5 -5
- package/dist/cli/{chunk-PRL7EKJZ.mjs → chunk-CW6TAQBF.mjs} +15 -4
- package/dist/cli/{chunk-75IIHFN6.js → chunk-DMNVM34J.js} +5 -4
- package/dist/cli/{chunk-IEV5UWPN.mjs → chunk-E73JXJA3.mjs} +1 -1
- package/dist/cli/{chunk-DS455RPF.js → chunk-EC2CVPN5.js} +3 -3
- package/dist/cli/{chunk-B7HQL77V.js → chunk-ECIXZNSW.js} +87 -76
- package/dist/cli/{chunk-JJSLEMQQ.mjs → chunk-FJY6K3BG.mjs} +93 -17
- package/dist/cli/{chunk-FK47YUPC.mjs → chunk-G5PI3RNT.mjs} +1 -1
- package/dist/cli/{chunk-GRE3ID5E.mjs → chunk-GHHJWCMD.mjs} +2 -1
- package/dist/cli/{chunk-2JWG2H2N.js → chunk-HKGXGGIV.js} +1 -1
- package/dist/cli/{chunk-2MKX3HV3.js → chunk-IHMYIHF4.js} +5 -5
- package/dist/cli/{chunk-SD7QWZTV.mjs → chunk-INW22YP7.mjs} +1 -1
- package/dist/cli/{chunk-OWUZKXE7.mjs → chunk-J7EENGKJ.mjs} +1 -1
- package/dist/cli/{chunk-AWAFYRFV.mjs → chunk-JD6HKNKD.mjs} +1 -1
- package/dist/cli/{chunk-UY7OXFVU.js → chunk-JQXUWYWX.js} +13 -13
- package/dist/cli/{chunk-GGJQ4HJW.mjs → chunk-KZTNNLIL.mjs} +2 -2
- package/dist/cli/{chunk-NREZRYPU.mjs → chunk-L352NOE3.mjs} +2 -2
- package/dist/cli/{chunk-WI2HNYQX.js → chunk-L7IQ3DFH.js} +53 -53
- package/dist/cli/{chunk-4IOY2SCQ.js → chunk-LOX3BISD.js} +4 -4
- package/dist/cli/{chunk-XRIQN6EP.js → chunk-NKPTM7SK.js} +7 -7
- package/dist/cli/{chunk-5ICAG4RE.js → chunk-NLRTFJGH.js} +14 -14
- package/dist/cli/{chunk-WKB6Y43W.js → chunk-NRNWPWBW.js} +37 -37
- package/dist/cli/{chunk-HNRELVCS.mjs → chunk-ONONSV2Q.mjs} +96 -7
- package/dist/cli/{chunk-MYB6JVSD.js → chunk-OW4OTEFF.js} +16 -16
- package/dist/cli/{chunk-ISP7ZENV.mjs → chunk-RZE5I2XJ.mjs} +4 -4
- package/dist/cli/{chunk-5LHU7NUS.js → chunk-S3WQJ5VG.js} +3 -3
- package/dist/cli/{chunk-EDMCD7MX.mjs → chunk-SR6S4EYG.mjs} +5 -5
- package/dist/cli/{chunk-2T4OSJEH.js → chunk-T4G2T5DS.js} +21 -21
- package/dist/cli/{chunk-EGHYGTJM.mjs → chunk-TMCC7ORQ.mjs} +1 -1
- package/dist/cli/{chunk-SCPFOH5Z.mjs → chunk-TSCUWWTM.mjs} +1 -1
- package/dist/cli/{chunk-7TKLISLM.js → chunk-TVW6USSG.js} +3 -3
- package/dist/cli/{chunk-QSYA6VE4.js → chunk-U6WEGDD3.js} +2 -2
- package/dist/cli/{chunk-FGEC5SWP.mjs → chunk-UPHXGZCE.mjs} +4 -4
- package/dist/cli/{chunk-5JCXS4MP.js → chunk-UQ3LQ6IF.js} +5 -5
- package/dist/cli/{chunk-JYEZ6BWX.mjs → chunk-VZYTLWOM.mjs} +2 -2
- package/dist/cli/{chunk-FAZTLYJO.mjs → chunk-W33OL4F2.mjs} +2 -2
- package/dist/cli/{chunk-ZM2YPJQJ.js → chunk-XK5DMLZE.js} +5 -1
- package/dist/cli/{chunk-LJ5747UC.mjs → chunk-XRDXNAAY.mjs} +5 -1
- package/dist/cli/{chunk-S24CK3CJ.mjs → chunk-YDA3PMKK.mjs} +3 -3
- package/dist/cli/{csv-EKEFLUIW.js → csv-HFEQPGNY.js} +13 -13
- package/dist/cli/{csv-DIFVIR23.mjs → csv-OHF3Y5KB.mjs} +4 -4
- package/dist/cli/{db-DOW4EVEU.mjs → db-M456OUXD.mjs} +7 -7
- package/dist/cli/{db-S7DDRUHX.js → db-VLQKCYQS.js} +28 -28
- package/dist/cli/describe-CP35DZ5Z.js +49 -0
- package/dist/cli/{describe-KSZFOWKV.mjs → describe-M6VXFYVL.mjs} +21 -21
- package/dist/cli/describe-core.d.mts +3 -3
- package/dist/cli/describe-core.d.ts +3 -3
- package/dist/cli/describe-core.js +4 -4
- package/dist/cli/describe-core.mjs +3 -3
- package/dist/cli/{executions-CAG7YC5K.mjs → executions-4FGRBPJF.mjs} +7 -7
- package/dist/cli/{executions-3DU5IXB6.js → executions-GKINJZI6.js} +9 -9
- package/dist/cli/{feedback-BQMPTE47.mjs → feedback-D2WMGK3V.mjs} +4 -4
- package/dist/cli/{feedback-I65JMCP2.js → feedback-ZH5K7WV7.js} +8 -8
- package/dist/cli/git-IDALMZDN.js +25 -0
- package/dist/cli/{git-UQUCD7XZ.mjs → git-OCIJ5ME4.mjs} +5 -5
- package/dist/cli/index.js +142 -139
- package/dist/cli/index.mjs +45 -42
- package/dist/cli/{legacy-noops-OLNT2BG5.js → legacy-noops-QNIVP7LO.js} +8 -8
- package/dist/cli/{legacy-noops-JXKLHUI3.mjs → legacy-noops-V6Q2X34P.mjs} +5 -5
- package/dist/cli/{monitors-DLTHHAFQ.mjs → monitors-2USHTG5G.mjs} +8 -8
- package/dist/cli/{monitors-Z5X56AZN.js → monitors-5DNK7W2K.js} +92 -92
- package/dist/cli/{org-XBHJLKUG.js → org-RPGM5AN4.js} +73 -73
- package/dist/cli/{org-6EZZHD3M.mjs → org-TL2YPYSE.mjs} +7 -7
- package/dist/cli/{pages-XVJ34SCN.js → pages-PNUKPFWV.js} +18 -18
- package/dist/cli/{pages-MYXROSVK.mjs → pages-XDEW6EE3.mjs} +7 -7
- package/dist/cli/{play-ACC4T2XQ.js → play-F5LHRKV5.js} +858 -632
- package/dist/cli/{play-5PV4LAHE.mjs → play-WINNQ4HZ.mjs} +372 -146
- package/dist/cli/{providers-JCI3KNE4.js → providers-BD4IS5U5.js} +10 -10
- package/dist/cli/{providers-2DLUGIFF.mjs → providers-PXGL3FRE.mjs} +7 -7
- package/dist/cli/{quickstart-PDSQEDLD.js → quickstart-7LVF6HZF.js} +6 -6
- package/dist/cli/{quickstart-NSL3C76K.mjs → quickstart-XTH3UQWZ.mjs} +4 -4
- package/dist/cli/{run-X5MXCM4P.mjs → run-MBMUENR7.mjs} +26 -26
- package/dist/cli/{run-UCFMHOQC.js → run-NH2BAWPA.js} +41 -41
- package/dist/cli/{search-RPEMXV6N.mjs → search-BMRWBV66.mjs} +8 -8
- package/dist/cli/search-R3MQJQMT.js +32 -0
- package/dist/cli/{search-output-MZH3HLVE.js → search-output-5NNT337U.js} +22 -16
- package/dist/cli/{search-output-6UO47B7G.mjs → search-output-QKKRD4MF.mjs} +14 -8
- package/dist/cli/{secrets-NLEQURD3.mjs → secrets-AWEXBTJV.mjs} +7 -7
- package/dist/cli/{secrets-UFBASYGY.js → secrets-KQSTOREN.js} +16 -16
- package/dist/cli/{sessions-JYH4DBEE.js → sessions-DSPLZYCJ.js} +6 -6
- package/dist/cli/{sessions-3ALFLWVU.mjs → sessions-RO25Q67X.mjs} +5 -5
- package/dist/cli/{settings-MQYKNAMB.js → settings-7JXIKNKI.js} +79 -79
- package/dist/cli/{settings-YPRILREA.mjs → settings-JMGXGK4Z.mjs} +12 -12
- package/dist/cli/{setup-5IGSHH4E.js → setup-5QFAQQRW.js} +47 -47
- package/dist/cli/{setup-DK4GM227.mjs → setup-ZQZ47FHB.mjs} +9 -9
- package/dist/cli/skills-EDZXY7DV.js +33 -0
- package/dist/cli/{skills-KYBZH3IT.mjs → skills-W3H2DL56.mjs} +7 -7
- package/dist/cli/{tools-4B2MHNBN.mjs → tools-2BZCVNBS.mjs} +19 -19
- package/dist/cli/tools-2EY2ETCZ.js +56 -0
- package/dist/cli/{update-S6VEO7NB.mjs → update-GAWYMGAW.mjs} +9 -9
- package/dist/cli/update-UKDQKNBY.js +33 -0
- package/dist/cli/{workflow-KXZZYFEF.mjs → workflow-M6LLHQ2I.mjs} +8 -8
- package/dist/cli/{workflow-FU2XVPUK.js → workflow-ZPTDFPKW.js} +18 -18
- package/dist/{client-DJ3r8VQJ.d.mts → client-BkbDHRIg.d.mts} +1 -1
- package/dist/{client-JPSNljtj.d.ts → client-D3hVHXjK.d.ts} +1 -1
- package/dist/{client-core-3SJlNsKU.d.mts → client-core-BZoSMKcY.d.mts} +30 -15
- package/dist/{client-core-rCoQ5Xz3.d.ts → client-core-DUdVqO_m.d.ts} +30 -15
- package/dist/{compiler-manifest-gkO9ZkVg.d.mts → compiler-manifest-BFTwq1HI.d.mts} +1 -1
- package/dist/{compiler-manifest-gkO9ZkVg.d.ts → compiler-manifest-BFTwq1HI.d.ts} +1 -1
- package/dist/{errors-Cc92LKH-.d.ts → errors-c3pMsylw.d.ts} +1 -1
- package/dist/{errors-CeCCOKSA.d.mts → errors-w31ybrQM.d.mts} +1 -1
- package/dist/{index-DJQKdV76.d.ts → index-CQ-15-QL.d.ts} +1 -1
- package/dist/{index-DsqWJL3Q.d.mts → index-DvNtxucX.d.mts} +1 -1
- package/dist/index.d.mts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +10 -10
- package/dist/index.mjs +7 -7
- package/dist/install-integrity.json +123 -116
- package/dist/plays/bundle-play-file.d.mts +3 -3
- package/dist/plays/bundle-play-file.d.ts +3 -3
- package/dist/plays/bundle-play-file.mjs +2 -2
- 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/plays/run-request.js +12 -2
- package/dist/plays/run-request.mjs +11 -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 +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +6 -6
- package/dist/server.mjs +4 -4
- package/package.json +1 -1
- package/dist/cli/auth-JHQKM6QY.js +0 -43
- package/dist/cli/chunk-PHDEQ6W3.js +0 -33
- package/dist/cli/describe-RXYQCJRR.js +0 -49
- package/dist/cli/git-ADIABNMQ.js +0 -25
- package/dist/cli/search-YILJZD36.js +0 -32
- package/dist/cli/skills-I4IUZN3U.js +0 -33
- package/dist/cli/tools-NLZR7ABS.js +0 -56
- package/dist/cli/update-RVDEUJTE.js +0 -33
package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isRuntimeRateStateDiagnosticBucket,
|
|
3
|
+
runtimeRateStateBucketDigest,
|
|
4
|
+
} from '../test-runtime-seams';
|
|
1
5
|
import {
|
|
2
6
|
acquireRateStateViaAppRuntime,
|
|
3
7
|
AppRuntimeApiTransportError,
|
|
4
8
|
capacityShedRetryAfterMs,
|
|
9
|
+
isAppRuntimeApiCapacityError,
|
|
5
10
|
flushRateStateFeedbackViaAppRuntime,
|
|
6
11
|
penalizeRateStateViaAppRuntime,
|
|
7
12
|
releaseRateStateViaAppRuntime,
|
|
13
|
+
AppRuntimeApiResponseError,
|
|
8
14
|
RateStateValidationUnavailableError,
|
|
9
15
|
validateRateStateViaAppRuntime,
|
|
10
16
|
type WorkerRuntimeApiContext,
|
|
@@ -216,6 +222,10 @@ interface PendingRelease {
|
|
|
216
222
|
flushing: boolean;
|
|
217
223
|
}
|
|
218
224
|
|
|
225
|
+
type RateStateDiagnostic = Readonly<
|
|
226
|
+
Record<string, string | number | boolean | null>
|
|
227
|
+
>;
|
|
228
|
+
|
|
219
229
|
interface Options {
|
|
220
230
|
schedulerSchema?: string | null;
|
|
221
231
|
now?: () => number;
|
|
@@ -238,6 +248,9 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
238
248
|
*/
|
|
239
249
|
readonly kind: RateStateBackendKind = 'app_runtime_postgres';
|
|
240
250
|
private readonly port: AppRuntimeRatePort;
|
|
251
|
+
private onDiagnostic = (fields: RateStateDiagnostic): void => {
|
|
252
|
+
console.info('[runtime.provider.rate_state.decision]', fields);
|
|
253
|
+
};
|
|
241
254
|
private readonly schedulerSchema: string | null;
|
|
242
255
|
private readonly now: () => number;
|
|
243
256
|
private readonly sleep: (
|
|
@@ -292,7 +305,7 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
292
305
|
* grant). Demand-sizing reads this to request a block sized to the live wave
|
|
293
306
|
* instead of a fixed floor, so a 200-row map fans into ~one round trip.
|
|
294
307
|
*/
|
|
295
|
-
private readonly waiters = new Map<string,
|
|
308
|
+
private readonly waiters = new Map<string, Set<{ signal?: AbortSignal }>>();
|
|
296
309
|
/** Due retries precede fresh draws; already assigned tickets keep ownership. */
|
|
297
310
|
private readonly retryAdmissions = new Map<string, Set<Promise<void>>>();
|
|
298
311
|
/** Last-known server cooldown per bucket (surfaced for PROVIDER_EXHAUSTED). */
|
|
@@ -352,6 +365,20 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
352
365
|
});
|
|
353
366
|
}
|
|
354
367
|
|
|
368
|
+
/** Route selected diagnostics through the owning runner's retained log. */
|
|
369
|
+
setDiagnosticSink(sink: (fields: RateStateDiagnostic) => void): void {
|
|
370
|
+
this.onDiagnostic = sink;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
private emitDiagnostic(fields: RateStateDiagnostic): void {
|
|
374
|
+
try {
|
|
375
|
+
this.onDiagnostic(fields);
|
|
376
|
+
} catch {
|
|
377
|
+
// Diagnostics are advisory. A failing log sink must never turn a
|
|
378
|
+
// committed admission into a store retry and mint another grant.
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
355
382
|
/**
|
|
356
383
|
* Last-known server cooldown for a bucket, or null if the bucket has never
|
|
357
384
|
* reported one. Minimal read surface for the PROVIDER_EXHAUSTED task: it lets
|
|
@@ -362,8 +389,30 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
362
389
|
return this.cooldowns.get(bucketId) ?? null;
|
|
363
390
|
}
|
|
364
391
|
|
|
365
|
-
private serverNow(bucketId: string): number {
|
|
366
|
-
return
|
|
392
|
+
private serverNow(bucketId: string, localNowMs = this.now()): number {
|
|
393
|
+
return localNowMs + (this.serverClockOffsetsMs.get(bucketId) ?? 0);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
private providerExhaustedAtServerDeadline(
|
|
397
|
+
bucketId: string,
|
|
398
|
+
retryAtMs: number,
|
|
399
|
+
localNowMs: number,
|
|
400
|
+
): ProviderExhaustedError {
|
|
401
|
+
return new ProviderExhaustedError({
|
|
402
|
+
provider: providerNameFromBucketId(bucketId),
|
|
403
|
+
retryAtMs,
|
|
404
|
+
...(this.serverClockOffsetsMs.has(bucketId)
|
|
405
|
+
? {
|
|
406
|
+
// Keep the provider's absolute deadline unchanged. A caller uses
|
|
407
|
+
// its own wall clock, while this backend deliberately retains a
|
|
408
|
+
// conservative server clock across uncertain response transit.
|
|
409
|
+
localRetryAtMs: Math.ceil(
|
|
410
|
+
localNowMs +
|
|
411
|
+
Math.max(0, retryAtMs - this.serverNow(bucketId, localNowMs)),
|
|
412
|
+
),
|
|
413
|
+
}
|
|
414
|
+
: {}),
|
|
415
|
+
});
|
|
367
416
|
}
|
|
368
417
|
|
|
369
418
|
/**
|
|
@@ -382,9 +431,10 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
382
431
|
if (exhausted) throw exhausted;
|
|
383
432
|
const stall = this.providerStalls.get(bucketId);
|
|
384
433
|
if (!stall) return;
|
|
385
|
-
const
|
|
434
|
+
const localNowMs = this.now();
|
|
435
|
+
const elapsedMs = localNowMs - stall.startedAt;
|
|
386
436
|
const cooldown = this.cooldowns.get(bucketId);
|
|
387
|
-
const serverNowMs = this.serverNow(bucketId);
|
|
437
|
+
const serverNowMs = this.serverNow(bucketId, localNowMs);
|
|
388
438
|
const retryAtMs = Math.max(
|
|
389
439
|
cooldown?.coolUntilMs ?? 0,
|
|
390
440
|
cooldown?.claimedRetryAtMs ?? 0,
|
|
@@ -403,10 +453,11 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
403
453
|
(elapsedMs >= RATE_ACQUIRE_MAX_WAIT_MS ||
|
|
404
454
|
retryAtMs - serverNowMs > RATE_ACQUIRE_MAX_WAIT_MS - elapsedMs)
|
|
405
455
|
) {
|
|
406
|
-
throw
|
|
407
|
-
|
|
456
|
+
throw this.providerExhaustedAtServerDeadline(
|
|
457
|
+
bucketId,
|
|
408
458
|
retryAtMs,
|
|
409
|
-
|
|
459
|
+
localNowMs,
|
|
460
|
+
);
|
|
410
461
|
}
|
|
411
462
|
if (!stall.warned && elapsedMs >= PROVIDER_NO_PROGRESS_WARNING_MS) {
|
|
412
463
|
stall.warned = true;
|
|
@@ -424,7 +475,8 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
424
475
|
): ProviderExhaustedError | null {
|
|
425
476
|
const cooldown = this.cooldowns.get(bucketId);
|
|
426
477
|
if (!cooldown) return null;
|
|
427
|
-
const
|
|
478
|
+
const localNowMs = this.now();
|
|
479
|
+
const now = this.serverNow(bucketId, localNowMs);
|
|
428
480
|
const coolActive = cooldown.coolUntilMs - now > 0;
|
|
429
481
|
const claimActive = cooldown.claimedRetryAtMs - now > 0;
|
|
430
482
|
if (!coolActive && !claimActive) return null;
|
|
@@ -445,10 +497,11 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
445
497
|
coolActive ? cooldown.coolUntilMs : 0,
|
|
446
498
|
claimActive ? cooldown.claimedRetryAtMs : 0,
|
|
447
499
|
);
|
|
448
|
-
return
|
|
449
|
-
|
|
500
|
+
return this.providerExhaustedAtServerDeadline(
|
|
501
|
+
bucketId,
|
|
450
502
|
retryAtMs,
|
|
451
|
-
|
|
503
|
+
localNowMs,
|
|
504
|
+
);
|
|
452
505
|
}
|
|
453
506
|
|
|
454
507
|
tryAcquire(input: {
|
|
@@ -657,7 +710,10 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
657
710
|
// Count this acquirer as waiting on the refill so the single-flight refill
|
|
658
711
|
// can size its block to the live wave. Decremented once a block lands (or
|
|
659
712
|
// the refill errors) — see the finally in `refillBlock`.
|
|
660
|
-
|
|
713
|
+
const waiter = { signal };
|
|
714
|
+
const waiters = this.waiters.get(laneKey) ?? new Set();
|
|
715
|
+
waiters.add(waiter);
|
|
716
|
+
this.waiters.set(laneKey, waiters);
|
|
661
717
|
try {
|
|
662
718
|
await this.refillBlock(
|
|
663
719
|
bucketId,
|
|
@@ -669,9 +725,8 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
669
725
|
input.yieldProviderHolds === true,
|
|
670
726
|
);
|
|
671
727
|
} finally {
|
|
672
|
-
|
|
673
|
-
if (
|
|
674
|
-
else this.waiters.delete(laneKey);
|
|
728
|
+
waiters.delete(waiter);
|
|
729
|
+
if (waiters.size === 0) this.waiters.delete(laneKey);
|
|
675
730
|
}
|
|
676
731
|
}
|
|
677
732
|
}
|
|
@@ -708,9 +763,10 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
708
763
|
learnedRps < DEFAULT_UNKNOWN_PROVIDER_FAST_RECOVERY_RPS &&
|
|
709
764
|
rules.some((rule) => rule.ruleId === 'default:provider-scope') &&
|
|
710
765
|
rules.every((rule) => rule.ruleId.startsWith('default:'));
|
|
711
|
-
//
|
|
712
|
-
//
|
|
713
|
-
//
|
|
766
|
+
// During fast recovery, one dispatch interval at the learned pace can
|
|
767
|
+
// prove the next step. Reserve only that interval so cached old-pace
|
|
768
|
+
// tickets cannot delay fresh-feedback refills. Once recovered, batch over
|
|
769
|
+
// the normal horizon and preserve the round-trip savings for steady traffic.
|
|
714
770
|
const horizonMs = Math.min(
|
|
715
771
|
recoveringUnknownProvider ? 1_000 / currentRps : RATE_BLOCK_HORIZON_MS,
|
|
716
772
|
leasedBlockTtlMs(rules),
|
|
@@ -720,7 +776,7 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
720
776
|
Math.floor((currentRps * horizonMs) / 1_000),
|
|
721
777
|
);
|
|
722
778
|
if (!Number.isFinite(rateBudget) || rateBudget <= 0) return floor;
|
|
723
|
-
const waiters = this.waiters.get(laneKey) ?? 1;
|
|
779
|
+
const waiters = this.waiters.get(laneKey)?.size ?? 1;
|
|
724
780
|
const concurrencyLimits = rules.flatMap((rule) =>
|
|
725
781
|
rule.maxConcurrency != null &&
|
|
726
782
|
Number.isFinite(rule.maxConcurrency) &&
|
|
@@ -960,7 +1016,8 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
960
1016
|
claimedRetryAtMs?: number;
|
|
961
1017
|
},
|
|
962
1018
|
): ProviderExhaustedError {
|
|
963
|
-
const
|
|
1019
|
+
const localNowMs = this.now();
|
|
1020
|
+
const now = this.serverNow(bucketId, localNowMs);
|
|
964
1021
|
const claimedRetryAtMs = Number(response.claimedRetryAtMs);
|
|
965
1022
|
const coolUntilMs = Number(response.coolUntilMs);
|
|
966
1023
|
const retryAtMs =
|
|
@@ -970,10 +1027,11 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
970
1027
|
: 0,
|
|
971
1028
|
Number.isFinite(coolUntilMs) && coolUntilMs > now ? coolUntilMs : 0,
|
|
972
1029
|
) || now + Math.max(0, response.waitMs);
|
|
973
|
-
return
|
|
974
|
-
|
|
1030
|
+
return this.providerExhaustedAtServerDeadline(
|
|
1031
|
+
bucketId,
|
|
975
1032
|
retryAtMs,
|
|
976
|
-
|
|
1033
|
+
localNowMs,
|
|
1034
|
+
);
|
|
977
1035
|
}
|
|
978
1036
|
|
|
979
1037
|
/**
|
|
@@ -1046,6 +1104,9 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
1046
1104
|
await pendingPenalty;
|
|
1047
1105
|
continue;
|
|
1048
1106
|
}
|
|
1107
|
+
let acquireRpcStartedAtMs: number | null = null;
|
|
1108
|
+
let acquireRpcRequested: number | null = null;
|
|
1109
|
+
let acquireRpcPending = false;
|
|
1049
1110
|
try {
|
|
1050
1111
|
let releaseSignal = this.leaseReleaseSignals.get(bucketId);
|
|
1051
1112
|
if (
|
|
@@ -1059,15 +1120,42 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
1059
1120
|
const releaseGeneration = releaseSignal?.generation;
|
|
1060
1121
|
const successKey = pendingSuccessKey(bucketId, ordered);
|
|
1061
1122
|
const feedback = this.snapshotSuccessFeedback(successKey);
|
|
1123
|
+
const requested = this.requestedForBucket(laneKey, ordered);
|
|
1062
1124
|
const requestStartedAtMs = this.now();
|
|
1125
|
+
acquireRpcStartedAtMs = requestStartedAtMs;
|
|
1126
|
+
acquireRpcRequested = requested;
|
|
1127
|
+
acquireRpcPending = true;
|
|
1063
1128
|
const rawResponse = await this.port.acquire({
|
|
1064
1129
|
bucketId,
|
|
1065
1130
|
rateScopeToken,
|
|
1066
1131
|
rules: withAdaptiveMaxRps(ordered),
|
|
1067
|
-
requested
|
|
1132
|
+
requested,
|
|
1068
1133
|
...feedback,
|
|
1069
1134
|
schedulerSchema: this.schedulerSchema,
|
|
1070
1135
|
});
|
|
1136
|
+
const acquireRpcElapsedMs = Math.max(
|
|
1137
|
+
0,
|
|
1138
|
+
this.now() - requestStartedAtMs,
|
|
1139
|
+
);
|
|
1140
|
+
acquireRpcPending = false;
|
|
1141
|
+
// The receiver opts in using authenticated Play identity. Older receivers
|
|
1142
|
+
// omit this snapshot; neither its absence nor this trace affects pacing.
|
|
1143
|
+
if (
|
|
1144
|
+
rawResponse.governorSnapshot &&
|
|
1145
|
+
isRuntimeRateStateDiagnosticBucket(bucketId)
|
|
1146
|
+
) {
|
|
1147
|
+
this.emitDiagnostic({
|
|
1148
|
+
observationStage: 'caller_acquire',
|
|
1149
|
+
action: 'rate_state_acquire',
|
|
1150
|
+
bucketDigest: runtimeRateStateBucketDigest(bucketId),
|
|
1151
|
+
requested,
|
|
1152
|
+
granted: rawResponse.granted,
|
|
1153
|
+
waitMs: rawResponse.waitMs,
|
|
1154
|
+
acquireRpcElapsedMs,
|
|
1155
|
+
serverNowMs: rawResponse.serverNowMs ?? null,
|
|
1156
|
+
...rawResponse.governorSnapshot,
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1071
1159
|
const serverElapsedMs = rawResponse.serverClockElapsedMs;
|
|
1072
1160
|
const validServerElapsed =
|
|
1073
1161
|
typeof rawResponse.serverNowMs === 'number' &&
|
|
@@ -1130,16 +1218,40 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
1130
1218
|
);
|
|
1131
1219
|
}
|
|
1132
1220
|
if (response.granted > 0) {
|
|
1133
|
-
|
|
1134
|
-
// permit is handed out here, so nothing is double-drawn.
|
|
1135
|
-
this.mergeGrantedBlock(
|
|
1221
|
+
const permits = this.grantedPermits(
|
|
1136
1222
|
bucketId,
|
|
1137
|
-
rateScopeToken,
|
|
1138
1223
|
ordered,
|
|
1139
|
-
rulesKey,
|
|
1140
1224
|
laneKey,
|
|
1141
1225
|
response,
|
|
1142
1226
|
);
|
|
1227
|
+
// A committed grant can arrive after every owner of this refill
|
|
1228
|
+
// cancelled. Nobody will draw or lazily expire that block: return
|
|
1229
|
+
// its exact unsent reservations before another backend needs slots.
|
|
1230
|
+
// The first caller's signal alone cannot cancel a live sibling.
|
|
1231
|
+
if (
|
|
1232
|
+
![...(this.waiters.get(laneKey) ?? [])].some(
|
|
1233
|
+
(waiter) => !waiter.signal?.aborted,
|
|
1234
|
+
)
|
|
1235
|
+
) {
|
|
1236
|
+
// A refund failure rejects this flight; it must not enter the
|
|
1237
|
+
// store-acquire retry ladder and mint another ownerless grant.
|
|
1238
|
+
return this.cancelReserved({
|
|
1239
|
+
bucketId,
|
|
1240
|
+
rateScopeToken,
|
|
1241
|
+
rules: ordered,
|
|
1242
|
+
leaseIds: permits.flatMap(([, id]) => (id ? [id] : [])),
|
|
1243
|
+
reservationIds: permits.flatMap(([, , id]) => (id ? [id] : [])),
|
|
1244
|
+
});
|
|
1245
|
+
}
|
|
1246
|
+
// No permit is handed out here: matching live acquirers re-draw.
|
|
1247
|
+
this.mergeBlock(
|
|
1248
|
+
bucketId,
|
|
1249
|
+
rateScopeToken,
|
|
1250
|
+
permits,
|
|
1251
|
+
rulesKey,
|
|
1252
|
+
laneKey,
|
|
1253
|
+
ordered,
|
|
1254
|
+
);
|
|
1143
1255
|
return;
|
|
1144
1256
|
}
|
|
1145
1257
|
if (yieldProviderHolds) {
|
|
@@ -1195,6 +1307,37 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
1195
1307
|
}
|
|
1196
1308
|
return;
|
|
1197
1309
|
} catch (error) {
|
|
1310
|
+
// A thrown RPC has an unknown grant/commit outcome, not a zero grant.
|
|
1311
|
+
// The caller lacks authenticated Play identity; only this reserved
|
|
1312
|
+
// synthetic bucket is eligible for error timing (no snapshot arrived).
|
|
1313
|
+
if (
|
|
1314
|
+
acquireRpcPending &&
|
|
1315
|
+
acquireRpcStartedAtMs !== null &&
|
|
1316
|
+
isRuntimeRateStateDiagnosticBucket(bucketId)
|
|
1317
|
+
) {
|
|
1318
|
+
const errorName = error instanceof Error ? error.name : '';
|
|
1319
|
+
this.emitDiagnostic({
|
|
1320
|
+
observationStage: 'caller_acquire_error',
|
|
1321
|
+
action: 'rate_state_acquire',
|
|
1322
|
+
bucketDigest: runtimeRateStateBucketDigest(bucketId),
|
|
1323
|
+
requested: acquireRpcRequested,
|
|
1324
|
+
acquireRpcElapsedMs: Math.max(
|
|
1325
|
+
0,
|
|
1326
|
+
this.now() - acquireRpcStartedAtMs,
|
|
1327
|
+
),
|
|
1328
|
+
outcome: 'unknown',
|
|
1329
|
+
errorClassification:
|
|
1330
|
+
signal?.aborted || errorName === 'AbortError'
|
|
1331
|
+
? 'cancelled'
|
|
1332
|
+
: errorName === 'TimeoutError'
|
|
1333
|
+
? 'timeout'
|
|
1334
|
+
: isAppRuntimeApiCapacityError(error)
|
|
1335
|
+
? 'capacity'
|
|
1336
|
+
: error instanceof AppRuntimeApiResponseError
|
|
1337
|
+
? 'http'
|
|
1338
|
+
: 'transport_or_store',
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1198
1341
|
// A provider hold is not a store failure. Preserve its deadline for
|
|
1199
1342
|
// the caller's durable suspension or non-durable error path.
|
|
1200
1343
|
if (error instanceof ProviderExhaustedError) throw error;
|
|
@@ -1237,16 +1380,14 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
1237
1380
|
}
|
|
1238
1381
|
|
|
1239
1382
|
/**
|
|
1240
|
-
* Validate a granted acquire response and
|
|
1241
|
-
*
|
|
1383
|
+
* Validate a granted acquire response and prepare its scheduled permits.
|
|
1384
|
+
* Concurrency rules carry one lease token per permit (release
|
|
1242
1385
|
* semantics); pure-rate rules carry untracked window permits the store already
|
|
1243
1386
|
* decremented.
|
|
1244
1387
|
*/
|
|
1245
|
-
private
|
|
1388
|
+
private grantedPermits(
|
|
1246
1389
|
bucketId: string,
|
|
1247
|
-
rateScopeToken: string | null,
|
|
1248
1390
|
ordered: PacingRule[],
|
|
1249
|
-
rulesKey: string,
|
|
1250
1391
|
laneKey: string,
|
|
1251
1392
|
response: {
|
|
1252
1393
|
granted: number;
|
|
@@ -1259,7 +1400,7 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
1259
1400
|
claimedRetryAtMs?: number;
|
|
1260
1401
|
dispatchValidationSupported?: boolean;
|
|
1261
1402
|
},
|
|
1262
|
-
):
|
|
1403
|
+
): LeasedBlock['permits'] {
|
|
1263
1404
|
const hasConcurrency = ordered.some((rule) => rule.maxConcurrency != null);
|
|
1264
1405
|
const leaseIds = Array.isArray(response.leaseIds)
|
|
1265
1406
|
? response.leaseIds.filter(
|
|
@@ -1452,23 +1593,16 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
1452
1593
|
`Rate-state store granted ${response.granted} permits for ${bucketId} with ${scheduledAtMs.length} dispatch timestamps.`,
|
|
1453
1594
|
);
|
|
1454
1595
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
Math.max(0, response.claimedRetryAtMs ?? 0),
|
|
1466
|
-
response.dispatchValidationSupported === true,
|
|
1467
|
-
],
|
|
1468
|
-
),
|
|
1469
|
-
rulesKey,
|
|
1470
|
-
laneKey,
|
|
1471
|
-
ordered,
|
|
1596
|
+
return scheduledAtMs.map(
|
|
1597
|
+
(scheduledAtMs, index): LeasedBlock['permits'][number] => [
|
|
1598
|
+
scheduledAtMs,
|
|
1599
|
+
hasConcurrency ? (leaseIds[index] ?? null) : null,
|
|
1600
|
+
reservationIds[index] ?? null,
|
|
1601
|
+
concurrencyGrants[index] ?? null,
|
|
1602
|
+
pacingGrant,
|
|
1603
|
+
Math.max(0, response.claimedRetryAtMs ?? 0),
|
|
1604
|
+
response.dispatchValidationSupported === true,
|
|
1605
|
+
],
|
|
1472
1606
|
);
|
|
1473
1607
|
}
|
|
1474
1608
|
|
|
@@ -1729,7 +1863,7 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
1729
1863
|
rateScopeToken,
|
|
1730
1864
|
rules,
|
|
1731
1865
|
leaseIds: leaseId ? [leaseId] : [],
|
|
1732
|
-
reservationId,
|
|
1866
|
+
reservationIds: [reservationId],
|
|
1733
1867
|
});
|
|
1734
1868
|
};
|
|
1735
1869
|
return {
|
|
@@ -2038,15 +2172,19 @@ export class AppRuntimeRateStateBackend implements RateStateBackend {
|
|
|
2038
2172
|
rateScopeToken: string | null;
|
|
2039
2173
|
rules: readonly PacingRule[];
|
|
2040
2174
|
leaseIds: readonly string[];
|
|
2041
|
-
|
|
2175
|
+
reservationIds: readonly string[];
|
|
2042
2176
|
}): Promise<void> {
|
|
2177
|
+
// Outgoing gateways can omit refundable identities. Preserve their
|
|
2178
|
+
// forfeited rate tokens while still returning any concurrency leases.
|
|
2179
|
+
if (input.leaseIds.length === 0 && input.reservationIds.length === 0)
|
|
2180
|
+
return;
|
|
2043
2181
|
try {
|
|
2044
2182
|
await this.port.release({
|
|
2045
2183
|
bucketId: input.bucketId,
|
|
2046
2184
|
rateScopeToken: input.rateScopeToken,
|
|
2047
2185
|
rules: [...input.rules],
|
|
2048
2186
|
leaseIds: [...input.leaseIds],
|
|
2049
|
-
refundReservationIds: [input.
|
|
2187
|
+
refundReservationIds: [...input.reservationIds],
|
|
2050
2188
|
schedulerSchema: this.schedulerSchema,
|
|
2051
2189
|
});
|
|
2052
2190
|
if (input.leaseIds.length > 0) this.signalLeaseRelease(input.bucketId);
|
|
@@ -43,7 +43,8 @@ export type LogProvenance =
|
|
|
43
43
|
* replay copy is churn. */
|
|
44
44
|
| 'replay'
|
|
45
45
|
/** Scheduler / sandbox / worker internals: run-file prep, sandbox
|
|
46
|
-
* lifecycle, `[perf]` timings, batch-drain bookkeeping.
|
|
46
|
+
* lifecycle, `[perf]` and `[perf-trace]` timings, batch-drain bookkeeping.
|
|
47
|
+
* Operator-facing. */
|
|
47
48
|
| 'infra'
|
|
48
49
|
/** Warnings and diagnostics: `[warn]`, `[error]`, `[runtime.*_failure]`,
|
|
49
50
|
* and forward-looking hints. Surfaced because a human may need to act. */
|
|
@@ -127,10 +128,12 @@ export function isDurableDirectRunnerLog(event: {
|
|
|
127
128
|
source?: unknown;
|
|
128
129
|
line?: unknown;
|
|
129
130
|
}): boolean {
|
|
131
|
+
if (typeof event.line !== 'string' || event.line.length === 0) return false;
|
|
132
|
+
if (event.source !== 'worker') return true;
|
|
133
|
+
const tagged = readProvenanceTag(event.line);
|
|
130
134
|
return (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
(event.source !== 'worker' || event.line.startsWith('[perf-trace] '))
|
|
135
|
+
(tagged.provenance === null || tagged.provenance === 'infra') &&
|
|
136
|
+
tagged.line.startsWith('[perf-trace] ')
|
|
134
137
|
);
|
|
135
138
|
}
|
|
136
139
|
|
|
@@ -319,8 +322,9 @@ export function stripProvenanceTag(line: string): string {
|
|
|
319
322
|
* Legacy classifier for old persisted log strings that carry NO structural
|
|
320
323
|
* tag. Mirrors — and supersedes — the two ad-hoc filters that used to live in
|
|
321
324
|
* `PlayRunDetailPanel.isInternalLogLine` and `formatPlayLogLine`. The patterns
|
|
322
|
-
* are the historical `[worker] ...` / `[event] ...` / `[perf] ...`
|
|
323
|
-
* the checkpoint-replay marker. Order matters:
|
|
325
|
+
* are the historical `[worker] ...` / `[event] ...` / `[perf] ...` /
|
|
326
|
+
* `[perf-trace] ...` shapes plus the checkpoint-replay marker. Order matters:
|
|
327
|
+
* most specific first.
|
|
324
328
|
*
|
|
325
329
|
* A legacy line the classifier can't place defaults to `user` — old runs
|
|
326
330
|
* predate structural tagging, and the safe default for an unrecognized line is
|
|
@@ -341,6 +345,7 @@ export function classifyLegacyLogLine(line: string): LogProvenance {
|
|
|
341
345
|
|
|
342
346
|
// Scheduler / sandbox / worker internals.
|
|
343
347
|
if (
|
|
348
|
+
/^\[perf-trace\]/i.test(message) ||
|
|
344
349
|
/^\[perf\]/i.test(message) ||
|
|
345
350
|
/^\[runtime\.(?:phase_summary|logs|log_transport)\]/i.test(message) ||
|
|
346
351
|
/\[worker\] picked up run\b/.test(message) ||
|
|
@@ -43,6 +43,7 @@ export function createSandboxCleanupJob(
|
|
|
43
43
|
input,
|
|
44
44
|
deletion.detail,
|
|
45
45
|
confirmationReadDelay(input.resource.failureCount + 1),
|
|
46
|
+
{ code: deletion.code },
|
|
46
47
|
);
|
|
47
48
|
}
|
|
48
49
|
if (deletion.kind === 'failed') {
|
|
@@ -129,11 +130,13 @@ async function scheduleRetry(
|
|
|
129
130
|
input: SandboxCleanupInput,
|
|
130
131
|
error: string,
|
|
131
132
|
retryAfterMs = retryDelay(input.resource.failureCount + 1),
|
|
133
|
+
confirmationPending?: { code: string },
|
|
132
134
|
): Promise<SandboxCleanupOutcome> {
|
|
133
135
|
const scheduled = await ports.store.retry({
|
|
134
136
|
resource: input.resource,
|
|
135
137
|
error,
|
|
136
138
|
retryAfterMs,
|
|
139
|
+
...(confirmationPending ? { confirmationPending } : {}),
|
|
137
140
|
});
|
|
138
141
|
return scheduled === 'retry_scheduled'
|
|
139
142
|
? { kind: 'retry_scheduled', retryAfterMs }
|
|
@@ -29,6 +29,8 @@ export type SandboxCleanupStore = {
|
|
|
29
29
|
resource: SandboxCleanupResource;
|
|
30
30
|
error: string;
|
|
31
31
|
retryAfterMs: number;
|
|
32
|
+
/** The provider is still confirming deletion, rather than reporting failure. */
|
|
33
|
+
confirmationPending?: { code: string };
|
|
32
34
|
}): Promise<'retry_scheduled' | 'rejected'>;
|
|
33
35
|
block(input: {
|
|
34
36
|
resource: SandboxCleanupResource;
|
package/dist/bundling-sources/shared_libs/play-runtime/play-runs/sandbox-cleanup/postgres-adapter.ts
CHANGED
|
@@ -61,7 +61,7 @@ export function createPostgresSandboxCleanupStore(
|
|
|
61
61
|
),
|
|
62
62
|
);
|
|
63
63
|
},
|
|
64
|
-
async retry({ resource, error, retryAfterMs }) {
|
|
64
|
+
async retry({ resource, error, retryAfterMs, confirmationPending }) {
|
|
65
65
|
const outcome = await input.runWithClient(
|
|
66
66
|
async (client) =>
|
|
67
67
|
await retryPostgresSchedulerSandboxCleanupJob(
|
|
@@ -74,6 +74,7 @@ export function createPostgresSandboxCleanupStore(
|
|
|
74
74
|
claimGeneration: resource.cleanupAttempt,
|
|
75
75
|
error,
|
|
76
76
|
retryAfterMs,
|
|
77
|
+
confirmationPending,
|
|
77
78
|
},
|
|
78
79
|
options,
|
|
79
80
|
),
|
|
@@ -83,7 +83,37 @@ export type PlayRunnerRateStateConcurrencyGrant = {
|
|
|
83
83
|
minimumRttMs: number | null;
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
+
/** Fixed scalar acquisition facts, present only for the scoped synthetic diagnostic. */
|
|
87
|
+
export type PlayRunnerRateStateGovernorSnapshot = {
|
|
88
|
+
previousRefillPerSecond: number;
|
|
89
|
+
previousRateSuccesses: number;
|
|
90
|
+
previousObservationStartedAtMs: number | null;
|
|
91
|
+
previousRecoveryIntervalMs: number;
|
|
92
|
+
previousThrottleCeilingRps: number | null;
|
|
93
|
+
fastRecovery: boolean;
|
|
94
|
+
tokensAfterRefill: number;
|
|
95
|
+
refillPerSecond: number;
|
|
96
|
+
tokens: number;
|
|
97
|
+
rateSuccesses: number;
|
|
98
|
+
observationStartedAtMs: number | null;
|
|
99
|
+
recoveryIntervalMs: number;
|
|
100
|
+
throttleCeilingRps: number | null;
|
|
101
|
+
probeStartedAtMs: number | null;
|
|
102
|
+
probeSuccessesAtRamp: number | null;
|
|
103
|
+
lastRampAtMs: number;
|
|
104
|
+
refilledAtMs: number;
|
|
105
|
+
nextDispatchAtMs: number;
|
|
106
|
+
retryAtMs: number;
|
|
107
|
+
coolUntilMs: number;
|
|
108
|
+
seenBackpressure: boolean;
|
|
109
|
+
activeConcurrency: number | null;
|
|
110
|
+
freeConcurrency: number | null;
|
|
111
|
+
concurrencyLimit: number | null;
|
|
112
|
+
};
|
|
113
|
+
|
|
86
114
|
export type PlayRunnerRateStateAcquireResult = {
|
|
115
|
+
/** Diagnostic only; absence never changes admission, clocks or retries. */
|
|
116
|
+
governorSnapshot?: PlayRunnerRateStateGovernorSnapshot;
|
|
87
117
|
granted: number;
|
|
88
118
|
waitMs: number;
|
|
89
119
|
/** This receiver serves rate_state_validate. Absent on pre-expansion readers. */
|