feat(research): cut over canonical runtime and enforce agent budgets
This commit is contained in:
parent
ab08db82fd
commit
bbf0dd4453
103 changed files with 6138 additions and 3112 deletions
|
|
@ -16,6 +16,7 @@ import type {
|
|||
ValidationResultEvidence,
|
||||
} from '@stock-bot/stock-config/chronological-validation';
|
||||
import type { ExperimentPreview } from '@stock-bot/stock-config/experiments';
|
||||
import type { ResearchActor } from '@stock-bot/types';
|
||||
import { HistoricalDataRequestError } from '@stock-bot/types';
|
||||
import { validateDatasetV2 } from '../../../orchestrator/src/data/historical-dataset-v2';
|
||||
import { BacktestServiceV2 } from './backtest-v2.service';
|
||||
|
|
@ -28,6 +29,7 @@ import {
|
|||
experimentTrialRequest,
|
||||
} from './experiment-input';
|
||||
import { ExperimentsService } from './experiments.service';
|
||||
import { lockExperimentResearchAgent, lockResearchAgent } from './research-agent-budget';
|
||||
import { RunReproductionError, verifyReproductionInputs } from './run-reproduction';
|
||||
import {
|
||||
parseValidationFinalization,
|
||||
|
|
@ -89,6 +91,7 @@ export class ChronologicalValidationService {
|
|||
submission,
|
||||
});
|
||||
return this.database.transaction(async client => {
|
||||
await lockResearchAgent(client, identity.principal);
|
||||
const replay = async () => {
|
||||
const row = (
|
||||
await client.query(
|
||||
|
|
@ -144,7 +147,7 @@ export class ChronologicalValidationService {
|
|||
prepared: ReturnType<typeof prepareChronologicalValidation>,
|
||||
identity: {
|
||||
id: string;
|
||||
principal: 'operator' | 'service';
|
||||
principal: ResearchActor;
|
||||
key: string;
|
||||
hash: string;
|
||||
membership?: { id: string; index: number };
|
||||
|
|
@ -225,12 +228,14 @@ export class ChronologicalValidationService {
|
|||
const operation = 'select-and-admit-holdouts' as const;
|
||||
const hash = experimentHash({ version: 1, operation, validationId: id, input });
|
||||
return this.database.transaction(async client => {
|
||||
await lockResearchAgent(client, identity.principal);
|
||||
const replay = () =>
|
||||
this.actionReplay(client, 'validation_selection', operation, identity, hash);
|
||||
const prior = await replay();
|
||||
if (prior) {
|
||||
return prior;
|
||||
}
|
||||
await lockExperimentResearchAgent(client, id, identity.principal, true);
|
||||
const { root, parent } = await this.lockRoot(client, id);
|
||||
const concurrent = await replay();
|
||||
if (concurrent) {
|
||||
|
|
@ -357,6 +362,7 @@ export class ChronologicalValidationService {
|
|||
const operation = 'finalize-report' as const,
|
||||
hash = experimentHash({ version: 1, operation, validationId: id, input });
|
||||
return this.database.transaction(async client => {
|
||||
await lockResearchAgent(client, identity.principal);
|
||||
const replay = () =>
|
||||
this.actionReplay(client, 'validation_report', operation, identity, hash);
|
||||
const prior = await replay();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue