fix(research): accept automatic candidate publication lineage (RP16)

This commit is contained in:
Boki 2026-10-27 17:10:22 -04:00
parent e3d6512b8f
commit cc49f0389c
3 changed files with 157 additions and 2 deletions

View file

@ -253,6 +253,50 @@ async function fixture() {
}
describe.skipIf(!url)('AI research workflow through authenticated APIs and Rust', () => {
test('candidate revisions retain automatic and explicit lineage across delayed receipt replay', async () => {
const f = await fixture();
const family = await f.client.createStrategy({
name: 'Refined candidate',
description: 'Successive revisions and a delayed publication receipt',
});
const pkg = f.suggestions().candidates[0]!.package;
const first = await f.client.publishVersion(family.id, pkg, 'lineage:first');
expect(first).toMatchObject({
ordinal: 1,
parentVersionId: null,
createdBy: f.provisioned.agent.id,
});
const second = await f.client.publishVersion(family.id, pkg, 'lineage:second');
expect(second).toMatchObject({ ordinal: 2, parentVersionId: first.id });
const third = await f.client.publishVersion(family.id, pkg, 'lineage:third', null);
expect(third).toMatchObject({ ordinal: 3, parentVersionId: second.id });
// An explicit branch parent remains binding even when another version is latest.
const branch = await f.client.publishVersion(family.id, pkg, 'lineage:branch', first.id);
expect(branch).toMatchObject({ ordinal: 4, parentVersionId: first.id });
const replayed = await f.client.publishVersion(family.id, pkg, 'lineage:second');
expect(replayed).toEqual(second);
const publications = f.requests.filter(
request => request.path === `/api/v2/strategies/${family.id}/versions`
);
expect(publications).toHaveLength(5);
expect(
publications.every(request => request.status === 201 && request.method === 'POST')
).toBeTrue();
expect(publications[1]).toEqual(publications[4]!);
expect(publications[1]!.body).toEqual({ package: pkg, parentVersionId: null });
expect(publications[3]!.body).toEqual({ package: pkg, parentVersionId: first.id });
expect(
(
await f.pool.query(
'SELECT count(*)::int AS count FROM strategy_versions WHERE strategy_id=$1',
[family.id]
)
).rows[0].count
).toBe(4);
expect((await f.pool.query('SELECT count(*)::int AS count FROM runs')).rows[0].count).toBe(0);
expect(f.executionErrors).toEqual([]);
});
test('two generated candidates, train-only selection, costs, exact saved evidence and a retained failure', async () => {
const f = await fixture();
const events: ResearchCycleEvent[] = [];