stock-bot/test/contracts/canonical-runner.type-test.ts
Boki 4cd6038063 refactor: pre-M0 cleanup, core library hardening, and isolated dev/QA Docker stack
- Remove ~44k LOC of dead code, legacy v1 TS simulator/strategy stack, event-bus, analytics FastAPI prototype, legacy calculation archives, and unused deps (data-ingestion provider API handlers untouched)
- Extract @stock-bot/di/http-security and isolate @stock-bot/browser to data-ingestion via ServiceContainerBuilder.withRegistrations()
- Harden @stock-bot/mongodb read-only proxies, flatten @stock-bot/postgres with unified master+research migrations, and fix @stock-bot/config EnvLoader, ServiceApplication worker lifecycle, NamespacedCache.clear(), and BatchProcessor error propagation
- Flatten workspace root (remove apps/stock/package.json) and collapse orchestrator re-export shims
- Pin all Docker image versions, add shm_size/nofile/RAM caps and docker-compose.quant.yml, fix 05-add-visible-column.sql view recreation, and decouple dev/QA Compose project names for side-by-side execution
- Update PLATFORM-PLAN, DATA-CONTRACTS (bars_1m PARTITION BY MONTH, Rust bulk ETL, DuckDB limits), MILESTONES, and servers docs
2026-11-27 00:11:50 -05:00

61 lines
3.2 KiB
TypeScript

import { BacktestRunner } from '../../apps/stock/orchestrator/src/backtest/BacktestRunner';
import type { BacktestExecutionEngine } from '../../apps/stock/orchestrator/src/backtest/execution-engine';
import type { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src/backtest/PostgresBacktestRunRepository';
import type {
BacktestRunRepository,
UnavailableBacktestRunRepository,
} from '../../apps/stock/orchestrator/src/backtest/run-repository';
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
function canonicalDependencies(
engine: BacktestExecutionEngine,
legacy: Pick<BacktestExecutionEngine, 'on' | 'off' | 'stopBacktest' | 'getStatus' | 'shutdown'>,
repository: BacktestRunRepository,
withoutReplay: Omit<BacktestExecutionEngine, 'runCanonical'>,
withoutClaim: Omit<BacktestRunRepository, 'startCanonical'>,
withoutDataset: Omit<BacktestRunRepository, 'loadCanonicalDataset'>,
withoutCompletion: Omit<BacktestRunRepository, 'completeCanonical'>
) {
const logger = { error() {} };
new BacktestRunner({ engine, repository, logger });
// @ts-expect-error Canonical replay is mandatory; a legacy playback engine is insufficient.
new BacktestRunner({ engine: legacy, repository, logger });
// @ts-expect-error The current runner cannot be composed without canonical execution.
new BacktestRunner({ engine: withoutReplay, repository, logger });
// @ts-expect-error Canonical claim custody is mandatory.
new BacktestRunner({ engine, repository: withoutClaim, logger });
// @ts-expect-error Retained canonical dataset loading is mandatory.
new BacktestRunner({ engine, repository: withoutDataset, logger });
// @ts-expect-error Canonical completion persistence is mandatory.
new BacktestRunner({ engine, repository: withoutCompletion, logger });
// @ts-expect-error Current execution does not accept provider storage dependencies.
new RustBacktestAdapter({ logger, storage: { getHistoricalBars: async () => [] } });
// @ts-expect-error The canonical runner cannot select a competing engine by name.
new BacktestRunner({ engine, repository, logger, engineName: 'typescript' });
}
void canonicalDependencies;
function canonicalRepositorySurface(
repository: PostgresBacktestRunRepository,
unavailable: UnavailableBacktestRunRepository
) {
// @ts-expect-error Legacy claim/create is an explicit compatibility-only capability.
repository.start;
// @ts-expect-error Production cannot perform legacy provider lookup/pinning.
repository.loadDataset;
// @ts-expect-error Admission already binds canonical datasets.
repository.freezeDataset;
// @ts-expect-error Production cannot persist an independent legacy financial result.
repository.complete;
// @ts-expect-error Playback controls are retained only by the compatibility writer.
repository.updateControl;
// @ts-expect-error Shared completion fences are not public writer capabilities.
repository.markComplete;
// @ts-expect-error Shared transaction locks are protected, not public.
repository.ownedTransaction;
// @ts-expect-error The unavailable production implementation has the same canonical surface.
unavailable.start;
}
void canonicalRepositorySurface;