fix(monitoring): report observed research and paper readiness (O02)
This commit is contained in:
parent
70d173a908
commit
8c858b9d5c
23 changed files with 1340 additions and 319 deletions
|
|
@ -2,6 +2,7 @@ import { EventEmitter } from 'node:events';
|
|||
import { z } from 'zod';
|
||||
import type { Logger } from '@stock-bot/services';
|
||||
import { parseBacktestRequest } from '@stock-bot/stock-config/backtest';
|
||||
import type { researchRuntimeSchema } from '@stock-bot/stock-config/diagnostics';
|
||||
import type { BacktestRunResult } from '@stock-bot/types';
|
||||
import type { BacktestRunner } from './BacktestRunner';
|
||||
import { BacktestCancelledError, LEGACY_EXECUTION_RETIRED } from './execution-engine';
|
||||
|
|
@ -27,6 +28,7 @@ export type ResearchBacktestRuntime = Pick<
|
|||
> &
|
||||
Pick<EventEmitter, 'on' | 'off'> & {
|
||||
getStatus(runId?: string): ReturnType<BacktestRunner['getStatus']>;
|
||||
getDiagnostics?(): z.infer<typeof researchRuntimeSchema>;
|
||||
};
|
||||
|
||||
type Reservation = {
|
||||
|
|
@ -155,6 +157,14 @@ export class ResearchBacktestPool extends EventEmitter implements ResearchBackte
|
|||
const [runId, { runner }] = this.resolve(input);
|
||||
await runner.setSpeedMultiplier(speed, runId);
|
||||
}
|
||||
getDiagnostics() {
|
||||
return {
|
||||
accepting: !this.closing,
|
||||
capacity: this.runners.length,
|
||||
slots: this.runners.map(runner => runner.getAttemptDiagnostics()),
|
||||
};
|
||||
}
|
||||
|
||||
getStatus(input?: string): ReturnType<BacktestRunner['getStatus']> {
|
||||
if (input === undefined && this.reservations.size === 0) {
|
||||
return { isRunning: false, isPaused: false, progress: 0, currentTime: 0, runId: undefined };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue