refactor(runtime): expose shared admission and artifact boundaries (CL26)
This commit is contained in:
parent
2165a2efa8
commit
b4589d5af1
49 changed files with 1790 additions and 1565 deletions
|
|
@ -1,10 +1,2 @@
|
|||
import { setImmediate } from 'node:timers/promises';
|
||||
|
||||
export const PREPARATION_BATCH_SIZE = 2048;
|
||||
|
||||
/** Yield to cancellation, timeouts and lease heartbeats between bounded CPU batches. */
|
||||
export async function preparationCheckpoint(signal?: AbortSignal): Promise<void> {
|
||||
signal?.throwIfAborted();
|
||||
await setImmediate();
|
||||
signal?.throwIfAborted();
|
||||
}
|
||||
/** Compatibility entrypoint; implementation is shared by the API and orchestrator. */
|
||||
export * from '@stock-bot/trading-runtime/preparation';
|
||||
|
|
|
|||
|
|
@ -1,23 +1,2 @@
|
|||
import { validateDatasetV2 } from './historical-dataset-v2';
|
||||
|
||||
export interface RetainedDatasetStore {
|
||||
query(text: string, values?: unknown[]): Promise<{ rows: Record<string, unknown>[] }>;
|
||||
}
|
||||
|
||||
/** Content-addressed custody shared by explicit CLI import and web source preparation. */
|
||||
export async function retainResearchDataset(database: RetainedDatasetStore, input: unknown) {
|
||||
const dataset = validateDatasetV2(input);
|
||||
await database.query(
|
||||
'INSERT INTO backtest_datasets(hash,payload) VALUES($1,$2::jsonb) ON CONFLICT(hash) DO NOTHING',
|
||||
[dataset.manifest.hash, JSON.stringify(dataset)]
|
||||
);
|
||||
const stored = (
|
||||
await database.query('SELECT payload FROM backtest_datasets WHERE hash=$1', [
|
||||
dataset.manifest.hash,
|
||||
])
|
||||
).rows[0];
|
||||
if (!stored || validateDatasetV2(stored.payload).manifest.hash !== dataset.manifest.hash) {
|
||||
throw new Error('Retained dataset content does not match the imported identity');
|
||||
}
|
||||
return dataset.manifest;
|
||||
}
|
||||
/** Compatibility entrypoint; implementation is shared by the API and orchestrator. */
|
||||
export * from '@stock-bot/trading-runtime/retained-dataset';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue