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
|
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
|
|
|
205
205
|
// getters keep their established compatibility behavior.
|
|
206
206
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
207
207
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
208
|
-
version: '0.3.
|
|
208
|
+
version: '0.3.533',
|
|
209
209
|
updateSummary: {
|
|
210
210
|
introducedIn: '0.3.90',
|
|
211
211
|
summary:
|
|
@@ -714,6 +714,16 @@ const authoredStepContext = new AsyncLocalStorage<{
|
|
|
714
714
|
invocationId?: string;
|
|
715
715
|
}>();
|
|
716
716
|
const toolExecutionOverrides = new AsyncLocalStorage<{ force: boolean }>();
|
|
717
|
+
/**
|
|
718
|
+
* `ctx.runSteps` passes each `runIf` leg to `ctx.step` with a receipt gate
|
|
719
|
+
* keyed by the leg's body. Unless the run's checkpoint already holds the
|
|
720
|
+
* step, the gate evaluates the condition inside the step: after its
|
|
721
|
+
* occurrence and boundary are allocated, in its authored scope and work
|
|
722
|
+
* window. False means the step returns its body's value without reading or
|
|
723
|
+
* writing its receipt. Module-private, so `ctx.step` gains no public
|
|
724
|
+
* parameter.
|
|
725
|
+
*/
|
|
726
|
+
const runStepsReceiptGates = new WeakMap<object, () => Promise<boolean>>();
|
|
717
727
|
|
|
718
728
|
/**
|
|
719
729
|
* Diagnostic split of one direct tool call, recorded only in the existing
|
|
@@ -13450,45 +13460,63 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
13450
13460
|
),
|
|
13451
13461
|
});
|
|
13452
13462
|
}
|
|
13453
|
-
const runStep = async () =>
|
|
13454
|
-
options?.checkpointSteps
|
|
13455
|
-
|
|
13456
|
-
|
|
13457
|
-
|
|
13458
|
-
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13471
|
-
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13485
|
-
|
|
13486
|
-
|
|
13463
|
+
const runStep = async () => {
|
|
13464
|
+
if (!options?.checkpointSteps) {
|
|
13465
|
+
return await this.executeStepProgramStep(
|
|
13466
|
+
step,
|
|
13467
|
+
currentRow,
|
|
13468
|
+
index,
|
|
13469
|
+
stepPath,
|
|
13470
|
+
undefined,
|
|
13471
|
+
stageExecution,
|
|
13472
|
+
);
|
|
13473
|
+
}
|
|
13474
|
+
// Set by the receipt gate below, so the body reuses the decision
|
|
13475
|
+
// instead of evaluating the condition a second time.
|
|
13476
|
+
let decision: { shouldRun: boolean } | undefined;
|
|
13477
|
+
const body = async () =>
|
|
13478
|
+
await this.executeStepProgramStep(
|
|
13479
|
+
step,
|
|
13480
|
+
currentRow,
|
|
13481
|
+
index,
|
|
13482
|
+
stepPath,
|
|
13483
|
+
undefined,
|
|
13484
|
+
stageExecution,
|
|
13485
|
+
decision ? { ...options, decision } : options,
|
|
13486
|
+
);
|
|
13487
|
+
const conditional = step.resolver;
|
|
13488
|
+
if (isRuntimeConditionalStepResolver(conditional)) {
|
|
13489
|
+
// A `runIf` leg the row does not take returns its declared else
|
|
13490
|
+
// value and runs nothing. Its receipt read and write were serial
|
|
13491
|
+
// gateway requests at the end of every waterfall row, so it skips
|
|
13492
|
+
// them. It stays a step: the same occurrence and boundary, the same
|
|
13493
|
+
// events, and its condition evaluated in the step's scope.
|
|
13494
|
+
runStepsReceiptGates.set(body, async () => {
|
|
13495
|
+
// Truthiness, as the body tests it: a condition that returns
|
|
13496
|
+
// nothing skips its leg.
|
|
13497
|
+
decision = {
|
|
13498
|
+
shouldRun: Boolean(await conditional.when(currentRow, index)),
|
|
13499
|
+
};
|
|
13500
|
+
return decision.shouldRun;
|
|
13501
|
+
});
|
|
13502
|
+
}
|
|
13503
|
+
return await this.step(stepPath.join('.'), body, {
|
|
13504
|
+
semanticKey: stableDigest(
|
|
13505
|
+
stableStringify({
|
|
13487
13506
|
index,
|
|
13507
|
+
input: currentRow,
|
|
13488
13508
|
stepPath,
|
|
13489
|
-
|
|
13490
|
-
|
|
13491
|
-
|
|
13509
|
+
}),
|
|
13510
|
+
),
|
|
13511
|
+
...(step.staleAfterSeconds !== undefined
|
|
13512
|
+
? { staleAfterSeconds: step.staleAfterSeconds }
|
|
13513
|
+
: options?.defaultStaleAfterSeconds !== undefined
|
|
13514
|
+
? {
|
|
13515
|
+
staleAfterSeconds: options.defaultStaleAfterSeconds,
|
|
13516
|
+
}
|
|
13517
|
+
: {}),
|
|
13518
|
+
});
|
|
13519
|
+
};
|
|
13492
13520
|
let value: unknown;
|
|
13493
13521
|
try {
|
|
13494
13522
|
value = await runStep();
|
|
@@ -13620,7 +13648,11 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
13620
13648
|
path: string[],
|
|
13621
13649
|
previousCell?: PreviousCell,
|
|
13622
13650
|
stageExecution?: { skipped: boolean },
|
|
13623
|
-
options?: {
|
|
13651
|
+
options?: {
|
|
13652
|
+
defaultStaleAfterSeconds?: number | null;
|
|
13653
|
+
/** A `runIf` decision the caller already evaluated for this row. */
|
|
13654
|
+
decision?: { shouldRun: boolean };
|
|
13655
|
+
},
|
|
13624
13656
|
): Promise<unknown> {
|
|
13625
13657
|
const resolver = step.resolver;
|
|
13626
13658
|
const store = rowContext.getStore();
|
|
@@ -13650,7 +13682,9 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
13650
13682
|
}
|
|
13651
13683
|
|
|
13652
13684
|
if (isRuntimeConditionalStepResolver(resolver)) {
|
|
13653
|
-
const shouldRun =
|
|
13685
|
+
const shouldRun = options?.decision
|
|
13686
|
+
? options.decision.shouldRun
|
|
13687
|
+
: await resolver.when(currentRow, index);
|
|
13654
13688
|
// ADR 0019: the per-row branch this evaluator selected, written onto the
|
|
13655
13689
|
// cell the decision governs. `run`/`else` is the runtime's own vocabulary
|
|
13656
13690
|
// for a `runIf` conditional — the only per-row branch construct the
|
|
@@ -17999,6 +18033,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
17999
18033
|
run: () => T | Promise<T>,
|
|
18000
18034
|
options?: RuntimeStepOptions,
|
|
18001
18035
|
): Promise<T> {
|
|
18036
|
+
const readsReceipt = runStepsReceiptGates.get(run);
|
|
18002
18037
|
if (!rowContext.getStore()) this.assertRowAdmissionOpen();
|
|
18003
18038
|
this.assertNoPendingDurableSuspension();
|
|
18004
18039
|
validatePlayAuthoringField('ctx.step.id', key);
|
|
@@ -18064,6 +18099,37 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
18064
18099
|
const boundaryId = this.durableBoundaryId(
|
|
18065
18100
|
`step-${scope}:${normalizedKey}${explicitStepScope ? `:${explicitStepScope}` : ''}${boundarySuffix}`,
|
|
18066
18101
|
);
|
|
18102
|
+
// The step's own work: the call positions and sleeps it takes. A `runIf`
|
|
18103
|
+
// gate runs in the same capture before the receipt read, so the
|
|
18104
|
+
// condition's calls and sleeps count as the step's, as they did when the
|
|
18105
|
+
// condition ran at the start of the step's body.
|
|
18106
|
+
const callAdvances = new Map<string, number>();
|
|
18107
|
+
// Sleeps the gate's condition took on this attempt. The step's recorded
|
|
18108
|
+
// count includes them; a receipt recovered after the gate counts them
|
|
18109
|
+
// already, so recovery advances only the rest.
|
|
18110
|
+
let conditionSleeps = 0;
|
|
18111
|
+
const inStepWindow = async <R>(work: () => R | Promise<R>): Promise<R> =>
|
|
18112
|
+
rowStore?.replayCallIndexes
|
|
18113
|
+
? await rowContext.run(
|
|
18114
|
+
{
|
|
18115
|
+
...rowStore,
|
|
18116
|
+
replayStepCaptures: [
|
|
18117
|
+
...(rowStore.replayStepCaptures ?? []),
|
|
18118
|
+
callAdvances,
|
|
18119
|
+
],
|
|
18120
|
+
},
|
|
18121
|
+
work,
|
|
18122
|
+
)
|
|
18123
|
+
: await work();
|
|
18124
|
+
const checkpointedStep = () => {
|
|
18125
|
+
const existing = assertKnownResolvedBoundary(
|
|
18126
|
+
boundaryId,
|
|
18127
|
+
this.checkpoint.resolvedBoundaries?.[boundaryId],
|
|
18128
|
+
);
|
|
18129
|
+
return existing?.kind === 'step' && 'output' in existing
|
|
18130
|
+
? existing
|
|
18131
|
+
: null;
|
|
18132
|
+
};
|
|
18067
18133
|
const advanceRecoveredSleepCursor = async (
|
|
18068
18134
|
receipt?: RuntimeStepReceipt,
|
|
18069
18135
|
) => {
|
|
@@ -18078,15 +18144,13 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
18078
18144
|
: receipt?.runId === this.currentReceiptOwnerRunId
|
|
18079
18145
|
? ((await this.readStepSleepCount(boundaryId)) ?? 0)
|
|
18080
18146
|
: 0;
|
|
18081
|
-
|
|
18082
|
-
|
|
18147
|
+
const remaining = sleepCount - Math.min(conditionSleeps, sleepCount);
|
|
18148
|
+
if (Number.isSafeInteger(remaining) && remaining > 0)
|
|
18149
|
+
this.sleepBoundaryIndex += remaining;
|
|
18083
18150
|
};
|
|
18084
18151
|
const executeStep = async (): Promise<T> => {
|
|
18085
|
-
const existing =
|
|
18086
|
-
|
|
18087
|
-
this.checkpoint.resolvedBoundaries?.[boundaryId],
|
|
18088
|
-
);
|
|
18089
|
-
if (existing?.kind === 'step' && 'output' in existing) {
|
|
18152
|
+
const existing = checkpointedStep();
|
|
18153
|
+
if (existing) {
|
|
18090
18154
|
this.runtimeLog(
|
|
18091
18155
|
`ctx.step(${normalizedKey}): recovered result from checkpoint`,
|
|
18092
18156
|
);
|
|
@@ -18095,19 +18159,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
18095
18159
|
}
|
|
18096
18160
|
|
|
18097
18161
|
const sleepBoundaryIndexBefore = this.sleepBoundaryIndex;
|
|
18098
|
-
const
|
|
18099
|
-
const output = rowStore?.replayCallIndexes
|
|
18100
|
-
? await rowContext.run(
|
|
18101
|
-
{
|
|
18102
|
-
...rowStore,
|
|
18103
|
-
replayStepCaptures: [
|
|
18104
|
-
...(rowStore.replayStepCaptures ?? []),
|
|
18105
|
-
callAdvances,
|
|
18106
|
-
],
|
|
18107
|
-
},
|
|
18108
|
-
run,
|
|
18109
|
-
)
|
|
18110
|
-
: await run();
|
|
18162
|
+
const output = await inStepWindow(run);
|
|
18111
18163
|
assertJsonSerializableStepOutput(normalizedKey, output);
|
|
18112
18164
|
// A caught durable suspension is still the invocation's outcome. Never
|
|
18113
18165
|
// publish an enclosing step fallback that would make a later resume skip
|
|
@@ -18115,7 +18167,7 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
18115
18167
|
this.assertNoPendingDurableSuspension();
|
|
18116
18168
|
const sleepCount = rowStore?.replayCallIndexes
|
|
18117
18169
|
? (callAdvances.get('sleep:legacy') ?? 0)
|
|
18118
|
-
: this.sleepBoundaryIndex - sleepBoundaryIndexBefore;
|
|
18170
|
+
: this.sleepBoundaryIndex - sleepBoundaryIndexBefore + conditionSleeps;
|
|
18119
18171
|
if (sleepCount > 0 && this.durableDirectToolResultsBackedByReceipts) {
|
|
18120
18172
|
await this.persistStepSleepCount(boundaryId, sleepCount);
|
|
18121
18173
|
}
|
|
@@ -18151,6 +18203,18 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
18151
18203
|
...(freshnessPolicy ? { invocationId: boundaryId } : {}),
|
|
18152
18204
|
},
|
|
18153
18205
|
async () => {
|
|
18206
|
+
// A step this run's checkpoint already holds is recovered as any
|
|
18207
|
+
// step is, without evaluating its condition again.
|
|
18208
|
+
if (readsReceipt && !checkpointedStep()) {
|
|
18209
|
+
const gateSleepStart = this.sleepBoundaryIndex;
|
|
18210
|
+
const takesReceipt = await inStepWindow(readsReceipt);
|
|
18211
|
+
// A row counts its own sleeps, as `executeStep` does: the shared
|
|
18212
|
+
// cursor also moves for sleeps in concurrent rows.
|
|
18213
|
+
conditionSleeps = rowStore?.replayCallIndexes
|
|
18214
|
+
? (callAdvances.get('sleep:legacy') ?? 0)
|
|
18215
|
+
: this.sleepBoundaryIndex - gateSleepStart;
|
|
18216
|
+
if (!takesReceipt) return await executeStep();
|
|
18217
|
+
}
|
|
18154
18218
|
if (freshnessPolicy) {
|
|
18155
18219
|
const semanticKey = stableStringify({
|
|
18156
18220
|
operation: 'step',
|
|
@@ -18188,7 +18252,8 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
18188
18252
|
return {
|
|
18189
18253
|
output: value === undefined ? null : value,
|
|
18190
18254
|
undefinedOutput: value === undefined,
|
|
18191
|
-
sleepCount:
|
|
18255
|
+
sleepCount:
|
|
18256
|
+
this.sleepBoundaryIndex - before + conditionSleeps,
|
|
18192
18257
|
completedAt:
|
|
18193
18258
|
(boundary?.kind === 'step'
|
|
18194
18259
|
? boundary.completedAt
|
|
@@ -18197,7 +18262,9 @@ export class PlayContextImpl implements ScalarPlayAuthoringRuntimeContext {
|
|
|
18197
18262
|
},
|
|
18198
18263
|
onOutcome: (value, freshness) => {
|
|
18199
18264
|
if (freshness.source !== 'executed') {
|
|
18200
|
-
this.sleepBoundaryIndex +=
|
|
18265
|
+
this.sleepBoundaryIndex +=
|
|
18266
|
+
value.sleepCount -
|
|
18267
|
+
Math.min(conditionSleeps, value.sleepCount);
|
|
18201
18268
|
}
|
|
18202
18269
|
return value;
|
|
18203
18270
|
},
|
package/dist/bundling-sources/shared_libs/play-runtime/deployment/commands/roll-execution-relay.ts
CHANGED
|
@@ -16,7 +16,10 @@ import {
|
|
|
16
16
|
classifyFlyRequestError,
|
|
17
17
|
createWithReadBeforeRetry,
|
|
18
18
|
describeMachineFailures,
|
|
19
|
+
FLY_CREATE_NONCE_METADATA_KEY,
|
|
19
20
|
runFlyctlWithTransientRetry,
|
|
21
|
+
type FlyCreateReadBackOptions,
|
|
22
|
+
type FlyCreateResult,
|
|
20
23
|
} from '../fly-transient-retry';
|
|
21
24
|
import { machineIsServingRuntimeGateway } from '../runtime-gateway-capacity';
|
|
22
25
|
import {
|
|
@@ -301,6 +304,128 @@ function candidates(machines: FlyMachine[], sha: string): FlyMachine[] {
|
|
|
301
304
|
export function serving(machines: FlyMachine[]): FlyMachine[] {
|
|
302
305
|
return machines.filter(machineIsServingRuntimeGateway);
|
|
303
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* More candidates exist for this SHA than the serving fleet has Machines.
|
|
309
|
+
* `POST /machines` cannot be made idempotent (see
|
|
310
|
+
* `createWithReadBeforeRetry`), so an ambiguous create can still leave a
|
|
311
|
+
* duplicate. Waiting never resolves one, so name every Machine and fail now.
|
|
312
|
+
*
|
|
313
|
+
* Unlike the receipt gateway, this rollout does not remove the duplicate by
|
|
314
|
+
* itself: it keeps no durable activation phase, so a cordoned candidate is
|
|
315
|
+
* not proof that it was never admitted (a rolled-back generation is cordoned
|
|
316
|
+
* again). Cleanup for this SHA stays the one path that deletes candidates.
|
|
317
|
+
*/
|
|
318
|
+
export class ExecutionRelayCandidateSurplusError extends Error {
|
|
319
|
+
readonly machineIds: readonly string[];
|
|
320
|
+
constructor(input: { sha: string; count: number; green: FlyMachine[] }) {
|
|
321
|
+
super(
|
|
322
|
+
`Execution relay rollout ${input.sha} has ${input.green.length} candidate Machine(s) where ${input.count} are expected: ${input.green
|
|
323
|
+
.map(
|
|
324
|
+
(machine) =>
|
|
325
|
+
`${machine.id} ${machine.name ?? '<no-name>'} state=${machine.state ?? '<no-state>'} cordoned=${machine.cordoned ?? '<unknown>'} created_at=${machine.created_at ?? '<unknown>'}`,
|
|
326
|
+
)
|
|
327
|
+
.join(
|
|
328
|
+
' | ',
|
|
329
|
+
)}. The rollout's cleanup command for this SHA removes only its still-cordoned candidates; run it, then prepare again.`,
|
|
330
|
+
);
|
|
331
|
+
this.name = 'ExecutionRelayCandidateSurplusError';
|
|
332
|
+
this.machineIds = input.green.map((machine) => machine.id);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export function assertNoExecutionRelayCandidateSurplus(input: {
|
|
337
|
+
sha: string;
|
|
338
|
+
count: number;
|
|
339
|
+
green: FlyMachine[];
|
|
340
|
+
}): void {
|
|
341
|
+
if (input.green.length > input.count) {
|
|
342
|
+
throw new ExecutionRelayCandidateSurplusError(input);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* The candidates of one rollout must be one Machine per source Machine. A
|
|
348
|
+
* create that landed after `prepare` finished shows up as a second candidate
|
|
349
|
+
* for a source that already has one. The release runs this before the
|
|
350
|
+
* receipt gateway is activated, so such a duplicate stops the release while
|
|
351
|
+
* both gateways still serve the old generation, instead of at relay
|
|
352
|
+
* activation with receipt already cut over.
|
|
353
|
+
*/
|
|
354
|
+
export function assertExecutionRelayCandidatesAreOnePerSource(input: {
|
|
355
|
+
sha: string;
|
|
356
|
+
green: FlyMachine[];
|
|
357
|
+
}): void {
|
|
358
|
+
const sources = new Set(
|
|
359
|
+
input.green.map(
|
|
360
|
+
(machine) =>
|
|
361
|
+
machine.config?.metadata?.[EXECUTION_RELAY_SOURCE_METADATA] ??
|
|
362
|
+
`<no-source:${machine.id}>`,
|
|
363
|
+
),
|
|
364
|
+
);
|
|
365
|
+
assertNoExecutionRelayCandidateSurplus({
|
|
366
|
+
sha: input.sha,
|
|
367
|
+
count: sources.size,
|
|
368
|
+
green: input.green,
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** The two Machines API calls a candidate create needs; a fake in tests. */
|
|
373
|
+
export type ExecutionRelayCandidateFlyClient = Readonly<{
|
|
374
|
+
createMachine: (config: Record<string, unknown>) => Promise<FlyMachine>;
|
|
375
|
+
listMachines: () => Promise<FlyMachine[]>;
|
|
376
|
+
}>;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Create one cordoned candidate, or adopt the Machine that already carries
|
|
380
|
+
* its identity. The identity is the deterministic name plus this SHA in Fly
|
|
381
|
+
* metadata; each create request also stamps its own nonce there. See
|
|
382
|
+
* `createWithReadBeforeRetry` for what happens when Fly does not answer.
|
|
383
|
+
*/
|
|
384
|
+
export async function createExecutionRelayCandidate(input: {
|
|
385
|
+
client: ExecutionRelayCandidateFlyClient;
|
|
386
|
+
sha: string;
|
|
387
|
+
name: string;
|
|
388
|
+
source: FlyMachine;
|
|
389
|
+
options?: FlyCreateReadBackOptions;
|
|
390
|
+
}): Promise<FlyCreateResult<FlyMachine>> {
|
|
391
|
+
const { source } = input;
|
|
392
|
+
return await createWithReadBeforeRetry<FlyMachine>({
|
|
393
|
+
identity: `execution relay candidate ${input.name} (rollout ${input.sha})`,
|
|
394
|
+
create: ({ nonce }) =>
|
|
395
|
+
input.client.createMachine({
|
|
396
|
+
name: input.name,
|
|
397
|
+
region: topology.region,
|
|
398
|
+
skip_service_registration: true,
|
|
399
|
+
config: gatewayMachineConfig({
|
|
400
|
+
profile: 'production',
|
|
401
|
+
role: 'execution',
|
|
402
|
+
image: image(input.sha),
|
|
403
|
+
metadata: {
|
|
404
|
+
deepline_gateway_role: 'execution',
|
|
405
|
+
[EXECUTION_RELAY_ROLLOUT_METADATA]: input.sha,
|
|
406
|
+
[EXECUTION_RELAY_SOURCE_METADATA]: source.id,
|
|
407
|
+
[FLY_CREATE_NONCE_METADATA_KEY]: nonce,
|
|
408
|
+
fly_process_group: topology.processGroup,
|
|
409
|
+
...(source.config?.metadata?.[
|
|
410
|
+
RUNTIME_GATEWAY_AUTOSCALED_METADATA_KEY
|
|
411
|
+
] === '1' ||
|
|
412
|
+
source.name?.startsWith('execution-relay-autoscale-') === true
|
|
413
|
+
? { [RUNTIME_GATEWAY_AUTOSCALED_METADATA_KEY]: '1' }
|
|
414
|
+
: {}),
|
|
415
|
+
},
|
|
416
|
+
}),
|
|
417
|
+
}),
|
|
418
|
+
findExisting: async () =>
|
|
419
|
+
candidates(await input.client.listMachines(), input.sha).filter(
|
|
420
|
+
(machine) => machine.name === input.name,
|
|
421
|
+
),
|
|
422
|
+
describe: (machine) =>
|
|
423
|
+
`${machine.id} (create nonce ${machine.config?.metadata?.[FLY_CREATE_NONCE_METADATA_KEY] ?? '<none>'})`,
|
|
424
|
+
classify: classifyFlyRequestError,
|
|
425
|
+
...(input.options ? { options: input.options } : {}),
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
|
|
304
429
|
async function waitForGreen(
|
|
305
430
|
client: FlyMachinesClient,
|
|
306
431
|
sha: string,
|
|
@@ -310,6 +435,7 @@ async function waitForGreen(
|
|
|
310
435
|
let last = 'waiting for candidates';
|
|
311
436
|
while (Date.now() < deadline) {
|
|
312
437
|
const green = candidates(await inventory(client), sha);
|
|
438
|
+
assertNoExecutionRelayCandidateSurplus({ sha, count, green });
|
|
313
439
|
try {
|
|
314
440
|
if (green.length !== count)
|
|
315
441
|
last = `expected ${count} candidates; found ${green.length}`;
|
|
@@ -378,29 +504,6 @@ async function prepare(sha: string): Promise<void> {
|
|
|
378
504
|
return;
|
|
379
505
|
}
|
|
380
506
|
}
|
|
381
|
-
const createCandidate = (name: string, source: FlyMachine) =>
|
|
382
|
-
client.createMachine({
|
|
383
|
-
name,
|
|
384
|
-
region: topology.region,
|
|
385
|
-
skip_service_registration: true,
|
|
386
|
-
config: gatewayMachineConfig({
|
|
387
|
-
profile: 'production',
|
|
388
|
-
role: 'execution',
|
|
389
|
-
image: image(sha),
|
|
390
|
-
metadata: {
|
|
391
|
-
deepline_gateway_role: 'execution',
|
|
392
|
-
[EXECUTION_RELAY_ROLLOUT_METADATA]: sha,
|
|
393
|
-
[EXECUTION_RELAY_SOURCE_METADATA]: source.id!,
|
|
394
|
-
fly_process_group: topology.processGroup,
|
|
395
|
-
...(source.config?.metadata?.[
|
|
396
|
-
RUNTIME_GATEWAY_AUTOSCALED_METADATA_KEY
|
|
397
|
-
] === '1' ||
|
|
398
|
-
source.name?.startsWith('execution-relay-autoscale-') === true
|
|
399
|
-
? { [RUNTIME_GATEWAY_AUTOSCALED_METADATA_KEY]: '1' }
|
|
400
|
-
: {}),
|
|
401
|
-
},
|
|
402
|
-
}),
|
|
403
|
-
});
|
|
404
507
|
if (existing.length === 0) {
|
|
405
508
|
if (
|
|
406
509
|
blue.length < topology.minimumMachines ||
|
|
@@ -410,17 +513,11 @@ async function prepare(sha: string): Promise<void> {
|
|
|
410
513
|
'Cannot prepare an execution relay generation without a healthy serving fleet.',
|
|
411
514
|
);
|
|
412
515
|
for (const [index, source] of blue.entries()) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
findExisting: async () =>
|
|
419
|
-
candidates(await inventory(client), sha).find(
|
|
420
|
-
(machine) => machine.name === name,
|
|
421
|
-
),
|
|
422
|
-
classify: classifyFlyRequestError,
|
|
423
|
-
options: { label: `Create execution relay candidate ${name}` },
|
|
516
|
+
await createExecutionRelayCandidate({
|
|
517
|
+
client,
|
|
518
|
+
sha,
|
|
519
|
+
name: candidateName(sha, index),
|
|
520
|
+
source,
|
|
424
521
|
});
|
|
425
522
|
}
|
|
426
523
|
}
|
|
@@ -566,7 +663,14 @@ export async function main(): Promise<void> {
|
|
|
566
663
|
if (command === 'activate') return await activate(sha);
|
|
567
664
|
if (command === 'rollback') return await rollback(sha);
|
|
568
665
|
if (command === 'cleanup') return await cleanup(sha);
|
|
666
|
+
if (command === 'assert-no-surplus') {
|
|
667
|
+
// Read-only: one inventory read, no provider mutation.
|
|
668
|
+
return assertExecutionRelayCandidatesAreOnePerSource({
|
|
669
|
+
sha,
|
|
670
|
+
green: candidates(await inventory(releaseFlyClient()), sha),
|
|
671
|
+
});
|
|
672
|
+
}
|
|
569
673
|
throw new Error(
|
|
570
|
-
'Usage: roll-execution-relay.ts prepare|activate|rollback|cleanup --environment production --sha <sha> --apply',
|
|
674
|
+
'Usage: roll-execution-relay.ts prepare|activate|rollback|cleanup|assert-no-surplus --environment production --sha <sha> --apply',
|
|
571
675
|
);
|
|
572
676
|
}
|