T-57: M1.3b — trial_ledger + vault_evaluations append-only PostgreSQL migration (research track)

This commit is contained in:
Studio 2026-11-27 16:45:16 -05:00 • committed by Boki
parent 2ea7316af6
commit 5025286e49
8 changed files with 920 additions and 11 deletions

View file

@ -36,6 +36,7 @@ const migrations = [
'31-research-agent-project-links.sql',
'32-candidate-parameter-defaults.sql',
'33-candidate-decimal-normalization.sql',
'36-trial-ledger.sql',
];
const cleanup: (() => Promise<void>)[] = [];
afterEach(async () => {
@ -382,25 +383,30 @@ describe.skipIf(!url)('startup migrations on real PostgreSQL', () => {
'golden_field_audit',
];
// 1. research track must NOT apply 34-security-master.sql or 35-security-master-exchange-seed.sql;
// master track applies both in order and is idempotent on re-run.
// 1. research track must NOT apply 34-security-master.sql or 35-security-master-exchange-seed.sql,
// and MUST apply 36-trial-ledger.sql; master track applies 34-35 (not 36) and is idempotent on re-run.
const f1 = await fixture();
const runner1 = f1.startup();
const researchApplied = await runner1.runTrack('research');
expect(researchApplied).not.toContain('34-security-master.sql');
expect(researchApplied).not.toContain('35-security-master-exchange-seed.sql');
expect(researchApplied).toContain('36-trial-ledger.sql');
const recordedAfterResearch = await f1.recorded();
expect(recordedAfterResearch).not.toContain('34-security-master.sql');
expect(recordedAfterResearch).not.toContain('35-security-master-exchange-seed.sql');
expect(recordedAfterResearch).toContain('36-trial-ledger.sql');
const tablesAfterResearch = new Set(await f1.relations());
for (const table of securityMasterTables) {
expect(tablesAfterResearch.has(table)).toBe(false);
}
expect(tablesAfterResearch.has('trial_ledger')).toBe(true);
expect(tablesAfterResearch.has('vault_evaluations')).toBe(true);
const masterApplied = await runner1.runTrack('master');
expect(masterApplied).toContain('34-security-master.sql');
expect(masterApplied).toContain('35-security-master-exchange-seed.sql');
expect(masterApplied).not.toContain('36-trial-ledger.sql');
expect(masterApplied.indexOf('35-security-master-exchange-seed.sql')).toBe(
masterApplied.indexOf('34-security-master.sql') + 1
);
@ -415,7 +421,7 @@ describe.skipIf(!url)('startup migrations on real PostgreSQL', () => {
expect(await runner1.runTrack('master')).toEqual([]);
// 2. all track applies 34 and 35 alongside 01-05 and 09-33 and is idempotent.
// 2. all track applies 34, 35, and 36 alongside 01-05 and 09-33 and is idempotent.
const f2 = await fixture();
const runner2 = f2.startup();
const allApplied = await runner2.runTrack('all');
@ -425,14 +431,18 @@ describe.skipIf(!url)('startup migrations on real PostgreSQL', () => {
expect(allApplied).toContain('33-candidate-decimal-normalization.sql');
expect(allApplied).toContain('34-security-master.sql');
expect(allApplied).toContain('35-security-master-exchange-seed.sql');
expect(allApplied).toContain('36-trial-ledger.sql');
const recordedAfterAll = await f2.recorded();
expect(recordedAfterAll).toContain('34-security-master.sql');
expect(recordedAfterAll).toContain('35-security-master-exchange-seed.sql');
expect(recordedAfterAll).toContain('36-trial-ledger.sql');
const tablesAfterAll = new Set(await f2.relations());
for (const table of securityMasterTables) {
expect(tablesAfterAll.has(table)).toBe(true);
}
expect(tablesAfterAll.has('trial_ledger')).toBe(true);
expect(tablesAfterAll.has('vault_evaluations')).toBe(true);
expect(await runner2.runTrack('all')).toEqual([]);
});