feat(research): isolate candidates and add reviewed paper promotion
This commit is contained in:
parent
26b97265c6
commit
25b5cbf481
128 changed files with 13038 additions and 1388 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { fork, type ChildProcess } from 'node:child_process';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { realpathSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import {
|
||||
|
|
@ -13,6 +14,7 @@ import {
|
|||
parseStrategyReplayResult,
|
||||
strategyReplayRequestSchema,
|
||||
} from '../contracts/strategy-replay';
|
||||
import { removeCandidateContainer } from './candidate-sandbox';
|
||||
import { canonicalWorkerUrl } from './canonical-build';
|
||||
import {
|
||||
nativeWorkerMessageSchema,
|
||||
|
|
@ -49,6 +51,16 @@ export class NativeBacktestWorker {
|
|||
request.type === 'runStrategyReplay'
|
||||
? structuredClone(strategyReplayRequestSchema.parse(request))
|
||||
: undefined;
|
||||
const candidateContainerName =
|
||||
retainedRequest?.request.strategy.origin === 'candidate'
|
||||
? `stock-bot-candidate-${randomUUID()}`
|
||||
: undefined;
|
||||
if (retainedRequest) {
|
||||
delete retainedRequest.candidateContainerName;
|
||||
if (candidateContainerName) {
|
||||
retainedRequest.candidateContainerName = candidateContainerName;
|
||||
}
|
||||
}
|
||||
const submitted = retainedRequest ?? strategyRequest ?? request;
|
||||
if (
|
||||
retainedRequest &&
|
||||
|
|
@ -155,7 +167,7 @@ export class NativeBacktestWorker {
|
|||
}
|
||||
}
|
||||
};
|
||||
const finish = (code: number | null, exitSignal: NodeJS.Signals | null) => {
|
||||
const finish = async (code: number | null, exitSignal: NodeJS.Signals | null) => {
|
||||
if (settled) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -163,6 +175,13 @@ export class NativeBacktestWorker {
|
|||
signal.removeEventListener('abort', onAbort);
|
||||
child.off('message', onMessage);
|
||||
child.stderr?.off('data', onStderr);
|
||||
if (candidateContainerName) {
|
||||
try {
|
||||
await removeCandidateContainer(candidateContainerName);
|
||||
} catch (error) {
|
||||
failure ??= error instanceof Error ? error : new Error(String(error));
|
||||
}
|
||||
}
|
||||
this.active = undefined;
|
||||
if (failure) {
|
||||
reject(failure);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue