@tradejs/cli 3.1.8-beta.207 → 3.1.8-beta.212
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/cli.js +245 -471
- package/dist/lib/runtimeLineage.js +6 -6
- package/dist/lib/runtimeSignalsStorage.js +1 -1
- package/dist/lib/strategyRelease.js +6 -5
- package/dist/scripts/backtest.js +6 -2
- package/dist/scripts/replay.js +11 -11
- package/dist/scripts/replayRunner.js +11 -11
- package/dist/scripts/runtimeControl.js +177 -0
- package/dist/scripts/runtimeEvidence.js +1 -1
- package/dist/scripts/signals.js +50 -45
- package/dist/scripts/signalsDaemon.js +50 -45
- package/dist/scripts/signalsSummary.js +2 -2
- package/dist/scripts/strategyRelease.js +6 -5
- package/package.json +8 -8
- package/dist/scripts/runtimeConfig.js +0 -427
|
@@ -276,20 +276,20 @@ async function buildRuntimeLineage({
|
|
|
276
276
|
projectRoot,
|
|
277
277
|
strategyName,
|
|
278
278
|
compositionId,
|
|
279
|
-
|
|
279
|
+
version,
|
|
280
280
|
strategyPackageVersion,
|
|
281
281
|
runtimePackageVersion,
|
|
282
282
|
config,
|
|
283
283
|
runContext,
|
|
284
284
|
env = process.env
|
|
285
285
|
}) {
|
|
286
|
-
if (
|
|
287
|
-
if (!Number.isSafeInteger(
|
|
288
|
-
throw new Error(`Invalid runtime
|
|
286
|
+
if (version != null) {
|
|
287
|
+
if (!Number.isSafeInteger(version) || version <= 0) {
|
|
288
|
+
throw new Error(`Invalid runtime strategy version: ${version}`);
|
|
289
289
|
}
|
|
290
290
|
return {
|
|
291
291
|
schemaVersion: 2,
|
|
292
|
-
|
|
292
|
+
version,
|
|
293
293
|
strategyPackageVersion,
|
|
294
294
|
runtimePackageVersion,
|
|
295
295
|
maxLossValue: resolveRuntimeMaxLossValue(config)
|
|
@@ -330,7 +330,7 @@ async function buildRuntimeLineage({
|
|
|
330
330
|
maxLossValue: resolveRuntimeMaxLossValue(config)
|
|
331
331
|
};
|
|
332
332
|
}
|
|
333
|
-
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.
|
|
333
|
+
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.version].join(":") : [
|
|
334
334
|
lineage.schemaVersion,
|
|
335
335
|
lineage.compositionId ?? "unbound-composition",
|
|
336
336
|
lineage.gitSha ?? "unknown",
|
|
@@ -64,7 +64,7 @@ var toRuntimeSignalBucketRef = (signal) => ({
|
|
|
64
64
|
strategy: signal.strategy,
|
|
65
65
|
timestamp: signal.timestamp,
|
|
66
66
|
...signal.runtimeConfigId && signal.runtimeConfigId !== "config" ? { runtimeConfigId: signal.runtimeConfigId } : {},
|
|
67
|
-
...signal.
|
|
67
|
+
...signal.runtimeVersion ? { runtimeVersion: signal.runtimeVersion } : {}
|
|
68
68
|
});
|
|
69
69
|
var shouldStoreRuntimeSignalDiagnostics = (signal) => signal.orderStatus === "completed" || signal.orderStatus === "failed";
|
|
70
70
|
var toStoredRuntimeSignal = (signal) => {
|
|
@@ -300,8 +300,8 @@ var verifyFullPeriodChartArtifact = async (input) => {
|
|
|
300
300
|
return false;
|
|
301
301
|
}
|
|
302
302
|
};
|
|
303
|
-
var hasExactRuntimeTarget = (target) => Boolean(
|
|
304
|
-
target?.userName.trim() && target.deploymentId.trim() && target.accountId.trim() && target.
|
|
303
|
+
var hasExactRuntimeTarget = (target, strategyName) => Boolean(
|
|
304
|
+
target?.userName.trim() && target.deploymentId.trim() && target.accountId.trim() && target.strategyName.trim() === strategyName.trim() && Number.isSafeInteger(target.version) && target.version > 0
|
|
305
305
|
);
|
|
306
306
|
var deriveStrategyReleaseResearchDecision = async (input) => {
|
|
307
307
|
const blockers = [];
|
|
@@ -386,13 +386,14 @@ var deriveStrategyReleaseResearchDecision = async (input) => {
|
|
|
386
386
|
targetDirection: input.recentFailure?.direction ?? null,
|
|
387
387
|
maxLossValue: 1,
|
|
388
388
|
requiresRuntimeBinding: !hasExactRuntimeTarget(
|
|
389
|
-
input.forwardTest.runtimeTarget
|
|
389
|
+
input.forwardTest.runtimeTarget,
|
|
390
|
+
input.strategy
|
|
390
391
|
),
|
|
391
392
|
blockers: ["FORWARD_NOT_AUTHORIZED"],
|
|
392
393
|
summary: "The candidate is ready for a separately authorized micro-forward test at MAX_LOSS_VALUE=1."
|
|
393
394
|
};
|
|
394
395
|
}
|
|
395
|
-
if (!hasExactRuntimeTarget(input.forwardTest.runtimeTarget)) {
|
|
396
|
+
if (!hasExactRuntimeTarget(input.forwardTest.runtimeTarget, input.strategy)) {
|
|
396
397
|
return {
|
|
397
398
|
strategy: input.strategy,
|
|
398
399
|
action: "MICRO_FORWARD_READY",
|
|
@@ -401,7 +402,7 @@ var deriveStrategyReleaseResearchDecision = async (input) => {
|
|
|
401
402
|
maxLossValue: 1,
|
|
402
403
|
requiresRuntimeBinding: true,
|
|
403
404
|
blockers: [],
|
|
404
|
-
summary: "The portable micro-forward handoff is ready.
|
|
405
|
+
summary: "The portable micro-forward handoff is ready. Commit its deployment, account binding, complete config, and explicit strategy version in TradeJS-Project."
|
|
405
406
|
};
|
|
406
407
|
}
|
|
407
408
|
return {
|
package/dist/scripts/backtest.js
CHANGED
|
@@ -74,7 +74,7 @@ var import_constants5 = require("@tradejs/core/constants");
|
|
|
74
74
|
var import_time3 = require("@tradejs/core/time");
|
|
75
75
|
var import_backtestArtifacts = require("@tradejs/infra/backtestArtifacts");
|
|
76
76
|
var import_redis4 = require("@tradejs/infra/redis");
|
|
77
|
-
var
|
|
77
|
+
var import_runtimeStrategies = require("@tradejs/node/runtimeStrategies");
|
|
78
78
|
var import_types3 = require("@tradejs/types");
|
|
79
79
|
|
|
80
80
|
// src/lib/runFormatting.ts
|
|
@@ -5025,7 +5025,11 @@ var validateBacktestRuntimeDeployment = ({
|
|
|
5025
5025
|
};
|
|
5026
5026
|
var prepareRunEnvironment2 = async () => {
|
|
5027
5027
|
const deployment = validateBacktestRuntimeDeployment({
|
|
5028
|
-
deployment: flags.deployment ? await (0,
|
|
5028
|
+
deployment: flags.deployment ? await (0, import_runtimeStrategies.getRuntimeDeployment)({
|
|
5029
|
+
userName,
|
|
5030
|
+
projectRoot,
|
|
5031
|
+
deploymentId: String(flags.deployment)
|
|
5032
|
+
}) : null,
|
|
5029
5033
|
deploymentId: typeof flags.deployment === "string" ? flags.deployment : void 0
|
|
5030
5034
|
});
|
|
5031
5035
|
const preparedRun = await prepareRunEnvironment({
|
package/dist/scripts/replay.js
CHANGED
|
@@ -5139,20 +5139,20 @@ async function buildRuntimeLineage({
|
|
|
5139
5139
|
projectRoot,
|
|
5140
5140
|
strategyName,
|
|
5141
5141
|
compositionId,
|
|
5142
|
-
|
|
5142
|
+
version,
|
|
5143
5143
|
strategyPackageVersion,
|
|
5144
5144
|
runtimePackageVersion,
|
|
5145
5145
|
config,
|
|
5146
5146
|
runContext,
|
|
5147
5147
|
env = process.env
|
|
5148
5148
|
}) {
|
|
5149
|
-
if (
|
|
5150
|
-
if (!Number.isSafeInteger(
|
|
5151
|
-
throw new Error(`Invalid runtime
|
|
5149
|
+
if (version != null) {
|
|
5150
|
+
if (!Number.isSafeInteger(version) || version <= 0) {
|
|
5151
|
+
throw new Error(`Invalid runtime strategy version: ${version}`);
|
|
5152
5152
|
}
|
|
5153
5153
|
return {
|
|
5154
5154
|
schemaVersion: 2,
|
|
5155
|
-
|
|
5155
|
+
version,
|
|
5156
5156
|
strategyPackageVersion,
|
|
5157
5157
|
runtimePackageVersion,
|
|
5158
5158
|
maxLossValue: resolveRuntimeMaxLossValue(config)
|
|
@@ -5193,7 +5193,7 @@ async function buildRuntimeLineage({
|
|
|
5193
5193
|
maxLossValue: resolveRuntimeMaxLossValue(config)
|
|
5194
5194
|
};
|
|
5195
5195
|
}
|
|
5196
|
-
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.
|
|
5196
|
+
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.version].join(":") : [
|
|
5197
5197
|
lineage.schemaVersion,
|
|
5198
5198
|
lineage.compositionId ?? "unbound-composition",
|
|
5199
5199
|
lineage.gitSha ?? "unknown",
|
|
@@ -7226,7 +7226,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
7226
7226
|
strategy,
|
|
7227
7227
|
symbol,
|
|
7228
7228
|
runtimeConfigId,
|
|
7229
|
-
|
|
7229
|
+
runtimeVersion,
|
|
7230
7230
|
timestamp,
|
|
7231
7231
|
lineage
|
|
7232
7232
|
}) => {
|
|
@@ -7239,7 +7239,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
7239
7239
|
strategy,
|
|
7240
7240
|
symbol,
|
|
7241
7241
|
...runtimeConfigId ? { runtimeConfigId } : {},
|
|
7242
|
-
...
|
|
7242
|
+
...runtimeVersion ? { runtimeVersion } : {},
|
|
7243
7243
|
lineage,
|
|
7244
7244
|
firstTimestamp: existing ? Math.min(existing.firstTimestamp, timestamp) : timestamp,
|
|
7245
7245
|
lastTimestamp: existing ? Math.max(existing.lastTimestamp, timestamp) : timestamp
|
|
@@ -7250,7 +7250,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
7250
7250
|
strategy: signal.strategy,
|
|
7251
7251
|
symbol: signal.symbol,
|
|
7252
7252
|
runtimeConfigId: signal.runtimeConfigId,
|
|
7253
|
-
|
|
7253
|
+
runtimeVersion: signal.runtimeVersion,
|
|
7254
7254
|
timestamp: signal.timestamp,
|
|
7255
7255
|
lineage: signal.runtimeLineage
|
|
7256
7256
|
});
|
|
@@ -7260,7 +7260,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
7260
7260
|
strategy: evaluation.strategy,
|
|
7261
7261
|
symbol: evaluation.symbol,
|
|
7262
7262
|
runtimeConfigId: evaluation.runtimeConfigId,
|
|
7263
|
-
|
|
7263
|
+
runtimeVersion: evaluation.runtimeVersion,
|
|
7264
7264
|
timestamp: evaluation.timestamp,
|
|
7265
7265
|
lineage: evaluation.runtimeLineage
|
|
7266
7266
|
});
|
|
@@ -8575,7 +8575,7 @@ var renderLineageRows = (runtimeComparison) => {
|
|
|
8575
8575
|
existing.gitShas.add("release-versioned");
|
|
8576
8576
|
existing.dirty.add("n/a");
|
|
8577
8577
|
existing.gates.add("release-versioned");
|
|
8578
|
-
existing.configs.add(`v${record.lineage.
|
|
8578
|
+
existing.configs.add(`v${record.lineage.version}`);
|
|
8579
8579
|
existing.contexts.add(
|
|
8580
8580
|
[
|
|
8581
8581
|
record.lineage.strategyPackageVersion ?? "strategy:unknown",
|
|
@@ -5142,20 +5142,20 @@ async function buildRuntimeLineage({
|
|
|
5142
5142
|
projectRoot,
|
|
5143
5143
|
strategyName,
|
|
5144
5144
|
compositionId,
|
|
5145
|
-
|
|
5145
|
+
version,
|
|
5146
5146
|
strategyPackageVersion,
|
|
5147
5147
|
runtimePackageVersion,
|
|
5148
5148
|
config,
|
|
5149
5149
|
runContext,
|
|
5150
5150
|
env = process.env
|
|
5151
5151
|
}) {
|
|
5152
|
-
if (
|
|
5153
|
-
if (!Number.isSafeInteger(
|
|
5154
|
-
throw new Error(`Invalid runtime
|
|
5152
|
+
if (version != null) {
|
|
5153
|
+
if (!Number.isSafeInteger(version) || version <= 0) {
|
|
5154
|
+
throw new Error(`Invalid runtime strategy version: ${version}`);
|
|
5155
5155
|
}
|
|
5156
5156
|
return {
|
|
5157
5157
|
schemaVersion: 2,
|
|
5158
|
-
|
|
5158
|
+
version,
|
|
5159
5159
|
strategyPackageVersion,
|
|
5160
5160
|
runtimePackageVersion,
|
|
5161
5161
|
maxLossValue: resolveRuntimeMaxLossValue(config)
|
|
@@ -5196,7 +5196,7 @@ async function buildRuntimeLineage({
|
|
|
5196
5196
|
maxLossValue: resolveRuntimeMaxLossValue(config)
|
|
5197
5197
|
};
|
|
5198
5198
|
}
|
|
5199
|
-
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.
|
|
5199
|
+
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.version].join(":") : [
|
|
5200
5200
|
lineage.schemaVersion,
|
|
5201
5201
|
lineage.compositionId ?? "unbound-composition",
|
|
5202
5202
|
lineage.gitSha ?? "unknown",
|
|
@@ -7229,7 +7229,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
7229
7229
|
strategy,
|
|
7230
7230
|
symbol,
|
|
7231
7231
|
runtimeConfigId,
|
|
7232
|
-
|
|
7232
|
+
runtimeVersion,
|
|
7233
7233
|
timestamp,
|
|
7234
7234
|
lineage
|
|
7235
7235
|
}) => {
|
|
@@ -7242,7 +7242,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
7242
7242
|
strategy,
|
|
7243
7243
|
symbol,
|
|
7244
7244
|
...runtimeConfigId ? { runtimeConfigId } : {},
|
|
7245
|
-
...
|
|
7245
|
+
...runtimeVersion ? { runtimeVersion } : {},
|
|
7246
7246
|
lineage,
|
|
7247
7247
|
firstTimestamp: existing ? Math.min(existing.firstTimestamp, timestamp) : timestamp,
|
|
7248
7248
|
lastTimestamp: existing ? Math.max(existing.lastTimestamp, timestamp) : timestamp
|
|
@@ -7253,7 +7253,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
7253
7253
|
strategy: signal.strategy,
|
|
7254
7254
|
symbol: signal.symbol,
|
|
7255
7255
|
runtimeConfigId: signal.runtimeConfigId,
|
|
7256
|
-
|
|
7256
|
+
runtimeVersion: signal.runtimeVersion,
|
|
7257
7257
|
timestamp: signal.timestamp,
|
|
7258
7258
|
lineage: signal.runtimeLineage
|
|
7259
7259
|
});
|
|
@@ -7263,7 +7263,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
7263
7263
|
strategy: evaluation.strategy,
|
|
7264
7264
|
symbol: evaluation.symbol,
|
|
7265
7265
|
runtimeConfigId: evaluation.runtimeConfigId,
|
|
7266
|
-
|
|
7266
|
+
runtimeVersion: evaluation.runtimeVersion,
|
|
7267
7267
|
timestamp: evaluation.timestamp,
|
|
7268
7268
|
lineage: evaluation.runtimeLineage
|
|
7269
7269
|
});
|
|
@@ -8578,7 +8578,7 @@ var renderLineageRows = (runtimeComparison) => {
|
|
|
8578
8578
|
existing.gitShas.add("release-versioned");
|
|
8579
8579
|
existing.dirty.add("n/a");
|
|
8580
8580
|
existing.gates.add("release-versioned");
|
|
8581
|
-
existing.configs.add(`v${record.lineage.
|
|
8581
|
+
existing.configs.add(`v${record.lineage.version}`);
|
|
8582
8582
|
existing.contexts.add(
|
|
8583
8583
|
[
|
|
8584
8584
|
record.lineage.strategyPackageVersion ?? "strategy:unknown",
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/scripts/runtimeControl.ts
|
|
21
|
+
var runtimeControl_exports = {};
|
|
22
|
+
__export(runtimeControl_exports, {
|
|
23
|
+
RUNTIME_CONTROL_ACTIONS: () => RUNTIME_CONTROL_ACTIONS,
|
|
24
|
+
main: () => main,
|
|
25
|
+
runtimeControl: () => runtimeControl
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(runtimeControl_exports);
|
|
28
|
+
var import_config = require("dotenv/config");
|
|
29
|
+
var import_runtimeControls = require("@tradejs/infra/runtimeControls");
|
|
30
|
+
var import_runtimeStrategies = require("@tradejs/node/runtimeStrategies");
|
|
31
|
+
var argv = process.argv.slice(2);
|
|
32
|
+
var RUNTIME_CONTROL_ACTIONS = [
|
|
33
|
+
"inspect",
|
|
34
|
+
"verify",
|
|
35
|
+
"pause",
|
|
36
|
+
"resume"
|
|
37
|
+
];
|
|
38
|
+
var action = argv[0] ?? "inspect";
|
|
39
|
+
var option = (name) => {
|
|
40
|
+
const index = argv.indexOf(`--${name}`);
|
|
41
|
+
return index >= 0 ? argv[index + 1] : void 0;
|
|
42
|
+
};
|
|
43
|
+
var required = (name) => {
|
|
44
|
+
const value = String(option(name) ?? "").trim();
|
|
45
|
+
if (!value) throw new Error(`--${name} is required`);
|
|
46
|
+
return value;
|
|
47
|
+
};
|
|
48
|
+
var projectRoot = String(process.env.PROJECT_CWD || process.cwd()).trim() || process.cwd();
|
|
49
|
+
var userName = String(option("user") ?? process.env.USER_NAME ?? "root");
|
|
50
|
+
var verify = async () => {
|
|
51
|
+
const deployments = await (0, import_runtimeStrategies.listRuntimeDeployments)({ userName, projectRoot });
|
|
52
|
+
const requestedDeployment = option("deployment");
|
|
53
|
+
const selected = requestedDeployment ? deployments.filter((deployment) => deployment.id === requestedDeployment) : deployments;
|
|
54
|
+
if (requestedDeployment && !selected.length) {
|
|
55
|
+
throw new Error(`Runtime deployment not found: ${requestedDeployment}`);
|
|
56
|
+
}
|
|
57
|
+
const results = [];
|
|
58
|
+
for (const deployment of selected) {
|
|
59
|
+
try {
|
|
60
|
+
const strategies = await (0, import_runtimeStrategies.loadResolvedRuntimeStrategies)({
|
|
61
|
+
userName,
|
|
62
|
+
projectRoot,
|
|
63
|
+
deploymentId: deployment.id
|
|
64
|
+
});
|
|
65
|
+
results.push({
|
|
66
|
+
deploymentId: deployment.id,
|
|
67
|
+
ok: true,
|
|
68
|
+
strategies: strategies.map((strategy) => ({
|
|
69
|
+
strategyName: strategy.strategyName,
|
|
70
|
+
version: strategy.version,
|
|
71
|
+
controlState: strategy.controlState,
|
|
72
|
+
interval: strategy.interval,
|
|
73
|
+
universe: strategy.universe,
|
|
74
|
+
accountId: strategy.accountId,
|
|
75
|
+
strategyPackage: strategy.strategyPackage,
|
|
76
|
+
strategyPackageVersion: strategy.strategyPackageVersion,
|
|
77
|
+
runtimePackageVersion: strategy.runtimePackageVersion
|
|
78
|
+
}))
|
|
79
|
+
});
|
|
80
|
+
} catch (error) {
|
|
81
|
+
results.push({
|
|
82
|
+
deploymentId: deployment.id,
|
|
83
|
+
ok: false,
|
|
84
|
+
error: error instanceof Error ? error.message : String(error)
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
console.log(JSON.stringify({ userName, results }, null, 2));
|
|
89
|
+
if (results.some((result) => !result.ok)) process.exitCode = 1;
|
|
90
|
+
};
|
|
91
|
+
var inspect = async () => {
|
|
92
|
+
const requestedDeployment = option("deployment");
|
|
93
|
+
const requestedStrategy = option("strategy");
|
|
94
|
+
const deployments = (await (0, import_runtimeStrategies.listRuntimeDeployments)({ userName, projectRoot })).filter(
|
|
95
|
+
(deployment) => !requestedDeployment || deployment.id === requestedDeployment
|
|
96
|
+
).map((deployment) => ({
|
|
97
|
+
...deployment,
|
|
98
|
+
strategies: deployment.strategies.filter(
|
|
99
|
+
(strategy) => !requestedStrategy || strategy.strategyName === requestedStrategy
|
|
100
|
+
)
|
|
101
|
+
}));
|
|
102
|
+
console.log(JSON.stringify({ userName, deployments }, null, 2));
|
|
103
|
+
};
|
|
104
|
+
var updateControlState = async (nextState) => {
|
|
105
|
+
const deploymentId = required("deployment");
|
|
106
|
+
const strategyName = required("strategy");
|
|
107
|
+
const deployment = await (0, import_runtimeStrategies.getRuntimeDeployment)({
|
|
108
|
+
userName,
|
|
109
|
+
projectRoot,
|
|
110
|
+
deploymentId
|
|
111
|
+
});
|
|
112
|
+
if (!deployment) {
|
|
113
|
+
throw new Error(`Runtime deployment not found: ${deploymentId}`);
|
|
114
|
+
}
|
|
115
|
+
const reference = deployment.strategies.find(
|
|
116
|
+
(strategy) => strategy.strategyName === strategyName
|
|
117
|
+
);
|
|
118
|
+
if (!reference) {
|
|
119
|
+
throw new Error(`${strategyName} is not declared in ${deploymentId}`);
|
|
120
|
+
}
|
|
121
|
+
if (nextState === "active" && (!deployment.enabled || !reference.enabled)) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`${strategyName} is disabled in tradejs.config.ts and cannot be resumed manually`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
const previousState = reference.controlState;
|
|
127
|
+
if (nextState === "entries_paused") {
|
|
128
|
+
await (0, import_runtimeControls.pauseRuntimeStrategy)({
|
|
129
|
+
userName,
|
|
130
|
+
deploymentId,
|
|
131
|
+
strategyName,
|
|
132
|
+
updatedBy: `cli:${userName}`
|
|
133
|
+
});
|
|
134
|
+
} else {
|
|
135
|
+
await (0, import_runtimeControls.resumeRuntimeStrategy)({ userName, deploymentId, strategyName });
|
|
136
|
+
}
|
|
137
|
+
const updated = await (0, import_runtimeStrategies.getRuntimeDeployment)({
|
|
138
|
+
userName,
|
|
139
|
+
projectRoot,
|
|
140
|
+
deploymentId
|
|
141
|
+
});
|
|
142
|
+
const updatedReference = updated?.strategies.find(
|
|
143
|
+
(strategy) => strategy.strategyName === strategyName
|
|
144
|
+
);
|
|
145
|
+
const event = previousState === nextState ? null : await (0, import_runtimeControls.recordRuntimeStrategyControlEvent)({
|
|
146
|
+
userName,
|
|
147
|
+
deploymentId,
|
|
148
|
+
strategyName,
|
|
149
|
+
version: reference.version,
|
|
150
|
+
previousState,
|
|
151
|
+
nextState,
|
|
152
|
+
createdBy: `cli:${userName}`
|
|
153
|
+
});
|
|
154
|
+
console.log(
|
|
155
|
+
JSON.stringify(
|
|
156
|
+
{ deployment: updated, strategy: updatedReference, event },
|
|
157
|
+
null,
|
|
158
|
+
2
|
|
159
|
+
)
|
|
160
|
+
);
|
|
161
|
+
};
|
|
162
|
+
var runtimeControl = async () => {
|
|
163
|
+
if (action === "verify") return verify();
|
|
164
|
+
if (action === "pause") return updateControlState("entries_paused");
|
|
165
|
+
if (action === "resume") return updateControlState("active");
|
|
166
|
+
if (action === "inspect") return inspect();
|
|
167
|
+
throw new Error(
|
|
168
|
+
`Usage: tradejs runtime-control ${RUNTIME_CONTROL_ACTIONS.join("|")}`
|
|
169
|
+
);
|
|
170
|
+
};
|
|
171
|
+
var main = runtimeControl;
|
|
172
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
173
|
+
0 && (module.exports = {
|
|
174
|
+
RUNTIME_CONTROL_ACTIONS,
|
|
175
|
+
main,
|
|
176
|
+
runtimeControl
|
|
177
|
+
});
|
|
@@ -573,7 +573,7 @@ var import_promises2 = __toESM(require("fs/promises"));
|
|
|
573
573
|
var import_node_path2 = __toESM(require("path"));
|
|
574
574
|
|
|
575
575
|
// src/lib/runtimeLineage.ts
|
|
576
|
-
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.
|
|
576
|
+
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 2 ? ["v2", lineage.version].join(":") : [
|
|
577
577
|
lineage.schemaVersion,
|
|
578
578
|
lineage.compositionId ?? "unbound-composition",
|
|
579
579
|
lineage.gitSha ?? "unknown",
|