@tradejs/cli 3.1.29-beta.278 → 3.1.29-beta.281

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 CHANGED
@@ -24591,8 +24591,11 @@ const path = require('node:path');
24591
24591
  const [root, id, request] = process.argv.slice(1);
24592
24592
  const file = path.join(root, id);
24593
24593
  fs.mkdirSync(root, {recursive:true});
24594
- try { fs.writeFileSync(file + '.request', request, {flag:'wx'}); }
24594
+ const temporary = file + '.request.tmp-' + process.pid;
24595
+ fs.writeFileSync(temporary, request, {flag:'wx'});
24596
+ try { fs.linkSync(temporary, file + '.request'); }
24595
24597
  catch (error) { if (error.code !== 'EEXIST') throw error; if (fs.readFileSync(file + '.request', 'utf8') !== request) throw new Error('Replay request identity conflict'); }
24598
+ finally { fs.unlinkSync(temporary); }
24596
24599
  process.on('SIGTERM', () => { fs.writeFileSync(file + '.cancel', 'cancel'); process.exit(143); });
24597
24600
  const timer = setInterval(() => {
24598
24601
  try {
@@ -33075,12 +33078,26 @@ var init_runtimeEvidenceCompositions = __esm({
33075
33078
  const register = (snapshot) => {
33076
33079
  const compositionId = snapshot.deployment.deploymentCompositionId;
33077
33080
  const known = snapshots.get(compositionId);
33078
- if (known && (stableSnapshotIdentity(known.deployment) !== stableSnapshotIdentity(snapshot.deployment) || producerIdentity(known.producer) !== producerIdentity(snapshot.producer))) {
33081
+ if (known && stableSnapshotIdentity(known.deployment) !== stableSnapshotIdentity(snapshot.deployment)) {
33079
33082
  throw new Error(
33080
33083
  `Conflicting runtime evidence snapshot for composition ${compositionId}`
33081
33084
  );
33082
33085
  }
33083
- snapshots.set(compositionId, snapshot);
33086
+ const producers = /* @__PURE__ */ new Map();
33087
+ for (const source of [
33088
+ ...known?.producerVariants ?? [],
33089
+ known?.producer,
33090
+ snapshot.producer
33091
+ ]) {
33092
+ if (source) producers.set(producerIdentity(source), source);
33093
+ }
33094
+ const producerVariants = [...producers.values()];
33095
+ snapshots.set(compositionId, {
33096
+ ...known,
33097
+ ...snapshot,
33098
+ producer: producerVariants.length === 1 ? producerVariants[0] : null,
33099
+ ...producerVariants.length > 1 ? { producerVariants } : {}
33100
+ });
33084
33101
  };
33085
33102
  const compositionSnapshots = await discoverRuntimeEvidenceCompositionSnapshots(publishRoot);
33086
33103
  for (const snapshot of compositionSnapshots) {
@@ -33115,7 +33132,7 @@ var init_runtimeEvidenceCompositions = __esm({
33115
33132
  `Current runtime deployment conflicts with stored composition ${currentDeployment.deploymentCompositionId}`
33116
33133
  );
33117
33134
  }
33118
- snapshots.set(currentDeployment.deploymentCompositionId, {
33135
+ register({
33119
33136
  deployment: { ...currentDeployment, tickers: void 0 },
33120
33137
  producer: currentProducer
33121
33138
  });
@@ -33173,6 +33190,14 @@ var init_runtimeEvidenceCompositions = __esm({
33173
33190
  `Runtime evidence has no verified deployment snapshot for composition(s): ${missing.sort().join(", ")}`
33174
33191
  );
33175
33192
  }
33193
+ for (const compositionId of observed) {
33194
+ const variants = snapshots.get(compositionId)?.producerVariants;
33195
+ if (variants && variants.length > 1) {
33196
+ throw new Error(
33197
+ `Ambiguous runtime evidence producer for composition ${compositionId}: ${variants.map((source) => `${source.projectSha}@${source.imageDigest}`).sort().join(", ")}; runtime lineage has no producer image identity`
33198
+ );
33199
+ }
33200
+ }
33176
33201
  return [...observed].filter((compositionId) => snapshots.has(compositionId)).map((compositionId) => snapshots.get(compositionId)).map(({ deployment, producer, fallbackTickers }) => {
33177
33202
  const trades = evidence.trades.filter(
33178
33203
  (row) => belongsToSnapshot(row, deployment)
@@ -49,8 +49,11 @@ const path = require('node:path');
49
49
  const [root, id, request] = process.argv.slice(1);
50
50
  const file = path.join(root, id);
51
51
  fs.mkdirSync(root, {recursive:true});
52
- try { fs.writeFileSync(file + '.request', request, {flag:'wx'}); }
52
+ const temporary = file + '.request.tmp-' + process.pid;
53
+ fs.writeFileSync(temporary, request, {flag:'wx'});
54
+ try { fs.linkSync(temporary, file + '.request'); }
53
55
  catch (error) { if (error.code !== 'EEXIST') throw error; if (fs.readFileSync(file + '.request', 'utf8') !== request) throw new Error('Replay request identity conflict'); }
56
+ finally { fs.unlinkSync(temporary); }
54
57
  process.on('SIGTERM', () => { fs.writeFileSync(file + '.cancel', 'cancel'); process.exit(143); });
55
58
  const timer = setInterval(() => {
56
59
  try {
@@ -143,12 +143,26 @@ var loadRuntimeEvidenceCompositionSnapshots = async ({
143
143
  const register = (snapshot) => {
144
144
  const compositionId = snapshot.deployment.deploymentCompositionId;
145
145
  const known = snapshots.get(compositionId);
146
- if (known && (stableSnapshotIdentity(known.deployment) !== stableSnapshotIdentity(snapshot.deployment) || producerIdentity(known.producer) !== producerIdentity(snapshot.producer))) {
146
+ if (known && stableSnapshotIdentity(known.deployment) !== stableSnapshotIdentity(snapshot.deployment)) {
147
147
  throw new Error(
148
148
  `Conflicting runtime evidence snapshot for composition ${compositionId}`
149
149
  );
150
150
  }
151
- snapshots.set(compositionId, snapshot);
151
+ const producers = /* @__PURE__ */ new Map();
152
+ for (const source of [
153
+ ...known?.producerVariants ?? [],
154
+ known?.producer,
155
+ snapshot.producer
156
+ ]) {
157
+ if (source) producers.set(producerIdentity(source), source);
158
+ }
159
+ const producerVariants = [...producers.values()];
160
+ snapshots.set(compositionId, {
161
+ ...known,
162
+ ...snapshot,
163
+ producer: producerVariants.length === 1 ? producerVariants[0] : null,
164
+ ...producerVariants.length > 1 ? { producerVariants } : {}
165
+ });
152
166
  };
153
167
  const compositionSnapshots = await discoverRuntimeEvidenceCompositionSnapshots(publishRoot);
154
168
  for (const snapshot of compositionSnapshots) {
@@ -183,7 +197,7 @@ var loadRuntimeEvidenceCompositionSnapshots = async ({
183
197
  `Current runtime deployment conflicts with stored composition ${currentDeployment.deploymentCompositionId}`
184
198
  );
185
199
  }
186
- snapshots.set(currentDeployment.deploymentCompositionId, {
200
+ register({
187
201
  deployment: { ...currentDeployment, tickers: void 0 },
188
202
  producer: currentProducer
189
203
  });
@@ -241,6 +255,14 @@ var splitRuntimeEvidenceByComposition = ({
241
255
  `Runtime evidence has no verified deployment snapshot for composition(s): ${missing.sort().join(", ")}`
242
256
  );
243
257
  }
258
+ for (const compositionId of observed) {
259
+ const variants = snapshots.get(compositionId)?.producerVariants;
260
+ if (variants && variants.length > 1) {
261
+ throw new Error(
262
+ `Ambiguous runtime evidence producer for composition ${compositionId}: ${variants.map((source) => `${source.projectSha}@${source.imageDigest}`).sort().join(", ")}; runtime lineage has no producer image identity`
263
+ );
264
+ }
265
+ }
244
266
  return [...observed].filter((compositionId) => snapshots.has(compositionId)).map((compositionId) => snapshots.get(compositionId)).map(({ deployment, producer, fallbackTickers }) => {
245
267
  const trades = evidence.trades.filter(
246
268
  (row) => belongsToSnapshot(row, deployment)
@@ -56,8 +56,11 @@ const path = require('node:path');
56
56
  const [root, id, request] = process.argv.slice(1);
57
57
  const file = path.join(root, id);
58
58
  fs.mkdirSync(root, {recursive:true});
59
- try { fs.writeFileSync(file + '.request', request, {flag:'wx'}); }
59
+ const temporary = file + '.request.tmp-' + process.pid;
60
+ fs.writeFileSync(temporary, request, {flag:'wx'});
61
+ try { fs.linkSync(temporary, file + '.request'); }
60
62
  catch (error) { if (error.code !== 'EEXIST') throw error; if (fs.readFileSync(file + '.request', 'utf8') !== request) throw new Error('Replay request identity conflict'); }
63
+ finally { fs.unlinkSync(temporary); }
61
64
  process.on('SIGTERM', () => { fs.writeFileSync(file + '.cancel', 'cancel'); process.exit(143); });
62
65
  const timer = setInterval(() => {
63
66
  try {
@@ -491,12 +491,26 @@ var loadRuntimeEvidenceCompositionSnapshots = async ({
491
491
  const register = (snapshot) => {
492
492
  const compositionId = snapshot.deployment.deploymentCompositionId;
493
493
  const known = snapshots.get(compositionId);
494
- if (known && (stableSnapshotIdentity(known.deployment) !== stableSnapshotIdentity(snapshot.deployment) || producerIdentity(known.producer) !== producerIdentity(snapshot.producer))) {
494
+ if (known && stableSnapshotIdentity(known.deployment) !== stableSnapshotIdentity(snapshot.deployment)) {
495
495
  throw new Error(
496
496
  `Conflicting runtime evidence snapshot for composition ${compositionId}`
497
497
  );
498
498
  }
499
- snapshots.set(compositionId, snapshot);
499
+ const producers = /* @__PURE__ */ new Map();
500
+ for (const source of [
501
+ ...known?.producerVariants ?? [],
502
+ known?.producer,
503
+ snapshot.producer
504
+ ]) {
505
+ if (source) producers.set(producerIdentity(source), source);
506
+ }
507
+ const producerVariants = [...producers.values()];
508
+ snapshots.set(compositionId, {
509
+ ...known,
510
+ ...snapshot,
511
+ producer: producerVariants.length === 1 ? producerVariants[0] : null,
512
+ ...producerVariants.length > 1 ? { producerVariants } : {}
513
+ });
500
514
  };
501
515
  const compositionSnapshots = await discoverRuntimeEvidenceCompositionSnapshots(publishRoot);
502
516
  for (const snapshot of compositionSnapshots) {
@@ -531,7 +545,7 @@ var loadRuntimeEvidenceCompositionSnapshots = async ({
531
545
  `Current runtime deployment conflicts with stored composition ${currentDeployment.deploymentCompositionId}`
532
546
  );
533
547
  }
534
- snapshots.set(currentDeployment.deploymentCompositionId, {
548
+ register({
535
549
  deployment: { ...currentDeployment, tickers: void 0 },
536
550
  producer: currentProducer
537
551
  });
@@ -589,6 +603,14 @@ var splitRuntimeEvidenceByComposition = ({
589
603
  `Runtime evidence has no verified deployment snapshot for composition(s): ${missing.sort().join(", ")}`
590
604
  );
591
605
  }
606
+ for (const compositionId of observed) {
607
+ const variants = snapshots.get(compositionId)?.producerVariants;
608
+ if (variants && variants.length > 1) {
609
+ throw new Error(
610
+ `Ambiguous runtime evidence producer for composition ${compositionId}: ${variants.map((source) => `${source.projectSha}@${source.imageDigest}`).sort().join(", ")}; runtime lineage has no producer image identity`
611
+ );
612
+ }
613
+ }
592
614
  return [...observed].filter((compositionId) => snapshots.has(compositionId)).map((compositionId) => snapshots.get(compositionId)).map(({ deployment, producer, fallbackTickers }) => {
593
615
  const trades = evidence.trades.filter(
594
616
  (row) => belongsToSnapshot(row, deployment)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradejs/cli",
3
- "version": "3.1.29-beta.278",
3
+ "version": "3.1.29-beta.281",
4
4
  "description": "Official CLI for the TradeJS TypeScript framework: infra setup, backtests, signals, bots, and ML workflows.",
5
5
  "keywords": [
6
6
  "tradejs",
@@ -37,13 +37,13 @@
37
37
  "tradejs": "dist/cli.js"
38
38
  },
39
39
  "dependencies": {
40
- "@tradejs/connectors": "^3.1.29-beta.278",
41
- "@tradejs/core": "^3.1.29-beta.278",
42
- "@tradejs/indicators": "^3.1.29-beta.278",
43
- "@tradejs/infra": "^3.1.29-beta.278",
44
- "@tradejs/node": "^3.1.29-beta.278",
40
+ "@tradejs/connectors": "^3.1.29-beta.281",
41
+ "@tradejs/core": "^3.1.29-beta.281",
42
+ "@tradejs/indicators": "^3.1.29-beta.281",
43
+ "@tradejs/infra": "^3.1.29-beta.281",
44
+ "@tradejs/node": "^3.1.29-beta.281",
45
45
  "@tradejs/strategy-kit": "3.0.6",
46
- "@tradejs/types": "^3.1.29-beta.278",
46
+ "@tradejs/types": "^3.1.29-beta.281",
47
47
  "args": "^5.0.3",
48
48
  "bcryptjs": "^2.4.3",
49
49
  "chalk": "4.1.2",