fix(research): honor retained candidate parameter defaults (RP17)
This commit is contained in:
parent
f185f2e253
commit
1502ab41dc
9 changed files with 727 additions and 7 deletions
|
|
@ -68,6 +68,7 @@ async function fixture() {
|
|||
'28-research-agents.sql',
|
||||
'29-isolated-candidates.sql',
|
||||
'31-research-agent-project-links.sql',
|
||||
'32-candidate-parameter-defaults.sql',
|
||||
]) {
|
||||
await pool.query(
|
||||
readFileSync(new URL(`../../database/postgres/init/${name}`, import.meta.url), 'utf8')
|
||||
|
|
@ -211,7 +212,8 @@ async function fixture() {
|
|||
name: 'Trend candidate',
|
||||
rationale: 'Short/long trend signals',
|
||||
package: trend,
|
||||
parameters: { fastPeriod: 2, slowPeriod: 3 },
|
||||
// Exercise default expansion throughout training, holdouts and saved evidence.
|
||||
parameters: { slowPeriod: 6 },
|
||||
grid: { fastPeriod: [1, 2] },
|
||||
},
|
||||
{
|
||||
|
|
@ -253,6 +255,64 @@ async function fixture() {
|
|||
}
|
||||
|
||||
describe.skipIf(!url)('AI research workflow through authenticated APIs and Rust', () => {
|
||||
test('defaulted candidate validation accepts, reopens and replays the exact original input', async () => {
|
||||
const f = await fixture();
|
||||
const plan = f.suggestions();
|
||||
const family = await f.client.createStrategy({
|
||||
name: 'Defaulted validation candidate',
|
||||
description: 'Omitted and partial parameter defaults',
|
||||
});
|
||||
const version = await f.client.publishVersion(
|
||||
family.id,
|
||||
plan.candidates[0]!.package,
|
||||
'defaults:version'
|
||||
);
|
||||
const cases: { parameters: Record<string, number>; normalized: Record<string, number> }[] = [
|
||||
{ parameters: {}, normalized: { fastPeriod: 5, slowPeriod: 15 } },
|
||||
{ parameters: { slowPeriod: 6 }, normalized: { fastPeriod: 5, slowPeriod: 6 } },
|
||||
];
|
||||
for (const [index, item] of cases.entries()) {
|
||||
const input = {
|
||||
backtestId: plan.backtestId,
|
||||
name: `Defaulted candidate ${index}`,
|
||||
candidate: { versionId: version.id, parameters: item.parameters },
|
||||
grid: {},
|
||||
recipe: plan.candidates[0]!.recipe,
|
||||
};
|
||||
const preview = await f.client.previewValidation(input);
|
||||
expect(preview.input).toEqual(input);
|
||||
expect(preview.partitions[0].request.strategy.selection.parameters).toEqual(item.normalized);
|
||||
const submission = { ...preview.input, previewHash: preview.previewHash };
|
||||
const key = `defaults:validation:${index}`;
|
||||
const saved = await f.client.submitValidation(submission, key);
|
||||
expect(saved.preview.input).toEqual(input);
|
||||
expect(saved.phases[0]!.experiment!.preview.input.candidate).toEqual({
|
||||
versionId: version.id,
|
||||
parameters: item.normalized,
|
||||
});
|
||||
const reopened = await f.client.waitForValidation(saved.id, {
|
||||
timeoutMs: 60000,
|
||||
intervalMs: 20,
|
||||
});
|
||||
expect(reopened.previewHash).toBe(preview.previewHash);
|
||||
expect(reopened.preview.input).toEqual(input);
|
||||
expect(reopened.phases[0]!.experiment!.trials[0]!.status).toBe('completed');
|
||||
const replayed = await f.client.submitValidation(submission, key);
|
||||
expect(replayed.id).toBe(saved.id);
|
||||
expect(replayed.previewHash).toBe(preview.previewHash);
|
||||
expect(replayed.phases[0]!.experiment!.trials[0]!.runId).toBe(
|
||||
reopened.phases[0]!.experiment!.trials[0]!.runId!
|
||||
);
|
||||
const writes = f.requests.filter(request => request.key === key);
|
||||
expect(writes).toHaveLength(2);
|
||||
expect(writes[0]).toEqual(writes[1]!);
|
||||
expect(writes[0]!.body).toEqual(submission);
|
||||
expect(writes[0]!.status).toBe(202);
|
||||
}
|
||||
expect((await f.pool.query('SELECT count(*)::int AS count FROM runs')).rows[0].count).toBe(2);
|
||||
expect(f.executionErrors).toEqual([]);
|
||||
}, 60000);
|
||||
|
||||
test('candidate revisions retain automatic and explicit lineage across delayed receipt replay', async () => {
|
||||
const f = await fixture();
|
||||
const family = await f.client.createStrategy({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue