@tradejs/cli 3.1.11 → 3.1.12-beta.218
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
|
@@ -529,17 +529,21 @@ var loadDeploymentReplayStrategies = async ({
|
|
|
529
529
|
const strategies = deployment.enabled ? runtimeStrategies.filter((strategy) => strategy.enabled).map(
|
|
530
530
|
({
|
|
531
531
|
strategyName,
|
|
532
|
-
|
|
532
|
+
strategyRevision,
|
|
533
|
+
deploymentCompositionId,
|
|
533
534
|
strategyPackage,
|
|
534
535
|
strategyPackageVersion,
|
|
536
|
+
strategyDependencyVersions,
|
|
535
537
|
runtimePackageVersion,
|
|
536
538
|
sourceStrategyConfig,
|
|
537
539
|
selection
|
|
538
540
|
}) => ({
|
|
539
541
|
strategyName,
|
|
540
|
-
|
|
542
|
+
strategyRevision,
|
|
543
|
+
deploymentCompositionId,
|
|
541
544
|
strategyPackage,
|
|
542
545
|
strategyPackageVersion,
|
|
546
|
+
strategyDependencyVersions,
|
|
543
547
|
runtimePackageVersion,
|
|
544
548
|
strategyConfig: sourceStrategyConfig,
|
|
545
549
|
...selection ? { selection } : {}
|
|
@@ -4589,21 +4593,38 @@ async function buildRuntimeLineage({
|
|
|
4589
4593
|
projectRoot,
|
|
4590
4594
|
strategyName,
|
|
4591
4595
|
compositionId,
|
|
4592
|
-
|
|
4596
|
+
strategyRevision,
|
|
4597
|
+
deploymentCompositionId,
|
|
4593
4598
|
strategyPackageVersion,
|
|
4599
|
+
strategyDependencyVersions,
|
|
4594
4600
|
runtimePackageVersion,
|
|
4595
4601
|
config,
|
|
4596
4602
|
runContext,
|
|
4597
4603
|
env = process.env
|
|
4598
4604
|
}) {
|
|
4599
|
-
if (
|
|
4600
|
-
if (
|
|
4601
|
-
throw new Error(`Invalid
|
|
4605
|
+
if (strategyRevision != null) {
|
|
4606
|
+
if (!/^sr1:[a-f0-9]{16}$/.test(strategyRevision)) {
|
|
4607
|
+
throw new Error(`Invalid strategy revision: ${strategyRevision}`);
|
|
4608
|
+
}
|
|
4609
|
+
if (typeof deploymentCompositionId !== "string" || !/^dc1:[a-f0-9]{16}$/.test(deploymentCompositionId)) {
|
|
4610
|
+
throw new Error(
|
|
4611
|
+
`Invalid deployment composition id: ${String(deploymentCompositionId)}`
|
|
4612
|
+
);
|
|
4613
|
+
}
|
|
4614
|
+
if (typeof strategyPackageVersion !== "string" || !strategyPackageVersion.trim() || typeof runtimePackageVersion !== "string" || !runtimePackageVersion.trim()) {
|
|
4615
|
+
throw new Error("Invalid revision package versions");
|
|
4616
|
+
}
|
|
4617
|
+
if (!strategyDependencyVersions || Object.keys(strategyDependencyVersions).length === 0 || Object.entries(strategyDependencyVersions).some(
|
|
4618
|
+
([name, version]) => !name.startsWith("@tradejs/") || typeof version !== "string" || !version.trim()
|
|
4619
|
+
)) {
|
|
4620
|
+
throw new Error("Invalid strategy dependency versions");
|
|
4602
4621
|
}
|
|
4603
4622
|
return {
|
|
4604
|
-
schemaVersion:
|
|
4605
|
-
|
|
4623
|
+
schemaVersion: 3,
|
|
4624
|
+
strategyRevision,
|
|
4625
|
+
deploymentCompositionId,
|
|
4606
4626
|
strategyPackageVersion,
|
|
4627
|
+
strategyDependencyVersions,
|
|
4607
4628
|
runtimePackageVersion,
|
|
4608
4629
|
maxLossValue: resolveRuntimeMaxLossValue(config)
|
|
4609
4630
|
};
|
|
@@ -4643,11 +4664,15 @@ async function buildRuntimeLineage({
|
|
|
4643
4664
|
maxLossValue: resolveRuntimeMaxLossValue(config)
|
|
4644
4665
|
};
|
|
4645
4666
|
}
|
|
4646
|
-
var runtimeLineageKey = (lineage) => lineage.schemaVersion ===
|
|
4647
|
-
"
|
|
4648
|
-
lineage.
|
|
4649
|
-
lineage.
|
|
4650
|
-
lineage.
|
|
4667
|
+
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 3 ? [
|
|
4668
|
+
"v3",
|
|
4669
|
+
lineage.deploymentCompositionId,
|
|
4670
|
+
lineage.strategyRevision,
|
|
4671
|
+
lineage.strategyPackageVersion,
|
|
4672
|
+
`deps:${fingerprintRuntimeValue(
|
|
4673
|
+
lineage.strategyDependencyVersions
|
|
4674
|
+
).slice(0, 16)}`,
|
|
4675
|
+
lineage.runtimePackageVersion
|
|
4651
4676
|
].join(":") : [
|
|
4652
4677
|
lineage.schemaVersion,
|
|
4653
4678
|
lineage.compositionId ?? "unbound-composition",
|
|
@@ -4664,6 +4689,9 @@ var runtimeLineagesComparable = (left, right) => runtimeLineagesMatch(left, righ
|
|
|
4664
4689
|
var import_runtimeStrategies2 = require("@tradejs/node/runtimeStrategies");
|
|
4665
4690
|
var isRecord = (value) => value != null && typeof value === "object" && !Array.isArray(value);
|
|
4666
4691
|
var isNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0;
|
|
4692
|
+
var isPackageVersionMap = (value) => isRecord(value) && Object.keys(value).length > 0 && Object.entries(value).every(
|
|
4693
|
+
([name, version]) => name.startsWith("@tradejs/") && isNonEmptyString(version)
|
|
4694
|
+
);
|
|
4667
4695
|
var INTERVALS = /* @__PURE__ */ new Set([
|
|
4668
4696
|
"1",
|
|
4669
4697
|
"3",
|
|
@@ -4682,13 +4710,13 @@ var INTERVALS = /* @__PURE__ */ new Set([
|
|
|
4682
4710
|
var UNIVERSES = /* @__PURE__ */ new Set(["crypto", "tradfi"]);
|
|
4683
4711
|
var 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));
|
|
4684
4712
|
var parseRuntimeEvidenceDeploymentSnapshot = (value) => {
|
|
4685
|
-
if (!isRecord(value) || value.schemaVersion !==
|
|
4713
|
+
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)) {
|
|
4686
4714
|
throw new Error(
|
|
4687
4715
|
"Runtime evidence deployment snapshot is missing or invalid"
|
|
4688
4716
|
);
|
|
4689
4717
|
}
|
|
4690
4718
|
const strategies = value.strategies.map((candidate) => {
|
|
4691
|
-
if (!isRecord(candidate) || !isNonEmptyString(candidate.strategyName) || !
|
|
4719
|
+
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)) {
|
|
4692
4720
|
throw new Error(
|
|
4693
4721
|
"Runtime evidence deployment strategy snapshot is invalid"
|
|
4694
4722
|
);
|
|
@@ -4722,15 +4750,16 @@ var parseRuntimeEvidenceDeploymentSnapshot = (value) => {
|
|
|
4722
4750
|
var activeRuntimeEvidenceStrategies = (deployment) => deployment.enabled ? deployment.strategies.filter((strategy) => strategy.enabled) : [];
|
|
4723
4751
|
var runtimeDeploymentFromEvidence = (deployment) => ({
|
|
4724
4752
|
id: deployment.id,
|
|
4753
|
+
deploymentCompositionId: deployment.deploymentCompositionId,
|
|
4725
4754
|
label: deployment.label,
|
|
4726
4755
|
connectorName: deployment.connectorName,
|
|
4727
4756
|
provider: deployment.provider,
|
|
4728
4757
|
accountId: deployment.accountId,
|
|
4729
4758
|
enabled: deployment.enabled,
|
|
4730
4759
|
strategies: deployment.strategies.map(
|
|
4731
|
-
({ strategyName,
|
|
4760
|
+
({ strategyName, strategyRevision, enabled, controlState, selection }) => ({
|
|
4732
4761
|
strategyName,
|
|
4733
|
-
|
|
4762
|
+
strategyRevision,
|
|
4734
4763
|
enabled,
|
|
4735
4764
|
controlState,
|
|
4736
4765
|
...selection ? { selection } : {}
|
|
@@ -4810,7 +4839,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
4810
4839
|
deploymentId,
|
|
4811
4840
|
accountId,
|
|
4812
4841
|
runtimeConfigId,
|
|
4813
|
-
|
|
4842
|
+
strategyRevision,
|
|
4814
4843
|
timestamp,
|
|
4815
4844
|
lineage
|
|
4816
4845
|
}) => {
|
|
@@ -4825,7 +4854,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
4825
4854
|
...deploymentId ? { deploymentId } : {},
|
|
4826
4855
|
...accountId ? { accountId } : {},
|
|
4827
4856
|
...runtimeConfigId ? { runtimeConfigId } : {},
|
|
4828
|
-
...
|
|
4857
|
+
...strategyRevision ? { strategyRevision } : {},
|
|
4829
4858
|
lineage,
|
|
4830
4859
|
firstTimestamp: existing ? Math.min(existing.firstTimestamp, timestamp) : timestamp,
|
|
4831
4860
|
lastTimestamp: existing ? Math.max(existing.lastTimestamp, timestamp) : timestamp
|
|
@@ -4838,7 +4867,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
4838
4867
|
deploymentId: signal.deploymentId,
|
|
4839
4868
|
accountId: signal.accountId,
|
|
4840
4869
|
runtimeConfigId: signal.runtimeConfigId,
|
|
4841
|
-
|
|
4870
|
+
strategyRevision: signal.strategyRevision,
|
|
4842
4871
|
timestamp: signal.timestamp,
|
|
4843
4872
|
lineage: signal.runtimeLineage
|
|
4844
4873
|
});
|
|
@@ -4850,7 +4879,7 @@ var buildRuntimeEvidenceLineageScopes = ({
|
|
|
4850
4879
|
deploymentId: evaluation.deploymentId,
|
|
4851
4880
|
accountId: evaluation.accountId,
|
|
4852
4881
|
runtimeConfigId: evaluation.runtimeConfigId,
|
|
4853
|
-
|
|
4882
|
+
strategyRevision: evaluation.strategyRevision,
|
|
4854
4883
|
timestamp: evaluation.timestamp,
|
|
4855
4884
|
lineage: evaluation.runtimeLineage
|
|
4856
4885
|
});
|
|
@@ -5494,9 +5523,11 @@ var loadRuntimeStrategies = async (runtimeStrategies) => {
|
|
|
5494
5523
|
runtimeStrategies.map(async (runtimeStrategy) => {
|
|
5495
5524
|
const {
|
|
5496
5525
|
strategyName,
|
|
5497
|
-
|
|
5526
|
+
strategyRevision,
|
|
5527
|
+
deploymentCompositionId,
|
|
5498
5528
|
strategyPackage,
|
|
5499
5529
|
strategyPackageVersion,
|
|
5530
|
+
strategyDependencyVersions,
|
|
5500
5531
|
runtimePackageVersion,
|
|
5501
5532
|
strategyConfig,
|
|
5502
5533
|
selection
|
|
@@ -5512,7 +5543,7 @@ var loadRuntimeStrategies = async (runtimeStrategies) => {
|
|
|
5512
5543
|
strategyName,
|
|
5513
5544
|
projectRoot: replayProjectRoot
|
|
5514
5545
|
});
|
|
5515
|
-
if (installed.strategyPackage !== strategyPackage || installed.strategyPackageVersion !== strategyPackageVersion || installed.runtimePackageVersion !== runtimePackageVersion) {
|
|
5546
|
+
if (installed.strategyPackage !== strategyPackage || installed.strategyPackageVersion !== strategyPackageVersion || JSON.stringify(installed.strategyDependencyVersions) !== JSON.stringify(strategyDependencyVersions) || installed.runtimePackageVersion !== runtimePackageVersion) {
|
|
5516
5547
|
throw new Error(
|
|
5517
5548
|
`Runtime evidence package mismatch for ${strategyName}: expected=${strategyPackage}@${strategyPackageVersion}/@tradejs/node@${runtimePackageVersion}, installed=${installed.strategyPackage ?? "missing"}@${installed.strategyPackageVersion ?? "missing"}/@tradejs/node@${installed.runtimePackageVersion ?? "missing"}`
|
|
5518
5549
|
);
|
|
@@ -5523,9 +5554,11 @@ var loadRuntimeStrategies = async (runtimeStrategies) => {
|
|
|
5523
5554
|
);
|
|
5524
5555
|
return {
|
|
5525
5556
|
strategyName,
|
|
5526
|
-
|
|
5557
|
+
strategyRevision,
|
|
5558
|
+
deploymentCompositionId,
|
|
5527
5559
|
strategyPackage,
|
|
5528
5560
|
strategyPackageVersion,
|
|
5561
|
+
strategyDependencyVersions,
|
|
5529
5562
|
runtimePackageVersion,
|
|
5530
5563
|
strategyCreator,
|
|
5531
5564
|
strategyConfig,
|
|
@@ -5729,8 +5762,10 @@ var runHistoricalSignalsReplay = async ({
|
|
|
5729
5762
|
loadedStrategies.filter((strategy) => strategyIncludesSymbol(strategy, symbol)).map(
|
|
5730
5763
|
async ({
|
|
5731
5764
|
strategyName,
|
|
5732
|
-
|
|
5765
|
+
strategyRevision,
|
|
5766
|
+
deploymentCompositionId,
|
|
5733
5767
|
strategyPackageVersion,
|
|
5768
|
+
strategyDependencyVersions,
|
|
5734
5769
|
runtimePackageVersion,
|
|
5735
5770
|
strategyCreator,
|
|
5736
5771
|
strategyConfig,
|
|
@@ -5739,11 +5774,13 @@ var runHistoricalSignalsReplay = async ({
|
|
|
5739
5774
|
const runtimeLineage = await buildRuntimeLineage({
|
|
5740
5775
|
projectRoot: replayProjectRoot,
|
|
5741
5776
|
strategyName,
|
|
5742
|
-
|
|
5777
|
+
strategyRevision,
|
|
5778
|
+
deploymentCompositionId,
|
|
5743
5779
|
strategyPackageVersion,
|
|
5780
|
+
strategyDependencyVersions,
|
|
5744
5781
|
runtimePackageVersion,
|
|
5745
5782
|
config: {
|
|
5746
|
-
configId:
|
|
5783
|
+
configId: strategyRevision,
|
|
5747
5784
|
strategyConfig,
|
|
5748
5785
|
symbolResultConfig: strategyResults?.[symbol]?.config ?? null
|
|
5749
5786
|
},
|
|
@@ -5767,7 +5804,8 @@ var runHistoricalSignalsReplay = async ({
|
|
|
5767
5804
|
run: await strategyCreator({
|
|
5768
5805
|
userName: replayUserName,
|
|
5769
5806
|
connectorName,
|
|
5770
|
-
runtimeConfigId:
|
|
5807
|
+
runtimeConfigId: strategyRevision,
|
|
5808
|
+
strategyRevision,
|
|
5771
5809
|
runtimeLineage,
|
|
5772
5810
|
universe: preparedRun.universe,
|
|
5773
5811
|
accountId: preparedRun.accountId,
|
|
@@ -8813,15 +8851,15 @@ var renderLineageRows = (runtimeComparison) => {
|
|
|
8813
8851
|
contexts: /* @__PURE__ */ new Set()
|
|
8814
8852
|
};
|
|
8815
8853
|
existing.scopes += 1;
|
|
8816
|
-
if (record.lineage.schemaVersion ===
|
|
8817
|
-
existing.gitShas.add(
|
|
8854
|
+
if (record.lineage.schemaVersion === 3) {
|
|
8855
|
+
existing.gitShas.add(record.lineage.deploymentCompositionId);
|
|
8818
8856
|
existing.dirty.add("n/a");
|
|
8819
|
-
existing.gates.add("
|
|
8820
|
-
existing.configs.add(
|
|
8857
|
+
existing.gates.add("package-owned");
|
|
8858
|
+
existing.configs.add(record.lineage.strategyRevision);
|
|
8821
8859
|
existing.contexts.add(
|
|
8822
8860
|
[
|
|
8823
|
-
record.lineage.strategyPackageVersion
|
|
8824
|
-
record.lineage.runtimePackageVersion
|
|
8861
|
+
record.lineage.strategyPackageVersion,
|
|
8862
|
+
record.lineage.runtimePackageVersion
|
|
8825
8863
|
].join("/")
|
|
8826
8864
|
);
|
|
8827
8865
|
} else {
|
|
@@ -9129,17 +9167,20 @@ var replayBacktest = async () => {
|
|
|
9129
9167
|
).map(
|
|
9130
9168
|
({
|
|
9131
9169
|
strategyName,
|
|
9132
|
-
|
|
9170
|
+
strategyRevision,
|
|
9133
9171
|
strategyPackage,
|
|
9134
9172
|
strategyPackageVersion,
|
|
9173
|
+
strategyDependencyVersions,
|
|
9135
9174
|
runtimePackageVersion,
|
|
9136
9175
|
strategyConfig,
|
|
9137
9176
|
selection
|
|
9138
9177
|
}) => ({
|
|
9139
9178
|
strategyName,
|
|
9140
|
-
|
|
9179
|
+
strategyRevision,
|
|
9180
|
+
deploymentCompositionId: evidenceMetadata.deployment.deploymentCompositionId,
|
|
9141
9181
|
strategyPackage,
|
|
9142
9182
|
strategyPackageVersion,
|
|
9183
|
+
strategyDependencyVersions,
|
|
9143
9184
|
runtimePackageVersion,
|
|
9144
9185
|
strategyConfig,
|
|
9145
9186
|
...selection ? { selection } : {}
|
|
@@ -67,7 +67,8 @@ var verify = async () => {
|
|
|
67
67
|
ok: true,
|
|
68
68
|
strategies: strategies.map((strategy) => ({
|
|
69
69
|
strategyName: strategy.strategyName,
|
|
70
|
-
|
|
70
|
+
strategyRevision: strategy.strategyRevision,
|
|
71
|
+
deploymentCompositionId: strategy.deploymentCompositionId,
|
|
71
72
|
controlState: strategy.controlState,
|
|
72
73
|
interval: strategy.interval,
|
|
73
74
|
universe: strategy.universe,
|
|
@@ -146,7 +147,7 @@ var updateControlState = async (nextState) => {
|
|
|
146
147
|
userName,
|
|
147
148
|
deploymentId,
|
|
148
149
|
strategyName,
|
|
149
|
-
|
|
150
|
+
strategyRevision: reference.strategyRevision,
|
|
150
151
|
previousState,
|
|
151
152
|
nextState,
|
|
152
153
|
createdBy: `cli:${userName}`
|
|
@@ -606,11 +606,27 @@ var import_promises2 = __toESM(require("fs/promises"));
|
|
|
606
606
|
var import_node_path2 = __toESM(require("path"));
|
|
607
607
|
|
|
608
608
|
// src/lib/runtimeLineage.ts
|
|
609
|
-
var
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
609
|
+
var normalizeForStableJson = (value) => {
|
|
610
|
+
if (Array.isArray(value)) {
|
|
611
|
+
return value.map(normalizeForStableJson);
|
|
612
|
+
}
|
|
613
|
+
if (value && typeof value === "object") {
|
|
614
|
+
return Object.fromEntries(
|
|
615
|
+
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, normalizeForStableJson(entry)])
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
return value;
|
|
619
|
+
};
|
|
620
|
+
var fingerprintRuntimeValue = (value) => (0, import_node_crypto3.createHash)("sha256").update(JSON.stringify(normalizeForStableJson(value))).digest("hex").slice(0, 16);
|
|
621
|
+
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 3 ? [
|
|
622
|
+
"v3",
|
|
623
|
+
lineage.deploymentCompositionId,
|
|
624
|
+
lineage.strategyRevision,
|
|
625
|
+
lineage.strategyPackageVersion,
|
|
626
|
+
`deps:${fingerprintRuntimeValue(
|
|
627
|
+
lineage.strategyDependencyVersions
|
|
628
|
+
).slice(0, 16)}`,
|
|
629
|
+
lineage.runtimePackageVersion
|
|
614
630
|
].join(":") : [
|
|
615
631
|
lineage.schemaVersion,
|
|
616
632
|
lineage.compositionId ?? "unbound-composition",
|
|
@@ -637,8 +653,9 @@ var resolveRuntimeEvidenceDeploymentSnapshot = async ({
|
|
|
637
653
|
throw new Error(`Runtime deployment not found: ${deploymentId}`);
|
|
638
654
|
}
|
|
639
655
|
return {
|
|
640
|
-
schemaVersion:
|
|
656
|
+
schemaVersion: 2,
|
|
641
657
|
id: deployment.id,
|
|
658
|
+
deploymentCompositionId: deployment.deploymentCompositionId,
|
|
642
659
|
label: deployment.label,
|
|
643
660
|
connectorName: deployment.connectorName,
|
|
644
661
|
provider: deployment.provider,
|
|
@@ -647,7 +664,7 @@ var resolveRuntimeEvidenceDeploymentSnapshot = async ({
|
|
|
647
664
|
strategies: strategies.map(
|
|
648
665
|
({
|
|
649
666
|
strategyName,
|
|
650
|
-
|
|
667
|
+
strategyRevision,
|
|
651
668
|
enabled,
|
|
652
669
|
controlState,
|
|
653
670
|
interval,
|
|
@@ -655,12 +672,13 @@ var resolveRuntimeEvidenceDeploymentSnapshot = async ({
|
|
|
655
672
|
accountId,
|
|
656
673
|
strategyPackage,
|
|
657
674
|
strategyPackageVersion,
|
|
675
|
+
strategyDependencyVersions,
|
|
658
676
|
runtimePackageVersion,
|
|
659
|
-
|
|
677
|
+
strategyConfig,
|
|
660
678
|
selection
|
|
661
679
|
}) => ({
|
|
662
680
|
strategyName,
|
|
663
|
-
|
|
681
|
+
strategyRevision,
|
|
664
682
|
enabled,
|
|
665
683
|
controlState,
|
|
666
684
|
interval,
|
|
@@ -668,8 +686,9 @@ var resolveRuntimeEvidenceDeploymentSnapshot = async ({
|
|
|
668
686
|
...accountId ? { accountId } : {},
|
|
669
687
|
strategyPackage,
|
|
670
688
|
strategyPackageVersion,
|
|
689
|
+
strategyDependencyVersions,
|
|
671
690
|
runtimePackageVersion,
|
|
672
|
-
strategyConfig
|
|
691
|
+
strategyConfig,
|
|
673
692
|
...selection ? { selection } : {}
|
|
674
693
|
})
|
|
675
694
|
),
|
|
@@ -208,11 +208,27 @@ var import_promises3 = __toESM(require("fs/promises"));
|
|
|
208
208
|
var import_node_path3 = __toESM(require("path"));
|
|
209
209
|
|
|
210
210
|
// src/lib/runtimeLineage.ts
|
|
211
|
-
var
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
211
|
+
var normalizeForStableJson = (value) => {
|
|
212
|
+
if (Array.isArray(value)) {
|
|
213
|
+
return value.map(normalizeForStableJson);
|
|
214
|
+
}
|
|
215
|
+
if (value && typeof value === "object") {
|
|
216
|
+
return Object.fromEntries(
|
|
217
|
+
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, normalizeForStableJson(entry)])
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
return value;
|
|
221
|
+
};
|
|
222
|
+
var fingerprintRuntimeValue = (value) => (0, import_node_crypto3.createHash)("sha256").update(JSON.stringify(normalizeForStableJson(value))).digest("hex").slice(0, 16);
|
|
223
|
+
var runtimeLineageKey = (lineage) => lineage.schemaVersion === 3 ? [
|
|
224
|
+
"v3",
|
|
225
|
+
lineage.deploymentCompositionId,
|
|
226
|
+
lineage.strategyRevision,
|
|
227
|
+
lineage.strategyPackageVersion,
|
|
228
|
+
`deps:${fingerprintRuntimeValue(
|
|
229
|
+
lineage.strategyDependencyVersions
|
|
230
|
+
).slice(0, 16)}`,
|
|
231
|
+
lineage.runtimePackageVersion
|
|
216
232
|
].join(":") : [
|
|
217
233
|
lineage.schemaVersion,
|
|
218
234
|
lineage.compositionId ?? "unbound-composition",
|
|
@@ -228,6 +244,19 @@ var asRecord2 = (value) => value && typeof value === "object" && !Array.isArray(
|
|
|
228
244
|
var asArray = (value) => Array.isArray(value) ? value : [];
|
|
229
245
|
var finiteNumber = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
230
246
|
var finiteString = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
247
|
+
var packageVersionMap = (value) => {
|
|
248
|
+
const record = asRecord2(value);
|
|
249
|
+
if (!record || Object.keys(record).length === 0) return null;
|
|
250
|
+
const entries = Object.entries(record);
|
|
251
|
+
if (entries.some(
|
|
252
|
+
([name, version]) => !name.startsWith("@tradejs/") || finiteString(version) == null
|
|
253
|
+
)) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
return Object.fromEntries(
|
|
257
|
+
entries.map(([name, version]) => [name, String(version).trim()]).sort(([left], [right]) => left.localeCompare(right))
|
|
258
|
+
);
|
|
259
|
+
};
|
|
231
260
|
var round = (value, decimals = 6) => Number(value.toFixed(decimals));
|
|
232
261
|
var unwrapRows = (value, key) => asArray(value).map((item) => asRecord2(asRecord2(item)?.[key]) ?? asRecord2(item)).filter((item) => item != null);
|
|
233
262
|
var runtimePayload = (artifact) => {
|
|
@@ -260,12 +289,18 @@ var buildRuntimeLineageSummary = (rows) => {
|
|
|
260
289
|
const lineages = lineageRows.map((row) => asRecord2(row.runtimeLineage)).filter((lineage) => lineage != null);
|
|
261
290
|
const identities = /* @__PURE__ */ new Map();
|
|
262
291
|
for (const lineage of lineages) {
|
|
263
|
-
const identity2 = lineage.schemaVersion ===
|
|
264
|
-
schemaVersion:
|
|
265
|
-
|
|
292
|
+
const identity2 = lineage.schemaVersion === 3 ? {
|
|
293
|
+
schemaVersion: 3,
|
|
294
|
+
strategyRevision: finiteString(lineage.strategyRevision),
|
|
295
|
+
deploymentCompositionId: finiteString(
|
|
296
|
+
lineage.deploymentCompositionId
|
|
297
|
+
),
|
|
266
298
|
strategyPackageVersion: finiteString(
|
|
267
299
|
lineage.strategyPackageVersion
|
|
268
300
|
),
|
|
301
|
+
strategyDependencyVersions: packageVersionMap(
|
|
302
|
+
lineage.strategyDependencyVersions
|
|
303
|
+
),
|
|
269
304
|
runtimePackageVersion: finiteString(lineage.runtimePackageVersion),
|
|
270
305
|
maxLossValue: finiteNumber(lineage.maxLossValue)
|
|
271
306
|
} : {
|
|
@@ -282,7 +317,7 @@ var buildRuntimeLineageSummary = (rows) => {
|
|
|
282
317
|
}
|
|
283
318
|
const identity = identities.size === 1 ? [...identities.values()][0] : null;
|
|
284
319
|
const schemaVersion = finiteNumber(identity?.schemaVersion);
|
|
285
|
-
const identityComplete = lineages.length > 0 && identity != null && (schemaVersion ===
|
|
320
|
+
const identityComplete = lineages.length > 0 && identity != null && (schemaVersion === 3 && finiteString(identity.strategyRevision) != null && finiteString(identity.deploymentCompositionId) != null && finiteString(identity.strategyPackageVersion) != null && packageVersionMap(identity.strategyDependencyVersions) != null && finiteString(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;
|
|
286
321
|
const coverageComplete = lineageRows.length > 0 && lineages.length === lineageRows.length;
|
|
287
322
|
const complete = identityComplete && coverageComplete;
|
|
288
323
|
const lineageKey = identityComplete ? runtimeLineageKey(identity) : null;
|
|
@@ -295,8 +330,12 @@ var buildRuntimeLineageSummary = (rows) => {
|
|
|
295
330
|
rowsWithLineage: lineages.length,
|
|
296
331
|
schemaVersion,
|
|
297
332
|
lineageKey,
|
|
298
|
-
|
|
333
|
+
strategyRevision: finiteString(identity?.strategyRevision),
|
|
334
|
+
deploymentCompositionId: finiteString(identity?.deploymentCompositionId),
|
|
299
335
|
strategyPackageVersion: finiteString(identity?.strategyPackageVersion),
|
|
336
|
+
strategyDependencyVersions: packageVersionMap(
|
|
337
|
+
identity?.strategyDependencyVersions
|
|
338
|
+
),
|
|
300
339
|
runtimePackageVersion: finiteString(identity?.runtimePackageVersion),
|
|
301
340
|
compositionId: finiteString(identity?.compositionId),
|
|
302
341
|
gitSha: finiteString(identity?.gitSha),
|