@tradejs/cli 3.1.11-beta.216 → 3.1.12-beta.217
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 +149 -78
- package/dist/lib/runEnvironment.js +6 -2
- package/dist/lib/runtimeEvidenceDeployment.js +16 -9
- package/dist/lib/runtimeLineage.js +32 -11
- package/dist/lib/runtimeScorecard.js +49 -10
- package/dist/lib/runtimeSignalsStorage.js +1 -1
- package/dist/lib/strategyRelease.js +4 -2
- package/dist/scripts/replay.js +77 -36
- package/dist/scripts/replayRunner.js +77 -36
- package/dist/scripts/runtimeControl.js +3 -2
- package/dist/scripts/runtimeEvidence.js +29 -10
- package/dist/scripts/runtimeScorecard.js +49 -10
- package/dist/scripts/signals.js +58 -36
- package/dist/scripts/signalsDaemon.js +58 -36
- package/dist/scripts/strategyRelease.js +4 -2
- package/package.json +12 -8
package/dist/cli.js
CHANGED
|
@@ -12772,17 +12772,21 @@ var init_runEnvironment = __esm({
|
|
|
12772
12772
|
const strategies = deployment.enabled ? runtimeStrategies.filter((strategy) => strategy.enabled).map(
|
|
12773
12773
|
({
|
|
12774
12774
|
strategyName,
|
|
12775
|
-
|
|
12775
|
+
strategyRevision,
|
|
12776
|
+
deploymentCompositionId,
|
|
12776
12777
|
strategyPackage,
|
|
12777
12778
|
strategyPackageVersion,
|
|
12779
|
+
strategyDependencyVersions,
|
|
12778
12780
|
runtimePackageVersion,
|
|
12779
12781
|
sourceStrategyConfig,
|
|
12780
12782
|
selection
|
|
12781
12783
|
}) => ({
|
|
12782
12784
|
strategyName,
|
|
12783
|
-
|
|
12785
|
+
strategyRevision,
|
|
12786
|
+
deploymentCompositionId,
|
|
12784
12787
|
strategyPackage,
|
|
12785
12788
|
strategyPackageVersion,
|
|
12789
|
+
strategyDependencyVersions,
|
|
12786
12790
|
runtimePackageVersion,
|
|
12787
12791
|
strategyConfig: sourceStrategyConfig,
|
|
12788
12792
|
...selection ? { selection } : {}
|
|
@@ -24015,7 +24019,7 @@ var init_runtimeSignalsStorage = __esm({
|
|
|
24015
24019
|
strategy: signal.strategy,
|
|
24016
24020
|
timestamp: signal.timestamp,
|
|
24017
24021
|
...signal.runtimeConfigId && signal.runtimeConfigId !== "config" ? { runtimeConfigId: signal.runtimeConfigId } : {},
|
|
24018
|
-
...signal.
|
|
24022
|
+
...signal.strategyRevision ? { strategyRevision: signal.strategyRevision } : {}
|
|
24019
24023
|
});
|
|
24020
24024
|
shouldStoreRuntimeSignalDiagnostics = (signal) => signal.orderStatus === "completed" || signal.orderStatus === "failed";
|
|
24021
24025
|
toStoredRuntimeSignal = (signal) => {
|
|
@@ -25307,21 +25311,38 @@ async function buildRuntimeLineage({
|
|
|
25307
25311
|
projectRoot: projectRoot15,
|
|
25308
25312
|
strategyName,
|
|
25309
25313
|
compositionId,
|
|
25310
|
-
|
|
25314
|
+
strategyRevision,
|
|
25315
|
+
deploymentCompositionId,
|
|
25311
25316
|
strategyPackageVersion,
|
|
25317
|
+
strategyDependencyVersions,
|
|
25312
25318
|
runtimePackageVersion,
|
|
25313
25319
|
config: config2,
|
|
25314
25320
|
runContext,
|
|
25315
25321
|
env = process.env
|
|
25316
25322
|
}) {
|
|
25317
|
-
if (
|
|
25318
|
-
if (
|
|
25319
|
-
throw new Error(`Invalid
|
|
25323
|
+
if (strategyRevision != null) {
|
|
25324
|
+
if (!/^sr1:[a-f0-9]{16}$/.test(strategyRevision)) {
|
|
25325
|
+
throw new Error(`Invalid strategy revision: ${strategyRevision}`);
|
|
25326
|
+
}
|
|
25327
|
+
if (typeof deploymentCompositionId !== "string" || !/^dc1:[a-f0-9]{16}$/.test(deploymentCompositionId)) {
|
|
25328
|
+
throw new Error(
|
|
25329
|
+
`Invalid deployment composition id: ${String(deploymentCompositionId)}`
|
|
25330
|
+
);
|
|
25331
|
+
}
|
|
25332
|
+
if (typeof strategyPackageVersion !== "string" || !strategyPackageVersion.trim() || typeof runtimePackageVersion !== "string" || !runtimePackageVersion.trim()) {
|
|
25333
|
+
throw new Error("Invalid revision package versions");
|
|
25334
|
+
}
|
|
25335
|
+
if (!strategyDependencyVersions || Object.keys(strategyDependencyVersions).length === 0 || Object.entries(strategyDependencyVersions).some(
|
|
25336
|
+
([name, version]) => !name.startsWith("@tradejs/") || typeof version !== "string" || !version.trim()
|
|
25337
|
+
)) {
|
|
25338
|
+
throw new Error("Invalid strategy dependency versions");
|
|
25320
25339
|
}
|
|
25321
25340
|
return {
|
|
25322
|
-
schemaVersion:
|
|
25323
|
-
|
|
25341
|
+
schemaVersion: 3,
|
|
25342
|
+
strategyRevision,
|
|
25343
|
+
deploymentCompositionId,
|
|
25324
25344
|
strategyPackageVersion,
|
|
25345
|
+
strategyDependencyVersions,
|
|
25325
25346
|
runtimePackageVersion,
|
|
25326
25347
|
maxLossValue: resolveRuntimeMaxLossValue(config2)
|
|
25327
25348
|
};
|
|
@@ -25547,11 +25568,15 @@ var init_runtimeLineage = __esm({
|
|
|
25547
25568
|
gateFingerprintCache.set(cacheKey, result);
|
|
25548
25569
|
return result;
|
|
25549
25570
|
};
|
|
25550
|
-
runtimeLineageKey = (lineage) => lineage.schemaVersion ===
|
|
25551
|
-
"
|
|
25552
|
-
lineage.
|
|
25553
|
-
lineage.
|
|
25554
|
-
lineage.
|
|
25571
|
+
runtimeLineageKey = (lineage) => lineage.schemaVersion === 3 ? [
|
|
25572
|
+
"v3",
|
|
25573
|
+
lineage.deploymentCompositionId,
|
|
25574
|
+
lineage.strategyRevision,
|
|
25575
|
+
lineage.strategyPackageVersion,
|
|
25576
|
+
`deps:${fingerprintRuntimeValue(
|
|
25577
|
+
lineage.strategyDependencyVersions
|
|
25578
|
+
).slice(0, 16)}`,
|
|
25579
|
+
lineage.runtimePackageVersion
|
|
25555
25580
|
].join(":") : [
|
|
25556
25581
|
lineage.schemaVersion,
|
|
25557
25582
|
lineage.compositionId ?? "unbound-composition",
|
|
@@ -25567,13 +25592,16 @@ var init_runtimeLineage = __esm({
|
|
|
25567
25592
|
});
|
|
25568
25593
|
|
|
25569
25594
|
// src/lib/runtimeEvidenceDeployment.ts
|
|
25570
|
-
var import_runtimeStrategies3, isRecord, isNonEmptyString, INTERVALS, UNIVERSES, isRuntimeStrategySelection, parseRuntimeEvidenceDeploymentSnapshot, activeRuntimeEvidenceStrategies, runtimeDeploymentFromEvidence, resolveRuntimeEvidenceDeploymentSnapshot;
|
|
25595
|
+
var import_runtimeStrategies3, isRecord, isNonEmptyString, isPackageVersionMap, INTERVALS, UNIVERSES, isRuntimeStrategySelection, parseRuntimeEvidenceDeploymentSnapshot, activeRuntimeEvidenceStrategies, runtimeDeploymentFromEvidence, resolveRuntimeEvidenceDeploymentSnapshot;
|
|
25571
25596
|
var init_runtimeEvidenceDeployment = __esm({
|
|
25572
25597
|
"src/lib/runtimeEvidenceDeployment.ts"() {
|
|
25573
25598
|
"use strict";
|
|
25574
25599
|
import_runtimeStrategies3 = require("@tradejs/node/runtimeStrategies");
|
|
25575
25600
|
isRecord = (value) => value != null && typeof value === "object" && !Array.isArray(value);
|
|
25576
25601
|
isNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0;
|
|
25602
|
+
isPackageVersionMap = (value) => isRecord(value) && Object.keys(value).length > 0 && Object.entries(value).every(
|
|
25603
|
+
([name, version]) => name.startsWith("@tradejs/") && isNonEmptyString(version)
|
|
25604
|
+
);
|
|
25577
25605
|
INTERVALS = /* @__PURE__ */ new Set([
|
|
25578
25606
|
"1",
|
|
25579
25607
|
"3",
|
|
@@ -25592,13 +25620,13 @@ var init_runtimeEvidenceDeployment = __esm({
|
|
|
25592
25620
|
UNIVERSES = /* @__PURE__ */ new Set(["crypto", "tradfi"]);
|
|
25593
25621
|
isRuntimeStrategySelection = (value) => value === void 0 || isRecord(value) && Object.keys(value).length === 1 && Object.keys(value).every((key) => key === "tickers") && Array.isArray(value.tickers) && value.tickers.length > 0 && value.tickers.every((ticker) => isNonEmptyString(ticker));
|
|
25594
25622
|
parseRuntimeEvidenceDeploymentSnapshot = (value) => {
|
|
25595
|
-
if (!isRecord(value) || value.schemaVersion !==
|
|
25623
|
+
if (!isRecord(value) || value.schemaVersion !== 2 || !isNonEmptyString(value.id) || !isNonEmptyString(value.deploymentCompositionId) || !/^dc1:[a-f0-9]{16}$/.test(value.deploymentCompositionId) || !isNonEmptyString(value.label) || !isNonEmptyString(value.connectorName) || !isNonEmptyString(value.provider) || !isNonEmptyString(value.accountId) || typeof value.enabled !== "boolean" || !Array.isArray(value.strategies)) {
|
|
25596
25624
|
throw new Error(
|
|
25597
25625
|
"Runtime evidence deployment snapshot is missing or invalid"
|
|
25598
25626
|
);
|
|
25599
25627
|
}
|
|
25600
25628
|
const strategies = value.strategies.map((candidate) => {
|
|
25601
|
-
if (!isRecord(candidate) || !isNonEmptyString(candidate.strategyName) || !
|
|
25629
|
+
if (!isRecord(candidate) || !isNonEmptyString(candidate.strategyName) || !isNonEmptyString(candidate.strategyRevision) || !/^sr1:[a-f0-9]{16}$/.test(candidate.strategyRevision) || typeof candidate.enabled !== "boolean" || !["active", "entries_paused"].includes(String(candidate.controlState)) || !INTERVALS.has(String(candidate.interval)) || !UNIVERSES.has(String(candidate.universe)) || !isNonEmptyString(candidate.strategyPackage) || !isNonEmptyString(candidate.strategyPackageVersion) || !isPackageVersionMap(candidate.strategyDependencyVersions) || !isNonEmptyString(candidate.runtimePackageVersion) || !isRecord(candidate.strategyConfig) || !isRuntimeStrategySelection(candidate.selection)) {
|
|
25602
25630
|
throw new Error(
|
|
25603
25631
|
"Runtime evidence deployment strategy snapshot is invalid"
|
|
25604
25632
|
);
|
|
@@ -25632,15 +25660,16 @@ var init_runtimeEvidenceDeployment = __esm({
|
|
|
25632
25660
|
activeRuntimeEvidenceStrategies = (deployment) => deployment.enabled ? deployment.strategies.filter((strategy) => strategy.enabled) : [];
|
|
25633
25661
|
runtimeDeploymentFromEvidence = (deployment) => ({
|
|
25634
25662
|
id: deployment.id,
|
|
25663
|
+
deploymentCompositionId: deployment.deploymentCompositionId,
|
|
25635
25664
|
label: deployment.label,
|
|
25636
25665
|
connectorName: deployment.connectorName,
|
|
25637
25666
|
provider: deployment.provider,
|
|
25638
25667
|
accountId: deployment.accountId,
|
|
25639
25668
|
enabled: deployment.enabled,
|
|
25640
25669
|
strategies: deployment.strategies.map(
|
|
25641
|
-
({ strategyName,
|
|
25670
|
+
({ strategyName, strategyRevision, enabled, controlState, selection }) => ({
|
|
25642
25671
|
strategyName,
|
|
25643
|
-
|
|
25672
|
+
strategyRevision,
|
|
25644
25673
|
enabled,
|
|
25645
25674
|
controlState,
|
|
25646
25675
|
...selection ? { selection } : {}
|
|
@@ -25662,8 +25691,9 @@ var init_runtimeEvidenceDeployment = __esm({
|
|
|
25662
25691
|
throw new Error(`Runtime deployment not found: ${deploymentId}`);
|
|
25663
25692
|
}
|
|
25664
25693
|
return {
|
|
25665
|
-
schemaVersion:
|
|
25694
|
+
schemaVersion: 2,
|
|
25666
25695
|
id: deployment.id,
|
|
25696
|
+
deploymentCompositionId: deployment.deploymentCompositionId,
|
|
25667
25697
|
label: deployment.label,
|
|
25668
25698
|
connectorName: deployment.connectorName,
|
|
25669
25699
|
provider: deployment.provider,
|
|
@@ -25672,7 +25702,7 @@ var init_runtimeEvidenceDeployment = __esm({
|
|
|
25672
25702
|
strategies: strategies.map(
|
|
25673
25703
|
({
|
|
25674
25704
|
strategyName,
|
|
25675
|
-
|
|
25705
|
+
strategyRevision,
|
|
25676
25706
|
enabled,
|
|
25677
25707
|
controlState,
|
|
25678
25708
|
interval: interval4,
|
|
@@ -25680,12 +25710,13 @@ var init_runtimeEvidenceDeployment = __esm({
|
|
|
25680
25710
|
accountId,
|
|
25681
25711
|
strategyPackage,
|
|
25682
25712
|
strategyPackageVersion,
|
|
25713
|
+
strategyDependencyVersions,
|
|
25683
25714
|
runtimePackageVersion,
|
|
25684
|
-
|
|
25715
|
+
strategyConfig,
|
|
25685
25716
|
selection
|
|
25686
25717
|
}) => ({
|
|
25687
25718
|
strategyName,
|
|
25688
|
-
|
|
25719
|
+
strategyRevision,
|
|
25689
25720
|
enabled,
|
|
25690
25721
|
controlState,
|
|
25691
25722
|
interval: interval4,
|
|
@@ -25693,8 +25724,9 @@ var init_runtimeEvidenceDeployment = __esm({
|
|
|
25693
25724
|
...accountId ? { accountId } : {},
|
|
25694
25725
|
strategyPackage,
|
|
25695
25726
|
strategyPackageVersion,
|
|
25727
|
+
strategyDependencyVersions,
|
|
25696
25728
|
runtimePackageVersion,
|
|
25697
|
-
strategyConfig
|
|
25729
|
+
strategyConfig,
|
|
25698
25730
|
...selection ? { selection } : {}
|
|
25699
25731
|
})
|
|
25700
25732
|
),
|
|
@@ -26135,7 +26167,7 @@ var init_runtimeEvidenceSync2 = __esm({
|
|
|
26135
26167
|
});
|
|
26136
26168
|
|
|
26137
26169
|
// src/lib/runtimeScorecard.ts
|
|
26138
|
-
var asRecord6, asArray3, finiteNumber5, finiteString2, round, unwrapRows, runtimePayload, runtimeWindow, extractRuntimeRows, buildRuntimeLineageSummary, belongsToRuntimeLineage, runtimeDeploymentBinding, belongsToRuntimeDeployment, belongsToStrategy, filterArtifactByStrategy, countBy2, buildDistributions, buildDistributionDelta, sum2, statsCount, tradeTimestamp, dedupeTrades, maxDrawdown, buildRollingPerformance, getReplayComparison, replayCountsForStrategy, getCalibrationSummary, getProspectiveSummary, buildRuntimeScorecard, formatRuntimeScorecardMarkdown;
|
|
26170
|
+
var asRecord6, asArray3, finiteNumber5, finiteString2, packageVersionMap, round, unwrapRows, runtimePayload, runtimeWindow, extractRuntimeRows, buildRuntimeLineageSummary, belongsToRuntimeLineage, runtimeDeploymentBinding, belongsToRuntimeDeployment, belongsToStrategy, filterArtifactByStrategy, countBy2, buildDistributions, buildDistributionDelta, sum2, statsCount, tradeTimestamp, dedupeTrades, maxDrawdown, buildRollingPerformance, getReplayComparison, replayCountsForStrategy, getCalibrationSummary, getProspectiveSummary, buildRuntimeScorecard, formatRuntimeScorecardMarkdown;
|
|
26139
26171
|
var init_runtimeScorecard = __esm({
|
|
26140
26172
|
"src/lib/runtimeScorecard.ts"() {
|
|
26141
26173
|
"use strict";
|
|
@@ -26144,6 +26176,19 @@ var init_runtimeScorecard = __esm({
|
|
|
26144
26176
|
asArray3 = (value) => Array.isArray(value) ? value : [];
|
|
26145
26177
|
finiteNumber5 = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
26146
26178
|
finiteString2 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
26179
|
+
packageVersionMap = (value) => {
|
|
26180
|
+
const record = asRecord6(value);
|
|
26181
|
+
if (!record || Object.keys(record).length === 0) return null;
|
|
26182
|
+
const entries = Object.entries(record);
|
|
26183
|
+
if (entries.some(
|
|
26184
|
+
([name, version]) => !name.startsWith("@tradejs/") || finiteString2(version) == null
|
|
26185
|
+
)) {
|
|
26186
|
+
return null;
|
|
26187
|
+
}
|
|
26188
|
+
return Object.fromEntries(
|
|
26189
|
+
entries.map(([name, version]) => [name, String(version).trim()]).sort(([left], [right]) => left.localeCompare(right))
|
|
26190
|
+
);
|
|
26191
|
+
};
|
|
26147
26192
|
round = (value, decimals = 6) => Number(value.toFixed(decimals));
|
|
26148
26193
|
unwrapRows = (value, key) => asArray3(value).map((item) => asRecord6(asRecord6(item)?.[key]) ?? asRecord6(item)).filter((item) => item != null);
|
|
26149
26194
|
runtimePayload = (artifact) => {
|
|
@@ -26176,12 +26221,18 @@ var init_runtimeScorecard = __esm({
|
|
|
26176
26221
|
const lineages = lineageRows.map((row) => asRecord6(row.runtimeLineage)).filter((lineage) => lineage != null);
|
|
26177
26222
|
const identities = /* @__PURE__ */ new Map();
|
|
26178
26223
|
for (const lineage of lineages) {
|
|
26179
|
-
const identity2 = lineage.schemaVersion ===
|
|
26180
|
-
schemaVersion:
|
|
26181
|
-
|
|
26224
|
+
const identity2 = lineage.schemaVersion === 3 ? {
|
|
26225
|
+
schemaVersion: 3,
|
|
26226
|
+
strategyRevision: finiteString2(lineage.strategyRevision),
|
|
26227
|
+
deploymentCompositionId: finiteString2(
|
|
26228
|
+
lineage.deploymentCompositionId
|
|
26229
|
+
),
|
|
26182
26230
|
strategyPackageVersion: finiteString2(
|
|
26183
26231
|
lineage.strategyPackageVersion
|
|
26184
26232
|
),
|
|
26233
|
+
strategyDependencyVersions: packageVersionMap(
|
|
26234
|
+
lineage.strategyDependencyVersions
|
|
26235
|
+
),
|
|
26185
26236
|
runtimePackageVersion: finiteString2(lineage.runtimePackageVersion),
|
|
26186
26237
|
maxLossValue: finiteNumber5(lineage.maxLossValue)
|
|
26187
26238
|
} : {
|
|
@@ -26198,7 +26249,7 @@ var init_runtimeScorecard = __esm({
|
|
|
26198
26249
|
}
|
|
26199
26250
|
const identity = identities.size === 1 ? [...identities.values()][0] : null;
|
|
26200
26251
|
const schemaVersion = finiteNumber5(identity?.schemaVersion);
|
|
26201
|
-
const identityComplete = lineages.length > 0 && identity != null && (schemaVersion ===
|
|
26252
|
+
const identityComplete = lineages.length > 0 && identity != null && (schemaVersion === 3 && finiteString2(identity.strategyRevision) != null && finiteString2(identity.deploymentCompositionId) != null && finiteString2(identity.strategyPackageVersion) != null && packageVersionMap(identity.strategyDependencyVersions) != null && finiteString2(identity.runtimePackageVersion) != null || schemaVersion === 1 && identity.compositionId != null && identity.gitSha != null && identity.gitDirty === false && identity.gateFingerprint != null && identity.configFingerprint != null && identity.contextFingerprint != null) && identity.maxLossValue != null;
|
|
26202
26253
|
const coverageComplete = lineageRows.length > 0 && lineages.length === lineageRows.length;
|
|
26203
26254
|
const complete = identityComplete && coverageComplete;
|
|
26204
26255
|
const lineageKey = identityComplete ? runtimeLineageKey(identity) : null;
|
|
@@ -26211,8 +26262,12 @@ var init_runtimeScorecard = __esm({
|
|
|
26211
26262
|
rowsWithLineage: lineages.length,
|
|
26212
26263
|
schemaVersion,
|
|
26213
26264
|
lineageKey,
|
|
26214
|
-
|
|
26265
|
+
strategyRevision: finiteString2(identity?.strategyRevision),
|
|
26266
|
+
deploymentCompositionId: finiteString2(identity?.deploymentCompositionId),
|
|
26215
26267
|
strategyPackageVersion: finiteString2(identity?.strategyPackageVersion),
|
|
26268
|
+
strategyDependencyVersions: packageVersionMap(
|
|
26269
|
+
identity?.strategyDependencyVersions
|
|
26270
|
+
),
|
|
26216
26271
|
runtimePackageVersion: finiteString2(identity?.runtimePackageVersion),
|
|
26217
26272
|
compositionId: finiteString2(identity?.compositionId),
|
|
26218
26273
|
gitSha: finiteString2(identity?.gitSha),
|
|
@@ -27168,7 +27223,7 @@ async function collectReleaseEvidenceReferences(references) {
|
|
|
27168
27223
|
})
|
|
27169
27224
|
);
|
|
27170
27225
|
}
|
|
27171
|
-
var import_node_crypto12, import_promises26, import_node_path21, import_types10, import_strategyReleaseEvidence3, SHA256_RE2, LINEAGE_FINGERPRINT_RE, REQUIRED_LONG_WINDOWS, REQUIRED_STABLE_TERMINAL_WINDOWS, MIN_RECENT_DIRECTION_REPAIR_TRADES, safeSegment3, compactTimestamp2, verifyFullPeriodChartArtifact, hasExactRuntimeTarget, deriveStrategyReleaseResearchDecision, canonicalStrategyReleaseJson, strategyReleaseSha256, assertFingerprint, assertLineageFingerprint, releaseReasons, deriveReleaseGates, verifyEvidenceComposition, createStrategyReleaseManifest, createStrategyReleaseEnvelope, verifyStrategyReleaseEnvelope, verifyStrategyEvidenceMarkerEnvelope, releaseMarkers, writeJsonAtomic2, publishStrategyRelease, publishStrategyLiveDiagnosis, finiteString3, finiteNumber6, finiteDirectionPolicy, uniqueStrings, incompleteEvidenceLineage, extractEvidenceLineage, verifyCompletedCoreResearchBundle;
|
|
27226
|
+
var import_node_crypto12, import_promises26, import_node_path21, import_types10, import_strategyReleaseEvidence3, SHA256_RE2, LINEAGE_FINGERPRINT_RE, STRATEGY_REVISION_RE, DEPLOYMENT_COMPOSITION_ID_RE, REQUIRED_LONG_WINDOWS, REQUIRED_STABLE_TERMINAL_WINDOWS, MIN_RECENT_DIRECTION_REPAIR_TRADES, safeSegment3, compactTimestamp2, verifyFullPeriodChartArtifact, hasExactRuntimeTarget, deriveStrategyReleaseResearchDecision, canonicalStrategyReleaseJson, strategyReleaseSha256, assertFingerprint, assertLineageFingerprint, releaseReasons, deriveReleaseGates, verifyEvidenceComposition, createStrategyReleaseManifest, createStrategyReleaseEnvelope, verifyStrategyReleaseEnvelope, verifyStrategyEvidenceMarkerEnvelope, releaseMarkers, writeJsonAtomic2, publishStrategyRelease, publishStrategyLiveDiagnosis, finiteString3, finiteNumber6, finiteDirectionPolicy, uniqueStrings, incompleteEvidenceLineage, extractEvidenceLineage, verifyCompletedCoreResearchBundle;
|
|
27172
27227
|
var init_strategyRelease = __esm({
|
|
27173
27228
|
"src/lib/strategyRelease.ts"() {
|
|
27174
27229
|
"use strict";
|
|
@@ -27182,6 +27237,8 @@ var init_strategyRelease = __esm({
|
|
|
27182
27237
|
init_evidenceRetention();
|
|
27183
27238
|
SHA256_RE2 = /^[a-f0-9]{64}$/;
|
|
27184
27239
|
LINEAGE_FINGERPRINT_RE = /^[a-f0-9]{16}$/;
|
|
27240
|
+
STRATEGY_REVISION_RE = /^sr1:[a-f0-9]{16}$/;
|
|
27241
|
+
DEPLOYMENT_COMPOSITION_ID_RE = /^dc1:[a-f0-9]{16}$/;
|
|
27185
27242
|
REQUIRED_LONG_WINDOWS = [1095, 1460, 1825];
|
|
27186
27243
|
REQUIRED_STABLE_TERMINAL_WINDOWS = [365, 180, 90];
|
|
27187
27244
|
MIN_RECENT_DIRECTION_REPAIR_TRADES = 20;
|
|
@@ -27204,7 +27261,7 @@ var init_strategyRelease = __esm({
|
|
|
27204
27261
|
}
|
|
27205
27262
|
};
|
|
27206
27263
|
hasExactRuntimeTarget = (target, strategyName) => Boolean(
|
|
27207
|
-
target?.userName.trim() && target.deploymentId.trim() && target.accountId.trim() && target.strategyName.trim() === strategyName.trim() &&
|
|
27264
|
+
target?.userName.trim() && target.deploymentId.trim() && target.accountId.trim() && target.strategyName.trim() === strategyName.trim() && STRATEGY_REVISION_RE.test(target.strategyRevision) && DEPLOYMENT_COMPOSITION_ID_RE.test(target.deploymentCompositionId)
|
|
27208
27265
|
);
|
|
27209
27266
|
deriveStrategyReleaseResearchDecision = async (input) => {
|
|
27210
27267
|
const blockers = [];
|
|
@@ -27305,7 +27362,7 @@ var init_strategyRelease = __esm({
|
|
|
27305
27362
|
maxLossValue: 1,
|
|
27306
27363
|
requiresRuntimeBinding: true,
|
|
27307
27364
|
blockers: [],
|
|
27308
|
-
summary: "The portable micro-forward handoff is ready. Commit its deployment, account binding, complete config
|
|
27365
|
+
summary: "The portable micro-forward handoff is ready. Commit its deployment, account binding, and complete config in TradeJS-Project; runtime revisions are computed from the installed packages and parsed config."
|
|
27309
27366
|
};
|
|
27310
27367
|
}
|
|
27311
27368
|
return {
|
|
@@ -28458,7 +28515,8 @@ var init_runtimeControl = __esm({
|
|
|
28458
28515
|
ok: true,
|
|
28459
28516
|
strategies: strategies.map((strategy) => ({
|
|
28460
28517
|
strategyName: strategy.strategyName,
|
|
28461
|
-
|
|
28518
|
+
strategyRevision: strategy.strategyRevision,
|
|
28519
|
+
deploymentCompositionId: strategy.deploymentCompositionId,
|
|
28462
28520
|
controlState: strategy.controlState,
|
|
28463
28521
|
interval: strategy.interval,
|
|
28464
28522
|
universe: strategy.universe,
|
|
@@ -28537,7 +28595,7 @@ var init_runtimeControl = __esm({
|
|
|
28537
28595
|
userName: userName2,
|
|
28538
28596
|
deploymentId,
|
|
28539
28597
|
strategyName,
|
|
28540
|
-
|
|
28598
|
+
strategyRevision: reference.strategyRevision,
|
|
28541
28599
|
previousState,
|
|
28542
28600
|
nextState,
|
|
28543
28601
|
createdBy: `cli:${userName2}`
|
|
@@ -31552,18 +31610,14 @@ var init_evaluations = __esm({
|
|
|
31552
31610
|
symbol,
|
|
31553
31611
|
timestamp,
|
|
31554
31612
|
runtimeConfigId,
|
|
31555
|
-
|
|
31613
|
+
strategyRevision,
|
|
31556
31614
|
deploymentId,
|
|
31557
31615
|
accountId
|
|
31558
31616
|
}) => {
|
|
31559
31617
|
const runtimeScope = deploymentId ? [deploymentId, accountId ?? "default-account"] : [];
|
|
31560
|
-
return
|
|
31561
|
-
|
|
31562
|
-
|
|
31563
|
-
`v${runtimeVersion}`,
|
|
31564
|
-
symbol,
|
|
31565
|
-
timestamp
|
|
31566
|
-
].join(":") : runtimeConfigId && runtimeConfigId !== "config" ? [
|
|
31618
|
+
return strategyRevision ? [...runtimeScope, strategyName, strategyRevision, symbol, timestamp].join(
|
|
31619
|
+
":"
|
|
31620
|
+
) : runtimeConfigId && runtimeConfigId !== "config" ? [
|
|
31567
31621
|
...runtimeScope,
|
|
31568
31622
|
strategyName,
|
|
31569
31623
|
runtimeConfigId,
|
|
@@ -31576,7 +31630,7 @@ var init_evaluations = __esm({
|
|
|
31576
31630
|
scope.accountId ?? "default-account",
|
|
31577
31631
|
scope.strategy,
|
|
31578
31632
|
scope.runtimeConfigId ?? "config",
|
|
31579
|
-
scope.
|
|
31633
|
+
scope.strategyRevision ?? "research",
|
|
31580
31634
|
scope.symbol,
|
|
31581
31635
|
runtimeLineageKey(scope.lineage)
|
|
31582
31636
|
].join(":");
|
|
@@ -31618,7 +31672,7 @@ var init_evaluations = __esm({
|
|
|
31618
31672
|
deploymentId: evaluation.deploymentId,
|
|
31619
31673
|
accountId: evaluation.accountId,
|
|
31620
31674
|
runtimeConfigId: evaluation.runtimeConfigId,
|
|
31621
|
-
|
|
31675
|
+
strategyRevision: evaluation.strategyRevision,
|
|
31622
31676
|
symbol: evaluation.symbol,
|
|
31623
31677
|
lineage: evaluation.runtimeLineage
|
|
31624
31678
|
});
|
|
@@ -31630,7 +31684,7 @@ var init_evaluations = __esm({
|
|
|
31630
31684
|
...evaluation.deploymentId ? { deploymentId: evaluation.deploymentId } : {},
|
|
31631
31685
|
...evaluation.accountId ? { accountId: evaluation.accountId } : {},
|
|
31632
31686
|
runtimeConfigId: evaluation.runtimeConfigId,
|
|
31633
|
-
|
|
31687
|
+
strategyRevision: evaluation.strategyRevision,
|
|
31634
31688
|
lineage: evaluation.runtimeLineage,
|
|
31635
31689
|
firstTimestamp: Math.min(
|
|
31636
31690
|
existing?.firstTimestamp ?? evaluation.timestamp,
|
|
@@ -32180,15 +32234,17 @@ var init_tickerEvaluator = __esm({
|
|
|
32180
32234
|
for (const runtimeStrategy of runtimeStrategies) {
|
|
32181
32235
|
const {
|
|
32182
32236
|
strategyName,
|
|
32183
|
-
|
|
32237
|
+
strategyRevision,
|
|
32238
|
+
deploymentCompositionId,
|
|
32184
32239
|
controlState,
|
|
32185
32240
|
strategyPackageVersion,
|
|
32241
|
+
strategyDependencyVersions,
|
|
32186
32242
|
runtimePackageVersion,
|
|
32187
32243
|
strategyCreator,
|
|
32188
32244
|
sourceStrategyConfig,
|
|
32189
32245
|
strategyConfig
|
|
32190
32246
|
} = runtimeStrategy;
|
|
32191
|
-
const runtimeIdentity =
|
|
32247
|
+
const runtimeIdentity = strategyRevision;
|
|
32192
32248
|
const runtimeConfig = buildRuntimeModeStrategyConfig({
|
|
32193
32249
|
strategyConfig,
|
|
32194
32250
|
env: "CRON",
|
|
@@ -32198,8 +32254,10 @@ var init_tickerEvaluator = __esm({
|
|
|
32198
32254
|
const runtimeLineage = await buildRuntimeLineage({
|
|
32199
32255
|
projectRoot: projectRoot15,
|
|
32200
32256
|
strategyName,
|
|
32201
|
-
|
|
32257
|
+
strategyRevision,
|
|
32258
|
+
deploymentCompositionId,
|
|
32202
32259
|
strategyPackageVersion,
|
|
32260
|
+
strategyDependencyVersions,
|
|
32203
32261
|
runtimePackageVersion,
|
|
32204
32262
|
config: { strategyConfig },
|
|
32205
32263
|
runContext: {
|
|
@@ -32241,7 +32299,7 @@ var init_tickerEvaluator = __esm({
|
|
|
32241
32299
|
userName: userName3,
|
|
32242
32300
|
connectorName,
|
|
32243
32301
|
runtimeConfigId: runtimeIdentity,
|
|
32244
|
-
|
|
32302
|
+
strategyRevision,
|
|
32245
32303
|
entriesPaused: controlState === "entries_paused",
|
|
32246
32304
|
runtimeLineage,
|
|
32247
32305
|
runtimeConfigSnapshot: {
|
|
@@ -32296,14 +32354,14 @@ var init_tickerEvaluator = __esm({
|
|
|
32296
32354
|
symbol,
|
|
32297
32355
|
timestamp: lastCandle.timestamp,
|
|
32298
32356
|
runtimeConfigId: runtimeIdentity,
|
|
32299
|
-
|
|
32357
|
+
strategyRevision,
|
|
32300
32358
|
deploymentId,
|
|
32301
32359
|
accountId
|
|
32302
32360
|
}),
|
|
32303
32361
|
userName: userName3,
|
|
32304
32362
|
strategy: strategyName,
|
|
32305
32363
|
runtimeConfigId: runtimeIdentity,
|
|
32306
|
-
|
|
32364
|
+
strategyRevision,
|
|
32307
32365
|
runtimeLineage,
|
|
32308
32366
|
symbol,
|
|
32309
32367
|
interval: interval4,
|
|
@@ -32321,13 +32379,13 @@ var init_tickerEvaluator = __esm({
|
|
|
32321
32379
|
}
|
|
32322
32380
|
if (stats) stats.signals += 1;
|
|
32323
32381
|
signal.runtimeConfigId = runtimeIdentity;
|
|
32324
|
-
signal.
|
|
32382
|
+
signal.strategyRevision = strategyRevision;
|
|
32325
32383
|
signal.runtimeLineage = runtimeLineage;
|
|
32326
32384
|
signal.deploymentId = deploymentId;
|
|
32327
32385
|
signal.accountId = accountId;
|
|
32328
32386
|
const signalRuntimeIdentity = [
|
|
32329
32387
|
...deploymentId ? [deploymentId, accountId ?? "default-account"] : [],
|
|
32330
|
-
|
|
32388
|
+
strategyRevision
|
|
32331
32389
|
].join(":");
|
|
32332
32390
|
if (signalRuntimeIdentity && !signal.signalId.endsWith(`:${signalRuntimeIdentity}`)) {
|
|
32333
32391
|
signal.signalId = `${signal.signalId}:${signalRuntimeIdentity}`;
|
|
@@ -32349,14 +32407,14 @@ var init_tickerEvaluator = __esm({
|
|
|
32349
32407
|
symbol,
|
|
32350
32408
|
timestamp: lastCandle.timestamp,
|
|
32351
32409
|
runtimeConfigId: runtimeIdentity,
|
|
32352
|
-
|
|
32410
|
+
strategyRevision,
|
|
32353
32411
|
deploymentId,
|
|
32354
32412
|
accountId
|
|
32355
32413
|
}),
|
|
32356
32414
|
userName: userName3,
|
|
32357
32415
|
strategy: strategyName,
|
|
32358
32416
|
runtimeConfigId: runtimeIdentity,
|
|
32359
|
-
|
|
32417
|
+
strategyRevision,
|
|
32360
32418
|
runtimeLineage,
|
|
32361
32419
|
symbol,
|
|
32362
32420
|
interval: interval4,
|
|
@@ -32389,7 +32447,7 @@ var init_configuredScopes = __esm({
|
|
|
32389
32447
|
"src/lib/signals/configuredScopes.ts"() {
|
|
32390
32448
|
"use strict";
|
|
32391
32449
|
sorted = (values) => values ? [...values].sort() : [];
|
|
32392
|
-
formatConfiguredStrategyIdentity = (strategy) => `${strategy.strategyName}
|
|
32450
|
+
formatConfiguredStrategyIdentity = (strategy) => `${strategy.strategyName}@${strategy.strategyRevision}[${strategy.controlState}]`;
|
|
32393
32451
|
getConfiguredScopeActiveSymbols = ({
|
|
32394
32452
|
trades,
|
|
32395
32453
|
deploymentId,
|
|
@@ -32414,6 +32472,7 @@ var init_configuredScopes = __esm({
|
|
|
32414
32472
|
}) => {
|
|
32415
32473
|
const deploymentIdentity = JSON.stringify({
|
|
32416
32474
|
id: deployment.id,
|
|
32475
|
+
deploymentCompositionId: deployment.deploymentCompositionId,
|
|
32417
32476
|
enabled: deployment.enabled,
|
|
32418
32477
|
connectorName: deployment.connectorName,
|
|
32419
32478
|
provider: deployment.provider,
|
|
@@ -32826,7 +32885,7 @@ var init_runner = __esm({
|
|
|
32826
32885
|
new Set(
|
|
32827
32886
|
tickers.flatMap(
|
|
32828
32887
|
(symbol) => runtimeStrategies.map(
|
|
32829
|
-
({ strategyName,
|
|
32888
|
+
({ strategyName, strategyRevision }) => buildSignalsStrategyLifecycleKey({
|
|
32830
32889
|
connectorName,
|
|
32831
32890
|
universe: sessionUniverse,
|
|
32832
32891
|
accountId,
|
|
@@ -32834,7 +32893,7 @@ var init_runner = __esm({
|
|
|
32834
32893
|
symbol,
|
|
32835
32894
|
interval: interval5,
|
|
32836
32895
|
strategyName,
|
|
32837
|
-
configId:
|
|
32896
|
+
configId: strategyRevision
|
|
32838
32897
|
})
|
|
32839
32898
|
)
|
|
32840
32899
|
)
|
|
@@ -33476,7 +33535,7 @@ var init_runtimeEvidenceSource = __esm({
|
|
|
33476
33535
|
deploymentId,
|
|
33477
33536
|
accountId,
|
|
33478
33537
|
runtimeConfigId,
|
|
33479
|
-
|
|
33538
|
+
strategyRevision,
|
|
33480
33539
|
timestamp,
|
|
33481
33540
|
lineage
|
|
33482
33541
|
}) => {
|
|
@@ -33491,7 +33550,7 @@ var init_runtimeEvidenceSource = __esm({
|
|
|
33491
33550
|
...deploymentId ? { deploymentId } : {},
|
|
33492
33551
|
...accountId ? { accountId } : {},
|
|
33493
33552
|
...runtimeConfigId ? { runtimeConfigId } : {},
|
|
33494
|
-
...
|
|
33553
|
+
...strategyRevision ? { strategyRevision } : {},
|
|
33495
33554
|
lineage,
|
|
33496
33555
|
firstTimestamp: existing ? Math.min(existing.firstTimestamp, timestamp) : timestamp,
|
|
33497
33556
|
lastTimestamp: existing ? Math.max(existing.lastTimestamp, timestamp) : timestamp
|
|
@@ -33504,7 +33563,7 @@ var init_runtimeEvidenceSource = __esm({
|
|
|
33504
33563
|
deploymentId: signal.deploymentId,
|
|
33505
33564
|
accountId: signal.accountId,
|
|
33506
33565
|
runtimeConfigId: signal.runtimeConfigId,
|
|
33507
|
-
|
|
33566
|
+
strategyRevision: signal.strategyRevision,
|
|
33508
33567
|
timestamp: signal.timestamp,
|
|
33509
33568
|
lineage: signal.runtimeLineage
|
|
33510
33569
|
});
|
|
@@ -33516,7 +33575,7 @@ var init_runtimeEvidenceSource = __esm({
|
|
|
33516
33575
|
deploymentId: evaluation.deploymentId,
|
|
33517
33576
|
accountId: evaluation.accountId,
|
|
33518
33577
|
runtimeConfigId: evaluation.runtimeConfigId,
|
|
33519
|
-
|
|
33578
|
+
strategyRevision: evaluation.strategyRevision,
|
|
33520
33579
|
timestamp: evaluation.timestamp,
|
|
33521
33580
|
lineage: evaluation.runtimeLineage
|
|
33522
33581
|
});
|
|
@@ -34025,9 +34084,11 @@ var init_historicalSignalsReplay = __esm({
|
|
|
34025
34084
|
runtimeStrategies.map(async (runtimeStrategy) => {
|
|
34026
34085
|
const {
|
|
34027
34086
|
strategyName,
|
|
34028
|
-
|
|
34087
|
+
strategyRevision,
|
|
34088
|
+
deploymentCompositionId,
|
|
34029
34089
|
strategyPackage,
|
|
34030
34090
|
strategyPackageVersion,
|
|
34091
|
+
strategyDependencyVersions,
|
|
34031
34092
|
runtimePackageVersion,
|
|
34032
34093
|
strategyConfig,
|
|
34033
34094
|
selection
|
|
@@ -34043,7 +34104,7 @@ var init_historicalSignalsReplay = __esm({
|
|
|
34043
34104
|
strategyName,
|
|
34044
34105
|
projectRoot: replayProjectRoot
|
|
34045
34106
|
});
|
|
34046
|
-
if (installed.strategyPackage !== strategyPackage || installed.strategyPackageVersion !== strategyPackageVersion || installed.runtimePackageVersion !== runtimePackageVersion) {
|
|
34107
|
+
if (installed.strategyPackage !== strategyPackage || installed.strategyPackageVersion !== strategyPackageVersion || JSON.stringify(installed.strategyDependencyVersions) !== JSON.stringify(strategyDependencyVersions) || installed.runtimePackageVersion !== runtimePackageVersion) {
|
|
34047
34108
|
throw new Error(
|
|
34048
34109
|
`Runtime evidence package mismatch for ${strategyName}: expected=${strategyPackage}@${strategyPackageVersion}/@tradejs/node@${runtimePackageVersion}, installed=${installed.strategyPackage ?? "missing"}@${installed.strategyPackageVersion ?? "missing"}/@tradejs/node@${installed.runtimePackageVersion ?? "missing"}`
|
|
34049
34110
|
);
|
|
@@ -34054,9 +34115,11 @@ var init_historicalSignalsReplay = __esm({
|
|
|
34054
34115
|
);
|
|
34055
34116
|
return {
|
|
34056
34117
|
strategyName,
|
|
34057
|
-
|
|
34118
|
+
strategyRevision,
|
|
34119
|
+
deploymentCompositionId,
|
|
34058
34120
|
strategyPackage,
|
|
34059
34121
|
strategyPackageVersion,
|
|
34122
|
+
strategyDependencyVersions,
|
|
34060
34123
|
runtimePackageVersion,
|
|
34061
34124
|
strategyCreator,
|
|
34062
34125
|
strategyConfig,
|
|
@@ -34260,8 +34323,10 @@ var init_historicalSignalsReplay = __esm({
|
|
|
34260
34323
|
loadedStrategies.filter((strategy) => strategyIncludesSymbol(strategy, symbol)).map(
|
|
34261
34324
|
async ({
|
|
34262
34325
|
strategyName,
|
|
34263
|
-
|
|
34326
|
+
strategyRevision,
|
|
34327
|
+
deploymentCompositionId,
|
|
34264
34328
|
strategyPackageVersion,
|
|
34329
|
+
strategyDependencyVersions,
|
|
34265
34330
|
runtimePackageVersion,
|
|
34266
34331
|
strategyCreator,
|
|
34267
34332
|
strategyConfig,
|
|
@@ -34270,11 +34335,13 @@ var init_historicalSignalsReplay = __esm({
|
|
|
34270
34335
|
const runtimeLineage = await buildRuntimeLineage({
|
|
34271
34336
|
projectRoot: replayProjectRoot,
|
|
34272
34337
|
strategyName,
|
|
34273
|
-
|
|
34338
|
+
strategyRevision,
|
|
34339
|
+
deploymentCompositionId,
|
|
34274
34340
|
strategyPackageVersion,
|
|
34341
|
+
strategyDependencyVersions,
|
|
34275
34342
|
runtimePackageVersion,
|
|
34276
34343
|
config: {
|
|
34277
|
-
configId:
|
|
34344
|
+
configId: strategyRevision,
|
|
34278
34345
|
strategyConfig,
|
|
34279
34346
|
symbolResultConfig: strategyResults?.[symbol]?.config ?? null
|
|
34280
34347
|
},
|
|
@@ -34298,7 +34365,8 @@ var init_historicalSignalsReplay = __esm({
|
|
|
34298
34365
|
run: await strategyCreator({
|
|
34299
34366
|
userName: replayUserName,
|
|
34300
34367
|
connectorName,
|
|
34301
|
-
runtimeConfigId:
|
|
34368
|
+
runtimeConfigId: strategyRevision,
|
|
34369
|
+
strategyRevision,
|
|
34302
34370
|
runtimeLineage,
|
|
34303
34371
|
universe: preparedRun.universe,
|
|
34304
34372
|
accountId: preparedRun.accountId,
|
|
@@ -36959,15 +37027,15 @@ var init_outputReport = __esm({
|
|
|
36959
37027
|
contexts: /* @__PURE__ */ new Set()
|
|
36960
37028
|
};
|
|
36961
37029
|
existing.scopes += 1;
|
|
36962
|
-
if (record.lineage.schemaVersion ===
|
|
36963
|
-
existing.gitShas.add(
|
|
37030
|
+
if (record.lineage.schemaVersion === 3) {
|
|
37031
|
+
existing.gitShas.add(record.lineage.deploymentCompositionId);
|
|
36964
37032
|
existing.dirty.add("n/a");
|
|
36965
|
-
existing.gates.add("
|
|
36966
|
-
existing.configs.add(
|
|
37033
|
+
existing.gates.add("package-owned");
|
|
37034
|
+
existing.configs.add(record.lineage.strategyRevision);
|
|
36967
37035
|
existing.contexts.add(
|
|
36968
37036
|
[
|
|
36969
|
-
record.lineage.strategyPackageVersion
|
|
36970
|
-
record.lineage.runtimePackageVersion
|
|
37037
|
+
record.lineage.strategyPackageVersion,
|
|
37038
|
+
record.lineage.runtimePackageVersion
|
|
36971
37039
|
].join("/")
|
|
36972
37040
|
);
|
|
36973
37041
|
} else {
|
|
@@ -37301,17 +37369,20 @@ var init_replayRunner = __esm({
|
|
|
37301
37369
|
).map(
|
|
37302
37370
|
({
|
|
37303
37371
|
strategyName,
|
|
37304
|
-
|
|
37372
|
+
strategyRevision,
|
|
37305
37373
|
strategyPackage,
|
|
37306
37374
|
strategyPackageVersion,
|
|
37375
|
+
strategyDependencyVersions,
|
|
37307
37376
|
runtimePackageVersion,
|
|
37308
37377
|
strategyConfig,
|
|
37309
37378
|
selection
|
|
37310
37379
|
}) => ({
|
|
37311
37380
|
strategyName,
|
|
37312
|
-
|
|
37381
|
+
strategyRevision,
|
|
37382
|
+
deploymentCompositionId: evidenceMetadata.deployment.deploymentCompositionId,
|
|
37313
37383
|
strategyPackage,
|
|
37314
37384
|
strategyPackageVersion,
|
|
37385
|
+
strategyDependencyVersions,
|
|
37315
37386
|
runtimePackageVersion,
|
|
37316
37387
|
strategyConfig,
|
|
37317
37388
|
...selection ? { selection } : {}
|