feat(engine): expose canonical replay sessions through native workers

This commit is contained in:
Boki 2026-10-23 00:54:36 -04:00
parent 417a7bd21e
commit e3635f23cf
26 changed files with 2693 additions and 33 deletions

View file

@ -10,7 +10,11 @@ function send(message: NativeWorkerMessage | { invalid: boolean }): Promise<void
}
process.once('message', async (input: unknown) => {
const { config } = nativeWorkerRequestSchema.parse(input);
const request = nativeWorkerRequestSchema.parse(input);
if (request.type !== 'run') {
throw new Error('Legacy fixture only');
}
const { config } = request;
// Fixture controls are run labels, not unsupported production strategy parameters.
const behavior = config.name?.startsWith('fixture:')
? config.name.slice('fixture:'.length)
@ -18,7 +22,7 @@ process.once('message', async (input: unknown) => {
if (!behavior) {
// The same adapter can recover and run the actual Rust engine after a failed worker.
await import('../../apps/stock/orchestrator/src/backtest/native-worker');
process.emit('message', input);
process.emit('message', input, undefined);
return;
}
await send({ type: 'progress', progress: 0, message: `Fixture worker ready:${process.pid}` });
@ -43,6 +47,7 @@ process.once('message', async (input: unknown) => {
break;
case 'no-result':
process.exit(0);
return;
case 'result-then-block':
await send({ type: 'result', result: '{}' });
while (true) {