deepline 0.3.531 → 0.3.533
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 +129 -62
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts +139 -35
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-receipt-gateway.ts +438 -38
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/runtime-topology.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-machine-lifecycle.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/deployment/fly-transient-retry.ts +279 -20
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/engine-suspension.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/ports.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/postgres-fence-adapter.ts +2 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +6 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +8 -0
- package/dist/cli/{auth-33B3OEM4.mjs → auth-2TZNPIJQ.mjs} +5 -5
- package/dist/cli/auth-KE6RFHUE.js +43 -0
- package/dist/cli/{billing-Y2M2ABLW.js → billing-HQYTRIV3.js} +79 -79
- package/dist/cli/{billing-X4OQRH6D.mjs → billing-LR4WJIHO.mjs} +6 -6
- package/dist/cli/{chunk-NXEQMKSM.js → chunk-274Y66HP.js} +2 -2
- package/dist/cli/{chunk-CVOFP6BU.mjs → chunk-2TMNRF5R.mjs} +1 -1
- package/dist/cli/{chunk-VWOOOU6G.mjs → chunk-2UYERVXF.mjs} +2 -2
- package/dist/cli/{chunk-3PMVNMG4.js → chunk-33SNTG5F.js} +16 -16
- package/dist/cli/{chunk-IXOEKHOY.js → chunk-352XVCGE.js} +5 -5
- package/dist/cli/{chunk-XOXKVLJZ.mjs → chunk-3KQBV2CG.mjs} +3 -3
- package/dist/cli/{chunk-O7EFJR6Y.mjs → chunk-3O3AL5RI.mjs} +4 -4
- package/dist/cli/{chunk-4O7UET74.js → chunk-425ERNBL.js} +44 -44
- package/dist/cli/{chunk-5M24K577.js → chunk-4CYNH47Y.js} +53 -53
- package/dist/cli/{chunk-PTKSHGUM.js → chunk-4UADZTU5.js} +22 -22
- package/dist/cli/{chunk-RZXSCWEB.js → chunk-4YP2YAIZ.js} +26 -26
- package/dist/cli/{chunk-DWYX5DFJ.js → chunk-5XTXC45Z.js} +41 -41
- package/dist/cli/{chunk-RBPCXQBE.js → chunk-735ZOYQN.js} +11 -11
- package/dist/cli/{chunk-IOOWKPF7.js → chunk-A4JP6RPX.js} +2 -2
- package/dist/cli/{chunk-L4XVL4LW.js → chunk-B4ZNWXUW.js} +9 -9
- package/dist/cli/{chunk-HYPLMUMA.mjs → chunk-BSI7UHQZ.mjs} +5 -5
- package/dist/cli/{chunk-O267YGUV.js → chunk-BWZHMWM5.js} +6 -6
- package/dist/cli/{chunk-YVOFNLGN.mjs → chunk-CANHB6DH.mjs} +2 -2
- package/dist/cli/{chunk-ZJQITGPV.mjs → chunk-CWIGRIIX.mjs} +3 -3
- package/dist/cli/{chunk-O4NTPEQV.js → chunk-E4VWBU2E.js} +16 -16
- package/dist/cli/{chunk-RLRPEHQ3.js → chunk-EYWES7F5.js} +3 -3
- package/dist/cli/{chunk-YMGQP7WI.mjs → chunk-G3GJ3IGU.mjs} +5 -5
- package/dist/cli/{chunk-VHIHGMZD.mjs → chunk-G3RVDRYL.mjs} +1 -1
- package/dist/cli/{chunk-TDJCNVDE.js → chunk-HOTJSXLY.js} +5 -5
- package/dist/cli/{chunk-XWQI4TMS.mjs → chunk-HPOVAUQF.mjs} +1 -1
- package/dist/cli/{chunk-UNTFERUX.mjs → chunk-IETLUG4C.mjs} +1 -1
- package/dist/cli/{chunk-SPODXGBZ.mjs → chunk-JZ7LJS3P.mjs} +6 -6
- package/dist/cli/{chunk-EURLINZT.mjs → chunk-KKUOIVQO.mjs} +1 -1
- package/dist/cli/{chunk-WHAMLN6B.js → chunk-LTF2J3JM.js} +2 -2
- package/dist/cli/{chunk-TU7HU5K2.mjs → chunk-LZ3PBEQH.mjs} +2 -2
- package/dist/cli/{chunk-U5YBINPF.mjs → chunk-LZMRCUVD.mjs} +2 -2
- package/dist/cli/{chunk-MGWYYTZN.mjs → chunk-MKUYZ7LR.mjs} +1 -1
- package/dist/cli/{chunk-2WWTIR2G.js → chunk-MNAEALPG.js} +98 -98
- package/dist/cli/{chunk-MYTA37IL.mjs → chunk-NFDYVMGC.mjs} +10 -10
- package/dist/cli/{chunk-VGWUCBNA.mjs → chunk-NKVW552R.mjs} +1 -1
- package/dist/cli/{chunk-XQGLHKDI.mjs → chunk-NW736SOD.mjs} +2 -2
- package/dist/cli/{chunk-BUK6WHY2.js → chunk-O7RSUW75.js} +4 -4
- package/dist/cli/{chunk-6W73VXMK.mjs → chunk-PIACHLYY.mjs} +2 -2
- package/dist/cli/{chunk-JFTO33FK.js → chunk-QZWURUBP.js} +7 -7
- package/dist/cli/{chunk-ZBL4CP75.js → chunk-R7YDZSN7.js} +3 -3
- package/dist/cli/{chunk-4WPHK2R3.js → chunk-SVVUC3B4.js} +7 -7
- package/dist/cli/{chunk-4M4AASO3.js → chunk-TU56J4OV.js} +13 -13
- package/dist/cli/{chunk-2CUPFDW5.mjs → chunk-USAQ42OG.mjs} +5 -5
- package/dist/cli/{chunk-623FFVZU.mjs → chunk-VKGNQC2S.mjs} +5 -5
- package/dist/cli/{chunk-WDLY4HST.js → chunk-VPQDKL5O.js} +6 -6
- package/dist/cli/{chunk-H26ZSNLX.js → chunk-WF652G74.js} +14 -14
- package/dist/cli/{chunk-57PPAYDB.mjs → chunk-XUX5KGCQ.mjs} +2 -2
- package/dist/cli/{chunk-567HD6G6.mjs → chunk-XZN3DBTP.mjs} +1 -1
- package/dist/cli/{chunk-PTOPMO22.mjs → chunk-YZK5RSUL.mjs} +1 -1
- package/dist/cli/{chunk-D5BLTX5L.js → chunk-ZH5HCAN3.js} +1 -1
- package/dist/cli/{csv-CMUWCM46.mjs → csv-CJKKHGNQ.mjs} +4 -4
- package/dist/cli/{csv-N4P2XOKP.js → csv-MBSCHS4H.js} +13 -13
- package/dist/cli/{db-GFI45WV5.js → db-45HNPCY3.js} +27 -27
- package/dist/cli/{db-J5HFGOUO.mjs → db-EAFR6N45.mjs} +6 -6
- package/dist/cli/{describe-NKHH3VVI.mjs → describe-IXW3LDGC.mjs} +18 -18
- package/dist/cli/describe-PYLZAVRI.js +50 -0
- package/dist/cli/{executions-FMWHU72C.js → executions-SZAES2S4.js} +8 -8
- package/dist/cli/{executions-54QEYYE6.mjs → executions-ZATZV7O6.mjs} +6 -6
- package/dist/cli/{feedback-R7C3AZKN.js → feedback-KXLF4GR4.js} +14 -14
- package/dist/cli/{feedback-HA4QUWMU.mjs → feedback-NY63KEK2.mjs} +6 -6
- package/dist/cli/{git-OVG63PJV.mjs → git-BSSSTR6N.mjs} +5 -5
- package/dist/cli/git-T5JTVBYZ.js +25 -0
- package/dist/cli/index.js +141 -141
- package/dist/cli/index.mjs +43 -43
- package/dist/cli/{legacy-noops-PLQWYZ7A.mjs → legacy-noops-CYF6DJBF.mjs} +6 -6
- package/dist/cli/{legacy-noops-GM2F7GMV.js → legacy-noops-XQANGML3.js} +9 -9
- package/dist/cli/{monitors-QXK7JTRG.mjs → monitors-ABJVLWIP.mjs} +7 -7
- package/dist/cli/{monitors-SJBIPV4K.js → monitors-F3PTNP45.js} +100 -100
- package/dist/cli/{org-OFMMMVYT.mjs → org-BHF6Y5R7.mjs} +6 -6
- package/dist/cli/{org-XKO7BBT4.js → org-WQAPZI5Q.js} +86 -86
- package/dist/cli/{pages-ZGXRON5S.js → pages-U3EJ2NPL.js} +18 -18
- package/dist/cli/{pages-NDI2K34M.mjs → pages-W4HWVJUG.mjs} +6 -6
- package/dist/cli/{play-2YD5NTH6.js → play-2UHKONON.js} +317 -317
- package/dist/cli/{play-SMKNTBRK.mjs → play-3T4X3ZKH.mjs} +18 -18
- package/dist/cli/{providers-6SKF5W4Y.mjs → providers-2G2VTNDG.mjs} +6 -6
- package/dist/cli/{providers-52PIA36O.js → providers-LUK5LIUA.js} +9 -9
- package/dist/cli/{quickstart-4Z22WVLK.js → quickstart-76P6PGID.js} +6 -6
- package/dist/cli/{quickstart-RVA335ED.mjs → quickstart-XP4PJZ7N.mjs} +4 -4
- package/dist/cli/{run-GMN4TCVV.mjs → run-ACIHA53A.mjs} +23 -23
- package/dist/cli/{run-FDTSTMDM.js → run-S2KHGBCM.js} +41 -41
- package/dist/cli/search-5MD65V43.js +33 -0
- package/dist/cli/{search-2FG2USCF.mjs → search-VFIJCUZL.mjs} +8 -8
- package/dist/cli/{search-output-AC3AAV6E.mjs → search-output-2KFLZS5F.mjs} +4 -4
- package/dist/cli/{search-output-5FKQYLFW.js → search-output-GV7NNB4X.js} +6 -6
- package/dist/cli/{secrets-5A7AY2YU.js → secrets-KJSFEW2F.js} +15 -15
- package/dist/cli/{secrets-MA4ZTNVG.mjs → secrets-MAQLBVC4.mjs} +6 -6
- package/dist/cli/sessions-FDMO7PAA.js +22 -0
- package/dist/cli/{sessions-LBYKV5O4.mjs → sessions-G5MWNJ75.mjs} +6 -6
- package/dist/cli/{settings-6MQVNROV.mjs → settings-MR6UFOK5.mjs} +13 -13
- package/dist/cli/{settings-HA3D4GNZ.js → settings-VXGRPFXP.js} +86 -86
- package/dist/cli/{setup-3JWTNSOK.js → setup-C74BRK7N.js} +50 -50
- package/dist/cli/{setup-BXCUZOZH.mjs → setup-ZOBXMONM.mjs} +10 -10
- package/dist/cli/{skills-7ASML2WZ.mjs → skills-4CG3MHOY.mjs} +8 -8
- package/dist/cli/skills-KRUL7QCT.js +37 -0
- package/dist/cli/tools-CGHOSCPS.js +57 -0
- package/dist/cli/{tools-7IJWJXZ3.mjs → tools-YXCXZ4ZD.mjs} +17 -17
- package/dist/cli/update-S2TILEHZ.js +35 -0
- package/dist/cli/{update-JFKH4SVK.mjs → update-Z3C5W3I4.mjs} +10 -10
- package/dist/cli/{views-2EURG3P5.mjs → views-45B2FZQT.mjs} +6 -6
- package/dist/cli/{views-XTAIIX2Y.js → views-XGP2GZ52.js} +18 -18
- package/dist/cli/{workflow-AXOF74HO.js → workflow-DWO35XHZ.js} +17 -17
- package/dist/cli/{workflow-7FCQ34QD.mjs → workflow-KQRWSNBH.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-3UDRBF5D.js +0 -43
- package/dist/cli/describe-HFUWQN3A.js +0 -50
- package/dist/cli/git-ETBABM6D.js +0 -25
- package/dist/cli/search-63X5FPDM.js +0 -33
- package/dist/cli/sessions-SMWWKKD4.js +0 -22
- package/dist/cli/skills-OJ7NZL6S.js +0 -37
- package/dist/cli/tools-Y2VMPUSI.js +0 -57
- package/dist/cli/update-JURCS2FE.js +0 -35
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
* Rules:
|
|
13
13
|
* - Retry only an operation that converges when repeated: reads, cordon,
|
|
14
14
|
* uncordon, start, stop, metadata writes, and staged secret writes of the
|
|
15
|
-
* same values. A create is never repeated blindly
|
|
16
|
-
*
|
|
15
|
+
* same values. A create is never repeated blindly: every create is preceded
|
|
16
|
+
* by a read that shows its identity absent, and an ambiguous create is
|
|
17
|
+
* followed by a bounded read-back window before another one may be issued
|
|
18
|
+
* (see `createWithReadBeforeRetry`).
|
|
17
19
|
* - Retry only a failure classified as transient from structured data (HTTP
|
|
18
20
|
* status, Node/Bun error code, subprocess exit status) or from the stable
|
|
19
21
|
* transport text flyctl prints (`FLY_TRANSIENT_OUTPUT_PATTERNS`). Auth,
|
|
@@ -24,6 +26,7 @@
|
|
|
24
26
|
* - A subprocess killed by a signal or by its own deadline (exit 124 or
|
|
25
27
|
* >= 128) may have applied its effect; only a read may repeat it.
|
|
26
28
|
*/
|
|
29
|
+
import { randomBytes } from 'node:crypto';
|
|
27
30
|
|
|
28
31
|
export const FLY_TRANSIENT_RETRY_ATTEMPTS = 4;
|
|
29
32
|
export const FLY_TRANSIENT_RETRY_BASE_DELAY_MS = 1_000;
|
|
@@ -510,28 +513,284 @@ export async function runFlyctlWithTransientRetry(
|
|
|
510
513
|
}
|
|
511
514
|
|
|
512
515
|
/**
|
|
513
|
-
*
|
|
514
|
-
*
|
|
515
|
-
|
|
516
|
-
|
|
516
|
+
* Fly Machine metadata key that carries the nonce of the create request that
|
|
517
|
+
* made the Machine. Diagnostic identity only: nothing selects on it.
|
|
518
|
+
*/
|
|
519
|
+
export const FLY_CREATE_NONCE_METADATA_KEY = 'deepline_create_attempt_nonce';
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* One identity may see at most this many create requests end ambiguously:
|
|
523
|
+
* the first and one retry. Requests Fly answered with a rate limit are
|
|
524
|
+
* counted by `FLY_TRANSIENT_RETRY_ATTEMPTS` instead.
|
|
525
|
+
*/
|
|
526
|
+
export const FLY_CREATE_ATTEMPTS = 2;
|
|
527
|
+
export const FLY_CREATE_READBACK_POLL_MS = 5_000;
|
|
528
|
+
/**
|
|
529
|
+
* How long an identity must stay absent from provider state, after an
|
|
530
|
+
* ambiguous create, before another create may be issued for it.
|
|
531
|
+
*
|
|
532
|
+
* Aborting a request client-side does not cancel it at Fly. In Production
|
|
533
|
+
* release run 43649841489 (2026-11-14) `POST /machines` for
|
|
534
|
+
* `receipt-12f77d159ca8-2` hit the 30 s client timeout, one inventory read
|
|
535
|
+
* 1.1 s later did not contain a Machine with that name, a second create was
|
|
536
|
+
* issued, and within about 35 s of the abort Fly listed two Machines with
|
|
537
|
+
* that name. Whether the first create committed late or the list lagged, a
|
|
538
|
+
* single read moments after a timeout proves nothing.
|
|
539
|
+
*
|
|
540
|
+
* 90 s is about 2.5 times that observed worst case. Together with the 30 s
|
|
541
|
+
* request timeout, a create has two minutes from the moment it was issued to
|
|
542
|
+
* become visible before it is treated as never having happened. Fly records
|
|
543
|
+
* no upper bound for this, so a later arrival is still possible; the callers'
|
|
544
|
+
* readiness waits detect that surplus instead of assuming it away.
|
|
545
|
+
*/
|
|
546
|
+
export const FLY_CREATE_ABSENCE_WINDOW_MS = 90_000;
|
|
547
|
+
|
|
548
|
+
export type FlyCreateAttempt = Readonly<{
|
|
549
|
+
/** 1-based create attempt for this identity in this process. */
|
|
550
|
+
number: number;
|
|
551
|
+
/**
|
|
552
|
+
* Unique per create request. The caller persists it on the resource (Fly
|
|
553
|
+
* Machine metadata) so provider state names the request that made it.
|
|
554
|
+
*/
|
|
555
|
+
nonce: string;
|
|
556
|
+
}>;
|
|
557
|
+
|
|
558
|
+
export type FlyCreateResult<T> = Readonly<{
|
|
559
|
+
/** `adopted`: provider state already held the identity; nothing was created. */
|
|
560
|
+
outcome: 'created' | 'adopted';
|
|
561
|
+
/**
|
|
562
|
+
* The resource(s) carrying the identity. More than one adopted resource is
|
|
563
|
+
* a surplus an earlier ambiguous create left behind; the caller's
|
|
564
|
+
* readiness path must reconcile or refuse it.
|
|
565
|
+
*/
|
|
566
|
+
resources: readonly T[];
|
|
567
|
+
}>;
|
|
568
|
+
|
|
569
|
+
export type FlyCreateReadBackOptions = Readonly<{
|
|
570
|
+
/** Create requests that may end ambiguously. */
|
|
571
|
+
attempts?: number;
|
|
572
|
+
/** Create requests in total, rate-limited ones included. */
|
|
573
|
+
requests?: number;
|
|
574
|
+
/** Total time that may be spent waiting out rate limits. */
|
|
575
|
+
rateLimitDeadlineMs?: number;
|
|
576
|
+
random?: () => number;
|
|
577
|
+
absenceWindowMs?: number;
|
|
578
|
+
pollMs?: number;
|
|
579
|
+
now?: () => number;
|
|
580
|
+
sleep?: (ms: number) => Promise<void>;
|
|
581
|
+
log?: (line: string) => void;
|
|
582
|
+
nonce?: () => string;
|
|
583
|
+
}>;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* An ambiguous create could be neither confirmed nor ruled out inside its
|
|
587
|
+
* bounds. Nothing further was created; the identity may or may not exist.
|
|
588
|
+
*/
|
|
589
|
+
export class FlyAmbiguousCreateError extends Error {
|
|
590
|
+
readonly identity: string;
|
|
591
|
+
readonly nonces: readonly string[];
|
|
592
|
+
constructor(input: {
|
|
593
|
+
identity: string;
|
|
594
|
+
nonces: readonly string[];
|
|
595
|
+
detail: string;
|
|
596
|
+
cause: unknown;
|
|
597
|
+
}) {
|
|
598
|
+
super(
|
|
599
|
+
`Create ${input.identity} is unresolved: ${input.detail} No further create was issued (attempt nonces: ${input.nonces.join(', ')}). Inspect provider state for this identity before retrying.`,
|
|
600
|
+
{ cause: input.cause },
|
|
601
|
+
);
|
|
602
|
+
this.name = 'FlyAmbiguousCreateError';
|
|
603
|
+
this.identity = input.identity;
|
|
604
|
+
this.nonces = input.nonces;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Fly answered `POST` with HTTP 429: the request was refused before it took
|
|
610
|
+
* effect. Unlike a timeout or a 5xx, this outcome is not ambiguous.
|
|
611
|
+
*/
|
|
612
|
+
export function isFlyRateLimitRefusal(error: unknown): boolean {
|
|
613
|
+
return error instanceof FlyTransientHttpError && error.status === 429;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function errorDetail(error: unknown): string {
|
|
617
|
+
return error instanceof Error ? error.message : String(error);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Create a provider resource that Fly does not deduplicate for us. The
|
|
622
|
+
* Machines client sends `POST /machines` with no idempotency key, and the
|
|
623
|
+
* incident above shows Fly accepting a second Machine with the same name. So
|
|
624
|
+
* the identity travels inside the request (a deterministic name, the
|
|
625
|
+
* operation id, and this attempt's nonce in Machine metadata) and provider
|
|
626
|
+
* state is the only record of whether a request took effect.
|
|
627
|
+
*
|
|
628
|
+
* - Before the first create, read. An identity that already exists is adopted.
|
|
629
|
+
* - A failure Fly answered with a non-transient status is rethrown unchanged.
|
|
630
|
+
* - HTTP 429 is also an answer: Fly refused the request and created nothing.
|
|
631
|
+
* It is sent again after the shared backoff (or `Retry-After`, when
|
|
632
|
+
* longer) with no read-back window, within `requests` requests in total
|
|
633
|
+
* and `rateLimitDeadlineMs` of waiting.
|
|
634
|
+
* - Every other transient failure is ambiguous: a client timeout, a dropped
|
|
635
|
+
* connection, and also a 5xx. The client only sees the status
|
|
636
|
+
* (`FlyTransientHttpError`), and a 502/503/504 can come from a proxy after
|
|
637
|
+
* the request reached Fly, so it cannot tell whether a 5xx was applied.
|
|
638
|
+
* Poll provider state every `pollMs` for `absenceWindowMs`. The identity
|
|
639
|
+
* appearing ends the wait and is adopted. Only a full window of absence,
|
|
640
|
+
* closed by a successful read, permits the next create. A window whose
|
|
641
|
+
* closing read failed proves nothing and fails.
|
|
642
|
+
* - At most `attempts` requests may end ambiguously. After the last one the
|
|
643
|
+
* same window runs, so a late resource is still adopted; otherwise the
|
|
644
|
+
* failure names the identity and every nonce that was sent.
|
|
645
|
+
*
|
|
646
|
+
* Worst case per identity, at the defaults: 2 x (30 s request timeout + 90 s
|
|
647
|
+
* window + one 5 s poll) plus up to 150 s of rate-limit waiting, about
|
|
648
|
+
* 6 min 40 s plus read latency.
|
|
517
649
|
*/
|
|
518
650
|
export async function createWithReadBeforeRetry<T>(input: {
|
|
519
|
-
|
|
520
|
-
|
|
651
|
+
/** Names the intended resource in every log line and error. */
|
|
652
|
+
identity: string;
|
|
653
|
+
/** Issues exactly one create that persists `attempt.nonce` on the resource. */
|
|
654
|
+
create: (attempt: FlyCreateAttempt) => Promise<T>;
|
|
655
|
+
/** Every live provider resource that carries the identity right now. */
|
|
656
|
+
findExisting: () => Promise<readonly T[]>;
|
|
657
|
+
/** One short token per resource for logs, e.g. a Machine id. */
|
|
658
|
+
describe?: (resource: T) => string;
|
|
521
659
|
classify: (error: unknown) => FlyTransientClassification;
|
|
522
|
-
options
|
|
523
|
-
}): Promise<T
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
660
|
+
options?: FlyCreateReadBackOptions;
|
|
661
|
+
}): Promise<FlyCreateResult<T>> {
|
|
662
|
+
const options = input.options ?? {};
|
|
663
|
+
const attempts = options.attempts ?? FLY_CREATE_ATTEMPTS;
|
|
664
|
+
const requests = options.requests ?? FLY_TRANSIENT_RETRY_ATTEMPTS;
|
|
665
|
+
const rateLimitDeadlineMs =
|
|
666
|
+
options.rateLimitDeadlineMs ?? FLY_TRANSIENT_RETRY_DEADLINE_MS;
|
|
667
|
+
const absenceWindowMs =
|
|
668
|
+
options.absenceWindowMs ?? FLY_CREATE_ABSENCE_WINDOW_MS;
|
|
669
|
+
const pollMs = options.pollMs ?? FLY_CREATE_READBACK_POLL_MS;
|
|
670
|
+
const now = options.now ?? Date.now;
|
|
671
|
+
const sleep =
|
|
672
|
+
options.sleep ??
|
|
673
|
+
((ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms)));
|
|
674
|
+
const log = options.log ?? ((line: string) => console.warn(line));
|
|
675
|
+
const newNonce = options.nonce ?? (() => randomBytes(8).toString('hex'));
|
|
676
|
+
const describe = (resources: readonly T[]): string =>
|
|
677
|
+
input.describe
|
|
678
|
+
? resources.map(input.describe).join(', ')
|
|
679
|
+
: `${resources.length} resource(s)`;
|
|
680
|
+
const adopt = (
|
|
681
|
+
resources: readonly T[],
|
|
682
|
+
observed: string,
|
|
683
|
+
): FlyCreateResult<T> => {
|
|
684
|
+
log(
|
|
685
|
+
resources.length === 1
|
|
686
|
+
? `[fly-create] ${input.identity}: adopting ${describe(resources)}, ${observed}; no create issued.`
|
|
687
|
+
: `[fly-create] ${input.identity}: ${resources.length} resources carry this identity (${describe(resources)}), ${observed}; no create issued. The surplus must be reconciled before this identity is used.`,
|
|
688
|
+
);
|
|
689
|
+
return { outcome: 'adopted', resources };
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
const present = await input.findExisting();
|
|
693
|
+
if (present.length > 0) return adopt(present, 'already present');
|
|
694
|
+
|
|
695
|
+
const nonces: string[] = [];
|
|
696
|
+
let lastError: unknown;
|
|
697
|
+
let ambiguous = 0;
|
|
698
|
+
let rateLimited = 0;
|
|
699
|
+
let rateLimitWaitMs = 0;
|
|
700
|
+
for (let number = 1; ; number += 1) {
|
|
701
|
+
const nonce = newNonce();
|
|
702
|
+
nonces.push(nonce);
|
|
703
|
+
// The intent is on record before the effect: the nonce is logged here and
|
|
704
|
+
// travels inside the request, so a Machine this request makes names it.
|
|
705
|
+
log(
|
|
706
|
+
`[fly-create] ${input.identity}: issuing create request ${number}/${requests} (nonce ${nonce}).`,
|
|
707
|
+
);
|
|
708
|
+
try {
|
|
709
|
+
const resource = await input.create({ number, nonce });
|
|
710
|
+
return { outcome: 'created', resources: [resource] };
|
|
711
|
+
} catch (error) {
|
|
712
|
+
const classification = input.classify(error);
|
|
713
|
+
if (!classification.transient) throw error;
|
|
714
|
+
lastError = error;
|
|
715
|
+
if (isFlyRateLimitRefusal(error)) {
|
|
716
|
+
// Fly answered and created nothing: no read-back, no ambiguity spent.
|
|
717
|
+
rateLimited += 1;
|
|
718
|
+
const delayMs = Math.max(
|
|
719
|
+
flyTransientRetryDelayMs({
|
|
720
|
+
retry: rateLimited,
|
|
721
|
+
...(options.random ? { random: options.random } : {}),
|
|
722
|
+
}),
|
|
723
|
+
classification.retryAfterMs ?? 0,
|
|
724
|
+
);
|
|
725
|
+
if (
|
|
726
|
+
number >= requests ||
|
|
727
|
+
rateLimitWaitMs + delayMs > rateLimitDeadlineMs
|
|
728
|
+
) {
|
|
729
|
+
throw new FlyTransientRetryExhaustedError({
|
|
730
|
+
label: `Create ${input.identity}`,
|
|
731
|
+
attempts: number,
|
|
732
|
+
cause: error,
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
rateLimitWaitMs += delayMs;
|
|
736
|
+
log(
|
|
737
|
+
`[fly-create] ${input.identity}: create request ${number}/${requests} (nonce ${nonce}) was refused by Fly (${classification.reason}), so nothing was created; sending it again in ${delayMs}ms.`,
|
|
738
|
+
);
|
|
739
|
+
await sleep(delayMs);
|
|
740
|
+
continue;
|
|
529
741
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
742
|
+
ambiguous += 1;
|
|
743
|
+
log(
|
|
744
|
+
`[fly-create] ${input.identity}: create request ${number}/${requests} (nonce ${nonce}) ended ambiguously (${classification.reason}; ${ambiguous}/${attempts} allowed); reading provider state every ${pollMs}ms for ${absenceWindowMs}ms before any further create.`,
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
const windowStartedAtMs = now();
|
|
749
|
+
for (let read = 1; ; read += 1) {
|
|
750
|
+
await sleep(pollMs);
|
|
751
|
+
let observed: readonly T[] | undefined;
|
|
752
|
+
let readError: unknown;
|
|
753
|
+
try {
|
|
754
|
+
observed = await input.findExisting();
|
|
755
|
+
} catch (error) {
|
|
756
|
+
readError = error;
|
|
757
|
+
}
|
|
758
|
+
const elapsedMs = now() - windowStartedAtMs;
|
|
759
|
+
if (observed !== undefined && observed.length > 0) {
|
|
760
|
+
return adopt(
|
|
761
|
+
observed,
|
|
762
|
+
`observed on read ${read}, ${elapsedMs}ms after the ambiguous create`,
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
if (elapsedMs < absenceWindowMs) {
|
|
766
|
+
if (observed === undefined) {
|
|
767
|
+
log(
|
|
768
|
+
`[fly-create] ${input.identity}: read-back ${read} failed (${errorDetail(readError)}); still inside the ${absenceWindowMs}ms window.`,
|
|
769
|
+
);
|
|
770
|
+
}
|
|
771
|
+
continue;
|
|
772
|
+
}
|
|
773
|
+
if (observed === undefined) {
|
|
774
|
+
throw new FlyAmbiguousCreateError({
|
|
775
|
+
identity: input.identity,
|
|
776
|
+
nonces,
|
|
777
|
+
detail: `create request ${number}/${requests} ended ambiguously (${errorDetail(lastError)}) and the read that closes its ${absenceWindowMs}ms read-back window failed (${errorDetail(readError)}), so absence is not proven.`,
|
|
778
|
+
cause: readError,
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
log(
|
|
782
|
+
`[fly-create] ${input.identity}: absent on ${read} read(s) over ${elapsedMs}ms after create request ${number}/${requests}.`,
|
|
783
|
+
);
|
|
784
|
+
break;
|
|
785
|
+
}
|
|
786
|
+
if (ambiguous >= attempts || number >= requests) break;
|
|
787
|
+
}
|
|
788
|
+
throw new FlyAmbiguousCreateError({
|
|
789
|
+
identity: input.identity,
|
|
790
|
+
nonces,
|
|
791
|
+
detail: `${ambiguous} create request(s) ended ambiguously (last: ${errorDetail(lastError)}) and the identity stayed absent for ${absenceWindowMs}ms after each.`,
|
|
792
|
+
cause: lastError,
|
|
793
|
+
});
|
|
535
794
|
}
|
|
536
795
|
|
|
537
796
|
/**
|
package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/engine-suspension.ts
CHANGED
|
@@ -97,6 +97,7 @@ export function createPlayRunAttemptSuspensionJob(ports: {
|
|
|
97
97
|
const resumed = await ports.store.resumeAfterPark({
|
|
98
98
|
claim: input.attempt,
|
|
99
99
|
suspension: input.suspension,
|
|
100
|
+
checkpoint: engineOutcome.checkpoint,
|
|
100
101
|
});
|
|
101
102
|
if (resumed.kind === 'fence_lost') {
|
|
102
103
|
return { kind: 'fence_lost', stage: 'resume' };
|
|
@@ -53,6 +53,8 @@ export type PlayRunAttemptStore = {
|
|
|
53
53
|
resumeAfterPark(input: {
|
|
54
54
|
claim: PlayRunAttemptClaim;
|
|
55
55
|
suspension: PlayExecutionSuspension;
|
|
56
|
+
/** Omission preserves the stored checkpoint for older callers. */
|
|
57
|
+
checkpoint?: unknown;
|
|
56
58
|
}): Promise<
|
|
57
59
|
| { kind: 'resumed'; lifecycle: PlayRunAttemptLifecycle }
|
|
58
60
|
| { kind: 'fence_lost' }
|
package/dist/bundling-sources/shared_libs/play-runtime/play-runs/attempts/postgres-fence-adapter.ts
CHANGED
|
@@ -169,13 +169,14 @@ export function createPostgresPlayRunAttemptStore(input: {
|
|
|
169
169
|
? { kind: 'parked', lifecycle: parked }
|
|
170
170
|
: { kind: 'fence_lost' };
|
|
171
171
|
},
|
|
172
|
-
async resumeAfterPark({ claim, suspension }) {
|
|
172
|
+
async resumeAfterPark({ claim, suspension, checkpoint }) {
|
|
173
173
|
const resumed = await markPostgresSchedulerAttemptRunning(
|
|
174
174
|
input.client,
|
|
175
175
|
{
|
|
176
176
|
runId: claim.runId,
|
|
177
177
|
attempt: claim.number,
|
|
178
178
|
leaseToken: claim.fenceId,
|
|
179
|
+
checkpoint,
|
|
179
180
|
preserveHeartbeatAt: suspension.kind === 'detached_runner',
|
|
180
181
|
},
|
|
181
182
|
options,
|
|
@@ -8469,6 +8469,8 @@ export async function markPostgresSchedulerAttemptRunning(
|
|
|
8469
8469
|
leaseToken: string;
|
|
8470
8470
|
/** Detached runner liveness is renewed only by the sandbox gateway. */
|
|
8471
8471
|
preserveHeartbeatAt?: boolean;
|
|
8472
|
+
/** Persist the resolved wake before admission can defer this attempt. */
|
|
8473
|
+
checkpoint?: unknown;
|
|
8472
8474
|
},
|
|
8473
8475
|
options?: Pick<PostgresSchedulerOptions, 'schema'>,
|
|
8474
8476
|
): Promise<PostgresSchedulerLifecycleOutboxEvent | null> {
|
|
@@ -8505,6 +8507,7 @@ export async function markPostgresSchedulerAttemptRunning(
|
|
|
8505
8507
|
running_run AS (
|
|
8506
8508
|
UPDATE ${tableName('runs', options)} AS target
|
|
8507
8509
|
SET status = 'running',
|
|
8510
|
+
checkpoint_json = COALESCE($6::jsonb, target.checkpoint_json),
|
|
8508
8511
|
suspension_json = CASE
|
|
8509
8512
|
WHEN $5::boolean AND target.suspension_json ->> 'kind' = 'detached_runner'
|
|
8510
8513
|
THEN target.suspension_json ELSE NULL END,
|
|
@@ -8544,6 +8547,9 @@ export async function markPostgresSchedulerAttemptRunning(
|
|
|
8544
8547
|
input.leaseToken,
|
|
8545
8548
|
outboxEventId,
|
|
8546
8549
|
input.preserveHeartbeatAt === true,
|
|
8550
|
+
input.checkpoint === undefined
|
|
8551
|
+
? null
|
|
8552
|
+
: stringifyPostgresJson(input.checkpoint),
|
|
8547
8553
|
],
|
|
8548
8554
|
);
|
|
8549
8555
|
const row = running.rows[0];
|
|
@@ -1475,6 +1475,11 @@ export type RuntimeSandboxCapacityTestEvidence = {
|
|
|
1475
1475
|
hasComputeIntent: boolean;
|
|
1476
1476
|
recordedResources: number;
|
|
1477
1477
|
firstAcquiredAtMs: number | null;
|
|
1478
|
+
/** Optional for older Preview readers; separates readiness from later work. */
|
|
1479
|
+
lastAcquiredAtMs?: number | null;
|
|
1480
|
+
/** Last durable signal acceptance, not a client-side offer timestamp. */
|
|
1481
|
+
lastSignalAtMs?: number | null;
|
|
1482
|
+
firstDeleteConfirmedAtMs?: number | null;
|
|
1478
1483
|
lastDeleteConfirmedAtMs: number | null;
|
|
1479
1484
|
};
|
|
1480
1485
|
};
|
|
@@ -1566,6 +1571,9 @@ export async function readRuntimeSandboxCapacityTestEvidence(
|
|
|
1566
1571
|
AND NULLIF(resource->>'sandboxId', '') IS NOT NULL),
|
|
1567
1572
|
'computeJobStatus', (SELECT status FROM ${schema}."compute_billing_jobs_v2" AS job WHERE job.run_id = owned_run.run_id),
|
|
1568
1573
|
'firstAcquiredAtMs', (SELECT floor(extract(epoch FROM min(provider_created_at)) * 1000)::bigint FROM owned_operations),
|
|
1574
|
+
'lastAcquiredAtMs', (SELECT floor(extract(epoch FROM max(provider_created_at)) * 1000)::bigint FROM owned_operations),
|
|
1575
|
+
'lastSignalAtMs', (SELECT floor(extract(epoch FROM max(signal.created_at)) * 1000)::bigint FROM ${schema}."signals" AS signal WHERE signal.run_id = owned_run.run_id),
|
|
1576
|
+
'firstDeleteConfirmedAtMs', (SELECT floor(extract(epoch FROM min(delete_confirmed_at)) * 1000)::bigint FROM owned_operations),
|
|
1569
1577
|
'lastDeleteConfirmedAtMs', (SELECT floor(extract(epoch FROM max(delete_confirmed_at)) * 1000)::bigint FROM owned_operations)
|
|
1570
1578
|
) FROM owned_run)
|
|
1571
1579
|
) AS evidence`,
|
|
@@ -14,14 +14,14 @@ import {
|
|
|
14
14
|
reportSetupCompleted,
|
|
15
15
|
resolvePendingAuthClaimForResume,
|
|
16
16
|
statusBannerLine
|
|
17
|
-
} from "./chunk-
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-3KQBV2CG.mjs";
|
|
18
|
+
import "./chunk-2UYERVXF.mjs";
|
|
19
|
+
import "./chunk-IETLUG4C.mjs";
|
|
20
|
+
import "./chunk-MKUYZ7LR.mjs";
|
|
21
21
|
import "./chunk-QNHHZ63P.mjs";
|
|
22
22
|
import "./chunk-DLIRSHV6.mjs";
|
|
23
23
|
import "./chunk-ZPGGW27Q.mjs";
|
|
24
|
-
import "./chunk-
|
|
24
|
+
import "./chunk-YZK5RSUL.mjs";
|
|
25
25
|
import "./chunk-WZYKRD7T.mjs";
|
|
26
26
|
import "./chunk-KRD6H754.mjs";
|
|
27
27
|
export {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _chunk4CYNH47Yjs = require('./chunk-4CYNH47Y.js');
|
|
18
|
+
require('./chunk-QZWURUBP.js');
|
|
19
|
+
require('./chunk-EYWES7F5.js');
|
|
20
|
+
require('./chunk-O7RSUW75.js');
|
|
21
|
+
require('./chunk-T2N3B7IQ.js');
|
|
22
|
+
require('./chunk-XNYIZMNQ.js');
|
|
23
|
+
require('./chunk-SQWET4SL.js');
|
|
24
|
+
require('./chunk-ZH5HCAN3.js');
|
|
25
|
+
require('./chunk-OG64RBAC.js');
|
|
26
|
+
require('./chunk-COGTRVWW.js');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
exports.EXIT_WORKSPACE_MISMATCH = _chunk4CYNH47Yjs.EXIT_WORKSPACE_MISMATCH; exports.authStatusLine = _chunk4CYNH47Yjs.authStatusLine; exports.clearPendingClaim = _chunk4CYNH47Yjs.clearPendingClaim; exports.clearSatisfiedPendingClaim = _chunk4CYNH47Yjs.clearSatisfiedPendingClaim; exports.handleRegister = _chunk4CYNH47Yjs.handleRegister; exports.handleStatus = _chunk4CYNH47Yjs.handleStatus; exports.handleWait = _chunk4CYNH47Yjs.handleWait; exports.httpJson = _chunk4CYNH47Yjs.httpJson; exports.readPendingAuthClaim = _chunk4CYNH47Yjs.readPendingAuthClaim; exports.readStatusBanner = _chunk4CYNH47Yjs.readStatusBanner; exports.registerAuthCommands = _chunk4CYNH47Yjs.registerAuthCommands; exports.reportApprovalLinkShown = _chunk4CYNH47Yjs.reportApprovalLinkShown; exports.reportSetupCompleted = _chunk4CYNH47Yjs.reportSetupCompleted; exports.resolvePendingAuthClaimForResume = _chunk4CYNH47Yjs.resolvePendingAuthClaimForResume; exports.statusBannerLine = _chunk4CYNH47Yjs.statusBannerLine;
|